@commentray/render 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist/block-stretch-layout.d.ts.map +1 -1
  2. package/dist/block-stretch-layout.js +2 -1
  3. package/dist/block-stretch-layout.js.map +1 -1
  4. package/dist/browse-page-slug.d.ts +6 -1
  5. package/dist/browse-page-slug.d.ts.map +1 -1
  6. package/dist/browse-page-slug.js +6 -1
  7. package/dist/browse-page-slug.js.map +1 -1
  8. package/dist/browse-pair-html-test-fixtures.d.ts +10 -0
  9. package/dist/browse-pair-html-test-fixtures.d.ts.map +1 -0
  10. package/dist/browse-pair-html-test-fixtures.js +19 -0
  11. package/dist/browse-pair-html-test-fixtures.js.map +1 -0
  12. package/dist/build-commentray-nav-search.d.ts +4 -4
  13. package/dist/build-commentray-nav-search.js +1 -1
  14. package/dist/code-browser-block-rays.d.ts +29 -0
  15. package/dist/code-browser-block-rays.d.ts.map +1 -1
  16. package/dist/code-browser-block-rays.js +120 -0
  17. package/dist/code-browser-block-rays.js.map +1 -1
  18. package/dist/code-browser-client.bundle.js +11 -11
  19. package/dist/code-browser-client.js +80 -27
  20. package/dist/code-browser-client.js.map +1 -1
  21. package/dist/code-browser-pair-nav.d.ts +3 -3
  22. package/dist/code-browser-pair-nav.d.ts.map +1 -1
  23. package/dist/code-browser-pair-nav.js +25 -13
  24. package/dist/code-browser-pair-nav.js.map +1 -1
  25. package/dist/code-browser.d.ts +18 -4
  26. package/dist/code-browser.d.ts.map +1 -1
  27. package/dist/code-browser.js +66 -269
  28. package/dist/code-browser.js.map +1 -1
  29. package/dist/commentray-anchor-viewport-probe.d.ts +9 -0
  30. package/dist/commentray-anchor-viewport-probe.d.ts.map +1 -0
  31. package/dist/commentray-anchor-viewport-probe.js +13 -0
  32. package/dist/commentray-anchor-viewport-probe.js.map +1 -0
  33. package/dist/commentray-preview-html.d.ts +13 -0
  34. package/dist/commentray-preview-html.d.ts.map +1 -0
  35. package/dist/commentray-preview-html.js +12 -0
  36. package/dist/commentray-preview-html.js.map +1 -0
  37. package/dist/companion-markdown-preview-entry.d.ts +7 -0
  38. package/dist/companion-markdown-preview-entry.d.ts.map +1 -0
  39. package/dist/companion-markdown-preview-entry.js +6 -0
  40. package/dist/companion-markdown-preview-entry.js.map +1 -0
  41. package/dist/index.d.ts +2 -0
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +2 -0
  44. package/dist/index.js.map +1 -1
  45. package/dist/inject-md-line-anchors.d.ts +18 -0
  46. package/dist/inject-md-line-anchors.d.ts.map +1 -0
  47. package/dist/inject-md-line-anchors.js +250 -0
  48. package/dist/inject-md-line-anchors.js.map +1 -0
  49. package/dist/inline-favicon.js +15 -15
  50. package/dist/markdown-pipeline.d.ts +5 -0
  51. package/dist/markdown-pipeline.d.ts.map +1 -1
  52. package/dist/markdown-pipeline.js +40 -0
  53. package/dist/markdown-pipeline.js.map +1 -1
  54. package/package.json +6 -2
  55. package/dist/code-browser-client.d.ts +0 -2
  56. package/dist/side-by-side-layout.css +0 -58
  57. package/dist/side-by-side-layout.embedded.d.ts +0 -3
  58. package/dist/side-by-side-layout.embedded.d.ts.map +0 -1
  59. package/dist/side-by-side-layout.embedded.js +0 -3
  60. package/dist/side-by-side-layout.embedded.js.map +0 -1
