@iframe-resizer/child 6.0.0-beta.3 → 6.0.0-beta.5
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 +11 -13
- package/index.cjs.js.map +1 -1
- package/index.esm.js +687 -799
- package/index.esm.js.map +1 -1
- package/index.umd.js +11 -15
- package/index.umd.js.map +1 -1
- package/package.json +2 -1
package/index.umd.js
CHANGED
|
@@ -1,32 +1,28 @@
|
|
|
1
|
-
(function(
|
|
2
|
-
`,rb:"\x1B[31;1m",bb:"\x1B[34;1m",b:"\x1B[1m",i:"\x1B[3m",u:"\x1B[4m","/":"\x1B[m"},Un=Object.keys(zt),Wn=new RegExp(`<(${Un.join("|")})>`,"gi"),Vn=(e,t)=>zt[t]??"",qn=e=>e.replace(Wn,Vn),Zn=e=>e.replaceAll("<br>",`
|
|
3
|
-
`).replaceAll(/<\/?[^>]+>/gi,""),Yn=e=>t=>e(_n(t)?window.chrome?qn(t):Zn(t):t);let He=!0,wt=ve;const V=Bn(s)({label:`${ve}(child)`,expand:!1});function Qn(e){wt=e.id||ve,V.label(`${wt}`),V.expand(e.expand),He=e.enabled}const Et=e=>(...t)=>He?V[e](...t):!0,l=Et("log"),u=l,ie=Et("debug");function Jn(e,t){console.info(`%ciframe-resizer ${e}`,He||t<1?jn:s.NORMAL)}const{assert:Kn,endAutoGroup:j,error:It,errorBoundary:Me,event:h,label:ii,purge:ci,warn:_}=V,Ot=Yn(re),z=(...e)=>V.warn(...e.map(Ot)),Xn=(...e)=>console.warn(...e.map(Ot)),Le=[];function St(e,t){l(`${e} event listener: %c${t}`,s.HIGHLIGHT)}const Rt=(e,t,n,o)=>{e.removeEventListener(t,n,o),St("Removed",t)},A=(e,t,n,o=!1)=>{e.addEventListener(t,n,o),Le.push(()=>Rt(e,t,n,o)),St("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 Tt=!1;function Ht(e){const t=window?.iframeResizer?.targetOrigin||"*",n=Array.isArray(t)?t:[t];for(const o of n)e.postMessage(zn,o)}function Mt(){if(document.readyState==="loading"||!i.firstRun||Tt)return;const{parent:e,top:t}=window;h("ready"),l("Sending%c ready%c to parent from",s.HIGHLIGHT,s.FOREGROUND,window.location.href),Ht(e),e!==t&&Ht(t),Tt=!0}const Lt="iframeResize",eo=e=>oe===`${e.data}`.slice(0,ht),to=()=>Lt in window||window.jQuery!==void 0&&Lt in window.jQuery.prototype,no=e=>e.data.split(":")[2]in{true:1,false:1},oo=()=>[document.documentElement,document.body],so=["min-height","min-width","max-height","max-width"],kt=new Set,ro=e=>!!e&&e!=="0px"&&e!==W&&e!==Te,At=e=>e.tagName?e.tagName.toLowerCase():"unknown",Nt=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),io=(e,t)=>ro(Nt(e,t));function co(e,t){const n=e.style.getPropertyValue(t);return n?{source:"an inline style attribute",value:n}:null}function ao({href:e}){kt.has(e)||(l("Unable to access stylesheet:",e),kt.add(e))}function lo(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{ao(n)}return{source:"cross-origin stylesheet",value:Nt(e,t)}}const uo=(e,t)=>co(e,t)||lo(e,t),fo=(e,t)=>{const{source:n,value:o}=uo(e,t),r=At(e);z(`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</>.
|
|
1
|
+
(function(n,i){typeof exports=="object"&&typeof module<"u"?i(require("@iframe-resizer/common"),require("auto-console-group")):typeof define=="function"&&define.amd?define(["@iframe-resizer/common","auto-console-group"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.common,n.acg))})(this,(function(n,i){"use strict";let ne=!0,Ae=n.LABEL;const C=n.esModuleInterop(i)({label:`${n.LABEL}(child)`,expand:!1});function St(e){Ae=e.id||n.LABEL,C.label(`${Ae}`),C.expand(e.expand),ne=e.enabled}const Ne=e=>(...t)=>ne?C[e](...t):!0,d=Ne("log"),f=d,W=Ne("debug");function Tt(e,t){console.info(`%ciframe-resizer ${e}`,ne||t<1?n.BOLD:i.NORMAL)}const{assert:Rt,endAutoGroup:G,error:Me,errorBoundary:re,event:E,label:ps,purge:Os,warn:$}=C,Le=n.createFormatAdvise(n.id),T=(...e)=>C.warn(...e.map(Le)),bt=(...e)=>console.warn(...e.map(Le)),se=n.deprecate((e,t)=>T(t));se("Method"),se("Method","replaced with"),se("Option");const ie=[];function Ge(e,t){d(`${e} event listener: %c${t}`,i.HIGHLIGHT)}const ze=(e,t,r,s)=>{e.removeEventListener(t,r,s),Ge("Removed",t)},N=(e,t,r,s=!1)=>{e.addEventListener(t,r,s),ie.push(()=>ze(e,t,r,s)),Ge("Added",t)},a={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 $e=!1;function _e(e){const t=window?.iframeResizer?.targetOrigin||"*",r=Array.isArray(t)?t:[t];for(const s of r)e.postMessage(n.CHILD_READY_MESSAGE,s)}function ke(){if(document.readyState==="loading"||!a.firstRun||$e)return;const{parent:e,top:t}=window;E("ready"),d("Sending%c ready%c to parent from",i.HIGHLIGHT,i.FOREGROUND,window.location.href),_e(e),e!==t&&_e(t),$e=!0}const Ce="iframeResize",wt=e=>n.MESSAGE_ID===`${e.data}`.slice(0,n.MESSAGE_ID_LENGTH),vt=()=>Ce in window||window.jQuery!==void 0&&Ce in window.jQuery.prototype,yt=e=>e.data.split(n.SEPARATOR)[2]in{true:1,false:1},Ht=()=>[document.documentElement,document.body],At=["min-height","min-width","max-height","max-width"],De=new Set,Nt=e=>!!e&&e!=="0px"&&e!==n.AUTO&&e!==n.NONE,Pe=e=>e.tagName?e.tagName.toLowerCase():"unknown",Be=(e,t)=>window.getComputedStyle(e).getPropertyValue(t),Mt=(e,t)=>Nt(Be(e,t));function Lt(e,t){const r=e.style.getPropertyValue(t);return r?{source:"an inline style attribute",value:r}:null}function Gt({href:e}){De.has(e)||(d("Unable to access stylesheet:",e),De.add(e))}function zt(e,t){for(const r of document.styleSheets)try{for(const s of r.cssRules||[]){if(!("selectorText"in s))continue;const o=s;if(!e.matches(o.selectorText))continue;const u=o.style.getPropertyValue(t);if(!u)continue;const{ownerNode:l}=r;return{source:l instanceof Element&&l.tagName==="STYLE"?"an inline <style> block":`stylesheet (${r.href})`,value:u}}}catch{Gt(r)}return{source:"cross-origin stylesheet",value:Be(e,t)}}const $t=(e,t)=>Lt(e,t)||zt(e,t),_t=(e,t)=>{const{source:r,value:s}=$t(e,t),o=Pe(e);T(`The <b>${t}</> CSS property is set to <b>${s}</> on the <b><${o}></> element via ${r}. This may cause issues with the correct operation of <i>iframe-resizer</>.
|
|
4
2
|
|
|
5
|
-
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
|
|
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 kt(){for(const e of Ht())for(const t of At)d(`Checking <${Pe(e)}> for blocking CSS: ${t}`),Mt(e,t)&&_t(e,t)}const Ct=({calculateWidth:e,calculateHeight:t})=>e===t,c={autoResize:!0,bodyBackground:"",bodyMargin:0,bodyMarginStr:"",bodyPadding:"",calculateHeight:!0,calculateWidth:!1,heightCalcMode:n.AUTO,ignoreSelector:"",inPageLinks:!1,logging:!1,logExpand:!1,mode:0,mouseEvents:!1,offsetHeight:0,offsetWidth:0,parentId:void 0,sizeSelector:"",targetOrigin:"*",tolerance:0,widthCalcMode:n.AUTO,onBeforeResize:void 0,onMessage:()=>{$("onMessage function not defined")},onReady:()=>{}};function Dt(){try{a.sameOrigin=c.mode===1||"iframeParentListener"in window.parent}catch{d("Cross domain iframe detected")}}let Fe=0;function Pt(e){const t=e.length===1?"":"s";$(`%c[${n.IGNORE_ATTR}]%c found on %c${e.length}%c element${t}`,i.BOLD,i.NORMAL,i.BOLD,i.NORMAL)}function Bt(){const e=document.querySelectorAll(`*[${n.IGNORE_ATTR}]`),t=e.length>0;return t&&e.length!==Fe&&(Pt(e),Fe=e.length),t}function Ft(e,t,r){(!n.isDef(r)||t>-1&&e>t)&&(Tt(`v${n.VERSION} (${n.getModeLabel(e)})`,e),e===0&&bt(n.getModeData(3)))}function Ut({key:e,key2:t,mode:r,version:s}){const o=r,u=n.isDef(e)?n.setMode({key:e}):-1,l=n.isDef(t)?n.setMode({key:t}):-1;let g;switch(r=Math.max(u,l),r){case-2:case-1:g=`${n.getModeData(Math.min(u,l)+2)}${n.getModeData(2)}`,a.firstRun=!1;break;case 1:case 2:case 3:g=n.getModeData(6);break;case 4:g=n.getModeData(7);break;case 5:g=n.getModeData(8);break}if(r>=0&&Ft(r,o,s),(!n.isDef(s)||!a.firstRun)&&(g&&T(g),r<0))throw T(n.getModeData(9)),g.split("<br>")[0].replace(/<\/?[a-z][^>]*>|<\/>/gi,"");c.mode=r}const mt="BackCompat",xt=`<rb>Quirks Mode Detected</>
|
|
6
4
|
|
|
7
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</>.
|
|
8
6
|
|
|
9
7
|
For more information see <u>https://iframe-resizer.com/quirks-mode</>.
|
|
10
|
-
`;function
|
|
8
|
+
`;function Vt(){document.compatMode===mt&&T(xt)}const Wt="complete";let Ue=!1;function me(e){document.readyState===Wt?n.isolateUserCode(e):Ue||N(document,n.READY_STATE_CHANGE,()=>me(e)),Ue=!0}const Zt=()=>{f(`Set targetOrigin for parent: %c${c.targetOrigin}`,i.HIGHLIGHT),c.autoResize!==!0&&d("Auto Resize disabled")};function xe(){a.taggedElements=document.querySelectorAll(`[${n.SIZE_ATTR}]`),a.hasTags=a.taggedElements.length>0,d(`Tagged elements found: %c${a.hasTags}`,i.HIGHLIGHT)}const qt=`<rb>Legacy version detected on parent page</>
|
|
11
9
|
|
|
12
10
|
Detected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.
|
|
13
11
|
|
|
14
12
|
See <u>https://iframe-resizer.com/setup/</> for more details.
|
|
15
|
-
`,
|
|
13
|
+
`,jt=e=>`<b>Version mismatch</>
|
|
16
14
|
|
|
17
15
|
The parent and child pages are running different versions of <i>iframe resizer</>.
|
|
18
16
|
|
|
19
|
-
Parent page: ${e} - Child page: ${
|
|
20
|
-
`;function
|
|
17
|
+
Parent page: ${e} - Child page: ${n.VERSION}.
|
|
18
|
+
`;function Yt({version:e}){!e||e===""||e===n.FALSE?T(qt):e!==n.VERSION&&T(jt(e))}const Qt=n.once(()=>T(n.getModeData(4)));function Kt(e){if(!a.timerActive)return;const t=n.round(performance.now()-a.totalTime),r=e===n.INIT?`Initialised iframe in %c${t}ms`:`Size calculated in %c${t}ms`;d(r,i.HIGHLIGHT)}function Jt(e){return e===void 0?e=c.targetOrigin:d(`Message targetOrigin: %c${e}`,i.HIGHLIGHT),e}function Xt(e,t){const{mode:r}=c,{sameOrigin:s,target:o}=a;if(s)try{window.parent.iframeParentListener(n.MESSAGE_ID+e)}catch(u){if(n.checkMode(r))Qt();else throw new Error(u);return!1}else{Rt(o,"Internal error: postMessage target is undefined");const u=Jt(t),l=Array.isArray(u)?u:[u];for(const g of l)o.postMessage(n.MESSAGE_ID+e,g)}return!0}function Ve(e,t,r,s,o){const{parentId:u}=c,{sameOrigin:l}=a,g=`${e}:${t}`,S=`${u}:${g}:${r}${s===void 0?"":`:${s}`}`;c.mode<-1||!Xt(S,o)||(Kt(r),f(`Sending message to parent page via ${l?"sameOrigin":"postMessage"}: %c%c${S}`,i.ITALIC,i.HIGHLIGHT))}const O=re((e,t,r,s,o)=>{E(r),Ve(e,t,r,s,o),G()}),en=e=>O(0,0,e.type,`${e.screenY}:${e.screenX}`);function We(e,t){d(`Add event listener: %c${t}`,i.HIGHLIGHT),N(window.document,e,en)}function tn({mouseEvents:e}){e===!0&&(We(n.MOUSE_ENTER,"Mouse Enter"),We(n.MOUSE_LEAVE,"Mouse Leave"))}const nn=()=>O(0,0,n.BEFORE_UNLOAD);function rn({persisted:e}){e||nn(),E(n.PAGE_HIDE),f("Page persisted:",e),!e&&ie.forEach(n.invoke)}const sn=()=>N(window,n.lower(n.PAGE_HIDE),rn),Ze=(e,t)=>!(Math.abs(e-t)<=c.tolerance);function on(e,t){const{calculateHeight:r,calculateWidth:s}=c,{height:o,width:u}=a;return r&&Ze(o,e)||s&&Ze(u,t)}const M=[i.HIGHLIGHT,i.FOREGROUND,i.HIGHLIGHT],Z={height:0,width:0},_={height:0,width:0};function k(e,t,r){return _[e]=t,Z[e]=r,t}function an(e){const t=e.getOffset();return t!==0&&f(`Page offsetSize: %c${t}px`,i.HIGHLIGHT),t}const cn=e=>e.documentElementScroll()+Math.max(0,e.getOffset());function qe(e){const{hasOverflow:t,hasTags:r,triggerLocked:s}=a,o=e.label,u=o===n.HEIGHT,l=e.boundingClientRect(),g=Math.ceil(l),S=Math.floor(l),h=cn(e),R=`HTML: %c${l}px %cPage: %c${h}px`;let I;switch(!0){case!e.enabled():return Math.max(h,n.MIN_SIZE);case r:f("Found element with data-iframe-size attribute"),I=e.taggedElement();break;case(!t&&a.firstRun&&_[o]===0&&Z[o]===0):f(`Initial page size values: ${R}`,...M),I=k(o,l,h);break;case(s&&l===_[o]&&h===Z[o]):f(`Size unchanged: ${R}`,...M),I=Math.max(l,h);break;case(l===0&&h!==0):f(`Page is hidden: ${R}`,...M),I=h;break;case(!t&&l!==_[o]&&h<=Z[o]):f(`New <html> size: ${R} `,...M),f(`Previous <html> size: %c${_[o]}px`,i.HIGHLIGHT),I=k(o,l,h);break;case!u:I=e.taggedElement();break;case(!t&&l<_[o]):f(`<html> size decreased: ${R}`,...M),I=k(o,l,h);break;case(h===S||h===g):f(`<html> size equals page size: ${R}`,...M),I=k(o,l,h);break;case l>h:f(`Page size < <html> size: ${R}`,...M),I=k(o,l,h);break;case t:f("Found elements possibly overflowing <html> "),I=e.taggedElement();break;default:f(`Using <html> size: ${R}`,...M),I=k(o,l,h)}return f(`Content ${o}: %c${I}px`,i.HIGHLIGHT),I+=an(e),Math.max(I,n.MIN_SIZE)}const dn=5*1e3,ln=4,fn=10,un=100,oe="--ifr-start",q="--ifr-end",je="--ifr-measure",p=[];let j={},Ye=0,ae;function Qe(){try{performance.clearMarks(oe),performance.clearMarks(q),performance.clearMeasures(je)}catch{}}function gn(){ae=setInterval(()=>{if(p.length<fn||j.hasTags&&j.len<25)return;p.sort();const e=Math.min(p.reduce((r,s)=>r+s,0)/p.length,p[Math.floor(p.length/2)]),t=n.round(e);t>Ye&&(Ye=t,E("performanceObserver"),d("Mean time:",n.round(p[Math.floor(p.length/2)])),d("Median time:",n.round(p.reduce((r,s)=>r+s,0)/p.length)),d("Average time:",t),d("Max time:",n.round(Math.max(...p)))),Qe(),!(e<=ln)&&(clearInterval(ae),T(`<rb>Performance Warning</>
|
|
21
19
|
|
|
22
|
-
Calculating the page size is taking an excessive amount of time (${
|
|
20
|
+
Calculating the page size is taking an excessive amount of time (${n.round(e)}ms).
|
|
23
21
|
|
|
24
|
-
To improve performance add the <b>data-iframe-size</> attribute to the ${
|
|
25
|
-
`,
|
|
26
|
-
`,
|
|
27
|
-
`,n),j()}),t}function ln(){const e=document.querySelectorAll(`[${nt}]`),t=Zs(e);let n=!0;return typeof Set.prototype.symmetricDifference===we&&(n=t.symmetricDifference(an).size>0),an=t,i.overflowedNodeSet=t,i.hasOverflow=t.size>0,{hasOverflowUpdated:n,overflowedNodeSet:t}}const O={},un=e=>{const t=new Set;for(const n of e)if(n instanceof Element){t.add(n);for(const o of $e(n))t.add(o)}return u(`Inspecting:
|
|
28
|
-
`,t),t},Ys=e=>{if(e.size===0)return;h("addObservers");const t=un(e);O.overflow.attachObservers(t),O.resize.attachObserverToNonStaticElements(t),j()},Qs=e=>{if(e.size===0)return;h("removeObservers");const t=un(e);O.overflow.detachObservers(t),O.resize.detachObservers(t),j()};function Js({addedNodes:e,removedNodes:t}){h("contentMutated"),i.applySelectors(),Bt(),ln(),j(),Qs(t),Ys(e)}function Ks(e){Js(e),E(dt,"Mutation Observed")}const Y="Overflow",Xs=fe(Y),er=fe(Y,!1),tr=tn(Y),nr=nn(Y),or=e=>e instanceof HTMLElement&&(!!e.hidden||e.offsetParent===null||e.style.display===Te),sr=(e,t)=>{const n=t.side,o={root:t.root,rootMargin:"0px",threshold:1},r=window?.requestAnimationFrame||re,d=(S=!1)=>e(S),a=(S,L)=>S===0||S>L[n],f=(S,L)=>{S.toggleAttribute(nt,L)};function v(S){for(const L of S){const{boundingClientRect:X,rootBounds:ee,target:R}=L;if(!ee)continue;const ei=X[n],ti=a(ei,ee)&&!(R instanceof HTMLElement&&or(R));f(R,ti)}r(d)}const m=new IntersectionObserver(v,o),b=new WeakSet;function p(S){const L=new Set,X=new Set;let ee=0;for(const R of S)if(R instanceof Element){if(b.has(R)){L.add(R);continue}m.observe(R),b.add(R),X.add(R),ee+=1}nr(L),tr(X),Xs(ee),X.clear(),L.clear()}return{attachObservers:p,detachObservers:on(Y,m,b,er),disconnect:()=>{m.disconnect(),u("Detached%c OverflowObserver",s.HIGHLIGHT)}}};function rr(){const{hasOverflow:e}=i,{hasOverflowUpdated:t,overflowedNodeSet:n}=ln();switch(!0){case!t:return;case n.size>1:u("Overflowed Elements:",n);break;case e:break;default:u("No overflow detected")}E(Re,"Overflow updated")}function ir(e){const t={root:document.documentElement,side:c.calculateHeight?it:ct};return O.overflow=sr(rr,t),O.overflow.attachObservers(e),O.overflow}const Q="Resize",cr=fe(Q),ar=fe(Q,!1),lr=tn(Q),ur=nn(Q),he=new WeakSet,We=new Set,Ve=new Set;let J;function dr(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)){We.add(n);continue}J.observe(n),he.add(n),Ve.add(n),t+=1}}ur(We),lr(Ve),cr(t),Ve.clear(),We.clear()}const fr=e=>(J=new ResizeObserver(e),J.observe(document.body),he.add(document.body),u("Attached%c ResizeObserver%c to body",s.HIGHLIGHT,s.FOREGROUND),{attachObserverToNonStaticElements:dr,detachObservers:on(Q,J,he,ar),disconnect:()=>{J.disconnect(),u("Detached%c ResizeObserver",s.HIGHLIGHT)}});function mr(e){if(!Array.isArray(e)||e.length===0)return;const t=e[0].target;E(ut,`Element resized <${Fn(t)}>`)}function hr(e){return O.resize=fr(mr),O.resize.attachObserverToNonStaticElements(e),O.resize}let dn;function pr(){const e=document.title;e!==dn&&(dn=e,l(`Title: %c${e}`,s.HIGHLIGHT),e&&g(0,0,kn,e))}function yr(e){l(`Visible: %c${e}`,s.HIGHLIGHT),i.isHidden=!e,E(ft,"Visibility changed")}function gr(e){Le.push(...e.map(t=>t.disconnect))}function vr(){h("attachObservers");const e=$e(document.documentElement),t=[Us(Ks),ir(e),ts(),hr(e),Vs(pr),qs(yr)];gr(t)}const fn=(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 br({sizeSelector:e,ignoreSelector:t}){return()=>{fn("sizeSelector",ze,e),fn("ignoreSelector",B,t)}}function zr(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}function wr(e,t){return t.includes("-")&&(_(`Negative CSS value ignored for ${e}`),t=""),t}function qe(e,t){t===void 0||t===""||t===Cn||(document.body.style.setProperty(e,t),u(`Set body ${e}: %c${t}`,s.HIGHLIGHT))}function Er({bodyMarginStr:e,bodyMargin:t}){e===void 0&&(e=`${t}px`),qe("margin",wr("margin",e))}const Ir=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function Or(e){const t=e.getBoundingClientRect(),n=Ir();return{x:Math.round(t.left+n.x),y:Math.round(t.top+n.y)}}function Sr(e,t){const n=Or(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),g(n.y,n.x,tt)}function Ze(e){const t=e.split("#")[1]||e,n=decodeURIComponent(t),o=document.getElementById(n)||document.getElementsByName(n)[0];if(o!==void 0){Sr(t,o);return}l(`In page link (#${t}) not found in iframe, so sending to parent`),g(0,0,On,`#${t}`)}function mn(){const{hash:e,href:t}=window.location;e!==""&&e!=="#"&&Ze(t)}function Rr(){for(const e of document.querySelectorAll('a[href^="#"]'))e.getAttribute("href")!=="#"&&A(e,"click",t=>{t.preventDefault(),Ze(e.getAttribute("href"))})}function Tr(){A(window,"hashchange",mn)}function Hr(){setTimeout(mn,pt)}function Mr(){l("Setting up location.hash handlers"),Rr(),Tr(),Hr(),i.inPageLinks={findTarget:Ze}}function Lr(e){const{mode:t}=c;e?ke(t)?z(M(5)):Mr():l("In page linking not enabled")}const kr="important";function Ar(){const e=t=>t.style.setProperty(ne,W,kr);e(document.documentElement),e(document.body),l("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}.`)}},Qe=Ye(we),hn=Ye(G),pe=Ye(U),Nr=e=>e!==null&&typeof e===Nn&&!Array.isArray(e);function $r(e){const{calculateHeight:t,calculateWidth:n}=c;let o,r;return typeof e?.offsetSize===G&&(t&&(o=hn(e,st)),n&&(r=hn(e,st))),{offsetHeight:o,offsetWidth:r}}function Gr(e){l("Reading data from page:",Object.keys(e));const{offsetHeight:t,offsetWidth:n}=$r(e);return{offsetHeight:t,offsetWidth:n,ignoreSelector:pe(e,"ignoreSelector"),[_t(3)]:pe(e,_t(0)),sizeSelector:pe(e,"sizeSelector"),targetOrigin:pe(e,"targetOrigin"),onBeforeResize:Qe(e,"onBeforeResize"),onMessage:Qe(e,"onMessage"),onReady:Qe(e,"onReady")}}function Cr(){const{mode:e}=c;if(ke(e))return{};const t=window.iframeResizer||window.iFrameResizer;return Nr(t)?Gr(t):{}}const jr=e=>e==="true",pn=e=>t=>t===void 0?void 0:e(t),P=pn(jr),K=pn(Number),Pr=e=>({parentId:e[0],bodyMargin:K(e[1]),calculateWidth:P(e[2]),logging:P(e[3]),autoResize:P(e[6]),bodyMarginStr:e[7],bodyBackground:e[9],bodyPadding:e[10],tolerance:K(e[11]),inPageLinks:P(e[12]),mouseEvents:P(e[15]),offsetHeight:K(e[16]),offsetWidth:K(e[17]),calculateHeight:P(e[18]),key:e[19],version:e[20],mode:K(e[21]),logExpand:P(e[23])});function _r(e){const{mode:t}=c;e.forEach(n=>{try{n()}catch(o){if(t<0)throw o;z(`<rb>Error in setup function</>
|
|
22
|
+
To improve performance add the <b>data-iframe-size</> attribute to the ${j.Side.toLowerCase()} most element on the page. For more details see: <u>https://iframe-resizer.com/perf</>.`))},dn)}function hn(e){e.getEntries().forEach(t=>{if(t.name===q)try{const{duration:r}=performance.measure(je,oe,q);j=t.detail,p.push(r),p.length>un&&p.shift()}catch{}})}function En(){f("Attached%c PerformanceObserver%c to page",i.HIGHLIGHT,i.FOREGROUND);const e=new PerformanceObserver(hn);return e.observe({entryTypes:["mark"]}),gn(),{disconnect:()=>{Qe(),clearInterval(ae),e.disconnect(),f("Detached%c PerformanceObserver",i.HIGHLIGHT)}}}const In=e=>`:not(${e})`,pn=`* ${Array.from(n.IGNORE_TAGS).map(In).join("")}`,ce=e=>e.querySelectorAll(pn);function On(){const{hasOverflow:e,hasTags:t,overflowedNodeSet:r,taggedElements:s}=a;return t?s:e?Array.from(r):ce(document.documentElement)}function Sn(e,t){const r=`margin-${t}`;let s,o=document.documentElement,u=a.hasTags?n.MIN_SIZE:document.documentElement.getBoundingClientRect().bottom;for(const l of e)s=l.getBoundingClientRect()[t]+parseFloat(getComputedStyle(l).getPropertyValue(r)),s>u&&(u=s,o=l);return{maxEl:o,maxVal:u}}function Ke(e){performance.mark(oe);const t=n.capitalizeFirstLetter(e),{logging:r}=c,{hasTags:s}=a,o=On(),{maxEl:u,maxVal:l}=Sn(o,e);return f(`${t} position calculated from:`,u),f(`Checked %c${o.length}%c elements`,i.HIGHLIGHT,i.FOREGROUND),performance.mark(q,{detail:{hasTags:s,len:o.length,logging:r,Side:t}}),l}const de={label:n.HEIGHT,enabled:()=>c.calculateHeight,getOffset:()=>c.offsetHeight,auto:()=>qe(de),boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().bottom,document.body.getBoundingClientRect().bottom),documentElementScroll:()=>document.documentElement.scrollHeight,taggedElement:()=>Ke(n.HEIGHT_EDGE)},le={label:n.WIDTH,enabled:()=>c.calculateWidth,getOffset:()=>c.offsetWidth,auto:()=>qe(le),boundingClientRect:()=>Math.max(document.documentElement.getBoundingClientRect().right,document.body.getBoundingClientRect().right),documentElementScroll:()=>document.documentElement.scrollWidth,taggedElement:()=>Ke(n.WIDTH_EDGE)};function Tn(e,t,r){const s=c.onBeforeResize(e,t,r);if(s===void 0)throw new TypeError("No value returned from onBeforeResize(), expected a numeric value");if(Number.isNaN(s))throw new TypeError(`Invalid value returned from onBeforeResize(): ${s}, expected Number`);if(s<n.MIN_SIZE)throw new RangeError(`Out of range value returned from onBeforeResize(): ${s}, must be at least ${n.MIN_SIZE}`);return s}const Je=(e,t)=>(r,s)=>{const o=e[r]();return e.enabled()&&c.onBeforeResize!==void 0?Tn(o,s,t):o},Rn=Je(de,n.HEIGHT),bn=Je(le,n.WIDTH);function wn(){(window.scrollY!==0||window.scrollX!==0)&&(f("Reset iframe scroll position to (0, 0)"),window.scrollTo(0,0))}function vn(e,t,r,s){const{heightCalcMode:o,widthCalcMode:u}=c;wn();const l=r??Rn(o,e),g=s??bn(u,e),S=on(l,g)?n.SIZE_CHANGE_DETECTED:e;switch(d(`Resize event: %c${t}`,i.HIGHLIGHT),S){case n.INIT:case n.ENABLE:case n.SIZE_CHANGE_DETECTED:case n.MANUAL_RESIZE_REQUEST:case n.PARENT_RESIZE_REQUEST:a.height=l,a.width=g;case n.SET_OFFSET_SIZE:return a;case n.OVERFLOW_OBSERVER:case n.MUTATION_OBSERVER:case n.RESIZE_OBSERVER:case n.VISIBILITY_OBSERVER:{d(n.NO_CHANGE);break}default:f(n.NO_CHANGE)}return null}let Y=!1,fe=!1,D=null;function yn(e,t,r,s,o){const{autoResize:u}=c,{isHidden:l}=a;switch(E(e),!0){case(l===!0&&!(e in n.IGNORE_DISABLE_RESIZE)):{if(fe===!0)break;d("Iframe hidden - Ignored resize request"),fe=!0,Y=!1,cancelAnimationFrame(D),D=null;break}case(Y===!0&&e!==n.OVERFLOW_OBSERVER&&!(e in n.IGNORE_DISABLE_RESIZE)):{d("Resize already pending - Ignored resize request");break}case(!u&&!(e in n.IGNORE_DISABLE_RESIZE)):{f("Resizing disabled");break}default:{fe=!1,Y=!0,a.totalTime=performance.now(),a.timerActive=!0;const g=vn(e,t,r,s);g&&Ve(g.height,g.width,e,o),D||(D=requestAnimationFrame(()=>{Y=!1,D=null,E("requestAnimationFrame"),W(`Reset sendPending: %c${e}`,i.HIGHLIGHT)})),a.timerActive=!1}}G()}const b=re(yn);function Xe({eventType:e,eventName:t}){N(window,t,()=>b(t,e),{passive:!0})}function Hn(){Xe({eventType:"After Print",eventName:"afterprint"}),Xe({eventType:"Before Print",eventName:"beforeprint"})}function An(){if(a.triggerLocked){d("TriggerLock blocked calculation");return}a.triggerLocked=!0,W("Trigger event lock on"),requestAnimationFrame(()=>{a.triggerLocked=!1,W("Trigger event lock off")})}function et(e){const{heightCalcMode:t,widthCalcMode:r}=c,s=de[t](),o=le[r]();d(`Reset trigger event: %c${e}`,i.HIGHLIGHT),O(s,o,e)}function Nn(e){const t=c.heightCalcMode;d(`Reset trigger event: %c${e}`,i.HIGHLIGHT),c.heightCalcMode=n.HEIGHT_CALC_MODE_DEFAULT,An(),et("reset"),c.heightCalcMode=t}const Mn=`Auto Resize can not be changed when <b>direction</> is set to '${n.NONE}'.`;function Ln(e){n.typeAssert(e,n.BOOLEAN,"parentIframe.autoResize(enable) enable");const{autoResize:t,calculateHeight:r,calculateWidth:s}=c;return s===!1&&r===!1?(E(n.ENABLE),T(Mn),!1):(e===!0&&t===!1?(c.autoResize=!0,queueMicrotask(()=>b(n.ENABLE,"Auto Resize enabled"))):e===!1&&t===!0&&(c.autoResize=!1),O(0,0,n.AUTO_RESIZE,JSON.stringify(c.autoResize)),c.autoResize)}function Gn(e){n.typeAssert(e,n.STRING,"parentIframe.moveToAnchor(anchor) anchor"),a.inPageLinks.findTarget(e)}function zn(e){n.typeAssert(e,n.NUMBER,"parentIframe.setOffsetSize(offset) offset"),c.offsetHeight=e,c.offsetWidth=e,b(n.SET_OFFSET_SIZE,`parentIframe.setOffsetSize(${e})`)}const $n=()=>a.origin;function _n(e){n.typeAssert(e,n.STRING,"parentIframe.setTargetOrigin(targetOrigin) targetOrigin"),d(`Set targetOrigin: %c${e}`,i.HIGHLIGHT),c.targetOrigin=e}function kn(e){return n.typeAssert(e,n.FUNCTION,"parentIframe.getParentProps(callback) callback"),a.onParentInfo=e,O(0,0,n.PARENT_INFO),()=>{a.onParentInfo=null,O(0,0,n.PARENT_INFO_STOP)}}function Cn(e,t){e!==void 0&&n.typeAssert(e,n.NUMBER,"parentIframe.resize(customHeight, customWidth) customHeight"),t!==void 0&&n.typeAssert(t,n.NUMBER,"parentIframe.resize(customHeight, customWidth) customWidth");const r=e===void 0?"":e,s=t===void 0?"":`,${t}`,o=`${r}${s}`;b(n.MANUAL_RESIZE_REQUEST,`parentIframe.resize(${o})`,e,t)}const ue=e=>(t,r)=>{n.typeAssert(t,n.NUMBER,`parentIframe.${e}(x, y) x`),n.typeAssert(r,n.NUMBER,`parentIframe.${e}(x, y) y`),O(r,t,e)},Dn=ue(n.SCROLL_BY),Pn=ue(n.SCROLL_TO),Bn=ue(n.SCROLL_TO_OFFSET);function Fn(e,t){t&&n.typeAssert(t,n.STRING,"parentIframe.sendMessage(msg, targetOrigin) targetOrigin"),O(0,0,n.MESSAGE,JSON.stringify(e),t)}const Un=()=>O(0,0,n.CLOSE),mn=()=>c.parentId,xn=()=>Nn("parentIframe.reset");function Vn(){const{win:e}=a;c.mode!==1&&(e.parentIframe=Object.freeze({autoResize:Ln,close:Un,getId:mn,getParentOrigin:$n,getParentProps:kn,moveToAnchor:Gn,reset:xn,setOffsetSize:zn,scrollBy:Dn,scrollTo:Pn,scrollToOffset:Bn,sendMessage:Fn,setTargetOrigin:_n,resize:Cn}))}const P=(e="")=>t=>r=>{r.size>0&&W(`${t}Observer ${e}:`,...Array.from(r).flatMap(s=>[n.NEW_LINE,s]))},Wn=(e="")=>t=>r=>{r.size>0&&Me(`${t}Observer ${e}:`,...Array.from(r).flatMap(s=>[n.NEW_LINE,s]))},tt=P("attached to"),nt=Wn("already attached"),Zn=P("detached from"),Q=(e,t=!0)=>r=>{r>0&&f(`${t?"At":"De"}tached %c${e}Observer%c ${t?"to":"from"} %c${r}%c element${r===1?"":"s"}`,i.HIGHLIGHT,i.NORMAL,i.HIGHLIGHT,i.NORMAL)},rt=(e,t,r,s)=>{const o=Zn(e);return u=>{const l=new Set;let g=0;for(const S of u)r.has(S)&&(t.unobserve(S),r.delete(S),l.add(S),g+=1);o(l),s(g),l.clear()}},st=16,it=2,qn=200,ge="Mutation",w=new Set,L=new Set,he=new Set,K=[],jn={attributes:!0,attributeFilter:[n.IGNORE_ATTR,n.SIZE_ATTR],attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};let Ee=1,Ie,pe=!1,Oe=0;const Yn=P("added")(ge),Qn=P("removed (page)")(ge),Kn=P("removed (added)")(ge),ot=e=>e.nodeType!==Node.ELEMENT_NODE||n.IGNORE_TAGS.has(e.tagName.toLowerCase());function Jn(e){const t=e.addedNodes;for(const r of t)ot(r)||w.add(r)}function Xn(e){const t=e.removedNodes;for(const r of t)ot(r)||(w.has(r)?(w.delete(r),he.add(r)):L.add(r))}const er=e=>{f("Mutations:",e);for(const t of e)Jn(t),Xn(t);Yn(w),Qn(L),Kn(he),he.clear()};function tr(){L.size>0&&d(`Detected %c${L.size} %cremoved element${L.size>1?"s":""}`,i.HIGHLIGHT,i.FOREGROUND),w.size>0&&d(`Found %c${w.size} %cnew element${w.size>1?"s":""}`,i.HIGHLIGHT,i.FOREGROUND)}const nr=e=>()=>{const t=performance.now(),r=t-Oe,s=st*Ee+++it;if(r>s&&r<qn){E("mutationThrottled"),f("Update delayed due to heavy workload on the callStack"),f(`EventLoop busy time: %c${n.round(r)}ms %c> Max wait: %c${s-it}ms`,i.HIGHLIGHT,i.FOREGROUND,i.HIGHLIGHT),setTimeout(Ie,st*Ee),Oe=t;return}Ee=1,K.forEach(er),K.length=0,pe=!1,tr(),e({addedNodes:w,removedNodes:L}),w.clear(),L.clear()};function rr(e){K.push(e),!pe&&(Oe=performance.now(),pe=!0,requestAnimationFrame(Ie))}function sr(e){const t=new window.MutationObserver(rr),r=document.body||document.documentElement;return Ie=nr(e),t.observe(r,jn),f("Attached%c MutationObserver%c to body",i.HIGHLIGHT,i.FOREGROUND),{disconnect:()=>{w.clear(),L.clear(),K.length=0,t.disconnect(),f("Detached%c MutationObserver",i.HIGHLIGHT)}}}const ir={characterData:!0,childList:!0,subtree:!0};function or(e){const t=document.querySelector("title")??document.head??document.documentElement,r=new MutationObserver(e);return r.observe(t,ir),f("Attached%c TitleObserver%c to head",i.HIGHLIGHT,i.FOREGROUND),setTimeout(e),{disconnect:()=>{r.disconnect(),f("Detached%c TitleObserver",i.HIGHLIGHT)}}}function ar(e){const t=new IntersectionObserver(s=>e(s.at(-1)?.isIntersecting??!1),{threshold:0}),r=document.documentElement;return t.observe(r),f("Attached%c VisibilityObserver%c to page",i.HIGHLIGHT,i.FOREGROUND),{disconnect:()=>{t.disconnect(),f("Detached%c VisibilityObserver",i.HIGHLIGHT)}}}let at=new Set;function cr(e){const t=new Set,r=new Set;for(const s of e)s.closest(`[${n.IGNORE_ATTR}]`)?r.add(s):t.add(s);return r.size>0&&queueMicrotask(()=>{E("overflowIgnored"),f(`Ignoring elements with [data-iframe-ignore] > *:
|
|
23
|
+
`,r),G()}),t}function ct(){const e=document.querySelectorAll(`[${n.OVERFLOW_ATTR}]`),t=cr(e);let r=!0;return typeof Set.prototype.symmetricDifference===n.FUNCTION&&(r=t.symmetricDifference(at).size>0),at=t,a.overflowedNodeSet=t,a.hasOverflow=t.size>0,{hasOverflowUpdated:r,overflowedNodeSet:t}}const v={},dt=e=>{const t=new Set;for(const r of e)if(r instanceof Element){t.add(r);for(const s of ce(r))t.add(s)}return f(`Inspecting:
|
|
24
|
+
`,t),t},dr=e=>{if(e.size===0)return;E("addObservers");const t=dt(e);v.overflow.attachObservers(t),v.resize.attachObserverToNonStaticElements(t),G()},lr=e=>{if(e.size===0)return;E("removeObservers");const t=dt(e);v.overflow.detachObservers(t),v.resize.detachObservers(t),G()};function fr({addedNodes:e,removedNodes:t}){E("contentMutated"),a.applySelectors(),xe(),ct(),G(),lr(t),dr(e)}function ur(e){fr(e),b(n.MUTATION_OBSERVER,"Mutation Observed")}const B="Overflow",gr=Q(B),hr=Q(B,!1),Er=tt(B),Ir=nt(B),pr=e=>e instanceof HTMLElement&&(!!e.hidden||e.offsetParent===null||e.style.display===n.NONE),Or=(e,t)=>{const r=t.side||n.HEIGHT_EDGE,s={root:t.root,rootMargin:"0px",threshold:1},o=window?.requestAnimationFrame||n.id,u=(y=!1)=>e(y),l=(y,A)=>y===0||y>A[r],g=(y,A)=>{y.toggleAttribute(n.OVERFLOW_ATTR,A)};function S(y){for(const A of y){const{boundingClientRect:x,rootBounds:V,target:H}=A;if(!V)continue;const hs=x[r],Es=l(hs,V)&&!(H instanceof HTMLElement&&pr(H));g(H,Es)}o(u)}const h=new IntersectionObserver(S,s),R=new WeakSet;function I(y){const A=new Set,x=new Set;let V=0;for(const H of y)if(H instanceof Element){if(R.has(H)){A.add(H);continue}h.observe(H),R.add(H),x.add(H),V+=1}Ir(A),Er(x),gr(V),x.clear(),A.clear()}return{attachObservers:I,detachObservers:rt(B,h,R,hr),disconnect:()=>{h.disconnect(),f("Detached%c OverflowObserver",i.HIGHLIGHT)}}};function Sr(){const{hasOverflow:e}=a,{hasOverflowUpdated:t,overflowedNodeSet:r}=ct();switch(!0){case!t:return;case r.size>1:f("Overflowed Elements:",r);break;case e:break;default:f("No overflow detected")}b(n.OVERFLOW_OBSERVER,"Overflow updated")}function Tr(e){const t={root:document.documentElement,side:c.calculateHeight?n.HEIGHT_EDGE:n.WIDTH_EDGE};return v.overflow=Or(Sr,t),v.overflow.attachObservers(e),v.overflow}const F="Resize",Rr=Q(F),br=Q(F,!1),wr=tt(F),vr=nt(F),J=new WeakSet,Se=new Set,Te=new Set;let U;function yr(e){let t=0;for(const r of e){if(!(r instanceof Element))continue;const s=getComputedStyle(r)?.position;if(!(s===""||s==="static")){if(J.has(r)){Se.add(r);continue}U.observe(r),J.add(r),Te.add(r),t+=1}}vr(Se),wr(Te),Rr(t),Te.clear(),Se.clear()}const Hr=e=>(U=new ResizeObserver(e),U.observe(document.body),J.add(document.body),f("Attached%c ResizeObserver%c to body",i.HIGHLIGHT,i.FOREGROUND),{attachObserverToNonStaticElements:yr,detachObservers:rt(F,U,J,br),disconnect:()=>{U.disconnect(),f("Detached%c ResizeObserver",i.HIGHLIGHT)}});function Ar(e){if(!Array.isArray(e)||e.length===0)return;const t=e[0].target;b(n.RESIZE_OBSERVER,`Element resized <${n.getElementName(t)}>`)}function Nr(e){return v.resize=Hr(Ar),v.resize.attachObserverToNonStaticElements(e),v.resize}let lt;function Mr(){const e=document.title;e!==lt&&(lt=e,d(`Title: %c${e}`,i.HIGHLIGHT),e&&O(0,0,n.TITLE,e))}function Lr(e){d(`Visible: %c${e}`,i.HIGHLIGHT),a.isHidden=!e,b(n.VISIBILITY_OBSERVER,"Visibility changed")}function Gr(e){ie.push(...e.map(t=>t.disconnect))}function zr(){E("attachObservers");const e=ce(document.documentElement),t=[sr(ur),Tr(e),En(),Nr(e),or(Mr),ar(Lr)];Gr(t)}const ft=(e,t,r)=>{if(r!==""){d(`${e}: %c${r}`,i.HIGHLIGHT);for(const s of document.querySelectorAll(r))d(`Applying ${t} to:`,s),s.toggleAttribute(t,!0)}};function $r({sizeSelector:e,ignoreSelector:t}){return()=>{ft("sizeSelector",n.SIZE_ATTR,e),ft("ignoreSelector",n.IGNORE_ATTR,t)}}function _r(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}function kr(e,t){return t.includes("-")&&($(`Negative CSS value ignored for ${e}`),t=""),t}function Re(e,t){t===void 0||t===""||t===n.NULL||(document.body.style.setProperty(e,t),f(`Set body ${e}: %c${t}`,i.HIGHLIGHT))}function Cr({bodyMarginStr:e,bodyMargin:t}){e===void 0&&(e=`${t}px`),Re("margin",kr("margin",e))}const Dr=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function Pr(e){const t=e.getBoundingClientRect(),r=Dr();return{x:Math.round(t.left+r.x),y:Math.round(t.top+r.y)}}function Br(e,t){const r=Pr(t);d(`Moving to in page link (%c#${e}%c) at x: %c${r.x}%c y: %c${r.y}`,i.HIGHLIGHT,i.FOREGROUND,i.HIGHLIGHT,i.FOREGROUND,i.HIGHLIGHT),O(r.y,r.x,n.SCROLL_TO_OFFSET)}function be(e){const t=e.split("#")[1]||e,r=decodeURIComponent(t),s=document.getElementById(r)||document.getElementsByName(r)[0];if(s!==void 0){Br(t,s);return}d(`In page link (#${t}) not found in iframe, so sending to parent`),O(0,0,n.IN_PAGE_LINK,`#${t}`)}function ut(){const{hash:e,href:t}=window.location;e!==""&&e!=="#"&&be(t)}function Fr(){for(const e of document.querySelectorAll('a[href^="#"]'))e.getAttribute("href")!=="#"&&N(e,"click",t=>{t.preventDefault(),be(e.getAttribute("href"))})}function Ur(){N(window,"hashchange",ut)}function mr(){setTimeout(ut,n.EVENT_CANCEL_TIMER)}function xr(){d("Setting up location.hash handlers"),Fr(),Ur(),mr(),a.inPageLinks={findTarget:be}}function Vr(e){const{mode:t}=c;e?n.checkMode(t)?T(n.getModeData(5)):xr():d("In page linking not enabled")}const Wr="important";function Zr(){const e=t=>t.style.setProperty(n.HEIGHT,n.AUTO,Wr);e(document.documentElement),e(document.body),d("Set HTML & body height: %cauto !important",i.HIGHLIGHT)}const we=e=>(t,r)=>{if(r in t){if(typeof t[r]===e)return t[r];throw new TypeError(`${r} is not a ${e}.`)}},ve=we(n.FUNCTION),gt=we(n.NUMBER),X=we(n.STRING),qr=e=>e!==null&&typeof e===n.OBJECT&&!Array.isArray(e);function jr(e){const{calculateHeight:t,calculateWidth:r}=c;let s,o;return typeof e?.offsetSize===n.NUMBER&&(t&&(s=gt(e,n.OFFSET_SIZE)),r&&(o=gt(e,n.OFFSET_SIZE))),{offsetHeight:s,offsetWidth:o}}function Yr(e){d("Reading data from page:",Object.keys(e));const{offsetHeight:t,offsetWidth:r}=jr(e);return{offsetHeight:t,offsetWidth:r,ignoreSelector:X(e,"ignoreSelector"),[n.getKey(3)]:X(e,n.getKey(0)),sizeSelector:X(e,"sizeSelector"),targetOrigin:X(e,"targetOrigin"),onBeforeResize:ve(e,"onBeforeResize"),onMessage:ve(e,"onMessage"),onReady:ve(e,"onReady")}}function Qr(){const{mode:e}=c;if(n.checkMode(e))return{};const t=window.iframeResizer||window.iFrameResizer;return qr(t)?Yr(t):{}}const Kr=e=>e==="true",ht=e=>t=>t===void 0?void 0:e(t),z=ht(Kr),m=ht(Number),Jr=e=>({parentId:e[0],bodyMargin:m(e[1]),calculateWidth:z(e[2]),logging:z(e[3]),autoResize:z(e[6]),bodyMarginStr:e[7],bodyBackground:e[9],bodyPadding:e[10],tolerance:m(e[11]),inPageLinks:z(e[12]),mouseEvents:z(e[15]),offsetHeight:m(e[16]),offsetWidth:m(e[17]),calculateHeight:z(e[18]),key:e[19],version:e[20],mode:m(e[21]),logExpand:z(e[23])});function Xr(e){const{mode:t}=c;e.forEach(r=>{try{r()}catch(s){if(t<0)throw s;T(`<rb>Error in setup function</>
|
|
29
25
|
<i>iframe-resizer</> detected an error during setup.
|
|
30
26
|
|
|
31
|
-
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</>`),Me(s)}})}function Et(e){for(const[t,r]of Object.entries(e))r!==void 0&&(c[t]=r)}function es({logExpand:e,logging:t,parentId:r=""}){St({id:r,enabled:t,expand:e}),E("initReceived"),d(`Initialising iframe v${n.VERSION} ${window.location.href}`)}function ts(e){E("ready"),me(n.once(e)),d("Initialization complete",(({key:t,key2:r,...s})=>s)(c))}function ns({bodyBackground:e,bodyPadding:t,inPageLinks:r,onReady:s}){const o=Ct(c),u=[Bt,Dt,Vt,xe,Zt,o?n.id:kt,()=>Cr(c),()=>Re("background",e),()=>Re("padding",t),o?n.id:Zr,_r,a.applySelectors,()=>Vr(r),Hn,()=>tn(c),sn,()=>Vn(),()=>b(n.INIT,"Init message from host page",void 0,void 0,`${n.VERSION}:${c.mode}`),zr,G];Yt(c),Ut(c),Xr(u),ts(s)}function rs(e){a.firstRun&&(Et(Jr(e)),es(c),Et(Qr()),a.applySelectors=$r(c),ns(c))}function ss(e){if(document.readyState==="loading"){d("Page not ready, ignoring init message");return}const t=e.data.slice(n.MESSAGE_ID_LENGTH).split(n.SEPARATOR);a.target=e.source,a.origin=e.origin,rs(t),a.firstRun=!1,setTimeout(()=>{a.initLock=!1},n.EVENT_CANCEL_TIMER)}const{freeze:is}=Object,{parse:ye}=JSON,He=e=>is(ye(e)),It=e=>O(0,0,`${e}Stop`),ee=e=>e.data.slice(e.data.indexOf(n.SEPARATOR)+1),os=e=>yt(e)?n.INIT:e.data.split("]")[1].split(n.SEPARATOR)[0];function as(e){const t=ee(e);d("onMessage called from parent:%c",i.HIGHLIGHT,He(t)),n.isolateUserCode(c.onMessage,ye(t))}function cs(e){const{onPageInfo:t}=a,r=ee(e);d("PageInfo received from parent:",He(r)),t?n.isolateUserCode(t,ye(r)):It(n.PAGE_INFO)}function ds(e){const{onParentInfo:t}=a,r=He(ee(e));d("ParentInfo received from parent:",r),t?n.isolateUserCode(t,r):It(n.PARENT_INFO)}function ls(){if(a.initLock){d("Page reset ignored by init");return}d("Page size reset by host page"),et("resetPage")}function fs(){d("Resize requested by host page"),b(n.PARENT_RESIZE_REQUEST,"Parent window requested size check")}const pt=e=>a.inPageLinks.findTarget(ee(e)),Ot={init:ss,reset:ls,resize:fs,moveToAnchor:pt,inPageLink:pt,pageInfo:cs,parentInfo:ds,message:as};function us(e){const{firstRun:t}=a,r=os(e);switch(E(r),!0){case r in Ot:Ot[r](e);break;case(t&&vt()):$(`Ignored message of type "${r}". Received before initialization.`);break;default:$(`Unexpected message (${e.data}), this is likely due to a newer version of iframe-resizer running on the parent page.`)}}const te=re(e=>{wt(e)&&us(e)});function gs(){if("iframeChildListener"in window){$("Already setup");return}window.iframeChildListener=(t=>{setTimeout(()=>te({data:t,sameOrigin:!0}))}),E("listen"),N(window,n.MESSAGE,te),N(document,n.READY_STATE_CHANGE,ke),ke();function e(t){return te(t),a.win}try{top?.document?.getElementById("banner")&&(a.win={},window.mockMsgListener=e,ze(window,n.MESSAGE,te),typeof window.define=="function"&&window.define([],()=>e))}catch{}}typeof window!==n.UNDEFINED&&gs()}));
|
|
32
28
|
//# sourceMappingURL=index.umd.js.map
|