/* harmony default export */

/* harmony export (binding) */

/* harmony import */

/*#__PURE__*/

/**
	* If provided a value, the accumulator function returns an updated mean. If not provided a value, the accumulator function returns the current mean.
	*
	* @private
	* @param {number} [x] - input value
	* @returns {(number|null)} mean or null
	*/

/**
	* If provided a value, the accumulator function returns an updated range. If not provided a value, the accumulator function returns the current range.
	*
	* @private
	* @param {number} [x] - input value
	* @returns {(number|null)} range or null
	*/

/**
   * A Callback fired by the Overlay when it wishes to be hidden.
   *
   * __required__ when `rootClose` is `true`.
   *
   * @type func
   */

/**
   * A DOM Element, Ref to an element, or function that returns either. The `container` will have the Portal children
   * appended to it.
   */

/**
   * A DOM Element, Ref to an element, or function that returns either. The `target` element is where
   * the overlay is positioned relative to.
   */

/**
   * A `react-transition-group@2.0.0` `<Transition/>` component
   * used to animate the overlay as it changes visibility.
   */

/**
   * A render prop that returns an element to overlay and position. See
   * the [react-popper documentation](https://github.com/FezVrasta/react-popper#children) for more info.
   *
   * @type {Function ({
   *   show: boolean,
   *   placement: Placement,
   *   outOfBoundaries: ?boolean,
   *   scheduleUpdate: () => void,
   *   props: {
   *     ref: (?HTMLElement) => void,
   *     style: { [string]: string | number },
   *     aria-labelledby: ?string
   *   },
   *   arrowProps: {
   *     ref: (?HTMLElement) => void,
   *     style: { [string]: string | number },
   *   },
   * }) => React.Element}
   */

/**
   * A set of popper options and props passed directly to react-popper's Popper component.
   */

/**
   * Add empty cells due to rowspan
   *
   * @param {Object} params
   *   @param {Array} rows
   *   @param {Object} cell
   *   @param {Number} rowIndex Current row index
   *   @param {Number} cellIndex Current cell index
   */

/**
   * Apply style and classes from all the parents
   *
   * @param  {Object} params
   *   @param {Object} ret The object that will receive the 'style' and other properties
   *   @param {Array} parents Array of node elements
   * @return {Object} the modified 'ret'
   */

/**
   * Callback fired after the Overlay finishes transitioning in
   */

/**
   * Callback fired after the Overlay finishes transitioning out
   */

/**
   * Callback fired as the Overlay begins to transition in
   */

/**
   * Callback fired as the Overlay begins to transition out
   */

/**
   * Callback fired before the Overlay transitions in
   */

/**
   * Callback fired right before the Overlay transitions out
   */

/**
   * Control how much space there is between the edge of the boundary element and overlay.
   * A convenience shortcut to setting `popperConfig.modfiers.preventOverflow.padding`
   */

/**
   * Convert 'px'/'rem' to 'pt', and return false for the other ones. If it's only a number, it will just return it
   *
   * @param  {String} val The value with units (e.g. 12px)
   * @return {Number|Boolean} Return the pt value, or false
   */

/**
   * Converts a single HTML element to pdfmake, calls itself recursively for child html elements
   *
   * @param element can be an HTML element (<p>) or plain text ("Hello World")
   * @param parentNode the parent node for the current element
   * @param parents Array of node names of all the parents for the element
   * @returns the doc def to the given element in consideration to the given paragraph and styles
   */

/**
   * Enables the Popper.js `flip` modifier, allowing the Overlay to
   * automatically adjust it's placement in case of overlap with the viewport or toggle.
   * Refer to the [flip docs](https://popper.js.org/popper-documentation.html#modifiers..flip.enabled) for more info
   */

/**
   * Permit to change the default styles based on the options
   */

/**
   * Returns the color in a hex format (e.g. #12ff00).
   * Also tries to convert RGB colors into hex values
   *
   * @param color color as string representation
   * @returns color as hex values for pdfmake
   */

/**
   * Set the visibility of the Overlay
   */

/**
   * Specify disabled for disable RootCloseWrapper
   */

/**
   * Specify event for toggling overlay
   */

/**
   * Specify whether the overlay should trigger `onHide` when the user clicks outside the overlay
   */

/**
   * Takes an HTML string, converts to HTML using a DOM parser and recursivly parses
   * the content into pdfmake compatible doc definition
   *
   * @param htmlText the html text to translate as string
   * @returns pdfmake doc definition as object
   */

