UNPKG

@iframe-resizer/child

Version:

Keep iframes sized to their content.

21 lines (18 loc) 22.8 kB
/*! * @preserve * * @module iframe-resizer/child 5.4.6 (cjs) - 2025-04-24 * * @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. */ "use strict";const e=require("auto-console-group"),t="5.4.6",n=10,o="data-iframe-size",r="data-iframe-overflowed",i="data-iframe-ignore",a="bottom",s="right",l="autoResizeEnabled",c=Symbol("sizeChanged"),u="manualResize",d="parentResize",m={[u]:1,[d]:1},f="setOffsetSize",p="resizeObserver",h="overflowObserver",y="mutationObserver",g="init",b=(e,t,n,o)=>e.addEventListener(t,n,o||!1),v=["<iy><yi>Puchspk Spjluzl Rlf</><iy><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."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const z=e=>(e=>e.replace(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(v[e]),w=e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}},$=e=>e,S=e=>Math.round(1e3*e)/1e3,O=e=>e.charAt(0).toUpperCase()+e.slice(1),I=e=>""!=`${e}`&&void 0!==e;const E=(e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${O(t)}`)};let j=!0;var T;const k=(T=e,T?.__esModule?T.default:T)({label:"iframeResizer(child)"});var M;const A=(M="log",(...e)=>!j||k[M](...e)),{assert:C,debug:P,endAutoGroup:x,error:N,errorBoundary:R,event:H,label:L,purge:B,warn:q}=k,G=e=>{return k.warn((t=$,e=>window.chrome?t(e.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):t(e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,"")))(e));var t},W=G,D=(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)=>G(t))),F=D("Method"),V=D("Method","replaced with"),U=D("Option"),Z=e=>t=>void 0===t?void 0:e(t),J=Z((e=>"true"===e)),_=Z(Number),Q="--ifr-start",X="--ifr-end",Y=[],K=new WeakSet,ee=e=>"object"==typeof e&&K.add(e);let te={},ne=0;const oe=setInterval((()=>{if(Y.length<10)return;if(te.hasTags&&te.len<25)return;Y.sort();const e=Math.min(Y.reduce(((e,t)=>e+t),0)/Y.length,Y[Math.floor(Y.length/2)]),t=S(e);t>ne&&(ne=t,H("performanceObserver")),e<=4||(clearInterval(oe),G(`<rb>Performance Warning</>\n\nCalculating the page size is taking an excessive amount of time (${S(e)}ms).\n\nTo improve performance add the <b>data-iframe-size</> attribute to the ${te.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))}),5e3);function re(e){e.getEntries().forEach((e=>{if(e.name===X){const{duration:t}=performance.measure("--ifr-measure",Q,X);te=e.detail,Y.push(t),Y.length>100&&Y.shift()}}))}function ie(){new PerformanceObserver(re).observe({entryTypes:["mark"]}),ee(document.documentElement),ee(document.body)}"undefined"!=typeof document&&"undefined"!=typeof PerformanceObserver&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",ie):ie());const ae=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},se=ae("function"),le=ae("number"),ce=ae("string");"undefined"!=typeof window&&function(){const v={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},S={height:()=>(q("Custom height calculation function not defined"),yt.auto()),width:()=>(q("Custom width calculation function not defined"),gt.auto())},T={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,boundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},M={},P="checkVisibility"in window,N="auto",D="[iFrameSizer]",Z="scroll";let Y,K,ee,te,ne,oe=!0,re="",ie=0,ae="",ue="",de=!0,me=!1,fe=!0,pe=!1,he=!1,ye=!1,ge=1,be=N,ve="",ze=!0,we={},$e=!0,Se=!1,Oe="",Ie=0,Ee=!1,je="",Te=$,ke=[],Me="child",Ae=null,Ce=!1,Pe="",xe=[],Ne=window.parent,Re="*",He=0,Le=!1,Be=1,qe=Z,Ge=window,We=()=>{q("onMessage function not defined")},De=()=>{},Fe=null,Ve=null;function Ue(c){var d,m,p;!function(e){je=e[0]??je,ie=_(e[1])??ie,me=J(e[2])??me,Se=J(e[3])??Se,oe=J(e[6])??oe,ae=e[7]??ae,be=e[8]??be,re=e[9]??re,ue=e[10]??ue,He=_(e[11])??He,we.enable=J(e[12])??!1,Me=e[13]??Me,qe=e[14]??qe,Ee=J(e[15])??Ee,Y=_(e[16])??Y,K=_(e[17])??K,de=J(e[18])??de,Oe=e[19]??Oe,te=e[20]??te,Ie=_(e[21])??Ie,$e=J(e[23])??$e}(c),d={id:je,enabled:Se,expand:$e},k.label(`${d.id}`),k.expand(d.expand),j=d.enabled,function(){function t(e){ne=se(e,"onBeforeResize")??ne,We=se(e,"onMessage")??We,De=se(e,"onReady")??De,"number"==typeof e?.offset&&(U("offset","offsetSize"),de&&(Y=le(e,"offset")??Y),me&&(K=le(e,"offset")??K)),"number"==typeof e?.offsetSize&&(de&&(Y=le(e,"offsetSize")??Y),me&&(K=le(e,"offsetSize")??K)),ve=ce(e,"ignoreSelector")??ve,Pe=ce(e,"sizeSelector")??Pe,Re=ce(e,"targetOrigin")??Re,be=e?.heightCalculationMethod||be,qe=e?.widthCalculationMethod||qe}function n(e,t){return"function"==typeof e&&(G(`<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.`),S[t]=e,e="custom"),e}if(1===Ie)return;const o=window.iframeResizer||window.iFrameResizer;"object"==typeof o&&(t(o),be=n(be,"height"),qe=n(qe,"width"),A(`Set targetOrigin for parent: %c${Re}`,e.HIGHLIGHT))}(),tt(),function(){try{Ce=1===Ie||"iframeParentListener"in window.parent}catch(e){}}(),Ie<0?W(`${z(Ie+2)}${z(2)}`):te?.codePointAt(0)>4||Ie<2&&W(z(3)),te&&""!==te&&"false"!==te?te!==t&&G(`<b>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${te} - Child page: ${t}.\n`):G("<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"),rt(),it(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((n=>{e=!0,n.removeAttribute(t),n.toggleAttribute(o,!0)}));t("data-iframe-height"),t("data-iframe-width"),e&&G("<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&&G("<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"),_e(),1!==Ie&&(Ge.parentIframe=Object.freeze({autoResize:e=>(E(e,"boolean","parentIframe.autoResize(enable) enable"),!1===me&&!1===de?(H(l),G("Auto Resize can not be changed when <b>direction</> is set to 'none'."),!1):(!0===e&&!1===oe?(oe=!0,queueMicrotask((()=>$t(l,"Auto Resize enabled")))):!1===e&&!0===oe&&(oe=!1),Ot(0,0,"autoResize",JSON.stringify(oe)),oe)),close(){Ot(0,0,"close")},getId:()=>je,getOrigin:()=>(F("getOrigin()","getParentOrigin()"),ee),getParentOrigin:()=>ee,getPageInfo(e){if("function"==typeof e)return Fe=e,Ot(0,0,"pageInfo"),void V("getPageInfo()","getParentProps()","See <u>https://iframe-resizer.com/upgrade</> for details. ");Fe=null,Ot(0,0,"pageInfoStop")},getParentProps:e=>(E(e,"function","parentIframe.getParentProps(callback) callback"),Ve=e,Ot(0,0,"parentInfo"),()=>{Ve=null,Ot(0,0,"parentInfoStop")}),getParentProperties(e){F("getParentProperties()","getParentProps()"),this.getParentProps(e)},moveToAnchor(e){E(e,"string","parentIframe.moveToAnchor(anchor) anchor"),we.findTarget(e)},reset(){!function(){const e=be;be=N,Le||(Le=!0,requestAnimationFrame((()=>{Le=!1}))),St("reset"),be=e}()},setOffsetSize(e){E(e,"number","parentIframe.setOffsetSize(offset) offset"),Y=e,K=e,$t(f,`parentIframe.setOffsetSize(${e})`)},scrollBy(e,t){E(e,"number","parentIframe.scrollBy(x, y) x"),E(t,"number","parentIframe.scrollBy(x, y) y"),Ot(t,e,"scrollBy")},scrollTo(e,t){E(e,"number","parentIframe.scrollTo(x, y) x"),E(t,"number","parentIframe.scrollTo(x, y) y"),Ot(t,e,"scrollTo")},scrollToOffset(e,t){E(e,"number","parentIframe.scrollToOffset(x, y) x"),E(t,"number","parentIframe.scrollToOffset(x, y) y"),Ot(t,e,"scrollToOffset")},sendMessage(e,t){t&&E(t,"string","parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),Ot(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){be=e,rt()},setWidthCalculationMethod(e){qe=e,it()},setTargetOrigin(e){E(e,"string","parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),Re=e},resize(e,t){e&&E(e,"number","parentIframe.resize(customHeight, customWidth) customHeight"),t&&E(t,"number","parentIframe.resize(customHeight, customWidth) customWidth"),$t(u,`parentIframe.resize(${e||""}${t?`,${t}`:""})`,e,t)},size(e,t){F("size()","resize()"),this.resize(e,t)}}),Ge.parentIFrame=Ge.parentIframe),function(){function e(e){Ot(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){b(window.document,t,e)}!0===Ee&&(t("mouseenter"),t("mouseleave"))}(),we=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function t(t){const o=t.getBoundingClientRect(),r=e();return{x:parseInt(o.left,n)+parseInt(r.x,n),y:parseInt(o.top,n)+parseInt(r.y,n)}}function o(e){function n(e){const n=t(e);Ot(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?Ot(0,0,"inPageLink",`#${o}`):n(i)}function r(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&o(t)}function i(){for(const e of document.querySelectorAll('a[href^="#"]'))"#"!==e.getAttribute("href")&&b(e,"click",(t=>{t.preventDefault(),o(e.getAttribute("href"))}))}function a(){b(window,"hashchange",r)}function s(){setTimeout(r,128)}function l(){i(),a(),s()}return we.enable&&(1===Ie?G("In page linking requires a Professional or Business license. Please see <u>https://iframe-resizer.com/pricing</> for more details."):l()),{findTarget:o}}(),void 0===ae&&(ae=`${ie}px`),Ke("margin",(m="margin",(p=ae).includes("-")&&(q(`Negative CSS value ignored for ${m}`),p=""),p)),Ke("background",re),Ke("padding",ue),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body)}(),function(e){nt({method:e,eventType:"After Print",eventName:"afterprint"}),nt({method:e,eventType:"Before Print",eventName:"beforeprint"}),nt({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}("add"),function(){const e=new Set,t=[];let n=!1,r=0;const a=t=>{A("Mutations observed:",t);for(const n of t){const{addedNodes:t,removedNodes:o}=n;for(const n of t)e.add(n);for(const t of o)e.delete(t)}},s=16,l=2,c=200;let u=1;function d(e){tt(),Qe(e),e.forEach(lt),e.clear()}function m(){const o=performance.now(),i=o-r;if(i>s*u+++l&&i<c)return A("Backed off due to heavy workload on callStack"),setTimeout(m,s*u),void(r=o);u=1,t.forEach(a),t.length=0,e.size>0&&d(e),_e(),Ze(),n=!1,$t(y,"Mutation Observed")}function f(e){t.push(e),n||(r=performance.now(),n=!0,requestAnimationFrame(m))}function p(){const e=new window.MutationObserver(f),t=document.querySelector("body"),n={attributes:!0,attributeFilter:[i,o],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return e.observe(t,n),e}p()}(),Ae=new ResizeObserver(at),Ae.observe(document.body),st.add(document.body),lt(document.body),de!==me&&(Te=(e=>{const t=e.side||a,n=e.onChange||$,o={root:e.root,rootMargin:"0px",threshold:1},i=window?.requestAnimationFrame||$,s=(e=!1)=>n(e),l=(e,n)=>0===e||e>n[t],c=(e,t)=>e.toggleAttribute(r,t),u=new IntersectionObserver((function(e){for(const o of e){const{boundingClientRect:e,rootBounds:r,target:i}=o,a=e[t],s=l(a,r)&&!((n=i).hidden||null===n.offsetParent||"none"===n.style.display);c(i,s)}var n;i(s)}),o),d=new WeakSet;return function(e){for(const t of e){const e=t.nodeType===Node.ELEMENT_NODE,n=d.has(t);!n&&e?(u.observe(t),d.add(t)):C(!n,"Node already observed",t)}}})({onChange:Je,root:document.documentElement,side:de?a:s})),Qe(dt(document)()),queueMicrotask(De),$t(g,"Init message from host page",void 0,void 0,t),document.title&&""!==document.title&&Ot(0,0,"title",document.title)}function Ze(){ke=document.querySelectorAll(`[${r}]:not([${i}]):not([${i}] *)`),he=ke.length>0}function Je(e){Ze(),(he||e)&&(he?A("Overflowed Elements:",...ke):A("Overflow removed"),$t(h,"Overflow updated"))}function _e(){xe=document.querySelectorAll(`[${o}]`),ye=xe.length>0}function Qe(e){ye||Te(e)}let Xe=0;function Ye(){const t=document.querySelectorAll(`*[${i}]`);pe=t.length>0,pe&&t.length!==Xe&&(function(t){const n=1===t.length?"":"s";q(`%c[${i}]%c found on %c${t.length}%c element${n}`,e.BOLD,e.NORMAL,e.BOLD,e.NORMAL)}(t),Xe=t.length)}function Ke(t,n){void 0!==n&&""!==n&&"null"!==n&&(document.body.style.setProperty(t,n),A(`Set body ${t}: %c${n}`,e.HIGHLIGHT))}function et(e,t,n){if(""!==n)for(const e of document.querySelectorAll(n))e.toggleAttribute(t,!0)}function tt(){et(0,o,Pe),et(0,i,ve)}function nt(e){({add(t){function n(){$t(e.eventName,e.eventType)}M[t]=n,b(window,t,n,{passive:!0})},remove(e){const t=M[e];var n,o;delete M[e],n=e,o=t,window.removeEventListener(n,o,!1)}})[e.method](e.eventName)}function ot(e,t,n,o){return t!==e&&(e in n||(q(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in T)&&G(`<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 ${te?"remove this option.":"set this option to <b>'auto'</> when using an older version of <i>iframe-resizer</> on the parent page."}`),e}function rt(){be=ot(be,N,yt,"height")}function it(){qe=ot(qe,Z,gt,"width")}function at(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;$t(p,`Element resized <${function(e){switch(!0){case!I(e):return"";case I(e.id):return`${e.nodeName}#${e.id}`;case I(e.name):return`${e.nodeName} (${e.name}`;case I(e.className):return`${e.nodeName}.${e.className}`;default:return e.nodeName}}(t)}>`)}const st=new WeakSet;function lt(e){if(e.nodeType!==Node.ELEMENT_NODE)return;if(!st.has(e)){const t=getComputedStyle(e)?.position;""!==t&&"static"!==t&&(Ae.observe(e),st.add(e))}const t=dt(e)();for(const e of t){if(st.has(e)||e?.nodeType!==Node.ELEMENT_NODE)continue;const t=getComputedStyle(e)?.position;""!==t&&"static"!==t&&(Ae.observe(e),st.add(e))}}function ct(e){performance.mark(Q);const t=O(e);let n=0,o=document.documentElement,r=ye?0:document.documentElement.getBoundingClientRect().bottom;const i=ye?xe:he?ke:dt(document)();let a=i.length;for(const t of i)ye||!P||t.checkVisibility(v)?(n=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),n>r&&(r=n,o=t)):a-=1;return A(`${t} position calculated from:`,o),performance.mark(X,{detail:{Side:t,len:a,hasTags:ye,logging:Se}}),r}const ut=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.boundingClientRect()],dt=e=>()=>{Ye();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 pe&&t.push(`not([${i}])`,`not([${i}] *)`),e.querySelectorAll(t.join(":"))},mt={height:0,width:0},ft={height:0,width:0},pt=[e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT];function ht(t){function n(){return ft[r]=i,mt[r]=l,i}const o=t===yt,r=o?"height":"width",i=t.boundingClientRect(),a=Math.ceil(i),s=Math.floor(i),l=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(t),c=`HTML: %c${i}px %cPage: %c${l}px`;let u=0;switch(!0){case!t.enabled():return l;case ye:A("Found element with data-iframe-size attribute"),u=t.taggedElement();break;case!he&&0===ft[r]&&0===mt[r]:A(`Initial page size values: ${c}`,...pt),u=n();break;case Le&&i===ft[r]&&l===mt[r]:A(`Size unchanged: ${c}`,...pt),u=Math.max(i,l);break;case 0===i:A(`Page is hidden: ${c}`,...pt),u=l;break;case!he&&i!==ft[r]&&l<=mt[r]:A(`New <html> size: ${c} `,...pt),A(`Previous <html> size: %c${ft[r]}px`,e.HIGHLIGHT),u=n();break;case!o:u=t.taggedElement();break;case!he&&i<ft[r]:A(`<html> size decreased: ${c}`,...pt),u=n();break;case l===s||l===a:A(`<html> size equals page size: ${c}`,...pt),u=n();break;case i>l:A(`Page size < <html> size: ${c}`,...pt),u=n();break;case he:A("Found element overflowing <html> "),u=t.taggedElement();break;default:A(`Using <html> size: ${c}`,...pt),u=n()}return A(`Content ${r}: %c${u}px`,e.HIGHLIGHT),u+=function(t){const n=t.getOffset();return 0!==n&&A(`Page offsetSize: %c${n}px`,e.HIGHLIGHT),n}(t),u}const yt={enabled:()=>de,getOffset:()=>Y,auto:()=>ht(yt),bodyOffset:()=>{const{body:e}=document,t=getComputedStyle(e);return e.offsetHeight+parseInt(t.marginTop,n)+parseInt(t.marginBottom,n)},bodyScroll:()=>document.body.scrollHeight,offset:()=>yt.bodyOffset(),custom:()=>S.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),max:()=>Math.max(...ut(yt)),min:()=>Math.min(...ut(yt)),grow:()=>yt.max(),lowestElement:()=>ct(a),taggedElement:()=>ct(a)},gt={enabled:()=>me,getOffset:()=>K,auto:()=>ht(gt),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>S.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),max:()=>Math.max(...ut(gt)),min:()=>Math.min(...ut(gt)),rightMostElement:()=>ct(s),scroll:()=>Math.max(gt.bodyScroll(),gt.documentElementScroll()),taggedElement:()=>ct(s)},bt=(e,t)=>!(Math.abs(e-t)<=He);function vt(e,t){const n=e[t]();return e.enabled()&&void 0!==ne?function(e){const t=ne(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 zt=!1;const wt=w((()=>W(z(4)))),$t=R(((e,t,n,o,r)=>{if(performance.now(),H(e),!0!==zt)return oe||e in m?void(document.hidden||(zt=!0,requestAnimationFrame((()=>{zt=!1})),function(e,t,n,o,r){const i=n??vt(yt,be),a=o??vt(gt,qe);switch(de&&bt(ge,i)||me&&bt(Be,a)?c:e){case g:case l:case c:ge=i,Be=a;case f:Ot(ge,Be,e,r);break;case p:case h:case y:B();break;default:B(),A("No change in content size detected")}}(e,0,n,o,r))):(A("Resizing disabled"),void x())}));function St(e){ge=yt[be](),Be=gt[qe](),Ot(ge,Be,e)}const Ot=R((function(t,n,o,r,i){Ie<-1||(H(o),void 0!==i||(i=Re),function(){const a=`${je}:${t}:${n}:${o}${void 0===r?"":`:${r}`}`;if(Ce)try{window.parent.iframeParentListener(D+a)}catch(e){if(1!==Ie)throw e;return void wt()}else Ne.postMessage(D+a,i);A(`Sending message to parent page via ${Ce?"sameOrigin":"postMessage"}: %c%c${a}`,e.ITALIC,e.HIGHLIGHT)}(),x())})),It=R((function(e){H("onMessage");const{freeze:t}=Object,{parse:n}=JSON,o=e=>Ot(0,0,`${e}Stop`),r={init:function(){if("loading"===document.readyState)return;const t=e.data.slice(13).split(":");Ne=e.source,ee=e.origin,Ue(t),fe=!1,setTimeout((()=>{ze=!1}),128)},reset(){ze||St("resetPage")},resize(){$t(d,"Parent window requested size check")},moveToAnchor(){we.findTarget(a())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=a();Fe?setTimeout((()=>Fe(n(e)))):o("pageInfo")},parentInfo(){const e=(r=a(),t(n(r)));var r;Ve?setTimeout((()=>Ve(e))):o("parentInfo")},message(){const e=a();setTimeout((()=>We(n(e))))}},i=()=>e.data.split("]")[1].split(":")[0],a=()=>e.data.slice(e.data.indexOf(":")+1),s=()=>e.data.split(":")[2]in{true:1,false:1};function l(){const t=i();H(t),t in r?r[t]():"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype||s()||q(`Unexpected message (${e.data})`)}D===`${e.data}`.slice(0,13)&&function(){if(!1!==fe)return s()?(L(i()),H(g),void r.init()):void 0;l()}()}));function Et(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"iframeChildListener"in window?q("Already setup"):(window.iframeChildListener=e=>setTimeout((()=>It({data:e,sameOrigin:!0}))),b(window,"message",It),b(window,"readystatechange",Et),Et())}();