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jC,CAAC,QAAS,UAAU,QAAQ,SAAU,GAAS,EAAM,aAAa,IAAI,EAAO,aAAa,EAAG,EAAM,aAAa,GAAK,GACrH,EAAM,aAAa,EAAQ,EAC7B,MACE,EAAM,MAAQ,EACd,EAAM,iBAAkB,EACxB,EAAM,IAAM,EAAK,OACjB,EAAM,gBAAgB,YACtB,EAAM,gBAAgB,eACtB,EAAM,gBAAgB,UACtB,EAAO,QAEX,EAAG,CAAE,MAAM,GApDX,MAFE,EAAS,EAAO,EAPuC,CAFhB,CAFb,CAkE9B,CAEA,SAAS,EAAK,GACU,IAAlB,EAAK,WACY,WAAjB,EAAK,QAAsB,EAAO,GAC7B,EAAK,sBAAsB,MAAM,UAAU,QAAQ,KAAK,EAAK,qBAAqB,UAAW,GACxG,CAeD,CApPD","file":"/gh/bolkstudio/jeremyloreau-scripts@1.5.0/wistia-facade.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.51.2.\n * Original file: /gh/bolkstudio/jeremyloreau-scripts@1.5.0/wistia-facade.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*!\n * wistia-facade v1.5.0\n * Bolk Studio, for jeremyloreau.com\n *\n * Wistia, YouTube, Vimeo and Loom videos embedded through Webflow (Embedly iframes in Rich\n * Text and in native Video elements, `.w-video`) only load when they come near the screen.\n * Until then an empty `srcdoc` keeps each iframe from loading its `src`. Cuts the player JS\n * and video buffering of off-screen videos (Core Web Vitals).\n *\n * Two modes, per video:\n * - \"lazy\" (default for Wistia, Vimeo, Loom): the original iframe and player are kept untouched,\n *   so the final rendering is exactly the site's (Wistia autoplay loops, animated video\n *   thumbnails, controls). No player starts before the page has loaded: until then, videos on\n *   screen show their still thumbnail, then the player takes over (v1.5).\n * - \"click\" (default for YouTube, whose embed is a thumbnail + play button anyway): thumbnail +\n *   play button, the player loads on click only. Opt-in for any video with\n *   data-jl-wistia-facade=\"click\" on an ancestor; data-jl-wistia-facade=\"lazy\" keeps a\n *   YouTube video in lazy mode.\n *\n * Install: classic synchronous <script> at the very top of the <head>\n * (no async, no defer, no type=\"module\"), so it runs before the iframes are parsed.\n * Opt-out: data-jl-wistia-facade=\"off\" on any ancestor of the video.\n */\n(function () {\n  'use strict';\n  if (window.__jlWistiaFacade) return;\n  window.__jlWistiaFacade = true;\n  var doc = document;\n  var ALLOW = 'autoplay; fullscreen; encrypted-media; picture-in-picture';\n  // Containers managed by other site scripts (popups, exercise previews already built by the site)\n  var SKIP = '[data-jl-wistia-facade=\"off\"],[cd-popup-wrap],[cd-popup-root],[data-jl-video-preview],[data-media-stage]';\n  // Lazy mode: start loading a video when it is within 1.5 screen heights of the viewport\n  var MARGIN = '150% 0px';\n  // No player before the page has loaded (window load + idle time), at most this long after start\n  var START_CAP = 8000;\n  var lazyObserver = null, posterObserver = null, started = false, waiting = [];\n\n  // Before the page has loaded, a video on screen shows its still thumbnail inside the empty iframe\n  function posterDoc(url) {\n    return '<!doctype html><style>html,body{margin:0;height:100%;background:#000 url(' + JSON.stringify(url) +\n      ') center/cover no-repeat}</style>';\n  }\n\n  function release(frame) {\n    frame.removeAttribute('srcdoc'); // the iframe now loads its current src\n    frame.removeAttribute('data-jl-wistia-lazy');\n  }\n\n  function observeLazy(frame) {\n    if (!lazyObserver) {\n      lazyObserver = new IntersectionObserver(function (entries) {\n        entries.forEach(function (entry) {\n          if (!entry.isIntersecting) return;\n          lazyObserver.unobserve(entry.target);\n          release(entry.target);\n        });\n      }, { rootMargin: MARGIN });\n    }\n    lazyObserver.observe(frame);\n  }\n\n  function start() {\n    if (started) return;\n    started = true;\n    if (posterObserver) posterObserver.disconnect();\n    waiting.forEach(observeLazy);\n    waiting = null;\n  }\n\n  function lazyLoad(frame, info) {\n    if (!('IntersectionObserver' in window)) return;\n    frame.setAttribute('srcdoc', ''); // srcdoc wins over src: nothing is loaded, src stays readable and editable\n    frame.setAttribute('data-jl-wistia-lazy', '');\n    if (started) return observeLazy(frame);\n    waiting.push(frame);\n    var poster = posterUrl(info);\n    if (!poster) return;\n    if (!posterObserver) {\n      posterObserver = new IntersectionObserver(function (entries) {\n        entries.forEach(function (entry) {\n          if (!entry.isIntersecting) return;\n          posterObserver.unobserve(entry.target);\n          if (!started && entry.target.getAttribute('srcdoc') === '') entry.target.setAttribute('srcdoc', posterDoc(entry.target.__jlPoster));\n        });\n      });\n    }\n    frame.__jlPoster = poster;\n    posterObserver.observe(frame);\n  }\n\n  function whenLoaded() {\n    var idle = window.requestIdleCallback || function (fn) { return setTimeout(fn, 200); };\n    idle(start, { timeout: 1500 });\n  }\n  if (doc.readyState === 'complete') whenLoaded();\n  else window.addEventListener('load', whenLoaded, { once: true });\n  setTimeout(start, START_CAP);\n\n  var CSS =\n    '.jl-wistia-facade{position:absolute;inset:0;z-index:1;width:100%;height:100%;padding:0;margin:0;border:0;background:#000;cursor:pointer;overflow:hidden;display:block}' +\n    '.jl-wistia-facade img{width:100%;height:100%;object-fit:cover;display:block;pointer-events:none}' +\n    '.jl-wistia-facade__play{position:absolute;left:50%;top:50%;width:4.5rem;height:4.5rem;margin:-2.25rem 0 0 -2.25rem;border-radius:50%;background:rgba(0,0,0,.6);transition:transform .2s ease,background-color .2s ease}' +\n    '.jl-wistia-facade__play::after{content:\"\";position:absolute;left:52%;top:50%;transform:translate(-50%,-50%);border-style:solid;border-width:.8rem 0 .8rem 1.35rem;border-color:transparent transparent transparent #fff}' +\n    '.jl-wistia-facade:hover .jl-wistia-facade__play{transform:scale(1.08);background:rgba(0,0,0,.8)}' +\n    '.jl-wistia-facade:focus-visible{outline:2px solid currentColor;outline-offset:2px}';\n\n  function injectStyle() {\n    if (doc.getElementById('jl-wistia-facade-css')) return;\n    var style = doc.createElement('style');\n    style.id = 'jl-wistia-facade-css';\n    style.textContent = CSS;\n    (doc.head || doc.documentElement).appendChild(style);\n  }\n\n  // Resolve an Embedly, Wistia, YouTube or Vimeo iframe URL to { kind, id, image, player }\n  function resolve(src) {\n    try {\n      var u = new URL(src, location.href), image = null, host, id, m, q;\n      for (var i = 0; i < 3 && /(^|\\.)embedly\\.com$/.test(u.hostname); i++) {\n        image = image || u.searchParams.get('image');\n        u = new URL(u.searchParams.get('src'));\n      }\n      host = u.hostname;\n      if (/(^|\\.)wistia\\.(net|com)$/.test(host)) {\n        id = (u.pathname.match(/\\/(?:iframe|medias)\\/([a-z0-9]+)/i) || [])[1];\n        // Same URL shape as the site's jl-wistia-native-frames script, so it does not reload it\n        return id ? { kind: 'wistia', id: id, image: image, player: 'https://fast.wistia.com/embed/iframe/' + id + '?autoPlay=true' } : null;\n      }\n      if (/(^|\\.)(youtube\\.com|youtube-nocookie\\.com|youtu\\.be)$/.test(host)) {\n        id = /youtu\\.be$/.test(host) ? u.pathname.split('/')[1]\n          : u.pathname === '/watch' ? u.searchParams.get('v')\n          : (u.pathname.match(/^\\/(?:embed|shorts|live)\\/([^/]+)/) || [])[1];\n        if (!/^[\\w-]{11}$/.test(id || '')) return null;\n        q = new URLSearchParams(u.search);\n        q.delete('v'); q.delete('feature');\n        q.set('autoplay', '1'); q.set('playsinline', '1');\n        return { kind: 'youtube', id: id, image: image || 'https://i.ytimg.com/vi/' + id + '/hqdefault.jpg', player: 'https://www.youtube-nocookie.com/embed/' + id + '?' + q };\n      }\n      if (/(^|\\.)loom\\.com$/.test(host) && /^\\/embed\\//.test(u.pathname)) {\n        return { kind: 'loom', id: u.pathname.split('/')[2], image: image, player: u.href };\n      }\n      if (/(^|\\.)vimeo\\.com$/.test(host)) {\n        m = u.pathname.match(/^\\/(?:video\\/)?(\\d+)(?:\\/([a-zA-Z0-9]+))?\\/?$/);\n        if (!m) return null;\n        q = new URLSearchParams(u.search);\n        if (m[2] && !q.has('h')) q.set('h', m[2]);\n        q.set('autoplay', '1'); q.set('playsinline', '1');\n        return { kind: 'vimeo', id: m[1], image: image, player: 'https://player.vimeo.com/video/' + m[1] + '?' + q };\n      }\n    } catch (e) {}\n    return null;\n  }\n\n  // Single still thumbnail URL for the pre-load poster\n  function posterUrl(info) {\n    var wistia = info.kind === 'wistia' && info.image && info.image.match(/^https:\\/\\/embed-ssl\\.wistia\\.com\\/deliveries\\/([a-f0-9]+)/);\n    if (wistia) return 'https://embed-ssl.wistia.com/deliveries/' + wistia[1] + '.webp?image_resize=960';\n    return info.image && /^https:/.test(info.image) ? info.image : null;\n  }\n\n  // Thumbnail <img>: Wistia in WebP at several widths, other providers as given by Embedly\n  function thumbnail(info) {\n    var wistia = info.kind === 'wistia' && info.image && info.image.match(/^https:\\/\\/embed-ssl\\.wistia\\.com\\/deliveries\\/([a-f0-9]+)/);\n    if (!wistia && !info.image) return null;\n    var img = doc.createElement('img');\n    if (wistia) {\n      var base = 'https://embed-ssl.wistia.com/deliveries/' + wistia[1] + '.webp?image_resize=';\n      img.src = base + 960;\n      img.srcset = [480, 960, 1440].map(function (w) { return base + w + ' ' + w + 'w'; }).join(', ');\n      img.sizes = '(max-width: 767px) 100vw, 960px';\n    } else {\n      img.src = info.image;\n    }\n    img.alt = '';\n    img.loading = 'lazy';\n    img.decoding = 'async';\n    return img;\n  }\n\n  function facade(frame) {\n    if (frame.__jlFacade) return;\n    var stage = frame.parentElement;\n    if (!stage || frame.closest(SKIP)) return;\n    var rich = !!frame.closest('figure.w-richtext-figure-type-video');\n    if (!rich && !stage.classList.contains('w-video')) return;\n    var info = resolve(frame.getAttribute('src') || '');\n    if (!info) return;\n    frame.__jlFacade = true;\n\n    var click = info.kind === 'youtube' ? !frame.closest('[data-jl-wistia-facade=\"lazy\"]') : !!frame.closest('[data-jl-wistia-facade=\"click\"]');\n    if (!click || (info.kind === 'loom' && !info.image)) {\n      lazyLoad(frame, info);\n      return;\n    }\n    injectStyle();\n\n    var english = (doc.documentElement.lang || '').indexOf('en') === 0;\n    var title = frame.getAttribute('title');\n    if (!title || /^(Wistia|YouTube|Vimeo)/i.test(title)) title = english ? 'Video' : 'Vidéo';\n\n    // Stop the iframe before it loads the player and buffers the video\n    if (rich) {\n      frame.removeAttribute('src');\n      frame.remove();\n    } else {\n      frame.setAttribute('srcdoc', ''); // srcdoc wins over src: nothing is loaded, src stays readable\n      frame.setAttribute('tabindex', '-1');\n      frame.setAttribute('aria-hidden', 'true');\n    }\n\n    var button = doc.createElement('button');\n    button.type = 'button';\n    button.className = 'jl-wistia-facade';\n    button.setAttribute('data-ascii-images', 'off');\n    button.setAttribute('cd-lightbox-exclude', ''); // keep the site's image lightbox off the thumbnail\n    button.setAttribute('aria-label', (english ? 'Play video: ' : 'Lire la vidéo : ') + title);\n    var img = thumbnail(info);\n    if (img) button.appendChild(img);\n    var play = doc.createElement('span');\n    play.className = 'jl-wistia-facade__play';\n    play.setAttribute('aria-hidden', 'true');\n    button.appendChild(play);\n    stage.appendChild(button);\n\n    button.addEventListener('click', function () {\n      if (rich) {\n        var player = doc.createElement('iframe');\n        player.__jlFacade = true; // the observer must not turn the real player back into a facade\n        player.src = info.player;\n        player.title = title;\n        player.allow = ALLOW;\n        player.allowFullscreen = true;\n        player.setAttribute('frameborder', '0');\n        player.setAttribute('scrolling', 'no');\n        ['width', 'height'].forEach(function (a) { if (frame.getAttribute(a)) player.setAttribute(a, frame.getAttribute(a)); });\n        stage.replaceChild(player, button);\n      } else {\n        frame.allow = ALLOW;\n        frame.allowFullscreen = true;\n        frame.src = info.player;\n        frame.removeAttribute('tabindex');\n        frame.removeAttribute('aria-hidden');\n        frame.removeAttribute('srcdoc'); // the iframe now loads its src\n        button.remove();\n      }\n    }, { once: true });\n  }\n\n  function scan(node) {\n    if (node.nodeType !== 1) return;\n    if (node.tagName === 'IFRAME') facade(node);\n    else if (node.getElementsByTagName) Array.prototype.forEach.call(node.getElementsByTagName('iframe'), facade);\n  }\n\n  // Catch iframes as the parser inserts them, then a final pass and stop at DOMContentLoaded\n  // (the videos are in the HTML; no need to watch later DOM churn)\n  var observer = new MutationObserver(function (records) {\n    records.forEach(function (r) { r.addedNodes.forEach(scan); });\n  });\n  observer.observe(doc.documentElement, { childList: true, subtree: true });\n  if (doc.readyState === 'loading') {\n    doc.addEventListener('DOMContentLoaded', function () { observer.disconnect(); scan(doc.documentElement); }, { once: true });\n  } else {\n    // Loaded too late (async/defer): still convert what is there, but the videos may already have started loading\n    observer.disconnect();\n    scan(doc.documentElement);\n  }\n})();\n"]}