@commentray/render 0.0.6 → 0.0.8

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 (39) hide show
  1. package/dist/code-browser-client.bundle.js +10 -10
  2. package/dist/code-browser-client.js +747 -104
  3. package/dist/code-browser-client.js.map +1 -1
  4. package/dist/code-browser-color-theme.d.ts +15 -0
  5. package/dist/code-browser-color-theme.d.ts.map +1 -0
  6. package/dist/code-browser-color-theme.js +73 -0
  7. package/dist/code-browser-color-theme.js.map +1 -0
  8. package/dist/code-browser-pair-nav.d.ts +8 -0
  9. package/dist/code-browser-pair-nav.d.ts.map +1 -1
  10. package/dist/code-browser-pair-nav.js +20 -2
  11. package/dist/code-browser-pair-nav.js.map +1 -1
  12. package/dist/code-browser-scroll-sync.js +1 -1
  13. package/dist/code-browser-scroll-sync.js.map +1 -1
  14. package/dist/code-browser.d.ts +2 -2
  15. package/dist/code-browser.d.ts.map +1 -1
  16. package/dist/code-browser.js +903 -228
  17. package/dist/code-browser.js.map +1 -1
  18. package/dist/hljs-stylesheet-themes.d.ts +13 -0
  19. package/dist/hljs-stylesheet-themes.d.ts.map +1 -0
  20. package/dist/hljs-stylesheet-themes.js +19 -0
  21. package/dist/hljs-stylesheet-themes.js.map +1 -0
  22. package/dist/inline-favicon.d.ts +2 -0
  23. package/dist/inline-favicon.d.ts.map +1 -0
  24. package/dist/inline-favicon.js +25 -0
  25. package/dist/inline-favicon.js.map +1 -0
  26. package/dist/markdown-pipeline.d.ts.map +1 -1
  27. package/dist/markdown-pipeline.js +37 -2
  28. package/dist/markdown-pipeline.js.map +1 -1
  29. package/dist/mermaid-runtime-html.d.ts.map +1 -1
  30. package/dist/mermaid-runtime-html.js +10 -2
  31. package/dist/mermaid-runtime-html.js.map +1 -1
  32. package/dist/package-version.d.ts.map +1 -1
  33. package/dist/package-version.js +4 -4
  34. package/dist/package-version.js.map +1 -1
  35. package/dist/side-by-side-layout.css +58 -0
  36. package/dist/side-by-side.d.ts.map +1 -1
  37. package/dist/side-by-side.js +10 -12
  38. package/dist/side-by-side.js.map +1 -1
  39. package/package.json +2 -2
@@ -1,12 +1,12 @@
1
- "use strict";(()=>{var H=class{static ToInt32Array(e){let t=new Int32Array(e.length);for(let r=0,i=e.length;r<i;r++)t[r]=e[r];return t}},X=class{static getHashCode(e){let t=5381,r=t;for(let i=0,s=e.length;i<s&&e[i]!="\0"&&(t=(t<<5)+t^e.charCodeAt(i),i!==s-1&&e[i+1]!=="\0");i+=2)r=(r<<5)+r^e.charCodeAt(i+1);return t+1566083941*r|0}},y=class{constructor(e){this.entries=void 0,this.entries=e!==void 0?e:new Map}add(e,t){if(this.entries.has(e))throw new Error(`A meta entry with key ${e} is already present.`);this.entries.set(e,t)}get(e){return this.entries.get(e)}get allEntries(){return this.entries}toJSON(){return{entries:Object.fromEntries(this.entries)}}},q=class{static mergeMeta(e){if(e.length===0)return new y;if(e.length===1)return e[0];let t=new Map;for(let i of e)for(let[s,o]of i.allEntries){let a=t.get(s);a===void 0?t.set(s,[o]):a.push(o)}let r=new Map;for(let[i,s]of t)if(s.length!==1){if(s.every(o=>typeof o=="number")){let o=s.reduce((a,c)=>a+c,0);r.set(i,o);continue}for(let o=0;o<s.length;o++)r.set(`${i}_${o}`,s[o])}else r.set(i,s[0]);return new y(r)}},Z=class{static isSurrogate(e){let t=e.charCodeAt(0);return t>=55296&&t<=57343}static isAlphanumeric(e){let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122}static isLowerAlpha(e){let t=e.charCodeAt(0);return t>=97&&t<=122}},ee=class{constructor(e,t){this.usableSearchers=void 0,this.usableSearchers=new Map;for(let r of t)e.includes(r.type)&&this.usableSearchers.set(r.type,r)}has(e){return this.usableSearchers.has(e)}minQuality(e){return this.usableSearchers.get(e).minQuality}spec(e){return this.usableSearchers.get(e)}},A=class{constructor(e,t,r){this.matches=void 0,this.query=void 0,this.meta=void 0,this.matches=e,this.query=t,this.meta=r}},p,G;(function(n){n.Fuzzy="fuzzy",n.Substring="substring",n.Prefix="prefix"})(p||(p={}));var Q=class{constructor(e,t){this.type=void 0,this.minQuality=void 0,this.type=e,this.minQuality=Math.max(0,t)}},U=class extends Q{constructor(e){super(p.Fuzzy,e)}},D=class extends Q{constructor(e){super(p.Substring,e)}},F=class extends Q{constructor(e){super(p.Prefix,e)}},z=class{constructor(e,t=10,r=[new U(.3),new D(0),new F(0)]){this.string=void 0,this.topN=void 0,this.searchers=void 0,this.string=e,this.topN=Math.max(0,t),this.searchers=r}},pe=class{constructor(e,t){this.removedEntities=void 0,this.meta=void 0,this.removedEntities=e,this.meta=t}},ye=class{static mergeResults(e,t){let r=e.query,i=this.mergeMatches(e.matches,t.matches,r.topN),s=q.mergeMeta([e.meta,t.meta]);return new A(i,r,s)}static mergeMatches(e,t,r){if(t.length===0)return e;if(e.length===0)return t;let i=[...e,...t];return i.sort((s,o)=>s.quality>o.quality?-1:s.quality<o.quality?1:0),i.length<=r?i:i.slice(0,r)}},Se=class{constructor(e,t,r){this.maxQueryLength=void 0,this.mainSearcher=void 0,this.secondarySearcher=void 0,this.maxQueryLength=e,this.mainSearcher=t,this.secondarySearcher=r}indexEntities(e,t,r){return this.secondarySearcher.indexEntities([],t,r),this.mainSearcher.indexEntities(e,t,r)}getMatches(e){return e.string?(e.string.length>this.maxQueryLength&&(e=new z(e.string.substring(0,this.maxQueryLength),e.topN,e.searchers)),ye.mergeResults(this.mainSearcher.getMatches(e),this.secondarySearcher.getMatches(e))):new A([],e,new y)}tryGetTerms(e){let t=this.mainSearcher.tryGetTerms(e);return t!==null?t:this.secondarySearcher.tryGetTerms(e)}getTerms(){return this.mainSearcher.getTerms().concat(this.secondarySearcher.getTerms())}tryGetEntity(e){var t,r;return(t=(r=this.mainSearcher.tryGetEntity(e))!=null?r:this.secondarySearcher.tryGetEntity(e))!=null?t:null}getEntities(){return this.mainSearcher.getEntities().concat(this.secondarySearcher.getEntities())}removeEntities(e){let t=[];for(let i=0,s=e.length;i<s;i++)(this.mainSearcher.removeEntity(e[i])||this.secondarySearcher.removeEntity(e[i]))&&t.push(e[i]);let r=new y;return new pe(t,r)}upsertEntities(e,t,r){let i=[],s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],h=t(c);this.tryUpdate(c,h,r)||(i.push(h),s.push(c))}return this.removeEntities(i),s.length>0?this.reindexSecondarySearcher(s,t,r):new y}reindexSecondarySearcher(e,t,r){let i=this.secondarySearcher.getEntities().concat(e);return this.secondarySearcher.indexEntities(i,t,r)}tryUpdate(e,t,r){return this.tryUpdateSearcher(e,t,r,this.mainSearcher)||this.tryUpdateSearcher(e,t,r,this.secondarySearcher)}tryUpdateSearcher(e,t,r,i){let s=i.tryGetTerms(t);if(s===null)return!1;if(this.termsAreEqual(s,r(e))){if(!i.replaceEntity(t,e,t))throw new Error(`Entity with id ${t} was not present.`);return!0}return!1}termsAreEqual(e,t){return e===t||e!=null&&t!=null&&e.length===t.length&&e.every((r,i)=>r===t[i])}removeEntity(e){return this.mainSearcher.removeEntity(e)||this.secondarySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.mainSearcher.replaceEntity(e,t,r)||this.secondarySearcher.replaceEntity(e,t,r)}save(e){this.mainSearcher.save(e),this.secondarySearcher.save(e)}load(e){this.mainSearcher.load(e),this.secondarySearcher.load(e)}},we=class{constructor(e){this.dynamicSearcher=void 0,this.dynamicSearcher=e}removeEntities(e){let t=performance.now(),r=this.dynamicSearcher.removeEntities(e),i=Math.round(performance.now()-t);return r.meta.add("removalDuration",i),r}upsertEntities(e,t,r){let i=performance.now(),s=this.dynamicSearcher.upsertEntities(e,t,r),o=Math.round(performance.now()-i);return s.add("upsertDuration",o),s}indexEntities(e,t,r){let i=performance.now(),s=this.dynamicSearcher.indexEntities(e,t,r),o=Math.round(performance.now()-i);return s.add("indexingDurationTotal",o),s}getMatches(e){let t=performance.now(),r=this.dynamicSearcher.getMatches(e),i=Math.round(performance.now()-t);return r.meta.add("queryDuration",i),r}tryGetEntity(e){return this.dynamicSearcher.tryGetEntity(e)}getEntities(){return this.dynamicSearcher.getEntities()}tryGetTerms(e){return this.dynamicSearcher.tryGetTerms(e)}getTerms(){return this.dynamicSearcher.getTerms()}removeEntity(e){return this.dynamicSearcher.removeEntity(e)}replaceEntity(e,t,r){return this.dynamicSearcher.replaceEntity(e,t,r)}save(e){this.dynamicSearcher.save(e)}load(e){this.dynamicSearcher.load(e)}},be=class{constructor(e,t,r){this.entity=void 0,this.quality=void 0,this.matchedString=void 0,this.entity=e,this.quality=t,this.matchedString=r}},ve=class{constructor(e){this.query=void 0,this.matchedIndexes=new Set,this.matches=[],this.meta=[],this.query=e}},j=class{constructor(e,t=0,r){this.string=void 0,this.minQuality=void 0,this.searcherType=void 0,this.string=e,this.minQuality=Math.max(0,Math.min(1,t)),this.searcherType=r}},xe=class{constructor(e,t){this.stringSearcher=void 0,this.searcherTypes=void 0,this.entities=void 0,this.idToIndex=void 0,this.terms=void 0,this.termIndexToEntityIndex=void 0,this.entityIndexToFirstTermIndex=void 0,this.searchersAndQualityOffsets=[{searcherType:p.Prefix,qualityOffset:2},{searcherType:p.Substring,qualityOffset:1},{searcherType:p.Fuzzy,qualityOffset:0}],this.stringSearcher=e,this.searcherTypes=t,this.entities=[],this.idToIndex=new Map,this.terms=[],this.termIndexToEntityIndex=new Int32Array(0),this.entityIndexToFirstTermIndex=new Int32Array(0)}indexEntities(e,t,r){this.entities=[...e],this.idToIndex=new Map,this.terms=[];let i=[],s=[];for(let a=0,c=e.length;a<c;a++){this.idToIndex.set(t(e[a]),a);let h=r(e[a]);s.push(this.terms.length),this.terms.push(...h),i.push(...h.map(()=>a))}this.termIndexToEntityIndex=H.ToInt32Array(i),this.entityIndexToFirstTermIndex=H.ToInt32Array(s);let o=this.stringSearcher.index(this.terms);return o.add("numberOfEntities",this.entities.length),o.add("numberOfTerms",this.terms.length),o}getMatches(e){let t=new ve(e),r=new ee(this.searcherTypes,e.searchers);for(let{searcherType:s,qualityOffset:o}of this.searchersAndQualityOffsets){if(e.topN==t.matches.length)break;r.has(s)&&this.addMatchesFromSearcher(t,r.spec(s),o)}let i=q.mergeMeta(t.meta);return new A(t.matches,e,i)}addMatchesFromSearcher(e,t,r){let i=Math.max(0,t.minQuality-r);if(i>1)return;let s=new j(e.query.string,i,t.type),o=this.stringSearcher.getMatches(s);this.addMatchesFromResult(e,o,r)}addMatchesFromResult(e,t,r){if(e.meta.push(t.meta),e.query.topN!==0)for(let i=0,s=t.matches.length;i<s;i++){let o=t.matches[i],a=this.termIndexToEntityIndex[o.index];if(!e.matchedIndexes.has(a)&&this.entities[a]!==null&&(e.matchedIndexes.add(a),e.matches.push(new be(this.entities[a],o.quality+r,this.terms[o.index])),e.matches.length===e.query.topN))break}}tryGetEntity(e){let t=this.idToIndex.get(e);return t===void 0?null:this.entities[t]}getEntities(){return this.entities.filter(e=>e!==null)}tryGetTerms(e){let t=this.idToIndex.get(e);return t===void 0?null:this.terms.slice(this.entityIndexToFirstTermIndex[t],t===this.entities.length-1?this.terms.length:this.entityIndexToFirstTermIndex[t+1])}getTerms(){let e=[];for(let t=0,r=this.termIndexToEntityIndex.length;t<r;t++)this.entities[this.termIndexToEntityIndex[t]]!==null&&e.push(this.terms[t]);return e}removeEntity(e){let t=this.idToIndex.get(e);return t!==void 0&&(this.entities[t]=null,this.idToIndex.delete(e),!0)}replaceEntity(e,t,r){let i=this.idToIndex.get(e);return i!==void 0&&(this.entities[i]=t,this.idToIndex.delete(e),this.idToIndex.set(r,i),!0)}save(e){e.add(this.entities),e.add(this.idToIndex),e.add(this.terms),e.add(this.termIndexToEntityIndex),e.add(this.entityIndexToFirstTermIndex),this.stringSearcher.save(e)}load(e){this.entities=e.get(),this.idToIndex=e.get(),this.terms=e.get(),this.termIndexToEntityIndex=e.get(),this.entityIndexToFirstTermIndex=e.get(),this.stringSearcher.load(e)}},P=class{constructor(e,t){this.strings=void 0,this.meta=void 0,this.strings=e,this.meta=t}},Te=class{constructor(e,t){this.treatCharacterAsSpace=void 0,this.allowCharacter=void 0,this.numberOfSurrogateCharacters=0,this.treatCharacterAsSpace=e,this.allowCharacter=t}normalize(e){let t=new Array(e.length),r=0,i=!1,s=!1;for(let o=0,a=e.length;o<a;o++){let c=this.getNormalizedCharacter(e[o]);c!==""&&(c===" "?i=!0:(i&&s&&(t[r++]=" "),t[r++]=c,s=!0,i=!1))}return s?t.join(""):""}getNormalizedCharacter(e){return e===" "||this.treatCharacterAsSpace(e)?" ":this.isSurrogate(e)||!this.allowCharacter(e)?"":e.toLowerCase()}isSurrogate(e){return!!Z.isSurrogate(e)&&(this.numberOfSurrogateCharacters++,!0)}normalizeBulk(e){this.numberOfSurrogateCharacters=0;let t=e.map(i=>this.normalize(i)),r=new y;return r.add("numberOfSurrogateCharacters",this.numberOfSurrogateCharacters),new P(t,r)}},Ee=class{constructor(e){this.normalizationFunction=void 0,this.normalizationFunction=e}normalize(e){return this.normalizationFunction(e)}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new P(t,new y)}},Me=class{constructor(e){this.normalizers=void 0,this.normalizers=e}normalize(e){for(let t=0,r=this.normalizers.length;t<r;t++)e=this.normalizers[t].normalize(e);return e}normalizeBulk(e){let t=new y;for(let r=0,i=this.normalizers.length;r<i;r++){let s=this.normalizers[r].normalizeBulk(e);e=s.strings;for(let o of s.meta.allEntries)t.add(o[0],o[1])}return new P(e,t)}},Pe=class{normalize(e){return e||""}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new P(t,new y)}},Ce=class{constructor(e,t){this.normalizeVariationsAndInput=void 0,this.replacements=void 0,this.normalizeVariationsAndInput=t,this.replacements=[];for(let r of e){let i=new Map;for(let[s,o]of r)for(let a of o){let c=t(a);i.set(c,s)}this.replacements.push(i)}}normalize(e){e=this.normalizeVariationsAndInput(e);let t=new Array(e.length),r=0;for(let i=0,s=e.length;i<s;i++)for(let o of this.replacements){let a=o.get(e[i]);if(a!==void 0){t[r++]=a;break}t[r++]=e[i]}return t.join("")}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new P(t,new y)}},Le=class{static create(e){let t=new Pe,r=new Ce(e.replacements,o=>o.toLowerCase().normalize("NFKC")),i=new Ee(o=>o.normalize("NFKD")),s=new Te(e.treatCharacterAsSpace,e.allowCharacter);return new Me([t,r,i,s])}},_=class{constructor(e,t){this.index=void 0,this.quality=void 0,this.index=e,this.quality=t}},T=class{constructor(e,t,r){this.matches=void 0,this.query=void 0,this.meta=void 0,this.matches=e,this.query=t,this.meta=r}},Ie=class{constructor(e){this.stringSearcher=void 0,this.distinctMapping=void 0,this.sortMapping=void 0,this.stringSearcher=e,this.distinctMapping=new Int32Array(0),this.sortMapping=new Int32Array(0)}index(e){let t=e.map((c,h)=>({term:c,index:h}));t.sort((c,h)=>c.term<h.term?-1:c.term>h.term?1:0),this.sortMapping=new Int32Array(t.length);for(let c=0,h=t.length;c<h;c++)this.sortMapping[c]=t[c].index;let r=[],i=[],s=0,o=null;for(let c=0,h=t.length;c<h;c++){let l=t[c].term;l!=o&&(r[s]=l,i[s]=c,s++),o=l}i[s++]=t.length,this.distinctMapping=H.ToInt32Array(i);let a=this.stringSearcher.index(r);return a.add("numberOfDistinctTerms",r.length),a}getMatches(e){let t=this.stringSearcher.getMatches(e),r=new Array(t.matches.length),i=0;return t.matches.forEach(s=>{let o=this.distinctMapping[s.index+1];for(let a=this.distinctMapping[s.index];a<o;a++)r[i++]=new _(this.sortMapping[a],s.quality)}),new T(r,e,t.meta)}save(e){e.add(this.distinctMapping),e.add(this.sortMapping),this.stringSearcher.save(e)}load(e){this.distinctMapping=e.get(),this.sortMapping=e.get(),this.stringSearcher.load(e)}},ke=class{constructor(e,t){this.entitySearcher=void 0,this.searcherTypes=void 0,this.entitySearcher=e,this.searcherTypes=t}indexEntities(e,t,r){return this.entitySearcher.indexEntities(e,t,r)}getMatches(e){let t=new ee(this.searcherTypes,e.searchers);if(e.topN>200)return this.entitySearcher.getMatches(e);if(e.string.length<=3&&t.has(p.Prefix)&&t.minQuality(p.Prefix)<2.2){let r=new z(e.string,e.topN,[new F(2.3)]),i=this.entitySearcher.getMatches(r);if(i.matches.length==e.topN)return new A(i.matches,e,i.meta)}if(e.string.length<=3&&!t.has(p.Prefix)&&t.has(p.Substring)&&t.minQuality(p.Substring)<1.2){let r=new z(e.string,e.topN,[new D(1.3)]),i=this.entitySearcher.getMatches(r);if(i.matches.length==e.topN)return new A(i.matches,e,i.meta)}return this.entitySearcher.getMatches(e)}tryGetEntity(e){return this.entitySearcher.tryGetEntity(e)}getEntities(){return this.entitySearcher.getEntities()}tryGetTerms(e){return this.entitySearcher.tryGetTerms(e)}getTerms(){return this.entitySearcher.getTerms()}removeEntity(e){return this.entitySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.entitySearcher.replaceEntity(e,t,r)}save(e){return this.entitySearcher.save(e)}load(e){return this.entitySearcher.load(e)}},te=class{constructor(){this.ids=void 0,this.frequencies=void 0,this.ids=[],this.frequencies=[]}addId(e,t){this.ids.push(e),this.frequencies.push(t)}seal(){this.ids=H.ToInt32Array(this.ids),this.frequencies=H.ToInt32Array(this.frequencies)}get length(){return this.ids.length}save(e){e.add(this.ids),e.add(this.frequencies)}load(e){this.ids=e.get(),this.frequencies=e.get()}},O=class{constructor(){this.ngramToTermIds=void 0,this.ngramToTermIds=new Map}add(e,t,r){let i=this.ngramToTermIds.get(e);i||(i=new te,this.ngramToTermIds.set(e,i)),i.addId(t,r)}seal(){for(let e of this.ngramToTermIds.values())e.seal()}getIds(e){return this.ngramToTermIds.get(e)}get size(){return this.ngramToTermIds.size}save(e){e.add(this.ngramToTermIds.size);for(let[t,r]of this.ngramToTermIds)e.add(t),r.save(e)}load(e){let t=e.get();for(let r=0;r<t;r++){let i=e.get(),s=new te;s.load(e),this.ngramToTermIds.set(i,s)}}},Re=class{static ComputeJaccardCoefficient(e,t,r){return r/(e+t-r)}static ComputeOverlapMaxCoefficient(e,t,r){return r/Math.max(e,t)}},He=class{constructor(e){this.ngramComputer=void 0,this.invertedIndex=void 0,this.numberOfNgrams=void 0,this.commonNgramCounts=void 0,this.ngramComputer=e,this.invertedIndex=new O,this.numberOfNgrams=new Int32Array(0),this.commonNgramCounts=new Int32Array(0)}index(e){let t=performance.now();this.invertedIndex=new O,this.commonNgramCounts=new Int32Array(e.length),this.numberOfNgrams=new Int32Array(e.length);let r=0;for(let o=0,a=e.length;o<a;o++){let c=e[o];if(!this.isValidTerm(c)){this.numberOfNgrams[o]=0,r++;continue}let h=this.ngramComputer.computeNgrams(c);this.numberOfNgrams[o]=h.length;let l=this.getNgramsToFrequency(h);for(let[u,d]of l)this.invertedIndex.add(u,o,d)}this.invertedIndex.seal();let i=Math.round(performance.now()-t),s=new y;return s.add("numberOfInvalidTerms",r),s.add("indexingDurationFuzzySearcher",i),s}isValidTerm(e){return e!=null&&e.trim()!==""}getMatches(e){if(this.invertedIndex.size===0)return new T([],e,new y);let t=this.ngramComputer.computeNgrams(e.string),r=this.getNgramsToFrequency(t),i=t.length;this.computeCommonNgramCounts(r);let s=this.getMatchesFromCommonNgrams(i,e.minQuality);return new T(s,e,new y)}computeCommonNgramCounts(e){this.commonNgramCounts.fill(0);for(let[t,r]of e){let i=this.invertedIndex.getIds(t);if(i!=null)for(let s=0,o=i.length;s<o;s++)this.commonNgramCounts[i.ids[s]]+=Math.min(r,i.frequencies[s])}}getNgramsToFrequency(e){let t=new Map;for(let r=0,i=e.length;r<i;r++){let s=e[r],o=t.get(s);t.set(s,o!==void 0?o+1:1)}return t}getMatchesFromCommonNgrams(e,t){let r=[];for(let i=0,s=this.numberOfNgrams.length;i<s;i++){let o=Re.ComputeOverlapMaxCoefficient(e,this.numberOfNgrams[i],this.commonNgramCounts[i]);o>t&&r.push(new _(i,o))}return r}save(e){this.invertedIndex.save(e),e.add(this.numberOfNgrams)}load(e){this.invertedIndex=new O,this.invertedIndex.load(e),this.numberOfNgrams=e.get(),this.commonNgramCounts=new Int32Array(this.numberOfNgrams.length)}},Ae=class{constructor(e,t){this.stringSearcher=void 0,this.penaltyFactor=void 0,this.hashCodes=void 0,this.stringSearcher=e,this.penaltyFactor=1-t,this.hashCodes=new Int32Array(0)}index(e){this.hashCodes=new Int32Array(e.length);for(let t=0,r=e.length;t<r;t++)this.hashCodes[t]=X.getHashCode(e[t]);return this.stringSearcher.index(e)}getMatches(e){let t=X.getHashCode(e.string),r=this.stringSearcher.getMatches(e),i=r.matches.map(s=>this.penalizeMatch(s,t)).filter(s=>s.quality>=e.minQuality);return new T(i,r.query,r.meta)}penalizeMatch(e,t){return e.quality*=this.hashCodes[e.index]===t?1:this.penaltyFactor,e}save(e){e.add(this.hashCodes),this.stringSearcher.save(e)}load(e){this.hashCodes=e.get(),this.stringSearcher.load(e)}},ze=class{constructor(e,t){this.ngramN=void 0,this.transformNgram=void 0,this.ngramN=e,this.transformNgram=t??(r=>r)}computeNgrams(e){if(e.length===0)return[];if(e.length<=this.ngramN){let r=this.transformNgram(e);return r?[r]:[]}let t=[];for(let r=0,i=this.maximumNumberOfNgrams(e);r<i;r++){let s=this.transformNgram(e.substring(r,r+this.ngramN));s&&t.push(s)}return t}maximumNumberOfNgrams(e){return Math.max(e.length-this.ngramN+1,e.length>0?1:0)}},Be=class{constructor(e,t,r){this.paddingLeft=void 0,this.paddingRight=void 0,this.paddingMiddle=void 0,this.paddingLeft=e,this.paddingRight=t,this.paddingMiddle=r}normalize(e){return e&&`${this.paddingLeft}${e.split(" ").join(this.paddingMiddle)}${this.paddingRight}`}normalizeBulk(e){let t=e.map(i=>this.normalize(i)),r=new y;return new P(t,r)}},re=class{};re.Value=new Map([["a",["\u1D8F","\u2C65","\u0251","\u1D00","\u0250","\u0252"]],["aa",["\xE5","\uA733"]],["ae",["\xE4","\xE6","\u1D01","\u1D2D","\u1D46","\u01FD","\u01E3","\u1D02"]],["ao",["\uA735"]],["au",["\uA737"]],["av",["\uA739","\uA73B"]],["ay",["\uA73D"]],["b",["\u0180","\u0253","\u0183","\u1D6C","\u1D80","\u0299"]],["c",["\u023C","\u0188","\u0255","\u1D04","\uA73F","\u2184"]],["d",["\u0111","\xF0","\u0256","\u0257","\u018C","\u1D6D","\u1D81","\u1D91","\u0221","\u1D05","\uA77A"]],["db",["\u0238"]],["e",["\u1D92","\u0247","\u2C78","\u1D07","\u0259","\u01DD","\u025B"]],["eo",["\u1D14"]],["f",["\u0192","\u1D6E","\u1D82","\uA730","\uA77C"]],["g",["\u01E5","\u0260","\u1D83","\u0262","\u021D","\u014B","\uA7A1","\u1D79","\uA77F"]],["h",["\u0127","\u2C68","\u0266","\u029C","\u0303","\u0267","\u2C76","\u0265"]],["hv",["\u0195"]],["i",["\u0268","\u1D7B","\u1D96","\u0131","\u026A","\u0269"]],["j",["\u0249","\u0237","\u029D","\u025F","\u0284","\u1D0A"]],["k",["\u0199","\u2C6A","\u1D84","\uA741","\u1D0B","\uA743","\uA745","\uA7A3"]],["l",["\u0142","\u019A","\u2C61","\u026B","\u026C","\u1D85","\u026D","\u0234","\u029F","\uA749","\uA781","\uA747"]],["m",["\u1D6F","\u1D86","\u0271","\u1D0D","\u026F"]],["n",["\u0272","\u019E","\u1D70","\u1D87","\u0273","\u0235","\u0274","\uA791","\uA7A5"]],["o",["\xF8","\u01FF","\u0275","\u0254","\u2C7A","\u1D0F","\uA74B","\uA74D"]],["oe",["\xF6","\u0153"]],["oi",["\u01A3"]],["oo",["\uA74F"]],["ou",["\u0223"]],["p",["\u1D7D","\u01A5","\u1D71","\u1D88","\u1D18","\u01BF","\uA751","\uA753","\uA755"]],["q",["\u024B","\u02A0","\uA757","\uA759"]],["qp",["\u0239"]],["r",["\u024D","\u027D","\uA75B","\u1D72","\u1D89","\u027C","\u027E","\u1D73","\u0280","\u0279","\u0281","\uA7A7","\uA783"]],["s",["\u1D74","\u1D8A","\u0282","\u023F","\uA731","\u0283","\uA7A9","\uA785","\u017F"]],["ss",["\xDF"]],["t",["\u0167","\u2C66","\u01AD","\u0288","\u1D75","\u01AB","\u0236","\u1D1B","\uA787"]],["th",["\xFE"]],["tz",["\uA729"]],["u",["\u0289","\u028A","\u1D7E","\u1D1C","\u1D99"]],["ue",["\xFC","\u1D6B"]],["v",["\u028B","\u1D8C","\u2C71","\u2C74","\u1D20","\u028C","\uA75F"]],["vy",["\uA761"]],["w",["\u2C73","\u1D21","\u028D"]],["x",["\u1D8D"]],["y",["\u024F","\u01B4","\u028F","\u1EFF"]],["z",["\u01B6","\u0225","\u2C6C","\u1D76","\u1D8E","\u0290","\u0291","\u0240","\u1D22","\u0292","\u01B9","\uA763"]]]);var ne=class n{constructor(e,t,r){this.replacements=void 0,this.treatCharacterAsSpace=void 0,this.allowCharacter=void 0,this.replacements=e,this.treatCharacterAsSpace=t,this.allowCharacter=r}static createDefaultConfig(){let e=new Set(["_","-","\u2013","/",","," "]);return new n([re.Value],t=>e.has(t),t=>Z.isAlphanumeric(t))}},ie=class{constructor(e,t,r="normalizationDuration"){this.stringSearcher=void 0,this.normalizer=void 0,this.normalizationDurationMetaKey=void 0,this.stringSearcher=e,this.normalizer=t,this.normalizationDurationMetaKey=r}index(e){let t=performance.now(),r=this.normalizer.normalizeBulk(e),i=Math.round(performance.now()-t),s=this.stringSearcher.index(r.strings);s.add(this.normalizationDurationMetaKey,i);for(let o of r.meta.allEntries)s.add(o[0],o[1]);return s}getMatches(e){let t=new j(this.normalizer.normalize(e.string),e.minQuality,e.searcherType),r=this.stringSearcher.getMatches(t);return new T(r.matches,e,r.meta)}save(e){this.stringSearcher.save(e)}load(e){this.stringSearcher.load(e)}},Ne=class{constructor(e){this.suffixArraySearcher=void 0,this.suffixArraySearcher=e}index(e){return this.suffixArraySearcher.index(e)}getMatches(e){if(!e.string)return new T([],e,new y);let t=this.modifyQueryString(e.string),r=new j(t,e.minQuality,e.searcherType);return this.suffixArraySearcher.getMatches(r,e.string.length)}modifyQueryString(e){return`${this.suffixArraySearcher.separator}${e}`}save(e){this.suffixArraySearcher.save(e)}load(e){this.suffixArraySearcher.load(e)}},De=class{constructor(e,t,r){this.prefixSearcher=void 0,this.substringSearcher=void 0,this.fuzzySearcher=void 0,this.prefixSearcher=e,this.substringSearcher=t,this.fuzzySearcher=r}index(e){let t=[];if(this.prefixSearcher&&!this.substringSearcher){let r=this.prefixSearcher.index(e);t.push(r)}if(this.substringSearcher){let r=this.substringSearcher.index(e);t.push(r)}if(this.fuzzySearcher){let r=this.fuzzySearcher.index(e);t.push(r)}return q.mergeMeta(t)}getMatches(e){if(!e.searcherType)throw new Error("SearcherSwitch requires a searcher type.");switch(e.searcherType){case p.Prefix:if(!this.prefixSearcher)throw new Error("No prefix searcher has been indexed.");return this.prefixSearcher.getMatches(e);case p.Substring:if(!this.substringSearcher)throw new Error("No substring searcher has been indexed.");return this.substringSearcher.getMatches(e);case p.Fuzzy:if(!this.fuzzySearcher)throw new Error("No fuzzy searcher has been indexed.");return this.fuzzySearcher.getMatches(e);default:throw new Error(`Unknown searcher type: ${e.searcherType}`)}}save(e){this.prefixSearcher&&!this.substringSearcher&&this.prefixSearcher.save(e),this.substringSearcher&&this.substringSearcher.save(e),this.fuzzySearcher&&this.fuzzySearcher.save(e)}load(e){this.prefixSearcher&&!this.substringSearcher&&this.prefixSearcher.load(e),this.substringSearcher&&this.substringSearcher.load(e),this.fuzzySearcher&&this.fuzzySearcher.load(e)}};(function(n){n.QualityAndIndex="qualityAndIndex",n.QualityAndMatchedString="qualityAndMatchedString"})(G||(G={}));var Fe=class{constructor(e,t){this.sortOrder=void 0,this.entitySearcher=void 0,this.collator=new Intl.Collator(void 0,{numeric:!0}),this.sortOrder=e,this.entitySearcher=t}indexEntities(e,t,r){return this.entitySearcher.indexEntities(e,t,r)}getMatches(e){let t=this.entitySearcher.getMatches(e);switch(this.sortOrder){case G.QualityAndIndex:return t;case G.QualityAndMatchedString:return this.sortMatchesByQualityAndMatchedString(t.matches),t;default:throw new Error(`Unsupported sort order: ${this.sortOrder}`)}}sortMatchesByQualityAndMatchedString(e){e.sort((t,r)=>t.quality>r.quality?-1:t.quality<r.quality?1:this.collator.compare(t.matchedString,r.matchedString))}tryGetEntity(e){return this.entitySearcher.tryGetEntity(e)}getEntities(){return this.entitySearcher.getEntities()}tryGetTerms(e){return this.entitySearcher.tryGetTerms(e)}getTerms(){return this.entitySearcher.getTerms()}save(e){this.entitySearcher.save(e)}load(e){this.entitySearcher.load(e)}removeEntity(e){return this.entitySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.entitySearcher.replaceEntity(e,t,r)}},$e=class{constructor(e){this.stringSearcher=void 0,this.stringSearcher=e}index(e){return this.stringSearcher.index(e)}getMatches(e){let t=this.stringSearcher.getMatches(e);return t.matches.sort(this.compareMatchesByQualityAndIndex),t}compareMatchesByQualityAndIndex(e,t){return e.quality>t.quality?-1:e.quality<t.quality?1:e.index<t.index?-1:e.index>t.index?1:0}save(e){this.stringSearcher.save(e)}load(e){this.stringSearcher.load(e)}},W=class{static compareOrdinal(e,t,r,i,s){let o=Math.min(t+s,e.length),a=Math.min(i+s,r.length),c=t,h=i;for(;c<o&&h<a;){let d=e.charCodeAt(c),g=r.charCodeAt(h);if(d<g)return-1;if(d>g)return 1;c++,h++}let l=o-t,u=a-i;return l===u?0:l<u?-1:1}},Oe=class n{static create(e){if(e==null)throw new Error("Input string cannot be null.");let t=new n(e);return t.FormInitialChains(),t.BuildSufixArray(),t.sa}constructor(e){this.inputString=void 0,this.eoc=2147483647,this.sa=void 0,this.isa=void 0,this.chainHeadsDict=void 0,this.chainStack=[],this.subChains=[],this.nextRank=1,this.inputString=e;let t=e.length;this.sa=new Int32Array(t),this.isa=new Int32Array(t),this.chainHeadsDict=new Map}FormInitialChains(){this.FindInitialChains(),this.SortAndPushSubchains()}FindInitialChains(){for(let e=0;e<this.inputString.length;e++){let t=this.inputString.charCodeAt(e),r=this.chainHeadsDict.get(t);this.isa[e]=r!==void 0?r:this.eoc,this.chainHeadsDict.set(t,e)}for(let e of this.chainHeadsDict.values()){let t=new se(e,1);this.subChains.push(t)}}BuildSufixArray(){for(;this.chainStack.length>0;){let e=this.chainStack.pop();this.isa[e.head]===this.eoc?this.RankSuffix(e.head):this.RefineChainWithInductionSorting(e)}}RankSuffix(e){this.isa[e]=-this.nextRank,this.sa[this.nextRank-1]=e,this.nextRank++}RefineChainWithInductionSorting(e){let t=[];for(this.chainHeadsDict.clear(),this.subChains=[];e.head!==this.eoc;){let r=this.isa[e.head];if(e.head+e.length>this.inputString.length-1)this.RankSuffix(e.head);else if(this.isa[e.head+e.length]<0){let i=new qe(e.head,-this.isa[e.head+e.length]);t.push(i)}else this.ExtendChain(e);e.head=r}this.SortAndPushSubchains(),this.SortAndRankNotedSuffixes(t)}ExtendChain(e){let t=this.inputString.charCodeAt(e.head+e.length);if(this.chainHeadsDict.has(t))this.isa[this.chainHeadsDict.get(t)]=e.head,this.isa[e.head]=this.eoc;else{this.isa[e.head]=this.eoc;let r=new se(e.head,e.length+1);this.subChains.push(r)}this.chainHeadsDict.set(t,e.head)}SortAndRankNotedSuffixes(e){e.sort((t,r)=>t.rank-r.rank);for(let t=0;t<e.length;t++)this.RankSuffix(e[t].head)}SortAndPushSubchains(){this.subChains.sort((e,t)=>{let r=Math.min(e.length,t.length);return W.compareOrdinal(this.inputString,e.head,this.inputString,t.head,r)});for(let e=this.subChains.length-1;e>=0;e--)this.chainStack.push(this.subChains[e])}},qe=class{constructor(e,t){this.head=void 0,this.rank=void 0,this.head=e,this.rank=t}},se=class{constructor(e,t){this.head=void 0,this.length=void 0,this.head=e,this.length=t}},Ge=class{constructor(e){this.separator=void 0,this.str=void 0,this.suffixArray=void 0,this.indexToTermIndex=void 0,this.termLengths=void 0,this.separator=e,this.str="",this.suffixArray=new Int32Array(0),this.indexToTermIndex=new Int32Array(0),this.termLengths=new Int32Array(0)}index(e){let t=performance.now();this.str=e.length>0?this.separator+e.join(this.separator)+this.separator:"",this.suffixArray=Oe.create(this.str),this.indexToTermIndex=new Int32Array(this.suffixArray.length),this.termLengths=new Int32Array(e.length);let r=0;for(let o=0;o<e.length;o++){this.termLengths[o]=e[o].length;for(let a=0;a<=e[o].length;a++)this.indexToTermIndex[r++]=o}this.indexToTermIndex[r++]=-1;let i=Math.round(performance.now()-t),s=new y;return s.add("indexingDurationSuffixArraySearcher",i),s}getMatches(e,t){if(!e.string)return new T([],e,new y);let[r,i]=this.GetPositionsInSuffixArray(e.string),s=new Int32Array(i-r),o=new Set,a=0;for(let l=r;l<i;l++){let u=this.indexToTermIndex[this.suffixArray[l]];o.has(u)||(o.add(u),s[a++]=u)}let c=[];t=t??e.string.length;let h=0;for(let l=0;l<a;l++)h=this.computeQuality(t,this.termLengths[s[l]]),h>e.minQuality&&c.push(new _(s[l],h));return new T(c,e,new y)}computeQuality(e,t){return e/t}GetPositionsInSuffixArray(e){let t=0,r=this.suffixArray.length,i=0;for(;t<r;)i=Math.floor((t+r)/2),W.compareOrdinal(e,0,this.str,this.suffixArray[i],e.length)>0?t=i+1:r=i;let s=t;for(r=this.suffixArray.length;t<r;)i=Math.floor((t+r)/2),W.compareOrdinal(e,0,this.str,this.suffixArray[i],e.length)==0?t=i+1:r=i;return[s,r]}save(e){e.add(this.str),e.add(this.suffixArray),e.add(this.indexToTermIndex),e.add(this.termLengths)}load(e){this.str=e.get(),this.suffixArray=e.get(),this.indexToTermIndex=e.get(),this.termLengths=e.get()}},oe=class{static createSearcher(e){let t=this.createDefaultNormalizer(e),r=this.tryCreateFuzzySearcher(e),i=this.tryCreateSubstringSearcher(e),s=this.tryCreatePrefixSearcher(e,i),o=new De(s,i,r);o=new Ie(o),o=new $e(o),o=new ie(o,t,"normalizationDurationDefault");let a=new xe(o,e.searcherTypes);return a=new ke(a,e.searcherTypes),a=new Fe(e.sortOrder,a),a}static createDefaultNormalizer(e){let t=new Set;e.fuzzySearchConfig&&(e.fuzzySearchConfig.paddingLeft.split("").forEach(i=>t.add(i)),e.fuzzySearchConfig.paddingRight.split("").forEach(i=>t.add(i)),e.fuzzySearchConfig.paddingMiddle.split("").forEach(i=>t.add(i))),e.substringSearchConfig&&e.substringSearchConfig.suffixArraySeparator.split("").forEach(i=>t.add(i));let r=new ne(e.normalizerConfig.replacements,e.normalizerConfig.treatCharacterAsSpace,i=>e.normalizerConfig.allowCharacter(i)&&!t.has(i));return Le.create(r)}static tryCreateFuzzySearcher(e){if(!e.searcherTypes.includes(p.Fuzzy))return null;if(e.fuzzySearchConfig===void 0)throw new Error("Unable to create fuzzy searcher: No fuzzy search config provided.");return this.createFuzzySearcher(e.fuzzySearchConfig)}static createFuzzySearcher(e){let t=new ze(e.ngramN,e.transformNgram),r=new Be(e.paddingLeft,e.paddingRight,e.paddingMiddle),i=new He(t);return i=new Ae(i,e.inequalityPenalty),i=new ie(i,r,"normalizationDurationNgrams"),i}static tryCreateSubstringSearcher(e){if(!e.searcherTypes.includes(p.Substring))return null;if(e.substringSearchConfig===void 0)throw new Error("Unable to create substring searcher: No substring search config provided.");return this.createSubstringSearcher(e.substringSearchConfig)}static createSubstringSearcher(e){return new Ge(e.suffixArraySeparator)}static tryCreatePrefixSearcher(e,t){if(!e.searcherTypes.includes(p.Prefix))return null;if(e.substringSearchConfig===void 0)throw new Error("Unable to create prefix searcher: No substring search config provided.");return this.createPrefixSearcher(e.substringSearchConfig,t)}static createPrefixSearcher(e,t){return t===null&&(t=this.createSubstringSearcher(e)),new Ne(t)}},Qe=class n{constructor(e,t,r,i,s,o){this.paddingLeft=void 0,this.paddingRight=void 0,this.paddingMiddle=void 0,this.ngramN=void 0,this.transformNgram=void 0,this.inequalityPenalty=void 0,this.paddingLeft=e,this.paddingRight=t,this.paddingMiddle=r,this.ngramN=i,this.transformNgram=s,this.inequalityPenalty=o}static createDefaultConfig(){return new n("$$","!","!$$",3,e=>e.endsWith("$")?null:e.indexOf("$")===-1?e.split("").sort().join(""):e,.05)}};var Ue=class n{constructor(e){this.suffixArraySeparator=void 0,this.suffixArraySeparator=e}static createDefaultConfig(){return new n("$")}},je=class n{constructor(e,t,r,i,s,o){this.searcherTypes=void 0,this.maxQueryLength=void 0,this.sortOrder=void 0,this.normalizerConfig=void 0,this.fuzzySearchConfig=void 0,this.substringSearchConfig=void 0,this.searcherTypes=e,this.maxQueryLength=t,this.sortOrder=r,this.normalizerConfig=i,this.fuzzySearchConfig=s,this.substringSearchConfig=o}static createDefaultConfig(){let e=[p.Fuzzy,p.Substring,p.Prefix],t=G.QualityAndMatchedString,r=ne.createDefaultConfig(),i=Qe.createDefaultConfig(),s=Ue.createDefaultConfig();return new n(e,150,t,r,i,s)}},ae=class{static createSearcher(e){let t=oe.createSearcher(e),r=oe.createSearcher(e),i=new Se(e.maxQueryLength,t,r);return i=new we(i),i}static createDefaultSearcher(){let e=je.createDefaultConfig();return this.createSearcher(e)}};function V(n,e){if(n.length===0)return null;let t=n.find(i=>i.sourceStart<=e&&e<=i.sourceEnd);if(t)return t.commentrayLine;if(e<n[0].sourceStart)return n[0].commentrayLine;let r=n[0];for(let i of n)if(i.sourceStart<=e)r=i;else break;return r.commentrayLine}function _e(n,e){if(n.length===0)return null;let t=n[0];for(let r of n)if(r.commentrayLine<=e)t=r;else break;return t.sourceStart-1}function B(n,e,t,r,i){let s=Math.max(0,e-t),o=Math.max(0,r-i);return s<=0?0:n/s*o}function K(n,e,t,r=5){let i=e+r,s=e+t-r;return n<i?{y:i-e,clipped:"above"}:n>s?{y:s-e,clipped:"below"}:{y:n-e,clipped:"none"}}function Bt(n,e,t,r,i={}){let{tension:s=.38,clipStart:o="none",clipEnd:a="none"}=i,h=Math.min(.66,s+.24),l=o==="none"?s:h,u=a==="none"?s:h,d=t-n;return[{x:n,y:e},{x:n+d*l,y:e},{x:t-d*u,y:r},{x:t,y:r}]}function We(n,e,t,r){return`M ${C(n.x)} ${C(n.y)} C ${C(e.x)} ${C(e.y)} ${C(t.x)} ${C(t.y)} ${C(r.x)} ${C(r.y)}`}function Nt(n,e,t,r,i){let s=$(n,e,i),o=$(e,t,i),a=$(t,r,i),c=$(s,o,i),h=$(o,a,i),l=$(c,h,i);return[[n,s,c,l],[l,h,a,r]]}function $(n,e,t){return{x:(1-t)*n.x+t*e.x,y:(1-t)*n.y+t*e.y}}function Ve(n,e,t,r,i={}){let{tension:s=.38,clipStart:o="none",clipEnd:a="none",splitT:c=.66}=i,h=Bt(n,e,t,r,{tension:s,clipStart:o,clipEnd:a}),[l,u,d,g]=h;if(!(o!=="none"||a!=="none"))return{solid:We(l,u,d,g)};let[f,S]=Nt(l,u,d,g,c),[v,I,x,E]=f,[b,k,R,N]=S;return{solid:We(v,I,x,E),dotted:We(b,k,R,N)}}function C(n){return n.toFixed(2)}function st(n){return[...n].sort((e,t)=>e.sourceStart-t.sourceStart)}function ot(n,e){if(n.length===0)return null;let t=V(n,e);return t===null?null:n.find(i=>i.commentrayLine===t)?.id??null}function Ke(n){return Math.max(0,n-1)}function L(n){let e=n.trim();if(e==="")return"";try{let t=atob(e),r=new Uint8Array(t.length);for(let i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return new TextDecoder("utf-8",{fatal:!1}).decode(r)}catch{return""}}function at(n,e){function t(r){let i=n.getAttribute(r);return i!==null&&i.trim()!==""?i:e.getAttribute(r)?.trim()??""}return{rawCodeB64:t("data-raw-code-b64"),rawMdB64:t("data-raw-md-b64")}}function ce(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ct(n,e){let t=e.map(r=>r.trim()).filter(Boolean);if(t.length===0)return ce(n);try{let r=t.map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`(${r.join("|")})`,"gi");return n.split(i).map((o,a)=>a%2===1?`<mark class="search-hit">${ce(o)}</mark>`:ce(o)).join("")}catch{return ce(n)}}function he(n,e){let t=e.map(c=>c.trim()).filter(Boolean);if(t.length===0)return[];let r=n.toLowerCase(),i=t.map(c=>c.toLowerCase()),s=[],o=0,a=0;for(;o<n.length&&a<400;){let c=o,h=-1,l=!0;for(let u of i){if(u.length===0)continue;let d=r.indexOf(u,c);if(d<0){l=!1;break}h<0&&(h=d),c=d+u.length}if(!l||h<0)break;s.push({start:h,end:c}),a++,o=h+1}return s}function ht(n,e){let t=Math.max(0,Math.min(e,n.length)),r=0;for(let i=0;i<t;i++)n[i]===`
2
- `&&r++;return r}function lt(n,e){let t=n.split(`
3
- `);return e<0||e>=t.length?"":t[e]??""}function le(n){return n.trim().split(/\s+/).filter(Boolean)}function ut(n,e){let t=le(e);return t.length===0?[...n]:n.filter(r=>{let i=r.sourcePath.replace(/\\/g,"/");return he(i,t).length>0})}function dt(n){let e=new Set,t=new Set,r=[],i=0;for(let s of n){let o=s.sourcePath.trim(),a=s.commentrayPath.trim();if(o.length>0){let c=`${o}\0${a}`;e.has(c)||(e.add(c),r.push({kind:"path",line:i++,text:o,spPath:s.sourcePath,crPath:s.commentrayPath}))}a.length>0&&!t.has(a)&&(t.add(a),r.push({kind:"path",line:i++,text:a,spPath:s.sourcePath,crPath:s.commentrayPath}))}return r}var Dt=80;function mt(n,e=Dt){let t=new Map;for(let s of n){let o=s.sourcePath.trim();if(o.length===0)continue;let a=t.get(o),c={sourcePath:s.sourcePath.trim(),commentrayPath:s.commentrayPath.trim()};if(!a){t.set(o,c);continue}c.commentrayPath.localeCompare(a.commentrayPath)<0&&t.set(o,c)}let r=t.size;return{rows:[...t.values()].sort((s,o)=>s.sourcePath.localeCompare(o.sourcePath)).slice(0,e),totalUnique:r}}function w(n){return n.trim().replaceAll("\\","/").replace(/^\.\//,"")}function Ft(n){let e=n.indexOf("/browse/");if(e>=0){let r=n.slice(0,e).replace(/\/+$/,"");return r===""?"/":r}let t=n.replace(/\/[^/]*$/,"");return t===""||t==="/"?"/":t.replace(/\/+$/,"")||"/"}var $t=/^\.\/?browse\/([^/?#]+\.html)$/i;function ue(n,e,t){let r=n.trim();if(r.startsWith("/"))return`${t}${r}`;let i=$t.exec(r);if(i?.[1]){let s=Ft(e),o=s==="/"?`/browse/${i[1]}`:`${s}/browse/${i[1]}`;return`${t}${o}`}return new URL(r,`${t}${e}`).href}function Je(n,e,t){let r=w(e),i=w(t);if(r.length>0){let s=n.find(o=>w(o.commentrayPath)===r);if(s)return s}if(i.length>0){let s=n.find(o=>w(o.sourcePath)===i);if(s)return s}}function gt(n,e,t){return w(n.sourcePath)===w(e)&&w(n.commentrayPath)===w(t)}function Ye(n,e){try{return n.getItem(e)}catch{return null}}function de(n,e,t){try{n.setItem(e,t)}catch{}}function Ot(n){if(typeof globalThis.location<"u"&&globalThis.location.protocol==="file:")return;let e=n.querySelectorAll(".mermaid");if(e.length===0)return;let t=globalThis.commentrayMermaid;if(!t)return;let r=Array.from(e);t.run({nodes:r}).catch(()=>{})}function vt(n,e,t){return Math.max(e,Math.min(t,n))}function M(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function qt(n,e){let t=n.replace(/\s+/g," ").trim();return t.length<=e?t:`${t.slice(0,e-1)}\u2026`}function Gt(n,e){let t=new Map;for(let r of n){let i=r.kind==="path"?`path:${r.spPath??""}|${r.crPath??""}|${r.text.slice(0,120)}`:`${r.kind}:${r.line}:${r.crPath??""}`,s=t.get(i);(!s||r.score>s.score)&&t.set(i,r)}return[...t.values()].sort((r,i)=>i.score-r.score).slice(0,e)}function Xe(n,e,t){let r=he(n,t),i=new Set,s=[];for(let o of r){let a=ht(n,o.start);i.has(a)||(i.add(a),s.push({kind:e,line:a,text:lt(n,a),score:1e3,source:"ordered"}))}return s}function Qt(n,e,t){let r=e.trim();if(!r)return[];let i=new z(r,t,[new U(.22),new D(0),new F(0)]),s=n.getMatches(i),o=[];for(let a of s.matches){let c=a.entity;o.push({kind:c.kind,line:c.line,text:c.text,score:100+a.quality,source:"fuzzy",crPath:c.crPath,spPath:c.spPath})}return o}function Ut(n,e){if(e.length===0)return[];let t=[];for(let r of n)r.kind!=="path"||he(r.text,e).length===0||t.push({kind:"path",line:r.line,text:r.text,score:1e3,source:"ordered",spPath:r.spPath,crPath:r.crPath});return t}function jt(n){let{scope:e,filePathLabel:t,commentrayPathLabel:r,rawCode:i,rawMd:s,searcher:o,queryRaw:a,tokens:c,pathBlobWide:h,pathRowsForOrdering:l}=n,u=(h&&h.trim().length>0?h.trim():[t,r].filter(S=>S.trim().length>0).join(`
4
- `))||"",d=e==="commentray-and-paths"?[]:Xe(i,"code",c),g=e==="commentray-and-paths"&&l&&l.length>0?Ut(l,c):e==="commentray-and-paths"&&u?Xe(u,"path",c):[],m=Xe(s,"md",c),f=Qt(o,a,60);return Gt([...d,...g,...m,...f],80)}function _t(n){return n==="commentray-and-paths"?"Paths + indexed commentray (this page + browse pages when built). Ordered tokens + fuzzy lines.":"Whole source: whitespace tokens in order (may span lines). Per-line fuzzy ranking for typos."}function Wt(n,e){if(n.kind==="code")return`Code L${n.line+1}`;if(n.kind==="path")return"Path";let t=n.crPath&&n.crPath!==e.currentCommentrayPath?` \xB7 ${n.crPath}`:"";return`Commentray L${n.line+1}${t}`}function xt(n,e,t){let r=Wt(n,t),i=n.source==="ordered"?"ordered":"fuzzy",s=ct(qt(n.text,320),e),o=M(n.kind==="md"?n.crPath??t.currentCommentrayPath:n.crPath??""),a=M(n.kind==="md"?n.spPath??t.currentSourcePath:n.spPath??"");return`<button type="button" class="hit" data-kind="${n.kind}" data-line="${String(n.line)}" data-cr-path="${o}" data-sp-path="${a}"><span class="meta">${M(r)} <span class="src-tag">(${i})</span></span><div class="snippet">${s}</div></button>`}function Vt(n,e,t,r){if(e.length===0)return'<div class="hint">No matches. Try fewer tokens or looser spelling (fuzzy matches per line).</div>';let i=_t(n),s=[];s.push(`<div class="hint">${i} ${e.length} hit(s).</div>`);for(let o of e)s.push(xt(o,t,r));return s.join("")}function Ze(n,e,t,r){return n==="full"?"Documented source for this page. Type to search.":r?"Documented source on this page. Type to search the index when it is available.":t>e?`Indexed source files (${String(e)} of ${String(t)} shown). Type to search.`:`Indexed source files (${String(t)}). Type to search.`}function et(n,e,t){let r=[],i=[`<div class="hint">${M(n)}</div>`],s=e.map((o,a)=>({kind:"path",line:a,text:o.sourcePath,score:1e3,source:"ordered",spPath:o.sourcePath,crPath:o.commentrayPath}));for(let o of s)i.push(xt(o,r,t));return i.join("")}function Tt(n,e,t){let r=n.querySelector(`#commentray-md-line-${String(e)}`);if(r instanceof HTMLElement){let o=r.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop;n.scrollTo({top:Math.max(0,o-8),behavior:"smooth"});return}if(t<=1)return;let i=e/Math.max(1,t-1),s=n.scrollHeight-n.clientHeight;n.scrollTo({top:i*Math.max(0,s),behavior:"smooth"})}function Et(n,e){if(n.staticBrowseUrl?.trim()){let r=ue(n.staticBrowseUrl.trim(),globalThis.location.pathname,globalThis.location.origin),i=new URL(r);e!==null&&e>=0&&(i.hash=`commentray-md-line-${String(e)}`),globalThis.location.assign(i.toString());return}let t=(n.commentrayOnGithub??"").trim();if(t.length>0){let r=e!==null&&e>=0?`${t}#L${String(e+1)}`:t;globalThis.location.assign(r)}}function Kt(n){return{scope:(n.getAttribute("data-search-scope")||"")==="commentray-and-paths"?"commentray-and-paths":"full",filePathLabel:n.getAttribute("data-search-file-path")||"",commentrayPathLabel:n.getAttribute("data-search-commentray-path")||""}}function ft(n,e,t,r,i){let s=t.split(`
1
+ "use strict";(()=>{var k=class{static ToInt32Array(e){let t=new Int32Array(e.length);for(let r=0,i=e.length;r<i;r++)t[r]=e[r];return t}},te=class{static getHashCode(e){let t=5381,r=t;for(let i=0,s=e.length;i<s&&e[i]!="\0"&&(t=(t<<5)+t^e.charCodeAt(i),i!==s-1&&e[i+1]!=="\0");i+=2)r=(r<<5)+r^e.charCodeAt(i+1);return t+1566083941*r|0}},S=class{constructor(e){this.entries=void 0,this.entries=e!==void 0?e:new Map}add(e,t){if(this.entries.has(e))throw new Error(`A meta entry with key ${e} is already present.`);this.entries.set(e,t)}get(e){return this.entries.get(e)}get allEntries(){return this.entries}toJSON(){return{entries:Object.fromEntries(this.entries)}}},G=class{static mergeMeta(e){if(e.length===0)return new S;if(e.length===1)return e[0];let t=new Map;for(let i of e)for(let[s,o]of i.allEntries){let a=t.get(s);a===void 0?t.set(s,[o]):a.push(o)}let r=new Map;for(let[i,s]of t)if(s.length!==1){if(s.every(o=>typeof o=="number")){let o=s.reduce((a,c)=>a+c,0);r.set(i,o);continue}for(let o=0;o<s.length;o++)r.set(`${i}_${o}`,s[o])}else r.set(i,s[0]);return new S(r)}},re=class{static isSurrogate(e){let t=e.charCodeAt(0);return t>=55296&&t<=57343}static isAlphanumeric(e){let t=e.charCodeAt(0);return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122}static isLowerAlpha(e){let t=e.charCodeAt(0);return t>=97&&t<=122}},ne=class{constructor(e,t){this.usableSearchers=void 0,this.usableSearchers=new Map;for(let r of t)e.includes(r.type)&&this.usableSearchers.set(r.type,r)}has(e){return this.usableSearchers.has(e)}minQuality(e){return this.usableSearchers.get(e).minQuality}spec(e){return this.usableSearchers.get(e)}},H=class{constructor(e,t,r){this.matches=void 0,this.query=void 0,this.meta=void 0,this.matches=e,this.query=t,this.meta=r}},p,Q;(function(n){n.Fuzzy="fuzzy",n.Substring="substring",n.Prefix="prefix"})(p||(p={}));var _=class{constructor(e,t){this.type=void 0,this.minQuality=void 0,this.type=e,this.minQuality=Math.max(0,t)}},U=class extends _{constructor(e){super(p.Fuzzy,e)}},B=class extends _{constructor(e){super(p.Substring,e)}},D=class extends _{constructor(e){super(p.Prefix,e)}},I=class{constructor(e,t=10,r=[new U(.3),new B(0),new D(0)]){this.string=void 0,this.topN=void 0,this.searchers=void 0,this.string=e,this.topN=Math.max(0,t),this.searchers=r}},Me=class{constructor(e,t){this.removedEntities=void 0,this.meta=void 0,this.removedEntities=e,this.meta=t}},xe=class{static mergeResults(e,t){let r=e.query,i=this.mergeMatches(e.matches,t.matches,r.topN),s=G.mergeMeta([e.meta,t.meta]);return new H(i,r,s)}static mergeMatches(e,t,r){if(t.length===0)return e;if(e.length===0)return t;let i=[...e,...t];return i.sort((s,o)=>s.quality>o.quality?-1:s.quality<o.quality?1:0),i.length<=r?i:i.slice(0,r)}},Ee=class{constructor(e,t,r){this.maxQueryLength=void 0,this.mainSearcher=void 0,this.secondarySearcher=void 0,this.maxQueryLength=e,this.mainSearcher=t,this.secondarySearcher=r}indexEntities(e,t,r){return this.secondarySearcher.indexEntities([],t,r),this.mainSearcher.indexEntities(e,t,r)}getMatches(e){return e.string?(e.string.length>this.maxQueryLength&&(e=new I(e.string.substring(0,this.maxQueryLength),e.topN,e.searchers)),xe.mergeResults(this.mainSearcher.getMatches(e),this.secondarySearcher.getMatches(e))):new H([],e,new S)}tryGetTerms(e){let t=this.mainSearcher.tryGetTerms(e);return t!==null?t:this.secondarySearcher.tryGetTerms(e)}getTerms(){return this.mainSearcher.getTerms().concat(this.secondarySearcher.getTerms())}tryGetEntity(e){var t,r;return(t=(r=this.mainSearcher.tryGetEntity(e))!=null?r:this.secondarySearcher.tryGetEntity(e))!=null?t:null}getEntities(){return this.mainSearcher.getEntities().concat(this.secondarySearcher.getEntities())}removeEntities(e){let t=[];for(let i=0,s=e.length;i<s;i++)(this.mainSearcher.removeEntity(e[i])||this.secondarySearcher.removeEntity(e[i]))&&t.push(e[i]);let r=new S;return new Me(t,r)}upsertEntities(e,t,r){let i=[],s=[];for(let o=0,a=e.length;o<a;o++){let c=e[o],l=t(c);this.tryUpdate(c,l,r)||(i.push(l),s.push(c))}return this.removeEntities(i),s.length>0?this.reindexSecondarySearcher(s,t,r):new S}reindexSecondarySearcher(e,t,r){let i=this.secondarySearcher.getEntities().concat(e);return this.secondarySearcher.indexEntities(i,t,r)}tryUpdate(e,t,r){return this.tryUpdateSearcher(e,t,r,this.mainSearcher)||this.tryUpdateSearcher(e,t,r,this.secondarySearcher)}tryUpdateSearcher(e,t,r,i){let s=i.tryGetTerms(t);if(s===null)return!1;if(this.termsAreEqual(s,r(e))){if(!i.replaceEntity(t,e,t))throw new Error(`Entity with id ${t} was not present.`);return!0}return!1}termsAreEqual(e,t){return e===t||e!=null&&t!=null&&e.length===t.length&&e.every((r,i)=>r===t[i])}removeEntity(e){return this.mainSearcher.removeEntity(e)||this.secondarySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.mainSearcher.replaceEntity(e,t,r)||this.secondarySearcher.replaceEntity(e,t,r)}save(e){this.mainSearcher.save(e),this.secondarySearcher.save(e)}load(e){this.mainSearcher.load(e),this.secondarySearcher.load(e)}},Ce=class{constructor(e){this.dynamicSearcher=void 0,this.dynamicSearcher=e}removeEntities(e){let t=performance.now(),r=this.dynamicSearcher.removeEntities(e),i=Math.round(performance.now()-t);return r.meta.add("removalDuration",i),r}upsertEntities(e,t,r){let i=performance.now(),s=this.dynamicSearcher.upsertEntities(e,t,r),o=Math.round(performance.now()-i);return s.add("upsertDuration",o),s}indexEntities(e,t,r){let i=performance.now(),s=this.dynamicSearcher.indexEntities(e,t,r),o=Math.round(performance.now()-i);return s.add("indexingDurationTotal",o),s}getMatches(e){let t=performance.now(),r=this.dynamicSearcher.getMatches(e),i=Math.round(performance.now()-t);return r.meta.add("queryDuration",i),r}tryGetEntity(e){return this.dynamicSearcher.tryGetEntity(e)}getEntities(){return this.dynamicSearcher.getEntities()}tryGetTerms(e){return this.dynamicSearcher.tryGetTerms(e)}getTerms(){return this.dynamicSearcher.getTerms()}removeEntity(e){return this.dynamicSearcher.removeEntity(e)}replaceEntity(e,t,r){return this.dynamicSearcher.replaceEntity(e,t,r)}save(e){this.dynamicSearcher.save(e)}load(e){this.dynamicSearcher.load(e)}},Le=class{constructor(e,t,r){this.entity=void 0,this.quality=void 0,this.matchedString=void 0,this.entity=e,this.quality=t,this.matchedString=r}},Pe=class{constructor(e){this.query=void 0,this.matchedIndexes=new Set,this.matches=[],this.meta=[],this.query=e}},W=class{constructor(e,t=0,r){this.string=void 0,this.minQuality=void 0,this.searcherType=void 0,this.string=e,this.minQuality=Math.max(0,Math.min(1,t)),this.searcherType=r}},ke=class{constructor(e,t){this.stringSearcher=void 0,this.searcherTypes=void 0,this.entities=void 0,this.idToIndex=void 0,this.terms=void 0,this.termIndexToEntityIndex=void 0,this.entityIndexToFirstTermIndex=void 0,this.searchersAndQualityOffsets=[{searcherType:p.Prefix,qualityOffset:2},{searcherType:p.Substring,qualityOffset:1},{searcherType:p.Fuzzy,qualityOffset:0}],this.stringSearcher=e,this.searcherTypes=t,this.entities=[],this.idToIndex=new Map,this.terms=[],this.termIndexToEntityIndex=new Int32Array(0),this.entityIndexToFirstTermIndex=new Int32Array(0)}indexEntities(e,t,r){this.entities=[...e],this.idToIndex=new Map,this.terms=[];let i=[],s=[];for(let a=0,c=e.length;a<c;a++){this.idToIndex.set(t(e[a]),a);let l=r(e[a]);s.push(this.terms.length),this.terms.push(...l),i.push(...l.map(()=>a))}this.termIndexToEntityIndex=k.ToInt32Array(i),this.entityIndexToFirstTermIndex=k.ToInt32Array(s);let o=this.stringSearcher.index(this.terms);return o.add("numberOfEntities",this.entities.length),o.add("numberOfTerms",this.terms.length),o}getMatches(e){let t=new Pe(e),r=new ne(this.searcherTypes,e.searchers);for(let{searcherType:s,qualityOffset:o}of this.searchersAndQualityOffsets){if(e.topN==t.matches.length)break;r.has(s)&&this.addMatchesFromSearcher(t,r.spec(s),o)}let i=G.mergeMeta(t.meta);return new H(t.matches,e,i)}addMatchesFromSearcher(e,t,r){let i=Math.max(0,t.minQuality-r);if(i>1)return;let s=new W(e.query.string,i,t.type),o=this.stringSearcher.getMatches(s);this.addMatchesFromResult(e,o,r)}addMatchesFromResult(e,t,r){if(e.meta.push(t.meta),e.query.topN!==0)for(let i=0,s=t.matches.length;i<s;i++){let o=t.matches[i],a=this.termIndexToEntityIndex[o.index];if(!e.matchedIndexes.has(a)&&this.entities[a]!==null&&(e.matchedIndexes.add(a),e.matches.push(new Le(this.entities[a],o.quality+r,this.terms[o.index])),e.matches.length===e.query.topN))break}}tryGetEntity(e){let t=this.idToIndex.get(e);return t===void 0?null:this.entities[t]}getEntities(){return this.entities.filter(e=>e!==null)}tryGetTerms(e){let t=this.idToIndex.get(e);return t===void 0?null:this.terms.slice(this.entityIndexToFirstTermIndex[t],t===this.entities.length-1?this.terms.length:this.entityIndexToFirstTermIndex[t+1])}getTerms(){let e=[];for(let t=0,r=this.termIndexToEntityIndex.length;t<r;t++)this.entities[this.termIndexToEntityIndex[t]]!==null&&e.push(this.terms[t]);return e}removeEntity(e){let t=this.idToIndex.get(e);return t!==void 0&&(this.entities[t]=null,this.idToIndex.delete(e),!0)}replaceEntity(e,t,r){let i=this.idToIndex.get(e);return i!==void 0&&(this.entities[i]=t,this.idToIndex.delete(e),this.idToIndex.set(r,i),!0)}save(e){e.add(this.entities),e.add(this.idToIndex),e.add(this.terms),e.add(this.termIndexToEntityIndex),e.add(this.entityIndexToFirstTermIndex),this.stringSearcher.save(e)}load(e){this.entities=e.get(),this.idToIndex=e.get(),this.terms=e.get(),this.termIndexToEntityIndex=e.get(),this.entityIndexToFirstTermIndex=e.get(),this.stringSearcher.load(e)}},C=class{constructor(e,t){this.strings=void 0,this.meta=void 0,this.strings=e,this.meta=t}},He=class{constructor(e,t){this.treatCharacterAsSpace=void 0,this.allowCharacter=void 0,this.numberOfSurrogateCharacters=0,this.treatCharacterAsSpace=e,this.allowCharacter=t}normalize(e){let t=new Array(e.length),r=0,i=!1,s=!1;for(let o=0,a=e.length;o<a;o++){let c=this.getNormalizedCharacter(e[o]);c!==""&&(c===" "?i=!0:(i&&s&&(t[r++]=" "),t[r++]=c,s=!0,i=!1))}return s?t.join(""):""}getNormalizedCharacter(e){return e===" "||this.treatCharacterAsSpace(e)?" ":this.isSurrogate(e)||!this.allowCharacter(e)?"":e.toLowerCase()}isSurrogate(e){return!!re.isSurrogate(e)&&(this.numberOfSurrogateCharacters++,!0)}normalizeBulk(e){this.numberOfSurrogateCharacters=0;let t=e.map(i=>this.normalize(i)),r=new S;return r.add("numberOfSurrogateCharacters",this.numberOfSurrogateCharacters),new C(t,r)}},Ie=class{constructor(e){this.normalizationFunction=void 0,this.normalizationFunction=e}normalize(e){return this.normalizationFunction(e)}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new C(t,new S)}},Re=class{constructor(e){this.normalizers=void 0,this.normalizers=e}normalize(e){for(let t=0,r=this.normalizers.length;t<r;t++)e=this.normalizers[t].normalize(e);return e}normalizeBulk(e){let t=new S;for(let r=0,i=this.normalizers.length;r<i;r++){let s=this.normalizers[r].normalizeBulk(e);e=s.strings;for(let o of s.meta.allEntries)t.add(o[0],o[1])}return new C(e,t)}},Ae=class{normalize(e){return e||""}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new C(t,new S)}},Be=class{constructor(e,t){this.normalizeVariationsAndInput=void 0,this.replacements=void 0,this.normalizeVariationsAndInput=t,this.replacements=[];for(let r of e){let i=new Map;for(let[s,o]of r)for(let a of o){let c=t(a);i.set(c,s)}this.replacements.push(i)}}normalize(e){e=this.normalizeVariationsAndInput(e);let t=new Array(e.length),r=0;for(let i=0,s=e.length;i<s;i++)for(let o of this.replacements){let a=o.get(e[i]);if(a!==void 0){t[r++]=a;break}t[r++]=e[i]}return t.join("")}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new C(t,new S)}},De=class{static create(e){let t=new Ae,r=new Be(e.replacements,o=>o.toLowerCase().normalize("NFKC")),i=new Ie(o=>o.normalize("NFKD")),s=new He(e.treatCharacterAsSpace,e.allowCharacter);return new Re([t,r,i,s])}},j=class{constructor(e,t){this.index=void 0,this.quality=void 0,this.index=e,this.quality=t}},T=class{constructor(e,t,r){this.matches=void 0,this.query=void 0,this.meta=void 0,this.matches=e,this.query=t,this.meta=r}},Fe=class{constructor(e){this.stringSearcher=void 0,this.distinctMapping=void 0,this.sortMapping=void 0,this.stringSearcher=e,this.distinctMapping=new Int32Array(0),this.sortMapping=new Int32Array(0)}index(e){let t=e.map((c,l)=>({term:c,index:l}));t.sort((c,l)=>c.term<l.term?-1:c.term>l.term?1:0),this.sortMapping=new Int32Array(t.length);for(let c=0,l=t.length;c<l;c++)this.sortMapping[c]=t[c].index;let r=[],i=[],s=0,o=null;for(let c=0,l=t.length;c<l;c++){let h=t[c].term;h!=o&&(r[s]=h,i[s]=c,s++),o=h}i[s++]=t.length,this.distinctMapping=k.ToInt32Array(i);let a=this.stringSearcher.index(r);return a.add("numberOfDistinctTerms",r.length),a}getMatches(e){let t=this.stringSearcher.getMatches(e),r=new Array(t.matches.length),i=0;return t.matches.forEach(s=>{let o=this.distinctMapping[s.index+1];for(let a=this.distinctMapping[s.index];a<o;a++)r[i++]=new j(this.sortMapping[a],s.quality)}),new T(r,e,t.meta)}save(e){e.add(this.distinctMapping),e.add(this.sortMapping),this.stringSearcher.save(e)}load(e){this.distinctMapping=e.get(),this.sortMapping=e.get(),this.stringSearcher.load(e)}},ze=class{constructor(e,t){this.entitySearcher=void 0,this.searcherTypes=void 0,this.entitySearcher=e,this.searcherTypes=t}indexEntities(e,t,r){return this.entitySearcher.indexEntities(e,t,r)}getMatches(e){let t=new ne(this.searcherTypes,e.searchers);if(e.topN>200)return this.entitySearcher.getMatches(e);if(e.string.length<=3&&t.has(p.Prefix)&&t.minQuality(p.Prefix)<2.2){let r=new I(e.string,e.topN,[new D(2.3)]),i=this.entitySearcher.getMatches(r);if(i.matches.length==e.topN)return new H(i.matches,e,i.meta)}if(e.string.length<=3&&!t.has(p.Prefix)&&t.has(p.Substring)&&t.minQuality(p.Substring)<1.2){let r=new I(e.string,e.topN,[new B(1.3)]),i=this.entitySearcher.getMatches(r);if(i.matches.length==e.topN)return new H(i.matches,e,i.meta)}return this.entitySearcher.getMatches(e)}tryGetEntity(e){return this.entitySearcher.tryGetEntity(e)}getEntities(){return this.entitySearcher.getEntities()}tryGetTerms(e){return this.entitySearcher.tryGetTerms(e)}getTerms(){return this.entitySearcher.getTerms()}removeEntity(e){return this.entitySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.entitySearcher.replaceEntity(e,t,r)}save(e){return this.entitySearcher.save(e)}load(e){return this.entitySearcher.load(e)}},ie=class{constructor(){this.ids=void 0,this.frequencies=void 0,this.ids=[],this.frequencies=[]}addId(e,t){this.ids.push(e),this.frequencies.push(t)}seal(){this.ids=k.ToInt32Array(this.ids),this.frequencies=k.ToInt32Array(this.frequencies)}get length(){return this.ids.length}save(e){e.add(this.ids),e.add(this.frequencies)}load(e){this.ids=e.get(),this.frequencies=e.get()}},O=class{constructor(){this.ngramToTermIds=void 0,this.ngramToTermIds=new Map}add(e,t,r){let i=this.ngramToTermIds.get(e);i||(i=new ie,this.ngramToTermIds.set(e,i)),i.addId(t,r)}seal(){for(let e of this.ngramToTermIds.values())e.seal()}getIds(e){return this.ngramToTermIds.get(e)}get size(){return this.ngramToTermIds.size}save(e){e.add(this.ngramToTermIds.size);for(let[t,r]of this.ngramToTermIds)e.add(t),r.save(e)}load(e){let t=e.get();for(let r=0;r<t;r++){let i=e.get(),s=new ie;s.load(e),this.ngramToTermIds.set(i,s)}}},Ne=class{static ComputeJaccardCoefficient(e,t,r){return r/(e+t-r)}static ComputeOverlapMaxCoefficient(e,t,r){return r/Math.max(e,t)}},qe=class{constructor(e){this.ngramComputer=void 0,this.invertedIndex=void 0,this.numberOfNgrams=void 0,this.commonNgramCounts=void 0,this.ngramComputer=e,this.invertedIndex=new O,this.numberOfNgrams=new Int32Array(0),this.commonNgramCounts=new Int32Array(0)}index(e){let t=performance.now();this.invertedIndex=new O,this.commonNgramCounts=new Int32Array(e.length),this.numberOfNgrams=new Int32Array(e.length);let r=0;for(let o=0,a=e.length;o<a;o++){let c=e[o];if(!this.isValidTerm(c)){this.numberOfNgrams[o]=0,r++;continue}let l=this.ngramComputer.computeNgrams(c);this.numberOfNgrams[o]=l.length;let h=this.getNgramsToFrequency(l);for(let[u,m]of h)this.invertedIndex.add(u,o,m)}this.invertedIndex.seal();let i=Math.round(performance.now()-t),s=new S;return s.add("numberOfInvalidTerms",r),s.add("indexingDurationFuzzySearcher",i),s}isValidTerm(e){return e!=null&&e.trim()!==""}getMatches(e){if(this.invertedIndex.size===0)return new T([],e,new S);let t=this.ngramComputer.computeNgrams(e.string),r=this.getNgramsToFrequency(t),i=t.length;this.computeCommonNgramCounts(r);let s=this.getMatchesFromCommonNgrams(i,e.minQuality);return new T(s,e,new S)}computeCommonNgramCounts(e){this.commonNgramCounts.fill(0);for(let[t,r]of e){let i=this.invertedIndex.getIds(t);if(i!=null)for(let s=0,o=i.length;s<o;s++)this.commonNgramCounts[i.ids[s]]+=Math.min(r,i.frequencies[s])}}getNgramsToFrequency(e){let t=new Map;for(let r=0,i=e.length;r<i;r++){let s=e[r],o=t.get(s);t.set(s,o!==void 0?o+1:1)}return t}getMatchesFromCommonNgrams(e,t){let r=[];for(let i=0,s=this.numberOfNgrams.length;i<s;i++){let o=Ne.ComputeOverlapMaxCoefficient(e,this.numberOfNgrams[i],this.commonNgramCounts[i]);o>t&&r.push(new j(i,o))}return r}save(e){this.invertedIndex.save(e),e.add(this.numberOfNgrams)}load(e){this.invertedIndex=new O,this.invertedIndex.load(e),this.numberOfNgrams=e.get(),this.commonNgramCounts=new Int32Array(this.numberOfNgrams.length)}},$e=class{constructor(e,t){this.stringSearcher=void 0,this.penaltyFactor=void 0,this.hashCodes=void 0,this.stringSearcher=e,this.penaltyFactor=1-t,this.hashCodes=new Int32Array(0)}index(e){this.hashCodes=new Int32Array(e.length);for(let t=0,r=e.length;t<r;t++)this.hashCodes[t]=te.getHashCode(e[t]);return this.stringSearcher.index(e)}getMatches(e){let t=te.getHashCode(e.string),r=this.stringSearcher.getMatches(e),i=r.matches.map(s=>this.penalizeMatch(s,t)).filter(s=>s.quality>=e.minQuality);return new T(i,r.query,r.meta)}penalizeMatch(e,t){return e.quality*=this.hashCodes[e.index]===t?1:this.penaltyFactor,e}save(e){e.add(this.hashCodes),this.stringSearcher.save(e)}load(e){this.hashCodes=e.get(),this.stringSearcher.load(e)}},Oe=class{constructor(e,t){this.ngramN=void 0,this.transformNgram=void 0,this.ngramN=e,this.transformNgram=t??(r=>r)}computeNgrams(e){if(e.length===0)return[];if(e.length<=this.ngramN){let r=this.transformNgram(e);return r?[r]:[]}let t=[];for(let r=0,i=this.maximumNumberOfNgrams(e);r<i;r++){let s=this.transformNgram(e.substring(r,r+this.ngramN));s&&t.push(s)}return t}maximumNumberOfNgrams(e){return Math.max(e.length-this.ngramN+1,e.length>0?1:0)}},Ge=class{constructor(e,t,r){this.paddingLeft=void 0,this.paddingRight=void 0,this.paddingMiddle=void 0,this.paddingLeft=e,this.paddingRight=t,this.paddingMiddle=r}normalize(e){return e&&`${this.paddingLeft}${e.split(" ").join(this.paddingMiddle)}${this.paddingRight}`}normalizeBulk(e){let t=e.map(i=>this.normalize(i)),r=new S;return new C(t,r)}},se=class{};se.Value=new Map([["a",["\u1D8F","\u2C65","\u0251","\u1D00","\u0250","\u0252"]],["aa",["\xE5","\uA733"]],["ae",["\xE4","\xE6","\u1D01","\u1D2D","\u1D46","\u01FD","\u01E3","\u1D02"]],["ao",["\uA735"]],["au",["\uA737"]],["av",["\uA739","\uA73B"]],["ay",["\uA73D"]],["b",["\u0180","\u0253","\u0183","\u1D6C","\u1D80","\u0299"]],["c",["\u023C","\u0188","\u0255","\u1D04","\uA73F","\u2184"]],["d",["\u0111","\xF0","\u0256","\u0257","\u018C","\u1D6D","\u1D81","\u1D91","\u0221","\u1D05","\uA77A"]],["db",["\u0238"]],["e",["\u1D92","\u0247","\u2C78","\u1D07","\u0259","\u01DD","\u025B"]],["eo",["\u1D14"]],["f",["\u0192","\u1D6E","\u1D82","\uA730","\uA77C"]],["g",["\u01E5","\u0260","\u1D83","\u0262","\u021D","\u014B","\uA7A1","\u1D79","\uA77F"]],["h",["\u0127","\u2C68","\u0266","\u029C","\u0303","\u0267","\u2C76","\u0265"]],["hv",["\u0195"]],["i",["\u0268","\u1D7B","\u1D96","\u0131","\u026A","\u0269"]],["j",["\u0249","\u0237","\u029D","\u025F","\u0284","\u1D0A"]],["k",["\u0199","\u2C6A","\u1D84","\uA741","\u1D0B","\uA743","\uA745","\uA7A3"]],["l",["\u0142","\u019A","\u2C61","\u026B","\u026C","\u1D85","\u026D","\u0234","\u029F","\uA749","\uA781","\uA747"]],["m",["\u1D6F","\u1D86","\u0271","\u1D0D","\u026F"]],["n",["\u0272","\u019E","\u1D70","\u1D87","\u0273","\u0235","\u0274","\uA791","\uA7A5"]],["o",["\xF8","\u01FF","\u0275","\u0254","\u2C7A","\u1D0F","\uA74B","\uA74D"]],["oe",["\xF6","\u0153"]],["oi",["\u01A3"]],["oo",["\uA74F"]],["ou",["\u0223"]],["p",["\u1D7D","\u01A5","\u1D71","\u1D88","\u1D18","\u01BF","\uA751","\uA753","\uA755"]],["q",["\u024B","\u02A0","\uA757","\uA759"]],["qp",["\u0239"]],["r",["\u024D","\u027D","\uA75B","\u1D72","\u1D89","\u027C","\u027E","\u1D73","\u0280","\u0279","\u0281","\uA7A7","\uA783"]],["s",["\u1D74","\u1D8A","\u0282","\u023F","\uA731","\u0283","\uA7A9","\uA785","\u017F"]],["ss",["\xDF"]],["t",["\u0167","\u2C66","\u01AD","\u0288","\u1D75","\u01AB","\u0236","\u1D1B","\uA787"]],["th",["\xFE"]],["tz",["\uA729"]],["u",["\u0289","\u028A","\u1D7E","\u1D1C","\u1D99"]],["ue",["\xFC","\u1D6B"]],["v",["\u028B","\u1D8C","\u2C71","\u2C74","\u1D20","\u028C","\uA75F"]],["vy",["\uA761"]],["w",["\u2C73","\u1D21","\u028D"]],["x",["\u1D8D"]],["y",["\u024F","\u01B4","\u028F","\u1EFF"]],["z",["\u01B6","\u0225","\u2C6C","\u1D76","\u1D8E","\u0290","\u0291","\u0240","\u1D22","\u0292","\u01B9","\uA763"]]]);var oe=class n{constructor(e,t,r){this.replacements=void 0,this.treatCharacterAsSpace=void 0,this.allowCharacter=void 0,this.replacements=e,this.treatCharacterAsSpace=t,this.allowCharacter=r}static createDefaultConfig(){let e=new Set(["_","-","\u2013","/",","," "]);return new n([se.Value],t=>e.has(t),t=>re.isAlphanumeric(t))}},ae=class{constructor(e,t,r="normalizationDuration"){this.stringSearcher=void 0,this.normalizer=void 0,this.normalizationDurationMetaKey=void 0,this.stringSearcher=e,this.normalizer=t,this.normalizationDurationMetaKey=r}index(e){let t=performance.now(),r=this.normalizer.normalizeBulk(e),i=Math.round(performance.now()-t),s=this.stringSearcher.index(r.strings);s.add(this.normalizationDurationMetaKey,i);for(let o of r.meta.allEntries)s.add(o[0],o[1]);return s}getMatches(e){let t=new W(this.normalizer.normalize(e.string),e.minQuality,e.searcherType),r=this.stringSearcher.getMatches(t);return new T(r.matches,e,r.meta)}save(e){this.stringSearcher.save(e)}load(e){this.stringSearcher.load(e)}},Qe=class{constructor(e){this.suffixArraySearcher=void 0,this.suffixArraySearcher=e}index(e){return this.suffixArraySearcher.index(e)}getMatches(e){if(!e.string)return new T([],e,new S);let t=this.modifyQueryString(e.string),r=new W(t,e.minQuality,e.searcherType);return this.suffixArraySearcher.getMatches(r,e.string.length)}modifyQueryString(e){return`${this.suffixArraySearcher.separator}${e}`}save(e){this.suffixArraySearcher.save(e)}load(e){this.suffixArraySearcher.load(e)}},_e=class{constructor(e,t,r){this.prefixSearcher=void 0,this.substringSearcher=void 0,this.fuzzySearcher=void 0,this.prefixSearcher=e,this.substringSearcher=t,this.fuzzySearcher=r}index(e){let t=[];if(this.prefixSearcher&&!this.substringSearcher){let r=this.prefixSearcher.index(e);t.push(r)}if(this.substringSearcher){let r=this.substringSearcher.index(e);t.push(r)}if(this.fuzzySearcher){let r=this.fuzzySearcher.index(e);t.push(r)}return G.mergeMeta(t)}getMatches(e){if(!e.searcherType)throw new Error("SearcherSwitch requires a searcher type.");switch(e.searcherType){case p.Prefix:if(!this.prefixSearcher)throw new Error("No prefix searcher has been indexed.");return this.prefixSearcher.getMatches(e);case p.Substring:if(!this.substringSearcher)throw new Error("No substring searcher has been indexed.");return this.substringSearcher.getMatches(e);case p.Fuzzy:if(!this.fuzzySearcher)throw new Error("No fuzzy searcher has been indexed.");return this.fuzzySearcher.getMatches(e);default:throw new Error(`Unknown searcher type: ${e.searcherType}`)}}save(e){this.prefixSearcher&&!this.substringSearcher&&this.prefixSearcher.save(e),this.substringSearcher&&this.substringSearcher.save(e),this.fuzzySearcher&&this.fuzzySearcher.save(e)}load(e){this.prefixSearcher&&!this.substringSearcher&&this.prefixSearcher.load(e),this.substringSearcher&&this.substringSearcher.load(e),this.fuzzySearcher&&this.fuzzySearcher.load(e)}};(function(n){n.QualityAndIndex="qualityAndIndex",n.QualityAndMatchedString="qualityAndMatchedString"})(Q||(Q={}));var Ue=class{constructor(e,t){this.sortOrder=void 0,this.entitySearcher=void 0,this.collator=new Intl.Collator(void 0,{numeric:!0}),this.sortOrder=e,this.entitySearcher=t}indexEntities(e,t,r){return this.entitySearcher.indexEntities(e,t,r)}getMatches(e){let t=this.entitySearcher.getMatches(e);switch(this.sortOrder){case Q.QualityAndIndex:return t;case Q.QualityAndMatchedString:return this.sortMatchesByQualityAndMatchedString(t.matches),t;default:throw new Error(`Unsupported sort order: ${this.sortOrder}`)}}sortMatchesByQualityAndMatchedString(e){e.sort((t,r)=>t.quality>r.quality?-1:t.quality<r.quality?1:this.collator.compare(t.matchedString,r.matchedString))}tryGetEntity(e){return this.entitySearcher.tryGetEntity(e)}getEntities(){return this.entitySearcher.getEntities()}tryGetTerms(e){return this.entitySearcher.tryGetTerms(e)}getTerms(){return this.entitySearcher.getTerms()}save(e){this.entitySearcher.save(e)}load(e){this.entitySearcher.load(e)}removeEntity(e){return this.entitySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.entitySearcher.replaceEntity(e,t,r)}},We=class{constructor(e){this.stringSearcher=void 0,this.stringSearcher=e}index(e){return this.stringSearcher.index(e)}getMatches(e){let t=this.stringSearcher.getMatches(e);return t.matches.sort(this.compareMatchesByQualityAndIndex),t}compareMatchesByQualityAndIndex(e,t){return e.quality>t.quality?-1:e.quality<t.quality?1:e.index<t.index?-1:e.index>t.index?1:0}save(e){this.stringSearcher.save(e)}load(e){this.stringSearcher.load(e)}},V=class{static compareOrdinal(e,t,r,i,s){let o=Math.min(t+s,e.length),a=Math.min(i+s,r.length),c=t,l=i;for(;c<o&&l<a;){let m=e.charCodeAt(c),g=r.charCodeAt(l);if(m<g)return-1;if(m>g)return 1;c++,l++}let h=o-t,u=a-i;return h===u?0:h<u?-1:1}},je=class n{static create(e){if(e==null)throw new Error("Input string cannot be null.");let t=new n(e);return t.FormInitialChains(),t.BuildSufixArray(),t.sa}constructor(e){this.inputString=void 0,this.eoc=2147483647,this.sa=void 0,this.isa=void 0,this.chainHeadsDict=void 0,this.chainStack=[],this.subChains=[],this.nextRank=1,this.inputString=e;let t=e.length;this.sa=new Int32Array(t),this.isa=new Int32Array(t),this.chainHeadsDict=new Map}FormInitialChains(){this.FindInitialChains(),this.SortAndPushSubchains()}FindInitialChains(){for(let e=0;e<this.inputString.length;e++){let t=this.inputString.charCodeAt(e),r=this.chainHeadsDict.get(t);this.isa[e]=r!==void 0?r:this.eoc,this.chainHeadsDict.set(t,e)}for(let e of this.chainHeadsDict.values()){let t=new ce(e,1);this.subChains.push(t)}}BuildSufixArray(){for(;this.chainStack.length>0;){let e=this.chainStack.pop();this.isa[e.head]===this.eoc?this.RankSuffix(e.head):this.RefineChainWithInductionSorting(e)}}RankSuffix(e){this.isa[e]=-this.nextRank,this.sa[this.nextRank-1]=e,this.nextRank++}RefineChainWithInductionSorting(e){let t=[];for(this.chainHeadsDict.clear(),this.subChains=[];e.head!==this.eoc;){let r=this.isa[e.head];if(e.head+e.length>this.inputString.length-1)this.RankSuffix(e.head);else if(this.isa[e.head+e.length]<0){let i=new Ve(e.head,-this.isa[e.head+e.length]);t.push(i)}else this.ExtendChain(e);e.head=r}this.SortAndPushSubchains(),this.SortAndRankNotedSuffixes(t)}ExtendChain(e){let t=this.inputString.charCodeAt(e.head+e.length);if(this.chainHeadsDict.has(t))this.isa[this.chainHeadsDict.get(t)]=e.head,this.isa[e.head]=this.eoc;else{this.isa[e.head]=this.eoc;let r=new ce(e.head,e.length+1);this.subChains.push(r)}this.chainHeadsDict.set(t,e.head)}SortAndRankNotedSuffixes(e){e.sort((t,r)=>t.rank-r.rank);for(let t=0;t<e.length;t++)this.RankSuffix(e[t].head)}SortAndPushSubchains(){this.subChains.sort((e,t)=>{let r=Math.min(e.length,t.length);return V.compareOrdinal(this.inputString,e.head,this.inputString,t.head,r)});for(let e=this.subChains.length-1;e>=0;e--)this.chainStack.push(this.subChains[e])}},Ve=class{constructor(e,t){this.head=void 0,this.rank=void 0,this.head=e,this.rank=t}},ce=class{constructor(e,t){this.head=void 0,this.length=void 0,this.head=e,this.length=t}},Ye=class{constructor(e){this.separator=void 0,this.str=void 0,this.suffixArray=void 0,this.indexToTermIndex=void 0,this.termLengths=void 0,this.separator=e,this.str="",this.suffixArray=new Int32Array(0),this.indexToTermIndex=new Int32Array(0),this.termLengths=new Int32Array(0)}index(e){let t=performance.now();this.str=e.length>0?this.separator+e.join(this.separator)+this.separator:"",this.suffixArray=je.create(this.str),this.indexToTermIndex=new Int32Array(this.suffixArray.length),this.termLengths=new Int32Array(e.length);let r=0;for(let o=0;o<e.length;o++){this.termLengths[o]=e[o].length;for(let a=0;a<=e[o].length;a++)this.indexToTermIndex[r++]=o}this.indexToTermIndex[r++]=-1;let i=Math.round(performance.now()-t),s=new S;return s.add("indexingDurationSuffixArraySearcher",i),s}getMatches(e,t){if(!e.string)return new T([],e,new S);let[r,i]=this.GetPositionsInSuffixArray(e.string),s=new Int32Array(i-r),o=new Set,a=0;for(let h=r;h<i;h++){let u=this.indexToTermIndex[this.suffixArray[h]];o.has(u)||(o.add(u),s[a++]=u)}let c=[];t=t??e.string.length;let l=0;for(let h=0;h<a;h++)l=this.computeQuality(t,this.termLengths[s[h]]),l>e.minQuality&&c.push(new j(s[h],l));return new T(c,e,new S)}computeQuality(e,t){return e/t}GetPositionsInSuffixArray(e){let t=0,r=this.suffixArray.length,i=0;for(;t<r;)i=Math.floor((t+r)/2),V.compareOrdinal(e,0,this.str,this.suffixArray[i],e.length)>0?t=i+1:r=i;let s=t;for(r=this.suffixArray.length;t<r;)i=Math.floor((t+r)/2),V.compareOrdinal(e,0,this.str,this.suffixArray[i],e.length)==0?t=i+1:r=i;return[s,r]}save(e){e.add(this.str),e.add(this.suffixArray),e.add(this.indexToTermIndex),e.add(this.termLengths)}load(e){this.str=e.get(),this.suffixArray=e.get(),this.indexToTermIndex=e.get(),this.termLengths=e.get()}},le=class{static createSearcher(e){let t=this.createDefaultNormalizer(e),r=this.tryCreateFuzzySearcher(e),i=this.tryCreateSubstringSearcher(e),s=this.tryCreatePrefixSearcher(e,i),o=new _e(s,i,r);o=new Fe(o),o=new We(o),o=new ae(o,t,"normalizationDurationDefault");let a=new ke(o,e.searcherTypes);return a=new ze(a,e.searcherTypes),a=new Ue(e.sortOrder,a),a}static createDefaultNormalizer(e){let t=new Set;e.fuzzySearchConfig&&(e.fuzzySearchConfig.paddingLeft.split("").forEach(i=>t.add(i)),e.fuzzySearchConfig.paddingRight.split("").forEach(i=>t.add(i)),e.fuzzySearchConfig.paddingMiddle.split("").forEach(i=>t.add(i))),e.substringSearchConfig&&e.substringSearchConfig.suffixArraySeparator.split("").forEach(i=>t.add(i));let r=new oe(e.normalizerConfig.replacements,e.normalizerConfig.treatCharacterAsSpace,i=>e.normalizerConfig.allowCharacter(i)&&!t.has(i));return De.create(r)}static tryCreateFuzzySearcher(e){if(!e.searcherTypes.includes(p.Fuzzy))return null;if(e.fuzzySearchConfig===void 0)throw new Error("Unable to create fuzzy searcher: No fuzzy search config provided.");return this.createFuzzySearcher(e.fuzzySearchConfig)}static createFuzzySearcher(e){let t=new Oe(e.ngramN,e.transformNgram),r=new Ge(e.paddingLeft,e.paddingRight,e.paddingMiddle),i=new qe(t);return i=new $e(i,e.inequalityPenalty),i=new ae(i,r,"normalizationDurationNgrams"),i}static tryCreateSubstringSearcher(e){if(!e.searcherTypes.includes(p.Substring))return null;if(e.substringSearchConfig===void 0)throw new Error("Unable to create substring searcher: No substring search config provided.");return this.createSubstringSearcher(e.substringSearchConfig)}static createSubstringSearcher(e){return new Ye(e.suffixArraySeparator)}static tryCreatePrefixSearcher(e,t){if(!e.searcherTypes.includes(p.Prefix))return null;if(e.substringSearchConfig===void 0)throw new Error("Unable to create prefix searcher: No substring search config provided.");return this.createPrefixSearcher(e.substringSearchConfig,t)}static createPrefixSearcher(e,t){return t===null&&(t=this.createSubstringSearcher(e)),new Qe(t)}},Ke=class n{constructor(e,t,r,i,s,o){this.paddingLeft=void 0,this.paddingRight=void 0,this.paddingMiddle=void 0,this.ngramN=void 0,this.transformNgram=void 0,this.inequalityPenalty=void 0,this.paddingLeft=e,this.paddingRight=t,this.paddingMiddle=r,this.ngramN=i,this.transformNgram=s,this.inequalityPenalty=o}static createDefaultConfig(){return new n("$$","!","!$$",3,e=>e.endsWith("$")?null:e.indexOf("$")===-1?e.split("").sort().join(""):e,.05)}};var Je=class n{constructor(e){this.suffixArraySeparator=void 0,this.suffixArraySeparator=e}static createDefaultConfig(){return new n("$")}},Xe=class n{constructor(e,t,r,i,s,o){this.searcherTypes=void 0,this.maxQueryLength=void 0,this.sortOrder=void 0,this.normalizerConfig=void 0,this.fuzzySearchConfig=void 0,this.substringSearchConfig=void 0,this.searcherTypes=e,this.maxQueryLength=t,this.sortOrder=r,this.normalizerConfig=i,this.fuzzySearchConfig=s,this.substringSearchConfig=o}static createDefaultConfig(){let e=[p.Fuzzy,p.Substring,p.Prefix],t=Q.QualityAndMatchedString,r=oe.createDefaultConfig(),i=Ke.createDefaultConfig(),s=Je.createDefaultConfig();return new n(e,150,t,r,i,s)}},he=class{static createSearcher(e){let t=le.createSearcher(e),r=le.createSearcher(e),i=new Ee(e.maxQueryLength,t,r);return i=new Ce(i),i}static createDefaultSearcher(){let e=Xe.createDefaultConfig();return this.createSearcher(e)}};function Y(n,e){if(n.length===0)return null;let t=n.find(i=>i.sourceStart<=e&&e<=i.sourceEnd);if(t)return t.commentrayLine;if(e<n[0].sourceStart)return n[0].commentrayLine;let r=n[0];for(let i of n)if(i.sourceStart<=e)r=i;else break;return r.commentrayLine}function Ze(n,e){if(n.length===0)return null;let t=n[0];for(let r of n)if(r.commentrayLine<=e)t=r;else break;return t.sourceStart-1}function et(n,e,t,r,i){let s=Math.max(0,e-t),o=Math.max(0,r-i);return s<=0?0:Math.min(1,Math.max(0,n/s))*o}function K(n,e,t,r=5){let i=e+r,s=e+t-r;return n<i?{y:i-e,clipped:"above"}:n>s?{y:s-e,clipped:"below"}:{y:n-e,clipped:"none"}}function cr(n,e,t,r,i={}){let{tension:s=.38,clipStart:o="none",clipEnd:a="none"}=i,l=Math.min(.66,s+.24),h=o==="none"?s:l,u=a==="none"?s:l,m=t-n;return[{x:n,y:e},{x:n+m*h,y:e},{x:t-m*u,y:r},{x:t,y:r}]}function tt(n,e,t,r){return`M ${L(n.x)} ${L(n.y)} C ${L(e.x)} ${L(e.y)} ${L(t.x)} ${L(t.y)} ${L(r.x)} ${L(r.y)}`}function lr(n,e,t,r,i){let s=F(n,e,i),o=F(e,t,i),a=F(t,r,i),c=F(s,o,i),l=F(o,a,i),h=F(c,l,i);return[[n,s,c,h],[h,l,a,r]]}function F(n,e,t){return{x:(1-t)*n.x+t*e.x,y:(1-t)*n.y+t*e.y}}function rt(n,e,t,r,i={}){let{tension:s=.38,clipStart:o="none",clipEnd:a="none",splitT:c=.66}=i,l=cr(n,e,t,r,{tension:s,clipStart:o,clipEnd:a}),[h,u,m,g]=l;if(!(o!=="none"||a!=="none"))return{solid:tt(h,u,m,g)};let[f,b]=lr(h,u,m,g,c),[y,q,E,$]=f,[R,A,ee,be]=b;return{solid:tt(y,q,E,$),dotted:tt(R,A,ee,be)}}function L(n){return n.toFixed(2)}function bt(n){return[...n].sort((e,t)=>e.sourceStart-t.sourceStart)}function wt(n,e){if(n.length===0)return null;let t=Y(n,e);return t===null?null:n.find(i=>i.commentrayLine===t)?.id??null}function nt(n){return Math.max(0,n-1)}function P(n){let e=n.trim();if(e==="")return"";try{let t=atob(e),r=new Uint8Array(t.length);for(let i=0;i<t.length;i++)r[i]=t.charCodeAt(i);return new TextDecoder("utf-8",{fatal:!1}).decode(r)}catch{return""}}function vt(n,e){function t(r){let i=n.getAttribute(r);return i!==null&&i.trim()!==""?i:e.getAttribute(r)?.trim()??""}return{rawCodeB64:t("data-raw-code-b64"),rawMdB64:t("data-raw-md-b64")}}function ue(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Tt(n,e){let t=e.map(r=>r.trim()).filter(Boolean);if(t.length===0)return ue(n);try{let r=t.map(o=>o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`(${r.join("|")})`,"gi");return n.split(i).map((o,a)=>a%2===1?`<mark class="search-hit">${ue(o)}</mark>`:ue(o)).join("")}catch{return ue(n)}}function de(n,e){let t=e.map(c=>c.trim()).filter(Boolean);if(t.length===0)return[];let r=n.toLowerCase(),i=t.map(c=>c.toLowerCase()),s=[],o=0,a=0;for(;o<n.length&&a<400;){let c=o,l=-1,h=!0;for(let u of i){if(u.length===0)continue;let m=r.indexOf(u,c);if(m<0){h=!1;break}l<0&&(l=m),c=m+u.length}if(!h||l<0)break;s.push({start:l,end:c}),a++,o=l+1}return s}function Mt(n,e){let t=Math.max(0,Math.min(e,n.length)),r=0;for(let i=0;i<t;i++)n[i]===`
2
+ `&&r++;return r}function xt(n,e){let t=n.split(`
3
+ `);return e<0||e>=t.length?"":t[e]??""}function me(n){return n.trim().split(/\s+/).filter(Boolean)}function Et(n,e){let t=me(e);return t.length===0?[...n]:n.filter(r=>{let i=r.sourcePath.replace(/\\/g,"/");return de(i,t).length>0})}function Ct(n){let e=new Set,t=new Set,r=[],i=0;for(let s of n){let o=s.sourcePath.trim(),a=s.commentrayPath.trim();if(o.length>0){let c=`${o}\0${a}`;e.has(c)||(e.add(c),r.push({kind:"path",line:i++,text:o,spPath:s.sourcePath,crPath:s.commentrayPath}))}a.length>0&&!t.has(a)&&(t.add(a),r.push({kind:"path",line:i++,text:a,spPath:s.sourcePath,crPath:s.commentrayPath}))}return r}var hr=80;function Lt(n,e=hr){let t=new Map;for(let s of n){let o=s.sourcePath.trim();if(o.length===0)continue;let a=t.get(o),c={sourcePath:s.sourcePath.trim(),commentrayPath:s.commentrayPath.trim()};if(!a){t.set(o,c);continue}c.commentrayPath.localeCompare(a.commentrayPath)<0&&t.set(o,c)}let r=t.size;return{rows:[...t.values()].sort((s,o)=>s.sourcePath.localeCompare(o.sourcePath)).slice(0,e),totalUnique:r}}function w(n){return n.trim().replaceAll("\\","/").replace(/^\.\//,"")}function ur(n){let e=n.indexOf("/browse/");if(e>=0){let r=n.slice(0,e).replace(/\/+$/,"");return r===""?"/":r}let t=n.replace(/\/[^/]*$/,"");return t===""||t==="/"?"/":t.replace(/\/+$/,"")||"/"}var it=/^(?:\.\/)?browse\/([^/?#]+\.html)$/i;function Pt(n){return it.test(n.trim())}function J(n,e,t){let r=n.trim();if(r.startsWith("/"))return`${t}${r}`;let i=it.exec(r);if(i?.[1]){let s=ur(e),o=s==="/"?`/browse/${i[1]}`:`${s}/browse/${i[1]}`;return`${t}${o}`}return new URL(r,`${t}${e}`).href}function kt(n,e,t){let r=n.trim();if(r.length===0)return"";let i=it.exec(r);return i?.[1]?`./browse/${i[1]}`:J(r,e,t)}function st(n,e,t){let r=w(e),i=w(t);if(r.length>0){let s=n.find(o=>w(o.commentrayPath)===r);if(s)return s}if(i.length>0){let s=n.find(o=>w(o.sourcePath)===i);if(s)return s}}function Ht(n,e,t){return w(n.sourcePath)===w(e)&&w(n.commentrayPath)===w(t)}var at="commentray.codeCommentrayStatic.colorTheme",ot=["system","light","dark"];function It(n){let e=ot.indexOf(n),t=(e>=0?e+1:0)%ot.length;return ot[t]??"system"}function ge(n){return n==="light"||n==="dark"||n==="system"?n:"system"}function dr(n){let e=globalThis.document;if(!e)return;let t=e.getElementById("commentray-hljs-light"),r=e.getElementById("commentray-hljs-dark");if(!(!(t instanceof HTMLLinkElement)||!(r instanceof HTMLLinkElement))){if(n==="light"){t.disabled=!1,t.removeAttribute("media"),r.disabled=!0,r.setAttribute("media","(prefers-color-scheme: dark)");return}if(n==="dark"){r.disabled=!1,r.removeAttribute("media"),t.disabled=!0,t.setAttribute("media","(prefers-color-scheme: light)");return}t.disabled=!1,r.disabled=!1,t.media="(prefers-color-scheme: light)",r.media="(prefers-color-scheme: dark)"}}function ct(n){let e=globalThis.document?.documentElement;e&&(e.dataset.commentrayTheme=n,dr(n))}function X(n,e){try{return n.getItem(e)}catch{return null}}function z(n,e,t){try{n.setItem(e,t)}catch{}}function _t(n){let e=globalThis.location.pathname,t=globalThis.location.origin;for(let r of Array.from(n.querySelectorAll("a[href]"))){if(!(r instanceof HTMLAnchorElement))continue;let i=r.getAttribute("href")?.trim()??"";Pt(i)&&(r.href=J(i,e,t))}}function Ut(n){if(typeof globalThis.location<"u"&&globalThis.location.protocol==="file:")return;let t=Array.from(n.querySelectorAll("pre.mermaid")).filter(i=>{let s=i.closest(".commentray-mermaid");return s===null||s.querySelector("svg")===null});if(t.length===0)return;let r=globalThis.commentrayMermaid;r&&r.run({nodes:t}).catch(i=>{console.error("Commentray: mermaid.run failed",i)})}function x(n,e,t){return Math.max(e,Math.min(t,n))}function Wt(n,e,t){let r=e.getBoundingClientRect(),i=n.getBoundingClientRect();return n.scrollTop+(r.top-i.top)-n.clientTop-t}function Z(n,e){let t=Math.max(0,n.scrollHeight-n.clientHeight),r=x(e,0,t);Math.abs(n.scrollTop-r)<.25||(n.scrollTop=r)}function v(n){if(n.scrollHeight-n.clientHeight<=1)return!1;let t=getComputedStyle(n).overflowY;return t==="auto"||t==="scroll"||t==="overlay"}function ye(){let n=document.scrollingElement;return n instanceof HTMLElement?n:document.documentElement}function N(n){let e=ye(),t=Math.max(0,e.scrollHeight-e.clientHeight),r=x(n*t,0,t);Math.abs(e.scrollTop-r)<.25||(e.scrollTop=r)}function jt(n,e,t){if(v(n)){Z(n,Math.round(Wt(n,e,t)));return}let r=ye(),i=e.getBoundingClientRect(),s=globalThis.scrollY+i.top-t,o=Math.max(0,r.scrollHeight-r.clientHeight),a=x(s,0,o);Math.abs(r.scrollTop-a)<.25||(r.scrollTop=a)}function Se(){let n=ye(),e=Math.max(0,n.scrollHeight-n.clientHeight);return e>0?x(n.scrollTop/e,0,1):0}function fe(n,e,t){if(t.k==="block"){let s=n.querySelector(`#code-line-${String(t.src0)}`);s?jt(n,s,2):N(t.winRatio);return}if(t.k==="mirrorW"){if(v(n)){let s=Math.max(0,n.scrollHeight-n.clientHeight);Z(n,t.ratio*s)}else N(t.ratio);return}let r=et(t.docTop,t.docSH,t.docCH,n.scrollHeight,n.clientHeight);if(v(n)){Z(n,r);return}let i=Math.max(1,n.scrollHeight-n.clientHeight);N(x(r/i,0,1))}function pe(n,e,t){if(t.k==="block"){let s=e.querySelector(`[data-commentray-line="${String(t.mdLine0)}"]`);s instanceof HTMLElement?jt(e,s,2):N(t.winRatio);return}if(t.k==="mirrorW"){if(v(e)){let s=Math.max(0,e.scrollHeight-e.clientHeight);Z(e,t.ratio*s)}else N(t.ratio);return}let r=et(t.codeTop,t.codeSH,t.codeCH,e.scrollHeight,e.clientHeight);if(v(e)){Z(e,r);return}let i=Math.max(1,e.scrollHeight-e.clientHeight);N(x(r/i,0,1))}function Rt(n,e){let t=Se(),r=e(),i=kr(n),s=Ze(r,i);return s!==null?{k:"block",src0:s,winRatio:t}:v(n)?{k:"mirrorI",docTop:n.scrollTop,docSH:n.scrollHeight,docCH:n.clientHeight}:{k:"mirrorW",ratio:t}}function At(n,e,t){let r=Se(),i=t(),s=er(n),o=Y(i,s);return o===null?v(n)?{k:"mirrorI",codeTop:n.scrollTop,codeSH:n.scrollHeight,codeCH:n.clientHeight}:{k:"mirrorW",ratio:r}:{k:"block",mdLine0:o,winRatio:r}}function Bt(n){return v(n)?{k:"mirrorI",docTop:n.scrollTop,docSH:n.scrollHeight,docCH:n.clientHeight}:{k:"mirrorW",ratio:Se()}}function Dt(n){return v(n)?{k:"mirrorI",codeTop:n.scrollTop,codeSH:n.scrollHeight,codeCH:n.clientHeight}:{k:"mirrorW",ratio:Se()}}function M(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function mr(n,e){let t=n.replace(/\s+/g," ").trim();return t.length<=e?t:`${t.slice(0,e-1)}\u2026`}function gr(n,e){let t=new Map;for(let r of n){let i=r.kind==="path"?`path:${r.spPath??""}|${r.crPath??""}|${r.text.slice(0,120)}`:`${r.kind}:${r.line}:${r.crPath??""}`,s=t.get(i);(!s||r.score>s.score)&&t.set(i,r)}return[...t.values()].sort((r,i)=>i.score-r.score).slice(0,e)}function lt(n,e,t){let r=de(n,t),i=new Set,s=[];for(let o of r){let a=Mt(n,o.start);i.has(a)||(i.add(a),s.push({kind:e,line:a,text:xt(n,a),score:1e3,source:"ordered"}))}return s}function fr(n,e,t){let r=e.trim();if(!r)return[];let i=new I(r,t,[new U(.22),new B(0),new D(0)]),s=n.getMatches(i),o=[];for(let a of s.matches){let c=a.entity;o.push({kind:c.kind,line:c.line,text:c.text,score:100+a.quality,source:"fuzzy",crPath:c.crPath,spPath:c.spPath})}return o}function pr(n,e){if(e.length===0)return[];let t=[];for(let r of n)r.kind!=="path"||de(r.text,e).length===0||t.push({kind:"path",line:r.line,text:r.text,score:1e3,source:"ordered",spPath:r.spPath,crPath:r.crPath});return t}function yr(n){let{scope:e,filePathLabel:t,commentrayPathLabel:r,rawCode:i,rawMd:s,searcher:o,queryRaw:a,tokens:c,pathBlobWide:l,pathRowsForOrdering:h}=n,u=(l&&l.trim().length>0?l.trim():[t,r].filter(b=>b.trim().length>0).join(`
4
+ `))||"",m=e==="commentray-and-paths"?[]:lt(i,"code",c),g=e==="commentray-and-paths"&&h&&h.length>0?pr(h,c):e==="commentray-and-paths"&&u?lt(u,"path",c):[],d=lt(s,"md",c),f=fr(o,a,60);return gr([...m,...g,...d,...f],80)}function Sr(n){return n==="commentray-and-paths"?"Paths + indexed commentray (this page + browse pages when built). Ordered tokens + fuzzy lines.":"Whole source: whitespace tokens in order (may span lines). Per-line fuzzy ranking for typos."}function br(n,e){if(n.kind==="code")return`Code L${n.line+1}`;if(n.kind==="path")return"Path";let t=n.crPath&&n.crPath!==e.currentCommentrayPath?` \xB7 ${n.crPath}`:"";return`Commentray L${n.line+1}${t}`}function Vt(n,e,t){let r=br(n,t),i=n.source==="ordered"?"ordered":"fuzzy",s=Tt(mr(n.text,320),e),o=M(n.kind==="md"?n.crPath??t.currentCommentrayPath:n.crPath??""),a=M(n.kind==="md"?n.spPath??t.currentSourcePath:n.spPath??"");return`<button type="button" class="hit" data-kind="${n.kind}" data-line="${String(n.line)}" data-cr-path="${o}" data-sp-path="${a}"><span class="meta">${M(r)} <span class="src-tag">(${i})</span></span><div class="snippet">${s}</div></button>`}function wr(n,e,t,r){if(e.length===0)return'<div class="hint">No matches. Try fewer tokens or looser spelling (fuzzy matches per line).</div>';let i=Sr(n),s=[];s.push(`<div class="hint">${i} ${e.length} hit(s).</div>`);for(let o of e)s.push(Vt(o,t,r));return s.join("")}function ht(n,e,t,r){return n==="full"?"Documented source for this page. Type to search.":r?"Documented source on this page. Type to search the index when it is available.":t>e?`Indexed source files (${String(e)} of ${String(t)} shown). Type to search.`:`Indexed source files (${String(t)}). Type to search.`}function ut(n,e,t){let r=[],i=[`<div class="hint">${M(n)}</div>`],s=e.map((o,a)=>({kind:"path",line:a,text:o.sourcePath,score:1e3,source:"ordered",spPath:o.sourcePath,crPath:o.commentrayPath}));for(let o of s)i.push(Vt(o,r,t));return i.join("")}function Yt(n,e,t){let r=n.querySelector(`#commentray-md-line-${String(e)}`);if(r instanceof HTMLElement){let o=Math.round(Wt(n,r,8)),a=Math.round(Math.max(0,n.scrollHeight-n.clientHeight));n.scrollTo({top:x(o,0,a),behavior:"smooth"});return}if(t<=1)return;let i=e/Math.max(1,t-1),s=Math.max(0,n.scrollHeight-n.clientHeight);n.scrollTo({top:i*s,behavior:"smooth"})}function Kt(n,e){if(n.staticBrowseUrl?.trim()){let r=J(n.staticBrowseUrl.trim(),globalThis.location.pathname,globalThis.location.origin),i=new URL(r);e!==null&&e>=0&&(i.hash=`commentray-md-line-${String(e)}`),globalThis.location.assign(i.toString());return}let t=(n.commentrayOnGithub??"").trim();if(t.length>0){let r=e!==null&&e>=0?`${t}#L${String(e+1)}`:t;globalThis.location.assign(r)}}function vr(n){return{scope:(n.getAttribute("data-search-scope")||"")==="commentray-and-paths"?"commentray-and-paths":"full",filePathLabel:n.getAttribute("data-search-file-path")||"",commentrayPathLabel:n.getAttribute("data-search-commentray-path")||""}}function Ft(n,e,t,r,i){let s=t.split(`
5
5
  `),o=e.split(`
6
- `),a=[];return n==="commentray-and-paths"&&(r.trim()&&a.push({kind:"path",line:a.length,text:r}),i.trim()&&a.push({kind:"path",line:a.length,text:i})),[...n==="full"?o.map((c,h)=>({kind:"code",line:h,text:c})):[],...a,...s.map((c,h)=>({kind:"md",line:h,text:c}))]}function pt(n){let e=ae.createDefaultSearcher();return e.indexEntities(n,t=>t.kind==="md"&&t.crPath?`md:${t.crPath}:${t.line}`:t.kind==="path"?`path:${t.spPath??""}|${t.crPath??""}|${t.line}|${t.text.slice(0,120)}`:`${t.kind}:${t.line}`,t=>[t.text]),e}function Jt(n,e){let t=n;for(;t;){if(t.classList?.contains("hit"))return t;if(t===e)return null;t=t.parentElement}return null}function Yt(n){let e=document.getElementById(`code-line-${String(n)}`);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Xt(n,e){let t=(n.getAttribute("data-cr-path")??"").trim(),r=(n.getAttribute("data-sp-path")??"").trim(),i=Je(e.mutable.documentedPairs,t,r);if(i&&gt(i,e.filePathLabel,e.mutable.commentrayPathLabel)){e.docScrollEl.scrollTo({top:0,behavior:"smooth"});return}i&&Et(i,null)}function Zt(n,e,t){let r=t.mutable.commentrayPathLabel.trim(),i=e.trim();if(i.length>0&&w(i)!==w(r)){let s=Je(t.mutable.documentedPairs,i,"");if(s){Et(s,n);return}return}Tt(t.docScrollEl,n,t.mutable.mdLines.length)}function er(n,e){let t=n.getAttribute("data-kind"),r=parseInt(n.getAttribute("data-line")||"0",10),i=n.getAttribute("data-cr-path")?.trim()??"";if(t==="code"){Yt(r);return}if(t==="path"){Xt(n,e);return}Zt(r,i,e)}function tr(n,e,t){let r={currentCommentrayPath:t.commentrayPathLabel,currentSourcePath:e};if(n==="full"){let h=e.trim();if(h.length===0)return null;let l=[{sourcePath:h,commentrayPath:t.commentrayPathLabel.trim()}],u=Ze("full",l.length,l.length,!1);return et(u,l,r)}let{rows:i,totalUnique:s}=mt(t.documentedPairs);if(i.length>0){let h=Ze("commentray-and-paths",i.length,s,!1);return et(h,i,r)}let o=e.trim();if(o.length===0)return null;let a=[{sourcePath:o,commentrayPath:t.commentrayPathLabel.trim()}],c=Ze("commentray-and-paths",a.length,a.length,!0);return et(c,a,r)}function rr(n){let{scope:e,filePathLabel:t,mutable:r,rawCode:i,searchInput:s,searchClear:o,searchResults:a,docScrollEl:c}=n,h;function l(){clearTimeout(h),h=void 0,s.value="",a.innerHTML="",a.hidden=!0}function u(){let m=tr(e,t,r);m!==null&&(a.hidden=!1,a.innerHTML=m)}function d(){let m=le(s.value);if(m.length===0){a.hidden=!0,a.innerHTML="";return}let f=jt({scope:e,filePathLabel:t,commentrayPathLabel:r.commentrayPathLabel,rawCode:i,rawMd:r.rawMd,searcher:r.searcher,queryRaw:s.value,tokens:m,pathBlobWide:r.pathBlobWide,pathRowsForOrdering:r.pathRowsForOrdering.length>0?r.pathRowsForOrdering:void 0});a.hidden=!1,a.innerHTML=Vt(e,f,m,{currentCommentrayPath:r.commentrayPathLabel,currentSourcePath:t})}let g={mutable:r,docScrollEl:c,filePathLabel:t};a.addEventListener("click",m=>{let f=Jt(m.target,a);f&&er(f,g)}),s.addEventListener("input",()=>{clearTimeout(h),h=setTimeout(d,200)}),s.addEventListener("keydown",m=>{m.key==="ArrowDown"&&(le(s.value).length>0||(u(),m.preventDefault()))}),o.addEventListener("click",l),document.addEventListener("keydown",m=>{if(m.key!=="Escape")return;let f=s.value.trim().length>0,S=document.activeElement===s,v=!a.hidden;!f&&!S&&!v||(l(),S&&s.blur(),m.preventDefault())})}function Mt(n,e,t){let r=Ye(localStorage,n)==="1";t.checked=r,r&&e.classList.add("wrap"),t.addEventListener("change",()=>{t.checked?(e.classList.add("wrap"),de(localStorage,n,"1")):(e.classList.remove("wrap"),de(localStorage,n,"0"))})}function Pt(n){let e=n.trim();if(!e)return[];try{let t=JSON.parse(L(e));if(!Array.isArray(t))return[];let r=[];for(let i of t){if(typeof i!="object"||i===null)continue;let s=i;typeof s.id=="string"&&typeof s.commentrayLine=="number"&&typeof s.sourceStart=="number"&&typeof s.sourceEnd=="number"&&r.push({id:s.id,commentrayLine:s.commentrayLine,sourceStart:s.sourceStart,sourceEnd:s.sourceEnd})}return r}catch{return[]}}function Ct(n){let e=n.getBoundingClientRect().top+2,t=n.querySelectorAll('[id^="code-line-"]');for(let r of t)if(r.getBoundingClientRect().bottom>e){let s=/^code-line-(\d+)$/.exec(r.id);return s?Number(s[1])+1:1}return t.length>0?t.length:1}function nr(n){let e=n.getBoundingClientRect().top+2,t=n.querySelectorAll(".commentray-block-anchor"),r=0;for(let i of t){let s=i.getAttribute("data-commentray-line");if(!(s===null||s===""))if(i.getBoundingClientRect().top<=e+1)r=Number(s);else break}return r}function Lt(n,e,t,r){let i="none";n.addEventListener("scroll",()=>{i!=="doc"&&(i="code",t(),i="none")},{passive:!0}),e.addEventListener("scroll",()=>{i!=="code"&&(i="doc",r(),i="none")},{passive:!0})}function yt(n,e,t){Lt(n,e,()=>{let r=t(),i=Ct(n),s=V(r,i);if(s===null)e.scrollTop=B(n.scrollTop,n.scrollHeight,n.clientHeight,e.scrollHeight,e.clientHeight);else{let o=e.querySelector(`[data-commentray-line="${String(s)}"]`);if(o instanceof HTMLElement){let a=o.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;e.scrollTop=Math.max(0,a-2)}else e.scrollTop=B(n.scrollTop,n.scrollHeight,n.clientHeight,e.scrollHeight,e.clientHeight)}},()=>{let r=t(),i=nr(e),s=_e(r,i);if(s===null)n.scrollTop=B(e.scrollTop,e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);else{let o=document.getElementById(`code-line-${String(s)}`);if(o){let a=o.getBoundingClientRect().top-n.getBoundingClientRect().top+n.scrollTop;n.scrollTop=Math.max(0,a-2)}else n.scrollTop=B(e.scrollTop,e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight)}})}function ir(n,e){Lt(n,e,()=>{e.scrollTop=B(n.scrollTop,n.scrollHeight,n.clientHeight,e.scrollHeight,e.clientHeight)},()=>{n.scrollTop=B(e.scrollTop,e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight)})}function It(n){let e=n.getBoundingClientRect();return(e.top+e.bottom)/2}function St(n){return It(n)}function sr(n,e,t){if(e){let o=document.getElementById(`commentray-block-${e.id}`);return o?o.getBoundingClientRect().top-3:It(t)}let i=n.getBoundingClientRect().bottom-4,s=n.children[n.children.length-1];return s&&(i=Math.min(i,s.getBoundingClientRect().bottom-4)),i}function or(n,e,t,r){let i=()=>r();e.addEventListener("scroll",i,{passive:!0}),t.addEventListener("scroll",i,{passive:!0}),globalThis.addEventListener("resize",i);let s=new ResizeObserver(i);s.observe(n),s.observe(e),s.observe(t);let o=n.parentElement;o&&s.observe(o)}function ar(n,e,t,r,i){let s=r(),o=st(s),a=e.getBoundingClientRect(),c=a.width,h=a.height;if(c<=0||h<=0||o.length===0){n.replaceChildren();return}let l=ot(s,i());n.setAttribute("viewBox",`0 0 ${String(c)} ${String(h)}`),n.setAttribute("preserveAspectRatio","none");let u=[];for(let d=0;d<o.length;d++){let g=o[d];if(!g)continue;let m=o[d+1],f=Ke(g.sourceStart),S=Ke(g.sourceEnd),v=document.getElementById(`code-line-${String(f)}`),I=document.getElementById(`code-line-${String(S)}`),x=document.getElementById(`commentray-block-${g.id}`);if(!v||!I||!x)continue;let E=sr(t,m,x),b=St(v),k=St(I),R=x.getBoundingClientRect().top+2,N=Math.max(E,R+4),J=K(b,a.top,h),Y=K(R,a.top,h),rt=K(k,a.top,h),nt=K(N,a.top,h),me=g.id===l?"gutter__rays-path gutter__rays-path--active":"gutter__rays-path",it=`${me} gutter__rays-path--trail`,ge=Ve(0,J.y,c,Y.y,{tension:.38,clipStart:J.clipped,clipEnd:Y.clipped}),fe=Ve(0,rt.y,c,nt.y,{tension:.38,clipStart:rt.clipped,clipEnd:nt.clipped}),At=ge.dotted?`<path class="${it}" d="${ge.dotted}" />`:"",zt=fe.dotted?`<path class="${it}" d="${fe.dotted}" />`:"";u.push(`<g class="gutter__rays-block" data-commentray-block="${M(g.id)}"><path class="${me}" d="${ge.solid}" />`+At+`<path class="${me}" d="${fe.solid}" />`+zt+"</g>")}n.innerHTML=u.join("")}function cr(n){let{gutter:e,codePane:t,docScrollEl:r,getLinks:i,probeTopSourceLine1Based:s}=n,o="http://www.w3.org/2000/svg",a=document.createElement("div");a.className="gutter__rays",a.setAttribute("aria-hidden","true");let c=document.createElementNS(o,"svg");a.appendChild(c),e.appendChild(a);let h=0;function l(){h===0&&(h=globalThis.requestAnimationFrame(()=>{h=0,ar(c,e,r,i,s)}))}or(e,t,r,l),l(),globalThis.requestAnimationFrame(()=>{l(),globalThis.requestAnimationFrame(l)})}function hr(n){if(typeof n!="object"||n===null)return!1;let e=n;if(typeof e.sourcePath!="string"||typeof e.commentrayPath!="string"||e.staticBrowseUrl!==void 0&&typeof e.staticBrowseUrl!="string")return!1;let t=e.sourceOnGithub,r=e.commentrayOnGithub,i=typeof t=="string";return!(i!==(typeof r=="string")||!(typeof e.staticBrowseUrl=="string"&&e.staticBrowseUrl.trim().length>0)&&!i)}function tt(n){let e=[];if(!Array.isArray(n))return e;for(let t of n)hr(t)&&e.push(t);return e}function lr(n){if(n.kind!=="commentrayLine"||typeof n.line!="number"||typeof n.text!="string")return null;let e=typeof n.sourcePath=="string"?n.sourcePath:"",t=typeof n.commentrayPath=="string"?n.commentrayPath:"";return{kind:"md",line:n.line,text:n.text,spPath:e,crPath:t}}function ur(n,e){if(n.kind!=="sourcePath"&&n.kind!=="commentrayPath")return null;let t=typeof n.sourcePath=="string"?n.sourcePath:"",r=typeof n.commentrayPath=="string"?n.commentrayPath:"",i=n.kind==="sourcePath"?t:r;return i?{kind:"path",line:e,text:i,spPath:t,crPath:r}:null}function dr(n){if(!n||typeof n!="object")return[];let e=n.rows;if(!Array.isArray(e))return[];let t=[],r=0;for(let i of e){if(!i||typeof i!="object")continue;let s=i,o=lr(s);if(o){t.push(o);continue}let a=ur(s,r);a&&(t.push(a),r+=1)}return t}function kt(n){let e=n.trim();if(e==="")return[];try{let t=JSON.parse(L(e));return tt(t)}catch{return[]}}function mr(n,e){let t=e.sourcePath.split("/").filter(Boolean);if(t.length===0)return;let r=n;for(let i=0;i<t.length;i++){let s=t[i];if(s===void 0)continue;r.children.has(s)||r.children.set(s,{children:new Map,pairs:[]});let o=r.children.get(s);if(o===void 0)return;i===t.length-1&&o.pairs.push(e),r=o}}function gr(n){let e=n.replace(/\\/g,"/").replace(/\/+$/,""),t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function fr(n){return(n.replace(/\\/g,"/").replace(/\/+$/,"").split("/").filter(Boolean).at(-1)??"").replace(/\.md$/i,"")}function pr(n,e){let t=gr(n.sourcePath);if(!e)return t;let r=fr(n.commentrayPath);return r!==""&&r!==t?`${t} \xB7 ${r}`:t}function yr(n){let e=(n.staticBrowseUrl??"").trim();if(e.length>0)return ue(e,globalThis.location.pathname,globalThis.location.origin);let t=(n.commentrayOnGithub??"").trim();return t.length>0?t:"#"}function Sr(n){return(n.staticBrowseUrl??"").trim().length>0?`${n.sourcePath} \u2014 open this pair in the site viewer`:(n.commentrayOnGithub??"").trim().length>0?`${n.sourcePath} \u2014 open companion commentray on the repository host`:n.sourcePath}function Rt(n){let e=[...n.children.keys()].sort((r,i)=>r.localeCompare(i));if(e.length===0)return"";let t=[];for(let r of e){let i=n.children.get(r);if(i!==void 0){if(i.children.size>0){let s=Rt(i);t.push(`<li><div class="tree-dir">${M(r)}</div>${s}</li>`)}if(i.pairs.length>0){let s=i.pairs.length>1;for(let o of i.pairs){let a=M(pr(o,s)),c=M(Sr(o)),h=M(yr(o)),u=(o.staticBrowseUrl?.trim()??"").length>0?"":' target="_blank" rel="noopener noreferrer"';t.push(`<li><div class="tree-file"><a class="tree-file-link" href="${h}"${u} title="${c}">${a}</a></div></li>`)}}}}return`<ul>${t.join("")}</ul>`}function wr(n,e,t){if(e.length===0){n.innerHTML=t?'<p class="nav-rail__doc-hub-hint" role="status">No paths match this filter.</p>':'<p class="nav-rail__doc-hub-hint" role="status">No documented pairs in this export.</p>';return}let r={children:new Map,pairs:[]};for(let i of e)mr(r,i);n.innerHTML=Rt(r)}function br(n,e){let t=null,r=null;return async()=>t!==null?t:(r===null&&(r=(async()=>{if(e.length>0&&(t=kt(e),t.length>0))return;if(n.length===0){t=[];return}let i=await fetch(n,{credentials:"same-origin"});if(!i.ok)throw new Error(`nav json ${String(i.status)}`);let s=await i.json();t=tt(s.documentedPairs)})()),await r,t??[])}function vr(){let n=document.getElementById("documented-files-hub"),e=document.getElementById("documented-files-tree"),t=document.getElementById("documented-files-filter"),r=document.getElementById("shell");if(!(n instanceof HTMLDetailsElement)||!(e instanceof HTMLElement))return;let i=e,s=n.getAttribute("data-nav-json-url")?.trim()??"",o=r?.getAttribute("data-documented-pairs-b64")?.trim()??"";if(s.length===0&&o.length===0)return;let a=br(s,o),c=null;function h(){if(c===null)return;let u=t instanceof HTMLInputElement?t.value:"",d=ut(c,u),g=u.trim().length>0;wr(i,d,g&&c.length>0&&d.length===0)}async function l(){try{c=await a(),h()}catch{c=null,i.innerHTML='<p class="nav-rail__doc-hub-hint" role="alert">Could not load the file list.</p>'}}n.addEventListener("toggle",()=>{n.open&&l()}),t instanceof HTMLInputElement&&t.addEventListener("input",()=>{!n.open||c===null||h()})}function xr(n,e,t,r,i){let s=!1,o=i;function a(h){if(!s)return;let l=e.getBoundingClientRect(),u=h.clientX-l.left,d=vt(u/l.width*100,15,85);o=d,t.style.flex=`0 0 ${d}%`}function c(){s=!1,window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",c),document.body.style.cursor="",document.body.style.userSelect="",de(localStorage,n,String(o))}r.addEventListener("mousedown",h=>{h.preventDefault(),s=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",a),window.addEventListener("mouseup",c)})}var wt="commentray.codeCommentrayStatic.splitPct",Ht="commentray.codeCommentrayStatic.wrap";function Tr(n){let e=document.getElementById("wrap-lines");e&&Mt(Ht,n,e)}function Er(n){let e=n?.textContent?.trim()??"";if(!e)return null;try{let t=JSON.parse(L(e));if(!t||!Array.isArray(t.angles)||t.angles.length<2)return null;for(let r of t.angles)if(typeof r.id!="string"||typeof r.docInnerHtmlB64!="string")return null;return t}catch{return null}}function Mr(){let n=document.getElementById("doc-pane"),e=document.getElementById("gutter"),t=document.getElementById("wrap-lines"),r=document.getElementById("search-q"),i=document.getElementById("search-clear"),s=document.getElementById("search-results");if(!n||!e||!t||!r||!i||!s)return null;let o=document.getElementById("doc-pane-body"),a=o instanceof HTMLElement?o:n;return{docBody:o,docScrollEl:a,gutter:e,wrapCb:t,searchInput:r,searchClear:i,searchResults:s}}function Pr(n){let{scope:e,rawCode:t,filePathLabel:r,hubNavRows:i,pathRowsForOrdering:s,rawMd:o,commentrayPathLabel:a}=n;if(e!=="commentray-and-paths")return ft(e,t,o,r,a);if(i.length>0)return i;let c=s.length>0?s:ft(e,t,o,r,a).filter(l=>l.kind==="path"),h=o.split(`
7
- `).map((l,u)=>({kind:"md",line:u,text:l,spPath:r,crPath:a}));return[...c,...h]}function Cr(n,e,t,r){if(e!=="commentray-and-paths")return{documentedPairs:[],pathRowsForOrdering:[],pathBlobWide:""};let i=kt(n.getAttribute("data-documented-pairs-b64")?.trim()??""),s=dt(i),o=s.length>0?s.map(a=>a.text).join(`
6
+ `),a=[];return n==="commentray-and-paths"&&(r.trim()&&a.push({kind:"path",line:a.length,text:r}),i.trim()&&a.push({kind:"path",line:a.length,text:i})),[...n==="full"?o.map((c,l)=>({kind:"code",line:l,text:c})):[],...a,...s.map((c,l)=>({kind:"md",line:l,text:c}))]}function zt(n){let e=he.createDefaultSearcher();return e.indexEntities(n,t=>t.kind==="md"&&t.crPath?`md:${t.crPath}:${t.line}`:t.kind==="path"?`path:${t.spPath??""}|${t.crPath??""}|${t.line}|${t.text.slice(0,120)}`:`${t.kind}:${t.line}`,t=>[t.text]),e}function Tr(n,e){let t=n;for(;t;){if(t.classList?.contains("hit"))return t;if(t===e)return null;t=t.parentElement}return null}function Mr(n){let e=document.getElementById(`code-line-${String(n)}`);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}function xr(n,e){let t=(n.getAttribute("data-cr-path")??"").trim(),r=(n.getAttribute("data-sp-path")??"").trim(),i=st(e.mutable.documentedPairs,t,r);if(i&&Ht(i,e.filePathLabel,e.mutable.commentrayPathLabel)){e.docScrollEl.scrollTo({top:0,behavior:"smooth"});return}i&&Kt(i,null)}function Er(n,e,t){let r=t.mutable.commentrayPathLabel.trim(),i=e.trim();if(i.length>0&&w(i)!==w(r)){let s=st(t.mutable.documentedPairs,i,"");if(s){Kt(s,n);return}return}Yt(t.docScrollEl,n,t.mutable.mdLines.length)}function Cr(n,e){let t=n.getAttribute("data-kind"),r=parseInt(n.getAttribute("data-line")||"0",10),i=n.getAttribute("data-cr-path")?.trim()??"";if(t==="code"){Mr(r);return}if(t==="path"){xr(n,e);return}Er(r,i,e)}function Lr(n,e,t){let r={currentCommentrayPath:t.commentrayPathLabel,currentSourcePath:e};if(n==="full"){let l=e.trim();if(l.length===0)return null;let h=[{sourcePath:l,commentrayPath:t.commentrayPathLabel.trim()}],u=ht("full",h.length,h.length,!1);return ut(u,h,r)}let{rows:i,totalUnique:s}=Lt(t.documentedPairs);if(i.length>0){let l=ht("commentray-and-paths",i.length,s,!1);return ut(l,i,r)}let o=e.trim();if(o.length===0)return null;let a=[{sourcePath:o,commentrayPath:t.commentrayPathLabel.trim()}],c=ht("commentray-and-paths",a.length,a.length,!0);return ut(c,a,r)}function Pr(n){let{scope:e,filePathLabel:t,mutable:r,rawCode:i,searchInput:s,searchClear:o,searchResults:a,docScrollEl:c}=n,l;function h(){clearTimeout(l),l=void 0,s.value="",a.innerHTML="",a.hidden=!0}function u(){let d=Lr(e,t,r);d!==null&&(a.hidden=!1,a.innerHTML=d)}function m(){let d=me(s.value);if(d.length===0){a.hidden=!0,a.innerHTML="";return}let f=yr({scope:e,filePathLabel:t,commentrayPathLabel:r.commentrayPathLabel,rawCode:i,rawMd:r.rawMd,searcher:r.searcher,queryRaw:s.value,tokens:d,pathBlobWide:r.pathBlobWide,pathRowsForOrdering:r.pathRowsForOrdering.length>0?r.pathRowsForOrdering:void 0});a.hidden=!1,a.innerHTML=wr(e,f,d,{currentCommentrayPath:r.commentrayPathLabel,currentSourcePath:t})}let g={mutable:r,docScrollEl:c,filePathLabel:t};a.addEventListener("click",d=>{let f=Tr(d.target,a);f&&Cr(f,g)}),s.addEventListener("input",()=>{clearTimeout(l),l=setTimeout(m,200)}),s.addEventListener("keydown",d=>{d.key==="ArrowDown"&&(me(s.value).length>0||(u(),d.preventDefault()))}),o.addEventListener("click",h),document.addEventListener("keydown",d=>{if(d.key!=="Escape")return;let f=s.value.trim().length>0,b=document.activeElement===s,y=!a.hidden;!f&&!b&&!y||(h(),b&&s.blur(),d.preventDefault())})}function Jt(n,e,t,r,...i){let s=i.filter(a=>a instanceof HTMLElement),o=X(localStorage,n)==="1";if(t.checked=o,o){e.classList.add("wrap");for(let a of s)a.classList.add("wrap")}else{e.classList.remove("wrap");for(let a of s)a.classList.remove("wrap")}t.addEventListener("change",()=>{if(t.checked){e.classList.add("wrap");for(let a of s)a.classList.add("wrap");z(localStorage,n,"1")}else{e.classList.remove("wrap");for(let a of s)a.classList.remove("wrap");z(localStorage,n,"0")}r&&queueMicrotask(()=>{requestAnimationFrame(()=>{r(),requestAnimationFrame(()=>{r()})})})})}function Xt(n){let e=n.trim();if(!e)return[];try{let t=JSON.parse(P(e));if(!Array.isArray(t))return[];let r=[];for(let i of t){if(typeof i!="object"||i===null)continue;let s=i;typeof s.id=="string"&&typeof s.commentrayLine=="number"&&typeof s.sourceStart=="number"&&typeof s.sourceEnd=="number"&&r.push({id:s.id,commentrayLine:s.commentrayLine,sourceStart:s.sourceStart,sourceEnd:s.sourceEnd})}return r}catch{return[]}}function Zt(n=56){let e=ye(),t=Math.max(0,e.scrollHeight-e.clientHeight);return t>0&&e.scrollTop>=t-n}function er(n){let e=n.querySelectorAll('[id^="code-line-"]');if(e.length===0)return 1;if(!v(n)){if(Zt()){let l=e[e.length-1],h=/^code-line-(\d+)$/.exec(l.id);return h?Number(h[1])+1:e.length}let i=n.getBoundingClientRect(),s=globalThis.innerHeight,o=Math.max(0,i.top),a=Math.min(s,i.bottom),c=o+Math.max(2,Math.min(40,(a-o)*.15));for(let l of e)if(l.getBoundingClientRect().bottom>c-.001){let u=/^code-line-(\d+)$/.exec(l.id);return u?Number(u[1])+1:1}return e.length}let r=n.getBoundingClientRect().top+n.clientTop+2;for(let i of e)if(i.getBoundingClientRect().bottom>r-.001){let o=/^code-line-(\d+)$/.exec(i.id);return o?Number(o[1])+1:1}return e.length}function kr(n){let e=n.querySelectorAll(".commentray-block-anchor");if(e.length===0)return 0;if(!v(n)){if(Zt()){let m=e[e.length-1].getAttribute("data-commentray-line");return m!==null&&m!==""?Number(m):0}let s=n.getBoundingClientRect(),o=globalThis.innerHeight,a=Math.max(0,s.top),c=Math.min(o,s.bottom),l=a+Math.max(2,Math.min(40,(c-a)*.15)),h=0;for(let u of e){let m=u.getAttribute("data-commentray-line");if(!(m===null||m===""))if(u.getBoundingClientRect().top<=l+1+.001)h=Number(m);else break}return h}let r=n.getBoundingClientRect().top+n.clientTop+2,i=0;for(let s of e){let o=s.getAttribute("data-commentray-line");if(!(o===null||o===""))if(s.getBoundingClientRect().top<=r+1+.001)i=Number(o);else break}return i}function Nt(n){n.n++,queueMicrotask(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{n.n=Math.max(0,n.n-1)})})})}function tr(n,e,t,r){let i="none",s={n:0},o={n:0};n.addEventListener("scroll",()=>{if(s.n>0){s.n--;return}i!=="doc"&&(i="code",Nt(o),t(),i="none")},{passive:!0}),e.addEventListener("scroll",()=>{if(o.n>0){o.n--;return}i!=="code"&&(i="doc",Nt(s),r(),i="none")},{passive:!0})}function qt(n,e,t){let r=null,i=null,s=()=>{pe(n,e,At(n,e,t))},o=()=>{fe(n,e,Rt(e,t))},a=()=>{r=Rt(e,t)},c=()=>{if(!r)return;let u=r;r=null,fe(n,e,u)},l=()=>{i=At(n,e,t)},h=()=>{if(!i)return;let u=i;i=null,pe(n,e,u)};return tr(n,e,s,o),{syncFromCodeToDoc:s,syncFromDocToCode:o,prepareMobileFlipToCode:a,finishMobileFlipToCode:c,prepareMobileFlipToDoc:l,finishMobileFlipToDoc:h}}function Hr(n,e){let t=null,r=null,i=()=>{pe(n,e,Dt(n))},s=()=>{fe(n,e,Bt(e))},o=()=>{t=Bt(e)},a=()=>{if(!t)return;let h=t;t=null,fe(n,e,h)},c=()=>{r=Dt(n)},l=()=>{if(!r)return;let h=r;r=null,pe(n,e,h)};return tr(n,e,i,s),{syncFromCodeToDoc:i,syncFromDocToCode:s,prepareMobileFlipToCode:o,finishMobileFlipToCode:a,prepareMobileFlipToDoc:c,finishMobileFlipToDoc:l}}function rr(n){let e=n.getBoundingClientRect();return(e.top+e.bottom)/2}function $t(n){return rr(n)}function Ir(n,e,t){if(e){let o=document.getElementById(`commentray-block-${e.id}`);return o?o.getBoundingClientRect().top-3:rr(t)}let i=n.getBoundingClientRect().bottom-4,s=n.children[n.children.length-1];return s&&(i=Math.min(i,s.getBoundingClientRect().bottom-4)),i}function Rr(n,e,t,r){let i=()=>r();e.addEventListener("scroll",i,{passive:!0}),t.addEventListener("scroll",i,{passive:!0}),globalThis.addEventListener("resize",i);let s=new ResizeObserver(i);s.observe(n),s.observe(e),s.observe(t);let o=n.parentElement;o&&s.observe(o)}function Ar(n,e,t,r,i){let s=r(),o=bt(s),a=e.getBoundingClientRect(),c=a.width,l=a.height;if(c<=0||l<=0||o.length===0){n.replaceChildren();return}let h=wt(s,i());n.setAttribute("viewBox",`0 0 ${String(c)} ${String(l)}`),n.setAttribute("preserveAspectRatio","none");let u=[];for(let m=0;m<o.length;m++){let g=o[m];if(!g)continue;let d=o[m+1],f=nt(g.sourceStart),b=nt(g.sourceEnd),y=document.getElementById(`code-line-${String(f)}`),q=document.getElementById(`code-line-${String(b)}`),E=document.getElementById(`commentray-block-${g.id}`);if(!y||!q||!E)continue;let $=Ir(t,d,E),R=$t(y),A=$t(q),ee=E.getBoundingClientRect().top+2,be=Math.max($,ee+4),gt=K(R,a.top,l),ft=K(ee,a.top,l),pt=K(A,a.top,l),yt=K(be,a.top,l),we=g.id===h?"gutter__rays-path gutter__rays-path--active":"gutter__rays-path",St=`${we} gutter__rays-path--trail`,ve=rt(0,gt.y,c,ft.y,{tension:.38,clipStart:gt.clipped,clipEnd:ft.clipped}),Te=rt(0,pt.y,c,yt.y,{tension:.38,clipStart:pt.clipped,clipEnd:yt.clipped}),or=ve.dotted?`<path class="${St}" d="${ve.dotted}" />`:"",ar=Te.dotted?`<path class="${St}" d="${Te.dotted}" />`:"";u.push(`<g class="gutter__rays-block" data-commentray-block="${M(g.id)}"><path class="${we}" d="${ve.solid}" />`+or+`<path class="${we}" d="${Te.solid}" />`+ar+"</g>")}n.innerHTML=u.join("")}function Br(n){let{gutter:e,codePane:t,docScrollEl:r,getLinks:i,probeTopSourceLine1Based:s}=n,o="http://www.w3.org/2000/svg",a=document.createElement("div");a.className="gutter__rays",a.setAttribute("aria-hidden","true");let c=document.createElementNS(o,"svg");a.appendChild(c),e.appendChild(a);let l=0;function h(){l===0&&(l=globalThis.requestAnimationFrame(()=>{l=0,Ar(c,e,r,i,s)}))}return Rr(e,t,r,h),h(),globalThis.requestAnimationFrame(()=>{h(),globalThis.requestAnimationFrame(h)}),h}function Dr(n){if(typeof n!="object"||n===null)return!1;let e=n;if(typeof e.sourcePath!="string"||typeof e.commentrayPath!="string"||e.staticBrowseUrl!==void 0&&typeof e.staticBrowseUrl!="string")return!1;let t=e.sourceOnGithub,r=e.commentrayOnGithub,i=typeof t=="string";return!(i!==(typeof r=="string")||!(typeof e.staticBrowseUrl=="string"&&e.staticBrowseUrl.trim().length>0)&&!i)}function mt(n){let e=[];if(!Array.isArray(n))return e;for(let t of n)Dr(t)&&e.push(t);return e}function Fr(n){if(n.kind!=="commentrayLine"||typeof n.line!="number"||typeof n.text!="string")return null;let e=typeof n.sourcePath=="string"?n.sourcePath:"",t=typeof n.commentrayPath=="string"?n.commentrayPath:"";return{kind:"md",line:n.line,text:n.text,spPath:e,crPath:t}}function zr(n,e){if(n.kind!=="sourcePath"&&n.kind!=="commentrayPath")return null;let t=typeof n.sourcePath=="string"?n.sourcePath:"",r=typeof n.commentrayPath=="string"?n.commentrayPath:"",i=n.kind==="sourcePath"?t:r;return i?{kind:"path",line:e,text:i,spPath:t,crPath:r}:null}function Nr(n){if(!n||typeof n!="object")return[];let e=n.rows;if(!Array.isArray(e))return[];let t=[],r=0;for(let i of e){if(!i||typeof i!="object")continue;let s=i,o=Fr(s);if(o){t.push(o);continue}let a=zr(s,r);a&&(t.push(a),r+=1)}return t}function nr(n){let e=n.trim();if(e==="")return[];try{let t=JSON.parse(P(e));return mt(t)}catch{return[]}}function qr(n,e){let t=e.sourcePath.split("/").filter(Boolean);if(t.length===0)return;let r=n;for(let i=0;i<t.length;i++){let s=t[i];if(s===void 0)continue;r.children.has(s)||r.children.set(s,{children:new Map,pairs:[]});let o=r.children.get(s);if(o===void 0)return;i===t.length-1&&o.pairs.push(e),r=o}}function $r(n){let e=n.replace(/\\/g,"/").replace(/\/+$/,""),t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Or(n){return(n.replace(/\\/g,"/").replace(/\/+$/,"").split("/").filter(Boolean).at(-1)??"").replace(/\.md$/i,"")}function Gr(n,e){let t=$r(n.sourcePath);if(!e)return t;let r=Or(n.commentrayPath);return r!==""&&r!==t?`${t} \xB7 ${r}`:t}function Qr(n){let e=(n.staticBrowseUrl??"").trim();if(e.length>0)return J(e,globalThis.location.pathname,globalThis.location.origin);let t=(n.commentrayOnGithub??"").trim();return t.length>0?t:"#"}function _r(n){return(n.staticBrowseUrl??"").trim().length>0?`${n.sourcePath} \u2014 open this pair in the site viewer`:(n.commentrayOnGithub??"").trim().length>0?`${n.sourcePath} \u2014 open companion commentray on the repository host`:n.sourcePath}function ir(n){let e=[...n.children.keys()].sort((r,i)=>r.localeCompare(i));if(e.length===0)return"";let t=[];for(let r of e){let i=n.children.get(r);if(i!==void 0){if(i.children.size>0){let s=ir(i);t.push(`<li><div class="tree-dir">${M(r)}</div>${s}</li>`)}if(i.pairs.length>0){let s=i.pairs.length>1;for(let o of i.pairs){let a=M(Gr(o,s)),c=M(_r(o)),l=M(Qr(o)),u=(o.staticBrowseUrl?.trim()??"").length>0?"":' target="_blank" rel="noopener noreferrer"';t.push(`<li><div class="tree-file"><a class="tree-file-link" href="${l}"${u} title="${c}">${a}</a></div></li>`)}}}}return`<ul>${t.join("")}</ul>`}function Ur(n,e,t){if(e.length===0){n.innerHTML=t?'<p class="nav-rail__doc-hub-hint" role="status">No paths match this filter.</p>':'<p class="nav-rail__doc-hub-hint" role="status">No documented pairs in this export.</p>';return}let r={children:new Map,pairs:[]};for(let i of e)qr(r,i);n.innerHTML=ir(r)}function Wr(n,e){let t=null,r=null;return async()=>t!==null?t:(r===null&&(r=(async()=>{if(e.length>0&&(t=nr(e),t.length>0))return;if(n.length===0){t=[];return}let i=await fetch(n,{credentials:"same-origin"});if(!i.ok)throw new Error(`nav json ${String(i.status)}`);let s=await i.json();t=mt(s.documentedPairs)})()),await r,t??[])}function jr(n){let e=n.querySelector(".nav-rail__doc-hub-inner");if(!(e instanceof HTMLElement))return()=>{};let t=e,r=globalThis.matchMedia("(max-width: 767px)");function i(){let o=n.querySelector("summary");return o instanceof HTMLElement?o:null}function s(){if(!n.open||!r.matches){t.style.removeProperty("position"),t.style.removeProperty("top"),t.style.removeProperty("left"),t.style.removeProperty("right"),t.style.removeProperty("width"),t.style.removeProperty("max-width"),t.style.removeProperty("max-height"),t.style.removeProperty("z-index");return}let o=i();if(!o)return;let a=o.getBoundingClientRect(),c=8;t.style.position="fixed",t.style.top=`${String(Math.round(a.bottom+4))}px`,t.style.left=`${String(Math.round(c))}px`,t.style.right=`${String(Math.round(c))}px`,t.style.width="auto",t.style.maxWidth="none",t.style.maxHeight="min(52vh, 400px)",t.style.zIndex="200"}return r.addEventListener("change",s),globalThis.addEventListener("resize",s),globalThis.addEventListener("scroll",s,!0),s}function Vr(){let n=document.getElementById("documented-files-hub"),e=document.getElementById("documented-files-tree"),t=document.getElementById("documented-files-filter"),r=document.getElementById("shell");if(!(n instanceof HTMLDetailsElement)||!(e instanceof HTMLElement))return;let i=e,s=n.getAttribute("data-nav-json-url")?.trim()??"",o=r?.getAttribute("data-documented-pairs-b64")?.trim()??"";if(s.length===0&&o.length===0)return;let a=jr(n),c=Wr(s,o),l=null;function h(){if(l===null)return;let m=t instanceof HTMLInputElement?t.value:"",g=Et(l,m),d=m.trim().length>0;Ur(i,g,d&&l.length>0&&g.length===0)}async function u(){try{l=await c(),h()}catch{l=null,i.innerHTML='<p class="nav-rail__doc-hub-hint" role="alert">Could not load the file list.</p>'}}n.addEventListener("toggle",()=>{a(),n.open&&globalThis.requestAnimationFrame(a),n.open&&u()}),t instanceof HTMLInputElement&&t.addEventListener("input",()=>{!n.open||l===null||h()})}function Yr(n,e,t,r,i){let s=!1,o=i;function a(l){if(!s)return;let h=e.getBoundingClientRect(),u=l.clientX-h.left,m=x(u/h.width*100,15,85);o=m,t.style.flex=`0 0 ${m}%`,e.style.setProperty("--split-pct",`${String(m)}%`)}function c(){s=!1,window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",c),document.body.style.cursor="",document.body.style.userSelect="",z(localStorage,n,String(o))}r.addEventListener("mousedown",l=>{l.preventDefault(),s=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",a),window.addEventListener("mouseup",c)})}var Ot="commentray.codeCommentrayStatic.splitPct",sr="commentray.codeCommentrayStatic.wrap",Gt="commentray.codeCommentrayStatic.dualMobilePane",Kr="(max-width: 767px)";function dt(n){return n==="code"?"code":"doc"}function Jr(n,e){let t=()=>{if(n.getAttribute("data-layout")!=="dual"||!e.matches||dt(n.getAttribute("data-dual-mobile-pane"))!=="doc")return;let r=document.getElementById("doc-pane-body");r instanceof HTMLElement&&Ut(r)};queueMicrotask(()=>{t(),requestAnimationFrame(()=>{t(),requestAnimationFrame(t)})})}function Xr(n,e,t){let r=()=>{e.hidden=!0,e.classList.remove("is-visible")},i=()=>{e.hidden=!1,e.classList.add("is-visible")},s=()=>{if(!t.matches){r();return}let o=n.getBoundingClientRect(),a=globalThis.innerHeight,c=10;o.bottom<c||o.top>a-c?i():r()};globalThis.addEventListener("scroll",s,{passive:!0}),globalThis.addEventListener("resize",s,{passive:!0}),t.addEventListener("change",s),globalThis.requestAnimationFrame(s)}function Zr(n,e,t,r){let i=globalThis.matchMedia(Kr);function s(){return dt(X(localStorage,Gt))}function o(){i.matches?n.setAttribute("data-dual-mobile-pane",s()):n.removeAttribute("data-dual-mobile-pane")}let a=()=>{if(!i.matches)return;let l=dt(n.getAttribute("data-dual-mobile-pane"))==="code"?"doc":"code";l==="code"?t.prepareMobileFlipToCode():t.prepareMobileFlipToDoc(),n.setAttribute("data-dual-mobile-pane",l),z(localStorage,Gt,l),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(()=>{l==="code"?t.finishMobileFlipToCode():t.finishMobileFlipToDoc()})}),l==="doc"&&Jr(n,i)};e.addEventListener("click",a),r&&(r.addEventListener("click",a),Xr(e,r,i)),i.addEventListener("change",o),o()}function en(n){let e=document.getElementById("wrap-lines");e&&Jt(sr,n,e,()=>{globalThis.dispatchEvent(new Event("resize"))})}function tn(n){let e=n?.textContent?.trim()??"";if(!e)return null;try{let t=JSON.parse(P(e));if(!t||!Array.isArray(t.angles)||t.angles.length<2)return null;for(let r of t.angles)if(typeof r.id!="string"||typeof r.docInnerHtmlB64!="string")return null;return t}catch{return null}}function rn(){let n=document.getElementById("doc-pane"),e=document.getElementById("gutter"),t=document.getElementById("wrap-lines"),r=document.getElementById("search-q"),i=document.getElementById("search-clear"),s=document.getElementById("search-results");if(!n||!e||!t||!r||!i||!s)return null;let o=document.getElementById("doc-pane-body"),a=o instanceof HTMLElement?o:n;return{docBody:o,docScrollEl:a,gutter:e,wrapCb:t,searchInput:r,searchClear:i,searchResults:s}}function nn(n){let{scope:e,rawCode:t,filePathLabel:r,hubNavRows:i,pathRowsForOrdering:s,rawMd:o,commentrayPathLabel:a}=n;if(e!=="commentray-and-paths")return Ft(e,t,o,r,a);if(i.length>0)return i;let c=s.length>0?s:Ft(e,t,o,r,a).filter(h=>h.kind==="path"),l=o.split(`
7
+ `).map((h,u)=>({kind:"md",line:u,text:h,spPath:r,crPath:a}));return[...c,...l]}function sn(n,e,t,r){if(e!=="commentray-and-paths")return{documentedPairs:[],pathRowsForOrdering:[],pathBlobWide:""};let i=nr(n.getAttribute("data-documented-pairs-b64")?.trim()??""),s=Ct(i),o=s.length>0?s.map(a=>a.text).join(`
8
8
  `):[t,r].filter(a=>a.trim().length>0).join(`
9
- `);return{documentedPairs:i,pathRowsForOrdering:s,pathBlobWide:o}}function Lr(n,e){if(e.length===0)return n;if(n.length===0)return e;let t=new Map;for(let r of n){let i=(r.staticBrowseUrl??"").trim();i.length!==0&&t.set(w(r.commentrayPath),i)}return e.map(r=>{if((r.staticBrowseUrl??"").trim().length>0)return r;let s=t.get(w(r.commentrayPath));return s!==void 0&&s.length>0?{...r,staticBrowseUrl:s}:r})}function Ir(n){let e=n.getAttribute("data-nav-search-json-url")?.trim()??"";if(e.length===0)return"";try{return new URL(e,globalThis.location.href).href}catch{return e}}function kr(n,e,t,r,i,s){let o=Ir(n);o.length!==0&&(async()=>{try{let a=await fetch(o,{credentials:"same-origin"});if(!a.ok)return;let c=await a.json(),h=tt(c.documentedPairs),l=Lr(e,h);l.length>0&&(t.documentedPairs=l,r.documentedPairs=l);let u=dr(c);if(u.length===0)return;t.hubNavRows=u,t.pathRowsForOrdering=u.filter(d=>d.kind==="path"),r.pathRowsForOrdering=t.pathRowsForOrdering,r.pathBlobWide=t.pathRowsForOrdering.map(d=>d.text).join(`
10
- `),i(),s.value.trim().length>0&&s.dispatchEvent(new Event("input",{bubbles:!0}))}catch{}})()}function Rr(n){let{codePane:e,docScrollEl:t,docBody:r,shell:i,scrollLinksRef:s,multiPayload:o,mutable:a,rebuildSearcher:c,searchInput:h,searchResults:l}=n;if(o){yt(e,t,()=>s.current);let u=document.getElementById("angle-select");u&&r&&u.addEventListener("change",()=>{let d=o.angles.find(f=>f.id===u.value);if(!d)return;r.innerHTML=L(d.docInnerHtmlB64),Ot(r),a.rawMd=L(d.rawMdB64),a.mdLines=a.rawMd.split(`
11
- `),a.commentrayPathLabel=d.commentrayPathForSearch,c(),s.current=Pt(d.scrollBlockLinksB64),i.setAttribute("data-scroll-block-links-b64",d.scrollBlockLinksB64),i.setAttribute("data-search-commentray-path",d.commentrayPathForSearch);let g=document.getElementById("nav-rail-doc-path");if(g){let f=d.commentrayPathForSearch.trim();g.textContent=f.length>0?f:"\u2014",f.length>0?g.setAttribute("title",f):g.removeAttribute("title")}let m=document.getElementById("toolbar-commentray-github");if(m instanceof HTMLAnchorElement){let f=d.staticBrowseUrl?.trim()??"";if(f.length>0)m.href=ue(f,globalThis.location.pathname,globalThis.location.origin),m.removeAttribute("target"),m.setAttribute("rel","noopener");else{let S=d.commentrayOnGithubUrl?.trim();S&&(m.href=S,m.target="_blank",m.setAttribute("rel","noopener noreferrer"))}}h.value="",l.innerHTML="",l.hidden=!0});return}if(s.current.length>0){yt(e,t,()=>s.current);return}ir(e,t)}function Hr(n,e){function t(){let r=/^commentray-md-line-(\d+)$/.exec(globalThis.location.hash.slice(1));if(!r?.[1])return;let i=Number.parseInt(r[1],10);Number.isFinite(i)&&Tt(n,i,e())}globalThis.addEventListener("hashchange",t),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(t)})}function Ar(n,e){let t=Mr();if(!t)return;let{docBody:r,docScrollEl:i,gutter:s,wrapCb:o,searchInput:a,searchClear:c,searchResults:h}=t,{rawCodeB64:l,rawMdB64:u}=at(n,e),d=L(l),g=L(u),f={current:Pt(n.getAttribute("data-scroll-block-links-b64")||"")},{scope:S,filePathLabel:v,commentrayPathLabel:I}=Kt(n),x=Cr(n,S,v,I),E={hubNavRows:[],documentedPairs:x.documentedPairs,pathRowsForOrdering:x.pathRowsForOrdering},b={rawMd:g,mdLines:g.split(`
12
- `),commentrayPathLabel:I,searcher:pt([]),pathBlobWide:x.pathBlobWide,pathRowsForOrdering:E.pathRowsForOrdering,documentedPairs:E.documentedPairs};function k(){b.searcher=pt(Pr({scope:S,rawCode:d,filePathLabel:v,hubNavRows:E.hubNavRows,pathRowsForOrdering:E.pathRowsForOrdering,rawMd:b.rawMd,commentrayPathLabel:b.commentrayPathLabel}))}k(),rr({scope:S,filePathLabel:v,mutable:b,rawCode:d,searchInput:a,searchClear:c,searchResults:h,docScrollEl:i}),kr(n,x.documentedPairs,E,b,k,a);let R=parseFloat(Ye(localStorage,wt)||"50"),N=vt(Number.isFinite(R)?R:50,15,85);e.style.flex=`0 0 ${N}%`,Mt(Ht,e,o),xr(wt,n,e,s,N);let J=document.getElementById("commentray-multi-angle-b64"),Y=Er(J);Rr({codePane:e,docScrollEl:i,docBody:r,shell:n,scrollLinksRef:f,multiPayload:Y,mutable:b,rebuildSearcher:k,searchInput:a,searchResults:h}),f.current.length>0&&cr({gutter:s,codePane:e,docScrollEl:i,getLinks:()=>f.current,probeTopSourceLine1Based:()=>Ct(e)}),Hr(i,()=>b.mdLines.length)}function bt(){vr();let n=document.getElementById("shell"),e=document.getElementById("code-pane");if(!n||!e)return;if((n.getAttribute("data-layout")||"dual")==="stretch"){Tr(e);return}Ar(n,e)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",bt):bt();})();
9
+ `);return{documentedPairs:i,pathRowsForOrdering:s,pathBlobWide:o}}function on(n,e){if(e.length===0)return n;if(n.length===0)return e;let t=new Map;for(let r of n){let i=(r.staticBrowseUrl??"").trim();i.length!==0&&t.set(w(r.commentrayPath),i)}return e.map(r=>{if((r.staticBrowseUrl??"").trim().length>0)return r;let s=t.get(w(r.commentrayPath));return s!==void 0&&s.length>0?{...r,staticBrowseUrl:s}:r})}function an(n){let e=n.getAttribute("data-nav-search-json-url")?.trim()??"";if(e.length===0)return"";try{return new URL(e,globalThis.location.href).href}catch{return e}}function cn(n,e,t,r,i,s){let o=an(n);o.length!==0&&(async()=>{try{let a=await fetch(o,{credentials:"same-origin"});if(!a.ok)return;let c=await a.json(),l=mt(c.documentedPairs),h=on(e,l);h.length>0&&(t.documentedPairs=h,r.documentedPairs=h);let u=Nr(c);if(u.length===0)return;t.hubNavRows=u,t.pathRowsForOrdering=u.filter(m=>m.kind==="path"),r.pathRowsForOrdering=t.pathRowsForOrdering,r.pathBlobWide=t.pathRowsForOrdering.map(m=>m.text).join(`
10
+ `),i(),s.value.trim().length>0&&s.dispatchEvent(new Event("input",{bubbles:!0}))}catch{}})()}function ln(n){let{codePane:e,docScrollEl:t,docBody:r,shell:i,scrollLinksRef:s,multiPayload:o,mutable:a,rebuildSearcher:c,searchInput:l,searchResults:h,requestBlockRayRedraw:u}=n;if(o){let m=qt(e,t,()=>s.current),g=document.getElementById("angle-select");return g&&r&&g.addEventListener("change",()=>{let d=o.angles.find(y=>y.id===g.value);if(!d)return;r.innerHTML=P(d.docInnerHtmlB64),Ut(r),_t(r),a.rawMd=P(d.rawMdB64),a.mdLines=a.rawMd.split(`
11
+ `),a.commentrayPathLabel=d.commentrayPathForSearch,c(),s.current=Xt(d.scrollBlockLinksB64),i.setAttribute("data-scroll-block-links-b64",d.scrollBlockLinksB64),i.setAttribute("data-search-commentray-path",d.commentrayPathForSearch);let f=document.getElementById("nav-rail-doc-path");if(f){let y=d.commentrayPathForSearch.trim();f.textContent=y.length>0?y:"\u2014",y.length>0?f.setAttribute("title",y):f.removeAttribute("title")}let b=d.staticBrowseUrl?.trim()??"";if(b.length>0){let y=kt(b,globalThis.location.pathname,globalThis.location.origin);i.setAttribute("data-commentray-pair-browse-href",y)}else{let y=d.commentrayOnGithubUrl?.trim();y?i.setAttribute("data-commentray-pair-browse-href",y):i.removeAttribute("data-commentray-pair-browse-href")}l.value="",h.innerHTML="",h.hidden=!0,u?.(),globalThis.requestAnimationFrame(()=>{u?.(),globalThis.requestAnimationFrame(()=>{u?.()})})}),m}return s.current.length>0?qt(e,t,()=>s.current):Hr(e,t)}function hn(n,e){function t(){let r=/^commentray-md-line-(\d+)$/.exec(globalThis.location.hash.slice(1));if(!r?.[1])return;let i=Number.parseInt(r[1],10);Number.isFinite(i)&&Yt(n,i,e())}globalThis.addEventListener("hashchange",t),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(t)})}function un(n,e){let{rawCodeB64:t,rawMdB64:r}=vt(n,e),i=P(t),s=P(r),a={current:Xt(n.getAttribute("data-scroll-block-links-b64")||"")},{scope:c,filePathLabel:l,commentrayPathLabel:h}=vr(n),u=sn(n,c,l,h),m={hubNavRows:[],documentedPairs:u.documentedPairs,pathRowsForOrdering:u.pathRowsForOrdering},g={rawMd:s,mdLines:s.split(`
12
+ `),commentrayPathLabel:h,searcher:zt([]),pathBlobWide:u.pathBlobWide,pathRowsForOrdering:m.pathRowsForOrdering,documentedPairs:m.documentedPairs};function d(){g.searcher=zt(nn({scope:c,rawCode:i,filePathLabel:l,hubNavRows:m.hubNavRows,pathRowsForOrdering:m.pathRowsForOrdering,rawMd:g.rawMd,commentrayPathLabel:g.commentrayPathLabel}))}return d(),{rawCode:i,rawMd:s,scrollLinksRef:a,scope:c,filePathLabel:l,commentrayPathLabel:h,pathInit:u,indexState:m,mutable:g,rebuildSearcher:d}}function dn(n,e){let t=rn();if(!t)return;let{docBody:r,docScrollEl:i,gutter:s,wrapCb:o,searchInput:a,searchClear:c,searchResults:l}=t,h=un(n,e);_t(document),Pr({scope:h.scope,filePathLabel:h.filePathLabel,mutable:h.mutable,rawCode:h.rawCode,searchInput:a,searchClear:c,searchResults:l,docScrollEl:i}),cn(n,h.pathInit.documentedPairs,h.indexState,h.mutable,h.rebuildSearcher,a);let u=parseFloat(X(localStorage,Ot)||"46"),m=x(Number.isFinite(u)?u:46,15,85);e.style.flex=`0 0 ${m}%`,n.style.setProperty("--split-pct",`${String(m)}%`);let g=document.getElementById("doc-pane"),d=g instanceof HTMLElement?g:null,f={};Jt(sr,e,o,()=>{f.request?.(),e.dispatchEvent(new Event("scroll")),i.dispatchEvent(new Event("scroll"))},d,r),Yr(Ot,n,e,s,m);let b=document.getElementById("commentray-multi-angle-b64"),y=tn(b),E=y!==null||h.scrollLinksRef.current.length>0?Br({gutter:s,codePane:e,docScrollEl:i,getLinks:()=>h.scrollLinksRef.current,probeTopSourceLine1Based:()=>er(e)}):void 0;f.request=E;let $=ln({codePane:e,docScrollEl:i,docBody:r,shell:n,scrollLinksRef:h.scrollLinksRef,multiPayload:y,mutable:h.mutable,rebuildSearcher:h.rebuildSearcher,searchInput:a,searchResults:l,requestBlockRayRedraw:E}),R=document.getElementById("mobile-pane-flip"),A=document.getElementById("mobile-pane-flip-scroll");R instanceof HTMLButtonElement&&Zr(n,R,$,A instanceof HTMLButtonElement?A:null),hn(i,()=>h.mutable.mdLines.length)}function mn(n){return n==="light"?"Light":n==="dark"?"Dark":"System"}function gn(n,e){let t=mn(e);n.setAttribute("aria-label",`Color theme: ${t}. Left-click opens the menu. Right-click cycles System, Light, and Dark.`),n.title=`Appearance: ${t} \u2014 left-click menu, right-click cycle`}function fn(){let n=document.querySelector(".toolbar-theme"),e=document.getElementById("commentray-theme-trigger"),t=document.getElementById("commentray-theme-menu");if(!n||!(e instanceof HTMLButtonElement)||!(t instanceof HTMLElement))return;let r=n,i=e,s=t,o=ge(X(localStorage,at));ct(o);let a=!1;function c(){i.dataset.commentrayTriggerMode=o,i.setAttribute("aria-expanded",a?"true":"false"),gn(i,o);for(let d of s.querySelectorAll("[data-commentray-theme-value]")){let f=ge(d.dataset.commentrayThemeValue??"");d.setAttribute("aria-checked",f===o?"true":"false")}}function l(){a=!0,s.removeAttribute("hidden"),c(),(s.querySelector('[role="menuitemradio"][aria-checked="true"]')??s.querySelector('[role="menuitemradio"]'))?.focus()}function h(){a=!1,s.setAttribute("hidden",""),c()}function u(d){o=d,z(localStorage,at,d),ct(d),c()}i.addEventListener("click",d=>{d.preventDefault(),d.stopPropagation(),a?h():l()}),i.addEventListener("contextmenu",d=>{d.preventDefault(),a&&h(),u(It(o))});for(let d of s.querySelectorAll("[data-commentray-theme-value]"))d.addEventListener("click",f=>{f.stopPropagation();let b=ge(d.dataset.commentrayThemeValue??"");u(b),h(),i.focus()});function m(d){if(!a)return;let f=d.target;f instanceof Node&&(r.contains(f)||h())}function g(d){!a||d.key!=="Escape"||(d.preventDefault(),d.stopPropagation(),h(),i.focus())}document.addEventListener("mousedown",m,!0),document.addEventListener("touchstart",m,!0),document.addEventListener("keydown",g,!0),c()}function Qt(){fn(),Vr();let n=document.getElementById("shell"),e=document.getElementById("code-pane");if(!n||!e)return;if((n.getAttribute("data-layout")||"dual")==="stretch"){en(e);return}dn(n,e)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Qt):Qt();})();