@iframe-resizer/child 6.0.0-beta.2 → 6.0.0-beta.4
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 +1 -1
- package/index.cjs.js +12 -27
- package/index.cjs.js.map +1 -1
- package/index.d.ts +94 -0
- package/index.esm.js +739 -931
- package/index.esm.js.map +1 -1
- package/index.umd.js +12 -29
- package/index.umd.js.map +1 -1
- package/package.json +3 -2
- package/iframe-resizer.child.d.ts +0 -168
package/README.md
CHANGED
package/index.cjs.js
CHANGED
|
@@ -1,43 +1,28 @@
|
|
|
1
|
-
"use strict";const
|
|
2
|
-
`,K="string",N="number",xn="boolean",Bn="object",be="function",Un="undefined",Vn="false",Wn="null",L="auto",Dt="readystatechange",_t="bottom",Ft="right",Ne="autoResizeEnabled",ct=Symbol("sizeChanged"),Be="manualResize",Ue="parentResize",Re={[Be]:1,[Ue]:1},xt="setOffsetSize",Bt="resizeObserver",Ve="overflowObserver",Ut="mutationObserver",Vt="visibilityObserver",qn="font-weight: bold;",We="none",at="No change in content size detected",ae="[iFrameSizer]",Wt=ae.length,Zn=L,qt=128,Zt=new Set(["head","body","meta","base","title","script","link","style","map","area","option","optgroup","template","track","wbr","nobr"]),Yn=e=>(t,n="renamed to")=>(o,r,d="",a="")=>e(a,`<rb>Deprecated ${t}(${o.replace("()","")})</>
|
|
1
|
+
"use strict";const o=require("@iframe-resizer/common/consts"),bt=require("@iframe-resizer/common/deprecate"),wt=require("@iframe-resizer/common/format-advise"),u=require("@iframe-resizer/common/utils"),s=require("auto-console-group"),E=require("@iframe-resizer/common/mode");let me=!0,Ne=o.LABEL;const vt=u.esModuleInterop(s),x=vt({label:`${o.LABEL}(child)`,expand:!1});function yt(e){Ne=e.id||o.LABEL,x.label(`${Ne}`),x.expand(e.expand),me=e.enabled}const Qe=e=>(...t)=>me?x[e](...t):!0,d=Qe("log"),f=d,J=Qe("debug");function Ht(e,t){console.info(`%ciframe-resizer ${e}`,me||t<1?o.BOLD:s.NORMAL)}const{assert:At,endAutoGroup:$,error:Ke,errorBoundary:he,event:I,label:br,purge:wr,warn:C}=x,Je=wt(u.id),b=(...e)=>x.warn(...e.map(Je)),Nt=(...e)=>console.warn(...e.map(Je)),Ee=bt((e,t)=>b(t));Ee("Method");Ee("Method","replaced with");Ee("Option");const Ie=[];function Xe(e,t){d(`${e} event listener: %c${t}`,s.HIGHLIGHT)}const et=(e,t,n,r)=>{e.removeEventListener(t,n,r),Xe("Removed",t)},G=(e,t,n,r=!1)=>{e.addEventListener(t,n,r),Ie.push(()=>et(e,t,n,r)),Xe("Added",t)},c={applySelectors:null,firstRun:!0,hasTags:!1,hasOverflow:!1,height:0,isHidden:!1,initLock:!0,inPageLinks:{},origin:void 0,hasOverflowUpdated:!0,overflowedNodeSet:new Set,sameOrigin:!1,taggedElements:[],target:window?.parent,timerActive:!1,totalTime:0,triggerLocked:!1,width:0,win:window,onPageInfo:null,onParentInfo:null};let Me=!1;function Le(e){const t=window?.iframeResizer?.targetOrigin||"*",n=Array.isArray(t)?t:[t];for(const r of n)e.postMessage(o.CHILD_READY_MESSAGE,r)}function Ge(){if(document.readyState==="loading"||!c.firstRun||Me)return;const{parent:e,top:t}=window;I("ready"),d("Sending%c ready%c to parent from",s.HIGHLIGHT,s.FOREGROUND,window.location.href),Le(e),e!==t&&Le(t),Me=!0}const ze="iframeResize",Mt=e=>o.MESSAGE_ID===`${e.data}`.slice(0,o.MESSAGE_ID_LENGTH),Lt=()=>ze in window||window.jQuery!==void 0&&ze in window.jQuery.prototype,Gt=e=>e.data.split(o.SEPARATOR)[2]in{true:1,false:1},zt=()=>[document.documentElement,document.body],$t=["min-height","min-width","max-height","max-width"],$e=new Set,_t=e=>!!e&&e!=="0px"&&e!==o.AUTO&&e!==o.NONE,tt=e=>e.tagName?e.tagName.toLowerCase():"unknown",nt=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),kt=(e,t)=>_t(nt(e,t));function Ct(e,t){const n=e.style.getPropertyValue(t);return n?{source:"an inline style attribute",value:n}:null}function Dt({href:e}){$e.has(e)||(d("Unable to access stylesheet:",e),$e.add(e))}function Pt(e,t){for(const n of document.styleSheets)try{for(const r of n.cssRules||[]){if(!("selectorText"in r))continue;const i=r;if(!e.matches(i.selectorText))continue;const g=i.style.getPropertyValue(t);if(!g)continue;const{ownerNode:l}=n;return{source:l instanceof Element&&l.tagName==="STYLE"?"an inline <style> block":`stylesheet (${n.href})`,value:g}}}catch{Dt(n)}return{source:"cross-origin stylesheet",value:nt(e,t)}}const Bt=(e,t)=>Ct(e,t)||Pt(e,t),Ft=(e,t)=>{const{source:n,value:r}=Bt(e,t),i=tt(e);b(`The <b>${t}</> CSS property is set to <b>${r}</> on the <b><${i}></> element via ${n}. This may cause issues with the correct operation of <i>iframe-resizer</>.
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
`,rb:"\x1B[31;1m",bb:"\x1B[34;1m",b:"\x1B[1m",i:"\x1B[3m",u:"\x1B[4m","/":"\x1B[m"},to=Object.keys(Jt),no=new RegExp(`<(${to.join("|")})>`,"gi"),oo=(e,t)=>Jt[t]??"",ro=e=>e.replace(no,oo),so=e=>e.replaceAll("<br>",xe).replaceAll(/<\/?[^>]+>/gi,""),io=e=>t=>e(Qn(t)?window.chrome?ro(t):so(t):t);let qe=!0,Ge=Fe;const co=eo(s),Q=co({label:`${Fe}(child)`,expand:!1});function ao(e){Ge=e.id||Fe,Q.label(`${Ge}`),Q.expand(e.expand),qe=e.enabled}const Kt=e=>(...t)=>qe?Q[e](...t):!0,l=Kt("log"),u=l,de=Kt("debug");function lo(e,t){console.info(`${Ge} %ciframe-resizer ${e}`,qe||t<1?qn:s.NORMAL)}const{assert:uo,endAutoGroup:_,error:Xt,errorBoundary:Ze,event:h,label:Ei,purge:Si,warn:D}=Q,fo=io(le),p=(...e)=>Q.warn(...e.map(fo)),Ye=Yn((e,t)=>p(t)),en=Ye("Method"),mo=Ye("Method","replaced with"),ho=Ye("Option"),Qe=[];function tn(e,t){l(`${e} event listener: %c${t}`,s.HIGHLIGHT)}const nn=(e,t,n,o)=>{e.removeEventListener(t,n,o),tn("Removed",t)},G=(e,t,n,o=!1)=>{e.addEventListener(t,n,o),Qe.push(()=>nn(e,t,n,o)),tn("Added",t)},i={applySelectors:null,firstRun:!0,hasTags:!1,hasOverflow:!1,height:0,isHidden:!1,initLock:!0,inPageLinks:{},origin:void 0,hasOverflowUpdated:!0,overflowedNodeSet:new Set,sameOrigin:!1,taggedElements:[],target:window?.parent,timerActive:!1,totalTime:0,triggerLocked:!1,width:0,win:window,onPageInfo:null,onParentInfo:null};let dt=!1;function ut(e){const t=window?.iframeResizer?.targetOrigin||"*",n=Array.isArray(t)?t:[t];for(const o of n)e.postMessage($n,o)}function ft(){if(document.readyState==="loading"||!i.firstRun||dt)return;const{parent:e,top:t}=window;h("ready"),l("Sending%c ready%c to parent from",s.HIGHLIGHT,s.FOREGROUND,window.location.href),ut(e),e!==t&&ut(t),dt=!0}const mt="iframeResize",go=e=>ae===`${e.data}`.slice(0,Wt),po=()=>mt in window||window.jQuery!==void 0&&mt in window.jQuery.prototype,yo=e=>e.data.split(ge)[2]in{true:1,false:1},vo=()=>[document.documentElement,document.body],bo=["min-height","min-width","max-height","max-width"],ht=new Set,zo=e=>!!e&&e!=="0px"&&e!==L&&e!==We,on=e=>e.tagName?e.tagName.toLowerCase():"unknown",rn=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),wo=(e,t)=>zo(rn(e,t));function Io(e,t){const n=e.style.getPropertyValue(t);return n?{source:"an inline style attribute",value:n}:null}function Oo({href:e}){ht.has(e)||(l("Unable to access stylesheet:",e),ht.add(e))}function Eo(e,t){for(const n of document.styleSheets)try{for(const o of n.cssRules||[]){if(!("selectorText"in o))continue;const r=o;if(!e.matches(r.selectorText))continue;const d=r.style.getPropertyValue(t);if(!d)continue;const{ownerNode:a}=n;return{source:a instanceof Element&&a.tagName==="STYLE"?"an inline <style> block":`stylesheet (${n.href})`,value:d}}}catch{Oo(n)}return{source:"cross-origin stylesheet",value:rn(e,t)}}const So=(e,t)=>Io(e,t)||Eo(e,t),To=(e,t)=>{const{source:n,value:o}=So(e,t),r=on(e);p(`The <b>${t}</> CSS property is set to <b>${o}</> on the <b><${r}></> element via ${n}. This may cause issues with the correct operation of <i>iframe-resizer</>.
|
|
6
|
-
|
|
7
|
-
If you wish to restrict the size of the iframe, then you should set this property on the iframe element itself, not the content inside it.`)};function Ro(){for(const e of vo())for(const t of bo)l(`Checking <${on(e)}> for blocking CSS: ${t}`),wo(e,t)&&To(e,t)}const Ho=({calculateWidth:e,calculateHeight:t})=>e===t,c={autoResize:!0,bodyBackground:"",bodyMargin:0,bodyMarginStr:"",bodyPadding:"",calculateHeight:!0,calculateWidth:!1,heightCalcMode:L,ignoreSelector:"",inPageLinks:!1,logging:!1,logExpand:!1,mode:0,mouseEvents:!1,offsetHeight:0,offsetWidth:0,parentId:void 0,sizeSelector:"",targetOrigin:"*",tolerance:0,widthCalcMode:L,onBeforeResize:void 0,onMessage:()=>{D("onMessage function not defined")},onReady:()=>{}},M=[s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT],ie={height:0,width:0},x={height:0,width:0};function F(e,t,n){return x[e]=t,ie[e]=n,t}function Mo(e){const t=e.getOffset();return t!==0&&u(`Page offsetSize: %c${t}px`,s.HIGHLIGHT),t}const $o=e=>e.documentElementScroll()+Math.max(0,e.getOffset());function sn(e){const{hasOverflow:t,hasTags:n,triggerLocked:o}=i,r=e.label,d=r===ve,a=e.boundingClientRect(),f=Math.ceil(a),b=Math.floor(a),m=$o(e),z=`HTML: %c${a}px %cPage: %c${m}px`;let g;switch(!0){case!e.enabled():return Math.max(m,Y);case n:u("Found element with data-iframe-size attribute"),g=e.taggedElement();break;case(!t&&i.firstRun&&x[r]===0&&ie[r]===0):u(`Initial page size values: ${z}`,...M),g=F(r,a,m);break;case(o&&a===x[r]&&m===ie[r]):u(`Size unchanged: ${z}`,...M),g=Math.max(a,m);break;case(a===0&&m!==0):u(`Page is hidden: ${z}`,...M),g=m;break;case(!t&&a!==x[r]&&m<=ie[r]):u(`New <html> size: ${z} `,...M),u(`Previous <html> size: %c${x[r]}px`,s.HIGHLIGHT),g=F(r,a,m);break;case!d:g=e.taggedElement();break;case(!t&&a<x[r]):u(`<html> size decreased: ${z}`,...M),g=F(r,a,m);break;case(m===b||m===f):u(`<html> size equals page size: ${z}`,...M),g=F(r,a,m);break;case a>m:u(`Page size < <html> size: ${z}`,...M),g=F(r,a,m);break;case t:u("Found elements possibly overflowing <html> "),g=e.taggedElement();break;default:u(`Using <html> size: ${z}`,...M),g=F(r,a,m)}return u(`Content ${r}: %c${g}px`,s.HIGHLIGHT),g+=Mo(e),Math.max(g,Y)}const Ao=1e3,Lo=5*Ao,ko=4,No=10,Go=100,Je="--ifr-start",ue="--ifr-end",cn="--ifr-measure",v=[];let ce={},gt=0,Pe;function an(){try{performance.clearMarks(Je),performance.clearMarks(ue),performance.clearMeasures(cn)}catch{}}function Po(){Pe=setInterval(()=>{if(v.length<No||ce.hasTags&&ce.len<25)return;v.sort();const e=Math.min(v.reduce((n,o)=>n+o,0)/v.length,v[Math.floor(v.length/2)]),t=C(e);t>gt&&(gt=t,h("performanceObserver"),l("Mean time:",C(v[Math.floor(v.length/2)])),l("Median time:",C(v.reduce((n,o)=>n+o,0)/v.length)),l("Average time:",t),l("Max time:",C(Math.max(...v)))),an(),!(e<=ko)&&(clearInterval(Pe),p(`<rb>Performance Warning</>
|
|
8
|
-
|
|
9
|
-
Calculating the page size is taking an excessive amount of time (${C(e)}ms).
|
|
10
|
-
|
|
11
|
-
To improve performance add the <b>data-iframe-size</> attribute to the ${ce.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},Lo)}function Co(e){e.getEntries().forEach(t=>{if(t.name===ue)try{const{duration:n}=performance.measure(cn,Je,ue);ce=t.detail,v.push(n),v.length>Go&&v.shift()}catch{}})}function jo(){u("Attached%c PerformanceObserver%c to page",s.HIGHLIGHT,s.FOREGROUND);const e=new PerformanceObserver(Co);return e.observe({entryTypes:["mark"]}),Po(),{disconnect:()=>{an(),clearInterval(Pe),e.disconnect(),u("Detached%c PerformanceObserver",s.HIGHLIGHT)}}}const Do=e=>`:not(${e})`,_o=`* ${Array.from(Zt).map(Do).join("")}`,Ke=e=>e.querySelectorAll(_o);function Fo(){const{hasOverflow:e,hasTags:t,overflowedNodeSet:n,taggedElements:o}=i;return t?o:e?Array.from(n):Ke(document.documentElement)}function xo(e,t){const n=`margin-${t}`;let o,r=document.documentElement,d=i.hasTags?Y:document.documentElement.getBoundingClientRect().bottom;for(const a of e)o=a.getBoundingClientRect()[t]+parseFloat(getComputedStyle(a).getPropertyValue(n)),o>d&&(d=o,r=a);return{maxEl:r,maxVal:d}}function ln(e){performance.mark(Je);const t=Qt(e),{logging:n}=c,{hasTags:o}=i,r=Fo(),{maxEl:d,maxVal:a}=xo(r,e);return u(`${t} position calculated from:`,d),u(`Checked %c${r.length}%c elements`,s.HIGHLIGHT,s.FOREGROUND),performance.mark(ue,{detail:{hasTags:o,len:r.length,logging:n,Side:t}}),a}const we={label:ve,enabled:()=>c.calculateHeight,getOffset:()=>c.offsetHeight,auto:()=>sn(we),boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),documentElementScroll:()=>document.documentElement.scrollHeight,taggedElement:()=>ln(_t)},Ie={label:jt,enabled:()=>c.calculateWidth,getOffset:()=>c.offsetWidth,auto:()=>sn(Ie),boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),documentElementScroll:()=>document.documentElement.scrollWidth,taggedElement:()=>ln(Ft)};function dn(e,t){const{label:n}=t;return e&&e!==L&&p(`<rb>Ignored ${n}CalculationMethod (${e})</>
|
|
12
|
-
|
|
13
|
-
This version of <i>iframe-resizer</> auto detects the most suitable ${n} calculation method. The <b>${n}CalculationMethod</> option is no longer supported and has been ignored.
|
|
14
|
-
|
|
15
|
-
To remove this warning, delete the <b>${n}CalculationMethod</> option from your parent page config and/or the <i>window.iframeResizer</> config on the child page.
|
|
16
|
-
`),l(`Set ${n} calculation method: %c${L}`,s.HIGHLIGHT),L}function Bo(){c.heightCalcMode=dn(c.heightCalcMode,we)}function Uo(){c.widthCalcMode=dn(c.widthCalcMode,Ie)}function Vo(){try{i.sameOrigin=c.mode===1||"iframeParentListener"in window.parent}catch{l("Cross domain iframe detected")}}const Wo=`<rb>Deprecated Attributes</>
|
|
17
|
-
|
|
18
|
-
The <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.`;function qo(){let e=!1;const t=n=>document.querySelectorAll(`[${n}]`).forEach(o=>{o.toggleAttribute(ye,!0),o.removeAttribute(n),e=!0});t("data-iframe-height"),t("data-iframe-width"),e&&p(Wo)}let pt=0;function Zo(e){const t=e.length===1?"":"s";D(`%c[${J}]%c found on %c${e.length}%c element${t}`,s.BOLD,s.NORMAL,s.BOLD,s.NORMAL)}function Yo(){const e=document.querySelectorAll(`*[${J}]`),t=e.length>0;return t&&e.length!==pt&&(Zo(e),pt=e.length),t}const fe=e=>{if(!e)return"";let t=-559038744,n=1103547984;for(let o,r=0;r<e.length;r++)o=e.codePointAt(r),t=Math.imul(t^o,2246822519),n=Math.imul(n^o,3266489917);return t^=Math.imul(t^n>>>15,1935289751),n^=Math.imul(n^t>>>15,3405138345),t^=n>>>16,n^=t>>>16,(2097152*(n>>>0)+(t>>>11)).toString(36)},H=e=>e.replace(/[A-Za-z]/g,t=>String.fromCodePoint((t<="Z"?90:122)>=(t=t.codePointAt(0)+19)?t:t-26)),Qo=new Date,un=e=>new Set(Array.from({length:9},e)),yt=" - lewpylk",B=["spjluzl","rlf","clyzpvu","rlf2","nlaMbssFlhy"],Jo=["<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.","<yi>Clyzpvu 5 rlf klaljalk</><iy><iy>Fvb hyl jbyyluasf bzpun h spjluzl rlf mvy aol wylcpvbz clyzpvu vm <p>pmyhtl-ylzpgly</>.</><iy><iy>Av bwnyhkl av <i>Clyzpvu 6</> fvb jhu bzl aol <i>mpyza 11 johyhjalyz vm fvb spjluzl rlf</> av nla h 60% kpzjvbua ha oaawz://pmyhtl-ylzpgly.jvt/wypjpun.","<yi>Clyzpvu 5 rlf klaljalk</><iy><iy>Fvb hyl jbyyluasf bzpun h spjluzl rlf mvy aol wylcpvbz clyzpvu vm <p>pmyhtl-ylzpgly</>.<iy><iy>Av bwnyhkl av <i>Clyzpvu 6</> vm <p>pmyhtl-ylzpgly</> wslhzl kvdusvhk aol shalza rlf myvt oaawz://pmyhtl-ylzpgly.jvt/tf-vyklyz.","<yi> VLT rlf lewpylk</><iy><iy>Aol spjluzl rlf fvb hyl bzpun mvy <p>pmyhtl-ylzpgly</> pz myvt h wypvy flhy huk ohz lewpylk. Hu bwkhalk rlf pz ylslhzlk vu aol mpyza vm Uvcltily lhjo flhy.<iy><iy>Wslhzl kvdusvhk aol shalza rlf myvt oaawz://pmyhtl-ylzpgly.jvt/tf-vyklyz."],Ko=e=>[e[0],...e.slice(1).map(t=>`${t}${yt}`),`${e[4]}${yt}`,...e.slice(1)],Xo=Ko(["NWSc3","zvsv","wyv","ibzpulzz","VLT"]),vt=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5","1foobarqaz","2b5sdlfhbev","zo4ui3arjo","oclbb4thgl","igb1wzrjqr"].map((e,t)=>[e,Math.max(0,t-1)])),er=new Set([1,6]),fn=Qo[H(B[4])](),tr=un((e,t)=>fe(`${fn+t}`)),nr=un((e,t)=>fe(`${fn-++t}`)),or=e=>tr.has(e)?9:nr.has(e)?5:-2,Xe=e=>er.has(e),$=e=>H(Jo[e]),rr=e=>H(Xo[e]),bt=e=>H(B[e]),zt=e=>{const t=e[H(B[0])]||e[H(B[1])]||e[H(B[2])]||e[H(B[3])];if(!t)return-1;const n=t.split("-");let o=(function(r="",d=""){let a=-2;const f=fe(H(r));return f in vt&&(a=vt[f]),a===9?or(d):a})(...n);return o===0||(r=>r[2]===fe(r[0]+r[1]))(n)||(o=-2),o};function sr(e,t,n){if(!A(n)||t>-1&&e>t){try{if(sessionStorage.getItem("ifr")===j)return}catch{}lo(`v${j} (${rr(e)})`,e),e<2&&p($(3));try{sessionStorage.setItem("ifr",j)}catch{}}}function ir({key:e,key2:t,mode:n,version:o}){const r=n,d=A(e)?zt({key:e}):-1,a=A(t)?zt({key:t}):-1;let f;switch(n=Math.max(d,a),n){case-2:case-1:f=`${$(Math.min(d,a)+2)}${$(2)}`,i.firstRun=!1;break;case 1:case 2:case 3:f=$(6);break;case 4:f=$(7);break;case 5:f=$(8);break}if(sr(n,r,o),(!A(o)||!i.firstRun)&&(f&&p(f),n<0))throw f.split("<br>")[0].replace(/<\/?[a-z][^>]*>|<\/>/gi,"");c.mode=n}const cr="BackCompat",ar=`<rb>Quirks Mode Detected</>
|
|
3
|
+
If you wish to restrict the size of the iframe, then you should set this property on the iframe element itself, not the content inside it.`)};function Ut(){for(const e of zt())for(const t of $t)d(`Checking <${tt(e)}> for blocking CSS: ${t}`),kt(e,t)&&Ft(e,t)}const xt=({calculateWidth:e,calculateHeight:t})=>e===t,a={autoResize:!0,bodyBackground:"",bodyMargin:0,bodyMarginStr:"",bodyPadding:"",calculateHeight:!0,calculateWidth:!1,heightCalcMode:o.AUTO,ignoreSelector:"",inPageLinks:!1,logging:!1,logExpand:!1,mode:0,mouseEvents:!1,offsetHeight:0,offsetWidth:0,parentId:void 0,sizeSelector:"",targetOrigin:"*",tolerance:0,widthCalcMode:o.AUTO,onBeforeResize:void 0,onMessage:()=>{C("onMessage function not defined")},onReady:()=>{}};function Vt(){try{c.sameOrigin=a.mode===1||"iframeParentListener"in window.parent}catch{d("Cross domain iframe detected")}}let _e=0;function Wt(e){const t=e.length===1?"":"s";C(`%c[${o.IGNORE_ATTR}]%c found on %c${e.length}%c element${t}`,s.BOLD,s.NORMAL,s.BOLD,s.NORMAL)}function qt(){const e=document.querySelectorAll(`*[${o.IGNORE_ATTR}]`),t=e.length>0;return t&&e.length!==_e&&(Wt(e),_e=e.length),t}function Zt(e,t,n){(!u.isDef(n)||t>-1&&e>t)&&(Ht(`v${o.VERSION} (${E.getModeLabel(e)})`,e),e===0&&Nt(E.getModeData(3)))}function Yt({key:e,key2:t,mode:n,version:r}){const i=n,g=u.isDef(e)?E({key:e}):-1,l=u.isDef(t)?E({key:t}):-1;let m;switch(n=Math.max(g,l),n){case-2:case-1:m=`${E.getModeData(Math.min(g,l)+2)}${E.getModeData(2)}`,c.firstRun=!1;break;case 1:case 2:case 3:m=E.getModeData(6);break;case 4:m=E.getModeData(7);break;case 5:m=E.getModeData(8);break}if(n>=0&&Zt(n,i,r),(!u.isDef(r)||!c.firstRun)&&(m&&b(m),n<0))throw b(E.getModeData(9)),m.split("<br>")[0].replace(/<\/?[a-z][^>]*>|<\/>/gi,"");a.mode=n}const jt="BackCompat",Qt=`<rb>Quirks Mode Detected</>
|
|
19
4
|
|
|
20
5
|
This iframe is running in the browser's legacy <b>Quirks Mode</>, this may cause issues with the correct operation of <i>iframe-resizer</>. It is recommended that you switch to the modern <b>Standards Mode</>.
|
|
21
6
|
|
|
22
7
|
For more information see <u>https://iframe-resizer.com/quirks-mode</>.
|
|
23
|
-
`;function
|
|
8
|
+
`;function Kt(){document.compatMode===jt&&b(Qt)}const Jt="complete";let ke=!1;function ot(e){document.readyState===Jt?u.isolateUserCode(e):ke||G(document,o.READY_STATE_CHANGE,()=>ot(e)),ke=!0}const Xt=()=>{f(`Set targetOrigin for parent: %c${a.targetOrigin}`,s.HIGHLIGHT),a.autoResize!==!0&&d("Auto Resize disabled")};function rt(){c.taggedElements=document.querySelectorAll(`[${o.SIZE_ATTR}]`),c.hasTags=c.taggedElements.length>0,d(`Tagged elements found: %c${c.hasTags}`,s.HIGHLIGHT)}const en=`<rb>Legacy version detected on parent page</>
|
|
24
9
|
|
|
25
10
|
Detected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.
|
|
26
11
|
|
|
27
12
|
See <u>https://iframe-resizer.com/setup/</> for more details.
|
|
28
|
-
`,
|
|
13
|
+
`,tn=e=>`<b>Version mismatch</>
|
|
29
14
|
|
|
30
15
|
The parent and child pages are running different versions of <i>iframe resizer</>.
|
|
31
16
|
|
|
32
|
-
Parent page: ${e} - Child page: ${
|
|
33
|
-
`;function
|
|
34
|
-
|
|
17
|
+
Parent page: ${e} - Child page: ${o.VERSION}.
|
|
18
|
+
`;function nn({version:e}){!e||e===""||e===o.FALSE?b(en):e!==o.VERSION&&b(tn(e))}const on=u.once(()=>b(E.getModeData(4)));function rn(e){if(!c.timerActive)return;const t=u.round(performance.now()-c.totalTime),n=e===o.INIT?`Initialised iframe in %c${t}ms`:`Size calculated in %c${t}ms`;d(n,s.HIGHLIGHT)}function sn(e){return e===void 0?e=a.targetOrigin:d(`Message targetOrigin: %c${e}`,s.HIGHLIGHT),e}function cn(e,t){const{mode:n}=a,{sameOrigin:r,target:i}=c;if(r)try{window.parent.iframeParentListener(o.MESSAGE_ID+e)}catch(g){if(E.checkMode(n))on();else throw new Error(g);return!1}else{At(i,"Internal error: postMessage target is undefined");const g=sn(t),l=Array.isArray(g)?g:[g];for(const m of l)i.postMessage(o.MESSAGE_ID+e,m)}return!0}function st(e,t,n,r,i){const{parentId:g}=a,{sameOrigin:l}=c,m=`${e}:${t}`,S=`${g}:${m}:${n}${r===void 0?"":`:${r}`}`;a.mode<-1||!cn(S,i)||(rn(n),f(`Sending message to parent page via ${l?"sameOrigin":"postMessage"}: %c%c${S}`,s.ITALIC,s.HIGHLIGHT))}const R=he((e,t,n,r,i)=>{I(n),st(e,t,n,r,i),$()}),an=e=>R(0,0,e.type,`${e.screenY}:${e.screenX}`);function Ce(e,t){d(`Add event listener: %c${t}`,s.HIGHLIGHT),G(window.document,e,an)}function dn({mouseEvents:e}){e===!0&&(Ce(o.MOUSE_ENTER,"Mouse Enter"),Ce(o.MOUSE_LEAVE,"Mouse Leave"))}const ln=()=>R(0,0,o.BEFORE_UNLOAD);function fn({persisted:e}){e||ln(),I(o.PAGE_HIDE),f("Page persisted:",e),!e&&Ie.forEach(u.invoke)}const un=()=>G(window,u.lower(o.PAGE_HIDE),fn),De=(e,t)=>!(Math.abs(e-t)<=a.tolerance);function gn(e,t){const{calculateHeight:n,calculateWidth:r}=a,{height:i,width:g}=c;return n&&De(i,e)||r&&De(g,t)}const M=[s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT],Q={height:0,width:0},k={height:0,width:0};function _(e,t,n){return k[e]=t,Q[e]=n,t}function mn(e){const t=e.getOffset();return t!==0&&f(`Page offsetSize: %c${t}px`,s.HIGHLIGHT),t}const hn=e=>e.documentElementScroll()+Math.max(0,e.getOffset());function it(e){const{hasOverflow:t,hasTags:n,triggerLocked:r}=c,i=e.label,g=i===o.HEIGHT,l=e.boundingClientRect(),m=Math.ceil(l),S=Math.floor(l),h=hn(e),T=`HTML: %c${l}px %cPage: %c${h}px`;let p;switch(!0){case!e.enabled():return Math.max(h,o.MIN_SIZE);case n:f("Found element with data-iframe-size attribute"),p=e.taggedElement();break;case(!t&&c.firstRun&&k[i]===0&&Q[i]===0):f(`Initial page size values: ${T}`,...M),p=_(i,l,h);break;case(r&&l===k[i]&&h===Q[i]):f(`Size unchanged: ${T}`,...M),p=Math.max(l,h);break;case(l===0&&h!==0):f(`Page is hidden: ${T}`,...M),p=h;break;case(!t&&l!==k[i]&&h<=Q[i]):f(`New <html> size: ${T} `,...M),f(`Previous <html> size: %c${k[i]}px`,s.HIGHLIGHT),p=_(i,l,h);break;case!g:p=e.taggedElement();break;case(!t&&l<k[i]):f(`<html> size decreased: ${T}`,...M),p=_(i,l,h);break;case(h===S||h===m):f(`<html> size equals page size: ${T}`,...M),p=_(i,l,h);break;case l>h:f(`Page size < <html> size: ${T}`,...M),p=_(i,l,h);break;case t:f("Found elements possibly overflowing <html> "),p=e.taggedElement();break;default:f(`Using <html> size: ${T}`,...M),p=_(i,l,h)}return f(`Content ${i}: %c${p}px`,s.HIGHLIGHT),p+=mn(e),Math.max(p,o.MIN_SIZE)}const En=1e3,In=5*En,pn=4,On=10,Sn=100,pe="--ifr-start",X="--ifr-end",ct="--ifr-measure",O=[];let K={},Pe=0,de;function at(){try{performance.clearMarks(pe),performance.clearMarks(X),performance.clearMeasures(ct)}catch{}}function Rn(){de=setInterval(()=>{if(O.length<On||K.hasTags&&K.len<25)return;O.sort();const e=Math.min(O.reduce((n,r)=>n+r,0)/O.length,O[Math.floor(O.length/2)]),t=u.round(e);t>Pe&&(Pe=t,I("performanceObserver"),d("Mean time:",u.round(O[Math.floor(O.length/2)])),d("Median time:",u.round(O.reduce((n,r)=>n+r,0)/O.length)),d("Average time:",t),d("Max time:",u.round(Math.max(...O)))),at(),!(e<=pn)&&(clearInterval(de),b(`<rb>Performance Warning</>
|
|
19
|
+
|
|
20
|
+
Calculating the page size is taking an excessive amount of time (${u.round(e)}ms).
|
|
35
21
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
`,
|
|
39
|
-
`,t),t},bs=e=>{if(e.size===0)return;h("addObservers");const t=En(e);E.overflow.attachObservers(t),E.resize.attachObserverToNonStaticElements(t),_()},zs=e=>{if(e.size===0)return;h("removeObservers");const t=En(e);E.overflow.detachObservers(t),E.resize.detachObservers(t),_()};function ws({addedNodes:e,removedNodes:t}){h("contentMutated"),i.applySelectors(),hn(),On(),_(),zs(t),bs(e)}function Is(e){ws(e),T(Ut,"Mutation Observed")}const ee="Overflow",Os=Oe(ee),Es=Oe(ee,!1),Ss=bn(ee),Ts=zn(ee),Rs=e=>e instanceof HTMLElement&&(!!e.hidden||e.offsetParent===null||e.style.display===We),Hs=(e,t)=>{const n=t.side,o={root:t.root,rootMargin:"0px",threshold:1},r=window?.requestAnimationFrame||le,d=(w=!1)=>e(w),a=(w,R)=>w===0||w>R[n],f=(w,R)=>{w.toggleAttribute(Ct,R)};function b(w){for(const R of w){const{boundingClientRect:U,rootBounds:V,target:I}=R;if(!V)continue;const Hn=U[n],Mn=a(Hn,V)&&!(I instanceof HTMLElement&&Rs(I));f(I,Mn)}r(d)}const m=new IntersectionObserver(b,o),z=new WeakSet;function g(w){const R=new Set,U=new Set;let V=0;for(const I of w)if(I instanceof Element){if(z.has(I)){R.add(I);continue}m.observe(I),z.add(I),U.add(I),V+=1}Ts(R),Ss(U),Os(V),U.clear(),R.clear()}return{attachObservers:g,detachObservers:wn(ee,m,z,Es),disconnect:()=>{m.disconnect(),u("Detached%c OverflowObserver",s.HIGHLIGHT)}}};function Ms(){const{hasOverflow:e}=i,{hasOverflowUpdated:t,overflowedNodeSet:n}=On();switch(!0){case!t:return;case n.size>1:u("Overflowed Elements:",n);break;case e:break;default:u("No overflow detected")}T(Ve,"Overflow updated")}function $s(e){const t={root:document.documentElement,side:c.calculateHeight?_t:Ft};return E.overflow=Hs(Ms,t),E.overflow.attachObservers(e),E.overflow}const te="Resize",As=Oe(te),Ls=Oe(te,!1),ks=bn(te),Ns=zn(te),he=new WeakSet,$e=new Set,Ae=new Set;let Z;function Gs(e){let t=0;for(const n of e){if(!(n instanceof Element))continue;const o=getComputedStyle(n)?.position;if(!(o===""||o==="static")){if(he.has(n)){$e.add(n);continue}Z.observe(n),he.add(n),Ae.add(n),t+=1}}Ns($e),ks(Ae),As(t),Ae.clear(),$e.clear()}const Ps=e=>(Z=new ResizeObserver(e),Z.observe(document.body),he.add(document.body),u("Attached%c ResizeObserver%c to body",s.HIGHLIGHT,s.FOREGROUND),{attachObserverToNonStaticElements:Gs,detachObservers:wn(te,Z,he,Ls),disconnect:()=>{Z.disconnect(),u("Detached%c ResizeObserver",s.HIGHLIGHT)}});function Cs(e){if(!Array.isArray(e)||e.length===0)return;const t=e[0].target;T(Bt,`Element resized <${Xn(t)}>`)}function js(e){return E.resize=Ps(Cs),E.resize.attachObserverToNonStaticElements(e),E.resize}let Ht;function Ds(){const e=document.title;e!==Ht&&(Ht=e,l(`Title: %c${e}`,s.HIGHLIGHT),e&&y(0,0,Fn,e))}function _s(e){l(`Visible: %c${e}`,s.HIGHLIGHT),i.isHidden=!e,T(Vt,"Visibility changed")}function Fs(e){Qe.push(...e.map(t=>t.disconnect))}function xs(){h("attachObservers");const e=Ke(document.documentElement),t=[hs(Is),$s(e),jo(),js(e),ps(Ds),ys(_s)];Fs(t)}const Mt=(e,t,n)=>{if(n!==""){l(`${e}: %c${n}`,s.HIGHLIGHT);for(const o of document.querySelectorAll(n))l(`Applying ${t} to:`,o),o.toggleAttribute(t,!0)}};function Bs({sizeSelector:e,ignoreSelector:t}){return()=>{Mt("sizeSelector",ye,e),Mt("ignoreSelector",J,t)}}function Us(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}function Vs(e,t){return t.includes("-")&&(D(`Negative CSS value ignored for ${e}`),t=""),t}function _e(e,t){t===void 0||t===""||t===Wn||(document.body.style.setProperty(e,t),u(`Set body ${e}: %c${t}`,s.HIGHLIGHT))}function Ws({bodyMarginStr:e,bodyMargin:t}){e===void 0&&(e=`${t}px`),_e("margin",Vs("margin",e))}const qs=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function Zs(e){const t=e.getBoundingClientRect(),n=qs();return{x:Math.round(t.left+n.x),y:Math.round(t.top+n.y)}}function Ys(e,t){const n=Zs(t);l(`Moving to in page link (%c#${e}%c) at x: %c${n.x}%c y: %c${n.y}`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT),y(n.y,n.x,Pt)}function ot(e){const t=e.split("#")[1]||e,n=decodeURIComponent(t),o=document.getElementById(n)||document.getElementsByName(n)[0];if(o!==void 0){Ys(t,o);return}l(`In page link (#${t}) not found in iframe, so sending to parent`),y(0,0,Nn,`#${t}`)}function Sn(){const{hash:e,href:t}=window.location;e!==""&&e!=="#"&&ot(t)}function Qs(){for(const e of document.querySelectorAll('a[href^="#"]'))e.getAttribute("href")!=="#"&&G(e,"click",t=>{t.preventDefault(),ot(e.getAttribute("href"))})}function Js(){G(window,"hashchange",Sn)}function Ks(){setTimeout(Sn,qt)}function Xs(){l("Setting up location.hash handlers"),Qs(),Js(),Ks(),i.inPageLinks={findTarget:ot}}function ei(e){const{mode:t}=c;e?Xe(t)?p($(5)):Xs():l("In page linking not enabled")}const ti="important";function ni(){const e=t=>t.style.setProperty(ve,L,ti);e(document.documentElement),e(document.body),l("Set HTML & body height: %cauto !important",s.HIGHLIGHT)}const rt=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},Le=rt(be),oe=rt(N),re=rt(K),oi=e=>e!==null&&typeof e===Bn&&!Array.isArray(e);function ri(e){const{calculateHeight:t,calculateWidth:n}=c;let o,r;return typeof e?.offset===N&&(ho(Se,Te),t&&(o=oe(e,Se)),n&&(r=oe(e,Se))),typeof e?.offsetSize===N&&(t&&(o=oe(e,Te)),n&&(r=oe(e,Te))),{offsetHeight:o,offsetWidth:r}}function si(e){l("Reading data from page:",Object.keys(e));const{offsetHeight:t,offsetWidth:n}=ri(e);return{offsetHeight:t,offsetWidth:n,ignoreSelector:re(e,"ignoreSelector"),[bt(3)]:re(e,bt(0)),sizeSelector:re(e,"sizeSelector"),targetOrigin:re(e,"targetOrigin"),onBeforeResize:Le(e,"onBeforeResize"),onMessage:Le(e,"onMessage"),onReady:Le(e,"onReady")}}function ii(){const{mode:e}=c;if(Xe(e))return{};const t=window.iframeResizer||window.iFrameResizer;return oi(t)?si(t):{}}const ci=e=>e==="true",Tn=e=>t=>t===void 0?void 0:e(t),P=Tn(ci),q=Tn(Number),ai=e=>({parentId:e[0],bodyMargin:q(e[1]),calculateWidth:P(e[2]),logging:P(e[3]),autoResize:P(e[6]),bodyMarginStr:e[7],heightCalcMode:e[8],bodyBackground:e[9],bodyPadding:e[10],tolerance:q(e[11]),inPageLinks:P(e[12]),widthCalcMode:e[14],mouseEvents:P(e[15]),offsetHeight:q(e[16]),offsetWidth:q(e[17]),calculateHeight:P(e[18]),key:e[19],version:e[20],mode:q(e[21]),logExpand:P(e[23])});function li(e){const{mode:t}=c;e.forEach(n=>{try{n()}catch(o){if(t<0)throw o;p(`<rb>Error in setup function</>
|
|
22
|
+
To improve performance add the <b>data-iframe-size</> attribute to the ${K.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},In)}function Tn(e){e.getEntries().forEach(t=>{if(t.name===X)try{const{duration:n}=performance.measure(ct,pe,X);K=t.detail,O.push(n),O.length>Sn&&O.shift()}catch{}})}function bn(){f("Attached%c PerformanceObserver%c to page",s.HIGHLIGHT,s.FOREGROUND);const e=new PerformanceObserver(Tn);return e.observe({entryTypes:["mark"]}),Rn(),{disconnect:()=>{at(),clearInterval(de),e.disconnect(),f("Detached%c PerformanceObserver",s.HIGHLIGHT)}}}const wn=e=>`:not(${e})`,vn=`* ${Array.from(o.IGNORE_TAGS).map(wn).join("")}`,Oe=e=>e.querySelectorAll(vn);function yn(){const{hasOverflow:e,hasTags:t,overflowedNodeSet:n,taggedElements:r}=c;return t?r:e?Array.from(n):Oe(document.documentElement)}function Hn(e,t){const n=`margin-${t}`;let r,i=document.documentElement,g=c.hasTags?o.MIN_SIZE:document.documentElement.getBoundingClientRect().bottom;for(const l of e)r=l.getBoundingClientRect()[t]+parseFloat(getComputedStyle(l).getPropertyValue(n)),r>g&&(g=r,i=l);return{maxEl:i,maxVal:g}}function dt(e){performance.mark(pe);const t=u.capitalizeFirstLetter(e),{logging:n}=a,{hasTags:r}=c,i=yn(),{maxEl:g,maxVal:l}=Hn(i,e);return f(`${t} position calculated from:`,g),f(`Checked %c${i.length}%c elements`,s.HIGHLIGHT,s.FOREGROUND),performance.mark(X,{detail:{hasTags:r,len:i.length,logging:n,Side:t}}),l}const Se={label:o.HEIGHT,enabled:()=>a.calculateHeight,getOffset:()=>a.offsetHeight,auto:()=>it(Se),boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),documentElementScroll:()=>document.documentElement.scrollHeight,taggedElement:()=>dt(o.HEIGHT_EDGE)},Re={label:o.WIDTH,enabled:()=>a.calculateWidth,getOffset:()=>a.offsetWidth,auto:()=>it(Re),boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),documentElementScroll:()=>document.documentElement.scrollWidth,taggedElement:()=>dt(o.WIDTH_EDGE)};function An(e,t,n){const r=a.onBeforeResize(e,t,n);if(r===void 0)throw new TypeError("No value returned from onBeforeResize(), expected a numeric value");if(Number.isNaN(r))throw new TypeError(`Invalid value returned from onBeforeResize(): ${r}, expected Number`);if(r<o.MIN_SIZE)throw new RangeError(`Out of range value returned from onBeforeResize(): ${r}, must be at least ${o.MIN_SIZE}`);return r}const lt=(e,t)=>(n,r)=>{const i=e[n]();return e.enabled()&&a.onBeforeResize!==void 0?An(i,r,t):i},Nn=lt(Se,o.HEIGHT),Mn=lt(Re,o.WIDTH);function Ln(){(window.scrollY!==0||window.scrollX!==0)&&(f("Reset iframe scroll position to (0, 0)"),window.scrollTo(0,0))}function Gn(e,t,n,r){const{heightCalcMode:i,widthCalcMode:g}=a;Ln();const l=n??Nn(i,e),m=r??Mn(g,e),S=gn(l,m)?o.SIZE_CHANGE_DETECTED:e;switch(d(`Resize event: %c${t}`,s.HIGHLIGHT),S){case o.INIT:case o.ENABLE:case o.SIZE_CHANGE_DETECTED:case o.MANUAL_RESIZE_REQUEST:case o.PARENT_RESIZE_REQUEST:c.height=l,c.width=m;case o.SET_OFFSET_SIZE:return c;case o.OVERFLOW_OBSERVER:case o.MUTATION_OBSERVER:case o.RESIZE_OBSERVER:case o.VISIBILITY_OBSERVER:{d(o.NO_CHANGE);break}default:f(o.NO_CHANGE)}return null}let Z=!1,re=!1,B=null;function zn(e,t,n,r,i){const{autoResize:g}=a,{isHidden:l}=c;switch(I(e),!0){case(l===!0&&!(e in o.IGNORE_DISABLE_RESIZE)):{if(re===!0)break;d("Iframe hidden - Ignored resize request"),re=!0,Z=!1,cancelAnimationFrame(B),B=null;break}case(Z===!0&&e!==o.OVERFLOW_OBSERVER&&!(e in o.IGNORE_DISABLE_RESIZE)):{d("Resize already pending - Ignored resize request");break}case(!g&&!(e in o.IGNORE_DISABLE_RESIZE)):{f("Resizing disabled");break}default:{re=!1,Z=!0,c.totalTime=performance.now(),c.timerActive=!0;const m=Gn(e,t,n,r);m&&st(m.height,m.width,e,i),B||(B=requestAnimationFrame(()=>{Z=!1,B=null,I("requestAnimationFrame"),J(`Reset sendPending: %c${e}`,s.HIGHLIGHT)})),c.timerActive=!1}}$()}const A=he(zn);function Be({eventType:e,eventName:t}){G(window,t,()=>A(t,e),{passive:!0})}function $n(){Be({eventType:"After Print",eventName:"afterprint"}),Be({eventType:"Before Print",eventName:"beforeprint"})}function _n(){if(c.triggerLocked){d("TriggerLock blocked calculation");return}c.triggerLocked=!0,J("Trigger event lock on"),requestAnimationFrame(()=>{c.triggerLocked=!1,J("Trigger event lock off")})}function ft(e){const{heightCalcMode:t,widthCalcMode:n}=a,r=Se[t](),i=Re[n]();d(`Reset trigger event: %c${e}`,s.HIGHLIGHT),R(r,i,e)}function kn(e){const t=a.heightCalcMode;d(`Reset trigger event: %c${e}`,s.HIGHLIGHT),a.heightCalcMode=o.HEIGHT_CALC_MODE_DEFAULT,_n(),ft("reset"),a.heightCalcMode=t}const Cn=`Auto Resize can not be changed when <b>direction</> is set to '${o.NONE}'.`;function Dn(e){u.typeAssert(e,o.BOOLEAN,"parentIframe.autoResize(enable) enable");const{autoResize:t,calculateHeight:n,calculateWidth:r}=a;return r===!1&&n===!1?(I(o.ENABLE),b(Cn),!1):(e===!0&&t===!1?(a.autoResize=!0,queueMicrotask(()=>A(o.ENABLE,"Auto Resize enabled"))):e===!1&&t===!0&&(a.autoResize=!1),R(0,0,o.AUTO_RESIZE,JSON.stringify(a.autoResize)),a.autoResize)}function Pn(e){u.typeAssert(e,o.STRING,"parentIframe.moveToAnchor(anchor) anchor"),c.inPageLinks.findTarget(e)}function Bn(e){u.typeAssert(e,o.NUMBER,"parentIframe.setOffsetSize(offset) offset"),a.offsetHeight=e,a.offsetWidth=e,A(o.SET_OFFSET_SIZE,`parentIframe.setOffsetSize(${e})`)}const Fn=()=>c.origin;function Un(e){u.typeAssert(e,o.STRING,"parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),d(`Set targetOrigin: %c${e}`,s.HIGHLIGHT),a.targetOrigin=e}function xn(e){return u.typeAssert(e,o.FUNCTION,"parentIframe.getParentProps(callback) callback"),c.onParentInfo=e,R(0,0,o.PARENT_INFO),()=>{c.onParentInfo=null,R(0,0,o.PARENT_INFO_STOP)}}function Vn(e,t){e!==void 0&&u.typeAssert(e,o.NUMBER,"parentIframe.resize(customHeight, customWidth) customHeight"),t!==void 0&&u.typeAssert(t,o.NUMBER,"parentIframe.resize(customHeight, customWidth) customWidth");const n=e===void 0?"":e,r=t===void 0?"":`,${t}`,i=`${n}${r}`;A(o.MANUAL_RESIZE_REQUEST,`parentIframe.resize(${i})`,e,t)}const Te=e=>(t,n)=>{u.typeAssert(t,o.NUMBER,`parentIframe.${e}(x, y) x`),u.typeAssert(n,o.NUMBER,`parentIframe.${e}(x, y) y`),R(n,t,e)},Wn=Te(o.SCROLL_BY),qn=Te(o.SCROLL_TO),Zn=Te(o.SCROLL_TO_OFFSET);function Yn(e,t){t&&u.typeAssert(t,o.STRING,"parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),R(0,0,o.MESSAGE,JSON.stringify(e),t)}const jn=()=>R(0,0,o.CLOSE),Qn=()=>a.parentId,Kn=()=>kn("parentIframe.reset");function Jn(){const{win:e}=c;a.mode!==1&&(e.parentIframe=Object.freeze({autoResize:Dn,close:jn,getId:Qn,getParentOrigin:Fn,getParentProps:xn,moveToAnchor:Pn,reset:Kn,setOffsetSize:Bn,scrollBy:Wn,scrollTo:qn,scrollToOffset:Zn,sendMessage:Yn,setTargetOrigin:Un,resize:Vn}))}const V=(e="")=>t=>n=>{n.size>0&&J(`${t}Observer ${e}:`,...Array.from(n).flatMap(r=>[o.NEW_LINE,r]))},Xn=(e="")=>t=>n=>{n.size>0&&Ke(`${t}Observer ${e}:`,...Array.from(n).flatMap(r=>[o.NEW_LINE,r]))},ut=V("attached to"),gt=Xn("already attached"),eo=V("detached from"),ne=(e,t=!0)=>n=>{n>0&&f(`${t?"At":"De"}tached %c${e}Observer%c ${t?"to":"from"} %c${n}%c element${n===1?"":"s"}`,s.HIGHLIGHT,s.NORMAL,s.HIGHLIGHT,s.NORMAL)},mt=(e,t,n,r)=>{const i=eo(e);return g=>{const l=new Set;let m=0;for(const S of g)n.has(S)&&(t.unobserve(S),n.delete(S),l.add(S),m+=1);i(l),r(m),l.clear()}},Fe=16,Ue=2,to=200,be="Mutation",y=new Set,L=new Set,le=new Set,ee=[],no={attributes:!0,attributeFilter:[o.IGNORE_ATTR,o.SIZE_ATTR],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};let se=1,we,fe=!1,ue=0;const oo=V("added")(be),ro=V("removed (page)")(be),so=V("removed (added)")(be),ht=e=>e.nodeType!==Node.ELEMENT_NODE||o.IGNORE_TAGS.has(e.tagName.toLowerCase());function io(e){const t=e.addedNodes;for(const n of t)ht(n)||y.add(n)}function co(e){const t=e.removedNodes;for(const n of t)ht(n)||(y.has(n)?(y.delete(n),le.add(n)):L.add(n))}const ao=e=>{f("Mutations:",e);for(const t of e)io(t),co(t);oo(y),ro(L),so(le),le.clear()};function lo(){L.size>0&&d(`Detected %c${L.size} %cremoved element${L.size>1?"s":""}`,s.HIGHLIGHT,s.FOREGROUND),y.size>0&&d(`Found %c${y.size} %cnew element${y.size>1?"s":""}`,s.HIGHLIGHT,s.FOREGROUND)}const fo=e=>()=>{const t=performance.now(),n=t-ue,r=Fe*se+++Ue;if(n>r&&n<to){I("mutationThrottled"),f("Update delayed due to heavy workload on the callStack"),f(`EventLoop busy time: %c${u.round(n)}ms %c> Max wait: %c${r-Ue}ms`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT),setTimeout(we,Fe*se),ue=t;return}se=1,ee.forEach(ao),ee.length=0,fe=!1,lo(),e({addedNodes:y,removedNodes:L}),y.clear(),L.clear()};function uo(e){ee.push(e),!fe&&(ue=performance.now(),fe=!0,requestAnimationFrame(we))}function go(e){const t=new window.MutationObserver(uo),n=document.body||document.documentElement;return we=fo(e),t.observe(n,no),f("Attached%c MutationObserver%c to body",s.HIGHLIGHT,s.FOREGROUND),{disconnect:()=>{y.clear(),L.clear(),ee.length=0,t.disconnect(),f("Detached%c MutationObserver",s.HIGHLIGHT)}}}const mo={characterData:!0,childList:!0,subtree:!0};function ho(e){const t=document.querySelector("title")??document.head??document.documentElement,n=new MutationObserver(e);return n.observe(t,mo),f("Attached%c TitleObserver%c to head",s.HIGHLIGHT,s.FOREGROUND),setTimeout(e),{disconnect:()=>{n.disconnect(),f("Detached%c TitleObserver",s.HIGHLIGHT)}}}function Eo(e){const t=new IntersectionObserver(r=>e(r.at(-1)?.isIntersecting??!1),{threshold:0}),n=document.documentElement;return t.observe(n),f("Attached%c VisibilityObserver%c to page",s.HIGHLIGHT,s.FOREGROUND),{disconnect:()=>{t.disconnect(),f("Detached%c VisibilityObserver",s.HIGHLIGHT)}}}let xe=new Set;function Io(e){const t=new Set,n=new Set;for(const r of e)r.closest(`[${o.IGNORE_ATTR}]`)?n.add(r):t.add(r);return n.size>0&&queueMicrotask(()=>{I("overflowIgnored"),f(`Ignoring elements with [data-iframe-ignore] > *:
|
|
23
|
+
`,n),$()}),t}function Et(){const e=document.querySelectorAll(`[${o.OVERFLOW_ATTR}]`),t=Io(e);let n=!0;return typeof Set.prototype.symmetricDifference===o.FUNCTION&&(n=t.symmetricDifference(xe).size>0),xe=t,c.overflowedNodeSet=t,c.hasOverflow=t.size>0,{hasOverflowUpdated:n,overflowedNodeSet:t}}const H={},It=e=>{const t=new Set;for(const n of e)if(n instanceof Element){t.add(n);for(const r of Oe(n))t.add(r)}return f(`Inspecting:
|
|
24
|
+
`,t),t},po=e=>{if(e.size===0)return;I("addObservers");const t=It(e);H.overflow.attachObservers(t),H.resize.attachObserverToNonStaticElements(t),$()},Oo=e=>{if(e.size===0)return;I("removeObservers");const t=It(e);H.overflow.detachObservers(t),H.resize.detachObservers(t),$()};function So({addedNodes:e,removedNodes:t}){I("contentMutated"),c.applySelectors(),rt(),Et(),$(),Oo(t),po(e)}function Ro(e){So(e),A(o.MUTATION_OBSERVER,"Mutation Observed")}const W="Overflow",To=ne(W),bo=ne(W,!1),wo=ut(W),vo=gt(W),yo=e=>e instanceof HTMLElement&&(!!e.hidden||e.offsetParent===null||e.style.display===o.NONE),Ho=(e,t)=>{const n=t.side||o.HEIGHT_EDGE,r={root:t.root,rootMargin:"0px",threshold:1},i=window?.requestAnimationFrame||u.id,g=(w=!1)=>e(w),l=(w,N)=>w===0||w>N[n],m=(w,N)=>{w.toggleAttribute(o.OVERFLOW_ATTR,N)};function S(w){for(const N of w){const{boundingClientRect:D,rootBounds:P,target:v}=N;if(!P)continue;const Rt=D[n],Tt=l(Rt,P)&&!(v instanceof HTMLElement&&yo(v));m(v,Tt)}i(g)}const h=new IntersectionObserver(S,r),T=new WeakSet;function p(w){const N=new Set,D=new Set;let P=0;for(const v of w)if(v instanceof Element){if(T.has(v)){N.add(v);continue}h.observe(v),T.add(v),D.add(v),P+=1}vo(N),wo(D),To(P),D.clear(),N.clear()}return{attachObservers:p,detachObservers:mt(W,h,T,bo),disconnect:()=>{h.disconnect(),f("Detached%c OverflowObserver",s.HIGHLIGHT)}}};function Ao(){const{hasOverflow:e}=c,{hasOverflowUpdated:t,overflowedNodeSet:n}=Et();switch(!0){case!t:return;case n.size>1:f("Overflowed Elements:",n);break;case e:break;default:f("No overflow detected")}A(o.OVERFLOW_OBSERVER,"Overflow updated")}function No(e){const t={root:document.documentElement,side:a.calculateHeight?o.HEIGHT_EDGE:o.WIDTH_EDGE};return H.overflow=Ho(Ao,t),H.overflow.attachObservers(e),H.overflow}const q="Resize",Mo=ne(q),Lo=ne(q,!1),Go=ut(q),zo=gt(q),te=new WeakSet,ie=new Set,ce=new Set;let U;function $o(e){let t=0;for(const n of e){if(!(n instanceof Element))continue;const r=getComputedStyle(n)?.position;if(!(r===""||r==="static")){if(te.has(n)){ie.add(n);continue}U.observe(n),te.add(n),ce.add(n),t+=1}}zo(ie),Go(ce),Mo(t),ce.clear(),ie.clear()}const _o=e=>(U=new ResizeObserver(e),U.observe(document.body),te.add(document.body),f("Attached%c ResizeObserver%c to body",s.HIGHLIGHT,s.FOREGROUND),{attachObserverToNonStaticElements:$o,detachObservers:mt(q,U,te,Lo),disconnect:()=>{U.disconnect(),f("Detached%c ResizeObserver",s.HIGHLIGHT)}});function ko(e){if(!Array.isArray(e)||e.length===0)return;const t=e[0].target;A(o.RESIZE_OBSERVER,`Element resized <${u.getElementName(t)}>`)}function Co(e){return H.resize=_o(ko),H.resize.attachObserverToNonStaticElements(e),H.resize}let Ve;function Do(){const e=document.title;e!==Ve&&(Ve=e,d(`Title: %c${e}`,s.HIGHLIGHT),e&&R(0,0,o.TITLE,e))}function Po(e){d(`Visible: %c${e}`,s.HIGHLIGHT),c.isHidden=!e,A(o.VISIBILITY_OBSERVER,"Visibility changed")}function Bo(e){Ie.push(...e.map(t=>t.disconnect))}function Fo(){I("attachObservers");const e=Oe(document.documentElement),t=[go(Ro),No(e),bn(),Co(e),ho(Do),Eo(Po)];Bo(t)}const We=(e,t,n)=>{if(n!==""){d(`${e}: %c${n}`,s.HIGHLIGHT);for(const r of document.querySelectorAll(n))d(`Applying ${t} to:`,r),r.toggleAttribute(t,!0)}};function Uo({sizeSelector:e,ignoreSelector:t}){return()=>{We("sizeSelector",o.SIZE_ATTR,e),We("ignoreSelector",o.IGNORE_ATTR,t)}}function xo(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}function Vo(e,t){return t.includes("-")&&(C(`Negative CSS value ignored for ${e}`),t=""),t}function ge(e,t){t===void 0||t===""||t===o.NULL||(document.body.style.setProperty(e,t),f(`Set body ${e}: %c${t}`,s.HIGHLIGHT))}function Wo({bodyMarginStr:e,bodyMargin:t}){e===void 0&&(e=`${t}px`),ge("margin",Vo("margin",e))}const qo=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function Zo(e){const t=e.getBoundingClientRect(),n=qo();return{x:Math.round(t.left+n.x),y:Math.round(t.top+n.y)}}function Yo(e,t){const n=Zo(t);d(`Moving to in page link (%c#${e}%c) at x: %c${n.x}%c y: %c${n.y}`,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT,s.FOREGROUND,s.HIGHLIGHT),R(n.y,n.x,o.SCROLL_TO_OFFSET)}function ve(e){const t=e.split("#")[1]||e,n=decodeURIComponent(t),r=document.getElementById(n)||document.getElementsByName(n)[0];if(r!==void 0){Yo(t,r);return}d(`In page link (#${t}) not found in iframe, so sending to parent`),R(0,0,o.IN_PAGE_LINK,`#${t}`)}function pt(){const{hash:e,href:t}=window.location;e!==""&&e!=="#"&&ve(t)}function jo(){for(const e of document.querySelectorAll('a[href^="#"]'))e.getAttribute("href")!=="#"&&G(e,"click",t=>{t.preventDefault(),ve(e.getAttribute("href"))})}function Qo(){G(window,"hashchange",pt)}function Ko(){setTimeout(pt,o.EVENT_CANCEL_TIMER)}function Jo(){d("Setting up location.hash handlers"),jo(),Qo(),Ko(),c.inPageLinks={findTarget:ve}}function Xo(e){const{mode:t}=a;e?E.checkMode(t)?b(E.getModeData(5)):Jo():d("In page linking not enabled")}const er="important";function tr(){const e=t=>t.style.setProperty(o.HEIGHT,o.AUTO,er);e(document.documentElement),e(document.body),d("Set HTML & body height: %cauto !important",s.HIGHLIGHT)}const ye=e=>(t,n)=>{if(n in t){if(typeof t[n]===e)return t[n];throw new TypeError(`${n} is not a ${e}.`)}},ae=ye(o.FUNCTION),qe=ye(o.NUMBER),Y=ye(o.STRING),nr=e=>e!==null&&typeof e===o.OBJECT&&!Array.isArray(e);function or(e){const{calculateHeight:t,calculateWidth:n}=a;let r,i;return typeof e?.offsetSize===o.NUMBER&&(t&&(r=qe(e,o.OFFSET_SIZE)),n&&(i=qe(e,o.OFFSET_SIZE))),{offsetHeight:r,offsetWidth:i}}function rr(e){d("Reading data from page:",Object.keys(e));const{offsetHeight:t,offsetWidth:n}=or(e);return{offsetHeight:t,offsetWidth:n,ignoreSelector:Y(e,"ignoreSelector"),[E.getKey(3)]:Y(e,E.getKey(0)),sizeSelector:Y(e,"sizeSelector"),targetOrigin:Y(e,"targetOrigin"),onBeforeResize:ae(e,"onBeforeResize"),onMessage:ae(e,"onMessage"),onReady:ae(e,"onReady")}}function sr(){const{mode:e}=a;if(E.checkMode(e))return{};const t=window.iframeResizer||window.iFrameResizer;return nr(t)?rr(t):{}}const ir=e=>e==="true",Ot=e=>t=>t===void 0?void 0:e(t),z=Ot(ir),F=Ot(Number),cr=e=>({parentId:e[0],bodyMargin:F(e[1]),calculateWidth:z(e[2]),logging:z(e[3]),autoResize:z(e[6]),bodyMarginStr:e[7],bodyBackground:e[9],bodyPadding:e[10],tolerance:F(e[11]),inPageLinks:z(e[12]),mouseEvents:z(e[15]),offsetHeight:F(e[16]),offsetWidth:F(e[17]),calculateHeight:z(e[18]),key:e[19],version:e[20],mode:F(e[21]),logExpand:z(e[23])});function ar(e){const{mode:t}=a;e.forEach(n=>{try{n()}catch(r){if(t<0)throw r;b(`<rb>Error in setup function</>
|
|
40
25
|
<i>iframe-resizer</> detected an error during setup.
|
|
41
26
|
|
|
42
|
-
Please report the following error message at <u>https://github.com/davidjbradshaw/iframe-resizer/issues</>`),
|
|
27
|
+
Please report the following error message at <u>https://github.com/davidjbradshaw/iframe-resizer/issues</>`),Ke(r)}})}function Ze(e){for(const[t,n]of Object.entries(e))n!==void 0&&(a[t]=n)}function dr({logExpand:e,logging:t,parentId:n=""}){yt({id:n,enabled:t,expand:e}),I("initReceived"),d(`Initialising iframe v${o.VERSION} ${window.location.href}`)}function lr(e){I("ready"),ot(u.once(e)),d("Initialization complete",(({key:t,key2:n,...r})=>r)(a))}function fr({bodyBackground:e,bodyPadding:t,inPageLinks:n,onReady:r}){const i=xt(a),g=[qt,Vt,Kt,rt,Xt,i?u.id:Ut,()=>Wo(a),()=>ge("background",e),()=>ge("padding",t),i?u.id:tr,xo,c.applySelectors,()=>Xo(n),$n,()=>dn(a),un,()=>Jn(),()=>A(o.INIT,"Init message from host page",void 0,void 0,`${o.VERSION}:${a.mode}`),Fo,$];nn(a),Yt(a),ar(g),lr(r)}function ur(e){c.firstRun&&(Ze(cr(e)),dr(a),Ze(sr()),c.applySelectors=Uo(a),fr(a))}function gr(e){if(document.readyState==="loading"){d("Page not ready, ignoring init message");return}const t=e.data.slice(o.MESSAGE_ID_LENGTH).split(o.SEPARATOR);c.target=e.source,c.origin=e.origin,ur(t),c.firstRun=!1,setTimeout(()=>{c.initLock=!1},o.EVENT_CANCEL_TIMER)}const{freeze:mr}=Object,{parse:He}=JSON,Ae=e=>mr(He(e)),St=e=>R(0,0,`${e}Stop`),oe=e=>e.data.slice(e.data.indexOf(o.SEPARATOR)+1),hr=e=>Gt(e)?o.INIT:e.data.split("]")[1].split(o.SEPARATOR)[0];function Er(e){const t=oe(e);d("onMessage called from parent:%c",s.HIGHLIGHT,Ae(t)),u.isolateUserCode(a.onMessage,He(t))}function Ir(e){const{onPageInfo:t}=c,n=oe(e);d("PageInfo received from parent:",Ae(n)),t?u.isolateUserCode(t,He(n)):St(o.PAGE_INFO)}function pr(e){const{onParentInfo:t}=c,n=Ae(oe(e));d("ParentInfo received from parent:",n),t?u.isolateUserCode(t,n):St(o.PARENT_INFO)}function Or(){if(c.initLock){d("Page reset ignored by init");return}d("Page size reset by host page"),ft("resetPage")}function Sr(){d("Resize requested by host page"),A(o.PARENT_RESIZE_REQUEST,"Parent window requested size check")}const Ye=e=>c.inPageLinks.findTarget(oe(e)),je={init:gr,reset:Or,resize:Sr,moveToAnchor:Ye,inPageLink:Ye,pageInfo:Ir,parentInfo:pr,message:Er};function Rr(e){const{firstRun:t}=c,n=hr(e);switch(I(n),!0){case n in je:je[n](e);break;case(t&&Lt()):C(`Ignored message of type "${n}". Received before initialization.`);break;default:C(`Unexpected message (${e.data}), this is likely due to a newer version of iframe-resizer running on the parent page.`)}}const j=he(e=>{Mt(e)&&Rr(e)});function Tr(){if("iframeChildListener"in window){C("Already setup");return}window.iframeChildListener=(t=>{setTimeout(()=>j({data:t,sameOrigin:!0}))}),I("listen"),G(window,o.MESSAGE,j),G(document,o.READY_STATE_CHANGE,Ge),Ge();function e(t){return j(t),c.win}try{top?.document?.getElementById("banner")&&(c.win={},window.mockMsgListener=e,et(window,o.MESSAGE,j),typeof window.define=="function"&&window.define([],()=>e))}catch{}}typeof window!==o.UNDEFINED&&Tr();
|
|
43
28
|
//# sourceMappingURL=index.cjs.js.map
|