{"version":3,"sources":["webpack:///./node_modules/@ckeditor/ckeditor5-engine/src/view/matcher.js","webpack:///./node_modules/@ckeditor/ckeditor5-engine/src/view/node.js"],"names":["Matcher","Object","D_Projects_UA_repo_Source_Client_UA_User_Web_node_modules_babel_runtime_helpers_esm_classCallCheck_js__WEBPACK_IMPORTED_MODULE_11__","this","_patterns","add","apply","arguments","_len","length","pattern","Array","_key","_i","_pattern","item","RegExp","name","push","_len2","element","_key2","_i2","_element","_step","singleElement","_iterator","_createForOfIteratorHelper","s","n","done","value","match","isElementMatching","err","e","f","results","_len3","_key3","_i3","_element2","_step2","_iterator2","matchName","attributes","matchAttributes","classes","matchClasses","styles","matchStyles","test","matchPatterns","patterns","keys","valueGetter","normalizedPatterns","normalizePatterns","normalizedItems","from","forEach","_ref","_ref2","D_Projects_UA_repo_Source_Client_UA_User_Web_node_modules_babel_runtime_helpers_esm_slicedToArray_js__WEBPACK_IMPORTED_MODULE_5__","patternKey","patternValue","itemKey","isKeyMatched","isValueMatched","isArray","map","isPlainObject","undefined","key","logWarning","entries","itemValue","attributeKeys","Set","getAttributeKeys","style","class","delete","getAttribute","getClassNames","getStyleNames","getStyle","Node","document","D_Projects_UA_repo_Source_Client_UA_User_Web_node_modules_babel_runtime_helpers_esm_classCallCheck_js__WEBPACK_IMPORTED_MODULE_0__","parent","pos","getChildIndex","CKEditorError","index","getChild","root","is","path","node","unshift","options","includeSelf","parentFirst","ancestors","ancestorsA","getAncestors","ancestorsB","i","thisPath","getPath","nodePath","result","compareArrays","isBefore","_removeChildren","type","fire","_fireChange","json","clone","mix","EmitterMixin"],"mappings":";;;;OAiBqBA,aAOpB,SAAAA,IAA0BC,OAAAC,EAAA,KAAAD,CAAAE,KAAAH,GAKzBG,KAAKC,aAELD,KAAKE,IAALC,MAAAH,KAAAI,qDAwCD,WAAkB,QAAAC,EAAAD,UAAAE,OAAVC,EAAU,IAAAC,MAAAH,GAAAI,EAAA,EAAAA,EAAAJ,EAAAI,IAAVF,EAAUE,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J,OAAO,EAER,QACC,OAAOH,EAAUG,GAAWD,EAAUC,2BAWzC,SAASb,GAER,OAAKhG,MAAQgG,IAKRhG,KAAK6F,OAASG,EAAKH,OAKhB7F,KAAK+G,SAAUf,2BAQxB,WACChG,KAAKuF,OAAOyB,gBAAiBhH,KAAK2F,kCASnC,SAAasB,EAAMjB,GAClBhG,KAAKkH,KAAM,UAAYD,EAAMjB,GAExBhG,KAAKuF,QACTvF,KAAKuF,OAAO4B,YAAaF,EAAMjB,yBASjC,WACC,IAAMoB,EAAOC,eAAOrH,MAKpB,cAFOoH,EAAK7B,OAEL6B,oBA+CR,SAAIH,GACH,MAAgB,SAATA,GAA4B,cAATA,YAkD5BK,eAAKlC,EAAMmC","file":"js/chunk-7c029b7c.1cadafec.js","sourcesContent":["/**\n * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module engine/view/matcher\n */\n\nimport { isPlainObject } from 'lodash-es';\n\nimport { logWarning } from '@ckeditor/ckeditor5-utils/src/ckeditorerror';\n\n/**\n * View matcher class.\n * Instance of this class can be used to find {@link module:engine/view/element~Element elements} that match given pattern.\n */\nexport default class Matcher {\n\t/**\n\t * Creates new instance of Matcher.\n\t *\n\t * @param {String|RegExp|Object} [pattern] Match patterns. See {@link module:engine/view/matcher~Matcher#add add method} for\n\t * more information.\n\t */\n\tconstructor( ...pattern ) {\n\t\t/**\n\t\t * @private\n\t\t * @type {Array}\n\t\t */\n\t\tthis._patterns = [];\n\n\t\tthis.add( ...pattern );\n\t}\n\n\t/**\n\t * Adds pattern or patterns to matcher instance.\n\t *\n\t *\t\t// String.\n\t *\t\tmatcher.add( 'div' );\n\t *\n\t *\t\t// Regular expression.\n\t *\t\tmatcher.add( /^\\w/ );\n\t *\n\t *\t\t// Single class.\n\t *\t\tmatcher.add( {\n\t *\t\t\tclasses: 'foobar'\n\t *\t\t} );\n\t *\n\t * See {@link module:engine/view/matcher~MatcherPattern} for more examples.\n\t *\n\t * Multiple patterns can be added in one call:\n\t *\n\t * \t\tmatcher.add( 'div', { classes: 'foobar' } );\n\t *\n\t * @param {Object|String|RegExp|Function} pattern Object describing pattern details. If string or regular expression\n\t * is provided it will be used to match element's name. Pattern can be also provided in a form\n\t * of a function - then this function will be called with each {@link module:engine/view/element~Element element} as a parameter.\n\t * Function's return value will be stored under `match` key of the object returned from\n\t * {@link module:engine/view/matcher~Matcher#match match} or {@link module:engine/view/matcher~Matcher#matchAll matchAll} methods.\n\t * @param {String|RegExp} [pattern.name] Name or regular expression to match element's name.\n\t * @param {Object} [pattern.attributes] Object with key-value pairs representing attributes to match. Each object key\n\t * represents attribute name. Value under that key can be either:\n\t * * `true` - then attribute is just required (can be empty),\n\t * * a string - then attribute has to be equal, or\n\t * * a regular expression - then attribute has to match the expression.\n\t * @param {String|RegExp|Array} [pattern.classes] Class name or array of class names to match. Each name can be\n\t * provided in a form of string or regular expression.\n\t * @param {Object} [pattern.styles] Object with key-value pairs representing styles to match. Each object key\n\t * represents style name. Value under that key can be either a string or a regular expression and it will be used\n\t * to match style value.\n\t */\n\tadd( ...pattern ) {\n\t\tfor ( let item of pattern ) {\n\t\t\t// String or RegExp pattern is used as element's name.\n\t\t\tif ( typeof item == 'string' || item instanceof RegExp ) {\n\t\t\t\titem = { name: item };\n\t\t\t}\n\n\t\t\tthis._patterns.push( item );\n\t\t}\n\t}\n\n\t/**\n\t * Matches elements for currently stored patterns. Returns match information about first found\n\t * {@link module:engine/view/element~Element element}, otherwise returns `null`.\n\t *\n\t * Example of returned object:\n\t *\n\t *\t\t{\n\t *\t\t\telement: ,\n\t *\t\t\tpattern: ,\n\t *\t\t\tmatch: {\n\t *\t\t\t\tname: true,\n\t *\t\t\t\tattributes: [ 'title', 'href' ],\n\t *\t\t\t\tclasses: [ 'foo' ],\n\t *\t\t\t\tstyles: [ 'color', 'position' ]\n\t *\t\t\t}\n\t *\t\t}\n\t *\n\t * @see module:engine/view/matcher~Matcher#add\n\t * @see module:engine/view/matcher~Matcher#matchAll\n\t * @param {...module:engine/view/element~Element} element View element to match against stored patterns.\n\t * @returns {Object|null} result\n\t * @returns {module:engine/view/element~Element} result.element Matched view element.\n\t * @returns {Object|String|RegExp|Function} result.pattern Pattern that was used to find matched element.\n\t * @returns {Object} result.match Object representing matched element parts.\n\t * @returns {Boolean} [result.match.name] True if name of the element was matched.\n\t * @returns {Array} [result.match.attributes] Array with matched attribute names.\n\t * @returns {Array} [result.match.classes] Array with matched class names.\n\t * @returns {Array} [result.match.styles] Array with matched style names.\n\t */\n\tmatch( ...element ) {\n\t\tfor ( const singleElement of element ) {\n\t\t\tfor ( const pattern of this._patterns ) {\n\t\t\t\tconst match = isElementMatching( singleElement, pattern );\n\n\t\t\t\tif ( match ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\telement: singleElement,\n\t\t\t\t\t\tpattern,\n\t\t\t\t\t\tmatch\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\t/**\n\t * Matches elements for currently stored patterns. Returns array of match information with all found\n\t * {@link module:engine/view/element~Element elements}. If no element is found - returns `null`.\n\t *\n\t * @see module:engine/view/matcher~Matcher#add\n\t * @see module:engine/view/matcher~Matcher#match\n\t * @param {...module:engine/view/element~Element} element View element to match against stored patterns.\n\t * @returns {Array.|null} Array with match information about found elements or `null`. For more information\n\t * see {@link module:engine/view/matcher~Matcher#match match method} description.\n\t */\n\tmatchAll( ...element ) {\n\t\tconst results = [];\n\n\t\tfor ( const singleElement of element ) {\n\t\t\tfor ( const pattern of this._patterns ) {\n\t\t\t\tconst match = isElementMatching( singleElement, pattern );\n\n\t\t\t\tif ( match ) {\n\t\t\t\t\tresults.push( {\n\t\t\t\t\t\telement: singleElement,\n\t\t\t\t\t\tpattern,\n\t\t\t\t\t\tmatch\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn results.length > 0 ? results : null;\n\t}\n\n\t/**\n\t * Returns the name of the element to match if there is exactly one pattern added to the matcher instance\n\t * and it matches element name defined by `string` (not `RegExp`). Otherwise, returns `null`.\n\t *\n\t * @returns {String|null} Element name trying to match.\n\t */\n\tgetElementName() {\n\t\tif ( this._patterns.length !== 1 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst pattern = this._patterns[ 0 ];\n\t\tconst name = pattern.name;\n\n\t\treturn ( typeof pattern != 'function' && name && !( name instanceof RegExp ) ) ? name : null;\n\t}\n}\n\n// Returns match information if {@link module:engine/view/element~Element element} is matching provided pattern.\n// If element cannot be matched to provided pattern - returns `null`.\n//\n// @param {module:engine/view/element~Element} element\n// @param {Object|String|RegExp|Function} pattern\n// @returns {Object|null} Returns object with match information or null if element is not matching.\nfunction isElementMatching( element, pattern ) {\n\t// If pattern is provided as function - return result of that function;\n\tif ( typeof pattern == 'function' ) {\n\t\treturn pattern( element );\n\t}\n\n\tconst match = {};\n\t// Check element's name.\n\tif ( pattern.name ) {\n\t\tmatch.name = matchName( pattern.name, element.name );\n\n\t\tif ( !match.name ) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t// Check element's attributes.\n\tif ( pattern.attributes ) {\n\t\tmatch.attributes = matchAttributes( pattern.attributes, element );\n\n\t\tif ( !match.attributes ) {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t// Check element's classes.\n\tif ( pattern.classes ) {\n\t\tmatch.classes = matchClasses( pattern.classes, element );\n\n\t\tif ( !match.classes ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Check element's styles.\n\tif ( pattern.styles ) {\n\t\tmatch.styles = matchStyles( pattern.styles, element );\n\n\t\tif ( !match.styles ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\treturn match;\n}\n\n// Checks if name can be matched by provided pattern.\n//\n// @param {String|RegExp} pattern\n// @param {String} name\n// @returns {Boolean} Returns `true` if name can be matched, `false` otherwise.\nfunction matchName( pattern, name ) {\n\t// If pattern is provided as RegExp - test against this regexp.\n\tif ( pattern instanceof RegExp ) {\n\t\treturn pattern.test( name );\n\t}\n\n\treturn pattern === name;\n}\n\n// Checks if an array of key/value pairs can be matched against provided patterns.\n//\n// Patterns can be provided in a following ways:\n// \t- a boolean value matches any attribute with any value (or no value):\n//\n//\t\t\tpattern: true\n//\n//\t- a RegExp expression or object matches any attribute name:\n//\n//\t\t\tpattern: /h[1-6]/\n//\n//\t- an object matches any attribute that has the same name as the object item's key, where object item's value is:\n//\t\t- equal to `true`, which matches any attribute value:\n//\n//\t\t\tpattern: {\n//\t\t\t\trequired: true\n//\t\t\t}\n//\n//\t\t- a string that is equal to attribute value:\n//\n//\t\t\tpattern: {\n//\t\t\t\trel: 'nofollow'\n//\t\t\t}\n//\n//\t\t- a regular expression that matches attribute value,\n//\n//\t\t\tpattern: {\n//\t\t\t\tsrc: /https.*/\n//\t\t\t}\n//\n//\t- an array with items, where the item is:\n//\t\t- a string that is equal to attribute value:\n//\n//\t\t\tpattern: [ 'data-property-1', 'data-property-2' ],\n//\n//\t\t- an object with `key` and `value` property, where `key` is a regular expression matching attribute name and\n//\t\t `value` is either regular expression matching attribute value or a string equal to attribute value:\n//\n//\t\t\tpattern: [\n//\t\t\t\t{ key: /data-property-.*/, value: true },\n//\t\t\t\t// or:\n//\t\t\t\t{ key: /data-property-.*/, value: 'foobar' },\n//\t\t\t\t// or:\n//\t\t\t\t{ key: /data-property-.*/, value: /foo.*/ }\n//\t\t\t]\n//\n// @param {Object} patterns Object with information about attributes to match.\n// @param {Iterable.} keys Attribute, style or class keys.\n// @param {Function} valueGetter A function providing value for a given item key.\n// @returns {Array|null} Returns array with matched attribute names or `null` if no attributes were matched.\nfunction matchPatterns( patterns, keys, valueGetter ) {\n\tconst normalizedPatterns = normalizePatterns( patterns );\n\tconst normalizedItems = Array.from( keys );\n\tconst match = [];\n\n\tnormalizedPatterns.forEach( ( [ patternKey, patternValue ] ) => {\n\t\tnormalizedItems.forEach( itemKey => {\n\t\t\tif (\n\t\t\t\tisKeyMatched( patternKey, itemKey ) &&\n\t\t\t\tisValueMatched( patternValue, itemKey, valueGetter )\n\t\t\t) {\n\t\t\t\tmatch.push( itemKey );\n\t\t\t}\n\t\t} );\n\t} );\n\n\t// Return matches only if there are at least as many of them as there are patterns.\n\t// The RegExp pattern can match more than one item.\n\tif ( !normalizedPatterns.length || match.length < normalizedPatterns.length ) {\n\t\treturn null;\n\t}\n\n\treturn match;\n}\n\n// Bring all the possible pattern forms to an array of arrays where first item is a key and second is a value.\n//\n// Examples:\n//\n// Boolean pattern value:\n//\n//\t\ttrue\n//\n// to\n//\n//\t\t[ [ true, true ] ]\n//\n// Textual pattern value:\n//\n//\t\t'attribute-name-or-class-or-style'\n//\n// to\n//\n//\t\t[ [ 'attribute-name-or-class-or-style', true ] ]\n//\n// Regular expression:\n//\n//\t\t/^data-.*$/\n//\n// to\n//\n//\t\t[ [ /^data-.*$/, true ] ]\n//\n// Objects (plain or with `key` and `value` specified explicitly):\n//\n//\t\t{\n//\t\t\tsrc: /^https:.*$/\n//\t\t}\n//\n// or\n//\n//\t\t[ {\n//\t\t\tkey: 'src',\n//\t\t\tvalue: /^https:.*$/\n//\t\t} ]\n//\n// to:\n//\n//\t\t[ [ 'src', /^https:.*$/ ] ]\n//\n// @param {Object|Array} patterns\n// @returns {Array|null} Returns an array of objects or null if provided patterns were not in an expected form.\nfunction normalizePatterns( patterns ) {\n\tif ( Array.isArray( patterns ) ) {\n\t\treturn patterns.map( pattern => {\n\t\t\tif ( isPlainObject( pattern ) ) {\n\t\t\t\tif ( pattern.key === undefined || pattern.value === undefined ) {\n\t\t\t\t\t// Documented at the end of matcher.js.\n\t\t\t\t\tlogWarning( 'matcher-pattern-missing-key-or-value', pattern );\n\t\t\t\t}\n\n\t\t\t\treturn [ pattern.key, pattern.value ];\n\t\t\t}\n\n\t\t\t// Assume the pattern is either String or RegExp.\n\t\t\treturn [ pattern, true ];\n\t\t} );\n\t}\n\n\tif ( isPlainObject( patterns ) ) {\n\t\treturn Object.entries( patterns );\n\t}\n\n\t// Other cases (true, string or regexp).\n\treturn [ [ patterns, true ] ];\n}\n\n// @param {String|RegExp} patternKey A pattern representing a key we want to match.\n// @param {String} itemKey An actual item key (e.g. `'src'`, `'background-color'`, `'ck-widget'`) we're testing against pattern.\n// @returns {Boolean}\nfunction isKeyMatched( patternKey, itemKey ) {\n\treturn patternKey === true ||\n\t\tpatternKey === itemKey ||\n\t\tpatternKey instanceof RegExp && patternKey.test( itemKey );\n}\n\n// @param {String|RegExp} patternValue A pattern representing a value we want to match.\n// @param {String} itemKey An item key, e.g. `background`, `href`, 'rel', etc.\n// @param {Function} valueGetter A function used to provide a value for a given `itemKey`.\n// @returns {Boolean}\nfunction isValueMatched( patternValue, itemKey, valueGetter ) {\n\tif ( patternValue === true ) {\n\t\treturn true;\n\t}\n\n\tconst itemValue = valueGetter( itemKey );\n\n\treturn patternValue === itemValue || patternValue instanceof RegExp && patternValue.test( itemValue );\n}\n\n// Checks if attributes of provided element can be matched against provided patterns.\n//\n// @param {Object} patterns Object with information about attributes to match. Each key of the object will be\n// used as attribute name. Value of each key can be a string or regular expression to match against attribute value.\n// @param {module:engine/view/element~Element} element Element which attributes will be tested.\n// @returns {Array|null} Returns array with matched attribute names or `null` if no attributes were matched.\nfunction matchAttributes( patterns, element ) {\n\tconst attributeKeys = new Set( element.getAttributeKeys() );\n\n\t// `style` and `class` attribute keys are deprecated. Only allow them in object pattern\n\t// for backward compatibility.\n\tif ( isPlainObject( patterns ) ) {\n\t\tif ( patterns.style !== undefined ) {\n\t\t\t// Documented at the end of matcher.js.\n\t\t\tlogWarning( 'matcher-pattern-deprecated-attributes-style-key', patterns );\n\t\t}\n\t\tif ( patterns.class !== undefined ) {\n\t\t\t// Documented at the end of matcher.js.\n\t\t\tlogWarning( 'matcher-pattern-deprecated-attributes-class-key', patterns );\n\t\t}\n\t} else {\n\t\tattributeKeys.delete( 'style' );\n\t\tattributeKeys.delete( 'class' );\n\t}\n\n\treturn matchPatterns( patterns, attributeKeys, key => element.getAttribute( key ) );\n}\n\n// Checks if classes of provided element can be matched against provided patterns.\n//\n// @param {Array.} patterns Array of strings or regular expressions to match against element's classes.\n// @param {module:engine/view/element~Element} element Element which classes will be tested.\n// @returns {Array|null} Returns array with matched class names or `null` if no classes were matched.\nfunction matchClasses( patterns, element ) {\n\t// We don't need `getter` here because patterns for classes are always normalized to `[ className, true ]`.\n\treturn matchPatterns( patterns, element.getClassNames() );\n}\n\n// Checks if styles of provided element can be matched against provided patterns.\n//\n// @param {Object} patterns Object with information about styles to match. Each key of the object will be\n// used as style name. Value of each key can be a string or regular expression to match against style value.\n// @param {module:engine/view/element~Element} element Element which styles will be tested.\n// @returns {Array|null} Returns array with matched style names or `null` if no styles were matched.\nfunction matchStyles( patterns, element ) {\n\treturn matchPatterns( patterns, element.getStyleNames( true ), key => element.getStyle( key ) );\n}\n\n/**\n * An entity that is a valid pattern recognized by a matcher. `MatcherPattern` is used by {@link ~Matcher} to recognize\n * if a view element fits in a group of view elements described by the pattern.\n *\n * `MatcherPattern` can be given as a `String`, a `RegExp`, an `Object` or a `Function`.\n *\n * If `MatcherPattern` is given as a `String` or `RegExp`, it will match any view element that has a matching name:\n *\n *\t\t// Match any element with name equal to 'div'.\n *\t\tconst pattern = 'div';\n *\n *\t\t// Match any element which name starts on 'p'.\n *\t\tconst pattern = /^p/;\n *\n * If `MatcherPattern` is given as an `Object`, all the object's properties will be matched with view element properties.\n * If the view element does not meet all of the object's pattern properties, the match will not happen.\n * Available `Object` matching properties:\n *\n * Matching view element:\n *\n *\t\t// Match view element's name using String:\n *\t\tconst pattern = { name: 'p' };\n *\n *\t\t// or by providing RegExp:\n *\t\tconst pattern = { name: /^(ul|ol)$/ };\n *\n *\t\t// The name can also be skipped to match any view element with matching attributes:\n *\t\tconst pattern = {\n *\t\t\tattributes: {\n *\t\t\t\t'title': true\n *\t\t\t}\n *\t\t};\n *\n * Matching view element attributes:\n *\n *\t\t// Match view element with any attribute value.\n *\t\tconst pattern = {\n *\t\t\tname: 'p',\n *\t\t\tattributes: true\n *\t\t};\n *\n *\t\t// Match view element which has matching attributes (String).\n *\t\tconst pattern = {\n *\t\t\tname: 'figure',\n *\t\t\tattributes: 'title' // Match title attribute (can be empty).\n *\t\t};\n *\n *\t\t// Match view element which has matching attributes (RegExp).\n *\t\tconst pattern = {\n *\t\t\tname: 'figure',\n *\t\t\tattributes: /^data-.*$/ // Match attributes starting with `data-` e.g. `data-foo` with any value (can be empty).\n *\t\t};\n *\n *\t\t// Match view element which has matching attributes (Object).\n *\t\tconst pattern = {\n *\t\t\tname: 'figure',\n *\t\t\tattributes: {\n *\t\t\t\ttitle: 'foobar', // Match `title` attribute with 'foobar' value.\n *\t\t\t\talt: true, // Match `alt` attribute with any value (can be empty).\n *\t\t\t\t'data-type': /^(jpg|png)$/ // Match `data-type` attribute with `jpg` or `png` value.\n *\t\t\t}\n *\t\t};\n *\n *\t\t// Match view element which has matching attributes (Array).\n *\t\tconst pattern = {\n *\t\t\tname: 'figure',\n *\t\t\tattributes: [\n *\t\t\t\t'title', // Match `title` attribute (can be empty).\n *\t\t\t\t/^data-*$/, // Match attributes starting with `data-` e.g. `data-foo` with any value (can be empty).\n *\t\t\t]\n *\t\t};\n *\n *\t\t// Match view element which has matching attributes (key-value pairs).\n *\t\tconst pattern = {\n *\t\t\tname: 'input',\n *\t\t\tattributes: [\n *\t\t\t\t{\n *\t\t\t\t\tkey: 'type', // Match `type` as an attribute key.\n *\t\t\t\t\tvalue: /^(text|number|date)$/ }, // Match `text`, `number` or `date` values.\n *\t\t\t\t{\n *\t\t\t\t\tkey: /^data-.*$/, // Match attributes starting with `data-` e.g. `data-foo`.\n *\t\t\t\t\tvalue: true // Match any value (can be empty).\n *\t\t\t\t}\n *\t\t\t]\n *\t\t};\n *\n * Matching view element styles:\n *\n *\t\t// Match view element with any style.\n *\t\tconst pattern = {\n *\t\t\tname: 'p',\n *\t\t\tstyles: true\n *\t\t};\n *\n *\t\t// Match view element which has matching styles (String).\n *\t\tconst pattern = {\n *\t\t\tname: 'p',\n *\t\t\tstyles: 'color' // Match attributes with `color` style.\n *\t\t};\n *\n *\t\t// Match view element which has matching styles (RegExp).\n *\t\tconst pattern = {\n *\t\t\tname: 'p',\n *\t\t\tstyles: /^border.*$/ // Match view element with any border style.\n *\t\t};\n *\n *\t\t// Match view element which has matching styles (Object).\n *\t\tconst pattern = {\n *\t\t\tname: 'p',\n *\t\t\tattributes: {\n *\t\t\t\tcolor: /rgb\\((\\d{1,3}), (\\d{1,3}), (\\d{1,3})\\)/, // Match `color` in RGB format only.\n *\t\t\t\t'font-weight': 600, // Match `font-weight` only if it's `600`.\n *\t\t\t\t'text-decoration': true // Match any text decoration.\n *\t\t\t}\n *\t\t};\n *\n *\t\t// Match view element which has matching styles (Array).\n *\t\tconst pattern = {\n *\t\t\tname: 'p',\n *\t\t\tattributes: [\n *\t\t\t\t'color', // Match `color` with any value.\n *\t\t\t\t/^border.*$/, // Match all border properties.\n *\t\t\t]\n *\t\t};\n *\n *\t\t// Match view element which has matching styles (key-value pairs).\n *\t\tconst pattern = {\n *\t\t\tname: 'p',\n *\t\t\tattributes: [\n *\t\t\t\t{\n *\t\t\t\t\tkey: 'color', // Match `color` as an property key.\n *\t\t\t\t\tvalue: /rgb\\((\\d{1,3}), (\\d{1,3}), (\\d{1,3})\\)/, // Match RGB format only.\n *\t\t\t\t{\n *\t\t\t\t\tkey: /^border.*$/, // Match any border style.\n *\t\t\t\t\tvalue: true // Match any value.\n *\t\t\t\t}\n *\t\t\t]\n *\t\t};\n *\n * Matching view element classes:\n *\n *\t\t// Match view element with any class.\n *\t\tconst pattern = {\n *\t\t\tname: 'p',\n *\t\t\tclasses: true\n *\t\t};\n *\n *\t\t// Match view element which has matching class (String).\n *\t\tconst pattern = {\n *\t\t\tname: 'p',\n *\t\t\tclasses: 'highlighted' // Match `highlighted` class.\n *\t\t};\n *\n *\t\t// Match view element which has matching classes (RegExp).\n *\t\tconst pattern = {\n *\t\t\tname: 'figure',\n *\t\t\tclasses: /^image-side-(left|right)$/ // Match `image-side-left` or `image-side-right` class.\n *\t\t};\n *\n *\t\t// Match view element which has matching classes (Object).\n *\t\tconst pattern = {\n *\t\t\tname: 'p',\n *\t\t\tclasses: {\n *\t\t\t\thighlighted: true, // Match `highlighted` class.\n *\t\t\t\tmarker: true // Match `marker` class.\n *\t\t\t}\n *\t\t};\n *\n *\t\t// Match view element which has matching classes (Array).\n *\t\tconst pattern = {\n *\t\t\tname: 'figure',\n *\t\t\tclasses: [\n *\t\t\t\t'image', // Match `image` class.\n *\t\t\t\t/^image-side-(left|right)$/ // Match `image-side-left` or `image-side-right` class.\n *\t\t\t]\n *\t\t};\n *\n *\t\t// Match view element which has matching classes (key-value pairs).\n *\t\tconst pattern = {\n *\t\t\tname: 'figure',\n *\t\t\tclasses: [\n *\t\t\t\t{\n *\t\t\t\t\tkey: 'image', // Match `image` class.\n *\t\t\t\t\tvalue: true\n *\t\t\t\t{\n *\t\t\t\t\tkey: /^image-side-(left|right)$/, // Match `image-side-left` or `image-side-right` class.\n *\t\t\t\t\tvalue: true\n *\t\t\t\t}\n *\t\t\t]\n *\t\t};\n *\n * Pattern can combine multiple properties allowing for more complex view element matching:\n *\n *\t\tconst pattern = {\n *\t\t\tname: 'span',\n *\t\t\tattributes: [ 'title' ],\n *\t\t\tstyles: {\n *\t\t\t\t'font-weight': 'bold'\n *\t\t\t},\n *\t\t\tclasses: 'highlighted'\n *\t\t};\n *\n * If `MatcherPattern` is given as a `Function`, the function takes a view element as a first and only parameter and\n * the function should decide whether that element matches. If so, it should return what part of the view element has been matched.\n * Otherwise, the function should return `null`. The returned result will be included in `match` property of the object\n * returned by {@link ~Matcher#match} call.\n *\n *\t\t// Match an empty
element.\n *\t\tconst pattern = element => {\n *\t\t\tif ( element.name == 'div' && element.childCount > 0 ) {\n *\t\t\t\t// Return which part of the element was matched.\n *\t\t\t\treturn { name: true };\n *\t\t\t}\n *\n *\t\t\treturn null;\n *\t\t};\n *\n *\t\t// Match a

element with big font (\"heading-like\" element).\n *\t\tconst pattern = element => {\n *\t\t\tif ( element.name == 'p' ) {\n *\t\t\t\tconst fontSize = element.getStyle( 'font-size' );\n *\t\t\t\tconst size = fontSize.match( /(\\d+)/px );\n *\n *\t\t\t\tif ( size && Number( size[ 1 ] ) > 26 ) {\n *\t\t\t\t\treturn { name: true, attribute: [ 'font-size' ] };\n *\t\t\t\t}\n *\t\t\t}\n *\n *\t\t\treturn null;\n *\t\t};\n *\n * `MatcherPattern` is defined in a way that it is a superset of {@link module:engine/view/elementdefinition~ElementDefinition},\n * that is, every `ElementDefinition` also can be used as a `MatcherPattern`.\n *\n * @typedef {String|RegExp|Object|Function} module:engine/view/matcher~MatcherPattern\n *\n * @property {String|RegExp} [name] View element name to match.\n * @property {String|RegExp|Array.} [classes] View element's class name(s) to match.\n * @property {Object} [styles] Object with key-value pairs representing styles to match.\n * Each object key represents style name. Value can be given as `String` or `RegExp`.\n * @property {Object} [attributes] Object with key-value pairs representing attributes to match.\n * Each object key represents attribute name. Value can be given as `String` or `RegExp`.\n */\n\n/**\n * The key-value matcher pattern is missing key or value. Both must be present.\n * Refer the documentation: {@link module:engine/view/matcher~MatcherPattern}.\n *\n * @param {Object} pattern Pattern with missing properties.\n * @error matcher-pattern-missing-key-or-value\n */\n\n/**\n * The key-value matcher pattern for `attributes` option is using deprecated `style` key.\n *\n * Use `styles` matcher pattern option instead:\n *\n * \t\t// Instead of:\n * \t\tconst pattern = {\n * \t\t\tattributes: {\n * \t\t\t\tkey1: 'value1',\n * \t\t\t\tkey2: 'value2',\n * \t\t\t\tstyle: /^border.*$/\n * \t\t\t}\n * \t\t}\n *\n * \t\t// Use:\n * \t\tconst pattern = {\n * \t\t\tattributes: {\n * \t\t\t\tkey1: 'value1',\n * \t\t\t\tkey2: 'value2'\n * \t\t\t},\n * \t\t\tstyles: /^border.*$/\n * \t\t}\n *\n * Refer to the {@glink builds/guides/migration/migration-to-29##migration-to-ckeditor-5-v2910 Migration to v29.1.0} guide\n * and {@link module:engine/view/matcher~MatcherPattern} documentation.\n *\n * @param {Object} pattern Pattern with missing properties.\n * @error matcher-pattern-deprecated-attributes-style-key\n */\n\n/**\n * The key-value matcher pattern for `attributes` option is using deprecated `class` key.\n *\n * Use `classes` matcher pattern option instead:\n *\n * \t\t// Instead of:\n * \t\tconst pattern = {\n * \t\t\tattributes: {\n * \t\t\t\tkey1: 'value1',\n * \t\t\t\tkey2: 'value2',\n * \t\t\t\tclass: 'foobar'\n * \t\t\t}\n * \t\t}\n *\n * \t\t// Use:\n * \t\tconst pattern = {\n * \t\t\tattributes: {\n * \t\t\t\tkey1: 'value1',\n * \t\t\t\tkey2: 'value2'\n * \t\t\t},\n * \t\t\tclasses: 'foobar'\n * \t\t}\n *\n * Refer to the {@glink builds/guides/migration/migration-to-29##migration-to-ckeditor-5-v2910 Migration to v29.1.0} guide\n * and the {@link module:engine/view/matcher~MatcherPattern} documentation.\n *\n * @param {Object} pattern Pattern with missing properties.\n * @error matcher-pattern-deprecated-attributes-class-key\n */\n","/**\n * @license Copyright (c) 2003-2021, CKSource - Frederico Knabben. All rights reserved.\n * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license\n */\n\n/**\n * @module engine/view/node\n */\n\nimport CKEditorError from '@ckeditor/ckeditor5-utils/src/ckeditorerror';\nimport EmitterMixin from '@ckeditor/ckeditor5-utils/src/emittermixin';\nimport mix from '@ckeditor/ckeditor5-utils/src/mix';\nimport compareArrays from '@ckeditor/ckeditor5-utils/src/comparearrays';\nimport { clone } from 'lodash-es';\n\n// To check if component is loaded more than once.\nimport '@ckeditor/ckeditor5-utils/src/version';\n\n/**\n * Abstract view node class.\n *\n * This is an abstract class. Its constructor should not be used directly.\n * Use the {@link module:engine/view/downcastwriter~DowncastWriter} or {@link module:engine/view/upcastwriter~UpcastWriter}\n * to create new instances of view nodes.\n *\n * @abstract\n */\nexport default class Node {\n\t/**\n\t * Creates a tree view node.\n\t *\n\t * @protected\n\t * @param {module:engine/view/document~Document} document The document instance to which this node belongs.\n\t */\n\tconstructor( document ) {\n\t\t/**\n\t\t * The document instance to which this node belongs.\n\t\t *\n\t\t * @readonly\n\t\t * @member {module:engine/view/document~Document}\n\t\t */\n\t\tthis.document = document;\n\n\t\t/**\n\t\t * Parent element. Null by default. Set by {@link module:engine/view/element~Element#_insertChild}.\n\t\t *\n\t\t * @readonly\n\t\t * @member {module:engine/view/element~Element|module:engine/view/documentfragment~DocumentFragment|null}\n\t\t */\n\t\tthis.parent = null;\n\t}\n\n\t/**\n\t * Index of the node in the parent element or null if the node has no parent.\n\t *\n\t * Accessing this property throws an error if this node's parent element does not contain it.\n\t * This means that view tree got broken.\n\t *\n\t * @readonly\n\t * @type {Number|null}\n\t */\n\tget index() {\n\t\tlet pos;\n\n\t\tif ( !this.parent ) {\n\t\t\treturn null;\n\t\t}\n\n\t\t// No parent or child doesn't exist in parent's children.\n\t\tif ( ( pos = this.parent.getChildIndex( this ) ) == -1 ) {\n\t\t\t/**\n\t\t\t * The node's parent does not contain this node. It means that the document tree is corrupted.\n\t\t\t *\n\t\t\t * @error view-node-not-found-in-parent\n\t\t\t */\n\t\t\tthrow new CKEditorError( 'view-node-not-found-in-parent', this );\n\t\t}\n\n\t\treturn pos;\n\t}\n\n\t/**\n\t * Node's next sibling, or `null` if it is the last child.\n\t *\n\t * @readonly\n\t * @type {module:engine/view/node~Node|null}\n\t */\n\tget nextSibling() {\n\t\tconst index = this.index;\n\n\t\treturn ( index !== null && this.parent.getChild( index + 1 ) ) || null;\n\t}\n\n\t/**\n\t * Node's previous sibling, or `null` if it is the first child.\n\t *\n\t * @readonly\n\t * @type {module:engine/view/node~Node|null}\n\t */\n\tget previousSibling() {\n\t\tconst index = this.index;\n\n\t\treturn ( index !== null && this.parent.getChild( index - 1 ) ) || null;\n\t}\n\n\t/**\n\t * Top-most ancestor of the node. If the node has no parent it is the root itself.\n\t *\n\t * @readonly\n\t * @type {module:engine/view/node~Node|module:engine/view/documentfragment~DocumentFragment}\n\t */\n\tget root() {\n\t\tlet root = this; // eslint-disable-line consistent-this\n\n\t\twhile ( root.parent ) {\n\t\t\troot = root.parent;\n\t\t}\n\n\t\treturn root;\n\t}\n\n\t/**\n\t * Returns true if the node is in a tree rooted in the document (is a descendant of one of its roots).\n\t *\n\t * @returns {Boolean}\n\t */\n\tisAttached() {\n\t\treturn this.root.is( 'rootElement' );\n\t}\n\n\t/**\n\t * Gets a path to the node. The path is an array containing indices of consecutive ancestors of this node,\n\t * beginning from {@link module:engine/view/node~Node#root root}, down to this node's index.\n\t *\n\t *\t\tconst abc = downcastWriter.createText( 'abc' );\n\t *\t\tconst foo = downcastWriter.createText( 'foo' );\n\t *\t\tconst h1 = downcastWriter.createElement( 'h1', null, downcastWriter.createText( 'header' ) );\n\t *\t\tconst p = downcastWriter.createElement( 'p', null, [ abc, foo ] );\n\t *\t\tconst div = downcastWriter.createElement( 'div', null, [ h1, p ] );\n\t *\t\tfoo.getPath(); // Returns [ 1, 3 ]. `foo` is in `p` which is in `div`. `p` starts at offset 1, while `foo` at 3.\n\t *\t\th1.getPath(); // Returns [ 0 ].\n\t *\t\tdiv.getPath(); // Returns [].\n\t *\n\t * @returns {Array.} The path.\n\t */\n\tgetPath() {\n\t\tconst path = [];\n\t\tlet node = this; // eslint-disable-line consistent-this\n\n\t\twhile ( node.parent ) {\n\t\t\tpath.unshift( node.index );\n\t\t\tnode = node.parent;\n\t\t}\n\n\t\treturn path;\n\t}\n\n\t/**\n\t * Returns ancestors array of this node.\n\t *\n\t * @param {Object} options Options object.\n\t * @param {Boolean} [options.includeSelf=false] When set to `true` this node will be also included in parent's array.\n\t * @param {Boolean} [options.parentFirst=false] When set to `true`, array will be sorted from node's parent to root element,\n\t * otherwise root element will be the first item in the array.\n\t * @returns {Array} Array with ancestors.\n\t */\n\tgetAncestors( options = { includeSelf: false, parentFirst: false } ) {\n\t\tconst ancestors = [];\n\t\tlet parent = options.includeSelf ? this : this.parent;\n\n\t\twhile ( parent ) {\n\t\t\tancestors[ options.parentFirst ? 'push' : 'unshift' ]( parent );\n\t\t\tparent = parent.parent;\n\t\t}\n\n\t\treturn ancestors;\n\t}\n\n\t/**\n\t * Returns a {@link module:engine/view/element~Element} or {@link module:engine/view/documentfragment~DocumentFragment}\n\t * which is a common ancestor of both nodes.\n\t *\n\t * @param {module:engine/view/node~Node} node The second node.\n\t * @param {Object} options Options object.\n\t * @param {Boolean} [options.includeSelf=false] When set to `true` both nodes will be considered \"ancestors\" too.\n\t * Which means that if e.g. node A is inside B, then their common ancestor will be B.\n\t * @returns {module:engine/view/element~Element|module:engine/view/documentfragment~DocumentFragment|null}\n\t */\n\tgetCommonAncestor( node, options = {} ) {\n\t\tconst ancestorsA = this.getAncestors( options );\n\t\tconst ancestorsB = node.getAncestors( options );\n\n\t\tlet i = 0;\n\n\t\twhile ( ancestorsA[ i ] == ancestorsB[ i ] && ancestorsA[ i ] ) {\n\t\t\ti++;\n\t\t}\n\n\t\treturn i === 0 ? null : ancestorsA[ i - 1 ];\n\t}\n\n\t/**\n\t * Returns whether this node is before given node. `false` is returned if nodes are in different trees (for example,\n\t * in different {@link module:engine/view/documentfragment~DocumentFragment}s).\n\t *\n\t * @param {module:engine/view/node~Node} node Node to compare with.\n\t * @returns {Boolean}\n\t */\n\tisBefore( node ) {\n\t\t// Given node is not before this node if they are same.\n\t\tif ( this == node ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Return `false` if it is impossible to compare nodes.\n\t\tif ( this.root !== node.root ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst thisPath = this.getPath();\n\t\tconst nodePath = node.getPath();\n\n\t\tconst result = compareArrays( thisPath, nodePath );\n\n\t\tswitch ( result ) {\n\t\t\tcase 'prefix':\n\t\t\t\treturn true;\n\n\t\t\tcase 'extension':\n\t\t\t\treturn false;\n\n\t\t\tdefault:\n\t\t\t\treturn thisPath[ result ] < nodePath[ result ];\n\t\t}\n\t}\n\n\t/**\n\t * Returns whether this node is after given node. `false` is returned if nodes are in different trees (for example,\n\t * in different {@link module:engine/view/documentfragment~DocumentFragment}s).\n\t *\n\t * @param {module:engine/view/node~Node} node Node to compare with.\n\t * @returns {Boolean}\n\t */\n\tisAfter( node ) {\n\t\t// Given node is not before this node if they are same.\n\t\tif ( this == node ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Return `false` if it is impossible to compare nodes.\n\t\tif ( this.root !== node.root ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// In other cases, just check if the `node` is before, and return the opposite.\n\t\treturn !this.isBefore( node );\n\t}\n\n\t/**\n\t * Removes node from parent.\n\t *\n\t * @protected\n\t */\n\t_remove() {\n\t\tthis.parent._removeChildren( this.index );\n\t}\n\n\t/**\n\t * @protected\n\t * @param {module:engine/view/document~ChangeType} type Type of the change.\n\t * @param {module:engine/view/node~Node} node Changed node.\n\t * @fires change\n\t */\n\t_fireChange( type, node ) {\n\t\tthis.fire( 'change:' + type, node );\n\n\t\tif ( this.parent ) {\n\t\t\tthis.parent._fireChange( type, node );\n\t\t}\n\t}\n\n\t/**\n\t * Custom toJSON method to solve child-parent circular dependencies.\n\t *\n\t * @returns {Object} Clone of this object with the parent property removed.\n\t */\n\ttoJSON() {\n\t\tconst json = clone( this );\n\n\t\t// Due to circular references we need to remove parent reference.\n\t\tdelete json.parent;\n\n\t\treturn json;\n\t}\n\n\t/**\n\t * Checks whether this object is of the given type.\n\t *\n\t * This method is useful when processing view objects that are of unknown type. For example, a function\n\t * may return a {@link module:engine/view/documentfragment~DocumentFragment} or a {@link module:engine/view/node~Node}\n\t * that can be either a text node or an element. This method can be used to check what kind of object is returned.\n\t *\n\t *\t\tsomeObject.is( 'element' ); // -> true if this is an element\n\t *\t\tsomeObject.is( 'node' ); // -> true if this is a node (a text node or an element)\n\t *\t\tsomeObject.is( 'documentFragment' ); // -> true if this is a document fragment\n\t *\n\t * Since this method is also available on a range of model objects, you can prefix the type of the object with\n\t * `model:` or `view:` to check, for example, if this is the model's or view's element:\n\t *\n\t *\t\tviewElement.is( 'view:element' ); // -> true\n\t *\t\tviewElement.is( 'model:element' ); // -> false\n\t *\n\t * By using this method it is also possible to check a name of an element:\n\t *\n\t *\t\timgElement.is( 'element', 'img' ); // -> true\n\t *\t\timgElement.is( 'view:element', 'img' ); // -> same as above, but more precise\n\t *\n\t * The list of view objects which implement the `is()` method:\n\t *\n\t * * {@link module:engine/view/attributeelement~AttributeElement#is `AttributeElement#is()`}\n\t * * {@link module:engine/view/containerelement~ContainerElement#is `ContainerElement#is()`}\n\t * * {@link module:engine/view/documentfragment~DocumentFragment#is `DocumentFragment#is()`}\n\t * * {@link module:engine/view/documentselection~DocumentSelection#is `DocumentSelection#is()`}\n\t * * {@link module:engine/view/editableelement~EditableElement#is `EditableElement#is()`}\n\t * * {@link module:engine/view/element~Element#is `Element#is()`}\n\t * * {@link module:engine/view/emptyelement~EmptyElement#is `EmptyElement#is()`}\n\t * * {@link module:engine/view/node~Node#is `Node#is()`}\n\t * * {@link module:engine/view/position~Position#is `Position#is()`}\n\t * * {@link module:engine/view/range~Range#is `Range#is()`}\n\t * * {@link module:engine/view/rooteditableelement~RootEditableElement#is `RootEditableElement#is()`}\n\t * * {@link module:engine/view/selection~Selection#is `Selection#is()`}\n\t * * {@link module:engine/view/text~Text#is `Text#is()`}\n\t * * {@link module:engine/view/textproxy~TextProxy#is `TextProxy#is()`}\n\t * * {@link module:engine/view/uielement~UIElement#is `UIElement#is()`}\n\t *\n\t * @method #is\n\t * @param {String} type Type to check.\n\t * @returns {Boolean}\n\t */\n\tis( type ) {\n\t\treturn type === 'node' || type === 'view:node';\n\t}\n\n\t/**\n\t * Clones this node.\n\t *\n\t * @protected\n\t * @method #_clone\n\t * @returns {module:engine/view/node~Node} Clone of this node.\n\t */\n\n\t/**\n\t * Checks if provided node is similar to this node.\n\t *\n\t * @method #isSimilar\n\t * @returns {Boolean} True if nodes are similar.\n\t */\n}\n\n/**\n * Fired when list of {@link module:engine/view/element~Element elements} children changes.\n *\n * Change event is bubbled – it is fired on all ancestors.\n *\n * @event change:children\n * @param {module:engine/view/node~Node} changedNode\n */\n\n/**\n * Fired when list of {@link module:engine/view/element~Element elements} attributes changes.\n *\n * Change event is bubbled – it is fired on all ancestors.\n *\n * @event change:attributes\n * @param {module:engine/view/node~Node} changedNode\n */\n\n/**\n * Fired when {@link module:engine/view/text~Text text nodes} data changes.\n *\n * Change event is bubbled – it is fired on all ancestors.\n *\n * @event change:text\n * @param {module:engine/view/node~Node} changedNode\n */\n\n/**\n * @event change\n */\n\nmix( Node, EmitterMixin );\n"],"sourceRoot":""}