@iframe-resizer/core 5.5.6 → 5.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,4 +25,4 @@ yarn add @iframe-resizer/core
25
25
 
26
26
  ---
27
27
 
28
- _iframe-resizer version 5.5.6 2025-09-10 - 16:04:48.965Z_
28
+ _iframe-resizer version 5.5.7 2025-09-23 - 09:33:32.779Z_
package/index.cjs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/core 5.5.6 (cjs) - 2025-09-10
4
+ * @module iframe-resizer/core 5.5.7 (cjs) - 2025-09-23
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
@@ -17,4 +17,4 @@
17
17
  */
18
18
 
19
19
 
20
- "use strict";const e=require("auto-console-group"),t="5.5.6",i="iframeResizer",o="autoResize",n="init",r="iframeReady",s="load",a="message",l="onload",c="pageInfo",d="parentInfo",u="reset",f="resize",p="scroll",h="none",m="vertical",g="horizontal",y="[iFrameSizer]",b=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),v=Object.freeze({[l]:1,[n]:1,[r]:1}),w="expanded",z="collapsed",T=Object.freeze({[w]:1,[z]:1}),j=(e,t,i,o)=>e.addEventListener(t,i,o||!1),$=(e,t,i)=>e.removeEventListener(t,i,!1),I=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),t=Math.imul(t^o,2246822519),i=Math.imul(i^o,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},k=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),H=["spjluzl","rlf","clyzpvu"],x=["<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."],M=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],R=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),O=e=>k(x[e]),L=e=>{const t=e[k(H[0])]||e[k(H[1])]||e[k(H[2])];if(!t)return-1;const i=t.split("-");let o=function(e=""){let t=-2;const i=I(k(e));return i in R&&(t=R[i]),t}(i[0]);return 0===o||(e=>e[2]===I(e[0]+e[1]))(i)||(o=-2),o},S=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),E=e=>e,C=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)),W={},A=(N=e,N?.__esModule?N.default:N);var N;let G=!0;const B=A({expand:!1,label:"parent"}),F=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const P=e=>(t,...i)=>W[t]?W[t].console[e](...i):B[e](...i);var D;const U=(D="log",(e,...t)=>!0===(e=>W[e]?W[e].log:G)(e)?P(D)(e,...t):null),q=P("warn"),J=P("error"),Z=P("event"),V=P("purge"),X=P("errorBoundary");const Y=(e,...t)=>W[e]?W[e].console.warn(C(E)(...t)):queueMicrotask(()=>console?.warn(C((e=>(...t)=>[`${i}(${e})`,...t].join(" "))(e))(...t))),_=(e=>(t,i="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${i} <b>${n}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(Y),K=_("Option");function Q(e,t){const{msgTimeout:i,warningTimeout:o}=t[e];o&&(i&&clearTimeout(i),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{initialised:i,loadErrorShown:o}=t[e];t[e].msgTimeout=void 0,i||o||(t[e].loadErrorShown=!0,function(e,t){const{iframe:i,waitForLoad:o}=t[e],{sandbox:n}=i,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));Z(e,"noResponse"),Y(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))},o))}const ee=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:m,firstRun:!0,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 W[e.id].onInit&&(K("init()","onReady()","",e.id),W[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),te={position:null,version:t};function ie(i){function r(){de(N),le(F),L("onResized",N)}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=>C.slice(C.indexOf(":")+7+e);const g=(e,t)=>(i,o)=>{const n={};var r,s;r=function(){fe(`${i} (${e})`,`${e}:${t()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},b=(e,t)=>()=>{let i=!1;const o=t=>()=>{W[c]?i&&i!==t||(e(t,c),i=t,requestAnimationFrame(()=>{i=!1})):l()},n=o(p),r=o("resize window");function a(e,t){t(window,p,n),t(window,f,r)}function l(){Z(c,`stop${t}`),a(0,$),d.disconnect(),u.disconnect(),$(W[c].iframe,s,l)}const c=F,d=new ResizeObserver(o("pageObserver")),u=new ResizeObserver(o("iframeObserver"));W[c]&&(W[c][`stop${t}`]=l,j(W[c].iframe,s,l),a(0,j),d.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),u.observe(W[c].iframe,{attributes:!0,childList:!1,subtree:!1}))},v=e=>()=>{e in W[F]&&(W[F][e](),delete W[F][e])},w=g(c,function(){const e=document.body.getBoundingClientRect(),t=N.iframe.getBoundingClientRect(),{scrollY:i,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),z=g(d,function(){const{iframe:e}=N,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),T=b(w,"PageInfo"),I=b(z,"ParentInfo"),k=v("stopPageInfo"),H=v("stopParentInfo");function x(e){const t=e.getBoundingClientRect();return se(),{x:Number(t.left)+Number(te.position.x),y:Number(t.top)+Number(te.position.y)}}function M(t){const i=t?x(N.iframe):{x:0,y:0};U(F,`Reposition requested (offset x:%c${i.x}%c y:%c${i.y})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT);const o=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(N,i),n=window.parentIframe||window.parentIFrame;n?function(e,i){setTimeout(()=>e["scrollTo"+(t?"Offset":"")](i.x,i.y))}(n,o):function(e){te.position=e,R(F)}(o)}function R(e){const{x:t,y:i}=te.position,o=W[e]?.iframe;!1!==L("onScroll",{iframe:o,top:i,left:t,x:t,y:i})?le(e):ae()}function O(e){let t={};if(0===N.width&&0===N.height){const e=m(9).split(":");t={x:e[1],y:e[0]}}else t={x:N.width,y:N.height};L(e,{iframe:N.iframe,screenX:Number(t.x),screenY:Number(t.y),type:N.type})}const L=(e,t)=>oe(F,e,t);function S(){const{height:i,iframe:s,msg:l,type:f,width:p}=N;switch(W[F]?.firstRun&&function(){if(!W[F])return;ge(F,N.mode),W[F].firstRun=!1}(),f){case"close":re(s);break;case a:g=m(6),L("onMessage",{iframe:N.iframe,message:JSON.parse(g)});break;case"mouseenter":O("onMouseEnter");break;case"mouseleave":O("onMouseLeave");break;case"beforeUnload":U(F,"Ready state reset"),W[F].initialised=!1;break;case o:W[F].autoResize=JSON.parse(m(9));break;case"scrollBy":!function(){const t=N.width,i=N.height,o=window.parentIframe||window.parentIFrame||window;U(F,`scrollBy: x: %c${t}%c y: %c${i}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),o.scrollBy(t,i)}();break;case"scrollTo":M(!1);break;case"scrollToOffset":M(!0);break;case c:T();break;case d:I();break;case"pageInfoStop":k();break;case"parentInfoStop":H();break;case"inPageLink":!function(t){const i=t.split("#")[1]||"",o=decodeURIComponent(i);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const t=x(n);U(F,`Moving to in page link: %c#${i}`,e.HIGHLIGHT),te.position={x:t.x,y:t.y},R(F),window.location.hash=i}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(i)}()}(m(9));break;case"title":!function(t,i){W[i]?.syncTitle&&(W[i].iframe.title=t,U(i,`Set iframe title attribute: %c${t}`,e.HIGHLIGHT))}(l,F);break;case u:ce(N);break;case n:r(),function(e){try{W[e].sameOrigin=!!W[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){W[e].sameOrigin=!1}}(F),(h=l)!==t&&(void 0!==h||Y(F,"<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")),W[F].initialised=!0,L("onReady",s);break;default:if(0===p&&0===i)return void q(F,`Unsupported message received (${f}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===p||0===i)return;if(document.hidden)return;r()}var h,g}function E(e){if(!W[e])throw new Error(`${N.type} No settings for ${e}. Message was: ${C}`)}let C=i.data;if("[iFrameResizerChild]Ready"===C)return A=i.source,void Object.values(W).forEach((e=>({initChild:t,initialised:i,postMessageTarget:o})=>{i||e!==o||t()})(A));var A;if(!(e=>y===`${e}`.slice(0,13)&&e.slice(13).split(":")[0]in W)(C)){if("string"!=typeof C)return;return void Z("parent","ignoredMessage")}const N=function(e){const t=e.slice(13).split(":"),i=t[1]?Number(t[1]):0,o=W[t[0]]?.iframe,n=getComputedStyle(o),r={iframe:o,id:t[0],height:i+l(n)+h(n),width:Number(t[2]),type:t[3],msg:t[4]};return t[5]&&(r.mode=t[5]),r}(C),{id:G,type:B}=N,F=G;F?(Z(F,B),X(F,function(e){E(F),N.type in{true:1,false:1,undefined:1}||(null!==N.iframe||(q(F,`The iframe (${N.id}) was not found.`),0))&&function(){const{origin:e,sameOrigin:t}=i;if(t)return!0;let o=W[F]?.checkOrigin;if(o&&"null"!=`${e}`&&!(o.constructor===Array?function(){let t=0,i=!1;for(;t<o.length;t++)if(o[t]===e){i=!0;break}return i}():function(){const t=W[F]?.remoteHost;return e===t}()))throw new Error(`Unexpected message received from: ${e} for ${N.iframe.id}. Message was: ${i.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&S()})(C)):q("","iframeResizer received messageData without id, message was: ",C)}function oe(e,t,i){let o=null,n=null;if(W[e]){if(o=W[e][t],"function"!=typeof o)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{n=o(i)}catch(i){console.error(i),q(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(o,i)}return n}function ne(e){const{id:t}=e;delete W[t],delete e.iframeResizer}function re(e){const{id:t}=e;if(!1!==oe(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){q(t,e)}oe(t,"onAfterClose",t),ne(e)}}function se(e){null===te.position&&(te.position={x:window.scrollX,y:window.scrollY})}function ae(){te.position=null}function le(t){null!==te.position&&(window.scrollTo(te.position.x,te.position.y),U(t,`Set page position: %c${te.position.x}%c, %c${te.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),ae())}function ce(e){se(e.id),de(e),fe(u,u,e.id)}function de(t){function i(i){const n=`${t[i]}px`;t.iframe.style[i]=n,U(o,`Set ${i}: %c${n}`,e.HIGHLIGHT)}const{id:o}=t,{sizeHeight:n,sizeWidth:r}=W[o];n&&i("height"),r&&i("width")}const ue=e=>e.split(":").filter((e,t)=>19!==t).join(":");function fe(t,i,o){function n(n){const r=t in v?ue(i):i;U(o,n,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),U(o,`Message data: %c${r}`,e.HIGHLIGHT)}Z(o,t),W[o]&&(W[o]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:r,sameOrigin:s,targetOrigin:a}=W[o];if(s)try{return e.contentWindow.iframeChildListener(y+i),void n(`Sending message to iframe %c${o}%c via same origin%c`)}catch(e){t in v?W[o].sameOrigin=!1:q(o,"Same origin messaging failed, falling back to postMessage")}n(`Sending message to iframe: %c${o}%c targetOrigin: %c${a}`),r.postMessage(y+i,a)}():q(o,`Iframe(${o}) not found`))}let pe=0,he=!1,me=!1;function ge(i,o=-3){if(he)return;const n=Math.max(W[i].mode,o);if(n>W[i].mode&&(W[i].mode=n),n<0)throw V(i),W[i].vAdvised||Y(i||"Parent",`${O(n+2)}${O(2)}`),W[i].vAdvised=!0,O(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>0&&me||function(t,i){queueMicrotask(()=>console.info(`%ciframe-resizer ${t}`,G||i<1?"font-weight: bold;":e.NORMAL))}(`v${t} (${(e=>k(M[e]))(n)})`,n),n<1&&Y("Parent",O(3)),he=!0}function ye(){!0!==document.hidden&&((e,t)=>{Object.values(W).filter(({autoResize:e,firstRun:t})=>e&&!t).forEach(({iframe:i})=>fe(e,t,i.id))})("tabVisible",f)}const be=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{j(window,a,ie),j(document,"visibilitychange",ye),window.iframeParentListener=e=>setTimeout(()=>ie({data:e,sameOrigin:!0}))});module.exports=t=>c=>{function d(){if(W[H]){const{iframe:e}=W[H],t={close:re.bind(null,e),disconnect:ne.bind(null,e),removeListeners(){Y(H,"<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize(){Y(H,"<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."),fe.bind(null,"Window resize",f,H)},moveToAnchor(e){((e,t,i)=>{if(typeof e!==t)throw new TypeError(`${i} is not a ${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,"string","moveToAnchor(anchor) anchor"),fe("Move to anchor",`moveToAnchor:${e}`,H)},sendMessage(e){e=JSON.stringify(e),fe(a,`${a}:${e}`,H)}};e.iframeResizer=t,e.iFrameResizer=t}}function u(e,t){const{waitForLoad:i}=W[e],o=i=>()=>{W[e]&&!0!==W[e].initialised&&(fe(i,t,e),Q(e,W),W[e].firstRun||W[H]?.heightCalculationMethod in b&&ce({iframe:c,height:1,width:1,type:n}))},a=o(l);j(c,s,()=>setTimeout(a,1)),W[e].initChild=o(r),!0!==i&&((e=>{const{src:t,srcdoc:i}=e;return!i&&(null==t||""===t||"about:blank"===t)})(c)?setTimeout(()=>{Z(e,"noContent"),U(e,"No content detected in the iframe, delaying initialisation")}):setTimeout(o(n)))}function p(e){return e?(("sizeWidth"in e||"sizeHeight"in e||o in e)&&Y(H,`<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>"${m}"</>, <i>"${g}"</> or <i>"${h}"</>.\n`),e):{}}function y(e){const t=W[e]?.iframe?.title;return""===t||void 0===t}function v(e,t){S(W[H],e)&&(Y(H,`<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</>.`),W[H][t]=W[H][e],delete W[H][e])}const $=e=>S(e,"onMouseEnter")||S(e,"onMouseLeave");function I(t){var i,o;W[H]={...W[H],iframe:c,remoteHost:c?.src.split("/").slice(0,3).join("/"),...ee,...p(t),mouseEvents:$(t),mode:L(t),syncTitle:y(H)},v("offset","offsetSize"),v("onClose","onBeforeClose"),v("onClosed","onAfterClose"),Z(H,"setup"),function(){const{direction:e}=W[H];switch(e){case m:break;case g:W[H].sizeHeight=!1;case"both":W[H].sizeWidth=!0;break;case h:W[H].sizeWidth=!1,W[H].sizeHeight=!1,W[H].autoResize=!1;break;default:throw new TypeError(H,`Direction value of "${e}" is not valid`)}}(),(i=t?.offsetSize||t?.offset)&&(W[H].direction===m?W[H].offsetHeight=i:W[H].offsetWidth=i),function(e){e?.offset&&Y(H,"<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</>.")}(t),W[H].warningTimeout||U(H,"warningTimeout:%c disabled",e.HIGHLIGHT),null===W[H].postMessageTarget&&(W[H].postMessageTarget=c.contentWindow),W[H].targetOrigin=!0===W[H].checkOrigin?""===(o=W[H].remoteHost)||null!==o.match(/^(about:blank|javascript:|file:\/\/)/)?"*":o:"*"}const k=()=>i in c,H=function(e){if(e&&"string"!=typeof e)throw new TypeError("Invalid id for iFrame. Expected String");return""!==e&&e||(e=function(){let e=t?.id||ee.id+pe++;return null!==document.getElementById(e)&&(e+=pe++),e}(),c.id=e,Z(e,"assignId")),e}(c.id);if("object"!=typeof t)throw new TypeError("Options is not an object");return function(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=z,e.logExpand=t.includes("ifrlog=expanded"))}(t),function(e,t){const i=S(t,"log"),o="string"==typeof t.log,n=i?!!o||t.log:ee.log;S(t,"logExpand")||(t.logExpand=i&&o?t.log===w:ee.logExpand),function(e){-1===e?.log&&(e.log=!1,me=!0)}(t),function({enabled:e,expand:t,iframeId:i}){const o=A({expand:t,label:F(i)});G=e,W[i]||(W[i]={console:o})}({enabled:n,expand:t.logExpand,iframeId:e}),o&&!(t.log in T)&&J(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=n}(H,t),X(H,function(e){k()?q(H,`Ignored iframe (${H}), already setup.`):(I(e),function(){if(he)return;const{mode:e}=W[H];-1!==e&&ge(H,e)}(),be(),function(){switch(c.style.overflow=!1===W[H]?.scrolling?"hidden":"auto",W[H]?.scrolling){case"omit":break;case!0:c.scrolling="yes";break;case!1:c.scrolling="no";break;default:c.scrolling=W[H]?W[H].scrolling:"no"}}(),function(){const{bodyMargin:e}=W[H];"number"!=typeof e&&"0"!==e||(W[H].bodyMargin=`${e}px`)}(),u(H,function(e){const t=W[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,te.version,t.mode,"",t.logExpand].join(":")}(H)),d())})(t),c?.iframeResizer};
20
+ "use strict";const e=require("auto-console-group"),t="5.5.7",i="iframeResizer",o=":",n="autoResize",r="init",s="iframeReady",a="load",l="message",c="onload",u="pageInfo",d="parentInfo",f="reset",p="resize",h="scroll",m="child",g="parent",y="string",b="object",v="function",z="auto",w="none",j="vertical",T="horizontal",$="[iFrameSizer]",I=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),k=Object.freeze({[c]:1,[r]:1,[s]:1}),H="expanded",x="collapsed",M=Object.freeze({[H]:1,[x]:1}),R=(e,t,i,o)=>e.addEventListener(t,i,o||!1),O=(e,t,i)=>e.removeEventListener(t,i,!1),L=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),t=Math.imul(t^o,2246822519),i=Math.imul(i^o,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},S=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),E=["spjluzl","rlf","clyzpvu"],W=["<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."],C=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],A=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),N=e=>S(W[e]),G=e=>{const t=e[S(E[0])]||e[S(E[1])]||e[S(E[2])];if(!t)return-1;const i=t.split("-");let o=function(e=""){let t=-2;const i=L(S(e));return i in A&&(t=A[i]),t}(i[0]);return 0===o||(e=>e[2]===L(e[0]+e[1]))(i)||(o=-2),o},B=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),F=e=>e,P=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)),D={},U=(q=e,q?.__esModule?q.default:q);var q;let J=!0;const Z=U({expand:!1,label:g}),V=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const X=e=>(t,...i)=>D[t]?D[t].console[e](...i):Z[e](...i);var Y;const _=(Y="log",(e,...t)=>!0===(e=>D[e]?D[e].log:J)(e)?X(Y)(e,...t):null),K=X("warn"),Q=X("error"),ee=X("event"),te=X("purge"),ie=X("errorBoundary");const oe=(e,...t)=>D[e]?D[e].console.warn(P(F)(...t)):queueMicrotask(()=>console?.warn(P((e=>(...t)=>[`${i}(${e})`,...t].join(" "))(e))(...t))),ne=(e=>(t,i="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${i} <b>${n}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(oe),re=ne("Option");function se(e,t){const{msgTimeout:i,warningTimeout:o}=t[e];o&&(i&&clearTimeout(i),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{initialised:i,loadErrorShown:o}=t[e];t[e].msgTimeout=void 0,i||o||(t[e].loadErrorShown=!0,function(e,t){const{iframe:i,waitForLoad:o}=t[e],{sandbox:n}=i,r=typeof n===b&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));ee(e,"noResponse"),oe(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))},o))}const ae=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:j,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 D[e.id].onInit===v&&(re("init()","onReady()","",e.id),D[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),le={position:null,version:t};function ce(i){function s(){ye(B),me(U),W("onResized",B)}function c(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function m(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const b=e=>N.slice(N.indexOf(o)+7+e);const v=(e,t)=>(i,o)=>{const n={};var r,s;r=function(){ve(`${i} (${e})`,`${e}:${t()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},z=(e,t)=>()=>{let i=!1;const o=t=>()=>{D[c]?i&&i!==t||(e(t,c),i=t,requestAnimationFrame(()=>{i=!1})):l()},n=o(h),r=o("resize window");function s(e,t){t(window,h,n),t(window,p,r)}function l(){ee(c,`stop${t}`),s(0,O),u.disconnect(),d.disconnect(),O(D[c].iframe,a,l)}const c=U,u=new ResizeObserver(o("pageObserver")),d=new ResizeObserver(o("iframeObserver"));D[c]&&(D[c][`stop${t}`]=l,R(D[c].iframe,a,l),s(0,R),u.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(D[c].iframe,{attributes:!0,childList:!1,subtree:!1}))},w=e=>()=>{e in D[U]&&(D[U][e](),delete D[U][e])},j=v(u,function(){const e=document.body.getBoundingClientRect(),t=B.iframe.getBoundingClientRect(),{scrollY:i,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),T=v(d,function(){const{iframe:e}=B,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),I=z(j,"PageInfo"),k=z(T,"ParentInfo"),H=w("stopPageInfo"),x=w("stopParentInfo");function M(e){const t=e.getBoundingClientRect();return pe(),{x:Number(t.left)+Number(le.position.x),y:Number(t.top)+Number(le.position.y)}}function L(t){const i=t?M(B.iframe):{x:0,y:0};_(U,`Reposition requested (offset x:%c${i.x}%c y:%c${i.y})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT);const o=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(B,i),n=window.parentIframe||window.parentIFrame;n?function(e,i){setTimeout(()=>e["scrollTo"+(t?"Offset":"")](i.x,i.y))}(n,o):function(e){le.position=e,S(U)}(o)}function S(e){const{x:t,y:i}=le.position,o=D[e]?.iframe;!1!==W("onScroll",{iframe:o,top:i,left:t,x:t,y:i})?me(e):he()}function E(e){let t={};if(0===B.width&&0===B.height){const e=b(9).split(o);t={x:e[1],y:e[0]}}else t={x:B.width,y:B.height};W(e,{iframe:B.iframe,screenX:Number(t.x),screenY:Number(t.y),type:B.type})}const W=(e,t)=>ue(U,e,t);function C(){const{height:i,iframe:o,msg:a,type:c,width:p}=B;switch(D[U]?.firstRun&&function(){if(!D[U])return;Te(U,B.mode),D[U].firstRun=!1}(),c){case"close":fe(o);break;case l:m=b(6),W("onMessage",{iframe:B.iframe,message:JSON.parse(m)});break;case"mouseenter":E("onMouseEnter");break;case"mouseleave":E("onMouseLeave");break;case"beforeUnload":_(U,"Ready state reset"),D[U].initialised=!1;break;case n:D[U].autoResize=JSON.parse(b(9));break;case"scrollBy":!function(){const t=B.width,i=B.height,o=window.parentIframe||window.parentIFrame||window;_(U,`scrollBy: x: %c${t}%c y: %c${i}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),o.scrollBy(t,i)}();break;case"scrollTo":L(!1);break;case"scrollToOffset":L(!0);break;case u:I();break;case d:k();break;case"pageInfoStop":H();break;case"parentInfoStop":x();break;case"inPageLink":!function(t){const i=t.split("#")[1]||"",o=decodeURIComponent(i);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const t=M(n);_(U,`Moving to in page link: %c#${i}`,e.HIGHLIGHT),le.position={x:t.x,y:t.y},S(U),window.location.hash=i}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(i)}()}(b(9));break;case"title":!function(t,i){D[i]?.syncTitle&&(D[i].iframe.title=t,_(i,`Set iframe title attribute: %c${t}`,e.HIGHLIGHT))}(a,U);break;case f:ge(B);break;case r:s(),function(e){try{D[e].sameOrigin=!!D[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){D[e].sameOrigin=!1}}(U),(h=a)!==t&&(void 0!==h||oe(U,"<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")),D[U].initialised=!0,W("onReady",o);break;default:if(0===p&&0===i)return void K(U,`Unsupported message received (${c}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===p||0===i)return;if(document.hidden)return;s()}var h,m}function A(e){if(!D[e])throw new Error(`${B.type} No settings for ${e}. Message was: ${N}`)}let N=i.data;if("[iFrameResizerChild]Ready"===N)return G=i.source,void Object.values(D).forEach((e=>({initChild:t,postMessageTarget:i})=>{e===i&&t()})(G));var G;if(!(e=>$===`${e}`.slice(0,13)&&e.slice(13).split(o)[0]in D)(N)){if(typeof N!==y)return;return void ee(g,"ignoredMessage")}const B=function(e){const t=e.slice(13).split(o),i=t[1]?Number(t[1]):0,n=D[t[0]]?.iframe,r=getComputedStyle(n),s={iframe:n,id:t[0],height:i+c(r)+m(r),width:Number(t[2]),type:t[3],msg:t[4]};return t[5]&&(s.mode=t[5]),s}(N),{id:F,type:P}=B,U=F;U?(ee(U,P),ie(U,function(e){A(U),B.type in{true:1,false:1,undefined:1}||(null!==B.iframe||(K(U,`The iframe (${B.id}) was not found.`),0))&&function(){const{origin:e,sameOrigin:t}=i;if(t)return!0;let o=D[U]?.checkOrigin;if(o&&"null"!=`${e}`&&!(o.constructor===Array?function(){let t=0,i=!1;for(;t<o.length;t++)if(o[t]===e){i=!0;break}return i}():function(){const t=D[U]?.remoteHost;return e===t}()))throw new Error(`Unexpected message received from: ${e} for ${B.iframe.id}. Message was: ${i.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&C()})(N)):K("","iframeResizer received messageData without id, message was: ",N)}function ue(e,t,i){let o=null,n=null;if(D[e]){if(o=D[e][t],typeof o!==v)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{n=o(i)}catch(i){console.error(i),K(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(o,i)}return n}function de(e){const{id:t}=e;delete D[t],delete e.iframeResizer}function fe(e){const{id:t}=e;if(!1!==ue(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){K(t,e)}ue(t,"onAfterClose",t),de(e)}}function pe(e){null===le.position&&(le.position={x:window.scrollX,y:window.scrollY})}function he(){le.position=null}function me(t){null!==le.position&&(window.scrollTo(le.position.x,le.position.y),_(t,`Set page position: %c${le.position.x}%c, %c${le.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),he())}function ge(e){pe(e.id),ye(e),ve(f,f,e.id)}function ye(t){function i(i){const n=`${t[i]}px`;t.iframe.style[i]=n,_(o,`Set ${i}: %c${n}`,e.HIGHLIGHT)}const{id:o}=t,{sizeHeight:n,sizeWidth:r}=D[o];n&&i("height"),r&&i("width")}const be=e=>e.split(o).filter((e,t)=>19!==t).join(o);function ve(t,i,o){function n(n){const r=t in k?be(i):i;_(o,n,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),_(o,`Message data: %c${r}`,e.HIGHLIGHT)}ee(o,t),D[o]&&(D[o]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:r,sameOrigin:s,targetOrigin:a}=D[o];if(s)try{return e.contentWindow.iframeChildListener($+i),void n(`Sending message to iframe %c${o}%c via same origin%c`)}catch(e){t in k?D[o].sameOrigin=!1:K(o,"Same origin messaging failed, falling back to postMessage")}n(`Sending message to iframe: %c${o}%c targetOrigin: %c${a}`),r.postMessage($+i,a)}():K(o,`Iframe(${o}) not found`))}let ze=0,we=!1,je=!1;function Te(i,o=-3){if(we)return;const n=Math.max(D[i].mode,o);if(n>D[i].mode&&(D[i].mode=n),n<0)throw te(i),D[i].vAdvised||oe(i||"Parent",`${N(n+2)}${N(2)}`),D[i].vAdvised=!0,N(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>0&&je||function(t,i){queueMicrotask(()=>console.info(`%ciframe-resizer ${t}`,J||i<1?"font-weight: bold;":e.NORMAL))}(`v${t} (${(e=>S(C[e]))(n)})`,n),n<1&&oe("Parent",N(3)),we=!0}function $e(){!0!==document.hidden&&((e,t)=>{Object.values(D).filter(({autoResize:e,firstRun:t})=>e&&!t).forEach(({iframe:i})=>ve(e,t,i.id))})("tabVisible",p)}const Ie=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{R(window,l,ce),R(document,"visibilitychange",$e),window.iframeParentListener=e=>setTimeout(()=>ce({data:e,sameOrigin:!0}))});module.exports=t=>u=>{function d(){D[S]?.heightCalculationMethod in I&&ge({iframe:u,height:1,width:1,type:r})}function f(){if(D[S]){const{iframe:e}=D[S],t={close:fe.bind(null,e),disconnect:de.bind(null,e),removeListeners(){oe(S,"<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize(){oe(S,"<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."),ve.bind(null,"Window resize",p,S)},moveToAnchor(e){((e,t,i)=>{if(typeof e!==t)throw new TypeError(`${i} is not a ${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,y,"moveToAnchor(anchor) anchor"),ve("Move to anchor",`moveToAnchor:${e}`,S)},sendMessage(e){e=JSON.stringify(e),ve(l,`${l}:${e}`,S)}};e.iframeResizer=t,e.iFrameResizer=t}}function h(e,t){const i=i=>()=>{if(!D[e])return;const{firstRun:o,iframe:n}=D[e];ve(i,t,e),(e=>e===r)(i)&&(e=>"lazy"===e.loading)(n)||se(e,D),o||d()},{iframe:o}=D[e];D[e].initChild=i(s),function(e,t){R(e,a,()=>setTimeout(t,1))}(o,i(c)),function(e,t){const{iframe:i,waitForLoad:o}=D[e];!0!==o&&((e=>{const{src:t,srcdoc:i}=e;return!i&&(null==t||""===t||"about:blank"===t)})(i)?setTimeout(()=>{ee(e,"noContent"),_(e,"No content detected in the iframe, delaying initialisation")}):setTimeout(t))}(e,i(r))}function g(e){return e?(("sizeWidth"in e||"sizeHeight"in e||n in e)&&oe(S,`<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>"${j}"</>, <i>"${T}"</> or <i>"${w}"</>.\n`),e):{}}function v(e){const t=D[e]?.iframe?.title;return""===t||void 0===t}function $(e,t){B(D[S],e)&&(oe(S,`<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</>.`),D[S][t]=D[S][e],delete D[S][e])}const k=e=>B(e,"onMouseEnter")||B(e,"onMouseLeave");function O(t){var i,o;D[S]={...D[S],iframe:u,remoteHost:u?.src.split("/").slice(0,3).join("/"),...ae,...g(t),mouseEvents:k(t),mode:G(t),syncTitle:v(S)},$("offset","offsetSize"),$("onClose","onBeforeClose"),$("onClosed","onAfterClose"),ee(S,"setup"),function(){const{direction:e}=D[S];switch(e){case j:break;case T:D[S].sizeHeight=!1;case"both":D[S].sizeWidth=!0;break;case w:D[S].sizeWidth=!1,D[S].sizeHeight=!1,D[S].autoResize=!1;break;default:throw new TypeError(S,`Direction value of "${e}" is not valid`)}}(),(i=t?.offsetSize||t?.offset)&&(D[S].direction===j?D[S].offsetHeight=i:D[S].offsetWidth=i),function(e){e?.offset&&oe(S,"<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</>.")}(t),D[S].warningTimeout||_(S,"warningTimeout:%c disabled",e.HIGHLIGHT),null===D[S].postMessageTarget&&(D[S].postMessageTarget=u.contentWindow),D[S].targetOrigin=!0===D[S].checkOrigin?""===(o=D[S].remoteHost)||null!==o.match(/^(about:blank|javascript:|file:\/\/)/)?"*":o:"*"}const L=()=>i in u,S=function(e){if(e&&typeof e!==y)throw new TypeError("Invalid id for iFrame. Expected String");return""!==e&&e||(e=function(){let e=t?.id||ae.id+ze++;return null!==document.getElementById(e)&&(e+=ze++),e}(),u.id=e,ee(e,"assignId")),e}(u.id);if(typeof t!==b)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=expanded"))}(t),function(e,t){const i=B(t,"log"),o=typeof t.log===y,n=i?!!o||t.log:ae.log;B(t,"logExpand")||(t.logExpand=i&&o?t.log===H:ae.logExpand),function(e){-1===e?.log&&(e.log=!1,je=!0)}(t),function({enabled:e,expand:t,iframeId:i}){const o=U({expand:t,label:V(i)});J=e,D[i]||(D[i]={console:o})}({enabled:n,expand:t.logExpand,iframeId:e}),o&&!(t.log in M)&&Q(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=n}(S,t),ie(S,function(e){L()?K(S,`Ignored iframe (${S}), already setup.`):(O(e),function(){if(we)return;const{mode:e}=D[S];-1!==e&&Te(S,e)}(),Ie(),function(){switch(u.style.overflow=!1===D[S]?.scrolling?"hidden":z,D[S]?.scrolling){case"omit":break;case!0:u.scrolling="yes";break;case!1:u.scrolling="no";break;default:u.scrolling=D[S]?D[S].scrolling:"no"}}(),function(){const{bodyMargin:e}=D[S];"number"!=typeof e&&"0"!==e||(D[S].bodyMargin=`${e}px`)}(),h(S,function(e){const{autoResize:t,bodyBackground:i,bodyMargin:n,bodyPadding:r,heightCalculationMethod:s,inPageLinks:a,license:l,log:c,logExpand:u,mouseEvents:d,offsetHeight:f,offsetWidth:p,mode:h,sizeHeight:g,sizeWidth:y,tolerance:b,widthCalculationMethod:v}=D[e];return[e,"8",y,c,"32",!0,t,n,s,i,r,b,a,m,v,d,f,p,g,l,le.version,h,"",u].join(o)}(S)),f())})(t),u?.iframeResizer};
package/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/core 5.5.6 (esm) - 2025-09-10
4
+ * @module iframe-resizer/core 5.5.7 (esm) - 2025-09-23
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
@@ -17,4 +17,4 @@
17
17
  */
18
18
 
19
19
 
20
- import e,{NORMAL as t,HIGHLIGHT as i,FOREGROUND as o}from"auto-console-group";const n="5.5.6",r="iframeResizer",a="autoResize",s="init",l="iframeReady",c="load",d="message",u="onload",f="pageInfo",p="parentInfo",h="reset",m="resize",g="scroll",y="none",b="vertical",v="horizontal",w="[iFrameSizer]",z=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),j=Object.freeze({[u]:1,[s]:1,[l]:1}),$="expanded",k="collapsed",T=Object.freeze({[$]:1,[k]:1}),x=(e,t,i,o)=>e.addEventListener(t,i,o||!1),M=(e,t,i)=>e.removeEventListener(t,i,!1),S=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),t=Math.imul(t^o,2246822519),i=Math.imul(i^o,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},R=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),O=["spjluzl","rlf","clyzpvu"],I=["<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."],E=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],C=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),W=e=>R(I[e]),A=e=>{const t=e[R(O[0])]||e[R(O[1])]||e[R(O[2])];if(!t)return-1;const i=t.split("-");let o=function(e=""){let t=-2;const i=S(R(e));return i in C&&(t=C[i]),t}(i[0]);return 0===o||(e=>e[2]===S(e[0]+e[1]))(i)||(o=-2),o},L=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),N=e=>e,B=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)),H={},P=(F=e,F?.__esModule?F.default:F);var F;let q=!0;const D=P({expand:!1,label:"parent"}),U=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const J=e=>(t,...i)=>H[t]?H[t].console[e](...i):D[e](...i);var Z;const V=(Z="log",(e,...t)=>!0===(e=>H[e]?H[e].log:q)(e)?J(Z)(e,...t):null),X=J("warn"),Y=J("error"),_=J("event"),G=J("purge"),K=J("errorBoundary");const Q=(e,...t)=>H[e]?H[e].console.warn(B(N)(...t)):queueMicrotask(()=>console?.warn(B((e=>(...t)=>[`${r}(${e})`,...t].join(" "))(e))(...t))),ee=(e=>(t,i="renamed to")=>(o,n,r="",a="")=>e(a,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${i} <b>${n}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(Q),te=ee("Option");function ie(e,t){const{msgTimeout:i,warningTimeout:o}=t[e];o&&(i&&clearTimeout(i),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{initialised:i,loadErrorShown:o}=t[e];t[e].msgTimeout=void 0,i||o||(t[e].loadErrorShown=!0,function(e,t){const{iframe:i,waitForLoad:o}=t[e],{sandbox:n}=i,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));_(e,"noResponse"),Q(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))},o))}const oe=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:b,firstRun:!0,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 H[e.id].onInit&&(te("init()","onReady()","",e.id),H[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),ne={position:null,version:n};function re(e){function t(){pe(B),ue(q),C("onResized",B)}function r(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function l(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const u=e=>L.slice(L.indexOf(":")+7+e);const y=(e,t)=>(i,o)=>{const n={};var r,a;r=function(){me(`${i} (${e})`,`${e}:${t()}`,o)},n[a=o]||(r(),n[a]=requestAnimationFrame(()=>{n[a]=null}))},b=(e,t)=>()=>{let i=!1;const o=t=>()=>{H[l]?i&&i!==t||(e(t,l),i=t,requestAnimationFrame(()=>{i=!1})):s()},n=o(g),r=o("resize window");function a(e,t){t(window,g,n),t(window,m,r)}function s(){_(l,`stop${t}`),a(0,M),d.disconnect(),u.disconnect(),M(H[l].iframe,c,s)}const l=q,d=new ResizeObserver(o("pageObserver")),u=new ResizeObserver(o("iframeObserver"));H[l]&&(H[l][`stop${t}`]=s,x(H[l].iframe,c,s),a(0,x),d.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),u.observe(H[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},v=e=>()=>{e in H[q]&&(H[q][e](),delete H[q][e])},z=y(f,function(){const e=document.body.getBoundingClientRect(),t=B.iframe.getBoundingClientRect(),{scrollY:i,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:a,clientWidth:s}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(a,n||0),clientWidth:Math.max(s,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:o,documentHeight:a,documentWidth:s,windowHeight:n,windowWidth:r})}),j=y(p,function(){const{iframe:e}=B,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:o,height:n,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}})}),$=b(z,"PageInfo"),k=b(j,"ParentInfo"),T=v("stopPageInfo"),S=v("stopParentInfo");function R(e){const t=e.getBoundingClientRect();return ce(),{x:Number(t.left)+Number(ne.position.x),y:Number(t.top)+Number(ne.position.y)}}function O(e){const t=e?R(B.iframe):{x:0,y:0};V(q,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,i,o,i);const n=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(B,t),r=window.parentIframe||window.parentIFrame;r?function(t,i){setTimeout(()=>t["scrollTo"+(e?"Offset":"")](i.x,i.y))}(r,n):function(e){ne.position=e,I(q)}(n)}function I(e){const{x:t,y:i}=ne.position,o=H[e]?.iframe;!1!==C("onScroll",{iframe:o,top:i,left:t,x:t,y:i})?ue(e):de()}function E(e){let t={};if(0===B.width&&0===B.height){const e=u(9).split(":");t={x:e[1],y:e[0]}}else t={x:B.width,y:B.height};C(e,{iframe:B.iframe,screenX:Number(t.x),screenY:Number(t.y),type:B.type})}const C=(e,t)=>ae(q,e,t);function W(){const{height:e,iframe:r,msg:l,type:c,width:m}=B;switch(H[q]?.firstRun&&function(){if(!H[q])return;ve(q,B.mode),H[q].firstRun=!1}(),c){case"close":le(r);break;case d:y=u(6),C("onMessage",{iframe:B.iframe,message:JSON.parse(y)});break;case"mouseenter":E("onMouseEnter");break;case"mouseleave":E("onMouseLeave");break;case"beforeUnload":V(q,"Ready state reset"),H[q].initialised=!1;break;case a:H[q].autoResize=JSON.parse(u(9));break;case"scrollBy":!function(){const e=B.width,t=B.height,n=window.parentIframe||window.parentIFrame||window;V(q,`scrollBy: x: %c${e}%c y: %c${t}`,i,o,i),n.scrollBy(e,t)}();break;case"scrollTo":O(!1);break;case"scrollToOffset":O(!0);break;case f:$();break;case p:k();break;case"pageInfoStop":T();break;case"parentInfoStop":S();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=R(n);V(q,`Moving to in page link: %c#${t}`,i),ne.position={x:e.x,y:e.y},I(q),window.location.hash=t}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(t)}()}(u(9));break;case"title":!function(e,t){H[t]?.syncTitle&&(H[t].iframe.title=e,V(t,`Set iframe title attribute: %c${e}`,i))}(l,q);break;case h:fe(B);break;case s:t(),function(e){try{H[e].sameOrigin=!!H[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){H[e].sameOrigin=!1}}(q),(g=l)!==n&&(void 0!==g||Q(q,"<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")),H[q].initialised=!0,C("onReady",r);break;default:if(0===m&&0===e)return void X(q,`Unsupported message received (${c}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===m||0===e)return;if(document.hidden)return;t()}var g,y}function A(e){if(!H[e])throw new Error(`${B.type} No settings for ${e}. Message was: ${L}`)}let L=e.data;if("[iFrameResizerChild]Ready"===L)return N=e.source,void Object.values(H).forEach((e=>({initChild:t,initialised:i,postMessageTarget:o})=>{i||e!==o||t()})(N));var N;if(!(e=>w===`${e}`.slice(0,13)&&e.slice(13).split(":")[0]in H)(L)){if("string"!=typeof L)return;return void _("parent","ignoredMessage")}const B=function(e){const t=e.slice(13).split(":"),i=t[1]?Number(t[1]):0,o=H[t[0]]?.iframe,n=getComputedStyle(o),a={iframe:o,id:t[0],height:i+r(n)+l(n),width:Number(t[2]),type:t[3],msg:t[4]};return t[5]&&(a.mode=t[5]),a}(L),{id:P,type:F}=B,q=P;q?(_(q,F),K(q,function(t){A(q),B.type in{true:1,false:1,undefined:1}||(null!==B.iframe||(X(q,`The iframe (${B.id}) was not found.`),0))&&function(){const{origin:t,sameOrigin:i}=e;if(i)return!0;let o=H[q]?.checkOrigin;if(o&&"null"!=`${t}`&&!(o.constructor===Array?function(){let e=0,i=!1;for(;e<o.length;e++)if(o[e]===t){i=!0;break}return i}():function(){const e=H[q]?.remoteHost;return t===e}()))throw new Error(`Unexpected message received from: ${t} for ${B.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}()&&W()})(L)):X("","iframeResizer received messageData without id, message was: ",L)}function ae(e,t,i){let o=null,n=null;if(H[e]){if(o=H[e][t],"function"!=typeof o)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{n=o(i)}catch(i){console.error(i),X(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(o,i)}return n}function se(e){const{id:t}=e;delete H[t],delete e.iframeResizer}function le(e){const{id:t}=e;if(!1!==ae(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){X(t,e)}ae(t,"onAfterClose",t),se(e)}}function ce(e){null===ne.position&&(ne.position={x:window.scrollX,y:window.scrollY})}function de(){ne.position=null}function ue(e){null!==ne.position&&(window.scrollTo(ne.position.x,ne.position.y),V(e,`Set page position: %c${ne.position.x}%c, %c${ne.position.y}`,i,o,i),de())}function fe(e){ce(e.id),pe(e),me(h,h,e.id)}function pe(e){function t(t){const n=`${e[t]}px`;e.iframe.style[t]=n,V(o,`Set ${t}: %c${n}`,i)}const{id:o}=e,{sizeHeight:n,sizeWidth:r}=H[o];n&&t("height"),r&&t("width")}const he=e=>e.split(":").filter((e,t)=>19!==t).join(":");function me(e,t,n){function r(r){const a=e in j?he(t):t;V(n,r,i,o,i),V(n,`Message data: %c${a}`,i)}_(n,e),H[n]&&(H[n]?.postMessageTarget?function(){const{iframe:i,postMessageTarget:o,sameOrigin:a,targetOrigin:s}=H[n];if(a)try{return i.contentWindow.iframeChildListener(w+t),void r(`Sending message to iframe %c${n}%c via same origin%c`)}catch(t){e in j?H[n].sameOrigin=!1:X(n,"Same origin messaging failed, falling back to postMessage")}r(`Sending message to iframe: %c${n}%c targetOrigin: %c${s}`),o.postMessage(w+t,s)}():X(n,`Iframe(${n}) not found`))}let ge=0,ye=!1,be=!1;function ve(e,i=-3){if(ye)return;const o=Math.max(H[e].mode,i);if(o>H[e].mode&&(H[e].mode=o),o<0)throw G(e),H[e].vAdvised||Q(e||"Parent",`${W(o+2)}${W(2)}`),H[e].vAdvised=!0,W(o+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");o>0&&be||function(e,i){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,q||i<1?"font-weight: bold;":t))}(`v${n} (${(e=>R(E[e]))(o)})`,o),o<1&&Q("Parent",W(3)),ye=!0}const we=e=>t=>{function o(){if(H[M]){const{iframe:e}=H[M],t={close:le.bind(null,e),disconnect:se.bind(null,e),removeListeners(){Q(M,"<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize(){Q(M,"<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."),me.bind(null,"Window resize",m,M)},moveToAnchor(e){((e,t,i)=>{if(typeof e!==t)throw new TypeError(`${i} is not a ${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,"string","moveToAnchor(anchor) anchor"),me("Move to anchor",`moveToAnchor:${e}`,M)},sendMessage(e){e=JSON.stringify(e),me(d,`${d}:${e}`,M)}};e.iframeResizer=t,e.iFrameResizer=t}}function n(e,i){const{waitForLoad:o}=H[e],n=o=>()=>{H[e]&&!0!==H[e].initialised&&(me(o,i,e),ie(e,H),H[e].firstRun||H[M]?.heightCalculationMethod in z&&fe({iframe:t,height:1,width:1,type:s}))},r=n(u);x(t,c,()=>setTimeout(r,1)),H[e].initChild=n(l),!0!==o&&((e=>{const{src:t,srcdoc:i}=e;return!i&&(null==t||""===t||"about:blank"===t)})(t)?setTimeout(()=>{_(e,"noContent"),V(e,"No content detected in the iframe, delaying initialisation")}):setTimeout(n(s)))}function f(e){return e?(("sizeWidth"in e||"sizeHeight"in e||a in e)&&Q(M,`<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>"${v}"</> or <i>"${y}"</>.\n`),e):{}}function p(e){const t=H[e]?.iframe?.title;return""===t||void 0===t}function h(e,t){L(H[M],e)&&(Q(M,`<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</>.`),H[M][t]=H[M][e],delete H[M][e])}const g=e=>L(e,"onMouseEnter")||L(e,"onMouseLeave");function w(e){var o,n;H[M]={...H[M],iframe:t,remoteHost:t?.src.split("/").slice(0,3).join("/"),...oe,...f(e),mouseEvents:g(e),mode:A(e),syncTitle:p(M)},h("offset","offsetSize"),h("onClose","onBeforeClose"),h("onClosed","onAfterClose"),_(M,"setup"),function(){const{direction:e}=H[M];switch(e){case b:break;case v:H[M].sizeHeight=!1;case"both":H[M].sizeWidth=!0;break;case y:H[M].sizeWidth=!1,H[M].sizeHeight=!1,H[M].autoResize=!1;break;default:throw new TypeError(M,`Direction value of "${e}" is not valid`)}}(),(o=e?.offsetSize||e?.offset)&&(H[M].direction===b?H[M].offsetHeight=o:H[M].offsetWidth=o),function(e){e?.offset&&Q(M,"<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),H[M].warningTimeout||V(M,"warningTimeout:%c disabled",i),null===H[M].postMessageTarget&&(H[M].postMessageTarget=t.contentWindow),H[M].targetOrigin=!0===H[M].checkOrigin?""===(n=H[M].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}const j=()=>r in t,M=function(i){if(i&&"string"!=typeof i)throw new TypeError("Invalid id for iFrame. Expected String");return""!==i&&i||(i=function(){let t=e?.id||oe.id+ge++;return null!==document.getElementById(t)&&(t+=ge++),t}(),t.id=i,_(i,"assignId")),i}(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=k,e.logExpand=t.includes("ifrlog=expanded"))}(e),function(e,t){const i=L(t,"log"),o="string"==typeof t.log,n=i?!!o||t.log:oe.log;L(t,"logExpand")||(t.logExpand=i&&o?t.log===$:oe.logExpand),function(e){-1===e?.log&&(e.log=!1,be=!0)}(t),function({enabled:e,expand:t,iframeId:i}){const o=P({expand:t,label:U(i)});q=e,H[i]||(H[i]={console:o})}({enabled:n,expand:t.logExpand,iframeId:e}),o&&!(t.log in T)&&Y(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=n}(M,e),K(M,function(e){j()?X(M,`Ignored iframe (${M}), already setup.`):(w(e),function(){if(ye)return;const{mode:e}=H[M];-1!==e&&ve(M,e)}(),je(),function(){switch(t.style.overflow=!1===H[M]?.scrolling?"hidden":"auto",H[M]?.scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=H[M]?H[M].scrolling:"no"}}(),function(){const{bodyMargin:e}=H[M];"number"!=typeof e&&"0"!==e||(H[M].bodyMargin=`${e}px`)}(),n(M,function(e){const t=H[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,ne.version,t.mode,"",t.logExpand].join(":")}(M)),o())})(e),t?.iframeResizer};function ze(){!0!==document.hidden&&((e,t)=>{Object.values(H).filter(({autoResize:e,firstRun:t})=>e&&!t).forEach(({iframe:i})=>me(e,t,i.id))})("tabVisible",m)}const je=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{x(window,d,re),x(document,"visibilitychange",ze),window.iframeParentListener=e=>setTimeout(()=>re({data:e,sameOrigin:!0}))});export{we as default};
20
+ import e,{NORMAL as t,HIGHLIGHT as i,FOREGROUND as o}from"auto-console-group";const n="5.5.7",r="iframeResizer",a=":",s="autoResize",l="init",c="iframeReady",u="load",d="message",f="onload",p="pageInfo",h="parentInfo",m="reset",g="resize",y="scroll",b="child",v="parent",z="string",w="object",j="function",$="auto",k="none",T="vertical",x="horizontal",M="[iFrameSizer]",S=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),R=Object.freeze({[f]:1,[l]:1,[c]:1}),O="expanded",I="collapsed",E=Object.freeze({[O]:1,[I]:1}),W=(e,t,i,o)=>e.addEventListener(t,i,o||!1),C=(e,t,i)=>e.removeEventListener(t,i,!1),A=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),t=Math.imul(t^o,2246822519),i=Math.imul(i^o,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},L=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),N=["spjluzl","rlf","clyzpvu"],B=["<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."],H=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],P=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),F=e=>L(B[e]),q=e=>{const t=e[L(N[0])]||e[L(N[1])]||e[L(N[2])];if(!t)return-1;const i=t.split("-");let o=function(e=""){let t=-2;const i=A(L(e));return i in P&&(t=P[i]),t}(i[0]);return 0===o||(e=>e[2]===A(e[0]+e[1]))(i)||(o=-2),o},D=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),U=e=>e,J=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)),Z={},V=(X=e,X?.__esModule?X.default:X);var X;let Y=!0;const _=V({expand:!1,label:v}),G=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const K=e=>(t,...i)=>Z[t]?Z[t].console[e](...i):_[e](...i);var Q;const ee=(Q="log",(e,...t)=>!0===(e=>Z[e]?Z[e].log:Y)(e)?K(Q)(e,...t):null),te=K("warn"),ie=K("error"),oe=K("event"),ne=K("purge"),re=K("errorBoundary");const ae=(e,...t)=>Z[e]?Z[e].console.warn(J(U)(...t)):queueMicrotask(()=>console?.warn(J((e=>(...t)=>[`${r}(${e})`,...t].join(" "))(e))(...t))),se=(e=>(t,i="renamed to")=>(o,n,r="",a="")=>e(a,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${i} <b>${n}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(ae),le=se("Option");function ce(e,t){const{msgTimeout:i,warningTimeout:o}=t[e];o&&(i&&clearTimeout(i),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{initialised:i,loadErrorShown:o}=t[e];t[e].msgTimeout=void 0,i||o||(t[e].loadErrorShown=!0,function(e,t){const{iframe:i,waitForLoad:o}=t[e],{sandbox:n}=i,r=typeof n===w&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));oe(e,"noResponse"),ae(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))},o))}const ue=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:T,firstRun:!0,inPageLinks:!1,heightCalculationMethod:$,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:$,onBeforeClose:()=>!0,onAfterClose(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{typeof Z[e.id].onInit===j&&(le("init()","onReady()","",e.id),Z[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),de={position:null,version:n};function fe(e){function t(){ze(F),be(U),L("onResized",F)}function r(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function c(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const f=e=>H.slice(H.indexOf(a)+7+e);const b=(e,t)=>(i,o)=>{const n={};var r,a;r=function(){je(`${i} (${e})`,`${e}:${t()}`,o)},n[a=o]||(r(),n[a]=requestAnimationFrame(()=>{n[a]=null}))},w=(e,t)=>()=>{let i=!1;const o=t=>()=>{Z[l]?i&&i!==t||(e(t,l),i=t,requestAnimationFrame(()=>{i=!1})):s()},n=o(y),r=o("resize window");function a(e,t){t(window,y,n),t(window,g,r)}function s(){oe(l,`stop${t}`),a(0,C),c.disconnect(),d.disconnect(),C(Z[l].iframe,u,s)}const l=U,c=new ResizeObserver(o("pageObserver")),d=new ResizeObserver(o("iframeObserver"));Z[l]&&(Z[l][`stop${t}`]=s,W(Z[l].iframe,u,s),a(0,W),c.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(Z[l].iframe,{attributes:!0,childList:!1,subtree:!1}))},j=e=>()=>{e in Z[U]&&(Z[U][e](),delete Z[U][e])},$=b(p,function(){const e=document.body.getBoundingClientRect(),t=F.iframe.getBoundingClientRect(),{scrollY:i,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:a,clientWidth:s}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(a,n||0),clientWidth:Math.max(s,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:o,documentHeight:a,documentWidth:s,windowHeight:n,windowWidth:r})}),k=b(h,function(){const{iframe:e}=F,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:o,height:n,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}})}),T=w($,"PageInfo"),x=w(k,"ParentInfo"),S=j("stopPageInfo"),R=j("stopParentInfo");function O(e){const t=e.getBoundingClientRect();return ge(),{x:Number(t.left)+Number(de.position.x),y:Number(t.top)+Number(de.position.y)}}function I(e){const t=e?O(F.iframe):{x:0,y:0};ee(U,`Reposition requested (offset x:%c${t.x}%c y:%c${t.y})`,i,o,i);const n=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(F,t),r=window.parentIframe||window.parentIFrame;r?function(t,i){setTimeout(()=>t["scrollTo"+(e?"Offset":"")](i.x,i.y))}(r,n):function(e){de.position=e,E(U)}(n)}function E(e){const{x:t,y:i}=de.position,o=Z[e]?.iframe;!1!==L("onScroll",{iframe:o,top:i,left:t,x:t,y:i})?be(e):ye()}function A(e){let t={};if(0===F.width&&0===F.height){const e=f(9).split(a);t={x:e[1],y:e[0]}}else t={x:F.width,y:F.height};L(e,{iframe:F.iframe,screenX:Number(t.x),screenY:Number(t.y),type:F.type})}const L=(e,t)=>pe(U,e,t);function N(){const{height:e,iframe:r,msg:a,type:c,width:u}=F;switch(Z[U]?.firstRun&&function(){if(!Z[U])return;xe(U,F.mode),Z[U].firstRun=!1}(),c){case"close":me(r);break;case d:y=f(6),L("onMessage",{iframe:F.iframe,message:JSON.parse(y)});break;case"mouseenter":A("onMouseEnter");break;case"mouseleave":A("onMouseLeave");break;case"beforeUnload":ee(U,"Ready state reset"),Z[U].initialised=!1;break;case s:Z[U].autoResize=JSON.parse(f(9));break;case"scrollBy":!function(){const e=F.width,t=F.height,n=window.parentIframe||window.parentIFrame||window;ee(U,`scrollBy: x: %c${e}%c y: %c${t}`,i,o,i),n.scrollBy(e,t)}();break;case"scrollTo":I(!1);break;case"scrollToOffset":I(!0);break;case p:T();break;case h:x();break;case"pageInfoStop":S();break;case"parentInfoStop":R();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=O(n);ee(U,`Moving to in page link: %c#${t}`,i),de.position={x:e.x,y:e.y},E(U),window.location.hash=t}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(t)}()}(f(9));break;case"title":!function(e,t){Z[t]?.syncTitle&&(Z[t].iframe.title=e,ee(t,`Set iframe title attribute: %c${e}`,i))}(a,U);break;case m:ve(F);break;case l:t(),function(e){try{Z[e].sameOrigin=!!Z[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){Z[e].sameOrigin=!1}}(U),(g=a)!==n&&(void 0!==g||ae(U,"<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")),Z[U].initialised=!0,L("onReady",r);break;default:if(0===u&&0===e)return void te(U,`Unsupported message received (${c}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===u||0===e)return;if(document.hidden)return;t()}var g,y}function B(e){if(!Z[e])throw new Error(`${F.type} No settings for ${e}. Message was: ${H}`)}let H=e.data;if("[iFrameResizerChild]Ready"===H)return P=e.source,void Object.values(Z).forEach((e=>({initChild:t,postMessageTarget:i})=>{e===i&&t()})(P));var P;if(!(e=>M===`${e}`.slice(0,13)&&e.slice(13).split(a)[0]in Z)(H)){if(typeof H!==z)return;return void oe(v,"ignoredMessage")}const F=function(e){const t=e.slice(13).split(a),i=t[1]?Number(t[1]):0,o=Z[t[0]]?.iframe,n=getComputedStyle(o),s={iframe:o,id:t[0],height:i+r(n)+c(n),width:Number(t[2]),type:t[3],msg:t[4]};return t[5]&&(s.mode=t[5]),s}(H),{id:q,type:D}=F,U=q;U?(oe(U,D),re(U,function(t){B(U),F.type in{true:1,false:1,undefined:1}||(null!==F.iframe||(te(U,`The iframe (${F.id}) was not found.`),0))&&function(){const{origin:t,sameOrigin:i}=e;if(i)return!0;let o=Z[U]?.checkOrigin;if(o&&"null"!=`${t}`&&!(o.constructor===Array?function(){let e=0,i=!1;for(;e<o.length;e++)if(o[e]===t){i=!0;break}return i}():function(){const e=Z[U]?.remoteHost;return t===e}()))throw new Error(`Unexpected message received from: ${t} for ${F.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}()&&N()})(H)):te("","iframeResizer received messageData without id, message was: ",H)}function pe(e,t,i){let o=null,n=null;if(Z[e]){if(o=Z[e][t],typeof o!==j)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{n=o(i)}catch(i){console.error(i),te(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(o,i)}return n}function he(e){const{id:t}=e;delete Z[t],delete e.iframeResizer}function me(e){const{id:t}=e;if(!1!==pe(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){te(t,e)}pe(t,"onAfterClose",t),he(e)}}function ge(e){null===de.position&&(de.position={x:window.scrollX,y:window.scrollY})}function ye(){de.position=null}function be(e){null!==de.position&&(window.scrollTo(de.position.x,de.position.y),ee(e,`Set page position: %c${de.position.x}%c, %c${de.position.y}`,i,o,i),ye())}function ve(e){ge(e.id),ze(e),je(m,m,e.id)}function ze(e){function t(t){const n=`${e[t]}px`;e.iframe.style[t]=n,ee(o,`Set ${t}: %c${n}`,i)}const{id:o}=e,{sizeHeight:n,sizeWidth:r}=Z[o];n&&t("height"),r&&t("width")}const we=e=>e.split(a).filter((e,t)=>19!==t).join(a);function je(e,t,n){function r(r){const a=e in R?we(t):t;ee(n,r,i,o,i),ee(n,`Message data: %c${a}`,i)}oe(n,e),Z[n]&&(Z[n]?.postMessageTarget?function(){const{iframe:i,postMessageTarget:o,sameOrigin:a,targetOrigin:s}=Z[n];if(a)try{return i.contentWindow.iframeChildListener(M+t),void r(`Sending message to iframe %c${n}%c via same origin%c`)}catch(t){e in R?Z[n].sameOrigin=!1:te(n,"Same origin messaging failed, falling back to postMessage")}r(`Sending message to iframe: %c${n}%c targetOrigin: %c${s}`),o.postMessage(M+t,s)}():te(n,`Iframe(${n}) not found`))}let $e=0,ke=!1,Te=!1;function xe(e,i=-3){if(ke)return;const o=Math.max(Z[e].mode,i);if(o>Z[e].mode&&(Z[e].mode=o),o<0)throw ne(e),Z[e].vAdvised||ae(e||"Parent",`${F(o+2)}${F(2)}`),Z[e].vAdvised=!0,F(o+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");o>0&&Te||function(e,i){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,Y||i<1?"font-weight: bold;":t))}(`v${n} (${(e=>L(H[e]))(o)})`,o),o<1&&ae("Parent",F(3)),ke=!0}const Me=e=>t=>{function o(){Z[R]?.heightCalculationMethod in S&&ve({iframe:t,height:1,width:1,type:l})}function n(){if(Z[R]){const{iframe:e}=Z[R],t={close:me.bind(null,e),disconnect:he.bind(null,e),removeListeners(){ae(R,"<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize(){ae(R,"<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."),je.bind(null,"Window resize",g,R)},moveToAnchor(e){((e,t,i)=>{if(typeof e!==t)throw new TypeError(`${i} is not a ${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,z,"moveToAnchor(anchor) anchor"),je("Move to anchor",`moveToAnchor:${e}`,R)},sendMessage(e){e=JSON.stringify(e),je(d,`${d}:${e}`,R)}};e.iframeResizer=t,e.iFrameResizer=t}}function p(e,t){const i=i=>()=>{if(!Z[e])return;const{firstRun:n,iframe:r}=Z[e];je(i,t,e),(e=>e===l)(i)&&(e=>"lazy"===e.loading)(r)||ce(e,Z),n||o()},{iframe:n}=Z[e];Z[e].initChild=i(c),function(e,t){W(e,u,()=>setTimeout(t,1))}(n,i(f)),function(e,t){const{iframe:i,waitForLoad:o}=Z[e];!0!==o&&((e=>{const{src:t,srcdoc:i}=e;return!i&&(null==t||""===t||"about:blank"===t)})(i)?setTimeout(()=>{oe(e,"noContent"),ee(e,"No content detected in the iframe, delaying initialisation")}):setTimeout(t))}(e,i(l))}function h(e){return e?(("sizeWidth"in e||"sizeHeight"in e||s in e)&&ae(R,`<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>"${T}"</>, <i>"${x}"</> or <i>"${k}"</>.\n`),e):{}}function m(e){const t=Z[e]?.iframe?.title;return""===t||void 0===t}function y(e,t){D(Z[R],e)&&(ae(R,`<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</>.`),Z[R][t]=Z[R][e],delete Z[R][e])}const v=e=>D(e,"onMouseEnter")||D(e,"onMouseLeave");function j(e){var o,n;Z[R]={...Z[R],iframe:t,remoteHost:t?.src.split("/").slice(0,3).join("/"),...ue,...h(e),mouseEvents:v(e),mode:q(e),syncTitle:m(R)},y("offset","offsetSize"),y("onClose","onBeforeClose"),y("onClosed","onAfterClose"),oe(R,"setup"),function(){const{direction:e}=Z[R];switch(e){case T:break;case x:Z[R].sizeHeight=!1;case"both":Z[R].sizeWidth=!0;break;case k:Z[R].sizeWidth=!1,Z[R].sizeHeight=!1,Z[R].autoResize=!1;break;default:throw new TypeError(R,`Direction value of "${e}" is not valid`)}}(),(o=e?.offsetSize||e?.offset)&&(Z[R].direction===T?Z[R].offsetHeight=o:Z[R].offsetWidth=o),function(e){e?.offset&&ae(R,"<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),Z[R].warningTimeout||ee(R,"warningTimeout:%c disabled",i),null===Z[R].postMessageTarget&&(Z[R].postMessageTarget=t.contentWindow),Z[R].targetOrigin=!0===Z[R].checkOrigin?""===(n=Z[R].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}const M=()=>r in t,R=function(i){if(i&&typeof i!==z)throw new TypeError("Invalid id for iFrame. Expected String");return""!==i&&i||(i=function(){let t=e?.id||ue.id+$e++;return null!==document.getElementById(t)&&(t+=$e++),t}(),t.id=i,oe(i,"assignId")),i}(t.id);if(typeof e!==w)throw new TypeError("Options is not an object");return function(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=I,e.logExpand=t.includes("ifrlog=expanded"))}(e),function(e,t){const i=D(t,"log"),o=typeof t.log===z,n=i?!!o||t.log:ue.log;D(t,"logExpand")||(t.logExpand=i&&o?t.log===O:ue.logExpand),function(e){-1===e?.log&&(e.log=!1,Te=!0)}(t),function({enabled:e,expand:t,iframeId:i}){const o=V({expand:t,label:G(i)});Y=e,Z[i]||(Z[i]={console:o})}({enabled:n,expand:t.logExpand,iframeId:e}),o&&!(t.log in E)&&ie(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=n}(R,e),re(R,function(e){M()?te(R,`Ignored iframe (${R}), already setup.`):(j(e),function(){if(ke)return;const{mode:e}=Z[R];-1!==e&&xe(R,e)}(),Re(),function(){switch(t.style.overflow=!1===Z[R]?.scrolling?"hidden":$,Z[R]?.scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=Z[R]?Z[R].scrolling:"no"}}(),function(){const{bodyMargin:e}=Z[R];"number"!=typeof e&&"0"!==e||(Z[R].bodyMargin=`${e}px`)}(),p(R,function(e){const{autoResize:t,bodyBackground:i,bodyMargin:o,bodyPadding:n,heightCalculationMethod:r,inPageLinks:s,license:l,log:c,logExpand:u,mouseEvents:d,offsetHeight:f,offsetWidth:p,mode:h,sizeHeight:m,sizeWidth:g,tolerance:y,widthCalculationMethod:v}=Z[e];return[e,"8",g,c,"32",!0,t,o,r,i,n,y,s,b,v,d,f,p,m,l,de.version,h,"",u].join(a)}(R)),n())})(e),t?.iframeResizer};function Se(){!0!==document.hidden&&((e,t)=>{Object.values(Z).filter(({autoResize:e,firstRun:t})=>e&&!t).forEach(({iframe:i})=>je(e,t,i.id))})("tabVisible",g)}const Re=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{W(window,d,fe),W(document,"visibilitychange",Se),window.iframeParentListener=e=>setTimeout(()=>fe({data:e,sameOrigin:!0}))});export{Me as default};
package/index.umd.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/core 5.5.6 (umd) - 2025-09-10
4
+ * @module iframe-resizer/core 5.5.7 (umd) - 2025-09-23
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
@@ -17,4 +17,4 @@
17
17
  */
18
18
 
19
19
 
20
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("auto-console-group")):"function"==typeof define&&define.amd?define(["auto-console-group"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).createResizer=t(e.acg)}(this,function(e){"use strict";const t="5.5.6",i="iframeResizer",o="autoResize",n="init",r="iframeReady",s="load",a="message",l="onload",c="pageInfo",d="parentInfo",u="reset",f="resize",p="scroll",h="none",m="vertical",g="horizontal",y="[iFrameSizer]",b=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),v=Object.freeze({[l]:1,[n]:1,[r]:1}),w="expanded",z="collapsed",T=Object.freeze({[w]:1,[z]:1}),j=(e,t,i,o)=>e.addEventListener(t,i,o||!1),$=(e,t,i)=>e.removeEventListener(t,i,!1),I=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),t=Math.imul(t^o,2246822519),i=Math.imul(i^o,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},k=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),H=["spjluzl","rlf","clyzpvu"],x=["<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."],M=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],R=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),O=e=>k(x[e]),L=e=>{const t=e[k(H[0])]||e[k(H[1])]||e[k(H[2])];if(!t)return-1;const i=t.split("-");let o=function(e=""){let t=-2;const i=I(k(e));return i in R&&(t=R[i]),t}(i[0]);return 0===o||(e=>e[2]===I(e[0]+e[1]))(i)||(o=-2),o},S=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),E=e=>e,C=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)),W={},A=(N=e,N?.__esModule?N.default:N);var N;let G=!0;const B=A({expand:!1,label:"parent"}),F=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const P=e=>(t,...i)=>W[t]?W[t].console[e](...i):B[e](...i);var D;const U=(D="log",(e,...t)=>!0===(e=>W[e]?W[e].log:G)(e)?P(D)(e,...t):null),q=P("warn"),J=P("error"),Z=P("event"),V=P("purge"),X=P("errorBoundary");const Y=(e,...t)=>W[e]?W[e].console.warn(C(E)(...t)):queueMicrotask(()=>console?.warn(C((e=>(...t)=>[`${i}(${e})`,...t].join(" "))(e))(...t))),_=(e=>(t,i="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${i} <b>${n}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(Y),K=_("Option");function Q(e,t){const{msgTimeout:i,warningTimeout:o}=t[e];o&&(i&&clearTimeout(i),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{initialised:i,loadErrorShown:o}=t[e];t[e].msgTimeout=void 0,i||o||(t[e].loadErrorShown=!0,function(e,t){const{iframe:i,waitForLoad:o}=t[e],{sandbox:n}=i,r="object"==typeof n&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));Z(e,"noResponse"),Y(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))},o))}const ee=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:m,firstRun:!0,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 W[e.id].onInit&&(K("init()","onReady()","",e.id),W[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),te={position:null,version:t};function ie(i){function r(){de(N),le(F),L("onResized",N)}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=>C.slice(C.indexOf(":")+7+e);const g=(e,t)=>(i,o)=>{const n={};var r,s;r=function(){fe(`${i} (${e})`,`${e}:${t()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},b=(e,t)=>()=>{let i=!1;const o=t=>()=>{W[c]?i&&i!==t||(e(t,c),i=t,requestAnimationFrame(()=>{i=!1})):l()},n=o(p),r=o("resize window");function a(e,t){t(window,p,n),t(window,f,r)}function l(){Z(c,`stop${t}`),a(0,$),d.disconnect(),u.disconnect(),$(W[c].iframe,s,l)}const c=F,d=new ResizeObserver(o("pageObserver")),u=new ResizeObserver(o("iframeObserver"));W[c]&&(W[c][`stop${t}`]=l,j(W[c].iframe,s,l),a(0,j),d.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),u.observe(W[c].iframe,{attributes:!0,childList:!1,subtree:!1}))},v=e=>()=>{e in W[F]&&(W[F][e](),delete W[F][e])},w=g(c,function(){const e=document.body.getBoundingClientRect(),t=N.iframe.getBoundingClientRect(),{scrollY:i,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),z=g(d,function(){const{iframe:e}=N,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),T=b(w,"PageInfo"),I=b(z,"ParentInfo"),k=v("stopPageInfo"),H=v("stopParentInfo");function x(e){const t=e.getBoundingClientRect();return se(),{x:Number(t.left)+Number(te.position.x),y:Number(t.top)+Number(te.position.y)}}function M(t){const i=t?x(N.iframe):{x:0,y:0};U(F,`Reposition requested (offset x:%c${i.x}%c y:%c${i.y})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT);const o=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(N,i),n=window.parentIframe||window.parentIFrame;n?function(e,i){setTimeout(()=>e["scrollTo"+(t?"Offset":"")](i.x,i.y))}(n,o):function(e){te.position=e,R(F)}(o)}function R(e){const{x:t,y:i}=te.position,o=W[e]?.iframe;!1!==L("onScroll",{iframe:o,top:i,left:t,x:t,y:i})?le(e):ae()}function O(e){let t={};if(0===N.width&&0===N.height){const e=m(9).split(":");t={x:e[1],y:e[0]}}else t={x:N.width,y:N.height};L(e,{iframe:N.iframe,screenX:Number(t.x),screenY:Number(t.y),type:N.type})}const L=(e,t)=>oe(F,e,t);function S(){const{height:i,iframe:s,msg:l,type:f,width:p}=N;switch(W[F]?.firstRun&&function(){if(!W[F])return;ge(F,N.mode),W[F].firstRun=!1}(),f){case"close":re(s);break;case a:g=m(6),L("onMessage",{iframe:N.iframe,message:JSON.parse(g)});break;case"mouseenter":O("onMouseEnter");break;case"mouseleave":O("onMouseLeave");break;case"beforeUnload":U(F,"Ready state reset"),W[F].initialised=!1;break;case o:W[F].autoResize=JSON.parse(m(9));break;case"scrollBy":!function(){const t=N.width,i=N.height,o=window.parentIframe||window.parentIFrame||window;U(F,`scrollBy: x: %c${t}%c y: %c${i}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),o.scrollBy(t,i)}();break;case"scrollTo":M(!1);break;case"scrollToOffset":M(!0);break;case c:T();break;case d:I();break;case"pageInfoStop":k();break;case"parentInfoStop":H();break;case"inPageLink":!function(t){const i=t.split("#")[1]||"",o=decodeURIComponent(i);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const t=x(n);U(F,`Moving to in page link: %c#${i}`,e.HIGHLIGHT),te.position={x:t.x,y:t.y},R(F),window.location.hash=i}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(i)}()}(m(9));break;case"title":!function(t,i){W[i]?.syncTitle&&(W[i].iframe.title=t,U(i,`Set iframe title attribute: %c${t}`,e.HIGHLIGHT))}(l,F);break;case u:ce(N);break;case n:r(),function(e){try{W[e].sameOrigin=!!W[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){W[e].sameOrigin=!1}}(F),(h=l)!==t&&(void 0!==h||Y(F,"<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")),W[F].initialised=!0,L("onReady",s);break;default:if(0===p&&0===i)return void q(F,`Unsupported message received (${f}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===p||0===i)return;if(document.hidden)return;r()}var h,g}function E(e){if(!W[e])throw new Error(`${N.type} No settings for ${e}. Message was: ${C}`)}let C=i.data;if("[iFrameResizerChild]Ready"===C)return A=i.source,void Object.values(W).forEach((e=>({initChild:t,initialised:i,postMessageTarget:o})=>{i||e!==o||t()})(A));var A;if(!(e=>y===`${e}`.slice(0,13)&&e.slice(13).split(":")[0]in W)(C)){if("string"!=typeof C)return;return void Z("parent","ignoredMessage")}const N=function(e){const t=e.slice(13).split(":"),i=t[1]?Number(t[1]):0,o=W[t[0]]?.iframe,n=getComputedStyle(o),r={iframe:o,id:t[0],height:i+l(n)+h(n),width:Number(t[2]),type:t[3],msg:t[4]};return t[5]&&(r.mode=t[5]),r}(C),{id:G,type:B}=N,F=G;F?(Z(F,B),X(F,function(e){E(F),N.type in{true:1,false:1,undefined:1}||(null!==N.iframe||(q(F,`The iframe (${N.id}) was not found.`),0))&&function(){const{origin:e,sameOrigin:t}=i;if(t)return!0;let o=W[F]?.checkOrigin;if(o&&"null"!=`${e}`&&!(o.constructor===Array?function(){let t=0,i=!1;for(;t<o.length;t++)if(o[t]===e){i=!0;break}return i}():function(){const t=W[F]?.remoteHost;return e===t}()))throw new Error(`Unexpected message received from: ${e} for ${N.iframe.id}. Message was: ${i.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&S()})(C)):q("","iframeResizer received messageData without id, message was: ",C)}function oe(e,t,i){let o=null,n=null;if(W[e]){if(o=W[e][t],"function"!=typeof o)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{n=o(i)}catch(i){console.error(i),q(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(o,i)}return n}function ne(e){const{id:t}=e;delete W[t],delete e.iframeResizer}function re(e){const{id:t}=e;if(!1!==oe(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){q(t,e)}oe(t,"onAfterClose",t),ne(e)}}function se(e){null===te.position&&(te.position={x:window.scrollX,y:window.scrollY})}function ae(){te.position=null}function le(t){null!==te.position&&(window.scrollTo(te.position.x,te.position.y),U(t,`Set page position: %c${te.position.x}%c, %c${te.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),ae())}function ce(e){se(e.id),de(e),fe(u,u,e.id)}function de(t){function i(i){const n=`${t[i]}px`;t.iframe.style[i]=n,U(o,`Set ${i}: %c${n}`,e.HIGHLIGHT)}const{id:o}=t,{sizeHeight:n,sizeWidth:r}=W[o];n&&i("height"),r&&i("width")}const ue=e=>e.split(":").filter((e,t)=>19!==t).join(":");function fe(t,i,o){function n(n){const r=t in v?ue(i):i;U(o,n,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),U(o,`Message data: %c${r}`,e.HIGHLIGHT)}Z(o,t),W[o]&&(W[o]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:r,sameOrigin:s,targetOrigin:a}=W[o];if(s)try{return e.contentWindow.iframeChildListener(y+i),void n(`Sending message to iframe %c${o}%c via same origin%c`)}catch(e){t in v?W[o].sameOrigin=!1:q(o,"Same origin messaging failed, falling back to postMessage")}n(`Sending message to iframe: %c${o}%c targetOrigin: %c${a}`),r.postMessage(y+i,a)}():q(o,`Iframe(${o}) not found`))}let pe=0,he=!1,me=!1;function ge(i,o=-3){if(he)return;const n=Math.max(W[i].mode,o);if(n>W[i].mode&&(W[i].mode=n),n<0)throw V(i),W[i].vAdvised||Y(i||"Parent",`${O(n+2)}${O(2)}`),W[i].vAdvised=!0,O(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>0&&me||function(t,i){queueMicrotask(()=>console.info(`%ciframe-resizer ${t}`,G||i<1?"font-weight: bold;":e.NORMAL))}(`v${t} (${(e=>k(M[e]))(n)})`,n),n<1&&Y("Parent",O(3)),he=!0}function ye(){!0!==document.hidden&&((e,t)=>{Object.values(W).filter(({autoResize:e,firstRun:t})=>e&&!t).forEach(({iframe:i})=>fe(e,t,i.id))})("tabVisible",f)}const be=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{j(window,a,ie),j(document,"visibilitychange",ye),window.iframeParentListener=e=>setTimeout(()=>ie({data:e,sameOrigin:!0}))});return t=>c=>{function d(){if(W[H]){const{iframe:e}=W[H],t={close:re.bind(null,e),disconnect:ne.bind(null,e),removeListeners(){Y(H,"<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize(){Y(H,"<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."),fe.bind(null,"Window resize",f,H)},moveToAnchor(e){((e,t,i)=>{if(typeof e!==t)throw new TypeError(`${i} is not a ${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,"string","moveToAnchor(anchor) anchor"),fe("Move to anchor",`moveToAnchor:${e}`,H)},sendMessage(e){e=JSON.stringify(e),fe(a,`${a}:${e}`,H)}};e.iframeResizer=t,e.iFrameResizer=t}}function u(e,t){const{waitForLoad:i}=W[e],o=i=>()=>{W[e]&&!0!==W[e].initialised&&(fe(i,t,e),Q(e,W),W[e].firstRun||W[H]?.heightCalculationMethod in b&&ce({iframe:c,height:1,width:1,type:n}))},a=o(l);j(c,s,()=>setTimeout(a,1)),W[e].initChild=o(r),!0!==i&&((e=>{const{src:t,srcdoc:i}=e;return!i&&(null==t||""===t||"about:blank"===t)})(c)?setTimeout(()=>{Z(e,"noContent"),U(e,"No content detected in the iframe, delaying initialisation")}):setTimeout(o(n)))}function p(e){return e?(("sizeWidth"in e||"sizeHeight"in e||o in e)&&Y(H,`<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>"${m}"</>, <i>"${g}"</> or <i>"${h}"</>.\n`),e):{}}function y(e){const t=W[e]?.iframe?.title;return""===t||void 0===t}function v(e,t){S(W[H],e)&&(Y(H,`<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</>.`),W[H][t]=W[H][e],delete W[H][e])}const $=e=>S(e,"onMouseEnter")||S(e,"onMouseLeave");function I(t){var i,o;W[H]={...W[H],iframe:c,remoteHost:c?.src.split("/").slice(0,3).join("/"),...ee,...p(t),mouseEvents:$(t),mode:L(t),syncTitle:y(H)},v("offset","offsetSize"),v("onClose","onBeforeClose"),v("onClosed","onAfterClose"),Z(H,"setup"),function(){const{direction:e}=W[H];switch(e){case m:break;case g:W[H].sizeHeight=!1;case"both":W[H].sizeWidth=!0;break;case h:W[H].sizeWidth=!1,W[H].sizeHeight=!1,W[H].autoResize=!1;break;default:throw new TypeError(H,`Direction value of "${e}" is not valid`)}}(),(i=t?.offsetSize||t?.offset)&&(W[H].direction===m?W[H].offsetHeight=i:W[H].offsetWidth=i),function(e){e?.offset&&Y(H,"<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</>.")}(t),W[H].warningTimeout||U(H,"warningTimeout:%c disabled",e.HIGHLIGHT),null===W[H].postMessageTarget&&(W[H].postMessageTarget=c.contentWindow),W[H].targetOrigin=!0===W[H].checkOrigin?""===(o=W[H].remoteHost)||null!==o.match(/^(about:blank|javascript:|file:\/\/)/)?"*":o:"*"}const k=()=>i in c,H=function(e){if(e&&"string"!=typeof e)throw new TypeError("Invalid id for iFrame. Expected String");return""!==e&&e||(e=function(){let e=t?.id||ee.id+pe++;return null!==document.getElementById(e)&&(e+=pe++),e}(),c.id=e,Z(e,"assignId")),e}(c.id);if("object"!=typeof t)throw new TypeError("Options is not an object");return function(e){const{search:t}=window.location;t.includes("ifrlog")&&(e.log=z,e.logExpand=t.includes("ifrlog=expanded"))}(t),function(e,t){const i=S(t,"log"),o="string"==typeof t.log,n=i?!!o||t.log:ee.log;S(t,"logExpand")||(t.logExpand=i&&o?t.log===w:ee.logExpand),function(e){-1===e?.log&&(e.log=!1,me=!0)}(t),function({enabled:e,expand:t,iframeId:i}){const o=A({expand:t,label:F(i)});G=e,W[i]||(W[i]={console:o})}({enabled:n,expand:t.logExpand,iframeId:e}),o&&!(t.log in T)&&J(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=n}(H,t),X(H,function(e){k()?q(H,`Ignored iframe (${H}), already setup.`):(I(e),function(){if(he)return;const{mode:e}=W[H];-1!==e&&ge(H,e)}(),be(),function(){switch(c.style.overflow=!1===W[H]?.scrolling?"hidden":"auto",W[H]?.scrolling){case"omit":break;case!0:c.scrolling="yes";break;case!1:c.scrolling="no";break;default:c.scrolling=W[H]?W[H].scrolling:"no"}}(),function(){const{bodyMargin:e}=W[H];"number"!=typeof e&&"0"!==e||(W[H].bodyMargin=`${e}px`)}(),u(H,function(e){const t=W[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,te.version,t.mode,"",t.logExpand].join(":")}(H)),d())})(t),c?.iframeResizer}});
20
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("auto-console-group")):"function"==typeof define&&define.amd?define(["auto-console-group"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).createResizer=t(e.acg)}(this,function(e){"use strict";const t="5.5.7",i="iframeResizer",o=":",n="autoResize",r="init",s="iframeReady",a="load",l="message",c="onload",u="pageInfo",d="parentInfo",f="reset",p="resize",h="scroll",m="child",g="parent",y="string",b="object",v="function",z="auto",w="none",T="vertical",j="horizontal",$="[iFrameSizer]",I=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),k=Object.freeze({[c]:1,[r]:1,[s]:1}),H="expanded",x="collapsed",M=Object.freeze({[H]:1,[x]:1}),R=(e,t,i,o)=>e.addEventListener(t,i,o||!1),O=(e,t,i)=>e.removeEventListener(t,i,!1),L=e=>{if(!e)return"";let t=-559038744,i=1103547984;for(let o,n=0;n<e.length;n++)o=e.codePointAt(n),t=Math.imul(t^o,2246822519),i=Math.imul(i^o,3266489917);return t^=Math.imul(t^i>>>15,1935289751),i^=Math.imul(i^t>>>15,3405138345),t^=i>>>16,i^=t>>>16,(2097152*(i>>>0)+(t>>>11)).toString(36)},S=e=>e.replace(/[A-Za-z]/g,e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26)),E=["spjluzl","rlf","clyzpvu"],W=["<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."],C=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],A=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map((e,t)=>[e,Math.max(0,t-1)])),N=e=>S(W[e]),G=e=>{const t=e[S(E[0])]||e[S(E[1])]||e[S(E[2])];if(!t)return-1;const i=t.split("-");let o=function(e=""){let t=-2;const i=L(S(e));return i in A&&(t=A[i]),t}(i[0]);return 0===o||(e=>e[2]===L(e[0]+e[1]))(i)||(o=-2),o},B=Object.hasOwn||((e,t)=>Object.prototype.hasOwnProperty.call(e,t)),F=e=>e,P=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)),D={},U=(q=e,q?.__esModule?q.default:q);var q;let J=!0;const Z=U({expand:!1,label:g}),V=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const X=e=>(t,...i)=>D[t]?D[t].console[e](...i):Z[e](...i);var Y;const _=(Y="log",(e,...t)=>!0===(e=>D[e]?D[e].log:J)(e)?X(Y)(e,...t):null),K=X("warn"),Q=X("error"),ee=X("event"),te=X("purge"),ie=X("errorBoundary");const oe=(e,...t)=>D[e]?D[e].console.warn(P(F)(...t)):queueMicrotask(()=>console?.warn(P((e=>(...t)=>[`${i}(${e})`,...t].join(" "))(e))(...t))),ne=(e=>(t,i="renamed to")=>(o,n,r="",s="")=>e(s,`<rb>Deprecated ${t}(${o.replace("()","")})</>\n\nThe <b>${o}</> ${t.toLowerCase()} has been ${i} <b>${n}</>. ${r}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`))(oe),re=ne("Option");function se(e,t){const{msgTimeout:i,warningTimeout:o}=t[e];o&&(i&&clearTimeout(i),t[e].msgTimeout=setTimeout(function(){if(void 0===t[e])return;const{initialised:i,loadErrorShown:o}=t[e];t[e].msgTimeout=void 0,i||o||(t[e].loadErrorShown=!0,function(e,t){const{iframe:i,waitForLoad:o}=t[e],{sandbox:n}=i,r=typeof n===b&&n.length>0&&!(n.contains("allow-scripts")&&n.contains("allow-same-origin"));ee(e,"noResponse"),oe(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))},o))}const ae=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:T,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 D[e.id].onInit===v&&(re("init()","onReady()","",e.id),D[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),le={position:null,version:t};function ce(i){function s(){ye(B),me(U),W("onResized",B)}function c(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function m(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}const b=e=>N.slice(N.indexOf(o)+7+e);const v=(e,t)=>(i,o)=>{const n={};var r,s;r=function(){ve(`${i} (${e})`,`${e}:${t()}`,o)},n[s=o]||(r(),n[s]=requestAnimationFrame(()=>{n[s]=null}))},z=(e,t)=>()=>{let i=!1;const o=t=>()=>{D[c]?i&&i!==t||(e(t,c),i=t,requestAnimationFrame(()=>{i=!1})):l()},n=o(h),r=o("resize window");function s(e,t){t(window,h,n),t(window,p,r)}function l(){ee(c,`stop${t}`),s(0,O),u.disconnect(),d.disconnect(),O(D[c].iframe,a,l)}const c=U,u=new ResizeObserver(o("pageObserver")),d=new ResizeObserver(o("iframeObserver"));D[c]&&(D[c][`stop${t}`]=l,R(D[c].iframe,a,l),s(0,R),u.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),d.observe(D[c].iframe,{attributes:!0,childList:!1,subtree:!1}))},w=e=>()=>{e in D[U]&&(D[U][e](),delete D[U][e])},T=v(u,function(){const e=document.body.getBoundingClientRect(),t=B.iframe.getBoundingClientRect(),{scrollY:i,scrollX:o,innerHeight:n,innerWidth:r}=window,{clientHeight:s,clientWidth:a}=document.documentElement;return JSON.stringify({iframeHeight:t.height,iframeWidth:t.width,clientHeight:Math.max(s,n||0),clientWidth:Math.max(a,r||0),offsetTop:parseInt(t.top-e.top,10),offsetLeft:parseInt(t.left-e.left,10),scrollTop:i,scrollLeft:o,documentHeight:s,documentWidth:a,windowHeight:n,windowWidth:r})}),j=v(d,function(){const{iframe:e}=B,{scrollWidth:t,scrollHeight:i}=document.documentElement,{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:t,scrollHeight:i},viewport:{width:o,height:n,offsetLeft:r,offsetTop:s,pageLeft:a,pageTop:l,scale:c}})}),I=z(T,"PageInfo"),k=z(j,"ParentInfo"),H=w("stopPageInfo"),x=w("stopParentInfo");function M(e){const t=e.getBoundingClientRect();return pe(),{x:Number(t.left)+Number(le.position.x),y:Number(t.top)+Number(le.position.y)}}function L(t){const i=t?M(B.iframe):{x:0,y:0};_(U,`Reposition requested (offset x:%c${i.x}%c y:%c${i.y})`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT);const o=((e,t)=>({x:e.width+t.x,y:e.height+t.y}))(B,i),n=window.parentIframe||window.parentIFrame;n?function(e,i){setTimeout(()=>e["scrollTo"+(t?"Offset":"")](i.x,i.y))}(n,o):function(e){le.position=e,S(U)}(o)}function S(e){const{x:t,y:i}=le.position,o=D[e]?.iframe;!1!==W("onScroll",{iframe:o,top:i,left:t,x:t,y:i})?me(e):he()}function E(e){let t={};if(0===B.width&&0===B.height){const e=b(9).split(o);t={x:e[1],y:e[0]}}else t={x:B.width,y:B.height};W(e,{iframe:B.iframe,screenX:Number(t.x),screenY:Number(t.y),type:B.type})}const W=(e,t)=>ue(U,e,t);function C(){const{height:i,iframe:o,msg:a,type:c,width:p}=B;switch(D[U]?.firstRun&&function(){if(!D[U])return;je(U,B.mode),D[U].firstRun=!1}(),c){case"close":fe(o);break;case l:m=b(6),W("onMessage",{iframe:B.iframe,message:JSON.parse(m)});break;case"mouseenter":E("onMouseEnter");break;case"mouseleave":E("onMouseLeave");break;case"beforeUnload":_(U,"Ready state reset"),D[U].initialised=!1;break;case n:D[U].autoResize=JSON.parse(b(9));break;case"scrollBy":!function(){const t=B.width,i=B.height,o=window.parentIframe||window.parentIFrame||window;_(U,`scrollBy: x: %c${t}%c y: %c${i}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),o.scrollBy(t,i)}();break;case"scrollTo":L(!1);break;case"scrollToOffset":L(!0);break;case u:I();break;case d:k();break;case"pageInfoStop":H();break;case"parentInfoStop":x();break;case"inPageLink":!function(t){const i=t.split("#")[1]||"",o=decodeURIComponent(i);let n=document.getElementById(o)||document.getElementsByName(o)[0];n?function(){const t=M(n);_(U,`Moving to in page link: %c#${i}`,e.HIGHLIGHT),le.position={x:t.x,y:t.y},S(U),window.location.hash=i}():window.top!==window.self&&function(){const e=window.parentIframe||window.parentIFrame;e&&e.moveToAnchor(i)}()}(b(9));break;case"title":!function(t,i){D[i]?.syncTitle&&(D[i].iframe.title=t,_(i,`Set iframe title attribute: %c${t}`,e.HIGHLIGHT))}(a,U);break;case f:ge(B);break;case r:s(),function(e){try{D[e].sameOrigin=!!D[e]?.iframe?.contentWindow?.iframeChildListener}catch(t){D[e].sameOrigin=!1}}(U),(h=a)!==t&&(void 0!==h||oe(U,"<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")),D[U].initialised=!0,W("onReady",o);break;default:if(0===p&&0===i)return void K(U,`Unsupported message received (${c}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===p||0===i)return;if(document.hidden)return;s()}var h,m}function A(e){if(!D[e])throw new Error(`${B.type} No settings for ${e}. Message was: ${N}`)}let N=i.data;if("[iFrameResizerChild]Ready"===N)return G=i.source,void Object.values(D).forEach((e=>({initChild:t,postMessageTarget:i})=>{e===i&&t()})(G));var G;if(!(e=>$===`${e}`.slice(0,13)&&e.slice(13).split(o)[0]in D)(N)){if(typeof N!==y)return;return void ee(g,"ignoredMessage")}const B=function(e){const t=e.slice(13).split(o),i=t[1]?Number(t[1]):0,n=D[t[0]]?.iframe,r=getComputedStyle(n),s={iframe:n,id:t[0],height:i+c(r)+m(r),width:Number(t[2]),type:t[3],msg:t[4]};return t[5]&&(s.mode=t[5]),s}(N),{id:F,type:P}=B,U=F;U?(ee(U,P),ie(U,function(e){A(U),B.type in{true:1,false:1,undefined:1}||(null!==B.iframe||(K(U,`The iframe (${B.id}) was not found.`),0))&&function(){const{origin:e,sameOrigin:t}=i;if(t)return!0;let o=D[U]?.checkOrigin;if(o&&"null"!=`${e}`&&!(o.constructor===Array?function(){let t=0,i=!1;for(;t<o.length;t++)if(o[t]===e){i=!0;break}return i}():function(){const t=D[U]?.remoteHost;return e===t}()))throw new Error(`Unexpected message received from: ${e} for ${B.iframe.id}. Message was: ${i.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&C()})(N)):K("","iframeResizer received messageData without id, message was: ",N)}function ue(e,t,i){let o=null,n=null;if(D[e]){if(o=D[e][t],typeof o!==v)throw new TypeError(`${t} on iFrame[${e}] is not a function`);if("onBeforeClose"===t||"onScroll"===t)try{n=o(i)}catch(i){console.error(i),K(e,`Error in ${t} callback`)}else((e,...t)=>{setTimeout(()=>e(...t),0)})(o,i)}return n}function de(e){const{id:t}=e;delete D[t],delete e.iframeResizer}function fe(e){const{id:t}=e;if(!1!==ue(t,"onBeforeClose",t)){try{e.parentNode&&e.remove()}catch(e){K(t,e)}ue(t,"onAfterClose",t),de(e)}}function pe(e){null===le.position&&(le.position={x:window.scrollX,y:window.scrollY})}function he(){le.position=null}function me(t){null!==le.position&&(window.scrollTo(le.position.x,le.position.y),_(t,`Set page position: %c${le.position.x}%c, %c${le.position.y}`,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),he())}function ge(e){pe(e.id),ye(e),ve(f,f,e.id)}function ye(t){function i(i){const n=`${t[i]}px`;t.iframe.style[i]=n,_(o,`Set ${i}: %c${n}`,e.HIGHLIGHT)}const{id:o}=t,{sizeHeight:n,sizeWidth:r}=D[o];n&&i("height"),r&&i("width")}const be=e=>e.split(o).filter((e,t)=>19!==t).join(o);function ve(t,i,o){function n(n){const r=t in k?be(i):i;_(o,n,e.HIGHLIGHT,e.FOREGROUND,e.HIGHLIGHT),_(o,`Message data: %c${r}`,e.HIGHLIGHT)}ee(o,t),D[o]&&(D[o]?.postMessageTarget?function(){const{iframe:e,postMessageTarget:r,sameOrigin:s,targetOrigin:a}=D[o];if(s)try{return e.contentWindow.iframeChildListener($+i),void n(`Sending message to iframe %c${o}%c via same origin%c`)}catch(e){t in k?D[o].sameOrigin=!1:K(o,"Same origin messaging failed, falling back to postMessage")}n(`Sending message to iframe: %c${o}%c targetOrigin: %c${a}`),r.postMessage($+i,a)}():K(o,`Iframe(${o}) not found`))}let ze=0,we=!1,Te=!1;function je(i,o=-3){if(we)return;const n=Math.max(D[i].mode,o);if(n>D[i].mode&&(D[i].mode=n),n<0)throw te(i),D[i].vAdvised||oe(i||"Parent",`${N(n+2)}${N(2)}`),D[i].vAdvised=!0,N(n+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");n>0&&Te||function(t,i){queueMicrotask(()=>console.info(`%ciframe-resizer ${t}`,J||i<1?"font-weight: bold;":e.NORMAL))}(`v${t} (${(e=>S(C[e]))(n)})`,n),n<1&&oe("Parent",N(3)),we=!0}function $e(){!0!==document.hidden&&((e,t)=>{Object.values(D).filter(({autoResize:e,firstRun:t})=>e&&!t).forEach(({iframe:i})=>ve(e,t,i.id))})("tabVisible",p)}const Ie=(e=>{let t=!1;return function(){return t?void 0:(t=!0,Reflect.apply(e,this,arguments))}})(()=>{R(window,l,ce),R(document,"visibilitychange",$e),window.iframeParentListener=e=>setTimeout(()=>ce({data:e,sameOrigin:!0}))});return t=>u=>{function d(){D[S]?.heightCalculationMethod in I&&ge({iframe:u,height:1,width:1,type:r})}function f(){if(D[S]){const{iframe:e}=D[S],t={close:fe.bind(null,e),disconnect:de.bind(null,e),removeListeners(){oe(S,"<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize(){oe(S,"<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."),ve.bind(null,"Window resize",p,S)},moveToAnchor(e){((e,t,i)=>{if(typeof e!==t)throw new TypeError(`${i} is not a ${o=t,o.charAt(0).toUpperCase()+o.slice(1)}`);var o})(e,y,"moveToAnchor(anchor) anchor"),ve("Move to anchor",`moveToAnchor:${e}`,S)},sendMessage(e){e=JSON.stringify(e),ve(l,`${l}:${e}`,S)}};e.iframeResizer=t,e.iFrameResizer=t}}function h(e,t){const i=i=>()=>{if(!D[e])return;const{firstRun:o,iframe:n}=D[e];ve(i,t,e),(e=>e===r)(i)&&(e=>"lazy"===e.loading)(n)||se(e,D),o||d()},{iframe:o}=D[e];D[e].initChild=i(s),function(e,t){R(e,a,()=>setTimeout(t,1))}(o,i(c)),function(e,t){const{iframe:i,waitForLoad:o}=D[e];!0!==o&&((e=>{const{src:t,srcdoc:i}=e;return!i&&(null==t||""===t||"about:blank"===t)})(i)?setTimeout(()=>{ee(e,"noContent"),_(e,"No content detected in the iframe, delaying initialisation")}):setTimeout(t))}(e,i(r))}function g(e){return e?(("sizeWidth"in e||"sizeHeight"in e||n in e)&&oe(S,`<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>"${T}"</>, <i>"${j}"</> or <i>"${w}"</>.\n`),e):{}}function v(e){const t=D[e]?.iframe?.title;return""===t||void 0===t}function $(e,t){B(D[S],e)&&(oe(S,`<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</>.`),D[S][t]=D[S][e],delete D[S][e])}const k=e=>B(e,"onMouseEnter")||B(e,"onMouseLeave");function O(t){var i,o;D[S]={...D[S],iframe:u,remoteHost:u?.src.split("/").slice(0,3).join("/"),...ae,...g(t),mouseEvents:k(t),mode:G(t),syncTitle:v(S)},$("offset","offsetSize"),$("onClose","onBeforeClose"),$("onClosed","onAfterClose"),ee(S,"setup"),function(){const{direction:e}=D[S];switch(e){case T:break;case j:D[S].sizeHeight=!1;case"both":D[S].sizeWidth=!0;break;case w:D[S].sizeWidth=!1,D[S].sizeHeight=!1,D[S].autoResize=!1;break;default:throw new TypeError(S,`Direction value of "${e}" is not valid`)}}(),(i=t?.offsetSize||t?.offset)&&(D[S].direction===T?D[S].offsetHeight=i:D[S].offsetWidth=i),function(e){e?.offset&&oe(S,"<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</>.")}(t),D[S].warningTimeout||_(S,"warningTimeout:%c disabled",e.HIGHLIGHT),null===D[S].postMessageTarget&&(D[S].postMessageTarget=u.contentWindow),D[S].targetOrigin=!0===D[S].checkOrigin?""===(o=D[S].remoteHost)||null!==o.match(/^(about:blank|javascript:|file:\/\/)/)?"*":o:"*"}const L=()=>i in u,S=function(e){if(e&&typeof e!==y)throw new TypeError("Invalid id for iFrame. Expected String");return""!==e&&e||(e=function(){let e=t?.id||ae.id+ze++;return null!==document.getElementById(e)&&(e+=ze++),e}(),u.id=e,ee(e,"assignId")),e}(u.id);if(typeof t!==b)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=expanded"))}(t),function(e,t){const i=B(t,"log"),o=typeof t.log===y,n=i?!!o||t.log:ae.log;B(t,"logExpand")||(t.logExpand=i&&o?t.log===H:ae.logExpand),function(e){-1===e?.log&&(e.log=!1,Te=!0)}(t),function({enabled:e,expand:t,iframeId:i}){const o=U({expand:t,label:V(i)});J=e,D[i]||(D[i]={console:o})}({enabled:n,expand:t.logExpand,iframeId:e}),o&&!(t.log in M)&&Q(e,'Invalid value for options.log: Accepted values are "expanded" and "collapsed"'),t.log=n}(S,t),ie(S,function(e){L()?K(S,`Ignored iframe (${S}), already setup.`):(O(e),function(){if(we)return;const{mode:e}=D[S];-1!==e&&je(S,e)}(),Ie(),function(){switch(u.style.overflow=!1===D[S]?.scrolling?"hidden":z,D[S]?.scrolling){case"omit":break;case!0:u.scrolling="yes";break;case!1:u.scrolling="no";break;default:u.scrolling=D[S]?D[S].scrolling:"no"}}(),function(){const{bodyMargin:e}=D[S];"number"!=typeof e&&"0"!==e||(D[S].bodyMargin=`${e}px`)}(),h(S,function(e){const{autoResize:t,bodyBackground:i,bodyMargin:n,bodyPadding:r,heightCalculationMethod:s,inPageLinks:a,license:l,log:c,logExpand:u,mouseEvents:d,offsetHeight:f,offsetWidth:p,mode:h,sizeHeight:g,sizeWidth:y,tolerance:b,widthCalculationMethod:v}=D[e];return[e,"8",y,c,"32",!0,t,n,s,i,r,b,a,m,v,d,f,p,g,l,le.version,h,"",u].join(o)}(S)),f())})(t),u?.iframeResizer}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iframe-resizer/core",
3
- "version": "5.5.6",
3
+ "version": "5.5.7",
4
4
  "license": "GPL-3.0",
5
5
  "homepage": "https://iframe-resizer.com",
6
6
  "author": {