UNPKG

highlight-it

Version:

A lightweight syntax highlighting library with themes, line numbers, and copy functionality

7 lines 58.8 kB
/*!
 * HighlightIt v0.2.7
 * https://github.com/TN3W/highlight-it
 * (c) 2025 TN3W
 * Released under the Apache 2.0 License
 */
(t=>{let P={supports:{requestAnimationFrame:"function"==typeof requestAnimationFrame,ResizeObserver:"function"==typeof ResizeObserver,MutationObserver:"function"==typeof MutationObserver,classList:"classList"in document.documentElement&&void 0!==document.documentElement.classList,dataset:"dataset"in document.documentElement&&void 0!==document.documentElement.dataset,clipboard:"clipboard"in navigator,clipboardItem:"undefined"!=typeof ClipboardItem,touch:"ontouchstart"in window||0<navigator.maxTouchPoints||0<navigator.msMaxTouchPoints,getBoundingClientRect:"getBoundingClientRect"in document.documentElement,animation:"Animation"in window&&"animate"in document.documentElement,cssHas:(()=>{try{return document.querySelector(":has(*)"),!0}catch{return!1}})(),download:void 0!==document.createElement("a").download,blob:"undefined"!=typeof Blob,URL:"undefined"!=typeof URL&&"function"==typeof URL.createObjectURL,TextEncoder:"undefined"!=typeof TextEncoder,crypto:"undefined"!=typeof crypto&&void 0!==crypto.subtle,BigInt:"undefined"!=typeof BigInt,padStart:"function"==typeof String.prototype.padStart},initStringPadding:function(){this.supports.padStart||(String.prototype.padStart=function(t,i){return t>>=0,i=String(void 0!==i?i:" "),t<=this.length?String(this):(i.length<(t-=this.length)&&(i+=i.repeat(t/i.length)),i.slice(0,t)+String(this))})},objectEntries:function(t){if("function"==typeof Object.entries)return Object.entries(t);var i,e=[];for(i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.push([i,t[i]]);return e},init:function(){this.initStringPadding()},requestAnimationFrame:(()=>window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return window.setTimeout(t,1e3/60)})(),TextEncoder:(()=>"undefined"!=typeof TextEncoder?TextEncoder:class{constructor(){this.encoding="utf-8"}encode(t){if(null==t)return new Uint8Array;let e=String(t),h=-1,l=e.length,i=0;for(let t=0;t<l;t++){var o=e.charCodeAt(t);o<128?i+=1:o<2048?i+=2:o<55296||57344<=o?i+=3:(t++,i+=4)}var a=new Uint8Array(i);for(let i=0;i<l;i++){let t=e.charCodeAt(i);if(55296<=t&&t<57344){if(++i>=l)break;var r=e.charCodeAt(i);56320<=r&&r<57344?t=65536+(t-55296<<10)+(r-56320):i--}t<128?a[++h]=t:(t<2048?a[++h]=192|t>>6:(t<65536?a[++h]=224|t>>12:(a[++h]=240|t>>18,a[++h]=128|t>>12&63),a[++h]=128|t>>6&63),a[++h]=128|63&t)}return a}})(),simpleHash:function(i){if(!i)return"h-000000000000";let e=0;for(let t=0;t<i.length;t++){var h=i.charCodeAt(t);e=(e<<5)-e+h,e&=e}return"h-"+Math.abs(e).toString(16).padStart(12,"0").substring(0,12)},BigIntPolyfill:(()=>"undefined"!=typeof BigInt?null:class e{constructor(t){this.value=String(t)}static from(t){return new e(t)}divide(t){var t="object"==typeof t?parseInt(t.value):parseInt(t),i=parseInt(this.value),i=Math.floor(i/t);return new e(i)}modulo(t){t="object"==typeof t?parseInt(t.value):parseInt(t);return parseInt(this.value)%t}shiftLeft(t){t=parseInt(this.value)<<t;return new e(t)}or(t){t="object"==typeof t?parseInt(t.value):parseInt(t),t=parseInt(this.value)|t;return new e(t)}toString(){return this.value}valueOf(){return parseInt(this.value)}})(),MutationObserver:(()=>"undefined"!=typeof MutationObserver?MutationObserver:class{constructor(t){this.callback=t,this.observed=new Map,this.timeout=null,this.pollInterval=100}observe(t,i){t&&i&&(i={element:t,options:i,attributes:this.t(t),characterData:i.characterData?t.textContent:null,childList:i.childList?this.i(t):null},this.observed.set(t,i),this.timeout||this.h())}disconnect(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.observed.clear()}takeRecords(){return[]}h(){this.timeout=setTimeout(()=>{let g=[];this.observed.forEach((t,i)=>{if(document.contains(i)){if(t.options.attributes){var e,h,l=this.t(i),o=t.attributes;for(e of P.objectEntries(o)){var a=e[0],r=e[1];a in l&&l[a]===r||g.push({type:"attributes",target:i,attributeName:a,oldValue:t.options.attributeOldValue?r:null})}for(h in l)h in o||g.push({type:"attributes",target:i,attributeName:h,oldValue:null});t.attributes=l}var n;t.options.characterData&&(n=i.textContent)!==t.characterData&&(g.push({type:"characterData",target:i,oldValue:t.options.characterDataOldValue?t.characterData:null}),t.characterData=n),t.options.childList&&((n=this.i(i)).length!==t.childList.length&&g.push({type:"childList",target:i,addedNodes:[],removedNodes:[]}),t.childList=n)}else this.observed.delete(i)}),0<g.length&&this.callback(g),0<this.observed.size?this.h():this.timeout=null},this.pollInterval)}t(t){var i={},e=t.attributes;if(e)for(let t=0;t<e.length;t++){var h=e[t];i[h.name]=h.value}return i}i(t){return Array.from(t.childNodes)}})(),ResizeObserver:(()=>"function"==typeof ResizeObserver?ResizeObserver:class{constructor(t){this.callback=t,this.observedElements=new Set,this.observer=new MutationObserver(this.handleMutation.bind(this))}observe(t){this.observedElements.has(t)||(this.observedElements.add(t),this.observer.observe(t,{attributes:!0,attributeFilter:["style","class"]}),this.checkSize(t))}unobserve(t){this.observedElements.delete(t),this.observer.unobserve(t)}disconnect(){this.observer.disconnect(),this.observedElements.clear()}handleMutation(t){t.forEach(t=>{t.target&&this.observedElements.has(t.target)&&this.checkSize(t.target)})}checkSize(t){this.callback([{target:t,contentRect:{width:t.offsetWidth,height:t.offsetHeight}}])}})(),getBoundingClientRect:function(t){if(!t)return{top:0,right:0,bottom:0,left:0,width:0,height:0};if(this.supports.getBoundingClientRect)try{return t.getBoundingClientRect()}catch{}var i={top:t.offsetTop,left:t.offsetLeft,width:t.offsetWidth,height:t.offsetHeight};i.right=i.left+i.width,i.bottom=i.top+i.height;let e=t.offsetParent;for(;e;)i.top+=e.offsetTop,i.left+=e.offsetLeft,e=e.offsetParent;return i.top-=window.scrollY||document.documentElement.scrollTop||0,i.left-=window.scrollX||document.documentElement.scrollLeft||0,i},classList:{add:function(t,i){if(t)try{this.supports.classList?t.classList.add(i):((e=(t.className||"").split(" ")).includes(i)||e.push(i),t.className=e.join(" "))}catch{var e=(t.className||"").split(" ");e.includes(i)||e.push(i),t.className=e.join(" ")}},remove:function(t,i){if(t)try{this.supports.classList?t.classList.remove(i):t.className=(t.className||"").split(" ").filter(t=>t!==i).join(" ")}catch{t.className=(t.className||"").split(" ").filter(t=>t!==i).join(" ")}},contains:function(t,i){if(!t)return!1;try{return this.supports.classList?t.classList.contains(i):(t.className||"").split(" ").includes(i)}catch{return(t.className||"").split(" ").includes(i)}}},dataset:{get:function(t,i){if(t)try{return this.supports.dataset?t.dataset[i]:t.getAttribute("data-"+i)}catch{return t.getAttribute("data-"+i)}},set:function(t,i,e){if(t)try{this.supports.dataset?t.dataset[i]=e:t.setAttribute("data-"+i,e)}catch{t.setAttribute("data-"+i,e)}}},copyToClipboard:async function(t){if(this.supports.clipboard)try{return await navigator.clipboard.writeText(t),!0}catch{}if(this.supports.clipboard&&this.supports.clipboardItem)try{var i=new ClipboardItem({"text/plain":new Blob([t],{type:"text/plain"})});return await navigator.clipboard.write([i]),!0}catch{}i=document.createElement("textarea");i.value=t,i.style.position="fixed",i.style.left="-9999px",document.body.appendChild(i),i.focus(),i.select();try{var e=document.execCommand("copy");return document.body.removeChild(i),e}catch{return document.body.removeChild(i),!1}},downloadFile:function(e,h,l="text/plain"){if(this.supports.blob&&this.supports.URL)try{let t=new Blob([h],{type:l}),i=URL.createObjectURL(t);if(this.supports.download){let t=document.createElement("a");t.href=i,t.download=e,t.style.display="none",document.body.appendChild(t),t.click(),setTimeout(()=>{document.body.removeChild(t),URL.revokeObjectURL(i)},100)}else window.open(i,"_blank"),setTimeout(()=>{URL.revokeObjectURL(i)},100);return!0}catch(t){console.error("Error downloading file:",t)}try{let t="highlightit-download-iframe",i=document.getElementById(t);i||((i=document.createElement("iframe")).id=t,i.style.display="none",document.body.appendChild(i));var o=i.contentWindow.document;return o.open("text/html","replace"),o.write(h),o.close(),o.execCommand("SaveAs",!0,e),!0}catch(t){return console.error("Legacy download failed:",t),!1}},animate:function(e,h,t){if(!e)return null;if(this.supports.animation)try{return e.animate(h,t)}catch{}let i=Date.now().toString(36),l=t.duration||1e3;return Object.keys(h[0]).forEach(t=>{e.style[t]=h[0][t]}),setTimeout(()=>{e.style.transition=`all ${l}ms `+(t.easing||"ease");let i=h[h.length-1];Object.keys(i).forEach(t=>{e.style[t]=i[t]}),setTimeout(()=>{e.style.transition="","forwards"!==t.fill&&Object.keys(i).forEach(t=>{e.style[t]=""})},l)},0),{id:i,cancel:function(){e.style.transition=""},finished:new Promise(t=>{setTimeout(t,l)})}},updateHasClass:function(t,i,e,h){t&&i&&e&&(this.supports.cssHas||(i=t.querySelector(i),h&&i?this.classList.add(t,e):h||i||this.classList.remove(t,e)))}},N={popularLanguages:new Set(["javascript","typescript","python","java","html","css","scss","php","ruby","go","rust","c","cpp","csharp","bash","json","markdown","yaml","xml"]),extensionMap:new Map([["js","javascript"],["ts","typescript"],["jsx","javascript"],["tsx","typescript"],["html","html"],["css","css"],["scss","scss"],["sass","scss"],["py","python"],["rb","ruby"],["java","java"],["c","c"],["cpp","cpp"],["hpp","cpp"],["h","c"],["cs","csharp"],["php","php"],["go","go"],["rust","rust"],["rs","rust"],["swift","swift"],["md","markdown"],["json","json"],["xml","xml"],["yaml","yaml"],["yml","yaml"],["sh","bash"],["bash","bash"],["kt","kotlin"],["kts","kotlin"],["dart","dart"],["pl","perl"],["pm","perl"],["lua","lua"],["groovy","groovy"],["r","r"],["scala","scala"],["sql","sql"],["toml","toml"],["ini","ini"],["hcl","hcl"],["tf","terraform"],["dockerfile","dockerfile"],["vue","vue"],["elm","elm"],["clj","clojure"],["cljs","clojure"],["hs","haskell"],["lhs","haskell"],["ex","elixir"],["exs","elixir"],["erl","erlang"],["fs","fsharp"],["fsx","fsharp"],["ml","ocaml"],["mli","ocaml"],["graphql","graphql"],["gql","graphql"],["proto","protobuf"],["sol","solidity"]]),htmlEscapes:new Map([["&","&amp;"],["<","&lt;"],[">","&gt;"],['"',"&quot;"],["'","&#39;"],["/","&#x2F;"],["`","&#x60;"],["=","&#x3D;"]]),svgIcons:{copy:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="highlightit-copy-icon"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg>',check:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="highlightit-check-icon"><polyline points="20 6 9 17 4 12"></polyline></svg>',share:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="highlightit-share-icon"><circle cx="18" cy="5" r="3"></circle><circle cx="6" cy="12" r="3"></circle><circle cx="18" cy="19" r="3"></circle><line x1="8.59" y1="13.51" x2="15.42" y2="17.49"></line><line x1="15.41" y1="6.51" x2="8.59" y2="10.49"></line></svg>',link:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="highlightit-link-icon"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>',download:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="highlightit-download-icon"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="7 10 12 15 17 10"></polyline><line x1="12" y1="15" x2="12" y2="3"></line></svg>'}};class i{static init(t={}){let{selector:i=".highlight-it",autoDetect:h=!0,addCopyButton:l=!0,showLanguage:o=!0,addHeader:a=!0,addLines:r=!1,addShare:n=!1,addDownload:g=!1,theme:e="auto",debounceTime:c=50}=t,s=(P.init(),this.debounceTime=c,this.applyGlobalTheme(e),this.isTouchDevice=P.supports.touch,this.isTouchDevice&&P.classList.add(document.documentElement,"highlightit-touch-device"),document.querySelectorAll(i+":not(.highlightit-original)")),d=50,u=i=>{let e=Math.min(i+d,s.length);for(let t=i;t<e;t++)this.processElement(s[t],h,l,o,a,r,n,g);e<s.length?P.requestAnimationFrame(()=>u(e)):window.location.hash&&this.scrollToAnchor()};u(0),this.l=!0,this.initSharing()}static async generateHash(e){try{if(!window.crypto||!window.crypto.subtle)return P.simpleHash(e);var h=window.TextEncoder||P.TextEncoder;if(!h)return P.simpleHash(e);var l=(new h).encode(e),o=await crypto.subtle.digest("SHA-256",l),a=Array.from(new Uint8Array(o));if("undefined"==typeof BigInt&&P.BigIntPolyfill)return P.simpleHash(e);let t="",i=0n;for(let t=0;t<a.length;t++)i=i<<8n|BigInt(a[t]);for(;0<i||t.length<12;){var r=Number(i%62n);t="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[r]+t,0n===(i/=62n)&&t.length<12&&(t="0"+t)}return t.slice(-12).padStart(12,"0")}catch(t){return console.warn("Error generating hash:",t),P.simpleHash(e)}}static async createShareButton(t,e){let h=document.createElement("button"),i=(h.className="highlightit-button highlightit-share",h.setAttribute("aria-label","Copy link to this code"),h.innerHTML=N.svgIcons.share,e.getAttribute("data-original-id")||e.id);i||(i=await this.generateHash(t),e.id=i);t=async()=>{var t=e.getAttribute("data-original-id")||e.id,i=new URL(window.location.href);i.hash=t,await P.copyToClipboard(i.toString())&&(h.classList.add("copied"),h.innerHTML=N.svgIcons.check,setTimeout(()=>{h.classList.remove("copied"),h.innerHTML=N.svgIcons.share},2e3))};return h.addEventListener("click",t),h.onclickBackup=t,h.o=i,h}static async updateBlockId(i,t){var e=i.getAttribute("data-original-id");if(e)return(l=document.querySelector(`.highlightit-original[id="${e}"]`))?(l.id!==e&&(l.id=e),i.id===e&&(i.id=""),i.setAttribute("data-original-id",e)):i.id&&i.id===e||(i.id=e),e;if(i.id)return i.id;try{var h=await this.generateHash(t);return i.id=h}catch(t){console.error("Error generating hash:",t);var l="highlightit-"+Math.random().toString(36).substring(2,15);return i.id=l}}static scrollToAnchor(l=0){var o=window.location.hash.substring(1);if(o){let t=o.split("_"),i=t[0],e=1<t.length?parseInt(t[1],10):null,h=document.getElementById(i);if(h){if(h.classList.contains("highlightit-original")){let t=h.getAttribute("data-highlightit-id"),i;if(i=t?document.querySelector(`[data-linked-original="${t}"]`):null)return void setTimeout(()=>{this.scrollToHighlightedElement(i,e)},100)}setTimeout(()=>{this.scrollToHighlightedElement(h,e)},100)}else l<10&&setTimeout(()=>{this.scrollToAnchor(l+1)},300*(l+1))}}static scrollToHighlightedElement(t,i){if(null!==i){var e=t.closest(".highlightit-container");if(e){var h=e.querySelectorAll(".highlightit-line-number");for(let t=0;t<h.length;t++){var l=h[t];if(l.textContent.trim()===String(i))return l=l.closest(".highlightit-line-number-container")||l,this.createFullWidthHighlight(l,e),void l.scrollIntoView({behavior:"smooth",block:"center"})}}}t.scrollIntoView({behavior:"smooth",block:"start"}),t.classList.add("highlightit-anchor-highlight"),setTimeout(()=>{t.classList.remove("highlightit-anchor-highlight")},2e3)}static createFullWidthHighlight(t,i){t.classList.add("highlightit-line-highlight");let e=P.getBoundingClientRect(t),h=P.getBoundingClientRect(i),l=document.createElement("div");l.className="highlightit-line-highlight-overlay",l.style.top=e.top-h.top+"px",l.style.height=e.height+"px",l.style.width="100%",l.style.left="0",i.appendChild(l),setTimeout(()=>{t.classList.remove("highlightit-line-highlight"),l&&l.parentNode&&l.parentNode.removeChild(l)},2500)}static processElement(t,i,e,h,l,o,a,r){let n,g,c=null,s,d,u=void 0!==t.dataset.withReload;if(null!=t.textContent&&(t.textContent=t.textContent.trim()),void 0!==t.dataset.lineStart&&(o=!(t.dataset.withLines="")),"code"===t.tagName.toLowerCase()&&"pre"===t.parentElement.tagName.toLowerCase())n=t,g=t.parentElement,u&&(s="highlightit-id-"+Math.random().toString(36).substr(2,9),c=document.createElement("pre"),(d=document.createElement("code")).textContent=t.textContent||"",c.classList.add("highlightit-original"),g.id&&(c.id=g.id,g.setAttribute("data-original-id",g.id),g.id=""),c.setAttribute("data-highlightit-id",s),c.classList.add("highlightit-visually-hidden"),t.dataset.language&&(d.dataset.language=t.dataset.language),void 0!==t.dataset.lineStart&&(d.dataset.lineStart=t.dataset.lineStart),void 0!==t.dataset.withShare&&(d.dataset.withShare=t.dataset.withShare),void 0!==t.dataset.withDownload&&(d.dataset.withDownload=t.dataset.withDownload),void 0!==t.dataset.filename&&(d.dataset.filename=t.dataset.filename),c.appendChild(d),g.dataset.linkedOriginal=s,g.classList.add("highlightit-streaming-target"),g.parentNode.insertBefore(c,g));else{var p,m,b,v=t.textContent||"",f=(u&&(p="highlightit-id-"+Math.random().toString(36).substr(2,9),c=document.createElement("pre"),(m=document.createElement("code")).textContent=v,c.appendChild(m),c.classList.add("highlightit-original"),t.id&&(c.id=t.id,t.setAttribute("data-original-id",t.id),t.id=""),c.setAttribute("data-highlightit-id",p),c.classList.add("highlightit-visually-hidden"),t.dataset.language&&(m.dataset.language=t.dataset.language),void 0!==t.dataset.lineStart&&(m.dataset.lineStart=t.dataset.lineStart),void 0!==t.dataset.withShare&&(m.dataset.withShare=t.dataset.withShare),void 0!==t.dataset.withDownload&&(m.dataset.withDownload=t.dataset.withDownload),void 0!==t.dataset.filename&&(m.dataset.filename=t.dataset.filename),t.parentNode.insertBefore(c,t),t.setAttribute("data-linked-original",p)),document.createElement("div"));for(b in t.className.includes("highlight-it")?f.className="highlight-it highlightit-container":f.className=t.className,t.id&&!u&&(f.id=t.id),g=document.createElement("pre"),(n=document.createElement("code")).textContent=v.trim(),t.dataset)f.dataset[b]=t.dataset[b],"language"===b&&(n.dataset.language=t.dataset[b],n.className="language-"+t.dataset[b]),"withLines"===b&&f.classList.add("highlightit-with-lines"),"withDownload"===b&&f.classList.add("highlightit-with-download"),"noHeader"===b&&f.classList.add("highlightit-no-header"),"lineStart"===b&&(n.dataset.lineStart=t.dataset[b]);g.appendChild(n),f.appendChild(g),t.parentNode.replaceChild(f,t),t=n}!o&&void 0===t.dataset.withLines||this.createCodeContainer(t).classList.add("highlightit-with-lines"),!r&&void 0===t.dataset.withDownload||this.createCodeContainer(t).classList.add("highlightit-with-download"),this.highlightElement(t,i,e,h,l,o,a,r)}static applyGlobalTheme(t){document.documentElement.classList.remove("highlightit-theme-light","highlightit-theme-dark","highlightit-theme-auto"),["light","dark","auto"].includes(t)?document.documentElement.classList.add("highlightit-theme-"+t):document.documentElement.classList.add("highlightit-theme-auto")}static highlightElement(e,i,t,h,l,o,a,r){let n=this.createCodeContainer(e),g=(e.textContent||"").trim(),c=null,s=null,d=null;var u=e.dataset,p=n.dataset,m=!l||void 0!==u.noHeader||void 0!==p.noHeader,o=o||void 0!==u.withLines||void 0!==p.withLines,b=void 0!==u.withReload||void 0!==p.withReload,a=a||void 0!==u.withShare||void 0!==p.withShare,r=r||void 0!==u.withDownload||void 0!==p.withDownload,t=t&&!(void 0!==u.noCopy||void 0!==p.noCopy);if(u.language?(c=u.language,s=c):p.language&&(c=p.language,s=c),u.filename?(d=u.filename,c=this.getLanguageFromFilename(d),s=d):p.filename&&(d=p.filename,c=this.getLanguageFromFilename(d),s=d),u.theme?(u=u.theme.toLowerCase(),["light","dark","auto"].includes(u)&&n.classList.add("highlightit-theme-"+u)):p.theme&&(u=p.theme.toLowerCase(),["light","dark","auto"].includes(u))&&n.classList.add("highlightit-theme-"+u),!a||b||n.getAttribute("data-original-id")||n.id||this.generateHash(g).then(t=>{n.id=t}),(h||t||a||r)&&l&&!m?(p=this.createCodeHeader(s,g,t,h,a,r,n),n.prepend(p)):m&&(n.classList.add("highlightit-no-header"),t||a||r)&&(u=this.createFloatingButtons(g,a,r,n),n.appendChild(u)),o&&n.classList.add("highlightit-with-lines"),b&&this.setupLiveUpdates(e,n,i,h,a),!c&&i)l=this.autoDetectLanguage(g),c=l.language||"unknown",e.innerHTML=l.value,e.classList.add("language-"+c),o&&this.addLineNumbers(e,g),h&&!m&&(p=n.querySelector(".highlightit-header"))&&((t=p.querySelector(".highlightit-language"))?t.textContent=c:c&&((r=document.createElement("span")).className="highlightit-language",r.textContent=c,p.insertBefore(r,p.firstChild)));else if(c)try{let i;try{i=hljs.highlight(g,{language:c})}catch(t){console.error("HighlightIt: Error highlighting with language "+c,t,"This might be because highlight.js is not available. Please ensure its script is included in the page."),i={value:this.escapeHtml(g)}}e.innerHTML=i.value,e.classList.add("language-"+c),o&&this.addLineNumbers(e,g)}catch(t){i?(u=this.autoDetectLanguage(g),e.innerHTML=u.value,e.classList.add("language-"+(u.language||"unknown")),o&&this.addLineNumbers(e,g),h&&!m&&(b=n.querySelector(".highlightit-header"))&&(a=b.querySelector(".highlightit-language"))&&u.language&&(a.textContent=u.language)):(console.error("HighlightIt: Error highlighting with language "+c,t),e.innerHTML=this.escapeHtml(g),o&&this.addLineNumbers(e,g))}else e.innerHTML=""+this.escapeHtml(g),o&&this.addLineNumbers(e,g)}static setupLiveUpdates(g,c,s,d,u){var p;if(window.MutationObserver||P.MutationObserver){let t=this.debounceTime||30,i=null,h=this.findOriginalElement(g,c)||g,n=g,l=P.dataset.get(g,"language")||(g.className.match(/language-(\w+)/)||[])[1]||null,o=null,a=(!l&&s&&(p=(h.querySelector("code")||h).textContent.trim())&&(p=this.autoDetectLanguage(p),o=p.language||null),""),e=()=>{let r=(h.querySelector("code")||h).textContent.trim();if(r&&r!==a){if(a=r,u)this.updateBlockId(c,r).then(()=>{this.updateCodeBlock(n,c,l,r,d)});else if(!l&&s)if(!o||d&&!c.querySelector(".highlightit-header .highlightit-language")){var t,i=this.autoDetectLanguage(r);o=i.language||"unknown",n.innerHTML=i.value,P.classList.add(n,"language-"+o),d&&o&&(i=c.querySelector(".highlightit-header"))&&((t=i.querySelector(".highlightit-language"))?t.textContent=o:((t=document.createElement("span")).className="highlightit-language",t.textContent=o,i.insertBefore(t,i.firstChild)))}else{try{var e=hljs.highlight(r,{language:o});n.innerHTML=e.value}catch(t){console.error("HighlightIt: Error highlighting with language "+o,t,"This might be because highlight.js is not available. Please ensure its script is included in the page."),n.innerHTML=this.escapeHtml(r)}P.classList.add(n,"language-"+o)}else this.updateCodeBlock(n,c,l,r,d),P.classList.add(n,"language-"+(l||"unknown"));if(c.classList.contains("highlightit-with-lines")){let t=n.parentElement,i=t.querySelector(".highlightit-line-numbers"),e=r.split("\n").length,h=i?i.querySelectorAll(".highlightit-line-number-container").length||i.querySelectorAll(".highlightit-line-number").length:0,l=parseInt(n.dataset.lineStart||t.dataset.lineStart||1,10),o=c.getAttribute("data-original-id")||c.id,a=void 0!==c.dataset.withShare||void 0!==g.dataset.withShare;this.updateLineNumbersForLiveUpdates(i,e,h,l,a,o,c)}}},r=new MutationObserver(()=>{i&&clearTimeout(i),i=setTimeout(()=>{e(),i=null},t)});r.observe(h,{characterData:!0,childList:!0,subtree:!0}),h.g=r}else console.warn("HighlightIt: Live updates not supported in this browser")}static updateLineNumbersForLiveUpdates(i,e,h,l,o,a,r){if(e===h){var n=i.querySelectorAll(".highlightit-line-number"),g=i.querySelectorAll(".highlightit-line-share");for(let t=0;t<e;t++){var c=l+t;n[t]&&(n[t].textContent=c),o&&a&&g[t]&&(g[t].dataset.lineNumber=c,g[t].dataset.blockId!==a)&&(g[t].dataset.blockId=a,(c=g[t].u)&&g[t].removeEventListener("click",c),this.setupLineShareButtonHandler(g[t],r))}}else if(h<e){var s=document.createDocumentFragment();for(let t=h;t<e;t++){var d,u=l+t,p=document.createElement("div"),m=(p.className="highlightit-line-number-container",document.createElement("span"));m.className="highlightit-line-number",m.textContent=u,o&&a?(m.className+=" highlightit-line-number-shareable",(d=document.createElement("button")).className="highlightit-line-share",d.setAttribute("aria-label","Copy link to line "+u),d.innerHTML=N.svgIcons.link,d.dataset.lineNumber=u,d.dataset.blockId=a,this.setupLineShareButtonHandler(d,r),p.appendChild(m),p.appendChild(d)):p.appendChild(m),s.appendChild(p)}i.appendChild(s)}else if(e<h){var b=i.querySelectorAll(".highlightit-line-number-container"),v=i.querySelectorAll(".highlightit-line-number");for(let t=e;t<h;t++)b[t]?i.removeChild(b[t]):v[t]&&i.removeChild(v[t]);for(let t=0;t<e;t++){var f,w,y=l+t;b[t]?((f=b[t].querySelector(".highlightit-line-number"))&&(f.textContent=y),o&&a&&(f=b[t].querySelector(".highlightit-line-share"))&&(f.dataset.lineNumber=y,f.dataset.blockId!==a)&&(f.dataset.blockId=a,(w=f.u)&&f.removeEventListener("click",w),this.setupLineShareButtonHandler(f,r))):v[t]&&(v[t].textContent=y)}}}static createCodeContainer(t){var i,e=t.parentElement;return e.parentElement&&e.parentElement.classList.contains("highlightit-container")?e.parentElement:((i=document.createElement("div")).className="highlightit-container",e.dataset&&e.dataset.linkedOriginal?i.dataset.linkedOriginal=e.dataset.linkedOriginal:e.hasAttribute("data-linked-original")&&(i.setAttribute("data-linked-original",e.getAttribute("data-linked-original")),e.removeAttribute("data-linked-original")),e.hasAttribute("data-original-id")&&i.setAttribute("data-original-id",e.getAttribute("data-original-id")),i.id||(e.id?(i.id=e.id,e.removeAttribute("id")):t.id&&(i.id=t.id,t.removeAttribute("id"))),e.parentNode.insertBefore(i,e),i.appendChild(e),i)}static createCodeHeader(t,i,e,h,l,o,a){var r=document.createElement("div");r.className="highlightit-header",h?((h=document.createElement("span")).className="highlightit-language",h.textContent=t||"unknown",r.appendChild(h)):r.style.justifyContent="flex-end";let n=document.createElement("div");return n.className="highlightit-buttons-container",n.style.display="flex",n.style.alignItems="center",e&&(h=this.createCopyButton(i),n.appendChild(h)),o&&(e=this.createDownloadButton(i,t,a),n.appendChild(e)),l&&this.createShareButton(i,a).then(t=>{n.appendChild(t)}),r.appendChild(n),r}static createCopyButton(i){let e=document.createElement("button");e.className="highlightit-button highlightit-copy",e.setAttribute("aria-label","Copy code"),e.innerHTML=""+N.svgIcons.copy+N.svgIcons.check.replace("highlightit-check-icon",'highlightit-check-icon" style="display: none;');var t=async()=>{var t=i.trim();if(await P.copyToClipboard(t)){P.classList.add(e,"copied");let t=e.querySelector(".highlightit-copy-icon"),i=e.querySelector(".highlightit-check-icon");t&&(t.style.display="none"),i&&(i.style.display="block"),setTimeout(()=>{P.classList.remove(e,"copied"),t&&(t.style.display="block"),i&&(i.style.display="none")},2e3)}else console.warn("Failed to copy code")};return e.onclickBackup=t,e.p=i.trim(),e.addEventListener("click",t),e}static createDownloadButton(i,t,e){let h=document.createElement("button"),l=(h.className="highlightit-button highlightit-download",h.setAttribute("aria-label","Download code"),h.innerHTML=""+N.svgIcons.download+N.svgIcons.check.replace("highlightit-check-icon",'highlightit-check-icon" style="display: none;'),e&&e.dataset&&e.dataset.filename);l||(e=t?this.getLanguageFileExtension(t):"txt",l="code."+e);t=async()=>{var t=i.trim();if(P.downloadFile(l,t)){P.classList.add(h,"copied");let t=h.querySelector(".highlightit-download-icon"),i=h.querySelector(".highlightit-check-icon");t&&(t.style.display="none"),i&&(i.style.display="block"),setTimeout(()=>{P.classList.remove(h,"copied"),t&&(t.style.display="block"),i&&(i.style.display="none")},2e3)}else console.warn("Failed to download code")};return h.addEventListener("click",t),h.onclickBackup=t,h.m=i,h}static createFloatingButtons(o,t=!1,i=!1,a=null){let r=document.createElement("div"),e=(r.className="highlightit-floating-buttons",document.createElement("button"));if(e.className="highlightit-button highlightit-floating highlightit-copy",e.setAttribute("aria-label","Copy code"),e.innerHTML=N.svgIcons.copy,e.addEventListener("click",async()=>{await P.copyToClipboard(o.trim())&&(P.classList.add(e,"copied"),e.innerHTML=N.svgIcons.check,setTimeout(()=>{P.classList.remove(e,"copied"),e.innerHTML=N.svgIcons.copy},2e3))}),r.appendChild(e),i&&a){let e=document.createElement("button"),t=(e.className="highlightit-button highlightit-floating highlightit-download",e.setAttribute("aria-label","Download code"),e.innerHTML=""+N.svgIcons.download+N.svgIcons.check.replace("highlightit-check-icon",'highlightit-check-icon" style="display: none;'),a&&a.dataset&&a.dataset.filename),i,h=a.querySelector("code")&&(a.querySelector("code").dataset.language||(a.querySelector("code").className.match(/language-(\w+)/)||[])[1]),l=(t||(i=h?this.getLanguageFileExtension(h):"txt",t="code."+i),()=>{if(P.downloadFile(t,o.trim())){P.classList.add(e,"copied");let t=e.querySelector(".highlightit-download-icon"),i=e.querySelector(".highlightit-check-icon");t&&(t.style.display="none"),i&&(i.style.display="block"),setTimeout(()=>{P.classList.remove(e,"copied"),t&&(t.style.display="block"),i&&(i.style.display="none")},2e3)}});e.addEventListener("click",l),e.onclickBackup=l,e.m=o.trim(),r.appendChild(e)}return t&&a&&(async()=>{var t=await this.createShareButton(o,a);t.className="highlightit-button highlightit-floating highlightit-share",this.isTouchDevice&&(t.style.opacity="1"),r.appendChild(t)})(),r}static getLanguageFromFilename(t){t=t.split(".").pop().toLowerCase();return N.extensionMap.get(t)||null}static autoDetectLanguage(i){try{var t;return!i||i.trim().length<3?{value:this.escapeHtml(i),language:"plaintext"}:(t=hljs.highlightAuto(i,Array.from(N.popularLanguages))).language?t:hljs.highlightAuto(i)}catch(t){return console.error("HighlightIt: Error auto-detecting language",t,"This might be because highlight.js is not available. Please ensure its script is included in the page."),{value:this.escapeHtml(i),language:"unknown"}}}static escapeHtml(t){return t.replace(/[&<>"'`=/]/g,t=>N.htmlEscapes.get(t))}static addLineNumbers(r,n){var g=r.parentElement;if(!g.querySelector(".highlightit-line-numbers")){let e=g.closest(".highlightit-container"),i=e&&(void 0!==e.dataset.withShare||void 0!==r.dataset.withShare),h=n.trim().split("\n").length,t=document.createElement("div"),l=(t.className="highlightit-line-numbers",parseInt(r.dataset.lineStart||g.dataset.lineStart||1,10)),o=document.createDocumentFragment(),a="";i&&!(a=e.getAttribute("data-original-id")||e.id)&&(a="temp-"+Math.random().toString(36).substr(2,9),e.id=a,this.generateHash(n).then(i=>{e.id===a&&(e.id=i),t.querySelectorAll(".highlightit-line-number").forEach(t=>{t=t.querySelector(".highlightit-line-share");t&&t.dataset.blockId===a&&(t.dataset.blockId=i)})}));for(let t=0;t<h;t++){var c,s,d=document.createElement("div"),u=(d.className="highlightit-line-number-container",document.createElement("span"));u.className="highlightit-line-number",u.textContent=l+t,i&&a?(c=l+t,u.className+=" highlightit-line-number-shareable",(s=document.createElement("button")).className="highlightit-line-share",s.setAttribute("aria-label","Copy link to line "+c),s.innerHTML=N.svgIcons.link,s.dataset.lineNumber=c,s.dataset.blockId=a,this.setupLineShareButtonHandler(s,e),d.appendChild(u),d.appendChild(s)):d.appendChild(u),o.appendChild(d)}t.appendChild(o),P.classList.add(g,"highlightit-has-line-numbers"),g.insertBefore(t,g.firstChild)}}static updateCodeBlock(e,a,t,i,U){let r=i.trim(),D=a.classList.contains("highlightit-with-lines")||void 0!==e.dataset.lineStart,h=null,l=t;t&&(h=this.getLanguageFromFilename(t)||t);try{let i;try{i=h?hljs.highlight(r,{language:h}):{value:this.escapeHtml(r)}}catch(t){console.error("HighlightIt: Error highlighting with language "+h,t,"This might be because highlight.js is not available. Please ensure its script is included in the page."),i={value:this.escapeHtml(r)}}if(e.innerHTML=i.value,D){var o=a.querySelector(".highlightit-line-numbers"),n=o?o.querySelectorAll(".highlightit-line-number-container, .highlightit-line-number"):null,g=r.split("\n").length,c=n?n.length:0,s=parseInt(e.dataset.lineStart||a.dataset.lineStart||1,10),d=a.getAttribute("data-original-id")||a.id,u=void 0!==a.dataset.withShare||void 0!==e.dataset.withShare;if(o){if(g!==c)if(c<g){var p=document.createDocumentFragment();for(let t=c;t<g;t++){var m,b=s+t,v=document.createElement("div"),f=(v.className="highlightit-line-number-container",document.createElement("span"));f.className="highlightit-line-number",f.textContent=b,u&&d?(f.className+=" highlightit-line-number-shareable",(m=document.createElement("button")).className="highlightit-line-share",m.setAttribute("aria-label","Copy link to line "+b),m.innerHTML=N.svgIcons.link,m.dataset.lineNumber=b,m.dataset.blockId=d,this.setupLineShareButtonHandler(m,a),v.appendChild(f),v.appendChild(m)):v.appendChild(f),p.appendChild(v)}o.appendChild(p)}else if(g<c){var w=o.querySelectorAll(".highlightit-line-number-container"),y=o.querySelectorAll(".highlightit-line-number");for(let t=g;t<c;t++)w[t]?o.removeChild(w[t]):y[t]&&o.removeChild(y[t])}var k=o.querySelectorAll(".highlightit-line-number-container"),x=o.querySelectorAll(".highlightit-line-number"),j=o.querySelectorAll(".highlightit-line-share");for(let t=0;t<g;t++){var T,L,I,M,C=s+t;k[t]?((T=k[t].querySelector(".highlightit-line-number"))&&(T.textContent=C),u&&d&&(L=k[t].querySelector(".highlightit-line-share"))&&(L.dataset.lineNumber=C,L.setAttribute("aria-label","Copy link to line "+C),L.dataset.blockId!==d)&&(L.dataset.blockId=d,(I=L.u)&&L.removeEventListener("click",I),this.setupLineShareButtonHandler(L,a))):x[t]&&(x[t].textContent=C,u)&&d&&j[t]&&(j[t].dataset.lineNumber=C,j[t].setAttribute("aria-label","Copy link to line "+C),j[t].dataset.blockId!==d)&&(j[t].dataset.blockId=d,(M=j[t].u)&&j[t].removeEventListener("click",M),this.setupLineShareButtonHandler(j[t],a))}}else this.addLineNumbers(e,r)}a.querySelectorAll(".highlightit-copy").forEach(e=>{var t;e.p!==r&&((t=e.onclickBackup||e.onclick)&&e.removeEventListener("click",t),e.onclickBackup=t=async()=>{var t=r;if(await P.copyToClipboard(t)){P.classList.add(e,"copied");let t=e.querySelector(".highlightit-copy-icon"),i=e.querySelector(".highlightit-check-icon");t&&(t.style.display="none"),i&&(i.style.display="block"),setTimeout(()=>{P.classList.remove(e,"copied"),t&&(t.style.display="block"),i&&(i.style.display="none")},2e3)}else console.warn("Failed to copy code")},e.p=r,e.addEventListener("click",t))}),a.querySelectorAll(".highlightit-download").forEach(l=>{if(l.m!==r){var o=l.onclickBackup||l.onclick;o&&l.removeEventListener("click",o);let t=a&&a.dataset&&a.dataset.filename,i,e=a.querySelector("code")&&(a.querySelector("code").dataset.language||(a.querySelector("code").className.match(/language-(\w+)/)||[])[1]),h=(t||(i=e?this.getLanguageFileExtension(e):"txt",t="code."+i),()=>{if(P.downloadFile(t,r.trim())){P.classList.add(l,"copied");let t=l.querySelector(".highlightit-download-icon"),i=l.querySelector(".highlightit-check-icon");t&&(t.style.display="none"),i&&(i.style.display="block"),setTimeout(()=>{P.classList.remove(l,"copied"),t&&(t.style.display="block"),i&&(i.style.display="none")},2e3)}});l.onclickBackup=h,l.m=r,l.addEventListener("click",h)}}),a.querySelectorAll(".highlightit-share").forEach(async e=>{var t=a.getAttribute("data-original-id");if(t)e.o!==t&&(e.o=t);else if(a.id)e.o!==a.id&&((t=e.onclickBackup||e.onclick)&&e.removeEventListener("click",t),e.onclickBackup=t=async()=>{var t=new URL(window.location.href);t.hash=a.id,await P.copyToClipboard(t.toString())&&(e.classList.add("copied"),e.innerHTML=N.svgIcons.check,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=N.svgIcons.share},2e3))},e.o=a.id,e.addEventListener("click",t));else{let i=await this.generateHash(r);a.id=i,e.o!==i&&((t=e.onclickBackup||e.onclick)&&e.removeEventListener("click",t),e.onclickBackup=t=async()=>{var t=new URL(window.location.href);t.hash=i,await P.copyToClipboard(t.toString())&&(e.classList.add("copied"),e.innerHTML=N.svgIcons.check,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=N.svgIcons.share},2e3))},e.o=i,e.addEventListener("click",t))}});var B,R,S,H,E,A,O,q,z,F=a.querySelector(".highlightit-floating-buttons");if(F&&a.classList.contains("highlightit-no-header")){let t=F.querySelector(".highlightit-copy"),l=(t&&t.p!==r&&((B=t.onclick)&&t.removeEventListener("click",B),t.p=r,t.addEventListener("click",async()=>{await P.copyToClipboard(r.trim())&&(P.classList.add(t,"copied"),t.innerHTML=N.svgIcons.check,setTimeout(()=>{P.classList.remove(t,"copied"),t.innerHTML=N.svgIcons.copy},2e3))})),F.querySelector(".highlightit-download"));if(l&&l.m!==r){var _=l.onclickBackup||l.onclick;_&&l.removeEventListener("click",_);let t=a&&a.dataset&&a.dataset.filename,i,e=a.querySelector("code")&&(a.querySelector("code").dataset.language||(a.querySelector("code").className.match(/language-(\w+)/)||[])[1]),h=(t||(i=e?this.getLanguageFileExtension(e):"txt",t="code."+i),()=>{if(P.downloadFile(t,r.trim())){P.classList.add(l,"copied");let t=l.querySelector(".highlightit-download-icon"),i=l.querySelector(".highlightit-check-icon");t&&(t.style.display="none"),i&&(i.style.display="block"),setTimeout(()=>{P.classList.remove(l,"copied"),t&&(t.style.display="block"),i&&(i.style.display="none")},2e3)}});l.onclickBackup=h,l.m=r,l.addEventListener("click",h)}let e=F.querySelector(".highlightit-share");e&&((R=a.getAttribute("data-original-id"))?e.o!==R&&(e.o=R):a.id?e.o!==a.id&&((S=e.onclick)&&e.removeEventListener("click",S),e.o=a.id,e.addEventListener("click",async()=>{var t=new URL(window.location.href);t.hash=a.id,await P.copyToClipboard(t.toString())&&(e.classList.add("copied"),e.innerHTML=N.svgIcons.check,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=N.svgIcons.share},2e3))})):this.generateHash(r).then(i=>{var t;a.id=i,e.o!==i&&((t=e.onclick)&&e.removeEventListener("click",t),e.o=i,e.addEventListener("click",async()=>{var t=new URL(window.location.href);t.hash=i,await P.copyToClipboard(t.toString())&&(e.classList.add("copied"),e.innerHTML=N.svgIcons.check,setTimeout(()=>{e.classList.remove("copied"),e.innerHTML=N.svgIcons.share},2e3))}))}))}else!F&&a.classList.contains("highlightit-no-header")&&(H=void 0!==a.dataset.withShare,E=void 0!==a.dataset.withDownload,A=this.createFloatingButtons(r,H,E,a),a.appendChild(A));U&&h&&(O=a.querySelector(".highlightit-header"))&&((q=O.querySelector(".highlightit-language"))?q.textContent=l||h:h&&((z=document.createElement("span")).className="highlightit-language",z.textContent=l||h,O.insertBefore(z,O.firstChild)))}catch(t){console.warn("HighlightIt: Error highlighting with language "+h,t),e.innerHTML=this.escapeHtml(r)}}static setupLineShareButtonHandler(h,l){var t=async t=>{t.stopPropagation();var t=l.getAttribute("data-original-id")||l.id,i=h.dataset.lineNumber,e=new URL(window.location.href);if(e.hash=t+"_"+i,await P.copyToClipboard(e.toString())){h.classList.add("copied"),h.innerHTML=N.svgIcons.check;let t=h.closest(".highlightit-line-number-container");t&&(t.classList.add("has-copied-button"),P.updateHasClass(t,".highlightit-line-share.copied","has-copied-button",!0)),setTimeout(()=>{h.classList.remove("copied"),h.innerHTML=N.svgIcons.link,t&&(t.classList.remove("has-copied-button"),P.updateHasClass(t,".highlightit-line-share.copied","has-copied-button",!1))},2e3)}};h.u=t,h.addEventListener("click",t)}static findOriginalElement(t,i){var e=t.parentElement&&t.parentElement.dataset&&t.parentElement.dataset.linkedOriginal||i&&i.dataset&&i.dataset.linkedOriginal||t.parentElement&&t.parentElement.getAttribute("data-linked-original")||i&&i.getAttribute("data-linked-original");if(e){e=document.querySelector(`.highlightit-original[data-highlightit-id="${e}"]`);if(e)return e}e=t.parentElement&&t.parentElement.getAttribute("data-original-id")||i&&i.getAttribute("data-original-id");if(e){t=document.getElementById(e);if(t)return t}return i&&i.previousSibling&&i.previousSibling.classList&&i.previousSibling.classList.contains("highlightit-original")?i.previousSibling:null}static initSharing(){setTimeout(()=>{this.scrollToAnchor()},100),window.addEventListener("hashchange",()=>{this.scrollToAnchor()})}static getLanguageFileExtension(t){if(!t)return"txt";for(var[i,e]of N.extensionMap.entries())if(e===t.toLowerCase())return i;return t.toLowerCase()}}"undefined"!=typeof window&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>i.initSharing()):i.initSharing()),i.highlight=function(t,i={}){var e,h,l,o,a,r,n,g,c,s,d;return!t||t.classList.contains("highlightit-original")||t.closest(".highlightit-container")||t.parentElement&&t.parentElement.classList.contains("highlightit-container")?(console.warn("HighlightIt: Element is already highlighted or is a hidden original element"),t):({autoDetect:i=!0,addCopyButton:e=!0,showLanguage:h=!0,addHeader:l=!0,addLines:o=!1,withReload:a=!1,addShare:r=!1,addDownload:n=!1,filename:g,language:c,theme:s,lineStart:d}=i,o&&(t.dataset.withLines=""),void 0!==d&&(t.dataset.lineStart=d),a&&(t.dataset.withReload=""),l||(t.dataset.noHeader=""),e||(t.dataset.noCopy=""),r&&(t.dataset.withShare=""),n&&(t.dataset.withDownload=""),g&&(t.dataset.filename=g),c&&(t.dataset.language=c),s&&(t.dataset.theme=s),this.processElement(t,i,e,h,l,o,r,n),t.closest(".highlightit-container")||t.parentElement&&t.parentElement.closest(".highlightit-container")||t)},t.HighlightIt=i,"undefined"!=typeof window&&(window.HighlightIt=i,(()=>{var t=document.createElement("style");t.textContent=':root{--hl-background:#1e1e1e;--hl-border:#2d2d2d;--hl-header-bg:#2d2d2d;--hl-text:#d4d4d4;--hl-badge-bg:#3d3d3d;--hl-hover-bg:#3d3d3d;--hl-copied-color:#4ec9b0;--hl-keyword:#569cd6;--hl-string:#ce9178;--hl-comment:#6a9955;--hl-function:#dcdcaa;--hl-number:#b5cea8;--hl-class:#4ec9b0;--hl-params:#9cdcfe;--hl-built-in:#4ec9b0;--hl-tag:#569cd6;--hl-attr:#9cdcfe;--hl-variable:#9cdcfe;--hl-property:#9cdcfe;--hl-operator:#d4d4d4;--hl-punctuation:#d4d4d4;--hl-regexp:#d16969;--hl-doctype:grey;--hl-meta:grey;--hl-name:#569cd6;--hl-selector:#d7ba7d;--hl-attr-value:#ce9178;--hl-constant:#4fc1ff;--hl-symbol:#b5cea8;--hl-important:#569cd6;--hl-deleted:#ce9178;--hl-inserted:#b5cea8;--hl-type:#4ec9b0;--hl-literal:#569cd6;--hl-link:#9cdcfe;--hl-title-function:#dcdcaa;--hl-title-class:#4ec9b0;--hl-title-namespace:#4ec9b0;--hl-text-rgb:212,212,212}.highlightit-theme-light{--hl-background:#fff;--hl-border:#ccc;--hl-header-bg:#e0e0e0;--hl-text:#333;--hl-badge-bg:silver;--hl-hover-bg:#d0d0d0;--hl-copied-color:#0b8043;--hl-keyword:#00f;--hl-string:#a31515;--hl-comment:green;--hl-function:#795e26;--hl-number:#098658;--hl-class:#267f99;--hl-params:#001080;--hl-built-in:#0070c1;--hl-tag:maroon;--hl-attr:red;--hl-variable:#001080;--hl-property:#001080;--hl-operator:#000;--hl-punctuation:#000;--hl-regexp:#811f3f;--hl-doctype:grey;--hl-meta:grey;--hl-name:maroon;--hl-selector:maroon;--hl-attr-value:#00f;--hl-constant:#0070c1;--hl-symbol:#000;--hl-important:#00f;--hl-deleted:#a31515;--hl-inserted:#098658;--hl-type:#267f99;--hl-literal:#00f;--hl-link:#00f;--hl-title-function:#795e26;--hl-title-class:#267f99;--hl-title-namespace:#267f99;--hl-text-rgb:51,51,51}@media (prefers-color-scheme:light){:root.highlightit-theme-auto{--hl-background:#fff;--hl-border:#ccc;--hl-header-bg:#e0e0e0;--hl-text:#333;--hl-badge-bg:silver;--hl-hover-bg:#d0d0d0;--hl-copied-color:#0b8043;--hl-keyword:#00f;--hl-string:#a31515;--hl-comment:green;--hl-function:#795e26;--hl-number:#098658;--hl-class:#267f99;--hl-params:#001080;--hl-built-in:#0070c1;--hl-tag:maroon;--hl-attr:red;--hl-variable:#001080;--hl-property:#001080;--hl-operator:#000;--hl-punctuation:#000;--hl-regexp:#811f3f;--hl-doctype:grey;--hl-meta:grey;--hl-name:maroon;--hl-selector:maroon;--hl-attr-value:#00f;--hl-constant:#0070c1;--hl-symbol:#000;--hl-important:#00f;--hl-deleted:#a31515;--hl-inserted:#098658;--hl-type:#267f99;--hl-literal:#00f;--hl-link:#00f;--hl-title-function:#795e26;--hl-title-class:#267f99;--hl-title-namespace:#267f99;--hl-text-rgb:51,51,51}}.highlightit-container{border:1px solid var(--hl-border);border-radius:6px;overflow:hidden;position:relative}.highlightit-container code[data-theme=light],.highlightit-container pre[data-theme=light],.highlightit-container[data-theme=light]{--hl-background:#fff!important;--hl-border:#ccc!important;--hl-header-bg:#e0e0e0!important;--hl-text:#333!important;--hl-badge-bg:silver!important;--hl-hover-bg:#d0d0d0!important;--hl-copied-color:#0b8043!important;--hl-keyword:#00f!important;--hl-string:#a31515!important;--hl-comment:green!important;--hl-function:#795e26!important;--hl-number:#098658!important;--hl-class:#267f99!important;--hl-params:#001080!important;--hl-built-in:#0070c1!important;--hl-tag:maroon!important;--hl-attr:red!important;--hl-variable:#001080!important;--hl-property:#001080!important;--hl-operator:#000!important;--hl-punctuation:#000!important;--hl-regexp:#811f3f!important;--hl-doctype:grey!important;--hl-meta:grey!important;--hl-name:maroon!important;--hl-selector:maroon!important;--hl-attr-value:#00f!important;--hl-constant:#0070c1!important;--hl-symbol:#000!important;--hl-important:#00f!important;--hl-deleted:#a31515!important;--hl-inserted:#098658!important;--hl-type:#267f99!important;--hl-literal:#00f!important;--hl-link:#00f!important;--hl-title-function:#795e26!important;--hl-title-class:#267f99!important;--hl-title-namespace:#267f99!important}.highlightit-container code[data-theme=dark],.highlightit-container pre[data-theme=dark],.highlightit-container[data-theme=dark]{--hl-background:#1e1e1e!important;--hl-border:#2d2d2d!important;--hl-header-bg:#2d2d2d!important;--hl-text:#d4d4d4!important;--hl-badge-bg:#3d3d3d!important;--hl-hover-bg:#3d3d3d!important;--hl-copied-color:#4ec9b0!important;--hl-keyword:#569cd6!important;--hl-string:#ce9178!important;--hl-comment:#6a9955!important;--hl-function:#dcdcaa!important;--hl-number:#b5cea8!important;--hl-class:#4ec9b0!important;--hl-params:#9cdcfe!important;--hl-built-in:#4ec9b0!important;--hl-tag:#569cd6!important;--hl-attr:#9cdcfe!important;--hl-variable:#9cdcfe!important;--hl-property:#9cdcfe!important;--hl-operator:#d4d4d4!important;--hl-punctuation:#d4d4d4!important;--hl-regexp:#d16969!important;--hl-doctype:grey!important;--hl-meta:grey!important;--hl-name:#569cd6!important;--hl-selector:#d7ba7d!important;--hl-attr-value:#ce9178!important;--hl-constant:#4fc1ff!important;--hl-symbol:#b5cea8!important;--hl-important:#569cd6!important;--hl-deleted:#ce9178!important;--hl-inserted:#b5cea8!important;--hl-type:#4ec9b0!important;--hl-literal:#569cd6!important;--hl-link:#9cdcfe!important;--hl-title-function:#dcdcaa!important;--hl-title-class:#4ec9b0!important;--hl-title-namespace:#4ec9b0!important}.highlightit-header{align-items:center;background:var(--hl-header-bg);color:var(--hl-text);display:flex;font-size:14px;font-weight:600;justify-content:space-between;padding:8px 15px}.highlightit-language{background:var(--hl-badge-bg);border-radius:4px;color:var(--hl-text);font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:12px;padding:2px 8px}.highlightit-button{align-items:center;background:transparent;border:none;border-radius:4px;color:var(--hl-text);cursor:pointer;display:flex;height:28px;justify-content:center;padding:4px 6px;transition:all .2s ease}.highlightit-button:hover{background:var(--hl-hover-bg)}.highlightit-button.copied{color:var(--hl-copied-color)}.highlightit-check-icon,.highlightit-copy-icon,.highlightit-download-icon,.highlightit-share-icon{height:16px;vertical-align:middle;width:16px}.highlightit-original,[data-with-reload][style*="display: none"]{border:0!important;height:0!important;margin:0!important;opacity:0!important;overflow:hidden!important;padding:0!important;pointer-events:none!important;position:absolute!important;visibility:hidden!important;width:0!important;z-index:-9999!important;clip:rect(1px,1px,1px,1px)!important;clip-path:inset(50%)!important}.highlightit-floating-buttons{display:flex;gap:4px;opacity:0;position:absolute;right:8px;top:8px;transition:opacity .2s ease;z-index:10}.highlightit-button.highlightit-floating{background-color:rgba(45,45,45,.8);transition:background-color .2s ease,transform .2s ease}.highlightit-container[data-theme=light] .highlightit-button.highlightit-floating,.highlightit-theme-light .highlightit-button.highlightit-floating,:root.highlightit-theme-auto.system-light-theme .highlightit-button.highlightit-floating{background-color:hsla(0,0%,78%,.8)}.highlightit-no-header:hover .highlightit-floating-buttons,:root.highlightit-touch-device .highlightit-floating-buttons{opacity:1}.highlightit-button.highlightit-floating:hover{background-color:rgba(65,65,65,.9);transform:scale(1.05)}.highlightit-container[data-theme=light] .highlightit-button.highlightit-floating:hover,.highlightit-theme-light .highlightit-button.highlightit-floating:hover,:root.highlightit-theme-auto.system-light-theme .highlightit-button.highlightit-floating:hover{background-color:hsla(0,0%,67%,.9);transform:scale(1.05)}.highlightit-container pre{background-color:var(--hl-background)!important;border-radius:0 0 6px 6px;margin:0;overflow:auto;padding:16px}.highlightit-container pre::-webkit-scrollbar{height:10px;width:10px}.highlightit-theme-dark .highlightit-container pre::-webkit-scrollbar-track,:root:not(.highlightit-theme-light) .highlightit-container pre::-webkit-scrollbar-track{background:#2d2d2d;border-radius:4px}.highlightit-theme-dark .highlightit-container pre::-webkit-scrollbar-thumb,:root:not(.highlightit-theme-light) .highlightit-container pre::-webkit-scrollbar-thumb{background:#3d3d3d;border-radius:4px}.highlightit-theme-dark .highlightit-container pre::-webkit-scrollbar-thumb:hover,:root:not(.highlightit-theme-light) .highlightit-container pre::-webkit-scrollbar-thumb:hover{background:#4d4d4d}:root.highlightit-theme-light .highlightit-container pre::-webkit-scrollbar-track{background:#e0e0e0;border-radius:4px}:root.highlightit-theme-light .highlightit-container pre::-webkit-scrollbar-thumb{background:silver;border-radius:4px}.highlightit-container[data-theme=light] pre::-webkit-scrollbar-thumb:hover,:root.highlightit-theme-light .highlightit-container pre::-webkit-scrollbar-thumb:hover{background:#a0a0a0}.highlightit-theme-dark .highlightit-container pre,:root:not(.highlightit-theme-light) .highlightit-container pre{scrollbar-color:#3d3d3d #2d2d2d;scrollbar-width:thin}:root.highlightit-theme-light .highlightit-container pre{scrollbar-color:silver #e0e0e0;scrollbar-width:thin}html .highlightit-container[data-theme=dark] pre::-webkit-scrollbar-track{background:#2d2d2d!important;border-radius:4px}html .highlightit-container[data-theme=dark] pre::-webkit-scrollbar-thumb{background:#3d3d3d!important;border-radius:4px}html .highlightit-container[data-theme=dark] pre::-webkit-scrollbar-thumb:hover{background:#4d4d4d!important}html .highlightit-container[data-theme=dark] pre{scrollbar-color:#3d3d3d #2d2d2d!important;scrollbar-width:thin!important}html .highlightit-container[data-theme=light] pre::-webkit-scrollbar-track{background:#e0e0e0!important;border-radius:4px}html .highlightit-container[data-theme=light] pre::-webkit-scrollbar-thumb{background:silver!important;border-radius:4px}html .highlightit-container[data-theme=light] pre::-webkit-scrollbar-thumb:hover{background:#a0a0a0!important}html .highlightit-container[data-theme=light] pre{scrollbar-color:silver #e0e0e0!important;scrollbar-width:thin!important}.highlightit-no-header pre{border-radius:6px}.highlightit-container code{color:var(--hl-text);font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:14px;line-height:1.5;margin-left:0;padding:0!important;tab-size:4;-moz-tab-size:4;white-space:pre}.highlightit-has-line-numbers code{margin-left:1em}.highlightit-anchor-highlight{animation:highlightit-anchor-pulse 2s ease-in-out}@keyframes highlightit-anchor-pulse{0%{box-shadow:0 0 0 0 rgba(var(--hl-text-rgb),.2)}70%{box-shadow:0 0 0 10px rgba(var(--hl-text-rgb),0)}to{box-shadow:0 0 0 0 rgba(var(--hl-text-rgb),0)}}.hljs-keyword{color:var(--hl-keyword)}.hljs-string{color:var(--hl-string)}.hljs-comment{color:var(--hl-comment)}.hljs-function{color:var(--hl-function)}.hljs-number{color:var(--hl-number)}.hljs-class,.hljs-title{color:var(--hl-class)}.hljs-params{color:var(--hl-params)}.hljs-built_in{color:var(--hl-built-in)}.hljs-tag{color:var(--hl-tag)}.hljs-name{color:var(--hl-name)}.hljs-attribute{color:var(--hl-attr)}.hljs-attr-value{color:var(--hl-attr-value)}.hljs-doctype{font-style:italic}.hljs-doctag,.hljs-doctype{color:var(--hl-doctype)}.hljs-variable{color:var(--hl-variable)}.hljs-property{color:var(--hl-property)}.hljs-operator{color:var(--hl-operator)}.hljs-punctuation{color:var(--hl-punctuation)}.hljs-regexp{color:var(--hl-regexp)}.hljs-meta{color:var(--hl-meta);font-style:italic}.hljs-selector{color:var(--hl-selector)}.hljs-constant{color:var(--hl-constant);font-weight:700}.hljs-symbol{color:var(--hl-symbol)}.hljs-important{color:var(--hl-important);font-weight:700}.hljs-type{color:var(--hl-type)}.hljs-literal{color:var(--hl-literal)}.hljs-link{color:var(--hl-link);text-decoration:underline}.hljs-deleted{background-color:rgba(255,0,0,.1);color:var(--hl-deleted)}.hljs-inserted{background-color:rgba(0,255,0,.1);color:var(--hl-inserted)}.hljs-title.function_{color:var(--hl-title-function)}.hljs-title.class_{color:var(--hl-title-class)}.hljs-title.namespace{color:var(--hl-title-namespace)}.hljs-selector-tag{color:var(--hl-tag)}.hljs-selector-class,.hljs-selector-id{color:var(--hl-selector)}.hljs-selector-attr{color:var(--hl-attr)}.hljs-selector-pseudo{color:var(--hl-selector);font-style:italic}.hljs-template-variable{font-style:italic}.hljs-subst,.hljs-template-variable{color:var(--hl-variable)}.hljs-section{color:var(--hl-keyword);font-weight:700}.hljs-bullet{color:var(--hl-operator)}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-quote{color:var(--hl-string);font-style:italic}.hljs-code{background-color:rgba(0,0,0,.05);border-radius:3px;color:var(--hl-class);padding:.1em .2em}.hljs-keyword.operator{color:var(--hl-operator)}.hljs-attr{color:var(--hl-attr)}.hljs-variable.language_{color:var(--hl-params);font-style:italic}.hljs-built_in.shell{color:var(--hl-keyword)}.hljs-symbol.instance{color:var(--hl-symbol)}.hljs-symbol.class_{color:var(--hl-class)}.language-html .hljs-tag,.language-xml .hljs-tag{color:var(--hl-tag)}.language-css .hljs-property{color:var(--hl-property)}.language-javascript .hljs-keyword,.language-js .hljs-keyword{color:var(--hl-keyword)}.language-ts .hljs-type,.language-typescript .hljs-type{color:var(--hl-type)}.language-php .hljs-variable{color:var(--hl-variable)}.language-diff .hljs-deletion{background-color:rgba(255,0,0,.1);color:var(--hl-deleted)}.language-diff .hljs-addition{background-color:rgba(0,255,0,.1);color:var(--hl-inserted)}.highlightit-has-line-numbers{display:flex;isolation:isolate;overflow:hidden;position:relative}.highlightit-line-numbers{border-right:1px solid var(--hl-border);color:var(--hl-text);display:flex;flex-direction:column;font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,monospace;font-size:14px;line-height:1.5;opacity:.7;padding-right:.5em;position:relative;text-align:right;user-select:none;-webkit-user-select:none;-moz-user-select:none}.highlightit-line-numbers:after{background-color:var(--hl-header-bg);bottom:0;content:"";left:0;opacity:.05;pointer-events:none;position:absolute;right:0;top:0;z-index:-1}.highlightit-has-line-numbers pre{border-radius:0!important;flex:1;margin:0;padding-left:.5em;position:relative}.highlightit-container[data-theme=light] .highlightit-line-numbers,.highlightit-theme-light .highlightit-line-numbers,:root.highlightit-theme-auto.system-light-theme .highlightit-line-numbers{border-right-color:#ccc!important}.highlightit-visually-hidden{height:1px!important;margin:-1px!important;overflow:hidden!important;padding:0!important;position:absolute!important;width:1px!important;clip:rect(0,0,0,0)!important;border:0!important;opacity:.01!important;pointer-events:none!important;white-space:nowrap!important}.highlightit-line-number-container,.highlightit-with-lines .highlightit-line-number{align-items:center;display:flex;height:1.5em;justify-content:flex-end;margin-bottom:0;position:relative}.highlightit-with-lines .highlightit-line-number{padding-right:1em;transition:opacity .2s ease;z-index:1}.highlightit-line-number-shareable{cursor:pointer}.highlightit-container[data-with-share]\t.highlightit-line-number-container:hover\t.highlightit-line-number,[data-with-share] .highlightit-line-number-container:hover .highlightit-line-number{opacity:0}.highlightit-line-share{align-items:center;background:transparent;border:none;border-radius:3px;color:var(--hl-text);cursor:pointer;display:flex;height:auto;justify-content:center;margin-right:1em;opacity:0;padding:4px;position:absolute;right:0;top:50%;transform:translateY(-50%);transition:opacity .2s ease;width:auto;z-index:2}.highlightit-line-number-container:hover .highlightit-line-share{opacity:.7}.highlightit-line-share:hover{background:var(--hl-hover-bg);opacity:1!important}.highlightit-line-share.copied{background:var(--hl-hover-bg);color:var(--hl-copied-color);opacity:1}.highlightit-line-number-container:has(.highlightit-line-share.copied) .highlightit-line-number{opacity:.3}.highlightit-line-number-container.has-copied-button .highlightit-line-number{opacity:.3}.highlightit-line-share svg{height:14px;width:14px}.highlightit-line-highlight{position:relative}.highlightit-line-highlight-overlay{animation:highlightit-line-pulse 2s ease-in-out;background-color:rgba(var(--hl-text-rgb),.1);bottom:0;left:0;pointer-events:none;position:absolute;right:0;top:0;z-index:1}@keyframes highlightit-line-pulse{0%{background-color:rgba(var(--hl-text-rgb),.2)}70%{background-color:rgba(var(--hl-text-rgb),.1)}to{background-color:rgba(var(--hl-text-rgb),.1)}}',document.head.appendChild(t)})())})("undefined"!=typeof window?window:this);