iframe-resizer
Version:
Keep iframes sized to their content.
21 lines (18 loc) • 28 kB
JavaScript
/*!
* @preserve
*
* @module iframe-resizer/legacy (child) 5.5.1 (iife)
*
* @license GPL-3.0 for non-commercial use only.
* For commercial use, you must purchase a license from
* https://iframe-resizer.com/pricing
*
* @description Keep same and cross domain iFrames sized to their content
*
* @author David J. Bradshaw <info@iframe-resizer.com>
*
* @see {@link https://iframe-resizer.com}
*
* @copyright (c) 2013 - 2025, David J. Bradshaw. All rights reserved.
*/
!function(){"use strict";const e="font-weight: normal;",t="font-weight: bold;",n="font-style: italic;",o=e+n,r="default",i=Object.freeze({assert:!0,error:!0,warn:!0}),a={expand:!0,defaultEvent:void 0,event:void 0,label:"AutoConsoleGroup",showTime:!0},s={profile:0,profileEnd:0,timeStamp:0,trace:0},l=Object.assign(console);const{fromEntries:c,keys:u}=Object,d=e=>[e,l[e]],f=e=>t=>[t,function(n){e[t]=n}],m=(e,t)=>c(u(e).map(t));const p=!(typeof window>"u"||"function"!=typeof window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches,h=p?"color: #A9C7FB;":"color: #135CD2;",g=p?"color: #E3E3E3;":"color: #1F1F1F;",y="5.5.1",v="iframeResizer",b=10,z="data-iframe-size",w="data-iframe-overflowed",$="data-iframe-ignore",S="bottom",O="right",E="autoResizeEnabled",M=Symbol("sizeChanged"),j="manualResize",k={},T="setOffsetSize",x="resizeObserver",A="overflowObserver",I="mutationObserver",C="visibilityObserver",N="none",P="init",R=(e,t,n,o)=>e.addEventListener(t,n,o||!1),B=e=>{if(!e)return"";let t=-559038744,n=1103547984;for(let o,r=0;r<e.length;r++)o=e.codePointAt(r),t=Math.imul(t^o,2246822519),n=Math.imul(n^o,3266489917);return t^=Math.imul(t^n>>>15,1935289751),n^=Math.imul(n^t>>>15,3405138345),t^=n>>>16,n^=t>>>16,(2097152*(n>>>0)+(t>>>11)).toString(36)},q=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),L=["spjluzl","rlf","clyzpvu"],W=["<yi>Puchspk Spjluzl Rlf</><iy><iy>","<yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.","<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt."],F=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],D=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),H=e=>q(W[e]);var V=e=>{const t=e[q(L[0])]||e[q(L[1])]||e[q(L[2])];if(!t)return-1;const n=t.split("-");let o=function(e=""){let t=-2;const n=B(q(e));return n in D&&(t=D[n]),t}(n[0]);return 0===o||(e=>e[2]===B(e[0]+e[1]))(n)||(o=-2),o};const U=(e,...t)=>setTimeout(()=>e(...t),0),Z=e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}},J=e=>e,_=e=>Math.round(1e3*e)/1e3,Q=e=>e.charAt(0).toUpperCase()+e.slice(1),G=e=>""!=`${e}`&&void 0!==e;const Y=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${Q(t)}`)};let X=!0,K=v;const ee=(te=function(n={}){const c={},u={},p=[],h={...a,expand:!n.collapsed||a.expanded,...n};let g="";function y(){p.length=0,g=""}function v(){delete h.event,y()}const b=()=>!!p.some(([e])=>e in i)||!!h.expand;function z(){if(0!==p.length){l[b()?"group":"groupCollapsed"](`%c${h.label}%c ${(e=>{const t=e.event||e.defaultEvent;return t?`${t}`:""})(h)} %c${h.showTime?g:""}`,e,t,o);for(const[e,...t]of p)l.assert(e in l,`Unknown console method: ${e}`),e in l&&l[e](...t);l.groupEnd(),v()}else v()}function w(){""===g&&(g=function(){const e=new Date,t=(t,n)=>e[t]().toString().padStart(n,"0");return`@ ${t("getHours",2)}:${t("getMinutes",2)}:${t("getSeconds",2)}.${t("getMilliseconds",3)}`}())}function $(e,...t){0===p.length&&(w(),queueMicrotask(()=>queueMicrotask(z))),p.push([e,...t])}function S(e=r,...t){c[e]?$("log",`${e}: ${performance.now()-c[e]} ms`,...t):$("timeLog",e,...t)}return{...m(h,f(h)),...m(console,e=>[e,(...t)=>$(e,...t)]),...m(s,d),assert:function(e,...t){!0!==e&&$("assert",e,...t)},count:function(e=r){u[e]?u[e]+=1:u[e]=1,$("log",`${e}: ${u[e]}`)},countReset:function(e=r){delete u[e]},endAutoGroup:z,errorBoundary:e=>(...t)=>{let n;try{n=e(...t)}catch(e){if(!Error.prototype.isPrototypeOf(e))throw e;$("error",e),z()}return n},event:function(e){w(),h.event=e},purge:y,time:function(e=r){w(),c[e]=performance.now()},timeEnd:function(e=r){S(e),delete c[e]},timeLog:S,touch:w}},te?.__esModule?te.default:te);var te;const ne=ee({label:`${v}(child)`});var oe;const re=(oe="log",(...e)=>!X||ne[oe](...e));const{assert:ie,debug:ae,endAutoGroup:se,error:le,errorBoundary:ce,event:ue,label:de,purge:fe,warn:me}=ne,pe=e=>{return ne.warn((t=J,e=>window.chrome?t(e.replaceAll("<br>","\n").replaceAll("<rb>","[31;1m").replaceAll("</>","[m").replaceAll("<b>","[1m").replaceAll("<i>","[3m").replaceAll("<u>","[4m")):t(e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,"")))(e));var t},he=pe,ge=(e=>(t,n="renamed to")=>(o,r,i="",a="")=>e(a,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${r}</>. ${i}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))((e,t)=>pe(t)),ye=ge("Method"),ve=ge("Method","replaced with"),be=ge("Option"),ze=["min-height","min-width","max-height","max-width"],we=new Set,$e=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),Se=(e,t)=>{return(n=$e(e,t))&&"0px"!==n&&"auto"!==n&&"none"!==n;var n};function Oe({href:e}){we.has(e)||we.add(e)}const Ee=(e,t)=>function(e,t){const n=e.style[t];return n?{source:"an inline style attribute",value:n}:null}(e,t)||function(e,t){for(const n of document.styleSheets)try{for(const o of n.cssRules||[])if(o.selectorText&&e.matches(o.selectorText)){const e=o.style[t];if(e)return{source:"STYLE"===n.ownerNode.tagName?"an inline <style> block":`stylesheet (${n.href})`,value:e}}}catch(e){Oe(n)}return{source:"cross-origin stylesheet",value:$e(e,t)}}(e,t),Me=(e,t)=>{const{source:n,value:o}=Ee(e,t),r=(e=>e.tagName?e.tagName.toLowerCase():"unknown")(e);pe(`The <b>${t}</> CSS property is set to <b>${o}</> on the <b><${r}></> element via ${n}. This may cause issues with the correct operation of <i>iframe-resizer</>.\n\nIf you wish to restrict the size of the iframe, then you should set this property on the iframe element itself, not the content inside it.`)};function je(){for(const e of[document.documentElement,document.body])for(const t of ze)Se(e,t)&&Me(e,t)}const ke=e=>t=>void 0===t?void 0:e(t),Te=ke(e=>"true"===e),xe=ke(Number),Ae=new Set,Ie=new Set,Ce=[];let Ne,Pe=1,Re=!1,Be=0;const qe=e=>{for(const t of e){const{addedNodes:e,removedNodes:n}=t;for(const t of e)Ae.add(t);for(const e of n)Ae.has(e)?Ae.delete(e):Ie.add(e)}};function Le(e){Ce.push(e),Re||(Be=performance.now(),Re=!0,requestAnimationFrame(Ne))}function We(e){const t=new window.MutationObserver(Le),n=document.querySelector("body"),o={attributes:!0,attributeFilter:[$,z],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return Ne=(e=>()=>{const t=performance.now(),n=t-Be,o=16*Pe+++2;if(n>o&&n<200)return ue("MutationDelay"),re("Update delayed due to heavy workload on the callStack"),re(`EventLoop busy time: %c${_(n)}ms %c> Max wait: %c${o-2}ms`,h,g,h),setTimeout(Ne,16*Pe),void(Be=t);Pe=1,Ce.forEach(qe),Ce.length=0,e({addedMutations:Ae,removedMutations:Ie}),Re=!1,Ae.clear(),Ie.clear()})(e),t.observe(n,o),re("Attached MutationObserver to body"),t}const Fe=(t,n=!0)=>o=>{o>0&&re(`${n?"At":"De"}tached ${t}Observer ${n?"to":"from"} %c${o}%c element${1===o?"":"s"}`,h,e)},De=(e,t,n)=>e=>{let o=0;for(const r of e)n.has(r)&&(t.unobserve(r),n.delete(r),o+=1);return o},He=e=>e.hidden||null===e.offsetParent||"none"===e.style.display,Ve=(e,t)=>{const n=t.side,o={root:t.root,rootMargin:"0px",threshold:1},r=window?.requestAnimationFrame||J,i=(t=!1)=>e(t),a=(e,t)=>0===e||e>t[n],s=(e,t)=>e.toggleAttribute(w,t);const l=new IntersectionObserver(function(e){for(const t of e){const{boundingClientRect:e,rootBounds:o,target:r}=t,i=e[n],l=a(i,o)&&!He(r);s(r,l)}r(i)},o),c=new WeakSet;return{attachObservers:function(e){let t=0;for(const n of e){const e=n.nodeType===Node.ELEMENT_NODE,o=c.has(n);e&&(ie(!o,"Node already observed for overflow",n),o||(l.observe(n),c.add(n),t+=1))}return t},detachObservers:De(0,l,c)}},Ue="--ifr-start",Ze="--ifr-end",Je=[],_e=new WeakSet,Qe=e=>"object"==typeof e&&_e.add(e);let Ge={},Ye=0;function Xe(e){e.getEntries().forEach(e=>{if(e.name===Ze){const{duration:t}=performance.measure("--ifr-measure",Ue,Ze);Ge=e.detail,Je.push(t),Je.length>100&&Je.shift()}})}function Ke(){re("Attached PerformanceObserver to page");new PerformanceObserver(Xe).observe({entryTypes:["mark"]}),Qe(document.documentElement),Qe(document.body),function(){const e=setInterval(()=>{if(Je.length<10)return;if(Ge.hasTags&&Ge.len<25)return;Je.sort();const t=Math.min(Je.reduce((e,t)=>e+t,0)/Je.length,Je[Math.floor(Je.length/2)]),n=_(t);n>Ye&&(Ye=n,ue("performanceObserver")),t<=4||(clearInterval(e),pe(`<rb>Performance Warning</>\n\nCalculating the page size is taking an excessive amount of time (${_(t)}ms).\n\nTo improve performance add the <b>data-iframe-size</> attribute to the ${Ge.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},5e3)}()}const et=Fe("Resize"),tt=new WeakSet;let nt;function ot(e){let t=0;for(const n of e){const e=n.nodeType===Node.ELEMENT_NODE,o=tt.has(n);if(!e)continue;const r=getComputedStyle(n)?.position;""!==r&&"static"!==r&&(ie(!o,"Node already observed for resize",n),o||(nt.observe(n),tt.add(n),t+=1))}et(t)}const rt=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},it=rt("function"),at=rt("number"),st=rt("string");"undefined"!=typeof window&&function(){const o={height:()=>(me("Custom height calculation function not defined"),Wt.auto()),width:()=>(me("Custom width calculation function not defined"),Ft.auto())},r={},i={},a="auto",s="[iFrameSizer]",l="scroll";let c,u,d,f,m,p,B,W,D,J=!0,_="",ee=0,te="",oe="",ie=!1,ae=!0,le=!1,ge=!0,ze=!1,we=!1,$e=!1,Se=1,Oe=a,Ee="",Me=!0,ke={},Ae=!1,Ie=!0,Ce=!1,Ne=0,Pe=!1,Re=[],Be="",qe="child",Le=!1,He="",Je=[],_e=window.parent,Qe="*",Ge=0,Ye=!1,Xe=1,et=l,rt=window,lt=()=>{me("onMessage function not defined")},ct=()=>{},ut=null,dt=null;function ft(t){var n,r,i;!function(e){Be=e[0]??Be,ee=xe(e[1])??ee,le=Te(e[2])??le,Ce=Te(e[3])??Ce,J=Te(e[6])??J,te=e[7]??te,Oe=e[8]??Oe,_=e[9]??_,oe=e[10]??oe,Ge=xe(e[11])??Ge,ke.enable=Te(e[12])??!1,qe=e[13]??qe,et=e[14]??et,Pe=Te(e[15])??Pe,d=xe(e[16])??d,f=xe(e[17])??f,ae=Te(e[18])??ae,c=e[19]??c,W=e[20]??W,Ne=xe(e[21])??Ne,Ie=Te(e[23])??Ie}(t),K=(n={id:Be,enabled:Ce,expand:Ie}).id||v,ne.label(`${K}`),ne.expand(n.expand),X=n.enabled,function(){function e(e){D=it(e,"onBeforeResize")??D,lt=it(e,"onMessage")??lt,ct=it(e,"onReady")??ct,"number"==typeof e?.offset&&(be("offset","offsetSize"),ae&&(d=at(e,"offset")??d),le&&(f=at(e,"offset")??f)),"number"==typeof e?.offsetSize&&(ae&&(d=at(e,"offsetSize")??d),le&&(f=at(e,"offsetSize")??f)),u=st(e,q(L[0]))??u,Ee=st(e,"ignoreSelector")??Ee,He=st(e,"sizeSelector")??He,Qe=st(e,"targetOrigin")??Qe,Oe=e?.heightCalculationMethod||Oe,et=e?.widthCalculationMethod||et}function t(e,t){return"function"==typeof e&&(pe(`<rb>Deprecated Option(${t}CalculationMethod)</>\n\nThe use of <b>${t}CalculationMethod</> as a function is deprecated and will be removed in a future version of <i>iframe-resizer</>. Please use the new <b>onBeforeResize</> event handler instead.\n\nSee <u>https://iframe-resizer.com/api/child</> for more details.`),o[t]=e,e="custom"),e}if(1===Ne)return;const n=window.iframeResizer||window.iFrameResizer;"object"==typeof n&&(e(n),Oe=t(Oe,"height"),et=t(et,"width"),re(`Set targetOrigin for parent: %c${Qe}`,h))}(),bt(),function(){try{Le=1===Ne||"iframeParentListener"in window.parent}catch(e){}}(),le===ae&&(ie=!0),function(){const t=Ne,n=V({key:c}),o=V({key:u});if(Ne=Math.max(n,o),Ne<0){if(Ne=Math.min(n,o),fe(),pe(`${H(Ne+2)}${H(2)}`),G(W))throw H(Ne+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"")}else(!G(W)||t>-1&&Ne>t)&&(sessionStorage.getItem("ifr")!==y&&function(t,n){console.info(`${K} %ciframe-resizer ${t}`,X||n<1?"font-weight: bold;":e)}(`v${y} (${(e=>q(F[e]))(Ne)})`,Ne),Ne<2&&he(H(3)),sessionStorage.setItem("ifr",y))}(),W&&""!==W&&"false"!==W?W!==y&&pe(`<b>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${W} - Child page: ${y}.\n`):pe("<rb>Legacy version detected on parent page</>\n\nDetected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.\n\nSee <u>https://iframe-resizer.com/setup/</> for more details.\n"),$t(),St(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach(n=>{e=!0,n.removeAttribute(t),n.toggleAttribute(z,!0)});t("data-iframe-height"),t("data-iframe-width"),e&&pe("<rb>Deprecated Attributes</>\n \nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}(),"BackCompat"===document.compatMode&&pe("<rb>Quirks Mode Detected</>\n\nThis iframe is running in the browser's legacy <b>Quirks Mode</>, this may cause issues with the correct operation of <i>iframe-resizer</>. It is recommended that you switch to the modern <b>Standards Mode</>.\n\nFor more information see <u>https://iframe-resizer.com/quirks-mode</>.\n"),pt(),ie||je(),1!==Ne&&(rt.parentIframe=Object.freeze({autoResize:e=>(Y(e,"boolean","parentIframe.autoResize(enable) enable"),!1===le&&!1===ae?(ue(E),pe(`Auto Resize can not be changed when <b>direction</> is set to '${N}'.`),!1):(!0===e&&!1===J?(J=!0,queueMicrotask(()=>Jt(E,"Auto Resize enabled"))):!1===e&&!0===J&&(J=!1),Qt(0,0,"autoResize",JSON.stringify(J)),J)),close(){Qt(0,0,"close")},getId:()=>Be,getOrigin:()=>(ye("getOrigin()","getParentOrigin()"),m),getParentOrigin:()=>m,getPageInfo(e){if("function"==typeof e)return ut=e,Qt(0,0,"pageInfo"),void ve("getPageInfo()","getParentProps()","See <u>https://iframe-resizer.com/upgrade</> for details. ");ut=null,Qt(0,0,"pageInfoStop")},getParentProps:e=>(Y(e,"function","parentIframe.getParentProps(callback) callback"),dt=e,Qt(0,0,"parentInfo"),()=>{dt=null,Qt(0,0,"parentInfoStop")}),getParentProperties(e){ye("getParentProperties()","getParentProps()"),this.getParentProps(e)},moveToAnchor(e){Y(e,"string","parentIframe.moveToAnchor(anchor) anchor"),ke.findTarget(e)},reset(){!function(){const e=Oe;Oe=a,Ye||(Ye=!0,requestAnimationFrame(()=>{Ye=!1})),_t("reset"),Oe=e}()},setOffsetSize(e){Y(e,"number","parentIframe.setOffsetSize(offset) offset"),d=e,f=e,Jt(T,`parentIframe.setOffsetSize(${e})`)},scrollBy(e,t){Y(e,"number","parentIframe.scrollBy(x, y) x"),Y(t,"number","parentIframe.scrollBy(x, y) y"),Qt(t,e,"scrollBy")},scrollTo(e,t){Y(e,"number","parentIframe.scrollTo(x, y) x"),Y(t,"number","parentIframe.scrollTo(x, y) y"),Qt(t,e,"scrollTo")},scrollToOffset(e,t){Y(e,"number","parentIframe.scrollToOffset(x, y) x"),Y(t,"number","parentIframe.scrollToOffset(x, y) y"),Qt(t,e,"scrollToOffset")},sendMessage(e,t){t&&Y(t,"string","parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),Qt(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){Oe=e,$t()},setWidthCalculationMethod(e){et=e,St()},setTargetOrigin(e){Y(e,"string","parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),Qe=e},resize(e,t){e&&Y(e,"number","parentIframe.resize(customHeight, customWidth) customHeight"),t&&Y(t,"number","parentIframe.resize(customHeight, customWidth) customWidth"),Jt(j,`parentIframe.resize(${e||""}${t?`,${t}`:""})`,e,t)},size(e,t){ye("size()","resize()"),this.resize(e,t)}}),rt.parentIFrame=rt.parentIframe),function(){function e(e){Qt(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){R(window.document,t,e)}!0===Pe&&(t("mouseenter"),t("mouseleave"))}(),ke=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function t(t){const n=t.getBoundingClientRect(),o=e();return{x:parseInt(n.left,b)+parseInt(o.x,b),y:parseInt(n.top,b)+parseInt(o.y,b)}}function n(e){function n(e){const n=t(e);Qt(n.y,n.x,"scrollToOffset")}const o=e.split("#")[1]||e,r=decodeURIComponent(o),i=document.getElementById(r)||document.getElementsByName(r)[0];void 0===i?Qt(0,0,"inPageLink",`#${o}`):n(i)}function o(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&n(t)}function r(){for(const e of document.querySelectorAll('a[href^="#"]'))"#"!==e.getAttribute("href")&&R(e,"click",t=>{t.preventDefault(),n(e.getAttribute("href"))})}function i(){R(window,"hashchange",o)}function a(){setTimeout(o,128)}function s(){r(),i(),a()}return ke.enable&&(1===Ne?pe("In page linking requires a Professional or Business license. Please see <u>https://iframe-resizer.com/pricing</> for more details."):s()),{findTarget:n}}(),void 0===te&&(te=`${ee}px`),yt("margin",(r="margin",(i=te).includes("-")&&(me(`Negative CSS value ignored for ${r}`),i=""),i)),yt("background",_),yt("padding",oe),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),ie||function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body)}(),function(e){zt({method:e,eventType:"After Print",eventName:"afterprint"}),zt({method:e,eventType:"Before Print",eventName:"beforeprint"}),zt({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}("add"),function(){const e=Pt(document.documentElement)();We(It),function(e){const t={root:document.documentElement,side:ae?S:O};p=Ve(Et,t),p.attachObservers(e)}(e),Ke(),function(e){nt=new ResizeObserver(Mt),nt.observe(document.body),tt.add(document.body),re("Attached ResizeObserver to body"),B={attachObserverToNonStaticElements:ot,detachObservers:De(0,nt,tt)},B.attachObserverToNonStaticElements(e)}(e),function(e){const t=new IntersectionObserver(t=>e(t[0].isIntersecting),{threshold:0}),n=document.documentElement;t.observe(n),re("Attached VisibilityObserver to page")}(jt)}(),mt(Z(ct)),Jt(P,"Init message from host page",void 0,void 0,`${y}:${Ne}`),document.title&&""!==document.title&&Qt(0,0,"title",document.title)}function mt(e){"complete"===document.readyState?U(e):R(document,"readystatechange",()=>mt(e))}function pt(){Je=document.querySelectorAll(`[${z}]`),$e=Je.length>0}let ht=0;function gt(){const n=document.querySelectorAll(`*[${$}]`);ze=n.length>0,ze&&n.length!==ht&&(function(n){const o=1===n.length?"":"s";me(`%c[${$}]%c found on %c${n.length}%c element${o}`,t,e,t,e)}(n),ht=n.length)}function yt(e,t){void 0!==t&&""!==t&&"null"!==t&&(document.body.style.setProperty(e,t),re(`Set body ${e}: %c${t}`,h))}function vt(e,t,n){if(""!==n)for(const e of document.querySelectorAll(n))e.toggleAttribute(t,!0)}function bt(){vt(0,z,He),vt(0,$,Ee)}function zt(e){({add(t){function n(){Jt(e.eventName,e.eventType)}i[t]=n,R(window,t,n,{passive:!0})},remove(e){const t=i[e];var n,o;delete i[e],n=e,o=t,window.removeEventListener(n,o,!1)}})[e.method](e.eventName)}function wt(e,t,n,o){return t!==e&&(e in n||(me(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in r)&&pe(`<rb>Deprecated ${o}CalculationMethod (${e})</>\n\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${o} calculation method. It is recommended that you ${W?"remove this option.":"set this option to <b>'auto'</> when using an older version of <i>iframe-resizer</> on the parent page."}`),e}function $t(){Oe=wt(Oe,a,Wt,"height")}function St(){et=wt(et,l,Ft,"width")}function Ot(){const e=document.querySelectorAll(`[${w}]`);Re=Array.from(e).filter(e=>!e.closest(`[${$}]`)),we=Re.length>0}function Et(e){Ot(),(we||e)&&(Re.length>1?re("Overflowed Elements:",...Re):we||re("Overflow removed"),Jt(A,"Overflow updated"))}function Mt(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;Jt(x,`Element resized <${function(e){switch(!0){case!G(e):return"";case G(e.id):return`${e.nodeName}#${e.id}`;case G(e.name):return`${e.nodeName} (${e.name}`;case G(e.className):return`${e.nodeName}.${e.className}`;default:return e.nodeName}}(t)}>`)}function jt(e){Ae=!e,Jt(C,"Visibility changed")}const kt=Fe("Overflow"),Tt=Fe("Overflow",!1),xt=Fe("Resize"),At=Fe("Resize",!1);function It(e){!function({addedMutations:e,removedMutations:t}){ue("contentMutated"),bt(),pt(),Ot();let n=0,o=0,r=0,i=0;for(const e of t){const t=Pt(e)();o+=p.detachObservers(t),i+=B.detachObservers(t)}for(const t of e){const e=Pt(t)();n+=p.attachObservers(e),r+=B.attachObserverToNonStaticElements(e)}Tt(o),At(i),kt(n),xt(r),se()}(e),Jt(I,"Mutation Observed")}function Ct(e){performance.mark(Ue);const t=Q(e);let n=0,o=document.documentElement,r=$e?0:document.documentElement.getBoundingClientRect().bottom;const i=$e?Je:we?Re:Pt(document)();for(const t of i)n=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),n>r&&(r=n,o=t);return re(`${t} position calculated from:`,o),performance.mark(Ze,{detail:{hasTags:$e,len:i.length,logging:Ce,Side:t}}),r}const Nt=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.boundingClientRect()],Pt=e=>()=>{if(!(e=>e.nodeType===Node.ELEMENT_NODE)(e))return[e];const t=["* ","not(head)","not(meta)","not(base)","not(title)","not(script)","not(link)","not(style)","not(map)","not(area)","not(option)","not(optgroup)","not(template)","not(track)","not(wbr)","not(nobr)"];return gt(),ze&&t.push(`not([${$}])`,`not([${$}] *)`),[e,...e.querySelectorAll(t.join(":"))]},Rt={height:0,width:0},Bt={height:0,width:0},qt=[h,g,h];function Lt(e){function t(){return Bt[o]=r,Rt[o]=s,r}const n=e===Wt,o=n?"height":"width",r=e.boundingClientRect(),i=Math.ceil(r),a=Math.floor(r),s=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e),l=`HTML: %c${r}px %cPage: %c${s}px`;let c=0;switch(!0){case!e.enabled():return s;case $e:re("Found element with data-iframe-size attribute"),c=e.taggedElement();break;case!we&&0===Bt[o]&&0===Rt[o]:re(`Initial page size values: ${l}`,...qt),c=t();break;case Ye&&r===Bt[o]&&s===Rt[o]:re(`Size unchanged: ${l}`,...qt),c=Math.max(r,s);break;case 0===r:re(`Page is hidden: ${l}`,...qt),c=s;break;case!we&&r!==Bt[o]&&s<=Rt[o]:re(`New <html> size: ${l} `,...qt),re(`Previous <html> size: %c${Bt[o]}px`,h),c=t();break;case!n:c=e.taggedElement();break;case!we&&r<Bt[o]:re(`<html> size decreased: ${l}`,...qt),c=t();break;case s===a||s===i:re(`<html> size equals page size: ${l}`,...qt),c=t();break;case r>s:re(`Page size < <html> size: ${l}`,...qt),c=t();break;case we:re("Found element overflowing <html> "),c=e.taggedElement();break;default:re(`Using <html> size: ${l}`,...qt),c=t()}return re(`Content ${o}: %c${c}px`,h),c+=function(e){const t=e.getOffset();return 0!==t&&re(`Page offsetSize: %c${t}px`,h),t}(e),c}const Wt={enabled:()=>ae,getOffset:()=>d,auto:()=>Lt(Wt),bodyOffset:()=>{const{body:e}=document,t=getComputedStyle(e);return e.offsetHeight+parseInt(t.marginTop,b)+parseInt(t.marginBottom,b)},bodyScroll:()=>document.body.scrollHeight,offset:()=>Wt.bodyOffset(),custom:()=>o.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),max:()=>Math.max(...Nt(Wt)),min:()=>Math.min(...Nt(Wt)),grow:()=>Wt.max(),lowestElement:()=>Ct(S),taggedElement:()=>Ct(S)},Ft={enabled:()=>le,getOffset:()=>f,auto:()=>Lt(Ft),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>o.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),max:()=>Math.max(...Nt(Ft)),min:()=>Math.min(...Nt(Ft)),rightMostElement:()=>Ct(O),scroll:()=>Math.max(Ft.bodyScroll(),Ft.documentElementScroll()),taggedElement:()=>Ct(O)},Dt=(e,t)=>!(Math.abs(e-t)<=Ge);function Ht(e,t){const n=e[t]();return e.enabled()&&void 0!==D?function(e){const t=D(e);if(void 0===t)throw new TypeError("No value returned from onBeforeResize(), expected a numeric value");if(Number.isNaN(t))throw new TypeError(`Invalid value returned from onBeforeResize(): ${t}, expected Number`);return t}(n):n}let Vt=!1;const Ut=Z(()=>he(H(4)));let Zt=!1;const Jt=ce((e,t,n,o,r)=>{if(performance.now(),ue(e),!0!==Vt){if(!J&&!(e in k))return re("Resizing disabled"),void se();if(Ae){if(!0===Zt)return;Zt=!0}else Zt=!1,Vt=!0,requestAnimationFrame(()=>{Vt=!1}),function(e,t,n,o,r){const i=n??Ht(Wt,Oe),a=o??Ht(Ft,et);switch(ae&&Dt(Se,i)||le&&Dt(Xe,a)?M:e){case P:case E:case M:Se=i,Xe=a;case T:Qt(Se,Xe,e,r);break;case A:case I:case x:case C:fe();break;default:fe(),re("No change in content size detected")}}(e,0,n,o,r)}});function _t(e){Se=Wt[Oe](),Xe=Ft[et](),Qt(Se,Xe,e)}const Qt=ce(function(e,t,o,r,i){Ne<-1||(ue(o),void 0!==i||(i=Qe),function(){const a=`${Be}:${e}:${t}:${o}${void 0===r?"":`:${r}`}`;if(Le)try{window.parent.iframeParentListener(s+a)}catch(e){if(1!==Ne)throw e;return void Ut()}else _e.postMessage(s+a,i);re(`Sending message to parent page via ${Le?"sameOrigin":"postMessage"}: %c%c${a}`,n,h)}(),se())}),Gt=ce(function(e){ue("onMessage");const{freeze:t}=Object,{parse:n}=JSON,o=e=>Qt(0,0,`${e}Stop`),r={init:function(){if("loading"===document.readyState)return;const t=e.data.slice(13).split(":");_e=e.source,m=e.origin,ft(t),ge=!1,setTimeout(()=>{Me=!1},128)},reset(){Me||_t("resetPage")},resize(){Jt("parentResize","Parent window requested size check")},moveToAnchor(){ke.findTarget(a())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=a();ut?U(ut,n(e)):o("pageInfo")},parentInfo(){const e=(r=a(),t(n(r)));var r;dt?U(dt,e):o("parentInfo")},message(){const e=a();U(lt,n(e))}},i=()=>e.data.split("]")[1].split(":")[0],a=()=>e.data.slice(e.data.indexOf(":")+1),l=()=>e.data.split(":")[2]in{true:1,false:1};function c(){const t=i();ue(t),t in r?r[t]():"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype||l()||me(`Unexpected message (${e.data})`)}s===`${e.data}`.slice(0,13)&&function(){if(!1!==ge)return l()?(de(i()),ue(P),void r.init()):void 0;c()}()});function Yt(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"iframeChildListener"in window?me("Already setup"):(window.iframeChildListener=e=>setTimeout(()=>Gt({data:e,sameOrigin:!0})),R(window,"message",Gt),R(window,"readystatechange",Yt),Yt())}()}();