/**
   * Transform a CSS expression (e.g. 'margin:10px') in the PDFMake version
   *
   * @param {String} style The CSS expression to transform
   * @param {DOMElement} element
   * @param {Boolean} ignoreProperties TRUE when we have to ignore some properties, like border, padding, margin
   * @returns {Array} array of {key, value}
   */

/**
  To use it:
  import htmlToPdfMake from 'html-to-pdfmake.js'
  htmlToPdfMake('<b>my bold text</b>');
*/

/**
 * Iterates through children that are "valid elements".
 *
 * The provided forEachFunc(child, index) will be called for each
 * leaf child with the index reflecting the position relative to "valid components".
 */

/**
 * Iterates through children that are typically specified as `props.children`,
 * but only maps over children that are "valid elements".
 *
 * The mapFunction provided index will be normalised to the components mapped,
 * so an invalid component would not increase the index.
 *
 */

/**
 * Transform HTML code to a PdfMake object
 * @param  {String} htmlText The HTML code to transform
 * @param  {Object} [options]
 *   @param  {Object} [defaultStyles] An object with the default styles for each elements
 *   @param  {Boolean} [tableAutoSize=false] It permits to use the width/height defined in styles for a table's cells and rows
 *   @param  {Object} [window] The `window` object (required for NodeJS server side use)
 * @return {Object} it returns a PdfMake object
 *
 * @example
 * // Some styles are applied by defaults for the supported HTML elements
 * // but you can pass your own styles if you prefer
 * htmlToPdfMake('<div><h1>My Title</h1><p>My paragraph</p></div>');
 *
 * // If you want to overwrite the default styles, e.g. you want <li> to not have a margin-left, and links to be 'purple' and not 'blue', and links without 'underline'
 * htmlToPdfMake('<ul><li>this is <a href="...">a link</a></li><li>another item</li></ul>', {
 *   defaultStyles:{
 *     a:{
 *       color:'purple',
 *       decoration:null
 *     },
 *     li:null
 *   }
 * });
 */

/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*    http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* Compute a moving arithmetic mean incrementally.
*
* @module @stdlib/stats/incr/mmean
*
* @example
* var incrmmean = require( '@stdlib/stats/incr/mmean' );
*
* var accumulator = incrmmean( 3 );
*
* var mu = accumulator();
* // returns null
*
* mu = accumulator( 2.0 );
* // returns 2.0
*
* mu = accumulator( -5.0 );
* // returns -1.5
*
* mu = accumulator( 3.0 );
* // returns 0.0
*
* mu = accumulator( 5.0 );
* // returns 1.0
*
* mu = accumulator();
* // returns 1.0
*/

/**
* Compute a moving range incrementally.
*
* @module @stdlib/stats/incr/mrange
*
* @example
* var incrmrange = require( '@stdlib/stats/incr/mrange' );
*
* var accumulator = incrmrange( 3 );
*
* var r = accumulator();
* // returns null
*
* r = accumulator( 2.0 );
* // returns 0.0
*
* r = accumulator( -5.0 );
* // returns 7.0
*
* r = accumulator( 3.0 );
* // returns 8.0
*
* r = accumulator( 5.0 );
* // returns 10.0
*
* r = accumulator();
* // returns 10.0
*/

/**
* Returns an accumulator function which incrementally computes a moving arithmetic mean.
*
* @param {PositiveInteger} W - window size
* @throws {TypeError} must provide a positive integer
* @returns {Function} accumulator function
*
* @example
* var accumulator = incrmmean( 3 );
*
* var mu = accumulator();
* // returns null
*
* mu = accumulator( 2.0 );
* // returns 2.0
*
* mu = accumulator( -5.0 );
* // returns -1.5
*
* mu = accumulator( 3.0 );
* // returns 0.0
*
* mu = accumulator( 5.0 );
* // returns 1.0
*
* mu = accumulator();
* // returns 1.0
*/

/**
* Returns an accumulator function which incrementally computes a moving range.
*
* @param {PositiveInteger} W - window size
* @throws {TypeError} must provide a positive integer
* @returns {Function} accumulator function
*
* @example
* var accumulator = incrmrange( 3 );
*
* var r = accumulator();
* // returns null
*
* r = accumulator( 2.0 );
* // returns 0.0
*
* r = accumulator( -5.0 );
* // returns 7.0
*
* r = accumulator( 3.0 );
* // returns 8.0
*
* r = accumulator( 5.0 );
* // returns 10.0
*
* r = accumulator();
* // returns 10.0
*/

