1import{j as e,m as _}from"./mod-04ce686a-RPK1-APr.js";import{r as c}from"./mod-1bc04b52-LZlvPb-j.js";import{c as z}from"./mod-7150b8be-ClpOO9iO.js";import{B as A}from"./mod-c3e2d78f-DryM_HhE.js";import{T as l}from"./mod-1bc04b52-DBK5RBgN.js";import"./mod-36c5fbfc-BWSHNbDj.js";import{c as E}from"./mod-6fd89734-DWHvss_h.js";import{c as F,T as Q,a as H,b as G}from"./mod-1fb69198-B0yEyRop.js";import{e as J,c as V,u as K}from"./mod-fa76d99a-DxIuuhWl.js";import{D as W}from"./mod-1bc04b52-BuaZwY25.js";import{g as X,c as Y}from"./mod-851a39f9-DQs6b0i8.js";import{P as Z}from"./mod-1bc04b52-IgZJTuLB.js";import{u as ee}from"./mod-93ed5dbb-UUHoq7XN.js";function te({product:s}){const{t:i}=ee("product"),a=z(),N=J(),M=V(),u=c.useRef(!1),d=X(s,"c_pdfURL")||void 0,r=Y(s,"c_quantityLimit")??0,o=s.id,m=s.name??"",b=s.shortDescription??"",y=s.longDescription??"",k=s.inventory?.orderable===!1,h=s.imageGroups?.find(t=>t.images?.length)?.images?.[0],p=h?.disBaseLink??h?.link??"",q=h?.alt||m||"Product",f=M?.productItems?.reduce((t,n)=>n.productId===o?t+(n.quantity??0):t,0)??0,O=r>0?Math.max(r-f,0):void 0,g=r>0&&f>=r,[v,w]=c.useState(1),[S,j]=c.useState(""),[T,D]=c.useState(null),[$,C]=c.useState(!1),{openSheet:I}=K();c.useEffect(()=>{if(!u.current){if(a.data?.success&&a.data.basket){u.current=!0;const t=a.data.basket.productItems?.find(n=>n.productId===o);N(a.data.basket),w(1),j(""),I("quick-add-confirmation",{productName:m,productId:o,price:0,imageUrl:p||void 0,itemId:t?.itemId,quantity:1})}else if(a.data?.success===!1){u.current=!0;const t=a.data.error,n=typeof t=="string"?t:t?.message??"Failed to add to bag";j(n)}}},[a.data,N,o,m,p,I]);const R=c.useCallback(()=>{g||(j(""),u.current=!1,a.submit({productItem:JSON.stringify({productId:o,quantity:v})},{method:"POST",action:"/action/cart-item-add"}))},[g,v,o,a]),x=a.state==="submitting",L=!r||k?null:f>0?`${f} of ${r} added to cart`:`Limit of ${r} per order`,P=p?e.jsx(W,{src:p,alt:q,widths:{base:172},className:"size-full object-cover"}):null,B="size-[86px] shrink-0 overflow-hidden bg-muted",U=(t,n)=>d?e.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:n,children:t}):t;return e.jsxs("div",{className:"flex flex-col gap-4 md:flex-row md:items-center md:gap-9","data-testid":`material-product-${o}`,children:[e.jsxs("div",{className:"flex w-full items-start gap-4 md:items-center",children:[d?e.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:`block ${B}`,children:P}):e.jsx("div",{className:B,children:P}),e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[U(e.jsx(l,{as:"span",variant:"static14",className:"font-bold text-foreground",children:m}),"hover:underline"),y&&e.jsx(F,{children:e.jsxs(Q,{open:$,onOpenChange:C,children:[e.jsx(H,{asChild:!0,children:e.jsx("button",{type:"button",onClick:()=>C(t=>!t),"aria-label":"More information",className:"shrink-0 text-foreground",children:e.jsx(_,{className:"size-5"})})}),e.jsx(G,{className:"max-w-xs",children:y})]})})]}),b&&e.jsx(l,{as:"p",variant:"static14",className:"text-foreground",children:b}),L&&e.jsx(l,{as:"p",variant:"static11",className:"text-foreground",children:L})]}),d&&e.jsx("a",{href:d,target:"_blank",rel:"noopener noreferrer",className:"shrink-0 text-sm text-foreground underline hover:no-underline",children:"View"})]}),!k&&e.jsxs("div",{className:"flex w-full flex-col gap-2 md:w-auto",children:[e.jsxs("div",{className:"flex w-full items-center justify-between gap-9 md:w-auto md:justify-end",children:[e.jsx(Z,{value:String(v),onChange:w,quantityLimit:r||void 0,stockLevel:O,productName:m,busy:x,hideLabel:!0,hideInlineMessage:!0,onInventoryMessageChange:D,className:"shrink-0"}),e.jsx(A,{onClick:R,disabled:g||x,className:"uppercase",variant:"outline",children:e.jsxs("span",{className:"grid",children:[e.jsx("span",{className:E("col-start-1 row-start-1",x&&"invisible"),children:i("addToBag")}),e.jsx("span",{className:E("col-start-1 row-start-1",!x&&"invisible"),children:i("adding")})]})})]}),T&&e.jsx(l,{"data-testid":"material-product-inventory-message",as:"p",variant:"static11",className:"text-destructive",role:"alert","aria-live":"polite",children:T}),S&&e.jsx(l,{as:"p",variant:"static11",className:"text-destructive",children:S})]})]})}function xe({groups:s}){return s.length===0?e.jsx("div",{className:"py-12 text-center",children:e.jsx(l,{as:"p",variant:"muted",className:"text-muted-foreground",children:"No sales tools are currently available."})}):e.jsx("div",{className:"space-y-10","data-testid":"sales-tools-content",children:s.map(i=>e.jsxs("section",{"data-testid":`collateral-group-${i.name}`,className:"space-y-4",children:[e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsx(l,{as:"h2",variant:"h2",children:i.name}),e.jsx("span",{className:"bg-secondary px-2 py-1 text-base font-bold uppercase text-foreground",children:"FREE"})]}),e.jsx("div",{className:"space-y-8",children:i.products.map(a=>e.jsx(te,{product:a},a.id))})]},i.name))})}function he(){return e.jsx("div",{className:"space-y-10","aria-hidden":"true",children:[1,2,3].map(s=>e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"mb-4 h-8 w-48 bg-muted"}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-24 bg-muted"}),e.jsx("div",{className:"h-24 bg-muted"})]})]},s))})}export{he as C,xe as S};
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.