1"use strict";(self.webpackChunkgcom_rhythm=self.webpackChunkgcom_rhythm||[]).push([[1813],{1813(e,t,a){a.d(t,{Cy:()=>o,J1:()=>i,checkFrameInCart:()=>l,getVariantId:()=>s,handlePauseReservation:()=>n,isCurrentPauseItemInCart:()=>u});var r=a(5805);async function n(e,t,a){let n,u=[];localStorage.getItem("pauseCartItems")&&(u=JSON.parse(localStorage.getItem("pauseCartItems")));const c=new URLSearchParams(window.location.search).get("frame"),l=String(t||s(a)),d=i(a),m=await async function(e,t,a,r){const n="/a/app/graphql/query";let s=await o();s.includes("?key=")&&(s=s.split("?key=")[0]);localStorage.getItem("pauseCartId")!==s&&localStorage.setItem("pauseCartId",s);let i=1;t.length>0&&(i=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: "${s}", productId: "${t[e].productId}", shopifyVariantId: "${t[e].variantId}" }) {\n duration\n }`;const c={query:`mutation PauseFrameReserve {\n frame${i}:pauseFrameReserve(input: { frameNum: ${e}, cartId: "${s}", productId: "${r}" , shopifyVariantId: "${a}" }) {\n duration\n }\n ${u}\n }`};try{const e=await fetch(n,{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"+i].duration}}}catch(e){return!1}}(c,u,l,d);if(!1!==m){const e=new Date;e.setSeconds(e.getSeconds()+m.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;u.length>0&&(t=u[u.length-1].lineId+1);const a={lineKey:e.items[0].key,lineId:t,productId:d,frameNum:c,variantId:l};u.push(a),localStorage.setItem("pauseCartItems",JSON.stringify(u)),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 s(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 i(e){return e?.querySelector?.('form [name="product-id"]')?.value||null}function u(e,t){const a=new URLSearchParams(window.location.search).get("frame"),r=i(t);return JSON.parse(localStorage.getItem("pauseCartItems")||"[]").some(t=>t.frameNum===a&&String(t.variantId)===String(e)&&String(t.productId)===String(r))}function c(e,t){document.dispatchEvent(new CustomEvent("umg:pause:frame-availability-updated",{detail:{variantId:String(e),availability:t}}))}async function l(e,t){const a=new URLSearchParams(window.location.search).get("frame"),n=t.querySelector('[name="id"]')?.value||e,o=i(t),s=document.querySelector("#pause_reservation_mode")?.value;let u=[];localStorage.getItem("pauseCartItems")&&(u=JSON.parse(localStorage.getItem("pauseCartItems")));let l=!1;for(let t=0;t<u.length;t++){const n=u[t].frameNum===a&&String(u[t].productId)===String(o),i=String(u[t].variantId)===String(e);if(n&&(i||"PRODUCT_FRAME"===s)){l=!0;const e=JSON.stringify({id:u[t].lineKey,quantity:0});await fetch(`${routes.cart_change_url}`,{...(0,r.Dz)(),body:e}).then(e=>{!0===e.ok&&(u.splice(t,1),localStorage.setItem("pauseCartItems",JSON.stringify(u)))}).catch(e=>{});break}}const d=await async function(e,t,a){const r={query:`query getFrameAvailability { \n pauseFrame(productId: "${a}", 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(r),method:"POST"});return!!(e.ok&&e.status<400)&&(await e.json()).data.pauseFrame}catch(e){return!1}}(a,e,o);let m;return!0===d.soldOut&&(m="sold_out"),!0===d.available&&(m="available"),!1===d.soldOut&&!1===d.available&&(m="reserved"),"sold_out"===m&&!1===l?(c(n,d),t.handleErrorMessage(window.cartStrings.pauseFrameSoldOutMessage),!1):!("reserved"===m&&!1===l||"reserved"===m&&!0===l)||(c(n,d),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.