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