@commentray/render 0.3.3 → 0.3.4

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.
@@ -1,6 +1,6 @@
1
- "use strict";(()=>{var W=class{static ToInt32Array(e){let t=new Int32Array(e.length);for(let r=0,o=e.length;r<o;r++)t[r]=e[r];return t}},ke=class{static getHashCode(e){let t=5381,r=t;for(let o=0,i=e.length;o<i&&e[o]!="\0"&&(t=(t<<5)+t^e.charCodeAt(o),o!==i-1&&e[o+1]!=="\0");o+=2)r=(r<<5)+r^e.charCodeAt(o+1);return t+1566083941*r|0}},v=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)}}},le=class{static mergeMeta(e){if(e.length===0)return new v;if(e.length===1)return e[0];let t=new Map;for(let o of e)for(let[i,s]of o.allEntries){let a=t.get(i);a===void 0?t.set(i,[s]):a.push(s)}let r=new Map;for(let[o,i]of t)if(i.length!==1){if(i.every(s=>typeof s=="number")){let s=i.reduce((a,c)=>a+c,0);r.set(o,s);continue}for(let s=0;s<i.length;s++)r.set(`${o}_${s}`,i[s])}else r.set(o,i[0]);return new v(r)}},He=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}},xe=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)}},V=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}},w,ue;(function(n){n.Fuzzy="fuzzy",n.Substring="substring",n.Prefix="prefix"})(w||(w={}));var de=class{constructor(e,t){this.type=void 0,this.minQuality=void 0,this.type=e,this.minQuality=Math.max(0,t)}},he=class extends de{constructor(e){super(w.Fuzzy,e)}},Z=class extends de{constructor(e){super(w.Substring,e)}},ee=class extends de{constructor(e){super(w.Prefix,e)}},U=class{constructor(e,t=10,r=[new he(.3),new Z(0),new ee(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}},it=class{constructor(e,t){this.removedEntities=void 0,this.meta=void 0,this.removedEntities=e,this.meta=t}},st=class{static mergeResults(e,t){let r=e.query,o=this.mergeMatches(e.matches,t.matches,r.topN),i=le.mergeMeta([e.meta,t.meta]);return new V(o,r,i)}static mergeMatches(e,t,r){if(t.length===0)return e;if(e.length===0)return t;let o=[...e,...t];return o.sort((i,s)=>i.quality>s.quality?-1:i.quality<s.quality?1:0),o.length<=r?o:o.slice(0,r)}},at=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 U(e.string.substring(0,this.maxQueryLength),e.topN,e.searchers)),st.mergeResults(this.mainSearcher.getMatches(e),this.secondarySearcher.getMatches(e))):new V([],e,new v)}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 o=0,i=e.length;o<i;o++)(this.mainSearcher.removeEntity(e[o])||this.secondarySearcher.removeEntity(e[o]))&&t.push(e[o]);let r=new v;return new it(t,r)}upsertEntities(e,t,r){let o=[],i=[];for(let s=0,a=e.length;s<a;s++){let c=e[s],l=t(c);this.tryUpdate(c,l,r)||(o.push(l),i.push(c))}return this.removeEntities(o),i.length>0?this.reindexSecondarySearcher(i,t,r):new v}reindexSecondarySearcher(e,t,r){let o=this.secondarySearcher.getEntities().concat(e);return this.secondarySearcher.indexEntities(o,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,o){let i=o.tryGetTerms(t);if(i===null)return!1;if(this.termsAreEqual(i,r(e))){if(!o.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,o)=>r===t[o])}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)}},ct=class{constructor(e){this.dynamicSearcher=void 0,this.dynamicSearcher=e}removeEntities(e){let t=performance.now(),r=this.dynamicSearcher.removeEntities(e),o=Math.round(performance.now()-t);return r.meta.add("removalDuration",o),r}upsertEntities(e,t,r){let o=performance.now(),i=this.dynamicSearcher.upsertEntities(e,t,r),s=Math.round(performance.now()-o);return i.add("upsertDuration",s),i}indexEntities(e,t,r){let o=performance.now(),i=this.dynamicSearcher.indexEntities(e,t,r),s=Math.round(performance.now()-o);return i.add("indexingDurationTotal",s),i}getMatches(e){let t=performance.now(),r=this.dynamicSearcher.getMatches(e),o=Math.round(performance.now()-t);return r.meta.add("queryDuration",o),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)}},lt=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}},ut=class{constructor(e){this.query=void 0,this.matchedIndexes=new Set,this.matches=[],this.meta=[],this.query=e}},me=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}},dt=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:w.Prefix,qualityOffset:2},{searcherType:w.Substring,qualityOffset:1},{searcherType:w.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 o=[],i=[];for(let a=0,c=e.length;a<c;a++){this.idToIndex.set(t(e[a]),a);let l=r(e[a]);i.push(this.terms.length),this.terms.push(...l),o.push(...l.map(()=>a))}this.termIndexToEntityIndex=W.ToInt32Array(o),this.entityIndexToFirstTermIndex=W.ToInt32Array(i);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 ut(e),r=new xe(this.searcherTypes,e.searchers);for(let{searcherType:i,qualityOffset:s}of this.searchersAndQualityOffsets){if(e.topN==t.matches.length)break;r.has(i)&&this.addMatchesFromSearcher(t,r.spec(i),s)}let o=le.mergeMeta(t.meta);return new V(t.matches,e,o)}addMatchesFromSearcher(e,t,r){let o=Math.max(0,t.minQuality-r);if(o>1)return;let i=new me(e.query.string,o,t.type),s=this.stringSearcher.getMatches(i);this.addMatchesFromResult(e,s,r)}addMatchesFromResult(e,t,r){if(e.meta.push(t.meta),e.query.topN!==0)for(let o=0,i=t.matches.length;o<i;o++){let s=t.matches[o],a=this.termIndexToEntityIndex[s.index];if(!e.matchedIndexes.has(a)&&this.entities[a]!==null&&(e.matchedIndexes.add(a),e.matches.push(new lt(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 o=this.idToIndex.get(e);return o!==void 0&&(this.entities[o]=t,this.idToIndex.delete(e),this.idToIndex.set(r,o),!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)}},q=class{constructor(e,t){this.strings=void 0,this.meta=void 0,this.strings=e,this.meta=t}},ht=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,o=!1,i=!1;for(let s=0,a=e.length;s<a;s++){let c=this.getNormalizedCharacter(e[s]);c!==""&&(c===" "?o=!0:(o&&i&&(t[r++]=" "),t[r++]=c,i=!0,o=!1))}return i?t.join(""):""}getNormalizedCharacter(e){return e===" "||this.treatCharacterAsSpace(e)?" ":this.isSurrogate(e)||!this.allowCharacter(e)?"":e.toLowerCase()}isSurrogate(e){return!!He.isSurrogate(e)&&(this.numberOfSurrogateCharacters++,!0)}normalizeBulk(e){this.numberOfSurrogateCharacters=0;let t=e.map(o=>this.normalize(o)),r=new v;return r.add("numberOfSurrogateCharacters",this.numberOfSurrogateCharacters),new q(t,r)}},mt=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 q(t,new v)}},ft=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 v;for(let r=0,o=this.normalizers.length;r<o;r++){let i=this.normalizers[r].normalizeBulk(e);e=i.strings;for(let s of i.meta.allEntries)t.add(s[0],s[1])}return new q(e,t)}},pt=class{normalize(e){return e||""}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new q(t,new v)}},gt=class{constructor(e,t){this.normalizeVariationsAndInput=void 0,this.replacements=void 0,this.normalizeVariationsAndInput=t,this.replacements=[];for(let r of e){let o=new Map;for(let[i,s]of r)for(let a of s){let c=t(a);o.set(c,i)}this.replacements.push(o)}}normalize(e){e=this.normalizeVariationsAndInput(e);let t=new Array(e.length),r=0;for(let o=0,i=e.length;o<i;o++)for(let s of this.replacements){let a=s.get(e[o]);if(a!==void 0){t[r++]=a;break}t[r++]=e[o]}return t.join("")}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new q(t,new v)}},yt=class{static create(e){let t=new pt,r=new gt(e.replacements,s=>s.toLowerCase().normalize("NFKC")),o=new mt(s=>s.normalize("NFKD")),i=new ht(e.treatCharacterAsSpace,e.allowCharacter);return new ft([t,r,o,i])}},fe=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}},bt=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=[],o=[],i=0,s=null;for(let c=0,l=t.length;c<l;c++){let u=t[c].term;u!=s&&(r[i]=u,o[i]=c,i++),s=u}o[i++]=t.length,this.distinctMapping=W.ToInt32Array(o);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),o=0;return t.matches.forEach(i=>{let s=this.distinctMapping[i.index+1];for(let a=this.distinctMapping[i.index];a<s;a++)r[o++]=new fe(this.sortMapping[a],i.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)}},St=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 xe(this.searcherTypes,e.searchers);if(e.topN>200)return this.entitySearcher.getMatches(e);if(e.string.length<=3&&t.has(w.Prefix)&&t.minQuality(w.Prefix)<2.2){let r=new U(e.string,e.topN,[new ee(2.3)]),o=this.entitySearcher.getMatches(r);if(o.matches.length==e.topN)return new V(o.matches,e,o.meta)}if(e.string.length<=3&&!t.has(w.Prefix)&&t.has(w.Substring)&&t.minQuality(w.Substring)<1.2){let r=new U(e.string,e.topN,[new Z(1.3)]),o=this.entitySearcher.getMatches(r);if(o.matches.length==e.topN)return new V(o.matches,e,o.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)}},Ce=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=W.ToInt32Array(this.ids),this.frequencies=W.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()}},ce=class{constructor(){this.ngramToTermIds=void 0,this.ngramToTermIds=new Map}add(e,t,r){let o=this.ngramToTermIds.get(e);o||(o=new Ce,this.ngramToTermIds.set(e,o)),o.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 o=e.get(),i=new Ce;i.load(e),this.ngramToTermIds.set(o,i)}}},Tt=class{static ComputeJaccardCoefficient(e,t,r){return r/(e+t-r)}static ComputeOverlapMaxCoefficient(e,t,r){return r/Math.max(e,t)}},wt=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 ce,this.numberOfNgrams=new Int32Array(0),this.commonNgramCounts=new Int32Array(0)}index(e){let t=performance.now();this.invertedIndex=new ce,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[d,h]of u)this.invertedIndex.add(d,s,h)}this.invertedIndex.seal();let o=Math.round(performance.now()-t),i=new v;return i.add("numberOfInvalidTerms",r),i.add("indexingDurationFuzzySearcher",o),i}isValidTerm(e){return e!=null&&e.trim()!==""}getMatches(e){if(this.invertedIndex.size===0)return new P([],e,new v);let t=this.ngramComputer.computeNgrams(e.string),r=this.getNgramsToFrequency(t),o=t.length;this.computeCommonNgramCounts(r);let i=this.getMatchesFromCommonNgrams(o,e.minQuality);return new P(i,e,new v)}computeCommonNgramCounts(e){this.commonNgramCounts.fill(0);for(let[t,r]of e){let o=this.invertedIndex.getIds(t);if(o!=null)for(let i=0,s=o.length;i<s;i++)this.commonNgramCounts[o.ids[i]]+=Math.min(r,o.frequencies[i])}}getNgramsToFrequency(e){let t=new Map;for(let r=0,o=e.length;r<o;r++){let i=e[r],s=t.get(i);t.set(i,s!==void 0?s+1:1)}return t}getMatchesFromCommonNgrams(e,t){let r=[];for(let o=0,i=this.numberOfNgrams.length;o<i;o++){let s=Tt.ComputeOverlapMaxCoefficient(e,this.numberOfNgrams[o],this.commonNgramCounts[o]);s>t&&r.push(new fe(o,s))}return r}save(e){this.invertedIndex.save(e),e.add(this.numberOfNgrams)}load(e){this.invertedIndex=new ce,this.invertedIndex.load(e),this.numberOfNgrams=e.get(),this.commonNgramCounts=new Int32Array(this.numberOfNgrams.length)}},vt=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]=ke.getHashCode(e[t]);return this.stringSearcher.index(e)}getMatches(e){let t=ke.getHashCode(e.string),r=this.stringSearcher.getMatches(e),o=r.matches.map(i=>this.penalizeMatch(i,t)).filter(i=>i.quality>=e.minQuality);return new P(o,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)}},Et=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,o=this.maximumNumberOfNgrams(e);r<o;r++){let i=this.transformNgram(e.substring(r,r+this.ngramN));i&&t.push(i)}return t}maximumNumberOfNgrams(e){return Math.max(e.length-this.ngramN+1,e.length>0?1:0)}},Lt=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(o=>this.normalize(o)),r=new v;return new q(t,r)}},Ae=class{};Ae.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 Be=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([Ae.Value],t=>e.has(t),t=>He.isAlphanumeric(t))}},Ie=class{constructor(e,t,r="normalizationDuration"){this.stringSearcher=void 0,this.normalizer=void 0,this.normalizationDurationMetaKey=void 0,this.stringSearcher=e,this.normalizer=t,this.normalizationDurationMetaKey=r}index(e){let t=performance.now(),r=this.normalizer.normalizeBulk(e),o=Math.round(performance.now()-t),i=this.stringSearcher.index(r.strings);i.add(this.normalizationDurationMetaKey,o);for(let s of r.meta.allEntries)i.add(s[0],s[1]);return i}getMatches(e){let t=new me(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)}},Mt=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 v);let t=this.modifyQueryString(e.string),r=new me(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)}},kt=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 le.mergeMeta(t)}getMatches(e){if(!e.searcherType)throw new Error("SearcherSwitch requires a searcher type.");switch(e.searcherType){case w.Prefix:if(!this.prefixSearcher)throw new Error("No prefix searcher has been indexed.");return this.prefixSearcher.getMatches(e);case w.Substring:if(!this.substringSearcher)throw new Error("No substring searcher has been indexed.");return this.substringSearcher.getMatches(e);case w.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"})(ue||(ue={}));var Ht=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 ue.QualityAndIndex:return t;case ue.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)}},xt=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)}},pe=class{static compareOrdinal(e,t,r,o,i){let s=Math.min(t+i,e.length),a=Math.min(o+i,r.length),c=t,l=o;for(;c<s&&l<a;){let h=e.charCodeAt(c),p=r.charCodeAt(l);if(h<p)return-1;if(h>p)return 1;c++,l++}let u=s-t,d=a-o;return u===d?0:u<d?-1:1}},Ct=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 o=new At(e.head,-this.isa[e.head+e.length]);t.push(o)}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 pe.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])}},At=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}},Bt=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=Ct.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 o=Math.round(performance.now()-t),i=new v;return i.add("indexingDurationSuffixArraySearcher",o),i}getMatches(e,t){if(!e.string)return new P([],e,new v);let[r,o]=this.GetPositionsInSuffixArray(e.string),i=new Int32Array(o-r),s=new Set,a=0;for(let u=r;u<o;u++){let d=this.indexToTermIndex[this.suffixArray[u]];s.has(d)||(s.add(d),i[a++]=d)}let c=[];t=t??e.string.length;let l=0;for(let u=0;u<a;u++)l=this.computeQuality(t,this.termLengths[i[u]]),l>e.minQuality&&c.push(new fe(i[u],l));return new P(c,e,new v)}computeQuality(e,t){return e/t}GetPositionsInSuffixArray(e){let t=0,r=this.suffixArray.length,o=0;for(;t<r;)o=Math.floor((t+r)/2),pe.compareOrdinal(e,0,this.str,this.suffixArray[o],e.length)>0?t=o+1:r=o;let i=t;for(r=this.suffixArray.length;t<r;)o=Math.floor((t+r)/2),pe.compareOrdinal(e,0,this.str,this.suffixArray[o],e.length)==0?t=o+1:r=o;return[i,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()}},Re=class{static createSearcher(e){let t=this.createDefaultNormalizer(e),r=this.tryCreateFuzzySearcher(e),o=this.tryCreateSubstringSearcher(e),i=this.tryCreatePrefixSearcher(e,o),s=new kt(i,o,r);s=new bt(s),s=new xt(s),s=new Ie(s,t,"normalizationDurationDefault");let a=new dt(s,e.searcherTypes);return a=new St(a,e.searcherTypes),a=new Ht(e.sortOrder,a),a}static createDefaultNormalizer(e){let t=new Set;e.fuzzySearchConfig&&(e.fuzzySearchConfig.paddingLeft.split("").forEach(o=>t.add(o)),e.fuzzySearchConfig.paddingRight.split("").forEach(o=>t.add(o)),e.fuzzySearchConfig.paddingMiddle.split("").forEach(o=>t.add(o))),e.substringSearchConfig&&e.substringSearchConfig.suffixArraySeparator.split("").forEach(o=>t.add(o));let r=new Be(e.normalizerConfig.replacements,e.normalizerConfig.treatCharacterAsSpace,o=>e.normalizerConfig.allowCharacter(o)&&!t.has(o));return yt.create(r)}static tryCreateFuzzySearcher(e){if(!e.searcherTypes.includes(w.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 Et(e.ngramN,e.transformNgram),r=new Lt(e.paddingLeft,e.paddingRight,e.paddingMiddle),o=new wt(t);return o=new vt(o,e.inequalityPenalty),o=new Ie(o,r,"normalizationDurationNgrams"),o}static tryCreateSubstringSearcher(e){if(!e.searcherTypes.includes(w.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 Bt(e.suffixArraySeparator)}static tryCreatePrefixSearcher(e,t){if(!e.searcherTypes.includes(w.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 Mt(t)}},It=class n{constructor(e,t,r,o,i,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=o,this.transformNgram=i,this.inequalityPenalty=s}static createDefaultConfig(){return new n("$$","!","!$$",3,e=>e.endsWith("$")?null:e.indexOf("$")===-1?e.split("").sort().join(""):e,.05)}};var Pt=class n{constructor(e){this.suffixArraySeparator=void 0,this.suffixArraySeparator=e}static createDefaultConfig(){return new n("$")}},Rt=class n{constructor(e,t,r,o,i,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=o,this.fuzzySearchConfig=i,this.substringSearchConfig=s}static createDefaultConfig(){let e=[w.Fuzzy,w.Substring,w.Prefix],t=ue.QualityAndMatchedString,r=Be.createDefaultConfig(),o=It.createDefaultConfig(),i=Pt.createDefaultConfig();return new n(e,150,t,r,o,i)}},De=class{static createSearcher(e){let t=Re.createSearcher(e),r=Re.createSearcher(e),o=new at(e.maxQueryLength,t,r);return o=new ct(o),o}static createDefaultSearcher(){let e=Rt.createDefaultConfig();return this.createSearcher(e)}};function te(n,e){if(n.length===0)return null;let t=[...n].sort((r,o)=>r.markerViewportHalfOpen1Based.lo-o.markerViewportHalfOpen1Based.lo);for(let r of t){let{lo:o,hiExclusive:i}=r.markerViewportHalfOpen1Based;if(o<=e&&e<i)return r}return null}function Dt(n,e){if(n.length===0)return!1;let t=1/0;for(let r of n)t=Math.min(t,r.markerViewportHalfOpen1Based.lo);return e<t}function Ft(n,e){if(n.length===0)return null;let t=[...n].sort((i,s)=>i.commentrayLine-s.commentrayLine),r=t[0];if(r===void 0)return null;let o=r;for(let i of t)i.commentrayLine<=e&&(o=i);return o}function Nt(n,e,t,r,o){let i=Math.max(0,e-t),s=Math.max(0,r-o);return i<=0?0:Math.min(1,Math.max(0,n/i))*s}function N(n,e,t,r=5){let o=e+r,i=e+t-r;return n<o?{y:o-e,clipped:"above"}:n>i?{y:i-e,clipped:"below"}:{y:n-e,clipped:"none"}}function uo(n,e,t,r,o={}){let{tension:i=.38,clipStart:s="none",clipEnd:a="none"}=o,l=Math.min(.66,i+.24),u=s==="none"?i:l,d=a==="none"?i:l,h=t-n;return[{x:n,y:e},{x:n+h*u,y:e},{x:t-h*d,y:r},{x:t,y:r}]}function Ot(n,e,t,r){return`M ${G(n.x)} ${G(n.y)} C ${G(e.x)} ${G(e.y)} ${G(t.x)} ${G(t.y)} ${G(r.x)} ${G(r.y)}`}function ho(n,e,t,r,o){let i=ne(n,e,o),s=ne(e,t,o),a=ne(t,r,o),c=ne(i,s,o),l=ne(s,a,o),u=ne(c,l,o);return[[n,i,c,u],[u,l,a,r]]}function ne(n,e,t){return{x:(1-t)*n.x+t*e.x,y:(1-t)*n.y+t*e.y}}function ge(n,e,t,r,o={}){let{tension:i=.38,clipStart:s="none",clipEnd:a="none",splitT:c=.66}=o,l=uo(n,e,t,r,{tension:i,clipStart:s,clipEnd:a}),[u,d,h,p]=l;if(!(s!=="none"||a!=="none"))return{solid:Ot(u,d,h,p)};let[f,g]=ho(u,d,h,p,c),[S,b,y,x]=f,[C,E,H,I]=g;return{solid:Ot(S,b,y,x),dotted:Ot(C,E,H,I)}}function G(n){return n.toFixed(2)}function Fe(n){return[...n].sort((e,t)=>e.sourceStart-t.sourceStart)}function Ln(n){let e=new Map;for(let t of Fe(n))e.has(t.id)||e.set(t.id,t);return Fe([...e.values()])}function Mn(n){return[...n].sort((e,t)=>e.commentrayLine!==t.commentrayLine?e.commentrayLine-t.commentrayLine:e.sourceStart-t.sourceStart)}function kn(n,e){let t=Mn([...n]),r=t.findIndex(o=>o.id===e.id);if(!(r<0))return t[r+1]}function Hn(n,e){return n.length===0?null:te(n,e)?.id??null}function xn(n,e){if(n.length===0)return null;let t=Mn([...n]),r=t[0];if(r===void 0)return null;let o=r;for(let i of t)i.commentrayLine<=e&&(o=i);return o.id}function zt(n){return Math.max(0,n-1)}var $t='.commentray-page-break[data-commentray-page-break="true"]';function Ne(n,e){return(n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)!==0}function Cn(n,e,t){return Array.from(n.querySelectorAll($t)).filter(r=>Ne(e,r)&&(t===null||Ne(r,t)))}var En=.5;function mo(n){let e=n.closest($t);return!!(e&&!n.isSameNode(e))}function _t(n,e,t){let r=e.getBoundingClientRect().top+2;for(let o of Array.from(n.querySelectorAll("*"))){if(!(o instanceof HTMLElement)||t!==null&&(o===t||!Ne(o,t))||!Ne(e,o)||mo(o)||o.matches($t))continue;let i=o.getBoundingClientRect();i.width<En||i.height<En||(r=Math.max(r,i.bottom))}return r}function Oe(n,e,t){let r=Cn(n,e,t),o=e.getBoundingClientRect().top+2,i=e;for(let s of r)o=Math.max(o,_t(n,i,s)),i=s;return t?o=Math.max(o,_t(n,i,t)):o=Math.max(o,_t(n,i,null)),o}function An(n,e,t){let r=t.getBoundingClientRect().top-3,o=e.getBoundingClientRect().top+4,s=Cn(n,e,t)[0];if(s!==void 0){let c=Oe(n,e,s),l=s.getBoundingClientRect().top-2;return Math.min(r,l,Math.max(o,c))}let a=Oe(n,e,t);return Math.min(r,Math.max(o,a))}function Bn(n,e){if(n.length===0)return null;let t=null;for(let{line0:r,top:o}of n)o<=e+1+.001&&(t=t===null?r:Math.max(t,r));return t}function R(n){let e=n.trim();if(e==="")return"";try{let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return new TextDecoder("utf-8",{fatal:!1}).decode(r)}catch{return""}}function In(n,e){function t(r){let o=n.getAttribute(r);return o!==null&&o.trim()!==""?o:e.getAttribute(r)?.trim()??""}return{rawCodeB64:t("data-raw-code-b64"),rawMdB64:t("data-raw-md-b64")}}function _e(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Pn(n,e){let t=e.map(r=>r.trim()).filter(Boolean);if(t.length===0)return _e(n);try{let r=t.map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),o=new RegExp(`(${r.join("|")})`,"gi");return n.split(o).map((s,a)=>a%2===1?`<mark class="search-hit">${_e(s)}</mark>`:_e(s)).join("")}catch{return _e(n)}}function ze(n,e){let t=e.map(c=>c.trim()).filter(Boolean);if(t.length===0)return[];let r=n.toLowerCase(),o=t.map(c=>c.toLowerCase()),i=[],s=0,a=0;for(;s<n.length&&a<400;){let c=s,l=-1,u=!0;for(let d of o){if(d.length===0)continue;let h=r.indexOf(d,c);if(h<0){u=!1;break}l<0&&(l=h),c=h+d.length}if(!u||l<0)break;i.push({start:l,end:c}),a++,s=l+1}return i}function Rn(n,e){let t=Math.max(0,Math.min(e,n.length)),r=0;for(let o=0;o<t;o++)n[o]===`
2
- `&&r++;return r}function Dn(n,e){let t=n.split(`
3
- `);return e<0||e>=t.length?"":t[e]??""}function ye(n){return n.trim().split(/\s+/).filter(Boolean)}function Fn(n,e){let t=ye(e);return t.length===0?[...n]:n.filter(r=>{let o=r.sourcePath.replace(/\\/g,"/");return ze(o,t).length>0})}function Nn(n){let e=new Set,t=new Set,r=[],o=0;for(let i of n){let s=i.sourcePath.trim(),a=i.commentrayPath.trim();if(s.length>0){let c=`${s}\0${a}`;e.has(c)||(e.add(c),r.push({kind:"path",line:o++,text:s,spPath:i.sourcePath,crPath:i.commentrayPath}))}a.length>0&&!t.has(a)&&(t.add(a),r.push({kind:"path",line:o++,text:a,spPath:i.sourcePath,crPath:i.commentrayPath}))}return r}var fo=80;function On(n,e=fo){let t=new Map;for(let i of n){let s=i.sourcePath.trim();if(s.length===0)continue;let a=t.get(s),c={sourcePath:i.sourcePath.trim(),commentrayPath:i.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((i,s)=>i.sourcePath.localeCompare(s.sourcePath)).slice(0,e),totalUnique:r}}function k(n){return n.trim().replaceAll("\\","/").replace(/^\.\//,"")}function po(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 qt=/^(?:\.\/|\/)?browse\/(.+)\/index\.html$/i,Gt=/^(?:\.\/|\/)?browse\/(.+\.html)$/i;function go(n){return qt.test(n)}function yo(n){return Gt.test(n)&&!n.toLowerCase().endsWith("/index.html")}function $e(n){let e=n.trim();return go(e)||yo(e)}function Y(n,e,t){let r=n.trim();if(r.startsWith("/"))return`${t}${r}`;let o=po(e),i=qt.exec(r);if(i?.[1]){let a=i[1],c=o==="/"?`/browse/${a}/index.html`:`${o}/browse/${a}/index.html`;return`${t}${c}`}let s=Gt.exec(r);if(s?.[1]&&!r.toLowerCase().endsWith("/index.html")){let a=o==="/"?`/browse/${s[1]}`:`${o}/browse/${s[1]}`;return`${t}${a}`}return new URL(r,`${t}${e}`).href}function Wt(n,e,t){let r=n.trim();if(r.length===0)return"";let o=qt.exec(r);if(o?.[1])return`./browse/${o[1]}/index.html`;let i=Gt.exec(r);return i?.[1]&&!r.toLowerCase().endsWith("/index.html")?`./browse/${i[1]}`:Y(r,e,t)}function Vt(n,e,t){let r=k(e),o=k(t);if(r.length>0){let i=n.find(s=>k(s.commentrayPath)===r);if(i)return i}if(o.length>0){let i=n.find(s=>k(s.sourcePath)===o);if(i)return i}}function Ut(n,e,t){return k(n.sourcePath)===k(e)&&k(n.commentrayPath)===k(t)}var Qt="commentray.codeCommentrayStatic.colorTheme",Yt=["system","light","dark"];function _n(n){let e=Yt.indexOf(n),t=(e>=0?e+1:0)%Yt.length;return Yt[t]??"system"}function qe(n){return n==="light"||n==="dark"||n==="system"?n:"system"}function bo(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 jt(n){let e=globalThis.document?.documentElement;e&&(e.dataset.commentrayTheme=n,bo(n))}function zn(n){let e=n.eps??1.5,{driverDelta:t,partnerBefore:r,partnerAfter:o}=n;return Math.abs(t)<e?!1:t>e&&o<r-e||t<-e&&o>r+e}var So=["block-aware-proportional","block-snap-only","filler-blocks"],Kt="block-aware-proportional";function $n(n){if(n==null)return Kt;let e=n.trim();return e.length===0?Kt:So.includes(e)?e:Kt}function Q(n){return Math.max(12,Math.min(48,n*.18))}var j=12,Xt=8;function Ge(n,e,t){return Math.max(e,Math.min(t,n))}function qn(n,e){let t=e.getBoundingClientRect(),r=globalThis.innerWidth,o=globalThis.innerHeight,i=n.getBoundingClientRect(),s=i.width>0?i.width:340,a=i.height>0?i.height:160,c=8,l=t.bottom+12+a<=o-c,u=l?Math.max(c,t.bottom+12):Math.max(c,t.top-a-12),d=Ge(t.left,c,r-s-c);n.style.top=`${String(Math.round(u))}px`,n.style.left=`${String(Math.round(d))}px`,n.dataset.side=l?"below":"above";let h=Ge(t.left+t.width/2-d-8,10,s-22);n.style.setProperty("--pointer-left",`${String(Math.round(h))}px`)}function Gn(n,e,t){if(e.replaceChildren(),t.length===0)return;let r=n.getBoundingClientRect(),o=r.left+r.width/2,i=r.top+r.height/2,s=12,a=8,c=12,l=n.dataset.side,u=Number.parseFloat(n.style.getPropertyValue("--pointer-left")),d=Number.isFinite(u)?r.left+u+8:o,h=l==="below"?r.top-a:l==="above"?r.bottom+a:i;for(let[p,m]of t.entries()){let f=m.getBoundingClientRect(),g=f.left+f.width/2,S=f.top+f.height/2,b=g-o,y=S-i,x=Math.abs(b)>=Math.abs(y),C=p-(t.length-1)/2,E,H;t.length===1&&(l==="below"||l==="above")?(E=d,H=h):x?(E=b>=0?r.right+a:r.left-a,H=Ge(S+C*c,r.top+s,r.bottom-s)):(H=y>=0?r.bottom+a:r.top-a,E=Ge(g+C*c,r.left+s,r.right-s));let I=g-E,X=S-H,J=Math.hypot(I,X);if(!Number.isFinite(J)||J<12)continue;let F=document.createElement("span");F.className="commentray-wide-intro-arrow",F.style.left=`${String(Math.round(E))}px`,F.style.top=`${String(Math.round(H))}px`,F.style.width=`${String(Math.round(J))}px`,F.style.setProperty("--wide-intro-arrow-angle",`${String(Math.atan2(X,I))}rad`);let ae=document.createElement("span");ae.className="commentray-wide-intro-arrow-head",F.appendChild(ae),e.appendChild(F)}}function Jt(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",o=t==="#shell"?r:t;return[{targetSelectors:e?[o]:["#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?[o]:["#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 i=document.getElementById("source-markdown-pane-flip");i instanceof HTMLButtonElement&&i.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 To(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]:[],o=[],i=new Set;for(let s of r){let a=document.querySelector(s);!(a instanceof HTMLElement)||i.has(a)||(i.add(a),o.push(a))}return o}function wo(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 We(n,e){return To(n,e).filter(t=>wo(t))}function Wn(){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 Vn(){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 V=class{static ToInt32Array(e){let t=new Int32Array(e.length);for(let r=0,o=e.length;r<o;r++)t[r]=e[r];return t}},Ce=class{static getHashCode(e){let t=5381,r=t;for(let o=0,i=e.length;o<i&&e[o]!="\0"&&(t=(t<<5)+t^e.charCodeAt(o),o!==i-1&&e[o+1]!=="\0");o+=2)r=(r<<5)+r^e.charCodeAt(o+1);return t+1566083941*r|0}},E=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)}}},de=class{static mergeMeta(e){if(e.length===0)return new E;if(e.length===1)return e[0];let t=new Map;for(let o of e)for(let[i,s]of o.allEntries){let a=t.get(i);a===void 0?t.set(i,[s]):a.push(s)}let r=new Map;for(let[o,i]of t)if(i.length!==1){if(i.every(s=>typeof s=="number")){let s=i.reduce((a,c)=>a+c,0);r.set(o,s);continue}for(let s=0;s<i.length;s++)r.set(`${o}_${s}`,i[s])}else r.set(o,i[0]);return new E(r)}},Ae=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}},Be=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)}},U=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}},T,me;(function(n){n.Fuzzy="fuzzy",n.Substring="substring",n.Prefix="prefix"})(T||(T={}));var he=class{constructor(e,t){this.type=void 0,this.minQuality=void 0,this.type=e,this.minQuality=Math.max(0,t)}},fe=class extends he{constructor(e){super(T.Fuzzy,e)}},te=class extends he{constructor(e){super(T.Substring,e)}},ne=class extends he{constructor(e){super(T.Prefix,e)}},Y=class{constructor(e,t=10,r=[new fe(.3),new te(0),new ne(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}},lt=class{constructor(e,t){this.removedEntities=void 0,this.meta=void 0,this.removedEntities=e,this.meta=t}},ut=class{static mergeResults(e,t){let r=e.query,o=this.mergeMatches(e.matches,t.matches,r.topN),i=de.mergeMeta([e.meta,t.meta]);return new U(o,r,i)}static mergeMatches(e,t,r){if(t.length===0)return e;if(e.length===0)return t;let o=[...e,...t];return o.sort((i,s)=>i.quality>s.quality?-1:i.quality<s.quality?1:0),o.length<=r?o:o.slice(0,r)}},dt=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 Y(e.string.substring(0,this.maxQueryLength),e.topN,e.searchers)),ut.mergeResults(this.mainSearcher.getMatches(e),this.secondarySearcher.getMatches(e))):new U([],e,new E)}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 o=0,i=e.length;o<i;o++)(this.mainSearcher.removeEntity(e[o])||this.secondarySearcher.removeEntity(e[o]))&&t.push(e[o]);let r=new E;return new lt(t,r)}upsertEntities(e,t,r){let o=[],i=[];for(let s=0,a=e.length;s<a;s++){let c=e[s],l=t(c);this.tryUpdate(c,l,r)||(o.push(l),i.push(c))}return this.removeEntities(o),i.length>0?this.reindexSecondarySearcher(i,t,r):new E}reindexSecondarySearcher(e,t,r){let o=this.secondarySearcher.getEntities().concat(e);return this.secondarySearcher.indexEntities(o,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,o){let i=o.tryGetTerms(t);if(i===null)return!1;if(this.termsAreEqual(i,r(e))){if(!o.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,o)=>r===t[o])}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)}},mt=class{constructor(e){this.dynamicSearcher=void 0,this.dynamicSearcher=e}removeEntities(e){let t=performance.now(),r=this.dynamicSearcher.removeEntities(e),o=Math.round(performance.now()-t);return r.meta.add("removalDuration",o),r}upsertEntities(e,t,r){let o=performance.now(),i=this.dynamicSearcher.upsertEntities(e,t,r),s=Math.round(performance.now()-o);return i.add("upsertDuration",s),i}indexEntities(e,t,r){let o=performance.now(),i=this.dynamicSearcher.indexEntities(e,t,r),s=Math.round(performance.now()-o);return i.add("indexingDurationTotal",s),i}getMatches(e){let t=performance.now(),r=this.dynamicSearcher.getMatches(e),o=Math.round(performance.now()-t);return r.meta.add("queryDuration",o),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)}},ht=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}},ft=class{constructor(e){this.query=void 0,this.matchedIndexes=new Set,this.matches=[],this.meta=[],this.query=e}},pe=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}},pt=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:T.Prefix,qualityOffset:2},{searcherType:T.Substring,qualityOffset:1},{searcherType:T.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 o=[],i=[];for(let a=0,c=e.length;a<c;a++){this.idToIndex.set(t(e[a]),a);let l=r(e[a]);i.push(this.terms.length),this.terms.push(...l),o.push(...l.map(()=>a))}this.termIndexToEntityIndex=V.ToInt32Array(o),this.entityIndexToFirstTermIndex=V.ToInt32Array(i);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 ft(e),r=new Be(this.searcherTypes,e.searchers);for(let{searcherType:i,qualityOffset:s}of this.searchersAndQualityOffsets){if(e.topN==t.matches.length)break;r.has(i)&&this.addMatchesFromSearcher(t,r.spec(i),s)}let o=de.mergeMeta(t.meta);return new U(t.matches,e,o)}addMatchesFromSearcher(e,t,r){let o=Math.max(0,t.minQuality-r);if(o>1)return;let i=new pe(e.query.string,o,t.type),s=this.stringSearcher.getMatches(i);this.addMatchesFromResult(e,s,r)}addMatchesFromResult(e,t,r){if(e.meta.push(t.meta),e.query.topN!==0)for(let o=0,i=t.matches.length;o<i;o++){let s=t.matches[o],a=this.termIndexToEntityIndex[s.index];if(!e.matchedIndexes.has(a)&&this.entities[a]!==null&&(e.matchedIndexes.add(a),e.matches.push(new ht(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 o=this.idToIndex.get(e);return o!==void 0&&(this.entities[o]=t,this.idToIndex.delete(e),this.idToIndex.set(r,o),!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)}},G=class{constructor(e,t){this.strings=void 0,this.meta=void 0,this.strings=e,this.meta=t}},gt=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,o=!1,i=!1;for(let s=0,a=e.length;s<a;s++){let c=this.getNormalizedCharacter(e[s]);c!==""&&(c===" "?o=!0:(o&&i&&(t[r++]=" "),t[r++]=c,i=!0,o=!1))}return i?t.join(""):""}getNormalizedCharacter(e){return e===" "||this.treatCharacterAsSpace(e)?" ":this.isSurrogate(e)||!this.allowCharacter(e)?"":e.toLowerCase()}isSurrogate(e){return!!Ae.isSurrogate(e)&&(this.numberOfSurrogateCharacters++,!0)}normalizeBulk(e){this.numberOfSurrogateCharacters=0;let t=e.map(o=>this.normalize(o)),r=new E;return r.add("numberOfSurrogateCharacters",this.numberOfSurrogateCharacters),new G(t,r)}},yt=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 G(t,new E)}},bt=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 E;for(let r=0,o=this.normalizers.length;r<o;r++){let i=this.normalizers[r].normalizeBulk(e);e=i.strings;for(let s of i.meta.allEntries)t.add(s[0],s[1])}return new G(e,t)}},St=class{normalize(e){return e||""}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new G(t,new E)}},Tt=class{constructor(e,t){this.normalizeVariationsAndInput=void 0,this.replacements=void 0,this.normalizeVariationsAndInput=t,this.replacements=[];for(let r of e){let o=new Map;for(let[i,s]of r)for(let a of s){let c=t(a);o.set(c,i)}this.replacements.push(o)}}normalize(e){e=this.normalizeVariationsAndInput(e);let t=new Array(e.length),r=0;for(let o=0,i=e.length;o<i;o++)for(let s of this.replacements){let a=s.get(e[o]);if(a!==void 0){t[r++]=a;break}t[r++]=e[o]}return t.join("")}normalizeBulk(e){let t=e.map(r=>this.normalize(r));return new G(t,new E)}},wt=class{static create(e){let t=new St,r=new Tt(e.replacements,s=>s.toLowerCase().normalize("NFKC")),o=new yt(s=>s.normalize("NFKD")),i=new gt(e.treatCharacterAsSpace,e.allowCharacter);return new bt([t,r,o,i])}},ge=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}},Et=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=[],o=[],i=0,s=null;for(let c=0,l=t.length;c<l;c++){let u=t[c].term;u!=s&&(r[i]=u,o[i]=c,i++),s=u}o[i++]=t.length,this.distinctMapping=V.ToInt32Array(o);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),o=0;return t.matches.forEach(i=>{let s=this.distinctMapping[i.index+1];for(let a=this.distinctMapping[i.index];a<s;a++)r[o++]=new ge(this.sortMapping[a],i.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)}},vt=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 Be(this.searcherTypes,e.searchers);if(e.topN>200)return this.entitySearcher.getMatches(e);if(e.string.length<=3&&t.has(T.Prefix)&&t.minQuality(T.Prefix)<2.2){let r=new Y(e.string,e.topN,[new ne(2.3)]),o=this.entitySearcher.getMatches(r);if(o.matches.length==e.topN)return new U(o.matches,e,o.meta)}if(e.string.length<=3&&!t.has(T.Prefix)&&t.has(T.Substring)&&t.minQuality(T.Substring)<1.2){let r=new Y(e.string,e.topN,[new te(1.3)]),o=this.entitySearcher.getMatches(r);if(o.matches.length==e.topN)return new U(o.matches,e,o.meta)}return this.entitySearcher.getMatches(e)}tryGetEntity(e){return this.entitySearcher.tryGetEntity(e)}getEntities(){return this.entitySearcher.getEntities()}tryGetTerms(e){return this.entitySearcher.tryGetTerms(e)}getTerms(){return this.entitySearcher.getTerms()}removeEntity(e){return this.entitySearcher.removeEntity(e)}replaceEntity(e,t,r){return this.entitySearcher.replaceEntity(e,t,r)}save(e){return this.entitySearcher.save(e)}load(e){return this.entitySearcher.load(e)}},Ie=class{constructor(){this.ids=void 0,this.frequencies=void 0,this.ids=[],this.frequencies=[]}addId(e,t){this.ids.push(e),this.frequencies.push(t)}seal(){this.ids=V.ToInt32Array(this.ids),this.frequencies=V.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()}},ue=class{constructor(){this.ngramToTermIds=void 0,this.ngramToTermIds=new Map}add(e,t,r){let o=this.ngramToTermIds.get(e);o||(o=new Ie,this.ngramToTermIds.set(e,o)),o.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 o=e.get(),i=new Ie;i.load(e),this.ngramToTermIds.set(o,i)}}},Mt=class{static ComputeJaccardCoefficient(e,t,r){return r/(e+t-r)}static ComputeOverlapMaxCoefficient(e,t,r){return r/Math.max(e,t)}},Lt=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 ue,this.numberOfNgrams=new Int32Array(0),this.commonNgramCounts=new Int32Array(0)}index(e){let t=performance.now();this.invertedIndex=new ue,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[d,m]of u)this.invertedIndex.add(d,s,m)}this.invertedIndex.seal();let o=Math.round(performance.now()-t),i=new E;return i.add("numberOfInvalidTerms",r),i.add("indexingDurationFuzzySearcher",o),i}isValidTerm(e){return e!=null&&e.trim()!==""}getMatches(e){if(this.invertedIndex.size===0)return new P([],e,new E);let t=this.ngramComputer.computeNgrams(e.string),r=this.getNgramsToFrequency(t),o=t.length;this.computeCommonNgramCounts(r);let i=this.getMatchesFromCommonNgrams(o,e.minQuality);return new P(i,e,new E)}computeCommonNgramCounts(e){this.commonNgramCounts.fill(0);for(let[t,r]of e){let o=this.invertedIndex.getIds(t);if(o!=null)for(let i=0,s=o.length;i<s;i++)this.commonNgramCounts[o.ids[i]]+=Math.min(r,o.frequencies[i])}}getNgramsToFrequency(e){let t=new Map;for(let r=0,o=e.length;r<o;r++){let i=e[r],s=t.get(i);t.set(i,s!==void 0?s+1:1)}return t}getMatchesFromCommonNgrams(e,t){let r=[];for(let o=0,i=this.numberOfNgrams.length;o<i;o++){let s=Mt.ComputeOverlapMaxCoefficient(e,this.numberOfNgrams[o],this.commonNgramCounts[o]);s>t&&r.push(new ge(o,s))}return r}save(e){this.invertedIndex.save(e),e.add(this.numberOfNgrams)}load(e){this.invertedIndex=new ue,this.invertedIndex.load(e),this.numberOfNgrams=e.get(),this.commonNgramCounts=new Int32Array(this.numberOfNgrams.length)}},kt=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]=Ce.getHashCode(e[t]);return this.stringSearcher.index(e)}getMatches(e){let t=Ce.getHashCode(e.string),r=this.stringSearcher.getMatches(e),o=r.matches.map(i=>this.penalizeMatch(i,t)).filter(i=>i.quality>=e.minQuality);return new P(o,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)}},Ht=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,o=this.maximumNumberOfNgrams(e);r<o;r++){let i=this.transformNgram(e.substring(r,r+this.ngramN));i&&t.push(i)}return t}maximumNumberOfNgrams(e){return Math.max(e.length-this.ngramN+1,e.length>0?1:0)}},xt=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(o=>this.normalize(o)),r=new E;return new G(t,r)}},Pe=class{};Pe.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 Re=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([Pe.Value],t=>e.has(t),t=>Ae.isAlphanumeric(t))}},De=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),o=Math.round(performance.now()-t),i=this.stringSearcher.index(r.strings);i.add(this.normalizationDurationMetaKey,o);for(let s of r.meta.allEntries)i.add(s[0],s[1]);return i}getMatches(e){let t=new pe(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)}},Ct=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 E);let t=this.modifyQueryString(e.string),r=new pe(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)}},At=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 de.mergeMeta(t)}getMatches(e){if(!e.searcherType)throw new Error("SearcherSwitch requires a searcher type.");switch(e.searcherType){case T.Prefix:if(!this.prefixSearcher)throw new Error("No prefix searcher has been indexed.");return this.prefixSearcher.getMatches(e);case T.Substring:if(!this.substringSearcher)throw new Error("No substring searcher has been indexed.");return this.substringSearcher.getMatches(e);case T.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"})(me||(me={}));var Bt=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 me.QualityAndIndex:return t;case me.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)}},ye=class{static compareOrdinal(e,t,r,o,i){let s=Math.min(t+i,e.length),a=Math.min(o+i,r.length),c=t,l=o;for(;c<s&&l<a;){let m=e.charCodeAt(c),h=r.charCodeAt(l);if(m<h)return-1;if(m>h)return 1;c++,l++}let u=s-t,d=a-o;return u===d?0:u<d?-1:1}},Pt=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 Fe(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 o=new Rt(e.head,-this.isa[e.head+e.length]);t.push(o)}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 Fe(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 ye.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])}},Rt=class{constructor(e,t){this.head=void 0,this.rank=void 0,this.head=e,this.rank=t}},Fe=class{constructor(e,t){this.head=void 0,this.length=void 0,this.head=e,this.length=t}},Dt=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=Pt.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 o=Math.round(performance.now()-t),i=new E;return i.add("indexingDurationSuffixArraySearcher",o),i}getMatches(e,t){if(!e.string)return new P([],e,new E);let[r,o]=this.GetPositionsInSuffixArray(e.string),i=new Int32Array(o-r),s=new Set,a=0;for(let u=r;u<o;u++){let d=this.indexToTermIndex[this.suffixArray[u]];s.has(d)||(s.add(d),i[a++]=d)}let c=[];t=t??e.string.length;let l=0;for(let u=0;u<a;u++)l=this.computeQuality(t,this.termLengths[i[u]]),l>e.minQuality&&c.push(new ge(i[u],l));return new P(c,e,new E)}computeQuality(e,t){return e/t}GetPositionsInSuffixArray(e){let t=0,r=this.suffixArray.length,o=0;for(;t<r;)o=Math.floor((t+r)/2),ye.compareOrdinal(e,0,this.str,this.suffixArray[o],e.length)>0?t=o+1:r=o;let i=t;for(r=this.suffixArray.length;t<r;)o=Math.floor((t+r)/2),ye.compareOrdinal(e,0,this.str,this.suffixArray[o],e.length)==0?t=o+1:r=o;return[i,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()}},Ne=class{static createSearcher(e){let t=this.createDefaultNormalizer(e),r=this.tryCreateFuzzySearcher(e),o=this.tryCreateSubstringSearcher(e),i=this.tryCreatePrefixSearcher(e,o),s=new At(i,o,r);s=new Et(s),s=new It(s),s=new De(s,t,"normalizationDurationDefault");let a=new pt(s,e.searcherTypes);return a=new vt(a,e.searcherTypes),a=new Bt(e.sortOrder,a),a}static createDefaultNormalizer(e){let t=new Set;e.fuzzySearchConfig&&(e.fuzzySearchConfig.paddingLeft.split("").forEach(o=>t.add(o)),e.fuzzySearchConfig.paddingRight.split("").forEach(o=>t.add(o)),e.fuzzySearchConfig.paddingMiddle.split("").forEach(o=>t.add(o))),e.substringSearchConfig&&e.substringSearchConfig.suffixArraySeparator.split("").forEach(o=>t.add(o));let r=new Re(e.normalizerConfig.replacements,e.normalizerConfig.treatCharacterAsSpace,o=>e.normalizerConfig.allowCharacter(o)&&!t.has(o));return wt.create(r)}static tryCreateFuzzySearcher(e){if(!e.searcherTypes.includes(T.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 Ht(e.ngramN,e.transformNgram),r=new xt(e.paddingLeft,e.paddingRight,e.paddingMiddle),o=new Lt(t);return o=new kt(o,e.inequalityPenalty),o=new De(o,r,"normalizationDurationNgrams"),o}static tryCreateSubstringSearcher(e){if(!e.searcherTypes.includes(T.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 Dt(e.suffixArraySeparator)}static tryCreatePrefixSearcher(e,t){if(!e.searcherTypes.includes(T.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 Ct(t)}},Ft=class n{constructor(e,t,r,o,i,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=o,this.transformNgram=i,this.inequalityPenalty=s}static createDefaultConfig(){return new n("$$","!","!$$",3,e=>e.endsWith("$")?null:e.indexOf("$")===-1?e.split("").sort().join(""):e,.05)}};var Nt=class n{constructor(e){this.suffixArraySeparator=void 0,this.suffixArraySeparator=e}static createDefaultConfig(){return new n("$")}},Ot=class n{constructor(e,t,r,o,i,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=o,this.fuzzySearchConfig=i,this.substringSearchConfig=s}static createDefaultConfig(){let e=[T.Fuzzy,T.Substring,T.Prefix],t=me.QualityAndMatchedString,r=Re.createDefaultConfig(),o=Ft.createDefaultConfig(),i=Nt.createDefaultConfig();return new n(e,150,t,r,o,i)}},Oe=class{static createSearcher(e){let t=Ne.createSearcher(e),r=Ne.createSearcher(e),o=new dt(e.maxQueryLength,t,r);return o=new mt(o),o}static createDefaultSearcher(){let e=Ot.createDefaultConfig();return this.createSearcher(e)}};function re(n,e){if(n.length===0)return null;let t=[...n].sort((r,o)=>r.markerViewportHalfOpen1Based.lo-o.markerViewportHalfOpen1Based.lo);for(let r of t){let{lo:o,hiExclusive:i}=r.markerViewportHalfOpen1Based;if(o<=e&&e<i)return r}return null}function _t(n,e){if(n.length===0)return!1;let t=1/0;for(let r of n)t=Math.min(t,r.markerViewportHalfOpen1Based.lo);return e<t}function zt(n,e){if(n.length===0)return null;let t=[...n].sort((i,s)=>i.commentrayLine-s.commentrayLine),r=t[0];if(r===void 0)return null;let o=r;for(let i of t)i.commentrayLine<=e&&(o=i);return o}function $t(n,e,t,r,o){let i=Math.max(0,e-t),s=Math.max(0,r-o);return i<=0?0:Math.min(1,Math.max(0,n/i))*s}function N(n,e,t,r=5){let o=e+r,i=e+t-r;return n<o?{y:o-e,clipped:"above"}:n>i?{y:i-e,clipped:"below"}:{y:n-e,clipped:"none"}}function So(n,e,t,r,o={}){let{tension:i=.38,clipStart:s="none",clipEnd:a="none"}=o,l=Math.min(.66,i+.24),u=s==="none"?i:l,d=a==="none"?i:l,m=t-n;return[{x:n,y:e},{x:n+m*u,y:e},{x:t-m*d,y:r},{x:t,y:r}]}function qt(n,e,t,r){return`M ${W(n.x)} ${W(n.y)} C ${W(e.x)} ${W(e.y)} ${W(t.x)} ${W(t.y)} ${W(r.x)} ${W(r.y)}`}function To(n,e,t,r,o){let i=oe(n,e,o),s=oe(e,t,o),a=oe(t,r,o),c=oe(i,s,o),l=oe(s,a,o),u=oe(c,l,o);return[[n,i,c,u],[u,l,a,r]]}function oe(n,e,t){return{x:(1-t)*n.x+t*e.x,y:(1-t)*n.y+t*e.y}}function be(n,e,t,r,o={}){let{tension:i=.38,clipStart:s="none",clipEnd:a="none",splitT:c=.66}=o,l=So(n,e,t,r,{tension:i,clipStart:s,clipEnd:a}),[u,d,m,h]=l;if(!(s!=="none"||a!=="none"))return{solid:qt(u,d,m,h)};let[p,g]=To(u,d,m,h,c),[w,b,y,x]=p,[C,v,H,I]=g;return{solid:qt(w,b,y,x),dotted:qt(C,v,H,I)}}function W(n){return n.toFixed(2)}function _e(n){return[...n].sort((e,t)=>e.sourceStart-t.sourceStart)}function xn(n){let e=new Map;for(let t of _e(n))e.has(t.id)||e.set(t.id,t);return _e([...e.values()])}function Cn(n){return[...n].sort((e,t)=>e.commentrayLine!==t.commentrayLine?e.commentrayLine-t.commentrayLine:e.sourceStart-t.sourceStart)}function An(n,e){let t=Cn([...n]),r=t.findIndex(o=>o.id===e.id);if(!(r<0))return t[r+1]}function Bn(n,e){return n.length===0?null:re(n,e)?.id??null}function In(n,e){if(n.length===0)return null;let t=Cn([...n]),r=t[0];if(r===void 0)return null;let o=r;for(let i of t)i.commentrayLine<=e&&(o=i);return o.id}function Wt(n){return Math.max(0,n-1)}var Vt='.commentray-page-break[data-commentray-page-break="true"]';function ze(n,e){return(n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING)!==0}function Pn(n,e,t){return Array.from(n.querySelectorAll(Vt)).filter(r=>ze(e,r)&&(t===null||ze(r,t)))}var Hn=.5;function wo(n){let e=n.closest(Vt);return!!(e&&!n.isSameNode(e))}function Gt(n,e,t){let r=e.getBoundingClientRect().top+2;for(let o of Array.from(n.querySelectorAll("*"))){if(!(o instanceof HTMLElement)||t!==null&&(o===t||!ze(o,t))||!ze(e,o)||wo(o)||o.matches(Vt))continue;let i=o.getBoundingClientRect();i.width<Hn||i.height<Hn||(r=Math.max(r,i.bottom))}return r}function $e(n,e,t){let r=Pn(n,e,t),o=e.getBoundingClientRect().top+2,i=e;for(let s of r)o=Math.max(o,Gt(n,i,s)),i=s;return t?o=Math.max(o,Gt(n,i,t)):o=Math.max(o,Gt(n,i,null)),o}function Rn(n,e,t){let r=t.getBoundingClientRect().top-3,o=e.getBoundingClientRect().top+4,s=Pn(n,e,t)[0];if(s!==void 0){let c=$e(n,e,s),l=s.getBoundingClientRect().top-2;return Math.min(r,l,Math.max(o,c))}let a=$e(n,e,t);return Math.min(r,Math.max(o,a))}function Dn(n,e){if(n.length===0)return null;let t=null;for(let{line0:r,top:o}of n)o<=e+1+.001&&(t=t===null?r:Math.max(t,r));return t}function R(n){let e=n.trim();if(e==="")return"";try{let t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return new TextDecoder("utf-8",{fatal:!1}).decode(r)}catch{return""}}function Fn(n,e){function t(r){let o=n.getAttribute(r);return o!==null&&o.trim()!==""?o:e.getAttribute(r)?.trim()??""}return{rawCodeB64:t("data-raw-code-b64"),rawMdB64:t("data-raw-md-b64")}}function qe(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Nn(n,e){let t=e.map(r=>r.trim()).filter(Boolean);if(t.length===0)return qe(n);try{let r=t.map(s=>s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),o=new RegExp(`(${r.join("|")})`,"gi");return n.split(o).map((s,a)=>a%2===1?`<mark class="search-hit">${qe(s)}</mark>`:qe(s)).join("")}catch{return qe(n)}}function Ge(n,e){let t=e.map(c=>c.trim()).filter(Boolean);if(t.length===0)return[];let r=n.toLowerCase(),o=t.map(c=>c.toLowerCase()),i=[],s=0,a=0;for(;s<n.length&&a<400;){let c=s,l=-1,u=!0;for(let d of o){if(d.length===0)continue;let m=r.indexOf(d,c);if(m<0){u=!1;break}l<0&&(l=m),c=m+d.length}if(!u||l<0)break;i.push({start:l,end:c}),a++,s=l+1}return i}function On(n,e){let t=Math.max(0,Math.min(e,n.length)),r=0;for(let o=0;o<t;o++)n[o]===`
2
+ `&&r++;return r}function _n(n,e){let t=n.split(`
3
+ `);return e<0||e>=t.length?"":t[e]??""}function Se(n){return n.trim().split(/\s+/).filter(Boolean)}function zn(n,e){let t=Se(e);return t.length===0?[...n]:n.filter(r=>{let o=r.sourcePath.replace(/\\/g,"/");return Ge(o,t).length>0})}function $n(n){let e=new Set,t=new Set,r=[],o=0;for(let i of n){let s=i.sourcePath.trim(),a=i.commentrayPath.trim();if(s.length>0){let c=`${s}\0${a}`;e.has(c)||(e.add(c),r.push({kind:"path",line:o++,text:s,spPath:i.sourcePath,crPath:i.commentrayPath}))}a.length>0&&!t.has(a)&&(t.add(a),r.push({kind:"path",line:o++,text:a,spPath:i.sourcePath,crPath:i.commentrayPath}))}return r}var Eo=80;function qn(n,e=Eo){let t=new Map;for(let i of n){let s=i.sourcePath.trim();if(s.length===0)continue;let a=t.get(s),c={sourcePath:i.sourcePath.trim(),commentrayPath:i.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((i,s)=>i.sourcePath.localeCompare(s.sourcePath)).slice(0,e),totalUnique:r}}function k(n){return n.trim().replaceAll("\\","/").replace(/^\.\//,"")}function vo(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 Ut=/^(?:\.\/|\/)?browse\/(.+)\/index\.html$/i,Yt=/^(?:\.\/|\/)?browse\/(.+\.html)$/i;function Mo(n){return Ut.test(n)}function Lo(n){return Yt.test(n)&&!n.toLowerCase().endsWith("/index.html")}function We(n){let e=n.trim();return Mo(e)||Lo(e)}function Q(n,e,t){let r=n.trim();if(r.startsWith("/"))return`${t}${r}`;let o=vo(e),i=Ut.exec(r);if(i?.[1]){let a=i[1],c=o==="/"?`/browse/${a}/index.html`:`${o}/browse/${a}/index.html`;return`${t}${c}`}let s=Yt.exec(r);if(s?.[1]&&!r.toLowerCase().endsWith("/index.html")){let a=o==="/"?`/browse/${s[1]}`:`${o}/browse/${s[1]}`;return`${t}${a}`}return new URL(r,`${t}${e}`).href}function Qt(n,e,t){let r=n.trim();if(r.length===0)return"";let o=Ut.exec(r);if(o?.[1])return`./browse/${o[1]}/index.html`;let i=Yt.exec(r);return i?.[1]&&!r.toLowerCase().endsWith("/index.html")?`./browse/${i[1]}`:Q(r,e,t)}function jt(n,e,t){let r=k(e),o=k(t);if(r.length>0){let i=n.find(s=>k(s.commentrayPath)===r);if(i)return i}if(o.length>0){let i=n.find(s=>k(s.sourcePath)===o);if(i)return i}}function Kt(n,e,t){return k(n.sourcePath)===k(e)&&k(n.commentrayPath)===k(t)}var Jt="commentray.codeCommentrayStatic.colorTheme",Xt=["system","light","dark"];function Gn(n){let e=Xt.indexOf(n),t=(e>=0?e+1:0)%Xt.length;return Xt[t]??"system"}function Ve(n){return n==="light"||n==="dark"||n==="system"?n:"system"}function ko(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 Zt(n){let e=globalThis.document?.documentElement;e&&(e.dataset.commentrayTheme=n,ko(n))}function Wn(n){let e=n.eps??1.5,{driverDelta:t,partnerBefore:r,partnerAfter:o}=n;return Math.abs(t)<e?!1:t>e&&o<r-e||t<-e&&o>r+e}var Ho=["block-aware-proportional","block-snap-only","filler-blocks"],en="block-aware-proportional";function Vn(n){if(n==null)return en;let e=n.trim();return e.length===0?en:Ho.includes(e)?e:en}function j(n){return Math.max(12,Math.min(48,n*.18))}var K=12,tn=8;function Ue(n,e,t){return Math.max(e,Math.min(t,n))}function Un(n,e){let t=e.getBoundingClientRect(),r=globalThis.innerWidth,o=globalThis.innerHeight,i=n.getBoundingClientRect(),s=i.width>0?i.width:340,a=i.height>0?i.height:160,c=8,l=t.bottom+12+a<=o-c,u=l?Math.max(c,t.bottom+12):Math.max(c,t.top-a-12),d=Ue(t.left,c,r-s-c);n.style.top=`${String(Math.round(u))}px`,n.style.left=`${String(Math.round(d))}px`,n.dataset.side=l?"below":"above";let m=Ue(t.left+t.width/2-d-8,10,s-22);n.style.setProperty("--pointer-left",`${String(Math.round(m))}px`)}function Yn(n,e,t){if(e.replaceChildren(),t.length===0)return;let r=n.getBoundingClientRect(),o=r.left+r.width/2,i=r.top+r.height/2,s=12,a=8,c=12,l=n.dataset.side,u=Number.parseFloat(n.style.getPropertyValue("--pointer-left")),d=Number.isFinite(u)?r.left+u+8:o,m=l==="below"?r.top-a:l==="above"?r.bottom+a:i;for(let[h,f]of t.entries()){let p=f.getBoundingClientRect(),g=p.left+p.width/2,w=p.top+p.height/2,b=g-o,y=w-i,x=Math.abs(b)>=Math.abs(y),C=h-(t.length-1)/2,v,H;t.length===1&&(l==="below"||l==="above")?(v=d,H=m):x?(v=b>=0?r.right+a:r.left-a,H=Ue(w+C*c,r.top+s,r.bottom-s)):(H=y>=0?r.bottom+a:r.top-a,v=Ue(g+C*c,r.left+s,r.right-s));let I=g-v,Z=w-H,ee=Math.hypot(I,Z);if(!Number.isFinite(ee)||ee<12)continue;let F=document.createElement("span");F.className="commentray-wide-intro-arrow",F.style.left=`${String(Math.round(v))}px`,F.style.top=`${String(Math.round(H))}px`,F.style.width=`${String(Math.round(ee))}px`,F.style.setProperty("--wide-intro-arrow-angle",`${String(Math.atan2(Z,I))}rad`);let le=document.createElement("span");le.className="commentray-wide-intro-arrow-head",F.appendChild(le),e.appendChild(F)}}function nn(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",o=t==="#shell"?r:t;return[{targetSelectors:e?[o]:["#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?[o]:["#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 i=document.getElementById("source-markdown-pane-flip");i instanceof HTMLButtonElement&&i.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 xo(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]:[],o=[],i=new Set;for(let s of r){let a=document.querySelector(s);!(a instanceof HTMLElement)||i.has(a)||(i.add(a),o.push(a))}return o}function Co(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 Ye(n,e){return xo(n,e).filter(t=>Co(t))}function Qn(){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 jn(){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,14 +13,14 @@
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"),o=e.querySelector(".commentray-wide-intro-step-action"),i=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)||!(o instanceof HTMLButtonElement)||!(i 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:o,progressEl:i,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 Un="commentray.codeCommentrayStatic.wideModeIntro.v1";function Yn(n){let e=n.isNarrowViewport()?"narrow":"wide";e!==n.viewportMode&&(n.viewportMode=e,n.steps=Jt(n.shell,e==="narrow"))}function Qn(n){let{bubble:e,arrowLayer:t}=n.elements;Yn(n);let r=We(n.steps,n.current),o=r[0];if(!o){e.dataset.side="none",e.style.top="12px",e.style.left="12px",t.replaceChildren();return}qn(e,o),Gn(e,t,r)}function vo(n){for(Yn(n);n.current<n.steps.length;){let e=n.steps[n.current];if(!e)break;let t=We(n.steps,n.current),r=typeof e.fallbackAction=="function";if(t.length>0||r)break;n.current++}}function Eo(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 Lo(n,e){let{titleEl:t,bodyEl:r,progressEl:o,backBtn:i,nextBtn:s}=n.elements;if(vo(n),n.current>=n.steps.length){e();return}let a=n.steps[n.current];if(!a)return;let c=We(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,Eo(n,a,c),o.textContent=`${String(n.current+1)} / ${String(n.steps.length)}`,i.disabled=n.current===0,s.textContent=n.current===n.steps.length-1?"Done":"Next",Qn(n)}function Zt(n,e,t){if(!t?.force&&D(localStorage,Un)==="1")return;Wn();let r=Vn();if(!r)return;let o={shell:n,steps:Jt(n,e()),viewportMode:e()?"narrow":"wide",current:0,highlighted:[],elements:r,isNarrowViewport:e},{bubble:i,arrowLayer:s,stepActionBtn:a,backBtn:c,nextBtn:l,skipBtn:u}=o.elements,d=()=>{for(let g of o.highlighted)g.classList.remove("commentray-wide-intro-target");o.highlighted=[],s.remove(),i.remove(),globalThis.removeEventListener("resize",m),globalThis.removeEventListener("scroll",h,!0),document.removeEventListener("keydown",f,!0),A(localStorage,Un,"1")},h=()=>{Qn(o)},p=()=>{Lo(o,d)},m=()=>{p()},f=g=>{g.key==="Escape"&&(g.preventDefault(),d())};c.addEventListener("click",()=>{o.current>0&&o.current--,p()}),a.addEventListener("click",()=>{let g=o.steps[o.current];!g||typeof g.fallbackAction!="function"||(g.fallbackAction(),p())}),l.addEventListener("click",()=>{if(o.current>=o.steps.length-1){d();return}o.current++,p()}),u.addEventListener("click",d),globalThis.addEventListener("resize",m),globalThis.addEventListener("scroll",h,!0),document.addEventListener("keydown",f,!0),p()}var Mo="__NON_SYNC_TAIL_SLACK__";function jn(n){return n.reduce((e,t)=>e+t.bufferAbove+t.height+t.bufferBelow,0)}function Kn(n,e){return n.map(t=>{let r=be(t.id)?e.get(t.id)??t.height:t.height;return{...t,bufferAbove:t.bufferAbove??0,bufferBelow:be(t.id)?r-t.height:t.bufferBelow??0,...t.syncRegionContinuationRows!==void 0?{syncRegionContinuationRows:[...t.syncRegionContinuationRows]}:{}}})}function be(n){return/^R\d+XX$/.test(n)}function Xn(n,e){let t=0;for(let o=0;o<e;o++){let i=n[o];i!==void 0&&(t+=i.bufferAbove+i.height+i.bufferBelow)}let r=n[e];return t+(r?.bufferAbove??0)}function Jn(n,e){return n.findIndex(t=>t.id===e)}function ko(n,e,t,r){let o=Xn(n,t),i=Xn(e,r);if(o===i)return!1;if(o>i){let d=o-i,h=n[t],p=h!==void 0?Math.min(d,h.bufferAbove):0,m=!1;p>0&&h!==void 0&&(h.bufferAbove-=p,m=!0);let f=d-p;if(f>0){let g=e[r];g!==void 0&&(g.bufferAbove+=f,m=!0)}return m}let s=i-o,a=e[r],c=a!==void 0?Math.min(s,a.bufferAbove):0,l=!1;c>0&&a!==void 0&&(a.bufferAbove-=c,l=!0);let u=s-c;if(u>0){let d=n[t];d!==void 0&&(d.bufferAbove+=u,l=!0)}return l}function Ho(n,e){let t=new Set;for(let i of n)be(i.id)&&t.add(i.id);let r=[];for(let i of t){let s=Jn(n,i),a=Jn(e,i);s>=0&&a>=0&&r.push({id:i,il:s,ir:a})}r.sort((i,s)=>i.il-s.il);let o=r.length+8;for(let i=0;i<o;i++){let s=!1;for(let{il:a,ir:c}of r)ko(n,e,a,c)&&(s=!0);if(!s)break}}function Zn(n){return{id:Mo,height:0,bufferAbove:0,bufferBelow:n}}function xo(n,e){let t=jn(n),r=jn(e),o=r-t;if(o>0&&n.length>0){er(n,e,o);return}let i=t-r;i>0&&e.length>0&&er(e,n,i)}function er(n,e,t){if(t<=0)return;let r=n.at(-1);if(r!==void 0&&!be(r.id)){n[n.length-1]={...r,bufferBelow:r.bufferBelow+t};return}n.push(Zn(t)),e.push(Zn(0))}function tr(n){return{...n,...n.syncRegionContinuationRows!==void 0?{syncRegionContinuationRows:[...n.syncRegionContinuationRows]}:{}}}function Co(n,e){let t=n.map(tr),r=e.map(tr);return Ho(t,r),xo(t,r),{left:t,right:r}}var Ve=class{synchronize(e,t){let r=[...e],o=[...t],i=new Map;for(let a of[...r,...o]){if(!be(a.id))continue;let c=i.get(a.id)??0;a.height>c&&i.set(a.id,a.height)}let s={left:Kn(r,i),right:Kn(o,i)};return Co(s.left,s.right)}};var Ao="tbody tr.stretch-row[data-commentray-stretch-sync-id]",en="commentray-mermaid-done",Bo=new Ve;function O(n){return!Number.isFinite(n)||n<=0?0:Math.max(0,Math.round(n))}var Ue=1;function Io(n){let e=n.querySelector(":scope .stretch-doc-inner");if(e===null||e.nodeType!==Ue)return 0;let t=e,r=t.scrollHeight;if(typeof r=="number"&&r>0)return O(r);let o=O(t.getBoundingClientRect().height);return o>0?o:0}function Po(n){let e=n.querySelector(":scope .stretch-code-stack");if(e===null||e.nodeType!==Ue)return 0;let t=e,r=t.scrollHeight;if(typeof r=="number"&&r>0)return O(r);let o=O(t.getBoundingClientRect().height);return o>0?o:0}function Ro(n){let e=n.querySelectorAll(".code-line");if(e.length===0)return 0;let t=1/0,r=-1/0;for(let i of e){let s=i.getBoundingClientRect();t=Math.min(t,s.top),r=Math.max(r,s.bottom)}if(r<=t||!Number.isFinite(t))return 0;let o=O(r-t);return o>0?o:0}function Do(n){let e=n.querySelector(".stretch-gap-mark");return e===null||e.nodeType!==Ue?0:O(e.getBoundingClientRect().height)}function nr(n){let e=Io(n);if(e>0)return e;let t=Po(n);if(t>0)return t;let r=n.querySelector(":scope > .stretch-cell-measure");if(r===null||r.nodeType!==Ue)return O(n.offsetHeight);let o=r,i=Ro(o);if(i>0)return i;let s=Do(r);if(s>0)return s;let a=O(o.getBoundingClientRect().height);return a>0?a:O(o.offsetHeight)}function Fo(n){return Array.from(n.querySelectorAll(Ao)).filter(e=>(e.dataset.commentrayStretchSyncId?.trim()??"").length>0)}function No(n,e){n.style.paddingBottom="",e.style.paddingBottom="",n.style.paddingTop="",e.style.paddingTop=""}function Oo(n,e,t,r){t.bufferAbove>0&&(n.style.paddingTop=`${String(t.bufferAbove)}px`),r.bufferAbove>0&&(e.style.paddingTop=`${String(r.bufferAbove)}px`),t.bufferBelow>0&&(n.style.paddingBottom=`${String(t.bufferBelow)}px`),r.bufferBelow>0&&(e.style.paddingBottom=`${String(r.bufferBelow)}px`)}function Ye(n){let e=n.querySelectorAll("td"),t=e[0],r=e[1];return t===void 0||r===void 0?null:{codeTd:t,docTd:r}}function _o(n){for(let e of n){let t=Ye(e);t!==null&&No(t.codeTd,t.docTd)}}function zo(n){let e=[],t=[];for(let r of n){let o=Ye(r);if(o===null)continue;let i=r.dataset.commentrayStretchSyncId?.trim()??"";e.push({id:i,height:nr(o.codeTd),bufferAbove:0,bufferBelow:0}),t.push({id:i,height:nr(o.docTd),bufferAbove:0,bufferBelow:0})}return e.length===0?null:{left:e,right:t}}function $o(n,e){let t=n.length;for(let r=0;r<t;r++){let o=n[r],i=o===void 0?null:Ye(o),s=e.left[r],a=e.right[r];i===null||s===void 0||a===void 0||Oo(i.codeTd,i.docTd,s,a)}}function qo(n){let e=n.at(-1);if(e===void 0||!e.classList.contains("stretch-row--gap"))return;let t=e===void 0?null:Ye(e);t!==null&&(t.codeTd.style.paddingBottom="",t.docTd.style.paddingBottom="")}function Go(n){let e=Fo(n);if(e.length===0)return;_o(e);let t=zo(e);if(t===null)return;let r=Bo.synchronize(t.left,t.right);$o(e,r),qo(e)}function rr(){globalThis.dispatchEvent(new CustomEvent(en))}function or(n){let e=0,t,r=()=>{e!==0&&globalThis.cancelAnimationFrame(e),e=globalThis.requestAnimationFrame(()=>{e=0,Go(n)})},o=()=>{t!==void 0&&globalThis.clearTimeout(t),t=globalThis.setTimeout(()=>{t=void 0,r()},32)},i=new ResizeObserver(()=>{r()});i.observe(n);let s=n.querySelector("tbody"),a=s!==null?new MutationObserver(()=>{o()}):null;a!==null&&s!==null&&a.observe(s,{childList:!0,subtree:!0});let c=()=>{r()};globalThis.addEventListener("resize",c,{passive:!0}),globalThis.visualViewport?.addEventListener("resize",c,{passive:!0});let l=()=>{r()};return globalThis.addEventListener(en,l),queueMicrotask(()=>{r(),globalThis.requestAnimationFrame(()=>{r(),globalThis.requestAnimationFrame(()=>{r()})}),globalThis.setTimeout(()=>{r()},120)}),{disconnect:()=>{e!==0&&globalThis.cancelAnimationFrame(e),t!==void 0&&globalThis.clearTimeout(t),i.disconnect(),a?.disconnect(),globalThis.removeEventListener("resize",c),globalThis.visualViewport?.removeEventListener("resize",c),globalThis.removeEventListener(en,l)}}}function Ee(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 o=r.getAttribute("href")?.trim()??"";$e(o)&&(r.href=Y(o,e,t))}}function se(n){if(typeof globalThis.location<"u"&&globalThis.location.protocol==="file:")return Promise.resolve();let t=Array.from(n.querySelectorAll("pre.mermaid")).filter(o=>{let i=o.closest(".commentray-mermaid");return i===null||i.querySelector("svg")===null});if(t.length===0)return Promise.resolve();let r=globalThis.commentrayMermaid;return r?r.run({nodes:t}).then(()=>{rr()}).catch(o=>{console.error("Commentray: mermaid.run failed",o)}):Promise.resolve()}function L(n,e,t){return Math.max(e,Math.min(t,n))}function Er(n,e,t){let r=e.getBoundingClientRect(),o=n.getBoundingClientRect();return n.scrollTop+(r.top-o.top)-n.clientTop-t}function Te(n,e){let t=Math.max(0,n.scrollHeight-n.clientHeight),r=L(e,0,t);Math.abs(n.scrollTop-r)<.25||(n.scrollTop=r)}function M(n){if(n.scrollHeight-n.clientHeight<=1)return!1;let t=getComputedStyle(n).overflowY;return t==="auto"||t==="scroll"||t==="overlay"}function $(){let n=document.scrollingElement;return n instanceof HTMLElement?n:document.documentElement}function _(n){return M(n)?n.scrollTop:$().scrollTop}function Wo(n,e){if(M(n)){let o=Math.max(0,n.scrollHeight-n.clientHeight);n.scrollTop=L(e,0,o);return}let t=$(),r=Math.max(0,t.scrollHeight-t.clientHeight);t.scrollTop=L(e,0,r)}function je(n){let{driverDelta:e,partnerBefore:t,partnerPane:r,axis:o}=n,i=_(r);zn({driverDelta:e,partnerBefore:t,partnerAfter:i})&&(fn()&&globalThis.console.warn("[commentray:scroll-sync] monotonic.revert",{t:Math.round(performance.now()),axis:o??"?",driverDelta:e,partnerBefore:t,partnerAfter:i}),Wo(r,t))}function re(n){let e=$(),t=Math.max(0,e.scrollHeight-e.clientHeight),r=L(n*t,0,t);Math.abs(e.scrollTop-r)<.25||(e.scrollTop=r)}function mn(n,e,t){if(M(n)){let c=Math.round(Er(n,e,t));Te(n,c);return}let r=$(),o=e.getBoundingClientRect(),i=globalThis.scrollY+o.top-t,s=Math.max(0,r.scrollHeight-r.clientHeight),a=L(i,0,s);Math.abs(r.scrollTop-a)<.25||(r.scrollTop=a)}function Lr(n,e,t){if(M(n)){let o=e.getBoundingClientRect(),i=n.getBoundingClientRect(),s=o.top-i.top-n.clientTop;return Math.abs(s-t)<=Xt}let r=e.getBoundingClientRect();return Math.abs(r.top-t)<=Xt}function Mr(n,e,t){let r=n.querySelector(`[data-commentray-line="${String(e)}"]`);return r instanceof HTMLElement?Lr(n,r,t):!1}function kr(n,e,t){let r=n.querySelector(`#${e}${String(t)}`);return r instanceof HTMLElement?r:jr(xi(e),t)}function Vo(n,e,t,r){let o=kr(n,e,t);return o?Lr(n,o,r):!1}function Hr(n,e,t,r,o){return Vo(n,e,t,j)?(T("doc\u2192code.plan",{reason:r,...o,src0:t,lineIdPrefix:e}),{k:"noop",skipProportionalFallbackOnFlip:!0}):null}var xr=6;function Uo(n,e,t){let r=te(n,e);if(r)return r;let o=t.sourceSticky.lockedId;if(o===null)return null;let i=n.find(l=>l.id===o);if(!i)return null;let{lo:s,hiExclusive:a}=i.markerViewportHalfOpen1Based,c=xr;return e>=s&&e<a+c?i:null}function Le(){let n=$(),e=Math.max(0,n.scrollHeight-n.clientHeight);return e>0?L(n.scrollTop/e,0,1):0}var Ke="commentrayDebugScroll";function Yo(){let n=new URLSearchParams(globalThis.location.search).get(Ke);return n==="1"||n==="true"||n===""}function ir(n){try{let e=n.getItem(Ke);return e==="1"||e==="true"}catch{return!1}}function Qo(){let n=globalThis.location.hash;return n===`#${Ke}`||n===`#${Ke}=1`}function jo(){let n=globalThis.location.hostname;return n==="localhost"||n==="127.0.0.1"||n==="0.0.0.0"||n==="::1"}function Cr(){try{return!!(Yo()||Qo()||ir(globalThis.sessionStorage)||ir(globalThis.localStorage))}catch{return!1}}var Ko=500,tn=!1,cn=-1/0;function sr(){cn=-1/0}function fn(){let n=performance.now();return n-cn<Ko||(cn=n,tn=Cr()),tn}typeof globalThis.addEventListener=="function"&&(globalThis.addEventListener("hashchange",sr),globalThis.addEventListener("storage",sr));function Xo(){let n=jo(),e=Cr();!n&&!e||globalThis.console.log("[commentray:scroll-sync] boot",{t:Math.round(performance.now()),href:globalThis.location.href,devHost:n,traceVerbose:e})}function T(n,e){fn()&&globalThis.console.log(`[commentray:scroll-sync] ${n}`,{t:Math.round(performance.now()),...e})}function oe(n){return n.k==="noop"?n.skipProportionalFallbackOnFlip===!0?"noop(skipFlipFallback)":"noop":n.k==="block"?`block(src0=${String(n.src0)})`:n.k==="mirrorW"?`mirrorW(ratio=${n.ratio.toFixed(4)})`:`mirrorI(docTop=${String(n.docTop)})`}function ie(n){return n.k==="noop"?"noop":n.k==="block"?`block(mdLine0=${String(n.mdLine0)})`:n.k==="mirrorW"?`mirrorW(ratio=${n.ratio.toFixed(4)})`:`mirrorI(codeTop=${String(n.codeTop)})`}function Xe(n,e,t,r="code-line-"){if(t.k==="noop")return;let o=globalThis.matchMedia(Me).matches;if(t.k==="block"){let a=kr(n,r,t.src0);a&&mn(n,a,j);return}if(t.k==="mirrorW"){if(M(n)){let a=Math.max(0,n.scrollHeight-n.clientHeight);Te(n,t.ratio*a),o&&re(t.ratio)}else re(t.ratio);return}let i=Nt(t.docTop,t.docSH,t.docCH,n.scrollHeight,n.clientHeight);if(M(n)){if(Te(n,i),o){let a=Math.max(1,n.scrollHeight-n.clientHeight);re(L(i/a,0,1))}return}let s=Math.max(1,n.scrollHeight-n.clientHeight);re(L(i/s,0,1))}function Je(n,e,t){if(t.k==="noop")return;if(t.k==="block"){let i=e.querySelector(`[data-commentray-line="${String(t.mdLine0)}"]`);i instanceof HTMLElement&&mn(e,i,j);return}if(t.k==="mirrorW"){if(M(e)){let i=Math.max(0,e.scrollHeight-e.clientHeight);Te(e,t.ratio*i)}else re(t.ratio);return}let r=Nt(t.codeTop,t.codeSH,t.codeCH,e.scrollHeight,e.clientHeight);if(M(e)){Te(e,r);return}let o=Math.max(1,e.scrollHeight-e.clientHeight);re(L(r/o,0,1))}function Ar(n,e){let t=e.map(r=>r.id).join("\0");t!==n.linksKey.current&&(n.sourceSticky.lockedId=null,n.commentraySticky.lockedId=null,n.linksKey.current=t)}function Jo(n,e,t,r,o,i){if(i===null)return null;let s=Ft(e,i),a=s!==null?s.markerViewportHalfOpen1Based.lo-1:null;if(s!==null&&(t.commentraySticky.lockedId=s.id),a===null)return null;let c=Hr(n,r,a,"block-code-anchor-already-aligned-noop",{mdLine0:i,blockId:s?.id??null});if(c)return c;let l={k:"block",src0:a,winRatio:o};return T("doc\u2192code.plan",{reason:"block-from-md-probe",plan:oe(l),mdLine0:i,blockId:s?.id??null,markerSpan:s?.markerViewportHalfOpen1Based??null}),l}function Zo(n,e,t,r,o){let i=Ti(n);if(i===null)return null;let s=Hr(e,t,i,"page-break-pull-code-anchor-already-aligned-noop",{mdLine0:o,pulledSrc0:i});if(s)return s;let a={k:"block",src0:i,winRatio:r};return T("doc\u2192code.plan",{reason:"page-break-pull",plan:oe(a),pulledSrc0:i,mdLine0:o}),a}function Br(n,e,t,r,o,i){let s=M(n)?L(n.scrollTop/Math.max(1,n.scrollHeight-n.clientHeight),0,1):Le(),a=t();Ar(r,a);let c=pn(n),l=Jo(e,a,r,o,s,c);if(l!==null)return l;let u=Zo(n,e,o,s,c);if(u!==null)return u;if(a.length>0){if(T("doc\u2192code.plan",{reason:i?"indexed-fallback-mirror-no-confident-block":"indexed-noop-no-src0",mdLine0:c,linkCount:a.length,allowProportionalMirror:i}),!i)return{k:"noop"}}else if(!i)return T("doc\u2192code.plan",{reason:"snap-only-no-index-noop",linkCount:0}),{k:"noop"};if(M(n)){let h={k:"mirrorI",docTop:n.scrollTop,docSH:n.scrollHeight,docCH:n.clientHeight};return T("doc\u2192code.plan",{reason:"no-index-mirror-internal",plan:oe(h)}),h}let d={k:"mirrorW",ratio:s};return T("doc\u2192code.plan",{reason:"no-index-mirror-window",plan:oe(d)}),d}function ar(n,e){return M(n)?{k:"mirrorI",codeTop:n.scrollTop,codeSH:n.scrollHeight,codeCH:n.clientHeight}:{k:"mirrorW",ratio:e}}function ei(n,e,t,r,o,i){let a=[...n].sort((u,d)=>u.markerViewportHalfOpen1Based.lo-d.markerViewportHalfOpen1Based.lo)[0];if(!a)return T("code\u2192doc.plan",{reason:"prelude-missing-first-link",line1:r,lineIdPrefix:o}),{k:"noop"};t.sourceSticky.lockedId=a.id;let c=a.commentrayLine;if(Mr(e,c,j))return T("code\u2192doc.plan",{reason:"prelude-anchor-already-aligned-noop",line1:r,blockId:a.id,mdLine0:c}),{k:"noop"};let l={k:"block",mdLine0:c,winRatio:i};return T("code\u2192doc.plan",{reason:"prelude-first-block",line1:r,blockId:a.id,mdLine0:c,plan:ie(l)}),l}function ti(n,e,t,r,o,i){r.sourceSticky.lockedId=n.id;let s=n.commentrayLine,a=e!==null&&e.id===n.id?"strict":"trailing-slack";if(Mr(t,s,j))return T("code\u2192doc.plan",{reason:"active-block-anchor-aligned-noop",line1:o,pickMode:a,blockId:n.id,mdLine0:s}),{k:"noop"};let c={k:"block",mdLine0:s,winRatio:i};return T("code\u2192doc.plan",{reason:"active-block-reveal",line1:o,pickMode:a,blockId:n.id,mdLine0:s,markerSpan:n.markerViewportHalfOpen1Based,plan:ie(c)}),c}function ni(n,e,t){let r=n.sourceSticky.lockedId;if(!r)return;let o=e.find(s=>s.id===r);if(!o){n.sourceSticky.lockedId=null;return}let i=o.markerViewportHalfOpen1Based.hiExclusive;t>=i+xr&&(n.sourceSticky.lockedId=null)}function Ir(n,e,t,r,o,i){let s=Le(),a=t();if(Ar(o,a),a.length===0){if(!i)return T("code\u2192doc.plan",{reason:"snap-only-no-block-links-noop",lineIdPrefix:r}),{k:"noop"};let h=ar(n,s);return T("code\u2192doc.plan",{reason:h.k==="mirrorI"?"no-block-links-mirror-internal":"no-block-links-mirror-window",lineIdPrefix:r,plan:ie(h)}),h}let c=Gr(n,r);if(Dt(a,c))return ei(a,e,o,c,r,s);let l=te(a,c),u=Uo(a,c,o);if(u)return ti(u,l,e,o,c,s);if(ni(o,a,c),!i)return T("code\u2192doc.plan",{reason:"snap-only-source-gap-noop",line1:c,lineIdPrefix:r,stickyLockAfter:o.sourceSticky.lockedId}),{k:"noop"};let d=ar(n,s);return T("code\u2192doc.plan",{reason:d.k==="mirrorI"?"source-gap-mirror-internal":"source-gap-mirror-window",line1:c,lineIdPrefix:r,stickyLockAfter:o.sourceSticky.lockedId,plan:ie(d)}),d}function ln(n){return M(n)?{k:"mirrorI",docTop:n.scrollTop,docSH:n.scrollHeight,docCH:n.clientHeight}:{k:"mirrorW",ratio:Le()}}function un(n){return M(n)?{k:"mirrorI",codeTop:n.scrollTop,codeSH:n.scrollHeight,codeCH:n.clientHeight}:{k:"mirrorW",ratio:Le()}}function B(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ri(n,e){let t=n.replace(/\s+/g," ").trim();return t.length<=e?t:`${t.slice(0,e-1)}\u2026`}function oi(n,e){let t=new Map;for(let r of n){let o=r.kind==="path"?`path:${r.spPath??""}|${r.crPath??""}|${r.text.slice(0,120)}`:`${r.kind}:${r.line}:${r.crPath??""}`,i=t.get(o);(!i||r.score>i.score)&&t.set(o,r)}return[...t.values()].sort((r,o)=>o.score-r.score).slice(0,e)}function nn(n,e,t){let r=ze(n,t),o=new Set,i=[];for(let s of r){let a=Rn(n,s.start);o.has(a)||(o.add(a),i.push({kind:e,line:a,text:Dn(n,a),score:1e3,source:"ordered"}))}return i}function ii(n,e,t){let r=e.trim();if(!r)return[];let o=new U(r,t,[new he(.22),new Z(0),new ee(0)]),i=n.getMatches(o),s=[];for(let a of i.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 si(n,e){if(e.length===0)return[];let t=[];for(let r of n)r.kind!=="path"||ze(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 ai(n){let{scope:e,filePathLabel:t,commentrayPathLabel:r,rawCode:o,rawMd:i,searcher:s,queryRaw:a,tokens:c,pathBlobWide:l,pathRowsForOrdering:u}=n,d=(l&&l.trim().length>0?l.trim():[t,r].filter(g=>g.trim().length>0).join(`
17
- `))||"",h=e==="commentray-and-paths"?[]:nn(o,"code",c),p=e==="commentray-and-paths"&&u&&u.length>0?si(u,c):e==="commentray-and-paths"&&d?nn(d,"path",c):[],m=nn(i,"md",c),f=ii(s,a,60);return oi([...h,...p,...m,...f],80)}function ci(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 li(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 Pr(n,e,t){let r=li(n,t),o=n.source==="ordered"?"ordered":"fuzzy",i=Pn(ri(n.text,320),e),s=B(n.kind==="md"?n.crPath??t.currentCommentrayPath:n.crPath??""),a=B(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">${B(r)} <span class="src-tag">(${o})</span></span><div class="snippet">${i}</div></button>`}function ui(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 o=ci(n),i=[];i.push(`<div class="hint">${o} ${e.length} hit(s).</div>`);for(let s of e)i.push(Pr(s,t,r));return i.join("")}function rn(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 on(n,e,t){let r=[],o=[`<div class="hint">${B(n)}</div>`],i=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 i)o.push(Pr(s,r,t));return o.join("")}function Rr(n,e,t){let r=n.querySelector(`#commentray-md-line-${String(e)}`);if(r instanceof HTMLElement){let s=Math.round(Er(n,r,j)),a=Math.round(Math.max(0,n.scrollHeight-n.clientHeight));n.scrollTo({top:L(s,0,a),behavior:"smooth"});return}if(t<=1)return;let o=e/Math.max(1,t-1),i=Math.max(0,n.scrollHeight-n.clientHeight);n.scrollTo({top:o*i,behavior:"smooth"})}function Dr(n,e){if(n.staticBrowseUrl?.trim()){let r=Y(n.staticBrowseUrl.trim(),globalThis.location.pathname,globalThis.location.origin),o=new URL(r);e!==null&&e>=0&&(o.hash=`commentray-md-line-${String(e)}`),globalThis.location.assign(o.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 di(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 cr(n,e,t,r,o){let i=t.split(`
16
+ `,document.body.appendChild(e);let t=e.querySelector(".commentray-wide-intro-title"),r=e.querySelector(".commentray-wide-intro-body"),o=e.querySelector(".commentray-wide-intro-step-action"),i=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)||!(o instanceof HTMLButtonElement)||!(i 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:o,progressEl:i,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 Kn="commentray.codeCommentrayStatic.wideModeIntro.v1";function Xn(n){let e=n.isNarrowViewport()?"narrow":"wide";e!==n.viewportMode&&(n.viewportMode=e,n.steps=nn(n.shell,e==="narrow"))}function Jn(n){let{bubble:e,arrowLayer:t}=n.elements;Xn(n);let r=Ye(n.steps,n.current),o=r[0];if(!o){e.dataset.side="none",e.style.top="12px",e.style.left="12px",t.replaceChildren();return}Un(e,o),Yn(e,t,r)}function Ao(n){for(Xn(n);n.current<n.steps.length;){let e=n.steps[n.current];if(!e)break;let t=Ye(n.steps,n.current),r=typeof e.fallbackAction=="function";if(t.length>0||r)break;n.current++}}function Bo(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 Io(n,e){let{titleEl:t,bodyEl:r,progressEl:o,backBtn:i,nextBtn:s}=n.elements;if(Ao(n),n.current>=n.steps.length){e();return}let a=n.steps[n.current];if(!a)return;let c=Ye(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,Bo(n,a,c),o.textContent=`${String(n.current+1)} / ${String(n.steps.length)}`,i.disabled=n.current===0,s.textContent=n.current===n.steps.length-1?"Done":"Next",Jn(n)}function rn(n,e,t){if(!t?.force&&D(localStorage,Kn)==="1")return;Qn();let r=jn();if(!r)return;let o={shell:n,steps:nn(n,e()),viewportMode:e()?"narrow":"wide",current:0,highlighted:[],elements:r,isNarrowViewport:e},{bubble:i,arrowLayer:s,stepActionBtn:a,backBtn:c,nextBtn:l,skipBtn:u}=o.elements,d=()=>{for(let g of o.highlighted)g.classList.remove("commentray-wide-intro-target");o.highlighted=[],s.remove(),i.remove(),globalThis.removeEventListener("resize",f),globalThis.removeEventListener("scroll",m,!0),document.removeEventListener("keydown",p,!0),A(localStorage,Kn,"1")},m=()=>{Jn(o)},h=()=>{Io(o,d)},f=()=>{h()},p=g=>{g.key==="Escape"&&(g.preventDefault(),d())};c.addEventListener("click",()=>{o.current>0&&o.current--,h()}),a.addEventListener("click",()=>{let g=o.steps[o.current];!g||typeof g.fallbackAction!="function"||(g.fallbackAction(),h())}),l.addEventListener("click",()=>{if(o.current>=o.steps.length-1){d();return}o.current++,h()}),u.addEventListener("click",d),globalThis.addEventListener("resize",f),globalThis.addEventListener("scroll",m,!0),document.addEventListener("keydown",p,!0),h()}var Po="__NON_SYNC_TAIL_SLACK__";function Zn(n){return n.reduce((e,t)=>e+t.bufferAbove+t.height+t.bufferBelow,0)}function er(n,e){return n.map(t=>{let r=Te(t.id)?e.get(t.id)??t.height:t.height;return{...t,bufferAbove:t.bufferAbove??0,bufferBelow:Te(t.id)?r-t.height:t.bufferBelow??0,...t.syncRegionContinuationRows!==void 0?{syncRegionContinuationRows:[...t.syncRegionContinuationRows]}:{}}})}function Te(n){return/^R\d+XX$/.test(n)}function tr(n,e){let t=0;for(let o=0;o<e;o++){let i=n[o];i!==void 0&&(t+=i.bufferAbove+i.height+i.bufferBelow)}let r=n[e];return t+(r?.bufferAbove??0)}function nr(n,e){return n.findIndex(t=>t.id===e)}function Ro(n,e,t,r){let o=tr(n,t),i=tr(e,r);if(o===i)return!1;if(o>i){let d=o-i,m=n[t],h=m!==void 0?Math.min(d,m.bufferAbove):0,f=!1;h>0&&m!==void 0&&(m.bufferAbove-=h,f=!0);let p=d-h;if(p>0){let g=e[r];g!==void 0&&(g.bufferAbove+=p,f=!0)}return f}let s=i-o,a=e[r],c=a!==void 0?Math.min(s,a.bufferAbove):0,l=!1;c>0&&a!==void 0&&(a.bufferAbove-=c,l=!0);let u=s-c;if(u>0){let d=n[t];d!==void 0&&(d.bufferAbove+=u,l=!0)}return l}function Do(n,e){let t=new Set;for(let i of n)Te(i.id)&&t.add(i.id);let r=[];for(let i of t){let s=nr(n,i),a=nr(e,i);s>=0&&a>=0&&r.push({id:i,il:s,ir:a})}r.sort((i,s)=>i.il-s.il);let o=r.length+8;for(let i=0;i<o;i++){let s=!1;for(let{il:a,ir:c}of r)Ro(n,e,a,c)&&(s=!0);if(!s)break}}function rr(n){return{id:Po,height:0,bufferAbove:0,bufferBelow:n}}function Fo(n,e){let t=Zn(n),r=Zn(e),o=r-t;if(o>0&&n.length>0){or(n,e,o);return}let i=t-r;i>0&&e.length>0&&or(e,n,i)}function or(n,e,t){if(t<=0)return;let r=n.at(-1);if(r!==void 0&&!Te(r.id)){n[n.length-1]={...r,bufferBelow:r.bufferBelow+t};return}n.push(rr(t)),e.push(rr(0))}function ir(n){return{...n,...n.syncRegionContinuationRows!==void 0?{syncRegionContinuationRows:[...n.syncRegionContinuationRows]}:{}}}function No(n,e){let t=n.map(ir),r=e.map(ir);return Do(t,r),Fo(t,r),{left:t,right:r}}var Qe=class{synchronize(e,t){let r=[...e],o=[...t],i=new Map;for(let a of[...r,...o]){if(!Te(a.id))continue;let c=i.get(a.id)??0;a.height>c&&i.set(a.id,a.height)}let s={left:er(r,i),right:er(o,i)};return No(s.left,s.right)}};var Oo="tbody tr.stretch-row[data-commentray-stretch-sync-id]",on="commentray-mermaid-done",_o=new Qe;function O(n){return!Number.isFinite(n)||n<=0?0:Math.max(0,Math.round(n))}var je=1;function zo(n){let e=n.querySelector(":scope .stretch-doc-inner");if(e===null||e.nodeType!==je)return 0;let t=e,r=t.scrollHeight;if(typeof r=="number"&&r>0)return O(r);let o=O(t.getBoundingClientRect().height);return o>0?o:0}function $o(n){let e=n.querySelector(":scope .stretch-code-stack");if(e===null||e.nodeType!==je)return 0;let t=e,r=t.scrollHeight;if(typeof r=="number"&&r>0)return O(r);let o=O(t.getBoundingClientRect().height);return o>0?o:0}function qo(n){let e=n.querySelectorAll(".code-line");if(e.length===0)return 0;let t=1/0,r=-1/0;for(let i of e){let s=i.getBoundingClientRect();t=Math.min(t,s.top),r=Math.max(r,s.bottom)}if(r<=t||!Number.isFinite(t))return 0;let o=O(r-t);return o>0?o:0}function Go(n){let e=n.querySelector(".stretch-gap-mark");return e===null||e.nodeType!==je?0:O(e.getBoundingClientRect().height)}function sr(n){let e=zo(n);if(e>0)return e;let t=$o(n);if(t>0)return t;let r=n.querySelector(":scope > .stretch-cell-measure");if(r===null||r.nodeType!==je)return O(n.offsetHeight);let o=r,i=qo(o);if(i>0)return i;let s=Go(r);if(s>0)return s;let a=O(o.getBoundingClientRect().height);return a>0?a:O(o.offsetHeight)}function Wo(n){return Array.from(n.querySelectorAll(Oo)).filter(e=>(e.dataset.commentrayStretchSyncId?.trim()??"").length>0)}function Vo(n,e){n.style.paddingBottom="",e.style.paddingBottom="",n.style.paddingTop="",e.style.paddingTop=""}function Uo(n,e,t,r){t.bufferAbove>0&&(n.style.paddingTop=`${String(t.bufferAbove)}px`),r.bufferAbove>0&&(e.style.paddingTop=`${String(r.bufferAbove)}px`),t.bufferBelow>0&&(n.style.paddingBottom=`${String(t.bufferBelow)}px`),r.bufferBelow>0&&(e.style.paddingBottom=`${String(r.bufferBelow)}px`)}function Ke(n){let e=n.querySelectorAll("td"),t=e[0],r=e[1];return t===void 0||r===void 0?null:{codeTd:t,docTd:r}}function Yo(n){for(let e of n){let t=Ke(e);t!==null&&Vo(t.codeTd,t.docTd)}}function Qo(n){let e=[],t=[];for(let r of n){let o=Ke(r);if(o===null)continue;let i=r.dataset.commentrayStretchSyncId?.trim()??"";e.push({id:i,height:sr(o.codeTd),bufferAbove:0,bufferBelow:0}),t.push({id:i,height:sr(o.docTd),bufferAbove:0,bufferBelow:0})}return e.length===0?null:{left:e,right:t}}function jo(n,e){let t=n.length;for(let r=0;r<t;r++){let o=n[r],i=o===void 0?null:Ke(o),s=e.left[r],a=e.right[r];i===null||s===void 0||a===void 0||Uo(i.codeTd,i.docTd,s,a)}}function Ko(n){let e=n.at(-1);if(e===void 0||!e.classList.contains("stretch-row--gap"))return;let t=e===void 0?null:Ke(e);t!==null&&(t.codeTd.style.paddingBottom="",t.docTd.style.paddingBottom="")}function Xo(n){let e=Wo(n);if(e.length===0)return;Yo(e);let t=Qo(e);if(t===null)return;let r=_o.synchronize(t.left,t.right);jo(e,r),Ko(e)}function ar(){globalThis.dispatchEvent(new CustomEvent(on))}function cr(n){let e=0,t,r=()=>{e!==0&&globalThis.cancelAnimationFrame(e),e=globalThis.requestAnimationFrame(()=>{e=0,Xo(n)})},o=()=>{t!==void 0&&globalThis.clearTimeout(t),t=globalThis.setTimeout(()=>{t=void 0,r()},32)},i=new ResizeObserver(()=>{r()});i.observe(n);let s=n.querySelector("tbody"),a=s!==null?new MutationObserver(()=>{o()}):null;a!==null&&s!==null&&a.observe(s,{childList:!0,subtree:!0});let c=()=>{r()};globalThis.addEventListener("resize",c,{passive:!0}),globalThis.visualViewport?.addEventListener("resize",c,{passive:!0});let l=()=>{r()};return globalThis.addEventListener(on,l),queueMicrotask(()=>{r(),globalThis.requestAnimationFrame(()=>{r(),globalThis.requestAnimationFrame(()=>{r()})}),globalThis.setTimeout(()=>{r()},120)}),{disconnect:()=>{e!==0&&globalThis.cancelAnimationFrame(e),t!==void 0&&globalThis.clearTimeout(t),i.disconnect(),a?.disconnect(),globalThis.removeEventListener("resize",c),globalThis.visualViewport?.removeEventListener("resize",c),globalThis.removeEventListener(on,l)}}}var lr="commentray-mermaid-module-ready";function ke(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 o=r.getAttribute("href")?.trim()??"";We(o)&&(r.href=Q(o,e,t))}}var Je=new Set,X=new Set,we=null;function Jo(n){let e=new Set;for(let t of n)for(let r of Array.from(t.querySelectorAll("pre.mermaid"))){let o=r.closest(".commentray-mermaid");o!==null&&o.querySelector("svg")!==null||e.add(r)}return Array.from(e)}function Cr(){return we||(we=(async()=>{for(;X.size>0;){let n=globalThis.commentrayMermaid;if(!n){for(let r of X)Je.add(r);X.clear();return}let e=Array.from(X);X.clear();let t=Jo(e);if(t.length!==0)try{await n.run({nodes:t}),ar()}catch(r){console.error("Commentray: mermaid.run failed",r)}}})().finally(()=>{we=null,X.size>0&&Cr()}),we)}function Ar(n){return X.add(n),Cr()}function Zo(){let n=Array.from(Je);Je.clear();for(let e of n)Ar(e)}globalThis.addEventListener(lr,()=>{Zo()});function ce(n){return typeof globalThis.location<"u"&&globalThis.location.protocol==="file:"?Promise.resolve():globalThis.commentrayMermaid?Ar(n):(Je.add(n),Promise.resolve())}function M(n,e,t){return Math.max(e,Math.min(t,n))}function Br(n,e,t){let r=e.getBoundingClientRect(),o=n.getBoundingClientRect();return n.scrollTop+(r.top-o.top)-n.clientTop-t}function ve(n,e){let t=Math.max(0,n.scrollHeight-n.clientHeight),r=M(e,0,t);Math.abs(n.scrollTop-r)<.25||(n.scrollTop=r)}function L(n){if(n.scrollHeight-n.clientHeight<=1)return!1;let t=getComputedStyle(n).overflowY;return t==="auto"||t==="scroll"||t==="overlay"}function q(){let n=document.scrollingElement;return n instanceof HTMLElement?n:document.documentElement}function _(n){return L(n)?n.scrollTop:q().scrollTop}function ei(n,e){if(L(n)){let o=Math.max(0,n.scrollHeight-n.clientHeight);n.scrollTop=M(e,0,o);return}let t=q(),r=Math.max(0,t.scrollHeight-t.clientHeight);t.scrollTop=M(e,0,r)}function Ze(n){let{driverDelta:e,partnerBefore:t,partnerPane:r,axis:o}=n,i=_(r);Wn({driverDelta:e,partnerBefore:t,partnerAfter:i})&&(bn()&&globalThis.console.warn("[commentray:scroll-sync] monotonic.revert",{t:Math.round(performance.now()),axis:o??"?",driverDelta:e,partnerBefore:t,partnerAfter:i}),ei(r,t))}function ie(n){let e=q(),t=Math.max(0,e.scrollHeight-e.clientHeight),r=M(n*t,0,t);Math.abs(e.scrollTop-r)<.25||(e.scrollTop=r)}function yn(n,e,t){if(L(n)){let c=Math.round(Br(n,e,t));ve(n,c);return}let r=q(),o=e.getBoundingClientRect(),i=globalThis.scrollY+o.top-t,s=Math.max(0,r.scrollHeight-r.clientHeight),a=M(i,0,s);Math.abs(r.scrollTop-a)<.25||(r.scrollTop=a)}function Ir(n,e,t){if(L(n)){let o=e.getBoundingClientRect(),i=n.getBoundingClientRect(),s=o.top-i.top-n.clientTop;return Math.abs(s-t)<=tn}let r=e.getBoundingClientRect();return Math.abs(r.top-t)<=tn}function Pr(n,e,t){let r=n.querySelector(`[data-commentray-line="${String(e)}"]`);return r instanceof HTMLElement?Ir(n,r,t):!1}function Rr(n,e,t){let r=n.querySelector(`#${e}${String(t)}`);return r instanceof HTMLElement?r:ro(Oi(e),t)}function ti(n,e,t,r){let o=Rr(n,e,t);return o?Ir(n,o,r):!1}function Dr(n,e,t,r,o){return ti(n,e,t,K)?(S("doc\u2192code.plan",{reason:r,...o,src0:t,lineIdPrefix:e}),{k:"noop",skipProportionalFallbackOnFlip:!0}):null}var Fr=6;function ni(n,e,t){let r=re(n,e);if(r)return r;let o=t.sourceSticky.lockedId;if(o===null)return null;let i=n.find(l=>l.id===o);if(!i)return null;let{lo:s,hiExclusive:a}=i.markerViewportHalfOpen1Based,c=Fr;return e>=s&&e<a+c?i:null}function He(){let n=q(),e=Math.max(0,n.scrollHeight-n.clientHeight);return e>0?M(n.scrollTop/e,0,1):0}var et="commentrayDebugScroll";function ri(){let n=new URLSearchParams(globalThis.location.search).get(et);return n==="1"||n==="true"||n===""}function ur(n){try{let e=n.getItem(et);return e==="1"||e==="true"}catch{return!1}}function oi(){let n=globalThis.location.hash;return n===`#${et}`||n===`#${et}=1`}function ii(){let n=globalThis.location.hostname;return n==="localhost"||n==="127.0.0.1"||n==="0.0.0.0"||n==="::1"}function Nr(){try{return!!(ri()||oi()||ur(globalThis.sessionStorage)||ur(globalThis.localStorage))}catch{return!1}}var si=500,sn=!1,mn=-1/0;function dr(){mn=-1/0}function bn(){let n=performance.now();return n-mn<si||(mn=n,sn=Nr()),sn}typeof globalThis.addEventListener=="function"&&(globalThis.addEventListener("hashchange",dr),globalThis.addEventListener("storage",dr));function ai(){let n=ii(),e=Nr();!n&&!e||globalThis.console.log("[commentray:scroll-sync] boot",{t:Math.round(performance.now()),href:globalThis.location.href,devHost:n,traceVerbose:e})}function S(n,e){bn()&&globalThis.console.log(`[commentray:scroll-sync] ${n}`,{t:Math.round(performance.now()),...e})}function se(n){return n.k==="noop"?n.skipProportionalFallbackOnFlip===!0?"noop(skipFlipFallback)":"noop":n.k==="block"?`block(src0=${String(n.src0)})`:n.k==="mirrorW"?`mirrorW(ratio=${n.ratio.toFixed(4)})`:`mirrorI(docTop=${String(n.docTop)})`}function ae(n){return n.k==="noop"?"noop":n.k==="block"?`block(mdLine0=${String(n.mdLine0)})`:n.k==="mirrorW"?`mirrorW(ratio=${n.ratio.toFixed(4)})`:`mirrorI(codeTop=${String(n.codeTop)})`}function tt(n,e,t,r="code-line-"){if(t.k==="noop")return;let o=globalThis.matchMedia(xe).matches;if(t.k==="block"){let a=Rr(n,r,t.src0);a&&yn(n,a,K);return}if(t.k==="mirrorW"){if(L(n)){let a=Math.max(0,n.scrollHeight-n.clientHeight);ve(n,t.ratio*a),o&&ie(t.ratio)}else ie(t.ratio);return}let i=$t(t.docTop,t.docSH,t.docCH,n.scrollHeight,n.clientHeight);if(L(n)){if(ve(n,i),o){let a=Math.max(1,n.scrollHeight-n.clientHeight);ie(M(i/a,0,1))}return}let s=Math.max(1,n.scrollHeight-n.clientHeight);ie(M(i/s,0,1))}function nt(n,e,t){if(t.k==="noop")return;if(t.k==="block"){let i=e.querySelector(`[data-commentray-line="${String(t.mdLine0)}"]`);i instanceof HTMLElement&&yn(e,i,K);return}if(t.k==="mirrorW"){if(L(e)){let i=Math.max(0,e.scrollHeight-e.clientHeight);ve(e,t.ratio*i)}else ie(t.ratio);return}let r=$t(t.codeTop,t.codeSH,t.codeCH,e.scrollHeight,e.clientHeight);if(L(e)){ve(e,r);return}let o=Math.max(1,e.scrollHeight-e.clientHeight);ie(M(r/o,0,1))}function Or(n,e){let t=e.map(r=>r.id).join("\0");t!==n.linksKey.current&&(n.sourceSticky.lockedId=null,n.commentraySticky.lockedId=null,n.linksKey.current=t)}function ci(n,e,t,r,o,i){if(i===null)return null;let s=zt(e,i),a=s!==null?s.markerViewportHalfOpen1Based.lo-1:null;if(s!==null&&(t.commentraySticky.lockedId=s.id),a===null)return null;let c=Dr(n,r,a,"block-code-anchor-already-aligned-noop",{mdLine0:i,blockId:s?.id??null});if(c)return c;let l={k:"block",src0:a,winRatio:o};return S("doc\u2192code.plan",{reason:"block-from-md-probe",plan:se(l),mdLine0:i,blockId:s?.id??null,markerSpan:s?.markerViewportHalfOpen1Based??null}),l}function li(n,e,t,r,o){let i=Ai(n);if(i===null)return null;let s=Dr(e,t,i,"page-break-pull-code-anchor-already-aligned-noop",{mdLine0:o,pulledSrc0:i});if(s)return s;let a={k:"block",src0:i,winRatio:r};return S("doc\u2192code.plan",{reason:"page-break-pull",plan:se(a),pulledSrc0:i,mdLine0:o}),a}function _r(n,e,t,r,o,i){let s=L(n)?M(n.scrollTop/Math.max(1,n.scrollHeight-n.clientHeight),0,1):He(),a=t();Or(r,a);let c=Sn(n),l=ci(e,a,r,o,s,c);if(l!==null)return l;let u=li(n,e,o,s,c);if(u!==null)return u;if(a.length>0){if(S("doc\u2192code.plan",{reason:i?"indexed-fallback-mirror-no-confident-block":"indexed-noop-no-src0",mdLine0:c,linkCount:a.length,allowProportionalMirror:i}),!i)return{k:"noop"}}else if(!i)return S("doc\u2192code.plan",{reason:"snap-only-no-index-noop",linkCount:0}),{k:"noop"};if(L(n)){let m={k:"mirrorI",docTop:n.scrollTop,docSH:n.scrollHeight,docCH:n.clientHeight};return S("doc\u2192code.plan",{reason:"no-index-mirror-internal",plan:se(m)}),m}let d={k:"mirrorW",ratio:s};return S("doc\u2192code.plan",{reason:"no-index-mirror-window",plan:se(d)}),d}function mr(n,e){return L(n)?{k:"mirrorI",codeTop:n.scrollTop,codeSH:n.scrollHeight,codeCH:n.clientHeight}:{k:"mirrorW",ratio:e}}function ui(n,e,t,r,o,i){let a=[...n].sort((u,d)=>u.markerViewportHalfOpen1Based.lo-d.markerViewportHalfOpen1Based.lo)[0];if(!a)return S("code\u2192doc.plan",{reason:"prelude-missing-first-link",line1:r,lineIdPrefix:o}),{k:"noop"};t.sourceSticky.lockedId=a.id;let c=a.commentrayLine;if(Pr(e,c,K))return S("code\u2192doc.plan",{reason:"prelude-anchor-already-aligned-noop",line1:r,blockId:a.id,mdLine0:c}),{k:"noop"};let l={k:"block",mdLine0:c,winRatio:i};return S("code\u2192doc.plan",{reason:"prelude-first-block",line1:r,blockId:a.id,mdLine0:c,plan:ae(l)}),l}function di(n,e,t,r,o,i){r.sourceSticky.lockedId=n.id;let s=n.commentrayLine,a=e!==null&&e.id===n.id?"strict":"trailing-slack";if(Pr(t,s,K))return S("code\u2192doc.plan",{reason:"active-block-anchor-aligned-noop",line1:o,pickMode:a,blockId:n.id,mdLine0:s}),{k:"noop"};let c={k:"block",mdLine0:s,winRatio:i};return S("code\u2192doc.plan",{reason:"active-block-reveal",line1:o,pickMode:a,blockId:n.id,mdLine0:s,markerSpan:n.markerViewportHalfOpen1Based,plan:ae(c)}),c}function mi(n,e,t){let r=n.sourceSticky.lockedId;if(!r)return;let o=e.find(s=>s.id===r);if(!o){n.sourceSticky.lockedId=null;return}let i=o.markerViewportHalfOpen1Based.hiExclusive;t>=i+Fr&&(n.sourceSticky.lockedId=null)}function zr(n,e,t,r,o,i){let s=He(),a=t();if(Or(o,a),a.length===0){if(!i)return S("code\u2192doc.plan",{reason:"snap-only-no-block-links-noop",lineIdPrefix:r}),{k:"noop"};let m=mr(n,s);return S("code\u2192doc.plan",{reason:m.k==="mirrorI"?"no-block-links-mirror-internal":"no-block-links-mirror-window",lineIdPrefix:r,plan:ae(m)}),m}let c=Xr(n,r);if(_t(a,c))return ui(a,e,o,c,r,s);let l=re(a,c),u=ni(a,c,o);if(u)return di(u,l,e,o,c,s);if(mi(o,a,c),!i)return S("code\u2192doc.plan",{reason:"snap-only-source-gap-noop",line1:c,lineIdPrefix:r,stickyLockAfter:o.sourceSticky.lockedId}),{k:"noop"};let d=mr(n,s);return S("code\u2192doc.plan",{reason:d.k==="mirrorI"?"source-gap-mirror-internal":"source-gap-mirror-window",line1:c,lineIdPrefix:r,stickyLockAfter:o.sourceSticky.lockedId,plan:ae(d)}),d}function hn(n){return L(n)?{k:"mirrorI",docTop:n.scrollTop,docSH:n.scrollHeight,docCH:n.clientHeight}:{k:"mirrorW",ratio:He()}}function fn(n){return L(n)?{k:"mirrorI",codeTop:n.scrollTop,codeSH:n.scrollHeight,codeCH:n.clientHeight}:{k:"mirrorW",ratio:He()}}function B(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function hi(n,e){let t=n.replace(/\s+/g," ").trim();return t.length<=e?t:`${t.slice(0,e-1)}\u2026`}function fi(n,e){let t=new Map;for(let r of n){let o=r.kind==="path"?`path:${r.spPath??""}|${r.crPath??""}|${r.text.slice(0,120)}`:`${r.kind}:${r.line}:${r.crPath??""}`,i=t.get(o);(!i||r.score>i.score)&&t.set(o,r)}return[...t.values()].sort((r,o)=>o.score-r.score).slice(0,e)}function an(n,e,t){let r=Ge(n,t),o=new Set,i=[];for(let s of r){let a=On(n,s.start);o.has(a)||(o.add(a),i.push({kind:e,line:a,text:_n(n,a),score:1e3,source:"ordered"}))}return i}function pi(n,e,t){let r=e.trim();if(!r)return[];let o=new Y(r,t,[new fe(.22),new te(0),new ne(0)]),i=n.getMatches(o),s=[];for(let a of i.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 gi(n,e){if(e.length===0)return[];let t=[];for(let r of n)r.kind!=="path"||Ge(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 yi(n){let{scope:e,filePathLabel:t,commentrayPathLabel:r,rawCode:o,rawMd:i,searcher:s,queryRaw:a,tokens:c,pathBlobWide:l,pathRowsForOrdering:u}=n,d=(l&&l.trim().length>0?l.trim():[t,r].filter(g=>g.trim().length>0).join(`
17
+ `))||"",m=e==="commentray-and-paths"?[]:an(o,"code",c),h=e==="commentray-and-paths"&&u&&u.length>0?gi(u,c):e==="commentray-and-paths"&&d?an(d,"path",c):[],f=an(i,"md",c),p=pi(s,a,60);return fi([...m,...h,...f,...p],80)}function bi(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 Si(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 $r(n,e,t){let r=Si(n,t),o=n.source==="ordered"?"ordered":"fuzzy",i=Nn(hi(n.text,320),e),s=B(n.kind==="md"?n.crPath??t.currentCommentrayPath:n.crPath??""),a=B(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">${B(r)} <span class="src-tag">(${o})</span></span><div class="snippet">${i}</div></button>`}function Ti(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 o=bi(n),i=[];i.push(`<div class="hint">${o} ${e.length} hit(s).</div>`);for(let s of e)i.push($r(s,t,r));return i.join("")}function cn(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 ln(n,e,t){let r=[],o=[`<div class="hint">${B(n)}</div>`],i=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 i)o.push($r(s,r,t));return o.join("")}function qr(n,e,t){let r=n.querySelector(`#commentray-md-line-${String(e)}`);if(r instanceof HTMLElement){let s=Math.round(Br(n,r,K)),a=Math.round(Math.max(0,n.scrollHeight-n.clientHeight));n.scrollTo({top:M(s,0,a),behavior:"smooth"});return}if(t<=1)return;let o=e/Math.max(1,t-1),i=Math.max(0,n.scrollHeight-n.clientHeight);n.scrollTo({top:o*i,behavior:"smooth"})}function Gr(n,e){if(n.staticBrowseUrl?.trim()){let r=Q(n.staticBrowseUrl.trim(),globalThis.location.pathname,globalThis.location.origin),o=new URL(r);e!==null&&e>=0&&(o.hash=`commentray-md-line-${String(e)}`),globalThis.location.assign(o.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 wi(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 hr(n,e,t,r,o){let i=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}),o.trim()&&a.push({kind:"path",line:a.length,text:o})),[...n==="full"?s.map((c,l)=>({kind:"code",line:l,text:c})):[],...a,...i.map((c,l)=>({kind:"md",line:l,text:c}))]}function lr(n){let e=De.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 hi(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 dn(n){return[...n.querySelectorAll("button.hit")].filter(e=>e instanceof HTMLButtonElement)}function ur(n){return[...n.querySelectorAll("a.tree-file-link")].filter(e=>e instanceof HTMLAnchorElement)}function mi(n){let e=document.getElementById(`code-line-${String(n)}`);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}function fi(n,e){let t=(n.getAttribute("data-cr-path")??"").trim(),r=(n.getAttribute("data-sp-path")??"").trim(),o=Vt(e.mutable.documentedPairs,t,r);if(o&&Ut(o,e.filePathLabel,e.mutable.commentrayPathLabel)){e.docScrollEl.scrollTo({top:0,behavior:"smooth"});return}o&&Dr(o,null)}function pi(n,e,t){let r=t.mutable.commentrayPathLabel.trim(),o=e.trim();if(o.length>0&&k(o)!==k(r)){let i=Vt(t.mutable.documentedPairs,o,"");if(i){Dr(i,n);return}return}Rr(t.docScrollEl,n,t.mutable.mdLines.length)}function Fr(n,e){let t=n.getAttribute("data-kind"),r=parseInt(n.getAttribute("data-line")||"0",10),o=n.getAttribute("data-cr-path")?.trim()??"";if(t==="code"){mi(r);return}if(t==="path"){fi(n,e);return}pi(r,o,e)}function gi(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()}],d=rn("full",u.length,u.length,!1);return on(d,u,r)}let{rows:o,totalUnique:i}=On(t.documentedPairs);if(o.length>0){let l=rn("commentray-and-paths",o.length,i,!1);return on(l,o,r)}let s=e.trim();if(s.length===0)return null;let a=[{sourcePath:s,commentrayPath:t.commentrayPathLabel.trim()}],c=rn("commentray-and-paths",a.length,a.length,!0);return on(c,a,r)}function yi(n,e){n.addEventListener("keydown",t=>{if(t.isComposing||n.hidden)return;let r=dn(n);if(r.length===0)return;let o=document.activeElement;if(!(o instanceof HTMLButtonElement)||!o.classList.contains("hit"))return;let i=r.indexOf(o);if(!(i<0)){if(t.key==="ArrowDown"&&i<r.length-1){r[i+1].focus({preventScroll:!0}),t.preventDefault();return}if(t.key==="ArrowUp"){if(i>0){r[i-1].focus({preventScroll:!0}),t.preventDefault();return}e.focus({preventScroll:!0}),t.preventDefault()}}})}function bi(n,e,t){let{renderEmptyBrowsePreview:r,runSearch:o,cancelDebounceTimer:i,hitClickDeps:s}=t;n.addEventListener("keydown",a=>{if(a.isComposing)return;if(a.key==="ArrowDown"){if(!e.hidden){let l=dn(e);if(l.length>0&&document.activeElement===n){l[0].focus({preventScroll:!0}),a.preventDefault();return}}if(ye(n.value).length>0)return;r(),a.preventDefault();return}if(a.key!=="Enter")return;i(),ye(n.value).length>0&&o();let c=dn(e);!e.hidden&&c.length>0&&document.activeElement===n&&(a.preventDefault(),Fr(c[0],s))})}function Nr(n){let{scope:e,filePathLabel:t,mutable:r,rawCode:o,searchInput:i,searchClear:s,searchResults:a,docScrollEl:c}=n,l;function u(){clearTimeout(l),l=void 0}function d(){u(),i.value="",a.innerHTML="",a.hidden=!0}function h(){let f=gi(e,t,r);f!==null&&(a.hidden=!1,a.innerHTML=f)}function p(){let f=ye(i.value);if(f.length===0){a.hidden=!0,a.innerHTML="";return}let g=ai({scope:e,filePathLabel:t,commentrayPathLabel:r.commentrayPathLabel,rawCode:o,rawMd:r.rawMd,searcher:r.searcher,queryRaw:i.value,tokens:f,pathBlobWide:r.pathBlobWide,pathRowsForOrdering:r.pathRowsForOrdering.length>0?r.pathRowsForOrdering:void 0});a.hidden=!1,a.innerHTML=ui(e,g,f,{currentCommentrayPath:r.commentrayPathLabel,currentSourcePath:t})}let m={mutable:r,docScrollEl:c,filePathLabel:t};a.addEventListener("click",f=>{let g=hi(f.target,a);g&&Fr(g,m)}),yi(a,i),i.addEventListener("input",()=>{clearTimeout(l),l=setTimeout(p,200)}),bi(i,a,{renderEmptyBrowsePreview:h,runSearch:p,cancelDebounceTimer:u,hitClickDeps:m}),s.addEventListener("click",d),document.addEventListener("keydown",f=>{if(f.key!=="Escape")return;let g=i.value.trim().length>0,S=document.activeElement===i,b=!a.hidden;!g&&!S&&!b||(d(),S&&i.blur(),f.preventDefault())})}function Or(n,e,t,r,...o){let i=o.filter(a=>a instanceof HTMLElement),s=D(localStorage,n)==="1";if(t.checked=s,s){e.classList.add("wrap");for(let a of i)a.classList.add("wrap")}else{e.classList.remove("wrap");for(let a of i)a.classList.remove("wrap")}t.addEventListener("change",()=>{if(t.checked){e.classList.add("wrap");for(let a of i)a.classList.add("wrap");A(localStorage,n,"1")}else{e.classList.remove("wrap");for(let a of i)a.classList.remove("wrap");A(localStorage,n,"0")}r&&queueMicrotask(()=>{requestAnimationFrame(()=>{r(),requestAnimationFrame(()=>{r()})})})})}function _r(n){let e=n.trim();if(!e)return[];try{let t=JSON.parse(R(e));if(!Array.isArray(t))return[];let r=[];for(let o of t){if(typeof o!="object"||o===null)continue;let i=o;if(typeof i.id=="string"&&typeof i.commentrayLine=="number"&&typeof i.sourceStart=="number"&&typeof i.sourceEnd=="number"){let s=i.markerViewportHalfOpen1Based,a=typeof s=="object"&&s!==null&&typeof s.lo=="number"&&typeof s.hiExclusive=="number"?{lo:s.lo,hiExclusive:s.hiExclusive}:{lo:i.sourceStart,hiExclusive:i.sourceEnd+1};r.push({id:i.id,commentrayLine:i.commentrayLine,sourceStart:i.sourceStart,sourceEnd:i.sourceEnd,markerViewportHalfOpen1Based:a})}}return r}catch{return[]}}function zr(n=64){let e=$(),t=Math.max(0,e.scrollHeight-e.clientHeight);return t>0&&e.scrollTop>=t-n}function $r(n,e=64){let t=Math.max(0,n.scrollHeight-n.clientHeight);return t>0&&n.scrollTop>=t-e}function qr(n){let e=n.getAttribute("data-commentray-line");return e===null||e===""?null:Number(e)}function dr(n,e){let t=[];for(let r of n){let o=qr(r);o!==null&&t.push({line0:o,top:r.getBoundingClientRect().top})}return Bn(t,e)}function hr(n){for(let e=n.length-1;e>=0;e--){let t=n.item(e);if(!t)continue;let r=qr(t);if(r!==null)return r}return null}function Gr(n,e="code-line-"){let t=n.querySelectorAll(`[id^="${e}"]`);if(t.length===0)return 1;if(!M(n)){if(zr()){let u=t[t.length-1],d=/^(?:code-line-|code-md-line-)(\d+)$/.exec(u.id);return d?Number(d[1])+1:t.length}let i=n.getBoundingClientRect(),s=globalThis.innerHeight,a=Math.max(0,i.top),c=Math.min(s,i.bottom),l=a+Q(c-a);for(let u of t)if(u.getBoundingClientRect().bottom>l-.001){let h=/^(?:code-line-|code-md-line-)(\d+)$/.exec(u.id);return h?Number(h[1])+1:1}return t.length}if($r(n)){let i=t[t.length-1],s=/^(?:code-line-|code-md-line-)(\d+)$/.exec(i.id);return s?Number(s[1])+1:t.length}let o=n.getBoundingClientRect().top+n.clientTop+Q(n.clientHeight);for(let i of t)if(i.getBoundingClientRect().bottom>o-.001){let a=/^(?:code-line-|code-md-line-)(\d+)$/.exec(i.id);return a?Number(a[1])+1:1}return t.length}function pn(n){let e=n.querySelectorAll(".commentray-block-anchor");if(e.length===0)return null;if(!M(n)){if(zr()){let l=hr(e);if(l!==null)return l}let o=n.getBoundingClientRect(),i=globalThis.innerHeight,s=Math.max(0,o.top),a=Math.min(i,o.bottom),c=s+Q(a-s);return dr(e,c)}if($r(n)){let o=hr(e);if(o!==null)return o}let r=n.getBoundingClientRect().top+n.clientTop+Q(n.clientHeight);return dr(e,r)}function Wr(){let n=document.getElementById("shell");return n instanceof HTMLElement?n.getAttribute("data-page-breaks-enabled")==="true":!1}function Si(n){if(!M(n)){let t=n.getBoundingClientRect(),r=globalThis.innerHeight,o=Math.max(0,t.top),i=Math.min(r,t.bottom);return o+Q(i-o)}return n.getBoundingClientRect().top+n.clientTop+Q(n.clientHeight)}function Ti(n){if(!Wr())return null;let e=Si(n),t=Array.from(n.querySelectorAll(".commentray-page-break[data-next-source-viewport-line]"));for(let r of t){let o=r.getAttribute("data-next-source-viewport-line");if(!o)continue;let i=Number.parseInt(o,10);if(!Number.isFinite(i)||i<=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 d=Math.max(1,u-s),h=L((e-s)/d,0,1),m=globalThis.matchMedia("(max-width: 767px)").matches?.2:.35;return h<m?null:i-1}return null}var wi=Math.max(320,1050);function vi(n){let e=performance.now()+wi;n.until=Math.max(n.until,e)}function Vr(n){return performance.now()<n.until}var Ei=200;function Li(n,e,t,r){let o=performance.now();!fn()||o-e.lastEchoSkipTraceAt<Ei||(e.lastEchoSkipTraceAt=o,T(`wire.${n}.flush-skipped`,{reason:"partner-echo",echoUntilMs:Math.round(t.until),[`${n}ScrollTop`]:r.scrollTop}))}function mr(n){let{axis:e,driverPane:t,state:r,syncingRef:o,ownEchoGate:i,partnerEchoGate:s,syncFromDriver:a}=n;return()=>{if(r.pendingRaf=0,Vr(i)){Li(e,r,i,t),r.lastSeenTop=t.scrollTop;return}if(o.current!=="none"){T(`wire.${e}.flush-skipped`,{reason:"sync-in-progress",syncing:o.current});return}let c=t.scrollTop,l=c-r.lastSeenTop;r.lastSeenTop=c,o.current=e,vi(s),T(`wire.${e}.driver`,{delta:l,[`${e}ScrollTop`]:c}),a(l),o.current="none"}}function fr(n){let{driverPane:e,state:t,syncingRef:r,ownEchoGate:o,flush:i}=n;e.addEventListener("scroll",()=>{if(Vr(o)){t.lastSeenTop=e.scrollTop,t.pendingRaf!==0&&(cancelAnimationFrame(t.pendingRaf),t.pendingRaf=0);return}if(r.current!=="none"){t.lastSeenTop=e.scrollTop;return}t.pendingRaf!==0&&cancelAnimationFrame(t.pendingRaf),t.pendingRaf=requestAnimationFrame(i)},{passive:!0})}function Ur(n,e,t,r){let o={current:"none"},i={until:0},s={until:0},a={lastSeenTop:n.scrollTop,pendingRaf:0,lastEchoSkipTraceAt:-1/0},c={lastSeenTop:e.scrollTop,pendingRaf:0,lastEchoSkipTraceAt:-1/0},l=mr({axis:"code",driverPane:n,state:a,syncingRef:o,ownEchoGate:i,partnerEchoGate:s,syncFromDriver:t}),u=mr({axis:"doc",driverPane:e,state:c,syncingRef:o,ownEchoGate:s,partnerEchoGate:i,syncFromDriver:r});fr({driverPane:n,state:a,syncingRef:o,ownEchoGate:i,flush:l}),fr({driverPane:e,state:c,syncingRef:o,ownEchoGate:s,flush:u})}function pr(n,e){let{codePane:t,docPane:r,getLinks:o,lineIdPrefix:i,sticky:s}=n,a=_(r),c=i(),l=Ir(t,r,o,c,s,n.allowProportionalMirror);Je(t,r,l);let u=_(r);T("code\u2192doc.apply",{driverDelta:e,lineIdPrefix:c,plan:ie(l),docScrollTopBefore:a,docScrollTopAfter:u,docDelta:u-a,codeScrollTop:t.scrollTop}),je({driverDelta:e,partnerBefore:a,partnerPane:r,axis:"code\u2192doc"})}function gr(n,e){let{codePane:t,docPane:r,getLinks:o,lineIdPrefix:i,sticky:s}=n,a=_(t),c=i(),l=Br(r,t,o,s,c,n.allowProportionalMirror);Xe(t,r,l,c);let u=_(t);T("doc\u2192code.apply",{driverDelta:e,lineIdPrefix:c,plan:oe(l),codeScrollTopBefore:a,codeScrollTopAfter:u,codeDelta:u-a,docScrollTop:r.scrollTop}),je({driverDelta:e,partnerBefore:a,partnerPane:t,axis:"doc\u2192code"})}function sn(n,e,t,r,o,i){let s=i?.allowProportionalMirror!==!1,a=null,c=null,l={sourceSticky:{lockedId:null},commentraySticky:{lockedId:null},linksKey:{current:""}},u={codePane:n,docPane:e,getLinks:t,lineIdPrefix:r,sticky:l,allowProportionalMirror:s},d=y=>pr(u,y),h=y=>gr(u,y),p=()=>{pr(u,0)},m=()=>{gr(u,0)},f=()=>{if(s&&o?.()===!0){a={k:"mirrorW",ratio:Le()};return}a=Br(e,n,t,l,r(),s)},g=()=>{if(!a)return;let y=a;a=null,y.k==="noop"&&y.skipProportionalFallbackOnFlip!==!0&&s&&(y=ln(e)),Xe(n,e,y,r())},S=()=>{c=Ir(n,e,t,r(),l,s)},b=()=>{if(!c)return;let y=c;c=null,y.k==="noop"&&s&&(y=un(n)),Je(n,e,y)};return Ur(n,e,d,h),{syncFromCodeToDoc:p,syncFromDocToCode:m,prepareMobileFlipToCode:f,finishMobileFlipToCode:g,prepareMobileFlipToDoc:S,finishMobileFlipToDoc:b}}function Mi(n,e){let t=null,r=null,o=h=>{let p=_(e),m=un(n);Je(n,e,m),T("code\u2192doc.apply",{mode:"proportional-shell",driverDelta:h,plan:ie(m),docScrollTopBefore:p,docScrollTopAfter:_(e),codeScrollTop:n.scrollTop}),je({driverDelta:h,partnerBefore:p,partnerPane:e,axis:"code\u2192doc"})},i=h=>{let p=_(n),m=ln(e);Xe(n,e,m),T("doc\u2192code.apply",{mode:"proportional-shell",driverDelta:h,plan:oe(m),codeScrollTopBefore:p,codeScrollTopAfter:_(n),docScrollTop:e.scrollTop}),je({driverDelta:h,partnerBefore:p,partnerPane:n,axis:"doc\u2192code"})},s=()=>{o(0)},a=()=>{i(0)},c=()=>{t=ln(e)},l=()=>{if(!t)return;let h=t;t=null,Xe(n,e,h)},u=()=>{r=un(n)},d=()=>{if(!r)return;let h=r;r=null,Je(n,e,h)};return Ur(n,e,o,i),{syncFromCodeToDoc:s,syncFromDocToCode:a,prepareMobileFlipToCode:c,finishMobileFlipToCode:l,prepareMobileFlipToDoc:u,finishMobileFlipToDoc:d}}function Yr(n){let e=n.getBoundingClientRect();return(e.top+e.bottom)/2}function yr(n){return Yr(n)}function ki(n,e,t,r){if(e){let a=document.getElementById(`commentray-block-${e.id}`);if(!a)return Yr(t);let c=a.getBoundingClientRect().top-3;return r?An(n,t,a):c}let i=n.getBoundingClientRect().bottom-4,s=n.children[n.children.length-1];if(s&&(i=Math.min(i,s.getBoundingClientRect().bottom-4)),r){let a=t.getBoundingClientRect().top+4,c=Oe(n,t,null);i=Math.min(i,Math.max(a,c))}return i}function Qr(n,e){if(!n.startsWith(e))return null;let t=Number.parseInt(n.slice(e.length),10);return Number.isFinite(t)?t:null}function jr(n,e){let t=0,r=n.length-1,o=-1;for(;t<=r;){let i=t+r>>1;(n[i]?.line0??-1)>=e?(o=i,r=i-1):t=i+1}return o>=0?n[o]?.el??null:null}function Hi(n,e){let t=0,r=n.length-1,o=-1;for(;t<=r;){let i=t+r>>1;(n[i]?.line0??-1)<=e?(o=i,t=i+1):r=i-1}return o>=0?n[o]?.el??null:null}function xi(n){return Array.from(document.querySelectorAll(`[id^="${n}"]`)).map(e=>({line0:Qr(e.id,n),el:e})).filter(e=>e.line0!==null).sort((e,t)=>e.line0-t.line0)}function Ci(n,e,t,r){let o=()=>r();e.addEventListener("scroll",o,{passive:!0}),t.addEventListener("scroll",o,{passive:!0}),globalThis.addEventListener("resize",o);let i=new ResizeObserver(o);i.observe(n),i.observe(e),i.observe(t);let s=n.parentElement;s&&i.observe(s)}function Ai(n,e,t){let r=pn(e);return e.querySelector(".commentray-block-anchor")!==null&&r!==null?xn(n,r):Hn(n,t())}function Bi(n,e,t,r,o,i){let s=Ln(r()),a=Fe(s),c=e.getBoundingClientRect(),l=c.width,u=c.height;if(l<=0||u<=0||a.length===0){n.replaceChildren();return}let d=Ai(s,t,o),h=Wr();n.setAttribute("viewBox",`0 0 ${String(l)} ${String(u)}`),n.setAttribute("preserveAspectRatio","none");let p=[],m=Array.from(document.querySelectorAll(`[id^="${i}"]`)).map(f=>({line0:Qr(f.id,i),el:f})).filter(f=>f.line0!==null).sort((f,g)=>f.line0-g.line0);for(let f=0;f<a.length;f++){let g=a[f];if(!g)continue;let S=kn(s,g),b=zt(g.sourceStart),y=zt(g.sourceEnd),x=document.getElementById(`${i}${String(b)}`)??jr(m,b),C=document.getElementById(`${i}${String(y)}`)??Hi(m,y),E=document.getElementById(`commentray-block-${g.id}`);if(!x||!C||!E)continue;let H=ki(t,S,E,h),I=yr(x),X=yr(C),J=E.getBoundingClientRect().top+2,F=Math.max(H,J+4),ae=N(I,c.top,u),Sn=N(J,c.top,u),Tn=N(X,c.top,u),wn=N(F,c.top,u),nt=g.id===d?"gutter__rays-path gutter__rays-path--active":"gutter__rays-path",vn=`${nt} gutter__rays-path--trail`,rt=ge(0,ae.y,l,Sn.y,{tension:.38,clipStart:ae.clipped,clipEnd:Sn.clipped}),ot=ge(0,Tn.y,l,wn.y,{tension:.38,clipStart:Tn.clipped,clipEnd:wn.clipped}),co=rt.dotted?`<path class="${vn}" d="${rt.dotted}" />`:"",lo=ot.dotted?`<path class="${vn}" d="${ot.dotted}" />`:"";p.push(`<g class="gutter__rays-block" data-commentray-block="${B(g.id)}"><path class="${nt}" d="${rt.solid}" />`+co+`<path class="${nt}" d="${ot.solid}" />`+lo+"</g>")}n.innerHTML=p.join("")}function Ii(n){let{gutter:e,codePane:t,docScrollEl:r,getLinks:o,probeTopSourceLine1Based:i}=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 d(){u===0&&(u=globalThis.requestAnimationFrame(()=>{u=0,Bi(l,e,r,o,i,s())}))}return Ci(e,t,r,d),d(),globalThis.requestAnimationFrame(()=>{d(),globalThis.requestAnimationFrame(d)}),d}function Pi(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,o=typeof t=="string";return!(o!==(typeof r=="string")||!(typeof e.staticBrowseUrl=="string"&&e.staticBrowseUrl.trim().length>0)&&!o)}function gn(n){let e=[];if(!Array.isArray(n))return e;for(let t of n)Pi(t)&&e.push(t);return e}function Ri(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 Di(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:"",o=n.kind==="sourcePath"?t:r;return o?{kind:"path",line:e,text:o,spPath:t,crPath:r}:null}function Fi(n){if(!n||typeof n!="object")return[];let e=n.rows;if(!Array.isArray(e))return[];let t=[],r=0;for(let o of e){if(!o||typeof o!="object")continue;let i=o,s=Ri(i);if(s){t.push(s);continue}let a=Di(i,r);a&&(t.push(a),r+=1)}return t}function Kr(n){let e=n.trim();if(e==="")return[];try{let t=JSON.parse(R(e));return gn(t)}catch{return[]}}function Ni(n,e){let t=e.sourcePath.split("/").filter(Boolean);if(t.length===0)return;let r=n;for(let o=0;o<t.length;o++){let i=t[o];if(i===void 0)continue;r.children.has(i)||r.children.set(i,{children:new Map,pairs:[]});let s=r.children.get(i);if(s===void 0)return;o===t.length-1&&s.pairs.push(e),r=s}}function Oi(n){let e=n.replace(/\\/g,"/").replace(/\/+$/,""),t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function _i(n){return(n.replace(/\\/g,"/").replace(/\/+$/,"").split("/").filter(Boolean).at(-1)??"").replace(/\.md$/i,"")}function zi(n,e){let t=Oi(n.sourcePath);if(!e)return t;let r=_i(n.commentrayPath);return r!==""&&r!==t?`${t} \xB7 ${r}`:t}function $i(n){let e=(n.staticBrowseUrl??"").trim();if(e.length>0)return Y(e,globalThis.location.pathname,globalThis.location.origin);let t=(n.commentrayOnGithub??"").trim();return t.length>0?t:"#"}function qi(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 Gi(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 Wi(n,e,t){for(let r of n.querySelectorAll("a.tree-file-link")){if(!(r instanceof HTMLAnchorElement))continue;let o=r.getAttribute("data-pair-source-path")?.trim()??"",i=r.getAttribute("data-pair-commentray-path")?.trim()??"";if(Ut({sourcePath:o,commentrayPath:i},e,t)){r.classList.add("tree-file-link--current"),r.setAttribute("aria-current","page");break}}}function yn(){let n=document.getElementById("shell"),e=document.getElementById("documented-files-tree");if(!(n instanceof HTMLElement)||!(e instanceof HTMLElement))return;Gi(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||Wi(e,t,r)}function Xr(n){let e=[...n.children.keys()].sort((r,o)=>r.localeCompare(o));if(e.length===0)return"";let t=[];for(let r of e){let o=n.children.get(r);if(o!==void 0){if(o.children.size>0){let i=Xr(o);t.push(`<li><div class="tree-dir">${B(r)}</div>${i}</li>`)}if(o.pairs.length>0){let i=o.pairs.length>1;for(let s of o.pairs){let a=B(zi(s,i)),c=B(qi(s)),l=B($i(s)),u=B(k(s.sourcePath)),d=B(k(s.commentrayPath)),p=(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="${d}"${p} title="${c}">${a}</a></div></li>`)}}}}return`<ul>${t.join("")}</ul>`}function Vi(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 o of e)Ni(r,o);n.innerHTML=Xr(r),yn()}function Ui(n,e){let t=null,r=null;return async()=>t!==null?t:(r===null&&(r=(async()=>{if(e.length>0&&(t=Kr(e),t.length>0))return;if(n.length===0){t=[];return}let o=await fetch(n,{credentials:"same-origin"});if(!o.ok)throw new Error(`nav json ${String(o.status)}`);let i=await o.json();t=gn(i.documentedPairs)})()),await r,t??[])}function Yi(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 o(){let s=n.querySelector("summary");return s instanceof HTMLElement?s:null}function i(){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=o();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",i),globalThis.addEventListener("resize",i),globalThis.addEventListener("scroll",i,!0),i}function Qi(){let n=document.getElementById("documented-files-filter");n instanceof HTMLInputElement&&n.focus({preventScroll:!0})}function ji(){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 o=n,i=e,s=o.getAttribute("data-nav-json-url")?.trim()??"",a=r?.getAttribute("data-documented-pairs-b64")?.trim()??"";if(s.length===0&&a.length===0)return;let c=Yi(o),l=Ui(s,a),u=null;function d(){if(u===null)return;let m=t instanceof HTMLInputElement?t.value:"",f=Fn(u,m),g=m.trim().length>0;Vi(i,f,g&&u.length>0&&f.length===0)}async function h(){try{u=await l(),d()}catch{u=null,i.innerHTML='<p class="nav-rail__doc-hub-hint" role="alert">Could not load the file list.</p>'}}o.addEventListener("toggle",()=>{c(),o.open&&globalThis.requestAnimationFrame(()=>{c(),Qi()}),o.open&&h()});function p(m){if(!o.open||m.key!=="Escape")return;m.preventDefault(),o.open=!1;let f=o.querySelector("summary");f instanceof HTMLElement&&f.focus({preventScroll:!0})}document.addEventListener("keydown",p,!0),i.addEventListener("keydown",m=>{if(!o.open||m.isComposing)return;let f=m.target;if(!(f instanceof HTMLAnchorElement)||!f.classList.contains("tree-file-link"))return;let g=ur(i);if(g.length===0)return;let S=g.indexOf(f);if(!(S<0)){if(m.key==="ArrowDown"){S<g.length-1&&(g[S+1].focus({preventScroll:!0}),m.preventDefault());return}if(m.key==="ArrowUp"){if(S>0){g[S-1].focus({preventScroll:!0}),m.preventDefault();return}t instanceof HTMLInputElement&&(t.focus({preventScroll:!0}),m.preventDefault())}}}),t instanceof HTMLInputElement&&(t.addEventListener("input",()=>{!o.open||u===null||d()}),t.addEventListener("keydown",m=>{if(!o.open||m.isComposing||m.key!=="ArrowDown")return;let f=ur(i);f.length!==0&&(f[0].focus({preventScroll:!0}),m.preventDefault())}))}function Ki(n,e,t,r,o){let i=!1,s=o;function a(l){if(!i)return;let u=e.getBoundingClientRect(),d=l.clientX-u.left,h=L(d/u.width*100,15,85);s=h,t.style.flex=`0 0 ${h}%`,e.style.setProperty("--split-pct",`${String(h)}%`)}function c(){i=!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(),i=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",a),window.addEventListener("mouseup",c)})}var Ze="commentray.codeCommentrayStatic.splitPct",Jr="commentray.codeCommentrayStatic.wrap",we="commentray.codeCommentrayStatic.dualMobilePane",Xi="commentray.codeCommentrayStatic.sourceMarkdownPaneMode",Ji="commentray.codeCommentrayStatic.pageBreaksEnabled",Me="(max-width: 767px)";function K(n){return n==="code"?"code":"doc"}function ve(){return globalThis.matchMedia(Me).matches}function et(n,e){if(e){n.setAttribute("data-mobile-single-pane","true");return}n.removeAttribute("data-mobile-single-pane")}function Zi(n){let e=document.getElementById("commentray-help-tour");e instanceof HTMLButtonElement&&e.addEventListener("click",()=>{Zt(n,ve,{force:!0})})}function z(n){return n.getAttribute("data-source-pane-mode")==="rendered-markdown"?"rendered-markdown":"source"}function es(n){let e=(n??"").trim().toLowerCase();return!(e==="0"||e==="false"||e==="off")}function ts(n){let e=es(D(localStorage,Ji));n.setAttribute("data-page-breaks-enabled",e?"true":"false")}function ns(n){let e=()=>{let t=Math.max(globalThis.innerHeight,document.documentElement?.clientHeight??0);if(!Number.isFinite(t)||t<=0)return;let r=Math.round(L(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 br(n){let e=document.querySelector("label.toolbar-wrap-lines");e instanceof HTMLLabelElement&&(e.hidden=z(n)==="rendered-markdown")}function Se(n){return z(n)==="rendered-markdown"?"code-md-line-":"code-line-"}function rs(n,e){let t=()=>{if(n.getAttribute("data-layout")!=="dual"||!e.matches||K(n.getAttribute("data-dual-mobile-pane"))!=="doc")return;let r=document.getElementById("doc-pane-body");r instanceof HTMLElement&&se(r)};queueMicrotask(()=>{t(),requestAnimationFrame(()=>{t(),requestAnimationFrame(t)})})}function Zr(n,e,t){let r=()=>{e.hidden=!0,e.classList.remove("is-visible")},o=()=>{e.hidden=!1,e.classList.add("is-visible")},i=()=>{if(!t.matches){r();return}let s=n.getBoundingClientRect(),a=globalThis.innerHeight,c=10;s.bottom<c||s.top>a-c?o():r()};globalThis.addEventListener("scroll",i,{passive:!0}),globalThis.addEventListener("resize",i,{passive:!0}),t.addEventListener("change",i),globalThis.requestAnimationFrame(i)}function os(n,e,t){let r=()=>{e.hidden=!0,e.classList.remove("is-visible")},o=()=>{e.hidden=!1,e.classList.add("is-visible")},i=()=>{if(n.hidden||n.getClientRects().length===0){r();return}let s=n.getBoundingClientRect(),a=globalThis.innerHeight,c=10;s.bottom<c||s.top>a-c?o():r()};globalThis.addEventListener("scroll",i,{passive:!0,signal:t}),globalThis.addEventListener("resize",i,{passive:!0,signal:t}),globalThis.requestAnimationFrame(i)}function Sr(n,e,t){let r=ve()&&K(n.getAttribute("data-dual-mobile-pane"))!=="code";e.hidden=r,r?(e.setAttribute("aria-hidden","true"),e.style.setProperty("display","none","important")):(e.removeAttribute("aria-hidden"),e.style.removeProperty("display")),t instanceof HTMLButtonElement&&(t.hidden=!0,t.classList.remove("is-visible"))}function is(n,e){let t=n.querySelectorAll(`[id^="${e}"]`);if(t.length===0)return null;let r=M(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 o=t[t.length-1];if(!o)return null;let i=/^(?:code-line-|code-md-line-)(\d+)$/.exec(o.id);return i?.[1]?Number.parseInt(i[1],10):null}function ss(n,e,t,r,o,i){function s(){return Array.from(e.querySelectorAll('[data-source-markdown-body="true"]'))}function a(){let p=z(n)==="rendered-markdown",m=p?"markdown source":"rendered markdown",f=p?"rendered markdown":"markdown source",g=`Switch source pane to ${m}`,S=`Switch source pane to ${m} (currently ${f})`,b=y=>{y instanceof HTMLButtonElement&&(y.setAttribute("aria-pressed",p?"true":"false"),y.setAttribute("aria-label",g),y.title=S)};b(t),b(r)}a(),br(n),Sr(n,t,r);let c=()=>{Sr(n,t,r)};globalThis.addEventListener("resize",c,{passive:!0,signal:o}),globalThis.matchMedia(Me).addEventListener("change",c,{signal:o});let u=new MutationObserver(c);u.observe(n,{attributes:!0,attributeFilter:["data-dual-mobile-pane","data-source-pane-mode"]}),o.addEventListener("abort",()=>u.disconnect(),{once:!0});let d=()=>{let h=z(n),m=is(e,h==="rendered-markdown"?"code-md-line-":"code-line-"),f=h==="rendered-markdown"?"source":"rendered-markdown",g=f==="rendered-markdown"?"code-md-line-":"code-line-";n.setAttribute("data-source-pane-mode",f),A(localStorage,Xi,f),ve()&&K(n.getAttribute("data-dual-mobile-pane"))==="doc"&&(n.setAttribute("data-dual-mobile-pane","code"),A(localStorage,we,"code")),a(),br(n);let S=!ve()||M(e);if(m!==null&&S){let b=e.querySelector(`#${g}${String(m)}`);b instanceof HTMLElement&&mn(e,b,0)}if(f==="rendered-markdown")for(let b of s())se(b),Ee(b);i?.()};t.addEventListener("click",d,{signal:o}),r&&(r.addEventListener("click",d,{signal:o}),os(t,r,o))}function as(n,e,t,r){let o=globalThis.matchMedia(Me);function i(){return K(D(localStorage,we))}function s(){o.matches?(et(n,!0),n.setAttribute("data-dual-mobile-pane",i())):(et(n,!1),n.removeAttribute("data-dual-mobile-pane"))}let a=()=>{if(!o.matches)return;let l=K(n.getAttribute("data-dual-mobile-pane"))==="code"?"doc":"code",u=$().scrollTop;l==="code"?t.prepareMobileFlipToCode():t.prepareMobileFlipToDoc(),n.setAttribute("data-dual-mobile-pane",l),A(localStorage,we,l),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(()=>{if(l==="code"){t.finishMobileFlipToCode();let d=$();if(u>5&&d.scrollTop<=1){let h=Math.max(0,d.scrollHeight-d.clientHeight);d.scrollTop=L(u,0,h)}}else t.finishMobileFlipToDoc()})}),l==="doc"&&rs(n,o)};e.addEventListener("click",a),r&&(r.addEventListener("click",a),Zr(e,r,o)),o.addEventListener("change",s),s()}function eo(n,e,t,r,o){let i=globalThis.matchMedia(Me);function s(){return K(D(localStorage,we))}function a(){i.matches?(et(n,!0),n.setAttribute("data-dual-mobile-pane",s())):(et(n,!1),n.removeAttribute("data-dual-mobile-pane"))}let c=()=>{if(!i.matches)return;let u=K(n.getAttribute("data-dual-mobile-pane"))==="code"?"doc":"code";n.setAttribute("data-dual-mobile-pane",u),A(localStorage,we,u),u==="doc"&&queueMicrotask(()=>{requestAnimationFrame(()=>{se(n)})})};t.addEventListener("click",c),r&&(r.addEventListener("click",c),Zr(t,r,i)),i.addEventListener("change",a),a()}var Qe=null,hn=null;function cs(n){return n.getAttribute("data-stretch-buffer-sync")==="flow-synchronizer"}function ls(n){return Array.from(n.querySelectorAll("tbody tr.stretch-row--block[data-commentray-stretch-sync-id]")).filter(e=>(e.dataset.commentrayStretchSyncId?.trim()??"").length>0)}function us(n){let e=n.dataset.commentrayStretchSyncId?.trim()??"";if(e.length===0)return null;let t=n.querySelector(":scope > td.stretch-code"),r=n.querySelector(":scope > td.stretch-doc");return!(t instanceof HTMLTableCellElement)||!(r instanceof HTMLTableCellElement)?null:{id:e,codeRect:t.getBoundingClientRect(),docRect:r.getBoundingClientRect()}}function tt(n){if(!(n instanceof HTMLElement))return null;let e=n.getBoundingClientRect();if(e.width<=0||e.height<=0)return null;let t=globalThis.getComputedStyle(n);return t.display==="none"||t.visibility==="hidden"?null:e}function ds(n,e){let t=z(e)==="rendered-markdown"?".source-pane--rendered-md":".source-pane--code",r=n.querySelector(t);if(tt(r)!==null)return r;let o=n.querySelectorAll(".source-pane--code, .source-pane--rendered-md");for(let i of o)if(tt(i)!==null)return i;return null}function hs(n,e){let t=ds(n,e),r=tt(t);return r!==null?r.bottom:n.getBoundingClientRect().bottom}function ms(n){let e=n.querySelector(":scope .stretch-doc-inner"),t=tt(e);return t!==null?t.bottom:n.getBoundingClientRect().bottom}function fs(n,e){let t=n.getBoundingClientRect(),r=t.top+Math.min(Math.max(t.height*.18,24),120);for(let o of e){let i=o.getBoundingClientRect();if(i.top<=r&&i.bottom>=r)return o.dataset.commentrayStretchSyncId?.trim()??null}return e[0]?.dataset.commentrayStretchSyncId?.trim()??null}function ps(n,e,t,r){let o=ls(t),i=r.getBoundingClientRect(),s=i.width,a=i.height;if(s<=0||a<=0||o.length===0){n.replaceChildren();return}n.setAttribute("viewBox",`0 0 ${String(s)} ${String(a)}`),n.setAttribute("preserveAspectRatio","none");let c=fs(e,o),l=[];for(let u of o){let d=us(u);if(d===null)continue;let h=u.querySelector(":scope > td.stretch-code"),p=u.querySelector(":scope > td.stretch-doc");if(!(h instanceof HTMLTableCellElement)||!(p instanceof HTMLTableCellElement))continue;let m=hs(h,e),f=ms(p),g=N(d.codeRect.top+1,i.top,a),S=N(d.docRect.top+1,i.top,a),b=N(m-1,i.top,a),y=N(f-1,i.top,a),x=d.id===c?"gutter__rays-path gutter__rays-path--active":"gutter__rays-path",C=`${x} gutter__rays-path--trail`,E=ge(0,g.y,s,S.y,{tension:.38,clipStart:g.clipped,clipEnd:S.clipped}),H=ge(0,b.y,s,y.y,{tension:.38,clipStart:b.clipped,clipEnd:y.clipped}),I=E.dotted?`<path class="${C}" d="${E.dotted}" />`:"",X=H.dotted?`<path class="${C}" d="${H.dotted}" />`:"";l.push(`<g class="gutter__rays-block" data-commentray-block="${B(d.id)}"><path class="${x}" d="${E.solid}" />`+I+`<path class="${x}" d="${H.solid}" />`+X+"</g>")}n.innerHTML=l.join("")}function gs(n,e,t){t.querySelector(":scope > .gutter__rays")?.remove();let r="http://www.w3.org/2000/svg",o=document.createElement("div");o.className="gutter__rays",o.setAttribute("aria-hidden","true");let i=document.createElementNS(r,"svg");o.appendChild(i),t.appendChild(o);let s=0,a=()=>{s===0&&(s=globalThis.requestAnimationFrame(()=>{s=0,ps(i,n,e,t)}))},c=()=>a();n.addEventListener("scroll",c,{passive:!0}),globalThis.addEventListener("resize",c);let l=new ResizeObserver(c);return l.observe(n),l.observe(e),l.observe(t),a(),globalThis.requestAnimationFrame(()=>{a(),globalThis.requestAnimationFrame(a)}),{disconnect:()=>{s!==0&&globalThis.cancelAnimationFrame(s),n.removeEventListener("scroll",c),globalThis.removeEventListener("resize",c),l.disconnect(),o.remove()},request:a}}function ys(n,e){let t=document.getElementById("stretch-gutter");if(!(t instanceof HTMLElement))return;let r=Number.parseFloat(D(localStorage,Ze)??""),o=L(Number.isFinite(r)?r:50,15,85);n.style.setProperty("--stretch-code-pct",`${String(o)}%`);let i=!1,s=c=>{if(!i)return;let l=e.getBoundingClientRect();if(l.width<=0)return;let u=c.clientX-l.left,d=L(u/l.width*100,15,85);n.style.setProperty("--stretch-code-pct",`${String(d)}%`),A(localStorage,Ze,String(d)),hn?.request()},a=()=>{i&&(i=!1,document.body.style.cursor="",document.body.style.userSelect="",globalThis.removeEventListener("mousemove",s),globalThis.removeEventListener("mouseup",a))};t.addEventListener("mousedown",c=>{c.preventDefault(),i=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",globalThis.addEventListener("mousemove",s),globalThis.addEventListener("mouseup",a)})}function to(n,e){e instanceof HTMLTableElement&&cs(n)?(Qe?.disconnect(),Qe=or(e)):(Qe?.disconnect(),Qe=null);let t=document.getElementById("wrap-lines");t&&Or(Jr,e,t,()=>{globalThis.dispatchEvent(new Event("resize"))});let r=document.getElementById("stretch-gutter");hn?.disconnect(),hn=e instanceof HTMLElement&&r instanceof HTMLElement?gs(n,e,r):null,ys(n,e)}function bs(n,e){if(n===null||typeof n!="object")return!1;let t=n;return typeof t.id!="string"||typeof t.docInnerHtmlB64!="string"?!1:e!=="stretch"?!0:typeof t.stretchSwapInnerB64=="string"&&t.stretchSwapInnerB64.trim().length>0}function no(n){let e=n?.textContent?.trim()??"";if(!e)return null;try{let t=JSON.parse(R(e));if(!t||!Array.isArray(t.angles)||t.angles.length<2)return null;let r=t.layoutMode==="stretch"?"stretch":"dual";return t.angles.every(o=>bs(o,r))?{...t,layoutMode:r}:null}catch{return null}}function Ss(n,e){let t=e.stretchSwapInnerB64;if(t===void 0||t.trim().length===0)return;n.innerHTML=R(t);let r=document.getElementById("code-pane");if(r instanceof HTMLElement){to(n,r),bn(n,r,()=>{globalThis.dispatchEvent(new Event("resize"))});let a=document.getElementById("mobile-pane-flip"),c=document.getElementById("mobile-pane-flip-scroll");a instanceof HTMLButtonElement&&eo(n,r,a,c instanceof HTMLButtonElement?c:null,()=>{globalThis.dispatchEvent(new Event("resize"))})}n.setAttribute("data-scroll-block-links-b64",e.scrollBlockLinksB64),n.setAttribute("data-raw-md-b64",e.rawMdB64),n.setAttribute("data-search-commentray-path",e.commentrayPathForSearch);let o=k(e.commentrayPathForSearch);o.length>0?n.setAttribute("data-commentray-pair-commentray-path",o):n.removeAttribute("data-commentray-pair-commentray-path");let i=document.getElementById("nav-rail-doc-path");if(i){let a=e.commentrayPathForSearch.trim();i.textContent=a.length>0?a:"\u2014",a.length>0?i.setAttribute("title",a):i.removeAttribute("title")}let s=e.staticBrowseUrl?.trim()??"";if(s.length>0){let a=Wt(s,globalThis.location.pathname,globalThis.location.origin);n.setAttribute("data-commentray-pair-browse-href",a)}else{let a=e.commentrayOnGithubUrl?.trim();a?n.setAttribute("data-commentray-pair-browse-href",a):n.removeAttribute("data-commentray-pair-browse-href")}yn(),ao(n),se(n),Ee(n),$().scrollTop=0}function Ts(n,e,t){if(e.layoutMode!=="stretch")return;let r=document.getElementById("angle-select");r&&r.addEventListener("change",()=>{let o=e.angles.find(i=>i.id===r.value);o&&(Ss(n,o),t?.(o))})}function ws(n,e){let t=ro();if(!t)return;let r=io(n,e),{searchInput:o,searchClear:i,searchResults:s}=t;Nr({scope:r.scope,filePathLabel:r.filePathLabel,mutable:r.mutable,rawCode:r.rawCode,searchInput:o,searchClear:i,searchResults:s,docScrollEl:n}),oo(n,r.pathInit.documentedPairs,r.indexState,r.mutable,r.rebuildSearcher,o);let a=document.getElementById("commentray-multi-angle-b64"),c=no(a);c?.layoutMode==="stretch"&&Ts(n,c,l=>{r.mutable.rawMd=R(l.rawMdB64),r.mutable.mdLines=r.mutable.rawMd.split(`
20
- `),r.mutable.commentrayPathLabel=l.commentrayPathForSearch,r.rebuildSearcher(),o.value="",s.innerHTML="",s.hidden=!0})}function vs(){let n=document.getElementById("doc-pane"),e=document.getElementById("gutter"),t=document.getElementById("wrap-lines");if(!n||!e||!t)return null;let r=document.getElementById("doc-pane-body"),o=r instanceof HTMLElement?r:n;return{docBody:r,docScrollEl:o,gutter:e,wrapCb:t}}function ro(){let n=document.getElementById("search-q"),e=document.getElementById("search-clear"),t=document.getElementById("search-results");return!n||!e||!t?null:{searchInput:n,searchClear:e,searchResults:t}}function Es(n){let{scope:e,rawCode:t,filePathLabel:r,hubNavRows:o,pathRowsForOrdering:i,rawMd:s,commentrayPathLabel:a}=n;if(e!=="commentray-and-paths")return cr(e,t,s,r,a);if(o.length>0)return o;let c=i.length>0?i:cr(e,t,s,r,a).filter(u=>u.kind==="path"),l=s.split(`
21
- `).map((u,d)=>({kind:"md",line:d,text:u,spPath:r,crPath:a}));return[...c,...l]}function Ls(n,e,t,r){if(e!=="commentray-and-paths")return{documentedPairs:[],pathRowsForOrdering:[],pathBlobWide:""};let o=Kr(n.getAttribute("data-documented-pairs-b64")?.trim()??""),i=Nn(o),s=i.length>0?i.map(a=>a.text).join(`
19
+ `),a=[];return n==="commentray-and-paths"&&(r.trim()&&a.push({kind:"path",line:a.length,text:r}),o.trim()&&a.push({kind:"path",line:a.length,text:o})),[...n==="full"?s.map((c,l)=>({kind:"code",line:l,text:c})):[],...a,...i.map((c,l)=>({kind:"md",line:l,text:c}))]}function fr(n){let e=Oe.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 Ei(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 pn(n){return[...n.querySelectorAll("button.hit")].filter(e=>e instanceof HTMLButtonElement)}function pr(n){return[...n.querySelectorAll("a.tree-file-link")].filter(e=>e instanceof HTMLAnchorElement)}function vi(n){let e=document.getElementById(`code-line-${String(n)}`);e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})}function Mi(n,e){let t=(n.getAttribute("data-cr-path")??"").trim(),r=(n.getAttribute("data-sp-path")??"").trim(),o=jt(e.mutable.documentedPairs,t,r);if(o&&Kt(o,e.filePathLabel,e.mutable.commentrayPathLabel)){e.docScrollEl.scrollTo({top:0,behavior:"smooth"});return}o&&Gr(o,null)}function Li(n,e,t){let r=t.mutable.commentrayPathLabel.trim(),o=e.trim();if(o.length>0&&k(o)!==k(r)){let i=jt(t.mutable.documentedPairs,o,"");if(i){Gr(i,n);return}return}qr(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),o=n.getAttribute("data-cr-path")?.trim()??"";if(t==="code"){vi(r);return}if(t==="path"){Mi(n,e);return}Li(r,o,e)}function ki(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()}],d=cn("full",u.length,u.length,!1);return ln(d,u,r)}let{rows:o,totalUnique:i}=qn(t.documentedPairs);if(o.length>0){let l=cn("commentray-and-paths",o.length,i,!1);return ln(l,o,r)}let s=e.trim();if(s.length===0)return null;let a=[{sourcePath:s,commentrayPath:t.commentrayPathLabel.trim()}],c=cn("commentray-and-paths",a.length,a.length,!0);return ln(c,a,r)}function z(n){n.focus({preventScroll:!0}),n.scrollIntoView({block:"nearest",inline:"nearest"})}function Hi(n,e){n.addEventListener("keydown",t=>{if(t.isComposing||n.hidden)return;let r=pn(n);if(r.length===0)return;let o=document.activeElement;if(!(o instanceof HTMLButtonElement)||!o.classList.contains("hit"))return;let i=r.indexOf(o);if(!(i<0)){if(t.key==="ArrowDown"&&i<r.length-1){z(r[i+1]),t.preventDefault();return}if(t.key==="ArrowUp"){if(i>0){z(r[i-1]),t.preventDefault();return}z(e),t.preventDefault()}}})}function xi(n,e,t){let{renderEmptyBrowsePreview:r,runSearch:o,cancelDebounceTimer:i,hitClickDeps:s}=t;n.addEventListener("keydown",a=>{if(a.isComposing)return;if(a.key==="ArrowDown"){if(!e.hidden){let l=pn(e);if(l.length>0&&document.activeElement===n){z(l[0]),a.preventDefault();return}}if(Se(n.value).length>0)return;r(),a.preventDefault();return}if(a.key!=="Enter")return;i(),Se(n.value).length>0&&o();let c=pn(e);!e.hidden&&c.length>0&&document.activeElement===n&&(a.preventDefault(),Wr(c[0],s))})}function Vr(n){let{scope:e,filePathLabel:t,mutable:r,rawCode:o,searchInput:i,searchClear:s,searchResults:a,docScrollEl:c}=n,l;function u(){clearTimeout(l),l=void 0}function d(){u(),i.value="",a.innerHTML="",a.hidden=!0}function m(){let p=ki(e,t,r);p!==null&&(a.hidden=!1,a.innerHTML=p)}function h(){let p=Se(i.value);if(p.length===0){a.hidden=!0,a.innerHTML="";return}let g=yi({scope:e,filePathLabel:t,commentrayPathLabel:r.commentrayPathLabel,rawCode:o,rawMd:r.rawMd,searcher:r.searcher,queryRaw:i.value,tokens:p,pathBlobWide:r.pathBlobWide,pathRowsForOrdering:r.pathRowsForOrdering.length>0?r.pathRowsForOrdering:void 0});a.hidden=!1,a.innerHTML=Ti(e,g,p,{currentCommentrayPath:r.commentrayPathLabel,currentSourcePath:t})}let f={mutable:r,docScrollEl:c,filePathLabel:t};a.addEventListener("click",p=>{let g=Ei(p.target,a);g&&Wr(g,f)}),Hi(a,i),i.addEventListener("input",()=>{clearTimeout(l),l=setTimeout(h,200)}),xi(i,a,{renderEmptyBrowsePreview:m,runSearch:h,cancelDebounceTimer:u,hitClickDeps:f}),s.addEventListener("click",d),document.addEventListener("keydown",p=>{if(p.key!=="Escape")return;let g=i.value.trim().length>0,w=document.activeElement===i,b=!a.hidden;!g&&!w&&!b||(d(),w&&i.blur(),p.preventDefault())})}function Ur(n,e,t,r,...o){let i=o.filter(a=>a instanceof HTMLElement),s=D(localStorage,n)==="1";if(t.checked=s,s){e.classList.add("wrap");for(let a of i)a.classList.add("wrap")}else{e.classList.remove("wrap");for(let a of i)a.classList.remove("wrap")}t.addEventListener("change",()=>{if(t.checked){e.classList.add("wrap");for(let a of i)a.classList.add("wrap");A(localStorage,n,"1")}else{e.classList.remove("wrap");for(let a of i)a.classList.remove("wrap");A(localStorage,n,"0")}r&&queueMicrotask(()=>{requestAnimationFrame(()=>{r(),requestAnimationFrame(()=>{r()})})})})}function Yr(n){let e=n.trim();if(!e)return[];try{let t=JSON.parse(R(e));if(!Array.isArray(t))return[];let r=[];for(let o of t){if(typeof o!="object"||o===null)continue;let i=o;if(typeof i.id=="string"&&typeof i.commentrayLine=="number"&&typeof i.sourceStart=="number"&&typeof i.sourceEnd=="number"){let s=i.markerViewportHalfOpen1Based,a=typeof s=="object"&&s!==null&&typeof s.lo=="number"&&typeof s.hiExclusive=="number"?{lo:s.lo,hiExclusive:s.hiExclusive}:{lo:i.sourceStart,hiExclusive:i.sourceEnd+1};r.push({id:i.id,commentrayLine:i.commentrayLine,sourceStart:i.sourceStart,sourceEnd:i.sourceEnd,markerViewportHalfOpen1Based:a})}}return r}catch{return[]}}function Qr(n=64){let e=q(),t=Math.max(0,e.scrollHeight-e.clientHeight);return t>0&&e.scrollTop>=t-n}function jr(n,e=64){let t=Math.max(0,n.scrollHeight-n.clientHeight);return t>0&&n.scrollTop>=t-e}function Kr(n){let e=n.getAttribute("data-commentray-line");return e===null||e===""?null:Number(e)}function gr(n,e){let t=[];for(let r of n){let o=Kr(r);o!==null&&t.push({line0:o,top:r.getBoundingClientRect().top})}return Dn(t,e)}function yr(n){for(let e=n.length-1;e>=0;e--){let t=n.item(e);if(!t)continue;let r=Kr(t);if(r!==null)return r}return null}function Xr(n,e="code-line-"){let t=n.querySelectorAll(`[id^="${e}"]`);if(t.length===0)return 1;if(!L(n)){if(Qr()){let u=t[t.length-1],d=/^(?:code-line-|code-md-line-)(\d+)$/.exec(u.id);return d?Number(d[1])+1:t.length}let i=n.getBoundingClientRect(),s=globalThis.innerHeight,a=Math.max(0,i.top),c=Math.min(s,i.bottom),l=a+j(c-a);for(let u of t)if(u.getBoundingClientRect().bottom>l-.001){let m=/^(?:code-line-|code-md-line-)(\d+)$/.exec(u.id);return m?Number(m[1])+1:1}return t.length}if(jr(n)){let i=t[t.length-1],s=/^(?:code-line-|code-md-line-)(\d+)$/.exec(i.id);return s?Number(s[1])+1:t.length}let o=n.getBoundingClientRect().top+n.clientTop+j(n.clientHeight);for(let i of t)if(i.getBoundingClientRect().bottom>o-.001){let a=/^(?:code-line-|code-md-line-)(\d+)$/.exec(i.id);return a?Number(a[1])+1:1}return t.length}function Sn(n){let e=n.querySelectorAll(".commentray-block-anchor");if(e.length===0)return null;if(!L(n)){if(Qr()){let l=yr(e);if(l!==null)return l}let o=n.getBoundingClientRect(),i=globalThis.innerHeight,s=Math.max(0,o.top),a=Math.min(i,o.bottom),c=s+j(a-s);return gr(e,c)}if(jr(n)){let o=yr(e);if(o!==null)return o}let r=n.getBoundingClientRect().top+n.clientTop+j(n.clientHeight);return gr(e,r)}function Jr(){let n=document.getElementById("shell");return n instanceof HTMLElement?n.getAttribute("data-page-breaks-enabled")==="true":!1}function Ci(n){if(!L(n)){let t=n.getBoundingClientRect(),r=globalThis.innerHeight,o=Math.max(0,t.top),i=Math.min(r,t.bottom);return o+j(i-o)}return n.getBoundingClientRect().top+n.clientTop+j(n.clientHeight)}function Ai(n){if(!Jr())return null;let e=Ci(n),t=Array.from(n.querySelectorAll(".commentray-page-break[data-next-source-viewport-line]"));for(let r of t){let o=r.getAttribute("data-next-source-viewport-line");if(!o)continue;let i=Number.parseInt(o,10);if(!Number.isFinite(i)||i<=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 d=Math.max(1,u-s),m=M((e-s)/d,0,1),f=globalThis.matchMedia("(max-width: 767px)").matches?.2:.35;return m<f?null:i-1}return null}var Bi=Math.max(320,1050);function Ii(n){let e=performance.now()+Bi;n.until=Math.max(n.until,e)}function Zr(n){return performance.now()<n.until}var Pi=200;function Ri(n,e,t,r){let o=performance.now();!bn()||o-e.lastEchoSkipTraceAt<Pi||(e.lastEchoSkipTraceAt=o,S(`wire.${n}.flush-skipped`,{reason:"partner-echo",echoUntilMs:Math.round(t.until),[`${n}ScrollTop`]:r.scrollTop}))}function br(n){let{axis:e,driverPane:t,state:r,syncingRef:o,ownEchoGate:i,partnerEchoGate:s,syncFromDriver:a}=n;return()=>{if(r.pendingRaf=0,Zr(i)){Ri(e,r,i,t),r.lastSeenTop=t.scrollTop;return}if(o.current!=="none"){S(`wire.${e}.flush-skipped`,{reason:"sync-in-progress",syncing:o.current});return}let c=t.scrollTop,l=c-r.lastSeenTop;r.lastSeenTop=c,o.current=e,Ii(s),S(`wire.${e}.driver`,{delta:l,[`${e}ScrollTop`]:c}),a(l),o.current="none"}}function Sr(n){let{driverPane:e,state:t,syncingRef:r,ownEchoGate:o,flush:i}=n;e.addEventListener("scroll",()=>{if(Zr(o)){t.lastSeenTop=e.scrollTop,t.pendingRaf!==0&&(cancelAnimationFrame(t.pendingRaf),t.pendingRaf=0);return}if(r.current!=="none"){t.lastSeenTop=e.scrollTop;return}t.pendingRaf!==0&&cancelAnimationFrame(t.pendingRaf),t.pendingRaf=requestAnimationFrame(i)},{passive:!0})}function eo(n,e,t,r){let o={current:"none"},i={until:0},s={until:0},a={lastSeenTop:n.scrollTop,pendingRaf:0,lastEchoSkipTraceAt:-1/0},c={lastSeenTop:e.scrollTop,pendingRaf:0,lastEchoSkipTraceAt:-1/0},l=br({axis:"code",driverPane:n,state:a,syncingRef:o,ownEchoGate:i,partnerEchoGate:s,syncFromDriver:t}),u=br({axis:"doc",driverPane:e,state:c,syncingRef:o,ownEchoGate:s,partnerEchoGate:i,syncFromDriver:r});Sr({driverPane:n,state:a,syncingRef:o,ownEchoGate:i,flush:l}),Sr({driverPane:e,state:c,syncingRef:o,ownEchoGate:s,flush:u})}function Tr(n,e){let{codePane:t,docPane:r,getLinks:o,lineIdPrefix:i,sticky:s}=n,a=_(r),c=i(),l=zr(t,r,o,c,s,n.allowProportionalMirror);nt(t,r,l);let u=_(r);S("code\u2192doc.apply",{driverDelta:e,lineIdPrefix:c,plan:ae(l),docScrollTopBefore:a,docScrollTopAfter:u,docDelta:u-a,codeScrollTop:t.scrollTop}),Ze({driverDelta:e,partnerBefore:a,partnerPane:r,axis:"code\u2192doc"})}function wr(n,e){let{codePane:t,docPane:r,getLinks:o,lineIdPrefix:i,sticky:s}=n,a=_(t),c=i(),l=_r(r,t,o,s,c,n.allowProportionalMirror);tt(t,r,l,c);let u=_(t);S("doc\u2192code.apply",{driverDelta:e,lineIdPrefix:c,plan:se(l),codeScrollTopBefore:a,codeScrollTopAfter:u,codeDelta:u-a,docScrollTop:r.scrollTop}),Ze({driverDelta:e,partnerBefore:a,partnerPane:t,axis:"doc\u2192code"})}function un(n,e,t,r,o,i){let s=i?.allowProportionalMirror!==!1,a=null,c=null,l={sourceSticky:{lockedId:null},commentraySticky:{lockedId:null},linksKey:{current:""}},u={codePane:n,docPane:e,getLinks:t,lineIdPrefix:r,sticky:l,allowProportionalMirror:s},d=y=>Tr(u,y),m=y=>wr(u,y),h=()=>{Tr(u,0)},f=()=>{wr(u,0)},p=()=>{if(s&&o?.()===!0){a={k:"mirrorW",ratio:He()};return}a=_r(e,n,t,l,r(),s)},g=()=>{if(!a)return;let y=a;a=null,y.k==="noop"&&y.skipProportionalFallbackOnFlip!==!0&&s&&(y=hn(e)),tt(n,e,y,r())},w=()=>{c=zr(n,e,t,r(),l,s)},b=()=>{if(!c)return;let y=c;c=null,y.k==="noop"&&s&&(y=fn(n)),nt(n,e,y)};return eo(n,e,d,m),{syncFromCodeToDoc:h,syncFromDocToCode:f,prepareMobileFlipToCode:p,finishMobileFlipToCode:g,prepareMobileFlipToDoc:w,finishMobileFlipToDoc:b}}function Di(n,e){let t=null,r=null,o=m=>{let h=_(e),f=fn(n);nt(n,e,f),S("code\u2192doc.apply",{mode:"proportional-shell",driverDelta:m,plan:ae(f),docScrollTopBefore:h,docScrollTopAfter:_(e),codeScrollTop:n.scrollTop}),Ze({driverDelta:m,partnerBefore:h,partnerPane:e,axis:"code\u2192doc"})},i=m=>{let h=_(n),f=hn(e);tt(n,e,f),S("doc\u2192code.apply",{mode:"proportional-shell",driverDelta:m,plan:se(f),codeScrollTopBefore:h,codeScrollTopAfter:_(n),docScrollTop:e.scrollTop}),Ze({driverDelta:m,partnerBefore:h,partnerPane:n,axis:"doc\u2192code"})},s=()=>{o(0)},a=()=>{i(0)},c=()=>{t=hn(e)},l=()=>{if(!t)return;let m=t;t=null,tt(n,e,m)},u=()=>{r=fn(n)},d=()=>{if(!r)return;let m=r;r=null,nt(n,e,m)};return eo(n,e,o,i),{syncFromCodeToDoc:s,syncFromDocToCode:a,prepareMobileFlipToCode:c,finishMobileFlipToCode:l,prepareMobileFlipToDoc:u,finishMobileFlipToDoc:d}}function to(n){let e=n.getBoundingClientRect();return(e.top+e.bottom)/2}function Er(n){return to(n)}function Fi(n,e,t,r){if(e){let a=document.getElementById(`commentray-block-${e.id}`);if(!a)return to(t);let c=a.getBoundingClientRect().top-3;return r?Rn(n,t,a):c}let i=n.getBoundingClientRect().bottom-4,s=n.children[n.children.length-1];if(s&&(i=Math.min(i,s.getBoundingClientRect().bottom-4)),r){let a=t.getBoundingClientRect().top+4,c=$e(n,t,null);i=Math.min(i,Math.max(a,c))}return i}function no(n,e){if(!n.startsWith(e))return null;let t=Number.parseInt(n.slice(e.length),10);return Number.isFinite(t)?t:null}function ro(n,e){let t=0,r=n.length-1,o=-1;for(;t<=r;){let i=t+r>>1;(n[i]?.line0??-1)>=e?(o=i,r=i-1):t=i+1}return o>=0?n[o]?.el??null:null}function Ni(n,e){let t=0,r=n.length-1,o=-1;for(;t<=r;){let i=t+r>>1;(n[i]?.line0??-1)<=e?(o=i,t=i+1):r=i-1}return o>=0?n[o]?.el??null:null}function Oi(n){return Array.from(document.querySelectorAll(`[id^="${n}"]`)).map(e=>({line0:no(e.id,n),el:e})).filter(e=>e.line0!==null).sort((e,t)=>e.line0-t.line0)}function _i(n,e,t,r){let o=()=>r();e.addEventListener("scroll",o,{passive:!0}),t.addEventListener("scroll",o,{passive:!0}),globalThis.addEventListener("resize",o);let i=new ResizeObserver(o);i.observe(n),i.observe(e),i.observe(t);let s=n.parentElement;s&&i.observe(s)}function zi(n,e,t){let r=Sn(e);return e.querySelector(".commentray-block-anchor")!==null&&r!==null?In(n,r):Bn(n,t())}function $i(n,e,t,r,o,i){let s=xn(r()),a=_e(s),c=e.getBoundingClientRect(),l=c.width,u=c.height;if(l<=0||u<=0||a.length===0){n.replaceChildren();return}let d=zi(s,t,o),m=Jr();n.setAttribute("viewBox",`0 0 ${String(l)} ${String(u)}`),n.setAttribute("preserveAspectRatio","none");let h=[],f=Array.from(document.querySelectorAll(`[id^="${i}"]`)).map(p=>({line0:no(p.id,i),el:p})).filter(p=>p.line0!==null).sort((p,g)=>p.line0-g.line0);for(let p=0;p<a.length;p++){let g=a[p];if(!g)continue;let w=An(s,g),b=Wt(g.sourceStart),y=Wt(g.sourceEnd),x=document.getElementById(`${i}${String(b)}`)??ro(f,b),C=document.getElementById(`${i}${String(y)}`)??Ni(f,y),v=document.getElementById(`commentray-block-${g.id}`);if(!x||!C||!v)continue;let H=Fi(t,w,v,m),I=Er(x),Z=Er(C),ee=v.getBoundingClientRect().top+2,F=Math.max(H,ee+4),le=N(I,c.top,u),vn=N(ee,c.top,u),Mn=N(Z,c.top,u),Ln=N(F,c.top,u),st=g.id===d?"gutter__rays-path gutter__rays-path--active":"gutter__rays-path",kn=`${st} gutter__rays-path--trail`,at=be(0,le.y,l,vn.y,{tension:.38,clipStart:le.clipped,clipEnd:vn.clipped}),ct=be(0,Mn.y,l,Ln.y,{tension:.38,clipStart:Mn.clipped,clipEnd:Ln.clipped}),yo=at.dotted?`<path class="${kn}" d="${at.dotted}" />`:"",bo=ct.dotted?`<path class="${kn}" d="${ct.dotted}" />`:"";h.push(`<g class="gutter__rays-block" data-commentray-block="${B(g.id)}"><path class="${st}" d="${at.solid}" />`+yo+`<path class="${st}" d="${ct.solid}" />`+bo+"</g>")}n.innerHTML=h.join("")}function qi(n){let{gutter:e,codePane:t,docScrollEl:r,getLinks:o,probeTopSourceLine1Based:i}=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 d(){u===0&&(u=globalThis.requestAnimationFrame(()=>{u=0,$i(l,e,r,o,i,s())}))}return _i(e,t,r,d),d(),globalThis.requestAnimationFrame(()=>{d(),globalThis.requestAnimationFrame(d)}),d}function Gi(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,o=typeof t=="string";return!(o!==(typeof r=="string")||!(typeof e.staticBrowseUrl=="string"&&e.staticBrowseUrl.trim().length>0)&&!o)}function Tn(n){let e=[];if(!Array.isArray(n))return e;for(let t of n)Gi(t)&&e.push(t);return e}function Wi(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 Vi(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:"",o=n.kind==="sourcePath"?t:r;return o?{kind:"path",line:e,text:o,spPath:t,crPath:r}:null}function Ui(n){if(!n||typeof n!="object")return[];let e=n.rows;if(!Array.isArray(e))return[];let t=[],r=0;for(let o of e){if(!o||typeof o!="object")continue;let i=o,s=Wi(i);if(s){t.push(s);continue}let a=Vi(i,r);a&&(t.push(a),r+=1)}return t}function oo(n){let e=n.trim();if(e==="")return[];try{let t=JSON.parse(R(e));return Tn(t)}catch{return[]}}function Yi(n,e){let t=e.sourcePath.split("/").filter(Boolean);if(t.length===0)return;let r=n;for(let o=0;o<t.length;o++){let i=t[o];if(i===void 0)continue;r.children.has(i)||r.children.set(i,{children:new Map,pairs:[]});let s=r.children.get(i);if(s===void 0)return;o===t.length-1&&s.pairs.push(e),r=s}}function Qi(n){let e=n.replace(/\\/g,"/").replace(/\/+$/,""),t=e.lastIndexOf("/");return t>=0?e.slice(t+1):e}function ji(n){return(n.replace(/\\/g,"/").replace(/\/+$/,"").split("/").filter(Boolean).at(-1)??"").replace(/\.md$/i,"")}function Ki(n,e){let t=Qi(n.sourcePath);if(!e)return t;let r=ji(n.commentrayPath);return r!==""&&r!==t?`${t} \xB7 ${r}`:t}function Xi(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 Ji(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 Zi(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 es(n,e,t){for(let r of n.querySelectorAll("a.tree-file-link")){if(!(r instanceof HTMLAnchorElement))continue;let o=r.getAttribute("data-pair-source-path")?.trim()??"",i=r.getAttribute("data-pair-commentray-path")?.trim()??"";if(Kt({sourcePath:o,commentrayPath:i},e,t)){r.classList.add("tree-file-link--current"),r.setAttribute("aria-current","page");break}}}function wn(){let n=document.getElementById("shell"),e=document.getElementById("documented-files-tree");if(!(n instanceof HTMLElement)||!(e instanceof HTMLElement))return;Zi(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||es(e,t,r)}function io(n){let e=[...n.children.keys()].sort((r,o)=>r.localeCompare(o));if(e.length===0)return"";let t=[];for(let r of e){let o=n.children.get(r);if(o!==void 0){if(o.children.size>0){let i=io(o);t.push(`<li><div class="tree-dir">${B(r)}</div>${i}</li>`)}if(o.pairs.length>0){let i=o.pairs.length>1;for(let s of o.pairs){let a=B(Ki(s,i)),c=B(Ji(s)),l=B(Xi(s)),u=B(k(s.sourcePath)),d=B(k(s.commentrayPath)),h=(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="${d}"${h} title="${c}">${a}</a></div></li>`)}}}}return`<ul>${t.join("")}</ul>`}function ts(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 o of e)Yi(r,o);n.innerHTML=io(r),wn()}function ns(n,e){let t=null,r=null;return async()=>t!==null?t:(r===null&&(r=(async()=>{if(e.length>0&&(t=oo(e),t.length>0))return;if(n.length===0){t=[];return}let o=await fetch(n,{credentials:"same-origin"});if(!o.ok)throw new Error(`nav json ${String(o.status)}`);let i=await o.json();t=Tn(i.documentedPairs)})()),await r,t??[])}function rs(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 o(){let s=n.querySelector("summary");return s instanceof HTMLElement?s:null}function i(){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=o();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",i),globalThis.addEventListener("resize",i),globalThis.addEventListener("scroll",i,!0),i}function os(){let n=document.getElementById("documented-files-filter");n instanceof HTMLInputElement&&z(n)}function vr(n){let e=n.querySelector("summary");e instanceof HTMLElement&&e.focus({preventScroll:!0})}function is(n){function e(t){!n.open||t.key!=="Escape"||(t.preventDefault(),n.open=!1,vr(n))}document.addEventListener("keydown",e,!0),document.addEventListener("pointerdown",t=>{if(!n.open)return;let r=t.target;r instanceof Node&&(n.contains(r)||(n.open=!1,vr(n)))},!0)}function ss(){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 o=n,i=e,s=o.getAttribute("data-nav-json-url")?.trim()??"",a=r?.getAttribute("data-documented-pairs-b64")?.trim()??"";if(s.length===0&&a.length===0)return;let c=rs(o),l=ns(s,a),u=null;function d(){if(u===null)return;let h=t instanceof HTMLInputElement?t.value:"",f=zn(u,h),p=h.trim().length>0;ts(i,f,p&&u.length>0&&f.length===0)}async function m(){try{u=await l(),d()}catch{u=null,i.innerHTML='<p class="nav-rail__doc-hub-hint" role="alert">Could not load the file list.</p>'}}o.addEventListener("toggle",()=>{c(),o.open&&globalThis.requestAnimationFrame(()=>{c(),os()}),o.open&&m()}),is(o),i.addEventListener("keydown",h=>{if(!o.open||h.isComposing)return;let f=h.target;if(!(f instanceof HTMLAnchorElement)||!f.classList.contains("tree-file-link"))return;let p=pr(i);if(p.length===0)return;let g=p.indexOf(f);if(!(g<0)){if(h.key==="ArrowDown"){g<p.length-1&&(z(p[g+1]),h.preventDefault());return}if(h.key==="ArrowUp"){if(g>0){z(p[g-1]),h.preventDefault();return}t instanceof HTMLInputElement&&(z(t),h.preventDefault())}}}),t instanceof HTMLInputElement&&(t.addEventListener("input",()=>{!o.open||u===null||d()}),t.addEventListener("keydown",h=>{if(!o.open||h.isComposing||h.key!=="ArrowDown")return;let f=pr(i);f.length!==0&&(z(f[0]),h.preventDefault())}))}function as(n,e,t,r,o){let i=!1,s=o;function a(l){if(!i)return;let u=e.getBoundingClientRect(),d=l.clientX-u.left,m=M(d/u.width*100,15,85);s=m,t.style.flex=`0 0 ${m}%`,e.style.setProperty("--split-pct",`${String(m)}%`)}function c(){i=!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(),i=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",window.addEventListener("mousemove",a),window.addEventListener("mouseup",c)})}var rt="commentray.codeCommentrayStatic.splitPct",so="commentray.codeCommentrayStatic.wrap",Me="commentray.codeCommentrayStatic.dualMobilePane",cs="commentray.codeCommentrayStatic.sourceMarkdownPaneMode",ls="commentray.codeCommentrayStatic.pageBreaksEnabled",xe="(max-width: 767px)";function J(n){return n==="code"?"code":"doc"}function Le(){return globalThis.matchMedia(xe).matches}function ot(n,e){if(e){n.setAttribute("data-mobile-single-pane","true");return}n.removeAttribute("data-mobile-single-pane")}function us(n){let e=document.getElementById("commentray-help-tour");e instanceof HTMLButtonElement&&e.addEventListener("click",()=>{rn(n,Le,{force:!0})})}function $(n){return n.getAttribute("data-source-pane-mode")==="rendered-markdown"?"rendered-markdown":"source"}function ds(n){let e=(n??"").trim().toLowerCase();return!(e==="0"||e==="false"||e==="off")}function ms(n){let e=ds(D(localStorage,ls));n.setAttribute("data-page-breaks-enabled",e?"true":"false")}function hs(n){let e=()=>{let t=Math.max(globalThis.innerHeight,document.documentElement?.clientHeight??0);if(!Number.isFinite(t)||t<=0)return;let r=Math.round(M(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 Mr(n){let e=document.querySelector("label.toolbar-wrap-lines");e instanceof HTMLLabelElement&&(e.hidden=$(n)==="rendered-markdown")}function Ee(n){return $(n)==="rendered-markdown"?"code-md-line-":"code-line-"}function fs(n,e){let t=()=>{if(n.getAttribute("data-layout")!=="dual"||!e.matches||J(n.getAttribute("data-dual-mobile-pane"))!=="doc")return;let r=document.getElementById("doc-pane-body");r instanceof HTMLElement&&ce(r)};queueMicrotask(()=>{t(),requestAnimationFrame(()=>{t(),requestAnimationFrame(t)})})}function ao(n,e,t){let r=()=>{e.hidden=!0,e.classList.remove("is-visible")},o=()=>{e.hidden=!1,e.classList.add("is-visible")},i=()=>{if(!t.matches){r();return}let s=n.getBoundingClientRect(),a=globalThis.innerHeight,c=10;s.bottom<c||s.top>a-c?o():r()};globalThis.addEventListener("scroll",i,{passive:!0}),globalThis.addEventListener("resize",i,{passive:!0}),t.addEventListener("change",i),globalThis.requestAnimationFrame(i)}function ps(n,e,t){let r=()=>{e.hidden=!0,e.classList.remove("is-visible")},o=()=>{e.hidden=!1,e.classList.add("is-visible")},i=()=>{if(n.hidden||n.getClientRects().length===0){r();return}let s=n.getBoundingClientRect(),a=globalThis.innerHeight,c=10;s.bottom<c||s.top>a-c?o():r()};globalThis.addEventListener("scroll",i,{passive:!0,signal:t}),globalThis.addEventListener("resize",i,{passive:!0,signal:t}),globalThis.requestAnimationFrame(i)}function Lr(n,e,t){let r=Le()&&J(n.getAttribute("data-dual-mobile-pane"))!=="code";e.hidden=r,r?(e.setAttribute("aria-hidden","true"),e.style.setProperty("display","none","important")):(e.removeAttribute("aria-hidden"),e.style.removeProperty("display")),t instanceof HTMLButtonElement&&(t.hidden=!0,t.classList.remove("is-visible"))}function gs(n,e){let t=n.querySelectorAll(`[id^="${e}"]`);if(t.length===0)return null;let r=L(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 o=t[t.length-1];if(!o)return null;let i=/^(?:code-line-|code-md-line-)(\d+)$/.exec(o.id);return i?.[1]?Number.parseInt(i[1],10):null}function ys(n,e,t,r,o,i){function s(){return Array.from(e.querySelectorAll('[data-source-markdown-body="true"]'))}function a(){let h=$(n)==="rendered-markdown",f=h?"markdown source":"rendered markdown",p=h?"rendered markdown":"markdown source",g=`Switch source pane to ${f}`,w=`Switch source pane to ${f} (currently ${p})`,b=y=>{y instanceof HTMLButtonElement&&(y.setAttribute("aria-pressed",h?"true":"false"),y.setAttribute("aria-label",g),y.title=w)};b(t),b(r)}a(),Mr(n),Lr(n,t,r);let c=()=>{Lr(n,t,r)};globalThis.addEventListener("resize",c,{passive:!0,signal:o}),globalThis.matchMedia(xe).addEventListener("change",c,{signal:o});let u=new MutationObserver(c);u.observe(n,{attributes:!0,attributeFilter:["data-dual-mobile-pane","data-source-pane-mode"]}),o.addEventListener("abort",()=>u.disconnect(),{once:!0});let d=()=>{let m=$(n),f=gs(e,m==="rendered-markdown"?"code-md-line-":"code-line-"),p=m==="rendered-markdown"?"source":"rendered-markdown",g=p==="rendered-markdown"?"code-md-line-":"code-line-";n.setAttribute("data-source-pane-mode",p),A(localStorage,cs,p),Le()&&J(n.getAttribute("data-dual-mobile-pane"))==="doc"&&(n.setAttribute("data-dual-mobile-pane","code"),A(localStorage,Me,"code")),a(),Mr(n);let w=!Le()||L(e);if(f!==null&&w){let b=e.querySelector(`#${g}${String(f)}`);b instanceof HTMLElement&&yn(e,b,0)}if(p==="rendered-markdown")for(let b of s())ce(b),ke(b);i?.()};t.addEventListener("click",d,{signal:o}),r&&(r.addEventListener("click",d,{signal:o}),ps(t,r,o))}function bs(n,e,t,r){let o=globalThis.matchMedia(xe);function i(){return J(D(localStorage,Me))}function s(){o.matches?(ot(n,!0),n.setAttribute("data-dual-mobile-pane",i())):(ot(n,!1),n.removeAttribute("data-dual-mobile-pane"))}let a=()=>{if(!o.matches)return;let l=J(n.getAttribute("data-dual-mobile-pane"))==="code"?"doc":"code",u=q().scrollTop;l==="code"?t.prepareMobileFlipToCode():t.prepareMobileFlipToDoc(),n.setAttribute("data-dual-mobile-pane",l),A(localStorage,Me,l),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(()=>{if(l==="code"){t.finishMobileFlipToCode();let d=q();if(u>5&&d.scrollTop<=1){let m=Math.max(0,d.scrollHeight-d.clientHeight);d.scrollTop=M(u,0,m)}}else t.finishMobileFlipToDoc()})}),l==="doc"&&fs(n,o)};e.addEventListener("click",a),r&&(r.addEventListener("click",a),ao(e,r,o)),o.addEventListener("change",s),s()}function co(n,e,t,r,o){let i=globalThis.matchMedia(xe);function s(){return J(D(localStorage,Me))}function a(){i.matches?(ot(n,!0),n.setAttribute("data-dual-mobile-pane",s())):(ot(n,!1),n.removeAttribute("data-dual-mobile-pane"))}let c=()=>{if(!i.matches)return;let u=J(n.getAttribute("data-dual-mobile-pane"))==="code"?"doc":"code";n.setAttribute("data-dual-mobile-pane",u),A(localStorage,Me,u),u==="doc"&&queueMicrotask(()=>{requestAnimationFrame(()=>{ce(n)})})};t.addEventListener("click",c),r&&(r.addEventListener("click",c),ao(t,r,i)),i.addEventListener("change",a),a()}var Xe=null,gn=null;function Ss(n){return n.getAttribute("data-stretch-buffer-sync")==="flow-synchronizer"}function Ts(n){return Array.from(n.querySelectorAll("tbody tr.stretch-row--block[data-commentray-stretch-sync-id]")).filter(e=>(e.dataset.commentrayStretchSyncId?.trim()??"").length>0)}function ws(n){let e=n.dataset.commentrayStretchSyncId?.trim()??"";if(e.length===0)return null;let t=n.querySelector(":scope > td.stretch-code"),r=n.querySelector(":scope > td.stretch-doc");return!(t instanceof HTMLTableCellElement)||!(r instanceof HTMLTableCellElement)?null:{id:e,codeRect:t.getBoundingClientRect(),docRect:r.getBoundingClientRect()}}function it(n){if(!(n instanceof HTMLElement))return null;let e=n.getBoundingClientRect();if(e.width<=0||e.height<=0)return null;let t=globalThis.getComputedStyle(n);return t.display==="none"||t.visibility==="hidden"?null:e}function Es(n,e){let t=$(e)==="rendered-markdown"?".source-pane--rendered-md":".source-pane--code",r=n.querySelector(t);if(it(r)!==null)return r;let o=n.querySelectorAll(".source-pane--code, .source-pane--rendered-md");for(let i of o)if(it(i)!==null)return i;return null}function vs(n,e){let t=Es(n,e),r=it(t);return r!==null?r.bottom:n.getBoundingClientRect().bottom}function Ms(n){let e=n.querySelector(":scope .stretch-doc-inner"),t=it(e);return t!==null?t.bottom:n.getBoundingClientRect().bottom}function Ls(n,e){let t=n.getBoundingClientRect(),r=t.top+Math.min(Math.max(t.height*.18,24),120);for(let o of e){let i=o.getBoundingClientRect();if(i.top<=r&&i.bottom>=r)return o.dataset.commentrayStretchSyncId?.trim()??null}return e[0]?.dataset.commentrayStretchSyncId?.trim()??null}function ks(n,e,t,r){let o=Ts(t),i=r.getBoundingClientRect(),s=i.width,a=i.height;if(s<=0||a<=0||o.length===0){n.replaceChildren();return}n.setAttribute("viewBox",`0 0 ${String(s)} ${String(a)}`),n.setAttribute("preserveAspectRatio","none");let c=Ls(e,o),l=[];for(let u of o){let d=ws(u);if(d===null)continue;let m=u.querySelector(":scope > td.stretch-code"),h=u.querySelector(":scope > td.stretch-doc");if(!(m instanceof HTMLTableCellElement)||!(h instanceof HTMLTableCellElement))continue;let f=vs(m,e),p=Ms(h),g=N(d.codeRect.top+1,i.top,a),w=N(d.docRect.top+1,i.top,a),b=N(f-1,i.top,a),y=N(p-1,i.top,a),x=d.id===c?"gutter__rays-path gutter__rays-path--active":"gutter__rays-path",C=`${x} gutter__rays-path--trail`,v=be(0,g.y,s,w.y,{tension:.38,clipStart:g.clipped,clipEnd:w.clipped}),H=be(0,b.y,s,y.y,{tension:.38,clipStart:b.clipped,clipEnd:y.clipped}),I=v.dotted?`<path class="${C}" d="${v.dotted}" />`:"",Z=H.dotted?`<path class="${C}" d="${H.dotted}" />`:"";l.push(`<g class="gutter__rays-block" data-commentray-block="${B(d.id)}"><path class="${x}" d="${v.solid}" />`+I+`<path class="${x}" d="${H.solid}" />`+Z+"</g>")}n.innerHTML=l.join("")}function Hs(n,e,t){t.querySelector(":scope > .gutter__rays")?.remove();let r="http://www.w3.org/2000/svg",o=document.createElement("div");o.className="gutter__rays",o.setAttribute("aria-hidden","true");let i=document.createElementNS(r,"svg");o.appendChild(i),t.appendChild(o);let s=0,a=()=>{s===0&&(s=globalThis.requestAnimationFrame(()=>{s=0,ks(i,n,e,t)}))},c=()=>a();n.addEventListener("scroll",c,{passive:!0}),globalThis.addEventListener("resize",c);let l=new ResizeObserver(c);return l.observe(n),l.observe(e),l.observe(t),a(),globalThis.requestAnimationFrame(()=>{a(),globalThis.requestAnimationFrame(a)}),{disconnect:()=>{s!==0&&globalThis.cancelAnimationFrame(s),n.removeEventListener("scroll",c),globalThis.removeEventListener("resize",c),l.disconnect(),o.remove()},request:a}}function xs(n,e){let t=document.getElementById("stretch-gutter");if(!(t instanceof HTMLElement))return;let r=Number.parseFloat(D(localStorage,rt)??""),o=M(Number.isFinite(r)?r:50,15,85);n.style.setProperty("--stretch-code-pct",`${String(o)}%`);let i=!1,s=c=>{if(!i)return;let l=e.getBoundingClientRect();if(l.width<=0)return;let u=c.clientX-l.left,d=M(u/l.width*100,15,85);n.style.setProperty("--stretch-code-pct",`${String(d)}%`),A(localStorage,rt,String(d)),gn?.request()},a=()=>{i&&(i=!1,document.body.style.cursor="",document.body.style.userSelect="",globalThis.removeEventListener("mousemove",s),globalThis.removeEventListener("mouseup",a))};t.addEventListener("mousedown",c=>{c.preventDefault(),i=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none",globalThis.addEventListener("mousemove",s),globalThis.addEventListener("mouseup",a)})}function lo(n,e){e instanceof HTMLTableElement&&Ss(n)?(Xe?.disconnect(),Xe=cr(e)):(Xe?.disconnect(),Xe=null);let t=document.getElementById("wrap-lines");t&&Ur(so,e,t,()=>{globalThis.dispatchEvent(new Event("resize"))});let r=document.getElementById("stretch-gutter");gn?.disconnect(),gn=e instanceof HTMLElement&&r instanceof HTMLElement?Hs(n,e,r):null,xs(n,e)}function Cs(n,e){if(n===null||typeof n!="object")return!1;let t=n;return typeof t.id!="string"||typeof t.docInnerHtmlB64!="string"?!1:e!=="stretch"?!0:typeof t.stretchSwapInnerB64=="string"&&t.stretchSwapInnerB64.trim().length>0}function uo(n){let e=n?.textContent?.trim()??"";if(!e)return null;try{let t=JSON.parse(R(e));if(!t||!Array.isArray(t.angles)||t.angles.length<2)return null;let r=t.layoutMode==="stretch"?"stretch":"dual";return t.angles.every(o=>Cs(o,r))?{...t,layoutMode:r}:null}catch{return null}}function As(n,e){let t=e.stretchSwapInnerB64;if(t===void 0||t.trim().length===0)return;n.innerHTML=R(t);let r=document.getElementById("code-pane");if(r instanceof HTMLElement){lo(n,r),En(n,r,()=>{globalThis.dispatchEvent(new Event("resize"))});let a=document.getElementById("mobile-pane-flip"),c=document.getElementById("mobile-pane-flip-scroll");a instanceof HTMLButtonElement&&co(n,r,a,c instanceof HTMLButtonElement?c:null,()=>{globalThis.dispatchEvent(new Event("resize"))})}n.setAttribute("data-scroll-block-links-b64",e.scrollBlockLinksB64),n.setAttribute("data-raw-md-b64",e.rawMdB64),n.setAttribute("data-search-commentray-path",e.commentrayPathForSearch);let o=k(e.commentrayPathForSearch);o.length>0?n.setAttribute("data-commentray-pair-commentray-path",o):n.removeAttribute("data-commentray-pair-commentray-path");let i=document.getElementById("nav-rail-doc-path");if(i){let a=e.commentrayPathForSearch.trim();i.textContent=a.length>0?a:"\u2014",a.length>0?i.setAttribute("title",a):i.removeAttribute("title")}let s=e.staticBrowseUrl?.trim()??"";if(s.length>0){let a=Qt(s,globalThis.location.pathname,globalThis.location.origin);n.setAttribute("data-commentray-pair-browse-href",a)}else{let a=e.commentrayOnGithubUrl?.trim();a?n.setAttribute("data-commentray-pair-browse-href",a):n.removeAttribute("data-commentray-pair-browse-href")}wn(),go(n),ce(n),ke(n),q().scrollTop=0}function Bs(n,e,t){if(e.layoutMode!=="stretch")return;let r=document.getElementById("angle-select");r&&r.addEventListener("change",()=>{let o=e.angles.find(i=>i.id===r.value);o&&(As(n,o),t?.(o))})}function Is(n,e){let t=mo();if(!t)return;let r=fo(n,e),{searchInput:o,searchClear:i,searchResults:s}=t;Vr({scope:r.scope,filePathLabel:r.filePathLabel,mutable:r.mutable,rawCode:r.rawCode,searchInput:o,searchClear:i,searchResults:s,docScrollEl:n}),ho(n,r.pathInit.documentedPairs,r.indexState,r.mutable,r.rebuildSearcher,o);let a=document.getElementById("commentray-multi-angle-b64"),c=uo(a);c?.layoutMode==="stretch"&&Bs(n,c,l=>{r.mutable.rawMd=R(l.rawMdB64),r.mutable.mdLines=r.mutable.rawMd.split(`
20
+ `),r.mutable.commentrayPathLabel=l.commentrayPathForSearch,r.rebuildSearcher(),o.value="",s.innerHTML="",s.hidden=!0})}function Ps(){let n=document.getElementById("doc-pane"),e=document.getElementById("gutter"),t=document.getElementById("wrap-lines");if(!n||!e||!t)return null;let r=document.getElementById("doc-pane-body"),o=r instanceof HTMLElement?r:n;return{docBody:r,docScrollEl:o,gutter:e,wrapCb:t}}function mo(){let n=document.getElementById("search-q"),e=document.getElementById("search-clear"),t=document.getElementById("search-results");return!n||!e||!t?null:{searchInput:n,searchClear:e,searchResults:t}}function Rs(n){let{scope:e,rawCode:t,filePathLabel:r,hubNavRows:o,pathRowsForOrdering:i,rawMd:s,commentrayPathLabel:a}=n;if(e!=="commentray-and-paths")return hr(e,t,s,r,a);if(o.length>0)return o;let c=i.length>0?i:hr(e,t,s,r,a).filter(u=>u.kind==="path"),l=s.split(`
21
+ `).map((u,d)=>({kind:"md",line:d,text:u,spPath:r,crPath:a}));return[...c,...l]}function Ds(n,e,t,r){if(e!=="commentray-and-paths")return{documentedPairs:[],pathRowsForOrdering:[],pathBlobWide:""};let o=oo(n.getAttribute("data-documented-pairs-b64")?.trim()??""),i=$n(o),s=i.length>0?i.map(a=>a.text).join(`
22
22
  `):[t,r].filter(a=>a.trim().length>0).join(`
23
- `);return{documentedPairs:o,pathRowsForOrdering:i,pathBlobWide:s}}function Ms(n,e){if(e.length===0)return n;if(n.length===0)return e;let t=new Map;for(let r of n){let o=(r.staticBrowseUrl??"").trim();o.length!==0&&t.set(k(r.commentrayPath),o)}return e.map(r=>{if((r.staticBrowseUrl??"").trim().length>0)return r;let i=t.get(k(r.commentrayPath));return i!==void 0&&i.length>0?{...r,staticBrowseUrl:i}:r})}function ks(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 oo(n,e,t,r,o,i){let s=ks(n);s.length!==0&&(async()=>{try{let a=await fetch(s,{credentials:"same-origin"});if(!a.ok)return;let c=await a.json(),l=gn(c.documentedPairs),u=Ms(e,l);u.length>0&&(t.documentedPairs=u,r.documentedPairs=u);let d=Fi(c);if(d.length===0)return;t.hubNavRows=d,t.pathRowsForOrdering=d.filter(h=>h.kind==="path"),r.pathRowsForOrdering=t.pathRowsForOrdering,r.pathBlobWide=t.pathRowsForOrdering.map(h=>h.text).join(`
24
- `),o(),i.value.trim().length>0&&i.dispatchEvent(new Event("input",{bubbles:!0}))}catch{}})()}function Hs(n){let{angle:e,docBody:t,mutable:r,rebuildSearcher:o,scrollLinksRef:i,shell:s,searchInput:a,searchResults:c,requestBlockRayRedraw:l}=n;t.innerHTML=R(e.docInnerHtmlB64),se(t),Ee(t),r.rawMd=R(e.rawMdB64),r.mdLines=r.rawMd.split(`
25
- `),r.commentrayPathLabel=e.commentrayPathForSearch,o(),i.current=_r(e.scrollBlockLinksB64),s.setAttribute("data-scroll-block-links-b64",e.scrollBlockLinksB64),s.setAttribute("data-search-commentray-path",e.commentrayPathForSearch);let u=k(e.commentrayPathForSearch);u.length>0?s.setAttribute("data-commentray-pair-commentray-path",u):s.removeAttribute("data-commentray-pair-commentray-path"),yn();let d=document.getElementById("nav-rail-doc-path");if(d){let p=e.commentrayPathForSearch.trim();d.textContent=p.length>0?p:"\u2014",p.length>0?d.setAttribute("title",p):d.removeAttribute("title")}let h=e.staticBrowseUrl?.trim()??"";if(h.length>0){let p=Wt(h,globalThis.location.pathname,globalThis.location.origin);s.setAttribute("data-commentray-pair-browse-href",p)}else{let p=e.commentrayOnGithubUrl?.trim();p?s.setAttribute("data-commentray-pair-browse-href",p):s.removeAttribute("data-commentray-pair-browse-href")}a&&c&&(a.value="",c.innerHTML="",c.hidden=!0),ao(s),l?.(),globalThis.requestAnimationFrame(()=>{l?.(),globalThis.requestAnimationFrame(()=>{l?.()})})}function xs(n,e){let{codePane:t,docScrollEl:r,docBody:o,shell:i,scrollLinksRef:s,multiPayload:a,mutable:c,rebuildSearcher:l,searchInput:u,searchResults:d,requestBlockRayRedraw:h}=n;if(a){let p=sn(t,r,()=>s.current,()=>Se(i),()=>z(i)==="rendered-markdown",e),m=document.getElementById("angle-select");return m&&o&&m.addEventListener("change",()=>{let f=a.angles.find(g=>g.id===m.value);f&&Hs({angle:f,docBody:o,mutable:c,rebuildSearcher:l,scrollLinksRef:s,shell:i,searchInput:u,searchResults:d,requestBlockRayRedraw:h})}),p}return s.current.length>0?sn(t,r,()=>s.current,()=>Se(i),()=>z(i)==="rendered-markdown",e):e.allowProportionalMirror?Mi(t,r):sn(t,r,()=>[],()=>Se(i),()=>z(i)==="rendered-markdown",e)}function Cs(n){let t=$n(n.shell.getAttribute("data-scroll-sync-strategy"))==="block-snap-only"?{allowProportionalMirror:!1}:{allowProportionalMirror:!0};return xs(n,t)}function As(n,e){function t(o){let i=o.replace(/^#/,"").trim();if(i.length===0)return null;let s=i.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 o=t(globalThis.location.hash);o!==null&&Rr(n,o,e())}globalThis.addEventListener("hashchange",r),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(r)})}function Bs(n){if(z(n)!=="rendered-markdown")return;let e=document.getElementById("code-pane");if(e instanceof HTMLElement)for(let t of e.querySelectorAll('[data-source-markdown-body="true"]'))se(t),Ee(t)}var an=null;function bn(n,e,t){let r=document.getElementById("source-markdown-pane-flip"),o=document.getElementById("source-markdown-pane-flip-scroll");r instanceof HTMLButtonElement&&(an?.abort(),an=new AbortController,ss(n,e,r,o instanceof HTMLButtonElement?o:null,an.signal,t),Bs(n))}function io(n,e){let{rawCodeB64:t,rawMdB64:r}=In(n,e),o=R(t),i=R(r),a={current:_r(n.getAttribute("data-scroll-block-links-b64")||"")},{scope:c,filePathLabel:l,commentrayPathLabel:u}=di(n),d=Ls(n,c,l,u),h={hubNavRows:[],documentedPairs:d.documentedPairs,pathRowsForOrdering:d.pathRowsForOrdering},p={rawMd:i,mdLines:i.split(`
26
- `),commentrayPathLabel:u,searcher:lr([]),pathBlobWide:d.pathBlobWide,pathRowsForOrdering:h.pathRowsForOrdering,documentedPairs:h.documentedPairs};function m(){p.searcher=lr(Es({scope:c,rawCode:o,filePathLabel:l,hubNavRows:h.hubNavRows,pathRowsForOrdering:h.pathRowsForOrdering,rawMd:p.rawMd,commentrayPathLabel:p.commentrayPathLabel}))}return m(),{rawCode:o,rawMd:i,scrollLinksRef:a,scope:c,filePathLabel:l,commentrayPathLabel:u,pathInit:d,indexState:h,mutable:p,rebuildSearcher:m}}function Is(n,e){let t=vs();if(!t)return;let{docBody:r,docScrollEl:o,gutter:i,wrapCb:s}=t,a=ro(),c=io(n,e);if(Ee(document),a){let{searchInput:E,searchClear:H,searchResults:I}=a;Nr({scope:c.scope,filePathLabel:c.filePathLabel,mutable:c.mutable,rawCode:c.rawCode,searchInput:E,searchClear:H,searchResults:I,docScrollEl:o}),oo(n,c.pathInit.documentedPairs,c.indexState,c.mutable,c.rebuildSearcher,E)}let l=parseFloat(D(localStorage,Ze)||"46"),u=L(Number.isFinite(l)?l:46,15,85);e.style.flex=`0 0 ${u}%`,n.style.setProperty("--split-pct",`${String(u)}%`);let d=document.getElementById("doc-pane"),h=d instanceof HTMLElement?d:null,p=document.getElementById("code-pane-markdown-body"),m={};Or(Jr,e,s,()=>{m.request?.()},h,r,p instanceof HTMLElement?p:null),Ki(Ze,n,e,i,u);let f=document.getElementById("commentray-multi-angle-b64"),g=no(f),b=g!==null||c.scrollLinksRef.current.length>0?Ii({gutter:i,codePane:e,docScrollEl:o,getLinks:()=>c.scrollLinksRef.current,probeTopSourceLine1Based:()=>Gr(e,Se(n)),sourceLineIdPrefix:()=>Se(n)}):void 0;m.request=b;let y=Cs({codePane:e,docScrollEl:o,docBody:r,shell:n,scrollLinksRef:c.scrollLinksRef,multiPayload:g,mutable:c.mutable,rebuildSearcher:c.rebuildSearcher,searchInput:a?.searchInput,searchResults:a?.searchResults,requestBlockRayRedraw:b}),x=document.getElementById("mobile-pane-flip"),C=document.getElementById("mobile-pane-flip-scroll");x instanceof HTMLButtonElement&&as(n,x,y,C instanceof HTMLButtonElement?C:null),bn(n,e,()=>{b?.()}),Zt(n,ve),As(o,()=>c.mutable.mdLines.length)}function Ps(n){return n==="light"?"Light":n==="dark"?"Dark":"System"}function Rs(n,e){let t=Ps(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 Ds(){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,o=e,i=t,s=qe(D(localStorage,Qt));jt(s);let a=!1;function c(){o.dataset.commentrayTriggerMode=s,o.setAttribute("aria-expanded",a?"true":"false"),Rs(o,s);for(let m of i.querySelectorAll("[data-commentray-theme-value]")){let f=qe(m.dataset.commentrayThemeValue??"");m.setAttribute("aria-checked",f===s?"true":"false")}}function l(){a=!0,i.removeAttribute("hidden"),c(),(i.querySelector('[role="menuitemradio"][aria-checked="true"]')??i.querySelector('[role="menuitemradio"]'))?.focus()}function u(){a=!1,i.setAttribute("hidden",""),c()}function d(m){s=m,A(localStorage,Qt,m),jt(m),c()}o.addEventListener("click",m=>{m.preventDefault(),m.stopPropagation(),a?u():l()}),o.addEventListener("contextmenu",m=>{m.preventDefault(),a&&u(),d(_n(s))});for(let m of i.querySelectorAll("[data-commentray-theme-value]"))m.addEventListener("click",f=>{f.stopPropagation();let g=qe(m.dataset.commentrayThemeValue??"");d(g),u(),o.focus()});function h(m){if(!a)return;let f=m.target;f instanceof Node&&(r.contains(f)||u())}function p(m){!a||m.key!=="Escape"||(m.preventDefault(),m.stopPropagation(),u(),o.focus())}document.addEventListener("mousedown",h,!0),document.addEventListener("touchstart",h,!0),document.addEventListener("keydown",p,!0),c()}function Fs(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 Tr(n,e){return new URL(n,e).toString()}function Ns(n,e){let t=n.getAttribute("data-nav-search-json-url")?.trim()??"";t.length>0&&n.setAttribute("data-nav-search-json-url",Tr(t,e));let r=document.getElementById("documented-files-hub");if(r instanceof HTMLElement){let o=r.getAttribute("data-nav-json-url")?.trim()??"";o.length>0&&r.setAttribute("data-nav-json-url",Tr(o,e))}}function Os(n,e){let t=n.getAttribute("data-commentray-pair-browse-href")?.trim()??"";t.length>0&&$e(t)&&n.setAttribute("data-commentray-pair-browse-href",Y(t,e,globalThis.location.origin))}function _s(){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 o=pn(t);return o===null||!Number.isFinite(o)||o<0?null:`commentray-md-line-${String(o)}`}function zs(n){if((n.getAttribute("data-layout")??"dual")!=="dual")return;let e=globalThis.location.pathname,t=globalThis.location.href;Ns(n,t),Os(n,e)}function so(n){let t=(n.getAttribute("data-commentray-pair-browse-href")??"").trim();return($e(t)&&t.length>0?Y(t,globalThis.location.pathname,globalThis.location.origin):Fs(t))??globalThis.location.href}function $s(){let n=[],e=o=>{let i=o.trim();i.length!==0&&(n.includes(i)||n.push(i))},t=document.getElementById("angle-select");if(t instanceof HTMLSelectElement){let o=t.value.trim();o.length>0&&e(`angle-${encodeURIComponent(o)}`)}let r=_s();return r&&e(r),n.length>0?`#${n.join("&")}`:""}function qs(n){let e=new URL(so(n),globalThis.location.href),t=$s();return e.hash=t.length>0?t.slice(1):"",e.toString()}function ao(n){let e;try{e=new URL(so(n),globalThis.location.href)}catch{return}if(e.origin!==globalThis.location.origin)return;e.hash="";let t=new URL(globalThis.location.href);t.pathname===e.pathname&&t.search===e.search||globalThis.location.assign(e.toString())}async function Gs(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 Ws(){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 o=qs(n);await Gs(o)&&(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 wr(){Xo(),Ws(),Ds(),ji();let n=document.getElementById("shell"),e=document.getElementById("code-pane");if(!n||!e)return;if(ts(n),ns(n),Zi(n),(n.getAttribute("data-layout")||"dual")==="stretch"){to(n,e),ws(n,e),bn(n,e,()=>{globalThis.dispatchEvent(new Event("resize"))});let r=document.getElementById("mobile-pane-flip"),o=document.getElementById("mobile-pane-flip-scroll");r instanceof HTMLButtonElement&&eo(n,e,r,o instanceof HTMLButtonElement?o:null,()=>{globalThis.dispatchEvent(new Event("resize"))});return}Is(n,e),zs(n)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",wr):wr();})();
23
+ `);return{documentedPairs:o,pathRowsForOrdering:i,pathBlobWide:s}}function Fs(n,e){if(e.length===0)return n;if(n.length===0)return e;let t=new Map;for(let r of n){let o=(r.staticBrowseUrl??"").trim();o.length!==0&&t.set(k(r.commentrayPath),o)}return e.map(r=>{if((r.staticBrowseUrl??"").trim().length>0)return r;let i=t.get(k(r.commentrayPath));return i!==void 0&&i.length>0?{...r,staticBrowseUrl:i}:r})}function Ns(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 ho(n,e,t,r,o,i){let s=Ns(n);s.length!==0&&(async()=>{try{let a=await fetch(s,{credentials:"same-origin"});if(!a.ok)return;let c=await a.json(),l=Tn(c.documentedPairs),u=Fs(e,l);u.length>0&&(t.documentedPairs=u,r.documentedPairs=u);let d=Ui(c);if(d.length===0)return;t.hubNavRows=d,t.pathRowsForOrdering=d.filter(m=>m.kind==="path"),r.pathRowsForOrdering=t.pathRowsForOrdering,r.pathBlobWide=t.pathRowsForOrdering.map(m=>m.text).join(`
24
+ `),o(),i.value.trim().length>0&&i.dispatchEvent(new Event("input",{bubbles:!0}))}catch{}})()}function Os(n){let{angle:e,docBody:t,mutable:r,rebuildSearcher:o,scrollLinksRef:i,shell:s,searchInput:a,searchResults:c,requestBlockRayRedraw:l}=n;t.innerHTML=R(e.docInnerHtmlB64),ce(t),ke(t),r.rawMd=R(e.rawMdB64),r.mdLines=r.rawMd.split(`
25
+ `),r.commentrayPathLabel=e.commentrayPathForSearch,o(),i.current=Yr(e.scrollBlockLinksB64),s.setAttribute("data-scroll-block-links-b64",e.scrollBlockLinksB64),s.setAttribute("data-search-commentray-path",e.commentrayPathForSearch);let u=k(e.commentrayPathForSearch);u.length>0?s.setAttribute("data-commentray-pair-commentray-path",u):s.removeAttribute("data-commentray-pair-commentray-path"),wn();let d=document.getElementById("nav-rail-doc-path");if(d){let h=e.commentrayPathForSearch.trim();d.textContent=h.length>0?h:"\u2014",h.length>0?d.setAttribute("title",h):d.removeAttribute("title")}let m=e.staticBrowseUrl?.trim()??"";if(m.length>0){let h=Qt(m,globalThis.location.pathname,globalThis.location.origin);s.setAttribute("data-commentray-pair-browse-href",h)}else{let h=e.commentrayOnGithubUrl?.trim();h?s.setAttribute("data-commentray-pair-browse-href",h):s.removeAttribute("data-commentray-pair-browse-href")}a&&c&&(a.value="",c.innerHTML="",c.hidden=!0),go(s),l?.(),globalThis.requestAnimationFrame(()=>{l?.(),globalThis.requestAnimationFrame(()=>{l?.()})})}function _s(n,e){let{codePane:t,docScrollEl:r,docBody:o,shell:i,scrollLinksRef:s,multiPayload:a,mutable:c,rebuildSearcher:l,searchInput:u,searchResults:d,requestBlockRayRedraw:m}=n;if(a){let h=un(t,r,()=>s.current,()=>Ee(i),()=>$(i)==="rendered-markdown",e),f=document.getElementById("angle-select");return f&&o&&f.addEventListener("change",()=>{let p=a.angles.find(g=>g.id===f.value);p&&Os({angle:p,docBody:o,mutable:c,rebuildSearcher:l,scrollLinksRef:s,shell:i,searchInput:u,searchResults:d,requestBlockRayRedraw:m})}),h}return s.current.length>0?un(t,r,()=>s.current,()=>Ee(i),()=>$(i)==="rendered-markdown",e):e.allowProportionalMirror?Di(t,r):un(t,r,()=>[],()=>Ee(i),()=>$(i)==="rendered-markdown",e)}function zs(n){let t=Vn(n.shell.getAttribute("data-scroll-sync-strategy"))==="block-snap-only"?{allowProportionalMirror:!1}:{allowProportionalMirror:!0};return _s(n,t)}function $s(n,e){function t(o){let i=o.replace(/^#/,"").trim();if(i.length===0)return null;let s=i.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 o=t(globalThis.location.hash);o!==null&&qr(n,o,e())}globalThis.addEventListener("hashchange",r),globalThis.requestAnimationFrame(()=>{globalThis.requestAnimationFrame(r)})}function qs(n){if($(n)!=="rendered-markdown")return;let e=document.getElementById("code-pane");if(e instanceof HTMLElement)for(let t of e.querySelectorAll('[data-source-markdown-body="true"]'))ce(t),ke(t)}var dn=null;function En(n,e,t){let r=document.getElementById("source-markdown-pane-flip"),o=document.getElementById("source-markdown-pane-flip-scroll");r instanceof HTMLButtonElement&&(dn?.abort(),dn=new AbortController,ys(n,e,r,o instanceof HTMLButtonElement?o:null,dn.signal,t),qs(n))}function fo(n,e){let{rawCodeB64:t,rawMdB64:r}=Fn(n,e),o=R(t),i=R(r),a={current:Yr(n.getAttribute("data-scroll-block-links-b64")||"")},{scope:c,filePathLabel:l,commentrayPathLabel:u}=wi(n),d=Ds(n,c,l,u),m={hubNavRows:[],documentedPairs:d.documentedPairs,pathRowsForOrdering:d.pathRowsForOrdering},h={rawMd:i,mdLines:i.split(`
26
+ `),commentrayPathLabel:u,searcher:fr([]),pathBlobWide:d.pathBlobWide,pathRowsForOrdering:m.pathRowsForOrdering,documentedPairs:m.documentedPairs};function f(){h.searcher=fr(Rs({scope:c,rawCode:o,filePathLabel:l,hubNavRows:m.hubNavRows,pathRowsForOrdering:m.pathRowsForOrdering,rawMd:h.rawMd,commentrayPathLabel:h.commentrayPathLabel}))}return f(),{rawCode:o,rawMd:i,scrollLinksRef:a,scope:c,filePathLabel:l,commentrayPathLabel:u,pathInit:d,indexState:m,mutable:h,rebuildSearcher:f}}function Gs(n,e){let t=Ps();if(!t)return;let{docBody:r,docScrollEl:o,gutter:i,wrapCb:s}=t,a=mo(),c=fo(n,e);if(ke(document),a){let{searchInput:v,searchClear:H,searchResults:I}=a;Vr({scope:c.scope,filePathLabel:c.filePathLabel,mutable:c.mutable,rawCode:c.rawCode,searchInput:v,searchClear:H,searchResults:I,docScrollEl:o}),ho(n,c.pathInit.documentedPairs,c.indexState,c.mutable,c.rebuildSearcher,v)}let l=parseFloat(D(localStorage,rt)||"46"),u=M(Number.isFinite(l)?l:46,15,85);e.style.flex=`0 0 ${u}%`,n.style.setProperty("--split-pct",`${String(u)}%`);let d=document.getElementById("doc-pane"),m=d instanceof HTMLElement?d:null,h=document.getElementById("code-pane-markdown-body"),f={};Ur(so,e,s,()=>{f.request?.()},m,r,h instanceof HTMLElement?h:null),as(rt,n,e,i,u);let p=document.getElementById("commentray-multi-angle-b64"),g=uo(p),b=g!==null||c.scrollLinksRef.current.length>0?qi({gutter:i,codePane:e,docScrollEl:o,getLinks:()=>c.scrollLinksRef.current,probeTopSourceLine1Based:()=>Xr(e,Ee(n)),sourceLineIdPrefix:()=>Ee(n)}):void 0;f.request=b;let y=zs({codePane:e,docScrollEl:o,docBody:r,shell:n,scrollLinksRef:c.scrollLinksRef,multiPayload:g,mutable:c.mutable,rebuildSearcher:c.rebuildSearcher,searchInput:a?.searchInput,searchResults:a?.searchResults,requestBlockRayRedraw:b}),x=document.getElementById("mobile-pane-flip"),C=document.getElementById("mobile-pane-flip-scroll");x instanceof HTMLButtonElement&&bs(n,x,y,C instanceof HTMLButtonElement?C:null),En(n,e,()=>{b?.()}),rn(n,Le),$s(o,()=>c.mutable.mdLines.length)}function Ws(n){return n==="light"?"Light":n==="dark"?"Dark":"System"}function Vs(n,e){let t=Ws(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 Us(){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,o=e,i=t,s=Ve(D(localStorage,Jt));Zt(s);let a=!1;function c(){o.dataset.commentrayTriggerMode=s,o.setAttribute("aria-expanded",a?"true":"false"),Vs(o,s);for(let f of i.querySelectorAll("[data-commentray-theme-value]")){let p=Ve(f.dataset.commentrayThemeValue??"");f.setAttribute("aria-checked",p===s?"true":"false")}}function l(){a=!0,i.removeAttribute("hidden"),c(),(i.querySelector('[role="menuitemradio"][aria-checked="true"]')??i.querySelector('[role="menuitemradio"]'))?.focus()}function u(){a=!1,i.setAttribute("hidden",""),c()}function d(f){s=f,A(localStorage,Jt,f),Zt(f),c()}o.addEventListener("click",f=>{f.preventDefault(),f.stopPropagation(),a?u():l()}),o.addEventListener("contextmenu",f=>{f.preventDefault(),a&&u(),d(Gn(s))});for(let f of i.querySelectorAll("[data-commentray-theme-value]"))f.addEventListener("click",p=>{p.stopPropagation();let g=Ve(f.dataset.commentrayThemeValue??"");d(g),u(),o.focus()});function m(f){if(!a)return;let p=f.target;p instanceof Node&&(r.contains(p)||u())}function h(f){!a||f.key!=="Escape"||(f.preventDefault(),f.stopPropagation(),u(),o.focus())}document.addEventListener("mousedown",m,!0),document.addEventListener("touchstart",m,!0),document.addEventListener("keydown",h,!0),c()}function Ys(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 kr(n,e){return new URL(n,e).toString()}function Qs(n,e){let t=n.getAttribute("data-nav-search-json-url")?.trim()??"";t.length>0&&n.setAttribute("data-nav-search-json-url",kr(t,e));let r=document.getElementById("documented-files-hub");if(r instanceof HTMLElement){let o=r.getAttribute("data-nav-json-url")?.trim()??"";o.length>0&&r.setAttribute("data-nav-json-url",kr(o,e))}}function js(n,e){let t=n.getAttribute("data-commentray-pair-browse-href")?.trim()??"";t.length>0&&We(t)&&n.setAttribute("data-commentray-pair-browse-href",Q(t,e,globalThis.location.origin))}function Ks(){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 o=Sn(t);return o===null||!Number.isFinite(o)||o<0?null:`commentray-md-line-${String(o)}`}function Xs(n){if((n.getAttribute("data-layout")??"dual")!=="dual")return;let e=globalThis.location.pathname,t=globalThis.location.href;Qs(n,t),js(n,e)}function po(n){let t=(n.getAttribute("data-commentray-pair-browse-href")??"").trim();return(We(t)&&t.length>0?Q(t,globalThis.location.pathname,globalThis.location.origin):Ys(t))??globalThis.location.href}function Js(){let n=[],e=o=>{let i=o.trim();i.length!==0&&(n.includes(i)||n.push(i))},t=document.getElementById("angle-select");if(t instanceof HTMLSelectElement){let o=t.value.trim();o.length>0&&e(`angle-${encodeURIComponent(o)}`)}let r=Ks();return r&&e(r),n.length>0?`#${n.join("&")}`:""}function Zs(n){let e=new URL(po(n),globalThis.location.href),t=Js();return e.hash=t.length>0?t.slice(1):"",e.toString()}function go(n){let e;try{e=new URL(po(n),globalThis.location.href)}catch{return}if(e.origin!==globalThis.location.origin)return;e.hash="";let t=new URL(globalThis.location.href);t.pathname===e.pathname&&t.search===e.search||globalThis.location.assign(e.toString())}async function ea(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 ta(){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 o=Zs(n);await ea(o)&&(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 Hr(){ai(),ta(),Us(),ss();let n=document.getElementById("shell"),e=document.getElementById("code-pane");if(!n||!e)return;if(ms(n),hs(n),us(n),(n.getAttribute("data-layout")||"dual")==="stretch"){lo(n,e),Is(n,e),En(n,e,()=>{globalThis.dispatchEvent(new Event("resize"))});let r=document.getElementById("mobile-pane-flip"),o=document.getElementById("mobile-pane-flip-scroll");r instanceof HTMLButtonElement&&co(n,e,r,o instanceof HTMLButtonElement?o:null,()=>{globalThis.dispatchEvent(new Event("resize"))});return}Gs(n,e),Xs(n)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Hr):Hr();})();