Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@glimmer/compiler

Package Overview
Dependencies
Maintainers
15
Versions
292
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@glimmer/compiler - npm Package Compare versions

Comparing version 0.92.4 to 0.93.0

187

dist/dev/index.d.ts
import { Nullable, PresentArray, WireFormat, Dict, SerializedTemplateBlock, TemplateJavascript } from "@glimmer/interfaces";
import { PrecompileOptions, PrecompileOptionsWithLexicalScope, TemplateIdFn } from "@glimmer/syntax";
/// Builder ///
type BUILDER_LITERAL = 0;
declare const BUILDER_LITERAL: BUILDER_LITERAL;
type BUILDER_COMMENT = 1;
declare const BUILDER_COMMENT: BUILDER_COMMENT;
type BUILDER_APPEND = 2;
declare const BUILDER_APPEND: BUILDER_APPEND;
type BUILDER_MODIFIER = 3;
declare const BUILDER_MODIFIER: BUILDER_MODIFIER;
type BUILDER_DYNAMIC_COMPONENT = 4;
declare const BUILDER_DYNAMIC_COMPONENT: BUILDER_DYNAMIC_COMPONENT;
type BUILDER_GET = 5;
declare const BUILDER_GET: BUILDER_GET;
type BUILDER_CONCAT = 6;
declare const BUILDER_CONCAT: BUILDER_CONCAT;
type BUILDER_HAS_BLOCK = 7;
declare const BUILDER_HAS_BLOCK: BUILDER_HAS_BLOCK;
type BUILDER_HAS_BLOCK_PARAMS = 8;
declare const BUILDER_HAS_BLOCK_PARAMS: BUILDER_HAS_BLOCK_PARAMS;
/// HeadKind ///
type BLOCK_HEAD = "Block";
declare const BLOCK_HEAD: BLOCK_HEAD;
type CALL_HEAD = "Call";
declare const CALL_HEAD: CALL_HEAD;
type ELEMENT_HEAD = "Element";
declare const ELEMENT_HEAD: ELEMENT_HEAD;
type APPEND_PATH_HEAD = "AppendPath";
declare const APPEND_PATH_HEAD: APPEND_PATH_HEAD;
type APPEND_EXPR_HEAD = "AppendExpr";
declare const APPEND_EXPR_HEAD: APPEND_EXPR_HEAD;
type LITERAL_HEAD = "Literal";
declare const LITERAL_HEAD: LITERAL_HEAD;
type MODIFIER_HEAD = "Modifier";
declare const MODIFIER_HEAD: MODIFIER_HEAD;
type DYNAMIC_COMPONENT_HEAD = "DynamicComponent";
declare const DYNAMIC_COMPONENT_HEAD: DYNAMIC_COMPONENT_HEAD;
type COMMENT_HEAD = "Comment";
declare const COMMENT_HEAD: COMMENT_HEAD;
type SPLAT_HEAD = "Splat";
declare const SPLAT_HEAD: SPLAT_HEAD;
type KEYWORD_HEAD = "Keyword";
declare const KEYWORD_HEAD: KEYWORD_HEAD;
/// VariableKind ///
type LOCAL_VAR = "Local";
declare const LOCAL_VAR: LOCAL_VAR;
type FREE_VAR = "Free";
declare const FREE_VAR: FREE_VAR;
type ARG_VAR = "Arg";
declare const ARG_VAR: ARG_VAR;
type BLOCK_VAR = "Block";
declare const BLOCK_VAR: BLOCK_VAR;
type THIS_VAR = "This";
declare const THIS_VAR: THIS_VAR;
type VariableKind = LOCAL_VAR | FREE_VAR | ARG_VAR | BLOCK_VAR | THIS_VAR;
/// ExpressionKind ///
type LITERAL_EXPR = "Literal";
declare const LITERAL_EXPR: LITERAL_EXPR;
type CALL_EXPR = "Call";
declare const CALL_EXPR: CALL_EXPR;
type GET_PATH_EXPR = "GetPath";
declare const GET_PATH_EXPR: GET_PATH_EXPR;
type GET_VAR_EXPR = "GetVar";
declare const GET_VAR_EXPR: GET_VAR_EXPR;
type CONCAT_EXPR = "Concat";
declare const CONCAT_EXPR: CONCAT_EXPR;
type HAS_BLOCK_EXPR = "HasBlock";
declare const HAS_BLOCK_EXPR: HAS_BLOCK_EXPR;
type HAS_BLOCK_PARAMS_EXPR = "HasBlockParams";
declare const HAS_BLOCK_PARAMS_EXPR: HAS_BLOCK_PARAMS_EXPR;
type BuilderParams = BuilderExpression[];

@@ -15,23 +84,3 @@ type BuilderHash = Nullable<Dict<BuilderExpression>>;

