PageSourceSearch

https://ritual.com/cdn/shop/t/577/assets/WithApiClient.PdN3Ndxr.min.js

js ritual.com collected 2026-10-01 08:47:27 UTC 5,061 bytes, 1 lines download raw bytes

1import{d as e}from"./vendor.BxRSgd5H.min.js";const t={},o={},n=async(e,t)=>{try{const o=e.headers.get("content-type");return o&&(o.includes("application/json")||o.includes("json")||o.includes("application/graphql")||o.includes("text/javascript"))||(null==t?void 0:t.forceJSON)?await e.json():await e.text()}catch(o){return console.error("Error in formattedResponse",o),await e.text()}},r=e=>{const t={};for(const[o,n]of e.entries())t[o]?Array.isArray(t[o])?t[o].push(n):t[o]=[t[o],n]:t[o]=n;return t},s=async(e,t,o,r,s)=>{var i,a,c,l;try{const l={...e.headers,...(null==r?void 0:r.headers)||{}},h=(null==s?void 0:s.params)?(e=>{const t=new URLSearchParams;for(const o in e){const n=e[o];if(Array.isArray(n))for(const e of n)t.append(o,e);else t.set(o,n)}return t})(s.params):null;null==(i=null==e?void 0:e.onRequestStart)||i.call(e);const d={...l,...(null==r?void 0:r.headers)||{}};(null==s?void 0:s.removeContentType)&&delete d["Content-Type"];const u=(null==r?void 0:r.method)||e.defaultMethod||"GET",f=(null==s?void 0:s.withCache)&&"GET"===u,p=(null==s?void 0:s.persistCache)&&"GET"===u?(e,t)=>async function(e,t={},o=[],n=6e4){try{const s=((e,t=[])=>{var o,n;const r="undefined"!=typeof window&&(null==(o=window.location)?void 0:o.origin)?window.location.origin:"http://localhost",s=new URL(e,r);return s.hash="",t.forEach(e=>s.searchParams.delete(e)),`fetch-cache:${function(e){let t,o,n=0;for(t=0;t<e.length;t++)o=e.charCodeAt(t),n=(n<<5)-n+o,n|=0;return(n>>>0).toString(16).padStart(8,"0")}(s.pathname+(s.search?s.search:""))}:${(null==(n=window.Shopify)?void 0:n.country)||"US"}`})(e,o),i=Date.now();if("GET"===(t.method??"GET").toUpperCase())try{const e=localStorage.getItem(s);if(e){const{timestamp:t,body:o,headers:r}=JSON.parse(e);if(i-t<n)return new Response(o,{headers:r});localStorage.removeItem(s)}}catch(r){console.warn("Error reading from fetch cache",r)}const a=await fetch(e,t),c=a.clone();try{const e=await c.text(),t={};c.headers.forEach((e,o)=>{t[o]=e}),localStorage.setItem(s,JSON.stringify({timestamp:i,body:e,headers:t}))}catch{}return a}catch(r){return console.error("Error in fetchWithCache",r),fetch(e,t)}}(e,t,null==s?void 0:s.persistCacheParamsToIgnore,null==s?void 0:s.persistCacheExpiryMs):fetch,y=`${e.baseUrl}${o}${h?"?"+h.toString():""}`;if(f){const e=t.get(y);if(e)return e}const w=await p(y,{signal:e.signal,method:u,...r,headers:d,...(null==r?void 0:r.body)&&(null==s?void 0:s.rawBody)&&{body:r.body},...(null==r?void 0:r.body)&&!(null==s?void 0:s.rawBody)&&{body:JSON.stringify(r.body)}});if(!w.ok||w.status>=400)throw await n(w,s);if(null==(c=null==(a=null==r?void 0:r.headers)?void 0:a["Content-Type"])?void 0:c.includes("text/")){const e=await w.text();return f&&t.set(y,e),e}const g=await n(w,s);return f&&t.set(y,g),g}catch(h){const e=String(h).toLowerCase(),t=h instanceof Error?h.message:e,o=h instanceof Error&&h.name||"undefined"!=typeof DOMException&&h instanceof DOMException&&h.name||"";if("undefined"!=typeof DOMException&&h instanceof DOMException&&"AbortError"===h.name||h instanceof Error&&"AbortError"===h.name||(null==t?void 0:t.toLowerCase().includes("aborted"))||e.includes("aborted")||"AbortError"===o)throw h;throw console.error("Error in createApiClient",h),h}finally{null==(l=null==e?void 0:e.onRequestEnd)||l.call(e)}},i=(n,r)=>{const i=new h(r);return n.withQueue&&n.queueKey&&(t[n.queueKey]||(t[n.queueKey]=[])),(r,a,c)=>{if("FLUSH_CACHE"===r)return i.clear(),Promise.resolve({});if(n.withQueue&&n.queueKey){const l=e();return t[n.queueKey].push({requestArguments:{endpoint:r,init:a,options:c},deferred:l}),(async(e,n,r)=>{if(o[r])return;o[r]=!0;const i=t[r];for(;i.length>0;){const{requestArguments:t,deferred:o}=i.shift();try{const r=await s(e,n,t.endpoint,t.init,t.options);o.resolve(r)}catch(a){o.reject(a)}}o[r]=!1})(n,i,n.queueKey),l.promise}return s(n,i,r,a,c)}},a=e=>class extends e{constructor(){super(...arguments),this.$api=new c(this)}};class c{constructor(e){this.abortController=new AbortController,this.fetchClient=i({baseUrl:"",signal:this.abortController.signal}),this.storefrontClient=i({baseUrl:`${"/"===window.Shopify.routes.root?"":window.Shopify.routes.root}/api/2026-01/graphql.json`,headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":`${window.__STOREFRONT_ACCESS_TOKEN__}`},defaultMethod:"POST",signal:this.abortController.signal}),this.shopifyClient=i({baseUrl:`${window.Shopify.routes.root}`,headers:{"Content-Type":"application/json"},signal:this.abortController.signal}),(this.host=e).addController(this)}hostDisconnected(){this.abortController.abort()}get client(){return{fetchClient:this.fetchClient,storefront:e=>this.storefrontClient("",e),shopify:this.shopifyClient}}}const l=new Map;class h{constructor(e){if(this.cache=new Map,this.get=e=>this.cache.get(e),this.set=(e,t)=>this.cache.set(e,t),this.clear=()=>this.cache.clear(),this.cacheKey=e,this.cacheKey&&(l.has(this.cacheKey)||l.set(this.cacheKey,this)),this.cacheKey&&l.has(this.cacheKey)){const e=l.get(this.cacheKey);e&&(this.cache=e.cache)}}}export{a as W,i as c,r as f};

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.