'use strict';

require('../../../../../stringify-entities@4.0.4/node_modules/stringify-entities/index.js');
var index = require('../../../../../stringify-entities@4.0.4/node_modules/stringify-entities/lib/index.js');

/**
 * @typedef {import('../types.js').State} State
 * @typedef {import('../types.js').Parent} Parent
 * @typedef {import('../types.js').Raw} Raw
 * @typedef {import('../types.js').Text} Text
 */


/**
 * Serialize a text node.
 *
 * @param {Text | Raw} node
 *   Node to handle.
 * @param {number | undefined} _
 *   Index of `node` in `parent.
 * @param {Parent | undefined} parent
 *   Parent of `node`.
 * @param {State} state
 *   Info passed around about the current state.
 * @returns {string}
 *   Serialized node.
 */
function text(node, _, parent, state) {
  // Check if content of `node` should be escaped.
  return parent &&
    parent.type === 'element' &&
    (parent.tagName === 'script' || parent.tagName === 'style')
    ? node.value
    : index.stringifyEntities(
        node.value,
        Object.assign({}, state.settings.characterReferences, {
          subset: ['<', '&']
        })
      )
}

exports.text = text;
//# sourceMappingURL=text.js.map
