@iframe-resizer/child 5.0.2 → 5.1.1

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,7 +1,7 @@
1
1
  /*!
2
2
  * @preserve
3
3
  *
4
- * @module iframe-resizer/child 5.0.2 (umd) - 2024-05-30
4
+ * @module iframe-resizer/child 5.1.1 (umd) - 2024-06-19
5
5
  *
6
6
  * @license GPL-3.0 for non-commercial use only.
7
7
  * For commercial use, you must purchase a license from
@@ -17,1295 +17,4 @@
17
17
  */
18
18
 
19
19
 
20
- (function (factory) {
21
- typeof define === 'function' && define.amd ? define(factory) :
22
- factory();
23
- })((function () { 'use strict';
24
-
25
- const VERSION = '5.0.2';
26
-
27
- const BASE = 10;
28
- const SIZE_ATTR = 'data-iframe-size';
29
-
30
- const encode = (s) =>
31
- s
32
- .replaceAll('<br>', '\n')
33
- .replaceAll('<rb>', '\u001B[31;1m')
34
- .replaceAll('</>', '\u001B[m')
35
- .replaceAll('<b>', '\u001B[1m')
36
- .replaceAll('<i>', '\u001B[3m')
37
- .replaceAll('<u>', '\u001B[4m');
38
-
39
- const remove = (s) => s.replaceAll('<br>', '\n').replaceAll(/<[/a-z]+>/gi, '');
40
-
41
- const formatAdvise = (formatLogMsg) => (msg) =>
42
- window.chrome // Only show formatting in Chrome as not supported in other browsers
43
- ? formatLogMsg(encode(msg))
44
- : formatLogMsg(remove(msg));
45
-
46
- const addEventListener = (el, evt, func, options) =>
47
- el.addEventListener(evt, func, options || false);
48
-
49
- const removeEventListener = (el, evt, func) =>
50
- el.removeEventListener(evt, func, false);
51
-
52
- const p = (l) =>
53
- l.replaceAll(/[A-Za-z]/g, (l) =>
54
- String.fromCodePoint(
55
- (l <= 'Z' ? 90 : 122) >= (l = l.codePointAt(0) + 19) ? l : l - 26,
56
- ),
57
- ),
58
- y = [
59
- '<iy><yi>Puchspk Spjluzl Rlf</><iy><iy>',
60
- '<iy><yi>Tpzzpun Spjluzl Rlf</><iy><iy>',
61
- '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</>',
62
- '<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</>.',
63
- ];
64
- Object.fromEntries(
65
- [
66
- '2cgs7fdf4xb',
67
- '1c9ctcccr4z',
68
- '1q2pc4eebgb',
69
- 'ueokt0969w',
70
- 'w2zxchhgqz',
71
- '1umuxblj2e5',
72
- ].map((l, p) => [l, Math.max(0, p - 1)]),
73
- );
74
- const getModeData = (l) => p(y[l]);
75
-
76
- const checkVisibilityOptions = {
77
- contentVisibilityAuto: true,
78
- opacityProperty: true,
79
- visibilityProperty: true,
80
- };
81
- const customCalcMethods = {
82
- height: () => {
83
- warn('Custom height calculation function not defined');
84
- return getHeight.auto()
85
- },
86
- width: () => {
87
- warn('Custom width calculation function not defined');
88
- return getWidth.auto()
89
- },
90
- };
91
- const deprecatedResizeMethods = {
92
- bodyOffset: 1,
93
- bodyScroll: 1,
94
- offset: 1,
95
- documentElementOffset: 1,
96
- documentElementScroll: 1,
97
- documentElementBoundingClientRect: 1,
98
- max: 1,
99
- min: 1,
100
- grow: 1,
101
- lowestElement: 1,
102
- };
103
- const eventCancelTimer = 128;
104
- const eventHandlersByName = {};
105
- const hasCheckVisibility = 'checkVisibility' in window;
106
- const heightCalcModeDefault = 'auto';
107
- const msgID = '[iFrameSizer]'; // Must match host page msg ID
108
- const msgIdLen = msgID.length;
109
- const resetRequiredMethods = {
110
- max: 1,
111
- min: 1,
112
- bodyScroll: 1,
113
- documentElementScroll: 1,
114
- };
115
- const resizeObserveTargets = ['body'];
116
- const widthCalcModeDefault = 'scroll';
117
-
118
- let autoResize = true;
119
- let bodyBackground = '';
120
- let bodyMargin = 0;
121
- let bodyMarginStr = '';
122
- let bodyObserver = null;
123
- let bodyPadding = '';
124
- let calculateHeight = true;
125
- let calculateWidth = false;
126
- let calcElements = null;
127
- let firstRun = true;
128
- let hasTags = false;
129
- let height = 1;
130
- let heightCalcMode = heightCalcModeDefault; // only applys if not provided by host page (V1 compatibility)
131
- let initLock = true;
132
- let initMsg = '';
133
- let inPageLinks = {};
134
- let isInit = true;
135
- let logging = false;
136
- let mode = 0;
137
- let mouseEvents = false;
138
- let myID = '';
139
- let offsetHeight;
140
- let offsetWidth;
141
- let resizeFrom = 'child';
142
- let resizeObserver = null;
143
- let sameDomain = false;
144
- let target = window.parent;
145
- let targetOriginDefault = '*';
146
- let tolerance = 0;
147
- let triggerLocked = false;
148
- let version = '';
149
- let width = 1;
150
- let widthCalcMode = widthCalcModeDefault;
151
- let win = window;
152
-
153
- let onMessage = () => {
154
- warn('onMessage function not defined');
155
- };
156
- let onReady = () => {};
157
- let onPageInfo = null;
158
- let onParentInfo = null;
159
-
160
- const capitalizeFirstLetter = (string) =>
161
- string.charAt(0).toUpperCase() + string.slice(1);
162
-
163
- const isDef = (value) => `${value}` !== '' && value !== undefined;
164
-
165
- function getElementName(el) {
166
- switch (true) {
167
- case !isDef(el):
168
- return ''
169
-
170
- case isDef(el.id):
171
- return `${el.nodeName.toUpperCase()}#${el.id}`
172
-
173
- case isDef(el.name):
174
- return `${el.nodeName.toUpperCase()} (${el.name})`
175
-
176
- default:
177
- return (
178
- el.nodeName.toUpperCase() +
179
- (isDef(el.className) ? `.${el.className}` : '')
180
- )
181
- }
182
- }
183
-
184
- function elementSnippet(el) {
185
- const outer = el?.outerHTML?.toString();
186
-
187
- if (!outer) return el
188
-
189
- return outer.length < 30
190
- ? outer
191
- : `${outer.slice(0, 30).replaceAll('\n', ' ')}...`
192
- }
193
-
194
- // TODO: remove .join(' '), requires major test updates
195
- const formatLogMsg = (...msg) => [`[iframe-resizer][${myID}]`, ...msg].join(' ');
196
-
197
- // const info = (...msg) =>
198
- // // eslint-disable-next-line no-console
199
- // console?.info(formatAdvise(...msg))
200
-
201
- const warn = (...msg) =>
202
- // eslint-disable-next-line no-console
203
- console?.warn(formatLogMsg(...msg));
204
-
205
- const advise = (...msg) =>
206
- // eslint-disable-next-line no-console
207
- console?.warn(formatAdvise(formatLogMsg)(...msg));
208
-
209
- const adviser = (msg) => advise(msg);
210
-
211
- function init() {
212
- checkCrossDomain();
213
- readDataFromParent();
214
- readDataFromPage();
215
- setMargin();
216
- setBodyStyle('background', bodyBackground);
217
- setBodyStyle('padding', bodyPadding);
218
- injectClearFixIntoBodyElement();
219
- stopInfiniteResizingOfIFrame();
220
- checkMode();
221
- checkVersion();
222
- checkHeightMode();
223
- checkWidthMode();
224
- checkDeprecatedAttrs();
225
- checkHasDataSizeAttributes();
226
- setupCalcElements();
227
- setupPublicMethods();
228
- setupMouseEvents();
229
- startEventListeners();
230
- inPageLinks = setupInPageLinks();
231
- sendSize('init', 'Init message from host page', undefined, undefined, VERSION);
232
- onReady();
233
- isInit = false;
234
- }
235
-
236
- function checkVersion() {
237
- if (!version || version === '' || version === 'false') {
238
- advise(
239
- `<rb>Legacy version detected on parent page</>
240
-
241
- Detected legacy version of parent page script. It is recommended to update the parent page to use <b>@iframe-resizer/parent</>.
242
-
243
- See <u>https://iframe-resizer.com/setup/<u> for more details.
244
- `,
245
- );
246
- return
247
- }
248
-
249
- if (version !== VERSION) {
250
- advise(
251
- `<rb>Version mismatch</>
252
-
253
- The parent and child pages are running different versions of <i>iframe resizer</>.
254
-
255
- Parent page: ${version} - Child page: ${VERSION}.
256
- `,
257
- );
258
- }
259
- }
260
-
261
- function checkCrossDomain() {
262
- try {
263
- sameDomain = 'iframeParentListener' in window.parent;
264
- } catch (error) {
265
- }
266
- }
267
-
268
- function readDataFromParent() {
269
- const strBool = (str) => str === 'true';
270
- const data = initMsg.slice(msgIdLen).split(':');
271
-
272
- myID = data[0]; // eslint-disable-line prefer-destructuring
273
- bodyMargin = undefined === data[1] ? bodyMargin : Number(data[1]); // For V1 compatibility
274
- calculateWidth = undefined === data[2] ? calculateWidth : strBool(data[2]);
275
- logging = undefined === data[3] ? logging : strBool(data[3]);
276
- // data[4] no longer used (was intervalTimer)
277
- autoResize = undefined === data[6] ? autoResize : strBool(data[6]);
278
- bodyMarginStr = data[7]; // eslint-disable-line prefer-destructuring
279
- heightCalcMode = undefined === data[8] ? heightCalcMode : data[8];
280
- bodyBackground = data[9]; // eslint-disable-line prefer-destructuring
281
- bodyPadding = data[10]; // eslint-disable-line prefer-destructuring
282
- tolerance = undefined === data[11] ? tolerance : Number(data[11]);
283
- inPageLinks.enable = undefined === data[12] ? false : strBool(data[12]);
284
- resizeFrom = undefined === data[13] ? resizeFrom : data[13];
285
- widthCalcMode = undefined === data[14] ? widthCalcMode : data[14];
286
- mouseEvents = undefined === data[15] ? mouseEvents : strBool(data[15]);
287
- offsetHeight = undefined === data[16] ? offsetHeight : Number(data[16]);
288
- offsetWidth = undefined === data[17] ? offsetWidth : Number(data[17]);
289
- calculateHeight = undefined === data[18] ? calculateHeight : strBool(data[18]);
290
- data[19]; // eslint-disable-line prefer-destructuring
291
- version = data[20] || version;
292
- mode = undefined === data[21] ? mode : Number(data[21]);
293
- }
294
-
295
- function readDataFromPage() {
296
- function readData() {
297
- const data = window.iframeResizer || window.iFrameResizer;
298
-
299
- onMessage = data?.onMessage || onMessage;
300
- onReady = data?.onReady || onReady;
301
-
302
- if (typeof data?.offset === 'number') {
303
- if (calculateHeight) offsetHeight = data?.offset;
304
- if (calculateWidth) offsetWidth = data?.offset;
305
- }
306
-
307
- targetOriginDefault = data?.targetOrigin || targetOriginDefault;
308
- heightCalcMode = data?.heightCalculationMethod || heightCalcMode;
309
- widthCalcMode = data?.widthCalculationMethod || widthCalcMode;
310
- }
311
-
312
- function setupCustomCalcMethods(calcMode, calcFunc) {
313
- if (typeof calcMode === 'function') {
314
- customCalcMethods[calcFunc] = calcMode;
315
- calcMode = 'custom';
316
- }
317
-
318
- return calcMode
319
- }
320
-
321
- if (mode === 1) return
322
-
323
- if (
324
- 'iFrameResizer' in window &&
325
- Object === window.iFrameResizer.constructor
326
- ) {
327
- readData();
328
- heightCalcMode = setupCustomCalcMethods(heightCalcMode, 'height');
329
- widthCalcMode = setupCustomCalcMethods(widthCalcMode, 'width');
330
- }
331
- }
332
-
333
- function chkCSS(attr, value) {
334
- if (value.includes('-')) {
335
- warn(`Negative CSS value ignored for ${attr}`);
336
- value = '';
337
- }
338
-
339
- return value
340
- }
341
-
342
- function setBodyStyle(attr, value) {
343
- if (undefined !== value && value !== '' && value !== 'null') {
344
- document.body.style.setProperty(attr, value);
345
- }
346
- }
347
-
348
- function setMargin() {
349
- // If called via V1 script, convert bodyMargin from int to str
350
- if (undefined === bodyMarginStr) {
351
- bodyMarginStr = `${bodyMargin}px`;
352
- }
353
-
354
- setBodyStyle('margin', chkCSS('margin', bodyMarginStr));
355
- }
356
-
357
- function stopInfiniteResizingOfIFrame() {
358
- const setAutoHeight = (el) =>
359
- el.style.setProperty('height', 'auto', 'important');
360
-
361
- setAutoHeight(document.documentElement);
362
- setAutoHeight(document.body);
363
- }
364
-
365
- function manageTriggerEvent(options) {
366
- const listener = {
367
- add(eventName) {
368
- function handleEvent() {
369
- sendSize(options.eventName, options.eventType);
370
- }
371
-
372
- eventHandlersByName[eventName] = handleEvent;
373
-
374
- addEventListener(window, eventName, handleEvent, { passive: true });
375
- },
376
- remove(eventName) {
377
- const handleEvent = eventHandlersByName[eventName];
378
- delete eventHandlersByName[eventName];
379
-
380
- removeEventListener(window, eventName, handleEvent);
381
- },
382
- };
383
-
384
- listener[options.method](options.eventName);
385
- }
386
-
387
- function manageEventListeners(method) {
388
- manageTriggerEvent({
389
- method,
390
- eventType: 'After Print',
391
- eventName: 'afterprint',
392
- });
393
-
394
- manageTriggerEvent({
395
- method,
396
- eventType: 'Before Print',
397
- eventName: 'beforeprint',
398
- });
399
-
400
- manageTriggerEvent({
401
- method,
402
- eventType: 'Ready State Change',
403
- eventName: 'readystatechange',
404
- });
405
-
406
- // manageTriggerEvent({
407
- // method: method,
408
- // eventType: 'Orientation Change',
409
- // eventName: 'orientationchange'
410
- // })
411
- }
412
-
413
- function checkDeprecatedAttrs() {
414
- let found = false;
415
-
416
- const checkAttrs = (attr) =>
417
- document.querySelectorAll(`[${attr}]`).forEach((el) => {
418
- found = true;
419
- el.removeAttribute(attr);
420
- el.setAttribute(SIZE_ATTR, null);
421
- });
422
-
423
- checkAttrs('data-iframe-height');
424
- checkAttrs('data-iframe-width');
425
-
426
- if (found) {
427
- advise(
428
- `<rb>Deprecated Attributes</>
429
-
430
- The <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.`,
431
- );
432
- }
433
- }
434
-
435
- function checkHasDataSizeAttributes() {
436
- if (document.querySelectorAll(`[${SIZE_ATTR}]`).length > 0) {
437
- if (heightCalcMode === 'auto') {
438
- heightCalcMode = 'autoOverflow';
439
- }
440
- if (widthCalcMode === 'auto') {
441
- widthCalcMode = 'autoOverflow';
442
- }
443
- }
444
- }
445
-
446
- function setupCalcElements() {
447
- const taggedElements = document.querySelectorAll(`[${SIZE_ATTR}]`);
448
- hasTags = taggedElements.length > 0;
449
- calcElements = hasTags ? taggedElements : getAllElements(document)();
450
- }
451
-
452
- function checkCalcMode(calcMode, calcModeDefault, modes, type) {
453
- if (calcModeDefault !== calcMode) {
454
- if (!(calcMode in modes)) {
455
- warn(`${calcMode} is not a valid option for ${type}CalculationMethod.`);
456
- calcMode = calcModeDefault;
457
- }
458
- if (calcMode in deprecatedResizeMethods) {
459
- advise(
460
- `<rb>Deprecated ${type}CalculationMethod (${calcMode})</>
461
-
462
- This version of <i>iframe-resizer</> can auto detect the most suitable ${type} calculation method. It is recommended that you remove this option.`,
463
- );
464
- }
465
- }
466
-
467
- return calcMode
468
- }
469
-
470
- function checkHeightMode() {
471
- heightCalcMode = checkCalcMode(
472
- heightCalcMode,
473
- heightCalcModeDefault,
474
- getHeight,
475
- 'height',
476
- );
477
- }
478
-
479
- function checkWidthMode() {
480
- widthCalcMode = checkCalcMode(
481
- widthCalcMode,
482
- widthCalcModeDefault,
483
- getWidth,
484
- 'width',
485
- );
486
- }
487
-
488
- function checkMode() {
489
- if (mode < 0) return adviser(`${getModeData(mode + 2)}${getModeData(2)}`)
490
- if (version.codePointAt(0) > 4) return mode
491
- if (mode < 2) return adviser(getModeData(3))
492
- return mode
493
- }
494
-
495
- function startEventListeners() {
496
- if (autoResize !== true) {
497
- return
498
- }
499
-
500
- manageEventListeners('add');
501
- setupMutationObserver();
502
- setupResizeObserver();
503
- }
504
-
505
- function stopEventListeners() {
506
- manageEventListeners('remove');
507
- resizeObserver?.disconnect();
508
- bodyObserver?.disconnect();
509
- }
510
-
511
- function injectClearFixIntoBodyElement() {
512
- const clearFix = document.createElement('div');
513
-
514
- clearFix.style.clear = 'both';
515
- // Guard against the following having been globally redefined in CSS.
516
- clearFix.style.display = 'block';
517
- clearFix.style.height = '0';
518
- document.body.append(clearFix);
519
- }
520
-
521
- function setupInPageLinks() {
522
- const getPagePosition = () => ({
523
- x: document.documentElement.scrollLeft,
524
- y: document.documentElement.scrollTop,
525
- });
526
-
527
- function getElementPosition(el) {
528
- const elPosition = el.getBoundingClientRect();
529
- const pagePosition = getPagePosition();
530
-
531
- return {
532
- x: parseInt(elPosition.left, BASE) + parseInt(pagePosition.x, BASE),
533
- y: parseInt(elPosition.top, BASE) + parseInt(pagePosition.y, BASE),
534
- }
535
- }
536
-
537
- function findTarget(location) {
538
- function jumpToTarget(target) {
539
- const jumpPosition = getElementPosition(target);
540
-
541
- sendMsg(jumpPosition.y, jumpPosition.x, 'scrollToOffset'); // X&Y reversed at sendMsg uses height/width
542
- }
543
-
544
- const hash = location.split('#')[1] || location; // Remove # if present
545
- const hashData = decodeURIComponent(hash);
546
- const target =
547
- document.getElementById(hashData) ||
548
- document.getElementsByName(hashData)[0];
549
-
550
- if (target !== undefined) {
551
- jumpToTarget(target);
552
- return
553
- }
554
- sendMsg(0, 0, 'inPageLink', `#${hash}`);
555
- }
556
-
557
- function checkLocationHash() {
558
- const { hash, href } = window.location;
559
-
560
- if (hash !== '' && hash !== '#') {
561
- findTarget(href);
562
- }
563
- }
564
-
565
- function bindAnchors() {
566
- function setupLink(el) {
567
- function linkClicked(e) {
568
- e.preventDefault();
569
-
570
- findTarget(this.getAttribute('href'));
571
- }
572
-
573
- if (el.getAttribute('href') !== '#') {
574
- addEventListener(el, 'click', linkClicked);
575
- }
576
- }
577
-
578
- document.querySelectorAll('a[href^="#"]').forEach(setupLink);
579
- }
580
-
581
- function bindLocationHash() {
582
- addEventListener(window, 'hashchange', checkLocationHash);
583
- }
584
-
585
- function initCheck() {
586
- // Check if page loaded with location hash after init resize
587
- setTimeout(checkLocationHash, eventCancelTimer);
588
- }
589
-
590
- function enableInPageLinks() {
591
- bindAnchors();
592
- bindLocationHash();
593
- initCheck();
594
- }
595
-
596
- if (inPageLinks.enable) {
597
- if (mode === 1) {
598
- advise(
599
- `In page linking requires a Professional or Business license. Please see https://iframe-resizer.com/pricing for more details.`,
600
- );
601
- } else {
602
- enableInPageLinks();
603
- }
604
- }
605
-
606
- return {
607
- findTarget,
608
- }
609
- }
610
-
611
- function setupMouseEvents() {
612
- if (mouseEvents !== true) return
613
-
614
- function sendMouse(e) {
615
- sendMsg(0, 0, e.type, `${e.screenY}:${e.screenX}`);
616
- }
617
-
618
- function addMouseListener(evt, name) {
619
- addEventListener(window.document, evt, sendMouse);
620
- }
621
-
622
- addMouseListener('mouseenter');
623
- addMouseListener('mouseleave');
624
- }
625
-
626
- function setupPublicMethods() {
627
- if (mode === 1) return
628
-
629
- win.parentIframe = Object.freeze({
630
- autoResize: (resize) => {
631
- if (resize === true && autoResize === false) {
632
- autoResize = true;
633
- startEventListeners();
634
- } else if (resize === false && autoResize === true) {
635
- autoResize = false;
636
- stopEventListeners();
637
- }
638
-
639
- sendMsg(0, 0, 'autoResize', JSON.stringify(autoResize));
640
-
641
- return autoResize
642
- },
643
-
644
- close() {
645
- sendMsg(0, 0, 'close');
646
- },
647
-
648
- getId: () => myID,
649
-
650
- getPageInfo(callback) {
651
- if (typeof callback === 'function') {
652
- onPageInfo = callback;
653
- sendMsg(0, 0, 'pageInfo');
654
- advise(
655
- `<rb>Deprecated Method</>
656
-
657
- The <b>getPageInfo()</> method has been deprecated and replaced with <b>getParentProperties()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.
658
- `,
659
- );
660
- return
661
- }
662
-
663
- onPageInfo = null;
664
- sendMsg(0, 0, 'pageInfoStop');
665
- },
666
-
667
- getParentProperties(callback) {
668
- if (typeof callback !== 'function') {
669
- throw new TypeError(
670
- 'parentIFrame.getParentProperties(callback) callback not a function',
671
- )
672
- }
673
-
674
- onParentInfo = callback;
675
- sendMsg(0, 0, 'parentInfo');
676
-
677
- return () => {
678
- onParentInfo = null;
679
- sendMsg(0, 0, 'parentInfoStop');
680
- }
681
- },
682
-
683
- moveToAnchor(hash) {
684
- inPageLinks.findTarget(hash);
685
- },
686
-
687
- reset() {
688
- resetIFrame();
689
- },
690
-
691
- scrollTo(x, y) {
692
- sendMsg(y, x, 'scrollTo'); // X&Y reversed at sendMsg uses height/width
693
- },
694
-
695
- scrollToOffset(x, y) {
696
- sendMsg(y, x, 'scrollToOffset'); // X&Y reversed at sendMsg uses height/width
697
- },
698
-
699
- sendMessage(msg, targetOrigin) {
700
- sendMsg(0, 0, 'message', JSON.stringify(msg), targetOrigin);
701
- },
702
-
703
- setHeightCalculationMethod(heightCalculationMethod) {
704
- heightCalcMode = heightCalculationMethod;
705
- checkHeightMode();
706
- },
707
-
708
- setWidthCalculationMethod(widthCalculationMethod) {
709
- widthCalcMode = widthCalculationMethod;
710
- checkWidthMode();
711
- },
712
-
713
- setTargetOrigin(targetOrigin) {
714
- targetOriginDefault = targetOrigin;
715
- },
716
-
717
- resize(customHeight, customWidth) {
718
- const valString = `${customHeight || ''}${customWidth ? `,${customWidth}` : ''}`;
719
-
720
- sendSize(
721
- 'size',
722
- `parentIFrame.size(${valString})`,
723
- customHeight,
724
- customWidth,
725
- );
726
- },
727
-
728
- size(customHeight, customWidth) {
729
- advise(
730
- `<rb>Deprecated Method</>
731
-
732
- The <b>size()</> method has been deprecated and replaced with <b>resize()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.
733
- `,
734
- );
735
- this.resize(customHeight, customWidth);
736
- },
737
- });
738
-
739
- win.parentIFrame = win.parentIframe;
740
- }
741
-
742
- let dispatchResized;
743
-
744
- function resizeObserved(entries) {
745
- if (!Array.isArray(entries) || entries.length === 0) return
746
-
747
- const el = entries[0].target;
748
-
749
- dispatchResized = () =>
750
- sendSize('resizeObserver', `Resize Observed: ${getElementName(el)}`);
751
-
752
- // Throttle event to once per current call stack (Safari issue)
753
- setTimeout(() => {
754
- if (dispatchResized) dispatchResized();
755
- dispatchResized = undefined;
756
- }, 0);
757
- }
758
-
759
- const checkPositionType = (element) => {
760
- const style = getComputedStyle(element);
761
- return style?.position !== '' && style?.position !== 'static'
762
- };
763
-
764
- const getAllNonStaticElements = () =>
765
- [...getAllElements(document)()].filter(checkPositionType);
766
-
767
- function setupResizeObservers(el) {
768
- if (!el) return
769
- resizeObserver.observe(el);
770
- }
771
-
772
- function createResizeObservers(el) {
773
- [
774
- ...getAllNonStaticElements(),
775
- ...resizeObserveTargets.flatMap((target) => el.querySelector(target)),
776
- ].forEach(setupResizeObservers);
777
- }
778
-
779
- function addResizeObservers(mutation) {
780
- if (mutation.type === 'childList') {
781
- createResizeObservers(mutation.target);
782
- }
783
- }
784
-
785
- function setupResizeObserver() {
786
- resizeObserver = new ResizeObserver(resizeObserved);
787
- createResizeObservers(window.document);
788
- }
789
-
790
- function setupBodyMutationObserver() {
791
- function mutationObserved(mutations) {
792
- // Look for injected elements that need ResizeObservers
793
- mutations.forEach(addResizeObservers);
794
-
795
- // Rebuild elements list for size calculation
796
- setupCalcElements();
797
- }
798
-
799
- function createMutationObserver() {
800
- const observer = new window.MutationObserver(mutationObserved);
801
- const target = document.querySelector('body');
802
- const config = {
803
- // attributes: true,
804
- attributes: false,
805
- attributeOldValue: false,
806
- // characterData: true,
807
- characterData: false,
808
- characterDataOldValue: false,
809
- childList: true,
810
- subtree: true,
811
- };
812
- observer.observe(target, config);
813
-
814
- return observer
815
- }
816
-
817
- const observer = createMutationObserver();
818
-
819
- return {
820
- disconnect() {
821
- observer.disconnect();
822
- },
823
- }
824
- }
825
-
826
- function setupMutationObserver() {
827
- bodyObserver = setupBodyMutationObserver();
828
- }
829
-
830
- function getMaxElement(side) {
831
- const Side = capitalizeFirstLetter(side);
832
-
833
- let elVal = 0;
834
- let len = calcElements.length;
835
- let maxEl;
836
- let maxVal = 0;
837
- let timer = performance.now();
838
-
839
- calcElements.forEach((element) => {
840
- if (
841
- !hasTags &&
842
- hasCheckVisibility &&
843
- !element.checkVisibility(checkVisibilityOptions)
844
- ) {
845
- len -= 1;
846
- return
847
- }
848
-
849
- elVal =
850
- element.getBoundingClientRect()[side] +
851
- parseFloat(getComputedStyle(element).getPropertyValue(`margin-${side}`));
852
-
853
- if (elVal > maxVal) {
854
- maxVal = elVal;
855
- maxEl = element;
856
- }
857
- });
858
-
859
- timer = performance.now() - timer;
860
-
861
- const logMsg = `
862
- Parsed ${len} element${(len = '' )} in ${timer.toPrecision(3)}ms
863
- ${Side} ${hasTags ? 'tagged ' : ''}element found at: ${maxVal}px
864
- Position calculated from HTML element: ${elementSnippet(maxEl)}`;
865
-
866
- if (timer < 1.1 || isInit || hasTags) ; else {
867
- advise(
868
- `<rb>Performance Warning</>
869
-
870
- Calculating the page size took an excessive amount of time. To improve performance add the <b>data-iframe-size</> attribute to the ${side} most element on the page.
871
- ${logMsg}`,
872
- );
873
- }
874
- return maxVal
875
- }
876
-
877
- const getAllMeasurements = (dimension) => [
878
- dimension.bodyOffset(),
879
- dimension.bodyScroll(),
880
- dimension.documentElementOffset(),
881
- dimension.documentElementScroll(),
882
- dimension.documentElementBoundingClientRect(),
883
- ];
884
-
885
- const getAllElements = (element) => () =>
886
- element.querySelectorAll(
887
- '* :not(head):not(meta):not(base):not(title):not(script):not(link):not(style):not(map):not(area):not(option):not(optgroup):not(template):not(track):not(wbr):not(nobr)',
888
- );
889
-
890
- let switchChecked = false;
891
-
892
- function switchToAutoOverflow({
893
- ceilBoundingSize,
894
- dimension,
895
- getDimension,
896
- isHeight,
897
- scrollSize,
898
- }) {
899
- if (!switchChecked) {
900
- // If this just happens once, then it is likely we just came from a large page.
901
- switchChecked = true;
902
- return getDimension.taggedElement()
903
- }
904
-
905
- const furthest = isHeight ? 'lowest' : 'right most';
906
- const side = isHeight ? 'bottom' : 'right';
907
- const overflowDetectedMessage = `<rb>Detected content overflowing html element</>
908
-
909
- This causes <i>iframe-resizer</> to fall back to checking the position of every element on the page in order to calculate the correct dimensions of the iframe. Inspecting the size, ${side} margin, and position of every visible HTML element will have a performance impact on more complex pages.
910
-
911
- To fix this issue, and remove this warning, you can either ensure the content of the page does not overflow the <b><HTML></> element or alternatively you can add the attribute <b>data-iframe-size</> to the elements on the page that you want <i>iframe-resizer</> to use when calculating the dimensions of the iframe.
912
-
913
- When present the <i>${side} margin of the ${furthest} element</> with a <b>data-iframe-size</> attribute will be used to set the ${dimension} of the iframe.
914
-
915
- (Page size: ${scrollSize} > document size: ${ceilBoundingSize})`;
916
-
917
- advise(overflowDetectedMessage);
918
-
919
- if (isHeight) {
920
- heightCalcMode = 'autoOverflow';
921
- } else {
922
- widthCalcMode = 'autoOverflow';
923
- }
924
-
925
- return getDimension.taggedElement()
926
- }
927
-
928
- const prevScrollSize = {
929
- height: 0,
930
- width: 0,
931
- };
932
-
933
- const prevBoundingSize = {
934
- height: 0,
935
- width: 0,
936
- };
937
-
938
- const getAdjustedScroll = (getDimension) =>
939
- getDimension.documentElementScroll() + Math.max(0, getDimension.getOffset());
940
-
941
- function getAutoSize(getDimension, autoOverflow) {
942
- function returnBoundingClientRect() {
943
- prevBoundingSize[dimension] = boundingSize;
944
- prevScrollSize[dimension] = scrollSize;
945
- return boundingSize
946
- }
947
-
948
- const isHeight = getDimension === getHeight;
949
- const dimension = isHeight ? 'height' : 'width';
950
- const boundingSize = getDimension.documentElementBoundingClientRect();
951
- const ceilBoundingSize = Math.ceil(boundingSize);
952
- const floorBoundingSize = Math.floor(boundingSize);
953
- const scrollSize = getAdjustedScroll(getDimension);
954
-
955
- switch (true) {
956
- case !getDimension.enabled():
957
- return scrollSize
958
-
959
- case !autoOverflow &&
960
- prevBoundingSize[dimension] === 0 &&
961
- prevScrollSize[dimension] === 0:
962
- if (getDimension.taggedElement(true) <= ceilBoundingSize) {
963
- return returnBoundingClientRect()
964
- }
965
- break
966
-
967
- case triggerLocked &&
968
- boundingSize === prevBoundingSize[dimension] &&
969
- scrollSize === prevScrollSize[dimension]:
970
- return Math.max(boundingSize, scrollSize)
971
-
972
- case boundingSize === 0:
973
- return scrollSize
974
-
975
- case !autoOverflow &&
976
- boundingSize !== prevBoundingSize[dimension] &&
977
- scrollSize <= prevScrollSize[dimension]:
978
- return returnBoundingClientRect()
979
-
980
- case !isHeight:
981
- return autoOverflow
982
- ? getDimension.taggedElement()
983
- : switchToAutoOverflow({
984
- ceilBoundingSize,
985
- dimension,
986
- getDimension,
987
- isHeight,
988
- scrollSize,
989
- })
990
-
991
- case !autoOverflow && boundingSize < prevBoundingSize[dimension]:
992
- return returnBoundingClientRect()
993
-
994
- case scrollSize === floorBoundingSize || scrollSize === ceilBoundingSize:
995
- return returnBoundingClientRect()
996
-
997
- case boundingSize > scrollSize:
998
- return returnBoundingClientRect()
999
-
1000
- case !autoOverflow:
1001
- return switchToAutoOverflow({
1002
- ceilBoundingSize,
1003
- dimension,
1004
- getDimension,
1005
- isHeight,
1006
- scrollSize,
1007
- })
1008
- }
1009
-
1010
- return Math.max(getDimension.taggedElement(), returnBoundingClientRect())
1011
- }
1012
-
1013
- const getBodyOffset = () => {
1014
- const { body } = document;
1015
- const style = getComputedStyle(body);
1016
-
1017
- return (
1018
- body.offsetHeight +
1019
- parseInt(style.marginTop, BASE) +
1020
- parseInt(style.marginBottom, BASE)
1021
- )
1022
- };
1023
-
1024
- const getHeight = {
1025
- enabled: () => calculateHeight,
1026
- getOffset: () => offsetHeight,
1027
- type: 'height',
1028
- auto: () => getAutoSize(getHeight, false),
1029
- autoOverflow: () => getAutoSize(getHeight, true),
1030
- bodyOffset: getBodyOffset,
1031
- bodyScroll: () => document.body.scrollHeight,
1032
- offset: () => getHeight.bodyOffset(), // Backwards compatibility
1033
- custom: () => customCalcMethods.height(),
1034
- documentElementOffset: () => document.documentElement.offsetHeight,
1035
- documentElementScroll: () => document.documentElement.scrollHeight,
1036
- documentElementBoundingClientRect: () =>
1037
- document.documentElement.getBoundingClientRect().bottom,
1038
- max: () => Math.max(...getAllMeasurements(getHeight)),
1039
- min: () => Math.min(...getAllMeasurements(getHeight)),
1040
- grow: () => getHeight.max(),
1041
- lowestElement: () => getMaxElement('bottom'),
1042
- taggedElement: () => getMaxElement('bottom'),
1043
- };
1044
-
1045
- const getWidth = {
1046
- enabled: () => calculateWidth,
1047
- getOffset: () => offsetWidth,
1048
- type: 'width',
1049
- auto: () => getAutoSize(getWidth, false),
1050
- autoOverflow: () => getAutoSize(getWidth, true),
1051
- bodyScroll: () => document.body.scrollWidth,
1052
- bodyOffset: () => document.body.offsetWidth,
1053
- custom: () => customCalcMethods.width(),
1054
- documentElementScroll: () => document.documentElement.scrollWidth,
1055
- documentElementOffset: () => document.documentElement.offsetWidth,
1056
- documentElementBoundingClientRect: () =>
1057
- document.documentElement.getBoundingClientRect().right,
1058
- max: () => Math.max(...getAllMeasurements(getWidth)),
1059
- min: () => Math.min(...getAllMeasurements(getWidth)),
1060
- rightMostElement: () => getMaxElement('right'),
1061
- scroll: () =>
1062
- Math.max(getWidth.bodyScroll(), getWidth.documentElementScroll()),
1063
- taggedElement: () => getMaxElement('right'),
1064
- };
1065
-
1066
- function sizeIFrame(
1067
- triggerEvent,
1068
- triggerEventDesc,
1069
- customHeight,
1070
- customWidth,
1071
- msg,
1072
- ) {
1073
- function resizeIFrame() {
1074
- height = currentHeight;
1075
- width = currentWidth;
1076
- sendMsg(height, width, triggerEvent, msg);
1077
- }
1078
-
1079
- function isSizeChangeDetected() {
1080
- const checkTolerance = (a, b) => !(Math.abs(a - b) <= tolerance);
1081
-
1082
- // currentHeight = Math.ceil(
1083
- // undefined === customHeight ? getHeight[heightCalcMode]() : customHeight,
1084
- // )
1085
-
1086
- // currentWidth = Math.ceil(
1087
- // undefined === customWidth ? getWidth[widthCalcMode]() : customWidth,
1088
- // )
1089
-
1090
- currentHeight =
1091
- undefined === customHeight ? getHeight[heightCalcMode]() : customHeight;
1092
- currentWidth =
1093
- undefined === customWidth ? getWidth[widthCalcMode]() : customWidth;
1094
-
1095
- return (
1096
- (calculateHeight && checkTolerance(height, currentHeight)) ||
1097
- (calculateWidth && checkTolerance(width, currentWidth))
1098
- )
1099
- }
1100
-
1101
- const isForceResizableEvent = () => !(triggerEvent in { init: 1, size: 1 });
1102
-
1103
- const isForceResizableCalcMode = () =>
1104
- (calculateHeight && heightCalcMode in resetRequiredMethods) ||
1105
- (calculateWidth && widthCalcMode in resetRequiredMethods);
1106
-
1107
- function checkDownSizing() {
1108
- if (isForceResizableEvent() && isForceResizableCalcMode()) {
1109
- resetIFrame();
1110
- }
1111
- }
1112
-
1113
- let currentHeight;
1114
- let currentWidth;
1115
-
1116
- if (isSizeChangeDetected() || triggerEvent === 'init') {
1117
- lockTrigger();
1118
- resizeIFrame();
1119
- } else {
1120
- checkDownSizing();
1121
- }
1122
- }
1123
-
1124
- function sendSize(
1125
- triggerEvent,
1126
- triggerEventDesc,
1127
- customHeight,
1128
- customWidth,
1129
- msg,
1130
- ) {
1131
- if (document.hidden) {
1132
- // Currently only correctly supported in firefox
1133
- // This is checked again on the parent page
1134
- return
1135
- }
1136
-
1137
- sizeIFrame(triggerEvent, triggerEventDesc, customHeight, customWidth, msg);
1138
- }
1139
-
1140
- function lockTrigger() {
1141
- if (triggerLocked) return
1142
-
1143
- triggerLocked = true;
1144
-
1145
- requestAnimationFrame(() => {
1146
- triggerLocked = false;
1147
- });
1148
- }
1149
-
1150
- function triggerReset(triggerEvent) {
1151
- height = getHeight[heightCalcMode]();
1152
- width = getWidth[widthCalcMode]();
1153
-
1154
- sendMsg(height, width, triggerEvent);
1155
- }
1156
-
1157
- function resetIFrame(triggerEventDesc) {
1158
- const hcm = heightCalcMode;
1159
- heightCalcMode = heightCalcModeDefault;
1160
- lockTrigger();
1161
- triggerReset('reset');
1162
-
1163
- heightCalcMode = hcm;
1164
- }
1165
-
1166
- function sendMsg(height, width, triggerEvent, msg, targetOrigin) {
1167
- if (mode < 0) return
1168
-
1169
- function setTargetOrigin() {
1170
- if (undefined === targetOrigin) {
1171
- targetOrigin = targetOriginDefault;
1172
- return
1173
- }
1174
- }
1175
-
1176
- function sendToParent() {
1177
- const size = `${height + (offsetHeight || 0)}:${width + (offsetWidth || 0)}`;
1178
- const message = `${myID}:${size}:${triggerEvent}${undefined === msg ? '' : `:${msg}`}`;
1179
-
1180
- if (sameDomain) {
1181
- window.parent.iframeParentListener(msgID + message);
1182
- return
1183
- }
1184
-
1185
- target.postMessage(msgID + message, targetOrigin);
1186
- }
1187
-
1188
- setTargetOrigin();
1189
- sendToParent();
1190
- }
1191
-
1192
- function receiver(event) {
1193
- const processRequestFromParent = {
1194
- init: function initFromParent() {
1195
- initMsg = event.data;
1196
- target = event.source;
1197
-
1198
- init();
1199
- firstRun = false;
1200
- setTimeout(() => {
1201
- initLock = false;
1202
- }, eventCancelTimer);
1203
- },
1204
-
1205
- reset() {
1206
- if (initLock) {
1207
- return
1208
- }
1209
- triggerReset('resetPage');
1210
- },
1211
-
1212
- resize() {
1213
- sendSize('resizeParent', 'Parent window requested size check');
1214
- },
1215
-
1216
- moveToAnchor() {
1217
- inPageLinks.findTarget(getData());
1218
- },
1219
-
1220
- inPageLink() {
1221
- this.moveToAnchor();
1222
- }, // Backward compatibility
1223
-
1224
- pageInfo() {
1225
- const msgBody = getData();
1226
- if (onPageInfo) {
1227
- onPageInfo(JSON.parse(msgBody));
1228
- } else {
1229
- // not expected, so cancel more messages
1230
- sendMsg(0, 0, 'pageInfoStop');
1231
- }
1232
- },
1233
-
1234
- parentInfo() {
1235
- const msgBody = getData();
1236
- if (onParentInfo) {
1237
- onParentInfo(Object.freeze(JSON.parse(msgBody)));
1238
- } else {
1239
- // not expected, so cancel more messages
1240
- sendMsg(0, 0, 'parentInfoStop');
1241
- }
1242
- },
1243
-
1244
- message() {
1245
- const msgBody = getData();
1246
- // eslint-disable-next-line sonarjs/no-extra-arguments
1247
- onMessage(JSON.parse(msgBody));
1248
- },
1249
- };
1250
-
1251
- const isMessageForUs = () => msgID === `${event.data}`.slice(0, msgIdLen);
1252
-
1253
- const getMessageType = () => event.data.split(']')[1].split(':')[0];
1254
-
1255
- const getData = () => event.data.slice(event.data.indexOf(':') + 1);
1256
-
1257
- const isMiddleTier = () =>
1258
- 'iframeResize' in window ||
1259
- (window.jQuery !== undefined && '' in window.jQuery.prototype);
1260
-
1261
- // Test if this message is from a child below us. This is an ugly test, however, updating
1262
- // the message format would break backwards compatibility.
1263
- const isInitMsg = () => event.data.split(':')[2] in { true: 1, false: 1 };
1264
-
1265
- function callFromParent() {
1266
- const messageType = getMessageType();
1267
-
1268
- if (messageType in processRequestFromParent) {
1269
- processRequestFromParent[messageType]();
1270
- return
1271
- }
1272
-
1273
- if (!isMiddleTier() && !isInitMsg()) {
1274
- warn(`Unexpected message (${event.data})`);
1275
- }
1276
- }
1277
-
1278
- function processMessage() {
1279
- if (firstRun === false) {
1280
- callFromParent();
1281
- return
1282
- }
1283
-
1284
- if (isInitMsg()) {
1285
- processRequestFromParent.init();
1286
- return
1287
- }
1288
- }
1289
-
1290
- if (isMessageForUs()) {
1291
- processMessage();
1292
- }
1293
- }
1294
-
1295
- // Normally the parent kicks things off when it detects the iFrame has loaded.
1296
- // If this script is async-loaded, then tell parent page to retry init.
1297
- function chkLateLoaded() {
1298
- if (document.readyState !== 'loading') {
1299
- window.parent.postMessage('[iFrameResizerChild]Ready', '*');
1300
- }
1301
- }
1302
-
1303
- // Don't run for server side render
1304
- if (typeof window !== 'undefined') {
1305
- window.iframeChildListener = (data) => receiver({ data, sameDomain: true });
1306
- addEventListener(window, 'message', receiver);
1307
- addEventListener(window, 'readystatechange', chkLateLoaded);
1308
- chkLateLoaded();
1309
- }
1310
-
1311
- }));
20
+ !function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="5.1.1",t=10,n="data-iframe-size",o=(e,t,n,o)=>e.addEventListener(t,n,o||!1),i=(e,t,n)=>e.removeEventListener(t,n,!1),r=["<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</>."];Object.fromEntries(["2cgs7fdf4xb","1c9ctcccr4z","1q2pc4eebgb","ueokt0969w","w2zxchhgqz","1umuxblj2e5"].map(((e,t)=>[e,Math.max(0,t-1)])));const a=e=>(e=>e.replaceAll(/[A-Za-z]/g,(e=>String.fromCodePoint((e<="Z"?90:122)>=(e=e.codePointAt(0)+19)?e:e-26))))(r[e]),l={contentVisibilityAuto:!0,opacityProperty:!0,visibilityProperty:!0},c={height:()=>(se("Custom height calculation function not defined"),Le.auto()),width:()=>(se("Custom width calculation function not defined"),De.auto())},s={bodyOffset:1,bodyScroll:1,offset:1,documentElementOffset:1,documentElementScroll:1,documentElementBoundingClientRect:1,max:1,min:1,grow:1,lowestElement:1},u=128,d={},m="checkVisibility"in window,f="auto",p="[iFrameSizer]",h=p.length,y={max:1,min:1,bodyScroll:1,documentElementScroll:1},g=["body"],v="scroll";let b,w,z=!0,S="",$=0,j="",E=null,P="",O=!0,M=!1,A=null,T=!0,C=!1,I=1,k=f,x=!0,N="",R={},B=!0,q=!1,L=0,D=!1,H="",W="child",U=null,F=!1,V="",J=window.parent,Z="*",Q=0,X=!1,Y="",G=1,K=v,_=window,ee=()=>{se("onMessage function not defined")},te=()=>{},ne=null,oe=null;const ie=e=>""!=`${e}`&&void 0!==e;function re(e){switch(!0){case!ie(e):return"";case ie(e.id):return`${e.nodeName.toUpperCase()}#${e.id}`;case ie(e.name):return`${e.nodeName.toUpperCase()} (${e.name})`;default:return e.nodeName.toUpperCase()+(ie(e.className)?`.${e.className}`:"")}}function ae(e,t=30){const n=e?.outerHTML?.toString();return n?n.length<t?n:`${n.slice(0,t).replaceAll("\n"," ")}...`:e}const le=(...e)=>[`[iframe-resizer][${H}]`,...e].join(" "),ce=(...e)=>console?.info(le(...e)),se=(...e)=>console?.warn(le(...e)),ue=(...e)=>console?.warn((e=>t=>window.chrome?e(t.replaceAll("<br>","\n").replaceAll("<rb>","").replaceAll("</>","").replaceAll("<b>","").replaceAll("<i>","").replaceAll("<u>","")):e(t.replaceAll("<br>","\n").replaceAll(/<[/a-z]+>/gi,"")))(le)(...e)),de=e=>ue(e);function me(){!function(){try{F="iframeParentListener"in window.parent}catch(e){}}(),function(){const e=e=>"true"===e,t=N.slice(h).split(":");H=t[0],$=void 0===t[1]?$:Number(t[1]),M=void 0===t[2]?M:e(t[2]),q=void 0===t[3]?q:e(t[3]),z=void 0===t[6]?z:e(t[6]),j=t[7],k=void 0===t[8]?k:t[8],S=t[9],P=t[10],Q=void 0===t[11]?Q:Number(t[11]),R.enable=void 0!==t[12]&&e(t[12]),W=void 0===t[13]?W:t[13],K=void 0===t[14]?K:t[14],D=void 0===t[15]?D:e(t[15]),b=void 0===t[16]?b:Number(t[16]),w=void 0===t[17]?w:Number(t[17]),O=void 0===t[18]?O:e(t[18]),t[19],Y=t[20]||Y,L=void 0===t[21]?L:Number(t[21])}(),function(){function e(){const e=window.iframeResizer||window.iFrameResizer;ee=e?.onMessage||ee,te=e?.onReady||te,"number"==typeof e?.offset&&(O&&(b=e?.offset),M&&(w=e?.offset)),Object.prototype.hasOwnProperty.call(e,"sizeSelector")&&(V=e.sizeSelector),Z=e?.targetOrigin||Z,k=e?.heightCalculationMethod||k,K=e?.widthCalculationMethod||K}function t(e,t){return"function"==typeof e&&(c[t]=e,e="custom"),e}if(1===L)return;"iFrameResizer"in window&&Object===window.iFrameResizer.constructor&&(e(),k=t(k,"height"),K=t(K,"width"))}(),function(){void 0===j&&(j=`${$}px`);fe("margin",function(e,t){t.includes("-")&&(se(`Negative CSS value ignored for ${e}`),t="");return t}("margin",j))}(),fe("background",S),fe("padding",P),function(){const e=document.createElement("div");e.style.clear="both",e.style.display="block",e.style.height="0",document.body.append(e)}(),function(){const e=e=>e.style.setProperty("height","auto","important");e(document.documentElement),e(document.body)}(),pe(),L<0?de(`${a(L+2)}${a(2)}`):Y.codePointAt(0)>4||L<2&&de(a(3)),function(){if(!Y||""===Y||"false"===Y)return void ue("<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/<u> for more details.\n");Y!==e&&ue(`<rb>Version mismatch</>\n\nThe parent and child pages are running different versions of <i>iframe resizer</>.\n\nParent page: ${Y} - Child page: ${e}.\n`)}(),be(),we(),function(){let e=!1;const t=t=>document.querySelectorAll(`[${t}]`).forEach((o=>{e=!0,o.removeAttribute(t),o.setAttribute(n,null)}));t("data-iframe-height"),t("data-iframe-width"),e&&ue("<rb>Deprecated Attributes</>\n \nThe <b>data-iframe-height</> and <b>data-iframe-width</> attributes have been deprecated and replaced with the single <b>data-iframe-size</> attribute. Use of the old attributes will be removed in a future version of <i>iframe-resizer</>.")}(),document.querySelectorAll(`[${n}]`).length>0&&("auto"===k&&(k="autoOverflow"),"auto"===K&&(K="autoOverflow")),ge(),function(){if(1===L)return;_.parentIframe=Object.freeze({autoResize:e=>(!0===e&&!1===z?(z=!0,ze()):!1===e&&!0===z&&(z=!1,ye("remove"),U?.disconnect(),E?.disconnect()),Je(0,0,"autoResize",JSON.stringify(z)),z),close(){Je(0,0,"close")},getId:()=>H,getPageInfo(e){if("function"==typeof e)return ne=e,Je(0,0,"pageInfo"),void ue("<rb>Deprecated Method</>\n \nThe <b>getPageInfo()</> method has been deprecated and replaced with <b>getParentProps()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\n");ne=null,Je(0,0,"pageInfoStop")},getParentProps(e){if("function"!=typeof e)throw new TypeError("parentIFrame.getParentProps(callback) callback not a function");return oe=e,Je(0,0,"parentInfo"),()=>{oe=null,Je(0,0,"parentInfoStop")}},getParentProperties(e){ue("<rb>Renamed Method</>\n \nThe <b>getParentProperties()</> method has been renamed <b>getParentProps()</>. Use of the old name will be removed in a future version of <i>iframe-resizer</>.\n"),this.getParentProps(e)},moveToAnchor(e){R.findTarget(e)},reset(){Ve()},scrollBy(e,t){Je(t,e,"scrollBy")},scrollTo(e,t){Je(t,e,"scrollTo")},scrollToOffset(e,t){Je(t,e,"scrollToOffset")},sendMessage(e,t){Je(0,0,"message",JSON.stringify(e),t)},setHeightCalculationMethod(e){k=e,be()},setWidthCalculationMethod(e){K=e,we()},setTargetOrigin(e){Z=e},resize(e,t){We("size",`parentIFrame.size(${`${e||""}${t?`,${t}`:""}`})`,e,t)},size(e,t){ue("<rb>Deprecated Method</>\n \nThe <b>size()</> method has been deprecated and replaced with <b>resize()</>. Use of this method will be removed in a future version of <i>iframe-resizer</>.\n"),this.resize(e,t)}}),_.parentIFrame=_.parentIframe}(),function(){if(!0!==D)return;function e(e){Je(0,0,e.type,`${e.screenY}:${e.screenX}`)}function t(t,n){o(window.document,t,e)}t("mouseenter"),t("mouseleave")}(),ze(),R=function(){const e=()=>({x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop});function n(n){const o=n.getBoundingClientRect(),i=e();return{x:parseInt(o.left,t)+parseInt(i.x,t),y:parseInt(o.top,t)+parseInt(i.y,t)}}function i(e){function t(e){const t=n(e);Je(t.y,t.x,"scrollToOffset")}const o=e.split("#")[1]||e,i=decodeURIComponent(o),r=document.getElementById(i)||document.getElementsByName(i)[0];void 0===r?Je(0,0,"inPageLink",`#${o}`):t(r)}function r(){const{hash:e,href:t}=window.location;""!==e&&"#"!==e&&i(t)}function a(){function e(e){function t(e){e.preventDefault(),i(this.getAttribute("href"))}"#"!==e.getAttribute("href")&&o(e,"click",t)}document.querySelectorAll('a[href^="#"]').forEach(e)}function l(){o(window,"hashchange",r)}function c(){setTimeout(r,u)}function s(){a(),l(),c()}R.enable&&(1===L?ue("In page linking requires a Professional or Business license. Please see https://iframe-resizer.com/pricing for more details."):s());return{findTarget:i}}(),We("init","Init message from host page",void 0,void 0,e),document.title&&""!==document.title&&Je(0,0,"title",document.title),te(),B=!1}function fe(e,t){void 0!==t&&""!==t&&"null"!==t&&document.body.style.setProperty(e,t)}function pe(){""!==V&&document.querySelectorAll(V).forEach((e=>{e.dataset.iframeSize=!0}))}function he(e){({add(t){function n(){We(e.eventName,e.eventType)}d[t]=n,o(window,t,n,{passive:!0})},remove(e){const t=d[e];delete d[e],i(window,e,t)}})[e.method](e.eventName)}function ye(e){he({method:e,eventType:"After Print",eventName:"afterprint"}),he({method:e,eventType:"Before Print",eventName:"beforeprint"}),he({method:e,eventType:"Ready State Change",eventName:"readystatechange"})}function ge(){const e=document.querySelectorAll(`[${n}]`);C=e.length>0,A=C?e:ke(document)()}function ve(e,t,n,o){return t!==e&&(e in n||(se(`${e} is not a valid option for ${o}CalculationMethod.`),e=t),e in s&&ue(`<rb>Deprecated ${o}CalculationMethod (${e})</>\n\nThis version of <i>iframe-resizer</> can auto detect the most suitable ${o} calculation method. It is recommended that you remove this option.`)),e}function be(){k=ve(k,f,Le,"height")}function we(){K=ve(K,v,De,"width")}function ze(){!0===z&&(ye("add"),E=function(){function e(e){e.forEach(Me),pe(),ge()}function t(){const t=new window.MutationObserver(e),n=document.querySelector("body"),o={attributes:!1,attributeOldValue:!1,characterData:!1,characterDataOldValue:!1,childList:!0,subtree:!0};return t.observe(n,o),t}const n=t();return{disconnect(){n.disconnect()}}}(),U=new ResizeObserver($e),Oe(window.document))}let Se;function $e(e){if(!Array.isArray(e)||0===e.length)return;const t=e[0].target;Se=()=>We("resizeObserver",`Resize Observed: ${re(t)}`),setTimeout((()=>{Se&&Se(),Se=void 0}),0)}const je=e=>{const t=getComputedStyle(e);return""!==t?.position&&"static"!==t?.position},Ee=()=>[...ke(document)()].filter(je);function Pe(e){e&&U.observe(e)}function Oe(e){[...Ee(),...g.flatMap((t=>e.querySelector(t)))].forEach(Pe)}function Me(e){"childList"===e.type&&Oe(e.target)}const Ae=new WeakSet;Ae.add(document.documentElement),Ae.add(document.body);let Te=0;function Ce(e){const t=(n=e).charAt(0).toUpperCase()+n.slice(1);var n;let o,i=0,r=A.length,a=0,c=performance.now();var s;A.forEach((t=>{C||!m||t.checkVisibility(l)?(i=t.getBoundingClientRect()[e]+parseFloat(getComputedStyle(t).getPropertyValue(`margin-${e}`)),i>a&&(a=i,o=t)):r-=1})),c=performance.now()-c,r>1&&(s=o,Ae.has(s)||(Ae.add(s),ce(`\nHeight calculated from: ${re(s)} (${ae(s)})`)));const u=`\nParsed ${r} element${r=""} in ${c.toPrecision(3)}ms\n${t} ${C?"tagged ":""}element found at: ${a}px\nPosition calculated from HTML element: ${re(o)} (${ae(o,100)})`;if(c<1.1||B||C);else{if(Te>c)return a;Te=c,ue(`<rb>Performance Warning</>\n\nCalculating the page size took an excessive amount of time. To improve performance add the <b>data-iframe-size</> attribute to the ${e} most element on the page.\n\nMore info: https://iframe-resizer.com/performance.\n${u}`)}return a}const Ie=e=>[e.bodyOffset(),e.bodyScroll(),e.documentElementOffset(),e.documentElementScroll(),e.documentElementBoundingClientRect()],ke=e=>()=>e.querySelectorAll("* :not(head):not(meta):not(base):not(title):not(script):not(link):not(style):not(map):not(area):not(option):not(optgroup):not(template):not(track):not(wbr):not(nobr)");let xe=!1;function Ne({ceilBoundingSize:e,dimension:t,getDimension:n,isHeight:o,scrollSize:i}){if(!xe)return xe=!0,n.taggedElement();const r=o?"bottom":"right";return ue(`<rb>Detected content overflowing html element</>\n \nThis causes <i>iframe-resizer</> to fall back to checking the position of every element on the page in order to calculate the correct dimensions of the iframe. Inspecting the size, ${r} margin, and position of every visible HTML element will have a performance impact on more complex pages. \n\nTo fix this issue, and remove this warning, you can either ensure the content of the page does not overflow the <b><HTML></> element or alternatively you can add the attribute <b>data-iframe-size</> to the elements on the page that you want <i>iframe-resizer</> to use when calculating the dimensions of the iframe. \n \nWhen present the ${r} margin of the ${o?"lowest":"right most"} element with a <b>data-iframe-size</> attribute will be used to set the ${t} of the iframe.\n \n(Page size: ${i} > document size: ${e})`),o?k="autoOverflow":K="autoOverflow",n.taggedElement()}const Re={height:0,width:0},Be={height:0,width:0};function qe(e,t){function n(){return Be[i]=r,Re[i]=c,r}const o=e===Le,i=o?"height":"width",r=e.documentElementBoundingClientRect(),a=Math.ceil(r),l=Math.floor(r),c=(e=>e.documentElementScroll()+Math.max(0,e.getOffset()))(e);switch(!0){case!e.enabled():return c;case!t&&0===Be[i]&&0===Re[i]:if(e.taggedElement(!0)<=a)return n();break;case X&&r===Be[i]&&c===Re[i]:return Math.max(r,c);case 0===r:return c;case!t&&r!==Be[i]&&c<=Re[i]:return n();case!o:return t?e.taggedElement():Ne({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c});case!t&&r<Be[i]:case c===l||c===a:case r>c:return n();case!t:return Ne({ceilBoundingSize:a,dimension:i,getDimension:e,isHeight:o,scrollSize:c})}return Math.max(e.taggedElement(),n())}const Le={enabled:()=>O,getOffset:()=>b,type:"height",auto:()=>qe(Le,!1),autoOverflow:()=>qe(Le,!0),bodyOffset:()=>{const{body:e}=document,n=getComputedStyle(e);return e.offsetHeight+parseInt(n.marginTop,t)+parseInt(n.marginBottom,t)},bodyScroll:()=>document.body.scrollHeight,offset:()=>Le.bodyOffset(),custom:()=>c.height(),documentElementOffset:()=>document.documentElement.offsetHeight,documentElementScroll:()=>document.documentElement.scrollHeight,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().bottom,max:()=>Math.max(...Ie(Le)),min:()=>Math.min(...Ie(Le)),grow:()=>Le.max(),lowestElement:()=>Ce("bottom"),taggedElement:()=>Ce("bottom")},De={enabled:()=>M,getOffset:()=>w,type:"width",auto:()=>qe(De,!1),autoOverflow:()=>qe(De,!0),bodyScroll:()=>document.body.scrollWidth,bodyOffset:()=>document.body.offsetWidth,custom:()=>c.width(),documentElementScroll:()=>document.documentElement.scrollWidth,documentElementOffset:()=>document.documentElement.offsetWidth,documentElementBoundingClientRect:()=>document.documentElement.getBoundingClientRect().right,max:()=>Math.max(...Ie(De)),min:()=>Math.min(...Ie(De)),rightMostElement:()=>Ce("right"),scroll:()=>Math.max(De.bodyScroll(),De.documentElementScroll()),taggedElement:()=>Ce("right")};function He(e,t,n,o,i){let r,a;!function(){const e=(e,t)=>!(Math.abs(e-t)<=Q);return r=void 0===n?Le[k]():n,a=void 0===o?De[K]():o,O&&e(I,r)||M&&e(G,a)}()&&"init"!==e?!(e in{init:1,size:1})&&(O&&k in y||M&&K in y)&&Ve():(Ue(),I=r,G=a,Je(I,G,e,i))}function We(e,t,n,o,i){document.hidden||He(e,0,n,o,i)}function Ue(){X||(X=!0,requestAnimationFrame((()=>{X=!1})))}function Fe(e){I=Le[k](),G=De[K](),Je(I,G,e)}function Ve(e){const t=k;k=f,Ue(),Fe("reset"),k=t}function Je(e,t,n,o,i){L<-1||(void 0!==i||(i=Z),function(){const r=`${H}:${`${e+(b||0)}:${t+(w||0)}`}:${n}${void 0===o?"":`:${o}`}`;F?window.parent.iframeParentListener(p+r):J.postMessage(p+r,i)}())}function Ze(e){const t={init:function(){N=e.data,J=e.source,me(),T=!1,setTimeout((()=>{x=!1}),u)},reset(){x||Fe("resetPage")},resize(){We("resizeParent")},moveToAnchor(){R.findTarget(o())},inPageLink(){this.moveToAnchor()},pageInfo(){const e=o();ne?ne(JSON.parse(e)):Je(0,0,"pageInfoStop")},parentInfo(){const e=o();oe?oe(Object.freeze(JSON.parse(e))):Je(0,0,"parentInfoStop")},message(){const e=o();ee(JSON.parse(e))}},n=()=>e.data.split("]")[1].split(":")[0],o=()=>e.data.slice(e.data.indexOf(":")+1),i=()=>"iframeResize"in window||void 0!==window.jQuery&&""in window.jQuery.prototype,r=()=>e.data.split(":")[2]in{true:1,false:1};p===`${e.data}`.slice(0,h)&&(!1!==T?r()&&t.init():function(){const o=n();o in t?t[o]():i()||r()||se(`Unexpected message (${e.data})`)}())}function Qe(){"loading"!==document.readyState&&window.parent.postMessage("[iFrameResizerChild]Ready","*")}"undefined"!=typeof window&&(window.iframeChildListener=e=>Ze({data:e,sameDomain:!0}),o(window,"message",Ze),o(window,"readystatechange",Qe),Qe())}));