/**
* Test if a string ends with the characters of another string.
*
* @module @stdlib/string/ends-with
*
* @example
* var endsWith = require( '@stdlib/string/ends-with' );
*
* var str = 'Fair is foul, and foul is fair, hover through fog and filthy air';
*
* var bool = endsWith( str, 'air' );
* // returns true
*
* bool = endsWith( str, 'fair' );
* // returns false
*
* bool = endsWith( str, 'fair', 30 );
* // returns true
*
* bool = endsWith( str, 'fair', -34 );
* // returns true
*/

/**
* Test if a string ends with the characters of another string.
*
* @param {string} str - input string
* @param {string} search - search string
* @param {integer} [len=str.length] - substring length
* @throws {TypeError} first argument must be a string primitive
* @throws {TypeError} second argument must be a string primitive
* @throws {TypeError} third argument must be an integer
* @returns {boolean} boolean indicating if the input string ends with the search string
*
* @example
* var bool = endsWith( 'Remember the story I used to tell you when you were a boy?', 'boy?' );
* // returns true
*
* @example
* var bool = endsWith( 'Remember the story I used to tell you when you were a boy?', 'Boy?' );
* // returns false
*
* @example
* var bool = endsWith( 'To be, or not to be, that is the question.', 'to be' );
* // returns false
*
* @example
* var bool = endsWith( 'To be, or not to be, that is the question.', 'to be', 19 );
* // returns true
*
* @example
* var bool = endsWith( 'To be, or not to be, that is the question.', 'to be', -23 );
* // returns true
*/

/** Specify where the overlay element is positioned in relation to the target element */

/***/

// 1) the default styles

// 1px => 0.75292857248934pt

// 2) element's style

// @ts-ignore

// Based on the premise that every string can be "surrounded" by empty strings (e.g., "" + "a" + "" + "b" + "" === "ab"):

// Case: incoming value is NaN, the sliding mean is automatically NaN...

// Case: incoming value is NaN...

// Case: the current mean is NaN, so nothing to do until the buffer no longer contains NaN values...

// Case: updating existing window; however, the minimum and maximum values do not change so nothing to do but update our buffer...

// Create a HTML DOM tree out of html string

// Don't bother showing anything if we don't have to.

// Don't un-render the overlay while it's transitioning out.

// ELEMENT_NODE

// EXPORTS //

// MAIN //

// MODULES //

// Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595

// TEXT_NODE

// Update the index for managing the circular buffer:

// We provide an empty the TabContext so `<Nav>`s in `<TabPane>`s don't

// and https://github.com/bpampuch/pdfmake/issues/205

// apply all the inhirent classes and styles from the parents

// apply all the inhirent classes and styles from the parents, or for the current element

// array of boolean

// array of colors

// check if we have "width" or "height"

// check if we have colspan or rowspan

// check if we have some data-pdfmake to apply

// chekck if we have some data-pdfmake to apply

// classes

// conflict with the top level one.

// convert value to a 'pt' when possible

// default style for the HR

// determine the max height for each row

// determine the max width for each cell

// do we have a colSpan?

// do we have a rowSpan ?

// do we have a rowSpan in addition of the colSpan?

// e.g. `#fff` or `#ff0048`

// explicitly set to avoid `N < W` branch

// fill the gaps

// for BR we return '\n'

// for borders

// for each THEAD / TBODY

// for each cell

// for each row

// for the color

// for the width

// if TH/TD and key is 'background', then we use 'fillColor' instead

// if it's just a number, then return it

// if option tableAutoSize, then we try to apply the correct width/height on the table

// if we don't have a number with supported units, then return false

// if we want to delete a specific property

// if we want to remove a default style

// if yes, insert empty cells due to colspan

// ignore if we have a FALSE in the table

// ignore some HTML tags

// ignore some properties

// keep adding empty cell due to rowspan

// mean is automatically NaN, so no need to continue

// no need to continue searching

// not all the CSS properties should be inhirent

// padding is not supported by PDFMake

// pdfMake uses a different order than CSS

// remove first level

// source: https://github.com/OpenSlides/OpenSlides/blob/f4f8b8422f9b3fbab58e35ac3f8f870d35813b7d/client/src/app/core/ui-services/html-to-pdf.service.ts

// the format for the table is table.body[[], [], …]

// top | right | bottom | left ==> left | top | right | bottom

// we can override the default HR style with "data-pdfmake"

// we have 3 properties: width style color

// we have to merge together the borders in two properties

// we now need to convert to PT

// we want TD/TH to receive descendent properties from TR

// we want to remember the different sizes

//var util = require("util"); // to debug
