admesh-ui-sdk 0.16.1 → 0.16.3
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/README.md +3 -3
- package/dist/components/AdMeshSummaryUnit.d.ts.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +382 -343
- package/dist/index.mjs.map +1 -1
- package/dist/test-setup.d.ts +1 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -133,7 +133,7 @@ Choose the right component for your use case:
|
|
|
133
133
|
- **Single API**: One component handles all recommendation types
|
|
134
134
|
- **Smart Optimization**: Automatically limits items and optimizes for mobile
|
|
135
135
|
- **Customizable**: Full control over layout, spacing, and component behavior
|
|
136
|
-
- **FTC Compliance**: Includes proper "
|
|
136
|
+
- **FTC Compliance**: Includes proper "Sponsored", "Sponsored", and "" disclosures
|
|
137
137
|
|
|
138
138
|
### Default Configuration
|
|
139
139
|
|
|
@@ -180,7 +180,7 @@ import { AdMeshLayout } from 'admesh-ui-sdk';
|
|
|
180
180
|
|
|
181
181
|
## 📋 Individual Components
|
|
182
182
|
|
|
183
|
-
> **Note**: Individual components no longer display disclosure elements (Match Score, "Sponsored", "
|
|
183
|
+
> **Note**: Individual components no longer display disclosure elements (Match Score, "Sponsored", ""). Only AdMeshLayout includes FTC-compliant disclosures. Use AdMeshLayout for platform integration.
|
|
184
184
|
|
|
185
185
|
### Core Components
|
|
186
186
|
|
|
@@ -1303,7 +1303,7 @@ const [isDarkMode, setIsDarkMode] = useState(false);
|
|
|
1303
1303
|
|
|
1304
1304
|
- ✅ **Full Dark Mode Support**: All components automatically adapt to dark theme
|
|
1305
1305
|
- ✅ **WCAG Accessibility**: Proper contrast ratios meet accessibility guidelines
|
|
1306
|
-
- ✅ **Consistent Branding**: "
|
|
1306
|
+
- ✅ **Consistent Branding**: "" remains visible in both themes
|
|
1307
1307
|
- ✅ **Smooth Transitions**: Components transition smoothly between light and dark modes
|
|
1308
1308
|
- ✅ **CSS Variables**: Uses CSS custom properties for consistent theming
|
|
1309
1309
|
- ✅ **No Ambiguous Elements**: Clean, focused interface without confusing UI elements
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdMeshSummaryUnit.d.ts","sourceRoot":"","sources":["../../src/components/AdMeshSummaryUnit.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAExE,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,oBAAoB,EAAE,CAAC;IACxC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,WAAW,CAAC,EAAE,CAAC,cAAc,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC9D;
|
|
1
|
+
{"version":3,"file":"AdMeshSummaryUnit.d.ts","sourceRoot":"","sources":["../../src/components/AdMeshSummaryUnit.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAExE,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,oBAAoB,EAAE,CAAC;IACxC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,WAAW,CAAC,EAAE,CAAC,cAAc,EAAE,oBAAoB,KAAK,IAAI,CAAC;CAC9D;AA0ID,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAyD9D,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react");function we(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var X={exports:{}},Y={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var le;function
|
|
9
|
+
*/var le;function ke(){if(le)return Y;le=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(d,i,n){var s=null;if(n!==void 0&&(s=""+n),i.key!==void 0&&(s=""+i.key),"key"in i){n={};for(var l in i)l!=="key"&&(n[l]=i[l])}else n=i;return i=n.ref,{$$typeof:e,type:d,key:s,ref:i!==void 0?i:null,props:n}}return Y.Fragment=t,Y.jsx=o,Y.jsxs=o,Y}var G={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var ce;function ve(){return ce||(ce=1,process.env.NODE_ENV!=="production"&&function(){function e(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===S?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case T:return"Fragment";case
|
|
17
|
+
*/var ce;function ve(){return ce||(ce=1,process.env.NODE_ENV!=="production"&&function(){function e(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===S?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case T:return"Fragment";case k:return"Profiler";case j:return"StrictMode";case $:return"Suspense";case I:return"SuspenseList";case m:return"Activity"}if(typeof a=="object")switch(typeof a.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),a.$$typeof){case f:return"Portal";case z:return(a.displayName||"Context")+".Provider";case A:return(a._context.displayName||"Context")+".Consumer";case U:var p=a.render;return a=a.displayName,a||(a=p.displayName||p.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case D:return p=a.displayName||null,p!==null?p:e(a.type)||"Memo";case F:p=a._payload,a=a._init;try{return e(a(p))}catch{}}return null}function t(a){return""+a}function o(a){try{t(a);var p=!1}catch{p=!0}if(p){p=console;var b=p.error,v=typeof Symbol=="function"&&Symbol.toStringTag&&a[Symbol.toStringTag]||a.constructor.name||"Object";return b.call(p,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",v),t(a)}}function d(a){if(a===T)return"<>";if(typeof a=="object"&&a!==null&&a.$$typeof===F)return"<...>";try{var p=e(a);return p?"<"+p+">":"<...>"}catch{return"<...>"}}function i(){var a=R.A;return a===null?null:a.getOwner()}function n(){return Error("react-stack-top-frame")}function s(a){if(C.call(a,"key")){var p=Object.getOwnPropertyDescriptor(a,"key").get;if(p&&p.isReactWarning)return!1}return a.key!==void 0}function l(a,p){function b(){Q||(Q=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",p))}b.isReactWarning=!0,Object.defineProperty(a,"key",{get:b,configurable:!0})}function g(){var a=e(this.type);return W[a]||(W[a]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),a=this.props.ref,a!==void 0?a:null}function u(a,p,b,v,P,M,Z,ee){return b=M.ref,a={$$typeof:w,type:a,key:p,props:M,_owner:P},(b!==void 0?b:null)!==null?Object.defineProperty(a,"ref",{enumerable:!1,get:g}):Object.defineProperty(a,"ref",{enumerable:!1,value:null}),a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(a,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(a,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Z}),Object.defineProperty(a,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ee}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a}function x(a,p,b,v,P,M,Z,ee){var _=p.children;if(_!==void 0)if(v)if(B(_)){for(v=0;v<_.length;v++)c(_[v]);Object.freeze&&Object.freeze(_)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else c(_);if(C.call(p,"key")){_=e(a);var V=Object.keys(p).filter(function(ye){return ye!=="key"});v=0<V.length?"{key: someKey, "+V.join(": ..., ")+": ...}":"{key: someKey}",de[_+v]||(V=0<V.length?"{"+V.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,
|
|
22
|
+
<%s key={someKey} {...props} />`,v,_,V,_),de[_+v]=!0)}if(_=null,b!==void 0&&(o(b),_=""+b),s(p)&&(o(p.key),_=""+p.key),"key"in p){b={};for(var te in p)te!=="key"&&(b[te]=p[te])}else b=p;return _&&l(b,typeof a=="function"?a.displayName||a.name||"Unknown":a),u(a,_,M,P,i(),b,Z,ee)}function c(a){typeof a=="object"&&a!==null&&a.$$typeof===w&&a._store&&(a._store.validated=1)}var h=y,w=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),j=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),z=Symbol.for("react.context"),U=Symbol.for("react.forward_ref"),$=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),S=Symbol.for("react.client.reference"),R=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,C=Object.prototype.hasOwnProperty,B=Array.isArray,N=console.createTask?console.createTask:function(){return null};h={"react-stack-bottom-frame":function(a){return a()}};var Q,W={},E=h["react-stack-bottom-frame"].bind(h,n)(),K=N(d(n)),de={};G.Fragment=T,G.jsx=function(a,p,b,v,P){var M=1e4>R.recentlyCreatedOwnerStacks++;return x(a,p,b,!1,v,P,M?Error("react-stack-top-frame"):E,M?N(d(a)):K)},G.jsxs=function(a,p,b,v,P){var M=1e4>R.recentlyCreatedOwnerStacks++;return x(a,p,b,!0,v,P,M?Error("react-stack-top-frame"):E,M?N(d(a)):K)}}()),G}var me;function _e(){return me||(me=1,process.env.NODE_ENV==="production"?X.exports=ke():X.exports=ve()),X.exports}var r=_e();const je=e=>{try{return new URL(e),!0}catch{return!1}},pe=(e,t)=>{const o=new Map;t.forEach(g=>{g.admesh_link&&o.set(g.admesh_link,g)});const d=/\[([^\]]+)\]\(([^)]+)\)/g,i=[];let n=0,s,l=0;for(;(s=d.exec(e))!==null;){const[g,u,x]=s,c=o.get(x);s.index>n&&i.push(e.slice(n,s.index)),c?(l++,i.push(r.jsx("a",{href:c.admesh_link,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:h=>{console.log("AdMesh summary link clicked:",{adId:c.ad_id,productId:c.product_id,title:c.title||c.recommendation_title,brand:c.brand,pricing:c.pricing,admeshLink:c.admesh_link,source:"summary"}),typeof window<"u"&&window.admeshTracker&&window.admeshTracker.trackClick({adId:c.ad_id,productId:c.product_id,admeshLink:c.admesh_link,source:"summary"})},children:u},`summary-link-${l}`))):(console.warn(`[AdMesh Summary] No recommendation found for link: [${u}](${x}), creating regular link`),je(x)?(l++,i.push(r.jsx("a",{href:x,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:h=>{console.log("AdMesh summary unmatched link clicked:",{linkText:u,url:x,source:"summary"}),typeof window<"u"&&window.admeshTracker&&window.admeshTracker.trackClick({url:x,linkText:u,source:"summary_unmatched"})},children:u},`summary-link-${l}`))):(console.warn(`[AdMesh Summary] Invalid URL in markdown link: [${u}](${x})`),i.push(u))),n=s.index+g.length}return n<e.length&&i.push(e.slice(n)),i},oe=({summaryText:e,recommendations:t,theme:o,className:d="",style:i={},onLinkClick:n})=>{if(!e||!e.trim())return console.warn("[AdMesh Summary] No summary text provided"),null;if(!t||t.length===0){console.warn("[AdMesh Summary] No recommendations provided");const l=pe(e,[]);return r.jsx("div",{className:`admesh-summary-unit ${d}`,style:i,children:r.jsx("p",{className:"text-gray-700 dark:text-gray-300 leading-relaxed",children:l.map((g,u)=>r.jsx(y.Fragment,{children:g},u))})})}const s=pe(e,t);return r.jsxs("div",{className:`admesh-summary-unit ${d}`,style:{fontFamily:(o==null?void 0:o.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...i},children:[r.jsx("div",{className:"summary-content",children:r.jsx("p",{className:"text-gray-700 dark:text-gray-300 leading-relaxed text-base",children:s.map((l,g)=>r.jsx(y.Fragment,{children:l},g))})}),r.jsx("div",{className:"mt-3 pt-2 border-t border-gray-200 dark:border-gray-700",children:r.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Sponsored •"})})]})};var re={exports:{}};/*!
|
|
23
23
|
Copyright (c) 2018 Jed Watson.
|
|
24
24
|
Licensed under the MIT License (MIT), see
|
|
25
25
|
http://jedwatson.github.io/classnames
|
|
26
|
-
*/var
|
|
26
|
+
*/var he;function Ce(){return he||(he=1,function(e){(function(){var t={}.hasOwnProperty;function o(){for(var n="",s=0;s<arguments.length;s++){var l=arguments[s];l&&(n=i(n,d(l)))}return n}function d(n){if(typeof n=="string"||typeof n=="number")return n;if(typeof n!="object")return"";if(Array.isArray(n))return o.apply(null,n);if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]"))return n.toString();var s="";for(var l in n)t.call(n,l)&&n[l]&&(s=i(s,l));return s}function i(n,s){return s?n?n+" "+s:n+s:n}e.exports?(o.default=o,e.exports=o):window.classNames=o})()}(re)),re.exports}var Se=Ce();const O=we(Se),Te="https://api.useadmesh.com/track";let ne={apiBaseUrl:Te,enabled:!0,debug:!1,retryAttempts:3,retryDelay:1e3};const Ne=e=>{ne={...ne,...e}},ue=e=>{const[t,o]=y.useState(!1),[d,i]=y.useState(null),n=y.useMemo(()=>({...ne,...e}),[e]),s=y.useCallback((c,h)=>{n.debug&&console.log(`[AdMesh Tracker] ${c}`,h)},[n.debug]),l=y.useCallback(async(c,h)=>{if(!n.enabled){s("Tracking disabled, skipping event",{eventType:c,data:h});return}if(!h.adId||!h.admeshLink){const j="Missing required tracking data: adId and admeshLink are required";s(j,h),i(j);return}o(!0),i(null);const w={event_type:c,ad_id:h.adId,admesh_link:h.admeshLink,product_id:h.productId,user_id:h.userId,session_id:h.sessionId,revenue:h.revenue,conversion_type:h.conversionType,metadata:h.metadata,timestamp:new Date().toISOString(),user_agent:navigator.userAgent,referrer:document.referrer,page_url:window.location.href};s(`Sending ${c} event`,w);let f=null;for(let j=1;j<=(n.retryAttempts||3);j++)try{const k=await fetch(`${n.apiBaseUrl}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)});if(!k.ok)throw new Error(`HTTP ${k.status}: ${k.statusText}`);const A=await k.json();s(`${c} event tracked successfully`,A),o(!1);return}catch(k){f=k,s(`Attempt ${j} failed for ${c} event`,k),j<(n.retryAttempts||3)&&await new Promise(A=>setTimeout(A,(n.retryDelay||1e3)*j))}const T=`Failed to track ${c} event after ${n.retryAttempts} attempts: ${f==null?void 0:f.message}`;s(T,f),i(T),o(!1)},[n,s]),g=y.useCallback(async c=>l("click",c),[l]),u=y.useCallback(async c=>l("view",c),[l]),x=y.useCallback(async c=>(!c.revenue&&!c.conversionType&&s("Warning: Conversion tracking without revenue or conversion type",c),l("conversion",c)),[l,s]);return{trackClick:g,trackView:u,trackConversion:x,isTracking:t,error:d}},Re=(e,t,o)=>{try{const d=new URL(e);return d.searchParams.set("ad_id",t),d.searchParams.set("utm_source","admesh"),d.searchParams.set("utm_medium","recommendation"),o&&Object.entries(o).forEach(([i,n])=>{d.searchParams.set(i,n)}),d.toString()}catch(d){return console.warn("[AdMesh] Invalid URL provided to buildAdMeshLink:",e,d),e}},Ae=(e,t)=>({adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,...t}),J=({adId:e,admeshLink:t,productId:o,children:d,trackingData:i,className:n,style:s})=>{const{trackClick:l,trackView:g}=ue(),u=y.useRef(null),x=y.useRef(!1);y.useEffect(()=>{if(!u.current||x.current)return;const h=new IntersectionObserver(w=>{w.forEach(f=>{f.isIntersecting&&!x.current&&(x.current=!0,g({adId:e,admeshLink:t,productId:o,...i}).catch(console.error))})},{threshold:.5,rootMargin:"0px"});return h.observe(u.current),()=>{h.disconnect()}},[e,t,o,i,g]);const c=y.useCallback(async h=>{try{await l({adId:e,admeshLink:t,productId:o,...i})}catch(T){console.error("Failed to track click:",T)}h.target.closest("a")||window.open(t,"_blank","noopener,noreferrer")},[e,t,o,i,l]);return r.jsx("div",{ref:u,className:n,onClick:c,style:{cursor:"pointer",...s},children:d})};J.displayName="AdMeshLinkTracker";const Me=`
|
|
27
27
|
/* AdMesh UI SDK - Complete Self-Contained Styles */
|
|
28
28
|
|
|
29
29
|
/* CSS Reset for AdMesh components */
|
|
@@ -691,7 +691,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
691
691
|
.admesh-component .lg\\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
692
692
|
.admesh-component .lg\\:col-span-1 { grid-column: span 1 / span 1; }
|
|
693
693
|
}
|
|
694
|
-
`;let ae=!1;const ue=()=>{y.useEffect(()=>{if(ae)return;const e=document.createElement("style");return e.id="admesh-ui-sdk-styles",e.textContent=Ae,document.getElementById("admesh-ui-sdk-styles")||(document.head.appendChild(e),ae=!0),()=>{const t=document.getElementById("admesh-ui-sdk-styles");t&&document.head.contains(t)&&(document.head.removeChild(t),ae=!1)}},[])},V=(e,t={})=>{const o=e.intent_match_score||0,i=t.customLabels||{};return o>=.8?i.partnerRecommendation||"Partner Recommendation":o>=.6?i.partnerMatch||"Partner Match":o>=.3?i.promotedOption||"Promoted":i.relatedOption||"Related"},se=(e,t)=>{const o=e.intent_match_score||0;return o>=.8?"This recommendation is from a partner who compensates us when you engage. We've matched it to your needs based on your query.":o>=.6?"Top-rated partner solution matched to your specific requirements. Partner compensates us for qualified referrals.":o>=.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."},Me=(e=!0,t=!1)=>e?t?"These curated recommendations are from partners who compensate us for referrals.":"Personalized Partner Recommendations: All results are from vetted partners who compensate us for qualified matches. We've ranked them based on relevance to your specific needs.":"Expanded Results: While these don't perfectly match your query, they're related solutions from our partner network. All partners compensate us for referrals.",Ee=(e,t=!1)=>{const o=e.intent_match_score||0;return t?"Promoted":o>=.8?"Smart Recommendation":o>=.6?"Partner Match":"Promoted"},Pe=()=>"We've partnered with trusted providers to bring you relevant solutions. These partners compensate us for qualified referrals, which helps us keep our service free.",Ie=e=>({"Top Match":"Top Match","Partner Recommendation":"Partner Recommendation","Perfect Fit":"Perfect Fit","Great Match":"Great Match",Recommended:"Recommended","Good Fit":"Good Fit",Featured:"Featured","Popular Choice":"Popular Choice","Premium Pick":"Premium Pick","Free Tier":"Free Tier","AI Powered":"AI Powered",Popular:"Popular",New:"New","Trial Available":"Trial Available","Related Option":"Related Option","Alternative Solution":"Alternative Solution","Expanded Match":"Expanded Match"})[e]||e,Fe=(e,t="button")=>{const o=e.recommendation_title||e.title;return t==="link"?o:e.trial_days&&e.trial_days>0?`Try ${o}`:"Learn More"},Le=e=>e.some(t=>(t.intent_match_score||0)>=.8),Oe=(e=!1)=>e?"Powered by AdMesh":"Recommendations powered by AdMesh",H=({recommendation:e,theme:t,showMatchScore:o=!1,showBadges:i=!0,variation:d="default",expandable:n=!1,className:s,style:c})=>{var u,T,j,v,A,z,U,$,I,D,F,m,S,R;ue();const[f,g]=y.useState(!1);y.useMemo(()=>{var W;const C=[];V(e)==="Partner Recommendation"&&C.push("Top Match"),e.trial_days&&e.trial_days>0&&C.push("Trial Available");const N=["ai","artificial intelligence","machine learning","ml","automation"];return(((W=e.keywords)==null?void 0:W.some(E=>N.some(K=>E.toLowerCase().includes(K))))||e.title.toLowerCase().includes("ai"))&&C.push("AI Powered"),e.badges&&e.badges.length>0&&e.badges.forEach(E=>{["Top Match","Free Tier","AI Powered","Popular","New","Trial Available"].includes(E)&&!C.includes(E)&&C.push(E)}),C},[e]),Math.round(e.intent_match_score*100);const l=d==="simple"?{title:e.recommendation_title||e.title,description:e.recommendation_description||e.description||e.reason,ctaText:e.recommendation_title||e.title,isSimple:!0}:{title:e.recommendation_title||e.title,description:e.recommendation_description||e.description||e.reason,ctaText:e.recommendation_title||e.title},h=O("admesh-component","admesh-card","relative p-4 sm:p-5 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",s),w=t?{"--admesh-primary":t.primaryColor||t.accentColor||"#3b82f6","--admesh-secondary":t.secondaryColor||"#10b981","--admesh-accent":t.accentColor||"#3b82f6","--admesh-background":t.backgroundColor,"--admesh-surface":t.surfaceColor,"--admesh-border":t.borderColor,"--admesh-text":t.textColor,"--admesh-text-secondary":t.textSecondaryColor,"--admesh-radius":t.borderRadius||"12px","--admesh-shadow-sm":(u=t.shadows)==null?void 0:u.small,"--admesh-shadow-md":(T=t.shadows)==null?void 0:T.medium,"--admesh-shadow-lg":(j=t.shadows)==null?void 0:j.large,"--admesh-spacing-sm":(v=t.spacing)==null?void 0:v.small,"--admesh-spacing-md":(A=t.spacing)==null?void 0:A.medium,"--admesh-spacing-lg":(z=t.spacing)==null?void 0:z.large,"--admesh-font-size-sm":(U=t.fontSize)==null?void 0:U.small,"--admesh-font-size-base":($=t.fontSize)==null?void 0:$.base,"--admesh-font-size-lg":(I=t.fontSize)==null?void 0:I.large,"--admesh-font-size-title":(D=t.fontSize)==null?void 0:D.title,fontFamily:t.fontFamily,width:((m=(F=t.components)==null?void 0:F.productCard)==null?void 0:m.width)||"100%"}:{width:"100%"};return d==="simple"?r.jsxs("div",{className:O("admesh-component admesh-simple-ad","inline-block text-sm leading-relaxed",s),style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(S=t==null?void 0:t.components)==null?void 0:S.productCard,...c},"data-admesh-theme":t==null?void 0:t.mode,children:[r.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(t==null?void 0:t.accentColor)||"#2563eb",backgroundColor:(t==null?void 0:t.mode)==="dark"?"#374151":"#f3f4f6",padding:"2px 6px",borderRadius:"4px",marginRight:"8px"},title:se(e,V(e)),children:V(e)}),r.jsxs("span",{style:{color:(t==null?void 0:t.mode)==="dark"?"#f3f4f6":"#374151",marginRight:"4px"},children:[l.description," "]}),r.jsx(J,{adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,trackingData:{title:e.title,matchScore:e.intent_match_score,component:"simple_ad_cta"},children:r.jsx("span",{style:{color:(t==null?void 0:t.accentColor)||"#2563eb",textDecoration:"underline",cursor:"pointer",fontSize:"inherit",fontFamily:"inherit"},children:l.ctaText})}),r.jsx("span",{style:{fontSize:"10px",color:(t==null?void 0:t.mode)==="dark"?"#9ca3af":"#6b7280",marginLeft:"8px"},children:"(Sponsored • Powered by AdMesh)"})]}):r.jsx("div",{className:h,style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(R=t==null?void 0:t.components)==null?void 0:R.productCard,...c},"data-admesh-theme":t==null?void 0:t.mode,children:r.jsxs("div",{className:"h-full flex flex-col",style:w,children:[r.jsx("div",{className:"mb-3",children:r.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(t==null?void 0:t.accentColor)||"#2563eb",backgroundColor:(t==null?void 0:t.mode)==="dark"?"#374151":"#f3f4f6",padding:"2px 6px",borderRadius:"4px"},title:se(e,V(e)),children:V(e)})}),r.jsxs("div",{className:"flex justify-between items-center gap-3 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.product_logo&&r.jsx("img",{src:e.product_logo.url,alt:`${e.title} logo`,className:"w-6 h-6 rounded flex-shrink-0",onError:C=>{C.target.style.display="none"}}),r.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm sm:text-base truncate",children:l.title})]}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx(J,{adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,trackingData:{title:e.title,matchScore:e.intent_match_score,component:"product_card_cta"},children:r.jsxs("button",{className:"text-xs px-2 py-1 sm:px-3 sm:py-2 rounded-full bg-gradient-to-r from-purple-500 to-pink-500 text-white hover:from-purple-600 hover:to-pink-600 flex items-center transition-all duration-200 transform hover:scale-105 shadow-md hover:shadow-lg whitespace-nowrap",children:["Visit",r.jsx("svg",{className:"ml-1 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.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"})})]})})})]}),r.jsx("div",{className:"mb-6",children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 leading-relaxed",children:l.description})}),e.features&&e.features.length>0&&r.jsxs("div",{className:"mb-3",children:[r.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 font-medium",children:"✨ Key Features"}),r.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.features.slice(0,4).map((C,B)=>r.jsxs("span",{className:"text-xs px-2 py-1 rounded-full bg-gradient-to-r from-indigo-100 to-purple-100 dark:from-indigo-900/30 dark:to-purple-900/30 text-indigo-700 dark:text-indigo-300 border border-indigo-200 dark:border-indigo-700",children:[r.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-indigo-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.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"})}),C]},B)),e.features.length>4&&r.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 px-2 py-1",children:["+",e.features.length-4," more"]})]})]}),r.jsx("div",{className:"mt-auto pt-3 border-t border-gray-100 dark:border-slate-700",children:r.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[r.jsx("span",{children:"Sponsored"}),r.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Powered by AdMesh"})]})})]})})};H.displayName="AdMeshProductCard";const fe=({products:e=[],recommendations:t=[],title:o="Product Recommendations",showTitle:i=!0,className:d="",cardClassName:n="",onProductClick:s,showPricing:c=!0,showRatings:f=!0,showBrand:g=!0,showSource:b=!1,showShipping:l=!0,maxCards:h=10,cardWidth:w="md",theme:u="auto",borderRadius:T="md",shadow:j="sm"})=>{const v=t.length>0?t.slice(0,h):e.slice(0,h),A=()=>{switch(w){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"}},z=()=>{switch(T){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-lg";case"lg":return"rounded-xl";default:return"rounded-lg"}},U=()=>{switch(j){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"}},$=()=>u==="dark"?"bg-gray-900 text-white":u==="light"?"bg-white text-gray-900":"bg-white dark:bg-gray-900 text-gray-900 dark:text-white",I=m=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:2}).format(m),D=m=>{const S=[],R=Math.floor(m),C=m%1!==0;for(let N=0;N<R;N++)S.push(r.jsx("span",{className:"text-yellow-400",children:"★"},N));C&&S.push(r.jsx("span",{className:"text-yellow-400",children:"☆"},"half"));const B=5-Math.ceil(m);for(let N=0;N<B;N++)S.push(r.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"☆"},`empty-${N}`));return S},F=m=>{if(s)s(m);else{const S=m.admesh_link||m.url;S&&window.open(S,"_blank","noopener,noreferrer")}};return(!e||e.length===0)&&(!t||t.length===0)?null:r.jsxs("div",{className:O("w-full",d),children:[i&&r.jsxs("div",{className:"mb-4",children:[r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:o}),r.jsx("div",{className:"mt-1 h-0.5 w-12 bg-blue-500"})]}),r.jsxs("div",{className:"relative",children:[v.length===0?r.jsx("div",{className:"text-center py-8 text-gray-500",children:"No products to display"}):r.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4 scrollbar-hide",children:v.map(m=>{var R;const S=m.product_id||m.id||m.ad_id;return r.jsxs("div",{className:O(A(),z(),U(),$(),"flex-shrink-0 border border-gray-200 dark:border-gray-700 transition-all duration-200 cursor-pointer hover:scale-[1.02]",n),onClick:()=>F(m),children:[r.jsxs("div",{className:"relative aspect-square w-full overflow-hidden",children:[m.image_url?r.jsx("img",{src:m.image_url,alt:m.title,className:"h-full w-full object-cover transition-transform duration-200 hover:scale-105",loading:"lazy"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-gray-100 dark:bg-gray-800",children:r.jsx("svg",{className:"h-12 w-12 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.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"})})}),c&&m.discount_percentage&&m.discount_percentage>0&&r.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(m.discount_percentage),"%"]}),b&&m.source&&r.jsx("div",{className:"absolute top-2 right-2 bg-blue-500 text-white text-xs font-medium px-2 py-1 rounded",children:m.source.toUpperCase()})]}),r.jsxs("div",{className:"p-3",children:[g&&m.brand&&r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1 uppercase tracking-wide",children:m.brand}),r.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white line-clamp-2 mb-2 leading-tight",children:m.title}),f&&m.rating&&r.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[r.jsx("div",{className:"flex text-sm",children:D(m.rating)}),r.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["(",m.review_count||0,")"]})]}),c&&m.price&&r.jsx("div",{className:"mb-2",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-lg font-bold text-gray-900 dark:text-white",children:I(m.price)}),m.original_price&&m.original_price>m.price&&r.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 line-through",children:I(m.original_price)})]})}),l&&((R=m.shipping_info)==null?void 0:R.free_shipping_over_35)&&r.jsx("div",{className:"text-xs text-green-600 dark:text-green-400 font-medium",children:"Free shipping over $35"}),m.availability&&m.availability!=="unknown"&&r.jsx("div",{className:O("text-xs font-medium mt-1",m.availability==="in_stock"?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"),children:m.availability==="in_stock"?"In Stock":"Out of Stock"})]})]},S)})}),v.length>0&&r.jsxs(r.Fragment,{children:[r.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:r.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),r.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:r.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})]}),r.jsxs("div",{className:"flex justify-between items-center mt-3 pt-2 border-t border-gray-200 dark:border-gray-700",children:[r.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Sponsored"}),r.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Powered by AdMesh"})]}),r.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
694
|
+
`;let ae=!1;const fe=()=>{y.useEffect(()=>{if(ae)return;const e=document.createElement("style");return e.id="admesh-ui-sdk-styles",e.textContent=Me,document.getElementById("admesh-ui-sdk-styles")||(document.head.appendChild(e),ae=!0),()=>{const t=document.getElementById("admesh-ui-sdk-styles");t&&document.head.contains(t)&&(document.head.removeChild(t),ae=!1)}},[])},q=(e,t={})=>{const o=e.intent_match_score||0,d=t.customLabels||{};return o>=.8?d.partnerRecommendation||"Sponsored":o>=.6?d.partnerMatch||"Partner Match":o>=.3?d.promotedOption||"Promoted":d.relatedOption||"Related"},se=(e,t)=>{const o=e.intent_match_score||0;return o>=.8?"This recommendation is from a partner who compensates us when you engage. We've matched it to your needs based on your query.":o>=.6?"Top-rated partner solution matched to your specific requirements. Partner compensates us for qualified referrals.":o>=.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."},Ee=(e=!0,t=!1)=>e?t?"These curated recommendations are from partners who compensate us for referrals.":"Personalized Sponsoreds: All results are from vetted partners who compensate us for qualified matches. We've ranked them based on relevance to your specific needs.":"Expanded Results: While these don't perfectly match your query, they're related solutions from our partner network. All partners compensate us for referrals.",Pe=(e,t=!1)=>{const o=e.intent_match_score||0;return t?"Promoted":o>=.8?"Smart Recommendation":o>=.6?"Partner Match":"Promoted"},Ie=()=>"We've partnered with trusted providers to bring you relevant solutions. These partners compensate us for qualified referrals, which helps us keep our service free.",Fe=e=>({"Top Match":"Top Match",Sponsored:"Sponsored","Perfect Fit":"Perfect Fit","Great Match":"Great Match",Recommended:"Recommended","Good Fit":"Good Fit",Featured:"Featured","Popular Choice":"Popular Choice","Premium Pick":"Premium Pick","Free Tier":"Free Tier","AI Powered":"AI Powered",Popular:"Popular",New:"New","Trial Available":"Trial Available","Related Option":"Related Option","Alternative Solution":"Alternative Solution","Expanded Match":"Expanded Match"})[e]||e,Le=(e,t="button")=>{const o=e.recommendation_title||e.title;return t==="link"?o:e.trial_days&&e.trial_days>0?`Try ${o}`:"Learn More"},Oe=e=>e.some(t=>(t.intent_match_score||0)>=.8),ze=(e=!1)=>e?"":"Recommendations ",H=({recommendation:e,theme:t,showMatchScore:o=!1,showBadges:d=!0,variation:i="default",expandable:n=!1,className:s,style:l})=>{var f,T,j,k,A,z,U,$,I,D,F,m,S,R;fe();const[g,u]=y.useState(!1);y.useMemo(()=>{var W;const C=[];q(e)==="Sponsored"&&C.push("Top Match"),e.trial_days&&e.trial_days>0&&C.push("Trial Available");const N=["ai","artificial intelligence","machine learning","ml","automation"];return(((W=e.keywords)==null?void 0:W.some(E=>N.some(K=>E.toLowerCase().includes(K))))||e.title.toLowerCase().includes("ai"))&&C.push("AI Powered"),e.badges&&e.badges.length>0&&e.badges.forEach(E=>{["Top Match","Free Tier","AI Powered","Popular","New","Trial Available"].includes(E)&&!C.includes(E)&&C.push(E)}),C},[e]),Math.round(e.intent_match_score*100);const c=i==="simple"?{title:e.recommendation_title||e.title,description:e.recommendation_description||e.description||e.reason,ctaText:e.recommendation_title||e.title,isSimple:!0}:{title:e.recommendation_title||e.title,description:e.recommendation_description||e.description||e.reason,ctaText:e.recommendation_title||e.title},h=O("admesh-component","admesh-card","relative p-4 sm:p-5 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",s),w=t?{"--admesh-primary":t.primaryColor||t.accentColor||"#3b82f6","--admesh-secondary":t.secondaryColor||"#10b981","--admesh-accent":t.accentColor||"#3b82f6","--admesh-background":t.backgroundColor,"--admesh-surface":t.surfaceColor,"--admesh-border":t.borderColor,"--admesh-text":t.textColor,"--admesh-text-secondary":t.textSecondaryColor,"--admesh-radius":t.borderRadius||"12px","--admesh-shadow-sm":(f=t.shadows)==null?void 0:f.small,"--admesh-shadow-md":(T=t.shadows)==null?void 0:T.medium,"--admesh-shadow-lg":(j=t.shadows)==null?void 0:j.large,"--admesh-spacing-sm":(k=t.spacing)==null?void 0:k.small,"--admesh-spacing-md":(A=t.spacing)==null?void 0:A.medium,"--admesh-spacing-lg":(z=t.spacing)==null?void 0:z.large,"--admesh-font-size-sm":(U=t.fontSize)==null?void 0:U.small,"--admesh-font-size-base":($=t.fontSize)==null?void 0:$.base,"--admesh-font-size-lg":(I=t.fontSize)==null?void 0:I.large,"--admesh-font-size-title":(D=t.fontSize)==null?void 0:D.title,fontFamily:t.fontFamily,width:((m=(F=t.components)==null?void 0:F.productCard)==null?void 0:m.width)||"100%"}:{width:"100%"};return i==="simple"?r.jsxs("div",{className:O("admesh-component admesh-simple-ad","inline-block text-sm leading-relaxed",s),style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(S=t==null?void 0:t.components)==null?void 0:S.productCard,...l},"data-admesh-theme":t==null?void 0:t.mode,children:[r.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(t==null?void 0:t.accentColor)||"#2563eb",backgroundColor:(t==null?void 0:t.mode)==="dark"?"#374151":"#f3f4f6",padding:"2px 6px",borderRadius:"4px",marginRight:"8px"},title:se(e,q(e)),children:q(e)}),r.jsxs("span",{style:{color:(t==null?void 0:t.mode)==="dark"?"#f3f4f6":"#374151",marginRight:"4px"},children:[c.description," "]}),r.jsx(J,{adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,trackingData:{title:e.title,matchScore:e.intent_match_score,component:"simple_ad_cta"},children:r.jsx("span",{style:{color:(t==null?void 0:t.accentColor)||"#2563eb",textDecoration:"underline",cursor:"pointer",fontSize:"inherit",fontFamily:"inherit"},children:c.ctaText})}),r.jsx("span",{style:{fontSize:"10px",color:(t==null?void 0:t.mode)==="dark"?"#9ca3af":"#6b7280",marginLeft:"8px"},children:"(Sponsored • )"})]}):r.jsx("div",{className:h,style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(R=t==null?void 0:t.components)==null?void 0:R.productCard,...l},"data-admesh-theme":t==null?void 0:t.mode,children:r.jsxs("div",{className:"h-full flex flex-col",style:w,children:[r.jsx("div",{className:"mb-3",children:r.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(t==null?void 0:t.accentColor)||"#2563eb",backgroundColor:(t==null?void 0:t.mode)==="dark"?"#374151":"#f3f4f6",padding:"2px 6px",borderRadius:"4px"},title:se(e,q(e)),children:q(e)})}),r.jsxs("div",{className:"flex justify-between items-center gap-3 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.product_logo&&r.jsx("img",{src:e.product_logo.url,alt:`${e.title} logo`,className:"w-6 h-6 rounded flex-shrink-0",onError:C=>{C.target.style.display="none"}}),r.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm sm:text-base truncate",children:c.title})]}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx(J,{adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,trackingData:{title:e.title,matchScore:e.intent_match_score,component:"product_card_cta"},children:r.jsxs("button",{className:"text-xs px-2 py-1 sm:px-3 sm:py-2 rounded-full bg-gradient-to-r from-purple-500 to-pink-500 text-white hover:from-purple-600 hover:to-pink-600 flex items-center transition-all duration-200 transform hover:scale-105 shadow-md hover:shadow-lg whitespace-nowrap",children:["Visit",r.jsx("svg",{className:"ml-1 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.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"})})]})})})]}),r.jsx("div",{className:"mb-6",children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 leading-relaxed",children:c.description})}),e.features&&e.features.length>0&&r.jsxs("div",{className:"mb-3",children:[r.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 font-medium",children:"✨ Key Features"}),r.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.features.slice(0,4).map((C,B)=>r.jsxs("span",{className:"text-xs px-2 py-1 rounded-full bg-gradient-to-r from-indigo-100 to-purple-100 dark:from-indigo-900/30 dark:to-purple-900/30 text-indigo-700 dark:text-indigo-300 border border-indigo-200 dark:border-indigo-700",children:[r.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-indigo-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.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"})}),C]},B)),e.features.length>4&&r.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 px-2 py-1",children:["+",e.features.length-4," more"]})]})]}),r.jsx("div",{className:"mt-auto pt-3 border-t border-gray-100 dark:border-slate-700",children:r.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[r.jsx("span",{children:"Sponsored"}),r.jsx("span",{className:"text-gray-400 dark:text-gray-500"})]})})]})})};H.displayName="AdMeshProductCard";const ge=({products:e=[],recommendations:t=[],title:o="Product Recommendations",showTitle:d=!0,className:i="",cardClassName:n="",onProductClick:s,showPricing:l=!0,showRatings:g=!0,showBrand:u=!0,showSource:x=!1,showShipping:c=!0,maxCards:h=10,cardWidth:w="md",theme:f="auto",borderRadius:T="md",shadow:j="sm"})=>{const k=t.length>0?t.slice(0,h):e.slice(0,h),A=()=>{switch(w){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"}},z=()=>{switch(T){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-lg";case"lg":return"rounded-xl";default:return"rounded-lg"}},U=()=>{switch(j){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"}},$=()=>f==="dark"?"bg-gray-900 text-white":f==="light"?"bg-white text-gray-900":"bg-white dark:bg-gray-900 text-gray-900 dark:text-white",I=m=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:2}).format(m),D=m=>{const S=[],R=Math.floor(m),C=m%1!==0;for(let N=0;N<R;N++)S.push(r.jsx("span",{className:"text-yellow-400",children:"★"},N));C&&S.push(r.jsx("span",{className:"text-yellow-400",children:"☆"},"half"));const B=5-Math.ceil(m);for(let N=0;N<B;N++)S.push(r.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"☆"},`empty-${N}`));return S},F=m=>{if(s)s(m);else{const S=m.admesh_link||m.url;S&&window.open(S,"_blank","noopener,noreferrer")}};return(!e||e.length===0)&&(!t||t.length===0)?null:r.jsxs("div",{className:O("w-full",i),children:[d&&r.jsxs("div",{className:"mb-4",children:[r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:o}),r.jsx("div",{className:"mt-1 h-0.5 w-12 bg-blue-500"})]}),r.jsxs("div",{className:"relative",children:[k.length===0?r.jsx("div",{className:"text-center py-8 text-gray-500",children:"No products to display"}):r.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4 scrollbar-hide",children:k.map(m=>{var R;const S=m.product_id||m.id||m.ad_id;return r.jsxs("div",{className:O(A(),z(),U(),$(),"flex-shrink-0 border border-gray-200 dark:border-gray-700 transition-all duration-200 cursor-pointer hover:scale-[1.02]",n),onClick:()=>F(m),children:[r.jsxs("div",{className:"relative aspect-square w-full overflow-hidden",children:[m.image_url?r.jsx("img",{src:m.image_url,alt:m.title,className:"h-full w-full object-cover transition-transform duration-200 hover:scale-105",loading:"lazy"}):r.jsx("div",{className:"flex h-full w-full items-center justify-center bg-gray-100 dark:bg-gray-800",children:r.jsx("svg",{className:"h-12 w-12 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.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"})})}),l&&m.discount_percentage&&m.discount_percentage>0&&r.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(m.discount_percentage),"%"]}),x&&m.source&&r.jsx("div",{className:"absolute top-2 right-2 bg-blue-500 text-white text-xs font-medium px-2 py-1 rounded",children:m.source.toUpperCase()})]}),r.jsxs("div",{className:"p-3",children:[u&&m.brand&&r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1 uppercase tracking-wide",children:m.brand}),r.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white line-clamp-2 mb-2 leading-tight",children:m.title}),g&&m.rating&&r.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[r.jsx("div",{className:"flex text-sm",children:D(m.rating)}),r.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["(",m.review_count||0,")"]})]}),l&&m.price&&r.jsx("div",{className:"mb-2",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-lg font-bold text-gray-900 dark:text-white",children:I(m.price)}),m.original_price&&m.original_price>m.price&&r.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 line-through",children:I(m.original_price)})]})}),c&&((R=m.shipping_info)==null?void 0:R.free_shipping_over_35)&&r.jsx("div",{className:"text-xs text-green-600 dark:text-green-400 font-medium",children:"Free shipping over $35"}),m.availability&&m.availability!=="unknown"&&r.jsx("div",{className:O("text-xs font-medium mt-1",m.availability==="in_stock"?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"),children:m.availability==="in_stock"?"In Stock":"Out of Stock"})]})]},S)})}),k.length>0&&r.jsxs(r.Fragment,{children:[r.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:r.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),r.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:r.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})]}),r.jsxs("div",{className:"flex justify-between items-center mt-3 pt-2 border-t border-gray-200 dark:border-gray-700",children:[r.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Sponsored"}),r.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500"})]}),r.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
695
695
|
.scrollbar-hide {
|
|
696
696
|
-ms-overflow-style: none;
|
|
697
697
|
scrollbar-width: none;
|
|
@@ -705,5 +705,5 @@ React keys must be passed directly to JSX without using spread:
|
|
|
705
705
|
-webkit-box-orient: vertical;
|
|
706
706
|
overflow: hidden;
|
|
707
707
|
}
|
|
708
|
-
`}})]})},ze=e=>{var i,d;const t=[];if(!e)return{isValid:!1,warnings:["No response object provided"]};(!e.recommendations||!Array.isArray(e.recommendations))&&t.push("No recommendations array found in response"),e.layout_type==="citation"&&!e.citation_summary&&t.push("Citation layout specified but no citation_summary provided");const o=((i=e.recommendations)==null?void 0:i.filter(n=>n&&n.admesh_link&&(n.title||n.recommendation_title)))||[];return o.length===0&&t.push("No valid recommendations found (missing admesh_link or title)"),{isValid:o.length>0,validCount:o.length,totalCount:((d=e.recommendations)==null?void 0:d.length)||0,warnings:t}},ie=({response:e,theme:t,className:o="",style:i={},onRecommendationClick:d,onLinkClick:n})=>{const s=ze(e);if(s.warnings.length>0&&console.warn("[AdMesh Summary Layout] Validation warnings:",s.warnings),!s.isValid)return console.error("[AdMesh Summary Layout] Invalid response object"),r.jsx("div",{className:`admesh-summary-layout-error ${o}`,style:i,children:r.jsxs("div",{className:"text-center py-6 px-4 bg-gray-50 dark:bg-gray-800 rounded-lg",children:[r.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:"Unable to display recommendations"}),r.jsx("p",{className:"text-gray-500 dark:text-gray-500 text-xs mt-1",children:"Check console for details"})]})});const{layout_type:c="citation",citation_summary:f,recommendations:g=[],requires_summary:b=!0}=e;console.log(`[AdMesh Summary Layout] Rendering ${c} layout with ${s.validCount}/${s.totalCount} valid recommendations`);const l=()=>{switch(c){case"citation":return f&&b?r.jsx(oe,{summaryText:f,recommendations:g,theme:t,onLinkClick:n}):r.jsxs("div",{className:"fallback-citation",children:[r.jsx("p",{className:"text-gray-700 dark:text-gray-300 mb-3",children:"Based on your query, I'd recommend checking out these options:"}),r.jsx(H,{recommendation:g[0],theme:t})]});case"product_cards":case"product":return r.jsx("div",{className:"product-cards-layout",children:g.slice(0,3).map((h,w)=>r.jsx(H,{recommendation:h,theme:t,className:"mb-4"},h.ad_id||`rec-${w}`))});case"ecommerce":return r.jsx(fe,{recommendations:g.slice(0,3),theme:(t==null?void 0:t.mode)||"light"});default:return console.warn(`[AdMesh Summary Layout] Unknown layout type: ${c}`),f?r.jsx(oe,{summaryText:f,recommendations:g,theme:t,onLinkClick:n}):r.jsx(H,{recommendation:g[0],theme:t})}};return r.jsx("div",{className:`admesh-summary-layout admesh-layout-${c} ${o}`,style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...i},children:l()})},Ue=({recommendations:e=[],citationSummary:t,layout:o,response:i,theme:d,className:n,style:s,onRecommendationClick:c,onLinkClick:f})=>{const g=c?l=>c(l.ad_id||"",l.admesh_link||""):void 0;if(i)return r.jsx(ie,{response:i,theme:d,className:n,style:s,onRecommendationClick:g,onLinkClick:f});const b={layout_type:o||"citation",citation_summary:t,recommendations:e,requires_summary:!!t};return r.jsx(ie,{response:b,theme:d,className:n,style:s,onRecommendationClick:g,onLinkClick:f})},ge=({recommendation:e,theme:t,variation:o="default",expandable:i=!1,className:d,style:n})=>{var l,h,w;const[s,c]=y.useState(!1),g=(()=>{const u=e.content_variations;return o==="question"&&(u!=null&&u.question)?{title:u.question.cta||e.recommendation_title||e.title,description:u.question.text,ctaText:u.question.cta||e.recommendation_title||e.title}:o==="statement"&&(u!=null&&u.statement)?{title:e.recommendation_title||e.title,description:u.statement.text,ctaText:u.statement.cta||e.recommendation_title||e.title}:{title:e.recommendation_title||e.title,description:e.recommendation_description||e.reason||"",ctaText:e.recommendation_title||e.title}})(),b=O("rounded-xl shadow-sm border border-gray-200 dark:border-gray-800 p-4 bg-white dark:bg-slate-900","hover:shadow-md transition-shadow duration-200",{"cursor-pointer":i&&(o==="question"||o==="statement")},d);return r.jsx("div",{className:b,style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:((h=(l=t==null?void 0:t.components)==null?void 0:l.inlineRecommendation)==null?void 0:h.width)||"100%",...(w=t==null?void 0:t.components)==null?void 0:w.productCard,...n},"data-admesh-theme":t==null?void 0:t.mode,children:r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex justify-between items-center gap-3 mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.product_logo&&r.jsx("img",{src:e.product_logo.url,alt:`${e.title} logo`,className:"w-5 h-5 rounded flex-shrink-0",onError:u=>{u.target.style.display="none"}}),r.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm truncate",children:g.title})]}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx(J,{adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,trackingData:{title:e.title,matchScore:e.intent_match_score,component:"inline_card_cta"},children:r.jsxs("button",{className:"text-xs px-2 py-1 rounded-full bg-gradient-to-r from-purple-500 to-pink-500 text-white hover:from-purple-600 hover:to-pink-600 flex items-center transition-all duration-200 transform hover:scale-105 shadow-sm whitespace-nowrap",children:[o==="question"?"Try":"Visit",r.jsx("svg",{className:"ml-1 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.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"})})]})})})]}),g.description&&r.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 line-clamp-2",children:g.description}),r.jsx("div",{className:"mt-auto pt-2 border-t border-gray-100 dark:border-slate-700",children:r.jsxs("div",{className:"flex items-center justify-between text-[11px] text-gray-500 dark:text-gray-400",children:[r.jsx("span",{children:"Sponsored"}),r.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Powered by AdMesh"})]})})]})})};ge.displayName="AdMeshInlineCard";const $e={"Top Match":"primary","Free Tier":"success","AI Powered":"secondary",Popular:"warning",New:"primary","Trial Available":"success"},De={"Top Match":"★","Free Tier":"◆","AI Powered":"◉",Popular:"▲",New:"●","Trial Available":"◈"},xe=({type:e,variant:t,size:o="md",className:i,style:d})=>{const n=t||$e[e]||"secondary",s=De[e],c=O("admesh-component","admesh-badge",`admesh-badge--${n}`,`admesh-badge--${o}`,i);return r.jsxs("span",{className:c,style:d,children:[s&&r.jsx("span",{className:"admesh-badge__icon",children:s}),r.jsx("span",{className:"admesh-badge__text",children:e})]})};xe.displayName="AdMeshBadge";const L=(e={})=>{const t={mode:"light",primaryColor:"#3b82f6",secondaryColor:"#10b981",accentColor:"#3b82f6",backgroundColor:"#ffffff",surfaceColor:"#f9fafb",borderColor:"#e5e7eb",textColor:"#111827",textSecondaryColor:"#6b7280",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:{small:"12px",base:"14px",large:"16px",title:"18px"},borderRadius:"8px",spacing:{small:"4px",medium:"8px",large:"16px"},shadows:{small:"0 1px 3px rgba(0, 0, 0, 0.1)",medium:"0 4px 6px rgba(0, 0, 0, 0.1)",large:"0 10px 15px rgba(0, 0, 0, 0.1)"},icons:{expandIcon:"▼",collapseIcon:"▲",starIcon:"★",checkIcon:"✓",arrowIcon:"→"},gradients:{primary:"linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)",secondary:"linear-gradient(135deg, #10b981 0%, #059669 100%)",accent:"linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%)"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"},card:{width:"auto"},button:{width:"auto"}}},o={...t,...e,fontSize:{...t.fontSize,...e.fontSize},spacing:{...t.spacing,...e.spacing},shadows:{...t.shadows,...e.shadows},icons:{...t.icons,...e.icons},components:{...t.components,...e.components}};return Ve(o)},Be=(e={})=>L({...{mode:"dark",backgroundColor:"#1f2937",surfaceColor:"#374151",borderColor:"#4b5563",textColor:"#f9fafb",textSecondaryColor:"#9ca3af",shadows:{small:"0 1px 3px rgba(0, 0, 0, 0.3)",medium:"0 4px 6px rgba(0, 0, 0, 0.3)",large:"0 10px 15px rgba(0, 0, 0, 0.3)"}},...e}),qe={get minimal(){return L({primaryColor:"#000000",secondaryColor:"#666666",borderRadius:"4px",shadows:{small:"none",medium:"0 1px 3px rgba(0, 0, 0, 0.1)",large:"0 2px 6px rgba(0, 0, 0, 0.1)"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}})},get vibrant(){return L({primaryColor:"#8b5cf6",secondaryColor:"#06b6d4",accentColor:"#f59e0b",borderRadius:"12px",gradients:{primary:"linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%)",secondary:"linear-gradient(135deg, #06b6d4 0%, #10b981 100%)",accent:"linear-gradient(135deg, #f59e0b 0%, #ef4444 100%)"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}})},get corporate(){return L({primaryColor:"#1e40af",secondaryColor:"#059669",backgroundColor:"#f8fafc",surfaceColor:"#ffffff",borderColor:"#cbd5e1",borderRadius:"6px",fontFamily:'"Inter", -apple-system, BlinkMacSystemFont, sans-serif',components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}})},get highContrast(){return L({primaryColor:"#000000",secondaryColor:"#ffffff",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",borderColor:"#000000",textColor:"#000000",textSecondaryColor:"#333333",borderRadius:"0px",shadows:{small:"none",medium:"0 0 0 2px #000000",large:"0 0 0 3px #000000"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}})}},Ve=(e={})=>{const t=e.components||{},o={productCard:{width:"100%",...t.productCard},citationUnit:{width:"100%",...t.citationUnit},inlineRecommendation:{width:"100%",...t.inlineRecommendation},expandableUnit:{width:"100%",...t.expandableUnit},compareTable:{width:"100%",...t.compareTable},card:{width:"auto",...t.card},button:{width:"auto",...t.button}};return{...e,components:{...t,...o}}},We=(...e)=>{const t=L();return e.reduce((o,i)=>i?{...o,...i,mode:i.mode||o.mode}:o,t)},Ye=e=>{var o,i,d,n,s,c;const t=getComputedStyle(e);return{primaryColor:((o=t.getPropertyValue("--admesh-primary-color"))==null?void 0:o.trim())||void 0,secondaryColor:((i=t.getPropertyValue("--admesh-secondary-color"))==null?void 0:i.trim())||void 0,backgroundColor:((d=t.getPropertyValue("--admesh-background-color"))==null?void 0:d.trim())||void 0,textColor:((n=t.getPropertyValue("--admesh-text-color"))==null?void 0:n.trim())||void 0,borderRadius:((s=t.getPropertyValue("--admesh-border-radius"))==null?void 0:s.trim())||void 0,fontFamily:((c=t.getPropertyValue("--admesh-font-family"))==null?void 0:c.trim())||void 0}},Ge="0.2.1",He={trackingEnabled:!0,debug:!1,theme:{mode:"light",accentColor:"#2563eb"}};exports.AdMeshBadge=xe;exports.AdMeshEcommerceCards=fe;exports.AdMeshInlineCard=ge;exports.AdMeshLayout=Ue;exports.AdMeshLinkTracker=J;exports.AdMeshProductCard=H;exports.AdMeshSummaryLayout=ie;exports.AdMeshSummaryUnit=oe;exports.DEFAULT_CONFIG=He;exports.VERSION=Ge;exports.buildAdMeshLink=Ne;exports.createAdMeshTheme=L;exports.createDarkTheme=Be;exports.extractTrackingData=Re;exports.getBadgeText=Ie;exports.getCtaText=Fe;exports.getInlineDisclosure=Ee;exports.getInlineTooltip=Pe;exports.getLabelTooltip=se;exports.getPoweredByText=Oe;exports.getRecommendationLabel=V;exports.getSectionDisclosure=Me;exports.hasHighQualityMatches=Le;exports.mergeThemes=We;exports.setAdMeshTrackerConfig=Te;exports.themeFromCSSProperties=Ye;exports.themePresets=qe;exports.useAdMeshStyles=ue;exports.useAdMeshTracker=he;
|
|
708
|
+
`}})]})},Ue=e=>{var d,i;const t=[];if(!e)return{isValid:!1,warnings:["No response object provided"]};(!e.recommendations||!Array.isArray(e.recommendations))&&t.push("No recommendations array found in response"),e.layout_type==="citation"&&!e.citation_summary&&t.push("Citation layout specified but no citation_summary provided");const o=((d=e.recommendations)==null?void 0:d.filter(n=>n&&n.admesh_link&&(n.title||n.recommendation_title)))||[];return o.length===0&&t.push("No valid recommendations found (missing admesh_link or title)"),{isValid:o.length>0,validCount:o.length,totalCount:((i=e.recommendations)==null?void 0:i.length)||0,warnings:t}},ie=({response:e,theme:t,className:o="",style:d={},onRecommendationClick:i,onLinkClick:n})=>{const s=Ue(e);if(s.warnings.length>0&&console.warn("[AdMesh Summary Layout] Validation warnings:",s.warnings),!s.isValid)return console.error("[AdMesh Summary Layout] Invalid response object"),r.jsx("div",{className:`admesh-summary-layout-error ${o}`,style:d,children:r.jsxs("div",{className:"text-center py-6 px-4 bg-gray-50 dark:bg-gray-800 rounded-lg",children:[r.jsx("p",{className:"text-gray-600 dark:text-gray-400 text-sm",children:"Unable to display recommendations"}),r.jsx("p",{className:"text-gray-500 dark:text-gray-500 text-xs mt-1",children:"Check console for details"})]})});const{layout_type:l="citation",citation_summary:g,recommendations:u=[],requires_summary:x=!0}=e;console.log(`[AdMesh Summary Layout] Rendering ${l} layout with ${s.validCount}/${s.totalCount} valid recommendations`);const c=()=>{switch(l){case"citation":return g&&x?r.jsx(oe,{summaryText:g,recommendations:u,theme:t,onLinkClick:n}):r.jsxs("div",{className:"fallback-citation",children:[r.jsx("p",{className:"text-gray-700 dark:text-gray-300 mb-3",children:"Based on your query, I'd recommend checking out these options:"}),r.jsx(H,{recommendation:u[0],theme:t})]});case"product_cards":case"product":return r.jsx("div",{className:"product-cards-layout",children:u.slice(0,3).map((h,w)=>r.jsx(H,{recommendation:h,theme:t,className:"mb-4"},h.ad_id||`rec-${w}`))});case"ecommerce":return r.jsx(ge,{recommendations:u.slice(0,3),theme:(t==null?void 0:t.mode)||"light"});default:return console.warn(`[AdMesh Summary Layout] Unknown layout type: ${l}`),g?r.jsx(oe,{summaryText:g,recommendations:u,theme:t,onLinkClick:n}):r.jsx(H,{recommendation:u[0],theme:t})}};return r.jsx("div",{className:`admesh-summary-layout admesh-layout-${l} ${o}`,style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...d},children:c()})},$e=({recommendations:e=[],citationSummary:t,layout:o,response:d,theme:i,className:n,style:s,onRecommendationClick:l,onLinkClick:g})=>{const u=l?c=>l(c.ad_id||"",c.admesh_link||""):void 0;if(d)return r.jsx(ie,{response:d,theme:i,className:n,style:s,onRecommendationClick:u,onLinkClick:g});const x={layout_type:o||"citation",citation_summary:t,recommendations:e,requires_summary:!!t};return r.jsx(ie,{response:x,theme:i,className:n,style:s,onRecommendationClick:u,onLinkClick:g})},xe=({recommendation:e,theme:t,variation:o="default",expandable:d=!1,className:i,style:n})=>{var c,h,w;const[s,l]=y.useState(!1),u=(()=>{const f=e.content_variations;return o==="question"&&(f!=null&&f.question)?{title:f.question.cta||e.recommendation_title||e.title,description:f.question.text,ctaText:f.question.cta||e.recommendation_title||e.title}:o==="statement"&&(f!=null&&f.statement)?{title:e.recommendation_title||e.title,description:f.statement.text,ctaText:f.statement.cta||e.recommendation_title||e.title}:{title:e.recommendation_title||e.title,description:e.recommendation_description||e.reason||"",ctaText:e.recommendation_title||e.title}})(),x=O("rounded-xl shadow-sm border border-gray-200 dark:border-gray-800 p-4 bg-white dark:bg-slate-900","hover:shadow-md transition-shadow duration-200",{"cursor-pointer":d&&(o==="question"||o==="statement")},i);return r.jsx("div",{className:x,style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:((h=(c=t==null?void 0:t.components)==null?void 0:c.inlineRecommendation)==null?void 0:h.width)||"100%",...(w=t==null?void 0:t.components)==null?void 0:w.productCard,...n},"data-admesh-theme":t==null?void 0:t.mode,children:r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex justify-between items-center gap-3 mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.product_logo&&r.jsx("img",{src:e.product_logo.url,alt:`${e.title} logo`,className:"w-5 h-5 rounded flex-shrink-0",onError:f=>{f.target.style.display="none"}}),r.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm truncate",children:u.title})]}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx(J,{adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,trackingData:{title:e.title,matchScore:e.intent_match_score,component:"inline_card_cta"},children:r.jsxs("button",{className:"text-xs px-2 py-1 rounded-full bg-gradient-to-r from-purple-500 to-pink-500 text-white hover:from-purple-600 hover:to-pink-600 flex items-center transition-all duration-200 transform hover:scale-105 shadow-sm whitespace-nowrap",children:[o==="question"?"Try":"Visit",r.jsx("svg",{className:"ml-1 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:r.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"})})]})})})]}),u.description&&r.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 line-clamp-2",children:u.description}),r.jsx("div",{className:"mt-auto pt-2 border-t border-gray-100 dark:border-slate-700",children:r.jsxs("div",{className:"flex items-center justify-between text-[11px] text-gray-500 dark:text-gray-400",children:[r.jsx("span",{children:"Sponsored"}),r.jsx("span",{className:"text-gray-400 dark:text-gray-500"})]})})]})})};xe.displayName="AdMeshInlineCard";const De={"Top Match":"primary","Free Tier":"success","AI Powered":"secondary",Popular:"warning",New:"primary","Trial Available":"success"},Be={"Top Match":"★","Free Tier":"◆","AI Powered":"◉",Popular:"▲",New:"●","Trial Available":"◈"},be=({type:e,variant:t,size:o="md",className:d,style:i})=>{const n=t||De[e]||"secondary",s=Be[e],l=O("admesh-component","admesh-badge",`admesh-badge--${n}`,`admesh-badge--${o}`,d);return r.jsxs("span",{className:l,style:i,children:[s&&r.jsx("span",{className:"admesh-badge__icon",children:s}),r.jsx("span",{className:"admesh-badge__text",children:e})]})};be.displayName="AdMeshBadge";const L=(e={})=>{const t={mode:"light",primaryColor:"#3b82f6",secondaryColor:"#10b981",accentColor:"#3b82f6",backgroundColor:"#ffffff",surfaceColor:"#f9fafb",borderColor:"#e5e7eb",textColor:"#111827",textSecondaryColor:"#6b7280",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:{small:"12px",base:"14px",large:"16px",title:"18px"},borderRadius:"8px",spacing:{small:"4px",medium:"8px",large:"16px"},shadows:{small:"0 1px 3px rgba(0, 0, 0, 0.1)",medium:"0 4px 6px rgba(0, 0, 0, 0.1)",large:"0 10px 15px rgba(0, 0, 0, 0.1)"},icons:{expandIcon:"▼",collapseIcon:"▲",starIcon:"★",checkIcon:"✓",arrowIcon:"→"},gradients:{primary:"linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)",secondary:"linear-gradient(135deg, #10b981 0%, #059669 100%)",accent:"linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%)"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"},card:{width:"auto"},button:{width:"auto"}}},o={...t,...e,fontSize:{...t.fontSize,...e.fontSize},spacing:{...t.spacing,...e.spacing},shadows:{...t.shadows,...e.shadows},icons:{...t.icons,...e.icons},components:{...t.components,...e.components}};return We(o)},Ve=(e={})=>L({...{mode:"dark",backgroundColor:"#1f2937",surfaceColor:"#374151",borderColor:"#4b5563",textColor:"#f9fafb",textSecondaryColor:"#9ca3af",shadows:{small:"0 1px 3px rgba(0, 0, 0, 0.3)",medium:"0 4px 6px rgba(0, 0, 0, 0.3)",large:"0 10px 15px rgba(0, 0, 0, 0.3)"}},...e}),qe={get minimal(){return L({primaryColor:"#000000",secondaryColor:"#666666",borderRadius:"4px",shadows:{small:"none",medium:"0 1px 3px rgba(0, 0, 0, 0.1)",large:"0 2px 6px rgba(0, 0, 0, 0.1)"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}})},get vibrant(){return L({primaryColor:"#8b5cf6",secondaryColor:"#06b6d4",accentColor:"#f59e0b",borderRadius:"12px",gradients:{primary:"linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%)",secondary:"linear-gradient(135deg, #06b6d4 0%, #10b981 100%)",accent:"linear-gradient(135deg, #f59e0b 0%, #ef4444 100%)"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}})},get corporate(){return L({primaryColor:"#1e40af",secondaryColor:"#059669",backgroundColor:"#f8fafc",surfaceColor:"#ffffff",borderColor:"#cbd5e1",borderRadius:"6px",fontFamily:'"Inter", -apple-system, BlinkMacSystemFont, sans-serif',components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}})},get highContrast(){return L({primaryColor:"#000000",secondaryColor:"#ffffff",backgroundColor:"#ffffff",surfaceColor:"#f5f5f5",borderColor:"#000000",textColor:"#000000",textSecondaryColor:"#333333",borderRadius:"0px",shadows:{small:"none",medium:"0 0 0 2px #000000",large:"0 0 0 3px #000000"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}})}},We=(e={})=>{const t=e.components||{},o={productCard:{width:"100%",...t.productCard},citationUnit:{width:"100%",...t.citationUnit},inlineRecommendation:{width:"100%",...t.inlineRecommendation},expandableUnit:{width:"100%",...t.expandableUnit},compareTable:{width:"100%",...t.compareTable},card:{width:"auto",...t.card},button:{width:"auto",...t.button}};return{...e,components:{...t,...o}}},Ye=(...e)=>{const t=L();return e.reduce((o,d)=>d?{...o,...d,mode:d.mode||o.mode}:o,t)},Ge=e=>{var o,d,i,n,s,l;const t=getComputedStyle(e);return{primaryColor:((o=t.getPropertyValue("--admesh-primary-color"))==null?void 0:o.trim())||void 0,secondaryColor:((d=t.getPropertyValue("--admesh-secondary-color"))==null?void 0:d.trim())||void 0,backgroundColor:((i=t.getPropertyValue("--admesh-background-color"))==null?void 0:i.trim())||void 0,textColor:((n=t.getPropertyValue("--admesh-text-color"))==null?void 0:n.trim())||void 0,borderRadius:((s=t.getPropertyValue("--admesh-border-radius"))==null?void 0:s.trim())||void 0,fontFamily:((l=t.getPropertyValue("--admesh-font-family"))==null?void 0:l.trim())||void 0}},He="0.2.1",Je={trackingEnabled:!0,debug:!1,theme:{mode:"light",accentColor:"#2563eb"}};exports.AdMeshBadge=be;exports.AdMeshEcommerceCards=ge;exports.AdMeshInlineCard=xe;exports.AdMeshLayout=$e;exports.AdMeshLinkTracker=J;exports.AdMeshProductCard=H;exports.AdMeshSummaryLayout=ie;exports.AdMeshSummaryUnit=oe;exports.DEFAULT_CONFIG=Je;exports.VERSION=He;exports.buildAdMeshLink=Re;exports.createAdMeshTheme=L;exports.createDarkTheme=Ve;exports.extractTrackingData=Ae;exports.getBadgeText=Fe;exports.getCtaText=Le;exports.getInlineDisclosure=Pe;exports.getInlineTooltip=Ie;exports.getLabelTooltip=se;exports.getPoweredByText=ze;exports.getRecommendationLabel=q;exports.getSectionDisclosure=Ee;exports.hasHighQualityMatches=Oe;exports.mergeThemes=Ye;exports.setAdMeshTrackerConfig=Ne;exports.themeFromCSSProperties=Ge;exports.themePresets=qe;exports.useAdMeshStyles=fe;exports.useAdMeshTracker=ue;
|
|
709
709
|
//# sourceMappingURL=index.js.map
|