import { S as SvelteComponent, i as init, s as safe_not_equal, e as element, a as append, b as add_render_callback, c as space, t as text, d as attr, q as null_to_empty, g as insert, l as listen, j as set_data, h as detach, r as run_all, k as empty, n as noop, o as onMount, m as globals } from "./embed.js"; import { d as determinePlatform, c as checkMatchConditions, a as convertToMS } from "./helpers.js"; const mdbExitedCookie = "tc_mdb_exited"; function getTTLCookie() { const cookie = document.cookie.split(";").map((cookie2) => cookie2.trim()).find((cookie2) => cookie2.startsWith(mdbExitedCookie + "=")); return cookie ? cookie.substring(mdbExitedCookie.length + 1) : null; } const setTTLCookie = (timeInMS) => { const cookieParams = []; const expiryTime = new Date(timeInMS); cookieParams.push(`${mdbExitedCookie}=1`); cookieParams.push("path=/"); cookieParams.push("expires=" + new Date(expiryTime).toUTCString()); const cookie = cookieParams.join("; "); document.cookie = cookie; }; const { window: window_1 } = globals; function add_css() { var style = element("style"); style.id = "svelte-vzkjil-style"; style.textContent = '@font-face{font-family:system;font-style:normal;font-weight:600;src:local(-apple-system), local(BlinkMacSystemFont), local(".SFNSText-Medium"), local(".HelveticaNeueDeskInterface-medium"), local(".LucidaGrandeUI"), local("Ubuntu Medium"), local("Segoe UI Medium"), local("Roboto-Medium"), local("DroidSans"), local("Tahoma")}@font-face{font-family:system-light;font-style:normal;font-weight:lighter;src:local(-apple-system), local(BlinkMacSystemFont), local(".SFNSText-Light"), local(".HelveticaNeueDeskInterface-Light"), local(".LucidaGrandeUI"), local("Ubuntu Light"), local("Segoe UI Light"), local("Roboto-Light"), local("DroidSans"), local("Tahoma")}.tc-mobile-download-banner-container.svelte-vzkjil.svelte-vzkjil{position:fixed;left:0;right:0;margin:0 auto;z-index:2147483647;width:90vw;border-radius:10px;box-shadow:rgba(0, 0, 0, 0.2) 0px 2px 16px 0px}.tc-mobile-download-banner-top.svelte-vzkjil.svelte-vzkjil{top:calc(env(safe-area-inset-top, 0) + 20px)}.tc-mobile-download-banner-bottom.svelte-vzkjil.svelte-vzkjil{bottom:calc(env(safe-area-inset-bottom, 0) + 20px)}.tc-mobile-download-banner-content.svelte-vzkjil.svelte-vzkjil{display:flex;background-color:#fff;padding:12px 24px 12px 15px;align-items:center;max-height:84px;justify-content:space-between;border-radius:10px}.tc-mdb-column.svelte-vzkjil.svelte-vzkjil{display:flex;align-items:center;justify-content:center}.tc-mdb-column-2.svelte-vzkjil.svelte-vzkjil{margin-right:5px}.tc-mobile-download-banner-app-icon.svelte-vzkjil.svelte-vzkjil{max-width:60px;max-height:60px;box-shadow:0 5px 12px 0 rgba(0, 0, 0, 0.2);border-radius:8.5px;overflow:hidden}.tc-mobile-download-banner-app-icon.svelte-vzkjil .tc-mobile-download-banner-app-icon-image.svelte-vzkjil{width:100%;height:100%}.tc-mobile-download-banner-text.svelte-vzkjil.svelte-vzkjil{display:block;font-size:12px;margin-left:15px;line-height:16px;letter-spacing:0.03px;overflow:hidden}.tc-mobile-download-banner-subtitle.svelte-vzkjil.svelte-vzkjil{font-family:system-light;font-weight:lighter;font-size:10px;line-height:15px;letter-spacing:0.04pt;max-width:130px;word-break:break-word}.tc-mobile-download-banner-download-button.svelte-vzkjil.svelte-vzkjil{width:100%}.tc-mobile-download-banner-download-button.svelte-vzkjil a.svelte-vzkjil,.tc-mobile-download-banner-download-button.svelte-vzkjil button.svelte-vzkjil{text-decoration:none}.tc-mobile-download-banner-download-button.svelte-vzkjil button.svelte-vzkjil{background:black;color:white;font-size:12px;padding:10px 15px;border-radius:18px;line-height:15px;letter-spacing:1px;border:none;min-width:70px;text-transform:uppercase;text-decoration:none;display:flex;flex:1;justify-content:center}.tc-mdb-close-button.svelte-vzkjil.svelte-vzkjil{position:absolute;top:-10px;right:-6px;display:block;margin:0;width:28px;height:28px;border:0;text-align:center;border-radius:14px;background-color:#d7d7d7}.tc-mdb-close-button.svelte-vzkjil a.svelte-vzkjil{display:block !important}.tc-mdb-close-button.svelte-vzkjil .svelte-vzkjil::before,.tc-mdb-close-button.svelte-vzkjil .svelte-vzkjil::after{position:absolute;width:2px;height:16px;background:#4f4f4f;content:" ";top:6px}.tc-mdb-close-button.svelte-vzkjil .svelte-vzkjil::before{transform:rotate(45deg)}.tc-mdb-close-button.svelte-vzkjil .svelte-vzkjil::after{transform:rotate(-45deg)}@media(min-width: 768px){.tc-mobile-download-banner-title.svelte-vzkjil.svelte-vzkjil{font-size:16px;margin-bottom:4px}.tc-mobile-download-banner-subtitle.svelte-vzkjil.svelte-vzkjil{font-size:14px;max-width:240px}.tc-mobile-download-banner-download-button.svelte-vzkjil button.svelte-vzkjil{width:130px;padding:16px 20px 16px 20px;border-radius:24px;font-size:14px}}'; append(document.head, style); } function create_if_block(ctx) { var _a, _b, _c; let div9; let div7; let div4; let div0; let img; let img_src_value; let t0; let div3; let div1; let span0; let t1_value = ((_a = ctx[0]) == null ? void 0 : _a.title) + ""; let t1; let t2; let div2; let span1; let t3_value = ((_b = ctx[6]) == null ? void 0 : _b.title) + ""; let t3; let t4; let div6; let div5; let button; let t5_value = ((_c = ctx[6]) == null ? void 0 : _c.button) + ""; let t5; let button_style_value; let div7_style_value; let t6; let div8; let a; let a_href_value; let div9_class_value; let div9_style_value; let mounted; let dispose; return { c() { var _a2; div9 = element("div"); div7 = element("div"); div4 = element("div"); div0 = element("div"); img = element("img"); t0 = space(); div3 = element("div"); div1 = element("div"); span0 = element("span"); t1 = text(t1_value); t2 = space(); div2 = element("div"); span1 = element("span"); t3 = text(t3_value); t4 = space(); div6 = element("div"); div5 = element("div"); button = element("button"); t5 = text(t5_value); t6 = space(); div8 = element("div"); a = element("a"); if (img.src !== (img_src_value = (_a2 = ctx[0]) == null ? void 0 : _a2.icon)) attr(img, "src", img_src_value); attr(img, "alt", "App Icon"); attr(img, "class", "tc-mobile-download-banner-app-icon-image svelte-vzkjil"); attr(div0, "class", "tc-mobile-download-banner-app-icon svelte-vzkjil"); attr(span0, "class", "svelte-vzkjil"); attr(div1, "class", "tc-mobile-download-banner-title svelte-vzkjil"); attr(span1, "class", "svelte-vzkjil"); attr(div2, "class", "tc-mobile-download-banner-subtitle svelte-vzkjil"); attr(div3, "class", "tc-mobile-download-banner-text svelte-vzkjil"); attr(div4, "class", "tc-mdb-column tc-mdb-column-1 svelte-vzkjil"); attr(button, "class", "tc-mobile-download-banner-download-button-text svelte-vzkjil"); attr(button, "style", button_style_value = `background: ${ctx[3].buttonBackground}; color: ${ctx[3].buttonText};`); attr(div5, "class", "tc-mobile-download-banner-download-button svelte-vzkjil"); attr(div6, "class", "tc-mdb-column tc-mdb-column-2 svelte-vzkjil"); attr(div7, "class", "tc-mobile-download-banner-content svelte-vzkjil"); attr(div7, "style", div7_style_value = ` background-color: ${ctx[3].background}; color: ${ctx[3].title}; `); attr(a, "href", a_href_value = "#"); attr(a, "aria-label", "close"); attr(a, "role", "button"); attr(a, "class", "svelte-vzkjil"); attr(div8, "class", "tc-mdb-close-button svelte-vzkjil"); attr(div9, "class", div9_class_value = null_to_empty(`tc-mobile-download-banner-container ${`tc-mobile-download-banner-${ctx[2]}`}`) + " svelte-vzkjil"); attr(div9, "id", "tapcart-web-banner"); attr(div9, "style", div9_style_value = `font-family: ${ctx[1].family}`); }, m(target, anchor) { insert(target, div9, anchor); append(div9, div7); append(div7, div4); append(div4, div0); append(div0, img); append(div4, t0); append(div4, div3); append(div3, div1); append(div1, span0); append(span0, t1); append(div3, t2); append(div3, div2); append(div2, span1); append(span1, t3); append(div7, t4); append(div7, div6); append(div6, div5); append(div5, button); append(button, t5); append(div9, t6); append(div9, div8); append(div8, a); if (!mounted) { dispose = [ listen(button, "click", ctx[13]), listen(a, "click", ctx[8]), listen(div8, "click", ctx[8]) ]; mounted = true; } }, p(ctx2, dirty) { var _a2, _b2, _c2, _d; if (dirty & 1 && img.src !== (img_src_value = (_a2 = ctx2[0]) == null ? void 0 : _a2.icon)) { attr(img, "src", img_src_value); } if (dirty & 1 && t1_value !== (t1_value = ((_b2 = ctx2[0]) == null ? void 0 : _b2.title) + "")) set_data(t1, t1_value); if (dirty & 64 && t3_value !== (t3_value = ((_c2 = ctx2[6]) == null ? void 0 : _c2.title) + "")) set_data(t3, t3_value); if (dirty & 64 && t5_value !== (t5_value = ((_d = ctx2[6]) == null ? void 0 : _d.button) + "")) set_data(t5, t5_value); if (dirty & 8 && button_style_value !== (button_style_value = `background: ${ctx2[3].buttonBackground}; color: ${ctx2[3].buttonText};`)) { attr(button, "style", button_style_value); } if (dirty & 8 && div7_style_value !== (div7_style_value = ` background-color: ${ctx2[3].background}; color: ${ctx2[3].title}; `)) { attr(div7, "style", div7_style_value); } if (dirty & 4 && div9_class_value !== (div9_class_value = null_to_empty(`tc-mobile-download-banner-container ${`tc-mobile-download-banner-${ctx2[2]}`}`) + " svelte-vzkjil")) { attr(div9, "class", div9_class_value); } if (dirty & 2 && div9_style_value !== (div9_style_value = `font-family: ${ctx2[1].family}`)) { attr(div9, "style", div9_style_value); } }, d(detaching) { if (detaching) detach(div9); mounted = false; run_all(dispose); } }; } function create_fragment(ctx) { let if_block_anchor; let mounted; let dispose; add_render_callback(ctx[12]); let if_block = ctx[7] && create_if_block(ctx); return { c() { if (if_block) if_block.c(); if_block_anchor = empty(); }, m(target, anchor) { if (if_block) if_block.m(target, anchor); insert(target, if_block_anchor, anchor); if (!mounted) { dispose = listen(window_1, "resize", ctx[12]); mounted = true; } }, p(ctx2, [dirty]) { if (ctx2[7]) { if (if_block) { if_block.p(ctx2, dirty); } else { if_block = create_if_block(ctx2); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } } else if (if_block) { if_block.d(1); if_block = null; } }, i: noop, o: noop, d(detaching) { if (if_block) if_block.d(detaching); if (detaching) detach(if_block_anchor); mounted = false; dispose(); } }; } const language = "en"; function navigate(url) { if (url) { window.open(url, "_blank"); } } function instance($$self, $$props, $$invalidate) { let { appInfo } = $$props; let { enabled } = $$props; let { font } = $$props; let { text: text2 } = $$props; let { placement = "bottom" } = $$props; let { colors = { background: "#FFF", title: "#000", buttonBackground: "#000", buttonText: "#FFF" } } = $$props; let { display = { frequency: { period: 24, unit: "hours" }, on: "all", triggerDelayInMS: 0 } } = $$props; let innerWidth = window.innerWidth; let devicePlatform; let downloadLink; let textFields; let showBanner = false; const determinePageDisplay = () => { const currentUrl = window.location.href; let shouldDisplay = true; switch (display.on) { case "and": const allShouldMatch = display.matches.every((match) => { const { value: matchCondition, url: urlToMatch } = match; return checkMatchConditions({ matchCondition, urlToMatch, currentUrl }); }); shouldDisplay = allShouldMatch; break; case "or": const someShouldMatch = display.matches.some((match) => { const { value: matchCondition, url: urlToMatch } = match; return checkMatchConditions({ matchCondition, urlToMatch, currentUrl }); }); shouldDisplay = someShouldMatch; break; case "all": default: shouldDisplay = true; break; } return shouldDisplay; }; const getDownloadLink = (platform) => { if (platform === "ios") { return appInfo.appStoreLink; } else if (platform === "android") { return appInfo.playStoreLink; } }; const closeBanner = (event) => { event.preventDefault(); $$invalidate(7, showBanner = false); const additionalMS = convertToMS(display.frequency.period, display.frequency.unit); const expiryTime = new Date().getTime() + additionalMS; setTTLCookie(expiryTime); }; onMount(() => { if (!enabled) { $$invalidate(7, showBanner = false); return; } setTimeout(() => { $$invalidate(7, showBanner = true); devicePlatform = determinePlatform(); $$invalidate(5, downloadLink = getDownloadLink(devicePlatform)); $$invalidate(6, textFields = text2[language] || text2.en); const shouldDisplayBannerOnPage = determinePageDisplay(); if (!shouldDisplayBannerOnPage) { $$invalidate(7, showBanner = false); } const validDevicePlatform = devicePlatform === "ios" || devicePlatform === "android"; if (!validDevicePlatform) { $$invalidate(7, showBanner = false); } const bannerExitedCookie = getTTLCookie(); if (bannerExitedCookie) { $$invalidate(7, showBanner = false); } }, display.triggerDelayInMS); }); function onwindowresize() { $$invalidate(4, innerWidth = window_1.innerWidth); } const click_handler = () => navigate(downloadLink); $$self.$$set = ($$props2) => { if ("appInfo" in $$props2) $$invalidate(0, appInfo = $$props2.appInfo); if ("enabled" in $$props2) $$invalidate(9, enabled = $$props2.enabled); if ("font" in $$props2) $$invalidate(1, font = $$props2.font); if ("text" in $$props2) $$invalidate(10, text2 = $$props2.text); if ("placement" in $$props2) $$invalidate(2, placement = $$props2.placement); if ("colors" in $$props2) $$invalidate(3, colors = $$props2.colors); if ("display" in $$props2) $$invalidate(11, display = $$props2.display); }; return [ appInfo, font, placement, colors, innerWidth, downloadLink, textFields, showBanner, closeBanner, enabled, text2, display, onwindowresize, click_handler ]; } class MobileDownloadBanner extends SvelteComponent { constructor(options) { super(); if (!document.getElementById("svelte-vzkjil-style")) add_css(); init(this, options, instance, create_fragment, safe_not_equal, { appInfo: 0, enabled: 9, font: 1, text: 10, placement: 2, colors: 3, display: 11 }); } } export { MobileDownloadBanner as default };