You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1608 lines
49 KiB

1 year ago
  1. /******/ (function() { // webpackBootstrap
  2. /******/ var __webpack_modules__ = ({
  3. /***/ 124:
  4. /***/ (function(module, exports, __webpack_require__) {
  5. var __WEBPACK_AMD_DEFINE_RESULT__;/* global window, exports, define */
  6. !function() {
  7. 'use strict'
  8. var re = {
  9. not_string: /[^s]/,
  10. not_bool: /[^t]/,
  11. not_type: /[^T]/,
  12. not_primitive: /[^v]/,
  13. number: /[diefg]/,
  14. numeric_arg: /[bcdiefguxX]/,
  15. json: /[j]/,
  16. not_json: /[^j]/,
  17. text: /^[^\x25]+/,
  18. modulo: /^\x25{2}/,
  19. placeholder: /^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,
  20. key: /^([a-z_][a-z_\d]*)/i,
  21. key_access: /^\.([a-z_][a-z_\d]*)/i,
  22. index_access: /^\[(\d+)\]/,
  23. sign: /^[+-]/
  24. }
  25. function sprintf(key) {
  26. // `arguments` is not an array, but should be fine for this call
  27. return sprintf_format(sprintf_parse(key), arguments)
  28. }
  29. function vsprintf(fmt, argv) {
  30. return sprintf.apply(null, [fmt].concat(argv || []))
  31. }
  32. function sprintf_format(parse_tree, argv) {
  33. var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, ph, pad, pad_character, pad_length, is_positive, sign
  34. for (i = 0; i < tree_length; i++) {
  35. if (typeof parse_tree[i] === 'string') {
  36. output += parse_tree[i]
  37. }
  38. else if (typeof parse_tree[i] === 'object') {
  39. ph = parse_tree[i] // convenience purposes only
  40. if (ph.keys) { // keyword argument
  41. arg = argv[cursor]
  42. for (k = 0; k < ph.keys.length; k++) {
  43. if (arg == undefined) {
  44. throw new Error(sprintf('[sprintf] Cannot access property "%s" of undefined value "%s"', ph.keys[k], ph.keys[k-1]))
  45. }
  46. arg = arg[ph.keys[k]]
  47. }
  48. }
  49. else if (ph.param_no) { // positional argument (explicit)
  50. arg = argv[ph.param_no]
  51. }
  52. else { // positional argument (implicit)
  53. arg = argv[cursor++]
  54. }
  55. if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) {
  56. arg = arg()
  57. }
  58. if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) {
  59. throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg))
  60. }
  61. if (re.number.test(ph.type)) {
  62. is_positive = arg >= 0
  63. }
  64. switch (ph.type) {
  65. case 'b':
  66. arg = parseInt(arg, 10).toString(2)
  67. break
  68. case 'c':
  69. arg = String.fromCharCode(parseInt(arg, 10))
  70. break
  71. case 'd':
  72. case 'i':
  73. arg = parseInt(arg, 10)
  74. break
  75. case 'j':
  76. arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0)
  77. break
  78. case 'e':
  79. arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential()
  80. break
  81. case 'f':
  82. arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg)
  83. break
  84. case 'g':
  85. arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg)
  86. break
  87. case 'o':
  88. arg = (parseInt(arg, 10) >>> 0).toString(8)
  89. break
  90. case 's':
  91. arg = String(arg)
  92. arg = (ph.precision ? arg.substring(0, ph.precision) : arg)
  93. break
  94. case 't':
  95. arg = String(!!arg)
  96. arg = (ph.precision ? arg.substring(0, ph.precision) : arg)
  97. break
  98. case 'T':
  99. arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase()
  100. arg = (ph.precision ? arg.substring(0, ph.precision) : arg)
  101. break
  102. case 'u':
  103. arg = parseInt(arg, 10) >>> 0
  104. break
  105. case 'v':
  106. arg = arg.valueOf()
  107. arg = (ph.precision ? arg.substring(0, ph.precision) : arg)
  108. break
  109. case 'x':
  110. arg = (parseInt(arg, 10) >>> 0).toString(16)
  111. break
  112. case 'X':
  113. arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase()
  114. break
  115. }
  116. if (re.json.test(ph.type)) {
  117. output += arg
  118. }
  119. else {
  120. if (re.number.test(ph.type) && (!is_positive || ph.sign)) {
  121. sign = is_positive ? '+' : '-'
  122. arg = arg.toString().replace(re.sign, '')
  123. }
  124. else {
  125. sign = ''
  126. }
  127. pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' '
  128. pad_length = ph.width - (sign + arg).length
  129. pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : ''
  130. output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg)
  131. }
  132. }
  133. }
  134. return output
  135. }
  136. var sprintf_cache = Object.create(null)
  137. function sprintf_parse(fmt) {
  138. if (sprintf_cache[fmt]) {
  139. return sprintf_cache[fmt]
  140. }
  141. var _fmt = fmt, match, parse_tree = [], arg_names = 0
  142. while (_fmt) {
  143. if ((match = re.text.exec(_fmt)) !== null) {
  144. parse_tree.push(match[0])
  145. }
  146. else if ((match = re.modulo.exec(_fmt)) !== null) {
  147. parse_tree.push('%')
  148. }
  149. else if ((match = re.placeholder.exec(_fmt)) !== null) {
  150. if (match[2]) {
  151. arg_names |= 1
  152. var field_list = [], replacement_field = match[2], field_match = []
  153. if ((field_match = re.key.exec(replacement_field)) !== null) {
  154. field_list.push(field_match[1])
  155. while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
  156. if ((field_match = re.key_access.exec(replacement_field)) !== null) {
  157. field_list.push(field_match[1])
  158. }
  159. else if ((field_match = re.index_access.exec(replacement_field)) !== null) {
  160. field_list.push(field_match[1])
  161. }
  162. else {
  163. throw new SyntaxError('[sprintf] failed to parse named argument key')
  164. }
  165. }
  166. }
  167. else {
  168. throw new SyntaxError('[sprintf] failed to parse named argument key')
  169. }
  170. match[2] = field_list
  171. }
  172. else {
  173. arg_names |= 2
  174. }
  175. if (arg_names === 3) {
  176. throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported')
  177. }
  178. parse_tree.push(
  179. {
  180. placeholder: match[0],
  181. param_no: match[1],
  182. keys: match[2],
  183. sign: match[3],
  184. pad_char: match[4],
  185. align: match[5],
  186. width: match[6],
  187. precision: match[7],
  188. type: match[8]
  189. }
  190. )
  191. }
  192. else {
  193. throw new SyntaxError('[sprintf] unexpected placeholder')
  194. }
  195. _fmt = _fmt.substring(match[0].length)
  196. }
  197. return sprintf_cache[fmt] = parse_tree
  198. }
  199. /**
  200. * export to either browser or node.js
  201. */
  202. /* eslint-disable quote-props */
  203. if (true) {
  204. exports.sprintf = sprintf
  205. exports.vsprintf = vsprintf
  206. }
  207. if (typeof window !== 'undefined') {
  208. window['sprintf'] = sprintf
  209. window['vsprintf'] = vsprintf
  210. if (true) {
  211. !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() {
  212. return {
  213. 'sprintf': sprintf,
  214. 'vsprintf': vsprintf
  215. }
  216. }).call(exports, __webpack_require__, exports, module),
  217. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__))
  218. }
  219. }
  220. /* eslint-enable quote-props */
  221. }(); // eslint-disable-line
  222. /***/ })
  223. /******/ });
  224. /************************************************************************/
  225. /******/ // The module cache
  226. /******/ var __webpack_module_cache__ = {};
  227. /******/
  228. /******/ // The require function
  229. /******/ function __webpack_require__(moduleId) {
  230. /******/ // Check if module is in cache
  231. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  232. /******/ if (cachedModule !== undefined) {
  233. /******/ return cachedModule.exports;
  234. /******/ }
  235. /******/ // Create a new module (and put it into the cache)
  236. /******/ var module = __webpack_module_cache__[moduleId] = {
  237. /******/ // no module.id needed
  238. /******/ // no module.loaded needed
  239. /******/ exports: {}
  240. /******/ };
  241. /******/
  242. /******/ // Execute the module function
  243. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  244. /******/
  245. /******/ // Return the exports of the module
  246. /******/ return module.exports;
  247. /******/ }
  248. /******/
  249. /************************************************************************/
  250. /******/ /* webpack/runtime/compat get default export */
  251. /******/ !function() {
  252. /******/ // getDefaultExport function for compatibility with non-harmony modules
  253. /******/ __webpack_require__.n = function(module) {
  254. /******/ var getter = module && module.__esModule ?
  255. /******/ function() { return module['default']; } :
  256. /******/ function() { return module; };
  257. /******/ __webpack_require__.d(getter, { a: getter });
  258. /******/ return getter;
  259. /******/ };
  260. /******/ }();
  261. /******/
  262. /******/ /* webpack/runtime/define property getters */
  263. /******/ !function() {
  264. /******/ // define getter functions for harmony exports
  265. /******/ __webpack_require__.d = function(exports, definition) {
  266. /******/ for(var key in definition) {
  267. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  268. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  269. /******/ }
  270. /******/ }
  271. /******/ };
  272. /******/ }();
  273. /******/
  274. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  275. /******/ !function() {
  276. /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
  277. /******/ }();
  278. /******/
  279. /******/ /* webpack/runtime/make namespace object */
  280. /******/ !function() {
  281. /******/ // define __esModule on exports
  282. /******/ __webpack_require__.r = function(exports) {
  283. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  284. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  285. /******/ }
  286. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  287. /******/ };
  288. /******/ }();
  289. /******/
  290. /************************************************************************/
  291. var __webpack_exports__ = {};
  292. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  293. !function() {
  294. "use strict";
  295. // ESM COMPAT FLAG
  296. __webpack_require__.r(__webpack_exports__);
  297. // EXPORTS
  298. __webpack_require__.d(__webpack_exports__, {
  299. __: function() { return /* reexport */ __; },
  300. _n: function() { return /* reexport */ _n; },
  301. _nx: function() { return /* reexport */ _nx; },
  302. _x: function() { return /* reexport */ _x; },
  303. createI18n: function() { return /* reexport */ createI18n; },
  304. defaultI18n: function() { return /* reexport */ default_i18n; },
  305. getLocaleData: function() { return /* reexport */ getLocaleData; },
  306. hasTranslation: function() { return /* reexport */ hasTranslation; },
  307. isRTL: function() { return /* reexport */ isRTL; },
  308. resetLocaleData: function() { return /* reexport */ resetLocaleData; },
  309. setLocaleData: function() { return /* reexport */ setLocaleData; },
  310. sprintf: function() { return /* reexport */ sprintf_sprintf; },
  311. subscribe: function() { return /* reexport */ subscribe; }
  312. });
  313. ;// CONCATENATED MODULE: ./node_modules/memize/dist/index.js
  314. /**
  315. * Memize options object.
  316. *
  317. * @typedef MemizeOptions
  318. *
  319. * @property {number} [maxSize] Maximum size of the cache.
  320. */
  321. /**
  322. * Internal cache entry.
  323. *
  324. * @typedef MemizeCacheNode
  325. *
  326. * @property {?MemizeCacheNode|undefined} [prev] Previous node.
  327. * @property {?MemizeCacheNode|undefined} [next] Next node.
  328. * @property {Array<*>} args Function arguments for cache
  329. * entry.
  330. * @property {*} val Function result.
  331. */
  332. /**
  333. * Properties of the enhanced function for controlling cache.
  334. *
  335. * @typedef MemizeMemoizedFunction
  336. *
  337. * @property {()=>void} clear Clear the cache.
  338. */
  339. /**
  340. * Accepts a function to be memoized, and returns a new memoized function, with
  341. * optional options.
  342. *
  343. * @template {(...args: any[]) => any} F
  344. *
  345. * @param {F} fn Function to memoize.
  346. * @param {MemizeOptions} [options] Options object.
  347. *
  348. * @return {((...args: Parameters<F>) => ReturnType<F>) & MemizeMemoizedFunction} Memoized function.
  349. */
  350. function memize(fn, options) {
  351. var size = 0;
  352. /** @type {?MemizeCacheNode|undefined} */
  353. var head;
  354. /** @type {?MemizeCacheNode|undefined} */
  355. var tail;
  356. options = options || {};
  357. function memoized(/* ...args */) {
  358. var node = head,
  359. len = arguments.length,
  360. args,
  361. i;
  362. searchCache: while (node) {
  363. // Perform a shallow equality test to confirm that whether the node
  364. // under test is a candidate for the arguments passed. Two arrays
  365. // are shallowly equal if their length matches and each entry is
  366. // strictly equal between the two sets. Avoid abstracting to a
  367. // function which could incur an arguments leaking deoptimization.
  368. // Check whether node arguments match arguments length
  369. if (node.args.length !== arguments.length) {
  370. node = node.next;
  371. continue;
  372. }
  373. // Check whether node arguments match arguments values
  374. for (i = 0; i < len; i++) {
  375. if (node.args[i] !== arguments[i]) {
  376. node = node.next;
  377. continue searchCache;
  378. }
  379. }
  380. // At this point we can assume we've found a match
  381. // Surface matched node to head if not already
  382. if (node !== head) {
  383. // As tail, shift to previous. Must only shift if not also
  384. // head, since if both head and tail, there is no previous.
  385. if (node === tail) {
  386. tail = node.prev;
  387. }
  388. // Adjust siblings to point to each other. If node was tail,
  389. // this also handles new tail's empty `next` assignment.
  390. /** @type {MemizeCacheNode} */ (node.prev).next = node.next;
  391. if (node.next) {
  392. node.next.prev = node.prev;
  393. }
  394. node.next = head;
  395. node.prev = null;
  396. /** @type {MemizeCacheNode} */ (head).prev = node;
  397. head = node;
  398. }
  399. // Return immediately
  400. return node.val;
  401. }
  402. // No cached value found. Continue to insertion phase:
  403. // Create a copy of arguments (avoid leaking deoptimization)
  404. args = new Array(len);
  405. for (i = 0; i < len; i++) {
  406. args[i] = arguments[i];
  407. }
  408. node = {
  409. args: args,
  410. // Generate the result from original function
  411. val: fn.apply(null, args),
  412. };
  413. // Don't need to check whether node is already head, since it would
  414. // have been returned above already if it was
  415. // Shift existing head down list
  416. if (head) {
  417. head.prev = node;
  418. node.next = head;
  419. } else {
  420. // If no head, follows that there's no tail (at initial or reset)
  421. tail = node;
  422. }
  423. // Trim tail if we're reached max size and are pending cache insertion
  424. if (size === /** @type {MemizeOptions} */ (options).maxSize) {
  425. tail = /** @type {MemizeCacheNode} */ (tail).prev;
  426. /** @type {MemizeCacheNode} */ (tail).next = null;
  427. } else {
  428. size++;
  429. }
  430. head = node;
  431. return node.val;
  432. }
  433. memoized.clear = function () {
  434. head = null;
  435. tail = null;
  436. size = 0;
  437. };
  438. // Ignore reason: There's not a clear solution to create an intersection of
  439. // the function with additional properties, where the goal is to retain the
  440. // function signature of the incoming argument and add control properties
  441. // on the return value.
  442. // @ts-ignore
  443. return memoized;
  444. }
  445. // EXTERNAL MODULE: ./node_modules/sprintf-js/src/sprintf.js
  446. var sprintf = __webpack_require__(124);
  447. var sprintf_default = /*#__PURE__*/__webpack_require__.n(sprintf);
  448. ;// CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/sprintf.js
  449. /**
  450. * External dependencies
  451. */
  452. /**
  453. * Log to console, once per message; or more precisely, per referentially equal
  454. * argument set. Because Jed throws errors, we log these to the console instead
  455. * to avoid crashing the application.
  456. *
  457. * @param {...*} args Arguments to pass to `console.error`
  458. */
  459. const logErrorOnce = memize(console.error); // eslint-disable-line no-console
  460. /**
  461. * Returns a formatted string. If an error occurs in applying the format, the
  462. * original format string is returned.
  463. *
  464. * @param {string} format The format of the string to generate.
  465. * @param {...*} args Arguments to apply to the format.
  466. *
  467. * @see https://www.npmjs.com/package/sprintf-js
  468. *
  469. * @return {string} The formatted string.
  470. */
  471. function sprintf_sprintf(format, ...args) {
  472. try {
  473. return sprintf_default().sprintf(format, ...args);
  474. } catch (error) {
  475. if (error instanceof Error) {
  476. logErrorOnce('sprintf error: \n\n' + error.toString());
  477. }
  478. return format;
  479. }
  480. }
  481. ;// CONCATENATED MODULE: ./node_modules/@tannin/postfix/index.js
  482. var PRECEDENCE, OPENERS, TERMINATORS, PATTERN;
  483. /**
  484. * Operator precedence mapping.
  485. *
  486. * @type {Object}
  487. */
  488. PRECEDENCE = {
  489. '(': 9,
  490. '!': 8,
  491. '*': 7,
  492. '/': 7,
  493. '%': 7,
  494. '+': 6,
  495. '-': 6,
  496. '<': 5,
  497. '<=': 5,
  498. '>': 5,
  499. '>=': 5,
  500. '==': 4,
  501. '!=': 4,
  502. '&&': 3,
  503. '||': 2,
  504. '?': 1,
  505. '?:': 1,
  506. };
  507. /**
  508. * Characters which signal pair opening, to be terminated by terminators.
  509. *
  510. * @type {string[]}
  511. */
  512. OPENERS = [ '(', '?' ];
  513. /**
  514. * Characters which signal pair termination, the value an array with the
  515. * opener as its first member. The second member is an optional operator
  516. * replacement to push to the stack.
  517. *
  518. * @type {string[]}
  519. */
  520. TERMINATORS = {
  521. ')': [ '(' ],
  522. ':': [ '?', '?:' ],
  523. };
  524. /**
  525. * Pattern matching operators and openers.
  526. *
  527. * @type {RegExp}
  528. */
  529. PATTERN = /<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;
  530. /**
  531. * Given a C expression, returns the equivalent postfix (Reverse Polish)
  532. * notation terms as an array.
  533. *
  534. * If a postfix string is desired, simply `.join( ' ' )` the result.
  535. *
  536. * @example
  537. *
  538. * ```js
  539. * import postfix from '@tannin/postfix';
  540. *
  541. * postfix( 'n > 1' );
  542. * // ⇒ [ 'n', '1', '>' ]
  543. * ```
  544. *
  545. * @param {string} expression C expression.
  546. *
  547. * @return {string[]} Postfix terms.
  548. */
  549. function postfix( expression ) {
  550. var terms = [],
  551. stack = [],
  552. match, operator, term, element;
  553. while ( ( match = expression.match( PATTERN ) ) ) {
  554. operator = match[ 0 ];
  555. // Term is the string preceding the operator match. It may contain
  556. // whitespace, and may be empty (if operator is at beginning).
  557. term = expression.substr( 0, match.index ).trim();
  558. if ( term ) {
  559. terms.push( term );
  560. }
  561. while ( ( element = stack.pop() ) ) {
  562. if ( TERMINATORS[ operator ] ) {
  563. if ( TERMINATORS[ operator ][ 0 ] === element ) {
  564. // Substitution works here under assumption that because
  565. // the assigned operator will no longer be a terminator, it
  566. // will be pushed to the stack during the condition below.
  567. operator = TERMINATORS[ operator ][ 1 ] || operator;
  568. break;
  569. }
  570. } else if ( OPENERS.indexOf( element ) >= 0 || PRECEDENCE[ element ] < PRECEDENCE[ operator ] ) {
  571. // Push to stack if either an opener or when pop reveals an
  572. // element of lower precedence.
  573. stack.push( element );
  574. break;
  575. }
  576. // For each popped from stack, push to terms.
  577. terms.push( element );
  578. }
  579. if ( ! TERMINATORS[ operator ] ) {
  580. stack.push( operator );
  581. }
  582. // Slice matched fragment from expression to continue match.
  583. expression = expression.substr( match.index + operator.length );
  584. }
  585. // Push remainder of operand, if exists, to terms.
  586. expression = expression.trim();
  587. if ( expression ) {
  588. terms.push( expression );
  589. }
  590. // Pop remaining items from stack into terms.
  591. return terms.concat( stack.reverse() );
  592. }
  593. ;// CONCATENATED MODULE: ./node_modules/@tannin/evaluate/index.js
  594. /**
  595. * Operator callback functions.
  596. *
  597. * @type {Object}
  598. */
  599. var OPERATORS = {
  600. '!': function( a ) {
  601. return ! a;
  602. },
  603. '*': function( a, b ) {
  604. return a * b;
  605. },
  606. '/': function( a, b ) {
  607. return a / b;
  608. },
  609. '%': function( a, b ) {
  610. return a % b;
  611. },
  612. '+': function( a, b ) {
  613. return a + b;
  614. },
  615. '-': function( a, b ) {
  616. return a - b;
  617. },
  618. '<': function( a, b ) {
  619. return a < b;
  620. },
  621. '<=': function( a, b ) {
  622. return a <= b;
  623. },
  624. '>': function( a, b ) {
  625. return a > b;
  626. },
  627. '>=': function( a, b ) {
  628. return a >= b;
  629. },
  630. '==': function( a, b ) {
  631. return a === b;
  632. },
  633. '!=': function( a, b ) {
  634. return a !== b;
  635. },
  636. '&&': function( a, b ) {
  637. return a && b;
  638. },
  639. '||': function( a, b ) {
  640. return a || b;
  641. },
  642. '?:': function( a, b, c ) {
  643. if ( a ) {
  644. throw b;
  645. }
  646. return c;
  647. },
  648. };
  649. /**
  650. * Given an array of postfix terms and operand variables, returns the result of
  651. * the postfix evaluation.
  652. *
  653. * @example
  654. *
  655. * ```js
  656. * import evaluate from '@tannin/evaluate';
  657. *
  658. * // 3 + 4 * 5 / 6 ⇒ '3 4 5 * 6 / +'
  659. * const terms = [ '3', '4', '5', '*', '6', '/', '+' ];
  660. *
  661. * evaluate( terms, {} );
  662. * // ⇒ 6.333333333333334
  663. * ```
  664. *
  665. * @param {string[]} postfix Postfix terms.
  666. * @param {Object} variables Operand variables.
  667. *
  668. * @return {*} Result of evaluation.
  669. */
  670. function evaluate( postfix, variables ) {
  671. var stack = [],
  672. i, j, args, getOperatorResult, term, value;
  673. for ( i = 0; i < postfix.length; i++ ) {
  674. term = postfix[ i ];
  675. getOperatorResult = OPERATORS[ term ];
  676. if ( getOperatorResult ) {
  677. // Pop from stack by number of function arguments.
  678. j = getOperatorResult.length;
  679. args = Array( j );
  680. while ( j-- ) {
  681. args[ j ] = stack.pop();
  682. }
  683. try {
  684. value = getOperatorResult.apply( null, args );
  685. } catch ( earlyReturn ) {
  686. return earlyReturn;
  687. }
  688. } else if ( variables.hasOwnProperty( term ) ) {
  689. value = variables[ term ];
  690. } else {
  691. value = +term;
  692. }
  693. stack.push( value );
  694. }
  695. return stack[ 0 ];
  696. }
  697. ;// CONCATENATED MODULE: ./node_modules/@tannin/compile/index.js
  698. /**
  699. * Given a C expression, returns a function which can be called to evaluate its
  700. * result.
  701. *
  702. * @example
  703. *
  704. * ```js
  705. * import compile from '@tannin/compile';
  706. *
  707. * const evaluate = compile( 'n > 1' );
  708. *
  709. * evaluate( { n: 2 } );
  710. * // ⇒ true
  711. * ```
  712. *
  713. * @param {string} expression C expression.
  714. *
  715. * @return {(variables?:{[variable:string]:*})=>*} Compiled evaluator.
  716. */
  717. function compile( expression ) {
  718. var terms = postfix( expression );
  719. return function( variables ) {
  720. return evaluate( terms, variables );
  721. };
  722. }
  723. ;// CONCATENATED MODULE: ./node_modules/@tannin/plural-forms/index.js
  724. /**
  725. * Given a C expression, returns a function which, when called with a value,
  726. * evaluates the result with the value assumed to be the "n" variable of the
  727. * expression. The result will be coerced to its numeric equivalent.
  728. *
  729. * @param {string} expression C expression.
  730. *
  731. * @return {Function} Evaluator function.
  732. */
  733. function pluralForms( expression ) {
  734. var evaluate = compile( expression );
  735. return function( n ) {
  736. return +evaluate( { n: n } );
  737. };
  738. }
  739. ;// CONCATENATED MODULE: ./node_modules/tannin/index.js
  740. /**
  741. * Tannin constructor options.
  742. *
  743. * @typedef {Object} TanninOptions
  744. *
  745. * @property {string} [contextDelimiter] Joiner in string lookup with context.
  746. * @property {Function} [onMissingKey] Callback to invoke when key missing.
  747. */
  748. /**
  749. * Domain metadata.
  750. *
  751. * @typedef {Object} TanninDomainMetadata
  752. *
  753. * @property {string} [domain] Domain name.
  754. * @property {string} [lang] Language code.
  755. * @property {(string|Function)} [plural_forms] Plural forms expression or
  756. * function evaluator.
  757. */
  758. /**
  759. * Domain translation pair respectively representing the singular and plural
  760. * translation.
  761. *
  762. * @typedef {[string,string]} TanninTranslation
  763. */
  764. /**
  765. * Locale data domain. The key is used as reference for lookup, the value an
  766. * array of two string entries respectively representing the singular and plural
  767. * translation.
  768. *
  769. * @typedef {{[key:string]:TanninDomainMetadata|TanninTranslation,'':TanninDomainMetadata|TanninTranslation}} TanninLocaleDomain
  770. */
  771. /**
  772. * Jed-formatted locale data.
  773. *
  774. * @see http://messageformat.github.io/Jed/
  775. *
  776. * @typedef {{[domain:string]:TanninLocaleDomain}} TanninLocaleData
  777. */
  778. /**
  779. * Default Tannin constructor options.
  780. *
  781. * @type {TanninOptions}
  782. */
  783. var DEFAULT_OPTIONS = {
  784. contextDelimiter: '\u0004',
  785. onMissingKey: null,
  786. };
  787. /**
  788. * Given a specific locale data's config `plural_forms` value, returns the
  789. * expression.
  790. *
  791. * @example
  792. *
  793. * ```
  794. * getPluralExpression( 'nplurals=2; plural=(n != 1);' ) === '(n != 1)'
  795. * ```
  796. *
  797. * @param {string} pf Locale data plural forms.
  798. *
  799. * @return {string} Plural forms expression.
  800. */
  801. function getPluralExpression( pf ) {
  802. var parts, i, part;
  803. parts = pf.split( ';' );
  804. for ( i = 0; i < parts.length; i++ ) {
  805. part = parts[ i ].trim();
  806. if ( part.indexOf( 'plural=' ) === 0 ) {
  807. return part.substr( 7 );
  808. }
  809. }
  810. }
  811. /**
  812. * Tannin constructor.
  813. *
  814. * @class
  815. *
  816. * @param {TanninLocaleData} data Jed-formatted locale data.
  817. * @param {TanninOptions} [options] Tannin options.
  818. */
  819. function Tannin( data, options ) {
  820. var key;
  821. /**
  822. * Jed-formatted locale data.
  823. *
  824. * @name Tannin#data
  825. * @type {TanninLocaleData}
  826. */
  827. this.data = data;
  828. /**
  829. * Plural forms function cache, keyed by plural forms string.
  830. *
  831. * @name Tannin#pluralForms
  832. * @type {Object<string,Function>}
  833. */
  834. this.pluralForms = {};
  835. /**
  836. * Effective options for instance, including defaults.
  837. *
  838. * @name Tannin#options
  839. * @type {TanninOptions}
  840. */
  841. this.options = {};
  842. for ( key in DEFAULT_OPTIONS ) {
  843. this.options[ key ] = options !== undefined && key in options
  844. ? options[ key ]
  845. : DEFAULT_OPTIONS[ key ];
  846. }
  847. }
  848. /**
  849. * Returns the plural form index for the given domain and value.
  850. *
  851. * @param {string} domain Domain on which to calculate plural form.
  852. * @param {number} n Value for which plural form is to be calculated.
  853. *
  854. * @return {number} Plural form index.
  855. */
  856. Tannin.prototype.getPluralForm = function( domain, n ) {
  857. var getPluralForm = this.pluralForms[ domain ],
  858. config, plural, pf;
  859. if ( ! getPluralForm ) {
  860. config = this.data[ domain ][ '' ];
  861. pf = (
  862. config[ 'Plural-Forms' ] ||
  863. config[ 'plural-forms' ] ||
  864. // Ignore reason: As known, there's no way to document the empty
  865. // string property on a key to guarantee this as metadata.
  866. // @ts-ignore
  867. config.plural_forms
  868. );
  869. if ( typeof pf !== 'function' ) {
  870. plural = getPluralExpression(
  871. config[ 'Plural-Forms' ] ||
  872. config[ 'plural-forms' ] ||
  873. // Ignore reason: As known, there's no way to document the empty
  874. // string property on a key to guarantee this as metadata.
  875. // @ts-ignore
  876. config.plural_forms
  877. );
  878. pf = pluralForms( plural );
  879. }
  880. getPluralForm = this.pluralForms[ domain ] = pf;
  881. }
  882. return getPluralForm( n );
  883. };
  884. /**
  885. * Translate a string.
  886. *
  887. * @param {string} domain Translation domain.
  888. * @param {string|void} context Context distinguishing terms of the same name.
  889. * @param {string} singular Primary key for translation lookup.
  890. * @param {string=} plural Fallback value used for non-zero plural
  891. * form index.
  892. * @param {number=} n Value to use in calculating plural form.
  893. *
  894. * @return {string} Translated string.
  895. */
  896. Tannin.prototype.dcnpgettext = function( domain, context, singular, plural, n ) {
  897. var index, key, entry;
  898. if ( n === undefined ) {
  899. // Default to singular.
  900. index = 0;
  901. } else {
  902. // Find index by evaluating plural form for value.
  903. index = this.getPluralForm( domain, n );
  904. }
  905. key = singular;
  906. // If provided, context is prepended to key with delimiter.
  907. if ( context ) {
  908. key = context + this.options.contextDelimiter + singular;
  909. }
  910. entry = this.data[ domain ][ key ];
  911. // Verify not only that entry exists, but that the intended index is within
  912. // range and non-empty.
  913. if ( entry && entry[ index ] ) {
  914. return entry[ index ];
  915. }
  916. if ( this.options.onMissingKey ) {
  917. this.options.onMissingKey( singular, domain );
  918. }
  919. // If entry not found, fall back to singular vs. plural with zero index
  920. // representing the singular value.
  921. return index === 0 ? singular : plural;
  922. };
  923. ;// CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/create-i18n.js
  924. /**
  925. * External dependencies
  926. */
  927. /**
  928. * @typedef {Record<string,any>} LocaleData
  929. */
  930. /**
  931. * Default locale data to use for Tannin domain when not otherwise provided.
  932. * Assumes an English plural forms expression.
  933. *
  934. * @type {LocaleData}
  935. */
  936. const DEFAULT_LOCALE_DATA = {
  937. '': {
  938. /** @param {number} n */
  939. plural_forms(n) {
  940. return n === 1 ? 0 : 1;
  941. }
  942. }
  943. };
  944. /*
  945. * Regular expression that matches i18n hooks like `i18n.gettext`, `i18n.ngettext`,
  946. * `i18n.gettext_domain` or `i18n.ngettext_with_context` or `i18n.has_translation`.
  947. */
  948. const I18N_HOOK_REGEXP = /^i18n\.(n?gettext|has_translation)(_|$)/;
  949. /**
  950. * @typedef {(domain?: string) => LocaleData} GetLocaleData
  951. *
  952. * Returns locale data by domain in a
  953. * Jed-formatted JSON object shape.
  954. *
  955. * @see http://messageformat.github.io/Jed/
  956. */
  957. /**
  958. * @typedef {(data?: LocaleData, domain?: string) => void} SetLocaleData
  959. *
  960. * Merges locale data into the Tannin instance by domain. Note that this
  961. * function will overwrite the domain configuration. Accepts data in a
  962. * Jed-formatted JSON object shape.
  963. *
  964. * @see http://messageformat.github.io/Jed/
  965. */
  966. /**
  967. * @typedef {(data?: LocaleData, domain?: string) => void} AddLocaleData
  968. *
  969. * Merges locale data into the Tannin instance by domain. Note that this
  970. * function will also merge the domain configuration. Accepts data in a
  971. * Jed-formatted JSON object shape.
  972. *
  973. * @see http://messageformat.github.io/Jed/
  974. */
  975. /**
  976. * @typedef {(data?: LocaleData, domain?: string) => void} ResetLocaleData
  977. *
  978. * Resets all current Tannin instance locale data and sets the specified
  979. * locale data for the domain. Accepts data in a Jed-formatted JSON object shape.
  980. *
  981. * @see http://messageformat.github.io/Jed/
  982. */
  983. /** @typedef {() => void} SubscribeCallback */
  984. /** @typedef {() => void} UnsubscribeCallback */
  985. /**
  986. * @typedef {(callback: SubscribeCallback) => UnsubscribeCallback} Subscribe
  987. *
  988. * Subscribes to changes of locale data
  989. */
  990. /**
  991. * @typedef {(domain?: string) => string} GetFilterDomain
  992. * Retrieve the domain to use when calling domain-specific filters.
  993. */
  994. /**
  995. * @typedef {(text: string, domain?: string) => string} __
  996. *
  997. * Retrieve the translation of text.
  998. *
  999. * @see https://developer.wordpress.org/reference/functions/__/
  1000. */
  1001. /**
  1002. * @typedef {(text: string, context: string, domain?: string) => string} _x
  1003. *
  1004. * Retrieve translated string with gettext context.
  1005. *
  1006. * @see https://developer.wordpress.org/reference/functions/_x/
  1007. */
  1008. /**
  1009. * @typedef {(single: string, plural: string, number: number, domain?: string) => string} _n
  1010. *
  1011. * Translates and retrieves the singular or plural form based on the supplied
  1012. * number.
  1013. *
  1014. * @see https://developer.wordpress.org/reference/functions/_n/
  1015. */
  1016. /**
  1017. * @typedef {(single: string, plural: string, number: number, context: string, domain?: string) => string} _nx
  1018. *
  1019. * Translates and retrieves the singular or plural form based on the supplied
  1020. * number, with gettext context.
  1021. *
  1022. * @see https://developer.wordpress.org/reference/functions/_nx/
  1023. */
  1024. /**
  1025. * @typedef {() => boolean} IsRtl
  1026. *
  1027. * Check if current locale is RTL.
  1028. *
  1029. * **RTL (Right To Left)** is a locale property indicating that text is written from right to left.
  1030. * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common
  1031. * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,
  1032. * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).
  1033. */
  1034. /**
  1035. * @typedef {(single: string, context?: string, domain?: string) => boolean} HasTranslation
  1036. *
  1037. * Check if there is a translation for a given string in singular form.
  1038. */
  1039. /** @typedef {import('@wordpress/hooks').Hooks} Hooks */
  1040. /**
  1041. * An i18n instance
  1042. *
  1043. * @typedef I18n
  1044. * @property {GetLocaleData} getLocaleData Returns locale data by domain in a Jed-formatted JSON object shape.
  1045. * @property {SetLocaleData} setLocaleData Merges locale data into the Tannin instance by domain. Note that this
  1046. * function will overwrite the domain configuration. Accepts data in a
  1047. * Jed-formatted JSON object shape.
  1048. * @property {AddLocaleData} addLocaleData Merges locale data into the Tannin instance by domain. Note that this
  1049. * function will also merge the domain configuration. Accepts data in a
  1050. * Jed-formatted JSON object shape.
  1051. * @property {ResetLocaleData} resetLocaleData Resets all current Tannin instance locale data and sets the specified
  1052. * locale data for the domain. Accepts data in a Jed-formatted JSON object shape.
  1053. * @property {Subscribe} subscribe Subscribes to changes of Tannin locale data.
  1054. * @property {__} __ Retrieve the translation of text.
  1055. * @property {_x} _x Retrieve translated string with gettext context.
  1056. * @property {_n} _n Translates and retrieves the singular or plural form based on the supplied
  1057. * number.
  1058. * @property {_nx} _nx Translates and retrieves the singular or plural form based on the supplied
  1059. * number, with gettext context.
  1060. * @property {IsRtl} isRTL Check if current locale is RTL.
  1061. * @property {HasTranslation} hasTranslation Check if there is a translation for a given string.
  1062. */
  1063. /**
  1064. * Create an i18n instance
  1065. *
  1066. * @param {LocaleData} [initialData] Locale data configuration.
  1067. * @param {string} [initialDomain] Domain for which configuration applies.
  1068. * @param {Hooks} [hooks] Hooks implementation.
  1069. *
  1070. * @return {I18n} I18n instance.
  1071. */
  1072. const createI18n = (initialData, initialDomain, hooks) => {
  1073. /**
  1074. * The underlying instance of Tannin to which exported functions interface.
  1075. *
  1076. * @type {Tannin}
  1077. */
  1078. const tannin = new Tannin({});
  1079. const listeners = new Set();
  1080. const notifyListeners = () => {
  1081. listeners.forEach(listener => listener());
  1082. };
  1083. /**
  1084. * Subscribe to changes of locale data.
  1085. *
  1086. * @param {SubscribeCallback} callback Subscription callback.
  1087. * @return {UnsubscribeCallback} Unsubscribe callback.
  1088. */
  1089. const subscribe = callback => {
  1090. listeners.add(callback);
  1091. return () => listeners.delete(callback);
  1092. };
  1093. /** @type {GetLocaleData} */
  1094. const getLocaleData = (domain = 'default') => tannin.data[domain];
  1095. /**
  1096. * @param {LocaleData} [data]
  1097. * @param {string} [domain]
  1098. */
  1099. const doSetLocaleData = (data, domain = 'default') => {
  1100. tannin.data[domain] = {
  1101. ...tannin.data[domain],
  1102. ...data
  1103. };
  1104. // Populate default domain configuration (supported locale date which omits
  1105. // a plural forms expression).
  1106. tannin.data[domain][''] = {
  1107. ...DEFAULT_LOCALE_DATA[''],
  1108. ...tannin.data[domain]?.['']
  1109. };
  1110. // Clean up cached plural forms functions cache as it might be updated.
  1111. delete tannin.pluralForms[domain];
  1112. };
  1113. /** @type {SetLocaleData} */
  1114. const setLocaleData = (data, domain) => {
  1115. doSetLocaleData(data, domain);
  1116. notifyListeners();
  1117. };
  1118. /** @type {AddLocaleData} */
  1119. const addLocaleData = (data, domain = 'default') => {
  1120. tannin.data[domain] = {
  1121. ...tannin.data[domain],
  1122. ...data,
  1123. // Populate default domain configuration (supported locale date which omits
  1124. // a plural forms expression).
  1125. '': {
  1126. ...DEFAULT_LOCALE_DATA[''],
  1127. ...tannin.data[domain]?.[''],
  1128. ...data?.['']
  1129. }
  1130. };
  1131. // Clean up cached plural forms functions cache as it might be updated.
  1132. delete tannin.pluralForms[domain];
  1133. notifyListeners();
  1134. };
  1135. /** @type {ResetLocaleData} */
  1136. const resetLocaleData = (data, domain) => {
  1137. // Reset all current Tannin locale data.
  1138. tannin.data = {};
  1139. // Reset cached plural forms functions cache.
  1140. tannin.pluralForms = {};
  1141. setLocaleData(data, domain);
  1142. };
  1143. /**
  1144. * Wrapper for Tannin's `dcnpgettext`. Populates default locale data if not
  1145. * otherwise previously assigned.
  1146. *
  1147. * @param {string|undefined} domain Domain to retrieve the translated text.
  1148. * @param {string|undefined} context Context information for the translators.
  1149. * @param {string} single Text to translate if non-plural. Used as
  1150. * fallback return value on a caught error.
  1151. * @param {string} [plural] The text to be used if the number is
  1152. * plural.
  1153. * @param {number} [number] The number to compare against to use
  1154. * either the singular or plural form.
  1155. *
  1156. * @return {string} The translated string.
  1157. */
  1158. const dcnpgettext = (domain = 'default', context, single, plural, number) => {
  1159. if (!tannin.data[domain]) {
  1160. // Use `doSetLocaleData` to set silently, without notifying listeners.
  1161. doSetLocaleData(undefined, domain);
  1162. }
  1163. return tannin.dcnpgettext(domain, context, single, plural, number);
  1164. };
  1165. /** @type {GetFilterDomain} */
  1166. const getFilterDomain = (domain = 'default') => domain;
  1167. /** @type {__} */
  1168. const __ = (text, domain) => {
  1169. let translation = dcnpgettext(domain, undefined, text);
  1170. if (!hooks) {
  1171. return translation;
  1172. }
  1173. /**
  1174. * Filters text with its translation.
  1175. *
  1176. * @param {string} translation Translated text.
  1177. * @param {string} text Text to translate.
  1178. * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
  1179. */
  1180. translation = /** @type {string} */
  1181. /** @type {*} */hooks.applyFilters('i18n.gettext', translation, text, domain);
  1182. return (/** @type {string} */
  1183. /** @type {*} */hooks.applyFilters('i18n.gettext_' + getFilterDomain(domain), translation, text, domain)
  1184. );
  1185. };
  1186. /** @type {_x} */
  1187. const _x = (text, context, domain) => {
  1188. let translation = dcnpgettext(domain, context, text);
  1189. if (!hooks) {
  1190. return translation;
  1191. }
  1192. /**
  1193. * Filters text with its translation based on context information.
  1194. *
  1195. * @param {string} translation Translated text.
  1196. * @param {string} text Text to translate.
  1197. * @param {string} context Context information for the translators.
  1198. * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
  1199. */
  1200. translation = /** @type {string} */
  1201. /** @type {*} */hooks.applyFilters('i18n.gettext_with_context', translation, text, context, domain);
  1202. return (/** @type {string} */
  1203. /** @type {*} */hooks.applyFilters('i18n.gettext_with_context_' + getFilterDomain(domain), translation, text, context, domain)
  1204. );
  1205. };
  1206. /** @type {_n} */
  1207. const _n = (single, plural, number, domain) => {
  1208. let translation = dcnpgettext(domain, undefined, single, plural, number);
  1209. if (!hooks) {
  1210. return translation;
  1211. }
  1212. /**
  1213. * Filters the singular or plural form of a string.
  1214. *
  1215. * @param {string} translation Translated text.
  1216. * @param {string} single The text to be used if the number is singular.
  1217. * @param {string} plural The text to be used if the number is plural.
  1218. * @param {string} number The number to compare against to use either the singular or plural form.
  1219. * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
  1220. */
  1221. translation = /** @type {string} */
  1222. /** @type {*} */hooks.applyFilters('i18n.ngettext', translation, single, plural, number, domain);
  1223. return (/** @type {string} */
  1224. /** @type {*} */hooks.applyFilters('i18n.ngettext_' + getFilterDomain(domain), translation, single, plural, number, domain)
  1225. );
  1226. };
  1227. /** @type {_nx} */
  1228. const _nx = (single, plural, number, context, domain) => {
  1229. let translation = dcnpgettext(domain, context, single, plural, number);
  1230. if (!hooks) {
  1231. return translation;
  1232. }
  1233. /**
  1234. * Filters the singular or plural form of a string with gettext context.
  1235. *
  1236. * @param {string} translation Translated text.
  1237. * @param {string} single The text to be used if the number is singular.
  1238. * @param {string} plural The text to be used if the number is plural.
  1239. * @param {string} number The number to compare against to use either the singular or plural form.
  1240. * @param {string} context Context information for the translators.
  1241. * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
  1242. */
  1243. translation = /** @type {string} */
  1244. /** @type {*} */hooks.applyFilters('i18n.ngettext_with_context', translation, single, plural, number, context, domain);
  1245. return (/** @type {string} */
  1246. /** @type {*} */hooks.applyFilters('i18n.ngettext_with_context_' + getFilterDomain(domain), translation, single, plural, number, context, domain)
  1247. );
  1248. };
  1249. /** @type {IsRtl} */
  1250. const isRTL = () => {
  1251. return 'rtl' === _x('ltr', 'text direction');
  1252. };
  1253. /** @type {HasTranslation} */
  1254. const hasTranslation = (single, context, domain) => {
  1255. const key = context ? context + '\u0004' + single : single;
  1256. let result = !!tannin.data?.[domain !== null && domain !== void 0 ? domain : 'default']?.[key];
  1257. if (hooks) {
  1258. /**
  1259. * Filters the presence of a translation in the locale data.
  1260. *
  1261. * @param {boolean} hasTranslation Whether the translation is present or not..
  1262. * @param {string} single The singular form of the translated text (used as key in locale data)
  1263. * @param {string} context Context information for the translators.
  1264. * @param {string} domain Text domain. Unique identifier for retrieving translated strings.
  1265. */
  1266. result = /** @type { boolean } */
  1267. /** @type {*} */hooks.applyFilters('i18n.has_translation', result, single, context, domain);
  1268. result = /** @type { boolean } */
  1269. /** @type {*} */hooks.applyFilters('i18n.has_translation_' + getFilterDomain(domain), result, single, context, domain);
  1270. }
  1271. return result;
  1272. };
  1273. if (initialData) {
  1274. setLocaleData(initialData, initialDomain);
  1275. }
  1276. if (hooks) {
  1277. /**
  1278. * @param {string} hookName
  1279. */
  1280. const onHookAddedOrRemoved = hookName => {
  1281. if (I18N_HOOK_REGEXP.test(hookName)) {
  1282. notifyListeners();
  1283. }
  1284. };
  1285. hooks.addAction('hookAdded', 'core/i18n', onHookAddedOrRemoved);
  1286. hooks.addAction('hookRemoved', 'core/i18n', onHookAddedOrRemoved);
  1287. }
  1288. return {
  1289. getLocaleData,
  1290. setLocaleData,
  1291. addLocaleData,
  1292. resetLocaleData,
  1293. subscribe,
  1294. __,
  1295. _x,
  1296. _n,
  1297. _nx,
  1298. isRTL,
  1299. hasTranslation
  1300. };
  1301. };
  1302. ;// CONCATENATED MODULE: external ["wp","hooks"]
  1303. var external_wp_hooks_namespaceObject = window["wp"]["hooks"];
  1304. ;// CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/default-i18n.js
  1305. /**
  1306. * Internal dependencies
  1307. */
  1308. /**
  1309. * WordPress dependencies
  1310. */
  1311. const i18n = createI18n(undefined, undefined, external_wp_hooks_namespaceObject.defaultHooks);
  1312. /**
  1313. * Default, singleton instance of `I18n`.
  1314. */
  1315. /* harmony default export */ var default_i18n = (i18n);
  1316. /*
  1317. * Comments in this file are duplicated from ./i18n due to
  1318. * https://github.com/WordPress/gutenberg/pull/20318#issuecomment-590837722
  1319. */
  1320. /**
  1321. * @typedef {import('./create-i18n').LocaleData} LocaleData
  1322. * @typedef {import('./create-i18n').SubscribeCallback} SubscribeCallback
  1323. * @typedef {import('./create-i18n').UnsubscribeCallback} UnsubscribeCallback
  1324. */
  1325. /**
  1326. * Returns locale data by domain in a Jed-formatted JSON object shape.
  1327. *
  1328. * @see http://messageformat.github.io/Jed/
  1329. *
  1330. * @param {string} [domain] Domain for which to get the data.
  1331. * @return {LocaleData} Locale data.
  1332. */
  1333. const getLocaleData = i18n.getLocaleData.bind(i18n);
  1334. /**
  1335. * Merges locale data into the Tannin instance by domain. Accepts data in a
  1336. * Jed-formatted JSON object shape.
  1337. *
  1338. * @see http://messageformat.github.io/Jed/
  1339. *
  1340. * @param {LocaleData} [data] Locale data configuration.
  1341. * @param {string} [domain] Domain for which configuration applies.
  1342. */
  1343. const setLocaleData = i18n.setLocaleData.bind(i18n);
  1344. /**
  1345. * Resets all current Tannin instance locale data and sets the specified
  1346. * locale data for the domain. Accepts data in a Jed-formatted JSON object shape.
  1347. *
  1348. * @see http://messageformat.github.io/Jed/
  1349. *
  1350. * @param {LocaleData} [data] Locale data configuration.
  1351. * @param {string} [domain] Domain for which configuration applies.
  1352. */
  1353. const resetLocaleData = i18n.resetLocaleData.bind(i18n);
  1354. /**
  1355. * Subscribes to changes of locale data
  1356. *
  1357. * @param {SubscribeCallback} callback Subscription callback
  1358. * @return {UnsubscribeCallback} Unsubscribe callback
  1359. */
  1360. const subscribe = i18n.subscribe.bind(i18n);
  1361. /**
  1362. * Retrieve the translation of text.
  1363. *
  1364. * @see https://developer.wordpress.org/reference/functions/__/
  1365. *
  1366. * @param {string} text Text to translate.
  1367. * @param {string} [domain] Domain to retrieve the translated text.
  1368. *
  1369. * @return {string} Translated text.
  1370. */
  1371. const __ = i18n.__.bind(i18n);
  1372. /**
  1373. * Retrieve translated string with gettext context.
  1374. *
  1375. * @see https://developer.wordpress.org/reference/functions/_x/
  1376. *
  1377. * @param {string} text Text to translate.
  1378. * @param {string} context Context information for the translators.
  1379. * @param {string} [domain] Domain to retrieve the translated text.
  1380. *
  1381. * @return {string} Translated context string without pipe.
  1382. */
  1383. const _x = i18n._x.bind(i18n);
  1384. /**
  1385. * Translates and retrieves the singular or plural form based on the supplied
  1386. * number.
  1387. *
  1388. * @see https://developer.wordpress.org/reference/functions/_n/
  1389. *
  1390. * @param {string} single The text to be used if the number is singular.
  1391. * @param {string} plural The text to be used if the number is plural.
  1392. * @param {number} number The number to compare against to use either the
  1393. * singular or plural form.
  1394. * @param {string} [domain] Domain to retrieve the translated text.
  1395. *
  1396. * @return {string} The translated singular or plural form.
  1397. */
  1398. const _n = i18n._n.bind(i18n);
  1399. /**
  1400. * Translates and retrieves the singular or plural form based on the supplied
  1401. * number, with gettext context.
  1402. *
  1403. * @see https://developer.wordpress.org/reference/functions/_nx/
  1404. *
  1405. * @param {string} single The text to be used if the number is singular.
  1406. * @param {string} plural The text to be used if the number is plural.
  1407. * @param {number} number The number to compare against to use either the
  1408. * singular or plural form.
  1409. * @param {string} context Context information for the translators.
  1410. * @param {string} [domain] Domain to retrieve the translated text.
  1411. *
  1412. * @return {string} The translated singular or plural form.
  1413. */
  1414. const _nx = i18n._nx.bind(i18n);
  1415. /**
  1416. * Check if current locale is RTL.
  1417. *
  1418. * **RTL (Right To Left)** is a locale property indicating that text is written from right to left.
  1419. * For example, the `he` locale (for Hebrew) specifies right-to-left. Arabic (ar) is another common
  1420. * language written RTL. The opposite of RTL, LTR (Left To Right) is used in other languages,
  1421. * including English (`en`, `en-US`, `en-GB`, etc.), Spanish (`es`), and French (`fr`).
  1422. *
  1423. * @return {boolean} Whether locale is RTL.
  1424. */
  1425. const isRTL = i18n.isRTL.bind(i18n);
  1426. /**
  1427. * Check if there is a translation for a given string (in singular form).
  1428. *
  1429. * @param {string} single Singular form of the string to look up.
  1430. * @param {string} [context] Context information for the translators.
  1431. * @param {string} [domain] Domain to retrieve the translated text.
  1432. * @return {boolean} Whether the translation exists or not.
  1433. */
  1434. const hasTranslation = i18n.hasTranslation.bind(i18n);
  1435. ;// CONCATENATED MODULE: ./node_modules/@wordpress/i18n/build-module/index.js
  1436. }();
  1437. (window.wp = window.wp || {}).i18n = __webpack_exports__;
  1438. /******/ })()
  1439. ;