1import{B as t}from"./bluetti.bluettiModal.AaGe6k0D.min.js";import{P as e}from"./bluetti.productExchange.DGX_rp40.min.js";import{U as n,g as i}from"./bluetti.Customer.Ckm4_sV5.min.js";import{p as s}from"./bluetti.theme.DMb47qTq.min.js";import{x as o,c as a,t as r,v as l}from"./bluetti.utils.BeiRElZ6.min.js";import"./bluetti.vendor.OdbWYEnF.min.js";import"./bluetti.modulepreload-polyfill.YP0FEG5d.min.js";import"./bluetti.baseApi.D5nYpQJ4.min.js";import"./bluetti.constants.Cyvr9pHy.min.js";import"./bluetti.preload-helper.DTdAas1V.min.js";import"./bluetti.modal.BkmKJNm2.min.js";import"./bluetti.mallApi.DsZj8Mwg.min.js";import"./bluetti.member-price-sdk.DEQAWf2_.min.js";const{moneyFormat:c}=window.Shopify.format,{productI18n:d,confirm_exchange_modal:u,api_error_text:h}=window.Shopify.productExchangeI18n,p='<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="24" height="24" viewBox="0 0 24 24" class="transition-colors"><g><g></g><g><g><path d="M2.1785370390625,7.523886056640625L2.8785400390625,7.523883056640625L21.1214400390625,7.523883056640625L21.8214400390625,7.523886056640625L21.8214400390625,6.123880056640625L21.1214400390625,6.123883056640625L2.8785400390625,6.123883056640625L2.1785370390625,6.123880056640625L2.1785370390625,7.523886056640625Z" fill-rule="evenodd"/><path d="M6.7390839140625,3.578573556640625L7.4390869140625,3.578570556640625L16.5605469140625,3.578570556640625L17.260546914062502,3.578573556640625L17.260546914062502,2.178567556640625L16.5605469140625,2.178570556640625L7.4390869140625,2.178570556640625L6.7390839140625,2.178567556640625L6.7390839140625,3.578573556640625Z" fill-rule="evenodd"/><path d="M4.6511932890625,6.123880056640625L4.6511962890625,6.823883056640625L4.6511962890625,14.241933056640626L4.6511962890625,19.686183056640623Q4.6511962890625,20.805083056640626,5.4362932890625,21.584183056640626Q6.2180922890625,22.359983056640623,7.3359562890625,22.359983056640623L11.999066289062501,22.359983056640623L16.6621962890625,22.359983056640623Q17.7800962890625,22.359983056640623,18.5618962890625,21.584183056640626Q19.3468962890625,20.805083056640626,19.3468962890625,19.686183056640623L19.3468962890625,6.823883056640625L19.3469962890625,6.123880056640625L17.9468962890625,6.123880056640625L17.9468962890625,6.823883056640625L17.9468962890625,19.686183056640623Q17.9468962890625,20.221983056640624,17.5756962890625,20.590383056640626Q17.2032962890625,20.959983056640624,16.6621962890625,20.959983056640624L11.999066289062501,20.959983056640624L7.3359562890625,20.959983056640624Q6.7948362890625,20.959983056640624,6.4224362890624995,20.590383056640626Q6.0511962890625,20.221983056640624,6.0511962890625,19.686183056640623L6.0511962890625,14.241933056640626L6.0511962890625,6.823883056640625L6.0511992890625,6.123880056640625L4.6511932890625,6.123880056640625Z" fill-rule="evenodd"/><path d="M9.1574432890625,11.038333181640626L9.1574462890625,11.638336181640625L9.1574462890625,16.127016181640624L9.1574432890625,16.727016181640625L10.3574492890625,16.727016181640625L10.3574462890625,16.127016181640624L10.3574462890625,11.638336181640625L10.3574492890625,11.038333181640626L9.1574432890625,11.038333181640626ZM13.6408762890625,11.038333181640626L13.6408862890625,11.638336181640625L13.6408862890625,16.127016181640624L13.6408762890625,16.727016181640625L14.8408862890625,16.727016181640625L14.8408862890625,16.127016181640624L14.8408862890625,11.638336181640625L14.8408862890625,11.038333181640626L13.6408762890625,11.038333181640626Z" fill-rule="evenodd"/></g></g></g></svg>',g='<svg class="animate-spin" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="24" height="24" viewBox="0 0 24 24"><defs><clipPath id="master_svg0_1702_221386"><rect x="0" y="0" width="24" height="24" rx="0"/></clipPath></defs><g clip-path="url(#master_svg0_1702_221386)"><g><g><path d="M11,1.998291015625L11,2.998291015625L11,5.248721015625L11,6.248721015625L13,6.248721015625L13,5.248721015625L13,2.998291015625L13,1.998291015625L11,1.998291015625Z" fill-rule="evenodd" fill="#A5A5A8" fill-opacity="1"/></g><g><path d="M18.3647075,4.220789765625L17.6576055,4.927903765625L16.0663305,6.519179765625L15.3592175,7.226289765625L16.7734375,8.640509765625L17.4805445,7.933389765625L19.0718175,6.342115765625L19.7789375,5.635009765625L18.3647075,4.220789765625Z" fill-rule="evenodd" fill="#A5A5A8" fill-opacity="1"/></g><g style="opacity:0.800000011920929;">
1<path d="M17.75,13.000244140625L18.75,13.000244140625L21.00043,13.000244140625L22.00043,13.000244140625L22.00043,11.000244140625L21.00043,11.000244140625L18.75,11.000244140625L17.75,11.000244140625L17.75,13.000244140625Z" fill-rule="evenodd" fill="#A5A5A8" fill-opacity="1"/></g><g style="opacity:0.6000000238418579;"><path d="M15.3592175,16.773681640625L16.0663305,17.480788640625L17.6576065,19.072061640625L18.3647175,19.779181640625L19.7789375,18.364961640625L19.0718175,17.657850640625L17.4805445,16.066574640625L16.7734375,15.359461640625L15.3592175,16.773681640625Z" fill-rule="evenodd" fill="#A5A5A8" fill-opacity="1"/></g><g style="opacity:0.5;"><path d="M11,17.751220703125L11,18.751220703125L11,21.001650703125L11,22.001650703125L13,22.001650703125L13,21.001650703125L13,18.751220703125L13,17.751220703125L11,17.751220703125Z" fill-rule="evenodd" fill="#A5A5A8" fill-opacity="1"/></g><g style="opacity:0.4000000059604645;"><path d="M7.226045625,15.359461640625L6.518935625,16.066574640625L4.927659625,17.657849640625L4.220545625,18.364951640625L5.634765625,19.779181640625L6.341872625,19.072061640625L7.933145625,17.480788640625L8.640265625,16.773681640625L7.226045625,15.359461640625Z" fill-rule="evenodd" fill="#A5A5A8" fill-opacity="1"/></g><g style="opacity:0.30000001192092896;"><path d="M1.998046875,13.000244140625L2.998046875,13.000244140625L5.248476875,13.000244140625L6.248476875,13.000244140625L6.248476875,11.000244140625L5.248476875,11.000244140625L2.998046875,11.000244140625L1.998046875,13.000244140625L1.998046875,13.000244140625Z" fill-rule="evenodd" fill="#A5A5A8" fill-opacity="1"/></g><g style="opacity:0.20000000298023224;"><path d="M4.220545625,5.635009765625L4.927658625,6.342116765625L6.518935625,7.933389765625L7.226045625,8.640509765625L8.640265625,7.226289765625L7.933145625,6.519179765625L6.341872625,4.927902765625L5.634765625,4.220789765625L4.220545625,5.635009765625Z" fill-rule="evenodd" fill="#A5A5A8" fill-opacity="1"/></g></g></g></svg>',m="text-blue-500 no-underline hover:text-blue-600 hover:underline active:text-blue-600 active:underline",v={1012:h.product_is_out_of_stock,4004:h.event_has_not_started,4003:h.event_has_ended,4013:h.event_is_draft,4016:h.event_is_goldenvip,4015:h.product_is_out_of_stock,1008:h.invalid_user,4017:h.points_not_enough_min,4018:h.points_not_enough_max,4001:h.points_not_enough,4019:h.order_has_paid,4020:h.draft_order_canceled,4021:h.order_has_canceled,4022:h.product_is_sold_out,4023:h.points_are_not_fixed_multiples},b=t=>v[t]||h.network_busy,f="undefined"!=typeof window&&window.innerWidth<1024;class x{constructor(){this.api=new e,this.userApi=new n,this.product=null,this.userData=null,this.selectedVariant=null,this.isExchanging=!1,this.customer=null,this.userExchangeProductList=[],this.bucksIcon=null}async show(e,n,s,a,r,l,c){var d,h;this.customer=await i(),this.currentActivityType=s||1,this.vipIconSrc=a||"",this.product=e,this.userData=n,this.isExchanging=!1,this.userExchangeProductList=[],this.getPointsLink=r,this.sectionId=l,this.bucksIcon=c,this.selectedVariant=e.redeemVariants.find(t=>this.checkVariantInventoryStatus(t))||this.product.redeemVariants[0];const p=this.selectedVariant?2===this.selectedVariant.combinationMethod?(null==(d=this.selectedVariant.combinationValueInfo)?void 0:d.currentBucks)||0:(null==(h=this.selectedVariant.basicValueInfo)?void 0:h.bucks)||0:0,g=(null==n?void 0:n.points)||0;this.selectedVariant&&g<p&&o("error",u.points_not_enough_btn),this.userData.hasDraftOrder=await this.checkDraftOrder();const m=this.generateContent();t.open({header:1===this.currentActivityType&&this.vipIconSrc?`<img src="${this.vipIconSrc}" alt="VIP" class="absolute z-10 h-15 lg:h-[97px] w-full lg:w-[1200px] -top-1 lg:-top-2 left-0" />`:"",closeIconClass:"relative z-30",closeIcon:"https://cdn.shopify.com/s/files/1/0536/3390/8911/files/gray-close-icon.svg?v=1753174167",content:m,contentClass:"lg:w-[1200px]",showCancel:!1,showConfirm:!1,confirmClass:"bg-blue-600 text-white hover:bg-blue-700",cancelClass:"bg-gray-200 text-gray-800 hover:bg-gray-300",bodyClass:"lg:h-[598px] box-border pb-[120px] lg:!pb-0",onOpen:()=>{this.bindModalEvents()}})}getBucksDisplay(t="w-5 h-5 lg:w-7 lg:h-7"){return this.bucksIcon?`<img src="${this.bucksIcon}" alt="积å" class="inline-block ${t} mr-1">`:d.bucks}generateExchangePriceText(t){if(!t)return"";const{basicMethod:e,combinationMethod:n,basicValueInfo:i,combinationValueInfo:s}=t,o=i?a(100*i.bucks,"{{amount_no_decimals}}"):"",r=s?a(100*(null==s?void 0:s.currentBucks),"{{amount_no_decimals}}"):"";if(1===e)return`${this.getBucksDisplay()}${o}`;if(2===e){if(1===n){const t=i.cash;return t>0?`${this.getBucksDisplay()}${o} + ${a(t,c)}`:`${this.getBucksDisplay()}${o}`}if(2===n){const t=(null==s?void 0:s.currentBucks)||0,e=(null==s?void 0:s.currentCash)||0;return 0===t?`${a(e,c)}`:0===e?`${this.getBucksDisplay()}${r}`:`${this.getBucksDisplay()}${r} + ${a(e,c)}`}}return""}hasPlaceholders(t){return t.includes("{{")&&t.includes("}}")}stripHtmlTags(t){if(!t)return"";const e=document.createElement("div");return e.innerHTML=t,e.textContent||e.innerText||""}updateFooterDisplay(){const t=document.querySelector(".bluetti-modal-body")||document.querySelector(".modal-content");
1if(!t)return;const e=t.querySelector(`.footer-content-${this.product.id}`);if(e){const n=this.generateBottomBar(this.selectedVariant),i=document.createElement("div");i.innerHTML=n;const s=i.firstElementChild;if(s){e.replaceWith(s);const n=t.querySelector(`.exchange-price-top-${this.product.id}`),i=t.querySelector(`.exchange-price-text-footer-${this.product.id}`);n&&i&&(n.innerHTML=i.innerHTML),this.bindBottomBarEvents()}}}bindBottomBarEvents(){const t=document.querySelector(".bluetti-modal-body")||document.querySelector(".modal-content");t&&(t.querySelectorAll(`.exchange-confirm-btn-${this.product.id}`).forEach(t=>{t.addEventListener("click",t=>{t.preventDefault(),this.handleExchangeClick()})}),t.querySelectorAll(`.pending-exchange-btn-${this.product.id}`).forEach(t=>{t.addEventListener("click",t=>{t.preventDefault(),this.setPendingExchangeOrder()})}))}renderCustomPointsCashInput(){if(!this.selectedVariant||2!==this.selectedVariant.combinationMethod)return"";const{combinationValueInfo:t,price:e,variantID:n}=this.selectedVariant,i=(null==t?void 0:t.minBucks)||0;Number(null==t?void 0:t.deductionCash),Number(null==t?void 0:t.multipliedBucks);let s=100*(Number(e)/100||0);this.selectedVariant.combinationValueInfo.maxBucks=s;return`\n <div class="flex items-center mt-3">\n <div class="flex flex-col w-full lg:w-1/2 h-[108px] relative rounded-lg p-3 " style="background: linear-gradient(284deg, rgba(219, 181, 109, 0.48) 0%, rgba(238, 204, 136, 0) 26%), #FAFAFC;">\n \n <img class="w-5 h-5 absolute right-3 top-3 cursor-pointer question-icon-${n} z-10" src="https://cdn.shopify.com/s/files/1/0536/3390/8911/files/question-icon.svg?v=1752651178" alt="add">\n <div style="background: rgba(0, 0, 0, 0.6);backdrop-filter: blur(10px)" class="custom-tooltip-${n} hidden w-full lg:w-[340px] absolute left-0 -top-[72px] lg:left-[94px] z-30 px-3 py-2 rounded-lg text-white text-sm text-center pointer-events-none lg:pointer-events-auto">\n ${r(u.points_range_tip,{min:i,max:s})}\n <span class="hidden lg:inline-block absolute left-1/2 -translate-x-1/2 bottom-[-14px] w-4 h-4 overflow-hidden">\n <svg width="16" height="8" viewBox="0 0 16 8"><polygon points="8,8 0,0 16,0" fill="#4B5563"/></svg>\n </span>\n </div>\n <div class="text-gray-600 text-xs mb-2 flex items-center">${this.getBucksDisplay("h-5 w-5 lg:w-6 lg:h-6")}100=${a(100).split(".")[0]}</div>\n <div class="flex gap-1 mb-2 relative z-10">\n <button type="button" class="custom-points-minus-${n} px-[6px] py-[6px] rounded-[4px] bg-gray-200" aria-label="-">\n <img class="w-6 h-6" src="https://cdn.shopify.com/s/files/1/0536/3390/8911/files/minus-icon_ec5c0aa3-e1da-469f-8612-45155b82ae3c.svg?v=1752657914" alt="minus"> \n </button>\n <input type="number" class="custom-points-input-${n} min-w-[80px] h-9 py-[6px] text-center rounded-[4px] bg-gray-200 border-none caret-blue" min="${i}" max="${s}" step="100" value="0" />\n <button type="button" class="custom-points-plus-${n} px-[6px] py-[6px] rounded-[4px] bg-gray-200" aria-label="+">\n <img class="w-6 h-6" src="https://cdn.shopify.com/s/files/1/0536/3390/8911/files/add-icon_3b1d3a2a-9660-41c9-96c7-f14da1d8a9bc.svg?v=1752657914" alt="add"> \n </button>\n </div>\n <div class="text-gray-600 text-xs relative z-10">${i}-${s} ${d.bucks}</div>\n <img src="https://cdn.shopify.com/s/files/1/0536/3390/8911/files/gold-icon.webp?v=1752717876" alt="add" class="w-20 h-14 absolute bottom-0 right-0 z-0">\n </div>\n </div>\n `}bindCustomPointsCashEvents(){var t,e;if(!this.selectedVariant||2!==this.selectedVariant.combinationMethod)return;const n=document.querySelector(".bluetti-modal-body")||document.querySelector(".modal-content");if(!n)return;const{variantID:i}=this.selectedVariant,s=n.querySelector(`.custom-points-input-${i}`),o=n.querySelector(`.custom-points-minus-${i}`),a=n.querySelector(`.custom-points-plus-${i}`);if(!s||!o||!a)return;const r=(null==(t=this.selectedVariant.combinationValueInfo)?void 0:t.minBucks)||0,l=(null==(e=this.selectedVariant.combinationValueInfo)?void 0:e.maxBucks)||0,c=100,d=Number(this.selectedVariant.price)/100||0,u=t=>{let e=Math.floor(Number(t/c))*c;e=Math.max(r,Math.min(l,e));let n=d-e/c;n<0&&(n=0),n=Math.round(100*n)/100,this.selectedVariant.combinationValueInfo.currentBucks=e,this.selectedVariant.combinationValueInfo.currentCash=100*n,s.value=e,this.updateFooterDisplay()};u(0),s.addEventListener("change",t=>{u(t.target.value)}),o.addEventListener("click",()=>{u(Number(s.value)-c)}),a.addEventListener("click",()=>{u(Number(s.value)+c)});const h=n.querySelector(`.question-icon-${i}`),p=n.querySelector(`.custom-tooltip-${i}`);if(h&&p)if(f){let t=null;h.addEventListener("click",e=>{e.stopPropagation();const n=p.classList.contains("hidden");t&&(clearTimeout(t),t=null),p.classList.toggle("hidden"),n&&(t=setTimeout(()=>{p.classList.add("hidden"),t=null},3e3))}),document.addEventListener("click",function(e){h.contains(e.target)||p.contains(e.target)||(p.classList.add("hidden"),t&&(clearTimeout(t),t=null))},{once:!0})}else h.addEventListener("mouseenter",()=>{p.classList.remove("hidden")}),h.addEventListener("mouseleave",()=>{p.classList.add("hidden")}),p.addEventListener("mouseenter",()=>{p.classList.remove("hidden")}),p.addEventListener("mouseleave",()=>{p.classList.add("hidden")})}getAvailableSubOptions(t,e){if(!this.product||!this.product.redeemVariants)return[];const n=[];return this.checkAllVariantsOutOfStock()?[]:(this.product.redeemVariants.forEac
1h(i=>{let s=!0;for(let n=0;n<t;n++){const t=`option${n+1}`;if(e[t]&&i[t]!==e[t]){s=!1;break}}if(s){const e=i[`option${t+1}`];if(e&&!n.includes(e)){this.checkVariantInventoryStatus(i)&&n.push(e)}}}),n)}checkVariantInventoryStatus(t){if(!t)return!1;const e="shopify"===t.inventoryManagement,n="continue"===t.inventoryPolicy;return!e||n||e&&!n&&t.inventoryQuantity>0}checkAllVariantsOutOfStock(){return!(!this.product||!this.product.redeemVariants)&&this.product.redeemVariants.every(t=>!this.checkVariantInventoryStatus(t))}checkMainOptionOutOfStock(t){if(!this.product||!this.product.redeemVariants||!t)return!1;const e=this.product.redeemVariants.filter(e=>e.option1===t);return 0===e.length||e.every(t=>!this.checkVariantInventoryStatus(t))}generateContent(){var t,e,n;const{productImg:i,options:s}=this.product,o=`\n <div class="relative w-60 lg:w-[546px] h-60 lg:h-[450px] mx-auto">\n <img\n src="${(null==(t=this.selectedVariant)?void 0:t.variantImg)||i}"\n loading="lazy"\n width="450"\n height="450"\n class="product-image-preview-${this.product.id} aspect-1 object-contain w-full h-full"\n />\n <img\n src="https://cdn.shopify.com/s/files/1/0536/3390/8911/files/expand-icon.svg?v=1751540125"\n loading="lazy"\n width="24"\n height="24"\n class="lg:hidden expand-icon-${this.product.id} absolute right-0 top-0 z-10 cursor-pointer mb-6"\n />\n </div>\n `,a=(null==(n=null==(e=this.selectedVariant)?void 0:e.combinationValueInfo)?void 0:n.combinationRule)?`\n <style>\n .collapse-text-${this.product.id} { \n overflow: hidden; \n position: relative; \n transition: max-height 0.3s ease-in-out; \n line-height: 1.5;\n }\n @media (max-width: 1023px) { \n .collapse-text-${this.product.id} { \n max-height: 76px; \n display: -webkit-box;\n -webkit-line-clamp: 3;\n -webkit-box-orient: vertical;\n overflow: hidden;\n text-overflow: ellipsis;\n } \n }\n @media (min-width: 1024px) { \n .collapse-text-${this.product.id} { \n max-height: 72px; /* 3è¡æåé«åº¦: 1.5 * 16px * 3 = 72px */\n display: -webkit-box;\n -webkit-line-clamp: 3;\n -webkit-box-orient: vertical;\n overflow: hidden;\n text-overflow: ellipsis;\n } \n }\n .collapse-text-${this.product.id}.expanded { \n max-height: 3000px; \n display: block;\n -webkit-line-clamp: unset;\n text-overflow: unset;\n }\n .expand-btn-${this.product.id} { display: none; }\n .expand-btn-${this.product.id}.show { display: inline-flex; }\n </style>\n <div class="mb-3 lg:mb-6 relative">\n <div class="usage-desc collapse-text-${this.product.id}">${this.selectedVariant.combinationValueInfo.combinationRule}</div>\n <div class="expand-btn-${this.product.id} text-sm lg:text-base mt-2 lg:mt-3 text-gray-700 flex items-center gap-[2px] cursor-pointer">\n ${d.expand}\n <img src="https://cdn.shopify.com/s/files/1/0536/3390/8911/files/arrow-bottom.svg?v=1751624188" alt="expand" class="expand-arrow-${this.product.id} w-4 h-4 transition-transform duration-300">\n </div>\n </div>\n `:"",r=this.selectedVariant?(()=>{if("shopify"===this.selectedVariant.inventoryManagement){const t=Math.max(0,this.selectedVariant.inventoryQuantity||0);return`\n <div class="mb-4">\n <div class="text-sm text-gray-500 in-stock-${this.product.id}">${d.in_stock}ï¼${t}</div>\n </div>\n `}return""})():"";let l="";1===s.length&&"Title"===s[0].name&&1===s[0].values.length&&"Default Title"===s[0].values[0]||(l=s.length?`\n <div class="mb-4">\n ${s.map((t,e)=>{const n=t.values,i=this.selectedVariant&&this.selectedVariant[`option${e+1}`]||"",s=0===e;let o=n;!s&&this.selectedVariant&&(o=this.getAvailableSubOptions(e,this.selectedVariant));const a=this.checkAllVariantsOutOfStock();return`\n <div class="mb-3">\n <div class="font-semibold mb-2">${t.name}ï¼</div>\n <div class="flex flex-wrap gap-2">\n ${n.map(n=>{const r=n===i;let l=!1;return l=!!a||(s?this.checkMainOptionOutOfStock(n):!o.includes(n)),`\n <button \n class="overflow-hidden max-w-full variant-option px-3 py-1 rounded-lg border text-sm transition-all ${r?"btn btn-black-base":l?"btn btn-black-grey opacity-50 cursor-not-allowed":"btn btn-black-grey"}"\n data-option-index="${e}"\n data-option-name="${t.name}"\n data-value="${n}"\n ${l?"disabled":""}\n >\n ${n}\n </button>\n `}).join("")}\n </div>\n </div>\n `}).join("")}\n </div>\n `:"");let c="";this.selectedVariant&&2===this.selectedVariant.combinationMethod&&(c=this.renderCustomPointsCashInput());const u=this.generateBottomBar(this.selectedVariant),h=this.product.productName;return`\n <div class="w-full lg:flex lg:gap-6 lg:h-full ${1===this.currentActivityType?"activity-vip":"activity-normal"}">\n ${o}\n <div class="mb-4 relative lg:static lg:overflow-y-auto lg:flex-1 pr-1 lg:pb-6">\n <div class="sticky -top-1 z-20 bg-white border-b !border-[#D2D2D7] mb-1 lg:mb-4 pb-2">\n <div class="line-clamp-2 overflow-hidden break-all text-xl lg:text-2.5xl font-bold mb-1 lg:mb-3 ">${h}</div>\n <div class="${"card-bucks-"+this.sectionId} text-base lg:text-2xl font-bold exchange-price-top-${this.product.id} w-full truncate flex items-center">${this.generateExchangePriceText(this.selectedVariant)}</div>\n </div>\n ${a}\n ${r}\n ${l}\n ${c}\n </div>\n ${u}\n </div>\n `}bindModalEvents(){const t=document.querySelector(".bluetti-modal-body")||document.querySelector(".modal-content");
1t&&(t.querySelectorAll(".variant-option").forEach(e=>{e.addEventListener("click",n=>{const i=parseInt(e.dataset.optionIndex),s=e.dataset.value,o={};if(this.selectedVariant)for(let t=0;t<this.product.options.length;t++)o[`option${t+1}`]=this.selectedVariant[`option${t+1}`];o[`option${i+1}`]=s;for(let t=i+1;t<this.product.options.length;t++){const e=this.getAvailableSubOptions(t,o);e.length>0?o[`option${t+1}`]=e[0]:o[`option${t+1}`]=""}const a=this.product.redeemVariants.find(t=>this.product.options.every((e,n)=>t[`option${n+1}`]===o[`option${n+1}`]));this.selectedVariant=a||{...o},t&&(t.innerHTML=this.generateContent(),this.bindModalEvents(),this.updateFooterDisplay())})}),t.querySelectorAll(`.expand-btn-${this.product.id}`).forEach(t=>{const e=t.parentElement.querySelector(`.collapse-text-${this.product.id}`),n=t.querySelector(`.expand-arrow-${this.product.id}`);(()=>{const t=e.style.cssText;e.style.display="block",e.style.maxHeight="none",e.style.webkitLineClamp="unset",e.style.textOverflow="unset";const n=e.scrollHeight,i=3*parseFloat(getComputedStyle(e).lineHeight);return e.style.cssText=t,n>i})()?t.classList.add("show"):t.style.display="none",t.addEventListener("click",function(){e.classList.contains("expanded")?(e.classList.remove("expanded"),t.childNodes[0].textContent=d.expand,n&&n.classList.remove("rotate-180")):(e.classList.add("expanded"),t.childNodes[0].textContent=d.collapse,n&&n.classList.add("rotate-180"))})}),f&&t.querySelectorAll(`.expand-icon-${this.product.id}, .product-image-preview-${this.product.id}`).forEach(e=>{e.addEventListener("click",e=>{const n=Array.from(t.querySelectorAll(`.product-image-preview-${this.product.id}`)),i=n.map(t=>t.getAttribute("src")),s=n.findIndex(t=>t===e.target||t.parentElement.contains(e.target));l(i,s>=0?s:0,`preview-${this.product.id}`,{inactiveColor:"#FFFFFF",activeColor:"#6E6E73"})})}),t.querySelectorAll(`.exchange-confirm-btn-${this.product.id}`).forEach(t=>{t.addEventListener("click",t=>{t.preventDefault(),this.handleExchangeClick()})}),t.querySelectorAll(`.pending-exchange-btn-${this.product.id}`).forEach(t=>{t.addEventListener("click",t=>{t.preventDefault(),this.setPendingExchangeOrder()})}),this.bindCustomPointsCashEvents(),this.bindBottomBarEvents())}async handleExchangeClick(){var t,e,n;if(!this.isExchanging)if(this.selectedVariant&&this.selectedVariant.variantID)if(this.checkVariantInventoryStatus(this.selectedVariant)){const s=2===this.selectedVariant.combinationMethod?(null==(t=this.selectedVariant.combinationValueInfo)?void 0:t.currentBucks)||0:(null==(e=this.selectedVariant.basicValueInfo)?void 0:e.bucks)||0;if(((null==(n=this.userData)?void 0:n.points)||0)<s)return void o("error",h.points_not_enough);this.isExchanging=!0,this.setButtonLoading(!0,"exchange-confirm-btn-"+this.product.id);try{await this.checkDraftOrder()?(await this.showExchangeConfirmModal(!0),this.isExchanging=!1,this.setButtonLoading(!1,"exchange-confirm-btn-"+this.product.id)):(await this.proceedToCheckout(),this.isExchanging=!1)}catch(i){this.isExchanging=!1,this.setButtonLoading(!1,"exchange-confirm-btn-"+this.product.id)}}else o("error",h.product_is_sold_out);else o("error",h.product_is_sold_out)}async checkDraftOrder(){var t;const e=await this.api.getUserExchangeProductList();return this.userExchangeProductList=(null==(t=e.data)?void 0:t.records)||[],this.userExchangeProductList.length>0}async setPendingExchangeOrder(){this.setButtonLoading(!0,"pending-exchange-btn-"+this.product.id);try{await this.checkDraftOrder()}catch(t){return o("error","è·åå
æ¢å表失败ï¼è¯·éè¯"),void this.setButtonLoading(!1,"pending-exchange-btn-"+this.product.id)}this.setButtonLoading(!1,"pending-exchange-btn-"+this.product.id),this.showExchangeConfirmModal(!1)}async showExchangeConfirmModal(e=!0){const{content:n,isMaxReached:i,buttonClass:s,buttonText:a}=this.generateDraftOrderContent();i&&o("error",u.max_exchange_count_description),t.open({singleton:!0,modalType:"exchange-confirm-list",header:u.title,content:n,showCancel:!1,showConfirm:e,confirmClass:s,confirmText:a,onConfirm:async()=>{const t=document.querySelector(`.exchange-current-btn-${this.product.id}`);t&&(t.disabled=!0,t.innerHTML=g);try{await this.proceedToCheckout()}catch(e){return t&&(t.disabled=!1,t.innerHTML=a),!1}},bodyClass:`pb-0 order-content-body-${this.product.id}`,footerClass:"pt-0",onOpen:()=>{this.bindDeleteEvents()}})}
1generateDraftOrderContent(){const t=this.userExchangeProductList||[],e=Date.now(),n=t.length>=5;let i="";i=0===t.length?`<div class="text-center text-gray-400 py-8">${u.no_pending_exchange}</div>`:t.map(t=>{const n=t.createAt?t.createAt+9e5-e:0,i=Math.max(0,Math.ceil(n/6e4)),s=t.actualPrice>0?`${a(t.actualPrice,c)}`:"",o=t.bucks>0?`${this.getBucksDisplay()}${t.bucks} ${s?"+":""} ${s}`:`${s}`;return`\n <div class="lg:flex lg:gap-3 lg:justify-between bg-neutral-100 rounded-xl px-3 py-2 mb-2">\n <div>\n <div class="text-sm text-neutral-600 mb-[2px]">${i}${u.time}</div>\n <div class="flex items-center font-normal text-base text-neutral-900 lg:max-w-[460px]">\n <span class="overflow-hidden whitespace-normal lg:whitespace-nowrap text-ellipsis line-clamp-2 lg:line-clamp-1 flex-1 lg:flex-none lg:max-w-[310px]">${"Default Title"==t.variantName?t.productName:t.variantName}</span>\n <span class="hidden lg:inline">ï¼</span>\n <span class="ml-1 flex items-center"> ${o}</span>\n </div>\n </div>\n <div class="flex items-center gap-3 lg:gap-2 mt-[10px] lg:mt-0">\n <a href="${t.draftOrderUrl}" class="${m} font-medium" target="_blank">${u.redeem}</a>\n <button class="delete-draft-btn-${this.product.id} group" data-draft-id="${t.id}">\n <span class="icon-wrapper text-[#A5A5A8] group-hover:text-[#86868B] group-active:text-[#6E6E73] transition-colors">\n ${p}\n </span>\n </button>\n </div>\n </div>\n `}).join("");const s=n?`w-full lg:w-[343px] flex justify-center items-center lg:mx-auto rounded-full exchange-current-btn-${this.product.id} bg-gray-300 text-gray-500 cursor-not-allowed pointer-events-none hover:bg-gray-300 hover:opacity-80 transition-all`:`px-4 py-2 bg-blue-600 text-white hover:bg-blue-700 transition-colors w-full lg:w-[343px] flex justify-center items-center lg:mx-auto rounded-full exchange-current-btn-${this.product.id}`,o=n?u.max_exchange_count_title:u.current_exchange_btn;return{content:`\n <div>\n ${t.length>0?`<div class="mb-4">${u.description}</div>`:""}\n <div id="draft-order-list">${i}</div>\n </div>\n `,hasOrders:t.length>0,isMaxReached:n,buttonClass:s,buttonText:o}}updateModalContent(){const{content:t,isMaxReached:e,buttonClass:n,buttonText:i}=this.generateDraftOrderContent(),s=document.querySelector(`.order-content-body-${this.product.id}`);s&&(s.innerHTML=t,this.bindDeleteEvents());const o=document.querySelector(`.exchange-current-btn-${this.product.id}`);o.className="",o&&(o.className+=n,o.textContent=i,o.disabled=!!e)}bindDeleteEvents(){document.querySelectorAll(`.delete-draft-btn-${this.product.id}`).forEach(t=>{t.addEventListener("click",async e=>{const n=t.getAttribute("data-draft-id"),i=t.querySelector(".icon-wrapper");i.innerHTML=g;const a=await this.api.userCancelRedemption({redemptionLogsID:n});if([4020,4021,0].includes(a.code)){this.userExchangeProductList=this.userExchangeProductList.filter(t=>t.id!==n),0==a.code&&(a.code=4020),o("success",b(a.code)),this.updateModalContent();try{const t=await this.userApi.getUserTier(this.customer.token);t&&0===t.code&&t.data&&(this.userData.points=t.data.points,this.updateFooterDisplay(),s("userPointsUpdated",{points:t.data.points}))}catch(r){}}else o("error",b(a.code)),i.innerHTML=p})})}async proceedToCheckout(){var t,e;const n=2===this.selectedVariant.combinationMethod,i=n?null==(t=this.selectedVariant.combinationValueInfo)?void 0:t.currentBucks:void 0,s={redemptionID:this.product.redemptionID,productID:this.product.productID,variantID:this.selectedVariant.variantID};n&&(s.bucks=i);const a=await this.api.userExchangeProduct(s);return 0==a.code&&(null==(e=a.data)?void 0:e.draftOrderUrl)?(setTimeout(()=>{window.location.href=a.data.draftOrderUrl}
1,1e3),!0):(4022==a.code&&(this.product.redeemVariants.forEach(t=>{t.variantID==this.selectedVariant.variantID&&(t.inventoryQuantity=0)}),this.selectedVariant.inventoryQuantity=0,document.querySelector(`.in-stock-${this.product.id}`).innerHTML=d.in_stock+"ï¼0",this.updateFooterDisplay()),o("error",b(a.code)),this.setButtonLoading(!1,"exchange-confirm-btn-"+this.product.id),!1)}generateFooterButtons(t,e,n,i=!1){var s,o;if(!t&&i){const t="rounded-full px-5 py-[10px] font-medium text-base cursor-pointer h-11 lg:!min-w-60 truncate lg:truncate-none flex justify-center items-center",e=`${1==this.currentActivityType?"vip-exchange-btn-"+this.sectionId:"normal-exchange-btn-"+this.sectionId} ${t}`,i=`pending-exchange-btn-${this.product.id} ${1==this.currentActivityType?"vip-ghost-btn-"+this.sectionId:"normal-ghost-btn-"+this.sectionId} ${t}`;return`\n <div class="flex gap-3 mt-3 md:mt-0">\n ${n?`<button class="${i}" style="width: calc(50% - 6px)">\n <span class="btn-text-${this.product.id}">${u.pending_exchange_order_btn}</span>\n <span class="btn-loading-${this.product.id} hidden">\n ${g}\n </span>\n </button>`:""}\n <button class="${e} disabled-${this.sectionId} opacity-50 cursor-not-allowed" style="${n&&f?"width: calc(50% - 6px)":"width: 100%"}" disabled>${h.product_is_sold_out}</button>\n </div>\n `}if(!t)return"";const a=2===t.combinationMethod?(null==(s=t.combinationValueInfo)?void 0:s.currentBucks)||0:(null==(o=t.basicValueInfo)?void 0:o.bucks)||0,r=this.checkVariantInventoryStatus(t),l=i||this.checkAllVariantsOutOfStock(),c="rounded-full px-5 py-[10px] font-medium text-base cursor-pointer h-11 lg:!min-w-60 truncate lg:truncate-none flex justify-center items-center",p=`pending-exchange-btn-${this.product.id} ${1==this.currentActivityType?"vip-ghost-btn-"+this.sectionId:"normal-ghost-btn-"+this.sectionId} ${c}`,m=`${1==this.currentActivityType?"vip-exchange-btn-"+this.sectionId:"normal-exchange-btn-"+this.sectionId} ${c}`;return e<a?`\n <div class="flex gap-3 mt-3 md:mt-0">\n ${n?`<button class="${p}" style="width: calc(50% - 6px)">\n <span class="btn-text-${this.product.id}">${u.pending_exchange_order_btn}</span>\n <span class="btn-loading-${this.product.id} hidden">\n ${g}\n </span>\n </button>`:""}\n <button class="${m} disabled-${this.sectionId}" style="${n&&f?"width: calc(50% - 6px)":"width: 100%"}" disabled>${u.points_not_enough_btn}</button>\n </div>\n `:!r||l?`\n <div class="flex gap-3 mt-3 md:mt-0">\n ${n?`<button class="${p}" style="width: calc(50% - 6px)">\n <span class="btn-text-${this.product.id}">${u.pending_exchange_order_btn}</span>\n <span class="btn-loading-${this.product.id} hidden">\n ${g}\n </span>\n </button>`:""}\n <button class="${m} disabled-${this.sectionId} opacity-50 cursor-not-allowed" style="${n&&f?"width: calc(50% - 6px)":"width: 100%"}" disabled>${h.product_is_sold_out}</button>\n </div>\n `:`\n <button class="${m} exchange-confirm-btn-${this.product.id} mt-3 lg:mt-0" data-variant-id="${(null==t?void 0:t.id)||""}">\n <span class="btn-text-${this.product.id}">${d.exchange_confirm_btn}</span>\n <span class="btn-loading-${this.product.id} hidden">\n <svg class="animate-spin" xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewBox="0 0 24 24"><defs><clipPath id="master_svg0_1702_221223/1552_200729"><rect x="0" y="0" width="24" height="24" rx="0"/></clipPath></defs><g clip-path="url(#master_svg0_1702_221223/1552_200729)"><g><g><path d="M11,1.998291015625L11,2.998291015625L11,5.248721015625L11,6.248721015625L13,6.248721015625L13,5.248721015625L13,2.998291015625L13,1.998291015625Z" fill-rule="evenodd" fill="#FFFFFF" fill-opacity="1"/></g><g><path d="M18.3647075,4.220789765625L17.6576055,4.927903765625L16.0663305,6.519179765625L15.3592175,7.226289765625L16.7734375,8.640509765625L17.4805445,7.933389765625L19.0718175,6.342115765625L19.7789375,5.635009765625L18.3647075,4.220789765625Z" fill-rule="evenodd" fill="#FFFFFF" fill-opacity="1"/></g><g style="opacity:0.800000011920929;">
1<path d="M17.75,13.000244140625L18.75,13.000244140625L21.00043,13.000244140625L22.00043,13.000244140625L22.00043,11.000244140625L21.00043,11.000244140625L18.75,11.000244140625L17.75,11.000244140625L17.75,13.000244140625Z" fill-rule="evenodd" fill="#FFFFFF" fill-opacity="1"/></g><g style="opacity:0.6000000238418579;"><path d="M15.3592175,16.773681640625L16.0663305,17.480788640625L17.6576065,19.072061640625L18.3647175,19.779181640625L19.7789375,18.364961640625L19.0718175,17.657850640625L17.4805445,16.066574640625L16.7734375,15.359461640625L15.3592175,16.773681640625Z" fill-rule="evenodd" fill="#FFFFFF" fill-opacity="1"/></g><g style="opacity:0.5;"><path d="M11,17.751220703125L11,18.751220703125L11,21.001650703125L11,22.001650703125L13,22.001650703125L13,21.001650703125L13,18.751220703125L13,17.751220703125L11,17.751220703125Z" fill-rule="evenodd" fill="#FFFFFF" fill-opacity="1"/></g><g style="opacity:0.4000000059604645;"><path d="M7.226045625,15.359461640625L6.518935625,16.066574640625L4.927659625,17.657849640625L4.220545625,18.364951640625L5.634765625,19.779181640625L6.341872625,19.072061640625L7.933145625,17.480788640625L8.640265625,16.773681640625L7.226045625,15.359461640625Z" fill-rule="evenodd" fill="#FFFFFF" fill-opacity="1"/></g><g style="opacity:0.30000001192092896;"><path d="M1.998046875,13.000244140625L2.998046875,13.000244140625L5.248476875,13.000244140625L6.248476875,13.000244140625L6.248476875,11.000244140625L5.248476875,11.000244140625L2.998046875,11.000244140625L1.998046875,13.000244140625Z" fill-rule="evenodd" fill="#FFFFFF" fill-opacity="1"/></g><g style="opacity:0.20000000298023224;"><path d="M4.220545625,5.635009765625L4.927658625,6.342116765625L6.518935625,7.933389765625L7.226045625,8.640509765625L8.640265625,7.226289765625L7.933145625,6.519179765625L6.341872625,4.927902765625L5.634765625,4.220789765625L4.220545625,5.635009765625Z" fill-rule="evenodd" fill="#FFFFFF" fill-opacity="1"/></g></g></g></svg>\n </span>\n </button>\n `}generateBottomBar(t){var e,n,i,s;const o=(null==(e=this.userData)?void 0:e.points)||0,a=null==(n=this.userData)?void 0:n.hasDraftOrder,r=this.checkAllVariantsOutOfStock();if(!t&&r){const e=this.generateFooterButtons(t,o,a,r);return this.generateFooterContainer(this.product.productName,this.generatePointsBalanceText(o),e)}if(!t)return"";const l=2===t.combinationMethod?(null==(i=t.combinationValueInfo)?void 0:i.currentBucks)||0:(null==(s=t.basicValueInfo)?void 0:s.bucks)||0,c=this.generateFooterButtons(t,o,a,r),d=this.generateExchangePriceText(t),u=o<l?this.generatePointsBalanceText(o,!0):this.generatePointsBalanceText(o);return this.generateFooterContainer(d,u,c)}generateFooterContainer(t,e,n){return`\n <div class="footer-content-${this.product.id} rounded-b-xl fixed left-0 right-0 bottom-0 bg-white px-4 lg:px-6 pt-3 lg:pt-4 pb-4 flex flex-col md:flex-row md:items-center md:justify-between z-50 lg:border-t lg:!border-gray-400">\n <div>\n <div class="text-2xl font-bold text-neutral-900 exchange-price-text-footer-${this.product.id} line-clamp-2 flex flex-wrap items-center">${t}</div>\n <div class="text-sm lg:text-base text-neutral-600 flex flex-wrap items-center">${e}</div>\n </div>\n ${n}\n </div>\n `}generatePointsBalanceText(t,e=!1){const n=`${d.points_balance} ${this.getBucksDisplay()}${a(100*t,"{{amount_no_decimals}}")}`;return e?`${n} <a href="${this.getPointsLink}" class="${m} text-base ml-2 lg:ml-1" target="_self">${u.get_points} ></a>`:n}setButtonLoading(t,e){const n=document.querySelector(".bluetti-modal-body")||document.querySelector(".modal-content");if(!n)return;const i=n.querySelector(`.${e}`);if(!i)return;const s=i.querySelector(`.btn-text-${this.product.id}`),o=i.querySelector(`.btn-loading-${this.product.id}`);s&&o&&(t?(i.disabled=!0,i.classList.add("opacity-60","cursor-not-allowed"),s.classList.add("hidden"),o.classList.remove("hidden")):(i.disabled=!1,i.classList.remove("opacity-60","cursor-not-allowed"),s.classList.remove("hidden"),o.classList.add("hidden")))}}let y=null;const L=(y||(y=new x),y);
1export{L as default,v as errorMessages};
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.