admesh-ui-sdk 0.18.0 → 0.19.1

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 CHANGED
@@ -32,6 +32,153 @@ A comprehensive React + TypeScript component library for displaying AdMesh produ
32
32
  npm install admesh-ui-sdk
33
33
  ```
34
34
 
35
+ ## 🚀 Zero-Code Integration (Recommended for Platforms)
36
+
37
+ The AdMesh SDK provides a **zero-code integration experience** that handles everything automatically. Perfect for platforms that want to add monetized recommendations without writing custom code.
38
+
39
+ ### 3-Step Integration
40
+
41
+ **Step 1: Install the SDK**
42
+ ```bash
43
+ npm install admesh-ui-sdk
44
+ ```
45
+
46
+ **Step 2: Add a container element**
47
+ ```html
48
+ <!-- Place this div where you want recommendations to appear -->
49
+ <div id="admesh-recommendations"></div>
50
+ ```
51
+
52
+ **Step 3: Initialize and fetch recommendations**
53
+ ```typescript
54
+ import { AdMeshSDK } from 'admesh-ui-sdk';
55
+
56
+ // Initialize once with your API key
57
+ const admesh = new AdMeshSDK({
58
+ apiKey: 'your-api-key-here'
59
+ });
60
+
61
+ // Fetch and render recommendations automatically
62
+ await admesh.showRecommendations({
63
+ query: userQuery,
64
+ containerId: 'admesh-recommendations',
65
+ format: 'auto' // optional: auto-detects best format
66
+ });
67
+
68
+ // Close session when conversation ends
69
+ admesh.closeSession();
70
+ ```
71
+
72
+ ### Complete Example
73
+
74
+ ```typescript
75
+ import { AdMeshSDK } from 'admesh-ui-sdk';
76
+
77
+ const admesh = new AdMeshSDK({
78
+ apiKey: 'admesh_prod_your_key_here',
79
+ debug: true // optional: enable debug logging
80
+ });
81
+
82
+ // When user searches or asks a question
83
+ async function handleUserQuery(query: string) {
84
+ try {
85
+ await admesh.showRecommendations({
86
+ query: query,
87
+ containerId: 'admesh-recommendations',
88
+ format: 'auto',
89
+ onRecommendationClick: (adId, admeshLink) => {
90
+ console.log('User clicked recommendation:', adId);
91
+ // Optional: custom handling before opening link
92
+ }
93
+ });
94
+ } catch (error) {
95
+ console.error('Failed to fetch recommendations:', error);
96
+ }
97
+ }
98
+
99
+ // When conversation ends
100
+ function handleConversationEnd() {
101
+ admesh.closeSession();
102
+ }
103
+ ```
104
+
105
+ ### Session Management
106
+
107
+ The SDK automatically manages sessions for you:
108
+
109
+ - **Automatic Session Creation**: A new session is created on first recommendation fetch
110
+ - **Session Persistence**: Sessions are stored in localStorage and reused across page reloads
111
+ - **Session Timeout**: Sessions expire after 30 minutes of inactivity
112
+ - **Manual Control**: You can create new sessions or set custom session IDs
113
+
114
+ ```typescript
115
+ // Create a new session (e.g., for a new conversation)
116
+ const newSessionId = admesh.createNewSession();
117
+
118
+ // Get current session ID
119
+ const sessionId = admesh.getSessionId();
120
+
121
+ // Set a custom session ID
122
+ admesh.setSessionId('custom-session-id');
123
+
124
+ // Close session when done
125
+ admesh.closeSession();
126
+ ```
127
+
128
+ ### Configuration Options
129
+
130
+ ```typescript
131
+ const admesh = new AdMeshSDK({
132
+ apiKey: 'your-api-key', // Required
133
+ apiBaseUrl: 'https://api.useadmesh.com', // Optional: defaults to production
134
+ debug: false, // Optional: enable debug logging
135
+ theme: { // Optional: customize appearance
136
+ mode: 'light',
137
+ primaryColor: '#3b82f6',
138
+ borderRadius: '8px'
139
+ }
140
+ });
141
+ ```
142
+
143
+ ### What the SDK Handles Automatically
144
+
145
+ - ✅ API authentication with your API key
146
+ - ✅ Recommendation fetching from `/agent/recommend` endpoint
147
+ - ✅ Session creation and management
148
+ - ✅ Automatic rendering with appropriate UI components
149
+ - ✅ Exposure tracking (when recommendations are shown)
150
+ - ✅ Click tracking (when users click recommendations)
151
+ - ✅ Conversion tracking (when users complete actions)
152
+ - ✅ Error handling and logging
153
+ - ✅ Responsive design and theming
154
+
155
+ ### Advanced: Custom Rendering
156
+
157
+ If you need more control over rendering, you can use the individual components:
158
+
159
+ ```typescript
160
+ import { AdMeshLayout } from 'admesh-ui-sdk';
161
+
162
+ // Fetch recommendations manually
163
+ const response = await admesh.fetcher.fetchRecommendations({
164
+ query: 'best CRM for small business',
165
+ session_id: admesh.getSessionId()
166
+ });
167
+
168
+ // Render with custom configuration
169
+ <AdMeshLayout
170
+ response={{
171
+ layout_type: response.response?.layout_type,
172
+ recommendations: response.response?.recommendations || [],
173
+ citation_summary: response.response?.summary
174
+ }}
175
+ theme={{ mode: 'dark' }}
176
+ onRecommendationClick={(rec) => {
177
+ // Custom click handling
178
+ }}
179
+ />
180
+ ```
181
+
35
182
  ## ✨ Self-Contained Design
36
183
 
37
184
  **Zero configuration required!** The AdMesh UI SDK is completely self-contained and works like Google Ads or any professional SDK:
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { AdMeshLayout, AdMeshProductCard, AdMeshInlineCard, AdMeshEcommerceCards, AdMeshSummaryUnit, AdMeshSummaryLayout, AdMeshLinkTracker, AdMeshBadge } from './components';
2
2
  export { AdMeshViewabilityTracker } from './components/AdMeshViewabilityTracker';
3
+ export { AdMeshSDK, AdMeshSessionManager, AdMeshRecommendationFetcher, AdMeshTracker, AdMeshRenderer } from './sdk';
4
+ export type { AdMeshSDKConfig, ShowRecommendationsOptions, FetchRecommendationsParams, FetcherConfig, TrackerConfig, RenderOptions } from './sdk';
3
5
  export { useAdMeshTracker, setAdMeshTrackerConfig, buildAdMeshLink, extractTrackingData } from './hooks/useAdMeshTracker';
4
6
  export { useAdMeshStyles } from './hooks/useAdMeshStyles';
5
7
  export { useViewabilityTracker, setViewabilityTrackerConfig } from './hooks/useViewabilityTracker';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AAGjF,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC5B,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,WAAW,EACX,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACV,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EACV,oBAAoB,EACpB,WAAW,EACX,UAAU,EACV,SAAS,EACT,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,YAAY,EACb,MAAM,eAAe,CAAC;AAGvB,YAAY,EACV,uBAAuB,EACvB,oBAAoB,EACpB,UAAU,EACV,sBAAsB,EACtB,4BAA4B,EAC5B,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC7B,MAAM,mBAAmB,CAAC;AAG3B,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,eAAO,MAAM,cAAc;;;;;;;CAO1B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACZ,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAC;AAGjF,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,2BAA2B,EAC3B,aAAa,EACb,cAAc,EACf,MAAM,OAAO,CAAC;AAEf,YAAY,EACV,eAAe,EACf,0BAA0B,EAC1B,0BAA0B,EAC1B,aAAa,EACb,aAAa,EACb,aAAa,EACd,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,EACf,mBAAmB,EACpB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC5B,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,WAAW,EACX,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,UAAU,EACV,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACV,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EACV,oBAAoB,EACpB,WAAW,EACX,UAAU,EACV,SAAS,EACT,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,YAAY,EACb,MAAM,eAAe,CAAC;AAGvB,YAAY,EACV,uBAAuB,EACvB,oBAAoB,EACpB,UAAU,EACV,sBAAsB,EACtB,4BAA4B,EAC5B,yBAAyB,EACzB,yBAAyB,EACzB,yBAAyB,EACzB,wBAAwB,EACxB,uBAAuB,EACvB,4BAA4B,EAC5B,4BAA4B,EAC7B,MAAM,mBAAmB,CAAC;AAG3B,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,eAAO,MAAM,cAAc;;;;;;;CAO1B,CAAC"}
package/dist/index.js CHANGED
@@ -1,29 +1,37 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react");function Se(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Q={exports:{}},Y={};/**
1
+ "use strict";var Ht=Object.defineProperty;var Kt=(t,e,o)=>e in t?Ht(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var $=(t,e,o)=>Kt(t,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react"),Yt=require("react-dom");function at(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ge={exports:{}},se={};/**
2
2
  * @license React
3
- * react-jsx-runtime.production.js
3
+ * react-jsx-runtime.production.min.js
4
4
  *
5
- * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
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 je(){if(le)return Y;le=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(d,n,i){var a=null;if(i!==void 0&&(a=""+i),n.key!==void 0&&(a=""+n.key),"key"in n){i={};for(var c in n)c!=="key"&&(i[c]=n[c])}else i=n;return n=i.ref,{$$typeof:e,type:d,key:a,ref:n!==void 0?n:null,props:i}}return Y.Fragment=t,Y.jsx=o,Y.jsxs=o,Y}var G={};/**
9
+ */var Xe;function Gt(){if(Xe)return se;Xe=1;var t=w,e=Symbol.for("react.element"),o=Symbol.for("react.fragment"),d=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function n(l,h,b){var p,u={},g=null,x=null;b!==void 0&&(g=""+b),h.key!==void 0&&(g=""+h.key),h.ref!==void 0&&(x=h.ref);for(p in h)d.call(h,p)&&!i.hasOwnProperty(p)&&(u[p]=h[p]);if(l&&l.defaultProps)for(p in h=l.defaultProps,h)u[p]===void 0&&(u[p]=h[p]);return{$$typeof:e,type:l,key:g,ref:x,props:u,_owner:s.current}}return se.Fragment=o,se.jsx=n,se.jsxs=n,se}var ie={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
13
- * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
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 me;function Me(){return me||(me=1,process.env.NODE_ENV!=="production"&&function(){function e(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===k?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case S:return"Fragment";case j:return"Profiler";case y:return"StrictMode";case I:return"Suspense";case p:return"SuspenseList";case v:return"Activity"}if(typeof s=="object")switch(typeof s.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case C:return"Portal";case M:return(s.displayName||"Context")+".Provider";case R:return(s._context.displayName||"Context")+".Consumer";case V:var b=s.render;return s=s.displayName,s||(s=b.displayName||b.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case _:return b=s.displayName||null,b!==null?b:e(s.type)||"Memo";case l:b=s._payload,s=s._init;try{return e(s(b))}catch{}}return null}function t(s){return""+s}function o(s){try{t(s);var b=!1}catch{b=!0}if(b){b=console;var T=b.error,N=typeof Symbol=="function"&&Symbol.toStringTag&&s[Symbol.toStringTag]||s.constructor.name||"Object";return T.call(b,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",N),t(s)}}function d(s){if(s===S)return"<>";if(typeof s=="object"&&s!==null&&s.$$typeof===l)return"<...>";try{var b=e(s);return b?"<"+b+">":"<...>"}catch{return"<...>"}}function n(){var s=D.A;return s===null?null:s.getOwner()}function i(){return Error("react-stack-top-frame")}function a(s){if(L.call(s,"key")){var b=Object.getOwnPropertyDescriptor(s,"key").get;if(b&&b.isReactWarning)return!1}return s.key!==void 0}function c(s,b){function T(){U||(U=!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)",b))}T.isReactWarning=!0,Object.defineProperty(s,"key",{get:T,configurable:!0})}function u(){var s=e(this.type);return P[s]||(P[s]=!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.")),s=this.props.ref,s!==void 0?s:null}function g(s,b,T,N,$,F,te,re){return T=F.ref,s={$$typeof:x,type:s,key:b,props:F,_owner:$},(T!==void 0?T:null)!==null?Object.defineProperty(s,"ref",{enumerable:!1,get:u}):Object.defineProperty(s,"ref",{enumerable:!1,value:null}),s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(s,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(s,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.defineProperty(s,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:re}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s}function w(s,b,T,N,$,F,te,re){var A=b.children;if(A!==void 0)if(N)if(E(A)){for(N=0;N<A.length;N++)m(A[N]);Object.freeze&&Object.freeze(A)}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 m(A);if(L.call(b,"key")){A=e(s);var H=Object.keys(b).filter(function(Te){return Te!=="key"});N=0<H.length?"{key: someKey, "+H.join(": ..., ")+": ...}":"{key: someKey}",ee[A+N]||(H=0<H.length?"{"+H.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var Qe;function Jt(){return Qe||(Qe=1,process.env.NODE_ENV!=="production"&&function(){var t=w,e=Symbol.for("react.element"),o=Symbol.for("react.portal"),d=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),n=Symbol.for("react.provider"),l=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),x=Symbol.for("react.offscreen"),M=Symbol.iterator,N="@@iterator";function k(r){if(r===null||typeof r!="object")return null;var c=M&&r[M]||r[N];return typeof c=="function"?c:null}var A=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function j(r){{for(var c=arguments.length,m=new Array(c>1?c-1:0),v=1;v<c;v++)m[v-1]=arguments[v];D("error",r,m)}}function D(r,c,m){{var v=A.ReactDebugCurrentFrame,R=v.getStackAddendum();R!==""&&(c+="%s",m=m.concat([R]));var I=m.map(function(E){return String(E)});I.unshift("Warning: "+c),Function.prototype.apply.call(console[r],console,I)}}var H=!1,z=!1,y=!1,T=!1,f=!1,_;_=Symbol.for("react.module.reference");function S(r){return!!(typeof r=="string"||typeof r=="function"||r===d||r===i||f||r===s||r===b||r===p||T||r===x||H||z||y||typeof r=="object"&&r!==null&&(r.$$typeof===g||r.$$typeof===u||r.$$typeof===n||r.$$typeof===l||r.$$typeof===h||r.$$typeof===_||r.getModuleId!==void 0))}function K(r,c,m){var v=r.displayName;if(v)return v;var R=c.displayName||c.name||"";return R!==""?m+"("+R+")":m}function q(r){return r.displayName||"Context"}function P(r){if(r==null)return null;if(typeof r.tag=="number"&&j("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case d:return"Fragment";case o:return"Portal";case i:return"Profiler";case s:return"StrictMode";case b:return"Suspense";case p:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case l:var c=r;return q(c)+".Consumer";case n:var m=r;return q(m._context)+".Provider";case h:return K(r,r.render,"ForwardRef");case u:var v=r.displayName||null;return v!==null?v:P(r.type)||"Memo";case g:{var R=r,I=R._payload,E=R._init;try{return P(E(I))}catch{return null}}}return null}var B=Object.assign,Y=0,L,G,le,xe,ne,J,ue;function De(){}De.__reactDisabledLog=!0;function yt(){{if(Y===0){L=console.log,G=console.info,le=console.warn,xe=console.error,ne=console.group,J=console.groupCollapsed,ue=console.groupEnd;var r={configurable:!0,enumerable:!0,value:De,writable:!0};Object.defineProperties(console,{info:r,log:r,warn:r,error:r,group:r,groupCollapsed:r,groupEnd:r})}Y++}}function vt(){{if(Y--,Y===0){var r={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:B({},r,{value:L}),info:B({},r,{value:G}),warn:B({},r,{value:le}),error:B({},r,{value:xe}),group:B({},r,{value:ne}),groupCollapsed:B({},r,{value:J}),groupEnd:B({},r,{value:ue})})}Y<0&&j("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ye=A.ReactCurrentDispatcher,ve;function me(r,c,m){{if(ve===void 0)try{throw Error()}catch(R){var v=R.stack.trim().match(/\n( *(at )?)/);ve=v&&v[1]||""}return`
18
+ `+ve+r}}var we=!1,he;{var wt=typeof WeakMap=="function"?WeakMap:Map;he=new wt}function Fe(r,c){if(!r||we)return"";{var m=he.get(r);if(m!==void 0)return m}var v;we=!0;var R=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var I;I=ye.current,ye.current=null,yt();try{if(c){var E=function(){throw Error()};if(Object.defineProperty(E.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(E,[])}catch(U){v=U}Reflect.construct(r,[],E)}else{try{E.call()}catch(U){v=U}r.call(E.prototype)}}else{try{throw Error()}catch(U){v=U}r()}}catch(U){if(U&&v&&typeof U.stack=="string"){for(var C=U.stack.split(`
19
+ `),V=v.stack.split(`
20
+ `),F=C.length-1,O=V.length-1;F>=1&&O>=0&&C[F]!==V[O];)O--;for(;F>=1&&O>=0;F--,O--)if(C[F]!==V[O]){if(F!==1||O!==1)do if(F--,O--,O<0||C[F]!==V[O]){var W=`
21
+ `+C[F].replace(" at new "," at ");return r.displayName&&W.includes("<anonymous>")&&(W=W.replace("<anonymous>",r.displayName)),typeof r=="function"&&he.set(r,W),W}while(F>=1&&O>=0);break}}}finally{we=!1,ye.current=I,vt(),Error.prepareStackTrace=R}var te=r?r.displayName||r.name:"",X=te?me(te):"";return typeof r=="function"&&he.set(r,X),X}function kt(r,c,m){return Fe(r,!1)}function _t(r){var c=r.prototype;return!!(c&&c.isReactComponent)}function fe(r,c,m){if(r==null)return"";if(typeof r=="function")return Fe(r,_t(r));if(typeof r=="string")return me(r);switch(r){case b:return me("Suspense");case p:return me("SuspenseList")}if(typeof r=="object")switch(r.$$typeof){case h:return kt(r.render);case u:return fe(r.type,c,m);case g:{var v=r,R=v._payload,I=v._init;try{return fe(I(R),c,m)}catch{}}}return""}var ae=Object.prototype.hasOwnProperty,Oe={},Le=A.ReactDebugCurrentFrame;function pe(r){if(r){var c=r._owner,m=fe(r.type,r._source,c?c.type:null);Le.setExtraStackFrame(m)}else Le.setExtraStackFrame(null)}function St(r,c,m,v,R){{var I=Function.call.bind(ae);for(var E in r)if(I(r,E)){var C=void 0;try{if(typeof r[E]!="function"){var V=Error((v||"React class")+": "+m+" type `"+E+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[E]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw V.name="Invariant Violation",V}C=r[E](c,E,v,m,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(F){C=F}C&&!(C instanceof Error)&&(pe(R),j("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",v||"React class",m,E,typeof C),pe(null)),C instanceof Error&&!(C.message in Oe)&&(Oe[C.message]=!0,pe(R),j("Failed %s type: %s",m,C.message),pe(null))}}}var Ct=Array.isArray;function ke(r){return Ct(r)}function Tt(r){{var c=typeof Symbol=="function"&&Symbol.toStringTag,m=c&&r[Symbol.toStringTag]||r.constructor.name||"Object";return m}}function Et(r){try{return Ve(r),!1}catch{return!0}}function Ve(r){return""+r}function $e(r){if(Et(r))return j("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Tt(r)),Ve(r)}var Ue=A.ReactCurrentOwner,Mt={key:!0,ref:!0,__self:!0,__source:!0},Be,ze;function Rt(r){if(ae.call(r,"ref")){var c=Object.getOwnPropertyDescriptor(r,"ref").get;if(c&&c.isReactWarning)return!1}return r.ref!==void 0}function jt(r){if(ae.call(r,"key")){var c=Object.getOwnPropertyDescriptor(r,"key").get;if(c&&c.isReactWarning)return!1}return r.key!==void 0}function At(r,c){typeof r.ref=="string"&&Ue.current}function It(r,c){{var m=function(){Be||(Be=!0,j("%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://reactjs.org/link/special-props)",c))};m.isReactWarning=!0,Object.defineProperty(r,"key",{get:m,configurable:!0})}}function Pt(r,c){{var m=function(){ze||(ze=!0,j("%s: `ref` 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://reactjs.org/link/special-props)",c))};m.isReactWarning=!0,Object.defineProperty(r,"ref",{get:m,configurable:!0})}}var Nt=function(r,c,m,v,R,I,E){var C={$$typeof:e,type:r,key:c,ref:m,props:E,_owner:I};return C._store={},Object.defineProperty(C._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(C,"_self",{configurable:!1,enumerable:!1,writable:!1,value:v}),Object.defineProperty(C,"_source",{configurable:!1,enumerable:!1,writable:!1,value:R}),Object.freeze&&(Object.freeze(C.props),Object.freeze(C)),C};function Dt(r,c,m,v,R){{var I,E={},C=null,V=null;m!==void 0&&($e(m),C=""+m),jt(c)&&($e(c.key),C=""+c.key),Rt(c)&&(V=c.ref,At(c,R));for(I in c)ae.call(c,I)&&!Mt.hasOwnProperty(I)&&(E[I]=c[I]);if(r&&r.defaultProps){var F=r.defaultProps;for(I in F)E[I]===void 0&&(E[I]=F[I])}if(C||V){var O=typeof r=="function"?r.displayName||r.name||"Unknown":r;C&&It(E,O),V&&Pt(E,O)}return Nt(r,C,V,R,v,Ue.current,E)}}var _e=A.ReactCurrentOwner,qe=A.ReactDebugCurrentFrame;function ee(r){if(r){var c=r._owner,m=fe(r.type,r._source,c?c.type:null);qe.setExtraStackFrame(m)}else qe.setExtraStackFrame(null)}var Se;Se=!1;function Ce(r){return typeof r=="object"&&r!==null&&r.$$typeof===e}function We(){{if(_e.current){var r=P(_e.current.type);if(r)return`
22
+
23
+ Check the render method of \``+r+"`."}return""}}function Ft(r){return""}var He={};function Ot(r){{var c=We();if(!c){var m=typeof r=="string"?r:r.displayName||r.name;m&&(c=`
24
+
25
+ Check the top-level render call using <`+m+">.")}return c}}function Ke(r,c){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var m=Ot(c);if(He[m])return;He[m]=!0;var v="";r&&r._owner&&r._owner!==_e.current&&(v=" It was passed a child from "+P(r._owner.type)+"."),ee(r),j('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',m,v),ee(null)}}function Ye(r,c){{if(typeof r!="object")return;if(ke(r))for(var m=0;m<r.length;m++){var v=r[m];Ce(v)&&Ke(v,c)}else if(Ce(r))r._store&&(r._store.validated=!0);else if(r){var R=k(r);if(typeof R=="function"&&R!==r.entries)for(var I=R.call(r),E;!(E=I.next()).done;)Ce(E.value)&&Ke(E.value,c)}}}function Lt(r){{var c=r.type;if(c==null||typeof c=="string")return;var m;if(typeof c=="function")m=c.propTypes;else if(typeof c=="object"&&(c.$$typeof===h||c.$$typeof===u))m=c.propTypes;else return;if(m){var v=P(c);St(m,r.props,"prop",v,r)}else if(c.PropTypes!==void 0&&!Se){Se=!0;var R=P(c);j("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",R||"Unknown")}typeof c.getDefaultProps=="function"&&!c.getDefaultProps.isReactClassApproved&&j("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Vt(r){{for(var c=Object.keys(r.props),m=0;m<c.length;m++){var v=c[m];if(v!=="children"&&v!=="key"){ee(r),j("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",v),ee(null);break}}r.ref!==null&&(ee(r),j("Invalid attribute `ref` supplied to `React.Fragment`."),ee(null))}}var Ge={};function Je(r,c,m,v,R,I){{var E=S(r);if(!E){var C="";(r===void 0||typeof r=="object"&&r!==null&&Object.keys(r).length===0)&&(C+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var V=Ft();V?C+=V:C+=We();var F;r===null?F="null":ke(r)?F="array":r!==void 0&&r.$$typeof===e?(F="<"+(P(r.type)||"Unknown")+" />",C=" Did you accidentally export a JSX literal instead of a component?"):F=typeof r,j("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",F,C)}var O=Dt(r,c,m,R,I);if(O==null)return O;if(E){var W=c.children;if(W!==void 0)if(v)if(ke(W)){for(var te=0;te<W.length;te++)Ye(W[te],r);Object.freeze&&Object.freeze(W)}else j("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 Ye(W,r)}if(ae.call(c,"key")){var X=P(r),U=Object.keys(c).filter(function(Wt){return Wt!=="key"}),Te=U.length>0?"{key: someKey, "+U.join(": ..., ")+": ...}":"{key: someKey}";if(!Ge[X+Te]){var qt=U.length>0?"{"+U.join(": ..., ")+": ...}":"{}";j(`A props object containing a "key" prop is being spread into JSX:
18
26
  let props = %s;
19
27
  <%s {...props} />
20
28
  React keys must be passed directly to JSX without using spread:
21
29
  let props = %s;
22
- <%s key={someKey} {...props} />`,N,A,H,A),ee[A+N]=!0)}if(A=null,T!==void 0&&(o(T),A=""+T),a(b)&&(o(b.key),A=""+b.key),"key"in b){T={};for(var ae in b)ae!=="key"&&(T[ae]=b[ae])}else T=b;return A&&c(T,typeof s=="function"?s.displayName||s.name||"Unknown":s),g(s,A,F,$,n(),T,te,re)}function m(s){typeof s=="object"&&s!==null&&s.$$typeof===x&&s._store&&(s._store.validated=1)}var h=f,x=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),R=Symbol.for("react.consumer"),M=Symbol.for("react.context"),V=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),_=Symbol.for("react.memo"),l=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),k=Symbol.for("react.client.reference"),D=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=Object.prototype.hasOwnProperty,E=Array.isArray,O=console.createTask?console.createTask:function(){return null};h={"react-stack-bottom-frame":function(s){return s()}};var U,P={},z=h["react-stack-bottom-frame"].bind(h,i)(),K=O(d(i)),ee={};G.Fragment=S,G.jsx=function(s,b,T,N,$){var F=1e4>D.recentlyCreatedOwnerStacks++;return w(s,b,T,!1,N,$,F?Error("react-stack-top-frame"):z,F?O(d(s)):K)},G.jsxs=function(s,b,T,N,$){var F=1e4>D.recentlyCreatedOwnerStacks++;return w(s,b,T,!0,N,$,F?Error("react-stack-top-frame"):z,F?O(d(s)):K)}}()),G}var ue;function Ee(){return ue||(ue=1,process.env.NODE_ENV==="production"?Q.exports=je():Q.exports=Me()),Q.exports}var r=Ee();const Ne=e=>{try{return new URL(e),!0}catch{return!1}},pe=(e,t)=>{const o=new Map;t.forEach(u=>{u.admesh_link&&o.set(u.admesh_link,u)});const d=/\[([^\]]+)\]\(([^)]+)\)/g,n=[];let i=0,a,c=0;for(;(a=d.exec(e))!==null;){const[u,g,w]=a,m=o.get(w);a.index>i&&n.push(e.slice(i,a.index)),m?(c++,n.push(r.jsx("a",{href:m.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:m.ad_id,productId:m.product_id,title:m.title||m.recommendation_title,brand:m.brand,pricing:m.pricing,admeshLink:m.admesh_link,source:"summary"}),typeof window<"u"&&window.admeshTracker&&window.admeshTracker.trackClick({adId:m.ad_id,productId:m.product_id,admeshLink:m.admesh_link,source:"summary"})},children:g},`summary-link-${c}`))):(console.warn(`[AdMesh Summary] No recommendation found for link: [${g}](${w}), creating regular link`),Ne(w)?(c++,n.push(r.jsx("a",{href:w,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:g,url:w,source:"summary"}),typeof window<"u"&&window.admeshTracker&&window.admeshTracker.trackClick({url:w,linkText:g,source:"summary_unmatched"})},children:g},`summary-link-${c}`))):(console.warn(`[AdMesh Summary] Invalid URL in markdown link: [${g}](${w})`),n.push(g))),i=a.index+u.length}return i<e.length&&n.push(e.slice(i)),n},se=({summaryText:e,recommendations:t,theme:o,className:d="",style:n={},onLinkClick:i})=>{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 c=pe(e,[]);return r.jsx("div",{className:`admesh-summary-unit ${d}`,style:n,children:r.jsx("p",{className:"text-gray-700 dark:text-gray-300 leading-relaxed",children:c.map((u,g)=>r.jsx(f.Fragment,{children:u},g))})})}const a=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',...n},children:[r.jsx("div",{className:"summary-content",children:r.jsx("p",{className:"text-gray-700 dark:text-gray-300 leading-relaxed text-base",children:a.map((c,u)=>r.jsx(f.Fragment,{children:c},u))})}),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 oe={exports:{}};/*!
30
+ <%s key={someKey} {...props} />`,Te,X,qt,X),Ge[X+Te]=!0}}return r===d?Vt(O):Lt(O),O}}function $t(r,c,m){return Je(r,c,m,!0)}function Ut(r,c,m){return Je(r,c,m,!1)}var Bt=Ut,zt=$t;ie.Fragment=d,ie.jsx=Bt,ie.jsxs=zt}()),ie}var Ze;function Xt(){return Ze||(Ze=1,process.env.NODE_ENV==="production"?ge.exports=Gt():ge.exports=Jt()),ge.exports}var a=Xt();const Qt=t=>{try{return new URL(t),!0}catch{return!1}},et=(t,e)=>{const o=new Map;e.forEach(h=>{h.admesh_link&&o.set(h.admesh_link,h)});const d=/\[([^\]]+)\]\(([^)]+)\)/g,s=[];let i=0,n,l=0;for(;(n=d.exec(t))!==null;){const[h,b,p]=n,u=o.get(p);n.index>i&&s.push(t.slice(i,n.index)),u?(l++,s.push(a.jsx("a",{href:u.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:g=>{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,admeshLink:u.admesh_link,source:"summary"}),typeof window<"u"&&window.admeshTracker&&window.admeshTracker.trackClick({adId:u.ad_id,productId:u.product_id,admeshLink:u.admesh_link,source:"summary"})},children:b},`summary-link-${l}`))):(console.warn(`[AdMesh Summary] No recommendation found for link: [${b}](${p}), creating regular link`),Qt(p)?(l++,s.push(a.jsx("a",{href:p,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:g=>{console.log("AdMesh summary unmatched link clicked:",{linkText:b,url:p,source:"summary"}),typeof window<"u"&&window.admeshTracker&&window.admeshTracker.trackClick({url:p,linkText:b,source:"summary_unmatched"})},children:b},`summary-link-${l}`))):(console.warn(`[AdMesh Summary] Invalid URL in markdown link: [${b}](${p})`),s.push(b))),i=n.index+h.length}return i<t.length&&s.push(t.slice(i)),s},Ae=({summaryText:t,recommendations:e,theme:o,className:d="",style:s={},onLinkClick:i})=>{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 l=et(t,[]);return a.jsx("div",{className:`admesh-summary-unit ${d}`,style:s,children:a.jsx("p",{className:"text-gray-700 dark:text-gray-300 leading-relaxed",children:l.map((h,b)=>a.jsx(w.Fragment,{children:h},b))})})}const n=et(t,e);return a.jsxs("div",{className:`admesh-summary-unit ${d}`,style:{fontFamily:(o==null?void 0:o.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...s},children:[a.jsx("div",{className:"summary-content",children:a.jsx("p",{className:"text-gray-700 dark:text-gray-300 leading-relaxed text-base",children:n.map((l,h)=>a.jsx(w.Fragment,{children:l},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"})})]})};var Ee={exports:{}};/*!
23
31
  Copyright (c) 2018 Jed Watson.
24
32
  Licensed under the MIT License (MIT), see
25
33
  http://jedwatson.github.io/classnames
26
- */var he;function Ae(){return he||(he=1,function(e){(function(){var t={}.hasOwnProperty;function o(){for(var i="",a=0;a<arguments.length;a++){var c=arguments[a];c&&(i=n(i,d(c)))}return i}function d(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return o.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var a="";for(var c in i)t.call(i,c)&&i[c]&&(a=n(a,c));return a}function n(i,a){return a?i?i+" "+a:i+a:i}e.exports?(o.default=o,e.exports=o):window.classNames=o})()}(oe)),oe.exports}var Re=Ae();const W=Se(Re),Pe="https://api.useadmesh.com/track";let ie={apiBaseUrl:Pe,enabled:!0,debug:!1,retryAttempts:3,retryDelay:1e3};const Ie=e=>{ie={...ie,...e}},be=e=>{const[t,o]=f.useState(!1),[d,n]=f.useState(null),i=f.useMemo(()=>({...ie,...e}),[e]),a=f.useCallback((m,h)=>{i.debug&&console.log(`[AdMesh Tracker] ${m}`,h)},[i.debug]),c=f.useCallback(async(m,h)=>{if(!i.enabled){a("Tracking disabled, skipping event",{eventType:m,data:h});return}if(!h.adId||!h.admeshLink){const y="Missing required tracking data: adId and admeshLink are required";a(y,h),n(y);return}o(!0),n(null);const x={event_type:m,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};a(`Sending ${m} event`,x);let C=null;for(let y=1;y<=(i.retryAttempts||3);y++)try{const j=await fetch(`${i.apiBaseUrl}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!j.ok)throw new Error(`HTTP ${j.status}: ${j.statusText}`);const R=await j.json();a(`${m} event tracked successfully`,R),o(!1);return}catch(j){C=j,a(`Attempt ${y} failed for ${m} event`,j),y<(i.retryAttempts||3)&&await new Promise(R=>setTimeout(R,(i.retryDelay||1e3)*y))}const S=`Failed to track ${m} event after ${i.retryAttempts} attempts: ${C==null?void 0:C.message}`;a(S,C),n(S),o(!1)},[i,a]),u=f.useCallback(async m=>c("click",m),[c]),g=f.useCallback(async m=>c("view",m),[c]),w=f.useCallback(async m=>(!m.revenue&&!m.conversionType&&a("Warning: Conversion tracking without revenue or conversion type",m),c("conversion",m)),[c,a]);return{trackClick:u,trackView:g,trackConversion:w,isTracking:t,error:d}},De=(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(([n,i])=>{d.searchParams.set(n,i)}),d.toString()}catch(d){return console.warn("[AdMesh] Invalid URL provided to buildAdMeshLink:",e,d),e}},Le=(e,t)=>({adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,...t}),X=({adId:e,admeshLink:t,productId:o,children:d,trackingData:n,className:i,style:a})=>{const{trackClick:c,trackView:u}=be(),g=f.useRef(null),w=f.useRef(!1);f.useEffect(()=>{if(!g.current||w.current)return;const h=new IntersectionObserver(x=>{x.forEach(C=>{C.isIntersecting&&!w.current&&(w.current=!0,u({adId:e,admeshLink:t,productId:o,...n}).catch(console.error))})},{threshold:.5,rootMargin:"0px"});return h.observe(g.current),()=>{h.disconnect()}},[e,t,o,n,u]);const m=f.useCallback(async h=>{try{await c({adId:e,admeshLink:t,productId:o,...n})}catch(S){console.error("Failed to track click:",S)}h.target.closest("a")||window.open(t,"_blank","noopener,noreferrer")},[e,t,o,n,c]);return r.jsx("div",{ref:g,className:i,onClick:m,style:{cursor:"pointer",...a},children:d})};X.displayName="AdMeshLinkTracker";const Ve=`
34
+ */var tt;function Zt(){return tt||(tt=1,function(t){(function(){var e={}.hasOwnProperty;function o(){for(var i="",n=0;n<arguments.length;n++){var l=arguments[n];l&&(i=s(i,d(l)))}return i}function d(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return o.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var n="";for(var l in i)e.call(i,l)&&i[l]&&(n=s(n,l));return n}function s(i,n){return n?i?i+" "+n:i+n:i}t.exports?(o.default=o,t.exports=o):window.classNames=o})()}(Ee)),Ee.exports}var er=Zt();const Z=at(er),tr="https://api.useadmesh.com/track";let Ie={apiBaseUrl:tr,enabled:!0,debug:!1,retryAttempts:3,retryDelay:1e3};const rr=t=>{Ie={...Ie,...t}},st=t=>{const[e,o]=w.useState(!1),[d,s]=w.useState(null),i=w.useMemo(()=>({...Ie,...t}),[t]),n=w.useCallback((u,g)=>{i.debug&&console.log(`[AdMesh Tracker] ${u}`,g)},[i.debug]),l=w.useCallback(async(u,g)=>{if(!i.enabled){n("Tracking disabled, skipping event",{eventType:u,data:g});return}if(!g.adId||!g.admeshLink){const k="Missing required tracking data: adId and admeshLink are required";n(k,g),s(k);return}o(!0),s(null);const x={event_type:u,ad_id:g.adId,admesh_link:g.admeshLink,product_id:g.productId,user_id:g.userId,session_id:g.sessionId,revenue:g.revenue,conversion_type:g.conversionType,metadata:g.metadata,timestamp:new Date().toISOString(),user_agent:navigator.userAgent,referrer:document.referrer,page_url:window.location.href};n(`Sending ${u} event`,x);let M=null;for(let k=1;k<=(i.retryAttempts||3);k++)try{const A=await fetch(`${i.apiBaseUrl}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)});if(!A.ok)throw new Error(`HTTP ${A.status}: ${A.statusText}`);const j=await A.json();n(`${u} event tracked successfully`,j),o(!1);return}catch(A){M=A,n(`Attempt ${k} failed for ${u} event`,A),k<(i.retryAttempts||3)&&await new Promise(j=>setTimeout(j,(i.retryDelay||1e3)*k))}const N=`Failed to track ${u} event after ${i.retryAttempts} attempts: ${M==null?void 0:M.message}`;n(N,M),s(N),o(!1)},[i,n]),h=w.useCallback(async u=>l("click",u),[l]),b=w.useCallback(async u=>l("view",u),[l]),p=w.useCallback(async u=>(!u.revenue&&!u.conversionType&&n("Warning: Conversion tracking without revenue or conversion type",u),l("conversion",u)),[l,n]);return{trackClick:h,trackView:b,trackConversion:p,isTracking:e,error:d}},or=(t,e,o)=>{try{const d=new URL(t);return d.searchParams.set("ad_id",e),d.searchParams.set("utm_source","admesh"),d.searchParams.set("utm_medium","recommendation"),o&&Object.entries(o).forEach(([s,i])=>{d.searchParams.set(s,i)}),d.toString()}catch(d){return console.warn("[AdMesh] Invalid URL provided to buildAdMeshLink:",t,d),t}},nr=(t,e)=>({adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,...e}),ce=({adId:t,admeshLink:e,productId:o,children:d,trackingData:s,className:i,style:n})=>{const{trackClick:l,trackView:h}=st(),b=w.useRef(null),p=w.useRef(!1);w.useEffect(()=>{if(!b.current||p.current)return;const g=new IntersectionObserver(x=>{x.forEach(M=>{M.isIntersecting&&!p.current&&(p.current=!0,h({adId:t,admeshLink:e,productId:o,...s}).catch(console.error))})},{threshold:.5,rootMargin:"0px"});return g.observe(b.current),()=>{g.disconnect()}},[t,e,o,s,h]);const u=w.useCallback(async g=>{try{await l({adId:t,admeshLink:e,productId:o,...s})}catch(N){console.error("Failed to track click:",N)}g.target.closest("a")||window.open(e,"_blank","noopener,noreferrer")},[t,e,o,s,l]);return a.jsx("div",{ref:b,className:i,onClick:u,style:{cursor:"pointer",...n},children:d})};ce.displayName="AdMeshLinkTracker";const ar=`
27
35
  /* AdMesh UI SDK - Complete Self-Contained Styles */
28
36
 
29
37
  /* CSS Reset for AdMesh components */
@@ -691,7 +699,7 @@ React keys must be passed directly to JSX without using spread:
691
699
  .admesh-component .lg\\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
692
700
  .admesh-component .lg\\:col-span-1 { grid-column: span 1 / span 1; }
693
701
  }
694
- `;let ne=!1;const xe=()=>{f.useEffect(()=>{if(ne)return;const e=document.createElement("style");return e.id="admesh-ui-sdk-styles",e.textContent=Ve,document.getElementById("admesh-ui-sdk-styles")||(document.head.appendChild(e),ne=!0),()=>{const t=document.getElementById("admesh-ui-sdk-styles");t&&document.head.contains(t)&&(document.head.removeChild(t),ne=!1)}},[])},q=(e,t={})=>{const o=e.intent_match_score||0,d=t.customLabels||{};return o>=.8?d.partnerRecommendation||"Smart Pick":o>=.6?d.partnerMatch||"Partner Recommendation":o>=.3?d.promotedOption||"Promoted Match":d.relatedOption||"Related"},de=(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."},Fe=(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.",Oe=(e,t=!1)=>{const o=e.intent_match_score||0;return t?"Promoted Match":o>=.8?"Smart Pick":o>=.6?"Partner Recommendation":"Promoted Match"},ze=()=>"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.",$e=e=>({"Top Match":"Smart Pick",Sponsored:"Smart Pick","Perfect Fit":"Smart Pick","Great Match":"Partner Recommendation",Recommended:"Partner Recommendation","Good Fit":"Promoted Match",Featured:"Promoted Match","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,Ue=(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"},Be=e=>e.some(t=>(t.intent_match_score||0)>=.8),We=(e=!1)=>e?"":"Recommendations ",J=({recommendation:e,theme:t,showBadges:o=!0,showFeatures:d=!1,variation:n="default",expandable:i=!1,className:a,style:c})=>{var C,S,y,j,R,M,V,I,p,_,l,v,k,D,L,E,O,U;xe();const[u,g]=f.useState(!1);f.useMemo(()=>{var s;const P=[],z=q(e);(z==="Smart Pick"||z==="Partner Recommendation"||z==="Promoted Match")&&P.push("Top Match"),e.trial_days&&e.trial_days>0&&P.push("Trial Available");const K=["ai","artificial intelligence","machine learning","ml","automation"];return(((s=e.keywords)==null?void 0:s.some(b=>K.some(T=>b.toLowerCase().includes(T))))||e.title.toLowerCase().includes("ai"))&&P.push("AI Powered"),e.badges&&e.badges.length>0&&e.badges.forEach(b=>{["Top Match","Free Tier","AI Powered","Popular","New","Trial Available"].includes(b)&&!P.includes(b)&&P.push(b)}),P},[e]),Math.round((((C=e.meta)==null?void 0:C.intent_match_score)||e.intent_match_score||0)*100);const m=n==="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=W("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",a),x=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":(S=t.shadows)==null?void 0:S.small,"--admesh-shadow-md":(y=t.shadows)==null?void 0:y.medium,"--admesh-shadow-lg":(j=t.shadows)==null?void 0:j.large,"--admesh-spacing-sm":(R=t.spacing)==null?void 0:R.small,"--admesh-spacing-md":(M=t.spacing)==null?void 0:M.medium,"--admesh-spacing-lg":(V=t.spacing)==null?void 0:V.large,"--admesh-font-size-sm":(I=t.fontSize)==null?void 0:I.small,"--admesh-font-size-base":(p=t.fontSize)==null?void 0:p.base,"--admesh-font-size-lg":(_=t.fontSize)==null?void 0:_.large,"--admesh-font-size-title":(l=t.fontSize)==null?void 0:l.title,fontFamily:t.fontFamily,width:((k=(v=t.components)==null?void 0:v.productCard)==null?void 0:k.width)||"100%"}:{width:"100%"};return n==="simple"?r.jsxs("div",{className:W("admesh-component admesh-simple-ad","inline-block text-sm leading-relaxed",a),style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(D=t==null?void 0:t.components)==null?void 0:D.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.mode)==="dark"?"#000000":"#ffffff",backgroundColor:(t==null?void 0:t.mode)==="dark"?"#ffffff":"#000000",padding:"2px 6px",borderRadius:"4px",marginRight:"8px"},title:de(e,q(e)),children:q(e)}),r.jsxs("span",{style:{color:(t==null?void 0:t.mode)==="dark"?"#f3f4f6":"#374151",marginRight:"4px"},children:[m.description," "]}),r.jsx(X,{adId:((L=e.meta)==null?void 0:L.ad_id)||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.mode)==="dark"?"#ffffff":"#000000",textDecoration:"underline",cursor:"pointer",fontSize:"inherit",fontFamily:"inherit"},children:m.ctaText})})]}):r.jsx("div",{className:h,style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(E=t==null?void 0:t.components)==null?void 0:E.productCard,...c},"data-admesh-theme":t==null?void 0:t.mode,children:r.jsxs("div",{className:"h-full flex flex-col",style:x,children:[r.jsx("div",{className:"mb-1.5",children:r.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(t==null?void 0:t.mode)==="dark"?"#000000":"#ffffff",backgroundColor:(t==null?void 0:t.mode)==="dark"?"#ffffff":"#000000",padding:"2px 6px",borderRadius:"4px"},title:de(e,q(e)),children:q(e)})}),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-6 h-6 rounded flex-shrink-0",onError:P=>{P.target.style.display="none"}}),r.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm sm:text-base truncate",children:m.title})]}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx(X,{adId:((O=e.meta)==null?void 0:O.ad_id)||e.ad_id||"",admeshLink:e.admesh_link,productId:e.product_id,trackingData:{title:e.title,matchScore:((U=e.meta)==null?void 0:U.intent_match_score)||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 flex items-center transition-all duration-200 transform hover:scale-105 shadow-md hover:shadow-lg whitespace-nowrap",style:{backgroundColor:(t==null?void 0:t.accentColor)||"#000000",color:(t==null?void 0:t.mode)==="dark"?"#000000":"#ffffff"},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-3",children:r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 leading-snug",children:m.description})}),d&&e.features&&e.features.length>0&&r.jsxs("div",{className:"mb-2",children:[r.jsx("div",{className:"text-xs font-medium mb-1.5",style:{color:(t==null?void 0:t.mode)==="dark"?"#9ca3af":"#666666"},children:"Key Features"}),r.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.features.slice(0,4).map((P,z)=>r.jsxs("span",{className:"text-xs px-2 py-1 rounded-full border",style:{backgroundColor:(t==null?void 0:t.mode)==="dark"?"#111111":"#f5f5f5",color:(t==null?void 0:t.mode)==="dark"?"#ffffff":"#000000",borderColor:(t==null?void 0:t.mode)==="dark"?"#333333":"#e5e7eb"},children:[r.jsx("svg",{className:"h-3 w-3 mr-0.5 inline",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"})}),P]},z)),e.features.length>4&&r.jsxs("span",{className:"text-xs px-2 py-1",style:{color:(t==null?void 0:t.mode)==="dark"?"#9ca3af":"#666666"},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"})]})})]})})};J.displayName="AdMeshProductCard";const ye=({recommendations:e,title:t="Product Recommendations",showTitle:o=!0,className:d="",cardClassName:n="",onProductClick:i,showPricing:a=!0,showRatings:c=!0,showBrand:u=!0,showSource:g=!1,showShipping:w=!0,maxCards:m=10,cardWidth:h="md",theme:x="auto",borderRadius:C="md",shadow:S="sm"})=>{if(!e||e.length===0)return console.log("[AdMesh Ecommerce Cards] Empty recommendations - not rendering anything"),null;const y=e.slice(0,m),j=()=>{switch(h){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"}},R=()=>{switch(C){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-lg";case"lg":return"rounded-xl";default:return"rounded-lg"}},M=()=>{switch(S){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"}},V=()=>x==="dark"?"bg-gray-900 text-white":x==="light"?"bg-white text-gray-900":"bg-white dark:bg-gray-900 text-gray-900 dark:text-white",I=l=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:2}).format(l),p=l=>{const v=[],k=Math.floor(l),D=l%1!==0;for(let E=0;E<k;E++)v.push(r.jsx("span",{className:"text-yellow-400",children:"★"},E));D&&v.push(r.jsx("span",{className:"text-yellow-400",children:"☆"},"half"));const L=5-Math.ceil(l);for(let E=0;E<L;E++)v.push(r.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"☆"},`empty-${E}`));return v},_=l=>{if(i)i(l);else{const v=l.admesh_link||l.url;v&&window.open(v,"_blank","noopener,noreferrer")}};return(!products||products.length===0)&&(!e||e.length===0)?null:r.jsxs("div",{className:W("w-full",d),children:[o&&r.jsxs("div",{className:"mb-4",children:[r.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:t}),r.jsx("div",{className:"mt-1 h-0.5 w-12 bg-blue-500"})]}),r.jsxs("div",{className:"relative",children:[y.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:y.map(l=>{var k;const v=l.product_id||l.id||l.ad_id;return r.jsxs("div",{className:W(j(),R(),M(),V(),"flex-shrink-0 border border-gray-200 dark:border-gray-700 transition-all duration-200 cursor-pointer hover:scale-[1.02]",n),onClick:()=>_(l),children:[r.jsxs("div",{className:"relative aspect-square w-full overflow-hidden",children:[l.image_url?r.jsx("img",{src:l.image_url,alt:l.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"})})}),a&&l.discount_percentage&&l.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(l.discount_percentage),"%"]}),g&&l.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:l.source.toUpperCase()})]}),r.jsxs("div",{className:"p-3",children:[u&&l.brand&&r.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1 uppercase tracking-wide",children:l.brand}),r.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white line-clamp-2 mb-2 leading-tight",children:l.title}),c&&l.rating&&r.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[r.jsx("div",{className:"flex text-sm",children:p(l.rating)}),r.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["(",l.review_count||0,")"]})]}),a&&l.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(l.price)}),l.original_price&&l.original_price>l.price&&r.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 line-through",children:I(l.original_price)})]})}),w&&((k=l.shipping_info)==null?void 0:k.free_shipping_over_35)&&r.jsx("div",{className:"text-xs text-green-600 dark:text-green-400 font-medium",children:"Free shipping over $35"}),l.availability&&l.availability!=="unknown"&&r.jsx("div",{className:W("text-xs font-medium mt-1",l.availability==="in_stock"?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"),children:l.availability==="in_stock"?"In Stock":"Out of Stock"})]})]},v)})}),y.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:`
702
+ `;let Me=!1;const it=()=>{w.useEffect(()=>{if(Me)return;const t=document.createElement("style");return t.id="admesh-ui-sdk-styles",t.textContent=ar,document.getElementById("admesh-ui-sdk-styles")||(document.head.appendChild(t),Me=!0),()=>{const e=document.getElementById("admesh-ui-sdk-styles");e&&document.head.contains(e)&&(document.head.removeChild(e),Me=!1)}},[])},oe=(t,e={})=>{const o=t.intent_match_score||0,d=e.customLabels||{};return o>=.8?d.partnerRecommendation||"Smart Pick":o>=.6?d.partnerMatch||"Partner Recommendation":o>=.3?d.promotedOption||"Promoted Match":d.relatedOption||"Related"},Pe=(t,e)=>{const o=t.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."},sr=(t=!0,e=!1)=>t?e?"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.",ir=(t,e=!1)=>{const o=t.intent_match_score||0;return e?"Promoted Match":o>=.8?"Smart Pick":o>=.6?"Partner Recommendation":"Promoted Match"},dr=()=>"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.",cr=t=>({"Top Match":"Smart Pick",Sponsored:"Smart Pick","Perfect Fit":"Smart Pick","Great Match":"Partner Recommendation",Recommended:"Partner Recommendation","Good Fit":"Promoted Match",Featured:"Promoted Match","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"})[t]||t,lr=(t,e="button")=>{const o=t.recommendation_title||t.title;return e==="link"?o:t.trial_days&&t.trial_days>0?`Try ${o}`:"Learn More"},ur=t=>t.some(e=>(e.intent_match_score||0)>=.8),mr=(t=!1)=>t?"":"Recommendations ",de=({recommendation:t,theme:e,showBadges:o=!0,showFeatures:d=!1,variation:s="default",expandable:i=!1,className:n,style:l})=>{var M,N,k,A,j,D,H,z,y,T,f,_,S,K,q,P,B,Y;it();const[h,b]=w.useState(!1);w.useMemo(()=>{var ne;const L=[],G=oe(t);(G==="Smart Pick"||G==="Partner Recommendation"||G==="Promoted Match")&&L.push("Top Match"),t.trial_days&&t.trial_days>0&&L.push("Trial Available");const le=["ai","artificial intelligence","machine learning","ml","automation"];return(((ne=t.keywords)==null?void 0:ne.some(J=>le.some(ue=>J.toLowerCase().includes(ue))))||t.title.toLowerCase().includes("ai"))&&L.push("AI Powered"),t.badges&&t.badges.length>0&&t.badges.forEach(J=>{["Top Match","Free Tier","AI Powered","Popular","New","Trial Available"].includes(J)&&!L.includes(J)&&L.push(J)}),L},[t]),Math.round((((M=t.meta)==null?void 0:M.intent_match_score)||t.intent_match_score||0)*100);const u=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},g=Z("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",n),x=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":(N=e.shadows)==null?void 0:N.small,"--admesh-shadow-md":(k=e.shadows)==null?void 0:k.medium,"--admesh-shadow-lg":(A=e.shadows)==null?void 0:A.large,"--admesh-spacing-sm":(j=e.spacing)==null?void 0:j.small,"--admesh-spacing-md":(D=e.spacing)==null?void 0:D.medium,"--admesh-spacing-lg":(H=e.spacing)==null?void 0:H.large,"--admesh-font-size-sm":(z=e.fontSize)==null?void 0:z.small,"--admesh-font-size-base":(y=e.fontSize)==null?void 0:y.base,"--admesh-font-size-lg":(T=e.fontSize)==null?void 0:T.large,"--admesh-font-size-title":(f=e.fontSize)==null?void 0:f.title,fontFamily:e.fontFamily,width:((S=(_=e.components)==null?void 0:_.productCard)==null?void 0:S.width)||"100%"}:{width:"100%"};return s==="simple"?a.jsxs("div",{className:Z("admesh-component admesh-simple-ad","inline-block text-sm leading-relaxed",n),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,...l},"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:Pe(t,oe(t)),children:oe(t)}),a.jsxs("span",{style:{color:(e==null?void 0:e.mode)==="dark"?"#f3f4f6":"#374151",marginRight:"4px"},children:[u.description," "]}),a.jsx(ce,{adId:((q=t.meta)==null?void 0:q.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:u.ctaText})})]}):a.jsx("div",{className:g,style:{fontFamily:(e==null?void 0:e.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(P=e==null?void 0:e.components)==null?void 0:P.productCard,...l},"data-admesh-theme":e==null?void 0:e.mode,children:a.jsxs("div",{className:"h-full flex flex-col",style:x,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:Pe(t,oe(t)),children:oe(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:L=>{L.target.style.display="none"}}),a.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm sm:text-base truncate",children:u.title})]}),a.jsx("div",{className:"flex-shrink-0",children:a.jsx(ce,{adId:((B=t.meta)==null?void 0:B.ad_id)||t.ad_id||"",admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:((Y=t.meta)==null?void 0:Y.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:u.description})}),d&&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((L,G)=>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"})}),L]},G)),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"})]})})]})})};de.displayName="AdMeshProductCard";const dt=({recommendations:t,title:e="Product Recommendations",showTitle:o=!0,className:d="",cardClassName:s="",onProductClick:i,showPricing:n=!0,showRatings:l=!0,showBrand:h=!0,showSource:b=!1,showShipping:p=!0,maxCards:u=10,cardWidth:g="md",theme:x="auto",borderRadius:M="md",shadow:N="sm"})=>{if(!t||t.length===0)return console.log("[AdMesh Ecommerce Cards] Empty recommendations - not rendering anything"),null;const k=t.slice(0,u),A=()=>{switch(g){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"}},j=()=>{switch(M){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-lg";case"lg":return"rounded-xl";default:return"rounded-lg"}},D=()=>{switch(N){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"}},H=()=>x==="dark"?"bg-gray-900 text-white":x==="light"?"bg-white text-gray-900":"bg-white dark:bg-gray-900 text-gray-900 dark:text-white",z=f=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:2}).format(f),y=f=>{const _=[],S=Math.floor(f),K=f%1!==0;for(let P=0;P<S;P++)_.push(a.jsx("span",{className:"text-yellow-400",children:"★"},P));K&&_.push(a.jsx("span",{className:"text-yellow-400",children:"☆"},"half"));const q=5-Math.ceil(f);for(let P=0;P<q;P++)_.push(a.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"☆"},`empty-${P}`));return _},T=f=>{if(i)i(f);else{const _=f.admesh_link||f.url;_&&window.open(_,"_blank","noopener,noreferrer")}};return(!products||products.length===0)&&(!t||t.length===0)?null:a.jsxs("div",{className:Z("w-full",d),children:[o&&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:[k.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:k.map(f=>{var S;const _=f.product_id||f.id||f.ad_id;return a.jsxs("div",{className:Z(A(),j(),D(),H(),"flex-shrink-0 border border-gray-200 dark:border-gray-700 transition-all duration-200 cursor-pointer hover:scale-[1.02]",s),onClick:()=>T(f),children:[a.jsxs("div",{className:"relative aspect-square w-full overflow-hidden",children:[f.image_url?a.jsx("img",{src:f.image_url,alt:f.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"})})}),n&&f.discount_percentage&&f.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(f.discount_percentage),"%"]}),b&&f.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:f.source.toUpperCase()})]}),a.jsxs("div",{className:"p-3",children:[h&&f.brand&&a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1 uppercase tracking-wide",children:f.brand}),a.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white line-clamp-2 mb-2 leading-tight",children:f.title}),l&&f.rating&&a.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[a.jsx("div",{className:"flex text-sm",children:y(f.rating)}),a.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["(",f.review_count||0,")"]})]}),n&&f.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:z(f.price)}),f.original_price&&f.original_price>f.price&&a.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 line-through",children:z(f.original_price)})]})}),p&&((S=f.shipping_info)==null?void 0:S.free_shipping_over_35)&&a.jsx("div",{className:"text-xs text-green-600 dark:text-green-400 font-medium",children:"Free shipping over $35"}),f.availability&&f.availability!=="unknown"&&a.jsx("div",{className:Z("text-xs font-medium mt-1",f.availability==="in_stock"?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"),children:f.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:`
695
703
  .scrollbar-hide {
696
704
  -ms-overflow-style: none;
697
705
  scrollbar-width: none;
@@ -705,5 +713,5 @@ React keys must be passed directly to JSX without using spread:
705
713
  -webkit-box-orient: vertical;
706
714
  overflow: hidden;
707
715
  }
708
- `}})]})},He=e=>{var n,i,a;const t=[];if(!e)return{isValid:!1,isEmpty:!0,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=((n=e.recommendations)==null?void 0:n.filter(c=>c&&c.admesh_link&&(c.title||c.recommendation_title)))||[],d=((i=e.recommendations)==null?void 0:i.length)===0;return o.length===0&&!d&&t.push("No valid recommendations found (missing admesh_link or title)"),{isValid:o.length>0,isEmpty:d,validCount:o.length,totalCount:((a=e.recommendations)==null?void 0:a.length)||0,warnings:t}},we=({response:e,theme:t,className:o="",style:d={},onRecommendationClick:n,onLinkClick:i})=>{const a=He(e);if(a.warnings.length>0&&console.warn("[AdMesh Summary Layout] Validation warnings:",a.warnings),a.isEmpty)return console.log("[AdMesh Summary Layout] Empty recommendations array - not rendering anything"),null;if(!a.isValid)return console.error("[AdMesh Summary Layout] Invalid response object"),null;const{layout_type:c="citation",citation_summary:u,recommendations:g=[],requires_summary:w=!0}=e;console.log(`[AdMesh Summary Layout] Rendering ${c} layout with ${a.validCount}/${a.totalCount} valid recommendations`);const m=()=>{switch(c){case"citation":return u&&w?r.jsx(se,{summaryText:u,recommendations:g,theme:t,onLinkClick:i}):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(J,{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,x)=>r.jsx(J,{recommendation:h,theme:t,className:"mb-4"},h.ad_id||`rec-${x}`))});case"ecommerce":return r.jsx(ye,{recommendations:g.slice(0,3),theme:(t==null?void 0:t.mode)||"light"});default:return console.warn(`[AdMesh Summary Layout] Unknown layout type: ${c}`),u?r.jsx(se,{summaryText:u,recommendations:g,theme:t,onLinkClick:i}):r.jsx(J,{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',...d},children:m()})},qe=({response:e,theme:t,className:o,style:d,onRecommendationClick:n,onLinkClick:i})=>e?e.recommendations&&Array.isArray(e.recommendations)&&e.recommendations.length===0?(console.log("[AdMeshLayout] Empty recommendations array - not rendering anything"),null):r.jsx(we,{response:e,theme:t,className:o,style:d,onRecommendationClick:n,onLinkClick:i}):(console.error("[AdMeshLayout] response prop is required"),null),ve=({recommendation:e,theme:t,variation:o="default",expandable:d=!1,className:n,style:i})=>{var m,h,x,C,S;const[a,c]=f.useState(!1),g=(()=>{const y=e.content_variations;return o==="question"&&(y!=null&&y.question)?{title:y.question.cta||e.recommendation_title||e.title,description:y.question.text,ctaText:y.question.cta||e.recommendation_title||e.title}:o==="statement"&&(y!=null&&y.statement)?{title:e.recommendation_title||e.title,description:y.statement.text,ctaText:y.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}})(),w=W("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")},n);return r.jsx("div",{className:w,style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:((h=(m=t==null?void 0:t.components)==null?void 0:m.inlineRecommendation)==null?void 0:h.width)||"100%",...(x=t==null?void 0:t.components)==null?void 0:x.productCard,...i},"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:y=>{y.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(X,{adId:((C=e.meta)==null?void 0:C.ad_id)||e.ad_id||"",admeshLink:e.admesh_link,productId:e.product_id,trackingData:{title:e.title,matchScore:((S=e.meta)==null?void 0:S.intent_match_score)||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"})]})})]})})};ve.displayName="AdMeshInlineCard";const Ye={"Top Match":"primary","Free Tier":"success","AI Powered":"secondary",Popular:"warning",New:"primary","Trial Available":"success"},Ge={"Top Match":"★","Free Tier":"◆","AI Powered":"◉",Popular:"▲",New:"●","Trial Available":"◈"},ke=({type:e,variant:t,size:o="md",className:d,style:n})=>{const i=t||Ye[e]||"secondary",a=Ge[e],c=W("admesh-component","admesh-badge",`admesh-badge--${i}`,`admesh-badge--${o}`,d);return r.jsxs("span",{className:c,style:n,children:[a&&r.jsx("span",{className:"admesh-badge__icon",children:a}),r.jsx("span",{className:"admesh-badge__text",children:e})]})};ke.displayName="AdMeshBadge";function Je(e,t,o){const n=e*t>242500;return{...{visibilityThreshold:n?.3:.5,minimumDuration:1e3,isLargeAd:n},...o}}function Xe(e){return e<768?"mobile":e<1024?"tablet":"desktop"}function Ke(e){const t=e.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight,d=window.innerWidth||document.documentElement.clientWidth,n=t.height,i=t.width;if(n===0||i===0)return 0;const a=Math.max(0,t.top),c=Math.min(o,t.bottom),u=Math.max(0,t.left),g=Math.min(d,t.right),w=Math.max(0,c-a),m=Math.max(0,g-u),h=w*m,x=n*i;return x>0?h/x:0}function fe(){const e=window.innerHeight,t=document.documentElement.scrollHeight,o=window.pageYOffset||document.documentElement.scrollTop,d=t-e;return d<=0?100:Math.min(100,o/d*100)}function Qe(e){const t=e.getBoundingClientRect(),o=window.pageYOffset||document.documentElement.scrollTop,d=window.pageXOffset||document.documentElement.scrollLeft;return{top:t.top+o,left:t.left+d}}function Ze(e){const t=e.getBoundingClientRect(),o=Qe(e),d=window.innerWidth||document.documentElement.clientWidth,n=window.innerHeight||document.documentElement.clientHeight,i=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;return{pageUrl:window.location.href,pageTitle:document.title,referrer:document.referrer,deviceType:Xe(d),viewportWidth:d,viewportHeight:n,adWidth:t.width,adHeight:t.height,adPositionTop:o.top,adPositionLeft:o.left,isDarkMode:i,language:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}}function et(){return`session_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}function tt(){return`batch_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}function rt(e,t,o){return e>=o.visibilityThreshold&&t>=o.minimumDuration}function Z(e=new Date){return e.toISOString()}function at(e){return e.length===0?0:e.reduce((o,d)=>o+d,0)/e.length}function ge(e,t){let o;return function(...n){o||(e(...n),o=!0,setTimeout(()=>o=!1,t))}}async function ot(e,t,o=3,d=1e3){let n=null;for(let i=0;i<o;i++){try{const a=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(a.ok)return!0;n=new Error(`HTTP ${a.status}: ${a.statusText}`)}catch(a){n=a}i<o-1&&await new Promise(a=>setTimeout(a,d*Math.pow(2,i)))}return console.error("[AdMesh Viewability] Failed to send analytics event:",n),!1}async function nt(e,t,o,d=3,n=1e3){if(e.length===0)return!0;const i={batchId:tt(),sessionId:t,createdAt:Z(),events:e,eventCount:e.length};let a=null;for(let c=0;c<d;c++){try{const u=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(u.ok)return!0;a=new Error(`HTTP ${u.status}: ${u.statusText}`)}catch(u){a=u}c<d-1&&await new Promise(u=>setTimeout(u,n*Math.pow(2,c)))}return console.error("[AdMesh Viewability] Failed to send analytics batch:",a),!1}const st={enabled:!0,apiEndpoint:"https://api.useadmesh.com/analytics/ui-sdk/viewability",enableBatching:!0,batchSize:10,batchTimeout:5e3,debug:!1,enableRetry:!0,maxRetries:3,retryDelay:1e3};let ce=st;const it=e=>{ce={...ce,...e}};function _e({adId:e,productId:t,offerId:o,agentId:d,elementRef:n,config:i}){const a={...ce,...i},c=f.useRef(et()),[u,g]=f.useState({isVisible:!1,isViewable:!1,visibilityPercentage:0,timeMetrics:{loadedAt:Z(),totalVisibleDuration:0,totalViewableDuration:0,totalHoverDuration:0,totalFocusDuration:0},engagementMetrics:{currentScrollDepth:0,viewportEnterCount:0,viewportExitCount:0,hoverCount:0,wasClicked:!1,maxVisibilityPercentage:0,averageVisibilityPercentage:0},isTracking:a.enabled}),w=f.useRef(null),m=f.useRef(null),h=f.useRef(null),x=f.useRef(null),C=f.useRef(null),S=f.useRef([]),y=f.useRef([]),j=f.useRef(null),R=f.useCallback((p,_)=>{a.debug&&console.log(`[AdMesh Viewability] ${p}`,_)},[a.debug]),M=f.useCallback(async(p,_)=>{if(!a.enabled||!n.current||!w.current)return;const l=Ze(n.current),v={eventType:p,timestamp:Z(),sessionId:c.current,adId:e,productId:t,offerId:o,agentId:d,timeMetrics:u.timeMetrics,engagementMetrics:u.engagementMetrics,contextMetrics:l,mrcStandards:w.current,isViewable:u.isViewable,metadata:_};R(`Event: ${p}`,v),a.onEvent&&a.onEvent(v),a.enableBatching?(y.current.push(v),y.current.length>=a.batchSize?await V():(j.current&&clearTimeout(j.current),j.current=setTimeout(V,a.batchTimeout))):await ot(v,a.apiEndpoint,a.maxRetries,a.retryDelay)},[a,e,t,o,d,n,u,R]),V=f.useCallback(async()=>{if(y.current.length===0)return;const p=[...y.current];y.current=[],j.current&&(clearTimeout(j.current),j.current=null),await nt(p,c.current,a.apiEndpoint,a.maxRetries,a.retryDelay)&&a.onBatchSent&&a.onBatchSent({batchId:`batch_${Date.now()}`,sessionId:c.current,createdAt:Z(),events:p,eventCount:p.length})},[a]),I=f.useCallback(ge(()=>{if(!n.current)return;const p=Ke(n.current),_=Date.now(),l=new Date(u.timeMetrics.loadedAt).getTime();g(v=>{const k={...v};p>0&&S.current.push(p);const D=v.isVisible,L=p>0;if(L&&!D)m.current=_,k.engagementMetrics.viewportEnterCount++,k.timeMetrics.timeToFirstVisible||(k.timeMetrics.timeToFirstVisible=_-l,k.engagementMetrics.scrollDepthAtFirstVisible=fe(),M("ad_visible"));else if(!L&&D){if(m.current){const E=_-m.current;k.timeMetrics.totalVisibleDuration+=E,m.current=null}k.engagementMetrics.viewportExitCount++,M("ad_hidden")}else if(L&&D&&m.current){const E=_-m.current;k.timeMetrics.totalVisibleDuration+=E,m.current=_}if(k.isVisible=L,k.visibilityPercentage=p,p>k.engagementMetrics.maxVisibilityPercentage&&(k.engagementMetrics.maxVisibilityPercentage=p),S.current.length>0&&(k.engagementMetrics.averageVisibilityPercentage=at(S.current)),w.current){const E=v.isViewable,O=rt(p,k.timeMetrics.totalVisibleDuration,w.current);if(O&&!E)k.isViewable=!0,k.timeMetrics.timeToViewable=_-l,h.current=_,M("ad_viewable");else if(O&&E&&h.current){const U=_-h.current;k.timeMetrics.totalViewableDuration+=U,h.current=_}}return k.engagementMetrics.currentScrollDepth=fe(),k})},100),[n,u.timeMetrics.loadedAt,M]);return f.useEffect(()=>{if(!n.current)return;const p=n.current.getBoundingClientRect();w.current=Je(p.width,p.height,a.mrcStandards),R("Initialized MRC standards",w.current),M("ad_loaded")},[n,a.mrcStandards,R,M]),f.useEffect(()=>{if(!a.enabled||!n.current)return;const p=new IntersectionObserver(_=>{_.forEach(()=>{I()})},{threshold:[0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1],rootMargin:"0px"});return p.observe(n.current),()=>{p.disconnect()}},[a.enabled,n,I]),f.useEffect(()=>{if(!a.enabled)return;const p=ge(()=>{I()},100);return window.addEventListener("scroll",p,{passive:!0}),()=>window.removeEventListener("scroll",p)},[a.enabled,I]),f.useEffect(()=>{if(!a.enabled||!n.current)return;const p=n.current,_=()=>{x.current=Date.now(),g(v=>({...v,engagementMetrics:{...v.engagementMetrics,hoverCount:v.engagementMetrics.hoverCount+1}})),M("ad_hover_start")},l=()=>{if(x.current){const v=Date.now()-x.current;g(k=>({...k,timeMetrics:{...k.timeMetrics,totalHoverDuration:k.timeMetrics.totalHoverDuration+v}})),x.current=null,M("ad_hover_end",{hoverDuration:v})}};return p.addEventListener("mouseenter",_),p.addEventListener("mouseleave",l),()=>{p.removeEventListener("mouseenter",_),p.removeEventListener("mouseleave",l)}},[a.enabled,n,M]),f.useEffect(()=>{if(!a.enabled||!n.current)return;const p=n.current,_=()=>{C.current=Date.now(),M("ad_focus")},l=()=>{if(C.current){const v=Date.now()-C.current;g(k=>({...k,timeMetrics:{...k.timeMetrics,totalFocusDuration:k.timeMetrics.totalFocusDuration+v}})),C.current=null,M("ad_blur",{focusDuration:v})}};return p.addEventListener("focus",_),p.addEventListener("blur",l),()=>{p.removeEventListener("focus",_),p.removeEventListener("blur",l)}},[a.enabled,n,M]),f.useEffect(()=>{if(!a.enabled||!n.current)return;const p=n.current,_=()=>{g(l=>({...l,engagementMetrics:{...l.engagementMetrics,wasClicked:!0}})),M("ad_click")};return p.addEventListener("click",_),()=>{p.removeEventListener("click",_)}},[a.enabled,n,M]),f.useEffect(()=>()=>{const p=Date.now(),_=new Date(u.timeMetrics.loadedAt).getTime(),l=p-_;g(v=>({...v,timeMetrics:{...v.timeMetrics,sessionDuration:l}})),M("ad_unloaded",{sessionDuration:l}),V()},[]),u}const Ce=({adId:e,productId:t,offerId:o,agentId:d,children:n,config:i,className:a,style:c,onViewabilityChange:u,onVisible:g,onViewable:w,onClick:m})=>{const h=f.useRef(null),x=_e({adId:e,productId:t,offerId:o,agentId:d,elementRef:h,config:i}),C=f.useRef(x.isViewable);f.useEffect(()=>{x.isViewable!==C.current&&(C.current=x.isViewable,u&&u(x.isViewable),x.isViewable&&w&&w())},[x.isViewable,u,w]);const S=f.useRef(x.isVisible);f.useEffect(()=>{x.isVisible!==S.current&&(S.current=x.isVisible,x.isVisible&&g&&g())},[x.isVisible,g]);const y=j=>{m&&m()};return r.jsx("div",{ref:h,className:a,style:c,onClick:y,"data-admesh-viewability-tracker":!0,"data-ad-id":e,"data-is-viewable":x.isViewable,"data-is-visible":x.isVisible,"data-visibility-percentage":x.visibilityPercentage.toFixed(2),children:n})};Ce.displayName="AdMeshViewabilityTracker";const B=(e={})=>{const t={mode:"light",primaryColor:"#000000",secondaryColor:"#666666",accentColor:"#000000",backgroundColor:"#ffffff",surfaceColor:"#ffffff",borderColor:"#e5e7eb",textColor:"#000000",textSecondaryColor:"#666666",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:"#000000",secondary:"#666666",accent:"#000000"},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 lt(o)},dt=(e={})=>B({...{mode:"dark",primaryColor:"#ffffff",secondaryColor:"#9ca3af",accentColor:"#ffffff",backgroundColor:"#000000",surfaceColor:"#111111",borderColor:"#333333",textColor:"#ffffff",textSecondaryColor:"#9ca3af",shadows:{small:"0 1px 3px rgba(255, 255, 255, 0.1)",medium:"0 4px 6px rgba(255, 255, 255, 0.1)",large:"0 10px 15px rgba(255, 255, 255, 0.1)"},gradients:{primary:"#ffffff",secondary:"#9ca3af",accent:"#ffffff"}},...e}),ct={get minimal(){return B({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)"},gradients:{primary:"#000000",secondary:"#666666",accent:"#000000"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}})},get vibrant(){return B({primaryColor:"#8b5cf6",secondaryColor:"#06b6d4",accentColor:"#f59e0b",borderRadius:"12px",gradients:{primary:"#8b5cf6",secondary:"#06b6d4",accent:"#f59e0b"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}})},get corporate(){return B({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 B({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%"}}})}},lt=(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}}},mt=(...e)=>{const t=B();return e.reduce((o,d)=>d?{...o,...d,mode:d.mode||o.mode}:o,t)},ut=e=>{var o,d,n,i,a,c;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:((n=t.getPropertyValue("--admesh-background-color"))==null?void 0:n.trim())||void 0,textColor:((i=t.getPropertyValue("--admesh-text-color"))==null?void 0:i.trim())||void 0,borderRadius:((a=t.getPropertyValue("--admesh-border-radius"))==null?void 0:a.trim())||void 0,fontFamily:((c=t.getPropertyValue("--admesh-font-family"))==null?void 0:c.trim())||void 0}},pt="0.2.1",ht={trackingEnabled:!0,debug:!1,theme:{mode:"light",accentColor:"#2563eb"}};exports.AdMeshBadge=ke;exports.AdMeshEcommerceCards=ye;exports.AdMeshInlineCard=ve;exports.AdMeshLayout=qe;exports.AdMeshLinkTracker=X;exports.AdMeshProductCard=J;exports.AdMeshSummaryLayout=we;exports.AdMeshSummaryUnit=se;exports.AdMeshViewabilityTracker=Ce;exports.DEFAULT_CONFIG=ht;exports.VERSION=pt;exports.buildAdMeshLink=De;exports.createAdMeshTheme=B;exports.createDarkTheme=dt;exports.extractTrackingData=Le;exports.getBadgeText=$e;exports.getCtaText=Ue;exports.getInlineDisclosure=Oe;exports.getInlineTooltip=ze;exports.getLabelTooltip=de;exports.getPoweredByText=We;exports.getRecommendationLabel=q;exports.getSectionDisclosure=Fe;exports.hasHighQualityMatches=Be;exports.mergeThemes=mt;exports.setAdMeshTrackerConfig=Ie;exports.setViewabilityTrackerConfig=it;exports.themeFromCSSProperties=ut;exports.themePresets=ct;exports.useAdMeshStyles=xe;exports.useAdMeshTracker=be;exports.useViewabilityTracker=_e;
716
+ `}})]})},hr=t=>{var s,i,n;const e=[];if(!t)return{isValid:!1,isEmpty:!0,warnings:["No response object provided"]};(!t.recommendations||!Array.isArray(t.recommendations))&&e.push("No recommendations array found in response"),t.layout_type==="citation"&&!t.citation_summary&&e.push("Citation layout specified but no citation_summary provided");const o=((s=t.recommendations)==null?void 0:s.filter(l=>l&&l.admesh_link&&(l.title||l.recommendation_title)))||[],d=((i=t.recommendations)==null?void 0:i.length)===0;return o.length===0&&!d&&e.push("No valid recommendations found (missing admesh_link or title)"),{isValid:o.length>0,isEmpty:d,validCount:o.length,totalCount:((n=t.recommendations)==null?void 0:n.length)||0,warnings:e}},ct=({response:t,theme:e,className:o="",style:d={},onRecommendationClick:s,onLinkClick:i})=>{const n=hr(t);if(n.warnings.length>0&&console.warn("[AdMesh Summary Layout] Validation warnings:",n.warnings),n.isEmpty)return console.log("[AdMesh Summary Layout] Empty recommendations array - not rendering anything"),null;if(!n.isValid)return console.error("[AdMesh Summary Layout] Invalid response object"),null;const{layout_type:l="citation",citation_summary:h,recommendations:b=[],requires_summary:p=!0}=t;console.log(`[AdMesh Summary Layout] Rendering ${l} layout with ${n.validCount}/${n.totalCount} valid recommendations`);const u=()=>{switch(l){case"citation":return h&&p?a.jsx(Ae,{summaryText:h,recommendations:b,theme:e,onLinkClick:i}):a.jsxs("div",{className:"fallback-citation",children:[a.jsx("p",{className:"text-gray-700 dark:text-gray-300 mb-3",children:"Based on your query, I'd recommend checking out these options:"}),a.jsx(de,{recommendation:b[0],theme:e})]});case"product_cards":case"product":return a.jsx("div",{className:"product-cards-layout",children:b.slice(0,3).map((g,x)=>a.jsx(de,{recommendation:g,theme:e,className:"mb-4"},g.ad_id||`rec-${x}`))});case"ecommerce":return a.jsx(dt,{recommendations:b.slice(0,3),theme:(e==null?void 0:e.mode)||"light"});default:return console.warn(`[AdMesh Summary Layout] Unknown layout type: ${l}`),h?a.jsx(Ae,{summaryText:h,recommendations:b,theme:e,onLinkClick:i}):a.jsx(de,{recommendation:b[0],theme:e})}};return a.jsx("div",{className:`admesh-summary-layout admesh-layout-${l} ${o}`,style:{fontFamily:(e==null?void 0:e.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...d},children:u()})},lt=({response:t,theme:e,className:o,style:d,onRecommendationClick:s,onLinkClick:i})=>t?t.recommendations&&Array.isArray(t.recommendations)&&t.recommendations.length===0?(console.log("[AdMeshLayout] Empty recommendations array - not rendering anything"),null):a.jsx(ct,{response:t,theme:e,className:o,style:d,onRecommendationClick:s,onLinkClick:i}):(console.error("[AdMeshLayout] response prop is required"),null),ut=({recommendation:t,theme:e,variation:o="default",expandable:d=!1,className:s,style:i})=>{var u,g,x,M,N;const[n,l]=w.useState(!1),b=(()=>{const k=t.content_variations;return o==="question"&&(k!=null&&k.question)?{title:k.question.cta||t.recommendation_title||t.title,description:k.question.text,ctaText:k.question.cta||t.recommendation_title||t.title}:o==="statement"&&(k!=null&&k.statement)?{title:t.recommendation_title||t.title,description:k.statement.text,ctaText:k.statement.cta||t.recommendation_title||t.title}:{title:t.recommendation_title||t.title,description:t.recommendation_description||t.reason||"",ctaText:t.recommendation_title||t.title}})(),p=Z("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")},s);return a.jsx("div",{className:p,style:{fontFamily:(e==null?void 0:e.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:((g=(u=e==null?void 0:e.components)==null?void 0:u.inlineRecommendation)==null?void 0:g.width)||"100%",...(x=e==null?void 0:e.components)==null?void 0:x.productCard,...i},"data-admesh-theme":e==null?void 0:e.mode,children:a.jsxs("div",{className:"h-full flex flex-col",children:[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-5 h-5 rounded flex-shrink-0",onError:k=>{k.target.style.display="none"}}),a.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm truncate",children:b.title})]}),a.jsx("div",{className:"flex-shrink-0",children:a.jsx(ce,{adId:((M=t.meta)==null?void 0:M.ad_id)||t.ad_id||"",admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:((N=t.meta)==null?void 0:N.intent_match_score)||t.intent_match_score,component:"inline_card_cta"},children:a.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",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"})})]})})})]}),b.description&&a.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 line-clamp-2",children:b.description}),a.jsx("div",{className:"mt-auto pt-2 border-t border-gray-100 dark:border-slate-700",children:a.jsxs("div",{className:"flex items-center justify-between text-[11px] text-gray-500 dark:text-gray-400",children:[a.jsx("span",{children:"Sponsored"}),a.jsx("span",{className:"text-gray-400 dark:text-gray-500"})]})})]})})};ut.displayName="AdMeshInlineCard";const fr={"Top Match":"primary","Free Tier":"success","AI Powered":"secondary",Popular:"warning",New:"primary","Trial Available":"success"},pr={"Top Match":"★","Free Tier":"◆","AI Powered":"◉",Popular:"▲",New:"●","Trial Available":"◈"},mt=({type:t,variant:e,size:o="md",className:d,style:s})=>{const i=e||fr[t]||"secondary",n=pr[t],l=Z("admesh-component","admesh-badge",`admesh-badge--${i}`,`admesh-badge--${o}`,d);return a.jsxs("span",{className:l,style:s,children:[n&&a.jsx("span",{className:"admesh-badge__icon",children:n}),a.jsx("span",{className:"admesh-badge__text",children:t})]})};mt.displayName="AdMeshBadge";function gr(t,e,o){const s=t*e>242500;return{...{visibilityThreshold:s?.3:.5,minimumDuration:1e3,isLargeAd:s},...o}}function br(t){return t<768?"mobile":t<1024?"tablet":"desktop"}function xr(t){const e=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight,d=window.innerWidth||document.documentElement.clientWidth,s=e.height,i=e.width;if(s===0||i===0)return 0;const n=Math.max(0,e.top),l=Math.min(o,e.bottom),h=Math.max(0,e.left),b=Math.min(d,e.right),p=Math.max(0,l-n),u=Math.max(0,b-h),g=p*u,x=s*i;return x>0?g/x:0}function rt(){const t=window.innerHeight,e=document.documentElement.scrollHeight,o=window.pageYOffset||document.documentElement.scrollTop,d=e-t;return d<=0?100:Math.min(100,o/d*100)}function yr(t){const e=t.getBoundingClientRect(),o=window.pageYOffset||document.documentElement.scrollTop,d=window.pageXOffset||document.documentElement.scrollLeft;return{top:e.top+o,left:e.left+d}}function vr(t){const e=t.getBoundingClientRect(),o=yr(t),d=window.innerWidth||document.documentElement.clientWidth,s=window.innerHeight||document.documentElement.clientHeight,i=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;return{pageUrl:window.location.href,pageTitle:document.title,referrer:document.referrer,deviceType:br(d),viewportWidth:d,viewportHeight:s,adWidth:e.width,adHeight:e.height,adPositionTop:o.top,adPositionLeft:o.left,isDarkMode:i,language:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone}}function wr(){return`session_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}function kr(){return`batch_${Date.now()}_${Math.random().toString(36).substring(2,11)}`}function _r(t,e,o){return t>=o.visibilityThreshold&&e>=o.minimumDuration}function be(t=new Date){return t.toISOString()}function Sr(t){return t.length===0?0:t.reduce((o,d)=>o+d,0)/t.length}function ot(t,e){let o;return function(...s){o||(t(...s),o=!0,setTimeout(()=>o=!1,e))}}async function Cr(t,e,o=3,d=1e3){let s=null;for(let i=0;i<o;i++){try{const n=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(n.ok)return!0;s=new Error(`HTTP ${n.status}: ${n.statusText}`)}catch(n){s=n}i<o-1&&await new Promise(n=>setTimeout(n,d*Math.pow(2,i)))}return console.error("[AdMesh Viewability] Failed to send analytics event:",s),!1}async function Tr(t,e,o,d=3,s=1e3){if(t.length===0)return!0;const i={batchId:kr(),sessionId:e,createdAt:be(),events:t,eventCount:t.length};let n=null;for(let l=0;l<d;l++){try{const h=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(h.ok)return!0;n=new Error(`HTTP ${h.status}: ${h.statusText}`)}catch(h){n=h}l<d-1&&await new Promise(h=>setTimeout(h,s*Math.pow(2,l)))}return console.error("[AdMesh Viewability] Failed to send analytics batch:",n),!1}const Er={enabled:!0,apiEndpoint:"https://api.useadmesh.com/analytics/ui-sdk/viewability",enableBatching:!0,batchSize:10,batchTimeout:5e3,debug:!1,enableRetry:!0,maxRetries:3,retryDelay:1e3};let Ne=Er;const Mr=t=>{Ne={...Ne,...t}};function ht({adId:t,productId:e,offerId:o,agentId:d,elementRef:s,config:i}){const n={...Ne,...i},l=w.useRef(wr()),[h,b]=w.useState({isVisible:!1,isViewable:!1,visibilityPercentage:0,timeMetrics:{loadedAt:be(),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}),p=w.useRef(null),u=w.useRef(null),g=w.useRef(null),x=w.useRef(null),M=w.useRef(null),N=w.useRef([]),k=w.useRef([]),A=w.useRef(null),j=w.useCallback((y,T)=>{n.debug&&console.log(`[AdMesh Viewability] ${y}`,T)},[n.debug]),D=w.useCallback(async(y,T)=>{if(!n.enabled||!s.current||!p.current)return;const f=vr(s.current),_={eventType:y,timestamp:be(),sessionId:l.current,adId:t,productId:e,offerId:o,agentId:d,timeMetrics:h.timeMetrics,engagementMetrics:h.engagementMetrics,contextMetrics:f,mrcStandards:p.current,isViewable:h.isViewable,metadata:T};j(`Event: ${y}`,_),n.onEvent&&n.onEvent(_),n.enableBatching?(k.current.push(_),k.current.length>=n.batchSize?await H():(A.current&&clearTimeout(A.current),A.current=setTimeout(H,n.batchTimeout))):await Cr(_,n.apiEndpoint,n.maxRetries,n.retryDelay)},[n,t,e,o,d,s,h,j]),H=w.useCallback(async()=>{if(k.current.length===0)return;const y=[...k.current];k.current=[],A.current&&(clearTimeout(A.current),A.current=null),await Tr(y,l.current,n.apiEndpoint,n.maxRetries,n.retryDelay)&&n.onBatchSent&&n.onBatchSent({batchId:`batch_${Date.now()}`,sessionId:l.current,createdAt:be(),events:y,eventCount:y.length})},[n]),z=w.useCallback(ot(()=>{if(!s.current)return;const y=xr(s.current),T=Date.now(),f=new Date(h.timeMetrics.loadedAt).getTime();b(_=>{const S={..._};y>0&&N.current.push(y);const K=_.isVisible,q=y>0;if(q&&!K)u.current=T,S.engagementMetrics.viewportEnterCount++,S.timeMetrics.timeToFirstVisible||(S.timeMetrics.timeToFirstVisible=T-f,S.engagementMetrics.scrollDepthAtFirstVisible=rt(),D("ad_visible"));else if(!q&&K){if(u.current){const P=T-u.current;S.timeMetrics.totalVisibleDuration+=P,u.current=null}S.engagementMetrics.viewportExitCount++,D("ad_hidden")}else if(q&&K&&u.current){const P=T-u.current;S.timeMetrics.totalVisibleDuration+=P,u.current=T}if(S.isVisible=q,S.visibilityPercentage=y,y>S.engagementMetrics.maxVisibilityPercentage&&(S.engagementMetrics.maxVisibilityPercentage=y),N.current.length>0&&(S.engagementMetrics.averageVisibilityPercentage=Sr(N.current)),p.current){const P=_.isViewable,B=_r(y,S.timeMetrics.totalVisibleDuration,p.current);if(B&&!P)S.isViewable=!0,S.timeMetrics.timeToViewable=T-f,g.current=T,D("ad_viewable");else if(B&&P&&g.current){const Y=T-g.current;S.timeMetrics.totalViewableDuration+=Y,g.current=T}}return S.engagementMetrics.currentScrollDepth=rt(),S})},100),[s,h.timeMetrics.loadedAt,D]);return w.useEffect(()=>{if(!s.current)return;const y=s.current.getBoundingClientRect();p.current=gr(y.width,y.height,n.mrcStandards),j("Initialized MRC standards",p.current),D("ad_loaded")},[s,n.mrcStandards,j,D]),w.useEffect(()=>{if(!n.enabled||!s.current)return;const y=new IntersectionObserver(T=>{T.forEach(()=>{z()})},{threshold:[0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1],rootMargin:"0px"});return y.observe(s.current),()=>{y.disconnect()}},[n.enabled,s,z]),w.useEffect(()=>{if(!n.enabled)return;const y=ot(()=>{z()},100);return window.addEventListener("scroll",y,{passive:!0}),()=>window.removeEventListener("scroll",y)},[n.enabled,z]),w.useEffect(()=>{if(!n.enabled||!s.current)return;const y=s.current,T=()=>{x.current=Date.now(),b(_=>({..._,engagementMetrics:{..._.engagementMetrics,hoverCount:_.engagementMetrics.hoverCount+1}})),D("ad_hover_start")},f=()=>{if(x.current){const _=Date.now()-x.current;b(S=>({...S,timeMetrics:{...S.timeMetrics,totalHoverDuration:S.timeMetrics.totalHoverDuration+_}})),x.current=null,D("ad_hover_end",{hoverDuration:_})}};return y.addEventListener("mouseenter",T),y.addEventListener("mouseleave",f),()=>{y.removeEventListener("mouseenter",T),y.removeEventListener("mouseleave",f)}},[n.enabled,s,D]),w.useEffect(()=>{if(!n.enabled||!s.current)return;const y=s.current,T=()=>{M.current=Date.now(),D("ad_focus")},f=()=>{if(M.current){const _=Date.now()-M.current;b(S=>({...S,timeMetrics:{...S.timeMetrics,totalFocusDuration:S.timeMetrics.totalFocusDuration+_}})),M.current=null,D("ad_blur",{focusDuration:_})}};return y.addEventListener("focus",T),y.addEventListener("blur",f),()=>{y.removeEventListener("focus",T),y.removeEventListener("blur",f)}},[n.enabled,s,D]),w.useEffect(()=>{if(!n.enabled||!s.current)return;const y=s.current,T=()=>{b(f=>({...f,engagementMetrics:{...f.engagementMetrics,wasClicked:!0}})),D("ad_click")};return y.addEventListener("click",T),()=>{y.removeEventListener("click",T)}},[n.enabled,s,D]),w.useEffect(()=>()=>{const y=Date.now(),T=new Date(h.timeMetrics.loadedAt).getTime(),f=y-T;b(_=>({..._,timeMetrics:{..._.timeMetrics,sessionDuration:f}})),D("ad_unloaded",{sessionDuration:f}),H()},[]),h}const ft=({adId:t,productId:e,offerId:o,agentId:d,children:s,config:i,className:n,style:l,onViewabilityChange:h,onVisible:b,onViewable:p,onClick:u})=>{const g=w.useRef(null),x=ht({adId:t,productId:e,offerId:o,agentId:d,elementRef:g,config:i}),M=w.useRef(x.isViewable);w.useEffect(()=>{x.isViewable!==M.current&&(M.current=x.isViewable,h&&h(x.isViewable),x.isViewable&&p&&p())},[x.isViewable,h,p]);const N=w.useRef(x.isVisible);w.useEffect(()=>{x.isVisible!==N.current&&(N.current=x.isVisible,x.isVisible&&b&&b())},[x.isVisible,b]);const k=A=>{u&&u()};return a.jsx("div",{ref:g,className:n,style:l,onClick:k,"data-admesh-viewability-tracker":!0,"data-ad-id":t,"data-is-viewable":x.isViewable,"data-is-visible":x.isVisible,"data-visibility-percentage":x.visibilityPercentage.toFixed(2),children:s})};ft.displayName="AdMeshViewabilityTracker";const Re="admesh_session_id",je="admesh_session_timestamp",Rr=30*60*1e3;class pt{constructor(e=!1){$(this,"debug");this.debug=e}generateSessionId(){const e=Date.now(),o=Math.random().toString(36).substring(2,15);return`session_${e}_${o}`}createSession(){const e=this.generateSessionId();return this.storeSessionId(e),this.debug&&console.log("[SessionManager] Created session:",e),e}storeSessionId(e){try{typeof window<"u"&&window.localStorage&&(localStorage.setItem(Re,e),localStorage.setItem(je,Date.now().toString()))}catch(o){this.debug&&console.warn("[SessionManager] Failed to store session ID:",o)}}getStoredSessionId(){try{if(typeof window>"u"||!window.localStorage)return null;const e=localStorage.getItem(Re),o=localStorage.getItem(je);return!e||!o?null:Date.now()-parseInt(o,10)>Rr?(this.debug&&console.log("[SessionManager] Session expired"),this.clearStoredSessionId(),null):e}catch(e){return this.debug&&console.warn("[SessionManager] Failed to get stored session ID:",e),null}}clearStoredSessionId(){try{typeof window<"u"&&window.localStorage&&(localStorage.removeItem(Re),localStorage.removeItem(je))}catch(e){this.debug&&console.warn("[SessionManager] Failed to clear session ID:",e)}}closeSession(e){this.debug&&console.log("[SessionManager] Closing session:",e),this.clearStoredSessionId()}isSessionValid(e){return this.getStoredSessionId()===e}}class gt{constructor(e){$(this,"apiKey");$(this,"apiBaseUrl");$(this,"debug");this.apiKey=e.apiKey,this.apiBaseUrl=e.apiBaseUrl||"https://api.useadmesh.com",this.debug=e.debug||!1}async fetchRecommendations(e){try{const o=`${this.apiBaseUrl}/agent/recommend`,d={query:e.query,format:e.format||"auto",...e.previous_query&&{previous_query:e.previous_query},...e.previous_summary&&{previous_summary:e.previous_summary},...e.session_id&&{session_id:e.session_id},...e.is_fallback_allowed!==void 0&&{is_fallback_allowed:e.is_fallback_allowed}};this.debug&&(console.log("[Fetcher] Calling endpoint:",o),console.log("[Fetcher] Payload:",d));const s=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify(d)});if(!s.ok){const l=(await s.json().catch(()=>({}))).detail||`HTTP ${s.status}`;throw new Error(`Failed to fetch recommendations: ${l}`)}const i=await s.json();return this.debug&&console.log("[Fetcher] Response:",i),i}catch(o){throw this.debug&&console.error("[Fetcher] Error fetching recommendations:",o),o}}}var re={},nt;function jr(){if(nt)return re;nt=1;var t=Yt;if(process.env.NODE_ENV==="production")re.createRoot=t.createRoot,re.hydrateRoot=t.hydrateRoot;else{var e=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;re.createRoot=function(o,d){e.usingClientEntryPoint=!0;try{return t.createRoot(o,d)}finally{e.usingClientEntryPoint=!1}},re.hydrateRoot=function(o,d,s){e.usingClientEntryPoint=!0;try{return t.hydrateRoot(o,d,s)}finally{e.usingClientEntryPoint=!1}}}return re}var Ar=jr();const Ir=at(Ar);class bt{constructor(e){$(this,"debug");$(this,"firedExposures",new Set);this.debug=e.debug||!1}fireExposure(e,o,d){const s=`${d}_${o}`;if(this.firedExposures.has(s)){this.debug&&console.log("[Tracker] Exposure already fired for:",o);return}this.firedExposures.add(s);try{fetch(e,{method:"GET",keepalive:!0}).catch(i=>{this.debug&&console.warn("[Tracker] Failed to fire exposure:",i)}),this.debug&&console.log("[Tracker] Fired exposure for:",o)}catch(i){this.debug&&console.error("[Tracker] Error firing exposure:",i)}}fireClick(e,o,d){try{fetch(e,{method:"GET",keepalive:!0}).catch(s=>{this.debug&&console.warn("[Tracker] Failed to fire click:",s)}),this.debug&&console.log("[Tracker] Fired click for:",o)}catch(s){this.debug&&console.error("[Tracker] Error firing click:",s)}}fireConversion(e,o,d){try{fetch(e,{method:"GET",keepalive:!0}).catch(s=>{this.debug&&console.warn("[Tracker] Failed to fire conversion:",s)}),this.debug&&console.log("[Tracker] Fired conversion for:",o)}catch(s){this.debug&&console.error("[Tracker] Error firing conversion:",s)}}clearFiredExposures(){this.firedExposures.clear(),this.debug&&console.log("[Tracker] Cleared fired exposures")}}class xt{constructor(e=!1){$(this,"debug");$(this,"roots",new Map);this.debug=e}async render(e){var o,d,s,i;try{const n=document.getElementById(e.containerId);if(!n)throw new Error(`Container with ID "${e.containerId}" not found`);this.debug&&console.log("[Renderer] Rendering recommendations in container:",e.containerId);const l=this.roots.get(e.containerId);l&&l.unmount();const h=Ir.createRoot(n),b=(p,u)=>{var x,M;const g=(M=(x=e.response.response)==null?void 0:x.recommendations)==null?void 0:M.find(N=>{var k;return((k=N.meta)==null?void 0:k.ad_id)===p||N.ad_id===p});g!=null&&g.click_url&&e.tracker.fireClick(g.click_url,p,e.sessionId),e.onRecommendationClick&&e.onRecommendationClick(p,u),window.open(u,"_blank")};h.render(a.jsx(lt,{response:{layout_type:(o=e.response.response)==null?void 0:o.layout_type,citation_summary:(d=e.response.response)==null?void 0:d.summary,recommendations:((s=e.response.response)==null?void 0:s.recommendations)||[],requires_summary:!!((i=e.response.response)!=null&&i.summary)},theme:e.theme,onRecommendationClick:p=>{var x;const u=((x=p.meta)==null?void 0:x.ad_id)||p.ad_id||"",g=p.admesh_link||"";b(u,g)}})),this.roots.set(e.containerId,h),this.debug&&console.log("[Renderer] Rendered successfully")}catch(n){throw this.debug&&console.error("[Renderer] Error rendering:",n),n}}unmount(e){const o=this.roots.get(e);o&&(o.unmount(),this.roots.delete(e),this.debug&&console.log("[Renderer] Unmounted container:",e))}unmountAll(){for(const[e,o]of this.roots.entries())o.unmount(),this.debug&&console.log("[Renderer] Unmounted container:",e);this.roots.clear()}}class Pr{constructor(e){$(this,"config");$(this,"sessionManager");$(this,"fetcher");$(this,"renderer");$(this,"tracker");$(this,"currentSessionId",null);if(!e.apiKey)throw new Error("AdMeshSDK: apiKey is required");this.config={apiBaseUrl:e.apiBaseUrl||"https://api.useadmesh.com",debug:e.debug||!1,...e},this.sessionManager=new pt(this.config.debug),this.fetcher=new gt(this.config),this.renderer=new xt(this.config.debug),this.tracker=new bt(this.config),this.currentSessionId=this.sessionManager.getStoredSessionId(),this.config.debug&&this.currentSessionId&&console.log("[AdMeshSDK] Restored session:",this.currentSessionId)}async showRecommendations(e){var o,d;try{this.config.debug&&console.log("[AdMeshSDK] Fetching recommendations for query:",e.query),this.currentSessionId||(this.currentSessionId=this.sessionManager.createSession(),this.config.debug&&console.log("[AdMeshSDK] Created new session:",this.currentSessionId));const s=await this.fetcher.fetchRecommendations({query:e.query,format:e.format||"auto",previous_query:e.previousQuery,previous_summary:e.previousSummary,session_id:this.currentSessionId,is_fallback_allowed:e.isFallbackAllowed!==!1});if(this.config.debug&&console.log("[AdMeshSDK] Received recommendations:",s),await this.renderer.render({containerId:e.containerId,response:s,theme:e.theme||this.config.theme,onRecommendationClick:e.onRecommendationClick,tracker:this.tracker,sessionId:this.currentSessionId}),(o=s.response)!=null&&o.recommendations){for(const i of s.response.recommendations)if(i.exposure_url){const n=((d=i.meta)==null?void 0:d.ad_id)||i.ad_id||"";this.tracker.fireExposure(i.exposure_url,n,this.currentSessionId)}}}catch(s){throw console.error("[AdMeshSDK] Error showing recommendations:",s),s}}closeSession(){this.currentSessionId&&(this.config.debug&&console.log("[AdMeshSDK] Closing session:",this.currentSessionId),this.sessionManager.closeSession(this.currentSessionId),this.currentSessionId=null)}getSessionId(){return this.currentSessionId}createNewSession(){return this.currentSessionId=this.sessionManager.createSession(),this.config.debug&&console.log("[AdMeshSDK] Created new session:",this.currentSessionId),this.currentSessionId}setSessionId(e){this.currentSessionId=e,this.sessionManager.storeSessionId(e),this.config.debug&&console.log("[AdMeshSDK] Set session ID:",e)}}const Q=(t={})=>{const e={mode:"light",primaryColor:"#000000",secondaryColor:"#666666",accentColor:"#000000",backgroundColor:"#ffffff",surfaceColor:"#ffffff",borderColor:"#e5e7eb",textColor:"#000000",textSecondaryColor:"#666666",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:"#000000",secondary:"#666666",accent:"#000000"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"},card:{width:"auto"},button:{width:"auto"}}},o={...e,...t,fontSize:{...e.fontSize,...t.fontSize},spacing:{...e.spacing,...t.spacing},shadows:{...e.shadows,...t.shadows},icons:{...e.icons,...t.icons},components:{...e.components,...t.components}};return Fr(o)},Nr=(t={})=>Q({...{mode:"dark",primaryColor:"#ffffff",secondaryColor:"#9ca3af",accentColor:"#ffffff",backgroundColor:"#000000",surfaceColor:"#111111",borderColor:"#333333",textColor:"#ffffff",textSecondaryColor:"#9ca3af",shadows:{small:"0 1px 3px rgba(255, 255, 255, 0.1)",medium:"0 4px 6px rgba(255, 255, 255, 0.1)",large:"0 10px 15px rgba(255, 255, 255, 0.1)"},gradients:{primary:"#ffffff",secondary:"#9ca3af",accent:"#ffffff"}},...t}),Dr={get minimal(){return Q({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)"},gradients:{primary:"#000000",secondary:"#666666",accent:"#000000"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}})},get vibrant(){return Q({primaryColor:"#8b5cf6",secondaryColor:"#06b6d4",accentColor:"#f59e0b",borderRadius:"12px",gradients:{primary:"#8b5cf6",secondary:"#06b6d4",accent:"#f59e0b"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}})},get corporate(){return Q({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 Q({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%"}}})}},Fr=(t={})=>{const e=t.components||{},o={productCard:{width:"100%",...e.productCard},citationUnit:{width:"100%",...e.citationUnit},inlineRecommendation:{width:"100%",...e.inlineRecommendation},expandableUnit:{width:"100%",...e.expandableUnit},compareTable:{width:"100%",...e.compareTable},card:{width:"auto",...e.card},button:{width:"auto",...e.button}};return{...t,components:{...e,...o}}},Or=(...t)=>{const e=Q();return t.reduce((o,d)=>d?{...o,...d,mode:d.mode||o.mode}:o,e)},Lr=t=>{var o,d,s,i,n,l;const e=getComputedStyle(t);return{primaryColor:((o=e.getPropertyValue("--admesh-primary-color"))==null?void 0:o.trim())||void 0,secondaryColor:((d=e.getPropertyValue("--admesh-secondary-color"))==null?void 0:d.trim())||void 0,backgroundColor:((s=e.getPropertyValue("--admesh-background-color"))==null?void 0:s.trim())||void 0,textColor:((i=e.getPropertyValue("--admesh-text-color"))==null?void 0:i.trim())||void 0,borderRadius:((n=e.getPropertyValue("--admesh-border-radius"))==null?void 0:n.trim())||void 0,fontFamily:((l=e.getPropertyValue("--admesh-font-family"))==null?void 0:l.trim())||void 0}},Vr="0.2.1",$r={trackingEnabled:!0,debug:!1,theme:{mode:"light",accentColor:"#2563eb"}};exports.AdMeshBadge=mt;exports.AdMeshEcommerceCards=dt;exports.AdMeshInlineCard=ut;exports.AdMeshLayout=lt;exports.AdMeshLinkTracker=ce;exports.AdMeshProductCard=de;exports.AdMeshRecommendationFetcher=gt;exports.AdMeshRenderer=xt;exports.AdMeshSDK=Pr;exports.AdMeshSessionManager=pt;exports.AdMeshSummaryLayout=ct;exports.AdMeshSummaryUnit=Ae;exports.AdMeshTracker=bt;exports.AdMeshViewabilityTracker=ft;exports.DEFAULT_CONFIG=$r;exports.VERSION=Vr;exports.buildAdMeshLink=or;exports.createAdMeshTheme=Q;exports.createDarkTheme=Nr;exports.extractTrackingData=nr;exports.getBadgeText=cr;exports.getCtaText=lr;exports.getInlineDisclosure=ir;exports.getInlineTooltip=dr;exports.getLabelTooltip=Pe;exports.getPoweredByText=mr;exports.getRecommendationLabel=oe;exports.getSectionDisclosure=sr;exports.hasHighQualityMatches=ur;exports.mergeThemes=Or;exports.setAdMeshTrackerConfig=rr;exports.setViewabilityTrackerConfig=Mr;exports.themeFromCSSProperties=Lr;exports.themePresets=Dr;exports.useAdMeshStyles=it;exports.useAdMeshTracker=st;exports.useViewabilityTracker=ht;
709
717
  //# sourceMappingURL=index.js.map