@@ -1,6 +1,6 @@
1
- "use strict";(()=>{var N=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}},le=class{static getHashCode(e){let t=5381,r=t;for(let i=0,o=e.length;i<o&&e[i]!="\0"&&(t=(t<<5)+t^e.charCodeAt(i),i!==o-1&&e[i+1]!=="\0");i+=2)r=(r<<5)+r^e.charCodeAt(i+1);return t+1566083941*r|0}},b=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)}}},X=class{static mergeMeta(e){if(e.length===0)return new b;if(e.length===1)return e[0];let t=new Map;for(let i of e)for(let[o,s]of i.allEntries){let a=t.get(o);a===void 0?t.set(o,[s]):a.push(s)}let r=new Map;for(let[i,o]of t)if(o.length!==1){if(o.every(s=>typeof s=="number")){let s=o.reduce((a,c)=>a+c,0);r.set(i,s);continue}for(let s=0;s<o.length;s++)r.set(`${i}_${s}`,o[s])}else r.set(i,o[0]);return new b(r)}},ue=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}},he=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)}},$=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}},y,Z;(function(n){n.Fuzzy="fuzzy",n.Substring="substring",n.Prefix="prefix"})(y||(y={}));var ee=class{constructor(e,t){this.type=void 0,this.minQuality=void 0,this.type=e,this.minQuality=Math.max(0,t)}},te=class extends ee{constructor(e){super(y.Fuzzy,e)}},U=class extends ee{constructor(e){super(y.Substring,e)}},_=class extends ee{constructor(e){super(y.Prefix,e)}},q=class{constructor(e,t=10,r=[new te(.3),new U(0),new _(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}},Fe=class{constructor(e,t){this.removedEntities=void 0,this.meta=void 0,this.removedEntities=e,this.meta=t}},De=class{static mergeResults(e,t){let r=e.query,i=this.mergeMatches(e.matches,t.matches,r.topN),o=X.mergeMeta([e.meta,t.meta]);return new $(i,r,o)}static mergeMatches(e,t,r){if(t.length===0)return e;if(e.length===0)return t;let i=[...e,...t];return i.sort((o,s)=>o.quality>s.quality?-1:o.quality<s.quality?1:0),i.length<=r?i:i.slice(0,r)}},ze=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 q(e.string.substring(0,this.maxQueryLength),e.topN,e.searchers)),De.mergeResults(this.mainSearcher.getMatches(e),this.secondarySearcher.getMatches(e))):new $([],e,new b)}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,o=e.length;i<o;i++)(this.mainSearcher.removeEntity(e[i])||this.secondarySearcher.removeEntity(e[i]))&&t.push(e[i]);let r=new b;return new Fe(t,r)}upsertEntities(e,t,r){let i=[],o=[];for(let s=0,a=e.length;s<a;s++){let c=e[s],l=t(c);this.tryUpdate(c,l,r)||(i.push(l),o.push(c))}return this.removeEntities(i),o.length>0?this.reindexSecondarySearcher(o,t,r):new b}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 o=i.tryGetTerms(t);if(o===null)return!1;if(this.termsAreEqual(o,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)}},Ne=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(),o=this.dynamicSearcher.upsertEntities(e,t,r),s=Math.round(performance.now()-i);return o.add("upsertDuration",s),o}indexEntities(e,t,r){let i=performance.now(),o=this.dynamicSearcher.indexEntities(e,t,r),s=Math.round(performance.now()-i);return o.add("indexingDurationTotal",s),o}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)}},$e=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}},qe=class{constructor(e){this.query=void 0,this.matchedIndexes=new Set,this.matches=[],this.meta=[],this.query=e}},ne=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}},Oe=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:y.Prefix,qualityOffset:2},{searcherType:y.Substring,qualityOffset:1},{searcherType:y.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=[],o=[];for(let a=0,c=e.length;a<c;a++){this.idToIndex.set(t(e[a]),a);let l=r(e[a]);o.push(this.terms.length),this.terms.push(...l),i.push(...l.map(()=>a))}this.termIndexToEntityIndex=N.ToInt32Array(i),this.entityIndexToFirstTermIndex=N.ToInt32Array(o);let s=this.stringSearcher.index(this.terms);return s.add("numberOfEntities",this.entities.length),s.add("numberOfTerms",this.terms.length),s}getMatches(e){let t=new qe(e),r=new he(this.searcherTypes,e.searchers);for(let{searcherType:o,qualityOffset:s}of this.searchersAndQualityOffsets){if(e.topN==t.matches.length)break;r.has(o)&&this.addMatchesFromSearcher(t,r.spec(o),s)}let i=X.mergeMeta(t.meta);return new $(t.matches,e,i)}addMatchesFromSearcher(e,t,r){let i=Math.max(0,t.minQuality-r);if(i>1)return;let o=new ne(e.query.string,i,t.type),s=this.stringSearcher.getMatches(o);this.addMatchesFromResult(e,s,r)}addMatchesFromResult(e,t,r){if(e.meta.push(t.meta),e.query.topN!==0)for(let i=0,o=t.matches.length;i<o;i++){let s=t.matches[i],a=this.termIndexToEntityIndex[s.index];if(!e.matchedIndexes.has(a)&&this.entities[a]!==null&&(e.matchedIndexes.add(a),e.matches.push(new $e(this.entities[a],s.quality+r,this.terms[s.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)}},B=class{constructor(e,t){this.strings=void 0,this.meta=void 0,this.strings=e,this.meta=t}},We=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,o=!1;for(let s=0,a=e.length;s<a;s++){let c=this.getNormalizedCharacter(e[s]);c!==""&&(c===" "?i=!0:(i&&o&&(t[r++]=" "),t[r++]=c,o=!0,i=!1))}return o?t.join(""):""}getNormalizedCharacter(e){return e===" "||this.treatCharacterAsSpace(e)?" ":this.isSurrogate(e)||!this.allowCharacter(e)?"":e.toLowerCase()}isSurrogate(e){return!!ue.isSurrogate(e)&&(this.numberOfSurrogateCharacters++,!0)}normalizeBulk(e){this.numberOfSurrogateCharacters=0;let t=e.map(i=>this.normalize(i)),r=new b;return r.add("numberOfSurrogateCharacters",this.numberOfSurrogateCharacters),new B(t,r)}},Ge=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 B(t,new b)}},Ue=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 b;for(let r=0,i=this.normalizers.length;r<i;r++){let o=this.normalizers[r].normalizeBulk(e);e=o.strings;for(let s of o.meta.allEntries)t.add(s[0],s[1])}return new B(e,t)}},_e=class{normalize(e){return e||""}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new B(t,new b)}},Qe=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[o,s]of r)for(let a of s){let c=t(a);i.set(c,o)}this.replacements.push(i)}}normalize(e){e=this.normalizeVariationsAndInput(e);let t=new Array(e.length),r=0;for(let i=0,o=e.length;i<o;i++)for(let s of this.replacements){let a=s.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 B(t,new b)}},je=class{static create(e){let t=new _e,r=new Qe(e.replacements,s=>s.toLowerCase().normalize("NFKC")),i=new Ge(s=>s.normalize("NFKD")),o=new We(e.treatCharacterAsSpace,e.allowCharacter);return new Ue([t,r,i,o])}},re=class{constructor(e,t){this.index=void 0,this.quality=void 0,this.index=e,this.quality=t}},P=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}},Ye=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=[],o=0,s=null;for(let c=0,l=t.length;c<l;c++){let u=t[c].term;u!=s&&(r[o]=u,i[o]=c,o++),s=u}i[o++]=t.length,this.distinctMapping=N.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(o=>{let s=this.distinctMapping[o.index+1];for(let a=this.distinctMapping[o.index];a<s;a++)r[i++]=new re(this.sortMapping[a],o.quality)}),new P(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)}},Ve=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 he(this.searcherTypes,e.searchers);if(e.topN>200)return this.entitySearcher.getMatches(e);if(e.string.length<=3&&t.has(y.Prefix)&&t.minQuality(y.Prefix)<2.2){let r=new q(e.string,e.topN,[new _(2.3)]),i=this.entitySearcher.getMatches(r);if(i.matches.length==e.topN)return new $(i.matches,e,i.meta)}if(e.string.length<=3&&!t.has(y.Prefix)&&t.has(y.Substring)&&t.minQuality(y.Substring)<1.2){let r=new q(e.string,e.topN,[new U(1.3)]),i=this.entitySearcher.getMatches(r);if(i.matches.length==e.topN)return new $(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)}},de=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=N.ToInt32Array(this.ids),this.frequencies=N.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()}},J=class{constructor(){this.ngramToTermIds=void 0,this.ngramToTermIds=new Map}add(e,t,r){let i=this.ngramToTermIds.get(e);i||(i=new de,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(),o=new de;o.load(e),this.ngramToTermIds.set(i,o)}}},Ke=class{static ComputeJaccardCoefficient(e,t,r){return r/(e+t-r)}static ComputeOverlapMaxCoefficient(e,t,r){return r/Math.max(e,t)}},Je=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 J,this.numberOfNgrams=new Int32Array(0),this.commonNgramCounts=new Int32Array(0)}index(e){let t=performance.now();this.invertedIndex=new J,this.commonNgramCounts=new Int32Array(e.length),this.numberOfNgrams=new Int32Array(e.length);let r=0;for(let s=0,a=e.length;s<a;s++){let c=e[s];if(!this.isValidTerm(c)){this.numberOfNgrams[s]=0,r++;continue}let l=this.ngramComputer.computeNgrams(c);this.numberOfNgrams[s]=l.length;let u=this.getNgramsToFrequency(l);for(let[h,d]of u)this.invertedIndex.add(h,s,d)}this.invertedIndex.seal();let i=Math.round(performance.now()-t),o=new b;return o.add("numberOfInvalidTerms",r),o.add("indexingDurationFuzzySearcher",i),o}isValidTerm(e){return e!=null&&e.trim()!==""}getMatches(e){if(this.invertedIndex.size===0)return new P([],e,new b);let t=this.ngramComputer.computeNgrams(e.string),r=this.getNgramsToFrequency(t),i=t.length;this.computeCommonNgramCounts(r);let o=this.getMatchesFromCommonNgrams(i,e.minQuality);return new P(o,e,new b)}computeCommonNgramCounts(e){this.commonNgramCounts.fill(0);for(let[t,r]of e){let i=this.invertedIndex.getIds(t);if(i!=null)for(let o=0,s=i.length;o<s;o++)this.commonNgramCounts[i.ids[o]]+=Math.min(r,i.frequencies[o])}}getNgramsToFrequency(e){let t=new Map;for(let r=0,i=e.length;r<i;r++){let o=e[r],s=t.get(o);t.set(o,s!==void 0?s+1:1)}return t}getMatchesFromCommonNgrams(e,t){let r=[];for(let i=0,o=this.numberOfNgrams.length;i<o;i++){let s=Ke.ComputeOverlapMaxCoefficient(e,this.numberOfNgrams[i],this.commonNgramCounts[i]);s>t&&r.push(new re(i,s))}return r}save(e){this.invertedIndex.save(e),e.add(this.numberOfNgrams)}load(e){this.invertedIndex=new J,this.invertedIndex.load(e),this.numberOfNgrams=e.get(),this.commonNgramCounts=new Int32Array(this.numberOfNgrams.length)}},Xe=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]=le.getHashCode(e[t]);return this.stringSearcher.index(e)}getMatches(e){let t=le.getHashCode(e.string),r=this.stringSearcher.getMatches(e),i=r.matches.map(o=>this.penalizeMatch(o,t)).filter(o=>o.quality>=e.minQuality);return new P(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 o=this.transformNgram(e.substring(r,r+this.ngramN));o&&t.push(o)}return t}maximumNumberOfNgrams(e){return Math.max(e.length-this.ngramN+1,e.length>0?1:0)}},et=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 b;return new B(t,r)}},me=class{};me.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 ge=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([me.Value],t=>e.has(t),t=>ue.isAlphanumeric(t))}},fe=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),o=this.stringSearcher.index(r.strings);o.add(this.normalizationDurationMetaKey,i);for(let s of r.meta.allEntries)o.add(s[0],s[1]);return o}getMatches(e){let t=new ne(this.normalizer.normalize(e.string),e.minQuality,e.searcherType),r=this.stringSearcher.getMatches(t);return new P(r.matches,e,r.meta)}save(e){this.stringSearcher.save(e)}load(e){this.stringSearcher.load(e)}},tt=class{constructor(e){this.suffixArraySearcher=void 0,this.suffixArraySearcher=e}index(e){return this.suffixArraySearcher.index(e)}getMatches(e){if(!e.string)return new P([],e,new b);let t=this.modifyQueryString(e.string),r=new ne(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)}},nt=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 X.mergeMeta(t)}getMatches(e){if(!e.searcherType)throw new Error("SearcherSwitch requires a searcher type.");switch(e.searcherType){case y.Prefix:if(!this.prefixSearcher)throw new Error("No prefix searcher has been indexed.");return this.prefixSearcher.getMatches(e);case y.Substring:if(!this.substringSearcher)throw new Error("No substring searcher has been indexed.");return this.substringSearcher.getMatches(e);case y.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"})(Z||(Z={}));var rt=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 Z.QualityAndIndex:return t;case Z.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)}},it=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)}},ie=class{static compareOrdinal(e,t,r,i,o){let s=Math.min(t+o,e.length),a=Math.min(i+o,r.length),c=t,l=i;for(;c<s&&l<a;){let d=e.charCodeAt(c),g=r.charCodeAt(l);if(d<g)return-1;if(d>g)return 1;c++,l++}let u=s-t,h=a-i;return u===h?0:u<h?-1:1}},ot=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 pe(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 st(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 pe(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 ie.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])}},st=class{constructor(e,t){this.head=void 0,this.rank=void 0,this.head=e,this.rank=t}},pe=class{constructor(e,t){this.head=void 0,this.length=void 0,this.head=e,this.length=t}},at=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=ot.create(this.str),this.indexToTermIndex=new Int32Array(this.suffixArray.length),this.termLengths=new Int32Array(e.length);let r=0;for(let s=0;s<e.length;s++){this.termLengths[s]=e[s].length;for(let a=0;a<=e[s].length;a++)this.indexToTermIndex[r++]=s}this.indexToTermIndex[r++]=-1;let i=Math.round(performance.now()-t),o=new b;return o.add("indexingDurationSuffixArraySearcher",i),o}getMatches(e,t){if(!e.string)return new P([],e,new b);let[r,i]=this.GetPositionsInSuffixArray(e.string),o=new Int32Array(i-r),s=new Set,a=0;for(let u=r;u<i;u++){let h=this.indexToTermIndex[this.suffixArray[u]];s.has(h)||(s.add(h),o[a++]=h)}let c=[];t=t??e.string.length;let l=0;for(let u=0;u<a;u++)l=this.computeQuality(t,this.termLengths[o[u]]),l>e.minQuality&&c.push(new re(o[u],l));return new P(c,e,new b)}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),ie.compareOrdinal(e,0,this.str,this.suffixArray[i],e.length)>0?t=i+1:r=i;let o=t;for(r=this.suffixArray.length;t<r;)i=Math.floor((t+r)/2),ie.compareOrdinal(e,0,this.str,this.suffixArray[i],e.length)==0?t=i+1:r=i;return[o,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()}},ye=class{static createSearcher(e){let t=this.createDefaultNormalizer(e),r=this.tryCreateFuzzySearcher(e),i=this.tryCreateSubstringSearcher(e),o=this.tryCreatePrefixSearcher(e,i),s=new nt(o,i,r);s=new Ye(s),s=new it(s),s=new fe(s,t,"normalizationDurationDefault");let a=new Oe(s,e.searcherTypes);return a=new Ve(a,e.searcherTypes),a=new rt(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 ge(e.normalizerConfig.replacements,e.normalizerConfig.treatCharacterAsSpace,i=>e.normalizerConfig.allowCharacter(i)&&!t.has(i));return je.create(r)}static tryCreateFuzzySearcher(e){if(!e.searcherTypes.includes(y.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 et(e.paddingLeft,e.paddingRight,e.paddingMiddle),i=new Je(t);return i=new Xe(i,e.inequalityPenalty),i=new fe(i,r,"normalizationDurationNgrams"),i}static tryCreateSubstringSearcher(e){if(!e.searcherTypes.includes(y.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 at(e.suffixArraySeparator)}static tryCreatePrefixSearcher(e,t){if(!e.searcherTypes.includes(y.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 tt(t)}},ct=class n{constructor(e,t,r,i,o,s){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=o,this.inequalityPenalty=s}static createDefaultConfig(){return new n("$$","!","!$$",3,e=>e.endsWith("$")?null:e.indexOf("$")===-1?e.split("").sort().join(""):e,.05)}};var lt=class n{constructor(e){this.suffixArraySeparator=void 0,this.suffixArraySeparator=e}static createDefaultConfig(){return new n("$")}},ut=class n{constructor(e,t,r,i,o,s){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=o,this.substringSearchConfig=s}static createDefaultConfig(){let e=[y.Fuzzy,y.Substring,y.Prefix],t=Z.QualityAndMatchedString,r=ge.createDefaultConfig(),i=ct.createDefaultConfig(),o=lt.createDefaultConfig();return new n(e,150,t,r,i,o)}},be=class{static createSearcher(e){let t=ye.createSearcher(e),r=ye.createSearcher(e),i=new ze(e.maxQueryLength,t,r);return i=new Ne(i),i}static createDefaultSearcher(){let e=ut.createDefaultConfig();return this.createSearcher(e)}};function oe(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 ht(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 dt(n,e,t,r,i){let o=Math.max(0,e-t),s=Math.max(0,r-i);return o<=0?0:Math.min(1,Math.max(0,n/o))*s}function se(n,e,t,r=5){let i=e+r,o=e+t-r;return n<i?{y:i-e,clipped:"above"}:n>o?{y:o-e,clipped:"below"}:{y:n-e,clipped:"none"}}function zn(n,e,t,r,i={}){let{tension:o=.38,clipStart:s="none",clipEnd:a="none"}=i,l=Math.min(.66,o+.24),u=s==="none"?o:l,h=a==="none"?o:l,d=t-n;return[{x:n,y:e},{x:n+d*u,y:e},{x:t-d*h,y:r},{x:t,y:r}]}function mt(n,e,t,r){return`M ${R(n.x)} ${R(n.y)} C ${R(e.x)} ${R(e.y)} ${R(t.x)} ${R(t.y)} ${R(r.x)} ${R(r.y)}`}function Nn(n,e,t,r,i){let o=Q(n,e,i),s=Q(e,t,i),a=Q(t,r,i),c=Q(o,s,i),l=Q(s,a,i),u=Q(c,l,i);return[[n,o,c,u],[u,l,a,r]]}function Q(n,e,t){return{x:(1-t)*n.x+t*e.x,y:(1-t)*n.y+t*e.y}}function gt(n,e,t,r,i={}){let{tension:o=.38,clipStart:s="none",clipEnd:a="none",splitT:c=.66}=i,l=zn(n,e,t,r,{tension:o,clipStart:s,clipEnd:a}),[u,h,d,g]=l;if(!(s!=="none"||a!=="none"))return{solid:mt(u,h,d,g)};let[f,p]=Nn(u,h,d,g,c),[v,x,I,H]=f,[k,M,E,G]=p;return{solid:mt(v,x,I,H),dotted:mt(k,M,E,G)}}function R(n){return n.toFixed(2)}function Rt(n){return[...n].sort((e,t)=>e.sourceStart-t.sourceStart)}function Ft(n,e){if(n.length===0)return null;let t=oe(n,e);return t===null?null:n.find(i=>i.commentrayLine===t)?.id??null}function ft(n){return Math.max(0,n-1)}function F(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 Dt(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 Se(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function zt(n,e){let t=e.map(r=>r.trim()).filter(Boolean);if(t.length===0)return Se(n);try{let r=t.map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`(${r.join("|")})`,"gi");return n.split(i).map((s,a)=>a%2===1?`<mark class="search-hit">${Se(s)}</mark>`:Se(s)).join("")}catch{return Se(n)}}function we(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()),o=[],s=0,a=0;for(;s<n.length&&a<400;){let c=s,l=-1,u=!0;for(let h of i){if(h.length===0)continue;let d=r.indexOf(h,c);if(d<0){u=!1;break}l<0&&(l=d),c=d+h.length}if(!u||l<0)break;o.push({start:l,end:c}),a++,s=l+1}return o}function Nt(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 $t(n,e){let t=n.split(`
3
- `);return e<0||e>=t.length?"":t[e]??""}function Te(n){return n.trim().split(/\s+/).filter(Boolean)}function qt(n,e){let t=Te(e);return t.length===0?[...n]:n.filter(r=>{let i=r.sourcePath.replace(/\\/g,"/");return we(i,t).length>0})}function Ot(n){let e=new Set,t=new Set,r=[],i=0;for(let o of n){let s=o.sourcePath.trim(),a=o.commentrayPath.trim();if(s.length>0){let c=`${s}\0${a}`;e.has(c)||(e.add(c),r.push({kind:"path",line:i++,text:s,spPath:o.sourcePath,crPath:o.commentrayPath}))}a.length>0&&!t.has(a)&&(t.add(a),r.push({kind:"path",line:i++,text:a,spPath:o.sourcePath,crPath:o.commentrayPath}))}return r}var $n=80;function Wt(n,e=$n){let t=new Map;for(let o of n){let s=o.sourcePath.trim();if(s.length===0)continue;let a=t.get(s),c={sourcePath:o.sourcePath.trim(),commentrayPath:o.commentrayPath.trim()};if(!a){t.set(s,c);continue}c.commentrayPath.localeCompare(a.commentrayPath)<0&&t.set(s,c)}let r=t.size;return{rows:[...t.values()].sort((o,s)=>o.sourcePath.localeCompare(s.sourcePath)).slice(0,e),totalUnique:r}}function S(n){return n.trim().replaceAll("\\","/").replace(/^\.\//,"")}function ve(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 pt=/^(?:\.\/)?browse\/([^/?#]+\.html)$/i;function Me(n){return pt.test(n.trim())}function O(n,e,t){let r=n.trim();if(r.startsWith("/"))return`${t}${r}`;let i=pt.exec(r);if(i?.[1]){let o=ve(e),s=o==="/"?`/browse/${i[1]}`:`${o}/browse/${i[1]}`;return`${t}${s}`}return new URL(r,`${t}${e}`).href}function Gt(n,e,t){let r=n.trim();if(r.length===0)return"";let i=pt.exec(r);return i?.[1]?`./browse/${i[1]}`:O(r,e,t)}function yt(n,e,t){let r=S(e),i=S(t);if(r.length>0){let o=n.find(s=>S(s.commentrayPath)===r);if(o)return o}if(i.length>0){let o=n.find(s=>S(s.sourcePath)===i);if(o)return o}}function bt(n,e,t){return S(n.sourcePath)===S(e)&&S(n.commentrayPath)===S(t)}var wt="commentray.codeCommentrayStatic.colorTheme",St=["system","light","dark"];function Ut(n){let e=St.indexOf(n),t=(e>=0?e+1:0)%St.length;return St[t]??"system"}function Ee(n){return n==="light"||n==="dark"||n==="system"?n:"system"}function qn(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 Tt(n){let e=globalThis.document?.documentElement;e&&(e.dataset.commentrayTheme=n,qn(n))}function Le(n,e,t){return Math.max(e,Math.min(t,n))}function _t(n,e){let t=e.getBoundingClientRect(),r=globalThis.innerWidth,i=globalThis.innerHeight,o=n.getBoundingClientRect(),s=o.width>0?o.width:340,a=o.height>0?o.height:160,c=8,l=t.bottom+12+a<=i-c,u=l?Math.max(c,t.bottom+12):Math.max(c,t.top-a-12),h=Le(t.left,c,r-s-c);n.style.top=`${String(Math.round(u))}px`,n.style.left=`${String(Math.round(h))}px`,n.dataset.side=l?"below":"above";let d=Le(t.left+t.width/2-h-8,10,s-22);n.style.setProperty("--pointer-left",`${String(Math.round(d))}px`)}function Qt(n,e,t){if(e.replaceChildren(),t.length===0)return;let r=n.getBoundingClientRect(),i=r.left+r.width/2,o=r.top+r.height/2,s=12,a=8,c=12,l=n.dataset.side,u=Number.parseFloat(n.style.getPropertyValue("--pointer-left")),h=Number.isFinite(u)?r.left+u+8:i,d=l==="below"?r.top-a:l==="above"?r.bottom+a:o;for(let[g,m]of t.entries()){let f=m.getBoundingClientRect(),p=f.left+f.width/2,v=f.top+f.height/2,x=p-i,I=v-o,H=Math.abs(x)>=Math.abs(I),k=g-(t.length-1)/2,M,E;t.length===1&&(l==="below"||l==="above")?(M=h,E=d):H?(M=x>=0?r.right+a:r.left-a,E=Le(v+k*c,r.top+s,r.bottom-s)):(E=I>=0?r.bottom+a:r.top-a,M=Le(p+k*c,r.left+s,r.right-s));let G=p-M,Y=v-E,V=Math.hypot(G,Y);if(!Number.isFinite(V)||V<12)continue;let C=document.createElement("span");C.className="commentray-wide-intro-arrow",C.style.left=`${String(Math.round(M))}px`,C.style.top=`${String(Math.round(E))}px`,C.style.width=`${String(Math.round(V))}px`,C.style.setProperty("--wide-intro-arrow-angle",`${String(Math.atan2(Y,G))}rad`);let K=document.createElement("span");K.className="commentray-wide-intro-arrow-head",C.appendChild(K),e.appendChild(C)}}function vt(n,e){let t=e?"#mobile-pane-flip":"#shell",r=n.id.trim().length>0&&typeof globalThis.CSS?.escape=="function"?`#${globalThis.CSS.escape(n.id)}`:"#shell",i=t==="#shell"?r:t;return[{targetSelectors:e?[i]:["#code-pane","#doc-pane"],title:"Welcome",body:"Welcome to commentray, a system to create and view commentaries next to the source tree. Angles are different aspects of these commentaries, so switch between them and keep scrolling while both panes stay aligned."},{targetSelectors:e?[i]:["#code-pane","#doc-pane"],title:"Two views",body:e?"You are in narrow view now. Use the pane flip to switch code and commentary. Wide view shows both panes side by side.":"You are in wide view now. It shows code and commentary side by side. Narrow view uses one pane and a flip control."},{targetSelectors:e?["#mobile-pane-flip","#doc-pane"]:["#code-pane","#doc-pane"],title:e?"Scroll and toggle":"Scroll both panes",body:e?"Try scrolling commentary, then use the pane flip to switch to source and keep exploring.":"Try scrolling in either pane. Source and commentary stay aligned while you read side by side."},{targetSelector:"#search-q",title:"Search quickly",body:"Use this search input to jump to documented source lines and markdown snippets."},{targetSelector:"#angle-select",title:"Angle switch",body:"Change the Commentray angle to view a different narrative for this same source file."},{targetSelector:"#source-markdown-pane-flip",title:"Source view mode",body:"Toggle between raw source and rendered markdown in the source pane."},{targetSelector:"#wrap-lines",title:"Readability controls",body:"Wrap lines to reduce horizontal scrolling in both source and commentary panes.",fallbackActionLabel:"Switch to markdown source",fallbackAction:()=>{let o=document.getElementById("source-markdown-pane-flip");o instanceof HTMLButtonElement&&o.click()}},{targetSelector:"#commentray-theme-trigger",title:"Appearance",body:"Change theme mode from this trigger (menu on left-click, quick cycle on right-click)."},{targetSelector:"#commentray-share-link",title:"Share this view",body:"Use this link button to copy a shareable permalink to the exact page and state you are viewing."},{targetSelector:"#commentray-help-tour",title:"Need a refresher?",body:"You can always go back to this tutorial via the help button."}]}function On(n,e){let t=n[e];if(!t)return[];let r=Array.isArray(t.targetSelectors)&&t.targetSelectors.length>0?t.targetSelectors:t.targetSelector?[t.targetSelector]:[],i=[],o=new Set;for(let s of r){let a=document.querySelector(s);!(a instanceof HTMLElement)||o.has(a)||(o.add(a),i.push(a))}return i}function Wn(n){if(n.hidden)return!1;let e=globalThis.getComputedStyle(n);if(e.display==="none"||e.visibility==="hidden")return!1;let t=n.getBoundingClientRect();return t.width>0&&t.height>0}function xe(n,e){return On(n,e).filter(t=>Wn(t))}function jt(){for(let t of Array.from(document.querySelectorAll(".commentray-wide-intro-target")))t instanceof HTMLElement&&t.classList.remove("commentray-wide-intro-target");let n=document.getElementById("commentray-wide-intro");n instanceof HTMLElement&&n.remove();let e=document.getElementById("commentray-wide-intro-arrows");e instanceof HTMLElement&&e.remove()}function Yt(){let n=document.createElement("div");n.id="commentray-wide-intro-arrows",n.setAttribute("aria-hidden","true"),document.body.appendChild(n);let e=document.createElement("section");e.id="commentray-wide-intro",e.setAttribute("role","dialog"),e.setAttribute("aria-live","polite"),e.innerHTML=`
1
+ "use strict";(()=>{var z=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}},le=class{static getHashCode(e){let t=5381,r=t;for(let i=0,o=e.length;i<o&&e[i]!="\0"&&(t=(t<<5)+t^e.charCodeAt(i),i!==o-1&&e[i+1]!=="\0");i+=2)r=(r<<5)+r^e.charCodeAt(i+1);return t+1566083941*r|0}},b=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)}}},J=class{static mergeMeta(e){if(e.length===0)return new b;if(e.length===1)return e[0];let t=new Map;for(let i of e)for(let[o,s]of i.allEntries){let a=t.get(o);a===void 0?t.set(o,[s]):a.push(s)}let r=new Map;for(let[i,o]of t)if(o.length!==1){if(o.every(s=>typeof s=="number")){let s=o.reduce((a,c)=>a+c,0);r.set(i,s);continue}for(let s=0;s<o.length;s++)r.set(`${i}_${s}`,o[s])}else r.set(i,o[0]);return new b(r)}},ue=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}},he=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)}},$=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}},y,X;(function(n){n.Fuzzy="fuzzy",n.Substring="substring",n.Prefix="prefix"})(y||(y={}));var Z=class{constructor(e,t){this.type=void 0,this.minQuality=void 0,this.type=e,this.minQuality=Math.max(0,t)}},ee=class extends Z{constructor(e){super(y.Fuzzy,e)}},U=class extends Z{constructor(e){super(y.Substring,e)}},Q=class extends Z{constructor(e){super(y.Prefix,e)}},O=class{constructor(e,t=10,r=[new ee(.3),new U(0),new Q(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}},Ne=class{constructor(e,t){this.removedEntities=void 0,this.meta=void 0,this.removedEntities=e,this.meta=t}},ze=class{static mergeResults(e,t){let r=e.query,i=this.mergeMatches(e.matches,t.matches,r.topN),o=J.mergeMeta([e.meta,t.meta]);return new $(i,r,o)}static mergeMatches(e,t,r){if(t.length===0)return e;if(e.length===0)return t;let i=[...e,...t];return i.sort((o,s)=>o.quality>s.quality?-1:o.quality<s.quality?1:0),i.length<=r?i:i.slice(0,r)}},$e=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 O(e.string.substring(0,this.maxQueryLength),e.topN,e.searchers)),ze.mergeResults(this.mainSearcher.getMatches(e),this.secondarySearcher.getMatches(e))):new $([],e,new b)}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,o=e.length;i<o;i++)(this.mainSearcher.removeEntity(e[i])||this.secondarySearcher.removeEntity(e[i]))&&t.push(e[i]);let r=new b;return new Ne(t,r)}upsertEntities(e,t,r){let i=[],o=[];for(let s=0,a=e.length;s<a;s++){let c=e[s],l=t(c);this.tryUpdate(c,l,r)||(i.push(l),o.push(c))}return this.removeEntities(i),o.length>0?this.reindexSecondarySearcher(o,t,r):new b}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 o=i.tryGetTerms(t);if(o===null)return!1;if(this.termsAreEqual(o,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)}},Oe=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(),o=this.dynamicSearcher.upsertEntities(e,t,r),s=Math.round(performance.now()-i);return o.add("upsertDuration",s),o}indexEntities(e,t,r){let i=performance.now(),o=this.dynamicSearcher.indexEntities(e,t,r),s=Math.round(performance.now()-i);return o.add("indexingDurationTotal",s),o}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)}},qe=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}},We=class{constructor(e){this.query=void 0,this.matchedIndexes=new Set,this.matches=[],this.meta=[],this.query=e}},te=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}},Ge=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:y.Prefix,qualityOffset:2},{searcherType:y.Substring,qualityOffset:1},{searcherType:y.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=[],o=[];for(let a=0,c=e.length;a<c;a++){this.idToIndex.set(t(e[a]),a);let l=r(e[a]);o.push(this.terms.length),this.terms.push(...l),i.push(...l.map(()=>a))}this.termIndexToEntityIndex=z.ToInt32Array(i),this.entityIndexToFirstTermIndex=z.ToInt32Array(o);let s=this.stringSearcher.index(this.terms);return s.add("numberOfEntities",this.entities.length),s.add("numberOfTerms",this.terms.length),s}getMatches(e){let t=new We(e),r=new he(this.searcherTypes,e.searchers);for(let{searcherType:o,qualityOffset:s}of this.searchersAndQualityOffsets){if(e.topN==t.matches.length)break;r.has(o)&&this.addMatchesFromSearcher(t,r.spec(o),s)}let i=J.mergeMeta(t.meta);return new $(t.matches,e,i)}addMatchesFromSearcher(e,t,r){let i=Math.max(0,t.minQuality-r);if(i>1)return;let o=new te(e.query.string,i,t.type),s=this.stringSearcher.getMatches(o);this.addMatchesFromResult(e,s,r)}addMatchesFromResult(e,t,r){if(e.meta.push(t.meta),e.query.topN!==0)for(let i=0,o=t.matches.length;i<o;i++){let s=t.matches[i],a=this.termIndexToEntityIndex[s.index];if(!e.matchedIndexes.has(a)&&this.entities[a]!==null&&(e.matchedIndexes.add(a),e.matches.push(new qe(this.entities[a],s.quality+r,this.terms[s.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)}},I=class{constructor(e,t){this.strings=void 0,this.meta=void 0,this.strings=e,this.meta=t}},_e=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,o=!1;for(let s=0,a=e.length;s<a;s++){let c=this.getNormalizedCharacter(e[s]);c!==""&&(c===" "?i=!0:(i&&o&&(t[r++]=" "),t[r++]=c,o=!0,i=!1))}return o?t.join(""):""}getNormalizedCharacter(e){return e===" "||this.treatCharacterAsSpace(e)?" ":this.isSurrogate(e)||!this.allowCharacter(e)?"":e.toLowerCase()}isSurrogate(e){return!!ue.isSurrogate(e)&&(this.numberOfSurrogateCharacters++,!0)}normalizeBulk(e){this.numberOfSurrogateCharacters=0;let t=e.map(i=>this.normalize(i)),r=new b;return r.add("numberOfSurrogateCharacters",this.numberOfSurrogateCharacters),new I(t,r)}},Ue=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 I(t,new b)}},Qe=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 b;for(let r=0,i=this.normalizers.length;r<i;r++){let o=this.normalizers[r].normalizeBulk(e);e=o.strings;for(let s of o.meta.allEntries)t.add(s[0],s[1])}return new I(e,t)}},je=class{normalize(e){return e||""}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new I(t,new b)}},Ye=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[o,s]of r)for(let a of s){let c=t(a);i.set(c,o)}this.replacements.push(i)}}normalize(e){e=this.normalizeVariationsAndInput(e);let t=new Array(e.length),r=0;for(let i=0,o=e.length;i<o;i++)for(let s of this.replacements){let a=s.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 I(t,new b)}},Ve=class{static create(e){let t=new je,r=new Ye(e.replacements,s=>s.toLowerCase().normalize("NFKC")),i=new Ue(s=>s.normalize("NFKD")),o=new _e(e.treatCharacterAsSpace,e.allowCharacter);return new Qe([t,r,i,o])}},ne=class{constructor(e,t){this.index=void 0,this.quality=void 0,this.index=e,this.quality=t}},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}},Ke=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=[],o=0,s=null;for(let c=0,l=t.length;c<l;c++){let u=t[c].term;u!=s&&(r[o]=u,i[o]=c,o++),s=u}i[o++]=t.length,this.distinctMapping=z.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(o=>{let s=this.distinctMapping[o.index+1];for(let a=this.distinctMapping[o.index];a<s;a++)r[i++]=new ne(this.sortMapping[a],o.quality)}),new H(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)}},Je=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 he(this.searcherTypes,e.searchers);if(e.topN>200)return this.entitySearcher.getMatches(e);if(e.string.length<=3&&t.has(y.Prefix)&&t.minQuality(y.Prefix)<2.2){let r=new O(e.string,e.topN,[new Q(2.3)]),i=this.entitySearcher.getMatches(r);if(i.matches.length==e.topN)return new $(i.matches,e,i.meta)}if(e.string.length<=3&&!t.has(y.Prefix)&&t.has(y.Substring)&&t.minQuality(y.Substring)<1.2){let r=new O(e.string,e.topN,[new U(1.3)]),i=this.entitySearcher.getMatches(r);if(i.matches.length==e.topN)return new $(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)}},de=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=z.ToInt32Array(this.ids),this.frequencies=z.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()}},K=class{constructor(){this.ngramToTermIds=void 0,this.ngramToTermIds=new Map}add(e,t,r){let i=this.ngramToTermIds.get(e);i||(i=new de,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(),o=new de;o.load(e),this.ngramToTermIds.set(i,o)}}},Xe=class{static ComputeJaccardCoefficient(e,t,r){return r/(e+t-r)}static ComputeOverlapMaxCoefficient(e,t,r){return r/Math.max(e,t)}},Ze=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 K,this.numberOfNgrams=new Int32Array(0),this.commonNgramCounts=new Int32Array(0)}index(e){let t=performance.now();this.invertedIndex=new K,this.commonNgramCounts=new Int32Array(e.length),this.numberOfNgrams=new Int32Array(e.length);let r=0;for(let s=0,a=e.length;s<a;s++){let c=e[s];if(!this.isValidTerm(c)){this.numberOfNgrams[s]=0,r++;continue}let l=this.ngramComputer.computeNgrams(c);this.numberOfNgrams[s]=l.length;let u=this.getNgramsToFrequency(l);for(let[h,d]of u)this.invertedIndex.add(h,s,d)}this.invertedIndex.seal();let i=Math.round(performance.now()-t),o=new b;return o.add("numberOfInvalidTerms",r),o.add("indexingDurationFuzzySearcher",i),o}isValidTerm(e){return e!=null&&e.trim()!==""}getMatches(e){if(this.invertedIndex.size===0)return new H([],e,new b);let t=this.ngramComputer.computeNgrams(e.string),r=this.getNgramsToFrequency(t),i=t.length;this.computeCommonNgramCounts(r);let o=this.getMatchesFromCommonNgrams(i,e.minQuality);return new H(o,e,new b)}computeCommonNgramCounts(e){this.commonNgramCounts.fill(0);for(let[t,r]of e){let i=this.invertedIndex.getIds(t);if(i!=null)for(let o=0,s=i.length;o<s;o++)this.commonNgramCounts[i.ids[o]]+=Math.min(r,i.frequencies[o])}}getNgramsToFrequency(e){let t=new Map;for(let r=0,i=e.length;r<i;r++){let o=e[r],s=t.get(o);t.set(o,s!==void 0?s+1:1)}return t}getMatchesFromCommonNgrams(e,t){let r=[];for(let i=0,o=this.numberOfNgrams.length;i<o;i++){let s=Xe.ComputeOverlapMaxCoefficient(e,this.numberOfNgrams[i],this.commonNgramCounts[i]);s>t&&r.push(new ne(i,s))}return r}save(e){this.invertedIndex.save(e),e.add(this.numberOfNgrams)}load(e){this.invertedIndex=new K,this.invertedIndex.load(e),this.numberOfNgrams=e.get(),this.commonNgramCounts=new Int32Array(this.numberOfNgrams.length)}},et=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]=le.getHashCode(e[t]);return this.stringSearcher.index(e)}getMatches(e){let t=le.getHashCode(e.string),r=this.stringSearcher.getMatches(e),i=r.matches.map(o=>this.penalizeMatch(o,t)).filter(o=>o.quality>=e.minQuality);return new H(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)}},tt=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 o=this.transformNgram(e.substring(r,r+this.ngramN));o&&t.push(o)}return t}maximumNumberOfNgrams(e){return Math.max(e.length-this.ngramN+1,e.length>0?1:0)}},nt=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 b;return new I(t,r)}},me=class{};me.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 ge=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([me.Value],t=>e.has(t),t=>ue.isAlphanumeric(t))}},fe=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),o=this.stringSearcher.index(r.strings);o.add(this.normalizationDurationMetaKey,i);for(let s of r.meta.allEntries)o.add(s[0],s[1]);return o}getMatches(e){let t=new te(this.normalizer.normalize(e.string),e.minQuality,e.searcherType),r=this.stringSearcher.getMatches(t);return new H(r.matches,e,r.meta)}save(e){this.stringSearcher.save(e)}load(e){this.stringSearcher.load(e)}},rt=class{constructor(e){this.suffixArraySearcher=void 0,this.suffixArraySearcher=e}index(e){return this.suffixArraySearcher.index(e)}getMatches(e){if(!e.string)return new H([],e,new b);let t=this.modifyQueryString(e.string),r=new te(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)}},it=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 J.mergeMeta(t)}getMatches(e){if(!e.searcherType)throw new Error("SearcherSwitch requires a searcher type.");switch(e.searcherType){case y.Prefix:if(!this.prefixSearcher)throw new Error("No prefix searcher has been indexed.");return this.prefixSearcher.getMatches(e);case y.Substring:if(!this.substringSearcher)throw new Error("No substring searcher has been indexed.");return this.substringSearcher.getMatches(e);case y.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"})(X||(X={}));var ot=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 X.QualityAndIndex:return t;case X.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)}},st=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)}},re=class{static compareOrdinal(e,t,r,i,o){let s=Math.min(t+o,e.length),a=Math.min(i+o,r.length),c=t,l=i;for(;c<s&&l<a;){let d=e.charCodeAt(c),g=r.charCodeAt(l);if(d<g)return-1;if(d>g)return 1;c++,l++}let u=s-t,h=a-i;return u===h?0:u<h?-1:1}},at=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 pe(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 ct(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 pe(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 re.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])}},ct=class{constructor(e,t){this.head=void 0,this.rank=void 0,this.head=e,this.rank=t}},pe=class{constructor(e,t){this.head=void 0,this.length=void 0,this.head=e,this.length=t}},lt=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=at.create(this.str),this.indexToTermIndex=new Int32Array(this.suffixArray.length),this.termLengths=new Int32Array(e.length);let r=0;for(let s=0;s<e.length;s++){this.termLengths[s]=e[s].length;for(let a=0;a<=e[s].length;a++)this.indexToTermIndex[r++]=s}this.indexToTermIndex[r++]=-1;let i=Math.round(performance.now()-t),o=new b;return o.add("indexingDurationSuffixArraySearcher",i),o}getMatches(e,t){if(!e.string)return new H([],e,new b);let[r,i]=this.GetPositionsInSuffixArray(e.string),o=new Int32Array(i-r),s=new Set,a=0;for(let u=r;u<i;u++){let h=this.indexToTermIndex[this.suffixArray[u]];s.has(h)||(s.add(h),o[a++]=h)}let c=[];t=t??e.string.length;let l=0;for(let u=0;u<a;u++)l=this.computeQuality(t,this.termLengths[o[u]]),l>e.minQuality&&c.push(new ne(o[u],l));return new H(c,e,new b)}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),re.compareOrdinal(e,0,this.str,this.suffixArray[i],e.length)>0?t=i+1:r=i;let o=t;for(r=this.suffixArray.length;t<r;)i=Math.floor((t+r)/2),re.compareOrdinal(e,0,this.str,this.suffixArray[i],e.length)==0?t=i+1:r=i;return[o,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()}},ye=class{static createSearcher(e){let t=this.createDefaultNormalizer(e),r=this.tryCreateFuzzySearcher(e),i=this.tryCreateSubstringSearcher(e),o=this.tryCreatePrefixSearcher(e,i),s=new it(o,i,r);s=new Ke(s),s=new st(s),s=new fe(s,t,"normalizationDurationDefault");let a=new Ge(s,e.searcherTypes);return a=new Je(a,e.searcherTypes),a=new ot(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 ge(e.normalizerConfig.replacements,e.normalizerConfig.treatCharacterAsSpace,i=>e.normalizerConfig.allowCharacter(i)&&!t.has(i));return Ve.create(r)}static tryCreateFuzzySearcher(e){if(!e.searcherTypes.includes(y.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 tt(e.ngramN,e.transformNgram),r=new nt(e.paddingLeft,e.paddingRight,e.paddingMiddle),i=new Ze(t);return i=new et(i,e.inequalityPenalty),i=new fe(i,r,"normalizationDurationNgrams"),i}static tryCreateSubstringSearcher(e){if(!e.searcherTypes.includes(y.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 lt(e.suffixArraySeparator)}static tryCreatePrefixSearcher(e,t){if(!e.searcherTypes.includes(y.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 rt(t)}},ut=class n{constructor(e,t,r,i,o,s){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=o,this.inequalityPenalty=s}static createDefaultConfig(){return new n("$$","!","!$$",3,e=>e.endsWith("$")?null:e.indexOf("$")===-1?e.split("").sort().join(""):e,.05)}};var ht=class n{constructor(e){this.suffixArraySeparator=void 0,this.suffixArraySeparator=e}static createDefaultConfig(){return new n("$")}},dt=class n{constructor(e,t,r,i,o,s){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=o,this.substringSearchConfig=s}static createDefaultConfig(){let e=[y.Fuzzy,y.Substring,y.Prefix],t=X.QualityAndMatchedString,r=ge.createDefaultConfig(),i=ut.createDefaultConfig(),o=ht.createDefaultConfig();return new n(e,150,t,r,i,o)}},be=class{static createSearcher(e){let t=ye.createSearcher(e),r=ye.createSearcher(e),i=new $e(e.maxQueryLength,t,r);return i=new Oe(i),i}static createDefaultSearcher(){let e=dt.createDefaultConfig();return this.createSearcher(e)}};function ie(n,e){if(n.length===0)return null;let t=[...n].sort((c,l)=>c.markerViewportHalfOpen1Based.lo-l.markerViewportHalfOpen1Based.lo),r=t[0];if(r===void 0)return null;let i=r.markerViewportHalfOpen1Based.lo,o=t.find(c=>c.markerViewportHalfOpen1Based.lo<=e&&e<c.markerViewportHalfOpen1Based.hiExclusive);if(o)return o.commentrayLine;if(e<i)return r.commentrayLine;let s=r,a=-1/0;for(let c of t){let l=c.markerViewportHalfOpen1Based.lo;l<=e&&l>a&&(s=c,a=l)}return s.commentrayLine}function mt(n,e){if(n.length===0)return null;let t=[...n].sort((o,s)=>o.commentrayLine-s.commentrayLine),r=t[0];if(r===void 0)return null;let i=r;for(let o of t)o.commentrayLine<=e&&(i=o);return i.markerViewportHalfOpen1Based.lo-1}function gt(n,e,t,r,i){let o=Math.max(0,e-t),s=Math.max(0,r-i);return o<=0?0:Math.min(1,Math.max(0,n/o))*s}function oe(n,e,t,r=5){let i=e+r,o=e+t-r;return n<i?{y:i-e,clipped:"above"}:n>o?{y:o-e,clipped:"below"}:{y:n-e,clipped:"none"}}function Kn(n,e,t,r,i={}){let{tension:o=.38,clipStart:s="none",clipEnd:a="none"}=i,l=Math.min(.66,o+.24),u=s==="none"?o:l,h=a==="none"?o:l,d=t-n;return[{x:n,y:e},{x:n+d*u,y:e},{x:t-d*h,y:r},{x:t,y:r}]}function ft(n,e,t,r){return`M ${R(n.x)} ${R(n.y)} C ${R(e.x)} ${R(e.y)} ${R(t.x)} ${R(t.y)} ${R(r.x)} ${R(r.y)}`}function Jn(n,e,t,r,i){let o=j(n,e,i),s=j(e,t,i),a=j(t,r,i),c=j(o,s,i),l=j(s,a,i),u=j(c,l,i);return[[n,o,c,u],[u,l,a,r]]}function j(n,e,t){return{x:(1-t)*n.x+t*e.x,y:(1-t)*n.y+t*e.y}}function yt(n,e,t,r,i={}){let{tension:o=.38,clipStart:s="none",clipEnd:a="none",splitT:c=.66}=i,l=Kn(n,e,t,r,{tension:o,clipStart:s,clipEnd:a}),[u,h,d,g]=l;if(!(s!=="none"||a!=="none"))return{solid:ft(u,h,d,g)};let[f,p]=Jn(u,h,d,g,c),[E,x,P,k]=f,[C,w,M,G]=p;return{solid:ft(E,x,P,k),dotted:ft(C,w,M,G)}}function R(n){return n.toFixed(2)}function Se(n){return[...n].sort((e,t)=>e.sourceStart-t.sourceStart)}function Gt(n){let e=new Map;for(let t of Se(n))e.has(t.id)||e.set(t.id,t);return Se([...e.values()])}function _t(n){return[...n].sort((e,t)=>e.commentrayLine!==t.commentrayLine?e.commentrayLine-t.commentrayLine:e.sourceStart-t.sourceStart)}function Ut(n,e){let t=_t([...n]),r=t.findIndex(i=>i.id===e.id);if(!(r<0))return t[r+1]}function Qt(n,e){if(n.length===0)return null;let t=ie(n,e);return t===null?null:n.find(i=>i.commentrayLine===t)?.id??null}function jt(n,e){if(n.length===0)return null;let t=_t([...n]),r=t[0];if(r===void 0)return null;let i=r;for(let o of t)o.commentrayLine<=e&&(i=o);return i.id}function bt(n){return Math.max(0,n-1)}var St='.commentray-page-break[data-commentray-page-break="true"]';function we(n,e){return(n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)!==0}function Xn(n,e,t){return Array.from(n.querySelectorAll(St)).filter(r=>we(e,r)&&(t===null||we(r,t)))}var Wt=.5;function Zn(n){let e=n.closest(St);return!!(e&&!n.isSameNode(e))}function pt(n,e,t){let r=e.getBoundingClientRect().top+2;for(let i of Array.from(n.querySelectorAll("*"))){if(!(i instanceof HTMLElement)||t!==null&&(i===t||!we(i,t))||!we(e,i)||Zn(i)||i.matches(St))continue;let o=i.getBoundingClientRect();o.width<Wt||o.height<Wt||(r=Math.max(r,o.bottom))}return r}function wt(n,e,t){let r=Xn(n,e,t),i=e.getBoundingClientRect().top+2,o=e;for(let s of r)i=Math.max(i,pt(n,o,s)),o=s;return t?i=Math.max(i,pt(n,o,t)):i=Math.max(i,pt(n,o,null)),i}function Yt(n,e){let t=0;for(let{line0:r,top:i}of n)i<=e+1+.001&&(t=Math.max(t,r));return t}function F(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 Te(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Kt(n,e){let t=e.map(r=>r.trim()).filter(Boolean);if(t.length===0)return Te(n);try{let r=t.map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),i=new RegExp(`(${r.join("|")})`,"gi");return n.split(i).map((s,a)=>a%2===1?`<mark class="search-hit">${Te(s)}</mark>`:Te(s)).join("")}catch{return Te(n)}}function ve(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()),o=[],s=0,a=0;for(;s<n.length&&a<400;){let c=s,l=-1,u=!0;for(let h of i){if(h.length===0)continue;let d=r.indexOf(h,c);if(d<0){u=!1;break}l<0&&(l=d),c=d+h.length}if(!u||l<0)break;o.push({start:l,end:c}),a++,s=l+1}return o}function Jt(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 Zt(n,e){let t=Me(e);return t.length===0?[...n]:n.filter(r=>{let i=r.sourcePath.replace(/\\/g,"/");return ve(i,t).length>0})}function en(n){let e=new Set,t=new Set,r=[],i=0;for(let o of n){let s=o.sourcePath.trim(),a=o.commentrayPath.trim();if(s.length>0){let c=`${s}\0${a}`;e.has(c)||(e.add(c),r.push({kind:"path",line:i++,text:s,spPath:o.sourcePath,crPath:o.commentrayPath}))}a.length>0&&!t.has(a)&&(t.add(a),r.push({kind:"path",line:i++,text:a,spPath:o.sourcePath,crPath:o.commentrayPath}))}return r}var er=80;function tn(n,e=er){let t=new Map;for(let o of n){let s=o.sourcePath.trim();if(s.length===0)continue;let a=t.get(s),c={sourcePath:o.sourcePath.trim(),commentrayPath:o.commentrayPath.trim()};if(!a){t.set(s,c);continue}c.commentrayPath.localeCompare(a.commentrayPath)<0&&t.set(s,c)}let r=t.size;return{rows:[...t.values()].sort((o,s)=>o.sourcePath.localeCompare(s.sourcePath)).slice(0,e),totalUnique:r}}function S(n){return n.trim().replaceAll("\\","/").replace(/^\.\//,"")}function Ee(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 Tt=/^(?:\.\/)?browse\/([^/?#]+\.html)$/i,vt=/^(?:\.\/)?browse\/(.+)\/index\.html$/i;function Le(n){let e=n.trim();return Tt.test(e)||vt.test(e)}function q(n,e,t){let r=n.trim();if(r.startsWith("/"))return`${t}${r}`;let i=Ee(e),o=Tt.exec(r);if(o?.[1]){let a=i==="/"?`/browse/${o[1]}`:`${i}/browse/${o[1]}`;return`${t}${a}`}let s=vt.exec(r);if(s?.[1]){let a=s[1],c=i==="/"?`/browse/${a}/index.html`:`${i}/browse/${a}/index.html`;return`${t}${c}`}return new URL(r,`${t}${e}`).href}function nn(n,e,t){let r=n.trim();if(r.length===0)return"";let i=Tt.exec(r);if(i?.[1])return`./browse/${i[1]}`;let o=vt.exec(r);return o?.[1]?`./browse/${o[1]}/index.html`:q(r,e,t)}function Mt(n,e,t){let r=S(e),i=S(t);if(r.length>0){let o=n.find(s=>S(s.commentrayPath)===r);if(o)return o}if(i.length>0){let o=n.find(s=>S(s.sourcePath)===i);if(o)return o}}function Et(n,e,t){return S(n.sourcePath)===S(e)&&S(n.commentrayPath)===S(t)}var xt="commentray.codeCommentrayStatic.colorTheme",Lt=["system","light","dark"];function rn(n){let e=Lt.indexOf(n),t=(e>=0?e+1:0)%Lt.length;return Lt[t]??"system"}function xe(n){return n==="light"||n==="dark"||n==="system"?n:"system"}function tr(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 kt(n){let e=globalThis.document?.documentElement;e&&(e.dataset.commentrayTheme=n,tr(n))}function ke(n,e,t){return Math.max(e,Math.min(t,n))}function on(n,e){let t=e.getBoundingClientRect(),r=globalThis.innerWidth,i=globalThis.innerHeight,o=n.getBoundingClientRect(),s=o.width>0?o.width:340,a=o.height>0?o.height:160,c=8,l=t.bottom+12+a<=i-c,u=l?Math.max(c,t.bottom+12):Math.max(c,t.top-a-12),h=ke(t.left,c,r-s-c);n.style.top=`${String(Math.round(u))}px`,n.style.left=`${String(Math.round(h))}px`,n.dataset.side=l?"below":"above";let d=ke(t.left+t.width/2-h-8,10,s-22);n.style.setProperty("--pointer-left",`${String(Math.round(d))}px`)}function sn(n,e,t){if(e.replaceChildren(),t.length===0)return;let r=n.getBoundingClientRect(),i=r.left+r.width/2,o=r.top+r.height/2,s=12,a=8,c=12,l=n.dataset.side,u=Number.parseFloat(n.style.getPropertyValue("--pointer-left")),h=Number.isFinite(u)?r.left+u+8:i,d=l==="below"?r.top-a:l==="above"?r.bottom+a:o;for(let[g,m]of t.entries()){let f=m.getBoundingClientRect(),p=f.left+f.width/2,E=f.top+f.height/2,x=p-i,P=E-o,k=Math.abs(x)>=Math.abs(P),C=g-(t.length-1)/2,w,M;t.length===1&&(l==="below"||l==="above")?(w=h,M=d):k?(w=x>=0?r.right+a:r.left-a,M=ke(E+C*c,r.top+s,r.bottom-s)):(M=P>=0?r.bottom+a:r.top-a,w=ke(p+C*c,r.left+s,r.right-s));let G=p-w,ce=E-M,_=Math.hypot(G,ce);if(!Number.isFinite(_)||_<12)continue;let A=document.createElement("span");A.className="commentray-wide-intro-arrow",A.style.left=`${String(Math.round(w))}px`,A.style.top=`${String(Math.round(M))}px`,A.style.width=`${String(Math.round(_))}px`,A.style.setProperty("--wide-intro-arrow-angle",`${String(Math.atan2(ce,G))}rad`);let V=document.createElement("span");V.className="commentray-wide-intro-arrow-head",A.appendChild(V),e.appendChild(A)}}function Ht(n,e){let t=e?"#mobile-pane-flip":"#shell",r=n.id.trim().length>0&&typeof globalThis.CSS?.escape=="function"?`#${globalThis.CSS.escape(n.id)}`:"#shell",i=t==="#shell"?r:t;return[{targetSelectors:e?[i]:["#code-pane","#doc-pane"],title:"Welcome",body:"Welcome to commentray, a system to create and view commentaries next to the source tree. Angles are different aspects of these commentaries, so switch between them and keep scrolling while both panes stay aligned."},{targetSelectors:e?[i]:["#code-pane","#doc-pane"],title:"Two views",body:e?"You are in narrow view now. Use the pane flip to switch code and commentary. Wide view shows both panes side by side.":"You are in wide view now. It shows code and commentary side by side. Narrow view uses one pane and a flip control."},{targetSelectors:e?["#mobile-pane-flip","#doc-pane"]:["#code-pane","#doc-pane"],title:e?"Scroll and toggle":"Scroll both panes",body:e?"Try scrolling commentary, then use the pane flip to switch to source and keep exploring.":"Try scrolling in either pane. Source and commentary stay aligned while you read side by side."},{targetSelector:"#search-q",title:"Search quickly",body:"Use this search input to jump to documented source lines and markdown snippets."},{targetSelector:"#angle-select",title:"Angle switch",body:"Change the Commentray angle to view a different narrative for this same source file."},{targetSelector:"#source-markdown-pane-flip",title:"Source view mode",body:"Toggle between raw source and rendered markdown in the source pane."},{targetSelector:"#wrap-lines",title:"Readability controls",body:"Wrap lines to reduce horizontal scrolling in both source and commentary panes.",fallbackActionLabel:"Switch to markdown source",fallbackAction:()=>{let o=document.getElementById("source-markdown-pane-flip");o instanceof HTMLButtonElement&&o.click()}},{targetSelector:"#commentray-theme-trigger",title:"Appearance",body:"Change theme mode from this trigger (menu on left-click, quick cycle on right-click)."},{targetSelector:"#commentray-share-link",title:"Share this view",body:"Use this link button to copy a shareable permalink to the exact page and state you are viewing."},{targetSelector:"#commentray-help-tour",title:"Need a refresher?",body:"You can always go back to this tutorial via the help button."}]}function nr(n,e){let t=n[e];if(!t)return[];let r=Array.isArray(t.targetSelectors)&&t.targetSelectors.length>0?t.targetSelectors:t.targetSelector?[t.targetSelector]:[],i=[],o=new Set;for(let s of r){let a=document.querySelector(s);!(a instanceof HTMLElement)||o.has(a)||(o.add(a),i.push(a))}return i}function rr(n){if(n.hidden)return!1;let e=globalThis.getComputedStyle(n);if(e.display==="none"||e.visibility==="hidden")return!1;let t=n.getBoundingClientRect();return t.width>0&&t.height>0}function He(n,e){return nr(n,e).filter(t=>rr(t))}function an(){for(let t of Array.from(document.querySelectorAll(".commentray-wide-intro-target")))t instanceof HTMLElement&&t.classList.remove("commentray-wide-intro-target");let n=document.getElementById("commentray-wide-intro");n instanceof HTMLElement&&n.remove();let e=document.getElementById("commentray-wide-intro-arrows");e instanceof HTMLElement&&e.remove()}function cn(){let n=document.createElement("div");n.id="commentray-wide-intro-arrows",n.setAttribute("aria-hidden","true"),document.body.appendChild(n);let e=document.createElement("section");e.id="commentray-wide-intro",e.setAttribute("role","dialog"),e.setAttribute("aria-live","polite"),e.innerHTML=`
4
4
  <span class="commentray-wide-intro-pointer" aria-hidden="true"></span>
5
5
  <p class="commentray-wide-intro-title"></p>
6
6
  <p class="commentray-wide-intro-body"></p>
@@ -13,13 +13,13 @@
13
13
  <button type="button" data-wide-intro="skip">Skip</button>
14
14
  </div>
15
15
  </div>
16
- `,document.body.appendChild(e);let t=e.querySelector(".commentray-wide-intro-title"),r=e.querySelector(".commentray-wide-intro-body"),i=e.querySelector(".commentray-wide-intro-step-action"),o=e.querySelector(".commentray-wide-intro-progress"),s=e.querySelector('button[data-wide-intro="back"]'),a=e.querySelector('button[data-wide-intro="next"]'),c=e.querySelector('button[data-wide-intro="skip"]');return!(t instanceof HTMLElement)||!(r instanceof HTMLElement)||!(i instanceof HTMLButtonElement)||!(o instanceof HTMLElement)||!(s instanceof HTMLButtonElement)||!(a instanceof HTMLButtonElement)||!(c instanceof HTMLButtonElement)?(n.remove(),e.remove(),null):{bubble:e,arrowLayer:n,titleEl:t,bodyEl:r,stepActionBtn:i,progressEl:o,backBtn:s,nextBtn:a,skipBtn:c}}function D(n,e){try{return n.getItem(e)}catch{return null}}function A(n,e,t){try{n.setItem(e,t)}catch{}}var Vt="commentray.codeCommentrayStatic.wideModeIntro.v1";function Kt(n){let e=n.isNarrowViewport()?"narrow":"wide";e!==n.viewportMode&&(n.viewportMode=e,n.steps=vt(n.shell,e==="narrow"))}function Jt(n){let{bubble:e,arrowLayer:t}=n.elements;Kt(n);let r=xe(n.steps,n.current),i=r[0];if(!i){e.dataset.side="none",e.style.top="12px",e.style.left="12px",t.replaceChildren();return}_t(e,i),Qt(e,t,r)}function Gn(n){for(Kt(n);n.current<n.steps.length;){let e=n.steps[n.current];if(!e)break;let t=xe(n.steps,n.current),r=typeof e.fallbackAction=="function";if(t.length>0||r)break;n.current++}}function Un(n,e,t){let{stepActionBtn:r}=n.elements;if(t.length===0&&typeof e.fallbackAction=="function"&&e.fallbackActionLabel){r.hidden=!1,r.textContent=e.fallbackActionLabel,r.disabled=!1;return}r.hidden=!0,r.textContent="",r.disabled=!0}function _n(n,e){let{titleEl:t,bodyEl:r,progressEl:i,backBtn:o,nextBtn:s}=n.elements;if(Gn(n),n.current>=n.steps.length){e();return}let a=n.steps[n.current];if(!a)return;let c=xe(n.steps,n.current);for(let l of n.highlighted)l.classList.remove("commentray-wide-intro-target");n.highlighted=c;for(let l of n.highlighted)l.classList.add("commentray-wide-intro-target");t.textContent=a.title,r.textContent=a.body,Un(n,a,c),i.textContent=`${String(n.current+1)} / ${String(n.steps.length)}`,o.disabled=n.current===0,s.textContent=n.current===n.steps.length-1?"Done":"Next",Jt(n)}function Mt(n,e,t){if(!t?.force&&D(localStorage,Vt)==="1")return;jt();let r=Yt();if(!r)return;let i={shell:n,steps:vt(n,e()),viewportMode:e()?"narrow":"wide",current:0,highlighted:[],elements:r,isNarrowViewport:e},{bubble:o,arrowLayer:s,stepActionBtn:a,backBtn:c,nextBtn:l,skipBtn:u}=i.elements,h=()=>{for(let p of i.highlighted)p.classList.remove("commentray-wide-intro-target");i.highlighted=[],s.remove(),o.remove(),globalThis.removeEventListener("resize",m),globalThis.removeEventListener("scroll",d,!0),document.removeEventListener("keydown",f,!0),A(localStorage,Vt,"1")},d=()=>{Jt(i)},g=()=>{_n(i,h)},m=()=>{g()},f=p=>{p.key==="Escape"&&(p.preventDefault(),h())};c.addEventListener("click",()=>{i.current>0&&i.current--,g()}),a.addEventListener("click",()=>{let p=i.steps[i.current];!p||typeof p.fallbackAction!="function"||(p.fallbackAction(),g())}),l.addEventListener("click",()=>{if(i.current>=i.steps.length-1){h();return}i.current++,g()}),u.addEventListener("click",h),globalThis.addEventListener("resize",m),globalThis.addEventListener("scroll",d,!0),document.addEventListener("keydown",f,!0),g()}function Pe(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()??"";Me(i)&&(r.href=O(i,e,t))}}function Ae(n){if(typeof globalThis.location<"u"&&globalThis.location.protocol==="file:")return;let t=Array.from(n.querySelectorAll("pre.mermaid")).filter(i=>{let o=i.closest(".commentray-mermaid");return o===null||o.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 w(n,e,t){return Math.max(e,Math.min(t,n))}function fn(n,e,t){let r=e.getBoundingClientRect(),i=n.getBoundingClientRect();return n.scrollTop+(r.top-i.top)-n.clientTop-t}function ae(n,e){let t=Math.max(0,n.scrollHeight-n.clientHeight),r=w(e,0,t);Math.abs(n.scrollTop-r)<.25||(n.scrollTop=r)}function T(n){if(n.scrollHeight-n.clientHeight<=1)return!1;let t=getComputedStyle(n).overflowY;return t==="auto"||t==="scroll"||t==="overlay"}function j(){let n=document.scrollingElement;return n instanceof HTMLElement?n:document.documentElement}function z(n){let e=j(),t=Math.max(0,e.scrollHeight-e.clientHeight),r=w(n*t,0,t);Math.abs(e.scrollTop-r)<.25||(e.scrollTop=r)}function kt(n,e,t){if(T(n)){ae(n,Math.round(fn(n,e,t)));return}let r=j(),i=e.getBoundingClientRect(),o=globalThis.scrollY+i.top-t,s=Math.max(0,r.scrollHeight-r.clientHeight),a=w(o,0,s);Math.abs(r.scrollTop-a)<.25||(r.scrollTop=a)}function ce(){let n=j(),e=Math.max(0,n.scrollHeight-n.clientHeight);return e>0?w(n.scrollTop/e,0,1):0}function He(n,e,t,r="code-line-"){let i=globalThis.matchMedia(Pt).matches;if(t.k==="block"){let a=n.querySelector(`#${r}${String(t.src0)}`),c=a instanceof HTMLElement?a:Cn(gr(r),t.src0);c?kt(n,c,2):z(t.winRatio);return}if(t.k==="mirrorW"){if(T(n)){let a=Math.max(0,n.scrollHeight-n.clientHeight);ae(n,t.ratio*a),i&&z(t.ratio)}else z(t.ratio);return}let o=dt(t.docTop,t.docSH,t.docCH,n.scrollHeight,n.clientHeight);if(T(n)){if(ae(n,o),i){let a=Math.max(1,n.scrollHeight-n.clientHeight);z(w(o/a,0,1))}return}let s=Math.max(1,n.scrollHeight-n.clientHeight);z(w(o/s,0,1))}function ke(n,e,t){if(t.k==="block"){let o=e.querySelector(`[data-commentray-line="${String(t.mdLine0)}"]`);o instanceof HTMLElement?kt(e,o,2):z(t.winRatio);return}if(t.k==="mirrorW"){if(T(e)){let o=Math.max(0,e.scrollHeight-e.clientHeight);ae(e,t.ratio*o)}else z(t.ratio);return}let r=dt(t.codeTop,t.codeSH,t.codeCH,e.scrollHeight,e.clientHeight);if(T(e)){ae(e,r);return}let i=Math.max(1,e.scrollHeight-e.clientHeight);z(w(r/i,0,1))}function Xt(n,e){let t=T(n)?w(n.scrollTop/Math.max(1,n.scrollHeight-n.clientHeight),0,1):ce(),r=ur(n);if(r!==null)return{k:"block",src0:r,winRatio:t};let i=e(),o=Ln(n),s=ht(i,o);return s!==null?{k:"block",src0:s,winRatio:t}:T(n)?{k:"mirrorI",docTop:n.scrollTop,docSH:n.scrollHeight,docCH:n.clientHeight}:{k:"mirrorW",ratio:t}}function Zt(n,e,t,r="code-line-"){let i=ce(),o=t(),s=En(n,r),a=oe(o,s);return a===null?T(n)?{k:"mirrorI",codeTop:n.scrollTop,codeSH:n.scrollHeight,codeCH:n.clientHeight}:{k:"mirrorW",ratio:i}:{k:"block",mdLine0:a,winRatio:i}}function en(n){return T(n)?{k:"mirrorI",docTop:n.scrollTop,docSH:n.scrollHeight,docCH:n.clientHeight}:{k:"mirrorW",ratio:ce()}}function tn(n){return T(n)?{k:"mirrorI",codeTop:n.scrollTop,codeSH:n.scrollHeight,codeCH:n.clientHeight}:{k:"mirrorW",ratio:ce()}}function L(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Qn(n,e){let t=n.replace(/\s+/g," ").trim();return t.length<=e?t:`${t.slice(0,e-1)}\u2026`}function jn(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??""}`,o=t.get(i);(!o||r.score>o.score)&&t.set(i,r)}return[...t.values()].sort((r,i)=>i.score-r.score).slice(0,e)}function Et(n,e,t){let r=we(n,t),i=new Set,o=[];for(let s of r){let a=Nt(n,s.start);i.has(a)||(i.add(a),o.push({kind:e,line:a,text:$t(n,a),score:1e3,source:"ordered"}))}return o}function Yn(n,e,t){let r=e.trim();if(!r)return[];let i=new q(r,t,[new te(.22),new U(0),new _(0)]),o=n.getMatches(i),s=[];for(let a of o.matches){let c=a.entity;s.push({kind:c.kind,line:c.line,text:c.text,score:100+a.quality,source:"fuzzy",crPath:c.crPath,spPath:c.spPath})}return s}function Vn(n,e){if(e.length===0)return[];let t=[];for(let r of n)r.kind!=="path"||we(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 Kn(n){let{scope:e,filePathLabel:t,commentrayPathLabel:r,rawCode:i,rawMd:o,searcher:s,queryRaw:a,tokens:c,pathBlobWide:l,pathRowsForOrdering:u}=n,h=(l&&l.trim().length>0?l.trim():[t,r].filter(p=>p.trim().length>0).join(`
17
- `))||"",d=e==="commentray-and-paths"?[]:Et(i,"code",c),g=e==="commentray-and-paths"&&u&&u.length>0?Vn(u,c):e==="commentray-and-paths"&&h?Et(h,"path",c):[],m=Et(o,"md",c),f=Yn(s,a,60);return jn([...d,...g,...m,...f],80)}function Jn(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 Xn(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 pn(n,e,t){let r=Xn(n,t),i=n.source==="ordered"?"ordered":"fuzzy",o=zt(Qn(n.text,320),e),s=L(n.kind==="md"?n.crPath??t.currentCommentrayPath:n.crPath??""),a=L(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="${s}" data-sp-path="${a}"><span class="meta">${L(r)} <span class="src-tag">(${i})</span></span><div class="snippet">${o}</div></button>`}function Zn(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=Jn(n),o=[];o.push(`<div class="hint">${i} ${e.length} hit(s).</div>`);for(let s of e)o.push(pn(s,t,r));return o.join("")}function Lt(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 xt(n,e,t){let r=[],i=[`<div class="hint">${L(n)}</div>`],o=e.map((s,a)=>({kind:"path",line:a,text:s.sourcePath,score:1e3,source:"ordered",spPath:s.sourcePath,crPath:s.commentrayPath}));for(let s of o)i.push(pn(s,r,t));return i.join("")}function yn(n,e,t){let r=n.querySelector(`#commentray-md-line-${String(e)}`);if(r instanceof HTMLElement){let s=Math.round(fn(n,r,8)),a=Math.round(Math.max(0,n.scrollHeight-n.clientHeight));n.scrollTo({top:w(s,0,a),behavior:"smooth"});return}if(t<=1)return;let i=e/Math.max(1,t-1),o=Math.max(0,n.scrollHeight-n.clientHeight);n.scrollTo({top:i*o,behavior:"smooth"})}function bn(n,e){if(n.staticBrowseUrl?.trim()){let r=O(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 er(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 nn(n,e,t,r,i){let o=t.split(`
16
+ `,document.body.appendChild(e);let t=e.querySelector(".commentray-wide-intro-title"),r=e.querySelector(".commentray-wide-intro-body"),i=e.querySelector(".commentray-wide-intro-step-action"),o=e.querySelector(".commentray-wide-intro-progress"),s=e.querySelector('button[data-wide-intro="back"]'),a=e.querySelector('button[data-wide-intro="next"]'),c=e.querySelector('button[data-wide-intro="skip"]');return!(t instanceof HTMLElement)||!(r instanceof HTMLElement)||!(i instanceof HTMLButtonElement)||!(o instanceof HTMLElement)||!(s instanceof HTMLButtonElement)||!(a instanceof HTMLButtonElement)||!(c instanceof HTMLButtonElement)?(n.remove(),e.remove(),null):{bubble:e,arrowLayer:n,titleEl:t,bodyEl:r,stepActionBtn:i,progressEl:o,backBtn:s,nextBtn:a,skipBtn:c}}function D(n,e){try{return n.getItem(e)}catch{return null}}function B(n,e,t){try{n.setItem(e,t)}catch{}}var ln="commentray.codeCommentrayStatic.wideModeIntro.v1";function un(n){let e=n.isNarrowViewport()?"narrow":"wide";e!==n.viewportMode&&(n.viewportMode=e,n.steps=Ht(n.shell,e==="narrow"))}function hn(n){let{bubble:e,arrowLayer:t}=n.elements;un(n);let r=He(n.steps,n.current),i=r[0];if(!i){e.dataset.side="none",e.style.top="12px",e.style.left="12px",t.replaceChildren();return}on(e,i),sn(e,t,r)}function ir(n){for(un(n);n.current<n.steps.length;){let e=n.steps[n.current];if(!e)break;let t=He(n.steps,n.current),r=typeof e.fallbackAction=="function";if(t.length>0||r)break;n.current++}}function or(n,e,t){let{stepActionBtn:r}=n.elements;if(t.length===0&&typeof e.fallbackAction=="function"&&e.fallbackActionLabel){r.hidden=!1,r.textContent=e.fallbackActionLabel,r.disabled=!1;return}r.hidden=!0,r.textContent="",r.disabled=!0}function sr(n,e){let{titleEl:t,bodyEl:r,progressEl:i,backBtn:o,nextBtn:s}=n.elements;if(ir(n),n.current>=n.steps.length){e();return}let a=n.steps[n.current];if(!a)return;let c=He(n.steps,n.current);for(let l of n.highlighted)l.classList.remove("commentray-wide-intro-target");n.highlighted=c;for(let l of n.highlighted)l.classList.add("commentray-wide-intro-target");t.textContent=a.title,r.textContent=a.body,or(n,a,c),i.textContent=`${String(n.current+1)} / ${String(n.steps.length)}`,o.disabled=n.current===0,s.textContent=n.current===n.steps.length-1?"Done":"Next",hn(n)}function Ct(n,e,t){if(!t?.force&&D(localStorage,ln)==="1")return;an();let r=cn();if(!r)return;let i={shell:n,steps:Ht(n,e()),viewportMode:e()?"narrow":"wide",current:0,highlighted:[],elements:r,isNarrowViewport:e},{bubble:o,arrowLayer:s,stepActionBtn:a,backBtn:c,nextBtn:l,skipBtn:u}=i.elements,h=()=>{for(let p of i.highlighted)p.classList.remove("commentray-wide-intro-target");i.highlighted=[],s.remove(),o.remove(),globalThis.removeEventListener("resize",m),globalThis.removeEventListener("scroll",d,!0),document.removeEventListener("keydown",f,!0),B(localStorage,ln,"1")},d=()=>{hn(i)},g=()=>{sr(i,h)},m=()=>{g()},f=p=>{p.key==="Escape"&&(p.preventDefault(),h())};c.addEventListener("click",()=>{i.current>0&&i.current--,g()}),a.addEventListener("click",()=>{let p=i.steps[i.current];!p||typeof p.fallbackAction!="function"||(p.fallbackAction(),g())}),l.addEventListener("click",()=>{if(i.current>=i.steps.length-1){h();return}i.current++,g()}),u.addEventListener("click",h),globalThis.addEventListener("resize",m),globalThis.addEventListener("scroll",d,!0),document.addEventListener("keydown",f,!0),g()}function Pe(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()??"";Le(i)&&(r.href=q(i,e,t))}}function Ie(n){if(typeof globalThis.location<"u"&&globalThis.location.protocol==="file:")return;let t=Array.from(n.querySelectorAll("pre.mermaid")).filter(i=>{let o=i.closest(".commentray-mermaid");return o===null||o.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 T(n,e,t){return Math.max(e,Math.min(t,n))}function Hn(n,e,t){let r=e.getBoundingClientRect(),i=n.getBoundingClientRect();return n.scrollTop+(r.top-i.top)-n.clientTop-t}function se(n,e){let t=Math.max(0,n.scrollHeight-n.clientHeight),r=T(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 Y(){let n=document.scrollingElement;return n instanceof HTMLElement?n:document.documentElement}function N(n){let e=Y(),t=Math.max(0,e.scrollHeight-e.clientHeight),r=T(n*t,0,t);Math.abs(e.scrollTop-r)<.25||(e.scrollTop=r)}function Rt(n,e,t){if(v(n)){se(n,Math.round(Hn(n,e,t)));return}let r=Y(),i=e.getBoundingClientRect(),o=globalThis.scrollY+i.top-t,s=Math.max(0,r.scrollHeight-r.clientHeight),a=T(o,0,s);Math.abs(r.scrollTop-a)<.25||(r.scrollTop=a)}function ae(){let n=Y(),e=Math.max(0,n.scrollHeight-n.clientHeight);return e>0?T(n.scrollTop/e,0,1):0}function Ce(n,e,t,r="code-line-"){let i=globalThis.matchMedia(Nt).matches;if(t.k==="block"){let a=n.querySelector(`#${r}${String(t.src0)}`),c=a instanceof HTMLElement?a:Wn(Hr(r),t.src0);c?Rt(n,c,2):N(t.winRatio);return}if(t.k==="mirrorW"){if(v(n)){let a=Math.max(0,n.scrollHeight-n.clientHeight);se(n,t.ratio*a),i&&N(t.ratio)}else N(t.ratio);return}let o=gt(t.docTop,t.docSH,t.docCH,n.scrollHeight,n.clientHeight);if(v(n)){if(se(n,o),i){let a=Math.max(1,n.scrollHeight-n.clientHeight);N(T(o/a,0,1))}return}let s=Math.max(1,n.scrollHeight-n.clientHeight);N(T(o/s,0,1))}function Ae(n,e,t){if(t.k==="block"){let o=e.querySelector(`[data-commentray-line="${String(t.mdLine0)}"]`);o instanceof HTMLElement?Rt(e,o,2):N(t.winRatio);return}if(t.k==="mirrorW"){if(v(e)){let o=Math.max(0,e.scrollHeight-e.clientHeight);se(e,t.ratio*o)}else N(t.ratio);return}let r=gt(t.codeTop,t.codeSH,t.codeCH,e.scrollHeight,e.clientHeight);if(v(e)){se(e,r);return}let i=Math.max(1,e.scrollHeight-e.clientHeight);N(T(r/i,0,1))}function dn(n,e){let t=v(n)?T(n.scrollTop/Math.max(1,n.scrollHeight-n.clientHeight),0,1):ae(),r=Er(n);if(r!==null)return{k:"block",src0:r,winRatio:t};let i=e(),o=Ft(n),s=mt(i,o);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 mn(n,e,t,r="code-line-"){let i=ae(),o=t(),s=Nn(n,r),a=ie(o,s);return a===null?v(n)?{k:"mirrorI",codeTop:n.scrollTop,codeSH:n.scrollHeight,codeCH:n.clientHeight}:{k:"mirrorW",ratio:i}:{k:"block",mdLine0:a,winRatio:i}}function gn(n){return v(n)?{k:"mirrorI",docTop:n.scrollTop,docSH:n.scrollHeight,docCH:n.clientHeight}:{k:"mirrorW",ratio:ae()}}function fn(n){return v(n)?{k:"mirrorI",codeTop:n.scrollTop,codeSH:n.scrollHeight,codeCH:n.clientHeight}:{k:"mirrorW",ratio:ae()}}function L(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ar(n,e){let t=n.replace(/\s+/g," ").trim();return t.length<=e?t:`${t.slice(0,e-1)}\u2026`}function cr(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??""}`,o=t.get(i);(!o||r.score>o.score)&&t.set(i,r)}return[...t.values()].sort((r,i)=>i.score-r.score).slice(0,e)}function At(n,e,t){let r=ve(n,t),i=new Set,o=[];for(let s of r){let a=Jt(n,s.start);i.has(a)||(i.add(a),o.push({kind:e,line:a,text:Xt(n,a),score:1e3,source:"ordered"}))}return o}function lr(n,e,t){let r=e.trim();if(!r)return[];let i=new O(r,t,[new ee(.22),new U(0),new Q(0)]),o=n.getMatches(i),s=[];for(let a of o.matches){let c=a.entity;s.push({kind:c.kind,line:c.line,text:c.text,score:100+a.quality,source:"fuzzy",crPath:c.crPath,spPath:c.spPath})}return s}function ur(n,e){if(e.length===0)return[];let t=[];for(let r of n)r.kind!=="path"||ve(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 hr(n){let{scope:e,filePathLabel:t,commentrayPathLabel:r,rawCode:i,rawMd:o,searcher:s,queryRaw:a,tokens:c,pathBlobWide:l,pathRowsForOrdering:u}=n,h=(l&&l.trim().length>0?l.trim():[t,r].filter(p=>p.trim().length>0).join(`
17
+ `))||"",d=e==="commentray-and-paths"?[]:At(i,"code",c),g=e==="commentray-and-paths"&&u&&u.length>0?ur(u,c):e==="commentray-and-paths"&&h?At(h,"path",c):[],m=At(o,"md",c),f=lr(s,a,60);return cr([...d,...g,...m,...f],80)}function dr(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 mr(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 Cn(n,e,t){let r=mr(n,t),i=n.source==="ordered"?"ordered":"fuzzy",o=Kt(ar(n.text,320),e),s=L(n.kind==="md"?n.crPath??t.currentCommentrayPath:n.crPath??""),a=L(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="${s}" data-sp-path="${a}"><span class="meta">${L(r)} <span class="src-tag">(${i})</span></span><div class="snippet">${o}</div></button>`}function gr(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=dr(n),o=[];o.push(`<div class="hint">${i} ${e.length} hit(s).</div>`);for(let s of e)o.push(Cn(s,t,r));return o.join("")}function Bt(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 Pt(n,e,t){let r=[],i=[`<div class="hint">${L(n)}</div>`],o=e.map((s,a)=>({kind:"path",line:a,text:s.sourcePath,score:1e3,source:"ordered",spPath:s.sourcePath,crPath:s.commentrayPath}));for(let s of o)i.push(Cn(s,r,t));return i.join("")}function An(n,e,t){let r=n.querySelector(`#commentray-md-line-${String(e)}`);if(r instanceof HTMLElement){let s=Math.round(Hn(n,r,8)),a=Math.round(Math.max(0,n.scrollHeight-n.clientHeight));n.scrollTo({top:T(s,0,a),behavior:"smooth"});return}if(t<=1)return;let i=e/Math.max(1,t-1),o=Math.max(0,n.scrollHeight-n.clientHeight);n.scrollTo({top:i*o,behavior:"smooth"})}function Bn(n,e){if(n.staticBrowseUrl?.trim()){let r=q(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 fr(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 pn(n,e,t,r,i){let o=t.split(`
18
18
  `),s=e.split(`
19
- `),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"?s.map((c,l)=>({kind:"code",line:l,text:c})):[],...a,...o.map((c,l)=>({kind:"md",line:l,text:c}))]}function rn(n){let e=be.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 nr(n){let e=document.getElementById(`code-line-${String(n)}`);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}function rr(n,e){let t=(n.getAttribute("data-cr-path")??"").trim(),r=(n.getAttribute("data-sp-path")??"").trim(),i=yt(e.mutable.documentedPairs,t,r);if(i&&bt(i,e.filePathLabel,e.mutable.commentrayPathLabel)){e.docScrollEl.scrollTo({top:0,behavior:"smooth"});return}i&&bn(i,null)}function ir(n,e,t){let r=t.mutable.commentrayPathLabel.trim(),i=e.trim();if(i.length>0&&S(i)!==S(r)){let o=yt(t.mutable.documentedPairs,i,"");if(o){bn(o,n);return}return}yn(t.docScrollEl,n,t.mutable.mdLines.length)}function or(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"){nr(r);return}if(t==="path"){rr(n,e);return}ir(r,i,e)}function sr(n,e,t){let r={currentCommentrayPath:t.commentrayPathLabel,currentSourcePath:e};if(n==="full"){let l=e.trim();if(l.length===0)return null;let u=[{sourcePath:l,commentrayPath:t.commentrayPathLabel.trim()}],h=Lt("full",u.length,u.length,!1);return xt(h,u,r)}let{rows:i,totalUnique:o}=Wt(t.documentedPairs);if(i.length>0){let l=Lt("commentray-and-paths",i.length,o,!1);return xt(l,i,r)}let s=e.trim();if(s.length===0)return null;let a=[{sourcePath:s,commentrayPath:t.commentrayPathLabel.trim()}],c=Lt("commentray-and-paths",a.length,a.length,!0);return xt(c,a,r)}function ar(n){let{scope:e,filePathLabel:t,mutable:r,rawCode:i,searchInput:o,searchClear:s,searchResults:a,docScrollEl:c}=n,l;function u(){clearTimeout(l),l=void 0,o.value="",a.innerHTML="",a.hidden=!0}function h(){let m=sr(e,t,r);m!==null&&(a.hidden=!1,a.innerHTML=m)}function d(){let m=Te(o.value);if(m.length===0){a.hidden=!0,a.innerHTML="";return}let f=Kn({scope:e,filePathLabel:t,commentrayPathLabel:r.commentrayPathLabel,rawCode:i,rawMd:r.rawMd,searcher:r.searcher,queryRaw:o.value,tokens:m,pathBlobWide:r.pathBlobWide,pathRowsForOrdering:r.pathRowsForOrdering.length>0?r.pathRowsForOrdering:void 0});a.hidden=!1,a.innerHTML=Zn(e,f,m,{currentCommentrayPath:r.commentrayPathLabel,currentSourcePath:t})}let g={mutable:r,docScrollEl:c,filePathLabel:t};a.addEventListener("click",m=>{let f=tr(m.target,a);f&&or(f,g)}),o.addEventListener("input",()=>{clearTimeout(l),l=setTimeout(d,200)}),o.addEventListener("keydown",m=>{m.key==="ArrowDown"&&(Te(o.value).length>0||(h(),m.preventDefault()))}),s.addEventListener("click",u),document.addEventListener("keydown",m=>{if(m.key!=="Escape")return;let f=o.value.trim().length>0,p=document.activeElement===o,v=!a.hidden;!f&&!p&&!v||(u(),p&&o.blur(),m.preventDefault())})}function Sn(n,e,t,r,...i){let o=i.filter(a=>a instanceof HTMLElement),s=D(localStorage,n)==="1";if(t.checked=s,s){e.classList.add("wrap");for(let a of o)a.classList.add("wrap")}else{e.classList.remove("wrap");for(let a of o)a.classList.remove("wrap")}t.addEventListener("change",()=>{if(t.checked){e.classList.add("wrap");for(let a of o)a.classList.add("wrap");A(localStorage,n,"1")}else{e.classList.remove("wrap");for(let a of o)a.classList.remove("wrap");A(localStorage,n,"0")}r&&queueMicrotask(()=>{requestAnimationFrame(()=>{r(),requestAnimationFrame(()=>{r()})})})})}function wn(n){let e=n.trim();if(!e)return[];try{let t=JSON.parse(F(e));if(!Array.isArray(t))return[];let r=[];for(let i of t){if(typeof i!="object"||i===null)continue;let o=i;typeof o.id=="string"&&typeof o.commentrayLine=="number"&&typeof o.sourceStart=="number"&&typeof o.sourceEnd=="number"&&r.push({id:o.id,commentrayLine:o.commentrayLine,sourceStart:o.sourceStart,sourceEnd:o.sourceEnd})}return r}catch{return[]}}function Tn(n=56){let e=j(),t=Math.max(0,e.scrollHeight-e.clientHeight);return t>0&&e.scrollTop>=t-n}function vn(n,e=56){let t=Math.max(0,n.scrollHeight-n.clientHeight);return t>0&&n.scrollTop>=t-e}function Mn(n){let e=n.getAttribute("data-commentray-line");return e===null||e===""?null:Number(e)}function on(n,e){let t=0;for(let r of n){let i=Mn(r);if(i!==null)if(r.getBoundingClientRect().top<=e+1+.001)t=i;else break}return t}function sn(n){let e=n[n.length-1];return e?Mn(e)??0:0}function En(n,e="code-line-"){let t=n.querySelectorAll(`[id^="${e}"]`);if(t.length===0)return 1;if(!T(n)){if(Tn()){let u=t[t.length-1],h=/^(?:code-line-|code-md-line-)(\d+)$/.exec(u.id);return h?Number(h[1])+1:t.length}let o=n.getBoundingClientRect(),s=globalThis.innerHeight,a=Math.max(0,o.top),c=Math.min(s,o.bottom),l=a+Math.max(2,Math.min(40,(c-a)*.15));for(let u of t)if(u.getBoundingClientRect().bottom>l-.001){let d=/^(?:code-line-|code-md-line-)(\d+)$/.exec(u.id);return d?Number(d[1])+1:1}return t.length}if(vn(n)){let o=t[t.length-1],s=/^(?:code-line-|code-md-line-)(\d+)$/.exec(o.id);return s?Number(s[1])+1:t.length}let i=n.getBoundingClientRect().top+n.clientTop+2;for(let o of t)if(o.getBoundingClientRect().bottom>i-.001){let a=/^(?:code-line-|code-md-line-)(\d+)$/.exec(o.id);return a?Number(a[1])+1:1}return t.length}function Ln(n){let e=n.querySelectorAll(".commentray-block-anchor");if(e.length===0)return 0;if(!T(n)){if(Tn())return sn(e);let i=n.getBoundingClientRect(),o=globalThis.innerHeight,s=Math.max(0,i.top),a=Math.min(o,i.bottom),c=s+Math.max(2,Math.min(40,(a-s)*.15));return on(e,c)}if(vn(n))return sn(e);let r=n.getBoundingClientRect().top+n.clientTop+2;return on(e,r)}function cr(){let n=document.getElementById("shell");return n instanceof HTMLElement?n.getAttribute("data-page-breaks-enabled")==="true":!1}function lr(n){if(!T(n)){let t=n.getBoundingClientRect(),r=globalThis.innerHeight,i=Math.max(0,t.top),o=Math.min(r,t.bottom);return i+Math.max(2,Math.min(40,(o-i)*.15))}return n.getBoundingClientRect().top+n.clientTop+2}function ur(n){if(!cr())return null;let e=lr(n),t=Array.from(n.querySelectorAll(".commentray-page-break[data-next-source-start]"));for(let r of t){let i=r.getAttribute("data-next-source-start");if(!i)continue;let o=Number.parseInt(i,10);if(!Number.isFinite(o)||o<=0)continue;let s=r.getBoundingClientRect().top,a=r.getAttribute("data-next-commentray-line"),c=a?Number.parseInt(a,10):Number.NaN,l=Number.isFinite(c)&&c>=0?n.querySelector(`[data-commentray-line="${String(c)}"]`):null,u=l?l.getBoundingClientRect().top:s+r.clientHeight;if(!(s<=e&&e<u))continue;let h=Math.max(1,u-s),d=w((e-s)/h,0,1),m=globalThis.matchMedia("(max-width: 767px)").matches?.2:.35;return d<m?null:o-1}return null}function an(n){n.n++,queueMicrotask(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{n.n=Math.max(0,n.n-1)})})})}function xn(n,e,t,r){let i="none",o={n:0},s={n:0};n.addEventListener("scroll",()=>{if(o.n>0){o.n--;return}i!=="doc"&&(i="code",an(s),t(),i="none")},{passive:!0}),e.addEventListener("scroll",()=>{if(s.n>0){s.n--;return}i!=="code"&&(i="doc",an(o),r(),i="none")},{passive:!0})}function cn(n,e,t,r,i){let o=null,s=null,a=()=>{ke(n,e,Zt(n,e,t,r()))},c=()=>{He(n,e,Xt(e,t),r())},l=()=>{if(i?.()===!0){o={k:"mirrorW",ratio:ce()};return}o=Xt(e,t)},u=()=>{if(!o)return;let g=o;o=null,He(n,e,g,r())},h=()=>{s=Zt(n,e,t,r())},d=()=>{if(!s)return;let g=s;s=null,ke(n,e,g)};return xn(n,e,a,c),{syncFromCodeToDoc:a,syncFromDocToCode:c,prepareMobileFlipToCode:l,finishMobileFlipToCode:u,prepareMobileFlipToDoc:h,finishMobileFlipToDoc:d}}function hr(n,e){let t=null,r=null,i=()=>{ke(n,e,tn(n))},o=()=>{He(n,e,en(e))},s=()=>{t=en(e)},a=()=>{if(!t)return;let u=t;t=null,He(n,e,u)},c=()=>{r=tn(n)},l=()=>{if(!r)return;let u=r;r=null,ke(n,e,u)};return xn(n,e,i,o),{syncFromCodeToDoc:i,syncFromDocToCode:o,prepareMobileFlipToCode:s,finishMobileFlipToCode:a,prepareMobileFlipToDoc:c,finishMobileFlipToDoc:l}}function Hn(n){let e=n.getBoundingClientRect();return(e.top+e.bottom)/2}function ln(n){return Hn(n)}function dr(n,e,t){if(e){let s=document.getElementById(`commentray-block-${e.id}`);return s?s.getBoundingClientRect().top-3:Hn(t)}let i=n.getBoundingClientRect().bottom-4,o=n.children[n.children.length-1];return o&&(i=Math.min(i,o.getBoundingClientRect().bottom-4)),i}function kn(n,e){if(!n.startsWith(e))return null;let t=Number.parseInt(n.slice(e.length),10);return Number.isFinite(t)?t:null}function Cn(n,e){let t=0,r=n.length-1,i=-1;for(;t<=r;){let o=t+r>>1;(n[o]?.line0??-1)>=e?(i=o,r=o-1):t=o+1}return i>=0?n[i]?.el??null:null}function mr(n,e){let t=0,r=n.length-1,i=-1;for(;t<=r;){let o=t+r>>1;(n[o]?.line0??-1)<=e?(i=o,t=o+1):r=o-1}return i>=0?n[i]?.el??null:null}function gr(n){return Array.from(document.querySelectorAll(`[id^="${n}"]`)).map(e=>({line0:kn(e.id,n),el:e})).filter(e=>e.line0!==null).sort((e,t)=>e.line0-t.line0)}function fr(n,e,t,r){let i=()=>r();e.addEventListener("scroll",i,{passive:!0}),t.addEventListener("scroll",i,{passive:!0}),globalThis.addEventListener("resize",i);let o=new ResizeObserver(i);o.observe(n),o.observe(e),o.observe(t);let s=n.parentElement;s&&o.observe(s)}function pr(n,e,t,r,i,o){let s=r(),a=Rt(s),c=e.getBoundingClientRect(),l=c.width,u=c.height;if(l<=0||u<=0||a.length===0){n.replaceChildren();return}let h=Ft(s,i());n.setAttribute("viewBox",`0 0 ${String(l)} ${String(u)}`),n.setAttribute("preserveAspectRatio","none");let d=[],g=Array.from(document.querySelectorAll(`[id^="${o}"]`)).map(m=>({line0:kn(m.id,o),el:m})).filter(m=>m.line0!==null).sort((m,f)=>m.line0-f.line0);for(let m=0;m<a.length;m++){let f=a[m];if(!f)continue;let p=a[m+1],v=ft(f.sourceStart),x=ft(f.sourceEnd),I=document.getElementById(`${o}${String(v)}`)??Cn(g,v),H=document.getElementById(`${o}${String(x)}`)??mr(g,x),k=document.getElementById(`commentray-block-${f.id}`);if(!I||!H||!k)continue;let M=dr(t,p,k),E=ln(I),G=ln(H),Y=k.getBoundingClientRect().top+2,V=Math.max(M,Y+4),C=se(E,c.top,u),K=se(Y,c.top,u),At=se(G,c.top,u),It=se(V,c.top,u),Ie=f.id===h?"gutter__rays-path gutter__rays-path--active":"gutter__rays-path",Bt=`${Ie} gutter__rays-path--trail`,Be=gt(0,C.y,l,K.y,{tension:.38,clipStart:C.clipped,clipEnd:K.clipped}),Re=gt(0,At.y,l,It.y,{tension:.38,clipStart:At.clipped,clipEnd:It.clipped}),Fn=Be.dotted?`<path class="${Bt}" d="${Be.dotted}" />`:"",Dn=Re.dotted?`<path class="${Bt}" d="${Re.dotted}" />`:"";d.push(`<g class="gutter__rays-block" data-commentray-block="${L(f.id)}"><path class="${Ie}" d="${Be.solid}" />`+Fn+`<path class="${Ie}" d="${Re.solid}" />`+Dn+"</g>")}n.innerHTML=d.join("")}function yr(n){let{gutter:e,codePane:t,docScrollEl:r,getLinks:i,probeTopSourceLine1Based:o}=n,s=n.sourceLineIdPrefix??(()=>"code-line-"),a="http://www.w3.org/2000/svg",c=document.createElement("div");c.className="gutter__rays",c.setAttribute("aria-hidden","true");let l=document.createElementNS(a,"svg");c.appendChild(l),e.appendChild(c);let u=0;function h(){u===0&&(u=globalThis.requestAnimationFrame(()=>{u=0,pr(l,e,r,i,o,s())}))}return fr(e,t,r,h),h(),globalThis.requestAnimationFrame(()=>{h(),globalThis.requestAnimationFrame(h)}),h}function br(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 Ct(n){let e=[];if(!Array.isArray(n))return e;for(let t of n)br(t)&&e.push(t);return e}function Sr(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 wr(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 Tr(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 o=i,s=Sr(o);if(s){t.push(s);continue}let a=wr(o,r);a&&(t.push(a),r+=1)}return t}function Pn(n){let e=n.trim();if(e==="")return[];try{let t=JSON.parse(F(e));return Ct(t)}catch{return[]}}function vr(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 o=t[i];if(o===void 0)continue;r.children.has(o)||r.children.set(o,{children:new Map,pairs:[]});let s=r.children.get(o);if(s===void 0)return;i===t.length-1&&s.pairs.push(e),r=s}}function Mr(n){let e=n.replace(/\\/g,"/").replace(/\/+$/,""),t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function Er(n){return(n.replace(/\\/g,"/").replace(/\/+$/,"").split("/").filter(Boolean).at(-1)??"").replace(/\.md$/i,"")}function Lr(n,e){let t=Mr(n.sourcePath);if(!e)return t;let r=Er(n.commentrayPath);return r!==""&&r!==t?`${t} \xB7 ${r}`:t}function xr(n){let e=(n.staticBrowseUrl??"").trim();if(e.length>0)return O(e,globalThis.location.pathname,globalThis.location.origin);let t=(n.commentrayOnGithub??"").trim();return t.length>0?t:"#"}function Hr(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 kr(n){for(let e of n.querySelectorAll("a.tree-file-link"))e instanceof HTMLAnchorElement&&(e.classList.remove("tree-file-link--current"),e.removeAttribute("aria-current"))}function Cr(n,e,t){for(let r of n.querySelectorAll("a.tree-file-link")){if(!(r instanceof HTMLAnchorElement))continue;let i=r.getAttribute("data-pair-source-path")?.trim()??"",o=r.getAttribute("data-pair-commentray-path")?.trim()??"";if(bt({sourcePath:i,commentrayPath:o},e,t)){r.classList.add("tree-file-link--current"),r.setAttribute("aria-current","page");break}}}function An(){let n=document.getElementById("shell"),e=document.getElementById("documented-files-tree");if(!(n instanceof HTMLElement)||!(e instanceof HTMLElement))return;kr(e);let t=n.getAttribute("data-commentray-pair-source-path")?.trim()??"",r=n.getAttribute("data-commentray-pair-commentray-path")?.trim()??"";t.length===0||r.length===0||Cr(e,t,r)}function In(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 o=In(i);t.push(`<li><div class="tree-dir">${L(r)}</div>${o}</li>`)}if(i.pairs.length>0){let o=i.pairs.length>1;for(let s of i.pairs){let a=L(Lr(s,o)),c=L(Hr(s)),l=L(xr(s)),u=L(S(s.sourcePath)),h=L(S(s.commentrayPath)),g=(s.staticBrowseUrl?.trim()??"").length>0?"":' target="_blank" rel="noopener noreferrer"';t.push(`<li><div class="tree-file"><a class="tree-file-link" href="${l}" data-pair-source-path="${u}" data-pair-commentray-path="${h}"${g} title="${c}">${a}</a></div></li>`)}}}}return`<ul>${t.join("")}</ul>`}function Pr(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)vr(r,i);n.innerHTML=In(r),An()}function Ar(n,e){let t=null,r=null;return async()=>t!==null?t:(r===null&&(r=(async()=>{if(e.length>0&&(t=Pn(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 o=await i.json();t=Ct(o.documentedPairs)})()),await r,t??[])}function Ir(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 s=n.querySelector("summary");return s instanceof HTMLElement?s:null}function o(){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 s=i();if(!s)return;let a=s.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",o),globalThis.addEventListener("resize",o),globalThis.addEventListener("scroll",o,!0),o}function Br(){let n=document.getElementById("documented-files-filter");n instanceof HTMLInputElement&&n.focus({preventScroll:!0})}function Rr(){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,o=n.getAttribute("data-nav-json-url")?.trim()??"",s=r?.getAttribute("data-documented-pairs-b64")?.trim()??"";if(o.length===0&&s.length===0)return;let a=Ir(n),c=Ar(o,s),l=null;function u(){if(l===null)return;let d=t instanceof HTMLInputElement?t.value:"",g=qt(l,d),m=d.trim().length>0;Pr(i,g,m&&l.length>0&&g.length===0)}async function h(){try{l=await c(),u()}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(),Br()}),n.open&&h()}),t instanceof HTMLInputElement&&t.addEventListener("input",()=>{!n.open||l===null||u()})}function Fr(n,e,t,r,i){let o=!1,s=i;function a(l){if(!o)return;let u=e.getBoundingClientRect(),h=l.clientX-u.left,d=w(h/u.width*100,15,85);s=d,t.style.flex=`0 0 ${d}%`,e.style.setProperty("--split-pct",`${String(d)}%`)}function c(){o=!1,window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",c),document.body.style.cursor="",document.body.style.userSelect="",A(localStorage,n,String(s))}r.addEventListener("mousedown",l=>{l.preventDefault(),o=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",a),window.addEventListener("mouseup",c)})}var un="commentray.codeCommentrayStatic.splitPct",Bn="commentray.codeCommentrayStatic.wrap",hn="commentray.codeCommentrayStatic.dualMobilePane",Dr="commentray.codeCommentrayStatic.sourceMarkdownPaneMode",zr="commentray.codeCommentrayStatic.pageBreaksEnabled",Pt="(max-width: 767px)";function Ht(n){return n==="code"?"code":"doc"}function Rn(){return globalThis.matchMedia(Pt).matches}function Nr(n){let e=document.getElementById("commentray-help-tour");e instanceof HTMLButtonElement&&e.addEventListener("click",()=>{Mt(n,Rn,{force:!0})})}function W(n){return n.getAttribute("data-source-pane-mode")==="rendered-markdown"?"rendered-markdown":"source"}function $r(n){let e=(n??"").trim().toLowerCase();return!(e==="0"||e==="false"||e==="off")}function qr(n){let e=$r(D(localStorage,zr));n.setAttribute("data-page-breaks-enabled",e?"true":"false")}function Or(n){let e=()=>{let t=Math.max(globalThis.innerHeight,document.documentElement?.clientHeight??0);if(!Number.isFinite(t)||t<=0)return;let r=Math.round(w(t*.72,260,820));n.style.setProperty("--commentray-page-break-min-height",`${String(r)}px`)};globalThis.addEventListener("resize",e,{passive:!0}),globalThis.addEventListener("orientationchange",e,{passive:!0}),globalThis.visualViewport?.addEventListener("resize",e,{passive:!0}),e()}function dn(n){let e=document.querySelector("label.toolbar-wrap-lines");e instanceof HTMLLabelElement&&(e.hidden=W(n)==="rendered-markdown")}function Ce(n){return W(n)==="rendered-markdown"?"code-md-line-":"code-line-"}function Wr(n,e){let t=()=>{if(n.getAttribute("data-layout")!=="dual"||!e.matches||Ht(n.getAttribute("data-dual-mobile-pane"))!=="doc")return;let r=document.getElementById("doc-pane-body");r instanceof HTMLElement&&Ae(r)};queueMicrotask(()=>{t(),requestAnimationFrame(()=>{t(),requestAnimationFrame(t)})})}function Gr(n,e,t){let r=()=>{e.hidden=!0,e.classList.remove("is-visible")},i=()=>{e.hidden=!1,e.classList.add("is-visible")},o=()=>{if(!t.matches){r();return}let s=n.getBoundingClientRect(),a=globalThis.innerHeight,c=10;s.bottom<c||s.top>a-c?i():r()};globalThis.addEventListener("scroll",o,{passive:!0}),globalThis.addEventListener("resize",o,{passive:!0}),t.addEventListener("change",o),globalThis.requestAnimationFrame(o)}function Ur(n,e){let t=()=>{e.hidden=!0,e.classList.remove("is-visible")},r=()=>{e.hidden=!1,e.classList.add("is-visible")},i=()=>{let o=n.getBoundingClientRect(),s=globalThis.innerHeight,a=10;o.bottom<a||o.top>s-a?r():t()};globalThis.addEventListener("scroll",i,{passive:!0}),globalThis.addEventListener("resize",i,{passive:!0}),globalThis.requestAnimationFrame(i)}function _r(n,e){let t=n.querySelectorAll(`[id^="${e}"]`);if(t.length===0)return null;let r=T(n)?n.getBoundingClientRect().top+n.clientTop+2:Math.max(0,n.getBoundingClientRect().top)+2;for(let s of t)if(s.getBoundingClientRect().bottom>r-.001){let c=/^(?:code-line-|code-md-line-)(\d+)$/.exec(s.id);return c?.[1]?Number.parseInt(c[1],10):null}let i=t[t.length-1];if(!i)return null;let o=/^(?:code-line-|code-md-line-)(\d+)$/.exec(i.id);return o?.[1]?Number.parseInt(o[1],10):null}function Qr(n,e,t,r,i){function o(){let c=W(n)==="rendered-markdown",u=`Switch source pane to ${c?"markdown source":"rendered markdown"}`,h=`Source pane: ${c?"rendered markdown":"markdown source"} (click to switch)`,d=g=>{g instanceof HTMLButtonElement&&(g.setAttribute("aria-pressed",c?"true":"false"),g.setAttribute("aria-label",u),g.title=h)};d(t),d(r)}n.setAttribute("data-source-pane-mode","rendered-markdown"),o(),dn(n);let s=()=>{let a=W(n),l=_r(e,a==="rendered-markdown"?"code-md-line-":"code-line-"),u=a==="rendered-markdown"?"source":"rendered-markdown",h=u==="rendered-markdown"?"code-md-line-":"code-line-";if(n.setAttribute("data-source-pane-mode",u),A(localStorage,Dr,u),o(),dn(n),l!==null){let d=e.querySelector(`#${h}${String(l)}`);d instanceof HTMLElement&&kt(e,d,2)}if(u==="rendered-markdown"){let d=document.getElementById("code-pane-markdown-body");d instanceof HTMLElement&&(Ae(d),Pe(d))}i?.()};t.addEventListener("click",s),r&&(r.addEventListener("click",s),Ur(t,r))}function jr(n,e,t,r){let i=globalThis.matchMedia(Pt);function o(){return Ht(D(localStorage,hn))}function s(){i.matches?n.setAttribute("data-dual-mobile-pane",o()):n.removeAttribute("data-dual-mobile-pane")}let a=()=>{if(!i.matches)return;let l=Ht(n.getAttribute("data-dual-mobile-pane"))==="code"?"doc":"code",u=j().scrollTop;l==="code"?t.prepareMobileFlipToCode():t.prepareMobileFlipToDoc(),n.setAttribute("data-dual-mobile-pane",l),A(localStorage,hn,l),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(()=>{if(l==="code"){t.finishMobileFlipToCode();let h=j();if(u>5&&h.scrollTop<=1){let d=Math.max(0,h.scrollHeight-h.clientHeight);h.scrollTop=w(u,0,d)}}else t.finishMobileFlipToDoc()})}),l==="doc"&&Wr(n,i)};e.addEventListener("click",a),r&&(r.addEventListener("click",a),Gr(e,r,i)),i.addEventListener("change",s),s()}function Yr(n){let e=document.getElementById("wrap-lines");e&&Sn(Bn,n,e,()=>{globalThis.dispatchEvent(new Event("resize"))})}function Vr(n){let e=n?.textContent?.trim()??"";if(!e)return null;try{let t=JSON.parse(F(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 Kr(){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"),o=document.getElementById("search-results");if(!n||!e||!t||!r||!i||!o)return null;let s=document.getElementById("doc-pane-body"),a=s instanceof HTMLElement?s:n;return{docBody:s,docScrollEl:a,gutter:e,wrapCb:t,searchInput:r,searchClear:i,searchResults:o}}function Jr(n){let{scope:e,rawCode:t,filePathLabel:r,hubNavRows:i,pathRowsForOrdering:o,rawMd:s,commentrayPathLabel:a}=n;if(e!=="commentray-and-paths")return nn(e,t,s,r,a);if(i.length>0)return i;let c=o.length>0?o:nn(e,t,s,r,a).filter(u=>u.kind==="path"),l=s.split(`
20
- `).map((u,h)=>({kind:"md",line:h,text:u,spPath:r,crPath:a}));return[...c,...l]}function Xr(n,e,t,r){if(e!=="commentray-and-paths")return{documentedPairs:[],pathRowsForOrdering:[],pathBlobWide:""};let i=Pn(n.getAttribute("data-documented-pairs-b64")?.trim()??""),o=Ot(i),s=o.length>0?o.map(a=>a.text).join(`
19
+ `),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"?s.map((c,l)=>({kind:"code",line:l,text:c})):[],...a,...o.map((c,l)=>({kind:"md",line:l,text:c}))]}function yn(n){let e=be.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 pr(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 yr(n){let e=document.getElementById(`code-line-${String(n)}`);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}function br(n,e){let t=(n.getAttribute("data-cr-path")??"").trim(),r=(n.getAttribute("data-sp-path")??"").trim(),i=Mt(e.mutable.documentedPairs,t,r);if(i&&Et(i,e.filePathLabel,e.mutable.commentrayPathLabel)){e.docScrollEl.scrollTo({top:0,behavior:"smooth"});return}i&&Bn(i,null)}function Sr(n,e,t){let r=t.mutable.commentrayPathLabel.trim(),i=e.trim();if(i.length>0&&S(i)!==S(r)){let o=Mt(t.mutable.documentedPairs,i,"");if(o){Bn(o,n);return}return}An(t.docScrollEl,n,t.mutable.mdLines.length)}function wr(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"){yr(r);return}if(t==="path"){br(n,e);return}Sr(r,i,e)}function Tr(n,e,t){let r={currentCommentrayPath:t.commentrayPathLabel,currentSourcePath:e};if(n==="full"){let l=e.trim();if(l.length===0)return null;let u=[{sourcePath:l,commentrayPath:t.commentrayPathLabel.trim()}],h=Bt("full",u.length,u.length,!1);return Pt(h,u,r)}let{rows:i,totalUnique:o}=tn(t.documentedPairs);if(i.length>0){let l=Bt("commentray-and-paths",i.length,o,!1);return Pt(l,i,r)}let s=e.trim();if(s.length===0)return null;let a=[{sourcePath:s,commentrayPath:t.commentrayPathLabel.trim()}],c=Bt("commentray-and-paths",a.length,a.length,!0);return Pt(c,a,r)}function vr(n){let{scope:e,filePathLabel:t,mutable:r,rawCode:i,searchInput:o,searchClear:s,searchResults:a,docScrollEl:c}=n,l;function u(){clearTimeout(l),l=void 0,o.value="",a.innerHTML="",a.hidden=!0}function h(){let m=Tr(e,t,r);m!==null&&(a.hidden=!1,a.innerHTML=m)}function d(){let m=Me(o.value);if(m.length===0){a.hidden=!0,a.innerHTML="";return}let f=hr({scope:e,filePathLabel:t,commentrayPathLabel:r.commentrayPathLabel,rawCode:i,rawMd:r.rawMd,searcher:r.searcher,queryRaw:o.value,tokens:m,pathBlobWide:r.pathBlobWide,pathRowsForOrdering:r.pathRowsForOrdering.length>0?r.pathRowsForOrdering:void 0});a.hidden=!1,a.innerHTML=gr(e,f,m,{currentCommentrayPath:r.commentrayPathLabel,currentSourcePath:t})}let g={mutable:r,docScrollEl:c,filePathLabel:t};a.addEventListener("click",m=>{let f=pr(m.target,a);f&&wr(f,g)}),o.addEventListener("input",()=>{clearTimeout(l),l=setTimeout(d,200)}),o.addEventListener("keydown",m=>{m.key==="ArrowDown"&&(Me(o.value).length>0||(h(),m.preventDefault()))}),s.addEventListener("click",u),document.addEventListener("keydown",m=>{if(m.key!=="Escape")return;let f=o.value.trim().length>0,p=document.activeElement===o,E=!a.hidden;!f&&!p&&!E||(u(),p&&o.blur(),m.preventDefault())})}function Pn(n,e,t,r,...i){let o=i.filter(a=>a instanceof HTMLElement),s=D(localStorage,n)==="1";if(t.checked=s,s){e.classList.add("wrap");for(let a of o)a.classList.add("wrap")}else{e.classList.remove("wrap");for(let a of o)a.classList.remove("wrap")}t.addEventListener("change",()=>{if(t.checked){e.classList.add("wrap");for(let a of o)a.classList.add("wrap");B(localStorage,n,"1")}else{e.classList.remove("wrap");for(let a of o)a.classList.remove("wrap");B(localStorage,n,"0")}r&&queueMicrotask(()=>{requestAnimationFrame(()=>{r(),requestAnimationFrame(()=>{r()})})})})}function In(n){let e=n.trim();if(!e)return[];try{let t=JSON.parse(F(e));if(!Array.isArray(t))return[];let r=[];for(let i of t){if(typeof i!="object"||i===null)continue;let o=i;if(typeof o.id=="string"&&typeof o.commentrayLine=="number"&&typeof o.sourceStart=="number"&&typeof o.sourceEnd=="number"){let s=o.markerViewportHalfOpen1Based,a=typeof s=="object"&&s!==null&&typeof s.lo=="number"&&typeof s.hiExclusive=="number"?{lo:s.lo,hiExclusive:s.hiExclusive}:{lo:o.sourceStart,hiExclusive:o.sourceEnd+1};r.push({id:o.id,commentrayLine:o.commentrayLine,sourceStart:o.sourceStart,sourceEnd:o.sourceEnd,markerViewportHalfOpen1Based:a})}}return r}catch{return[]}}function Rn(n=56){let e=Y(),t=Math.max(0,e.scrollHeight-e.clientHeight);return t>0&&e.scrollTop>=t-n}function Fn(n,e=56){let t=Math.max(0,n.scrollHeight-n.clientHeight);return t>0&&n.scrollTop>=t-e}function Dn(n){let e=n.getAttribute("data-commentray-line");return e===null||e===""?null:Number(e)}function bn(n,e){let t=[];for(let r of n){let i=Dn(r);i!==null&&t.push({line0:i,top:r.getBoundingClientRect().top})}return Yt(t,e)}function Sn(n){let e=n[n.length-1];return e?Dn(e)??0:0}function Nn(n,e="code-line-"){let t=n.querySelectorAll(`[id^="${e}"]`);if(t.length===0)return 1;if(!v(n)){if(Rn()){let u=t[t.length-1],h=/^(?:code-line-|code-md-line-)(\d+)$/.exec(u.id);return h?Number(h[1])+1:t.length}let o=n.getBoundingClientRect(),s=globalThis.innerHeight,a=Math.max(0,o.top),c=Math.min(s,o.bottom),l=a+Math.max(2,Math.min(40,(c-a)*.15));for(let u of t)if(u.getBoundingClientRect().bottom>l-.001){let d=/^(?:code-line-|code-md-line-)(\d+)$/.exec(u.id);return d?Number(d[1])+1:1}return t.length}if(Fn(n)){let o=t[t.length-1],s=/^(?:code-line-|code-md-line-)(\d+)$/.exec(o.id);return s?Number(s[1])+1:t.length}let i=n.getBoundingClientRect().top+n.clientTop+2;for(let o of t)if(o.getBoundingClientRect().bottom>i-.001){let a=/^(?:code-line-|code-md-line-)(\d+)$/.exec(o.id);return a?Number(a[1])+1:1}return t.length}function Ft(n){let e=n.querySelectorAll(".commentray-block-anchor");if(e.length===0)return 0;if(!v(n)){if(Rn())return Sn(e);let i=n.getBoundingClientRect(),o=globalThis.innerHeight,s=Math.max(0,i.top),a=Math.min(o,i.bottom),c=s+Math.max(2,Math.min(40,(a-s)*.15));return bn(e,c)}if(Fn(n))return Sn(e);let r=n.getBoundingClientRect().top+n.clientTop+Math.max(2,Math.min(40,n.clientHeight*.15));return bn(e,r)}function zn(){let n=document.getElementById("shell");return n instanceof HTMLElement?n.getAttribute("data-page-breaks-enabled")==="true":!1}function Mr(n){if(!v(n)){let t=n.getBoundingClientRect(),r=globalThis.innerHeight,i=Math.max(0,t.top),o=Math.min(r,t.bottom);return i+Math.max(2,Math.min(40,(o-i)*.15))}return n.getBoundingClientRect().top+n.clientTop+2}function Er(n){if(!zn())return null;let e=Mr(n),t=Array.from(n.querySelectorAll(".commentray-page-break[data-next-source-start]"));for(let r of t){let i=r.getAttribute("data-next-source-start");if(!i)continue;let o=Number.parseInt(i,10);if(!Number.isFinite(o)||o<=0)continue;let s=r.getBoundingClientRect().top,a=r.getAttribute("data-next-commentray-line"),c=a?Number.parseInt(a,10):Number.NaN,l=Number.isFinite(c)&&c>=0?n.querySelector(`[data-commentray-line="${String(c)}"]`):null,u=l?l.getBoundingClientRect().top:s+r.clientHeight;if(!(s<=e&&e<u))continue;let h=Math.max(1,u-s),d=T((e-s)/h,0,1),m=globalThis.matchMedia("(max-width: 767px)").matches?.2:.35;return d<m?null:o-1}return null}function wn(n){n.n++,queueMicrotask(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{n.n=Math.max(0,n.n-1)})})})}function $n(n,e,t,r){let i="none",o={n:0},s={n:0};n.addEventListener("scroll",()=>{if(o.n>0){o.n--;return}i!=="doc"&&(i="code",wn(s),t(),i="none")},{passive:!0}),e.addEventListener("scroll",()=>{if(s.n>0){s.n--;return}i!=="code"&&(i="doc",wn(o),r(),i="none")},{passive:!0})}function Tn(n,e,t,r,i){let o=null,s=null,a=()=>{Ae(n,e,mn(n,e,t,r()))},c=()=>{Ce(n,e,dn(e,t),r())},l=()=>{if(i?.()===!0){o={k:"mirrorW",ratio:ae()};return}o=dn(e,t)},u=()=>{if(!o)return;let g=o;o=null,Ce(n,e,g,r())},h=()=>{s=mn(n,e,t,r())},d=()=>{if(!s)return;let g=s;s=null,Ae(n,e,g)};return $n(n,e,a,c),{syncFromCodeToDoc:a,syncFromDocToCode:c,prepareMobileFlipToCode:l,finishMobileFlipToCode:u,prepareMobileFlipToDoc:h,finishMobileFlipToDoc:d}}function Lr(n,e){let t=null,r=null,i=()=>{Ae(n,e,fn(n))},o=()=>{Ce(n,e,gn(e))},s=()=>{t=gn(e)},a=()=>{if(!t)return;let u=t;t=null,Ce(n,e,u)},c=()=>{r=fn(n)},l=()=>{if(!r)return;let u=r;r=null,Ae(n,e,u)};return $n(n,e,i,o),{syncFromCodeToDoc:i,syncFromDocToCode:o,prepareMobileFlipToCode:s,finishMobileFlipToCode:a,prepareMobileFlipToDoc:c,finishMobileFlipToDoc:l}}function On(n){let e=n.getBoundingClientRect();return(e.top+e.bottom)/2}function vn(n){return On(n)}function xr(n,e,t,r){if(e){let a=document.getElementById(`commentray-block-${e.id}`);if(!a)return On(t);let c=a.getBoundingClientRect().top-3;if(!r)return c;let l=t.getBoundingClientRect().top+4,u=wt(n,t,a);return Math.min(c,Math.max(l,u))}let o=n.getBoundingClientRect().bottom-4,s=n.children[n.children.length-1];if(s&&(o=Math.min(o,s.getBoundingClientRect().bottom-4)),r){let a=t.getBoundingClientRect().top+4,c=wt(n,t,null);o=Math.min(o,Math.max(a,c))}return o}function qn(n,e){if(!n.startsWith(e))return null;let t=Number.parseInt(n.slice(e.length),10);return Number.isFinite(t)?t:null}function Wn(n,e){let t=0,r=n.length-1,i=-1;for(;t<=r;){let o=t+r>>1;(n[o]?.line0??-1)>=e?(i=o,r=o-1):t=o+1}return i>=0?n[i]?.el??null:null}function kr(n,e){let t=0,r=n.length-1,i=-1;for(;t<=r;){let o=t+r>>1;(n[o]?.line0??-1)<=e?(i=o,t=o+1):r=o-1}return i>=0?n[i]?.el??null:null}function Hr(n){return Array.from(document.querySelectorAll(`[id^="${n}"]`)).map(e=>({line0:qn(e.id,n),el:e})).filter(e=>e.line0!==null).sort((e,t)=>e.line0-t.line0)}function Cr(n,e,t,r){let i=()=>r();e.addEventListener("scroll",i,{passive:!0}),t.addEventListener("scroll",i,{passive:!0}),globalThis.addEventListener("resize",i);let o=new ResizeObserver(i);o.observe(n),o.observe(e),o.observe(t);let s=n.parentElement;s&&o.observe(s)}function Ar(n,e,t,r,i,o){let s=Gt(r()),a=Se(s),c=e.getBoundingClientRect(),l=c.width,u=c.height;if(l<=0||u<=0||a.length===0){n.replaceChildren();return}let h=t.querySelector(".commentray-block-anchor")!==null?jt(s,Ft(t)):Qt(s,i()),d=zn();n.setAttribute("viewBox",`0 0 ${String(l)} ${String(u)}`),n.setAttribute("preserveAspectRatio","none");let g=[],m=Array.from(document.querySelectorAll(`[id^="${o}"]`)).map(f=>({line0:qn(f.id,o),el:f})).filter(f=>f.line0!==null).sort((f,p)=>f.line0-p.line0);for(let f=0;f<a.length;f++){let p=a[f];if(!p)continue;let E=Ut(s,p),x=bt(p.sourceStart),P=bt(p.sourceEnd),k=document.getElementById(`${o}${String(x)}`)??Wn(m,x),C=document.getElementById(`${o}${String(P)}`)??kr(m,P),w=document.getElementById(`commentray-block-${p.id}`);if(!k||!C||!w)continue;let M=xr(t,E,w,d),G=vn(k),ce=vn(C),_=w.getBoundingClientRect().top+2,A=Math.max(M,_+4),V=oe(G,c.top,u),zt=oe(_,c.top,u),$t=oe(ce,c.top,u),Ot=oe(A,c.top,u),Re=p.id===h?"gutter__rays-path gutter__rays-path--active":"gutter__rays-path",qt=`${Re} gutter__rays-path--trail`,Fe=yt(0,V.y,l,zt.y,{tension:.38,clipStart:V.clipped,clipEnd:zt.clipped}),De=yt(0,$t.y,l,Ot.y,{tension:.38,clipStart:$t.clipped,clipEnd:Ot.clipped}),Yn=Fe.dotted?`<path class="${qt}" d="${Fe.dotted}" />`:"",Vn=De.dotted?`<path class="${qt}" d="${De.dotted}" />`:"";g.push(`<g class="gutter__rays-block" data-commentray-block="${L(p.id)}"><path class="${Re}" d="${Fe.solid}" />`+Yn+`<path class="${Re}" d="${De.solid}" />`+Vn+"</g>")}n.innerHTML=g.join("")}function Br(n){let{gutter:e,codePane:t,docScrollEl:r,getLinks:i,probeTopSourceLine1Based:o}=n,s=n.sourceLineIdPrefix??(()=>"code-line-"),a="http://www.w3.org/2000/svg",c=document.createElement("div");c.className="gutter__rays",c.setAttribute("aria-hidden","true");let l=document.createElementNS(a,"svg");c.appendChild(l),e.appendChild(c);let u=0;function h(){u===0&&(u=globalThis.requestAnimationFrame(()=>{u=0,Ar(l,e,r,i,o,s())}))}return Cr(e,t,r,h),h(),globalThis.requestAnimationFrame(()=>{h(),globalThis.requestAnimationFrame(h)}),h}function Pr(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 Dt(n){let e=[];if(!Array.isArray(n))return e;for(let t of n)Pr(t)&&e.push(t);return e}function Ir(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 Rr(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 Fr(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 o=i,s=Ir(o);if(s){t.push(s);continue}let a=Rr(o,r);a&&(t.push(a),r+=1)}return t}function Gn(n){let e=n.trim();if(e==="")return[];try{let t=JSON.parse(F(e));return Dt(t)}catch{return[]}}function Dr(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 o=t[i];if(o===void 0)continue;r.children.has(o)||r.children.set(o,{children:new Map,pairs:[]});let s=r.children.get(o);if(s===void 0)return;i===t.length-1&&s.pairs.push(e),r=s}}function Nr(n){let e=n.replace(/\\/g,"/").replace(/\/+$/,""),t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function zr(n){return(n.replace(/\\/g,"/").replace(/\/+$/,"").split("/").filter(Boolean).at(-1)??"").replace(/\.md$/i,"")}function $r(n,e){let t=Nr(n.sourcePath);if(!e)return t;let r=zr(n.commentrayPath);return r!==""&&r!==t?`${t} \xB7 ${r}`:t}function Or(n){let e=(n.staticBrowseUrl??"").trim();if(e.length>0)return q(e,globalThis.location.pathname,globalThis.location.origin);let t=(n.commentrayOnGithub??"").trim();return t.length>0?t:"#"}function qr(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 Wr(n){for(let e of n.querySelectorAll("a.tree-file-link"))e instanceof HTMLAnchorElement&&(e.classList.remove("tree-file-link--current"),e.removeAttribute("aria-current"))}function Gr(n,e,t){for(let r of n.querySelectorAll("a.tree-file-link")){if(!(r instanceof HTMLAnchorElement))continue;let i=r.getAttribute("data-pair-source-path")?.trim()??"",o=r.getAttribute("data-pair-commentray-path")?.trim()??"";if(Et({sourcePath:i,commentrayPath:o},e,t)){r.classList.add("tree-file-link--current"),r.setAttribute("aria-current","page");break}}}function _n(){let n=document.getElementById("shell"),e=document.getElementById("documented-files-tree");if(!(n instanceof HTMLElement)||!(e instanceof HTMLElement))return;Wr(e);let t=n.getAttribute("data-commentray-pair-source-path")?.trim()??"",r=n.getAttribute("data-commentray-pair-commentray-path")?.trim()??"";t.length===0||r.length===0||Gr(e,t,r)}function Un(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 o=Un(i);t.push(`<li><div class="tree-dir">${L(r)}</div>${o}</li>`)}if(i.pairs.length>0){let o=i.pairs.length>1;for(let s of i.pairs){let a=L($r(s,o)),c=L(qr(s)),l=L(Or(s)),u=L(S(s.sourcePath)),h=L(S(s.commentrayPath)),g=(s.staticBrowseUrl?.trim()??"").length>0?"":' target="_blank" rel="noopener noreferrer"';t.push(`<li><div class="tree-file"><a class="tree-file-link" href="${l}" data-pair-source-path="${u}" data-pair-commentray-path="${h}"${g} title="${c}">${a}</a></div></li>`)}}}}return`<ul>${t.join("")}</ul>`}function _r(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)Dr(r,i);n.innerHTML=Un(r),_n()}function Ur(n,e){let t=null,r=null;return async()=>t!==null?t:(r===null&&(r=(async()=>{if(e.length>0&&(t=Gn(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 o=await i.json();t=Dt(o.documentedPairs)})()),await r,t??[])}function Qr(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 s=n.querySelector("summary");return s instanceof HTMLElement?s:null}function o(){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 s=i();if(!s)return;let a=s.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",o),globalThis.addEventListener("resize",o),globalThis.addEventListener("scroll",o,!0),o}function jr(){let n=document.getElementById("documented-files-filter");n instanceof HTMLInputElement&&n.focus({preventScroll:!0})}function Yr(){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=n,o=e,s=i.getAttribute("data-nav-json-url")?.trim()??"",a=r?.getAttribute("data-documented-pairs-b64")?.trim()??"";if(s.length===0&&a.length===0)return;let c=Qr(i),l=Ur(s,a),u=null;function h(){if(u===null)return;let m=t instanceof HTMLInputElement?t.value:"",f=Zt(u,m),p=m.trim().length>0;_r(o,f,p&&u.length>0&&f.length===0)}async function d(){try{u=await l(),h()}catch{u=null,o.innerHTML='<p class="nav-rail__doc-hub-hint" role="alert">Could not load the file list.</p>'}}i.addEventListener("toggle",()=>{c(),i.open&&globalThis.requestAnimationFrame(()=>{c(),jr()}),i.open&&d()});function g(m){if(!i.open||m.key!=="Escape")return;m.preventDefault(),i.open=!1;let f=i.querySelector("summary");f instanceof HTMLElement&&f.focus({preventScroll:!0})}document.addEventListener("keydown",g,!0),t instanceof HTMLInputElement&&t.addEventListener("input",()=>{!i.open||u===null||h()})}function Vr(n,e,t,r,i){let o=!1,s=i;function a(l){if(!o)return;let u=e.getBoundingClientRect(),h=l.clientX-u.left,d=T(h/u.width*100,15,85);s=d,t.style.flex=`0 0 ${d}%`,e.style.setProperty("--split-pct",`${String(d)}%`)}function c(){o=!1,window.removeEventListener("mousemove",a),window.removeEventListener("mouseup",c),document.body.style.cursor="",document.body.style.userSelect="",B(localStorage,n,String(s))}r.addEventListener("mousedown",l=>{l.preventDefault(),o=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",a),window.addEventListener("mouseup",c)})}var Mn="commentray.codeCommentrayStatic.splitPct",Qn="commentray.codeCommentrayStatic.wrap",En="commentray.codeCommentrayStatic.dualMobilePane",Kr="commentray.codeCommentrayStatic.sourceMarkdownPaneMode",Jr="commentray.codeCommentrayStatic.pageBreaksEnabled",Nt="(max-width: 767px)";function It(n){return n==="code"?"code":"doc"}function jn(){return globalThis.matchMedia(Nt).matches}function Xr(n){let e=document.getElementById("commentray-help-tour");e instanceof HTMLButtonElement&&e.addEventListener("click",()=>{Ct(n,jn,{force:!0})})}function W(n){return n.getAttribute("data-source-pane-mode")==="rendered-markdown"?"rendered-markdown":"source"}function Zr(n){let e=(n??"").trim().toLowerCase();return!(e==="0"||e==="false"||e==="off")}function ei(n){let e=Zr(D(localStorage,Jr));n.setAttribute("data-page-breaks-enabled",e?"true":"false")}function ti(n){let e=()=>{let t=Math.max(globalThis.innerHeight,document.documentElement?.clientHeight??0);if(!Number.isFinite(t)||t<=0)return;let r=Math.round(T(t*.72,260,820));n.style.setProperty("--commentray-page-break-min-height",`${String(r)}px`)};globalThis.addEventListener("resize",e,{passive:!0}),globalThis.addEventListener("orientationchange",e,{passive:!0}),globalThis.visualViewport?.addEventListener("resize",e,{passive:!0}),e()}function Ln(n){let e=document.querySelector("label.toolbar-wrap-lines");e instanceof HTMLLabelElement&&(e.hidden=W(n)==="rendered-markdown")}function Be(n){return W(n)==="rendered-markdown"?"code-md-line-":"code-line-"}function ni(n,e){let t=()=>{if(n.getAttribute("data-layout")!=="dual"||!e.matches||It(n.getAttribute("data-dual-mobile-pane"))!=="doc")return;let r=document.getElementById("doc-pane-body");r instanceof HTMLElement&&Ie(r)};queueMicrotask(()=>{t(),requestAnimationFrame(()=>{t(),requestAnimationFrame(t)})})}function ri(n,e,t){let r=()=>{e.hidden=!0,e.classList.remove("is-visible")},i=()=>{e.hidden=!1,e.classList.add("is-visible")},o=()=>{if(!t.matches){r();return}let s=n.getBoundingClientRect(),a=globalThis.innerHeight,c=10;s.bottom<c||s.top>a-c?i():r()};globalThis.addEventListener("scroll",o,{passive:!0}),globalThis.addEventListener("resize",o,{passive:!0}),t.addEventListener("change",o),globalThis.requestAnimationFrame(o)}function ii(n,e){let t=()=>{e.hidden=!0,e.classList.remove("is-visible")},r=()=>{e.hidden=!1,e.classList.add("is-visible")},i=()=>{let o=n.getBoundingClientRect(),s=globalThis.innerHeight,a=10;o.bottom<a||o.top>s-a?r():t()};globalThis.addEventListener("scroll",i,{passive:!0}),globalThis.addEventListener("resize",i,{passive:!0}),globalThis.requestAnimationFrame(i)}function oi(n,e){let t=n.querySelectorAll(`[id^="${e}"]`);if(t.length===0)return null;let r=v(n)?n.getBoundingClientRect().top+n.clientTop+2:Math.max(0,n.getBoundingClientRect().top)+2;for(let s of t)if(s.getBoundingClientRect().bottom>r-.001){let c=/^(?:code-line-|code-md-line-)(\d+)$/.exec(s.id);return c?.[1]?Number.parseInt(c[1],10):null}let i=t[t.length-1];if(!i)return null;let o=/^(?:code-line-|code-md-line-)(\d+)$/.exec(i.id);return o?.[1]?Number.parseInt(o[1],10):null}function si(n,e,t,r,i){function o(){let c=W(n)==="rendered-markdown",u=`Switch source pane to ${c?"markdown source":"rendered markdown"}`,h=`Source pane: ${c?"rendered markdown":"markdown source"} (click to switch)`,d=g=>{g instanceof HTMLButtonElement&&(g.setAttribute("aria-pressed",c?"true":"false"),g.setAttribute("aria-label",u),g.title=h)};d(t),d(r)}n.setAttribute("data-source-pane-mode","rendered-markdown"),o(),Ln(n);let s=()=>{let a=W(n),l=oi(e,a==="rendered-markdown"?"code-md-line-":"code-line-"),u=a==="rendered-markdown"?"source":"rendered-markdown",h=u==="rendered-markdown"?"code-md-line-":"code-line-";if(n.setAttribute("data-source-pane-mode",u),B(localStorage,Kr,u),o(),Ln(n),l!==null){let d=e.querySelector(`#${h}${String(l)}`);d instanceof HTMLElement&&Rt(e,d,2)}if(u==="rendered-markdown"){let d=document.getElementById("code-pane-markdown-body");d instanceof HTMLElement&&(Ie(d),Pe(d))}i?.()};t.addEventListener("click",s),r&&(r.addEventListener("click",s),ii(t,r))}function ai(n,e,t,r){let i=globalThis.matchMedia(Nt);function o(){return It(D(localStorage,En))}function s(){i.matches?n.setAttribute("data-dual-mobile-pane",o()):n.removeAttribute("data-dual-mobile-pane")}let a=()=>{if(!i.matches)return;let l=It(n.getAttribute("data-dual-mobile-pane"))==="code"?"doc":"code",u=Y().scrollTop;l==="code"?t.prepareMobileFlipToCode():t.prepareMobileFlipToDoc(),n.setAttribute("data-dual-mobile-pane",l),B(localStorage,En,l),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(()=>{if(l==="code"){t.finishMobileFlipToCode();let h=Y();if(u>5&&h.scrollTop<=1){let d=Math.max(0,h.scrollHeight-h.clientHeight);h.scrollTop=T(u,0,d)}}else t.finishMobileFlipToDoc()})}),l==="doc"&&ni(n,i)};e.addEventListener("click",a),r&&(r.addEventListener("click",a),ri(e,r,i)),i.addEventListener("change",s),s()}function ci(n){let e=document.getElementById("wrap-lines");e&&Pn(Qn,n,e,()=>{globalThis.dispatchEvent(new Event("resize"))})}function li(n){let e=n?.textContent?.trim()??"";if(!e)return null;try{let t=JSON.parse(F(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 ui(){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"),o=document.getElementById("search-results");if(!n||!e||!t||!r||!i||!o)return null;let s=document.getElementById("doc-pane-body"),a=s instanceof HTMLElement?s:n;return{docBody:s,docScrollEl:a,gutter:e,wrapCb:t,searchInput:r,searchClear:i,searchResults:o}}function hi(n){let{scope:e,rawCode:t,filePathLabel:r,hubNavRows:i,pathRowsForOrdering:o,rawMd:s,commentrayPathLabel:a}=n;if(e!=="commentray-and-paths")return pn(e,t,s,r,a);if(i.length>0)return i;let c=o.length>0?o:pn(e,t,s,r,a).filter(u=>u.kind==="path"),l=s.split(`
20
+ `).map((u,h)=>({kind:"md",line:h,text:u,spPath:r,crPath:a}));return[...c,...l]}function di(n,e,t,r){if(e!=="commentray-and-paths")return{documentedPairs:[],pathRowsForOrdering:[],pathBlobWide:""};let i=Gn(n.getAttribute("data-documented-pairs-b64")?.trim()??""),o=en(i),s=o.length>0?o.map(a=>a.text).join(`
21
21
  `):[t,r].filter(a=>a.trim().length>0).join(`
22
- `);return{documentedPairs:i,pathRowsForOrdering:o,pathBlobWide:s}}function Zr(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(S(r.commentrayPath),i)}return e.map(r=>{if((r.staticBrowseUrl??"").trim().length>0)return r;let o=t.get(S(r.commentrayPath));return o!==void 0&&o.length>0?{...r,staticBrowseUrl:o}:r})}function ei(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 ti(n,e,t,r,i,o){let s=ei(n);s.length!==0&&(async()=>{try{let a=await fetch(s,{credentials:"same-origin"});if(!a.ok)return;let c=await a.json(),l=Ct(c.documentedPairs),u=Zr(e,l);u.length>0&&(t.documentedPairs=u,r.documentedPairs=u);let h=Tr(c);if(h.length===0)return;t.hubNavRows=h,t.pathRowsForOrdering=h.filter(d=>d.kind==="path"),r.pathRowsForOrdering=t.pathRowsForOrdering,r.pathBlobWide=t.pathRowsForOrdering.map(d=>d.text).join(`
23
- `),i(),o.value.trim().length>0&&o.dispatchEvent(new Event("input",{bubbles:!0}))}catch{}})()}function ni(n){let{angle:e,docBody:t,mutable:r,rebuildSearcher:i,scrollLinksRef:o,shell:s,searchInput:a,searchResults:c,requestBlockRayRedraw:l}=n;t.innerHTML=F(e.docInnerHtmlB64),Ae(t),Pe(t),r.rawMd=F(e.rawMdB64),r.mdLines=r.rawMd.split(`
24
- `),r.commentrayPathLabel=e.commentrayPathForSearch,i(),o.current=wn(e.scrollBlockLinksB64),s.setAttribute("data-scroll-block-links-b64",e.scrollBlockLinksB64),s.setAttribute("data-search-commentray-path",e.commentrayPathForSearch);let u=S(e.commentrayPathForSearch);u.length>0?s.setAttribute("data-commentray-pair-commentray-path",u):s.removeAttribute("data-commentray-pair-commentray-path"),An();let h=document.getElementById("nav-rail-doc-path");if(h){let g=e.commentrayPathForSearch.trim();h.textContent=g.length>0?g:"\u2014",g.length>0?h.setAttribute("title",g):h.removeAttribute("title")}let d=e.staticBrowseUrl?.trim()??"";if(d.length>0){let g=Gt(d,globalThis.location.pathname,globalThis.location.origin);s.setAttribute("data-commentray-pair-browse-href",g)}else{let g=e.commentrayOnGithubUrl?.trim();g?s.setAttribute("data-commentray-pair-browse-href",g):s.removeAttribute("data-commentray-pair-browse-href")}a.value="",c.innerHTML="",c.hidden=!0,l?.(),globalThis.requestAnimationFrame(()=>{l?.(),globalThis.requestAnimationFrame(()=>{l?.()})})}function ri(n){let{codePane:e,docScrollEl:t,docBody:r,shell:i,scrollLinksRef:o,multiPayload:s,mutable:a,rebuildSearcher:c,searchInput:l,searchResults:u,requestBlockRayRedraw:h}=n;if(s){let d=cn(e,t,()=>o.current,()=>Ce(i),()=>W(i)==="rendered-markdown"),g=document.getElementById("angle-select");return g&&r&&g.addEventListener("change",()=>{let m=s.angles.find(f=>f.id===g.value);m&&ni({angle:m,docBody:r,mutable:a,rebuildSearcher:c,scrollLinksRef:o,shell:i,searchInput:l,searchResults:u,requestBlockRayRedraw:h})}),d}return o.current.length>0?cn(e,t,()=>o.current,()=>Ce(i),()=>W(i)==="rendered-markdown"):hr(e,t)}function ii(n,e){function t(i){let o=i.replace(/^#/,"").trim();if(o.length===0)return null;let s=o.split(/--|&/).map(a=>a.trim()).filter(a=>a.length>0);for(let a of s){let c=/^commentray-md-line-(\d+)$/.exec(a);if(!c?.[1])continue;let l=Number.parseInt(c[1],10);if(Number.isFinite(l))return l}return null}function r(){let i=t(globalThis.location.hash);i!==null&&yn(n,i,e())}globalThis.addEventListener("hashchange",r),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(r)})}function oi(n){if(W(n)!=="rendered-markdown")return;let e=document.getElementById("code-pane-markdown-body");e instanceof HTMLElement&&(Ae(e),Pe(e))}function si(n,e,t){let r=document.getElementById("source-markdown-pane-flip"),i=document.getElementById("source-markdown-pane-flip-scroll");r instanceof HTMLButtonElement&&(Qr(n,e,r,i instanceof HTMLButtonElement?i:null,t),oi(n))}function ai(n,e){let{rawCodeB64:t,rawMdB64:r}=Dt(n,e),i=F(t),o=F(r),a={current:wn(n.getAttribute("data-scroll-block-links-b64")||"")},{scope:c,filePathLabel:l,commentrayPathLabel:u}=er(n),h=Xr(n,c,l,u),d={hubNavRows:[],documentedPairs:h.documentedPairs,pathRowsForOrdering:h.pathRowsForOrdering},g={rawMd:o,mdLines:o.split(`
25
- `),commentrayPathLabel:u,searcher:rn([]),pathBlobWide:h.pathBlobWide,pathRowsForOrdering:d.pathRowsForOrdering,documentedPairs:d.documentedPairs};function m(){g.searcher=rn(Jr({scope:c,rawCode:i,filePathLabel:l,hubNavRows:d.hubNavRows,pathRowsForOrdering:d.pathRowsForOrdering,rawMd:g.rawMd,commentrayPathLabel:g.commentrayPathLabel}))}return m(),{rawCode:i,rawMd:o,scrollLinksRef:a,scope:c,filePathLabel:l,commentrayPathLabel:u,pathInit:h,indexState:d,mutable:g,rebuildSearcher:m}}function ci(n,e){let t=Kr();if(!t)return;let{docBody:r,docScrollEl:i,gutter:o,wrapCb:s,searchInput:a,searchClear:c,searchResults:l}=t,u=ai(n,e);Pe(document),ar({scope:u.scope,filePathLabel:u.filePathLabel,mutable:u.mutable,rawCode:u.rawCode,searchInput:a,searchClear:c,searchResults:l,docScrollEl:i}),ti(n,u.pathInit.documentedPairs,u.indexState,u.mutable,u.rebuildSearcher,a);let h=parseFloat(D(localStorage,un)||"46"),d=w(Number.isFinite(h)?h:46,15,85);e.style.flex=`0 0 ${d}%`,n.style.setProperty("--split-pct",`${String(d)}%`);let g=document.getElementById("doc-pane"),m=g instanceof HTMLElement?g:null,f=document.getElementById("code-pane-markdown-body"),p={};Sn(Bn,e,s,()=>{p.request?.()},m,r,f instanceof HTMLElement?f:null),Fr(un,n,e,o,d);let v=document.getElementById("commentray-multi-angle-b64"),x=Vr(v),H=x!==null||u.scrollLinksRef.current.length>0?yr({gutter:o,codePane:e,docScrollEl:i,getLinks:()=>u.scrollLinksRef.current,probeTopSourceLine1Based:()=>En(e,Ce(n)),sourceLineIdPrefix:()=>Ce(n)}):void 0;p.request=H;let k=ri({codePane:e,docScrollEl:i,docBody:r,shell:n,scrollLinksRef:u.scrollLinksRef,multiPayload:x,mutable:u.mutable,rebuildSearcher:u.rebuildSearcher,searchInput:a,searchResults:l,requestBlockRayRedraw:H}),M=document.getElementById("mobile-pane-flip"),E=document.getElementById("mobile-pane-flip-scroll");M instanceof HTMLButtonElement&&jr(n,M,k,E instanceof HTMLButtonElement?E:null),si(n,e,()=>{H?.()}),Mt(n,Rn),ii(i,()=>u.mutable.mdLines.length)}function li(n){return n==="light"?"Light":n==="dark"?"Dark":"System"}function ui(n,e){let t=li(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 hi(){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,o=t,s=Ee(D(localStorage,wt));Tt(s);let a=!1;function c(){i.dataset.commentrayTriggerMode=s,i.setAttribute("aria-expanded",a?"true":"false"),ui(i,s);for(let m of o.querySelectorAll("[data-commentray-theme-value]")){let f=Ee(m.dataset.commentrayThemeValue??"");m.setAttribute("aria-checked",f===s?"true":"false")}}function l(){a=!0,o.removeAttribute("hidden"),c(),(o.querySelector('[role="menuitemradio"][aria-checked="true"]')??o.querySelector('[role="menuitemradio"]'))?.focus()}function u(){a=!1,o.setAttribute("hidden",""),c()}function h(m){s=m,A(localStorage,wt,m),Tt(m),c()}i.addEventListener("click",m=>{m.preventDefault(),m.stopPropagation(),a?u():l()}),i.addEventListener("contextmenu",m=>{m.preventDefault(),a&&u(),h(Ut(s))});for(let m of o.querySelectorAll("[data-commentray-theme-value]"))m.addEventListener("click",f=>{f.stopPropagation();let p=Ee(m.dataset.commentrayThemeValue??"");h(p),u(),i.focus()});function d(m){if(!a)return;let f=m.target;f instanceof Node&&(r.contains(f)||u())}function g(m){!a||m.key!=="Escape"||(m.preventDefault(),m.stopPropagation(),u(),i.focus())}document.addEventListener("mousedown",d,!0),document.addEventListener("touchstart",d,!0),document.addEventListener("keydown",g,!0),c()}function di(n){let e=n.trim();if(e.length===0||/^(javascript|data):/i.test(e))return null;try{return new URL(e,globalThis.location.href).toString()}catch{return null}}function mi(n){return n.split("/").filter(e=>e.length>0).map(e=>encodeURIComponent(e)).join("/")}function gi(n){return(S(n).split("/").filter(Boolean).at(-1)??"").replace(/\.md$/i,"").trim()}function mn(n,e){return new URL(n,e).toString()}function fi(n,e){return(n.getAttribute("data-layout")??"dual")!=="dual"||e.includes("/browse/")?!1:e.endsWith("/")||e.endsWith("/index.html")}function pi(n,e){let t=S(n.getAttribute("data-commentray-pair-source-path")??"");if(t.length===0)return null;let r=mi(t);if(r.length===0)return null;let i=document.getElementById("angle-select"),o=i instanceof HTMLSelectElement?i.value.trim():"",s=n.getAttribute("data-commentray-pair-commentray-path")??"",a=gi(s),c=o.length>0?o:a;if(c.length===0)return null;let l=`${r}@${encodeURIComponent(c)}.html`,u=ve(e);return u==="/"?`/browse/${l}`:`${u}/browse/${l}`}function yi(n,e){let t=n.getAttribute("data-nav-search-json-url")?.trim()??"";t.length>0&&n.setAttribute("data-nav-search-json-url",mn(t,e));let r=document.getElementById("documented-files-hub");if(r instanceof HTMLElement){let i=r.getAttribute("data-nav-json-url")?.trim()??"";i.length>0&&r.setAttribute("data-nav-json-url",mn(i,e))}}function bi(n,e){let t=n.getAttribute("data-commentray-pair-browse-href")?.trim()??"";t.length>0&&Me(t)&&n.setAttribute("data-commentray-pair-browse-href",O(t,e,globalThis.location.origin))}function Si(){let n=document.querySelector('a[aria-label="Documentation home"]');if(!(n instanceof HTMLAnchorElement))return;let e=ve(globalThis.location.pathname),t=e==="/"?"/":`${e}/`;n.setAttribute("href",t)}function wi(){let n=document.getElementById("doc-pane");if(!(n instanceof HTMLElement))return null;let e=document.getElementById("doc-pane-body"),t=e instanceof HTMLElement?e:n;if(t.querySelectorAll(".commentray-block-anchor").length===0)return null;let i=Ln(t);return!Number.isFinite(i)||i<0?null:`commentray-md-line-${String(i)}`}function Ti(){let n=document.getElementById("shell");if(!(n instanceof HTMLElement))return;let e=globalThis.location.pathname;if(Si(),!fi(n,e))return;let t=pi(n,e);if(t===null)return;let r=globalThis.location.href;yi(n,r),bi(n,e),globalThis.history.replaceState(null,"",`${t}${globalThis.location.search}${globalThis.location.hash}`)}function vi(){let n=[],e=i=>{let o=i.trim();o.length!==0&&(n.includes(o)||n.push(o))},t=document.getElementById("angle-select");if(t instanceof HTMLSelectElement){let i=t.value.trim();i.length>0&&e(`angle-${encodeURIComponent(i)}`)}let r=wi();return r&&e(r),n.length>0?`#${n.join("&")}`:""}function Mi(n){let e=n.getAttribute("data-commentray-pair-browse-href")??"",r=(Me(e.trim())&&e.trim().length>0?O(e.trim(),globalThis.location.pathname,globalThis.location.origin):di(e))??globalThis.location.href,i=new URL(r,globalThis.location.href),o=vi();return i.hash=o.length>0?o.slice(1):"",i.toString()}async function Ei(n){try{return await navigator.clipboard.writeText(n),!0}catch{let e=document.createElement("textarea");e.value=n,e.setAttribute("readonly","true"),e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px",document.body.appendChild(e),e.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(e)}}}function Li(){let n=document.getElementById("shell"),e=document.getElementById("commentray-share-link");if(!(n instanceof HTMLElement)||!(e instanceof HTMLButtonElement))return;let t="Copy shareable permalink",r;e.addEventListener("click",()=>{(async()=>{let i=Mi(n);await Ei(i)&&(e.dataset.copied="true",e.setAttribute("aria-label","Permalink copied"),e.title="Permalink copied",r!==void 0&&globalThis.clearTimeout(r),r=globalThis.setTimeout(()=>{delete e.dataset.copied,e.setAttribute("aria-label",t),e.title=t},1200))})()})}function gn(){Li(),hi(),Rr();let n=document.getElementById("shell"),e=document.getElementById("code-pane");if(!n||!e)return;if(qr(n),Or(n),Nr(n),(n.getAttribute("data-layout")||"dual")==="stretch"){Yr(e);return}ci(n,e),Ti()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",gn):gn();})();
22
+ `);return{documentedPairs:i,pathRowsForOrdering:o,pathBlobWide:s}}function mi(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(S(r.commentrayPath),i)}return e.map(r=>{if((r.staticBrowseUrl??"").trim().length>0)return r;let o=t.get(S(r.commentrayPath));return o!==void 0&&o.length>0?{...r,staticBrowseUrl:o}:r})}function gi(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 fi(n,e,t,r,i,o){let s=gi(n);s.length!==0&&(async()=>{try{let a=await fetch(s,{credentials:"same-origin"});if(!a.ok)return;let c=await a.json(),l=Dt(c.documentedPairs),u=mi(e,l);u.length>0&&(t.documentedPairs=u,r.documentedPairs=u);let h=Fr(c);if(h.length===0)return;t.hubNavRows=h,t.pathRowsForOrdering=h.filter(d=>d.kind==="path"),r.pathRowsForOrdering=t.pathRowsForOrdering,r.pathBlobWide=t.pathRowsForOrdering.map(d=>d.text).join(`
23
+ `),i(),o.value.trim().length>0&&o.dispatchEvent(new Event("input",{bubbles:!0}))}catch{}})()}function pi(n){let{angle:e,docBody:t,mutable:r,rebuildSearcher:i,scrollLinksRef:o,shell:s,searchInput:a,searchResults:c,requestBlockRayRedraw:l}=n;t.innerHTML=F(e.docInnerHtmlB64),Ie(t),Pe(t),r.rawMd=F(e.rawMdB64),r.mdLines=r.rawMd.split(`
24
+ `),r.commentrayPathLabel=e.commentrayPathForSearch,i(),o.current=In(e.scrollBlockLinksB64),s.setAttribute("data-scroll-block-links-b64",e.scrollBlockLinksB64),s.setAttribute("data-search-commentray-path",e.commentrayPathForSearch);let u=S(e.commentrayPathForSearch);u.length>0?s.setAttribute("data-commentray-pair-commentray-path",u):s.removeAttribute("data-commentray-pair-commentray-path"),_n();let h=document.getElementById("nav-rail-doc-path");if(h){let g=e.commentrayPathForSearch.trim();h.textContent=g.length>0?g:"\u2014",g.length>0?h.setAttribute("title",g):h.removeAttribute("title")}let d=e.staticBrowseUrl?.trim()??"";if(d.length>0){let g=nn(d,globalThis.location.pathname,globalThis.location.origin);s.setAttribute("data-commentray-pair-browse-href",g)}else{let g=e.commentrayOnGithubUrl?.trim();g?s.setAttribute("data-commentray-pair-browse-href",g):s.removeAttribute("data-commentray-pair-browse-href")}a.value="",c.innerHTML="",c.hidden=!0,l?.(),globalThis.requestAnimationFrame(()=>{l?.(),globalThis.requestAnimationFrame(()=>{l?.()})})}function yi(n){let{codePane:e,docScrollEl:t,docBody:r,shell:i,scrollLinksRef:o,multiPayload:s,mutable:a,rebuildSearcher:c,searchInput:l,searchResults:u,requestBlockRayRedraw:h}=n;if(s){let d=Tn(e,t,()=>o.current,()=>Be(i),()=>W(i)==="rendered-markdown"),g=document.getElementById("angle-select");return g&&r&&g.addEventListener("change",()=>{let m=s.angles.find(f=>f.id===g.value);m&&pi({angle:m,docBody:r,mutable:a,rebuildSearcher:c,scrollLinksRef:o,shell:i,searchInput:l,searchResults:u,requestBlockRayRedraw:h})}),d}return o.current.length>0?Tn(e,t,()=>o.current,()=>Be(i),()=>W(i)==="rendered-markdown"):Lr(e,t)}function bi(n,e){function t(i){let o=i.replace(/^#/,"").trim();if(o.length===0)return null;let s=o.split(/--|&/).map(a=>a.trim()).filter(a=>a.length>0);for(let a of s){let c=/^commentray-md-line-(\d+)$/.exec(a);if(!c?.[1])continue;let l=Number.parseInt(c[1],10);if(Number.isFinite(l))return l}return null}function r(){let i=t(globalThis.location.hash);i!==null&&An(n,i,e())}globalThis.addEventListener("hashchange",r),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(r)})}function Si(n){if(W(n)!=="rendered-markdown")return;let e=document.getElementById("code-pane-markdown-body");e instanceof HTMLElement&&(Ie(e),Pe(e))}function wi(n,e,t){let r=document.getElementById("source-markdown-pane-flip"),i=document.getElementById("source-markdown-pane-flip-scroll");r instanceof HTMLButtonElement&&(si(n,e,r,i instanceof HTMLButtonElement?i:null,t),Si(n))}function Ti(n,e){let{rawCodeB64:t,rawMdB64:r}=Vt(n,e),i=F(t),o=F(r),a={current:In(n.getAttribute("data-scroll-block-links-b64")||"")},{scope:c,filePathLabel:l,commentrayPathLabel:u}=fr(n),h=di(n,c,l,u),d={hubNavRows:[],documentedPairs:h.documentedPairs,pathRowsForOrdering:h.pathRowsForOrdering},g={rawMd:o,mdLines:o.split(`
25
+ `),commentrayPathLabel:u,searcher:yn([]),pathBlobWide:h.pathBlobWide,pathRowsForOrdering:d.pathRowsForOrdering,documentedPairs:d.documentedPairs};function m(){g.searcher=yn(hi({scope:c,rawCode:i,filePathLabel:l,hubNavRows:d.hubNavRows,pathRowsForOrdering:d.pathRowsForOrdering,rawMd:g.rawMd,commentrayPathLabel:g.commentrayPathLabel}))}return m(),{rawCode:i,rawMd:o,scrollLinksRef:a,scope:c,filePathLabel:l,commentrayPathLabel:u,pathInit:h,indexState:d,mutable:g,rebuildSearcher:m}}function vi(n,e){let t=ui();if(!t)return;let{docBody:r,docScrollEl:i,gutter:o,wrapCb:s,searchInput:a,searchClear:c,searchResults:l}=t,u=Ti(n,e);Pe(document),vr({scope:u.scope,filePathLabel:u.filePathLabel,mutable:u.mutable,rawCode:u.rawCode,searchInput:a,searchClear:c,searchResults:l,docScrollEl:i}),fi(n,u.pathInit.documentedPairs,u.indexState,u.mutable,u.rebuildSearcher,a);let h=parseFloat(D(localStorage,Mn)||"46"),d=T(Number.isFinite(h)?h:46,15,85);e.style.flex=`0 0 ${d}%`,n.style.setProperty("--split-pct",`${String(d)}%`);let g=document.getElementById("doc-pane"),m=g instanceof HTMLElement?g:null,f=document.getElementById("code-pane-markdown-body"),p={};Pn(Qn,e,s,()=>{p.request?.()},m,r,f instanceof HTMLElement?f:null),Vr(Mn,n,e,o,d);let E=document.getElementById("commentray-multi-angle-b64"),x=li(E),k=x!==null||u.scrollLinksRef.current.length>0?Br({gutter:o,codePane:e,docScrollEl:i,getLinks:()=>u.scrollLinksRef.current,probeTopSourceLine1Based:()=>Nn(e,Be(n)),sourceLineIdPrefix:()=>Be(n)}):void 0;p.request=k;let C=yi({codePane:e,docScrollEl:i,docBody:r,shell:n,scrollLinksRef:u.scrollLinksRef,multiPayload:x,mutable:u.mutable,rebuildSearcher:u.rebuildSearcher,searchInput:a,searchResults:l,requestBlockRayRedraw:k}),w=document.getElementById("mobile-pane-flip"),M=document.getElementById("mobile-pane-flip-scroll");w instanceof HTMLButtonElement&&ai(n,w,C,M instanceof HTMLButtonElement?M:null),wi(n,e,()=>{k?.()}),Ct(n,jn),bi(i,()=>u.mutable.mdLines.length)}function Mi(n){return n==="light"?"Light":n==="dark"?"Dark":"System"}function Ei(n,e){let t=Mi(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 Li(){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,o=t,s=xe(D(localStorage,xt));kt(s);let a=!1;function c(){i.dataset.commentrayTriggerMode=s,i.setAttribute("aria-expanded",a?"true":"false"),Ei(i,s);for(let m of o.querySelectorAll("[data-commentray-theme-value]")){let f=xe(m.dataset.commentrayThemeValue??"");m.setAttribute("aria-checked",f===s?"true":"false")}}function l(){a=!0,o.removeAttribute("hidden"),c(),(o.querySelector('[role="menuitemradio"][aria-checked="true"]')??o.querySelector('[role="menuitemradio"]'))?.focus()}function u(){a=!1,o.setAttribute("hidden",""),c()}function h(m){s=m,B(localStorage,xt,m),kt(m),c()}i.addEventListener("click",m=>{m.preventDefault(),m.stopPropagation(),a?u():l()}),i.addEventListener("contextmenu",m=>{m.preventDefault(),a&&u(),h(rn(s))});for(let m of o.querySelectorAll("[data-commentray-theme-value]"))m.addEventListener("click",f=>{f.stopPropagation();let p=xe(m.dataset.commentrayThemeValue??"");h(p),u(),i.focus()});function d(m){if(!a)return;let f=m.target;f instanceof Node&&(r.contains(f)||u())}function g(m){!a||m.key!=="Escape"||(m.preventDefault(),m.stopPropagation(),u(),i.focus())}document.addEventListener("mousedown",d,!0),document.addEventListener("touchstart",d,!0),document.addEventListener("keydown",g,!0),c()}function xi(n){let e=n.trim();if(e.length===0||/^(javascript|data):/i.test(e))return null;try{return new URL(e,globalThis.location.href).toString()}catch{return null}}function ki(n){return n.split("/").filter(e=>e.length>0).map(e=>e.startsWith(".")?`%2E${encodeURIComponent(e.slice(1))}`:encodeURIComponent(e)).join("/")}function Hi(n){return(S(n).split("/").filter(Boolean).at(-1)??"").replace(/\.md$/i,"").trim()}function xn(n,e){return new URL(n,e).toString()}function Ci(n,e){return(n.getAttribute("data-layout")??"dual")!=="dual"||e.includes("/browse/")?!1:e.endsWith("/")||e.endsWith("/index.html")}function Ai(n,e){let t=S(n.getAttribute("data-commentray-pair-source-path")??"");if(t.length===0)return null;let r=ki(t);if(r.length===0)return null;let i=document.getElementById("angle-select"),o=i instanceof HTMLSelectElement?i.value.trim():"",s=n.getAttribute("data-commentray-pair-commentray-path")??"",a=Hi(s),c=o.length>0?o:a;if(c.length===0)return null;let l=`${r}@${encodeURIComponent(c)}.html`,u=Ee(e);return u==="/"?`/browse/${l}`:`${u}/browse/${l}`}function Bi(n,e){let t=n.getAttribute("data-nav-search-json-url")?.trim()??"";t.length>0&&n.setAttribute("data-nav-search-json-url",xn(t,e));let r=document.getElementById("documented-files-hub");if(r instanceof HTMLElement){let i=r.getAttribute("data-nav-json-url")?.trim()??"";i.length>0&&r.setAttribute("data-nav-json-url",xn(i,e))}}function Pi(n,e){let t=n.getAttribute("data-commentray-pair-browse-href")?.trim()??"";t.length>0&&Le(t)&&n.setAttribute("data-commentray-pair-browse-href",q(t,e,globalThis.location.origin))}function Ii(){let n=document.querySelector('a[aria-label="Documentation home"]');if(!(n instanceof HTMLAnchorElement))return;let e=Ee(globalThis.location.pathname),t=e==="/"?"/":`${e}/`;n.setAttribute("href",t)}function Ri(){let n=document.getElementById("doc-pane");if(!(n instanceof HTMLElement))return null;let e=document.getElementById("doc-pane-body"),t=e instanceof HTMLElement?e:n;if(t.querySelectorAll(".commentray-block-anchor").length===0)return null;let i=Ft(t);return!Number.isFinite(i)||i<0?null:`commentray-md-line-${String(i)}`}function Fi(){let n=document.getElementById("shell");if(!(n instanceof HTMLElement))return;let e=globalThis.location.pathname;if(Ii(),!Ci(n,e))return;let t=globalThis.location.href;Bi(n,t),Pi(n,e);let i=(()=>{let o=n.getAttribute("data-commentray-pair-browse-href")?.trim()??"";if(o.length===0)return null;try{let s=new URL(o,globalThis.location.href);return s.origin!==globalThis.location.origin||!s.pathname.includes("/browse/")?null:s.pathname}catch{return null}})()??Ai(n,e);i!==null&&globalThis.history.replaceState(null,"",`${i}${globalThis.location.search}${globalThis.location.hash}`)}function Di(){let n=[],e=i=>{let o=i.trim();o.length!==0&&(n.includes(o)||n.push(o))},t=document.getElementById("angle-select");if(t instanceof HTMLSelectElement){let i=t.value.trim();i.length>0&&e(`angle-${encodeURIComponent(i)}`)}let r=Ri();return r&&e(r),n.length>0?`#${n.join("&")}`:""}function Ni(n){let e=n.getAttribute("data-commentray-pair-browse-href")??"",r=(Le(e.trim())&&e.trim().length>0?q(e.trim(),globalThis.location.pathname,globalThis.location.origin):xi(e))??globalThis.location.href,i=new URL(r,globalThis.location.href),o=Di();return i.hash=o.length>0?o.slice(1):"",i.toString()}async function zi(n){try{return await navigator.clipboard.writeText(n),!0}catch{let e=document.createElement("textarea");e.value=n,e.setAttribute("readonly","true"),e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px",document.body.appendChild(e),e.select();try{return document.execCommand("copy")}catch{return!1}finally{document.body.removeChild(e)}}}function $i(){let n=document.getElementById("shell"),e=document.getElementById("commentray-share-link");if(!(n instanceof HTMLElement)||!(e instanceof HTMLButtonElement))return;let t="Copy shareable permalink",r;e.addEventListener("click",()=>{(async()=>{let i=Ni(n);await zi(i)&&(e.dataset.copied="true",e.setAttribute("aria-label","Permalink copied"),e.title="Permalink copied",r!==void 0&&globalThis.clearTimeout(r),r=globalThis.setTimeout(()=>{delete e.dataset.copied,e.setAttribute("aria-label",t),e.title=t},1200))})()})}function kn(){$i(),Li(),Yr();let n=document.getElementById("shell"),e=document.getElementById("code-pane");if(!n||!e)return;if(ei(n),ti(n),Xr(n),(n.getAttribute("data-layout")||"dual")==="stretch"){ci(e);return}vi(n,e),Fi()}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",kn):kn();})();