PageSourceSearch

http://pricklypearenergy.com/js/standard-actions.js

js pricklypearenergy.com collected 2026-09-27 01:57:10 UTC 12,366 bytes, 2 lines download raw bytes

1// version: 948d7e184fee6871cd19ed1aaf82584a483aa44c
2(function(){let e=`gid://shopify/`,t=`?cart=`,n=/^gid:\/\/shopify\/CartLine\/[-A-Za-z0-9\?=]+$/;function r(t,n){return`${e}${t}/${n}`}function i(t,n){let i=String(n);return i.startsWith(e)?i:r(t,i)}function a(){if(typeof document>`u`)return null;let e=document.cookie.match(/(?:^|;\s*)cart=([^;]*)/);return e&&decodeURIComponent(e[1])||null}let o=e=>e?.replace(r(`Cart`,``),``)??``;function s(e){let t=e??a();return t?i(`Cart`,t):null}let c=(e,t)=>l(e)?u(e,t):String(e),l=e=>n.test(String(e));function u(e,n){let r=String(e);if(!l(r))throw Error(`Expected CartLine GID, received "${r}"`,{cause:{id:e}});if(!r.includes(t)){let e=o(String(n??a()??``)).split(`?`,1)[0];e&&(r=r+t+e)}return r}var d=class extends Error{constructor(e,t){super(e,{cause:t}),this.name=`CartActionError`}},f=class extends Error{constructor(e){super(e),this.name=`ValidationError`}};let p=`update`,m=`remove`;function h(e){let t=window.Shopify;return{...e,c:t?.country??`US`,l:t?.locale?.replace(/-/g,`_`).toUpperCase()||`EN`}}let g=`fragment f on Cart{id totalQuantity cost{totalAmount{amount currencyCode}} lines(first:250){nodes{id quantity cost{totalAmount{amount currencyCode}}}} discountCodes{applicable code}}`,_=`$c:CountryCode!,$l:LanguageCode!`,v=`@inContext(country:$c,language:$l)`,ee=`query($i:ID!,${_})${v}{cart(id:$i){...f}}${g}`,y=`cart{...f}userErrors{code field message}warnings{code message target}`,te=`mutation($i:CartInput!,${_})${v}{cartCreate(input:$i){${y}}}${g}`;async function b(e,t){let n=(await E(ee,h({i:e}),t)).data.cart;return n?w(n):null}function x(e){let t={add:[],[p]:[],[m]:[]};for(let n of e){let e=n.id?n.quantity===0?m:n.quantity>0?p:null:`add`;e&&t[e].push(n)}return t}function S(e,t){return!e||!t?.length?e:e.map(e=>{let n=e.field;if(!n)return e;let r=n.findIndex((e,t)=>(e===`lines`||e===`lineIds`)&&/^\d+$/.test(n[t+1]??``));if(r===-1)return e;let i=t[Number(n[r+1])]?.index;if(i===void 0)return e;let a=[...n];return a[r+1]=String(i),{...e,field:a}})}function C(e,t){let n=[],r={i:e},i=[`$i:ID!`,_],a=(e,t,a,o,s)=>{i.push(`$${e}:${o}`),r[e]=s,n.push(`${e}:${t}(cartId:$i,${a}:$${e}){${y}}`)};if(t.lines?.length){let{add:e,update:n,remove:r}=x(t.lines),i=r.map(e=>e.id);e.length&&a(`add`,`cartLinesAdd`,`lines`,`[CartLineInput!]!`,e),n.length&&a(p,`cartLinesUpdate`,`lines`,`[CartLineUpdateInput!]!`,n),i.length&&a(m,`cartLinesRemove`,`lineIds`,`[ID!]!`,i)}return t.note!==void 0&&a(`note`,`cartNoteUpdate`,`note`,`String!`,t.note),t.discountCodes!==void 0&&a(`discount`,`cartDiscountCodesUpdate`,`discountCodes`,`[String!]!`,t.discountCodes),n.length?{query:`mutation(${i.join(`,`)})${v}{${n.join(``)}}${g}`,variables:h(r)}:null}function ne(e,t){let n={cart:null};for(let[r,{cart:i,warnings:a,userErrors:o}]of Object.entries(e.data)){i&&(n.cart=w(i));let e=S(o,t?.[r]);e&&(n.userErrors??=[]).push(...e),a&&(n.warnings??=[]).push(...a)}return n}function w(e){return{id:e.id,totalQuantity:e.totalQuantity,cost:e.cost,lines:e.lines.nodes,discountCodes:e.discountCodes}}function T(e){if(e.cart)return{cart:w(e.cart),...e.userErrors?.length?{userErrors:e.userErrors}:{},...e.warnings?.length?{warnings:e.warnings}:{}};throw e.userErrors?.length?new d(e.userErrors.map(e=>e.message).join(`, `),{userErrors:e.userErrors,warnings:e.warnings}):Error(`cartCreate: no cart`)}async function E(e,t,n){let r=await fetch(`/api/2026-01/graphql.json`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({query:e,variables:t}),signal:n});if(!r.ok)throw Error(`SFAPI ${r.status} ${r.statusText}`,{cause:r});let i=await r.json();if(!i.data||i.errors?.length)throw Error(i.errors?.map(e=>e.message).join(`, `)||`No SFAPI data`,{cause:i});return i}let D=`AbortError`,O=()=>new DOMException(`The operation was aborted.`,D),k=e=>{if(e?.aborted)throw O()};function A(e,t){return t?(k(t),new Promise((n,r)=>{let i=()=>r(O());t.addEventListener(`abort`,i,{once:!0}),e.finally(()=>t.removeEventListener(`abort`,i)).then(n,r)})):e}function j(e){let t=o(e);document.cookie=`cart=${encodeURIComponent(t)}; path=/; SameSite=Lax`}let M=(e,t)=>E(te,h({i:e}),t).then(e=>e.data.cartCreate);async function N(e,t){if(k(t),P)return{cartId:(await A(P,t)).id};let n=M(e).then(e=>{let t=T(e);return j(t.cart.id),t});return P=n.then(e=>e.cart).finally(()=>{P=null}),P.catch(()=>{}),A(n,t)}let P=null;async function F(e){let t=s();if(t)return t;let n=await N({},e);return`cartId`in n?n.cartId:n.cart.id}function I(e){if(!(e instanceof Error)||e.name===D||e.name===`ValidationError`)return null;let t=e.cause?.userErrors?.[0];return t?.message?{code:t.code??`SERVICE_UNAVAILABLE`,message:t.message}:{code:`SERVICE_UNAVAILABLE`,message:e.message}}let re=()=>{let e=new Map,t=t=>{let n=e.get(t);if(n)return n;
2let r=b(t).finally(()=>e.delete(t));return e.set(t,r),r.catch(()=>{}),r};return async(e,n)=>{let r=s(e?.cartId);return r?(k(n?.signal),{cart:await A(t(r),n?.signal)}):{cart:null}}},ie=()=>re(),L=()=>import(`./standard-events.js`),R=(e,t)=>{(t??document).dispatchEvent(e)},z=e=>{let t=null;return Object.assign((...n)=>e(t,...n),{isDefault:()=>t===null,configure(e){return t||!e||typeof e!=`object`?!1:(t=e,!0)}})},B=[`cart-drawer`,`cart-items`,`cart-drawer-items`,`cart-notification`],V=()=>{let e=document.querySelector(`cart-icon`),t=document.querySelector(`cart-items-component`);return typeof e?.renderCartBubble==`function`&&typeof t?.updateQuantity==`function`},H=()=>B.some(e=>typeof window.customElements?.get(e)?.prototype?.getSectionsToRender==`function`),U=e=>{try{return document.dispatchEvent(new CustomEvent(`cart:update`,{bubbles:!0,detail:{resource:null,sourceId:`external`,data:{source:`external`,itemCount:e}}})),!0}catch{return!1}},W=async()=>{let e=window,t=typeof e.publish==`function`?new Set([`cart-drawer:cart-drawer`,`cart-drawer-items:CartDrawer`,`cart-items:main-cart-items`]):new Set,n=new Map;for(let e of document.querySelectorAll(B.join(`,`))){let r;try{r=e.getSectionsToRender?.()}catch{continue}let i=e.tagName.toLowerCase();for(let e of r??[]){if(t.has(`${i}:${e.id}`))continue;let r=e.section??e.id;if(!r||n.has(r))continue;let a=e.section?document.getElementById(e.id):document;if(!a)continue;let o=e.selector?a.querySelector(e.selector)??(e.section?a:null):document.getElementById(e.id);o&&n.set(r,{mount:o,extractSelector:e.selector||`.shopify-section`})}}if(n.size){let t=`${e.routes?.cart_url||`/cart`}.js?sections=${[...n.keys()].join(`,`)}`,r=await fetch(t,{headers:{Accept:`application/json`}}).then(e=>e.ok?e.json():null).catch(()=>null);for(let[e,{mount:t,extractSelector:i}]of n){let n=r?.sections?.[e];if(!n)continue;let a=new DOMParser().parseFromString(n,`text/html`).querySelector(i);a&&t.replaceChildren(...Array.from(a.childNodes))}}try{await e.publish?.(e.PUB_SUB_EVENTS?.cartUpdate??`cart-update`,{source:`external-refresh`})}catch{}return!0},G=async e=>{V()&&U(e)||H()&&await W()||window.location.reload()};async function K(e,t){k(t);let n=await fetch(`/cart/change.js`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:e.id,quantity:e.quantity,...e.sellingPlanId&&{selling_plan:String(e.sellingPlanId).replace(/^gid:\/\/shopify\/SellingPlan\//,``)},...e.attributes?.length&&{properties:Object.fromEntries(e.attributes.map(({key:e,value:t})=>[e,t]))}}),signal:t}),r=await n.json().catch(()=>null);if(!n.ok||!r){let e=r?.description||r?.message;if(e&&typeof e==`string`)return e;throw Error(`AJAX cart change `+(n.ok?`returned invalid JSON`:`${n.status} ${n.statusText}`),{cause:r??n})}return null}let q=({id:e,merchandiseId:t,quantity:n})=>!!(e?.trim()&&n>=0||t&&n>0),J=e=>{let t=``,n=(e.lines?.filter(e=>!!e.id?.trim())??[]).some(e=>!l(e.id));if(typeof e.note==`string`||e.discountCodes||e.lines?.length?e.cartId!==void 0&&n?t=`updateCart cannot target an explicit cartId when lines contain AJAX-style ids; omit cartId or pass CartLine GIDs.`:e.lines?.some(e=>!q(e))&&(t=`updateCart lines must add, update, or remove at least one item.`):t=`updateCart requires at least one of: lines, note, or discountCodes.`,t)throw new f(t)},Y=async(e,{input:t,signal:n,sfapiLines:r,syncCartCookie:i})=>{let a=C(e,t),o=ne(await E(a.query,a.variables,n),r&&x(r)),s=o.cart??await b(e,n);if(!s)throw new d(`Cart mutation did not return a cart`,{cartId:e,userErrors:o.userErrors,warnings:o.warnings});return i&&j(s.id),{...o,cart:s}},X=async e=>{let{input:t,signal:n,sfapiLines:r}=e,i=await N(t,n).catch(async e=>{if(e instanceof Error&&e.cause?.userErrors?.length)return{cartId:await F(n)};throw e});return`cartId`in i?Y(i.cartId,e):(i.userErrors&&=S(i.userErrors,r),i)},Z=async e=>{let t=s();return t?b(t,e):null},ae=async(e,t)=>{let n=await Promise.allSettled(e.map(e=>K({id:e.id,quantity:e.quantity,...e.sellingPlanId&&{sellingPlanId:e.sellingPlanId},...e.attributes&&{attributes:e.attributes}},t))),r=[],i=null;for(let[t,a]of n.entries()){if(a.status===`rejected`){i??=a.reason;continue}a.value&&r.push({code:`AJAX_CART_CHANGE_ERROR`,field:[`lines`,String(e[t].index)],message:a.value})}if(i)throw i;return r},oe=async(e,t,n)=>{let r=t?.signal,a=e.lines??[],o=[],c=[];for(let[e,t]of a.entries()){let n={...t,index:e};t.id&&!l(t.id)?o.push(n):c.push(n)}let f=c.length>0||e.note!==void 0||e.discountCodes!==void 0,p=await ae(o,r);if(!f){let e=await Z(r);if(!e)throw new d(`Cart read did not return a cart after AJAX updates`,{cartId:n,userErrors:p,warnings:void 0});return{cart:e,...p.length?{userErrors:p}:{}}}o.length&&(n=s()??n);let m={lines:c.map(({index:e,...t})=>
2({...t,...t.id&&{id:u(t.id,n)},...t.merchandiseId&&{merchandiseId:i(`ProductVariant`,t.merchandiseId)},...t.sellingPlanId&&{sellingPlanId:i(`SellingPlan`,t.sellingPlanId)}})),note:e.note,discountCodes:e.discountCodes};try{let t={input:m,signal:r,sfapiLines:c,syncCartCookie:e.cartId===void 0},i=n?await Y(n,t):await X(t);return{...i,...p.length||i.userErrors?.length?{userErrors:[...p,...i.userErrors??[]]}:{}}}catch(e){if(!o.length||e instanceof DOMException&&e.name===`AbortError`)throw e;let t=await Z(r),n=I(e);if(!t||!n)throw e;return{cart:t,userErrors:[...p,{code:n.code,message:n.message}]}}},se=async(e,t,n,r)=>{let a=await L(),o=n?.event?.detail,s=o?{detail:o}:{},l=n?.event?.context??`standard-action`,u=[],{add:d,update:f,remove:p}=x(t.lines??[]),m=(t,n,r)=>{R(n,e?.eventTarget?.(r)),u.push(t)};if(d.length||f.length||p.length){let e=e=>{let{promise:t,...n}=a.CartLinesUpdateEvent.createPromise();m(n,new a.CartLinesUpdateEvent({...e,promise:t,...s}),{type:a.CartLinesUpdateEvent.eventName,action:e.action})};d.length&&e({action:`add`,context:l,lines:d.map(e=>({merchandiseId:i(`ProductVariant`,e.merchandiseId),quantity:e.quantity}))});for(let[t,n]of[[`update`,f],[`remove`,p]])n.length&&e({action:t,context:l,lines:n.map(e=>({id:c(e.id,r),quantity:e.quantity}))})}let h=t.note;if(h!==void 0){let{promise:e,...t}=a.CartNoteUpdateEvent.createPromise();m(t,new a.CartNoteUpdateEvent({context:l,note:h,promise:e,...s}),{type:a.CartNoteUpdateEvent.eventName})}let g=t.discountCodes;if(g!==void 0){let{promise:e,...t}=a.CartDiscountUpdateEvent.createPromise();m(t,new a.CartDiscountUpdateEvent({discountCodes:g.map(e=>({code:e})),promise:e,...s}),{type:a.CartDiscountUpdateEvent.eventName})}return u},ce=({cart:e,userErrors:t,warnings:n,detail:r})=>({cart:e,...t!==void 0&&{userErrors:t},...n!==void 0&&{warnings:n},...r!==void 0&&{detail:r}}),le=()=>{let e=0,t=!1,n=null,r,i=()=>{!t||n||e>0||(n=setTimeout(()=>{n=null,!(!t||e>0)&&(t=!1,G(r))},0))};return z(async(n,a,o,...c)=>{J(a);let l=!n,u=s(a.cartId),d=oe.bind(null,a,o,u);l&&(e+=1);let f=await se(n,a,o,u);try{let e=ce(await(n?.handler?n.handler(d,a,o,...c):d()));for(let t of f)t.resolve(e);return l&&(t=!0,r=e.cart?.totalQuantity),e}catch(e){for(let t of f)t.reject(e);let t=I(e);if(t){let e=await L(),r=o?.event?.detail;R(new e.CartErrorEvent({error:t.message,code:t.code,...r&&{detail:r}}),n?.eventTarget?.({type:e.CartErrorEvent.eventName}))}throw e}finally{l&&(--e,i())}})},Q=e=>{let t=document.querySelector(e);if(typeof t?.open!=`function`)return!1;try{return t.open(),!0}catch{return!1}},$=async()=>{Q(`cart-drawer-component`)||Q(`cart-drawer`)||(window.location.href=`/cart`)},ue=Object.freeze({getCart:ie(),updateCart:le(),openCart:z((e,...t)=>e?.handler?e.handler($,...t):$())});Object.defineProperty(window.Shopify??={},`actions`,{value:ue,writable:!1,configurable:!1,enumerable:!0})})();

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.