admesh-ui-sdk 0.19.21 → 0.19.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/hooks/useViewabilityTracker.d.ts +9 -0
- package/dist/hooks/useViewabilityTracker.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -32
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,34 @@ All notable changes to the AdMesh UI SDK will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.19.22] - 2025-10-27
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **TEMPORARY: Global analytics disable flag** - `disableViewabilityAnalytics()`
|
|
12
|
+
- Allows temporary disabling of all viewability analytics sending
|
|
13
|
+
- Prevents any API calls to backend while keeping tracking logic intact
|
|
14
|
+
- Useful for development, testing, and debugging
|
|
15
|
+
- Easy to toggle on/off without code changes
|
|
16
|
+
- Fails silently with optional debug logging
|
|
17
|
+
|
|
18
|
+
### Usage
|
|
19
|
+
```typescript
|
|
20
|
+
import { disableViewabilityAnalytics } from 'admesh-ui-sdk';
|
|
21
|
+
|
|
22
|
+
// Disable all analytics
|
|
23
|
+
disableViewabilityAnalytics(true);
|
|
24
|
+
|
|
25
|
+
// Re-enable analytics
|
|
26
|
+
disableViewabilityAnalytics(false);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Implementation
|
|
30
|
+
- Added global `ANALYTICS_DISABLED` flag
|
|
31
|
+
- Check in `sendEvent()` to skip event sending
|
|
32
|
+
- Check in `flushBatch()` to clear queued events
|
|
33
|
+
- Console warnings when toggled
|
|
34
|
+
- No breaking changes, fully backward compatible
|
|
35
|
+
|
|
8
36
|
## [0.19.21] - 2025-10-27
|
|
9
37
|
|
|
10
38
|
### Changed
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { ViewabilityTrackerConfig, ViewabilityTrackerState } from '../types/analytics';
|
|
2
2
|
export declare const setViewabilityTrackerConfig: (config: Partial<ViewabilityTrackerConfig>) => void;
|
|
3
|
+
/**
|
|
4
|
+
* TEMPORARY: Disable/enable all viewability analytics sending
|
|
5
|
+
* @param disabled - Set to true to disable analytics, false to enable
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* disableViewabilityAnalytics(true); // Disable all analytics
|
|
9
|
+
* disableViewabilityAnalytics(false); // Re-enable analytics
|
|
10
|
+
*/
|
|
11
|
+
export declare const disableViewabilityAnalytics: (disabled: boolean) => void;
|
|
3
12
|
interface UseViewabilityTrackerProps {
|
|
4
13
|
/** Ad ID */
|
|
5
14
|
adId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useViewabilityTracker.d.ts","sourceRoot":"","sources":["../../src/hooks/useViewabilityTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EAIxB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"useViewabilityTracker.d.ts","sourceRoot":"","sources":["../../src/hooks/useViewabilityTracker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EAIxB,MAAM,oBAAoB,CAAC;AAuC5B,eAAO,MAAM,2BAA2B,GAAI,QAAQ,OAAO,CAAC,wBAAwB,CAAC,SAEpF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GAAI,UAAU,OAAO,SAO5D,CAAC;AAEF,UAAU,0BAA0B;IAClC,YAAY;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,4BAA4B;IAC5B,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACzC,2BAA2B;IAC3B,MAAM,CAAC,EAAE,OAAO,CAAC,wBAAwB,CAAC,CAAC;CAC5C;AAED,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,SAAS,EACT,OAAO,EACP,OAAO,EACP,gBAAgB,EAChB,UAAU,EACV,MAAM,EAAE,YAAY,EACrB,EAAE,0BAA0B,GAAG,uBAAuB,CA8ZtD"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var le=Object.defineProperty;var me=(t,e,r)=>e in t?le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var S=(t,e,r)=>me(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),ue=require("react-dom/client"),x=require("react");function he(t,e,r){const i=t*e>242500;return{...{visibilityThreshold:i?.3:.5,minimumDuration:1e3,isLargeAd:i},...r}}function pe(t){return t<768?"mobile":t<1024?"tablet":"desktop"}function ge(t){const e=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,s=window.innerWidth||document.documentElement.clientWidth,i=e.height,o=e.width;if(i===0||o===0)return 0;const d=Math.max(0,e.top),n=Math.min(r,e.bottom),l=Math.max(0,e.left),m=Math.min(s,e.right),p=Math.max(0,n-d),h=Math.max(0,m-l),u=p*h,g=i*o;return g>0?u/g:0}function K(){const t=window.innerHeight,e=document.documentElement.scrollHeight,r=window.pageYOffset||document.documentElement.scrollTop,s=e-t;return s<=0?100:Math.min(100,r/s*100)}function fe(t){const e=t.getBoundingClientRect(),r=window.pageYOffset||document.documentElement.scrollTop,s=window.pageXOffset||document.documentElement.scrollLeft;return{top:e.top+r,left:e.left+s}}function be(t){const e=t.getBoundingClientRect(),r=fe(t),s=window.innerWidth||document.documentElement.clientWidth,i=window.innerHeight||document.documentElement.clientHeight,o=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;return{pageUrl:window.location.href,pageTitle:document.title,referrer:document.referrer,deviceType:pe(s),viewportWidth:s,viewportHeight:i,adWidth:e.width,adHeight:e.height,adPositionTop:r.top,adPositionLeft:r.left,isDarkMode:o,language:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}}function xe(){return`session_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}function ye(){return`batch_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}function we(t,e,r){return t>=r.visibilityThreshold&&e>=r.minimumDuration}function B(t=new Date){return t.toISOString()}function ke(t){return t.length===0?0:t.reduce((r,s)=>r+s,0)/t.length}function Y(t,e){let r;return function(...i){r||(t(...i),r=!0,setTimeout(()=>r=!1,e))}}async function ve(t,e,r=3,s=1e3){if(!e||e.trim()==="")return!0;let i=null;for(let o=0;o<r;o++){try{const d=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:!0});if(d.ok)return!0;const n=await d.text().catch(()=>"");i=new Error(`HTTP ${d.status}: ${d.statusText} - ${n}`)}catch(d){i=d}o<r-1&&await new Promise(d=>setTimeout(d,s*Math.pow(2,o)))}return console.error("[AdMesh Viewability] Failed to send analytics event:",i),!1}async function _e(t,e,r,s=3,i=1e3){if(t.length===0||!r||r.trim()==="")return!0;const o={batchId:ye(),sessionId:e,createdAt:B(),events:t,eventCount:t.length};let d=null;for(let n=0;n<s;n++){try{const l=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),keepalive:!0});if(l.ok)return!0;const m=await l.text().catch(()=>"");d=new Error(`HTTP ${l.status}: ${l.statusText} - ${m}`)}catch(l){d=l}n<s-1&&await new Promise(l=>setTimeout(l,i*Math.pow(2,n)))}return console.error("[AdMesh Viewability] Failed to send analytics batch:",d),!1}const Me={enabled:!0,apiEndpoint:"https://api.useadmesh.com/api/recommendations/viewability/batch",enableBatching:!0,batchSize:10,batchTimeout:5e3,debug:!1,enableRetry:!0,maxRetries:3,retryDelay:1e3};let Se=Me;function Z({adId:t,productId:e,offerId:r,agentId:s,recommendationId:i,elementRef:o,config:d}){const n={...Se,...d},l=x.useRef(xe()),[m,p]=x.useState({isVisible:!1,isViewable:!1,visibilityPercentage:0,timeMetrics:{loadedAt:B(),totalVisibleDuration:0,totalViewableDuration:0,totalHoverDuration:0,totalFocusDuration:0},engagementMetrics:{currentScrollDepth:0,viewportEnterCount:0,viewportExitCount:0,hoverCount:0,wasClicked:!1,maxVisibilityPercentage:0,averageVisibilityPercentage:0},isTracking:n.enabled}),h=x.useRef(null),u=x.useRef(null),g=x.useRef(null),b=x.useRef(null),w=x.useRef(null),_=x.useRef([]),A=x.useRef([]),T=x.useRef(null),E=x.useCallback((f,c)=>{n.debug&&console.log(`[AdMesh Viewability] ${f}`,c)},[n.debug]),M=x.useCallback(async(f,c)=>{if(!n.enabled||!o.current||!h.current)return;if(!["ad_viewable","ad_click"].includes(f)){E(`Skipping non-critical event: ${f} (only ad_viewable and ad_click are sent)`);return}const v=be(o.current),y={eventType:f,timestamp:B(),sessionId:l.current,adId:t,productId:e,offerId:r,agentId:s,recommendationId:i,timeMetrics:m.timeMetrics,engagementMetrics:m.engagementMetrics,contextMetrics:v,mrcStandards:h.current,isViewable:m.isViewable,metadata:c};E(`Sending critical event: ${f}`,y),n.onEvent&&n.onEvent(y),n.enableBatching?(A.current.push(y),A.current.length>=n.batchSize?await N():(T.current&&clearTimeout(T.current),T.current=setTimeout(N,n.batchTimeout))):await ve(y,n.apiEndpoint,n.maxRetries,n.retryDelay)},[n,t,e,r,s,o,m,E]),N=x.useCallback(async()=>{if(A.current.length===0)return;const f=[...A.current];A.current=[],T.current&&(clearTimeout(T.current),T.current=null),await _e(f,l.current,n.apiEndpoint,n.maxRetries,n.retryDelay)&&n.onBatchSent&&n.onBatchSent({batchId:`batch_${Date.now()}`,sessionId:l.current,createdAt:B(),events:f,eventCount:f.length})},[n]),L=x.useCallback(Y(()=>{if(!o.current)return;const f=ge(o.current),c=Date.now(),k=new Date(m.timeMetrics.loadedAt).getTime();p(v=>{const y={...v};f>0&&_.current.push(f);const C=v.isVisible,j=f>0;if(j&&!C)u.current=c,y.engagementMetrics.viewportEnterCount++,y.timeMetrics.timeToFirstVisible||(y.timeMetrics.timeToFirstVisible=c-k,y.engagementMetrics.scrollDepthAtFirstVisible=K(),M("ad_visible"));else if(!j&&C){if(u.current){const D=c-u.current;y.timeMetrics.totalVisibleDuration+=D,u.current=null}y.engagementMetrics.viewportExitCount++,M("ad_hidden")}else if(j&&C&&u.current){const D=c-u.current;y.timeMetrics.totalVisibleDuration+=D,u.current=c}if(y.isVisible=j,y.visibilityPercentage=f,f>y.engagementMetrics.maxVisibilityPercentage&&(y.engagementMetrics.maxVisibilityPercentage=f),_.current.length>0&&(y.engagementMetrics.averageVisibilityPercentage=ke(_.current)),h.current){const D=v.isViewable,z=we(f,y.timeMetrics.totalVisibleDuration,h.current);if(z&&!D)y.isViewable=!0,y.timeMetrics.timeToViewable=c-k,g.current=c,M("ad_viewable");else if(z&&D&&g.current){const I=c-g.current;y.timeMetrics.totalViewableDuration+=I,g.current=c}}return y.engagementMetrics.currentScrollDepth=K(),y})},100),[o,m.timeMetrics.loadedAt,M]);return x.useEffect(()=>{if(!o.current)return;const f=o.current.getBoundingClientRect();h.current=he(f.width,f.height,n.mrcStandards),E("Initialized MRC standards",h.current),M("ad_loaded")},[o,n.mrcStandards,E,M]),x.useEffect(()=>{if(!n.enabled||!o.current)return;const f=new IntersectionObserver(c=>{c.forEach(()=>{L()})},{threshold:[0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1],rootMargin:"0px"});return f.observe(o.current),()=>{f.disconnect()}},[n.enabled,o,L]),x.useEffect(()=>{if(!n.enabled)return;const f=Y(()=>{L()},100);return window.addEventListener("scroll",f,{passive:!0}),()=>window.removeEventListener("scroll",f)},[n.enabled,L]),x.useEffect(()=>{if(!n.enabled||!o.current)return;const f=o.current,c=()=>{b.current=Date.now(),p(v=>({...v,engagementMetrics:{...v.engagementMetrics,hoverCount:v.engagementMetrics.hoverCount+1}})),M("ad_hover_start")},k=()=>{if(b.current){const v=Date.now()-b.current;p(y=>({...y,timeMetrics:{...y.timeMetrics,totalHoverDuration:y.timeMetrics.totalHoverDuration+v}})),b.current=null,M("ad_hover_end",{hoverDuration:v})}};return f.addEventListener("mouseenter",c),f.addEventListener("mouseleave",k),()=>{f.removeEventListener("mouseenter",c),f.removeEventListener("mouseleave",k)}},[n.enabled,o,M]),x.useEffect(()=>{if(!n.enabled||!o.current)return;const f=o.current,c=()=>{w.current=Date.now(),M("ad_focus")},k=()=>{if(w.current){const v=Date.now()-w.current;p(y=>({...y,timeMetrics:{...y.timeMetrics,totalFocusDuration:y.timeMetrics.totalFocusDuration+v}})),w.current=null,M("ad_blur",{focusDuration:v})}};return f.addEventListener("focus",c),f.addEventListener("blur",k),()=>{f.removeEventListener("focus",c),f.removeEventListener("blur",k)}},[n.enabled,o,M]),x.useEffect(()=>{if(!n.enabled||!o.current)return;const f=o.current,c=()=>{p(k=>({...k,engagementMetrics:{...k.engagementMetrics,wasClicked:!0}})),M("ad_click")};return f.addEventListener("click",c),()=>{f.removeEventListener("click",c)}},[n.enabled,o,M]),x.useEffect(()=>()=>{const f=Date.now(),c=new Date(m.timeMetrics.loadedAt).getTime(),k=f-c;p(v=>({...v,timeMetrics:{...v.timeMetrics,sessionDuration:k}})),M("ad_unloaded",{sessionDuration:k}),N()},[]),m}const P=({adId:t,productId:e,offerId:r,agentId:s,children:i,config:o,className:d,style:n,onViewabilityChange:l,onVisible:m,onViewable:p,onClick:h})=>{const u=x.useRef(null),g=Z({adId:t,productId:e,offerId:r,agentId:s,elementRef:u,config:o}),b=x.useRef(g.isViewable);x.useEffect(()=>{g.isViewable!==b.current&&(b.current=g.isViewable,l&&l(g.isViewable),g.isViewable&&p&&p())},[g.isViewable,l,p]);const w=x.useRef(g.isVisible);x.useEffect(()=>{g.isVisible!==w.current&&(w.current=g.isVisible,g.isVisible&&m&&m())},[g.isVisible,m]);const _=()=>{h&&h()};return a.jsx("div",{ref:u,className:d,style:n,onClick:_,"data-admesh-viewability-tracker":!0,"data-ad-id":t,"data-is-viewable":g.isViewable,"data-is-visible":g.isVisible,"data-visibility-percentage":g.visibilityPercentage.toFixed(2),children:i})};P.displayName="AdMeshViewabilityTracker";const je=t=>{try{return new URL(t),!0}catch{return!1}},G=(t,e)=>{const r=new Map,s=new Map;e.forEach(m=>{m.admesh_link&&r.set(m.admesh_link,m),m.click_url&&s.set(m.click_url,m)}),console.log("[AdMesh Summary] Processing recommendations:",{totalRecommendations:e.length,recommendationFields:e.map(m=>({ad_id:m.ad_id,click_url:m.click_url,admesh_link:m.admesh_link,title:m.title||m.recommendation_title}))}),r.size>0||s.size>0?console.log("[AdMesh Summary] Available recommendation links:",{admesh_links:Array.from(r.keys()),click_urls:Array.from(s.keys())}):console.warn("[AdMesh Summary] No click_url or admesh_link found in recommendations!");const i=/\[([^\]]+)\]\(([^)]+)\)/g,o=[];let d=0,n,l=0;for(;(n=i.exec(t))!==null;){const[m,p,h]=n;console.log("[AdMesh Summary] Processing markdown link:",{linkText:p,url:h,urlLength:h.length});let u=r.get(h)||s.get(h);if(console.log("[AdMesh Summary] URL match result:",{found:!!u,matchedBy:u?"exact_match":"none"}),u||(u=e.find(g=>g.ad_id&&h.includes(g.ad_id)),u&&console.log("[AdMesh Summary] Found by ad_id match")),n.index>d&&o.push(t.slice(d,n.index)),u){l++;const g=h||u.click_url||u.admesh_link;o.push(a.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 underline decoration-blue-600 dark:decoration-blue-400 hover:decoration-blue-800 dark:hover:decoration-blue-300 transition-colors duration-200 font-medium",style:{color:"#2563eb",textDecoration:"underline",textDecorationColor:"#2563eb",textUnderlineOffset:"2px"},onClick:()=>{console.log("AdMesh summary link clicked:",{adId:u.ad_id,productId:u.product_id,title:u.title||u.recommendation_title,brand:u.brand,pricing:u.pricing,clickUrl:u.click_url,admeshLink:u.admesh_link,source:"summary"}),typeof window<"u"&&window.admeshTracker&&window.admeshTracker.trackClick({adId:u.ad_id,productId:u.product_id,clickUrl:u.click_url,admeshLink:u.admesh_link,source:"summary"}).catch(b=>{console.error("[AdMesh] Failed to track summary link click:",b)})},children:p},`summary-link-${l}`))}else console.warn(`[AdMesh Summary] No recommendation found for link: [${p}](${h}), creating regular link`,{availableLinks:Array.from(r.keys()),totalRecommendations:e.length,urlToMatch:h}),je(h)?(l++,o.push(a.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 underline decoration-blue-600 dark:decoration-blue-400 hover:decoration-blue-800 dark:hover:decoration-blue-300 transition-colors duration-200 font-medium",style:{color:"#2563eb",textDecoration:"underline",textDecorationColor:"#2563eb",textUnderlineOffset:"2px"},onClick:()=>{console.log("AdMesh summary unmatched link clicked:",{linkText:p,url:h,source:"summary"}),typeof window<"u"&&window.admeshTracker&&window.admeshTracker.trackClick({url:h,linkText:p,source:"summary_unmatched"}).catch(g=>{console.error("[AdMesh] Failed to track unmatched link click:",g)})},children:p},`summary-link-${l}`))):(console.warn(`[AdMesh Summary] Invalid URL in markdown link: [${p}](${h})`),o.push(p));d=n.index+m.length}return d<t.length&&o.push(t.slice(d)),o},q=({summaryText:t,recommendations:e,theme:r,className:s="",style:i={}})=>{var n,l,m;if(!t||!t.trim())return console.warn("[AdMesh Summary] No summary text provided"),null;if(!e||e.length===0){console.warn("[AdMesh Summary] No recommendations provided");const p=G(t,[]);return a.jsx("div",{className:`admesh-summary-unit ${s}`,style:i,children:a.jsx("p",{className:"text-gray-700 dark:text-gray-300 leading-relaxed",children:p.map((h,u)=>a.jsx(x.Fragment,{children:h},u))})})}const o=G(t,e),d=((l=(n=e[0])==null?void 0:n.meta)==null?void 0:l.ad_id)||((m=e[0])==null?void 0:m.ad_id)||"";return a.jsx(P,{adId:d,className:`admesh-summary-unit ${s}`,style:{fontFamily:(r==null?void 0:r.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...i},children:a.jsxs("div",{children:[a.jsx("div",{className:"summary-content",children:a.jsx("p",{className:"text-gray-700 dark:text-gray-300 leading-relaxed text-base",children:o.map((p,h)=>a.jsx(x.Fragment,{children:p},h))})}),a.jsx("div",{className:"mt-3 pt-2 border-t border-gray-200 dark:border-gray-700",children:a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Sponsored"})})]})})};function Ae(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var U={exports:{}};/*!
|
|
1
|
+
"use strict";var le=Object.defineProperty;var me=(t,e,r)=>e in t?le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var S=(t,e,r)=>me(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),ue=require("react-dom/client"),x=require("react");function he(t,e,r){const i=t*e>242500;return{...{visibilityThreshold:i?.3:.5,minimumDuration:1e3,isLargeAd:i},...r}}function pe(t){return t<768?"mobile":t<1024?"tablet":"desktop"}function ge(t){const e=t.getBoundingClientRect(),r=window.innerHeight||document.documentElement.clientHeight,s=window.innerWidth||document.documentElement.clientWidth,i=e.height,o=e.width;if(i===0||o===0)return 0;const d=Math.max(0,e.top),n=Math.min(r,e.bottom),l=Math.max(0,e.left),m=Math.min(s,e.right),p=Math.max(0,n-d),h=Math.max(0,m-l),u=p*h,g=i*o;return g>0?u/g:0}function K(){const t=window.innerHeight,e=document.documentElement.scrollHeight,r=window.pageYOffset||document.documentElement.scrollTop,s=e-t;return s<=0?100:Math.min(100,r/s*100)}function fe(t){const e=t.getBoundingClientRect(),r=window.pageYOffset||document.documentElement.scrollTop,s=window.pageXOffset||document.documentElement.scrollLeft;return{top:e.top+r,left:e.left+s}}function be(t){const e=t.getBoundingClientRect(),r=fe(t),s=window.innerWidth||document.documentElement.clientWidth,i=window.innerHeight||document.documentElement.clientHeight,o=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;return{pageUrl:window.location.href,pageTitle:document.title,referrer:document.referrer,deviceType:pe(s),viewportWidth:s,viewportHeight:i,adWidth:e.width,adHeight:e.height,adPositionTop:r.top,adPositionLeft:r.left,isDarkMode:o,language:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}}function xe(){return`session_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}function ye(){return`batch_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}function we(t,e,r){return t>=r.visibilityThreshold&&e>=r.minimumDuration}function B(t=new Date){return t.toISOString()}function ke(t){return t.length===0?0:t.reduce((r,s)=>r+s,0)/t.length}function Y(t,e){let r;return function(...i){r||(t(...i),r=!0,setTimeout(()=>r=!1,e))}}async function ve(t,e,r=3,s=1e3){if(!e||e.trim()==="")return!0;let i=null;for(let o=0;o<r;o++){try{const d=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:!0});if(d.ok)return!0;const n=await d.text().catch(()=>"");i=new Error(`HTTP ${d.status}: ${d.statusText} - ${n}`)}catch(d){i=d}o<r-1&&await new Promise(d=>setTimeout(d,s*Math.pow(2,o)))}return console.error("[AdMesh Viewability] Failed to send analytics event:",i),!1}async function _e(t,e,r,s=3,i=1e3){if(t.length===0||!r||r.trim()==="")return!0;const o={batchId:ye(),sessionId:e,createdAt:B(),events:t,eventCount:t.length};let d=null;for(let n=0;n<s;n++){try{const l=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o),keepalive:!0});if(l.ok)return!0;const m=await l.text().catch(()=>"");d=new Error(`HTTP ${l.status}: ${l.statusText} - ${m}`)}catch(l){d=l}n<s-1&&await new Promise(l=>setTimeout(l,i*Math.pow(2,n)))}return console.error("[AdMesh Viewability] Failed to send analytics batch:",d),!1}const Me={enabled:!0,apiEndpoint:"https://api.useadmesh.com/api/recommendations/viewability/batch",enableBatching:!0,batchSize:10,batchTimeout:5e3,debug:!1,enableRetry:!1,maxRetries:3,retryDelay:1e3};let Se=Me;function Z({adId:t,productId:e,offerId:r,agentId:s,recommendationId:i,elementRef:o,config:d}){const n={...Se,...d},l=x.useRef(xe()),[m,p]=x.useState({isVisible:!1,isViewable:!1,visibilityPercentage:0,timeMetrics:{loadedAt:B(),totalVisibleDuration:0,totalViewableDuration:0,totalHoverDuration:0,totalFocusDuration:0},engagementMetrics:{currentScrollDepth:0,viewportEnterCount:0,viewportExitCount:0,hoverCount:0,wasClicked:!1,maxVisibilityPercentage:0,averageVisibilityPercentage:0},isTracking:n.enabled}),h=x.useRef(null),u=x.useRef(null),g=x.useRef(null),b=x.useRef(null),w=x.useRef(null),_=x.useRef([]),A=x.useRef([]),T=x.useRef(null),C=x.useCallback((f,c)=>{n.debug&&console.log(`[AdMesh Viewability] ${f}`,c)},[n.debug]),M=x.useCallback(async(f,c)=>{if(!n.enabled||!o.current||!h.current)return;if(!["ad_viewable","ad_click"].includes(f)){C(`Skipping non-critical event: ${f} (only ad_viewable and ad_click are sent)`);return}const v=be(o.current),y={eventType:f,timestamp:B(),sessionId:l.current,adId:t,productId:e,offerId:r,agentId:s,recommendationId:i,timeMetrics:m.timeMetrics,engagementMetrics:m.engagementMetrics,contextMetrics:v,mrcStandards:h.current,isViewable:m.isViewable,metadata:c};C(`Sending critical event: ${f}`,y),n.onEvent&&n.onEvent(y),n.enableBatching?(A.current.push(y),A.current.length>=n.batchSize?await N():(T.current&&clearTimeout(T.current),T.current=setTimeout(N,n.batchTimeout))):await ve(y,n.apiEndpoint,n.maxRetries,n.retryDelay)},[n,t,e,r,s,o,m,C]),N=x.useCallback(async()=>{if(A.current.length===0)return;const f=[...A.current];A.current=[],T.current&&(clearTimeout(T.current),T.current=null),await _e(f,l.current,n.apiEndpoint,n.maxRetries,n.retryDelay)&&n.onBatchSent&&n.onBatchSent({batchId:`batch_${Date.now()}`,sessionId:l.current,createdAt:B(),events:f,eventCount:f.length})},[n,C]),L=x.useCallback(Y(()=>{if(!o.current)return;const f=ge(o.current),c=Date.now(),k=new Date(m.timeMetrics.loadedAt).getTime();p(v=>{const y={...v};f>0&&_.current.push(f);const E=v.isVisible,j=f>0;if(j&&!E)u.current=c,y.engagementMetrics.viewportEnterCount++,y.timeMetrics.timeToFirstVisible||(y.timeMetrics.timeToFirstVisible=c-k,y.engagementMetrics.scrollDepthAtFirstVisible=K(),M("ad_visible"));else if(!j&&E){if(u.current){const D=c-u.current;y.timeMetrics.totalVisibleDuration+=D,u.current=null}y.engagementMetrics.viewportExitCount++,M("ad_hidden")}else if(j&&E&&u.current){const D=c-u.current;y.timeMetrics.totalVisibleDuration+=D,u.current=c}if(y.isVisible=j,y.visibilityPercentage=f,f>y.engagementMetrics.maxVisibilityPercentage&&(y.engagementMetrics.maxVisibilityPercentage=f),_.current.length>0&&(y.engagementMetrics.averageVisibilityPercentage=ke(_.current)),h.current){const D=v.isViewable,z=we(f,y.timeMetrics.totalVisibleDuration,h.current);if(z&&!D)y.isViewable=!0,y.timeMetrics.timeToViewable=c-k,g.current=c,M("ad_viewable");else if(z&&D&&g.current){const I=c-g.current;y.timeMetrics.totalViewableDuration+=I,g.current=c}}return y.engagementMetrics.currentScrollDepth=K(),y})},100),[o,m.timeMetrics.loadedAt,M]);return x.useEffect(()=>{if(!o.current)return;const f=o.current.getBoundingClientRect();h.current=he(f.width,f.height,n.mrcStandards),C("Initialized MRC standards",h.current),M("ad_loaded")},[o,n.mrcStandards,C,M]),x.useEffect(()=>{if(!n.enabled||!o.current)return;const f=new IntersectionObserver(c=>{c.forEach(()=>{L()})},{threshold:[0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1],rootMargin:"0px"});return f.observe(o.current),()=>{f.disconnect()}},[n.enabled,o,L]),x.useEffect(()=>{if(!n.enabled)return;const f=Y(()=>{L()},100);return window.addEventListener("scroll",f,{passive:!0}),()=>window.removeEventListener("scroll",f)},[n.enabled,L]),x.useEffect(()=>{if(!n.enabled||!o.current)return;const f=o.current,c=()=>{b.current=Date.now(),p(v=>({...v,engagementMetrics:{...v.engagementMetrics,hoverCount:v.engagementMetrics.hoverCount+1}})),M("ad_hover_start")},k=()=>{if(b.current){const v=Date.now()-b.current;p(y=>({...y,timeMetrics:{...y.timeMetrics,totalHoverDuration:y.timeMetrics.totalHoverDuration+v}})),b.current=null,M("ad_hover_end",{hoverDuration:v})}};return f.addEventListener("mouseenter",c),f.addEventListener("mouseleave",k),()=>{f.removeEventListener("mouseenter",c),f.removeEventListener("mouseleave",k)}},[n.enabled,o,M]),x.useEffect(()=>{if(!n.enabled||!o.current)return;const f=o.current,c=()=>{w.current=Date.now(),M("ad_focus")},k=()=>{if(w.current){const v=Date.now()-w.current;p(y=>({...y,timeMetrics:{...y.timeMetrics,totalFocusDuration:y.timeMetrics.totalFocusDuration+v}})),w.current=null,M("ad_blur",{focusDuration:v})}};return f.addEventListener("focus",c),f.addEventListener("blur",k),()=>{f.removeEventListener("focus",c),f.removeEventListener("blur",k)}},[n.enabled,o,M]),x.useEffect(()=>{if(!n.enabled||!o.current)return;const f=o.current,c=()=>{p(k=>({...k,engagementMetrics:{...k.engagementMetrics,wasClicked:!0}})),M("ad_click")};return f.addEventListener("click",c),()=>{f.removeEventListener("click",c)}},[n.enabled,o,M]),x.useEffect(()=>()=>{const f=Date.now(),c=new Date(m.timeMetrics.loadedAt).getTime(),k=f-c;p(v=>({...v,timeMetrics:{...v.timeMetrics,sessionDuration:k}})),M("ad_unloaded",{sessionDuration:k}),N()},[]),m}const P=({adId:t,productId:e,offerId:r,agentId:s,children:i,config:o,className:d,style:n,onViewabilityChange:l,onVisible:m,onViewable:p,onClick:h})=>{const u=x.useRef(null),g=Z({adId:t,productId:e,offerId:r,agentId:s,elementRef:u,config:o}),b=x.useRef(g.isViewable);x.useEffect(()=>{g.isViewable!==b.current&&(b.current=g.isViewable,l&&l(g.isViewable),g.isViewable&&p&&p())},[g.isViewable,l,p]);const w=x.useRef(g.isVisible);x.useEffect(()=>{g.isVisible!==w.current&&(w.current=g.isVisible,g.isVisible&&m&&m())},[g.isVisible,m]);const _=()=>{h&&h()};return a.jsx("div",{ref:u,className:d,style:n,onClick:_,"data-admesh-viewability-tracker":!0,"data-ad-id":t,"data-is-viewable":g.isViewable,"data-is-visible":g.isVisible,"data-visibility-percentage":g.visibilityPercentage.toFixed(2),children:i})};P.displayName="AdMeshViewabilityTracker";const je=t=>{try{return new URL(t),!0}catch{return!1}},G=(t,e)=>{const r=new Map,s=new Map;e.forEach(m=>{m.admesh_link&&r.set(m.admesh_link,m),m.click_url&&s.set(m.click_url,m)}),console.log("[AdMesh Summary] Processing recommendations:",{totalRecommendations:e.length,recommendationFields:e.map(m=>({ad_id:m.ad_id,click_url:m.click_url,admesh_link:m.admesh_link,title:m.title||m.recommendation_title}))}),r.size>0||s.size>0?console.log("[AdMesh Summary] Available recommendation links:",{admesh_links:Array.from(r.keys()),click_urls:Array.from(s.keys())}):console.warn("[AdMesh Summary] No click_url or admesh_link found in recommendations!");const i=/\[([^\]]+)\]\(([^)]+)\)/g,o=[];let d=0,n,l=0;for(;(n=i.exec(t))!==null;){const[m,p,h]=n;console.log("[AdMesh Summary] Processing markdown link:",{linkText:p,url:h,urlLength:h.length});let u=r.get(h)||s.get(h);if(console.log("[AdMesh Summary] URL match result:",{found:!!u,matchedBy:u?"exact_match":"none"}),u||(u=e.find(g=>g.ad_id&&h.includes(g.ad_id)),u&&console.log("[AdMesh Summary] Found by ad_id match")),n.index>d&&o.push(t.slice(d,n.index)),u){l++;const g=h||u.click_url||u.admesh_link;o.push(a.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 underline decoration-blue-600 dark:decoration-blue-400 hover:decoration-blue-800 dark:hover:decoration-blue-300 transition-colors duration-200 font-medium",style:{color:"#2563eb",textDecoration:"underline",textDecorationColor:"#2563eb",textUnderlineOffset:"2px"},onClick:()=>{console.log("AdMesh summary link clicked:",{adId:u.ad_id,productId:u.product_id,title:u.title||u.recommendation_title,brand:u.brand,pricing:u.pricing,clickUrl:u.click_url,admeshLink:u.admesh_link,source:"summary"}),typeof window<"u"&&window.admeshTracker&&window.admeshTracker.trackClick({adId:u.ad_id,productId:u.product_id,clickUrl:u.click_url,admeshLink:u.admesh_link,source:"summary"}).catch(b=>{console.error("[AdMesh] Failed to track summary link click:",b)})},children:p},`summary-link-${l}`))}else console.warn(`[AdMesh Summary] No recommendation found for link: [${p}](${h}), creating regular link`,{availableLinks:Array.from(r.keys()),totalRecommendations:e.length,urlToMatch:h}),je(h)?(l++,o.push(a.jsx("a",{href:h,target:"_blank",rel:"noopener noreferrer",className:"text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 underline decoration-blue-600 dark:decoration-blue-400 hover:decoration-blue-800 dark:hover:decoration-blue-300 transition-colors duration-200 font-medium",style:{color:"#2563eb",textDecoration:"underline",textDecorationColor:"#2563eb",textUnderlineOffset:"2px"},onClick:()=>{console.log("AdMesh summary unmatched link clicked:",{linkText:p,url:h,source:"summary"}),typeof window<"u"&&window.admeshTracker&&window.admeshTracker.trackClick({url:h,linkText:p,source:"summary_unmatched"}).catch(g=>{console.error("[AdMesh] Failed to track unmatched link click:",g)})},children:p},`summary-link-${l}`))):(console.warn(`[AdMesh Summary] Invalid URL in markdown link: [${p}](${h})`),o.push(p));d=n.index+m.length}return d<t.length&&o.push(t.slice(d)),o},q=({summaryText:t,recommendations:e,theme:r,className:s="",style:i={}})=>{var n,l,m;if(!t||!t.trim())return console.warn("[AdMesh Summary] No summary text provided"),null;if(!e||e.length===0){console.warn("[AdMesh Summary] No recommendations provided");const p=G(t,[]);return a.jsx("div",{className:`admesh-summary-unit ${s}`,style:i,children:a.jsx("p",{className:"text-gray-700 dark:text-gray-300 leading-relaxed",children:p.map((h,u)=>a.jsx(x.Fragment,{children:h},u))})})}const o=G(t,e),d=((l=(n=e[0])==null?void 0:n.meta)==null?void 0:l.ad_id)||((m=e[0])==null?void 0:m.ad_id)||"";return a.jsx(P,{adId:d,className:`admesh-summary-unit ${s}`,style:{fontFamily:(r==null?void 0:r.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...i},children:a.jsxs("div",{children:[a.jsx("div",{className:"summary-content",children:a.jsx("p",{className:"text-gray-700 dark:text-gray-300 leading-relaxed text-base",children:o.map((p,h)=>a.jsx(x.Fragment,{children:p},h))})}),a.jsx("div",{className:"mt-3 pt-2 border-t border-gray-200 dark:border-gray-700",children:a.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Sponsored"})})]})})};function Ae(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var U={exports:{}};/*!
|
|
2
2
|
Copyright (c) 2018 Jed Watson.
|
|
3
3
|
Licensed under the MIT License (MIT), see
|
|
4
4
|
http://jedwatson.github.io/classnames
|
|
@@ -970,7 +970,7 @@
|
|
|
970
970
|
.admesh-component .lg\\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
971
971
|
.admesh-component .lg\\:col-span-1 { grid-column: span 1 / span 1; }
|
|
972
972
|
}
|
|
973
|
-
`;let Q=!1;const te=()=>{x.useEffect(()=>{if(!Q){try{Ie();const t=document.createElement("style");t.id="admesh-ui-sdk-styles-legacy",t.textContent=Fe,document.getElementById("admesh-ui-sdk-styles-legacy")||document.head.appendChild(t),Q=!0}catch(t){console.error("[AdMesh] Failed to inject styles:",t)}return()=>{}}},[])},$=(t,e={})=>{const r=t.intent_match_score||0,s=e.customLabels||{};return r>=.8?s.partnerRecommendation||"Smart Pick":r>=.6?s.partnerMatch||"Partner Recommendation":r>=.3?s.promotedOption||"Promoted Match":s.relatedOption||"Related"},X=(t,e)=>{const r=t.intent_match_score||0;return r>=.8?"This recommendation is from a partner who compensates us when you engage. We've matched it to your needs based on your query.":r>=.6?"Top-rated partner solution matched to your specific requirements. Partner compensates us for qualified referrals.":r>=.3?"This partner solution may be relevant to your needs. The partner compensates us when you take qualifying actions.":"This solution is somewhat related to your query. While not a perfect match, it might still be helpful. This partner compensates us for qualified referrals."},R=({recommendation:t,theme:e,showFeatures:r=!1,variation:s="default",className:i,style:o})=>{var u,g,b,w,_,A,T,E,M,N,L,f,c,k,v,y,C,j,D,z;te();const n=s==="simple"?{title:t.recommendation_title||t.title,description:t.recommendation_description||t.description||t.reason,ctaText:t.recommendation_title||t.title,isSimple:!0}:{title:t.recommendation_title||t.title,description:t.recommendation_description||t.description||t.reason,ctaText:t.recommendation_title||t.title},l=F("admesh-component","admesh-card","relative p-3 sm:p-4 rounded-xl bg-gradient-to-br from-white to-gray-50 dark:from-slate-800 dark:to-slate-900 border border-gray-200/50 dark:border-slate-700/50 shadow-lg hover:shadow-xl transition-all duration-300 hover:-translate-y-1",i),m=e?{"--admesh-primary":e.primaryColor||e.accentColor||"#3b82f6","--admesh-secondary":e.secondaryColor||"#10b981","--admesh-accent":e.accentColor||"#3b82f6","--admesh-background":e.backgroundColor,"--admesh-surface":e.surfaceColor,"--admesh-border":e.borderColor,"--admesh-text":e.textColor,"--admesh-text-secondary":e.textSecondaryColor,"--admesh-radius":e.borderRadius||"12px","--admesh-shadow-sm":(u=e.shadows)==null?void 0:u.small,"--admesh-shadow-md":(g=e.shadows)==null?void 0:g.medium,"--admesh-shadow-lg":(b=e.shadows)==null?void 0:b.large,"--admesh-spacing-sm":(w=e.spacing)==null?void 0:w.small,"--admesh-spacing-md":(_=e.spacing)==null?void 0:_.medium,"--admesh-spacing-lg":(A=e.spacing)==null?void 0:A.large,"--admesh-font-size-sm":(T=e.fontSize)==null?void 0:T.small,"--admesh-font-size-base":(E=e.fontSize)==null?void 0:E.base,"--admesh-font-size-lg":(M=e.fontSize)==null?void 0:M.large,"--admesh-font-size-title":(N=e.fontSize)==null?void 0:N.title,fontFamily:e.fontFamily,width:((f=(L=e.components)==null?void 0:L.productCard)==null?void 0:f.width)||"100%"}:{width:"100%"};if(s==="simple"){const I=((c=t.meta)==null?void 0:c.ad_id)||t.ad_id||"",O=t.product_id||"";return a.jsx(P,{adId:I,productId:O,className:F("admesh-component admesh-simple-ad","inline-block text-sm leading-relaxed",i),style:{fontFamily:(e==null?void 0:e.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(k=e==null?void 0:e.components)==null?void 0:k.productCard,...o},children:a.jsxs("div",{"data-admesh-theme":e==null?void 0:e.mode,children:[a.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(e==null?void 0:e.mode)==="dark"?"#000000":"#ffffff",backgroundColor:(e==null?void 0:e.mode)==="dark"?"#ffffff":"#000000",padding:"2px 6px",borderRadius:"4px",marginRight:"8px"},title:X(t,$(t)),children:$(t)}),a.jsxs("span",{style:{color:(e==null?void 0:e.mode)==="dark"?"#f3f4f6":"#374151",marginRight:"4px"},children:[n.description," "]}),a.jsx(V,{adId:((v=t.meta)==null?void 0:v.ad_id)||t.ad_id||"",admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:t.intent_match_score,component:"simple_ad_cta"},children:a.jsx("span",{style:{color:(e==null?void 0:e.mode)==="dark"?"#ffffff":"#000000",textDecoration:"underline",cursor:"pointer",fontSize:"inherit",fontFamily:"inherit"},children:n.ctaText})})]})})}const p=((y=t.meta)==null?void 0:y.ad_id)||t.ad_id||"",h=t.product_id||"";return a.jsx(P,{adId:p,productId:h,className:l,style:{fontFamily:(e==null?void 0:e.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(C=e==null?void 0:e.components)==null?void 0:C.productCard,...o},children:a.jsx("div",{style:{fontFamily:(e==null?void 0:e.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(j=e==null?void 0:e.components)==null?void 0:j.productCard,...o},"data-admesh-theme":e==null?void 0:e.mode,children:a.jsxs("div",{className:"h-full flex flex-col",style:m,children:[a.jsx("div",{className:"mb-1.5",children:a.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(e==null?void 0:e.mode)==="dark"?"#000000":"#ffffff",backgroundColor:(e==null?void 0:e.mode)==="dark"?"#ffffff":"#000000",padding:"2px 6px",borderRadius:"4px"},title:X(t,$(t)),children:$(t)})}),a.jsxs("div",{className:"flex justify-between items-center gap-3 mb-2",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[t.product_logo&&a.jsx("img",{src:t.product_logo.url,alt:`${t.title} logo`,className:"w-6 h-6 rounded flex-shrink-0",onError:I=>{I.target.style.display="none"}}),a.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm sm:text-base truncate",children:n.title})]}),a.jsx("div",{className:"flex-shrink-0",children:a.jsx(V,{adId:((D=t.meta)==null?void 0:D.ad_id)||t.ad_id||"",admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:((z=t.meta)==null?void 0:z.intent_match_score)||t.intent_match_score,component:"product_card_cta"},children:a.jsxs("button",{className:"text-xs px-2 py-1 sm:px-3 sm:py-2 rounded-full flex items-center transition-all duration-200 transform hover:scale-105 shadow-md hover:shadow-lg whitespace-nowrap",style:{backgroundColor:(e==null?void 0:e.accentColor)||"#000000",color:(e==null?void 0:e.mode)==="dark"?"#000000":"#ffffff"},children:["Visit",a.jsx("svg",{className:"ml-1 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})})})]}),a.jsx("div",{className:"mb-3",children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 leading-snug",children:n.description})}),r&&t.features&&t.features.length>0&&a.jsxs("div",{className:"mb-2",children:[a.jsx("div",{className:"text-xs font-medium mb-1.5",style:{color:(e==null?void 0:e.mode)==="dark"?"#9ca3af":"#666666"},children:"Key Features"}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.features.slice(0,4).map((I,O)=>a.jsxs("span",{className:"text-xs px-2 py-1 rounded-full border",style:{backgroundColor:(e==null?void 0:e.mode)==="dark"?"#111111":"#f5f5f5",color:(e==null?void 0:e.mode)==="dark"?"#ffffff":"#000000",borderColor:(e==null?void 0:e.mode)==="dark"?"#333333":"#e5e7eb"},children:[a.jsx("svg",{className:"h-3 w-3 mr-0.5 inline",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),I]},O)),t.features.length>4&&a.jsxs("span",{className:"text-xs px-2 py-1",style:{color:(e==null?void 0:e.mode)==="dark"?"#9ca3af":"#666666"},children:["+",t.features.length-4," more"]})]})]}),a.jsx("div",{className:"mt-auto pt-3 border-t border-gray-100 dark:border-slate-700",children:a.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[a.jsx("span",{children:"Sponsored"}),a.jsx("span",{className:"text-gray-400 dark:text-gray-500"})]})})]})})})};R.displayName="AdMeshProductCard";const re=({recommendations:t,title:e="Product Recommendations",showTitle:r=!0,className:s="",cardClassName:i="",onProductClick:o,showPricing:d=!0,showRatings:n=!0,showBrand:l=!0,showSource:m=!1,showShipping:p=!0,maxCards:h=10,cardWidth:u="md",theme:g="auto",borderRadius:b="md",shadow:w="sm"})=>{if(!t||t.length===0)return console.log("[AdMesh Ecommerce Cards] Empty recommendations - not rendering anything"),null;const _=t.slice(0,h),A=()=>{switch(u){case"sm":return"w-48 min-w-48";case"md":return"w-64 min-w-64";case"lg":return"w-80 min-w-80";default:return"w-64 min-w-64"}},T=()=>{switch(b){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-lg";case"lg":return"rounded-xl";default:return"rounded-lg"}},E=()=>{switch(w){case"none":return"";case"sm":return"shadow-sm hover:shadow-md";case"md":return"shadow-md hover:shadow-lg";case"lg":return"shadow-lg hover:shadow-xl";default:return"shadow-sm hover:shadow-md"}},M=()=>g==="dark"?"bg-gray-900 text-white":g==="light"?"bg-white text-gray-900":"bg-white dark:bg-gray-900 text-gray-900 dark:text-white",N=c=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:2}).format(c),L=c=>{const k=[],v=Math.floor(c),y=c%1!==0;for(let j=0;j<v;j++)k.push(a.jsx("span",{className:"text-yellow-400",children:"★"},j));y&&k.push(a.jsx("span",{className:"text-yellow-400",children:"☆"},"half"));const C=5-Math.ceil(c);for(let j=0;j<C;j++)k.push(a.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"☆"},`empty-${j}`));return k},f=c=>{if(o)o(c);else{const k=c.admesh_link||c.url;k&&window.open(k,"_blank","noopener,noreferrer")}};return!t||t.length===0?null:a.jsxs("div",{className:F("w-full",s),children:[r&&a.jsxs("div",{className:"mb-4",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:e}),a.jsx("div",{className:"mt-1 h-0.5 w-12 bg-blue-500"})]}),a.jsxs("div",{className:"relative",children:[_.length===0?a.jsx("div",{className:"text-center py-8 text-gray-500",children:"No products to display"}):a.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4 scrollbar-hide",children:_.map(c=>{var C;const k=c.product_id||c.id||c.ad_id,v=c.ad_id||c.product_id||"",y=c.product_id||"";return a.jsx(P,{adId:v,productId:y,className:F(A(),T(),E(),M(),"flex-shrink-0 border border-gray-200 dark:border-gray-700 transition-all duration-200 cursor-pointer hover:scale-[1.02]",i),onClick:()=>f(c),children:a.jsxs("div",{children:[a.jsxs("div",{className:"relative aspect-square w-full overflow-hidden",children:[c.image_url?a.jsx("img",{src:c.image_url,alt:c.title,className:"h-full w-full object-cover transition-transform duration-200 hover:scale-105",loading:"lazy"}):a.jsx("div",{className:"flex h-full w-full items-center justify-center bg-gray-100 dark:bg-gray-800",children:a.jsx("svg",{className:"h-12 w-12 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),d&&c.discount_percentage&&c.discount_percentage>0&&a.jsxs("div",{className:"absolute top-2 left-2 bg-red-500 text-white text-xs font-bold px-2 py-1 rounded",children:["-",Math.round(c.discount_percentage),"%"]}),m&&c.source&&a.jsx("div",{className:"absolute top-2 right-2 bg-blue-500 text-white text-xs font-medium px-2 py-1 rounded",children:c.source.toUpperCase()})]}),a.jsxs("div",{className:"p-3",children:[l&&c.brand&&a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1 uppercase tracking-wide",children:c.brand}),a.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white line-clamp-2 mb-2 leading-tight",children:c.title}),n&&c.rating&&a.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[a.jsx("div",{className:"flex text-sm",children:L(c.rating)}),a.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["(",c.review_count||0,")"]})]}),d&&c.price&&a.jsx("div",{className:"mb-2",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-lg font-bold text-gray-900 dark:text-white",children:N(c.price)}),c.original_price&&c.original_price>c.price&&a.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 line-through",children:N(c.original_price)})]})}),p&&((C=c.shipping_info)==null?void 0:C.free_shipping_over_35)&&a.jsx("div",{className:"text-xs text-green-600 dark:text-green-400 font-medium",children:"Free shipping over $35"}),c.availability&&c.availability!=="unknown"&&a.jsx("div",{className:F("text-xs font-medium mt-1",c.availability==="in_stock"?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"),children:c.availability==="in_stock"?"In Stock":"Out of Stock"})]})]})},k)})}),_.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"absolute top-1/2 -left-2 transform -translate-y-1/2 bg-white dark:bg-gray-800 rounded-full shadow-lg p-1 opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),a.jsx("div",{className:"absolute top-1/2 -right-2 transform -translate-y-1/2 bg-white dark:bg-gray-800 rounded-full shadow-lg p-1 opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})]}),a.jsxs("div",{className:"flex justify-between items-center mt-3 pt-2 border-t border-gray-200 dark:border-gray-700",children:[a.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Sponsored"}),a.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500"})]}),a.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
973
|
+
`;let Q=!1;const te=()=>{x.useEffect(()=>{if(!Q){try{Ie();const t=document.createElement("style");t.id="admesh-ui-sdk-styles-legacy",t.textContent=Fe,document.getElementById("admesh-ui-sdk-styles-legacy")||document.head.appendChild(t),Q=!0}catch(t){console.error("[AdMesh] Failed to inject styles:",t)}return()=>{}}},[])},$=(t,e={})=>{const r=t.intent_match_score||0,s=e.customLabels||{};return r>=.8?s.partnerRecommendation||"Smart Pick":r>=.6?s.partnerMatch||"Partner Recommendation":r>=.3?s.promotedOption||"Promoted Match":s.relatedOption||"Related"},X=(t,e)=>{const r=t.intent_match_score||0;return r>=.8?"This recommendation is from a partner who compensates us when you engage. We've matched it to your needs based on your query.":r>=.6?"Top-rated partner solution matched to your specific requirements. Partner compensates us for qualified referrals.":r>=.3?"This partner solution may be relevant to your needs. The partner compensates us when you take qualifying actions.":"This solution is somewhat related to your query. While not a perfect match, it might still be helpful. This partner compensates us for qualified referrals."},R=({recommendation:t,theme:e,showFeatures:r=!1,variation:s="default",className:i,style:o})=>{var u,g,b,w,_,A,T,C,M,N,L,f,c,k,v,y,E,j,D,z;te();const n=s==="simple"?{title:t.recommendation_title||t.title,description:t.recommendation_description||t.description||t.reason,ctaText:t.recommendation_title||t.title,isSimple:!0}:{title:t.recommendation_title||t.title,description:t.recommendation_description||t.description||t.reason,ctaText:t.recommendation_title||t.title},l=F("admesh-component","admesh-card","relative p-3 sm:p-4 rounded-xl bg-gradient-to-br from-white to-gray-50 dark:from-slate-800 dark:to-slate-900 border border-gray-200/50 dark:border-slate-700/50 shadow-lg hover:shadow-xl transition-all duration-300 hover:-translate-y-1",i),m=e?{"--admesh-primary":e.primaryColor||e.accentColor||"#3b82f6","--admesh-secondary":e.secondaryColor||"#10b981","--admesh-accent":e.accentColor||"#3b82f6","--admesh-background":e.backgroundColor,"--admesh-surface":e.surfaceColor,"--admesh-border":e.borderColor,"--admesh-text":e.textColor,"--admesh-text-secondary":e.textSecondaryColor,"--admesh-radius":e.borderRadius||"12px","--admesh-shadow-sm":(u=e.shadows)==null?void 0:u.small,"--admesh-shadow-md":(g=e.shadows)==null?void 0:g.medium,"--admesh-shadow-lg":(b=e.shadows)==null?void 0:b.large,"--admesh-spacing-sm":(w=e.spacing)==null?void 0:w.small,"--admesh-spacing-md":(_=e.spacing)==null?void 0:_.medium,"--admesh-spacing-lg":(A=e.spacing)==null?void 0:A.large,"--admesh-font-size-sm":(T=e.fontSize)==null?void 0:T.small,"--admesh-font-size-base":(C=e.fontSize)==null?void 0:C.base,"--admesh-font-size-lg":(M=e.fontSize)==null?void 0:M.large,"--admesh-font-size-title":(N=e.fontSize)==null?void 0:N.title,fontFamily:e.fontFamily,width:((f=(L=e.components)==null?void 0:L.productCard)==null?void 0:f.width)||"100%"}:{width:"100%"};if(s==="simple"){const I=((c=t.meta)==null?void 0:c.ad_id)||t.ad_id||"",O=t.product_id||"";return a.jsx(P,{adId:I,productId:O,className:F("admesh-component admesh-simple-ad","inline-block text-sm leading-relaxed",i),style:{fontFamily:(e==null?void 0:e.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(k=e==null?void 0:e.components)==null?void 0:k.productCard,...o},children:a.jsxs("div",{"data-admesh-theme":e==null?void 0:e.mode,children:[a.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(e==null?void 0:e.mode)==="dark"?"#000000":"#ffffff",backgroundColor:(e==null?void 0:e.mode)==="dark"?"#ffffff":"#000000",padding:"2px 6px",borderRadius:"4px",marginRight:"8px"},title:X(t,$(t)),children:$(t)}),a.jsxs("span",{style:{color:(e==null?void 0:e.mode)==="dark"?"#f3f4f6":"#374151",marginRight:"4px"},children:[n.description," "]}),a.jsx(V,{adId:((v=t.meta)==null?void 0:v.ad_id)||t.ad_id||"",admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:t.intent_match_score,component:"simple_ad_cta"},children:a.jsx("span",{style:{color:(e==null?void 0:e.mode)==="dark"?"#ffffff":"#000000",textDecoration:"underline",cursor:"pointer",fontSize:"inherit",fontFamily:"inherit"},children:n.ctaText})})]})})}const p=((y=t.meta)==null?void 0:y.ad_id)||t.ad_id||"",h=t.product_id||"";return a.jsx(P,{adId:p,productId:h,className:l,style:{fontFamily:(e==null?void 0:e.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(E=e==null?void 0:e.components)==null?void 0:E.productCard,...o},children:a.jsx("div",{style:{fontFamily:(e==null?void 0:e.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(j=e==null?void 0:e.components)==null?void 0:j.productCard,...o},"data-admesh-theme":e==null?void 0:e.mode,children:a.jsxs("div",{className:"h-full flex flex-col",style:m,children:[a.jsx("div",{className:"mb-1.5",children:a.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(e==null?void 0:e.mode)==="dark"?"#000000":"#ffffff",backgroundColor:(e==null?void 0:e.mode)==="dark"?"#ffffff":"#000000",padding:"2px 6px",borderRadius:"4px"},title:X(t,$(t)),children:$(t)})}),a.jsxs("div",{className:"flex justify-between items-center gap-3 mb-2",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[t.product_logo&&a.jsx("img",{src:t.product_logo.url,alt:`${t.title} logo`,className:"w-6 h-6 rounded flex-shrink-0",onError:I=>{I.target.style.display="none"}}),a.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm sm:text-base truncate",children:n.title})]}),a.jsx("div",{className:"flex-shrink-0",children:a.jsx(V,{adId:((D=t.meta)==null?void 0:D.ad_id)||t.ad_id||"",admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:((z=t.meta)==null?void 0:z.intent_match_score)||t.intent_match_score,component:"product_card_cta"},children:a.jsxs("button",{className:"text-xs px-2 py-1 sm:px-3 sm:py-2 rounded-full flex items-center transition-all duration-200 transform hover:scale-105 shadow-md hover:shadow-lg whitespace-nowrap",style:{backgroundColor:(e==null?void 0:e.accentColor)||"#000000",color:(e==null?void 0:e.mode)==="dark"?"#000000":"#ffffff"},children:["Visit",a.jsx("svg",{className:"ml-1 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14"})})]})})})]}),a.jsx("div",{className:"mb-3",children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 leading-snug",children:n.description})}),r&&t.features&&t.features.length>0&&a.jsxs("div",{className:"mb-2",children:[a.jsx("div",{className:"text-xs font-medium mb-1.5",style:{color:(e==null?void 0:e.mode)==="dark"?"#9ca3af":"#666666"},children:"Key Features"}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.features.slice(0,4).map((I,O)=>a.jsxs("span",{className:"text-xs px-2 py-1 rounded-full border",style:{backgroundColor:(e==null?void 0:e.mode)==="dark"?"#111111":"#f5f5f5",color:(e==null?void 0:e.mode)==="dark"?"#ffffff":"#000000",borderColor:(e==null?void 0:e.mode)==="dark"?"#333333":"#e5e7eb"},children:[a.jsx("svg",{className:"h-3 w-3 mr-0.5 inline",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),I]},O)),t.features.length>4&&a.jsxs("span",{className:"text-xs px-2 py-1",style:{color:(e==null?void 0:e.mode)==="dark"?"#9ca3af":"#666666"},children:["+",t.features.length-4," more"]})]})]}),a.jsx("div",{className:"mt-auto pt-3 border-t border-gray-100 dark:border-slate-700",children:a.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[a.jsx("span",{children:"Sponsored"}),a.jsx("span",{className:"text-gray-400 dark:text-gray-500"})]})})]})})})};R.displayName="AdMeshProductCard";const re=({recommendations:t,title:e="Product Recommendations",showTitle:r=!0,className:s="",cardClassName:i="",onProductClick:o,showPricing:d=!0,showRatings:n=!0,showBrand:l=!0,showSource:m=!1,showShipping:p=!0,maxCards:h=10,cardWidth:u="md",theme:g="auto",borderRadius:b="md",shadow:w="sm"})=>{if(!t||t.length===0)return console.log("[AdMesh Ecommerce Cards] Empty recommendations - not rendering anything"),null;const _=t.slice(0,h),A=()=>{switch(u){case"sm":return"w-48 min-w-48";case"md":return"w-64 min-w-64";case"lg":return"w-80 min-w-80";default:return"w-64 min-w-64"}},T=()=>{switch(b){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-lg";case"lg":return"rounded-xl";default:return"rounded-lg"}},C=()=>{switch(w){case"none":return"";case"sm":return"shadow-sm hover:shadow-md";case"md":return"shadow-md hover:shadow-lg";case"lg":return"shadow-lg hover:shadow-xl";default:return"shadow-sm hover:shadow-md"}},M=()=>g==="dark"?"bg-gray-900 text-white":g==="light"?"bg-white text-gray-900":"bg-white dark:bg-gray-900 text-gray-900 dark:text-white",N=c=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:2}).format(c),L=c=>{const k=[],v=Math.floor(c),y=c%1!==0;for(let j=0;j<v;j++)k.push(a.jsx("span",{className:"text-yellow-400",children:"★"},j));y&&k.push(a.jsx("span",{className:"text-yellow-400",children:"☆"},"half"));const E=5-Math.ceil(c);for(let j=0;j<E;j++)k.push(a.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"☆"},`empty-${j}`));return k},f=c=>{if(o)o(c);else{const k=c.admesh_link||c.url;k&&window.open(k,"_blank","noopener,noreferrer")}};return!t||t.length===0?null:a.jsxs("div",{className:F("w-full",s),children:[r&&a.jsxs("div",{className:"mb-4",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:e}),a.jsx("div",{className:"mt-1 h-0.5 w-12 bg-blue-500"})]}),a.jsxs("div",{className:"relative",children:[_.length===0?a.jsx("div",{className:"text-center py-8 text-gray-500",children:"No products to display"}):a.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4 scrollbar-hide",children:_.map(c=>{var E;const k=c.product_id||c.id||c.ad_id,v=c.ad_id||c.product_id||"",y=c.product_id||"";return a.jsx(P,{adId:v,productId:y,className:F(A(),T(),C(),M(),"flex-shrink-0 border border-gray-200 dark:border-gray-700 transition-all duration-200 cursor-pointer hover:scale-[1.02]",i),onClick:()=>f(c),children:a.jsxs("div",{children:[a.jsxs("div",{className:"relative aspect-square w-full overflow-hidden",children:[c.image_url?a.jsx("img",{src:c.image_url,alt:c.title,className:"h-full w-full object-cover transition-transform duration-200 hover:scale-105",loading:"lazy"}):a.jsx("div",{className:"flex h-full w-full items-center justify-center bg-gray-100 dark:bg-gray-800",children:a.jsx("svg",{className:"h-12 w-12 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),d&&c.discount_percentage&&c.discount_percentage>0&&a.jsxs("div",{className:"absolute top-2 left-2 bg-red-500 text-white text-xs font-bold px-2 py-1 rounded",children:["-",Math.round(c.discount_percentage),"%"]}),m&&c.source&&a.jsx("div",{className:"absolute top-2 right-2 bg-blue-500 text-white text-xs font-medium px-2 py-1 rounded",children:c.source.toUpperCase()})]}),a.jsxs("div",{className:"p-3",children:[l&&c.brand&&a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1 uppercase tracking-wide",children:c.brand}),a.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white line-clamp-2 mb-2 leading-tight",children:c.title}),n&&c.rating&&a.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[a.jsx("div",{className:"flex text-sm",children:L(c.rating)}),a.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["(",c.review_count||0,")"]})]}),d&&c.price&&a.jsx("div",{className:"mb-2",children:a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-lg font-bold text-gray-900 dark:text-white",children:N(c.price)}),c.original_price&&c.original_price>c.price&&a.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 line-through",children:N(c.original_price)})]})}),p&&((E=c.shipping_info)==null?void 0:E.free_shipping_over_35)&&a.jsx("div",{className:"text-xs text-green-600 dark:text-green-400 font-medium",children:"Free shipping over $35"}),c.availability&&c.availability!=="unknown"&&a.jsx("div",{className:F("text-xs font-medium mt-1",c.availability==="in_stock"?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"),children:c.availability==="in_stock"?"In Stock":"Out of Stock"})]})]})},k)})}),_.length>0&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"absolute top-1/2 -left-2 transform -translate-y-1/2 bg-white dark:bg-gray-800 rounded-full shadow-lg p-1 opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),a.jsx("div",{className:"absolute top-1/2 -right-2 transform -translate-y-1/2 bg-white dark:bg-gray-800 rounded-full shadow-lg p-1 opacity-0 group-hover:opacity-100 transition-opacity",children:a.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})]}),a.jsxs("div",{className:"flex justify-between items-center mt-3 pt-2 border-t border-gray-200 dark:border-gray-700",children:[a.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Sponsored"}),a.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500"})]}),a.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
974
974
|
.scrollbar-hide {
|
|
975
975
|
-ms-overflow-style: none;
|
|
976
976
|
scrollbar-width: none;
|