type NormalizedAttrs = Dict<NormalizedAttr>;
type NormalizedAttr = HeadKind.Splat | NormalizedExpression;
declare enum HeadKind {
Block = "Block",
Call = "Call",
Element = "Element",
AppendPath = "AppendPath",
AppendExpr = "AppendExpr",
Literal = "Literal",
Modifier = "Modifier",
DynamicComponent = "DynamicComponent",
Comment = "Comment",
Splat = "Splat",
Keyword = "Keyword"
}
declare enum VariableKind {
Local = "Local",
Free = "Free",
Arg = "Arg",
Block = "Block",
This = "This"
}
type NormalizedAttr = SPLAT_HEAD | NormalizedExpression;
interface Variable {

@@ -54,3 +103,3 @@ kind: VariableKind;

interface AppendExpr {
kind: HeadKind.AppendExpr;
kind: APPEND_EXPR_HEAD;
expr: NormalizedExpression;

@@ -60,3 +109,3 @@ trusted: boolean;

interface AppendPath {
kind: HeadKind.AppendPath;
kind: APPEND_PATH_HEAD;
path: NormalizedPath;

@@ -66,3 +115,3 @@ trusted: boolean;

interface NormalizedKeywordStatement {
kind: HeadKind.Keyword;
kind: KEYWORD_HEAD;
name: string;

@@ -75,3 +124,3 @@ params: Nullable<NormalizedParams>;

type NormalizedStatement = {
kind: HeadKind.Call;
kind: CALL_HEAD;
head: NormalizedHead;

@@ -82,3 +131,3 @@ params: Nullable<NormalizedParams>;

} | {
kind: HeadKind.Block;
kind: BLOCK_HEAD;
head: NormalizedHead;

@@ -90,3 +139,3 @@ params: Nullable<NormalizedParams>;

} | NormalizedKeywordStatement | {
kind: HeadKind.Element;
kind: ELEMENT_HEAD;
name: string;

@@ -96,13 +145,13 @@ attrs: NormalizedAttrs;

} | {
kind: HeadKind.Comment;
kind: COMMENT_HEAD;
value: string;
} | {
kind: HeadKind.Literal;
kind: LITERAL_HEAD;
value: string;
} | AppendPath | AppendExpr | {
kind: HeadKind.Modifier;
kind: MODIFIER_HEAD;
params: NormalizedParams;
hash: Nullable<NormalizedHash>;
} | {
kind: HeadKind.DynamicComponent;
kind: DYNAMIC_COMPONENT_HEAD;
expr: NormalizedExpression;

@@ -140,35 +189,24 @@ hash: Nullable<NormalizedHash>;

type BuilderComment = [
Builder.Comment,
BUILDER_COMMENT,
string
];
declare enum Builder {
Literal = 0,
Comment = 1,
Append = 2,
Modifier = 3,
DynamicComponent = 4,
Get = 5,
Concat = 6,
HasBlock = 7,
HasBlockParams = 8
}
type VerboseStatement = [
Builder.Literal,
BUILDER_LITERAL,
string
] | [
Builder.Comment,
BUILDER_COMMENT,
string
] | [
Builder.Append,
BUILDER_APPEND,
BuilderExpression,
true
] | [
Builder.Append,
BUILDER_APPEND,
BuilderExpression
] | [
Builder.Modifier,
BUILDER_MODIFIER,
Params,
Hash
] | [
Builder.DynamicComponent,
BUILDER_DYNAMIC_COMPONENT,
BuilderExpression,

@@ -181,19 +219,19 @@ Hash,

type TupleBuilderExpression = [
Builder.Literal,
BUILDER_LITERAL,
string | boolean | null | undefined
] | [
Builder.Get,
BUILDER_GET,
string
] | [
Builder.Get,
BUILDER_GET,
string,
string[]
] | [
Builder.Concat,
BUILDER_CONCAT,
...BuilderExpression[]
] | [
Builder.HasBlock,
BUILDER_HAS_BLOCK,
string
] | [
Builder.HasBlockParams,
BUILDER_HAS_BLOCK_PARAMS,
string

@@ -203,13 +241,4 @@ ] | BuilderCallExpression;

type Hash = Dict<BuilderExpression>;
declare enum ExpressionKind {
Literal = "Literal",
Call = "Call",
GetPath = "GetPath",
GetVar = "GetVar",
Concat = "Concat",
HasBlock = "HasBlock",
HasBlockParams = "HasBlockParams"
}
interface NormalizedCallExpression {
type: ExpressionKind.Call;
type: CALL_EXPR;
head: NormalizedHead;

@@ -220,7 +249,7 @@ params: Nullable<NormalizedParams>;

interface NormalizedPath {
type: ExpressionKind.GetPath;
type: GET_PATH_EXPR;
path: Path;
}
interface NormalizedVar {
type: ExpressionKind.GetVar;
type: GET_VAR_EXPR;
variable: Variable;

@@ -230,3 +259,3 @@ }

interface NormalizedConcat {
type: ExpressionKind.Concat;
type: CONCAT_EXPR;
params: [

@@ -238,16 +267,16 @@ NormalizedExpression,

type NormalizedExpression = {
type: ExpressionKind.Literal;
type: LITERAL_EXPR;
value: null | undefined | boolean | string | number;
} | NormalizedCallExpression | NormalizedPath | NormalizedVar | NormalizedConcat | {
type: ExpressionKind.HasBlock;
type: HAS_BLOCK_EXPR;
name: string;
} | {
type: ExpressionKind.HasBlockParams;
type: HAS_BLOCK_PARAMS_EXPR;
name: string;
};
// | [Builder.Get, string]
// | [Builder.Get, string, string[]]
// | [Builder.Concat, Params]
// | [Builder.HasBlock, string]
// | [Builder.HasBlockParams, string]
// | [GET, string]
// | [GET, string, string[]]
// | [CONCAT, Params]
// | [HAS_BLOCK, string]
// | [HAS_BLOCK_PARAMS, string]
type BuilderExpression = TupleBuilderExpression | BuilderCallExpression | null | undefined | boolean | string | number;

@@ -309,3 +338,3 @@ type MiniBuilderBlock = BuilderStatement[];

declare function s(arr: TemplateStringsArray, ...interpolated: unknown[]): [
Builder.Literal,
BUILDER_LITERAL,
string

@@ -353,3 +382,3 @@ ];

private symbols;
constructor([_statements, symbols, _hasEval, upvars]: SerializedTemplateBlock);
constructor([_statements, symbols, upvars]: SerializedTemplateBlock);
format(program: SerializedTemplateBlock): unknown;

@@ -364,3 +393,3 @@ formatOpcode(opcode: WireFormat.Syntax): unknown;

}
export { buildStatement, buildStatements, c, NEWLINE, ProgramSymbols, s, unicode, Builder, BuilderStatement, defaultId, precompile, precompileJSON, PrecompileOptions, WireFormatDebugger };
export { buildStatement, buildStatements, c, NEWLINE, ProgramSymbols, s, unicode, BuilderStatement, defaultId, precompile, precompileJSON, PrecompileOptions, WireFormatDebugger };
//# sourceMappingURL=index.d.ts.map
import { Nullable, PresentArray, WireFormat, Dict, SerializedTemplateBlock, TemplateJavascript } from "@glimmer/interfaces";
import { PrecompileOptions, PrecompileOptionsWithLexicalScope, TemplateIdFn } from "@glimmer/syntax";
/// Builder ///
type BUILDER_LITERAL = 0;
declare const BUILDER_LITERAL: BUILDER_LITERAL;
type BUILDER_COMMENT = 1;
declare const BUILDER_COMMENT: BUILDER_COMMENT;
type BUILDER_APPEND = 2;
declare const BUILDER_APPEND: BUILDER_APPEND;
type BUILDER_MODIFIER = 3;
declare const BUILDER_MODIFIER: BUILDER_MODIFIER;
type BUILDER_DYNAMIC_COMPONENT = 4;
declare const BUILDER_DYNAMIC_COMPONENT: BUILDER_DYNAMIC_COMPONENT;
type BUILDER_GET = 5;
declare const BUILDER_GET: BUILDER_GET;
type BUILDER_CONCAT = 6;
declare const BUILDER_CONCAT: BUILDER_CONCAT;
type BUILDER_HAS_BLOCK = 7;
declare const BUILDER_HAS_BLOCK: BUILDER_HAS_BLOCK;
type BUILDER_HAS_BLOCK_PARAMS = 8;
declare const BUILDER_HAS_BLOCK_PARAMS: BUILDER_HAS_BLOCK_PARAMS;
/// HeadKind ///
type BLOCK_HEAD = "Block";
declare const BLOCK_HEAD: BLOCK_HEAD;
type CALL_HEAD = "Call";
declare const CALL_HEAD: CALL_HEAD;
type ELEMENT_HEAD = "Element";
declare const ELEMENT_HEAD: ELEMENT_HEAD;
type APPEND_PATH_HEAD = "AppendPath";
declare const APPEND_PATH_HEAD: APPEND_PATH_HEAD;
type APPEND_EXPR_HEAD = "AppendExpr";
declare const APPEND_EXPR_HEAD: APPEND_EXPR_HEAD;
type LITERAL_HEAD = "Literal";
declare const LITERAL_HEAD: LITERAL_HEAD;
type MODIFIER_HEAD = "Modifier";
declare const MODIFIER_HEAD: MODIFIER_HEAD;
type DYNAMIC_COMPONENT_HEAD = "DynamicComponent";
declare const DYNAMIC_COMPONENT_HEAD: DYNAMIC_COMPONENT_HEAD;
type COMMENT_HEAD = "Comment";
declare const COMMENT_HEAD: COMMENT_HEAD;
type SPLAT_HEAD = "Splat";
declare const SPLAT_HEAD: SPLAT_HEAD;
type KEYWORD_HEAD = "Keyword";
declare const KEYWORD_HEAD: KEYWORD_HEAD;
/// VariableKind ///
type LOCAL_VAR = "Local";
declare const LOCAL_VAR: LOCAL_VAR;
type FREE_VAR = "Free";
declare const FREE_VAR: FREE_VAR;
type ARG_VAR = "Arg";
declare const ARG_VAR: ARG_VAR;
type BLOCK_VAR = "Block";
declare const BLOCK_VAR: BLOCK_VAR;
type THIS_VAR = "This";
declare const THIS_VAR: THIS_VAR;
type VariableKind = LOCAL_VAR | FREE_VAR | ARG_VAR | BLOCK_VAR | THIS_VAR;
/// ExpressionKind ///
type LITERAL_EXPR = "Literal";
declare const LITERAL_EXPR: LITERAL_EXPR;
type CALL_EXPR = "Call";
declare const CALL_EXPR: CALL_EXPR;
type GET_PATH_EXPR = "GetPath";
declare const GET_PATH_EXPR: GET_PATH_EXPR;
type GET_VAR_EXPR = "GetVar";
declare const GET_VAR_EXPR: GET_VAR_EXPR;
type CONCAT_EXPR = "Concat";
declare const CONCAT_EXPR: CONCAT_EXPR;
type HAS_BLOCK_EXPR = "HasBlock";
declare const HAS_BLOCK_EXPR: HAS_BLOCK_EXPR;
type HAS_BLOCK_PARAMS_EXPR = "HasBlockParams";
declare const HAS_BLOCK_PARAMS_EXPR: HAS_BLOCK_PARAMS_EXPR;
type BuilderParams = BuilderExpression[];

@@ -15,23 +84,3 @@ type BuilderHash = Nullable<Dict<BuilderExpression>>;

type NormalizedAttrs = Dict<NormalizedAttr>;
type NormalizedAttr = HeadKind.Splat | NormalizedExpression;
declare enum HeadKind {
Block = "Block",
Call = "Call",
Element = "Element",
AppendPath = "AppendPath",
AppendExpr = "AppendExpr",
Literal = "Literal",
Modifier = "Modifier",
DynamicComponent = "DynamicComponent",
Comment = "Comment",
Splat = "Splat",
Keyword = "Keyword"
}
declare enum VariableKind {
Local = "Local",
Free = "Free",
Arg = "Arg",
Block = "Block",
This = "This"
}
type NormalizedAttr = SPLAT_HEAD | NormalizedExpression;
interface Variable {

@@ -54,3 +103,3 @@ kind: VariableKind;

interface AppendExpr {
kind: HeadKind.AppendExpr;
kind: APPEND_EXPR_HEAD;
expr: NormalizedExpression;

@@ -60,3 +109,3 @@ trusted: boolean;

interface AppendPath {
kind: HeadKind.AppendPath;
kind: APPEND_PATH_HEAD;
path: NormalizedPath;

@@ -66,3 +115,3 @@ trusted: boolean;

interface NormalizedKeywordStatement {
kind: HeadKind.Keyword;
kind: KEYWORD_HEAD;
name: string;

@@ -75,3 +124,3 @@ params: Nullable<NormalizedParams>;

type NormalizedStatement = {
kind: HeadKind.Call;
kind: CALL_HEAD;
head: NormalizedHead;

@@ -82,3 +131,3 @@ params: Nullable<NormalizedParams>;

} | {
kind: HeadKind.Block;
kind: BLOCK_HEAD;
head: NormalizedHead;

@@ -90,3 +139,3 @@ params: Nullable<NormalizedParams>;

} | NormalizedKeywordStatement | {
kind: HeadKind.Element;
kind: ELEMENT_HEAD;
name: string;

@@ -96,13 +145,13 @@ attrs: NormalizedAttrs;

} | {
kind: HeadKind.Comment;
kind: COMMENT_HEAD;
value: string;
} | {
kind: HeadKind.Literal;
kind: LITERAL_HEAD;
value: string;
} | AppendPath | AppendExpr | {
kind: HeadKind.Modifier;
kind: MODIFIER_HEAD;
params: NormalizedParams;
hash: Nullable<NormalizedHash>;
} | {
kind: HeadKind.DynamicComponent;
kind: DYNAMIC_COMPONENT_HEAD;
expr: NormalizedExpression;

@@ -140,35 +189,24 @@ hash: Nullable<NormalizedHash>;

type BuilderComment = [
Builder.Comment,
BUILDER_COMMENT,
string
];
declare enum Builder {
Literal = 0,
Comment = 1,
Append = 2,
Modifier = 3,
DynamicComponent = 4,
Get = 5,
Concat = 6,
HasBlock = 7,
HasBlockParams = 8
}
type VerboseStatement = [
Builder.Literal,
BUILDER_LITERAL,
string
] | [
Builder.Comment,
BUILDER_COMMENT,
string
] | [
Builder.Append,
BUILDER_APPEND,
BuilderExpression,
true
] | [
Builder.Append,
BUILDER_APPEND,
BuilderExpression
] | [
Builder.Modifier,
BUILDER_MODIFIER,
Params,
Hash
] | [
Builder.DynamicComponent,
BUILDER_DYNAMIC_COMPONENT,
BuilderExpression,

@@ -181,19 +219,19 @@ Hash,

type TupleBuilderExpression = [
Builder.Literal,
BUILDER_LITERAL,
string | boolean | null | undefined
] | [
Builder.Get,
BUILDER_GET,
string
] | [
Builder.Get,
BUILDER_GET,
string,
string[]
] | [
Builder.Concat,
BUILDER_CONCAT,
...BuilderExpression[]
] | [
Builder.HasBlock,
BUILDER_HAS_BLOCK,
string
] | [
Builder.HasBlockParams,
BUILDER_HAS_BLOCK_PARAMS,
string

@@ -203,13 +241,4 @@ ] | BuilderCallExpression;

type Hash = Dict<BuilderExpression>;
declare enum ExpressionKind {
Literal = "Literal",
Call = "Call",
GetPath = "GetPath",
GetVar = "GetVar",
Concat = "Concat",
HasBlock = "HasBlock",
HasBlockParams = "HasBlockParams"
}
interface NormalizedCallExpression {
type: ExpressionKind.Call;
type: CALL_EXPR;
head: NormalizedHead;

@@ -220,7 +249,7 @@ params: Nullable<NormalizedParams>;

interface NormalizedPath {
type: ExpressionKind.GetPath;
type: GET_PATH_EXPR;
path: Path;
}
interface NormalizedVar {
type: ExpressionKind.GetVar;
type: GET_VAR_EXPR;
variable: Variable;

@@ -230,3 +259,3 @@ }

interface NormalizedConcat {
type: ExpressionKind.Concat;
type: CONCAT_EXPR;
params: [

@@ -238,16 +267,16 @@ NormalizedExpression,

type NormalizedExpression = {
type: ExpressionKind.Literal;
type: LITERAL_EXPR;
value: null | undefined | boolean | string | number;
} | NormalizedCallExpression | NormalizedPath | NormalizedVar | NormalizedConcat | {
type: ExpressionKind.HasBlock;
type: HAS_BLOCK_EXPR;
name: string;
} | {
type: ExpressionKind.HasBlockParams;
type: HAS_BLOCK_PARAMS_EXPR;
name: string;
};
// | [Builder.Get, string]
// | [Builder.Get, string, string[]]
// | [Builder.Concat, Params]
// | [Builder.HasBlock, string]
// | [Builder.HasBlockParams, string]
// | [GET, string]
// | [GET, string, string[]]
// | [CONCAT, Params]
// | [HAS_BLOCK, string]
// | [HAS_BLOCK_PARAMS, string]
type BuilderExpression = TupleBuilderExpression | BuilderCallExpression | null | undefined | boolean | string | number;

@@ -309,3 +338,3 @@ type MiniBuilderBlock = BuilderStatement[];

declare function s(arr: TemplateStringsArray, ...interpolated: unknown[]): [
Builder.Literal,
BUILDER_LITERAL,
string

@@ -353,3 +382,3 @@ ];

private symbols;
constructor([_statements, symbols, _hasEval, upvars]: SerializedTemplateBlock);
constructor([_statements, symbols, upvars]: SerializedTemplateBlock);
format(program: SerializedTemplateBlock): unknown;

@@ -364,3 +393,3 @@ formatOpcode(opcode: WireFormat.Syntax): unknown;

}
export { buildStatement, buildStatements, c, NEWLINE, ProgramSymbols, s, unicode, Builder, BuilderStatement, defaultId, precompile, precompileJSON, PrecompileOptions, WireFormatDebugger };
export { buildStatement, buildStatements, c, NEWLINE, ProgramSymbols, s, unicode, BuilderStatement, defaultId, precompile, precompileJSON, PrecompileOptions, WireFormatDebugger };
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,2 @@

import{assertNever as e,dict as t,expect as r,isPresentArray as n,values as s,assert as a,NS_XMLNS as l,NS_XML as o,NS_XLINK as i,exhausted as c,mapPresentArray as u,getLast as p,assertPresentArray as m}from"@glimmer/util";import{VariableResolutionContext as d,SexpOpcodes as h,WellKnownTagNames as f,WellKnownAttrNames as k}from"@glimmer/wire-format";import{node as y,KEYWORDS_TYPES as g,ASTv2 as A,isKeyword as v,generateSyntaxError as w,SourceSlice as x,src as b,maybeLoc as E,loc as C,normalize as B}from"@glimmer/syntax";import{CurriedTypes as S}from"@glimmer/vm";let O=function(e){return e.Block="Block",e.Call="Call",e.Element="Element",e.AppendPath="AppendPath",e.AppendExpr="AppendExpr",e.Literal="Literal",e.Modifier="Modifier",e.DynamicComponent="DynamicComponent",e.Comment="Comment",e.Splat="Splat",e.Keyword="Keyword",e}({}),H=function(e){return e.Local="Local",e.Free="Free",e.Arg="Arg",e.Block="Block",e.This="This",e}({});function P(n){if(Array.isArray(n))return function(e){if(!Array.isArray(e))return!1;const t=e[0];if("number"==typeof t)switch(t){case j.Literal:case j.Get:case j.Concat:case j.HasBlock:case j.HasBlockParams:return!0;default:return!1}return"("===t[0]}(n)?U(n):function(e){if(Array.isArray(e)&&"string"==typeof e[0])switch(e[0][0]){case"(":case"#":case"<":case"!":return!0;default:return!1}return!1}(n)?function(e){const n=e[0];switch(n[0]){case"(":{let t=null,r=null;return 3===e.length?(t=Y(e[1]),r=J(e[2])):2===e.length&&(Array.isArray(e[1])?t=Y(e[1]):r=J(e[1])),{kind:O.Call,head:L(n),params:t,hash:r,trusted:!1}}case"#":{const{head:t,params:r,hash:n,blocks:s,blockParams:a}=M(e);return{kind:O.Block,head:t,params:r,hash:n,blocks:s,blockParams:a}}case"!":{const t=e[0].slice(1),{params:r,hash:n,blocks:s,blockParams:a}=M(e);return{kind:O.Keyword,name:t,params:r,hash:n,blocks:s,blockParams:a}}case"<":{let s=t(),a=[];return 3===e.length?(s=_(e[1]),a=F(e[2])):2===e.length&&(Array.isArray(e[1])?a=F(e[1]):s=_(e[1])),{kind:O.Element,name:r(K(n),`BUG: expected ${n} to look like a tag name`),attrs:s,block:a}}default:throw new Error(`Unreachable ${JSON.stringify(e)} in normalizeSugaryArrayStatement`)}}(n):function(e){switch(e[0]){case j.Literal:return{kind:O.Literal,value:e[1]};case j.Append:return U(e[1],e[2]);case j.Modifier:return{kind:O.Modifier,params:Y(e[1]),hash:J(e[2])};case j.DynamicComponent:return{kind:O.DynamicComponent,expr:W(e[1]),hash:J(e[2]),block:F(e[3])};case j.Comment:return{kind:O.Comment,value:e[1]}}}(n);if("string"==typeof n)return T($(n),!1);throw e(n)}function T(e,t){return e.type===z.GetPath?{kind:O.AppendPath,path:e,trusted:t}:{kind:O.AppendExpr,expr:e,trusted:t}}function N(e){const t=/^(#|!)(.*)$/u.exec(e);if(null===t)throw new Error("Unexpected missing # in block head");return $(t[2])}function L(e){const t=/^\((.*)\)$/u.exec(e);if(null===t)throw new Error("Unexpected missing () in call head");return $(t[1])}function I(e,t=[]){const r=G(e);return n(t)?{type:z.GetPath,path:{head:r,tail:t}}:{type:z.GetVar,variable:r}}function $(e){const{kind:t,name:r}=G(e),[s,...a]=r.split("."),l={kind:t,name:s,mode:"loose"};return n(a)?{type:z.GetPath,path:{head:l,tail:a}}:{type:z.GetVar,variable:l}}function G(e){let t,r;if(/^this(?:\.|$)/u.test(e))return{kind:H.This,name:e,mode:"loose"};switch(e[0]){case"^":t=H.Free,r=e.slice(1);break;case"@":t=H.Arg,r=e.slice(1);break;case"&":t=H.Block,r=e.slice(1);break;default:t=H.Local,r=e}return{kind:t,name:r,mode:"loose"}}function M(e){const r=e[0];let n=t(),s=null,a=null,l=null;return 2===e.length?n=V(e[1]):3===e.length?(Array.isArray(e[1])?s=Y(e[1]):({hash:a,blockParams:l}=D(e[1])),n=V(e[2])):4===e.length&&(s=Y(e[1]),({hash:a,blockParams:l}=D(e[2])),n=V(e[3])),{head:N(r),params:s,hash:a,blockParams:l,blocks:n}}function D(e){if(null===e)return{hash:null,blockParams:null};let r=null,n=null;return function(e,t){Object.keys(e).forEach((r=>{const n=e[r];t(r,n)}))}(e,((e,s)=>{"as"===e?n=Array.isArray(s)?s:[s]:(r=r||t(),r[e]=W(s))})),{hash:r,blockParams:n}}function V(e){return Array.isArray(e)?{default:F(e)}:q(e,F)}function F(e){return e.map((e=>P(e)))}function _(e){return q(e,(e=>{return(t=e,"splat"===t?{expr:O.Splat,trusted:!1}:{expr:W(t),trusted:!1}).expr;var t}))}function q(e,r){const n=t();return Object.keys(e).forEach((t=>{n[t]=r(e[t],t)})),n}function K(e){const t=/^<([\d\-a-z][\d\-A-Za-z]*)>$/u.exec(e);return t?.[1]??null}let j=function(e){return e[e.Literal=0]="Literal",e[e.Comment=1]="Comment",e[e.Append=2]="Append",e[e.Modifier=3]="Modifier",e[e.DynamicComponent=4]="DynamicComponent",e[e.Get=5]="Get",e[e.Concat=6]="Concat",e[e.HasBlock=7]="HasBlock",e[e.HasBlockParams=8]="HasBlockParams",e}({}),z=function(e){return e.Literal="Literal",e.Call="Call",e.GetPath="GetPath",e.GetVar="GetVar",e.Concat="Concat",e.HasBlock="HasBlock",e.HasBlockParams="HasBlockParams",e}({});function U(t,r=!1){if(null==t)return{expr:{type:z.Literal,value:t},kind:O.AppendExpr,trusted:!1};if(Array.isArray(t))switch(t[0]){case j.Literal:return{expr:{type:z.Literal,value:t[1]},kind:O.AppendExpr,trusted:!1};case j.Get:return T(I(t[1],t[2]),r);case j.Concat:return{expr:{type:z.Concat,params:Y(t.slice(1))},kind:O.AppendExpr,trusted:r};case j.HasBlock:return{expr:{type:z.HasBlock,name:t[1]},kind:O.AppendExpr,trusted:r};case j.HasBlockParams:return{expr:{type:z.HasBlockParams,name:t[1]},kind:O.AppendExpr,trusted:r};default:if(R(t))return{expr:X(t),kind:O.AppendExpr,trusted:r};throw new Error(`Unexpected array in expression position (wasn't a tuple expression and ${t[0]} isn't wrapped in parens, so it isn't a call): ${JSON.stringify(t)}`)}else{if("object"==typeof t)throw e(t);switch(typeof t){case"string":return T($(t),r);case"boolean":case"number":return{expr:{type:z.Literal,value:t},kind:O.AppendExpr,trusted:!0};default:throw e(t)}}}function W(t){if(null==t)return{type:z.Literal,value:t};if(Array.isArray(t))switch(t[0]){case j.Literal:return{type:z.Literal,value:t[1]};case j.Get:return I(t[1],t[2]);case j.Concat:return{type:z.Concat,params:Y(t.slice(1))};case j.HasBlock:return{type:z.HasBlock,name:t[1]};case j.HasBlockParams:return{type:z.HasBlockParams,name:t[1]};default:if(R(t))return X(t);throw new Error(`Unexpected array in expression position (wasn't a tuple expression and ${t[0]} isn't wrapped in parens, so it isn't a call): ${JSON.stringify(t)}`)}else{if("object"==typeof t)throw e(t);switch(typeof t){case"string":return $(t);case"boolean":case"number":return{type:z.Literal,value:t};default:throw e(t)}}}function R(e){return"string"==typeof e[0]&&"("===e[0][0]}function Y(e){return e.map(W)}function J(e){return null===e?null:q(e,W)}function X(e){switch(e.length){case 1:return{type:z.Call,head:L(e[0]),params:null,hash:null};case 2:return Array.isArray(e[1])?{type:z.Call,head:L(e[0]),params:Y(e[1]),hash:null}:{type:z.Call,head:L(e[0]),params:null,hash:J(e[1])};case 3:return{type:z.Call,head:L(e[0]),params:Y(e[1]),hash:J(e[2])}}}class Z{_freeVariables=[];_symbols=["this"];top=this;toSymbols(){return this._symbols.slice(1)}toUpvars(){return this._freeVariables}freeVar(e){return ee(this._freeVariables,e)}block(e){return this.symbol(e)}arg(e){return ee(this._symbols,e)}local(e){throw new Error(`No local ${e} was found. Maybe you meant ^${e} for upvar, or !${e} for keyword?`)}this(){return 0}hasLocal(e){return!1}symbol(e){return ee(this._symbols,e)}child(e){return new Q(this,e)}}class Q{locals=t();constructor(e,t){this.parent=e;for(let r of t)this.locals[r]=e.top.symbol(r)}get paramSymbols(){return s(this.locals)}get top(){return this.parent.top}freeVar(e){return this.parent.freeVar(e)}arg(e){return this.parent.arg(e)}block(e){return this.parent.block(e)}local(e){return e in this.locals?this.locals[e]:this.parent.local(e)}this(){return this.parent.this()}hasLocal(e){return e in this.locals||this.parent.hasLocal(e)}child(e){return new Q(this,e)}}function ee(e,t){let r=e.indexOf(t);return-1===r?(r=e.length,e.push(t),r):r}function te(e){return new Error(`unimplemented ${e}`)}function re(e,t){let r=[];return e.forEach((e=>r.push(...se(P(e),t)))),r}function ne(e,t){let r=[];return e.forEach((e=>r.push(...se(e,t)))),r}function se(t,r=new Z){switch(t.kind){case O.AppendPath:return[[t.trusted?h.TrustingAppend:h.Append,ke(t.path,r)]];case O.AppendExpr:return[[t.trusted?h.TrustingAppend:h.Append,he(t.expr,t.trusted?"TrustedAppend":"Append",r)]];case O.Call:{let{head:e,params:n,hash:s,trusted:a}=t,l=n?ge(n,r):null,o=s?ve(s,r):null,i=fe(e,a?d.ResolveAsHelperHead:d.ResolveAsComponentOrHelperHead,r);return[[a?h.TrustingAppend:h.Append,[h.Call,i,l,o]]]}case O.Literal:return[[h.Append,t.value]];case O.Comment:return[[h.Comment,t.value]];case O.Block:{let e=function(e,t,r){let n=[],s=[];for(const[a,l]of Object.entries(e))if(n.push(a),"default"===a){let e=r.child(t||[]);s.push(we(l,e,e.paramSymbols))}else s.push(we(l,r,[]));return[n,s]}(t.blocks,t.blockParams,r),n=ve(t.hash,r),s=ge(t.params,r),a=fe(t.head,d.ResolveAsComponentHead,r);return[[h.Block,a,s,n,e]]}case O.Keyword:return[ce(t,r)];case O.Element:return function({name:t,attrs:r,block:s},l){let o=[ue(r)?[h.OpenElementWithSplat,t]:[h.OpenElement,t]];if(r){let{params:e,args:t}=function(e,t){let r=[],s=[],a=[];for(const[n,l]of Object.entries(e))l===O.Splat?r.push([h.AttrSplat,t.block("&attrs")]):"@"===n[0]?(s.push(n),a.push(he(l,"Strict",t))):r.push(...me(n,l,pe(n),t));return{params:r,args:n(s)&&n(a)?[s,a]:null}}(r,l);o.push(...e),a(null===t,"Can't pass args to a simple element")}if(o.push([h.FlushElement]),Array.isArray(s))s.forEach((e=>o.push(...se(e,l))));else if(null!==s)throw e(s);return o.push([h.CloseElement]),o}(t,r);case O.Modifier:throw te("modifier");case O.DynamicComponent:throw te("dynamic component");default:throw e(t)}}function ae(e,...t){let r=e.reduce(((e,r,n)=>e+`${r}${t[n]?String(t[n]):""}`),"");return[j.Literal,r]}function le(e,...t){let r=e.reduce(((e,r,n)=>e+`${r}${t[n]?String(t[n]):""}`),"");return[j.Comment,r]}function oe(e){return String.fromCharCode(parseInt(e,16))}const ie="\n";function ce(e,t){let{name:n}=e,s=ge(e.params,t),a=t.child(e.blockParams||[]),l=we(e.blocks.default,a,a.paramSymbols),o=e.blocks.else?we(e.blocks.else,t,[]):null;switch(n){case"let":return[h.Let,r(s,"let requires params"),l];case"if":return[h.If,r(s,"if requires params")[0],l,o];case"each":{let n=e.hash?e.hash.key:null,a=n?he(n,"Strict",t):null;return[h.Each,r(s,"if requires params")[0],a,l,o]}default:throw new Error("unimplemented keyword")}}function ue(e){return null!==e&&Object.keys(e).some((t=>e[t]===O.Splat))}function pe(e){if("xmlns"===e)return l;let t=/^([^:]*):([^:]*)$/u.exec(e);if(null===t)return null;switch(t[1]){case"xlink":return i;case"xml":return o;case"xmlns":return l}return null}function me(e,t,r,n){if(t.type===z.Literal){let n=t.value;if(!1===n)return[];if(!0===n)return[[h.StaticAttr,e,"",r??void 0]];if("string"==typeof n)return[[h.StaticAttr,e,n,r??void 0]];throw new Error(`Unexpected/unimplemented literal attribute ${JSON.stringify(n)}`)}return[[h.DynamicAttr,e,he(t,"AttrValue",n),r??void 0]]}function de(e,t){switch(e){case"Append":return t?"AppendBare":"AppendInvoke";case"TrustedAppend":return t?"TrustedAppendBare":"TrustedAppendInvoke";case"AttrValue":return t?"AttrValueBare":"AttrValueInvoke";default:return e}}function he(t,r,n){switch(t.type){case z.GetPath:return ke(t,n);case z.GetVar:return ye(t.variable,de(r,!0),n);case z.Concat:return[h.Concat,Ae(t.params,n)];case z.Call:{let e=ge(t.params,n),s=ve(t.hash,n),a=fe(t.head,"Strict"===r?"SubExpression":de(r,!1),n);return[h.Call,a,e,s]}case z.HasBlock:return[h.HasBlock,ye({kind:H.Block,name:t.name,mode:"loose"},d.Strict,n)];case z.HasBlockParams:return[h.HasBlockParams,ye({kind:H.Block,name:t.name,mode:"loose"},d.Strict,n)];case z.Literal:return void 0===t.value?[h.Undefined]:t.value;default:e(t)}}function fe(e,t,r){return e.type===z.GetVar?ye(e.variable,t,r):ke(e,r)}function ke(e,t){return ye(e.path.head,d.Strict,t,e.path.tail)}function ye(e,t,r,n){let s,l=h.GetSymbol;return e.kind===H.Free?(l="Strict"===t?h.GetStrictKeyword:"AppendBare"===t||"AppendInvoke"===t?h.GetFreeAsComponentOrHelperHead:"TrustedAppendBare"===t||"TrustedAppendInvoke"===t||"AttrValueBare"===t||"AttrValueInvoke"===t||"SubExpression"===t?h.GetFreeAsHelperHead:function(e){switch(e){case d.Strict:return h.GetStrictKeyword;case d.ResolveAsComponentOrHelperHead:return h.GetFreeAsComponentOrHelperHead;case d.ResolveAsHelperHead:return h.GetFreeAsHelperHead;case d.ResolveAsModifierHead:return h.GetFreeAsModifierHead;case d.ResolveAsComponentHead:return h.GetFreeAsComponentHead;default:return c(e)}}(t),s=r.freeVar(e.name)):(l=h.GetSymbol,s=function(e,t,r){switch(e){case H.Arg:return t.arg(r);case H.Block:return t.block(r);case H.Local:return t.local(r);case H.This:return t.this();default:return c(e)}}(e.kind,r,e.name)),void 0===n||0===n.length?[l,s]:(a(l!==h.GetStrictKeyword,"[BUG] keyword with a path"),[l,s,n])}function ge(e,t){return null!==e&&n(e)?e.map((e=>he(e,"Strict",t))):null}function Ae(e,t){return e.map((e=>he(e,"AttrValue",t)))}function ve(e,t){if(null===e)return null;let r=[[],[]];for(const[n,s]of Object.entries(e))r[0].push(n),r[1].push(he(s,"Strict",t));return r}function we(e,t,r=[]){return[ne(e,t),r]}class xe extends(y("Template").fields()){}class be extends(y("InElement").fields()){}class Ee extends(y("Not").fields()){}class Ce extends(y("If").fields()){}class Be extends(y("IfInline").fields()){}class Se extends(y("Each").fields()){}class Oe extends(y("Let").fields()){}class He extends(y("WithDynamicVars").fields()){}class Pe extends(y("GetDynamicVar").fields()){}class Te extends(y("Log").fields()){}class Ne extends(y("InvokeComponent").fields()){}class Le extends(y("NamedBlocks").fields()){}class Ie extends(y("NamedBlock").fields()){}class $e extends(y("AppendTrustedHTML").fields()){}class Ge extends(y("AppendTextNode").fields()){}class Me extends(y("AppendComment").fields()){}class De extends(y("Component").fields()){}class Ve extends(y("StaticAttr").fields()){}class Fe extends(y("DynamicAttr").fields()){}class _e extends(y("SimpleElement").fields()){}class qe extends(y("ElementParameters").fields()){}class Ke extends(y("Yield").fields()){}class je extends(y("Debugger").fields()){}class ze extends(y("CallExpression").fields()){}class Ue extends(y("Modifier").fields()){}class We extends(y("InvokeBlock").fields()){}class Re extends(y("SplatAttr").fields()){}class Ye extends(y("PathExpression").fields()){}class Je extends(y("Missing").fields()){}class Xe extends(y("InterpolateExpression").fields()){}class Ze extends(y("HasBlock").fields()){}class Qe extends(y("HasBlockParams").fields()){}class et extends(y("Curry").fields()){}class tt extends(y("Positional").fields()){}class rt extends(y("NamedArguments").fields()){}class nt extends(y("NamedArgument").fields()){}class st extends(y("Args").fields()){}class at extends(y("Tail").fields()){}class lt{constructor(e){this.list=e}toArray(){return this.list}map(e){let t=u(this.list,e);return new lt(t)}filter(e){let t=[];for(let r of this.list)e(r)&&t.push(r);return it(t)}toPresentArray(){return this.list}into({ifPresent:e}){return e(this)}}class ot{list=[];map(e){return new ot}filter(e){return new ot}toArray(){return this.list}toPresentArray(){return null}into({ifEmpty:e}){return e()}}function it(e){return n(e)?new lt(e):new ot}class ct{static all(...e){let t=[];for(let r of e){if(r.isErr)return r.cast();t.push(r.value)}return dt(t)}}const ut=ct;class pt extends ct{isOk=!0;isErr=!1;constructor(e){super(),this.value=e}expect(e){return this.value}ifOk(e){return e(this.value),this}andThen(e){return e(this.value)}mapOk(e){return dt(e(this.value))}ifErr(e){return this}mapErr(e){return this}}class mt extends ct{isOk=!1;isErr=!0;constructor(e){super(),this.reason=e}expect(e){throw new Error(e||"expected an Ok, got Err")}andThen(e){return this.cast()}mapOk(e){return this.cast()}ifOk(e){return this}mapErr(e){return ht(e(this.reason))}ifErr(e){return e(this.reason),this}cast(){return this}}function dt(e){return new pt(e)}function ht(e){return new mt(e)}class ft{constructor(e=[]){this.items=e}add(e){this.items.push(e)}toArray(){let e=this.items.filter((e=>e instanceof mt))[0];return void 0!==e?e.cast():dt(this.items.map((e=>e.value)))}toOptionalList(){return this.toArray().mapOk((e=>it(e)))}}function kt(e){return"Path"===e.type&&"Free"===e.ref.type&&e.ref.name in g?new A.CallExpression({callee:e,args:A.Args.empty(e.loc),loc:e.loc}):e}const yt=new class{visit(e,t){switch(e.type){case"Literal":return dt(this.Literal(e));case"Keyword":return dt(this.Keyword(e));case"Interpolate":return this.Interpolate(e,t);case"Path":return this.PathExpression(e);case"Call":{let r=Vt.translate(e,t);return null!==r?r:this.CallExpression(e,t)}}}visitList(e,t){return new ft(e.map((e=>yt.visit(e,t)))).toOptionalList()}PathExpression(e){let t=this.VariableReference(e.ref),{tail:r}=e;if(n(r)){let n=r[0].loc.extend(p(r).loc);return dt(new Ye({loc:e.loc,head:t,tail:new at({loc:n,members:r})}))}return dt(t)}VariableReference(e){return e}Literal(e){return e}Keyword(e){return e}Interpolate(e,t){let r=e.parts.map(kt);return yt.visitList(r,t).mapOk((t=>new Xe({loc:e.loc,parts:t})))}CallExpression(e,t){if("Call"===e.callee.type)throw new Error("unimplemented: subexpression at the head of a subexpression");return ut.all(yt.visit(e.callee,t),yt.Args(e.args,t)).mapOk((([t,r])=>new ze({loc:e.loc,callee:t,args:r})))}Args({positional:e,named:t,loc:r},n){return ut.all(this.Positional(e,n),this.NamedArguments(t,n)).mapOk((([e,t])=>new st({loc:r,positional:e,named:t})))}Positional(e,t){return yt.visitList(e.exprs,t).mapOk((t=>new tt({loc:e.loc,list:t})))}NamedArguments(e,t){let r=e.entries.map((e=>{let r=kt(e.value);return yt.visit(r,t).mapOk((t=>new nt({loc:e.loc,key:e.name,value:t})))}));return new ft(r).toOptionalList().mapOk((t=>new rt({loc:e.loc,entries:t})))}};class gt{types;constructor(e,t,r){this.keyword=e,this.delegate=r;let n=new Set;for(let e of At[t])n.add(e);this.types=n}match(e){if(!this.types.has(e.type))return!1;let t=vt(e);return null!==t&&"Path"===t.type&&"Free"===t.ref.type&&t.ref.name===this.keyword}translate(e,t){if(this.match(e)){let r=vt(e);return null!==r&&"Path"===r.type&&r.tail.length>0?ht(w(`The \`${this.keyword}\` keyword was used incorrectly. It was used as \`${r.loc.asString()}\`, but it cannot be used with additional path segments. \n\nError caused by`,e.loc)):this.delegate.assert(e,t).andThen((r=>this.delegate.translate({node:e,state:t},r)))}return null}}const At={Call:["Call"],Block:["InvokeBlock"],Append:["AppendContent"],Modifier:["ElementModifier"]};function vt(e){switch(e.type){case"Path":return e;case"AppendContent":return vt(e.value);case"Call":case"InvokeBlock":case"ElementModifier":return e.callee;default:return null}}class wt{_keywords=[];_type;constructor(e){this._type=e}kw(e,t){return this._keywords.push(function(e,t,r){return new gt(e,t,r)}(e,this._type,t)),this}translate(e,t){for(let r of this._keywords){let n=r.translate(e,t);if(null!==n)return n}let r=vt(e);if(r&&"Path"===r.type&&"Free"===r.ref.type&&v(r.ref.name)){let{name:t}=r.ref,n=this._type,s=g[t];if(!s.includes(n))return ht(w(`The \`${t}\` keyword was used incorrectly. It was used as ${xt[n]}, but its valid usages are:\n\n${function(e,t){return t.map((t=>{switch(t){case"Append":return`- As an append statement, as in: {{${e}}}`;case"Block":return`- As a block statement, as in: {{#${e}}}{{/${e}}}`;case"Call":return`- As an expression, as in: (${e})`;case"Modifier":return`- As a modifier, as in: <div {{${e}}}></div>`;default:return c(t)}})).join("\n\n")}(t,s)}\n\nError caused by`,e.loc))}return null}}const xt={Append:"an append statement",Block:"a block statement",Call:"a call expression",Modifier:"a modifier"};function bt(e){return new wt(e)}function Et({assert:e,translate:t}){return{assert:e,translate:({node:e,state:r},n)=>t({node:e,state:r},n).mapOk((t=>new Ge({text:t,loc:e.loc})))}}const Ct={[S.Component]:"component",[S.Helper]:"helper",[S.Modifier]:"modifier"};function Bt(e){return(t,r)=>{let n=Ct[e],s=e===S.Component,{args:a}=t,l=a.nth(0);if(null===l)return ht(w(`(${n}) requires a ${n} definition or identifier as its first positional parameter, did not receive any parameters.`,a.loc));if("Literal"===l.type){if(s&&r.isStrict)return ht(w(`(${n}) cannot resolve string values in strict mode templates`,t.loc));if(!s)return ht(w(`(${n}) cannot resolve string values, you must pass a ${n} definition directly`,t.loc))}return a=new A.Args({positional:new A.PositionalArguments({exprs:a.positional.exprs.slice(1),loc:a.positional.loc}),named:a.named,loc:a.loc}),dt({definition:l,args:a})}}function St(e){return({node:t,state:r},{definition:n,args:s})=>{let a=yt.visit(n,r),l=yt.Args(s,r);return ut.all(a,l).mapOk((([r,n])=>new et({loc:t.loc,curriedType:e,definition:r,args:n})))}}function Ot(e){return{assert:Bt(e),translate:St(e)}}const Ht={assert:function(e){let t="AppendContent"===e.type?e.value:e,r="Call"===t.type?t.args.named:null,n="Call"===t.type?t.args.positional:null;if(r&&!r.isEmpty())return ht(w("(-get-dynamic-vars) does not take any named arguments",e.loc));let s=n?.nth(0);return s?n&&n.size>1?ht(w("(-get-dynamic-vars) only receives one positional arg",e.loc)):dt(s):ht(w("(-get-dynamic-vars) requires a var name to get",e.loc))},translate:function({node:e,state:t},r){return yt.visit(r,t).mapOk((t=>new Pe({name:t,loc:e.loc})))}};function Pt(e){return t=>{let r="AppendContent"===t.type?t.value:t,n="Call"===r.type?r.args.named:null,s="Call"===r.type?r.args.positional:null;if(n&&!n.isEmpty())return ht(w(`(${e}) does not take any named arguments`,r.loc));if(!s||s.isEmpty())return dt(x.synthetic("default"));if(1===s.exprs.length){let t=s.exprs[0];return A.isLiteral(t,"string")?dt(t.toSlice()):ht(w(`(${e}) can only receive a string literal as its first argument`,r.loc))}return ht(w(`(${e}) only takes a single positional argument`,r.loc))}}function Tt(e){return({node:t,state:{scope:r}},n)=>dt("has-block"===e?new Ze({loc:t.loc,target:n,symbol:r.allocateBlock(n.chars)}):new Qe({loc:t.loc,target:n,symbol:r.allocateBlock(n.chars)}))}function Nt(e){return{assert:Pt(e),translate:Tt(e)}}function Lt(e){return t=>{let r="unless"===e,n="AppendContent"===t.type?t.value:t,s="Call"===n.type?n.args.named:null,a="Call"===n.type?n.args.positional:null;if(s&&!s.isEmpty())return ht(w(`(${e}) cannot receive named parameters, received ${s.entries.map((e=>e.name.chars)).join(", ")}`,t.loc));let l=a?.nth(0);if(!a||!l)return ht(w(`When used inline, (${e}) requires at least two parameters 1. the condition that determines the state of the (${e}), and 2. the value to return if the condition is ${r?"false":"true"}. Did not receive any parameters`,t.loc));let o=a.nth(1),i=a.nth(2);return null===o?ht(w(`When used inline, (${e}) requires at least two parameters 1. the condition that determines the state of the (${e}), and 2. the value to return if the condition is ${r?"false":"true"}. Received only one parameter, the condition`,t.loc)):a.size>3?ht(w(`When used inline, (${e}) can receive a maximum of three positional parameters 1. the condition that determines the state of the (${e}), 2. the value to return if the condition is ${r?"false":"true"}, and 3. the value to return if the condition is ${r?"true":"false"}. Received ${a?.size??0} parameters`,t.loc)):dt({condition:l,truthy:o,falsy:i})}}function It(e){let t="unless"===e;return({node:e,state:r},{condition:n,truthy:s,falsy:a})=>{let l=yt.visit(n,r),o=yt.visit(s,r),i=a?yt.visit(a,r):dt(null);return ut.all(l,o,i).mapOk((([r,n,s])=>(t&&(r=new Ee({value:r,loc:e.loc})),new Be({loc:e.loc,condition:r,truthy:n,falsy:s}))))}}function $t(e){return{assert:Lt(e),translate:It(e)}}const Gt={assert:function(e){let{args:{named:t,positional:r}}=e;return t&&!t.isEmpty()?ht(w("(log) does not take any named arguments",e.loc)):dt(r)},translate:function({node:e,state:t},r){return yt.Positional(r,t).mapOk((t=>new Te({positional:t,loc:e.loc})))}},Mt=bt("Append").kw("has-block",Et(Nt("has-block"))).kw("has-block-params",Et(Nt("has-block-params"))).kw("-get-dynamic-var",Et(Ht)).kw("log",Et(Gt)).kw("if",Et($t("if"))).kw("unless",Et($t("unless"))).kw("yield",{assert(e){let{args:t}=e;if(t.named.isEmpty())return dt({target:b.SourceSpan.synthetic("default").toSlice(),positional:t.positional});{let e=t.named.get("to");return t.named.size>1||null===e?ht(w("yield only takes a single named argument: 'to'",t.named.loc)):A.isLiteral(e,"string")?dt({target:e.toSlice(),positional:t.positional}):ht(w("you can only yield to a literal string value",e.loc))}},translate:({node:e,state:t},{target:r,positional:n})=>yt.Positional(n,t).mapOk((n=>new Ke({loc:e.loc,target:r,to:t.scope.allocateBlock(r.chars),positional:n})))}).kw("debugger",{assert(e){let{args:t}=e,{positional:r}=t;return t.isEmpty()?dt(void 0):r.isEmpty()?ht(w("debugger does not take any named arguments",e.loc)):ht(w("debugger does not take any positional arguments",e.loc))},translate:({node:e,state:{scope:t}})=>(t.setHasDebugger(),dt(new je({loc:e.loc,scope:t})))}).kw("component",{assert:Bt(S.Component),translate({node:e,state:t},{definition:r,args:n}){let s=yt.visit(r,t),a=yt.Args(n,t);return ut.all(s,a).mapOk((([t,r])=>new Ne({loc:e.loc,definition:t,args:r,blocks:null})))}}).kw("helper",{assert:Bt(S.Helper),translate({node:e,state:t},{definition:r,args:n}){let s=yt.visit(r,t),a=yt.Args(n,t);return ut.all(s,a).mapOk((([t,r])=>{let n=new ze({callee:t,args:r,loc:e.loc});return new Ge({loc:e.loc,text:n})}))}}),Dt=bt("Block").kw("in-element",{assert(e){let{args:t}=e,r=t.get("guid");if(r)return ht(w("Cannot pass `guid` to `{{#in-element}}`",r.loc));let n=t.get("insertBefore"),s=t.nth(0);return null===s?ht(w("{{#in-element}} requires a target element as its first positional parameter",t.loc)):dt({insertBefore:n,destination:s})},translate({node:e,state:t},{insertBefore:r,destination:n}){let s=e.blocks.get("default"),a=tr.NamedBlock(s,t),l=yt.visit(n,t);return ut.all(a,l).andThen((([n,s])=>r?yt.visit(r,t).mapOk((e=>({body:n,destination:s,insertBefore:e}))):dt({body:n,destination:s,insertBefore:new Je({loc:e.callee.loc.collapse("end")})}))).mapOk((({body:r,destination:n,insertBefore:s})=>new be({loc:e.loc,block:r,insertBefore:s,guid:t.generateUniqueCursor(),destination:n})))}}).kw("if",{assert(e){let{args:t}=e;if(!t.named.isEmpty())return ht(w(`{{#if}} cannot receive named parameters, received ${t.named.entries.map((e=>e.name.chars)).join(", ")}`,e.loc));if(t.positional.size>1)return ht(w(`{{#if}} can only receive one positional parameter in block form, the conditional value. Received ${t.positional.size} parameters`,e.loc));let r=t.nth(0);return null===r?ht(w("{{#if}} requires a condition as its first positional parameter, did not receive any parameters",e.loc)):dt({condition:r})},translate({node:e,state:t},{condition:r}){let n=e.blocks.get("default"),s=e.blocks.get("else"),a=yt.visit(r,t),l=tr.NamedBlock(n,t),o=s?tr.NamedBlock(s,t):dt(null);return ut.all(a,l,o).mapOk((([t,r,n])=>new Ce({loc:e.loc,condition:t,block:r,inverse:n})))}}).kw("unless",{assert(e){let{args:t}=e;if(!t.named.isEmpty())return ht(w(`{{#unless}} cannot receive named parameters, received ${t.named.entries.map((e=>e.name.chars)).join(", ")}`,e.loc));if(t.positional.size>1)return ht(w(`{{#unless}} can only receive one positional parameter in block form, the conditional value. Received ${t.positional.size} parameters`,e.loc));let r=t.nth(0);return null===r?ht(w("{{#unless}} requires a condition as its first positional parameter, did not receive any parameters",e.loc)):dt({condition:r})},translate({node:e,state:t},{condition:r}){let n=e.blocks.get("default"),s=e.blocks.get("else"),a=yt.visit(r,t),l=tr.NamedBlock(n,t),o=s?tr.NamedBlock(s,t):dt(null);return ut.all(a,l,o).mapOk((([t,r,n])=>new Ce({loc:e.loc,condition:new Ee({value:t,loc:e.loc}),block:r,inverse:n})))}}).kw("each",{assert(e){let{args:t}=e;if(!t.named.entries.every((e=>"key"===e.name.chars)))return ht(w(`{{#each}} can only receive the 'key' named parameter, received ${t.named.entries.filter((e=>"key"!==e.name.chars)).map((e=>e.name.chars)).join(", ")}`,t.named.loc));if(t.positional.size>1)return ht(w(`{{#each}} can only receive one positional parameter, the collection being iterated. Received ${t.positional.size} parameters`,t.positional.loc));let r=t.nth(0),n=t.get("key");return null===r?ht(w("{{#each}} requires an iterable value to be passed as its first positional parameter, did not receive any parameters",t.loc)):dt({value:r,key:n})},translate({node:e,state:t},{value:r,key:n}){let s=e.blocks.get("default"),a=e.blocks.get("else"),l=yt.visit(r,t),o=n?yt.visit(n,t):dt(null),i=tr.NamedBlock(s,t),c=a?tr.NamedBlock(a,t):dt(null);return ut.all(l,o,i,c).mapOk((([t,r,n,s])=>new Se({loc:e.loc,value:t,key:r,block:n,inverse:s})))}}).kw("let",{assert(e){let{args:t}=e;return t.named.isEmpty()?0===t.positional.size?ht(w("{{#let}} requires at least one value as its first positional parameter, did not receive any parameters",t.positional.loc)):e.blocks.get("else")?ht(w("{{#let}} cannot receive an {{else}} block",t.positional.loc)):dt({positional:t.positional}):ht(w(`{{#let}} cannot receive named parameters, received ${t.named.entries.map((e=>e.name.chars)).join(", ")}`,t.named.loc))},translate({node:e,state:t},{positional:r}){let n=e.blocks.get("default"),s=yt.Positional(r,t),a=tr.NamedBlock(n,t);return ut.all(s,a).mapOk((([t,r])=>new Oe({loc:e.loc,positional:t,block:r})))}}).kw("-with-dynamic-vars",{assert:e=>dt({named:e.args.named}),translate({node:e,state:t},{named:r}){let n=e.blocks.get("default"),s=yt.NamedArguments(r,t),a=tr.NamedBlock(n,t);return ut.all(s,a).mapOk((([t,r])=>new He({loc:e.loc,named:t,block:r})))}}).kw("component",{assert:Bt(S.Component),translate({node:e,state:t},{definition:r,args:n}){let s=yt.visit(r,t),a=yt.Args(n,t),l=tr.NamedBlocks(e.blocks,t);return ut.all(s,a,l).mapOk((([t,r,n])=>new Ne({loc:e.loc,definition:t,args:r,blocks:n})))}}),Vt=bt("Call").kw("has-block",Nt("has-block")).kw("has-block-params",Nt("has-block-params")).kw("-get-dynamic-var",Ht).kw("log",Gt).kw("if",$t("if")).kw("unless",$t("unless")).kw("component",Ot(S.Component)).kw("helper",Ot(S.Helper)).kw("modifier",Ot(S.Modifier)),Ft=bt("Modifier"),_t="http://www.w3.org/1999/xlink",qt="http://www.w3.org/XML/1998/namespace",Kt="http://www.w3.org/2000/xmlns/",jt={"xlink:actuate":_t,"xlink:arcrole":_t,"xlink:href":_t,"xlink:role":_t,"xlink:show":_t,"xlink:title":_t,"xlink:type":_t,"xml:base":qt,"xml:lang":qt,"xml:space":qt,xmlns:Kt,"xmlns:xlink":Kt},zt={div:f.div,span:f.span,p:f.p,a:f.a},Ut=["div","span","p","a"];function Wt(e){return"string"==typeof e?e:Ut[e]}const Rt={class:k.class,id:k.id,value:k.value,name:k.name,type:k.type,style:k.style,href:k.href},Yt=["class","id","value","name","type","style","href"];function Jt(e){return Rt[e]??e}function Xt(e){return"string"==typeof e?e:Yt[e]}class Zt{delegate;constructor(e,t,r){this.element=e,this.state=r,this.delegate=t}toStatement(){return this.prepare().andThen((e=>this.delegate.toStatement(this,e)))}attr(e){let t=e.name,r=e.value,n=(s=t.chars,jt[s]||void 0);var s;return A.isLiteral(r,"string")?dt(new Ve({loc:e.loc,name:t,value:r.toSlice(),namespace:n,kind:{component:this.delegate.dynamicFeatures}})):yt.visit(kt(r),this.state).mapOk((r=>{let s=e.trusting;return new Fe({loc:e.loc,name:t,value:r,namespace:n,kind:{trusting:s,component:this.delegate.dynamicFeatures}})}))}modifier(e){let t=Ft.translate(e,this.state);if(null!==t)return t;let r=yt.visit(e.callee,this.state),n=yt.Args(e.args,this.state);return ut.all(r,n).mapOk((([t,r])=>new Ue({loc:e.loc,callee:t,args:r})))}attrs(){let e=new ft,t=new ft,r=null,n=0===this.element.attrs.filter((e=>"SplatAttr"===e.type)).length;for(let t of this.element.attrs)"SplatAttr"===t.type?e.add(dt(new Re({loc:t.loc,symbol:this.state.scope.allocateBlock("attrs")}))):"type"===t.name.chars&&n?r=t:e.add(this.attr(t));for(let e of this.element.componentArgs)t.add(this.delegate.arg(e,this));return r&&e.add(this.attr(r)),ut.all(t.toArray(),e.toArray()).mapOk((([e,t])=>({attrs:t,args:new rt({loc:E(e,b.SourceSpan.NON_EXISTENT),entries:it(e)})})))}prepare(){let e=this.attrs(),t=new ft(this.element.modifiers.map((e=>this.modifier(e)))).toArray();return ut.all(e,t).mapOk((([e,t])=>{let{attrs:r,args:n}=e,s=[...r,...t];return{args:n,params:new qe({loc:E(s,b.SourceSpan.NON_EXISTENT),body:it(s)})}}))}}class Qt{dynamicFeatures=!0;constructor(e,t){this.tag=e,this.element=t}arg(e,{state:t}){let r=e.name;return yt.visit(kt(e.value),t).mapOk((t=>new nt({loc:e.loc,key:r,value:t})))}toStatement(e,{args:t,params:r}){let{element:n,state:s}=e;return this.blocks(s).mapOk((e=>new De({loc:n.loc,tag:this.tag,params:r,args:t,blocks:e})))}blocks(e){return tr.NamedBlocks(this.element.blocks,e)}}class er{constructor(e,t,r){this.tag=e,this.element=t,this.dynamicFeatures=r}isComponent=!1;arg(e){return ht(w(`${e.name.chars} is not a valid attribute name. @arguments are only allowed on components, but the tag for this element (\`${this.tag.chars}\`) is a regular, non-component HTML element.`,e.loc))}toStatement(e,{params:t}){let{state:r,element:n}=e;return tr.visitList(this.element.body,r).mapOk((e=>new _e({loc:n.loc,tag:this.tag,params:t,body:e.toArray(),dynamicFeatures:this.dynamicFeatures})))}}const tr=new class{visitList(e,t){return new ft(e.map((e=>tr.visit(e,t)))).toOptionalList().mapOk((e=>e.filter((e=>null!==e))))}visit(e,t){switch(e.type){case"GlimmerComment":return dt(null);case"AppendContent":return this.AppendContent(e,t);case"HtmlText":return dt(this.TextNode(e));case"HtmlComment":return dt(this.HtmlComment(e));case"InvokeBlock":return this.InvokeBlock(e,t);case"InvokeComponent":return this.Component(e,t);case"SimpleElement":return this.SimpleElement(e,t)}}InvokeBlock(e,t){let r=Dt.translate(e,t);if(null!==r)return r;let n=yt.visit(e.callee,t),s=yt.Args(e.args,t);return ut.all(n,s).andThen((([r,n])=>this.NamedBlocks(e.blocks,t).mapOk((t=>new We({loc:e.loc,head:r,args:n,blocks:t})))))}NamedBlocks(e,t){return new ft(e.blocks.map((e=>this.NamedBlock(e,t)))).toArray().mapOk((t=>new Le({loc:e.loc,blocks:it(t)})))}NamedBlock(e,t){return t.visitBlock(e.block).mapOk((t=>new Ie({loc:e.loc,name:e.name,body:t.toArray(),scope:e.block.scope})))}SimpleElement(e,t){return new Zt(e,new er(e.tag,e,function({attrs:e,modifiers:t}){return t.length>0||!!e.filter((e=>"SplatAttr"===e.type))[0]}(e)),t).toStatement()}Component(e,t){return yt.visit(e.callee,t).andThen((r=>new Zt(e,new Qt(r,e),t).toStatement()))}AppendContent(e,t){let r=Mt.translate(e,t);return null!==r?r:yt.visit(e.value,t).mapOk((t=>e.trusting?new $e({loc:e.loc,html:t}):new Ge({loc:e.loc,text:t})))}TextNode(e){return new Ge({loc:e.loc,text:new A.LiteralExpression({loc:e.loc,value:e.chars})})}HtmlComment(e){return new Me({loc:e.loc,value:e.text})}};class rr{_currentScope;_cursorCount=0;constructor(e,t){this.isStrict=t,this._currentScope=e}generateUniqueCursor(){return`%cursor:${this._cursorCount++}%`}get scope(){return this._currentScope}visitBlock(e){let t=this._currentScope;this._currentScope=e.scope;try{return tr.visitList(e.body,this)}finally{this._currentScope=t}}}var nr=function(e){return e.Value="value",e.Component="component",e.Helper="helper",e.Modifier="modifier",e.ComponentOrHelper="component or helper",e}(nr||{});class sr{static validate(e){return new this(e).validate()}constructor(e){this.template=e}validate(){return this.Statements(this.template.body).mapOk((()=>this.template))}Statements(e){let t=dt(null);for(let r of e)t=t.andThen((()=>this.Statement(r)));return t}NamedBlocks({blocks:e}){let t=dt(null);for(let r of e.toArray())t=t.andThen((()=>this.NamedBlock(r)));return t}NamedBlock(e){return this.Statements(e.body)}Statement(e){switch(e.type){case"InElement":return this.InElement(e);case"Debugger":case"AppendComment":return dt(null);case"Yield":return this.Yield(e);case"AppendTrustedHTML":return this.AppendTrustedHTML(e);case"AppendTextNode":return this.AppendTextNode(e);case"Component":return this.Component(e);case"SimpleElement":return this.SimpleElement(e);case"InvokeBlock":return this.InvokeBlock(e);case"If":return this.If(e);case"Each":return this.Each(e);case"Let":return this.Let(e);case"WithDynamicVars":return this.WithDynamicVars(e);case"InvokeComponent":return this.InvokeComponent(e)}}Expressions(e){let t=dt(null);for(let r of e)t=t.andThen((()=>this.Expression(r)));return t}Expression(e,t=e,r){switch(e.type){case"Literal":case"Keyword":case"Missing":case"This":case"Arg":case"Local":case"HasBlock":case"HasBlockParams":case"GetDynamicVar":return dt(null);case"PathExpression":return this.Expression(e.head,t,r);case"Free":return this.errorFor(e.name,t,r);case"InterpolateExpression":return this.InterpolateExpression(e,t,r);case"CallExpression":return this.CallExpression(e,t,r??nr.Helper);case"Not":return this.Expression(e.value,t,r);case"IfInline":return this.IfInline(e);case"Curry":return this.Curry(e);case"Log":return this.Log(e)}}Args(e){return this.Positional(e.positional).andThen((()=>this.NamedArguments(e.named)))}Positional(e,t){let r=dt(null),n=e.list.toArray();return r=1===n.length?this.Expression(n[0],t):this.Expressions(n),r}NamedArguments({entries:e}){let t=dt(null);for(let r of e.toArray())t=t.andThen((()=>this.NamedArgument(r)));return t}NamedArgument(e){return"CallExpression"===e.value.type?this.Expression(e.value,e,nr.Helper):this.Expression(e.value,e)}ElementParameters({body:e}){let t=dt(null);for(let r of e.toArray())t=t.andThen((()=>this.ElementParameter(r)));return t}ElementParameter(e){switch(e.type){case"StaticAttr":case"SplatAttr":return dt(null);case"DynamicAttr":return this.DynamicAttr(e);case"Modifier":return this.Modifier(e)}}DynamicAttr(e){return"CallExpression"===e.value.type?this.Expression(e.value,e,nr.Helper):this.Expression(e.value,e)}Modifier(e){return this.Expression(e.callee,e,nr.Modifier).andThen((()=>this.Args(e.args)))}InElement(e){return this.Expression(e.destination).andThen((()=>this.Expression(e.insertBefore))).andThen((()=>this.NamedBlock(e.block)))}Yield(e){return this.Positional(e.positional,e)}AppendTrustedHTML(e){return this.Expression(e.html,e)}AppendTextNode(e){return"CallExpression"===e.text.type?this.Expression(e.text,e,nr.ComponentOrHelper):this.Expression(e.text,e)}Component(e){return this.Expression(e.tag,e,nr.Component).andThen((()=>this.ElementParameters(e.params))).andThen((()=>this.NamedArguments(e.args))).andThen((()=>this.NamedBlocks(e.blocks)))}SimpleElement(e){return this.ElementParameters(e.params).andThen((()=>this.Statements(e.body)))}InvokeBlock(e){return this.Expression(e.head,e.head,nr.Component).andThen((()=>this.Args(e.args))).andThen((()=>this.NamedBlocks(e.blocks)))}If(e){return this.Expression(e.condition,e).andThen((()=>this.NamedBlock(e.block))).andThen((()=>e.inverse?this.NamedBlock(e.inverse):dt(null)))}Each(e){return this.Expression(e.value,e).andThen((()=>e.key?this.Expression(e.key,e):dt(null))).andThen((()=>this.NamedBlock(e.block))).andThen((()=>e.inverse?this.NamedBlock(e.inverse):dt(null)))}Let(e){return this.Positional(e.positional).andThen((()=>this.NamedBlock(e.block)))}WithDynamicVars(e){return this.NamedArguments(e.named).andThen((()=>this.NamedBlock(e.block)))}InvokeComponent(e){return this.Expression(e.definition,e,nr.Component).andThen((()=>this.Args(e.args))).andThen((()=>e.blocks?this.NamedBlocks(e.blocks):dt(null)))}InterpolateExpression(e,t,r){let n=e.parts.toArray();return 1===n.length?this.Expression(n[0],t,r):this.Expressions(n)}CallExpression(e,t,r){return this.Expression(e.callee,t,r).andThen((()=>this.Args(e.args)))}IfInline(e){return this.Expression(e.condition).andThen((()=>this.Expression(e.truthy))).andThen((()=>e.falsy?this.Expression(e.falsy):dt(null)))}Curry(e){let t;return t=e.curriedType===S.Component?nr.Component:e.curriedType===S.Helper?nr.Helper:nr.Modifier,this.Expression(e.definition,e,t).andThen((()=>this.Args(e.args)))}Log(e){return this.Positional(e.positional,e)}errorFor(e,t,r=nr.Value){return ht(w(`Attempted to resolve a ${r} in a strict mode template, but that value was not in scope: ${e}`,C(t)))}}class ar{upvars;symbols;constructor([e,t,r,n]){this.upvars=n,this.symbols=t}format(e){let t=[];for(let r of e[0])t.push(this.formatOpcode(r));return t}formatOpcode(e){if(!Array.isArray(e))return e;switch(e[0]){case h.Append:return["append",this.formatOpcode(e[1])];case h.TrustingAppend:return["trusting-append",this.formatOpcode(e[1])];case h.Block:return["block",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3]),this.formatBlocks(e[4])];case h.InElement:return["in-element",e[1],this.formatOpcode(e[2]),e[3]?this.formatOpcode(e[3]):void 0];case h.OpenElement:return["open-element",Wt(e[1])];case h.OpenElementWithSplat:return["open-element-with-splat",Wt(e[1])];case h.CloseElement:return["close-element"];case h.FlushElement:return["flush-element"];case h.StaticAttr:return["static-attr",Xt(e[1]),e[2],e[3]];case h.StaticComponentAttr:return["static-component-attr",Xt(e[1]),e[2],e[3]];case h.DynamicAttr:return["dynamic-attr",Xt(e[1]),this.formatOpcode(e[2]),e[3]];case h.ComponentAttr:return["component-attr",Xt(e[1]),this.formatOpcode(e[2]),e[3]];case h.AttrSplat:return["attr-splat"];case h.Yield:return["yield",e[1],this.formatParams(e[2])];case h.DynamicArg:return["dynamic-arg",e[1],this.formatOpcode(e[2])];case h.StaticArg:return["static-arg",e[1],this.formatOpcode(e[2])];case h.TrustingDynamicAttr:return["trusting-dynamic-attr",Xt(e[1]),this.formatOpcode(e[2]),e[3]];case h.TrustingComponentAttr:return["trusting-component-attr",Xt(e[1]),this.formatOpcode(e[2]),e[3]];case h.Debugger:return["debugger",e[1]];case h.Comment:return["comment",e[1]];case h.Modifier:return["modifier",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3])];case h.Component:return["component",this.formatOpcode(e[1]),this.formatElementParams(e[2]),this.formatHash(e[3]),this.formatBlocks(e[4])];case h.HasBlock:return["has-block",this.formatOpcode(e[1])];case h.HasBlockParams:return["has-block-params",this.formatOpcode(e[1])];case h.Curry:return["curry",this.formatOpcode(e[1]),this.formatCurryType(e[2]),this.formatParams(e[3]),this.formatHash(e[4])];case h.Undefined:return["undefined"];case h.Call:return["call",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3])];case h.Concat:return["concat",this.formatParams(e[1])];case h.GetStrictKeyword:return["get-strict-free",this.upvars[e[1]]];case h.GetFreeAsComponentOrHelperHead:return["GetFreeAsComponentOrHelperHead",this.upvars[e[1]],e[2]];case h.GetFreeAsHelperHead:return["GetFreeAsHelperHead",this.upvars[e[1]],e[2]];case h.GetFreeAsComponentHead:return["GetFreeAsComponentHead",this.upvars[e[1]],e[2]];case h.GetFreeAsModifierHead:return["GetFreeAsModifierHead",this.upvars[e[1]],e[2]];case h.GetSymbol:return 0===e[1]?["get-symbol","this",e[2]]:["get-symbol",this.symbols[e[1]-1],e[2]];case h.GetLexicalSymbol:return["get-template-symbol",e[1],e[2]];case h.If:return["if",this.formatOpcode(e[1]),this.formatBlock(e[2]),e[3]?this.formatBlock(e[3]):null];case h.IfInline:return["if-inline"];case h.Not:return["not"];case h.Each:return["each",this.formatOpcode(e[1]),e[2]?this.formatOpcode(e[2]):null,this.formatBlock(e[3]),e[4]?this.formatBlock(e[4]):null];case h.Let:return["let",this.formatParams(e[1]),this.formatBlock(e[2])];case h.Log:return["log",this.formatParams(e[1])];case h.WithDynamicVars:return["-with-dynamic-vars",this.formatHash(e[1]),this.formatBlock(e[2])];case h.GetDynamicVar:return["-get-dynamic-vars",this.formatOpcode(e[1])];case h.InvokeComponent:return["component",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3]),this.formatBlocks(e[4])]}}formatCurryType(e){switch(e){case S.Component:return"component";case S.Helper:return"helper";case S.Modifier:return"modifier";default:throw c(e)}}formatElementParams(e){return null===e?null:e.map((e=>this.formatOpcode(e)))}formatParams(e){return null===e?null:e.map((e=>this.formatOpcode(e)))}formatHash(e){return null===e?null:e[0].reduce(((t,r,n)=>(t[r]=this.formatOpcode(e[1][n]),t)),t())}formatBlocks(e){return null===e?null:e[0].reduce(((t,r,n)=>(t[r]=this.formatBlock(e[1][n]),t)),t())}formatBlock(e){return{statements:e[0].map((e=>this.formatOpcode(e))),parameters:e[1]}}}const lr=new class{expr(e){switch(e.type){case"Missing":return;case"Literal":return this.Literal(e);case"Keyword":return this.Keyword(e);case"CallExpression":return this.CallExpression(e);case"PathExpression":return this.PathExpression(e);case"Arg":return[h.GetSymbol,e.symbol];case"Local":return this.Local(e);case"This":return[h.GetSymbol,0];case"Free":return[e.resolution.resolution(),e.symbol];case"HasBlock":return this.HasBlock(e);case"HasBlockParams":return this.HasBlockParams(e);case"Curry":return this.Curry(e);case"Not":return this.Not(e);case"IfInline":return this.IfInline(e);case"InterpolateExpression":return this.InterpolateExpression(e);case"GetDynamicVar":return this.GetDynamicVar(e);case"Log":return this.Log(e)}}Literal({value:e}){return void 0===e?[h.Undefined]:e}Missing(){}HasBlock({symbol:e}){return[h.HasBlock,[h.GetSymbol,e]]}HasBlockParams({symbol:e}){return[h.HasBlockParams,[h.GetSymbol,e]]}Curry({definition:e,curriedType:t,args:r}){return[h.Curry,lr.expr(e),t,lr.Positional(r.positional),lr.NamedArguments(r.named)]}Local({isTemplateLocal:e,symbol:t}){return[e?h.GetLexicalSymbol:h.GetSymbol,t]}Keyword({symbol:e}){return[h.GetStrictKeyword,e]}PathExpression({head:e,tail:t}){let r=lr.expr(e);return a(r[0]!==h.GetStrictKeyword,"[BUG] keyword in a PathExpression"),[...r,lr.Tail(t)]}InterpolateExpression({parts:e}){return[h.Concat,e.map((e=>lr.expr(e))).toArray()]}CallExpression({callee:e,args:t}){return[h.Call,lr.expr(e),...lr.Args(t)]}Tail({members:e}){return u(e,(e=>e.chars))}Args({positional:e,named:t}){return[this.Positional(e),this.NamedArguments(t)]}Positional({list:e}){return e.map((e=>lr.expr(e))).toPresentArray()}NamedArgument({key:e,value:t}){return[e.chars,lr.expr(t)]}NamedArguments({entries:e}){let t=e.toArray();if(n(t)){let e=[],r=[];for(let n of t){let[t,s]=lr.NamedArgument(n);e.push(t),r.push(s)}return m(e),m(r),[e,r]}return null}Not({value:e}){return[h.Not,lr.expr(e)]}IfInline({condition:e,truthy:t,falsy:r}){let n=[h.IfInline,lr.expr(e),lr.expr(t)];return r&&n.push(lr.expr(r)),n}GetDynamicVar({name:e}){return[h.GetDynamicVar,lr.expr(e)]}Log({positional:e}){return[h.Log,this.Positional(e)]}};class or{constructor(e){this.statements=e}toArray(){return this.statements}}const ir=new class{list(e){let t=[];for(let r of e){let e=ir.content(r);e&&e instanceof or?t.push(...e.toArray()):t.push(e)}return t}content(e){return this.visitContent(e)}visitContent(e){switch(e.type){case"Debugger":return[h.Debugger,e.scope.getDebugInfo()];case"AppendComment":return this.AppendComment(e);case"AppendTextNode":return this.AppendTextNode(e);case"AppendTrustedHTML":return this.AppendTrustedHTML(e);case"Yield":return this.Yield(e);case"Component":return this.Component(e);case"SimpleElement":return this.SimpleElement(e);case"InElement":return this.InElement(e);case"InvokeBlock":return this.InvokeBlock(e);case"If":return this.If(e);case"Each":return this.Each(e);case"Let":return this.Let(e);case"WithDynamicVars":return this.WithDynamicVars(e);case"InvokeComponent":return this.InvokeComponent(e);default:return c(e)}}Yield({to:e,positional:t}){return[h.Yield,e,lr.Positional(t)]}InElement({guid:e,insertBefore:t,destination:r,block:n}){let s=ir.NamedBlock(n)[1],a=lr.expr(r),l=lr.expr(t);return void 0===l?[h.InElement,s,e,a]:[h.InElement,s,e,a,l]}InvokeBlock({head:e,args:t,blocks:r}){return[h.Block,lr.expr(e),...lr.Args(t),ir.NamedBlocks(r)]}AppendTrustedHTML({html:e}){return[h.TrustingAppend,lr.expr(e)]}AppendTextNode({text:e}){return[h.Append,lr.expr(e)]}AppendComment({value:e}){return[h.Comment,e.chars]}SimpleElement({tag:e,params:t,body:r,dynamicFeatures:n}){let s=n?h.OpenElementWithSplat:h.OpenElement;return new or([[s,(a=e.chars,zt[a]??a)],...ir.ElementParameters(t).toArray(),[h.FlushElement],...ir.list(r),[h.CloseElement]]);var a}Component({tag:e,params:t,args:r,blocks:n}){let s=lr.expr(e),a=ir.ElementParameters(t),l=lr.NamedArguments(r),o=ir.NamedBlocks(n);return[h.Component,s,a.toPresentArray(),l,o]}ElementParameters({body:e}){return e.map((e=>ir.ElementParameter(e)))}ElementParameter(e){switch(e.type){case"SplatAttr":return[h.AttrSplat,e.symbol];case"DynamicAttr":return[(t=e.kind,t.component?t.trusting?h.TrustingComponentAttr:h.ComponentAttr:t.trusting?h.TrustingDynamicAttr:h.DynamicAttr),...ur(e)];case"StaticAttr":return[pr(e.kind),...cr(e)];case"Modifier":return[h.Modifier,lr.expr(e.callee),...lr.Args(e.args)]}var t}NamedBlocks({blocks:e}){let t=[],r=[];for(let n of e.toArray()){let[e,s]=ir.NamedBlock(n);t.push(e),r.push(s)}return t.length>0?[t,r]:null}NamedBlock({name:e,body:t,scope:r}){let n=e.chars;return"inverse"===n&&(n="else"),[n,[ir.list(t),r.slots]]}If({condition:e,block:t,inverse:r}){return[h.If,lr.expr(e),ir.NamedBlock(t)[1],r?ir.NamedBlock(r)[1]:null]}Each({value:e,key:t,block:r,inverse:n}){return[h.Each,lr.expr(e),t?lr.expr(t):null,ir.NamedBlock(r)[1],n?ir.NamedBlock(n)[1]:null]}Let({positional:e,block:t}){return[h.Let,lr.Positional(e),ir.NamedBlock(t)[1]]}WithDynamicVars({named:e,block:t}){return[h.WithDynamicVars,lr.NamedArguments(e),ir.NamedBlock(t)[1]]}InvokeComponent({definition:e,args:t,blocks:r}){return[h.InvokeComponent,lr.expr(e),lr.Positional(t.positional),lr.NamedArguments(t.named),r?ir.NamedBlocks(r):null]}};function cr({name:e,value:t,namespace:r}){let n=[Jt(e.chars),t.chars];return r&&n.push(r),n}function ur({name:e,value:t,namespace:r}){let n=[Jt(e.chars),lr.expr(t)];return r&&n.push(r),n}function pr(e){return e.component?h.StaticComponentAttr:h.StaticAttr}const mr=(()=>{const e="object"==typeof module&&"function"==typeof module.require?module.require:globalThis.require;if(e)try{const t=e("crypto"),r=e=>{const r=t.createHash("sha1");return r.update(e,"utf8"),r.digest("base64").substring(0,8)};return r("test"),r}catch{}return function(){return null}})(),dr={id:mr};function hr(e,t=dr){const r=new b.Source(e??"",t.meta?.moduleName),[n,s]=B(r,{lexicalScope:()=>!1,...t}),a=function(e,t,r){let n=new rr(t.table,r),s=tr.visitList(t.body,n).mapOk((e=>new xe({loc:t.loc,scope:t.table,body:e.toArray()})));return r&&(s=s.andThen((e=>sr.validate(e)))),s}(0,n,t.strictMode??!1).mapOk((e=>function(e){let t=ir.list(e.body),r=e.scope;return[t,r.symbols,r.hasEval,r.upvars]}(e)));if(a.isOk)return[a.value,s];throw a.reason}const fr="796d24e6-2450-4fb0-8cdf-b65638b5ef70";function kr(e,t=dr){const[r,n]=hr(e,t),s=t.meta?.moduleName,a=t.id||mr,l=JSON.stringify(r),o={id:a(JSON.stringify(t.meta)+l),block:l,moduleName:s??"(unknown template module)",scope:fr,isStrictMode:t.strictMode??!1};0===n.length&&delete o.scope;let i=JSON.stringify(o);if(n.length>0){const e=`()=>[${n.join(",")}]`;i=i.replace(`"${fr}"`,e)}return i}export{j as Builder,ie as NEWLINE,Z as ProgramSymbols,ar as WireFormatDebugger,se as buildStatement,re as buildStatements,le as c,mr as defaultId,kr as precompile,hr as precompileJSON,ae as s,oe as unicode};
import{assertNever as e,dict as t,values as r}from"@glimmer/util";import{VariableResolutionContext as n,SexpOpcodes as s,WellKnownTagNames as a,WellKnownAttrNames as o}from"@glimmer/wire-format";import{node as l,KEYWORDS_TYPES as i,ASTv2 as c,isKeyword as u,generateSyntaxError as d,SourceSlice as p,src as m,maybeLoc as h,loc as f,normalize as y}from"@glimmer/syntax";import{$v0 as k,$t1 as g,$t0 as v,$s1 as b,$s0 as w,$sp as A,$fp as x,$ra as E,$pc as S}from"@glimmer/vm";const C="Block",B="Call",O="Element",T="AppendPath",N="AppendExpr",$="Literal",I="Modifier",P="DynamicComponent",H="Comment",L="Splat",M="Keyword",G="Local",V="Free",F="Block",D="This",_="Literal",j="Call",z="GetPath",R="GetVar",W="Concat",q="HasBlock",K="HasBlockParams",U=0,J=1,Y=2,X="http://www.w3.org/2000/xmlns/",Z=console;function Q(e,t){return e}function ee(e){return e.length>0}function te(e,t){if(null===e)return null;let r=[];for(let n of e)r.push(t(n));return r}const re=~(2**29);function ne(e){return(e|=0)>re?function(e){return~e}(e):function(e){return 536870912|e}(e)}function se(r){if(Array.isArray(r))return function(e){if(!Array.isArray(e))return!1;const t=e[0];if("number"==typeof t)switch(t){case 0:case 5:case 6:case 7:case 8:return!0;default:return!1}return"("===t[0]}(r)?ge(r):function(e){if(Array.isArray(e)&&"string"==typeof e[0])switch(e[0][0]){case"(":case"#":case"<":case"!":return!0;default:return!1}return!1}(r)?function(e){const r=e[0];switch(r[0]){case"(":{let t=null,n=null;return 3===e.length?(t=we(e[1]),n=Ae(e[2])):2===e.length&&(Array.isArray(e[1])?t=we(e[1]):n=Ae(e[1])),{kind:B,head:le(r),params:t,hash:n,trusted:!1}}case"#":{const{head:t,params:r,hash:n,blocks:s,blockParams:a}=de(e);return{kind:C,head:t,params:r,hash:n,blocks:s,blockParams:a}}case"!":{const t=e[0].slice(1),{params:r,hash:n,blocks:s,blockParams:a}=de(e);return{kind:M,name:t,params:r,hash:n,blocks:s,blockParams:a}}case"<":{let n=t(),s=[];return 3===e.length?(n=fe(e[1]),s=he(e[2])):2===e.length&&(Array.isArray(e[1])?s=he(e[1]):n=fe(e[1])),{kind:O,name:Q(ke(r)),attrs:n,block:s}}default:throw new Error(`Unreachable ${JSON.stringify(e)} in normalizeSugaryArrayStatement`)}}(r):function(e){switch(e[0]){case 0:return{kind:$,value:e[1]};case 2:return ge(e[1],e[2]);case 3:return{kind:I,params:we(e[1]),hash:Ae(e[2])};case 4:return{kind:P,expr:ve(e[1]),hash:Ae(e[2]),block:he(e[3])};case 1:return{kind:H,value:e[1]}}}(r);if("string"==typeof r)return ae(ce(r),!1);throw e(r)}function ae(e,t){return e.type===z?{kind:T,path:e,trusted:t}:{kind:N,expr:e,trusted:t}}function oe(e){const t=/^(#|!)(.*)$/u.exec(e);if(null===t)throw new Error("Unexpected missing # in block head");return ce(t[2])}function le(e){const t=/^\((.*)\)$/u.exec(e);if(null===t)throw new Error("Unexpected missing () in call head");return ce(t[1])}function ie(e,t=[]){const r=ue(e);return ee(t)?{type:z,path:{head:r,tail:t}}:{type:R,variable:r}}function ce(e){const{kind:t,name:r}=ue(e),[n,...s]=r.split("."),a={kind:t,name:n,mode:"loose"};return ee(s)?{type:z,path:{head:a,tail:s}}:{type:R,variable:a}}function ue(e){let t,r;if(/^this(?:\.|$)/u.test(e))return{kind:D,name:e,mode:"loose"};switch(e[0]){case"^":t=V,r=e.slice(1);break;case"@":t="Arg",r=e.slice(1);break;case"&":t=F,r=e.slice(1);break;default:t=G,r=e}return{kind:t,name:r,mode:"loose"}}function de(e){const r=e[0];let n=t(),s=null,a=null,o=null;return 2===e.length?n=me(e[1]):3===e.length?(Array.isArray(e[1])?s=we(e[1]):({hash:a,blockParams:o}=pe(e[1])),n=me(e[2])):4===e.length&&(s=we(e[1]),({hash:a,blockParams:o}=pe(e[2])),n=me(e[3])),{head:oe(r),params:s,hash:a,blockParams:o,blocks:n}}function pe(e){if(null===e)return{hash:null,blockParams:null};let r=null,n=null;return function(e,t){Object.keys(e).forEach((r=>{const n=e[r];t(r,n)}))}(e,((e,s)=>{"as"===e?n=Array.isArray(s)?s:[s]:(r=r||t(),r[e]=ve(s))})),{hash:r,blockParams:n}}function me(e){return Array.isArray(e)?{default:he(e)}:ye(e,he)}function he(e){return e.map((e=>se(e)))}function fe(e){return ye(e,(e=>{return(t=e,"splat"===t?{expr:L,trusted:!1}:{expr:ve(t),trusted:!1}).expr;var t}))}function ye(e,r){const n=t();return Object.keys(e).forEach((t=>{n[t]=r(e[t],t)})),n}function ke(e){const t=/^<([\d\-a-z][\d\-A-Za-z]*)>$/u.exec(e);return t?.[1]??null}function ge(t,r=!1){if(null==t)return{expr:{type:_,value:t},kind:N,trusted:!1};if(Array.isArray(t))switch(t[0]){case 0:return{expr:{type:_,value:t[1]},kind:N,trusted:!1};case 5:return ae(ie(t[1],t[2]),r);case 6:return{expr:{type:W,params:we(t.slice(1))},kind:N,trusted:r};case 7:return{expr:{type:q,name:t[1]},kind:N,trusted:r};case 8:return{expr:{type:K,name:t[1]},kind:N,trusted:r};default:if(be(t))return{expr:xe(t),kind:N,trusted:r};throw new Error(`Unexpected array in expression position (wasn't a tuple expression and ${t[0]} isn't wrapped in parens, so it isn't a call): ${JSON.stringify(t)}`)}else{if("object"==typeof t)throw e(t);switch(typeof t){case"string":return ae(ce(t),r);case"boolean":case"number":return{expr:{type:_,value:t},kind:N,trusted:!0};default:throw e(t)}}}function ve(t){if(null==t)return{type:_,value:t};if(Array.isArray(t))switch(t[0]){case 0:return{type:_,value:t[1]};case 5:return ie(t[1],t[2]);case 6:return{type:W,params:we(t.slice(1))};case 7:return{type:q,name:t[1]};case 8:return{type:K,name:t[1]};default:if(be(t))return xe(t);throw new Error(`Unexpected array in expression position (wasn't a tuple expression and ${t[0]} isn't wrapped in parens, so it isn't a call): ${JSON.stringify(t)}`)}else{if("object"==typeof t)throw e(t);switch(typeof t){case"string":return ce(t);case"boolean":case"number":return{type:_,value:t};default:throw e(t)}}}function be(e){return"string"==typeof e[0]&&"("===e[0][0]}function we(e){return e.map(ve)}function Ae(e){return null===e?null:ye(e,ve)}function xe(e){switch(e.length){case 1:return{type:j,head:le(e[0]),params:null,hash:null};case 2:return Array.isArray(e[1])?{type:j,head:le(e[0]),params:we(e[1]),hash:null}:{type:j,head:le(e[0]),params:null,hash:Ae(e[1])};case 3:return{type:j,head:le(e[0]),params:we(e[1]),hash:Ae(e[2])}}}[1,-1].forEach((e=>{return ne((t=e,(t|=0)<0?function(e){return e&re}(t):function(e){return~e}(t)));var t}));class Ee{_freeVariables=[];_symbols=["this"];top=this;toSymbols(){return this._symbols.slice(1)}toUpvars(){return this._freeVariables}freeVar(e){return Ce(this._freeVariables,e)}block(e){return this.symbol(e)}arg(e){return Ce(this._symbols,e)}local(e){throw new Error(`No local ${e} was found. Maybe you meant ^${e} for upvar, or !${e} for keyword?`)}this(){return 0}hasLocal(e){return!1}symbol(e){return Ce(this._symbols,e)}child(e){return new Se(this,e)}}class Se{locals=t();constructor(e,t){this.parent=e;for(let r of t)this.locals[r]=e.top.symbol(r)}get paramSymbols(){return r(this.locals)}get top(){return this.parent.top}freeVar(e){return this.parent.freeVar(e)}arg(e){return this.parent.arg(e)}block(e){return this.parent.block(e)}local(e){return e in this.locals?this.locals[e]:this.parent.local(e)}this(){return this.parent.this()}hasLocal(e){return e in this.locals||this.parent.hasLocal(e)}child(e){return new Se(this,e)}}function Ce(e,t){let r=e.indexOf(t);return-1===r?(r=e.length,e.push(t),r):r}function Be(e){return new Error(`unimplemented ${e}`)}function Oe(e,t){let r=[];return e.forEach((e=>r.push(...Ne(se(e),t)))),r}function Te(e,t){let r=[];return e.forEach((e=>r.push(...Ne(e,t)))),r}function Ne(t,r=new Ee){switch(t.kind){case T:return[[t.trusted?s.TrustingAppend:s.Append,je(t.path,r)]];case N:return[[t.trusted?s.TrustingAppend:s.Append,De(t.expr,t.trusted?"TrustedAppend":"Append",r)]];case B:{let{head:e,params:a,hash:o,trusted:l}=t,i=a?Re(a,r):null,c=o?qe(o,r):null,u=_e(e,l?n.ResolveAsHelperHead:n.ResolveAsComponentOrHelperHead,r);return[[l?s.TrustingAppend:s.Append,[s.Call,u,i,c]]]}case $:return[[s.Append,t.value]];case H:return[[s.Comment,t.value]];case C:{let e=function(e,t,r){let n=[],s=[];for(const[a,o]of Object.entries(e))if(n.push(a),"default"===a){let e=r.child(t||[]);s.push(Ke(o,e,e.paramSymbols))}else s.push(Ke(o,r,[]));return[n,s]}(t.blocks,t.blockParams,r),a=qe(t.hash,r),o=Re(t.params,r),l=_e(t.head,n.ResolveAsComponentHead,r);return[[s.Block,l,o,a,e]]}case M:return[Le(t,r)];case O:return function({name:t,attrs:r,block:n},a){let o=[Me(r)?[s.OpenElementWithSplat,t]:[s.OpenElement,t]];if(r){let{params:e,args:t}=function(e,t){let r=[],n=[],a=[];for(const[o,l]of Object.entries(e))l===L?r.push([s.AttrSplat,t.block("&attrs")]):"@"===o[0]?(n.push(o),a.push(De(l,"Strict",t))):r.push(...Ve(o,l,Ge(o),t));return{params:r,args:ee(n)&&ee(a)?[n,a]:null}}(r,a);o.push(...e)}if(o.push([s.FlushElement]),Array.isArray(n))n.forEach((e=>o.push(...Ne(e,a))));else if(null!==n)throw e(n);return o.push([s.CloseElement]),o}(t,r);case I:throw Be("modifier");case P:throw Be("dynamic component");default:throw e(t)}}function $e(e,...t){return[0,e.reduce(((e,r,n)=>e+`${r}${t[n]?String(t[n]):""}`),"")]}function Ie(e,...t){return[1,e.reduce(((e,r,n)=>e+`${r}${t[n]?String(t[n]):""}`),"")]}function Pe(e){return String.fromCharCode(parseInt(e,16))}const He="\n";function Le(e,t){let{name:r}=e,n=Re(e.params,t),a=t.child(e.blockParams||[]),o=Ke(e.blocks.default,a,a.paramSymbols),l=e.blocks.else?Ke(e.blocks.else,t,[]):null;switch(r){case"let":return[s.Let,Q(n),o];case"if":return[s.If,Q(n)[0],o,l];case"each":{let r=e.hash?e.hash.key:null,a=r?De(r,"Strict",t):null;return[s.Each,Q(n)[0],a,o,l]}default:throw new Error("unimplemented keyword")}}function Me(e){return null!==e&&Object.keys(e).some((t=>e[t]===L))}function Ge(e){if("xmlns"===e)return X;let t=/^([^:]*):([^:]*)$/u.exec(e);if(null===t)return null;switch(t[1]){case"xlink":return"http://www.w3.org/1999/xlink";case"xml":return"http://www.w3.org/XML/1998/namespace";case"xmlns":return X}return null}function Ve(e,t,r,n){if(t.type===_){let n=t.value;if(!1===n)return[];if(!0===n)return[[s.StaticAttr,e,"",r??void 0]];if("string"==typeof n)return[[s.StaticAttr,e,n,r??void 0]];throw new Error(`Unexpected/unimplemented literal attribute ${JSON.stringify(n)}`)}return[[s.DynamicAttr,e,De(t,"AttrValue",n),r??void 0]]}function Fe(e,t){switch(e){case"Append":return t?"AppendBare":"AppendInvoke";case"TrustedAppend":return t?"TrustedAppendBare":"TrustedAppendInvoke";case"AttrValue":return t?"AttrValueBare":"AttrValueInvoke";default:return e}}function De(t,r,a){switch(t.type){case z:return je(t,a);case R:return ze(t.variable,Fe(r,!0),a);case W:return[s.Concat,We(t.params,a)];case j:{let e=Re(t.params,a),n=qe(t.hash,a),o=_e(t.head,"Strict"===r?"SubExpression":Fe(r,!1),a);return[s.Call,o,e,n]}case q:return[s.HasBlock,ze({kind:F,name:t.name,mode:"loose"},n.Strict,a)];case K:return[s.HasBlockParams,ze({kind:F,name:t.name,mode:"loose"},n.Strict,a)];case _:return void 0===t.value?[s.Undefined]:t.value;default:e(t)}}function _e(e,t,r){return e.type===R?ze(e.variable,t,r):je(e,r)}function je(e,t){return ze(e.path.head,n.Strict,t,e.path.tail)}function ze(e,t,r,a){let o,l=s.GetSymbol;return e.kind===V?(l="Strict"===t?s.GetStrictKeyword:"AppendBare"===t||"AppendInvoke"===t?s.GetFreeAsComponentOrHelperHead:"TrustedAppendBare"===t||"TrustedAppendInvoke"===t||"AttrValueBare"===t||"AttrValueInvoke"===t||"SubExpression"===t?s.GetFreeAsHelperHead:function(e){switch(e){case n.Strict:return s.GetStrictKeyword;case n.ResolveAsComponentOrHelperHead:return s.GetFreeAsComponentOrHelperHead;case n.ResolveAsHelperHead:return s.GetFreeAsHelperHead;case n.ResolveAsModifierHead:return s.GetFreeAsModifierHead;case n.ResolveAsComponentHead:return s.GetFreeAsComponentHead;default:return}}(t),o=r.freeVar(e.name)):(l=s.GetSymbol,o=function(e,t,r){switch(e){case"Arg":return t.arg(r);case F:return t.block(r);case G:return t.local(r);case D:return t.this();default:return}}(e.kind,r,e.name)),void 0===a||0===a.length?[l,o]:(s.GetStrictKeyword,[l,o,a])}function Re(e,t){return null!==e&&ee(e)?e.map((e=>De(e,"Strict",t))):null}function We(e,t){return e.map((e=>De(e,"AttrValue",t)))}function qe(e,t){if(null===e)return null;let r=[[],[]];for(const[n,s]of Object.entries(e))r[0].push(n),r[1].push(De(s,"Strict",t));return r}function Ke(e,t,r=[]){return[Te(e,t),r]}const Ue=["background-color: oklch(93% 0.03 300); color: oklch(34% 0.18 300)","background-color: oklch(93% 0.03 250); color: oklch(34% 0.18 250)","background-color: oklch(93% 0.03 200); color: oklch(34% 0.18 200)","background-color: oklch(93% 0.03 150); color: oklch(34% 0.18 150)","background-color: oklch(93% 0.03 100); color: oklch(34% 0.18 100)","background-color: oklch(93% 0.03 50); color: oklch(34% 0.18 50)","background-color: oklch(93% 0.03 0); color: oklch(34% 0.18 0)"];class Je{#e="";#t=[];#r;#n=[];#s=1;#a=0;constructor(e){this.#r=e}addFootnoted(e,t){if(e&&!this.#r.showSubtle)return;const r=new Je(this.#r),n=Ue[this.#a++%Ue.length];t({n:this.#s,style:n},r)&&(this.#s+=1),this.#n.push({type:"line",subtle:!1,template:r.#e,substitutions:r.#t}),this.#n.push(...r.#n)}append(e,t,...r){e&&!this.#r.showSubtle||(this.#e+=t,this.#t.push(...r))}#o(e){return e.subtle&&!this.#r.showSubtle?[]:[{type:"line",line:[e.template,...e.substitutions]}]}flush(){return[{type:"line",line:[this.#e,...this.#t]},...this.#n.flatMap((e=>this.#o(e)))]}}const Ye={var:"color: grey",varReference:"color: blue; text-decoration: underline",varBinding:"color: blue;",specialVar:"color: blue",prop:"color: grey",specialProp:"color: red",token:"color: green",def:"color: blue",builtin:"color: blue",punct:"color: GrayText",kw:"color: rgb(185 0 99 / 100%);",type:"color: teal",number:"color: blue",string:"color: red",null:"color: grey",specialString:"color: darkred",atom:"color: blue",attrName:"color: orange",attrValue:"color: blue",boolean:"color: blue",comment:"color: green",meta:"color: grey",register:"color: purple",constant:"color: purple",dim:"color: grey",internals:"color: lightgrey; font-style: italic",diffAdd:"color: Highlight",diffDelete:"color: SelectedItemText; background-color: SelectedItem",diffChange:"color: MarkText; background-color: Mark",sublabel:"font-style: italic; color: grey",error:"color: red",label:"text-decoration: underline",errorLabel:"color: darkred; font-style: italic",errorMessage:"color: darkred; text-decoration: underline",stack:"color: grey; font-style: italic",unbold:"font-weight: normal",pointer:"background-color: lavender; color: indigo",pointee:"background-color: lavender; color: indigo",focus:"font-weight: bold",focusColor:"background-color: lightred; color: darkred"};function Xe(...e){return e.map((e=>{return(t=e,"string"==typeof t?{style:Ye[t]}:t).style;var t})).join("; ")}const Ze={value:"%O",string:"%s",integer:"%d",float:"%f",special:"%o"};class Qe{static integer(e,t){return new Qe({kind:"integer",value:e,...t})}static float(e,t){return new Qe({kind:"float",value:e,...t})}static string(e,t){return new Qe({kind:"string",value:e,...t})}static special(e,t){return new Qe({kind:"special",value:e,...t})}#l;constructor(e){this.#l=e}isSubtle(){return this.leaves().every((e=>e.#l.subtle))}map(e){if(this.isEmpty())return this;const t=e(this);return this.isSubtle()?t.subtle():t}isEmpty(e={showSubtle:!0}){return this.leaves().every((t=>!t.#i(e)))}leaves(){return"multi"===this.#l.kind?this.#l.value.flatMap((e=>e.leaves())):"string"===this.#l.kind&&""===this.#l.value?[]:[this]}subtle(e=!0){if(!1===this.isSubtle()&&!1===e)return this;const t=this.#c(e);return e?t.styleAll("dim"):t}#c(e){return"multi"===this.#l.kind?new Qe({...this.#l,value:this.leaves().flatMap((t=>t.subtle(e).leaves()))}):new Qe({...this.#l,subtle:e})}styleAll(...e){return 0===e.length?this:"multi"===this.#l.kind?new Qe({...this.#l,value:this.#l.value.flatMap((t=>t.styleAll(...e).leaves()))}):new Qe({...this.#l,style:(t=this.#l.style,r=Xe(...e),t&&r?`${t}; ${r}`:t||r)});var t,r}stringify(e){return this.leaves().filter((t=>t.#i(e))).map((e=>{const t=e.#l;return"value"===t.kind?"<object>":String(t.value)})).join("")}#i(e){return this.leaves().some((t=>{const r=t.#l;return!(r.subtle&&!e.showSubtle||"string"===r.kind&&""===r.value)}))}toLoggable(e){const t=new Je(e);for(const e of this.leaves())e.appendTo(t);return t.flush()}appendTo(e){const t=this.#l,r=this.isSubtle();if("multi"!==t.kind){if("value"===t.kind){if("string"==typeof t.value)return Qe.string(JSON.stringify(t.value),{style:Ye.string,subtle:r}).appendTo(e);if("number"==typeof t.value)return(t.value%1==0?Qe.integer:Qe.float)(t.value,{style:Ye.number,subtle:r}).appendTo(e);if(null===t.value||void 0===t.value)return Qe.string("null",{style:Ye.null,subtle:this.isSubtle()}).appendTo(e);if("boolean"==typeof t.value)return Qe.string(String(t.value),{style:Ye.boolean,subtle:r}).appendTo(e)}switch(t.kind){case"string":case"integer":case"float":e.append(t.subtle??!1,`%c${Ze[t.kind]}`,t.style,t.value);break;case"special":case"value":{const n="value"===t.kind?t.display:void 0;e.addFootnoted(t.subtle??!1,(({n:s,style:a},o)=>{const l=e=>o.append(r,`%c| %c[${e}]%c ${Ze[t.kind]}`,Ye.dim,a,"",t.value);return n?"inline"in n?(n.inline.subtle(r).appendTo(o),!1):(e.append(r,`%c[${n.ref}]%c`,a,""),n.footnote?nt`${st.dim("| ")}${n.footnote}`.subtle(r).appendTo(o):l(n.ref),!1):(e.append(r,`%c[${s}]%c`,a,""),l(String(s)),!0)}));break}default:!function(e,t="unexpected unreachable branch"){throw Z.log("unreachable",e),Z.log(`${t} :: ${JSON.stringify(e)} (${e})`),new Error("code reached unreachable")}(t)}}else for(const r of t.value)r.appendTo(e)}}function et(e){const t=tt(e),[r,...n]=t;return void 0!==r&&0===n.length?r:new Qe({kind:"multi",value:t})}function tt(e){return Array.isArray(e)?e.flatMap(tt):"object"==typeof e&&null!==e?e.leaves():[rt(e)]}function rt(e){return null===e?new Qe({kind:"value",value:null}):"number"==typeof e?new Qe({kind:"integer",value:e}):"string"==typeof e?/^[\s\p{P}\p{Sm}]*$/u.test(e)?new Qe({kind:"string",value:e,style:Ye.punct}):new Qe({kind:"string",value:e}):e}function nt(e,...t){const r=[];return e.forEach(((e,n)=>{r.push(...et(e).leaves());const s=t[n];s&&r.push(...et(s).leaves())})),new Qe({kind:"multi",value:r})}const st=Object.fromEntries(Object.entries(Ye).map((([e,t])=>[e,e=>et(e).styleAll({style:t})]))),at=({label:e,value:t})=>["error:operand",t,{label:e}];class ot{static build(e){return e(new ot).#u}#u;constructor(){this.#u={}}addNullable(e,t){for(const r of e)this.#u[r]=t,this.#u[`${r}?`]=t;return this}add(e,t){const r=(e,t)=>this.#u[e]=t;for(const n of e)r(n,t);return this}}function lt(e){switch(e){case 0:return"component";case 1:return"helper";case 2:return"modifier";default:throw Error(`Unexpected curry value: ${e}`)}}function it(e){switch(e){case S:return"$pc";case E:return"$ra";case x:return"$fp";case A:return"$sp";case w:return"$s0";case b:return"$s1";case v:return"$t0";case g:return"$t1";case k:return"$v0";default:return`$bug${e}`}}function ct(e,t){return e>=0?t.getValue(e):ne(e)}ot.build((e=>e.add(["imm/u32","imm/i32","imm/u32{todo}","imm/i32{todo}"],(({value:e})=>["number",e])).add(["const/i32[]"],(({value:e,constants:t})=>["array",t.getArray(e),{kind:Number}])).add(["const/bool"],(({value:e})=>["boolean",!!e])).add(["imm/bool"],(({value:e,constants:t})=>["boolean",t.getValue(e)])).add(["handle"],(({constants:e,value:t})=>["constant",e.getValue(t)])).add(["handle/block"],(({value:e,heap:t})=>["instruction",t.getaddr(e)])).add(["imm/pc"],(({value:e})=>["instruction",e])).add(["const/any[]"],(({value:e,constants:t})=>["array",t.getArray(e)])).add(["const/primitive"],(({value:e,constants:t})=>["primitive",ct(e,t)])).add(["register"],(({value:e})=>["register",it(e)])).add(["const/any"],(({value:e,constants:t})=>["dynamic",t.getValue(e)])).add(["variable"],(({value:e,meta:t})=>["variable",e,{name:t?.symbols.lexical?.at(e)??null}])).add(["register/instruction"],(({value:e})=>["instruction",e])).add(["imm/enum<curry>"],(({value:e})=>["enum<curry>",lt(e)])).addNullable(["const/str"],(({value:e,constants:t})=>["string",t.getValue(e)])).addNullable(["const/str[]"],(({value:e,constants:t})=>["array",t.getArray(e),{kind:String}])).add(["imm/block:handle"],at).add(["const/definition"],at).add(["const/fn"],at).add(["instruction/relative"],(({value:e,offset:t})=>["instruction",t+e])).add(["register/sN"],at).add(["register/stack"],at).add(["register/tN"],at).add(["register/v0"],at))),new Array(113).fill(null),new Array(7).fill(null);class ut extends(l("Template").fields()){}class dt extends(l("InElement").fields()){}class pt extends(l("Not").fields()){}class mt extends(l("If").fields()){}class ht extends(l("IfInline").fields()){}class ft extends(l("Each").fields()){}class yt extends(l("Let").fields()){}class kt extends(l("WithDynamicVars").fields()){}class gt extends(l("GetDynamicVar").fields()){}class vt extends(l("Log").fields()){}class bt extends(l("InvokeComponent").fields()){}class wt extends(l("NamedBlocks").fields()){}class At extends(l("NamedBlock").fields()){}class xt extends(l("AppendTrustedHTML").fields()){}class Et extends(l("AppendTextNode").fields()){}class St extends(l("AppendComment").fields()){}class Ct extends(l("Component").fields()){}class Bt extends(l("StaticAttr").fields()){}class Ot extends(l("DynamicAttr").fields()){}class Tt extends(l("SimpleElement").fields()){}class Nt extends(l("ElementParameters").fields()){}class $t extends(l("Yield").fields()){}class It extends(l("Debugger").fields()){}class Pt extends(l("CallExpression").fields()){}class Ht extends(l("Modifier").fields()){}class Lt extends(l("InvokeBlock").fields()){}class Mt extends(l("SplatAttr").fields()){}class Gt extends(l("PathExpression").fields()){}class Vt extends(l("Missing").fields()){}class Ft extends(l("InterpolateExpression").fields()){}class Dt extends(l("HasBlock").fields()){}class _t extends(l("HasBlockParams").fields()){}class jt extends(l("Curry").fields()){}class zt extends(l("Positional").fields()){}class Rt extends(l("NamedArguments").fields()){}class Wt extends(l("NamedArgument").fields()){}class qt extends(l("Args").fields()){}class Kt extends(l("Tail").fields()){}class Ut{constructor(e){this.list=e}toArray(){return this.list}map(e){let t=te(this.list,e);return new Ut(t)}filter(e){let t=[];for(let r of this.list)e(r)&&t.push(r);return Yt(t)}toPresentArray(){return this.list}into({ifPresent:e}){return e(this)}}class Jt{list=[];map(e){return new Jt}filter(e){return new Jt}toArray(){return this.list}toPresentArray(){return null}into({ifEmpty:e}){return e()}}function Yt(e){return ee(e)?new Ut(e):new Jt}class Xt{static all(...e){let t=[];for(let r of e){if(r.isErr)return r.cast();t.push(r.value)}return tr(t)}}const Zt=Xt;class Qt extends Xt{isOk=!0;isErr=!1;constructor(e){super(),this.value=e}expect(e){return this.value}ifOk(e){return e(this.value),this}andThen(e){return e(this.value)}mapOk(e){return tr(e(this.value))}ifErr(e){return this}mapErr(e){return this}}class er extends Xt{isOk=!1;isErr=!0;constructor(e){super(),this.reason=e}expect(e){throw new Error(e||"expected an Ok, got Err")}andThen(e){return this.cast()}mapOk(e){return this.cast()}ifOk(e){return this}mapErr(e){return rr(e(this.reason))}ifErr(e){return e(this.reason),this}cast(){return this}}function tr(e){return new Qt(e)}function rr(e){return new er(e)}class nr{constructor(e=[]){this.items=e}add(e){this.items.push(e)}toArray(){let e=this.items.filter((e=>e instanceof er))[0];return void 0!==e?e.cast():tr(this.items.map((e=>e.value)))}toOptionalList(){return this.toArray().mapOk((e=>Yt(e)))}}function sr(e){return"Path"===e.type&&"Free"===e.ref.type&&e.ref.name in i?new c.CallExpression({callee:e,args:c.Args.empty(e.loc),loc:e.loc}):e}const ar=new class{visit(e,t){switch(e.type){case"Literal":return tr(this.Literal(e));case"Keyword":return tr(this.Keyword(e));case"Interpolate":return this.Interpolate(e,t);case"Path":return this.PathExpression(e);case"Call":{let r=Br.translate(e,t);return null!==r?r:this.CallExpression(e,t)}}}visitList(e,t){return new nr(e.map((e=>ar.visit(e,t)))).toOptionalList()}PathExpression(e){let t=this.VariableReference(e.ref),{tail:r}=e;if(ee(r)){let s=r[0].loc.extend((n=r,0===n.length?void 0:n[n.length-1]).loc);return tr(new Gt({loc:e.loc,head:t,tail:new Kt({loc:s,members:r})}))}return tr(t);var n}VariableReference(e){return e}Literal(e){return e}Keyword(e){return e}Interpolate(e,t){let r=e.parts.map(sr);return ar.visitList(r,t).mapOk((t=>new Ft({loc:e.loc,parts:t})))}CallExpression(e,t){if("Call"===e.callee.type)throw new Error("unimplemented: subexpression at the head of a subexpression");return Zt.all(ar.visit(e.callee,t),ar.Args(e.args,t)).mapOk((([t,r])=>new Pt({loc:e.loc,callee:t,args:r})))}Args({positional:e,named:t,loc:r},n){return Zt.all(this.Positional(e,n),this.NamedArguments(t,n)).mapOk((([e,t])=>new qt({loc:r,positional:e,named:t})))}Positional(e,t){return ar.visitList(e.exprs,t).mapOk((t=>new zt({loc:e.loc,list:t})))}NamedArguments(e,t){let r=e.entries.map((e=>{let r=sr(e.value);return ar.visit(r,t).mapOk((t=>new Wt({loc:e.loc,key:e.name,value:t})))}));return new nr(r).toOptionalList().mapOk((t=>new Rt({loc:e.loc,entries:t})))}};class or{types;constructor(e,t,r){this.keyword=e,this.delegate=r;let n=new Set;for(let e of lr[t])n.add(e);this.types=n}match(e){if(!this.types.has(e.type))return!1;let t=ir(e);return null!==t&&"Path"===t.type&&"Free"===t.ref.type&&t.ref.name===this.keyword}translate(e,t){if(this.match(e)){let r=ir(e);return null!==r&&"Path"===r.type&&r.tail.length>0?rr(d(`The \`${this.keyword}\` keyword was used incorrectly. It was used as \`${r.loc.asString()}\`, but it cannot be used with additional path segments. \n\nError caused by`,e.loc)):this.delegate.assert(e,t).andThen((r=>this.delegate.translate({node:e,state:t},r)))}return null}}const lr={Call:["Call"],Block:["InvokeBlock"],Append:["AppendContent"],Modifier:["ElementModifier"]};function ir(e){switch(e.type){case"Path":return e;case"AppendContent":return ir(e.value);case"Call":case"InvokeBlock":case"ElementModifier":return e.callee;default:return null}}class cr{_keywords=[];_type;constructor(e){this._type=e}kw(e,t){return this._keywords.push(function(e,t,r){return new or(e,t,r)}(e,this._type,t)),this}translate(e,t){for(let r of this._keywords){let n=r.translate(e,t);if(null!==n)return n}let r=ir(e);if(r&&"Path"===r.type&&"Free"===r.ref.type&&u(r.ref.name)){let{name:t}=r.ref,n=this._type,s=i[t];if(!s.includes(n))return rr(d(`The \`${t}\` keyword was used incorrectly. It was used as ${ur[n]}, but its valid usages are:\n\n${function(e,t){return t.map((t=>{switch(t){case"Append":return`- As an append statement, as in: {{${e}}}`;case"Block":return`- As a block statement, as in: {{#${e}}}{{/${e}}}`;case"Call":return`- As an expression, as in: (${e})`;case"Modifier":return`- As a modifier, as in: <div {{${e}}}></div>`;default:return}})).join("\n\n")}(t,s)}\n\nError caused by`,e.loc))}return null}}const ur={Append:"an append statement",Block:"a block statement",Call:"a call expression",Modifier:"a modifier"};function dr(e){return new cr(e)}function pr({assert:e,translate:t}){return{assert:e,translate:({node:e,state:r},n)=>t({node:e,state:r},n).mapOk((t=>new Et({text:t,loc:e.loc})))}}const mr={[U]:"component",[J]:"helper",[Y]:"modifier"};function hr(e){return(t,r)=>{let n=mr[e],s=0===e,{args:a}=t,o=a.nth(0);if(null===o)return rr(d(`(${n}) requires a ${n} definition or identifier as its first positional parameter, did not receive any parameters.`,a.loc));if("Literal"===o.type){if(s&&r.isStrict)return rr(d(`(${n}) cannot resolve string values in strict mode templates`,t.loc));if(!s)return rr(d(`(${n}) cannot resolve string values, you must pass a ${n} definition directly`,t.loc))}return a=new c.Args({positional:new c.PositionalArguments({exprs:a.positional.exprs.slice(1),loc:a.positional.loc}),named:a.named,loc:a.loc}),tr({definition:o,args:a})}}function fr(e){return({node:t,state:r},{definition:n,args:s})=>{let a=ar.visit(n,r),o=ar.Args(s,r);return Zt.all(a,o).mapOk((([r,n])=>new jt({loc:t.loc,curriedType:e,definition:r,args:n})))}}function yr(e){return{assert:hr(e),translate:fr(e)}}const kr={assert:function(e){let t="AppendContent"===e.type?e.value:e,r="Call"===t.type?t.args.named:null,n="Call"===t.type?t.args.positional:null;if(r&&!r.isEmpty())return rr(d("(-get-dynamic-vars) does not take any named arguments",e.loc));let s=n?.nth(0);return s?n&&n.size>1?rr(d("(-get-dynamic-vars) only receives one positional arg",e.loc)):tr(s):rr(d("(-get-dynamic-vars) requires a var name to get",e.loc))},translate:function({node:e,state:t},r){return ar.visit(r,t).mapOk((t=>new gt({name:t,loc:e.loc})))}};function gr(e){return t=>{let r="AppendContent"===t.type?t.value:t,n="Call"===r.type?r.args.named:null,s="Call"===r.type?r.args.positional:null;if(n&&!n.isEmpty())return rr(d(`(${e}) does not take any named arguments`,r.loc));if(!s||s.isEmpty())return tr(p.synthetic("default"));if(1===s.exprs.length){let t=s.exprs[0];return c.isLiteral(t,"string")?tr(t.toSlice()):rr(d(`(${e}) can only receive a string literal as its first argument`,r.loc))}return rr(d(`(${e}) only takes a single positional argument`,r.loc))}}function vr(e){return({node:t,state:{scope:r}},n)=>tr("has-block"===e?new Dt({loc:t.loc,target:n,symbol:r.allocateBlock(n.chars)}):new _t({loc:t.loc,target:n,symbol:r.allocateBlock(n.chars)}))}function br(e){return{assert:gr(e),translate:vr(e)}}function wr(e){return t=>{let r="unless"===e,n="AppendContent"===t.type?t.value:t,s="Call"===n.type?n.args.named:null,a="Call"===n.type?n.args.positional:null;if(s&&!s.isEmpty())return rr(d(`(${e}) cannot receive named parameters, received ${s.entries.map((e=>e.name.chars)).join(", ")}`,t.loc));let o=a?.nth(0);if(!a||!o)return rr(d(`When used inline, (${e}) requires at least two parameters 1. the condition that determines the state of the (${e}), and 2. the value to return if the condition is ${r?"false":"true"}. Did not receive any parameters`,t.loc));let l=a.nth(1),i=a.nth(2);return null===l?rr(d(`When used inline, (${e}) requires at least two parameters 1. the condition that determines the state of the (${e}), and 2. the value to return if the condition is ${r?"false":"true"}. Received only one parameter, the condition`,t.loc)):a.size>3?rr(d(`When used inline, (${e}) can receive a maximum of three positional parameters 1. the condition that determines the state of the (${e}), 2. the value to return if the condition is ${r?"false":"true"}, and 3. the value to return if the condition is ${r?"true":"false"}. Received ${a?.size??0} parameters`,t.loc)):tr({condition:o,truthy:l,falsy:i})}}function Ar(e){let t="unless"===e;return({node:e,state:r},{condition:n,truthy:s,falsy:a})=>{let o=ar.visit(n,r),l=ar.visit(s,r),i=a?ar.visit(a,r):tr(null);return Zt.all(o,l,i).mapOk((([r,n,s])=>(t&&(r=new pt({value:r,loc:e.loc})),new ht({loc:e.loc,condition:r,truthy:n,falsy:s}))))}}function xr(e){return{assert:wr(e),translate:Ar(e)}}const Er={assert:function(e){let{args:{named:t,positional:r}}=e;return t&&!t.isEmpty()?rr(d("(log) does not take any named arguments",e.loc)):tr(r)},translate:function({node:e,state:t},r){return ar.Positional(r,t).mapOk((t=>new vt({positional:t,loc:e.loc})))}},Sr=dr("Append").kw("has-block",pr(br("has-block"))).kw("has-block-params",pr(br("has-block-params"))).kw("-get-dynamic-var",pr(kr)).kw("log",pr(Er)).kw("if",pr(xr("if"))).kw("unless",pr(xr("unless"))).kw("yield",{assert(e){let{args:t}=e;if(t.named.isEmpty())return tr({target:m.SourceSpan.synthetic("default").toSlice(),positional:t.positional});{let e=t.named.get("to");return t.named.size>1||null===e?rr(d("yield only takes a single named argument: 'to'",t.named.loc)):c.isLiteral(e,"string")?tr({target:e.toSlice(),positional:t.positional}):rr(d("you can only yield to a literal string value",e.loc))}},translate:({node:e,state:t},{target:r,positional:n})=>ar.Positional(n,t).mapOk((n=>new $t({loc:e.loc,target:r,to:t.scope.allocateBlock(r.chars),positional:n})))}).kw("debugger",{assert(e){let{args:t}=e,{positional:r}=t;return t.isEmpty()?tr(void 0):r.isEmpty()?rr(d("debugger does not take any named arguments",e.loc)):rr(d("debugger does not take any positional arguments",e.loc))},translate:({node:e,state:{scope:t}})=>tr(new It({loc:e.loc,scope:t}))}).kw("component",{assert:hr(0),translate({node:e,state:t},{definition:r,args:n}){let s=ar.visit(r,t),a=ar.Args(n,t);return Zt.all(s,a).mapOk((([t,r])=>new bt({loc:e.loc,definition:t,args:r,blocks:null})))}}).kw("helper",{assert:hr(1),translate({node:e,state:t},{definition:r,args:n}){let s=ar.visit(r,t),a=ar.Args(n,t);return Zt.all(s,a).mapOk((([t,r])=>{let n=new Pt({callee:t,args:r,loc:e.loc});return new Et({loc:e.loc,text:n})}))}}),Cr=dr("Block").kw("in-element",{assert(e){let{args:t}=e,r=t.get("guid");if(r)return rr(d("Cannot pass `guid` to `{{#in-element}}`",r.loc));let n=t.get("insertBefore"),s=t.nth(0);return null===s?rr(d("{{#in-element}} requires a target element as its first positional parameter",t.loc)):tr({insertBefore:n,destination:s})},translate({node:e,state:t},{insertBefore:r,destination:n}){let s=e.blocks.get("default"),a=zr.NamedBlock(s,t),o=ar.visit(n,t);return Zt.all(a,o).andThen((([n,s])=>r?ar.visit(r,t).mapOk((e=>({body:n,destination:s,insertBefore:e}))):tr({body:n,destination:s,insertBefore:new Vt({loc:e.callee.loc.collapse("end")})}))).mapOk((({body:r,destination:n,insertBefore:s})=>new dt({loc:e.loc,block:r,insertBefore:s,guid:t.generateUniqueCursor(),destination:n})))}}).kw("if",{assert(e){let{args:t}=e;if(!t.named.isEmpty())return rr(d(`{{#if}} cannot receive named parameters, received ${t.named.entries.map((e=>e.name.chars)).join(", ")}`,e.loc));if(t.positional.size>1)return rr(d(`{{#if}} can only receive one positional parameter in block form, the conditional value. Received ${t.positional.size} parameters`,e.loc));let r=t.nth(0);return null===r?rr(d("{{#if}} requires a condition as its first positional parameter, did not receive any parameters",e.loc)):tr({condition:r})},translate({node:e,state:t},{condition:r}){let n=e.blocks.get("default"),s=e.blocks.get("else"),a=ar.visit(r,t),o=zr.NamedBlock(n,t),l=s?zr.NamedBlock(s,t):tr(null);return Zt.all(a,o,l).mapOk((([t,r,n])=>new mt({loc:e.loc,condition:t,block:r,inverse:n})))}}).kw("unless",{assert(e){let{args:t}=e;if(!t.named.isEmpty())return rr(d(`{{#unless}} cannot receive named parameters, received ${t.named.entries.map((e=>e.name.chars)).join(", ")}`,e.loc));if(t.positional.size>1)return rr(d(`{{#unless}} can only receive one positional parameter in block form, the conditional value. Received ${t.positional.size} parameters`,e.loc));let r=t.nth(0);return null===r?rr(d("{{#unless}} requires a condition as its first positional parameter, did not receive any parameters",e.loc)):tr({condition:r})},translate({node:e,state:t},{condition:r}){let n=e.blocks.get("default"),s=e.blocks.get("else"),a=ar.visit(r,t),o=zr.NamedBlock(n,t),l=s?zr.NamedBlock(s,t):tr(null);return Zt.all(a,o,l).mapOk((([t,r,n])=>new mt({loc:e.loc,condition:new pt({value:t,loc:e.loc}),block:r,inverse:n})))}}).kw("each",{assert(e){let{args:t}=e;if(!t.named.entries.every((e=>"key"===e.name.chars)))return rr(d(`{{#each}} can only receive the 'key' named parameter, received ${t.named.entries.filter((e=>"key"!==e.name.chars)).map((e=>e.name.chars)).join(", ")}`,t.named.loc));if(t.positional.size>1)return rr(d(`{{#each}} can only receive one positional parameter, the collection being iterated. Received ${t.positional.size} parameters`,t.positional.loc));let r=t.nth(0),n=t.get("key");return null===r?rr(d("{{#each}} requires an iterable value to be passed as its first positional parameter, did not receive any parameters",t.loc)):tr({value:r,key:n})},translate({node:e,state:t},{value:r,key:n}){let s=e.blocks.get("default"),a=e.blocks.get("else"),o=ar.visit(r,t),l=n?ar.visit(n,t):tr(null),i=zr.NamedBlock(s,t),c=a?zr.NamedBlock(a,t):tr(null);return Zt.all(o,l,i,c).mapOk((([t,r,n,s])=>new ft({loc:e.loc,value:t,key:r,block:n,inverse:s})))}}).kw("let",{assert(e){let{args:t}=e;return t.named.isEmpty()?0===t.positional.size?rr(d("{{#let}} requires at least one value as its first positional parameter, did not receive any parameters",t.positional.loc)):e.blocks.get("else")?rr(d("{{#let}} cannot receive an {{else}} block",t.positional.loc)):tr({positional:t.positional}):rr(d(`{{#let}} cannot receive named parameters, received ${t.named.entries.map((e=>e.name.chars)).join(", ")}`,t.named.loc))},translate({node:e,state:t},{positional:r}){let n=e.blocks.get("default"),s=ar.Positional(r,t),a=zr.NamedBlock(n,t);return Zt.all(s,a).mapOk((([t,r])=>new yt({loc:e.loc,positional:t,block:r})))}}).kw("-with-dynamic-vars",{assert:e=>tr({named:e.args.named}),translate({node:e,state:t},{named:r}){let n=e.blocks.get("default"),s=ar.NamedArguments(r,t),a=zr.NamedBlock(n,t);return Zt.all(s,a).mapOk((([t,r])=>new kt({loc:e.loc,named:t,block:r})))}}).kw("component",{assert:hr(0),translate({node:e,state:t},{definition:r,args:n}){let s=ar.visit(r,t),a=ar.Args(n,t),o=zr.NamedBlocks(e.blocks,t);return Zt.all(s,a,o).mapOk((([t,r,n])=>new bt({loc:e.loc,definition:t,args:r,blocks:n})))}}),Br=dr("Call").kw("has-block",br("has-block")).kw("has-block-params",br("has-block-params")).kw("-get-dynamic-var",kr).kw("log",Er).kw("if",xr("if")).kw("unless",xr("unless")).kw("component",yr(0)).kw("helper",yr(1)).kw("modifier",yr(2)),Or=dr("Modifier"),Tr="http://www.w3.org/1999/xlink",Nr="http://www.w3.org/XML/1998/namespace",$r="http://www.w3.org/2000/xmlns/",Ir={"xlink:actuate":Tr,"xlink:arcrole":Tr,"xlink:href":Tr,"xlink:role":Tr,"xlink:show":Tr,"xlink:title":Tr,"xlink:type":Tr,"xml:base":Nr,"xml:lang":Nr,"xml:space":Nr,xmlns:$r,"xmlns:xlink":$r},Pr={div:a.div,span:a.span,p:a.p,a:a.a},Hr=["div","span","p","a"];function Lr(e){return"string"==typeof e?e:Hr[e]}const Mr={class:o.class,id:o.id,value:o.value,name:o.name,type:o.type,style:o.style,href:o.href},Gr=["class","id","value","name","type","style","href"];function Vr(e){return Mr[e]??e}function Fr(e){return"string"==typeof e?e:Gr[e]}class Dr{delegate;constructor(e,t,r){this.element=e,this.state=r,this.delegate=t}toStatement(){return this.prepare().andThen((e=>this.delegate.toStatement(this,e)))}attr(e){let t=e.name,r=e.value,n=(s=t.chars,Ir[s]||void 0);var s;return c.isLiteral(r,"string")?tr(new Bt({loc:e.loc,name:t,value:r.toSlice(),namespace:n,kind:{component:this.delegate.dynamicFeatures}})):ar.visit(sr(r),this.state).mapOk((r=>{let s=e.trusting;return new Ot({loc:e.loc,name:t,value:r,namespace:n,kind:{trusting:s,component:this.delegate.dynamicFeatures}})}))}modifier(e){let t=Or.translate(e,this.state);if(null!==t)return t;let r=ar.visit(e.callee,this.state),n=ar.Args(e.args,this.state);return Zt.all(r,n).mapOk((([t,r])=>new Ht({loc:e.loc,callee:t,args:r})))}attrs(){let e=new nr,t=new nr,r=null,n=0===this.element.attrs.filter((e=>"SplatAttr"===e.type)).length;for(let t of this.element.attrs)"SplatAttr"===t.type?e.add(tr(new Mt({loc:t.loc,symbol:this.state.scope.allocateBlock("attrs")}))):"type"===t.name.chars&&n?r=t:e.add(this.attr(t));for(let e of this.element.componentArgs)t.add(this.delegate.arg(e,this));return r&&e.add(this.attr(r)),Zt.all(t.toArray(),e.toArray()).mapOk((([e,t])=>({attrs:t,args:new Rt({loc:h(e,m.SourceSpan.NON_EXISTENT),entries:Yt(e)})})))}prepare(){let e=this.attrs(),t=new nr(this.element.modifiers.map((e=>this.modifier(e)))).toArray();return Zt.all(e,t).mapOk((([e,t])=>{let{attrs:r,args:n}=e,s=[...r,...t];return{args:n,params:new Nt({loc:h(s,m.SourceSpan.NON_EXISTENT),body:Yt(s)})}}))}}class _r{dynamicFeatures=!0;constructor(e,t){this.tag=e,this.element=t}arg(e,{state:t}){let r=e.name;return ar.visit(sr(e.value),t).mapOk((t=>new Wt({loc:e.loc,key:r,value:t})))}toStatement(e,{args:t,params:r}){let{element:n,state:s}=e;return this.blocks(s).mapOk((e=>new Ct({loc:n.loc,tag:this.tag,params:r,args:t,blocks:e})))}blocks(e){return zr.NamedBlocks(this.element.blocks,e)}}class jr{constructor(e,t,r){this.tag=e,this.element=t,this.dynamicFeatures=r}isComponent=!1;arg(e){return rr(d(`${e.name.chars} is not a valid attribute name. @arguments are only allowed on components, but the tag for this element (\`${this.tag.chars}\`) is a regular, non-component HTML element.`,e.loc))}toStatement(e,{params:t}){let{state:r,element:n}=e;return zr.visitList(this.element.body,r).mapOk((e=>new Tt({loc:n.loc,tag:this.tag,params:t,body:e.toArray(),dynamicFeatures:this.dynamicFeatures})))}}const zr=new class{visitList(e,t){return new nr(e.map((e=>zr.visit(e,t)))).toOptionalList().mapOk((e=>e.filter((e=>null!==e))))}visit(e,t){switch(e.type){case"GlimmerComment":return tr(null);case"AppendContent":return this.AppendContent(e,t);case"HtmlText":return tr(this.TextNode(e));case"HtmlComment":return tr(this.HtmlComment(e));case"InvokeBlock":return this.InvokeBlock(e,t);case"InvokeComponent":return this.Component(e,t);case"SimpleElement":return this.SimpleElement(e,t)}}InvokeBlock(e,t){let r=Cr.translate(e,t);if(null!==r)return r;let n=ar.visit(e.callee,t),s=ar.Args(e.args,t);return Zt.all(n,s).andThen((([r,n])=>this.NamedBlocks(e.blocks,t).mapOk((t=>new Lt({loc:e.loc,head:r,args:n,blocks:t})))))}NamedBlocks(e,t){return new nr(e.blocks.map((e=>this.NamedBlock(e,t)))).toArray().mapOk((t=>new wt({loc:e.loc,blocks:Yt(t)})))}NamedBlock(e,t){return t.visitBlock(e.block).mapOk((t=>new At({loc:e.loc,name:e.name,body:t.toArray(),scope:e.block.scope})))}SimpleElement(e,t){return new Dr(e,new jr(e.tag,e,function({attrs:e,modifiers:t}){return t.length>0||!!e.filter((e=>"SplatAttr"===e.type))[0]}(e)),t).toStatement()}Component(e,t){return ar.visit(e.callee,t).andThen((r=>new Dr(e,new _r(r,e),t).toStatement()))}AppendContent(e,t){let r=Sr.translate(e,t);return null!==r?r:ar.visit(e.value,t).mapOk((t=>e.trusting?new xt({loc:e.loc,html:t}):new Et({loc:e.loc,text:t})))}TextNode(e){return new Et({loc:e.loc,text:new c.LiteralExpression({loc:e.loc,value:e.chars})})}HtmlComment(e){return new St({loc:e.loc,value:e.text})}};class Rr{_currentScope;_cursorCount=0;constructor(e,t){this.isStrict=t,this._currentScope=e}generateUniqueCursor(){return`%cursor:${this._cursorCount++}%`}get scope(){return this._currentScope}visitBlock(e){let t=this._currentScope;this._currentScope=e.scope;try{return zr.visitList(e.body,this)}finally{this._currentScope=t}}}const Wr="component",qr="helper",Kr="modifier";class Ur{static validate(e){return new this(e).validate()}constructor(e){this.template=e}validate(){return this.Statements(this.template.body).mapOk((()=>this.template))}Statements(e){let t=tr(null);for(let r of e)t=t.andThen((()=>this.Statement(r)));return t}NamedBlocks({blocks:e}){let t=tr(null);for(let r of e.toArray())t=t.andThen((()=>this.NamedBlock(r)));return t}NamedBlock(e){return this.Statements(e.body)}Statement(e){switch(e.type){case"InElement":return this.InElement(e);case"Debugger":case"AppendComment":return tr(null);case"Yield":return this.Yield(e);case"AppendTrustedHTML":return this.AppendTrustedHTML(e);case"AppendTextNode":return this.AppendTextNode(e);case"Component":return this.Component(e);case"SimpleElement":return this.SimpleElement(e);case"InvokeBlock":return this.InvokeBlock(e);case"If":return this.If(e);case"Each":return this.Each(e);case"Let":return this.Let(e);case"WithDynamicVars":return this.WithDynamicVars(e);case"InvokeComponent":return this.InvokeComponent(e)}}Expressions(e){let t=tr(null);for(let r of e)t=t.andThen((()=>this.Expression(r)));return t}Expression(e,t=e,r){switch(e.type){case"Literal":case"Keyword":case"Missing":case"This":case"Arg":case"Local":case"HasBlock":case"HasBlockParams":case"GetDynamicVar":return tr(null);case"PathExpression":return this.Expression(e.head,t,r);case"Free":return this.errorFor(e.name,t,r);case"InterpolateExpression":return this.InterpolateExpression(e,t,r);case"CallExpression":return this.CallExpression(e,t,r??qr);case"Not":return this.Expression(e.value,t,r);case"IfInline":return this.IfInline(e);case"Curry":return this.Curry(e);case"Log":return this.Log(e)}}Args(e){return this.Positional(e.positional).andThen((()=>this.NamedArguments(e.named)))}Positional(e,t){let r=tr(null),n=e.list.toArray();return r=1===n.length?this.Expression(n[0],t):this.Expressions(n),r}NamedArguments({entries:e}){let t=tr(null);for(let r of e.toArray())t=t.andThen((()=>this.NamedArgument(r)));return t}NamedArgument(e){return"CallExpression"===e.value.type?this.Expression(e.value,e,qr):this.Expression(e.value,e)}ElementParameters({body:e}){let t=tr(null);for(let r of e.toArray())t=t.andThen((()=>this.ElementParameter(r)));return t}ElementParameter(e){switch(e.type){case"StaticAttr":case"SplatAttr":return tr(null);case"DynamicAttr":return this.DynamicAttr(e);case"Modifier":return this.Modifier(e)}}DynamicAttr(e){return"CallExpression"===e.value.type?this.Expression(e.value,e,qr):this.Expression(e.value,e)}Modifier(e){return this.Expression(e.callee,e,Kr).andThen((()=>this.Args(e.args)))}InElement(e){return this.Expression(e.destination).andThen((()=>this.Expression(e.insertBefore))).andThen((()=>this.NamedBlock(e.block)))}Yield(e){return this.Positional(e.positional,e)}AppendTrustedHTML(e){return this.Expression(e.html,e)}AppendTextNode(e){return"CallExpression"===e.text.type?this.Expression(e.text,e,"component or helper"):this.Expression(e.text,e)}Component(e){return this.Expression(e.tag,e,Wr).andThen((()=>this.ElementParameters(e.params))).andThen((()=>this.NamedArguments(e.args))).andThen((()=>this.NamedBlocks(e.blocks)))}SimpleElement(e){return this.ElementParameters(e.params).andThen((()=>this.Statements(e.body)))}InvokeBlock(e){return this.Expression(e.head,e.head,Wr).andThen((()=>this.Args(e.args))).andThen((()=>this.NamedBlocks(e.blocks)))}If(e){return this.Expression(e.condition,e).andThen((()=>this.NamedBlock(e.block))).andThen((()=>e.inverse?this.NamedBlock(e.inverse):tr(null)))}Each(e){return this.Expression(e.value,e).andThen((()=>e.key?this.Expression(e.key,e):tr(null))).andThen((()=>this.NamedBlock(e.block))).andThen((()=>e.inverse?this.NamedBlock(e.inverse):tr(null)))}Let(e){return this.Positional(e.positional).andThen((()=>this.NamedBlock(e.block)))}WithDynamicVars(e){return this.NamedArguments(e.named).andThen((()=>this.NamedBlock(e.block)))}InvokeComponent(e){return this.Expression(e.definition,e,Wr).andThen((()=>this.Args(e.args))).andThen((()=>e.blocks?this.NamedBlocks(e.blocks):tr(null)))}InterpolateExpression(e,t,r){let n=e.parts.toArray();return 1===n.length?this.Expression(n[0],t,r):this.Expressions(n)}CallExpression(e,t,r){return this.Expression(e.callee,t,r).andThen((()=>this.Args(e.args)))}IfInline(e){return this.Expression(e.condition).andThen((()=>this.Expression(e.truthy))).andThen((()=>e.falsy?this.Expression(e.falsy):tr(null)))}Curry(e){let t;return t=0===e.curriedType?Wr:1===e.curriedType?qr:Kr,this.Expression(e.definition,e,t).andThen((()=>this.Args(e.args)))}Log(e){return this.Positional(e.positional,e)}errorFor(e,t,r="value"){return rr(d(`Attempted to resolve a ${r} in a strict mode template, but that value was not in scope: ${e}`,f(t)))}}class Jr{upvars;symbols;constructor([e,t,r]){this.upvars=r,this.symbols=t}format(e){let t=[];for(let r of e[0])t.push(this.formatOpcode(r));return t}formatOpcode(e){if(!Array.isArray(e))return e;switch(e[0]){case s.Append:return["append",this.formatOpcode(e[1])];case s.TrustingAppend:return["trusting-append",this.formatOpcode(e[1])];case s.Block:return["block",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3]),this.formatBlocks(e[4])];case s.InElement:return["in-element",e[1],this.formatOpcode(e[2]),e[3]?this.formatOpcode(e[3]):void 0];case s.OpenElement:return["open-element",Lr(e[1])];case s.OpenElementWithSplat:return["open-element-with-splat",Lr(e[1])];case s.CloseElement:return["close-element"];case s.FlushElement:return["flush-element"];case s.StaticAttr:return["static-attr",Fr(e[1]),e[2],e[3]];case s.StaticComponentAttr:return["static-component-attr",Fr(e[1]),e[2],e[3]];case s.DynamicAttr:return["dynamic-attr",Fr(e[1]),this.formatOpcode(e[2]),e[3]];case s.ComponentAttr:return["component-attr",Fr(e[1]),this.formatOpcode(e[2]),e[3]];case s.AttrSplat:return["attr-splat"];case s.Yield:return["yield",e[1],this.formatParams(e[2])];case s.DynamicArg:return["dynamic-arg",e[1],this.formatOpcode(e[2])];case s.StaticArg:return["static-arg",e[1],this.formatOpcode(e[2])];case s.TrustingDynamicAttr:return["trusting-dynamic-attr",Fr(e[1]),this.formatOpcode(e[2]),e[3]];case s.TrustingComponentAttr:return["trusting-component-attr",Fr(e[1]),this.formatOpcode(e[2]),e[3]];case s.Debugger:return["debugger",e[1]];case s.Comment:return["comment",e[1]];case s.Modifier:return["modifier",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3])];case s.Component:return["component",this.formatOpcode(e[1]),this.formatElementParams(e[2]),this.formatHash(e[3]),this.formatBlocks(e[4])];case s.HasBlock:return["has-block",this.formatOpcode(e[1])];case s.HasBlockParams:return["has-block-params",this.formatOpcode(e[1])];case s.Curry:return["curry",this.formatOpcode(e[1]),this.formatCurryType(e[2]),this.formatParams(e[3]),this.formatHash(e[4])];case s.Undefined:return["undefined"];case s.Call:return["call",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3])];case s.Concat:return["concat",this.formatParams(e[1])];case s.GetStrictKeyword:return["get-strict-free",this.upvars[e[1]]];case s.GetFreeAsComponentOrHelperHead:return["GetFreeAsComponentOrHelperHead",this.upvars[e[1]],e[2]];case s.GetFreeAsHelperHead:return["GetFreeAsHelperHead",this.upvars[e[1]],e[2]];case s.GetFreeAsComponentHead:return["GetFreeAsComponentHead",this.upvars[e[1]],e[2]];case s.GetFreeAsModifierHead:return["GetFreeAsModifierHead",this.upvars[e[1]],e[2]];case s.GetSymbol:return 0===e[1]?["get-symbol","this",e[2]]:["get-symbol",this.symbols[e[1]-1],e[2]];case s.GetLexicalSymbol:return["get-template-symbol",e[1],e[2]];case s.If:return["if",this.formatOpcode(e[1]),this.formatBlock(e[2]),e[3]?this.formatBlock(e[3]):null];case s.IfInline:return["if-inline"];case s.Not:return["not"];case s.Each:return["each",this.formatOpcode(e[1]),e[2]?this.formatOpcode(e[2]):null,this.formatBlock(e[3]),e[4]?this.formatBlock(e[4]):null];case s.Let:return["let",this.formatParams(e[1]),this.formatBlock(e[2])];case s.Log:return["log",this.formatParams(e[1])];case s.WithDynamicVars:return["-with-dynamic-vars",this.formatHash(e[1]),this.formatBlock(e[2])];case s.GetDynamicVar:return["-get-dynamic-vars",this.formatOpcode(e[1])];case s.InvokeComponent:return["component",this.formatOpcode(e[1]),this.formatParams(e[2]),this.formatHash(e[3]),this.formatBlocks(e[4])]}}formatCurryType(e){switch(e){case 0:return"component";case 1:return"helper";case 2:return"modifier";default:throw void 0}}formatElementParams(e){return null===e?null:e.map((e=>this.formatOpcode(e)))}formatParams(e){return null===e?null:e.map((e=>this.formatOpcode(e)))}formatHash(e){return null===e?null:e[0].reduce(((t,r,n)=>(t[r]=this.formatOpcode(e[1][n]),t)),t())}formatBlocks(e){return null===e?null:e[0].reduce(((t,r,n)=>(t[r]=this.formatBlock(e[1][n]),t)),t())}formatBlock(e){return{statements:e[0].map((e=>this.formatOpcode(e))),parameters:e[1]}}}const Yr=new class{expr(e){switch(e.type){case"Missing":return;case"Literal":return this.Literal(e);case"Keyword":return this.Keyword(e);case"CallExpression":return this.CallExpression(e);case"PathExpression":return this.PathExpression(e);case"Arg":return[s.GetSymbol,e.symbol];case"Local":return this.Local(e);case"This":return[s.GetSymbol,0];case"Free":return[e.resolution.resolution(),e.symbol];case"HasBlock":return this.HasBlock(e);case"HasBlockParams":return this.HasBlockParams(e);case"Curry":return this.Curry(e);case"Not":return this.Not(e);case"IfInline":return this.IfInline(e);case"InterpolateExpression":return this.InterpolateExpression(e);case"GetDynamicVar":return this.GetDynamicVar(e);case"Log":return this.Log(e)}}Literal({value:e}){return void 0===e?[s.Undefined]:e}Missing(){}HasBlock({symbol:e}){return[s.HasBlock,[s.GetSymbol,e]]}HasBlockParams({symbol:e}){return[s.HasBlockParams,[s.GetSymbol,e]]}Curry({definition:e,curriedType:t,args:r}){return[s.Curry,Yr.expr(e),t,Yr.Positional(r.positional),Yr.NamedArguments(r.named)]}Local({isTemplateLocal:e,symbol:t}){return[e?s.GetLexicalSymbol:s.GetSymbol,t]}Keyword({symbol:e}){return[s.GetStrictKeyword,e]}PathExpression({head:e,tail:t}){let r=Yr.expr(e);return r[0],s.GetStrictKeyword,[...r,Yr.Tail(t)]}InterpolateExpression({parts:e}){return[s.Concat,e.map((e=>Yr.expr(e))).toArray()]}CallExpression({callee:e,args:t}){return[s.Call,Yr.expr(e),...Yr.Args(t)]}Tail({members:e}){return te(e,(e=>e.chars))}Args({positional:e,named:t}){return[this.Positional(e),this.NamedArguments(t)]}Positional({list:e}){return e.map((e=>Yr.expr(e))).toPresentArray()}NamedArgument({key:e,value:t}){return[e.chars,Yr.expr(t)]}NamedArguments({entries:e}){let t=e.toArray();if(ee(t)){let e=[],r=[];for(let n of t){let[t,s]=Yr.NamedArgument(n);e.push(t),r.push(s)}return[e,r]}return null}Not({value:e}){return[s.Not,Yr.expr(e)]}IfInline({condition:e,truthy:t,falsy:r}){let n=[s.IfInline,Yr.expr(e),Yr.expr(t)];return r&&n.push(Yr.expr(r)),n}GetDynamicVar({name:e}){return[s.GetDynamicVar,Yr.expr(e)]}Log({positional:e}){return[s.Log,this.Positional(e)]}};class Xr{constructor(e){this.statements=e}toArray(){return this.statements}}const Zr=new class{list(e){let t=[];for(let r of e){let e=Zr.content(r);e&&e instanceof Xr?t.push(...e.toArray()):t.push(e)}return t}content(e){return this.visitContent(e)}visitContent(e){switch(e.type){case"Debugger":return[s.Debugger,...e.scope.getDebugInfo(),{}];case"AppendComment":return this.AppendComment(e);case"AppendTextNode":return this.AppendTextNode(e);case"AppendTrustedHTML":return this.AppendTrustedHTML(e);case"Yield":return this.Yield(e);case"Component":return this.Component(e);case"SimpleElement":return this.SimpleElement(e);case"InElement":return this.InElement(e);case"InvokeBlock":return this.InvokeBlock(e);case"If":return this.If(e);case"Each":return this.Each(e);case"Let":return this.Let(e);case"WithDynamicVars":return this.WithDynamicVars(e);case"InvokeComponent":return this.InvokeComponent(e);default:return}}Yield({to:e,positional:t}){return[s.Yield,e,Yr.Positional(t)]}InElement({guid:e,insertBefore:t,destination:r,block:n}){let a=Zr.NamedBlock(n)[1],o=Yr.expr(r),l=Yr.expr(t);return void 0===l?[s.InElement,a,e,o]:[s.InElement,a,e,o,l]}InvokeBlock({head:e,args:t,blocks:r}){return[s.Block,Yr.expr(e),...Yr.Args(t),Zr.NamedBlocks(r)]}AppendTrustedHTML({html:e}){return[s.TrustingAppend,Yr.expr(e)]}AppendTextNode({text:e}){return[s.Append,Yr.expr(e)]}AppendComment({value:e}){return[s.Comment,e.chars]}SimpleElement({tag:e,params:t,body:r,dynamicFeatures:n}){let a=n?s.OpenElementWithSplat:s.OpenElement;return new Xr([[a,(o=e.chars,Pr[o]??o)],...Zr.ElementParameters(t).toArray(),[s.FlushElement],...Zr.list(r),[s.CloseElement]]);var o}Component({tag:e,params:t,args:r,blocks:n}){let a=Yr.expr(e),o=Zr.ElementParameters(t),l=Yr.NamedArguments(r),i=Zr.NamedBlocks(n);return[s.Component,a,o.toPresentArray(),l,i]}ElementParameters({body:e}){return e.map((e=>Zr.ElementParameter(e)))}ElementParameter(e){switch(e.type){case"SplatAttr":return[s.AttrSplat,e.symbol];case"DynamicAttr":return[(t=e.kind,t.component?t.trusting?s.TrustingComponentAttr:s.ComponentAttr:t.trusting?s.TrustingDynamicAttr:s.DynamicAttr),...en(e)];case"StaticAttr":return[tn(e.kind),...Qr(e)];case"Modifier":return[s.Modifier,Yr.expr(e.callee),...Yr.Args(e.args)]}var t}NamedBlocks({blocks:e}){let t=[],r=[];for(let n of e.toArray()){let[e,s]=Zr.NamedBlock(n);t.push(e),r.push(s)}return t.length>0?[t,r]:null}NamedBlock({name:e,body:t,scope:r}){let n=e.chars;return"inverse"===n&&(n="else"),[n,[Zr.list(t),r.slots]]}If({condition:e,block:t,inverse:r}){return[s.If,Yr.expr(e),Zr.NamedBlock(t)[1],r?Zr.NamedBlock(r)[1]:null]}Each({value:e,key:t,block:r,inverse:n}){return[s.Each,Yr.expr(e),t?Yr.expr(t):null,Zr.NamedBlock(r)[1],n?Zr.NamedBlock(n)[1]:null]}Let({positional:e,block:t}){return[s.Let,Yr.Positional(e),Zr.NamedBlock(t)[1]]}WithDynamicVars({named:e,block:t}){return[s.WithDynamicVars,Yr.NamedArguments(e),Zr.NamedBlock(t)[1]]}InvokeComponent({definition:e,args:t,blocks:r}){return[s.InvokeComponent,Yr.expr(e),Yr.Positional(t.positional),Yr.NamedArguments(t.named),r?Zr.NamedBlocks(r):null]}};function Qr({name:e,value:t,namespace:r}){let n=[Vr(e.chars),t.chars];return r&&n.push(r),n}function en({name:e,value:t,namespace:r}){let n=[Vr(e.chars),Yr.expr(t)];return r&&n.push(r),n}function tn(e){return e.component?s.StaticComponentAttr:s.StaticAttr}const rn=(()=>{const e="object"==typeof module&&"function"==typeof module.require?module.require:globalThis.require;if(e)try{const t=e("crypto"),r=e=>{const r=t.createHash("sha1");return r.update(e,"utf8"),r.digest("base64").substring(0,8)};return r("test"),r}catch{}return function(){return null}})(),nn={id:rn};function sn(e,t=nn){const r=new m.Source(e??"",t.meta?.moduleName),[n,s]=y(r,{lexicalScope:()=>!1,...t}),a=function(e,t,r){let n=new Rr(t.table,r),s=zr.visitList(t.body,n).mapOk((e=>new ut({loc:t.loc,scope:t.table,body:e.toArray()})));return r&&(s=s.andThen((e=>Ur.validate(e)))),s}(0,n,t.strictMode??!1).mapOk((e=>function(e){let t=Zr.list(e.body),r=e.scope;return[t,r.symbols,r.upvars]}(e)));if(a.isOk)return[a.value,s];throw a.reason}const an="796d24e6-2450-4fb0-8cdf-b65638b5ef70";function on(e,t=nn){const[r,n]=sn(e,t);"emit"in t&&t.emit?.debugSymbols&&n.length>0&&r.push(n);const s=t.meta?.moduleName,a=t.id||rn,o=JSON.stringify(r),l={id:a(JSON.stringify(t.meta)+o),block:o,moduleName:s??"(unknown template module)",scope:an,isStrictMode:t.strictMode??!1};0===n.length&&delete l.scope;let i=JSON.stringify(l);if(n.length>0){const e=`()=>[${n.join(",")}]`;i=i.replace(`"${an}"`,e)}return i}export{He as NEWLINE,Ee as ProgramSymbols,Jr as WireFormatDebugger,Ne as buildStatement,Oe as buildStatements,Ie as c,rn as defaultId,on as precompile,sn as precompileJSON,$e as s,Pe as unicode};
//# sourceMappingURL=index.js.map
{
"name": "@glimmer/compiler",
"version": "0.92.4",
"version": "0.93.0",
"license": "MIT",
"repository": "https://github.com/glimmerjs/glimmer-vm/tree/main/packages/@glimmer/compiler",
"type": "module",
"main": null,
"types": "dist/dev/index.d.ts",
"exports": {
".": {
"types": "./dist/dev/index.d.ts",
"development": {
"require": "./dist/dev/index.cjs",
"import": "./dist/dev/index.js"
"require": {
"development": {
"types": "./dist/dev/index.d.cts",
"default": "./dist/dev/index.cjs"
}
},
"require": "./dist/dev/index.cjs",
"import": "./dist/dev/index.js"
"default": {
"development": {
"types": "./dist/dev/index.d.ts",
"default": "./dist/dev/index.js"
},
"default": {
"types": "./dist/prod/index.d.ts",
"default": "./dist/prod/index.js"
}
}
}

@@ -27,7 +34,7 @@ },

"dependencies": {
"@glimmer/vm": "0.92.3",
"@glimmer/wire-format": "0.92.3",
"@glimmer/util": "0.92.3",
"@glimmer/interfaces": "0.92.3",
"@glimmer/syntax": "0.92.3"
"@glimmer/interfaces": "0.93.0",
"@glimmer/syntax": "0.93.0",
"@glimmer/util": "0.93.0",
"@glimmer/vm": "0.93.0",
"@glimmer/wire-format": "0.93.0"
},

@@ -38,5 +45,8 @@ "devDependencies": {

"publint": "^0.2.5",
"rollup": "^4.5.1",
"rollup": "^4.24.3",
"typescript": "*",
"@glimmer-workspace/build-support": "1.0.0",
"@glimmer/constants": "0.92.3",
"@glimmer/debug": "0.92.4",
"@glimmer/debug-util": "0.92.3",
"@glimmer/local-debug-flags": "0.92.0"

@@ -52,4 +62,3 @@ },

"test:types": "tsc --noEmit -p ../tsconfig.json"
},
"module": "dist/dev/index.js"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc