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A,MACAyE,EAAAtB,GAAAnD,GACA,IAAAyE,EAAA,UAAA1hB,MAAA,WAAwCid,qEAA0ElY,OAAA2D,KAAA0X,IAAAhU,KAAA,SAClH,IAAAjF,EAAAqD,EAAAC,GACA,OAAAtD,IAAAA,EAAA,UAAAsD,EAAAvK,OAAA,GAAAuK,EAAAiB,UAAA,EAAAjB,EAAA1K,OAAA,GAAA0K,GACA,MAAAhB,EAAA,GAEA,GADAqV,GAAArU,EAAAtD,EAAAsD,EAAAC,SAAA,OACAjB,EAAAkY,QAAA,UAAA3hB,MAAA,WAA+CyK,kIAS/C,wCAA2CA,wGAEzCiX,EAVF,4BAEUxM,KAAAC,UAAA1K,gBACAyK,KAAAC,UAAerN,EAAM2B,EAAAkY,QAAAC,4CAE7BnY,EAAAkY,QAAAxa,iBAKAsD,IACF,EAuCAoX,oBApCA,SAAAC,GACA,IAAAA,GAAA,mBAAAA,EAAAhE,OAAA,UAAA9d,MAAA,gEACA,GAA0B,IAA1B8hB,EAAA7E,OAAgC,UAAAjd,MAAA,2DAA6E8hB,EAAA7E,8DAC7G,MAAA2E,EAAe3Y,EAAM6Y,EAAAF,KAAA/R,GAAAmN,QAAAzZ,MACrBwe,EAAA,IAAoBlS,GAAAmN,WAAA4E,GASpB,OARA5X,EAAArI,IAAAmgB,EAAAlgB,KAAA,CACAgT,OAAA,GAEAnE,MAAA,KACAqN,OAAA,CAAAhS,EAAA0N,IAAAsI,EAAAhE,OAAAhS,EAAAiW,EAAAvI,GACAwF,aAAA,EACAiB,aAAA,IAEA6B,EAAAlgB,IACA,EAuBAogB,UAAAlE","sources":["webpack://teddy/webpack/bootstrap","webpack://teddy/./cheerioPolyfill.js","webpack://teddy/./compiler.js","webpack://teddy/./precompiled.js","webpack://teddy/./teddy.js"],"sourcesContent":["// The module cache\nconst __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tconst cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tconst module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// stub out cheerio using native dom methods for frontend so we don't have to bundle cheerio on the frontend\nexport function load (html) {\n  const doc = parseTeddyDOMFromString(html) // create a DOM\n\n  // return a querySelector function with function chains\n  //\n  // e.g. dom('include') or dom(el) from teddy\n  const $ = function (query) { // query can be a string, or a dom object\n    // if query is a string, we need to create a dom object from the string: an object with elements in it, e.g. a list of include tag objects\n    if (typeof query === 'string') {\n      return queryAll(doc, query) // return the object collection\n    }\n\n    // if query is an object, it's assumed we're trying to perform operations on a single dom node\n    const el = query\n    return {\n\n      // e.g. dom(el).children() from teddy\n      children: function () {\n        return Array.from(childrenOf(el).childNodes).filter(node => node.nodeType === 1)\n      },\n\n      // e.g. dom(el).contents() from teddy, which is every child node rather than only the elements among them\n      contents: function () {\n        return childrenOf(el).childNodes\n      },\n\n      // e.g. dom(el).find() from teddy\n      find: function (selector) {\n        return queryAll(el, selector)\n      },\n\n      // e.g. dom(arg).html() from teddy\n      html: function () {\n        return getTeddyDOMInnerHTML(el)\n      },\n\n      // e.g. dom(arg).toString() from teddy\n      toString: function () {\n        return getTeddyDOMOuterHTML(el)\n      },\n\n      // e.g. dom(el).attr('teddydeferreddynamicinclude', 'true') from teddy\n      attr: function (attr, val) {\n        return el.setAttribute(attr, val)\n      },\n\n      // dom(el).removeAttr(attr) from teddy\n      removeAttr: function (attr) {\n        return el.removeAttribute(attr)\n      },\n\n      // e.g. dom(el).replaceWith(localDom.html()) from teddy\n      replaceWith: function (html) {\n        // can either be a string or an array of elements\n        if (typeof html === 'object') {\n          let newHtml = ''\n          for (const el of html) {\n            if (el.nodeType === window.Node.COMMENT_NODE) newHtml += '<!--' + el.textContent + '-->'\n            else newHtml += el.outerHTML || el.textContent\n          }\n          html = newHtml\n        }\n        const temp = document.createElement('div')\n        temp.innerHTML = html\n        el.replaceWith(...temp.childNodes)\n      },\n\n      // e.g. dom(el).remove() from teddy\n      remove: function () {\n        return el.remove()\n      }\n    }\n  }\n\n  // e.g. dom.html() from teddy\n  $.html = function () {\n    return getTeddyDOMInnerHTML(doc)\n  }\n\n  // e.g. dom.toString() from teddy\n  $.toString = function () {\n    return getTeddyDOMOuterHTML(doc)\n  }\n\n  return $\n}\n\nload.isCheerioPolyfill = true\n\n// DOM parser function like DOMParser's parseFromString but allows Teddy elements to exist in places where they otherwise wouldn't be allowed, like inside of <select> elements\nfunction parseTeddyDOMFromString (html) {\n  const selfClosingTags = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'])\n  const root = document.createElement('body')\n  const dom = [root]\n  const openTags = [] // stack to track open tags\n  const tagAndCommentRegex = /<\\/?([a-zA-Z][a-zA-Z0-9-]*)([^>]*)>|<!--([\\s\\S]*?)-->/g\n  // the = belongs to both forms of a value. it used to sit inside the quoted form only, so an unquoted value such as src=x was read as the value \"=x\"\n  const attrRegex = /([a-zA-Z0-9-:._]+)(?:=(?:([\"'])(.*?)\\2|([^>\\s]+)))?/g\n  // elements whose contents a browser reads as plain text rather than as markup, so a tag written inside one is not a tag. teddy leaves their contents alone on the server for the same reason\n  const rawTextTags = new Set(['script', 'style', 'textarea'])\n  let lastIndex = 0\n  let match\n\n  // loop through each match and build a DOM\n  while ((match = tagAndCommentRegex.exec(html)) !== null) {\n    if (!dom[dom.length - 1]) throw new Error('Error parsing your template. There may be a coding mistake in your HTML. Look for extra closing </tags> and other common mistakes.')\n    const textBeforeMatch = html.slice(lastIndex, match.index)\n\n    // append text nodes\n    if (textBeforeMatch.trim()) {\n      const textNode = document.createTextNode(textBeforeMatch)\n      childrenOf(dom[dom.length - 1]).appendChild(textNode)\n    }\n\n    if (match[0].startsWith('<!--')) {\n      // handle comments\n      const commentNode = document.createComment(match[3])\n      childrenOf(dom[dom.length - 1]).appendChild(commentNode)\n    } else {\n      // handle tags\n      const [fullMatch, tagName, attrString] = match\n      const lowerCaseTagName = tagName.toLowerCase()\n      const isClosingTag = fullMatch.startsWith('</')\n      if (isClosingTag) {\n        if (selfClosingTags.has(lowerCaseTagName)) {\n          // convert incorrect closing tag for self-closing tag to self-closing tag\n          const element = document.createElement(tagName)\n          childrenOf(dom[dom.length - 1]).appendChild(element)\n        } else {\n          // check if the closing tag matches the most recent open tag\n          if (openTags.length > 0 && openTags[openTags.length - 1] === lowerCaseTagName) {\n            openTags.pop()\n            dom.pop()\n          }\n        }\n      } else {\n        // create a new element\n        const element = document.createElement(tagName)\n\n        // set attributes\n        let attrMatch\n        const attrMap = new Map()\n        while ((attrMatch = attrRegex.exec(attrString)) !== null) {\n          const attrName = attrMatch[1]\n          const attrValue = attrMatch[3] || attrMatch[4] || ''\n\n          // handle duplicate attributes for special tags\n          if (attrMap.has(attrName)) {\n            let count = 1\n            let newAttrName\n            do {\n              newAttrName = `${attrName}-teddyduplicate${count}`\n              count++\n            } while (attrMap.has(newAttrName))\n            attrMap.set(newAttrName, attrValue)\n          } else attrMap.set(attrName, attrValue)\n        }\n\n        // apply attributes to the element\n        for (const [name, value] of attrMap) {\n          try {\n            // replace elements with `src` attributes with `data-teddy-defer-attr-src` so the browser doesn't try to prefetch the asset\n            //\n            // this is needed because the value of the `src` attribute could be a {teddyVariable} and that fetch won't resolve\n            switch (lowerCaseTagName) {\n              case 'img':\n              case 'video':\n              case 'audio':\n              case 'iframe':\n              case 'script':\n                if (name === 'src') element.setAttribute('data-teddy-defer-attr-src', value) // replace src with data-teddy-defer-attr-src\n                else element.setAttribute(name, value || '')\n                break\n              case 'link':\n                if (name === 'href') element.setAttribute('data-teddy-defer-attr-href', value) // replace src with data-teddy-defer-attr-href\n                else element.setAttribute(name, value || '')\n                break\n              default:\n                element.setAttribute(name, value || '')\n            }\n          } catch (e) {\n            console.warn('Error parsing an element attribute. You might have a typo in your HTML. A common cause is two spaces between element attributes.')\n          }\n        }\n\n        // a template's children go into a fragment of its own, which has no way back to the template it belongs to. teddy walks up from an element to see what encloses it, so the way back is written here: without it a construct inside a template would look like the outermost one\n        if (isTemplate(element)) element.content.teddyTemplateHost = element\n\n        // append the new element to the current parent\n        childrenOf(dom[dom.length - 1]).appendChild(element)\n\n        // push the new element to the dom if it's not self-closing\n        if (!selfClosingTags.has(lowerCaseTagName) && !fullMatch.endsWith('/>')) {\n          if (rawTextTags.has(lowerCaseTagName)) {\n            // everything up to the element's closing tag is its text, however much of it looks like markup\n            const closeTag = new RegExp(`</${lowerCaseTagName}\\\\s*>`, 'ig')\n            closeTag.lastIndex = tagAndCommentRegex.lastIndex\n            const close = closeTag.exec(html)\n            const end = close ? close.index : html.length\n            const text = html.slice(tagAndCommentRegex.lastIndex, end)\n            if (text) element.appendChild(document.createTextNode(text))\n            tagAndCommentRegex.lastIndex = close ? closeTag.lastIndex : html.length\n          } else {\n            dom.push(element)\n            openTags.push(lowerCaseTagName)\n          }\n        }\n      }\n    }\n\n    lastIndex = tagAndCommentRegex.lastIndex\n  }\n\n  // append any remaining text after the last match\n  if (lastIndex < html.length) {\n    const remainingText = html.slice(lastIndex)\n    if (remainingText.trim()) {\n      const textNode = document.createTextNode(remainingText)\n      childrenOf(dom[dom.length - 1]).appendChild(textNode)\n    }\n  }\n\n  return root\n}\n\n// custom functions to get inner/outer HTML without escaping various things to prevent teddy from infinitely escaping them\nconst doublyEncodedEntities = {\n  '&amp;amp;': '&amp;',\n  '&amp;lt;': '&lt;',\n  '&amp;gt;': '&gt;',\n  '&amp;quot;': '&quot;',\n  '&amp;#39;': '&#39;',\n  '&amp;#x2F;': '&#x2F;'\n}\n// built once rather than on every node of every serialization\nconst entityFixes = Object.entries(doublyEncodedEntities).map(([doublyEncoded, singleEncoded]) => [new RegExp(doublyEncoded, 'g'), singleEncoded])\n\n// teddy renames src and href while the markup is a live dom, so that the browser does not try to fetch a url that is still a {variable}. a string is not a dom and cannot fetch anything, so the real attribute name goes back on as the markup leaves the dom. doing it here rather than at the end of a render is what saves every render a sweep of its whole output looking for these\nconst deferredAttributes = /data-teddy-defer-attr-(src|href)/g\n\n// undoes what parsing the markup into a dom did to it: the double encoding a browser's serializer applies, and the attribute names teddy renamed on the way in\nfunction undoParserArtifacts (html) {\n  for (const [pattern, singleEncoded] of entityFixes) html = html.replace(pattern, singleEncoded)\n  return html.replace(deferredAttributes, '$1')\n}\n// every element under a root that matches a selector, including the ones inside a template\n//\n// a query never reaches into a template's content fragment, so a teddy tag written inside a template went unclaimed in a browser while node claimed it. asking for the templates in the same query keeps everything in the order it was written in\nfunction queryAll (root, selector) {\n  const found = []\n  for (const el of root.querySelectorAll(`${selector}, template`)) {\n    if (el.matches(selector)) found.push(el)\n    if (isTemplate(el)) found.push(...queryAll(el.content, selector))\n  }\n  return found\n}\n\n// where the children of a node belong\n//\n// a template element keeps its children in a document fragment of its own rather than among its child nodes, and serializing a template writes that fragment out. so a child appended to the element itself is kept somewhere the markup never shows it, which is how everything inside a <template> used to disappear from a browser render\nfunction childrenOf (node) {\n  return isTemplate(node) ? node.content : node\n}\n\n// a template element, and not merely something with a content property: <meta content=\"...\"> has one of those and it is a string\nfunction isTemplate (node) {\n  return node.nodeName === 'TEMPLATE' && node.content\n}\n\nfunction getTeddyDOMInnerHTML (node) {\n  // build html string\n  let html = ''\n  for (const child of childrenOf(node).childNodes) {\n    if (child.nodeType === window.Node.ELEMENT_NODE) {\n      html += undoParserArtifacts(child.outerHTML)\n    } else if (child.nodeType === window.Node.TEXT_NODE) {\n      html += undoParserArtifacts(child.textContent)\n    } else if (child.nodeType === window.Node.COMMENT_NODE) {\n      html += `<!--${undoParserArtifacts(child.textContent)}-->`\n    }\n  }\n\n  return html\n}\nfunction getTeddyDOMOuterHTML (node) {\n  // start with the outerHTML of the node\n  let outerHTML = ''\n\n  if (node.nodeType === window.Node.ELEMENT_NODE) {\n    outerHTML = node.outerHTML\n  } else if (node.nodeType === window.Node.TEXT_NODE) {\n    outerHTML = node.textContent\n  } else if (node.nodeType === window.Node.COMMENT_NODE) {\n    outerHTML = `<!--${node.textContent}-->`\n  }\n\n  return undoParserArtifacts(outerHTML)\n}\n","// teddy's compiler\n//\n// the structure of a template does not change between renders, only the values do. this module walks a template once and emits a tree of nodes that a render walks\n//\n// three rules:\n//\n// 1. static markup is taken from cheerio's own serializer, never reconstructed. the compiler replaces each teddy construct in the parsed dom with a placeholder text node and then serializes the whole document, so the literal chunks between placeholders are the same as what the interpreter would have produced\n//\n// 2. anything the compiler does not recognize abandons the compile entirely and the template is delegated to the interpreter; partial coverage is therefore safe: a template can only ever come out faster or unchanged, never wrong\n//\n// 3. value level semantics are not reimplemented here: formatVariable and evaluateConditional are teddy's own, called from here, so nothing about what a {variable} or an <if> means lives in two places\n\nfunction internalError (detail) {\n  return new Error(`teddy: internal compiler error: ${detail}. this is a bug in teddy, not in your template.`)\n}\n\nfunction warn (params, message) {\n  if (params.verbosity > 0) console.warn(`teddy: ${message}`)\n}\n\n// marks where a construct's output goes. it contains no character a parser treats as special, so it survives being parsed and serialized again. the browser build swaps cheerio for a small polyfill over the native dom, so the compiler uses only the parts both of them provide\n//\n// a control character does not belong in markup, but a template is free to contain one, so the one used is picked per template from those the template does not already contain\nconst TOKEN_CANDIDATES = ['\\u0001', '\\u0002', '\\u0003', '\\u0004', '\\u0005', '\\u0006', '\\u0007', '\\u000e', '\\u000f']\n\nconst SELECTION_ATTRS = [['selected-value', 'option[value]', 'selected'], ['checked-value', 'input[type=\"checkbox\"][value], input[type=\"radio\"][value]', 'checked']]\n\n// tags whose presence around a construct means an enclosing construct owns it, so it is compiled as part of that one's body rather than on its own\nconst STRUCTURAL = new Set(['if', 'unless', 'elseif', 'elseunless', 'else', 'loop', 'include', 'arg', 'noteddy', 'noparse', 'pre', 'cache'])\nconst ARM_TAGS = new Set(['elseif', 'elseunless', 'else'])\n\n// teddy tags that can be left over once every construct has been claimed, because they only mean anything next to something else\nconst ORPHANABLE = ['arg', 'else', 'elseif', 'elseunless']\nconst OPENERS = new Set(['if', 'unless'])\nconst JOINERS = new Set(['and', 'or', 'xor'])\nconst OUTCOMES = new Set(['true', 'false'])\n\n// every construct that owns the markup inside it, found in one pass so the outermost of them can be picked out. a one line if is in here through its outcome attributes, which is also how the interpreter finds them\n//\n// a <noteddy> or <pre> carrying an id is teddy's own marker for content it has already lifted out, not something in the template, so it is left alone here exactly as the old renderer left it alone\nconst CONSTRUCTS = 'if, unless, loop, include, inline, cache, noteddy:not([id]), noparse:not([id]), pre:not([id]), [true], [false]'\n\n// a sequence of one line ifs on one element needs the element's opening tag worked out for whichever combination of outcomes a render arrives at. there are two to the power of however many conditions there are, so each is built as a render first calls for it and then kept, rather than all of them up front\n\n// teddy's rule for what counts as a variable name\nconst VALID_VARIABLE = /^(\\d+|[a-zA-Z_$][a-zA-Z0-9_$|{}.-]*(\\.[a-zA-Z_$][a-zA-Z0-9_$|{}.-]*)*)$/\n\n// what a value has to contain before anything further needs doing with it. deliberately specific: a value carrying ordinary markup such as <strong> is finished as it stands, and treating it otherwise would cost every template that injects safe html\nconst LOOKS_LIKE_TEDDY = /\\{|<\\/?(?:if|unless|elseif|elseunless|else|loop|include|arg|cache|inline|noteddy|noparse)\\b|\\s(?:true|false|selected-value|checked-value)=|\\sif-/i\n\n// whether a value carries teddy tags, as opposed to only carrying {variables}. a value of only variables and text cannot affect the shape of the document, so nothing about it has to be checked before compiling it\nconst HAS_TEDDY_TAGS = /<\\/?(?:if|unless|elseif|elseunless|else|loop|include|arg|cache|inline|noteddy|noparse)\\b|\\s(?:true|false|selected-value|checked-value)=|\\sif-/i\n\n// teddy's marker for a block it has lifted out of the markup. one of these turns up inside a value whenever a rendered fragment is passed on through another variable, which is what a layout taking its page as an argument does, and it is not something to look at a second time\nconst NOTEDDY_PLACEHOLDER = /<noteddy id=\"\\d+\"(?: pre=\"true\")?><\\/noteddy>/g\n\n// elements that never carry a closing tag, so an unclosed one of these does not mean the markup is unfinished\nconst VOID_ELEMENTS = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'])\n\n// elements whose contents are not markup as far as teddy is concerned: a browser reads the contents of a script, style, or textarea as plain text, and noteddy, noparse, and a pre without a parse attribute are teddy's own ways of asking for the same\nconst UNPARSED_CONTENT = new Set(['script', 'style', 'textarea', 'noteddy', 'noparse', 'pre'])\n\n// the tags in some markup, as matches of [whole, closing slash, name, rest of the tag], skipping over anything inside an element whose contents are not markup\n//\n// counting the tags inside those as though they were real is what made a script holding a string like \"<include src=x>\" look like markup that opens a tag it never closes\nfunction * tagsOutsideUnparsedContent (source) {\n  const tag = /<(\\/?)([a-zA-Z][a-zA-Z0-9-]*)([^>]*)>/g\n  let match\n  while ((match = tag.exec(source))) {\n    yield match\n    const name = match[2].toLowerCase()\n    if (match[1] || !UNPARSED_CONTENT.has(name) || match[3].trimEnd().endsWith('/')) continue\n    if (name === 'pre' && /(^|\\s)parse(\\s|=|$)/i.test(match[3])) continue // a <pre parse> asks for its contents to be parsed\n    const close = new RegExp(`</${name}\\\\s*>`, 'ig')\n    close.lastIndex = tag.lastIndex\n    const found = close.exec(source)\n    if (!found) return // the element runs to the end, so nothing after its opening tag is markup\n    tag.lastIndex = found.index // resume at the closing tag, so that it is matched next\n  }\n}\n\n// stands in for what a variable writes when working that out needs a model, which is the uncommon case\nconst NEEDS_MODEL = Symbol('teddy: value needs a model')\n\n// how many opening tags of a one line if are worth writing out in full. two conditions on one element is four tags, which is already more than almost any element carries\nconst MAX_EMITTED_VARIANTS = 4\n\n// what makes a plain value worth a second look: a character that has to be escaped, or the opening of a {variable} the value carries of its own\nconst QUICK_VALUE_STOP = /[&<>\"'{]/\n\n// values that came in through the model and have been compiled, kept against the value itself so a page rendering the same snippet over and over compiles it once\nconst MAX_VALUE_TEMPLATES = 10000\n\n// a value may refer to another value, which may refer to another, and so on. a value that comes round again is a loop the model cannot resolve, and it is reported rather than chased\nconst MAX_VALUE_DEPTH = 1000\n\nexport function createCompiler (deps) {\n  const {\n    cheerioLoad,\n    cheerioOptions,\n    browser,\n    params,\n    variableFlags,\n    formatVariable,\n    escapeEntities,\n    conditionPath,\n    evaluateConditional,\n    loadTemplate,\n    caches,\n    parseVars,\n    getAttribs,\n    getOrSetObjectByDotNotation\n  } = deps\n\n  // #region compiling\n\n  let token = TOKEN_CANDIDATES[0]\n  const tokenFor = index => token + index + token\n\n  // returns a node tree, or null if the template contains anything this compiler does not handle yet, which means the caller should interpret it instead\n  function compileTemplate (source, stack = []) {\n    token = TOKEN_CANDIDATES.find(candidate => !source.includes(candidate)) ?? TOKEN_CANDIDATES[0]\n    // one slot list for the whole template, so a placeholder found inside a construct's body means the same thing there as it did in the document it came out of\n    const slots = []\n    const nodes = compileMarkup(source, slots, stack)\n    // bodies are compiled after their document has been serialized, and compiling one can add slots of its own, so this walks the list as it grows rather than a snapshot of it\n    for (let i = 0; i < slots.length; i++) compileSlotBody(slots[i], slots)\n    return nodes\n  }\n\n  function compileSlotBody (slot, slots) {\n    if (slot.type === 'arm') {\n      const arm = slot.branch.arms[slot.index]\n      if (arm.body === null) arm.body = compileMarkup(arm.bodySource, slots, slot.stack)\n      return\n    }\n    if (slot.bodySource !== null && slot.body === null) slot.body = compileMarkup(slot.bodySource, slots, slot.stack)\n    // an argument's body is a template in its own right, rendered against the model the include is reached with\n    if (slot.bindings) {\n      for (const binding of slot.bindings) {\n        if (binding.body === null) binding.body = compileMarkup(binding.bodySource, slots, slot.stack)\n      }\n    }\n    // a component's light dom is written at the call site, so it is rendered against the model the include was reached with rather than against the partial's\n    if (slot.lightSource !== null && slot.lightNodes === null) slot.lightNodes = compileMarkup(slot.lightSource, slots, slot.stack)\n    // the fallback a component carries is its own template again, so it is rendered against the same model the shadow root was\n    if (slot.fallbackSource !== null && slot.fallbackNodes === null) slot.fallbackNodes = compileMarkup(slot.fallbackSource, slots, slot.stack)\n  }\n  // every node is made here, and every one of them carries the same fields in the same order whether it uses them or not\n  //\n  // v8 gives an object its shape from the fields it is written with, and reading one field across a dozen different shapes is a lookup it cannot cache. renderNodes reads node.type off every node in a template, so a dozen shapes made that read, and the reads after it, as slow as a lookup gets. one shape makes them all the fastest kind. the nodes are built once when a template is compiled rather than once per render, so the fields a node does not use cost nothing worth counting\n  function makeNode (type) {\n    return {\n      type,\n      value: null,\n      source: null,\n      stack: null,\n      body: null,\n      bodySource: null,\n      branch: null,\n      index: 0,\n      through: null,\n      keyName: null,\n      valName: null,\n      conditionals: null,\n      outcomesNeedModel: false,\n      variantNeedsModel: false,\n      openTag: null,\n      closeTag: null,\n      tagName: null,\n      variants: null,\n      src: null,\n      bindings: null,\n      compiled: null,\n      valueSource: null,\n      ownValue: null,\n      name: null,\n      key: null,\n      maxAge: 0,\n      maxCaches: 0,\n      css: null,\n      js: null,\n      element: null,\n      hydrate: null,\n      openNodes: null,\n      mode: null,\n      lightSource: null,\n      lightNodes: null,\n      fallbackSource: null,\n      fallbackNodes: null,\n      flags: null,\n      raw: false,\n      dollar: false,\n      path: null,\n      nameNodes: null\n    }\n  }\n\n  function compileMarkup (source, slots, stack) {\n    reportStrayClosingTags(source)\n    const dom = cheerioLoad(source || '', cheerioOptions)\n\n    applySelectionAttributes(dom, slots)\n\n    // every construct is found in one pass and narrowed to the outermost of them, so none of the elements about to be replaced contains another. that is what lets each body be captured intact: going type by type would mean replacing a loop that sits inside an element whose body has not been read yet\n    const outermost = Array.from(dom(CONSTRUCTS)).filter(el => !hasConstructAncestor(el))\n    const claimed = new Set()\n\n    for (const el of outermost) {\n      if (claimed.has(el)) continue\n      const name = tagNameOf(el)\n      if (OPENERS.has(name)) claimConditional(dom, el, slots, claimed, stack)\n      else if (name === 'loop') claimLoop(dom, el, slots, stack)\n      else if (name === 'include') claimInclude(dom, el, slots, stack)\n      else if (name === 'inline') claimInline(dom, el, slots)\n      else if (name === 'cache') claimCache(dom, el, slots, stack)\n      else if (name === 'noteddy' || name === 'noparse') claimNoParse(dom, el, slots, false)\n      else if (name === 'pre') claimPre(dom, el, slots)\n      else claimOneLineIf(dom, el, slots, stack)\n    }\n\n    // anything teddy still recognizes at this point belongs to nothing, and goes\n    sweepOrphanedTags(dom)\n\n    return buildNodes(dom.html(), slots)\n  }\n\n  // what a set of conditions asks, worked out while the template is compiled: for each one the name it looks up, whether it is negated, and what it compares against\n  //\n  // this covers one condition on its own and two joined by a single operator, which between them is nearly every conditional anyone writes. anything else, and anything with a quirk in it that the general path handles specially, comes back null and is left to that path\n  //\n  // knowing this at compile time is what lets a render answer a conditional without building an argument list, reducing it in place, and reading the same strings apart again every time\n  function conditionChecks (pairs) {\n    const checks = []\n    for (const [rawName, rawValue] of pairs) {\n      if (rawName === 'and' || rawName === 'or' || rawName === 'xor') {\n        checks.push(rawName)\n        continue\n      }\n      let name = rawName\n      const not = name.startsWith('not:')\n      if (not) name = name.slice(4)\n      // a colon anywhere but the not: prefix, or an equals sign in the name, is something the general path rejects outright and warns about\n      if (!name || name.includes(':') || name.includes('=')) return null\n      if (!rawValue) {\n        checks.push({ path: name, not, compare: null })\n        continue\n      }\n      // a value carrying a colon or an equals sign is also rejected by the general path, in its own particular way, and a value holding a {variable} is only resolved on the opening arm of a chain. all three are left where their behavior is already written down\n      if (rawValue.includes(':') || rawValue.includes('=') || rawValue.includes('{')) return null\n      checks.push({ path: name, not, compare: rawValue })\n    }\n    const shapeIsOne = checks.length === 1 && typeof checks[0] === 'object'\n    const shapeIsPair = checks.length === 3 && typeof checks[0] === 'object' && typeof checks[1] === 'string' && typeof checks[2] === 'object'\n    return shapeIsOne || shapeIsPair ? checks : null\n  }\n\n  // whether a value counts as being there. an empty object or an empty array does not\n  function valuePresent (value) {\n    return value ? !(typeof value === 'object' && Object.keys(value).length === 0) : false\n  }\n\n  // whether one condition holds, given the value it looks up already looked up\n  function settleCheck (check, value) {\n    let result\n    if (check.compare === null) result = valuePresent(value)\n    else result = value == check.compare // eslint-disable-line eqeqeq -- teddy compares conditions loosely on purpose, so \"1\" and 1 are the same answer\n    return check.not ? !result : result\n  }\n\n  // whether conditions of a shape settled at compile time hold\n  //\n  // the general path's reduction is not repeated here, it is not needed: one condition reduces to itself, and two joined by an operator reduce to that operator applied to both. everything else still goes through the general path, which is the only place those rules are written\n  function settleChecks (checks, model, values) {\n    const first = settleCheck(checks[0], values ? values[0] : getOrSetObjectByDotNotation(model, checks[0].path))\n    if (checks.length === 1) return first\n    const second = settleCheck(checks[2], values ? values[2] : getOrSetObjectByDotNotation(model, checks[2].path))\n    if (checks[1] === 'and') return first && second\n    if (checks[1] === 'or') return first || second\n    return first !== second // xor\n  }\n\n  // every arm of a conditional chain gets its own slot. the interpreter leaves the whitespace between arms in place and writes the winning arm's content where that arm sat, so one slot for a whole chain would move content and change the output\n  function claimConditional (dom, el, slots, claimed, stack) {\n    const branch = { arms: [] }\n    for (const arm of collectChain(el)) {\n      claimed.add(arm)\n      const attribs = readAttribs(arm)\n      branch.arms.push({\n        kind: tagNameOf(arm),\n        attribs,\n        checks: conditionChecks(attribs),\n        // compiled once the document has been serialized: recursing now would descend into a dom that is still being rewritten\n        bodySource: dom(arm).html(),\n        body: null\n      })\n      const armNode = makeNode('arm')\n      armNode.branch = branch\n      armNode.index = branch.arms.length - 1\n      armNode.stack = stack\n      slots.push(armNode)\n      dom(arm).replaceWith(tokenFor(slots.length - 1))\n    }\n  }\n\n  function claimLoop (dom, el, slots, stack) {\n    const attribs = readAttribs(el)\n    const node = makeNode('loop')\n    node.stack = stack\n    node.through = attribValue(attribs, 'through')\n    node.keyName = attribValue(attribs, 'key')\n    node.valName = attribValue(attribs, 'val')\n    node.bodySource = dom(el).html()\n    slots.push(node)\n    dom(el).replaceWith(tokenFor(slots.length - 1))\n  }\n\n  // an element carrying one line ifs has an opening tag that depends on the model, so it cannot be part of the static markup. rather than reproducing how the dom parser writes an attribute list out, the opening tag is worked out here for every combination of outcomes, by that same parser, applying the same attribute changes the interpreter applies. the render then picks one of them\n  function claimOneLineIf (dom, el, slots, stack) {\n    const pairs = readAttribs(el)\n\n    // an element can carry a sequence of one line conditionals rather than only one: a condition, any further conditions joined to it, then the outcomes for that condition, and then possibly another condition beginning the next one in the sequence\n    const conditionals = []\n    let current = null\n    for (const [name, value] of pairs) {\n      if (name.startsWith('if-')) {\n        if (!current || current.ifTrue !== undefined || current.ifFalse !== undefined) {\n          current = { argSources: [], args: null, dynamic: false, ifTrue: undefined, ifFalse: undefined }\n          conditionals.push(current)\n        }\n        // split the way the interpreter splits it rather than by length, so an attribute name containing if- more than once is read identically\n        const condition = name.split('if-')[1]\n        current.argSources.push([condition, value])\n        // a condition whose value names a variable is not known until there is a model to read it from, exactly as for an <if> tag. the variable may sit anywhere in the value rather than at its head, so any brace means the value has to be resolved\n        if (value && value.includes('{')) current.dynamic = true\n      } else if (OUTCOMES.has(name)) {\n        if (current) current[name === 'true' ? 'ifTrue' : 'ifFalse'] = value.replaceAll('&quot;', '\"')\n      } else if (JOINERS.has(name)) {\n        if (current) current.argSources.push([name, null])\n      }\n    }\n    if (!conditionals.length) {\n      warn(params, `a <${tagNameOf(el)}> carries a \"${pairs.find(([name]) => OUTCOMES.has(name))?.[0]}\" attribute with no if- condition for it to be the outcome of, so it has been removed.`)\n      for (const [name] of pairs) if (OUTCOMES.has(name) || JOINERS.has(name)) dom(el).removeAttr(name)\n      return\n    }\n\n    // a condition holding nothing model dependent is reduced to its finished form once, here, rather than being rebuilt on every render\n    for (const conditional of conditionals) {\n      if (!conditional.dynamic) conditional.args = oneLineArgs(conditional.argSources, null)\n      conditional.checks = conditional.dynamic ? null : conditionChecks(conditional.argSources)\n    }\n\n    const { openTag, closeTag } = splitTag(dom, el)\n    // whether either half of a one line if has anything to ask a model about, settled here so that emitted code inside a <loop> knows not to build one. working out which outcomes apply needs a model only for a condition this could not settle, and writing the opening tag needs one only if the tag or an outcome holds a {variable}\n    const outcomesNeedModel = conditionals.some(conditional => !conditional.checks)\n    const variantNeedsModel = openTag.includes('{') || conditionals.some(conditional => (conditional.ifTrue || '').includes('{') || (conditional.ifFalse || '').includes('{'))\n    const node = makeNode('attrs')\n    node.conditionals = conditionals\n    node.outcomesNeedModel = outcomesNeedModel\n    node.variantNeedsModel = variantNeedsModel\n    node.openTag = openTag\n    node.closeTag = closeTag\n    node.tagName = tagNameOf(el)\n    node.variants = []\n    node.bodySource = dom(el).html()\n    node.stack = stack\n    slots.push(node)\n    dom(el).replaceWith(tokenFor(slots.length - 1))\n  }\n\n  // an <include> is resolved while compiling: the partial is loaded, compiled, and becomes part of the parent's tree, so nothing about finding or parsing it is left to happen per render\n  //\n  // an <arg> is compiled as a template of its own and rendered against the model the include is reached with, rather than being handed to the partial as unrendered markup for a later pass to finish. that is what keeps an argument carrying markup or a {variable} on the fast path, and it resolves such an argument against the caller's model rather than against the partial's, which differs only where one argument's body names another argument\n  //\n  // what the html spec allows a custom element to be called, near enough: lower case, starting with a letter, and holding at least one hyphen. the hyphen is what keeps it from colliding with a tag the browser may define later, and is why a name without one is not a custom element at all\n  const CUSTOM_ELEMENT_NAME = /^[a-z][a-z0-9.]*-[a-z0-9._-]*$/\n\n  // what an include reads for itself, so that everything else written on one can be passed along to the element it renders as\n  const COMPONENT_ATTRIBUTES = new Set(['src', 'as', 'hydrate', 'mode'])\n\n  // where a component's markup is written\n  //\n  // `both` writes it into a declarative shadow root and keeps a copy of it beside that as fallback content, so that a browser which builds shadow roots renders the first and one which does not renders the second. `shadow` writes the shadow root alone, which is smaller but renders nothing at all where declarative shadow dom is unsupported, including in anything that parses html without being a browser. `light` writes the fallback alone, into the element's light dom\n  const COMPONENT_MODES = new Set(['both', 'shadow', 'light'])\n\n  // the slot the fallback of a `both` component names, which no component defines\n  //\n  // a browser that builds the shadow root leaves a child naming a slot that is not there unassigned, and an unassigned child is not rendered, so the fallback sits there inert. one that does not build it has no slots to assign anything to, ignores the attribute, and renders the fallback\n  const FALLBACK_SLOT = 'teddy-fallback'\n\n  // markup inside one of these is content rather than something to render, so an element written there is left as it was\n  const UNPARSED = new Set(['pre', 'noteddy', 'noparse'])\n\n  function hasUnparsedAncestor (el) {\n    let parent = el.parent || el.parentNode\n    while (parent) {\n      if (parent.teddyTemplateHost) {\n        parent = parent.teddyTemplateHost\n        continue\n      }\n      const name = tagNameOf(parent)\n      if (!name) return false\n      // a <pre parse> is asking for its contents to be parsed, so it does not own them\n      if (UNPARSED.has(name) && !(name === 'pre' && carriesParse(parent))) return true\n      parent = parent.parent || parent.parentNode\n    }\n    return false\n  }\n\n  // what a component's markup looks like in the light dom, where a <style> would leak to the rest of the page, a <slot> has no shadow root to project anything into, and a <script> has already run once as part of the page\n  //\n  // a component holding a default <slot> would project the fallback straight back into itself beside the real content, so that one is held out of the slots by name. a component whose slots are all named, or which has none, needs nothing: its fallback is unassigned already\n  function fallbackMarkup (markup) {\n    const dom = cheerioLoad(markup || '', cheerioOptions)\n    const slots = Array.from(dom('slot')).filter(el => !hasUnparsedAncestor(el))\n    const held = slots.some(el => !attribValue(readAttribs(el), 'name'))\n    for (const el of Array.from(dom('style, script, slot')).filter(el => !hasUnparsedAncestor(el))) dom(el).remove()\n    const stripped = dom.html()\n    return held ? `<div slot=\"${FALLBACK_SLOT}\">${stripped}</div>` : stripped\n  }\n\n  function claimInclude (dom, el, slots, stack) {\n    const src = attribValue(readAttribs(el), 'src')\n\n    // the interpreter drops an include with no src rather than leaving anything behind\n    if (!src) {\n      if (params.verbosity > 1) console.warn('teddy encountered an include tag with no src attribute.')\n      dom(el).replaceWith('')\n      return\n    }\n\n    // a src that names a variable is not known until there is a model to read it from, so the partial behind it is loaded and compiled on the first render that asks for it and kept against that name\n    if (src.includes('{')) {\n      const node = makeNode('dynamicInclude')\n      node.src = src\n      node.bindings = readArgs(dom, el)\n      node.compiled = new Map()\n      node.stack = stack\n      slots.push(node)\n      dom(el).replaceWith(tokenFor(slots.length - 1))\n      return\n    }\n\n    // a template that includes itself would otherwise be compiled forever\n    if (stack.includes(src)) {\n      throw new Error(`teddy: the template \"${src}\" includes itself, directly or through the templates it includes, so it can never finish compiling. include stack: ${stack.concat(src).map(name => JSON.stringify(name)).join(' -> ')}`)\n    }\n\n    const included = loadTemplate(src)\n    let markup = included\n    if (included === null) {\n      if (params.verbosity > 1) console.warn(`teddy encountered an include tag with a src set to a template that could not be found: ${src}`)\n      markup = params.includeNotFoundBehavior === 'display' ? `Template \"${src}\" not found!` : ''\n    }\n\n    const node = makeNode('scope')\n    node.bindings = readArgs(dom, el)\n    node.bodySource = markup\n    node.stack = stack.concat(src)\n    // an include asked to render as a custom element writes its markup into a declarative shadow root inside that element, rather than in place of it. a browser's parser builds the shadow root as it reads the page, so the markup is there, encapsulated, before any javascript runs; and when the element is upgraded its shadow root is already populated, so nothing has to be rendered again\n    //\n    // both halves of the wrapper are settled here, so that walking the tree and running emitted code cannot disagree about what a component looks like\n    const attribs = readAttribs(el)\n    const element = attribValue(attribs, 'as')\n    if (element) {\n      if (!CUSTOM_ELEMENT_NAME.test(element)) throw new Error(`teddy: \"${element}\" cannot name a custom element, so <include src=\"${src}\" as=\"${element}\"> has nothing it could render as. the name has to be lower case and hold a hyphen, like \"my-card\"`)\n      node.element = element\n\n      // every other attribute written on the include belongs to the element it renders as, which is how a custom element is configured: a class watches the attributes it named in observedAttributes, and teddy has nothing to say about which those are\n      //\n      // the opening tag is compiled rather than written out as it stands, so that an attribute whose value holds a {variable} resolves the way it would anywhere else\n      const passed = attribs.filter(([name]) => !COMPONENT_ATTRIBUTES.has(name))\n\n      // where the markup goes. a component is written into a declarative shadow root with a fallback copy beside it unless it asks for something else, that being the only arrangement which renders whatever the browser turns out to support\n      const mode = attribs.some(([name]) => name === 'mode') ? attribValue(attribs, 'mode') : 'both'\n      if (!COMPONENT_MODES.has(mode)) throw new Error(`teddy: <include src=\"${src}\" as=\"${element}\" mode=\"${mode}\"> asks for a mode that is not one of ${[...COMPONENT_MODES].join(', ')}`)\n      node.mode = mode\n\n      // a component rendering into the light dom alone has no shadow root to hold its styles or fill its slots, so what it writes is the fallback markup rather than the template as it stands\n      if (mode === 'light') node.bodySource = fallbackMarkup(markup)\n      else if (mode === 'both') node.fallbackSource = fallbackMarkup(markup)\n\n      node.openNodes = []\n      pushText(node.openNodes, `<${element}${passed.map(([name, value]) => value === '' ? ` ${name}` : ` ${name}=\"${value}\"`).join('')}>${mode === 'light' ? '' : '<template shadowrootmode=\"open\">'}`)\n\n      // whatever the include was given that is not an <arg> is the component's light dom, which is what a <slot> in its shadow root projects. an <arg> names a value the template reads; this is content, and it belongs to the page rather than to the shadow root\n      node.lightSource = Array.from(dom(el).contents()).filter(child => tagNameOf(child) !== 'arg').map(child => dom(child).toString()).join('')\n      // a component told to hydrate is sent the part of the model it renders from, so that the class upgrading it can render the same template again from new data without asking a server for anything. it names what it needs rather than being guessed at, because an argument carries rendered markup and so can only ever be a string: a component reading a list or an object reads it from the model, and only the model can carry it back out again\n      const hydrate = attribValue(attribs, 'hydrate')\n      // a bare hydrate would otherwise do nothing at all, which is not what anyone writing it meant\n      if (!hydrate && attribs.some(([name]) => name === 'hydrate')) throw new Error(`teddy: <include src=\"${src}\" as=\"${element}\" hydrate> does not say what the component needs, so there is nothing to send it. name the model keys it renders from, like hydrate=\"product\"`)\n      if (hydrate) {\n        node.hydrate = hydrate.split(',').map(name => name.trim()).filter(Boolean)\n        for (const name of node.hydrate) {\n          if (name.includes('.')) throw new Error(`teddy: <include src=\"${src}\" as=\"${element}\" hydrate=\"${hydrate}\"> names \"${name}\", and a component is sent whole model keys rather than paths into them. name the key that holds it instead`)\n        }\n      }\n    }\n    slots.push(node)\n    dom(el).replaceWith(tokenFor(slots.length - 1))\n  }\n\n  // selected-value and checked-value mark whichever of an element's descendants carries a matching value\n  //\n  // when the value is written in the template the marking is settled here and nothing is left to a render. when it comes from the model, each candidate descendant gets its opening tag both ways and the render picks, which is the same approach one line ifs use\n  //\n  // a candidate written inside a <loop> or an <if> is still written in the template, so it is found and prepared here too; it simply ends up inside that construct's body and is decided once per iteration\n  //\n  // a candidate arriving through an <include> is the one case this cannot reach, because the partial has not been pulled in yet when this runs\n  function applySelectionAttributes (dom, slots) {\n    for (const [attr, childSelector, marker] of SELECTION_ATTRS) {\n      for (const el of Array.from(dom(`[${attr}]`))) {\n        if (browser) el.attribs = getAttribs(el)\n        if (!inlineIncludes(dom, el)) {\n          warn(params, `a ${attr} could not be applied because the elements it would mark come from an <include> that cannot be resolved before rendering: either its src is a variable, or it takes arguments. move the ${attr} inside the included template.`)\n          for (const name of Object.keys(el.attribs || {})) {\n            if ((name.includes('-teddyduplicate') ? name.split('-teddyduplicate')[0] : name) === attr) dom(el).removeAttr(name)\n          }\n          continue\n        }\n\n        for (const [name, valueSource] of readAttribs(el)) {\n          if (name !== attr || !valueSource) continue\n          const candidates = Array.from(dom(el).find(childSelector))\n          for (const child of candidates) {\n            if (browser) child.attribs = getAttribs(child)\n            const ownValue = child.attribs.value\n            // both sides have to be written out before the match can be settled here\n            if (!valueSource.includes('{') && !(ownValue && ownValue.includes('{'))) {\n              if (ownValue === valueSource) dom(child).attr(marker, marker)\n              continue\n            }\n            claimSelectionCandidate(dom, child, slots, valueSource, ownValue, marker)\n          }\n        }\n\n        // the attribute has done its job, and the interpreter takes it off too\n        for (const name of Object.keys(el.attribs || {})) {\n          if ((name.includes('-teddyduplicate') ? name.split('-teddyduplicate')[0] : name) === attr) dom(el).removeAttr(name)\n        }\n      }\n    }\n  }\n\n  // an <include> inside a selection container is pulled in here, before the candidates are looked for, because otherwise its <option> or <input> elements would not be there to find. only a plain include can be inlined this way: one taking arguments has a scope of its own, which inlining would lose\n  function inlineIncludes (dom, container) {\n    for (let round = 0; round < 10; round++) {\n      const includes = Array.from(dom(container).find('include'))\n      if (!includes.length) return true\n      for (const el of includes) {\n        const src = attribValue(readAttribs(el), 'src')\n        if (!src || src.includes('{')) return false\n        for (const child of Array.from(dom(el).children())) if (tagNameOf(child) === 'arg') return false\n        const markup = loadTemplate(src)\n        if (markup === null) return false\n        dom(el).replaceWith(markup)\n      }\n    }\n    return false // includes nested past any sensible depth\n  }\n\n  // one candidate for a selected-value or checked-value whose value is not known yet: its opening tag is prepared both marked and unmarked, and the render writes whichever the model calls for\n  function claimSelectionCandidate (dom, el, slots, valueSource, ownValue, marker) {\n    const tagName = tagNameOf(el)\n    const { openTag, closeTag } = splitTag(dom, el)\n\n    const plain = []\n    pushText(plain, openTag)\n\n    const probe = cheerioLoad(openTag + closeTag, cheerioOptions)\n    const target = probe(tagName)[0]\n    if (!target) throw internalError(`a <${tagName}> could not be read back after being parsed on its own`)\n    probe(target).attr(marker, marker)\n    const rebuilt = probe(target).toString()\n    const marked = []\n    pushText(marked, closeTag && rebuilt.endsWith(closeTag) ? rebuilt.slice(0, rebuilt.length - closeTag.length) : rebuilt)\n\n    const node = makeNode('selection')\n    node.valueSource = valueSource\n    node.ownValue = ownValue\n    node.variants = [plain, marked]\n    node.closeTag = closeTag\n    node.bodySource = dom(el).html()\n    node.stack = []\n    slots.push(node)\n    dom(el).replaceWith(tokenFor(slots.length - 1))\n  }\n\n  // <noteddy> and <noparse> keep their contents out of teddy's hands. the interpreter lifts them out of the markup, renders everything else, and puts them back at the very end; here they simply become a piece of text nothing further is done to, which is the same thing said more directly\n  function claimNoParse (dom, el, slots, keepTags) {\n    const node = makeNode('raw')\n    node.value = keepTags ? dom(el).toString() : dom(el).html()\n    slots.push(node)\n    dom(el).replaceWith(tokenFor(slots.length - 1))\n  }\n\n  // a <pre> keeps its own tags as well as its contents, unless it carries a parse attribute, which asks for the opposite: its contents are compiled like anything else and the attribute itself comes off, which is what the stray tag sweep does for the interpreter\n  function claimPre (dom, el, slots) {\n    if (carriesParse(el)) {\n      dom(el).removeAttr('parse')\n      return\n    }\n    claimNoParse(dom, el, slots, true)\n  }\n\n  function carriesParse (el) {\n    if (browser) el.attribs = getAttribs(el)\n    return !!el.attribs && Object.prototype.hasOwnProperty.call(el.attribs, 'parse')\n  }\n\n  // a <cache> keeps the markup its body rendered to and writes that instead of rendering again. the interpreter does this in two halves, marking the element on the way in and storing what it produced once the output has gone stable; a compiled render knows when the body is finished, so it is one step here\n  function claimCache (dom, el, slots, stack) {\n    const attribs = readAttribs(el)\n    const node = makeNode('cache')\n    node.name = attribValue(attribs, 'name')\n    // an absent key means the whole body is cached under one entry, which teddy calls 'none'\n    node.key = attribValue(attribs, 'key')\n    node.maxAge = parseInt(attribValue(attribs, 'maxAge') || attribValue(attribs, 'maxage')) || 0\n    node.maxCaches = parseInt(attribValue(attribs, 'maxCaches') || attribValue(attribs, 'maxcaches')) || 1000\n    node.bodySource = dom(el).html()\n    node.stack = stack\n    slots.push(node)\n    dom(el).replaceWith(tokenFor(slots.length - 1))\n  }\n\n  function claimInline (dom, el, slots) {\n    const attribs = readAttribs(el)\n    const node = makeNode('inline')\n    node.css = attribValue(attribs, 'css')\n    node.js = attribValue(attribs, 'js')\n    slots.push(node)\n    dom(el).replaceWith(tokenFor(slots.length - 1))\n  }\n\n  function readArgs (dom, el) {\n    const bindings = []\n    for (const child of Array.from(dom(el).children())) {\n      if (tagNameOf(child) !== 'arg') continue\n      if (browser) child.attribs = getAttribs(child)\n      // the interpreter takes an argument's name from its first attribute, and skips one that has none\n      const name = Object.keys(child.attribs || {})[0]\n      if (!name) continue\n      bindings.push({ name, bodySource: dom(child).html(), body: null })\n    }\n    return bindings\n  }\n\n  // a template is parsed before the model contributes anything to it, so it has to be well formed on its own\n  //\n  // only a close with no open at all is reported: html leaves plenty of tags implicitly closed, and complaining about those would be noise\n  function reportStrayClosingTags (source) {\n    if (params.verbosity < 1 || !source || !source.includes('</')) return\n    const open = []\n    for (const match of tagsOutsideUnparsedContent(source)) {\n      const name = match[2].toLowerCase()\n      if (VOID_ELEMENTS.has(name) || match[3].trimEnd().endsWith('/')) continue\n      if (!match[1]) open.push(name)\n      else if (open.includes(name)) open.splice(open.lastIndexOf(name), 1)\n      else {\n        console.warn(`teddy: the template closes a <${name}> it never opened. templates are parsed on their own, so a closing tag cannot be paired up by markup arriving through the model, and this one will be dropped.`)\n        return\n      }\n    }\n  }\n\n  // an element's opening and closing tags, taken apart by length rather than by looking for a bracket, since an attribute value may contain one. a void element has no closing tag and all of its serialization is the opening tag\n  function splitTag (dom, el) {\n    const outer = dom(el).toString()\n    const inner = dom(el).html() || ''\n    const closeTag = `</${tagNameOf(el)}>`\n    if (!outer.endsWith(closeTag) || outer.length < closeTag.length + inner.length) return { openTag: outer, closeTag: '' }\n    return { openTag: outer.slice(0, outer.length - closeTag.length - inner.length), closeTag }\n  }\n\n  // the opening tag as it looks with one combination of outcomes applied: the parser is handed the tag on its own, the one line if attributes come off it, the outcomes go on, and the result is read back out. bit `i` of outcomes is set when condition `i` came out true\n  function openTagFor (openTag, closeTag, tagName, conditionals, outcomes) {\n    const probe = cheerioLoad(openTag + closeTag, cheerioOptions)\n    const target = probe(tagName)[0]\n    if (!target) throw internalError(`a <${tagName}> carrying a one line if could not be read back after being parsed on its own`)\n    if (browser) target.attribs = getAttribs(target)\n\n    // the interpreter takes every one line if attribute off before it applies any outcome, so an outcome lands after whatever attributes the element keeps\n    for (const name of Object.keys(target.attribs || {})) {\n      const clean = name.includes('-teddyduplicate') ? name.split('-teddyduplicate')[0] : name\n      if (clean.startsWith('if-') || OUTCOMES.has(clean) || JOINERS.has(clean)) probe(target).removeAttr(name)\n    }\n    for (let i = 0; i < conditionals.length; i++) {\n      const outcome = (outcomes >> i) & 1 ? conditionals[i].ifTrue : conditionals[i].ifFalse\n      if (!outcome) continue\n      const parts = outcome.split('=')\n      probe(target).attr(parts[0], parts[1] ? parts[1].replace(/[\"']/g, '') : '')\n    }\n\n    const rebuilt = probe(target).toString()\n    return closeTag && rebuilt.endsWith(closeTag) ? rebuilt.slice(0, rebuilt.length - closeTag.length) : rebuilt\n  }\n\n  // from an <if> or <unless>, the elseif, elseunless and else tags belonging to it. this mirrors the interpreter's sibling walk exactly, including that it steps over text nodes and stops at the next fresh if or unless\n  function collectChain (el) {\n    const chain = [el]\n    let sibling = el.nextSibling\n    while (sibling) {\n      const name = tagNameOf(sibling)\n      if (ARM_TAGS.has(name)) {\n        chain.push(sibling)\n        sibling = sibling.nextSibling\n      } else if (OPENERS.has(name)) break\n      else sibling = sibling.nextSibling\n    }\n    return chain\n  }\n\n  function tagNameOf (el) {\n    if (!el) return ''\n    return (browser ? el.nodeName?.toLowerCase() : el.name) || ''\n  }\n\n  // an element's attributes in source order, as pairs rather than an object. a condition may name the same variable or the same operator twice, and those arrive renamed so an html parser will not drop them; collapsing them into an object by their real names would silently throw one away and change what the condition means\n  function readAttribs (el) {\n    if (browser) el.attribs = getAttribs(el)\n    const pairs = []\n    for (const name in el.attribs) {\n      pairs.push([name.includes('-teddyduplicate') ? name.split('-teddyduplicate')[0] : name, el.attribs[name]])\n    }\n    return pairs\n  }\n\n  function attribValue (pairs, name) {\n    for (const [key, value] of pairs) if (key === name) return value\n    return undefined\n  }\n\n  function hasConstructAncestor (el) {\n    let parent = el.parent || el.parentNode\n    while (parent) {\n      // a template's children sit in a fragment of its own, so the walk carries on from the template that fragment belongs to: a construct enclosing the template still encloses what is inside it\n      if (parent.teddyTemplateHost) {\n        parent = parent.teddyTemplateHost\n        continue\n      }\n      const name = tagNameOf(parent)\n      if (!name || name === 'body' || name === 'html' || name === 'root' || name === '#document-fragment') return false\n      // a <pre parse> is asking for its contents to be parsed, so it does not own them\n      if ((STRUCTURAL.has(name) && !(name === 'pre' && carriesParse(parent))) || carriesOneLineIf(parent)) return true\n      parent = parent.parent || parent.parentNode\n    }\n    return false\n  }\n\n  function carriesOneLineIf (el) {\n    if (browser) el.attribs = getAttribs(el)\n    if (!el.attribs) return false\n    for (const name in el.attribs) {\n      if (OUTCOMES.has(name.includes('-teddyduplicate') ? name.split('-teddyduplicate')[0] : name)) return true\n    }\n    return false\n  }\n\n  // by the time this runs every construct has been claimed, so a teddy tag still standing here is one that belongs to nothing: e.g. an <arg> with no <include> around it, or an <else> with no <if> before it\n  function sweepOrphanedTags (dom) {\n    for (const name of ORPHANABLE) {\n      for (const el of Array.from(dom(name))) {\n        warn(params, `a <${name}> in the template has no ${name === 'arg' ? '<include> around it' : 'preceding <if> or <unless>'}, so it and its contents have been removed.`)\n        dom(el).remove()\n      }\n    }\n    for (const el of Array.from(dom('*'))) {\n      if (browser) el.attribs = getAttribs(el)\n      for (const name in el.attribs) {\n        const clean = name.includes('-teddyduplicate') ? name.split('-teddyduplicate')[0] : name\n        // a one line if is claimed before this runs, and one carrying no condition has had its attributes taken off, so nothing should be left here\n        if (OUTCOMES.has(clean)) throw internalError(`a \"${clean}\" attribute survived one line if compilation on a <${tagNameOf(el)}>`)\n      }\n    }\n  }\n\n  // splits the serialized markup on its placeholders, and splits the literal text between them into runs of markup and variable slots\n  function buildNodes (markup, slots) {\n    const nodes = []\n    let cursor = 0\n\n    while (cursor < markup.length) {\n      const open = markup.indexOf(token, cursor)\n      if (open === -1) {\n        pushText(nodes, markup.slice(cursor))\n        break\n      }\n      pushText(nodes, markup.slice(cursor, open))\n      const close = markup.indexOf(token, open + 1)\n      if (close === -1) throw internalError('a placeholder did not survive serialization intact')\n      const index = Number(markup.slice(open + 1, close))\n      if (!Number.isInteger(index) || !slots[index]) throw internalError(`a placeholder referred to a slot that does not exist: ${JSON.stringify(markup.slice(open + 1, close))}`)\n      nodes.push(slots[index])\n      cursor = close + 1\n    }\n\n    return nodes\n  }\n\n  function pushTextNode (nodes, value) {\n    const node = makeNode('text')\n    node.value = value\n    nodes.push(node)\n  }\n\n  function notFoundBody (src) {\n    const nodes = []\n    pushTextNode(nodes, params.includeNotFoundBehavior === 'display' ? `Template \"${src}\" not found!` : '')\n    return nodes\n  }\n\n  function pushText (nodes, text) {\n    if (!text) return\n    let cursor = 0\n    let literalFrom = 0\n\n    while (cursor < text.length) {\n      const open = text.indexOf('{', cursor)\n      if (open === -1) break\n\n      // the closing brace is found by counting nested braces, the way teddy's own delimiter matcher does, so that only an outermost balanced pair is ever treated as a variable. that is what keeps a css rule or a block of javascript from being read as one: the interpreter does not substitute a variable sitting inside a brace pair either\n      let depth = 0\n      let close = -1\n      for (let i = open; i < text.length; i++) {\n        if (text[i] === '{') depth++\n        else if (text[i] === '}' && --depth === 0) {\n          close = i\n          break\n        }\n      }\n      if (close === -1) break // the braces do not balance, so the rest of this run is text\n      const inner = text.slice(open + 1, close)\n\n      if (!inner || !VALID_VARIABLE.test(inner)) {\n        // not a variable, so the whole pair is ordinary text and the scan resumes after it\n        cursor = close + 1\n        continue\n      }\n\n      // a variable name may hold a variable of its own: {a{b}} resolves b, joins the result onto a, and looks up whatever that spells. the name is a little template, so it is compiled as one and rendered when there is a model to render it against\n      const computed = inner.includes('{')\n\n      // teddy substitutes a variable in both its {name} and its template literal ${name} form, so a dollar immediately before the brace is part of this variable's span and is consumed with it\n      const spanStart = open > literalFrom && text[open - 1] === '$' ? open - 1 : open\n      if (spanStart > literalFrom) pushTextNode(nodes, text.slice(literalFrom, spanStart))\n      if (computed) {\n        const nameNodes = []\n        pushText(nameNodes, inner)\n        const node = makeNode('computedVar')\n        node.nameNodes = nameNodes\n        node.source = text.slice(spanStart, close + 1)\n        nodes.push(node)\n      } else {\n        // a variable's flags are the same for every render, so they are settled here rather than read off the end of its name every time\n        const flags = variableFlags(inner)\n        const node = makeNode('var')\n        node.name = inner\n        node.flags = flags\n        node.source = text.slice(spanStart, close + 1)\n        node.dollar = spanStart !== open\n        // only a raw variable can put markup into the page that a further look would parse: an escaped one cannot, and a no parse one is never looked at again\n        node.raw = flags.raw\n        nodes.push(node)\n      }\n      cursor = close + 1\n      literalFrom = cursor\n    }\n\n    if (literalFrom < text.length) pushTextNode(nodes, text.slice(literalFrom))\n  }\n\n  // #endregion\n\n  // #region rendering\n\n  const valueTemplates = new Map()\n\n  // a value that arrived through the model may be a little template in its own right: it can hold {variables}, and a raw one can hold teddy tags. rather than handing the page back to the interpreter, the value is compiled and kept against itself, so a snippet that recurs is compiled once and rendered from then on\n  //\n  // returns null when the value has to go to the interpreter after all\n  function compileValue (text) {\n    let nodes = valueTemplates.get(text)\n    if (nodes !== undefined) return nodes\n    if (HAS_TEDDY_TAGS.test(text) && !isSelfContained(text)) nodes = null\n    else nodes = compileTemplate(text)\n    if (valueTemplates.size > MAX_VALUE_TEMPLATES) valueTemplates.clear()\n    valueTemplates.set(text, nodes)\n    return nodes\n  }\n\n  // whether a value's tags open and close within the value, so that it stands on its own\n  //\n  // a value that opens a construct the surrounding template closes, or closes one the template opened, only means anything joined to that template. teddy renders such a thing because it reparses its own output, and that is the one case a value cannot be compiled on its own\n  function isSelfContained (text) {\n    const open = []\n    for (const match of tagsOutsideUnparsedContent(text)) {\n      const [, closing, rawName, rest] = match\n      const name = rawName.toLowerCase()\n      if (VOID_ELEMENTS.has(name) || rest.trimEnd().endsWith('/')) continue\n      if (!closing) open.push(name)\n      else if (open[open.length - 1] === name) open.pop()\n      else return false // closes something this value never opened\n    }\n    return open.length === 0\n  }\n\n  // a value that turned out to be a template: compiled, then rendered against the model in hand\n  //\n  // the chain of values being resolved is kept so that a value which comes round again is recognized as a loop in the model rather than chased until something gives out\n  function renderValue (text, model, state) {\n    if (state.values.includes(text) || state.values.length >= MAX_VALUE_DEPTH) {\n      if (params.verbosity > 0) {\n        const chain = state.values.concat(text).map(value => JSON.stringify(value.length > 40 ? value.slice(0, 40) + '...' : value))\n        console.error(`teddy: a value in the model refers back to itself, so it can never finish resolving, and it has been written out as it stands. the values leading the chain were: ${chain.join(' -> ')}`)\n      }\n      return text\n    }\n    const nodes = compileValue(text)\n    // markup arriving through the model has to make sense on its own. one that opens a teddy tag it does not close, or closes one it did not open, only means something joined to the template it landed in, and a template is no longer reparsed once its values are in place\n    if (nodes === null) {\n      warn(params, `a variable was given markup that is not complete on its own, so it has been left out. markup coming from the model has to open and close its own tags: ${JSON.stringify(text.length > 120 ? text.slice(0, 120) + '...' : text)}`)\n      return ''\n    }\n    state.values.push(text)\n    const out = renderNodes(nodes, model, state)\n    state.values.pop()\n    return out\n  }\n\n  function renderNodes (nodes, model, state) {\n    let out = ''\n    // the arms of one chain are always consecutive in a node list, so the winner is worked out when the first arm is reached and reused by the rest without any bookkeeping\n    let openBranch = null\n    let winningArm = -1\n\n    for (const node of nodes) {\n      switch (node.type) {\n        case 'text':\n          out += node.value\n          break\n\n        case 'var': {\n          // the name is split once for the life of the template rather than on every render\n          if (node.path === null) node.path = node.flags.name.split('.')\n          const resolved = formatVariable(node.flags, getOrSetObjectByDotNotation(model, node.path), model)\n          // nothing to write, so the variable stays in the markup verbatim\n          if (!resolved) {\n            out += node.source\n            break\n          }\n          // a variable that did not resolve keeps its own text, and the dollar of a ${name} form survives with it because teddy skips that substitution in this case\n          if (node.dollar && resolved.skipTemplateLiteralReplacement) out += '$'\n          out += writeValue(resolved, node.raw, model, state)\n          break\n        }\n\n        case 'arm':\n          if (node.branch !== openBranch) {\n            openBranch = node.branch\n            winningArm = pickArm(node.branch, model)\n          }\n          if (node.index === winningArm) out += renderNodes(node.branch.arms[node.index].body, model, state)\n          break\n\n        case 'attrs':\n          out += renderNodes(attrsVariant(node, attrsOutcomes(node, model)), model, state)\n          out += renderNodes(node.body, model, state)\n          out += node.closeTag\n          break\n\n        case 'raw':\n          out += rawBlock(node, model)\n          break\n\n        case 'inline':\n          out += inlineBlock(node, model)\n          break\n\n        case 'computedVar':\n          out += computedVariable(renderNodes(node.nameNodes, model, state), model, state)\n          break\n\n        case 'selection':\n          out += renderNodes(node.variants[selectionMarked(node, model) ? 1 : 0], model, state)\n          out += renderNodes(node.body, model, state)\n          out += node.closeTag\n          break\n\n        case 'cache':\n          out += cacheBlock(node, model, () => renderNodes(node.body, model, state))\n          break\n\n        case 'dynamicInclude':\n          out += renderNodes(dynamicBody(node, model), node.bindings.length ? bindArgs(model, node.bindings, node.bindings.map(binding => renderNodes(binding.body, model, state))) : model, state)\n          break\n\n        case 'scope': {\n          const values = node.bindings.length ? node.bindings.map(binding => renderNodes(binding.body, model, state)) : null\n          const scoped = values ? bindArgs(model, node.bindings, values) : model\n          const inner = renderNodes(node.body, scoped, state)\n          if (node.element === null) {\n            out += inner\n            break\n          }\n          // a component is its opening tag, then the shadow root the template rendered into and the fallback copy of it if there is one, then whatever the page put inside it, and then the model it was sent if it asked for one\n          out += renderNodes(node.openNodes, model, state) + inner\n          if (node.mode !== 'light') out += '</template>'\n          if (node.fallbackNodes !== null) out += renderNodes(node.fallbackNodes, scoped, state)\n          out += renderNodes(node.lightNodes, model, state) + (node.hydrate ? componentPayload(node, model) : '') + `</${node.element}>`\n          break\n        }\n\n        case 'loop':\n          out += renderLoop(node, model, state)\n          break\n      }\n    }\n\n    return out\n  }\n\n  // what a resolved variable actually writes. a value that turned out to hold {variables} or teddy tags of its own is a template and is rendered as one; anything else is already finished\n  //\n  // a variable that did not resolve is left out of this: its text always holds a brace, and treating every missing variable as a template would cost the win for nothing\n  function writeValue (resolved, raw, model, state) {\n    const text = writePlainValue(resolved, raw)\n    return text === NEEDS_MODEL ? renderValue(resolved.text, model, state) : text\n  }\n\n  // what a {variable} carrying no flags writes, when that can be answered from the value alone, and undefined when the full path has to work it out\n  //\n  // undefined is the answer for \"ask properly\" because it is the cheapest thing a caller can test for, and no value this can say yes to is undefined\n  //\n  // a plain variable holding a plain string is the overwhelming majority of what a page writes, and for that there is nothing to decide: escape it and write it. answering it here saves working out flags that were settled at compile time, building the object that carries the answer, and asking a second time whether the answer is finished\n  //\n  // the one scan covers both jobs at once. a value with nothing in it that needs escaping and no {variable} of its own is finished, and a value that trips the scan is rare enough to be worth going back over\n  function quickValue (value) {\n    const type = typeof value\n    // a string is asked about first because a string is what almost every variable holds, and the two questions it has to answer are answered by the one scan: nothing to escape and no {variable} of its own means the value is already what it writes\n    //\n    // the empty string is not checked for: it trips nothing here and writes as itself, which is what the full path would decide too\n    if (type === 'string') {\n      if (!QUICK_VALUE_STOP.test(value)) return value\n      if (value.includes('{')) return undefined\n      return escapeEntities(value)\n    }\n    // a number writes itself and needs no scanning: there is nothing in one to escape and nothing in one that could be teddy code. zero is left to the full path because whether it writes \"0\" or nothing at all depends on a setting, and so is a NaN, which writes the variable's own text\n    if (type === 'number') return value === 0 || Number.isNaN(value) ? undefined : value\n    if (type === 'boolean') return value || undefined // false writes the variable's own text\n    return undefined\n  }\n\n  // what a variable writes when the quick answer did not apply\n  //\n  // this is one call rather than the half dozen lines of branching it replaces, because those lines sat in the emitted function for every variable on the page and were almost never the ones taken. a shorter function is one v8 will inline into, and the branches are the same branches either way\n  //\n  // dollar says the variable was written in template literal form. a variable that did not resolve keeps its own text, and the dollar keeps its place in front of it\n  function slowValue (flags, value, raw, source, model, state, dollar) {\n    const resolved = formatVariable(flags, value, model)\n    if (resolved === null) return source\n    const text = writePlainValue(resolved, raw)\n    const written = text === NEEDS_MODEL ? renderValue(resolved.text, model, state) : text\n    return dollar && resolved.skipTemplateLiteralReplacement ? '$' + written : written\n  }\n\n  // what a resolved variable writes, when that can be answered without a model, and NEEDS_MODEL when it cannot\n  //\n  // almost every value is finished the moment it is looked up, and the two that are not are a value holding a {variable} of its own and a raw value holding teddy markup. emitted code asks this first and only reaches for a model on the rare answer, which is what lets a loop body avoid building one at all\n  function writePlainValue (resolved, raw) {\n    const text = resolved.text\n    if (typeof text !== 'string' || resolved.skipTemplateLiteralReplacement) return text\n    if (text.includes('{')) return NEEDS_MODEL\n    if (raw && needsAnotherLook(text)) return NEEDS_MODEL\n    return text\n  }\n\n  // whether a raw value holds anything teddy still has to do something about. a value made only of finished markup and teddy's own placeholders is done\n  function needsAnotherLook (text) {\n    if (!LOOKS_LIKE_TEDDY.test(text)) return false\n    return LOOKS_LIKE_TEDDY.test(text.replace(NOTEDDY_PLACEHOLDER, ''))\n  }\n\n  // which combination of a one line if's outcomes this model calls for, as a bitmask\n  //\n  // valueSets, when given, holds what each conditional's conditions look up already looked up, one array per conditional, which is what a compiled template hands in rather than having the lookups done again\n  function attrsOutcomes (node, model, valueSets) {\n    let outcomes = 0\n    for (let i = 0; i < node.conditionals.length; i++) {\n      const conditional = node.conditionals[i]\n      if (conditional.checks) {\n        if (settleChecks(conditional.checks, model, valueSets ? valueSets[i] : null)) outcomes |= 1 << i\n        continue\n      }\n      // evaluateConditional reduces the array it is handed to booleans as it goes, so a settled condition gets a copy: these have to survive to the next render\n      const args = conditional.dynamic ? oneLineArgs(conditional.argSources, model) : conditional.args.slice()\n      if (evaluateConditional(args, model)) outcomes |= 1 << i\n    }\n    return outcomes\n  }\n\n  // the element's opening tag for one combination of outcomes, worked out the first time a render calls for it and then kept\n  function attrsVariant (node, outcomes) {\n    let variant = node.variants[outcomes]\n    if (variant === undefined) {\n      // the opening tag may still hold a {variable} from one of the element's other attributes, so it is split into text and variable slots the same way the rest of the markup is\n      variant = []\n      pushText(variant, openTagFor(node.openTag, node.closeTag, node.tagName, node.conditionals, outcomes))\n      node.variants[outcomes] = variant\n    }\n    return variant\n  }\n\n  // every opening tag a one line if can produce, worked out while the template is compiled so that emitted code can write the tag itself instead of handing the job to the tree walker, which would need a model built for it\n  //\n  // an element carrying many conditions has too many combinations to write them all out, so those keep the lazy path, which builds only the combination a render actually arrives at\n  function attrsVariants (node) {\n    const total = 1 << node.conditionals.length\n    if (total > MAX_EMITTED_VARIANTS) return null\n    const all = []\n    for (let outcomes = 0; outcomes < total; outcomes++) all.push(attrsVariant(node, outcomes))\n    return all\n  }\n\n  // what closes a hydrating component: the shadow root, then the arguments it was rendered with, then the element itself\n  //\n  // the arguments travel as json in a script the browser will not execute, which is the ordinary way to hand a page some data and needs no permission a strict content security policy withholds. they sit in the light dom rather than the shadow root, so that re-rendering the shadow root does not throw them away\n  function componentPayload (node, model) {\n    const sent = {}\n    for (const name of node.hydrate) sent[name] = getOrSetObjectByDotNotation(model, name)\n    // the closing sequence of a script element is the one thing that could end the script early\n    const json = JSON.stringify(sent).replace(/<\\//g, '<\\\\/')\n    // naming a slot that no component defines is what keeps this out of a default slot: an empty slot attribute means the default slot, the same as writing none at all, while an element naming a slot that is not there is assigned to nothing and rendered nowhere\n    return `<script type=\"application/json\" class=\"teddy-component-model\" slot=\"teddy-component-model\">${json}</script>`\n  }\n\n  // the model an included template sees: the one the include was reached with, plus its arguments\n  function bindArgs (model, bindings, values) {\n    const localModel = Object.create(model || null)\n    for (let i = 0; i < bindings.length; i++) getOrSetObjectByDotNotation(localModel, bindings[i].name, values[i])\n    return localModel\n  }\n\n  // content exempt from parsing is held out of the markup rather than written into it, because the stray tag sweep at the end of a render reparses the finished page and would strip a teddy tag out of it. the same restoration at the end of the render puts it back\n  function rawBlock (node, model) {\n    return `<noteddy id=\"${model._noTeddyBlocks.push(node.value) - 1}\"></noteddy>`\n  }\n\n  function inlineBlock (node, model) {\n    const css = node.css && getOrSetObjectByDotNotation(model, node.css)\n    const js = node.js && getOrSetObjectByDotNotation(model, node.js)\n    if (css) return `<style>${css}</style>`\n    if (js) return `<script>${js}</script>`\n    // teddy drops an inline that names neither\n    if (params.verbosity > 1) console.warn('teddy encountered an <inline> element without a css or js attribute.')\n    return ''\n  }\n\n  // a variable whose name was built from other variables: the name is rendered first, then looked up, so {a{b}} with b of X asks the model for aX\n  function computedVariable (name, model, state) {\n    const flags = VALID_VARIABLE.test(name) ? variableFlags(name) : null\n    const resolved = flags ? formatVariable(flags, getOrSetObjectByDotNotation(model, flags.name), model) : null\n    if (!resolved) return `{${name}}`\n    return writeValue(resolved, name.slice(-6).includes('|s'), model, state)\n  }\n\n  // whether this candidate for a selected-value or checked-value is the one that carries the matching value\n  function selectionMarked (node, model) {\n    // teddy falls back to the attribute as written when the variable in it resolves to nothing\n    const target = parseVars(node.valueSource, model) || node.valueSource\n    // a candidate written inside a loop has had its own value substituted by the time it is compared, so it is compared substituted here too\n    const own = node.ownValue && node.ownValue.includes('{') ? parseVars(node.ownValue, model) : node.ownValue\n    return own === target\n  }\n\n  // whether one arm of a conditional chain is the one that applies\n  //\n  // values, when given, holds what each of the arm's conditions looks up, already looked up, which is what a compiled template hands in rather than having the lookups done again\n  function armMatches (arm, model, isFirst, values) {\n    if (arm.kind === 'else') return true\n    const inverted = arm.kind === 'unless' || arm.kind === 'elseunless'\n    // an arm of a shape settled at compile time is answered without building or reducing anything\n    if (arm.checks) {\n      const result = settleChecks(arm.checks, model, values)\n      return inverted ? !result : result\n    }\n    // only the opening if or unless resolves a {variable} in a condition's value; elseif and elseunless read the value as written. that is inconsistent, and it is preserved here because changing it would change what existing templates render\n    const result = evaluateConditional(conditionArgs(arm.attribs, model, isFirst), model, values)\n    return inverted ? !result : result\n  }\n\n  function pickArm (branch, model) {\n    for (let i = 0; i < branch.arms.length; i++) {\n      if (armMatches(branch.arms[i], model, i === 0, undefined)) return i\n    }\n    return -1\n  }\n\n  // the names a compile time settled set of conditions looks up, in the slots settleChecks reads them from\n  function conditionCheckPaths (checks) {\n    if (!checks) return null\n    if (checks.length === 1) return [checks[0].path]\n    return [checks[0].path, null, checks[2].path]\n  }\n\n  // the names an arm's conditions look up, in the order evaluateConditional will want them, or null where the entry is a boolean operator rather than a condition\n  function armPaths (arm) {\n    return arm.attribs.map(([name, value]) => conditionPath(value ? `${name}=${value}` : name))\n  }\n\n  // a one line if's conditions in the form evaluateConditional wants them. a joiner is stored with no value and goes in on its own; a condition whose value is a variable is resolved against the model, which is only ever needed when the compile could not settle it\n  function oneLineArgs (argSources, model) {\n    const args = []\n    for (const [name, value] of argSources) {\n      if (value === null) args.push(name)\n      else if (!value) args.push(name)\n      else args.push(`${name}=${model && value.includes('{') ? parseVars(value, model) : value}`)\n    }\n    return args\n  }\n\n  function conditionArgs (attribs, model, resolveValues) {\n    const args = []\n    for (const [name, raw] of attribs) {\n      let value = raw\n      if (value) {\n        if (resolveValues && value.includes('{')) value = parseVars(value, model)\n        args.push(`${name}=${value}`)\n      } else args.push(name)\n    }\n    return args\n  }\n\n  // what a loop walks: its collection's keys when the loop names its key, and the values themselves when it does not\n  //\n  // an array is walked by index rather than by key, which is both what the values already are and a far cheaper way to read an element than by a key spelled as a string\n  function loopWalk (collection, needsKey) {\n    if (needsKey) return Object.keys(collection)\n    return Array.isArray(collection) ? collection : Object.values(collection)\n  }\n\n  // whether what a loop was pointed at can be iterated, given a value already looked up. teddy drops a loop it cannot run rather than leaving its body behind\n  function iterable (collection, keyName, valName) {\n    if (!collection) {\n      if (params.verbosity > 1) console.warn('teddy encountered a loop without a through attribute.')\n      return null\n    }\n    if (!keyName && !valName) {\n      if (params.verbosity > 1) console.warn('teddy encountered a loop without a key or a val attribute.')\n      return null\n    }\n    if (collection instanceof Set) return [...collection]\n    return collection\n  }\n\n  // what a loop iterates when the name it was pointed at is only known once there is a model to read it from\n  //\n  // a {variable} may sit anywhere in the path rather than at its head, so any brace means the path has to be resolved before it is looked up\n  function loopCollection (through, keyName, valName, model) {\n    let source = through\n    if (source && source.includes('{')) source = parseVars(source, model)\n    return iterable(source ? getOrSetObjectByDotNotation(model, source) : undefined, keyName, valName)\n  }\n\n  // the model as a loop's body sees it: the model it was reached with, plus this iteration's key and val. emitted code needs this for the helpers it calls, which take a model rather than the javascript variables the emitted code keeps its locals in\n  //\n  // the enclosing model is reached through the prototype chain rather than copied. a loop of a thousand rows copied the whole model a thousand times, and because every copy started out owning nothing, writing this iteration's names into it also searched it for keys differing only in case each time round. an object made this way owns nothing but those two names, so neither cost is paid; a name holding a dot is left alone because setting one never did anything, and a value of undefined is left unset so that the enclosing model still answers for that name\n  function loopScope (model, keyName, key, valName, value) {\n    const localModel = Object.create(model || null)\n    if (keyName && key !== undefined && !keyName.includes('.')) localModel[keyName] = key\n    if (valName && value !== undefined && !valName.includes('.')) localModel[valName] = value\n    return localModel\n  }\n\n  // a <cache> writes the markup its body rendered to last time rather than rendering it again. renderBody is only called on a miss\n  function cacheBlock (node, model, renderBody) {\n    const name = node.name && node.name.includes('{') ? parseVars(node.name, model) : node.name\n    const keySource = node.key && node.key.includes('{') ? parseVars(node.key, model) : node.key\n    // a name or key that still holds a variable never resolved, and teddy leaves such an element alone until the stray tag sweep takes it away, contents and all\n    if (!name || name.includes('{') || (keySource && keySource.includes('{'))) return ''\n    const keyVal = keySource ? getOrSetObjectByDotNotation(model, keySource) : 'none'\n    const existing = caches[name]\n    const entry = existing && existing.entries && existing.entries[keyVal]\n    if (entry) {\n      const now = Date.now()\n      // an entry with no max age set never goes stale\n      if (!existing.maxAge || entry.lastAccessed + existing.maxAge > now) {\n        entry.lastAccessed = now\n        return entry.markup\n      }\n      delete existing.entries[keyVal]\n    }\n    const markup = renderBody()\n    if (!caches[name]) caches[name] = { key: keySource || 'none', maxAge: node.maxAge, maxCaches: node.maxCaches, entries: {} }\n    const stamp = Date.now()\n    caches[name].entries[keyVal] = { lastAccessed: stamp, created: stamp, markup }\n    // drop the least recently used entry once there are more than the element asked to keep\n    const entries = caches[name].entries\n    if (Object.keys(entries).length > node.maxCaches) {\n      delete entries[Object.keys(entries).reduce((a, b) => entries[a].lastAccessed < entries[b].lastAccessed ? a : b)]\n    }\n    return markup\n  }\n\n  // the compiled body of an <include> whose src is only known once there is a model to read it from, compiled the first time a render asks for that name and kept against it\n  function dynamicBody (node, model) {\n    const src = parseVars(node.src, model)\n    let body = node.compiled.get(src)\n    if (body !== undefined) return body\n    if (node.stack.includes(src)) {\n      throw new Error(`teddy: the template \"${src}\" includes itself, directly or through the templates it includes, so it can never finish compiling. include stack: ${node.stack.concat(src).map(name => JSON.stringify(name)).join(' -> ')}`)\n    }\n    const markup = loadTemplate(src)\n    body = markup === null\n      ? notFoundBody(src)\n      : compileTemplate(markup, node.stack.concat(src))\n    node.compiled.set(src, body)\n    return body\n  }\n\n  function renderLoop (node, model, state) {\n    const collection = loopCollection(node.through, node.keyName, node.valName, model)\n    if (!collection) return ''\n\n    let out = ''\n    const needsKey = !!node.keyName\n    const items = loopWalk(collection, needsKey)\n    for (let i = 0; i < items.length; i++) {\n      const key = needsKey ? items[i] : null\n      out += renderNodes(node.body, loopScope(model, node.keyName, key, node.valName, needsKey ? collection[key] : items[i]), state)\n    }\n    return out\n  }\n\n  // #endregion\n\n  // isSelfContained is returned so the test suite can attack it directly: it decides whether a value that arrived through the model can be compiled, and a wrong answer there is the one mistake in this module that would produce quietly incorrect output rather than a visible failure\n  //\n  // helpers are what emitted javascript calls into. every one of them is a function the tree walker calls too, so neither way of rendering a template can reach its own conclusion about what the template means\n  return {\n    compileTemplate,\n    renderNodes,\n    isSelfContained,\n    helpers: {\n      node: makeNode,\n      get: getOrSetObjectByDotNotation,\n      format: formatVariable,\n      write: writeValue,\n      pick: pickArm,\n      quick: quickValue,\n      slow: slowValue,\n      plain: writePlainValue,\n      needs: NEEDS_MODEL,\n      arm: armMatches,\n      present: valuePresent,\n      paths: armPaths,\n      checkPaths: conditionCheckPaths,\n      outcomes: attrsOutcomes,\n      variant: attrsVariant,\n      variants: attrsVariants,\n      bind: bindArgs,\n      payload: componentPayload,\n      render: renderNodes,\n      raw: rawBlock,\n      inline: inlineBlock,\n      computed: computedVariable,\n      marked: selectionMarked,\n      cache: cacheBlock,\n      dynamic: dynamicBody,\n      iterable,\n      walk: loopWalk,\n      collection: loopCollection,\n      scope: loopScope\n    }\n  }\n}\n","// the data a precompiled template carries beside its emitted javascript, written out and read back\n//\n// emitting javascript is what makes a render fast, and it needs to build a function from a string to do it, which a page under a strict content security policy may not do. a template compiled ahead of time does not have to: the function is written to a file as source, and the browser loads it as a script like any other. what has to travel with it is the data the emitted code indexes into, which is what this module writes and reads\n//\n// the shapes involved are not plain json. the same node list is reached from more than one place, an arm holds its branch and the branch holds the arm back, and a dynamic include keeps a map. so every object is written once into a table and referred to by its place in it, which handles sharing and circularity alike\n\nexport const FORMAT = 1 // precompile version: a template compiled by one version of teddy and loaded by another whose format differs is refused rather than rendered into something wrong\n\nconst REF = '$r'\nconst MAP = '$m'\nconst UNDEFINED = '$u'\n\n// the node types the compiler produces. a decoded object is rebuilt as a node when its type is one of these, so that it comes out with the same shape every other node has\nconst NODE_TYPES = new Set(['text', 'var', 'arm', 'loop', 'attrs', 'scope', 'raw', 'inline', 'computedVar', 'selection', 'cache', 'dynamicInclude'])\n\n// true for an object that came out of the compiler's node factory. checking the type alone is not enough: a binding also has a name, and a conditional also has a type of sorts\nfunction isNode (value) {\n  return typeof value.type === 'string' && NODE_TYPES.has(value.type) && Object.prototype.hasOwnProperty.call(value, 'bodySource')\n}\n\nexport function encode (value) {\n  const table = []\n  const places = new Map()\n\n  function write (value) {\n    if (value === undefined) return { [UNDEFINED]: 1 }\n    if (value === null || typeof value !== 'object') {\n      if (typeof value === 'function') throw new Error('teddy: a template holding a function in its compiled form cannot be precompiled')\n      return value\n    }\n\n    const seen = places.get(value)\n    if (seen !== undefined) return { [REF]: seen }\n    // the place is claimed before the contents are written, so that something reaching back to this object finds a reference rather than going round again\n    const place = table.length\n    places.set(value, place)\n    table.push(null)\n\n    if (value instanceof Map) {\n      table[place] = { [MAP]: [...value].map(([k, v]) => [write(k), write(v)]) }\n      return { [REF]: place }\n    }\n    if (Array.isArray(value)) {\n      table[place] = value.map(write)\n      return { [REF]: place }\n    }\n    const written = {}\n    for (const key of Object.keys(value)) written[key] = write(value[key])\n    if (isNode(value)) written.$n = value.type\n    table[place] = written\n    return { [REF]: place }\n  }\n\n  const root = write(value)\n  return { root, table }\n}\n\n// makeNode is the compiler's own node factory, passed in so that this module does not have to know what fields a node has\nexport function decode (encoded, makeNode) {\n  const { root, table } = encoded\n  const built = new Array(table.length).fill(undefined)\n  const done = new Array(table.length).fill(false)\n\n  function read (value) {\n    if (value === null || typeof value !== 'object') return value\n    if (value[UNDEFINED] !== undefined) return undefined\n    // anything else write produced is a reference into the table\n    return at(value[REF])\n  }\n\n  function at (place) {\n    if (done[place]) return built[place]\n    const raw = table[place]\n\n    // the container is made and recorded before what is in it is read, so that something inside it referring back finds the same object rather than a second copy of it\n    if (Array.isArray(raw)) {\n      const out = []\n      built[place] = out\n      done[place] = true\n      for (const item of raw) out.push(read(item))\n      return out\n    }\n    if (raw[MAP] !== undefined) {\n      const out = new Map()\n      built[place] = out\n      done[place] = true\n      for (const [k, v] of raw[MAP]) out.set(read(k), read(v))\n      return out\n    }\n    const out = raw.$n === undefined ? {} : makeNode(raw.$n)\n    built[place] = out\n    done[place] = true\n    for (const key of Object.keys(raw)) {\n      if (key === '$n') continue\n      out[key] = read(raw[key])\n    }\n    return out\n  }\n\n  return read(root)\n}\n","// #region globals\n\nimport fs from 'fs' // node filesystem module\nimport path from 'path' // node path module\nimport { load as cheerioLoad } from 'cheerio/slim' // dom parser\nimport { createCompiler } from './compiler.js' // walks a template once so a render does not have to\nimport { canEmit, emit } from './codegen.js' // turns what the compiler worked out into javascript; browser builds swap this for a stub\nimport { encode, decode, FORMAT } from './precompiled.js' // reads and writes the data a template compiled ahead of time carries\n\nconst cheerioOptions = { lowerCaseAttributeNames: false, decodeEntities: false }\nconst browser = cheerioLoad.isCheerioPolyfill // true if we are executing in the browser context\nconst params = {} // teddy parameters\nsetDefaultParams() // set params to the defaults\nlet templates = {} // templates registered by hand with setTemplate, e.g. { \"myTemplate.html\": \"<p>some markup</p>\"}; this is how templates reach the browser, where there is no filesystem to read them from\nlet fileCache = {} // templates that were read from the filesystem, kept only when template caching is switched on\nlet compiledCache = new Map() // node trees built by the compiler, kept on the same terms as fileCache: only when template caching is switched on, so that editing a template still takes effect without a restart\nconst maxCompiledCache = 10000 // a caller that renders markup passed in as a string rather than by name must not grow this without bound\nconst caches = {} // a place to store cached portions of templates\n// building a regular expression costs far more than using one, and a loop substitutes the same variables out of the same body on every iteration, so the patterns are compiled once and kept\nconst varPatterns = new Map()\nfunction varPattern (source, escape) {\n  const key = escape ? source : '\\u0000raw:' + source\n  let pattern = varPatterns.get(key)\n  if (pattern === undefined) {\n    pattern = new RegExp(escape ? source.replace(/[|\\\\{}()[\\]^$+*?.]/g, '\\\\$&').replace(/-/g, '\\\\x2d') : source, 'i')\n    if (varPatterns.size > 10000) varPatterns.clear() // a model that invents variable names without bound must not grow this forever\n    varPatterns.set(key, pattern)\n  }\n  return pattern\n}\nconst templateCaches = {} // a place to store cached full templates\n\n// #endregion\n\n// #region private methods\n\n// resolves a template to its markup:\n//\n// a template may be the markup itself, the name of a template registered with setTemplate, or the path of a file to read\n//\n// returns null when a name is neither registered nor readable, so that callers can tell a template that is missing apart from one that legitimately rendered to nothing\nfunction loadTemplate (template) {\n  // ensure template is a string\n  if (typeof template !== 'string') {\n    if (params.verbosity > 1) console.warn('teddy.loadTemplate attempted to load a template which is not a string.')\n    return null\n  }\n\n  // markup passed in directly rather than a name to look up\n  if (template.includes('<')) return removeTeddyComments(template)\n\n  const name = template\n  const withExtension = name.slice(-5) === '.html' ? name : name + '.html'\n\n  // a template registered by hand wins over anything on the filesystem, which is what makes the same template work in the browser\n  for (const key of [name, withExtension]) {\n    if (typeof templates[key] === 'string') return removeTeddyComments(templates[key])\n  }\n\n  // then whatever was read from the filesystem last time, if the caller asked for templates to be cached\n  if (params.cacheTemplates && typeof fileCache[name] === 'string') return fileCache[name]\n\n  // then the filesystem itself\n  if (fs && fs.readFileSync) {\n    for (const candidate of [withExtension, params.templateRoot + withExtension, params.templateRoot + '/' + withExtension]) {\n      let contents\n      try {\n        contents = fs.readFileSync(candidate, 'utf8')\n      } catch (e) {\n        continue // try the next place it might be\n      }\n      contents = removeTeddyComments(contents)\n      if (params.cacheTemplates) fileCache[name] = contents\n      return contents\n    }\n  }\n\n  return null // it is not a registered template and there is no file by that name\n}\n\n// remove teddy {! comments !} and <!--! comments -->; also replace <escape>tags</escape> and <!--# content -->\nfunction removeTeddyComments (renderedTemplate) {\n  let oldTemplate\n  do {\n    oldTemplate = renderedTemplate\n    let vars\n\n    // server-side comments\n    try {\n      vars = matchByDelimiter(renderedTemplate, '{!', '!}')\n    } catch (e) {\n      return renderedTemplate // it will match {! comments {! with comments in them !} !} but if there are unbalanced brackets, just return the original text\n    }\n    for (let i = 0; i < vars.length; i++) renderedTemplate = renderedTemplate.replace(`{!${vars[i]}!}`, '')\n\n    try {\n      vars = matchByDelimiter(renderedTemplate, '<!--!', '-->')\n    } catch (e) {\n      return renderedTemplate\n    }\n    for (let i = 0; i < vars.length; i++) renderedTemplate = renderedTemplate.replace(`<!--!${vars[i]}-->`, '')\n\n    // <!--# escape --> blocks and <escape> tags\n    let firstMatch\n    try {\n      firstMatch = getFirstMatchByDelimiters(renderedTemplate, [['<!--#', '-->'], ['<escape>', '</escape>']])\n    } catch (e) {\n      return renderedTemplate\n    }\n    let newContent = firstMatch\n    if (firstMatch) {\n      if (firstMatch.startsWith('<!--#')) {\n        newContent = newContent.substring(0, newContent.length - 3).slice(5)\n        renderedTemplate = renderedTemplate.replace(firstMatch, escapeEntities(newContent.trim()))\n      } else {\n        newContent = newContent.substring(0, newContent.length - 9).slice(8)\n        renderedTemplate = renderedTemplate.replace(firstMatch, escapeEntities(newContent.trim()))\n      }\n    }\n  } while (oldTemplate !== renderedTemplate)\n  return renderedTemplate\n}\n\n// evaluates a single <if> or <unless> tag\nfunction evaluateConditional (conditions, model, values) {\n  const conditionsLength = conditions.length\n  // loop through conditions and reduce them to booleans\n  for (let i = 0; i < conditionsLength; i++) {\n    const condition = conditions[i]\n    if (typeof condition === 'boolean') continue // if the condition is already a boolean then we don't need to reduce it to a boolean to evaluate it\n    // reject conditions with invalid formatting\n    if (condition.startsWith('=') || condition.endsWith('=')) {\n      if (params.verbosity > 1) console.warn('teddy encountered a conditional statement with \"=\" at the beginning or end of a condition.')\n      return false\n    }\n    if (condition.includes(':') && !condition.startsWith('not:')) {\n      if (params.verbosity > 1) console.warn('teddy encountered a conditional statement with a \"not:\" that isn\\'t at the beginning of a condition.')\n      return false\n    }\n    // deal with boolean logic\n    if (condition === 'and') {\n      if (conditions[i - 1] && evaluateCondition(conditions[i + 1], model, values, i + 1)) {\n        // if both sides of an and are true, then reduce all 3 condition blocks to true\n        conditions[i - 1] = true\n        conditions[i] = true\n        conditions[i + 1] = true\n      } else {\n        // if either side of an and is false, then reduce all 3 condition blocks to false\n        conditions[i - 1] = false\n        conditions[i] = false\n        conditions[i + 1] = false\n      }\n    } else if (condition === 'or') {\n      if (conditions[i - 1] || evaluateCondition(conditions[i + 1], model, values, i + 1)) {\n        // if either side of an or is true, then reduce all 3 condition blocks to true, as well as all condition blocks that preceded this or\n        conditions.fill(true, 0, i + 2)\n      } else {\n        // if both sides of an or are false, then reduce all 3 condition blocks to false\n        conditions[i - 1] = false\n        conditions[i] = false\n        conditions[i + 1] = false\n      }\n    } else if (condition === 'xor') {\n      if (!!conditions[i - 1] === !!evaluateCondition(conditions[i + 1], model, values, i + 1)) {\n        // if both sides of an xor are equal to each other, then reduce all 3 condition blocks to false\n        conditions[i - 1] = false\n        conditions[i] = false\n        conditions[i + 1] = false\n      } else {\n        // if the two sides of an xor are not equal to each other, then reduce all 3 condition blocks to true\n        conditions[i - 1] = true\n        conditions[i] = true\n        conditions[i + 1] = true\n      }\n    } else conditions[i] = evaluateCondition(condition, model, values, i)\n  }\n  return conditions.every(item => item === true) || false // if any of the booleans are false, then return false. otherwise return true\n}\n\n// the name a condition looks up in the model, or null when it is a boolean operator rather than a condition. this is the same for every render, so a compiled template works it out once and hands the looked up value in rather than having the lookup done again here\nfunction conditionPath (condition) {\n  if (typeof condition !== 'string') return null\n  if (condition === 'and' || condition === 'or' || condition === 'xor') return null\n  let path = condition.startsWith('not:') ? condition.slice(4) : condition\n  const equals = path.indexOf('=')\n  if (equals !== -1) path = path.slice(0, equals)\n  return path\n}\n\n// determines whether a single condition in a teddy conditional is true or false\n//\n// values, when given, holds what each condition looks up already looked up, which is how a compiled template avoids splitting a dotted name apart on every render\nfunction evaluateCondition (condition, model, values, index) {\n  let not // stores whether the :not modifier is present\n  if (typeof condition === 'string' && condition.includes('=')) { // it's an equality check condition\n    not = !!condition.startsWith('not:') // true if \"not:\" is present\n    if (not) condition = condition.slice(4) // remove the :not prefix\n    const parts = condition.split('=') // something=\"Some content\"\n    const cond = parts[0] // something\n    delete parts[0] // remove the something=\n    const val = parts.join('') // \"Some content\" — the path.join method ensures the string gets rebuilt even if it contains another = character\n    const lookup = values ? values[index] : getOrSetObjectByDotNotation(model, cond)\n    // the == is necessary because teddy does type-insensitive equality checks\n    if (lookup == val) return !not // eslint-disable-line\n    else return not // false\n  } else { // it's a presence check\n    not = typeof condition === 'string' ? !!condition.startsWith('not:') : false // true if \"not:\" is present\n    if (not) condition = condition.slice(4) // remove the :not prefix\n    const lookup = values ? values[index] : getOrSetObjectByDotNotation(model, condition)\n    if (lookup) {\n      if (typeof lookup === 'object' && Object.keys(lookup).length === 0) return not // false; empty object or array\n      return !not // true; var is present\n    } else return not // false; var is not present\n  }\n}\n\n// render {variables}\nfunction parseVars (templateString, model) {\n  let vars\n  try {\n    vars = matchByDelimiter(templateString, '{', '}')\n  } catch (e) {\n    return templateString // it will match {vars{withVarsInThem}} but if there are unbalanced brackets, just return the original text\n  }\n  for (let i = 0; i < vars.length; i++) {\n    let match = vars[i]\n    if (match === '') continue // empty {}\n    if (!/^(\\d+|[a-zA-Z_$][a-zA-Z0-9_$|{}.-]*(\\.[a-zA-Z_$][a-zA-Z0-9_$|{}.-]*)*)$/.test(match)) {\n      if (params.verbosity > 2) console.warn(`teddy.parseVars encountered a {variable} that could not be parsed: {${match}}`)\n      continue // skip invalid variables\n    }\n    if (match.includes('{')) {\n      // there's a variable inside the variable name\n      const originalMatch = match\n      match = parseVars(match, model)\n      try {\n        templateString = templateString.replace(varPattern(`\\${${originalMatch}}`, true), () => `\\${${match}}`)\n        templateString = templateString.replace(varPattern(`{${originalMatch}}`, true), () => `{${match}}`)\n      } catch (e) {\n        if (params.verbosity > 2) console.warn(`teddy.parseVars encountered a {variable} that could not be parsed: {${originalMatch}}`)\n      }\n    }\n    const resolved = resolveVariable(match, model)\n    if (!resolved) continue // the variable resolves to nothing that should be written, so it is left in the markup verbatim\n    const { name, text, skipTemplateLiteralReplacement } = resolved\n    try {\n      if (!skipTemplateLiteralReplacement) templateString = templateString.replace(varPattern(`\\${${name}}`, true), () => text)\n      templateString = templateString.replace(varPattern(`{${name}}`, true), () => text)\n    } catch (e) {\n      return templateString\n    }\n  }\n  return templateString\n}\n\n// works out what a single {variable} should be replaced with, given its name and any flags on it\n//\n// this is shared by the interpreter above and by the compiler, which walks a template once and keeps a slot for every variable rather than rescanning the markup for it. the rules it implements are not obvious: a value of false or null resolves to the variable's own text, 0 writes as \"0\" when escaped but resolves to its own text when raw, an object writes as [Object] when escaped and as its own toString when raw, and |h blanks all of them. having one implementation of that is the only way the two paths can be relied on to agree\n//\n// returns null when nothing should be substituted, or { name, text, skipTemplateLiteralReplacement } where name is the variable without its flags and text is what to write\nfunction resolveVariable (match, model) {\n  const flags = variableFlags(match)\n  return formatVariable(flags, getOrSetObjectByDotNotation(model, flags.name), model)\n}\n\n// which flags a {variable} carries and what its name is without them, worked out from the name alone. this is the same for every render of a template, so a compiled template settles it once rather than reading the last x characters of the name on every render\nfunction variableFlags (match) {\n  const lastSixChars = match.slice(-6)\n  const flagCount = lastSixChars.split('|').length - 1\n  const noparse = lastSixChars.includes('|p')\n  const raw = !noparse && lastSixChars.includes('|s')\n  return {\n    match,\n    name: noparse || raw ? match.substring(0, match.length - flagCount * 2) : match,\n    noparse,\n    raw,\n    hide: lastSixChars.includes('|h'),\n    display: lastSixChars.includes('|d')\n  }\n}\n\n// what a variable writes, given its flags and the value the model had for it\n//\n// the rules here are not obvious: a value of false or null resolves to the variable's own text, 0 writes as \"0\" when escaped but resolves to its own text when raw, an object writes as [Object] when escaped and as its own toString when raw, and |h blanks all of them. this is the one place they are implemented, so every caller agrees about them\n//\n// returns null when nothing should be substituted, or { name, text, skipTemplateLiteralReplacement } where name is the variable as written and text is what to write\nfunction formatVariable (flags, value, model) {\n  const { match, noparse, raw, hide, display } = flags\n  let parsed = value\n\n  if (noparse) {\n    if (!parsed && !display && (params.emptyVarBehavior === 'hide' || hide)) parsed = '' // display empty string instead of the variable text verbatim if this setting is set\n    if (typeof parsed === 'string' && parsed.startsWith('{') && parsed.includes('|d')) parsed = parsed.replace('|d', '')\n    if (!parsed && parsed !== '') return null\n    const id = model._noTeddyBlocks.push(parsed) - 1\n    return { name: match, text: `<noteddy id=\"${id}\"></noteddy>`, skipTemplateLiteralReplacement: false }\n  }\n\n  let skipTemplateLiteralReplacement = false\n  if (raw) {\n    if (!parsed && !display && (params.emptyVarBehavior === 'hide' || hide)) parsed = '' // display empty string instead of the variable text verbatim if this setting is set\n    else if (!parsed && parsed !== '') {\n      skipTemplateLiteralReplacement = true\n      parsed = `{${match}}`\n    }\n  } else {\n    if (!parsed && !display && (params.emptyVarBehavior === 'hide' || hide)) parsed = '' // display empty string instead of the variable text verbatim if this setting is set\n    else if (parsed || parsed === '') parsed = escapeEntities(parsed)\n    else if (parsed === 0) parsed = '0'\n    else {\n      skipTemplateLiteralReplacement = true\n      parsed = `{${match}}`\n    }\n  }\n  if (typeof parsed === 'string' && parsed.startsWith('{') && parsed.includes('|d')) parsed = parsed.replace('|d', '')\n  return { name: match, text: parsed, skipTemplateLiteralReplacement }\n}\n\n// escapes sensitive characters to prevent xss\nconst escapeHtmlEntities = {\n  '&': '&amp;',\n  '<': '&lt;',\n  '>': '&gt;',\n  '\"': '&#34;',\n  \"'\": '&#39;'\n}\n// the same replacements again, indexed by character code, so that finding one costs no comparisons and builds no single character string to compare against\nconst escapeHtmlEntitiesByCode = []\nfor (const character of Object.keys(escapeHtmlEntities)) escapeHtmlEntitiesByCode[character.charCodeAt(0)] = escapeHtmlEntities[character]\n\nconst needsEscaping = /[&<>\"']/g // most values have nothing in them that needs escaping, and one scan settles that\nfunction escapeEntities (value) {\n  if (typeof value === 'object') { // cannot escape on this value\n    if (!value) return false // it is falsy to return false\n    else if (Array.isArray(value)) {\n      if (value.length === 0) return false // empty arrays are falsy\n      else return '[Array]' // print that it is an array with content in it, but do not print the contents\n    }\n    return '[Object]' // just print that it is an object, do not print the contents\n  } else if (value === undefined) return false // cannot escape on this value; undefined is falsy\n  else if (typeof value === 'boolean' || typeof value === 'number') return value // cannot escape on these values; if it's already a boolean or a number just return it\n\n  // the regular expression engine finds the entities, which it does far faster than stepping through the value in javascript, and the stretches between them are copied a piece at a time rather than a character at a time. one pass over the value either way, and a value with nothing to escape is returned as it came in\n  needsEscaping.lastIndex = 0\n  let match = needsEscaping.exec(value)\n  if (match === null) return value\n\n  let escaped = ''\n  let copiedTo = 0\n  do {\n    escaped += value.slice(copiedTo, match.index) + escapeHtmlEntitiesByCode[value.charCodeAt(match.index)]\n    copiedTo = match.index + 1\n    match = needsEscaping.exec(value)\n  } while (match !== null)\n\n  return escaped + value.slice(copiedTo)\n}\n\n// if an entity is double-encoded, this will fix that\nfunction reverseDoubleEncodedEntities (str) {\n  return str.replace(/&amp;(#\\d+;|#x[0-9A-Fa-f]+;|[A-Za-z]+;)/g, '&$1')\n}\n\n// match strings by a custom delimiter\nfunction matchByDelimiter (input, openDelimiter, closeDelimiter) {\n  const stack = []\n  const result = []\n  const openLength = openDelimiter.length\n  const closeLength = closeDelimiter.length\n  for (let i = 0; i < input.length; i++) {\n    if (input.substring(i, i + openLength) === openDelimiter) {\n      stack.push(i + openLength)\n      i += openLength - 1\n    } else if (input.substring(i, i + closeLength) === closeDelimiter) {\n      const start = stack.pop()\n      if (stack.length === 0) result.push(input.substring(start, i))\n      i += closeLength - 1\n    }\n  }\n\n  return result\n}\n\nfunction getFirstMatchByDelimiters (str, delimiters) {\n  const openers = []\n  const closers = []\n  for (const delimiter of delimiters) {\n    openers.push(delimiter[0])\n    closers.push(delimiter[1])\n  }\n  const currentlyOpenBrackets = {}\n  let currentDelimiter = -1\n  let match = ''\n\n  for (let charIndex = 0; charIndex < str.length; charIndex++) {\n    for (let delimiterIndex = 0; delimiterIndex < openers.length; delimiterIndex++) {\n      if (currentDelimiter < 0 || currentDelimiter === delimiterIndex) {\n        const opener = openers[delimiterIndex]\n        const openerLength = opener.length\n        const closer = closers[delimiterIndex]\n        const closerLength = closer.length\n        let chunk = str.substring(charIndex, charIndex + openerLength)\n        if (chunk === opener) {\n          if (!currentlyOpenBrackets[opener]) {\n            match = opener.slice(0, -1)\n            currentlyOpenBrackets[opener] = 1\n            currentDelimiter = delimiterIndex\n            charIndex = charIndex + openerLength - 1 // move the loop ahead beyond the delimiter\n          } else {\n            currentlyOpenBrackets[opener]++\n          }\n        } else {\n          chunk = str.substring(charIndex, charIndex + closerLength)\n          if (chunk === closer) {\n            if (currentlyOpenBrackets[opener]) {\n              if (currentlyOpenBrackets[opener] > 1) currentlyOpenBrackets[opener]-- // they're nested; keep going\n              else if (currentlyOpenBrackets[opener] === 1) {\n                match += closer\n                return match\n              }\n            }\n          }\n        }\n        if (currentlyOpenBrackets[opener]) match += str.charAt(charIndex)\n      }\n    }\n  }\n\n  return match\n}\n\n// gets or sets an object by dot notation, e.g. thing.nestedThing.furtherNestedThing: two arguments gets, three arguments sets\nfunction getOrSetObjectByDotNotation (obj, dotNotation, value) {\n  if (!obj) return false\n  if (!dotNotation || typeof dotNotation === 'boolean' || typeof dotNotation === 'number') return dotNotation\n  if (typeof dotNotation === 'string') return getOrSetObjectByDotNotation(obj, dotNotation.split('.'), value)\n  else if (dotNotation.length === 1 && value !== undefined) {\n    // a lookup is case insensitive, so a key that differs from this one only in case has to go: leaving both in place means which one a later lookup finds depends on the order the keys happen to be in. this matters most for <include> <arg> names, because the browser lowercases attribute names and cheerio does not, so an <arg camelCase> would otherwise sit next to a model key of the same name in a different case\n    //\n    // only a key this object owns is ambiguous with the one about to be written, so only those are looked at. a key it merely inherits from the model an enclosing loop or include was reached with is shadowed by the write rather than left sitting behind it, and deleting one would reach back into a model that enclosing scope is still rendering from\n    const key = dotNotation[0]\n    if (!Object.prototype.hasOwnProperty.call(obj, key)) {\n      const lowerCaseKey = key.toLowerCase()\n      for (const existing of Object.keys(obj)) {\n        if (existing !== key && existing.toLowerCase() === lowerCaseKey) delete obj[existing]\n      }\n    }\n    obj[key] = value\n    return obj[key]\n  } else {\n    // walked rather than recursed: the recursion handed each step a copy of the rest of the path, so a name of three segments allocated two arrays every time it was read\n    let current = obj\n    for (let i = 0; i < dotNotation.length; i++) {\n      if (!current) return false\n      current = caseInsensitiveLookup(current, dotNotation[i])\n    }\n    return current\n  }\n  function caseInsensitiveLookup (obj, key) {\n    if (key === 'length') return obj.length\n    // a key that matches exactly is the overwhelming case, and answering it costs one lookup. the lowercased copy of the object below is only built when there is no exact match to be had, which is what stops a model lookup from costing as much as the object is wide on every single step of every single path\n    //\n    // asking what the object owns, rather than reading the key straight off it, is what makes an <arg> win against a model key that differs from it only in case. the browser lowercases attribute names, so an <arg escapeTest> arrives owned as escapetest while the model's own spelling is still reachable through the prototype chain: a plain read would find that one and stop, where the walk below prefers the key this object owns\n    if (Object.prototype.hasOwnProperty.call(obj, key)) return obj[key]\n    // a loop body and an included template see the model they were reached with through the prototype chain rather than through a copy of it, so the keys worth looking at are the inherited ones too. a key the object owns answers ahead of one it inherits, which is what an exact match one line above would have done\n    const lowerCaseKey = key.toLowerCase()\n    let own\n    let ownFound = false\n    let inherited\n    let inheritedFound = false\n    for (const k in obj) {\n      if (k.toLowerCase() !== lowerCaseKey) continue\n      if (Object.prototype.hasOwnProperty.call(obj, k)) {\n        own = obj[k]\n        ownFound = true\n      } else if (!inheritedFound) {\n        inherited = obj[k]\n        inheritedFound = true\n      }\n    }\n    return ownFound ? own : inherited\n  }\n}\n\n// cheerio polyfill\nfunction getAttribs (element) {\n  const attributes = element.attributes\n  const attributesObject = {}\n  for (let i = 0; i < attributes.length; i++) {\n    const attr = attributes[i]\n    attributesObject[attr.name] = attr.value\n  }\n  return attributesObject\n}\n\n// #endregion\n\n// #region public methods\n\n// set params to the defaults\nfunction setDefaultParams () {\n  params.verbosity = 1\n  params.templateRoot = './'\n  params.emptyVarBehavior = 'display' // or 'hide'\n  params.includeNotFoundBehavior = 'display' // or 'hide'\n  params.cacheTemplates = false // whether to keep templates read from the filesystem in memory rather than reading them again on the next render\n}\n\n// mutator method to set verbosity param. takes human-readable string argument and converts it to an integer for more efficient checks against the setting\nfunction setVerbosity (v) {\n  switch (v) {\n    case 'none':\n    case 0:\n      v = 0\n      break\n    case 'verbose':\n    case 2:\n      v = 2\n      break\n    case 'debug':\n    case 'DEBUG':\n    case 3:\n      v = 3\n      break\n    default: // concise\n      v = 1\n  }\n  params.verbosity = v\n}\n\n// mutator method to set template root param; must be a string\nfunction setTemplateRoot (v) {\n  params.templateRoot = String(v)\n}\n\n// mutator method to set empty var behavior param: whether to display {variables} that don't resolve as text ('display') or as an empty string ('hide')\nfunction setEmptyVarBehavior (v) {\n  if (v === 'hide') params.emptyVarBehavior = 'hide'\n  else params.emptyVarBehavior = 'display'\n}\n\n// mutator method to set include tag not found param: whether to display an error when an <include> tag src can't be found\nfunction setIncludeNotFoundBehavior (v) {\n  if (v === 'hide') params.includeNotFoundBehavior = 'hide'\n  else params.includeNotFoundBehavior = 'display'\n}\n\n// mutator method to set whether templates read from the filesystem are kept in memory\n//\n// off by default, matching how most other templating engines (e.g. ejs and pug) treat their own caching, so that editing a template takes effect without a restart\n//\n// express sets its own `view cache` setting per mode and teddy picks that up in render, so an express app gets caching in production and fresh reads in development without having to ask for either\nfunction setCacheTemplates (v) {\n  params.cacheTemplates = !!v\n}\n\n// access templates\nfunction getTemplates () {\n  return templates\n}\n\n// takes in a template string and outputs a function which when given data will render out html\nfunction compile (templateString) {\n  return function (model) {\n    return render(templateString, model)\n  }\n}\n\nconst compiler = createCompiler({\n  cheerioLoad,\n  cheerioOptions,\n  browser,\n  params,\n  variableFlags,\n  formatVariable,\n  escapeEntities,\n  conditionPath,\n  evaluateConditional,\n  loadTemplate,\n  caches,\n  parseVars,\n  getAttribs,\n  getOrSetObjectByDotNotation\n})\n\n// everything about a template that does not depend on the model: its markup with repeated attributes renamed, and the node tree the compiler built from it\n//\n// nodes is null for a template the compiler does not handle, and that answer is kept too, so a template it has already turned down is not walked again on every render only to be turned down again\n//\n// keyIsMarkup says the key is the template's own markup rather than a name it was looked up by. such an entry can never go stale, because the key is the content, so it is always kept: that is what makes teddy.compile() compile once even in development. an entry keyed by a name can go stale, since the file behind the name may change, so it is kept only on the same terms as the template source itself\nfunction prepareTemplate (cacheKey, markup, keyIsMarkup, emittedOut) {\n  const keep = keyIsMarkup || params.cacheTemplates\n  // give every repeated attribute name a unique one before the markup is parsed since html parsers strip duplicate attributes\n  const prepared = markup.replace(/<([a-zA-Z][a-zA-Z0-9-]*)([^>]*)>/g, (match, tagName, attributes) => {\n    const attrRegex = /([a-zA-Z0-9-:._]+)(?:=([\"'])(.*?)\\2|([^>\\s]+))?/g\n    const attrMap = new Map()\n    let count = 1\n    const processedAttributes = attributes.replace(attrRegex, (attrMatch, attrName, quote, attrValue) => {\n      if (attrMap.has(attrName)) {\n        const newAttrName = `${attrName}-teddyduplicate${count++}`\n        return attrMatch.replace(attrName, newAttrName)\n      } else {\n        attrMap.set(attrName, true)\n        return attrMatch\n      }\n    })\n    return `<${tagName}${processedAttributes}>`\n  })\n  const nodes = compiler.compileTemplate(prepared)\n  // emitting javascript is faster than walking the tree, and needs to build a function from a string to do it, which a page under a strict content security policy may not do. browser builds therefore walk the tree, and so does any template holding a construct the emitter does not write code for\n  let render = null\n  if (canEmit(nodes)) {\n    try {\n      const emitted = emit(nodes, compiler.helpers)\n      // only precompiling asks for this, and it is not kept on the entry: the source and the data behind it are wanted once, to be written out\n      if (emittedOut) emittedOut.emitted = emitted\n      render = emitted.render\n    } catch (err) {\n      if (params.verbosity > 1) console.warn(`teddy: could not emit javascript for this template, so it will be rendered by walking it instead: ${err.message}`)\n      render = null\n    }\n  }\n  const entry = { markup: prepared, nodes, render, keyIsMarkup }\n  if (keep) {\n    if (compiledCache.size > maxCompiledCache) compiledCache = new Map()\n    compiledCache.set(cacheKey, entry)\n  }\n  return entry\n}\n\n// mutator method to cache template\nfunction setTemplate (file, template) {\n  templates[file] = template\n  // whatever was compiled under this name was compiled from the old markup\n  compiledCache.delete(file)\n  compiledCache.delete(file.slice(-5) === '.html' ? file.substring(0, file.length - 5) : file + '.html')\n}\n\n// mutator method to clear template cache entirely\nfunction clearTemplates () {\n  templates = {}\n  fileCache = {}\n  compiledCache = new Map()\n}\n\nfunction setCache (params) {\n  if (!templateCaches[params.template]) templateCaches[params.template] = {}\n  if (params.key) {\n    templateCaches[params.template][params.key] = {\n      maxAge: params.maxAge || params.maxage,\n      maxCaches: (params.maxCaches || params.maxcaches) || 1000,\n      entries: {}\n    }\n  } else {\n    templateCaches[params.template].none = {\n      maxAge: params.maxAge || params.maxage,\n      markup: null,\n      created: null\n    }\n  }\n}\n\n// delete one or more cached templates\n//\n// 1 string argument deletes the whole cache at that name for template partial caches\n//\n// 2 arguments deletes just the value at that keyVal for template partial caches\n//\n// 1 object argument assumes we're clearing whole template level cache\nfunction clearCache (name, keyVal) {\n  if (typeof name === 'string') {\n    if (keyVal) delete caches[name].entries[keyVal]\n    else delete caches[name]\n  } else if (typeof name === 'object') {\n    const params = name\n    if (params.key) delete templateCaches[params.template][params.key]\n    else delete templateCaches[params.template]\n  } else if (params.verbosity > 0) console.error('teddy: invalid params passed to clearCache.')\n}\n\n// parses a template\nfunction render (template, model, callback) {\n  // ensure template is a string\n  if (typeof template !== 'string') {\n    if (params.verbosity > 1) console.warn('teddy.render attempted to render a template which is not a string.')\n    if (typeof callback === 'function') return callback(null, '')\n    else return ''\n  }\n\n  // ensure model is an object\n  if (typeof model !== 'object') {\n    if (params.verbosity > 1) console.warn('teddy.render was passed an invalid model.')\n    model = {} // allow the template to render if an invalid model is supplied, but it will have an empty model\n  }\n\n  // declare vars\n  let renderedTemplate\n  model._noTeddyBlocks = [] // will store code blocks exempt from teddy parsing\n\n  // express.js support\n  if (model.settings && model.settings.views && path) params.templateRoot = path.resolve(model.settings.views)\n\n  // caching is taken from the render options the way other templating engines (e.g. ejs and pug) take theirs, so that whoever is calling teddy decides\n  //\n  // an explicit `cache` option wins; otherwise express' own `view cache` setting is used, which express turns on in production and off in development, so an express app gets the right behavior without asking for it\n  if (typeof model.cache === 'boolean') params.cacheTemplates = model.cache\n  else if (model.settings && typeof model.settings['view cache'] === 'boolean') params.cacheTemplates = model.settings['view cache']\n\n  // remove templateRoot from template name if necessary\n  if (template.slice(params.templateRoot.length) === params.templateRoot) template = template.replace(params.templateRoot, '')\n\n  // whole template caching\n  const templateCache = templateCaches[template]\n  let cacheKey = null\n  let cacheKeyModelVal = null\n  if (templateCache) {\n    const singletonCache = templateCache.none\n    if (singletonCache) {\n      // an entry with no max age set never goes stale\n      if (!singletonCache.created) cacheKey = 'none'\n      else if (singletonCache.maxAge && singletonCache.created + singletonCache.maxAge < Date.now()) cacheKey = 'none' // it has gone stale, so render it again and keep the new markup\n      else {\n        if (typeof callback === 'function') return callback(null, singletonCache.markup)\n        else return singletonCache.markup\n      }\n    } else {\n      for (const key in templateCache) {\n        const modelVal = getOrSetObjectByDotNotation(model, key)\n        // the model says nothing about this key, so this render is not cached under it. saying zero, or an empty string, is still saying something\n        if (modelVal === false || modelVal === null || modelVal === undefined) continue\n\n        // the value names an entry, and the name of anything is a string: a number used as one becomes its own digits, so it has to be read back the same way it was written. searching the entries for it instead would cost as much as the cache is wide, and would never match a value that was not a string to begin with\n        cacheKeyModelVal = String(modelVal)\n        const templateCacheAtThisKey = templateCache[key]\n        const entry = templateCacheAtThisKey.entries[cacheKeyModelVal]\n        const maxAge = templateCacheAtThisKey.maxAge\n\n        // an entry with no max age set never goes stale\n        if (entry && (!maxAge || entry.created + maxAge >= Date.now())) {\n          if (typeof callback === 'function') return callback(null, entry.markup)\n          else return entry.markup\n        }\n\n        // either nothing is cached for this value yet or what was there has gone stale\n        cacheKey = key\n        break\n      }\n    }\n  }\n\n  // everything about a template that does not depend on the model is done once and kept together against the argument the caller passed, whether that was a name or the markup itself\n  //\n  // the entry is looked for before anything else happens, because reading the template and stripping its comments are template level work too\n  let prepared = compiledCache.get(template)\n  // a name may point at different markup than it did last time, so an entry keyed by one is only trusted on the same terms as the template source itself. an entry keyed by markup cannot go stale, because the key is the content\n  if (prepared && !prepared.keyIsMarkup && !prepared.precompiled && !params.cacheTemplates) prepared = undefined\n  if (!prepared) {\n    let source = loadTemplate(template)\n    // a name that resolves to nothing falls back to being rendered as though it were markup\n    if (source === null) source = template.slice(-5) === '.html' ? template.substring(0, template.length - 5) : template\n    prepared = prepareTemplate(template, source, template.includes('<'))\n  }\n  renderedTemplate = prepared.markup\n\n  // render from what the compiler worked out about this template: emitted javascript where that was possible, and a walk of the node tree otherwise. neither reparses the markup\n  const state = { values: [] }\n  renderedTemplate = prepared.render ? prepared.render(model, state) : compiler.renderNodes(prepared.nodes, model, state)\n\n  // replace <noteddy> blocks with the hidden code\n  for (const blockId in model._noTeddyBlocks) {\n    renderedTemplate = renderedTemplate.replace(`<noteddy id=\"${blockId}\"></noteddy>`, () => model._noTeddyBlocks[blockId])\n    renderedTemplate = renderedTemplate.replace(`<noteddy id=\"${blockId}\" pre=\"true\"></noteddy>`, () => model._noTeddyBlocks[blockId])\n  }\n\n  if (browser) {\n    // the renamed src and href attributes are put back as the markup leaves the dom now, so a render no longer sweeps its whole output for them\n    //\n    // what is left is the double encoding, which can still arrive in a value the model supplied rather than through the parser. asking whether there is any is far cheaper than rewriting a page that has none, and nearly every page has none\n    if (renderedTemplate.includes('&amp;')) renderedTemplate = reverseDoubleEncodedEntities(renderedTemplate)\n  }\n\n  // cache the template\n  if (cacheKey === 'none') {\n    templateCaches[template].none.markup = renderedTemplate\n    templateCaches[template].none.created = Date.now()\n  } else if (cacheKey) {\n    if (!templateCaches[template][cacheKey].entries[cacheKeyModelVal]) templateCaches[template][cacheKey].entries[cacheKeyModelVal] = {}\n    templateCaches[template][cacheKey].entries[cacheKeyModelVal].markup = renderedTemplate\n    templateCaches[template][cacheKey].entries[cacheKeyModelVal].created = Date.now()\n    // invalidate oldest cache if we've reached max caches limit\n    if (Object.keys(templateCaches[template][cacheKey].entries).length > templateCaches[template][cacheKey].maxCaches) {\n      const lowestKeyVal = Object.keys(templateCaches[template][cacheKey].entries).reduce((a, b) => templateCaches[template][cacheKey].entries[a].created < templateCaches[template][cacheKey].entries[b].created ? a : b)\n      delete templateCaches[template][cacheKey].entries[lowestKeyVal]\n    }\n  }\n\n  if (typeof callback === 'function') return callback(null, renderedTemplate)\n  else return renderedTemplate\n}\n\n// #endregion\n\n// writes a template out as the javascript teddy would otherwise have built for it at runtime, so that a browser can be handed the fast render rather than the slow one\n//\n// this runs where the emitter is, which is node: the returned string is an es module, meant to be written to a file at build time and loaded by the page that needs it. registerPrecompiled below is what the page then calls. nothing is built from a string at runtime, so a strict content security policy is satisfied\nconst PRECOMPILED_WRAPPERS = {\n  // for a bundler, for node's `import`, and for a browser's <script type=\"module\">\n  esm: body => `export default ${body}\\n`,\n\n  // for `require`, and for a bundler that would rather have commonjs\n  cjs: body => `module.exports = ${body}\\n`,\n\n  // for a plain <script src> with no module loader anywhere: the templates collect on one global, keyed by name, so that a page can load as many of them as it likes without them colliding\n  global: (body, name) => `;(function (root) {\\n  root.teddyPrecompiled = root.teddyPrecompiled || {}\\n  root.teddyPrecompiled[${JSON.stringify(name)}] = ${body}\\n})(typeof globalThis !== 'undefined' ? globalThis : this)\\n`\n}\n\nfunction precompile (template, options = {}) {\n  // the emitter is not in a browser build, so there would be nothing here to write out. saying so plainly beats reporting it as a template the emitter does not cover\n  if (browser) throw new Error('teddy: precompiling needs the code emitter, which browser builds do not carry. run teddy.precompile in node, at build time, and load what it writes with teddy.registerPrecompiled')\n  const format = options.format ?? 'esm'\n  const wrap = PRECOMPILED_WRAPPERS[format]\n  if (!wrap) throw new Error(`teddy: \"${format}\" is not a way teddy can write a precompiled template. it writes ${Object.keys(PRECOMPILED_WRAPPERS).join(', ')}`)\n  let source = loadTemplate(template)\n  if (source === null) source = template.slice(-5) === '.html' ? template.substring(0, template.length - 5) : template\n  const out = {}\n  prepareTemplate(template, source, template.includes('<'), out)\n  if (!out.emitted) throw new Error(`teddy: \"${template}\" holds something the emitter does not write code for, so it cannot be precompiled. it still renders by walking its node tree`)\n  const body = `{\n  format: ${FORMAT},\n  name: ${JSON.stringify(template)},\n  data: ${JSON.stringify(encode(out.emitted.data))},\n  render: function (m, r, s) {\n${out.emitted.source}\n  }\n}`\n  return `// teddy precompiled template: ${template}\n// generated: do not edit. rebuild this by running teddy.precompile() against the template again\n${wrap(body, template)}`\n}\n\n// takes what precompile wrote and renders with it from here on, in place of compiling the template\nfunction registerPrecompiled (artifact) {\n  if (!artifact || typeof artifact.render !== 'function') throw new Error('teddy: registerPrecompiled needs what teddy.precompile wrote')\n  if (artifact.format !== FORMAT) throw new Error(`teddy: this template was precompiled for teddy's format ${artifact.format}, and this teddy reads format ${FORMAT}. precompile it again`)\n  const data = decode(artifact.data, compiler.helpers.node)\n  const runtime = { ...compiler.helpers, ...data }\n  compiledCache.set(artifact.name, {\n    markup: '',\n    // there is no node tree behind a precompiled template: the emitted render is the only way it renders, and it is never the one that falls back to walking\n    nodes: null,\n    render: (model, state) => artifact.render(model, runtime, state),\n    keyIsMarkup: false,\n    precompiled: true\n  })\n  return artifact.name\n}\n\nexport default {\n  params,\n  caches,\n  templateCaches,\n\n  // functions\n  compile,\n  setDefaultParams,\n  setVerbosity,\n  setTemplateRoot,\n  setEmptyVarBehavior,\n  setIncludeNotFoundBehavior,\n  setCacheTemplates,\n  getTemplates,\n  setTemplate,\n  clearTemplates,\n  setCache,\n  clearCache,\n  render,\n  precompile,\n  registerPrecompiled,\n  __express: render\n}\n"],"names":["__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","exports","module","__webpack_modules__","load","html","doc","selfClosingTags","Set","root","document","createElement","dom","openTags","tagAndCommentRegex","attrRegex","rawTextTags","match","lastIndex","exec","length","Error","textBeforeMatch","slice","index","trim","textNode","createTextNode","childrenOf","appendChild","startsWith","commentNode","createComment","fullMatch","tagName","attrString","lowerCaseTagName","toLowerCase","has","element","pop","attrMatch","attrMap","Map","attrName","attrValue","newAttrName","count","set","name","value","setAttribute","e","console","warn","isTemplate","content","teddyTemplateHost","endsWith","closeTag","RegExp","close","end","text","push","remainingText","parseTeddyDOMFromString","$","query","queryAll","el","children","Array","from","childNodes","filter","node","nodeType","contents","find","selector","getTeddyDOMInnerHTML","toString","getTeddyDOMOuterHTML","attr","val","removeAttr","removeAttribute","replaceWith","newHtml","window","Node","COMMENT_NODE","textContent","outerHTML","temp","innerHTML","remove","isCheerioPolyfill","entityFixes","Object","entries","map","doublyEncoded","singleEncoded","deferredAttributes","undoParserArtifacts","pattern","replace","found","querySelectorAll","matches","nodeName","child","ELEMENT_NODE","TEXT_NODE","internalError","detail","params","message","verbosity","TOKEN_CANDIDATES","SELECTION_ATTRS","STRUCTURAL","ARM_TAGS","ORPHANABLE","OPENERS","JOINERS","OUTCOMES","VALID_VARIABLE","LOOKS_LIKE_TEDDY","HAS_TEDDY_TAGS","NOTEDDY_PLACEHOLDER","VOID_ELEMENTS","UNPARSED_CONTENT","tagsOutsideUnparsedContent","source","tag","trimEnd","test","NEEDS_MODEL","Symbol","QUICK_VALUE_STOP","REF","MAP","UNDEFINED","NODE_TYPES","encode","table","places","write","seen","get","place","k","v","isArray","written","key","keys","type","prototype","hasOwnProperty","call","isNode","$n","decode","encoded","makeNode","built","fill","done","read","raw","out","item","at","browser","setDefaultParams","templates","fileCache","compiledCache","caches","varPatterns","varPattern","escape","size","clear","templateCaches","loadTemplate","template","includes","removeTeddyComments","withExtension","cacheTemplates","fs_ignored_","readFileSync","candidate","templateRoot","renderedTemplate","oldTemplate","vars","firstMatch","matchByDelimiter","i","getFirstMatchByDelimiters","newContent","substring","escapeEntities","evaluateCondition","condition","model","values","not","parts","split","cond","join","getOrSetObjectByDotNotation","lookup","resolveVariable","flags","variableFlags","formatVariable","lastSixChars","flagCount","noparse","hide","display","parsed","emptyVarBehavior","_noTeddyBlocks","skipTemplateLiteralReplacement","escapeHtmlEntities","escapeHtmlEntitiesByCode","character","charCodeAt","needsEscaping","escaped","copiedTo","input","openDelimiter","closeDelimiter","stack","result","openLength","closeLength","start","str","delimiters","openers","closers","delimiter","currentlyOpenBrackets","currentDelimiter","charIndex","delimiterIndex","opener","openerLength","closer","closerLength","chunk","charAt","obj","dotNotation","lowerCaseKey","existing","current","caseInsensitiveLookup","own","inherited","ownFound","inheritedFound","includeNotFoundBehavior","compiler","deps","cheerioLoad","cheerioOptions","conditionPath","evaluateConditional","parseVars","getAttribs","token","tokenFor","compileTemplate","slots","nodes","compileMarkup","compileSlotBody","slot","arm","branch","arms","body","bodySource","bindings","binding","lightSource","lightNodes","fallbackSource","fallbackNodes","through","keyName","valName","conditionals","outcomesNeedModel","variantNeedsModel","openTag","variants","src","compiled","valueSource","ownValue","maxAge","maxCaches","css","js","hydrate","openNodes","mode","dollar","path","nameNodes","open","splice","lastIndexOf","reportStrayClosingTags","childSelector","marker","attribs","inlineIncludes","readAttribs","candidates","claimSelectionCandidate","applySelectionAttributes","outermost","parent","parentNode","tagNameOf","carriesParse","carriesOneLineIf","hasConstructAncestor","claimed","claimConditional","claimLoop","claimInclude","claimInline","claimCache","claimNoParse","claimPre","claimOneLineIf","clean","sweepOrphanedTags","markup","cursor","indexOf","pushText","Number","isInteger","JSON","stringify","buildNodes","conditionChecks","pairs","checks","rawName","rawValue","compare","shapeIsOne","shapeIsPair","valuePresent","settleCheck","check","settleChecks","first","second","chain","sibling","nextSibling","collectChain","add","kind","armNode","attribValue","ifTrue","ifFalse","argSources","args","dynamic","replaceAll","conditional","oneLineArgs","splitTag","some","CUSTOM_ELEMENT_NAME","COMPONENT_ATTRIBUTES","COMPONENT_MODES","FALLBACK_SLOT","UNPARSED","hasUnparsedAncestor","fallbackMarkup","held","stripped","readArgs","concat","included","passed","Boolean","container","round","plain","probe","target","rebuilt","marked","keepTags","parseInt","outer","inner","pushTextNode","literalFrom","depth","computed","spanStart","valueTemplates","isSelfContained","closing","rest","renderValue","state","error","compileValue","renderNodes","openBranch","winningArm","resolved","writeValue","pickArm","attrsVariant","attrsOutcomes","rawBlock","inlineBlock","computedVariable","selectionMarked","cacheBlock","dynamicBody","bindArgs","scoped","componentPayload","renderLoop","writePlainValue","needsAnotherLook","valueSets","outcomes","variant","outcome","openTagFor","sent","localModel","create","armMatches","isFirst","inverted","resolveValues","conditionArgs","loopWalk","collection","needsKey","iterable","loopCollection","loopScope","renderBody","keySource","keyVal","entry","now","Date","lastAccessed","stamp","created","reduce","a","b","notFoundBody","items","helpers","format","pick","quick","isNaN","slow","needs","present","paths","checkPaths","total","all","bind","payload","render","inline","cache","walk","scope","createCompiler","lowerCaseAttributeNames","decodeEntities","equals","conditions","conditionsLength","every","templateString","originalMatch","attributes","attributesObject","prepareTemplate","cacheKey","keyIsMarkup","emittedOut","keep","prepared","quote","callback","settings","views","path_ignored_","resolve","templateCache","cacheKeyModelVal","singletonCache","none","modelVal","String","templateCacheAtThisKey","precompiled","blockId","lowestKeyVal","PRECOMPILED_WRAPPERS","esm","cjs","global","teddy","compile","setVerbosity","setTemplateRoot","setEmptyVarBehavior","setIncludeNotFoundBehavior","setCacheTemplates","getTemplates","setTemplate","file","delete","clearTemplates","setCache","maxage","maxcaches","clearCache","precompile","options","wrap","emitted","data","registerPrecompiled","artifact","runtime","__express"],"sourceRoot":""}