@nextwebwg/html-next 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +26 -0
  3. package/dist/ast.d.ts +7 -0
  4. package/dist/ast.d.ts.map +1 -0
  5. package/dist/ast.js +2 -0
  6. package/dist/ast.js.map +1 -0
  7. package/dist/browser-loader.bundle.js +9 -0
  8. package/dist/browser-loader.d.ts +35 -0
  9. package/dist/browser-loader.d.ts.map +1 -0
  10. package/dist/browser-loader.js +83 -0
  11. package/dist/browser-loader.js.map +1 -0
  12. package/dist/browser-source.d.ts +10 -0
  13. package/dist/browser-source.d.ts.map +1 -0
  14. package/dist/browser-source.js +97 -0
  15. package/dist/browser-source.js.map +1 -0
  16. package/dist/browser.d.ts +5 -0
  17. package/dist/browser.d.ts.map +1 -0
  18. package/dist/browser.js +9 -0
  19. package/dist/browser.js.map +1 -0
  20. package/dist/cli.d.ts +31 -0
  21. package/dist/cli.d.ts.map +1 -0
  22. package/dist/cli.js +138 -0
  23. package/dist/cli.js.map +1 -0
  24. package/dist/component-styles-build.d.ts +11 -0
  25. package/dist/component-styles-build.d.ts.map +1 -0
  26. package/dist/component-styles-build.js +74 -0
  27. package/dist/component-styles-build.js.map +1 -0
  28. package/dist/component-styles.d.ts +37 -0
  29. package/dist/component-styles.d.ts.map +1 -0
  30. package/dist/component-styles.js +236 -0
  31. package/dist/component-styles.js.map +1 -0
  32. package/dist/contract-platform.d.ts +5 -0
  33. package/dist/contract-platform.d.ts.map +1 -0
  34. package/dist/contract-platform.js +8 -0
  35. package/dist/contract-platform.js.map +1 -0
  36. package/dist/contract.d.ts +14 -0
  37. package/dist/contract.d.ts.map +1 -0
  38. package/dist/contract.js +234 -0
  39. package/dist/contract.js.map +1 -0
  40. package/dist/controller-files.d.ts +10 -0
  41. package/dist/controller-files.d.ts.map +1 -0
  42. package/dist/controller-files.js +54 -0
  43. package/dist/controller-files.js.map +1 -0
  44. package/dist/controller.d.ts +15 -0
  45. package/dist/controller.d.ts.map +1 -0
  46. package/dist/controller.js +33 -0
  47. package/dist/controller.js.map +1 -0
  48. package/dist/data.d.ts +28 -0
  49. package/dist/data.d.ts.map +1 -0
  50. package/dist/data.js +100 -0
  51. package/dist/data.js.map +1 -0
  52. package/dist/diagnostics.d.ts +11 -0
  53. package/dist/diagnostics.d.ts.map +1 -0
  54. package/dist/diagnostics.js +13 -0
  55. package/dist/diagnostics.js.map +1 -0
  56. package/dist/expression.d.ts +80 -0
  57. package/dist/expression.d.ts.map +1 -0
  58. package/dist/expression.js +474 -0
  59. package/dist/expression.js.map +1 -0
  60. package/dist/freeze.d.ts +2 -0
  61. package/dist/freeze.d.ts.map +1 -0
  62. package/dist/freeze.js +8 -0
  63. package/dist/freeze.js.map +1 -0
  64. package/dist/generate.d.ts +11 -0
  65. package/dist/generate.d.ts.map +1 -0
  66. package/dist/generate.js +41 -0
  67. package/dist/generate.js.map +1 -0
  68. package/dist/generated/dom-properties.d.ts +8 -0
  69. package/dist/generated/dom-properties.d.ts.map +1 -0
  70. package/dist/generated/dom-properties.js +1410 -0
  71. package/dist/generated/dom-properties.js.map +1 -0
  72. package/dist/generated-runtime.d.ts +42 -0
  73. package/dist/generated-runtime.d.ts.map +1 -0
  74. package/dist/generated-runtime.js +266 -0
  75. package/dist/generated-runtime.js.map +1 -0
  76. package/dist/graph.d.ts +37 -0
  77. package/dist/graph.d.ts.map +1 -0
  78. package/dist/graph.js +81 -0
  79. package/dist/graph.js.map +1 -0
  80. package/dist/index.d.ts +29 -0
  81. package/dist/index.d.ts.map +1 -0
  82. package/dist/index.js +23 -0
  83. package/dist/index.js.map +1 -0
  84. package/dist/language.d.ts +7 -0
  85. package/dist/language.d.ts.map +1 -0
  86. package/dist/language.js +43 -0
  87. package/dist/language.js.map +1 -0
  88. package/dist/names.d.ts +4 -0
  89. package/dist/names.d.ts.map +1 -0
  90. package/dist/names.js +19 -0
  91. package/dist/names.js.map +1 -0
  92. package/dist/node-loader.d.ts +22 -0
  93. package/dist/node-loader.d.ts.map +1 -0
  94. package/dist/node-loader.js +109 -0
  95. package/dist/node-loader.js.map +1 -0
  96. package/dist/package-config.d.ts +22 -0
  97. package/dist/package-config.d.ts.map +1 -0
  98. package/dist/package-config.js +2 -0
  99. package/dist/package-config.js.map +1 -0
  100. package/dist/package.d.ts +9 -0
  101. package/dist/package.d.ts.map +1 -0
  102. package/dist/package.js +208 -0
  103. package/dist/package.js.map +1 -0
  104. package/dist/parser.d.ts +11 -0
  105. package/dist/parser.d.ts.map +1 -0
  106. package/dist/parser.js +938 -0
  107. package/dist/parser.js.map +1 -0
  108. package/dist/platform.d.ts +3 -0
  109. package/dist/platform.d.ts.map +1 -0
  110. package/dist/platform.js +26 -0
  111. package/dist/platform.js.map +1 -0
  112. package/dist/reactivity.d.ts +88 -0
  113. package/dist/reactivity.d.ts.map +1 -0
  114. package/dist/reactivity.js +594 -0
  115. package/dist/reactivity.js.map +1 -0
  116. package/dist/registry.d.ts +14 -0
  117. package/dist/registry.d.ts.map +1 -0
  118. package/dist/registry.js +39 -0
  119. package/dist/registry.js.map +1 -0
  120. package/dist/resolve.d.ts +24 -0
  121. package/dist/resolve.d.ts.map +1 -0
  122. package/dist/resolve.js +65 -0
  123. package/dist/resolve.js.map +1 -0
  124. package/dist/runtime.d.ts +110 -0
  125. package/dist/runtime.d.ts.map +1 -0
  126. package/dist/runtime.js +1926 -0
  127. package/dist/runtime.js.map +1 -0
  128. package/dist/sanitize.d.ts +8 -0
  129. package/dist/sanitize.d.ts.map +1 -0
  130. package/dist/sanitize.js +38 -0
  131. package/dist/sanitize.js.map +1 -0
  132. package/dist/source-graph.d.ts +5 -0
  133. package/dist/source-graph.d.ts.map +1 -0
  134. package/dist/source-graph.js +60 -0
  135. package/dist/source-graph.js.map +1 -0
  136. package/dist/source-parser.d.ts +4 -0
  137. package/dist/source-parser.d.ts.map +1 -0
  138. package/dist/source-parser.js +38 -0
  139. package/dist/source-parser.js.map +1 -0
  140. package/dist/source.d.ts +4 -0
  141. package/dist/source.d.ts.map +1 -0
  142. package/dist/source.js +6 -0
  143. package/dist/source.js.map +1 -0
  144. package/dist/targets/backend.d.ts +28 -0
  145. package/dist/targets/backend.d.ts.map +1 -0
  146. package/dist/targets/backend.js +42 -0
  147. package/dist/targets/backend.js.map +1 -0
  148. package/dist/targets/docs.d.ts +3 -0
  149. package/dist/targets/docs.d.ts.map +1 -0
  150. package/dist/targets/docs.js +85 -0
  151. package/dist/targets/docs.js.map +1 -0
  152. package/dist/targets/native-reactive.d.ts +41 -0
  153. package/dist/targets/native-reactive.d.ts.map +1 -0
  154. package/dist/targets/native-reactive.js +169 -0
  155. package/dist/targets/native-reactive.js.map +1 -0
  156. package/dist/targets/shared.d.ts +15 -0
  157. package/dist/targets/shared.d.ts.map +1 -0
  158. package/dist/targets/shared.js +122 -0
  159. package/dist/targets/shared.js.map +1 -0
  160. package/dist/targets/vanilla.d.ts +6 -0
  161. package/dist/targets/vanilla.d.ts.map +1 -0
  162. package/dist/targets/vanilla.js +442 -0
  163. package/dist/targets/vanilla.js.map +1 -0
  164. package/dist/targets/vue.d.ts +3 -0
  165. package/dist/targets/vue.d.ts.map +1 -0
  166. package/dist/targets/vue.js +577 -0
  167. package/dist/targets/vue.js.map +1 -0
  168. package/dist/template.d.ts +172 -0
  169. package/dist/template.d.ts.map +1 -0
  170. package/dist/template.js +2 -0
  171. package/dist/template.js.map +1 -0
  172. package/dist/type-system.d.ts +80 -0
  173. package/dist/type-system.d.ts.map +1 -0
  174. package/dist/type-system.js +414 -0
  175. package/dist/type-system.js.map +1 -0
  176. package/dist/types.d.ts +51 -0
  177. package/dist/types.d.ts.map +1 -0
  178. package/dist/types.js +2 -0
  179. package/dist/types.js.map +1 -0
  180. package/dist/validate.d.ts +38 -0
  181. package/dist/validate.d.ts.map +1 -0
  182. package/dist/validate.js +297 -0
  183. package/dist/validate.js.map +1 -0
  184. package/dist/validation.d.ts +6 -0
  185. package/dist/validation.d.ts.map +1 -0
  186. package/dist/validation.js +6 -0
  187. package/dist/validation.js.map +1 -0
  188. package/dist/validity-css.d.ts +6 -0
  189. package/dist/validity-css.d.ts.map +1 -0
  190. package/dist/validity-css.js +11 -0
  191. package/dist/validity-css.js.map +1 -0
  192. package/dist/validity.d.ts +45 -0
  193. package/dist/validity.d.ts.map +1 -0
  194. package/dist/validity.js +445 -0
  195. package/dist/validity.js.map +1 -0
  196. package/package.json +124 -0
