PageSourceSearch

https://www.francisandgaye.co.uk/cdn/shop/t/4/assets/product-form.min.js?v=66468117446728924431786003531

js francisandgaye.co.uk collected 2026-10-04 17:13:04 UTC 9,616 bytes, 1 lines download raw bytes

1var Z=Object.defineProperty;var Q=e=>{throw TypeError(e)};var tt=(e,t,r)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var K=(e,t,r)=>tt(e,typeof t!="symbol"?t+"":t,r),G=(e,t,r)=>t.has(e)||Q("Cannot "+r);var b=(e,t,r)=>(G(e,t,"read from private field"),r?r.call(e):t.get(e)),B=(e,t,r)=>t.has(e)?Q("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r);var u=(e,t,r)=>(G(e,t,"access private method"),r);import{C as et}from"./component-base.min.js";import{u as nt}from"./utilities.min.js";import"./add-to-cart.min.js";import"./variant-selector.min.js";import"./quantity-selector.min.js";import"./product-media.min.js";import{T as L}from"./events-bus.min.js";import{E as T}from"./event-constants.min.js";import"./variant-media-helpers.min.js";function rt(e){return!!(e!=null&&e.compare_at_price&&e.compare_at_price>e.price)}let I=null;const k=document.documentElement.dataset.elsklipHideByTag==="true";function it(e,t){L.dispatchEvent(new CustomEvent(T.variantInventory,{detail:{quantity:e.inventory_quantity||0,continueSelling:e.inventory_policy==="continue",inventoryManaged:e.inventory_management==="shopify",max:t}}))}function A(e){if(e&&(I=e),!I&&!k)return;const t=I?rt(I):!1,r=k||t;document.documentElement.classList.toggle("elsklip-coupon-hidden",r),document.querySelectorAll(".elsklip-coupon-box").forEach(d=>{d.toggleAttribute("data-hidden-for-tag",k),d.toggleAttribute("data-hidden-for-sale",t)})}function j(e){var r,d;const t=document.getElementById("product-json");if(!t||!e)return null;try{const s=JSON.parse(t.textContent);return((r=s.variants)==null?void 0:r.find(a=>a.id==e))??((d=s.variants)==null?void 0:d[0])??null}catch{return null}}function at(e){var r;const t=[];for(const d of e.childNodes){if(d.nodeType!==Node.COMMENT_NODE)continue;const s=((r=d.textContent)==null?void 0:r.trim())??"";if(s.startsWith("variant-spec-config:"))try{const a=JSON.parse(s.slice(20));a!=null&&a.namespace&&(a!=null&&a.key)&&(a==null?void 0:a.label)!=null&&t.push({...a,comment:d})}catch{}}return t}function ot(e,t){return document.querySelector(`[data-variant-spec-row][data-metafield-namespace="${e}"][data-metafield-key="${t}"]`)}function st(e,t,r,d){const s=document.createElement("tr");s.dataset.variantSpecRow="",s.dataset.metafieldNamespace=t,s.dataset.metafieldKey=r;const a=document.createElement("td");a.textContent=`${e}:`;const E=document.createElement("td");return E.dataset.variantSpecValue="",E.textContent=d,s.append(a,E),s}function ct(e){if(!(e!=null&&e.id))return;const t=j(e.id);t!=null&&t.variant_metafields&&document.querySelectorAll(".shopify-block-specifications-accordion tbody").forEach(r=>{var a,E;const d=at(r),s=new Set;for(const{label:p,namespace:l,key:g,comment:P}of d){s.add(`${l}:${g}`);const w=(E=(a=t.variant_metafields)==null?void 0:a[l])==null?void 0:E[g],_=w!=null&&w!==""?String(w):"";let y=ot(l,g);if(_)if(!y)y=st(p,l,g,_),r.insertBefore(y,P.nextSibling);else{const S=y.querySelector("[data-variant-spec-value]");S&&(S.textContent=_)}else y&&y.remove()}r.querySelectorAll("[data-variant-spec-row]").forEach(p=>{var y,S;const l=p.dataset.metafieldNamespace,g=p.dataset.metafieldKey;if(!l||!g||s.has(`${l}:${g}`))return;const P=(S=(y=t.variant_metafields)==null?void 0:y[l])==null?void 0:S[g],w=P!=null&&P!==""?String(P):"",_=p.querySelector("[data-variant-spec-value]");w?_&&(_.textContent=w):p.remove()})})}function dt(e){var d,s;if(!(e!=null&&e.id))return;const t=j(e.id),r=((s=(d=t==null?void 0:t.variant_metafields)==null?void 0:d.custom)==null?void 0:s.model)??"";document.querySelectorAll('input[name="properties[Stock No]"]').forEach(a=>{a.value=r})}const ut=new MutationObserver(()=>{(I||k)&&A(I)});ut.observe(document.documentElement,{childList:!0,subtree:!0});k&&A(null);L.addEventListener(T.variantChange,e=>{var r;const t=(r=e.detail)==null?void 0:r.variant;t&&(ct(t),dt(t))});async function lt(){var t,H,F,U,a,W,p,l,z,X,q,O;class e extends et{constructor(){super(...arguments);B(this,t);K(this,"requiredRefs",["variantId","liveRegion","errorMessage","price","comparePrice","addToCartButton","addToCartButtonContainer"]);
1B(this,a,async i=>{var m,C,h,x,M,$,N,D,V,J;i.preventDefault();const n=this.querySelector("form");if(!n)return;const o=parseInt(this.refs.variantId.value),v=parseInt(((m=this.refs.quantityInput)==null?void 0:m.value)||1);if(!u(this,t,W).call(this,o,v))return;const c=new FormData(n);c.set("quantity",v);const f=c.get("properties[Engraving]");(f===""||f===null)&&c.delete("properties[Engraving]"),(C=this.refs.addToCartButton.querySelector(".button-spinner"))==null||C.classList.remove("hidden"),this.refs.addToCartButton.disabled=!0,(x=(h=this.refs.addToCartButtonContainer)==null?void 0:h.setLoading)==null||x.call(h);try{const R=await(await fetch("/cart/add.js",{method:"POST",headers:{Accept:"application/json"},body:c})).json();if(R.status&&R.status!==200){u(this,t,q).call(this,R.message||"Error adding to cart"),($=(M=this.refs.addToCartButtonContainer)==null?void 0:M.enable)==null||$.call(M);return}(D=(N=this.refs.addToCartButtonContainer)==null?void 0:N.setSuccess)==null||D.call(N),u(this,t,q).call(this,"Added to cart"),setTimeout(async()=>{await u(this,t,F).call(this),setTimeout(()=>{L.dispatchEvent(new Event(T.cartUpdated)),L.dispatchEvent(new Event(T.cartItemAdded)),this.refs.quantityInput&&(this.refs.quantityInput.value=1,this.refs.quantityInput.dispatchEvent(new Event("input",{bubbles:!0})))},100)},500)}catch{u(this,t,q).call(this,"Add to cart failed"),(J=(V=this.refs.addToCartButtonContainer)==null?void 0:V.enable)==null||J.call(V)}});B(this,p,i=>{var m,C,h,x;const n=i.detail.variant;if(!n)return;this.refs.variantId.value=n.id,this.currentInventory=n.inventory_quantity;const o=n.inventory_policy==="continue",v=n.inventory_management;let c;o||v!=="shopify"?c=1/0:c=n.inventory_quantity||0,!n.available&&!o?(C=(m=this.refs.addToCartButtonContainer)==null?void 0:m.disable)==null||C.call(m):(x=(h=this.refs.addToCartButtonContainer)==null?void 0:h.enable)==null||x.call(h),this.refs.price&&(this.refs.price.textContent=u(this,t,O).call(this,n.price)),this.refs.comparePrice&&(n.compare_at_price&&n.compare_at_price>n.price?(this.refs.comparePrice.textContent=u(this,t,O).call(this,n.compare_at_price),this.refs.comparePrice.classList.remove("hidden")):(this.refs.comparePrice.classList.add("hidden"),this.refs.comparePrice.textContent="")),A(n),u(this,t,z).call(this,n),it(n,c);const f=new URL(window.location.href);f.searchParams.set("variant",n.id),window.history.replaceState({},"",f)});B(this,l,i=>{b(this,p).call(this,i)})}connectedCallback(){var o;super.connectedCallback(),this.validateRefs();const i=this.querySelector('quantity-selector-component input[name="quantity"]');i&&(this.refs.quantityInput=i),this.formEl=this.querySelector("form"),this.formEl&&this.formEl.addEventListener("submit",b(this,a),{capture:!0}),L.addEventListener(T.variantChange,b(this,l)),u(this,t,H).call(this);const n=j((o=this.refs.variantId)==null?void 0:o.value);n&&A(n),u(this,t,U).call(this)}disconnectedCallback(){super.disconnectedCallback(),this.formEl&&this.formEl.removeEventListener("submit",b(this,a)),L.removeEventListener(T.variantChange,b(this,l))}}t=new WeakSet,H=function(){if(!this.refs.comparePrice)return;this.refs.comparePrice.textContent.trim()?this.refs.comparePrice.classList.remove("hidden"):this.refs.comparePrice.classList.add("hidden")},F=async function(){try{const i=await fetch("/cart.js");if(!i.ok)throw new Error("Failed to fetch cart");const n=await i.json();window.__cart=n,nt()}catch(i){console.error("[ProductForm] Error fetching cart:",i)}},U=async function(){(!window.__cart||!window.__cart.items)&&await u(this,t,F).call(this)},a=new WeakMap,W=function(i,n){try{const o=document.getElementById("product-json");if(!o)return!0;const c=JSON.parse(o.textContent).variants.find(h=>h.id===i);if(!c||c.inventory_management!=="shopify"||c.inventory_policy!=="deny")return!0;const f=c.inventory_quantity||0,m=u(this,t,X).call(this,i),C=f-m;return C<=0?(u(this,t,q).call(this,"Maximum quantity already in cart"),!1):n>C?(u(this,t,q).call(this,`Only ${C} available (${m} already in cart)`),!1):!0}catch(o){return console.error("[ProductForm] Error checking cart quantity:",o),!0}},p=new WeakMap,l=new WeakMap,z=function(i){var o;let n=i.options;if(!(n!=null&&n.length)&&i.id){const v=document.getElementById("product-json");if(v)try{const f=(o=JSON.parse(v.textContent).variants)==null?void 0:o.find(m=>m.id==i.id);n=f==null?void 0:f.options}catch{}}
1n!=null&&n.length&&n.forEach((v,c)=>{this.querySelectorAll(`[data-variant-option-selected-value][data-option-index="${c}"]`).forEach(f=>{f.textContent=v??""})})},X=function(i){if(!window.__cart||!window.__cart.items)return 0;const n=window.__cart.items.find(o=>o.variant_id==i);return n?n.quantity:0},q=function(i){if(this.refs.liveRegion&&(this.refs.liveRegion.textContent=i),!this.refs.errorMessage)return;i.toLowerCase().includes("maximum")||i.toLowerCase().includes("only")||i.toLowerCase().includes("error")||i.toLowerCase().includes("failed")?(this.refs.errorMessage.textContent=i,this.refs.errorMessage.classList.remove("hidden"),setTimeout(()=>{this.refs.errorMessage.classList.add("hidden"),this.refs.errorMessage.textContent=""},5e3)):(this.refs.errorMessage.classList.add("hidden"),this.refs.errorMessage.textContent="")},O=function(i){const n=window.shopCurrency||"GBP",o=window.shopLocale||"en-GB";return new Intl.NumberFormat(o,{style:"currency",currency:n}).format(i/100)},customElements.get("product-form-component")||customElements.define("product-form-component",e)}lt();

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.