import { c as k, p as O, h as A, f as w, i as S, b as h, d as C, u as M, r as W, s as I, D as Y, o as j, n as H } from "./AssetItem-ufNA-vj9.js";
import { a as J } from "./index-client-DOkVNeOk.js";
import { t as R, n as K, D as U, m as B, v as N, o as Q, p as X, w as y, z as L, E as s, C as c, x as b, r as q, l as T, y as V, A as Z, I as D, L as P, W as ee, F as te } from "./index-DRgrWhNH.js";
import { D as re, a as $ } from "./constants-ByF0HyKB.js";
import { i as se } from "./validation-DaZvZUPL.js";
import { s as oe } from "./ProgressVideo.service-BmjtnZZl.js";
import { B as ae } from "./Button-Dvas4qfY.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 z(p, a) {
  if (new.target) return k({ component: z, ...p });
  R(a, !1);
  const r = B();
  let v = O(a, "isProgressFinished", 12), i = O(a, "options", 12), { text: n, onSetVideoEnded: u } = i();
  K(() => N(i()), () => {
    U(r, i().selected);
  }), Q();
  var f = {
    get isProgressFinished() {
      return v();
    },
    set isProgressFinished(e) {
      v(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(), _ = X(d), l = y(_);
  {
    var x = (e) => {
      var t = ie(), m = y(t, !0);
      b(t), V(() => W(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", (s(r), c(() => `${s(r).src}?autoplay=1&mute=1`)))), h(e, t);
    }, o = (e) => {
      var t = de();
      t.muted = !0;
      var m = y(t);
      Z(), b(t), V(() => I(m, "src", (s(r), c(() => s(r).src)))), h(e, t);
    };
    S(F, (e) => {
      s(r), c(() => s(r).embedded) ? e(E) : (s(r), c(() => s(r).src) && e(o, 1));
    });
  }
  b(_);
  var g = L(_, 2);
  {
    var G = (e) => {
      var t = le(), m = y(t);
      ae(m, {
        get onClick() {
          return u;
        },
        text: "Skip"
      }), b(t), h(e, t);
    };
    S(g, (e) => {
      v() && e(G);
    });
  }
  return h(p, d), q(f);
}
function pe(p, a) {
  if (new.target) return k({ component: pe, ...p });
  R(a, !1);
  const r = () => j(P, "$pageOptsStore", v), [v, i] = H();
  var n, u, f, d;
  const _ = ((n = D(P)) === null || n === void 0 ? void 0 : n.loaderText) || re, l = ((u = D(P)) === null || u === void 0 ? void 0 : u.progressVideos) || ((d = (f = D(ee)) === null || f === void 0 ? void 0 : f.content) === null || d === void 0 ? void 0 : d.progressVideos) || [$];
  let x = B($);
  J(() => {
    const o = Math.floor(Math.random() * l.length);
    U(x, se(l[o].src) ? l[o] : $);
  });
  var F = {
    $set: M,
    $on: (o, g) => C(a, o, g)
  };
  A();
  {
    let o = te(() => ({
      text: _,
      selected: s(x),
      onSetVideoEnded: oe
    }));
    z(p, {
      get options() {
        return s(o);
      },
      get isProgressFinished() {
        return r().isProgressFinished;
      },
      set isProgressFinished(g) {
        Y(P, c(r).isProgressFinished = g, c(r));
      },
      $$legacy: !0
    });
  }
  var E = q(F);
  return i(), E;
}
export {
  pe as default
};
//# sourceMappingURL=ProgressVideo-f0nY6lio.js.map
