# Path: wikitextparser/_config.py
# def _plant_trie(strings: _Iterable[str]) -> dict:
# def _pattern(trie: dict) -> str:
# def regex_pattern(words: _Iterable[str]) -> bytes:
# _HTML_TAG_NAME = regex_pattern(_valid_html_tag_names) + br'\b'


from functools import partial
from typing import Callable, Dict, Optional
from regex import DOTALL, REVERSE, compile as regex_compile, IGNORECASE
from ._config import (
    _HTML_TAG_NAME, _bare_external_link_schemes, _parsable_tag_extensions,
    _parser_functions, _unparsable_tag_extensions, regex_pattern)
WIKILINK_PARAM_FINDITER = regex_compile(  # noqa
    rb'(?<!(?>^|[^\[\0])(?:(?>\[\0*+){2})*+\[\0*+)'  # != 2N + 1
    rb'\[\0*\['
    rb'(?![\ \0]*+' + BARE_EXTERNAL_LINK + rb')'
    + VALID_TITLE_CHARS +
    rb'(?>'
        rb'\|'
        rb'(?>'
            rb'(?<!\[\0*+)'
            rb'\['
        rb')?+'
        rb'(?>'
            rb'(?<!\]\0*+)'
            rb'\]'
        rb')?+'
        # single matching brackets are allowed in text e.g. [[a|[b]]]
        rb'(?>'
            rb'[^\[\]\|]*+'
            rb'\['
            rb'[^\[\]\|]*+'
            rb'\]'
            rb'(?!(?:\0*+\]){3})'
        rb')?+'
        rb'[^\[\]\|]*+'
    rb')*+'
    rb'\]\0*+\]'
    rb'|\{\{\{('
        rb'[^{}]++'
        rb'|(?<!})}(?!})'
        rb'|(?<!{){'

# Path: wikitextparser/_config.py
# def _plant_trie(strings: _Iterable[str]) -> dict:
# def _pattern(trie: dict) -> str:
# def regex_pattern(words: _Iterable[str]) -> bytes:
# _HTML_TAG_NAME = regex_pattern(_valid_html_tag_names) + br'\b'


# Path: wikitextparser/_spans.py
from functools import partial
from typing import Callable, Dict, Optional
from regex import DOTALL, REVERSE, compile as regex_compile, IGNORECASE
from ._config import (
    _HTML_TAG_NAME, _bare_external_link_schemes, _parsable_tag_extensions,
    _parser_functions, _unparsable_tag_extensions, regex_pattern)

WIKILINK_PARAM_FINDITER = regex_compile(  # noqa
    rb'(?<!(?>^|[^\[\0])(?:(?>\[\0*+){2})*+\[\0*+)'  # != 2N + 1
    rb'\[\0*\['
    rb'(?![\ \0]*+' + BARE_EXTERNAL_LINK + rb')'
    + VALID_TITLE_CHARS +
    rb'(?>'
        rb'\|'
        rb'(?>'
            rb'(?<!\[\0*+)'
            rb'\['
        rb')?+'
        rb'(?>'
            rb'(?<!\]\0*+)'
            rb'\]'
        rb')?+'
        # single matching brackets are allowed in text e.g. [[a|[b]]]
        rb'(?>'
            rb'[^\[\]\|]*+'
            rb'\['
            rb'[^\[\]\|]*+'
            rb'\]'
            rb'(?!(?:\0*+\]){3})'
        rb')?+'
        rb'[^\[\]\|]*+'
    rb')*+'
    rb'\]\0*+\]'
    rb'|\{\{\{('
        rb'[^{}]++'
        rb'|(?<!})}(?!})'
        rb'|(?<!{){'

    rb')++\}\}\}',