@iframe-resizer/child
Version:
Keep iframes sized to their content.
21 lines (18 loc) • 29 kB
JavaScript
/*!
* @preserve
*
* @module iframe-resizer/child 5.5.7 (cjs) - 2025-09-23
*
* @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.
*/
;const e=require("auto-console-group"),t="5.5.7",n="iframeResizer",o=":",r="init",a="message",i="pageHide",s="pageInfo",l="parentInfo",c="scrollToOffset",d="title",u=10,m="data-iframe-size",f="data-iframe-overflowed",p="data-iframe-ignore",h="height",y="width",g="offset",b="offsetSize",v="string",z="number",w="object",$="function",O="auto",S="readystatechange",I="bottom",M="right",E="autoResizeEnabled",T=Symbol("sizeChanged"),k="manualResize",j="parentResize",N={[k]:1,[j]:1},A="setOffsetSize",x="resizeObserver",R="overflowObserver",C="mutationObserver",P="visibilityObserver",H="[iFrameSizer]",L=new Set(["head","body","meta","base","title","script","link","style","map","area","option","optgroup","template","track","wbr","nobr"]),G=(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)},D=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),q=["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.","Pu whnl spurpun ylxbpylz h Wyvmlzzpvuhs vy Ibzpulzz spjluzl. Wslhzl zll <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</> mvy tvyl klahpsz."],F=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],U=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),V=e=>D(W[e]),Z=e=>{const t=e[D(q[0])]||e[D(q[1])]||e[D(q[2])];if(!t)return-1;const n=t.split("-");let o=function(e=""){let t=-2;const n=B(D(e));return n in U&&(t=U[n]),t}(n[0]);return 0===o||(e=>e[2]===B(e[0]+e[1]))(n)||(o=-2),o},J=(e,...t)=>setTimeout(()=>e(...t),0),_=e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}},Q=e=>e,Y=e=>Math.round(1e3*e)/1e3,X=e=>e.charAt(0).toUpperCase()+e.slice(1),K=e=>""!=`${e}`&&void 0!==e,ee=e=>e();const te=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${X(t)}`)};let ne=!0,oe=n;var re;const ae=(re=e,re?.__esModule?re.default:re)({label:`${n}(child)`,expand:!1});var ie;const se=(ie="log",(...e)=>!ne||ae[ie](...e));const{assert:le,endAutoGroup:ce,error:de,errorBoundary:ue,event:me,label:fe,purge:pe,warn:he}=ae,ye=e=>{return ae.warn((t=Q,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},ge=(e=>(t,n="renamed to")=>(o,r,a="",i="")=>e(i,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${r}</>. ${a}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))((e,t)=>ye(t)),be=ge("Method"),ve=ge("Method","replaced with"),ze=ge("Option"),we=["min-height","min-width","max-height","max-width"],$e=new Set,Oe=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),Se=(e,t)=>{return(n=Oe(e,t))&&"0px"!==n&&n!==O&&"none"!==n;var n};function Ie({href:e}){$e.has(e)||$e.add(e)}const Me=(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){Ie(n)}return{source:"cross-origin stylesheet",value:Oe(e,t)}}(e,t),Ee=(e,t)=>{const{source:n,value:o}=Me(e,t),r=(e=>e.tagName?e.tagName.toLowerCase():"unknown")(e);ye(`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 Te(){for(const e of[document.documentElement,document.body])for(const t of we)Se(e,t)&&Ee(e,t)}const ke=e=>t=>void 0===t?void 0:e(t),je=ke(e=>"true"===e),Ne=ke(Number),Ae=e=>e=>{e.size},xe=((e="")=>t=>n=>{n.size>0&&de(`${t}Observer ${e}:`,...Array.from(n).flatMap(e=>["\n",e]))})("already attached"),Re=e=>e=>{e.size},Ce=(t,n=!0)=>o=>{o>0&&se(`${n?"At":"De"}tached ${t}Observer ${n?"to":"from"} %c${o}%c element${1===o?"":"s"}`,e.HIGHLIGHT,e.NORMAL)},Pe=(e,t,n,o)=>{const r=Re(e);return e=>{const a=new Set;let i=0;for(const o of e)n.has(o)&&(t.unobserve(o),n.delete(o),a.add(o),i+=1);r(a),o(i),a.clear()}},He=new Set,Le=new Set,Ge=new Set,Be=[],De={attributes:!0,attributeFilter:[p,m],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};let qe,We=1,Fe=!1,Ue=0;const Ve=e=>{e.size},Ze=e=>{e.size},Je=e=>{e.size},_e=e=>e.nodeType!==Node.ELEMENT_NODE||L.has(e.tagName.toLowerCase());function Qe(e){const t=e.addedNodes;for(const e of t)_e(e)||He.add(e)}function Ye(e){const t=e.removedNodes;for(const e of t)_e(e)||(He.has(e)?(He.delete(e),Ge.add(e)):Le.add(e))}const Xe=e=>{se("Mutations:",e);for(const t of e)Qe(t),Ye(t);Ve(He),Ze(Le),Je(Ge),Ge.clear()};const Ke=t=>()=>{const n=performance.now(),o=n-Ue,r=16*We+++2;if(o>r&&o<200)return me("mutationThrottled"),se("Update delayed due to heavy workload on the callStack"),se(`EventLoop busy time: %c${Y(o)}ms %c> Max wait: %c${r-2}ms`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),setTimeout(qe,16*We),void(Ue=n);We=1,Be.forEach(Xe),Be.length=0,Fe=!1,Le.size,He.size,t({addedNodes:He,removedNodes:Le}),He.clear(),Le.clear()};function et(e){Be.push(e),Fe||(Ue=performance.now(),Fe=!0,requestAnimationFrame(qe))}function tt(e){const t=new window.MutationObserver(et),n=document.body||document.documentElement;return qe=Ke(e),t.observe(n,De),se("Attached MutationObserver to body"),{...t,disconnect:()=>{He.clear(),Le.clear(),Be.length=0,t.disconnect(),se("Detached MutationObserver")}}}const nt="Overflow",ot=Ce(nt),rt=Ce(nt,!1),at=Ae(nt),it=xe(nt),st=e=>e.hidden||null===e.offsetParent||"none"===e.style.display,lt=(e,t)=>{const n=t.side,o={root:t.root,rootMargin:"0px",threshold:1},r=window?.requestAnimationFrame||Q,a=(t=!1)=>e(t),i=(e,t)=>0===e||e>t[n],s=(e,t)=>e.toggleAttribute(f,t);const l=new IntersectionObserver(function(e){for(const t of e){const{boundingClientRect:e,rootBounds:o,target:r}=t;if(!o)continue;const a=e[n],l=i(a,o)&&!st(r);s(r,l)}r(a)},o),c=new WeakSet;return{attachObservers:function(e){const t=new Set,n=new Set;let o=0;for(const r of e)r.nodeType===Node.ELEMENT_NODE&&(c.has(r)?t.add(r):(l.observe(r),c.add(r),n.add(r),o+=1));it(t),at(n),ot(o),n.clear(),t.clear()},detachObservers:Pe(nt,l,c,rt),disconnect:()=>{l.disconnect(),se("Detached OverflowObserver")}}},ct="--ifr-start",dt="--ifr-end",ut="--ifr-measure",mt=[];let ft,pt={},ht=0;function yt(){try{performance.clearMarks(ct),performance.clearMarks(dt),performance.clearMeasures(ut)}catch{}}function gt(e){e.getEntries().forEach(e=>{if(e.name===dt)try{const{duration:t}=performance.measure(ut,ct,dt);pt=e.detail,mt.push(t),mt.length>100&&mt.shift()}catch{}})}function bt(){se("Attached PerformanceObserver to page");const e=new PerformanceObserver(gt);return e.observe({entryTypes:["mark"]}),ft=setInterval(()=>{if(mt.length<10)return;if(pt.hasTags&&pt.len<25)return;mt.sort();const e=Math.min(mt.reduce((e,t)=>e+t,0)/mt.length,mt[Math.floor(mt.length/2)]),t=Y(e);t>ht&&(ht=t,me("performanceObserver")),yt(),e<=4||(clearInterval(ft),ye(`<rb>Performance Warning</>\n\nCalculating the page size is taking an excessive amount of time (${Y(e)}ms).\n\nTo improve performance add the <b>data-iframe-size</> attribute to the ${pt.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},5e3),{disconnect:()=>{yt(),clearInterval(ft),e.disconnect(),se("Detached PerformanceObserver")}}}const vt="Resize",zt=Ce(vt),wt=Ce(vt,!1),$t=Ae(vt),Ot=xe(vt),St=new WeakSet,It=new Set,Mt=new Set;let Et;function Tt(e){let t=0;for(const n of e){if(n.nodeType!==Node.ELEMENT_NODE)continue;const e=getComputedStyle(n)?.position;""!==e&&"static"!==e&&(St.has(n)?It.add(n):(Et.observe(n),St.add(n),Mt.add(n),t+=1))}Ot(It),$t(Mt),zt(t),Mt.clear(),It.clear()}function kt(e){const t=new IntersectionObserver(t=>e(t[0].isIntersecting),{threshold:0}),n=document.documentElement;return t.observe(n),se("Attached VisibilityObserver to page"),{disconnect:()=>{t.disconnect(),se("Detached VisibilityObserver")}}}const jt=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},Nt=jt($),At=jt(z),xt=jt(v);"undefined"!=typeof window&&function(){const B={height:()=>(he("Custom height calculation function not defined"),Tn.auto()),width:()=>(he("Custom width calculation function not defined"),kn.auto())},W={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,boundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},U={},Y=O,re=[],ie="scroll";let ge,we,$e,Oe,Se,Ie,Me,Ee=!0,ke="",Ae=0,xe="",Re="",Ce=!1,He=!0,Le=!1,Ge=!0,Be=!1,De=!1,qe=!0,We=!1,Fe=1,Ue=Y,Ve="",Ze=!0,Je={},_e=!1,Qe=!1,Ye=!1,Xe=0,Ke=!1,et=0,nt=0,ot=new Set,rt="",at="child",it=!1,st="",ut=[],mt=window.parent,ft="*",pt=0,ht=!1,yt=1,gt=ie,zt=window,$t=()=>{he("onMessage function not defined")},Ot=()=>{},It=null,Mt=null;function jt(o){var a;!function(e){rt=e[0]??rt,Ae=Ne(e[1])??Ae,Le=je(e[2])??Le,Ye=je(e[3])??Ye,Ee=je(e[6])??Ee,xe=e[7]??xe,Ue=e[8]??Ue,ke=e[9]??ke,Re=e[10]??Re,pt=Ne(e[11])??pt,Je.enable=je(e[12])??!1,at=e[13]??at,gt=e[14]??gt,Ke=je(e[15])??Ke,et=Ne(e[16])??et,nt=Ne(e[17])??nt,He=je(e[18])??He,ge=e[19]??ge,Ie=e[20]??Ie,Xe=Ne(e[21])??Xe,Qe=je(e[23])??Qe}(o),oe=(a={id:rt,enabled:Ye,expand:Qe}).id||n,ae.label(`${oe}`),ae.expand(a.expand),ne=a.enabled,function(){function t(e){Me=Nt(e,"onBeforeResize")??Me,$t=Nt(e,"onMessage")??$t,Ot=Nt(e,"onReady")??Ot,typeof e?.offset===z&&(ze(g,b),He&&(et=At(e,g)??et),Le&&(nt=At(e,g)??nt)),typeof e?.offsetSize===z&&(He&&(et=At(e,b)??et),Le&&(nt=At(e,b)??nt)),we=xt(e,D(q[0]))??we,Ve=xt(e,"ignoreSelector")??Ve,st=xt(e,"sizeSelector")??st,ft=xt(e,"targetOrigin")??ft,Ue=e?.heightCalculationMethod||Ue,gt=e?.widthCalculationMethod||gt}function n(e,t){return typeof e===$&&(ye(`<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.`),B[t]=e,e="custom"),e}if(1===Xe)return;const o=window.iframeResizer||window.iFrameResizer;typeof o===w&&(t(o),Ue=n(Ue,h),gt=n(gt,y),se(`Set targetOrigin for parent: %c${ft}`,e.HIGHLIGHT))}(),[Dt,Wt,tn,Gt,qt,Kt,en,Yt,Bt,Ht,Ce?Q:Te,Vt,sn,an,rn,Zt,()=>Ft("background",ke),()=>Ft("padding",Re),Ce?Q:Jt,on,nn,vn,Ct].forEach(e=>{try{e()}catch(e){if(Xe<0)throw e;ye("<rb>Error in setup function</>\n<i>iframe-resizer</> detected an error during setup.\n\nPlease report the following error message at <u>https://github.com/davidjbradshaw/iframe-resizer/issues</>"),de(e)}}),Pt(_(Ot)),Pn(r,"Init message from host page",void 0,void 0,`${t}:${Xe}`),document.title&&""!==document.title&&Gn(0,0,d,document.title)}function Rt({persisted:e}){e||Gn(0,0,"beforeUnload"),me(i),se("Page persisted:",e),e||re.forEach(ee)}const Ct=()=>G(window,i.toLowerCase(),Rt);function Pt(e){"complete"===document.readyState?J(e):G(document,S,()=>Pt(e))}function Ht(){ut=document.querySelectorAll(`[${m}]`),We=ut.length>0}let Lt=0;function Gt(){const t=document.querySelectorAll(`*[${p}]`);return Be=t.length>0,Be&&t.length!==Lt&&(function(t){const n=1===t.length?"":"s";he(`%c[${p}]%c found on %c${t.length}%c element${n}`,e.BOLD,e.NORMAL,e.BOLD,e.NORMAL)}(t),Lt=t.length),Be}function Bt(){"BackCompat"===document.compatMode&&ye("<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")}function Dt(){Ie&&""!==Ie&&"false"!==Ie?Ie!==t&&ye(`<b>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${Ie} - Child page: ${t}.\n`):ye("<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")}function qt(){try{it=1===Xe||"iframeParentListener"in window.parent}catch(e){}}function Wt(){Le===He&&(Ce=!0)}function Ft(t,n){void 0!==n&&""!==n&&"null"!==n&&(document.body.style.setProperty(t,n),se(`Set body ${t}: %c${n}`,e.HIGHLIGHT))}function Ut(e,t,n){if(""!==n)for(const e of document.querySelectorAll(n))e.toggleAttribute(t,!0)}function Vt(){Ut(0,m,st),Ut(0,p,Ve)}function Zt(){var e,t;void 0===xe&&(xe=`${Ae}px`),Ft("margin",(e="margin",(t=xe).includes("-")&&(he(`Negative CSS value ignored for ${e}`),t=""),t))}function Jt(){const e=e=>e.style.setProperty(h,O,"important");e(document.documentElement),e(document.body)}function _t(e){({add(t){function n(){Pn(e.eventName,e.eventType)}U[t]=n,G(window,t,n,{passive:!0})},remove(e){const t=U[e];var n,o;delete U[e],n=e,o=t,window.removeEventListener(n,o,!1)}})[e.method](e.eventName)}function Qt(e){_t({method:e,eventType:"After Print",eventName:"afterprint"}),_t({method:e,eventType:"Before Print",eventName:"beforeprint"}),_t({method:e,eventType:"Ready State Change",eventName:S})}function Yt(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach(n=>{e=!0,n.removeAttribute(t),n.toggleAttribute(m,!0)});t("data-iframe-height"),t("data-iframe-width"),e&&ye("<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</>.")}function Xt(e,t,n){const{label:o}=n;return t!==e&&(e in n||(he(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in W)&&ye(`<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 ${Ie?"remove this option.":`set this option to <b>'auto'</> when using an older version of <i>iframe-resizer</> on the parent page. This can be done on the child page by adding the following code:\n \nwindow.iframeResizer = {\n license: 'xxxx',\n ${o}CalculationMethod: AUTO,\n}\n`}\n`),e}function Kt(){Ue=Xt(Ue,Y,Tn)}function en(){gt=Xt(gt,ie,kn)}function tn(){const n=Xe,o=Z({key:ge}),r=Z({key:we});if(Xe=Math.max(o,r),Xe<0){if(Xe=Math.min(o,r),pe(),ye(`${V(Xe+2)}${V(2)}`),K(Ie))throw V(Xe+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"")}else(!K(Ie)||n>-1&&Xe>n)&&(sessionStorage.getItem("ifr")!==t&&function(t,n){console.info(`${oe} %ciframe-resizer ${t}`,ne||n<1?"font-weight: bold;":e.NORMAL)}(`v${t} (${(e=>D(F[e]))(Xe)})`,Xe),Xe<2&&ye(V(3)),sessionStorage.setItem("ifr",t))}function nn(){Qt("add"),re.push(()=>Qt("remove"))}function on(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}function rn(){function e(e){const t=e.getBoundingClientRect(),n={x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop};return{x:parseInt(t.left,u)+parseInt(n.x,u),y:parseInt(t.top,u)+parseInt(n.y,u)}}function t(t){const n=t.split("#")[1]||t,o=decodeURIComponent(n),r=document.getElementById(o)||document.getElementsByName(o)[0];void 0===r?Gn(0,0,"inPageLink",`#${n}`):function(t){const n=e(t);Gn(n.y,n.x,c)}(r)}function n(){const{hash:e,href:n}=window.location;""!==e&&"#"!==e&&t(n)}const{enable:o}=Je;o&&(1===Xe?ye(V(5)):(function(){for(const e of document.querySelectorAll('a[href^="#"]'))"#"!==e.getAttribute("href")&&G(e,"click",n=>{n.preventDefault(),t(e.getAttribute("href"))})}(),G(window,"hashchange",n),setTimeout(n,128))),Je={...Je,findTarget:t}}function an(){function e(e){Gn(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){G(window.document,t,e)}!0===Ke&&(t("mouseenter"),t("mouseleave"))}function sn(){1!==Xe&&(zt.parentIframe=Object.freeze({autoResize:e=>(te(e,"boolean","parentIframe.autoResize(enable) enable"),!1===Le&&!1===He?(me(E),ye("Auto Resize can not be changed when <b>direction</> is set to 'none'."),!1):(!0===e&&!1===Ee?(Ee=!0,queueMicrotask(()=>Pn(E,"Auto Resize enabled"))):!1===e&&!0===Ee&&(Ee=!1),Gn(0,0,"autoResize",JSON.stringify(Ee)),Ee)),close(){Gn(0,0,"close")},getId:()=>rt,getOrigin:()=>(me("getOrigin"),be("getOrigin()","getParentOrigin()"),$e),getParentOrigin:()=>$e,getPageInfo(e){if(typeof e===$)return It=e,Gn(0,0,s),void ve("getPageInfo()","getParentProps()","See <u>https://iframe-resizer.com/upgrade</> for details. ");It=null,Gn(0,0,"pageInfoStop")},getParentProps:e=>(te(e,$,"parentIframe.getParentProps(callback) callback"),Mt=e,Gn(0,0,l),()=>{Mt=null,Gn(0,0,"parentInfoStop")}),getParentProperties(e){be("getParentProperties()","getParentProps()"),this.getParentProps(e)},moveToAnchor(e){te(e,v,"parentIframe.moveToAnchor(anchor) anchor"),Je.findTarget(e)},reset(){!function(){const e=Ue;Ue=Y,ht||(ht=!0,requestAnimationFrame(()=>{ht=!1})),Hn("reset"),Ue=e}()},setOffsetSize(e){te(e,z,"parentIframe.setOffsetSize(offset) offset"),et=e,nt=e,Pn(A,`parentIframe.setOffsetSize(${e})`)},scrollBy(e,t){te(e,z,"parentIframe.scrollBy(x, y) x"),te(t,z,"parentIframe.scrollBy(x, y) y"),Gn(t,e,"scrollBy")},scrollTo(e,t){te(e,z,"parentIframe.scrollTo(x, y) x"),te(t,z,"parentIframe.scrollTo(x, y) y"),Gn(t,e,"scrollTo")},scrollToOffset(e,t){te(e,z,"parentIframe.scrollToOffset(x, y) x"),te(t,z,"parentIframe.scrollToOffset(x, y) y"),Gn(t,e,c)},sendMessage(e,t){t&&te(t,v,"parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),Gn(0,0,a,JSON.stringify(e),t)},setHeightCalculationMethod(e){Ue=e,Kt()},setWidthCalculationMethod(e){gt=e,en()},setTargetOrigin(e){te(e,v,"parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),ft=e},resize(e,t){void 0!==e&&te(e,z,"parentIframe.resize(customHeight, customWidth) customHeight"),void 0!==t&&te(t,z,"parentIframe.resize(customHeight, customWidth) customWidth"),Pn(k,`parentIframe.resize(${e||""}${t?`,${t}`:""})`,e,t)},size(e,t){be("size()","resize()"),this.resize(e,t)}}),zt.parentIFrame=zt.parentIframe)}let ln=new Set;function cn(){const e=document.querySelectorAll(`[${f}]`);ot=function(e){const t=new Set,n=new Set;for(const o of e)o.closest(`[${p}]`)?n.add(o):t.add(o);return n.size>0&&queueMicrotask(()=>{me("overflowIgnored"),se("Ignoring elements with [data-iframe-ignore] > *:\n",n),ce()}),t}(e),De=ot.size>0,typeof Set.prototype.symmetricDifference===$&&(qe=ot.symmetricDifference(ln).size>0),ln=ot}function dn(){switch(cn(),!0){case!qe:return;case ot.size>1:se("Overflowed Elements:",ot);break;case De:break;default:se("No overflow detected")}Pn(R,"Overflow updated")}function un(e){const t={root:document.documentElement,side:He?I:M};return Oe=lt(dn,t),Oe.attachObservers(e),Oe}function mn(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;Pn(x,`Element resized <${function(e){switch(!0){case!K(e):return"";case K(e.id):return`${e.nodeName}#${e.id}`;case K(e.name):return`${e.nodeName} (${e.name}`;case K(e.className):return`${e.nodeName}.${e.className}`;default:return e.nodeName}}(t)}>`)}function fn(e){return Et=new ResizeObserver(mn),Et.observe(document.body),St.add(document.body),se("Attached ResizeObserver to body"),Se={attachObserverToNonStaticElements:Tt,detachObservers:Pe(vt,Et,St,wt),disconnect:()=>{Et.disconnect(),se("Detached ResizeObserver")}},Se.attachObserverToNonStaticElements(e),Se}function pn(e){_e=!e,Pn(P,"Visibility changed")}const hn=e=>{const t=new Set;for(const n of e){t.add(n);for(const e of On(n))t.add(e)}return se("Inspecting:\n",t),t},yn=e=>{if(0===e.size)return;me("addObservers");const t=hn(e);Oe.attachObservers(t),Se.attachObserverToNonStaticElements(t),ce()},gn=e=>{if(0===e.size)return;me("removeObservers");const t=hn(e);Oe.detachObservers(t),Se.detachObservers(t),ce()};function bn(e){!function({addedNodes:e,removedNodes:t}){me("contentMutated"),Vt(),Ht(),cn(),ce(),gn(t),yn(e)}(e),Pn(C,"Mutation Observed")}function vn(){const e=On(document.documentElement);var t;t=[tt(bn),un(e),bt(),fn(e),kt(pn)],re.push(...t.map(e=>e.disconnect))}function zn(t){performance.mark(ct);const n=X(t);let o=1,r=document.documentElement,a=We?0:document.documentElement.getBoundingClientRect().bottom;const i=We?ut:De?Array.from(ot):On(document.documentElement);for(const e of i)o=e.getBoundingClientRect()[t]+parseFloat(getComputedStyle(e).getPropertyValue(`margin-${t}`)),o>a&&(a=o,r=e);return se(`${n} position calculated from:`,r),se(`Checked %c${i.length}%c elements`,e.HIGHLIGHT,e.FOREGROUND),performance.mark(dt,{detail:{hasTags:We,len:i.length,logging:Ye,Side:n}}),a}const wn=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.boundingClientRect()],$n=`* ${Array.from(L).map(e=>`:not(${e})`).join("")}`,On=e=>e.querySelectorAll($n),Sn={height:0,width:0},In={height:0,width:0},Mn=[e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT];function En(t){function n(){return In[r]=a,Sn[r]=l,Math.max(a,1)}const o=t===Tn,r=t.label,a=t.boundingClientRect(),i=Math.ceil(a),s=Math.floor(a),l=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(t),c=`HTML: %c${a}px %cPage: %c${l}px`;let d=1;switch(!0){case!t.enabled():return Math.max(l,1);case We:se("Found element with data-iframe-size attribute"),d=t.taggedElement();break;case!De&&Ge&&0===In[r]&&0===Sn[r]:se(`Initial page size values: ${c}`,...Mn),d=n();break;case ht&&a===In[r]&&l===Sn[r]:se(`Size unchanged: ${c}`,...Mn),d=Math.max(a,l);break;case 0===a&&0!==l:se(`Page is hidden: ${c}`,...Mn),d=l;break;case!De&&a!==In[r]&&l<=Sn[r]:se(`New <html> size: ${c} `,...Mn),se(`Previous <html> size: %c${In[r]}px`,e.HIGHLIGHT),d=n();break;case!o:d=t.taggedElement();break;case!De&&a<In[r]:se(`<html> size decreased: ${c}`,...Mn),d=n();break;case l===s||l===i:se(`<html> size equals page size: ${c}`,...Mn),d=n();break;case a>l:se(`Page size < <html> size: ${c}`,...Mn),d=n();break;case De:se("Found elements possibly overflowing <html> "),d=t.taggedElement();break;default:se(`Using <html> size: ${c}`,...Mn),d=n()}return se(`Content ${r}: %c${d}px`,e.HIGHLIGHT),d+=function(t){const n=t.getOffset();return 0!==n&&se(`Page offsetSize: %c${n}px`,e.HIGHLIGHT),n}(t),Math.max(d,1)}const Tn={label:h,enabled:()=>He,getOffset:()=>et,auto:()=>En(Tn),bodyOffset:()=>{const{body:e}=document,t=getComputedStyle(e);return e.offsetHeight+parseInt(t.marginTop,u)+parseInt(t.marginBottom,u)},bodyScroll:()=>document.body.scrollHeight,offset:()=>Tn.bodyOffset(),custom:()=>B.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),max:()=>Math.max(...wn(Tn)),min:()=>Math.min(...wn(Tn)),grow:()=>Tn.max(),lowestElement:()=>zn(I),taggedElement:()=>zn(I)},kn={label:y,enabled:()=>Le,getOffset:()=>nt,auto:()=>En(kn),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>B.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),max:()=>Math.max(...wn(kn)),min:()=>Math.min(...wn(kn)),rightMostElement:()=>zn(M),scroll:()=>Math.max(kn.bodyScroll(),kn.documentElementScroll()),taggedElement:()=>zn(M)},jn=(e,t)=>!(Math.abs(e-t)<=pt);function Nn(e,t){const n=e[t](),o=e.enabled()&&void 0!==Me?function(e){const t=Me(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`);if(t<1)throw new RangeError(`Out of range value returned from onBeforeResize(): ${t}, must be at least 1`);return t}(n):n;return le(o>=1,`New iframe ${e.label} is too small: ${o}, must be at least 1`),o}let An=!1;const xn=_(()=>ye(V(4)));let Rn,Cn=!1;const Pn=ue((e,t,n,o,a)=>{switch(me(e),!0){case!0===_e:if(!0===Cn)break;Cn=!0,An=!1,cancelAnimationFrame(Rn);break;case!0===An&&e!==R:pe();break;case!Ee&&!(e in N):se("Resizing disabled");break;default:Cn=!1,An=!0,performance.now(),Rn=requestAnimationFrame(()=>{An=!1,me("requestAnimationFrame")}),function(e,t,n,o,a){const i=n??Nn(Tn,Ue),s=o??Nn(kn,gt);switch(He&&jn(Fe,i)||Le&&jn(yt,s)?T:e){case r:case E:case T:Fe=i,yt=s;case A:Ln(Fe,yt,e,a);break;case R:case C:case x:case P:pe();break;default:pe(),se("No change in content size detected")}}(e,0,n,o,a)}ce()});function Hn(e){Fe=Tn[Ue](),yt=kn[gt](),Gn(Fe,yt,e)}function Ln(t,n,o,r,a){Xe<-1||(void 0!==a||(a=ft),function(){const i=`${rt}:${t}:${n}:${o}${void 0===r?"":`:${r}`}`;if(it)try{window.parent.iframeParentListener(H+i)}catch(e){if(1!==Xe)throw e;return void xn()}else mt.postMessage(H+i,a);se(`Sending message to parent page via ${it?"sameOrigin":"postMessage"}: %c%c${i}`,e.ITALIC,e.HIGHLIGHT)}())}const Gn=ue((e,t,n,o,r)=>{me(n),Ln(e,t,n,o,r),ce()}),Bn=ue(function(e){me("onMessage");const{freeze:t}=Object,{parse:n}=JSON,a=e=>Gn(0,0,`${e}Stop`),i={init:function(){if("loading"===document.readyState)return;const t=e.data.slice(13).split(o);mt=e.source,$e=e.origin,jt(t),Ge=!1,setTimeout(()=>{Ze=!1},128)},reset(){Ze||Hn("resetPage")},resize(){Pn(j,"Parent window requested size check")},moveToAnchor(){Je.findTarget(d())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=d();It?J(It,n(e)):a(s)},parentInfo(){const e=(o=d(),t(n(o)));var o;Mt?J(Mt,e):a(l)},message(){const e=d();J($t,n(e))}},c=()=>e.data.split("]")[1].split(o)[0],d=()=>e.data.slice(e.data.indexOf(o)+1),u=()=>e.data.split(o)[2]in{true:1,false:1};function m(){const t=c();me(t),t in i?i[t]():"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype||u()||he(`Unexpected message (${e.data})`)}H===`${e.data}`.slice(0,13)&&function(){if(!1!==Ge)return u()?(fe(c()),me(r),void i.init()):void 0;m()}()});let Dn=!1;const qn=e=>e.postMessage("[iFrameResizerChild]Ready",window?.iframeResizer?.targetOrigin||"*");function Wn(){if("loading"===document.readyState||!Ge||Dn)return;const{parent:e,top:t}=window;me("ready"),qn(e),e!==t&&qn(t),Dn=!0}"iframeChildListener"in window?he("Already setup"):(window.iframeChildListener=e=>setTimeout(()=>Bn({data:e,sameOrigin:!0})),G(window,a,Bn),G(document,S,Wn),Wn())}();