05-tilda-export-backup/Tilda_ Масонство в России. Шведская система. Этюд I._files/t-tooltip.min.js
2025-10-29 19:50:39 +03:00

111 lines
19 KiB
JavaScript

(()=>{"use strict";const t=5,e=6,i=12,o=300,n=150,s=9999998,r="top",l="hint",c="hover",a=600,h=600,d=5;function u(t){if(!(t=t||""))return!1;const e=t.match(/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(shorts\/)|(embed\/)|(watch\?v=))([^#&?]*).*/);return!(!e||11!==e[8].length)&&e[8]}function p(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}function m(t,e){return typeof t===e?t:arguments.length>2&&void 0!==arguments[2]?arguments[2]:""}function f(t,e,i){return e.includes(t)?t:i}const g={ru:"com",by:"biz",kz:"pro",cc:"one"}[function(){const t={ru:"com",by:"biz",kz:"pro",cc:"one"};let e="cc";if("undefined"!=typeof window){const i=window.location.origin.split(".").pop()||"";Object.keys(t).includes(i)&&(e=i)}return e}()],v=[`https://app.tildacdn.${g}/tfront/plugins/tooltip/t-tooltip.min.js`,`https://app.tildacdn.${g}/tfront/plugins/tooltip/t-tooltip.min.css`],b={position:"bottom",closeDelay:0,maxWidth:200,zIndex:999999999},w={position:"top",type:"info",closeDelay:0,maxWidth:250,zIndex:999999999};var y=function(t,e,i,o){var n;e[0]=0;for(var s=1;s<e.length;s++){var r=e[s++],l=e[s]?(e[0]|=r?1:2,i[e[s++]]):e[++s];3===r?o[0]=l:4===r?o[1]=Object.assign(o[1]||{},l):5===r?(o[1]=o[1]||{})[e[++s]]=l:6===r?o[1][e[++s]]+=l+"":r?(n=t.apply(l,y(t,l,i,["",null])),o.push(n),l[0]?e[0]|=2:(e[s-2]=0,e[s]=n)):o.push(l)}return o},k=new Map;const T=function(t){var e=k.get(this);return e||(e=new Map,k.set(this,e)),(e=y(this,e.get(t)||(e.set(t,e=function(t){for(var e,i,o=1,n="",s="",r=[0],l=function(t){1===o&&(t||(n=n.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?r.push(0,t,n):3===o&&(t||n)?(r.push(3,t,n),o=2):2===o&&"..."===n&&t?r.push(4,t,0):2===o&&n&&!t?r.push(5,0,!0,n):o>=5&&((n||!t&&5===o)&&(r.push(o,0,n,i),o=6),t&&(r.push(o,t,0,i),o=6)),n=""},c=0;c<t.length;c++){c&&(1===o&&l(),l(c));for(var a=0;a<t[c].length;a++)e=t[c][a],1===o?"<"===e?(l(),r=[r],o=3):n+=e:4===o?"--"===n&&">"===e?(o=1,n=""):n=e+n[0]:s?e===s?s="":n+=e:'"'===e||"'"===e?s=e:">"===e?(l(),o=1):o&&("="===e?(o=5,i=n,n=""):"/"===e&&(o<5||">"===t[c][a+1])?(l(),3===o&&(r=r[0]),o=r,(r=r[0]).push(2,0,o),o=0):" "===e||"\t"===e||"\n"===e||"\r"===e?(l(),o=2):n+=e),3===o&&"!--"===n&&(o=4,r=r[0])}return l(),r}(t)),e),arguments,[])).length>1?e:e[0]}.bind((function(t,e){this[0]=3;for(var i=arguments.length,o=new Array(i>2?i-2:0),n=2;n<i;n++)o[n-2]=arguments[n];if("function"==typeof t){const i=e?.bindTo;i&&delete e.bindTo;const n=new t(e).render(),s=n.querySelector("[children-container]")||n;if(s.append(...o.flat()),s.removeAttribute("children-container"),Array.isArray(i)){const[t,e]=i;t&&"object"==typeof t&&["string","number"].includes(typeof e)&&(t[e]=n)}return n}if("string"==typeof t){const i=document.createElement(t);return e&&Object.entries(e).forEach((t=>{let[e,o]=t;if(e.startsWith("on"))Array.isArray(o)?o.forEach((t=>i.addEventListener(e.substring(2).toLowerCase(),t))):"function"==typeof o&&i.addEventListener(e.substring(2).toLowerCase(),o);else if("className"===e&&"string"==typeof o)i.classList.add(...o.split(" "));else if("tooltip"===e&&"string"==typeof o)n=i,s=o,$(v).then((()=>{if(!window.Tooltip)return;const t=new window.Tooltip({...b,target:n,content:{title:s}});n.updateTooltipContent=t.updateContent.bind(t)}));else if("infoTooltip"===e&&o&&"object"==typeof o)!function(t,e){$(v).then((()=>{if(!window.Tooltip)return;const i=new window.Tooltip({...w,target:t,content:e});t.updateTooltipContent=i.updateContent.bind(i)}))}(i,o);else if("bindTo"===e){if(Array.isArray(o)){const[t,e]=o;t&&"object"==typeof t&&["string","number"].includes(typeof e)&&(t[e]=i)}}else"testid"===e||("string"==typeof o||"number"==typeof o?i.setAttribute(e,o.toString()):"boolean"==typeof o&&o?i.setAttribute(e,""):o&&(i[e]=o));var n,s})),i.append(...o.flat()),i}if(t instanceof Element)return t;throw new Error("Неверный тип для создания элемента")}));function $(t){const e=(Array.isArray(t)?t:[t]).map((t=>{const e=t.split("."),i=e.pop()?.toLowerCase(),o=window.ver?"?v="+window.ver:"";return"js"===i||"css"===i?function(t,e){return new Promise(((i,o)=>{const n="style"===e,s=n?"link":"script",r=n?"href":"src";let l;try{const{pathname:e}=new URL(t,window.location.href);l=e}catch(e){l=t}const c=document.querySelector(`${s}[${r}*="${l}"]`);if(c)return"true"===c.getAttribute("data-loading")?(c.addEventListener("load",i),void c.addEventListener("error",o)):i(new Event("load"));const a=document.createElement(s);a.setAttribute(r,t),n&&a.setAttribute("rel","stylesheet"),a.setAttribute("data-loading","true"),a.addEventListener("load",(()=>{a.removeAttribute("data-loading"),i(new Event("load"))})),a.addEventListener("error",(()=>{document.head.removeChild(a),o(new Error(`Failed to load resource: ${t}`))})),document.head.appendChild(a)}))}(t+o,"js"===i?"script":"style"):Promise.reject(new Error("Unknown resource extension. Make sure the resource url ends with .css or .js"))}));return Promise.all(e)}function _(t,e){E(t,e),e.add(t)}function E(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function C(t,e){var i=function(t,e,i){if(!e.has(t))throw new TypeError("attempted to "+i+" private field on non-instance");return e.get(t)}(t,e,"get");return function(t,e){if(e.get)return e.get.call(t);return e.value}(t,i)}function O(t,e,i){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return i}var S=new WeakSet,W=new WeakSet,x=new WeakSet,L=new WeakSet,A=new WeakSet,P=new WeakSet,N=new WeakSet,M=new WeakSet,I=new WeakSet,R=new WeakSet,j=new WeakSet,z=new WeakSet,D=new WeakSet,V=new WeakSet,H=new WeakSet,F=new WeakSet,B=new WeakSet,K=new WeakSet,U=new WeakSet,q=new WeakSet,J=new WeakSet,Y=new WeakSet,G=new WeakSet,Q=new WeakSet,X=new WeakSet,Z=new WeakSet,tt=new WeakMap,et=new WeakSet;function it(){this.scheduleClose=O(this,K,wt).bind(this),this.documentClickHandler=O(this,Y,$t).bind(this),this.handleEscapeKey=O(this,J,Tt).bind(this),this.instantClose=this.close.bind(this),this.scheduleOpen=O(this,B,bt).bind(this)}function ot(t){t.stopPropagation()}function nt(){this.isVisible||(this.tooltip?.remove(),this.tooltip=null)}function st(){this.isInitialized||(O(this,z,pt).call(this),this.isInitialized=!0)}function rt(){return T`
<div
className="t-tooltip__wrapper"
onScroll=${O(this,q,kt).bind(this)}
bindTo=${[this.elements,"wrapper"]}
>
${O(this,I,ht).call(this)}
</div>
${O(this,R,dt).call(this)}
`}function lt(){const t=`t-tooltip-${Math.random().toString(36).substring(2,9)}`;return this.tooltipContent=O(this,A,rt).call(this),T`
<div
className="t-tooltip t-tooltip-${this.config.type}"
role="t-tooltip"
id="${t}"
onClick=${O(this,W,ot)}
onMouseEnter=${O(this,U,yt).bind(this)}
onMouseLeave=${"click"!==this.config.hideOn?O(this,K,wt).bind(this):void 0}
onTransitionEnd=${O(this,x,nt).bind(this)}
>
${this.tooltipContent}
${"info"!==this.config.type||this.config.content.coverImage||this.config.content.coverVideo?"":T`
<div className="t-tooltip__arrow" bindTo=${[this.elements,"arrow"]}></div>
`}
</div>
`}function ct(){const t=`t-tooltip-${Math.random().toString(36).substring(2,9)}`;this.tooltip=O(this,P,lt).call(this),this.config.target.setAttribute("aria-describedby",t),document.body.appendChild(this.tooltip)}function at(t){if(!this.tooltip||!this.config.target)return;const o=this.config.target.getBoundingClientRect(),n=this.tooltip.getBoundingClientRect(),{arrow:s}=this.elements;if(!s)return;const r=this.getComputedStyle();if(r)switch(t){case"top":case"bottom":const t=parseFloat(r.borderLeftWidth)||0,l=parseFloat(r.paddingLeft)||0,c=i,a=o.left+t+l+(o.width-2*t-2*l)/2-n.left-c/2;s.style.setProperty("--arrow-left",`${a}px`);break;case"left":case"right":const h=parseFloat(r.borderTopWidth)||0,d=parseFloat(r.paddingTop)||0,u=o.top+h+d+(o.height-2*h-2*d)/2-n.top-e/2;s.style.setProperty("--arrow-top",`${u}px`)}}function ht(){const{title:t,description:e,shortcut:i,coverImage:o,coverVideo:n,mediaHeight:s,buttons:r}=this.config.content,{type:l}=this.config;return T`
${(o||n)&&"info"===l?T`
<div
className="t-tooltip__media"
style="
--media-height: ${s}px;"
>
${n?O(this,Z,Ot).call(this,n,o):o?T`
<img src="${o}" />
`:""}
</div>
`:""}
<div className="t-tooltip__body${r.length?"":" t-tooltip__body_without_buttons"}">
${t||i&&"hint"===l?T`
<div className="t-tooltip__main-content">
${t?T`
<div className="t-tooltip__title">
${document.createRange().createContextualFragment(t)}
</div>
`:""}
${i&&"hint"===l?T`
<div className="t-tooltip__shortcut">
${document.createRange().createContextualFragment(function(t){const e=t.split("+"),i=navigator.userAgent.includes("Mac"),o={Ctrl:i?"⌃":"Ctrl",Alt:i?"⌥":"Alt",Shift:i?"⇧":"Shift",ShortKey:i?"⌘":"Ctrl",Meta:i?"⌘":"⊞",Backspace:i?"⌫":"Backspace",Plus:"+",Minus:"-",Space:"␣",ArrowRight:"▶",ArrowLeft:"◀",ArrowUp:"▲",ArrowDown:"▼"};return e.map((t=>`<div class="t-tooltip-shortcuts-popup__key">${t in o?o[t]:t}</div>`)).join("")}(i))}
</div>
`:""}
</div>
`:""}
${e?T`
<div className="t-tooltip__description">
${document.createRange().createContextualFragment(e)}
</div>
`:""}
</div>
`}function dt(){const{buttons:t}=this.config.content,{type:e}=this.config;return t?.length&&"hint"!==e?T`
<div className="t-tooltip__buttons">
${t.map((t=>t.link?T`
<a
href="${t.link}"
target="_blank"
className="t-tooltip__link t-tooltip__link-${t.type}"
rel="noopener noreferrer"
>
${t.title}
</a>
`:T`
<button
className="t-tooltip__button t-tooltip__button-${t.type}"
onClick=${t.onclick}
type="button"
>
${t.title}
</button>
`))}
</div>
`:""}function ut(){this.mutationObserver||(this.mutationObserver=new MutationObserver((()=>{this.config.target.hasAttribute("disabled")?this.disable():this.enable()})),this.mutationObserver.observe(this.config.target,{attributes:!0,attributeFilter:["disabled"]})),this.intersectionObserver||(this.intersectionObserver=new IntersectionObserver((t=>{document.body.contains(this.config.target)?t[0].intersectionRatio<=.1&&this.close():this.destroy()}),{threshold:.1}),this.intersectionObserver.observe(this.config.target))}function pt(){const{showOn:t,target:e,hideOn:i}=this.config;"hover"===t&&(e.addEventListener("mouseenter",this.scheduleOpen),e.addEventListener("focus",this.scheduleOpen),e.addEventListener("blur",this.scheduleClose)),"click"===t&&e.addEventListener("click",this.scheduleOpen),"unhover"===i&&e.addEventListener("mouseleave",this.scheduleClose),"unhover"===i&&"hover"===t&&e.addEventListener("click",this.instantClose)}function mt(){const{target:t}=this.config;t.removeEventListener("mouseenter",this.scheduleOpen),t.removeEventListener("focus",this.scheduleOpen),t.removeEventListener("click",this.scheduleOpen),t.removeEventListener("mouseleave",this.scheduleClose),t.removeEventListener("click",this.instantClose),t.removeEventListener("blur",this.scheduleClose)}function ft(){const{hideOn:t}=this.config;"click"===t&&document.addEventListener("click",this.documentClickHandler),document.addEventListener("keydown",this.handleEscapeKey)}function gt(){document.removeEventListener("click",this.documentClickHandler),document.removeEventListener("keydown",this.handleEscapeKey)}function vt(){return this.isEnabled=!this.config.target.hasAttribute("disabled"),p()&&!this.config.showOnTouchDevices||!this.isEnabled||this.isVisible}function bt(){this.openTimeout&&clearTimeout(this.openTimeout),this.closeTimeout&&clearTimeout(this.closeTimeout),O(this,F,vt).call(this)||(this.openTimeout=setTimeout(this.open.bind(this),this.config.openDelay))}function wt(){this.openTimeout&&clearTimeout(this.openTimeout),this.closeTimeout&&clearTimeout(this.closeTimeout),this.closeTimeout=setTimeout(this.close.bind(this),this.config.closeDelay)}function yt(){clearTimeout(this.closeTimeout)}function kt(){const{wrapper:t}=this.elements;if(!t)return;t.scrollHeight-(t.scrollTop+t.clientHeight)<1?t.classList.remove("t-tooltip__wrapper-with-mask"):t.classList.add("t-tooltip__wrapper-with-mask")}function Tt(t){"Escape"===t.key&&this.isVisible&&O(this,K,wt).call(this)}function $t(t){!this.tooltip||this.config.target.contains(t.target)||this.tooltip.contains(t.target)||O(this,K,wt).call(this)}function _t(){this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null)}function Et(){if(!this.tooltip)return;const{tooltip:i,config:o}=this;let{position:n}=this.config;const s=i.getBoundingClientRect(),r=o.target.getBoundingClientRect(),l="info"===o.type&&!(o.content.coverImage||o.content.coverVideo),c=s.height+(l?e:0),a=e=>function(e){let{position:i,targetRect:o,tooltipHeightWithArrow:n,tooltipRect:s,gap:r}=e;switch(i){case"top":return o.top-n-r>=t;case"bottom":return o.bottom+s.height+r<=document.documentElement.clientHeight-t;case"left":return o.left-s.width-r>=t;case"right":return o.right+s.width+r<=document.documentElement.clientWidth-t}}({position:e,tooltipRect:s,targetRect:r,tooltipHeightWithArrow:c,gap:this.config.gap});if(!a(n)){const t=["top","bottom","left","right"].filter((t=>t!==n));for(const e of t)if(a(e)){n=e;break}}const{right:h,width:d,bottom:u,top:p,left:m,height:f}=this.config.target.getBoundingClientRect(),{height:g,width:v}=this.tooltip.getBoundingClientRect(),b=()=>l?this.config.gap+e:this.config.gap;switch(n){case"bottom":i.style.setProperty("--pos-x",h-d/2+"px"),i.style.setProperty("--pos-y",`${u+b()}px`);break;case"top":i.style.setProperty("--pos-x",h-d/2+"px"),i.style.setProperty("--pos-y",`${Math.max(0,p-g-b())}px`);break;case"left":i.style.setProperty("--pos-x",m-v/2-b()+"px"),i.style.setProperty("--pos-y",`${Math.max(0,p-g/2+f/2)}px`);break;case"right":i.style.setProperty("--pos-x",`${h+v/2+b()}px`),i.style.setProperty("--pos-y",`${Math.max(0,p-g/2+f/2)}px`)}i.setAttribute("data-position",n),i.style.setProperty("--max-width",`${this.config.maxWidth}px`),i.style.setProperty("z-index",this.config.zIndex),i.style.setProperty("--scroll-bar-width",window.innerWidth-document.documentElement.clientWidth+"px"),this.elements.arrow&&(this.elements.arrow.setAttribute("data-position",n),O(this,M,at).call(this,n)),O(this,q,kt).call(this)}function Ct(t){const e=t.currentTarget,{mediaElement:i,mediaPoster:o}=this.elements;if(i)if(o?.classList.add("t-tooltip__video-poster-hidden"),e.classList.add("t-tooltip__video-wrapper__play-btn-hidden"),i.classList.add("t-tooltip__video_visible"),"IFRAME"===i.tagName){const t=JSON.stringify({event:"command",func:"playVideo",args:""});i.contentWindow.postMessage(t,"*")}else"VIDEO"===i.tagName&&i.play()}function Ot(t,e){if(u(t)){const i=C(this,tt).call(this,t)+"?enablejsapi=1&autoplay=0";return T`
<div className="t-tooltip__video-wrapper">
<button
className="t-tooltip__video-wrapper__play-btn"
onClick=${O(this,X,Ct).bind(this)}
></button>
<img
src="${e}"
className="t-tooltip__video-poster"
bindTo=${[this.elements,"mediaPoster"]}
/>
<iframe
class="t-tooltip__video"
src="${i}"
frameborder="0"
allow="autoplay; fullscreen"
allowfullscreen
bindTo=${[this.elements,"mediaElement"]}
></iframe>
</div>
`}const i=`native-video-${Math.random().toString(36).slice(2,11)}`;return T`
<div className="t-tooltip__video-wrapper">
<button
className="t-tooltip__video-wrapper__play-btn"
onClick=${O(this,X,Ct).bind(this)}
></button>
<img src="${e}" className="t-tooltip__video-poster" bindTo=${[this.elements,"mediaPoster"]} />
<video class="t-tooltip__video" id="${i}" controls bindTo=${[this.elements,"mediaElement"]}>
<source src="${t}" type="video/mp4" />
Your browser does not support the video tag.
</video>
</div>
`}function St(){const t=O(this,A,rt).call(this);this.tooltipContent.forEach(((e,i)=>{e instanceof HTMLElement&&e.replaceWith(t[i])})),this.tooltipContent=t,O(this,Q,Et).call(this)}window.Tooltip=class{constructor(t){let{target:e,content:i,type:g="hint",...v}=t;var b,w,y;if(_(this,et),_(this,Z),_(this,X),_(this,Q),_(this,G),_(this,Y),_(this,J),_(this,q),_(this,U),_(this,K),_(this,B),_(this,F),_(this,H),_(this,V),_(this,D),_(this,z),_(this,j),_(this,R),_(this,I),_(this,M),_(this,N),_(this,P),_(this,A),_(this,L),_(this,x),_(this,W),_(this,S),y={writable:!0,value:t=>{const e=function(t){const e={youtube:u};return Object.entries(e).map((e=>{let[i,o]=e;return{videoType:i,videoId:o(t)}})).find((t=>{let{videoId:e}=t;return e}))||!1}(t);return i=e.videoType,{youtube:`https://www.youtube.com/embed/${o=e.videoId}`,vimeo:`https://player.vimeo.com/video/${o}`,vk:`https://vk.com/video_ext.php?oid=${o[0]}&id=${o[1]}&hd=2`,rutube:`https://rutube.ru/play/embed/${o}`,kinescope:`https://kinescope.io/embed/${o}`}[i]||"";var i,o}},E(b=this,w=tt),w.set(b,y),!(e&&e instanceof Element))throw new Error("Target element is invalid or not provided");this.config={target:e,content:{title:m(i.title,"string"),description:m(i.description,"string"),shortcut:m(i.shortcut,"string"),coverImage:m(i.coverImage,"string"),coverVideo:m(i.coverVideo,"string"),mediaWidth:m(i.mediaWidth,"number",o),mediaHeight:m(i.mediaHeight,"number",n),buttons:Array.isArray(i.buttons)?i.buttons:[]},type:f(g,["hint","info"],l),showOn:p()?"click":f(v.showOn,["hover","click"],c),hideOn:p()?"click":f(v.hideOn,["unhover","click"],"unhover"),showOnTouchDevices:m(v.showOnTouchDevices,"boolean","info"===g),position:f(v.position,["top","bottom","left","right"],r),zIndex:m(v.zIndex,"number",s),maxWidth:m(v.maxWidth,"number",o),gap:m(v.gap,"number",d),onOpen:m(i.onOpen,"function",(()=>{})),onClose:m(i.onClose,"function",(()=>{}))},this.config.openDelay="click"===this.config.showOn?0:m(v.openDelay,"number",h),this.config.closeDelay="click"===this.config.hideOn?0:m(v.closeDelay,"number",a),this.tooltip=null,this.elements={},this.closeTimeout=null,this.openTimeout=null,this.isVisible=!1,this.intersectionObserver=null,this.mutationObserver=null,this.isEnabled=!e.hasAttribute("disabled"),this.isInitialized=!1,O(this,S,it).call(this),O(this,L,st).call(this)}destroy(){this.openTimeout&&clearTimeout(this.openTimeout),this.closeTimeout&&clearTimeout(this.closeTimeout),this.close(),O(this,D,mt).call(this)}getComputedStyle(){if(document.body.contains(this.config.target))return this.targetStyleCache||(this.targetStyleCache=window.getComputedStyle(this.config.target)),this.targetStyleCache}open(){O(this,F,vt).call(this)||(O(this,U,yt).call(this),this.tooltip||O(this,N,ct).call(this),O(this,j,ut).call(this),O(this,V,ft).call(this),this.isVisible=!0,setTimeout((()=>{this.tooltip.classList.add("t-tooltip-visible")}),0),O(this,Q,Et).call(this),this.config.onOpen())}close(){this.tooltip&&(this.tooltip.classList.remove("t-tooltip-visible"),O(this,G,_t).call(this),O(this,H,gt).call(this),this.isVisible=!1,this.closeTimeout&&(clearTimeout(this.closeTimeout),this.closeTimeout=null),this.openTimeout&&(clearTimeout(this.openTimeout),this.openTimeout=null),this.config.onClose())}disable(){this.close(),this.isEnabled=!1}enable(){this.isEnabled=!0}updateContent(t){this.config.content={...this.config.content,...t},this.tooltip&&O(this,et,St).call(this)}}})();