diff --git a/builds/respec-w3c.js b/builds/respec-w3c.js index 1ca1480d66..961ed541a1 100644 --- a/builds/respec-w3c.js +++ b/builds/respec-w3c.js @@ -94,7 +94,7 @@ p:is(.respec-hint,.respec-occurrences){display:block;margin-top:.5em} ${Hs}
(plugin: "${e.plugin}")
`:"",n=e.hint?`\n${js(`How to fix: ${us(e.hint)}`,{inline:!e.hint.includes("\n")})}\n`:"",r=Array.isArray(e.elements)?`
Occurred ${e.elements.length} times at:
\n ${js(e.elements.map(si).join("\n"))}`:"",s=e.details?`\n\n(plugin: "${e.plugin}")
`:"",n=e.hint?`\n${js(`How to fix: ${us(e.hint)}`,{inline:!e.hint.includes("\n")})}\n`:"",r=Array.isArray(e.elements)?`
Occurred ${e.elements.length} times at:
\n ${js(e.elements.map(si).join("\n"))}`:"",s=e.details?`\n\n` block.'})}}(e,r,s))),a=document.body,c=s.definitions,a.querySelectorAll("[data-cddl-pending]").forEach((e=>{const t=`cddl-type:${e.dataset.cddlPending}`;if(c.has(t)){const n=c.get(t);if(!n)return;const r=a.ownerDocument.createElement("a");r.href=`#${n.id}`,r.className="cddl-name",r.dataset.linkType="cddl-type",r.textContent=e.textContent,e.replaceWith(r)}})),document.querySelectorAll("[data-cddl-pending]").forEach((e=>{rs(`No CDDL definition found for \`${e.getAttribute("data-cddl-pending")}\`.`,ul,{elements:[e],hint:"Check for typos in the type name."})})),function(e,t){e.querySelectorAll('a[data-link-type^="cddl-"]:not([href]):not([data-cite])').forEach((e=>{const n=e.getAttribute("data-link-type"),r=e.getAttribute("data-xref-for")||e.getAttribute("data-link-for")||"",s=e.textContent.trim();if("cddl-type"!==n&&"cddl-key"!==n&&"cddl-value"!==n)return;const i={"cddl-type":`cddl-type:${s}`,"cddl-key":`cddl-key:${r}/${s}`,"cddl-value":`cddl-value:${r}/${s}`}[n];if(t.has(i)){const n=t.get(i);if(!n)return;e.setAttribute("href",`#${n.id}`),e.classList.add("internalDFN")}else rs(`CDDL ${n}: no definition found for \`${s}\`${r?`, for \`${r}\`,`:""} in any \`\` block.`,ul,{elements:[e]}),e.setAttribute("data-no-link-to-dfn","")}))}(document,s.definitions),function(e,t){t.forEach((t=>{const n=e.getElementById(t.id);"dfn"===n?.localName&&pc(n,[n.textContent.trim()])}))}(document,s.definitions),Vc(),hs("beforesave",(e=>{e.querySelectorAll("[data-cddl-pending]").forEach((e=>e.removeAttribute("data-cddl-pending")))}))}});const bl="core/data-cite",yl="__SPEC__";async function wl(e){const{key:t,frag:n,path:r,href:s}=e;let i="",o="";if(t===yl)i=document.location.href;else{const e=await ka(t);if(!e)return null;i=e.href??"",o=e.title}if(s)i=s;else{if(r){const e=r.startsWith("/")?`.${r}`:r;i=new URL(e,i).href}n&&(i=new URL(n,i).href)}return{href:i,title:o}}function vl(e,t,n){const{href:r,title:s}=t,i=!n.path&&!n.frag;switch(e.localName){case"a":{const t=e;if(""===t.textContent&&"the-empty-string"!==t.dataset.lt&&(t.textContent=s),t.href=r,i){const e=document.createElement("cite");t.replaceWith(e),e.append(t)}break}case"dfn":{const t=document.createElement("a");if(t.href=r,t.dataset.cite=n.key,t.dataset.citePath=n.path,t.dataset.citeFrag=n.frag,e.textContent?Vr(e,t):(t.textContent=s,e.append(t)),i){const n=document.createElement("cite");n.append(t),e.append(n)}if("export"in e.dataset){ns("Exporting a linked external definition is not allowed.",bl,{hint:"Please remove the `data-export` attribute.",elements:[e]}),delete e.dataset.export}e.classList.add("externalDFN"),e.dataset.noExport="";break}}}function kl(e){return t=>{const n=t.search(e);return-1!==n?t.substring(n):""}}const $l=kl("#"),xl=kl("/");function Cl(e){const{dataset:t}=e,{cite:n,citeFrag:r,citePath:s,citeHref:i}=t;if((n??"").startsWith("#")&&!r){const r=e.parentElement?.closest('[data-cite]:not([data-cite^="#"])')??null,{key:s,isNormative:i}=r?Cl(r):{key:yl,isNormative:!1};return t.cite=i?s:`?${s}`,t.citeFrag=(n??"").replace("#",""),Cl(e)}const o=r?`#${r}`:$l(n??""),a=s||xl(n??"").split("#")[0],{type:c}=Gr(n??"",e),l="normative"===c,u=/^[?|!]/.test(n??"");return{key:(n??"").split(/[/|#]/)[0].substring(Number(u)),isNormative:l,frag:o,path:a,href:i}}function Sl(e){const t=["data-cite","data-cite-frag","data-cite-path"];e.querySelectorAll("a[data-cite], dfn[data-cite]").forEach((e=>t.forEach((t=>e.removeAttribute(t)))))}var _l=Object.freeze({__proto__:null,THIS_SPEC:yl,name:bl,run:async function(){const e=document.querySelectorAll("dfn[data-cite]:not([data-cite='']), a[data-cite]:not([data-cite=''])");await async function(e){const t=e.map(Cl).map((async e=>({entry:e,result:await ka(e.key)}))),n=(await Promise.all(t)).filter((({result:e})=>null===e)).map((({entry:{key:e}})=>e)),r=await va(n);r&&Object.assign(ma,r)}([...e]);const t=new Map,n=new Map;for(const r of e){t.set(r,r.dataset.cite);const e=Cl(r);n.set(r,e)}for(const r of e){const e=t.get(r),s=n.get(r),i=await wl(s);if(i)r.dataset.citeFrag&&r.dataset.matchedText||!r.dataset.lt||"the-empty-string"===r.dataset.lt||""!==r.textContent||(r.textContent=r.dataset.lt,delete r.dataset.lt),vl(r,i,s);else{const t=`Couldn't find a match for "${e}"`;r.dataset.matchedText&&(r.textContent=r.dataset.matchedText),rs(t,bl,{elements:[r]})}}hs("beforesave",Sl)},toCiteDetails:Cl});const Tl="core/link-to-dfn",Rl=[],El={en:{duplicateMsg:e=>`Duplicate definition(s) of '${e}'`,duplicateTitle:"This is defined more than once in the document."},ja:{duplicateMsg:e=>`'${e}' の重複定義`,duplicateTitle:"この文書内で複数回定義されています."},de:{duplicateMsg:e=>`Mehrfache Definition von '${e}'`,duplicateTitle:"Das Dokument enthält mehrere Definitionen dieses Eintrags."},zh:{duplicateMsg:e=>`'${e}' 的重复定义`,duplicateTitle:"在文档中有重复的定义。"},cs:{duplicateMsg:e=>`Duplicitní definice '${e}'`,duplicateTitle:"Toto je v dokumentu definováno vícekrát."}},Ll=Ir(El);function Al(e){const t=new Map,n=[];for(const r of dc.get(e)??[]){const{dfnType:s="dfn"}=r.dataset,i=r.dataset.dfnFor?.split(",").map((e=>e.trim()))??[""];for(const o of i){if(t.has(o)&&t.get(o)?.has(s)){const e=t.get(o)?.get(s),i="dfn"===e?.localName,a="dfn"===r.localName,c=s===(e?.dataset.dfnType||"dfn"),l=!o&&!e?.dataset.dfnFor||e?.dataset.dfnFor?.split(",").map((e=>e.trim())).includes(o);if(i&&a&&c&&l){n.push(r);continue}}t.has(o)||t.set(o,new Map),t.get(o)?.set(s,r),("idl"in r.dataset||"dfn"!==s)&&t.get(o)?.set("idl",r),Fr(r,"dfn",e)}}return{result:t,duplicates:n}}function Pl(e,t){const n=function(e){const t=e.closest("[data-link-for]"),n=t?t.dataset.linkFor??"":"",r=Br(e).reduce(((e,r)=>{const s=r.split(".");2===s.length&&e.push({for:s[0],title:s[1]}),e.push({for:n,title:r}),t||e.push({for:r,title:r}),""!==n&&e.push({for:"",title:r});const i=r.replace(yr,"");return i!==r&&""!==i&&(e.push({for:n,title:i}),t||e.push({for:i,title:i}),""!==n&&e.push({for:"",title:i})),e}),[]);return r}(e),r=n.find((e=>t.has(e.title)&&t.get(e.title)?.has(e.for)));if(!r)return;const s=t.get(r.title)?.get(r.for),{linkType:i}=e.dataset;if(i){for(const e of i.split("|"))if(s?.get(e))return s.get(e);return s?.get("dfn")}{const e=r.for?"idl":"dfn";return s?.get(e)||s?.get("idl")}}function Nl(e,t,n){let r=!1;const{linkFor:s}=e.dataset,{dfnFor:i}=t.dataset;if(t.dataset.cite)e.dataset.cite=t.dataset.cite;else if(s&&!n.get(s)&&i&&!i.split(",").map((e=>e.trim())).includes(s))r=!0;else if(t.classList.contains("externalDFN")){const n=t.dataset.lt?t.dataset.lt.split("|"):[];e.dataset.lt=n[0]||t.textContent,r=!0}else"partial"!==e.dataset.idl?(e.href=`#${t.id}`,e.classList.add("internalDFN")):r=!0;return e.hasAttribute("data-link-type")||(e.dataset.linkType="idl"in t.dataset?"idl":"dfn"),function(e){if(e.closest("code,pre"))return!0;if(1!==e.childNodes.length)return!1;const[t]=e.childNodes;return"code"===t.localName}(t)&&function(e,t){const n=e.textContent.trim(),r=t.dataset.hasOwnProperty("idl"),s=Il(e)&&Il(t,n);r&&!s||Vr(e,document.createElement("code"))}(e,t),!r}function Il(e,t=""){if("a"===e.localName){if(!e.querySelector("code"))return!0}else{const{dataset:n}=e;if(e.textContent.trim()===t)return!0;if(n.title===t)return!0;if(n.lt||n.localLt){const e=[];return n.lt&&e.push(...n.lt.split("|")),n.localLt&&e.push(...n.localLt.split("|")),e.includes(t)}}return!1}function Dl(e){e.forEach((e=>{const t=`Found linkless \`\` element with text "${e.textContent}" but no matching \`\``,n=e.closest("[data-link-for]"),r=`Add a matching \`\` element, ${ls`use ${"[data-cite]"} to link to an external definition, or enable ${"[xref]"} for automatic cross-spec linking.`}${n?` This link is inside a \`data-link-for="${n.dataset.linkFor}"\` section — \`[=term=]\` links are scoped to that context. To link to a global concept instead, either add \`data-link-for=""\` on this \`\` or move it outside the scoped section.`:""}`;rs(t,Tl,{title:"Linking error: no matching ``",hint:r,elements:[e]})}))}var Ol=Object.freeze({__proto__:null,name:Tl,possibleExternalLinks:Rl,run:async function(e){const t=function(){const e=new es;for(const t of dc.keys()){const{result:n,duplicates:r}=Al(t);e.set(t,n),r.length>0&&ns(Ll.duplicateMsg(t),Tl,{title:Ll.duplicateTitle,elements:r})}return e}(),n=[],r=document.querySelectorAll("a[data-cite='']:not([data-no-link-to-dfn]), a:not([href]):not([data-cite]):not([data-no-link-to-dfn]):not(.logo):not(.externalDFN)");for(const e of r){if(!e.dataset?.linkType&&e.dataset?.xrefType){Rl.push(e);continue}const r=Pl(e,t);if(r){Nl(e,r,t)||Rl.push(e)}else""===e.dataset.cite?n.push(e):Rl.push(e)}Dl(n),function(e){const{shortName:t=""}=e,n=t?new RegExp(String.raw`^([?!])?${vr(t)}\b([^-])`,"i"):null,r=document.querySelectorAll("dfn[data-cite]:not([data-cite='']), a[data-cite]:not([data-cite=''])");for(const t of r){n&&(t.dataset.cite=(t.dataset.cite??"").replace(n,`$1${yl}$2`));const{key:r,isNormative:s}=Cl(t);r!==yl&&(s||e.normativeReferences.has(r)?(e.normativeReferences.add(r),e.informativeReferences.delete(r)):e.informativeReferences.add(r))}}(e),e.xref||Dl(Rl)}});const jl="xrefs",zl=3e5;async function Ml(){return await ir.openDB("xref",2,{upgrade(e){[...e.objectStoreNames].forEach((t=>e.deleteObjectStore(t)));e.createObjectStore(jl,{keyPath:"query.id"}).createIndex("byTerm","query.term",{unique:!1})}})}async function Ul(e){const t=new Map;if(await async function(){const e="XREF:LAST_VERSION_CHECK",t=parseInt(localStorage.getItem(e)??"",10),n=Date.now();if(!t)return localStorage.setItem(e,n.toString()),!1;if(n-tt}())return await async function(){try{await Ml().then((e=>e.clear(jl)))}catch(e){console.error(e)}}(),t;const n=new Set(e.map((e=>e.id)));try{const e=await Ml();let r=await e.transaction(jl).store.openCursor();for(;r;)n.has(r.key)&&t.set(r.key,r.value.result),r=await r.continue()}catch(e){console.error(e)}return t}const ql="core/xref",Wl={"web-platform":["HTML","INFRA","URL","WEBIDL","DOM","FETCH"]},Fl="https://respec.org/xref/",Bl=[];if(!document.querySelector("link[rel='preconnect'][href='https://respec.org']")){const e=Sr({hint:"preconnect",href:"https://respec.org"});document.head.appendChild(e)}function Hl(e){const t="xrefType"in e.dataset;let n=Gl(e,{isIDL:t});t||(n=n.toLowerCase());const r=function(e){const t=[];let n=e.closest("[data-cite]");for(;n;){const r=(n.dataset.cite??"").toLowerCase().replace(/[!?]/g,"").split(/\s+/).filter((e=>e));if(r.length){t.push(r);const e=Jl(r);e.length&&t.push(e)}if(n===e)break;n=n.parentElement?.closest("[data-cite]")??null}if(n!==e){const n=e.closest("section"),r=n?n.querySelectorAll("a.bibref"):[],s=[...new Set([...r].map((e=>e.textContent.toLowerCase())))];if(s.length){t.push(s);const e=Jl(s);e.length&&t.push(e)}}const r=function(e){const t=[],n=new Set;for(const r of e){const e=[...new Set(r).values().filter((e=>!n.has(e)))];e.forEach((e=>n.add(e))),t.push(e.sort())}return t}(t);return r}(e),s=function(e,t){if(t)return e.dataset.xrefType?e.dataset.xrefType.split("|"):["_IDL_"];return["_CONCEPT_"]}(e,t),i=function(e,t){if(e.dataset.xrefFor)return Nr(e.dataset.xrefFor);if(t){const t=e.closest("[data-xref-for]");if(t)return Nr(t.dataset.xrefFor??"")}return null}(e,t);return{id:"",term:n,types:s,...r.length&&{specs:r},..."string"==typeof i&&{for:i}}}function Gl(e,{isIDL:t=!1}={}){const{lt:n}=e.dataset;let r=n?n.split("|",1)[0]:e.textContent;return r=Nr(r),"the-empty-string"===r?"":(t||n||(r=r.replace(yr,"")),r)}function Vl(e){return e.replace(/-\d+$/,"")}function Jl(e){return[...new Set(e.map(Vl)).difference(new Set(e))]}function Kl(e,t,n,r){const{term:s,specs:i=[]}=t,{uri:o,shortname:a,spec:c,normative:l,type:u,for:d}=n,p=i.flat().includes(c)?c:a,h=new URL(o,"https://partial");let{pathname:f}=h;"/"===f&&(f="");const m={cite:p,citePath:f,citeFrag:h.hash.slice(1),linkType:u};d&&(m.linkFor=d[0]),h.origin&&"https://partial"!==h.origin&&(m.citeHref=h.href),Object.assign(e.dataset,m),function(e,t,n,r,s){const i=function(e){const t=e.closest(".normative"),n=e.closest(Cr);return!n||e===t||t&&n&&n.contains(t)}(e);if(!i)return void(s.normativeReferences.has(t)||s.informativeReferences.add(t));if(n){const e=s.informativeReferences.has(t)?s.informativeReferences.getCanonicalKey(t)??t:t;return s.normativeReferences.add(e),void s.informativeReferences.delete(e)}Bl.push({term:r,spec:t,element:e})}(e,p,l,s,r)}function Zl(e){const t=JSON.stringify(e,Object.keys(e).sort()),n=(new TextEncoder).encode(t);return crypto.subtle.digest("SHA-1",n).then(Yl)}function Yl(e){const t=new Uint8Array(e);return t.toHex?.()??[...t].map((e=>e.toString(16).padStart(2,"0"))).join("")}function Xl(e){const t=e.querySelectorAll("a[data-xref-for], a[data-xref-type], a[data-link-for]"),n=["data-xref-for","data-xref-type","data-link-for"];t.forEach((e=>{n.forEach((t=>e.removeAttribute(t)))}))}var Ql=Object.freeze({__proto__:null,API_URL:Fl,getTermFromElement:Gl,informativeRefsInNormative:Bl,name:ql,run:async function(e){if(!e.xref)return;const t=function(e){const t={url:new URL("search/",Fl).href,specs:null},n=Object.assign({},t);switch(Array.isArray(e)?"array":typeof e){case"boolean":break;case"string":{const t=e;t.toLowerCase()in Wl?Object.assign(n,{specs:Wl[t.toLowerCase()]}):r(t);break}case"array":Object.assign(n,{specs:e});break;case"object":{const t=e;if(Object.assign(n,t),t.profile){const e=t.profile.toLowerCase();if(e in Wl){const r=(t.specs??[]).concat(Wl[e]);Object.assign(n,{specs:r})}else r(t.profile)}break}default:{const t=ls`Expected: \`true\`, a profile name (e.g. \`"web-platform"\`), an array of spec shortnames (e.g. \`["FETCH", "DOM"]\`), or an object with \`url\`, \`specs\`, or \`profile\` properties. See ${"[xref]"}.`;ns(`Invalid value for \`xref\` configuration option. Received: "${e}".`,ql,{hint:t})}}return n;function r(e){ns(`Invalid profile "${e}" in \`respecConfig.xref\`. Please use one of the supported profiles: ${Ar(Object.keys(Wl),(e=>`"${e}"`))}.`,ql)}}(e.xref);if(t.specs){const e=document.body.dataset.cite?document.body.dataset.cite.split(/\s+/):[];document.body.dataset.cite=e.concat(t.specs).join(" ")}const n=Rl.concat(function(){const e=document.querySelectorAll(":is(a,dfn)[data-cite]:not([data-cite=''],[data-cite*='#'])"),t=document.querySelectorAll("dfn.externalDFN");return[...e].filter((e=>{if(""===e.textContent.trim())return!1;const t=e.closest("[data-cite]");return!t||""!==t.dataset.cite})).concat(...t)}());if(!n.length)return;const r=[];for(const e of n){const t=Hl(e);t.id=await Zl(t),r.push(t)}const s=await async function(e,t){const n=new Set,r=e.filter((e=>!n.has(e.id)&&(n.add(e.id)&&!0))),s=await Ul(r),i=r.filter((e=>!s.get(e.id))),o=await async function(e,t){if(!e.length)return new Map;const n={method:"POST",body:JSON.stringify({queries:e}),headers:{"Content-Type":"application/json"}},r=await fetch(t,n),s=await r.json();return new Map(s.results.map((({id:e,result:t})=>[e,t])))}(i,t);o.size&&await async function(e,t){try{const n=(await Ml()).transaction(jl,"readwrite");for(const r of e){const e=t.get(r.id);e?.length&&n.objectStore(jl).add({query:r,result:e})}await n.done}catch(e){console.error(e)}}(r,o);return new Map([...s,...o])}(r,t.url);!function(e,t,n,r){const s={ambiguous:new Map,notFound:new Map};for(let i=0,o=e.length;i{const r=new URL(Fl);return r.searchParams.set("term",e),t.for&&r.searchParams.set("for",t.for),r.searchParams.set("types",t.types.join(",")),n.length&&r.searchParams.set("specs",n.join(",")),r.href},r=(e,t)=>ls`[See search matches for "${t}"](${e}) or ${"[Learn about this error|#error-term-not-found]"}.`;for(const{query:e,elems:s}of t.values()){const t=e.specs?[...new Set(e.specs.flat())].sort():[],i=Gl(s[0]),o=n(i,e),a=Lr(t,(e=>`**[${e}]**`));let c=r(o,i);const l=s[0].parentElement?.closest("[data-cite]")??null,u=l?.dataset.cite?.replace(/`/g,"")??"";l&&l!==document.body&&u&&(c+=` A parent element has \`data-cite="${u}"\` — check that the spec shortname is correct.`);ns(`Couldn't find "**${i}**"${e.for?`, for **"${e.for}"**, `:""} in this document or other cited documents: ${a}.`,ql,{title:"No matching definition found.",elements:s,hint:c})}for(const{query:t,elems:s,results:i}of e.values()){const e=[...new Set(i.map((e=>e.shortname)))].sort(),o=Lr(e,(e=>`**[${e}]**`)),a=Gl(s[0]),c=n(a,t,e),l=t.for?`, for **"${t.for}"**, `:"",u=r(c,a),d=ls`To fix, use the ${"[data-cite]"} attribute to pick the one you mean from the appropriate specification.`+String.raw` ${u}`;ns(`The term "**${a}**"${l} is ambiguous because it's defined in ${o}.`,ql,{title:"Definition is ambiguous.",elements:s,hint:d})}}(s)}(n,r,s,e),hs("beforesave",Xl)}});const eu="headings",tu=864e5;async function nu(){return await ir.openDB("respec-headings",1,{upgrade(e){[...e.objectStoreNames].forEach((t=>e.deleteObjectStore(t))),e.createObjectStore(eu)}})}async function ru(e){const t=new Map;if(function(){const e=parseInt(localStorage.getItem("HEADINGS:LAST_CACHED")??"",10);return!isNaN(e)&&Date.now()-e>tu}())return await async function(){try{const e=await nu();await e.clear(eu),localStorage.removeItem("HEADINGS:LAST_CACHED")}catch(e){console.error(e)}}(),t;try{const n=(await nu()).transaction(eu);for(const r of e){const e=`${r.spec}#${r.id}`,s=await n.store.get(e);s&&t.set(e,s.result)}}catch(e){console.error(e)}return t}const su="core/xref-headings",iu="https://respec.org/xref/search/headings";async function ou(e,t=iu){if(!e.length)return new Map;const n=await ru(e),r=e.filter((e=>!n.has(`${e.spec}#${e.id}`)));if(!r.length)return n;try{const e=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({queries:r})});if(!e.ok){const t=`Failed to fetch heading texts (HTTP ${e.status}).`;return rs(t,su,{hint:"Cross-spec section links will fall back to spec titles."}),n}const{result:s=[]}=await e.json(),i=new Map(s.filter((e=>!e.error)).map((e=>[`${e.spec}#${e.id}`,{title:e.title,number:e.number||null}])));return await async function(e,t){try{const n=(await nu()).transaction(eu,"readwrite");for(const r of e){const e=`${r.spec}#${r.id}`,s=t.get(e);s&&n.objectStore(eu).put({query:r,result:s},e)}await n.done,localStorage.setItem("HEADINGS:LAST_CACHED",Date.now().toString())}catch(e){console.error(e)}}(r,i),new Map([...n,...i])}catch{return rs("Failed to fetch heading texts from respec.org.",su,{hint:"Cross-spec section links will fall back to spec titles."}),n}}function au(e,{title:t,number:n}){n?e.append(sr`${n} `,t):e.textContent=t}var cu=Object.freeze({__proto__:null,HEADINGS_API_URL:iu,fetchHeadingTexts:ou,name:su,run:async function(e){const t=document.querySelectorAll("a[data-cite-frag][data-matched-text]");if(!t.length)return;const n=function(e){const t="object"!=typeof e.xref||null===e.xref||Array.isArray(e.xref)?{}:e.xref;return"string"==typeof t.headingApiUrl?t.headingApiUrl:iu}(e),r=new Map,s=[];if(t.forEach((e=>{if(e.dataset.lt)e.textContent=e.dataset.lt,delete e.dataset.lt;else{const t=(e.dataset.cite??"").replace(/^[!?]/,""),n=e.dataset.citeFrag??"",i=`${t}#${n}`;s.push({elem:e,key:i}),r.has(i)||r.set(i,{spec:t,id:n})}})),!s.length)return;const i=await ou([...r.values()],n);s.forEach((({elem:e,key:t})=>{const n=i.get(t);n?.title&&(e.textContent="",au(e,n))}))},setHeadingContent:au});var lu=String.raw`ul.index{columns:30ch;column-gap:1.5em}
+ >`}}switch(r.type){case"text":return fl`${Pr(i)}`;case"number":case"float":return fl`${Pr(i)}`;case"bytes":case"hex":case"base64":return fl`${Pr(i)}`;default:return Pr(i)}}#i(e){const t=e.parentNode;return!!t&&t instanceof gr}serializeToken(e,t){const n=e.type,r=e.serialize();switch(n){case"COMMENT":return this.#o(r);case"CTLOP":return this.#a(r);case"=":case"/=":case"//=":case"/":case"//":case"=>":case"..":case"...":return this.#c(r);case"?":case"*":case"+":return t instanceof br?this.#l(r):r;default:return r}}#o(e){return e.replace(/(;[^\n]*)/g,'$1')}#a(e){return e.replace(/(\.\w+)/g,'$1')}#c(e){const t=e.match(/^(\s*)(.*?)(\s*)$/s);return t?`${t[1]}${t[2]}${t[3]}`:fl`${e}`}#l(e){const t=e.match(/^(\s*)(.*?)(\s*)$/s);return t?`${t[1]}${t[2]}${t[3]}`:fl`${e}`}}var gl=Object.freeze({__proto__:null,name:ul,run:async function(){const e=document.querySelectorAll("pre.cddl:not([data-no-cddl])");if(!e.length)return;const t=document.createElement("style");t.textContent=ll;const n=document.querySelector("head link, head > *:last-child");n?n.before(t):document.head.append(t);const r=e=>new ur(e).parse(),s={definitions:new Map,proseDfns:new Map,genericParams:new Map};var i,o,a,c;i=document,o=s.proseDfns,i.querySelectorAll(["dfn[data-dfn-type='cddl-type']","dfn[data-dfn-type='cddl-key']","dfn[data-dfn-type='cddl-value']"].join(", ")).forEach((e=>{const t=e.dataset.dfnType,n=e.dataset.dfnFor,r=e.textContent.trim(),s=n?`${pl(n)}-`:"",i=`cddl-${t.replace("cddl-","")}-${s}${pl(r)}`;e.id||=i,o.set(i,e.id),pc(e,[r])})),e.forEach((e=>function(e,t,n){const r=e.textContent;if(r.trim())try{const s=t(r),i=new ml(n),o=s.serialize(i),a=document.createElement("code");a.innerHTML=o,e.textContent="",e.append(a),e.classList.add("def","highlight"),qr(e,"cddl-block");const c=document.createElement("span");c.className="cddlHeader",c.innerHTML=`CDDL`;const l=Gc(".cddlHeader");c.append(l),e.prepend(c)}catch(t){ns(`CDDL processing error: ${t instanceof Error?t.message:String(t)}`,ul,{elements:[e],hint:'Check the CDDL syntax in the `` block.'})}}(e,r,s))),a=document.body,c=s.definitions,a.querySelectorAll("[data-cddl-pending]").forEach((e=>{const t=`cddl-type:${e.dataset.cddlPending}`;if(c.has(t)){const n=c.get(t);if(!n)return;const r=a.ownerDocument.createElement("a");r.href=`#${n.id}`,r.className="cddl-name",r.dataset.linkType="cddl-type",r.textContent=e.textContent,e.replaceWith(r)}})),document.querySelectorAll("[data-cddl-pending]").forEach((e=>{rs(`No CDDL definition found for \`${e.getAttribute("data-cddl-pending")}\`.`,ul,{elements:[e],hint:"Check for typos in the type name."})})),function(e,t){e.querySelectorAll('a[data-link-type^="cddl-"]:not([href]):not([data-cite])').forEach((e=>{const n=e.getAttribute("data-link-type"),r=e.getAttribute("data-xref-for")||e.getAttribute("data-link-for")||"",s=e.textContent.trim();if("cddl-type"!==n&&"cddl-key"!==n&&"cddl-value"!==n)return;const i={"cddl-type":`cddl-type:${s}`,"cddl-key":`cddl-key:${r}/${s}`,"cddl-value":`cddl-value:${r}/${s}`}[n];if(t.has(i)){const n=t.get(i);if(!n)return;e.setAttribute("href",`#${n.id}`),e.classList.add("internalDFN")}else rs(`CDDL ${n}: no definition found for \`${s}\`${r?`, for \`${r}\`,`:""} in any \`\` block.`,ul,{elements:[e]}),e.setAttribute("data-no-link-to-dfn","")}))}(document,s.definitions),function(e,t){t.forEach((t=>{const n=e.getElementById(t.id);"dfn"===n?.localName&&pc(n,[n.textContent.trim()])}))}(document,s.definitions),Vc(),hs("beforesave",(e=>{e.querySelectorAll("[data-cddl-pending]").forEach((e=>e.removeAttribute("data-cddl-pending")))}))}});const bl="core/data-cite",yl="__SPEC__";async function wl(e){const{key:t,frag:n,path:r,href:s}=e;let i="",o="";if(t===yl)i=document.location.href;else{const e=await ka(t);if(!e)return null;i=e.href??"",o=e.title}if(s)i=s;else{if(r){const e=r.startsWith("/")?`.${r}`:r;i=new URL(e,i).href}n&&(i=new URL(n,i).href)}return{href:i,title:o}}function vl(e,t,n){const{href:r,title:s}=t,i=!n.path&&!n.frag;switch(e.localName){case"a":{const t=e;if(""===t.textContent&&"the-empty-string"!==t.dataset.lt&&(t.textContent=s),t.href=r,i){const e=document.createElement("cite");t.replaceWith(e),e.append(t)}break}case"dfn":{const t=document.createElement("a");if(t.href=r,t.dataset.cite=n.key,t.dataset.citePath=n.path,t.dataset.citeFrag=n.frag,e.textContent?Vr(e,t):(t.textContent=s,e.append(t)),i){const n=document.createElement("cite");n.append(t),e.append(n)}if("export"in e.dataset){ns("Exporting a linked external definition is not allowed.",bl,{hint:"Please remove the `data-export` attribute.",elements:[e]}),delete e.dataset.export}e.classList.add("externalDFN"),e.dataset.noExport="";break}}}function kl(e){return t=>{const n=t.search(e);return-1!==n?t.substring(n):""}}const $l=kl("#"),xl=kl("/");function Cl(e){const{dataset:t}=e,{cite:n,citeFrag:r,citePath:s,citeHref:i}=t;if((n??"").startsWith("#")&&!r){const r=e.parentElement?.closest('[data-cite]:not([data-cite^="#"])')??null,{key:s,isNormative:i}=r?Cl(r):{key:yl,isNormative:!1};return t.cite=i?s:`?${s}`,t.citeFrag=(n??"").replace("#",""),Cl(e)}const o=r?`#${r}`:$l(n??""),a=s||xl(n??"").split("#")[0],{type:c}=Gr(n??"",e),l="normative"===c,u=/^[?|!]/.test(n??"");return{key:(n??"").split(/[/|#]/)[0].substring(Number(u)),isNormative:l,frag:o,path:a,href:i}}function Sl(e){const t=["data-cite","data-cite-frag","data-cite-path"];e.querySelectorAll("a[data-cite], dfn[data-cite]").forEach((e=>t.forEach((t=>e.removeAttribute(t)))))}var _l=Object.freeze({__proto__:null,THIS_SPEC:yl,name:bl,run:async function(){const e=document.querySelectorAll("dfn[data-cite]:not([data-cite='']), a[data-cite]:not([data-cite=''])");await async function(e){const t=e.map(Cl).map((async e=>({entry:e,result:await ka(e.key)}))),n=(await Promise.all(t)).filter((({result:e})=>null===e)).map((({entry:{key:e}})=>e)),r=await va(n);r&&Object.assign(ma,r)}([...e]);const t=new Map,n=new Map;for(const r of e){t.set(r,r.dataset.cite);const e=Cl(r);n.set(r,e)}for(const r of e){const e=t.get(r),s=n.get(r),i=await wl(s);if(i)r.dataset.citeFrag&&r.dataset.matchedText||!r.dataset.lt||"the-empty-string"===r.dataset.lt||""!==r.textContent||(r.textContent=r.dataset.lt,delete r.dataset.lt),vl(r,i,s);else{const t=`Couldn't find a match for "${e}"`;r.dataset.matchedText&&(r.textContent=r.dataset.matchedText),rs(t,bl,{elements:[r]})}}hs("beforesave",Sl)},toCiteDetails:Cl});const Tl="core/link-to-dfn",Rl=[],El={en:{duplicateMsg:e=>`Duplicate definition(s) of '${e}'`,duplicateTitle:"This is defined more than once in the document."},ja:{duplicateMsg:e=>`'${e}' の重複定義`,duplicateTitle:"この文書内で複数回定義されています."},de:{duplicateMsg:e=>`Mehrfache Definition von '${e}'`,duplicateTitle:"Das Dokument enthält mehrere Definitionen dieses Eintrags."},zh:{duplicateMsg:e=>`'${e}' 的重复定义`,duplicateTitle:"在文档中有重复的定义。"},cs:{duplicateMsg:e=>`Duplicitní definice '${e}'`,duplicateTitle:"Toto je v dokumentu definováno vícekrát."}},Ll=Ir(El);function Al(e){const t=new Map,n=[];for(const r of dc.get(e)??[]){const{dfnType:s="dfn"}=r.dataset,i=r.dataset.dfnFor?.split(",").map((e=>e.trim()))??[""];for(const o of i){if(t.has(o)&&t.get(o)?.has(s)){const e=t.get(o)?.get(s),i="dfn"===e?.localName,a="dfn"===r.localName,c=s===(e?.dataset.dfnType||"dfn"),l=!o&&!e?.dataset.dfnFor||e?.dataset.dfnFor?.split(",").map((e=>e.trim())).includes(o);if(i&&a&&c&&l){n.push(r);continue}}t.has(o)||t.set(o,new Map),t.get(o)?.set(s,r),("idl"in r.dataset||"dfn"!==s)&&t.get(o)?.set("idl",r),Fr(r,"dfn",e)}}return{result:t,duplicates:n}}function Pl(e,t){const n=function(e){const t=e.closest("[data-link-for]"),n=t?t.dataset.linkFor??"":"",r=Br(e).reduce(((e,r)=>{const s=r.split(".");2===s.length&&e.push({for:s[0],title:s[1]}),e.push({for:n,title:r}),t||e.push({for:r,title:r}),""!==n&&e.push({for:"",title:r});const i=r.replace(yr,"");return i!==r&&""!==i&&(e.push({for:n,title:i}),t||e.push({for:i,title:i}),""!==n&&e.push({for:"",title:i})),e}),[]);return r}(e),r=n.find((e=>t.has(e.title)&&t.get(e.title)?.has(e.for)));if(!r)return;const s=t.get(r.title)?.get(r.for),{linkType:i}=e.dataset;if(i){for(const e of i.split("|"))if(s?.get(e))return s.get(e);return s?.get("dfn")}{const e=r.for?"idl":"dfn";return s?.get(e)||s?.get("idl")}}function Nl(e,t,n){let r=!1;const{linkFor:s}=e.dataset,{dfnFor:i}=t.dataset;if(t.dataset.cite)e.dataset.cite=t.dataset.cite;else if(s&&!n.get(s)&&i&&!i.split(",").map((e=>e.trim())).includes(s))r=!0;else if(t.classList.contains("externalDFN")){const n=t.dataset.lt?t.dataset.lt.split("|"):[];e.dataset.lt=n[0]||t.textContent,r=!0}else"partial"!==e.dataset.idl?(e.href=`#${t.id}`,e.classList.add("internalDFN")):r=!0;return e.hasAttribute("data-link-type")||(e.dataset.linkType="idl"in t.dataset?"idl":"dfn"),function(e){if(e.closest("code,pre"))return!0;if(1!==e.childNodes.length)return!1;const[t]=e.childNodes;return"code"===t.localName}(t)&&function(e,t){const n=e.textContent.trim(),r=t.dataset.hasOwnProperty("idl"),s=Il(e)&&Il(t,n);r&&!s||Vr(e,document.createElement("code"))}(e,t),!r}function Il(e,t=""){if("a"===e.localName){if(!e.querySelector("code"))return!0}else{const{dataset:n}=e;if(e.textContent.trim()===t)return!0;if(n.title===t)return!0;if(n.lt||n.localLt){const e=[];return n.lt&&e.push(...n.lt.split("|")),n.localLt&&e.push(...n.localLt.split("|")),e.includes(t)}}return!1}function Dl(e){e.forEach((e=>{const t=`Found linkless \`\` element with text "${e.textContent}" but no matching \`\``,n=e.closest("[data-link-for]"),r=`Add a matching \`\` element, ${ls`use ${"[data-cite]"} to link to an external definition, or enable ${"[xref]"} for automatic cross-spec linking.`}${n?` This link is inside a \`data-link-for="${n.dataset.linkFor}"\` section — \`[=term=]\` links are scoped to that context. To link to a global concept instead, either add \`data-link-for=""\` on this \`\` or move it outside the scoped section.`:""}`;rs(t,Tl,{title:"Linking error: no matching ``",hint:r,elements:[e]})}))}var Ol=Object.freeze({__proto__:null,name:Tl,possibleExternalLinks:Rl,run:async function(e){const t=function(){const e=new es;for(const t of dc.keys()){const{result:n,duplicates:r}=Al(t);e.set(t,n),r.length>0&&ns(Ll.duplicateMsg(t),Tl,{title:Ll.duplicateTitle,elements:r})}return e}(),n=[],r=document.querySelectorAll("a[data-cite='']:not([data-no-link-to-dfn]), a:not([href]):not([data-cite]):not([data-no-link-to-dfn]):not(.logo):not(.externalDFN)");for(const e of r){if(!e.dataset?.linkType&&e.dataset?.xrefType){Rl.push(e);continue}const r=Pl(e,t);if(r){Nl(e,r,t)||Rl.push(e)}else""===e.dataset.cite?n.push(e):Rl.push(e)}Dl(n),function(e){const{shortName:t=""}=e,n=t?new RegExp(String.raw`^([?!])?${vr(t)}\b([^-])`,"i"):null,r=document.querySelectorAll("dfn[data-cite]:not([data-cite='']), a[data-cite]:not([data-cite=''])");for(const t of r){n&&(t.dataset.cite=(t.dataset.cite??"").replace(n,`$1${yl}$2`));const{key:r,isNormative:s}=Cl(t);r!==yl&&(s||e.normativeReferences.has(r)?(e.normativeReferences.add(r),e.informativeReferences.delete(r)):e.informativeReferences.add(r))}}(e),e.xref||Dl(Rl)}});const jl="xrefs",zl=3e5;async function Ml(){return await ir.openDB("xref",2,{upgrade(e){[...e.objectStoreNames].forEach((t=>e.deleteObjectStore(t)));e.createObjectStore(jl,{keyPath:"query.id"}).createIndex("byTerm","query.term",{unique:!1})}})}async function Ul(e){const t=new Map;if(await async function(){const e="XREF:LAST_VERSION_CHECK",t=parseInt(localStorage.getItem(e)??"",10),n=Date.now();if(!t)return localStorage.setItem(e,n.toString()),!1;if(n-tt}())return await async function(){try{await Ml().then((e=>e.clear(jl)))}catch(e){console.error(e)}}(),t;const n=new Set(e.map((e=>e.id)));try{const e=await Ml();let r=await e.transaction(jl).store.openCursor();for(;r;)n.has(r.key)&&t.set(r.key,r.value.result),r=await r.continue()}catch(e){console.error(e)}return t}const ql="core/xref",Wl={"web-platform":["HTML","INFRA","URL","WEBIDL","DOM","FETCH"]},Fl="https://respec.org/xref/",Bl=[];if(!document.querySelector("link[rel='preconnect'][href='https://respec.org']")){const e=Sr({hint:"preconnect",href:"https://respec.org"});document.head.appendChild(e)}function Hl(e){const t="xrefType"in e.dataset;let n=Gl(e,{isIDL:t});t||(n=n.toLowerCase());const r=function(e){const t=[];let n=e.closest("[data-cite]");for(;n;){const r=(n.dataset.cite??"").toLowerCase().replace(/[!?]/g,"").split(/\s+/).filter((e=>e));if(r.length){t.push(r);const e=Jl(r);e.length&&t.push(e)}if(n===e)break;n=n.parentElement?.closest("[data-cite]")??null}if(n!==e){const n=e.closest("section"),r=n?n.querySelectorAll("a.bibref"):[],s=[...new Set([...r].map((e=>e.textContent.toLowerCase())))];if(s.length){t.push(s);const e=Jl(s);e.length&&t.push(e)}}const r=function(e){const t=[],n=new Set;for(const r of e){const e=[...new Set(r).values().filter((e=>!n.has(e)))];e.forEach((e=>n.add(e))),t.push(e.sort())}return t}(t);return r}(e),s=function(e,t){if(t)return e.dataset.xrefType?e.dataset.xrefType.split("|"):["_IDL_"];return["_CONCEPT_"]}(e,t),i=function(e,t){if(e.dataset.xrefFor)return Nr(e.dataset.xrefFor);if(t){const t=e.closest("[data-xref-for]");if(t)return Nr(t.dataset.xrefFor??"")}return null}(e,t);return{id:"",term:n,types:s,...r.length&&{specs:r},..."string"==typeof i&&{for:i}}}function Gl(e,{isIDL:t=!1}={}){const{lt:n}=e.dataset;let r=n?n.split("|",1)[0]:e.textContent;return r=Nr(r),"the-empty-string"===r?"":(t||n||(r=r.replace(yr,"")),r)}function Vl(e){return e.replace(/-\d+$/,"")}function Jl(e){return[...new Set(e.map(Vl)).difference(new Set(e))]}function Kl(e,t,n,r){const{term:s,specs:i=[]}=t,{uri:o,shortname:a,spec:c,normative:l,type:u,for:d}=n,p=i.flat().includes(c)?c:a,h=new URL(o,"https://partial");let{pathname:f}=h;"/"===f&&(f="");const m={cite:p,citePath:f,citeFrag:h.hash.slice(1),linkType:u};d&&(m.linkFor=d[0]),h.origin&&"https://partial"!==h.origin&&(m.citeHref=h.href),Object.assign(e.dataset,m),function(e,t,n,r,s){const i=function(e){const t=e.closest(".normative"),n=e.closest(Cr);return!n||e===t||t&&n&&n.contains(t)}(e);if(!i)return void(s.normativeReferences.has(t)||s.informativeReferences.add(t));if(n){const e=s.informativeReferences.has(t)?s.informativeReferences.getCanonicalKey(t)??t:t;return s.normativeReferences.add(e),void s.informativeReferences.delete(e)}Bl.push({term:r,spec:t,element:e})}(e,p,l,s,r)}function Zl(e){const t=JSON.stringify(e,Object.keys(e).sort()),n=(new TextEncoder).encode(t);return crypto.subtle.digest("SHA-1",n).then(Yl)}function Yl(e){const t=new Uint8Array(e);return t.toHex?.()??[...t].map((e=>e.toString(16).padStart(2,"0"))).join("")}function Xl(e){const t=e.querySelectorAll("a[data-xref-for], a[data-xref-type], a[data-link-for]"),n=["data-xref-for","data-xref-type","data-link-for"];t.forEach((e=>{n.forEach((t=>e.removeAttribute(t)))}))}var Ql=Object.freeze({__proto__:null,API_URL:Fl,getTermFromElement:Gl,informativeRefsInNormative:Bl,name:ql,run:async function(e){if(!e.xref)return;const t=function(e){const t={url:new URL("search/",Fl).href,specs:null},n=Object.assign({},t);switch(Array.isArray(e)?"array":typeof e){case"boolean":break;case"string":{const t=e;t.toLowerCase()in Wl?Object.assign(n,{specs:Wl[t.toLowerCase()]}):r(t);break}case"array":Object.assign(n,{specs:e});break;case"object":{const t=e;if(Object.assign(n,t),t.profile){const e=t.profile.toLowerCase();if(e in Wl){const r=(t.specs??[]).concat(Wl[e]);Object.assign(n,{specs:r})}else r(t.profile)}break}default:{const t=ls`Expected: \`true\`, a profile name (e.g. \`"web-platform"\`), an array of spec shortnames (e.g. \`["FETCH", "DOM"]\`), or an object with \`url\`, \`specs\`, or \`profile\` properties. See ${"[xref]"}.`;ns(`Invalid value for \`xref\` configuration option. Received: "${e}".`,ql,{hint:t})}}return n;function r(e){ns(`Invalid profile "${e}" in \`respecConfig.xref\`. Please use one of the supported profiles: ${Ar(Object.keys(Wl),(e=>`"${e}"`))}.`,ql)}}(e.xref);if(t.specs){const e=document.body.dataset.cite?document.body.dataset.cite.split(/\s+/):[];document.body.dataset.cite=e.concat(t.specs).join(" ")}const n=Rl.concat(function(){const e=document.querySelectorAll(":is(a,dfn)[data-cite]:not([data-cite=''],[data-cite*='#'])"),t=document.querySelectorAll("dfn.externalDFN");return[...e].filter((e=>{if(""===e.textContent.trim())return!1;const t=e.closest("[data-cite]");return!t||""!==t.dataset.cite})).concat(...t)}());if(!n.length)return;const r=[];for(const e of n){const t=Hl(e);t.id=await Zl(t),r.push(t)}const s=await async function(e,t){const n=new Set,r=e.filter((e=>!n.has(e.id)&&(n.add(e.id)&&!0))),s=await Ul(r),i=r.filter((e=>!s.get(e.id))),o=await async function(e,t){if(!e.length)return new Map;const n={method:"POST",body:JSON.stringify({queries:e}),headers:{"Content-Type":"application/json"}},r=await fetch(t,n),s=await r.json();return new Map(s.results.map((({id:e,result:t})=>[e,t])))}(i,t);o.size&&await async function(e,t){try{const n=(await Ml()).transaction(jl,"readwrite");for(const r of e){const e=t.get(r.id);e?.length&&n.objectStore(jl).add({query:r,result:e})}await n.done}catch(e){console.error(e)}}(r,o);return new Map([...s,...o])}(r,t.url);!function(e,t,n,r){const s={ambiguous:new Map,notFound:new Map};for(let i=0,o=e.length;i{const r=new URL(Fl);return r.searchParams.set("term",e),t.for&&r.searchParams.set("for",t.for),r.searchParams.set("types",t.types.join(",")),n.length&&r.searchParams.set("specs",n.join(",")),r.href},r=(e,t)=>ls`[See search matches for "${t}"](${e}) or ${"[Learn about this error|#error-term-not-found]"}.`;for(const{query:e,elems:s}of t.values()){const t=e.specs?[...new Set(e.specs.flat())].sort():[],i=Gl(s[0]),o=n(i,e),a=Lr(t,(e=>`**[${e}]**`));let c=r(o,i);const l=s[0].parentElement?.closest("[data-cite]")??null,u=l?.dataset.cite?.replace(/`/g,"")??"";l&&l!==document.body&&u&&(c+=` A parent element has \`data-cite="${u}"\` — check that the spec shortname is correct.`);ns(`Couldn't find "**${i}**"${e.for?`, for **"${e.for}"**, `:""} in this document or other cited documents: ${a}.`,ql,{title:"No matching definition found.",elements:s,hint:c})}for(const{query:t,elems:s,results:i}of e.values()){const e=[...new Set(i.map((e=>e.shortname)))].sort(),o=Lr(e,(e=>`**[${e}]**`)),a=Gl(s[0]),c=n(a,t,e),l=t.for?`, for **"${t.for}"**, `:"",u=r(c,a),d=ls`To fix, use the ${"[data-cite]"} attribute to pick the one you mean from the appropriate specification.`+String.raw` ${u}`;ns(`The term "**${a}**"${l} is ambiguous because it's defined in ${o}.`,ql,{title:"Definition is ambiguous.",elements:s,hint:d})}}(s)}(n,r,s,e),hs("beforesave",Xl)}});const eu="headings",tu=864e5;async function nu(){return await ir.openDB("respec-headings",1,{upgrade(e){[...e.objectStoreNames].forEach((t=>e.deleteObjectStore(t))),e.createObjectStore(eu)}})}async function ru(e){const t=new Map;if(function(){const e=parseInt(localStorage.getItem("HEADINGS:LAST_CACHED")??"",10);return!isNaN(e)&&Date.now()-e>tu}())return await async function(){try{const e=await nu();await e.clear(eu),localStorage.removeItem("HEADINGS:LAST_CACHED")}catch(e){console.error(e)}}(),t;try{const n=(await nu()).transaction(eu);for(const r of e){const e=`${r.spec}#${r.id}`,s=await n.store.get(e);s&&t.set(e,s.result)}}catch(e){console.error(e)}return t}const su="core/xref-headings",iu="https://respec.org/xref/search/headings";async function ou(e,t=iu){if(!e.length)return new Map;const n=await ru(e),r=e.filter((e=>!n.has(`${e.spec}#${e.id}`)));if(!r.length)return n;try{const e=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({queries:r})});if(!e.ok){const t=`Failed to fetch heading texts (HTTP ${e.status}).`;return rs(t,su,{hint:"Cross-spec section links will fall back to spec titles."}),n}const{result:s=[]}=await e.json(),i=new Map(s.filter((e=>!e.error)).map((e=>[`${e.spec}#${e.id}`,{title:e.title,number:e.number||null}])));return await async function(e,t){try{const n=(await nu()).transaction(eu,"readwrite");for(const r of e){const e=`${r.spec}#${r.id}`,s=t.get(e);s&&n.objectStore(eu).put({query:r,result:s},e)}await n.done,localStorage.setItem("HEADINGS:LAST_CACHED",Date.now().toString())}catch(e){console.error(e)}}(r,i),new Map([...n,...i])}catch{return rs("Failed to fetch heading texts from respec.org.",su,{hint:"Cross-spec section links will fall back to spec titles."}),n}}function au(e,{title:t,number:n}){n?e.append(sr`${n} `,t):e.textContent=t}var cu=Object.freeze({__proto__:null,HEADINGS_API_URL:iu,fetchHeadingTexts:ou,name:su,run:async function(e){const t=document.querySelectorAll("a[data-cite-frag][data-matched-text]");if(!t.length)return;const n=function(e){const t="object"!=typeof e.xref||null===e.xref||Array.isArray(e.xref)?{}:e.xref;return"string"==typeof t.headingApiUrl?t.headingApiUrl:iu}(e),r=new Map,s=[];if(t.forEach((e=>{if(e.dataset.lt)e.textContent=e.dataset.lt,delete e.dataset.lt;else{const t=(e.dataset.cite??"").replace(/^[!?]/,""),n=e.dataset.citeFrag??"",i=`${t}#${n}`;s.push({elem:e,key:i}),r.has(i)||r.set(i,{spec:t,id:n})}})),!s.length)return;const i=await ou([...r.values()],n);s.forEach((({elem:e,key:t})=>{const n=i.get(t);n?.title&&(e.textContent="",au(e,n))}))},setHeadingContent:au});var lu=String.raw`ul.index{columns:30ch;column-gap:1.5em}
ul.index li{list-style:inherit}
ul.index li span{color:inherit;cursor:pointer;white-space:normal}
#index-defined-here ul.index li{font-size:.9rem}
@@ -1500,5 +1503,5 @@ var[data-type]:hover::after,var[data-type]:hover::before{opacity:1}`;var up=Obje
* Přidejte atribut \`class=\"lint-ignore\"\` k odkazu.
* Použijte lokální normativní proxy pro definici, např. \`term\`
- Pro úplné potlačení tohoto varování nastavte \`lint: { \"${Th}\": false }\` ve vaší \`respecConfig\`.`}}});var Lh=Object.freeze({__proto__:null,name:Rh,run:function(e){if(!e.lint?.[Th])return;const t="error"===e.lint[Th]?ns:rs;Bl.forEach((({term:e,spec:n,element:r})=>{r.classList.contains("lint-ignore")||t(Eh.msg(e,n),Rh,{title:"Normative reference to non-normative term.",elements:[r],hint:Eh.hint})}))}}),Ah=Object.freeze({__proto__:null,default:'(() => {\n// @ts-check\n\nif (document.respec) {\n document.respec.ready.then(setupVarHighlighter);\n} else {\n setupVarHighlighter();\n}\n\nfunction setupVarHighlighter() {\n document\n .querySelectorAll("var")\n .forEach(varElem => varElem.addEventListener("click", highlightListener));\n}\n\n/**\n * @param {MouseEvent} ev\n */\nfunction highlightListener(ev) {\n ev.stopPropagation();\n const varElem = /** @type {HTMLElement} */ (ev.target);\n const hightligtedElems = highlightVars(varElem);\n const resetListener = () => {\n const hlColor = getHighlightColor(varElem);\n hightligtedElems.forEach(el => removeHighlight(el, hlColor));\n [...HL_COLORS.keys()].forEach(key => HL_COLORS.set(key, true));\n };\n if (hightligtedElems.length) {\n document.body.addEventListener("click", resetListener, { once: true });\n }\n}\n\n// availability of highlight colors. colors from var.css\nconst HL_COLORS = new Map([\n ["respec-hl-c1", true],\n ["respec-hl-c2", true],\n ["respec-hl-c3", true],\n ["respec-hl-c4", true],\n ["respec-hl-c5", true],\n ["respec-hl-c6", true],\n ["respec-hl-c7", true],\n]);\n\n/**\n * @param {HTMLElement} target\n */\nfunction getHighlightColor(target) {\n // return current colors if applicable\n const { value } = target.classList;\n const re = /respec-hl-\\w+/;\n const activeClass = re.test(value) && value.match(re);\n if (activeClass) return activeClass[0];\n\n // first color preference\n if (HL_COLORS.get("respec-hl-c1") === true) return "respec-hl-c1";\n\n // otherwise get some other available color\n return [...HL_COLORS.keys()].find(c => HL_COLORS.get(c)) || "respec-hl-c1";\n}\n\n/**\n * @param {HTMLElement} varElem\n */\nfunction highlightVars(varElem) {\n const textContent = norm(varElem.textContent);\n const parent = /** @type {HTMLElement} */ (\n varElem.closest(".algorithm, section")\n );\n if (!parent) return [];\n const highlightColor = getHighlightColor(varElem);\n\n const varsToHighlight = [...parent.querySelectorAll("var")].filter(\n el =>\n norm(el.textContent) === textContent &&\n el.closest(".algorithm, section") === parent\n );\n\n // update availability of highlight color\n const colorStatus = varsToHighlight[0].classList.contains("respec-hl");\n HL_COLORS.set(highlightColor, colorStatus);\n\n // highlight vars\n if (colorStatus) {\n varsToHighlight.forEach(el => removeHighlight(el, highlightColor));\n return [];\n } else {\n varsToHighlight.forEach(el => addHighlight(el, highlightColor));\n }\n return varsToHighlight;\n}\n\n/**\n * @param {HTMLElement} el\n * @param {string} highlightColor\n */\nfunction removeHighlight(el, highlightColor) {\n el.classList.remove("respec-hl", highlightColor);\n // clean up empty class attributes so they don\'t come in export\n if (!el.classList.length) el.removeAttribute("class");\n}\n\n/**\n * @param {HTMLElement} elem\n * @param {string} highlightColor\n */\nfunction addHighlight(elem, highlightColor) {\n elem.classList.add("respec-hl", highlightColor);\n}\n\n/**\n * Same as `norm` from src/core/utils, but our build process doesn\'t allow\n * imports in runtime scripts, so duplicated here.\n * @param {string} str\n */\nfunction norm(str) {\n return str.trim().replace(/\\s+/g, " ");\n}\n})()'}),Ph=Object.freeze({__proto__:null,default:'(() => {\n// @ts-check\nif (document.respec) {\n document.respec.ready.then(setupPanel);\n} else {\n setupPanel();\n}\n\nfunction setupPanel() {\n const listener = panelListener();\n document.body.addEventListener("keydown", listener);\n document.body.addEventListener("click", listener);\n}\n\nfunction panelListener() {\n /** @type {HTMLElement | null} */\n let panel = null;\n /**\n * @param {KeyboardEvent|MouseEvent} event\n */\n return event => {\n const { target, type } = event;\n\n if (!(target instanceof HTMLElement)) return;\n\n // For keys, we only care about Enter key to activate the panel\n // otherwise it\'s activated via a click.\n if (\n type === "keydown" &&\n /** @type {KeyboardEvent} */ (event).key !== "Enter"\n )\n return;\n\n const action = deriveAction(event);\n\n switch (action) {\n case "show": {\n hidePanel(panel);\n /** @type {HTMLElement | null} */\n const dfn = target.closest("dfn, .index-term");\n if (!dfn?.id) break;\n panel = document.getElementById(`dfn-panel-for-${dfn.id}`);\n if (!panel) break;\n const coords = deriveCoordinates(\n /** @type {MouseEvent|KeyboardEvent} */ (event)\n );\n displayPanel(dfn, panel, coords);\n break;\n }\n case "dock": {\n if (panel) {\n panel.style.left = "";\n panel.style.top = "";\n panel.classList.add("docked");\n }\n break;\n }\n case "hide": {\n hidePanel(panel);\n panel = null;\n break;\n }\n }\n };\n}\n\n/**\n * @param {MouseEvent|KeyboardEvent} event\n */\nfunction deriveCoordinates(event) {\n const target = /** @type HTMLElement */ (event.target);\n\n // We prevent synthetic AT clicks from putting\n // the dialog in a weird place. The AT events sometimes\n // lack coordinates, so they have clientX/Y = 0\n const rect = target.getBoundingClientRect();\n if (\n event instanceof MouseEvent &&\n event.clientX >= rect.left &&\n event.clientY >= rect.top\n ) {\n // The event probably happened inside the bounding rect...\n return { x: event.clientX, y: event.clientY };\n }\n\n // Offset to the middle of the element\n const x = rect.x + rect.width / 2;\n // Placed at the bottom of the element\n const y = rect.y + rect.height;\n return { x, y };\n}\n\n/**\n * @param {Event} event\n */\nfunction deriveAction(event) {\n const target = /** @type {HTMLElement} */ (event.target);\n const hitALink = !!target.closest("a");\n if (target.closest("dfn:not([data-cite]), .index-term")) {\n return hitALink ? "none" : "show";\n }\n if (target.closest(".dfn-panel")) {\n if (hitALink) {\n return target.classList.contains("self-link") ? "hide" : "dock";\n }\n\n const panel = /** @type {HTMLElement} */ (target.closest(".dfn-panel"));\n return panel.classList.contains("docked") ? "hide" : "none";\n }\n if (document.querySelector(".dfn-panel:not([hidden])")) {\n return "hide";\n }\n return "none";\n}\n\n/**\n * @param {HTMLElement} dfn\n * @param {HTMLElement} panel\n * @param {{ x: number, y: number }} clickPosition\n */\nfunction displayPanel(dfn, panel, { x, y }) {\n panel.hidden = false;\n // distance (px) between edge of panel and the pointing triangle (caret)\n const MARGIN = 20;\n\n const dfnRects = dfn.getClientRects();\n // Find the `top` offset when the `dfn` can be spread across multiple lines\n let closestTop = 0;\n let minDiff = Infinity;\n for (const rect of dfnRects) {\n const { top, bottom } = rect;\n const diffFromClickY = Math.abs((top + bottom) / 2 - y);\n if (diffFromClickY < minDiff) {\n minDiff = diffFromClickY;\n closestTop = top;\n }\n }\n\n const top = window.scrollY + closestTop + dfnRects[0].height;\n const left = x - MARGIN;\n panel.style.left = `${left}px`;\n panel.style.top = `${top}px`;\n\n // Find if the panel is flowing out of the window\n const panelRect = panel.getBoundingClientRect();\n const SCREEN_WIDTH = Math.min(window.innerWidth, window.screen.width);\n if (panelRect.right > SCREEN_WIDTH) {\n const newLeft = Math.max(MARGIN, x + MARGIN - panelRect.width);\n const newCaretOffset = left - newLeft;\n panel.style.left = `${newLeft}px`;\n /** @type {HTMLElement | null} */\n const caret = panel.querySelector(".caret");\n if (caret) caret.style.left = `${newCaretOffset}px`;\n }\n\n // As it\'s a dialog, we trap focus.\n // TODO: when