import{j as s}from"./jsx-runtime-Byf2O5Qf.js";import{r as d}from"./chunk-HA7DTUK3-Cv5eIhAv.js";import{R as y}from"./index-B6meePy9.js";import{f as D,a as Ae,u as P}from"./money-B1tIULeG.js";import{c as O}from"./clsx-B-dksMZM.js";import{am as Fe}from"./index-CryK06Hj.js";import{F as We}from"./index.es-HLHXff-Q.js";import{a as Ge,c as I}from"./index-BwBH8Yr2.js";import{a as He,P as oe,c as Ye,u as ie}from"./index-CJmgeWT8.js";import{c as le,A as Ue,R as $e,a as ze,P as Ke,D as Ze,C as Xe}from"./index-lWDX5i1b.js";import{u as Je,P as ae}from"./index-CCwjKZu8.js";import{a as Qe}from"./user-QN6PmLHd.js";import{S as B}from"./conditional_render-C0njI6gk.js";import{R as Ve,T as Be,a as qe,b as et}from"./index-BvB-E9am.js";import{u as tt}from"./useTranslation-BXe-2OXV.js";var rt=d.forwardRef((e,t)=>{const{children:r,...n}=e,o=d.Children.toArray(r),i=o.find(nt);if(i){const a=i.props.children,u=o.map(c=>c===i?d.Children.count(a)>1?d.Children.only(null):d.isValidElement(a)?a.props.children:null:c);return s.jsx(q,{...n,ref:t,children:d.isValidElement(a)?d.cloneElement(a,void 0,u):null})}return s.jsx(q,{...n,ref:t,children:r})});rt.displayName="Slot";var q=d.forwardRef((e,t)=>{const{children:r,...n}=e;if(d.isValidElement(r)){const o=ot(r),i=st(n,r.props);return r.type!==d.Fragment&&(i.ref=t?He(t,o):o),d.cloneElement(r,i)}return d.Children.count(r)>1?d.Children.only(null):null});q.displayName="SlotClone";var ce=({children:e})=>s.jsx(s.Fragment,{children:e});function nt(e){return d.isValidElement(e)&&e.type===ce}function st(e,t){const r={...t};for(const n in t){const o=e[n],i=t[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...u)=>{i(...u),o(...u)}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...e,...r}}function ot(e){var n,o;let t=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var it="VisuallyHidden",ue=d.forwardRef((e,t)=>s.jsx(oe.span,{...e,ref:t,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));ue.displayName=it;var lt=ue,[z,rr]=Ye("Tooltip",[le]),K=le(),de="TooltipProvider",at=700,ee="tooltip.open",[ct,re]=z(de),fe=e=>{const{__scopeTooltip:t,delayDuration:r=at,skipDelayDuration:n=300,disableHoverableContent:o=!1,children:i}=e,[a,u]=d.useState(!0),c=d.useRef(!1),l=d.useRef(0);return d.useEffect(()=>{const f=l.current;return()=>window.clearTimeout(f)},[]),s.jsx(ct,{scope:t,isOpenDelayed:a,delayDuration:r,onOpen:d.useCallback(()=>{window.clearTimeout(l.current),u(!1)},[]),onClose:d.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>u(!0),n)},[n]),isPointerInTransitRef:c,onPointerInTransitChange:d.useCallback(f=>{c.current=f},[]),disableHoverableContent:o,children:i})};fe.displayName=de;var Z="Tooltip",[ut,A]=z(Z),pe=e=>{const{__scopeTooltip:t,children:r,open:n,defaultOpen:o=!1,onOpenChange:i,disableHoverableContent:a,delayDuration:u}=e,c=re(Z,e.__scopeTooltip),l=K(t),[f,m]=d.useState(null),_=Je(),p=d.useRef(0),h=a??c.disableHoverableContent,b=u??c.delayDuration,j=d.useRef(!1),[v=!1,g]=Ge({prop:n,defaultProp:o,onChange:E=>{E?(c.onOpen(),document.dispatchEvent(new CustomEvent(ee))):c.onClose(),i==null||i(E)}}),T=d.useMemo(()=>v?j.current?"delayed-open":"instant-open":"closed",[v]),w=d.useCallback(()=>{window.clearTimeout(p.current),p.current=0,j.current=!1,g(!0)},[g]),k=d.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g(!1)},[g]),x=d.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{j.current=!0,g(!0),p.current=0},b)},[b,g]);return d.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),s.jsx($e,{...l,children:s.jsx(ut,{scope:t,contentId:_,open:v,stateAttribute:T,trigger:f,onTriggerChange:m,onTriggerEnter:d.useCallback(()=>{c.isOpenDelayed?x():w()},[c.isOpenDelayed,x,w]),onTriggerLeave:d.useCallback(()=>{h?k():(window.clearTimeout(p.current),p.current=0)},[k,h]),onOpen:w,onClose:k,disableHoverableContent:h,children:r})})};pe.displayName=Z;var te="TooltipTrigger",me=d.forwardRef((e,t)=>{const{__scopeTooltip:r,...n}=e,o=A(te,r),i=re(te,r),a=K(r),u=d.useRef(null),c=ie(t,u,o.onTriggerChange),l=d.useRef(!1),f=d.useRef(!1),m=d.useCallback(()=>l.current=!1,[]);return d.useEffect(()=>()=>document.removeEventListener("pointerup",m),[m]),s.jsx(ze,{asChild:!0,...a,children:s.jsx(oe.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...n,ref:c,onPointerMove:I(e.onPointerMove,_=>{_.pointerType!=="touch"&&!f.current&&!i.isPointerInTransitRef.current&&(o.onTriggerEnter(),f.current=!0)}),onPointerLeave:I(e.onPointerLeave,()=>{o.onTriggerLeave(),f.current=!1}),onPointerDown:I(e.onPointerDown,()=>{l.current=!0,document.addEventListener("pointerup",m,{once:!0})}),onFocus:I(e.onFocus,()=>{l.current||o.onOpen()}),onBlur:I(e.onBlur,o.onClose),onClick:I(e.onClick,o.onClose)})})});me.displayName=te;var ne="TooltipPortal",[dt,ft]=z(ne,{forceMount:void 0}),xe=e=>{const{__scopeTooltip:t,forceMount:r,children:n,container:o}=e,i=A(ne,t);return s.jsx(dt,{scope:t,forceMount:r,children:s.jsx(ae,{present:r||i.open,children:s.jsx(Ke,{asChild:!0,container:o,children:n})})})};xe.displayName=ne;var M="TooltipContent",he=d.forwardRef((e,t)=>{const r=ft(M,e.__scopeTooltip),{forceMount:n=r.forceMount,side:o="top",...i}=e,a=A(M,e.__scopeTooltip);return s.jsx(ae,{present:n||a.open,children:a.disableHoverableContent?s.jsx(be,{side:o,...i,ref:t}):s.jsx(pt,{side:o,...i,ref:t})})}),pt=d.forwardRef((e,t)=>{const r=A(M,e.__scopeTooltip),n=re(M,e.__scopeTooltip),o=d.useRef(null),i=ie(t,o),[a,u]=d.useState(null),{trigger:c,onClose:l}=r,f=o.current,{onPointerInTransitChange:m}=n,_=d.useCallback(()=>{u(null),m(!1)},[m]),p=d.useCallback((h,b)=>{const j=h.currentTarget,v={x:h.clientX,y:h.clientY},g=ht(v,j.getBoundingClientRect()),T=bt(v,g),w=_t(b.getBoundingClientRect()),k=wt([...T,...w]);u(k),m(!0)},[m]);return d.useEffect(()=>()=>_(),[_]),d.useEffect(()=>{if(c&&f){const h=j=>p(j,f),b=j=>p(j,c);return c.addEventListener("pointerleave",h),f.addEventListener("pointerleave",b),()=>{c.removeEventListener("pointerleave",h),f.removeEventListener("pointerleave",b)}}},[c,f,p,_]),d.useEffect(()=>{if(a){const h=b=>{const j=b.target,v={x:b.clientX,y:b.clientY},g=(c==null?void 0:c.contains(j))||(f==null?void 0:f.contains(j)),T=!gt(v,a);g?_():T&&(_(),l())};return document.addEventListener("pointermove",h),()=>document.removeEventListener("pointermove",h)}},[c,f,a,l,_]),s.jsx(be,{...e,ref:i})}),[mt,xt]=z(Z,{isInside:!1}),be=d.forwardRef((e,t)=>{const{__scopeTooltip:r,children:n,"aria-label":o,onEscapeKeyDown:i,onPointerDownOutside:a,...u}=e,c=A(M,r),l=K(r),{onClose:f}=c;return d.useEffect(()=>(document.addEventListener(ee,f),()=>document.removeEventListener(ee,f)),[f]),d.useEffect(()=>{if(c.trigger){const m=_=>{const p=_.target;p!=null&&p.contains(c.trigger)&&f()};return window.addEventListener("scroll",m,{capture:!0}),()=>window.removeEventListener("scroll",m,{capture:!0})}},[c.trigger,f]),s.jsx(Ze,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:m=>m.preventDefault(),onDismiss:f,children:s.jsxs(Xe,{"data-state":c.stateAttribute,...l,...u,ref:t,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[s.jsx(ce,{children:n}),s.jsx(mt,{scope:r,isInside:!0,children:s.jsx(lt,{id:c.contentId,role:"tooltip",children:o||n})})]})})});he.displayName=M;var _e="TooltipArrow",ge=d.forwardRef((e,t)=>{const{__scopeTooltip:r,...n}=e,o=K(r);return xt(_e,r).isInside?null:s.jsx(Ue,{...o,...n,ref:t})});ge.displayName=_e;function ht(e,t){const r=Math.abs(t.top-e.y),n=Math.abs(t.bottom-e.y),o=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(r,n,o,i)){case i:return"left";case o:return"right";case r:return"top";case n:return"bottom";default:throw new Error("unreachable")}}function bt(e,t,r=5){const n=[];switch(t){case"top":n.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":n.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":n.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":n.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return n}function _t(e){const{top:t,right:r,bottom:n,left:o}=e;return[{x:o,y:t},{x:r,y:t},{x:r,y:n},{x:o,y:n}]}function gt(e,t){const{x:r,y:n}=e;let o=!1;for(let i=0,a=t.length-1;in!=f>n&&r<(l-u)*(n-c)/(f-c)+u&&(o=!o)}return o}function wt(e){const t=e.slice();return t.sort((r,n)=>r.xn.x?1:r.yn.y?1:0),jt(t)}function jt(e){if(e.length<=1)return e.slice();const t=[];for(let n=0;n=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))t.pop();else break}t.push(o)}t.pop();const r=[];for(let n=e.length-1;n>=0;n--){const o=e[n];for(;r.length>=2;){const i=r[r.length-1],a=r[r.length-2];if((i.x-a.x)*(o.y-a.y)>=(i.y-a.y)*(o.x-a.x))r.pop();else break}r.push(o)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var vt=fe,yt=pe,Ct=me,Tt=xe,Et=he,kt=ge;const we={Package:.99},Pt={Package:25e3},je=(e,t)=>{if(!t)return null;const r=t.variantId?String(t.variantId):t.id;return r?e.find(o=>o.productVariantId===r):null};function nr({variants:e,defaultVariant:t,coupon:r}){if(!t)return null;const{id:n,freePurchaseOnly:o,minimumPaidPrice:i,allowFreePurchases:a}=t;let u=n;if(r){let c=0;r.productVariantDiscounts.forEach(l=>{const f=e.find(m=>m.id===l.productVariantId&&m.quantity===1);f&&f.minimumPaidPrice-l.discountedPrice>c&&(c=f.minimumPaidPrice-l.discountedPrice,u=l.productVariantId)})}else if(o||a||i===0){let c=1/0;e.forEach(l=>{!l.allowFreePurchases&&l.minimumPaidPricee.minimumPaidPrice,Q=e=>e.maximumPrice,Rt=e=>e.suggestedPrice,Ce=e=>e.royaltiesToRevenueRatio,Te=e=>e.ratioOfRevenueToAuthors,Ee=e=>e.ratioOfRevenueToCauses,Nt=e=>e.allowFreePurchases,U=(e,t,r)=>{const n=ke(e,t,r);if(n!=null)return n;const o=ye(t);return o>0?o:we.Package},ke=(e,t,r)=>{if(e&&e.discountedPrice!==null&&e.discountedPrice!==void 0)return e.discountedPrice;if(r&&t){const n=je(r.productVariantDiscounts,t);if(n&&n.discountedPrice!==null&&n.discountedPrice!==void 0)return n.discountedPrice}return null},$=(e,t,r)=>{if(Nt(t))return 0;const n=ke(e,t,r),o=ye(t);return n!=null?o!==null?Math.min(n,o):n:o!==null&&o>0?o:we.Package},Ot=(e,t,r,n)=>{const o=$(t,r,n);if(e<=o)return o;const i=U(t,r,n),a=Pt.Package;return e0&&(e=i),e>a&&(e=a),e},Pe=(e,t)=>{if(e<=0)return 0;let r=e*Ce(t);return e{if(e===0)return 0;const n=Ce(r),o=(e/t+ve)/n,i=e/t/n;return o>0&&o=Y?Math.ceil(i*100)/100:Math.ceil(Y*100)/100},Lt=(e,t)=>{const r=Pe(e,t)*Te(t);return Math.floor(r*100)/100},St=(e,t)=>Pe(e,t)*Ee(t),Ne=(e,t)=>Re(e,Te(t),t),Oe=(e,t)=>Re(e,Ee(t),t),Le=(e,t,r,n,o)=>{if(typeof e=="string"&&(e=parseFloat(e)),isNaN(e))return Rt(n);let i=null;switch(t){case"author":i=Ne(e,n);break;case"cause":i=Oe(e,n);break;default:i=e;break}return i=Ot(i,r,n,o),i},sr=({inputRef:e,youPayPrice:t,coupon:r,productVariantDiscount:n,compact:o=!1,cartable:i,handleValueChange:a})=>{const u=Number(t),[c,l]=d.useState(D(u)),f=p=>{l(p.currentTarget.value)},m=()=>{const p=Ae(e.current.value),h=Le(p,"product",n,i,r);a(h),l(h?D(h):D(u))},_=p=>{p.keyCode===13&&m()};return d.useEffect(()=>{l(D(u))},[t,u,l]),s.jsxs("section",{className:`${o?"pt-3":"pt-4"} pb-2`,children:[s.jsx("label",{htmlFor:"unitPrice",className:`block tracking-wider text-black uppercase ${o?"text-xs":"text-sm"}`,children:s.jsx(y,{k:"w_you_pay"})}),s.jsx("div",{className:"flex flex-row items-center gap-x-6 gap-y-3",children:s.jsxs("div",{className:"relative mt-1 block rounded-md shadow-sm",children:[s.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:s.jsx("span",{className:"text-neutral-600 sm:text-sm",children:"$"})}),s.jsx("input",{ref:e,id:"unitPrice",name:"unitPrice","aria-describedby":"price-currency",type:"text",inputMode:"decimal",value:c,onChange:f,onBlur:m,onKeyUp:_,placeholder:D(Number(n!=null&&n.discountedPrice?n.discountedPrice:i.suggestedPrice)),className:"focus:border-azure-500 focus:ring-azure-500 block w-36 rounded-lg border-neutral-300 ps-7 contrast-more:border-neutral-600 sm:text-sm md:w-36"})]})})]})},It=({allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,currentUser:o,freePurchaseRequiresMembership:i,isBundle:a,minimumPaidPrice:u,soldSeparately:c,suggestedPrice:l})=>s.jsxs(s.Fragment,{children:[s.jsx(y,{k:"w_product_authors_set_tip_html"}),s.jsx("br",{}),s.jsx("br",{}),a&&c?s.jsxs(s.Fragment,{children:[s.jsx(y,{k:"w_product_bundle_separate_price_html",opts:{suggested:P(c)}}),s.jsx("br",{}),s.jsx("br",{})]}):null,e?t&&r?s.jsxs(s.Fragment,{children:[s.jsx(y,{k:"w_product_min_paid_and_sug_tip_html",opts:{minimumPaidPrice:P(u),suggestedPrice:P(l)}}),s.jsx("br",{}),s.jsx("br",{}),s.jsx(y,{k:"w_product_free_with_coupon_used"})]}):i?o&&o.is_premium_reader?s.jsxs(s.Fragment,{children:[s.jsx(y,{k:"w_product_min_paid_and_sug_tip_html",opts:{minimumPaidPrice:P(u),suggestedPrice:P(l)}}),s.jsx("br",{}),s.jsx("br",{}),s.jsx(y,{k:"w_product_free_with_membership_thanks"})]}):t?s.jsxs(s.Fragment,{children:[s.jsx(y,{k:"w_product_min_paid_and_sug_tip_html",opts:{minimumPaidPrice:P(u),suggestedPrice:P(l)}}),s.jsx("br",{}),s.jsx("br",{}),s.jsx(y,{k:"w_product_cheap_with_coupon_used",opts:{couponPrice:n!==null?P(n):n}}),s.jsx("br",{}),s.jsx("br",{}),s.jsx(y,{k:"w_product_free_with_reader_membership"})]}):s.jsxs(s.Fragment,{children:[s.jsx(y,{k:"w_product_min_paid_and_sug_tip_html",opts:{minimumPaidPrice:P(u),suggestedPrice:P(l)}}),s.jsx("br",{}),s.jsx("br",{}),s.jsx(y,{k:"w_product_free_with_reader_membership"})]}):l===0?s.jsx(y,{k:"w_product_min_and_sug_free_tip_html",opts:{minimumPaidPrice:P(u)}}):s.jsx(y,{k:"w_product_min_free_price_tip_html",opts:{suggestedPrice:P(l)}}):t?s.jsx(y,{k:"w_product_cheap_with_coupon_used",opts:{couponPrice:n!==null?P(n):n}}):s.jsx(y,{k:"w_product_min_and_sug_price_tip_html",opts:{minimumPaidPrice:P(u),suggestedPrice:P(l)}})]}),Mt=({allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,muted:u,soldSeparately:c,subtext:l,suggestedPrice:f,children:m})=>{const _=Qe(),[p,h]=d.useState(null),[b,j]=d.useState(!1),[v,g]=d.useState(!1),T=d.useRef(null),w=d.useRef(null);d.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;const x=window.matchMedia("(hover: hover) and (pointer: fine)"),E=R=>{j(R.matches)};E(x);const C=R=>E(R);return x.addEventListener?x.addEventListener("change",C):x.addListener(C),()=>{x.removeEventListener?x.removeEventListener("change",C):x.removeListener(C)}},[]),d.useEffect(()=>{b&&v&&g(!1)},[b,v]),d.useEffect(()=>{if(b||!v||typeof document>"u")return;const x=C=>{var F,W;const R=C.target;!R||(F=T.current)!=null&&F.contains(R)||(W=w.current)!=null&&W.contains(R)||g(!1)},E=["pointerdown","mousedown","touchstart"];return E.forEach(C=>document.addEventListener(C,x,!0)),()=>{E.forEach(C=>document.removeEventListener(C,x,!0))}},[b,v]),d.useEffect(()=>{if(typeof document>"u")return;let x=document.getElementById("cartable-tooltip-portal");x||(x=document.createElement("div"),x.id="cartable-tooltip-portal",x.setAttribute("data-headlessui-portal",""),x.style.zIndex="10040",document.body.appendChild(x)),h(x)},[]);const k=s.jsxs(Et,{ref:w,className:"z-[10050] w-full max-w-64 rounded-lg bg-black px-6 py-4 text-center text-xs text-neutral-300 select-none md:max-w-72 md:text-sm [&_strong]:text-neutral-100",sideOffset:5,side:"bottom",collisionPadding:{left:20,right:20},onPointerDownOutside:x=>{var C;if(b)return;const E=x.target;if(E&&((C=T.current)!=null&&C.contains(E))){x.preventDefault();return}g(!1)},onEscapeKeyDown:()=>{b||g(!1)},children:[m??s.jsx(It,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,currentUser:_,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,soldSeparately:c,suggestedPrice:f}),s.jsx(kt,{className:"fill-black"})]});return s.jsx(vt,{delayDuration:0,children:s.jsxs(yt,{open:b?void 0:v,children:[s.jsx(Ct,{asChild:!0,children:s.jsxs("button",{ref:T,className:"flex items-center space-x-1.5",type:"button",onClick:()=>{b||g(x=>!x)},"aria-expanded":b?void 0:v,"aria-haspopup":"dialog",children:[s.jsx("p",{className:O("text-sm leading-5 tracking-wider uppercase",u?"text-neutral-500":"text-neutral-600"),children:s.jsx(y,{k:l})}),s.jsx(We,{icon:Fe,width:"12px",height:"12px",className:"h-3 w-3 text-black"})]})}),p?s.jsx(Tt,{container:p,children:k}):k]})})},N=({allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,muted:u,price:c,quickBuyHeader:l,compact:f=!1,soldSeparately:m,subtext:_,suggestedPrice:p,tooltip:h})=>s.jsxs("div",{className:"space-y-2",children:[h&&!l?s.jsx(Mt,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,muted:u,soldSeparately:m,subtext:_,suggestedPrice:p}):s.jsx("div",{children:s.jsx("p",{className:O("text-sm leading-5 tracking-wider uppercase",u?"text-neutral-500":"text-neutral-600"),children:s.jsx(y,{k:_})})}),s.jsx("p",{className:O(f?"text-2xl font-semibold":l?"text-lg":"pb-2 text-3xl font-bold",u?"text-neutral-500 line-through":""),children:c==0?s.jsx(y,{k:"w_free"}):c!==null?P(c):c})]}),Dt=({allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,quickBuyHeader:u,compact:c=!1,soldSeparately:l,suggestedPrice:f})=>t?r?s.jsx(N,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,muted:!1,price:0,quickBuyHeader:u,compact:c,soldSeparately:l,subtext:"w_with_coupon",suggestedPrice:f,tooltip:!1}):e?s.jsx(N,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,muted:!1,price:n,quickBuyHeader:u,compact:c,soldSeparately:l,subtext:"w_with_coupon",suggestedPrice:f,tooltip:!0}):s.jsx(N,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,muted:!1,price:n,quickBuyHeader:u,compact:c,soldSeparately:l,subtext:"w_with_coupon",suggestedPrice:f,tooltip:!1}):null,At=({allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,quickBuyHeader:u,compact:c=!1,soldSeparately:l,suggestedPrice:f})=>e?t&&r?null:o?s.jsx(N,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,price:0,quickBuyHeader:u,compact:c,soldSeparately:l,subtext:"w_with_membership",suggestedPrice:f}):s.jsx(N,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,price:0,quickBuyHeader:u,compact:c,soldSeparately:l,subtext:"w_min_price",suggestedPrice:f}):null,Ft=({quickBuyHeader:e})=>s.jsx("div",{className:O(e?"hidden":"block"),children:s.jsx("div",{children:s.jsx("p",{className:"text-lg leading-5 text-black",children:"You can only buy this for free!"})})}),Wt=({allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,quickBuyHeader:u,compact:c=!1,soldSeparately:l,suggestedPrice:f})=>{const m=i&&l&&l>a;return e||t?m&&t?null:a>f?s.jsx(N,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,price:a,quickBuyHeader:u,compact:c,soldSeparately:l,subtext:"w_min_paid_price",suggestedPrice:f,tooltip:!0}):s.jsx(N,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,muted:!!(r||t),price:f,quickBuyHeader:u,compact:c,soldSeparately:l,subtext:"w_suggested_price",suggestedPrice:f,tooltip:!0}):m?a===f?s.jsx(N,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,price:a,quickBuyHeader:u,compact:c,soldSeparately:l,subtext:"w_bundle_price",suggestedPrice:f,tooltip:!0}):s.jsxs(s.Fragment,{children:[s.jsx(N,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,price:a,quickBuyHeader:u,compact:c,soldSeparately:l,subtext:"w_min_price",suggestedPrice:f}),s.jsx(N,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,price:f,quickBuyHeader:u,compact:c,soldSeparately:l,subtext:"w_suggested_price",suggestedPrice:f,tooltip:!0})]}):s.jsxs(s.Fragment,{children:[s.jsx(N,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,price:a,quickBuyHeader:u,compact:c,soldSeparately:l,subtext:"w_min_price",suggestedPrice:f}),s.jsx(N,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,price:f,quickBuyHeader:u,compact:c,soldSeparately:l,subtext:"w_suggested_price",suggestedPrice:f,tooltip:!0})]})},Gt=({allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,quickBuyHeader:u,compact:c=!1,soldSeparately:l,suggestedPrice:f})=>i&&l&&l>a?s.jsx(N,{allowFreePurchases:e,couponActive:t,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:a,muted:!0,price:l,quickBuyHeader:u,compact:c,soldSeparately:l,subtext:"w_bought_separately",suggestedPrice:f}):null,or=({cartable:e,coupon:t=null,quickBuyHeader:r=!1,productVariantDiscount:n,isBundle:o=!1,soldSeparatelyPrice:i,onLayoutChange:a,compact:u=!1,isInQuickBuyPurchaseDetails:c=!1})=>{const l=d.useRef(null),[f,m]=d.useState(!1),[_,p]=d.useState(0);let{allowFreePurchases:h,boughtSeparatelyCombinedSuggestedPrice:b,freePurchaseOnly:j,freePurchaseRequiresMembership:v,minimumPaidPrice:g,suggestedPrice:T}=e;if(j)return s.jsx(Ft,{quickBuyHeader:r});let w=!1,k=!1,x=e.minimumPaidPrice,E=n||null;if(!E&&t&&(E=je(t.productVariantDiscounts,e)??null),E){const L=E.discountedPrice;w=L0;d.useEffect(()=>{const L=l.current;if(!L||typeof window>"u")return;const G=()=>{const X=Array.from(L.children),J=X.length;if(p(H=>H===J?H:J),J<=1){m(!0);return}const Ie=X[0].offsetTop,Me=X.some((H,De)=>De>0&&H.offsetTop===Ie);m(!Me)};G();const S="ResizeObserver"in window?new ResizeObserver(G):null;return S==null||S.observe(L),window.addEventListener("resize",G),()=>{S==null||S.disconnect(),window.removeEventListener("resize",G)}},[R,h,g,T]),d.useEffect(()=>{a==null||a(f)},[f,a]);const se=!c&&_===3,F=()=>c?O("text-sm hidden xs:inline-block xs:mr-4"):O("flex w-full flex-wrap","justify-around gap-2","text-center sm:text-left",r&&"[&>*]:inline-block [&>*]:mr-4"),W=c?"":se?"md:justify-around md:gap-2 md:max-w-lg":"md:justify-start md:gap-x-16 md:gap-y-4 md:max-w-full",Se=u?"max-w-full md:max-w-lg":"";return s.jsx("div",{className:O("flex",!u&&"mt-4"),children:s.jsxs("div",{ref:l,className:O(F(),!u&&"my-2",W,Se),children:[s.jsx(Gt,{allowFreePurchases:h,couponActive:w,couponFree:k,couponPrice:x,freePurchaseRequiresMembership:v,isBundle:R,minimumPaidPrice:g,quickBuyHeader:r,compact:u,soldSeparately:C,suggestedPrice:T}),s.jsx(At,{allowFreePurchases:h,couponActive:w,couponFree:k,couponPrice:x,freePurchaseRequiresMembership:v,isBundle:R,minimumPaidPrice:g,quickBuyHeader:r,compact:u,soldSeparately:C,suggestedPrice:T}),s.jsx(Wt,{allowFreePurchases:h,couponActive:w,couponFree:k,couponPrice:x,freePurchaseRequiresMembership:v,isBundle:R,minimumPaidPrice:g,quickBuyHeader:r,compact:u,soldSeparately:C,suggestedPrice:T}),t&&s.jsx(Dt,{allowFreePurchases:h,couponActive:w,couponFree:k,couponPrice:x,freePurchaseRequiresMembership:v,isBundle:R,minimumPaidPrice:g,quickBuyHeader:r,compact:u,soldSeparately:C,suggestedPrice:T})]})})},V=({ariaLabel:e,label:t,labelCount:r,maximum:n,name:o,sliderMinimum:i,sliderStyle:a,step:u,updateValue:c,value:l,money:f=!0,className:m})=>{let _,p,h;switch(a){case"primary":p="bg-sky-400",_="bg-sky-600 border-sky-800",h="focus-visible:ring-sky-700 border-white";break;case"secondary":p="bg-lime-400",_="bg-lime-600 border-lime-800",h="focus-visible:ring-lime-700 border-white";break;case"tertiary":p="bg-violet-400",_="bg-violet-600 border-violet-800",h="focus-visible:ring-violet-700 border-white";break;case"quaternary":p="bg-teal-400",_="bg-teal-500 border-teal-700",h="focus-visible:ring-teal-600 border-white";break;default:p="bg-neutral-500",_="bg-neutral-50",h="focus-visible:ring-neutral-500";break}const b=typeof m=="string"&&m.split(/\s+/).some(j=>j.startsWith("py-"));return s.jsxs("section",{className:O(m,!b&&"py-2"),children:[s.jsx(B,{test:o,children:s.jsx("input",{type:"hidden",value:String(l),name:o})}),s.jsx("h2",{className:"text-xs tracking-wider text-black uppercase sm:text-sm",children:r?s.jsx(y,{k:t,opts:{count:r}}):s.jsx(y,{k:t})}),s.jsxs(Ve,{value:[Math.min(l,n)],onValueChange:j=>c(j[0]),max:n,min:i,step:u,"aria-label":e,name:o,className:"relative flex h-12 w-full touch-none items-center",children:[s.jsx(Be,{className:"relative h-8 w-full grow rounded-lg border-2 border-neutral-300 before:absolute before:top-0.5 before:right-0.5 before:bottom-0.5 before:left-0.5 before:content-[''] before:[background:repeating-linear-gradient(to_right,_#efefef,_#efefef_1px,_transparent_1px,_transparent_5px)] contrast-more:border-neutral-600",children:s.jsx(qe,{className:O("absolute -top-0.5 -right-0.5 -bottom-0.5 -left-0.5! m-0 flex h-8 items-center rounded-l-lg border-2 border-r-0 font-semibold",_,l===0?"left-2! -ml-[0.6rem] pr-3":""),children:s.jsx("span",{className:`absolute text-sm font-semibold break-normal ${l>n/6?"left-2 text-white":l===0?"left-[calc(100%+0.75rem)]":"left-[calc(100%+1.25rem)]"}`,children:f?P(l):l})})}),s.jsx(et,{className:O("block h-12 w-3 items-center rounded-full border-2 [box-shadow:0_2px_10px_0_rgba(0,0,0,0.5)]","cursor-grab","focus-within:outline-hidden focus:outline-hidden focus-visible:ring-2",p,h,l===0?"ml-4!":"")})]})]})},ir=({youPayPrice:e,cartable:t,coupon:r,productVariantDiscount:n,numberOfAuthors:o,numberOfCauses:i,showWhatAuthorGets:a,showWhatCauseGets:u,handleValueChange:c,compact:l=!1})=>{const{t:f}=tt(),[m,_]=d.useState(e),[p,h]=d.useState(Q(t)),b=d.useCallback((w,k)=>{let x=Number(w);if(x>0)switch(k){case"author":x=Ne(x,t);break;case"cause":x=Oe(x,t);break}else x=0;const E=Le(x,"product",n,t,r);_(E),c(E)},[t,r,c,n]);d.useEffect(()=>{Q(t)!==p&&h(Q(t)),b(e,"product")},[t,p,b,e]);const j=m<=0?0:lt(m,t),v=m<=0||!t.ratioofrevenuetocauses?0:st(m,t),g=o("w-full md:max-w-lg",l&&"mt-2 mb-2 flex flex-col gap-y-3"),T=l?"py-0":void 0;return s.jsxs("div",{className:g,children:[s.jsx(V,{className:T,value:m,minimum:$(n,t,r),minimumNonZero:U(n,t,r),sliderMinimum:0,maximum:p,ariaLabel:"w_you_pay",label:"w_you_pay",name:"you_pay_price",sliderStyle:"primary",step:.01,updateValue:w=>b(w,"product")}),s.jsx(B,{test:a,children:s.jsx(V,{className:T,value:j,minimum:$(n,t,r),minimumNonZero:U(n,t,r),sliderMinimum:0,maximum:p,ariaLabel:f("w_author_earns",{count:o}),label:f("w_author_earns",{count:o}),labelCount:o,name:"author_earnings",sliderStyle:"secondary",step:.01,updateValue:w=>b(w,"author")})}),s.jsx(B,{test:u,children:s.jsx(V,{className:T,value:v,minimum:$(n,t,r),minimumNonZero:U(n,t,r),sliderMinimum:0,maximum:p,ariaLabel:"w_cause_gets",label:i>1?"w_causes_get":"w_cause_gets",name:"cause_earnings",sliderStyle:"tertiary",step:.01,updateValue:w=>b(w,"cause")})})]})};export{kt as A,or as C,vt as P,yt as R,Ct as T,ir as a,sr as b,Tt as c,Et as d,nr as e,je as g};

AltStyle によって変換されたページ (->オリジナル) /