UNPKG

iframe-resizer

Version:

Keep iframes sized to their content.

21 lines (18 loc) 22.6 kB
/*! * @preserve * * @module iframe-resizer/legacy (parent) 5.5.1 (umd) - 2025-08-01 * * @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;",n="default",o=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(n){e[t]=n}],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.1",g="iframeResizer",y="none",w="vertical",b="horizontal",v="[iFrameSizer]",z=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),$="onload",j="init",k=Object.freeze({[$]:1,[j]:1}),x="expanded",T="collapsed",M=Object.freeze({[x]:1,[T]: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)),O=e=>e,R=(S=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 w=()=>!!p.some(([e])=>e in o)||!!h.expand;function b(){if(0!==p.length){a[w()?"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,n)=>e[t]().toString().padStart(n,"0");return`@ ${t("getHours",2)}:${t("getMinutes",2)}:${t("getSeconds",2)}.${t("getMilliseconds",3)}`}())}function z(e,...t){0===p.length&&(v(),queueMicrotask(()=>queueMicrotask(b))),p.push([e,...t])}function $(e=n,...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=n){f[e]?f[e]+=1:f[e]=1,z("log",`${e}: ${f[e]}`)},countReset:function(e=n){delete f[e]},endAutoGroup:b,errorBoundary:e=>(...t)=>{let n;try{n=e(...t)}catch(e){if(!Error.prototype.isPrototypeOf(e))throw e;z("error",e),b()}return n},event:function(e){v(),h.event=e},purge:g,time:function(e=n){v(),l[e]=performance.now()},timeEnd:function(e=n){$(e),delete l[e]},timeLog:$,touch:v}},S?.__esModule?S.default:S);var S;let I={},A=!1;const C=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const W=e=>(t,...n)=>I[t]?.console[e](...n);var L;const N=(L="log",(e,...t)=>!0===(e=>I[e]?I[e].log:A)(e)?W(L)(e,...t):null),F=W("warn"),B=W("error"),H=W("event"),P=W("purge"),q=W("errorBoundary");const D=(e,...t)=>I[e]?I[e].console.warn(E(O)(...t)):queueMicrotask(()=>console?.warn(E((e=>(...t)=>[`${g}(${e})`,...t].join(" "))(e))(...t))),U=(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</>.`))(D),J=U("Function"),Z=U("Option"),V=(e,t,n,o)=>e.addEventListener(t,n,o||!1),G=(e,t,n)=>e.removeEventListener(t,n,!1),X=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)},Y=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),_=["spjluzl","rlf","clyzpvu"],Q=["<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."],K=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],ee=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),te=e=>Y(Q[e]),ne=e=>{const t=e[Y(_[0])]||e[Y(_[1])]||e[Y(_[2])];if(!t)return-1;const n=t.split("-");let o=function(e=""){let t=-2;const n=X(Y(e));return n in ee&&(t=ee[n]),t}(n[0]);return 0===o||(e=>e[2]===X(e[0]+e[1]))(n)||(o=-2),o};function oe(e,t){const{warningTimeout:n}=t[e];0!==n&&(t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{loaded:n,loadErrorShown:o}=t[e];n||o||(t[e].loadErrorShown=!0,function(e,t){const{iframe:n,waitForLoad:o}=t[e],{sandbox:i}=n,r="object"==typeof i&&i.length>0&&!(i.contains("allow-scripts")&&i.contains("allow-same-origin"));D(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${o?"\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 ie={},re=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:w,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 ie[e.id].onInit&&(Z("init()","onReady()","",e.id),ie[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),ae={position:null,version:m};function se(e){function t(){me(x),pe(T),$("onResized",x)}function n(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function o(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=>k.slice(k.indexOf(":")+7+e);const r=(e,t)=>(n,o)=>{const i={};var r,a;r=function(){ye(`${n} (${e})`,`${e}:${t()}`,o)},i[a=o]||(r(),i[a]=requestAnimationFrame(()=>{i[a]=null}))},a=(e,t)=>()=>{let n=!1;const o=t=>()=>{ie[l]?n&&n!==t||(e(t,l),n=t,requestAnimationFrame(()=>{n=!1})):s()},i=o("scroll"),r=o("resize window");function a(e,t){t(window,"scroll",i),t(window,"resize",r)}function s(){H(l,`stop${t}`),a(0,G),c.disconnect(),u.disconnect(),G(ie[l].iframe,"load",s)}const l=T,c=new ResizeObserver(o("pageObserver")),u=new ResizeObserver(o("iframeObserver"));ie[l]&&(ie[l][`stop${t}`]=s,V(ie[l].iframe,"load",s),a(0,V),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),u.observe(ie[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},s=e=>()=>{e in ie[T]&&(ie[T][e](),delete ie[T][e])},l=r("pageInfo",function(){const e=document.body.getBoundingClientRect(),t=x.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})}),c=r("parentInfo",function(){const{iframe:e}=x,{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}})}),u=a(l,"PageInfo"),d=a(c,"ParentInfo"),f=s("stopPageInfo"),g=s("stopParentInfo");function y(e){const t=e.getBoundingClientRect();return de(),{x:Number(t.left)+Number(ae.position.x),y:Number(t.top)+Number(ae.position.y)}}function w(e){const t=e?y(x.iframe):{x:0,y:0};N(T,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,p,h,p);const n=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(x,t),o=window.parentIframe||window.parentIFrame;o?function(t,n){t["scrollTo"+(e?"Offset":"")](n.x,n.y)}(o,n):function(e){ae.position=e,b(T)}(n)}function b(e){const{x:t,y:n}=ae.position,o=ie[e]?.iframe;!1!==$("onScroll",{iframe:o,top:n,left:t,x:t,y:n})?pe(e):fe()}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)=>le(T,e,t);function j(){const{height:e,iframe:n,msg:o,type:r,width:a}=x;switch(ie[T]?.firstRun&&function(){if(!ie[T])return;je(T,x.mode),ie[T].firstRun=!1}(),r){case"close":ue(n);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"autoResize":ie[T].autoResize=JSON.parse(i(9));break;case"scrollBy":!function(){const e=x.width,t=x.height,n=window.parentIframe||window.parentIFrame||window;N(T,`scrollBy: x: %c${e}%c y: %c${t}`,p,h,p),n.scrollBy(e,t)}();break;case"scrollTo":w(!1);break;case"scrollToOffset":w(!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]||"",n=decodeURIComponent(t);let o=document.getElementById(n)||document.getElementsByName(n)[0];o?function(){const e=y(o);N(T,`Moving to in page link: %c#${t}`,p),ae.position={x:e.x,y:e.y},b(T),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){ie[t]?.syncTitle&&(ie[t].iframe.title=e,N(t,`Set iframe title attribute: %c${e}`,p))}(o,T);break;case"reset":he(x);break;case"init":t(),function(e){try{ie[e].sameOrigin=!!ie[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){ie[e].sameOrigin=!1}}(T),(s=o)!==m&&(void 0!==s||D(T,"<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")),ve=!0,$("onReady",n);break;default:if(0===a&&0===e)return void F(T,`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}let k=e.data,x={},T=null;"[iFrameResizerChild]Ready"!==k?v===`${k}`.slice(0,13)&&k.slice(13).split(":")[0]in ie&&(x=function(){const e=k.slice(13).split(":"),t=e[1]?Number(e[1]):0,i=ie[e[0]]?.iframe,r=getComputedStyle(i),a={iframe:i,id:e[0],height:t+n(r)+o(r),width:Number(e[2]),type:e[3],msg:e[4]};return e[5]&&(a.mode=e[5]),a}(),T=x.id,T?(H(T,x.type),q(T,function(){!function(e){if(!ie[e])throw new Error(`${x.type} No settings for ${e}. Message was: ${k}`)}(T),x.type in{}||(ie[T].loaded=!0,(null!==x.iframe||(F(T,`The iframe (${x.id}) was not found.`),0))&&function(){const{origin:t,sameOrigin:n}=e;if(n)return!0;let o=ie[T]?.checkOrigin;if(o&&"null"!=`${t}`&&!(o.constructor===Array?function(){let e=0,n=!1;for(;e<o.length;e++)if(o[e]===t){n=!0;break}return n}():function(){const e=ie[T]?.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())})()):F("","iframeResizer received messageData without id, message was: ",k)):Object.keys(ie).forEach(e=>{ye("iFrame requested init",we(e),e)})}function le(e,t,n){let o=null,i=null;if(ie[e]){if(o=ie[e][t],"function"!=typeof o)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),F(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(o,n)}return i}function ce(e){const{id:t}=e;delete ie[t],delete e.iframeResizer}function ue(e){const{id:t}=e;if(!1!==le(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){F(t,e)}le(t,"onAfterClose",t),ce(e)}}function de(e){null===ae.position&&(ae.position={x:window.scrollX,y:window.scrollY})}function fe(){ae.position=null}function pe(e){null!==ae.position&&(window.scrollTo(ae.position.x,ae.position.y),N(e,`Set page position: %c${ae.position.x}%c, %c${ae.position.y}`,p,h,p),fe())}function he(e){de(e.id),me(e),ye("reset","reset",e.id)}function me(e){function t(t){const o=`${e[t]}px`;e.iframe.style[t]=o,N(n,`Set ${t}: %c${o}`,p)}const{id:n}=e,{sizeHeight:o,sizeWidth:i}=ie[n];o&&t("height"),i&&t("width")}I=ie;const ge=e=>e.split(":").filter((e,t)=>19!==t).join(":");function ye(e,t,n){function o(o){const i=e in k?ge(t):t;N(n,o,p,h,p),N(n,`Message data: %c${i}`,p)}H(n,e),ie[n]&&(ie[n]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:i,sameOrigin:r,targetOrigin:a}=ie[n];if(r)try{return e.contentWindow.iframeChildListener(v+t),void o(`Sending message to iframe %c${n}%c via sameOrigin`)}catch(e){}o(`Sending message to iframe: %c${n}%c targetOrigin: %c${a}`),i.postMessage(v+t,a)}():F(n,`Iframe(${n}) not found`))}function we(e){const t=ie[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,ae.version,t.mode,"",t.logExpand].join(":")}let be=0,ve=!1,ze=!1,$e=!1;function je(t,n=-3){if(ze)return;const o=Math.max(ie[t].mode,n);if(o>ie[t]&&(ie[t].mode=o),o<0)throw P(t),ie[t].vAdvised||D(t||"Parent",`${te(o+2)}${te(2)}`),ie[t].vAdvised=!0,te(o+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");o>-1&&$e||function(t,n){queueMicrotask(()=>console.info(`%ciframe-resizer ${t}`,A||n<1?"font-weight: bold;":e))}(`v${m} (${(e=>Y(K[e]))(o)})`,o),o<1&&D("Parent",te(3)),ze=!0}const ke=e=>t=>{function n(){if(ie[u]){const{iframe:e}=ie[u],t={close:ue.bind(null,e),disconnect:ce.bind(null,e),removeListeners(){D(u,"<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize(){D(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."),ye.bind(null,"Window resize","resize",u)},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,"string","moveToAnchor(anchor) anchor"),ye("Move to anchor",`moveToAnchor:${e}`,u)},sendMessage(e){ye("message",`message:${e=JSON.stringify(e)}`,u)}};e.iframeResizer=t,e.iFrameResizer=t}}function o(e){const{id:n}=t,{waitForLoad:o}=ie[n];oe(n,ie),V(t,"load",function(){ye($,`${e}:${ve}`,n),function(){const e=ie[u]?.firstRun,n=ie[u]?.heightCalculationMethod in z;!e&&n&&he({iframe:t,height:0,width:0,type:"init"})}()}),!1===o&&ye(j,`${e}:${ve}`,n)}function i(e){return e?(("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&D(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>"${w}"</>, <i>"${b}"</> or <i>"${y}"</>.\n`),e):{}}function r(e){const t=ie[e]?.iframe?.title;return""===t||void 0===t}function a(e,t){Object.hasOwn(ie[u],e)&&(D(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</>.`),ie[u][t]=ie[u][e],delete ie[u][e])}const s=e=>Object.hasOwn(e,"onMouseEnter")||Object.hasOwn(e,"onMouseLeave");function l(e){var n,o;ie[u]={...ie[u],iframe:t,firstRun:!0,remoteHost:t?.src.split("/").slice(0,3).join("/"),...re,...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}=ie[u];switch(e){case w:break;case b:ie[u].sizeHeight=!1;case"both":ie[u].sizeWidth=!0;break;case y:ie[u].sizeWidth=!1,ie[u].sizeHeight=!1,ie[u].autoResize=!1;break;default:throw new TypeError(u,`Direction value of "${e}" is not valid`)}}(),(n=e?.offsetSize||e?.offset)&&(ie[u].direction===w?ie[u].offsetHeight=n:ie[u].offsetWidth=n),e?.offset&&D(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</>."),null===ie[u].postMessageTarget&&(ie[u].postMessageTarget=t.contentWindow),ie[u].targetOrigin=!0===ie[u].checkOrigin?""===(o=ie[u].remoteHost)||null!==o.match(/^(about:blank|javascript:|file:\/\/)/)?"*":o:"*"}const c=()=>"iframeResizer"in t,u=function(n){if(n&&"string"!=typeof n)throw new TypeError("Invalid id for iFrame. Expected String");return""!==n&&n||(n=function(){let t=e?.id||re.id+be++;return null!==document.getElementById(t)&&(t+=be++),t}(),t.id=n),n}(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=x,e.logExpand=!t.includes("ifrlog=collapsed"))}(e),function(e,t){const n=Object.hasOwn(t,"log"),o="string"==typeof t.log,i=n?!!o||t.log:re.log;Object.hasOwn(t,"logExpand")||(t.logExpand=n&&o?t.log===x:re.logExpand),function(e){-1===e?.log&&(e.log=!1,$e=!0)}(t),function({enabled:e,expand:t,iframeId:n}){const o=R({expand:t,label:C(n)});A=e,I[n]||(I[n]={console:o})}({enabled:i,expand:t.logExpand,iframeId:e}),o&&!(t.log in M)&&B(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=i}(u,e),q(u,function(e){c()?F(u,`Ignored iframe (${u}), already setup.`):(l(e),function(){if(ze)return;const{mode:e}=ie[u];-1!==e&&je(u,e)}(),Te(),function(){switch(t.style.overflow=!1===ie[u]?.scrolling?"hidden":"auto",ie[u]?.scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=ie[u]?ie[u].scrolling:"no"}}(),function(){const{bodyMargin:e}=ie[u];"number"!=typeof e&&"0"!==e||(ie[u].bodyMargin=`${e}px`)}(),o(we(u)),n())})(e),t?.iframeResizer};function xe(){!1===document.hidden&&function(e,t){const n=e=>ie[e]?.autoResize&&!ie[e]?.firstRun;Object.keys(ie).forEach(function(o){n(o)&&ye(e,t,o)})}("Tab Visible","resize")}const Te=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{V(window,"message",se),V(document,"visibilitychange",xe),window.iframeParentListener=e=>setTimeout(()=>se({data:e,sameOrigin:!0}))}),Me=`[${g}] `;const Ee=function(){function e(e){switch(!0){case!e:throw new TypeError(`${Me}iframe is not defined`);case!e.tagName:throw new TypeError(`${Me}Not a valid DOM element`);case"IFRAME"!==e.tagName.toUpperCase():throw new TypeError(`${Me}Expected <IFRAME> tag, found <${e.tagName}>`);default:t(e),n.push(e)}}let t,n;return function(o,i){if("undefined"==typeof window)return[];switch(t=ke(o),n=[],typeof i){case"undefined":case"string":document.querySelectorAll(i||"iframe").forEach(e);break;case"object":e(i);break;default:throw new TypeError(`${Me}Unexpected data type (${typeof i})`)}return Object.freeze(n)}}();return"undefined"!=typeof window&&(window.iFrameResize=window.iFrameResize||function(...e){J("iFrameResize()","iframeResize()","","parent"),Ee(...e)}),Ee});