{
  "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
  "name": "WRNexus",
  "scopeName": "source.wrn",
  "patterns": [
    {
      "include": "#comments"
    },
    {
      "include": "#declaration"
    },
    {
      "include": "#blocks"
    }
  ],
  "repository": {
    "comments": {
      "patterns": [
        {
          "name": "comment.line.double-slash.wrn",
          "match": "//.*$"
        },
        {
          "name": "comment.block.html.wrn",
          "begin": "<!--",
          "end": "-->"
        }
      ]
    },
    "declaration": {
      "match": "\\b(page|component|layout)\\b\\s+([A-Za-z_$][A-Za-z0-9_$]*)?",
      "captures": {
        "1": {
          "name": "storage.type.wrn keyword.control.wrn"
        },
        "2": {
          "name": "entity.name.type.wrn"
        }
      }
    },
    "blocks": {
      "patterns": [
        {
          "include": "#view-block"
        },
        {
          "include": "#style-block"
        },
        {
          "include": "#seo-block"
        },
        {
          "include": "#props-block"
        },
        {
          "include": "#lifecycle-block"
        },
        {
          "include": "#watch-block"
        },
        {
          "include": "#realtime-block"
        },
        {
          "include": "#mode-block"
        },
        {
          "include": "#api-block"
        },
        {
          "include": "#functions-block"
        },
        {
          "include": "#state-decl"
        },
        {
          "include": "#layout-decl"
        },
        {
          "include": "#strings"
        }
      ]
    },
    "layout-decl": {
      "match": "\\b(layout)\\b\\s*(=)",
      "captures": {
        "1": {
          "name": "keyword.control.wrn"
        },
        "2": {
          "name": "keyword.operator.assignment.wrn"
        }
      }
    },
    "state-decl": {
      "begin": "\\b(state)\\b\\s+([A-Za-z_$][A-Za-z0-9_$]*)\\s*(=)",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.wrn"
        },
        "2": {
          "name": "variable.other.wrn"
        },
        "3": {
          "name": "keyword.operator.assignment.wrn"
        }
      },
      "end": "$",
      "contentName": "meta.embedded.expr.wrn",
      "patterns": [
        {
          "include": "source.ts"
        }
      ]
    },
    "props-block": {
      "begin": "\\b(props)\\b\\s*(\\{)",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.wrn"
        },
        "2": {
          "name": "punctuation.definition.block.begin.wrn"
        }
      },
      "end": "\\}",
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.block.end.wrn"
        }
      },
      "patterns": [
        {
          "include": "#comments"
        },
        {
          "match": "\\b([A-Za-z_$][A-Za-z0-9_$]*)\\s*(=)",
          "captures": {
            "1": {
              "name": "variable.parameter.wrn"
            },
            "2": {
              "name": "keyword.operator.assignment.wrn"
            }
          }
        },
        {
          "include": "#strings"
        }
      ]
    },
    "seo-block": {
      "begin": "\\b(seo)\\b\\s*(\\{)",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.wrn"
        },
        "2": {
          "name": "punctuation.definition.block.begin.wrn"
        }
      },
      "end": "\\}",
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.block.end.wrn"
        }
      },
      "patterns": [
        {
          "include": "#comments"
        },
        {
          "match": "\\b([A-Za-z_$][A-Za-z0-9_$-]*)\\s*(=)",
          "captures": {
            "1": {
              "name": "support.type.property-name.wrn"
            },
            "2": {
              "name": "keyword.operator.assignment.wrn"
            }
          }
        },
        {
          "include": "#strings"
        }
      ]
    },
    "style-block": {
      "begin": "\\b(style)\\b\\s*(\\{)",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.wrn"
        },
        "2": {
          "name": "punctuation.definition.block.begin.wrn"
        }
      },
      "end": "\\}",
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.block.end.wrn"
        }
      },
      "contentName": "meta.embedded.block.css",
      "patterns": [
        {
          "include": "#css-braces"
        },
        {
          "include": "source.css"
        }
      ]
    },
    "css-braces": {
      "begin": "\\{",
      "end": "\\}",
      "contentName": "meta.embedded.block.css",
      "patterns": [
        {
          "include": "#css-braces"
        },
        {
          "include": "source.css"
        }
      ]
    },
    "functions-block": {
      "begin": "\\b(functions)\\b\\s*(\\{)",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.wrn"
        },
        "2": {
          "name": "punctuation.definition.block.begin.wrn"
        }
      },
      "end": "\\}",
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.block.end.wrn"
        }
      },
      "contentName": "meta.embedded.block.ts",
      "patterns": [
        {
          "match": "\\b(async\\s+)?(function)\\s+([A-Za-z_$][A-Za-z0-9_$]*)",
          "captures": {
            "1": {
              "name": "storage.modifier.async.ts"
            },
            "2": {
              "name": "storage.type.function.ts"
            },
            "3": {
              "name": "entity.name.function.wrn"
            }
          }
        },
        {
          "include": "#ts-braces"
        },
        {
          "include": "source.ts"
        }
      ]
    },
    "lifecycle-block": {
      "begin": "\\b(lifecycle)\\b\\s*(\\{)",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.wrn"
        },
        "2": {
          "name": "punctuation.definition.block.begin.wrn"
        }
      },
      "end": "\\}",
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.block.end.wrn"
        }
      },
      "patterns": [
        {
          "include": "#comments"
        },
        {
          "begin": "\\b(mount|update|unmount)\\b\\s*(\\{)",
          "beginCaptures": {
            "1": {
              "name": "entity.name.function.lifecycle.wrn keyword.control.wrn"
            },
            "2": {
              "name": "punctuation.definition.block.begin.wrn"
            }
          },
          "end": "\\}",
          "endCaptures": {
            "0": {
              "name": "punctuation.definition.block.end.wrn"
            }
          },
          "contentName": "meta.embedded.block.ts",
          "patterns": [
            {
              "include": "#ts-braces"
            },
            {
              "include": "source.ts"
            }
          ]
        }
      ]
    },
    "watch-block": {
      "begin": "\\b(watch)\\b\\s+([A-Za-z_$][A-Za-z0-9_$]*)\\s*(\\{)",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.wrn"
        },
        "2": {
          "name": "variable.other.readwrite.wrn"
        },
        "3": {
          "name": "punctuation.definition.block.begin.wrn"
        }
      },
      "end": "\\}",
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.block.end.wrn"
        }
      },
      "contentName": "meta.embedded.block.ts",
      "patterns": [
        {
          "match": "\\b(value|previous)\\b",
          "name": "variable.language.wrn"
        },
        {
          "include": "#ts-braces"
        },
        {
          "include": "source.ts"
        }
      ]
    },
    "ts-braces": {
      "begin": "\\{",
      "end": "\\}",
      "contentName": "meta.embedded.block.ts",
      "patterns": [
        {
          "include": "#ts-braces"
        },
        {
          "include": "source.ts"
        }
      ]
    },
    "api-block": {
      "begin": "\\b(api)\\b\\s+(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\\b\\s*([^\\s{]*)\\s*(\\{)",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.wrn"
        },
        "2": {
          "name": "constant.language.http-method.wrn"
        },
        "3": {
          "name": "string.unquoted.route.wrn"
        },
        "4": {
          "name": "punctuation.definition.block.begin.wrn"
        }
      },
      "end": "\\}",
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.block.end.wrn"
        }
      },
      "contentName": "meta.embedded.block.ts",
      "patterns": [
        {
          "include": "#ts-braces"
        },
        {
          "include": "source.ts"
        }
      ]
    },
    "mode-block": {
      "begin": "\\b(ssr|client)\\b\\s*(\\{)",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.wrn"
        },
        "2": {
          "name": "punctuation.definition.block.begin.wrn"
        }
      },
      "end": "\\}",
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.block.end.wrn"
        }
      },
      "patterns": [
        {
          "include": "#comments"
        },
        {
          "begin": "\\b(api)\\b\\s+([A-Za-z_$][A-Za-z0-9_$]*)\\s+(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS)\\b\\s*([^\\s{]*)\\s*(\\{)",
          "beginCaptures": {
            "1": {
              "name": "keyword.control.wrn"
            },
            "2": {
              "name": "entity.name.function.wrn"
            },
            "3": {
              "name": "constant.language.http-method.wrn"
            },
            "4": {
              "name": "string.unquoted.route.wrn"
            },
            "5": {
              "name": "punctuation.definition.block.begin.wrn"
            }
          },
          "end": "\\}",
          "endCaptures": {
            "0": {
              "name": "punctuation.definition.block.end.wrn"
            }
          },
          "contentName": "meta.embedded.block.ts",
          "patterns": [
            {
              "include": "#ts-braces"
            },
            {
              "include": "source.ts"
            }
          ]
        },
        {
          "include": "#functions-block"
        }
      ]
    },
    "realtime-block": {
      "begin": "\\b(realtime)\\b\\s+([A-Za-z_$][A-Za-z0-9_$]*)\\s*(\\{)",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.wrn"
        },
        "2": {
          "name": "entity.name.function.wrn"
        },
        "3": {
          "name": "punctuation.definition.block.begin.wrn"
        }
      },
      "end": "\\}",
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.block.end.wrn"
        }
      },
      "patterns": [
        {
          "include": "#comments"
        },
        {
          "begin": "\\b(on)\\b\\s+([A-Za-z_$][A-Za-z0-9_$]*)\\s*(\\([^)]*\\))\\s*(\\{)",
          "beginCaptures": {
            "1": {
              "name": "keyword.control.wrn"
            },
            "2": {
              "name": "entity.name.function.event.wrn"
            },
            "3": {
              "name": "variable.parameter.wrn"
            },
            "4": {
              "name": "punctuation.definition.block.begin.wrn"
            }
          },
          "end": "\\}",
          "endCaptures": {
            "0": {
              "name": "punctuation.definition.block.end.wrn"
            }
          },
          "contentName": "meta.embedded.block.ts",
          "patterns": [
            {
              "include": "#ts-braces"
            },
            {
              "include": "source.ts"
            }
          ]
        }
      ]
    },
    "view-block": {
      "begin": "\\b(view)\\b\\s*(\\{)",
      "beginCaptures": {
        "1": {
          "name": "keyword.control.wrn"
        },
        "2": {
          "name": "punctuation.definition.block.begin.wrn"
        }
      },
      "end": "\\}",
      "endCaptures": {
        "0": {
          "name": "punctuation.definition.block.end.wrn"
        }
      },
      "contentName": "meta.embedded.block.html",
      "patterns": [
        {
          "include": "#interpolation"
        },
        {
          "include": "#wire-event"
        },
        {
          "include": "#conditional-class"
        },
        {
          "include": "text.html.basic"
        }
      ]
    },
    "wire-event": {
      "match": "(@)(?:(window|document)(:))?([A-Za-z][A-Za-z0-9_-]*)(\\s*=)",
      "captures": {
        "1": {
          "name": "punctuation.definition.keyword.wrn"
        },
        "2": {
          "name": "support.type.object.wrn"
        },
        "3": {
          "name": "punctuation.separator.key-value.wrn"
        },
        "4": {
          "name": "entity.other.attribute-name.event.wrn"
        },
        "5": {
          "name": "keyword.operator.assignment.wrn"
        }
      }
    },
    "conditional-class": {
      "match": "\\b(class)(:)([^\\s=]+)(\\s*=)",
      "captures": {
        "1": {
          "name": "entity.other.attribute-name.class.wrn"
        },
        "2": {
          "name": "punctuation.separator.key-value.wrn"
        },
        "3": {
          "name": "string.unquoted.class-name.wrn"
        },
        "4": {
          "name": "keyword.operator.assignment.wrn"
        }
      }
    },
    "interpolation": {
      "patterns": [
        {
          "name": "meta.interpolation.i18n.wrn",
          "match": "(\\{)(t:)([^}]*)(\\})",
          "captures": {
            "1": {
              "name": "punctuation.section.interpolation.begin.wrn"
            },
            "2": {
              "name": "keyword.control.i18n.wrn"
            },
            "3": {
              "name": "string.other.i18n-key.wrn"
            },
            "4": {
              "name": "punctuation.section.interpolation.end.wrn"
            }
          }
        },
        {
          "name": "meta.interpolation.wrn",
          "begin": "\\{",
          "end": "\\}",
          "beginCaptures": {
            "0": {
              "name": "punctuation.section.interpolation.begin.wrn"
            }
          },
          "endCaptures": {
            "0": {
              "name": "punctuation.section.interpolation.end.wrn"
            }
          },
          "contentName": "meta.embedded.expr.wrn",
          "patterns": [
            {
              "include": "#interp-braces"
            },
            {
              "include": "source.ts"
            }
          ]
        }
      ]
    },
    "interp-braces": {
      "begin": "\\{",
      "end": "\\}",
      "contentName": "meta.embedded.expr.wrn",
      "patterns": [
        {
          "include": "#interp-braces"
        },
        {
          "include": "source.ts"
        }
      ]
    },
    "strings": {
      "patterns": [
        {
          "name": "string.quoted.double.wrn",
          "begin": "\"",
          "end": "\"",
          "patterns": [
            {
              "name": "constant.character.escape.wrn",
              "match": "\\\\."
            }
          ]
        },
        {
          "name": "string.quoted.single.wrn",
          "begin": "'",
          "end": "'",
          "patterns": [
            {
              "name": "constant.character.escape.wrn",
              "match": "\\\\."
            }
          ]
        }
      ]
    }
  }
}
