PageSourceSearch

https://www.dorothyperkins.com/build/_shared/chunk-2GWC7YVY.js

js dorothyperkins.com collected 2026-09-26 02:57:53 UTC 15,637 bytes, 1 lines download raw bytes

1import{a as Me}from"/build/_shared/chunk-PQ7VC4B4.js";import{a as Fe}from"/build/_shared/chunk-6GXZJ4II.js";import{a as De}from"/build/_shared/chunk-CTMJI4HD.js";import{a as $e}from"/build/_shared/chunk-2PERMO3C.js";import{c as Ae,d as Re}from"/build/_shared/chunk-SAKNPURC.js";import{a as qe}from"/build/_shared/chunk-K4RWW6WO.js";import{b as Ue}from"/build/_shared/chunk-7LDRWM3B.js";import{b as ze}from"/build/_shared/chunk-MKNN3ROM.js";import{a as Oe}from"/build/_shared/chunk-LLC3PGUJ.js";import{b as K,d as we}from"/build/_shared/chunk-YECX7KNY.js";import{a as ne}from"/build/_shared/chunk-HHS65IS6.js";import{b as Be,c as oe}from"/build/_shared/chunk-PE2RAMGK.js";import{b as ae}from"/build/_shared/chunk-QRZPKHUZ.js";import{a as Le}from"/build/_shared/chunk-TGDXDXUC.js";import{a as _e}from"/build/_shared/chunk-UDBCBQQO.js";import{a as te}from"/build/_shared/chunk-FD5H2VPE.js";import{a as Ne}from"/build/_shared/chunk-POUH3CHJ.js";import{a as Ie}from"/build/_shared/chunk-I5UT2UAU.js";import{a as W}from"/build/_shared/chunk-UXJUA2QE.js";import{a as ce}from"/build/_shared/chunk-ZZB7OGT7.js";import{a as re}from"/build/_shared/chunk-RKA7QBAZ.js";import{a as H}from"/build/_shared/chunk-YUUKFOQM.js";import{a as Ve}from"/build/_shared/chunk-DEVQKMWM.js";import{a as Y}from"/build/_shared/chunk-5OBEDPFR.js";import{a as le}from"/build/_shared/chunk-H6S7FWVP.js";import{d as A}from"/build/_shared/chunk-T36URGAI.js";var U=A(le());var ee=A(le());var q=A(le());var ve=A(qe());var R=A(Y()),We=({product:f,variants:u,sizesForColour:g,selectedVariant:k,sizeSelectionError:x,bundleType:Z})=>{var B,M;let{dispatch:I}=K(),{translate:N}=H(),{trackUserInteraction:D}=oe(),z=i=>{var o;let l=u.find(t=>t.sku===i.target.value);l&&i.target.value!==""&&(I({type:"SET_SELECTED_SIZE_VARIANT",bundleType:Z,product:f,selectedSizeVariant:l}),I({type:"SET_SIZE_SELECTION_ERROR",bundleType:Z,product:f,sizeSelectionError:!1}),D({section:"bundle",action:"select",label:"size",value:`${(o=l.attributes)==null?void 0:o.size}`}))},P=!k;return(0,R.jsxs)("div",{className:"flex flex-col gap-3 justify-between mt-2 font-light",children:[P?(0,R.jsx)(W,{className:"text-base font-light",children:N("product.selectASize")}):(0,R.jsxs)(W,{className:"text-base font-light",children:[N("product.sizeLabel")," ",(0,R.jsx)(W,{className:"font-medium",children:(B=k.attributes)==null?void 0:B.size})]}),(0,R.jsxs)("div",{className:"relative inline-block text-input",children:[(0,R.jsxs)("select",{onChange:z,value:(M=k==null?void 0:k.sku)!=null?M:"",className:`cursor-pointer flex flex-row gap-2 py-3 border ${x?"border-dark-red":"border-[#E2E2E2]"}  rounded pl-4 appearance-none bg-transparent z-[2] relative w-full pr-10 ${P?"text-grey-4":"text-default-text-colour"}`,children:[(0,R.jsx)("option",{value:"",disabled:!0,selected:!k,hidden:!0,children:N("product.selectASize")}),g.map((i,l)=>{var o;return(0,R.jsxs)("option",{value:i.sku||"",disabled:!i||!i.isOnStock,children:[(o=i.attributes)==null?void 0:o.size,(!i||!i.isOnStock)&&N("product.outOfStockSuffix")]},l)})]}),(0,R.jsx)("div",{className:"absolute top-0 right-0 p-4 z-[1]",children:(0,R.jsx)(Ie,{height:18,width:18,icon:Oe})})]})]})};var s=A(Y()),Ze=({currentlyViewing:f,product:u,productsState:g,selectedBundleProducts:k,bundleType:x})=>{var ue,de,me,pe,fe,Se,ge,ye,be,he,ke,xe,Ee,Te,Ce;let{createResponsiveImageSrc:Z}=Le(),I=(0,q.useContext)(Ve),{buildProductUrl:N}=re(),{translate:D}=H(),{trackUserInteraction:z}=oe(),{selectItem:P}=De(),{name:B,slug:M,variants:i,key:l,productType:o}=u,t="selectedColor"in u?u.selectedColor:void 0,{bundleProductsState:c,dispatch:d}=K(),b=I==null?void 0:I.enableBundleColorAlignment,{enableFromPriceRange:E}=(0,q.useContext)(Ne),e=((ue=g==null?void 0:g[l])==null?void 0:ue.selectedColourVariant)||(i==null?void 0:i.find(h=>h==null?void 0:h.isMaster)),a=((de=g==null?void 0:g[l])==null?void 0:de.selectedSizeVariant)||void 0,y={id:l||"",name:B||"",price:String(((pe=(me=e==null?void 0:e.prices)==null?void 0:me.centAmount)!=null?pe:0)/100),brand:((fe=e==null?void 0:e.attributes)==null?void 0:fe.collection)||((Se=e==null?void 0:e.attributes)==null?void 0:Se.brand)||"",colour:((ge=e==null?void 0:e.attributes)==null?void 0:ge.colour)||"",breadcrumbs:[]}
1,r=((ye=g==null?void 0:g[l])==null?void 0:ye.isSelected)||!1,n=((be=g==null?void 0:g[l])==null?void 0:be.sizeSelectionError)||!1,m=(0,q.useMemo)(()=>(0,ve.default)(u.variants,p=>{var V;return(V=p==null?void 0:p.attributes)==null?void 0:V.colour}).map(p=>{var _;return((_=u.variants)==null?void 0:_.find(F=>{var j,G;return((j=F==null?void 0:F.attributes)==null?void 0:j.colour)===((G=p==null?void 0:p.attributes)==null?void 0:G.colour)&&(F==null?void 0:F.isOnStock)}))||p}),[u]),S=(0,q.useMemo)(()=>{let h=i==null?void 0:i.filter(p=>{var V,_;return((V=p==null?void 0:p.attributes)==null?void 0:V.colour)===((_=e==null?void 0:e.attributes)==null?void 0:_.colour)});return(h==null?void 0:h.some(p=>p==null?void 0:p.isOnStock))?h:[]},[e]),w={mobile:[{width:100,breakpoint:te.md}],desktop:[{width:350,breakpoint:te.md+1}]},O=(0,q.useMemo)(()=>{var h;return Z({media:(h=e==null?void 0:e.images)==null?void 0:h[0],widths:w,breakpoints:te,aspectRatio:1.5})},[e]),C=Ue(i,e,a),T=(h,$=!1,p)=>{let V=h.filter(_=>_.isOnStock);if(V.length===1)return d({type:"SET_SELECTED_SIZE_VARIANT",bundleType:x,product:u,selectedSizeVariant:V[0]}),!0;if(p){let _=V.find(F=>{var j,G;return((G=(j=F.attributes)==null?void 0:j.size)==null?void 0:G.toUpperCase())===(p==null?void 0:p.toUpperCase())});if(_)return d({type:"SET_SELECTED_SIZE_VARIANT",bundleType:x,product:u,selectedSizeVariant:_}),!0}if($)return d({type:"SET_SELECTED_SIZE_VARIANT",bundleType:x,product:u,selectedSizeVariant:void 0}),!1},J=h=>{let $=je(h,i);if($){let p=$.find(V=>V.isOnStock);d({type:"SET_SELECTED_COLOUR_VARIANT",bundleType:x,product:u,selectedColourVariant:p||$[0]}),p||d({type:"SET_IS_SELECTED",bundleType:x,product:u,isSelected:!1}),T($,!0)}},ie=()=>{z({section:"bundle",action:`${r?"deselect":"select"}`}),k.find(h=>h.product.key===l)?d({type:"SET_IS_SELECTED",bundleType:x,product:u,isSelected:!1}):d(a?{type:"SET_IS_SELECTED",bundleType:x,product:u,isSelected:!0}:{type:"SET_SIZE_SELECTION_ERROR",bundleType:x,product:u,sizeSelectionError:!0})};(0,q.useEffect)(()=>{var $,p,V,_,F;if(!c)return;let h=(p=($=f.selectedColourVariant)==null?void 0:$.attributes)==null?void 0:p.colour;if(h){if(f.product.key===l&&!t){J(h);return}if(b&&f.product.key!==l){let j=i!=null?i:[],G=j.filter(v=>{var X,Pe;return((Pe=(X=v==null?void 0:v.attributes)==null?void 0:X.colour)==null?void 0:Pe.toUpperCase())===h.toUpperCase()});if(G.length>0){let v=(V=G.find(X=>X.isOnStock))!=null?V:G[0];J((_=v.attributes)==null?void 0:_.colour)}else{let v=j.find(X=>X.isOnStock);(F=v==null?void 0:v.attributes)!=null&&F.colour&&J(v.attributes.colour)}}}},[f.selectedColourVariant]);let Q=()=>{P(y,0,I,"bundle_pdp"),z({section:"bundle",action:"click"})};return g[l]?(0,s.jsxs)("div",{className:"flex flex-row  gap-5",children:[(0,s.jsxs)("div",{className:"relative w-[100px] md:max-w-52 block cursor-pointer",children:[(0,s.jsx)("div",{className:"w-[100px] md:max-w-52 block",children:(0,s.jsx)(ce,{to:`${N(M)}?colour=${(he=e==null?void 0:e.attributes)==null?void 0:he.colour}`,prefetch:"intent",onClick:Q,children:(0,s.jsx)(_e,{lazyLoad:!0,fillParent:!0,src:O,alt:`Related Product ${B}`,urlFormat:"product"})})}),(0,s.jsx)(ze,{className:"absolute top-0 left-0",isSelected:r,onClick:ie})]}),(0,s.jsxs)("div",{className:"flex-grow",children:[f.product.key===l&&(0,s.jsx)("div",{className:"text-xs text-[#777777] font-light pb-1",children:D("product.currentlyViewing")}),(0,s.jsx)("div",{className:"text-sm font-medium tracking-[ 0.0175em] leading-normal",children:((ke=e==null?void 0:e.attributes)==null?void 0:ke.collection)||((xe=e==null?void 0:e.attributes)==null?void 0:xe.brand)}),(0,s.jsx)(ce,{to:`${N(M)}?colour=${(Ee=e==null?void 0:e.attributes)==null?void 0:Ee.colour}`,prefetch:"intent",onClick:Q,children:(0,s.jsx)("div",{className:"text-sm font-light pt-1",children:B})}),C&&(0,s.jsx)("div",{className:"flex flex-row pt-4 text-base",children:C.min.price!==C.max.price?E?(0,s.jsx)(ae,{...C.min,priceSavingInline:!1,showFromPriceRange:E}):(0,s.jsx)(Re,{priceRange:C}):(0,s.jsx)(ae,{...C.max,priceSavingInline:!1})}),o==="beauty"&&m.length===1?null:(t||o!=="beauty")&&e?(0,s.jsxs)("div",{className:"flex flex-row items-baseline text-sm md:text-l ",children:[(0,s.jsx)(W,{className:"text-base md:text-l py-2 md:pt-3 font-light",children:D("product.colourLabel")})," ",(0,s.jsx)(W,{className:"font-semibold ml-1",children:(0,s.jsxs)("div",{children:[" ",`${(Te=e==null?void 0:e.attributes)==null?void 0:Te.colourLabel}`]})})]}):(0,s.jsx)("div",{children:(0,s.jsxs)(Be,{origin:"bundle",children:[(0,s.jsx)(Ae,{variants:m,selectedColour:e,onColorSelection:J,dropDownSelector:o==="beauty",isBundleProduct:!0}),!(e!=null&&e.isOnStock)&&(0,s.jsxs)(W,{className:"text-sm pb-1 text-dark-red",children:[D("product.colourOutOfStock"),(0,s.jsx)("br",{}),D("product.selectAnotherColour")]})]})}),((Ce=S==null?void 0:S.length)!=null?Ce:0)>1?(0,s.jsxs)("div",{className:"flex flex-col gap-2 pb-2",children:[(0,s.jsx)(We,{product:u,variants:i,sizesForColour:S,selectedVariant:a,sizeSelectionError:n,bundleType:x}),n&&(0,s.jsx)(W,{className:"text-sm pb-1 text-dark-red",children:D("product.selectSizeError")})]}):null]})]}):null},je=(f,u)=>u.filter(g=>{var k,x;return((x=(k=g==null?void 0:g.attributes)==null?void 0:k.colour)==null?void 0:x.toUpperCase())===(f==null?void 0:f.toUpperCase())});
1var L=A(Y()),Ge=({currentlyViewing:f,products:u,title:g,bundleType:k})=>{var l;let{bundleProductsState:x,dispatch:Z}=K(),{translate:I}=H(),[N,D]=(0,ee.useState)(void 0),z=(0,ee.useMemo)(()=>[...u].slice(0,4),[u]),P=(l=x[k])==null?void 0:l.products,B=(0,ee.useMemo)(()=>P?Object.keys(P).filter(o=>P[o].isSelected).map(o=>{let t=z.find(c=>c.key===o);return t?{product:t,selectedVariant:P[o].selectedSizeVariant}:null}).filter(o=>o!==null):[],[P]),M=o=>{o.length>0&&B.forEach(t=>{Z({type:"SET_IS_SELECTED",bundleType:k,product:t.product,isSelected:!1})})},i=(0,ee.useMemo)(()=>{let o=0,t=0,c="GBP";return z.forEach(d=>{var e,a,y,r,n;if(!d)return;let b=(e=x[k])==null?void 0:e.products[d.key];if(!(b!=null&&b.isSelected))return;let E=b.selectedSizeVariant;if(E){let m=((a=E.prices)==null?void 0:a.centAmount)||0;o+=m,t+=m,c=((y=E.prices)==null?void 0:y.currencyCode)||c}else if(d.variants&&d.variants.length>0){let m=d.variants.filter(S=>S==null?void 0:S.isOnStock);if(m.length>0){let S=m.map(C=>{var T;return((T=C==null?void 0:C.prices)==null?void 0:T.centAmount)||0}),w=Math.min(...S),O=Math.max(...S);o+=w,t+=O,c=((n=(r=m[0])==null?void 0:r.prices)==null?void 0:n.currencyCode)||c}}}),o===t?ne(o,c):`${ne(o,c)} - ${ne(t,c)}`},[x]);return(0,L.jsx)("div",{className:"mx-auto relative max-w-screen-2xl",children:P&&(0,L.jsx)(Me,{title:g,onProductPage:!0,titleClass:"mt-0",children:(0,L.jsxs)("div",{className:"border rounded border-grey-2 p-4",children:[(0,L.jsx)("div",{className:"flex flex-col gap-5 justify-center",children:z.map((o,t)=>(0,L.jsx)(Ze,{product:o,currentlyViewing:f,productsState:P,selectedBundleProducts:B,bundleType:k},t))}),(0,L.jsxs)("div",{className:"flex flex-col items-center mx-auto pt-8",children:[B.length?(0,L.jsxs)("span",{className:"text-base font-medium -mb-1",children:[I("styleTogether.total"),": ",(0,L.jsx)("span",{className:"font-light",children:i})]}):(0,L.jsx)(W,{className:"-mb-4",children:I("styleTogether.chooseItems")}),(0,L.jsx)(we,{className:"h-[50px] mt-4",onError:o=>D(o),onAdded:M,items:[...B].map(o=>({product:o.product,quantity:1,variant:o.selectedVariant})),disabled:B.length===0,buttonVariant:"secondary",bundleType:k,listType:"bundle_pdp",children:I("styleTogether.addToBag",{count:B.length})})]}),N&&(0,L.jsx)("div",{className:"text-dark-red",children:N})]})})})};var se=A(Y()),Ye=["suits","home","beauties","outfits"],Rt=({currentProduct:f,productKey:u})=>{var o;let{bundleProductsState:g,dispatch:k}=K(),{translate:x}=H(),{viewItemList:Z}=$e(),{ref:I,inView:N}=Fe({triggerOnce:!0,threshold:.1}),{getInternalUrl:D}=re(),[z,P]=(0,U.useState)(null),[B,M]=(0,U.useState)(!0),i=(0,U.useRef)(!1);(0,U.useEffect)(()=>{P(null),M(!0),i.current=!1},[u]),(0,U.useEffect)(()=>{if(!u){M(!1);return}let t=new AbortController;return fetch(D(`/_api/product/bundles/${u}`),{signal:t.signal}).then(c=>c.json()).then(c=>P(c.bundles)).catch(c=>{c.name!=="AbortError"&&console.error("Error fetching bundles:",c)}).finally(()=>M(!1)),()=>t.abort()},[u]);let l=(0,U.useMemo)(()=>{var d;if(!z)return[];let t=[];for(let b of Ye){let E=(d=z[b])==null?void 0:d[0];if(E){let e=E.products?[...E.products]:[];e.find(a=>f.product.key===(a==null?void 0:a.key))||e.unshift(f.product),t.push({id:E.id,header:E.header,products:e,bundleType:b})}}let c=t;if(t.length>1){let b=t.find(e=>e.bundleType==="suits"),E=t.find(e=>e.bundleType==="outfits");b&&E&&(c=[b])}return c.filter(b=>b.products.length>1)},[z,f.product]);return(0,U.useEffect)(()=>{var E,e;if(l.length===0)return;let t=(a,y)=>{var w,O,C;let n=y.find(T=>(T==null?void 0:T.isMaster)&&(T==null?void 0:T.isOnStock))||y.find(T=>T==null?void 0:T.isOnStock),m=((w=n==null?void 0:n.attributes)==null?void 0:w.colour)||((C=(O=y[0])==null?void 0:O.attributes)==null?void 0:C.colour);"selectedColor"in a&&a.selectedColor&&(m=a.selectedColor);let S=c(m,y);if(S){let J=S.find(Q=>Q==null?void 0:Q.isOnStock)||S[0],ie=d(S,!0);return{selectedColourVariant:J,selectedSizeVariant:ie}}},c=(a,y)=>y.filter(r=>{var n,m;return((m=(n=r==null?void 0:r.attributes)==null?void 0:n.colour)==null?void 0:m.toUpperCase())===(a==null?void 0:a.toUpperCase())}),d=(a,y=!1,r)=>{let n=a.filter(m=>m==null?void 0:m.isOnStock);if(n.length===1)return n[0];if(r){let m=n.find(S=>{var w,O;return((O=(w=S.attributes)==null?void 0:w.size)==null?void 0:O.toUpperCase())===(r==null?void 0:r.toUpperCase())});if(m)return m}return y?void 0:!1},b={};for(let a of l){let y={};for(let r of a.products){if(!(r!=null&&r.key))continue;let n=t(r,(r==null?void 0:r.variants)||[]);if((E=n==null?void 0:n.selectedColourVariant)==null?void 0:E.isOnStock){let S=n==null?void 0:n.selectedSizeVariant;y[r.key]={selectedSizeVariant:S&&typeof S=="object"?S:void 0,selectedColourVariant:n==null?void 0:n.selectedColourVariant,isSelected:!0,sizeSelectionError:!1}}}b[a.bundleType]={showComponent:!1,products:y}}for(let a in b){let y=b[a];if(!y)continue;let r=y.products||{};
1(((e=f==null?void 0:f.product)==null?void 0:e.key)||"")in r&&Object.keys(r).length>1&&(y.showComponent=!0)}k({type:"SET_INITIAL_STATE",initialState:b})},[l,(o=f==null?void 0:f.product)==null?void 0:o.key,k]),(0,U.useEffect)(()=>{if(!N||l.length===0||i.current)return;i.current=!0;let t=l.flatMap(c=>c.products.filter(Boolean).map(d=>{var b,E,e,a,y,r,n,m,S,w,O,C,T;return{id:d.key||"",productKey:d.key||"",name:d.name||"",price:String(((a=(e=(E=(b=d.variants)==null?void 0:b[0])==null?void 0:E.prices)==null?void 0:e.centAmount)!=null?a:0)/100),brand:((n=(r=(y=d.variants)==null?void 0:y[0])==null?void 0:r.attributes)==null?void 0:n.collection)||((w=(S=(m=d.variants)==null?void 0:m[0])==null?void 0:S.attributes)==null?void 0:w.brand)||"",colour:((T=(C=(O=d.variants)==null?void 0:O[0])==null?void 0:C.attributes)==null?void 0:T.colour)||"",breadcrumbs:[]}}));Z(t,"bundle_pdp")},[N,l,Z]),B||l.length===0?null:(0,se.jsx)("div",{ref:I,children:l.map(t=>{var c;return(0,se.jsx)("div",{className:"",children:g&&((c=g[t.bundleType])==null?void 0:c.showComponent)&&(0,se.jsx)(Ge,{currentlyViewing:f,products:t.products,title:t.header||x("bundles.completeYourPurchase"),bundleType:t.bundleType})},t.id)})})};export{Rt as a};

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.