"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[29],{688:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.loadStylux=void 0;const s=n(21);t.loadStylux=function(e){const t=Object.assign({src:"https://sdk.stylux.io/js-sdk.js",id:"styluxScript",anonymous:!1},e);(0,s.loadScript)(t)}},209:function(e,t,n){var s=this&&this.__awaiter||function(e,t,n,s){return new(n||(n=Promise))((function(i,a){function o(e){try{r(s.next(e))}catch(e){a(e)}}function l(e){try{r(s.throw(e))}catch(e){a(e)}}function r(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,l)}r((s=s.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.useStyluxFeature=void 0;const i=n(3),a=n(688);t.useStyluxFeature=({addToCartWithPayload:e,payload:t,styluxAddToCartAnimation:n=!0,styluxPersonalizationPrice:o,isNotSleeve:l})=>{const[r,d]=(0,i.useState)(""),[c,u]=(0,i.useState)(!1),[p,h]=(0,i.useState)(!1),[v,x]=(0,i.useState)(!1),[j,y]=(0,i.useState)(!0),f=()=>h(!1),[b,g]=(0,i.useState)(l?10:3),w=c||!!r.length,[m,S]=(0,i.useState)(null);function T(){var e,n,i,a;return s(this,void 0,void 0,(function*(){if(window.Stylux)try{const s=yield window.Stylux.api.getProduct(t.variant.id),{offers:o=[]}=s;if(1===o.length){S(o[0]);const t=Number(null===(a=null===(i=null===(n=null===(e=o[0])||void 0===e?void 0:e.options)||void 0===n?void 0:n[0])||void 0===i?void 0:i.simpleText)||void 0===a?void 0:a.maxLength);Number.isNaN(t)||t==b||g(t)}}catch(e){return void console.warn("ERROR GETING STYLUX PRODUCT ====> ",e)}}))}function O(){return s(this,void 0,void 0,(function*(){try{function e(){return s(this,void 0,void 0,(function*(){if(!window.Stylux)throw new Error("Stylux is not defined");console.warn("STYLUX SETUP START"),yield window.Stylux.setup({apiKey:"STLX_7e571906d0d98eafeba362aec8e4b8d3225ba3b17c875d44a58859d0155f",merchantId:"fc220d21-1347-4fd8-a741-587bc5842827",preload:!1}),console.warn("STYLUX SETUP END")}))}return yield e(),yield T(),!0}catch(t){return!1}}))}return(0,i.useEffect)((()=>{let e=0;if("undefined"==typeof window)return;const t=setInterval((()=>s(void 0,void 0,void 0,(function*(){window.Stylux?(clearInterval(t),O(),console.warn("stylux loaded")):(e>50&&clearInterval(t),e++,console.warn("loading stylux"),(0,a.loadStylux)())}))),500)}),[]),(0,i.useEffect)((()=>{T()}),[t.variant.id]),{text:r,isActive:w,handleBlur:()=>{u(!1)},handleChange:e=>{y(!0),/[\uD800-\uDFFF\u2600-\u26FF\u2700-\u27BF\uD83C][\uDC00-\uDFFF\uDFC0-\uDFFF]/.test(e.currentTarget.value)&&y(!1),d(e.currentTarget.value)},handleFocus:()=>{u(!0)},MAX_TEXT_LENGTH:b,show:p,handleOpen:()=>h(!0),handleClose:f,addToCart:i=>s(void 0,void 0,void 0,(function*(){if(v)return;x(!0);const a=yield function(e){var t,n;return s(this,void 0,void 0,(function*(){try{if(!e&&(yield O(),!e))throw new Error("offer is not defined");const s=null===(n=null===(t=null==e?void 0:e.options)||void 0===t?void 0:t[0])||void 0===n?void 0:n.id,i=yield window.Stylux.api.createBundle([{personalizationOptionId:s,simpleText:{personalizationText:r}}],e),{id:a}=i;return a||null}catch(e){return console.log("error creating stylux bundle",e),null}}))}(m);a?(e(Object.assign(Object.assign({},t),{properties:Object.assign(Object.assign({},t.properties),{_STYLUX_BUNDLE:a,_styluxPersonalizationText:r,_styluxPersonalizationPrice:o})}),n?i:void 0,n?t.quantity:void 0),f(),x(!1)):x(!1)})),isAddingToCart:v,isValid:j}}},79:function(e,t,n){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.StyluxFeature=void 0;const i=n(0),a=n(1),o=n(2),l=n(25),r=n(4),d=s(n(99)),c=n(209),u=n(41),{wrapper:p,wrapperImage:h,wrapperText:v,wrapperContent:x,wrapperHeader:j,wrapperIcons:y,wrapperIcon:f,wrapperButtons:b,wrapperInput:g,wrapperInputActive:w,wrapperInputError:m,wrapperButton:S,wrapperClose:T,modalCloseWhite:O,button:C}=d.default;t.StyluxFeature=function({onClose:e,image:t,onOpen:n,onSubmit:s,displayPrice:d,styluxPersonalizationPrice:N,labels:{beUnique:F,chooseCharacters:P,customizeYourSleeve:_,greatGift:I,makeItMine:E,makeItYours:A,nevermind:k},addToCartWithPayload:z,payload:D,styluxAddToCartAnimation:L}){var U,X;const B=!(null===(X=null===(U=null==D?void 0:D.product)||void 0===U?void 0:U.title)||void 0===X?void 0:X.includes("Sleeve")),{handleBlur:M,handleChange:Y,handleFocus:G,isActive:R,text:W,MAX_TEXT_LENGTH:H,handleClose:$,handleOpen:q,show:V,addToCart:J,isAddingToCart:K,isValid:Q}=(0,c.useStyluxFeature)({addToCartWithPayload:z,payload:D,styluxAddToCartAnimation:L,styluxPersonalizationPrice:N,isNotSleeve:B}),Z=`personalize - ${d}`;return(0,i.jsxs)(a.Fragment,{children:[(0,i.jsx)("button",Object.assign({className:C,onClick:()=>{n&&n(),q()}},{children:Z})),(0,i.jsx)(l.Modal,Object.assign({show:V,onClose:()=>{e&&e(),$()},className:O},{children:(0,i.jsxs)("div",Object.assign({className:p},{children:[(0,i.jsxs)("div",Object.assign({className:h},{children:[(0,i.jsx)("img",{src:t.src,alt:t.alt,style:{objectFit:B?"contain":"cover"}}),(0,i.jsx)("div",Object.assign({style:{display:"flex",justifyContent:"center",alignItems:"center",position:"absolute",top:B?"50%":"30%",left:"50%",transform:"translate(-50%, -50%)"}},{children:(0,i.jsx)("span",Object.assign({className:v,style:{transform:B?"rotate(-90deg)":"unset",color:B?"black":"white",fontSize:B?"16px":"10px",position:"unset"}},{children:W}))}))]})),(0,i.jsxs)("div",Object.assign({className:x},{children:[(0,i.jsxs)("div",Object.assign({className:j},{children:[(0,i.jsx)("h2",{children:A}),(0,i.jsx)("h5",{children:B?"Customize Your Jar":_})]})),(0,i.jsxs)("div",Object.assign({className:y},{children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("span",Object.assign({className:f},{children:(0,i.jsx)(r.Icons.StarIcon,{})})),(0,i.jsx)("p",Object.assign({class:"no-translate"},{children:F}))]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("span",Object.assign({className:f},{children:(0,i.jsx)(r.Icons.GiftIcon,{})})),(0,i.jsx)("p",Object.assign({class:"no-translate"},{children:I}))]})]})),(0,i.jsxs)("div",Object.assign({className:b},{children:[(0,i.jsxs)("div",Object.assign({className:(0,o.cx)(g,R&&w)},{children:[(0,i.jsx)("input",{type:"text",onChange:Y,value:W,maxLength:B?10:3,name:"textInput",placeholder:"",onFocus:G,onBlur:M}),(0,i.jsx)("label",Object.assign({class:"no-translate"},{children:B?P.replace("3","10"):P})),(0,i.jsx)("span",{children:`${W.length}/${H}`})]})),!Q&&(0,i.jsx)("p",Object.assign({className:m},{children:"Text should not contain emojis"})),(0,i.jsx)("button",Object.assign({disabled:!Q||K,className:S,onClick:e=>{s&&s(),J(e)}},{children:K?(0,i.jsx)(u.Spinner,{}):E})),(0,i.jsx)("button",Object.assign({onClick:()=>{e&&e(),$()},className:T},{children:k}))]}))]}))]}))}))]})}}}]);