1 2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7af92811-0b80-5646-9fcc-7f2a5edf66d0")}catch(e){}}(); 3import{r as f,j as e,b as St}from"./vendor-react-qLnyzkeB.js";import{a as S}from"./index-B9K37ttC.js";import{R as re}from"./r_button-BiU6XUE-.js";import{R as z}from"./r_hidden-Bq03vPox.js";import"./rc_hidden-3sgqHmHH.js";import{R as Tt}from"./index-CE_0OOKE.js";import{R as N}from"./index-9As2c7F9.js";import{f as te,b as Pt,u as I}from"./money-BCLQuunm.js";import{P as B,c as U,b as Ee,a as Ke}from"./index-9GJscC6q.js";import{u as xe}from"./index-Cyefy6Xj.js";import{c as Ft,u as De}from"./index-C1h8wXa-.js";import{u as Ot,P as At}from"./index-tqa7NzKJ.js";import{u as Lt}from"./index-Ij08xJH0.js";import{u as Gt,R as Mt,T as zt,a as $t,b as Kt}from"./index-ClwUWgK-.js";import{u as ne}from"./useTranslation-QeIoSKbz.js";import{bl as Dt,bm as Yt,D as Ut}from"./index-DVnHJy9S.js";import{F as Ne}from"./index.es-mnCibYNf.js";import{P as Qt,R as Wt,T as Zt,a as Xt,C as Jt,A as Ht}from"./index-NgbAKfip.js";import{u as Ye}from"./user-Bpo4z6Hs.js";import{S as me}from"./conditional_render-f3_nkObB.js";import{u as Bt}from"./index-t1Ly9aOo.js";import{R as qt}from"./reload_root_input-Dic-Zmfl.js";import{o as Vt,s as H,l as es}from"./types-COGEWJEq.js";import{u as ts}from"./shopping_cart-DnfuLuPH.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"13978386027a4a2683cfa43e79422df47742043f"}}catch{}})();const Ue={Package:.99},ss={Package:5e5},Ie=(t,s)=>{if(!s)return null;const r=s.variantId?String(s.variantId):s.id;return r?t.find(o=>o.productVariantId===r):null};function gr({variants:t,defaultVariant:s,coupon:r}){if(!s)return null;const{id:n,freePurchaseOnly:o,minimumPaidPrice:i,allowFreePurchases:c}=s;let d=n;if(r){let u=0;r.productVariantDiscounts.forEach(a=>{const l=t.find(m=>m.id===a.productVariantId&&m.quantity===1);l&&l.minimumPaidPrice-a.discountedPrice>u&&(u=l.minimumPaidPrice-a.discountedPrice,d=a.productVariantId)})}else if(o||c||i===0){let u=1/0;t.forEach(a=>{!a.allowFreePurchases&&a.minimumPaidPrice<u&&(u=a.minimumPaidPrice,d=a.id)})}return d}const Qe=.5,de=7.99,We=t=>t.minimumPaidPrice,ye=t=>t.maximumPrice,rs=t=>t.suggestedPrice,Ze=t=>t.royaltiesToRevenueRatio,Xe=t=>t.ratioOfRevenueToAuthors,Je=t=>t.ratioOfRevenueToCauses,ns=t=>t.allowFreePurchases,ue=(t,s,r)=>{const n=He(t,s,r);if(n!=null)return n;const o=We(s);return o>0?o:Ue.Package},He=(t,s,r)=>{if(t&&t.discountedPrice!==null&&t.discountedPrice!==void 0)return t.discountedPrice;if(r&&s){const n=Ie(r.productVariantDiscounts,s);if(n&&n.discountedPrice!==null&&n.discountedPrice!==void 0)return n.discountedPrice}return null},fe=(t,s,r)=>{if(ns(s))return 0;const n=He(t,s,r),o=We(s);return n!=null?o!==null?Math.min(n,o):n:o!==null&&o>0?o:Ue.Package},as=(t,s,r,n)=>{const o=fe(s,r,n);if(t<=o)return o;const i=ue(s,r,n),c=ss.Package;return t<i&&t>0&&(t=i),t>c&&(t=c),t},Be=(t,s)=>{if(t<=0)return 0;let r=t*Ze(s);return t<de&&(r-=Qe),Math.max(r,0)},qe=(t,s,r)=>{if(t===0)return 0;const n=Ze(r),o=(t/s+Qe)/n,i=t/s/n;return o>0&&o<de?Math.ceil(o*100)/100:i>=de?Math.ceil(i*100)/100:Math.ceil(de*100)/100},os=(t,s)=>{const r=Be(t,s)*Xe(s);return Math.floor(r*100)/100},is=(t,s)=>Be(t,s)*Je(s),Ve=(t,s)=>qe(t,Xe(s),s),et=(t,s)=>qe(t,Je(s),s),tt=(t,s,r,n,o)=>{if(typeof t=="string"&&(t=parseFloat(t)),isNaN(t))return rs(n);let i=null;switch(s){case"author":i=Ve(t,n);break;case"cause":i=et(t,n);break;default:i=t;break}return i=as(i,r,n,o),i},ls=({inputRef:t,youPayPrice:s,coupon:r,productVariantDiscount:n,compact:o=!1,idPrefix:i="",cartable:c,handleValueChange:d})=>{const u=`${i}unitPrice`,a=Number(s),[l,m]=f.useState(te(a)),g=p=>{m(p.currentTarget.value)},x=()=>{const p=Pt(t.current.value),h=tt(p,"product",n,c,r);d(h),m(h?te(h):te(a))},_=p=>{p.keyCode===13&&x()};return f.useEffect(()=>{m(te(a))},[s,a,m]),e.jsxs("section",{className:`${o?"pt-3":"pt-4"} pb-2`,children:[e.jsx("label",{htmlFor:u,className:`block tracking-wider text-black uppercase dark:text-white ${o?"text-xs":"text-sm"}`,children:e.jsx(N,{k:"w_you_pay"})}),e.jsx("div",{className:"flex flex-row items-center gap-x-6 gap-y-3",children:e.jsxs("div",{className:"relative mt-1 block rounded-md shadow-sm",children:[e.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:e.jsx("span",{className:"text-neutral-600 sm:text-sm dark:text-neutral-400",children:"$"})}),e.jsx("input",{type:"hidden",name:"unitPrice",value:a}),e.jsx("input",{ref:t,id:u,"aria-describedby":"price-currency",type:"text",inputMode:"decimal",value:l,onCh
3ange:g,onBlur:x,onKeyUp:_,placeholder:te(Number(n!=null&&n.discountedPrice?n.discountedPrice:c.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 dark:border-zinc-600 dark:bg-zinc-800 dark:text-white"})]})})]})};function cs(t){const s=f.useRef(t);return f.useEffect(()=>{s.current=t}),f.useMemo(()=>(...r)=>{var n;return(n=s.current)==null?void 0:n.call(s,...r)},[])}var ke="rovingFocusGroup.onEntryFocus",ds={bubbles:!1,cancelable:!0},ae="RovingFocusGroup",[Re,st,us]=Ft(ae),[fs,rt]=Ee(ae,[us]),[ms,xs]=fs(ae),nt=f.forwardRef((t,s)=>e.jsx(Re.Provider,{scope:t.__scopeRovingFocusGroup,children:e.jsx(Re.Slot,{scope:t.__scopeRovingFocusGroup,children:e.jsx(ps,{...t,ref:s})})}));nt.displayName=ae;var ps=f.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:i,currentTabStopId:c,defaultCurrentTabStopId:d,onCurrentTabStopIdChange:u,onEntryFocus:a,preventScrollOnEntryFocus:l=!1,...m}=t,g=f.useRef(null),x=xe(s,g),_=De(i),[p,h]=Ke({prop:c,defaultProp:d??null,onChange:u,caller:ae}),[y,R]=f.useState(!1),v=cs(a),k=st(r),j=f.useRef(!1),[b,C]=f.useState(0);return f.useEffect(()=>{const w=g.current;if(w)return w.addEventListener(ke,v),()=>w.removeEventListener(ke,v)},[v]),e.jsx(ms,{scope:r,orientation:n,dir:_,loop:o,currentTabStopId:p,onItemFocus:f.useCallback(w=>h(w),[h]),onItemShiftTab:f.useCallback(()=>R(!0),[]),onFocusableItemAdd:f.useCallback(()=>C(w=>w+1),[]),onFocusableItemRemove:f.useCallback(()=>C(w=>w-1),[]),children:e.jsx(B.div,{tabIndex:y||b===0?-1:0,"data-orientation":n,...m,ref:x,style:{outline:"none",...t.style},onMouseDown:U(t.onMouseDown,()=>{j.current=!0}),onFocus:U(t.onFocus,w=>{const E=!j.current;if(w.target===w.currentTarget&&E&&!y){const O=new CustomEvent(ke,ds);if(w.currentTarget.dispatchEvent(O),!O.defaultPrevented){const L=k().filter(P=>P.focusable),Y=L.find(P=>P.active),Q=L.find(P=>P.id===p),G=[Y,Q,...L].filter(Boolean).map(P=>P.ref.current);it(G,l)}}j.current=!1}),onBlur:U(t.onBlur,()=>R(!1))})})}),at="RovingFocusGroupItem",ot=f.forwardRef((t,s)=>{const{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:i,children:c,...d}=t,u=Ot(),a=i||u,l=xs(at,r),m=l.currentTabStopId===a,g=st(r),{onFocusableItemAdd:x,onFocusableItemRemove:_,currentTabStopId:p}=l;return f.useEffect(()=>{if(n)return x(),()=>_()},[n,x,_]),e.jsx(Re.ItemSlot,{scope:r,id:a,focusable:n,active:o,children:e.jsx(B.span,{tabIndex:m?0:-1,"data-orientation":l.orientation,...d,ref:s,onMouseDown:U(t.onMouseDown,h=>{n?l.onItemFocus(a):h.preventDefault()}),onFocus:U(t.onFocus,()=>l.onItemFocus(a)),onKeyDown:U(t.onKeyDown,h=>{if(h.key==="Tab"&&h.shiftKey){l.onItemShiftTab();return}if(h.target!==h.currentTarget)return;const y=_s(h,l.orientation,l.dir);if(y!==void 0){if(h.metaKey||h.ctrlKey||h.altKey||h.shiftKey)return;h.preventDefault();let v=g().filter(k=>k.focusable).map(k=>k.ref.current);if(y==="last")v.reverse();else if(y==="prev"||y==="next"){y==="prev"&&v.reverse();const k=v.indexOf(h.currentTarget);v=l.loop?js(v,k+1):v.slice(k+1)}setTimeout(()=>it(v))}}),children:typeof c=="function"?c({isCurrentTabStop:m,hasTabStop:p!=null}):c})})});ot.displayName=at;var hs={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function bs(t,s){return s!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function _s(t,s,r){const n=bs(t.key,r);if(!(s==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(s==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return hs[n]}function it(t,s=!1){const r=document.activeElement;for(const n of t)if(n===r||(n.focus({preventScroll:s}),document.activeElement!==r))return}function js(t,s){return t.map((r,n)=>t[(s+n)%t.length])}var ws=nt,gs=ot,Se="Radio",[vs,lt]=Ee(Se),[ys,ks]=vs(Se),ct=f.forwardRef((t,s)=>{const{__scopeRadio:r,name:n,checked:o=!1,required:i,disabled:c,value:d="on",onCheck:u,form:a,...l}=t,[m,g]=f.useState(null),x=xe(s,h=>g(h)),_=f.useRef(!1),p=m?a||!!m.closest("form"):!0;
3return e.jsxs(ys,{scope:r,checked:o,disabled:c,children:[e.jsx(B.button,{type:"button",role:"radio","aria-checked":o,"data-state":mt(o),"data-disabled":c?"":void 0,disabled:c,value:d,...l,ref:x,onClick:U(t.onClick,h=>{o||u==null||u(),p&&(_.current=h.isPropagationStopped(),_.current||h.stopPropagation())})}),p&&e.jsx(ft,{control:m,bubbles:!_.current,name:n,value:d,checked:o,required:i,disabled:c,form:a,style:{transform:"translateX(-100%)"}})]})});ct.displayName=Se;var dt="RadioIndicator",ut=f.forwardRef((t,s)=>{const{__scopeRadio:r,forceMount:n,...o}=t,i=ks(dt,r);return e.jsx(At,{present:n||i.checked,children:e.jsx(B.span,{"data-state":mt(i.checked),"data-disabled":i.disabled?"":void 0,...o,ref:s})})});ut.displayName=dt;var Cs="RadioBubbleInput",ft=f.forwardRef(({__scopeRadio:t,control:s,checked:r,bubbles:n=!0,...o},i)=>{const c=f.useRef(null),d=xe(c,i),u=Gt(r),a=Lt(s);return f.useEffect(()=>{const l=c.current;if(!l)return;const m=window.HTMLInputElement.prototype,x=Object.getOwnPropertyDescriptor(m,"checked").set;if(u!==r&&x){const _=new Event("click",{bubbles:n});x.call(l,r),l.dispatchEvent(_)}},[u,r,n]),e.jsx(B.input,{type:"radio","aria-hidden":!0,defaultChecked:r,...o,tabIndex:-1,ref:d,style:{...o.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});ft.displayName=Cs;function mt(t){return t?"checked":"unchecked"}var Ns=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],pe="RadioGroup",[Rs]=Ee(pe,[rt,lt]),xt=rt(),pt=lt(),[Es,Is
3]=Rs(pe),ht=f.forwardRef((t,s)=>{const{__scopeRadioGroup:r,name:n,defaultValue:o,value:i,required:c=!1,disabled:d=!1,orientation:u,dir:a,loop:l=!0,onValueChange:m,...g}=t,x=xt(r),_=De(a),[p,h]=Ke({prop:i,defaultProp:o??null,onChange:m,caller:pe});return e.jsx(Es,{scope:r,name:n,required:c,disabled:d,value:p,onValueChange:h,children:e.jsx(ws,{asChild:!0,...x,orientation:u,dir:_,loop:l,children:e.jsx(B.div,{role:"radiogroup","aria-required":c,"aria-orientation":u,"data-disabled":d?"":void 0,dir:_,...g,ref:s})})})});ht.displayName=pe;var bt="RadioGroupItem",_t=f.forwardRef((t,s)=>{const{__scopeRadioGroup:r,disabled:n,...o}=t,i=Is(bt,r),c=i.disabled||n,d=xt(r),u=pt(r),a=f.useRef(null),l=xe(s,a),m=i.value===o.value,g=f.useRef(!1);return f.useEffect(()=>{const x=p=>{Ns.includes(p.key)&&(g.current=!0)},_=()=>g.current=!1;return document.addEventListener("keydown",x),document.addEventListener("keyup",_),()=>{document.removeEventListener("keydown",x),document.removeEventListener("keyup",_)}},[]),e.jsx(gs,{asChild:!0,...d,focusable:!c,active:m,children:e.jsx(ct,{disabled:c,required:i.required,
3checked:m,...u,...o,name:i.name,ref:l,onCheck:()=>i.onValueChange(o.value),onKeyDown:U(x=>{x.key==="Enter"&&x.preventDefault()}),onFocus:U(o.onFocus,()=>{var x;g.current&&((x=a.current)==null||x.click())})})})});_t.displayName=bt;var Ss="RadioGroupIndicator",jt=f.forwardRef((t,s)=>{const{__scopeRadioGroup:r,...n}=t,o=pt(r);return e.jsx(ut,{...o,...n,ref:s})});jt.displayName=Ss;var Ts=ht,Ps=_t,Fs=jt;const Os=({packages:t,selectedPackage:s,onPackageChange:r,idPrefix:n=""})=>{var u;const{i18n:o}=ne();if(!t||t.length===0)return null;const i=(s==null?void 0:s.id)??((u=t==null?void 0:t[0])==null?void 0:u.id)??"",c=a=>{var l;a.preventDefault(),(l=document.getElementById("packages"))==null||l.scrollIntoView({behavior:"smooth",block:"start",inline:"nearest"})},d=a=>{r==null||r(a)};return e.jsxs("section",{className:"mt-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("h3",{className:"pb-1.5 text-lg font-medium text-neutral-700 uppercase dark:text-white",children:e.jsx(N,{k:"w_packages"})}),e.jsx("a",{href:"#packages",className:"pb-1 text-xs font-medium text-neutral-400 underline dark:text-neutral-300",onClick:c,children:e.jsx(N,{k:"w_details"})})]}),e.jsx("article",{children:e.jsx(Ts,{value:i,dir:o.dir(),"aria-label":"Packages",name:"Packages",onValueChange:d,orientation:"horizontal",className:"flex flex-col gap-1 pl-2",children:t.map(a=>e.jsxs("label",{className:S(a.id===s.id?"font-bold":"","flex cursor-pointer items-center space-x-4 text-sm"),htmlFor:`${n}${a.id}`,children:[e.jsx(Ps,{className:"data-[state=checked]:bg-azure-500 h-3 w-3 min-w-[0.75rem] rounded-full border border-black bg-white shadow-sm data-[state=checked]:font-bold dark:border-zinc-500 dark:bg-zinc-800",value:a.id,id:`${n}${a.id}`,children:e.jsx(Fs,{className:"relative flex h-full w-full items-center justify-center after:block after:h-1 after:w-1 after:rounded-full after:bg-white after:content-['']"})}),e.jsx("span",{children:a.name})]},a.id))})})]})},As=({allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,currentUser:o,freePurchaseRequiresMembership:i,isBundle:c,minimumPaidPrice:d,soldSeparately:u,suggestedPrice:a})=>e.jsxs(e.Fragment,{children:[e.jsx(N,{k:"w_product_authors_set_tip_html"}),e.jsx("br",{}),e.jsx("br",{}),c&&u?e.jsxs(e.Fragment,{children:[e.jsx(N,{k:"w_product_bundle_separate_price_html",opts:{suggested:I(u)}}),e.jsx("br",{}),e.jsx("br",{})]}):null,t?s&&r?e.jsxs(e.Fragment,{children:[e.jsx(N,{k:"w_product_min_paid_and_sug_tip_html",opts:{minimumPaidPrice:I(d),suggestedPrice:I(a)}}),e.jsx("br",{}),e.jsx("br",{}),e.jsx(N,{k:"w_product_free_with_coupon_used"})]}):i?o&&o.is_premium_reader?e.jsxs(e.Fragment,{children:[e.jsx(N,{k:"w_product_min_paid_and_sug_tip_html",opts:{minimumPaidPrice:I(d),suggestedPrice:I(a)}}),e.jsx("br",{}),e.jsx("br",{}),e.jsx(N,{k:"w_product_free_with_membership_thanks"})]}):s?e.jsxs(e.Fragment,{children:[e.jsx(N,{k:"w_product_min_paid_and_sug_tip_html",opts:{minimumPaidPrice:I(d),suggestedPrice:I(a)}}),e.jsx("br",{}),e.jsx("br",{}),e.jsx(N,{k:"w_product_cheap_with_coupon_used",opts:{couponPrice:n!==null?I(n):n}}),e.jsx("br",{}),e.jsx("br",{}),e.jsx(N,{k:"w_product_free_with_reader_membership"})]}):e.jsxs(e.Fragment,{children:[e.jsx(N,{k:"w_product_min_paid_and_sug_tip_html",opts:{minimumPaidPrice:I(d),suggestedPrice:I(a)}}),e.jsx("br",{}),e.jsx("br",{}),e.jsx(N,{k:"w_product_free_with_reader_membership"})]}):a===0?e.jsx(N,{k:"w_product_min_and_sug_free_tip_html",opts:{minimumPaidPrice:I(d)}}):e.jsx(N,{k:"w_product_min_free_price_tip_html",opts:{suggestedPrice:I(a)}}):s?e.jsx(N,{k:"w_product_cheap_with_coupon_used",opts:{couponPrice:n!==null?I(n):n}}):e.jsx(N,{k:"w_product_min_and_sug_price_tip_html",opts:{minimumPaidPrice:I(d),suggestedPrice:I(a)}})]}),Ls=({allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,muted:d,soldSeparately:u,subtext:a,suggestedPrice:l,children:m})=>{const g=Ye(),[x,_]=f.useState(null),[p,h]=f.useState(!1),[y,R]=f.useState(!1),v=f.useRef(null),k=f.useRef(null);f.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;const b=window.matchMedia("(hover: hover) and (pointer: fine)"),C=E=>{h(E.matches)};C(b);const w=E=>C(E);return b.addEventListener?b.addEventListener("change",w):b.addListener(w),()=>{b.removeEventListener?b.removeEventListener("change",w):b.removeListener(w)}},[]),f.useEffect(()=>{p&&y&&R(!1)},[p,y]),f.useEffect(()=>{if(p||!y||typeof document>"u")return;const b=w=>{var L,Y;const E=w.target;!E||(L=v.current)!=null&&L.contains(E)||(Y=k.current)!=null&&Y.contains(E)||R(!1)},C=["pointerdown","mousedown","touchstart"];
3return C.forEach(w=>document.addEventListener(w,b,!0)),()=>{C.forEach(w=>document.removeEventListener(w,b,!0))}},[p,y]),f.useEffect(()=>{if(typeof document>"u")return;let b=document.getElementById("cartable-tooltip-portal");b||(b=document.createElement("div"),b.id="cartable-tooltip-portal",b.setAttribute("data-headlessui-portal",""),b.style.zIndex="10040",document.body.appendChild(b)),_(b)},[]);const j=e.jsxs(Jt,{ref:k,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:b=>{var w;if(p)return;const C=b.target;if(C&&((w=v.current)!=null&&w.contains(C))){b.preventDefault();return}R(!1)},onEscapeKeyDown:()=>{p||R(!1)},children:[m??e.jsx(As,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,currentUser:g,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,soldSeparately:u,suggestedPrice:l}),e.jsx(Ht,{className:"fill-black"})]});return e.jsx(Qt,{delayDuration:0,children:e.jsxs(Wt,{open:p?void 0:y,children:[e.jsx(Zt,{asChild:!0,children:e.jsxs("button",{ref:v,className:"flex items-center space-x-1.5",type:"button",onClick:()=>{p||R(b=>!b)},"aria-expanded":y,"aria-haspopup":"dialog",children:[e.jsx("p",{className:S("text-sm leading-5 tracking-wider uppercase",d?"text-neutral-500":"text-neutral-600"),children:e.jsx(N,{k:a})}),e.jsx(Ne,{icon:Dt,width:"12px",height:"12px",className:"h-3 w-3 text-black"})]})}),x?e.jsx(Xt,{container:x,children:j}):j]})})},A=({allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,muted:d,price:u,quickBuyHeader:a,compact:l=!1,soldSeparately:m,subtext:g,suggestedPrice:x,tooltip:_})=>e.jsxs("div",{className:"space-y-2",children:[_&&!a?e.jsx(Ls,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,muted:d,soldSeparately:m,subtext:g,suggestedPrice:x}):e.jsx("div",{children:e.jsx("p",{className:S("text-sm leading-5 tracking-wider uppercase",d?"text-neutral-500":"text-neutral-600"),children:e.jsx(N,{k:g})})}),e.jsx("p",{className:S(l?"text-2xl font-semibold":a?"text-lg":"pb-2 text-3xl font-bold",d?"text-neutral-500 line-through":""),children:u==0?e.jsx(N,{k:"w_free"}):u!==null?I(u):u})]}),Gs=({allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,quickBuyHeader:d,compact:u=!1,soldSeparately:a,suggestedPrice:l})=>s?r?e.jsx(A,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,muted:!1,price:0,quickBuyHeader:d,compact:u,soldSeparately:a,subtext:"w_with_coupon",suggestedPrice:l,tooltip:!1}):t?e.jsx(A,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,muted:!1,price:n,quickBuyHeader:d,compact:u,soldSeparately:a,subtext:"w_with_coupon",suggestedPrice:l,tooltip:!0}):e.jsx(A,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,muted:!1,price:n,quickBuyHeader:d,compact:u,soldSeparately:a,subtext:"w_with_coupon",suggestedPrice:l,tooltip:!1}):null,Ms=({allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,quickBuyHeader:d,compact:u=!1,soldSeparately:a,suggestedPrice:l})=>t?s&&r?null:o?e.jsx(A,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,price:0,quickBuyHeader:d,compact:u,soldSeparately:a,subtext:"w_with_membership",suggestedPrice:l}):e.jsx(A,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,price:0,quickBuyHeader:d,compact:u,soldSeparately:a,subtext:"w_min_price",suggestedPrice:l}):null,zs={book:"book",bundle:"bundle",course:"course",track:"track"},wt=({quickBuyHeader:t,productType:s})=>{const r=s?zs[s]:"product";return e.jsx("div",{className:S(t?"hidden":"block"),children:e.jsx("div",{children:e.jsxs("p",{className:"text-lg leading-5 text-black",children:["This ",r," can only be purchased for free."]})})})},$s=({allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,quickBuyHeader:d,compact:u=!1,soldSeparately:a,suggestedPrice:l})=>{const m=i&&a&&a>c;return t||s?m&&s?null:c>l?e.jsx(A,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,price:c,quickBuyHeader:d,compact:u,soldSeparately:a,subtext:"w_min_paid_price",suggestedPrice:l,tooltip:!0}):e.jsx(A,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,muted:!!(r||s),price:l,quickBuyHeader:d,compact:u,soldSeparately:a,subtext:"w_suggested_price",suggestedPrice:l,tooltip:!0}):m?c===l?e.jsx(A,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,price:c,quickBuyHeader:d,compact:u,soldSeparately:a,subtext:"w_bundle_price",suggestedPrice:l,tooltip:!0}):e.jsxs(e.Fragment,{children:[e.jsx(A,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,price:c,quickBuyHeader:d,compact:u,soldSeparately:a,subtext:"w_min_price",suggestedPrice:l}),e.jsx(A,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,price:l,quickBuyHeader:d,compact:u,soldSeparately:a,subtext:"w_suggested_price",suggestedPrice:l,tooltip:!0})]}):e.jsxs(e.Fragment,{children:[e.jsx(A,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,price:c,quickBuyHeader:d,compact:u,soldSeparately:a,subtext:"w_min_price",suggestedPrice:l}),e.jsx(A,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,price:l,quickBuyHeader:d,compact:u,soldSeparately:a,subtext:"w_suggested_price",suggestedPrice:l,tooltip:!0})]})},Ks=({allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,quickBuyHeader:d,compact:u=!1,soldSeparately:a,suggestedPrice:l})=>i&&a&&a>c?e.jsx(A,{allowFreePurchases:t,couponActive:s,couponFree:r,couponPrice:n,freePurchaseRequiresMembership:o,isBundle:i,minimumPaidPrice:c,muted:!0,price:a,quickBuyHeader:d,compact:u,soldSeparately:a,subtext:"w_bought_separately",suggestedPrice:l}):null,Ds=({cartable:t,coupon:s=null,quickBuyHeader:r=!1,productVariantDiscount:n,isBundle:o=!1,soldSeparatelyPrice:i,onLayoutChange:c,compact:d=!1,isInQuickBuyPurchaseDetails:u=!1,productType:a})=>{const l=f.useRef(null),[m,g]=f.useState(!1),[x,_]=f.useState(0);let{allowFreePurchases:p,boughtSeparatelyCombinedSuggestedPrice:h,freePurchaseOnly:y,freePurchaseRequiresMembership:R,minimumPaidPrice:v,suggestedPrice:k}=t;if(y)return e.jsx(wt,{quickBuyHeader:r,productType:a});let j=!1,b=!1,C=t.minimumPaidPrice,w=n||null;if(!w&&s&&(w=Ie(s.productVariantDiscounts,t)??null),w){const G=w.discountedPrice;j=G<v,j&&(C=G,b=C===0,p=p||b)}const E=o?i??h:void 0,O=o&&typeof E=="number"&&E>0;f.useEffect(()=>{const G=l.current;if(!G||typeof window>"u")return;const P=()=>{const V=Array.from(G.children),$=V.length;if(_(Z=>Z===$?Z:$),$<=1){g(!0);return}const K=V[0].offsetTop,he=V.some((Z,ee)=>ee>0&&Z.offsetTop===K);g(!he)};P();const W="ResizeObserver"in window?new ResizeObserver(P):null;return W==null||W.observe(G),window.addEventListener("resize",P),()=>{W==null||W.disconnect(),window.removeEventListener("resize",P)}},[O,p,v,k]),f.useEffect(()=>{c==null||c(m)},[m,c]);const L=!u&&x===3,Y=()=>u?S("text-sm hidden xs:inline-block xs:mr-4"):S("flex w-full flex-wrap","justify-around ga
3p-2","text-center sm:text-left",r&&"[&>*]:inline-block [&>*]:mr-4"),Q=u?"":L?"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",q=d?"max-w-full md:max-w-lg":"";return e.jsx("div",{className:S("flex",!d&&"mt-4"),children:e.jsxs("div",{ref:l,className:S(Y(),!d&&"my-2",Q,q),children:[e.jsx(Ks,{allowFreePurchases:p,couponActive:j,couponFree:b,couponPrice:C,freePurchaseRequiresMembership:R,isBundle:O,minimumPaidPrice:v,quickBuyHeader:r,compact:d,soldSeparately:E,suggestedPrice:k}),e.jsx(Ms,{allowFreePurchases:p,couponActive:j,couponFree:b,couponPrice:C,freePurchaseRequiresMembership:R,isBundle:O,minimumPaidPrice:v,quickBuyHeader:r,compact:d,soldSeparately:E,suggestedPrice:k}),e.jsx($s,{allowFreePurchases:p,couponActive:j,couponFree:b,couponPrice:C,freePurchaseRequiresMembership:R,isBundle:O,minimumPaidPrice:v,quickBuyHeader:r,compact:d,soldSeparately:E,suggestedPrice:k}),s&&e.jsx(Gs,{allowFreePurchases:p,couponActive:j,couponFree:b,couponPrice:C,freePurchaseRequiresMembership:R,isBundle:O,minimumPaidPrice:v,quickBuyHeader:r,compact:d,soldSeparately:E,suggestedPrice:k})]})})},Ce=({ariaLabel:t,disabled:s=!1,label:r,labelCount:n,maximum:o,name:i,sliderMinimum:c,sliderStyle:d,step:u,updateValue:a,value:l,money:m=!0,className:g})=>{let x,_,p;switch(d){case"primary":_="bg-sky-400",x="bg-sky-600 border-sky-800",p="focus-visible:ring-sky-700 border-white";break;case"secondary":_="bg-lime-400",x="bg-lime-600 border-lime-800",p="focus-visible:ring-lime-700 border-white";break;case"tertiary":_="bg-violet-400",x="bg-violet-600 border-violet-800",p="focus-visible:ring-violet-700 border-white";break;case"quaternary":_="bg-teal-400",x="bg-teal-500 border-teal-700",p="focus-visible:ring-teal-600 border-white";break;default:_="bg-neutral-500",x="bg-neutral-50",p="focus-visible:ring-neutral-500";break}const h=typeof g=="string"&&g.split(/\s+/).some(j=>j.startsWith("py-")),y=Math.min(l,o),R=o-c,v=R>0?(y-c)/R*100:0,k=Bt();return e.jsxs("section",{className:S(g,!h&&"py-2",s&&"cursor-not-allowed opacity-50"),children:[e.jsx(me,{test:i,children:e.jsx("input",{type:"hidden",value:String(l),name:i})}),e.jsx("h2",{className:"text-xs tracking-wider text-black uppercase sm:text-sm dark:text-white",children:n?e.jsx(N,{k:r,opts:{count:n}}):e.jsx(N,{k:r})}),k?e.jsxs(Mt,{value:[y],onValueChange:j=>a(j[0]),max:o,min:c,step:u,"aria-label":t,name:i,disabled:s,className:"relative flex h-12 w-full touch-none items-center",style:{"--lp-thumb-pct":`${v}%`},children:[e.jsx(zt,{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 dar
3k:border-neutral-700 dark:before:[background:repeating-linear-gradient(to_right,_#444,_#444_1px,_transparent_1px,_transparent_5px)]",children:e.jsx($t,{className:S("pointer-events-none 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",x,l===0?"left-2! -ml-[0.6rem] pr-3":""),children:e.jsx("span",{className:`absolute text-sm font-semibold break-normal ${l>o/6?"left-2 text-white":l===0?"left-[calc(100%+0.75rem)]":"left-[calc(100%+1.25rem)]"}`,children:m?I(l):l})})}),e.jsx(Kt,{className:S("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,l===0?"ml-4!":"")})]}):e.jsx("div",{"aria-hidden":!0,className:"relative flex h-12 w-full items-center",style:{"--lp-thumb-pct":`${v}%`}})]})},$e=({disabled:t=!1,youPayPrice:s,cartable:r,coupon:n,productVariantDiscount:o,numberOfAuthors:i,numberOfCauses:c,showWhatAuthorGets:d,showWhatCauseGets:u,handleValueChange:a,compact:l=!1})=>{const{t:m}=ne(),[g,x]=f.useState(s),[_,p]=f.useState(ye(r)),h=f.useCallback((j,b)=>{let C=Number(j);if(C>0)switch(b){case"author":C=Ve(C,r);break;case"cause":C=et(C,r);break}else C=0;const w=tt(C,"product",o,r,n);x(w),a(w)},[r,n,a,o]);f.useEffect(()=>{ye(r)!==_&&p(ye(r)),h(s,"product")},[r,_,h,s]);const y=g<=0?0:os(g,r),R=g<=0||!r.ratioOfRevenueToCauses?0:is(g,r),v=S("w-full md:max-w-lg",l&&"mt-2 mb-2 flex flex-col gap-y-3"),k=l?"py-0":void 0;return e.jsxs("div",{className:v,children:[e.jsx(Ce,{className:k,disabled:t,value:g,minimum:fe(o,r,n),minimumNonZero:ue(o,r,n),sliderMinimum:0,maximum:_,ariaLabel:"w_you_pay",label:"w_you_pay",name:"you_pay_price",sliderStyle:"primary",step:.01,updateValue:j=>h(j,"product")}),e.jsx(me,{test:d,children:e.jsx(Ce,{className:k,disabled:t,value:y,minimum:fe(o,r,n),minimumNonZero:ue(o,r,n),sliderMinimum:0,maximum:_,ariaLabel:m("w_author_earns",{count:i}),label:m("w_author_earns",{count:i}),labelCount:i,name:"author_earnings",sliderStyle:"secondary",step:.01,updateValue:j=>h(j,"author")})}),e.jsx(me,{test:u,children:e.jsx(Ce,{className:k,disabled:t,value:R,minimum:fe(o,r,n),minimumNonZero:ue(o,r,n),sliderMinimum:0,maximum:_,ariaLabel:"w_cause_gets",label:c>1?"w_causes_get":"w_cause_gets",name:"cause_earnings",sliderStyle:"tertiary",step:.01,updateValue:j=>h(j,"cause")})})]})},se=1,Ys=5e3,Us=({quantity:t,onChange:s,unitPrice:r,max:n=Ys,disabled:o=!1})=>{const i=Math.max(se,Math.floor(n)),c=l=>Math.min(Math.max(Math.round(l)||se,se),i),d=l=>s(c(l)),u=t>1&&r!=null&&r>0,a="flex h-9 w-9 items-center justify-center text-neutral-600 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent dark:text-neutral-300 dark:hover:bg-zinc-700";return e.jsxs("section",{className:"pt-1",children:[e.jsx("label",{className:"block text-sm tracking-wider text-black uppercase dark:text-white",children:e.jsx(N,{k:"w_quantity",opts:{defaultValue:"Quantity"}})}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-4 gap-y-2",children:[e.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-lg border border-neutral-300 bg-white dark:border-zinc-600 dark:bg-zinc-800",children:[e.jsx("button",{type:"button","aria-label":"Decrease quantity",onClick:()=>d(t-1),disabled:o||t<=se,className:a,children:e.jsx(Ne,{icon:Yt,className:"h-3 w-3"})}),e.jsx("input",{type:"text",inputMode:"numeric","aria-label":"Quantity",value:t,onChange:l=>{const m=l.currentTarget.value.replace(/\D/g,"");d(m===""?se:parseInt(m,10))},disabled:o,className:"h-9 w-12 border-x border-neutral-300 bg-transparent text-center text-sm font-semibold text-black tabular-nums focus:outline-hidden dark:border-zinc-600 dark:text-white"}),e.jsx("button",{type:"button","aria-label":"Increase quantity",onClick:()=>d(t+1),disabled:o||t>=i,className:a,children:e.jsx(Ne,{icon:Ut,className:"h-3 w-3"})})]}
3),u&&e.jsxs("span",{className:"text-sm text-neutral-600 dark:text-neutral-400",children:[I(r)," Ã ",t," ="," ",e.jsx("span",{className:"font-semibold text-black dark:text-white",children:I(r*t)})]})]})]})};Vt({action:es("add-to-wishlist").optional(),productId:H(),productVariantId:H(),productCouponId:H().optional(),purchaseSourceId:H().optional(),purchaseSourceType:H().optional(),purchaseSource:H().optional()});const Qs=t=>t?Array.isArray(t.formErrors)&&t.formErrors.length>0?!0:t.fieldErrors?Object.values(t.fieldErrors).some(s=>Array.isArray(s)?s.length>0:!!s):!1:!1;function Ws({productId:t,productVariantId:s,productCouponId:r,purchaseSourceId:n,purchaseSourceType:o,purchaseSource:i}){return e.jsxs(e.Fragment,{children:[e.jsx(z,{name:"productId",value:t}),e.jsx(z,{name:"productCouponId",value:r??""}),e.jsx(z,{name:"purchaseSourceId",value:n??""}),e.jsx(z,{name:"purchaseSourceType",value:o??""}),e.jsx(z,{name:"purchaseSource",value:i??""})]})}const vr=({action:t,authors:s,cartable:r,disabled:n=!1,causes:o=[],coupon:i,showPackageSelection:c=!0,onPackageChange:d,productType:u,productVariantDiscount:a,product:l,quickBuyHeader:m,timestamp:g,compactPricing:x=!1,isBundle:_=!1,soldSeparatelyPrice:p,orgMembershipBudgets:h,redirectToCartAfterAdd:y=!1,alreadyOnWishlist:R=!1,redirectToCartAfterWishlistAdd:v=!0,onWishlistAdded:k,editMode:j,hideCredits:b=!1,showQuantity:C=!1,inlineBuyRow:w=!1,replaceInCart:E=!1,formId:O,onPriceChange:L,fullWidthButtons:Y=!1})=>{const{id:Q,showWhatAuthorGets:q,showWhatCauseGets:G,suggestedPrice:P}=r,{hasMultiplePackages:W,variants:V,title:$}=l,K=l.freePurchaseOnly||r.freePurchaseOnly,he=f.useRef(null),Z=f.useCallback(()=>!!(a!=null&&a.discountedPrice)||!!i,[a,i]),ee=f.useCallback(()=>{var ze;const F=i&&((ze=Ie(i.productVariantDiscounts,r))==null?void 0:ze.discountedPrice);return a&&(a==null?void 0:a.discountedPrice)||F},[i,r,a]),[oe,be]=f.useState(()=>{if(j)return j.currentUnitPrice;const F=Z(),M=ee();return F&&M!==null&&M!==void 0?M:P}),Te=(a==null?void 0:a.bookCredits)??null,Pe=(a==null?void 0:a.courseCredits)??null,ie=Te??Pe??r.numCredits??0;Te??Pe??r.numCredits;const[gt,vt]=f.useState(ie);f.useEffect(()=>{vt(F=>F===ie?F:ie)},[r.id,ie,a]),f.useEffect(()=>{if(j)return;const F=Z(),M=ee();be(F&&M!==null&&M!==void 0?M:P)},[Z,ee,P,j]);const[le,yt]=f.useState((j==null?void 0:j.quantity)??1),_e=F=>{const M=parseFloat(F);be(M),L==null||L(M)},D=Ye(),kt=(D==null?void 0:D.bookCredits)||0,Ct=(D==null?void 0:D.courseCredits)||0,Nt=((D==null?void 0:D.activeOrgMemberships)??[]).filter(F=>F.role==="learner"),T=St({key:"cartableForm"}),je=ts(),we=f.useRef(!1),[X,Fe]=f.useState(R);f.useEffect(()=>{T.state==="submitting"&&T.formData&&T.formData.get("submit")==="wishlist"&&T.formData.get("productId")===l.id&&T.formData.get("productVariantId")===Q&&(we.current=!0)},[T.state,T.formData,l.id,Q]),f.useEffect(()=>{if(!we.current||T.state!=="idle")return;const F=T.data;Qs(F)?Fe(!1):(Fe(!0),k==null||k(),v&&typeof window<"u"&&window.location.assign("/shopping_cart")),we.current=!1},[T.state,T.data,v,k]);const{t:Rt}=ne(),Et=!!(d&&c&&W&&!m)&&!K,Oe=O?`${O}-`:"",ge=S("min-h-10 whitespace-nowrap sm:text-base",w?"w-auto min-w-48":Y?"w-full":"w-auto min-w-72 self-start"),ce=!!(j&&C&&!K&&!j.isGift),ve=()=>e.jsx(ls,{inputRef:he,youPayPrice:oe,coupon:i,productVariantDiscount:a,compact:x,idPrefix:Oe,cartable:r,handleValueChange:_e}),J=C&&!K&&e.jsx(Us,{quantity:le,onChange:yt,unitPrice:Number(oe),disabled:T.state!=="idle"||n}),Ae=e.jsx(re,{"aria-label":E?`Upgrade to ${$} in cart`:`${X?"Move":"Add"} ${$} to Cart`,type:"submit",name:"submit",value:"shopping_cart",disabled:T.state!=="idle"||n,className:ge,children:e.jsx(N,{k:E?"w_upgrade_in_cart":X?"w_move_to_cart":"w_add_to_cart"})}),Le={type:"submit",name:"submit",value:"wishlist","aria-label":Rt("a_add_title_to_wishlist",{title:$}),disabled:T.state!=="idle"||n},Ge=!X&&e.jsx(re,{...Le,color:"outline-blue",className:ge,children:e.jsx(N,{k:"w_add_to_wishlist"})}),It=!X&&e.jsx("button",{...Le,className:"mt-0.5 -mb-1.5 block w-full cursor-pointer py-1.5 text-center text-xs whitespace-nowrap text-neutral-500 transition-colors hover:text-neutral-700 hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-blue-600 disabled:cursor-default disabled:opacity-50 dark:text-neutral-400 dark:hover:text-neutral-200",children:e.jsx(N,{k:"w_add_to_wishlist"})}),Me=e.jsx(re,{"aria-label":ce?`Update ${$} in cart`:`Update the price for ${$}`,type:"submit",disabled:T.state!=="idle"||n,className:ge,children:e.jsx(N,{k:ce?"w_update":"w_update_price"})});return e.jsxs("div",{className:"flex flex-col",children:[K?e.jsxs(e.Fragment,{children:[e.jsx(wt,{quickBuyHeader:!!m,productType:u}),e.jsx($e,{disabled:!0,youPayPrice:0,cartable:r,coupon:i,productVariantDiscount:a,numberOfAuthors:(s==null?void 0:s.length)||0,numberOfCauses:o.length,showWhatAuthorGets:q,showWhatCauseGets:G,handleValueChange:_e,compact:x})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:S("mb-0",x&&"mb-2"),children:e.jsx(Ds,{cartable:r,coupon:i,productVariantDiscount:a,isBundle:_,soldSeparatelyPrice:p,compact:x})}),e.jsx($e,{youPayPrice:oe,cartable:r,coupon:i,productVariantDiscount:a,numberOfAuthors:(s==null?void 0:s.length)||0,numberOfCauses:o.length,showWhatAuthorGets:q,showWhatCauseGets:G,handleValueChange:_e,compact:x})]}),e.jsx(me,{test:Et,children:e.jsx(Os,{packages:V,selectedPackage:r,onPackage
3Change:d,idPrefix:Oe})}),e.jsxs(T.Form,{id:O,action:t,method:"post",children:[e.jsx(qt,{}),e.jsx(z,{name:"timestamp",value:g??(je==null?void 0:je.updatedAt)}),K?e.jsx("input",{type:"hidden",name:"unitPrice",value:"0"}):w?null:ve(),e.jsxs("div",{className:"mt-4 flex flex-col pb-4",children:[e.jsx("input",{type:"hidden",name:"productVariantId",value:Q}),j?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"hidden",name:"action",value:"update"}),e.jsx("input",{type:"hidden",name:"you_pay_price",value:oe}),e.jsx("input",{type:"hidden",name:"quantity",value:le}),e.jsx("input",{type:"hidden",name:"is-gift",value:j.isGift?"on":""}),j.isGift&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"hidden",name:"giftee-email",value:j.gifteeEmail??""}),e.jsx("input",{type:"hidden",name:"gift-note",value:j.giftNote??""})]}),w?e.jsxs("div",{className:"flex flex-wrap items-end gap-x-6 gap-y-2",children:[!K&&ve(),ce&&e.jsx("div",{className:"pb-2",children:J}),e.jsx("div",{className:"pb-2",children:Me})]}):e.jsxs(e.Fragment,{children:[ce&&e.jsx("div",{className:"mb-3",children:J}),e.jsx("div",{className:"xs:flex-row xs:justify-start flex flex-col gap-3",children:Me})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"hidden",name:"quantity",value:le}),y&&e.jsx("input",{type:"hidden",name:"redirectToCart",value:"true"}),E&&e.jsx("input",{type:"hidden",name:"replaceContainedBooks",value:"true"}),e.jsx(Ws,{productId:l.id,productVariantId:Q,productCouponId:i==null?void 0:i.id,purchaseSourceId:"",purchaseSourceType:"",purchaseSource:""}),w?e.jsxs("div",{className:"flex flex-wrap items-end gap-x-6 gap-y-2",children:[!K&&e.jsx("div",{className:X?void 0:"pb-4",children:ve()}),J&&e.jsx("div",{className:X?"pb-2":"pb-6",children:J}),e.jsxs("div",{className:X?"pb-2":void 0,children:[Ae,It]})]}):e.jsxs(e.Fragment,{children:[J&&e.jsx("div",{className:"mb-3",children:J}),e.jsx("div",{className:"xs:flex-row xs:justify-start flex flex-col gap-3",children:Ae}),Ge&&e.jsx("div",{className:"xs:flex-row xs:justify-start mt-2 flex flex-col gap-3",children:Ge})]}),!b&&le===1&&e.jsx(Xs,{currentUser:D,currentCredits:gt,bookCredits:kt,courseCredits:Ct,orgMemberships:Nt,orgMembershipBudgets:h,cartable:r,coupon:i,fetcher:T,disabled:n,title:$,isBook:r.taxedAsEbook,isProductFreeOnly:K,productVariantDiscount:a,fullWidthButtons:Y})]})]})]})]})};function Zs(t,s,r){const n=r?(s==null?void 0:s.organization.bookCredits)??t.organization.bookCredits:(s==null?void 0:s.organization.courseCredits)??t.organization.courseCredits;if(!s)return Math.max(0,n);const o=r?s.bookCreditCap:s.courseCreditCap,i=r?s.bookCreditsUsedThisPeriod:s.courseCreditsUsedThisPeriod,c=o==null?1/0:o-i;return Math.max(0,Math.min(n,c))}function Xs({currentUser:t,currentCredits:s,bookCredits:r,courseCredits:n,orgMemberships:o,orgMembershipBudgets:i,cartable:c,coupon:d,fetcher:u,disabled:a,title:l,isBook:m,isProductFreeOnly:g,productVariantDiscount:x,fullWidthButtons:_=!1}){var R,v;const{t:p}=ne();if(g||x&&x.discountedPrice===0)return null;const h=[];if(t){const k=m?r:n;k>=1&&h.push({type:"personal",available:k});const j=new Map((i??[]).map(b=>[b.id,b]));for(const b of o){const C=Zs(b,j.get(b.id),m);C>=1&&h.push({type:"org",membership:b,available:C})}}const y=p(m?"w_n_book_credits":"w_n_course_credits",{count:s});return h.length===0?(m?(R=t==null?void 0:t.readerSubscription)==null?void 0:R.hasBookCredits:(v=t==null?void 0:t.readerSubscription)==null?void 0:v.hasCourseCredits)||s<1?null:e.jsx(Js,{isBook:m,credits:s,fullWidthButtons:_}):e.jsx(Hs,{sources:h,creditTypeText:y,currentCredits:s,bookCredits:r,courseCredits:n,cartable:c,coupon:d,fetcher:u,disabled:a,title:l,isBook:m,fullWidthButtons:_})}function Js({isBook:t,credits:s,fullWidthButtons:r=!1}){return e.jsxs("p",{className:S("mt-3 text-xs leading-relaxed text-neutral-500 dark:text-neutral-400",r?"w-full":"w-auto max-w-96 min-w-72 self-start"),children:[e.jsx("span",{"aria-hidden":"true",className:"me-1.5 text-teal-600/70 dark:text-teal-400/70",children:"â¦"}),e.jsx(N,{k:t?"w_credit_hint_reader":"w_credit_hint_learner",count:s,components:{membershipLink:e.jsx(Tt,{to:t?"/readers/membership?lp_src=credit_hint_reader":"/readers/learner_memberships?lp_src=credit_hint_learner",hideDefaultStyles:!0,underline:!0,className:"text-neutral-600 decoration-neutral-300 underline-offset-2 transition-colors hover:text-teal-700 hover:decoration-teal-600 dar
3k:text-neutral-300 dark:decoration-neutral-600 dark:hover:text-teal-400 dark:hover:decoration-teal-500"})}})]})}function Hs({sources:t,creditTypeText:s,currentCredits:r,bookCredits:n,courseCredits:o,cartable:i,coupon:c,fetcher:d,disabled:u,title:a,isBook:l,fullWidthButtons:m=!1}){const{t:g}=ne(),[x,_]=f.useState(0),p=t[x]??t[0],h=y=>g(l?"w_n_book_credits":"w_n_course_credits",{count:y})+" "+g("w_available");return e.jsxs("div",{className:S("mt-4",m?"w-full":"w-auto min-w-72 self-start"),children:[e.jsx("div",{className:"mb-2 text-sm font-semibold text-neutral-700 dark:text-neutral-200",children:e.jsx(N,{k:"w_buy_with_credits_title"})}),e.jsx("div",{className:"mb-3 flex flex-col gap-2",children:t.map((y,R)=>{const v=R===x,k=y.type==="personal"?"â¦":"ð¢",j=t.some(w=>w.type==="org"),b=y.type==="personal"?g(j?"w_credit_personal_credits":"w_credit_balance"):y.membership.organization.name,C=h(y.available);return e.jsxs("button",{type:"button",onClick:()=>_(R),className:S("flex items-center gap-3 rounded-lg border px-3.5 py-2.5 text-left transition-colors",v?"border-teal-600 bg-teal-50 dark:border-teal-400 dark:bg-teal-950/30":"border-neutral-200 bg-white hover:border-teal-400 dark:border-neutral-600 dar
3k:bg-neutral-800 dark:hover:border-teal-500"),children:[e.jsx("span",{className:S("flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2",v?"border-teal-600 dark:border-teal-400":"border-neutral-300 dark:border-neutral-500"),children:v&&e.jsx("span",{className:"h-2.5 w-2.5 rounded-full bg-teal-600 dark:bg-teal-400"})}),e.jsx("span",{className:"text-lg leading-none",children:k}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-sm font-semibold text-neutral-800 dark:text-neutral-100",children:b}),e.jsx("span",{className:"text-xs text-neutral-500 dark:text-neutral-400",children:C})]})]},y.type==="personal"?"personal":y.membership.organization.id)})}),p.type==="personal"?e.jsxs(re,{"aria-label":`Buy ${a} with Credits Now`,type:"submit",name:"submit",value:"credits",color:"deepteal",disabled:d.state!=="idle"||u,className:"min-h-9 w-full border-2! text-sm",children:[(c==null?void 0:c.id)&&e.jsx(z,{name:"couponId",value:c.id}),e.jsx(z,{name:"numCredits",value:r-(i.taxedAsEbook?n:o)}),e.jsx(z,{name:"productType",value:i.taxedAsEbook?"book":"course"}),e.jsx(N,{k:l?"w_buy_with_book_credits":"w_buy_with_course_credits",count:r})]}):e.jsxs(re,{"aria-label":`Buy ${a} with ${p.membership.organization.name} credits`,type:"submit",name:"submit",value:"org_credits",color:"deepteal",disabled:d.state!=="idle"||u,className:"min-h-9 w-full border-2! text-sm",children:[(c==null?void 0:c.id)&&e.jsx(z,{name:"couponId",value:c.id}),e.jsx(z,{name:"organizationId",value:p.membership.organization.id}),e.jsx(N,{k:l?"w_buy_with_book_credits":"w_buy_with_course_credits",count:r})]})]})}export{vr as C,gr as a,Ie as g}; 4 5//# debugId=7af92811-0b80-5646-9fcc-7f2a5edf66d0
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.