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M,KAAMf,GACtBO,EAAkBQ,KAAM,KAAMf,GAC9BQ,EAAgBO,KAAM,KAAMf,GAC5BU,EAAYK,KAAM,KAAMf,GACxBI,EAAkBW,KAAM,KAAMf,GAC9BK,EAAgBU,KAAM,KAAMf,GAC5BM,EAAgBS,KAAM,KAAMf,IAC3BgB,QAAQ,CAAEC,EAAQC,IAAQA,EAAID,IAAUhB,GAC1CA,GAAc,KACoB,QAAlC2B,EAAO3B,EAAKkB,MAAON,IAASO,cAAM,IAAAQ,EAAAA,EAAI,CACvC,CA6CUC,CAAY5B,EAAM0B,EAAa3B,GACvC,IAAK,8BAEJ,OADA2B,EAAc3B,EAASJ,kCAChBgB,EAAiBX,EAAM0B,EAAa3B,GAC5C,IAAK,8BAEJ,OADA2B,EAAc3B,EAASL,kCAChBiB,EAAiBX,EAAM0B,EAAa3B,GAC5C,QACC,OAAO,EAEV,E","sources":["webpack://wp/webpack/bootstrap","webpack://wp/webpack/runtime/define property getters","webpack://wp/webpack/runtime/hasOwnProperty shorthand","webpack://wp/webpack/runtime/make namespace object","../../packages/wordcount/src/defaultSettings.js","../../packages/wordcount/src/stripTags.js","../../packages/wordcount/src/transposeAstralsToCountableChar.js","../../packages/wordcount/src/stripHTMLEntities.js","../../packages/wordcount/src/stripConnectors.js","../../packages/wordcount/src/stripRemovables.js","../../packages/wordcount/src/stripHTMLComments.js","../../packages/wordcount/src/stripShortcodes.js","../../packages/wordcount/src/stripSpaces.js","../../packages/wordcount/src/transposeHTMLEntitiesToCountableChars.js","../../packages/wordcount/src/index.js"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/** @typedef {import('./index').WPWordCountStrategy} WPWordCountStrategy */\n\n/** @typedef {Partial<{type: WPWordCountStrategy, shortcodes: string[]}>} WPWordCountL10n */\n\n/**\n * @typedef WPWordCountSettingsFields\n * @property {RegExp} HTMLRegExp Regular expression that matches HTML tags\n * @property {RegExp} HTMLcommentRegExp Regular expression that matches HTML comments\n * @property {RegExp} spaceRegExp Regular expression that matches spaces in HTML\n * @property {RegExp} HTMLEntityRegExp Regular expression that matches HTML entities\n * @property {RegExp} connectorRegExp Regular expression that matches word connectors, like em-dash\n * @property {RegExp} removeRegExp Regular expression that matches various characters to be removed when counting\n * @property {RegExp} astralRegExp Regular expression that matches astral UTF-16 code points\n * @property {RegExp} wordsRegExp Regular expression that matches words\n * @property {RegExp} characters_excluding_spacesRegExp Regular expression that matches characters excluding spaces\n * @property {RegExp} characters_including_spacesRegExp Regular expression that matches characters including spaces\n * @property {RegExp} shortcodesRegExp Regular expression that matches WordPress shortcodes\n * @property {string[]} shortcodes List of all shortcodes\n * @property {WPWordCountStrategy} type Describes what and how are we counting\n * @property {WPWordCountL10n} l10n Object with human translations\n */\n\n/**\n * Lower-level settings for word counting that can be overridden.\n *\n * @typedef {Partial} WPWordCountUserSettings\n */\n\n// Disable reason: JSDoc linter doesn't seem to parse the union (`&`) correctly: https://github.com/jsdoc/jsdoc/issues/1285\n/* eslint-disable jsdoc/valid-types */\n/**\n * Word counting settings that include non-optional values we set if missing\n *\n * @typedef {WPWordCountUserSettings & typeof defaultSettings} WPWordCountDefaultSettings\n */\n/* eslint-enable jsdoc/valid-types */\n\nexport const defaultSettings = {\n\tHTMLRegExp: /<\\/?[a-z][^>]*?>/gi,\n\tHTMLcommentRegExp: //g,\n\tspaceRegExp: / | /gi,\n\tHTMLEntityRegExp: /&\\S+?;/g,\n\n\t// \\u2014 = em-dash.\n\tconnectorRegExp: /--|\\u2014/g,\n\n\t// Characters to be removed from input text.\n\tremoveRegExp: new RegExp(\n\t\t[\n\t\t\t'[',\n\n\t\t\t// Basic Latin (extract)\n\t\t\t'\\u0021-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E',\n\n\t\t\t// Latin-1 Supplement (extract)\n\t\t\t'\\u0080-\\u00BF\\u00D7\\u00F7',\n\n\t\t\t/*\n\t\t\t * The following range consists of:\n\t\t\t * General Punctuation\n\t\t\t * Superscripts and Subscripts\n\t\t\t * Currency Symbols\n\t\t\t * Combining Diacritical Marks for Symbols\n\t\t\t * Letterlike Symbols\n\t\t\t * Number Forms\n\t\t\t * Arrows\n\t\t\t * Mathematical Operators\n\t\t\t * Miscellaneous Technical\n\t\t\t * Control Pictures\n\t\t\t * Optical Character Recognition\n\t\t\t * Enclosed Alphanumerics\n\t\t\t * Box Drawing\n\t\t\t * Block Elements\n\t\t\t * Geometric Shapes\n\t\t\t * Miscellaneous Symbols\n\t\t\t * Dingbats\n\t\t\t * Miscellaneous Mathematical Symbols-A\n\t\t\t * Supplemental Arrows-A\n\t\t\t * Braille Patterns\n\t\t\t * Supplemental Arrows-B\n\t\t\t * Miscellaneous Mathematical Symbols-B\n\t\t\t * Supplemental Mathematical Operators\n\t\t\t * Miscellaneous Symbols and Arrows\n\t\t\t */\n\t\t\t'\\u2000-\\u2BFF',\n\n\t\t\t// Supplemental Punctuation.\n\t\t\t'\\u2E00-\\u2E7F',\n\t\t\t']',\n\t\t].join( '' ),\n\t\t'g'\n\t),\n\n\t// Remove UTF-16 surrogate points, see https://en.wikipedia.org/wiki/UTF-16#U.2BD800_to_U.2BDFFF\n\tastralRegExp: /[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]/g,\n\twordsRegExp: /\\S\\s+/g,\n\tcharacters_excluding_spacesRegExp: /\\S/g,\n\n\t/*\n\t * Match anything that is not a formatting character, excluding:\n\t * \\f = form feed\n\t * \\n = new line\n\t * \\r = carriage return\n\t * \\t = tab\n\t * \\v = vertical tab\n\t * \\u00AD = soft hyphen\n\t * \\u2028 = line separator\n\t * \\u2029 = paragraph separator\n\t */\n\tcharacters_including_spacesRegExp: /[^\\f\\n\\r\\t\\v\\u00AD\\u2028\\u2029]/g,\n\tl10n: {\n\t\ttype: 'words',\n\t},\n};\n","/**\n * Replaces items matched in the regex with new line\n *\n * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions\n * @param {string} text The string being counted.\n *\n * @return {string} The manipulated text.\n */\nexport default function stripTags( settings, text ) {\n\treturn text.replace( settings.HTMLRegExp, '\\n' );\n}\n","/**\n * Replaces items matched in the regex with character.\n *\n * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions\n * @param {string} text The string being counted.\n *\n * @return {string} The manipulated text.\n */\nexport default function transposeAstralsToCountableChar( settings, text ) {\n\treturn text.replace( settings.astralRegExp, 'a' );\n}\n","/**\n * Removes items matched in the regex.\n *\n * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions\n * @param {string} text The string being counted.\n *\n * @return {string} The manipulated text.\n */\nexport default function stripHTMLEntities( settings, text ) {\n\treturn text.replace( settings.HTMLEntityRegExp, '' );\n}\n","/**\n * Replaces items matched in the regex with spaces.\n *\n * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions\n * @param {string} text The string being counted.\n *\n * @return {string} The manipulated text.\n */\nexport default function stripConnectors( settings, text ) {\n\treturn text.replace( settings.connectorRegExp, ' ' );\n}\n","/**\n * Removes items matched in the regex.\n *\n * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions\n * @param {string} text The string being counted.\n *\n * @return {string} The manipulated text.\n */\nexport default function stripRemovables( settings, text ) {\n\treturn text.replace( settings.removeRegExp, '' );\n}\n","/**\n * Removes items matched in the regex.\n *\n * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions\n * @param {string} text The string being counted.\n *\n * @return {string} The manipulated text.\n */\nexport default function stripHTMLComments( settings, text ) {\n\treturn text.replace( settings.HTMLcommentRegExp, '' );\n}\n","/**\n * Replaces items matched in the regex with a new line.\n *\n * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions\n * @param {string} text The string being counted.\n *\n * @return {string} The manipulated text.\n */\nexport default function stripShortcodes( settings, text ) {\n\tif ( settings.shortcodesRegExp ) {\n\t\treturn text.replace( settings.shortcodesRegExp, '\\n' );\n\t}\n\treturn text;\n}\n","/**\n * Replaces items matched in the regex with spaces.\n *\n * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions\n * @param {string} text The string being counted.\n *\n * @return {string} The manipulated text.\n */\nexport default function stripSpaces( settings, text ) {\n\treturn text.replace( settings.spaceRegExp, ' ' );\n}\n","/**\n * Replaces items matched in the regex with a single character.\n *\n * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions\n * @param {string} text The string being counted.\n *\n * @return {string} The manipulated text.\n */\nexport default function transposeHTMLEntitiesToCountableChars(\n\tsettings,\n\ttext\n) {\n\treturn text.replace( settings.HTMLEntityRegExp, 'a' );\n}\n","/**\n * Internal dependencies\n */\nimport { defaultSettings } from './defaultSettings';\nimport stripTags from './stripTags';\nimport transposeAstralsToCountableChar from './transposeAstralsToCountableChar';\nimport stripHTMLEntities from './stripHTMLEntities';\nimport stripConnectors from './stripConnectors';\nimport stripRemovables from './stripRemovables';\nimport stripHTMLComments from './stripHTMLComments';\nimport stripShortcodes from './stripShortcodes';\nimport stripSpaces from './stripSpaces';\nimport transposeHTMLEntitiesToCountableChars from './transposeHTMLEntitiesToCountableChars';\n\n/**\n * @typedef {import('./defaultSettings').WPWordCountDefaultSettings} WPWordCountSettings\n * @typedef {import('./defaultSettings').WPWordCountUserSettings} WPWordCountUserSettings\n */\n\n/**\n * Possible ways of counting.\n *\n * @typedef {'words'|'characters_excluding_spaces'|'characters_including_spaces'} WPWordCountStrategy\n */\n\n/**\n * Private function to manage the settings.\n *\n * @param {WPWordCountStrategy} type The type of count to be done.\n * @param {WPWordCountUserSettings} userSettings Custom settings for the count.\n *\n * @return {WPWordCountSettings} The combined settings object to be used.\n */\nfunction loadSettings( type, userSettings ) {\n\tconst settings = Object.assign( {}, defaultSettings, userSettings );\n\n\tsettings.shortcodes = settings.l10n?.shortcodes ?? [];\n\n\tif ( settings.shortcodes && settings.shortcodes.length ) {\n\t\tsettings.shortcodesRegExp = new RegExp(\n\t\t\t'\\\\[\\\\/?(?:' + settings.shortcodes.join( '|' ) + ')[^\\\\]]*?\\\\]',\n\t\t\t'g'\n\t\t);\n\t}\n\n\tsettings.type = type;\n\n\tif (\n\t\tsettings.type !== 'characters_excluding_spaces' &&\n\t\tsettings.type !== 'characters_including_spaces'\n\t) {\n\t\tsettings.type = 'words';\n\t}\n\n\treturn settings;\n}\n\n/**\n * Count the words in text\n *\n * @param {string} text The text being processed\n * @param {RegExp} regex The regular expression pattern being matched\n * @param {WPWordCountSettings} settings Settings object containing regular expressions for each strip function\n *\n * @return {number} Count of words.\n */\nfunction countWords( text, regex, settings ) {\n\ttext = [\n\t\tstripTags.bind( null, settings ),\n\t\tstripHTMLComments.bind( null, settings ),\n\t\tstripShortcodes.bind( null, settings ),\n\t\tstripSpaces.bind( null, settings ),\n\t\tstripHTMLEntities.bind( null, settings ),\n\t\tstripConnectors.bind( null, settings ),\n\t\tstripRemovables.bind( null, settings ),\n\t].reduce( ( result, fn ) => fn( result ), text );\n\ttext = text + '\\n';\n\treturn text.match( regex )?.length ?? 0;\n}\n\n/**\n * Count the characters in text\n *\n * @param {string} text The text being processed\n * @param {RegExp} regex The regular expression pattern being matched\n * @param {WPWordCountSettings} settings Settings object containing regular expressions for each strip function\n *\n * @return {number} Count of characters.\n */\nfunction countCharacters( text, regex, settings ) {\n\ttext = [\n\t\tstripTags.bind( null, settings ),\n\t\tstripHTMLComments.bind( null, settings ),\n\t\tstripShortcodes.bind( null, settings ),\n\t\ttransposeAstralsToCountableChar.bind( null, settings ),\n\t\tstripSpaces.bind( null, settings ),\n\t\ttransposeHTMLEntitiesToCountableChars.bind( null, settings ),\n\t].reduce( ( result, fn ) => fn( result ), text );\n\ttext = text + '\\n';\n\treturn text.match( regex )?.length ?? 0;\n}\n\n/**\n * Count some words.\n *\n * @param {string} text The text being processed\n * @param {WPWordCountStrategy} type The type of count. Accepts 'words', 'characters_excluding_spaces', or 'characters_including_spaces'.\n * @param {WPWordCountUserSettings} userSettings Custom settings object.\n *\n * @example\n * ```js\n * import { count } from '@wordpress/wordcount';\n * const numberOfWords = count( 'Words to count', 'words', {} )\n * ```\n *\n * @return {number} The word or character count.\n */\nexport function count( text, type, userSettings ) {\n\tconst settings = loadSettings( type, userSettings );\n\tlet matchRegExp;\n\tswitch ( settings.type ) {\n\t\tcase 'words':\n\t\t\tmatchRegExp = settings.wordsRegExp;\n\t\t\treturn countWords( text, matchRegExp, settings );\n\t\tcase 'characters_including_spaces':\n\t\t\tmatchRegExp = settings.characters_including_spacesRegExp;\n\t\t\treturn countCharacters( text, matchRegExp, settings );\n\t\tcase 'characters_excluding_spaces':\n\t\t\tmatchRegExp = settings.characters_excluding_spacesRegExp;\n\t\t\treturn countCharacters( text, matchRegExp, settings );\n\t\tdefault:\n\t\t\treturn 0;\n\t}\n}\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","defaultSettings","HTMLRegExp","HTMLcommentRegExp","spaceRegExp","HTMLEntityRegExp","connectorRegExp","removeRegExp","RegExp","join","astralRegExp","wordsRegExp","characters_excluding_spacesRegExp","characters_including_spacesRegExp","l10n","type","stripTags","settings","text","replace","transposeAstralsToCountableChar","stripHTMLEntities","stripConnectors","stripRemovables","stripHTMLComments","stripShortcodes","shortcodesRegExp","stripSpaces","transposeHTMLEntitiesToCountableChars","countCharacters","regex","_text$match$length2","bind","reduce","result","fn","match","length","count","userSettings","_settings$l10n$shortc","assign","shortcodes","loadSettings","matchRegExp","_text$match$length","countWords"],"sourceRoot":""}