1var __defProp = Object.defineProperty; 2var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 3var __publicField = (obj, key, value) => { 4 __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); 5 return value; 6}; 7var _a, _b; 8import { c as clsx, S as SvelteComponent, i as init, s as safe_not_equal, a as assign, B as Button$1, b as create_component, m as mount_component, g as get_spread_update, d as get_spread_object, t as transition_in, e as transition_out, f as destroy_component, h as compute_rest_props, j as exclude_internal_props, k as bubble, l as create_slot, n as space, o as element, p as insert, u as update_slot_base, q as get_all_dirty_from_scope, r as get_slot_changes, v as detach, w as svg_element, x as attr, y as append, z as derived, A as writable, C as text, D as group_outros, E as check_outros, F as set_data, G as component_subscribe, H as createQuery, I as createMutation, J as empty, X, K as listen, L as Gift, M as noop, N as src_url_equal, O as Check, P as ensure_array_like, Q as destroy_each, R as useQueryClient, T as HtmlTag, U as CheckCircle, V as set_style, W as construct_svelte_component, Y as is_function, Z as tweened, _ as cubicOut, $ as null_to_empty, a0 as Share2, a1 as Users, a2 as UserCheck, a3 as Copy, a4 as createQueries, a5 as Tag, a6 as BadgeEuro, a7 as ShoppingBag, a8 as Layers, a9 as QueryClientProvider, aa as MutationCache, ab as onMount, ac as QueryClient } from "./vendor-d10cda1d.js"; 9function replaceStrings$1(text2, obj) { 10 return obj.reduce((acc, replacementObj) => { 11 Object.entries(replacementObj).forEach(([key, value]) => { 12 const regex = new RegExp(`{{\\s*${key.slice(2, -2).trim()}\\s*}}`, "g"); 13 acc = acc.replace(regex, value ?? ""); 14 }); 15 return acc; 16 }, text2); 17} 18let currentNonce = ""; 19let currentTimestamp = 0; 20try { 21 const storedNonceValue = window.localStorage.getItem("cpops:storeApiNonce"); 22 const parsedNonce = storedNonceValue ? JSON.parse(storedNonceValue) : null; 23 currentNonce = (parsedNonce == null ? void 0 : parsedNonce.nonce) ?? ""; 24 currentTimestamp = (parsedNonce == null ? void 0 : parsedNonce.timestamp) ?? 0; 25} catch { 26} 27function isStoreApiRequest(options) { 28 const url = options.url ?? options.path; 29 if (!url) { 30 return false; 31 } 32 if (options.method === "GET") { 33 return false; 34 } 35 return /wc\/store\/v1\//.exec(url) !== null; 36} 37function setNonce(headers) { 38 let nonce = null; 39 let timestamp = null; 40 if (headers instanceof Headers) { 41 nonce = headers.get("Nonce"); 42 timestamp = headers.get("Nonce-Timestamp"); 43 } else if (typeof headers === "object" && headers !== null) { 44 nonce = headers.Nonce; 45 timestamp = headers["Nonce-Timestamp"]; 46 } 47 if (nonce) { 48 updateNonce(nonce, timestamp); 49 } 50} 51function updateNonce(nonce, timestamp) { 52 if (nonce === currentNonce) { 53 return; 54 } 55 if (currentTimestamp && timestamp && Number(timestamp) < currentTimestamp) { 56 return; 57 } 58 currentNonce = nonce; 59 currentTimestamp = Number(timestamp) ?? Date.now() / 1e3; 60 window.localStorage.setItem( 61 "cpops:storeApiNonce", 62 JSON.stringify({ 63 nonce: currentNonce, 64 timestamp: currentTimestamp 65 }) 66 ); 67} 68function appendNonceHeader(request2) { 69 const headers = request2.headers ?? {}; 70 request2.headers = { 71 ...headers, 72 Nonce: currentNonce 73 }; 74 return request2; 75} 76const wcStoreApiNonceMiddleware = (options, next) => { 77 var _a2; 78 if (isStoreApiRequest(options)) { 79 options = appendNonceHeader(options); 80 if (Array.isArray((_a2 = options == null ? void 0 : options.data) == null ? void 0 : _a2.requests)) { 81 options.data.requests = options.data.requests.map(appendNonceHeader); 82 } 83 } 84 return next(options); 85}; 86const logMiddleware = (options, next) => { 87 const start = Date.now(); 88 const result = next(options); 89 result.then(() => { 90 console.info(`[api: ${options.method}] ${options.path} ${Date.now() - start}ms`); 91 }).catch((e) => { 92 console.error(`[api: ${options.method}] ${options.path} ${Date.now() - start}
92ms`, e); 93 }); 94 return result; 95}; 96wp.apiFetch.use(wcStoreApiNonceMiddleware); 97wp.apiFetch.use(logMiddleware); 98wp.apiFetch.setNonce = setNonce; 99updateNonce( 100 window.leatMiddlewareConfig.storeApiNonce, 101 window.leatMiddlewareConfig.wcStoreApiNonceTimestamp 102); 103async function request(method = "GET", path, data, options) { 104 return wp.apiFetch({ path, method, data, ...options }).then((data2) => { 105 return { 106 data: data2, 107 error: null 108 }; 109 }).catch((e) => { 110 const err = e; 111 return { 112 data: null, 113 error: { 114 status: err ? err.data.status : 500, 115 statusText: err ? err.code : "unknown", 116 data: err ? err.message : "unknown" 117 } 118 }; 119 }); 120} 121const api = { 122 get: (path, options) => { 123 return request("GET", path, void 0, options); 124 }, 125 post: (path, data, options) => { 126 return request("POST", path, data, options); 127 }, 128 put: (path, data, options) => { 129 return request("PUT", path, data, options); 130 }, 131 delete: (path, options) => { 132 return request("DELETE", path, void 0, options); 133 } 134}; 135class LeatApiError extends Error { 136 constructor(status, statusText, data) { 137 super(`LeatApiError: ${statusText}`); 138 this.status = status; 139 this.statusText = statusText; 140 this.data = data; 141 this.message = data; 142 } 143} 144async function getCoupons(userId) { 145 const endpoint = "/leat/v1/coupons"; 146 const url = userId !== null ? `${endpoint}?userId=${userId}` : endpoint; 147 const { data, error } = await api.get(url); 148 if (error) { 149 throw new LeatApiError(error.status, error.statusText, error.data); 150 } 151 return data; 152} 153async function getContact(userId) { 154 const endpoint = "/leat/v1/contact"; 155 const url = `${endpoint}?userId=${userId}`; 156 const { data, error } = await api.get(url); 157 if (error) { 158 throw new LeatApiError(error.status, error.statusText, error.data); 159 } 160 return data; 161} 162async function getTiers() { 163 const { data, error } = await api.get("/leat/v1/tiers"); 164 if (error) { 165 throw new LeatApiError(error.status, error.statusText, error.data); 166 } 167 return data; 168} 169async function claimReward(earnRuleId, userId) { 170 const { data, error } = await api.post("/leat/v1/earn-reward", { 171 userId, 172 earnRuleId 173 }); 174 if (error) { 175 if (error) { 176 throw new LeatApiError(error.status, error.statusText, error.data); 177 } 178 throw new Error("No data returned"); 179 } 180 return data; 181} 182async function getEarnRules() { 183 const { data, error } = await api.get("/leat/v1/earn-rules"); 184 if (error) { 185 throw new LeatApiError(error.status, error.statusText, error.data); 186 } 187 return data; 188} 189async function getSpendRules(userId) { 190 const endpoint = "/leat/v1/spend-rules"; 191 const url = userId !== null ? `${endpoint}?userId=${userId}` : endpoint; 192 const { data, error } = await api.get(url); 193 if (error) { 194 throw new LeatApiError(error.status, error.statusText, error.data); 195 } 196 return data; 197} 198async function joinProgram(userId) { 199 const { data, error } = await api.post("/leat/v1/join-program?g", { 200 userId 201 }); 202 if (error) { 203 throw new LeatApiError(error.status, error.statusText, error.data); 204 } 205 return data; 206} 207async function claimSpendRule(spendRuleId, userId) { 208 const { data, error } = await api.post(`/leat/v1/spend-rules-claim`, { 209 userId, 210 id: spendRuleId 211 }); 212 if (error || !data) { 213 if (error) { 214 throw new LeatApiError(error.status, error.statusText, error.data); 215 } 216 throw new Error("No data returned"); 217 } 218 return data; 219} 220async function customApplyCoupon(couponCode) { 221 const { data, error } = await api.post(`/leat/v1/apply-coupon`, { 222 couponCode 223 }); 224 if (error) { 225 throw new LeatApiError(error.status, error.statusText, error.data); 226 } 227 return data; 228} 229const baseUrl = "/wc/store/v1"; 230async function getCart() { 231 try { 232 const { data, error } = await api.get(`${baseUrl}/cart`); 233 if (error) { 234 throw new LeatApiError(error.status, error.statusText, error.data); 235 } 236 if (!data) { 237 throw new LeatApiError(400, "Bad Request", "No data returned from API"); 238 } 239 return data; 240 } catch (error) { 241 console.error("Store API error getting cart:", error); 242 throw error; 243 } 244} 245async function removeCartItem(key) { 246 try { 247 const { data, error } = await api.post( 248 `${baseUrl}/cart/remove-item`, 249 { 250 key 251 } 252 ); 253 if (error) { 254 throw new LeatApiError(error.status, error.statusText, error.data); 255 } 256 if (!data) { 257 throw new LeatApiError(400, "Bad Request", "No data returned from API"); 258 } 259 return data; 260 } catch (error) { 261 console.error("Store API error removing item:", error); 262 throw error; 263 } 264} 265async function findCartItemKeyByVariationId(variationId) { 266 try { 267 const cart = await getCart(); 268 const cartItem = cart.items.find((item) => Number(item.id) === variationId); 269 return (cartItem == null ? void 0 : cartItem.key) || null; 270 } catch (error) { 271 console.error("Failed to find cart item key:", error); 272 return null; 273 } 274} 275async function removeCoupon(code) { 276 try { 277 const { error } = await api.delete(`${baseUrl}/cart/coupons/${code}`); 278 if (error) { 279 throw new LeatApiError(error.status, error.statusText, error.data); 280 } 281 return true; 282 } catch (error) { 283 console.error("Store API error removing coupon:", error); 284 throw error; 285 } 286} 287async function removeAllCoupons() { 288 try { 289 const { data, error } = await api.delete(`${baseUrl}/cart/coupons`); 290 if (error) { 291 throw new LeatApiError(error.status, error.statusText, error.data); 292 } 293 if (!data) { 294 throw new LeatApiError(400, "Bad Request", "No data returned from API"); 295 } 296 return data; 297 } catch (error) { 298 console.error("Store API error removing all coupons:", error); 299 throw error; 300 } 301} 302function replaceStrings(text2, obj) { 303 return obj.reduce((acc, replacementObj) => {
304 Object.entries(replacementObj).forEach(([key, value]) => { 305 const regex = new RegExp(`{{\\s*${key.slice(2, -2).trim()}\\s*}}`, "g"); 306 acc = acc.replace(regex, value ?? ""); 307 }); 308 return acc; 309 }, text2); 310} 311const currentLanguage$1 = ((_a = window == null ? void 0 : window.leatMiddlewareConfig) == null ? void 0 : _a.currentLanguage) || "en_US"; 312function getTranslatedText(tx) { 313 if (!tx) 314 return ""; 315 if (tx[currentLanguage$1]) { 316 return tx[currentLanguage$1] ?? ""; 317 } 318 if (tx.default) { 319 return tx.default; 320 } 321 return tx[Object.keys(tx)[0] ?? ""] ?? ""; 322} 323function getSpendRuleLabel(text2, credits, creditsName2, discount, discountType) { 324 if (!text2) 325 return ""; 326 const get_discount_type = () => { 327 if (discountType === "percentage") { 328 return `${discount}%`; 329 } else if (discountType === "fixed") { 330 const currency = window.leatWcSettings.currency.symbol; 331 return `${currency}${discount}`; 332 } else if (discountType === "free_shipping") { 333 return wp.i18n.__("Free Shipping", "leat-crm"); 334 } 335 return `${discount}`; 336 }; 337 return replaceStrings(text2, [ 338 { 339 "{{ credits_currency }}": creditsName2 ?? "", 340 "{{ credits }}": (credits == null ? void 0 : credits.toString()) ?? "0", 341 "{{ discount }}": get_discount_type() 342 } 343 ]); 344} 345function cn(...inputs) { 346 return clsx(...inputs); 347} 348const button_svelte_svelte_type_style_lang = ""; 349function create_if_block$b(ctx) { 350 let svg; 351 let circle; 352 let path; 353 return { 354 c() { 355 svg = svg_element("svg"); 356 circle = svg_element("circle"); 357 path = svg_element("path"); 358 attr(circle, "class", "leat-spinner-bg svelte-occxly"); 359 attr(circle, "cx", "12"); 360 attr(circle, "cy", "12"); 361 attr(circle, "r", "10"); 362 attr(circle, "stroke", "currentColor"); 363 attr(circle, "stroke-width", "4"); 364 attr(path, "class", "leat-spinner-fr svelte-occxly"); 365 attr(path, "fill", "currentColor"); 366 attr(path, "d", "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"); 367 attr(svg, "class", "leat-spinner leat-animate-spin svelte-occxly"); 368 attr(svg, "xmlns", "http://www.w3.org/2000/svg"); 369 attr(svg, "fill", "none"); 370 attr(svg, "viewBox", "0 0 24 24"); 371 }, 372 m(target, anchor) { 373 insert(target, svg, anchor); 374 append(svg, circle); 375 append(svg, path); 376 }, 377 d(detaching) { 378 if (detaching) { 379 detach(svg); 380 } 381 } 382 }; 383} 384function create_default_slot$6(ctx) { 385 let t; 386 let span; 387 let current; 388 let if_block = ( 389 /*loading*/ 390 ctx[1] && create_if_block$b() 391 ); 392 const default_slot_template = ( 393 /*#slots*/ 394 ctx[5].default 395 ); 396 const default_slot = create_slot( 397 default_slot_template, 398 ctx, 399 /*$$scope*/ 400 ctx[8], 401 null 402 ); 403 return { 404 c() { 405 if (if_block) 406 if_block.c(); 407 t = space(); 408 span = element("span"); 409 if (default_slot) 410 default_slot.c(); 411 }, 412 m(target, anchor) { 413 if (if_block) 414 if_block.m(target, anchor); 415 insert(target, t, anchor); 416 insert(target, span, anchor); 417 if (default_slot) { 418 default_slot.m(span, null); 419 } 420 current = true; 421 }, 422 p(ctx2, dirty) { 423 if ( 424 /*loading*/ 425 ctx2[1] 426 ) { 427 if (if_block) 428 ; 429 else { 430 if_block = create_if_block$b(); 431 if_block.c(); 432 if_block.m(t.parentNode, t); 433 } 434 } else if (if_block) { 435 if_block.d(1); 436 if_block = null; 437 } 438 if (default_slot) { 439 if (default_slot.p && (!current || dirty & /*$$scope*/ 440 256)) { 441 update_slot_base( 442 default_slot, 443 default_slot_template, 444 ctx2, 445 /*$$scope*/ 446 ctx2[8], 447 !current ? get_all_dirty_from_scope( 448 /*$$scope*/ 449 ctx2[8] 450 ) : get_slot_changes( 451 default_slot_template, 452 /*$$scope*/ 453 ctx2[8], 454 dirty, 455 null 456 ), 457 null 458 ); 459 } 460 } 461 }, 462 i(local) { 463 if (current) 464 return; 465 transition_in(default_slot, local); 466 current = true; 467 }, 468 o(local) { 469 transition_out(default_slot, local); 470 current = false;
471 }, 472 d(detaching) { 473 if (detaching) { 474 detach(t); 475 detach(span); 476 } 477 if (if_block) 478 if_block.d(detaching); 479 if (default_slot) 480 default_slot.d(detaching); 481 } 482 }; 483} 484function create_fragment$d(ctx) { 485 let buttonprimitive_root; 486 let current; 487 const buttonprimitive_root_spread_levels = [ 488 { builders: ( 489 /*builders*/ 490 ctx[3] 491 ) }, 492 { 493 class: cn("leat-button", `leat-button--${/*variant*/ 494 ctx[2]}`, { 495 "leat-button--disabled": ( 496 /*$$restProps*/ 497 ctx[4].disabled 498 ), 499 className: ( 500 /*className*/ 501 ctx[0] 502 ) 503 }) 504 }, 505 { type: "button" }, 506 /*$$restProps*/ 507 ctx[4] 508 ]; 509 let buttonprimitive_root_props = { 510 $$slots: { default: [create_default_slot$6] }, 511 $$scope: { ctx } 512 }; 513 for (let i = 0; i < buttonprimitive_root_spread_levels.length; i += 1) { 514 buttonprimitive_root_props = assign(buttonprimitive_root_props, buttonprimitive_root_spread_levels[i]); 515 } 516 buttonprimitive_root = new Button$1({ props: buttonprimitive_root_props }); 517 buttonprimitive_root.$on( 518 "click", 519 /*click_handler*/ 520 ctx[6] 521 ); 522 buttonprimitive_root.$on( 523 "keydown", 524 /*keydown_handler*/ 525 ctx[7] 526 ); 527 return { 528 c() { 529 create_component(buttonprimitive_root.$$.fragment); 530 }, 531 m(target, anchor) { 532 mount_component(buttonprimitive_root, target, anchor); 533 current = true; 534 }, 535 p(ctx2, [dirty]) { 536 const buttonprimitive_root_changes = dirty & /*builders, variant, $$restProps, className*/ 537 29 ? get_spread_update(buttonprimitive_root_spread_levels, [ 538 dirty & /*builders*/ 539 8 && { builders: ( 540 /*builders*/ 541 ctx2[3] 542 ) }, 543 dirty & /*variant, $$restProps, className*/ 544 21 && { 545 class: cn("leat-button", `leat-button--${/*variant*/ 546 ctx2[2]}`, { 547 "leat-button--disabled": ( 548 /*$$restProps*/ 549 ctx2[4].disabled 550 ), 551 className: ( 552 /*className*/ 553 ctx2[0] 554 ) 555 }) 556 }, 557 buttonprimitive_root_spread_levels[2], 558 dirty & /*$$restProps*/ 559 16 && get_spread_object( 560 /*$$restProps*/ 561 ctx2[4] 562 ) 563 ]) : {}; 564 if (dirty & /*$$scope, loading*/ 565 258) { 566 buttonprimitive_root_changes.$$scope = { dirty, ctx: ctx2 }; 567 } 568 buttonprimitive_root.$set(buttonprimitive_root_changes); 569 }, 570 i(local) { 571 if (current) 572 return; 573 transition_in(buttonprimitive_root.$$.fragment, local); 574 current = true; 575 }, 576 o(local) { 577 transition_out(buttonprimitive_root.$$.fragment, local); 578 current = false; 579 }, 580 d(detaching) { 581 destroy_component(buttonprimitive_root, detaching); 582 } 583 }; 584} 585function instance$d($$self, $$props, $$invalidate) { 586 const omit_props_names = ["class", "loading", "variant", "builders"]; 587 let $$restProps = compute_rest_props($$props, omit_props_names); 588 let { $$slots: slots = {}, $$scope } = $$props; 589 let { class: className = void 0 } = $$props; 590 let { loading = false } = $$props; 591 let { variant = "primary" } = $$props; 592 let { builders = [] } = $$props; 593 function click_handler(event) { 594 bubble.call(this, $$self, event); 595 } 596 function keydown_handler(event) { 597 bubble.call(this, $$self, event); 598 } 599 $$self.$$set = ($$new_props) => { 600 $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)); 601 $$invalidate(4, $$restProps = compute_rest_props($$props, omit_props_names)); 602 if ("class" in $$new_props) 603 $$invalidate(0, className = $$new_props.class); 604 if ("loading" in $$new_props) 605 $$invalidate(1, loading = $$new_props.loading); 606 if ("variant" in $$new_props) 607 $$invalidate(2, variant = $$new_props.variant); 608 if ("builders" in $$new_props) 609 $$invalidate(3, builders = $$new_props.builders); 610 if ("$$scope" in $$new_props) 611 $$invalidate(8, $$scope = $$new_props.$$scope); 612 }; 613 return [ 614 className, 615 loading, 616 variant, 617 builders, 618 $$restProps, 619 slots, 620 click_handler,
621 keydown_handler, 622 $$scope 623 ]; 624} 625class Button extends SvelteComponent { 626 constructor(options) { 627 super(); 628 init(this, options, instance$d, create_fragment$d, safe_not_equal, { 629 class: 0, 630 loading: 1, 631 variant: 2, 632 builders: 3 633 }); 634 } 635} 636const currentLanguage = ((_b = window == null ? void 0 : window.leatMiddlewareConfig) == null ? void 0 : _b.currentLanguage) || "en_US"; 637const pluginSettings = writable(); 638const isLoggedIn = window.leatMiddlewareConfig.loggedIn; 639const creditsName = derived(pluginSettings, ($pluginSettings) => { 640 return getTranslatedText($pluginSettings.credits_name); 641}); 642const defaultStorePage = { 643 id: 0, 644 permalink: null, 645 title: "" 646}; 647const initialWcSettingsState = { 648 adminUrl: "", 649 countries: [], 650 displayCartPricesIncludingTax: false, 651 currency: { 652 code: "USD", 653 precision: 2, 654 symbol: "$", 655 symbolPosition: "left", 656 decimalSeparator: ".", 657 priceFormat: "%1$s%2$s", 658 thousandSeparator: "," 659 }, 660 canUserRegister: false, 661 currentUserIsAdmin: false, 662 homeUrl: "", 663 locale: { 664 siteLocale: "en_US", 665 userLocale: "en_US", 666 weekdaysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] 667 }, 668 productsSettings: { 669 cartRedirectAfterAdd: false 670 }, 671 placeholderImgSrc: "", 672 siteTitle: "", 673 storePages: { 674 cart: defaultStorePage, 675 checkout: defaultStorePage, 676 myaccount: defaultStorePage, 677 privacy: defaultStorePage, 678 shop: defaultStorePage, 679 terms: defaultStorePage, 680 leat_dashboard: defaultStorePage 681 }, 682 wcAssetUrl: "", 683 wcVersion: "", 684 wpLoginUrl: "", 685 wpVersion: "", 686 taxTotalDisplayItemized: false, 687 shippingCalculatorEnabled: true, 688 taxesEnabled: true, 689 couponsEnabled: true, 690 shippingEnabled: true, 691 showCartPricesIncTax: true, 692 countryTaxOrVat: "tax", 693 endpoints: { 694 "order-received": { 695 active: false 696 } 697 } 698}; 699const wcSettings = writable(initialWcSettingsState); 700derived(wcSettings, ($opt) => { 701 return $opt == null ? void 0 : $opt.locale; 702}); 703const checkoutUrl = derived(wcSettings, ($opt) => { 704 var _a2; 705 if (!((_a2 = $opt.storePages.checkout) == null ? void 0 : _a2.permalink)) { 706 return "/checkout"; 707 } 708 return $opt.storePages.checkout.permalink; 709}); 710const cartUrl = derived(wcSettings, ($opt) => { 711 var _a2; 712 if (!((_a2 = $opt.storePages.cart) == null ? void 0 : _a2.permalink)) { 713 return "/cart"; 714 } 715 return $opt.storePages.cart.permalink; 716}); 717derived([checkoutUrl, cartUrl], ([$checkoutUrl, $cartUrl]) => { 718 return { 719 checkout: $checkoutUrl, 720 cart: $cartUrl 721 }; 722}); 723derived(wcSettings, ($opt) => { 724 return { 725 orderReceived: $opt.endpoints["order-received"] 726 }; 727}); 728derived(wcSettings, ($opt) => { 729 const countryTaxOrVat = $opt.countryTaxOrVat; 730 const taxesEnabled = $opt.taxesEnabled; 731 const showCartPricesIncTax = $opt.showCartPricesIncTax; 732 const taxTotalDisplayItemized = $opt.taxTotalDisplayItemized; 733 const showCartTax = taxesEnabled && showCartPricesIncTax; 734 return { 735 countryTaxOrVat, 736 showCartTax, 737 taxesEnabled, 738 showCartPricesIncTax, 739 taxTotalDisplayItemized 740 }; 741}); 742const QueryKeys = { 743 earnRules: "earnRules", 744 spendRules: "spendRules", 745 coupons: "coupons", 746 contact: "contact", 747 tiers: "tiers", 748 cart: "cart" 749}; 750const MutationKeys = { 751 claimReward: "claimReward", 752 claimSpendRule: "claimSpendRule", 753 joinProgram: "joinProgram", 754 applyCoupon: "applyCoupon" 755}; 756const dashboardCouponCard_svelte_svelte_type_style_lang = ""; 757function create_else_block_1$1(ctx) { 758 let gift; 759 let current; 760 gift = new Gift({ props: { size: 48 } }); 761 return { 762 c() { 763 create_component(gift.$$.fragment); 764 }, 765 m(target, anchor) { 766 mount_component(gift, target, anchor); 767 current = true; 768 }, 769 p: noop, 770 i(local) { 771 if (current) 772 return; 773 transition_in(gift.$$.fragment, local); 774 current = true; 775 }, 776 o(local) { 777 transition_out(gift.$$.fragment, local); 778 current = false; 779 }, 780 d(detaching) { 781 destroy_component(gift, detaching); 782 } 783 }; 784} 785function create_if_block_6$2(ctx) { 786 let img; 787 let img_src_value; 788 let img_alt_value; 789 return { 790 c() { 791 img = element("img"); 792 if (!src_url_equal(img.src, img_src_value = /*coupon*/ 793 ctx[0].rule.image.value)) 794 attr(img, "src", img_src_value); 795 attr(img, "alt", img_alt_value = /*coupon*/ 796 ctx[0].code); 797 attr(img, "class", "svelte-148dlwh"); 798 }, 799 m(target, anchor) { 800 insert(target, img, anchor); 801 }, 802 p(ctx2, dirty) {
803 if (dirty & /*coupon*/ 804 1 && !src_url_equal(img.src, img_src_value = /*coupon*/ 805 ctx2[0].rule.image.value)) { 806 attr(img, "src", img_src_value); 807 } 808 if (dirty & /*coupon*/ 809 1 && img_alt_value !== (img_alt_value = /*coupon*/ 810 ctx2[0].code)) { 811 attr(img, "alt", img_alt_value); 812 } 813 }, 814 i: noop, 815 o: noop, 816 d(detaching) { 817 if (detaching) { 818 detach(img); 819 } 820 } 821 }; 822} 823function create_if_block_5$2(ctx) { 824 let t_value = getTranslatedText( 825 /*coupon*/ 826 ctx[0].rule.label.value 827 ) + ""; 828 let t; 829 return { 830 c() { 831 t = text(t_value); 832 }, 833 m(target, anchor) { 834 insert(target, t, anchor); 835 }, 836 p(ctx2, dirty) { 837 if (dirty & /*coupon*/ 838 1 && t_value !== (t_value = getTranslatedText( 839 /*coupon*/ 840 ctx2[0].rule.label.value 841 ) + "")) 842 set_data(t, t_value); 843 }, 844 d(detaching) { 845 if (detaching) { 846 detach(t); 847 } 848 } 849 }; 850} 851function create_if_block_4$2(ctx) { 852 var _a2; 853 let t_value = getSpendRuleLabel( 854 getTranslatedText( 855 /*coupon*/ 856 ctx[0].rule.label.value 857 ), 858 /*coupon*/ 859 ctx[0].rule.creditCost.value, 860 /*$creditsName*/ 861 ctx[6], 862 /*coupon*/ 863 (_a2 = ctx[0].rule.discountValue) == null ? void 0 : _a2.value, 864 /*coupon*/ 865 ctx[0].rule.discountType.value 866 ) + ""; 867 let t; 868 return { 869 c() { 870 t = text(t_value); 871 }, 872 m(target, anchor) { 873 insert(target, t, anchor); 874 }, 875 p(ctx2, dirty) { 876 var _a3; 877 if (dirty & /*coupon, $creditsName*/ 878 65 && t_value !== (t_value = getSpendRuleLabel( 879 getTranslatedText( 880 /*coupon*/ 881 ctx2[0].rule.label.value 882 ), 883 /*coupon*/ 884 ctx2[0].rule.creditCost.value, 885 /*$creditsName*/ 886 ctx2[6], 887 /*coupon*/ 888 (_a3 = ctx2[0].rule.discountValue) == null ? void 0 : _a3.value, 889 /*coupon*/ 890 ctx2[0].rule.discountType.value 891 ) + "")) 892 set_data(t, t_value); 893 }, 894 d(detaching) { 895 if (detaching) { 896 detach(t); 897 } 898 } 899 }; 900} 901function create_if_block_3$4(ctx) { 902 let p; 903 let t_value = getTranslatedText( 904 /*coupon*/ 905 ctx[0].rule.instructions.value 906 ) + ""; 907 let t; 908 return { 909 c() { 910 p = element("p"); 911 t = text(t_value); 912 attr(p, "class", "leat-dashboard-coupon-card__description svelte-148dlwh"); 913 }, 914 m(target, anchor) { 915 insert(target, p, anchor); 916 append(p, t); 917 }, 918 p(ctx2, dirty) { 919 if (dirty & /*coupon*/ 920 1 && t_value !== (t_value = getTranslatedText( 921 /*coupon*/ 922 ctx2[0].rule.instructions.value 923 ) + "")) 924 set_data(t, t_value); 925 }, 926 d(detaching) { 927 if (detaching) { 928 detach(p); 929 } 930 } 931 }; 932} 933function create_if_block_2$6(ctx) { 934 let div; 935 let raw_value = ( 936 /*getErrorMessage*/ 937 ctx[13]( 938 /*combinedError*/ 939 ctx[4] 940 ) + "" 941 ); 942 return { 943 c() { 944 div = element("div"); 945 attr(div, "class", "leat-dashboard-coupon-card__error svelte-148dlwh"); 946 }, 947 m(target, anchor) { 948 insert(target, div, anchor); 949 div.innerHTML = raw_value; 950 }, 951 p(ctx2, dirty) { 952 if (dirty & /*combinedError*/ 953 16 && raw_value !== (raw_value = /*getErrorMessage*/ 954 ctx2[13]( 955 /*combinedError*/ 956 ctx2[4] 957 ) + "")) 958 div.innerHTML = raw_value; 959 }, 960 d(detaching) { 961 if (detaching) { 962 detach(div); 963 } 964 } 965 }; 966} 967function create_else_block$5(ctx) { 968 let t_value = getTranslatedText( 969 /*$pluginSettings*/ 970 ctx[7].dashboard_coupon_cta 971 ) + ""; 972 let t; 973 return { 974 c() { 975 t = text(t_value); 976 }, 977 m(target, anchor) { 978 insert(target, t, anchor); 979 }, 980 p(ctx2, dirty) { 981 if (dirty & /*$pluginSettings*/ 982 128 && t_value !== (t_value = getTranslatedText( 983 /*$pluginSettings*/ 984 ctx2[7].dashboard_coupon_cta 985 ) + "")) 986 set_data(t, t_value); 987 }, 988 i: noop, 989 o: noop, 990 d(detaching) { 991 if (detaching) { 992 detach(t); 993 } 994 } 995 }; 996} 997function create_if_block_1$8(ctx) { 998 let div; 999 let check; 1000 let t0; 1001 let span; 1002 let current; 1003 check = new Check({ props: { size: 16 } }); 1004 return { 1005 c() { 1006 div = element("div"); 1007 create_component(check.$$.fragment); 1008 t0 = space(); 1009 span = element("span"); 1010 span.textContent = "Applied"; 1011 attr(span, "class", "leat-sr-only svelte-148dlwh"); 1012 attr(div, "class", "leat-dashboard-coupon-card__button-success svelte-148dlwh"); 1013 }, 1014 m(target, anchor) { 1015 insert(target, div, anchor); 1016 mount_component(check, div, null); 1017 append(div, t0); 1018 append(div, span); 1019 current = true; 1020 }, 1021 p: noop, 1022 i(local) { 1023 if (current) 1024 return; 1025 transition_in(check.$$.fragment, local); 1026 current = true; 1027 }, 1028 o(local) { 1029 transition_out(check.$$.fragment, local); 1030 current = false;
1031 }, 1032 d(detaching) { 1033 if (detaching) { 1034 detach(div); 1035 } 1036 destroy_component(check); 1037 } 1038 }; 1039} 1040function create_default_slot$5(ctx) { 1041 let current_block_type_index; 1042 let if_block; 1043 let if_block_anchor; 1044 let current; 1045 const if_block_creators = [create_if_block_1$8, create_else_block$5]; 1046 const if_blocks = []; 1047 function select_block_type_2(ctx2, dirty) { 1048 if ( 1049 /*isApplied*/ 1050 ctx2[5] 1051 ) 1052 return 0; 1053 return 1; 1054 } 1055 current_block_type_index = select_block_type_2(ctx); 1056 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 1057 return { 1058 c() { 1059 if_block.c(); 1060 if_block_anchor = empty(); 1061 }, 1062 m(target, anchor) { 1063 if_blocks[current_block_type_index].m(target, anchor); 1064 insert(target, if_block_anchor, anchor); 1065 current = true; 1066 }, 1067 p(ctx2, dirty) { 1068 let previous_block_index = current_block_type_index; 1069 current_block_type_index = select_block_type_2(ctx2); 1070 if (current_block_type_index === previous_block_index) { 1071 if_blocks[current_block_type_index].p(ctx2, dirty); 1072 } else { 1073 group_outros(); 1074 transition_out(if_blocks[previous_block_index], 1, 1, () => { 1075 if_blocks[previous_block_index] = null; 1076 }); 1077 check_outros(); 1078 if_block = if_blocks[current_block_type_index]; 1079 if (!if_block) { 1080 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2); 1081 if_block.c(); 1082 } else { 1083 if_block.p(ctx2, dirty); 1084 } 1085 transition_in(if_block, 1); 1086 if_block.m(if_block_anchor.parentNode, if_block_anchor); 1087 } 1088 }, 1089 i(local) { 1090 if (current) 1091 return; 1092 transition_in(if_block); 1093 current = true; 1094 }, 1095 o(local) { 1096 transition_out(if_block); 1097 current = false; 1098 }, 1099 d(detaching) { 1100 if (detaching) { 1101 detach(if_block_anchor); 1102 } 1103 if_blocks[current_block_type_index].d(detaching); 1104 } 1105 }; 1106} 1107function create_if_block$a(ctx) { 1108 let button; 1109 let x; 1110 let button_disabled_value; 1111 let current; 1112 let mounted; 1113 let dispose; 1114 x = new X({ props: { size: 14 } }); 1115 return { 1116 c() { 1117 button = element("button"); 1118 create_component(x.$$.fragment); 1119 attr(button, "class", "leat-dashboard-coupon-card__remove-button svelte-148dlwh"); 1120 button.disabled = button_disabled_value = /*$removeCouponMutation*/ 1121 ctx[1].isPending; 1122 attr(button, "aria-label", "Remove coupon"); 1123 }, 1124 m(target, anchor) { 1125 insert(target, button, anchor); 1126 mount_component(x, button, null); 1127 current = true; 1128 if (!mounted) { 1129 dispose = listen( 1130 button, 1131 "click", 1132 /*click_handler_1*/ 1133 ctx[16] 1134 ); 1135 mounted = true; 1136 } 1137 }, 1138 p(ctx2, dirty) { 1139 if (!current || dirty & /*$removeCouponMutation*/ 1140 2 && button_disabled_value !== (button_disabled_value = /*$removeCouponMutation*/ 1141 ctx2[1].isPending)) { 1142 button.disabled = button_disabled_value; 1143 } 1144 }, 1145 i(local) { 1146 if (current) 1147 return; 1148 transition_in(x.$$.fragment, local); 1149 current = true; 1150 }, 1151 o(local) { 1152 transition_out(x.$$.fragment, local); 1153 current = false; 1154 }, 1155 d(detaching) { 1156 if (detaching) { 1157 detach(button); 1158 } 1159 destroy_component(x); 1160 mounted = false; 1161 dispose(); 1162 } 1163 }; 1164} 1165function create_fragment$c(ctx) { 1166 var _a2; 1167 let div6; 1168 let div0; 1169 let current_block_type_index; 1170 let if_block0; 1171 let t0; 1172 let div2; 1173 let h4; 1174 let t1; 1175 let t2; 1176 let div1; 1177 let span; 1178 let t3_value = ( 1179 /*coupon*/ 1180 ctx[0].code + "" 1181 ); 1182 let t3; 1183 let t4; 1184 let div5; 1185 let t5; 1186 let div4; 1187 let div3; 1188 let button; 1189 let t6; 1190 let div3_class_value; 1191 let current; 1192 const if_block_creators = [create_if_block_6$2, create_else_block_1$1]; 1193 const if_blocks = []; 1194 function select_block_type(ctx2, dirty) { 1195 var _a3, _b2; 1196 if ( 1197 /*coupon*/ 1198 (_b2 = (_a3 = ctx2[0].rule) == null ? void 0 : _a3.image) == null ? void 0 : _b2.value 1199 ) 1200 return 0; 1201 return 1; 1202 } 1203 current_block_type_index = select_block_type(ctx); 1204 if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 1205 function select_block_type_1(ctx2, dirty) { 1206 if ( 1207 /*coupon*/ 1208 ctx2[0].type === "spend_rule" 1209 ) 1210 return create_if_block_4$2; 1211 if ( 1212 /*coupon*/ 1213 ctx2[0].type === "promotion_rule" 1214 ) 1215 return create_if_block_5$2; 1216 } 1217 let current_block_type = select_block_type_1(ctx); 1218 let if_block1 = current_block_type && current_block_type(ctx); 1219 let if_block2 = ( 1220 /*coupon*/ 1221 ctx[0].type === "spend_rule" && /*coupon*/ 1222 ((_a2 = ctx[0].rule.instructions) == null ? void 0 : _a2.value) && create_if_block_3$4(ctx) 1223 ); 1224 let if_block3 = ( 1225 /*combinedError*/ 1226 ctx[4] && (!/*isApplied*/ 1227 ctx[5] || /*$removeCouponMutation*/ 1228 ctx[1].error) && create_if_block_2$6(ctx) 1229 ); 1230 button = new Button({ 1231 props: { 1232 variant: "primary", 1233 loading: ( 1234 /*$applyCouponMutation*/ 1235 ctx[3].isPending || /*$removeAllCouponsMutation*/ 1236 ctx[2].isPending 1237 ), 1238 disabled: ( 1239 /*isApplied*/ 1240 ctx[5] || /*$applyCouponMutation*/ 1241 ctx[3].isPending || /*$removeAllCouponsMutation*/ 1242 ctx[2].isPending 1243 ), 1244 class: ( 1245 /*isApplied*/ 1246 ctx[5] ? "leat-dashboard-coupon-card__button--success" : "" 1247 ), 1248 $$slots: { default: [create_default_slot$5] }, 1249 $$scope: { ctx } 1250 } 1251 }); 1252 button.$on( 1253 "click", 1254 /*click_handler*/ 1255 ctx[15] 1256 ); 1257 let if_block4 = ( 1258 /*isApplied*/ 1259 ctx[5] && create_if_block$a(ctx) 1260 ); 1261 return { 1262 c() { 1263 div6 = element("div"); 1264 div0 = element("div"); 1265 if_block0.c(); 1266 t0 = space(); 1267 div2 = element("div"); 1268 h4 = element("h4"); 1269 if (if_block1) 1270 if_block1.c(); 1271 t1 = space(); 1272 if (if_block2) 1273 if_block2.c(); 1274 t2 = space(); 1275 div1 = element("div"); 1276 span = element("span"); 1277 t3 = text(t3_value); 1278 t4 = space(); 1279 div5 = element("div"); 1280 if (if_block3) 1281 if_block3.c(); 1282 t5 = space(); 1283 div4 = element("div"); 1284 div3 = element("div"); 1285 create_component(button.$$.fragment); 1286 t6 = space(); 1287 if (if_block4) 1288 if_block4.c(); 1289 attr(div0, "class", "leat-dashboard-coupon-card__icon svelte-148dlwh"); 1290 attr(h4, "class", "leat-dashboard-coupon-card__header svelte-148dlwh"); 1291 attr(span, "class", "leat-dashboard-coupon-card__code-value"); 1292 attr(div1, "class", "leat-dashboard-coupon-card__code svelte-148dlwh"); 1293 attr(div2, "class", "leat-dashboard-coupon-card__info svelte-148dlwh"); 1294 attr(div3, "class", div3_class_value = "leat-dashboard-coupon-card__button-wrapper " + /*isApplied*/ 1295 (ctx[5] ? "is-applied" : "") + " svelte-148dlwh"); 1296 attr(div4, "class", "leat-dashboard-coupon-card__button-container svelte-148dlwh"); 1297 attr(div5, "class", "leat-dashboard-coupon-card__action svelte-148dlwh"); 1298 attr(div6, "class", "leat-dashboard-coupon-card svelte-148dlwh"); 1299 }, 1300 m(target, anchor) { 1301 insert(target, div6, anchor); 1302 append(div6, div0); 1303 if_blocks[current_block_type_index].m(div0, null); 1304 append(div6, t0); 1305 append(div6, div2); 1306 append(div2, h4); 1307 if (if_block1) 1308 if_block1.m(h4, null); 1309 append(div2, t1); 1310 if (if_block2) 1311 if_block2.m(div2, null); 1312 append(div2, t2); 1313 append(div2, div1); 1314 append(div1, span); 1315 append(span, t3); 1316 append(div6, t4); 1317 append(div6, div5); 1318 if (if_block3) 1319 if_block3.m(div5, null); 1320 append(div5, t5); 1321 append(div5, div4); 1322 append(div4, div3); 1323 mount_component(button, div3, null); 1324 append(div3, t6); 1325 if (if_block4) 1326 if_block4.m(div3, null); 1327 current = true; 1328 }, 1329 p(ctx2, [dirty]) { 1330 var _a3; 1331 let previous_block_index = current_block_type_index; 1332 current_block_type_index = select_block_type(ctx2); 1333 if (current_block_type_index === previous_block_index) { 1334 if_blocks[current_block_type_index].p(ctx2, dirty); 1335 } else { 1336 group_outros(); 1337 transition_out(if_blocks[previous_block_index], 1, 1, () => { 1338 if_blocks[previous_block_index] = null; 1339 }); 1340 check_outros(); 1341 if_block0 = if_blocks[current_block_type_index]; 1342 if (!if_block0) { 1343 if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2); 1344 if_block0.c(); 1345 } else { 1346 if_block0.p(ctx2, dirty); 1347 } 1348 transition_in(if_block0, 1); 1349 if_block0.m(div0, null); 1350 } 1351 if (current_block_type === (current_block_type = select_block_type_1(ctx2)) && if_block1) { 1352 if_block1.p(ctx2, dirty); 1353 } else { 1354 if (if_block1) 1355 if_block1.d(1); 1356 if_block1 = current_block_type && current_block_type(ctx2); 1357 if (if_block1) { 1358 if_block1.c(); 1359 if_block1.m(h4, null); 1360 } 1361 } 1362 if ( 1363 /*coupon*/ 1364 ctx2[0].type === "spend_rule" && /*coupon*/ 1365 ((_a3 = ctx2[0].rule.instructions) == null ? void 0 : _a3.value) 1366 ) { 1367 if (if_block2) { 1368 if_block2.p(ctx2, dirty); 1369 } else { 1370 if_block2 = create_if_block_3$4(ctx2); 1371 if_block2.c(); 1372 if_block2.m(div2, t2); 1373 } 1374 } else if (if_block2) { 1375 if_block2.d(1); 1376 if_block2 = null; 1377 } 1378 if ((!current || dirty & /*coupon*/ 1379 1) && t3_value !== (t3_value = /*coupon*/ 1380 ctx2[0].code + "")) 1381 set_data(t3, t3_value); 1382 if ( 1383 /*combinedError*/ 1384 ctx2[4] && (!/*isApplied*/ 1385 ctx2[5] || /*$removeCouponMutation*/ 1386 ctx2[1].error) 1387 ) { 1388 if (if_block3) { 1389 if_block3.p(ctx2, dirty); 1390 } else { 1391 if_block3 = create_if_block_2$6(ctx2); 1392 if_block3.c(); 1393 if_block3.m(div5, t5); 1394 } 1395 } else if (if_block3) { 1396 if_block3.d(1); 1397 if_block3 = null; 1398 } 1399 const button_changes = {};
1400 if (dirty & /*$applyCouponMutation, $removeAllCouponsMutation*/ 1401 12) 1402 button_changes.loading = /*$applyCouponMutation*/ 1403 ctx2[3].isPending || /*$removeAllCouponsMutation*/ 1404 ctx2[2].isPending; 1405 if (dirty & /*isApplied, $applyCouponMutation, $removeAllCouponsMutation*/ 1406 44) 1407 button_changes.disabled = /*isApplied*/ 1408 ctx2[5] || /*$applyCouponMutation*/ 1409 ctx2[3].isPending || /*$removeAllCouponsMutation*/ 1410 ctx2[2].isPending; 1411 if (dirty & /*isApplied*/ 1412 32) 1413 button_changes.class = /*isApplied*/ 1414 ctx2[5] ? "leat-dashboard-coupon-card__button--success" : ""; 1415 if (dirty & /*$$scope, isApplied, $pluginSettings*/ 1416 262304) { 1417 button_changes.$$scope = { dirty, ctx: ctx2 }; 1418 } 1419 button.$set(button_changes); 1420 if ( 1421 /*isApplied*/ 1422 ctx2[5] 1423 ) { 1424 if (if_block4) { 1425 if_block4.p(ctx2, dirty); 1426 if (dirty & /*isApplied*/ 1427 32) { 1428 transition_in(if_block4, 1); 1429 } 1430 } else { 1431 if_block4 = create_if_block$a(ctx2); 1432 if_block4.c(); 1433 transition_in(if_block4, 1); 1434 if_block4.m(div3, null); 1435 } 1436 } else if (if_block4) { 1437 group_outros(); 1438 transition_out(if_block4, 1, 1, () => { 1439 if_block4 = null; 1440 }); 1441 check_outros(); 1442 } 1443 if (!current || dirty & /*isApplied*/ 1444 32 && div3_class_value !== (div3_class_value = "leat-dashboard-coupon-card__button-wrapper " + /*isApplied*/ 1445 (ctx2[5] ? "is-applied" : "") + " svelte-148dlwh")) { 1446 attr(div3, "class", div3_class_value); 1447 } 1448 }, 1449 i(local) { 1450 if (current) 1451 return; 1452 transition_in(if_block0); 1453 transition_in(button.$$.fragment, local); 1454 transition_in(if_block4); 1455 current = true; 1456 }, 1457 o(local) { 1458 transition_out(if_block0); 1459 transition_out(button.$$.fragment, local); 1460 transition_out(if_block4); 1461 current = false; 1462 }, 1463 d(detaching) { 1464 if (detaching) { 1465 detach(div6); 1466 } 1467 if_blocks[current_block_type_index].d(); 1468 if (if_block1) { 1469 if_block1.d(); 1470 } 1471 if (if_block2) 1472 if_block2.d(); 1473 if (if_block3) 1474 if_block3.d(); 1475 destroy_component(button); 1476 if (if_block4) 1477 if_block4.d(); 1478 } 1479 }; 1480} 1481function instance$c($$self, $$props, $$invalidate) { 1482 let isApplied; 1483 let hasProducts; 1484 let combinedError; 1485 let $removeCouponMutation; 1486 let $removeAllCouponsMutation; 1487 let $applyCouponMutation; 1488 let $cartQuery; 1489 let $creditsName; 1490 let $pluginSettings; 1491 component_subscribe($$self, creditsName, ($$value) =>
1491 $$invalidate(6, $creditsName = $$value)); 1492 component_subscribe($$self, pluginSettings, ($$value) => $$invalidate(7, $pluginSettings = $$value)); 1493 let { coupon } = $$props; 1494 const cartQuery = createQuery({ 1495 queryKey: [QueryKeys.cart], 1496 queryFn: getCart 1497 }); 1498 component_subscribe($$self, cartQuery, (value) => $$invalidate(14, $cartQuery = value)); 1499 const applyCouponMutation = createMutation({ 1500 mutationFn: customApplyCoupon, 1501 mutationKey: [MutationKeys.applyCoupon, coupon.code], 1502 onSuccess: () => { 1503 var _a2, _b2; 1504 const cart = (_a2 = window.leatWcSettings.storePages.cart) == null ? void 0 : _a2.permalink; 1505 const checkout = (_b2 = window.leatWcSettings.storePages.checkout) == null ? void 0 : _b2.permalink; 1506 if (cart) { 1507 window.location.href = cart; 1508 } else if (checkout) { 1509 window.location.href = checkout; 1510 } 1511 $cartQuery.refetch(); 1512 }, 1513 onError: () => { 1514 } 1515 }); 1516 component_subscribe($$self, applyCouponMutation, (value) => $$invalidate(3, $applyCouponMutation = value)); 1517 const removeAllCouponsMutation = createMutation({ mutationFn: removeAllCoupons }); 1518 component_subscribe($$self, removeAllCouponsMutation, (value) =>
1518 $$invalidate(2, $removeAllCouponsMutation = value)); 1519 const removeCouponMutation = createMutation({ 1520 mutationFn: async (code) => { 1521 var _a2; 1522 if (hasProducts && ((_a2 = coupon.rule.selectedProducts) == null ? void 0 : _a2.value)) { 1523 for (const productId of coupon.rule.selectedProducts.value) { 1524 const numProductId = Number(productId); 1525 const cartItemKey = await findCartItemKeyByVariationId(numProductId); 1526 if (cartItemKey) { 1527 await removeCartItem(cartItemKey); 1528 } 1529 } 1530 } 1531 return removeCoupon(code); 1532 }, 1533 onSuccess: () => { 1534 $cartQuery.refetch(); 1535 } 1536 }); 1537 component_subscribe($$self, removeCouponMutation, (value) => $$invalidate(1, $removeCouponMutation = value)); 1538 function handleApplyCoupon(code) { 1539 var _a2, _b2; 1540 if (isApplied) 1541 return; 1542 if (hasProducts) { 1543 $applyCouponMutation.mutate(code); 1544 } else { 1545 if (((_a2 = $cartQuery.data) == null ? void 0 : _a2.items_count) === 0 && ((_b2 = $cartQuery.data) == null ? void 0 : _b2.coupons.length) > 0) { 1546 $removeAllCouponsMutation.mutate(void 0, { 1547 onSuccess: () => { 1548 $applyCouponMutation.mutate(code); 1549 } 1550 }); 1551 } else { 1552 $applyCouponMutation.mutate(code); 1553 } 1554 } 1555 } 1556 function getErrorMessage(error) { 1557 if (error instanceof LeatApiError) { 1558 if (typeof error.data === "string") { 1559 return error.data || error.statusText || "Error applying coupon"; 1560 } 1561 return error.statusText || "Error applying coupon"; 1562 } 1563 if (error instanceof Error) { 1564 return error.message; 1565 } 1566 return "An unknown error occurred"; 1567 } 1568 const click_handler = () => handleApplyCoupon(coupon.code); 1569 const click_handler_1 = () => $removeCouponMutation.mutate(coupon.code);
1570 $$self.$$set = ($$props2) => { 1571 if ("coupon" in $$props2) 1572 $$invalidate(0, coupon = $$props2.coupon); 1573 }; 1574 $$self.$$.update = () => { 1575 var _a2, _b2, _c, _d; 1576 if ($$self.$$.dirty & /*$cartQuery, coupon*/ 1577 16385) { 1578 $$invalidate(5, isApplied = ((_b2 = (_a2 = $cartQuery.data) == null ? void 0 : _a2.coupons) == null ? void 0 : _b2.some((c) => c.code === coupon.code)) ?? false); 1579 } 1580 if ($$self.$$.dirty & /*coupon*/ 1581 1) { 1582 hasProducts = ((_d = (_c = coupon.rule.selectedProducts) == null ? void 0 : _c.value) == null ? void 0 : _d.length) > 0; 1583 } 1584 if ($$self.$$.dirty & /*$applyCouponMutation, $removeAllCouponsMutation, $removeCouponMutation*/ 1585 14) { 1586 $$invalidate(4, combinedError = $applyCouponMutation.error || $removeAllCouponsMutation.error || $removeCouponMutation.error); 1587 } 1588 }; 1589 return [ 1590 coupon, 1591 $removeCouponMutation, 1592 $removeAllCouponsMutation, 1593 $applyCouponMutation, 1594 combinedError, 1595 isApplied, 1596 $creditsName, 1597 $pluginSettings, 1598 cartQuery, 1599 applyCouponMutation, 1600 removeAllCouponsMutation, 1601 removeCouponMutation, 1602 handleApplyCoupon, 1603 getErrorMessage, 1604 $cartQuery, 1605 click_handler, 1606 click_handler_1 1607 ]; 1608} 1609class Dashboard_coupon_card extends SvelteComponent { 1610 constructor(options) { 1611 super(); 1612 init(this, options, instance$c, create_fragment$c, safe_not_equal, { coupon: 0 }); 1613 } 1614} 1615const dashboardCoupons_svelte_svelte_type_style_lang = ""; 1616function get_each_context$4(ctx, list, i) { 1617 const child_ctx = ctx.slice(); 1618 child_ctx[8] = list[i]; 1619 return child_ctx; 1620} 1621function get_if_ctx(ctx) { 1622 const child_ctx = ctx.slice(); 1623 const constants_0 = ( 1624 /*coupons*/ 1625 child_ctx[0].spend_rules_coupons.filter((c) => c.rule.status.value === "publish" && c.rule.label.value) 1626 ); 1627 child_ctx[5] = constants_0; 1628 const constants_1 = ( 1629 /*coupons*/ 1630 child_ctx[0].promotion_rules_coupons.filter((c) => c.rule.status.value === "publish" && c.rule.label.value) 1631 ); 1632 child_ctx[6] = constants_1; 1633 const constants_2 = [ 1634 .../*filteredSpendRuleCoupons*/ 1635 child_ctx[5], 1636 .../*filteredPromotionRuleCoupons*/ 1637 child_ctx[6] 1638 ]; 1639 child_ctx[7] = constants_2; 1640 return child_ctx; 1641} 1642function create_if_block$9(ctx) { 1643 var _a2; 1644 let div1; 1645 let div0; 1646 let h3; 1647 let t0_value = ( 1648 /*getNavItemText*/ 1649 ctx[4](getTranslatedText( 1650 /*$pluginSettings*/ 1651 (_a2 = ctx[3]) == null ? void 0 : _a2.dashboard_nav_coupons 1652 )) + "" 1653 ); 1654 let t0; 1655 let t1; 1656 let t2; 1657 let current; 1658 let if_block0 = ( 1659 /*isLoading*/ 1660 ctx[1] && create_if_block_3$3(ctx) 1661 ); 1662 let if_block1 = ( 1663 /*isSuccess*/ 1664 ctx[2] && /*coupons*/ 1665 ctx[0] && create_if_block_1$7(get_if_ctx(ctx)) 1666 ); 1667 return { 1668 c() { 1669 div1 = element("div"); 1670 div0 = element("div"); 1671 h3 = element("h3"); 1672 t0 = text(t0_value); 1673 t1 = space(); 1674 if (if_block0) 1675 if_block0.c(); 1676 t2 = space(); 1677 if (if_block1) 1678 if_block1.c(); 1679 attr(h3, "class", "leat-dashboard__header"); 1680 attr(div1, "class", "leat-dashboard-section leat-dashboard-coupons"); 1681 }, 1682 m(target, anchor) { 1683 insert(target, div1, anchor); 1684 append(div1, div0); 1685 append(div0, h3); 1686 append(h3, t0); 1687 append(div1, t1); 1688 if (if_block0) 1689 if_block0.m(div1, null); 1690 append(div1, t2); 1691 if (if_block1) 1692 if_block1.m(div1, null); 1693 current = true; 1694 }, 1695 p(ctx2, dirty) { 1696 var _a3; 1697 if ((!current || dirty & /*$pluginSettings*/ 1698 8) && t0_value !== (t0_value = /*getNavItemText*/ 1699 ctx2[4](getTranslatedText( 1700 /*$pluginSettings*/ 1701 (_a3 = ctx2[3]) == null ? void 0 : _a3.dashboard_nav_coupons 1702 )) + "")) 1703 set_data(t0, t0_value); 1704 if ( 1705 /*isLoading*/ 1706 ctx2[1] 1707 ) { 1708 if (if_block0) { 1709 if_block0.p(ctx2, dirty); 1710 } else { 1711 if_block0 = create_if_block_3$3(ctx2); 1712 if_block0.c(); 1713 if_block0.m(div1, t2); 1714 } 1715 } else if (if_block0) { 1716 if_block0.d(1); 1717 if_block0 = null; 1718 } 1719 if ( 1720 /*isSuccess*/ 1721 ctx2[2] && /*coupons*/ 1722 ctx2[0] 1723 ) { 1724 if (if_block1) { 1725 if_block1.p(get_if_ctx(ctx2), dirty);
1726 if (dirty & /*isSuccess, coupons*/ 1727 5) { 1728 transition_in(if_block1, 1); 1729 } 1730 } else { 1731 if_block1 = create_if_block_1$7(get_if_ctx(ctx2)); 1732 if_block1.c(); 1733 transition_in(if_block1, 1); 1734 if_block1.m(div1, null); 1735 } 1736 } else if (if_block1) { 1737 group_outros(); 1738 transition_out(if_block1, 1, 1, () => { 1739 if_block1 = null; 1740 }); 1741 check_outros(); 1742 } 1743 }, 1744 i(local) { 1745 if (current) 1746 return; 1747 transition_in(if_block1); 1748 current = true; 1749 }, 1750 o(local) { 1751 transition_out(if_block1); 1752 current = false; 1753 }, 1754 d(detaching) { 1755 if (detaching) { 1756 detach(div1); 1757 } 1758 if (if_block0) 1759 if_block0.d(); 1760 if (if_block1) 1761 if_block1.d(); 1762 } 1763 }; 1764} 1765function create_if_block_3$3(ctx) { 1766 var _a2; 1767 let div; 1768 let p; 1769 let t_value = getTranslatedText( 1770 /*$pluginSettings*/ 1771 (_a2 = ctx[3]) == null ? void 0 : _a2.dashboard_coupons_loading_state 1772 ) + ""; 1773 let t; 1774 return { 1775 c() { 1776 div = element("div"); 1777 p = element("p"); 1778 t = text(t_value); 1779 attr(div, "class", "leat-dashboard-coupons__loading svelte-iyv9ub"); 1780 }, 1781 m(target, anchor) { 1782 insert(target, div, anchor); 1783 append(div, p); 1784 append(p, t); 1785 }, 1786 p(ctx2, dirty) { 1787 var _a3; 1788 if (dirty & /*$pluginSettings*/ 1789 8 && t_value !== (t_value = getTranslatedText( 1790 /*$pluginSettings*/ 1791 (_a3 = ctx2[3]) == null ? void 0 : _a3.dashboard_coupons_loading_state 1792 ) + "")) 1793 set_data(t, t_value); 1794 }, 1795 d(detaching) { 1796 if (detaching) { 1797 detach(div); 1798 } 1799 } 1800 }; 1801} 1802function create_if_block_1$7(ctx) { 1803 let current_block_type_index; 1804 let if_block; 1805 let if_block_anchor; 1806 let current; 1807 const if_block_creators = [create_if_block_2$5, create_else_block$4]; 1808 const if_blocks = []; 1809 function select_block_type(ctx2, dirty) { 1810 if ( 1811 /*allFilteredCoupons*/ 1812 ctx2[7].length > 0 1813 ) 1814 return 0; 1815 return 1; 1816 } 1817 current_block_type_index = select_block_type(ctx); 1818 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 1819 return { 1820 c() { 1821 if_block.c(); 1822 if_block_anchor = empty(); 1823 }, 1824 m(target, anchor) { 1825 if_blocks[current_block_type_index].m(target, anchor); 1826 insert(target, if_block_anchor, anchor); 1827 current = true; 1828 }, 1829 p(ctx2, dirty) { 1830 let previous_block_index = current_block_type_index; 1831 current_block_type_index = select_block_type(ctx2); 1832 if (current_block_type_index === previous_block_index) { 1833 if_blocks[current_block_type_index].p(ctx2, dirty); 1834 } else { 1835 group_outros(); 1836 transition_out(if_blocks[previous_block_index], 1, 1, () => { 1837 if_blocks[previous_block_index] = null; 1838 }); 1839 check_outros(); 1840 if_block = if_blocks[current_block_type_index]; 1841 if (!if_block) { 1842 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2); 1843 if_block.c(); 1844 } else { 1845 if_block.p(ctx2, dirty); 1846 } 1847 transition_in(if_block, 1); 1848 if_block.m(if_block_anchor.parentNode, if_block_anchor); 1849 } 1850 }, 1851 i(local) { 1852 if (current) 1853 return; 1854 transition_in(if_block); 1855 current = true; 1856 }, 1857 o(local) { 1858 transition_out(if_block); 1859 current = false; 1860 }, 1861 d(detaching) { 1862 if (detaching) { 1863 detach(if_block_anchor); 1864 } 1865 if_blocks[current_block_type_index].d(detaching); 1866 } 1867 }; 1868} 1869function create_else_block$4(ctx) { 1870 var _a2; 1871 let div; 1872 let p; 1873 let t_value = getTranslatedText( 1874 /*$pluginSettings*/ 1875 (_a2 = ctx[3]) == null ? void 0 : _a2.dashboard_nav_coupons_empty_state 1876 ) + ""; 1877 let t; 1878 return { 1879 c() { 1880 div = element("div"); 1881 p = element("p"); 1882 t = text(t_value); 1883 attr(div, "class", "leat-dashboard-coupons__empty svelte-iyv9ub"); 1884 }, 1885 m(target, anchor) { 1886 insert(target, div, anchor); 1887 append(div, p); 1888 append(p, t); 1889 }, 1890 p(ctx2, dirty) { 1891 var _a3;
1892 if (dirty & /*$pluginSettings*/ 1893 8 && t_value !== (t_value = getTranslatedText( 1894 /*$pluginSettings*/ 1895 (_a3 = ctx2[3]) == null ? void 0 : _a3.dashboard_nav_coupons_empty_state 1896 ) + "")) 1897 set_data(t, t_value); 1898 }, 1899 i: noop, 1900 o: noop, 1901 d(detaching) { 1902 if (detaching) { 1903 detach(div); 1904 } 1905 } 1906 }; 1907} 1908function create_if_block_2$5(ctx) { 1909 let div; 1910 let current; 1911 let each_value = ensure_array_like( 1912 /*allFilteredCoupons*/ 1913 ctx[7] 1914 ); 1915 let each_blocks = []; 1916 for (let i = 0; i < each_value.length; i += 1) { 1917 each_blocks[i] = create_each_block$4(get_each_context$4(ctx, each_value, i)); 1918 } 1919 const out = (i) => transition_out(each_blocks[i], 1, 1, () => { 1920 each_blocks[i] = null; 1921 }); 1922 return { 1923 c() { 1924 div = element("div"); 1925 for (let i = 0; i < each_blocks.length; i += 1) { 1926 each_blocks[i].c(); 1927 } 1928 attr(div, "class", "leat-dashboard-cards-grid leat-dashboard-coupons__cards"); 1929 }, 1930 m(target, anchor) { 1931 insert(target, div, anchor); 1932 for (let i = 0; i < each_blocks.length; i += 1) { 1933 if (each_blocks[i]) { 1934 each_blocks[i].m(div, null); 1935 } 1936 } 1937 current = true; 1938 }, 1939 p(ctx2, dirty) { 1940 if (dirty & /*coupons*/ 1941 1) { 1942 each_value = ensure_array_like( 1943 /*allFilteredCoupons*/ 1944 ctx2[7] 1945 ); 1946 let i; 1947 for (i = 0; i < each_value.length; i += 1) { 1948 const child_ctx = get_each_context$4(ctx2, each_value, i); 1949 if (each_blocks[i]) { 1950 each_blocks[i].p(child_ctx, dirty); 1951 transition_in(each_blocks[i], 1); 1952 } else { 1953 each_blocks[i] = create_each_block$4(child_ctx); 1954 each_blocks[i].c(); 1955 transition_in(each_blocks[i], 1); 1956 each_blocks[i].m(div, null); 1957 } 1958 } 1959 group_outros(); 1960 for (i = each_value.length; i < each_blocks.length; i += 1) { 1961 out(i); 1962 } 1963 check_outros(); 1964 } 1965 }, 1966 i(local) { 1967 if (current) 1968 return; 1969 for (let i = 0; i < each_value.length; i += 1) { 1970 transition_in(each_blocks[i]); 1971 } 1972 current = true; 1973 }, 1974 o(local) {
1975 each_blocks = each_blocks.filter(Boolean); 1976 for (let i = 0; i < each_blocks.length; i += 1) { 1977 transition_out(each_blocks[i]); 1978 } 1979 current = false; 1980 }, 1981 d(detaching) { 1982 if (detaching) { 1983 detach(div); 1984 } 1985 destroy_each(each_blocks, detaching); 1986 } 1987 }; 1988} 1989function create_each_block$4(ctx) { 1990 let dashboardcouponcard; 1991 let current; 1992 dashboardcouponcard = new Dashboard_coupon_card({ props: { coupon: ( 1993 /*coupon*/ 1994 ctx[8] 1995 ) } }); 1996 return { 1997 c() { 1998 create_component(dashboardcouponcard.$$.fragment); 1999 }, 2000 m(target, anchor) { 2001 mount_component(dashboardcouponcard, target, anchor); 2002 current = true; 2003 }, 2004 p(ctx2, dirty) { 2005 const dashboardcouponcard_changes = {}; 2006 if (dirty & /*coupons*/ 2007 1) 2008 dashboardcouponcard_changes.coupon = /*coupon*/ 2009 ctx2[8]; 2010 dashboardcouponcard.$set(dashboardcouponcard_changes); 2011 }, 2012 i(local) { 2013 if (current) 2014 return; 2015 transition_in(dashboardcouponcard.$$.fragment, local); 2016 current = true; 2017 }, 2018 o(local) { 2019 transition_out(dashboardcouponcard.$$.fragment, local); 2020 current = false; 2021 }, 2022 d(detaching) { 2023 destroy_component(dashboardcouponcard, detaching); 2024 } 2025 }; 2026} 2027function create_fragment$b(ctx) { 2028 let if_block_anchor; 2029 let current; 2030 let if_block = isLoggedIn && create_if_block$9(ctx); 2031 return { 2032 c() { 2033 if (if_block) 2034 if_block.c(); 2035 if_block_anchor = empty(); 2036 }, 2037 m(target, anchor) { 2038 if (if_block) 2039 if_block.m(target, anchor); 2040 insert(target, if_block_anchor, anchor); 2041 current = true; 2042 }, 2043 p(ctx2, [dirty]) { 2044 if (isLoggedIn) 2045 if_block.p(ctx2, dirty); 2046 }, 2047 i(local) { 2048 if (current) 2049 return; 2050 transition_in(if_block); 2051 current = true; 2052 }, 2053 o(local) { 2054 transition_out(if_block); 2055 current = false; 2056 }, 2057 d(detaching) { 2058 if (detaching) { 2059 detach(if_block_anchor); 2060 } 2061 if (if_block) 2062 if_block.d(detaching); 2063 } 2064 }; 2065} 2066function instance$b($$self, $$props, $$invalidate) { 2067 let $pluginSettings; 2068 component_subscribe($$self, pluginSettings, ($$value) =>
2068 $$invalidate(3, $pluginSettings = $$value)); 2069 let { coupons = void 0 } = $$props; 2070 let { isLoading } = $$props; 2071 let { isSuccess } = $$props; 2072 function getNavItemText(text2) { 2073 var _a2; 2074 if (!text2) 2075 return ""; 2076 const creditsName2 = (_a2 = $pluginSettings == null ? void 0 : $pluginSettings.credits_name) == null ? void 0 : _a2[currentLanguage]; 2077 return replaceStrings$1(text2, [ 2078 { 2079 "{{credits_currency}}": creditsName2 ?? "" 2080 } 2081 ]); 2082 } 2083 $$self.$$set = ($$props2) => { 2084 if ("coupons" in $$props2) 2085 $$invalidate(0, coupons = $$props2.coupons); 2086 if ("isLoading" in $$props2) 2087 $$invalidate(1, isLoading = $$props2.isLoading); 2088 if ("isSuccess" in $$props2) 2089 $$invalidate(2, isSuccess = $$props2.isSuccess); 2090 }; 2091 return [coupons, isLoading, isSuccess, $pluginSettings, getNavItemText]; 2092} 2093class Dashboard_coupons extends SvelteComponent { 2094 constructor(options) { 2095 super(); 2096 init(this, options, instance$b, create_fragment$b, safe_not_equal, { coupons: 0, isLoading: 1, isSuccess: 2 }); 2097 } 2098} 2099const contactStore = writable(null); 2100const hasLeatAccount = derived(contactStore, ($contact) => ($contact == null ? void 0 : $contact.contact) !== null); 2101const dashboardEarnCard_svelte_svelte_type_style_lang = ""; 2102function create_if_block_3$2(ctx) { 2103 let html_tag; 2104 let raw_value = ( 2105 /*getLabel*/ 2106 ctx[7]( 2107 getTranslatedText( 2108 /*earnRule*/ 2109 ctx[0].label.value 2110 ), 2111 /*earnRule*/ 2112 ctx[0].credits.value ?? 0 2113 ) + "" 2114 ); 2115 let html_anchor; 2116 return { 2117 c() { 2118 html_tag = new HtmlTag(false); 2119 html_anchor = empty(); 2120 html_tag.a = html_anchor; 2121 }, 2122 m(target, anchor) { 2123 html_tag.m(raw_value, target, anchor); 2124 insert(target, html_anchor, anchor); 2125 }, 2126 p(ctx2, dirty) { 2127 if (dirty & /*earnRule*/ 2128 1 && raw_value !== (raw_value = /*getLabel*/ 2129 ctx2[7]( 2130 getTranslatedText( 2131 /*earnRule*/ 2132 ctx2[0].label.value 2133 ), 2134 /*earnRule*/ 2135 ctx2[0].credits.value ?? 0 2136 ) + "")) 2137 html_tag.p(raw_value); 2138 }, 2139 d(detaching) { 2140 if (detaching) { 2141 detach(html_anchor); 2142 html_tag.d(); 2143 } 2144 } 2145 }; 2146} 2147function create_if_block$8(ctx) { 2148 let div; 2149 let current_block_type_index; 2150 let if_block; 2151 let current; 2152 const if_block_creators = [create_if_block_1$6, create_else_block$3]; 2153 const if_blocks = []; 2154 function select_block_type(ctx2, dirty) { 2155 if (!/*hasClaimed*/ 2156 ctx2[1]) 2157 return 0; 2158 return 1; 2159 } 2160 current_block_type_index = select_block_type(ctx); 2161 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 2162 return { 2163 c() { 2164 div = element("div"); 2165 if_block.c(); 2166 attr(div, "class", "leat-dashboard-earn-card__action svelte-1ghma4t"); 2167 }, 2168 m(target, anchor) { 2169 insert(target, div, anchor); 2170 if_blocks[current_block_type_index].m(div, null); 2171 current = true; 2172 }, 2173 p(ctx2, dirty) { 2174 let previous_block_index = current_block_type_index; 2175 current_block_type_index = select_block_type(ctx2); 2176 if (current_block_type_index === previous_block_index) { 2177 if_blocks[current_block_type_index].p(ctx2, dirty); 2178 } else { 2179 group_outros(); 2180 transition_out(if_blocks[previous_block_index], 1, 1, () => { 2181 if_blocks[previous_block_index] = null; 2182 }); 2183 check_outros(); 2184 if_block = if_blocks[current_block_type_index]; 2185 if (!if_block) { 2186 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2); 2187 if_block.c(); 2188 } else { 2189 if_block.p(ctx2, dirty); 2190 } 2191 transition_in(if_block, 1); 2192 if_block.m(div, null); 2193 } 2194 }, 2195 i(local) { 2196 if (current) 2197 return; 2198 transition_in(if_block); 2199 current = true; 2200 }, 2201 o(local) { 2202 transition_out(if_block); 2203 current = false; 2204 }, 2205 d(detaching) { 2206 if (detaching) { 2207 detach(div); 2208 } 2209 if_blocks[current_block_type_index].d(); 2210 } 2211 }; 2212} 2213function create_else_block$3(ctx) { 2214 let checkcircle; 2215 let current; 2216 checkcircle = new CheckCircle({ props: { size: "24", color: "#3da121" } }); 2217 return { 2218 c() { 2219 create_component(checkcircle.$$.fragment); 2220 }, 2221 m(target, anchor) { 2222 mount_component(checkcircle, target, anchor); 2223 current = true; 2224 }, 2225 p: noop, 2226 i(local) { 2227 if (current) 2228 return; 2229 transition_in(checkcircle.$$.fragment, local); 2230 current = true; 2231 }, 2232 o(local) { 2233 transition_out(checkcircle.$$.fragment, local); 2234 current = false;
2235 }, 2236 d(detaching) { 2237 destroy_component(checkcircle, detaching); 2238 } 2239 }; 2240} 2241function create_if_block_1$6(ctx) { 2242 let button; 2243 let t; 2244 let if_block_anchor; 2245 let current; 2246 button = new Button({ 2247 props: { 2248 loading: ( 2249 /*$claimRewardMutation*/ 2250 ctx[3].isPending 2251 ), 2252 disabled: ( 2253 /*$claimRewardMutation*/ 2254 ctx[3].isPending 2255 ), 2256 variant: "primary", 2257 $$slots: { default: [create_default_slot$4] }, 2258 $$scope: { ctx } 2259 } 2260 }); 2261 button.$on( 2262 "click", 2263 /*handleClaimAndOpenLink*/ 2264 ctx[8] 2265 ); 2266 let if_block = ( 2267 /*$claimRewardMutation*/ 2268 ctx[3].isError && create_if_block_2$4(ctx) 2269 ); 2270 return { 2271 c() { 2272 create_component(button.$$.fragment); 2273 t = space(); 2274 if (if_block) 2275 if_block.c(); 2276 if_block_anchor = empty(); 2277 }, 2278 m(target, anchor) { 2279 mount_component(button, target, anchor); 2280 insert(target, t, anchor); 2281 if (if_block) 2282 if_block.m(target, anchor); 2283 insert(target, if_block_anchor, anchor); 2284 current = true; 2285 }, 2286 p(ctx2, dirty) { 2287 const button_changes = {}; 2288 if (dirty & /*$claimRewardMutation*/ 2289 8) 2290 button_changes.loading = /*$claimRewardMutation*/ 2291 ctx2[3].isPending; 2292 if (dirty & /*$claimRewardMutation*/ 2293 8) 2294 button_changes.disabled = /*$claimRewardMutation*/ 2295 ctx2[3].isPending; 2296 if (dirty & /*$$scope, $pluginSettings*/ 2297 65568) { 2298 button_changes.$$scope = { dirty, ctx: ctx2 }; 2299 } 2300 button.$set(button_changes); 2301 if ( 2302 /*$claimRewardMutation*/ 2303 ctx2[3].isError 2304 ) { 2305 if (if_block) { 2306 if_block.p(ctx2, dirty); 2307 } else { 2308 if_block = create_if_block_2$4(ctx2); 2309 if_block.c(); 2310 if_block.m(if_block_anchor.parentNode, if_block_anchor); 2311 } 2312 } else if (if_block) { 2313 if_block.d(1); 2314 if_block = null; 2315 } 2316 }, 2317 i(local) { 2318 if (current) 2319 return; 2320 transition_in(button.$$.fragment, local); 2321 current = true; 2322 }, 2323 o(local) { 2324 transition_out(button.$$.fragment, local); 2325 current = false; 2326 }, 2327 d(detaching) { 2328 if (detaching) { 2329 detach(t); 2330 detach(if_block_anchor); 2331 } 2332 destroy_component(button, detaching); 2333 if (if_block) 2334 if_block.d(detaching); 2335 } 2336 }; 2337} 2338function create_default_slot$4(ctx) { 2339 let t_value = getTranslatedText( 2340 /*$pluginSettings*/ 2341 ctx[5].dashboard_earn_cta 2342 ) + ""; 2343 let t; 2344 return { 2345 c() { 2346 t = text(t_value); 2347 }, 2348 m(target, anchor) { 2349 insert(target, t, anchor); 2350 }, 2351 p(ctx2, dirty) { 2352 if (dirty & /*$pluginSettings*/ 2353 32 && t_value !== (t_value = getTranslatedText( 2354 /*$pluginSettings*/ 2355 ctx2[5].dashboard_earn_cta 2356 ) + "")) 2357 set_data(t, t_value); 2358 }, 2359 d(detaching) { 2360 if (detaching) { 2361 detach(t); 2362 } 2363 } 2364 }; 2365} 2366function create_if_block_2$4(ctx) { 2367 let div; 2368 let t_value = ( 2369 /*$claimRewardMutation*/ 2370 ctx[3].error.message + "" 2371 ); 2372 let t; 2373 return { 2374 c() { 2375 div = element("div"); 2376 t = text(t_value); 2377 set_style(div, "color", "red"); 2378 set_style(div, "margin-top", "8px"); 2379 set_style(div, "font-size", "13px"); 2380 }, 2381 m(target, anchor) { 2382 insert(target, div, anchor); 2383 append(div, t); 2384 }, 2385 p(ctx2, dirty) { 2386 if (dirty & /*$claimRewardMutation*/ 2387 8 && t_value !== (t_value = /*$claimRewardMutation*/ 2388 ctx2[3].error.message + "")) 2389 set_data(t, t_value); 2390 }, 2391 d(detaching) { 2392 if (detaching) { 2393 detach(div); 2394 } 2395 } 2396 }; 2397} 2398function create_fragment$a(ctx) { 2399 let div2; 2400 let div1; 2401 let div0; 2402 let raw_value = ( 2403 /*earnRule*/ 2404 ctx[0].svg + "" 2405 ); 2406 let t0; 2407 let h4; 2408 let t1; 2409 let current; 2410 let if_block0 = ( 2411 /*earnRule*/ 2412 ctx[0].label.value && create_if_block_3$2(ctx) 2413 ); 2414 let if_block1 = isLoggedIn && /*isSocial*/ 2415 ctx[2] && /*$hasLeatAccount*/ 2416 ctx[4] && create_if_block$8(ctx); 2417 return { 2418 c() { 2419 div2 = element("div"); 2420 div1 = element("div"); 2421 div0 = element("div"); 2422 t0 = space(); 2423 h4 = element("h4"); 2424 if (if_block0) 2425 if_block0.c(); 2426 t1 = space(); 2427 if (if_block1) 2428 if_block1.c(); 2429 attr(div0, "class", "leat-dashboard-earn-card__icon svelte-1ghma4t"); 2430 attr(h4, "class", "leat-dashboard-earn-card__header svelte-1ghma4t"); 2431 attr(div2, "class", "leat-dashboard-earn-card svelte-1ghma4t"); 2432 }, 2433 m(target, anchor) { 2434 insert(target, div2, anchor); 2435 append(div2, div1); 2436 append(div1, div0); 2437 div0.innerHTML = raw_value; 2438 append(div1, t0); 2439 append(div1, h4); 2440 if (if_block0) 2441 if_block0.m(h4, null); 2442 append(div1, t1); 2443 if (if_block1) 2444 if_block1.m(div1, null); 2445 current = true; 2446 }, 2447 p(ctx2, [dirty]) { 2448 if ((!current || dirty & /*earnRule*/ 2449 1) && raw_value !== (raw_value = /*earnRule*/ 2450 ctx2[0].svg + "")) 2451 div0.innerHTML = raw_value; 2452 if ( 2453 /*earnRule*/ 2454 ctx2[0].label.value 2455 ) { 2456 if (if_block0) { 2457 if_block0.p(ctx2, dirty); 2458 } else { 2459 if_block0 = create_if_block_3$2(ctx2); 2460 if_block0.c(); 2461 if_block0.m(h4, null); 2462 } 2463 } else if (if_block0) { 2464 if_block0.d(1); 2465 if_block0 = null; 2466 } 2467 if (isLoggedIn && /*isSocial*/ 2468 ctx2[2] && /*$hasLeatAccount*/ 2469 ctx2[4]) { 2470 if (if_block1) { 2471 if_block1.p(ctx2, dirty);
2472 if (dirty & /*isSocial, $hasLeatAccount*/ 2473 20) { 2474 transition_in(if_block1, 1); 2475 } 2476 } else { 2477 if_block1 = create_if_block$8(ctx2); 2478 if_block1.c(); 2479 transition_in(if_block1, 1); 2480 if_block1.m(div1, null); 2481 } 2482 } else if (if_block1) { 2483 group_outros(); 2484 transition_out(if_block1, 1, 1, () => { 2485 if_block1 = null; 2486 }); 2487 check_outros(); 2488 } 2489 }, 2490 i(local) { 2491 if (current) 2492 return; 2493 transition_in(if_block1); 2494 current = true; 2495 }, 2496 o(local) { 2497 transition_out(if_block1); 2498 current = false; 2499 }, 2500 d(detaching) { 2501 if (detaching) { 2502 detach(div2); 2503 } 2504 if (if_block0) 2505 if_block0.d(); 2506 if (if_block1) 2507 if_block1.d(); 2508 } 2509 }; 2510} 2511function getSocialLink(type, handle) { 2512 switch (type) { 2513 case "LIKE_ON_FACEBOOK": 2514 return `https://www.facebook.com/${handle}`; 2515 case "FOLLOW_ON_INSTAGRAM": 2516 return `https://www.instagram.com/${handle}`; 2517 case "FOLLOW_ON_TIKTOK": 2518 return `https://www.tiktok.com/@${handle}`; 2519 default: 2520 return ""; 2521 } 2522} 2523function instance$a($$self, $$props, $$invalidate) { 2524 let isSocial; 2525 let isClaimableOnce; 2526 let hasClaimed; 2527 let $contactStore; 2528 let $claimRewardMutation; 2529 let $creditsName; 2530 let $hasLeatAccount; 2531 let $pluginSettings; 2532 component_subscribe($$self, contactStore, ($$value) =>
2532 $$invalidate(10, $contactStore = $$value)); 2533 component_subscribe($$self, creditsName, ($$value) => $$invalidate(12, $creditsName = $$value)); 2534 component_subscribe($$self, hasLeatAccount, ($$value) => $$invalidate(4, $hasLeatAccount = $$value)); 2535 component_subscribe($$self, pluginSettings, ($$value) => $$invalidate(5, $pluginSettings = $$value)); 2536 let { earnRule } = $$props; 2537 let socialLinkToOpen = null; 2538 const socialTypes = ["LIKE_ON_FACEBOOK", "FOLLOW_ON_INSTAGRAM", "FOLLOW_ON_TIKTOK"]; 2539 const claimableOnceTypes = [...socialTypes, "CREATE_ACCOUNT"]; 2540 const queryClient = useQueryClient(); 2541 const claimRewardMutation = createMutation({ 2542 mutationKey: [MutationKeys.claimReward], 2543 mutationFn: () => claimReward(earnRule.id, window.leatMiddlewareConfig.userId), 2544 onSuccess: () => { 2545 const handle = earnRule.socialHandle.value; 2546 if (handle) { 2547 socialLinkToOpen = getSocialLink(earnRule.type.value, handle); 2548 } 2549 queryClient.invalidateQueries({ queryKey: [QueryKeys.contact] }); 2550 } 2551 }); 2552 component_subscribe($$self, claimRewardMutation, (value) =>
2552 $$invalidate(3, $claimRewardMutation = value)); 2553 function getLabel(text2, credits) { 2554 if (!text2) 2555 return ""; 2556 const handle = earnRule.socialHandle.value; 2557 return replaceStrings$1(text2, [ 2558 { 2559 "{{ credits_currency }}": $creditsName ?? "", 2560 "{{ credits }}": (credits == null ? void 0 : credits.toString()) ?? "0", 2561 "{{ handle }}": handle ? `@${handle}` : "" 2562 } 2563 ]); 2564 } 2565 function handleClaimAndOpenLink() { 2566 $claimRewardMutation.mutateAsync().then(() => { 2567 if (socialLinkToOpen) { 2568 window.open(socialLinkToOpen, "_blank"); 2569 socialLinkToOpen = null; 2570 } 2571 }); 2572 } 2573 $$self.$$set = ($$props2) => { 2574 if ("earnRule" in $$props2) 2575 $$invalidate(0, earnRule = $$props2.earnRule); 2576 }; 2577 $$self.$$.update = () => { 2578 var _a2; 2579 if ($$self.$$.dirty & /*earnRule*/ 2580 1) { 2581 $$invalidate(2, isSocial = socialTypes.includes(earnRule.type.value)); 2582 } 2583 if ($$self.$$.dirty & /*earnRule*/ 2584 1) { 2585 $$invalidate(9, isClaimableOnce = claimableOnceTypes.includes(earnRule.type.value)); 2586 } 2587 if ($$self.$$.dirty & /*$contactStore, earnRule, isClaimableOnce*/ 2588 1537) { 2589 $$invalidate(1, hasClaimed = (_a2 = $contactStore == null ? void 0 : $contactStore.claimedRewards) == null ? void 0 : _a2.find((reward) => reward.earn_rule_id === earnRule.id.toString() && isClaimableOnce)); 2590 } 2591 }; 2592 return [ 2593 earnRule, 2594 hasClaimed, 2595 isSocial, 2596 $claimRewardMutation, 2597 $hasLeatAccount, 2598 $pluginSettings, 2599 claimRewardMutation, 2600 getLabel, 2601 handleClaimAndOpenLink, 2602 isClaimableOnce, 2603 $contactStore 2604 ]; 2605} 2606class Dashboard_earn_card extends SvelteComponent { 2607 constructor(options) { 2608 super(); 2609 init(this, options, instance$a, create_fragment$a, safe_not_equal, { earnRule: 0 }); 2610 } 2611} 2612function get_each_context$3(ctx, list, i) { 2613 const child_ctx = ctx.slice(); 2614 child_ctx[4] = list[i]; 2615 return child_ctx; 2616} 2617function create_if_block$7(ctx) { 2618 let div1; 2619 let div0; 2620 let h3; 2621 let t0_value = ( 2622 /*getNavItemText*/ 2623 ctx[2](getTranslatedText( 2624 /*$pluginSettings*/ 2625 ctx[1].dashboard_nav_earn 2626 )) + "" 2627 ); 2628 let t0; 2629 let t1; 2630 let current; 2631 let if_block = ( 2632 /*earnRules*/ 2633 ctx[0] && /*earnRules*/ 2634 ctx[0].length > 0 && create_if_block_1$5(ctx) 2635 ); 2636 return { 2637 c() { 2638 div1 = element("div"); 2639 div0 = element("div"); 2640 h3 = element("h3"); 2641 t0 = text(t0_value); 2642 t1 = space(); 2643 if (if_block) 2644 if_block.c(); 2645 attr(h3, "class", "leat-dashboard__header"); 2646 attr(div1, "class", "leat-dashboard-section leat-dashboard-earn"); 2647 }, 2648 m(target, anchor) { 2649 insert(target, div1, anchor); 2650 append(div1, div0); 2651 append(div0, h3); 2652 append(h3, t0); 2653 append(div0, t1); 2654 if (if_block) 2655 if_block.m(div0, null); 2656 current = true; 2657 }, 2658 p(ctx2, dirty) { 2659 if ((!current || dirty & /*$pluginSettings*/ 2660 2) && t0_value !== (t0_value = /*getNavItemText*/ 2661 ctx2[2](getTranslatedText( 2662 /*$pluginSettings*/ 2663 ctx2[1].dashboard_nav_earn 2664 )) + "")) 2665 set_data(t0, t0_value); 2666 if ( 2667 /*earnRules*/ 2668 ctx2[0] && /*earnRules*/ 2669 ctx2[0].length > 0 2670 ) { 2671 if (if_block) { 2672 if_block.p(ctx2, dirty); 2673 if (dirty & /*earnRules*/ 2674 1) { 2675 transition_in(if_block, 1); 2676 } 2677 } else { 2678 if_block = create_if_block_1$5(ctx2); 2679 if_block.c(); 2680 transition_in(if_block, 1); 2681 if_block.m(div0, null); 2682 } 2683 } else if (if_block) { 2684 group_outros(); 2685 transition_out(if_block, 1, 1, () => { 2686 if_block = null; 2687 }); 2688 check_outros(); 2689 } 2690 }, 2691 i(local) { 2692 if (current) 2693 return; 2694 transition_in(if_block); 2695 current = true; 2696 }, 2697 o(local) { 2698 transition_out(if_block); 2699 current = false; 2700 }, 2701 d(detaching) { 2702 if (detaching) { 2703 detach(div1); 2704 } 2705 if (if_block) 2706 if_block.d(); 2707 } 2708 }; 2709} 2710function create_if_block_1$5(ctx) { 2711 let div; 2712 let current; 2713 let each_value = ensure_array_like( 2714 /*earnRules*/ 2715 ctx[0] 2716 ); 2717 let each_blocks = []; 2718 for (let i = 0; i < each_value.length; i += 1) { 2719 each_blocks[i] = create_each_block$3(get_each_context$3(ctx, each_value, i)); 2720 } 2721 const out = (i) => transition_out(each_blocks[i], 1, 1, () => { 2722 each_blocks[i] = null; 2723 }); 2724 return { 2725 c() { 2726 div = element("div"); 2727 for (let i = 0; i < each_blocks.length; i += 1) { 2728 each_blocks[i].c(); 2729 } 2730 attr(div, "class", "leat-dashboard-cards-grid leat-dashboard-earn__cards"); 2731 }, 2732 m(target, anchor) { 2733 insert(target, div, anchor); 2734 for (let i = 0; i < each_blocks.length; i += 1) { 2735 if (each_blocks[i]) { 2736 each_blocks[i].m(div, null); 2737 } 2738 } 2739 current = true; 2740 }, 2741 p(ctx2, dirty) {
2742 if (dirty & /*earnRules*/ 2743 1) { 2744 each_value = ensure_array_like( 2745 /*earnRules*/ 2746 ctx2[0] 2747 ); 2748 let i; 2749 for (i = 0; i < each_value.length; i += 1) { 2750 const child_ctx = get_each_context$3(ctx2, each_value, i); 2751 if (each_blocks[i]) { 2752 each_blocks[i].p(child_ctx, dirty); 2753 transition_in(each_blocks[i], 1); 2754 } else { 2755 each_blocks[i] = create_each_block$3(child_ctx); 2756 each_blocks[i].c(); 2757 transition_in(each_blocks[i], 1); 2758 each_blocks[i].m(div, null); 2759 } 2760 } 2761 group_outros(); 2762 for (i = each_value.length; i < each_blocks.length; i += 1) { 2763 out(i); 2764 } 2765 check_outros(); 2766 } 2767 }, 2768 i(local) { 2769 if (current) 2770 return; 2771 for (let i = 0; i < each_value.length; i += 1) { 2772 transition_in(each_blocks[i]); 2773 } 2774 current = true; 2775 }, 2776 o(local) { 2777 each_blocks = each_blocks.filter(Boolean); 2778 for (let i = 0; i < each_blocks.length; i += 1) { 2779 transition_out(each_blocks[i]); 2780 } 2781 current = false; 2782 }, 2783 d(detaching) { 2784 if (detaching) { 2785 detach(div); 2786 } 2787 destroy_each(each_blocks, detaching); 2788 } 2789 }; 2790} 2791function create_if_block_2$3(ctx) { 2792 let dashboardearncard; 2793 let current; 2794 dashboardearncard = new Dashboard_earn_card({ props: { earnRule: ( 2795 /*earnRule*/ 2796 ctx[4] 2797 ) } }); 2798 return { 2799 c() { 2800 create_component(dashboardearncard.$$.fragment); 2801 }, 2802 m(target, anchor) { 2803 mount_component(dashboardearncard, target, anchor); 2804 current = true; 2805 }, 2806 p(ctx2, dirty) { 2807 const dashboardearncard_changes = {}; 2808 if (dirty & /*earnRules*/ 2809 1) 2810 dashboardearncard_changes.earnRule = /*earnRule*/ 2811 ctx2[4]; 2812 dashboardearncard.$set(dashboardearncard_changes); 2813 }, 2814 i(local) { 2815 if (current) 2816 return; 2817 transition_in(dashboardearncard.$$.fragment, local); 2818 current = true; 2819 }, 2820 o(local) { 2821 transition_out(dashboardearncard.$$.fragment, local); 2822 current = false; 2823 }, 2824 d(detaching) { 2825 destroy_component(dashboardearncard, detaching); 2826 } 2827 }; 2828} 2829function create_each_block$3(ctx) { 2830 let if_block_anchor; 2831 let current; 2832 let if_block = ( 2833 /*earnRule*/ 2834 ctx[4].label.value && create_if_block_2$3(ctx) 2835 ); 2836 return { 2837 c() { 2838 if (if_block) 2839 if_block.c(); 2840 if_block_anchor = empty(); 2841 }, 2842 m(target, anchor) { 2843 if (if_block) 2844 if_block.m(target, anchor); 2845 insert(target, if_block_anchor, anchor); 2846 current = true; 2847 }, 2848 p(ctx2, dirty) { 2849 if ( 2850 /*earnRule*/ 2851 ctx2[4].label.value 2852 ) { 2853 if (if_block) { 2854 if_block.p(ctx2, dirty); 2855 if (dirty & /*earnRules*/ 2856 1) { 2857 transition_in(if_block, 1); 2858 } 2859 } else { 2860 if_block = create_if_block_2$3(ctx2); 2861 if_block.c(); 2862 transition_in(if_block, 1); 2863 if_block.m(if_block_anchor.parentNode, if_block_anchor); 2864 } 2865 } else if (if_block) { 2866 group_outros(); 2867 transition_out(if_block, 1, 1, () => { 2868 if_block = null; 2869 }); 2870 check_outros(); 2871 } 2872 }, 2873 i(local) { 2874 if (current) 2875 return; 2876 transition_in(if_block); 2877 current = true; 2878 }, 2879 o(local) { 2880 transition_out(if_block); 2881 current = false; 2882 }, 2883 d(detaching) { 2884 if (detaching) { 2885 detach(if_block_anchor); 2886 } 2887 if (if_block) 2888 if_block.d(detaching); 2889 } 2890 }; 2891} 2892function create_fragment$9(ctx) { 2893 let if_block_anchor; 2894 let current; 2895 let if_block = ( 2896 /*earnRules*/ 2897 ctx[0] && create_if_block$7(ctx) 2898 ); 2899 return { 2900 c() { 2901 if (if_block) 2902 if_block.c(); 2903 if_block_anchor = empty(); 2904 }, 2905 m(target, anchor) { 2906 if (if_block) 2907 if_block.m(target, anchor); 2908 insert(target, if_block_anchor, anchor); 2909 current = true; 2910 }, 2911 p(ctx2, [dirty]) { 2912 if ( 2913 /*earnRules*/ 2914 ctx2[0] 2915 ) { 2916 if (if_block) { 2917 if_block.p(ctx2, dirty);
2918 if (dirty & /*earnRules*/ 2919 1) { 2920 transition_in(if_block, 1); 2921 } 2922 } else { 2923 if_block = create_if_block$7(ctx2); 2924 if_block.c(); 2925 transition_in(if_block, 1); 2926 if_block.m(if_block_anchor.parentNode, if_block_anchor); 2927 } 2928 } else if (if_block) { 2929 group_outros(); 2930 transition_out(if_block, 1, 1, () => { 2931 if_block = null; 2932 }); 2933 check_outros(); 2934 } 2935 }, 2936 i(local) { 2937 if (current) 2938 return; 2939 transition_in(if_block); 2940 current = true; 2941 }, 2942 o(local) { 2943 transition_out(if_block); 2944 current = false; 2945 }, 2946 d(detaching) { 2947 if (detaching) { 2948 detach(if_block_anchor); 2949 } 2950 if (if_block) 2951 if_block.d(detaching); 2952 } 2953 }; 2954} 2955function instance$9($$self, $$props, $$invalidate) { 2956 let $creditsName; 2957 let $pluginSettings; 2958 component_subscribe($$self, creditsName, ($$value) => $$invalidate(3, $creditsName = $$value)); 2959 component_subscribe($$self, pluginSettings, ($$value) =>
2959 $$invalidate(1, $pluginSettings = $$value)); 2960 let { earnRules = void 0 } = $$props; 2961 function getNavItemText(text2) { 2962 if (!text2) 2963 return ""; 2964 return replaceStrings$1(text2, [ 2965 { 2966 "{{credits_currency}}": $creditsName ?? "" 2967 } 2968 ]); 2969 } 2970 $$self.$$set = ($$props2) => { 2971 if ("earnRules" in $$props2) 2972 $$invalidate(0, earnRules = $$props2.earnRules); 2973 }; 2974 return [earnRules, $pluginSettings, getNavItemText]; 2975} 2976class Dashboard_earn extends SvelteComponent { 2977 constructor(options) { 2978 super(); 2979 init(this, options, instance$9, create_fragment$9, safe_not_equal, { earnRules: 0 }); 2980 } 2981} 2982const dashboardHeaderPts_svelte_svelte_type_style_lang = ""; 2983function get_each_context$2(ctx, list, i) { 2984 const child_ctx = ctx.slice(); 2985 child_ctx[12] = list[i].icon; 2986 child_ctx[13] = list[i].text; 2987 child_ctx[14] = list[i].id; 2988 child_ctx[15] = list[i].show; 2989 return child_ctx; 2990} 2991function get_else_ctx(ctx) { 2992 var _a2, _b2, _c; 2993 const child_ctx = ctx.slice(); 2994 const constants_0 = ( 2995 /*getHeaderTitle*/ 2996 child_ctx[8]( 2997 getTranslatedText( 2998 /*$pluginSettings*/ 2999 child_ctx[4].dashboard_title_logged_in 3000 ), 3001 /*$contactStore*/ 3002 ((_c = (_b2 = (_a2 = child_ctx[5]) == null ? void 0 : _a2.contact) == null ? void 0 : _b2.balance) == null ? void 0 : _c.credits) ?? 0 3003 ) 3004 ); 3005 child_ctx[18] = constants_0; 3006 return child_ctx; 3007} 3008function get_else_ctx_1(ctx) { 3009 const child_ctx = ctx.slice(); 3010 const constants_0 = ( 3011 /*getHeaderTitle*/ 3012 child_ctx[8]( 3013 getTranslatedText( 3014 /*$pluginSettings*/ 3015 child_ctx[4].dashboard_title_logged_out 3016 ) ?? "", 3017 /*signupCredits*/ 3018 child_ctx[1] 3019 ) 3020 ); 3021 child_ctx[18] = constants_0; 3022 return child_ctx; 3023} 3024function create_else_block_2(ctx) { 3025 let if_block_anchor; 3026 function select_block_type_3(ctx2, dirty) { 3027 if ( 3028 /*title*/ 3029 ctx2[18].credits && /*title*/ 3030 ctx2[18].after 3031 ) 3032 return create_if_block_11; 3033 return create_else_block_3; 3034 } 3035 let current_block_type = select_block_type_3(ctx); 3036 let if_block = current_block_type(ctx); 3037 return { 3038 c() { 3039 if_block.c(); 3040 if_block_anchor = empty(); 3041 }, 3042 m(target, anchor) { 3043 if_block.m(target, anchor); 3044 insert(target, if_block_anchor, anchor); 3045 }, 3046 p(ctx2, dirty) { 3047 if (current_block_type === (current_block_type = select_block_type_3(ctx2)) && if_block) { 3048 if_block.p(ctx2, dirty); 3049 } else { 3050 if_block.d(1); 3051 if_block = current_block_type(ctx2); 3052 if (if_block) { 3053 if_block.c(); 3054 if_block.m(if_block_anchor.parentNode, if_block_anchor); 3055 } 3056 } 3057 }, 3058 d(detaching) { 3059 if (detaching) { 3060 detach(if_block_anchor); 3061 } 3062 if_block.d(detaching); 3063 } 3064 }; 3065} 3066function create_if_block_8(ctx) { 3067 let if_block_anchor; 3068 function select_block_type_1(ctx2, dirty) { 3069 if ( 3070 /*isContactNull*/ 3071 ctx2[2] 3072 ) 3073 return create_if_block_9; 3074 return create_else_block$2; 3075 } 3076 function select_block_ctx(ctx2, type) { 3077 if (type === create_else_block$2) 3078 return get_else_ctx(ctx2); 3079 return ctx2; 3080 } 3081 let current_block_type = select_block_type_1(ctx); 3082 let if_block = current_block_type(select_block_ctx(ctx, current_block_type)); 3083 return { 3084 c() { 3085 if_block.c(); 3086 if_block_anchor = empty(); 3087 }, 3088 m(target, anchor) { 3089 if_block.m(target, anchor); 3090 insert(target, if_block_anchor, anchor); 3091 }, 3092 p(ctx2, dirty) { 3093 if (current_block_type === (current_block_type = select_block_type_1(ctx2)) && if_block) { 3094 if_block.p(select_block_ctx(ctx2, current_block_type), dirty); 3095 } else { 3096 if_block.d(1); 3097 if_block = current_block_type(select_block_ctx(ctx2, current_block_type)); 3098 if (if_block) { 3099 if_block.c(); 3100 if_block.m(if_block_anchor.parentNode, if_block_anchor); 3101 } 3102 } 3103 }, 3104 d(detaching) { 3105 if (detaching) { 3106 detach(if_block_anchor); 3107 } 3108 if_block.d(detaching); 3109 } 3110 }; 3111} 3112function create_else_block_3(ctx) { 3113 let t_value = ( 3114 /*title*/ 3115 ctx[18].before + "" 3116 ); 3117 let t; 3118 return { 3119 c() { 3120 t = text(t_value); 3121 }, 3122 m(target, anchor) { 3123 insert(target, t, anchor); 3124 }, 3125 p(ctx2, dirty) {
3126 if (dirty & /*$pluginSettings, signupCredits*/ 3127 18 && t_value !== (t_value = /*title*/ 3128 ctx2[18].before + "")) 3129 set_data(t, t_value); 3130 }, 3131 d(detaching) { 3132 if (detaching) { 3133 detach(t); 3134 } 3135 } 3136 }; 3137} 3138function create_if_block_11(ctx) { 3139 let t0_value = ( 3140 /*title*/ 3141 ctx[18].before + "" 3142 ); 3143 let t0; 3144 let span; 3145 let t1_value = ( 3146 /*title*/ 3147 ctx[18].credits + "" 3148 ); 3149 let t1; 3150 let t2_value = ( 3151 /*title*/ 3152 ctx[18].after + "" 3153 ); 3154 let t2; 3155 return { 3156 c() { 3157 t0 = text(t0_value); 3158 span = element("span"); 3159 t1 = text(t1_value); 3160 t2 = text(t2_value); 3161 attr(span, "class", "leat-credits"); 3162 }, 3163 m(target, anchor) { 3164 insert(target, t0, anchor); 3165 insert(target, span, anchor); 3166 append(span, t1); 3167 insert(target, t2, anchor); 3168 }, 3169 p(ctx2, dirty) { 3170 if (dirty & /*$pluginSettings, signupCredits*/ 3171 18 && t0_value !== (t0_value = /*title*/ 3172 ctx2[18].before + "")) 3173 set_data(t0, t0_value); 3174 if (dirty & /*$pluginSettings, signupCredits*/ 3175 18 && t1_value !== (t1_value = /*title*/ 3176 ctx2[18].credits + "")) 3177 set_data(t1, t1_value); 3178 if (dirty & /*$pluginSettings, signupCredits*/ 3179 18 && t2_value !== (t2_value = /*title*/ 3180 ctx2[18].after + "")) 3181 set_data(t2, t2_value); 3182 }, 3183 d(detaching) { 3184 if (detaching) { 3185 detach(t0); 3186 detach(span); 3187 detach(t2); 3188 } 3189 } 3190 }; 3191} 3192function create_else_block$2(ctx) { 3193 let if_block_anchor; 3194 function select_block_type_2(ctx2, dirty) { 3195 if ( 3196 /*title*/ 3197 ctx2[18].credits 3198 ) 3199 return create_if_block_10; 3200 return create_else_block_1; 3201 } 3202 let current_block_type = select_block_type_2(ctx); 3203 let if_block = current_block_type(ctx); 3204 return { 3205 c() { 3206 if_block.c(); 3207 if_block_anchor = empty(); 3208 }, 3209 m(target, anchor) { 3210 if_block.m(target, anchor); 3211 insert(target, if_block_anchor, anchor); 3212 }, 3213 p(ctx2, dirty) { 3214 if (current_block_type === (current_block_type = select_block_type_2(ctx2)) && if_block) { 3215 if_block.p(ctx2, dirty); 3216 } else { 3217 if_block.d(1); 3218 if_block = current_block_type(ctx2); 3219 if (if_block) { 3220 if_block.c(); 3221 if_block.m(if_block_anchor.parentNode, if_block_anchor); 3222 } 3223 } 3224 }, 3225 d(detaching) { 3226 if (detaching) { 3227 detach(if_block_anchor); 3228 } 3229 if_block.d(detaching); 3230 } 3231 }; 3232} 3233function create_if_block_9(ctx) { 3234 let t_value = getTranslatedText( 3235 /*$pluginSettings*/ 3236 ctx[4].dashboard_title_join_program 3237 ) + ""; 3238 let t; 3239 return { 3240 c() { 3241 t = text(t_value); 3242 }, 3243 m(target, anchor) { 3244 insert(target, t, anchor); 3245 }, 3246 p(ctx2, dirty) { 3247 if (dirty & /*$pluginSettings*/ 3248 16 && t_value !== (t_value = getTranslatedText( 3249 /*$pluginSettings*/ 3250 ctx2[4].dashboard_title_join_program 3251 ) + "")) 3252 set_data(t, t_value); 3253 }, 3254 d(detaching) { 3255 if (detaching) { 3256 detach(t); 3257 } 3258 } 3259 }; 3260} 3261function create_else_block_1(ctx) { 3262 let t_value = ( 3263 /*title*/ 3264 ctx[18].before + "" 3265 ); 3266 let t; 3267 return { 3268 c() { 3269 t = text(t_value); 3270 }, 3271 m(target, anchor) { 3272 insert(target, t, anchor); 3273 }, 3274 p(ctx2, dirty) { 3275 if (dirty & /*$pluginSettings, $contactStore*/ 3276 48 && t_value !== (t_value = /*title*/ 3277 ctx2[18].before + "")) 3278 set_data(t, t_value); 3279 }, 3280 d(detaching) { 3281 if (detaching) { 3282 detach(t); 3283 } 3284 } 3285 }; 3286} 3287function create_if_block_10(ctx) { 3288 let t0_value = ( 3289 /*title*/ 3290 ctx[18].before + "" 3291 ); 3292 let t0; 3293 let span; 3294 let t1_value = ( 3295 /*title*/ 3296 ctx[18].credits + "" 3297 ); 3298 let t1; 3299 let t2_value = ( 3300 /*title*/ 3301 ctx[18].after + "" 3302 ); 3303 let t2; 3304 return { 3305 c() { 3306 t0 = text(t0_value); 3307 span = element("span"); 3308 t1 = text(t1_value); 3309 t2 = text(t2_value); 3310 attr(span, "class", "leat-credits"); 3311 }, 3312 m(target, anchor) { 3313 insert(target, t0, anchor); 3314 insert(target, span, anchor); 3315 append(span, t1); 3316 insert(target, t2, anchor); 3317 }, 3318 p(ctx2, dirty) {
3319 if (dirty & /*$pluginSettings, $contactStore*/ 3320 48 && t0_value !== (t0_value = /*title*/ 3321 ctx2[18].before + "")) 3322 set_data(t0, t0_value); 3323 if (dirty & /*$pluginSettings, $contactStore*/ 3324 48 && t1_value !== (t1_value = /*title*/ 3325 ctx2[18].credits + "")) 3326 set_data(t1, t1_value); 3327 if (dirty & /*$pluginSettings, $contactStore*/ 3328 48 && t2_value !== (t2_value = /*title*/ 3329 ctx2[18].after + "")) 3330 set_data(t2, t2_value); 3331 }, 3332 d(detaching) { 3333 if (detaching) { 3334 detach(t0); 3335 detach(span); 3336 detach(t2); 3337 } 3338 } 3339 }; 3340} 3341function create_if_block_5$1(ctx) { 3342 let div; 3343 let t; 3344 let current; 3345 let if_block0 = ( 3346 /*$pluginSettings*/ 3347 ctx[4].dashboard_show_join_program_cta === "on" && /*$wcSettings*/ 3348 ctx[6].canUserRegister && create_if_block_7$1(ctx) 3349 ); 3350 let if_block1 = ( 3351 /*$joinProgramMutation*/ 3352 ctx[3].isError && create_if_block_6$1(ctx) 3353 ); 3354 return { 3355 c() { 3356 div = element("div"); 3357 if (if_block0) 3358 if_block0.c(); 3359 t = space(); 3360 if (if_block1) 3361 if_block1.c(); 3362 attr(div, "class", "leat-dashboard__cta svelte-s6niyu"); 3363 }, 3364 m(target, anchor) { 3365 insert(target, div, anchor); 3366 if (if_block0) 3367 if_block0.m(div, null); 3368 append(div, t); 3369 if (if_block1) 3370 if_block1.m(div, null); 3371 current = true; 3372 }, 3373 p(ctx2, dirty) { 3374 if ( 3375 /*$pluginSettings*/ 3376 ctx2[4].dashboard_show_join_program_cta === "on" && /*$wcSettings*/ 3377 ctx2[6].canUserRegister 3378 ) { 3379 if (if_block0) { 3380 if_block0.p(ctx2, dirty); 3381 if (dirty & /*$pluginSettings, $wcSettings*/ 3382 80) { 3383 transition_in(if_block0, 1); 3384 } 3385 } else { 3386 if_block0 = create_if_block_7$1(ctx2); 3387 if_block0.c(); 3388 transition_in(if_block0, 1); 3389 if_block0.m(div, t); 3390 } 3391 } else if (if_block0) { 3392 group_outros(); 3393 transition_out(if_block0, 1, 1, () => { 3394 if_block0 = null; 3395 }); 3396 check_outros(); 3397 } 3398 if ( 3399 /*$joinProgramMutation*/ 3400 ctx2[3].isError 3401 ) { 3402 if (if_block1) { 3403 if_block1.p(ctx2, dirty); 3404 } else { 3405 if_block1 = create_if_block_6$1(ctx2); 3406 if_block1.c(); 3407 if_block1.m(div, null); 3408 } 3409 } else if (if_block1) { 3410 if_block1.d(1); 3411 if_block1 = null; 3412 } 3413 }, 3414 i(local) { 3415 if (current) 3416 return; 3417 transition_in(if_block0); 3418 current = true; 3419 }, 3420 o(local) { 3421 transition_out(if_block0); 3422 current = false; 3423 }, 3424 d(detaching) { 3425 if (detaching) { 3426 detach(div); 3427 } 3428 if (if_block0) 3429 if_block0.d(); 3430 if (if_block1) 3431 if_block1.d(); 3432 } 3433 }; 3434} 3435function create_if_block_2$2(ctx) { 3436 var _a2; 3437 let div; 3438 let current; 3439 let if_block = ((_a2 = window.leatWcSettings.storePages.leat_dashboard) == null ? void 0 : _a2.permalink) && create_if_block_3$1(ctx); 3440 return { 3441 c() { 3442 div = element("div"); 3443 if (if_block) 3444 if_block.c(); 3445 attr(div, "class", "leat-dashboard__cta svelte-s6niyu"); 3446 }, 3447 m(target, anchor) { 3448 insert(target, div, anchor); 3449 if (if_block) 3450 if_block.m(div, null); 3451 current = true; 3452 }, 3453 p(ctx2, dirty) { 3454 var _a3; 3455 if ((_a3 = window.leatWcSettings.storePages.leat_dashboard) == null ? void 0 : _a3.permalink) 3456 if_block.p(ctx2, dirty); 3457 }, 3458 i(local) { 3459 if (current) 3460 return; 3461 transition_in(if_block); 3462 current = true; 3463 }, 3464 o(local) { 3465 transition_out(if_block); 3466 current = false; 3467 }, 3468 d(detaching) { 3469 if (detaching) { 3470 detach(div); 3471 } 3472 if (if_block) 3473 if_block.d(); 3474 } 3475 }; 3476} 3477function create_if_block_7$1(ctx) { 3478 let button; 3479 let current; 3480 button = new Button({ 3481 props: { 3482 variant: "primary", 3483 loading: ( 3484 /*$joinProgramMutation*/ 3485 ctx[3].isPending 3486 ), 3487 $$slots: { default: [create_default_slot_2] }, 3488 $$scope: { ctx } 3489 } 3490 }); 3491 button.$on( 3492 "click", 3493 /*handleJoinProgram*/ 3494 ctx[10] 3495 ); 3496 return { 3497 c() { 3498 create_component(button.$$.fragment); 3499 }, 3500 m(target, anchor) { 3501 mount_component(button, target, anchor); 3502 current = true; 3503 }, 3504 p(ctx2, dirty) { 3505 const button_changes = {};
3506 if (dirty & /*$joinProgramMutation*/ 3507 8) 3508 button_changes.loading = /*$joinProgramMutation*/ 3509 ctx2[3].isPending; 3510 if (dirty & /*$$scope, $pluginSettings*/ 3511 524304) { 3512 button_changes.$$scope = { dirty, ctx: ctx2 }; 3513 } 3514 button.$set(button_changes); 3515 }, 3516 i(local) { 3517 if (current) 3518 return; 3519 transition_in(button.$$.fragment, local); 3520 current = true; 3521 }, 3522 o(local) { 3523 transition_out(button.$$.fragment, local); 3524 current = false; 3525 }, 3526 d(detaching) { 3527 destroy_component(button, detaching); 3528 } 3529 }; 3530} 3531function create_default_slot_2(ctx) { 3532 let t_value = getTranslatedText( 3533 /*$pluginSettings*/ 3534 ctx[4].dashboard_join_program_cta 3535 ) + ""; 3536 let t; 3537 return { 3538 c() { 3539 t = text(t_value); 3540 }, 3541 m(target, anchor) { 3542 insert(target, t, anchor); 3543 }, 3544 p(ctx2, dirty) { 3545 if (dirty & /*$pluginSettings*/ 3546 16 && t_value !== (t_value = getTranslatedText( 3547 /*$pluginSettings*/ 3548 ctx2[4].dashboard_join_program_cta 3549 ) + "")) 3550 set_data(t, t_value); 3551 }, 3552 d(detaching) { 3553 if (detaching) { 3554 detach(t); 3555 } 3556 } 3557 }; 3558} 3559function create_if_block_6$1(ctx) { 3560 let p; 3561 let t_value = ( 3562 /*$joinProgramMutation*/ 3563 ctx[3].error.message + "" 3564 ); 3565 let t; 3566 return { 3567 c() { 3568 p = element("p"); 3569 t = text(t_value); 3570 attr(p, "class", "leat-dashboard__error"); 3571 }, 3572 m(target, anchor) { 3573 insert(target, p, anchor); 3574 append(p, t); 3575 }, 3576 p(ctx2, dirty) { 3577 if (dirty & /*$joinProgramMutation*/ 3578 8 && t_value !== (t_value = /*$joinProgramMutation*/ 3579 ctx2[3].error.message + "")) 3580 set_data(t, t_value); 3581 }, 3582 d(detaching) { 3583 if (detaching) { 3584 detach(p); 3585 } 3586 } 3587 }; 3588} 3589function create_if_block_3$1(ctx) { 3590 var _a2; 3591 let t; 3592 let button; 3593 let current; 3594 let if_block = ( 3595 /*$pluginSettings*/ 3596 ctx[4].dashboard_show_join_program_cta === "on" && /*$wcSettings*/ 3597 ctx[6].canUserRegister && create_if_block_4$1(ctx) 3598 ); 3599 button = new Button({ 3600 props: { 3601 href: (_a2 = window.leatWcSettings.storePages.leat_dashboard) == null ? void 0 : _a2.permalink, 3602 variant: "primary", 3603 $$slots: { default: [create_default_slot$3] }, 3604 $$scope: { ctx } 3605 } 3606 }); 3607 return { 3608 c() { 3609 if (if_block) 3610 if_block.c(); 3611 t = space(); 3612 create_component(button.$$.fragment); 3613 }, 3614 m(target, anchor) { 3615 if (if_block) 3616 if_block.m(target, anchor); 3617 insert(target, t, anchor); 3618 mount_component(button, target, anchor); 3619 current = true; 3620 }, 3621 p(ctx2, dirty) { 3622 if ( 3623 /*$pluginSettings*/ 3624 ctx2[4].dashboard_show_join_program_cta === "on" && /*$wcSettings*/ 3625 ctx2[6].canUserRegister 3626 ) { 3627 if (if_block) { 3628 if_block.p(ctx2, dirty); 3629 if (dirty & /*$pluginSettings, $wcSettings*/ 3630 80) { 3631 transition_in(if_block, 1); 3632 } 3633 } else { 3634 if_block = create_if_block_4$1(ctx2); 3635 if_block.c(); 3636 transition_in(if_block, 1); 3637 if_block.m(t.parentNode, t); 3638 } 3639 } else if (if_block) { 3640 group_outros(); 3641 transition_out(if_block, 1, 1, () => { 3642 if_block = null; 3643 }); 3644 check_outros(); 3645 } 3646 const button_changes = {}; 3647 if (dirty & /*$$scope, $pluginSettings*/ 3648 524304) { 3649 button_changes.$$scope = { dirty, ctx: ctx2 }; 3650 } 3651 button.$set(button_changes); 3652 }, 3653 i(local) { 3654 if (current) 3655 return; 3656 transition_in(if_block); 3657 transition_in(button.$$.fragment, local); 3658 current = true; 3659 }, 3660 o(local) { 3661 transition_out(if_block); 3662 transition_out(button.$$.fragment, local); 3663 current = false; 3664 }, 3665 d(detaching) { 3666 if (detaching) { 3667 detach(t); 3668 } 3669 if (if_block) 3670 if_block.d(detaching); 3671 destroy_component(button, detaching); 3672 } 3673 }; 3674} 3675function create_if_block_4$1(ctx) { 3676 var _a2; 3677 let button; 3678 let current; 3679 button = new Button({ 3680 props: { 3681 href: (_a2 = window.leatWcSettings.storePages.leat_dashboard) == null ? void 0 : _a2.permalink, 3682 variant: "primary", 3683 $$slots: { default: [create_default_slot_1] }, 3684 $$scope: { ctx } 3685 } 3686 }); 3687 return { 3688 c() { 3689 create_component(button.$$.fragment); 3690 }, 3691 m(target, anchor) { 3692 mount_component(button, target, anchor); 3693 current = true; 3694 }, 3695 p(ctx2, dirty) { 3696 const button_changes = {};
3697 if (dirty & /*$$scope, $pluginSettings*/ 3698 524304) { 3699 button_changes.$$scope = { dirty, ctx: ctx2 }; 3700 } 3701 button.$set(button_changes); 3702 }, 3703 i(local) { 3704 if (current) 3705 return; 3706 transition_in(button.$$.fragment, local); 3707 current = true; 3708 }, 3709 o(local) { 3710 transition_out(button.$$.fragment, local); 3711 current = false; 3712 }, 3713 d(detaching) { 3714 destroy_component(button, detaching); 3715 } 3716 }; 3717} 3718function create_default_slot_1(ctx) { 3719 let t_value = getTranslatedText( 3720 /*$pluginSettings*/ 3721 ctx[4].dashboard_join_cta 3722 ) + ""; 3723 let t; 3724 return { 3725 c() { 3726 t = text(t_value); 3727 }, 3728 m(target, anchor) { 3729 insert(target, t, anchor); 3730 }, 3731 p(ctx2, dirty) { 3732 if (dirty & /*$pluginSettings*/ 3733 16 && t_value !== (t_value = getTranslatedText( 3734 /*$pluginSettings*/ 3735 ctx2[4].dashboard_join_cta 3736 ) + "")) 3737 set_data(t, t_value); 3738 }, 3739 d(detaching) { 3740 if (detaching) { 3741 detach(t); 3742 } 3743 } 3744 }; 3745} 3746function create_default_slot$3(ctx) { 3747 let t_value = getTranslatedText( 3748 /*$pluginSettings*/ 3749 ctx[4].dashboard_login_cta 3750 ) + ""; 3751 let t; 3752 return { 3753 c() { 3754 t = text(t_value); 3755 }, 3756 m(target, anchor) { 3757 insert(target, t, anchor); 3758 }, 3759 p(ctx2, dirty) { 3760 if (dirty & /*$pluginSettings*/ 3761 16 && t_value !== (t_value = getTranslatedText( 3762 /*$pluginSettings*/ 3763 ctx2[4].dashboard_login_cta 3764 ) + "")) 3765 set_data(t, t_value); 3766 }, 3767 d(detaching) { 3768 if (detaching) { 3769 detach(t); 3770 } 3771 } 3772 }; 3773} 3774function create_if_block$6(ctx) { 3775 let nav; 3776 let ul; 3777 let current; 3778 let each_value = ensure_array_like( 3779 /*navItems*/ 3780 ctx[0] 3781 ); 3782 let each_blocks = []; 3783 for (let i = 0; i < each_value.length; i += 1) { 3784 each_blocks[i] = create_each_block$2(get_each_context$2(ctx, each_value, i)); 3785 } 3786 const out = (i) => transition_out(each_blocks[i], 1, 1, () => { 3787 each_blocks[i] = null; 3788 }); 3789 return { 3790 c() { 3791 nav = element("nav"); 3792 ul = element("ul"); 3793 for (let i = 0; i < each_blocks.length; i += 1) { 3794 each_blocks[i].c(); 3795 } 3796 attr(ul, "class", "leat-dashboard__list svelte-s6niyu"); 3797 attr(nav, "class", "leat-dashboard__nav svelte-s6niyu"); 3798 }, 3799 m(target, anchor) { 3800 insert(target, nav, anchor); 3801 append(nav, ul); 3802 for (let i = 0; i < each_blocks.length; i += 1) { 3803 if (each_blocks[i]) { 3804 each_blocks[i].m(ul, null); 3805 } 3806 } 3807 current = true; 3808 }, 3809 p(ctx2, dirty) { 3810 if (dirty & /*handleScrollNavigation, navItems, getNavItemText*/ 3811 513) { 3812 each_value = ensure_array_like( 3813 /*navItems*/ 3814 ctx2[0] 3815 ); 3816 let i; 3817 for (i = 0; i < each_value.length; i += 1) { 3818 const child_ctx = get_each_context$2(ctx2, each_value, i); 3819 if (each_blocks[i]) { 3820 each_blocks[i].p(child_ctx, dirty); 3821 transition_in(each_blocks[i], 1); 3822 } else { 3823 each_blocks[i] = create_each_block$2(child_ctx); 3824 each_blocks[i].c(); 3825 transition_in(each_blocks[i], 1); 3826 each_blocks[i].m(ul, null); 3827 } 3828 } 3829 group_outros(); 3830 for (i = each_value.length; i < each_blocks.length; i += 1) { 3831 out(i); 3832 } 3833 check_outros(); 3834 } 3835 }, 3836 i(local) { 3837 if (current) 3838 return; 3839 for (let i = 0; i < each_value.length; i += 1) { 3840 transition_in(each_blocks[i]); 3841 } 3842 current = true; 3843 }, 3844 o(local) {
3845 each_blocks = each_blocks.filter(Boolean); 3846 for (let i = 0; i < each_blocks.length; i += 1) { 3847 transition_out(each_blocks[i]); 3848 } 3849 current = false; 3850 }, 3851 d(detaching) { 3852 if (detaching) { 3853 detach(nav); 3854 } 3855 destroy_each(each_blocks, detaching); 3856 } 3857 }; 3858} 3859function create_if_block_1$4(ctx) { 3860 let li; 3861 let button; 3862 let switch_instance; 3863 let t0; 3864 let t1_value = ( 3865 /*getNavItemText*/ 3866 ctx[9]( 3867 /*text*/ 3868 ctx[13] 3869 ) + "" 3870 ); 3871 let t1; 3872 let t2; 3873 let current; 3874 let mounted; 3875 let dispose; 3876 var switch_value = ( 3877 /*icon*/ 3878 ctx[12] 3879 ); 3880 function switch_props(ctx2, dirty) { 3881 return { props: { size: 24 } }; 3882 } 3883 if (switch_value) { 3884 switch_instance = construct_svelte_component(switch_value, switch_props()); 3885 } 3886 return { 3887 c() { 3888 li = element("li"); 3889 button = element("button"); 3890 if (switch_instance) 3891 create_component(switch_instance.$$.fragment); 3892 t0 = space(); 3893 t1 = text(t1_value); 3894 t2 = space(); 3895 attr(button, "class", "leat-dashboard__item svelte-s6niyu"); 3896 }, 3897 m(target, anchor) { 3898 insert(target, li, anchor); 3899 append(li, button); 3900 if (switch_instance) 3901 mount_component(switch_instance, button, null); 3902 append(button, t0); 3903 append(button, t1); 3904 append(li, t2); 3905 current = true; 3906 if (!mounted) { 3907 dispose = listen(button, "click", function() { 3908 if (is_function(handleScrollNavigation( 3909 /*id*/ 3910 ctx[14] 3911 ))) 3912 handleScrollNavigation( 3913 /*id*/ 3914 ctx[14] 3915 ).apply(this, arguments); 3916 }); 3917 mounted = true; 3918 } 3919 }, 3920 p(new_ctx, dirty) { 3921 ctx = new_ctx; 3922 if (dirty & /*navItems*/ 3923 1 && switch_value !== (switch_value = /*icon*/ 3924 ctx[12])) { 3925 if (switch_instance) { 3926 group_outros(); 3927 const old_component = switch_instance; 3928 transition_out(old_component.$$.fragment, 1, 0, () => { 3929 destroy_component(old_component, 1); 3930 }); 3931 check_outros(); 3932 } 3933 if (switch_value) { 3934 switch_instance = construct_svelte_component(switch_value, switch_props()); 3935 create_component(switch_instance.$$.fragment); 3936 transition_in(switch_instance.$$.fragment, 1); 3937 mount_component(switch_instance, button, t0); 3938 } else { 3939 switch_instance = null; 3940 } 3941 } 3942 if ((!current || dirty & /*navItems*/ 3943 1) && t1_value !== (t1_value = /*getNavItemText*/ 3944 ctx[9]( 3945 /*text*/ 3946 ctx[13] 3947 ) + "")) 3948 set_data(t1, t1_value); 3949 }, 3950 i(local) { 3951 if (current) 3952 return; 3953 if (switch_instance) 3954 transition_in(switch_instance.$$.fragment, local); 3955 current = true; 3956 }, 3957 o(local) { 3958 if (switch_instance) 3959 transition_out(switch_instance.$$.fragment, local); 3960 current = false; 3961 }, 3962 d(detaching) { 3963 if (detaching) { 3964 detach(li); 3965 } 3966 if (switch_instance) 3967 destroy_component(switch_instance); 3968 mounted = false; 3969 dispose(); 3970 } 3971 }; 3972} 3973function create_each_block$2(ctx) { 3974 let if_block_anchor; 3975 let current; 3976 let if_block = ( 3977 /*show*/ 3978 ctx[15] && create_if_block_1$4(ctx) 3979 ); 3980 return { 3981 c() { 3982 if (if_block) 3983 if_block.c(); 3984 if_block_anchor = empty(); 3985 }, 3986 m(target, anchor) { 3987 if (if_block) 3988 if_block.m(target, anchor); 3989 insert(target, if_block_anchor, anchor); 3990 current = true; 3991 }, 3992 p(ctx2, dirty) { 3993 if ( 3994 /*show*/ 3995 ctx2[15] 3996 ) { 3997 if (if_block) { 3998 if_block.p(ctx2, dirty); 3999 if (dirty & /*navItems*/ 4000 1) { 4001 transition_in(if_block, 1); 4002 } 4003 } else { 4004 if_block = create_if_block_1$4(ctx2); 4005 if_block.c(); 4006 transition_in(if_block, 1); 4007 if_block.m(if_block_anchor.parentNode, if_block_anchor); 4008 } 4009 } else if (if_block) { 4010 group_outros(); 4011 transition_out(if_block, 1, 1, () => { 4012 if_block = null; 4013 }); 4014 check_outros(); 4015 } 4016 }, 4017 i(local) { 4018 if (current) 4019 return; 4020 transition_in(if_block); 4021 current = true; 4022 }, 4023 o(local) { 4024 transition_out(if_block); 4025 current = false;
4026 }, 4027 d(detaching) { 4028 if (detaching) { 4029 detach(if_block_anchor); 4030 } 4031 if (if_block) 4032 if_block.d(detaching); 4033 } 4034 }; 4035} 4036function create_fragment$8(ctx) { 4037 let section; 4038 let h2; 4039 let t0; 4040 let current_block_type_index; 4041 let if_block1; 4042 let t1; 4043 let current; 4044 function select_block_type(ctx2, dirty) { 4045 if (isLoggedIn) 4046 return create_if_block_8; 4047 return create_else_block_2; 4048 } 4049 function select_block_ctx(ctx2, type) { 4050 if (type === create_else_block_2) 4051 return get_else_ctx_1(ctx2); 4052 return ctx2; 4053 } 4054 let current_block_type = select_block_type(); 4055 let if_block0 = current_block_type(select_block_ctx(ctx, current_block_type)); 4056 const if_block_creators = [create_if_block_2$2, create_if_block_5$1]; 4057 const if_blocks = []; 4058 function select_block_type_4(ctx2, dirty) { 4059 if (!isLoggedIn) 4060 return 0; 4061 if ( 4062 /*isContactNull*/ 4063 ctx2[2] 4064 ) 4065 return 1; 4066 return -1; 4067 } 4068 if (~(current_block_type_index = select_block_type_4(ctx))) { 4069 if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 4070 } 4071 let if_block2 = isLoggedIn && !/*isContactNull*/ 4072 ctx[2] && create_if_block$6(ctx); 4073 return { 4074 c() { 4075 section = element("section"); 4076 h2 = element("h2"); 4077 if_block0.c(); 4078 t0 = space(); 4079 if (if_block1) 4080 if_block1.c(); 4081 t1 = space(); 4082 if (if_block2) 4083 if_block2.c(); 4084 attr(h2, "class", "leat-dashboard__header svelte-s6niyu"); 4085 attr(section, "class", "svelte-s6niyu"); 4086 }, 4087 m(target, anchor) { 4088 insert(target, section, anchor); 4089 append(section, h2); 4090 if_block0.m(h2, null); 4091 append(section, t0); 4092 if (~current_block_type_index) { 4093 if_blocks[current_block_type_index].m(section, null); 4094 } 4095 append(section, t1); 4096 if (if_block2) 4097 if_block2.m(section, null); 4098 current = true; 4099 }, 4100 p(ctx2, [dirty]) { 4101 if_block0.p(select_block_ctx(ctx2, current_block_type), dirty); 4102 let previous_block_index = current_block_type_index; 4103 current_block_type_index = select_block_type_4(ctx2); 4104 if (current_block_type_index === previous_block_index) { 4105 if (~current_block_type_index) { 4106 if_blocks[current_block_type_index].p(ctx2, dirty); 4107 } 4108 } else { 4109 if (if_block1) { 4110 group_outros(); 4111 transition_out(if_blocks[previous_block_index], 1, 1, () => { 4112 if_blocks[previous_block_index] = null; 4113 }); 4114 check_outros(); 4115 } 4116 if (~current_block_type_index) { 4117 if_block1 = if_blocks[current_block_type_index]; 4118 if (!if_block1) { 4119 if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2); 4120 if_block1.c(); 4121 } else { 4122 if_block1.p(ctx2, dirty); 4123 } 4124 transition_in(if_block1, 1); 4125 if_block1.m(section, t1); 4126 } else { 4127 if_block1 = null; 4128 } 4129 } 4130 if (isLoggedIn && !/*isContactNull*/ 4131 ctx2[2]) { 4132 if (if_block2) { 4133 if_block2.p(ctx2, dirty); 4134 if (dirty & /*isContactNull*/ 4135 4) { 4136 transition_in(if_block2, 1); 4137 } 4138 } else { 4139 if_block2 = create_if_block$6(ctx2); 4140 if_block2.c(); 4141 transition_in(if_block2, 1); 4142 if_block2.m(section, null); 4143 } 4144 } else if (if_block2) { 4145 group_outros(); 4146 transition_out(if_block2, 1, 1, () => { 4147 if_block2 = null; 4148 }); 4149 check_outros(); 4150 } 4151 }, 4152 i(local) { 4153 if (current) 4154 return; 4155 transition_in(if_block1); 4156 transition_in(if_block2); 4157 current = true; 4158 }, 4159 o(local) { 4160 transition_out(if_block1); 4161 transition_out(if_block2); 4162 current = false; 4163 }, 4164 d(detaching) { 4165 if (detaching) { 4166 detach(section); 4167 } 4168 if_block0.d(); 4169 if (~current_block_type_index) { 4170 if_blocks[current_block_type_index].d(); 4171 } 4172 if (if_block2) 4173 if_block2.d(); 4174 } 4175 }; 4176} 4177function handleScrollNavigation(id) { 4178 return () => { 4179 const element2 = document.querySelector(`.leat-dashboard-${id}`); 4180 if (element2) { 4181 element2.scrollIntoView({ behavior: "smooth" }); 4182 } 4183 }; 4184}
4185function instance$8($$self, $$props, $$invalidate) { 4186 let isContactNull; 4187 let $hasLeatAccount; 4188 let $joinProgramMutation; 4189 let $pluginSettings; 4190 let $contactStore; 4191 let $wcSettings; 4192 component_subscribe($$self, hasLeatAccount, ($$value) => $$invalidate(11, $hasLeatAccount = $$value)); 4193 component_subscribe($$self, pluginSettings, ($$value) => $$invalidate(4, $pluginSettings = $$value)); 4194 component_subscribe($$self, contactStore, ($$value) => $$invalidate(5, $contactStore = $$value)); 4195 component_subscribe($$self, wcSettings, ($$value) => $$invalidate(6, $wcSettings = $$value)); 4196 let { navItems } = $$props; 4197 let { signupCredits } = $$props; 4198 const joinProgramMutation = createMutation({ 4199 mutationKey: [MutationKeys.joinProgram], 4200 mutationFn: () => joinProgram(window.leatMiddlewareConfig.userId), 4201 onSuccess: () => { 4202 location.reload(); 4203 } 4204 }); 4205 component_subscribe($$self, joinProgramMutation, (value) => $$invalidate(3, $joinProgramMutation = value)); 4206 function getHeaderTitle(text2, credits) { 4207 if (!text2) 4208 return { before: "", credits: "", after: "" }; 4209 const creditsName2 = getTranslatedText($pluginSettings == null ? void 0 : $pluginSettings.credits_name); 4210 const pattern = /^(.*?)\s*\{\{\s*credits\s*\}\}\s*(.*)$/; 4211 const match = text2.match(pattern); 4212 if (!match) { 4213 return { 4214 before: text2, 4215 credits: (credits == null ? void 0 : credits.toString()) ?? "0", 4216 after: "" 4217 }; 4218 } 4219 return { 4220 before: `${replaceStrings$1(match[1], [ 4221 { 4222 "{{credits_currency}}": creditsName2 ?? "" 4223 } 4224 ]).trim()} `, 4225 credits: (credits == null ? void 0 : credits.toString()) ?? "0", 4226 after: ` ${replaceStrings$1(match[2] || "", [ 4227 { 4228 "{{credits_currency}}": creditsName2 ?? "" 4229 } 4230 ]).trim()}` 4231 }; 4232 } 4233 function getNavItemText(text2) { 4234 if (!text2) 4235 return ""; 4236 const creditsName2 = getTranslatedText($pluginSettings == null ? void 0 : $pluginSettings.credits_name); 4237 return replaceStrings$1(text2, [ 4238 { 4239 "{{credits_currency}}": creditsName2 ?? "" 4240 } 4241 ]); 4242 } 4243 function handleJoinProgram() { 4244 $joinProgramMutation.mutate(); 4245 } 4246 $$self.$$set = ($$props2) => { 4247 if ("navItems" in $$props2) 4248 $$invalidate(0, navItems = $$props2.navItems); 4249 if ("signupCredits" in $$props2) 4250 $$invalidate(1, signupCredits = $$props2.signupCredits); 4251 }; 4252 $$self.$$.update = () => { 4253 if ($$self.$$.dirty & /*$hasLeatAccount*/ 4254 2048) { 4255 $$invalidate(2, isContactNull = isLoggedIn && !$hasLeatAccount); 4256 } 4257 }; 4258 return [ 4259 navItems, 4260 signupCredits, 4261 isContactNull, 4262 $joinProgramMutation, 4263 $pluginSettings, 4264 $contactStore, 4265 $wcSettings, 4266 joinProgramMutation, 4267 getHeaderTitle, 4268 getNavItemText, 4269 handleJoinProgram, 4270 $hasLeatAccount 4271 ]; 4272} 4273class Dashboard_header_pts extends SvelteComponent { 4274 constructor(options) { 4275 super(); 4276 init(this, options, instance$8, create_fragment$8, safe_not_equal, { navItems: 0, signupCredits: 1 }); 4277 } 4278} 4279const dashboardSpendRuleCard_svelte_svelte_type_style_lang = ""; 4280function create_if_block_7(ctx) { 4281 let div; 4282 let t; 4283 return { 4284 c() { 4285 div = element("div"); 4286 t = text( 4287 /*creditsRequired*/ 4288 ctx[2] 4289 ); 4290 attr(div, "class", "leat-dashboard-reward-card__badge svelte-6ll6qm"); 4291 }, 4292 m(target, anchor) { 4293 insert(target, div, anchor); 4294 append(div, t); 4295 }, 4296 p(ctx2, dirty) { 4297 if (dirty & /*creditsRequired*/ 4298 4) 4299 set_data( 4300 t, 4301 /*creditsRequired*/ 4302 ctx2[2] 4303 ); 4304 }, 4305 d(detaching) { 4306 if (detaching) { 4307 detach(div); 4308 } 4309 } 4310 }; 4311} 4312function create_else_block$1(ctx) { 4313 let gift; 4314 let current; 4315 gift = new Gift({ props: { size: 48 } }); 4316 return { 4317 c() { 4318 create_component(gift.$$.fragment); 4319 }, 4320 m(target, anchor) { 4321 mount_component(gift, target, anchor); 4322 current = true; 4323 }, 4324 p: noop, 4325 i(local) { 4326 if (current) 4327 return; 4328 transition_in(gift.$$.fragment, local); 4329 current = true; 4330 }, 4331 o(local) { 4332 transition_out(gift.$$.fragment, local); 4333 current = false;
4334 }, 4335 d(detaching) { 4336 destroy_component(gift, detaching); 4337 } 4338 }; 4339} 4340function create_if_block_6(ctx) { 4341 let img; 4342 let img_src_value; 4343 return { 4344 c() { 4345 img = element("img"); 4346 if (!src_url_equal(img.src, img_src_value = /*rule*/ 4347 ctx[0].image.value)) 4348 attr(img, "src", img_src_value); 4349 attr(img, "alt", wp.i18n.__("Reward image", "leat-crm")); 4350 attr(img, "class", "svelte-6ll6qm"); 4351 }, 4352 m(target, anchor) { 4353 insert(target, img, anchor); 4354 }, 4355 p(ctx2, dirty) { 4356 if (dirty & /*rule*/ 4357 1 && !src_url_equal(img.src, img_src_value = /*rule*/ 4358 ctx2[0].image.value)) { 4359 attr(img, "src", img_src_value); 4360 } 4361 }, 4362 i: noop, 4363 o: noop, 4364 d(detaching) { 4365 if (detaching) { 4366 detach(img); 4367 } 4368 } 4369 }; 4370} 4371function create_if_block_5(ctx) { 4372 let t_value = getSpendRuleLabel( 4373 getTranslatedText( 4374 /*rule*/ 4375 ctx[0].label.value 4376 ), 4377 /*rule*/ 4378 ctx[0].creditCost.value, 4379 /*$creditsName*/ 4380 ctx[4], 4381 /*rule*/ 4382 ctx[0].discountValue.value, 4383 /*rule*/ 4384 ctx[0].discountType.value 4385 ) + ""; 4386 let t; 4387 return { 4388 c() { 4389 t = text(t_value); 4390 }, 4391 m(target, anchor) { 4392 insert(target, t, anchor); 4393 }, 4394 p(ctx2, dirty) { 4395 if (dirty & /*rule, $creditsName*/ 4396 17 && t_value !== (t_value = getSpendRuleLabel( 4397 getTranslatedText( 4398 /*rule*/ 4399 ctx2[0].label.value 4400 ), 4401 /*rule*/ 4402 ctx2[0].creditCost.value, 4403 /*$creditsName*/ 4404 ctx2[4], 4405 /*rule*/ 4406 ctx2[0].discountValue.value, 4407 /*rule*/ 4408 ctx2[0].discountType.value 4409 ) + "")) 4410 set_data(t, t_value); 4411 }, 4412 d(detaching) { 4413 if (detaching) { 4414 detach(t); 4415 } 4416 } 4417 }; 4418} 4419function create_if_block_4(ctx) { 4420 let p; 4421 let t_value = ( 4422 /*getDescription*/ 4423 ctx[11]( 4424 getTranslatedText( 4425 /*rule*/ 4426 ctx[0].description.value 4427 ), 4428 /*creditsRequired*/ 4429 ctx[2] 4430 ) + "" 4431 ); 4432 let t; 4433 return { 4434 c() { 4435 p = element("p"); 4436 t = text(t_value); 4437 attr(p, "class", "leat-dashboard-reward-card__description svelte-6ll6qm"); 4438 }, 4439 m(target, anchor) { 4440 insert(target, p, anchor); 4441 append(p, t); 4442 }, 4443 p(ctx2, dirty) { 4444 if (dirty & /*rule, creditsRequired*/ 4445 5 && t_value !== (t_value = /*getDescription*/ 4446 ctx2[11]( 4447 getTranslatedText( 4448 /*rule*/ 4449 ctx2[0].description.value 4450 ), 4451 /*creditsRequired*/ 4452 ctx2[2] 4453 ) + "")) 4454 set_data(t, t_value); 4455 }, 4456 d(detaching) { 4457 if (detaching) { 4458 detach(p); 4459 } 4460 } 4461 }; 4462} 4463function create_if_block_2$1(ctx) { 4464 let div; 4465 let progress_1; 4466 let t; 4467 let if_block = ( 4468 /*$pluginSettings*/ 4469 ctx[6].credits_spend_rule_progress && /*creditsAccumulated*/ 4470 ctx[1] && create_if_block_3(ctx) 4471 ); 4472 return { 4473 c() { 4474 div = element("div"); 4475 progress_1 = element("progress"); 4476 t = space(); 4477 if (if_block) 4478 if_block.c(); 4479 progress_1.value = /*$progress*/ 4480 ctx[5]; 4481 attr(progress_1, "class", "svelte-6ll6qm"); 4482 attr(div, "class", "leat-dashboard-reward-card__progress svelte-6ll6qm"); 4483 }, 4484 m(target, anchor) { 4485 insert(target, div, anchor); 4486 append(div, progress_1); 4487 append(div, t); 4488 if (if_block) 4489 if_block.m(div, null); 4490 }, 4491 p(ctx2, dirty) { 4492 if (dirty & /*$progress*/ 4493 32) { 4494 progress_1.value = /*$progress*/ 4495 ctx2[5]; 4496 } 4497 if ( 4498 /*$pluginSettings*/ 4499 ctx2[6].credits_spend_rule_progress && /*creditsAccumulated*/ 4500 ctx2[1] 4501 ) { 4502 if (if_block) { 4503 if_block.p(ctx2, dirty); 4504 } else { 4505 if_block = create_if_block_3(ctx2); 4506 if_block.c(); 4507 if_block.m(div, null); 4508 } 4509 } else if (if_block) { 4510 if_block.d(1); 4511 if_block = null; 4512 } 4513 }, 4514 d(detaching) { 4515 if (detaching) { 4516 detach(div); 4517 } 4518 if (if_block) 4519 if_block.d(); 4520 } 4521 }; 4522} 4523function create_if_block_3(ctx) { 4524 let p; 4525 let t_value = ( 4526 /*getProgressText*/ 4527 ctx[12]( 4528 getTranslatedText( 4529 /*$pluginSettings*/ 4530 ctx[6].credits_spend_rule_progress 4531 ), 4532 /*creditsRequired*/ 4533 ctx[2] 4534 ) + "" 4535 ); 4536 let t; 4537 return { 4538 c() { 4539 p = element("p"); 4540 t = text(t_value); 4541 attr(p, "class", "svelte-6ll6qm"); 4542 }, 4543 m(target, anchor) { 4544 insert(target, p, anchor); 4545 append(p, t); 4546 }, 4547 p(ctx2, dirty) {
4548 if (dirty & /*$pluginSettings, creditsRequired*/ 4549 68 && t_value !== (t_value = /*getProgressText*/ 4550 ctx2[12]( 4551 getTranslatedText( 4552 /*$pluginSettings*/ 4553 ctx2[6].credits_spend_rule_progress 4554 ), 4555 /*creditsRequired*/ 4556 ctx2[2] 4557 ) + "")) 4558 set_data(t, t_value); 4559 }, 4560 d(detaching) { 4561 if (detaching) { 4562 detach(p); 4563 } 4564 } 4565 }; 4566} 4567function create_if_block$5(ctx) { 4568 let div; 4569 let button; 4570 let t; 4571 let current; 4572 button = new Button({ 4573 props: { 4574 loading: ( 4575 /*$claimSpendRuleMutation*/ 4576 ctx[8].isPending 4577 ), 4578 disabled: ( 4579 /*$claimSpendRuleMutation*/ 4580 ctx[8].isPending || !/*hasEnoughCredits*/ 4581 ctx[3] 4582 ), 4583 variant: "primary", 4584 $$slots: { default: [create_default_slot$2] }, 4585 $$scope: { ctx } 4586 } 4587 }); 4588 button.$on( 4589 "click", 4590 /*click_handler*/ 4591 ctx[14] 4592 ); 4593 let if_block = ( 4594 /*$claimSpendRuleMutation*/ 4595 ctx[8].isError && create_if_block_1$3(ctx) 4596 ); 4597 return { 4598 c() { 4599 div = element("div"); 4600 create_component(button.$$.fragment); 4601 t = space(); 4602 if (if_block) 4603 if_block.c(); 4604 attr(div, "class", "leat-dashboard-earn-card__action svelte-6ll6qm"); 4605 }, 4606 m(target, anchor) { 4607 insert(target, div, anchor); 4608 mount_component(button, div, null); 4609 append(div, t); 4610 if (if_block) 4611 if_block.m(div, null); 4612 current = true; 4613 }, 4614 p(ctx2, dirty) { 4615 const button_changes = {}; 4616 if (dirty & /*$claimSpendRuleMutation*/ 4617 256) 4618 button_changes.loading = /*$claimSpendRuleMutation*/ 4619 ctx2[8].isPending; 4620 if (dirty & /*$claimSpendRuleMutation, hasEnoughCredits*/ 4621 264) 4622 button_changes.disabled = /*$claimSpendRuleMutation*/ 4623 ctx2[8].isPending || !/*hasEnoughCredits*/ 4624 ctx2[3]; 4625 if (dirty & /*$$scope, $pluginSettings*/ 4626 131136) { 4627 button_changes.$$scope = { dirty, ctx: ctx2 }; 4628 } 4629 button.$set(button_changes); 4630 if ( 4631 /*$claimSpendRuleMutation*/ 4632 ctx2[8].isError 4633 ) { 4634 if (if_block) { 4635 if_block.p(ctx2, dirty); 4636 } else { 4637 if_block = create_if_block_1$3(ctx2); 4638 if_block.c(); 4639 if_block.m(div, null); 4640 } 4641 } else if (if_block) { 4642 if_block.d(1); 4643 if_block = null; 4644 } 4645 }, 4646 i(local) { 4647 if (current) 4648 return; 4649 transition_in(button.$$.fragment, local); 4650 current = true; 4651 }, 4652 o(local) { 4653 transition_out(button.$$.fragment, local); 4654 current = false; 4655 }, 4656 d(detaching) { 4657 if (detaching) { 4658 detach(div); 4659 } 4660 destroy_component(button); 4661 if (if_block) 4662 if_block.d(); 4663 } 4664 }; 4665} 4666function create_default_slot$2(ctx) { 4667 let t_value = getTranslatedText( 4668 /*$pluginSettings*/ 4669 ctx[6].dashboard_spend_cta 4670 ) + ""; 4671 let t; 4672 return { 4673 c() { 4674 t = text(t_value); 4675 }, 4676 m(target, anchor) { 4677 insert(target, t, anchor); 4678 }, 4679 p(ctx2, dirty) { 4680 if (dirty & /*$pluginSettings*/ 4681 64 && t_value !== (t_value = getTranslatedText( 4682 /*$pluginSettings*/ 4683 ctx2[6].dashboard_spend_cta 4684 ) + "")) 4685 set_data(t, t_value); 4686 }, 4687 d(detaching) { 4688 if (detaching) { 4689 detach(t); 4690 } 4691 } 4692 }; 4693} 4694function create_if_block_1$3(ctx) { 4695 let div; 4696 let t_value = ( 4697 /*$claimSpendRuleMutation*/ 4698 ctx[8].error.message + "" 4699 ); 4700 let t; 4701 return { 4702 c() { 4703 div = element("div"); 4704 t = text(t_value); 4705 set_style(div, "color", "red"); 4706 set_style(div, "margin-top", "8px"); 4707 set_style(div, "font-size", "13px"); 4708 }, 4709 m(target, anchor) { 4710 insert(target, div, anchor); 4711 append(div, t); 4712 }, 4713 p(ctx2, dirty) { 4714 if (dirty & /*$claimSpendRuleMutation*/ 4715 256 && t_value !== (t_value = /*$claimSpendRuleMutation*/ 4716 ctx2[8].error.message + "")) 4717 set_data(t, t_value); 4718 }, 4719 d(detaching) { 4720 if (detaching) { 4721 detach(div); 4722 } 4723 } 4724 }; 4725} 4726function create_fragment$7(ctx) { 4727 let div1; 4728 let t0; 4729 let div0; 4730 let current_block_type_index; 4731 let if_block1; 4732 let t1; 4733 let h4; 4734 let t2; 4735 let t3; 4736 let t4; 4737 let current; 4738 let if_block0 = ( 4739 /*creditsRequired*/ 4740 ctx[2] && create_if_block_7(ctx) 4741 ); 4742 const if_block_creators = [create_if_block_6, create_else_block$1]; 4743 const if_blocks = []; 4744 function select_block_type(ctx2, dirty) { 4745 var _a2, _b2; 4746 if ( 4747 /*rule*/ 4748 (_b2 = (_a2 = ctx2[0]) == null ? void 0 : _a2.image) == null ? void 0 : _b2.value 4749 ) 4750 return 0; 4751 return 1; 4752 } 4753 current_block_type_index = select_block_type(ctx); 4754 if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 4755 let if_block2 = ( 4756 /*rule*/ 4757 ctx[0].label.value && create_if_block_5(ctx) 4758 ); 4759 let if_block3 = ( 4760 /*rule*/ 4761 ctx[0].description.value && create_if_block_4(ctx) 4762 ); 4763 let if_block4 = ( 4764 /*creditsRequired*/ 4765 ctx[2] && isLoggedIn && create_if_block_2$1(ctx) 4766 ); 4767 let if_block5 = isLoggedIn && /*$hasLeatAccount*/ 4768 ctx[7] && create_if_block$5(ctx); 4769 return { 4770 c() { 4771 div1 = element("div"); 4772 if (if_block0) 4773 if_block0.c(); 4774 t0 = space(); 4775 div0 = element("div"); 4776 if_block1.c(); 4777 t1 = space(); 4778 h4 = element("h4"); 4779 if (if_block2) 4780 if_block2.c(); 4781 t2 = space(); 4782 if (if_block3) 4783 if_block3.c(); 4784 t3 = space(); 4785 if (if_block4) 4786 if_block4.c(); 4787 t4 = space(); 4788 if (if_block5) 4789 if_block5.c(); 4790 attr(div0, "class", "leat-dashboard-reward-card__icon svelte-6ll6qm"); 4791 attr(h4, "class", "leat-dashboard-reward-card__header svelte-6ll6qm"); 4792 attr(div1, "class", "leat-dashboard-reward-card svelte-6ll6qm"); 4793 }, 4794 m(target, anchor) { 4795 insert(target, div1, anchor); 4796 if (if_block0) 4797 if_block0.m(div1, null); 4798 append(div1, t0); 4799 append(div1, div0); 4800 if_blocks[current_block_type_index].m(div0, null); 4801 append(div1, t1); 4802 append(div1, h4); 4803 if (if_block2) 4804 if_block2.m(h4, null); 4805 append(div1, t2); 4806 if (if_block3) 4807 if_block3.m(div1, null); 4808 append(div1, t3); 4809 if (if_block4) 4810 if_block4.m(div1, null); 4811 append(div1, t4); 4812 if (if_block5) 4813 if_block5.m(div1, null); 4814 current = true; 4815 }, 4816 p(ctx2, [dirty]) { 4817 if ( 4818 /*creditsRequired*/ 4819 ctx2[2] 4820 ) { 4821 if (if_block0) { 4822 if_block0.p(ctx2, dirty); 4823 } else { 4824 if_block0 = create_if_block_7(ctx2); 4825 if_block0.c(); 4826 if_block0.m(div1, t0); 4827 } 4828 } else if (if_block0) { 4829 if_block0.d(1); 4830 if_block0 = null; 4831 } 4832 let previous_block_index = current_block_type_index; 4833 current_block_type_index = select_block_type(ctx2); 4834 if (current_block_type_index === previous_block_index) { 4835 if_blocks[current_block_type_index].p(ctx2, dirty); 4836 } else { 4837 group_outros(); 4838 transition_out(if_blocks[previous_block_index], 1, 1, () => { 4839 if_blocks[previous_block_index] = null; 4840 }); 4841 check_outros(); 4842 if_block1 = if_blocks[current_block_type_index]; 4843 if (!if_block1) { 4844 if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2); 4845 if_block1.c(); 4846 } else { 4847 if_block1.p(ctx2, dirty); 4848 } 4849 transition_in(if_block1, 1); 4850 if_block1.m(div0, null); 4851 } 4852 if ( 4853 /*rule*/ 4854 ctx2[0].label.value 4855 ) { 4856 if (if_block2) { 4857 if_block2.p(ctx2, dirty); 4858 } else { 4859 if_block2 = create_if_block_5(ctx2); 4860 if_block2.c(); 4861 if_block2.m(h4, null); 4862 } 4863 } else if (if_block2) { 4864 if_block2.d(1); 4865 if_block2 = null; 4866 } 4867 if ( 4868 /*rule*/ 4869 ctx2[0].description.value 4870 ) { 4871 if (if_block3) { 4872 if_block3.p(ctx2, dirty); 4873 } else { 4874 if_block3 = create_if_block_4(ctx2); 4875 if_block3.c(); 4876 if_block3.m(div1, t3); 4877 } 4878 } else if (if_block3) { 4879 if_block3.d(1); 4880 if_block3 = null; 4881 } 4882 if ( 4883 /*creditsRequired*/ 4884 ctx2[2] && isLoggedIn 4885 ) { 4886 if (if_block4) { 4887 if_block4.p(ctx2, dirty); 4888 } else { 4889 if_block4 = create_if_block_2$1(ctx2); 4890 if_block4.c(); 4891 if_block4.m(div1, t4); 4892 } 4893 } else if (if_block4) { 4894 if_block4.d(1); 4895 if_block4 = null; 4896 } 4897 if (isLoggedIn && /*$hasLeatAccount*/ 4898 ctx2[7]) { 4899 if (if_block5) { 4900 if_block5.p(ctx2, dirty);
4901 if (dirty & /*$hasLeatAccount*/ 4902 128) { 4903 transition_in(if_block5, 1); 4904 } 4905 } else { 4906 if_block5 = create_if_block$5(ctx2); 4907 if_block5.c(); 4908 transition_in(if_block5, 1); 4909 if_block5.m(div1, null); 4910 } 4911 } else if (if_block5) { 4912 group_outros(); 4913 transition_out(if_block5, 1, 1, () => { 4914 if_block5 = null; 4915 }); 4916 check_outros(); 4917 } 4918 }, 4919 i(local) { 4920 if (current) 4921 return; 4922 transition_in(if_block1); 4923 transition_in(if_block5); 4924 current = true; 4925 }, 4926 o(local) { 4927 transition_out(if_block1); 4928 transition_out(if_block5); 4929 current = false; 4930 }, 4931 d(detaching) { 4932 if (detaching) { 4933 detach(div1); 4934 } 4935 if (if_block0) 4936 if_block0.d(); 4937 if_blocks[current_block_type_index].d(); 4938 if (if_block2) 4939 if_block2.d(); 4940 if (if_block3) 4941 if_block3.d(); 4942 if (if_block4) 4943 if_block4.d(); 4944 if (if_block5) 4945 if_block5.d(); 4946 } 4947 }; 4948} 4949function instance$7($$self, $$props, $$invalidate) { 4950 let creditsAccumulated; 4951 let creditsRequired; 4952 let hasEnoughCredits; 4953 let $creditsName; 4954 let $contactStore; 4955 let $progress; 4956 let $pluginSettings; 4957 let $hasLeatAccount; 4958 let $claimSpendRuleMutation; 4959 component_subscribe($$self, creditsName, ($$value) =>
4959 $$invalidate(4, $creditsName = $$value)); 4960 component_subscribe($$self, contactStore, ($$value) => $$invalidate(13, $contactStore = $$value)); 4961 component_subscribe($$self, pluginSettings, ($$value) => $$invalidate(6, $pluginSettings = $$value)); 4962 component_subscribe($$self, hasLeatAccount, ($$value) => $$invalidate(7, $hasLeatAccount = $$value)); 4963 let { rule } = $$props; 4964 const progress = tweened(0, { duration: 450, easing: cubicOut }); 4965 component_subscribe($$self, progress, (value) => $$invalidate(5, $progress = value)); 4966 const client = useQueryClient(); 4967 const claimSpendRuleMutation = createMutation({ 4968 mutationKey: [MutationKeys.claimSpendRule], 4969 mutationFn: () => handleClaim(rule.id), 4970 onSuccess: async () => { 4971 await client.invalidateQueries({ queryKey: [QueryKeys.coupons] }); 4972 await client.refetchQueries({ queryKey: [QueryKeys.coupons] }); 4973 const couponsSection = document.querySelector(".leat-dashboard-coupons"); 4974 if (couponsSection) { 4975 couponsSection.scrollIntoView({ behavior: "smooth" }); 4976 } 4977 } 4978 }); 4979 component_subscribe($$self, claimSpendRuleMutation, (value) =>
4979 $$invalidate(8, $claimSpendRuleMutation = value)); 4980 function handleClaim(id) { 4981 return claimSpendRule(id, window.leatMiddlewareConfig.userId); 4982 } 4983 function getDescription(text2, credits) { 4984 var _a2, _b2; 4985 if (!text2) 4986 return ""; 4987 return replaceStrings$1(text2, [ 4988 { 4989 "{{ credits_currency }}": $creditsName ?? "", 4990 "{{ credits }}": (credits == null ? void 0 : credits.toString()) ?? "0", 4991 "{{ discount }}": ((_b2 = (_a2 = rule.discountValue) == null ? void 0 : _a2.value) == null ? void 0 : _b2.toString()) ?? "0" 4992 } 4993 ]); 4994 } 4995 function getProgressText(text2, creditsRecuired) { 4996 if (!text2) 4997 return ""; 4998 return replaceStrings$1(text2, [ 4999 { 5000 "{{ credits }}": (creditsAccumulated == null ? void 0 : creditsAccumulated.toString()) ?? "0", 5001 "{{ credits_currency }}": $creditsName ?? "", 5002 "{{ credits_required }}": (creditsRecuired == null ? void 0 : creditsRecuired.toString()) ?? "0" 5003 } 5004 ]); 5005 } 5006 const click_handler = () => $claimSpendRuleMutation.mutateAsync(); 5007 $$self.$$set = ($$props2) => { 5008 if ("rule" in $$props2) 5009 $$invalidate(0, rule = $$props2.rule); 5010 }; 5011 $$self.$$.update = () => { 5012 var _a2, _b2; 5013 if ($$self.$$.dirty & /*$contactStore*/ 5014 8192) { 5015 $$invalidate(1, creditsAccumulated = ((_b2 = (_a2 = $contactStore == null ? void 0 : $contactStore.contact) == null ? void 0 : _a2.balance) == null ? void 0 : _b2.credits) ?? 0); 5016 } 5017 if ($$self.$$.dirty & /*rule*/ 5018 1) { 5019 $$invalidate(2, creditsRequired = rule.creditCost.value); 5020 } 5021 if ($$self.$$.dirty & /*creditsRequired, creditsAccumulated*/ 5022 6) { 5023 if (creditsRequired) { 5024 progress.set(creditsAccumulated / creditsRequired); 5025 } 5026 } 5027 if ($$self.$$.dirty & /*creditsAccumulated, creditsRequired*/ 5028 6) { 5029 $$invalidate(3, hasEnoughCredits = creditsAccumulated >= (creditsRequired ?? 0)); 5030 } 5031 }; 5032 return [ 5033 rule, 5034 creditsAccumulated, 5035 creditsRequired, 5036 hasEnoughCredits, 5037 $creditsName, 5038 $progress, 5039 $pluginSettings, 5040 $hasLeatAccount, 5041 $claimSpendRuleMutation, 5042 progress, 5043 claimSpendRuleMutation, 5044 getDescription, 5045 getProgressText, 5046 $contactStore, 5047 click_handler 5048 ]; 5049} 5050class Dashboard_spend_rule_card extends SvelteComponent { 5051 constructor(options) { 5052 super(); 5053 init(this, options, instance$7, create_fragment$7, safe_not_equal, { rule: 0 }); 5054 } 5055} 5056function get_each_context$1(ctx, list, i) { 5057 const child_ctx = ctx.slice(); 5058 child_ctx[5] = list[i]; 5059 return child_ctx; 5060} 5061function create_if_block$4(ctx) { 5062 let div2; 5063 let div1; 5064 let h3; 5065 let t0_value = ( 5066 /*getNavItemText*/ 5067 ctx[2](getTranslatedText( 5068 /*$pluginSettings*/ 5069 ctx[1].dashboard_nav_rewards 5070 )) + "" 5071 ); 5072 let t0; 5073 let t1; 5074 let div0; 5075 let current; 5076 let each_value = ensure_array_like( 5077 /*orderedSpendRules*/ 5078 ctx[0] 5079 ); 5080 let each_blocks = []; 5081 for (let i = 0; i < each_value.length; i += 1) { 5082 each_blocks[i] = create_each_block$1(get_each_context$1(ctx, each_value, i)); 5083 } 5084 const out = (i) => transition_out(each_blocks[i], 1, 1, () => { 5085 each_blocks[i] = null; 5086 }); 5087 return { 5088 c() { 5089 div2 = element("div"); 5090 div1 = element("div"); 5091 h3 = element("h3"); 5092 t0 = text(t0_value); 5093 t1 = space(); 5094 div0 = element("div"); 5095 for (let i = 0; i < each_blocks.length; i += 1) { 5096 each_blocks[i].c(); 5097 } 5098 attr(h3, "class", "leat-dashboard__header"); 5099 attr(div0, "class", "leat-dashboard-cards-grid leat-dashboard-rewards__cards"); 5100 attr(div2, "class", "leat-dashboard-section leat-dashboard-rewards"); 5101 }, 5102 m(target, anchor) { 5103 insert(target, div2, anchor); 5104 append(div2, div1); 5105 append(div1, h3); 5106 append(h3, t0); 5107 append(div1, t1); 5108 append(div1, div0); 5109 for (let i = 0; i < each_blocks.length; i += 1) { 5110 if (each_blocks[i]) { 5111 each_blocks[i].m(div0, null); 5112 } 5113 } 5114 current = true; 5115 }, 5116 p(ctx2, dirty) { 5117 if ((!current || dirty & /*$pluginSettings*/ 5118 2) && t0_value !== (t0_value = /*getNavItemText*/ 5119 ctx2[2](getTranslatedText( 5120 /*$pluginSettings*/ 5121 ctx2[1].dashboard_nav_rewards 5122 )) + "")) 5123 set_data(t0, t0_value);
5124 if (dirty & /*orderedSpendRules*/ 5125 1) { 5126 each_value = ensure_array_like( 5127 /*orderedSpendRules*/ 5128 ctx2[0] 5129 ); 5130 let i; 5131 for (i = 0; i < each_value.length; i += 1) { 5132 const child_ctx = get_each_context$1(ctx2, each_value, i); 5133 if (each_blocks[i]) { 5134 each_blocks[i].p(child_ctx, dirty); 5135 transition_in(each_blocks[i], 1); 5136 } else { 5137 each_blocks[i] = create_each_block$1(child_ctx); 5138 each_blocks[i].c(); 5139 transition_in(each_blocks[i], 1); 5140 each_blocks[i].m(div0, null); 5141 } 5142 } 5143 group_outros(); 5144 for (i = each_value.length; i < each_blocks.length; i += 1) { 5145 out(i); 5146 } 5147 check_outros(); 5148 } 5149 }, 5150 i(local) { 5151 if (current) 5152 return; 5153 for (let i = 0; i < each_value.length; i += 1) { 5154 transition_in(each_blocks[i]); 5155 } 5156 current = true; 5157 }, 5158 o(local) { 5159 each_blocks = each_blocks.filter(Boolean); 5160 for (let i = 0; i < each_blocks.length; i += 1) { 5161 transition_out(each_blocks[i]); 5162 } 5163 current = false; 5164 }, 5165 d(detaching) { 5166 if (detaching) { 5167 detach(div2); 5168 } 5169 destroy_each(each_blocks, detaching); 5170 } 5171 }; 5172} 5173function create_each_block$1(ctx) { 5174 let dashboardspendrulecard; 5175 let current; 5176 dashboardspendrulecard = new Dashboard_spend_rule_card({ props: { rule: ( 5177 /*rule*/ 5178 ctx[5] 5179 ) } }); 5180 return { 5181 c() { 5182 create_component(dashboardspendrulecard.$$.fragment); 5183 }, 5184 m(target, anchor) { 5185 mount_component(dashboardspendrulecard, target, anchor); 5186 current = true; 5187 }, 5188 p(ctx2, dirty) { 5189 const dashboardspendrulecard_changes = {}; 5190 if (dirty & /*orderedSpendRules*/ 5191 1) 5192 dashboardspendrulecard_changes.rule = /*rule*/ 5193 ctx2[5]; 5194 dashboardspendrulecard.$set(dashboardspendrulecard_changes); 5195 }, 5196 i(local) { 5197 if (current) 5198 return; 5199 transition_in(dashboardspendrulecard.$$.fragment, local); 5200 current = true; 5201 }, 5202 o(local) { 5203 transition_out(dashboardspendrulecard.$$.fragment, local); 5204 current = false; 5205 }, 5206 d(detaching) { 5207 destroy_component(dashboardspendrulecard, detaching); 5208 } 5209 }; 5210} 5211function create_fragment$6(ctx) { 5212 let if_block_anchor; 5213 let current; 5214 let if_block = ( 5215 /*orderedSpendRules*/ 5216 ctx[0] && /*orderedSpendRules*/ 5217 ctx[0].length > 0 && create_if_block$4(ctx) 5218 ); 5219 return { 5220 c() { 5221 if (if_block) 5222 if_block.c(); 5223 if_block_anchor = empty(); 5224 }, 5225 m(target, anchor) { 5226 if (if_block) 5227 if_block.m(target, anchor); 5228 insert(target, if_block_anchor, anchor); 5229 current = true; 5230 }, 5231 p(ctx2, [dirty]) { 5232 if ( 5233 /*orderedSpendRules*/ 5234 ctx2[0] && /*orderedSpendRules*/ 5235 ctx2[0].length > 0 5236 ) { 5237 if (if_block) { 5238 if_block.p(ctx2, dirty); 5239 if (dirty & /*orderedSpendRules*/ 5240 1) { 5241 transition_in(if_block, 1); 5242 } 5243 } else { 5244 if_block = create_if_block$4(ctx2); 5245 if_block.c(); 5246 transition_in(if_block, 1); 5247 if_block.m(if_block_anchor.parentNode, if_block_anchor); 5248 } 5249 } else if (if_block) { 5250 group_outros(); 5251 transition_out(if_block, 1, 1, () => { 5252 if_block = null; 5253 }); 5254 check_outros(); 5255 } 5256 }, 5257 i(local) { 5258 if (current) 5259 return; 5260 transition_in(if_block); 5261 current = true; 5262 }, 5263 o(local) { 5264 transition_out(if_block); 5265 current = false; 5266 }, 5267 d(detaching) { 5268 if (detaching) { 5269 detach(if_block_anchor); 5270 } 5271 if (if_block) 5272 if_block.d(detaching); 5273 } 5274 }; 5275} 5276function instance$6($$self, $$props, $$invalidate) { 5277 let orderedSpendRules; 5278 let $creditsName; 5279 let $pluginSettings; 5280 component_subscribe($$self, creditsName, ($$value) =>
5280 $$invalidate(4, $creditsName = $$value)); 5281 component_subscribe($$self, pluginSettings, ($$value) => $$invalidate(1, $pluginSettings = $$value)); 5282 let { spendRules = void 0 } = $$props; 5283 function getNavItemText(text2) { 5284 if (!text2) 5285 return ""; 5286 return replaceStrings$1(text2, [ 5287 { 5288 "{{credits_currency}}": $creditsName ?? "" 5289 } 5290 ]); 5291 } 5292 $$self.$$set = ($$props2) => { 5293 if ("spendRules" in $$props2) 5294 $$invalidate(3, spendRules = $$props2.spendRules); 5295 }; 5296 $$self.$$.update = () => { 5297 if ($$self.$$.dirty & /*spendRules*/ 5298 8) { 5299 $$invalidate(0, orderedSpendRules = spendRules == null ? void 0 : spendRules.sort((a, b) => (b.creditCost.value ?? 0) - (a.creditCost.value ?? 0))); 5300 } 5301 }; 5302 return [orderedSpendRules, $pluginSettings, getNavItemText, spendRules]; 5303} 5304class Dashboard_rewards extends SvelteComponent { 5305 constructor(options) { 5306 super(); 5307 init(this, options, instance$6, create_fragment$6, safe_not_equal, { spendRules: 3 }); 5308 } 5309} 5310const dashboardTierCard_svelte_svelte_type_style_lang = ""; 5311function create_if_block_1$2(ctx) { 5312 let div; 5313 let img; 5314 let img_src_value; 5315 return { 5316 c() { 5317 var _a2; 5318 div = element("div"); 5319 img = element("img"); 5320 if (!src_url_equal(img.src, img_src_value = /*tier*/ 5321 (_a2 = ctx[0].media) == null ? void 0 : _a2.value)) 5322 attr(img, "src", img_src_value); 5323 attr(img, "alt", wp.i18n.__("Tier image", "leat-crm")); 5324 attr(img, "class", "svelte-v4pttw"); 5325 attr(div, "class", "leat-dashboard-tier-card__icon svelte-v4pttw"); 5326 }, 5327 m(target, anchor) { 5328 insert(target, div, anchor); 5329 append(div, img); 5330 }, 5331 p(ctx2, dirty) { 5332 var _a2; 5333 if (dirty & /*tier*/ 5334 1 && !src_url_equal(img.src, img_src_value = /*tier*/ 5335 (_a2 = ctx2[0].media) == null ? void 0 : _a2.value)) { 5336 attr(img, "src", img_src_value); 5337 } 5338 }, 5339 d(detaching) { 5340 if (detaching) { 5341 detach(div); 5342 } 5343 } 5344 }; 5345} 5346function create_if_block$3(ctx) { 5347 let p; 5348 let t_value = ( 5349 /*tier*/ 5350 ctx[0].description + "" 5351 ); 5352 let t; 5353 return { 5354 c() { 5355 p = element("p"); 5356 t = text(t_value); 5357 attr(p, "class", "leat-dashboard-tier-card__description svelte-v4pttw"); 5358 }, 5359 m(target, anchor) { 5360 insert(target, p, anchor); 5361 append(p, t); 5362 }, 5363 p(ctx2, dirty) { 5364 if (dirty & /*tier*/ 5365 1 && t_value !== (t_value = /*tier*/ 5366 ctx2[0].description + "")) 5367 set_data(t, t_value); 5368 }, 5369 d(detaching) { 5370 if (detaching) { 5371 detach(p); 5372 } 5373 } 5374 }; 5375} 5376function create_fragment$5(ctx) { 5377 var _a2; 5378 let div; 5379 let t0; 5380 let h4; 5381 let t1_value = ( 5382 /*tier*/ 5383 ctx[0].name + "" 5384 ); 5385 let t1; 5386 let t2; 5387 let div_class_value; 5388 let if_block0 = ( 5389 /*tier*/ 5390 ((_a2 = ctx[0].media) == null ? void 0 : _a2.value) && create_if_block_1$2(ctx) 5391 ); 5392 let if_block1 = ( 5393 /*tier*/ 5394 ctx[0].description && create_if_block$3(ctx) 5395 ); 5396 return { 5397 c() { 5398 div = element("div"); 5399 if (if_block0) 5400 if_block0.c(); 5401 t0 = space(); 5402 h4 = element("h4"); 5403 t1 = text(t1_value); 5404 t2 = space(); 5405 if (if_block1) 5406 if_block1.c(); 5407 attr(h4, "class", "leat-dashboard-tier-card__header svelte-v4pttw"); 5408 attr(div, "class", div_class_value = null_to_empty(cn( 5409 "leat-dashboard-tier-card", 5410 /*isCurrentTier*/ 5411 ctx[1] && "leat-dashboard-tier-card--current" 5412 )) + " svelte-v4pttw"); 5413 }, 5414 m(target, anchor) { 5415 insert(target, div, anchor); 5416 if (if_block0) 5417 if_block0.m(div, null); 5418 append(div, t0); 5419 append(div, h4); 5420 append(h4, t1); 5421 append(div, t2); 5422 if (if_block1) 5423 if_block1.m(div, null); 5424 }, 5425 p(ctx2, [dirty]) { 5426 var _a3; 5427 if ( 5428 /*tier*/ 5429 (_a3 = ctx2[0].media) == null ? void 0 : _a3.value 5430 ) { 5431 if (if_block0) { 5432 if_block0.p(ctx2, dirty); 5433 } else { 5434 if_block0 = create_if_block_1$2(ctx2); 5435 if_block0.c(); 5436 if_block0.m(div, t0); 5437 } 5438 } else if (if_block0) { 5439 if_block0.d(1); 5440 if_block0 = null; 5441 }
5442 if (dirty & /*tier*/ 5443 1 && t1_value !== (t1_value = /*tier*/ 5444 ctx2[0].name + "")) 5445 set_data(t1, t1_value); 5446 if ( 5447 /*tier*/ 5448 ctx2[0].description 5449 ) { 5450 if (if_block1) { 5451 if_block1.p(ctx2, dirty); 5452 } else { 5453 if_block1 = create_if_block$3(ctx2); 5454 if_block1.c(); 5455 if_block1.m(div, null); 5456 } 5457 } else if (if_block1) { 5458 if_block1.d(1); 5459 if_block1 = null; 5460 } 5461 if (dirty & /*isCurrentTier*/ 5462 2 && div_class_value !== (div_class_value = null_to_empty(cn( 5463 "leat-dashboard-tier-card", 5464 /*isCurrentTier*/ 5465 ctx2[1] && "leat-dashboard-tier-card--current" 5466 )) + " svelte-v4pttw")) { 5467 attr(div, "class", div_class_value); 5468 } 5469 }, 5470 i: noop, 5471 o: noop, 5472 d(detaching) { 5473 if (detaching) { 5474 detach(div); 5475 } 5476 if (if_block0) 5477 if_block0.d(); 5478 if (if_block1) 5479 if_block1.d(); 5480 } 5481 }; 5482} 5483function instance$5($$self, $$props, $$invalidate) { 5484 let { tier } = $$props; 5485 let { isCurrentTier } = $$props; 5486 $$self.$$set = ($$props2) => { 5487 if ("tier" in $$props2) 5488 $$invalidate(0, tier = $$props2.tier); 5489 if ("isCurrentTier" in $$props2) 5490 $$invalidate(1, isCurrentTier = $$props2.isCurrentTier); 5491 }; 5492 return [tier, isCurrentTier]; 5493} 5494class Dashboard_tier_card extends SvelteComponent { 5495 constructor(options) { 5496 super(); 5497 init(this, options, instance$5, create_fragment$5, safe_not_equal, { tier: 0, isCurrentTier: 1 }); 5498 } 5499} 5500function get_each_context(ctx, list, i) { 5501 const child_ctx = ctx.slice(); 5502 child_ctx[4] = list[i]; 5503 return child_ctx; 5504} 5505function create_if_block$2(ctx) { 5506 let div; 5507 let current; 5508 let each_value = ensure_array_like( 5509 /*tiersPositioned*/ 5510 ctx[1] 5511 ); 5512 let each_blocks = []; 5513 for (let i = 0; i < each_value.length; i += 1) { 5514 each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); 5515 } 5516 const out = (i) => transition_out(each_blocks[i], 1, 1, () => { 5517 each_blocks[i] = null; 5518 }); 5519 return { 5520 c() { 5521 div = element("div"); 5522 for (let i = 0; i < each_blocks.length; i += 1) { 5523 each_blocks[i].c(); 5524 } 5525 attr(div, "class", "leat-dashboard-cards-grid leat-dashboard-tiers__cards"); 5526 }, 5527 m(target, anchor) { 5528 insert(target, div, anchor); 5529 for (let i = 0; i < each_blocks.length; i += 1) { 5530 if (each_blocks[i]) { 5531 each_blocks[i].m(div, null); 5532 } 5533 } 5534 current = true; 5535 }, 5536 p(ctx2, dirty) { 5537 if (dirty & /*tiersPositioned, currentTier*/ 5538 3) { 5539 each_value = ensure_array_like( 5540 /*tiersPositioned*/ 5541 ctx2[1] 5542 ); 5543 let i; 5544 for (i = 0; i < each_value.length; i += 1) { 5545 const child_ctx = get_each_context(ctx2, each_value, i); 5546 if (each_blocks[i]) { 5547 each_blocks[i].p(child_ctx, dirty); 5548 transition_in(each_blocks[i], 1); 5549 } else { 5550 each_blocks[i] = create_each_block(child_ctx); 5551 each_blocks[i].c(); 5552 transition_in(each_blocks[i], 1); 5553 each_blocks[i].m(div, null); 5554 } 5555 } 5556 group_outros(); 5557 for (i = each_value.length; i < each_blocks.length; i += 1) { 5558 out(i); 5559 } 5560 check_outros(); 5561 } 5562 }, 5563 i(local) { 5564 if (current) 5565 return; 5566 for (let i = 0; i < each_value.length; i += 1) { 5567 transition_in(each_blocks[i]); 5568 } 5569 current = true; 5570 }, 5571 o(local) {
5572 each_blocks = each_blocks.filter(Boolean); 5573 for (let i = 0; i < each_blocks.length; i += 1) { 5574 transition_out(each_blocks[i]); 5575 } 5576 current = false; 5577 }, 5578 d(detaching) { 5579 if (detaching) { 5580 detach(div); 5581 } 5582 destroy_each(each_blocks, detaching); 5583 } 5584 }; 5585} 5586function create_each_block(ctx) { 5587 var _a2; 5588 let dashboardtiercard; 5589 let current; 5590 dashboardtiercard = new Dashboard_tier_card({ 5591 props: { 5592 tier: ( 5593 /*tier*/ 5594 ctx[4] 5595 ), 5596 isCurrentTier: ( 5597 /*tier*/ 5598 ctx[4].id === /*currentTier*/ 5599 ((_a2 = ctx[0]) == null ? void 0 : _a2.id) 5600 ) 5601 } 5602 }); 5603 return { 5604 c() { 5605 create_component(dashboardtiercard.$$.fragment); 5606 }, 5607 m(target, anchor) { 5608 mount_component(dashboardtiercard, target, anchor); 5609 current = true; 5610 }, 5611 p(ctx2, dirty) { 5612 var _a3; 5613 const dashboardtiercard_changes = {}; 5614 if (dirty & /*tiersPositioned*/ 5615 2) 5616 dashboardtiercard_changes.tier = /*tier*/ 5617 ctx2[4]; 5618 if (dirty & /*tiersPositioned, currentTier*/ 5619 3) 5620 dashboardtiercard_changes.isCurrentTier = /*tier*/ 5621 ctx2[4].id === /*currentTier*/ 5622 ((_a3 = ctx2[0]) == null ? void 0 : _a3.id); 5623 dashboardtiercard.$set(dashboardtiercard_changes); 5624 }, 5625 i(local) { 5626 if (current) 5627 return; 5628 transition_in(dashboardtiercard.$$.fragment, local); 5629 current = true; 5630 }, 5631 o(local) { 5632 transition_out(dashboardtiercard.$$.fragment, local); 5633 current = false; 5634 }, 5635 d(detaching) { 5636 destroy_component(dashboardtiercard, detaching); 5637 } 5638 }; 5639} 5640function create_fragment$4(ctx) { 5641 var _a2; 5642 let div1; 5643 let div0; 5644 let h3; 5645 let t0_value = getTranslatedText( 5646 /*$pluginSettings*/ 5647 (_a2 = ctx[2]) == null ? void 0 : _a2.dashboard_nav_tiers 5648 ) + ""; 5649 let t0; 5650 let t1; 5651 let current; 5652 let if_block = ( 5653 /*tiersPositioned*/ 5654 ctx[1] && /*tiersPositioned*/ 5655 ctx[1].length > 0 && create_if_block$2(ctx) 5656 ); 5657 return { 5658 c() { 5659 div1 = element("div"); 5660 div0 = element("div"); 5661 h3 = element("h3"); 5662 t0 = text(t0_value); 5663 t1 = space(); 5664 if (if_block) 5665 if_block.c(); 5666 attr(h3, "class", "leat-dashboard__header"); 5667 attr(div1, "class", "leat-dashboard-section leat-dashboard-tiers"); 5668 }, 5669 m(target, anchor) { 5670 insert(target, div1, anchor); 5671 append(div1, div0); 5672 append(div0, h3); 5673 append(h3, t0); 5674 append(div1, t1); 5675 if (if_block) 5676 if_block.m(div1, null); 5677 current = true; 5678 }, 5679 p(ctx2, [dirty]) { 5680 var _a3; 5681 if ((!current || dirty & /*$pluginSettings*/ 5682 4) && t0_value !== (t0_value = getTranslatedText( 5683 /*$pluginSettings*/ 5684 (_a3 = ctx2[2]) == null ? void 0 : _a3.dashboard_nav_tiers 5685 ) + "")) 5686 set_data(t0, t0_value); 5687 if ( 5688 /*tiersPositioned*/ 5689 ctx2[1] && /*tiersPositioned*/ 5690 ctx2[1].length > 0 5691 ) { 5692 if (if_block) { 5693 if_block.p(ctx2, dirty); 5694 if (dirty & /*tiersPositioned*/ 5695 2) { 5696 transition_in(if_block, 1); 5697 } 5698 } else { 5699 if_block = create_if_block$2(ctx2); 5700 if_block.c(); 5701 transition_in(if_block, 1); 5702 if_block.m(div1, null); 5703 } 5704 } else if (if_block) { 5705 group_outros(); 5706 transition_out(if_block, 1, 1, () => { 5707 if_block = null; 5708 }); 5709 check_outros(); 5710 } 5711 }, 5712 i(local) { 5713 if (current) 5714 return; 5715 transition_in(if_block); 5716 current = true; 5717 }, 5718 o(local) { 5719 transition_out(if_block); 5720 current = false; 5721 }, 5722 d(detaching) { 5723 if (detaching) { 5724 detach(div1); 5725 } 5726 if (if_block) 5727 if_block.d(); 5728 } 5729 }; 5730} 5731function instance$4($$self, $$props, $$invalidate) { 5732 let tiersPositioned; 5733 let $pluginSettings; 5734 component_subscribe($$self, pluginSettings, ($$value) =>
5734 $$invalidate(2, $pluginSettings = $$value)); 5735 let { tiers = [] } = $$props; 5736 let { currentTier = void 0 } = $$props; 5737 $$self.$$set = ($$props2) => { 5738 if ("tiers" in $$props2) 5739 $$invalidate(3, tiers = $$props2.tiers); 5740 if ("currentTier" in $$props2) 5741 $$invalidate(0, currentTier = $$props2.currentTier); 5742 }; 5743 $$self.$$.update = () => { 5744 if ($$self.$$.dirty & /*tiers*/ 5745 8) { 5746 $$invalidate(1, tiersPositioned = tiers == null ? void 0 : tiers.sort((a, b) => a.position - b.position)); 5747 } 5748 }; 5749 return [currentTier, tiersPositioned, $pluginSettings, tiers]; 5750} 5751class Dashboard_tiers extends SvelteComponent { 5752 constructor(options) { 5753 super(); 5754 init(this, options, instance$4, create_fragment$4, safe_not_equal, { tiers: 3, currentTier: 0 }); 5755 } 5756} 5757const dashboardReferralCard_svelte_svelte_type_style_lang = ""; 5758function create_fragment$3(ctx) { 5759 let div2; 5760 let div0; 5761 let switch_instance; 5762 let t0; 5763 let h4; 5764 let t1; 5765 let t2; 5766 let div1; 5767 let t3; 5768 let current; 5769 var switch_value = ( 5770 /*icon*/ 5771 ctx[0] 5772 ); 5773 function switch_props(ctx2, dirty) { 5774 return { props: { size: 32 } }; 5775 } 5776 if (switch_value) { 5777 switch_instance = construct_svelte_component(switch_value, switch_props()); 5778 } 5779 return { 5780 c() { 5781 div2 = element("div"); 5782 div0 = element("div"); 5783 if (switch_instance) 5784 create_component(switch_instance.$$.fragment); 5785 t0 = space(); 5786 h4 = element("h4"); 5787 t1 = text( 5788 /*title*/ 5789 ctx[1] 5790 ); 5791 t2 = space(); 5792 div1 = element("div"); 5793 t3 = text( 5794 /*value*/ 5795 ctx[2] 5796 ); 5797 attr(div0, "class", "leat-dashboard-referral-card__icon svelte-6k8wq4"); 5798 attr(h4, "class", "leat-dashboard-referral-card__title svelte-6k8wq4"); 5799 attr(div1, "class", "leat-dashboard-referral-card__value svelte-6k8wq4"); 5800 attr(div2, "class", "leat-dashboard-card leat-dashboard-referral-card svelte-6k8wq4"); 5801 }, 5802 m(target, anchor) { 5803 insert(target, div2, anchor); 5804 append(div2, div0); 5805 if (switch_instance) 5806 mount_component(switch_instance, div0, null); 5807 append(div2, t0); 5808 append(div2, h4); 5809 append(h4, t1); 5810 append(div2, t2); 5811 append(div2, div1); 5812 append(div1, t3); 5813 current = true; 5814 }, 5815 p(ctx2, [dirty]) { 5816 if (dirty & /*icon*/ 5817 1 && switch_value !== (switch_value = /*icon*/ 5818 ctx2[0])) { 5819 if (switch_instance) { 5820 group_outros(); 5821 const old_component = switch_instance; 5822 transition_out(old_component.$$.fragment, 1, 0, () => { 5823 destroy_component(old_component, 1); 5824 }); 5825 check_outros(); 5826 } 5827 if (switch_value) { 5828 switch_instance = construct_svelte_component(switch_value, switch_props()); 5829 create_component(switch_instance.$$.fragment); 5830 transition_in(switch_instance.$$.fragment, 1); 5831 mount_component(switch_instance, div0, null); 5832 } else { 5833 switch_instance = null; 5834 } 5835 } 5836 if (!current || dirty & /*title*/ 5837 2) 5838 set_data( 5839 t1, 5840 /*title*/ 5841 ctx2[1] 5842 ); 5843 if (!current || dirty & /*value*/ 5844 4) 5845 set_data( 5846 t3, 5847 /*value*/ 5848 ctx2[2] 5849 ); 5850 }, 5851 i(local) { 5852 if (current) 5853 return; 5854 if (switch_instance) 5855 transition_in(switch_instance.$$.fragment, local); 5856 current = true; 5857 }, 5858 o(local) { 5859 if (switch_instance) 5860 transition_out(switch_instance.$$.fragment, local); 5861 current = false; 5862 }, 5863 d(detaching) { 5864 if (detaching) { 5865 detach(div2); 5866 } 5867 if (switch_instance) 5868 destroy_component(switch_instance); 5869 } 5870 }; 5871} 5872function instance$3($$self, $$props, $$invalidate) { 5873 let { icon } = $$props; 5874 let { title } = $$props; 5875 let { value = void 0 } = $$props; 5876 $$self.$$set = ($$props2) => { 5877 if ("icon" in $$props2) 5878 $$invalidate(0, icon = $$props2.icon); 5879 if ("title" in $$props2) 5880 $$invalidate(1, title = $$props2.title); 5881 if ("value" in $$props2)
5882 $$invalidate(2, value = $$props2.value); 5883 }; 5884 return [icon, title, value]; 5885} 5886class Dashboard_referral_card extends SvelteComponent { 5887 constructor(options) { 5888 super(); 5889 init(this, options, instance$3, create_fragment$3, safe_not_equal, { icon: 0, title: 1, value: 2 }); 5890 } 5891} 5892const dashboardReferrals_svelte_svelte_type_style_lang = ""; 5893function create_else_block(ctx) { 5894 let copy; 5895 let current; 5896 copy = new Copy({ props: { size: 16 } }); 5897 return { 5898 c() { 5899 create_component(copy.$$.fragment); 5900 }, 5901 m(target, anchor) { 5902 mount_component(copy, target, anchor); 5903 current = true; 5904 }, 5905 i(local) { 5906 if (current) 5907 return; 5908 transition_in(copy.$$.fragment, local); 5909 current = true; 5910 }, 5911 o(local) { 5912 transition_out(copy.$$.fragment, local); 5913 current = false; 5914 }, 5915 d(detaching) { 5916 destroy_component(copy, detaching); 5917 } 5918 }; 5919} 5920function create_if_block$1(ctx) { 5921 let check; 5922 let current; 5923 check = new Check({ props: { size: 16 } }); 5924 return { 5925 c() { 5926 create_component(check.$$.fragment); 5927 }, 5928 m(target, anchor) { 5929 mount_component(check, target, anchor); 5930 current = true; 5931 }, 5932 i(local) { 5933 if (current) 5934 return; 5935 transition_in(check.$$.fragment, local); 5936 current = true; 5937 }, 5938 o(local) { 5939 transition_out(check.$$.fragment, local); 5940 current = false; 5941 }, 5942 d(detaching) { 5943 destroy_component(check, detaching); 5944 } 5945 }; 5946} 5947function create_default_slot$1(ctx) { 5948 var _a2; 5949 let t_value = getTranslatedText( 5950 /*$pluginSettings*/ 5951 (_a2 = ctx[3]) == null ? void 0 : _a2.dashboard_referrals_share_button 5952 ) + ""; 5953 let t; 5954 return { 5955 c() { 5956 t = text(t_value); 5957 }, 5958 m(target, anchor) { 5959 insert(target, t, anchor); 5960 }, 5961 p(ctx2, dirty) { 5962 var _a3; 5963 if (dirty & /*$pluginSettings*/ 5964 8 && t_value !== (t_value = getTranslatedText( 5965 /*$pluginSettings*/ 5966 (_a3 = ctx2[3]) == null ? void 0 : _a3.dashboard_referrals_share_button 5967 ) + "")) 5968 set_data(t, t_value); 5969 }, 5970 d(detaching) { 5971 if (detaching) { 5972 detach(t); 5973 } 5974 } 5975 }; 5976} 5977function create_fragment$2(ctx) { 5978 var _a2, _b2, _c, _d, _e; 5979 let div6; 5980 let div5; 5981 let h3; 5982 let t0_value = getTranslatedText( 5983 /*$pluginSettings*/ 5984 (_a2 = ctx[3]) == null ? void 0 : _a2.dashboard_nav_referrals 5985 ) + ""; 5986 let t0; 5987 let t1; 5988 let div0; 5989 let p; 5990 let t2_value = (getTranslatedText( 5991 /*$pluginSettings*/ 5992 (_b2 = ctx[3]) == null ? void 0 : _b2.dashboard_referrals_description 5993 ) || "Share your referral link with friends and earn rewards when they sign up!") + ""; 5994 let t2; 5995 let t3; 5996 let div4; 5997 let div3; 5998 let div1; 5999 let share2; 6000 let t4; 6001 let h4; 6002 let t5_value = (getTranslatedText( 6003 /*$pluginSettings*/ 6004 (_c = ctx[3]) == null ? void 0 : _c.dashboard_referrals_link_title 6005 ) || "Your Referral Link") + ""; 6006 let t5; 6007 let t6; 6008 let div2; 6009 let span; 6010 let t8; 6011 let button0; 6012 let current_block_type_index; 6013 let if_block; 6014 let t9; 6015 let button1; 6016 let t10; 6017 let dashboardreferralcard0; 6018 let t11; 6019 let dashboardreferralcard1; 6020 let current; 6021 let mounted; 6022 let dispose; 6023 share2 = new Share2({ props: { size: 24 } }); 6024 const if_block_creators = [create_if_block$1, create_else_block]; 6025 const if_blocks = []; 6026 function select_block_type(ctx2, dirty) { 6027 if ( 6028 /*copiedUrl*/ 6029 ctx2[2] 6030 ) 6031 return 0; 6032 return 1; 6033 } 6034 current_block_type_index = select_block_type(ctx); 6035 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); 6036 button1 = new Button({ 6037 props: { 6038 variant: "primary", 6039 $$slots: { default: [create_default_slot$1] }, 6040 $$scope: { ctx } 6041 } 6042 }); 6043 button1.$on( 6044 "click", 6045 /*shareReferralUrl*/ 6046 ctx[6] 6047 ); 6048 dashboardreferralcard0 = new Dashboard_referral_card({ 6049 props: { 6050 icon: Users, 6051 title: getTranslatedText( 6052 /*$pluginSettings*/ 6053 (_d = ctx[3]) == null ? void 0 : _d.dashboard_referrals_referred_title 6054 ), 6055 value: ( 6056 /*referredContacts*/ 6057 ctx[1] 6058 ) 6059 } 6060 }); 6061 dashboardreferralcard1 = new Dashboard_referral_card({ 6062 props: { 6063 icon: UserCheck, 6064 title: getTranslatedText( 6065 /*$pluginSettings*/ 6066 (_e = ctx[3]) == null ? void 0 : _e.dashboard_referrals_completed_title 6067 ), 6068 value: ( 6069 /*completedReferrals*/ 6070 ctx[0] 6071 ) 6072 } 6073 }); 6074 return { 6075 c() { 6076 div6 = element("div"); 6077 div5 = element("div"); 6078 h3 = element("h3"); 6079 t0 = text(t0_value); 6080 t1 = space(); 6081 div0 = element("div"); 6082 p = element("p"); 6083 t2 = text(t2_value); 6084 t3 = space(); 6085 div4 = element("div"); 6086 div3 = element("div"); 6087 div1 = element("div"); 6088 create_component(share2.$$.fragment); 6089 t4 = space(); 6090 h4 = element("h4"); 6091 t5 = text(t5_value); 6092 t6 = space(); 6093 div2 = element("div"); 6094 span = element("span"); 6095 span.textContent = `${/*getReferralUrl*/ 6096 ctx[4]()}`; 6097 t8 = space(); 6098 button0 = element("button"); 6099 if_block.c(); 6100 t9 = space(); 6101 create_component(button1.$$.fragment); 6102 t10 = space(); 6103 create_component(dashboardreferralcard0.$$.fragment); 6104 t11 = space(); 6105 create_component(dashboardreferralcard1.$$.fragment); 6106 attr(h3, "class", "leat-dashboard__header"); 6107 attr(div0, "class", "leat-dashboard__description"); 6108 attr(h4, "class", "svelte-1mdgdul"); 6109 attr(div1, "class", "leat-dashboard-referrals__url-header svelte-1mdgdul"); 6110 attr(span, "class", "leat-dashboard-referrals__url-value svelte-1mdgdul"); 6111 attr(button0, "class", "leat-dashboard-referrals__copy-button svelte-1mdgdul"); 6112 attr(button0, "aria-label", "Copy referral URL"); 6113 attr(div2, "class", "leat-dashboard-referrals__url-display svelte-1mdgdul"); 6114 attr(div3, "class", "leat-dashboard-referrals__url-card svelte-1mdgdul"); 6115 attr(div4, "class", "leat-dashboard-cards-grid leat-dashboard-referrals__cards svelte-1mdgdul"); 6116 attr(div6, "class", "leat-dashboard-section leat-dashboard-referrals"); 6117 }, 6118 m(target, anchor) { 6119 insert(target, div6, anchor); 6120 append(div6, div5); 6121 append(div5, h3); 6122 append(h3, t0); 6123 append(div5, t1); 6124 append(div5, div0); 6125 append(div0, p); 6126 append(p, t2); 6127 append(div5, t3); 6128 append(div5, div4); 6129 append(div4, div3); 6130 append(div3, div1); 6131 mount_component(share2, div1, null); 6132 append(div1, t4); 6133 append(div1, h4); 6134 append(h4, t5); 6135 append(div3, t6); 6136 append(div3, div2); 6137 append(div2, span); 6138 append(div2, t8); 6139 append(div2, button0); 6140 if_blocks[current_block_type_index].m(button0, null); 6141 append(div3, t9); 6142 mount_component(button1, div3, null); 6143 append(div4, t10); 6144 mount_component(dashboardreferralcard0, div4, null); 6145 append(div4, t11); 6146 mount_component(dashboardreferralcard1, div4, null); 6147 current = true; 6148 if (!mounted) { 6149 dispose = listen( 6150 button0, 6151 "click", 6152 /*click_handler*/ 6153 ctx[8] 6154 ); 6155 mounted = true; 6156 } 6157 }, 6158 p(ctx2, [dirty]) { 6159 var _a3, _b3, _c2, _d2, _e2; 6160 if ((!current || dirty & /*$pluginSettings*/ 6161 8) && t0_value !== (t0_value = getTranslatedText( 6162 /*$pluginSettings*/ 6163 (_a3 = ctx2[3]) == null ? void 0 : _a3.dashboard_nav_referrals 6164 ) + "")) 6165 set_data(t0, t0_value); 6166 if ((!current || dirty & /*$pluginSettings*/ 6167 8) && t2_value !== (t2_value = (getTranslatedText( 6168 /*$pluginSettings*/ 6169 (_b3 = ctx2[3]) == null ? void 0 : _b3.dashboard_referrals_description 6170 ) || "Share your referral link with friends and earn rewards when they sign up!") + "")) 6171 set_data(t2, t2_value); 6172 if ((!current || dirty & /*$pluginSettings*/ 6173 8) && t5_value !== (t5_value = (getTranslatedText( 6174 /*$pluginSettings*/ 6175 (_c2 = ctx2[3]) == null ? void 0 : _c2.dashboard_referrals_link_title 6176 ) || "Your Referral Link") + "")) 6177 set_data(t5, t5_value); 6178 let previous_block_index = current_block_type_index; 6179 current_block_type_index = select_block_type(ctx2); 6180 if (current_block_type_index !== previous_block_index) { 6181 group_outros(); 6182 transition_out(if_blocks[previous_block_index], 1, 1, () => { 6183 if_blocks[previous_block_index] = null; 6184 }); 6185 check_outros(); 6186 if_block = if_blocks[current_block_type_index]; 6187 if (!if_block) { 6188 if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2); 6189 if_block.c(); 6190 } 6191 transition_in(if_block, 1); 6192 if_block.m(button0, null); 6193 } 6194 const button1_changes = {};
6195 if (dirty & /*$$scope, $pluginSettings*/ 6196 1032) { 6197 button1_changes.$$scope = { dirty, ctx: ctx2 }; 6198 } 6199 button1.$set(button1_changes); 6200 const dashboardreferralcard0_changes = {}; 6201 if (dirty & /*$pluginSettings*/ 6202 8) 6203 dashboardreferralcard0_changes.title = getTranslatedText( 6204 /*$pluginSettings*/ 6205 (_d2 = ctx2[3]) == null ? void 0 : _d2.dashboard_referrals_referred_title 6206 ); 6207 if (dirty & /*referredContacts*/ 6208 2) 6209 dashboardreferralcard0_changes.value = /*referredContacts*/ 6210 ctx2[1]; 6211 dashboardreferralcard0.$set(dashboardreferralcard0_changes); 6212 const dashboardreferralcard1_changes = {}; 6213 if (dirty & /*$pluginSettings*/ 6214 8) 6215 dashboardreferralcard1_changes.title = getTranslatedText( 6216 /*$pluginSettings*/ 6217 (_e2 = ctx2[3]) == null ? void 0 : _e2.dashboard_referrals_completed_title 6218 ); 6219 if (dirty & /*completedReferrals*/ 6220 1) 6221 dashboardreferralcard1_changes.value = /*completedReferrals*/ 6222 ctx2[0]; 6223 dashboardreferralcard1.$set(dashboardreferralcard1_changes); 6224 }, 6225 i(local) { 6226 if (current) 6227 return; 6228 transition_in(share2.$$.fragment, local); 6229 transition_in(if_block); 6230 transition_in(button1.$$.fragment, local); 6231 transition_in(dashboardreferralcard0.$$.fragment, local); 6232 transition_in(dashboardreferralcard1.$$.fragment, local); 6233 current = true; 6234 }, 6235 o(local) { 6236 transition_out(share2.$$.fragment, local); 6237 transition_out(if_block); 6238 transition_out(button1.$$.fragment, local); 6239 transition_out(dashboardreferralcard0.$$.fragment, local); 6240 transition_out(dashboardreferralcard1.$$.fragment, local); 6241 current = false; 6242 }, 6243 d(detaching) { 6244 if (detaching) { 6245 detach(div6); 6246 } 6247 destroy_component(share2); 6248 if_blocks[current_block_type_index].d(); 6249 destroy_component(button1); 6250 destroy_component(dashboardreferralcard0); 6251 destroy_component(dashboardreferralcard1); 6252 mounted = false; 6253 dispose(); 6254 } 6255 }; 6256} 6257function instance$2($$self, $$props, $$invalidate) { 6258 let $pluginSettings; 6259 let $wcSettings; 6260 component_subscribe($$self, pluginSettings, ($$value) =>
6260 $$invalidate(3, $pluginSettings = $$value)); 6261 component_subscribe($$self, wcSettings, ($$value) => $$invalidate(9, $wcSettings = $$value)); 6262 let { referralCode } = $$props; 6263 let { completedReferrals = void 0 } = $$props; 6264 let { referredContacts = void 0 } = $$props; 6265 let copiedUrl = false; 6266 function getReferralUrl() { 6267 return `${$wcSettings.homeUrl}?ref=${referralCode}`; 6268 } 6269 async function copyToClipboard(text2) { 6270 try { 6271 await navigator.clipboard.writeText(text2); 6272 $$invalidate(2, copiedUrl = true); 6273 setTimeout(() => $$invalidate(2, copiedUrl = false), 2e3); 6274 } catch (err) { 6275 console.error("Failed to copy:", err); 6276 } 6277 } 6278 function shareReferralUrl() { 6279 const url = getReferralUrl(); 6280 const text2 = getTranslatedText($pluginSettings == null ? void 0 : $pluginSettings.dashboard_referrals_share_text) || "Join me and start earning rewards!"; 6281 if (navigator.share) { 6282 navigator.share({ 6283 title: getTranslatedText($pluginSettings == null ? void 0 : $pluginSettings.dashboard_referrals_share_title) || "Referral Link", 6284 text: text2, 6285 url 6286 }).catch((error) => { 6287 if (error.name !== "AbortError") { 6288 copyToClipboard(url); 6289 } 6290 }); 6291 } else { 6292 copyToClipboard(url); 6293 } 6294 } 6295 const click_handler = () => copyToClipboard(getReferralUrl()); 6296 $$self.$$set = ($$props2) => { 6297 if ("referralCode" in $$props2) 6298 $$invalidate(7, referralCode = $$props2.referralCode); 6299 if ("completedReferrals" in $$props2) 6300 $$invalidate(0, completedReferrals = $$props2.completedReferrals); 6301 if ("referredContacts" in $$props2) 6302 $$invalidate(1, referredContacts = $$props2.referredContacts); 6303 }; 6304 return [ 6305 completedReferrals, 6306 referredContacts, 6307 copiedUrl, 6308 $pluginSettings, 6309 getReferralUrl, 6310 copyToClipboard, 6311 shareReferralUrl, 6312 referralCode, 6313 click_handler 6314 ]; 6315} 6316class Dashboard_referrals extends SvelteComponent { 6317 constructor(options) { 6318 super(); 6319 init(this, options, instance$2, create_fragment$2, safe_not_equal, { 6320 referralCode: 7, 6321 completedReferrals: 0, 6322 referredContacts: 1 6323 }); 6324 } 6325} 6326function create_if_block_1$1(ctx) { 6327 var _a2, _b2, _c, _d, _e, _f; 6328 let dashboardreferrals; 6329 let current; 6330 dashboardreferrals = new Dashboard_referrals({ 6331 props: { 6332 referralCode: ( 6333 /*$queries*/ 6334 (_b2 = (_a2 = ctx[1][0].data) == null ? void 0 : _a2.contact) == null ? void 0 : _b2.attributes.referral_code 6335 ), 6336 completedReferrals: ( 6337 /*$queries*/ 6338 (_d = (_c = ctx[1][0].data) == null ? void 0 : _c.contact) == null ? void 0 : _d.attributes.number_of_completed_referrals 6339 ), 6340 referredContacts: ( 6341 /*$queries*/ 6342 (_f = (_e = ctx[1][0].data) == null ? void 0 : _e.contact) == null ? void 0 : _f.attributes.number_of_referred_contacts 6343 ) 6344 } 6345 }); 6346 return { 6347 c() { 6348 create_component(dashboardreferrals.$$.fragment); 6349 }, 6350 m(target, anchor) { 6351 mount_component(dashboardreferrals, target, anchor); 6352 current = true; 6353 }, 6354 p(ctx2, dirty) { 6355 var _a3, _b3, _c2, _d2, _e2, _f2; 6356 const dashboardreferrals_changes = {}; 6357 if (dirty & /*$queries*/ 6358 2) 6359 dashboardreferrals_changes.referralCode = /*$queries*/ 6360 (_b3 = (_a3 = ctx2[1][0].data) == null ? void 0 : _a3.contact) == null ? void 0 : _b3.attributes.referral_code; 6361 if (dirty & /*$queries*/ 6362 2) 6363 dashboardreferrals_changes.completedReferrals = /*$queries*/ 6364 (_d2 = (_c2 = ctx2[1][0].data) == null ? void 0 : _c2.contact) == null ? void 0 : _d2.attributes.number_of_completed_referrals; 6365 if (dirty & /*$queries*/ 6366 2) 6367 dashboardreferrals_changes.referredContacts = /*$queries*/ 6368 (_f2 = (_e2 = ctx2[1][0].data) == null ? void 0 : _e2.contact) == null ? void 0 : _f2.attributes.number_of_referred_contacts; 6369 dashboardreferrals.$set(dashboardreferrals_changes); 6370 }, 6371 i(local) { 6372 if (current) 6373 return; 6374 transition_in(dashboardreferrals.$$.fragment, local); 6375 current = true; 6376 }, 6377 o(local) { 6378 transition_out(dashboardreferrals.$$.fragment, local); 6379 current = false;
6380 }, 6381 d(detaching) { 6382 destroy_component(dashboardreferrals, detaching); 6383 } 6384 }; 6385} 6386function create_if_block(ctx) { 6387 var _a2, _b2; 6388 let dashboardtiers; 6389 let current; 6390 dashboardtiers = new Dashboard_tiers({ 6391 props: { 6392 tiers: ( 6393 /*$queries*/ 6394 (_a2 = ctx[1][4].data) == null ? void 0 : _a2.tiers 6395 ), 6396 currentTier: ( 6397 /*$queries*/ 6398 (_b2 = ctx[1][0].data) == null ? void 0 : _b2.tier 6399 ) 6400 } 6401 }); 6402 return { 6403 c() { 6404 create_component(dashboardtiers.$$.fragment); 6405 }, 6406 m(target, anchor) { 6407 mount_component(dashboardtiers, target, anchor); 6408 current = true; 6409 }, 6410 p(ctx2, dirty) { 6411 var _a3, _b3; 6412 const dashboardtiers_changes = {}; 6413 if (dirty & /*$queries*/ 6414 2) 6415 dashboardtiers_changes.tiers = /*$queries*/ 6416 (_a3 = ctx2[1][4].data) == null ? void 0 : _a3.tiers; 6417 if (dirty & /*$queries*/ 6418 2) 6419 dashboardtiers_changes.currentTier = /*$queries*/ 6420 (_b3 = ctx2[1][0].data) == null ? void 0 : _b3.tier; 6421 dashboardtiers.$set(dashboardtiers_changes); 6422 }, 6423 i(local) { 6424 if (current) 6425 return; 6426 transition_in(dashboardtiers.$$.fragment, local); 6427 current = true; 6428 }, 6429 o(local) { 6430 transition_out(dashboardtiers.$$.fragment, local); 6431 current = false; 6432 }, 6433 d(detaching) { 6434 destroy_component(dashboardtiers, detaching); 6435 } 6436 }; 6437} 6438function create_fragment$1(ctx) { 6439 var _a2, _b2, _c, _d, _e, _f; 6440 let dashboardheaderpts; 6441 let t0; 6442 let dashboardcoupons; 6443 let t1; 6444 let dashboardearn; 6445 let t2; 6446 let dashboardrewards; 6447 let t3; 6448 let t4; 6449 let if_block1_anchor; 6450 let current; 6451 dashboardheaderpts = new Dashboard_header_pts({ 6452 props: { 6453 navItems: ( 6454 /*navItems*/ 6455 ctx[4] 6456 ), 6457 signupCredits: ( 6458 /*signupCredits*/ 6459 ctx[3] 6460 ) 6461 } 6462 }); 6463 dashboardcoupons = new Dashboard_coupons({ 6464 props: { 6465 coupons: ( 6466 /*$queries*/ 6467 ctx[1][1].data 6468 ), 6469 isLoading: ( 6470 /*$queries*/ 6471 ctx[1][1].isLoading 6472 ), 6473 isSuccess: ( 6474 /*$queries*/ 6475 ctx[1][1].isSuccess 6476 ) 6477 } 6478 }); 6479 dashboardearn = new Dashboard_earn({ 6480 props: { 6481 earnRules: ( 6482 /*$queries*/ 6483 ctx[1][2].data ?? [] 6484 ) 6485 } 6486 }); 6487 dashboardrewards = new Dashboard_rewards({ 6488 props: { 6489 spendRules: ( 6490 /*filteredSpendRules*/ 6491 ctx[0] 6492 ) 6493 } 6494 }); 6495 let if_block0 = ( 6496 /*$queries*/ 6497 ((_b2 = (_a2 = ctx[1][0].data) == null ? void 0 : _a2.contact) == null ? void 0 : _b2.attributes.referral_code) && /*$pluginSettings*/ 6498 ((_c = ctx[2]) == null ? void 0 : _c.dashboard_show_referrals) === "on" && create_if_block_1$1(ctx) 6499 ); 6500 let if_block1 = ( 6501 /*$queries*/ 6502 ((_d = ctx[1][4].data) == null ? void 0 : _d.tiers) && /*$queries*/ 6503 ((_e = ctx[1][4].data) == null ? void 0 : _e.tiers.length) > 0 && /*$pluginSettings*/ 6504 ((_f = ctx[2]) == null ? void 0 : _f.dashboard_show_tiers) === "on" && create_if_block(ctx) 6505 ); 6506 return { 6507 c() { 6508 create_component(dashboardheaderpts.$$.fragment); 6509 t0 = space(); 6510 create_component(dashboardcoupons.$$.fragment); 6511 t1 = space(); 6512 create_component(dashboardearn.$$.fragment); 6513 t2 = space(); 6514 create_component(dashboardrewards.$$.fragment); 6515 t3 = space(); 6516 if (if_block0) 6517 if_block0.c(); 6518 t4 = space(); 6519 if (if_block1) 6520 if_block1.c(); 6521 if_block1_anchor = empty(); 6522 }, 6523 m(target, anchor) { 6524 mount_component(dashboardheaderpts, target, anchor); 6525 insert(target, t0, anchor); 6526 mount_component(dashboardcoupons, target, anchor); 6527 insert(target, t1, anchor); 6528 mount_component(dashboardearn, target, anchor); 6529 insert(target, t2, anchor); 6530 mount_component(dashboardrewards, target, anchor); 6531 insert(target, t3, anchor); 6532 if (if_block0) 6533 if_block0.m(target, anchor); 6534 insert(target, t4, anchor); 6535 if (if_block1) 6536 if_block1.m(target, anchor); 6537 insert(target, if_block1_anchor, anchor); 6538 current = true; 6539 }, 6540 p(ctx2, [dirty]) { 6541 var _a3, _b3, _c2, _d2, _e2, _f2; 6542 const dashboardheaderpts_changes = {};
6543 if (dirty & /*navItems*/ 6544 16) 6545 dashboardheaderpts_changes.navItems = /*navItems*/ 6546 ctx2[4]; 6547 if (dirty & /*signupCredits*/ 6548 8) 6549 dashboardheaderpts_changes.signupCredits = /*signupCredits*/ 6550 ctx2[3]; 6551 dashboardheaderpts.$set(dashboardheaderpts_changes); 6552 const dashboardcoupons_changes = {}; 6553 if (dirty & /*$queries*/ 6554 2) 6555 dashboardcoupons_changes.coupons = /*$queries*/ 6556 ctx2[1][1].data; 6557 if (dirty & /*$queries*/ 6558 2) 6559 dashboardcoupons_changes.isLoading = /*$queries*/ 6560 ctx2[1][1].isLoading; 6561 if (dirty & /*$queries*/ 6562 2) 6563 dashboardcoupons_changes.isSuccess = /*$queries*/ 6564 ctx2[1][1].isSuccess; 6565 dashboardcoupons.$set(dashboardcoupons_changes); 6566 const dashboardearn_changes = {}; 6567 if (dirty & /*$queries*/ 6568 2) 6569 dashboardearn_changes.earnRules = /*$queries*/ 6570 ctx2[1][2].data ?? []; 6571 dashboardearn.$set(dashboardearn_changes); 6572 const dashboardrewards_changes = {}; 6573 if (dirty & /*filteredSpendRules*/ 6574 1) 6575 dashboardrewards_changes.spendRules = /*filteredSpendRules*/ 6576 ctx2[0]; 6577 dashboardrewards.$set(dashboardrewards_changes); 6578 if ( 6579 /*$queries*/ 6580 ((_b3 = (_a3 = ctx2[1][0].data) == null ? void 0 : _a3.contact) == null ? void 0 : _b3.attributes.referral_code) && /*$pluginSettings*/ 6581 ((_c2 = ctx2[2]) == null ? void 0 : _c2.dashboard_show_referrals) === "on" 6582 ) { 6583 if (if_block0) { 6584 if_block0.p(ctx2, dirty); 6585 if (dirty & /*$queries, $pluginSettings*/ 6586 6) { 6587 transition_in(if_block0, 1); 6588 } 6589 } else { 6590 if_block0 = create_if_block_1$1(ctx2); 6591 if_block0.c(); 6592 transition_in(if_block0, 1); 6593 if_block0.m(t4.parentNode, t4); 6594 } 6595 } else if (if_block0) { 6596 group_outros(); 6597 transition_out(if_block0, 1, 1, () => { 6598 if_block0 = null; 6599 }); 6600 check_outros(); 6601 } 6602 if ( 6603 /*$queries*/ 6604 ((_d2 = ctx2[1][4].data) == null ? void 0 : _d2.tiers) && /*$queries*/ 6605 ((_e2 = ctx2[1][4].data) == null ? void 0 : _e2.tiers.length) > 0 && /*$pluginSettings*/ 6606 ((_f2 = ctx2[2]) == null ? void 0 : _f2.dashboard_show_tiers) === "on" 6607 ) { 6608 if (if_block1) { 6609 if_block1.p(ctx2, dirty); 6610 if (dirty & /*$queries, $pluginSettings*/ 6611 6) { 6612 transition_in(if_block1, 1); 6613 } 6614 } else { 6615 if_block1 = create_if_block(ctx2); 6616 if_block1.c(); 6617 transition_in(if_block1, 1); 6618 if_block1.m(if_block1_anchor.parentNode, if_block1_anchor); 6619 } 6620 } else if (if_block1) { 6621 group_outros(); 6622 transition_out(if_block1, 1, 1, () => { 6623 if_block1 = null; 6624 }); 6625 check_outros(); 6626 } 6627 }, 6628 i(local) { 6629 if (current) 6630 return; 6631 transition_in(dashboardheaderpts.$$.fragment, local); 6632 transition_in(dashboardcoupons.$$.fragment, local); 6633 transition_in(dashboardearn.$$.fragment, local); 6634 transition_in(dashboardrewards.$$.fragment, local); 6635 transition_in(if_block0); 6636 transition_in(if_block1); 6637 current = true; 6638 }, 6639 o(local) { 6640 transition_out(dashboardheaderpts.$$.fragment, local); 6641 transition_out(dashboardcoupons.$$.fragment, local); 6642 transition_out(dashboardearn.$$.fragment, local); 6643 transition_out(dashboardrewards.$$.fragment, local); 6644 transition_out(if_block0); 6645 transition_out(if_block1); 6646 current = false; 6647 }, 6648 d(detaching) { 6649 if (detaching) { 6650 detach(t0); 6651 detach(t1); 6652 detach(t2); 6653 detach(t3); 6654 detach(t4); 6655 detach(if_block1_anchor); 6656 } 6657 destroy_component(dashboardheaderpts, detaching); 6658 destroy_component(dashboardcoupons, detaching); 6659 destroy_component(dashboardearn, detaching); 6660 destroy_component(dashboardrewards, detaching); 6661 if (if_block0) 6662 if_block0.d(detaching); 6663 if (if_block1) 6664 if_block1.d(detaching); 6665 } 6666 }; 6667}
6668function instance$1($$self, $$props, $$invalidate) { 6669 let filteredSpendRules; 6670 let navItems; 6671 let signupCredits; 6672 let $queries; 6673 let $pluginSettings; 6674 component_subscribe($$self, pluginSettings, ($$value) => $$invalidate(2, $pluginSettings = $$value)); 6675 const queries = createQueries({ 6676 queries: [ 6677 { 6678 queryKey: [QueryKeys.contact], 6679 queryFn: async () => await getContact(window.leatMiddlewareConfig.userId), 6680 enabled: isLoggedIn && window.leatMiddlewareConfig.userId !== null 6681 }, 6682 { 6683 queryKey: [QueryKeys.coupons], 6684 queryFn: async () => await getCoupons(window.leatMiddlewareConfig.userId), 6685 enabled: isLoggedIn 6686 }, 6687 { 6688 queryKey: [QueryKeys.earnRules], 6689 queryFn: async () => await getEarnRules() 6690 }, 6691 { 6692 queryKey: [QueryKeys.spendRules], 6693 queryFn: async () => await getSpendRules(window.leatMiddlewareConfig.userId), 6694 enabled: isLoggedIn 6695 }, 6696 { 6697 queryKey: [QueryKeys.tiers], 6698 queryFn: async () => await getTiers(), 6699 enabled: isLoggedIn 6700 } 6701 ] 6702 }); 6703 component_subscribe($$self, queries, (value) =>
6703 $$invalidate(1, $queries = value)); 6704 $$self.$$.update = () => { 6705 var _a2, _b2, _c, _d, _e, _f, _g, _h, _i; 6706 if ($$self.$$.dirty & /*$queries*/ 6707 2) { 6708 contactStore.set($queries[0].data ?? null); 6709 } 6710 if ($$self.$$.dirty & /*$queries*/ 6711 2) { 6712 $$invalidate(0, filteredSpendRules = ((_a2 = $queries[3].data) == null ? void 0 : _a2.filter((rule) => rule.status.value === "publish" && rule.label.value)) ?? []); 6713 } 6714 if ($$self.$$.dirty & /*$pluginSettings, filteredSpendRules, $queries*/ 6715 7) { 6716 $$invalidate(4, navItems = [ 6717 { 6718 icon: Tag, 6719 id: "coupons", 6720 text: getTranslatedText($pluginSettings == null ? void 0 : $pluginSettings.dashboard_nav_coupons), 6721 show: true 6722 }, 6723 { 6724 icon: BadgeEuro, 6725 id: "earn", 6726 text: getTranslatedText($pluginSettings == null ? void 0 : $pluginSettings.dashboard_nav_earn), 6727 show: true 6728 }, 6729 { 6730 icon: ShoppingBag, 6731 id: "rewards", 6732 text: getTranslatedText($pluginSettings == null ? void 0 : $pluginSettings.dashboard_nav_rewards), 6733 show: !!filteredSpendRules.length 6734 }, 6735 { 6736 icon: Share2, 6737 id: "referrals", 6738 text: getTranslatedText($pluginSettings == null ? void 0 : $pluginSettings.dashboard_nav_referrals), 6739 show: !!(isLoggedIn && ((_b2 = $queries[0].data) == null ? void 0 : _b2.contact) && ((_d = (_c = $queries[0].data) == null ? void 0 : _c.contact) == null ? void 0 : _d.attributes.referral_code) && ($pluginSettings == null ? void 0 : $pluginSettings.dashboard_show_referrals) === "on") 6740 }, 6741 { 6742 icon: Layers, 6743 id: "tiers", 6744 text: getTranslatedText($pluginSettings == null ? void 0 : $pluginSettings.dashboard_nav_tiers), 6745 show: !!(((_e = $queries[4].data) == null ? void 0 : _e.tiers) && ((_f = $queries[4].data) == null ? void 0 : _f.tiers.length) > 0 && ($pluginSettings == null ? void 0 : $pluginSettings.dashboard_show_tiers) === "on") 6746 } 6747 ]); 6748 } 6749 if ($$self.$$.dirty & /*$queries*/ 6750 2) { 6751 $$invalidate(3, signupCredits = ((_i = (_h = (_g = $queries[2].data) == null ? void 0 : _g.find((rule) => rule.type.value === "CREATE_ACCOUNT")) == null ? void 0 : _h.credits) == null ? void 0 : _i.value) ?? null); 6752 } 6753 }; 6754 return [ 6755 filteredSpendRules, 6756 $queries, 6757 $pluginSettings, 6758 signupCredits, 6759 navItems, 6760 queries 6761 ]; 6762} 6763class Dashboard extends SvelteComponent { 6764 constructor(options) { 6765 super(); 6766 init(this, options, instance$1, create_fragment$1, safe_not_equal, {}); 6767 } 6768} 6769const isDev = false; 6770class WooCommerceStoreApiError extends Error { 6771 constructor(status, statusText, data) { 6772 super(`WooCommerceStoreApiError: ${statusText}`); 6773 __publicField(this, "status"); 6774 __publicField(this, "statusText"); 6775 __publicField(this, "data"); 6776 __publicField(this, "message"); 6777 this.status = status; 6778 this.statusText = statusText; 6779 this.data = data; 6780 this.message = data; 6781 } 6782} 6783const NAMESPACE = "leat"; 6784const hooks = { 6785 doAction: (hookname, ...args) => { 6786 window.wp.hooks.doAction(hookname, ...args); 6787 }, 6788 addAction: (hookname, callback, priority) => { 6789 window.wp.hooks.addAction(hookname, NAMESPACE, callback, priority); 6790 }, 6791 doingAction: (hookname) => { 6792 return window.wp.hooks.doingAction(hookname); 6793 } 6794}; 6795const global = ""; 6796const customerDashboard_svelte_svelte_type_style_lang = ""; 6797function create_if_block_1(ctx) { 6798 let if_block_anchor; 6799 let current; 6800 let if_block = ( 6801 /*$settingsState*/ 6802 ctx[0].plugin_enable && create_if_block_2() 6803 ); 6804 return { 6805 c() { 6806 if (if_block) 6807 if_block.c(); 6808 if_block_anchor = empty(); 6809 }, 6810 m(target, anchor) { 6811 if (if_block) 6812 if_block.m(target, anchor); 6813 insert(target, if_block_anchor, anchor); 6814 current = true; 6815 }, 6816 p(ctx2, dirty) { 6817 if ( 6818 /*$settingsState*/ 6819 ctx2[0].plugin_enable 6820 ) { 6821 if (if_block) { 6822 if (dirty & /*$settingsState*/ 6823 1) { 6824 transition_in(if_block, 1); 6825 } 6826 } else { 6827 if_block = create_if_block_2(); 6828 if_block.c(); 6829 transition_in(if_block, 1); 6830 if_block.m(if_block_anchor.parentNode, if_block_anchor); 6831 } 6832 } else if (if_block) { 6833 group_outros(); 6834 transition_out(if_block, 1, 1, () => { 6835 if_block = null; 6836 }); 6837 check_outros(); 6838 } 6839 }, 6840 i(local) { 6841 if (current) 6842 return; 6843 transition_in(if_block); 6844 current = true; 6845 }, 6846 o(local) { 6847 transition_out(if_block); 6848 current = false;
6849 }, 6850 d(detaching) { 6851 if (detaching) { 6852 detach(if_block_anchor); 6853 } 6854 if (if_block) 6855 if_block.d(detaching); 6856 } 6857 }; 6858} 6859function create_if_block_2(ctx) { 6860 let div; 6861 let dashboard; 6862 let current; 6863 dashboard = new Dashboard({}); 6864 return { 6865 c() { 6866 div = element("div"); 6867 create_component(dashboard.$$.fragment); 6868 attr(div, "class", "leat-dashboard svelte-1d6n3f"); 6869 }, 6870 m(target, anchor) { 6871 insert(target, div, anchor); 6872 mount_component(dashboard, div, null); 6873 current = true; 6874 }, 6875 i(local) { 6876 if (current) 6877 return; 6878 transition_in(dashboard.$$.fragment, local); 6879 current = true; 6880 }, 6881 o(local) { 6882 transition_out(dashboard.$$.fragment, local); 6883 current = false; 6884 }, 6885 d(detaching) { 6886 if (detaching) { 6887 detach(div); 6888 } 6889 destroy_component(dashboard); 6890 } 6891 }; 6892} 6893function create_default_slot(ctx) { 6894 let t; 6895 let if_block1_anchor; 6896 let current; 6897 let if_block0 = ( 6898 /*$settingsState*/ 6899 ctx[0] && create_if_block_1(ctx) 6900 ); 6901 let if_block1 = isDev; 6902 return { 6903 c() { 6904 if (if_block0) 6905 if_block0.c(); 6906 t = space(); 6907 if_block1_anchor = empty(); 6908 }, 6909 m(target, anchor) { 6910 if (if_block0) 6911 if_block0.m(target, anchor); 6912 insert(target, t, anchor); 6913 insert(target, if_block1_anchor, anchor); 6914 current = true; 6915 }, 6916 p(ctx2, dirty) { 6917 if ( 6918 /*$settingsState*/ 6919 ctx2[0] 6920 ) { 6921 if (if_block0) { 6922 if_block0.p(ctx2, dirty); 6923 if (dirty & /*$settingsState*/ 6924 1) { 6925 transition_in(if_block0, 1); 6926 } 6927 } else { 6928 if_block0 = create_if_block_1(ctx2); 6929 if_block0.c(); 6930 transition_in(if_block0, 1); 6931 if_block0.m(t.parentNode, t); 6932 } 6933 } else if (if_block0) { 6934 group_outros(); 6935 transition_out(if_block0, 1, 1, () => { 6936 if_block0 = null; 6937 }); 6938 check_outros(); 6939 } 6940 }, 6941 i(local) { 6942 if (current) 6943 return; 6944 transition_in(if_block0); 6945 transition_in(if_block1); 6946 current = true; 6947 }, 6948 o(local) { 6949 transition_out(if_block0); 6950 transition_out(if_block1); 6951 current = false; 6952 }, 6953 d(detaching) { 6954 if (detaching) { 6955 detach(t); 6956 detach(if_block1_anchor); 6957 } 6958 if (if_block0) 6959 if_block0.d(detaching); 6960 } 6961 }; 6962} 6963function create_fragment(ctx) { 6964 let queryclientprovider; 6965 let current; 6966 queryclientprovider = new QueryClientProvider({ 6967 props: { 6968 client: ( 6969 /*queryClient*/ 6970 ctx[1] 6971 ), 6972 $$slots: { default: [create_default_slot] }, 6973 $$scope: { ctx } 6974 } 6975 }); 6976 return { 6977 c() { 6978 create_component(queryclientprovider.$$.fragment); 6979 }, 6980 m(target, anchor) { 6981 mount_component(queryclientprovider, target, anchor); 6982 current = true; 6983 }, 6984 p(ctx2, [dirty]) { 6985 const queryclientprovider_changes = {}; 6986 if (dirty & /*$$scope, $settingsState*/ 6987 33) { 6988 queryclientprovider_changes.$$scope = { dirty, ctx: ctx2 }; 6989 } 6990 queryclientprovider.$set(queryclientprovider_changes); 6991 }, 6992 i(local) { 6993 if (current) 6994 return; 6995 transition_in(queryclientprovider.$$.fragment, local); 6996 current = true; 6997 }, 6998 o(local) { 6999 transition_out(queryclientprovider.$$.fragment, local); 7000 current = false; 7001 }, 7002 d(detaching) { 7003 destroy_component(queryclientprovider, detaching); 7004 } 7005 }; 7006} 7007function instance($$self, $$props, $$invalidate) { 7008 let $settingsState; 7009 component_subscribe($$self, pluginSettings, ($$value) =>
7009 $$invalidate(0, $settingsState = $$value)); 7010 let { wcSettings: wcSettings$1 } = $$props; 7011 let { pluginSettings: pluginSettings$1 } = $$props; 7012 wcSettings.set(wcSettings$1); 7013 pluginSettings.set(pluginSettings$1); 7014 const mutationCache = new MutationCache({ 7015 onError: (error) => { 7016 if (error instanceof WooCommerceStoreApiError) { 7017 const { message, status, statusText } = error; 7018 console.error(message, status, statusText); 7019 } 7020 } 7021 }); 7022 onMount(async () => { 7023 hooks.doAction("on.init", $settingsState); 7024 }); 7025 const queryClient = new QueryClient({ 7026 mutationCache, 7027 defaultOptions: { queries: { staleTime: 2 * 60 * 1e3 } } 7028 }); 7029 $$self.$$set = ($$props2) => { 7030 if ("wcSettings" in $$props2) 7031 $$invalidate(2, wcSettings$1 = $$props2.wcSettings); 7032 if ("pluginSettings" in $$props2) 7033 $$invalidate(3, pluginSettings$1 = $$props2.pluginSettings); 7034 }; 7035 return [$settingsState, queryClient, wcSettings$1, pluginSettings$1]; 7036} 7037class Customer_dashboard extends SvelteComponent { 7038 constructor(options) { 7039 super(); 7040 init(this, options, instance, create_fragment, safe_not_equal, { wcSettings: 2, pluginSettings: 3 }); 7041 } 7042} 7043const leatConfig = window.leatConfig; 7044const leatWcSettingsConfig = window.leatWcSettings; 7045const leatMiddlewareConfig = window.leatMiddlewareConfig; 7046const frontendMounts = document.getElementsByClassName("leat-customer-dashboard"); 7047function mountFrontend() { 7048 if (!leatConfig) { 7049 console.warn("[leat] window.leatConfig is not defined. This is needed to run the app."); 7050 return; 7051 } 7052 if (!leatWcSettingsConfig) { 7053 console.warn( 7054 "[leat] window.leatWcSettingsConfig is not defined. This is needed to run the app." 7055 ); 7056 return; 7057 } 7058 if (!leatMiddlewareConfig) { 7059 console.warn( 7060 "[leat] window.leatMiddlewareConfig is not defined. This is needed to run the app." 7061 ); 7062 return; 7063 } 7064 if (frontendMounts.length > 0) { 7065 Array.from(frontendMounts).forEach((frontendMount) => { 7066 new Customer_dashboard({ 7067 target: frontendMount, 7068 props: { 7069 pluginSettings: leatConfig, 7070 wcSettings: leatWcSettingsConfig 7071 } 7072 }); 7073 }); 7074 } 7075} 7076mountFrontend();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.