@iframe-resizer/jquery 5.2.2-beta.2 → 5.2.2-beta.3

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/index.umd.js CHANGED
@@ -1,21 +1,1388 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/jquery 5.2.2-beta.2 (umd) - 2024-07-18
4
+ * @module iframe-resizer/jquery 5.2.2-beta.3 (umd) - 2024-07-25
5
5
  *
6
- * @license GPL-3.0 for non-commercial use only.
7
- * For commercial use, you must purchase a license from
8
- * https://iframe-resizer.com/pricing
6
+ * @license GPL-3.0 for non-commercial use only.
7
+ * For commercial use, you must purchase a license from
8
+ * https://iframe-resizer.com/pricing
9
9
  *
10
- * @desciption Keep same and cross domain iFrames sized to their content
10
+ * @description Keep same and cross domain iFrames sized to their content
11
11
  *
12
- * @author David J. Bradshaw <info@iframe-resizer.com>
12
+ * @author David J. Bradshaw <info@iframe-resizer.com>
13
13
  *
14
- * @see {@link https://iframe-resizer.com}
14
+ * @see {@link https://iframe-resizer.com}
15
15
  *
16
16
  * @copyright (c) 2013 - 2024, David J. Bradshaw. All rights reserved.
17
17
  */
18
18
 
19
19
 
20
- !function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="5.2.2-beta.2",i="[iFrameSizer]",t=i.length,n=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),o=(e,i,t,n)=>e.addEventListener(i,t,n||!1),r=(e,i,t)=>e.removeEventListener(i,t,!1),a="[iframe-resizer]";let s={},l=!1;const c=e=>`${a}[${function(e){return window.top===window.self?`Parent page: ${e}`:window?.parentIFrame?.getId?`${window.parentIFrame.getId()}: ${e}`:`Nested parent page: ${e}`}(e)}]`,d=(e,i,...t)=>window?.console[e](c(i),...t),u=(e,...i)=>!0===(e=>s[e]?s[e].log:l)(e)?d("log",e,...i):null,f=(e,...i)=>d("warn",e,...i),p=(e,i)=>console?.warn((e=>i=>window.chrome?e(i.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):e(i.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,"")))((e=>(...i)=>[`${a}[${e}]`,...i].join(" "))(e))(i)),m=e=>{if(!e)return"";let i=-559038744,t=1103547984;for(let n,o=0;o<e.length;o++)n=e.codePointAt(o),i=Math.imul(i^n,2246822519),t=Math.imul(t^n,3266489917);return i^=Math.imul(i^t>>>15,1935289751),t^=Math.imul(t^i>>>15,3405138345),i^=t>>>16,t^=i>>>16,(2097152*(t>>>0)+(i>>>11)).toString(36)},h=e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))),g=["<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>","<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>","Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>","<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>."],y=["NWSc3","zvsv","wyv","ibzpulzz","vlt"],w=Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,i)=>[e,Math.max(0,i-1)]))),b=e=>h(g[e]),v=e=>{const i=e[h("spjluzl")];if(!i)return-1;const t=i.split("-");let n=function(e=""){let i=-2;const t=m(h(e));return t in w&&(i=w[t]),i}(t[0]);return 0===n||(e=>e[2]===m(e[0]+e[1]))(t)||(n=-2),n},z={},$=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:"vertical",inPageLinks:!1,heightCalculationMethod:"auto",id:"iFrameResizer",log:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,waitForLoad:!1,widthCalculationMethod:"auto",onClose:()=>!0,onClosed(){},onInit:!1,onMessage:null,onMouseEnter(){},onMouseLeave(){},onReady:e=>{"function"==typeof z[e.id].onInit&&(p(e.id,"\nDeprecated Option\n\nThe onInit() function is deprecated and has been replaced with onReady(). It will be removed in a future version of iFrame Resizer.\n "),z[e.id].onInit(e))},onResized(){},onScroll:()=>!0}),j={position:null,version:e};function k(n){function a(){W(H),M(P),A("onResized",H)}function s(e){if("border-box"!==e.boxSizing)return 0;return(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}function l(e){if("border-box"!==e.boxSizing)return 0;return(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}function c(e){return D.slice(D.indexOf(":")+7+e)}const d=(e,i)=>(t,n)=>{const o={};var r,a;r=function(){C(`Send ${e} (${t})`,`${e}:${i()}`,n)},o[a=n]||(r(),o[a]=requestAnimationFrame((()=>{o[a]=null})))},m=(e,i)=>()=>{const t=i=>()=>{z[s]?e(i,s):a()};function n(e,n){u(s,`${e} listeners for send${i}`),n(window,"scroll",t("scroll")),n(window,"resize",t("resize window"))}function a(){n("Remove ",r),l.disconnect(),c.disconnect()}const s=P,l=new ResizeObserver(t("page observed")),c=new ResizeObserver(t("iframe observed"));n("Add ",o),l.observe(document.body,{attributes:!0,childList:!0,subtree:!0}),c.observe(z[s].iframe,{attributes:!0,childList:!1,subtree:!1}),z[s]&&(z[s][`stop${i}`]=a)},h=e=>()=>{e in z[P]&&(z[P][e](),delete z[P][e])},g=d("pageInfo",(function(){const e=document.body.getBoundingClientRect(),i=H.iframe.getBoundingClientRect(),{scrollY:t,scrollX:n,innerHeight:o,innerWidth:r}=window,{clientHeight:a,clientWidth:s}=document.documentElement;return JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(a,o||0),clientWidth:Math.max(s,r||0),offsetTop:parseInt(i.top-e.top,10),offsetLeft:parseInt(i.left-e.left,10),scrollTop:t,scrollLeft:n,documentHeight:a,documentWidth:s,windowHeight:o,windowWidth:r})})),y=d("parentInfo",(function(){const{iframe:e}=H,{scrollWidth:i,scrollHeight:t}=document.documentElement,{width:n,height:o,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}=window.visualViewport;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:i,scrollHeight:t},viewport:{width:n,height:o,offsetLeft:r,offsetTop:a,pageLeft:s,pageTop:l,scale:c}})})),w=m(g,"PageInfo"),b=m(y,"ParentInfo"),v=h("stopPageInfo"),$=h("stopParentInfo");function k(e){const i=e.getBoundingClientRect();return S(P),{x:Number(i.left)+Number(j.position.x),y:Number(i.top)+Number(j.position.y)}}function I(e){const i=e?k(H.iframe):{x:0,y:0};let t=((e,i)=>({x:e.width+i.x,y:e.height+i.y}))(H,i);u(P,`Reposition requested from iFrame (offset x:${i.x} y:${i.y})`),window.top===window.self?(j.position=t,L(P),u(P,"--")):window.parentIFrame?window.parentIFrame["scrollTo"+(e?"Offset":"")](t.x,t.y):f(P,"Unable to scroll to requested position, window.parentIFrame not found")}function L(e){const{x:i,y:t}=j.position,n=z[e]?.iframe;!1!==A("onScroll",{iframe:n,top:t,left:i,x:i,y:t})?M(e):x()}function E(e){let i={};if(0===H.width&&0===H.height){const e=c(9).split(":");i={x:e[1],y:e[0]}}else i={x:H.width,y:H.height};A(e,{iframe:H.iframe,screenX:Number(i.x),screenY:Number(i.y),type:H.type})}const A=(e,i)=>T(P,e,i);let D=n.data,H={},P=null;"[iFrameResizerChild]Ready"!==D?i===`${D}`.slice(0,t)&&D.slice(t).split(":")[0]in z?(H=function(){const e=D.slice(t).split(":"),i=e[1]?Number(e[1]):0,n=z[e[0]]?.iframe,o=getComputedStyle(n);return{iframe:n,id:e[0],height:i+s(o)+l(o),width:Number(e[2]),type:e[3],msg:e[4]}}(),P=H.id,P?(function(e){if(!z[e])throw new Error(`${H.type} No settings for ${e}. Message was: ${D}`)}(P),function(){const e=H.type in{true:1,false:1,undefined:1};return e&&u(P,"Ignoring init message from meta parent page"),e}()||(u(P,`Received: ${D}`),z[P].loaded=!0,function(){let e=!0;return null===H.iframe&&(f(P,`The iframe (${H.id}) was not found.`),e=!1),e}()&&function(){const{origin:e,sameDomain:i}=n;if(i)return!0;let t=z[P]?.checkOrigin;if(t&&"null"!=`${e}`&&!(t.constructor===Array?function(){let i=0,n=!1;for(u(P,`Checking connection is from allowed list of origins: ${t}`);i<t.length;i++)if(t[i]===e){n=!0;break}return n}():function(){const i=z[P]?.remoteHost;return u(P,`Checking connection is from: ${i}`),e===i}()))throw new Error(`Unexpected message received from: ${e} for ${H.iframe.id}. Message was: ${n.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`);return!0}()&&function(){switch(z[P]?.firstRun&&z[P]&&(z[P].firstRun=!1),H.type){case"close":R(H.iframe);break;case"message":t=c(6),u(P,`onMessage passed: {iframe: ${H.iframe.id}, message: ${t}}`),A("onMessage",{iframe:H.iframe,message:JSON.parse(t)}),u(P,"--");break;case"mouseenter":E("onMouseEnter");break;case"mouseleave":E("onMouseLeave");break;case"autoResize":z[P].autoResize=JSON.parse(c(9));break;case"scrollBy":!function(){const e=H.width,i=H.height,t=window.parentIframe||window;u(P,`Scroll request received by parent: x: ${e} y: ${i}`),t.scrollBy(e,i)}();break;case"scrollTo":I(!1);break;case"scrollToOffset":I(!0);break;case"pageInfo":g("start",P),w();break;case"parentInfo":y("start",P),b();break;case"pageInfoStop":v();break;case"parentInfoStop":$();break;case"inPageLink":!function(e){const i=e.split("#")[1]||"",t=decodeURIComponent(i);let n=document.getElementById(t)||document.getElementsByName(t)[0];n?function(){const e=k(n);u(P,`Moving to in page link (#${i}) at x: ${e.x} y: ${e.y}`),j.position={x:e.x,y:e.y},L(P),window.location.hash=i,u(P,"--")}():window.top!==window.self?window.parentIFrame?window.parentIFrame.moveToAnchor(i):u(P,`In page link #${i} not found and window.parentIFrame not found`):u(P,`In page link #${i} not found`)}(c(9));break;case"title":!function(e,i){z[i]?.syncTitle&&(z[i].iframe.title=e,u(i,`Set title attribute to: ${e}`))}(H.msg,P);break;case"reset":F(H);break;case"init":a(),function(e){try{z[e].sameDomain=!!z[e]?.iframe?.contentWindow?.iframeChildListener}catch(i){z[e].sameDomain=!1}u(e,`sameDomain: ${z[e].sameDomain}`)}(P),(i=H.msg)!==e&&(void 0!==i?u(P,`Version mismatch (Child: ${i} !== Parent: ${e})`):p(P,"<rb>Legacy version detected in iframe</>\n\nDetected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.\n\nSee <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.\n")),N=!0,A("onReady",H.iframe);break;default:if(0===H.width&&0===H.height)return void f(`Unsupported message received (${H.type}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===H.width||0===H.height)return void u(P,"Ignoring message with 0 height or width");if(document.hidden)return void u(P,"Page hidden - ignored resize request");a()}var i,t}())):f("iframeResizer received messageData without id, message was: ",D)):null!==P&&u(P,"Ignored:",D):Object.keys(z).forEach((e=>{z[e].mode>=0&&C("iFrame requested init",O(e),e)}))}function T(e,i,t){let n=null,o=null;if(z[e]){if(n=z[e][i],"function"!=typeof n)throw new TypeError(`${i} on iFrame[${e}] is not a function`);o=n(t)}return o}function I(e){const i=e.id;delete z[i]}function R(e){const i=e.id;if(!1!==T(i,"onClose",i)){u(i,`Removing iFrame: ${i}`);try{e.parentNode&&e.remove()}catch(e){f(e)}T(i,"onClosed",i),u(i,"--"),I(e)}else u(i,"Close iframe cancelled by onClose event")}function S(e){null===j.position&&(j.position={x:window.scrollX,y:window.scrollY},u(e,`Get page position: ${j.position.x}, ${j.position.y}`))}function x(){j.position=null}function M(e){null!==j.position&&(window.scrollTo(j.position.x,j.position.y),u(e,`Set page position: ${j.position.x}, ${j.position.y}`),x())}function F(e){u(e.id,"Size reset requested by "+("init"===e.type?"parent page":"child page")),S(e.id),W(e),C("reset","reset",e.id)}function W(e){const i=e.id;function t(t){const n=`${e[t]}px`;e.iframe.style[t]=n,u(i,`IFrame (${i}) ${t} set to ${n}`)}z[i].sizeHeight&&t("height"),z[i].sizeWidth&&t("width")}function C(e,t,n,o){z[n]&&(z[n]?.postMessageTarget?function(){const{postMessageTarget:o,targetOrigin:r}=z[n];if(z[n].sameDomain)try{return z[n].iframe.contentWindow.iframeChildListener(i+t),void u(n,`[${e}] Sending message to iframe[${n}] (${t}) via sameDomain`)}catch(e){u(n,"Same domain connection failed. Trying cross domain")}u(n,`[${e}] Sending message to iframe[${n}] (${t}) targetOrigin: ${r}`),o.postMessage(i+t,r)}():f(n,`[${e}] IFrame(${n}) not found`),o&&z[n]?.warningTimeout&&(z[n].msgTimeout=setTimeout((function(){if(void 0===z[n])return;const{waitForLoad:e}=z[n];z[n].loaded||z[n].loadErrorShown||(z[n].loadErrorShown=!0,p(n,`\n<rb>No response from iFrame</>\n \nThe iframe (<i>${n}</>) has not responded within ${z[n].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${e?"\nThe <b>waitForLoad</> option is currently set to <b>true</>. If the iframe loads before the JavaScript runs, this option will prevent <i>iframe-resizer</> from initialising. To disable this, set the <b>waitForLoad</> option to <b>false</>. \n":""}\nThis message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.\n`))}),z[n].warningTimeout)))}function O(e){const i=z[e];return[e,"8",i.sizeWidth,i.log,"32",!0,i.autoResize,i.bodyMargin,i.heightCalculationMethod,i.bodyBackground,i.bodyPadding,i.tolerance,i.inPageLinks,"child",i.widthCalculationMethod,i.mouseEvents,i.offsetHeight,i.offsetWidth,i.sizeHeight,i.license,j.version,i.mode].join(":")}s=z;let L=0,N=!1,E=!1;const A=i=>t=>{function r(e){if(!e)return{};if("object"!=typeof e)throw new TypeError("Options is not an object");return("sizeWidth"in e||"sizeHeight"in e||"autoResize"in e)&&p(s,'<rb>Deprecated Option</>\n\nThe <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <i>"vertical"</>, <i>"horizontal"</> or <i>"horizontal"</>.\n'),e}function a(e){const i=z[e]?.iframe?.title;return""===i||void 0===i}const s=function(e){if(e&&"string"!=typeof e)throw new TypeError("Invalid id for iFrame. Expected String");var n;return""!==e&&e||(t.id=e=function(){let e=i?.id||$.id+L++;return null!==document.getElementById(e)&&(e+=L++),e}(),n=(i||{}).log,l=n,u(e,`Added missing iframe ID: ${e} (${t.src})`)),e}(t.id);return s in z&&"iFrameResizer"in t?f(s,"Ignored iFrame, already setup."):(function(e){var i,n;z[s]={iframe:t,firstRun:!0,remoteHost:t?.src.split("/").slice(0,3).join("/"),...$,...r(e),mode:v(e),syncTitle:a(s)},function(){if("horizontal"===z[s].direction)return z[s].sizeWidth=!0,z[s].sizeHeight=!1,void u(s,'Direction set to "horizontal"');if("none"===z[s].direction)return z[s].sizeWidth=!1,z[s].sizeHeight=!1,z[s].autoResize=!1,void u(s,'Direction set to "none"');if("vertical"!==z[s].direction)throw new TypeError(s,`Direction value of "${z[s].direction}" is not valid`);u(s,'Direction set to "vertical"')}(),(i=e?.offsetSize||e?.offset)&&("vertical"===z[s].direction?(z[s].offsetHeight=i,u(s,`Offset height set to ${i}`)):(z[s].offsetWidth=i,u(s,`Offset width set to ${i}`))),e?.offset&&p(s,"<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>."),null===z[s].postMessageTarget&&(z[s].postMessageTarget=t.contentWindow),z[s].targetOrigin=!0===z[s].checkOrigin?""===(n=z[s].remoteHost)||null!==n.match(/^(about:blank|javascript:|file:\/\/)/)?"*":n:"*"}(i),function(){const{mode:i}=z[s];i<0&&p("Parent",`${b(i+2)}${b(2)}`),E||i<0||(E=!0,((e,...i)=>{d("info",e,...i)})(`v${e} (${(e=>h(y[e]))(i)})`),i<1&&p("Parent",b(3)))}(),H(),function(){switch(u(s,`IFrame scrolling ${z[s]?.scrolling?"enabled":"disabled"} for ${s}`),t.style.overflow=!1===z[s]?.scrolling?"hidden":"auto",z[s]?.scrolling){case"omit":break;case!0:t.scrolling="yes";break;case!1:t.scrolling="no";break;default:t.scrolling=z[s]?z[s].scrolling:"no"}}(),function(){const{bodyMargin:e}=z[s];"number"!=typeof e&&"0"!==e||(z[s].bodyMargin=`${e}px`)}(),function(e){const{id:i}=t;-1!==z[i].mode&&-2!==z[i].mode&&(o(t,"load",(function(){C("iFrame.onload",`${e}:${N}`,i,!0),function(){const e=z[s]?.firstRun,i=z[s]?.heightCalculationMethod in n;!e&&i&&F({iframe:t,height:0,width:0,type:"init"})}()})),!1===z[i].waitForLoad&&C("init",`${e}:${N}`,i,!0))}(O(s)),function(){if(z[s]){const e={close:R.bind(null,z[s].iframe),disconnect:I.bind(null,z[s].iframe),removeListeners(){p(s,"\n<rb>Deprecated Method Name</>\n\nThe emoveListeners()</> method has been renamed to isconnect()</>.\n"),this.disconnect()},resize:C.bind(null,"Window resize","resize",s),moveToAnchor(e){C("Move to anchor",`moveToAnchor:${e}`,s)},sendMessage(e){C("Send Message",`message:${e=JSON.stringify(e)}`,s)}};z[s].iframe.iframeResizer=e,z[s].iframe.iFrameResizer=e}}()),t?.iFrameResizer};function D(){!1===document.hidden&&(u("document","Trigger event: Visibility change"),function(e,i){const t=e=>z[e]?.autoResize&&!z[e]?.firstRun;Object.keys(z).forEach((function(n){t(n)&&C(e,i,n)}))}("Tab Visible","resize"))}const H=(e=>{let i=!1;return function(){return i?void 0:(i=!0,Reflect.apply(e,this,arguments))}})((()=>{o(window,"message",k),o(document,"visibilitychange",D),window.iframeParentListener=e=>k({data:e,sameDomain:!0})}));switch(!0){case void 0===window.jQuery:f("","Unable to bind to jQuery, it is not available.");break;case!window.jQuery.fn:f("","Unable to bind to jQuery, it is not fully loaded.");break;case window.jQuery.fn.iframeResize:f("","iframeResize is already assigned to jQuery.fn.");break;default:window.jQuery.fn.iframeResize=function(e){const i=A(e);return this.filter("iframe").each(i).end()},window.jQuery.fn.iFrameResize=function(e){return f("","Deprecated: Use the iframeResize method instead of iFrameResize"),this.iframeResize(e)}}}));
21
- //# sourceMappingURL=index.umd.js.map
20
+ (function (factory) {
21
+ typeof define === 'function' && define.amd ? define(factory) :
22
+ factory();
23
+ })((function () { 'use strict';
24
+
25
+ const VERSION = '5.2.2-beta.3';
26
+
27
+ const msgHeader = 'message';
28
+ const msgHeaderLen = msgHeader.length;
29
+ const msgId$1 = '[iFrameSizer]'; // Must match iframe msg ID
30
+ const msgIdLen = msgId$1.length;
31
+ const resetRequiredMethods = Object.freeze({
32
+ max: 1,
33
+ scroll: 1,
34
+ bodyScroll: 1,
35
+ documentElementScroll: 1,
36
+ });
37
+
38
+ const addEventListener = (el, evt, func, options) =>
39
+ el.addEventListener(evt, func, options || false);
40
+
41
+ const removeEventListener = (el, evt, func) =>
42
+ el.removeEventListener(evt, func, false);
43
+
44
+ const encode = (s) =>
45
+ s
46
+ .replaceAll('<br>', '\n')
47
+ .replaceAll('<rb>', '\u001B[31;1m')
48
+ .replaceAll('</>', '\u001B[m')
49
+ .replaceAll('<b>', '\u001B[1m')
50
+ .replaceAll('<i>', '\u001B[3m')
51
+ .replaceAll('<u>', '\u001B[4m');
52
+
53
+ const remove = (s) => s.replaceAll('<br>', '\n').replaceAll(/<[/a-z]+>/gi, '');
54
+
55
+ const formatAdvise = (formatLogMsg) => (msg) =>
56
+ window.chrome // Only show formatting in Chrome as not supported in other browsers
57
+ ? formatLogMsg(encode(msg))
58
+ : formatLogMsg(remove(msg));
59
+
60
+ const msgId = '[iframe-resizer]';
61
+
62
+ let settings$1 = {};
63
+ let logEnabled = false;
64
+
65
+ function setLogEnabled(enabled) {
66
+ logEnabled = enabled;
67
+ }
68
+
69
+ function setLogSettings(newSettings) {
70
+ settings$1 = newSettings;
71
+ }
72
+
73
+ const isLogEnabled = (iframeId) =>
74
+ settings$1[iframeId] ? settings$1[iframeId].log : logEnabled;
75
+
76
+ function getMyID(iframeId) {
77
+ if (window.top === window.self) {
78
+ return `Parent page: ${iframeId}`
79
+ }
80
+
81
+ return window?.parentIFrame?.getId
82
+ ? `${window.parentIFrame.getId()}: ${iframeId}`
83
+ : `Nested parent page: ${iframeId}`
84
+ }
85
+
86
+ const formatLogHeader = (iframeId) => `${msgId}[${getMyID(iframeId)}]`;
87
+
88
+ const formatLogMsg =
89
+ (iframeId) =>
90
+ (...msg) =>
91
+ [`${msgId}[${iframeId}]`, ...msg].join(' ');
92
+
93
+ const output = (type, iframeId, ...msg) =>
94
+ // eslint-disable-next-line no-console
95
+ window?.console[type](formatLogHeader(iframeId), ...msg);
96
+
97
+ const log = (iframeId, ...msg) =>
98
+ isLogEnabled(iframeId) === true ? output('log', iframeId, ...msg) : null;
99
+
100
+ const info = (iframeId, ...msg) => output('info', iframeId, ...msg);
101
+
102
+ const warn = (iframeId, ...msg) => output('warn', iframeId, ...msg);
103
+
104
+ const advise = (iframeId, msg) =>
105
+ // eslint-disable-next-line no-console
106
+ console?.warn(formatAdvise(formatLogMsg(iframeId))(msg));
107
+
108
+ const l = (l) => {
109
+ if (!l) return ''
110
+ let p = -559038744,
111
+ y = 1103547984;
112
+ for (let z, t = 0; t < l.length; t++)
113
+ (z = l.codePointAt(t)),
114
+ (p = Math.imul(p ^ z, 2246822519)),
115
+ (y = Math.imul(y ^ z, 3266489917));
116
+ return (
117
+ (p ^= Math.imul(p ^ (y >>> 15), 1935289751)),
118
+ (y ^= Math.imul(y ^ (p >>> 15), 3405138345)),
119
+ (p ^= y >>> 16),
120
+ (y ^= p >>> 16),
121
+ (2097152 * (y >>> 0) + (p >>> 11)).toString(36)
122
+ )
123
+ },
124
+ p = (l) =>
125
+ l.replaceAll(/[A-Za-z]/g, (l) =>
126
+ String.fromCodePoint(
127
+ (l <= 'Z' ? 90 : 122) >= (l = l.codePointAt(0) + 19) ? l : l - 26,
128
+ ),
129
+ ),
130
+ y = [
131
+ '<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>',
132
+ '<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>',
133
+ 'Aopz spiyhyf pz hchpshisl dpao ivao Jvttlyjphs huk Vwlu-Zvbyjl spjluzlz.<iy><iy><i>Jvttlyjphs Spjluzl</><iy>Mvy jvttlyjphs bzl, <p>pmyhtl-ylzpgly</> ylxbpylz h svd jvza vul aptl spjluzl mll. Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.<iy><iy><i>Vwlu Zvbyjl Spjluzl</><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-jvttlyjphs vwlu zvbyjl wyvqlja aolu fvb jhu bzl pa mvy myll bukly aol alytz vm aol NWS C3 Spjluzl. Av jvumpyt fvb hjjlwa aolzl alytz, wslhzl zla aol <i>spjluzl</> rlf pu <p>pmyhtl-ylzpgly</> vwapvuz av <i>NWSc3</>.<iy><iy>Mvy tvyl pumvythapvu wslhzl zll: <b>oaawz://pmyhtl-ylzpgly.jvt/nws</>',
134
+ '<i>NWSc3 Spjluzl Clyzpvu</><iy><iy>Aopz clyzpvu vm <p>pmyhtl-ylzpgly</> pz ilpun bzlk bukly aol alytz vm aol <i>NWS C3</> spjluzl. Aopz spjluzl hssvdz fvb av bzl <p>pmyhtl-ylzpgly</> pu Vwlu Zvbyjl wyvqljaz, iba pa ylxbpylz fvby wyvqlja av il wbispj, wyvcpkl haaypibapvu huk il spjluzlk bukly clyzpvu 3 vy shaly vm aol NUB Nlulyhs Wbispj Spjluzl.<iy><iy>Pm fvb hyl bzpun aopz spiyhyf pu h uvu-vwlu zvbyjl wyvqlja vy dlizpal, fvb dpss ullk av wbyjohzl h svd jvza vul aptl jvttlyjphs spjluzl.<iy><iy>Mvy tvyl pumvythapvu cpzpa <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</>.',
135
+ ],
136
+ z = ['NWSc3', 'zvsv', 'wyv', 'ibzpulzz', 'vlt'],
137
+ t = Object.fromEntries(
138
+ [
139
+ '2cgs7fdf4xb',
140
+ '1c9ctcccr4z',
141
+ '1q2pc4eebgb',
142
+ 'ueokt0969w',
143
+ 'w2zxchhgqz',
144
+ '1umuxblj2e5',
145
+ ].map((l, p) => [l, Math.max(0, p - 1)]),
146
+ );
147
+ const getModeData = (l) => p(y[l]);
148
+ const getModeLabel = (l) => p(z[l]);
149
+ const setMode = (y) => {
150
+ const z = y[p('spjluzl')];
151
+ if (!z) return -1
152
+ const u = z.split('-');
153
+ let v = (function (y = '') {
154
+ let z = -2;
155
+ const u = l(p(y));
156
+ return u in t && (z = t[u]), z
157
+ })(u[0]);
158
+ return 0 === v || ((p) => p[2] === l(p[0] + p[1]))(u) || (v = -2), v
159
+ };
160
+
161
+ const once = (fn) => {
162
+ let done = false;
163
+
164
+ return function () {
165
+ return done
166
+ ? undefined
167
+ : ((done = true), Reflect.apply(fn, this, arguments))
168
+ }
169
+ };
170
+
171
+ const settings = {};
172
+
173
+ const onReadyDeprecated = (messageData) => {
174
+ if (typeof settings[messageData.id].onInit === 'function') {
175
+ advise(
176
+ messageData.id,
177
+ `
178
+ \u001B[31;1mDeprecated Option\u001B[m
179
+
180
+ The \u001B[1monInit()\u001B[m function is deprecated and has been replaced with \u001B[1monReady()\u001B[m. It will be removed in a future version of iFrame Resizer.
181
+ `,
182
+ );
183
+ settings[messageData.id].onInit(messageData);
184
+ }
185
+ };
186
+
187
+ const defaults = Object.freeze({
188
+ autoResize: true,
189
+ bodyBackground: null,
190
+ bodyMargin: null,
191
+ bodyPadding: null,
192
+ checkOrigin: true,
193
+ direction: 'vertical',
194
+ inPageLinks: false,
195
+ heightCalculationMethod: 'auto',
196
+ id: 'iFrameResizer',
197
+ log: false,
198
+ license: undefined,
199
+ mouseEvents: true,
200
+ offsetHeight: null,
201
+ offsetWidth: null,
202
+ postMessageTarget: null,
203
+ sameDomain: false,
204
+ scrolling: false,
205
+ sizeHeight: true,
206
+ // sizeSelector: '',
207
+ sizeWidth: false,
208
+ warningTimeout: 5000,
209
+ tolerance: 0,
210
+ waitForLoad: false,
211
+ widthCalculationMethod: 'auto',
212
+ onClose: () => true,
213
+ onClosed() {},
214
+ onInit: false,
215
+ onMessage: null,
216
+ onMouseEnter() {},
217
+ onMouseLeave() {},
218
+ onReady: onReadyDeprecated,
219
+ onResized() {},
220
+ onScroll: () => true,
221
+ });
222
+
223
+ const page = {
224
+ position: null,
225
+ version: VERSION,
226
+ };
227
+
228
+ setLogSettings(settings);
229
+
230
+ function iframeListener(event) {
231
+ function resizeIFrame() {
232
+ setSize(messageData);
233
+ setPagePosition(iframeId);
234
+
235
+ on('onResized', messageData);
236
+ }
237
+
238
+ function getPaddingEnds(compStyle) {
239
+ if (compStyle.boxSizing !== 'border-box') {
240
+ return 0
241
+ }
242
+
243
+ const top = compStyle.paddingTop ? parseInt(compStyle.paddingTop, 10) : 0;
244
+ const bot = compStyle.paddingBottom
245
+ ? parseInt(compStyle.paddingBottom, 10)
246
+ : 0;
247
+
248
+ return top + bot
249
+ }
250
+
251
+ function getBorderEnds(compStyle) {
252
+ if (compStyle.boxSizing !== 'border-box') {
253
+ return 0
254
+ }
255
+
256
+ const top = compStyle.borderTopWidth
257
+ ? parseInt(compStyle.borderTopWidth, 10)
258
+ : 0;
259
+ const bot = compStyle.borderBottomWidth
260
+ ? parseInt(compStyle.borderBottomWidth, 10)
261
+ : 0;
262
+
263
+ return top + bot
264
+ }
265
+
266
+ function processMsg() {
267
+ const data = msg.slice(msgIdLen).split(':');
268
+ const height = data[1] ? Number(data[1]) : 0;
269
+ const iframe = settings[data[0]]?.iframe;
270
+ const compStyle = getComputedStyle(iframe);
271
+
272
+ return {
273
+ iframe,
274
+ id: data[0],
275
+ height: height + getPaddingEnds(compStyle) + getBorderEnds(compStyle),
276
+ width: Number(data[2]),
277
+ type: data[3],
278
+ msg: data[4],
279
+ }
280
+ }
281
+
282
+ function isMessageFromIFrame() {
283
+ function checkAllowedOrigin() {
284
+ function checkList() {
285
+ let i = 0;
286
+ let retCode = false;
287
+
288
+ log(
289
+ iframeId,
290
+ `Checking connection is from allowed list of origins: ${checkOrigin}`,
291
+ );
292
+
293
+ for (; i < checkOrigin.length; i++) {
294
+ if (checkOrigin[i] === origin) {
295
+ retCode = true;
296
+ break
297
+ }
298
+ }
299
+
300
+ return retCode
301
+ }
302
+
303
+ function checkSingle() {
304
+ const remoteHost = settings[iframeId]?.remoteHost;
305
+ log(iframeId, `Checking connection is from: ${remoteHost}`);
306
+ return origin === remoteHost
307
+ }
308
+
309
+ return checkOrigin.constructor === Array ? checkList() : checkSingle()
310
+ }
311
+
312
+ const { origin, sameDomain } = event;
313
+
314
+ if (sameDomain) {
315
+ return true
316
+ }
317
+
318
+ let checkOrigin = settings[iframeId]?.checkOrigin;
319
+
320
+ if (checkOrigin && `${origin}` !== 'null' && !checkAllowedOrigin()) {
321
+ throw new Error(
322
+ `Unexpected message received from: ${origin} for ${messageData.iframe.id}. Message was: ${event.data}. This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.`,
323
+ )
324
+ }
325
+
326
+ return true
327
+ }
328
+
329
+ function isMessageForUs() {
330
+ return (
331
+ msgId$1 === `${msg}`.slice(0, msgIdLen) &&
332
+ msg.slice(msgIdLen).split(':')[0] in settings
333
+ ) // ''+Protects against non-string msg
334
+ }
335
+
336
+ function isMessageFromMetaParent() {
337
+ // Test if this message is from a parent above us. This is an ugly test, however, updating
338
+ // the message format would break backwards compatibility.
339
+ const retCode = messageData.type in { true: 1, false: 1, undefined: 1 };
340
+
341
+ if (retCode) {
342
+ log(iframeId, 'Ignoring init message from meta parent page');
343
+ }
344
+
345
+ return retCode
346
+ }
347
+
348
+ function getMsgBody(offset) {
349
+ return msg.slice(msg.indexOf(':') + msgHeaderLen + offset)
350
+ }
351
+
352
+ function forwardMsgFromIFrame(msgBody) {
353
+ log(
354
+ iframeId,
355
+ `onMessage passed: {iframe: ${messageData.iframe.id}, message: ${msgBody}}`,
356
+ );
357
+
358
+ on('onMessage', {
359
+ iframe: messageData.iframe,
360
+ message: JSON.parse(msgBody),
361
+ });
362
+
363
+ log(iframeId, '--');
364
+ }
365
+
366
+ function getPageInfo() {
367
+ const bodyPosition = document.body.getBoundingClientRect();
368
+ const iFramePosition = messageData.iframe.getBoundingClientRect();
369
+ const { scrollY, scrollX, innerHeight, innerWidth } = window;
370
+ const { clientHeight, clientWidth } = document.documentElement;
371
+
372
+ return JSON.stringify({
373
+ iframeHeight: iFramePosition.height,
374
+ iframeWidth: iFramePosition.width,
375
+ clientHeight: Math.max(clientHeight, innerHeight || 0),
376
+ clientWidth: Math.max(clientWidth, innerWidth || 0),
377
+ offsetTop: parseInt(iFramePosition.top - bodyPosition.top, 10),
378
+ offsetLeft: parseInt(iFramePosition.left - bodyPosition.left, 10),
379
+ scrollTop: scrollY,
380
+ scrollLeft: scrollX,
381
+ documentHeight: clientHeight,
382
+ documentWidth: clientWidth,
383
+ windowHeight: innerHeight,
384
+ windowWidth: innerWidth,
385
+ })
386
+ }
387
+
388
+ function getParentProps() {
389
+ const { iframe } = messageData;
390
+ const { scrollWidth, scrollHeight } = document.documentElement;
391
+ const { width, height, offsetLeft, offsetTop, pageLeft, pageTop, scale } =
392
+ window.visualViewport;
393
+
394
+ return JSON.stringify({
395
+ iframe: iframe.getBoundingClientRect(),
396
+ document: {
397
+ scrollWidth,
398
+ scrollHeight,
399
+ },
400
+ viewport: {
401
+ width,
402
+ height,
403
+ offsetLeft,
404
+ offsetTop,
405
+ pageLeft,
406
+ pageTop,
407
+ scale,
408
+ },
409
+ })
410
+ }
411
+
412
+ const sendInfoToIframe = (type, infoFunction) => (requestType, iframeId) => {
413
+ const gate = {};
414
+
415
+ function throttle(func, frameId) {
416
+ if (!gate[frameId]) {
417
+ func();
418
+ gate[frameId] = requestAnimationFrame(() => {
419
+ gate[frameId] = null;
420
+ });
421
+ }
422
+ }
423
+
424
+ function gatedTrigger() {
425
+ trigger(
426
+ `Send ${type} (${requestType})`,
427
+ `${type}:${infoFunction()}`,
428
+ iframeId,
429
+ );
430
+ }
431
+
432
+ throttle(gatedTrigger, iframeId);
433
+ };
434
+
435
+ const startInfoMonitor = (sendInfoToIframe, type) => () => {
436
+ const sendInfo = (requestType) => () => {
437
+ if (settings[id]) {
438
+ sendInfoToIframe(requestType, id);
439
+ } else {
440
+ stop();
441
+ }
442
+ };
443
+
444
+ function setListener(requestType, listener) {
445
+ log(id, `${requestType} listeners for send${type}`);
446
+ listener(window, 'scroll', sendInfo('scroll'));
447
+ listener(window, 'resize', sendInfo('resize window'));
448
+ }
449
+
450
+ function stop() {
451
+ setListener('Remove ', removeEventListener);
452
+ pageObserver.disconnect();
453
+ iframeObserver.disconnect();
454
+ }
455
+
456
+ function start() {
457
+ setListener('Add ', addEventListener);
458
+ pageObserver.observe(document.body, {
459
+ attributes: true,
460
+ childList: true,
461
+ subtree: true,
462
+ });
463
+ iframeObserver.observe(settings[id].iframe, {
464
+ attributes: true,
465
+ childList: false,
466
+ subtree: false,
467
+ });
468
+ }
469
+
470
+ const id = iframeId; // Create locally scoped copy of iFrame ID
471
+
472
+ const pageObserver = new ResizeObserver(sendInfo('page observed'));
473
+ const iframeObserver = new ResizeObserver(sendInfo('iframe observed'));
474
+
475
+ start();
476
+
477
+ if (settings[id]) {
478
+ settings[id][`stop${type}`] = stop;
479
+ }
480
+ };
481
+
482
+ const stopInfoMonitor = (stopFunction) => () => {
483
+ if (stopFunction in settings[iframeId]) {
484
+ settings[iframeId][stopFunction]();
485
+ delete settings[iframeId][stopFunction];
486
+ }
487
+ };
488
+
489
+ const sendPageInfoToIframe = sendInfoToIframe('pageInfo', getPageInfo);
490
+ const sendParentInfoToIframe = sendInfoToIframe('parentInfo', getParentProps);
491
+
492
+ const startPageInfoMonitor = startInfoMonitor(
493
+ sendPageInfoToIframe,
494
+ 'PageInfo',
495
+ );
496
+ const startParentInfoMonitor = startInfoMonitor(
497
+ sendParentInfoToIframe,
498
+ 'ParentInfo',
499
+ );
500
+
501
+ const stopPageInfoMonitor = stopInfoMonitor('stopPageInfo');
502
+ const stopParentInfoMonitor = stopInfoMonitor('stopParentInfo');
503
+
504
+ function checkIFrameExists() {
505
+ let retBool = true;
506
+
507
+ if (messageData.iframe === null) {
508
+ warn(iframeId, `The iframe (${messageData.id}) was not found.`);
509
+ retBool = false;
510
+ }
511
+
512
+ return retBool
513
+ }
514
+
515
+ function getElementPosition(target) {
516
+ const iFramePosition = target.getBoundingClientRect();
517
+
518
+ getPagePosition(iframeId);
519
+
520
+ return {
521
+ x: Number(iFramePosition.left) + Number(page.position.x),
522
+ y: Number(iFramePosition.top) + Number(page.position.y),
523
+ }
524
+ }
525
+
526
+ function scrollBy() {
527
+ const x = messageData.width;
528
+ const y = messageData.height;
529
+
530
+ const target = window.parentIframe || window;
531
+
532
+ log(iframeId, `Scroll request received by parent: x: ${x} y: ${y}`);
533
+
534
+ target.scrollBy(x, y);
535
+ }
536
+
537
+ function scrollRequestFromChild(addOffset) {
538
+ /* istanbul ignore next */ // Not testable in Karma
539
+ function reposition() {
540
+ page.position = newPosition;
541
+ scrollTo(iframeId);
542
+ log(iframeId, '--');
543
+ }
544
+
545
+ function scrollParent() {
546
+ if (window.parentIFrame) {
547
+ window.parentIFrame[`scrollTo${addOffset ? 'Offset' : ''}`](
548
+ newPosition.x,
549
+ newPosition.y,
550
+ );
551
+ } else {
552
+ warn(
553
+ iframeId,
554
+ 'Unable to scroll to requested position, window.parentIFrame not found',
555
+ );
556
+ }
557
+ }
558
+
559
+ const calcOffset = (messageData, offset) => ({
560
+ x: messageData.width + offset.x,
561
+ y: messageData.height + offset.y,
562
+ });
563
+
564
+ const offset = addOffset
565
+ ? getElementPosition(messageData.iframe)
566
+ : { x: 0, y: 0 };
567
+
568
+ let newPosition = calcOffset(messageData, offset);
569
+
570
+ log(
571
+ iframeId,
572
+ `Reposition requested from iFrame (offset x:${offset.x} y:${offset.y})`,
573
+ );
574
+
575
+ if (window.top === window.self) {
576
+ reposition();
577
+ } else {
578
+ scrollParent();
579
+ }
580
+ }
581
+
582
+ function scrollTo(iframeId) {
583
+ const { x, y } = page.position;
584
+ const iframe = settings[iframeId]?.iframe;
585
+ if (on('onScroll', { iframe, top: y, left: x, x, y }) === false) {
586
+ unsetPagePosition();
587
+ return
588
+ }
589
+ setPagePosition(iframeId);
590
+ }
591
+
592
+ function findTarget(location) {
593
+ function jumpToTarget() {
594
+ const jumpPosition = getElementPosition(target);
595
+
596
+ log(
597
+ iframeId,
598
+ `Moving to in page link (#${hash}) at x: ${jumpPosition.x} y: ${jumpPosition.y}`,
599
+ );
600
+
601
+ page.position = {
602
+ x: jumpPosition.x,
603
+ y: jumpPosition.y,
604
+ };
605
+
606
+ scrollTo(iframeId);
607
+ window.location.hash = hash;
608
+
609
+ log(iframeId, '--');
610
+ }
611
+
612
+ function jumpToParent() {
613
+ if (window.parentIFrame) {
614
+ window.parentIFrame.moveToAnchor(hash);
615
+ return
616
+ }
617
+
618
+ log(
619
+ iframeId,
620
+ `In page link #${hash} not found and window.parentIFrame not found`,
621
+ );
622
+ }
623
+
624
+ const hash = location.split('#')[1] || '';
625
+ const hashData = decodeURIComponent(hash);
626
+
627
+ let target =
628
+ document.getElementById(hashData) ||
629
+ document.getElementsByName(hashData)[0];
630
+
631
+ if (target) {
632
+ jumpToTarget();
633
+ return
634
+ }
635
+
636
+ if (window.top === window.self) {
637
+ log(iframeId, `In page link #${hash} not found`);
638
+ return
639
+ }
640
+
641
+ jumpToParent();
642
+ }
643
+
644
+ function onMouse(event) {
645
+ let mousePos = {};
646
+
647
+ if (messageData.width === 0 && messageData.height === 0) {
648
+ const data = getMsgBody(9).split(':');
649
+ mousePos = {
650
+ x: data[1],
651
+ y: data[0],
652
+ };
653
+ } else {
654
+ mousePos = {
655
+ x: messageData.width,
656
+ y: messageData.height,
657
+ };
658
+ }
659
+
660
+ on(event, {
661
+ iframe: messageData.iframe,
662
+ screenX: Number(mousePos.x),
663
+ screenY: Number(mousePos.y),
664
+ type: messageData.type,
665
+ });
666
+ }
667
+
668
+ const on = (funcName, val) => chkEvent(iframeId, funcName, val);
669
+
670
+ function checkSameDomain(id) {
671
+ try {
672
+ settings[id].sameDomain =
673
+ !!settings[id]?.iframe?.contentWindow?.iframeChildListener;
674
+ } catch (error) {
675
+ settings[id].sameDomain = false;
676
+ }
677
+
678
+ log(id, `sameDomain: ${settings[id].sameDomain}`);
679
+ }
680
+
681
+ function checkVersion(version) {
682
+ if (version === VERSION) return
683
+ if (version === undefined) {
684
+ advise(
685
+ iframeId,
686
+ `<rb>Legacy version detected in iframe</>
687
+
688
+ Detected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.
689
+
690
+ See <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.
691
+ `,
692
+ );
693
+ return
694
+ }
695
+ log(iframeId, `Version mismatch (Child: ${version} !== Parent: ${VERSION})`);
696
+ }
697
+
698
+ function setTitle(title, iframeId) {
699
+ if (!settings[iframeId]?.syncTitle) return
700
+ settings[iframeId].iframe.title = title;
701
+ log(iframeId, `Set title attribute to: ${title}`);
702
+ }
703
+
704
+ function started() {
705
+ setup = true;
706
+ }
707
+
708
+ function actionMsg() {
709
+ if (settings[iframeId]?.firstRun) firstRun();
710
+
711
+ switch (messageData.type) {
712
+ case 'close':
713
+ closeIFrame(messageData.iframe);
714
+ break
715
+
716
+ case 'message':
717
+ forwardMsgFromIFrame(getMsgBody(6));
718
+ break
719
+
720
+ case 'mouseenter':
721
+ onMouse('onMouseEnter');
722
+ break
723
+
724
+ case 'mouseleave':
725
+ onMouse('onMouseLeave');
726
+ break
727
+
728
+ case 'autoResize':
729
+ settings[iframeId].autoResize = JSON.parse(getMsgBody(9));
730
+ break
731
+
732
+ case 'scrollBy':
733
+ scrollBy();
734
+ break
735
+
736
+ case 'scrollTo':
737
+ scrollRequestFromChild(false);
738
+ break
739
+
740
+ case 'scrollToOffset':
741
+ scrollRequestFromChild(true);
742
+ break
743
+
744
+ case 'pageInfo':
745
+ sendPageInfoToIframe('start', iframeId);
746
+ startPageInfoMonitor();
747
+ break
748
+
749
+ case 'parentInfo':
750
+ sendParentInfoToIframe('start', iframeId);
751
+ startParentInfoMonitor();
752
+ break
753
+
754
+ case 'pageInfoStop':
755
+ stopPageInfoMonitor();
756
+ break
757
+
758
+ case 'parentInfoStop':
759
+ stopParentInfoMonitor();
760
+ break
761
+
762
+ case 'inPageLink':
763
+ findTarget(getMsgBody(9));
764
+ break
765
+
766
+ case 'title':
767
+ setTitle(messageData.msg, iframeId);
768
+ break
769
+
770
+ case 'reset':
771
+ resetIFrame(messageData);
772
+ break
773
+
774
+ case 'init':
775
+ resizeIFrame();
776
+ checkSameDomain(iframeId);
777
+ checkVersion(messageData.msg);
778
+ started();
779
+ on('onReady', messageData.iframe);
780
+ break
781
+
782
+ default:
783
+ if (messageData.width === 0 && messageData.height === 0) {
784
+ warn(
785
+ `Unsupported message received (${messageData.type}), this is likely due to the iframe containing a later ` +
786
+ `version of iframe-resizer than the parent page`,
787
+ );
788
+ return
789
+ }
790
+
791
+ if (messageData.width === 0 || messageData.height === 0) {
792
+ log(iframeId, 'Ignoring message with 0 height or width');
793
+ return
794
+ }
795
+
796
+ // Recheck document.hidden here, as only Firefox
797
+ // correctly supports this in the iframe
798
+ if (document.hidden) {
799
+ log(iframeId, 'Page hidden - ignored resize request');
800
+ return
801
+ }
802
+
803
+ resizeIFrame();
804
+ }
805
+ }
806
+
807
+ function checkSettings(iframeId) {
808
+ if (!settings[iframeId]) {
809
+ throw new Error(
810
+ `${messageData.type} No settings for ${iframeId}. Message was: ${msg}`,
811
+ )
812
+ }
813
+ }
814
+
815
+ function iFrameReadyMsgReceived() {
816
+ Object.keys(settings).forEach((iframeId) => {
817
+ if (settings[iframeId].mode >= 0)
818
+ trigger('iFrame requested init', createOutgoingMsg(iframeId), iframeId);
819
+ });
820
+ }
821
+
822
+ function firstRun() {
823
+ if (settings[iframeId]) {
824
+ settings[iframeId].firstRun = false;
825
+ }
826
+ }
827
+
828
+ let msg = event.data;
829
+ let messageData = {};
830
+ let iframeId = null;
831
+
832
+ if (msg === '[iFrameResizerChild]Ready') {
833
+ iFrameReadyMsgReceived();
834
+ return
835
+ }
836
+
837
+ if (!isMessageForUs()) {
838
+ if (iframeId !== null) log(iframeId, 'Ignored:', msg);
839
+ return
840
+ }
841
+
842
+ messageData = processMsg();
843
+ iframeId = messageData.id;
844
+
845
+ if (!iframeId) {
846
+ warn('iframeResizer received messageData without id, message was: ', msg);
847
+ return
848
+ }
849
+
850
+ checkSettings(iframeId);
851
+
852
+ if (!isMessageFromMetaParent()) {
853
+ log(iframeId, `Received: ${msg}`);
854
+ settings[iframeId].loaded = true;
855
+
856
+ if (checkIFrameExists() && isMessageFromIFrame()) {
857
+ actionMsg();
858
+ }
859
+ }
860
+ }
861
+
862
+ function chkEvent(iframeId, funcName, val) {
863
+ let func = null;
864
+ let retVal = null;
865
+
866
+ if (settings[iframeId]) {
867
+ func = settings[iframeId][funcName];
868
+
869
+ if (typeof func === 'function') {
870
+ retVal = func(val);
871
+ } else {
872
+ throw new TypeError(
873
+ `${funcName} on iFrame[${iframeId}] is not a function`,
874
+ )
875
+ }
876
+ }
877
+
878
+ return retVal
879
+ }
880
+
881
+ function removeIframeListeners(iframe) {
882
+ const iframeId = iframe.id;
883
+ delete settings[iframeId];
884
+ }
885
+
886
+ function closeIFrame(iframe) {
887
+ const iframeId = iframe.id;
888
+ if (chkEvent(iframeId, 'onClose', iframeId) === false) {
889
+ log(iframeId, 'Close iframe cancelled by onClose event');
890
+ return
891
+ }
892
+ log(iframeId, `Removing iFrame: ${iframeId}`);
893
+
894
+ try {
895
+ // Catch race condition error with React
896
+ if (iframe.parentNode) {
897
+ iframe.remove();
898
+ }
899
+ } catch (error) {
900
+ warn(error);
901
+ }
902
+
903
+ chkEvent(iframeId, 'onClosed', iframeId);
904
+ log(iframeId, '--');
905
+ removeIframeListeners(iframe);
906
+ }
907
+
908
+ function getPagePosition(iframeId) {
909
+ if (page.position === null) {
910
+ page.position = {
911
+ x: window.scrollX,
912
+ y: window.scrollY,
913
+ };
914
+ log(iframeId, `Get page position: ${page.position.x}, ${page.position.y}`);
915
+ }
916
+ }
917
+
918
+ function unsetPagePosition() {
919
+ page.position = null;
920
+ }
921
+
922
+ function setPagePosition(iframeId) {
923
+ if (page.position !== null) {
924
+ window.scrollTo(page.position.x, page.position.y);
925
+ log(iframeId, `Set page position: ${page.position.x}, ${page.position.y}`);
926
+ unsetPagePosition();
927
+ }
928
+ }
929
+
930
+ function resetIFrame(messageData) {
931
+ log(
932
+ messageData.id,
933
+ `Size reset requested by ${messageData.type === 'init' ? 'parent page' : 'child page'}`,
934
+ );
935
+
936
+ getPagePosition(messageData.id);
937
+ setSize(messageData);
938
+ trigger('reset', 'reset', messageData.id);
939
+ }
940
+
941
+ function setSize(messageData) {
942
+ const iframeId = messageData.id;
943
+
944
+ function setDimension(dimension) {
945
+ const size = `${messageData[dimension]}px`;
946
+ messageData.iframe.style[dimension] = size;
947
+ log(iframeId, `IFrame (${iframeId}) ${dimension} set to ${size}`);
948
+ }
949
+
950
+ if (settings[iframeId].sizeHeight) {
951
+ setDimension('height');
952
+ }
953
+ if (settings[iframeId].sizeWidth) {
954
+ setDimension('width');
955
+ }
956
+ }
957
+
958
+ function trigger(calleeMsg, msg, id, noResponseWarning) {
959
+ function postMessageToIFrame() {
960
+ const { postMessageTarget, targetOrigin } = settings[id];
961
+
962
+ if (settings[id].sameDomain) {
963
+ try {
964
+ settings[id].iframe.contentWindow.iframeChildListener(msgId$1 + msg);
965
+ log(
966
+ id,
967
+ `[${calleeMsg}] Sending message to iframe[${id}] (${msg}) via sameDomain`,
968
+ );
969
+ return
970
+ } catch (error) {
971
+ log(id, `Same domain connection failed. Trying cross domain`);
972
+ }
973
+ }
974
+
975
+ log(
976
+ id,
977
+ `[${calleeMsg}] Sending message to iframe[${id}] (${msg}) targetOrigin: ${targetOrigin}`,
978
+ );
979
+ postMessageTarget.postMessage(msgId$1 + msg, targetOrigin);
980
+ }
981
+
982
+ function iFrameNotFound() {
983
+ warn(id, `[${calleeMsg}] IFrame(${id}) not found`);
984
+ }
985
+
986
+ function chkAndSend() {
987
+ if (!settings[id]?.postMessageTarget) {
988
+ iFrameNotFound();
989
+ return
990
+ }
991
+ postMessageToIFrame();
992
+ }
993
+
994
+ function warnOnNoResponse() {
995
+ function warning() {
996
+ if (settings[id] === undefined) return // iframe has been closed while we where waiting
997
+ const { waitForLoad } = settings[id];
998
+
999
+ if (!settings[id].loaded && !settings[id].loadErrorShown) {
1000
+ settings[id].loadErrorShown = true;
1001
+ advise(
1002
+ id,
1003
+ `
1004
+ <rb>No response from iFrame</>
1005
+
1006
+ The iframe (<i>${id}</>) has not responded within ${settings[id].warningTimeout / 1000} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.
1007
+ ${
1008
+ waitForLoad
1009
+ ? `
1010
+ The <b>waitForLoad</> option is currently set to <b>true</>. If the iframe loads before the JavaScript runs, this option will prevent <i>iframe-resizer</> from initialising. To disable this, set the <b>waitForLoad</> option to <b>false</>.
1011
+ `
1012
+ : ''
1013
+ }
1014
+ This message can be ignored if everything is working, or you can set the <b>warningTimeout</> option to a higher value or zero to suppress this warning.
1015
+ `,
1016
+ );
1017
+ }
1018
+ }
1019
+
1020
+ if (!!noResponseWarning && !!settings[id]?.warningTimeout) {
1021
+ settings[id].msgTimeout = setTimeout(warning, settings[id].warningTimeout);
1022
+ }
1023
+ }
1024
+
1025
+ if (settings[id]) {
1026
+ chkAndSend();
1027
+ warnOnNoResponse();
1028
+ }
1029
+ }
1030
+
1031
+ function createOutgoingMsg(iframeId) {
1032
+ const iframeSettings = settings[iframeId];
1033
+
1034
+ return [
1035
+ iframeId,
1036
+ '8', // Backwards compatibility (PaddingV1)
1037
+ iframeSettings.sizeWidth,
1038
+ iframeSettings.log,
1039
+ '32', // Backwards compatibility (Interval)
1040
+ true, // Backwards compatibility (EnablePublicMethods)
1041
+ iframeSettings.autoResize,
1042
+ iframeSettings.bodyMargin,
1043
+ iframeSettings.heightCalculationMethod,
1044
+ iframeSettings.bodyBackground,
1045
+ iframeSettings.bodyPadding,
1046
+ iframeSettings.tolerance,
1047
+ iframeSettings.inPageLinks,
1048
+ 'child', // Backwards compatibility (resizeFrom)
1049
+ iframeSettings.widthCalculationMethod,
1050
+ iframeSettings.mouseEvents,
1051
+ iframeSettings.offsetHeight,
1052
+ iframeSettings.offsetWidth,
1053
+ iframeSettings.sizeHeight,
1054
+ iframeSettings.license,
1055
+ page.version,
1056
+ iframeSettings.mode,
1057
+ // iframeSettings.sizeSelector,
1058
+ ].join(':')
1059
+ }
1060
+
1061
+ let count = 0;
1062
+ let setup = false;
1063
+ let vAdvised = false;
1064
+
1065
+ const connectResizer = (options) => (iframe) => {
1066
+ function newId() {
1067
+ let id = options?.id || defaults.id + count++;
1068
+
1069
+ if (document.getElementById(id) !== null) {
1070
+ id += count++;
1071
+ }
1072
+
1073
+ return id
1074
+ }
1075
+
1076
+ function ensureHasId(iframeId) {
1077
+ if (iframeId && typeof iframeId !== 'string') {
1078
+ throw new TypeError('Invalid id for iFrame. Expected String')
1079
+ }
1080
+
1081
+ if (iframeId === '' || !iframeId) {
1082
+ // eslint-disable-next-line no-multi-assign
1083
+ iframe.id = iframeId = newId();
1084
+ setLogEnabled((options || {}).log);
1085
+ log(iframeId, `Added missing iframe ID: ${iframeId} (${iframe.src})`);
1086
+ }
1087
+
1088
+ return iframeId
1089
+ }
1090
+
1091
+ function setScrolling() {
1092
+ log(
1093
+ iframeId,
1094
+ `IFrame scrolling ${
1095
+ settings[iframeId]?.scrolling ? 'enabled' : 'disabled'
1096
+ } for ${iframeId}`,
1097
+ );
1098
+
1099
+ iframe.style.overflow =
1100
+ settings[iframeId]?.scrolling === false ? 'hidden' : 'auto';
1101
+
1102
+ switch (settings[iframeId]?.scrolling) {
1103
+ case 'omit':
1104
+ break
1105
+
1106
+ case true:
1107
+ iframe.scrolling = 'yes';
1108
+ break
1109
+
1110
+ case false:
1111
+ iframe.scrolling = 'no';
1112
+ break
1113
+
1114
+ default:
1115
+ iframe.scrolling = settings[iframeId]
1116
+ ? settings[iframeId].scrolling
1117
+ : 'no';
1118
+ }
1119
+ }
1120
+
1121
+ function setupBodyMarginValues() {
1122
+ const { bodyMargin } = settings[iframeId];
1123
+
1124
+ if (typeof bodyMargin === 'number' || bodyMargin === '0') {
1125
+ settings[iframeId].bodyMargin = `${bodyMargin}px`;
1126
+ }
1127
+ }
1128
+
1129
+ function checkReset() {
1130
+ const firstRun = settings[iframeId]?.firstRun;
1131
+ const resetRequestMethod =
1132
+ settings[iframeId]?.heightCalculationMethod in resetRequiredMethods;
1133
+
1134
+ if (!firstRun && resetRequestMethod) {
1135
+ resetIFrame({ iframe, height: 0, width: 0, type: 'init' });
1136
+ }
1137
+ }
1138
+
1139
+ function setupIFrameObject() {
1140
+ if (settings[iframeId]) {
1141
+ const resizer = {
1142
+ close: closeIFrame.bind(null, settings[iframeId].iframe),
1143
+
1144
+ disconnect: removeIframeListeners.bind(null, settings[iframeId].iframe),
1145
+
1146
+ removeListeners() {
1147
+ advise(
1148
+ iframeId,
1149
+ `
1150
+ <rb>Deprecated Method Name</>
1151
+
1152
+ The \u001B[removeListeners()</> method has been renamed to \u001B[disconnect()</>.
1153
+ `,
1154
+ );
1155
+ this.disconnect();
1156
+ },
1157
+
1158
+ resize: trigger.bind(null, 'Window resize', 'resize', iframeId),
1159
+
1160
+ moveToAnchor(anchor) {
1161
+ trigger('Move to anchor', `moveToAnchor:${anchor}`, iframeId);
1162
+ },
1163
+
1164
+ sendMessage(message) {
1165
+ message = JSON.stringify(message);
1166
+ trigger('Send Message', `message:${message}`, iframeId);
1167
+ },
1168
+ };
1169
+
1170
+ settings[iframeId].iframe.iframeResizer = resizer;
1171
+ settings[iframeId].iframe.iFrameResizer = resizer;
1172
+ }
1173
+ }
1174
+
1175
+ // We have to call trigger twice, as we can not be sure if all
1176
+ // iframes have completed loading when this code runs. The
1177
+ // event listener also catches the page changing in the iFrame.
1178
+ function init(msg) {
1179
+ function iFrameLoaded() {
1180
+ trigger('iFrame.onload', `${msg}:${setup}`, id, true);
1181
+ checkReset();
1182
+ }
1183
+
1184
+ const { id } = iframe;
1185
+
1186
+ if (settings[id].mode === -1) return // modal()
1187
+ if (settings[id].mode === -2) return
1188
+
1189
+ addEventListener(iframe, 'load', iFrameLoaded);
1190
+ if (settings[id].waitForLoad === false)
1191
+ trigger('init', `${msg}:${setup}`, id, true);
1192
+ }
1193
+
1194
+ function checkOptions(options) {
1195
+ if (!options) return {}
1196
+
1197
+ if (typeof options !== 'object') {
1198
+ throw new TypeError('Options is not an object')
1199
+ }
1200
+
1201
+ if (
1202
+ 'sizeWidth' in options ||
1203
+ 'sizeHeight' in options ||
1204
+ 'autoResize' in options
1205
+ ) {
1206
+ advise(
1207
+ iframeId,
1208
+ `<rb>Deprecated Option</>
1209
+
1210
+ The <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <i>"vertical"</>, <i>"horizontal"</> or <i>"horizontal"</>.
1211
+ `,
1212
+ );
1213
+ }
1214
+
1215
+ return options
1216
+ }
1217
+
1218
+ function checkMode() {
1219
+ const { mode } = settings[iframeId];
1220
+ if (mode < 0) advise('Parent', `${getModeData(mode + 2)}${getModeData(2)}`);
1221
+ if (vAdvised || mode < 0) return
1222
+ vAdvised = true;
1223
+ info(`v${VERSION} (${getModeLabel(mode)})`);
1224
+ if (mode < 1) advise('Parent', getModeData(3));
1225
+ }
1226
+
1227
+ function setDirection() {
1228
+ if (settings[iframeId].direction === 'horizontal') {
1229
+ settings[iframeId].sizeWidth = true;
1230
+ settings[iframeId].sizeHeight = false;
1231
+ log(iframeId, 'Direction set to "horizontal"');
1232
+ return
1233
+ }
1234
+
1235
+ if (settings[iframeId].direction === 'none') {
1236
+ settings[iframeId].sizeWidth = false;
1237
+ settings[iframeId].sizeHeight = false;
1238
+ settings[iframeId].autoResize = false;
1239
+ log(iframeId, 'Direction set to "none"');
1240
+ return
1241
+ }
1242
+
1243
+ if (settings[iframeId].direction !== 'vertical') {
1244
+ throw new TypeError(
1245
+ iframeId,
1246
+ `Direction value of "${settings[iframeId].direction}" is not valid`,
1247
+ )
1248
+ }
1249
+
1250
+ log(iframeId, 'Direction set to "vertical"');
1251
+ }
1252
+
1253
+ function setOffsetSize(offset) {
1254
+ if (!offset) return
1255
+ if (settings[iframeId].direction === 'vertical') {
1256
+ settings[iframeId].offsetHeight = offset;
1257
+ log(iframeId, `Offset height set to ${offset}`);
1258
+ } else {
1259
+ settings[iframeId].offsetWidth = offset;
1260
+ log(iframeId, `Offset width set to ${offset}`);
1261
+ }
1262
+ }
1263
+
1264
+ function getTargetOrigin(remoteHost) {
1265
+ return remoteHost === '' ||
1266
+ remoteHost.match(/^(about:blank|javascript:|file:\/\/)/) !== null
1267
+ ? '*'
1268
+ : remoteHost
1269
+ }
1270
+
1271
+ function getPostMessageTarget() {
1272
+ if (settings[iframeId].postMessageTarget === null)
1273
+ settings[iframeId].postMessageTarget = iframe.contentWindow;
1274
+ }
1275
+
1276
+ function chkTitle(iframeId) {
1277
+ const title = settings[iframeId]?.iframe?.title;
1278
+ return title === '' || title === undefined
1279
+ }
1280
+
1281
+ function processOptions(options) {
1282
+ settings[iframeId] = {
1283
+ iframe,
1284
+ firstRun: true,
1285
+ remoteHost: iframe?.src.split('/').slice(0, 3).join('/'),
1286
+ ...defaults,
1287
+ ...checkOptions(options),
1288
+ mode: setMode(options),
1289
+ syncTitle: chkTitle(iframeId),
1290
+ };
1291
+
1292
+ setDirection();
1293
+ setOffsetSize(options?.offsetSize || options?.offset);
1294
+
1295
+ if (options?.offset) {
1296
+ advise(
1297
+ iframeId,
1298
+ `<rb>Deprecated option</>\n\n The <b>offset</> option has been renamed to <b>offsetSize</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.`,
1299
+ );
1300
+ }
1301
+
1302
+ getPostMessageTarget();
1303
+
1304
+ settings[iframeId].targetOrigin =
1305
+ settings[iframeId].checkOrigin === true
1306
+ ? getTargetOrigin(settings[iframeId].remoteHost)
1307
+ : '*';
1308
+ }
1309
+
1310
+ function beenHere() {
1311
+ return iframeId in settings && 'iFrameResizer' in iframe
1312
+ }
1313
+
1314
+ const iframeId = ensureHasId(iframe.id);
1315
+
1316
+ if (beenHere()) {
1317
+ warn(iframeId, 'Ignored iFrame, already setup.');
1318
+ } else {
1319
+ processOptions(options);
1320
+ checkMode();
1321
+ setupEventListenersOnce();
1322
+ setScrolling();
1323
+ setupBodyMarginValues();
1324
+ init(createOutgoingMsg(iframeId));
1325
+ setupIFrameObject();
1326
+ }
1327
+
1328
+ return iframe?.iFrameResizer
1329
+ };
1330
+
1331
+ function sendTriggerMsg(eventName, event) {
1332
+ function triggerEnabledIframe(iframeId) {
1333
+ if (isIFrameResizeEnabled(iframeId)) {
1334
+ trigger(eventName, event, iframeId);
1335
+ }
1336
+ }
1337
+
1338
+ const isIFrameResizeEnabled = (iframeId) =>
1339
+ settings[iframeId]?.autoResize && !settings[iframeId]?.firstRun;
1340
+
1341
+ Object.keys(settings).forEach(triggerEnabledIframe);
1342
+ }
1343
+
1344
+ function tabVisible() {
1345
+ if (document.hidden === false) {
1346
+ log('document', 'Trigger event: Visibility change');
1347
+ sendTriggerMsg('Tab Visible', 'resize');
1348
+ }
1349
+ }
1350
+
1351
+ const setupEventListenersOnce = once(() => {
1352
+ addEventListener(window, 'message', iframeListener);
1353
+ addEventListener(document, 'visibilitychange', tabVisible);
1354
+ window.iframeParentListener = (data) =>
1355
+ iframeListener({ data, sameDomain: true });
1356
+ });
1357
+
1358
+ switch (true) {
1359
+ case window.jQuery === undefined:
1360
+ warn('', 'Unable to bind to jQuery, it is not available.');
1361
+ break
1362
+
1363
+ case !window.jQuery.fn:
1364
+ warn('', 'Unable to bind to jQuery, it is not fully loaded.');
1365
+ break
1366
+
1367
+ case window.jQuery.fn.iframeResize:
1368
+ warn('', 'iframeResize is already assigned to jQuery.fn.');
1369
+ break
1370
+
1371
+ default:
1372
+ window.jQuery.fn.iframeResize = function (options) {
1373
+ const connectWithOptions = connectResizer(options);
1374
+
1375
+ return this.filter('iframe').each(connectWithOptions).end()
1376
+ };
1377
+
1378
+ window.jQuery.fn.iFrameResize = function (options) {
1379
+ warn(
1380
+ '',
1381
+ 'Deprecated: Use the iframeResize method instead of iFrameResize',
1382
+ );
1383
+
1384
+ return this.iframeResize(options)
1385
+ };
1386
+ }
1387
+
1388
+ }));