1"use strict";(self.webpackChunkgcom_rhythm=self.webpackChunkgcom_rhythm||[]).push([[1813],{1813(e,t,a){a.d(t,{C:()=>o,checkFrameInCart:()=>c,getVariantId:()=>i,handlePauseReservation:()=>n,isCurrentPauseItemInCart:()=>s});var r=a(5805);async function n(e,t,a){let n,s=[];localStorage.getItem("pauseCartItems")&&(s=JSON.parse(localStorage.getItem("pauseCartItems")));const u=new URLSearchParams(window.location.search).get("frame"),c=String(t||i(a)),d=await async function(e,t,a){const r="/a/app/graphql/query",n=document.querySelector('[name="product_id"]').value;let i=await o();i.includes("?key=")&&(i=i.split("?key=")[0]);localStorage.getItem("pauseCartId")!==i&&localStorage.setItem("pauseCartId",i);let s=1;t.length>0&&(s=t[t.length-1].lineId+1);let u="";for(let e=0;e<t.length;e++)u+=`frame${t[e].lineId}:pauseFrameReserve(input: { frameNum: ${t[e].frameNum}, cartId: "${i}", productId: "${t[e].productId}", shopifyVariantId: "${t[e].variantId}" }) {\n duration\n }`;const c={query:`mutation PauseFrameReserve {\n frame${s}:pauseFrameReserve(input: { frameNum: ${e}, cartId: "${i}", productId: "${n}" , shopifyVariantId: "${a}" }) {\n duration\n }\n ${u}\n }`};try{const e=await fetch(r,{headers:{"Content-Type":"application/json"},body:JSON.stringify(c),method:"POST"});if(e.ok&&e.status<400){const t=await e.json();return null!==t.data&&void 0!==t.data&&{duration:t.data["frame"+s].duration}}}catch(e){return!1}}(u,s,c);if(!1!==d){const e=new Date;e.setSeconds(e.getSeconds()+d.duration),localStorage.setItem("pauseCountdown",e);const t=e.toISOString(),a=JSON.stringify({attributes:{"_pause-expiry-date-time":t}});await fetch(`${routes.cart_update_url}`,{...(0,r.Dz)(),body:a}).then(e=>e.json()).then(e=>{let t=1;s.length>0&&(t=s[s.length-1].lineId+1);const a={lineKey:e.items[0].key,lineId:t,productId:document.querySelector('[name="product_id"]').value,frameNum:u,variantId:c};s.push(a),localStorage.setItem("pauseCartItems",JSON.stringify(s)),n=!0})}else if(e?.key){const t=JSON.stringify({id:e.key,quantity:0});await fetch(`${routes.cart_change_url}`,{...(0,r.Dz)(),body:t}).then(e=>{n=!1}).catch(e=>{n=!1})}else n=!1;if(!1===n){a.has_cart_error=!0,a.handleErrorMessage(window.cartStrings.pauseFrameSoldOutMessage);const e=a.querySelector('[type="submit"]');e.setAttribute("disabled",!0),e.setAttribute("aria-disabled",!0),document.querySelector("main .product__info .product-form__submit .buybutton_label").innerHTML=window.variantStrings.soldOut}else if(!0===n){a.has_cart_error=!1;const e=a.querySelector('[type="submit"]');e.removeAttribute("disabled"),e.removeAttribute("aria-disabled"),e.setAttribute("data-pause-current-state","extend_timer")}return n}async function o(){try{const e=await fetch("/cart.js");if(e.ok){return(await e.json()).token}throw new Error("Something wrongs")}catch(e){}}function i(e){const t=e?.form?.querySelector('[name="id"]')?.value||e?.querySelector?.('[name="id"]')?.value,a=document.querySelector('main .product__info [name="id"]')?.value||document.querySelector('[name="id"]')?.value,r=new URLSearchParams(window.location.search).get("variant");return t||a||r}function s(e,t){const a=new URLSearchParams(window.location.search).get("frame"),r=t.form.querySelector('[name="product_id"]')?.value;return JSON.parse(localStorage.getItem("pauseCartItems")||"[]").some(t=>t.frameNum===a&&String(t.variantId)===String(e)&&String(t.productId)===String(r))}function u(e,t){document.dispatchEvent(new CustomEvent("umg:pause:frame-availability-updated",{detail:{variantId:String(e),availability:t}}))}async function c(e,t){const a=new URLSearchParams(window.location.search).get("frame"),n=t.querySelector('[name="id"]')?.value||e,o=document.querySelector('main .product__info [name="product_id"]').value,s=document.querySelector("#pause_reservation_mode")?.value;let c=[];localStorage.getItem("pauseCartItems")&&(c=JSON.parse(localStorage.getItem("pauseCartItems")));let d=!1;for(let t=0;t<c.length;t++){const n=c[t].frameNum===a&&String(c[t].productId)===String(o),i=String(c[t].variantId)===String(e);if(n&&(i||"PRODUCT_FRAME"===s)){d=!0;const e=JSON.stringify({id:c[t].lineKey,quantity:0});
1await fetch(`${routes.cart_change_url}`,{...(0,r.Dz)(),body:e}).then(e=>{!0===e.ok&&(c.splice(t,1),localStorage.setItem("pauseCartItems",JSON.stringify(c)))}).catch(e=>{});break}}const l=await async function(e,t=i()){const a={query:`query getFrameAvailability { \n pauseFrame(productId: "${document.querySelector('[name="product_id"]').value}", shopifyVariantId: "${t}", num: ${e} ) {\n available\n soldOut\n } \n }`};try{const e=await fetch("/a/app/graphql/query",{headers:{"Content-Type":"application/json"},body:JSON.stringify(a),method:"POST"});return!!(e.ok&&e.status<400)&&(await e.json()).data.pauseFrame}catch(e){return!1}}(a,e);let m;return!0===l.soldOut&&(m="sold_out"),!0===l.available&&(m="available"),!1===l.soldOut&&!1===l.available&&(m="reserved"),"sold_out"===m&&!1===d?(u(n,l),t.handleErrorMessage(window.cartStrings.pauseFrameSoldOutMessage),!1):!("reserved"===m&&!1===d||"reserved"===m&&!0===d)||(u(n,l),t.handleErrorMessage(window.cartStrings.pauseFrameUnavailableMessage),!1)}}}]);
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.