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