PageSourceSearch

https://paperworld-hamburg.de/assets/ProductDetail-DlVSNnyv.js

js paperworld-hamburg.de collected 2026-10-06 16:37:14 UTC 114,513 bytes, 59 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ProductLowerSection-Cwq_xm-G.js","assets/vendor-DkvdaZ_o.js","assets/query-BW4_HVfB.js","assets/index-D5Z1SVx2.js","assets/router-BgWwGfEz.js","assets/supabase-1Y6IIqT4.js","assets/ui-BEX0hx1v.js","assets/index-DCiZLGw9.css","assets/skeleton-B0ebgHDt.js","assets/ProductCard-B4uP5s4h.js","assets/imageAltText-CaTMmKur.js","assets/pallet-icon-D7BSRi81.js","assets/safe-html-CODRCF7f.js"])))=>i.map(i=>d[i]);
2import{j as e,R as P,r as p,h as ms}from"./vendor-DkvdaZ_o.js";import{s as Je,a as us}from"./stripHtml-BYQb6noi.js";import{L as fe,u as pt,c as hs,d as gs}from"./router-BgWwGfEz.js";import{a as Ut,u as me}from"./query-BW4_HVfB.js";import{av as et,cu as Zt,B as ce,s as te,bn as ht,C as je,a as we,A as fs,bp as Kt,cv as xs,J as be,co as ps,cw as bs,cx as vs,Q as ys,D as Qt,q as Gt,r as Yt,t as Wt,v as js,ad as ze,a7 as Ze,a8 as Ke,a9 as Qe,aa as Ge,ac as pe,m as ws,R as gt,cy as Et,cz as _s,cA as Fe,cB as bt,cC as vt,Y as Ie,ak as Xt,be as Ht,cD as Ns,p as yt,aB as Cs,cf as Ss,V as Ye,cE as ks,aY as Es,l as Oe,c2 as As,ax as Ls,ay as Fs,cF as qs,a3 as Ds,bq as zs,cc as Ms,W as Ce,aG as At,K as Lt,cb as Is,aH as tt,cG as Ts,T as Jt,cH as ye,bf as Ft,aI as Bs,aF as Ps,aA as Os,aC as $s,cI as Rs,br as ve,H as st,cJ as Me,bs as De,cK as nt,$ as Vs,ae as Us,aZ as Zs,a0 as Ks,k as Qs,cL as it,cM as Gs,cN as Ys,cO as Ws}from"./index-D5Z1SVx2.js";import{S as re}from"./skeleton-B0ebgHDt.js";import{B as Xs,a as Hs,b as $e,c as at,d as rt,e as Js}from"./breadcrumb-CHWLA4Wg.js";import{C as es,a as ts,b as ss}from"./collapsible-vkXbSppY.js";import{T as qt,a as Dt,b as zt,c as Mt}from"./tooltip-CI1tvqb2.js";import{u as en,g as tn,i as lt}from"./useAllAttributes-D3DccukT.js";import{p as ns}from"./paperAbcData-LpoFLHDw.js";import{u as sn}from"./index.esm-C2VCbg0h.js";import{z,t as nn}from"./index-BKdvSifg.js";import{F as an,a as Se,b as ke,c as Ee,d as Ae,e as Le}from"./form-Clkp2ew9.js";import{S as rn}from"./smart-email-input-CdyOKbuf.js";import{T as is}from"./textarea-DW0uU-g8.js";import{S as ft}from"./safe-html-CODRCF7f.js";import{S as jt,a as ln}from"./StarRating-BbgszjrO.js";import{t as on,r as cn}from"./imageAltText-CaTMmKur.js";import{T as dn,a as mn,b as ot,c as It}from"./tabs-CD_1EUsZ.js";import{_ as un}from"./supabase-1Y6IIqT4.js";import{u as hn,r as gn}from"./useProductReviews-COWKflTA.js";import{p as fn}from"./pallet-icon-D7BSRi81.js";import"./ui-BEX0hx1v.js";const xn=({product:t,categories:n=[]})=>{const r=(()=>{if(!t.categories)return[];const o=[],c=new Map(n.map(m=>[m.id,m]));let h=n.find(m=>{var l;return m.slug===((l=t.categories)==null?void 0:l.slug)});for(;h&&(o.unshift(h),h.parent_id);)h=c.get(h.parent_id);return o})(),a=o=>Zt(o,n);return e.jsx(Xs,{className:"mb-6",children:e.jsxs(Hs,{children:[e.jsx($e,{children:e.jsx(at,{asChild:!0,children:e.jsx(fe,{to:"/",children:"Startseite"})})}),r.map((o,c)=>e.jsxs(P.Fragment,{children:[e.jsx(rt,{children:e.jsx(et,{className:"h-4 w-4"})}),e.jsx($e,{children:e.jsx(at,{asChild:!0,children:e.jsx(fe,{to:a(o.slug),children:o.name})})})]},o.id)),r.length===0&&t.categories&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{children:e.jsx(et,{className:"h-4 w-4"})}),e.jsx($e,{children:e.jsx(at,{asChild:!0,children:e.jsx(fe,{to:a(t.categories.slug),children:t.categories.name})})})]}),e.jsx(rt,{children:e.jsx(et,{className:"h-4 w-4"})}),e.jsx($e,{children:e.jsx(Js,{children:t.name})})]})})},_e={pastell:{weiss:"#FFFFFF",lachs:"#FBCDB1",mittelorange:"#FFA62C",chamois:"#FFDDA0",hellchamois:"#F7EED1",hellgelb:"#F9EFAA",mittelgelb:"#EDE882",naturweiss:"#FFFDD6",grau:"#CBCCC6",hellgruen:"#D8EBCB",hellgrün:"#D8EBCB",hellgrau:"#D9DED8",mittelgruen:"#B2DCAA",mittelgrün:"#B2DCAA",hellblau:"#BEDEDB",mittelblau:"#A4D9DD",violett:"#C7BFE6",rosa:"#EC95B5",hellrosa:"#F8ABBF"},neon:{neonorange:"#FEAD51",neongelb:"#E7FE3A",neongruen:"#C4F63D",neongrün:"#C4F63D",neonpink:"#FF96C1"},intensiv:{intensivrot:"#CF4545",intensivorange:"#F56C40",orange:"#F8943C",intensivgelb:"#FFD020",gelb:"#FCE160","leuchtend grün":"#AFD04D","leuchtend gruen":"#AFD04D",grün:"#8DC94F",gruen:"#8DC94F",intensivgrün:"#59B65D",intensivgruen:"#59B65D",blau:"#3DBBD2",intensivblau:"#0095BD"}},Re=t=>{const n=t.toLowerCase();return _e.neon[n]?"neon":_e.intensiv[n]?"intensiv":_e.pastell[n]?"pastell":n.startsWith("neon")?"neon":n.startsWith("intensiv")||n.startsWith("leuchtend")?"intensiv":"pastell"},ct=t=>{const n=t.toLowerCase();return _e.pastell[n]||_e.neon[n]||_e.intensiv[n]||"#CCCCCC"},pn={pastell:["weiss","naturweiss","hellchamois","chamois","hellgelb","mittelgelb","mittelorange","lachs","hellgrau","grau","hellgruen","hellgrün","mittelgruen","mittelgrün","hellblau","mittelblau","violett","hellrosa","rosa"],neon:["neongelb","neonorange","neongruen","neongrün","neonpink"],intensiv:["gelb","intensivgelb","orange","intensivorange","intensivrot","leuchtend grün","leuchtend gruen","grün","gruen","intensivgrün","intensivgruen","blau","intensivblau"]},dt=(t,n)=>{const i=pn[n]||[];return t.sort((r,a)=>{const o=i.indexOf(r.value.toLowerCase()),c=i.indexOf(a.value.toLowerCase());return o!==-1&&c!==-1?o-c:o!==-1?-1:c!==-1?1:r.value.localeCompare(a.value,"de")})},bn=t=>t.some(n=>{const i=n.value.toLowerCase();return _e.pastell[i]||_e.neon[i]||_e.intensiv[i]}),vn={weiß:"#FFFFFF",weiss:"#FFFFFF","natron/braun":"#C4A77D",braun:"#8B6914",grau:"#808080",schwarz:"#000000",rot:"#CC0000",blau:"#0066CC",grün:"#008800",gruen:"#008800",gelb:"#FFCC00"},yn=t=>{const n=t.toLowerCase();return vn[n]||"#CCCCCC"},jn=({colorOptions:t,flatLayout:n=!1})=>{var m;const i=!n&&bn(t),r=p.useMemo(()=>({pastell:dt(t.filter(l=>
2Re(l.value)==="pastell"),"pastell"),neon:dt(t.filter(l=>Re(l.value)==="neon"),"neon"),intensiv:dt(t.filter(l=>Re(l.value)==="intensiv"),"intensiv")}),[t]),a=t.find(l=>l.isActive),o=a?Re(a.value):"pastell",[c,h]=p.useState(o);if(p.useEffect(()=>{h(o)},[o]),t.length<=1)return null;if(n){const l=[...t].sort((u,d)=>u.value.localeCompare(d.value,"de"));return e.jsx(qt,{children:e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(u=>{const d=ct(u.value)!=="#CCCCCC"?ct(u.value):yn(u.value),g=d==="#FFFFFF"||d==="#FFFDD6"||d==="#F7EED1";return e.jsxs(Dt,{children:[e.jsx(zt,{asChild:!0,children:e.jsx(fe,{to:`/${u.slug}`,className:"group",children:e.jsx("button",{type:"button",disabled:u.isActive,style:{backgroundColor:d,color:g?"initial":"white",border:u.isActive?"3px solid black":"1px solid black",cursor:u.isActive?"default":"pointer",width:"40px",height:"40px",borderRadius:"4px",transition:"all 0.2s ease"},className:`relative ${!u.isActive&&"hover:scale-110 hover:border-2"}`,children:e.jsx("span",{className:"sr-only",children:u.value})})})}),e.jsx(Mt,{children:e.jsx("p",{children:u.value})})]},u.value)})})})}return i?e.jsxs("div",{children:[e.jsx("div",{className:"flex gap-1 mb-4",children:Object.entries(r).map(([l,u])=>{if(u.length===0)return null;const d=l===c;return e.jsx(ce,{variant:d?"default":"outline",size:"sm",onClick:()=>h(l),className:`capitalize ${d?"bg-primary text-primary-foreground border-2 border-foreground":"hover:border-primary hover:text-primary"}`,children:l},l)})}),e.jsx(qt,{children:e.jsx("div",{className:"flex flex-wrap gap-2",children:(m=r[c])==null?void 0:m.map(l=>{const u=ct(l.value),d=u==="#FFFFFF"||u==="#FFFDD6"||u==="#F7EED1";return e.jsxs(Dt,{children:[e.jsx(zt,{asChild:!0,children:e.jsx(fe,{to:`/${l.slug}`,className:"group",children:e.jsx("button",{type:"button",disabled:l.isActive,style:{backgroundColor:u,color:d?"initial":"white",border:l.isActive?"3px solid black":"1px solid black",cursor:l.isActive?"default":"pointer",width:"40px",height:"40px",borderRadius:"4px",transition:"all 0.2s ease"},className:`relative ${!l.isActive&&"hover:scale-110 hover:border-2"}`,children:e.jsx("span",{className:"sr-only",children:l.value})})})}),e.jsx(Mt,{children:e.jsx("p",{children:l.value})})]},l.value)})})})]}):e.jsx("div",{children:e.jsx("div",{className:"flex flex-wrap gap-2",children:t.map(l=>e.jsx(fe,{to:`/${l.slug}`,className:`group ${l.isActive?"pointer-events-none":""}`,children:e.jsx(ce,{variant:l.isActive?"default":"outline",size:"sm",disabled:l.isActive,className:`min-w-[80px] transition-all disabled:opacity-100 ${l.isActive?"bg-primary/90 hover:bg-primary/90 text-primary-foreground cursor-default border-primary":"hover:border-primary hover:text-primary"}`,children:l.value})},l.value))})})},wn=({formatOptions:t,grammarOptions:n,colorOptions:i,perforationOptions:r,lagenOptions:a=[],rollenBreiteOptions:o=[],materialOptions:c=[],fensterOptions:h=[],verschlussOptions:m=[],currentProductSlug:l})=>{const u=Ut();p.useEffect(()=>{const d=new Set;[...t,...n,...i,...r,...a,...o,...c,...h,...m].forEach(g=>{g.slug&&g.slug!==l&&d.add(g.slug)}),Array.from(d).forEach(g=>{u.prefetchQuery({queryKey:["product",g],queryFn:async()=>{const{data:_,error:s}=await te.from("products").select(`
3              *,
4              categories(name, slug, packaging_unit_label),
5              brands(name, slug)
6            `).eq("slug",g).eq("is_active",!0).maybeSingle();if(s)throw s;if(!_)throw new Error("Produkt nicht gefunden");return _},staleTime:5*60*1e3}),u.prefetchQuery({queryKey:["product-attributes",g],queryFn:async()=>{const _=u.getQueryData(["product",g]);if(!(_!=null&&_.id))return[];const{data:s,error:E}=await te.from("product_attribute_assignments").select(`
7              *,
8              product_attributes(name, type, unit)
9            `).eq("product_id",_.id);if(E)throw E;return s||[]},staleTime:5*60*1e3}),u.prefetchQuery({queryKey:["price-tiers",g],queryFn:async()=>{const _=u.getQueryData(["product",g]);if(!(_!=null&&_.id))return[];const{data:s,error:E}=await te.from("products").select("tiered_pricing").eq("id",_.id).single();if(E)throw E;return s!=null&&s.tiered_pricing?s.tiered_pricing.split(",").map((N,j)=>{const[q,k]=N.split(":");return{id:`tier-${j}`,product_id:_.id,min_quantity:parseInt(q.trim()),price:parseFloat(k.trim())}}).filter(N=>!isNaN(N.min_quantity)&&!isNaN(N.price)):[]},staleTime:5*60*1e3})})},[t,n,i,r,a,o,c,h,m,l,u])},_n={A6:{w:9,h:12},A5:{w:12,h:17},SRA5:{w:13,h:18},A4:{w:17,h:24},SRA4:{w:18,h:25}
9,A3:{w:24,h:34},SRA3:{w:26,h:35},DL:{w:9,h:18},C6:{w:9,h:13},C5:{w:13,h:19},C4:{w:19,h:26},B6:{w:10,h:14},B5:{w:14,h:20},B4:{w:20,h:29}};function Nn(t){const n=t.match(/\b(SRA[0-5]|A[0-6]|B[0-6]|C[0-6]|DL)\b/i);return n?n[1].toUpperCase():null}function Tt({value:t,active:n,className:i}){const r=Nn(t),a=r?_n[r]:void 0;return a?e.jsx("span",{className:ht("relative inline-flex items-center justify-center shrink-0","w-9 h-9",i),"aria-hidden":"true",children:e.jsx("span",{className:ht("block rounded-[2px] border border-current transition-colors",n?"bg-current/20":"bg-current/5"),style:{width:`${a.w}px`,height:`${a.h}px`}})}):null}const Cn=[],Sn=[];function kn(t,n,i){var o;const r=i[n];if(!r)return null;const a=t.product_attribute_assignments||[];for(const c of a){const h=(o=c.product_attributes)==null?void 0:o.slug;if(h&&r.slugs.includes(h))return c.value}return null}const as=p.memo(({currentProduct:t,onAvailabilityChange:n})=>{const[i,r]=p.useState({}),[a,o]=p.useState({}),[c,h]=p.useState([]),{data:m}=en(),l=p.useMemo(()=>tn(m||[]),[m]),u=p.useRef(n);p.useEffect(()=>{u.current=n},[n]);const{data:d,isLoading:g}=me({queryKey:["product-family-config",t.id],queryFn:async()=>{const{data:b,error:f}=await te.from("products").select(`
10          id, 
11          family_id,
12          brand_id,
13          category_id,
14          product_families(
15            id,
16            name,
17            variation_attributes
18          )
19        `).eq("id",t.id).single();if(f)throw f;return b}}),{data:_}=me({queryKey:["product-category-chain",d==null?void 0:d.category_id],queryFn:async()=>{const b=[];let f=(d==null?void 0:d.category_id)??null;for(let D=0;D<5&&f;D++){const{data:M,error:K}=await te.from("categories").select("slug, parent_id").eq("id",f).maybeSingle();if(K||!M)break;b.push(M.slug),f=M.parent_id??null}return b},enabled:!!(d!=null&&d.category_id)}),s=(_??[]).includes("hygieneartikel"),{data:E,isLoading:N}=me({queryKey:["family-products",d==null?void 0:d.family_id,d==null?void 0:d.brand_id],queryFn:async()=>{if(!(d!=null&&d.family_id))return[];let b=te.from("products").select(`
20          id, name, slug, price, sale_price, image_url, stock_quantity, is_active, brand_id,
21          product_attribute_assignments(
22            value,
23            product_attributes(slug, name)
24          )
25        `).eq("family_id",d.family_id).eq("is_active",!0);d.brand_id&&(b=b.eq("brand_id",d.brand_id));const{data:f,error:D}=await b.limit(200);if(D)throw D;return f||[]},enabled:!!(d!=null&&d.family_id)}),{data:j}=me({queryKey:["variation-links-frontend",t.id],queryFn:async()=>{const{data:b,error:f}=await te.from("product_variation_links").select("target_product_id, link_type").eq("source_product_id",t.id);if(f)throw f;return b||[]}}),q=j??Cn,k=p.useMemo(()=>{const b=q.filter(f=>f.link_type==="include").map(f=>f.target_product_id).filter(Boolean);return b.sort(),b},[q]),L=k.join("|"),{data:w}=me({queryKey:["manual-variation-products",t.id,L],queryFn:async()=>{if(k.length===0)return[];const{data:b,error:f}=await te.from("products").select(`
26          id, name, slug, price, sale_price, image_url, stock_quantity, is_active, brand_id,
27          product_attribute_assignments(
28            value,
29            product_attributes(slug, name)
30          )
31        `).in("id",k).eq("is_active",!0);if(f)throw f;return b||[]},enabled:k.length>0}),C=w??Sn,A=p.useMemo(()=>{if(g||N)return null;if(!!!(d!=null&&d.family_id)&&C.length===0)return{options:{},attrs:[],currentVals:{},hasVariants:!1};const f=d==null?void 0:d.product_families,D=[...(f==null?void 0:f.variation_attributes)||[]],M=(y,U)=>kn(y,U,l),K=new Set(q.filter(y=>y.link_type==="exclude").map(y=>y.target_product_id)),se=lt(t.name),ae=(E||[]).filter(y=>lt(y.name)===se&&!K.has(y.id)),T=C.filter(y=>lt(y.name)===se&&!K.has(y.id)),O=new Set,Z=[...ae,...T].filter(y=>O.has(y.id)?!1:(O.add(y.id),!0));
31if(D.length===0)for(const y of Object.keys(l)){if(y==="ries")continue;const U=new Set;for(const F of Z){const B=M(F,y);if(B&&U.add(B),U.size>1)break}U.size>1&&D.push(y)}if(C.length>0){const y=Object.keys(l).filter(U=>!D.includes(U));for(const U of y){const F=new Set;for(const B of Z){const Y=M(B,U);if(Y&&F.add(Y),F.size>1)break}F.size>1&&D.push(U)}}const J=Z.find(y=>y.id===t.id),ne={};for(const y of D){const U=J?M(J,y):null;U&&(ne[y]=U)}const v=ne.farbe??null,S={};for(const y of D){const U=l[y];if(!U)continue;const F=v&&y!=="farbe"?Z.filter(I=>M(I,"farbe")===v):Z,B=new Set;for(const I of F){const W=M(I,y);W&&B.add(W)}y==="ries"&&(B.add("geriest"),B.add("ungeriest")),y==="farbe"&&v&&B.add(v);const Y=Array.from(B).map(I=>{let W=F.find(Q=>{if(M(Q,y)!==I)return!1;for(const H of D){if(H===y)continue;const le=ne[H];if(!le)continue;if(M(Q,H)!==le)return!1}return!0});if(!W){const Q=F.filter(ee=>M(ee,y)===I);if(Q.length>0){let ee=-1;for(const H of Q){let le=0;for(const x of D){if(x===y)continue;const $=ne[x];if(!$)continue;M(H,x)===$&&(le+=x==="format"?10:1)}le>ee&&(ee=le,W=H)}W||(W=Q[0])}}const ue=y==="ries"?!0:F.some(Q=>M(Q,y)===I),he=F.some(Q=>{if(M(Q,y)!==I)return!1;for(const H of D){if(H===y||y==="ries"&&H==="ries")continue;const le=ne[H];if(le&&M(Q,H)!==le)return!1}return!0});return{value:I,slug:(W==null?void 0:W.slug)||t.slug,isActive:I===ne[y],isAvailable:ue,hasFullMatch:he}});U.sortFn?Y.sort((I,W)=>U.sortFn(I.value,W.value)):Y.sort((I,W)=>I.value.localeCompare(W.value,"de")),S[y]=Y}const V=Object.values(S).some(y=>y.length>1)||C.length>0;return{options:S,attrs:D,currentVals:ne,hasVariants:V}},[d,E,C,q,t.id,t.name,t.slug,g,N,l]);return p.useEffect(()=>{var b;A&&(r(A.options),h(A.attrs),o(A.currentVals),(b=u.current)==null||b.call(u,A.hasVariants))},[A]),wn({formatOptions:i.format||[],grammarOptions:i.grammatur||[],colorOptions:i.farbe||[],perforationOptions:i.lochung||[],lagenOptions:i.lagen||[],rollenBreiteOptions:i.breite||[],materialOptions:i.material||[],fensterOptions:i.fenster||[],verschlussOptions:i.klebung||i.verschluss||[],currentProductSlug:t.slug}),g||N?e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-6 bg-muted rounded w-48 mb-4"}),e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((b,f)=>e.jsx("div",{className:"h-10 bg-muted rounded"},f))})]}):!(d!=null&&d.family_id)&&C.length===0||c.length===0&&C.length===0?null:e.jsx("div",{className:"space-y-4",children:c.map(b=>{var D,M;const f=i[b];return!f||f.length<=1?null:b==="farbe"?e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:(D=l[b])==null?void 0:D.label}),e.jsx(jn,{colorOptions:f,flatLayout:s})]},b):e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:(M=l[b])==null?void 0:M.label}),e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(K=>{const se=K.isActive,ae=K.isAvailable,T=K.hasFullMatch!==!1,O=b==="format";return e.jsx(ce,{variant:se?"default":"outline",size:"sm",className:ht("transition-all duration-200",O?"h-12 pl-2 pr-3 gap-2":"min-w-[60px] h-10 px-4",se&&"ring-2 ring-primary ring-offset-2",!ae&&"opacity-40 grayscale cursor-not-allowed",!T&&!se&&"opacity-50 bg-muted/50 text-muted-foreground border-dashed"),asChild:ae,disabled:!ae,children:ae?e.jsxs(fe,{to:`/${K.slug}`,children:[O&&e.jsx(Tt,{value:K.value,active:se}),e.jsx("span",{children:K.value})]}):e.jsxs("span",{className:"inline-flex items-center gap-2",children:[O&&e.jsx(Tt,{value:K.value,active:se}),e.jsx("span",{children:K.value})]})},K.value)})})]},b)})})});as.displayName="ProductVariations";const xt=[{name:"FSC",image:"/images/certificates/FSC.jpg",type:"environmental"},{name:"EU-Ecolabel",image:"/images/certificates/EU_Blume.jpg",type:"environmental"},{name:"Blauer Engel",image:"/images/certificates/Blauer_Engel.png",type:"environmental"},{name:"Cradle to Cradle",image:"/images/certificates/Cradletocradle.png",type:"environmental"},{name:"CO2-neutral",image:"/images/certificates/CO2_neutral.png",type:"environmental"},{name:"PEFC",image:"/images/certificates/PEFC.png",type:"environmental"},{name:"PCF",image:"/images/certificates/PCF.png",type:"environmental"},{name:"TCF",image:"/images/certificates/TCF.png",type:"environmental"},{name:"ECF",image:"/images/certificates/ECF.png",type:"environmental"},{name:"ISO 14001",image:"/images/certificates/ISO_14001.png",type:"environmental"},{name:"ISO 50001",image:"/images/certificates/ISO_50001.png",type:"environmental"},{name:"Biogas",image:"/images/certificates/Biogas.png",type:"environmental"},{name:"ColorLok",image:"/images/certificates/ColorLok_Logo.jpg",type:"manufacturer"},{name:"ISO 9001",image:"/images/certificates/ISO_9001.png",type:"manufacturer"},{name:"ISO 9706",image:"/images/certificates/ISO_9706_DIN_EN.png",type:"manufacturer"},{name:"ISO 45001",image:"/images/certificates/ISO_45001.png",type:"manufacturer"},{name:"OHSAS 18001",image:"/images/certificates/ISO_45001.png",type:"manufacturer"},{name:"DIN EN 12281",image:"/images/certificates/DIN_EN_12281.png",type:"manufacturer"},{name:"DIN 6738 LDK 24-85",image:"/images/certificates/6738_DIN_LDK_24-85.png",type:"quality"},{name:"DIN 6738",image:"/images/certificates/6738_DIN_LDK_24-85.png",type:"quality"},{name:"ISO 20494",image:"/images/certificates/ISO_20494.png",type:"quality"}],rs={"eu ecolabel":"EU-Ecolabel",euecolabel:"EU-Ecolabel","eu blume":"EU-Ecolabel","eu-blume":"EU-Ecolabel","tcf (total chlorfrei)":"TCF","tcf total chlorfrei":"TCF","totally chlorine free":"TCF","ecf (elementar chlorfrei)":"ECF","elementally chlorine free":"ECF","din iso 9001":"ISO 9001","din iso 9706":"ISO 9706","din en iso 9001":"ISO 9001","din en iso 9706":"ISO 9706","iso 12281":"DIN EN 12281","co2 neutral":"CO2-neutral",co2neutral:"CO2-neutral",klimaneutral:"CO2-neutral","cradle-to-cradle":"Cradle to Cradle",c2c:"Cradle to Cradle","pefc-zertifiziert":"PEFC",recyclingpapier:"Recycling","recycling-papier":"Recycling","recycling papier":"Recycling"},Te=t=>t.toLowerCase().replace(/[®™©]/g,"").replace(/\s+/g," ").trim(),ls=(()=>{const t=new Map;for(const n of xt)t.set(Te(n.name),n);for(const[n,i]of Object.entries(rs)){const r=xt.find(a=>a.name===i);r&&t.set(Te(n),r)}return t})();function En(t){if(!t)return null;const n=Te(t);return ls.get(n)??null}function An(t){if(!t)return[];const n=t.split(",").map(a=>
31a.trim()).filter(Boolean),i=new Set,r=[];for(const a of n){const o=En(a);o&&!i.has(o.name)&&(i.add(o.name),r.push(o))}return r}xt.map(t=>t.name);function Ln(t){if(!t)return t;const n=t.trim(),i=Te(n),r=ls.get(i);if(r)return r.name;for(const[a,o]of Object.entries(rs))if(Te(a)===i)return o;return n}const Fn=["umweltzertifikate","herstellerzertifikate"],qn=t=>t.replace(/[^a-zA-Z0-9äöüÄÖÜß]/g,"-").toLowerCase(),Bt=t=>{const n=t.toLowerCase().trim();return ns.find(i=>{const r=i.term.toLowerCase();return!!(r===n||n.includes(r)||r.includes(n)||r.split(/[\/,&]/).map(o=>o.trim()).some(o=>o===n||n.includes(o)||o.includes(n)))})},Pt={environmental:0,manufacturer:1,quality:2},Dn=t=>{const n=i=>/\d/.test(i);return[...t].sort((i,r)=>{const a=Pt[i.type]-Pt[r.type];if(a!==0)return a;const o=n(i.name),c=n(r.name);return o&&!c?-1:!o&&c?1:0})},Ot=t=>{var r,a;if(!(t!=null&&t.length))return[];const n=new Set,i=[];for(const o of t){const c=(a=(r=o.product_attributes)==null?void 0:r.slug)==null?void 0:a.toLowerCase();if(!(!c||!Fn.includes(c)))for(const h of An(o.value))n.has(h.name)||(n.add(h.name),i.push(h))}return Dn(i)},os=p.memo(({productId:t,open:n,onOpenChange:i,preloadedAttributes:r})=>{const[a,o]=p.useState([]),c=pt();if(p.useEffect(()=>{if(r){o(Ot(r));return}if(!t)return;let m=!1;return(async()=>{const{data:l,error:u}=await te.from("product_attribute_assignments").select("value, product_attributes(slug, name)").eq("product_id",t);m||u||!l||o(Ot(l))})(),()=>{m=!0}},[t,r]),a.length===0)return null;const h=m=>{const l=Bt(m);l&&c(`/papierratgeber/papier-abc#term-${qn(l.term)}`)};return e.jsxs(es,{open:n,onOpenChange:i,children:[e.jsx(ts,{asChild:!0,children:e.jsx(je,{className:"cursor-pointer hover:shadow-md transition-shadow",children:e.jsx(we,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-primary/10 rounded-full flex items-center justify-center",children:e.jsx(fs,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Zertifikate & Standards"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[a.length," Qualitätssiegel anzeigen"]})]})]}),e.jsx(Kt,{className:"w-4 h-4 text-muted-foreground"})]})})})}),e.jsx(ss,{children:e.jsx(je,{className:"mt-2",children:e.jsx(we,{className:"p-4 pt-0",children:e.jsx("div",{className:"flex flex-wrap items-center justify-center gap-3 pt-2",children:a.map(m=>{const l=!!Bt(m.name);return e.jsx("div",{className:`flex-shrink-0 ${l?"cursor-pointer group":""}`,onClick:()=>l&&h(m.name),title:l?`${m.name} – Im Papier-ABC ansehen`:m.name,children:e.jsx("img",{src:m.image,alt:m.name,className:`h-12 w-auto object-contain transition-transform duration-200 ${l?"hover:scale-110 group-hover:ring-2 group-hover:ring-primary/40 group-hover:rounded":"hover:scale-110"}`,onError:u=>{u.target.style.display="none"}})},m.name)})})})})})]})});os.displayName="ProductCertificates";const zn={sm:"h-9",md:"h-10",lg:"h-11"},Mn=({product:t,size:n="md",className:i})=>{const{isInWishlist:r,toggle:a,loading:o}=xs(),c=r(t.id),h=p.useMemo(()=>({product_id:t.id,product:{id:t.id,name:t.name,slug:t.slug,price:t.price,sale_price:t.sale_price??null,image_url:t.image_url??null,short_description:t.short_description??null}}),[t]);return e.jsxs(ce,{type:"button",variant:c?"secondary":"outline",className:["w-full",zn[n],i].filter(Boolean).join(" "),onClick:()=>{const m=!c;a(h),be.success(m?"Zur Wunschliste hinzugefügt":"Von Wunschliste entfernt",{description:m?`${t.name} wurde gemerkt.`:`${t.name} wurde entfernt.`,duration:2500})},disabled:o,"aria-pressed":c,"aria-label":c?"Von Merkliste entfernen":"Zur Merkliste hinzufügen",children:[e.jsx(ps,{className:`mr-2 h-5 w-5 transition-transform ${c?"fill-primary text-primary scale-110":"text-foreground"}`}),c?"Gemerkt":"Merken"]})},In={sm:"h-9",md:"h-10",lg:"h-11"},Tn=({product:t,size:n="md",className:i})=>{const{isInCompare:r,toggle:a,canAddMore:o}=bs(),c=r(t.id),h=p.useMemo(()=>
31({product_id:t.id,product:{id:t.id,name:t.name,slug:t.slug,price:t.price,sale_price:t.sale_price??null,image_url:t.image_url??null,short_description:t.short_description??null}}),[t]),m=()=>{const l=!c;if(l&&!o){be.error("Maximale Anzahl erreicht",{description:"Sie können maximal 6 Produkte vergleichen.",duration:3e3});return}a(h),be.success(l?"Zum Vergleich hinzugefügt":"Vom Vergleich entfernt",{description:l?`${t.name} wurde zum Vergleich hinzugefügt.`:`${t.name} wurde entfernt.`,duration:2500})};return e.jsxs(ce,{type:"button",variant:c?"secondary":"outline",className:["w-full",In[n],i].filter(Boolean).join(" "),onClick:m,"aria-pressed":c,"aria-label":c?"Vom Vergleich entfernen":"Zum Vergleich hinzufügen",children:[e.jsx(vs,{className:`mr-2 h-5 w-5 transition-transform ${c?"text-primary scale-110":"text-foreground"}`}),c?"Im Vergleich":"Vergleichen"]})};z.object({name:z.string().min(2,"Name muss mindestens 2 Zeichen lang sein").max(100,"Name darf nicht länger als 100 Zeichen sein").regex(/^[a-zA-ZäöüÄÖÜß\s-]+$/,"Name darf nur Buchstaben, Leerzeichen und Bindestriche enthalten"),email:z.string().email("Bitte geben Sie eine gültige E-Mail-Adresse ein").max(255,"E-Mail darf nicht länger als 255 Zeichen sein"),phone:z.string().optional(),company:z.string().max(200,"Firmenname darf nicht länger als 200 Zeichen sein").optional(),subject:z.string().min(5,"Betreff muss mindestens 5 Zeichen lang sein").max(200,"Betreff darf nicht länger als 200 Zeichen sein"),message:z.string().min(10,"Nachricht muss mindestens 10 Zeichen lang sein").max(2e3,"Nachricht darf nicht länger als 2000 Zeichen sein")});z.object({email:z.string().email("Bitte geben Sie eine gültige E-Mail-Adresse ein").max(255,"E-Mail darf nicht länger als 255 Zeichen sein"),firstName:z.string().min(2,"Vorname muss mindestens 2 Zeichen lang sein").max(100,"Vorname darf nicht länger als 100 Zeichen sein").regex(/^[a-zA-ZäöüÄÖÜß\s-]+$/,"Vorname darf nur Buchstaben enthalten").optional(),source:z.string().max(50,"Quelle darf nicht länger als 50 Zeichen sein").optional()});z.object({firstName:z.string().min(2,"Vorname muss mindestens 2 Zeichen lang sein").max(100,"Vorname darf nicht länger als 100 Zeichen sein").regex(/^[a-zA-ZäöüÄÖÜß\s-]+$/,"Vorname darf nur Buchstaben enthalten").optional(),lastName:z.string().min(2,"Nachname muss mindestens 2 Zeichen lang sein").max(100,"Nachname darf nicht länger als 100 Zeichen sein").regex(/^[a-zA-ZäöüÄÖÜß\s-]+$/,"Nachname darf nur Buchstaben enthalten").optional(),companyName:z.string().max(200,"Firmenname darf nicht länger als 200 Zeichen sein").optional(),phone:z.string().optional().refine(t=>t?/^[\+]?[1-9][\d]{0,15}$/.test(t.replace(/[\s\-\(\)]/g,"")):!0,"Bitte geben Sie eine gültige Telefonnummer ein"),taxNumber:z.string().max(50,"Steuernummer darf nicht länger als 50 Zeichen sein").optional()});z.object({firstName:z.string().min(2,"Vorname muss mindestens 2 Zeichen lang sein").max(100,"Vorname darf nicht länger als 100 Zeichen sein"),lastName:z.string().min(2,"Nachname muss mindestens 2 Zeichen lang sein").max(100,"Nachname darf nicht länger als 100 Zeichen sein"),company:z.string().max(200,"Firmenname darf nicht länger als 200 Zeichen sein").optional(),street:z.string().min(5,"Straße muss mindestens 5 Zeichen lang sein").max(200,"Straße darf nicht länger als 200 Zeichen sein"),postalCode:z.string().regex(/^\d{5}$/,"PLZ muss aus 5 Ziffern bestehen"),city:z.string().min(2,"Stadt muss mindestens 2 Zeichen lang sein").max(100,"Stadt darf nicht länger als 100 Zeichen sein"),country:z.string().length(2,"Ländercode muss 2 Zeichen lang sein").default("DE"),type:z.enum(["billing","shipping"],{errorMap:()=>({message:'Adresstyp muss "billing" oder "shipping" sein'})})});z.object({query:z.string().min(2,"Suchbegriff muss mindestens 2 Zeichen lang sein").max(100,"Suchbegriff darf nicht länger als 100 Zeichen sein").regex(/^[a-zA-Z0-9äöüÄÖÜß\s\-\.]+$/,"Suchbegriff enthält ungültige Zeichen"),category:z.string().uuid().optional(),brand:z.string().uuid().optional(),minPrice:z.number().min(0).optional(),maxPrice:z.number().min(0).optional(),limit:z.number().min(1).max(100).default(20),offset:z.number().min(0).default(0)});z.object({quantity:z.number().int("Menge muss eine ganze Zahl sein").min(1,"Menge muss mindestens 1 sein").max(1e4,"Menge darf nicht größer als 10.000 sein"),productId:z.string().uuid("Ungültige Produkt-ID")});const Bn=z.object({salutation:z.enum(["Herr","Frau","Divers"],{errorMap:()=>({message:"Bitte wählen Sie eine Anrede"})}),firstName:z.string().min(2,"Vorname muss mindestens 2 Zeichen lang sein").max(100,"Vorname darf nicht länger als 100 Zeichen sein").trim(),lastName:z.string().min(2,"Nachname muss mindestens 2 Zeichen lang sein").max(100,"Nachname darf nicht länger als 100 Zeichen sein").trim(),email:z.string().email("Bitte geben Sie eine gültige E-Mail-Adresse ein").max(255,"E-Mail-Adresse ist zu lang").trim().toLowerCase(),phone:z.string().min(6,"Bitte geben Sie eine gültige Rufnummer ein").max(30,"Rufnummer ist zu lang").trim(),message:z.string().max(2e3,"Nachricht darf nicht länger als 2000 Zeichen sein").optional(),privacyAccepted:z.literal(!0,{errorMap:()=>({message:"Bitte akzeptieren Sie die Datenschutzbestimmungen"})}),honeypot:z.string().optional()}),Pn=({open:t,onOpenChange:n,productName:i,productSku:r,productUrl:a})=>{const[o,c]=p.useState(!1),[h,m]=p.useState(0),l=sn({resolver:nn(Bn),defaultValues:{salutation:void 0,firstName:"",lastName:"",email:"",ph
31one:"",message:"",privacyAccepted:void 0,honeypot:""}});p.useEffect(()=>{t&&(m(Date.now()),l.reset())},[t,l]),p.useEffect(()=>{const d=l.formState.errors,g=Object.keys(d);g.length>0&&l.formState.submitCount>0&&ys(g)},[l.formState.errors,l.formState.submitCount]);const u=async d=>{if(d.honeypot){console.warn("Honeypot triggered");return}if(Date.now()-h<3e3){be.error("Bitte nehmen Sie sich einen Moment Zeit, das Formular auszufüllen.");return}c(!0);try{const{data:_,error:s}=await te.functions.invoke("send-product-inquiry",{body:{salutation:d.salutation,firstName:d.firstName,lastName:d.lastName,email:d.email,phone:d.phone,message:d.message||"",productName:i,productSku:r,productUrl:a}});if(s)throw s;if(_!=null&&_.success)be.success("Anfrage gesendet! Wir melden uns schnellstmöglich. Bestätigung folgt per E-Mail."),n(!1);else throw new Error((_==null?void 0:_.error)||"Fehler beim Senden der Anfrage")}catch(_){console.error("Error sending product inquiry:",_),be.error("Die Anfrage konnte nicht gesendet werden. Bitte erneut versuchen.")}finally{c(!1)}};return e.jsx(Qt,{open:t,onOpenChange:n,children:e.jsxs(Gt,{className:"max-w-md max-h-[85vh] overflow-y-auto",children:[e.jsxs(Yt,{children:[e.jsx(Wt,{children:"Frage zum Artikel"}),e.jsxs(js,{children:["Sie haben Fragen zu ",e.jsx("strong",{children:i})," (SKU: ",r,")? Füllen Sie das Formular aus und wir melden uns schnellstmöglich bei Ihnen."]})]}),e.jsx(an,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(u),className:"space-y-4",children:[e.jsx(Se,{control:l.control,name:"honeypot",render:({field:d})=>e.jsx(ke,{className:"hidden",children:e.jsx(Ee,{children:e.jsx(ze,{...d,tabIndex:-1,autoComplete:"off"})})})}),e.jsx(Se,{control:l.control,name:"salutation",render:({field:d})=>e.jsxs(ke,{children:[e.jsx(Ae,{children:"Anrede *"}),e.jsxs(Ze,{onValueChange:d.onChange,value:d.value,children:[e.jsx(Ee,{children:e.jsx(Ke,{children:e.jsx(Qe,{placeholder:"Bitte wählen"})})}),e.jsxs(Ge,{children:[e.jsx(pe,{value:"Herr",children:"Herr"}),e.jsx(pe,{value:"Frau",children:"Frau"}),e.jsx(pe,{value:"Divers",children:"Divers"})]})]}),e.jsx(Le,{})]})}),e.jsx(Se,{control:l.control,name:"firstName",render:({field:d})=>e.jsxs(ke,{children:[e.jsx(Ae,{children:"Vorname *"}),e.jsx(Ee,{children:e.jsx(ze,{placeholder:"Max",...d})}),e.jsx(Le,{})]})}),e.jsx(Se,{control:l.control,name:"lastName",render:({field:d})=>e.jsxs(ke,{children:[e.jsx(Ae,{children:"Nachname *"}),e.jsx(Ee,{children:e.jsx(ze,{placeholder:"Mustermann",...d})}),e.jsx(Le,{})]})}),e.jsx(Se,{control:l.control,name:"email",render:({field:d})=>e.jsxs(ke,{children:[e.jsx(Ae,{children:"E-Mail *"}),e.jsx(Ee,{children:e.jsx(rn,{placeholder:"[email protected]",name:d.name,value:d.value??"",onChange:g=>d.onChange(g),onBlur:d.onBlur,ref:d.ref})}),e.jsx(Le,{})]})}),e.jsx(Se,{control:l.control,name:"phone",render:({field:d})=>e.jsxs(ke,{children:[e.jsx(Ae,{children:"Rufnummer *"}),e.jsx(Ee,{children:e.jsx(ze,{type:"tel",placeholder:"+49 40 123456",...d})}),e.jsx(Le,{})]})}),e.jsx(Se,{control:l.control,name:"message",render:({field:d})=>e.jsxs(ke,{children:[e.jsx(Ae,{children:"Ihre Nachricht (optional)"}),e.jsx(Ee,{children:e.jsx(is,{placeholder:"Beschreiben Sie Ihre Frage oder Ihr Anliegen...",rows:4,...d})}),e.jsx(Le,{})]})}),e.jsx(Se,{control:l.control,name:"privacyAccepted",render:({field:d})=>e.jsxs(ke,{className:"flex flex-row items-start space-x-3 space-y-0",children:[e.jsx(Ee,{children:e.jsx(ws,{checked:d.value,onCheckedChange:d.onChange})}),e.jsxs("div",{className:"space-y-1 leading-none",children:[e.jsxs(Ae,{children:["Ich habe die"," ",e.jsx("a",{href:"/datenschutz",target:"_blank",rel:"noopener noreferrer",className:"text-brand-red hover:underline",children:"Datenschutzbestimmungen"})," ","gelesen und akzeptiert. *"]}),e.jsx(Le,{})]})]})}),e.jsx(ce,{type:"submit",className:"w-full",disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(gt,{className:"mr-2 h-4 w-4 animate-spin"}),"Wird gesendet..."]}):"Anfrage senden"})]})})]})})};function On({imageUrl:t,label:n}){const[i,r]=p.useState(!1),[a,o]=p.useState(!1);return t?i?e.jsxs("div",{className:"flex flex-col items-center gap-1.5 p-2 min-w-[70px] flex-1 max-w-[100px]",children:[e.jsx("div",{className:"w-12 h-12 flex items-center justify-center bg-gray-100 rounded flex-shrink-0",children:e.jsx(Et,{className:"w-6 h-6 text-gray-400"})}),e.jsx("span",{className:"text-xs text-gray-600 text-center leading-tight line-clamp-2",children:n})]}):e.jsxs(Qt,{children:[e.jsx(_s,{asChild:!0,children:e.jsxs("button",{type:"button",className:"flex flex-col items-center gap-1.5 p-2 min-w-[70px] flex-1 max-w-[100px] rounded-md hover:bg-gray-50 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring cursor-pointer","aria-label":`${n} vergrößern`,title:`${n}
31 vergrößern`,children:[e.jsx("img",{src:Fe(t,{width:160,quality:75,format:"webp",resize:"contain"}),alt:n,className:"w-12 h-12 object-contain flex-shrink-0",loading:"lazy",onError:()=>r(!0),onLoad:()=>o(!0)}),e.jsx("span",{className:"text-xs text-gray-600 text-center leading-tight line-clamp-2",children:n})]})}),e.jsxs(Gt,{className:"max-w-[360px] sm:max-w-[420px]",children:[e.jsx(Yt,{children:e.jsx(Wt,{className:"text-base",children:n})}),e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx("img",{src:Fe(t,{width:400,quality:80,format:"webp",resize:"contain"}),alt:n,className:"max-w-[300px] max-h-[300px] w-auto h-auto object-contain",style:{imageRendering:"auto"}})})]})]}):e.jsxs("div",{className:"flex flex-col items-center gap-1.5 p-2 min-w-[70px] flex-1 max-w-[100px]",children:[e.jsx("div",{className:"w-12 h-12 flex items-center justify-center bg-gray-100 rounded flex-shrink-0",children:e.jsx(Et,{className:"w-6 h-6 text-gray-400"})}),e.jsx("span",{className:"text-xs text-gray-600 text-center leading-tight line-clamp-2",children:n})]})}const wt=t=>{const n=t.sheets_per_pack||0,i=t.packs_per_carton||0;return{sheetsPerPack:n,packsPerCarton:i,totalSheetsPerCarton:n*i,isValid:n>0&&i>0}};function $n(){return P.createElement("svg",{"aria-hidden":"true","data-rmiz-btn-unzoom-icon":!0,fill:"currentColor",focusable:"false",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},P.createElement("path",{d:"M 14.144531 1.148438 L 9 6.292969 L 9 3 L 8 3 L 8 8 L 13 8 L 13 7 L 9.707031 7 L 14.855469 1.851563 Z M 8 8 L 3 8 L 3 9 L 6.292969 9 L 1.148438 14.144531 L 1.851563 14.855469 L 7 9.707031 L 7 13 L 8 13 Z"}))}function Rn(){return P.createElement("svg",{"aria-hidden":"true","data-rmiz-btn-zoom-icon":!0,fill:"currentColor",focusable:"false",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg"},P.createElement("path",{d:"M 9 1 L 9 2 L 12.292969 2 L 2 12.292969 L 2 9 L 1 9 L 1 14 L 6 14 L 6 13 L 2.707031 13 L 13 2.707031 L 13 6 L 14 6 L 14 1 Z"}))}const We=(t,n)=>{var i,r;return t===((r=(i=n==null?void 0:n.tagName)==null?void 0:i.toUpperCase)==null?void 0:r.call(i))},_t=t=>We("DIV",t)||We("SPAN",t),Xe=t=>We("IMG",t),$t=t=>t.complete&&t.naturalHeight!==0,Ue=t=>We("SVG",t),cs=({height:t,offset:n,width:i})=>Math.min((window.innerWidth-n*2)/i,(window.innerHeight-n*2)/t),Vn=({containerHeight:t,containerWidth:n,offset:i,targetHeight:r,targetWidth:a})=>{const o=cs({height:r,offset:i,width:a}),c=a>r?a/n:r/t;return o>1?c:o*c},qe=({containerHeight:t,containerWidth:n,hasScalableSrc:i,offset:r,targetHeight:a,targetWidth:o})=>!t||!n?1:!i&&a&&o?Vn({containerHeight:t,containerWidth:n,offset:r,targetHeight:a,targetWidth:o}):cs({height:t,offset:r,width:n}),Un=/url(?:\(['"]?)(.*?)(?:['"]?\))/,Rt=t=>{var n;if(t){if(Xe(t))return t.currentSrc;if(_t(t)){const i=window.getComputedStyle(t).backgroundImage;if(i)return(n=Un.exec(i))==null?void 0:n[1]}}},Zn=t=>{if(t)return Xe(t)?t.alt??void 0:t.getAttribute("aria-label")??void 0},Kn=({containerHeight:t,containerLeft:n,containerTop:i,containerWidth:r,hasScalableSrc:a,offset:o,targetHeight:c,targetWidth:h})=>{const m=qe({containerHeight:t,containerWidth:r,hasScalableSrc:a,offset:o,targetHeight:c,targetWidth:h});return{top:i,left:n,width:r*m,height:t*m,transform:`translate(0,0) scale(${1/m})`}},ge=({position:t,relativeNum:n})=>{const i=parseFloat(t);return t.endsWith("%")?n*i/100:i},Qn=({containerHeight:t,containerLeft:n,containerTop:i,containerWidth:r,hasScalableSrc:a,objectFit:o,objectPosition:c,offset:h,targetHeight:m,targetWidth:l})=>{if(o==="scale-down"&&(l<=r&&m<=t?o="none":o="contain"),o==="cover"||o==="contain"){const u=r/l,d=t/m,g=o==="cover"?Math.max(u,d):Math.min(u,d),[_="50%",s="50%"]=c.split(" "),E=ge({position:_,relativeNum:r-l*g}),N=ge({position:s,relativeNum:t-m*g}),j=qe({containerHeight:m*g,containerWidth:l*g,hasScalableSrc:a,offset:h,targetHeight:m,targetWidth:l});return{top:i+N,left:n+E,width:l*g*j,height:m*g*j,transform:`translate(0,0) scale(${1/j})`}}else if(o==="none"){const[u="50%",d="50%"]=c.split(" "),g=ge({position:u,relativeNum:r-l}),_=ge({position:d,relativeNum:t-m}),s=qe({containerHeight:m,containerWidth:l,hasScalableSrc:a,offset:h,targetHeight:m,targetWidth:l});return{top:i+_,left:n+g,width:l*s,height:m*s,transform:`translate(0,0) scale(${1/s})`}}else if(o==="fill"){const u=r/l,d=t/m,g=Math.max(u,d),_=qe({containerHeight:m*g,containerWidth:l*g,hasScalableSrc:a,offset:h,targetHeight:m,targetWidth:l});return{width:r*_,height:t*_,transform:`translate(0,0) scale(${1/_})`}}else return{}},Gn=({backgroundPosition:t,backgroundSize:n,containerHeight:i,containerLeft:r,containerTop:a,containerWidth:o,hasScalableSrc:c,offset:h,targetHeight:m,targetWidth:l})=>
31{if(n==="cover"||n==="contain"){const u=o/l,d=i/m,g=n==="cover"?Math.max(u,d):Math.min(u,d),[_="50%",s="50%"]=t.split(" "),E=ge({position:_,relativeNum:o-l*g}),N=ge({position:s,relativeNum:i-m*g}),j=qe({containerHeight:m*g,containerWidth:l*g,hasScalableSrc:c,offset:h,targetHeight:m,targetWidth:l});return{top:a+N,left:r+E,width:l*g*j,height:m*g*j,transform:`translate(0,0) scale(${1/j})`}}else if(n==="auto"){const[u="50%",d="50%"]=t.split(" "),g=ge({position:u,relativeNum:o-l}),_=ge({position:d,relativeNum:i-m}),s=qe({containerHeight:m,containerWidth:l,hasScalableSrc:c,offset:h,targetHeight:m,targetWidth:l});return{top:a+_,left:r+g,width:l*s,height:m*s,transform:`translate(0,0) scale(${1/s})`}}else{const[u="50%",d="50%"]=n.split(" "),g=ge({position:u,relativeNum:o}),_=ge({position:d,relativeNum:i}),s=g/l,E=_/m,N=Math.min(s,E),[j="50%",q="50%"]=t.split(" "),k=ge({position:j,relativeNum:o-l*N}),L=ge({position:q,relativeNum:i-m*N}),w=qe({containerHeight:m*N,containerWidth:l*N,hasScalableSrc:c,offset:h,targetHeight:m,targetWidth:l});return{top:a+L,left:r+k,width:l*N*w,height:m*N*w,transform:`translate(0,0) scale(${1/w})`}}},Yn=/\.svg$/i,Wn=({hasZoomImg:t,imgSrc:n,isSvg:i,isZoomed:r,loadedImgEl:a,offset:o,shouldRefresh:c,targetEl:h})=>{var j;const m=i||((j=n==null?void 0:n.slice)==null?void 0:j.call(n,0,18))==="data:image/svg+xml"||t||!!(n&&Yn.test(n)),l=h.getBoundingClientRect(),u=window.getComputedStyle(h),d=a!=null&&_t(h),g=a!=null&&!d,_=Kn({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:m,offset:o,targetHeight:(a==null?void 0:a.naturalHeight)||l.height,targetWidth:(a==null?void 0:a.naturalWidth)||l.width}),s=g?Qn({containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:m,objectFit:u.objectFit,objectPosition:u.objectPosition,offset:o,targetHeight:(a==null?void 0:a.naturalHeight)||l.height,targetWidth:(a==null?void 0:a.naturalWidth)||l.width}):void 0,E=d?Gn({backgroundPosition:u.backgroundPosition,backgroundSize:u.backgroundSize,containerHeight:l.height,containerLeft:l.left,containerTop:l.top,containerWidth:l.width,hasScalableSrc:m,offset:o,targetHeight:(a==null?void 0:a.naturalHeight)||l.height,targetWidth:(a==null?void 0:a.naturalWidth)||l.width}):void 0,N=Object.assign({},_,s,E);if(r){const q=window.innerWidth/2,k=window.innerHeight/2,L=parseFloat(String(N.left||0))+parseFloat(String(N.width||0))/2,w=parseFloat(String(N.top||0))+parseFloat(String(N.height||0))/2,C=q-L,A=k-w;c&&(N.transitionDuration="0.01ms"),N.transform=`translate(${C}px,${A}px) scale(1)`}return N},mt=t=>{if(!t)return{};if(Ue(t)){const n=t.parentElement,i=t.getBoundingClientRect();if(n){const r=n.getBoundingClientRect();return{height:i.height,left:r.left-i.left,top:r.top-i.top,width:i.width}}else return{height:i.height,left:i.left,width:i.width,top:i.top}}else return{height:t.offsetHeight,left:t.offsetLeft,width:t.offsetWidth,top:t.offsetTop}},Xn=t=>{const n="-zoom",i=["clip-path","fill","mask","marker-start","marker-mid","marker-end"],r=new Map;if(t.hasAttribute("id")){const a=t.id,o=a+n;r.set(a,o),t.id=o}t.querySelectorAll("[id]").forEach(a=>{const o=a.id,c=o+n;r.set(o,c),a.id=c}),r.forEach((a,o)=>{const c=`url(#${o})`,h=`url(#${a})`,m=i.map(l=>`[${l}="${c}"]`).join(", ");t.querySelectorAll(m).forEach(l=>{i.forEach(u=>{l.getAttribute(u)===c&&l.setAttribute(u,h)})})}),t.querySelectorAll("style").forEach(a=>{r.forEach((o,c)=>{a.textContent&&(a.textContent=a.textContent.replaceAll(`#${c}`,`#${o}`))})})},Hn=["img","svg",'[role="img"]',"[data-zoom]"].map(t=>`${t}:not([aria-hidden="true"])`).join(","),Vt={overflow:"",width:""};function Jn(t){return P.createElement(ds,{...t})}class ds extends P.Component{constructor(){super(...arguments),this.state={id:"",isZoomImgLoaded:!1,loadedImgEl:void 0,modalState:"UNLOADED",shouldRefresh:!1,styleGhost:{}},this.refContent=P.createRef(),this.refDialog=P.createRef(),this.refModalContent=P.createRef(),this.refModalImg=P.createRef(),this.refWrap=P.createRef(),this.imgEl=null,this.isScaling=!1,this.prevBodyAttrs=Vt,this.styleModalImg={},this.handleModalStateChange=n=>{var r,a,o,c;const{modalState:i}=this.state;n!=="LOADING"&&i==="LOADING"?(this.loadZoomImg(),window.addEventListener("resize",this.handleResize,{passive:!0}),window.addEventListener("touchstart",this.handleTouchStart,{passive:!0}),window.addEventListener("touchmove",this.handleTouchMove,{passive:!0}),window.addEventListener("touchend",this.handleTouchEnd,{passive:!0}),window.addEventListener("touchcancel",this.handleTouchCancel,{passive:!0}),document.addEventListener("keydown",this.handleKeyDown,!0)):n!=="LOADED"&&i==="LOADED"?window.addEventListener("wheel",this.handleWheel,{passive:!0}):n!=="UNLOADING"&&i==="UNLOADING"?(this.ensureImgTransitionEnd(),window.removeEventListener("wheel",this.handleWheel),window.removeEventListener("touchstart",this.handleTouchStart),window.removeEventListener("touchmove",this.handleTouchMove),window.removeEventListener("touchend",this.handleTouchEnd),window.removeEventListener("touchcancel",this.handleTouchCancel),document.removeEventListener("keydown",this.handleKeyDown,!0)):n!=="UNLOADED"&&i==="UNLOADED"&&(this.bodyScrollEnable(),window.removeEventListener("resize",this.handleResize),(a=(r=this.refModalImg.current)==null?void 0:r.removeEventListener)==null||a.call(r,"transitionend",this.handleImgTransitionEnd),(c=(o=this.refDialog.current)==null?void 0:o.close)==null||c.call(o))},this.getDialogContainer=()=>{let n=document.querySelector("[data-rmiz-portal]");return n==null&&(n=document.createElement("div"),n.setAttribute("data-rmiz-portal",""),document.body.appendChild(n)),n},this.setId=()=>{const n=()=>Math.random().toString(16).slice(-4);this.setState({id:n()+n()+n()})},this.setAndTrackImg=()=>{var i,r;const n=this.refContent.current;
31n&&(this.imgEl=n.querySelector(Hn),this.imgEl?((r=(i=this.contentNotFoundChangeObserver)==null?void 0:i.disconnect)==null||r.call(i),this.imgEl.addEventListener("load",this.handleImgLoad),this.imgEl.addEventListener("click",this.handleZoom),this.state.loadedImgEl||this.handleImgLoad(),this.imgElResizeObserver=new ResizeObserver(a=>{const o=a[0];o!=null&&o.target&&(this.imgEl=o.target,this.setState({styleGhost:mt(this.imgEl)}))}),this.imgElResizeObserver.observe(this.imgEl),this.contentChangeObserver||(this.contentChangeObserver=new MutationObserver(()=>{this.setState({styleGhost:mt(this.imgEl)})}),this.contentChangeObserver.observe(n,{attributes:!0,childList:!0,subtree:!0}))):this.contentNotFoundChangeObserver||(this.contentNotFoundChangeObserver=new MutationObserver(this.setAndTrackImg),this.contentNotFoundChangeObserver.observe(n,{childList:!0,subtree:!0})))},this.handleIfZoomChanged=n=>{const{isZoomed:i}=this.props;!n&&i?this.zoom():n&&!i&&this.unzoom()},this.handleImgLoad=()=>{const n=Rt(this.imgEl);if(!n)return;const i=new Image;Xe(this.imgEl)&&(i.sizes=this.imgEl.sizes,i.srcset=this.imgEl.srcset,i.crossOrigin=this.imgEl.crossOrigin),i.src=n;const r=()=>{this.setState({loadedImgEl:i,styleGhost:mt(this.imgEl)})};i.decode().then(r).catch(()=>{if($t(i)){r();return}i.onload=r})},this.handleZoom=n=>{var i,r;!this.props.isDisabled&&this.hasImage()&&((r=(i=this.props).onZoomChange)==null||r.call(i,!0,{event:n}))},this.handleUnzoom=n=>{var i,r;this.props.isDisabled||(r=(i=this.props).onZoomChange)==null||r.call(i,!1,{event:n})},this.handleBtnUnzoomClick=n=>{n.preventDefault(),n.stopPropagation(),this.handleUnzoom(n)},this.handleDialogCancel=n=>{n.preventDefault()},this.handleDialogClick=n=>{(n.target===this.refModalContent.current||n.target===this.refModalImg.current)&&(n.stopPropagation(),this.handleUnzoom(n))},this.handleDialogClose=n=>{n.stopPropagation(),this.handleUnzoom(n)},this.handleKeyDown=n=>{(n.key==="Escape"||n.keyCode===27)&&(n.preventDefault(),n.stopPropagation(),this.handleUnzoom(n))},this.handleWheel=n=>{n.ctrlKey||(n.stopPropagation(),queueMicrotask(()=>{this.handleUnzoom(n)}))},this.handleTouchStart=n=>{if(n.touches.length>1){this.isScaling=!0;return}n.changedTouches.length===1&&n.changedTouches[0]&&(this.touchYStart=n.changedTouches[0].screenY)},this.handleTouchMove=n=>{var r;const i=((r=window.visualViewport)==null?void 0:r.scale)??1;if(this.props.canSwipeToUnzoom&&!this.isScaling&&i<=1&&this.touchYStart!=null&&n.changedTouches[0]){this.touchYEnd=n.changedTouches[0].screenY;const a=Math.max(this.touchYStart,this.touchYEnd),o=Math.min(this.touchYStart,this.touchYEnd);Math.abs(a-o)>this.props.swipeToUnzoomThreshold&&(this.touchYStart=void 0,this.touchYEnd=void 0,this.handleUnzoom(n))}},this.handleTouchEnd=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleTouchCancel=()=>{this.isScaling=!1,this.touchYStart=void 0,this.touchYEnd=void 0},this.handleResize=()=>{this.setState({shouldRefresh:!0})},this.hasImage=()=>this.imgEl&&(this.state.loadedImgEl||Ue(this.imgEl))&&window.getComputedStyle(this.imgEl).display!=="none",this.zoom=()=>{var n,i,r,a;this.bodyScrollDisable(),(i=(n=this.refDialog.current)==null?void 0:n.showModal)==null||i.call(n),(a=(r=this.refModalImg.current)==null?void 0:r.addEventListener)==null||a.call(r,"transitionend",this.handleImgTransitionEnd),this.setState({modalState:"LOADING"})},this.unzoom=()=>{this.setState({modalState:"UNLOADING"})},this.handleImgTransitionEnd=()=>{clearTimeout(this.timeoutTransitionEnd),this.state.modalState==="LOADING"?this.setState({modalState:"LOADED"}):this.state.modalState==="UNLOADING"&&this.setState({shouldRefresh:!1,modalState:"UNLOADED"})},this.ensureImgTransitionEnd=()=>
31{if(this.refModalImg.current){const n=window.getComputedStyle(this.refModalImg.current).transitionDuration,i=parseFloat(n);if(i){const r=i*(n.endsWith("ms")?1:1e3)+50;this.timeoutTransitionEnd=setTimeout(this.handleImgTransitionEnd,r)}}},this.bodyScrollDisable=()=>{this.prevBodyAttrs={overflow:document.body.style.overflow,width:document.body.style.width};const n=document.body.clientWidth;document.body.style.overflow="hidden",document.body.style.width=`${n}px`},this.bodyScrollEnable=()=>{document.body.style.width=this.prevBodyAttrs.width,document.body.style.overflow=this.prevBodyAttrs.overflow,this.prevBodyAttrs=Vt},this.loadZoomImg=()=>{const{props:{zoomImg:n}}=this,i=n==null?void 0:n.src;if(i){const r=new Image;r.sizes=(n==null?void 0:n.sizes)??"",r.srcset=(n==null?void 0:n.srcSet)??"",r.crossOrigin=(n==null?void 0:n.crossOrigin)??void 0,r.src=i;const a=()=>{this.setState({isZoomImgLoaded:!0})};r.decode().then(a).catch(()=>{if($t(r)){a();return}r.onload=a})}},this.UNSAFE_handleSvg=()=>{var a,o,c,h,m;const{imgEl:n,refModalImg:i,styleModalImg:r}=this;if(Ue(n)){const l=n.cloneNode(!0);Xn(l),l.style.width=`${r.width||0}px`,l.style.height=`${r.height||0}px`,l.addEventListener("click",this.handleUnzoom),(c=(o=(a=i.current)==null?void 0:a.firstChild)==null?void 0:o.remove)==null||c.call(o),(m=(h=i.current)==null?void 0:h.appendChild)==null||m.call(h,l)}}}render(){const{handleBtnUnzoomClick:n,handleDialogCancel:i,handleDialogClick:r,handleDialogClose:a,handleUnzoom:o,handleZoom:c,imgEl:h,props:{a11yNameButtonUnzoom:m,a11yNameButtonZoom:l,children:u,classDialog:d,IconUnzoom:g,IconZoom:_,isZoomed:s,wrapElement:E,ZoomContent:N,zoomImg:j,zoomMargin:q},refContent:k,refDialog:L,refModalContent:w,refModalImg:C,refWrap:A,state:{id:b,isZoomImgLoaded:f,loadedImgEl:D,modalState:M,shouldRefresh:K,styleGhost:se}}=this,ae=`rmiz-modal-${b}`,T=`rmiz-modal-img-${b}`,O=_t(h),Z=Xe(h),J=Ue(h),ne=Zn(h),v=Rt(h),S=Z?h.sizes:void 0,V=Z?h.srcset:void 0,y=Z?h.crossOrigin:void 0,U=!!(j!=null&&j.src),F=this.hasImage(),B=ne?`${l}: ${ne}`:l,Y=M==="LOADING"||M==="LOADED",I=F?"found":"not-found",W=M==="UNLOADED"||M==="UNLOADING"?"hidden":"visible",ue={visibility:M==="UNLOADED"?"visible":"hidden"};this.styleModalImg=F?Wn({hasZoomImg:U,imgSrc:v,isSvg:J,isZoomed:s&&Y,loadedImgEl:D,offset:q,shouldRefresh:K,targetEl:h}):{};let he=null;if(F){const Q=Z||O?P.createElement("img",{alt:ne,crossOrigin:y,sizes:S,src:v,srcSet:V,...f&&M==="LOADED"?j:{},"data-rmiz-modal-img":"",height:this.styleModalImg.height||void 0,id:T,ref:C,style:this.styleModalImg,width:this.styleModalImg.width||void 0}):J?P.createElement("div",{"data-rmiz-modal-img":!0,ref:C,style:this.styleModalImg}):null,ee=P.createElement("button",{"aria-label":m,"data-rmiz-btn-unzoom":"",onClick:n,type:"button"},P.createElement(g,null));he=N?P.createElement(N,{buttonUnzoom:ee,modalState:M,img:Q,isZoomImgLoaded:f,onUnzoom:o}):P.createElement(P.Fragment,null,Q,ee)}return P.createElement(E,{"aria-owns":ae,"data-rmiz":"",ref:A},P.createElement(E,{"data-rmiz-content":I,ref:k,style:ue},u),F&&P.createElement(E,{"data-rmiz-ghost":"",style:se},P.createElement("button",{"aria-label":B,"data-rmiz-btn-zoom":"",onClick:c,type:"button"},P.createElement(_,null))),F&&ms.createPortal(P.createElement("dialog",{"aria-labelledby":T,"aria-modal":"true",className:d,"data-rmiz-modal":"",id:ae,onClick:r,onClose:a,onCancel:i,ref:L,role:"dialog"},P.createElement("div",{"data-rmiz-modal-overlay":W}),P.createElement("div",{"data-rmiz-modal-content":"",ref:w},he)),this.getDialogContainer()))}componentDidMount(){this.setId(),this.setAndTrackImg(),this.handleImgLoad(),this.UNSAFE_handleSvg()}componentWillUnmount(){var n,i,r,a,o,c,h,m,l,u,d,g;this.state.modalState!=="UNLOADED"&&this.bodyScrollEnable(),(i=(n=this.contentChangeObserver)==null?void 0:n.disconnect)==null||i.call(n),(a=(r=this.contentNotFoundChangeObserver)==null?void 0:r.disconnect)==null||a.call(r),(c=(o=this.imgElResizeObserver)==null?void 0:o.disconnect)==null||c.call(o),(m=(h=this.imgEl)==null?void 0:h.removeEventListener)==null||m.call(h,"load",this.handleImgLoad),(u=(l=this.imgEl)==null?void 0:l.removeEventListener)==null||u.call(l,"click",this.handleZoom),(g=(d=this.refModalImg.current)==null?void 0:d.removeEventListener)==null||g.call(d,"transitionend",this.handleImgTransitionEnd),window.removeEventListener("wheel",this.handleWheel),window.removeEventListener("touchstart",this.handleTouchStart),window.removeEventListener("touchmove",this.handleTouchMove),window.removeEventListener("touchend",this.handleTouchEnd),window.removeEventListener("touchcancel",this.handleTouchCancel),window.removeEventListener("resize",this.handleResize),document.removeEventListener("keydown",this.handleKeyDown,!0)}componentDidUpdate(n,i){this.handleModalStateChange(i.modalState),this.UNSAFE_handleSvg(),this.handleIfZoomChanged(n.isZoomed)}}ds.defaultProps={a11yNameButtonUnzoom:"Minimize image",a11yNameButtonZoom:"Expand image",canSwipeToUnzoom:!0,IconUnzoom:$n,IconZoom:Rn,isDisabled:!1,swipeToUnzoomThreshold:10,wrapElement:"div",zoomMargin:0};function ei({onZoomChange:t,...n}){const[i,r]=P.useState(!1),a=P.useCallback((o,{event:c})=>{r(o),t==null||t(o,{event:c})},[t]);return P.createElement(Jn,{...n,isZoomed:i,onZoomChange:a})}const Ve={avg_rating:0,review_count:0,internal_count:0,external_count:0,rating_distribution:{1:0,2:0,3:0,4:0,5:0}};function He(t){return me({queryKey:["product-review-stats",t],enabled:!!t,staleTime:5*60*1e3,queryFn:async()=>
31{if(!t)return Ve;const{data:n,error:i}=await te.from("product_review_stats").select("avg_rating, review_count, internal_count, external_count, rating_distribution").eq("product_id",t).maybeSingle();return i?(console.error("review stats fetch",i),Ve):n?{avg_rating:Number(n.avg_rating??0),review_count:n.review_count??0,internal_count:n.internal_count??0,external_count:n.external_count??0,rating_distribution:n.rating_distribution??Ve.rating_distribution}:Ve}})}const ti=({productId:t,deviceRatings:n,preloadedAttributes:i})=>{const[r,a]=p.useState(!1),o=n&&n.length>0;return e.jsxs("div",{className:"lg:col-span-9 grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsx(os,{productId:t,open:r,onOpenChange:a,preloadedAttributes:i}),o&&e.jsx("div",{"data-nosnippet":!0,children:e.jsxs(es,{open:r,onOpenChange:a,children:[e.jsx(ts,{asChild:!0,children:e.jsx(je,{className:"cursor-pointer hover:shadow-md transition-shadow",children:e.jsx(we,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-primary/10 rounded-full flex items-center justify-center",children:e.jsx(Ie,{className:"w-4 h-4 text-primary","aria-hidden":"true"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-foreground",children:"Geräteeignung"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Kompatibilität anzeigen"})]})]}),e.jsx(Kt,{className:"w-4 h-4 text-muted-foreground","aria-hidden":"true"})]})})})}),e.jsx(ss,{children:e.jsx(je,{className:"mt-2",children:e.jsx(we,{className:"p-4 pt-0",children:e.jsx("div",{className:"space-y-3",role:"list","aria-label":"Geräteeignung (technische Kompatibilität, keine Nutzerbewertung)",children:n.map((c,h)=>{const m=c.rating===5?"Ausgezeichnet":c.rating===4?"Sehr gut":c.rating===3?"Gut":c.rating===2?"Befriedigend":"Ausreichend";return e.jsxs("div",{role:"listitem","aria-label":`${c.name}: Eignung ${m}`,className:"flex items-center justify-between py-2 border-b border-border last:border-0",children:[e.jsx("span",{className:"text-sm font-medium text-foreground flex-1",children:c.name}),e.jsxs("div",{className:"flex items-center gap-2 min-w-[140px] justify-end",children:[e.jsx("div",{className:"flex items-center","aria-hidden":"true",children:Array.from({length:5},(l,u)=>e.jsx(Ie,{className:`w-4 h-4 ${u<c.rating?"fill-yellow-400 text-yellow-400":"text-muted-foreground/40"}`},u))}),e.jsx("span",{className:"text-xs text-muted-foreground ml-2 min-w-[80px]",children:m})]})]},h)})})})})})]})})]})},si=({product:t,attributes:n,priceTiers:i,quantity:r,setQuantity:a,selectedImageIndex:o,setSelectedImageIndex:c,deviceRatings:h,hasVariants:m,setHasVariants:l,categoryRoute:u,preloadedAttributes:d})=>{var D,M,K,se,ae;const[g,_]=p.useState(!1),{data:s}=He(t.id),{data:E=[]}=me({queryKey:["product-icons-display",t.id],queryFn:async()=>{const{data:T,error:O}=await te.from("product_icon_assignments").select(`
32          id,
33          sort_order,
34          product_icons (
35            id,
36            slug,
37            display_name,
38            image_url
39          )
40        `).eq("product_id",t.id).order("sort_order",{ascending:!0});if(O)throw O;return T||[]},enabled:!!t.id,staleTime:5*60*1e3,gcTime:10*60*1e3}),N=t?wt(t):null,j=(t==null?void 0:t.price)||0,q=((D=i==null?void 0:i.find(T=>r>=T.min_quantity))==null?void 0:D.price)||j;N!=null&&N.sheetsPerPack&&N.sheetsPerPack*r;const k=bt(t,(M=t.categories)==null?void 0:M.packaging_unit_label),L=vt(t,(K=t==null?void 0:t.categories)==null?void 0:K.quantity_unit_label),[w,C]=p.useState(0);p.useEffect(()=>{C(T=>T+1)},[q]);const A=on(t.image_alts),b=T=>{var O;return cn(A,f[T],{name:t.name,brandName:(O=t.brands)==null?void 0:O.name},T)||t.name},f=(()=>{var U;const T=[],O=new Set,Z=F=>{try{return decodeURIComponent(F)}catch{return F}},J=F=>{try{const Y=new URL(F,"https://example.com").pathname,I=Y.match(/\/storage\/v1\/object\/(?:public|sign)\/(.+)$/i);return((I==null?void 0:I[1])??Y).toLowerCase()}catch{return F.toLowerCase()}},ne=F=>{const B=F.split("/").pop()??"";return Z(B).replace(/\.[a-z0-9]+$/i,"")},v=F=>F.toLowerCase().replace(/ä/g,"ae").replace(/ö/g,"oe").replace(/ü/g,"ue").replace(/ß/g,"ss").replace(/[^a-z0-9]+/g,""),S=new Set,V=new Set;
40E.forEach(F=>{const B=F.product_icons;B&&(B.image_url&&(S.add(J(B.image_url)),V.add(v(ne(B.image_url)))),B.slug&&V.add(v(String(B.slug))),B.display_name&&V.add(v(String(B.display_name))))});const y=F=>{const B=J(F);if(S.has(B))return!0;const Y=v(ne(F));return!!(Y&&V.has(Y))};if(t!=null&&t.image_url&&!y(t.image_url)){const F=J(t.image_url);T.push(t.image_url),O.add(F)}return(U=t==null?void 0:t.gallery_images)!=null&&U.length&&t.gallery_images.forEach(F=>{if(!F)return;const B=J(F),Y=O.has(B);!y(F)&&!Y&&(T.push(F),O.add(B))}),T.length>0?T:["/placeholder.svg"]})();return p.useEffect(()=>{const T=f[o];if(!T||T==="/placeholder.svg")return;const O=Fe(T,{width:1200,quality:75,format:"webp",resize:"contain"}),Z=document.createElement("link");return Z.rel="preload",Z.as="image",Z.href=O,Z.fetchPriority="high",document.head.appendChild(Z),()=>{Z.parentNode&&Z.parentNode.removeChild(Z)}},[f,o]),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-9 gap-6",children:[e.jsxs("div",{className:"lg:col-span-9 space-y-2 -mt-[15px]",children:[t.is_featured&&e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"bg-primary text-primary-foreground px-4 py-1.5 rounded-full text-sm font-medium inline-flex items-center gap-1.5",children:[e.jsx(Ie,{className:"w-4 h-4 fill-current shrink-0"}),e.jsx("span",{children:"Bestseller"})]})}),e.jsx("h1",{"data-testid":"product-title",className:"text-3xl font-bold text-gray-900",children:t.name}),s&&s.review_count>0&&e.jsxs("a",{href:"#bewertungen",className:"inline-flex items-center gap-2 text-sm hover:underline",children:[e.jsx(jt,{value:s.avg_rating,size:16,showValue:!0}),e.jsxs("span",{className:"text-muted-foreground",children:["(",s.review_count," ",s.review_count===1?"Bewertung":"Bewertungen",")"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 text-sm p-3 bg-gray-50 rounded-lg text-gray-700",children:[t.sku&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Artikel-Nr.:"}),e.jsx("span",{className:"font-medium",children:t.sku})]}),((se=t.categories)==null?void 0:se.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Kategorie:"}),e.jsx(fe,{to:u||`/${t.categories.slug}`,className:"font-medium text-primary hover:underline",children:t.categories.name})]}),((ae=t.brands)==null?void 0:ae.name)&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Marke:"}),e.jsx(fe,{to:`/marken/${t.brands.slug}`,className:"font-medium text-primary hover:underline",children:t.brands.name})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Verfügbarkeit:"}),t.stock_quantity&&t.stock_quantity>0?e.jsxs("span",{className:"text-green-700 font-medium flex items-center gap-1",children:[e.jsx(Xt,{className:"w-4 h-4"}),"Lagernd"]}):e.jsxs("span",{className:"text-red-700 font-medium flex items-center gap-1",children:[e.jsx(Ht,{className:"w-4 h-4"}),"Nicht verfügbar"]})]})]})]}),e.jsxs("div",{className:"lg:col-span-4 space-y-2",children:[e.jsx("div",{className:"bg-white/50 rounded-lg overflow-hidden p-4 flex items-start justify-center h-[280px] sm:h-[400px]",children:e.jsx(ei,{zoomImg:{src:Fe(f[o],{width:1200,quality:80,format:"webp",resize:"contain"})},children:e.jsx("img",{src:Fe(f[o],{width:1200,quality:75,format:"webp",resize:"contain"}),alt:b(o),width:1200,height:1200,loading:"eager",decoding:"async",fetchpriority:"high",className:"max-w-full max-h-full object-contain cursor-zoom-in"})})}),f.length>1?e.jsx("div",{className:"flex gap-2 overflow-x-auto min-h-[80px]",role:"tablist","aria-label":"Produktbilder-Galerie",children:f.map((T,O)=>e.jsx("button",{type:"button",role:"tab","aria-label":`Bild ${O+1} von ${f.length} anzeigen`,"aria-selected":o===O,"aria-current":o===O?"true":void 0,onClick:()=>c(O),className:`flex-shrink-0 w-20 h-20 rounded border-2 overflow-hidden ${o===O?"border-primary":"border-gray-200"}
40`,children:e.jsx("img",{src:Fe(T,{width:160,quality:75,format:"webp",resize:"contain"}),alt:b(O),loading:"lazy",decoding:"async",className:"w-full h-full object-contain"})},O))}):null]}),e.jsx("div",{className:"lg:col-span-5 space-y-6",children:e.jsxs("div",{className:"space-y-4",children:[t.short_description&&e.jsx("div",{className:"prose prose-sm max-w-none text-gray-600",children:e.jsx(ft,{html:t.short_description})}),N&&N.sheetsPerPack>0&&e.jsxs("div",{className:"text-sm text-gray-600 bg-gray-50 rounded-md px-3 py-2 inline-flex items-center gap-2",children:[e.jsxs("span",{className:"font-medium text-gray-700",children:[L," pro ",k,":"]}),e.jsxs("span",{className:"font-semibold text-gray-900",children:[N.sheetsPerPack.toLocaleString("de-DE")," ",L]})]}),e.jsx("div",{className:m?"py-4":"hidden",children:e.jsx(as,{currentProduct:{id:t.id,name:t.name,slug:t.slug},onAvailabilityChange:l})}),E.length>0&&e.jsxs("div",{className:"pt-4 border-t border-gray-100",children:[e.jsx("h4",{className:"text-sm font-medium text-gray-700 mb-3",children:"Produkteigenschaften"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:E.map((T,O)=>{const Z=T.product_icons;return Z?e.jsx(On,{imageUrl:Z.image_url,label:Z.display_name},T.id):null})})]})]})}),e.jsx("div",{className:"lg:col-span-9 mb-6",children:e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsx(Mn,{product:t,className:"h-10 sm:h-12 bg-white hover:bg-primary/5 border-2 border-primary/20 hover:border-primary/40 transition-all duration-200 shadow-sm hover:shadow-md [&_svg]:hidden sm:[&_svg]:block"}),e.jsxs(ce,{variant:"outline",onClick:()=>_(!0),className:"h-10 sm:h-12 bg-white hover:bg-brand-red/5 border-2 border-brand-red/20 hover:border-brand-red text-foreground hover:text-brand-red transition-all duration-200 shadow-sm hover:shadow-md font-medium",children:[e.jsx(Ns,{className:"w-5 h-5 mr-2 hidden sm:block"}),e.jsx("span",{children:"Frage stellen"})]}),e.jsx(Tn,{product:{id:t.id,name:t.name,slug:t.slug,price:t.price,sale_price:t.sale_price,image_url:t.image_url,short_description:t.short_description},className:"h-10 sm:h-12 bg-white hover:bg-primary/5 border-2 border-primary/20 hover:border-primary/40 transition-all duration-200 shadow-sm hover:shadow-md [&_svg]:hidden sm:[&_svg]:block"})]})}),e.jsx(ti,{productId:t.id,deviceRatings:h,preloadedAttributes:d}),e.jsx(Pn,{open:g,onOpenChange:_,productName:t.name,productSku:t.sku,productUrl:`${window.location.origin}/${t.slug}`})]})},ni=({product:t,attributes:n,cleanedDescription:i})=>{var L;const r=pt();yt();const a=t?wt(t):null,o=a!=null&&a.isValid?{sheetsPerPack:a.sheetsPerPack,packsPerCarton:a.packsPerCarton}:null,c=vt(t,(L=t==null?void 0:t.categories)==null?void 0:L.quantity_unit_label),h=bt(t),m=Cs(t),l=w=>{const C=A=>/\d/.test(A);return[...w].sort((A,b)=>{const f=C(A),D=C(b);return f&&!D?-1:!f&&D?1:0})},u=w=>w.trim().toLowerCase(),d=w=>{if(!n)return[];const C=n.find(A=>{var f,D;return(((D=(f=A.product_attributes)==null?void 0:f.name)==null?void 0:D.toLowerCase())||"").includes(w)});return C!=null&&C.value?C.value.split(",").map(A=>A.trim()).filter(Boolean):[]},g=w=>{const C=new Set,A=[];for(const b of w){const f=Ln(b),D=u(f);D&&!C.has(D)&&(C.add(D),A.push(f))}return l(A)},_=g(d("umweltzertifikat")),s=g(d("herstellerzertifikat")),E=g(d("qualitätszertifikat")),N=(w,C)=>{const A=f=>f.toLowerCase().replace(/[-–—]/g," ").replace(/\s+/g," ").trim(),b=ns.find(f=>A(f.term)===A(w));if(b){const f=b.term.replace(/[^a-zA-Z0-9äöüÄÖÜß]/g,"-").toLowerCase();return e.jsxs(Ye,{variant:"secondary",className:"text-xs w-fit cursor-pointer hover:bg-primary/20 transition-colors",onClick:()=>r(`/papierratgeber/papier-abc#term-${f}`),children:[w," ↗"]},C)}return e.jsx(Ye,{variant:"secondary",className:"text-xs w-fit",children:w},C)},{data:j}=He(t==null?void 0:t.id),q=j&&j.review_count>0?j.avg_rating.toFixed(1).replace(".",","):"",k=w=>{w.preventDefault();const C=document.getElementById("bewertungen");C&&C.scrollIntoView({behavior:"smooth",block:"start"})};return e.jsx("div",{className:"mt-8 w-full",children:e.jsxs(dn,{defaultValue:"description",className:"w-full",children:[e.jsxs(mn,{className:"grid w-full",style:{gridTemplateColumns:"1fr 1fr 90px"},children:[e.jsx(ot,{value:"description",children:"Beschreibung"}),e.jsx(ot,{value:"specs",children:"Spezifikationen"}
40),e.jsxs(ot,{value:"reviews",onClick:k,"aria-label":"Bewertungen",className:"px-2",children:[e.jsx(Ie,{className:"w-4 h-4 fill-yellow-400 text-yellow-400"}),q&&e.jsx("span",{className:"ml-1 text-xs tabular-nums",children:q})]})]}),e.jsx(It,{value:"description",className:"mt-6 animate-fade-in",children:e.jsx("div",{className:"border rounded-lg p-6",children:e.jsxs("div",{className:"grid md:grid-cols-3 gap-6 items-start",children:[e.jsx("div",{className:"md:col-span-2",children:e.jsx("div",{className:"prose max-w-none product-description [&_ul]:list-disc [&_ul]:pl-6 [&_li]:mb-1",children:i?e.jsx(ft,{html:i}):t.long_description?e.jsx(ft,{html:t.long_description}):e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4",children:"Produktbeschreibung"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Hochwertiges Kopierpapier für den professionellen Büroalltag. Dieses Papier überzeugt durch seine hervorragende Qualität und Vielseitigkeit in der Anwendung."}),e.jsxs("ul",{className:"list-disc list-inside space-y-2 text-muted-foreground",children:[e.jsx("li",{children:"Optimale Laufeigenschaften in allen Geräten"}),e.jsx("li",{children:"Hohe Weiße für brillante Druckergebnisse"}),e.jsx("li",{children:"Umweltfreundlich und nachhaltig produziert"}),e.jsx("li",{children:"Perfekte Papierqualität für den täglichen Einsatz"})]})]})})}),(t==null?void 0:t.image_url)&&e.jsx("div",{className:"md:col-span-1",children:e.jsx("img",{src:Fe(t.image_url,{width:1200,quality:75,format:"webp",resize:"contain"}),alt:t.name,loading:"lazy",decoding:"async",className:"w-full h-auto rounded-lg border"})})]})})}),e.jsx(It,{value:"specs",className:"mt-6 animate-fade-in",children:e.jsx("div",{className:"border rounded-lg p-4",children:e.jsx("div",{className:"technical-data-display",children:e.jsx("div",{className:"td-grid-container",children:n&&n.length>0?e.jsxs(e.Fragment,{children:[(()=>{const w=n.filter(b=>{var D,M;const f=((M=(D=b.product_attributes)==null?void 0:D.name)==null?void 0:M.toLowerCase())||"";return!f.includes("zertifikat")&&!f.includes("certificate")}),C=6,A=[];for(let b=0;b<w.length;b+=C)A.push(w.slice(b,b+C));return A.map((b,f)=>e.jsxs("div",{className:"grid-item",children:[e.jsx("h4",{children:"Technische Spezifikationen"}),b.map((D,M)=>{var K;return e.jsxs("div",{children:[e.jsx("span",{children:(K=D.product_attributes)==null?void 0:K.name}),e.jsx("span",{children:Ss(D.value)})]},M)})]},`spec-${f}`))})(),(_.length>0||s.length>0||E.length>0)&&e.jsxs("div",{className:"grid-item",children:[_.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{children:"Umweltzertifikate"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 pl-4 !border-0",children:_.map((w,C)=>N(w,`env-${C}-${w}`))})]}),s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"!mt-4",children:"Herstellerzertifikate"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 pl-4 !border-0",children:s.map((w,C)=>N(w,`mfg-${C}-${w}`))})]}),E.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"!mt-4",children:"Qualitätszertifikate"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 pl-4 !border-0",children:E.map((w,C)=>N(w,`qual-${C}-${w}`))})]})]})]}):e.jsxs("div",{className:"grid-item",children:[e.jsx("h4",{children:"Technische Spezifikationen"}),e.jsxs("div",{children:[e.jsx("span",{children:"Format"}),e.jsx("span",{children:"DIN A4"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Grammatur"}),e.jsx("span",{children:"80 g/m²"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Weiße"}),e.jsx("span",{children:"CIE 169"})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Verpackung"}),e.jsx("span",{children:m||`${(o==null?void 0:o.sheetsPerPack)??500} ${c} / ${h}`})]})]})})})})})]})})},ii=p.lazy(()=>ks(()=>un(()=>import("./ProductLowerSection-Cwq_xm-G.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])))),ai=({product:t})=>{const[n,i]=p.useState(!1),r=p.useRef(null);p.useEffect(()=>{const o=r.current;if(!o)return;const c=new IntersectionObserver(([h])=>{h.isIntersecting&&(i(!0),c.disconnect())},{rootMargin:"400px",threshold:.01});return c.observe(o),()=>c.disconnect()},[]);const a=()=>e.jsxs("div",{className:"mt-16",children:[e.jsx(re,{className:"h-8 w-64 mb-6"}),e.jsx("div",{className:"flex gap-4 overflow-hidden",children:[...Array(5)].map((o,c)=>e.jsx("div",{className:"min-w-[280px]",children:e.jsx(je,{children:e.jsxs(we,{className:"p-4",children:[e.jsx(re,{className:"aspect-square w-full rounded-lg mb-4"}),e.jsx(re,{className:"h-4 w-full mb-2"}),e.jsx(re,{className:"h-4 w-3/4 mb-2"}),e.jsx(re,{className:"h-6 w-1/2"})]})})},c))})]});return e.jsx("div",{ref:r,children:n?e.jsx(p.Suspense,{fallback:e.jsx(a,{}),children:e.jsx(ii,{product:t})}):e.jsx("div",{className:"mt-16 h-[400px]"})})},ri=({productId:t,productName:n,preselectedOrderId:i,onSubmitted:r})=>{const{user:a}=yt(),o=Ut(),[c,h]=p.useState(0),[m,l]=p.useState(""),[u,d]=p.useState(""),[g,_]=p.useState(i??""),[s,E]=p.useState(!1),N=me({queryKey:["eligible-orders",a==null?void 0:a.id,t],enabled:!!a&&!!t,queryFn:async()=>
40{if(!a)return[];const{data:k,error:L}=await te.from("orders").select("id, order_number, created_at, status, order_items!inner(product_id)").eq("user_id",a.id).in("status",["confirmed","processing","partially_shipped","shipped"]).eq("order_items.product_id",t).order("created_at",{ascending:!1}).limit(20);if(L)return console.error(L),[];const{data:w}=await te.from("product_reviews").select("order_id").eq("product_id",t).eq("user_id",a.id),C=new Set((w??[]).map(A=>A.order_id));return(k??[]).filter(A=>!C.has(A.id)).map(({id:A,order_number:b,created_at:f})=>({id:A,order_number:b,created_at:f}))}});p.useEffect(()=>{var k;i&&((k=N.data)!=null&&k.some(L=>L.id===i))?_(i):!g&&N.data&&N.data.length>0&&_(N.data[0].id)},[N.data,i]);const j=N.data??[];if(!a)return e.jsx("div",{className:"rounded-lg border bg-muted/30 p-4 text-sm",children:e.jsxs("p",{children:[e.jsx(fe,{to:"/anmelden",className:"text-primary underline",children:"Melden Sie sich an"}),", um dieses Produkt zu bewerten. Nur verifizierte Käufer können Bewertungen abgeben."]})});if(N.isLoading)return e.jsxs("div",{className:"text-sm text-muted-foreground flex items-center gap-2",children:[e.jsx(gt,{className:"w-4 h-4 animate-spin"})," Bewertbare Bestellungen werden geprüft …"]});if(j.length===0)return e.jsxs("div",{className:"rounded-lg border bg-muted/30 p-4 text-sm flex items-start gap-2",children:[e.jsx(Es,{className:"w-4 h-4 mt-0.5 shrink-0 text-muted-foreground"}),e.jsx("span",{children:"Sie haben dieses Produkt bislang nicht gekauft (oder bereits bewertet). Nach einem verifizierten Kauf können Sie es hier bewerten."})]});const q=async()=>{if(!c){be.error("Bitte vergeben Sie 1 – 5 Sterne.");return}if(!g){be.error("Bitte wählen Sie eine Bestellung.");return}E(!0);try{const{data:k,error:L}=await te.functions.invoke("submit-product-review",{body:{product_id:t,order_id:g,rating:c,title:m,body:u}});if(L)throw L;if(k!=null&&k.error)throw new Error(k.error);be.success(c>=4?"Vielen Dank für Ihre Bewertung!":"Vielen Dank! Ihre Bewertung wird noch kurz geprüft und danach veröffentlicht."),h(0),l(""),d(""),o.invalidateQueries({queryKey:["product-reviews",t]}),o.invalidateQueries({queryKey:["product-review-stats",t]}),o.invalidateQueries({queryKey:["eligible-orders",a==null?void 0:a.id,t]}),o.invalidateQueries({queryKey:["my-reviews",a==null?void 0:a.id]}),r==null||r()}catch(k){be.error(k.message??"Bewertung konnte nicht gespeichert werden.")}finally{E(!1)}};return e.jsxs("div",{className:"rounded-lg border bg-card p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold text-lg",children:["Bewertung abgeben",n?` für ${n}`:""]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Nur verifizierte Käufer können bewerten."})]}),j.length>1&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Oe,{htmlFor:"review-order",children:"Bestellung"}),e.jsxs(Ze,{value:g,onValueChange:_,children:[e.jsx(Ke,{id:"review-order",children:e.jsx(Qe,{placeholder:"Bestellung wählen"})}),e.jsx(Ge,{children:j.map(k=>e.jsxs(pe,{value:k.id,children:[k.order_number," – ",new Date(k.created_at).toLocaleDateString("de-DE")]},k.id))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Oe,{children:"Ihre Sterne *"}),e.jsx("div",{"data-testid":"review-stars",children:e.jsx(ln,{value:c,onChange:h})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Oe,{htmlFor:"review-title",children:"Titel (optional)"}),e.jsx(ze,{id:"review-title",value:m,onChange:k=>l(k.target.value),maxLength:150,placeholder:"z. B. Top-Qualität, gerne wieder"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Oe,{htmlFor:"review-body",children:"Ihre Erfahrung (optional)"}),e.jsx(is,{id:"review-body",value:u,onChange:k=>d(k.target.value),maxLength:2e3,rows:4,placeholder:"Was hat Ihnen besonders gefallen?"}),e.jsxs("div",{className:"text-xs text-muted-foreground text-right",children:[u.length," / 2000"]})]}),e.jsxs(ce,{"data-testid":"review-submit",onClick:q,disabled:s||!c,children:[s&&e.jsx(gt,{className:"w-4 h-4 mr-2 animate-spin"}),"Bewertung absenden"]})]})},ut=10,li=({productId:t,productName:n,showSubmitForm:i=!0,anchorId:r="bewertungen"})=>{const a=hn(t),o=He(t),[c,h]=p.useState("all"),[m,l]=p.useState("newest"),[u,d]=p.useState(ut),[g]=hs(),_=g.get("bewerten")??void 0,s=p.useMemo(()=>{var L,w;const j=(((L=a.data)==null?void 0:L.internal)??[]).map(C=>({kind:"internal",...C})),q=(((w=a.data)==null?void 0:w.external)??[]).map(C=>({kind:"external",...C}));let k=[];return c==="verified"?k=j:c==="external"?k=q:k=[...j,...q],k.sort((C,A)=>
40{if(m==="highest")return(A.rating||0)-(C.rating||0);if(m==="lowest")return(C.rating||0)-(A.rating||0);const b="reviewed_at"in C&&C.reviewed_at||C.created_at,f="reviewed_at"in A&&A.reviewed_at||A.created_at;return new Date(f).getTime()-new Date(b).getTime()}),k},[a.data,c,m]),E=o.data,N=s.slice(0,u);return e.jsxs("section",{id:r,"aria-label":"Kundenbewertungen",className:"scroll-mt-24 space-y-6",children:[e.jsx("div",{className:"border rounded-lg p-6",children:e.jsxs("div",{className:"flex flex-wrap items-end gap-6 justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Bewertungen"}),E&&E.review_count>0?e.jsxs("div",{className:"mt-2 flex items-center gap-3",children:[e.jsx("span",{className:"text-3xl font-bold tabular-nums",children:E.avg_rating.toFixed(1).replace(".",",")}),e.jsxs("div",{children:[e.jsx(jt,{value:E.avg_rating,size:20}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[E.review_count," Bewertung",E.review_count===1?"":"en",E.external_count>0&&e.jsxs(e.Fragment,{children:[" · ",E.internal_count," verifiziert, ",E.external_count," extern"]})]})]})]}):e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Noch keine Bewertungen vorhanden."})]}),E&&E.review_count>0&&e.jsx("div",{className:"flex-1 min-w-[200px] max-w-md space-y-1",children:[5,4,3,2,1].map(j=>{var L;const q=((L=E.rating_distribution)==null?void 0:L[String(j)])??0,k=E.review_count>0?Math.round(q/E.review_count*100):0;return e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"w-4 text-right tabular-nums",children:j}),e.jsx("div",{className:"flex-1 h-2 bg-muted rounded overflow-hidden",children:e.jsx("div",{className:"h-full bg-yellow-400",style:{width:`${k}%`}})}),e.jsx("span",{className:"w-10 tabular-nums text-muted-foreground",children:q})]},j)})})]})}),i&&e.jsx(ri,{productId:t,productName:n,preselectedOrderId:_}),s.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs(Ze,{value:c,onValueChange:j=>{h(j),d(ut)},children:[e.jsx(Ke,{className:"w-44",children:e.jsx(Qe,{})}),e.jsxs(Ge,{children:[e.jsx(pe,{value:"all",children:"Alle Bewertungen"}),e.jsx(pe,{value:"verified",children:"Nur verifizierte Käufe"}),e.jsx(pe,{value:"external",children:"Nur externe Quellen"})]})]}),e.jsxs(Ze,{value:m,onValueChange:j=>l(j),children:[e.jsx(Ke,{className:"w-44",children:e.jsx(Qe,{})}),e.jsxs(Ge,{children:[e.jsx(pe,{value:"newest",children:"Neueste zuerst"}),e.jsx(pe,{value:"highest",children:"Beste Bewertung"}),e.jsx(pe,{value:"lowest",children:"Niedrigste Bewertung"})]})]})]}),a.isLoading?e.jsx("div",{className:"space-y-3",children:Array.from({length:3}).map((j,q)=>e.jsx(re,{className:"h-24 w-full"},q))}):e.jsx("ul",{className:"space-y-4",children:N.map(j=>e.jsx("li",{className:"border rounded-lg p-4 bg-card",children:e.jsx(oi,{review:j})},`${j.kind}-${j.id}`))}),s.length>N.length&&e.jsx("div",{className:"text-center",children:e.jsx(ce,{variant:"outline",onClick:()=>d(j=>j+ut),children:"Weitere Bewertungen laden"})})]})},oi=({review:t})=>{const n="reviewed_at"in t&&t.reviewed_at?t.reviewed_at:t.created_at,i=n?new Date(n).toLocaleDateString("de-DE",{year:"numeric",month:"long",day:"numeric"}):"";return e.jsxs("article",{children:[e.jsxs("header",{className:"flex items-center justify-between gap-3 flex-wrap mb-2",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(jt,{value:t.rating,size:16}),t.kind==="internal"&&t.is_verified_purchase&&e.jsx(Ye,{variant:"secondary",className:"text-[10px] uppercase tracking-wide",children:"Verifizierter Kauf"}),t.kind==="external"&&e.jsxs(Ye,{variant:"outline",className:"text-[10px] uppercase tracking-wide gap-1",children:[gn(t.source),t.source_url&&e.jsx("a",{href:t.source_url,target:"_blank",rel:"nofollow noopener noreferrer","aria-label":"Quelle öffnen",className:"inline-flex",children:e.jsx(As,{className:"w-3 h-3"})})]})]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i})]}),t.title&&e.jsx("h3",{className:"font-semibold text-sm mb-1",children:t.title}
40),t.body&&e.jsx("p",{className:"text-sm text-foreground/90 whitespace-pre-line",children:t.body}),t.kind==="external"&&t.author_name&&e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["– ",t.author_name]}),t.kind==="internal"&&t.admin_reply&&e.jsxs("div",{className:"mt-3 pl-3 border-l-2 border-primary/40 bg-primary/5 p-3 rounded-r",children:[e.jsx("p",{className:"text-xs font-semibold text-primary mb-1",children:"Antwort von Paperworld Hamburg"}),e.jsx("p",{className:"text-sm whitespace-pre-line",children:t.admin_reply})]})]})},ci=({product:t,priceTiers:n,quantity:i,setQuantity:r,customerPricing:a,hasSpecialPrice:o=!1,saleTieredPricing:c,saleStartDate:h,saleEndDate:m,palletProductSlug:l})=>{var ee,H,le;const[u,d]=p.useState(null),[g,_]=p.useState(null),E=c&&c.trim()!==""&&Ls(h,m),N=P.useMemo(()=>!E||!c?[]:Fs(c).map((x,$)=>({id:`sale-tier-${$}`,min_quantity:x.min_quantity,price:x.price})),[E,c]),j=t?wt(t):null,q=(a==null?void 0:a.basePrice)??(t==null?void 0:t.price)??0,k=o&&(a==null?void 0:a.isSpecialPrice),L=t.min_order_quantity||1,w=P.useMemo(()=>{if(k&&(a!=null&&a.tiers)&&a.tiers.length>0){const R=a.tiers.map((ie,de)=>({id:`special-tier-${de}`,min_quantity:ie.min_quantity,price:ie.price}));return R.some(ie=>ie.min_quantity===L)?R.sort((ie,de)=>ie.min_quantity-de.min_quantity):[{id:"min-tier",min_quantity:L,price:q},...R].sort((ie,de)=>ie.min_quantity-de.min_quantity)}if(E&&N.length>0){const R=n||[],X=R.some(oe=>oe.min_quantity===L)?[...R]:[{id:"min-tier",min_quantity:L,price:q},...R],ie=new Map(N.map(oe=>[oe.min_quantity,oe.price])),de=X.map(oe=>{const Ne=ie.get(oe.min_quantity);return Ne!==void 0?{...oe,price:Ne}:oe}),G=new Set(X.map(oe=>oe.min_quantity)),xe=N.filter(oe=>!G.has(oe.min_quantity));return[...de,...xe].sort((oe,Ne)=>oe.min_quantity-Ne.min_quantity)}const x=n||[];return x.some(R=>R.min_quantity===L)?x.sort((R,X)=>R.min_quantity-X.min_quantity):[{id:"min-tier",min_quantity:L,price:q},...x].sort((R,X)=>R.min_quantity-X.min_quantity)},[n,L,q,k,a,E,N,t.sale_price]),C=P.useMemo(()=>w.length>0?Math.max(...w.map(x=>x.min_quantity))*3:Math.max(L*10,100),[w,L]),A=P.useMemo(()=>{if(!E||k)return new Map;const x=new Map,$=n||[];return x.set(L,q),$.forEach(R=>x.set(R.min_quantity,R.price)),x},[E,n,L,q,k]),b=u??i,f=((ee=w==null?void 0:w.filter(x=>b>=x.min_quantity).sort((x,$)=>$.min_quantity-x.min_quantity)[0])==null?void 0:ee.price)||q,D=Math.round(f*b*100)/100,M=D>=ye.freeShippingThreshold,K=j!=null&&j.sheetsPerPack?j.sheetsPerPack*b:null,se=bt(t,(H=t.categories)==null?void 0:H.packaging_unit_label),ae=(x,$)=>{if($<=1)return x;const R=["palette","rolle"],X=x.toLowerCase();return R.includes(X)?x+"n":x},T=vt(t,(le=t==null?void 0:t.categories)==null?void 0:le.quantity_unit_label),[O,Z]=p.useState(0),[J,ne]=p.useState(!1),{settings:v}=qs(),[S,V]=p.useState(1),y=(v==null?void 0:v.is_enabled)!==!1&&t.subscription_enabled!==!1;p.useEffect(()=>{v!=null&&v.default_interval&&V(v.default_interval)},[v==null?void 0:v.default_interval]);const{addItem:U}=Ds(),{showAddedDialog:F}=zs(),B=x=>{const $=parseInt(x.target.value);if(!isNaN($)&&$>0){const R=t.min_order_quantity||1,X=t.order_quantity_steps||1;r(tt($,R,X))}},Y=()=>{const x=t.min_order_quantity||1,$=t.order_quantity_steps||1;r(Bs(i,x,$))},I=()=>{const x=t.min_order_quantity||1,$=t.order_quantity_steps||1;r(Ps(i,x,$))},W=(x,$)=>{const R=$.getBoundingClientRect();if(R.width<=0)return null;const X=Math.min(1,Math.max(0,(x-R.left)/R.width)),ie=L+X*(C-L),de=t.order_quantity_steps||1;return Math.min(C,tt(ie,L,de))},ue=x=>{if(x.pointerType==="touch"||x.buttons!==0)return;const $=W(x.clientX,x.currentTarget);if($===null||x.currentTarget.getBoundingClientRect().width<=0)return;const X=C===L?0:($-L)/(C-L)*100;d($),_(X)},he=()=>{d(null),_(null)},Q=()=>{if(!t)return;const x={id:t.id,name:t.name,price:(t.price??0).toString(),sale_price:t.sale_price??void 0,tiered_pricing:t.tiered_pricing??null,sale_tiered_pricing:c??null,sale_start_date:h??null,sale_end_date:m??null,image:t.image_url,image_url:t.image_url,slug:t.slug,short_description:t.short_description,sku:t.sku,sourceUrl:t.image_url,
40inStock:!0,min_order_quantity:t.min_order_quantity,order_quantity_steps:t.order_quantity_steps,sheets_per_pack:t.sheets_per_pack,packs_per_carton:t.packs_per_carton,category_id:t.category_id,brand_id:t.brand_id,categories:t.categories,brands:t.brands,packaging_unit_label_override:t.packaging_unit_label_override};U(x,i,J,J?S:void 0),F({product:x,quantity:i,isSubscription:J,subscriptionInterval:J?S:void 0})};return p.useEffect(()=>{Z(x=>x+1)},[f]),e.jsxs("div",{className:"space-y-4 min-h-[560px] lg:min-h-[640px]",children:[k&&e.jsxs("div",{className:"p-3 bg-gradient-to-r from-amber-50 to-yellow-50 border border-amber-200 rounded-lg flex items-center gap-2",children:[e.jsx(Ie,{className:"h-5 w-5 text-amber-500 fill-amber-400"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-amber-800",children:"Ihr Sonderpreis"}),e.jsx("p",{className:"text-xs text-amber-700",children:"Exklusive Konditionen für Sie"})]})]}),E&&!k&&e.jsxs("div",{className:"p-3 bg-gradient-to-r from-red-50 to-orange-50 border border-red-200 rounded-lg flex items-center gap-2",children:[e.jsx(Ms,{className:"h-5 w-5 text-red-500"}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold text-red-800",children:"Aktionspreis"}),e.jsx("p",{className:"text-xs text-red-700",children:"Zeitlich begrenztes Angebot"})]})]}),w&&w.length>0&&e.jsxs("div",{className:"space-y-3 animate-fade-in",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-px flex-1 bg-gradient-to-r from-transparent via-border to-transparent"}),e.jsx("h3",{className:"text-sm font-bold text-foreground tracking-wide uppercase",children:k?"Ihre Staffelpreise":E?"Aktions-Staffelpreise":"Staffelpreise"}),e.jsx("div",{className:"h-px flex-1 bg-gradient-to-r from-transparent via-border to-transparent"})]}),e.jsxs("div",{className:"space-y-3",children:[w.map((x,$)=>{const R=x.min_quantity===(t.min_order_quantity||1)&&$===0,X=b>=x.min_quantity,ie=E&&!k?A.get(x.min_quantity)??q:null,de=ie!==null&&ie>x.price,G=x.price<q?((q-x.price)/q*100).toFixed(0):null;return e.jsxs("div",{className:"relative",children:[R&&e.jsx("div",{className:"pointer-events-none absolute -top-1.5 -left-1.5 z-10 bg-brand-red text-white text-[9px] px-1.5 py-0.5 rounded-full font-bold shadow-md",children:"MIN"}),G&&e.jsx("div",{className:"pointer-events-none absolute -top-1.5 inset-x-0 z-10 flex justify-center",children:e.jsxs("div",{className:"bg-gradient-to-br from-green-600 to-green-700 text-white text-[11px] px-2 py-0.5 rounded-full font-bold shadow-lg whitespace-nowrap",children:["-",G,"%"]})}),e.jsxs("button",{onClick:()=>r(x.min_quantity),className:`
41                      group relative overflow-hidden rounded-lg border-2 p-3 w-full
42                      transition-colors duration-200 hover:shadow-lg
43                      ${X?"border-brand-red bg-gradient-to-r from-brand-red/15 via-brand-red/10 to-brand-red/5 shadow-lg shadow-brand-red/20":"border-border bg-gradient-to-r from-background to-muted/30 hover:border-brand-red/70"}
44                    `,children:[X&&e.jsx("div",{className:"absolute top-0 left-0 right-0 h-1 bg-gradient-to-r from-brand-red via-red-500 to-brand-red"}),e.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] gap-2 items-center pt-0.5",children:[e.jsxs("div",{className:"flex items-baseline gap-1 min-w-0",children:[e.jsx("span",{className:"text-[10px] text-muted-foreground font-medium shrink-0",children:"ab"}),e.jsx("span",{className:`text-lg sm:text-xl font-bold tabular-nums ${X?"text-brand-red":"text-foreground"}`,children:x.min_quantity}),e.jsx("span",{className:"text-[11px] sm:text-xs text-muted-foreground font-medium truncate",children:ae(se,x.min_quantity)})]}),e.jsx("div",{className:"flex flex-col items-center justify-self-center w-[clamp(60px,22%,120px)] min-w-0",children:G?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-[9px] text-muted-foreground uppercase tracking-wide mb-0.5",children:"Ersparnis"}),e.jsx("span",{className:"text-[11px] sm:text-xs font-bold text-green-700 whitespace-nowrap tabular-nums",children:Ce((q-x.price)*x.min_quantity)})]}):e.jsx("div",{className:"h-[2.25rem]"})}),e.jsxs("div",{className:"flex flex-col items-end min-w-0 text-right",children:[e.jsx("span",{className:"text-[9px] text-muted-foreground uppercase tracking-wide mb-0.5 truncate max-w-full",children:"Stückpreis"}),de&&e.jsx("span",{className:"text-[11px] sm:text-xs text-brand-red/70 line-through tabular-nums whitespace-nowrap",children:Ce(ie)}),e.jsx("span",{className:`text-base sm:text-lg font-bold tabular-nums whitespace-nowrap ${X?"text-brand-red":"text-foreground"}`,children:Ce(x.price)})]})]})]})]},x.id)}),l&&e.jsxs(fe,{to:`/${l}`,className:"group relative overflow-visible rounded-lg border-2 border-brand-red/40 bg-brand-red/5 p-3 w-full transition-colors duration-300 hover:shadow-lg hover:border-brand-red hover:bg-brand-red/10 hover:shadow-brand-red/20 text-foreground font-semibold flex items-center justify-center gap-2",children:[e.jsx("img",{src:fn,alt:"",className:"h-8 w-8"}),"Palettenpreise"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{htmlFor:"product-quantity-input",className:"sr-only",children:"Menge"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ce,{variant:"outline",size:"sm",onClick:I,disabled:i<=(t.min_order_quantity||1),"aria-label":"Menge verringern",className:"hover-scale hover:border-brand-red hover:bg-brand-red/5",children:e.jsx(At,{className:"w-4 h-4"})}),e.jsx(ze,{id:"product-quantity-input","data-testid":"product-quantity-input",type:"number",value:i,onChange:B,min:t.min_order_quantity||1,step:t.order_quantity_steps||1,"aria-label":"Menge",className:"flex-1 text-center"}),e.jsx(ce,{variant:"outline",size:"sm",onClick:Y,"aria-label":"Menge erhöhen",className:"hover-scale hover:border-brand-red hover:bg-brand-red/5",children:e.jsx(Lt,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"relative pt-11 pb-3 cursor-pointer",onPointerMove:ue,onPointerLeave:he,onClick:x=>{const $=W(x.clientX,x.currentTarget);$!==null&&r($)},children:[u!==null&&g!==null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":"true",className:`pointer-events-none absolute top-9 bottom-0 z-20 border-l-2 border-dashed transition-[left] duration-75 ${u>=i?"border-brand-red":"border-background drop-shadow-[0_0_2px_hsl(var(--foreground))]"}`,style:{left:`${g}%`}}),e.jsxs("span",{role:"status",className:"pointer-events-none absolute top-0 z-30 whitespace-nowrap rounded-md border border-border bg-popover px-2.5 py-1 text-xs font-semibold text-popover-foreground shadow-md transition-[left] duration-75",style:{left:`${g}%`,transform:g<=15?"translateX(0)":g>=85?"translateX(-100%)":"translateX(-50%)"},children:[u," ",ae(se,u)," · ",Ce(f)]})]}),e.jsx(Is,{value:[i],onValueChange:x=>{const $=x[0],R=t.order_quantity_steps||1;r(tt($,L,R))},min:L,max:C,step:t.order_quantity_steps||1,className:"w-full"})]})]}),(t.min_order_quantity&&t.min_order_quantity>1||t.order_quantity_steps&&t.order_quantity_steps>1)&&e.jsxs("div",{className:"text-xs text-gray-600 flex gap-4",children:[t.min_order_quantity&&t.min_order_quantity>1&&e.jsxs("span",{children:["Min: ",t.min_order_quantity]}),t.order_quantity_steps&&t.order_quantity_steps>1&&e.jsxs("span",{children:["Schritte: ",t.order_quantity_steps]})]}),y&&e.jsx(Ts,{isSubscription:J,onSubscriptionChange:ne,interval:S,onIntervalChange:V,availableIntervals:v==null?void 0:v.available_intervals}),(j==null?void 0:j.isValid)&&K&&e.jsx("div",{className:"p-3 bg-blue-50 rounded border border-blue-200 text-sm py-[8px]",children:e.jsxs("div",{className:"font-bold text-blue-900 flex items-center gap-2",children:[e.jsx("span",{className:"text-lg",children:"📄"}
44),e.jsxs("span",{children:[K.toLocaleString()," ",T," insgesamt"]})]})}),e.jsxs("div",{className:"p-5 bg-gradient-to-br from-primary/10 to-primary/5 rounded-lg border-2 border-primary/30 shadow-sm py-[10px]",children:[e.jsxs("div",{className:"flex justify-between items-baseline",children:[e.jsx("span",{className:"text-base font-semibold text-gray-800",children:"Gesamtpreis:"}),e.jsx("span",{className:"text-2xl font-bold text-primary transition-all duration-300 hover:scale-110 animate-fade-in",children:Ce(D)})]}),b>1&&e.jsxs("div",{className:"mt-2 text-sm text-gray-600 animate-fade-in",children:[e.jsxs("span",{className:"font-bold text-foreground",children:[b," ",se]})," × ",e.jsx("span",{className:"font-bold text-brand-red",children:Ce(f)}),f<q&&e.jsxs(e.Fragment,{children:[" = Ersparnis: ",Ce((q-f)*b)]})]}),e.jsxs("div",{className:"mt-2 flex items-start gap-2 border-t border-primary/20 pt-2 text-sm","aria-live":"polite",children:[e.jsx(Jt,{"aria-hidden":"true",className:"mt-0.5 h-4 w-4 shrink-0 text-primary"}),e.jsx("span",{className:M?"font-semibold text-primary":"text-muted-foreground",children:M?"Versandkostenfrei nach Deutschland & Österreich":`Noch ${Ce(ye.freeShippingThreshold-D)} bis zum versandkostenfreien Versand (DE & AT)`})]})]}),e.jsxs(ce,{"data-testid":"add-to-cart-btn",onClick:Q,size:"lg",className:"hidden sm:flex w-full h-auto py-2 sm:py-3 text-sm",disabled:!t.stock_quantity||t.stock_quantity<=0,children:[e.jsx(Ft,{className:"w-4 h-4 mr-1"}),J?`Abo starten (alle ${S} ${S===1?"Monat":"Monate"})`:"In den Warenkorb"]}),t.stock_quantity&&t.stock_quantity>0&&e.jsx(di,{children:e.jsxs("div",{className:"bg-background border-t border-border px-3 py-2 shadow-[0_-2px_10px_rgba(0,0,0,0.06)] flex items-center gap-2",style:{paddingBottom:"calc(0.5rem + env(safe-area-inset-bottom))"},children:[e.jsxs("div",{className:"flex items-center border border-border rounded-md h-11 shrink-0",children:[e.jsx(ce,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-10 rounded-none",onClick:I,"aria-label":"Menge verringern",children:e.jsx(At,{className:"w-4 h-4"})}),e.jsx("span",{className:"min-w-[2.5rem] text-center text-sm font-semibold tabular-nums",children:i}),e.jsx(ce,{type:"button",variant:"ghost",size:"icon",className:"h-11 w-10 rounded-none",onClick:Y,"aria-label":"Menge erhöhen",children:e.jsx(Lt,{className:"w-4 h-4"})})]}),e.jsxs(ce,{"data-testid":"add-to-cart-btn-mobile",onClick:Q,className:"flex-1 h-11 text-sm",disabled:!t.stock_quantity||t.stock_quantity<=0,children:[e.jsx(Ft,{className:"w-4 h-4 mr-1.5"}),J?"Abo starten":"In den Warenkorb"]})]})})]})},di=({children:t})=>{const n=p.useRef(null);return p.useEffect(()=>{const i=n.current;if(!i)return;const r=document.documentElement,a=()=>{const c=i.getBoundingClientRect().height;c>0&&r.style.setProperty("--mobile-product-cta-height",`${Math.round(c)}px`)};a();const o=typeof ResizeObserver<"u"?new ResizeObserver(a):null;return o==null||o.observe(i),()=>{o==null||o.disconnect(),r.style.setProperty("--mobile-product-cta-height","0px")}},[]),e.jsx("div",{ref:n,className:"sm:hidden fixed inset-x-0 bottom-0 z-50",style:{transform:"translateY(var(--mobile-product-cta-viewport-offset, 0px))",willChange:"transform"},children:t})},Mi=()=>{var se,ae,T,O,Z,J,ne;const{slug:t}=gs(),[n,i]=p.useState(1),[r,a]=p.useState(0);p.useState(!1);const[o,c]=p.useState(null),[h,m]=p.useState(null),[l,u]=p.useState(!1);pt();const{isAdmin:d}=yt(),g=Os();p.useEffect(()=>(document.documentElement.style.setProperty("--mobile-cta-offset","calc(var(--mobile-product-cta-height, 62px) + 8px)"),()=>{document.documentElement.style.setProperty("--mobile-cta-offset","0px")}),[]);const _=v=>{try{const S=JSON.parse(localStorage.getItem("recentlyViewed")||"[]"),V=[v,...S.filter(y=>y!==v)].slice(0,10);localStorage.setItem("recentlyViewed",JSON.stringify(V)),window.dispatchEvent(new Event("recently-viewed-updated"))}catch(S){console.error("Error saving to recently viewed:",S)}},{data:s,isLoading:E,error:N}=me({queryKey:["product",t],queryFn:async()=>{if(!t)throw new Error("Kein Produkt-Slug angegeben");const v=`
45          id, name, sku, slug, price, sale_price, short_description, long_description,
46          rating, image_url, gallery_images, image_alts, is_active, is_featured, stock_quantity,
47          min_order_quantity, order_quantity_steps, category_id, brand_id, family_id,
48          weight,
49          pallet_product_id, tags, packaging_unit_label_override, quantity_unit_label_override,
50          sheets_per_pack, packs_per_carton, stueck_ve, seo_title, seo_description, meta_keywords,
51          og_title, og_description, og_image, canonical_url, noindex, nofollow,
52          visibility,
53          tiered_pricing, sale_tiered_pricing, sale_start_date, sale_end_date,
54          categories(name, slug, packaging_unit_label, quantity_unit_label),
55          brands(name, slug)
56        `,{data:S,error:V}=await te.from("products").select(v).eq("slug",t).eq("is_active",!0).maybeSingle();if(V)throw V;if(!S){const{data:y}=await te.from("products").select(v).eq("slug",t).maybeSingle();throw y&&console.warn(`Produkt "${t}" existiert, ist aber inaktiv`),new Error("Produkt nicht gefunden")}return S},enabled:!!t,staleTime:2*60*1e3,gcTime:5*60*1e3}),{data:j}=He(s==null?void 0:s.id),{data:q}=me({queryKey:["all-categories-full"],queryFn:async()=>{const{data:v,error:S}=await te.from("categories").select("id, name, slug, parent_id, sort_order, filter_config, intro_html, og_title, og_description, og_image, meta_keywords, canonical_url, noindex, nofollow, description, image_url, icon_url, packaging_unit_label, quantity_unit_label").eq("is_active",!0);if(S)throw S;return v||[]},staleTime:10*60*1e3,gcTime:30*60*1e3}),{data:k}=me({queryKey:["product-attributes",s==null?void 0:s.id],queryFn:async()=>
56{if(!(s!=null&&s.id))return[];const{data:v,error:S}=await te.from("product_attribute_assignments").select(`
57          *,
58          product_attributes(slug, name, type, unit)
59        `).eq("product_id",s.id).order("sort_order",{ascending:!0});if(S)throw S;return v},enabled:!!(s!=null&&s.id),staleTime:5*60*1e3,gcTime:10*60*1e3}),L=p.useMemo(()=>s!=null&&s.tiered_pricing?s.tiered_pricing.split(",").map((v,S)=>{const[V,y]=v.split(":");return{id:`tier-${S}`,product_id:s.id,min_quantity:parseInt(V.trim()),price:parseFloat(y.trim())}}).filter(v=>!isNaN(v.min_quantity)&&!isNaN(v.price)):[],[s==null?void 0:s.tiered_pricing,s==null?void 0:s.id]),w=p.useMemo(()=>s?{sale_tiered_pricing:s.sale_tiered_pricing,sale_start_date:s.sale_start_date,sale_end_date:s.sale_end_date}:null,[s==null?void 0:s.sale_tiered_pricing,s==null?void 0:s.sale_start_date,s==null?void 0:s.sale_end_date]),{data:C}=me({queryKey:["pallet-product-slug",s==null?void 0:s.pallet_product_id],queryFn:async()=>{if(!(s!=null&&s.pallet_product_id))return null;const{data:v,error:S}=await te.from("products").select("slug").eq("id",s.pallet_product_id).eq("is_active",!0).maybeSingle();if(S)throw S;return(v==null?void 0:v.slug)??null},enabled:!!(s!=null&&s.pallet_product_id),staleTime:5*60*1e3}),{data:A}=me({queryKey:["product-family-seo",s==null?void 0:s.family_id],queryFn:async()=>{if(!(s!=null&&s.family_id))return null;const{data:v,error:S}=await te.from("product_families").select("id, slug, name, variation_attributes").eq("id",s.family_id).maybeSingle();if(S)throw S;return v},enabled:!!(s!=null&&s.family_id),staleTime:30*60*1e3,gcTime:60*60*1e3});p.useEffect(()=>{if(s){const v=s.min_order_quantity||1;i(v),_(s.id);const S={id:s.id,sku:s.sku,name:s.name,price:$s(s,v,g),brands:s.brands,categories:s.categories};Rs(S)}},[s]),p.useEffect(()=>{if(!s){c(null),m(null);return}if(s.long_description){const S=new DOMParser().parseFromString(s.long_description,"text/html"),V=S.querySelector(".td-grid-container");V&&V.remove(),c(S.body.innerHTML)}else c(null),m(null)},[s]),p.useEffect(()=>{if(!s){m(null);return}const v=S=>{try{const y=new DOMParser().parseFromString(S,"text/html"),U=y.querySelector("table.ratings")||y.querySelector("table"),F=[];return U&&U.querySelectorAll("tr").forEach(Y=>{var W,ue;const I=Y.querySelectorAll("td, th");if(I.length>=2){const he=(W=I[0].textContent)==null?void 0:W.trim(),Q=((ue=I[1].textContent)==null?void 0:ue.trim())||"";if(!he)return;let ee=0;if(/(⭐|★)/.test(Q))ee=(Q.match(/⭐|★/g)||[]).length;else if(/\b(\d)\s*\/\s*5\b/.test(Q)){const H=Q.match(/\b(\d)\s*\/\s*5\b/);ee=H?parseInt(H[1]):0}else{const H=Q.match(/\b([1-5])\b/);ee=H?parseInt(H[1]):0}ee>0&&F.push({name:he,rating:Math.min(5,Math.max(1,ee))})}}),F}catch{return[]}};if(s.rating&&s.rating.trim()!==""){const S=v(s.rating);if(S.length>0){m(S);return}}if(s.long_description){const S=v(s.long_description);m(S.length>0?S:null)}else m(null)},[s]);const b=()=>{var U;if(!((U=s==null?void 0:s.categories)!=null&&U.slug)||!q)return[];const v=new Map(q.map(F=>[F.id,F])),S=[];let V=q.find(F=>F.slug===s.categories.slug);const y=new Set;for(;V&&!y.has(V.id);)y.add(V.id),S.unshift(V),V=V.parent_id?v.get(V.parent_id):null;return S},f=()=>{var R,X,ie,de;if(!s)return null;const v=(s==null?void 0:s.sale_price)||(s==null?void 0:s.price)||0,S=Me(s.slug),V=(R=s.image_url)!=null&&R.startsWith("http")?s.image_url:s.image_url?`${De}${s.image_url}`:nt,U=v>=ye.freeShippingThreshold?"0.00":ye.standardShippingCost.toFixed(2),B=`${new Date().getUTCFullYear()+1}-12-31`,Y=s.stock_quantity===0,I={"@type":"Product","@id":`${S}#product`,name:s.name,description:us(s.short_description)||s.seo_description||s.name,sku:s.sku,mpn:s.sku,productID:s.sku,url:S,image:[V],...(X=s.categories)!=null&&X.name?{category:s.categories.name}:{},...(ie=s.brands)!=null&&ie.name?{brand:{"@type":"Brand",name:s.brands.name}}:{},offers:{"@type":"Offer",url:S,priceCurrency:"EUR",price:v.toFixed(2),priceValidUntil:B,availability:Y?"https://schema.org/OutOfStock":"https://schema.org/InStock",itemCondition:"https://schema.org/NewCondition",priceSpecification:[{"@type":"UnitPriceSpecification",price:v.toFixed(2),priceCurrency:"EUR",valueAddedTaxIncluded:!1,eligibleQuantity:{"@type":"QuantitativeValue",minValue:1,unitCode:"C62"}},...L.filter(G=>G.min_quantity>1&&G.price>0).sort((G,xe)=>G.min_quantity-xe.min_quantity).map(G=>({"@type":"UnitPriceSpecification",price:G.price.toFixed(2),priceCurrency:"EUR",valueAddedTaxIncluded:!1,eligibleQuantity:{"@type":"QuantitativeValue",minValue:G.min_quantity,unitCode:"C62"}}))],seller:{"@type":"Organization",name:ve,url:De},hasMerchantReturnPolicy:{"@type":"MerchantReturnPolicy",applicableCountry:it.country,returnPolicyCountry:it.country,returnPolicyCategory:"https://schema.org/MerchantReturnFiniteReturnWindow",merchantReturnDays:it.returnDays,returnMethod:"https://schema.org/ReturnByMail",returnFees:"https://schema.org/FreeReturn"},shippingDetails:{"@type":"OfferShippingDetails",shippingRate:{"@type":"MonetaryAmount",value:U,currency:"EUR"}
59,shippingDestination:{"@type":"DefinedRegion",addressCountry:ye.country},deliveryTime:{"@type":"ShippingDeliveryTime",handlingTime:{"@type":"QuantitativeValue",minValue:ye.handlingDaysMin,maxValue:ye.handlingDaysMax,unitCode:"DAY"},transitTime:{"@type":"QuantitativeValue",minValue:ye.transitDaysMin,maxValue:ye.transitDaysMax,unitCode:"DAY"}}}}};typeof s.stock_quantity=="number"&&(I.offers.inventoryLevel={"@type":"QuantitativeValue",value:s.stock_quantity}),s.weight&&Number(s.weight)>0&&(I.weight={"@type":"QuantitativeValue",value:Number(s.weight),unitCode:"KGM"});const W=new Set(((A==null?void 0:A.variation_attributes)||[]).map(G=>G.toLowerCase())),ue=[],he=new Set,Q=[];(k||[]).forEach(G=>{var Ct,St,kt;const xe=(((Ct=G.product_attributes)==null?void 0:Ct.slug)||"").toLowerCase(),oe=(St=G.product_attributes)==null?void 0:St.name,Ne=G.value,Nt=(kt=G.product_attributes)==null?void 0:kt.unit;if(!oe||!Ne)return;const Be=Ys[xe];if(Be&&W.has(xe)){I[Be]||(I[Be]=Ne);const Pe=Ws[Be];Pe&&!he.has(Pe)&&(he.add(Pe),Q.push(Pe))}ue.push({"@type":"PropertyValue",name:oe,value:Ne,...Nt?{unitText:Nt}:{}})}),ue.length>0&&(I.additionalProperty=ue),j&&j.review_count>0&&(I.aggregateRating={"@type":"AggregateRating",ratingValue:j.avg_rating.toFixed(1),reviewCount:j.review_count,bestRating:"5",worstRating:"1"});const ee=[I];if(A&&A.id){const G=`${De}/family/${A.slug||A.id}#productgroup`;I.isVariantOf={"@id":G};const xe={"@type":"ProductGroup","@id":G,name:A.name||s.name,url:S,productGroupID:A.slug||A.id,...(de=s.brands)!=null&&de.name?{brand:{"@type":"Brand",name:s.brands.name}}:{}};Q.length>0&&(xe.variesBy=Q),ee.push(xe)}const H=b(),le=[{"@type":"ListItem",position:1,name:"Startseite",item:De}];H.forEach((G,xe)=>{le.push({"@type":"ListItem",position:xe+2,name:G.name,item:Gs(G.slug)})}),le.push({"@type":"ListItem",position:le.length+1,name:s.name,item:S});const x={"@type":"BreadcrumbList","@id":`${S}#breadcrumb`,itemListElement:le};return[{"@context":"https://schema.org","@graph":[...ee,x]}]},D=t?`${t.split("-").map(v=>v.charAt(0).toUpperCase()+v.slice(1)).join(" ")} | ${ve}`:ve;if(E)return e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsxs(st,{children:[e.jsx("title",{children:D}),e.jsx("link",{rel:"canonical",href:t?Me(t):De})]}),e.jsx("div",{className:"flex-grow py-8",children:e.jsxs("div",{className:"container-layout",children:[e.jsx(re,{className:"h-8 w-64 mb-6"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-8 lg:gap-12",children:[e.jsxs("div",{className:"lg:col-span-4 space-y-2",children:[e.jsx(re,{className:"w-full h-[280px] sm:h-[400px] rounded-lg"}),e.jsx(re,{className:"h-[80px] w-full"})]}),e.jsxs("div",{className:"lg:col-span-5 space-y-4",children:[e.jsx(re,{className:"h-10 w-3/4"}),e.jsx(re,{className:"h-6 w-1/2"}),e.jsx(re,{className:"h-24 w-full"}),e.jsx(re,{className:"h-32 w-full"})]}),e.jsxs("div",{className:"lg:col-span-3 space-y-4 min-h-[560px] lg:min-h-[640px]",children:[e.jsx(re,{className:"h-12 w-full"}),e.jsx(re,{className:"h-24 w-full"}),e.jsx(re,{className:"h-10 w-full"}),e.jsx(re,{className:"h-10 w-full"}),e.jsx(re,{className:"h-12 w-full"})]})]})]})})]});if(N||!s)return e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsxs(st,{children:[e.jsx("title",{children:D}),e.jsx("meta",{name:"robots",content:"noindex"}),e.jsx("link",{rel:"canonical",href:t?Me(t):De})]}),e.jsx("div",{className:"flex-grow py-8",children:e.jsx("div",{className:"container-layout",children:e.jsxs("div",{className:"bg-red-50 border border-red-200 p-6 rounded-lg flex items-start",children:[e.jsx(Ht,{size:24,className:"text-red-600 mr-4 mt-0.5 flex-shrink-0"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-red-800 text-lg mb-2",children:"Produkt nicht gefunden"}),e.jsx("p",{className:"text-red-700 mb-4",children:"Das gesuchte Produkt konnte leider nicht gefunden werden."}),e.jsx(fe,{to:"/marken",children:e.jsx(ce,{children:"Alle Produkte anzeigen"})})]})]})})})]});const M=f(),K=(s==null?void 0:s.sale_price)||(s==null?void 0:s.price)||0;return e.jsxs("div",{className:"min-h-screen flex flex-col pb-[calc(var(--mobile-product-cta-height,88px)+env(safe-area-inset-bottom))] sm:pb-0",children:[e.jsxs(st,{children:[e.jsx("title",{children:(s==null?void 0:s.seo_title)||`${s==null?void 0:s.name} | ${ve}`}),e.jsx("meta",{name:"description",content:(s==null?void 0:s.seo_description)||Je((s==null?void 0:s.short_description)||"")||`Hochwertige Büroartikel von ${((se=s==null?void 0:s.brands)==null?void 0:se.name)||"führenden Marken"}. Jetzt online bestellen bei ${ve}!`}),e.jsx("meta",{name:"keywords",content:(s==null?void 0:s.meta_keywords)||`${s==null?void 0:s.name}, ${((ae=s==null?void 0:s.brands)==null?void 0:ae.name)||"Büropapier"}, ${((T=s==null?void 0:s.categories)==null?void 0:T.name)||"Büroartikel"}, online kaufen, ${ve}`}),e.jsx("meta",{property:"og:type",content:"product"}),e.jsx("meta",{property:"og:title",content:(s==null?void 0:s.og_title)||(s==null?void 0:s.seo_title)||`${s==null?void 0:s.name} | ${ve}`}),e.jsx("meta",{property:"og:description",content:(s==null?void 0:s.og_description)||(s==null?void 0:s.seo_description)||Je((s==null?void 0:s.short_description)||"")||`Hochwertige Büroartikel von ${((O=s==null?void 0:s.brands)==null?void 0:O.name)||"führenden Marken"}`}),e.jsx("meta",{property:"og:image",content:(s==null?void 0:s.og_image)||((Z=s==null?void 0:s.image_url)!=null&&Z.startsWith("http")?s==null?void 0:s.image_url:nt)}),e.jsx("meta",{property:"og:url",content:Me((s==null?void 0:s.slug)||"")}),e.jsx("meta",{property:"og:site_name",content:ve}),e.jsx("meta",{property:"product:price:amount",content:K==null?void 0:K.toString()}),e.jsx("meta",{property:"product:price:currency",content:"EUR"}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:(s==null?void 0:s.seo_title)||`${s==null?void 0:s.name} | ${ve}`}),e.jsx("meta",{name:"twitter:description",content:(s==null?void 0:s.seo_description)||Je((s==null?void 0:s.short_description)||"")}),e.jsx("meta",{name:"twitter:image",content:(J=s==null?void 0:s.image_url)!=null&&J.startsWith("http")?s==null?void 0:s.image_url:nt}),e.jsx("link",{rel:"canonical",href:(s==null?void 0:s.canonical_url)||Me((s==null?void 0:s.slug)||"")}),M&&M.map((v,S)=>e.jsx("script",{type:"application/ld+json",children:JSON.stringify(v)},S)),e.jsx("meta",{name:"robots",content:`${s!=null&&s.noindex||(s==null?void 0:s.visibility)==="private"?"noindex":"index"}, ${s!=null&&s.nofollow?"nofollow":"follow"}`}),(s==null?void 0:s.visibility)!=="private"&&e.jsx("meta",{name:"googlebot",content:"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1"})]}),e.jsx("div",{className:"flex-grow py-8",children:e.jsxs("div",{className:"container-layout",children:[d&&e.jsx("div",{className:"mb-4",children:e.jsxs(ce,{variant:"outline",size:"sm",onClick:()=>window.open(`/admin/products/${s.id}/edit?from=frontend`,"_blank"),className:"gap-2",children:[e.jsx(Vs,{size:16}),"Produkt bearbeiten"]})}),(s==null?void 0:s.visibility)==="private"&&e.jsxs("div",{className:"mb-4 flex items-center gap-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2 text-sm text-primary",children:[e.jsx(Us,{size:16}),e.jsx("span",{children:"Exklusiv für Sie freigegeben – dieser Artikel ist nicht öffentlich sichtbar."})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-8 lg:gap-12",children:[e.jsx("div",{className:"lg:col-span-12",children:e.jsx(xn,{product:s,categories:q})}),e.jsx("div",{className:"lg:col-span-8 lg:order-1",children:e.jsx(si,{product:s,attributes:k,priceTiers:L,quantity:n,setQuantity:i,selectedImageIndex:r,setSelectedImageIndex:a,deviceRatings:h,hasVariants:l,setHasVariants:u,categoryRoute:(ne=s.categories)!=null&&ne.slug&&q?Zt(s.categories.slug,q):void 0,preloadedAttributes:k})}),e.jsx("div",{className:"lg:col-span-4 lg:col-start-9 lg:row-start-2 lg:row-end-3 lg:order-2",children:e.jsx("div",{className:"lg:sticky lg:top-8",children:e.jsx(ci,{product:s,priceTiers:L,quantity:n,setQuantity:i,customerPricing:s&&g?g.getEffectivePricing(s.id,s.price,s.tiered_pricing):void 0,hasSpecialPrice
59:s&&g?g.hasSpecialPriceForProduct(s.id):!1,saleTieredPricing:w==null?void 0:w.sale_tiered_pricing,saleStartDate:w==null?void 0:w.sale_start_date,saleEndDate:w==null?void 0:w.sale_end_date,palletProductSlug:C})})})]}),e.jsx(Zs,{placement:"product",className:"mt-6",align:"start"}),e.jsx(ni,{product:s,attributes:k,cleanedDescription:o}),e.jsx("div",{className:"mt-8",children:e.jsx(li,{productId:s.id,productName:s.name})}),e.jsxs("div",{className:"mt-8 grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsx(je,{children:e.jsx(we,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-shrink-0 p-2 bg-green-100 rounded-full",children:e.jsx(Jt,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-sm",children:"Kostenloser Versand"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"ab 99 € netto Bestellwert · DE & AT"})]})]})})}),e.jsx(je,{children:e.jsx(we,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-shrink-0 p-2 bg-blue-100 rounded-full",children:e.jsx(Ks,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-sm",children:"Sichere Zahlung"}),e.jsx("p",{className:"text-xs text-gray-600",children:"SSL-verschlüsselt"})]})]})})}),e.jsx(je,{children:e.jsx(we,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-shrink-0 p-2 bg-orange-100 rounded-full",children:e.jsx(Qs,{className:"h-5 w-5 text-orange-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-medium text-sm",children:"Schnelle Lieferung"}),e.jsx("p",{className:"text-xs text-gray-600",children:"1-3 Werktage"})]})]})})}),e.jsx(je,{children:e.jsx(we,{className:"p-4",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-shrink-0 p-2 bg-purple-100 rounded-full",children:e.jsx(Xt,{className:"h-5 w-5 text-purple-600"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"font-medium text-sm",children:[e.jsxs("span",{className:"sm:hidden",children:["Qualitäts-",e.jsx("br",{}),"garantie"]}),e.jsx("span",{className:"hidden sm:inline",children:"Qualitätsgarantie"})]}),e.jsx("p",{className:"text-xs text-gray-600",children:"Geprüfte Markenqualität"})]})]})})})]}),e.jsx(ai,{product:s})]})})]})};export{Mi as default};

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.