import { c as k, p as D, h as A, f as w, i as S, b as h, d as C, u as M, o as z, s as I } from "./AssetItem-CFsdMEwW.js";
import { a as Q } from "./index-client-DJaMHbvZ.js";
import { v as R, o as j, G as U, m as B, w as H, p as J, r as K, x as y, A as L, I as r, D as c, y as b, t as G, n as T, z as V, C as N, M as $, Q as P, c0 as W, L as X, c1 as O, c2 as Z, F as ee, Y as te, E as se, c3 as re } from "./index-BxjwuJ6T.js";
import { i as oe } from "./validation-DaZvZUPL.js";
import { B as ae } from "./Button-S2OwL6nP.js";
var ie = w(`<div class="crtw-text-2xl crtw-font-bold crtw-font-['poppins'] crtw-mb-4"> </div>`), ne = w('<iframe id="videoProgressIframe" title="progress-video" frameborder="0" scrolling="no" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture;" allowfullscreen="" width="100%" style="min-height: 200px"></iframe>'), de = w('<video width="100%" controls="" autoplay=""><source/> Your browser does not support the video tag.</video>', 2), le = w('<div class="crtw-pt-4 crtw-w-full"><!></div>'), ce = w('<div class="crtw-w-full"><!> <!></div> <!>', 1);
function Y(v, a) {
  if (new.target) return k({ component: Y, ...v });
  R(a, !1);
  const s = B();
  let p = D(a, "isProgressFinished", 12), i = D(a, "options", 12), { text: n, onSetVideoEnded: u } = i();
  j(() => H(i()), () => {
    U(s, i().selected);
  }), J();
  var _ = {
    get isProgressFinished() {
      return p();
    },
    set isProgressFinished(e) {
      p(e), T();
    },
    get options() {
      return i();
    },
    set options(e) {
      i(e), T();
    },
    $set: M,
    $on: (e, t) => C(a, e, t)
  };
  A();
  var d = ce(), f = K(d), l = y(f);
  {
    var x = (e) => {
      var t = ie(), m = y(t, !0);
      b(t), V(() => z(m, n)), h(e, t);
    };
    S(l, (e) => {
      n && e(x);
    });
  }
  var F = L(l, 2);
  {
    var E = (e) => {
      var t = ne();
      V(() => I(t, "src", (r(s), c(() => `${r(s).src}?autoplay=1&mute=1`)))), h(e, t);
    }, o = (e) => {
      var t = de();
      t.muted = !0;
      var m = y(t);
      N(), b(t), V(() => I(m, "src", (r(s), c(() => r(s).src)))), h(e, t);
    };
    S(F, (e) => {
      r(s), c(() => r(s).embedded) ? e(E) : (r(s), c(() => r(s).src) && e(o, 1));
    });
  }
  b(f);
  var g = L(f, 2);
  {
    var q = (e) => {
      var t = le(), m = y(t);
      ae(m, {
        get onClick() {
          return u;
        },
        text: "Skip"
      }), b(t), h(e, t);
    };
    S(g, (e) => {
      p() && e(q);
    });
  }
  return h(v, d), G(_);
}
function ve(v, a) {
  if (new.target) return k({ component: ve, ...v });
  R(a, !1);
  const s = () => ee(P, "$pageOptsStore", p), [p, i] = se();
  var n, u, _, d;
  const f = ((n = $(P)) === null || n === void 0 ? void 0 : n.loaderText) || W, l = ((u = $(P)) === null || u === void 0 ? void 0 : u.progressVideos) || ((d = (_ = $(X)) === null || _ === void 0 ? void 0 : _.content) === null || d === void 0 ? void 0 : d.progressVideos) || [O];
  let x = B(O);
  Q(() => {
    const o = Math.floor(Math.random() * l.length);
    U(x, oe(l[o].src) ? l[o] : O);
  });
  var F = {
    $set: M,
    $on: (o, g) => C(a, o, g)
  };
  A();
  {
    let o = te(() => ({
      text: f,
      selected: r(x),
      onSetVideoEnded: re
    }));
    Y(v, {
      get options() {
        return r(o);
      },
      get isProgressFinished() {
        return s().isProgressFinished;
      },
      set isProgressFinished(g) {
        Z(P, c(s).isProgressFinished = g, c(s));
      },
      $$legacy: !0
    });
  }
  var E = G(F);
  return i(), E;
}
export {
  ve as default
};
//# sourceMappingURL=ProgressVideo-C0mOhkcx.js.map
