iframe-resizer
Version:
Keep iframes sized to their content.
21 lines (18 loc) • 24.9 kB
JavaScript
/*!
* @preserve
*
* @module iframe-resizer/legacy (parent) 5.5.9 (umd) - 2026-02-06
*
* @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 - 2026, David J. Bradshaw. All rights reserved.
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).iframeResize=t()}(this,function(){"use strict";console.info("IFRAME-RESIZER 5\n\nThis package has been split into separate packages for Parent and Child pages. Along with new packages for jQuery, React and Vue.\n\nGoing forward you are advised to use the new separate packages for Parent and Child pages, rather than this combined package.\n\nPlease see https://iframe-resizer.com/upgrade for more details.\n");const e="5.5.9",t="iframeResizer",n=":",o="autoResize",i="init",r="iframeReady",a="load",s="message",l="onload",c="pageInfo",u="parentInfo",d="reset",f="resize",p="scroll",h="\n",m="child",g="parent",y="string",b="object",w="function",v="undefined",z="auto",$="none",j="both",k="vertical",T="horizontal",x="[iFrameSizer]",M=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),E=Object.freeze({[l]:1,[i]:1,[r]:1}),R="expanded",O="collapsed",S=Object.freeze({[R]:1,[O]:1}),I="Use of the old name will be removed in a future version of <i>iframe-resizer</>.",C="font-weight: normal;",A=C+"font-style: italic;",W="default",L=Object.freeze({assert:!0,error:!0,warn:!0}),F={expand:!1,defaultEvent:void 0,event:void 0,label:"AutoConsoleGroup",showTime:!0},N={profile:0,profileEnd:0,timeStamp:0,trace:0},P=Object.assign(console);const{fromEntries:B,keys:H}=Object,D=e=>[e,P[e]],q=e=>t=>[t,function(n){e[t]=n}],U=(e,t)=>B(H(e).map(t));const J=!(typeof window>"u"||"function"!=typeof window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches,Z=J?"color: #A9C7FB;":"color: #135CD2;",V=J?"color: #E3E3E3;":"color: #1F1F1F;",G=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),X={br:"\n",rb:"[31;1m",bb:"[34;1m",b:"[1m",i:"[3m",u:"[4m","/":"[m"},Y=Object.keys(X),_=new RegExp(`<(${Y.join("|")})>`,"gi"),Q=(e,t)=>X[t]??"",K=e=>t=>e(typeof t===y?window.chrome?t.replace(_,Q):(e=>e.replaceAll("<br>",h).replaceAll(/<\/?[^>]+>/gi,""))(t):t),ee={},te=(ne=function(e={}){const t={},n={},o=[],i={...F,expand:!e.collapsed||F.expanded,...e};let r="";function a(){o.length=0,r=""}function s(){delete i.event,a()}const l=()=>!!o.some(([e])=>e in L)||!!i.expand;function c(){if(0!==o.length){P[l()?"group":"groupCollapsed"](`%c${i.label}%c ${(e=>{const t=e.event||e.defaultEvent;return t?`${t}`:""})(i)} %c${i.showTime?r:""}`,C,"font-weight: bold;",A);for(const[e,...t]of o)P.assert(e in P,`Unknown console method: ${e}`),e in P&&P[e](...t);P.groupEnd(),s()}else s()}function u(){""===r&&(r=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)}`}(),queueMicrotask(()=>queueMicrotask(c)))}function d(e,...t){0===o.length&&u(),o.push([e,...t])}function f(e=W,...n){t[e]?d("log",`${e}: ${performance.now()-t[e]} ms`,...n):d("timeLog",e,...n)}return{...U(i,q(i)),...U(console,e=>[e,(...t)=>d(e,...t)]),...U(N,D),assert:function(e,...t){!0!==e&&d("assert",e,...t)},count:function(e=W){n[e]?n[e]+=1:n[e]=1,d("log",`${e}: ${n[e]}`)},countReset:function(e=W){delete n[e]},endAutoGroup:c,errorBoundary:e=>(...t)=>{let n;try{n=e(...t)}catch(e){if(!Error.prototype.isPrototypeOf(e))throw e;d("error",e),c()}return n},event:function(e){u(),i.event=e},purge:a,time:function(e=W){u(),t[e]=performance.now()},timeEnd:function(e=W){f(e),delete t[e]},timeLog:f,touch:u}},ne?.__esModule?ne.default:ne);var ne;let oe=!0;const ie=te({expand:!1,label:g}),re=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const ae=e=>(t,...n)=>ee[t]?ee[t].console[e](...n):ie[e](...n);var se;const le=(se="log",(e,...t)=>!0===(e=>ee[e]?ee[e].log:oe)(e)?ae(se)(e,...t):null),ce=ae("warn"),ue=ae("error"),de=ae("event"),fe=ae("purge"),pe=ae("endAutoGroup"),he=ae("errorBoundary");const me=K(e=>e),ge=(e,...n)=>ee[e]?ee[e].console.warn(...n.map(me)):queueMicrotask(()=>{const o=K((e=>(...n)=>[`${t}(${e})`,...n].join(" "))(e));console?.warn(...n.map(o))}),ye=(e=>(t,n="renamed to")=>(o,i,r="",a="")=>e(a,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${i}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(ge),be=ye("Function"),we=ye("Option"),ve=(e,t,n,o)=>e.addEventListener(t,n,o||!1),ze=(e,t,n)=>e.removeEventListener(t,n,!1),$e=e=>{if(!e)return"";let t=-559038744,n=1103547984;for(let o,i=0;i<e.length;i++)o=e.codePointAt(i),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)},je=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),ke=["spjluzl","rlf","clyzpvu"],Te=["<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."],xe=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],Me=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5","2b5sdlfhbev","zo4ui3arjo","oclbb4thgl"].map((e,t)=>[e,Math.max(0,t-1)])),Ee=e=>je(Te[e]),Re=e=>{const t=e[je(ke[0])]||e[je(ke[1])]||e[je(ke[2])];if(!t)return-1;const n=t.split("-");let o=function(e=""){let t=-2;const n=$e(je(e));return n in Me&&(t=Me[n]),t>4?t-4:t}(n[0]);return 0===o||(e=>e[2]===$e(e[0]+e[1]))(n)||(o=-2),o};function Oe(e){const{checkOrigin:t,iframe:{id:n,src:o,sandbox:i},initialisedFirstPage:r,waitForLoad:a,warningTimeout:s}=e,l=(e=>{try{return new URL(e).origin}catch(e){return null}})(o);de(n,"noResponse"),ge(n,`<rb>No response from iframe</>\n\nThe iframe (<i>${n}</>) has not responded within ${s/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${t&&l?`\nThe <b>checkOrigin</> option is currently enabled. If the iframe redirects away from <i>${l}</>, then the connection to the iframe may be blocked by the browser. To disable this option, set <b>checkOrigin</> to <bb>false</> or an array of allowed origins. See <u>https://iframe-resizer.com/checkorigin</> for more information.\n`:""}${a&&!r?"\nThe <b>waitForLoad</> option is currently set to <bb>true</>. If the iframe loads before <i>iframe-resizer</> runs, this option will prevent <i>iframe-resizer</> initialising. To disable this option, set <b>waitForLoad</> to <bb>false</>.\n":""}${(e=>typeof e===b&&e.length>0&&!(e.contains("allow-scripts")&&e.contains("allow-same-origin")))(i)?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <bb>allow-same-origin</> and <bb>allow-scripts</> values.\n":""}\nThis message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.\n`)}const Se={};const Ie=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:k,firstRun:!0,inPageLinks:!1,heightCalculationMethod:z,id:"iFrameResizer",log:!1,logExpand:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,waitForLoad:!1,warningTimeout:5e3,widthCalculationMethod:z,onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{typeof ee[e.id].onInit===w&&(we("init()","onReady()","",e.id),ee[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),Ce={position:null,version:e};function Ae(t){function r(){De(F),Be(B),I("onResized",F)}function l(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function h(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const m=e=>W.slice(W.indexOf(n)+7+e);const b=(e,t)=>(n,o)=>{const i={};var r,a;r=function(){Ue(`${n} (${e})`,`${e}:${t()}`,o)},i[a=o]||(r(),i[a]=requestAnimationFrame(()=>{i[a]=null}))},w=(e,t)=>()=>{let n=!1;const o=t=>()=>{ee[c]?n&&n!==t||(e(t,c),n=t,requestAnimationFrame(()=>{n=!1})):l()},i=o(p),r=o("resize window");function s(e,t){t(window,p,i),t(window,f,r)}function l(){de(c,`stop${t}`),s(0,ze),u.disconnect(),d.disconnect(),ze(ee[c].iframe,a,l)}const c=B,u=new ResizeObserver(o("pageObserver")),d=new ResizeObserver(o("iframeObserver"));ee[c]&&(ee[c][`stop${t}`]=l,ve(ee[c].iframe,a,l),s(0,ve),u.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(ee[c].iframe,{attributes:!0,childList:!1,subtree:!1}))},v=e=>()=>{e in ee[B]&&(ee[B][e](),delete ee[B][e])},z=b(c,function(){const e=document.body.getBoundingClientRect(),t=F.iframe.getBoundingClientRect(),{scrollY:n,scrollX:o,innerHeight:i,innerWidth:r}=window,{clientHeight:a,clientWidth:s}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(a,i||0),clientWidth:Math.max(s,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:n,scrollLeft:o,documentHeight:a,documentWidth:s,windowHeight:i,windowWidth:r})}),$=b(u,function(){const{iframe:e}=F,{scrollWidth:t,scrollHeight:n}=document.documentElement,{width:o,height:i,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:n},viewport:{width:o,height:i,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}})}),j=w(z,"PageInfo"),k=w($,"ParentInfo"),T=v("stopPageInfo"),M=v("stopParentInfo");function E(e){const t=e.getBoundingClientRect();return Ne(),{x:Number(t.left)+Number(Ce.position.x),y:Number(t.top)+Number(Ce.position.y)}}function R(e){const t=e?E(F.iframe):{x:0,y:0};le(B,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,Z,V,Z);const n=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(F,t),o=window.parentIframe||window.parentIFrame;o?function(t,n){setTimeout(()=>t["scrollTo"+(e?"Offset":"")](n.x,n.y))}(o,n):function(e){Ce.position=e,O(B)}(n)}function O(e){const{x:t,y:n}=Ce.position,o=ee[e]?.iframe;!1!==I("onScroll",{iframe:o,top:n,left:t,x:t,y:n})?Be(e):Pe()}function S(e){let t={};if(0===F.width&&0===F.height){const e=m(9).split(n);t={x:e[1],y:e[0]}}else t={x:F.width,y:F.height};I(e,{iframe:F.iframe,screenX:Number(t.x),screenY:Number(t.y),type:F.type})}const I=(e,t)=>We(B,e,t);function C(){const{height:t,iframe:n,msg:a,type:l,width:f}=F;switch(ee[B]?.firstRun&&function(){if(!ee[B])return;Ge(B,F.mode),ee[B].firstRun=!1}(),l){case"close":Fe(n);break;case s:h=m(6),I("onMessage",{iframe:F.iframe,message:JSON.parse(h)});break;case"mouseenter":S("onMouseEnter");break;case"mouseleave":S("onMouseLeave");break;case"beforeUnload":le(B,"Ready state reset"),ee[B].initialised=!1;break;case o:ee[B].autoResize=JSON.parse(m(9));break;case"scrollBy":!function(){const e=F.width,t=F.height,n=window.parentIframe||window.parentIFrame||window;le(B,`scrollBy: x: %c${e}%c y: %c${t}`,Z,V,Z),n.scrollBy(e,t)}();break;case"scrollTo":R(!1);break;case"scrollToOffset":R(!0);break;case c:j();break;case u:k();break;case"pageInfoStop":T();break;case"parentInfoStop":M();break;case"inPageLink":!function(e){const t=e.split("#")[1]||"",n=decodeURIComponent(t);let o=document.getElementById(n)||document.getElementsByName(n)[0];o?function(){const e=E(o);le(B,`Moving to in page link: %c#${t}`,Z),Ce.position={x:e.x,y:e.y},O(B),window.location.hash=t}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(t)}()}(m(9));break;case"title":!function(e,t){ee[t]?.syncTitle&&(ee[t].iframe.title=e,le(t,`Set iframe title attribute: %c${e}`,Z))}(a,B);break;case d:He(F);break;case i:r(),function(e){try{ee[e].sameOrigin=!!ee[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){ee[e].sameOrigin=!1}}(B),(p=a)!==e&&(void 0!==p||ge(B,"<rb>Legacy version detected in iframe</>\n\nDetected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.\n\nSee <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.\n")),ee[B].initialised=!0,I("onReady",n);break;default:if(0===f&&0===t)return void ce(B,`Unsupported message received (${l}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===f||0===t)return;if(document.hidden)return;r()}var p,h}function A(e){if(!ee[e])throw new Error(`${F.type} No settings for ${e}. Message was: ${W}`)}let W=t.data;if("[iFrameResizerChild]Ready"===W)return L=t.source,void Object.values(ee).forEach((e=>({initChild:t,postMessageTarget:n})=>{e===n&&t()})(L));var L;if(!(e=>x===`${e}`.slice(0,13)&&e.slice(13).split(n)[0]in ee)(W)){if(typeof W!==y)return;return void de(g,"ignoredMessage")}const F=function(e){const t=e.slice(13).split(n),o=t[1]?Number(t[1]):0,i=ee[t[0]]?.iframe,r=getComputedStyle(i),a={iframe:i,id:t[0],height:o+l(r)+h(r),width:Number(t[2]),type:t[3],msg:t[4]};return t[5]&&(a.mode=t[5]),a}(W),{id:N,type:P}=F,B=N;B?(de(B,P),he(B,function(e){A(B),F.type in{true:1,false:1,undefined:1}||(null!==F.iframe||(ce(B,`The iframe (${F.id}) was not found.`),0))&&function(){const{origin:e,sameOrigin:n}=t;if(n)return!0;let o=ee[B]?.checkOrigin;if(o&&"null"!=`${e}`&&!(o.constructor===Array?function(){let t=0,n=!1;for(;t<o.length;t++)if(o[t]===e){n=!0;break}return n}():function(){const t=ee[B]?.remoteHost;return e===t}()))throw new Error(`Unexpected message received from: ${e} for ${F.iframe.id}. Message was: ${t.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&C()})(W)):ce("","iframeResizer received messageData without id, message was: ",W)}function We(e,t,n){let o=null,i=null;if(ee[e]){if(o=ee[e][t],typeof o!==w)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{i=o(n)}catch(n){console.error(n),ce(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(o,n)}return i}function Le(e){const{id:t}=e;delete ee[t],delete e.iframeResizer}function Fe(e){const{id:t}=e;if(!1!==We(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){ce(t,e)}We(t,"onAfterClose",t),Le(e)}}function Ne(e){null===Ce.position&&(Ce.position={x:window.scrollX,y:window.scrollY})}function Pe(){Ce.position=null}function Be(e){null!==Ce.position&&(window.scrollTo(Ce.position.x,Ce.position.y),le(e,`Set page position: %c${Ce.position.x}%c, %c${Ce.position.y}`,Z,V,Z),Pe())}function He(e){Ne(e.id),De(e),Ue(d,d,e.id)}function De(e){function t(t){const o=`${e[t]}px`;e.iframe.style[t]=o,le(n,`Set ${t}: %c${o}`,Z)}const{id:n}=e,{sizeHeight:o,sizeWidth:i}=ee[n];o&&t("height"),i&&t("width")}const qe=e=>e.split(n).filter((e,t)=>19!==t).join(n);function Ue(e,t,n){function o(o){const i=e in E?qe(t):t;le(n,o,Z,V,Z),le(n,`Message data: %c${i}`,Z)}de(n,e),ee[n]&&(ee[n]?.postMessageTarget?function(){const{iframe:i,postMessageTarget:r,sameOrigin:a,targetOrigin:s}=ee[n];if(a)try{return i.contentWindow.iframeChildListener(x+t),void o(`Sending message to iframe %c${n}%c via same origin%c`)}catch(t){e in E?ee[n].sameOrigin=!1:ce(n,"Same origin messaging failed, falling back to postMessage")}o(`Sending message to iframe: %c${n}%c targetOrigin: %c${s}`),r.postMessage(x+t,s)}():ce(n,`Iframe(${n}) not found`))}let Je=0,Ze=!1,Ve=!1;function Ge(t,n=-3){if(Ze)return;const o=Math.max(ee[t].mode,n);if(o>ee[t].mode&&(ee[t].mode=o),o<0)throw fe(t),ee[t].vAdvised||ge(t||"Parent",`${Ee(o+2)}${Ee(2)}`),ee[t].vAdvised=!0,Ee(o+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");o>0&&Ve||function(e,t){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,oe||t<1?"font-weight: bold;":C))}(`v${e} (${(e=>je(xe[e]))(o)})`,o),o<1&&ge("Parent",Ee(3)),Ze=!0}const Xe=e=>c=>{function u(){ee[A]?.heightCalculationMethod in M&&He({iframe:c,height:1,width:1,type:i})}function d(){if(ee[A]){const{iframe:e}=ee[A],t={close:Fe.bind(null,e),disconnect:Le.bind(null,e),removeListeners(){ge(A,`<rb>Deprecated Method Name</>\n\nThe <b>removeListeners()</> method has been renamed to <b>disconnect()</>. ${I}\n`),this.disconnect()},resize(){ge(A,"<rb>Deprecated Method</>\n\nUse of the <b>resize()</> method from the parent page is deprecated and will be removed in a future version of <i>iframe-resizer</>. As their are no longer any edge cases that require triggering a resize from the parent page, it is recommended to remove this method from your code."),Ue.bind(null,"Window resize",f,A)},moveToAnchor(e){((e,t,n)=>{if(typeof e!==t)throw new TypeError(`${n} is not a ${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,y,"moveToAnchor(anchor) anchor"),Ue("Move to anchor",`moveToAnchor:${e}`,A)},sendMessage(e){e=JSON.stringify(e),Ue(s,`${s}:${e}`,A)}};e.iframeResizer=t,e.iFrameResizer=t}}function p(e,t){const n=n=>()=>{if(!ee[e])return;const{firstRun:o,iframe:r}=ee[e];Ue(n,t,e),(e=>e===i)(n)&&(e=>"lazy"===e.loading)(r)||function(e,t){const n=t[e],{msgTimeout:o,warningTimeout:i}=n;i&&(o&&clearTimeout(o),n.msgTimeout=setTimeout(function(){const n=t[e];void 0!==n&&((e=>{e.msgTimeout=void 0})(n),function(e){const{initialised:t}=e;return t&&(e.initialisedFirstPage=!0),t}(n)||Oe(n))},i))}(e,ee),o||u()},{iframe:o}=ee[e];ee[e].initChild=n(r),function(e,t){ve(e,a,()=>setTimeout(t,1))}(o,n(l)),function(e,t){const{iframe:n,waitForLoad:o}=ee[e];!0!==o&&((e=>{const{src:t,srcdoc:n}=e;return!n&&(null==t||""===t||"about:blank"===t)})(n)?setTimeout(()=>{de(e,"noContent"),le(e,"No content detected in the iframe, delaying initialisation")}):setTimeout(t))}(e,n(i))}function g(e){return e?(("sizeWidth"in e||"sizeHeight"in e||o in e)&&ge(A,`<rb>Deprecated Option</>\n\nThe <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <bb>${k}</>, <bb>${T}</>, <bb>${j}</> or <bb>${$}</>.\n`),e):{}}function w(e){const t=ee[e]?.iframe?.title;return""===t||void 0===t}function v(e,t){G(ee[A],e)&&(ge(A,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${t}</>. ${I}`),ee[A][t]=ee[A][e],delete ee[A][e])}const x=e=>G(e,"onMouseEnter")||G(e,"onMouseLeave");function E(e){var t,n;ee[A]={...ee[A],iframe:c,remoteHost:c?.src.split("/").slice(0,3).join("/"),...Ie,...g(e),mouseEvents:x(e),mode:Re(e),syncTitle:w(A)},v("offset","offsetSize"),v("onClose","onBeforeClose"),v("onClosed","onAfterClose"),de(A,"setup"),function(){const{direction:e}=ee[A];switch(e){case k:break;case T:ee[A].sizeHeight=!1;case j:ee[A].sizeWidth=!0;break;case $:ee[A].sizeWidth=!1,ee[A].sizeHeight=!1,ee[A].autoResize=!1;break;default:throw new TypeError(A,`Direction value of "${e}" is not valid`)}}(),(t=e?.offsetSize||e?.offset)&&(ee[A].direction===k?ee[A].offsetHeight=t:ee[A].offsetWidth=t),ee[A].warningTimeout||le(A,"warningTimeout:%c disabled",Z),null===ee[A].postMessageTarget&&(ee[A].postMessageTarget=c.contentWindow),ee[A].targetOrigin=!0===ee[A].checkOrigin?""===(n=ee[A].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}const C=()=>t in c,A=function(t){if(t&&typeof t!==y)throw new TypeError("Invalid id for iFrame. Expected String");return""!==t&&t||(t=function(){let t=e?.id||Ie.id+Je++;return null!==document.getElementById(t)&&(t+=Je++),t}(),c.id=t,de(t,"assignId")),t}(c.id);if(typeof e!==b)throw new TypeError("Options is not an object");return function(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=O,e.logExpand=t.includes("ifrlog=expanded"))}(e),function(e,t){const n=G(t,"log"),o=typeof t.log===y,i=n?!!o||t.log:Ie.log;G(t,"logExpand")||(t.logExpand=n&&o?t.log===R:Ie.logExpand),function(e){-1===e?.log&&(e.log=!1,Ve=!0)}(t),function({enabled:e,expand:t,iframeId:n}){const o=te({expand:t,label:re(n)});oe=e,ee[n]||(ee[n]={console:o})}({enabled:i,expand:t.logExpand,iframeId:e}),o&&!(t.log in S)&&ue(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=i}(A,e),he(A,function(e){C()?ce(A,`Ignored iframe (${A}), already setup.`):(E(e),function(e){if(!0===Se[e])return!1;const t=document.querySelectorAll(`iframe#${CSS.escape(e)}`);if(t.length<=1)return!0;Se[e]=!0;const n=Array.from(t).flatMap(e=>[h,e,h]);ge(e,`<rb>Duplicate ID attributes detected</>\n\nThe <b>${e}</> ID is not unique. Having multiple iframes on the same page with the same ID causes problems with communication between the iframe and parent page. Please ensure that the ID of each iframe has a unique value.\n\nFound <bb>${t.length}</> iframes with the <b>${e}</> ID:`,...n,h)}(A),function(){if(Ze)return;const{mode:e}=ee[A];-1!==e&&Ge(A,e)}(),_e(),function(){switch(c.style.overflow=!1===ee[A]?.scrolling?"hidden":z,ee[A]?.scrolling){case"omit":break;case!0:c.scrolling="yes";break;case!1:c.scrolling="no";break;default:c.scrolling=ee[A]?ee[A].scrolling:"no"}}(),function(){const{bodyMargin:e}=ee[A];"number"!=typeof e&&"0"!==e||(ee[A].bodyMargin=`${e}px`)}(),p(A,function(e){const{autoResize:t,bodyBackground:o,bodyMargin:i,bodyPadding:r,heightCalculationMethod:a,inPageLinks:s,license:l,log:c,logExpand:u,mouseEvents:d,offsetHeight:f,offsetWidth:p,mode:h,sizeHeight:g,sizeWidth:y,tolerance:b,widthCalculationMethod:w}=ee[e];return[e,"8",y,c,"32",!0,t,i,a,o,r,b,s,m,w,d,f,p,g,l,Ce.version,h,"",u].join(n)}(A)),d(),pe(A))})(e),c?.iframeResizer};function Ye(){!0!==document.hidden&&((e,t)=>{Object.values(ee).filter(({autoResize:e,firstRun:t})=>e&&!t).forEach(({iframe:n})=>Ue(e,t,n.id))})("tabVisible",f)}const _e=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{ve(window,s,Ae),ve(document,"visibilitychange",Ye),window.iframeParentListener=e=>setTimeout(()=>Ae({data:e,sameOrigin:!0}))}),Qe=`[${t}] `;const Ke=function(){function e(e){switch(!0){case!e:throw new TypeError(`${Qe}iframe is not defined`);case!e.tagName:throw new TypeError(`${Qe}Not a valid DOM element`);case"IFRAME"!==e.tagName.toUpperCase():throw new TypeError(`${Qe}Expected <IFRAME> tag, found <${e.tagName}>`);case!e.isConnected:!function(e){const n=new MutationObserver(()=>{e.isConnected&&(t(e),n.disconnect())});n.observe(document.body,{childList:!0,subtree:!0})}(e),n.push(e);break;default:t(e),n.push(e)}}let t,n;return function(o,i){if(typeof window===v)return[];if(!document.body)throw new TypeError(`${Qe}document.body is not available. Ensure the DOM is fully loaded before calling iframeResize().`);switch(t=Xe(o),n=[],typeof i){case v:case y:document.querySelectorAll(i||"iframe").forEach(e);break;case b:e(i);break;default:throw new TypeError(`${Qe}Unexpected data type (${typeof i})`)}return Object.freeze(n)}}();return typeof window!==v&&(window.iFrameResize=window.iFrameResize||function(...e){be("iFrameResize()","iframeResize()","",g),Ke(...e)}),Ke});