@diplodoc/transform
Version:
A simple transformer of text in YFM (Yandex Flavored Markdown) to HTML
3 lines (2 loc) • 22.7 kB
JavaScript
;(()=>{(()=>{var ve=Object.create,Y=Object.defineProperty,be=Object.getOwnPropertyDescriptor,oe=Object.getOwnPropertyNames,ie=Object.getOwnPropertySymbols,ye=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty,Te=Object.prototype.propertyIsEnumerable,Q=(e,t,n)=>t in e?Y(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,le=(e,t)=>{for(var n in t||(t={}))re.call(t,n)&&Q(e,n,t[n]);if(ie)for(var n of ie(t))Te.call(t,n)&&Q(e,n,t[n]);return e},Le=(e,t)=>function(){return t||(0,e[oe(e)[0]])((t={exports:{}}).exports,t),t.exports},we=(e,t,n,d)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of oe(t))!re.call(e,r)&&r!==n&&Y(e,r,{get:()=>t[r],enumerable:!(d=be(t,r))||d.enumerable});return e},_e=(e,t,n)=>(n=e!=null?ve(ye(e)):{},we(t||!e||!e.__esModule?Y(n,"default",{value:e,enumerable:!0}):n,e)),z=(e,t,n)=>Q(e,typeof t!="symbol"?t+"":t,n),Ae=(e,t,n)=>new Promise((d,r)=>{var v=h=>{try{s(n.next(h))}catch(L){r(L)}},c=h=>{try{s(n.throw(h))}catch(L){r(L)}},s=h=>h.done?d(h.value):Promise.resolve(h.value).then(v,c);s((n=n.apply(e,t)).next())}),Ee=Le({"node_modules/get-root-node-polyfill/index.js"(e,t){"use strict";function n(c){var s=typeof c=="object"&&!!c.composed;return s?d(this):r(this)}function d(c){var s=r(c);return v(s)?d(s.host):s}function r(c){return c.parentNode!=null?r(c.parentNode):c}function v(c){return c.nodeName==="#document-fragment"&&c.constructor.name==="ShadowRoot"}typeof t=="object"&&t.exports&&(t.exports=n)}});(()=>{var e="yfm_cut",t={CUT:".yfm .yfm-cut",TITLE:".yfm .yfm-cut-title",CONTENT:".yfm .yfm-cut-content"},n={OPEN:"open"},d=c=>{let s=c.composedPath();return Array.isArray(s)&&s.length>0?s[0]:c.target},r=c=>{let s=d(c);return!s||!s.matches},v=class{constructor(c){z(this,"__doc"),z(this,"_onDocClick",s=>{if(r(s))return;let h=this._findTitleInPath(s);h&&this._toggleCut(h)}),z(this,"_matchTitle",s=>{var h;return s instanceof HTMLElement?(h=s==null?void 0:s.matches)==null?void 0:h.call(s,t.TITLE):!1}),this.__doc=c,this.__doc.addEventListener("click",this._onDocClick)}destroy(){this.__doc.removeEventListener("click",this._onDocClick)}focusActiveCut(){let c=window.location.hash.slice(1),s=document.getElementById(c);s instanceof HTMLElement&&s.matches(t.CUT)&&(s.classList.toggle(n.OPEN),s.setAttribute("open","true"),setTimeout(()=>{s.classList.add("cut-highlight"),s.scrollIntoView()},70),setTimeout(()=>{s.classList.remove("cut-highlight")},1e3))}_findTitleInPath(c){var s,h;let L=d(c);return this._matchTitle(L)?L:(h=(s=c.composedPath)==null?void 0:s.call(c))==null?void 0:h.find(this._matchTitle)}_toggleCut(c){var s;(s=c.parentElement)==null||s.classList.toggle(n.OPEN)}};typeof window<"u"&&typeof document<"u"&&!window[e]&&(window[e]=new v(document))})(),(()=>{var e="yfm-tabs",t="yfm-tab",n="yfm-tab-panel",d="yfm-tab-list",r="active",v="data-diplodoc-group",c="data-diplodoc-key",s="data-diplodoc-variant",h="data-diplodoc-id",L="defaultTabsGroup-",C="data-diplodoc-forced",M="yfm-tabs-dropdown-select",W="yfm-tabs-vertical",H=(o=>(o.Regular="regular",o.Radio="radio",o.Dropdown="dropdown",o.Accordion="accordion",o))(H||{}),w=Symbol.for("diplodocTabs"),_=o=>{let i=o.composedPath();return Array.isArray(i)&&i.length>0?i[0]:o.target},$=o=>{let i=_(o);return!i||!i.matches},P=o=>Math.abs(o.scrollHeight-o.clientHeight)>1?o:o.parentElement?P(o.parentElement):void 0,k=(o,i)=>{let l=o.getBoundingClientRect(),a=i.getBoundingClientRect();return{top:l.top-a.top,left:l.left-a.left,scrollTop:i.scrollTop,scrollLeft:i.scrollLeft}},b={TABS:`.${e}`,TAB_LIST:`.${d}`,TAB:`.${t}`,TAB_PANEL:`.${n}`,VERTICAL_TABS:`.${W}`},I=class{constructor(o,i={}){this._onSelectTabHandlers=new Set,this._currentPageTabGroups=[],this._isRestoringTabs=!1,this._document=o,this._options=Object.assign({saveTabsToLocalStorage:!1,saveTabsToQueryStateMode:"none"},i),this._document.addEventListener("click",l=>{let a=_(l);if(l.target&&this.hideAllDropdown(l.target),$(l))return;if(this.isElementDropdownSelect(a)){a.classList.toggle(r);return}if(!this.isValidTabElement(a))return;let u=this.getTabDataFromHTMLElement(a);u&&this._selectTab(u,a)}),this._document.addEventListener("keydown",l=>{let a=null;switch(l.key){case"ArrowLeft":{a="left";break}case"ArrowRight":{a="right";break}case"ArrowUp":{a="left";break}case"ArrowDown":{a="right";break}}if(!a)return;let u=_(l);if($(l)||!this.isValidTabElement(u))return;let{tabs:f,nodes:m}=this.getTabs(u),p=this.getTabDataFromHTMLElement(u),g=f.findIndex(({key:T})=>(p==null?void 0:p.key)&&T===p.key);if(!p||f.length<=1||g===-1)return;let y=(g+(a==="left"?-1:1)+f.length)%f.length;this.selectTab(f[y]),m[y].focus()})}configure(o){this._options=Object.assign(this._options,o)}onSelectTab(o){return this._onSelectTabHandlers.add(o),()=>{this._onSelectTabHandlers.delete(o)}}selectTabById(o,i){let l=this._document.querySelector(`${b.TAB}[${h}="${o}"]`);if(!l||!this.isValidTabElement(l))return;let a=this.getTabDataFromHTMLElement(l);a&&this._selectTab(a,l),i!=null&&i.scrollToElement&&l.scrollIntoView()}selectTab(o){this._selectTab(o)}restoreTabs(o){this._isRestoringTabs=!0;try{for(let[i,l]of Object.entries(o))if(i){let a=le({group:i},l);this.selectTab(a)}}finally{this._isRestoringTabs=!1}}getTabsFromLocalStorage(){return JSON.parse(localStorage.getItem("tabsHistory")||"{}")}getTabsFromSearchQuery(){let o={},i=new URLSearchParams(window.location.search);return i.has("tabs")&&(i.get("tabs")||"").split(",").forEach(l=>{let a=l.split("_"),[u,f]=a,m="regular";if(a.length===3&&(m=a[2]),u&&f&&Object.values(H).includes(m)){let p=f;o[u]={key:p,variant:m}}}),o}updateLocalStorageWithTabs(o){this._options.saveTabsToLocalStorage&&(this._isRestoringTabs||localStorage.setItem("tabsHistory",JSON.stringify(o)))}updateQueryParamWithTabs(o){if(this._isRestoringTabs)return;let i=new URLSearchParams(window.location.search),l=Object.entries(o).map(([f,{key:m,variant:p}])=>p==="regular"?`${f}_${m}`:`${f}_${m}_${p}`);l.length>0?i.set("tabs",l.join(",")):i.delete("tabs");let a=history.state||{},u=new URL(window.location.href);u.search=i.toString(),window.history.replaceState(le({},a),document.title,u.href)}getCurrentPageTabHistory(o){return Object.fromEntries(Object.entries(o).filter(([i])=>this._currentPageTabGroups.includes(i)))}onPageChanged(){this._currentPageTabGroups=this.getCurrentPageTabGroups()}getCurrentPageTabGroups(){let o=this._document.getElementsByClassName(e),i=new Set;return Array.from(o).forEach(l=>{let a=l.getAttribute(v);a&&i.add(a)}),Array.from(i)}clearTabsPreferred(){localStorage.removeItem("tabsHistory"),this.updateQueryParamWithTabs({})}_selectTab(o,i){let{group:l,key:a,variant:u}=o;if(!l)return;this.saveTabPreferred({group:l,key:a,variant:u});let f=i&&P(i),m=f&&k(i,f);this.updateHTML({group:l,key:a,variant:u},i,u)>0&&(this.fireSelectTabEvent({group:l,key:a,variant:u},i==null?void 0:i.dataset.diplodocId),m&&this.resetScroll(i,f,m))}updateHTML(o,i,l){switch(l){case"radio":return this.updateHTMLRadio(o,i);case"accordion":return this.updateHTMLAccordion(o,i);case"regular":return this.updateHTMLRegular(o);case"dropdown":return this.updateHTMLDropdown(o);default:return 0}}saveTabPreferred(o){let i={};switch(this._options.saveTabsToLocalStorage&&(i=JSON.parse(localStorage.getItem("tabsHistory")||"{}")),i[o.group]={key:o.key,variant:o.variant},this._options.saveTabsToLocalStorage&&this.updateLocalStorageWithTabs(i),this._options.saveTabsToQueryStateMode){case"all":{this.updateQueryParamWithTabs(i);break}case"page":{this.updateQueryParamWithTabs(this.getCurrentPageTabHistory(i));break}}}updateHTMLRadio(o,i){let{group:l,key:a}=o,{isForced:u,root:f}=this.didTabOpenForce(i),m=u?`.yfm-vertical-tab[${C}="true"]`:"",p=this._document.querySelectorAll(`${b.TABS}[${v}="${l}"] ${b.TAB}[${c}="${a}"]${m}`);u&&(f==null||f.removeAttribute(C));let g=0;return p.forEach(y=>{let T=y.parentNode.children;for(let E=0;E<T.length;E+=2){let[S,A]=[T.item(E),T.item(E+1)],N=S.children.item(0);if(S===y){N.checked?(S.classList.remove("active"),A==null||A.classList.remove("active"),N.removeAttribute("checked")):(S.classList.add("active"),A==null||A.classList.add("active"),N.setAttribute("checked","true"));continue}N.hasAttribute("checked")&&(S.classList.remove("active"),A==null||A.classList.remove("active"),N.removeAttribute("checked")),g++}}),g}updateHTMLRegular(o){let{group:i,key:l}=o,a=this._document.querySelectorAll(`${b.TABS}[${v}="${i}"] ${b.TAB}[${c}="${l}"]`),u=0;return a.forEach(f=>{let m=f;if(!this.isValidTabElement(m)||m.dataset.diplodocIsActive==="true")return;u++;let p=f,g=p.parentNode,y=g==null?void 0:g.parentNode,T=Array.from((g==null?void 0:g.querySelectorAll(b.TAB))||[]),E=Array.from((y==null?void 0:y.children)||[]).filter(A=>A.classList.contains(n)),S=T.indexOf(p);T.forEach((A,N)=>{let Ye=E[N],F=N===S,Qe=A;Qe.dataset.diplodocIsActive=F?"true":"false",A.classList.toggle(r,F),A.setAttribute("aria-selected",F.toString()),A.setAttribute("tabindex",F?"0":"-1"),Ye.classList.toggle(r,F)})}),u}updateHTMLDropdown(o){let{group:i,key:l}=o,a=this._document.querySelectorAll(`${b.TABS}[${v}="${i}"] ${b.TAB}[${c}="${l}"]`),u=0;return a.forEach(f=>{let m=f.closest(`[${s}=dropdown]`);if(!(m!=null&&m.children))return;let p=m.children.item(0),g=m.children.item(1);p==null||p.classList.remove(r);let y=Array.from((g==null?void 0:g.children)||[]).indexOf(f)+2;for(let T=2;T<m.children.length;T++){let E=m.children.item(T),S=g==null?void 0:g.children.item(T-2);if(u++,y===T){E==null||E.classList.add(r),S.classList.add(r),p.innerHTML=f.innerHTML,p.classList.add("filled");continue}S.classList.remove(r),E.classList.remove(r)}}),u}updateHTMLAccordion(o,i){let{group:l,key:a}=o,u=this._document.querySelectorAll(`${b.TABS}[${v}="${l}"] ${b.TAB}[${c}="${a}"]`),f=0;return u.forEach(m=>{let p=m.closest(`[${s}=accordion]`);if(p!=null&&p.children)for(let g=0;g<p.children.length;g+=2){let y=p.children.item(g),T=p.children.item(g+1);if(f++,m===y){y==null||y.classList.toggle(r),T==null||T.classList.toggle(r);continue}y==null||y.classList.remove(r),T==null||T.classList.remove(r)}}),i&&!this.checkVisible(i)&&setTimeout(()=>{i.scrollIntoView({block:"nearest"})}),f}checkVisible(o){let i=o.getBoundingClientRect(),l=Math.max(document.documentElement.clientHeight,window.innerHeight);return!(i.bottom<0||i.top-l>=0)}hideAllDropdown(o){this._document.querySelectorAll(".yfm-tabs-dropdown-select.active").forEach(i=>{i.contains(o)||i.classList.remove(r)})}resetScroll(o,i,l){let a=k(o,i),u=a.top-l.top,f=a.left-l.left,m=a.scrollTop-l.scrollTop,p=a.scrollLeft-l.scrollLeft;i.scrollTo(i.scrollLeft+f-p,i.scrollTop+u-m)}didTabOpenForce(o){if(!o)return{};if(o.dataset.diplodocForced)return{root:o,isForced:!0};let i=o.dataset.diplodocVerticalTab?o:o.parentElement,l=typeof(i==null?void 0:i.dataset.diplodocForced)!="undefined";return{root:i,isForced:l}}fireSelectTabEvent(o,i){let{group:l,key:a,variant:u}=o,f=l.startsWith(L)?{key:a,variant:u}:o;this._onSelectTabHandlers.forEach(m=>{m({tab:f,currentTabId:i})})}getTabsType(o){let i=o.closest(`[${s}]`);if(i)return i.dataset.diplodocVariant}isValidTabElement(o){return!!this.getTabsType(o)}isElementDropdownSelect(o){return o.classList.contains(M)}getTabDataFromHTMLElement(o){var i,l,a;let u=this.getTabsType(o);if(u==="radio"){let p=o.dataset.diplodocVerticalTab?o:o.parentElement,g=p.dataset.diplodocKey,y=(i=p.closest(b.TABS))==null?void 0:i.dataset.diplodocGroup;return g&&y?{group:y,key:g,variant:"radio"}:null}if(u==="dropdown"||u==="accordion"){let p=o.dataset.diplodocKey,g=(l=o.closest(b.TABS))==null?void 0:l.dataset.diplodocGroup;return p&&g?{group:g,key:p,variant:u}:null}let f=o.dataset.diplodocKey,m=(a=o.closest(b.TABS))==null?void 0:a.dataset.diplodocGroup;return f&&m?{group:m,key:f,variant:"regular"}:null}getTabs(o){var i,l;let a=(i=o.closest(b.TABS))==null?void 0:i.dataset.diplodocGroup,u=(l=o.closest(b.TAB_LIST))==null?void 0:l.querySelectorAll(b.TAB),f=[];return u.forEach(m=>{let p=m==null?void 0:m.dataset.diplodocKey;p&&f.push({group:a,key:p,variant:"regular"})}),{tabs:f,nodes:u}}};typeof window!="undefined"&&typeof document!="undefined"&&!window[w]&&(window[w]=new I(document))})();var Se=_e(Ee());typeof document!="undefined"&&function(e){let t=e.matches||e.matchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector;t?e.matches=e.matchesSelector=t:e.matches=e.matchesSelector=function(d){let v=(e.getRootNode?e.getRootNode():Se.default.call(e)).querySelectorAll(d),c=this;return Array.prototype.some.call(v,s=>s===c)}}(Element.prototype);var R=e=>{let t=e.composedPath();return Array.isArray(t)&&t.length>0?t[0]:e.target},j=e=>{let t=R(e);return!t||!t.matches},q=e=>Ae(void 0,null,function*(){if(!e)return;if(navigator.clipboard&&typeof navigator.clipboard.writeText)return navigator.clipboard.writeText(e);let t=document.createElement("textarea");t.setAttribute("style","position: absolute; left: 1000%"),t.textContent=e,document.body.append(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}),Ce=".yfm-clipboard-button";function Oe(e){if(!e)return;let t=e.getAttribute("data-animation"),n=e.getRootNode().getElementById(`visibileAnimation-${t}`);n&&n.beginElement()}function Pe(e){let t=e.parentNode;if(!t)return;let n=t.querySelector("pre code");if(!n)return;let d=Array.from(n.childNodes).filter(r=>!(r instanceof HTMLElement&&r.classList.contains("yfm-line-number"))).map(r=>r.textContent).join("");q(d).then(()=>{Oe(t.querySelector(".yfm-clipboard-icon"))})}typeof document!="undefined"&&document.addEventListener("click",e=>{let t=R(e),n=t.matches(Ce);j(e)||!n||Pe(t)});var ke=".yfm-clipboard-anchor";typeof document!="undefined"&&document.addEventListener("click",e=>{let t=R(e);if(j(e)||!t.matches(ke))return;let n=t.getAttribute("data-href")||"",d=new URL(n,window.location.href).toString();q(d)});var Ne=".yfm-clipboard-inline-code",B="open",K={TITLE:".yfm .yfm-term_title",CONTENT:".yfm .yfm-term_dfn"},D="open",V=K.CONTENT.replace(/\./g,"")+" "+D,G=!0;function Ie(e,t){let n=t.getAttribute("id")||Math.random().toString(36).substr(2,8);e==null||e.setAttribute("term-id",n)}function Re(e,t){let n=t.getAttribute("aria-live")||"polite";e==null||e.setAttribute("aria-live",n),e==null||e.setAttribute("aria-modal","true")}function J(e,t){let{x:n,y:d,right:r,left:v,width:c,height:s}=t.getBoundingClientRect(),h=ae(t);if(!h)return;let{right:L,left:C}=h.getBoundingClientRect();if((L<v||C>r)&&!G){U(e);return}G&&h&&(h.addEventListener("scroll",se),G=!1);let M=Number(e.getAttribute("relativeX")),W=Number(e.getAttribute("relativeY"));if(M===n&&W===d)return;e.setAttribute("relativeX",String(n)),e.setAttribute("relativeY",String(d));let H=s+5,w=e.parentElement;if(!w)return;let{width:_}=e.getBoundingClientRect(),{left:$}=w.getBoundingClientRect(),P=Number(O(t).left),k=_+P,b=P-_<0,I=k>document.body.clientWidth,i=(I||document.dir==="rtl")&&!b?_-c:0,l=O(w).top-w.offsetTop,u=I?k-document.body.clientWidth+5:0,f=O(t).left-$+w.offsetLeft-i,m=f+_>=document.body.clientWidth;e.style.top=Number(O(t).top+H-l)+"px",e.style.left=Number(f-(m?u:0))+"px"}function se(){let e=document.getElementsByClassName(V)[0];if(!e)return;let t=e.getAttribute("term-id")||"",n=document.getElementById(t);n&&J(e,n)}function ae(e){return e?e.closest("table")||e.closest("code")||e.parentElement:null}function ce(e){let t=document.getElementsByClassName(V)[0],n=e.getAttribute("id"),d=e.getAttribute("term-key"),r=document.getElementById(d+"_element");if(t&&n===t.getAttribute("term-id")){U(t);return}let c=e.closest([K.CONTENT.replace(" ",""),D].join("."));t&&!c&&U(t),!(!e.matches(K.TITLE)||!r)&&(Ie(r,e),Re(r,e),J(r,e),r.classList.toggle(D),Be(r))}function U(e){e.classList.remove(D);let t=de(e),n=ae(t);n&&(n.removeEventListener("scroll",se),G=!0)}function O(e){let t=e.getBoundingClientRect(),n=document.body,d=document.documentElement,r=window.pageYOffset||d.scrollTop||n.scrollTop,v=window.pageXOffset||d.scrollLeft||n.scrollLeft,c=d.clientTop||n.clientTop||0,s=d.clientLeft||n.clientLeft||0,h=t.top+r-c,L=t.left+v-s;return{top:Math.round(h),left:Math.round(L)}}function Be(e){let t=e.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),n=t[0],d=t[t.length-1];n&&n.focus(),e.addEventListener("keydown",function(r){(r.key==="Tab"||r.keyCode===9)&&(r.shiftKey?document.activeElement===n&&(d.focus(),r.preventDefault()):document.activeElement===d&&(n.focus(),r.preventDefault()))})}function de(e){let t=e.getAttribute("term-id");return t?document.getElementById(t):null}var x=null,X=!0;function Z(){return document.querySelector(".yfm-inline-code-tooltip")}function He(e,t){let n=t.getAttribute("aria-live")||"polite";e==null||e.setAttribute("aria-live",n),e==null||e.setAttribute("aria-modal","true")}function ue(){x&&(clearTimeout(x),x=null)}function fe(e){return e?e.closest("table")||e.closest("code")||e.parentElement:null}function me(){let e=Z();if(!e)return;let t=e.getAttribute("inline-id")||"",n=document.getElementById(t);n&&ee(e,n)}function ee(e,t){let{x:n,y:d,right:r,left:v,width:c,height:s}=t.getBoundingClientRect(),h=fe(t);if(!h)return;let{right:L,left:C}=h.getBoundingClientRect();if((L<v||C>r)&&!X){te(e);return}X&&h&&(h.addEventListener("scroll",me),X=!1);let M=Number(e.getAttribute("relativeX")),W=Number(e.getAttribute("relativeY"));if(M===n&&W===d)return;e.setAttribute("relativeX",String(n)),e.setAttribute("relativeY",String(d));let H=s+5,w=e.parentElement;if(!w)return;let{width:_}=e.getBoundingClientRect(),{left:$}=w.getBoundingClientRect(),P=Number(O(t).left),k=_+P,b=P-_<0,I=k>document.body.clientWidth,i=(I||document.dir==="rtl")&&!b?_-c:0,l=O(w).top-w.offsetTop,u=I?k-document.body.clientWidth+5:0,f=O(t).left-$+w.offsetLeft-i,m=f+_>=document.body.clientWidth;e.style.top=Number(O(t).top+H-l)+"px",e.style.left=Number(f-(m?u:0))+"px"}function pe(e){let t=e.getAttribute("inline-id");return t?document.getElementById(t):null}function $e(e){e.classList.remove(B);let t=pe(e),n=fe(t);e.removeAttribute("inline-id"),n&&(n.removeEventListener("scroll",me),X=!0)}function De(e){let t=document.getElementById("tooltip_inline_clipboard_dialog");if(!(!e.matches(".yfm-clipboard-inline-code")||!t))return t.setAttribute("inline-id",e.getAttribute("id")||""),He(t,e),ee(t,e),t.classList.contains(B)?(t.classList.remove(B),requestAnimationFrame(()=>{t.classList.add(B)})):t.classList.add(B),t}function te(e){ue(),$e(e)}function he(e){let t=De(e);t&&(ue(),x=setTimeout(()=>{te(t),x=null},1e3))}function xe(e){let t=e.innerText;t&&q(t).then(()=>{he(e)})}typeof document!="undefined"&&(document.addEventListener("click",e=>{let t=R(e),n=t.matches(Ne);j(e)||!n||xe(t)}),document.addEventListener("keydown",e=>{var t;if(e.key==="Enter"&&document.activeElement){let d=document.activeElement,r=d.innerText;if(!r)return;q(r).then(()=>{he(d)})}let n=Z();e.key==="Escape"&&n&&(te(n),(t=pe(n))==null||t.focus())}),window.addEventListener("resize",()=>{let e=Z();if(!e)return;let t=e.getAttribute("inline-id")||"",n=document.getElementById(t);if(!n){e.classList.toggle(B);return}ee(e,n)})),typeof document!="undefined"&&(document.addEventListener("click",e=>{(R(e)||!j(e))&&ce(R(e))}),document.addEventListener("keydown",e=>{var t;let n=document.getElementsByClassName(V)[0];e.key==="Enter"&&document.activeElement&&ce(document.activeElement),e.key==="Escape"&&n&&(U(n),(t=de(n))==null||t.focus())}),window.addEventListener("resize",()=>{let e=document.getElementsByClassName(V)[0];if(!e)return;let t=e.getAttribute("term-id")||"",n=document.getElementById(t);if(!n){e.classList.toggle(D);return}J(e,n)}));var Me="[wide-content]",We='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="currentColor" fill-rule="evenodd" d="M7.754 2.004a.75.75 0 0 0 0 1.5h4.75v4.742a.75.75 0 0 0 1.5 0V2.754a.75.75 0 0 0-.75-.75zm.492 11.992a.75.75 0 0 0 0-1.5h-4.75V7.754a.75.75 0 0 0-1.5 0v5.492a.75.75 0 0 0 .75.75z" clip-rule="evenodd"/></svg>',Fe='<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg" class="close-action"><path fillRule="evenodd" clipRule="evenodd" d="M9.46967 9.46967C9.76256 9.17678 10.2374 9.17678 10.5303 9.46967L14 12.9393L17.4697 9.46967C17.7626 9.17678 18.2374 9.17678 18.5303 9.46967C18.8232 9.76256 18.8232 10.2374 18.5303 10.5303L15.0607 14L18.5303 17.4697C18.8232 17.7626 18.8232 18.2374 18.5303 18.5303C18.2374 18.8232 17.7626 18.8232 17.4697 18.5303L14 15.0607L10.5303 18.5303C10.2374 18.8232 9.76256 18.8232 9.46967 18.5303C9.17678 18.2374 9.17678 17.7626 9.46967 17.4697L12.9393 14L9.46967 10.5303C9.17678 10.2374 9.17678 9.76256 9.46967 9.46967Z" fill="var(--g-color-text-primary)" fillOpacity="0.85"/></svg>',ne=()=>{window.wideTemplate&&(window.wideTemplate.style.display="none",window.wideTemplate.content(void 0))},je=e=>{if(e.tagName!=="TABLE")return;let t=Array.from(e.children);return t.find(r=>r.tagName==="THEAD")?void 0:t.find(r=>r.tagName==="TBODY")},qe=()=>{if(window.wideTemplate)return window.wideTemplate;let e=document.createElement("div");e.classList.add("dc-doc-page","wide-container");let t=document.createElement("div");t.classList.add("wide-content-overlay"),t.addEventListener("click",ne);let n=document.createElement("div");n.classList.add("yfm","wide-content-wrapper");let d=document.createElement("div");d.classList.add("wide-toolbar");let r=document.createElement("div");r.classList.add("wide-actions"),r.addEventListener("click",ne),r.innerHTML=Fe;let v=document.createElement("p");v.classList.add("wide-entity-name"),e.label=s=>{v.innerHTML=s||""};let c=document.createElement("div");return c.classList.add("wide-content"),e.content=s=>{var h;if(typeof s=="undefined"){c.innerHTML="";return}let L=s.cloneNode(!0),C=je(L);(h=C==null?void 0:C.classList)==null||h.add("wide-thead-content"),c.replaceChildren(L)},d.append(v,r),n.append(d,c),e.append(t,n),e.style.display="none",document.body.appendChild(e),window.wideTemplate=e,e},Ve=e=>{let t=qe();t.label(e.title),t.content(e),t.style.display="flex"},Ge={render:Ve,remove:ne},Ue=e=>{var t;if((t=e.parentElement)!=null&&t.classList.contains("wide-element-wrapper"))return;e.classList.add("wide-inner-element");let n=document.createElement("div");n.innerHTML=We,n.classList.add("wide-content-viewer"),n.addEventListener("click",()=>Ge.render(e));let d=document.createElement("div");d.classList.add("wide-element-wrapper"),e.before(d),d.appendChild(e),d.appendChild(n)},ge=()=>{Array.from(document.querySelectorAll(Me)).forEach(Ue)};typeof window!="undefined"&&typeof document!="undefined"&&window.addEventListener("load",ge);var Xe=()=>{ge()};typeof window!="undefined"&&(window.patchAfterRender=Xe)})();})();
//# sourceMappingURL=yfm.min.js.map