@@ -0,0 +1,9 @@
1
+ var K=class extends Error{diagnostic;constructor(e){let n=e.source?`${e.source}: `:"";super(`${n}${e.code}: ${e.message}`),this.name="HtmlDiagnosticError",this.diagnostic=Object.freeze({...e})}};function y(t,e,n){throw new K(n===void 0?{code:t,message:e}:{code:t,message:e,source:n})}function at([t],[e]){return t.localeCompare(e)}async function ct(t,e){let n=new Map,r=new Map,o=new Map,i=async c=>{let l=new URL(c.url).href,f=r.get(l)??l,d=n.get(f);if(d!==void 0)return d.url;let h;try{h=await e.fetchComponent(l)}catch(g){if(g instanceof K)throw g;y("HL009",`Component \`${l}\` failed to load: ${g instanceof Error?g.message:String(g)}.`,l)}let u=e.resolver.assertFinalURL(c,h.url,l);r.set(l,u);let p=n.get(u);if(p!==void 0)return p.url;let m=e.parseComponentResource(h.source,u),w=m.definition,k=o.get(w.contract.tag);k!==void 0&&k!==u&&y("HL007",`Both \`${k}\` and \`${u}\` declare <${w.contract.tag}>.`,u),o.set(w.contract.tag,u);let x={url:u,trustRoot:c.trustRoot,definition:w,dependencies:[],shadowedByCustomElement:e.isCustomElementRegistered?.(w.contract.tag)??!1,complete:!1};if(n.set(u,x),w.controller!==void 0){let g=e.resolver.resolveDependency(w.controller,u,c.trustRoot);x.controller=Object.freeze({specifier:w.controller,url:g.url})}for(let g of m.dependencies){let b=e.resolver.resolveDependency(g,u,c.trustRoot),v=await i(b);x.dependencies.includes(v)||x.dependencies.push(v)}return x.complete=!0,u},a=[];for(let c of t)a.push(await i(e.resolver.resolveRoot(c)));let s=[];for(let[c,l]of Array.from(n).sort(at))l.complete||y("HL008",`Component graph did not finish loading \`${c}\`.`),s.push([c,Object.freeze({url:c,trustRoot:l.trustRoot,definition:l.definition,dependencies:Object.freeze(Array.from(l.dependencies)),...l.controller===void 0?{}:{controller:l.controller},shadowedByCustomElement:l.shadowedByCustomElement})]);return Object.freeze({roots:Object.freeze(a),nodes:new Map(s),tags:new Map(Array.from(o).sort(at))})}function J(t){if(typeof t!="object"||t===null||Object.isFrozen(t))return t;for(let e of Object.values(t))J(e);return Object.freeze(t)}function dt(t){let e="",n=!0;for(let r of t)r==="-"?n=!0:(e+=n?r.toUpperCase():r,n=!1);return e}function Re(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}var hn=new Set(["string","boolean","number","integer","null","absent","trusted-html","trusted-script","function","unknown"]),ce=class extends SyntaxError{constructor(n,r){super(`${n} at character ${r+1}.`);this.position=r;this.name="TypeSyntaxError"}position},Se=class{constructor(e){this.source=e}source;#e=0;parse(){let e=this.#t();return this.#d(),this.#e!==this.source.length&&this.#l("Unexpected type syntax"),e}#t(){let e=[this.#n()];for(;this.#s("|");)e.push(this.#n());return e.length===1?e[0]:Ne(e)}#n(){let e=this.#o();for(;this.#s("?");)e=Ne([e,{kind:"terminal",name:"null"},{kind:"terminal",name:"absent"}]);return e}#o(){if(this.#s("(")){let r=this.#t();return this.#a(")"),r}let e=this.#c();if(e!==void 0)return{kind:"keyword",value:e};let n=this.#r();if(n===void 0&&this.#l("Expected a type, keyword, or group"),n==="list"||n==="record"){this.#a("(");let r=this.#t();return this.#a(")"),n==="list"?{kind:"list",item:r}:{kind:"record",value:r}}return n==="object"?this.#i():hn.has(n)?{kind:"terminal",name:n}:{kind:"keyword",value:n}}#i(){this.#a("("),this.#a("{");let e=[],n=!1;for(;!this.#s("}");){if(this.#d(),this.source.startsWith("...",this.#e))this.#e+=3,n=!0;else{let r=this.#c()??this.#r();r===void 0&&this.#l("Expected an object field or `...`");let o=this.#s("?");this.#a(":");let i=this.#t();e.some(a=>a.name===r)&&this.#l(`Duplicate object field \`${r}\``),e.push({name:r,type:i,optional:o})}if(this.#s("}"))break;this.#a(","),n&&(this.#d(),this.source.startsWith("}",this.#e)||this.#l("The open marker must be last"))}return this.#a(")"),{kind:"object",fields:e,open:n}}#r(){this.#d();let e=/^[A-Za-z_][A-Za-z0-9_-]*/.exec(this.source.slice(this.#e));if(e!==null)return this.#e+=e[0].length,e[0]}#c(){this.#d();let e=this.source[this.#e];if(e!=='"'&&e!=="'")return;this.#e+=1;let n="";for(;this.#e<this.source.length;){let r=this.source[this.#e++];if(r===e)return n;if(r!=="\\"){n+=r;continue}this.#e>=this.source.length&&this.#l("Unterminated escape");let o=this.source[this.#e++];n+={n:`
2
+ `,r:"\r",t:" ","\\":"\\",'"':'"',"'":"'"}[o]??o}this.#l("Unterminated quoted keyword")}#s(e){return this.#d(),this.source.startsWith(e,this.#e)?(this.#e+=e.length,!0):!1}#a(e){this.#s(e)||this.#l(`Expected \`${e}\``)}#d(){for(;/\s/.test(this.source[this.#e]??"");)this.#e+=1}#l(e){throw new ce(e,this.#e)}};function Ne(t){let e=t.flatMap(o=>o.kind==="union"?o.members:[o]),n=new Map(e.map(o=>[U(o),o])),r=Array.from(n.values());return r.length===1?r[0]:{kind:"union",members:r}}function de(t){if(t.trim()==="")throw new ce("A type expression cannot be empty",0);return J(new Se(t).parse())}function $e(t){return typeof t=="object"&&t!==null&&"kind"in t&&["terminal","keyword","union","list","record","object"].includes(String(t.kind))}function le(t){return $e(t)?t:typeof t=="string"?{kind:"terminal",name:t}:Ne(t.enum.map(e=>({kind:"keyword",value:e})))}function U(t){let e=$e(t)?t:le(t);switch(e.kind){case"terminal":return e.name;case"keyword":return/^[A-Za-z_][A-Za-z0-9_-]*$/.test(e.value)?e.value:JSON.stringify(e.value);case"union":return e.members.map(n=>U(n)).join(" | ");case"list":return`list(${U(e.item)})`;case"record":return`record(${U(e.value)})`;case"object":return`object({ ${[...e.fields.map(n=>`${n.name}${n.optional?"?":""}: ${U(n.type)}`),...e.open?["..."]:[]].join(", ")} })`}}function j(t,e,n){return{ok:!1,issues:[{reason:t,message:e,path:n}]}}function Q(t,e){return typeof e=="number"?`${t}[${e}]`:/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)?`${t}.${e}`:`${t}[${JSON.stringify(e)}]`}function lt(t){if(typeof t!="object"||t===null||Array.isArray(t))return!1;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}function Te(t){if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return Symbol.for("html-next.bad-json")}}function yn(t,e){if(typeof t!="object"||t===null)return!1;if(t.kind===e&&"value"in t)return!0;let n=e==="trusted-html"?"TrustedHTML":"TrustedScript";return t.constructor?.name===n||Object.prototype.toString.call(t)===`[object ${n}]`}function gn(t,e,n){switch(e){case"string":return typeof t=="string"?{ok:!0,value:t}:j("typeMismatch","Must be a string.",n);case"boolean":return typeof t=="boolean"?{ok:!0,value:t}:t===""||t==="true"?{ok:!0,value:!0}:t==="false"?{ok:!0,value:!1}:j("typeMismatch","Must be true or false.",n);case"number":case"integer":{let r=typeof t=="number"?t:typeof t=="string"&&t.trim()!==""?Number(t):Number.NaN;return Number.isFinite(r)?e==="integer"&&!Number.isInteger(r)?j("typeMismatch","Must be an integer.",n):{ok:!0,value:r}:j("badInput",`Must be ${e==="integer"?"an integer":"a finite number"}.`,n)}case"null":return t===null?{ok:!0,value:null}:j("typeMismatch","Must be null.",n);case"absent":return t===void 0?{ok:!0,value:void 0}:j("typeMismatch","Must be absent.",n);case"trusted-html":case"trusted-script":return yn(t,e)?{ok:!0,value:t}:j("untrustedValue",`Must be a ${e==="trusted-html"?"TrustedHTML":"TrustedScript"} value.`,n);case"function":return typeof t=="function"?{ok:!0,value:t}:j("typeMismatch","Must be a function supplied through a property.",n);case"unknown":return{ok:!0,value:t}}}function Y(t,e,n){switch(e.kind){case"terminal":return gn(t,e.name,n);case"keyword":return t===e.value?{ok:!0,value:t}:j("typeMismatch",`Must be ${JSON.stringify(e.value)}.`,n);case"union":{for(let r of e.members){let o=Y(t,r,n);if(o.ok)return o}return j("typeMismatch",`Must match ${U(e)}.`,n)}case"list":{let r=Te(t);if(!Array.isArray(r))return j("typeMismatch","Must be a list.",n);let o=[],i=[];return r.forEach((a,s)=>{let c=Y(a,e.item,Q(n,s));c.ok?o.push(c.value):i.push(...c.issues)}),i.length===0?{ok:!0,value:o}:{ok:!1,issues:i}}case"record":{let r=Te(t);if(!lt(r))return j("typeMismatch","Must be a string-keyed record.",n);let o={},i=[];for(let[a,s]of Object.entries(r)){let c=Y(s,e.value,Q(n,a));c.ok?o[a]=c.value:i.push(...c.issues)}return i.length===0?{ok:!0,value:o}:{ok:!1,issues:i}}case"object":{let r=Te(t);if(!lt(r))return j("typeMismatch","Must be an object.",n);let o={},i=[],a=new Map(e.fields.map(s=>[s.name,s]));for(let s of e.fields){if(!(s.name in r)){s.optional||i.push({reason:"typeMismatch",message:"Required field is absent.",path:Q(n,s.name)});continue}let c=Y(r[s.name],s.type,Q(n,s.name));c.ok?o[s.name]=c.value:i.push(...c.issues)}for(let[s,c]of Object.entries(r))a.has(s)||(e.open?o[s]=c:i.push({reason:"typeMismatch",message:"Field is not declared by this closed object type.",path:Q(n,s)}));return i.length===0?{ok:!0,value:o}:{ok:!1,issues:i}}}}function _(t,e,n="$"){return Y(t,le(e),n)}function Ae(t,e){let n=_(t,e);if(!n.ok)throw new TypeError(n.issues.map(o=>`${o.path}: ${o.message}`).join("; "));let r=le(e);if(r.kind==="terminal"&&(r.name==="function"||r.name==="unknown"))throw new TypeError(`The ${r.name} type is property-only and cannot be serialized.`);return r.kind==="list"||r.kind==="record"||r.kind==="object"||r.kind==="union"&&typeof n.value=="object"&&n.value!==null?JSON.stringify(n.value):n.value===null?"null":n.value===void 0?"":String(n.value)}function B(t){let e=le(t);return e.kind==="terminal"?!["function","unknown","trusted-html","trusted-script"].includes(e.name):e.kind==="keyword"?!0:e.kind==="union"?e.members.every(B):e.kind==="list"?B(e.item):e.kind==="record"?B(e.value):e.fields.every(n=>B(n.type))}function ut(t){let e;try{e=de(t)}catch(n){y("HC013",n instanceof Error?n.message:"Invalid prop type expression.")}return e.kind==="terminal"&&(e.name==="string"||e.name==="boolean"||e.name==="number")?e.name:e.kind==="keyword"?{enum:[e.value]}:e.kind==="union"&&e.members.every(n=>n.kind==="keyword")?{enum:e.members.map(n=>n.value)}:e}var E=Symbol("absent"),ee=class extends Error{constructor(n){super(`\`${n}\` is not declared in scope.`);this.identifier=n;this.name="UndeclaredName"}identifier},He=/\s*(?:(<=|>=|!=|\^=|\$=|\*=)|(\d+(?:\.\d*)?|\.\d+)|("(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*')|([A-Za-z_$][A-Za-z0-9_$]*)|([=<>+*/%(),.:{}[\]-])|$)/y,bn=/\\([\s\S])/g,wn=/%s/g,vn={or:1,and:2,"=":3,"!=":3,"^=":3,"$=":3,"*=":3,"<":4,"<=":4,">":4,">=":4,"+":5,"-":5,"*":6,"/":6,"%":6};function ft(t){return vn[t]??0}function kn(t){return t==="round"||t==="clamp"||t==="min"||t==="max"||t==="abs"||t==="format"}function Cn(t){let e=0,n=0,r="";function o(){He.lastIndex=e;let d=He.exec(t);if(d===null){let h=t.slice(e).trimStart()[0];throw h==='"'||h==="'"?new SyntaxError("Unterminated string literal."):new SyntaxError(`Unexpected character \`${h}\`.`)}e=He.lastIndex,d[1]!==void 0||d[5]!==void 0?(n=4,r=d[1]??d[5]):d[2]!==void 0?(n=1,r=Number(d[2])):d[3]!==void 0?(n=2,r=d[3].slice(1,-1).replace(bn,"$1")):d[4]!==void 0?(n=3,r=d[4]):(n=0,r="")}function i(d){return r!==d?!1:(o(),!0)}function a(d){if(!i(d))throw new SyntaxError(`Expected \`${d}\`.`)}function s(d){let h=c(),u=ft(r);for(;u>=d;){let p=r;o(),h={kind:"binary",op:p,left:h,right:s(u+1)},u=ft(r)}return h}function c(){if(n===3&&r==="not")return o(),{kind:"unary",op:"not",operand:c()};if(i("-"))return{kind:"unary",op:"-",operand:c()};let d=l();for(;n===4;)if(i(".")){if(n!==3)throw new SyntaxError("Expected a property name after `.`.");let h=r;o(),d={kind:"member",object:d,key:h}}else if(i("[")){let h=s(1);a("]"),d={kind:"index",object:d,index:h}}else break;return d}function l(){let d=n,h=r;if(d===1||d===2)return o(),{kind:"literal",value:h};if(d===4&&h==="("){o();let u=s(1);return a(")"),u}if(d===4&&h==="{"){o();let u=[];if(!i("}")){do{if(r==="}")break;if(n!==3&&n!==2)throw new SyntaxError("Object keys must be identifiers or strings.");let p=r;o(),a(":"),u.push({key:p,value:s(1)})}while(i(","));a("}")}return{kind:"object",pairs:u}}if(d===4&&h==="["){o();let u=[];if(!i("]")){do{if(r==="]")break;u.push(s(1))}while(i(","));a("]")}return{kind:"array",items:u}}if(d===3){let u=h;if(o(),u==="true")return{kind:"literal",value:!0};if(u==="false")return{kind:"literal",value:!1};if(u==="null")return{kind:"literal",value:null};if(r==="("&&kn(u)){o();let p=[];if(!i(")")){do p.push(s(1));while(i(","));a(")")}return{kind:"call",fn:u,args:p}}return{kind:"id",name:u}}throw new SyntaxError("Unexpected end of expression.")}o();let f=s(1);if(n!==0)throw new SyntaxError("Unexpected trailing input in expression.");return f}function X(t){return t===E||t===null}function L(t){if(t===E||t===null||t===!1)return!1;if(t===!0)return!0;if(typeof t=="string")return t.length>0;if(typeof t=="number")return t!==0&&t===t;if(Array.isArray(t))return t.length>0;for(let e in t)if(Object.hasOwn(t,e))return!0;return!1}function ue(t){return typeof t=="number"&&t===t?t:E}function H(t,e){switch(t.kind){case"literal":return t.value;case"id":{let n=e.get(t.name);if(n===void 0)throw new ee(t.name);return n}case"member":{let n=H(t.object,e);if(X(n)||typeof n!="object"||Array.isArray(n))return E;let r=n[t.key];return r===void 0?E:r}case"index":{let n=H(t.object,e),r=H(t.index,e);if(X(n)||X(r))return E;if(Array.isArray(n)&&typeof r=="number"){let o=n[r];return o===void 0?E:o}if(typeof n=="object"&&typeof r=="string"){let o=n[r];return o===void 0?E:o}return E}case"unary":{let n=H(t.operand,e);if(t.op==="not")return!L(n);let r=ue(n);return r===E?E:-r}case"binary":return xn(t,e);case"call":return En(t,e);case"object":{let n={};for(let r of t.pairs)n[r.key]=H(r.value,e);return n}case"array":{let n=[];for(let r of t.items)n.push(H(r,e));return n}}}function xn(t,e){let{op:n}=t;if(n==="and")return L(H(t.left,e))&&L(H(t.right,e));if(n==="or")return L(H(t.left,e))||L(H(t.right,e));let r=H(t.left,e),o=H(t.right,e);if(n==="=")return r===o;if(n==="!=")return r!==o;if(n==="^="||n==="$="||n==="*=")return typeof r!="string"||typeof o!="string"?E:n==="^="?r.startsWith(o):n==="$="?r.endsWith(o):r.includes(o);let i=ue(r),a=ue(o);if(i===E||a===E)return E;switch(n){case"<":return i<a;case"<=":return i<=a;case">":return i>a;case">=":return i>=a;case"+":return i+a;case"-":return i-a;case"*":return i*a;case"/":return i/a;case"%":return i%a;default:return E}}function En(t,e){let{args:n,fn:r}=t,o=[];for(let a of n)o.push(H(a,e));if(r==="format"){let a=o[0];if(typeof a!="string")return E;let s=1;return a.replace(wn,()=>s<o.length?P(o[s++]):"%s")}for(let a=0;a<o.length;a+=1){let s=ue(o[a]);if(s===E)return E;o[a]=s}let i=o;switch(r){case"abs":return i.length===1?Math.abs(i[0]):E;case"round":return i.length===1?Math.round(i[0]):E;case"min":return i.length>0?Math.min(...i):E;case"max":return i.length>0?Math.max(...i):E;case"clamp":return i.length===3?Math.min(Math.max(i[0],i[1]),i[2]):E;default:return E}}var pt=new Map;function De(t){if(t.kind==="id")return t.name;if(t.kind==="member"){let e=De(t.object);return e===void 0?void 0:`${e}.${t.key}`}if(t.kind==="index"&&t.index.kind==="literal"){let e=t.index.value;if(typeof e!="string"&&typeof e!="number")return;let n=De(t.object);return n===void 0?void 0:`${n}.${e}`}}function O(t,e){let n=De(t);if(n!==void 0){e.includes(n)||e.push(n);return}switch(t.kind){case"literal":return;case"id":return;case"member":O(t.object,e);return;case"index":O(t.object,e),O(t.index,e);return;case"unary":O(t.operand,e);return;case"binary":O(t.left,e),O(t.right,e);return;case"call":for(let r of t.args)O(r,e);return;case"object":for(let r of t.pairs)O(r.value,e);return;case"array":for(let r of t.items)O(r,e)}}function Me(t,e){if(t.kind==="id")return e.push(t.name),!0;if(t.kind==="member")return Me(t.object,e)?(e.push(t.key),!0):!1;if(t.kind!=="index"||!Me(t.object,e))return!1;let n=t.index,r=n.kind==="literal"?n.value:void 0;return e.push(typeof r=="string"||typeof r=="number"?r:{kind:"index",expression:n}),!0}function fe(t){let e=pt.get(t);if(e!==void 0)return e;let n=Cn(t),r=[];return O(n,r),r.sort(),e={source:t,ast:n,dependencies:r},pt.set(t,e),e}function Pe(t,e){let n=[];if(!(!Me(fe(t).ast,n)||!e.has(n[0])))return n}function mt(t,e){return H(fe(t).ast,e)}function I(t,e){return H("ast"in t?t.ast:t,e)}function P(t){return X(t)?"":Array.isArray(t)?t.map(P).join(" "):typeof t=="object"?"":String(t)}function Rn(t){return t.startsWith("aria-")||t==="contenteditable"||t==="draggable"||t==="spellcheck"}function ht(t,e=""){return typeof t=="boolean"&&Rn(e)?String(t):X(t)||t===!1?null:t===!0?"":typeof t=="number"||typeof t=="string"?String(t):Array.isArray(t)?t.map(P).join(" "):null}var Tn=new Set(["href","src","action","formaction","poster","data","xlink:href"]),Sn=new Set(["base","embed","iframe","link","meta","object","script","style","template"]),Nn=new Set(["srcdoc","style"]);function te(t){let e=t.replace(/[\u0000-\u0020\u007f]+/g,"");return/^(?:data|javascript|vbscript):/i.test(e)}function ne(t){return Tn.has(t.toLowerCase())}function je(t,e,n){let r=e.createElement("template");r.innerHTML=t;for(let o of Array.from(r.content.querySelectorAll("*"))){if(n?.(o),Sn.has(o.localName)){o.remove();continue}for(let i of Array.from(o.attributes)){let a=i.name.toLowerCase();(a.startsWith("on")||Nn.has(a)||ne(a)&&te(i.value))&&o.removeAttribute(i.name)}}return r.content}var $n=/^(?:if|else-if|else|for|with|value|state|computed|data)$/,An=/^(?:@|v-|#|on:|use:|transition:|animate:)/,Hn=/^(?:innerhtml|outerhtml|srcdoc)$/,Dn=/^(?:base|embed|link|meta|object|script|style)$/;function yt(t){return $n.test(t)}function Le(t,e){return Dn.test(t.toLowerCase())&&y("HT009",`<${t}> is not permitted in rendered component markup.`,e),t}function Oe(t,e,n=""){let r=t.toLowerCase();return(r.startsWith("on")||An.test(r))&&y("HT010",`Literal attribute \`${t}\` uses target-framework directive syntax that is not supported.`,e),r==="srcdoc"&&y("HT007","Literal `srcdoc` is not permitted in a component definition.",e),ne(r)&&te(n)&&y("HT007",`Literal \`${t}\` contains an executable URL.`,e),t}function gt(t,e){let n=t.toLowerCase();return(n.startsWith("on")||Hn.test(n))&&y("HT007",`Dynamic ${t} requires a future trusted-content type.`,e),t}function z(t){return"tagName"in t}function re(t){return t.nodeName==="#text"}function N(t){return"localName"in t?t.localName:t.tagName}function pe(t){return"attrs"in t?t.attrs:t.attributes}function V(t){return(N(t)==="template"?t.content:void 0)?.childNodes??t.childNodes}function oe(t){return"value"in t?t.value:"nodeValue"in t?t.nodeValue??"":""}function vt(t){let e=[];for(let n of t)n.nodeName!=="#comment"&&(!re(n)||oe(n).trim()!=="")&&e.push(n);return e}function C(t,e){return"attrs"in t?t.attrs.find(n=>n.name===e)?.value:t.getAttribute(e)??void 0}function kt(t){let e="";for(let n of V(t))re(n)&&(e+=oe(n));return e}function Ct(t,e){let n=[];for(let r of V(t))z(r)&&N(r)===e&&n.push(r);return n}function xt(t,e){for(let n of V(t)){if(!z(n))continue;let r=N(n);r==="link"&&y("HL001","External definition dependencies require the application-owned graph resolver.",e),Le(r,e);for(let o of pe(n))/^on(?!:)/i.test(o.name)&&Oe(o.name,e,o.value);xt(n,e)}}var Mn=/^\$(?:if|each|where|sort|limit|key|with|match|when|else)$/,bt=/^(?:innerhtml|outerhtml|textcontent|innertext|srcdoc)$/,Pn=/^\s*([A-Za-z_$][\w$]*)\s*(?:,\s*([A-Za-z_$][\w$]*)\s*)?\bof\b\s*(.+)$/,wt=/^\s*(.+?)\s+\bas\b\s+([A-Za-z_$][\w$]*)\s*$/,Ie=/^[a-z][a-z0-9-]*$/,jn=/^(?:prevent|stop|self|once|passive|capture|left|middle|right|ctrl|shift|alt|meta|exact|enter|escape|space|tab|up|down)$/,qe=/^[A-Za-z_$][A-Za-z0-9_$-]*$/;function ze(t,...e){let n=new Set(t.roots);for(let r of e)r!==void 0&&n.add(r);return{roots:n,writableRoots:t.writableRoots,handlers:t.handlers}}function S(t,e,n){let r=Vn(t,n);return Ln(r,e,n),r}function Ln(t,e,n){for(let r of t.dependencies){let o=r.split(".",1)[0];e.roots.has(o)||y("HT003",`Expression root \`${o}\` is not declared in this scope.`,n)}}function On(t,e,n){let r=Object.create(null),o=(a,s)=>{r[a]??=s},i=a=>{for(let s of pe(a))if(s.name.startsWith(":"))/^[A-Za-z][A-Za-z0-9_-]*$/.test(s.value)&&o(s.value,{attribute:s.name.slice(1).toLowerCase()});else if(s.name.startsWith(".")){let c=s.name.slice(1).toLowerCase();if(/^[A-Za-z][A-Za-z0-9_-]*$/.test(s.value)){let l=n.resolveDomProperty(N(a),c)??(s.value.toLowerCase()===c?s.value:c);o(s.value,{property:l})}}for(let s of V(a))z(s)&&N(s)!=="slot"&&i(s)};return i(t),r}function In(t,e,n,r=!0){let o=Object.create(null),i=Object.create(null);if(t===void 0)return o;let a=Ct(t,"prop");a.sort((s,c)=>{let l=C(s,"name")??"",f=C(c,"name")??"";return l<f?-1:l>f?1:0});for(let s of a){let c=C(s,"name");(c===void 0||c==="")&&y("HC010","A <prop> requires a `name` attribute.",n),/^[A-Za-z][A-Za-z0-9_-]*$/.test(c)||y("HC010",`Invalid prop name \`${c}\`.`,n);let l=C(s,"type");(l===void 0||l==="")&&y("HC013",`Prop \`${c}\` requires a \`type\` attribute.`,n);let f=c.toLowerCase(),d=i[f];d!==void 0&&y("HC011",`Props \`${d}\` and \`${c}\` collide after lowercase normalization.`,n),i[f]=c;let h=e[c];h===void 0&&r&&y("HC018",`Prop \`${c}\` is declared but never bound in the markup.`,n),h??={attribute:c.toLowerCase()};let u=ut(l),p=C(s,"required")!==void 0,m=kt(s).trim();m===""&&y("HC003",`\`props.${c}.description\` must be a non-empty string.`,n),B(u)||y("HC017",`Prop \`${c}\` cannot be written as an HTML attribute; function, unknown, and trusted content types have no text form.`,n);let w=C(s,"default");p&&w!==void 0&&y("HC019",`Required prop \`${c}\` cannot also declare a default.`,n);let k={type:u,required:p,target:h,description:m};if(w!==void 0){let x=_(w,u);x.ok||y("HC015",`Default for prop \`${c}\` does not satisfy its type.`,n),k.default=x.value}o[c]=k}return o}function zn(t,e,n,r,o,i,a){let s=C(t,"component")??"";s.trim()===""&&y("HC003","`component` must be a non-empty string.",i),/^[a-z][a-z0-9]*(?:-[a-z0-9]+)+$/.test(s)||y("HC005","The `component` tag must be lowercase and contain a hyphen.",i);let c=C(t,"status");c!==void 0&&!/^(?:early|experimental|stable|deprecated)$/.test(c)&&y("HC007","Component `status` is not recognized.",i);let l=C(t,"summary");return l!==void 0&&l.trim()===""&&y("HC003","`summary` must be a non-empty string.",i),(!/^[a-z][a-z0-9-]*$/.test(n)||r&&!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)+$/.test(n))&&y("HC008","`nativeElement` must be a lowercase HTML element or component tag.",i),{version:1,name:dt(s),tag:s,...c===void 0?{}:{status:c},...l===void 0?{}:{summary:l},nativeElement:n,props:In(e,o,i,a)}}function Vn(t,e){try{return fe(t)}catch{y("HT013",`Malformed expression \`${t}\`.`,e)}}function qn(t,e,n){let r=[];for(let o of vt(V(t))){z(o)||y("HC023","Handler bodies contain declarative step elements only.",n);let i=C(o,"$if"),a=i===void 0?void 0:S(i,e,n);if(N(o)==="set"){let s=C(o,"name")??"",c=C(o,":value"),l=C(o,"value");(s===""||c===void 0==(l===void 0))&&y("HC023","A <set> requires `name` and exactly one of `value` or `:value`.",n),S(s,e,n);let f=Pe(s,e.writableRoots);f===void 0&&y("HT005",`Handler write \`${s}\` is not rooted in declared state.`,n);let d={kind:"set",path:s,writablePath:f,value:S(c??JSON.stringify(l),e,n)};a!==void 0&&(d.guard=a),r.push(d);continue}if(N(o)==="dispatch"){let s=C(o,"event")??"";Ie.test(s)||y("HC023","A <dispatch> requires a valid `event` name.",n);let c=C(o,":value"),l=C(o,"value");c!==void 0&&l!==void 0&&y("HC023","A <dispatch> may declare only one of `value` or `:value`.",n);let f=c===void 0&&l===void 0?void 0:S(c??JSON.stringify(l),e,n),d={kind:"dispatch",event:s};f!==void 0&&(d.value=f),a!==void 0&&(d.guard=a),r.push(d);continue}if(N(o)==="validate"||N(o)==="focus"){let s=C(o,"target")??C(o,"ref")??C(o,"name")??"";qe.test(s)||y("HC023",`<${N(o)}> requires a valid target reference.`,n);let c={kind:N(o),target:s};a!==void 0&&(c.guard=a),r.push(c);continue}y("HC023",`<${N(o)}> is not a recognized handler step.`,n)}return r}function Un(t,e,n){let r=[],o=new Set(Object.keys(e.props)),i=new Set,a=new Set;if(t===void 0)return{declarations:r,scope:{roots:o,writableRoots:i,handlers:a}};let s=[],c=new Set,l=new Set;for(let d of V(t)){if(!z(d))continue;let h=d;s.push(h);let u=N(h);/^(?:prop|state|computed|data|handler|event|method)$/.test(u)||y("HC021",`<${u}> is not a recognized definition declaration.`,n);let p=C(h,"name")??"";if(p===""&&y("HC010",`A <${u}> requires a \`name\` attribute.`,n),u==="event"){l.has(p)&&y("HC020",`Event \`${p}\` is declared more than once.`,n),l.add(p);continue}c.has(p)&&y("HC020",`Declaration \`${p}\` collides in the flat component scope.`,n),c.add(p),o.add(p),u==="state"?i.add(p):u==="handler"&&a.add(p)}let f={roots:o,writableRoots:i,handlers:a};for(let d of s){let h=N(d);if(h==="prop")continue;let u=C(d,"name");if(h==="state"){let p=C(d,":value"),m=C(d,"value");p!==void 0&&m!==void 0&&y("HC013",`<state name="${u}"> may declare only one of \`value\` or \`:value\`.`,n);let w=p===void 0&&m===void 0?void 0:S(p??JSON.stringify(m),f,n),k={kind:h,name:u};m!==void 0&&(k.value=m),w!==void 0&&(k.expression=w),r.push(k);continue}if(h==="computed"){let p=C(d,"from");(p===void 0||p==="")&&y("HC013",`<computed name="${u}"> requires a \`from\` expression.`,n),r.push({kind:h,name:u,expression:S(p,f,n)});continue}if(h==="data"){let p=C(d,"src"),m=C(d,"type"),w=C(d,"debounce"),k=C(d,"poll"),x=[],g=new Set;for(let v of Ct(d,"param")){let R=C(v,"name")??"",T=C(v,":value");(!qe.test(R)||T===void 0)&&y("HC024","A data <param> requires a valid `name` and a `:value` expression.",n),g.has(R)&&y("HC024",`Data source \`${u}\` repeats a parameter name.`,n),g.add(R),x.push({name:R,expression:S(T,f,n)})}let b={kind:h,name:u,parameters:x};p!==void 0&&(b.source=p),m!==void 0&&(b.type=m),w!==void 0&&(b.debounce=w),k!==void 0&&(b.poll=k),r.push(b);continue}if(h==="event"){r.push({kind:h,name:u,type:C(d,"type")??"object",bubbles:C(d,"bubbles")!=="false",composed:C(d,"composed")!=="false",cancelable:C(d,"cancelable")==="true"});continue}if(h==="method"){r.push({kind:h,name:u,exportName:C(d,"export")??u,returns:C(d,"returns")??"undefined"});continue}r.push({kind:"handler",name:u,steps:qn(d,f,n)})}for(let d of r)if(d.kind==="handler")for(let h of d.steps)h.kind==="dispatch"&&!l.has(h.event)&&y("HC023",`Handler \`${d.name}\` dispatches undeclared component event \`${h.event}\`.`,n);return{declarations:r,scope:f}}function Bn(t,e,n,r,o,i){let a=[];for(let s of t){if(s.name.startsWith("bind:")){let c=s.name.slice(5).toLowerCase();(c===""||bt.test(c))&&y("HT007",`Two-way binding cannot target \`${c||s.name}\`.`,o);let l=S(s.value,r,o),f=Pe(s.value,r.writableRoots);f===void 0&&y("HT005",`\`${s.value}\` is not a writable state-rooted path.`,o),a.push({kind:"attribute",name:c,expression:s.value,expressionPlan:l,twoWay:!0,writablePath:f});continue}if(s.name.startsWith("class:")||s.name.startsWith("style:")){let c=s.name.startsWith("class:")?"class":"style",l=s.name.slice(c.length+1);(c==="class"?l!==""&&!/\s/.test(l):/^(?:--[a-z0-9_-]+|[a-z][a-z0-9-]*)$/.test(l))||y("HT020",`\`${s.name}\` does not name a valid ${c} binding target.`,o),a.push({kind:"attribute",name:l,expression:s.value,expressionPlan:S(s.value,r,o),target:c});continue}if(s.name.startsWith("$")){let c=s.name.slice(1).toLowerCase();c!=="value"&&c!=="html"&&y("HT012",`\`$${c}\` is not a known content directive.`,o),a.push({kind:"directive",name:c,expression:s.value,expressionPlan:S(s.value,r,o)});continue}if(s.name.startsWith(":")){let c=s.name.slice(1).toLowerCase();bt.test(c)&&y("HT007",`\`:${c}\` cannot bind a raw content sink.`,o);let l=S(s.value,r,o);a.push({kind:"attribute",name:c,expression:s.value,expressionPlan:l});continue}if(s.name.startsWith(".")){let c=s.name.slice(1).toLowerCase(),l=S(s.value,r,o),f=i.resolveDomProperty(e,c);f===void 0&&y("HP001",`\`${c}\` is not a native property of <${e}>.`,o),gt(f,o),a.push({kind:"property",key:c,name:f,expression:s.value,expressionPlan:l});continue}Oe(s.name,o,s.value),a.push({kind:"literal",name:s.name,value:s.value})}return a}function _n(t,e,n){if(t===void 0)return;let r=[];for(let o of t){let[i="",...a]=o.name.slice(3).split(".");(!Ie.test(i)||a.some(s=>!Ie.test(s)))&&y("HT010",`\`${o.name}\` is not a valid declarative event binding.`,n);for(let s=0;s<a.length;s+=1){let c=a[s];a.indexOf(c)!==s&&y("HT010",`\`${o.name}\` repeats an event modifier.`,n),jn.test(c)||y("HT010",`\`${o.name}\` contains an unsupported event modifier.`,n)}a.includes("passive")&&a.includes("prevent")&&y("HT010",`\`${o.name}\` cannot combine passive and prevent.`,n),e.handlers.has(o.value)||y("HT010",`Event binding \`${o.name}\` names undeclared handler \`${o.value}\`.`,n),r.push({name:i,handler:o.value,modifiers:a})}return r}function Wn(t,e,n){if(t!==void 0)return qe.test(t)||y("HT019","`$ref` requires a valid non-empty name.",n),e.has(t)&&y("HT019",`Reference \`${t}\` is duplicated.`,n),e.add(t),t}function Fn(t,e,n){if(t===void 0)return;let r=[],o=[];t.$if!==void 0&&r.push("$if"),t.$each!==void 0&&r.push("$each"),t.$with!==void 0&&r.push("$with"),t.$match!==void 0&&r.push("$match"),t.$when!==void 0&&r.push("$when"),t.$else!==void 0&&r.push("$else"),t.$where!==void 0&&o.push("$where"),t.$sort!==void 0&&o.push("$sort"),t.$limit!==void 0&&o.push("$limit"),t.$key!==void 0&&o.push("$key"),r.length>1&&y("HT014",`An element carries one structural directive; found ${r.join(", ")}.`,n);let i=t.$each;i===void 0&&o.length>0&&y("HT014",`${o.join(", ")} may only modify \`$each\`.`,n);let a=t.$if;if(a!==void 0){let f=a;return{kind:"if",test:f,testPlan:S(f,e,n)}}let s=t.$with;if(s!==void 0){let f=wt.exec(s);return f===null&&y("HT015","`$with` must be written `expr as name`.",n),{kind:"with",expr:f[1],expressionPlan:S(f[1],e,n),alias:f[2]}}if(i!==void 0){let f=Pn.exec(i);f===null&&y("HT016","`$each` must be written `item of items` (optionally `item, i of items`).",n);let d=f[1],h=f[2];(e.roots.has(d)||h!==void 0&&e.roots.has(h))&&y("HC020","Loop locals may not collide with an existing scope name.",n);let u=ze(e,d,h,"loop"),p={kind:"each",item:d,list:f[3],listPlan:S(f[3],e,n)};h!==void 0&&(p.index=h);let m=t.$where;m!==void 0&&(p.where=m,p.wherePlan=S(m,u,n)),t.$sort!==void 0&&(p.sort=t.$sort);let w=t.$limit;w!==void 0&&(p.limit=w,p.limitPlan=S(w,u,n));let k=t.$key;return k!==void 0&&(p.key=k,p.keyPlan=S(k,u,n)),p}let c=t.$match;if(c!==void 0){let f=c.trim();if(f==="")return{kind:"match"};let d=wt.exec(f);return d===null&&y("HT017","`$match` scope must be written `expr as name`.",n),{kind:"match",expr:d[1],expressionPlan:S(d[1],e,n),alias:d[2]}}let l=t.$when;if(l!==void 0){let f=l;return{kind:"when",test:f,testPlan:S(f,e,n)}}if(t.$else!==void 0)return{kind:"else"}}function Ve(t,e,n,r,o,i){let a=N(t);yt(a)&&y("HT009",`<${a}> is reserved but not supported by this profile.`,r),Le(a,r);let s,c=[],l,f;for(let g of pe(t))Mn.test(g.name)?(s??={})[g.name]=g.value:g.name==="$ref"?f=g.value:g.name.startsWith("on:")?(l??=[]).push(g):g.name!=="as"&&c.push(g);let d=Fn(s,n,r),h=d?.kind==="each"?ze(n,d.item,d.index,"loop"):d?.kind==="with"||d?.kind==="match"&&d.alias!==void 0?ze(n,d.alias):n,u=Bn(c,a,e,h,r,i),p=_n(l,h,r),m=Wn(f,o.refs,r),w=[],k=V(t);for(let g of k)if(g.nodeName!=="#comment"){if(re(g)){let b=oe(g);b.trim()!==""&&w.push({kind:"text",value:b});continue}if(z(g)){if(N(g)==="slot"){let b=C(g,"name"),v=C(g,":name");b!==void 0&&v!==void 0&&y("HT008","A slot cannot declare both `name` and `:name`.",r);for(let M of pe(g))M.name!=="name"&&M.name!==":name"&&y("HT008","A slot has an unsupported attribute.",r);b===void 0&&v===void 0&&(o.defaults+=1,o.defaults>1&&y("HT008","A component may declare one default slot.",r)),b!==void 0&&((b===""||o.names.has(b))&&y("HT008",`Slot name \`${b}\` is empty or duplicated.`,r),o.names.add(b));let R=[];for(let M of V(g))if(M.nodeName!=="#comment")if(re(M)){let ae=oe(M);ae.trim()!==""&&R.push({kind:"text",value:ae})}else z(M)&&R.push(Ve(M,e,h,r,o,i));let A={dynamic:v!==void 0,required:R.length===0};if(b!==void 0&&(A.name=b),o.contracts.push(A),b===void 0&&v===void 0&&R.length===0)w.push({kind:"slot"});else{let M={kind:"slot",fallback:R};b!==void 0&&(M.name=b),v!==void 0&&(M.nameExpression=S(v,h,r)),w.push(M)}continue}w.push(Ve(g,e,h,r,o,i))}}if(u.some(g=>g.kind==="directive")&&w.length>0&&y("HT006","A content directive cannot coexist with children.",r),u.some(g=>g.kind==="property"&&g.name==="textContent")&&w.length>0&&y("HT006","A content-replacing property binding cannot coexist with children.",r),d?.kind==="match"){let g=0;for(let v of w)v.kind==="element"&&(g+=1);let b=!1;for(let v of w)v.kind==="element"&&(g-=1,v.flow?.kind==="when"?b&&y("HT018","A `$when` arm may not follow `$else`.",r):v.flow?.kind==="else"?(b&&y("HT018","A `$match` has at most one `$else`.",r),b=!0,g!==0&&y("HT018","`$else` must be the last arm.",r)):y("HT018","Every direct child of a `$match` must be a `$when` or `$else` arm.",r))}let x={kind:"element",name:a,attributes:u,children:w};return d!==void 0&&(x.flow=d),p!==void 0&&(x.events=p),m!==void 0&&(x.ref=m),x}function Et(t,e,n){let r=vt(t);(r.length!==1||!z(r[0])||N(r[0])!=="template"||C(r[0],"component")===void 0)&&y("HS001","A source must contain exactly one top-level <template component>.",e);let o=r[0],i,a=!1,s,c;for(let b of V(o)){if(b.nodeName==="#comment"||re(b)&&oe(b).trim()==="")continue;z(b)||y("HT001","A component's markup must be exactly one element root.",e);let v=N(b);v==="props"||v==="defs"?(i!==void 0&&y("HS002","A component has one optional declaration group, one markup root, and one optional <style>.",e),i=b,a=v==="props",xt(b,e)):v==="style"?(s!==void 0&&y("HS002","A component has one optional declaration group, one markup root, and one optional <style>.",e),s=b):c===void 0?c=b:y("HT001","A component's markup must be exactly one element root.",e)}c===void 0&&y("HT001","A component's markup must be exactly one element root.",e);let l=N(c),f=(C(c,"as")??l).split("|");for(let b=f.length-1;b>=0;b-=1)f[b]=f[b].trim(),f[b]===""&&f.splice(b,1);let d=!n.isNativeElement(l);d&&C(c,"as")!==void 0&&y("HT021","A delegated component root cannot also declare native `as` choices.",e),!d&&(f.length===0||!f.includes(l)||f.some((b,v)=>f.indexOf(b)!==v)||f.some(b=>!n.isNativeElement(b)))&&y("HT021","A polymorphic root must list unique native choices including its markup root.",e);let h=On(c,e,n),u=zn(o,i,l,d,h,e,a),{declarations:p,scope:m}=Un(a?void 0:i,u,e),w={defaults:0,names:new Set,contracts:[],refs:new Set},k=Ve(c,u,m,e,w,n),x=C(o,"controller");x===""&&y("HC022","A controller specifier cannot be empty.",e);let g={source:{file:e},contract:u,template:k,css:s===void 0?"":kt(s).trim(),declarations:p,slots:w.contracts,root:d?{kind:"component",tag:l}:{kind:"native",element:l,choices:f}};return x!==void 0&&(g.controller=x),J(g)}var Rt=new WeakMap;function Gn(t){let e={},n={},r=o=>{if(o.includes("-"))return!1;if(Object.hasOwn(e,o))return e[o];let i=t.createElement(o),a=t.defaultView?.HTMLUnknownElement,s=a===void 0?i.constructor.name!=="HTMLUnknownElement":!(i instanceof a);return e[o]=s,s};return{isNativeElement:r,resolveDomProperty(o,i){if(!r(o))return;let a=`${o}:${i}`;if(a in n)return n[a]||void 0;let s=t.createElement(o),c=i.toLowerCase();for(;s!==null;){for(let l of Object.getOwnPropertyNames(s))if(l.toLowerCase()===c)return n[a]=l,l;s=Object.getPrototypeOf(s)}n[a]=""}}}function Ue(t,e=t.ownerDocument.URL){(t.localName!=="template"||!t.hasAttribute("component"))&&y("HS001","A browser component carrier must be a <template component>.",e);let n=t.ownerDocument,r=Rt.get(n);return r===void 0&&(r=Gn(n),Rt.set(n,r)),Et([t],e,r)}function Tt(t,e,n){let r=n.createElement("template");r.innerHTML=t;let o;for(let a of r.content.childNodes)a.nodeType===1&&a.localName==="template"&&a.hasAttribute("component")&&(o!==void 0&&y("HS001","A component resource must contain exactly one <template component>.",e),o=a);o===void 0&&y("HS001","A component resource must contain exactly one <template component>.",e);let i=[];for(let a of r.content.childNodes){if(a===o||a.nodeType===8||a.nodeType===3&&(a.nodeValue??"").trim()==="")continue;(a.nodeType!==1||a.localName!=="link"||a.getAttribute("rel")!=="component")&&y("HT009","A component resource may contain only dependency links and one inert carrier.",e);let s=a.getAttribute("href");(s===null||s.trim()==="")&&y("HL006","A component dependency link requires a non-empty `href`.",e),i.push(s)}return{definition:Ue(o,e),dependencies:i}}var me=class{#e=new Map;#t=new Map;define(e,n){this.#e.has(e)&&y("HR001",`More than one definition declares <${e}>.`),this.#e.set(e,Object.freeze(n));for(let r of this.#t.get(e)??[])r();this.#t.delete(e)}get(e){return this.#e.get(e)}whenDefined(e){return this.#e.has(e)?Promise.resolve():new Promise(n=>{let r=this.#t.get(e)??[];r.push(n),this.#t.set(e,r)})}addGraph(e,n){for(let r of e.nodes.values())r.shadowedByCustomElement||this.define(r.definition.contract.tag,{node:r,...r.controller===void 0||n===void 0?{}:{loadController:()=>n(r)}})}};var St=/^(?:[A-Za-z][A-Za-z\d+.-]*:|\/|\.\.?\/)/;function Nt(t){return new URL("./",t).href}function Zn(t,e){return t.endsWith("/")?e:Nt(e)}var he=class{#e;#t;constructor(e={},n="file:///"){this.#e=new URL(n).href,this.#t=new Map(Object.entries(e.imports??{}).map(([r,o])=>[r,new URL(o,this.#e).href]))}resolveRoot(e){if(St.test(e)){let n=new URL(e,this.#e).href;return Object.freeze({url:n,trustRoot:Nt(n)})}return this.#n(e)}resolveDependency(e,n,r){if(!St.test(e))return this.#n(e);let o=new URL(e,n).href;return Object.freeze({url:o,trustRoot:r})}assertFinalURL(e,n){return new URL(n,e.url).href}#n(e){let n=this.#t.get(e);if(n!==void 0)return Object.freeze({url:n,trustRoot:Zn(e,n),mapping:e});let r=Array.from(this.#t.keys()).filter(i=>i.endsWith("/")&&e.startsWith(i)).sort((i,a)=>a.length-i.length)[0];r===void 0&&y("HL002",`Bare resource specifier \`${e}\` is not mapped by the application.`);let o=this.#t.get(r);return Object.freeze({url:new URL(e.slice(r.length),o).href,trustRoot:o,mapping:r})}};var $t=new Map;function Be(t,e=n=>import(n)){let n=t.controller;if(n===void 0)return Promise.reject(new TypeError(`<${t.definition.contract.tag}> does not declare a controller.`));let r=$t.get(n.url);return r===void 0&&(r=e(n.url).then(o=>{let i=o?.default;return typeof i!="function"&&y("HJ002",`Controller module \`${n.url}\` must default-export a function.`,t.url),Object.freeze({...o,default:i})}).catch(o=>{if(o instanceof Error&&"diagnostic"in o)throw o;y("HJ001",`Controller module \`${n.url}\` failed to load: ${o instanceof Error?o.message:String(o)}.`,t.url)}),$t.set(n.url,r)),r}async function At(t,e=n=>import(n)){return(await Be(t,e)).default}function Kn(t,e,n){let r=new Set,o=t.replace(/\{([A-Za-z_$][A-Za-z0-9_$-]*)\}/g,(a,s)=>{r.add(s);let c=n[s];return c==null?"":encodeURIComponent(String(c))}),i=new URL(o,e);for(let[a,s]of Object.entries(n))if(!(r.has(a)||s==null))if(Array.isArray(s))for(let c of s)i.searchParams.append(a,String(c));else i.searchParams.set(a,String(s));return i.href}var ye=class{constructor(e){this.options=e;this.#e=e.fetch??globalThis.fetch.bind(globalThis),this.#t=e.setTimer??((n,r)=>setTimeout(n,r)),this.#n=e.clearTimer??(n=>clearTimeout(n))}options;#e;#t;#n;#o={};#i;#r;#c=0;#s=!1;update(e){this.#o={...e},this.#s=!0,this.#a();let n=++this.#c,r=()=>{this.#l(n)};(this.options.debounce??0)>0?this.#r=this.#t(r,this.options.debounce):r()}disconnect(){this.#s&&(this.#s=!1,this.#c+=1,this.#a())}#a(){this.#i?.abort(),this.#i=void 0,this.#r!==void 0&&this.#n(this.#r),this.#r=void 0}#d(e){return!this.#s||e!==this.#c}async#l(e){if(this.#d(e))return;let n=new AbortController;this.#i=n;let r=this.options;r.onState({pending:!0,value:null,error:null,ok:!1});try{let o=await this.#e(Kn(r.source,r.baseURL,this.#o),{signal:n.signal});if(!o.ok)throw new TypeError(`Request failed with ${o.status}.`);let i=r.type==="text"?await o.text():await o.json(),a=r.adapt===void 0?i:r.adapt(i);if(this.#d(e))return;r.onState({pending:!1,value:a,error:null,ok:!0})}catch(o){if(n.signal.aborted||this.#d(e))return;r.onState({pending:!1,value:null,error:o,ok:!1})}finally{this.#i===n&&(this.#i=void 0),!this.#d(e)&&(r.poll??0)>0&&(this.#r=this.#t(()=>{this.#l(e)},r.poll))}}};var $,Jn=0,Ht=100,_e=new WeakMap,ge=new WeakMap;function Dt(t){let{dependency:e,previousSubscriber:n,nextSubscriber:r}=t;n===void 0?e.first=r:n.nextSubscriber=r,r===void 0?e.last=n:r.previousSubscriber=n}function Mt(t){if(t.length>8)return[];for(;t.length>0;)t.pop();return t}var We=class{#e=[];#t=[];#n=!1;#o=!1;enqueue(e){e.stopped||e.queued||(e.queued=!0,this.#e.push(e),!this.#n&&!this.#o&&(this.#n=!0,queueMicrotask(()=>{this.#n=!1,this.flush()})))}enqueueDependency(e){if(this.#o||this.#e.length>0)return!1;for(let n=e.first;n!==void 0;n=n.nextSubscriber){let r=n.effect;if(r.scheduler!==this){for(let o of this.#e)o.queued=!1;return this.#e=[],!1}r.queued||(r.queued=!0,this.#e.push(r))}return this.#n||(this.#n=!0,queueMicrotask(()=>{this.#n=!1,this.flush()})),!0}flush(){this.#o||this.#e.length===0||this.#i()}#i(){this.#o=!0;let e=0,n,r=0;try{for(;this.#e.length>0;){if(e+=1,e>Ht){for(let o of this.#e)o.queued=!1;this.#e=[],y("HR006","A reactive flush exceeded the propagation-depth limit.")}if(n=this.#e,n.length>1){let o=1,i=n[0];for(;o<n.length;){let a=n[o];if(i.priority>a.priority||i.priority===a.priority&&i.id>a.id)break;i=a,o+=1}o<n.length&&n.sort((a,s)=>a.priority-s.priority||a.id-s.id)}this.#e=this.#t,r=0;do{let o=n[r];if(o.queued=!1,r+=1,o.computed===void 0?o.execute():o.computed.refresh(),this.#e.length===1&&r===n.length&&this.#e[0].computed===void 0){e+=1,e>Ht&&(this.#e[0].queued=!1,this.#e=[],y("HR006","A reactive flush exceeded the propagation-depth limit."));let i=this.#e;this.#e=Mt(n),n=i,r=0}else this.#e.length>0&&this.#r(n,r)}while(r<n.length);this.#t=Mt(n),n=void 0}}finally{if(n!==void 0){for(;r<n.length;)n[r++].queued=!1;this.#t=[]}if(this.#e.length>0){for(let o of this.#e)o.queued=!1;this.#e=[]}this.#o=!1}}#r(e,n){if(this.#e.some(r=>r.computed!==void 0))for(let r=e.length-1;r>=n;r-=1){let o=e[r];o.computed===void 0&&(e.splice(r,1),this.#e.push(o))}}},be=class{constructor(e,n,r,o){this.scheduler=e;this.run=n;this.priority=r;this.computed=o}scheduler;run;priority;computed;id=Jn++;dependencies=void 0;stopped=!1;paused=!1;queued=!1;#e=void 0;#t=void 0;execute(){if(this.stopped||this.paused)return;if(this.#t=void 0,this.#e!==void 0){let n=this.#e;this.#e=void 0,n()}let e=$;$=this;try{let n=this.run();n!==void 0&&(this.#e=n)}finally{$=e;let n=this.#t,r=n===void 0?this.dependencies:n.nextDependency;for(n===void 0?this.dependencies=void 0:n.nextDependency=void 0;r!==void 0;){let o=r.nextDependency;Dt(r),r=o}}}track(e){let n=this.#t===void 0?this.dependencies:this.#t.nextDependency;if(n?.dependency===e){this.#t=n;return}for(let i=this.dependencies;i!==n;i=i?.nextDependency)if(i?.dependency===e)return;let r={dependency:e,effect:this,nextDependency:n,previousSubscriber:void 0,nextSubscriber:void 0};this.#t===void 0?this.dependencies=r:this.#t.nextDependency=r,this.#t=r;let o=e.first;if(this.computed!==void 0&&o!==void 0)r.nextSubscriber=o,o.previousSubscriber=r,e.first=r;else{let i=e.last;r.previousSubscriber=i,i===void 0?e.first=r:i.nextSubscriber=r,e.last=r}}schedule(){if(this.computed!==void 0){this.computed.invalidate();return}this.paused||this.scheduler.enqueue(this)}pause(){this.stopped||this.paused||(this.paused=!0,this.#n(),this.#e?.(),this.#e=void 0)}resume(){this.stopped||!this.paused||(this.paused=!1,this.execute())}stop(){this.stopped||(this.stopped=!0,this.#n(),this.#e?.(),this.#e=void 0)}#n(){let e=this.dependencies;for(;e!==void 0;){let n=e.nextDependency;Dt(e),e=n}this.dependencies=void 0,this.#t=void 0}},Fe=class{#e={first:void 0,last:void 0};#t;constructor(e){this.#t=e}get(){return $!==void 0&&$.track(this.#e),this.#t}set(e){Object.is(this.#t,e)||(this.#t=e,W(this.#e))}update(e){this.set(e(this.#t))}},we=class{#e;#t;#n;#o;#i=!1;#r=!0;#c=!1;#s=!1;constructor(e,n,r={first:void 0,last:void 0}){this.#e=r,this.#t=n,this.#n=new be(e,()=>this.#l(),0,this)}get(){return this.#n.paused||this.#n.stopped?this.#d():(this.#a(),$!==void 0&&$.track(this.#e),this.#o)}invalidate(){if(!(this.#n.stopped||this.#r)){this.#r=!0;for(let e=this.#e.first;e!==void 0;e=e.nextSubscriber)if(e.effect.computed===void 0){this.#n.scheduler.enqueue(this.#n);return}W(this.#e)}}refresh(){this.#a()}pause(){this.#n.stopped||this.#n.paused||(this.#r=!0,this.#n.pause())}resume(){this.#n.stopped||!this.#n.paused||(this.#n.paused=!1)}stop(){this.#n.stop()}#a(){if(this.#c&&y("HR006","A reactive computed value depends on itself."),!this.#r||this.#n.stopped||this.#n.paused)return;let e=this.#i;this.#n.execute(),e&&this.#s&&W(this.#e,$?.computed===void 0?void 0:$)}#d(){this.#c&&y("HR006","A reactive computed value depends on itself.");let e=$;this.#c=!0,$=void 0;try{return this.#t()}finally{$=e,this.#c=!1}}#l(){this.#c=!0,this.#r=!1;try{let e=this.#t();this.#s=!this.#i||!Object.is(this.#o,e),this.#o=e,this.#i=!0}catch(e){throw this.#r=!0,e}finally{this.#c=!1}}};function W(t,e){let n=t?.first;if(n===void 0)return;let r=n!==t.last;if(!r&&n.effect.computed!==void 0){n.effect!==e&&n.effect.computed.invalidate();return}if(n.effect.computed===void 0){if(e===void 0&&r&&n.effect.scheduler.enqueueDependency(t))return;for(let o=n;o!==void 0;){let i=o.nextSubscriber;o.effect!==e&&o.effect.schedule(),o=i}return}for(let o=n;o!==void 0;){let i=o.nextSubscriber;o.effect!==e&&o.effect.schedule(),o=i}}function Pt(t){return new Fe(t)}function jt(t,e){return new we(t,e)}function F(t,e,n=1,r=!0){let o=new be(t,e,n);return r?o.execute():o.paused=!0,o}var ve=class t{constructor(e=[],n=new We,r){this.scheduler=n;this.parent=r;for(let[o,i]of e)this.set(o,i)}scheduler;parent;#e=new Map;#t;#n;has(e){return this.#o(e)!==void 0||this.parent?.has(e)===!0}get(e){let n=this.#o(e);return n===void 0?this.parent?.get(e):($!==void 0&&$.track(n),n.value)}set(e,n){let r=this.#r(n),o=this.#o(e);if(o===void 0){o={value:r,first:void 0,last:void 0},this.#e.set(e,o),this.#n=o;return}Object.is(o.value,r)||(o.value=r,W(o))}defineComputed(e,n){let r=this.#o(e);r===void 0&&(r={value:null,first:void 0,last:void 0},this.#e.set(e,r),this.#n=r);let o=new we(this.scheduler,()=>this.#r(n()),r);return r.computed=o,Object.hasOwn(this,"get")||(this.get=this.#i),o}fork(e=[]){return new t(e,this.scheduler,this)}#o(e){return e!==this.#t&&(this.#t=e,this.#n=this.#e.get(e)),this.#n}#i(e){let n=this.#o(e);return n===void 0?this.parent?.get(e):n.computed!==void 0?n.computed.get():($!==void 0&&$.track(n),n.value)}#r(e){if(e===null||typeof e!="object")return e;let n=_e.get(e);if(n!==void 0)return n;let r=new Proxy(e,{get:(o,i,a)=>{if($!==void 0){let s=ge.get(o);s===void 0&&(s=new Map,ge.set(o,s));let c=s.get(i);c===void 0&&(c={first:void 0,last:void 0},s.set(i,c)),$.track(c)}return this.#r(Reflect.get(o,i,a))},set:(o,i,a,s)=>{let c=Reflect.get(o,i,s),l=this.#r(a),f=Reflect.set(o,i,l,s);return Object.is(c,l)||W(ge.get(o)?.get(i)),f},deleteProperty:(o,i)=>{let a=Reflect.has(o,i),s=Reflect.deleteProperty(o,i);return a&&W(ge.get(o)?.get(i)),s}});return _e.set(e,r),_e.set(r,r),r}};var Qn=/\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|--[\w-]+\s*:[^;{}]*|:(user-invalid|invalid|valid)(?![\w-])/g;function Lt(t){return t.replace(Qn,(e,n)=>n===void 0?e:`:is(:${n}, [data-${n}])`)}var G="data-component",ke="data-slotted";function It(t,e,n){let r=new Set((t.getAttribute(e)??"").split(/\s+/).filter(Boolean));r.add(n),t.setAttribute(e,Array.from(r).join(" "))}function Ce(t){t.nodeType===1&&t.setAttribute(ke,"")}function Ge(t){return`data-${t}-state`}var Ot={slotted:"[--slotted]",state:"[--state]"},Yn=/\/\*[\s\S]*?\*\/|"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|:(slotted|host-state)\(/g;function Xn(t,e=["slotted","host-state"]){return t.replace(Yn,(n,r)=>r===void 0||!e.includes(r)?n:`:where(${r==="slotted"?Ot.slotted:Ot.state}):is(`)}function er(t){return/:where\(\s*\[--slotted\]\s*\)/.test(t)?"slotted":"own"}function tr(t,e){let n=0;for(let r=e;r<t.length;r+=1){let o=t[r];if(o==='"'||o==="'"){let i=t.indexOf(o,r+1);r=i===-1?t.length:i}else if(o==="(")n+=1;else if(o===")"&&--n===0)return r}return t.length}var nr=/\[\s*([\w-]+)\s*(?:=\s*(?:"((?:\\.|[^"\\])*)"|'((?:\\.|[^'\\])*)'|([^\]\s]+))\s*)?\]/g;function rr(t,e,n,r){let o="";for(let i of t.matchAll(nr)){let a=r(i[1]),s=i[2]??i[3]??i[4];n.add(a),o+=`[${Ge(e)}~="${s===void 0?a:`${a}=${encodeURIComponent(s)}`}"]`}return o}function or(t){let e="";for(let n=0;n<t.length;n+=1){let r=t[n];if(r==="["){let s=t.indexOf("]",n),c=s===-1?t.length:s+1;e+=t.slice(n,c),n=c-1;continue}let o=e.at(-1),a=o===void 0||/[\s>+~(,]/.test(o)?/^[a-z][a-z0-9]*(?:-[a-z0-9]+)+(?![\w-]|\()/.exec(t.slice(n))?.[0]:void 0;if(a!==void 0){e+=`:is(${a}, :where([${G}~="${a}"]))`,n+=a.length-1;continue}e+=r}return e}function ir(t,e,n,r,o=i=>i){/:scope(?![\w-])/.test(t)&&y("HY003",`\`:scope\` is not part of component styles; select the root with \`:host\` (in <${e}>).`);let i="",a=0,s=/:where\(\s*\[--state\]\s*\):is\(/g;for(let c=s.exec(t);c!==null;c=s.exec(t)){let l=c.index+c[0].length-1,f=tr(t,l);i+=`${t.slice(a,c.index)}${n}${rr(t.slice(l+1,f),e,r,o)}`,a=f+1,s.lastIndex=a}return i+=t.slice(a),i=i.replace(/:where\(\s*\[--slotted\]\s*\):is\(/g,`:where([${ke}], [${ke}] *):is(`).replace(/:host(?![\w-])/g,n),or(Lt(i))}function sr(t,e,n,r){let o=`[${G}~="${t}"]`;return[r,e.trim()===""?"":`@scope (${o}) to ([${G}], [${ke}]) {
3
+ ${e}
4
+ }`,n.trim()===""?"":`@scope (${o}) to ([${G}]) {
5
+ ${n}
6
+ }`].filter(i=>i!=="").join(`
7
+ `)}function zt(t){if(typeof t=="string")return!0;if(t===null||typeof t!="object")return!1;if("enum"in t)return!0;let e=t;return e.kind==="union"?(e.members??[]).every(zt):e.kind!=="list"&&e.kind!=="record"&&e.kind!=="object"}function ar(t,e,n){let r=new Set((t.declarations??[]).filter(o=>o.kind==="state").map(o=>o.name));for(let o of e){let i=t.contract.props[o];i===void 0&&!r.has(o)&&y("HY001",`\`:host-state()\` tests \`${o}\`, which is not a declared prop or state.`,n),i!==void 0&&!zt(i.type)&&y("HY002",`\`:host-state()\` cannot test \`${o}\`, whose type is structured.`,n)}}function Vt(t,e,n,r){let o=e.contract.tag;if(t.trim()==="")return{css:"",stateNames:[]};let i=(n.defaultView??globalThis).CSSStyleSheet,a=Xn(t),s=new Set,c=[],l=n.defaultView??globalThis,f=l.CSSStyleRule,d=l.CSSGroupingRule,h=new Map([...Object.keys(e.contract.props),...(e.declarations??[]).filter(g=>g.kind==="state").map(g=>g.name)].map(g=>[g.toLowerCase(),g])),u=g=>h.get(g.toLowerCase())??g,p=g=>{g.selectorText=ir(g.selectorText,o,":scope",s,u);for(let b of Array.from(g.cssRules??[]))b instanceof f&&p(b)},m=(g,b,v)=>{let R=g.cssRules;for(let T=0;T<R.length;){let A=R[T];A instanceof f?er(A.selectorText)===b?(p(A),T+=1):g.deleteRule(T):A instanceof d?(m(A,b,!1),T+=1):(v&&b==="own"&&c.push(A.cssText),g.deleteRule(T))}},w=g=>{let b=new i;return b.replaceSync(a),m(b,g,!0),Array.from(b.cssRules,v=>v.cssText).join(`
8
+ `)},k=w("own"),x=w("slotted");return ar(e,s,r),{css:sr(o,k,x,c.join(`
9
+ `)),stateNames:[...s]}}function qt(t,e){let n=[];for(let r of t){let o=e(r);(o===!0||typeof o=="string"&&o.length>0||typeof o=="number"&&o!==0&&!Number.isNaN(o))&&n.push(r),(typeof o=="string"||typeof o=="number")&&n.push(`${r}=${encodeURIComponent(String(o))}`)}return n.join(" ")}var xe=new WeakSet,Kt=new WeakMap,Ut=new WeakMap,cr=Symbol.for("@nextwebwg/html-next.runtime.v1");function Je(t){return t[cr]??={}}function Z(t){return Kt.get(t)}function Jt(t){let e=Je(t),n=e.registry;return(n===void 0||n.root!==t.documentElement)&&(n={root:t.documentElement,definitions:new Map,discoverySelector:void 0},e.registry=n),n}var Qt=new WeakMap;function Yt(t,e,n){let r=Vt(t,e,n);return Qt.set(e,r.stateNames),r.css}function Xt(t,e,n){t.definitions.set(e,n),t.discoverySelector!==void 0&&(t.discoverySelector+=`,${e}`)}function dr(t){return t.discoverySelector??=["template[component]","[data-component]",...Array.from(t.definitions.keys())].join(",")}function lr(t,e){let n=t.getAttribute("component")??"",r=`${t.ownerDocument.URL}#template[component="${n}"][${e+1}]`;t.hasAttribute("src")&&y("HL001","External definitions require the application-owned graph resolver.",r);let o=Ue(t,r),i=Array.from(t.content.children).find(a=>a.localName==="style");return{wrapper:t,style:i,definition:o}}function en(t,e=document){let n=Jt(e),r=0;for(let o of t.nodes.values()){if(o.shadowedByCustomElement)continue;let i=o.definition.contract.tag;n.definitions.has(i)&&y("HR001",`More than one definition declares <${i}>.`);let a=o.definition.css===""?void 0:e.createElement("style");a!==void 0&&(a.textContent=Yt(o.definition.css,o.definition,e),e.head.append(a)),Xt(n,i,{definition:o.definition,style:a}),r+=1}return r}function Qe(t,e,n=!1){let r=t.type==="boolean"&&n&&e===""?!0:e,o=_(r,t.type);if(!o.ok){let i=o.issues.map(a=>`${a.path}: ${a.message}`).join("; ");y("HR002",`A prop invocation value does not satisfy its declared type. ${i}`)}return o.value}function ur(t,e,n){return n!==void 0?Qe(e,n):(e.required&&y("HC020",`Required prop \`${t}\` was not provided.`),e.default===void 0?E:e.default)}function fr(t,e){let n=Ut.get(t);if(n===void 0){let r=Object.create(null),o=Object.create(null);for(let i of Object.keys(t.contract.props)){let a=Re(i);r[a]=i,o[`data-${a}`]=i,a!==i.toLowerCase()&&(o[`data-${i.toLowerCase()}`]=i)}n=[r,o],Ut.set(t,n)}return n[e?1:0]}function pr(t,e,n=!1){let r=e.contract,o=fr(e,n),i=Object.create(null),a=[],s;for(let p of Array.from(t.attributes)){if(p.name.toLowerCase()==="as"&&e.root?.kind==="native"){s=p.value.toLowerCase();continue}let m=o[p.name.toLowerCase()];if(m===void 0){n||a.push(p);continue}i[m]=Qe(r.props[m],p.value,!n)}let c=e.root?.kind==="native"?n?t.localName:s??e.root.element:e.template.name;e.root?.kind==="native"&&!e.root.choices.includes(c)&&y(n?"HR005":"HR002",`<${r.tag}> cannot use root <${c}>; expected one of ${e.root.choices.join(", ")}.`);let l=new Set(Object.keys(i).filter(p=>i[p]!==void 0)),f=new ve;for(let[p,m]of Object.entries(r.props))m.required&&i[p]===void 0&&y("HC020",`Required prop \`${p}\` was not provided.`),f.set(p,i[p]!==void 0?i[p]:m.default===void 0?E:m.default);let d=e.declarations??[];for(let p of d)(p.kind==="state"||p.kind==="computed"||p.kind==="data")&&f.set(p.name,null);for(let p of d)p.kind==="data"?f.set(p.name,{pending:!0,value:null,error:null,ok:!1}):p.kind==="state"&&f.set(p.name,p.expression===void 0?null:D(p.expression.source,f));let h=[];for(let p of d)p.kind!=="computed"||p.expression===void 0||h.push(f.defineComputed(p.name,()=>I(p.expression,f)));let u=(()=>{try{return new URL(e.source.file,t.ownerDocument.baseURI).href}catch{return t.ownerDocument.baseURI}})();for(let p of d){if(p.kind!=="data"||p.source===void 0)continue;let m=p,w=p.source,k=new ye({source:w,baseURL:u,...m.type===void 0?{}:{type:m.type},...m.debounce===void 0?{}:{debounce:Number(m.debounce)},...m.poll===void 0?{}:{poll:Number(m.poll)},onState:x=>f.set(m.name,x)});h.push(F(f.scheduler,()=>{let x=Object.fromEntries(m.parameters.map(g=>[g.name,I(g.expression,f)]));return k.update(x),()=>k.disconnect()},0))}return{scope:f,passThrough:a,effects:h,rootName:c,explicit:l}}function Ke(t,e){return t.fork(Object.entries(e))}function D(t,e){try{return mt(t,e)}catch(n){throw n instanceof ee&&y("HB001",n.message),n}}var ie="http://www.w3.org/2000/svg",Bt=new Map;function mr(t,e){if(t.namespaceURI!==ie)return e;let n=Bt.get(e);if(n===void 0){let r=t.ownerDocument.createElement("template");r.innerHTML=`<svg ${e}>`,n=r.content.firstChild.attributes[0]?.name??e,Bt.set(e,n)}return n}function tn(t,e,n){return e==="svg"||n.namespace===ie?t.createElementNS(ie,e):t.createElement(e)}function hr(t,e){let n=t.namespaceURI===ie&&t.localName!=="foreignObject"?ie:void 0;return n===e.namespace?e:Object.create(e,{namespace:{value:n,enumerable:!0}})}function q(t,e,n,r=1){t.effects.push(F(e.scheduler,n,r))}function nn(t,e,n){let[r,...o]=e;if(typeof r!="string")return;if(o.length===0){t.set(r,n);return}let i=t.get(r);for(let c=0;c<o.length-1;c+=1){let l=o[c],f=typeof l=="object"?I(l.expression,t):l;if(typeof f!="string"&&typeof f!="number"||i==null)return;i=i[f]}let a=o.at(-1),s=typeof a=="object"?I(a.expression,t):a;(typeof s=="string"||typeof s=="number")&&i!=null&&(i[s]=n)}function yr(t){return t instanceof HTMLInputElement?t.type==="checkbox"||t.type==="radio"?t.checked:t.type==="number"||t.type==="range"?Number.isNaN(t.valueAsNumber)?null:t.valueAsNumber:t.value:t instanceof HTMLSelectElement?t.multiple?Array.from(t.selectedOptions,e=>e.value):t.value:t instanceof HTMLTextAreaElement?t.value:t.value??t.getAttribute("value")}function gr(t,e,n){let r=e.toLowerCase();if(r==="checked"&&t instanceof HTMLInputElement)return t.checked=L(n),!0;if(r==="value"&&t instanceof HTMLSelectElement&&t.multiple){let o=new Set(Array.isArray(n)?n.map(String):[]);for(let i of Array.from(t.options))i.selected=o.has(i.value);return!0}return r==="value"&&(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)?(t.value=n==null?"":String(n),!0):!1}function br(t,e,n,r){for(let o of t.steps)if(!(o.guard!==void 0&&!L(I(o.guard,n))))if(o.kind==="set")nn(n,o.writablePath,I(o.value,n));else if(o.kind==="dispatch"){let i=rn(r.definition,o.event),a=o.value===void 0?void 0:I(o.value,n);i!==void 0&&a!==void 0&&(_(a,de(i.type)).ok||y("HR002",`Event \`${o.event}\` detail does not satisfy its declared type.`)),on(r.root??e,o.event,a,i)}else{let i=r.refs[o.target];o.kind==="focus"?i?.focus():i?.reportValidity?.()}}function rn(t,e){return(t.declarations??[]).find(n=>n.kind==="event"&&n.name===e)}function on(t,e,n,r){return t.dispatchEvent(new CustomEvent(e,{detail:n,bubbles:r?.bubbles??!0,composed:r?.composed??!0,cancelable:r?.cancelable??!1}))}function wr(t,e,n){if(n.includes("self")&&t.target!==e)return!1;if(t instanceof MouseEvent){let o=n.filter(a=>["left","middle","right"].includes(a)),i={left:0,middle:1,right:2};if(o.length>0&&!o.some(a=>t.button===i[a]))return!1}let r=["ctrl","shift","alt","meta"];for(let o of r)if(n.includes(o)&&!t[`${o}Key`])return!1;if(n.includes("exact")&&r.some(o=>!n.includes(o)&&t[`${o}Key`]))return!1;if(t instanceof KeyboardEvent){let o=n.filter(a=>["enter","escape","space","tab","up","down","left","right"].includes(a)),i={enter:"Enter",escape:"Escape",space:" ",tab:"Tab",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight"};if(o.length>0&&!o.some(a=>t.key===i[a]))return!1}return!0}function _t(t,e,n,r){for(let o of e.events??[]){let i=(r.definition.declarations??[]).find(s=>s.kind==="handler"&&s.name===o.handler),a=s=>{wr(s,t,o.modifiers)&&(o.modifiers.includes("prevent")&&s.preventDefault(),o.modifiers.includes("stop")&&s.stopPropagation(),br(i,t,n,r))};if(o.name==="connect"||o.name==="disconnect"){(o.name==="connect"?r.connectCallbacks:r.disconnectCallbacks).add(()=>a(new Event(o.name)));continue}q(r,n,()=>(t.addEventListener(o.name,a,{capture:o.modifiers.includes("capture"),passive:o.modifiers.includes("passive"),once:o.modifiers.includes("once")}),()=>t.removeEventListener(o.name,a,{capture:o.modifiers.includes("capture")})),2)}}function vr(t,e,n){e=mr(t,e),n===null||ne(e)&&te(n)?t.removeAttribute(e):t.setAttribute(e,n)}function kr(t,e,n,r){let o=D(e.expression,n);e.name==="value"?t.textContent=P(o):t.replaceChildren(je(P(o),r,i=>xe.add(i)))}function Cr(t,e,n){let r=D(t.expression,e);return t.name==="value"?n.createTextNode(P(r)):je(P(r),n,o=>xe.add(o))}function xr(t,e){return typeof t=="number"&&typeof e=="number"?t-e:P(t).localeCompare(P(e))}function Er(t,e,n){let r=t.slice();if(e.where!==void 0){let o=e.where;r=r.filter(i=>L(D(o,Ke(n,{[e.item]:i}))))}if(e.sort!==void 0){let o=e.sort.split(",").map(a=>a.trim()).filter(a=>a!==""),i=(a,s)=>a!==null&&typeof a=="object"&&!Array.isArray(a)?D(`${e.item}.${s}`,Ke(n,{[e.item]:a})):a;r.sort((a,s)=>{for(let c of o){let l=c.startsWith("-"),f=l?c.slice(1).trim():c,d=xr(i(a,f),i(s,f));if(d!==0)return l?-d:d}return 0})}if(e.limit!==void 0){let o=D(e.limit,n);typeof o=="number"&&(r=r.slice(0,Math.max(0,Math.trunc(o))))}return r}function sn(t,e){let n=e.createDocumentFragment();return n.append(...t),Array.from(n.childNodes)}function Rr(t,e){let n=t.nextSibling;for(;n!==null&&n!==e;){let r=n.nextSibling;n.remove(),n=r}}function Tr(t,e,n,r,o){if(t.flow?.kind==="each")return Ar(t,e,n,r,o);let i=n.createComment("html-next:start"),a=n.createComment("html-next:end"),s=n.createDocumentFragment();s.append(i,a);let c=[];return q(o,e,()=>{for(let d of c)d.stop();c=[],Rr(i,a);let l=o.effects.length,f=[];if(t.flow?.kind==="if"){if(L(D(t.flow.test,e))){let{flow:d,...h}=t;f=se(h,e,n,r,o)}}else if(t.flow?.kind==="with"){let d=e.fork([[t.flow.alias,D(t.flow.expr,e)]]),{flow:h,...u}=t;f=se(u,d,n,r,o)}else t.flow?.kind==="match"&&(f=Hr(t,e,n,o));c=o.effects.slice(l),a.before(...sn(f,n))}),[s]}function Sr(t,e){if(t.end.nextSibling===e)return;let n=[],r=t.start;for(;r!==null&&(n.push(r),r!==t.end);)r=r.nextSibling;let o=e.parentNode;if(o===null)return;let i=o.moveBefore;for(let a of n)i===void 0?o.insertBefore(a,e):i.call(o,a,e)}function Nr(t){for(let n of t.effects)n.stop();let e=t.start;for(;e!==null;){let n=e.nextSibling;if(e.parentNode?.removeChild(e),e===t.end)break;e=n}}function $r(t){let e=-1,n=!0;for(let s of t)s<0||(s<e&&(n=!1),e=s);if(n)return;let r=[],o=new Int32Array(t.length).fill(-1);for(let s=0;s<t.length;s+=1){let c=t[s];if(c<0)continue;let l=0,f=r.length;for(;l<f;){let d=l+f>>>1;t[r[d]]<c?l=d+1:f=d}l>0&&(o[s]=r[l-1]),r[l]=s}let i=new Uint8Array(t.length),a=r.at(-1)??-1;for(;a>=0;)i[a]=1,a=o[a];return i}function Ar(t,e,n,r,o){let i=t.flow,a=n.createComment("html-next:each-start"),s=n.createComment("html-next:each-end"),c=n.createDocumentFragment();c.append(a,s);let l=new Map;return q(o,e,()=>{let f=D(i.list,e),d=Array.isArray(f)?Er(f,i,e):[],h=new Map,u=i.key!==void 0,p=u?[]:void 0,m;if(u){m=new Map;let g=0;for(let b of l.keys())m.set(b,g++)}let w=u?[]:void 0,{flow:k,...x}=t;for(let g=0;g<d.length;g+=1){let b=d[g],v={[i.item]:b,loop:{index:g,first:g===0,last:g===d.length-1,count:d.length}};i.index!==void 0&&(v[i.index]=g);let R,T=g;i.key!==void 0&&(R=e.fork(Object.entries(v)),T=D(i.key,R)),h.has(T)&&y("HR004",`A keyed list produced duplicate key \`${P(T)}\`.`);let A=l.get(T);if(A===void 0){R??=e.fork(Object.entries(v));let M=o.effects.length,ae=sn(se(x,R,n,r,o),n),it=n.createComment("html-next:item-start"),st=n.createComment("html-next:item-end");s.before(it,...ae,st),A={start:it,end:st,scope:R,effects:o.effects.slice(M)}}else A.scope.set(i.item,b),i.index!==void 0&&A.scope.set(i.index,g),A.scope.set("loop",v.loop);h.set(T,A),p?.push(A),w?.push(m?.get(T)??-1)}for(let[g,b]of l)h.has(g)||Nr(b);if(p!==void 0&&w!==void 0){let g=$r(w),b=s;for(let v=p.length-1;v>=0;v-=1){let R=p[v];(w[v]<0||g!==void 0&&g[v]!==1)&&Sr(R,b),b=R.start}}l=h}),[c]}function an(t,e,n,r,o,i){return t.flow?.kind==="if"||t.flow?.kind==="each"||t.flow?.kind==="with"||t.flow?.kind==="match"?o.committed&&o.frameworkOwned&&i!==void 0?[i]:Tr(t,e,n,r,o):se(t,e,n,r,o,i)}function Hr(t,e,n,r){let o=t.flow,i=o.expr!==void 0?Ke(e,{[o.alias]:D(o.expr,e)}):e,a;for(let d of t.children)if(d.kind==="element"){if(d.flow?.kind==="when"&&L(D(d.flow.test,i))){a=d;break}if(d.flow?.kind==="else"){a=d;break}}if(a===void 0)return[];let{flow:s,...c}=a,l=se(c,i,n,[],r);if(t.name==="template")return l;let f=tn(n,t.name,r);for(let d of t.attributes)d.kind==="literal"&&f.setAttribute(d.name,d.value);return f.append(...l),[f]}function se(t,e,n,r,o,i){let a=t.attributes.find(m=>m.kind==="directive");if(t.name==="template"){if(a!==void 0){let m=n.createTextNode("");return q(o,e,()=>{let w=D(a.expression,e);a.name==="value"&&(m.data=P(w))}),a.name==="value"?[m]:[Cr(a,e,n)]}return cn(t.children,e,n,o)}let s=t===o.definition.template?o.rootName:t.name;if(o.frameworkOwned&&i instanceof Element&&i.localName!==s&&(i.getAttribute("data-component")??"").split(/\s+/).includes(t.name))return[i];if(o.hydrationRanges!==void 0&&!o.frameworkOwned&&i instanceof Element&&i.localName!==s&&(i.getAttribute("data-component")??"").split(/\s+/).includes(t.name)){let m=Ye(i,!1),w=b=>b.kind==="element"?b.attributes.find(v=>v.kind==="literal"&&v.name==="slot")?.value??"":"",k=m?.ranges.filter(b=>!b.fallback)??[],x=(b,v)=>{let R=0;for(let T of b)R+=Ee(T,e,n,o,v[R]).length};for(let b of k)x(t.children.filter(v=>w(v)===b.slot),b.content);let g=new Set(k.map(b=>b.slot));return x(t.children.filter(b=>!g.has(w(b))),m?.carried??[]),[i]}let c=i instanceof Element&&i.localName===s,l=c?i:tn(n,s,o);t===o.definition.template&&(o.root=l);let f=c?Array.from(l.childNodes):[],d=c&&(l instanceof HTMLInputElement||l instanceof HTMLTextAreaElement||l instanceof HTMLSelectElement)?{value:l.value,focused:l.ownerDocument.activeElement===l,...l instanceof HTMLInputElement?{checked:l.checked}:{},...l instanceof HTMLInputElement||l instanceof HTMLTextAreaElement?{selectionStart:l.selectionStart,selectionEnd:l.selectionEnd}:{}}:void 0;t.ref!==void 0&&(o.refs[t.ref]=l);for(let m of t.attributes)m.kind==="literal"&&l.setAttribute(m.name,m.value);for(let m of r){let w=m.name==="class"||m.name==="style"?l.getAttribute(m.name):null;l.setAttribute(m.name,w===null||w===""?m.value:`${w}${m.name==="class"?" ":"; "}${m.value}`)}for(let m of t.attributes)if(m.kind==="attribute"){if(q(o,e,()=>{let w=D(m.expression,e);m.target==="class"?l.classList.toggle(m.name,L(w)):m.target==="style"?l.style.setProperty(m.name,P(w)):m.twoWay===!0&&gr(l,m.name,w)||vr(l,m.name,ht(w,m.name))}),m.twoWay===!0&&m.writablePath!==void 0){let w=l instanceof HTMLSelectElement||l instanceof HTMLInputElement&&["checkbox","radio","file"].includes(l.type)?"change":"input",k=()=>{l instanceof HTMLInputElement&&l.type==="radio"&&!l.checked||nn(e,m.writablePath,yr(l))};q(o,e,()=>(l.addEventListener(w,k),()=>l.removeEventListener(w,k)),2)}}else m.kind==="property"&&q(o,e,()=>{l[m.name]=D(m.expression,e)});if(a!==void 0)return q(o,e,()=>kr(l,a,e,n)),_t(l,t,e,o),[l];let h=[],u=0,p=hr(l,o);for(let m of t.children){let w=u;if(o.frameworkOwned&&m.kind==="element"){let x=f.findIndex((g,b)=>b<u?!1:g instanceof Element&&(g.localName===m.name||(g.getAttribute("data-component")??"").split(/\s+/).includes(m.name)));x<0&&m.flow!==void 0&&(x=f.findIndex((g,b)=>b>=u&&g instanceof Comment)),x>=0&&(w=x)}let k=Ee(m,e,n,p,f[w]);h.push(...k),u=w+k.length}if(c&&!o.frameworkOwned){h=h.flatMap(m=>m.nodeType===11?Array.from(m.childNodes):[m]);for(let m=0;m<h.length;m+=1){let w=h[m];l.childNodes[m]!==w&&l.insertBefore(w,l.childNodes[m]??null)}for(;l.childNodes.length>h.length;)l.lastChild.remove()}else c||l.append(...h);return d!==void 0&&(l.value=d.value,l instanceof HTMLInputElement&&"checked"in d&&(l.checked=d.checked),(l instanceof HTMLInputElement||l instanceof HTMLTextAreaElement)&&"selectionStart"in d&&typeof d.selectionStart=="number"&&typeof d.selectionEnd=="number"&&(d.focused&&l.focus({preventScroll:!0}),l.setSelectionRange(d.selectionStart,d.selectionEnd))),_t(l,t,e,o),[l]}function cn(t,e,n,r){let o=[];for(let i of t)o.push(...Ee(i,e,n,r));return o}function Dr(t,e){return e.projectedSlotNames.get(t)??(t instanceof Element?t.getAttribute("slot")??"":"")}function Mr(t,e,n,r){let o=t.nameExpression===void 0?t.name??"":P(I(t.nameExpression,e)),i=r.projectedNodes.filter(d=>Dr(d,r)===o),a=r.hydrationRanges?.shift();if(a!==void 0){if(a.fallback){let d=[],h=0;for(let u of t.fallback??[]){let p=Ee(u,e,n,r,a.content[h]);d.push(...p),h+=p.length}return[a.markers[0],...d,...a.markers.slice(1)]}for(let d of a.content)Ce(d);return a.markers.length===1?[a.markers[0]]:[a.markers[0],...a.content,a.markers[1]]}let s=d=>`"${d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}"`,c=(d,h)=>Pr(n,d,h),l=(d,h)=>{if(d.length===0)return[c("marker",`slot=${s(o)}`)];let u=`slot=${s(o)}${h?' fallback=""':""}`;return[c("start",u),...d,c("end","")]};if(i.length===0)return l(cn(t.fallback??[],e,n,r),!0);if(r.committed){for(let d of i)Ce(d);return l([...i],!1)}let f=n.createComment(`html-next:slot:${o}`);return r.slotInsertions.push({anchor:f,nodes:i}),l([f],!1)}function Wt(t){let e=new Map,n=t.trim(),r={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};for(;n!=="";){let o=/^([A-Za-z_:][-A-Za-z0-9._:]*)\s*=\s*(?:"([^"<]*)"|'([^'<]*)')(?:\s+|$)/.exec(n);if(o===null||e.has(o[1]))return new Map;let i=(o[2]??o[3]).replace(/&(#x[0-9a-fA-F]+|#\d+|amp|lt|gt|quot|apos);/g,(a,s)=>s.startsWith("#x")?String.fromCodePoint(parseInt(s.slice(2),16)):s.startsWith("#")?String.fromCodePoint(Number(s.slice(1))):r[s]);e.set(o[1],i),n=n.slice(o[0].length)}return e}var Ft=new WeakMap;function dn(t){let e=Ft.get(t);if(e===void 0){let n=t.createElement("div");n.innerHTML='<?probe x="1"?>',e=n.firstChild?.nodeType===7,Ft.set(t,e)}return e}function Pr(t,e,n){return dn(t)?t.createProcessingInstruction(e,n):t.createComment(`?${e}${n===""?"":` ${n}`}?`)}function Ze(t){if(t.nodeType===7){let n=t;return{target:n.target,attributes:Wt(n.data)}}if(t.nodeType!==8||dn(t.ownerDocument))return;let e=/^\?([A-Za-z][-A-Za-z0-9]*)(?:\s+([\s\S]*?))?\s*\??$/.exec(t.data);return e===null?void 0:{target:e[1],attributes:Wt(e[2]??"")}}function Ye(t,e=!0){let n=[],r=new Set,o=(s,c)=>{for(let l=0;l<s.length;l+=1){let f=s[l],d=Ze(f);if(d?.target==="marker"&&d.attributes.has("slot")){c.push({slot:d.attributes.get("slot"),fallback:!1,markers:[f],content:[]});continue}if(d?.target==="start"){let h=1,u=[],p;for(l+=1;l<s.length;l+=1){let m=Ze(s[l]);if(m?.target==="start")h+=1;else if(m?.target==="end"&&--h===0){p=s[l];break}u.push(s[l])}if(d.attributes.has("slot")){c.push({slot:d.attributes.get("slot"),fallback:d.attributes.has("fallback"),markers:p?[f,p]:[f],content:u});for(let m of u)r.add(m)}else o(u,c);continue}if(f instanceof Element)if(f!==t&&f.hasAttribute("data-component")){let h=Ye(f,!1);for(let u of h?.ranges??[])o(u.content,c)}else o(Array.from(f.childNodes),c)}};o(Array.from(t.childNodes),n);let i=Array.from(t.children).find(s=>s instanceof HTMLTemplateElement&&!r.has(s)&&s.previousSibling!==null&&Ze(s.previousSibling)?.target==="carrier");if(n.length===0&&i===void 0)return;let a=[];if(i!==void 0&&e){for(let s of Array.from(i.content.childNodes))a.push(t.ownerDocument.adoptNode(s));i.previousSibling.remove(),i.remove()}else i!==void 0&&a.push(...Array.from(i.content.childNodes));return{ranges:n,carried:a}}function Ee(t,e,n,r,o){if(t.kind==="text"){let i=o instanceof Text?o:n.createTextNode("");return i.data=t.value,[i]}return t.kind==="slot"?Mr(t,e,n,r):an(t,e,n,[],r,o)}function jr(t,e){let n=Qt.get(e.definition)??[];if(n.length===0)return;let r=Ge(e.definition.contract.tag);e.effects.push(F(e.scope.scheduler,()=>{let o=qt(n,i=>e.scope.get(i));o===""?t.removeAttribute(r):t.getAttribute(r)!==o&&t.setAttribute(r,o)},2))}function Lr(t,e){let n=e.definition.contract.props,r={},o={};for(let[f,d]of Object.entries(n)){let h=`data-${Re(f)}`;r[h]=f;let u=e.definition.template.attributes.some(p=>p.kind==="attribute"&&p.name===h);e.effects.push(F(e.scope.scheduler,()=>{let p=e.scope.get(f);if(!u&&!e.explicit.has(f))return;let m=p===void 0||p===E||p===null?null:Ae(p,d.type);o[h]=m,m===null?t.removeAttribute(h):t.setAttribute(h,m)},2))}let i=t.ownerDocument.defaultView?.MutationObserver,a=Object.keys(r);if(i===void 0||a.length===0)return;let s=new i(f=>{for(let d of f){let h=d.attributeName;if(h===null)continue;let u=r[h];if(u===void 0)continue;let p=t.getAttribute(h);if(h in o&&o[h]===p){delete o[h];continue}delete o[h];let m=n[u];p===null?e.explicit.delete(u):e.explicit.add(u),e.scope.set(u,p===null?ur(u,m,void 0):Qe(m,p,!0))}}),c=()=>s.observe(t,{attributes:!0,attributeFilter:a}),l=()=>s.disconnect();e.connectCallbacks.add(c),e.disconnectCallbacks.add(l)}function Or(t,e){for(let n of e.definition.declarations??[])n.kind==="method"&&Object.defineProperty(t,n.name,{configurable:!0,enumerable:!1,value:(...r)=>e.controllerModule===void 0?Promise.reject(new TypeError(`Controller method \`${n.name}\` is not ready for <${e.definition.contract.tag}>.`)):e.controllerModule.then(o=>{let i=o[n.exportName];return typeof i!="function"&&y("HJ003",`Controller does not export method \`${n.exportName}\`.`),Reflect.apply(i,void 0,[Xe(t),...r])})})}function Ir(t,e,n,r,o=new WeakMap,i=!1){let a=n&&t.contains(t.ownerDocument.activeElement)?t.ownerDocument.activeElement:null,s=a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement?[a.selectionStart,a.selectionEnd]:void 0,{scope:c,passThrough:l,effects:f,rootName:d,explicit:h}=pr(t,e,n),u=r,p;if(n&&u===void 0){let b=Ye(t);if(b!==void 0){p=b.ranges;let v=[];for(let R of b.ranges)if(!R.fallback)for(let T of R.content)o.set(T,R.slot),v.push(T);v.push(...b.carried),u=v}else(e.slots??[]).length>0?y("HR005",`<${e.contract.tag}> has slots but its server-rendered root has no slot marks.`):u=[]}let m=n?u:Array.from(t.childNodes),w={definition:e,scope:c,refs:{},effects:f,connectCallbacks:new Set,disconnectCallbacks:new Set,connected:!1,explicit:h,frameworkOwned:i,projection:{nodes:n?u:Array.from(t.childNodes),slotNames:o}},k={definition:e,effects:f,refs:w.refs,connectCallbacks:w.connectCallbacks,disconnectCallbacks:w.disconnectCallbacks,projectedNodes:m,projectedSlotNames:o,slotInsertions:[],rootName:d,frameworkOwned:i,committed:n,hydrationRanges:p},x=an(e.template,c,t.ownerDocument,l,k,n?t:void 0);k.hydrationRanges=void 0;let g=x[0];return n&&g!==t&&y("HR005",`Server markup for <${e.contract.tag}> has an incompatible root.`),a instanceof HTMLElement&&(a.focus({preventScroll:!0}),s!==void 0&&(a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement)&&typeof s[0]=="number"&&typeof s[1]=="number"&&a.setSelectionRange(s[0],s[1])),It(g,G,e.contract.tag),w.element=g,{invocation:t,nativeRoot:g,context:k,definition:e,instance:w,replace:!n}}function zr(t,e){e.sort((n,r)=>n.invocation.contains(r.invocation)?-1:r.invocation.contains(n.invocation)?1:0);for(let n of e){for(let r of n.context.slotInsertions){for(let o of r.nodes)Ce(o);r.anchor.replaceWith(...r.nodes)}n.replace&&n.invocation.replaceWith(n.nativeRoot),n.context.committed=!0,Kt.set(n.nativeRoot,n.instance),Lr(n.nativeRoot,n.instance),jr(n.nativeRoot,n.instance),Or(n.nativeRoot,n.instance),ln(n.instance)}}function Gt(t,e,n){t.nodeType===1&&t.matches(e)&&n.add(t);for(let r of t.querySelectorAll(e))n.add(r)}function Vr(t,e){let n=t.nodeType===1?t:void 0;if(n?.matches("[data-component]")===!0&&e(n),n?.childElementCount!==0)for(let r of t.querySelectorAll("[data-component]"))e(r)}function qr(t,e,n){let r=Jt(t),o=new Set,i=dr(r);for(let u of e)Gt(u,i,o);let a=[];for(let u of o)u.localName==="template"&&u.hasAttribute("component")&&!xe.has(u)&&a.push(lr(u,a.length));let s=new Map;for(let u of a){let p=u.definition.contract.tag;(r.definitions.has(p)||s.has(p))&&y("HR001",`More than one definition declares <${p}>.`),s.set(p,u)}let c=[],l=new Set,f=(u,p,m)=>{let{definition:w}=u;return xe.has(p)||t.defaultView?.customElements.get(w.contract.tag)!==void 0||n?.(p,w,m)===!1?!1:(c.push(Ir(p,w,m)),!0)},d=(u,p)=>{for(let m of p){let w=u.get(m.localName);if(w!==void 0&&f(w,m,!1),!m.hasAttribute("data-component"))continue;let k=Z(m);if(k!==void 0){k.frameworkOwned||l.add(m);continue}let x=!1;for(let g of new Set((m.getAttribute("data-component")??"").split(/\s+/))){let b=u.get(g);b!==void 0&&f(b,m,!0)&&(x=!0)}x&&l.add(m)}};if(d(r.definitions,o),s.size>0){let u=["[data-component]",...Array.from(s.keys())].join(","),p=new Set;Gt(t,u,p),d(s,p)}for(let u of a)Xt(r,u.definition.contract.tag,u),u.style!==void 0&&(u.style.textContent=Yt(u.style.textContent??"",u.definition,u.wrapper.ownerDocument),u.wrapper.ownerDocument.head.append(u.style)),u.wrapper.remove();zr(r,c);let h=c.map(u=>u.nativeRoot);for(let u of h)l.add(u);return{lowered:h,roots:Array.from(l)}}function Ur(t,e){let n=Je(t),r=n.mutationHub;if(r===void 0){let i=t.defaultView?.MutationObserver;i===void 0&&y("HR003","Automatic component management requires a browser MutationObserver.");let a=new Set,s=new i(c=>{for(let l of Array.from(a))l(c)});r={observer:s,subscribers:a},n.mutationHub=r,s.observe(t,{childList:!0,subtree:!0})}r.subscribers.add(e);let o=!0;return()=>{o&&(o=!1,r.subscribers.delete(e),r.subscribers.size===0&&(r.observer.disconnect(),delete n.mutationHub))}}function ln(t){if(!t.connected){t.connected=!0;for(let e of t.effects)e.resume();for(let e of t.connectCallbacks)e();t.element?.dispatchEvent(new Event("connect"))}}function Zt(t){if(t.connected){t.element?.dispatchEvent(new Event("disconnect"));for(let e of t.disconnectCallbacks)e();t.connected=!1;for(let e of t.effects)e.pause()}}function Xe(t){let e=Z(t);if(e===void 0)return;if(e.host!==void 0)return e.host;let n=new Set((e.definition.declarations??[]).filter(a=>a.kind==="state").map(a=>a.name)),r=new Proxy({},{get:(a,s)=>{if(typeof s!="string")return;let c=e.scope.get(s);return c===E?void 0:c},set:(a,s,c)=>{if(typeof s!="string"||!n.has(s))throw new TypeError(`Only declared state roots are writable; \`${String(s)}\` is read-only.`);return e.scope.set(s,c),!0},has:(a,s)=>typeof s=="string"&&e.scope.has(s)}),o=new Proxy({},{get:(a,s)=>typeof s!="string"?void 0:(t instanceof HTMLFormElement?t:t.querySelector("form"))?.elements.namedItem(s)??t.querySelector(`[name="${CSS.escape(s)}"]`)??void 0}),i={element:t,state:r,refs:e.refs,elements:o,signal(a){return Pt(a)},computed(a){let s=jt(e.scope.scheduler,a);return e.connected||s.pause(),e.effects.unshift(s),s},effect(a){let s=F(e.scope.scheduler,a,2,e.connected);return e.effects.push(s),()=>s.stop()},on(a,s){if(a==="connect"){let c=s;return e.connectCallbacks.add(c),e.connected&&s(),()=>e.connectCallbacks.delete(c)}if(a==="disconnect"){let c=s;return e.disconnectCallbacks.add(c),()=>e.disconnectCallbacks.delete(c)}return t.addEventListener(a,s),()=>t.removeEventListener(a,s)},dispatch(a,s){return on(t,a,s,rn(e.definition,a))}};return e.host=Object.freeze(i),e.host}function un(t,e){let n=Z(t);n===void 0&&y("HJ003","A controller can attach only to a lowered component root."),n.controllerModule=e}function fn(t=document,e={}){let n=Je(t);n.observer!==void 0&&y("HR003","This document is already being observed.");let r=new Map,o=e.onError??(d=>console.error(d)),i=!1,a=d=>{let h=r.get(d);r.delete(d);let u=Z(d);u!==void 0&&Zt(u);try{h?.()}catch(p){o(p)}},s=d=>{let h=Z(d);if(!(h===void 0||h.frameworkOwned||r.has(d)||!t.contains(d))){r.set(d,void 0);try{ln(h);let u=e.onConnect?.(d,h.definition);i?u?.():r.set(d,u)}catch(u){o(u)}}},c=d=>{if(i)return;let h=[];if(d===void 0)h.push(t);else{let u=[];for(let p of d){for(let m of p.removedNodes)m.nodeType===1&&Vr(m,w=>{r.has(w)&&u.push(w)});for(let m of p.addedNodes)m.nodeType===1&&h.push(m)}for(let p of u)t.contains(p)||a(p)}if(h.length>0)try{for(let u of qr(t,h,e.shouldLower).roots){if(i)break;s(u)}}catch(u){o(u)}};n.release=d=>{r.has(d)&&a(d)};let l=Ur(t,c),f=()=>{if(!i){i=!0,l(),delete n.observer,delete n.release;for(let d of r.values())try{d?.()}catch(h){o(h)}for(let d of r.keys()){let h=Z(d);h!==void 0&&Zt(h)}r.clear()}};return n.observer=f,c(),f}function Br(t){let e={};for(let n of t.querySelectorAll('script[type="importmap"]')){let r=JSON.parse(n.textContent??"{}");Object.assign(e,r.imports??{})}return{imports:e}}async function et(t,e={}){let n=e.document??document,r=e.fetch??fetch,o=new he(e.importMap??Br(n),n.baseURI),i=await ct(t,{resolver:o,fetchComponent:async s=>{let c=await r(s);if(!c.ok)throw new TypeError(`Component request \`${s}\` failed with ${c.status}.`);return{url:c.url||s,source:await c.text()}},parseComponentResource:(s,c)=>Tt(s,c,n),isCustomElementRegistered:s=>n.defaultView?.customElements.get(s)!==void 0}),a=e.registry??new me;return a.addGraph(i,s=>At(s,e.importer)),Object.freeze({graph:i,registry:a})}function tt(t=document){return Object.freeze(Array.from(t.querySelectorAll('link[rel="component"][href]'),e=>e.getAttribute("href")).filter(e=>e.trim()!==""))}function nt(t=document,e={}){return et(tt(t),{...e,document:t})}async function rt(t=document,e={}){let n=await nt(t,e);en(n.graph,t);let r=e.onError??(i=>console.error(i)),o=fn(t,{onError:r,onConnect(i,a){let s=n.registry.get(a.contract.tag)?.node;if(s?.controller===void 0)return;let c=Be(s,e.importer);un(i,c);let l=!1,f;return c.then(d=>l?void 0:d.default(Xe(i))).then(d=>{typeof d=="function"&&(l?d():f=d)}).catch(r),()=>{l=!0,f?.()}}});return Object.freeze({...n,stop:o})}var pn=Symbol.for("@nextwebwg/html-next/browser"),ot=globalThis,mn=ot[pn]??Object.freeze({ready:rt()});ot[pn]=mn;var _r=mn.ready;ot.HTMLNext??=Object.freeze({ready:_r,documentComponentRoots:tt,loadBrowserComponents:et,loadDocumentComponents:nt,startBrowserComponents:rt});export{tt as documentComponentRoots,et as loadBrowserComponents,nt as loadDocumentComponents,_r as ready,rt as startBrowserComponents};
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,GAGvB,MAAM,qBAAqB,CAAC;AAE7B,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;AAiBrE,MAAM,aAAa,GAAG,UAA2B,CAAC;AAClD,MAAM,KAAK,GAAG,aAAa,CAAC,iBAAiB,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC;IAC9D,KAAK,EAAE,sBAAsB,EAAE;CAChC,CAAC,CAAC;AACH,aAAa,CAAC,iBAAiB,CAAC,GAAG,KAAK,CAAC;AAEzC,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;AAEjC,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,GACvB,CAAC;AAGF,aAAa,CAAC,QAAQ,KAAK,MAAM,CAAC,MAAM,CAAC;IACvC,KAAK;IACL,sBAAsB;IACtB,qBAAqB;IACrB,sBAAsB;IACtB,sBAAsB;CACvB,CAAC,CAAC"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env node
2
+ export type BuildTarget = "docs" | "styles" | "vanilla" | "vue";
3
+ export interface BuildOptions {
4
+ readonly targets?: readonly BuildTarget[];
5
+ }
6
+ export interface BuildManifest {
7
+ readonly generatorVersion: string;
8
+ readonly components: readonly {
9
+ readonly source: string;
10
+ readonly name: string;
11
+ readonly tag: string;
12
+ readonly artifacts: readonly string[];
13
+ readonly dependencies: readonly string[];
14
+ readonly controller: null | string;
15
+ }[];
16
+ }
17
+ export interface InspectedComponentGraph {
18
+ readonly roots: readonly string[];
19
+ readonly components: readonly {
20
+ readonly tag: string;
21
+ readonly source: string;
22
+ readonly dependencies: readonly string[];
23
+ readonly controller: null | string;
24
+ readonly support: string | null;
25
+ }[];
26
+ readonly modules: readonly string[];
27
+ }
28
+ export declare function inspectComponents(entries: readonly string[]): Promise<InspectedComponentGraph>;
29
+ export declare function checkComponents(entries: readonly string[]): Promise<InspectedComponentGraph>;
30
+ export declare function buildComponents(entries: readonly string[], outDirectory: string, options?: BuildOptions): Promise<BuildManifest>;
31
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1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wBAAsB,eAAe,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAElG;AAED,wBAAsB,eAAe,CACnC,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,aAAa,CAAC,CA8DxB"}
package/dist/cli.js ADDED
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env node
2
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
3
+ import { dirname, relative, resolve, sep } from "node:path";
4
+ import { fileURLToPath, pathToFileURL } from "node:url";
5
+ import ts from "typescript-compiler";
6
+ import { generateComponent, GENERATOR_VERSION, } from "./generate.js";
7
+ import { addControllerGraph } from "./controller-files.js";
8
+ import { loadNodeComponents } from "./node-loader.js";
9
+ async function componentGraph(entries) {
10
+ if (entries.length === 0)
11
+ throw new Error("At least one component source is required.");
12
+ const baseURL = pathToFileURL(`${process.cwd()}${sep}`).href;
13
+ return loadNodeComponents(entries.map((entry) => pathToFileURL(resolve(entry)).href), {
14
+ baseURL,
15
+ inspectModule: async (url) => {
16
+ const source = await readFile(fileURLToPath(url), "utf8");
17
+ return {
18
+ url,
19
+ dependencies: ts.preProcessFile(source, true, true).importedFiles
20
+ .map((item) => item.fileName)
21
+ .filter((specifier) => specifier.startsWith(".") || specifier.startsWith("/"))
22
+ .map((specifier) => new URL(specifier, url).href),
23
+ };
24
+ },
25
+ });
26
+ }
27
+ export async function inspectComponents(entries) {
28
+ const graph = await componentGraph(entries);
29
+ const display = (url) => url.startsWith("file:")
30
+ ? relative(process.cwd(), fileURLToPath(url)).split(sep).join("/")
31
+ : url;
32
+ return Object.freeze({
33
+ roots: Object.freeze(graph.roots.map(display)),
34
+ components: Object.freeze([...graph.nodes.values()].map((node) => Object.freeze({
35
+ tag: node.definition.contract.tag,
36
+ source: display(node.url),
37
+ dependencies: Object.freeze(node.dependencies.map(display)),
38
+ controller: node.controller === undefined ? null : display(node.controller.url),
39
+ support: node.definition.contract.status ?? null,
40
+ }))),
41
+ modules: Object.freeze(graph.moduleInputs.map(display)),
42
+ });
43
+ }
44
+ export async function checkComponents(entries) {
45
+ return inspectComponents(entries);
46
+ }
47
+ export async function buildComponents(entries, outDirectory, options = {}) {
48
+ if (entries.length === 0)
49
+ throw new Error("Build requires at least one component source.");
50
+ const normalizedEntries = entries.map((entry) => resolve(entry));
51
+ if (new Set(normalizedEntries).size !== normalizedEntries.length) {
52
+ throw new Error("Generated artifact collision: the same component source was provided more than once.");
53
+ }
54
+ const outputRoot = resolve(outDirectory);
55
+ const artifacts = new Map();
56
+ const components = [];
57
+ const selected = new Set(options.targets ?? ["docs", "styles", "vanilla", "vue"]);
58
+ const graph = await componentGraph(entries);
59
+ const displayPath = (url) => relative(process.cwd(), fileURLToPath(url)).split(sep).join("/");
60
+ for (const node of [...graph.nodes.values()].sort((left, right) => left.url.localeCompare(right.url))) {
61
+ const entry = fileURLToPath(node.url);
62
+ const controllerTarget = node.controller === undefined ? undefined : await addControllerGraph(node.controller.url, node.trustRoot, `controllers/${node.definition.contract.tag}`, artifacts);
63
+ const definition = controllerTarget === undefined
64
+ ? node.definition
65
+ : Object.freeze({ ...node.definition, controller: `../${controllerTarget}` });
66
+ const generated = generateComponent(definition).filter((artifact) => selected.has(artifact.path.split("/", 1)[0]));
67
+ for (const artifact of generated) {
68
+ if (artifacts.has(artifact.path)) {
69
+ throw new Error(`Generated artifact collision at ${artifact.path}.`);
70
+ }
71
+ artifacts.set(artifact.path, artifact);
72
+ }
73
+ components.push({
74
+ source: relative(process.cwd(), entry).split(sep).join("/"),
75
+ name: definition.contract.name,
76
+ tag: definition.contract.tag,
77
+ artifacts: generated.map((artifact) => artifact.path),
78
+ dependencies: node.dependencies.map(displayPath),
79
+ controller: node.controller === undefined ? null : displayPath(node.controller.url),
80
+ });
81
+ }
82
+ await mkdir(outputRoot, { recursive: true });
83
+ for (const artifact of artifacts.values()) {
84
+ const path = resolve(outputRoot, artifact.path);
85
+ if (path !== outputRoot && !path.startsWith(`${outputRoot}${sep}`)) {
86
+ throw new Error(`Generated artifact escaped the output directory: ${artifact.path}.`);
87
+ }
88
+ await mkdir(dirname(path), { recursive: true });
89
+ await writeFile(path, artifact.content, "utf8");
90
+ }
91
+ const manifest = {
92
+ generatorVersion: GENERATOR_VERSION,
93
+ components,
94
+ };
95
+ await writeFile(resolve(outputRoot, "html.manifest.json"), `${JSON.stringify(manifest, null, 2)}\n`, "utf8");
96
+ return manifest;
97
+ }
98
+ function usage() {
99
+ return "Usage: html-next <check|inspect|build> <component.html...> [--target <target>] [--out-dir <directory>]";
100
+ }
101
+ async function main(argv) {
102
+ if (argv[0] === "check" || argv[0] === "inspect") {
103
+ if (argv.length < 2)
104
+ throw new Error(usage());
105
+ const result = await inspectComponents(argv.slice(1));
106
+ if (argv[0] === "inspect")
107
+ process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
108
+ return;
109
+ }
110
+ if (argv[0] !== "build")
111
+ throw new Error(usage());
112
+ const outIndex = argv.indexOf("--out-dir");
113
+ const outDirectory = argv[outIndex + 1];
114
+ if (outIndex < 2 || outDirectory === undefined) {
115
+ throw new Error(usage());
116
+ }
117
+ const targetArgs = argv.slice(outIndex + 2);
118
+ const targets = [];
119
+ for (let index = 0; index < targetArgs.length; index += 2) {
120
+ if (targetArgs[index] !== "--target" || targetArgs[index + 1] === undefined)
121
+ throw new Error(usage());
122
+ targets.push(targetArgs[index + 1]);
123
+ }
124
+ const allowed = new Set(["docs", "styles", "vanilla", "vue"]);
125
+ if (targets.some((target) => !allowed.has(target)))
126
+ throw new Error(`Unknown build target: ${targets.find((target) => !allowed.has(target))}.`);
127
+ await buildComponents(argv.slice(1, outIndex), outDirectory, targets.length === 0 ? {} : { targets });
128
+ }
129
+ if (process.argv[1] === fileURLToPath(import.meta.url)) {
130
+ try {
131
+ await main(process.argv.slice(2));
132
+ }
133
+ catch (error) {
134
+ console.error(error instanceof Error ? error.message : String(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Y,EAAE,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AACxG,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACvD,IAAI,CAAC;QACH,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACtE,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type CompiledComponentStyles } from "./component-styles.js";
2
+ import type { ComponentDefinition } from "./template.js";
3
+ export declare function compileComponentStylesForBuild(css: string, definition: ComponentDefinition, source?: string): CompiledComponentStyles;
4
+ /**
5
+ * Styles for a converted Vue component, emitted as `<style scoped>`. Vue's scoping already bounds
6
+ * the region: projected content carries the consumer's scope, and Vue's own `:slotted()` reaches it.
7
+ * The generated root carries `data-component` and the state attribute, so `:host` and
8
+ * `:host-state()` become attribute selectors on it.
9
+ */
10
+ export declare function compileComponentStylesForVue(css: string, definition: ComponentDefinition, source?: string): CompiledComponentStyles;
11
+ //# sourceMappingURL=component-styles-build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-styles-build.d.ts","sourceRoot":"","sources":["../src/component-styles-build.ts"],"names":[],"mappings":"AAMA,OAAO,EAGL,KAAK,uBAAuB,EAM7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAKzD,wBAAgB,8BAA8B,CAC5C,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,mBAAmB,EAC/B,MAAM,CAAC,EAAE,MAAM,GACd,uBAAuB,CAqCzB;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,mBAAmB,EAC/B,MAAM,CAAC,EAAE,MAAM,GACd,uBAAuB,CAYzB"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Component style compilation for build tools, which have no DOM. It performs the same rename,
3
+ * two-copy prune, and selector rewrite as the browser (`component-styles.ts`), over postcss.
4
+ */
5
+ import postcss, {} from "postcss";
6
+ import { assembleComponentStyles, COMPONENT_ATTRIBUTE, renameComponentPseudoClasses, rewriteComponentSelector, styleRuleKind, validateStateNames, } from "./component-styles.js";
7
+ /** At-rules whose block holds style rules; everything else is document-wide and hoisted. */
8
+ const GROUPING = new Set(["media", "supports", "container", "layer", "scope", "starting-style"]);
9
+ export function compileComponentStylesForBuild(css, definition, source) {
10
+ const tag = definition.contract.tag;
11
+ if (css.trim() === "")
12
+ return { css: "", stateNames: [] };
13
+ const renamed = renameComponentPseudoClasses(css);
14
+ const names = new Set();
15
+ const hoisted = [];
16
+ const rewrite = (rule) => {
17
+ rule.selector = rewriteComponentSelector(rule.selector, tag, ":scope", names);
18
+ rule.walkRules((nested) => {
19
+ nested.selector = rewriteComponentSelector(nested.selector, tag, ":scope", names);
20
+ });
21
+ };
22
+ const prune = (container, want, topLevel) => {
23
+ container.each((node) => {
24
+ if (node.type === "rule") {
25
+ if (styleRuleKind(node.selector) === want)
26
+ rewrite(node);
27
+ else
28
+ node.remove();
29
+ }
30
+ else if (node.type === "atrule" && GROUPING.has(node.name.toLowerCase()) && node.nodes !== undefined) {
31
+ prune(node, want, false);
32
+ }
33
+ else if (node.type === "atrule") {
34
+ if (topLevel && want === "own")
35
+ hoisted.push(node.toString());
36
+ node.remove();
37
+ }
38
+ else if (node.type === "decl") {
39
+ node.remove();
40
+ }
41
+ });
42
+ };
43
+ const compile = (want) => {
44
+ const root = postcss.parse(renamed);
45
+ prune(root, want, true);
46
+ return root.toString().trim();
47
+ };
48
+ const own = compile("own");
49
+ const slotted = compile("slotted");
50
+ validateStateNames(definition, names, source);
51
+ return { css: assembleComponentStyles(tag, own, slotted, hoisted.join("\n")), stateNames: [...names] };
52
+ }
53
+ /**
54
+ * Styles for a converted Vue component, emitted as `<style scoped>`. Vue's scoping already bounds
55
+ * the region: projected content carries the consumer's scope, and Vue's own `:slotted()` reaches it.
56
+ * The generated root carries `data-component` and the state attribute, so `:host` and
57
+ * `:host-state()` become attribute selectors on it.
58
+ */
59
+ export function compileComponentStylesForVue(css, definition, source) {
60
+ const tag = definition.contract.tag;
61
+ if (css.trim() === "")
62
+ return { css: "", stateNames: [] };
63
+ const names = new Set();
64
+ const root = postcss.parse(renameComponentPseudoClasses(css, ["host-state"]));
65
+ root.walkRules((rule) => {
66
+ const parent = rule.parent;
67
+ if (parent?.type === "atrule" && /keyframes$/i.test(parent.name))
68
+ return;
69
+ rule.selector = rewriteComponentSelector(rule.selector, tag, `[${COMPONENT_ATTRIBUTE}~="${tag}"]`, names);
70
+ });
71
+ validateStateNames(definition, names, source);
72
+ return { css: root.toString().trim(), stateNames: [...names] };
73
+ }
74
+ //# sourceMappingURL=component-styles-build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-styles-build.js","sourceRoot":"","sources":["../src/component-styles-build.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,OAAO,EAAE,EAA0D,MAAM,SAAS,CAAC;AAE1F,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EAEnB,4BAA4B,EAC5B,wBAAwB,EACxB,aAAa,EAEb,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAG/B,4FAA4F;AAC5F,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,C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C,GAAG,CAAC;IACpC,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;IAC1D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC9E,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;QACtB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAI,MAAM,EAAE,IAAI,KAAK,QAAQ,IAAI,aAAa,CAAC,IAAI,CAAE,MAAiB,CAAC,IAAI,CAAC;YAAE,OAAO;QACrF,IAAI,CAAC,QAAQ,GAAG,wBAAwB,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,mBAAmB,MAAM,GAAG,IAAI,EAAE,KAAK,CAAC,CAAC;IAC5G,CAAC,CAAC,CAAC;IACH,kBAAkB,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;IAC9C,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC;AACjE,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { ComponentDefinition } from "./template.js";
2
+ /** Names a component on its root, and only its root. Delegated roots list every owner. */
3
+ export declare const COMPONENT_ATTRIBUTE = "data-component";
4
+ /** Marks each top-level projected node. */
5
+ export declare const PROJECTED_ATTRIBUTE = "data-slotted";
6
+ export declare function addAttributeToken(element: Element, attribute: string, token: string): void;
7
+ export declare function markProjectedRoot(node: Node): void;
8
+ /** The attribute carrying the resolved values a definition's `:host-state()` rules test. */
9
+ export declare function stateAttribute(tag: string): string;
10
+ export type StyleRuleKind = "own" | "slotted";
11
+ /**
12
+ * Renames `:slotted(` and `:host-state(` into valid selectors, skipping comments and strings. A
13
+ * target that has its own `:slotted()` (Vue) renames only `:host-state(`.
14
+ */
15
+ export declare function renameComponentPseudoClasses(css: string, kinds?: readonly ("slotted" | "host-state")[]): string;
16
+ /** Whether a renamed selector belongs to projected content rather than the component's own markup. */
17
+ export declare function styleRuleKind(selector: string): StyleRuleKind;
18
+ /**
19
+ * Rewrites one renamed selector. `host` is what `:host` becomes: `:scope` inside the component's
20
+ * `@scope` rules (both of them are rooted at the component root), or the root's own selector where
21
+ * there is no `@scope` (Vue's scoped styles).
22
+ */
23
+ export declare function rewriteComponentSelector(selector: string, tag: string, host: string, names: Set<string>, canonical?: (name: string) => string): string;
24
+ /** Wraps the compiled groups in the component's two scopes; `hoisted` rules stay document-wide. */
25
+ export declare function assembleComponentStyles(tag: string, own: string, slotted: string, hoisted: string): string;
26
+ /** Rejects `:host-state()` tests on names that are not declared props or state of a stylable type. */
27
+ export declare function validateStateNames(definition: ComponentDefinition, names: ReadonlySet<string>, source?: string): void;
28
+ export interface CompiledComponentStyles {
29
+ readonly css: string;
30
+ /** The props and state the state attribute must carry, in first-use order. */
31
+ readonly stateNames: readonly string[];
32
+ }
33
+ /** Compiles a style block in a browser through the CSS Object Model. */
34
+ export declare function compileComponentStyles(css: string, definition: ComponentDefinition, document: Document, source?: string): CompiledComponentStyles;
35
+ /** The state attribute's tokens for the current values: `name` while truthy, `name=value` for text. */
36
+ export declare function stateAttributeValue(names: readonly string[], read: (name: string) => unknown): string;
37
+ //# sourceMappingURL=component-styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-styles.d.ts","sourceRoot":"","sources":["../src/component-styles.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGzD,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AACpD,2CAA2C;AAC3C,eAAO,MAAM,mBAAmB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