@iframe-resizer/core 6.0.0-beta.0 → 6.0.0-beta.10

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.esm.js CHANGED
@@ -1,1002 +1,21 @@
1
- import Je, { NORMAL as Ye, HIGHLIGHT as l, FOREGROUND as v } from "auto-console-group";
2
- const C = "6.0.0-beta.0", pe = "iframeResizer", S = ":", Xe = "[iFrameResizerChild]Ready", de = "autoResize", Ke = "beforeUnload", Qe = "close", et = "inPageLink", $ = "init", he = "iframeReady", tt = "lazy", W = "load", R = "message", nt = "mouseenter", ot = "mouseleave", ge = "onload", me = "pageInfo", be = "parentInfo", it = "pageInfoStop", rt = "parentInfoStop", H = "reset", Z = "resize", st = "scrollBy", ct = "scrollTo", at = "scrollToOffset", lt = "title", Q = 1, ut = "height", ft = "width", pt = "offset", dt = "offsetSize", ee = "scroll", P = `
3
- `, ht = "hidden", gt = "child", D = "parent", J = "string", mt = "number", ye = "object", ve = "function", G = "auto", bt = "font-weight: bold;", we = "none", ze = "both", F = "vertical", Ee = "horizontal", yt = R.length, x = "[iFrameSizer]", U = x.length, vt = Object.freeze({
4
- max: 1,
5
- scroll: 1,
6
- bodyScroll: 1,
7
- documentElementScroll: 1
8
- }), te = Object.freeze({
9
- [ge]: 1,
10
- [$]: 1,
11
- [he]: 1
12
- }), V = "expanded", Y = "collapsed", wt = Object.freeze({
13
- [V]: 1,
14
- [Y]: 1
15
- }), Oe = "Use of the old name will be removed in a future version of <i>iframe-resizer</>.", Te = (e) => typeof e === ye && e !== null, X = (e) => typeof e === J;
16
- function zt(e) {
17
- if (!Te(e)) return !1;
18
- try {
19
- return e.tagName === "IFRAME" || e instanceof HTMLIFrameElement;
20
- } catch {
21
- return !1;
22
- }
23
- }
24
- const Et = (e, ...t) => setTimeout(() => e(...t), 0), Ot = (e) => {
25
- let t = !1;
26
- return function(...n) {
27
- return t ? void 0 : (t = !0, e.apply(this, n));
28
- };
29
- }, Tt = (e, t) => Object.prototype.hasOwnProperty.call(e, t), k = (e, t) => Object.hasOwn ? Object.hasOwn(e, t) : Tt(e, t), It = (e) => e, Mt = (e) => e.charAt(0).toUpperCase() + e.slice(1), $t = (e) => (
30
- // eslint-disable-next-line no-underscore-dangle
31
- e?.__esModule ? e.default : e
32
- ), St = (e, t, n) => {
33
- if (typeof e !== t)
34
- throw new TypeError(`${n} is not a ${Mt(t)}`);
35
- }, Rt = (e) => (t, n = "renamed to") => (o, r, s = "", c = "") => e(
36
- c,
37
- `<rb>Deprecated ${t}(${o.replace("()", "")})</>
38
-
39
- The <b>${o}</> ${t.toLowerCase()} has been ${n} <b>${r}</>. ${s}Use of the old ${t.toLowerCase()} will be removed in a future version of <i>iframe-resizer</>.`
40
- ), Ie = {
41
- br: `
42
- `,
43
- rb: "\x1B[31;1m",
44
- // red bold
45
- bb: "\x1B[34;1m",
46
- // blue bold
47
- b: "\x1B[1m",
48
- // bold
49
- i: "\x1B[3m",
50
- // italic
51
- u: "\x1B[4m",
52
- // underline
53
- "/": "\x1B[m"
54
- // reset
55
- }, kt = Object.keys(Ie), jt = new RegExp(`<(${kt.join("|")})>`, "gi"), Lt = (e, t) => Ie[t] ?? "", At = (e) => e.replace(jt, Lt), Pt = (e) => e.replaceAll("<br>", P).replaceAll(/<\/?[^>]+>/gi, ""), Me = (e) => (t) => e(
56
- X(t) ? window.chrome ? At(t) : Pt(t) : t
57
- ), i = {}, $e = $t(Je);
58
- let K = !0;
59
- const Nt = $e({
60
- expand: !1,
61
- label: D
62
- }), Ct = (e) => window.top === window.self ? `parent(${e})` : `nested parent(${e})`, xt = (e) => i[e] ? i[e].log : K;
63
- function _t({ enabled: e, expand: t, iframeId: n }) {
64
- const o = $e({
65
- expand: t,
66
- label: Ct(n)
67
- });
68
- K = e, i[n] || (i[n] = {
69
- console: o
70
- });
71
- }
72
- const I = (e) => (t, ...n) => i[t] ? i[t].console[e](...n) : Nt[e](...n), Se = (e) => (t, ...n) => xt(t) === !0 ? I(e)(t, ...n) : null, u = Se("log"), m = u, Ft = Se("debug"), M = I("warn"), Bt = I("error"), y = I("event"), Wt = I("purge"), Ht = I("endAutoGroup"), Re = I("errorBoundary");
73
- function Dt(e, t) {
74
- queueMicrotask(
75
- () => (
76
- // eslint-disable-next-line no-console
77
- console.info(
78
- `%ciframe-resizer ${e}`,
79
- K || t < 1 ? bt : Ye
80
- )
81
- )
82
- );
83
- }
84
- const Gt = (e) => (...t) => [`${pe}(${e})`, ...t].join(" "), Ut = Me(It), b = (e, ...t) => i[e] ? i[e].console.warn(...t.map(Ut)) : queueMicrotask(() => {
85
- const n = Me(Gt(e));
86
- console?.warn(...t.map(n));
87
- }), Vt = Rt(b), qt = Vt("Option"), Zt = (e) => {
88
- typeof i[e.id].onInit === ve && (qt("init()", "onReady()", "", e.id), i[e.id].onInit(e));
89
- }, _ = Object.freeze({
90
- autoResize: !0,
91
- bodyBackground: null,
92
- bodyMargin: null,
93
- bodyPadding: null,
94
- checkOrigin: !0,
95
- direction: F,
96
- firstRun: !0,
97
- inPageLinks: !1,
98
- heightCalculationMethod: G,
99
- id: "iFrameResizer",
100
- // TODO: v6 change to 'iframeResizer'
101
- log: !1,
102
- logExpand: !1,
103
- license: void 0,
104
- mouseEvents: !0,
105
- offsetHeight: null,
106
- offsetWidth: null,
107
- postMessageTarget: null,
108
- sameDomain: !1,
109
- scrolling: !1,
110
- sizeHeight: !0,
111
- // sizeSelector: '',
112
- sizeWidth: !1,
113
- tolerance: 0,
114
- waitForLoad: !1,
115
- warningTimeout: 5e3,
116
- widthCalculationMethod: G,
117
- onBeforeClose: () => !0,
118
- onAfterClose() {
119
- },
120
- onInit: !1,
121
- onMessage: null,
122
- onMouseEnter() {
123
- },
124
- onMouseLeave() {
125
- },
126
- onReady: Zt,
127
- onResized() {
128
- },
129
- onScroll: () => !0
130
- });
131
- let ne = 0;
132
- function Jt(e) {
133
- const t = e?.id || _.id + ne++;
134
- return document.getElementById(t) === null ? t : `${t}${ne++}`;
135
- }
136
- function Yt(e, t) {
137
- let { id: n } = e;
138
- if (n && !X(n))
139
- throw new TypeError("Invalid id for iFrame. Expected String");
140
- return (!n || n === "") && (n = Jt(t), e.id = n, y(n, "assignId"), u(n, `Added missing iframe ID: ${n} (${e.src})`)), n;
141
- }
142
- function Xt(e) {
143
- const { search: t } = window.location;
144
- t.includes("ifrlog") && (e.log = Y, e.logExpand = t.includes("ifrlog=expanded"));
145
- }
146
- const j = (e, t, n, o) => e.addEventListener(t, n, o || !1), oe = (e, t, n) => e.removeEventListener(t, n, !1), Kt = (e) => e.split(S).filter((t, n) => n !== 19).join(S);
147
- function Qt(e, t, n) {
148
- function o(f) {
149
- const p = e in te ? Kt(t) : t;
150
- m(n, f, l, v, l), m(n, `Message data: %c${p}`, l);
151
- }
152
- const { iframe: r, postMessageTarget: s, sameOrigin: c, targetOrigin: a } = i[n];
153
- if (c)
154
- try {
155
- r.contentWindow.iframeChildListener(x + t), o(`Sending message to iframe %c${n}%c via same origin%c`);
156
- return;
157
- } catch {
158
- e in te ? (i[n].sameOrigin = !1, u(n, "New iframe does not support same origin")) : M(n, "Same origin messaging failed, falling back to postMessage");
159
- }
160
- o(
161
- `Sending message to iframe: %c${n}%c targetOrigin: %c${a}`
162
- ), s.postMessage(x + t, a);
163
- }
164
- function O(e, t, n) {
165
- if (y(n, e), !i[n]?.postMessageTarget) {
166
- M(n, "Iframe not found");
167
- return;
168
- }
169
- Qt(e, t, n);
170
- }
171
- const en = (e, t) => Object.values(i).filter(({ autoResize: n, firstRun: o }) => n && !o).forEach(({ iframe: n }) => O(e, t, n.id));
172
- function tn() {
173
- document.hidden !== !0 && en("tabVisible", Z);
174
- }
175
- function nn(e) {
176
- if (e.boxSizing !== "border-box") return 0;
177
- const t = e.paddingTop ? parseInt(e.paddingTop, 10) : 0, n = e.paddingBottom ? parseInt(e.paddingBottom, 10) : 0;
178
- return t + n;
179
- }
180
- function on(e) {
181
- if (e.boxSizing !== "border-box") return 0;
182
- const t = e.borderTopWidth ? parseInt(e.borderTopWidth, 10) : 0, n = e.borderBottomWidth ? parseInt(e.borderBottomWidth, 10) : 0;
183
- return t + n;
184
- }
185
- function rn(e) {
186
- const t = e.slice(U).split(":"), n = t[1] ? Number(t[1]) : 0, o = i[t[0]]?.iframe, r = getComputedStyle(o), s = {
187
- iframe: o,
188
- id: t[0],
189
- height: n + nn(r) + on(r),
190
- width: Number(t[2]),
191
- type: t[3],
192
- msg: t[4],
193
- message: t[4]
194
- };
195
- return t[5] && (s.mode = t[5]), s;
196
- }
197
- const sn = { true: 1, false: 1, undefined: 1 };
198
- function cn(e) {
199
- const { id: t, msg: n, iframe: o } = e, r = zt(o);
200
- return r || (u(t, `Received: %c${n}`, l), M(t, "The target iframe was not found.")), r;
201
- }
202
- function an(e, t) {
203
- function n() {
204
- function f() {
205
- u(
206
- o,
207
- `Checking connection is from allowed list of origins: %c${a}`,
208
- l
209
- );
210
- for (const g of a)
211
- if (g === s)
212
- return !0;
213
- return !1;
214
- }
215
- function p() {
216
- const g = i[o]?.remoteHost;
217
- return u(o, `Checking connection is from: %c${g}`, l), s === g;
218
- }
219
- return a.constructor === Array ? f() : p();
220
- }
221
- const { id: o } = e, { data: r, origin: s } = t;
222
- if ("sameOrigin" in t && t.sameOrigin) return !0;
223
- let a = i[o]?.checkOrigin;
224
- if (a && `${s}` != "null" && !n())
225
- throw new Error(
226
- `Unexpected message received from: ${s} for ${o}. Message was: ${r}. This error can be disabled by setting the checkOrigin: false option or by providing an array of trusted domains.`
227
- );
228
- return !0;
229
- }
230
- const ln = (e) => x === `${e}`.slice(0, U) && e.slice(U).split(":")[0] in i;
231
- function un(e) {
232
- const { id: t, type: n } = e, o = n in sn;
233
- return o && u(t, "Ignoring init message from meta parent page"), o;
234
- }
235
- function fn(e) {
236
- try {
237
- i[e].sameOrigin = !!i[e]?.iframe?.contentWindow?.iframeChildListener;
238
- } catch {
239
- i[e].sameOrigin = !1;
240
- }
241
- u(e, `sameOrigin: %c${i[e].sameOrigin}`, l);
242
- }
243
- function pn(e, t) {
244
- if (t !== C) {
245
- if (t === void 0) {
246
- b(
247
- e,
248
- `<rb>Legacy version detected in iframe</>
249
-
250
- Detected legacy version of child page script. It is recommended to update the page in the iframe to use <b>@iframe-resizer/child</>.
251
-
252
- See <u>https://iframe-resizer.com/setup/#child-page-setup</> for more details.
253
- `
254
- );
255
- return;
256
- }
257
- u(
258
- e,
259
- `Version mismatch (Child: %c${t}%c !== Parent: %c${C})`,
260
- l,
261
- v,
262
- l
263
- );
264
- }
265
- }
266
- function T(e, t, n) {
267
- if (!i[e]) return null;
268
- const o = i[e][t];
269
- if (typeof o !== ve)
270
- throw new TypeError(`${t} on iframe[${e}] is not a function`);
271
- if (t !== "onBeforeClose" && t !== "onScroll")
272
- return Et(o, n);
273
- try {
274
- return o(n);
275
- } catch (r) {
276
- return console.error(r), M(e, `Error in ${t} callback`), null;
277
- }
278
- }
279
- function dn(e, t) {
280
- const { id: n, iframe: o } = e;
281
- u(
282
- n,
283
- `onMessage passed: {iframe: %c${n}%c, message: %c${t}%c}`,
284
- l,
285
- v,
286
- l,
287
- v
288
- ), T(n, "onMessage", {
289
- iframe: o,
290
- message: JSON.parse(t)
291
- });
292
- }
293
- function N(e, t) {
294
- const { lastMessage: n } = i[e];
295
- return n.slice(
296
- n.indexOf(S) + yt + t
297
- );
298
- }
299
- function ie(e, t) {
300
- const { id: n, iframe: o, height: r, type: s, width: c } = t;
301
- let a = { x: 0, y: 0 };
302
- if (c === 0 && r === 0) {
303
- const f = N(n, 9).split(S);
304
- a = {
305
- x: f[1],
306
- y: f[0]
307
- };
308
- } else
309
- a = {
310
- x: c,
311
- y: r
312
- };
313
- T(n, e, {
314
- iframe: o,
315
- screenX: Number(a.x),
316
- screenY: Number(a.y),
317
- type: s
318
- });
319
- }
320
- const d = {
321
- position: null,
322
- version: C
323
- };
324
- function ke() {
325
- d.position = null;
326
- }
327
- const hn = () => d.position;
328
- function gn(e) {
329
- d.position = e;
330
- }
331
- function je(e) {
332
- return d.position === null && (d.position = {
333
- x: window.scrollX,
334
- y: window.scrollY
335
- }), u(
336
- e,
337
- `Get page position: %c${d.position.x}%c, %c${d.position.y}`,
338
- l,
339
- v,
340
- l
341
- ), d.position;
342
- }
343
- function Le(e) {
344
- d.position !== null && (window.scrollTo(d.position.x, d.position.y), m(
345
- e,
346
- `Set page position: %c${d.position.x}%c, %c${d.position.y}`,
347
- l,
348
- v,
349
- l
350
- ), ke());
351
- }
352
- function re(e, t) {
353
- const { id: n } = t, o = `${t[e]}px`;
354
- i[n].iframe.style[e] = o, m(n, `Set ${e}: %c${o}`, l);
355
- }
356
- function Ae(e) {
357
- const { id: t } = e, { sizeHeight: n, sizeWidth: o } = i[t];
358
- n && re(ut, e), o && re(ft, e);
359
- }
360
- function se(e) {
361
- const { id: t } = e;
362
- Ae(e), Le(t), T(t, "onResized", e);
363
- }
364
- function Pe(e) {
365
- const { id: t } = e;
366
- u(t, "Disconnected from iframe"), delete i[t], delete e.iframeResizer;
367
- }
368
- function Ne(e) {
369
- const { id: t } = e;
370
- if (T(t, "onBeforeClose", t) === !1) {
371
- u(t, "Close iframe cancelled by onBeforeClose");
372
- return;
373
- }
374
- u(t, `Removing iFrame: %c${t}`, l);
375
- try {
376
- e.parentNode && e.remove();
377
- } catch (n) {
378
- M(t, n);
379
- }
380
- T(t, "onAfterClose", t), Pe(e);
381
- }
382
- function Ce(e) {
383
- const { id: t, type: n } = e;
384
- u(
385
- t,
386
- `Size reset requested by ${n === $ ? "parent page" : "child page"}`
387
- ), je(t), Ae(e), O(H, H, t);
388
- }
389
- const xe = (e, t) => {
390
- const n = {};
391
- return (o, r) => {
392
- const { iframe: s } = i[r];
393
- function c(f, p) {
394
- n[p] || (f(), n[p] = requestAnimationFrame(() => {
395
- n[p] = null;
396
- }));
397
- }
398
- function a() {
399
- O(`${o} (${e})`, `${e}:${t(s)}`, r);
400
- }
401
- c(a, r);
402
- };
403
- }, _e = (e) => (t) => {
404
- e in i[t] && (i[t][e](), delete i[t][e]);
405
- }, Fe = (e, t) => (n) => {
406
- let o = !1;
407
- const r = (h) => () => {
408
- i[n] ? (!o || o === h) && (e(h, n), o = h, requestAnimationFrame(() => {
409
- o = !1;
410
- })) : f();
411
- }, s = r(ee), c = r("resize window");
412
- function a(h, z) {
413
- u(n, `${h}listeners for send${t}`), z(window, ee, s), z(window, Z, c);
414
- }
415
- function f() {
416
- y(n, `stop${t}`), a("Remove ", oe), g.disconnect(), w.disconnect(), i[n] && oe(i[n].iframe, W, f);
417
- }
418
- function p() {
419
- a("Add ", j), g.observe(document.body), w.observe(i[n].iframe);
420
- }
421
- const g = new ResizeObserver(r("pageObserver")), w = new ResizeObserver(r("iframeObserver"));
422
- i[n] && (i[n][`stop${t}`] = f, j(i[n].iframe, W, f), p());
423
- };
424
- function mn(e) {
425
- const t = document.body.getBoundingClientRect(), n = e.getBoundingClientRect(), { scrollY: o, scrollX: r, innerHeight: s, innerWidth: c } = window, { clientHeight: a, clientWidth: f } = document.documentElement;
426
- return JSON.stringify({
427
- iframeHeight: n.height,
428
- iframeWidth: n.width,
429
- clientHeight: Math.max(a, s || 0),
430
- clientWidth: Math.max(f, c || 0),
431
- offsetTop: Math.trunc(n.top - t.top),
432
- offsetLeft: Math.trunc(n.left - t.left),
433
- scrollTop: o,
434
- scrollLeft: r,
435
- documentHeight: a,
436
- documentWidth: f,
437
- windowHeight: s,
438
- windowWidth: c
439
- });
440
- }
441
- const bn = xe(me, mn), yn = Fe(
442
- bn,
443
- "PageInfo"
444
- ), vn = _e("stopPageInfo");
445
- function wn(e) {
446
- const { scrollWidth: t, scrollHeight: n } = document.documentElement, { width: o, height: r, offsetLeft: s, offsetTop: c, pageLeft: a, pageTop: f, scale: p } = window.visualViewport;
447
- return JSON.stringify({
448
- iframe: e.getBoundingClientRect(),
449
- document: {
450
- scrollWidth: t,
451
- scrollHeight: n
452
- },
453
- viewport: {
454
- width: o,
455
- height: r,
456
- offsetLeft: s,
457
- offsetTop: c,
458
- pageLeft: a,
459
- pageTop: f,
460
- scale: p
461
- }
462
- });
463
- }
464
- const zn = xe(be, wn), En = Fe(
465
- zn,
466
- "ParentInfo"
467
- ), On = _e("stopParentInfo");
468
- function Be(e) {
469
- const t = e.getBoundingClientRect(), n = je(e.id);
470
- return {
471
- x: Number(t.left) + Number(n.x),
472
- y: Number(t.top) + Number(n.y)
473
- };
474
- }
475
- function We(e) {
476
- const { x: t, y: n } = hn(), o = i[e]?.iframe;
477
- if (T(e, "onScroll", { iframe: o, top: n, left: t, x: t, y: n }) === !1) {
478
- ke();
479
- return;
480
- }
481
- Le(e);
482
- }
483
- function Tn(e) {
484
- const { id: t, height: n, width: o } = e, r = window.parentIframe || window.parentIFrame || window;
485
- m(
486
- t,
487
- `scrollBy: x: %c${o}%c y: %c${n}`,
488
- l,
489
- v,
490
- l
491
- ), r.scrollBy(o, n);
492
- }
493
- const He = (e) => (t) => {
494
- function n(h) {
495
- gn(h), We(s);
496
- }
497
- function o(h, z) {
498
- h[`scrollTo${e ? "Offset" : ""}`](z.x, z.y);
499
- }
500
- const r = (h) => ({
501
- x: f + h.x,
502
- y: a + h.y
503
- }), { id: s, iframe: c, height: a, width: f } = t, p = e ? Be(c) : { x: 0, y: 0 }, g = r(p), w = window.parentIframe || window.parentIFrame;
504
- m(
505
- s,
506
- `Reposition requested (offset x:%c${p.x}%c y:%c${p.y})`,
507
- l,
508
- v,
509
- l
510
- ), w ? o(w, g) : n(g);
511
- }, In = He(!1), Mn = He(!0);
512
- function $n(e, t, n) {
513
- const { x: o, y: r } = Be(n);
514
- m(e, `Moving to in page link: %c#${t}`, l), d.position = { x: o, y: r }, We(e), window.location.hash = t;
515
- }
516
- function Sn(e, t) {
517
- const n = window.parentIframe || window.parentIFrame;
518
- if (!n) {
519
- u(e, `In page link #${t} not found`);
520
- return;
521
- }
522
- n.moveToAnchor(t);
523
- }
524
- function Rn(e, t) {
525
- const n = t.split("#")[1] || "", o = decodeURIComponent(n), r = document.getElementById(o) || document.getElementsByName(o)[0];
526
- if (r) {
527
- $n(e, n, r);
528
- return;
529
- }
530
- if (window.top === window.self) {
531
- u(e, `In page link #${n} not found`);
532
- return;
533
- }
534
- Sn(e, n);
535
- }
536
- function kn(e) {
537
- const t = i[e]?.iframe?.title;
538
- return t === "" || t === void 0;
539
- }
540
- function jn(e, t) {
541
- i[e]?.syncTitle && (i[e].iframe.title = t, m(e, `Set iframe title attribute: %c${t}`, l));
542
- }
543
- const ce = (e) => {
544
- if (!e) return "";
545
- let t = -559038744, n = 1103547984;
546
- for (let o, r = 0; r < e.length; r++)
547
- o = e.codePointAt(r), t = Math.imul(t ^ o, 2246822519), n = Math.imul(n ^ o, 3266489917);
548
- return t ^= Math.imul(t ^ n >>> 15, 1935289751), n ^= Math.imul(n ^ t >>> 15, 3405138345), t ^= n >>> 16, n ^= t >>> 16, (2097152 * (n >>> 0) + (t >>> 11)).toString(36);
549
- }, E = (e) => e.replace(
550
- /[A-Za-z]/g,
551
- (t) => String.fromCodePoint(
552
- (t <= "Z" ? 90 : 122) >= (t = t.codePointAt(0) + 19) ? t : t - 26
553
- )
554
- ), L = ["spjluzl", "rlf", "clyzpvu", "rlf2"], Ln = [
555
- "<yi>Puchspk Spjluzl Rlf</><iy><iy>",
556
- "<yi>Tpzzpun Spjluzl Rlf</><iy><iy>",
557
- "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</>",
558
- "<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</>.",
559
- "<iy><yi>Zvsv spjluzl kvlz uva zbwwvya jyvzz-kvthpu</><iy><iy>Av bzl <p>pmyhtl-ylzpgly</> dpao jyvzz kvthpu pmyhtlz fvb ullk lpaoly aol Wyvmlzzpvuhs vy Ibzpulzz spjluzlz. Mvy klahpsz vu bwnyhkl wypjpun wslhzl jvuahja pumv@pmyhtl-ylzpgly.jvt.",
560
- "Pu whnl spurpun ylxbpylz h Wyvmlzzpvuhs vy Ibzpulzz spjluzl. Wslhzl zll <b>oaawz://pmyhtl-ylzpgly.jvt/wypjpun</> mvy tvyl klahpsz."
561
- ], An = ["NWSc3", "zvsv", "wyv", "ibzpulzz", "vlt"], ae = Object.fromEntries(
562
- [
563
- "2cgs7fdf4xb",
564
- "1c9ctcccr4z",
565
- "1q2pc4eebgb",
566
- "ueokt0969w",
567
- "w2zxchhgqz",
568
- "1umuxblj2e5",
569
- "2b5sdlfhbev",
570
- "zo4ui3arjo",
571
- "oclbb4thgl"
572
- ].map((e, t) => [e, Math.max(0, t - 1)])
573
- ), A = (e) => E(Ln[e]), Pn = (e) => E(An[e]), Nn = (e) => {
574
- const t = e[E(L[0])] || e[E(L[1])] || e[E(L[2])] || e[E(L[3])];
575
- if (!t) return -1;
576
- const n = t.split("-");
577
- let o = (function(r = "") {
578
- let s = -2;
579
- const c = ce(E(r));
580
- return c in ae && (s = ae[c]), s > 4 ? s - 4 : s;
581
- })(n[0]);
582
- return o === 0 || ((r) => r[2] === ce(r[0] + r[1]))(n) || (o = -2), o;
583
- };
584
- let q = !1, De = !1;
585
- function Ge(e, t = -3) {
586
- if (q) return;
587
- const n = Math.max(i[e].mode, t);
588
- if (n > i[e].mode && (i[e].mode = n), n < 0)
589
- throw Wt(e), i[e].vAdvised || b(e || "Parent", `${A(n + 2)}${A(2)}`), i[e].vAdvised = !0, A(n + 2).replace(/<\/?[a-z][^>]*>|<\/>/gi, "");
590
- n > 0 && De || Dt(`v${C} (${Pn(n)})`, n), n < 1 && b("Parent", A(3)), q = !0;
591
- }
592
- function Cn(e) {
593
- if (q) return;
594
- const { mode: t } = i[e];
595
- t !== -1 && Ge(e, t);
596
- }
597
- function xn(e) {
598
- e?.log === -1 && (e.log = !1, De = !0);
599
- }
600
- function _n(e, t) {
601
- i[e] && (u(e, `First run for ${e}`), Ge(e, t !== void 0 ? Number(t) : void 0), i[e].firstRun = !1);
602
- }
603
- function Fn(e) {
604
- const { height: t, id: n, iframe: o, mode: r, message: s, type: c, width: a } = e, { lastMessage: f } = i[n];
605
- switch (i[n]?.firstRun && _n(n, r), u(n, `Received: %c${f}`, l), c) {
606
- case de:
607
- i[n].autoResize = JSON.parse(N(n, 9));
608
- break;
609
- case Ke:
610
- m(n, "Ready state reset"), i[n].initialised = !1;
611
- break;
612
- case Qe:
613
- Ne(o);
614
- break;
615
- case et:
616
- Rn(n, N(n, 9));
617
- break;
618
- case $:
619
- se(e), fn(n), pn(n, s), i[n].initialised = !0, T(n, "onReady", o);
620
- break;
621
- case R:
622
- dn(e, N(n, 6));
623
- break;
624
- case nt:
625
- ie("onMouseEnter", e);
626
- break;
627
- case ot:
628
- ie("onMouseLeave", e);
629
- break;
630
- case me:
631
- yn(n);
632
- break;
633
- case be:
634
- En(n);
635
- break;
636
- case it:
637
- vn(n);
638
- break;
639
- case rt:
640
- On(n);
641
- break;
642
- case H:
643
- Ce(e);
644
- break;
645
- case st:
646
- Tn(e);
647
- break;
648
- case ct:
649
- In(e);
650
- break;
651
- case at:
652
- Mn(e);
653
- break;
654
- case lt:
655
- jn(n, s);
656
- break;
657
- default:
658
- if (a === 0 && t === 0) {
659
- M(
660
- n,
661
- `Unsupported message received (${c}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`
662
- );
663
- return;
664
- }
665
- if (a === 0 || t === 0) {
666
- u(n, "Ignoring message with 0 height or width");
667
- return;
668
- }
669
- if (document.hidden) {
670
- u(n, "Page hidden - ignored resize request");
671
- return;
672
- }
673
- se(e);
674
- }
675
- }
676
- const Bn = (e) => ({ initChild: t, postMessageTarget: n }) => {
677
- e === n && t();
678
- }, Wn = (e) => Object.values(i).forEach(Bn(e));
679
- function le(e) {
680
- const t = e.data;
681
- if (t === Xe) {
682
- Wn(e.source);
683
- return;
684
- }
685
- if (!ln(t)) {
686
- if (typeof t !== J) return;
687
- y(D, "ignoredMessage"), Ft(D, t);
688
- return;
689
- }
690
- const n = rn(t), { id: o, type: r } = n;
691
- switch (y(o, r), !0) {
692
- case !i[o]:
693
- throw new Error(`${r} No settings for ${o}. Message was: ${t}`);
694
- case !cn(n):
695
- case un(n):
696
- case !an(n, e):
697
- return;
698
- default:
699
- i[o].lastMessage = e.data, Re(o, Fn)(n);
700
- }
701
- }
702
- const Hn = Ot(() => {
703
- j(window, R, le), j(document, "visibilitychange", tn), window.iframeParentListener = (e) => setTimeout(() => le({ data: e, sameOrigin: !0 }));
704
- }), ue = {};
705
- function Dn(e) {
706
- if (ue[e] === !0) return !1;
707
- const t = document.querySelectorAll(`iframe#${CSS.escape(e)}`);
708
- if (t.length <= 1) return !0;
709
- ue[e] = !0;
710
- const n = Array.from(t).flatMap((o) => [
711
- P,
712
- o,
713
- P
714
- ]);
715
- return b(
716
- e,
717
- `<rb>Duplicate ID attributes detected</>
718
-
719
- The <b>${e}</> ID is not unique. Having multiple iframes on the same page with the same ID causes problems with communication between the iframe and parent page. Please ensure that the ID of each iframe has a unique value.
720
-
721
- Found <bb>${t.length}</> iframes with the <b>${e}</> ID:`,
722
- ...n,
723
- P
724
- ), !1;
725
- }
726
- const Gn = `<rb>Deprecated Method Name</>
727
-
728
- The <b>removeListeners()</> method has been renamed to <b>disconnect()</>. ${Oe}`, Un = `<rb>Deprecated Method</>
729
-
730
- Use of the <b>resize()</> method from the parent page is deprecated and will be removed in a future version of <i>iframe-resizer</>. As there are no longer any edge cases that require triggering a resize from the parent page, it is recommended to remove this method from your code.`;
731
- function Vn(e) {
732
- if (i[e]) {
733
- const { iframe: t } = i[e], n = {
734
- close: Ne.bind(null, t),
735
- disconnect: Pe.bind(null, t),
736
- moveToAnchor(o) {
737
- St(o, J, "moveToAnchor(anchor) anchor"), O("Move to anchor", `moveToAnchor:${o}`, e);
738
- },
739
- removeListeners() {
740
- b(e, Gn), this.disconnect();
741
- },
742
- resize() {
743
- b(e, Un), O("Window resize", Z, e);
744
- },
745
- sendMessage(o) {
746
- o = JSON.stringify(o), O(R, `${R}:${o}`, e);
747
- }
748
- };
749
- t.iframeResizer = n, t.iFrameResizer = n;
750
- }
751
- }
752
- const qn = "8", Zn = "32", Jn = gt, Yn = !0;
753
- function Xn(e) {
754
- const {
755
- autoResize: t,
756
- bodyBackground: n,
757
- bodyMargin: o,
758
- bodyPadding: r,
759
- heightCalculationMethod: s,
760
- inPageLinks: c,
761
- license: a,
762
- log: f,
763
- logExpand: p,
764
- mouseEvents: g,
765
- offsetHeight: w,
766
- offsetWidth: h,
767
- mode: z,
768
- sizeHeight: Ue,
769
- // sizeSelector,
770
- sizeWidth: Ve,
771
- tolerance: qe,
772
- widthCalculationMethod: Ze
773
- } = i[e];
774
- return [
775
- e,
776
- qn,
777
- Ve,
778
- f,
779
- Zn,
780
- Yn,
781
- t,
782
- o,
783
- s,
784
- n,
785
- r,
786
- qe,
787
- c,
788
- Jn,
789
- Ze,
790
- g,
791
- w,
792
- h,
793
- Ue,
794
- a,
795
- d.version,
796
- z,
797
- "",
798
- // sizeSelector,
799
- p
800
- ].join(S);
801
- }
802
- const Kn = "0";
803
- function Qn(e) {
804
- const { bodyMargin: t } = i[e];
805
- (typeof t === mt || t === Kn) && (i[e].bodyMargin = `${t}px`);
806
- }
807
- const eo = (e) => {
808
- try {
809
- return new URL(e).origin;
810
- } catch {
811
- return null;
812
- }
813
- }, to = (e) => typeof e === ye && e.length > 0 && !(e.contains("allow-scripts") && e.contains("allow-same-origin"));
814
- function no(e, t) {
815
- const {
816
- checkOrigin: n,
817
- iframe: { src: o, sandbox: r },
818
- initialisedFirstPage: s,
819
- waitForLoad: c
820
- } = t[e], a = eo(o);
821
- y(e, "noResponse"), b(
822
- e,
823
- `<rb>No response from iframe</>
824
-
825
- The iframe (<i>${e}</>) has not responded within ${t[e].warningTimeout / 1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.
826
- ${n && a ? `
827
- The <b>checkOrigin</> option is currently enabled. If the iframe redirects away from <i>${a}</>, then the connection to the iframe may be blocked by the browser. To disable this option, set <b>checkOrigin</> to <bb>false</> or an array of allowed origins. See <u>https://iframe-resizer.com/checkorigin</> for more information.
828
- ` : ""}${c && !s ? `
829
- The <b>waitForLoad</> option is currently set to <bb>true</>. If the iframe loads before <i>iframe-resizer</> runs, this option will prevent <i>iframe-resizer</> initialising. To disable this option, set <b>waitForLoad</> to <bb>false</>.
830
- ` : ""}${to(r) ? `
831
- The iframe has the <b>sandbox</> attribute, please ensure it contains both the <bb>allow-same-origin</> and <bb>allow-scripts</> values.
832
- ` : ""}
833
- 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.
834
- `
835
- );
836
- }
837
- function oo(e, t) {
838
- function n() {
839
- if (t[e] === void 0) return;
840
- const { initialised: s, loadErrorShown: c } = t[e];
841
- if (t[e].msgTimeout = void 0, s) {
842
- t[e].initialisedFirstPage = !0;
843
- return;
844
- }
845
- c || (t[e].loadErrorShown = !0, no(e, t));
846
- }
847
- const { msgTimeout: o, warningTimeout: r } = t[e];
848
- r && (o && clearTimeout(o), t[e].msgTimeout = setTimeout(n, r));
849
- }
850
- const io = 1, ro = (e) => e.loading === tt, so = (e) => e === $;
851
- function co(e) {
852
- i[e]?.heightCalculationMethod in vt && Ce({
853
- id: e,
854
- iframe: i[e].iframe,
855
- height: Q,
856
- width: Q,
857
- type: $
858
- });
859
- }
860
- function ao(e, t) {
861
- j(e, W, () => setTimeout(t, io));
862
- }
863
- const lo = (e) => {
864
- const { src: t, srcdoc: n } = e;
865
- return !n && (t == null || t === "" || t === "about:blank");
866
- };
867
- function uo(e, t) {
868
- const { iframe: n, waitForLoad: o } = i[e];
869
- if (o !== !0) {
870
- if (lo(n)) {
871
- setTimeout(() => {
872
- y(e, "noContent"), m(e, "No content detected in the iframe, delaying initialisation");
873
- });
874
- return;
875
- }
876
- setTimeout(t);
877
- }
878
- }
879
- function fo(e, t) {
880
- const n = (r) => () => {
881
- if (!i[e]) return;
882
- const { firstRun: s, iframe: c } = i[e];
883
- O(r, t, e), so(r) && ro(c) || oo(e, i), s || co(e);
884
- }, { iframe: o } = i[e];
885
- i[e].initChild = n(he), ao(o, n(ge)), uo(e, n($));
886
- }
887
- function po(e, t) {
888
- return t ? (("sizeWidth" in t || "sizeHeight" in t || de in t) && b(
889
- e,
890
- `<rb>Deprecated Option</>
891
-
892
- The <b>sizeWidth</>, <b>sizeHeight</> and <b>autoResize</> options have been replaced with new <b>direction</> option which expects values of <bb>${F}</>, <bb>${Ee}</>, <bb>${ze}</> or <bb>${we}</>.
893
- `
894
- ), t) : {};
895
- }
896
- function ho(e) {
897
- i[e].warningTimeout || m(e, "warningTimeout:%c disabled", l);
898
- }
899
- function go(e, { offset: t, offsetSize: n }) {
900
- const o = n || t;
901
- o && (i[e].direction === F ? (i[e].offsetHeight = o, u(e, `Offset height: %c${o}`, l)) : (i[e].offsetWidth = o, u(e, `Offset width: %c${o}`, l)));
902
- }
903
- function mo(e) {
904
- const { direction: t } = i[e];
905
- switch (t) {
906
- case F:
907
- break;
908
- case Ee:
909
- i[e].sizeHeight = !1;
910
- // eslint-disable-next-line no-fallthrough
911
- case ze:
912
- i[e].sizeWidth = !0;
913
- break;
914
- case we:
915
- i[e].sizeWidth = !1, i[e].sizeHeight = !1, i[e].autoResize = !1;
916
- break;
917
- default:
918
- throw new TypeError(`Direction value of "${t}" is not valid`);
919
- }
920
- u(e, `direction: %c${t}`, l);
921
- }
922
- const bo = (e) => e === "" || e.match(/^(about:blank|javascript:|file:\/\/)/) !== null ? "*" : e;
923
- function yo(e) {
924
- i[e].targetOrigin = i[e].checkOrigin === !0 ? bo(i[e].remoteHost) : "*";
925
- }
926
- function vo(e) {
927
- const { id: t } = e;
928
- i[t].postMessageTarget === null && (i[t].postMessageTarget = e.contentWindow);
929
- }
930
- function B(e, t, n) {
931
- k(i[e], t) && (b(
932
- e,
933
- `<rb>Deprecated option</>
934
-
935
- The <b>${t}</> option has been renamed to <b>${n}</>. ${Oe}`
936
- ), i[e][n] = i[e][t], delete i[e][t]);
937
- }
938
- function wo(e) {
939
- B(e, pt, dt), B(e, "onClose", "onBeforeClose"), B(e, "onClosed", "onAfterClose");
940
- }
941
- const zo = (e) => k(e, "onMouseEnter") || k(e, "onMouseLeave");
942
- function Eo(e, t) {
943
- const { id: n } = e;
944
- i[n] = {
945
- ...i[n],
946
- iframe: e,
947
- remoteHost: e?.src.split("/").slice(0, 3).join("/"),
948
- ..._,
949
- ...po(n, t),
950
- mouseEvents: zo(t),
951
- mode: Nn(t),
952
- syncTitle: kn(n)
953
- }, wo(n), mo(n), go(n, t), ho(n), vo(e), yo(n);
954
- }
955
- const Oo = "yes", fe = "no", To = "omit";
956
- function Io(e) {
957
- const { id: t } = e;
958
- switch (u(
959
- t,
960
- `Iframe scrolling ${i[t]?.scrolling ? "enabled" : "disabled"} for ${t}`
961
- ), e.style.overflow = i[t]?.scrolling === !1 ? ht : G, i[t]?.scrolling) {
962
- case To:
963
- break;
964
- case !0:
965
- e.scrolling = Oo;
966
- break;
967
- case !1:
968
- e.scrolling = fe;
969
- break;
970
- default:
971
- e.scrolling = i[t]?.scrolling || fe;
972
- }
973
- }
974
- function Mo(e, t, n) {
975
- Eo(t, n), u(e, `src: %c${t.srcdoc || t.src}`, l), Cn(e), Io(t), Qn(e), fo(e, Xn(e)), Vn(e), u(e, "Setup complete");
976
- }
977
- function $o(e, t) {
978
- const { id: n } = e;
979
- y(n, "setup"), Dn(n) && Mo(n, e, t), Ht(n);
980
- }
981
- function So(e, t) {
982
- const n = k(t, "log"), o = X(t.log), r = n ? o ? !0 : t.log : _.log;
983
- k(t, "logExpand") || (t.logExpand = n && o ? t.log === V : _.logExpand), xn(t), _t({
984
- enabled: r,
985
- expand: t.logExpand,
986
- iframeId: e
987
- }), o && !(t.log in wt) && Bt(
988
- e,
989
- `Invalid value for options.log: Accepted values are "${V}" and "${Y}"`
990
- ), t.log = r;
991
- }
992
- function ko(e) {
993
- if (!Te(e)) throw new TypeError("Options is not an object");
994
- return Hn(), Xt(e), (t) => {
995
- const n = Yt(t, e);
996
- return pe in t ? (y(n, "alreadySetup"), M(n, `Ignored iframe (${n}), already setup.`)) : (So(n, e), Re(n, $o)(t, e)), t?.iframeResizer;
997
- };
998
- }
999
- export {
1000
- ko as default
1001
- };
1
+ /*!
2
+ * @preserve
3
+ *
4
+ * @module iframe-resizer/core 6.0.0-beta.10 (esm) - 2026-04-16
5
+ *
6
+ * @license GPL-3.0 For use with GPL compliant sites (fully published front & backend source code)
7
+ * Alternatively for commercial use, you can purchase a license from
8
+ * https://iframe-resizer.com/pricing
9
+ *
10
+ * @description Keep same and cross domain iframes sized to their content
11
+ *
12
+ * @author David J. Bradshaw <info@iframe-resizer.com>
13
+ *
14
+ * @see {@link https://iframe-resizer.com}
15
+ *
16
+ * @copyright (c) 2013 - 2026, David J. Bradshaw. All rights reserved.
17
+ */
18
+
19
+
20
+ import{esModuleInterop as e,createFormatAdvise as n,id as i,deprecate as t,isString as o,isIframe as r,isolateUserCode as s,addEventListener as a,removeEventListener as c,getModeData as d,getModeLabel as l,once as f,typeAssert as u,hasOwn as g,setMode as m,isObject as h}from"@iframe-resizer/common";import{PARENT as p,LABEL as b,BOLD as w,AUTO as y,VERTICAL as $,COLLAPSE as v,LOG_COLLAPSED as k,LOG_EXPANDED as T,EXPAND as z,LOG_DISABLED as x,MESSAGE_ID as O,INIT_EVENTS as M,SEPARATOR as I,RESIZE as E,MESSAGE_ID_LENGTH as S,VERSION as R,FUNCTION as C,MESSAGE_HEADER_LENGTH as L,HEIGHT as A,WIDTH as W,INIT as P,RESET as B,LOAD as D,SCROLL as H,PAGE_INFO as N,PARENT_INFO as F,TITLE as j,SCROLL_TO_OFFSET as q,SCROLL_TO as G,SCROLL_BY as _,PARENT_INFO_STOP as J,PAGE_INFO_STOP as U,MOUSE_LEAVE as X,MOUSE_ENTER as V,MESSAGE as Y,IN_PAGE_LINK as K,CLOSE as Q,BEFORE_UNLOAD as Z,AUTO_RESIZE as ee,CHILD_READY_MESSAGE as ne,STRING as ie,NEW_LINE as te,CHILD as oe,NUMBER as re,OBJECT as se,INIT_FROM_IFRAME as ae,LAZY as ce,RESET_REQUIRED_METHODS as de,MIN_SIZE as le,ONLOAD as fe,HORIZONTAL as ue,BOTH as ge,NONE as me,REMOVED_NEXT_VERSION as he,OFFSET_SIZE as pe,OFFSET as be,HIDDEN as we,OMIT as ye,LOG_OPTIONS as $e}from"@iframe-resizer/common/consts";import{LOG_COLLAPSED as ve,LOG_DISABLED as ke,LOG_EXPANDED as Te}from"@iframe-resizer/common/consts";import ze,{NORMAL as xe,HIGHLIGHT as Oe,FOREGROUND as Me}from"auto-console-group";const Ie={},Ee=e(ze);let Se=!0;const Re=Ee({expand:!1,label:p}),Ce=e=>window.top===window.self?`parent(${e})`:`nested parent(${e})`;const Le=e=>(n,...i)=>Ie[n]?Ie[n].console[e](...i):Re[e](...i),Ae=e=>(n,...i)=>!0===(e=>Ie[e]?Ie[e].log:Se)(n)?Le(e)(n,...i):null,We=Ae("log"),Pe=We,Be=Ae("debug"),De=Le("warn"),He=Le("error"),Ne=Le("event"),Fe=Le("purge"),je=Le("endAutoGroup"),qe=Le("errorBoundary");const Ge=n(i),_e=(e,...i)=>Ie[e]?Ie[e].console.warn(...i.map(Ge)):queueMicrotask(()=>{const t=n((e=>(...n)=>[`${b}(${e})`,...n].join(" "))(e));console?.warn(...i.map(t))}),Je=t(_e);Je("Function"),Je("Method"),Je("Option");const Ue=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyPadding:null,checkOrigin:!0,direction:$,firstRun:!0,inPageLinks:!1,heightCalculationMethod:y,id:"iframeResizer",log:!1,logExpand:!1,license:void 0,mouseEvents:!0,offsetHeight:null,offsetWidth:null,postMessageTarget:null,sameDomain:!1,scrolling:!1,sizeHeight:!0,sizeWidth:!1,tolerance:0,waitForLoad:!1,warningTimeout:5e3,widthCalculationMethod:y,onBeforeClose:()=>!0,onAfterClose(){},onMessage(){console.warn("","onMessage function not defined")},onMouseEnter(){},onMouseLeave(){},onReady(){},onResized(){},onScroll:()=>!0});let Xe=0;function Ve(e,n){let{id:i}=e;if(i&&!o(i))throw new TypeError("Invalid id for iframe. Expected String");return i&&""!==i||(i=function(e){const n=e?.id||Ue.id+Xe++;return null===document.getElementById(n)?n:`${n}${Xe++}`}(n),e.id=i,Ne(i,"assignId"),We(i,`Added missing iframe ID: ${i} (${e.src})`)),i}function Ye(e,n,i){function t(t){const o=e in M?(e=>e.split(I).filter((e,n)=>19!==n).join(I))(n):n;Pe(i,t,Oe,Me,Oe),Pe(i,`Message data: %c${o}`,Oe)}const{iframe:o,postMessageTarget:r,sameOrigin:s,targetOrigin:a}=Ie[i];if(s)try{return o.contentWindow.iframeChildListener(O+n),void t(`Sending message to iframe %c${i}%c via same origin%c`)}catch(c){e in M?(Ie[i].sameOrigin=!1,We(i,"New iframe does not support same origin")):De(i,"Same origin messaging failed, falling back to postMessage")}t(`Sending message to iframe: %c${i}%c targetOrigin: %c${a.join(", ")}`);for(const d of a)r.postMessage(O+n,d)}function Ke(e,n,i){Ne(i,e),Ie[i]?.postMessageTarget?Ye(e,n,i):De(i,"Iframe not found")}function Qe(){var e,n;!0!==document.hidden&&(e="tabVisible",n=E,Object.values(Ie).filter(({autoResize:e,firstRun:n})=>e&&!n).forEach(({iframe:i})=>Ke(e,n,i.id)))}function Ze(e){const n=e.slice(S).split(":"),i=n[1]?Number(n[1]):0,t=Ie[n[0]]?.iframe,o=t?getComputedStyle(t):null,r=o?function(e){return"border-box"!==e.boxSizing?0:(e.paddingTop?parseInt(e.paddingTop,10):0)+(e.paddingBottom?parseInt(e.paddingBottom,10):0)}(o)+function(e){return"border-box"!==e.boxSizing?0:(e.borderTopWidth?parseInt(e.borderTopWidth,10):0)+(e.borderBottomWidth?parseInt(e.borderBottomWidth,10):0)}(o):0,s={iframe:t,id:n[0],height:i+r,width:Number(n[2]),type:n[3],message:n[4]};return n[5]&&(s.mode=n[5]),s}const en={true:1,false:1,undefined:1};function nn(e,n,i){if(!Ie[e])return null;const t=Ie[e][n];if(typeof t!==C)throw new TypeError(`${n} on iframe[${e}] is not a function`);if("onBeforeClose"!==n&&"onScroll"!==n)return s(t,i);try{return t(i)}catch(o){return console.error(o),De(e,`Error in ${n} callback`),null}}function tn(e,n){const{lastMessage:i}=Ie[e];return i.slice(i.indexOf(I)+L+n)}function on(e,n){const{id:i,iframe:t,height:o,type:r,width:s}=n;let a={x:0,y:0};if(0===s&&0===o){const e=tn(i,9).split(I);a={x:e[1],y:e[0]}}else a={x:s,y:o};nn(i,e,{iframe:t,screenX:Number(a.x),screenY:Number(a.y),type:r})}const rn={position:null,version:R};function sn(){rn.position=null}function an(e){return null===rn.position&&(rn.position={x:window.scrollX,y:window.scrollY}),We(e,`Get page position: %c${rn.position.x}%c, %c${rn.position.y}`,Oe,Me,Oe),rn.position}function cn(e){null!==rn.position&&(window.scrollTo(rn.position.x,rn.position.y),Pe(e,`Set page position: %c${rn.position.x}%c, %c${rn.position.y}`,Oe,Me,Oe),sn())}function dn(e,n){const{id:i}=n,t=`${n[e]}px`;Ie[i].iframe.style[e]=t,Pe(i,`Set ${e}: %c${t}`,Oe)}function ln(e){const{id:n}=e,{sizeHeight:i,sizeWidth:t}=Ie[n];i&&dn(A,e),t&&dn(W,e)}function fn(e){const{id:n}=e;ln(e),cn(n),nn(n,"onResized",e)}function un(e){const{id:n}=e;We(n,"Disconnected from iframe"),delete Ie[n],delete e.iframeResizer}function gn(e){const{id:n}=e;if(!1!==nn(n,"onBeforeClose",n)){We(n,`Removing iframe: %c${n}`,Oe);try{e.parentNode&&e.remove()}catch(i){De(n,i)}nn(n,"onAfterClose",n),un(e)}else We(n,"Close iframe cancelled by onBeforeClose")}function mn(e){const{id:n,type:i}=e;We(n,"Size reset requested by "+(i===P?"parent page":"child page")),an(n),ln(e),Ke(B,B,n)}const hn=(e,n)=>{const i={};return(t,o)=>{const{iframe:r}=Ie[o];var s,a;s=function(){Ke(`${t} (${e})`,`${e}:${n(r)}`,o)},i[a=o]||(s(),i[a]=requestAnimationFrame(()=>{i[a]=null}))}},pn=e=>n=>{e in Ie[n]&&(Ie[n][e](),delete Ie[n][e])},bn=(e,n)=>i=>{let t=!1;const o=n=>()=>{Ie[i]?t&&t!==n||(e(n,i),t=n,requestAnimationFrame(()=>{t=!1})):u()},r=o(H),s=o("resize window"),d=new ResizeObserver(o("pageObserver")),l=new ResizeObserver(o("iframeObserver"));function f(e,t){We(i,`${e}listeners for send${n}`),t(window,H,r),t(window,E,s)}function u(){Ne(i,`stop${n}`),f("Remove ",c),d.disconnect(),l.disconnect(),Ie[i]&&c(Ie[i].iframe,D,u)}Ie[i]&&(Ie[i][`stop${n}`]=u,a(Ie[i].iframe,D,u),f("Add ",a),d.observe(document.body),l.observe(Ie[i].iframe))};const wn=bn(hn(N,function(e){const n=document.body.getBoundingClientRect(),i=e.getBoundingClientRect(),{scrollY:t,scrollX:o,innerHeight:r,innerWidth:s}=window,{clientHeight:a,clientWidth:c}=document.documentElement;return JSON.stringify({iframeHeight:i.height,iframeWidth:i.width,clientHeight:Math.max(a,r||0),clientWidth:Math.max(c,s||0),offsetTop:Math.trunc(i.top-n.top),offsetLeft:Math.trunc(i.left-n.left),scrollTop:t,scrollLeft:o,documentHeight:a,documentWidth:c,windowHeight:r,windowWidth:s})}),"PageInfo"),yn=pn("stopPageInfo");const $n=bn(hn(F,function(e){const{scrollWidth:n,scrollHeight:i}=document.documentElement,t="undefined"!=typeof window&&window.visualViewport?window.visualViewport:{},{width:o=0,height:r=0,offsetLeft:s=0,offsetTop:a=0,pageLeft:c=0,pageTop:d=0,scale:l=1}=t;return JSON.stringify({iframe:e.getBoundingClientRect(),document:{scrollWidth:n,scrollHeight:i},viewport:{width:o,height:r,offsetLeft:s,offsetTop:a,pageLeft:c,pageTop:d,scale:l}})}),"ParentInfo"),vn=pn("stopParentInfo");function kn(e){const n=e.getBoundingClientRect(),i=an(e.id);return{x:Number(n.left)+Number(i.x),y:Number(n.top)+Number(i.y)}}function Tn(e){const{x:n,y:i}=rn.position,t=Ie[e]?.iframe;!1!==nn(e,"onScroll",{iframe:t,top:i,left:n,x:n,y:i})?cn(e):sn()}const zn=e=>n=>{const{id:i,iframe:t,height:o,width:r}=n;const s=e?kn(t):{x:0,y:0},a={x:r+(c=s).x,y:o+c.y};var c;const d=window.parentIframe||window.parentIFrame;var l;Pe(i,`Reposition requested (offset x:%c${s.x}%c y:%c${s.y})`,Oe,Me,Oe),d?(l=a,d["scrollTo"+(e?"Offset":"")](l.x,l.y)):function(e){var n;n=e,rn.position=n,Tn(i)}(a)},xn=zn(!1),On=zn(!0);function Mn(e,n){const i=n.split("#")[1]||"",t=decodeURIComponent(i),o=document.getElementById(t)||document.getElementsByName(t)[0];o?function(e,n,i){const{x:t,y:o}=kn(i);Pe(e,`Moving to in page link: %c#${n}`,Oe),rn.position={x:t,y:o},Tn(e),window.location.hash=n}(e,i,o):window.top!==window.self?function(e,n){const i=window.parentIframe||window.parentIFrame;i?i.moveToAnchor(n):We(e,`In page link #${n} not found`)}(e,i):We(e,`In page link #${i} not found`)}function In(e){const n=Ie[e]?.iframe?.title;return""===n||void 0===n}let En=!1,Sn=!1;function Rn(e,n=-3){if(En)return;const i=Math.max(Ie[e].mode,n);if(i>Ie[e].mode&&(Ie[e].mode=i),i<0)throw Fe(e),Ie[e].vAdvised||_e(e||"Parent",`${d(i+2)}${d(2)}`),Ie[e].vAdvised=!0,d(i+2).replace(/<\/?[a-z][^>]*>|<\/>/gi,"");switch(i>5&&Sn||function(e,n){queueMicrotask(()=>console.info(`%ciframe-resizer ${e}`,Se||n<1?w:xe))}(`v${R} (${l(i)})`,i),i){case 1:case 2:case 3:_e("Parent",d(6));break;case 4:_e("Parent",d(7));break;case 5:_e("Parent",d(8));break;default:i<1&&_e("Parent",d(3))}En=!0}function Cn(e){const{height:n,id:i,iframe:t,mode:o,message:r,type:s,width:a}=e,{lastMessage:c}=Ie[i];switch(Ie[i]?.firstRun&&function(e,n){Ie[e]&&(We(e,`First run for ${e}`),Rn(e,void 0===n?void 0:Number(n)),Ie[e].firstRun=!1)}(i,o),We(i,`Received: %c${c}`,Oe),s){case ee:Ie[i].autoResize=JSON.parse(tn(i,9));break;case Z:Pe(i,"Ready state reset"),Ie[i].initialised=!1;break;case Q:gn(t);break;case K:Mn(i,tn(i,9));break;case P:fn(e),function(e){try{Ie[e].sameOrigin=!!Ie[e]?.iframe?.contentWindow?.iframeChildListener}catch(n){Ie[e].sameOrigin=!1}We(e,`sameOrigin: %c${Ie[e].sameOrigin}`,Oe)}(i),function(e,n){n!==R&&(void 0!==n?We(e,`Version mismatch (Child: %c${n}%c !== Parent: %c${R})`,Oe,Me,Oe):_e(e,"<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"))}(i,r),Ie[i].initialised=!0,nn(i,"onReady",t);break;case Y:!function(e,n){const{id:i,iframe:t}=e;We(i,`onMessage passed: {iframe: %c${i}%c, message: %c${n}%c}`,Oe,Me,Oe,Me),nn(i,"onMessage",{iframe:t,message:JSON.parse(n)})}(e,tn(i,6));break;case V:on("onMouseEnter",e);break;case X:on("onMouseLeave",e);break;case N:wn(i);break;case F:$n(i);break;case U:yn(i);break;case J:vn(i);break;case B:mn(e);break;case _:!function(e){const{id:n,height:i,width:t}=e,o=window.parentIframe||window.parentIFrame||window;Pe(n,`scrollBy: x: %c${t}%c y: %c${i}`,Oe,Me,Oe),o.scrollBy(t,i)}(e);break;case G:xn(e);break;case q:On(e);break;case j:!function(e,n){Ie[e]?.syncTitle&&(Ie[e].iframe.title=n,Pe(e,`Set iframe title attribute: %c${n}`,Oe))}(i,r);break;default:if(0===a&&0===n)return void De(i,`Unsupported message received (${s}), this is likely due to the iframe containing a later version of iframe-resizer than the parent page`);if(0===a||0===n)return void We(i,"Ignoring message with 0 height or width");if(document.hidden)return void We(i,"Page hidden - ignored resize request");fn(e)}}function Ln(e){const n=e.data;if(n===ne)return i=e.source,void Object.values(Ie).forEach((e=>({initChild:n,postMessageTarget:i})=>{e===i&&n()})(i));var i,t;if(O!==`${t=n}`.slice(0,S)||!(t.slice(S).split(":")[0]in Ie)){if(typeof n!==ie)return;return Ne(p,"ignoredMessage"),void Be(p,n)}const o=Ze(n),{id:s,type:a}=o;switch(Ne(s,a),!0){case!Ie[s]:throw new Error(`${a} No settings for ${s}. Message was: ${n}`);case!function(e){const{id:n,message:i,iframe:t}=e,o=r(t);return o||(We(n,`Received: %c${i}`,Oe),De(n,"The target iframe was not found.")),o}(o):case function(e){const{id:n,type:i}=e,t=i in en;return t&&We(n,"Ignoring init message from meta parent page"),t}(o):case!function(e,n){const{id:i}=e,{data:t,origin:o}=n;if("sameOrigin"in n&&n.sameOrigin)return!0;const r=Ie[i]?.checkOrigin;if(r&&"null"!=`${o}`&&!(r.constructor===Array?function(){We(i,`Checking connection is from allowed list of origins: %c${r}`,Oe);for(const e of r)if(e===o)return!0;return!1}():function(){const e=Ie[i]?.remoteHost;return We(i,`Checking connection is from: %c${e}`,Oe),o===e}()))throw new Error(`Unexpected message received from: ${o} for ${i}. Message was: ${t}. This error can be disabled by setting the checkOrigin: false option or by providing an array of trusted domains.`);return!0}(o,e):return;default:Ie[s].lastMessage=e.data,qe(s,Cn)(o)}}const An=f(()=>{a(window,Y,Ln),a(document,"visibilitychange",Qe),window.iframeParentListener=e=>setTimeout(()=>Ln({data:e,sameOrigin:!0}))}),Wn={};const Pn="8",Bn="32",Dn=oe,Hn=!0;function Nn(e,n){const{checkOrigin:i,iframe:{src:t,sandbox:o},initialisedFirstPage:r,waitForLoad:s}=n[e],a=(e=>{try{return new URL(e).origin}catch(n){return null}})(t);Ne(e,"noResponse"),_e(e,`<rb>No response from iframe</>\n\nThe iframe (<i>${e}</>) has not responded within ${n[e].warningTimeout/1e3} seconds. Check <b>@iframe-resizer/child</> package has been loaded in the iframe.\n${i&&a?`\nThe <b>checkOrigin</> option is currently enabled. If the iframe redirects away from <i>${a}</>, then the connection to the iframe may be blocked by the browser. To disable this option, set <b>checkOrigin</> to <bb>false</> or an array of allowed origins. See <u>https://iframe-resizer.com/checkorigin</> for more information.\n`:""}${s&&!r?"\nThe <b>waitForLoad</> option is currently set to <bb>true</>. If the iframe loads before <i>iframe-resizer</> runs, this option will prevent <i>iframe-resizer</> initialising. To disable this option, set <b>waitForLoad</> to <bb>false</>.\n":""}${(e=>typeof e===se&&e.length>0&&!(e.contains("allow-scripts")&&e.contains("allow-same-origin")))(o)?"\nThe iframe has the <b>sandbox</> attribute, please ensure it contains both the <bb>allow-same-origin</> and <bb>allow-scripts</> values.\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`)}function Fn(e,n){const i=i=>()=>{if(!Ie[e])return;const{firstRun:t,iframe:o}=Ie[e];Ke(i,n,e),(e=>e===P)(i)&&(e=>e.loading===ce)(o)||function(e,n){const{msgTimeout:i,warningTimeout:t}=n[e];t&&(i&&clearTimeout(i),n[e].msgTimeout=setTimeout(function(){if(void 0===n[e])return;const{initialised:i,loadErrorShown:t}=n[e];n[e].msgTimeout=void 0,i?n[e].initialisedFirstPage=!0:t||(n[e].loadErrorShown=!0,Nn(e,n))},t))}(e,Ie),t||function(e){Ie[e]?.heightCalculationMethod in de&&mn({id:e,iframe:Ie[e].iframe,height:le,width:le,type:P})}(e)},{iframe:t}=Ie[e];Ie[e].initChild=i(ae),function(e,n){a(e,D,()=>setTimeout(n,1))}(t,i(fe)),function(e,n){const{iframe:i,waitForLoad:t}=Ie[e];!0!==t&&((e=>{const{src:n,srcdoc:i}=e;return!i&&(null==n||""===n||"about:blank"===n)})(i)?setTimeout(()=>{Ne(e,"noContent"),Pe(e,"No content detected in the iframe, delaying initialisation")}):setTimeout(n))}(e,i(P))}function jn(e,n){return n?(("sizeWidth"in n||"sizeHeight"in n||ee in n)&&_e(e,`<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 <bb>${$}</>, <bb>${ue}</>, <bb>${ge}</> or <bb>${me}</>.\n`),n):{}}const qn=e=>""===e||null!==e.match(/^(about:blank|javascript:|file:\/\/)/)?"*":e;function Gn(e,n,i){g(Ie[e],n)&&(_e(e,`<rb>Deprecated option</>\n\nThe <b>${n}</> option has been renamed to <b>${i}</>. ${he}`),Ie[e][i]=Ie[e][n],delete Ie[e][n])}const _n=e=>g(e,"onMouseEnter")||g(e,"onMouseLeave");function Jn(e,n){const{id:i}=e;Ie[i]={...Ie[i],iframe:e,remoteHost:e?.src.split("/").slice(0,3).join("/"),...Ue,...jn(i,n),mouseEvents:_n(n),mode:m(n),syncTitle:In(i)},function(e){Gn(e,be,pe),Gn(e,"onClose","onBeforeClose"),Gn(e,"onClosed","onAfterClose")}(i),function(e){const{direction:n}=Ie[e];switch(n){case $:break;case ue:Ie[e].sizeHeight=!1;case ge:Ie[e].sizeWidth=!0;break;case me:Ie[e].sizeWidth=!1,Ie[e].sizeHeight=!1,Ie[e].autoResize=!1;break;default:throw new TypeError(`Direction value of "${n}" is not valid`)}We(e,`direction: %c${n}`,Oe)}(i),function(e,{offset:n,offsetSize:i}){const t=i||n;t&&(Ie[e].direction===$?(Ie[e].offsetHeight=t,We(e,`Offset height: %c${t}`,Oe)):(Ie[e].offsetWidth=t,We(e,`Offset width: %c${t}`,Oe)))}(i,n),function(e){Ie[e].warningTimeout||Pe(e,"warningTimeout:%c disabled",Oe)}(i),function(e){const{id:n}=e;null===Ie[n].postMessageTarget&&(Ie[n].postMessageTarget=e.contentWindow)}(e),function(e){const{checkOrigin:n,remoteHost:i}=Ie[e];Array.isArray(n)&&0===n.length&&De(e,"checkOrigin is an empty array — no messages will be sent to the iframe"),Ie[e].targetOrigin=Array.isArray(n)?n.map(qn):[!1===n?"*":qn(i)]}(i)}function Un(e,n,i){Jn(n,i),We(e,`src: %c${n.srcdoc||n.src}`,Oe),function(e){if(En)return;const{mode:n}=Ie[e];n>5&&Rn(e,n)}(e),function(e){const{id:n}=e;switch(We(n,`Iframe scrolling ${Ie[n]?.scrolling?"enabled":"disabled"} for ${n}`),e.style.overflow=!1===Ie[n]?.scrolling?we:y,Ie[n]?.scrolling){case ye:break;case!0:e.scrolling="yes";break;case!1:e.scrolling="no";break;default:e.scrolling=Ie[n]?.scrolling||"no"}}(n),function(e){const{bodyMargin:n}=Ie[e];typeof n!==re&&"0"!==n||(Ie[e].bodyMargin=`${n}px`)}(e),Fn(e,function(e){const{autoResize:n,bodyBackground:i,bodyMargin:t,bodyPadding:o,heightCalculationMethod:r,inPageLinks:s,license:a,log:c,logExpand:d,mouseEvents:l,offsetHeight:f,offsetWidth:u,mode:g,sizeHeight:m,sizeWidth:h,tolerance:p,widthCalculationMethod:b}=Ie[e];return[e,Pn,h,c,Bn,Hn,n,t,r,i,o,p,s,Dn,b,l,f,u,m,a,rn.version,g,"",d].join(I)}(e)),function(e){if(Ie[e]){const{iframe:n}=Ie[e];n.iframeResizer={close:gn.bind(null,n),disconnect:un.bind(null,n),moveToAnchor(n){u(n,ie,"moveToAnchor(anchor) anchor"),Ke("Move to anchor",`moveToAnchor:${n}`,e)},sendMessage(n){n=JSON.stringify(n),Ke(Y,`${Y}:${n}`,e)}}}}(e),We(e,"Setup complete")}function Xn(e,n){const{id:i}=e;Ne(i,"setup"),function(e){if(!0===Wn[e])return!1;const n=document.querySelectorAll(`iframe#${CSS.escape(e)}`);if(n.length<=1)return!0;Wn[e]=!0;const i=Array.from(n).flatMap(e=>[te,e,te]);return _e(e,`<rb>Duplicate ID attributes detected</>\n\nThe <b>${e}</> ID is not unique. Having multiple iframes on the same page with the same ID causes problems with communication between the iframe and parent page. Please ensure that the ID of each iframe has a unique value.\n\nFound <bb>${n.length}</> iframes with the <b>${e}</> ID:`,...i,te),!1}(i)&&Un(i,e,n),je(i)}function Vn(e,n){n.log===x?n.log=!1:n.log===k?n.log=v:n.log===T&&(n.log=z);const i=g(n,"log"),t=o(n.log),r=i?!!t||n.log:Ue.log;g(n,"logExpand")||(n.logExpand=i&&t?n.log===z:Ue.logExpand),function(e){-1===e?.log&&(e.log=!1,Sn=!0)}(n),function({enabled:e,expand:n,iframeId:i}){const t=Ee({expand:n,label:Ce(i)});Se=e,Ie[i]||(Ie[i]={console:t})}({enabled:r,expand:n.logExpand,iframeId:e}),t&&!(n.log in $e)&&He(e,`Invalid value for options.log: Accepted values are "${z}" and "${v}"`),n.log=r}function Yn(e){if(!h(e))throw new TypeError("Options is not an object");return An(),function(e){const{search:n}=window.location;if(n.includes("ifrlog"))switch(new URLSearchParams(n).get("ifrlog")){case String(x):e.log=!1;break;case z:case String(T):e.log=z;break;case v:case String(k):default:e.log=v}}(e),n=>{const i=Ve(n,e);return b in n?(Ne(i,"alreadySetup"),De(i,`Ignored iframe (${i}), already setup.`)):(Vn(i,e),qe(i,Xn)(n,e)),n.iframeResizer}}export{ve as LOG_COLLAPSED,ke as LOG_DISABLED,Te as LOG_EXPANDED,Yn as default};
1002
21
  //# sourceMappingURL=index.esm.js.map