PageSourceSearch

https://socialboom.io/_next/static/immutable/chunks/154i2l5nabvh4.js

js socialboom.io collected 2026-09-25 21:01:32 UTC 149,233 bytes, 266 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,73375,e=>{"use strict";let t=(0,e.i(75254).default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);e.s(["ChevronLeft",0,t],73375)},32189,(e,t,r)=>{"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},65156,(e,t,r)=>{"use strict";var a=e.r(32189);function s(){}function o(){}o.resetWarningCache=s,t.exports=function(){function e(e,t,r,s,o,n){if(n!==a){var i=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:s};return r.PropTypes=r,r}},45009,(e,t,r)=>{e.i(47167),t.exports=e.r(65156)()},76261,(e,t,r)=>{"use strict";var a="function"==typeof Symbol&&Symbol.for,s=a?Symbol.for("react.element"):60103,o=a?Symbol.for("react.portal"):60106,n=a?Symbol.for("react.fragment"):60107,i=a?Symbol.for("react.strict_mode"):60108,l=a?Symbol.for("react.profiler"):60114,d=a?Symbol.for("react.provider"):60109,c=a?Symbol.for("react.context"):60110,u=a?Symbol.for("react.async_mode"):60111,m=a?Symbol.for("react.concurrent_mode"):60111,p=a?Symbol.for("react.forward_ref"):60112,h=a?Symbol.for("react.suspense"):60113,x=a?Symbol.for("react.suspense_list"):60120,f=a?Symbol.for("react.memo"):60115,y=a?Symbol.for("react.lazy"):60116,g=a?Symbol.for("react.block"):60121,b=a?Symbol.for("react.fundamental"):60117,v=a?Symbol.for("react.responder"):60118,w=a?Symbol.for("react.scope"):60119;function j(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case s:switch(e=e.type){case u:case m:case n:case l:case i:case h:return e;default:switch(e=e&&e.$$typeof){case c:case p:case y:case f:case d:return e;default:return t}}case o:return t}}}function N(e){return j(e)===m}r.AsyncMode=u,r.ConcurrentMode=m,r.ContextConsumer=c,r.ContextProvider=d,r.Element=s,r.ForwardRef=p,r.Fragment=n,r.Lazy=y,r.Memo=f,r.Portal=o,r.Profiler=l,r.StrictMode=i,r.Suspense=h,r.isAsyncMode=function(e){return N(e)||j(e)===u},r.isConcurrentMode=N,r.isContextConsumer=function(e){return j(e)===c},r.isContextProvider=function(e){return j(e)===d},r.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===s},r.isForwardRef=function(e){return j(e)===p},r.isFragment=function(e){return j(e)===n},r.isLazy=function(e){return j(e)===y},r.isMemo=function(e){return j(e)===f},r.isPortal=function(e){return j(e)===o},r.isProfiler=function(e){return j(e)===l},r.isStrictMode=function(e){return j(e)===i},r.isSuspense=function(e){return j(e)===h},r.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===n||e===m||e===l||e===i||e===h||e===x||"object"==typeof e&&null!==e&&(e.$$typeof===y||e.$$typeof===f||e.$$typeof===d||e.$$typeof===c||e.$$typeof===p||e.$$typeof===b||e.$$typeof===v||e.$$typeof===w||e.$$typeof===g)},r.typeOf=j},2079,(e,t,r)=>{"use strict";e.i(47167),t.exports=e.r(76261)},98437,(e,t,r)=>{"use strict";var a=e.r(2079),s={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},n={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},i={};function l(e){return a.isMemo(e)?n:i[e.$$typeof]||s}i[a.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},i[a.Memo]=n;var d=Object.defineProperty,c=Object.getOwnPropertyNames,u=Object.getOwnPropertySymbols,m=Object.getOwnPropertyDescriptor,p=Object.getPrototypeOf,h=Object.prototype;t.exports=function e(t,r,a){if("string"!=typeof r){if(h){var s=p(r);s&&s!==h&&e(t,s,a)}var n=c(r);u&&(n=n.concat(u(r)));for(var i=l(t),x=l(r),f=0;f<n.length;++f){var y=n[f];
1if(!o[y]&&!(a&&a[y])&&!(x&&x[y])&&!(i&&i[y])){var g=m(r,y);try{d(t,y,g)}catch(e){}}}}return t}},55263,e=>{"use strict";var t,r,a=e.i(71645),s=e.i(45009),o=["sitekey","onChange","theme","type","tabindex","onExpired","onErrored","size","stoken","grecaptcha","badge","hl","isolated"];function n(){return(n=Object.assign.bind()).apply(this,arguments)}function i(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e,t){return(l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}var d=function(e){function t(){var t;return(t=e.call(this)||this).handleExpired=t.handleExpired.bind(i(t)),t.handleErrored=t.handleErrored.bind(i(t)),t.handleChange=t.handleChange.bind(i(t)),t.handleRecaptchaRef=t.handleRecaptchaRef.bind(i(t)),t}t.prototype=Object.create(e.prototype),t.prototype.constructor=t,l(t,e);var r=t.prototype;return r.getCaptchaFunction=function(e){return this.props.grecaptcha?this.props.grecaptcha.enterprise?this.props.grecaptcha.enterprise[e]:this.props.grecaptcha[e]:null},r.getValue=function(){var e=this.getCaptchaFunction("getResponse");return e&&void 0!==this._widgetId?e(this._widgetId):null},r.getWidgetId=function(){return this.props.grecaptcha&&void 0!==this._widgetId?this._widgetId:null},r.execute=function(){var e=this.getCaptchaFunction("execute");if(e&&void 0!==this._widgetId)return e(this._widgetId);this._executeRequested=!0},r.executeAsync=function(){var e=this;return new Promise(function(t,r){e.executionResolve=t,e.executionReject=r,e.execute()})},r.reset=function(){var e=this.getCaptchaFunction("reset");e&&void 0!==this._widgetId&&e(this._widgetId)},r.forceReset=function(){var e=this.getCaptchaFunction("reset");e&&e()},r.handleExpired=function(){this.props.onExpired?this.props.onExpired():this.handleChange(null)},r.handleErrored=function(){this.props.onErrored&&this.props.onErrored(),this.executionReject&&(this.executionReject(),delete this.executionResolve,delete this.executionReject)},r.handleChange=function(e){this.props.onChange&&this.props.onChange(e),this.executionResolve&&(this.executionResolve(e),delete this.executionReject,delete this.executionResolve)},r.explicitRender=function(){var e=this.getCaptchaFunction("render");if(e&&void 0===this._widgetId){var t=document.createElement("div");this._widgetId=e(t,{sitekey:this.props.sitekey,callback:this.handleChange,theme:this.props.theme,type:this.props.type,tabindex:this.props.tabindex,"expired-callback":this.handleExpired,"error-callback":this.handleErrored,size:this.props.size,stoken:this.props.stoken,hl:this.props.hl,badge:this.props.badge,isolated:this.props.isolated}),this.captcha.appendChild(t)}this._executeRequested&&this.props.grecaptcha&&void 0!==this._widgetId&&(this._executeRequested=!1,this.execute())},r.componentDidMount=function(){this.explicitRender()},r.componentDidUpdate=function(){this.explicitRender()},r.handleRecaptchaRef=function(e){this.captcha=e},r.render=function(){var e=this.props,t=(e.sitekey,e.onChange,e.theme,e.type,e.tabindex,e.onExpired,e.onErrored,e.size,e.stoken,e.grecaptcha,e.badge,e.hl,e.isolated,function(e,t){if(null==e)return{};var r,a,s={},o=Object.keys(e);for(a=0;a<o.length;a++)r=o[a],t.indexOf(r)>=0||(s[r]=e[r]);return s}(e,o));return a.createElement("div",n({},t,{ref:this.handleRecaptchaRef}))},t}(a.Component);d.displayName="ReCAPTCHA",d.propTypes={sitekey:s.default.string.isRequired,onChange:s.default.func,grecaptcha:s.default.object,theme:s.default.oneOf(["dark","light"]),type:s.default.oneOf(["image","audio"]),tabindex:s.default.number,onExpired:s.default.func,onErrored:s.default.func,size:s.default.oneOf(["compact","normal","invisible"]),stoken:s.default.string,hl:s.default.string,badge:s.default.oneOf(["bottomright","bottomleft","inline"]),isolated:s.default.bool},d.defaultProps={onChange:function(){},theme:"light",type:"image",tabindex:0,size:"normal",badge:"bottomright"};var c=e.i(98437);function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e}).apply(this,arguments)}var m={},p=0,h="onloadcallback";function x(){return"u">typeof window&&window.recaptchaOptions||{}}let f=(t=function(){var e=x(),t=e.useRecaptchaNet?"recaptcha.net":"www.google.com";return e.enterprise?"https://"+t+"/recaptcha/enterprise.js?onload="+h+"&render=explicit":"https://"+t+"/recaptcha/api.js?onload="+h+"&render=explicit"},r=r={callbackName:h,globalName:"grecaptcha",attributes:x().nonce?{nonce:x().nonce}:{}},function(e){var o=e.displayName||e.name||"Component",n=function(s){function o(e,t){var r;return(r=s.call(this,e,t)||this).state={},r.__scriptURL="",r}o.prototype=Object.create(s.prototype),o.prototype.constructor=o,o.__proto__=s;var n=o.prototype;return n.asyncScriptLoaderGetScriptLoaderID=function(){return this.__scriptLoaderID||(this.__scriptLoaderID="async-script-loader-"+p++),this.__scriptLoaderID},n.setupScriptURL=function(){return this.__scriptURL="function"==typeof t?t():t,this.__scriptURL},n.asyncScriptLoaderHandleLoad=function(e){var t=this;this.setState(e,function(){return t.props.asyncScriptOnLoad&&t.props.asyncScriptOnLoad(t.state)})},n.asyncScriptLoaderTriggerOnScriptLoaded=function(){var e=m[this.__scriptURL];if(!e||!e.loaded)throw Error("Script is not loaded.");for(var t in e.observers)e.observers[t](e);delete window[r.callbackName]},n.componentDidMount=function(){var e=this,t=this.setupScriptURL(),a=this.asyncScriptLoaderGetScriptLoaderID(),s=r,o=s.globalName,n=s.callbackName,i=s.scriptId;if(o&&void 0!==window[o]&&(m[t]={loaded:!0,observers:{}}),m[t]){var l=m[t];return l&&(l.loaded||l.errored)?void this.asyncScriptLoaderHandleLoad(l):void(l.observers[a]=function(t){return e.asyncScriptLoaderHandleLoad(t)})}var d={};d[a]=function(t){return e.asyncScriptLoaderHandleLoad(t)},m[t]={loaded:!1,observers:d};var c=document.createElement("script");for(var u in c.src=t,c.async=!0,r.attributes)c.setAttribute(u,r.attributes[u]);i&&(c.id=i);var p=function(e){if(m[t]){var r=m[t].observers;for(var a in r)e(r[a])&&delete r[a]}};n&&"u">typeof window&&(window[n]=function(){return e.asyncScriptLoaderTriggerOnScriptLoaded()}),c.onload=function(){var e=m[t];e&&(e.loaded=!0,p(function(t){return!n&&(t(e),!0)}))},c.onerror=function(){var e=m[t];e&&(e.errored=!0,p(function(t){return t(e),!0}))},document.body.appendChild(c)},n.componentWillUnmount=function(){var e=this.__scriptURL;if(!0===r.removeOnUnmount)for(var t=document.getElementsByTagName("script"),a=0;a<t.length;a+=1)t[a].src.indexOf(e)>-1&&t[a].parentNode&&t[a].parentNode.removeChild(t[a]);var s=m[e];s&&(delete s.observers[this.asyncScriptLoaderGetScriptLoaderID()],!0===r.removeOnUnmount&&delete m[e])},n.render=function(){var t=r.globalName,s=this.props,o=(s.asyncScriptOnLoad,s.forwardedRef),n=function(e,t){if(null==e)return{};var r,a,s={},o=Object.keys(e);for(a=0;a<o.length;a++)t.indexOf(r=o[a])>=0||(s[r]=e[r]);return s}(s,["asyncScriptOnLoad","forwardedRef"]);return t&&"u">typeof window&&(n[t]=void 0!==window[t]?window[t]:void 0),n.ref=o,(0,a.createElement)(e,n)},o}(a.Component),i=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(n,u({},e,{forwardedRef:t}))});return i.displayName="AsyncScriptLoader("+o+")",i.propTypes={asyncScriptOnLoad:s.default.func},(0,c.default)(i,e)})(d);e.s(["default",0,f],55263)},52893,e=>{"use strict";var t=e.i(47167),r=e.i(43476),a=e.i(71645),s=e.i(12970),o=e.i(73375),n=e.i(18566);function i({label:e="Back to Services",className:t="",platform:s,service:l}){let[d,c]=(0,a.useState)(!1),u=(0,n.useRouter)();return(0,r.jsxs)("button",{type:"button",onClick:()=>
1{if(d)return;c(!0);let e=l.replace(/\s+/g,"-");u.push(`/buy-${s.toLowerCase()}-${e.toLowerCase()}`)},disabled:d,className:`inline-flex touch-manipulation items-center gap-2 rounded-lg px-3 text-sm font-medium text-gray-600 transition-colors duration-200 hover:text-gray-900 focus:ring-2 focus:ring-red-500 focus:ring-offset-2 focus:outline-none active:bg-gray-100 active:text-gray-900 disabled:cursor-not-allowed disabled:opacity-50 md:text-base ${t}`,style:{WebkitTapHighlightColor:"transparent"},children:[(0,r.jsx)(o.ChevronLeft,{className:`h-4 w-4 flex-shrink-0 md:h-5 md:w-5 ${d?"animate-pulse":""}`}),(0,r.jsx)("span",{className:"select-none",children:e})]})}function l({customerAccessToken:e}){let t=(0,n.useRouter)();return e?(0,r.jsx)("div",{className:"ml-auto",children:(0,r.jsx)("button",{type:"button",onClick:()=>t.push("/panel"),className:"rounded-md border-2 border-primary/80 bg-primary px-3 py-2 font-bold text-white shadow-md duration-300 hover:scale-105 hover:opacity-90",children:"Go to Dashboard"})}):null}var d=e.i(61633),c=e.i(52844),u=e.i(82808),m=e.i(14635),p=e.i(93940);let h={"rapyd-toolkit":"rapyd_toolkit"},x=new Set(["balance","cardcorp","rapyd","rapyd_toolkit","paytree"]);function f(e){return x.has(h[e]||e)}let y=new Set(["likes","views","comments","saves","shares"]),g=new Set(["followers"]),b=new Set(["subscribers","live-views","live"]),v=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/(^-|-$)/g,"");function w(e){let t=new Map,r=[];for(let a of e){let e=Math.max(1,a.quantity||1),s=v(a.name);for(let o=0;o<e;o+=1){let e=(t.get(s)||0)+1;t.set(s,e),r.push({itemId:a.id,name:a.name,nameSlug:s,index:e})}}return r}async function j(e,t,r){try{if(!e||!t)return{isValid:!1};let a=new URLSearchParams({postalCode:String(e).trim(),country:t.toUpperCase()});r&&a.append("stateCode",r.toUpperCase());let s=await fetch(`/api/countries/postalValidator?${a.toString()}`);if(!s.ok)return{isValid:!0};return{isValid:(await s.json()).isValid}}catch(e){return console.error("Postal code validation error:",e),{isValid:!0}}}var N=e.i(76639),k=e.i(48425),C=Object.defineProperty,S=a.forwardRef(C(function(e,t){let{ratio:a=1,style:s,...o}=e;return(0,r.jsx)("div",{style:{position:"relative",width:"100%",paddingBottom:`${100/a}%`},"data-radix-aspect-ratio-wrapper":"",children:(0,r.jsx)(k.Primitive.div,{...o,ref:t,style:{...s,position:"absolute",top:0,right:0,bottom:0,left:0}})})},"name",{value:"AspectRatio",configurable:!0}));function P({...e}){return(0,r.jsx)(S,{"data-slot":"aspect-ratio",...e})}var I=e.i(29016),$=e.i(58388),E=e.i(97288);let L=/instagram\.com\/(?:p|reel|reels|tv)\/([A-Za-z0-9_-]+)/i;function R({selectedProduct:e,categoryName:t,priceBlock:s,nextButton:o}){let[n,i]=(0,a.useState)(""),[l,d]=(0,a.useState)("idle"),[p,h]=(0,a.useState)([]),[x,f]=(0,a.useState)(""),[y,g]=(0,a.useState)(new Set),[b,v]=(0,a.useState)(null),[w,j]=(0,a.useState)(""),[N,k]=(0,a.useState)(""),[C,S]=(0,a.useState)(!1),O=(0,I.usePostSelections)(),T=(0,a.useRef)(Promise.resolve()),U=(0,a.useRef)([]),D=(0,a.useRef)(null);(0,u.useCartUpdateListener)((0,a.useCallback)(e=>{U.current=e.lineItems??[]},[]));let V=e?.id??"";async function F(){try{let e=(0,m.getCartSessionId)(),t=(0,m.isGuest)()?e?await c.cartApi.getGuestCart(e):null:await c.cartApi.getCart();t?.ok&&(U.current=(await t.json()).lineItems??[])}catch{}}async function _(){let e=n.trim().replace(/^@+/,"");if(!e)return;D.current?.abort();let t=new AbortController;D.current=t,d("loading"),f(""),F();try{let r=await fetch(`${(0,$.getPanelUrl)()}/api/instagram/posts?username=${encodeURIComponent(e)}`,{signal:t.signal});if(t.signal.aborted)return;if(!r.ok){let e=await r.json().catch(()=>({}));h([]),d(404===r.status?"notfound":"error"),f(e.error??"Couldn't load posts. Try again.");return}let a=await r.json();h(a),d(0===a.length?"empty":"ready")}catch{if(t.signal.aborted)return;h([]),d("error"),f("Couldn't reach Instagram right now. Please try again.")}}async function B(t){if(!e)return;let r=e.id;v(null),(0,u.lockCartOperation)();try{let e=(0,I.findSelectionByPost)(r,t.shortcode);if(e){let t=(0,m.isGuest)()?await c.cartApi.removeFromGuestCart((0,m.getOrCreateCartSessionId)(),e.lineItemId):await c.cartApi.removeFromCart(e.lineItemId);if(t.ok){let r=await t.json();(0,I.removePostSelection)(e.lineItemId),U.current=r.lineItems??[],(0,u.emitCartUpdate)(r)}else v("Couldn't update your cart. Please try again.");return}let a=new Set(U.current.filter(e=>e.productId===r).map(e=>e.id)),s=(0,m.isGuest)()?await c.cartApi.addToGuestCart((0,m.getOrCreateCartSessionId)(),r):await c.cartApi.addToCart(r);if(s.ok){let e=await s.json(),o=(e.lineItems??[]).filter(e=>e.productId===r),n=o.find(e=>!a.has(e.id))??o[o.length-1];n&&(0,I.setPostSelection)(n.id,{shortcode:t.shortcode,postUrl:t.permalink,thumbnailUrl:t.thumbnailUrl,productId:r}),U.current=e.lineItems??[],(0,u.emitCartUpdate)(e)}else v("Couldn't add to your cart. Please try again.")}catch{v("Something went wrong. Please try again.")}finally{(0,u.unlockCartOperation)()}}function H(t){!e||y.has(t.shortcode)||(g(e=>new Set(e).add(t.shortcode)),T.current=T.current.then(()=>B(t)).finally(()=>g(e=>{let r=new Set(e);return r.delete(t.shortcode),r})))}async function G(){let t;if(!e||C)return;let r=w.trim();if(!r)return;let a=(t=r.trim().match(L))?t[1]:null,s=a??r,o=a?`https://www.instagram.com/p/${a}/`:r;if((0,I.findSelectionByPost)(e.id,s))return void k("That post is already selected.");k(""),j("");let n={shortcode:s,thumbnailUrl:"",permalink:o,isVideo:!1};if(a){S(!0);try{let e=await fetch(`${(0,$.getPanelUrl)()}/api/instagram/post?url=${encodeURIComponent(o)}`);if(e.ok){let t=await e.json();n={shortcode:t.shortcode||s,thumbnailUrl:t.thumbnailUrl||"",permalink:t.permalink||o,isVideo:!!t.isVideo}}}catch{}finally{S(!1)}}H(n)}let{format:W,showRegionalPrices:q}=(0,E.useRegionPrice)(),K=Object.values(O).filter(e=>e.productId===V).length,Y=e?.price??0,J=(K*Y).toFixed(2),X=q?W(K*Y):null,Z=new Set(p.map(e=>e.shortcode)),Q=Object.values(O).filter(e=>e.productId===V&&!Z.has(e.shortcode));return(0,r.jsxs)("div",{className:"border-t border-gray-100 pt-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("label",{htmlFor:"ig-post-username",className:"block text-base font-semibold text-gray-900 md:text-lg",children:["Select the posts you want ",t.toLowerCase()," on"]}),(0,r.jsxs)("p",{className:"text-sm text-slate-500",children:["Enter your Instagram username, then tap a post to add it. Eac
1h post you tap adds another ",e?.quantity??""," ",t," to your cart."]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)("span",{className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-gray-400",children:"@"}),(0,r.jsx)("input",{id:"ig-post-username",type:"text",value:n,onChange:e=>i(e.target.value.replace(/^@+/,"")),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),_())},placeholder:"your.username","data-testid":"ig-posts-username",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,className:"block w-full rounded-md border border-slate-200 bg-white py-2.5 pr-4 pl-8 text-gray-900 shadow-sm placeholder-gray-400 focus:border-indigo-500 focus:ring-indigo-500"})]}),(0,r.jsx)("button",{type:"button","data-testid":"ig-find-posts",onClick:_,disabled:!n.trim()||"loading"===l,className:"shrink-0 rounded-md bg-primary px-4 py-2.5 font-semibold text-white shadow-sm transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",children:"loading"===l?"Loading…":"Find posts"})]})]}),("notfound"===l||"error"===l||"empty"===l||"private"===l)&&(0,r.jsxs)("p",{className:"mt-3 text-sm text-slate-500",children:["empty"===l?"We couldn't find any posts on this profile.":x||"We couldn't load your posts."," ","You can still paste a post link below."]}),"ready"===l&&p.length>0&&(0,r.jsx)("div",{className:"mt-4 grid grid-cols-[repeat(auto-fill,minmax(88px,1fr))] gap-2 md:gap-3",children:p.map(e=>{let t=!!(0,I.findSelectionByPost)(V,e.shortcode),a=y.has(e.shortcode);return(0,r.jsxs)("button",{type:"button","data-testid":"ig-post-option","data-shortcode":e.shortcode,"data-selected":t,onClick:()=>H(e),"aria-pressed":t,className:`group relative overflow-hidden rounded-lg border-2 transition-all duration-150 ${t?"border-primary ring-2 ring-primary/30":"border-transparent hover:border-gray-300"}`,children:[(0,r.jsx)(P,{ratio:1,children:(0,r.jsx)("img",{src:e.thumbnailUrl,alt:`Post ${e.shortcode}`,referrerPolicy:"no-referrer",loading:"lazy",className:"h-full w-full object-cover"})}),e.isVideo&&(0,r.jsx)("span",{className:"absolute top-1 right-1 text-white drop-shadow",children:(0,r.jsx)(z,{})}),(t||a)&&(0,r.jsx)(A,{pending:a})]},e.shortcode)})}),Q.length>0&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("p",{className:"mb-2 text-sm font-medium text-gray-700",children:"Added by link"}),(0,r.jsx)("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(88px,1fr))] gap-2 md:gap-3",children:Q.map(e=>{let t=y.has(e.shortcode);return(0,r.jsxs)("button",{type:"button",onClick:()=>H({shortcode:e.shortcode,thumbnailUrl:"",permalink:e.postUrl,isVideo:!1}),className:"group relative overflow-hidden rounded-lg border-2 border-primary ring-2 ring-primary/30",children:[(0,r.jsx)(P,{ratio:1,children:e.thumbnailUrl?(0,r.jsx)("img",{src:e.thumbnailUrl,alt:`Post ${e.shortcode}`,referrerPolicy:"no-referrer",loading:"lazy",className:"h-full w-full object-cover"}):(0,r.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-1 bg-slate-100 text-slate-500",children:[(0,r.jsx)(M,{}),(0,r.jsxs)("span",{className:"max-w-full truncate px-1 text-[10px]",children:["/",e.shortcode]})]})}),(0,r.jsx)(A,{pending:t})]},e.shortcode)})})]}),e&&(0,r.jsxs)("div",{className:"mt-4 space-y-2",children:[(0,r.jsx)("label",{htmlFor:"ig-manual-post",className:"block text-sm font-medium text-gray-700",children:"Don't see your post? Paste its link"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{id:"ig-manual-post",type:"text",value:w,onChange:e=>{j(e.target.value),k("")},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),G())},placeholder:"https://www.instagram.com/p/…",autoComplete:"off",spellCheck:!1,className:"block w-full rounded-md border border-slate-200 bg-white px-4 py-2.5 text-gray-900 shadow-sm placeholder-gray-400 focus:border-indigo-500 focus:ring-indigo-500"}),(0,r.jsx)("button",{type:"button",onClick:G,disabled:!w.trim()||C,className:"shrink-0 rounded-md border-2 border-primary/80 px-4 py-2.5 font-semibold text-primary transition hover:bg-primary/5 disabled:cursor-not-allowed disabled:opacity-60",children:C?"Adding…":"Add"})]}),N&&(0,r.jsx)("p",{className:"text-sm text-primary",children:N})]}),b&&(0,r.jsx)("p",{className:"mt-2 text-sm text-primary",children:b}),(0,r.jsxs)("div",{className:"mt-4 flex flex-col gap-3 border-t border-gray-100 pt-4 md:flex-row md:items-center md:justify-between",children:[(0,r.jsxs)("div",{children:[s,K>0?(0,r.jsxs)("div",{className:"mt-1",children:[(0,r.jsxs)("div",{className:"text-lg font-bold text-gray-900",children:[K," ",1===K?"post":"posts"," selected · $",J]}),X&&(0,r.jsx)("div",{className:"text-xs text-slate-400",children:X}),(0,r.jsx)("p",{className:"text-xs text-slate-500",children:"Tap a selected post again to remove it."})]}):(0,r.jsx)("p",{className:"mt-1 text-sm text-slate-500",children:"No posts selected yet."})]}),(0,r.jsx)("div",{className:"flex w-full flex-col gap-2 md:w-auto md:flex-row md:items-center",children:o})]})]})}function A({pending:e}){return(0,r.jsx)("span",{className:"absolute inset-0 flex items-center justify-center bg-primary/25",children:e?(0,r.jsxs)("svg",{className:"size-6 animate-spin text-white",viewBox:"0 0 24 24",fill:"none",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):(0,r.jsx)("span",{className:"flex size-7 items-center justify-center rounded-full bg-primary text-white shadow",children:(0,r.jsx)("svg",{className:"size-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})})}function z(){return(0,r.jsx)("svg",{className:"size-4",viewBox:"0 0 24 24",fill:"
1currentColor","aria-label":"Reel",children:(0,r.jsx)("path",{d:"M8 5v14l11-7z"})})}function M(){return(0,r.jsx)("svg",{className:"size-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 010 5.656l-3 3a4 4 0 01-5.656-5.656l1.5-1.5M10.172 13.828a4 4 0 010-5.656l3-3a4 4 0 015.656 5.656l-1.5 1.5"})})}var O=e.i(5844),T=e.i(30030),U=e.i(30207),D=e.i(34620),V=Object.defineProperty,F=(e,t)=>V(e,"name",{value:t,configurable:!0}),_="Avatar",[B,H]=(0,T.createContextScope)(_),G=[0,()=>void 0],[W,q]=B(_),K=a.forwardRef(F(function(e,t){let{__scopeAvatar:s,...o}=e,[n,i]=a.useState("idle"),[l,d]=Q();return(0,r.jsx)(W,{scope:s,imageLoadingStatus:n,setImageLoadingStatus:i,imageCount:l,setImageCount:d,children:(0,r.jsx)(k.Primitive.span,{...o,ref:t})})},"Avatar")),Y=a.forwardRef(F(function(e,t){let{__scopeAvatar:s,src:o,onLoadingStatusChange:n,...i}=e,l=q("AvatarImage",s);ee(l.setImageCount);let d=X(o,{referrerPolicy:i.referrerPolicy,crossOrigin:i.crossOrigin,loadingStatus:l.imageLoadingStatus,setLoadingStatus:l.setImageLoadingStatus}),c=(0,U.useCallbackRef)(e=>{n?.(e)}),u=a.useRef(d);return(0,D.useLayoutEffect)(()=>{let e=u.current;u.current=d,d!==e&&c(d)},[d,c]),"loaded"===d?(0,r.jsx)(k.Primitive.img,{...i,ref:t,src:o}):null},"AvatarImage")),J=a.forwardRef(F(function(e,t){let{__scopeAvatar:s,delayMs:o,...n}=e,i=q("AvatarFallback",s),[l,d]=a.useState(void 0===o);return a.useEffect(()=>{if(void 0!==o){let e=window.setTimeout(()=>d(!0),o);return()=>window.clearTimeout(e)}},[o]),l&&"loaded"!==i.imageLoadingStatus?(0,r.jsx)(k.Primitive.span,{...n,ref:t}):null},"AvatarFallback"));function X(e,{loadingStatus:t,setLoadingStatus:r,referrerPolicy:a,crossOrigin:s}){return(0,D.useLayoutEffect)(()=>{if(!e)return void r("error");let t=new window.Image,o=F(e=>{r(Z(e.currentTarget))},"handleLoad"),n=F(()=>r("error"),"handleError");return t.addEventListener("load",o),t.addEventListener("error",n),a&&(t.referrerPolicy=a),t.crossOrigin=s??null,t.src=e,r(Z(t)),()=>{t.removeEventListener("load",o),t.removeEventListener("error",n),r("idle")}},[e,s,a,r]),t}function Z(e){return e.complete?e.naturalWidth>0?"loaded":"error":"loading"}function Q(){let e=G;if(O.IS_DEVELOPMENT){let[t]=e=a.useState(0),r=a.useRef(!1);a.useEffect(()=>{t>1&&!r.current&&(r.current=!0,console.warn("Avatar: Only one `Avatar.Image` component should be rendered per `Avatar.Root`, but multiple were detected. This will lead to unexpected behavior."))},[t])}return e}function ee(e){O.IS_DEVELOPMENT&&a.useEffect(()=>(e(e=>e+1),()=>{e(e=>e-1)}),[e])}F(X,"useImageLoadingStatus"),F(Z,"getImageLoadingStatus"),F(Q,"useImageCount"),F(ee,"useUpdateImageCount");var et=e.i(75157);function er({className:e,...t}){return(0,r.jsx)(K,{"data-slot":"avatar",className:(0,et.cn)("relative flex size-8 shrink-0 overflow-hidden rounded-full",e),...t})}function ea({className:e,...t}){return(0,r.jsx)(Y,{"data-slot":"avatar-image",className:(0,et.cn)("aspect-square size-full",e),...t})}function es({className:e,...t}){return(0,r.jsx)(J,{"data-slot":"avatar-fallback",className:(0,et.cn)("bg-muted flex size-full items-center justify-center rounded-full",e),...t})}function eo(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}K`:String(e)}function en({fieldName:e,placeholder:t="Enter your Instagram username",onConfirmedChange:s}){let[o,n]=(0,a.useState)(""),[i,l]=(0,a.useState)("idle"),[d,c]=(0,a.useState)(null),[u,m]=(0,a.useState)(""),[p,h]=(0,a.useState)(null),[x,f]=(0,a.useState)(!1),y=(0,a.useRef)(null),g=(0,a.useRef)(null),b=p?`https://www.instagram.com/${p.username}/`:"";function v(e){h(e),n(e.username),f(!1),l("found"),s?.({username:e.username,profileUrl:`https://www.instagram.com/${e.username}/`,profilePicUrl:e.unverified?"":e.profilePicUrl,unverified:!!e.unverified})}return(0,a.useEffect)(()=>{let e=o.trim().replace(/^@+/,"");if(p&&p.username.toLowerCase()===e.toLowerCase())return;if(e.length<1){l("idle"),c(null),f(!1);return}l("loading"),f(!0);let t=setTimeout(async()=>{y.current?.abort();let t=new AbortController;y.current=t;try{let r=await fetch(`${(0,$.getPanelUrl)()}/api/instagram/resolve?username=${encodeURIComponent(e)}`,{signal:t.signal});if(t.signal.aborted)return;if(!r.ok){let t=await r.json().catch(()=>({}));c(null),404===r.status?(l("notfound"),m(t.error??`We couldn't find @${e}.`)):(l("error"),m(t.error??"Something went wrong. Try again."));return}let a=await r.json();c(a),l("found")}catch(e){if(t.signal.aborted)return;l("error"),m("Couldn't reach Instagram right now. Please try again.")}},450);return()=>clearTimeout(t)},[o,p]),(0,a.useEffect)(()=>{function e(e){g.current&&!g.current.contains(e.target)&&f(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,r.jsxs)("div",{className:"relative",ref:g,children:[(0,r.jsx)("input",{type:"hidden",name:e,value:b,readOnly:!0}),p?(0,r.jsxs)("div",{"data-testid":"ig-profile-confirmed","data-username":p.username,className:`flex items-center gap-3 rounded-md border px-4 py-2.5 ${p.unverified?"border-slate-200 bg-slate-50":"border-emerald-200 bg-emerald-50/60"}`,children:[(0,r.jsxs)(er,{className:"size-10",children:[!p.unverified&&(0,r.jsx)(ea,{src:p.profilePicUrl,alt:p.username,referrerPolicy:"no-referrer"}),(0,r.jsx)(es,{className:"bg-slate-200 text-slate-500",children:p.username.charAt(0).toUpperCase()})]}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 font-semibold text-gray-900",children:[(0,r.jsx)("span",{className:"truncate",children:p.fullName||`@${p.username}`}),p.isVerified&&(0,r.jsx)(el,{})]}),(0,r.jsx)("div",{className:"truncate text-sm text-slate-500",children:p.unverified?`@${p.username}`:`@${p.username} \xb7 ${eo(p.followers)} followers`})]}),(0,r.jsx)("button",{type:"button","data-testid":"ig-profile-change",onClick:function(){h(null),n(""),c(null),l("idle"),s?.(null)},className:"shrink-0 text-sm font-medium text-indigo-600 hover:text-indigo-700",children:"Change"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("span",{className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-gray-400",children:"@"}),(0,r.jsx)("input",{type:"text","data-testid":"ig-profile-input","aria-label":"Instagram username",value:o,onChange:e=>n(e.target.value.replace(/^@+/,"")),onFocus:()=>d&&f(!0),onKeyDown:e=>"Enter"===e.key&&e.preventDefault(),placeholder:t,autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,className:"block w-full rounded-md border border-slate-200 bg-white px-4 py-2.5 text-gray-900 shadow-sm placeholder-gray-400 focus:border-indigo-500 focus:ring-indigo-500 pl-8"}),"loading"===i&&(0,r.jsx)("span",{className:"absolute top-1/2 right-3 -translate-y-1/2",children:(0,r.jsx)(ei,{})})]}),x&&(0,r.jsxs)("div",{className:"absolute z-20 mt-1 w-full overflow-hidden rounded-md border border-slate-200 bg-white shadow-lg",children:["loading"===i&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 text-sm text-slate-500",children:[(0,r.jsx)(ei,{})," Searching Instagram…"]}),"found"===i&&d&&(0,r.jsxs)("button",{type:"button","data-testid":"ig-profile-suggestion","data-username":d.username,onClick:()=>v(d),className:"flex w-full items-center gap-3 px-4 py-3 text-left hover:bg-slate-50",children:[(0,r.jsxs)(er,{className:"size-10",children:[(0,r.jsx)(ea,{src:d.profilePicUrl,alt:d.username,referrerPolicy:"no-referrer"}),(0,r.jsx)(es,{children:d.username.charAt(0).toUpperCase()})]}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center gap-1 font-semibold text-gray-900",children:[(0,r.jsx)("span",{className:"truncate",children:d.fullName||d.username}),d.isVerified&&(0,r.jsx)(el,{}),d.isPrivate&&(0,r.jsx)("span",{className:"rounded bg-slate-100 px-1.5 py-0.5 text-xs font-medium text-slate-500",children:"Private"})]}),(0,r.jsxs)("div",{className:"truncate text-sm text-slate-500",children:["@",d.username," · ",eo(d.followers)," ","followers"]})]})]}),("notfound"===i||"error"===i)&&(o.trim().replace(/^@+/,"")?(0,r.jsxs)("button",{type:"button","data-testid":"ig-profile-suggestion","data-unverified":"true",onClick:function(){let e=o.trim().replace(/^@+/,"");e&&v({username:e,fullName:"",profilePicUrl:"",followers:0,posts:0,isVerified:!1,isPrivate:!1,unverified:!0})},className:"flex w-full items-center gap-3 px-4 py-3 text-left hover:bg-slate-50",children:[(0,r.jsx)(er,{className:"size-10",children:(0,r.jsx)(es,{className:"bg-slate-200 text-slate-500",children:o.trim().replace(/^@+/,"").charAt(0).toUpperCase()})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("div",{className:"truncate font-semibold text-gray-900",children:["@",o.trim().replace(/^@+/,"")]}),(0,r.jsx)("div",{className:"truncate text-sm text-slate-500",children:"Select"})]})]}):(0,r.jsx)("div",{className:"px-4 py-3 text-sm text-slate-500",children:u}))]})]})]})}function ei(){return(0,r.jsxs)("svg",{className:"size-4 animate-spin text-indigo-500",viewBox:"0 0 24 24",fill:"none",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function el(){return(0,r.jsx)("svg",{className:"size-4 shrink-0 text-sky-500",viewBox:"0 0 24 24",fill:"
1currentColor","aria-label":"Verified",children:(0,r.jsx)("path",{d:"M12 2l2.09 2.26 3.04-.53.53 3.04L20 12l-2.34 2.23-.53 3.04-3.04-.53L12 22l-2.09-2.26-3.04.53-.53-3.04L4 12l2.34-2.23.53-3.04 3.04.53L12 2zm-1.2 12.8l4.6-4.6-1.2-1.2-3.4 3.4-1.6-1.6-1.2 1.2 2.8 2.8z"})})}function ed({selectedProduct:e,categoryName:t,priceBlock:s,nextButton:o,onAdded:n}){let[i,l]=(0,a.useState)([{key:0,confirmed:null}]),d=(0,a.useRef)(1),[p,h]=(0,a.useState)(!1),[x,f]=(0,a.useState)(null),y=(0,a.useRef)([]);(0,u.useCartUpdateListener)((0,a.useCallback)(e=>{y.current=e.lineItems??[]},[]));let g=i.map(e=>e.confirmed).filter(e=>null!==e),b=(0,a.useCallback)((e,t)=>{f(null),l(r=>{let a=r.map(r=>r.key===e?{...r,confirmed:t}:r),s=a.map((e,t)=>null===e.confirmed?t:-1).filter(e=>e>=0);if(0===s.length)return a.push({key:d.current++,confirmed:null}),a;if(s.length>1){let e=s[0];return a.filter((t,r)=>null!==t.confirmed||r===e)}return a})},[]);async function v(){try{let e=(0,m.getCartSessionId)(),t=(0,m.isGuest)()?e?await c.cartApi.getGuestCart(e):null:await c.cartApi.getCart();t?.ok&&(y.current=(await t.json()).lineItems??[])}catch{}}async function w(){if(!e)return;if(0===g.length)return void f("Enter your Instagram profile first.");let t=e.id;h(!0),f(null),(0,u.lockCartOperation)();try{await v();let e=new Set(y.current.filter(e=>e.productId===t).map(e=>e.id)),r=null;for(let a of g){let s=(0,m.isGuest)()?await c.cartApi.addToGuestCart((0,m.getOrCreateCartSessionId)(),t):await c.cartApi.addToCart(t);if(!s.ok){f("Error adding to cart");break}let o=await s.json();r=o;let n=(o.lineItems??[]).filter(e=>e.productId===t),i=n.find(t=>!e.has(t.id))??n[n.length-1];i&&(e.add(i.id),(0,I.setPostSelection)(i.id,{shortcode:`profile:${a.username}`,postUrl:a.profileUrl,thumbnailUrl:a.profilePicUrl,productId:t})),y.current=o.lineItems??[]}r&&((0,u.emitCartUpdate)(r),(0,u.emitProductAdded)(),n?.())}catch{f("Error adding to cart")}finally{h(!1),(0,u.unlockCartOperation)()}}let j=g.length>0;return(0,r.jsxs)("div",{className:"border-t border-gray-100 pt-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("label",{className:"block text-base font-semibold text-gray-900 md:text-lg",children:["Where should we deliver your ",t.toLowerCase(),"?"]}),(0,r.jsx)("p",{className:"text-sm text-slate-500",children:"Enter your Instagram username and pick your profile below."}),(0,r.jsx)("div",{className:"space-y-3",children:i.map((e,a)=>{let s=null===e.confirmed&&a===i.length-1;return(0,r.jsxs)("div",{className:"space-y-2",children:[s&&j&&(0,r.jsxs)("p",{className:"text-sm font-medium text-primary",children:["Want more ",t.toLowerCase(),"? Add another profile"]}),(0,r.jsx)(en,{onConfirmedChange:t=>b(e.key,t)})]},e.key)})})]}),x&&(0,r.jsx)("p",{className:"mt-2 text-sm text-primary",children:x}),(0,r.jsxs)("div",{className:"mt-4 flex flex-col gap-3 border-t border-gray-100 pt-4 md:flex-row md:items-center md:justify-between",children:[(0,r.jsx)("div",{children:s}),(0,r.jsxs)("div",{className:"flex w-full gap-2 md:w-auto",children:[(0,r.jsxs)("button",{type:"button","data-testid":"add-to-cart",onClick:w,disabled:!e||!j||p,className:`flex flex-1 cursor-pointer items-center justify-center gap-2 rounded-lg border-2 border-primary/80 bg-primary px-3 py-3 font-bold text-white shadow-md duration-300 hover:scale-105 hover:opacity-90 md:flex-initial md:py-2 ${!e||!j||p?"cursor-not-allowed opacity-70":""}`,children:[p&&(0,r.jsxs)("svg",{className:"size-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),g.length>1?`Add ${g.length} to Cart`:"Add to Cart"]}),o]})]})]})}let ec=/(?:youtube\.com\/(?:watch\?(?:.*&)?v=|embed\/|v\/|live\/|shorts\/)|youtu\.be\/)([A-Za-z0-9_-]{11})/i;function eu({selectedProduct:e,categoryName:t,priceBlock:s,nextButton:o}){let[n,i]=(0,a.useState)(""),[l,d]=(0,a.useState)("idle"),[p,h]=(0,a.useState)([]),[x,f]=(0,a.useState)(""),[y,g]=(0,a.useState)(new Set),[b,v]=(0,a.useState)(null),[w,j]=(0,a.useState)(""),[N,k]=(0,a.useState)(""),C=(0,I.usePostSelections)(),S=(0,a.useRef)(Promise.resolve()),L=(0,a.useRef)([]),R=(0,a.useRef)(null);(0,u.useCartUpdateListener)((0,a.useCallback)(e=>{L.current=e.lineItems??[]},[]));let A=e?.id??"";async function z(){try{let e=(0,m.getCartSessionId)(),t=(0,m.isGuest)()?e?await c.cartApi.getGuestCart(e):null:await c.cartApi.getCart();t?.ok&&(L.current=(await t.json()).lineItems??[])}catch{}}async function M(){let e=n.trim().replace(/^@+/,"");if(!e)return;R.current?.abort();let t=new AbortController;R.current=t,d("loading"),f(""),z();try{let r=await fetch(`${(0,$.getPanelUrl)()}/api/youtube/videos?handle=${encodeURIComponent(e)}`,{signal:t.signal});if(t.signal.aborted)return;if(!r.ok){let e=await r.json().catch(()=>({}));h([]),d(404===r.status?"notfound":"error"),f(e.error??"Couldn't load videos. Try again.");return}let a=await r.json();h(a),d(0===a.length?"empty":"ready")}catch{if(t.signal.aborted)return;h([]),d("error"),f("Couldn't reach YouTube right now. Please try again.")}}async function O(t){if(!e)return;let r=e.id;v(null),(0,u.lockCartOperation)();try{let e=(0,I.findSelectionByPost)(r,t.videoId);if(e){let t=(0,m.isGuest)()?await c.cartApi.removeFromGuestCart((0,m.getOrCreateCartSessionId)(),e.lineItemId):await c.cartApi.removeFromCart(e.lineItemId);if(t.ok){let r=await t.json();(0,I.removePostSelection)(e.lineItemId),L.current=r.lineItems??[],(0,u.emitCartUpdate)(r)}else v("Couldn't update your cart. Please try again.");return}let a=new Set(L.current.filter(e=>e.productId===r).map(e=>e.id)),s=(0,m.isGuest)()?await c.cartApi.addToGuestCart((0,m.getOrCreateCartSessionId)(),r):await c.cartApi.addToCart(r);if(s.ok){let e=await s.json(),o=(e.lineItems??[]).filter(e=>e.productId===r),n=o.find(e=>!a.has(e.id))??o[o.length-1];n&&(0,I.setPostSelection)(n.id,{shortcode:t.videoId,postUrl:t.videoUrl,thumbnailUrl:t.thumbnailUrl,productId:r}),L.current=e.lineItems??[],(0,u.emitCartUpdate)(e)}else v("Couldn't add to your cart. Please try again.")}catch{v("Something went wrong. Please try again.")}finally{(0,u.unlockCartOperation)()}}
1function T(t){!e||y.has(t.videoId)||(g(e=>new Set(e).add(t.videoId)),S.current=S.current.then(()=>O(t)).finally(()=>g(e=>{let r=new Set(e);return r.delete(t.videoId),r})))}function U(){let t;if(!e)return;let r=w.trim();if(!r)return;let a=(t=r.trim().match(ec))?t[1]:null,s=a??r;(0,I.findSelectionByPost)(e.id,s)?k("That video is already selected."):(k(""),j(""),T(a?{videoId:a,title:"",thumbnailUrl:`https://i.ytimg.com/vi/${a}/hqdefault.jpg`,videoUrl:`https://www.youtube.com/watch?v=${a}`,publishedAt:""}:{videoId:s,title:"",thumbnailUrl:"",videoUrl:r,publishedAt:""}))}let{format:D,showRegionalPrices:V}=(0,E.useRegionPrice)(),F=Object.values(C).filter(e=>e.productId===A).length,_=e?.price??0,B=(F*_).toFixed(2),H=V?D(F*_):null,G=new Set(p.map(e=>e.videoId)),W=Object.values(C).filter(e=>e.productId===A&&!G.has(e.shortcode));return(0,r.jsxs)("div",{className:"border-t border-gray-100 pt-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("label",{htmlFor:"yt-video-handle",className:"block text-base font-semibold text-gray-900 md:text-lg",children:["Select the videos you want ",t.toLowerCase()," on"]}),(0,r.jsxs)("p",{className:"text-sm text-slate-500",children:["Enter your YouTube @handle, then tap a video to add it. Each video you tap adds another ",e?.quantity??""," ",t," to your cart."]}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("div",{className:"relative flex-1",children:[(0,r.jsx)("span",{className:"pointer-events-none absolute top-1/2 left-3 -translate-y-1/2 text-gray-400",children:"@"}),(0,r.jsx)("input",{id:"yt-video-handle",type:"text",value:n,onChange:e=>i(e.target.value.replace(/^@+/,"")),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),M())},placeholder:"your.handle","data-testid":"yt-videos-handle",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,className:"block w-full rounded-md border border-slate-200 bg-white py-2.5 pr-4 pl-8 text-gray-900 shadow-sm placeholder-gray-400 focus:border-indigo-500 focus:ring-indigo-500"})]}),(0,r.jsx)("button",{type:"button","data-testid":"yt-find-videos",onClick:M,disabled:!n.trim()||"loading"===l,className:"shrink-0 rounded-md bg-primary px-4 py-2.5 font-semibold text-white shadow-sm transition hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",children:"loading"===l?"Loading…":"Find videos"})]})]}),("notfound"===l||"error"===l||"empty"===l)&&(0,r.jsxs)("p",{className:"mt-3 text-sm text-slate-500",children:["empty"===l?"We couldn't find any videos on this channel.":x||"We couldn't load your videos."," ","You can still paste a video link below."]}),"ready"===l&&p.length>0&&(0,r.jsx)("div",{className:"mt-4 grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2 md:gap-3",children:p.map(e=>{let t=!!(0,I.findSelectionByPost)(A,e.videoId),a=y.has(e.videoId);return(0,r.jsxs)("button",{type:"button","data-testid":"yt-video-option","data-video-id":e.videoId,"data-selected":t,onClick:()=>T(e),"aria-pressed":t,title:e.title,className:`group relative overflow-hidden rounded-lg border-2 transition-all duration-150 ${t?"border-primary ring-2 ring-primary/30":"border-transparent hover:border-gray-300"}`,children:[(0,r.jsx)(P,{ratio:16/9,children:(0,r.jsx)("img",{src:e.thumbnailUrl,alt:e.title||`Video ${e.videoId}`,referrerPolicy:"no-referrer",loading:"lazy",className:"h-full w-full object-cover"})}),(0,r.jsx)("span",{className:"absolute top-1 right-1 text-white drop-shadow",children:(0,r.jsx)(ep,{})}),(t||a)&&(0,r.jsx)(em,{pending:a})]},e.videoId)})}),W.length>0&&(0,r.jsxs)("div",{className:"mt-3",children:[(0,r.jsx)("p",{className:"mb-2 text-sm font-medium text-gray-700",children:"Added by link"}),(0,r.jsx)("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(160px,1fr))] gap-2 md:gap-3",children:W.map(e=>{let t=y.has(e.shortcode);return(0,r.jsxs)("button",{type:"button",onClick:()=>T({videoId:e.shortcode,title:"",thumbnailUrl:e.thumbnailUrl,videoUrl:e.postUrl,publishedAt:""}),className:"group relative overflow-hidden rounded-lg border-2 border-primary ring-2 ring-primary/30",children:[(0,r.jsx)(P,{ratio:16/9,children:e.thumbnailUrl?(0,r.jsx)("img",{src:e.thumbnailUrl,alt:`Video ${e.shortcode}`,referrerPolicy:"no-referrer",loading:"lazy",className:"h-full w-full object-cover"}):(0,r.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-1 bg-slate-100 text-slate-500",children:[(0,r.jsx)(eh,{}),(0,r.jsx)("span",{className:"max-w-full truncate px-1 text-[10px]",children:e.shortcode})]})}),(0,r.jsx)(em,{pending:t})]},e.shortcode)})})]}),e&&(0,r.jsxs)("div",{className:"mt-4 space-y-2",children:[(0,r.jsx)("label",{htmlFor:"yt-manual-video",className:"block text-sm font-medium text-gray-700",children:"Don't see your video? Paste its link"}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsx)("input",{id:"yt-manual-video",type:"text",value:w,onChange:e=>{j(e.target.value),k("")},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),U())},placeholder:"https://www.youtube.com/watch?v=…",autoComplete:"off",spellCheck:!1,className:"block w-full rounded-md border border-slate-200 bg-white px-4 py-2.5 text-gray-900 shadow-sm placeholder-gray-400 focus:border-indigo-500 focus:ring-indigo-500"}),(0,r.jsx)("button",{type:"button",onClick:U,disabled:!w.trim(),className:"shrink-0 rounded-md border-2 border-primary/80 px-4 py-2.5 font-semibold text-primary transition hover:bg-primary/5 disabled:cursor-not-allowed disabled:opacity-60",children:"Add"})]}),N&&(0,r.jsx)("p",{className:"text-sm text-primary",children:N})]}),b&&(0,r.jsx)("p",{className:"mt-2 text-sm text-primary",children:b}),(0,r.jsxs)("div",{className:"mt-4 flex flex-col gap-3 border-t border-gray-100 pt-4 md:flex-row md:items-center md:justify-between",children:[(0,r.jsxs)("div",{children:[s,F>0?(0,r.jsxs)("div",{className:"mt-1",children:[(0,r.jsxs)("div",{className:"text-lg font-bold text-gray-900",children:[F," ",1===F?"video":"videos"," ","selected · $",B]}),H&&(0,r.jsx)("div",{className:"text-xs text-slate-400",children:H}),(0,r.jsx)("p",{className:"text-xs text-slate-500",children:"Tap a selected video again to remove it."})]}):(0,r.jsx)("p",{className:"mt-1 text-sm text-slate-500",children:"No videos selected yet."})]}),(0,r.jsx)("div",{className:"flex w-full flex-col gap-2 md:w-auto md:flex-row md:items-center",children:o})]})]})}
1function em({pending:e}){return(0,r.jsx)("span",{className:"absolute inset-0 flex items-center justify-center bg-primary/25",children:e?(0,r.jsxs)("svg",{className:"size-6 animate-spin text-white",viewBox:"0 0 24 24",fill:"none",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):(0,r.jsx)("span",{className:"flex size-7 items-center justify-center rounded-full bg-primary text-white shadow",children:(0,r.jsx)("svg",{className:"size-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})})})}function ep(){return(0,r.jsx)("svg",{className:"size-4",viewBox:"0 0 24 24",fill:"currentColor","aria-label":"Video",children:(0,r.jsx)("path",{d:"M8 5v14l11-7z"})})}function eh(){return(0,r.jsx)("svg",{className:"size-5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.828 10.172a4 4 0 010 5.656l-3 3a4 4 0 01-5.656-5.656l1.5-1.5M10.172 13.828a4 4 0 010-5.656l3-3a4 4 0 015.656 5.656l-1.5 1.5"})})}function ex({mainCategoryNode:e,targetPrice:t}){let[s,o]=(0,a.useState)([]),[n,i]=(0,a.useState)(null);if((0,a.useEffect)(()=>{let r=e.children;if(0===r.length)return;let a=!1;return(async()=>{let e=await Promise.allSettled(r.map(async e=>{let r=await d.productsApi.getProducts({categoryId:e.id,limit:20}),a=await r.json(),s=(a?.data??[]).filter(e=>null!==e.price),o=void 0!==t?s.sort((e,r)=>Math.abs((e.price??0)-t)-Math.abs((r.price??0)-t))[0]:s.sort((e,t)=>(e.price??0)-(t.price??0))[0];return o?{categoryId:e.id,categoryName:e.name,product:o}:null}));a||o(e.filter(e=>"fulfilled"===e.status).map(e=>e.value).filter(e=>null!==e))})(),()=>{a=!0}},[e,t]),"Custom"===e.name||0===s.length)return null;let l=()=>i(null);return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-gray-900",children:"You may also like"}),(0,r.jsx)("div",{className:"-mx-1 flex gap-3 overflow-x-auto px-1 pb-2",children:s.map(e=>{let{categoryId:t,categoryName:a,product:s}=e;return(0,r.jsxs)("div",{className:"flex w-44 flex-shrink-0 flex-col justify-between rounded-xl border border-gray-200 bg-white p-3 shadow-sm",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"text-sm font-semibold text-gray-900",children:a}),(0,r.jsx)("p",{className:"text-xs text-slate-500",children:s.quantity}),(0,r.jsxs)("p",{className:"mt-1 text-base font-bold text-gray-900",children:["$",s.price]})]}),(0,r.jsx)("button",{type:"button",onClick:()=>i(e),className:"mt-2 rounded-md border-2 border-primary/80 bg-primary px-2 py-1.5 text-xs font-bold text-white duration-300 hover:scale-105 hover:opacity-90 cursor-pointer",children:"Add to cart"})]},t)})}),(0,r.jsx)(N.Dialog,{open:null!==n,onOpenChange:e=>!e&&l(),children:(0,r.jsx)(N.DialogContent,{className:"max-h-[90vh] overflow-y-auto sm:max-w-lg",children:n&&(0,r.jsx)(ef,{item:n,mainCategory:e.name,onDone:l},n.product.id)})})]})}function ef({item:e,mainCategory:t,onDone:a}){let{categoryName:s,product:o}=e;return t?.toLowerCase()==="instagram"&&y.has((s??"").toLowerCase())?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.DialogHeader,{children:(0,r.jsxs)(N.DialogTitle,{children:["Add ",s]})}),(0,r.jsx)(R,{selectedProduct:o,categoryName:s,nextButton:(0,r.jsx)("button",{type:"button",onClick:a,className:"rounded-md border-2 border-primary/80 bg-primary px-6 py-2 text-sm font-bold text-white shadow-md duration-300 hover:scale-105 hover:opacity-90 cursor-pointer",children:"Done"})})]}):t?.toLowerCase()==="instagram"&&g.has((s??"").toLowerCase())?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.DialogHeader,{children:(0,r.jsxs)(N.DialogTitle,{children:["Add ",s]})}),(0,r.jsx)(ed,{selectedProduct:o,categoryName:s,onAdded:a})]}):t?.toLowerCase()!=="youtube"||b.has((s??"").toLowerCase())?(0,r.jsx)(ey,{item:e,onDone:a}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.DialogHeader,{children:(0,r.jsxs)(N.DialogTitle,{children:["Add ",s]})}),(0,r.jsx)(eu,{selectedProduct:o,categoryName:s,nextButton:(0,r.jsx)("button",{type:"button",onClick:a,className:"rounded-md border-2 border-primary/80 bg-primary px-6 py-2 text-sm font-bold text-white shadow-md duration-300 hover:scale-105 hover:opacity-90 cursor-pointer",children:"Done"})})]})}function ey({item:e,onDone:t}){let{categoryName:s,product:o}=e,[n,i]=(0,a.useState)(!1),[l,d]=(0,a.useState)(!1);async function p(){i(!0);try{let e=(0,m.isGuest)()?await c.cartApi.addToGuestCart((0,m.getOrCreateCartSessionId)(),o.id):await c.cartApi.addToCart(o.id);if(e.ok){let r=await e.json();(0,u.emitCartUpdate)(r),d(!0),setTimeout(t,900)}}finally{i(!1)}}return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N.DialogHeader,{children:(0,r.jsxs)(N.DialogTitle,{children:["Add ",s]})}),(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"text-sm font-semibold text-gray-900",children:s}),(0,r.jsx)("p",{className:"text-xs text-slate-500",children:o.quantity}),(0,r.jsxs)("p",{className:"text-base font-bold text-gray-900",children:["$",o.price]})]}),(0,r.jsx)("button",{type:"button",onClick:p,disabled:n||l,className:`rounded-md border-2 border-primary/80 bg-primary px-6 py-2 text-sm font-bold text-white shadow-md duration-300 hover:scale-105 hover:opacity-90 cursor-pointer ${n||l?"curs
1or-not-allowed opacity-70":""}`,children:l?"Added ✓":n?"Adding…":"Add to cart"})]})}function eg({step:e,title:t,subtitle:a,children:s}){return(0,r.jsxs)("div",{className:"overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3 border-b border-gray-100 px-4 py-2.5 md:gap-4 md:px-6 md:py-4",children:[(0,r.jsx)("span",{className:"flex size-7 shrink-0 items-center justify-center rounded-full border-2 border-primary md:size-10",children:(0,r.jsx)("span",{className:"text-xs font-bold text-primary md:text-lg",children:e})}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-base font-semibold text-gray-900 md:text-xl",children:t}),a&&(0,r.jsx)("p",{className:"hidden text-sm text-slate-500 md:block",children:a})]})]}),(0,r.jsx)("div",{className:"space-y-4 p-3 sm:p-4 md:space-y-6 md:p-6",children:s})]})}function eb({steps:e,currentStep:t,onStepClick:a}){return(0,r.jsx)("div",{className:"divide-y divide-gray-200 rounded-md border border-gray-200 bg-white shadow-xs md:flex md:divide-y-0",children:e.map((s,o)=>{let n=o<t,i=o===t,l=n&&a;return(0,r.jsxs)("div",{className:`relative md:flex md:flex-1 ${l?"cursor-pointer hover:bg-gray-50 transition-colors":""}`,onClick:l?()=>a(o):void 0,role:l?"button":void 0,tabIndex:l?0:void 0,onKeyDown:l?e=>{("Enter"===e.key||" "===e.key)&&(e.preventDefault(),a(o))}:void 0,children:[(0,r.jsxs)("div",{className:"flex items-center px-4 py-2.5 text-xs font-medium md:px-6 md:py-4 md:text-sm",children:[(0,r.jsx)("span",{className:`flex size-6 shrink-0 items-center justify-center rounded-full border-2 md:size-9 ${n||i?"border-primary":"border-gray-300"} ${n?"bg-primary":""}`,children:n?(0,r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:"size-3 md:size-4",children:(0,r.jsx)("path",{d:"M20 6 9 17l-5-5"})}):(0,r.jsx)("span",{className:`text-xs font-bold md:text-sm ${i?"text-primary":"text-gray-500"}`,children:o+1})}),(0,r.jsx)("span",{className:`ml-2 text-xs font-medium md:ml-3 md:text-sm ${i?"text-gray-900":n?"text-gray-700":"text-gray-400"}`,children:s.title})]}),o!==e.length-1&&(0,r.jsx)("div",{className:"absolute top-0 right-0 hidden h-full w-5 md:block","aria-hidden":"true",children:(0,r.jsx)("svg",{className:"size-full text-gray-200",viewBox:"0 0 22 80",fill:"none",preserveAspectRatio:"none",children:(0,r.jsx)("path",{d:"M0 -2L20 40L0 82",vectorEffect:"non-scaling-stroke",stroke:"currentcolor",strokeLinejoin:"round"})})})]},s.title)})})}function ev(e){let t,a=e.name.split(" ")[0],s=isNaN(parseInt(t=a.replace(/[,\.]/g,"")))||t.length<=4?a:t.replace(/\B(?=(\d{3})+(?!\d))/g,","),o=s.length<=4?"text-xl md:text-2xl":"text-lg md:text-xl",n=e.comboFeatures?.slice().sort((e,t)=>e.localeCompare(t)),i=({className:e=""})=>(0,r.jsx)("svg",{fill:"currentColor",width:"14px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",className:`mt-0.5 shrink-0 text-primary ${e}`,children:(0,r.jsx)("path",{d:"M12,2A10,10,0,1,0,22,12,10,10,0,0,0,12,2Zm5.676,8.237-6,5.5a1,1,0,0,1-1.383-.03l-3-3a1,1,0,1,1,1.414-1.414l2.323,2.323,5.294-4.853a1,1,0,1,1,1.352,1.474Z"})}),l=()=>(0,r.jsx)("div",{className:"absolute left-0 right-0 top-0 bg-primary py-1.5 text-center text-[9px] font-bold leading-none tracking-wide text-white",children:"BEST SELLER"});return(0,r.jsx)(r.Fragment,{children:"Combo"===e.categoryName?(0,r.jsx)("div",{role:"button","data-testid":"product-option","data-item-id":e.entityId,"data-selected":e.isSelected,tabIndex:0,onClick:e.onClick,onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),e.onClick?.())},className:"relative w-full cursor-pointer",children:e.isSelected?(0,r.jsxs)("div",{className:"relative overflow-hidden rounded-xl border-2 border-primary bg-primary/5 text-primary transition-all duration-200",children:[e.isBestSeller&&(0,r.jsx)(l,{}),(0,r.jsxs)("div",{className:"px-2 pt-7 pb-1.5 text-center",children:[(0,r.jsx)("h3",{className:`${o} font-bold text-primary`,children:e.name.split(" ")[0]}),e.description&&(0,r.jsx)("div",{className:"text-sm",children:e.description})]}),n&&n.length>0&&(0,r.jsx)("ul",{className:"flex flex-col items-center px-3 pb-2 text-xs font-semibold",children:n.map(e=>(0,r.jsxs)("li",{className:"flex items-start gap-1.5 py-0.5",children:[(0,r.jsx)(i,{}),(0,r.jsx)("span",{children:e})]},e))})]}):(0,r.jsxs)("div",{className:"relative overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm transition-all duration-200 hover:border-gray-300",children:[e.isBestSeller&&(0,r.jsx)(l,{}),(0,r.jsxs)("div",{className:"px-2 pt-7 pb-1.5 text-center",children:[(0,r.jsx)("h3",{className:`${o} font-bold text-gray-900`,children:e.name.split(" ")[0]}),e.description&&(0,r.jsx)("div",{className:"text-sm",children:e.description})]}),n&&n.length>0&&(0,r.jsx)("ul",{className:"flex flex-col items-center px-3 pb-2 text-xs font-semibold text-gray-700",children:n.map(e=>(0,r.jsxs)("li",{className:"flex items-start gap-1.5 py-0.5",children:[(0,r.jsx)(i,{}),(0,r.jsx)("span",{children:e})]},e))})]})}):(0,r.jsx)("div",{role:"button","data-testid":"product-option","data-item-id":e.entityId,"data-selected":e.isSelected,tabIndex:0,onClick:e.onClick,onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),e.onClick?.())},className:"relative cursor-pointer",children:e.isSelected?(0,r.jsxs)("div",{className:"relative overflow-hidden rounded-xl border-2 border-primary bg-primary/5 text-primary transition-all duration-200",children:[e.isBestSeller&&(0,r.jsx)(l,{}),(0,r.jsxs)("div",{className:"px-2 pt-7 pb-3 text-center",children:[(0,r.jsx)("h3",{className:`${o} font-bold text-primary`,children:s}),(0,r.jsx)("p",{className:"text-xs text-primary md:text-sm",children:e.categoryName})]}),(0,r.jsx)("div",{className:`${"0"!==e.discountPer?"bg-primary":"bg-transparent"} border-t border-primary/15 py-0.5 text-center`,children:(0,r.jsx)("p",{className:`text-sm font-medium ${"0"!==e.discountPer?"text-white":"text-transparent"}`,children:"0"!==e.discountPer?`${e.discountPer}% off`:" "})})]}):(0,r.jsxs)("div",{className:"relative overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm transition-all duration-200 hover:border-gray-300 hover:shadow-md",children:[e.isBestSeller&&(0,r.jsx)(l,{}),(0,r.jsxs)("div",{className:"px-2 pt-7 pb-3 text-center",children:[(0,r.jsx)("h3",{className:`${o} font-bold text-gray-900`,children:s}),(0,r.jsx)("p",{className:"text-xs text-slate-500 md:text-sm",children:e.categoryName})]}),(0,r.jsx)("div",{className:`${"0"!==e.discountPer?"bg-[#f0fdf1]":"bg-transparent"} border-t border-gray-100 py-0.5 text-center`,children:(0,r.jsx)("p",{className:`text-sm font-medium ${"0"!==e.discountPer?"text-[#15803d]":"text-transparent"}`,children:"0"!==e.discountPer?`${e.discountPer}% off`:" "})})]})})})}var ew=e.i(74080);function ej(e){return e>=1e6?`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`:e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,"")}K`:String(e)}function eN({fieldName:e,placeholder:t="Search for your YouTube channel",onConfirmedChange:s}){let[o,n]=(0,a.useState)(""),[i,l]=(0,a.useState)("idle"),[d,c]=(0,a.useState)([]),[u,m]=(0,a.useState)(""),[p,h]=(0,a.useState)(null),[x,f]=(0,a.useState)(!1),y=(0,a.useRef)(null),g=(0,a.useRef)(null),b=(0,a.useRef)(null),[v,w]=(0,a.useState)(null),j=p?p.channelUrl:"";function N(e){h(e),n(e.title),f(!1),l("found"),s?.({channelId:e.channelId,channelUrl:e.channelUrl,title:e.title,thumbnailUrl:e.unverified?"":e.thumbnailUrl,unverified:!!e.unverified})}return(0,a.useEffect)(()=>{let e=o.trim();if(p&&p.title.toLowerCase()===e.toLowerCase())return;if(e.length<2){l("idle"),c([]),f(!1);return}l("loading"),f(!0);let t=setTimeout(async()=>{y.current?.abort();let t=new AbortController;y.current=t;try{let r=await fetch(`${(0,$.getPanelUrl)()}/api/youtube/search?query=${encodeURIComponent(e)}`,{signal:t.signal});if(t.signal.aborted)return;if(!r.ok){let t=await r.json().catch(()=>({}));c([]),404===r.status?(l("notfound"),m(t.error??`We couldn't find "${e}".`)):(l("error"),m(t.error??"Something went wrong. Try again."));return}let a=await r.json();c(a),l(a.length>
10?"found":"notfound"),0===a.length&&m(`We couldn't find "${e}".`)}catch(e){if(t.signal.aborted)return;l("error"),m("Couldn't reach YouTube right now. Please try again.")}},600);return()=>clearTimeout(t)},[o,p]),(0,a.useEffect)(()=>{function e(e){let t=e.target;!g.current||g.current.contains(t)||b.current&&b.current.contains(t)||f(!1)}return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,a.useEffect)(()=>{if(!x)return void w(null);function e(){let e=g.current;if(!e)return;let t=e.getBoundingClientRect();w({top:t.bottom,left:t.left,width:t.width})}return e(),window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[x]),(0,r.jsxs)("div",{className:"relative",ref:g,children:[(0,r.jsx)("input",{type:"hidden",name:e,value:j,readOnly:!0}),p?(0,r.jsxs)("div",{"data-testid":"yt-channel-confirmed","data-channel-id":p.channelId,className:`flex items-center gap-3 rounded-md border px-4 py-2.5 ${p.unverified?"border-slate-200 bg-slate-50":"border-emerald-200 bg-emerald-50/60"}`,children:[(0,r.jsxs)(er,{className:"size-10",children:[!p.unverified&&(0,r.jsx)(ea,{src:p.thumbnailUrl,alt:p.title,referrerPolicy:"no-referrer"}),(0,r.jsx)(es,{className:"bg-slate-200 text-slate-500",children:p.title.charAt(0).toUpperCase()})]}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"truncate font-semibold text-gray-900",children:p.title}),(0,r.jsx)("div",{className:"truncate text-sm text-slate-500",children:p.unverified?p.handle?`@${p.handle}`:"Channel":`${p.handle?`@${p.handle} \xb7 `:""}${ej(p.subscribers)} subscribers`})]}),(0,r.jsx)("button",{type:"button","data-testid":"yt-channel-change",onClick:function(){h(null),n(""),c([]),l("idle"),s?.(null)},className:"shrink-0 text-sm font-medium text-indigo-600 hover:text-indigo-700",children:"Change"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("input",{type:"text","data-testid":"yt-channel-input","aria-label":"YouTube channel",value:o,onChange:e=>n(e.target.value),onFocus:()=>d.length>0&&f(!0),onKeyDown:e=>"Enter"===e.key&&e.preventDefault(),placeholder:t,autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,className:"block w-full rounded-md border border-slate-200 bg-white px-4 py-2.5 text-gray-900 shadow-sm placeholder-gray-400 focus:border-indigo-500 focus:ring-indigo-500"}),"loading"===i&&(0,r.jsx)("span",{className:"absolute top-1/2 right-3 -translate-y-1/2",children:(0,r.jsx)(ek,{})})]}),x&&v&&"u">typeof document&&(0,ew.createPortal)((0,r.jsxs)("div",{ref:b,style:{position:"fixed",top:v.top+4,left:v.left,width:v.width},className:"z-50 max-h-80 overflow-y-auto overflow-x-hidden rounded-md border border-slate-200 bg-white shadow-lg",children:["loading"===i&&(0,r.jsxs)("div",{className:"flex items-center gap-2 px-4 py-3 text-sm text-slate-500",children:[(0,r.jsx)(ek,{})," Searching YouTube…"]}),"found"===i&&d.map(e=>(0,r.jsxs)("button",{type:"button","data-testid":"yt-channel-suggestion","data-channel-id":e.channelId,onClick:()=>N(e),className:"flex w-full items-center gap-3 px-4 py-3 text-left hover:bg-slate-50",children:[(0,r.jsxs)(er,{className:"size-10",children:[(0,r.jsx)(ea,{src:e.thumbnailUrl,alt:e.title,referrerPolicy:"no-referrer"}),(0,r.jsx)(es,{children:e.title.charAt(0).toUpperCase()})]}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"truncate font-semibold text-gray-900",children:e.title}),(0,r.jsxs)("div",{className:"truncate text-sm text-slate-500",children:[e.handle?`@${e.handle} \xb7 `:"",ej(e.subscribers)," subscribers"]}
1)]})]},e.channelId)),("notfound"===i||"error"===i)&&(o.trim()?(0,r.jsxs)("button",{type:"button","data-testid":"yt-channel-suggestion","data-unverified":"true",onClick:function(){let e=o.trim();e&&N({channelId:"",title:e,handle:null,thumbnailUrl:"",subscribers:0,channelUrl:e,unverified:!0})},className:"flex w-full items-center gap-3 px-4 py-3 text-left hover:bg-slate-50",children:[(0,r.jsx)(er,{className:"size-10",children:(0,r.jsx)(es,{className:"bg-slate-200 text-slate-500",children:o.trim().charAt(0).toUpperCase()})}),(0,r.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,r.jsx)("div",{className:"truncate font-semibold text-gray-900",children:o.trim()}),(0,r.jsx)("div",{className:"truncate text-sm text-slate-500",children:"Select"})]})]}):(0,r.jsx)("div",{className:"px-4 py-3 text-sm text-slate-500",children:u}))]}),document.body)]})]})}function ek(){return(0,r.jsxs)("svg",{className:"size-4 animate-spin text-indigo-500",viewBox:"0 0 24 24",fill:"none",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function eC({selectedProduct:e,categoryName:t,priceBlock:s,nextButton:o,onAdded:n}){let[i,l]=(0,a.useState)(null),[d,p]=(0,a.useState)(!1),[h,x]=(0,a.useState)(null),f=(0,a.useRef)([]);async function y(){try{let e=(0,m.getCartSessionId)(),t=(0,m.isGuest)()?e?await c.cartApi.getGuestCart(e):null:await c.cartApi.getCart();t?.ok&&(f.current=(await t.json()).lineItems??[])}catch{}}async function g(){if(!e)return;if(!i)return void x("Search and select your YouTube channel first.");let t=e.id;p(!0),x(null),(0,u.lockCartOperation)();try{await y();let e=new Set(f.current.filter(e=>e.productId===t).map(e=>e.id)),r=(0,m.isGuest)()?await c.cartApi.addToGuestCart((0,m.getOrCreateCartSessionId)(),t):await c.cartApi.addToCart(t);if(!r.ok)return void x("Error adding to cart");let a=await r.json(),s=(a.lineItems??[]).filter(e=>e.productId===t),o=s.find(t=>!e.has(t.id))??s[s.length-1];o&&(0,I.setPostSelection)(o.id,{shortcode:`channel:${i.channelId||i.channelUrl}`,postUrl:i.channelUrl,thumbnailUrl:i.thumbnailUrl,productId:t}),(0,u.emitCartUpdate)(a),(0,u.emitProductAdded)(),n?.()}catch{x("Error adding to cart")}finally{p(!1),(0,u.unlockCartOperation)()}}return(0,u.useCartUpdateListener)((0,a.useCallback)(e=>{f.current=e.lineItems??[]},[])),(0,r.jsxs)("div",{className:"border-t border-gray-100 pt-4",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("label",{className:"block text-base font-semibold text-gray-900 md:text-lg",children:["Which channel should we deliver your ",t.toLowerCase()," to?"]}),(0,r.jsx)("p",{className:"text-sm text-slate-500",children:"Search for your YouTube channel and pick it below."}),(0,r.jsx)(eN,{onConfirmedChange:l})]}),h&&(0,r.jsx)("p",{className:"mt-2 text-sm text-primary",children:h}),(0,r.jsxs)("div",{className:"mt-4 flex flex-col gap-3 border-t border-gray-100 pt-4 md:flex-row md:items-center md:justify-between",children:[(0,r.jsx)("div",{children:s}),(0,r.jsxs)("div",{className:"flex w-full gap-2 md:w-auto",children:[(0,r.jsxs)("button",{type:"button","data-testid":"add-to-cart",onClick:g,disabled:!e||!i||d,className:`flex flex-1 cursor-pointer items-center justify-center gap-2 rounded-lg border-2 border-primary/80 bg-primary px-3 py-3 font-bold text-white shadow-md duration-300 hover:scale-105 hover:opacity-90 md:flex-initial md:py-2 ${!e||!i||d?"cursor-not-allowed opacity-70":""}`,children:[d&&(0,r.jsxs)("svg",{className:"size-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Add to Cart"]}),o]})]})]})}let eS=["likes","views","comments","saves","shares"];function eP(e){let t,{products:s=[],mainCategory:o,categoryName:n,comboProducts:i=[],nextButton:l}=e,[d,p]=(0,a.useState)("regular"),[h,x]=(0,a.useState)(s[0]||null),[f,y]=(0,a.useState)(!1),[g,v]=(0,a.useState)(null),{format:w,showRegionalPrices:j,priceN
1ote:N}=(0,E.useRegionPrice)(),k=o?.toLowerCase()==="instagram"&&eS.includes(n?.toLowerCase())&&"regular"===d,C=o?.toLowerCase()==="instagram"&&n?.toLowerCase()==="followers"&&"regular"===d,S=o?.toLowerCase()==="youtube"&&n?.toLowerCase()==="subscribers"&&"regular"===d,P=o?.toLowerCase()==="youtube"&&!b.has((n??"").toLowerCase())&&"regular"===d,I=Array.isArray(i)&&i.length>0,$=e=>{if(!e)return 1;let t=parseInt(e.replace(/,/g,""));return isNaN(t)?1:t},L=("regular"===d?s:I?i:[]).slice().sort((e,t)=>$(e.quantity)-$(t.quantity));async function A(e){if(e){y(!0);try{let t=(0,m.isGuest)()?await c.cartApi.addToGuestCart((0,m.getOrCreateCartSessionId)(),e):await c.cartApi.addToCart(e);if(t.ok){let e=await t.json();(0,u.emitCartUpdate)(e),(0,u.emitProductAdded)(),v(null)}else v("Error adding to cart")}catch(e){v("Error adding to cart")}finally{y(!1)}}}(0,a.useEffect)(()=>{x(("regular"===d?s:i)[0]||null),n.toLowerCase().includes("combo")&&p("combo")},[d,s,i,n]);let z=e=>{if(!e||0===L.length)return{discountPercentage:"0",savings:"0.00",originalPrice:"0.00"};let t=L[0],r=$(t.quantity),a=$(e.quantity);if(e.id===t.id)return{discountPercentage:"0",savings:"0.00",originalPrice:"0.00"};let s=a*((t.price??0)/r),o=s-(e.price??0),n=o>0;return{discountPercentage:n?(o/s*100).toFixed(0):"0",savings:n?o.toFixed(2):"0.00",originalPrice:n?s.toFixed(2):"0.00"}},M=(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,r.jsxs)("span",{className:"text-2xl font-bold text-gray-900 md:text-3xl",children:["$",h?.price]}),h&&(()=>{let{originalPrice:e}=z(h);return"0.00"!==e?(0,r.jsxs)("span",{className:"text-sm text-slate-400 line-through",children:["$",e]}):null})()]}),j&&h?.price!=null&&(0,r.jsx)("p",{className:"text-xs text-slate-400",children:w(h.price)}),"regular"===d&&"0.00"!==z(h).savings&&(0,r.jsxs)("p",{className:"text-xs text-slate-500 md:text-sm",children:["You're saving"," ",(0,r.jsxs)("span",{className:"font-medium text-[#15803d]",children:["$",h?z(h).savings:"0.00"]})]})]});return(0,r.jsxs)(r.Fragment,{children:[!n.toLowerCase().includes("combo")&&(0,r.jsxs)("div",{className:"mb-3 inline-flex gap-1 rounded-full bg-gray-100 p-1",children:[(0,r.jsx)("button",{type:"button",className:`rounded-full px-4 py-1.5 text-sm font-medium transition-colors duration-200 ${"regular"===d?"bg-primary text-white shadow-sm":"text-gray-600 hover:bg-gray-200"}`,"data-testid":"product-tab-regular",onClick:()=>p("regular"),children:"Regular"}),(0,r.jsx)("button",{type:"button",className:`rounded-full px-4 py-1.5 text-sm font-medium transition-colors duration-200 ${"combo"===d?"bg-primary text-white shadow-sm":"text-gray-600 hover:bg-gray-200"} ${!I?"cursor-not-allowed opacity-50":""}`,"data-testid":"product-tab-combo",onClick:()=>I&&p("combo"),disabled:!I,children:"Combo"})]}),(0,r.jsx)("div",{className:`mb-4 grid ${"regular"===d?"grid-cols-3 sm:grid-cols-4 md:grid-cols-5":"grid-cols-2 md:grid-cols-3"} gap-2 md:gap-3`,children:((t=Math.floor(.75*L.length))===L.length-1&&(t=Math.floor(.5*L.length)),L.map((e,a)=>{let{discountPercentage:s}=z(e),o=a===t;return(0,r.jsx)(ev,{entityId:e.id,categoryName:"regular"===d?n:"Combo",name:e.quantity||"",discountPer:s,isSelected:h?.id===e.id,onClick:()=>{var t;return t=e.id,void x(L.find(e=>e.id===t)||null)},description:"",isBestSeller:o,comboFeatures:"combo"===d?e.comboFeatures:void 0},e.id)}))}),k?(0,r.jsx)(R,{selectedProduct:h,categoryName:n,priceBlock:M,nextButton:l}):C?(0,r.jsx)(ed,{selectedProduct:h,categoryName:n,priceBlock:M,nextButton:l}):S?(0,r.jsx)(eC,{selectedProduct:h,categoryName:n,priceBlock:M,nextButton:l}):P?(0,r.jsx)(eu,{selectedProduct:h,categoryName:n,priceBlock:M,nextButton:l}):(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex flex-col gap-3 border-t border-gray-100 pt-4 md:flex-row md:items-center md:justify-between",children:[(0,r.jsx)("div",{children:M}),(0,r.jsxs)("div",{className:"flex w-full gap-2 md:w-auto",children:[(0,r.jsxs)("button",{type:"button",className:`flex flex-1 cursor-pointer items-center justify-center gap-2 rounded-lg border-2 border-primary/80 bg-primary px-3 py-3 font-bold text-white shadow-md duration-300 hover:scale-105 hover:opacity-90 md:flex-initial md:py-2 ${f||!h?"cursor-not-allowed opacity-70":""}`,"data-testid":"add-to-cart",onClick:()=>h&&A(h.id),disabled:!h||f,children:[f&&(0,r.jsxs)("svg",{className:" size-4 animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,r.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,r.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Add to Cart"]}),l]})]})}),g&&(0,r.jsx)("p",{className:"text-sm text-primary",children:g}),N&&(0,r.jsx)("p",{"aria-hidden":N.hidden,className:`mt-2 text-[10px] text-slate-400${N.hidden?" invisible":""}`,children:N.text})]})}let eI=async e=>await fetch(`${(0,$.getApiUrl)()}/checkout/me`,{method:"POST",headers:(0,$.getHeaders)(),body:JSON.stringify(e)}),e$=async(e,t)=>await fetch(`${(0,$.getApiUrl)()}/checkout/guest`,{method:"POST",headers:(0,$.getGuestHeaders)(e),body:JSON.stringify(t)}),eE=async(e,t,r,a)=>{let s={};return a?s.paymentGroup=a:s.paymentMethod=t,r&&(s.retryToken=r),await fetch(`${(0,$.getApiUrl)()}/checkout/${encodeURIComponent(e)}/retry-payment`,{method:"POST",headers:(0,$.getHeaders)(),body:JSON.stringify(s)})};function eL(){return{validateServiceUrls:(e,t,r,a)=>{let s,o,n=Array.from(e.entries()).filter(([e,t])=>""!==t&&e.startsWith("service-url-")).map(([e,t])=>({key:e,url:t})),i=t.length;if(n.length<i)return{isValid:!1,error:"Please provide a URL for every selected service"};let{urls:l,errors:d}=function(e,t){let r=[],a=[];for(let s of w(t)){let t=e.get(`combo-${s.nameSlug}-${s.index}-profile-1`)?.trim()||"",o=e.get(`combo-${s.nameSlug}-${s.index}-video-1`)?.trim()||"",n=e.get(`combo-${s.nameSlug}-${s.index}-video-2`)?.trim()||o;if(!t){a.push(`Please enter a profile URL for ${s.nameSlug}${s.index>1?` #${s.index}`:""}`);continue}if(!o&&!n){a.push(`Please enter at least one video URL for ${s.nameSlug}${s.index>1?` #${s.index}`:""}`);continue}r.push({key:`service-url-combo-${s.nameSlug}-${s.index}-profile-1`,url:t}),o&&r.push({key:`service-url-combo-${s.nameSlug}-${s.index}-video-1`,url:o}),n&&r.push({key:`service-url-combo-${s.nameSlug}-${s.index}-video-2`,url:n})}return{urls:r,errors:a}}(e,r),{urls:c,errors:u}=(s=[],o=[],a.forEach((t,r)=>{let a=e.get(`custom-order-${t.id}-${r}`)?.trim()||"";a?a.length<10?o.push(`Please provide more detailed requirements for ${t.name} (minimum 10 characters)`):s.push({key:`service-url-custom-order-${t.id}-${r}`,url:a}):o.push(`Please enter custom order details for ${t.name}`)}),{urls:s,errors:o}),m=[...d,...u];return m.length>0?{isValid:!1,error:m[0]}:{isValid:!0,urls:[...n,...l,...c]}},validateUserInfo:(e,t)=>{if(t)return{isValid:!0};let r=(e.get("email")||"").trim(),a=(e.get("firstName")||"").trim(),s=(e.get("lastName")||"").trim(),o=e.get("postalCode");return r?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r)?a?s?o?{isValid:!0}:{isValid:!1,error:"Postal code is required"}:{isValid:!1,error:"Last name is required"}:{isValid:!1,error:"First name is required"}:{isValid:!1,error:"Please enter a valid email address"}:{isValid:!1,error:"Email is required"}},validateCart:e=>e&&e.totalAmount&&!(e.totalAmount<=0)?{isValid:!0}:{isValid:!1,error:"Invalid cart amount"},validateTermsAcceptance:(e,t)=>e||t?{isValid:!0}:{isValid:!1,error:"You must accept the terms and conditions to proceed with checkout"},validatePostalCodeAsync:async(e,t,r,a)=>{if(a)return{isValid:!0};if("US"===t.toUpperCase()&&!r)return{isValid:!1,error:"Please select a state"};let s=await j(e,t,r);return s.isValid?{isValid:!0}:{isValid:!1,error:s.error||"Invalid postal code"}}}}function eR(){let e=t.default.env.NEXT_PUBLIC_PAYMENT_DOMAIN||"ipn.yourdigitalmarketing.store";return e.startsWith("http://")||e.startsWith("https://")?e:`https://${e}`}let eA="checkoutReferer";function ez(e){if(e){try{localStorage.setItem(eA,e);return}catch{console.warn("localStorage not available, trying sessionStorage")}try{sessionStorage.setItem(eA,e);return}catch{console.warn("sessionStorage not available, referer will not be saved")}}}function eM({content:e}){let[t,s]=(0,a.useState)(!1),o=(0,a.useRef)(null),n=(0,a.useRef)(null);return(0,a.useEffect)(()=>{function e(e){o.current&&n.current&&!o.current.contains(e.target)&&!n.current.contains(e.target)&&s(!1)}if(t)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[t]),(0,r.jsxs)("div",{className:"relative inline-block",children:[(0,r.jsx)("button",{ref:n,type:"button",onClick:()=>s(!t),className:"ml-2 inline-flex size-5 items-center justify-center rounded-full border border-slate-300 bg-white text-xs font-medium text-slate-600 transition-colors hover:border-slate-400 hover:bg-slate-50","aria-label":"More information",children:"i"}),t&&(0,r.jsx)("div",{ref:o,className:"absolute top-full left-[-50px] z-50 mt-2 w-36 rounded-lg border border-slate-200 bg-white p-3 shadow-lg md:w-40",children:(0,r.jsx)("p",{className:"text-xs whitespace-pre-line text-slate-700 md:text-sm",children:e})})]})}let eO=e=>{"Enter"===e.key&&e.preventDefault()},eT="block w-full rounded-md border border-slate-200 bg-white px-4 py-2.5 text-gray-900 shadow-sm placeholder-gray-400 focus:border-indigo-500 focus:ring-indigo-500 cursor-pointer";function eU({individualServices:e,comboItems:t,customItems:a}){let s=(0,I.usePostSelections)();return(0,r.jsxs)(r.Fragment,{children:[e.map(e=>{let t,a=s[e.id]?.postUrl,o=e.description?e.description:"Make sure that the {{service}} count is public and not hidden.".replace("{{service}}",e.service.split("-")[1]||"");return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("label",{htmlFor:`service-url-${v(e.name)}
1-${e.index}`,className:"block text-base font-semibold text-gray-900 md:text-lg md:font-bold",children:[e.productQuantity," ",e.service.split("-")[0]," ","Watch"==e.service.split("-")[1]?"Watch hours":e.service.split("-")[1]," ","Link ",e.index>1?`#${e.index}`:"",e.description&&(0,r.jsx)(eM,{content:e.description})]}),(0,r.jsx)("p",{className:"text-sm text-slate-500",children:o}),(t=`service-url-${v(e.name)}-${e.index}`,(0,r.jsx)("input",{id:t,name:t,defaultValue:a||"",placeholder:"Paste your link",className:eT,onKeyDown:eO}))]},`${v(e.name)}-${e.index}`)}),t.length>0&&(0,r.jsxs)("div",{className:"space-y-4 pt-2",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-gray-900 md:text-xl",children:"Combo details"}),w(t).map(e=>(0,r.jsxs)("div",{className:"space-y-2 rounded-lg border border-slate-200 p-3 md:space-y-3 md:p-4",children:[(0,r.jsxs)("div",{className:"font-semibold text-gray-800",children:[e.name,e.index>1?` #${e.index}`:""]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-3",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{htmlFor:`combo-${v(e.name)}-${e.index}-profile-1`,className:"block text-sm font-medium text-gray-700",children:"Profile URL"}),(0,r.jsx)("input",{id:`combo-${v(e.name)}-${e.index}-profile-1`,name:`combo-${v(e.name)}-${e.index}-profile-1`,placeholder:"https://social.com/your-profile",className:eT,onKeyDown:eO})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{htmlFor:`combo-${v(e.name)}-${e.index}-video-1`,className:"block text-sm font-medium text-gray-700",children:"Video URL 1"}),(0,r.jsx)("input",{id:`combo-${v(e.name)}-${e.index}-video-1`,name:`combo-${v(e.name)}-${e.index}-video-1`,placeholder:"https://social.com/video-1",className:eT,onKeyDown:eO})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{htmlFor:`combo-${v(e.name)}-${e.index}-video-2`,className:"block text-sm font-medium text-gray-700",children:"Video URL 2"}),(0,r.jsx)("input",{id:`combo-${v(e.name)}-${e.index}-video-2`,name:`combo-${v(e.name)}-${e.index}-video-2`,placeholder:"https://social.com/video-2",className:eT,onKeyDown:eO})]})]}),(0,r.jsx)("p",{className:"text-sm text-slate-500",children:"*If only one post/video URL is introduced, the total amount of the combo will be delivered to it."})]},`${e.itemId}-${e.index}`))]}),a.length>0&&(0,r.jsxs)("div",{className:"space-y-4 pt-2",children:[(0,r.jsx)("h2",{className:"text-lg font-semibold text-gray-900 md:text-xl",children:"Custom Order Details"}),a.map((e,t)=>(0,r.jsxs)("div",{className:"space-y-2 rounded-lg border border-slate-200 p-3 md:space-y-3 md:p-4",children:[(0,r.jsxs)("div",{className:"font-semibold text-gray-800",children:[e.name," (Quantity: ",e.quantity,")"]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-sm text-slate-500",children:"Please provide all the details such as URLs agreed for the custom deal."}),(0,r.jsx)("textarea",{id:`custom-order-${e.id}-${t}`,name:`custom-order-${e.id}-${t}`,placeholder:"Enter your custom order details here...",rows:6,className:"w-full rounded-lg border border-slate-200 bg-white px-4 py-2.5 text-sm shadow-sm focus:border-indigo-300 focus:ring-3 focus:ring-indigo-500/10 focus:outline-hidden cursor-pointer"})]})]},`custom-${e.id}-${t}`))]})]})}var eD=e.i(22016);let eV=async()=>{try{let e=await fetch(`${(0,$.getApiUrl)()}/countries`,{method:"GET",headers:(0,$.getHeaders)()});if(!e.ok)return[];return e.json()}catch{return[]}},eF=async e=>{try{let t=await fetch(`${(0,$.getApiUrl)()}/countries/${e}/states`,{method:"GET",headers:(0,$.getHeaders)()});if(!t.ok)return[];return t.json()}catch{return[]}};function e_({onChange:e,value:t}){let[s,o]=(0,a.useState)([]);return(0,a.useEffect)(()=>{eV().then(o)},[]),(0,r.jsxs)("select",{id:"checkout-country",className:"block w-full rounded-md border border-gray-300 bg-white px-4 py-2.5 text-gray-900 shadow-sm placeholder-gray-400 focus:border-indigo-500 focus:ring-indigo-500",value:t?.code??"",onChange:t=>{let r=t.target.value;""===r?e(null):e(s.find(e=>e.code===r)||null)},children:[(0,r.jsx)("option",{value:"",children:"Select Country"}),s.map(e=>(0,r.jsx)("option",{value:e.code,children:e.name},e.code))]})}function eB({countryCode:e,onChange:t,value:s}){let[o,n]=(0,a.useState)([]),i=(0,a.useRef)(t);(0,a.useEffect)(()=>{i.current=t},[t]);let l=(0,a.useCallback)(async()=>
1{if(!e){n([]),i.current(null);return}try{let t=await eF(e);n(t)}catch(e){console.error("Error fetching states:",e)}},[e]);return(0,a.useEffect)(()=>{l()},[l]),(0,r.jsxs)("select",{id:"checkout-state",value:s?.code||"",onChange:e=>{let t=e.target.value;if(""===t)return void i.current(null);let r=o.find(e=>e.code===t)||null;i.current(r)},disabled:!e||0===o.length,className:"block w-full rounded-md border border-gray-300 bg-white px-4 py-2.5 text-gray-900 shadow-sm placeholder-gray-400 focus:border-indigo-500 focus:ring-indigo-500 disabled:cursor-not-allowed disabled:opacity-50",children:[(0,r.jsx)("option",{value:"",children:"Select State"}),o.map(e=>(0,r.jsx)("option",{value:e.code,children:e.name},e.code))]})}let eH=e=>{"Enter"===e.key&&e.preventDefault()},eG="block w-full rounded-md border border-slate-200 bg-white px-4 py-2.5 text-gray-900 shadow-sm placeholder-gray-400 focus:border-indigo-500 focus:ring-indigo-500";function eW({isLoggedIn:e,country:t,selectedState:a,onCountryChange:s,onStateChange:o,acceptTerms:n,onAcceptTermsChange:i,savedProfiles:l=[],onSelectProfile:d,onRemoveProfile:c}){return e?null:(0,r.jsxs)("div",{"data-testid":"checkout-customer-info",className:"space-y-2",children:[(0,r.jsxs)("div",{className:"rounded-lg border border-slate-200 bg-slate-50 p-4 text-sm text-slate-600",children:["Already have an account?"," ",(0,r.jsx)(eD.default,{href:"/login",className:"font-medium text-blue-600 hover:underline",children:"Sign in"})]}),l.length>0&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{className:"block text-base font-semibold text-gray-900 md:text-lg md:font-bold",children:"Saved details"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:l.map(e=>(0,r.jsxs)("button",{type:"button",onClick:()=>d?.(e),className:"group flex items-center gap-1.5 rounded-full border border-slate-200 bg-slate-50 px-3 py-1.5 text-sm text-gray-700 transition-colors hover:border-primary hover:bg-primary/5",children:[(0,r.jsxs)("span",{className:"max-w-[200px] truncate",children:[e.firstName," ",e.lastName]}),(0,r.jsxs)("span",{className:"hidden text-gray-400 sm:inline",children:["(",e.email,")"]}),(0,r.jsx)("span",{role:"button",onClick:t=>{t.stopPropagation(),c?.(e.email)},className:"ml-1 text-gray-400 hover:text-red-500",children:"×"})]},e.email))})]}),(0,r.jsx)("label",{htmlFor:"email",className:"block text-lg font-bold text-gray-900",children:"Your email"}),(0,r.jsx)("input",{id:"email",name:"email",type:"email",placeholder:"[email protected]",className:eG,onKeyDown:eH}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{htmlFor:"firstName",className:"block text-base font-semibold text-gray-900 md:text-lg md:font-bold",children:"First name"}),(0,r.jsx)("input",{id:"firstName",name:"firstName",type:"text",placeholder:"Mike",className:eG,onKeyDown:eH})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{htmlFor:"lastName",className:"block text-base font-semibold text-gray-900 md:text-lg md:font-bold",children:"Last name"}),(0,r.jsx)("input",{id:"lastName",name:"lastName",type:"text",placeholder:"Smith",className:eG,onKeyDown:eH})]})]}),(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{htmlFor:"checkout-country",className:"block text-base font-semibold text-gray-900 md:text-lg md:font-bold",children:"Country"}),(0,r.jsx)(e_,{value:t,onChange:s})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{htmlFor:"checkout-state",className:"block text-base font-semibold text-gray-900 md:text-lg md:font-bold",children:"State/Province"}),(0,r.jsx)(eB,{countryCode:t?t.code:null,value:a,onChange:o})]})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{htmlFor:"postalCode",className:"block text-base font-semibold text-gray-900 md:text-lg md:font-bold",children:"Postal Code"}),(0,r.jsx)("input",{id:"postalCode",name:"postalCode",type:"text",placeholder:"12345",className:eG,onKeyDown:eH})]}),(0,r.jsxs)("div",{className:"flex items-start space-x-2",children:[(0,r.jsx)("input",{type:"checkbox",id:"acceptTerms",checked:n,onChange:e=>i(e.target.checked),className:"mt-1 size-4 rounded border-gray-300 text-primary focus:ring-primary",required:!0}),(0,r.jsxs)("label",{htmlFor:"acceptTerms",className:"cursor-pointer text-sm leading-5",children:["I agree to the"," ",(0,r.jsx)(eD.default,{href:"/terms-and-conditions",target:"_blank",className:"text-blue-500 hover:underline",children:"Terms and Conditions."})," "]})]})]})}
1let eq=(0,e.i(75254).default)("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),eK={rapyd:{label:"Rapyd",description:"Pay via Rapyd hosted checkout page",icon:"💳"},"rapyd-toolkit":{label:"Credit/Debit Card",description:"Pay securely with your credit or debit card",icon:"💳"},balance:{label:"Store Credit",description:"Use your account balance",icon:"💰"},cardcorp:{label:"Visa/Mastercard",description:"Pay securely with your Visa or Mastercard credit/debit card",icon:"💳"},paytree:{label:"Credit/Debit Card",description:"Pay securely with your credit or debit card",icon:"💳"}};function eY(e,t){return e.filter(e=>{let r=t[e];return void 0===r||r>=100||!(r<=0)&&100*Math.random()<r})}let eJ={checkoutEnabledMethods:["cardcorp","rapyd","rapyd-toolkit","balance"],checkoutMethodOrder:["rapyd-toolkit","cardcorp","balance"],defaultProvider:"rapyd-toolkit",showGatewayIssuesMessage:!1,methodLabels:{},checkoutDebugMethods:[],checkoutRandomizeOrder:!1,checkoutMethodWeights:{},checkoutMethodVisibility:{},paymentGroups:[],methodAmountLimits:{},methodStatus:{},brandIconDefaults:{},brandIcons:{},brandMarksEnabled:{}},eX=null,eZ=0,eQ=null;async function e0(){try{let e=await fetch(`${(0,$.getApiUrl)()}/payment-config`,{next:{revalidate:60}});if(!e.ok)throw Error("Failed to fetch payment config");let t=await e.json(),r=t.checkoutMethodWeights||{},a=t.checkoutMethodVisibility||{},s=eY(t.checkoutMethodOrder,a);return t.checkoutRandomizeOrder&&(s=function(e,t){let r=e.map(e=>({method:e,weight:Math.max(.01,t[e]??1)})),a=[];for(;r.length>0;){let e=Math.random()*r.reduce((e,t)=>e+t.weight,0);for(let t=0;t<r.length;t++)if((e-=r[t].weight)<=0){a.push(r[t].method),r.splice(t,1);break}}return a}(s,r)),eX={checkoutEnabledMethods:eY(t.checkoutEnabledMethods,a),checkoutMethodOrder:s,defaultProvider:t.defaultProvider,showGatewayIssuesMessage:t.showGatewayIssuesMessage,methodLabels:t.methodLabels||{},checkoutDebugMethods:t.checkoutDebugMethods||[],checkoutRandomizeOrder:t.checkoutRandomizeOrder??!1,checkoutMethodWeights:r,checkoutMethodVisibility:a,paymentGroups:t.paymentGroups||[],methodAmountLimits:t.methodAmountLimits||{},methodStatus:t.methodStatus||{},brandIconDefaults:t.brandIconDefaults||{},brandIcons:t.brandIcons||{},brandMarksEnabled:t.brandMarksEnabled||{}},eZ=Date.now(),eX}catch{return eJ}}function e1(){let e=eX&&Date.now()-eZ<3e4,[t,r]=(0,a.useState)(e?eX:eJ),[s,o]=(0,a.useState)(!e);return(0,a.useEffect)(()=>{if(eX&&Date.now()-eZ<3e4){r(eX),o(!1);return}eQ||(eQ=e0().finally(()=>{eQ=null})),eQ.then(e=>{r(e),o(!1)})},[]),{config:t,isLoading:s}}let e2=`
2  .wpwl-form,
3  .wpwl-form-card {
4    font-family: 'Outfit', sans-serif;
5    max-width: 100%;
6    background: transparent !important;
7    padding: 0 !important;
8    margin: 0 !important;
9    border: 0px solid transparent !important;
10    box-shadow: 0 0 0 0 transparent !important;
11    filter: none !important;
12    backdrop-filter: none !important;
13    border-radius: 0 !important;
14    outline: none !important;
15  }
16
17  .wpwl-label {
18    font-size: 13px;
19    font-weight: 500;
20    color: #344054;
21    margin-bottom: 6px;
22    display: block;
23  }
24
25  .wpwl-control {
26    border: 1px solid #d0d5dd;
27    border-radius: 8px;
28    padding: 10px 14px;
29    min-height: 46px;
30    display: flex;
31    align-items: center;
32    background: #fff;
33    box-shadow: none;
34    transition: border-color 0.15s;
35    width: 100%;
36    box-sizing: border-box;
37    overflow: visible;
38  }
39  .wpwl-control:focus-within {
40    border-color: #475de5;
41    box-shadow: none;
42    outline: none;
43  }
44  .wpwl-control.wpwl-control-error,
45  .wpwl-has-error .wpwl-control {
46    border-color: #f04438;
47    box-shadow: none;
48  }
49  .wpwl-control iframe {
50    border: none !important;
51    box-shadow: none !important;
52    outline: none !important;
53    display: block;
54    width: 100% !important;
55    min-height: 24px;
56    flex: 1;
57  }
58
59  .wpwl-wrapper-cardNumber {
60    position: relative;
61    width: 100%;
62    display: flex;
63    flex-direction: column;
64    gap: 8px;
65  }
66  .wpwl-brand-card {
67    position: absolute;
68    right: 12px;
69    top: 50%;
70    transform: translateY(-50%);
71    width: 38px;
72    height: 24px;
73    pointer-events: none;
74    background-size: contain;
75    background-repeat: no-repeat;
76    background-position: center;
77    border-radius: 3px;
78    opacity: 0.9;
79    transition: opacity 0.15s;
80  }
81  .wpwl-brand-card.wpwl-brand-VISA,
82  .wpwl-brand-card.wpwl-brand-MASTER {
83    opacity: 1;
84  }
85
86  .wpwl-group-brand {
87    display: block !important;
88    width: 100% !important;
89    margin-bottom: 16px;
90  }
91  .wpwl-label-brand {
92    display: none !important;
93  }
94  .wpwl-control-brand {
95    display: block !important;
96    width: 100% !important;
97    align-self: stretch !important;
98    border: 1px solid #d0d5dd !important;
99    border-radius: 8px !important;
100    padding: 11px 14px !important;
101    font-size: 14px !important;
102    font-family: 'Outfit', sans-serif !important;
103    color: #101828 !important;
104    background: #fff !important;
105    box-shadow: none !important;
106    cursor: pointer;
107    appearance: auto;
108    height: auto !important;
109    margin: 0 !important;
110    box-sizing: border-box !important;
111  }
112  .wpwl-control-brand:focus {
113    border-color: #475de5 !important;
114    outline: none !important;
115  }
116
117  .wpwl-cvvHint,
118  a.wpwl-cvvHint,
119  button.wpwl-cvvHint,
120  .wpwl-button-cvvHint,
121  [class*="cvvHint"] {
122    display: inline-flex !important;
123    align-items: center !important;
124    justify-content: center !important;
125    width: 20px !important;
126    height: 20px !important;
127    border-radius: 50% !important;
128    border: 1.5px solid #d0d5dd !important;
129    background: #f9fafb !important;
130    color: #667085 !important;
131    font-size: 11px !important;
132    font-weight: 700 !important;
133    font-family: 'Outfit', sans-serif !important;
134    font-style: normal !important;
135    cursor: pointer !important;
136    text-decoration: none !important;
137    line-height: 1 !important;
138    transition: background 0.15s, border-color 0.15s, color 0.15s !important;
139    box-shadow: none !important;
140    margin-left: 8px !important;
141    vertical-align: middle !important;
142    padding: 0 !important;
143    flex-shrink: 0 !important;
144    user-select: none !important;
145  }
146  .wpwl-cvvHint:hover,
147  a.wpwl-cvvHint:hover,
148  button.wpwl-cvvHint:hover,
149  .wpwl-button-cvvHint:hover {
150    background: #eef2ff !important;
151    border-color: #475de5 !important;
152    color: #475de5 !important;
153  }
154
155  .wpwl-cvvHint-container,
156  .wpwl-hint-cvv,
157  [class*="cvvHint-container"] {
158    border: 1px solid #e4e7ec !important;
159    border-radius: 10px !important;
160    box-shadow: 0 8px 24px rgba(16,24,40,0.10), 0 2px 6px rgba(16,24,40,0.06) !important;
161    background: #fff !important;
162    padding: 14px !important;
163    font-family: 'Outfit', sans-serif !important;
164    font-size: 13px !important;
165    color: #344054 !important;
166    line-height: 1.5 !important;
167  }
168
169  .wpwl-hint {
170    font-size: 12px;
171    margin-top: 5px;
172    color: #667085;
173    font-family: 'Outfit', sans-serif;
174  }
175  .wpwl-hint-error,
176  .wpwl-has-error .wpwl-hint {
177    color: #f04438;
178  }
179
180  .wpwl-group {
181    margin-bottom: 16px;
182  }
183  .wpwl-group-expiry,
184  .wpwl-group-cvv {
185    display: inline-block;
186    width: calc(50% - 8px);
187    vertical-align: top;
188  }
189  .wpwl-group-expiry {
190    margin-right: 16px;
191  }
192  .wpwl-group-button {
193    margin-top: 4px;
194    margin-bottom: 0;
195  }
196
197  .wpwl-container {
198    width: 100% !important;
199    max-width: 100% !important;
200    box-sizing: border-box !important;
201  }
202
203  .wpwl-form-googlepay,
204  .wpwl-form-applepay {
205    width: 100% !important;
206    max-width: 100% !important;
207    box-sizing: border-box !important;
208    background: transparent !important;
209    border: none !important;
210    box-shadow: none !important;
211    padding: 0 !important;
212    margin-bottom: 8px !important;
213  }
214  .wpwl-form-googlepay > div,
215  .wpwl-form-applepay > div,
216  .wpwl-form-googlepay button,
217  .wpwl-form-applepay button,
218  .wpwl-form-googlepay [role="button"],
219  .wpwl-form-applepay [role="button"] {
220    width: 100% !important;
221    max-width: 100% !important;
222    box-sizing: border-box !important;
223  }
224
225  .wpwl-form-applepay apple-pay-button,
226  .wpwl-form-applepay .apple-pay-button,
227  .wpwl-form-applepay [class*="apple-pay"] {
228    width: 100% !important;
229    min-width: 100% !important;
230    max-width: 100% !important;
231    display: block !important;
232    box-sizing: border-box !important;
233    --apple-pay-button-width: 100% !important;
234    --apple-pay-button-height: 48px !important;
235    -apple-pay-button-style: black !important;
236    -apple-pay-button-type: pay !important;
237    height: 48px !important;
238    border-radius: 8px !important;
239  }
240
241  .wpwl-button-pay {
242    background-color: var(--color-primary);
243    border: none;
244    border-radius: 8px;
245    color: #fff;
246    font-family: 'Outfit', sans-serif;
247    font-size: 15px;
248    font-weight: 600;
249    letter-spacing: 0.02em;
250    padding: 13px 24px;
251    width: 100%;
252    cursor: pointer;
253    transition: background-color 0.15s;
254    display: block;
255  }
256  .wpwl-button-pay:hover {
257    filter: brightness(0.85);
258  }
259  .wpwl-button-pay:active {
260    filter: brightness(0.7);
261  }
262  .wpwl-button-pay:disabled {
263    opacity: 0.5;
264    cursor: not-allowed;
265  }
266`;function e5(){return(0,r.jsxs)("div",{className:"animate-pulse space-y-4 py-1",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"mb-2 h-3 w-20 rounded bg-gray-200"}),(0,r.jsx)("div",{className:"h-[46px] rounded-lg bg-gray-100"})]}),(0,r.jsxs)("div",{className:"flex gap-4",children:[(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("div",{className:"mb-2 h-3 w-16 rounded bg-gray-200"}),(0,r.jsx)("div",{className:"h-[46px] rounded-lg bg-gray-100"})]}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("div",{className:"mb-2 h-3 w-8 rounded bg-gray-200"}),(0,r.jsx)("div",{className:"h-[46px] rounded-lg bg-gray-100"})]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("div",{className:"mb-2 h-3 w-24 rounded bg-gray-200"}),(0,r.jsx)("div",{className:"h-[46px] rounded-lg bg-gray-100"})]}),(0,r.jsx)("div",{className:"h-[46px] rounded-lg bg-gray-200"})]})}function e4({checkoutId:e,integrity:t,scriptSrc:s,shopperResultUrl:o,amount:n,currencyCode:i="USD"}){let[l,d]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{let r=document.createElement("style");r.id="cardcorp-widget-styles",r.textContent=e2,document.head.appendChild(r),window.wpwlOptions={locale:"en",style:"card",brandDetection:!0,showCVVHint:!0,labels:{cardHolder:"Card holder name",cardNumber:"Card number",expiryDate:"Expiry date",cvv:"CVV"},...n?{applePay:{buttonSizeMode:"fill",buttonStyle:"black",buttonType:"pay",currencyCode:i,countryCode:"US",total:{label:"SocialBoom",amount:n}}}:{}};let a=document.createElement("script");return a.src=`${s}?checkoutId=${encodeURIComponent(e)}`,a.async=!0,t&&(a.integrity=t,a.crossOrigin="anonymous"),a.onload=()=>d(!0),a.onerror=()=>console.error("[CardCorp] Failed to load payment widget script"),document.body.appendChild(a),()=>{document.body.contains(a)&&document.body.removeChild(a),document.getElementById("cardcorp-widget-styles")?.remove(),delete window.wpwlOptions}},[e,t,s,n,i]),(0,r.jsxs)("div",{className:"w-full",children:[(0,r.jsxs)("div",{className:"mb-5 flex items-center justify-between border-b border-gray-100 pb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-gray-700",children:[(0,r.jsx)("svg",{className:"size-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),"Card details"]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"flex h-6 items-center justify-center rounded border border-gray-200 bg-white px-2 text-[10px] font-bold text-blue-800",children:"VISA"}),(0,r.jsx)("span",{className:"flex h-6 items-center justify-center rounded border border-gray-200 bg-white px-2 text-[10px] font-bold text-orange-600",children:"MC"})]})]}),!l&&(0,r.jsx)(e5,{}),(0,r.jsx)("form",{action:o,className:"paymentWidgets","data-brands":"VISA MASTER APPLEPAY"}),l&&(0,r.jsxs)("p",{className:"mt-3 flex items-center gap-1.5 text-xs text-gray-400",children:[(0,r.jsx)("svg",{className:"size-3 shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z",clipRule:"evenodd"})}),"SocialBoom does not store or process your card details — payments are handled securely by our external payment provider."]})]})}function e3({className:e="h-5 w-auto"}){return(0,r.jsxs)("svg",{viewBox:"0 0 56 24",className:e,"aria-label":"Google Pay",role:"img",children:[(0,r.jsx)("rect",{width:"56",height:"24",rx:"4",fill:"#f2f2f2"}),(0,r.jsxs)("g",{transform:"translate(4,3)",children:[(0,r.jsx)("path",{d:"M9.39 10.42V14.1H8.13V4.5h3.35a3.07 3.07 0 012.16.84 2.73 2.73 0 01.88 2.04 2.73 2.73 0 01-.88 2.06 3.04 3.04 0 01-2.16.85H9.39v.13zm0-4.7v3.43h2.13a1.78 1.78 0 001.34-.54 1.78 1.78 0 00.56-1.18 1.74 1.74 0 00-.56-1.17 1.76 1.76 0 00-1.34-.54H9.39z",fill:"#5f6368"}),(0,r.jsx)("path",{d:"M18.4 7.68a3.26 3.26 0 012.33.83 3.05 3.05 0 01.88 2.32v3.27h-1.2v-.74h-.05a2.45 2.45 0 01-2.04 1 2.36 2.36 0 01-1.63-.58 1.87 1.87 0 01-.67-1.47 1.78 1.78 0 01.7-1.47 2.9 2.9 0 011.84-.55 3.05 3.05 0 011.7.43v-.3a1.3 1.3 0 00-.47-.99 1.6 1.6 0 00-1.1-.42 1.69 1.69 0 00-1.47.79l-1.1-.7A2.87 2.87 0 0118.4 7.68zm-1.44 4.87a.88.88 0 00.38.72 1.36 1.36 0 00.85.29 1.8 1.8 0 001.27-.53 1.68 1.68 0 00.54-1.24 2.24 2.24 0 00-1.52-.44 1.96 1.96 0 00-1.12.32c-.28.2-.4.48-.4.88z",fill:"#5f6368"}),(0,r.jsx)("path",{d:"M27.05 7.93l-3.93 9.05h-1.3l1.46-3.15-2.59-5.9h1.37l1.79 4.35h.02l1.74-4.35h1.44z",fill:"#5f6368"}),(0,r.jsx)("path",{d:"M13.54 10.52a4.5 4.5 0 00-.07-.79h-4.3v1.5h2.46a2.1 2.1 0 01-.92 1.39v1.15h1.48a4.53 4.53 0 001.35-3.25z",fill:"#4285f4"}
266),(0,r.jsx)("path",{d:"M9.18 14.28a4.38 4.38 0 003.04-1.12l-1.48-1.15a2.76 2.76 0 01-1.56.44 2.72 2.72 0 01-2.56-1.88H5.1v1.19a4.57 4.57 0 004.08 2.52z",fill:"#34a853"}),(0,r.jsx)("path",{d:"M6.62 11.57a2.73 2.73 0 010-1.73V8.65H5.1a4.57 4.57 0 000 4.11l1.52-1.19z",fill:"#fbbc04"}),(0,r.jsx)("path",{d:"M9.18 7.96a2.48 2.48 0 011.75.69l1.3-1.31a4.38 4.38 0 00-3.05-1.19 4.57 4.57 0 00-4.08 2.5l1.52 1.19a2.72 2.72 0 012.56-1.88z",fill:"#ea4335"})]})]})}function e6({className:e="h-5 w-auto"}){return(0,r.jsxs)("svg",{viewBox:"0 0 56 24",className:e,"aria-label":"Apple Pay",role:"img",children:[(0,r.jsx)("rect",{width:"56",height:"24",rx:"4",fill:"#000"}),(0,r.jsxs)("g",{transform:"translate(6,3)",fill:"#fff",children:[(0,r.jsx)("path",{d:"M8.43 3.73a2.28 2.28 0 01-.52 1.63 1.93 1.93 0 01-1.52.76 2.18 2.18 0 01.54-1.58A2.3 2.3 0 018.43 3.73zm.56 1.1a2.54 2.54 0 00-1.22.35c-.34.18-.63.18-.87.18-.25 0-.52-.06-.83-.2a2.33 2.33 0 00-.84-.23 2.44 2.44 0 00-2.03 1.25 3.77 3.77 0 00.51 3.82c.34.48.72.99 1.22.98.49-.01.68-.32 1.06-.32.38 0 .55.32 1.06.31.53-.01.86-.48 1.2-.97a4.38 4.38 0 00.54-1.12 2.05 2.05 0 01-1.23-1.87 2.08 2.08 0 011-1.75 2.14 2.14 0 00-1.68-.88l.11.45z"}),(0,r.jsx)("path",{d:"M14.77 3.6v7.62h1.35V8.5h1.87a2.63 2.63 0 002.7-2.73 2.55 2.55 0 00-2.63-2.57h-3.29v.4zm1.35.92h1.56c1.08 0 1.7.58 1.7 1.59 0 1.01-.62 1.6-1.7 1.6h-1.56V4.52z"}),(0,r.jsx)("path",{d:"M24.2 11.35a2.1 2.1 0 001.81-.98v.85h1.16V7.2c0-1.23-.98-2.01-2.49-2.01a2.5 2.5 0 00-2.38 1.58l1.08.34c.17-.47.62-.78 1.22-.78.79 0 1.23.37 1.23 1.04v.46l-1.61.1c-1.5.09-2.31.71-2.31 1.78a1.83 1.83 0 001.95 1.64h-.66zm.34-.9c-.68 0-1.12-.33-1.12-.84 0-.53.42-.84 1.21-.89l1.43-.09v.56a1.4 1.4 0 01-1.52 1.26z"}),(0,r.jsx)("path",{d:"M28.64 14.91c1.14 0 1.68-.44 2.15-1.76l2.31-6.48H31.8l-1.55 5h-.05l-1.55-5H27.3l2.24 6.22-.12.39a.92.92 0 01-.98.72h-.33v1.04l.53-.13z"})]})]})}let e8={cardcorp:["visa","mastercard","applepay"],"rapyd-toolkit":["visa","mastercard","googlepay","applepay"],rapyd:["visa","mastercard","googlepay","applepay"],paytree:["visa","mastercard","googlepay","applepay"]},e7={visa:"Visa",mastercard:"Mastercard",googlepay:"Google Pay",applepay:"Apple Pay"},e9={visa:"/images/brands/visa.png",mastercard:"/images/brands/mastercard.png"},te={cardcorp:{visa:!0,mastercard:!1,applepay:!1}},tt=e=>{"Enter"===e.key&&e.preventDefault()};function tr({onProviderChange:e,selectedProvider:t,customerBalance:o,cartTotal:i,discountValue:l=0,discountType:d=s.DiscountType.PERCENT,isLoggedIn:c,cardcorpIframeParams:m,isLocked:p=!1}){let{config:h,isLoading:x}=e1(),f=(0,n.useSearchParams)().has("debug_payment"),y=t||h.defaultProvider,[g,b]=(0,a.useState)(h.checkoutMethodOrder),[v,w]=(0,a.useState)(y);(0,a.useEffect)(()=>{t&&w(t)},[t]),(0,a.useEffect)(()=>{t||x||w(h.defaultProvider)},[h.defaultProvider,x,t]),(0,a.useEffect)(()=>{b(h.checkoutMethodOrder)},[h.checkoutMethodOrder]);let j=f?[...g,...h.checkoutDebugMethods.filter(e=>!g.includes(e))]:g,N=i&&l>0?(0,u.applyDiscount)(i,l,d):i,k=t=>{w(t),e?.(t)},C=(e=>{switch(e){case"rapyd":return{name:"Rapyd",description:"Secure payment with Rapyd",color:"purple"};case"rapyd-toolkit":return{name:"Credit/Debit Card",description:"Pay securely with your credit or debit card",color:"blue"};case"cardcorp":return{name:"Visa/Mastercard",description:"Pay securely with your Visa or Mastercard credit/debit card",color:"blue"};case"balance":return{name:"Store Credit",description:"Pay with your account store balance, you will not be charged (the amount will only be deducted from your account balance)",color:"green"};default:return{name:"Credit/Debit Card",description:"Secure payment with Credit/Debit Card",color:"blue"}}})(v),S={blue:{bg:"bg-blue-50",border:"border-blue-200",text:"text-blue-900",icon:"text-blue-600"},purple:{bg:"bg-purple-50",border:"border-purple-200",text:"text-purple-900",icon:"text-purple-600"},green:{bg:"bg-green-50",border:"border-green-200",text:"text-green-900",icon:"text-green-600"}},P=S[C.color]||S.blue,I=e=>h.paymentGroups?.find(t=>t.key===e),$=(e,t)=>{let r=h.brandMarksEnabled?.[e]?.[t];if(void 0!==r)return r;let a=te[e]?.[t];return void 0===a||a},E=["visa","mastercard","googlepay","applepay"],L=e=>{let t=h.methodStatus[e];return t?.status!=="maintenance"&&("balance"===e?c&&void 0!==o&&void 0!==N:!!(h.checkoutEnabledMethods.includes(e)||f&&h.checkoutDebugMethods.includes(e)||I(e)))},R=e=>{let t=h.methodAmountLimits[e];return t&&null!=N?null!=t.min&&N<t.min?`Minimum amount: $${t.min.toFixed(2)}`:null!=t.max&&N>t.max?`Maximum amount: $${t.max.toFixed(2)}`:null:null},A=e=>!!L(e)&&("balance"===e?void 0!==o&&void 0!==N&&o>
266=N:!R(e)),z=j.some(L),M=j.find(A),O=void 0!==M,T=!x&&!A(v);return((0,a.useEffect)(()=>{!p&&T&&M&&k(M)},[p,T,M]),x)?(0,r.jsx)("div",{className:"space-y-3",children:[1,2].map(e=>(0,r.jsx)("div",{className:"h-[72px] animate-pulse rounded-xl border border-gray-200 bg-gray-100"},e))}):z?(0,r.jsxs)("div",{className:"grid grid-cols-1 gap-4",children:[(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("h3",{className:"text-sm font-medium text-gray-700",children:"Choose Payment Provider"}),!O&&(0,r.jsxs)("div",{className:"rounded-md border border-yellow-200 bg-yellow-50 p-4 text-sm text-yellow-800",children:[(0,r.jsx)("p",{className:"mb-1 font-medium text-yellow-900",children:"No payment method supports this order total"}),(0,r.jsxs)("p",{children:["None of the available payment methods support an order total of $",(N??0).toFixed(2),". Please adjust your order or contact support if you believe this is an error."]})]}),(0,r.jsx)("div",{className:`space-y-2 ${p?"pointer-events-none":""}`,children:j.map(e=>{let t=(e=>{if(!L(e))return null;let t=I(e),a=e.replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase()),s=t?{label:t.label||a,description:t.description||"Secure payment"}:eK[e]||{label:a,description:"Secure payment"},n=h.methodLabels[e]?{...s,label:h.methodLabels[e]}:s,i=v===e;if("balance"===e){let t=o<N;return(0,r.jsxs)("label",{"data-testid":"payment-method-option","data-item-id":e,className:`flex cursor-pointer items-center rounded-lg border p-2.5 transition-colors md:p-3 ${!t?"hover:bg-gray-50":"cursor-not-allowed opacity-50"}`,children:[(0,r.jsx)("input",{type:"radio",name:"paymentProvider","data-testid":"payment-method-input",value:e,checked:i,onChange:()=>!t&&k(e),onKeyDown:tt,disabled:t,className:"sr-only"}),(0,r.jsx)("div",{className:`mr-3 flex size-4 items-center justify-center rounded-full border-2 ${i?"border-green-600 bg-green-600":"border-gray-300"}`,children:i&&(0,r.jsx)("div",{className:"size-2 rounded-full bg-white"})}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsx)("div",{className:"font-medium text-gray-900",children:n.label}),(0,r.jsxs)("div",{className:"text-xs text-gray-500 md:text-sm",children:["Available: $",o.toFixed(2),t&&(0,r.jsx)("span",{className:"ml-1 text-red-500",children:"(Insufficient funds)"})]})]})]},e)}let l=R(e),d=!!l,c=h.methodStatus[e],u=c?.status==="degraded",m=t?.icon,p=((e,t)=>{if(t){let e=t.brandMarksEnabled;if(e&&Object.keys(e).length>0)return E.filter(t=>!0===e[t]);let r=new Set;for(let e of t.providers)for(let t of e8[e]||[])$(e,t)&&r.add(t);return E.filter(e=>r.has(e))}return(e8[e]||[]).filter(t=>$(e,t))})(e,t);return(0,r.jsx)("div",{children:(0,r.jsxs)("label",{"data-testid":"payment-method-option","data-item-id":e,className:`flex cursor-pointer items-start gap-3 rounded-lg border p-2.5 transition-colors md:items-center md:p-3 ${d?"cursor-not-allowed opacity-50":"hover:bg-gray-50"}`,children:[(0,r.jsx)("input",{type:"radio",name:"paymentProvider","data-testid":"payment-method-input",value:e,checked:i,onChange:()=>!d&&k(e),onKeyDown:tt,disabled:d,className:"sr-only"}),(0,r.jsx)("div",{className:`mt-0.5 flex size-4 shrink-0 items-center justify-center rounded-full border-2 md:mt-0 ${i?"border-blue-600 bg-blue-600":"border-gray-300"}`,children:i&&(0,r.jsx)("div",{className:"size-2 rounded-full bg-white"})}),(0,r.jsxs)("div",{className:"flex-1",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-medium text-gray-900 md:text-base",children:[m&&(m.startsWith("http")?(0,r.jsx)("img",{src:m,alt:"",className:"h-5 w-auto"}):(0,r.jsx)("span",{className:"text-base",children:m})),n.label]}),p.length>0&&(0,r.jsx)("div",{className:"flex items-center gap-1",children:p.map(a=>((e,t,a)=>{let s=a?.brandIcons?.[t]||h.brandIcons?.[e]?.[t]||h.brandIconDefaults?.[t]||void 0;if(s)return(0,r.jsx)("img",{src:s,alt:e7[t]||t,className:"h-3 w-auto",width:20,height:12},t);if("googlepay"===t)return(0,r.jsx)(e3,{className:"h-4 w-auto"},t);if("applepay"===t)return(0,r.jsx)(e6,{className:"h-4 w-auto"},t);let o=e9[t];return o?(0,r.jsx)("img",{src:o,alt:e7[t]||t,className:"h-3 w-auto",width:20,height:12},t):null})(e,a,t))})]}),(0,r.jsx)("div",{className:"text-xs text-gray-500",children:n.description}),d&&(0,r.jsx)("div",{className:"mt-0.5 text-xs text-red-500",children:l}),u&&c?.message&&(0,r.jsx)("div",{className:"mt-0.5 text-xs text-amber-600",children:c.message})]})]})},e)})(e);if(!t||!p)return t;let a=v===e;return(0,r.jsx)("div",{className:a?"":"opacity-40",children:t},e)})}),m&&(0,r.jsx)("div",{className:"mt-2 rounded-lg border border-blue-200 bg-white p-0 sm:p-4",children:(0,r.jsx)(e4,{checkoutId:m.checkoutId,integrity:m.integrity,scriptSrc:m.scriptSrc,shopperResultUrl:`${window.location.origin}/checkout/cardcorp/result?checkoutId=${encodeURIComponent(m.checkoutId)}&token=${encodeURIComponent(m.retryToken)}`,amount:(N??0).toFixed(2),currencyCode:"USD"})})]}),!m&&(0,r.jsxs)("div",{className:`flex w-full items-center justify-between rounded-md border px-3 py-2.5 text-left text-sm font-medium md:px-4 md:py-3 ${P.bg} ${P.border} ${P.text}`,children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("svg",{className:`size-5 ${P.icon}
266`,fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M2.166 4.999A11.954 11.954 0 0010 1.944 11.954 11.954 0 0017.834 5c.11.65.166 1.32.166 2.001 0 5.225-3.34 9.67-8 11.317C5.34 16.67 2 12.225 2 7c0-.682.057-1.35.166-2.001zm11.541 3.708a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})}),(0,r.jsx)("span",{className:"font-medium",children:C.description})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:["balance"===v&&(0,r.jsx)("svg",{className:"size-6 text-green-600",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M4 4a2 2 0 00-2 2v4a2 2 0 002 2V6h10a2 2 0 00-2-2H4zm2 6a2 2 0 012-2h8a2 2 0 012 2v4a2 2 0 01-2 2H8a2 2 0 01-2-2v-4zm6 4a2 2 0 100-4 2 2 0 000 4z",clipRule:"evenodd"})}),("rapyd"===v||"rapyd-toolkit"===v)&&(0,r.jsx)("span",{className:"rounded bg-white px-2 py-0.5 text-xs font-semibold text-purple-700",children:"Rapyd"})]})]}),(0,r.jsxs)("p",{className:"mt-2 flex items-center gap-1 text-xs text-gray-500",children:[(0,r.jsx)("svg",{className:"size-3",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z",clipRule:"evenodd"})}),"Your payment information is encrypted and secure"]})]}):(0,r.jsxs)("div",{className:"rounded-md border border-yellow-200 bg-yellow-50 p-4 text-sm text-yellow-800",children:[(0,r.jsx)("p",{className:"mb-1 font-medium text-yellow-900",children:"No payment methods available"}),(0,r.jsx)("p",{children:"There are no payment methods available at this time. Please come back later or contact support if you believe this is an error."})]})}function ta({selectedPaymentProvider:e,onProviderChange:t,isLoggedIn:a,customerBalance:o,cartTotal:n,discountValue:i=0,discountType:l=s.DiscountType.PERCENT,cardcorpIframeParams:d,isLocked:c=!1}){let{config:u}=e1();return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("label",{htmlFor:"payment-method",className:"block pt-3 text-base font-semibold text-gray-900 md:pt-4 md:text-lg md:font-bold",children:"Payment method"}),u.showGatewayIssuesMessage&&(0,r.jsxs)("div",{className:"flex items-start gap-3 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3",children:[(0,r.jsx)(eq,{className:"mt-0.5 size-5 shrink-0 text-amber-500"}),(0,r.jsxs)("div",{className:"text-sm text-amber-800",children:[(0,r.jsx)("span",{className:"font-semibold",children:"We are experiencing issues with our payment gateways."})," ",a?"Some payment methods may be temporarily unavailable. You can still pay using your store credit balance.":"Some payment methods may be temporarily unavailable. Please try again later or contact support."]})]}),(0,r.jsx)(tr,{onProviderChange:t,selectedProvider:e,isLoggedIn:a,customerBalance:o,cartTotal:n,discountValue:i,discountType:l,cardcorpIframeParams:d,isLocked:c})]})}let ts=async()=>await fetch(`${(0,$.getApiUrl)()}/users/me`,{method:"GET",headers:(0,$.getHeaders)()}),to="sb_checkout_form",tn="sb_guest_profiles";function ti(){try{let e=localStorage.getItem(tn);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function tl(e){try{localStorage.setItem(tn,JSON.stringify(e))}catch{}}var td=e.i(55263),tc=e.i(62032);function tu(){return(0,r.jsx)("div",{className:"animate-pulse space-y-4 py-1",children:(0,r.jsx)("div",{className:"h-[300px] rounded-lg bg-gray-100"})})}function tm({checkoutId:e,onSuccess:s,onFailure:o}){let n=(0,tc.useTenant)(),[i,l]=(0,a.useState)(!1),[d,c]=(0,a.useState)(null),u=(0,a.useRef)(null),m=(0,a.useRef)(null),p=(0,a.useRef)(s),h=(0,a.useRef)(o);return((0,a.useEffect)(()=>{p.current=s},[s]),(0,a.useEffect)(()=>{h.current=o},[o]),(0,a.useEffect)(()=>{let r=!1,a=e=>{let t=e.detail;p.current?.(t)},s=e=>{let t=e.detail?.error||"Payment failed";console.error("[Rapyd] Payment failure:",t),h.current?.(t)},o=e=>{let t=e.detail?.error||"Checkout failed";console.error("[Rapyd] Checkout failure:",t),h.current?.(t)},i=()=>{console.error("[Rapyd] Payment expired"),h.current?.("Payment session expired. Please try again.")};window.addEventListener("onCheckoutPaymentSuccess",a),window.addEventListener("onCheckoutPaymentFailure",s),window.addEventListener("onCheckoutFailure",o),window.addEventListener("onCheckoutPaymentExpired",i);let d="true"===t.default.env.NEXT_PUBLIC_RAPYD_SANDBOX?"https://sandboxcheckouttoolkit.rapyd.net":"https://checkouttoolkit.rapyd.net",x=document.createElement("div");x.id="rapyd-checkout",(m.current??document.body).appendChild(x);let f=()=>{if(!r)try{let t=window.RapydCheckoutToolkit;if(!t)return void c("Rapyd Checkout Toolkit not available");let a=new t({pay_button_text:"Pay Now",pay_button_color:n.primaryColor,id:e,close_on_complete:!0,wait_on_payment_redirect:!0,style:{submit:{base
266:{color:"white"}}}});if(r)return;u.current=a,a.displayCheckout(),l(!0)}catch(e){console.error("[Rapyd] Toolkit init error:",e),r||c("Failed to initialize payment form")}},y=document.querySelector(`script[src="${d}"]`),g=y??document.createElement("script");return y?window.RapydCheckoutToolkit?f():(g.addEventListener("load",f,{once:!0}),g.addEventListener("error",()=>{r||c("Failed to load payment form")},{once:!0})):(g.src=d,g.async=!0,g.onload=f,g.onerror=()=>{r||c("Failed to load payment form")},document.body.appendChild(g)),()=>{r=!0,window.removeEventListener("onCheckoutPaymentSuccess",a),window.removeEventListener("onCheckoutPaymentFailure",s),window.removeEventListener("onCheckoutFailure",o),window.removeEventListener("onCheckoutPaymentExpired",i);try{let e=u.current;e?.closeCheckout?e.closeCheckout():e?.close&&e.close()}catch{}u.current=null;try{x.remove()}catch{}document.querySelectorAll('[class*="rapyd-checkout-overlay"], [class*="rapyd-modal"]').forEach(e=>e.remove())}},[e]),d)?(0,r.jsx)("div",{className:"rounded-lg border border-red-200 bg-red-50 p-4 text-sm text-red-700",children:d}):(0,r.jsxs)("div",{className:"w-full",children:[(0,r.jsx)("div",{className:"mb-5 flex items-center justify-between border-b border-gray-100 pb-4",children:(0,r.jsxs)("div",{className:"flex items-center gap-2 text-sm font-medium text-gray-700",children:[(0,r.jsx)("svg",{className:"h-4 w-4 text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"})}),"Secure payment"]})}),!i&&!d&&(0,r.jsx)(tu,{}),(0,r.jsx)("div",{ref:m}),i&&(0,r.jsxs)("p",{className:"mt-3 flex items-center gap-1.5 text-xs text-gray-400",children:[(0,r.jsx)("svg",{className:"h-3 w-3 shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z",clipRule:"evenodd"})}),"Your card details are handled securely by Rapyd and never stored on our servers."]})]})}function tp({index:e,currentStep:t,stepKey:a,cardRef:s,children:o}){let n=e===t;return(0,r.jsx)("div",{ref:s,"data-testid":a?`checkout-step-${a}`:void 0,"data-step-active":n,className:"absolute inset-x-0 top-0 w-full",inert:!n,"aria-hidden":!n,children:(0,r.jsx)("div",{className:"transition-[transform,opacity] duration-300 ease-in-out",style:{transform:n?"none":`translateX(${(e-t)*100}%)`,opacity:+!!n},children:o})})}function th({showBack:e,onBack:t,children:a}){return(0,r.jsxs)("div",{"data-testid":"checkout-step-nav",className:"flex items-center justify-between gap-4 border-t border-gray-100 pt-4 md:pt-6",children:[e?(0,r.jsx)("button",{type:"button","data-testid":"checkout-back",onClick:t,className:"rounded-md border border-gray-300 px-6 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 cursor-pointer",children:"← Back"}):(0,r.jsx)("span",{}),a]})}e.s(["default",0,function(e){var o;let d,x,y,{mainCategoryNode:g,cart:b,orderSummary:j,productSelectorProps:N}=e,k=(0,n.useSearchParams)(),{config:C}=e1(),{format:S,showRegionalPrices:P}=(0,E.useRegionPrice)();o="checkout-form",d=(0,a.useRef)(null),x=(0,a.useCallback)(()=>{let e=document.getElementById(o);if(!e)return;let t=new FormData(e),r={};t.forEach((e,t)=>{"string"==typeof e&&e.trim()&&(r[t]=e)});try{localStorage.setItem(to,JSON.stringify(r))}catch{}},[o]),y=(0,a.useCallback)(()=>{try{let e=localStorage.getItem(to);if(!e)return;let t=JSON.parse(e),r=document.getElementById(o);if(!r)return;Object.entries(t).forEach(([e,t])=>{let a=r.elements.namedItem(e);a&&a instanceof HTMLInputElement&&!a.value&&(a.value=t)})}catch{}},[o]),(0,a.useCallback)(()=>{try{localStorage.removeItem(to)}catch{}},[]),(0,a.useEffect)(()=>{let e,t=null,r=()=>{d.current&&clearTimeout(d.current),d.current=setTimeout(x,2e3)},a=setTimeout(()=>{e=requestAnimationFrame(()=>y()),t=document.getElementById(o),t?.addEventListener("input",r)},100);return()=>{clearTimeout(a),e&&cancelAnimationFrame(e),t?.removeEventListener("input",r),d.current&&clearTimeout(d.current)}},[o,x,y]);let{profiles:$,saveProfile:L,removeProfile:R}=function(){let[e,t]=(0,a.useState)([]);return(0,a.useEffect)(()=>{t(ti())},[]),{profiles:e,saveProfile:(0,a.useCallback)(e=>{if(!e.email)return;let r=ti().filter(t=>t.email!==e.email),a=[{...e,savedAt:Date.now()},...r].slice(0,5);tl(a),t(a)},[]),removeProfile:(0,a.useCallback)(e=>{let r=ti().filter(t=>t.email!==e);tl(r),t(r)},[])}}(),[A,z]=(0,a.useState)(C.defaultProvider),[M,O]=(0,a.useState)(!1),T=(0,a.useCallback)(e=>{z(e),O(!0)},[]),[U,D]=(0,a.useState)(!1),[V,F]=(0,a.useState)(0),[_,B]=(0,a.useState)(s.DiscountType.PERCENT),[H,G]=(0,a.useState)(null),[W,q]=(0,a.useState)(null),[K,Y]=(0,a.useState)(""),[J,X]=(0,a.useState)(!1),Z=(0,a.useRef)(null),[Q,ee]=(0,a.useState)(b),[et,er]=(0,a.useState)(!1),[ea,es]=(0,a.useState)(void 0),[eo,en]=(0,a.useState)(null);(0,a.useEffect)(()=>{let e=!1;return(0,c.fetchCurrentCart)().then(t=>{!e&&t&&ee(t)}),()=>{e=!0}},[]),(0,a.useEffect)(()=>{let e=function(){if("u"<typeof document)return null;let e=document.cookie.match(/(?:^|;\s*)sb_access_token=([^;]*)/);return e?decodeURIComponent(e[1]):null}();if(!e)return;en(e);let t=!1;return ts().then(async e=>e.ok?e.json():((401===e.status||403===e.status)&&(!function(){if("u"<typeof document)return;let e="Thu, 01 Jan 1970 00:00:00 GMT";document.cookie=`sb_access_token=; path=/; expires=${e}`;let t=window.location.hostname.split(".").slice(-2).join(".");document.cookie=`sb_access_token=; path=/; domain=.${t}; expires=${e}`}(),t||en(null)),null)).then(e=>{!t&&e&&(er(!0),es((e.currentBalance??0).toString()))}).catch(()=>{}),()=>{t=!0}},[]);let ei=(0,a.useCallback)(e=>{ee(e);let t=(e.lineItems??[]).map(e=>e.id);(0,I.prunePostSelections)(t)&&(0,I.emitPostSelectionUpdate)()},[]);(0,u.useCartUpdateListener)(ei);let el=(0,a.useMemo)(()=>
266{if(Q?.lineItems?.length)return Q.lineItems.reduce((e,t)=>e+t.unitPrice,0)/Q.lineItems.length},[Q]),ed=(0,a.useCallback)((e,t,r)=>{F(t),B(r)},[]);(0,u.useCouponChangeListener)(ed);let ec=(0,u.useCartOperationLock)();(0,a.useEffect)(()=>{H||W?(0,u.lockCartOperation)():(0,u.unlockCartOperation)()},[H,W]);let{error:eu,setError:em,cartEntityId:ep,isLoading:eh}=function(e){let t=(0,n.useSearchParams)(),[r,s]=(0,a.useState)("Checking cart..."),[o,i]=(0,a.useState)(!0),l=t.get("cancelled");(0,a.useEffect)(()=>{"true"===l&&s("Payment was cancelled. You can continue with your checkout below.")},[l]),(0,a.useEffect)(()=>{i(!0);let t=e&&e.lineItems?.length>0;e?.id&&t?s(null):s("Add items to your cart first"),i(!1)},[e]);let d=e?.id??null;return{error:r,setError:s,cartId:d,cartEntityId:d,isLoading:o}}(Q),{country:ef,countryISO:ey,selectedState:ev,handleCountryChange:ew,handleStateChange:ej}=function(){let[e,t]=(0,a.useState)(null),[r,s]=(0,a.useState)(""),[o,n]=(0,a.useState)(null);return{country:e,countryISO:r,selectedState:o,handleCountryChange:e=>{t(e),s(e?e.code:""),n(null)},handleStateChange:e=>{n(e)}}}(),{validateServiceUrls:eN,validateUserInfo:ek,validateTermsAcceptance:eC,validatePostalCodeAsync:eS}=eL(),{individualServices:eA,comboItems:eM,customItems:eO}=(0,a.useMemo)(()=>(function(e){if(!e||!e.lineItems?.length)return{individualServices:[],comboItems:[],customItems:[]};let t=[],r=e.lineItems,a=new Map;r.forEach(e=>{let r=e.productName.split(" ");if(r.length>=3){let s=parseInt(r[0]);if(!isNaN(s)){let o=r[1],n=r[2],i=`${o}-${n}`,l=v(e.productName),d=(a.get(l)||0)+1;a.set(l,d),t.push({id:e.id,name:e.productName,service:i,productQuantity:s,index:d,mainCategory:o,categoryName:n,description:""})}}});let s=r.filter(e=>isNaN(parseInt(e.productName.split(" ")[0])));return{individualServices:t,comboItems:s.filter(e=>!e.productName.toLowerCase().includes("custom")).map(e=>({id:e.id,name:e.productName,quantity:1})),customItems:s.filter(e=>e.productName.toLowerCase().includes("custom")).map(e=>({id:e.id,name:e.productName,quantity:1}))}})(Q),[Q]),eT=(0,a.useMemo)(()=>{let e=Q&&Q.lineItems?.length>0;return!ep||!e},[Q,ep]),{handleSubmit:eD,isProcessingPayment:eV,resetProcessingPayment:eF}=function({cartEntityId:e,cart:r,isLoggedIn:s,selectedPaymentProvider:o,paymentGroups:n,countryISO:i,selectedState:l,individualServices:d,comboItems:c,customItems:x,acceptTerms:y,setError:g,recaptchaToken:b,onRecaptchaReset:j,onRequiresCaptcha:N,onCardCorpIframe:k,onRapydToolkit:C}){let[S,P]=(0,a.useState)(!1),[I,$]=(0,a.useState)(null),[E,L]=(0,a.useState)(null),R=n?.find(e=>e.key===o),A=R?.key||(f(o)?void 0:o),{validateServiceUrls:z,validateUserInfo:M,validateCart:O,validateTermsAcceptance:T,validatePostalCodeAsync:U}=eL();return{handleSubmit:async e=>{e.preventDefault();try{localStorage.removeItem("sb_checkout_form")}catch{}P(!0),g(null),(0,u.lockCartOperation)();let a=new FormData(e.currentTarget);try{let e,n=T(y,s);if(!n.isValid){g(n.error),P(!1),(0,u.unlockCartOperation)();return}let S=z(a,d,c,x);if(!S.isValid){g(S.error),P(!1),(0,u.unlockCartOperation)();return}let R=M(a,s);if(!R.isValid){g(R.error),P(!1),(0,u.unlockCartOperation)();return}let D=O(r);if(!D.isValid){g(D.error),P(!1),(0,u.unlockCartOperation)();return}let V=await U(a.get("postalCode"),i,l?.code||null,s);if(!V.isValid){g(V.error),P(!1),(0,u.unlockCartOperation)();return}let F=function(e,t,r,a,s,o,n=[],i=[],l=[],d){let c=function(e,t,r){let a=new Map;for(let{key:s,url:o}of e){let e,n="none",i=1;if(s.startsWith("service-url-custom-order-"))e=s.replace("service-url-custom-order-","").split("-")[0],n="custom";else if(s.startsWith("service-url-combo-")){let t=w(r),a=s.match(/^service-url-combo-(.+)-(\d+)-(profile|video)-(\d+)$/);if(a){let[,r,s,o,l]=a,d=t.find(e=>e.nameSlug===r&&e.index===parseInt(s));e=d?.itemId,n=o,i=parseInt(l)}}else if(s.startsWith("service-url-")){let r=s.replace("service-url-",""),a=t.find(e=>r===`${v(e.name)}-${e.index}`);e=a?.id}if(!e)continue;let l=a.get(e)||[];l.push({url:o,type:n,belongs:i}),a.set(e,l)}return Array.from(a.entries()).map(([e,t])=>({lineItemId:e,urls:t}))}(t,n,i),u=e.get("postalCode"),m=(0,p.getGuestPostReferer)(),x=d||(f(o)?void 0:o),y={...x?{paymentGroup:x}:{paymentMethod:h[o]||o},...r&&!u?{}
266:{billingAddress:{country:a||"US",state:s?.code||"",zip:String(u||"")}},lineItemUrls:c,...m?{referer:m}:{}};return r?y:{...y,guestFirstName:e.get("firstName")||"",guestLastName:e.get("lastName")||"",guestEmail:e.get("email")||""}}(a,S.urls,s,i,l,o,d,c,x,A);if(b&&(F.paymentMetadata={...F.paymentMetadata,recaptchaToken:b}),I){let t=await eE(I,h[o]||o,E||void 0,A);if(!t.ok){let e=await t.json();g(e.message||"Failed to retry payment. Please try again."),P(!1),(0,u.unlockCartOperation)();return}e=await t.json()}else{let t;if(s)t=await eI(F);else{let e=(0,m.getCartSessionId)();if(!e){g("Cart session not found. Please refresh the page."),P(!1),(0,u.unlockCartOperation)();return}t=await e$(e,F)}if(!t.ok){let e=await t.json();e.requiresCaptcha&&N?.(),j(),g(e.message||e.error||"Failed to create checkout. Please try again or use another payment method."),P(!1),(0,u.unlockCartOperation)();return}e=await t.json()}$(e.orderId),L(e.retryToken||null);let _=e.paymentSession?.method;if(e.paymentSession?.provider==="rapyd"&&("rapyd_toolkit"===_||!_&&"rapyd-toolkit"===o)&&C){C({checkoutId:e.paymentSession.sessionId,orderId:e.orderId}),(0,u.unlockCartOperation)();return}if(e.paymentSession?.provider==="cardcorp"&&k){k({checkoutId:e.paymentSession.sessionId,integrity:e.paymentSession.integrity||"",scriptSrc:e.paymentSession.scriptSrc||"",retryToken:e.retryToken||""}),(0,u.unlockCartOperation)();return}if(e.paymentSession?.provider==="balance"){(0,u.unlockCartOperation)(),window.location.href=`/checkout/complete?t=${Date.now()}`;return}let B=e.paymentSession?.redirectUrl;if(B){e.retryToken&&sessionStorage.setItem("sb_payment_retry_token",e.retryToken),(0,u.unlockCartOperation)();let r=window.location.href;ez(r),window.location.href=function(e,r){let a=e,s=e.includes("/checkout/loading?url="),o=e.startsWith(eR());if(!s&&!o&&t.default.env.NEXT_PUBLIC_PAYMENT_DOMAIN){let t=btoa(e);a=`${eR()}/checkout/loading?url=${t}`}if(r&&!a.includes("ref=")){let e=a.includes("?")?"&":"?";a=`${a}${e}ref=${encodeURIComponent(r)}`}return a}(B,r)}else console.error("No payment URL received from checkout data"),g("No payment URL received"),P(!1),(0,u.unlockCartOperation)()}catch(e){console.error("Error in checkout process:",e),g("Failed to process checkout. Please try again."),P(!1),(0,u.unlockCartOperation)()}},isProcessingPayment:S,pendingOrderId:I,resetProcessingPayment:()=>P(!1)}}({cartEntityId:ep,cart:Q,isLoggedIn:et,selectedPaymentProvider:A,paymentGroups:C.paymentGroups,countryISO:ey,selectedState:ev,individualServices:eA,comboItems:eM,customItems:eO,acceptTerms:U,setError:em,recaptchaToken:K,onRecaptchaReset:()=>{Z.current?.reset(),Y("")},onRequiresCaptcha:()=>X(!0),onCardCorpIframe:e=>{ez(window.location.href),G(e)},onRapydToolkit:e=>{ez(window.location.href),q(e)}}),e_=k.get("service")||"Views",eB=(0,a.useCallback)(e=>"balance"===e?et&&void 0!==ea&&Q?.totalAmount!==void 0:!!C.paymentGroups?.some(t=>t.key===e)||C.checkoutEnabledMethods.includes(e),[et,ea,Q?.totalAmount,C]),eH=C.checkoutMethodOrder.some(eB);(0,a.useEffect)(()=>{if(M)return;let e=eB(C.defaultProvider)?C.defaultProvider:C.checkoutMethodOrder.find(eB);e&&z(e)},[C.defaultProvider,C.checkoutMethodOrder,M,eB]);let eG=!et,eq=!eh&&!eT,eK=!N||eq,eY=(0,a.useMemo)(()=>{let e=[];return N&&e.push({key:"products",title:"Choose amount"}),eK&&e.push({key:"services",title:"Your services",subtitle:"Select multiple"}),eq&&(eG&&e.push({key:"details",title:"Your details"}),e.push({key:"payment",title:"Payment"})),e},[N,eK,eq,eG]),[eJ,eX]=(0,a.useState)(0);(0,a.useEffect)(()=>{eX(e=>Math.min(e,eY.length-1))},[eY.length]);let[eZ,eQ]=(0,a.useState)(0);(0,u.useProductAddedListener)((0,a.useCallback)(()=>eQ(e=>e+1),[])),(0,a.useEffect)(()=>{0!==eZ&&eY[eJ]?.key==="products"&&eX(e=>Math.min(eY.length-1,e+1))},[eZ]);let e0=(0,a.useRef)([]),[e2,e5]=(0,a.useState)(void 0);(0,a.useLayoutEffect)(()=>{let e=e0.current[eJ];if(!e)return;let t=()=>e5(e.offsetHeight);t();let r=new ResizeObserver(t);return r.observe(e),()=>r.disconnect()},[eJ,eY.length]);let e4=(0,a.useCallback)(e=>{let t=document.getElementById("checkout-form");if(t){for(let[r,a]of Object.entries({email:e.email,firstName:e.firstName,lastName:e.lastName,postalCode:e.postalCode})){let e=t.elements.namedItem(r);e instanceof HTMLInputElement&&(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,"value").set.call(e,a),e.dispatchEvent(new Event("input",{bubbles:!0})))}e.countryCode&&e.countryName&&(ew({code:e.countryCode,name:e.countryName}),e.stateCode&&e.stateName&&setTimeout(()=>ej({code:e.stateCode,name:e.stateName}),100))}},[ew,ej]),e3=(0,a.useRef)(1),e6=(0,a.useCallback)(()=>{e3.current=-1,em(null),eX(e=>{let t=Math.max(0,e-1);return setTimeout(()=>{let e=e0.current[t]||document.getElementById("checkout-card");e&&window.scrollTo({top:e.getBoundingClientRect().top+window.scrollY-160,behavior:"smooth"})},50),t})},[em]),e8=(0,a.useCallback)(async()=>{e3.current=1,em(null);let e=document.getElementById("checkout-form"),t=e?new FormData(e):new FormData,r=eY[eJ]?.key;if("products"===r){if(eT)return void em("Add at least one item to continue")}else if("services"===r){let e=eN(t,eA,eM,eO);if(!e.isValid)return void em(e.error)}else if("details"===r){let e=ek(t,et);if(!e.isValid)return void em(e.error);let r=eC(U,et);if(!r.isValid)return void em(r.error);let a=await eS(t.get("postalCode"),ey,ev?.code||null,et);if(!a.isValid)return void em(a.error);L({email:String(t.get("email")||""),firstName:String(t.get("firstName")||""),lastName:String(t.get("lastName")||""),postalCode:String(t.get("postalCode")||""),countryCode:ef?.code,countryName:ef?.name,stateCode:ev?.code,stateName:ev?.name})}eX(e=>{let t=Math.min(eY.length-1,e+1);return setTimeout(()=>{let e=e0.current[t]||document.getElementById("checkout-card");e&&window.scrollTo({top:e.getBoundingClientRect().top+window.scrollY-160,behavior:"smooth"})},50),t})},[eY,eJ,eT,eA,eM,eO,et,U,ey,ef,ev,em,eN,ek,eC,eS,L]),e7=eY[eJ]?.key;return(0,r.jsxs)("div",{className:"flex w-full flex-col gap-4 md:gap-6",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[N?(0,r.jsx)("span",{}):(0,r.jsx)(i,{label:"Back to Services",platform:g.name,service:e_}),(0,r.jsx)(l,{customerAccessToken:eo})]}),(0,r.jsx)("div",{className:"products"===e7?"hidden":void 0,children:j}),eY.length>1&&(0,r.jsx)(eb,{steps:eY,currentStep:eJ,onStepClick:e=>{e<eJ&&(e3.current=-1,em(null),eX(e))}}),(0,r.jsxs)("div",{className:"relative overflow-hidden transition-[height] duration-300 ease-in-out",style:{height:void 0!==e2?e2:"auto"},children:[(0,r.jsx)("form",{id:"checkout-form",onSubmit:eD,className:"contents",children:eY.map((e,t)=>"services"===e.key?(0,r.jsx)(tp,{index:t,currentStep:eJ,stepKey:e.key,cardRef:e=>{e0.current[t]=e},children:(0,r.jsxs)("div",{className:eJ===t?"fixed inset-0 z-50 overflow-y-auto bg-white px-2 py-3 pb-20 sm:static sm:z-auto sm:p-0 sm:pb-0":"",children:[eJ===t&&(0,r.jsx)("div",{className:"mb-4 sm:hidden",children:j}),(0,r.jsxs)("div",{className:"mb-3 flex items-center gap-2 sm:hidden",children:[(0,r.jsx)("svg",{className:"size-5 text-green-600",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z",clipRule:"evenodd"})}),(0,r.jsx)("h2",{className:"text-lg font-bold text-gray-900",children:"Secure Checkout"})]}),(0,r.jsxs)(eg,{step:t+1,title:e.title,subtitle:e.subtitle,children:[(0,r.jsx)(ex,{mainCategoryNode:g,targetPrice
266:el}),eh?(0,r.jsx)("div",{className:"space-y-6",children:[1,2,3].map(e=>(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"h-6 w-32 animate-pulse rounded bg-gray-200"}),(0,r.jsx)("div",{className:"h-10 animate-pulse rounded bg-gray-200"})]},e))}):eT?(0,r.jsx)("p",{className:"text-red-500",children:"Add items to your cart first"}):(0,r.jsxs)(r.Fragment,{children:[eu&&"services"===e7&&(0,r.jsx)("p",{className:"text-red-500",children:eu}),(0,r.jsx)(eU,{individualServices:eA,comboItems:eM,customItems:eO})]}),eY.length>1&&!eh&&!eT&&(0,r.jsx)(th,{showBack:t>0,onBack:e6,children:(0,r.jsx)("button",{type:"button","data-testid":"checkout-next",onClick:e8,className:"rounded-md border-2 border-primary/80 bg-primary px-6 py-2 text-sm font-bold text-white shadow-md duration-300 hover:scale-105 hover:opacity-90 cursor-pointer",children:"Next →"})})]})]})},e.key):"details"===e.key?(0,r.jsx)(tp,{index:t,currentStep:eJ,stepKey:e.key,cardRef:e=>{e0.current[t]=e},children:(0,r.jsxs)("div",{className:eJ===t?"fixed inset-0 z-50 overflow-y-auto bg-white px-2 py-3 pb-20 sm:static sm:z-auto sm:p-0 sm:pb-0":"",children:[eJ===t&&(0,r.jsx)("div",{className:"mb-4 sm:hidden",children:j}),(0,r.jsxs)("div",{className:"mb-3 flex items-center gap-2 sm:hidden",children:[(0,r.jsx)("svg",{className:"size-5 text-green-600",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z",clipRule:"evenodd"})}),(0,r.jsx)("h2",{className:"text-lg font-bold text-gray-900",children:"Secure Checkout"})]}),(0,r.jsxs)(eg,{step:t+1,title:e.title,children:[(0,r.jsx)(ex,{mainCategoryNode:g,targetPrice:el}),(0,r.jsx)(eW,{isLoggedIn:et,country:ef,selectedState:ev,onCountryChange:ew,onStateChange:ej,acceptTerms:U,onAcceptTermsChange:D,savedProfiles:$,onSelectProfile:e4,onRemoveProfile:R}),(0,r.jsx)(th,{showBack:t>0,onBack:e6,children:(0,r.jsx)("button",{type:"button","data-testid":"checkout-next",onClick:e8,className:"rounded-md border-2 border-primary/80 bg-primary px-6 py-2 text-sm font-bold text-white shadow-md duration-300 hover:scale-105 hover:opacity-90 cursor-pointer",children:"Next →"})})]})]})},e.key):null)}),eY.map((e,t)=>"products"===e.key?(0,r.jsx)(tp,{index:t,currentStep:eJ,stepKey:e.key,cardRef:e=>{e0.current[t]=e},children:(0,r.jsx)(eg,{step:t+1,title:e.title,children:N&&(0,r.jsx)(eP,{...N,isCartEmpty:eT,nextButton:eT?null:(0,r.jsx)("button",{type:"button","data-testid":"checkout-next",onClick:e8,className:"rounded-md border-2 border-black bg-black px-6 py-2 text-sm font-bold text-white shadow-md duration-300 hover:scale-105 hover:opacity-90 cursor-pointer",children:"Next →"})})})},e.key):null),eY.map((e,t)=>"payment"===e.key?(0,r.jsx)(tp,{index:t,currentStep:eJ,stepKey:e.key,cardRef:e=>{e0.current[t]=e},children:(0,r.jsxs)("div",{className:eJ===t?"fixed inset-0 z-50 overflow-y-auto bg-white px-2 py-3 pb-20 sm:static sm:z-auto sm:p-0 sm:pb-0":"",children:[eJ===t&&(0,r.jsx)("div",{className:"mb-4 sm:hidden",children:j}),(0,r.jsxs)("div",{className:"mb-3 flex items-center gap-2 sm:hidden",children:[(0,r.jsx)("svg",{className:"size-5 text-green-600",fill:"currentColor",viewBox:"0 0 20 20",children:(0,r.jsx)("path",{fillRule:"evenodd",d:"M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z",clipRule:"evenodd"})}),(0,r.jsx)("h2",{className:"text-lg font-bold text-gray-900",children:"Secure Checkout"})]}),(0,r.jsxs)(eg,{step:t+1,title:e.title,children:[(0,r.jsx)(ex,{mainCategoryNode:g,targetPrice:el}),(0,r.jsx)(ta,{selectedPaymentProvider:A,onProviderChange:T,isLoggedIn:et,customerBalance:Number(ea),cartTotal:Q?.totalAmount,discountValue:V,discountType:_,cardcorpIframeParams:H,isLocked:!!(H||W)}),W&&(0,r.jsx)("div",{className:"rounded-lg border border-blue-200 bg-white p-0 sm:p-4",children:(0,r.jsx)(tm,{checkoutId:W.checkoutId,onSuccess:()=>{window.location.href=`/checkout/complete?checkout_id=${W.orderId}&provider=rapyd`},onFailure:e=>{q(null),eF(),em(e)}})}),!(H||W)&&J&&!eV&&(0,r.jsx)("div",{className:"flex justify-center",children:(0,r.jsx)(td.default,{ref:Z,sitekey:"6LdnuKorAAAAAE3khWNAGxK9ujYbKnLyU6gQ6Fp0",onChange:e=>Y(e??"")})}),H||W?(0,r.jsx)("button",{type:"button",onClick:()=>{G(null),q(null),eF()},className:"w-full rounded-lg border border-gray-300 py-2 text-sm text-gray-600 hover:bg-gray-50 cursor-pointer",children:"← Change payment method"}):(0,r.jsx)(th,{showBack:t>0,onBack:e6,children:(0,r.jsxs)("button",{type:"submit",form:"checkout-form","data-testid":"checkout-submit",disabled:eV||ec||!eH||J&&!K,className:"flex flex-1 items-center justify-center gap-2 rounded-md border-2 border-primary/80 bg-primary py-2 text-sm md:text-base font-bold text-white shadow-md duration-300 hover:scale-105 hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50 md:text-lg cursor-pointer",children:[(0,r.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"hidden shrink-0 md:block",children:[(0,r.jsx)("rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2"}),(0,r.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),(0,r.jsx)("span",{children:eV?"Creating checkout...":ec?"Modifying cart...":`Pay $${(Q?.totalAmount??0).toFixed(2)}`})]})})]}),!(H||W)&&(0,r.jsx)("div",{className:"fixed bottom-0 left-0 right-0 z-50 border-t border-gray-200 bg-white px-4 py-3 shadow-[0_-2px_10px_rgba(0,0,0,0.1)] sm:hidden",children:(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("span",{className:"text-xs text-gray-500",children:"Total"}),(0,r.jsxs)("p",{className:"text-lg font-bold text-gray-900",children:["$",(Q?.totalAmount??0).toFixed(2)]}),P&&(0,r.jsx)("p",{className:"text-[10px] text-gray-400",children:S(Q?.totalAmount??0)})]}),(0,r.jsx)("button",{type:"submit",form:"checkout-form","data-testid":"checkout-submit-mobile",disabled:eV||ec||!eH,className:"rounded-lg bg-primary px-8 py-3 text-sm font-bold text-white shadow-md transition-transform hover:scale-105 disabled:opacity-50",children:eV?"Processing...":`Pay $${(Q?.totalAmount??0).toFixed(2)}`})]})})]})},e.key):null)]}),eu&&e7&&"services"!==e7&&"products"!==e7&&(0,r.jsx)("p",{className:"text-red-500",children:eu})]})}],52893)},37491,e=>{"use strict";var t=e.i(43476),r=e.i(12970),a=e.i(71645),s=e.i(52844),o=e.i(82808),n=e.i(14635);function i({couponCode:e,onCouponAmountChange:l,onCouponCodeChange:d}){let[c,u]=(0,a.useState)(""),[m,p]=(0,a.useState)(!1),[h,x]=(0,a.useState)(""),[f,y]=(0,a.useState)(""),g=(0,o.useCartOperationLock)();(0,a.useEffect)(()=>{e?y(`Current coupon applied: ${e}`):y("")},[e]);let b=async e=>{if(!e.trim()){x("Please enter a discount code."),y("");return}(0,o.lockCartOperation)(),p(!0),x(""),y("");try{let t=(0,n.getCartSessionId)(),r=(0,n.isGuest)()&&t?await s.cartApi.applyGuestCoupon(t,e):await s.cartApi.applyCoupon(e),a=await r.json();r.ok?(x(""),y(`Discount code ${e} applied successfully.`),a.appliedCoupon&&(l(a.appliedCoupon.discountValue,a.appliedCoupon.discountType),d(e)),(0,o.emitCartUpdate)(a)):(x(a.message||a.error||"Failed to apply coupon"),y(""))}catch(e){console.error("Error:",e),x("An error occurred while applying the discount code."),y("")}finally{p(!1),(0,o.unlockCartOperation)()}},v=async()=>
266{if(!e){x("There is no applied coupon."),y("");return}(0,o.lockCartOperation)(),p(!0),x(""),y("");try{let e=(0,n.getCartSessionId)(),t=(0,n.isGuest)()&&e?await s.cartApi.removeGuestCoupon(e):await s.cartApi.removeCoupon(),a=await t.json();t.ok?(x(""),y("Discount code removed successfully."),u(""),l(0,r.DiscountType.PERCENT),d(""),(0,o.emitCartUpdate)(a)):(x(a.error||a.message||"Failed to remove coupon"),y(""))}catch{x("An error occurred while removing the discount code."),y("")}finally{p(!1),(0,o.unlockCartOperation)()}};return(0,t.jsxs)("div",{className:"mb-2 md:mb-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 rounded-md border border-gray-300 bg-white px-2.5 py-1.5 md:gap-2 md:px-3 md:py-2",children:[(0,t.jsx)("input",{type:"text",placeholder:"Enter discount code","aria-label":"Discount code",className:"min-w-0 flex-1 bg-white text-sm text-gray-900 outline-none placeholder:text-sm placeholder:text-primary",onChange:e=>u(e.target.value),value:c}),(0,t.jsx)("button",{type:"button",className:`flex items-center gap-1 rounded-md bg-primary px-2 py-1 text-xs font-semibold whitespace-nowrap text-white cursor-pointer ${m||g?"cursor-not-allowed opacity-70":""}`,onClick:()=>b(c),disabled:m||g,children:"Apply"}),e&&(0,t.jsx)("button",{type:"button",className:`flex items-center gap-1 rounded-md bg-[#828282] px-2 py-1 text-xs font-semibold whitespace-nowrap text-white ${m||g?"cursor-not-allowed opacity-70":""}`,onClick:()=>v(),disabled:m||g,children:"Remove"})]}),h&&(0,t.jsx)("p",{className:"text-xs text-red-500 md:text-sm",children:h}),f&&(0,t.jsx)("p",{className:"text-xs text-green-500 md:text-sm",children:f})]})}var l=e.i(57841),d=e.i(62975),c=e.i(48436),u=e.i(97288);function m({cart:e,discountValue:r,discountType:s,onCartUpdate:n}){let{format:i,showRegionalPrices:l}=(0,u.useRegionPrice)(),{groupedItems:p,removingItems:h,updatingItems:x,errorMessage:f,isReloading:y,isCartOperationLocked:g,requestInProgressRef:b,addOneItemWithUrl:v,removeOneItem:w,removeAllItems:j,reloadCart:N}=(0,d.useCartItemActions)(e,n),[k,C]=(0,a.useState)(null),[S,P]=(0,a.useState)(!1),I=async e=>{if(k){P(!0);try{await v(k.productId,e)}finally{P(!1),C(null)}}};return(0,t.jsxs)("div",{"data-testid":"checkout-order-summary",className:"mb-3 overflow-hidden rounded-md border border-gray-200 shadow-sm md:mb-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between border-b border-gray-200 bg-gray-50 px-3 py-1.5 md:px-4 md:py-2",children:[(0,t.jsx)("h3",{className:"text-xs font-medium text-gray-700 md:text-sm",children:"Cart items"}),(0,t.jsx)("button",{onClick:N,disabled:y,className:"rounded p-1 text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 disabled:opacity-50 cursor-pointer","aria-label":"Reload cart",title:"Reload cart",children:y?(0,t.jsx)("div",{className:"size-4 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600"}):(0,t.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),(0,t.jsx)("path",{d:"M21 3v5h-5"}),(0,t.jsx)("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),(0,t.jsx)("path",{d:"M3 21v-5h5"})]})})]}),f&&(0,t.jsx)("div",{className:"border-b border-red-200 bg-red-50 px-4 py-3",children:(0,t.jsx)("p",{className:"text-sm text-red-800",children:f})}),0===p.length?(0,t.jsx)("div",{className:"flex items-center justify-between bg-white px-3 py-2.5 md:p-4",children:(0,t.jsx)("span",{className:"font-bold text-gray-900",children:"Cart is empty"})}):p.map(e=>(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b border-gray-100 bg-white px-3 py-2.5 last:border-b-0 md:gap-3 md:p-4",children:[(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold text-gray-900 md:text-base md:font-bold",children:e.productName}),(0,t.jsxs)("div",{className:"flex flex-shrink-0 items-center gap-3",children:[(0,t.jsxs)("div",{className:"flex flex-col items-end gap-0.5",children:[r>0?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("span",{className:"text-xs text-gray-400 line-through md:text-sm",children:["$",e.unitPrice]}),(0,t.jsxs)("span",{className:"text-sm font-semibold text-gray-700 md:font-bold",children:["$",(0,o.applyDiscount)(e.unitPrice,r,s).toFixed(2)]})]}):(0,t.jsxs)("span",{className:"text-sm font-semibold text-gray-700 md:font-bold",children:["$",e.unitPrice]}),l&&(0,t.jsx)("span",{className:"text-xs text-gray-400",children:i(r>0?(0,o.applyDiscount)(e.unitPrice,r,s):e.unitPrice)})]}),(0,t.jsxs)("div",{className:"flex items-center rounded border border-gray-300",children:[(0,t.jsx)("button",{onClick:()=>w(e),disabled:b.current||g,className:"px-1.5 py-0.5 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-5 cursor-pointer","aria-label":"Decrease quantity",children:(0,t.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"M5 12h14"})})}),(0,t.jsx)("span",{className:"min-w-6 border-x border-gray-300 px-2 py-0.5 text-center text-xs text-gray-700",children:x.has(e.productId)||g?(0,t.jsx)("div",{className:"mx-auto 
266size-2.5 animate-spin rounded-full border-2 border-gray-300 border-t-gray-600"}):e.quantity}),(0,t.jsx)("button",{onClick:()=>C(e),disabled:b.current||g,className:"px-1.5 py-0.5 text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50 cursor-pointer","aria-label":"Increase quantity",children:(0,t.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"M12 5v14M5 12h14"})})})]}),(0,t.jsx)("button",{onClick:()=>j(e),disabled:b.current||g,className:"rounded text-slate-400 transition-colors hover:bg-red-50 hover:text-red-500 disabled:opacity-50 cursor-pointer","aria-label":"Remove item from cart",children:h.has(e.productId)?(0,t.jsx)("div",{className:"size-4 animate-spin rounded-full border-2 border-slate-300 border-t-slate-600"}):(0,t.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,t.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]})]},e.productId)),(0,t.jsx)(c.CartItemUrlModal,{open:null!==k,productName:k?.productName??null,isSubmitting:S,onSubmit:I,onClose:()=>C(null)})]})}e.s(["default",0,function({cart:e}){let[n,d]=(0,a.useState)(e),[c,u]=(0,a.useState)(0),[p,h]=(0,a.useState)(r.DiscountType.PERCENT),[x,f]=(0,a.useState)("");(0,a.useEffect)(()=>{let e=!1;return(0,s.fetchCurrentCart)().then(t=>{!e&&t&&d(t)}),()=>{e=!0}},[]),(0,a.useEffect)(()=>{e?.lineItems?.length&&d(e)},[e]);let y=(0,a.useCallback)(e=>{d(e)},[]);return(0,o.useCartUpdateListener)(y),(0,a.useEffect)(()=>{if(!n||!n.lineItems?.length){u(0),h(r.DiscountType.PERCENT),f("");return}n.appliedCoupon?(u(n.appliedCoupon.discountValue),h(n.appliedCoupon.discountType),f(n.appliedCoupon.code)):(u(0),h(r.DiscountType.PERCENT),f(""))},[n]),(0,a.useEffect)(()=>{(0,o.emitCouponChange)(x,c,p)},[c,p,x]),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(m,{cart:n,discountValue:c,discountType:p,onCartUpdate:d}),(0,t.jsx)(i,{couponCode:x,onCouponAmountChange:(e,t)=>
266{u(e),h(t)},onCouponCodeChange:f}),(0,t.jsx)("div",{className:"mb-1 md:mb-2",children:(0,t.jsx)("div",{className:"flex items-baseline gap-2",children:(0,t.jsx)(l.default,{cart:n,discountValue:c,discountType:p})})})]})}],37491)}]);

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.