UNPKG

iframe-resizer

Version:

Keep iframes sized to their content.

21 lines (18 loc) 22.9 kB
/*! * @preserve * * @module iframe-resizer/legacy (parent) 5.5.3 (umd) - 2025-08-20 * * @license GPL-3.0 for non-commercial use only. * For commercial use, you must purchase a license from * https://iframe-resizer.com/pricing * * @description Keep same and cross domain iFrames sized to their content * * @author David J. Bradshaw <info@iframe-resizer.com> * * @see {@link https://iframe-resizer.com} * * @copyright (c) 2013 - 2025, David J. Bradshaw. All rights reserved. */ !function(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="font-weight: normal;",t=e+"font-style: italic;",o="default",n=Object.freeze({assert:!0,error:!0,warn:!0}),i={expand:!0,defaultEvent:void 0,event:void 0,label:"AutoConsoleGroup",showTime:!0},r={profile:0,profileEnd:0,timeStamp:0,trace:0},a=Object.assign(console);const{fromEntries:s,keys:l}=Object,c=e=>[e,a[e]],u=e=>t=>[t,function(o){e[t]=o}],d=(e,t)=>s(l(e).map(t));const f=!(typeof window>"u"||"function"!=typeof window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches,p=f?"color: #A9C7FB;":"color: #135CD2;",h=f?"color: #E3E3E3;":"color: #1F1F1F;",m="5.5.3",g="iframeResizer",y="none",b="vertical",w="horizontal",v="[iFrameSizer]",z=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),$="onload",j="init",k=Object.freeze({[$]:1,[j]:1}),T="expanded",x="collapsed",M=Object.freeze({[T]:1,[x]:1}),E=e=>t=>window.chrome?e(t.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):e((e=>e.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,""))(t)),R=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),S=e=>e,O=(I=function(s={}){const l={},f={},p=[],h={...i,expand:!s.collapsed||i.expanded,...s};let m="";function g(){p.length=0,m=""}function y(){delete h.event,g()}const b=()=>!!p.some(([e])=>e in n)||!!h.expand;function w(){if(0!==p.length){a[b()?"group":"groupCollapsed"](`%c${h.label}%c ${(e=>{const t=e.event||e.defaultEvent;return t?`${t}`:""})(h)} %c${h.showTime?m:""}`,e,"font-weight: bold;",t);for(const[e,...t]of p)a.assert(e in a,`Unknown console method: ${e}`),e in a&&a[e](...t);a.groupEnd(),y()}else y()}function v(){""===m&&(m=function(){const e=new Date,t=(t,o)=>e[t]().toString().padStart(o,"0");return`@ ${t("getHours",2)}:${t("getMinutes",2)}:${t("getSeconds",2)}.${t("getMilliseconds",3)}`}())}function z(e,...t){0===p.length&&(v(),queueMicrotask(()=>queueMicrotask(w))),p.push([e,...t])}function $(e=o,...t){l[e]?z("log",`${e}: ${performance.now()-l[e]} ms`,...t):z("timeLog",e,...t)}return{...d(h,u(h)),...d(console,e=>[e,(...t)=>z(e,...t)]),...d(r,c),assert:function(e,...t){!0!==e&&z("assert",e,...t)},count:function(e=o){f[e]?f[e]+=1:f[e]=1,z("log",`${e}: ${f[e]}`)},countReset:function(e=o){delete f[e]},endAutoGroup:w,errorBoundary:e=>(...t)=>{let o;try{o=e(...t)}catch(e){if(!Error.prototype.isPrototypeOf(e))throw e;z("error",e),w()}return o},event:function(e){v(),h.event=e},purge:g,time:function(e=o){v(),l[e]=performance.now()},timeEnd:function(e=o){$(e),delete l[e]},timeLog:$,touch:v}},I?.__esModule?I.default:I);var I;let A={},C=!1;const W=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const L=e=>(t,...o)=>A[t]?.console[e](...o);var N;const F=(N="log",(e,...t)=>!0===(e=>A[e]?A[e].log:C)(e)?L(N)(e,...t):null),B=L("warn"),P=L("error"),H=L("event"),q=L("purge"),D=L("errorBoundary");const U=(e,...t)=>A[e]?A[e].console.warn(E(S)(...t)):queueMicrotask(()=>console?.warn(E((e=>(...t)=>[`${g}(${e})`,...t].join(" "))(e))(...t))),J=(e=>(t,o="renamed to")=>(n,i,r="",a="")=>e(a,`<rb>Deprecated ${t}(${n.replace("()","")})</>\n\nThe <b>${n}</> ${t.toLowerCase()} has been ${o} <b>${i}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(U),Z=J("Function"),V=J("Option"),G=(e,t,o,n)=>e.addEventListener(t,o,n||!1),X=(e,t,o)=>e.removeEventListener(t,o,!1),Y=e=>{if(!e)return"";let t=-559038744,o=1103547984;for(let n,i=0;i<e.length;i++)n=e.codePointAt(i),t=Math.imul(t^n,2246822519),o=Math.imul(o^n,3266489917);return t^=Math.imul(t^o>>>15,1935289751),o^=Math.imul(o^t>>>15,3405138345),t^=o>>>16,o^=t>>>16,(2097152*(o>>>0)+(t>>>11)).toString(36)},_=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"],K=["<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."],ee=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],te=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),oe=e=>_(K[e]),ne=e=>{const t=e[_(Q[0])]||e[_(Q[1])]||e[_(Q[2])];if(!t)return-1;const o=t.split("-");let n=function(e=""){let t=-2;const o=Y(_(e));return o in te&&(t=te[o]),t}(o[0]);return 0===n||(e=>e[2]===Y(e[0]+e[1]))(o)||(n=-2),n};function ie(e,t){const{msgTimeout:o,warningTimeout:n}=t[e];n&&(o&&clearTimeout(o),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{ready:o,loadErrorShown:n}=t[e];t[e].msgTimeout=void 0,o||n||(t[e].loadErrorShown=!0,function(e,t){const{iframe:o,waitForLoad:n}=t[e],{sandbox:i}=o,r="object"==typeof i&&i.length>0&&!(i.contains("allow-scripts")&&i.contains("allow-same-origin"));H(e,"noResponse"),U(e,`<rb>No response from iframe</>\n \nThe iframe (<i>${e}</>) has not responded within ${t[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${n?"\nThe <b>waitForLoad</> option is currently set to <b>'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 <b>'false'</>. \n":""}${r?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <i>'allow-same-origin'</> and <i>'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`)}(e,t))},n))}const re={},ae=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:b,inPageLinks:!1,heightCalculationMethod:"auto",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:"auto",onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof re[e.id].onInit&&(V("init()","onReady()","",e.id),re[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),se={position:null,version:m};function le(e){function t(){ge(x),he(M),$("onResized",x)}function o(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function n(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const i=e=>T.slice(T.indexOf(":")+7+e);const r=(e,t)=>(o,n)=>{const i={};var r,a;r=function(){be(`${o} (${e})`,`${e}:${t()}`,n)},i[a=n]||(r(),i[a]=requestAnimationFrame(()=>{i[a]=null}))},a=(e,t)=>()=>{let o=!1;const n=t=>()=>{re[l]?o&&o!==t||(e(t,l),o=t,requestAnimationFrame(()=>{o=!1})):s()},i=n("scroll"),r=n("resize window");function a(e,t){t(window,"scroll",i),t(window,"resize",r)}function s(){H(l,`stop${t}`),a(0,X),c.disconnect(),u.disconnect(),X(re[l].iframe,"load",s)}const l=M,c=new ResizeObserver(n("pageObserver")),u=new ResizeObserver(n("iframeObserver"));re[l]&&(re[l][`stop${t}`]=s,G(re[l].iframe,"load",s),a(0,G),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),u.observe(re[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},s=e=>()=>{e in re[M]&&(re[M][e](),delete re[M][e])},l=r("pageInfo",function(){const e=document.body.getBoundingClientRect(),t=x.iframe.getBoundingClientRect(),{scrollY:o,scrollX:n,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:o,scrollLeft:n,documentHeight:a,documentWidth:s,windowHeight:i,windowWidth:r})}),c=r("parentInfo",function(){const{iframe:e}=x,{scrollWidth:t,scrollHeight:o}=document.documentElement,{width:n,height:i,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:o},viewport:{width:n,height:i,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}})}),u=a(l,"PageInfo"),d=a(c,"ParentInfo"),f=s("stopPageInfo"),g=s("stopParentInfo");function y(e){const t=e.getBoundingClientRect();return fe(),{x:Number(t.left)+Number(se.position.x),y:Number(t.top)+Number(se.position.y)}}function b(e){const t=e?y(x.iframe):{x:0,y:0};F(M,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,p,h,p);const o=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(x,t),n=window.parentIframe||window.parentIFrame;n?function(t,o){t["scrollTo"+(e?"Offset":"")](o.x,o.y)}(n,o):function(e){se.position=e,w(M)}(o)}function w(e){const{x:t,y:o}=se.position,n=re[e]?.iframe;!1!==$("onScroll",{iframe:n,top:o,left:t,x:t,y:o})?he(e):pe()}function z(e){let t={};if(0===x.width&&0===x.height){const e=i(9).split(":");t={x:e[1],y:e[0]}}else t={x:x.width,y:x.height};$(e,{iframe:x.iframe,screenX:Number(t.x),screenY:Number(t.y),type:x.type})}const $=(e,t)=>ce(M,e,t);function j(){const{height:e,iframe:o,msg:n,type:r,width:a}=x;switch(re[M]?.firstRun&&function(){if(!re[M])return;ke(M,x.mode),re[M].firstRun=!1}(),r){case"close":de(o);break;case"message":l=i(6),$("onMessage",{iframe:x.iframe,message:JSON.parse(l)});break;case"mouseenter":z("onMouseEnter");break;case"mouseleave":z("onMouseLeave");break;case"beforeUnload":F(M,"Ready state reset"),re[M].ready=!1;break;case"autoResize":re[M].autoResize=JSON.parse(i(9));break;case"scrollBy":!function(){const e=x.width,t=x.height,o=window.parentIframe||window.parentIFrame||window;F(M,`scrollBy: x: %c${e}%c y: %c${t}`,p,h,p),o.scrollBy(e,t)}();break;case"scrollTo":b(!1);break;case"scrollToOffset":b(!0);break;case"pageInfo":u();break;case"parentInfo":d();break;case"pageInfoStop":f();break;case"parentInfoStop":g();break;case"inPageLink":!function(e){const t=e.split("#")[1]||"",o=decodeURIComponent(t);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const e=y(n);F(M,`Moving to in page link: %c#${t}`,p),se.position={x:e.x,y:e.y},w(M),window.location.hash=t}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(t)}()}(i(9));break;case"title":!function(e,t){re[t]?.syncTitle&&(re[t].iframe.title=e,F(t,`Set iframe title attribute: %c${e}`,p))}(n,M);break;case"reset":me(x);break;case"init":t(),function(e){try{re[e].sameOrigin=!!re[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){re[e].sameOrigin=!1}}(M),(s=n)!==m&&(void 0!==s||U(M,"<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")),ze=!0,$("onReady",o);break;default:if(0===a&&0===e)return void B(M,`Unsupported message received (${r}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===a||0===e)return;if(document.hidden)return;t()}var s,l}function k(e){re[e].ready||(be("iframe requested init",we(e),e),ie(e,re))}let T=e.data,x={},M=null;"[iFrameResizerChild]Ready"!==T?v===`${T}`.slice(0,13)&&T.slice(13).split(":")[0]in re&&(x=function(){const e=T.slice(13).split(":"),t=e[1]?Number(e[1]):0,i=re[e[0]]?.iframe,r=getComputedStyle(i),a={iframe:i,id:e[0],height:t+o(r)+n(r),width:Number(e[2]),type:e[3],msg:e[4]};return e[5]&&(a.mode=e[5]),a}(),M=x.id,M?(H(M,x.type),D(M,function(){!function(e){if(!re[e])throw new Error(`${x.type} No settings for ${e}. Message was: ${T}`)}(M),x.type in{true:1,false:1,undefined:1}||(re[M].ready=!0,(null!==x.iframe||(B(M,`The iframe (${x.id}) was not found.`),0))&&function(){const{origin:t,sameOrigin:o}=e;if(o)return!0;let n=re[M]?.checkOrigin;if(n&&"null"!=`${t}`&&!(n.constructor===Array?function(){let e=0,o=!1;for(;e<n.length;e++)if(n[e]===t){o=!0;break}return o}():function(){const e=re[M]?.remoteHost;return t===e}()))throw new Error(`Unexpected message received from: ${t} for ${x.iframe.id}. Message was: ${e.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&j())})()):B("","iframeResizer received messageData without id, message was: ",T)):Object.keys(re).forEach(k)}function ce(e,t,o){let n=null,i=null;if(re[e]){if(n=re[e][t],"function"!=typeof n)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{i=n(o)}catch(o){console.error(o),B(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(n,o)}return i}function ue(e){const{id:t}=e;delete re[t],delete e.iframeResizer}function de(e){const{id:t}=e;if(!1!==ce(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){B(t,e)}ce(t,"onAfterClose",t),ue(e)}}function fe(e){null===se.position&&(se.position={x:window.scrollX,y:window.scrollY})}function pe(){se.position=null}function he(e){null!==se.position&&(window.scrollTo(se.position.x,se.position.y),F(e,`Set page position: %c${se.position.x}%c, %c${se.position.y}`,p,h,p),pe())}function me(e){fe(e.id),ge(e),be("reset","reset",e.id)}function ge(e){function t(t){const n=`${e[t]}px`;e.iframe.style[t]=n,F(o,`Set ${t}: %c${n}`,p)}const{id:o}=e,{sizeHeight:n,sizeWidth:i}=re[o];n&&t("height"),i&&t("width")}A=re;const ye=e=>e.split(":").filter((e,t)=>19!==t).join(":");function be(e,t,o){function n(n){const i=e in k?ye(t):t;F(o,n,p,h,p),F(o,`Message data: %c${i}`,p)}H(o,e),re[o]&&(re[o]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:i,sameOrigin:r,targetOrigin:a}=re[o];if(r)try{return e.contentWindow.iframeChildListener(v+t),void n(`Sending message to iframe %c${o}%c via sameOrigin`)}catch(e){}n(`Sending message to iframe: %c${o}%c targetOrigin: %c${a}`),i.postMessage(v+t,a)}():B(o,`Iframe(${o}) not found`))}function we(e){const t=re[e];return[e,"8",t.sizeWidth,t.log,"32",!0,t.autoResize,t.bodyMargin,t.heightCalculationMethod,t.bodyBackground,t.bodyPadding,t.tolerance,t.inPageLinks,"child",t.widthCalculationMethod,t.mouseEvents,t.offsetHeight,t.offsetWidth,t.sizeHeight,t.license,se.version,t.mode,"",t.logExpand].join(":")}let ve=0,ze=!1,$e=!1,je=!1;function ke(t,o=-3){if($e)return;const n=Math.max(re[t].mode,o);if(n>re[t].mode&&(re[t].mode=n),n<0)throw q(t),re[t].vAdvised||U(t||"Parent",`${oe(n+2)}${oe(2)}`),re[t].vAdvised=!0,oe(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>-1&&je||function(t,o){queueMicrotask(()=>console.info(`%ciframe-resizer ${t}`,C||o<1?"font-weight: bold;":e))}(`v${m} (${(e=>_(ee[e]))(n)})`,n),n<1&&U("Parent",oe(3)),$e=!0}const Te=e=>t=>{function o(){if(re[u]){const{iframe:e}=re[u],t={close:de.bind(null,e),disconnect:ue.bind(null,e),removeListeners(){U(u,"<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize(){U(u,"<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."),be.bind(null,"Window resize","resize",u)},moveToAnchor(e){((e,t,o)=>{if(typeof e!==t)throw new TypeError(`${o} is not a ${n=t,n.charAt(0).toUpperCase()+n.slice(1)}`);var n})(e,"string","moveToAnchor(anchor) anchor"),be("Move to anchor",`moveToAnchor:${e}`,u)},sendMessage(e){be("message",`message:${e=JSON.stringify(e)}`,u)}};e.iframeResizer=t,e.iFrameResizer=t}}function n(e){const{id:o}=t,{waitForLoad:n}=re[o];G(t,"load",()=>{be($,`${e}:${ze}`,o),ie(o,re),function(){const e=re[u]?.firstRun,o=re[u]?.heightCalculationMethod in z;!e&&o&&me({iframe:t,height:0,width:0,type:"init"})}()}),!0!==n&&(be(j,`${e}:${ze}`,o),ie(o,re))}function i(e){return e?(("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&U(u,`<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 <i>"${b}"</>, <i>"${w}"</> or <i>"${y}"</>.\n`),e):{}}function r(e){const t=re[e]?.iframe?.title;return""===t||void 0===t}function a(e,t){R(re[u],e)&&(U(u,`<rb>Deprecated option</>\n\nThe <b>${e}</> option has been renamed to <b>${t}</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`),re[u][t]=re[u][e],delete re[u][e])}const s=e=>R(e,"onMouseEnter")||R(e,"onMouseLeave");function l(e){var o,n;re[u]={...re[u],iframe:t,firstRun:!0,remoteHost:t?.src.split("/").slice(0,3).join("/"),...ae,...i(e),mouseEvents:s(e),mode:ne(e),syncTitle:r(u)},a("offset","offsetSize"),a("onClose","onBeforeClose"),a("onClosed","onAfterClose"),H(u,"setup"),function(){const{direction:e}=re[u];switch(e){case b:break;case w:re[u].sizeHeight=!1;case"both":re[u].sizeWidth=!0;break;case y:re[u].sizeWidth=!1,re[u].sizeHeight=!1,re[u].autoResize=!1;break;default:throw new TypeError(u,`Direction value of "${e}" is not valid`)}}(),(o=e?.offsetSize||e?.offset)&&(re[u].direction===b?re[u].offsetHeight=o:re[u].offsetWidth=o),function(e){e?.offset&&U(u,"<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.")}(e),re[u].warningTimeout||F(u,"warningTimeout:%c disabled",p),null===re[u].postMessageTarget&&(re[u].postMessageTarget=t.contentWindow),re[u].targetOrigin=!0===re[u].checkOrigin?""===(n=re[u].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}const c=()=>"iframeResizer"in t,u=function(o){if(o&&"string"!=typeof o)throw new TypeError("Invalid id for iFrame. Expected String");return""!==o&&o||(o=function(){let t=e?.id||ae.id+ve++;return null!==document.getElementById(t)&&(t+=ve++),t}(),t.id=o),o}(t.id);if("object"!=typeof e)throw new TypeError("Options is not an object");return function(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=T,e.logExpand=!t.includes("ifrlog=collapsed"))}(e),function(e,t){const o=R(t,"log"),n="string"==typeof t.log,i=o?!!n||t.log:ae.log;R(t,"logExpand")||(t.logExpand=o&&n?t.log===T:ae.logExpand),function(e){-1===e?.log&&(e.log=!1,je=!0)}(t),function({enabled:e,expand:t,iframeId:o}){const n=O({expand:t,label:W(o)});C=e,A[o]||(A[o]={console:n})}({enabled:i,expand:t.logExpand,iframeId:e}),n&&!(t.log in M)&&P(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=i}(u,e),D(u,function(e){c()?B(u,`Ignored iframe (${u}), already setup.`):(l(e),function(){if($e)return;const{mode:e}=re[u];-1!==e&&ke(u,e)}(),Me(),function(){switch(t.style.overflow=!1===re[u]?.scrolling?"hidden":"auto",re[u]?.scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=re[u]?re[u].scrolling:"no"}}(),function(){const{bodyMargin:e}=re[u];"number"!=typeof e&&"0"!==e||(re[u].bodyMargin=`${e}px`)}(),n(we(u)),o())})(e),t?.iframeResizer};function xe(){!1===document.hidden&&function(e,t){const o=e=>re[e]?.autoResize&&!re[e]?.firstRun;Object.keys(re).forEach(function(n){o(n)&&be(e,t,n)})}("tabVisible","resize")}const Me=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{G(window,"message",le),G(document,"visibilitychange",xe),window.iframeParentListener=e=>setTimeout(()=>le({data:e,sameOrigin:!0}))}),Ee=`[${g}] `;const Re=function(){function e(e){switch(!0){case!e:throw new TypeError(`${Ee}iframe is not defined`);case!e.tagName:throw new TypeError(`${Ee}Not a valid DOM element`);case"IFRAME"!==e.tagName.toUpperCase():throw new TypeError(`${Ee}Expected <IFRAME> tag, found <${e.tagName}>`);default:t(e),o.push(e)}}let t,o;return function(n,i){if("undefined"==typeof window)return[];switch(t=Te(n),o=[],typeof i){case"undefined":case"string":document.querySelectorAll(i||"iframe").forEach(e);break;case"object":e(i);break;default:throw new TypeError(`${Ee}Unexpected data type (${typeof i})`)}return Object.freeze(o)}}();return"undefined"!=typeof window&&(window.iFrameResize=window.iFrameResize||function(...e){Z("iFrameResize()","iframeResize()","","parent"),Re(...e)}),Re});