@glimmer/runtime
Version:
Minimal runtime needed to render Glimmer templates
1 lines • 65.3 kB
JavaScript
import{registerDestructor as e,destroy as t,associateDestroyableChild as s,_hasDestroyableChildren as n,destroyChildren as i}from"@glimmer/destroyable";export{destroy,isDestroyed,isDestroying,registerDestructor}from"@glimmer/destroyable";import{toBool as r,debugAssert as a,getPath as l,setPath as o}from"@glimmer/global-context";import{getInternalModifierManager as c,managerHasCapability as u,getInternalHelperManager as h,hasInternalComponentManager as d,hasInternalHelperManager as p,setInternalComponentManager as m,setInternalHelperManager as f,hasValue as g,hasDestroyable as b,setInternalModifierManager as k}from"@glimmer/manager";import{createComputeRef as v,valueForRef as y,UNDEFINED_REFERENCE as w,createConstRef as S,createPrimitiveRef as x,isConstRef as _,NULL_REFERENCE as N,TRUE_REFERENCE as E,FALSE_REFERENCE as T,REFERENCE as C,childRefFor as R,createIteratorRef as B,isInvokableRef as A,updateRef as O,createIteratorItemRef as M}from"@glimmer/reference";import{isIndexable as V,assign as D,Stack as L,EMPTY_STRING_ARRAY as I,dict as U,enumerate as H,emptyArray as j,clearElement as z,isDict as W,reverse as $}from"@glimmer/util";import{$v0 as F,$t1 as P,$t0 as G,$pc as Y,$ra as q,$fp as J,$sp as X,$s1 as K,$s0 as Q,InternalComponentCapabilities as Z,ContentType as ee,isLowLevelRegister as te}from"@glimmer/vm";import{validateTag as se,consumeTag as ne,valueForTag as ie,CONSTANT_TAG as re,INITIAL as ae,beginTrackFrame as le,endTrackFrame as oe,CURRENT_TAG as ce,track as ue,updateTag as he,createCache as de,getValue as pe,createUpdatableTag as me}from"@glimmer/validator";import{ProgramImpl as fe}from"@glimmer/program";import{getOwner as ge}from"@glimmer/owner";const be="http://www.w3.org/1998/Math/MathML",ke="http://www.w3.org/2000/svg",ve="afterbegin",ye="beforeend";function we(e){return function(e){e.nodeType}(e),e}function Se(e){if("number"==typeof e)return e;{let t=e.errors[0];throw new Error(`Compile Error: ${t.problem} @ ${t.span.start}..${t.span.end}`)}}function xe(e){if("error"===e.result)throw new Error(`Compile Error: ${e.problem} @ ${e.span.start}..${e.span.end}`);return e}const _e=-536870913;function Ne(e){return(e|=0)>_e?function(e){return~e}(e):function(e){return 536870912|e}(e)}[1,-1].forEach((e=>{return Ne((t=e,(t|=0)<0?function(e){return e&_e}(t):function(e){return~e}(t)));var t})),new class{validate(e){switch(e){case Q:case K:case X:case J:case q:case Y:case G:case P:case F:return!0;default:return!1}}expected(){return"Register"}};const Ee=new class{constructor(){this.evaluateOpcode=new Array(113).fill(null)}add(e,t,s="syscall"){this.evaluateOpcode[e]={syscall:"machine"!==s,evaluate:t}}evaluate(e,t,s){let n=this.evaluateOpcode[s];n.syscall?(t.isMachine,n.syscall,t.isMachine,t.type,n.evaluate(e,t)):(t.isMachine,n.syscall,t.isMachine,t.type,n.evaluate(e.lowlevel,t))}},Te=Symbol("TYPE"),Ce=Symbol("INNER"),Re=Symbol("OWNER"),Be=Symbol("ARGS"),Ae=Symbol("RESOLVED"),Oe=new WeakSet;function Me(e){return Oe.has(e)}function Ve(e,t){return Me(e)&&e[Te]===t}class De{constructor(e,t,s,n,i=!1){Oe.add(this),this[Te]=e,this[Ce]=t,this[Re]=s,this[Be]=n,this[Ae]=i}}function Le(e){let t,s,n,i,r,a=e;for(;;){let{[Be]:e,[Ce]:l}=a;if(null!==e){let{named:n,positional:i}=e;i.length>0&&(t=void 0===t?i:i.concat(t)),void 0===s&&(s=[]),s.unshift(n)}if(!Me(l)){n=l,i=a[Re],r=a[Ae];break}a=l}return{definition:n,owner:i,resolved:r,positional:t,named:s}}function Ie(e,t,s,n,i=!1){return new De(e,t,s,n,i)}class Ue{constructor(e){this.bucket=e?D({},e):{}}get(e){return this.bucket[e]}set(e,t){return this.bucket[e]=t}child(){return new Ue(this.bucket)}}class He{static root(e,{self:t,size:s=0}){let n=new Array(s+1).fill(w);return new He(e,n,null).init({self:t})}static sized(e,t=0){let s=new Array(t+1).fill(w);return new He(e,s,null)}constructor(e,t,s){this.owner=e,this.slots=t,this.callerScope=s}init({self:e}){return this.slots[0]=e,this}snapshot(){return this.slots.slice()}getSelf(){return this.get(0)}getSymbol(e){return this.get(e)}getBlock(e){let t=this.get(e);return t===w?null:t}bind(e,t){this.set(e,t)}bindSelf(e){this.set(0,e)}bindSymbol(e,t){this.set(e,t)}bindBlock(e,t){this.set(e,t)}bindCallerScope(e){this.callerScope=e}getCallerScope(){return this.callerScope}child(){return new He(this.owner,this.slots.slice(),this.callerScope)}get(e){if(e>=this.slots.length)throw new RangeError(`BUG: cannot get $${e} from scope; length=${this.slots.length}`);return this.slots[e]}set(e,t){if(e>=this.slots.length)throw new RangeError(`BUG: cannot get $${e} from scope; length=${this.slots.length}`);this.slots[e]=t}}class je{constructor(e,t){this.element=e,this.nextSibling=t}}class ze{constructor(e,t,s){this.parentNode=e,this.first=t,this.last=s}parentElement(){return this.parentNode}firstNode(){return this.first}lastNode(){return this.last}}function We(e,t){let s=e.parentElement(),n=e.firstNode(),i=e.lastNode(),r=n;for(;;){let e=r.nextSibling;if(s.insertBefore(r,t),r===i)return e;r=e}}function $e(e){let t=e.parentElement(),s=e.firstNode(),n=e.lastNode(),i=s;for(;;){let e=i.nextSibling;if(t.removeChild(i),i===n)return e;i=e}}function Fe(e){return"getDebugCustomRenderTree"in e}let Pe=0;class Ge{constructor(e){this.id=Pe++,this.value=e}get(){return this.value}release(){this.value=null}toString(){let e=`Ref ${this.id}`;if(null===this.value)return`${e} (released)`;try{return`${e}: ${this.value}`}catch{return e}}}class Ye{begin(){this.reset()}create(e,t){let s=D({},t,{bounds:null,refs:new Set});this.nodes.set(e,s),this.appendChild(s,e),this.enter(e)}update(e){this.enter(e)}didRender(e,t){this.nodeFor(e).bounds=t,this.exit()}willDestroy(e){this.refs.get(e).release()}commit(){this.reset()}capture(){return this.captureRefs(this.roots)}reset(){if(0!==this.stack.size){let e=this.stack.toArray()[0],t=this.refs.get(e);for(void 0!==t&&this.roots.delete(t);!this.stack.isEmpty();)this.stack.pop()}}enter(e){this.stack.push(e)}exit(){this.stack.pop()}nodeFor(e){return this.nodes.get(e)}appendChild(e,t){let s=this.stack.current,n=new Ge(t);if(this.refs.set(t,n),s){let t=this.nodeFor(s);t.refs.add(n),e.parent=t}else this.roots.add(n)}captureRefs(e){let t=[];return e.forEach((s=>{let n=s.get();n?t.push(this.captureNode(`render-node:${s.id}`,n)):e.delete(s)})),t}captureNode(e,t){let s=this.nodeFor(t),{type:n,name:i,args:r,instance:a,refs:l}=s,o=this.captureTemplate(s),c=this.captureBounds(s),u=this.captureRefs(l);return{id:e,type:n,name:i,args:Bt(r),instance:a,template:o,bounds:c,children:u}}captureTemplate({template:e}){return e||null}captureBounds(e){let t=e.bounds;return{parentElement:t.parentElement(),firstNode:t.firstNode(),lastNode:t.lastNode()}}constructor(){this.stack=new L,this.refs=new WeakMap,this.roots=new Set,this.nodes=new WeakMap}}function qe(e){return Je(e)?"":String(e)}function Je(e){return null==e||"function"!=typeof e.toString}function Xe(e){return null!==e&&"object"==typeof e}function Ke(e){return Xe(e)&&"function"==typeof e.toHTML}function Qe(e){return"string"==typeof e}Ee.add(39,(e=>e.pushChildScope())),Ee.add(40,(e=>e.popScope())),Ee.add(59,(e=>e.pushDynamicScope())),Ee.add(60,(e=>e.popDynamicScope())),Ee.add(28,((e,{op1:t})=>{e.stack.push(e.constants.getValue(t))})),Ee.add(29,((e,{op1:t})=>{e.stack.push(S(e.constants.getValue(t),!1))})),Ee.add(30,((e,{op1:t})=>{let s=e.stack;if(t>=0){let n=e.constants.getValue(t);s.push(n)}else s.push(Ne(t))})),Ee.add(31,(e=>{let t,s=e.stack,n=s.pop();t=void 0===n?w:null===n?N:!0===n?E:!1===n?T:x(n),s.push(t)})),Ee.add(33,((e,{op1:t,op2:s})=>{let n=e.fetchValue(t)-s;e.stack.dup(n)})),Ee.add(34,((e,{op1:t})=>{e.stack.pop(t)})),Ee.add(35,((e,{op1:t})=>{e.load(t)})),Ee.add(36,((e,{op1:t})=>{e.fetch(t)})),Ee.add(58,((e,{op1:t})=>{let s=e.constants.getArray(t);e.bindDynamicScope(s)})),Ee.add(69,((e,{op1:t})=>{e.enter(t)})),Ee.add(70,(e=>{e.exit()})),Ee.add(63,((e,{op1:t})=>{e.stack.push(e.constants.getValue(t))})),Ee.add(62,(e=>{e.stack.push(e.scope())})),Ee.add(61,(e=>{let t=e.stack,s=t.pop();s?t.push(e.compile(s)):t.push(null)})),Ee.add(64,(e=>{let{stack:t}=e,s=t.pop(),n=t.pop(),i=t.pop(),r=t.pop();if(null===i||null===s)return e.lowlevel.pushFrame(),void e.pushScope(n??e.scope());let a=n;{let e=i.parameters,t=e.length;if(t>0){a=a.child();for(let s=0;s<t;s++)a.bindSymbol(e[s],r.at(s))}}e.lowlevel.pushFrame(),e.pushScope(a),e.call(s)})),Ee.add(65,((e,{op1:t})=>{let s=e.stack.pop(),n=Boolean(y(s));_(s)?n&&e.lowlevel.goto(t):(n&&e.lowlevel.goto(t),e.updateWith(new Ze(s)))})),Ee.add(66,((e,{op1:t})=>{let s=e.stack.pop(),n=Boolean(y(s));_(s)?n||e.lowlevel.goto(t):(n||e.lowlevel.goto(t),e.updateWith(new Ze(s)))})),Ee.add(67,((e,{op1:t,op2:s})=>{e.stack.peek()===s&&e.lowlevel.goto(t)})),Ee.add(68,(e=>{let t=e.stack.peek();_(t)||e.updateWith(new Ze(t))})),Ee.add(71,(e=>{let{stack:t}=e,s=t.pop();t.push(v((()=>r(y(s)))))}));class Ze{constructor(e){this.ref=e,this.last=y(e)}evaluate(e){let{last:t,ref:s}=this;t!==y(s)&&e.throw()}}class et{constructor(e,t){this.ref=e,this.filter=t,this.last=t(y(e))}evaluate(e){let{last:t,ref:s,filter:n}=this;t!==n(y(s))&&e.throw()}}class tt{finalize(e,t){this.target=t,this.didModify(e)}evaluate(e){let{tag:t,target:s,lastRevision:n}=this;!e.alwaysRevalidate&&se(t,n)&&(ne(t),e.goto(s))}didModify(e){this.tag=e,this.lastRevision=ie(this.tag),ne(e)}constructor(){this.tag=re,this.lastRevision=ae}}class st{constructor(e){this.debugLabel=e}evaluate(){le(this.debugLabel)}}class nt{constructor(e){this.target=e}evaluate(){let e=oe();this.target.didModify(e)}}Ee.add(41,((e,{op1:t})=>{e.tree().appendText(e.constants.getValue(t))})),Ee.add(42,((e,{op1:t})=>{e.tree().appendComment(e.constants.getValue(t))})),Ee.add(48,((e,{op1:t})=>{e.tree().openElement(e.constants.getValue(t))})),Ee.add(49,(e=>{let t=y(e.stack.pop());e.tree().openElement(t)})),Ee.add(50,(t=>{let s=t.stack.pop(),n=t.stack.pop(),i=t.stack.pop(),r=y(s),a=y(n),l=y(i);_(s)||t.updateWith(new Ze(s)),void 0===a||_(n)||t.updateWith(new Ze(n));let o=t.tree().pushRemoteElement(r,l,a);if(t.associateDestroyable(o),void 0!==t.env.debugRenderTree){let i=xt(void 0===a?{}:{insertBefore:n},[s]);t.env.debugRenderTree.create(o,{type:"keyword",name:"in-element",args:i,instance:null}),e(o,(()=>{t.env.debugRenderTree?.willDestroy(o)}))}})),Ee.add(56,(e=>{let t=e.tree().popRemoteElement();void 0!==e.env.debugRenderTree&&e.env.debugRenderTree.didRender(t,t)})),Ee.add(54,(e=>{let t=e.fetchValue(G),s=null;t&&(s=t.flush(e),e.loadValue(G,null)),e.tree().flushElement(s)})),Ee.add(55,(e=>{let t=e.tree().closeElement();null!==t&&t.forEach((t=>{e.env.scheduleInstallModifier(t);const s=t.manager.getDestroyable(t.state);null!==s&&e.associateDestroyable(s)}))})),Ee.add(57,((e,{op1:t})=>{if(!e.env.isInteractive)return;let s=e.getOwner(),n=e.stack.pop(),i=e.constants.getValue(t),{manager:r}=i,{constructing:a}=e.tree(),l=n.capture(),o=r.create(s,a,i.state,l),c={manager:r,state:o,definition:i};e.fetchValue(G).addModifier(e,c,l);let u=r.getTag(o);return null!==u?(ne(u),e.updateWith(new it(u,c))):void 0})),Ee.add(108,(e=>{if(!e.env.isInteractive)return;let{stack:t}=e,s=t.pop(),n=t.pop().capture(),{positional:i,named:r}=n,{constructing:a}=e.tree(),l=e.getOwner(),o=v((()=>{let e,t,o=y(s);if(!V(o))return;if(Ve(o,2)){let{definition:s,owner:a,positional:l,named:c}=Le(o);t=s,e=a,void 0!==l&&(n.positional=l.concat(i)),void 0!==c&&(n.named=Object.assign({},...c,r))}else t=o,e=l;let u=c(t,!0);if(null===u)throw new Error("BUG: modifier manager expected");let h={resolvedName:null,manager:u,state:t},d=u.create(e,a,h.state,n);return{manager:u,state:d,definition:h}})),u=y(o),h=null;return void 0!==u&&(e.fetchValue(G).addModifier(e,u,n),h=u.manager.getTag(u.state),null!==h&&ne(h)),!_(s)||h?e.updateWith(new rt(h,u,o)):void 0}));class it{constructor(e,t){this.tag=e,this.modifier=t,this.lastUpdated=ie(e)}evaluate(e){let{modifier:t,tag:s,lastUpdated:n}=this;ne(s),se(s,n)||(e.env.scheduleUpdateModifier(t),this.lastUpdated=ie(s))}}class rt{constructor(e,t,s){this.tag=e,this.instance=t,this.instanceRef=s,this.lastUpdated=ie(e??ce)}evaluate(e){let{tag:n,lastUpdated:i,instance:r,instanceRef:a}=this,l=y(a);if(l!==r){if(void 0!==r){let e=r.manager.getDestroyable(r.state);null!==e&&t(e)}if(void 0!==l){let{manager:t,state:i}=l,r=t.getDestroyable(i);null!==r&&s(this,r),n=t.getTag(i),null!==n&&(this.lastUpdated=ie(n)),this.tag=n,e.env.scheduleInstallModifier(l)}this.instance=l}else null===n||se(n,i)||(e.env.scheduleUpdateModifier(r),this.lastUpdated=ie(n));null!==n&&ne(n)}}Ee.add(51,((e,{op1:t,op2:s,op3:n})=>{let i=e.constants.getValue(t),r=e.constants.getValue(s),a=n?e.constants.getValue(n):null;e.tree().setStaticAttribute(i,r,a)})),Ee.add(52,((e,{op1:t,op2:s,op3:n})=>{let i=e.constants.getValue(t),r=e.constants.getValue(s),a=e.stack.pop(),l=y(a),o=n?e.constants.getValue(n):null,c=e.tree().setDynamicAttribute(i,l,r,o);_(a)||e.updateWith(new at(a,c,e.env))}));class at{constructor(e,t,s){let n=!1;this.updateRef=v((()=>{let i=y(e);n?t.update(i,s):n=!0})),y(this.updateRef)}evaluate(){y(this.updateRef)}}Ee.add(78,((e,{op1:t})=>{let s=e.constants.getValue(t),{manager:n,capabilities:i}=s,r={definition:s,manager:n,capabilities:i,state:null,handle:null,table:null,lookup:null};e.stack.push(r)})),Ee.add(80,((e,{op1:t})=>{let s,n=e.stack,i=y(n.pop()),r=e.constants,a=e.getOwner();if(r.getValue(t),e.loadValue(P,null),"string"==typeof i){let t=function(e,t,s,n){let i=e?.lookupComponent?.(s,n)??null;return t.resolvedComponent(i,s)}(e.context.resolver,r,i,a);s=t}else s=Me(i)?i:r.component(i,a);n.push(s)})),Ee.add(81,(e=>{let t,s=e.stack,n=s.pop(),i=y(n),r=e.constants;t=Me(i)?i:r.component(i,e.getOwner(),!0),s.push(t)})),Ee.add(79,(e=>{let t,s,{stack:n}=e,i=n.pop();Me(i)?s=t=null:(s=i.manager,t=i.capabilities),n.push({definition:i,capabilities:t,manager:s,state:null,handle:null,table:null})})),Ee.add(82,((e,{op1:t,op2:s,op3:n})=>{let i=e.stack,r=e.constants.getArray(t),a=n>>4,l=8&n,o=7&n?e.constants.getArray(s):I;e.args.setup(i,r,o,a,!!l),i.push(e.args)})),Ee.add(83,(e=>{let{stack:t}=e;t.push(e.args.empty(t))})),Ee.add(86,(e=>{let t=e.stack,s=t.pop().capture();t.push(s)})),Ee.add(85,((e,{op1:t})=>{let s=e.stack,n=e.fetchValue(t),i=s.pop(),{definition:r}=n;if(Ve(r,0)){r.manager;let t=e.constants,{definition:s,owner:a,resolved:l,positional:o,named:c}=Le(r);if(l)r=s;else if("string"==typeof s){let n=e.context.resolver?.lookupComponent?.(s,a)??null;r=t.resolvedComponent(n,s)}else r=t.component(s,a);void 0!==c&&i.named.merge(D({},...c)),void 0!==o&&(i.realloc(o.length),i.positional.prepend(o));let{manager:u}=r;n.definition=r,n.manager=u,n.capabilities=r.capabilities,e.loadValue(P,a)}let{manager:a,state:l}=r,o=n.capabilities;if(!u(a,o,Z.prepareArgs))return void s.push(i);let c=i.blocks.values,h=i.blocks.names,d=a.prepareArgs(l,i);if(d){i.clear();for(let e=0;e<c.length;e++)s.push(c[e]);let{positional:e,named:t}=d,n=e.length;for(let t=0;t<n;t++)s.push(e[t]);let r=Object.keys(t);for(let e=0;e<r.length;e++)s.push(t[r[e]]);i.setup(s,r,h,n,!1)}s.push(i)})),Ee.add(87,((e,{op1:t})=>{let s=e.fetchValue(Q),{definition:n,manager:i,capabilities:r}=s;if(!u(i,r,Z.createInstance))return;let a=null;u(i,r,Z.dynamicScope)&&(a=e.dynamicScope());let l=1&t,o=null;u(i,r,Z.createArgs)&&(o=e.stack.peek());let c=null;u(i,r,Z.createCaller)&&(c=e.getSelf());let h=i.create(e.getOwner(),n.state,o,e.env,a,c,!!l);s.state=h,u(i,r,Z.updateHook)&&e.updateWith(new ht(h,i,a))})),Ee.add(88,((e,{op1:t})=>{let{manager:s,state:n,capabilities:i}=e.fetchValue(t),r=s.getDestroyable(n);r&&e.associateDestroyable(r)})),Ee.add(97,((e,{op1:t})=>{e.beginCacheGroup(void 0),e.tree().pushAppendingBlock()})),Ee.add(89,(e=>{e.loadValue(G,new lt)})),Ee.add(53,((e,{op1:t,op2:s,op3:n})=>{let i=e.constants.getValue(t),r=e.constants.getValue(s),a=e.stack.pop(),l=n?e.constants.getValue(n):null;e.fetchValue(G).setAttribute(i,a,r,l)})),Ee.add(105,((e,{op1:t,op2:s,op3:n})=>{let i=e.constants.getValue(t),r=e.constants.getValue(s),a=n?e.constants.getValue(n):null;e.fetchValue(G).setStaticAttribute(i,r,a)}));class lt{setAttribute(e,t,s,n){let i={value:t,namespace:n,trusting:s};"class"===e&&this.classes.push(t),this.attributes[e]=i}setStaticAttribute(e,t,s){let n={value:t,namespace:s};"class"===e&&this.classes.push(t),this.attributes[e]=n}addModifier(t,s,n){if(this.modifiers.push(s),void 0!==t.env.debugRenderTree){const{manager:i,definition:r,state:a}=s;if(null===a||"object"!=typeof a&&"function"!=typeof a)return;let{element:l,constructing:o}=t.tree(),c=r.resolvedName??i.getDebugName(r.state),u=i.getDebugInstance(a),h=new ze(l,o,o);t.env.debugRenderTree.create(a,{type:"modifier",name:c,args:n,instance:u}),t.env.debugRenderTree.didRender(a,h),t.associateDestroyable(a),t.updateWith(new pt(a)),t.updateWith(new mt(a,h)),e(a,(()=>{t.env.debugRenderTree?.willDestroy(a)}))}}flush(e){let t,s=this.attributes;for(let n in this.attributes){if("type"===n){t=s[n];continue}let i=this.attributes[n];"class"===n?ct(e,"class",ot(this.classes),i.namespace,i.trusting):ct(e,n,i.value,i.namespace,i.trusting)}return void 0!==t&&ct(e,"type",t.value,t.namespace,t.trusting),this.modifiers}constructor(){this.attributes=U(),this.classes=[],this.modifiers=[]}}function ot(e){return 0===e.length?"":1===e.length?e[0]:function(e){return e.every((e=>"string"==typeof e))}(e)?e.join(" "):(t=e,v((()=>{let e=[];for(const s of t){let t=qe("string"==typeof s?s:y(s));t&&e.push(t)}return 0===e.length?null:e.join(" ")})));var t}function ct(e,t,s,n,i=!1){if("string"==typeof s)e.tree().setStaticAttribute(t,s,n);else{let r=e.tree().setDynamicAttribute(t,y(s),i,n);_(s)||e.updateWith(new at(s,r,e.env))}}function ut(e,t,s,n,i){let r=s.table.symbols.indexOf(e),a=n.get(t);-1!==r&&i.scope().bindBlock(r+1,a),s.lookup&&(s.lookup[e]=a)}Ee.add(99,((e,{op1:t})=>{let{definition:s,state:n}=e.fetchValue(t),{manager:i}=s,r=e.fetchValue(G);i.didCreateElement(n,e.tree().constructing,r)})),Ee.add(90,((t,{op1:s,op2:n})=>{let i=t.fetchValue(s),{definition:r,state:a}=i,{manager:l}=r,o=l.getSelf(a);if(void 0!==t.env.debugRenderTree){let i,r,l=t.fetchValue(s),{definition:c,manager:h}=l;if(t.stack.peek()===t.args)i=t.args.capture();else{let e=t.constants.getArray(n);t.args.setup(t.stack,e,[],0,!0),i=t.args.capture()}let d=c.compilable;if(null===d){u(h,l.capabilities,Z.dynamicLayout);let e=t.context.resolver;d=null===e?null:h.getDynamicLayout(a,e),r=null!==d?d.moduleName:"__default__.hbs"}else r=d.moduleName;if(t.associateDestroyable(l),Fe(h))h.getDebugCustomRenderTree(l.definition.state,l.state,i,r).forEach((s=>{let{bucket:n}=s;t.env.debugRenderTree.create(n,s),e(l,(()=>{t.env.debugRenderTree?.willDestroy(n)})),t.updateWith(new pt(n))}));else{let s=function(e,t=e.manager){return e.resolvedName??e.debugName??t.getDebugName(e.state)}(c,h);t.env.debugRenderTree.create(l,{type:"component",name:s,args:i,template:r,instance:y(o)}),e(l,(()=>{t.env.debugRenderTree?.willDestroy(l)})),t.updateWith(new pt(l))}}t.stack.push(o)})),Ee.add(91,((e,{op1:t})=>{let{definition:s,state:n}=e.fetchValue(t),{manager:i}=s,r=i.getTagName(n);e.stack.push(r)})),Ee.add(92,((e,{op1:t})=>{let s=e.fetchValue(t),{manager:n,definition:i}=s,{stack:r}=e,{compilable:a}=i;if(null===a){let{capabilities:t}=s;u(n,t,Z.dynamicLayout);let i=e.context.resolver;a=null===i?null:n.getDynamicLayout(s.state,i),null===a&&(a=u(n,t,Z.wrapped)?xe(e.constants.defaultTemplate).asWrappedLayout():xe(e.constants.defaultTemplate).asLayout())}let l=a.compile(e.context);r.push(a.symbolTable),r.push(l)})),Ee.add(75,((e,{op1:t})=>{let s=e.stack.pop(),n=e.stack.pop(),{manager:i,capabilities:r}=s,a={definition:s,manager:i,capabilities:r,state:null,handle:n.handle,table:n.symbolTable,lookup:null};e.loadValue(t,a)})),Ee.add(95,((e,{op1:t})=>{let{stack:s}=e,n=s.pop(),i=s.pop(),r=e.fetchValue(t);r.handle=n,r.table=i})),Ee.add(38,((e,{op1:t})=>{let s,{table:n,manager:i,capabilities:r,state:a}=e.fetchValue(t);u(i,r,Z.hasSubOwner)?(s=i.getOwner(a),e.loadValue(P,null)):(s=e.fetchValue(P),null===s?s=e.getOwner():e.loadValue(P,null)),e.pushRootScope(n.symbols.length+1,s)})),Ee.add(17,((e,{op1:t})=>{let s=e.fetchValue(t),n=e.scope(),i=e.stack.peek(),r=i.named.atNames;for(let e=r.length-1;e>=0;e--){let t=r[e],a=s.table.symbols.indexOf(t),l=i.named.get(t,!0);-1!==a&&n.bindSymbol(a+1,l),s.lookup&&(s.lookup[t]=l)}})),Ee.add(18,((e,{op1:t})=>{let s=e.fetchValue(t),{blocks:n}=e.stack.peek();for(const[t]of H(n.names))ut(n.symbolNames[t],n.names[t],s,n,e)})),Ee.add(96,((e,{op1:t})=>{let s=e.fetchValue(t);e.call(s.handle)})),Ee.add(100,((e,{op1:t})=>{let s=e.fetchValue(t),{manager:n,state:i,capabilities:r}=s,a=e.tree().popBlock();void 0!==e.env.debugRenderTree&&(Fe(n)?n.getDebugCustomRenderTree(s.definition.state,i,Mt).reverse().forEach((t=>{let{bucket:s}=t;e.env.debugRenderTree.didRender(s,a),e.updateWith(new mt(s,a))})):(e.env.debugRenderTree.didRender(s,a),e.updateWith(new mt(s,a)))),u(n,r,Z.createInstance)&&(n.didRenderLayout(i,a),e.env.didCreate(s),e.updateWith(new dt(s,a)))})),Ee.add(98,(e=>{e.commitCacheGroup()}));class ht{constructor(e,t,s){this.component=e,this.manager=t,this.dynamicScope=s}evaluate(e){let{component:t,manager:s,dynamicScope:n}=this;s.update(t,n)}}class dt{constructor(e,t){this.component=e,this.bounds=t}evaluate(e){let{component:t,bounds:s}=this,{manager:n,state:i}=t;n.didUpdateLayout(i,s),e.env.didUpdate(t)}}class pt{constructor(e){this.bucket=e}evaluate(e){e.env.debugRenderTree?.update(this.bucket)}}class mt{constructor(e,t){this.bucket=e,this.bounds=t}evaluate(e){e.env.debugRenderTree?.didRender(this.bucket,this.bounds)}}new class{validate(e){return"object"==typeof e&&null!==e&&C in e}expected(){return"Reference"}};class ft{constructor(){this.stack=null,this.positional=new bt,this.named=new kt,this.blocks=new wt}empty(e){let t=e.registers[X]+1;return this.named.empty(e,t),this.positional.empty(e,t),this.blocks.empty(e,t),this}setup(e,t,s,n,i){this.stack=e;let r=this.named,a=t.length,l=e.registers[X]-a+1;r.setup(e,l,a,t,i);let o=l-n;this.positional.setup(e,o,n);let c=this.blocks,u=s.length,h=o-3*u;c.setup(e,h,u,s)}get base(){return this.blocks.base}get length(){return this.positional.length+this.named.length+3*this.blocks.length}at(e){return this.positional.at(e)}realloc(e){let{stack:t}=this;if(e>0&&null!==t){let{positional:s,named:n}=this,i=s.base+e;for(let e=s.length+n.length-1;e>=0;e--)t.copy(e+s.base,e+i);s.base+=e,n.base+=e,t.registers[X]+=e}}capture(){let e=0===this.positional.length?Ot:this.positional.capture();return{named:0===this.named.length?At:this.named.capture(),positional:e}}clear(){let{stack:e,length:t}=this;t>0&&null!==e&&e.pop(t)}}const gt=j();class bt{constructor(){this.base=0,this.length=0,this.stack=null,this._references=null}empty(e,t){this.stack=e,this.base=t,this.length=0,this._references=gt}setup(e,t,s){this.stack=e,this.base=t,this.length=s,this._references=0===s?gt:null}at(e){let{base:t,length:s,stack:n}=this;return e<0||e>=s?w:n.get(e,t)}capture(){return this.references}prepend(e){let t=e.length;if(t>0){let{base:s,length:n,stack:i}=this;this.base=s-=t,this.length=n+t;for(let n=0;n<t;n++)i.set(e[n],n,s);this._references=null}}get references(){let e=this._references;if(!e){let{stack:t,base:s,length:n}=this;e=this._references=t.slice(s,s+n)}return e}}class kt{constructor(){this.base=0,this.length=0,this._references=null,this._names=I,this._atNames=I}empty(e,t){this.stack=e,this.base=t,this.length=0,this._references=gt,this._names=I,this._atNames=I}setup(e,t,s,n,i){this.stack=e,this.base=t,this.length=s,0===s?(this._references=gt,this._names=I,this._atNames=I):(this._references=null,i?(this._names=null,this._atNames=n):(this._names=n,this._atNames=null))}get names(){let e=this._names;return e||(e=this._names=this._atNames.map(this.toSyntheticName)),e}get atNames(){let e=this._atNames;return e||(e=this._atNames=this._names.map(this.toAtName)),e}has(e){return-1!==this.names.indexOf(e)}get(e,t=!1){let{base:s,stack:n}=this,i=(t?this.atNames:this.names).indexOf(e);return-1===i?w:n.get(i,s)}capture(){let{names:e,references:t}=this,s=U();for(const[n,i]of H(e))s[i]=t[n];return s}merge(e){let t=Object.keys(e);if(t.length>0){let{names:s,length:n,stack:i}=this,r=s.slice();for(const s of t)-1===r.indexOf(s)&&(n=r.push(s),i.push(e[s]));this.length=n,this._references=null,this._names=r,this._atNames=null}}get references(){let e=this._references;if(!e){let{base:t,length:s,stack:n}=this;e=this._references=n.slice(t,t+s)}return e}toSyntheticName(e){return e.slice(1)}toAtName(e){return`@${e}`}}function vt(e){return`&${e}`}const yt=j();class wt{constructor(){this.internalValues=null,this._symbolNames=null,this.internalTag=null,this.names=I,this.length=0,this.base=0}empty(e,t){this.stack=e,this.names=I,this.base=t,this.length=0,this._symbolNames=null,this.internalTag=re,this.internalValues=yt}setup(e,t,s,n){this.stack=e,this.names=n,this.base=t,this.length=s,this._symbolNames=null,0===s?(this.internalTag=re,this.internalValues=yt):(this.internalTag=null,this.internalValues=null)}get values(){let e=this.internalValues;if(!e){let{base:t,length:s,stack:n}=this;e=this.internalValues=n.slice(t,t+3*s)}return e}has(e){return-1!==this.names.indexOf(e)}get(e){let t=this.names.indexOf(e);if(-1===t)return null;let{base:s,stack:n}=this,i=n.get(3*t,s),r=n.get(3*t+1,s),a=n.get(3*t+2,s);return null===a?null:[a,r,i]}capture(){return new St(this.names,this.values)}get symbolNames(){let e=this._symbolNames;return null===e&&(e=this._symbolNames=this.names.map(vt)),e}}class St{constructor(e,t){this.names=e,this.values=t,this.length=e.length}has(e){return-1!==this.names.indexOf(e)}get(e){let t=this.names.indexOf(e);return-1===t?null:[this.values[3*t+2],this.values[3*t+1],this.values[3*t]]}}function xt(e,t){return{named:e,positional:t}}function _t(e){let t=U();for(const[s,n]of Object.entries(e))t[s]=y(n);return t}function Nt(e){return e.map(y)}function Et(e){return{named:_t(e.named),positional:Nt(e.positional)}}const Tt=Symbol("ARGUMENT_ERROR");function Ct(e){return null!==e&&"object"==typeof e&&e[Tt]}function Rt(e){return{[Tt]:!0,error:e}}function Bt(e){return{named:function(e){let t=U();for(const[s,n]of Object.entries(e))try{t[s]=y(n)}catch(e){t[s]=Rt(e)}return t}(e.named),positional:(t=e.positional,t.map((e=>{try{return y(e)}catch(e){return Rt(e)}})))};var t}const At=Object.freeze(Object.create(null)),Ot=gt,Mt=xt(At,Ot);function Vt(e){return"string"==typeof e?e:"function"!=typeof e.toString?"":String(e)}function Dt(e,t){let s,n=h(e,!0);return s=null===n?null:"function"==typeof n?n:n.getHelper(e),a(null!==s,(()=>`Expected a dynamic helper definition, but received an object or function that did not have a helper manager associated with it. The dynamic invocation was \`{{${t.debugLabel}}}\` or \`(${t.debugLabel})\`, and the incorrect definition is the value at the path \`${t.debugLabel}\`, which was: undefined`)),s}function Lt(e){return e===w}Ee.add(77,((e,{op1:t,op2:s})=>{let n=e.stack,i=n.pop(),r=n.pop(),a=e.getOwner();e.context.resolver,e.loadValue(F,function(e,t,s,n){let i,r;return v((()=>{let a=y(t);return a===i||(r=Ve(a,e)?n?Ie(e,a,s,n):n:0===e&&"string"==typeof a&&a||V(a)?Ie(e,a,s,n):null,i=a),r}))}(t,i,a,r))})),Ee.add(107,(e=>{let i,r=e.stack,a=r.pop(),l=r.pop().capture(),o=e.getOwner(),c=v((()=>{void 0!==i&&t(i);let e=y(a);if(Ve(e,1)){let{definition:t,owner:n,positional:r,named:o}=Le(e),u=Dt(t,a);void 0!==o&&(l.named=D({},...o,l.named)),void 0!==r&&(l.positional=r.concat(l.positional)),i=u(l,n),s(c,i)}else if(V(e)){let t=Dt(e,a);i=t(l,o),n(i)&&s(c,i)}else i=w})),u=v((()=>(y(c),y(i))));e.associateDestroyable(c),e.loadValue(F,u)})),Ee.add(16,((e,{op1:t})=>{let s=e.stack,i=e.constants.getValue(t)(s.pop().capture(),e.getOwner(),e.dynamicScope());n(i)&&e.associateDestroyable(i),e.loadValue(F,i)})),Ee.add(21,((e,{op1:t})=>{let s=e.referenceForSymbol(t);e.stack.push(s)})),Ee.add(19,((e,{op1:t})=>{let s=e.stack.pop();e.scope().bindSymbol(t,s)})),Ee.add(20,((e,{op1:t})=>{let s=e.stack.pop(),n=e.stack.pop(),i=e.stack.pop();e.scope().bindBlock(t,[s,n,i])})),Ee.add(37,((e,{op1:t})=>{e.pushRootScope(t,e.getOwner())})),Ee.add(22,((e,{op1:t})=>{let s=e.constants.getValue(t),n=e.stack.pop();e.stack.push(R(n,s))})),Ee.add(23,((e,{op1:t})=>{let{stack:s}=e,n=e.scope().getBlock(t);s.push(n)})),Ee.add(24,(e=>{let{stack:t}=e,s=t.pop();if(s&&!Lt(s)){let[e,n,i]=s;t.push(i),t.push(n),t.push(e)}else t.push(null),t.push(null),t.push(null)})),Ee.add(25,(e=>{let{stack:t}=e,s=t.pop();s&&!Lt(s)?t.push(E):t.push(T)})),Ee.add(26,(e=>{e.stack.pop(),e.stack.pop();let t=e.stack.pop(),s=t&&t.parameters.length;e.stack.push(s?E:T)})),Ee.add(27,((e,{op1:t})=>{let s=new Array(t);for(let n=t;n>0;n--)s[n-1]=e.stack.pop();var n;e.stack.push((n=s,v((()=>{const e=[];for(const t of n){const s=y(t);null!=s&&e.push(Vt(s))}return e.length>0?e.join(""):null}))))})),Ee.add(109,(e=>{let t=e.stack.pop(),s=e.stack.pop(),n=e.stack.pop();e.stack.push(v((()=>r(y(t))?y(s):y(n))))})),Ee.add(110,(e=>{let t=e.stack.pop();e.stack.push(v((()=>!r(y(t)))))})),Ee.add(111,(e=>{let t=e.dynamicScope(),s=e.stack,n=s.pop();s.push(v((()=>{let e=String(y(n));return y(t.get(e))})))})),Ee.add(112,(e=>{let{positional:t}=e.stack.pop().capture();e.loadValue(F,v((()=>{console.log(...Nt(t))})))}));class It{constructor(e,t,s){this.node=e,this.reference=t,this.lastValue=s}evaluate(){let e,t=y(this.reference),{lastValue:s}=this;t!==s&&(e=Je(t)?"":Qe(t)?t:String(t),e!==s)&&(this.node.nodeValue=this.lastValue=e)}}function Ut(e){return function(e){return Qe(e)||Je(e)||"boolean"==typeof e||"number"==typeof e}(e)?ee.String:Ve(e,0)||d(e)?ee.Component:Ve(e,1)||p(e)?ee.Helper:Ke(e)?ee.SafeString:function(e){return Xe(e)&&11===e.nodeType}(e)?ee.Fragment:function(e){return Xe(e)&&"number"==typeof e.nodeType}(e)?ee.Node:ee.String}function Ht(e){return V(e)?Ve(e,0)||d(e)?ee.Component:ee.Helper:ee.String}function jt(e,t){console.info("Use `context`, and `get(<path>)` to debug this template."),t("this");debugger}Ee.add(76,(e=>{let t=e.stack.peek();e.stack.push(Ut(y(t))),_(t)||e.updateWith(new et(t,Ut))})),Ee.add(106,(e=>{let t=e.stack.peek();e.stack.push(Ht(y(t))),_(t)||e.updateWith(new et(t,Ht))})),Ee.add(43,(e=>{let t=e.stack.pop(),s=y(t),n=Je(s)?"":String(s);e.tree().appendDynamicHTML(n)})),Ee.add(44,(e=>{let t=e.stack.pop(),s=y(t).toHTML(),n=Je(s)?"":s;e.tree().appendDynamicHTML(n)})),Ee.add(47,(e=>{let t=e.stack.pop(),s=y(t),n=Je(s)?"":String(s),i=e.tree().appendDynamicText(n);_(t)||e.updateWith(new It(i,t,n))})),Ee.add(45,(e=>{let t=e.stack.pop(),s=y(t);e.tree().appendDynamicFragment(s)})),Ee.add(46,(e=>{let t=e.stack.pop(),s=y(t);e.tree().appendDynamicNode(s)}));let zt=jt;function Wt(e){zt=e}function $t(){zt=jt}class Ft{#e;constructor(e,t){this.scope=e,this.#e=t}get(e){let t,{scope:s}=this,n=this.#e,i=e.split("."),[r,...a]=e.split(".");return"this"===r?t=s.getSelf():n.locals[r]?t=s.getSymbol(n.locals[r]):(t=this.scope.getSelf(),a=i),a.reduce(((e,t)=>R(e,t)),t)}}Ee.add(103,((e,{op1:t})=>{let s=e.constants.getValue(t),n=new Ft(e.scope(),s);zt(y(e.getSelf()),(e=>y(n.get(e))))})),Ee.add(72,((e,{op1:t,op2:s})=>{let n=e.stack,i=n.pop(),r=n.pop(),a=y(r),l=null===a?"@identity":String(a),o=B(i,l),c=y(o);e.updateWith(new et(o,(e=>e.isEmpty()))),c.isEmpty()?e.lowlevel.goto(s+1):(e.enterList(o,t),e.stack.push(c))})),Ee.add(73,(e=>{e.exitList()})),Ee.add(74,((e,{op1:t})=>{let s=e.stack.peek().next();null!==s?e.registerItem(e.enterItem(s)):e.lowlevel.goto(t)}));const Pt={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:!1,attributeHook:!1,elementHook:!1,createCaller:!1,dynamicScope:!1,updateHook:!1,createInstance:!1,wrapped:!1,willDestroy:!1,hasSubOwner:!1};class Gt{getCapabilities(){return Pt}getDebugName({name:e}){return e}getSelf(){return N}getDestroyable(){return null}}const Yt=new Gt;class qt{constructor(e="@glimmer/component/template-only",t="(unknown template-only component)"){this.moduleName=e,this.name=t}toString(){return this.moduleName}}function Jt(e,t){return new qt(e,t)}m(Yt,qt.prototype);const Xt={foreignObject:1,desc:1,title:1},Kt=Object.create(null);class Qt{constructor(e){this.document=e,this.setupUselessElement()}setupUselessElement(){this.uselessElement=this.document.createElement("div")}createElement(e,t){let s,n,i,r;if(t?(s=t.namespaceURI===ke||"svg"===e,i=t.namespaceURI===be||"math"===e,n=!!Xt[t.tagName]):(s="svg"===e,i="math"===e,n=!1),!i&&!s||n)return this.document.createElement(e);if(Kt[e])throw new Error(`Cannot create a ${e} inside an SVG context`);return r=i?be:ke,this.document.createElementNS(r,e)}insertBefore(e,t,s){e.insertBefore(t,s)}insertHTMLBefore(e,t,s){if(""===s){const s=this.createComment("");return e.insertBefore(s,t),new ze(e,s,s)}const n=t?t.previousSibling:e.lastChild;let i;if(null===t)e.insertAdjacentHTML(ye,s),i=e.lastChild;else if(t instanceof HTMLElement)t.insertAdjacentHTML("beforebegin",s),i=t.previousSibling;else{const{uselessElement:n}=this;e.insertBefore(n,t),n.insertAdjacentHTML("beforebegin",s),i=n.previousSibling,e.removeChild(n)}const r=n?n.nextSibling:e.firstChild;return new ze(e,r,i)}createTextNode(e){return this.document.createTextNode(e)}createComment(e){return this.document.createComment(e)}}function Zt(e,t,s){if(!e)return t;if(!function(e,t){const s=e.createElementNS(t,"svg");try{s.insertAdjacentHTML(ye,"<circle></circle>")}catch{}finally{return 1!==s.childNodes.length||s.firstChild.namespaceURI!==ke}}(e,s))return t;const n=e.createElement("div");return class extends t{insertHTMLBefore(e,t,i){return""===i||e.namespaceURI!==s?super.insertHTMLBefore(e,t,i):function(e,t,s,n){let i;if("FOREIGNOBJECT"===e.tagName.toUpperCase()){const e="<svg><foreignObject>"+s+"</foreignObject></svg>";z(t),t.insertAdjacentHTML(ve,e),i=t.firstChild.firstChild}else{const e="<svg>"+s+"</svg>";z(t),t.insertAdjacentHTML(ve,e),i=t.firstChild}return function(e,t,s){const n=e.firstChild;let i=n,r=n;for(;r;){const e=r.nextSibling;t.insertBefore(r,s),i=r,r=e}return new ze(t,n,i)}(i,e,n)}(e,n,i,t)}}}function es(e,t){return e&&function(e){const t=e.createElement("div");return t.appendChild(e.createTextNode("first")),t.insertAdjacentHTML(ye,"second"),2!==t.childNodes.length}(e)?class extends t{constructor(e){super(e),this.uselessComment=e.createComment("")}insertHTMLBefore(e,t,s){if(""===s)return super.insertHTMLBefore(e,t,s);let n=!1;const i=t?t.previousSibling:e.lastChild;i&&i instanceof Text&&(n=!0,e.insertBefore(this.uselessComment,t));const r=super.insertHTMLBefore(e,t,s);return n&&e.removeChild(this.uselessComment),r}}:t}const ts="undefined"==typeof document?null:we(document);let ss=class extends Qt{createElementNS(e,t){return this.document.createElementNS(e,t)}setAttribute(e,t,s,n=null){n?e.setAttributeNS(n,t,s):e.setAttribute(t,s)}};ss=es(ts,ss),ss=Zt(ts,ss,ke);const ns=ss;["b","big","blockquote","body","br","center","code","dd","div","dl","dt","em","embed","h1","h2","h3","h4","h5","h6","head","hr","i","img","li","listing","main","meta","nobr","ol","p","pre","ruby","s","small","span","strong","strike","sub","sup","table","tt","u","ul","var"].forEach((e=>Kt[e]=1));const is=/[\t\n\v\f\r \xa0\u{1680}\u{180e}\u{2000}-\u{200a}\u{2028}\u{2029}\u{202f}\u{205f}\u{3000}\u{feff}]/u,rs="undefined"==typeof document?null:we(document);function as(e){return is.test(e)}class ls extends Qt{constructor(e){super(e),this.document=e,this.namespace=null}setAttribute(e,t,s){e.setAttribute(t,s)}removeAttribute(e,t){e.removeAttribute(t)}insertAfter(e,t,s){this.insertBefore(e,t,s.nextSibling)}}let os=ls;os=es(rs,os),os=Zt(rs,os,ke);const cs=os;function us(e,t){let s,n;if(t in e)n=t,s="prop";else{let i=t.toLowerCase();i in e?(s="prop",n=i):(s="attr",n=t)}return"prop"!==s||"style"!==n.toLowerCase()&&!function(e,t){let s=hs[e.toUpperCase()];return!(!s||!s[t.toLowerCase()])}(e.tagName,n)||(s="attr"),{normalized:n,type:s}}const hs={INPUT:{form:!0,autocorrect:!0,list:!0},SELECT:{form:!0},OPTION:{form:!0},TEXTAREA:{form:!0},LABEL:{form:!0},FIELDSET:{form:!0},LEGEND:{form:!0},OBJECT:{form:!0},OUTPUT:{form:!0},BUTTON:{form:!0}},ds=Symbol("TRANSACTION");class ps{didCreate(e){this.createdComponents.push(e)}didUpdate(e){this.updatedComponents.push(e)}scheduleInstallModifier(e){this.scheduledInstallModifiers.push(e)}scheduleUpdateModifier(e){this.scheduledUpdateModifiers.push(e)}commit(){let{createdComponents:e,updatedComponents:t}=this;for(const{manager:t,state:s}of e)t.didCreate(s);for(const{manager:e,state:s}of t)e.didUpdate(s);let{scheduledInstallModifiers:s,scheduledUpdateModifiers:n}=this;for(const{manager:e,state:t,definition:n}of s){let s=e.getTag(t);if(null!==s){let n=ue((()=>e.install(t)),!1);he(s,n)}else e.install(t)}for(const{manager:e,state:t,definition:s}of n){let s=e.getTag(t);if(null!==s){let n=ue((()=>e.update(t)),!1);he(s,n)}else e.update(t)}}constructor(){this.scheduledInstallModifiers=[],this.scheduledUpdateModifiers=[],this.createdComponents=[],this.updatedComponents=[]}}class ms{static{bs=ds}constructor(e,t){this.delegate=t,this[bs]=null,this.isInteractive=t.isInteractive,this.debugRenderTree=this.delegate.enableDebugTooling?new Ye:void 0,this.isArgumentCaptureError=this.delegate.enableDebugTooling?Ct:void 0,e.appendOperations?(this.appendOperations=e.appendOperations,this.updateOperations=e.updateOperations):e.document&&(this.appendOperations=new ns(e.document),this.updateOperations=new ls(e.document))}getAppendOperations(){return this.appendOperations}getDOM(){return this.updateOperations}begin(){this[ds],this.debugRenderTree?.begin(),this[ds]=new ps}get transaction(){return this[ds]}didCreate(e){this.transaction.didCreate(e)}didUpdate(e){this.transaction.didUpdate(e)}scheduleInstallModifier(e){this.isInteractive&&this.transaction.scheduleInstallModifier(e)}scheduleUpdateModifier(e){this.isInteractive&&this.transaction.scheduleUpdateModifier(e)}commit(){let e=this.transaction;this[ds]=null,e.commit(),this.debugRenderTree?.commit(),this.delegate.onTransactionCommit()}}function fs(e,t,s,n){return{env:new ms(e,t),program:new fe(s.constants,s.heap),resolver:n}}function gs(e,t){if(e[ds])t();else{e.begin();try{t()}finally{e.commit()}}}var bs;function ks(e){return f(e,{})}const vs=ks((({positional:e})=>v((()=>Nt(e)),null,"array"))),ys=e=>(e=>null==e||"function"!=typeof e.toString)(e)?"":String(e),ws=ks((({positional:e})=>v((()=>Nt(e).map(ys).join("")),null,"concat"))),Ss=ks((({positional:e})=>{let t=e[0];return v((()=>(...s)=>{let[n,...i]=Nt(e);if(!A(t))return n.call(null,...i,...s);{let e=i.length>0?i[0]:s[0];O(t,e)}}),null,"fn")})),xs=ks((({positional:e})=>{let t=e[0]??w,s=e[1]??w;return v((()=>{let e=y(t);if(W(e))return l(e,String(y(s)))}),(e=>{let n=y(t);if(W(n))return o(n,String(y(s)),e)}),"get")})),_s=ks((({named:e})=>{let t=v((()=>_t(e)),null,"hash"),s=new Map;for(let t in e)s.set(t,e[t]);return t.children=s,t}));function Ns(e){return pe(e.argsCache)}class Es{constructor(e,t=()=>Mt){let s=de((()=>t(e)));this.argsCache=s}get named(){return Ns(this).named||At}get positional(){return Ns(this).positional||Ot}}function Ts(e,t,n){const i=ge(e),r=h(t).getDelegateFor(i);let a,l=new Es(e,n),o=r.createHelper(t,l);if(!g(r))throw new Error("TODO: unreachable, to be implemented with hasScheduledEffect");if(a=de((()=>r.getValue(o))),s(e,a),b(r)){let e=r.getDestroyable(o);s(a,e)}return a}class Cs{constructor(t,s){this.tag=me(),this.listener=null,this.element=t,this.args=s,e(this,(()=>{let{element:e,listener:t}=this;if(t){let{eventName:s,callback:n,options:i}=t;As(e,s,n,i)}}))}updateListener(){let{element:e,args:t,listener:s}=this;t.positional[0];let n=y(t.positional[0]);t.positional[1];let i,r,a,l=y(t.positional[1]);{let{once:e,passive:s,capture:n}=t.named;e&&(i=y(e)),s&&(r=y(s)),n&&(a=y(n))}let o,c=!1;if(c=null===s||n!==s.eventName||l!==s.userProvidedCallback||i!==s.once||r!==s.passive||a!==s.capture,c&&(void 0===i&&void 0===r&&void 0===a||(o={once:i,passive:r,capture:a})),c){let t=l;this.listener={eventName:n,callback:t,userProvidedCallback:l,once:i,passive:r,capture:a,options:o},s&&As(e,s.eventName,s.callback,s.options),function(e,t,s,n){Rs++,e.addEventListener(t,s,n)}(e,n,t,o)}}}let Rs=0,Bs=0;function As(e,t,s,n){Bs++,e.removeEventListener(t,s,n)}const Os=k(new class{getDebugName(){return"on"}getDebugInstance(){return null}get counters(){return{adds:Rs,removes:Bs}}create(e,t,s,n){return new Cs(t,n)}getTag({tag:e}){return e}install(e){e.updateListener()}update(e){e.updateListener()}getDestroyable(e){return e}},{});class Ms{constructor(e,t,s,n){this.stack=e,this.externs=s,this.currentOpSize=0,this.context=t,this.registers=n}fetchRegister(e){return this.registers[e]}loadRegister(e,t){this.registers[e]=t}setPc(e){this.registers[Y]=e}pushFrame(){this.stack.push(this.registers[q]),this.stack.push(this.registers[J]),this.registers[J]=this.registers[X]-1}popFrame(){this.registers[X]=this.registers[J]-1,this.registers[q]=this.stack.get(0),this.registers[J]=this.stack.get(1)}pushSmallFrame(){this.stack.push(this.registers[q])}popSmallFrame(){this.registers[q]=this.stack.pop()}goto(e){this.setPc(this.target(e))}target(e){return this.registers[Y]+e-this.currentOpSize}call(e){this.registers[q]=this.registers[Y],this.setPc(this.context.program.heap.getaddr(e))}returnTo(e){this.registers[q]=this.target(e)}return(){this.setPc(this.registers[q])}nextStatement(){let{registers:e,context:t}=this,s=e[Y];if(-1===s)return null;let n=t.program.opcode(s),i=this.currentOpSize=n.size;return this.registers[Y]+=i,n}evaluateOuter(e,t){this.evaluateInner(e,t)}evaluateInner(e,t){e.isMachine?this.evaluateMachine(e,t):this.evaluateSyscall(e,t)}evaluateMachine(e,t){switch(e.type){case 0:return void this.pushFrame();case 1:return void this.popFrame();case 3:return void this.call(e.op1);case 2:return void t.call(this.stack.pop());case 4:return void this.goto(e.op1);case 5:return void t.return();case 6:return void this.returnTo(e.op1)}}evaluateSyscall(e,t){Ee.evaluate(t,e,e.type)}}const Vs=["javascript:","vbscript:"],Ds=["A","BODY","LINK","IMG","IFRAME","BASE","FORM"],Ls=["EMBED"],Is=["href","src","background","action"],Us=["src"];function Hs(e,t){return-1!==e.indexOf(t)}function js(e,t){return(null===e||Hs(Ds,e))&&Hs(Is,t)}function zs(e,t){return null!==e&&Hs(Ls,e)&&Hs(Us,t)}function Ws(e,t){return js(e,t)||zs(e,t)}let $s;function Fs(e,t,s){if(null==s)return s;if(Ke(s))return s.toHTML();const n=e.tagName.toUpperCase();let i=qe(s);if(js(n,t)){let e=(r=i,$s||($s=function(){const e=URL;if("object"==typeof e&&null!==e&&"function"==typeof e.parse){let t=e;return e=>{let s=null;return"string"==typeof e&&(s=t.parse(e).protocol),null===s?":":s}}if("function"==typeof e)return t=>{try{return new e(t).protocol}catch{return":"}};throw new Error('@glimmer/runtime needs a valid "globalThis.URL"')}()),$s(r));if(Hs(Vs,e))return`unsafe:${i}`}var r;return zs(n,t)?`unsafe:${i}`:i}function Ps(e,t,s){const{tagName:n,namespaceURI:i}=e,r={element:e,name:t,namespace:s};if(i===ke)return Gs(n,t,r);const{type:a,normalized:l}=us(e,t);return"attr"===a?Gs(n,l,r):function(e,t,s){return Ws(e,t)?new Xs(t,s):function(e,t){return("INPUT"===e||"TEXTAREA"===e)&&"value"===t}(e,t)?new Qs(t,s):function(e,t){return"OPTION"===e&&"selected"===t}(e,t)?new Zs(t,s):new Js(t,s)}(n,l,r)}function Gs(e,t,s){return Ws(e,t)?new Ks(s):new qs(s)}class Ys{constructor(e){this.attribute=e}}class qs extends Ys{set(e,t,s){const n=en(t);if(null!==n){const{name:t,namespace:s}=this.attribute;e.__setAttribute(t,n,s)}}update(e,t){const s=en(e),{element:n,name:i}=this.attribute;null===s?n.removeAttribute(i):n.setAttribute(i,s)}}class Js extends Ys{constructor(e,t){super(t),this.normalizedName=e}set(e,t,s){null!=t&&(this.value=t,e.__setProperty(this.normalizedName,t))}update(e,t){const{element:s}=this.attribute;this.value!==e&&(s[this.normalizedName]=this.value=e,null==e&&this.removeAttribute())}removeAttribute(){const{element:e,namespace:t}=this.attribute;t?e.removeAttributeNS(t,this.normalizedName):e.removeAttribute(this.normalizedName)}}class Xs extends Js{set(e,t,s){const{element:n,name:i}=this.attribute,r=Fs(n,i,t);super.set(e,r,s)}update(e,t){const{element:s,name:n}=this.attribute,i=Fs(s,n,e);super.update(i,t)}}class Ks extends qs{set(e,t,s){const{element:n,name:i}=this.attribute,r=Fs(n,i,t);super.set(e,r,s)}update(e,t){const{element:s,name:n}=this.attribute,i=Fs(s,n,e);super.update(i,t)}}class Qs extends Js{set(e,t){e.__setProperty("value",qe(t))}update(e){const t=this.attribute.element,s=t.value,n=qe(e);s!==n&&(t.value=n)}}class Zs extends Js{set(e,t){null!=t&&!1!==t&&e.__setProperty("selected",!0)}update(e){this.attribute.element.selected=!!e}}function en(e){return!1===e||null==e||void 0===e.toString?null:!0===e?"":"function"==typeof e?null:String(e)}class tn{constructor(e){this.node=e}firstNode(){return this.node}}class sn{constructor(e){this.node=e}lastNode(){return this.node}}class nn{static forInitialRender(e,t){return new this(e,t.element,t.nextSibling).initialize()}static resume(e,t){let s=new this(e,t.parentElement(),t.reset(e)).initialize();return s.pushBlock(t),s}constructor(e,t,s){this.constructing=null,this.operations=null,this.cursors=new L,this.modifierStack=new L,this.blockStack=new L,this.pushElement(t,s),this.env=e,this.dom=e.getAppendOperations(),this.updateOperations=e.getDOM()}initialize(){return this.pushAppendingBlock(),this}debugBlocks(){return this.blockStack.toArray()}get element(){return this.cursors.current.element}get nextSibling(){return this.cursors.current.nextSibling}get hasBlocks(){return this.blockStack.size>0}block(){return this.blockStack.current}popElement(){this.cursors.pop(),this.cursors.current}pushAppendingBlock(){return this.pushBlock(new rn(this.element))}pushResettableBlock(){return this.pushBlock(new ln(this.element))}pushBlockList(e){return this.pushBlock(new on(this.element,e))}pushBlock(e,t=!1){let s=this.blockStack.current;return null!==s&&(t||s.didAppendBounds(e)),this.__openBlock(),this.blockStack.push(e),e}popBlock(){return this.block().finalize(this),this.__closeBlock(),this.blockStack.pop()}__openBlock(){}__closeBlock(){}openElement(e){let t=this.__openElement(e);return this.constructing=t,t}__openElement(e){return this.dom.createElement(e,this.element)}flushElement(e){let t=this.element,s=this.constructing;this.__flushElement(t,s),this.constructing=null,this.operations=null,this.pushModifiers(e),this.pushElement(s,null),this.didOpenElement(s)}__flushElement(e,t){this.dom.insertBefore(e,t,this.nextSibling)}closeElement(){return this.willCloseElement(),this.popElement(),this.popModifiers()}pushRemoteElement(e,t,s){return this.__pushRemoteElement(e,t,s)}__pushRemoteElement(e,t,s){if(this.pushElement(e,s),void 0===s)for(;e.lastChild;)e.removeChild(e.lastChild);let n=new an(e);return this.pushBlock(n,!0)}popRemoteElement(){const e=this.popBlock();return this.popElement(),e}pushElement(e,t=null){this.cursors.push(new je(e,t))}pushModifiers(e){this.modifierStack.push(e)}popModifiers(){return this.modifierStack.pop()}didAppendBounds(e){return this.block().didAppendBounds(e),e}didAppendNode(e){return this.block().didAppendNode(e),e}didOpenElement(e){return this.block().openElement(e),e}willCloseElement(){this.block().closeElement()}appendText(e){return this.didAppendNode(this.__appendText(e))}__appendText(e){let{dom:t,element:s,nextSibling:n}=this,i=t.createTextNode(e);return t.insertBefore(s,i,n),i}__appendNode(e){return this.dom.insertBefore(this.element,e,this.nextSibling),e}__appendFragment(e){let t=e.firstChild;if(t){let s=new ze(this.element,t,e.lastChild);return this.dom.insertBefore(this.element,e,this.nextSibling),s}{const e=this.__appendComment("");return new ze(this.element,e,e)}}__appendHTML(e){return this.dom.insertHTMLBefore(this.element,this.nextSibling,e)}appendDynamicHTML(e){let t=this.trustedContent(e);this.didAppendBounds(t)}appendDynamicText(e){let t=this.untrustedContent(e);return this.didAppendNode(t),t}appendDynamicFragment(e){let t=this.__appendFragment(e);this.didAppendBounds(t)}appendDynamicNode(e){let t=this.__appendNode(e),s=new ze(this.element,t,t);this.didAppendBounds(s)}trustedContent(e){return this.__appendHTML(e)}untrustedContent(e){return this.__appendText(e)}appendComment(e){return this.didAppendNode(this.__appendComment(e))}__appendComment(e){let{dom:t,element:s,nextSibling:n}=this,i=t.createComment(e);return t.insertBefore(s,i,n),i}__setAttribute(e,t,s){this.dom.setAttribute(this.constructing,e,t,s)}__setProperty(e,t){this.constructing[e]=t}setStaticAttribute(e,t,s){this.__setAttribute(e,t,s)}setDynamicAttribute(e,t,s,n){let i=Ps(this.constructing,e,n);return i.set(this,t,this.env),i}}class rn{constructor(e){this.parent=e,this.first=null,this.last=null,this.nesting=0}parentElement(){return this.parent}firstNode(){return this.first.firstNode()}lastNode(){return this.last.lastNode()}openElement(e){this.didAppendNode(e),this.nesting++}closeElement(){this.nesting--}didAppendNode(e){0===this.nesting&&(this.first||(this.first=new tn(e)),this.last=new sn(e))}didAppendBounds(e){0===this.nesting&&(this.first||(this.first=e),this.last=e)}finalize(e){null===this.first&&e.appendComment("")}}class an extends rn{constructor(t){super(t),e(this,(()=>{this.parentElement()===this.firstNode().parentNode&&$e(this)}))}}class ln extends rn{constructor(e){super(e)}reset(){t(this);let e=$e(this);return this.first=null,this.last=null,this.nesting=0,e}}class on{constructor(e,t){this.parent=e,this.boundList=t,this.parent=e,this.boundList=t}parentElement(){return this.parent}firstNode(){return this.boundList[0].firstNode()}lastNode(){let e=this.boundList;return e[e.length-1].lastNode()}openElement(e){}closeElement(){}didAppendNode(e){}didAppendBounds(e){}finalize(e){this.boundList.length}}function cn(e,t){return nn.forInitialRender(e,t)}class un{constructor(e,{alwaysRevalidate:t=!1}){this.frameStack=new L,this.env=e,this.dom=e.getDOM(),this.alwaysRevalidate=t}execute(e,t){this._execute(e,t)}_execute(e,t){let{frameStack:s}=this;for(this.try(e,t);!s.isEmpty();){let e=this.frame.nextStatement();void 0!==e?e.evaluate(this):s.pop()}}get frame(){return this.frameStack.current}goto(e){this.frame.goto(e)}try(e,t){this.frameStack.push(new fn(e,t))}throw(){this.frame.handleException(),this.frameStack.pop()}}class hn{constructor(e,t,s,n){this.state=e,this.context=t,this.children=n,thi