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