PageSourceSearch

https://thewholetruthfoods.com/_next/static/chunks/5008-77503ada25…?dpl=dpl_5QyUw2kLKfLV9h5ABuCjLWvJuLeZ

js thewholetruthfoods.com collected 2026-10-03 20:36:04 UTC 18,660 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5008],{4102:(t,e,r)=>{r.d(e,{$g:()=>a,vB:()=>i,zs:()=>n});let a=t=>`₹${t?.toLocaleString("en-IN")}`,i=t=>!!(t&&"boolean"==typeof t.manage_inventory&&!t.manage_inventory),n=t=>t?t.replace(/\s*[-/]\s*Default\s*Option/gi,"").replace(/\s*[-/]\s*Default\s*Value/gi,"").replace(/\s*[-/]\s*Default\s*variant/gi,"").replace(/\s*[-/]\s*Default$/gi,"").replace(/^Default\s*Option$/gi,"").replace(/^Default\s*Value$/gi,"").replace(/^Default\s*variant$/gi,"").replace(/^Default$/gi,"").trim():""},16994:(t,e,r)=>{r.r(e),r.d(e,{default:()=>u});var a=r(95155),i=r(7050),n=r(6874),o=r.n(n),d=r(12115);let l={primary:"",outline:"",danger:"",success:"",info:"",ghost:"",text:"",none:""},c=(0,d.memo)((0,d.forwardRef)((t,e)=>{let{href:r,children:n,className:c="",variant:u="none",fullWidth:s,rounded:p,disabled:f,onClick:m,...v}=t,_=(0,d.useMemo)(()=>(0,i.cn)("flex items-center justify-center transition-all duration-200",l[u],s&&"w-full",p&&"rounded-full",f&&"pointer-events-none opacity-50",c),[u,s,p,f,c]),y=t=>{if(m&&m(t),r&&"string"==typeof r&&r.includes("#")&&!r.startsWith("http")){t.preventDefault();let e=r.split("#")[1],a=document.getElementById(e);if(a){let t=a.getBoundingClientRect().top+window.pageYOffset-100;window.scrollTo({top:t,behavior:"smooth"})}}};return f?(0,a.jsx)("span",{className:_,children:n}):r?(0,a.jsx)(o(),{href:r||"#",className:_,ref:e,prefetch:!1,onClick:y,...v,children:n}):(0,a.jsx)("div",{className:_,onClick:y,...Object.fromEntries(Object.entries(v).filter(t=>{let[e]=t;return!["as"].includes(e)})),children:n})}));c.displayName="Alink";let u=c},24883:(t,e,r)=>{r.d(e,{v:()=>i});var a=r(34477);let i=(0,a.createServerReference)("7ffa7162df95b5db7b0c880434e4a9445113fc40ab",a.callServer,void 0,a.findSourceMapURL,"toggleNotifyMeRequest")},57804:(t,e,r)=>{r.d(e,{P:()=>a});let a=(t,e,r)=>{let a=`/products/${encodeURIComponent(t)}`,i=new URLSearchParams;if(e&&i.set("sku_id",encodeURIComponent(e)),r)for(let[t,e]of Object.entries(r))i.set(t,String(e));let n=i.toString();return n?`${a}?${n}`:a}},76842:(t,e,r)=>{r.d(e,{Ux:()=>l,XZ:()=>p,it:()=>s,lo:()=>c,su:()=>u});var a=r(4102),i=r(79616),n=r(41919),o=r(37805);let d=t=>!!(t&&"boolean"==typeof t.manage_inventory&&!t.manage_inventory),l=(t,e,r)=>"COMBO"===t&&(e?.variants?e.variants.some(t=>!0===t.manage_inventory):!!r&&r.length>0&&r.some(t=>!0===t.manage_inventory)),c=(t,e)=>{if(!Array.isArray(t)||0===t.length)return console.warn("getBestAvailableVariant: Invalid or empty variants array"),null;try{let r=[...t].sort((t,e)=>{if(!t||!e)return 0;let r="number"==typeof t.variant_rank?t.variant_rank:0,a="number"==typeof e.variant_rank?e.variant_rank:0;return r-a}),i=e&&r.find(t=>t?.id===e)||null;if(i&&(0,a.vB)(i))return i;let n=r.find(a.vB);if(n)return n;return i}catch(e){return console.error("getBestAvailableVariant: Error processing variants:",e),t[0]||null}},u=t=>{if(!t||!Array.isArray(t.variants)||0===t.variants.length)return[];try{let e=t.strapi?.show_video_on_plp===!0,r=[...t.variants].sort((t,e)=>{if(!t||!e)return 0;let r="number"==typeof t.variant_rank?t.variant_rank:0,a="number"==typeof e.variant_rank?e.variant_rank:0;return r-a});(0,i.VE)().catch(t=>{console.error("createInternalVariants: Error during expired notify me cleanup:",t)});try{(0,i.st)(r)}catch(t){console.error("createInternalVariants: Error during notify me cleanup:",t)}return r.map(r=>({id:r.id,title:r.title||"",size:r.cms_variant?.product_weight_info||t.strapi?.variants?.find(t=>t.systemId===r.id)?.product_weight_info||"",price:(0,n.MA)(r),originalPrice:r.extended_product_variants?.compare_at_price||void 0,gstOldPrice:r.extended_product_variants?.old_mrp_price||void 0,image:(0,o.Cg)(r.variant_image,t.thumbnail,t.images)||"",listingMedia:e?(0,o.Mn)(r.variant_image,t.images):void 0,images:r.variant_image||[],sdd:r.extended_product_variants?.sdd||!1,showAbsoluteDiscount:r.extended_product_variants?.show_absolute_discount||!1,manage_inventory:r.manage_inventory||!1,optionValue:r.options?.[0]?.value}))}catch(t){return console.error("createInternalVariants: Error creating internal variants:",t),[]}},s=t=>{if(!t||!Array.isArray(t.variants)||0===t.variants.length)return null;try{let e=u(t);if(!Array.isArray(e)||0===e.length)return null;let r=t.extended_product?.default_variant_id,a=r&&e.find(t=>
1t.id===r)||null;if(a&&d(a))return a;let i=e.find(d);if(i)return i;return a||e[0]||null}catch(e){console.error("getBestAvailableInternalVariant: Error getting best available variant:",e);try{return u(t)[0]||null}catch(t){return console.error("getBestAvailableInternalVariant: Fallback also failed:",t),null}}},p=(t,e,r,a)=>{let i=Object.entries(r).filter(t=>{let[e,r]=t;return r>0}).map(t=>{let[e,r]=t;return{variant_id:e,quantity:r}}),n=Object.keys(r).filter(t=>r[t]>0),o=t?.variants?.find(t=>t.id===e);if(!o?.metadata?.bundle_sub_variant_info||!t)return{productToAdd:t,itemQuantities:i};let d=o.metadata.bundle_sub_variant_info?.filter(t=>n.includes(t.variant_id)).map(t=>{let e=a?.variants?.find(e=>e.id===t.variant_id);return{...t,quantity:r[t.variant_id]||t.quantity,price:e?.price?.amount||t.price}}),l={...o,metadata:{...o.metadata,bundle_sub_variant_info:d}};return{productToAdd:{...t,variants:t.variants?.map(t=>t.id===e?l:t)||null},itemQuantities:i}}},79616:(t,e,r)=>{r.d(e,{VE:()=>d,st:()=>l});var a=r(24883),i=r(84559);let n=t=>{try{if("undefined"==typeof localStorage)return null;let e=`notify_${t}`,r=localStorage.getItem(e);if(!r)return null;if("true"===r)return{isNotified:!0};try{let t=JSON.parse(r);return{isNotified:!0===t.isNotified,timestamp:t.timestamp,productId:t.productId}}catch{return{isNotified:"true"===r}}}catch(t){return console.error("getNotifyMeEntry: Error reading notify me entry:",t),null}},o=t=>!!t.timestamp&&Date.now()-t.timestamp>i.sB,d=async()=>{try{if("undefined"==typeof localStorage)return;let t=Object.keys(localStorage).filter(t=>t.startsWith("notify_"));if(0===t.length)return;let e=0,r=[];t.forEach(t=>{try{let i=t.replace("notify_",""),d=n(i);if(d&&d.isNotified&&o(d)){localStorage.removeItem(t),e++;{let t=new CustomEvent("notifyStateChanged",{detail:{variantId:i,isNotified:!1}});window.dispatchEvent(t)}if(d.productId){let t=(0,a.v)(d.productId,i,!1).then(t=>{t.success?console.log(`cleanupExpiredNotifyMeEntries: Successfully unnotified variant ${i} on backend`):console.error(`cleanupExpiredNotifyMeEntries: Failed to unnotify variant ${i} on backend:`,t.error)}).catch(t=>{console.error(`cleanupExpiredNotifyMeEntries: Error calling API for variant ${i}:`,t)});r.push(t)}else console.warn(`cleanupExpiredNotifyMeEntries: No productId found for variant ${i}, skipping backend unnotify`)}}catch(e){console.error("cleanupExpiredNotifyMeEntries: Error processing key:",t,e)}}),r.length>0&&Promise.all(r).catch(t=>{console.error("cleanupExpiredNotifyMeEntries: Error in API cleanup promises:",t)}),e>0&&console.log(`cleanupExpiredNotifyMeEntries: Cleaned up ${e} expired notify me entries`)}catch(t){console.error("cleanupExpiredNotifyMeEntries: Error during cleanup process:",t)}},l=t=>{try{if(!t||0===t.length||"undefined"==typeof localStorage)return;t.forEach(t=>{try{if(t&&t.id){let e=n(t.id),r=e&&e.isNotified;if(!1===t.manage_inventory&&r){let e=`notify_${t.id}`;localStorage.removeItem(e);let r=new CustomEvent("notifyStateChanged",{detail:{variantId:t.id,isNotified:!1}});window.dispatchEvent(r)}}}catch(e){console.error("cleanupNotifyMeEntries: Error processing variant:",t?.id,e)}})}catch(t){console.error("cleanupNotifyMeEntries: Error during cleanup process:",t)}}},80335:(t,e,r)=>{r.d(e,{S:()=>v});var a=r(61475),i=r(31423),n=r(82656),o=r(12115),d=r(26376),l=r(87298),c=r(58129),u=r(82929),s=r(81781),p=r(33541),f=r(13623),m=r(13841);let v=function(){let{showGoToCartButton:t=!0,showSuccessToast:e=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=(0,d.j)(),v=(0,d.G)(t=>t.cart.cart?.id),_=(0,d.G)(t=>t.cart.cart),y=(0,d.G)(t=>t.cart.localCart),g=(0,d.G)(t=>t.cart.localCart?.items),h=(0,d.G)(t=>t.modal.cartModal),b=(0,d.G)(t=>t.auth.user),{systemSettings:E}=(0,a.k)(),{initializeCart:q}=(0,m._)(),[A,k]=(0,o.useState)({loading:!1,success:"",error:""}),w=(0,o.useCallback)(async function(a){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,d=arguments.length>2?arguments[2]:void 0,m=arguments.length>3?arguments[3]:void 0,g=arguments.length>4?arguments[4]:void 0;if(!v||!Array.isArray(_?.items))return void q();if(!a||""===a.trim())return void(0,u.default)({message:"Please select a valid product variant.",type:"error"});if(o<=0)return void(0,u.default)({message:"Quantity must be greater than 0.",type:"error"});if(!m)return void(0,u.default)({message:"Product information is required for optimistic updates.",type:"error"});let A=y||_;if(A){let t=(0,s.vi)(A,m,a,o);if(!t.valid)return void(0,u.default)({message:t.message,type:"info"})}try{k(()=>({loading:!0,success:"",error:""}));let f=y||_;if(!f)throw Error("No cart available for optimistic update");let v=f.items.find(t=>t.variant_id===a),q=f;v&&v.metadata?.source==="cross_selling_cart_product_card"&&(q=(0,s.$E)(f,v.id));let A=(0,s.D5)({product:m,variantId:a,quantity:v&&v.metadata?.source==="cross_selling_cart_product_card"?o+(v.quantity||0):o,itemQuantities:d,source:g}),w=(0,s.Vb)(q,A,g);r((0,l.cH)(w)),k(t=>({...t,loading:!1,success:"Added to cart"})),!h&&e&&(E?.open_cart_drawer_on_actions?r((0,c.qf)("cartModal")):(0,u.default)({message:`${o>1?`${o} items`:"Product"} added to bag`,actionText:t?"Go to cart":void 0,onAction:()=>r((0,c.qf)("cartModal"))}));let I=b?(0,n.SJ)(b):void 0,M=(0,n.Tf)({product:A,quantity:o}),N=(0,p.br)(A.product);(0,i.u4)("add_to_cart",{product:M,user:I,source:g,categoryHandle:N})}catch(e){console.error("Failed to add item to cart:",e);let{message:t}=(0,f.fe)(e,"cart");k(e=>({...e,error:t})),(0,u.default)({message:t,type:"error"})}finally{k(t=>({...t,loading:!1}))}},[r,v,_,y,h,e,E]),I=(0,o.useCallback)(async t=>{if(!v||!Array.isArray(_?.items))return void q();if(!t||""===t.trim())return void(0,u.default)({message:"Unable to identify the item to remove.",type:"error"});try{k(()=>({loading:!0,success:"",error:""}));let a=y||_;if(!a)throw Error("No cart available for optimistic update");let o=(0,s.$E)(a,t);
1if(1===o.items.length){let t=o.items[0];if(t.metadata?.source==="cross_selling_cart_product_card"&&t.product){let e=(0,s.$E)(o,t.id),r=(0,s.D5)({product:t.product,variantId:t.variant_id||"",quantity:t.quantity||1,source:"cart_reward_to_regular"});o=(0,s.Vb)(e,r)}}r((0,l.cH)(o)),k(t=>({...t,loading:!1,success:"Removed from cart"})),!h&&e&&(E?.open_cart_drawer_on_actions?r((0,c.qf)("cartModal")):(0,u.default)({message:"Product removed from bag",onAction:()=>r((0,c.qf)("cartModal"))}));let[d]=a.items.filter(e=>e.id===t),f=b?(0,n.SJ)(b):void 0,m=(0,n.Tf)({product:d,quantity:d.quantity}),v=(0,p.br)(d.product);(0,i.u4)("remove_from_cart",{product:m,user:f,categoryHandle:v})}catch(e){console.error("Failed to remove item from cart:",e);let{message:t}=(0,f.fe)(e,"cart");k(e=>({...e,error:t})),(0,u.default)({message:t,type:"error"})}finally{k(t=>({...t,loading:!1}))}},[r,v,_,y,h,e,E]),M=(0,o.useCallback)(async(a,o,d)=>{if(!v||!Array.isArray(_?.items))return void q();if(!a||""===a.trim())return void(0,u.default)({message:"Unable to identify the item to update.",type:"error"});if(o<0)return void(0,u.default)({message:"Quantity cannot be negative.",type:"error"});let m=g?.find(t=>t.id===a);if(m?.product&&o>(m.quantity||0)){let t=y||_;if(t){let e=o-(m.quantity||0),r=(0,s.vi)(t,m.product,m.variant_id||"",e);if(!r.valid)return void(0,u.default)({message:r.message,type:"info"})}}try{k(()=>({loading:!0,success:"",error:""}));let f=y||_;if(!f)throw Error("No cart available for optimistic update");let v=(0,s.A0)(f,a,o);if(1===v.items.length){let t=v.items[0];if(t.metadata?.source==="cross_selling_cart_product_card"&&t.product){let e=(0,s.$E)(v,t.id),r=(0,s.D5)({product:t.product,variantId:t.variant_id||"",quantity:t.quantity||1,source:"cart_reward_to_regular"});v=(0,s.Vb)(e,r)}}if(r((0,l.cH)(v)),o>0&&m&&(0,i.u4)("quantity_change",{product_id:m.product?.id,variant_id:m.variant_id,old_quantity:m.quantity,new_quantity:o,change_source:d}),k(t=>({...t,loading:!1,success:o>0?"Quantity updated":"Removed from cart"})),!h&&e)if(E?.open_cart_drawer_on_actions)r((0,c.qf)("cartModal"));else{let e=o<=0?"Product removed from bag":"Quantity updated";(0,u.default)({message:e,actionText:t?"Go to cart":void 0,onAction:()=>r((0,c.qf)("cartModal"))})}let[g]=f.items.filter(t=>t.id===a),q=b?(0,n.SJ)(b):void 0,A=(0,p.br)(g.product);if(g.quantity>o){let t=(0,n.Tf)({product:g,quantity:o});(0,i.u4)("remove_from_cart",{product:t,user:q,categoryHandle:A})}else{let t=(0,n.Tf)({product:g,quantity:o});(0,i.u4)("add_to_cart",{product:t,user:q,source:d||"cart_line_quantity_change",categoryHandle:A})}}catch(e){console.error("Failed to update item quantity:",e);let{message:t}=(0,f.fe)(e,"cart");k(e=>({...e,error:t})),(0,u.default)({message:t,type:"error"})}finally{k(t=>({...t,loading:!1}))}},[r,v,_,y,h,e,E]),N=(0,o.useCallback)(async t=>{if(!v||!Array.isArray(_?.items))return void q();let e=g?.find(e=>e.id===t);if(!e)return void(0,u.default)({message:"Unable to find the item in your cart.",type:"error"});if(e.product&&y){let t=(0,s.vi)(y,e.product,e.variant_id||"",1);if(!t.valid)return void(0,u.default)({message:t.message,type:"info"})}await M(t,(e.quantity||0)+1,"increment-button")},[v,M,g]),$=(0,o.useCallback)(async t=>{if(!v||!Array.isArray(_?.items))return void q();let e=g?.find(e=>e.id===t);if(!e)return void(0,u.default)({message:"Unable to find the item in your cart.",type:"error"});await M(t,(e.quantity||0)-1,"decrement-button")},[v,M,g]),x=(0,o.useCallback)(async(a,i,n)=>{if(!v||!Array.isArray(_?.items))return void q();if(!a||""===a.trim())return void(0,u.default)({message:"Unable to identify the item to switch.",type:"error"});if(!i||""===i.trim())return void(0,u.default)({message:"Please select a valid product variant.",type:"error"});if(!n)return void(0,u.default)({message:"Product information is required for optimistic updates.",type:"error"});try{let o;k(()=>({loading:!0,success:"",error:""}));let d=y||_;if(!d)throw Error("No cart available for optimistic update");let p=d.items.find(t=>t.id===a);if(p){let t=(0,s.mZ)(d,n,i,a);if(null!==t&&t<1){let t=(0,s.DQ)(d,n,a,i);t.valid||(0,u.default)({message:t.message,type:"info"}),k(t=>({...t,loading:!1}));return}null!==t&&(p.quantity||0)>t&&(o=t)}let f=(0,s.Bo)(d,a,i,n,o);r((0,l.cH)(f)),k(t=>({...t,loading:!1,success:"Switched variant"})),e&&(E?.open_cart_drawer_on_actions?r((0,c.qf)("cartModal")):(0,u.default)({message:"Variant switched successfully",actionText:t?"Go to cart":void 0,onAction:()=>r((0,c.qf)("cartModal"))}))}catch(e){console.error("Failed to switch cart item variant:",e);let{message:t}=(0,f.fe)(e,"cart");k(e=>({...e,error:t})),(0,u.default)({message:t,type:"error"})}finally{k(t=>({...t,loading:!1}))}}
1,[v,_,y,h,r,e,E]);return{loading:A.loading,success:A.success,error:A.error,cart:y||_,localCartItems:g,addToCart:w,removeFromCart:I,updateQuantity:M,incQty:N,decQty:$,switchCartItemVariant:x}}},82656:(t,e,r)=>{r.d(e,{Oz:()=>c,SJ:()=>d,Tf:()=>o,_l:()=>n,qo:()=>l});var a=r(84559),i=r(25892);let n=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0;if(t.bundle)return{id:t.id,name:t.title,compareAtPrice:t.bundle?.starting_from_price?Math.round(t.bundle?.starting_from_price):t.bundle?.extended_bundle_variant?.compare_at_price?Math.round(t.bundle?.extended_bundle_variant?.compare_at_price):Math.round(t.bundle?.price),quantity:e,variant:t.bundle?.variants?.map(t=>t.product_title)?.filter(Boolean)?.join(",")||"",sku:"",brand:t?.brand||"TWT",price:t.bundle?.starting_from_price?Math.round(t.bundle?.starting_from_price):Math.round(t.bundle?.price),imageUrl:t.thumbnail?`${a.up}/${t.thumbnail}`:""};if(t.calculated_price||t.prices){let r={id:t.product_id||t.id,title:t.title||n?.title||"Product",handle:n?.handle||"",description:n?.short_description||"",variants:[t],metadata:{}};return i.Jq.variantToAnalyticsProduct(t,r,e,n)}if(t.variants&&Array.isArray(t.variants)){let a=t.variants.find(t=>t.title===r)||t.variants[0];return i.Jq.productToAnalyticsProduct(t,e,n,a)}if(t.product||t.quantity){let e=t.product?.variants?.find(e=>e.id===t.variant_id),r=t.metadata?.bundle_variants,i=r?r.reduce((t,e)=>t+(e.quantity||0),0):t.quantity,n=r?r.map(t=>t.title)?.filter(Boolean)?.join(","):t.variant_title;return{id:t.product?.id,name:t.title||t.product?.title||"",compareAtPrice:e?.extended_product_variants?.compare_at_price?Math.round(e?.extended_product_variants?.compare_at_price):Math.round(t.unit_price),quantity:i,variant:n,sku:t.variant_sku,brand:t?.brand||"TWT",price:M
1ath.round(t.unit_price),imageUrl:t.thumbnail?`${a.up}/${t.thumbnail}`:""}}return{id:t.systemId||t.id,name:t.single_product_title||t.title||t.name,price:t.price||t.variants?.[0]?.price||0,quantity:e,category:t.category?.name||t.productType,variant:r||t.variant?.title,sku:t.sku||t.systemId}},o=t=>{let{product:e,quantity:r}=t;if("SINGLE"===e.product_type){let t=e.product?.variants?.find(t=>t.id===e.variant_id);return{id:e?.product?.id,variantId:e.variant_id,productId:e?.product?.id,name:e?.product_title,compareAtPrice:e.compare_at_unit_price||e.unit_price,quantity:r||1,variant:e.variant_title,sku:e.variant_sku,brand:e?.brand||"TWT",price:e.unit_price||0,imageUrl:e.thumbnail?`${a.up}/${e.thumbnail}`:"",handle:e.product_handle,manageInventory:t?.manage_inventory}}if("COMBO"===e.product_type){let t=e.product?.variants?.find(t=>t.id===e.variant_id);return{id:e?.product?.id,variantId:e.variant_id,productId:e?.product?.id,name:e?.title,compareAtPrice:e.compare_at_unit_price||e.unit_price,quantity:r||1,variant:e.metadata?.bundle_variants?.map(t=>t.title)?.join(", "),sku:e.variant_sku||"",brand:e?.brand||"TWT",price:e.unit_price||0,imageUrl:e.thumbnail?`${a.up}/${e.thumbnail}`:"",handle:e.product_handle,manageInventory:t?.manage_inventory}}if("BYOB"===e.product_type){let t=e.product?.variants?.find(t=>t.id===e.variant_id);return{id:e?.product?.id,variantId:e.variant_id,productId:e?.product?.id,name:e?.title,compareAtPrice:e.unit_price||e.total,quantity:r||1,variant:e.metadata?.bundle_variants?.map(t=>t.title)?.join(", "),sku:e.variant_sku||"",brand:e?.brand||"TWT",price:e.unit_price,imageUrl:e.thumbnail?`${a.up}/${e.thumbnail}`:"",handle:e.product_handle,manageInventory:t?.manage_inventory}}return null},d=t=>i.Jq.userToAnalyticsUser(t),l=t=>(t?.items??[]).map(t=>n(t)),c=t=>"number"==typeof t&&Number.isFinite(t)?t/100: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.