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