admesh-ui-sdk 0.12.1 → 0.12.2

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/dist/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var de;function we(){if(de)return K;de=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(r,d,s){var c=null;if(s!==void 0&&(c=""+s),d.key!==void 0&&(c=""+d.key),"key"in d){s={};for(var l in d)l!=="key"&&(s[l]=d[l])}else s=d;return d=s.ref,{$$typeof:e,type:r,key:c,ref:d!==void 0?d:null,props:s}}return K.Fragment=t,K.jsx=o,K.jsxs=o,K}var G={};/**
9
+ */var de;function we(){if(de)return K;de=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function o(r,d,i){var l=null;if(i!==void 0&&(l=""+i),d.key!==void 0&&(l=""+d.key),"key"in d){i={};for(var c in d)c!=="key"&&(i[c]=d[c])}else i=d;return d=i.ref,{$$typeof:e,type:r,key:l,ref:d!==void 0?d:null,props:i}}return K.Fragment=t,K.jsx=o,K.jsxs=o,K}var G={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,16 +14,16 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var ce;function ye(){return ce||(ce=1,process.env.NODE_ENV!=="production"&&function(){function e(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===F?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case T:return"Fragment";case R:return"Profiler";case N:return"StrictMode";case A:return"Suspense";case C:return"SuspenseList";case E:return"Activity"}if(typeof n=="object")switch(typeof n.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),n.$$typeof){case g:return"Portal";case L:return(n.displayName||"Context")+".Provider";case $:return(n._context.displayName||"Context")+".Consumer";case O:var f=n.render;return n=n.displayName,n||(n=f.displayName||f.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case M:return f=n.displayName||null,f!==null?f:e(n.type)||"Memo";case S:f=n._payload,n=n._init;try{return e(n(f))}catch{}}return null}function t(n){return""+n}function o(n){try{t(n);var f=!1}catch{f=!0}if(f){f=console;var j=f.error,P=typeof Symbol=="function"&&Symbol.toStringTag&&n[Symbol.toStringTag]||n.constructor.name||"Object";return j.call(f,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",P),t(n)}}function r(n){if(n===T)return"<>";if(typeof n=="object"&&n!==null&&n.$$typeof===S)return"<...>";try{var f=e(n);return f?"<"+f+">":"<...>"}catch{return"<...>"}}function d(){var n=i.A;return n===null?null:n.getOwner()}function s(){return Error("react-stack-top-frame")}function c(n){if(b.call(n,"key")){var f=Object.getOwnPropertyDescriptor(n,"key").get;if(f&&f.isReactWarning)return!1}return n.key!==void 0}function l(n,f){function j(){k||(k=!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)",f))}j.isReactWarning=!0,Object.defineProperty(n,"key",{get:j,configurable:!0})}function h(){var n=e(this.type);return z[n]||(z[n]=!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.")),n=this.props.ref,n!==void 0?n:null}function x(n,f,j,P,B,U,Q,Z){return j=U.ref,n={$$typeof:_,type:n,key:f,props:U,_owner:B},(j!==void 0?j:null)!==null?Object.defineProperty(n,"ref",{enumerable:!1,get:h}):Object.defineProperty(n,"ref",{enumerable:!1,value:null}),n._store={},Object.defineProperty(n._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(n,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(n,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.defineProperty(n,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Z}),Object.freeze&&(Object.freeze(n.props),Object.freeze(n)),n}function v(n,f,j,P,B,U,Q,Z){var I=f.children;if(I!==void 0)if(P)if(m(I)){for(P=0;P<I.length;P++)p(I[P]);Object.freeze&&Object.freeze(I)}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 p(I);if(b.call(f,"key")){I=e(n);var V=Object.keys(f).filter(function(xe){return xe!=="key"});P=0<V.length?"{key: someKey, "+V.join(": ..., ")+": ...}":"{key: someKey}",ie[I+P]||(V=0<V.length?"{"+V.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var le;function ye(){return le||(le=1,process.env.NODE_ENV!=="production"&&function(){function e(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===F?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case N:return"Fragment";case R:return"Profiler";case T:return"StrictMode";case C:return"Suspense";case A:return"SuspenseList";case E:return"Activity"}if(typeof n=="object")switch(typeof n.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),n.$$typeof){case f:return"Portal";case L:return(n.displayName||"Context")+".Provider";case $:return(n._context.displayName||"Context")+".Consumer";case O:var u=n.render;return n=n.displayName,n||(n=u.displayName||u.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case M:return u=n.displayName||null,u!==null?u:e(n.type)||"Memo";case S:u=n._payload,n=n._init;try{return e(n(u))}catch{}}return null}function t(n){return""+n}function o(n){try{t(n);var u=!1}catch{u=!0}if(u){u=console;var j=u.error,P=typeof Symbol=="function"&&Symbol.toStringTag&&n[Symbol.toStringTag]||n.constructor.name||"Object";return j.call(u,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",P),t(n)}}function r(n){if(n===N)return"<>";if(typeof n=="object"&&n!==null&&n.$$typeof===S)return"<...>";try{var u=e(n);return u?"<"+u+">":"<...>"}catch{return"<...>"}}function d(){var n=s.A;return n===null?null:n.getOwner()}function i(){return Error("react-stack-top-frame")}function l(n){if(b.call(n,"key")){var u=Object.getOwnPropertyDescriptor(n,"key").get;if(u&&u.isReactWarning)return!1}return n.key!==void 0}function c(n,u){function j(){k||(k=!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)",u))}j.isReactWarning=!0,Object.defineProperty(n,"key",{get:j,configurable:!0})}function g(){var n=e(this.type);return z[n]||(z[n]=!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.")),n=this.props.ref,n!==void 0?n:null}function x(n,u,j,P,B,U,Q,Z){return j=U.ref,n={$$typeof:_,type:n,key:u,props:U,_owner:B},(j!==void 0?j:null)!==null?Object.defineProperty(n,"ref",{enumerable:!1,get:g}):Object.defineProperty(n,"ref",{enumerable:!1,value:null}),n._store={},Object.defineProperty(n._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(n,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(n,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.defineProperty(n,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Z}),Object.freeze&&(Object.freeze(n.props),Object.freeze(n)),n}function v(n,u,j,P,B,U,Q,Z){var I=u.children;if(I!==void 0)if(P)if(m(I)){for(P=0;P<I.length;P++)p(I[P]);Object.freeze&&Object.freeze(I)}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 p(I);if(b.call(u,"key")){I=e(n);var V=Object.keys(u).filter(function(xe){return xe!=="key"});P=0<V.length?"{key: someKey, "+V.join(": ..., ")+": ...}":"{key: someKey}",ie[I+P]||(V=0<V.length?"{"+V.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,P,I,V,I),ie[I+P]=!0)}if(I=null,j!==void 0&&(o(j),I=""+j),c(f)&&(o(f.key),I=""+f.key),"key"in f){j={};for(var ee in f)ee!=="key"&&(j[ee]=f[ee])}else j=f;return I&&l(j,typeof n=="function"?n.displayName||n.name||"Unknown":n),x(n,I,U,B,d(),j,Q,Z)}function p(n){typeof n=="object"&&n!==null&&n.$$typeof===_&&n._store&&(n._store.validated=1)}var u=w,_=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),N=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),$=Symbol.for("react.consumer"),L=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),F=Symbol.for("react.client.reference"),i=u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,b=Object.prototype.hasOwnProperty,m=Array.isArray,y=console.createTask?console.createTask:function(){return null};u={"react-stack-bottom-frame":function(n){return n()}};var k,z={},W=u["react-stack-bottom-frame"].bind(u,s)(),J=y(r(s)),ie={};G.Fragment=T,G.jsx=function(n,f,j,P,B){var U=1e4>i.recentlyCreatedOwnerStacks++;return v(n,f,j,!1,P,B,U?Error("react-stack-top-frame"):W,U?y(r(n)):J)},G.jsxs=function(n,f,j,P,B){var U=1e4>i.recentlyCreatedOwnerStacks++;return v(n,f,j,!0,P,B,U?Error("react-stack-top-frame"):W,U?y(r(n)):J)}}()),G}var le;function ke(){return le||(le=1,process.env.NODE_ENV==="production"?X.exports=we():X.exports=ye()),X.exports}var a=ke(),te={exports:{}};/*!
22
+ <%s key={someKey} {...props} />`,P,I,V,I),ie[I+P]=!0)}if(I=null,j!==void 0&&(o(j),I=""+j),l(u)&&(o(u.key),I=""+u.key),"key"in u){j={};for(var ee in u)ee!=="key"&&(j[ee]=u[ee])}else j=u;return I&&c(j,typeof n=="function"?n.displayName||n.name||"Unknown":n),x(n,I,U,B,d(),j,Q,Z)}function p(n){typeof n=="object"&&n!==null&&n.$$typeof===_&&n._store&&(n._store.validated=1)}var h=w,_=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),$=Symbol.for("react.consumer"),L=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),E=Symbol.for("react.activity"),F=Symbol.for("react.client.reference"),s=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,b=Object.prototype.hasOwnProperty,m=Array.isArray,y=console.createTask?console.createTask:function(){return null};h={"react-stack-bottom-frame":function(n){return n()}};var k,z={},W=h["react-stack-bottom-frame"].bind(h,i)(),J=y(r(i)),ie={};G.Fragment=N,G.jsx=function(n,u,j,P,B){var U=1e4>s.recentlyCreatedOwnerStacks++;return v(n,u,j,!1,P,B,U?Error("react-stack-top-frame"):W,U?y(r(n)):J)},G.jsxs=function(n,u,j,P,B){var U=1e4>s.recentlyCreatedOwnerStacks++;return v(n,u,j,!0,P,B,U?Error("react-stack-top-frame"):W,U?y(r(n)):J)}}()),G}var ce;function ke(){return ce||(ce=1,process.env.NODE_ENV==="production"?X.exports=we():X.exports=ye()),X.exports}var a=ke(),te={exports:{}};/*!
23
23
  Copyright (c) 2018 Jed Watson.
24
24
  Licensed under the MIT License (MIT), see
25
25
  http://jedwatson.github.io/classnames
26
- */var me;function ve(){return me||(me=1,function(e){(function(){var t={}.hasOwnProperty;function o(){for(var s="",c=0;c<arguments.length;c++){var l=arguments[c];l&&(s=d(s,r(l)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return o.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var c="";for(var l in s)t.call(s,l)&&s[l]&&(c=d(c,l));return c}function d(s,c){return c?s?s+" "+c:s+c:s}e.exports?(o.default=o,e.exports=o):window.classNames=o})()}(te)),te.exports}var _e=ve();const D=be(_e),je="https://api.useadmesh.com/track";let ae={apiBaseUrl:je,enabled:!0,debug:!1,retryAttempts:3,retryDelay:1e3};const Se=e=>{ae={...ae,...e}},pe=e=>{const[t,o]=w.useState(!1),[r,d]=w.useState(null),s=w.useMemo(()=>({...ae,...e}),[e]),c=w.useCallback((p,u)=>{s.debug&&console.log(`[AdMesh Tracker] ${p}`,u)},[s.debug]),l=w.useCallback(async(p,u)=>{if(!s.enabled){c("Tracking disabled, skipping event",{eventType:p,data:u});return}if(!u.adId||!u.admeshLink){const N="Missing required tracking data: adId and admeshLink are required";c(N,u),d(N);return}o(!0),d(null);const _={event_type:p,ad_id:u.adId,admesh_link:u.admeshLink,product_id:u.productId,user_id:u.userId,session_id:u.sessionId,revenue:u.revenue,conversion_type:u.conversionType,metadata:u.metadata,timestamp:new Date().toISOString(),user_agent:navigator.userAgent,referrer:document.referrer,page_url:window.location.href};c(`Sending ${p} event`,_);let g=null;for(let N=1;N<=(s.retryAttempts||3);N++)try{const R=await fetch(`${s.apiBaseUrl}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)});if(!R.ok)throw new Error(`HTTP ${R.status}: ${R.statusText}`);const $=await R.json();c(`${p} event tracked successfully`,$),o(!1);return}catch(R){g=R,c(`Attempt ${N} failed for ${p} event`,R),N<(s.retryAttempts||3)&&await new Promise($=>setTimeout($,(s.retryDelay||1e3)*N))}const T=`Failed to track ${p} event after ${s.retryAttempts} attempts: ${g==null?void 0:g.message}`;c(T,g),d(T),o(!1)},[s,c]),h=w.useCallback(async p=>l("click",p),[l]),x=w.useCallback(async p=>l("view",p),[l]),v=w.useCallback(async p=>(!p.revenue&&!p.conversionType&&c("Warning: Conversion tracking without revenue or conversion type",p),l("conversion",p)),[l,c]);return{trackClick:h,trackView:x,trackConversion:v,isTracking:t,error:r}},Ne=(e,t,o)=>{try{const r=new URL(e);return r.searchParams.set("ad_id",t),r.searchParams.set("utm_source","admesh"),r.searchParams.set("utm_medium","recommendation"),o&&Object.entries(o).forEach(([d,s])=>{r.searchParams.set(d,s)}),r.toString()}catch(r){return console.warn("[AdMesh] Invalid URL provided to buildAdMeshLink:",e,r),e}},Te=(e,t)=>({adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,...t}),H=({adId:e,admeshLink:t,productId:o,children:r,trackingData:d,className:s,style:c})=>{const{trackClick:l,trackView:h}=pe(),x=w.useRef(null),v=w.useRef(!1);w.useEffect(()=>{if(!x.current||v.current)return;const u=new IntersectionObserver(_=>{_.forEach(g=>{g.isIntersecting&&!v.current&&(v.current=!0,h({adId:e,admeshLink:t,productId:o,...d}).catch(console.error))})},{threshold:.5,rootMargin:"0px"});return u.observe(x.current),()=>{u.disconnect()}},[e,t,o,d,h]);const p=w.useCallback(async u=>{try{await l({adId:e,admeshLink:t,productId:o,...d})}catch(T){console.error("Failed to track click:",T)}u.target.closest("a")||window.open(t,"_blank","noopener,noreferrer")},[e,t,o,d,l]);return a.jsx("div",{ref:x,className:s,onClick:p,style:{cursor:"pointer",...c},children:r})};H.displayName="AdMeshLinkTracker";const Re=`
26
+ */var me;function ve(){return me||(me=1,function(e){(function(){var t={}.hasOwnProperty;function o(){for(var i="",l=0;l<arguments.length;l++){var c=arguments[l];c&&(i=d(i,r(c)))}return i}function r(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 l="";for(var c in i)t.call(i,c)&&i[c]&&(l=d(l,c));return l}function d(i,l){return l?i?i+" "+l:i+l:i}e.exports?(o.default=o,e.exports=o):window.classNames=o})()}(te)),te.exports}var _e=ve();const D=be(_e),je="https://api.useadmesh.com/track";let ae={apiBaseUrl:je,enabled:!0,debug:!1,retryAttempts:3,retryDelay:1e3};const Se=e=>{ae={...ae,...e}},pe=e=>{const[t,o]=w.useState(!1),[r,d]=w.useState(null),i=w.useMemo(()=>({...ae,...e}),[e]),l=w.useCallback((p,h)=>{i.debug&&console.log(`[AdMesh Tracker] ${p}`,h)},[i.debug]),c=w.useCallback(async(p,h)=>{if(!i.enabled){l("Tracking disabled, skipping event",{eventType:p,data:h});return}if(!h.adId||!h.admeshLink){const T="Missing required tracking data: adId and admeshLink are required";l(T,h),d(T);return}o(!0),d(null);const _={event_type:p,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};l(`Sending ${p} event`,_);let f=null;for(let T=1;T<=(i.retryAttempts||3);T++)try{const R=await fetch(`${i.apiBaseUrl}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)});if(!R.ok)throw new Error(`HTTP ${R.status}: ${R.statusText}`);const $=await R.json();l(`${p} event tracked successfully`,$),o(!1);return}catch(R){f=R,l(`Attempt ${T} failed for ${p} event`,R),T<(i.retryAttempts||3)&&await new Promise($=>setTimeout($,(i.retryDelay||1e3)*T))}const N=`Failed to track ${p} event after ${i.retryAttempts} attempts: ${f==null?void 0:f.message}`;l(N,f),d(N),o(!1)},[i,l]),g=w.useCallback(async p=>c("click",p),[c]),x=w.useCallback(async p=>c("view",p),[c]),v=w.useCallback(async p=>(!p.revenue&&!p.conversionType&&l("Warning: Conversion tracking without revenue or conversion type",p),c("conversion",p)),[c,l]);return{trackClick:g,trackView:x,trackConversion:v,isTracking:t,error:r}},Te=(e,t,o)=>{try{const r=new URL(e);return r.searchParams.set("ad_id",t),r.searchParams.set("utm_source","admesh"),r.searchParams.set("utm_medium","recommendation"),o&&Object.entries(o).forEach(([d,i])=>{r.searchParams.set(d,i)}),r.toString()}catch(r){return console.warn("[AdMesh] Invalid URL provided to buildAdMeshLink:",e,r),e}},Ne=(e,t)=>({adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,...t}),H=({adId:e,admeshLink:t,productId:o,children:r,trackingData:d,className:i,style:l})=>{const{trackClick:c,trackView:g}=pe(),x=w.useRef(null),v=w.useRef(!1);w.useEffect(()=>{if(!x.current||v.current)return;const h=new IntersectionObserver(_=>{_.forEach(f=>{f.isIntersecting&&!v.current&&(v.current=!0,g({adId:e,admeshLink:t,productId:o,...d}).catch(console.error))})},{threshold:.5,rootMargin:"0px"});return h.observe(x.current),()=>{h.disconnect()}},[e,t,o,d,g]);const p=w.useCallback(async h=>{try{await c({adId:e,admeshLink:t,productId:o,...d})}catch(N){console.error("Failed to track click:",N)}h.target.closest("a")||window.open(t,"_blank","noopener,noreferrer")},[e,t,o,d,c]);return a.jsx("div",{ref:x,className:i,onClick:p,style:{cursor:"pointer",...l},children:r})};H.displayName="AdMeshLinkTracker";const Re=`
27
27
  /* AdMesh UI SDK - Complete Self-Contained Styles */
28
28
 
29
29
  /* CSS Reset for AdMesh components */
@@ -691,7 +691,7 @@ React keys must be passed directly to JSX without using spread:
691
691
  .admesh-component .lg\\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
692
692
  .admesh-component .lg\\:col-span-1 { grid-column: span 1 / span 1; }
693
693
  }
694
- `;let re=!1;const he=()=>{w.useEffect(()=>{if(re)return;const e=document.createElement("style");return e.id="admesh-ui-sdk-styles",e.textContent=Re,document.getElementById("admesh-ui-sdk-styles")||(document.head.appendChild(e),re=!0),()=>{const t=document.getElementById("admesh-ui-sdk-styles");t&&document.head.contains(t)&&(document.head.removeChild(t),re=!1)}},[])},Y=(e,t={})=>{const o=e.intent_match_score||0,r=t.customLabels||{};return o>=.8?r.partnerRecommendation||"Partner Recommendation":o>=.6?r.partnerMatch||"Partner Match":o>=.3?r.promotedOption||"Promoted":r.relatedOption||"Related"},oe=(e,t)=>{const o=e.intent_match_score||0;return o>=.8?"This recommendation is from a partner who compensates us when you engage. We've matched it to your needs based on your query.":o>=.6?"Top-rated partner solution matched to your specific requirements. Partner compensates us for qualified referrals.":o>=.3?"This partner solution may be relevant to your needs. The partner compensates us when you take qualifying actions.":"This solution is somewhat related to your query. While not a perfect match, it might still be helpful. This partner compensates us for qualified referrals."},Me=(e=!0,t=!1)=>e?t?"These curated recommendations are from partners who compensate us for referrals.":"Personalized Partner Recommendations: All results are from vetted partners who compensate us for qualified matches. We've ranked them based on relevance to your specific needs.":"Expanded Results: While these don't perfectly match your query, they're related solutions from our partner network. All partners compensate us for referrals.",Ee=(e,t=!1)=>{const o=e.intent_match_score||0;return t?"Promoted":o>=.8?"Smart Recommendation":o>=.6?"Partner Match":"Promoted"},Ae=()=>"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.",Ce=e=>({"Top Match":"Top Match","Partner Recommendation":"Partner Recommendation","Perfect Fit":"Perfect Fit","Great Match":"Great Match",Recommended:"Recommended","Good Fit":"Good Fit",Featured:"Featured","Popular Choice":"Popular Choice","Premium Pick":"Premium Pick","Free Tier":"Free Tier","AI Powered":"AI Powered",Popular:"Popular",New:"New","Trial Available":"Trial Available","Related Option":"Related Option","Alternative Solution":"Alternative Solution","Expanded Match":"Expanded Match"})[e]||e,Pe=(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"},Ie=e=>e.some(t=>(t.intent_match_score||0)>=.8),$e=(e=!1)=>e?"Powered by AdMesh":"Recommendations powered by AdMesh",ne=({recommendation:e,theme:t,showMatchScore:o=!1,showBadges:r=!0,variation:d="default",expandable:s=!1,className:c,style:l})=>{var g,T,N,R,$,L,O,A,C,M,S,E,F,i;he();const[h,x]=w.useState(!1);w.useMemo(()=>{var z;const b=[];Y(e)==="Partner Recommendation"&&b.push("Top Match"),e.trial_days&&e.trial_days>0&&b.push("Trial Available");const y=["ai","artificial intelligence","machine learning","ml","automation"];return(((z=e.keywords)==null?void 0:z.some(W=>y.some(J=>W.toLowerCase().includes(J))))||e.title.toLowerCase().includes("ai"))&&b.push("AI Powered"),e.badges&&e.badges.length>0&&e.badges.forEach(W=>{["Top Match","Free Tier","AI Powered","Popular","New","Trial Available"].includes(W)&&!b.includes(W)&&b.push(W)}),b},[e]),Math.round(e.intent_match_score*100);const p=d==="simple"?{title:e.recommendation_title||e.title,description:e.recommendation_description||e.description||e.reason,ctaText:e.recommendation_title||e.title,isSimple:!0}:{title:e.recommendation_title||e.title,description:e.recommendation_description||e.description||e.reason,ctaText:e.recommendation_title||e.title},u=D("admesh-component","admesh-card","relative p-4 sm:p-5 rounded-xl bg-gradient-to-br from-white to-gray-50 dark:from-slate-800 dark:to-slate-900 border border-gray-200/50 dark:border-slate-700/50 shadow-lg hover:shadow-xl transition-all duration-300 hover:-translate-y-1",c),_=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":(g=t.shadows)==null?void 0:g.small,"--admesh-shadow-md":(T=t.shadows)==null?void 0:T.medium,"--admesh-shadow-lg":(N=t.shadows)==null?void 0:N.large,"--admesh-spacing-sm":(R=t.spacing)==null?void 0:R.small,"--admesh-spacing-md":($=t.spacing)==null?void 0:$.medium,"--admesh-spacing-lg":(L=t.spacing)==null?void 0:L.large,"--admesh-font-size-sm":(O=t.fontSize)==null?void 0:O.small,"--admesh-font-size-base":(A=t.fontSize)==null?void 0:A.base,"--admesh-font-size-lg":(C=t.fontSize)==null?void 0:C.large,"--admesh-font-size-title":(M=t.fontSize)==null?void 0:M.title,fontFamily:t.fontFamily,width:((E=(S=t.components)==null?void 0:S.productCard)==null?void 0:E.width)||"100%"}:{width:"100%"};return d==="simple"?a.jsxs("div",{className:D("admesh-component admesh-simple-ad","inline-block text-sm leading-relaxed",c),style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(F=t==null?void 0:t.components)==null?void 0:F.productCard,...l},"data-admesh-theme":t==null?void 0:t.mode,children:[a.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(t==null?void 0:t.accentColor)||"#2563eb",backgroundColor:(t==null?void 0:t.mode)==="dark"?"#374151":"#f3f4f6",padding:"2px 6px",borderRadius:"4px",marginRight:"8px"},title:oe(e,Y(e)),children:Y(e)}),a.jsxs("span",{style:{color:(t==null?void 0:t.mode)==="dark"?"#f3f4f6":"#374151",marginRight:"4px"},children:[p.description," "]}),a.jsx(H,{adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,trackingData:{title:e.title,matchScore:e.intent_match_score,component:"simple_ad_cta"},children:a.jsx("span",{style:{color:(t==null?void 0:t.accentColor)||"#2563eb",textDecoration:"underline",cursor:"pointer",fontSize:"inherit",fontFamily:"inherit"},children:p.ctaText})}),a.jsx("span",{style:{fontSize:"10px",color:(t==null?void 0:t.mode)==="dark"?"#9ca3af":"#6b7280",marginLeft:"8px"},children:"(Sponsored • Powered by AdMesh)"})]}):a.jsx("div",{className:u,style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(i=t==null?void 0:t.components)==null?void 0:i.productCard,...l},"data-admesh-theme":t==null?void 0:t.mode,children:a.jsxs("div",{className:"h-full flex flex-col",style:_,children:[a.jsx("div",{className:"mb-3",children:a.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(t==null?void 0:t.accentColor)||"#2563eb",backgroundColor:(t==null?void 0:t.mode)==="dark"?"#374151":"#f3f4f6",padding:"2px 6px",borderRadius:"4px"},title:oe(e,Y(e)),children:Y(e)})}),a.jsxs("div",{className:"flex justify-between items-center gap-3 mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.product_logo&&a.jsx("img",{src:e.product_logo.url,alt:`${e.title} logo`,className:"w-6 h-6 rounded flex-shrink-0",onError:b=>{b.target.style.display="none"}}),a.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm sm:text-base truncate",children:p.title})]}),a.jsx("div",{className:"flex-shrink-0",children:a.jsx(H,{adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,trackingData:{title:e.title,matchScore:e.intent_match_score,component:"product_card_cta"},children:a.jsxs("button",{className:"text-xs px-2 py-1 sm:px-3 sm:py-2 rounded-full bg-gradient-to-r from-purple-500 to-pink-500 text-white hover:from-purple-600 hover:to-pink-600 flex items-center transition-all duration-200 transform hover:scale-105 shadow-md hover:shadow-lg whitespace-nowrap",children:["Visit",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-6",children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 leading-relaxed",children:p.description})}),e.features&&e.features.length>0&&a.jsxs("div",{className:"mb-3",children:[a.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 font-medium",children:"✨ Key Features"}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.features.slice(0,4).map((b,m)=>a.jsxs("span",{className:"text-xs px-2 py-1 rounded-full bg-gradient-to-r from-indigo-100 to-purple-100 dark:from-indigo-900/30 dark:to-purple-900/30 text-indigo-700 dark:text-indigo-300 border border-indigo-200 dark:border-indigo-700",children:[a.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-indigo-500",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"})}),b]},m)),e.features.length>4&&a.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 px-2 py-1",children:["+",e.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",children:"Powered by AdMesh"})]})})]})})};ne.displayName="AdMeshProductCard";const se=({recommendation:e,theme:t,variation:o="default",expandable:r=!1,className:d,style:s})=>{var p,u,_;const[c,l]=w.useState(!1),x=(()=>{const g=e.content_variations;return o==="question"&&(g!=null&&g.question)?{title:g.question.cta||e.recommendation_title||e.title,description:g.question.text,ctaText:g.question.cta||e.recommendation_title||e.title}:o==="statement"&&(g!=null&&g.statement)?{title:e.recommendation_title||e.title,description:g.statement.text,ctaText:g.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}})(),v=D("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":r&&(o==="question"||o==="statement")},d);return a.jsx("div",{className:v,style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:((u=(p=t==null?void 0:t.components)==null?void 0:p.inlineRecommendation)==null?void 0:u.width)||"100%",...(_=t==null?void 0:t.components)==null?void 0:_.productCard,...s},"data-admesh-theme":t==null?void 0:t.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:[e.product_logo&&a.jsx("img",{src:e.product_logo.url,alt:`${e.title} logo`,className:"w-5 h-5 rounded flex-shrink-0",onError:g=>{g.target.style.display="none"}}),a.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm truncate",children:x.title})]}),a.jsx("div",{className:"flex-shrink-0",children:a.jsx(H,{adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,trackingData:{title:e.title,matchScore:e.intent_match_score,component:"inline_card_cta"},children: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"})})]})})})]}),x.description&&a.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 line-clamp-2",children:x.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",children:"Powered by AdMesh"})]})})]})})};se.displayName="AdMeshInlineCard";const Le=(e,t,o)=>{let r=e;if(t.forEach((s,c)=>{const l=`link_${c+1}`,h=`{product${c+1}}`,x=`{recommendation${c+1}}`;o.set(l,s),r.includes(h)?r=r.replace(h,`{{LINK_${l}_${s.title}}}`):r.includes(x)&&(r=r.replace(x,`{{LINK_${l}_${s.title}}}`))}),r.match(/\{product\}/g)&&t.length>0){const s="link_1";o.set(s,t[0]),r=r.replace("{product}",`{{LINK_${s}_${t[0].title}}}`)}return{text:r,linkMap:o}},Fe=(e,t,o,r)=>{let d=e;return o.forEach((s,c)=>{const l=Math.min(s.recommendationIndex,t.length-1),h=t[l];if(h){const x=`link_${c+1}`;r.set(x,h);const v=s.linkText||h.title,p=typeof s.pattern=="string"?new RegExp(s.pattern.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi"):s.pattern;d=d.replace(p,u=>`${u} {{LINK_${x}_${v}}}`)}}),{text:d,linkMap:r}},ze=(e,t,o)=>{let r=e;return t.forEach((d,s)=>{const c=`link_${s+1}`;o.set(c,d),s===0?r+=` Check out {{LINK_${c}_${d.title}}}`:s===t.length-1&&t.length>1?r+=` and {{LINK_${c}_${d.title}}}`:r+=`, {{LINK_${c}_${d.title}}}`}),{text:r,linkMap:o}},Oe=(e,t,o,r)=>{let d=e;return r.forEach((s,c)=>{const l=new RegExp(`\\b${c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");l.test(d)&&(d=d.replace(l,h=>`{{EXTERNAL_LINK_${h}_${s}}}`))}),t.forEach((s,c)=>{const l=`link_${c+1}`,h=s.title;o.set(l,s);const x=new RegExp(`\\b${h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if(x.test(d))d=d.replace(x,v=>`{{LINK_${l}_${v}}}`);else{const v=s.keywords||[];let p=!1;for(const u of v){const _=new RegExp(`\\b${u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if(_.test(d)&&!p){d=d.replace(_,g=>(p=!0,`${g} {{LINK_${l}_${h}}}`));break}}p||(d+=` {{LINK_${l}_${h}}}`)}}),{text:d,linkMap:o}},ue=({recommendations:e,conversationTextLinks:t,theme:o,citationStyle:r="numbered",onCitationHover:d,className:s,style:c,dynamicTemplate:l,linkInsertionStrategy:h="auto",customLinkPatterns:x,onTextUpdate:v,enableRealTimeUpdates:p=!1})=>{var L,O,A;const[u,_]=w.useState(null),g=w.useMemo(()=>t?t instanceof Map?t:new Map(Object.entries(t)):new Map,[t]),T=w.useMemo(()=>{var E;if(!e.length)return{text:"",linkMap:new Map};const C=new Map,M=[...e].sort((F,i)=>i.intent_match_score-F.intent_match_score),S=((E=M[0])==null?void 0:E.conversationText)||l||"";return S?h==="template"&&l?Le(l,M,C):h==="keywords"&&x?Fe(S,M,x,C):h==="append"?ze(S,M,C):Oe(S,M,C,g):{text:"",linkMap:new Map}},[e,l,h,x,g]);w.useEffect(()=>{if(p&&v){const{text:C}=T,M=C.replace(/\{\{LINK_[^}]+\}\}/g,S=>{const E=S.match(/\{\{LINK_link_\d+_(.+?)\}\}/);return E?E[1]:S});v(M)}},[T,p,v]);const N=()=>{const{text:C,linkMap:M}=T;return C.split(/(\{\{(?:LINK_|EXTERNAL_LINK_)[^}]+\}\})/).map((E,F)=>{const i=E.match(/\{\{LINK_(link_\d+)_(.+?)\}\}/),b=E.match(/\{\{EXTERNAL_LINK_(.+?)_(.+?)\}\}/);if(i){const m=i[1],y=i[2],k=M.get(m);if(k)return a.jsx("span",{className:"admesh-inline-link",onMouseEnter:()=>{_(k),d==null||d(k)},onMouseLeave:()=>_(null),children:a.jsx("a",{href:k.admesh_link||k.url,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",style:{textDecorationThickness:"1px",textUnderlineOffset:"2px",color:(o==null?void 0:o.accentColor)||void 0},onClick:z=>{k.ad_id&&console.log("AdMesh link clicked:",{adId:k.ad_id,title:k.title,url:k.admesh_link||k.url})},children:y})},`link-${m}-${F}`)}else if(b){const m=b[1],y=b[2];return a.jsx("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"text-purple-600 dark:text-purple-400 hover:text-purple-800 dark:hover:text-purple-300 underline decoration-purple-600 dark:decoration-purple-400 hover:decoration-purple-800 dark:hover:decoration-purple-300 transition-colors duration-200",style:{textDecorationThickness:"1px",textUnderlineOffset:"2px"},onClick:()=>{console.log("External link clicked:",{companyName:m,url:y})},children:m},`external-${F}`)}return a.jsx("span",{children:E},F)})},R=D("admesh-citation-unit","rounded-xl shadow-sm border border-gray-200 dark:border-gray-800 p-4 bg-white dark:bg-slate-900",s),$=o!=null&&o.accentColor?{"--admesh-primary":o.accentColor}:void 0;return a.jsxs("div",{className:R,style:{...$,fontFamily:(o==null?void 0:o.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:((O=(L=o==null?void 0:o.components)==null?void 0:L.citationUnit)==null?void 0:O.width)||"100%",...(A=o==null?void 0:o.components)==null?void 0:A.citationUnit,...c},"data-admesh-theme":o==null?void 0:o.mode,children:[a.jsx("div",{className:"admesh-citation-text text-gray-800 dark:text-gray-200 leading-relaxed",children:N()}),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",children:"Powered by AdMesh"})]})]})},fe=({products:e=[],recommendations:t=[],title:o="Product Recommendations",showTitle:r=!0,className:d="",cardClassName:s="",onProductClick:c,showPricing:l=!0,showRatings:h=!0,showBrand:x=!0,showSource:v=!1,showShipping:p=!0,maxCards:u=10,cardWidth:_="md",theme:g="auto",borderRadius:T="md",shadow:N="sm"})=>{const R=t.map(i=>({id:i.id||i.ad_id||i.product_id||`product-${Math.random()}`,title:i.title||"Product Title",price:i.price||99.99,original_price:i.original_price||i.price||129.99,image_url:i.image_url||i.logo_url||"https://via.placeholder.com/300x300?text=Product",brand:i.brand||i.company_name||"Brand",rating:i.rating||4.5,review_count:i.review_count||100,url:i.admesh_link||i.url||"#",source:i.source||i.recommendation_source||"admesh",availability:i.availability||"in_stock",shipping_info:i.shipping_info||{free_shipping_over_35:!0,two_day_shipping:!0},discount_percentage:i.discount_percentage||(i.original_price&&i.price?Math.round((i.original_price-i.price)/i.original_price*100):0),description:i.description||i.reason||"Product description",admesh_link:i.admesh_link||i.url||"#",external_id:i.external_id,trust_score:i.trust_score,intent_match_score:i.intent_match_score,features:i.features||[]})),L=(t.length>0?R:e).slice(0,u),O=()=>{switch(_){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"}},A=()=>{switch(T){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-lg";case"lg":return"rounded-xl";default:return"rounded-lg"}},C=()=>{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"}},M=()=>g==="dark"?"bg-gray-900 text-white":g==="light"?"bg-white text-gray-900":"bg-white dark:bg-gray-900 text-gray-900 dark:text-white",S=i=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:2}).format(i),E=i=>{const b=[],m=Math.floor(i),y=i%1!==0;for(let z=0;z<m;z++)b.push(a.jsx("span",{className:"text-yellow-400",children:"★"},z));y&&b.push(a.jsx("span",{className:"text-yellow-400",children:"☆"},"half"));const k=5-Math.ceil(i);for(let z=0;z<k;z++)b.push(a.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"☆"},`empty-${z}`));return b},F=i=>{if(c)c(i);else{const b=i.admesh_link||i.url;b&&window.open(b,"_blank","noopener,noreferrer")}};return!e||e.length===0?null:a.jsxs("div",{className:D("w-full",d),children:[r&&a.jsxs("div",{className:"mb-4",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:o}),a.jsx("div",{className:"mt-1 h-0.5 w-12 bg-blue-500"})]}),a.jsxs("div",{className:"relative",children:[L.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:L.map(i=>{var b;return a.jsxs("div",{className:D(O(),A(),C(),M(),"flex-shrink-0 border border-gray-200 dark:border-gray-700 transition-all duration-200 cursor-pointer hover:scale-[1.02]",s),onClick:()=>F(i),children:[a.jsxs("div",{className:"relative aspect-square w-full overflow-hidden",children:[i.image_url?a.jsx("img",{src:i.image_url,alt:i.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"})})}),l&&i.discount_percentage&&i.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(i.discount_percentage),"%"]}),v&&i.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:i.source.toUpperCase()})]}),a.jsxs("div",{className:"p-3",children:[x&&i.brand&&a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1 uppercase tracking-wide",children:i.brand}),a.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white line-clamp-2 mb-2 leading-tight",children:i.title}),h&&i.rating&&a.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[a.jsx("div",{className:"flex text-sm",children:E(i.rating)}),a.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["(",i.review_count||0,")"]})]}),l&&i.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:S(i.price)}),i.original_price&&i.original_price>i.price&&a.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 line-through",children:S(i.original_price)})]})}),p&&((b=i.shipping_info)==null?void 0:b.free_shipping_over_35)&&a.jsx("div",{className:"text-xs text-green-600 dark:text-green-400 font-medium",children:"Free shipping over $35"}),i.availability&&i.availability!=="unknown"&&a.jsx("div",{className:D("text-xs font-medium mt-1",i.availability==="in_stock"?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"),children:i.availability==="in_stock"?"In Stock":"Out of Stock"})]})]},i.id)})}),L.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",children:"Powered by AdMesh"})]}),a.jsx("style",{dangerouslySetInnerHTML:{__html:`
694
+ `;let re=!1;const he=()=>{w.useEffect(()=>{if(re)return;const e=document.createElement("style");return e.id="admesh-ui-sdk-styles",e.textContent=Re,document.getElementById("admesh-ui-sdk-styles")||(document.head.appendChild(e),re=!0),()=>{const t=document.getElementById("admesh-ui-sdk-styles");t&&document.head.contains(t)&&(document.head.removeChild(t),re=!1)}},[])},Y=(e,t={})=>{const o=e.intent_match_score||0,r=t.customLabels||{};return o>=.8?r.partnerRecommendation||"Partner Recommendation":o>=.6?r.partnerMatch||"Partner Match":o>=.3?r.promotedOption||"Promoted":r.relatedOption||"Related"},oe=(e,t)=>{const o=e.intent_match_score||0;return o>=.8?"This recommendation is from a partner who compensates us when you engage. We've matched it to your needs based on your query.":o>=.6?"Top-rated partner solution matched to your specific requirements. Partner compensates us for qualified referrals.":o>=.3?"This partner solution may be relevant to your needs. The partner compensates us when you take qualifying actions.":"This solution is somewhat related to your query. While not a perfect match, it might still be helpful. This partner compensates us for qualified referrals."},Me=(e=!0,t=!1)=>e?t?"These curated recommendations are from partners who compensate us for referrals.":"Personalized Partner Recommendations: All results are from vetted partners who compensate us for qualified matches. We've ranked them based on relevance to your specific needs.":"Expanded Results: While these don't perfectly match your query, they're related solutions from our partner network. All partners compensate us for referrals.",Ee=(e,t=!1)=>{const o=e.intent_match_score||0;return t?"Promoted":o>=.8?"Smart Recommendation":o>=.6?"Partner Match":"Promoted"},Ce=()=>"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.",Ae=e=>({"Top Match":"Top Match","Partner Recommendation":"Partner Recommendation","Perfect Fit":"Perfect Fit","Great Match":"Great Match",Recommended:"Recommended","Good Fit":"Good Fit",Featured:"Featured","Popular Choice":"Popular Choice","Premium Pick":"Premium Pick","Free Tier":"Free Tier","AI Powered":"AI Powered",Popular:"Popular",New:"New","Trial Available":"Trial Available","Related Option":"Related Option","Alternative Solution":"Alternative Solution","Expanded Match":"Expanded Match"})[e]||e,Pe=(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"},Ie=e=>e.some(t=>(t.intent_match_score||0)>=.8),$e=(e=!1)=>e?"Powered by AdMesh":"Recommendations powered by AdMesh",ne=({recommendation:e,theme:t,showMatchScore:o=!1,showBadges:r=!0,variation:d="default",expandable:i=!1,className:l,style:c})=>{var f,N,T,R,$,L,O,C,A,M,S,E,F,s;he();const[g,x]=w.useState(!1);w.useMemo(()=>{var z;const b=[];Y(e)==="Partner Recommendation"&&b.push("Top Match"),e.trial_days&&e.trial_days>0&&b.push("Trial Available");const y=["ai","artificial intelligence","machine learning","ml","automation"];return(((z=e.keywords)==null?void 0:z.some(W=>y.some(J=>W.toLowerCase().includes(J))))||e.title.toLowerCase().includes("ai"))&&b.push("AI Powered"),e.badges&&e.badges.length>0&&e.badges.forEach(W=>{["Top Match","Free Tier","AI Powered","Popular","New","Trial Available"].includes(W)&&!b.includes(W)&&b.push(W)}),b},[e]),Math.round(e.intent_match_score*100);const p=d==="simple"?{title:e.recommendation_title||e.title,description:e.recommendation_description||e.description||e.reason,ctaText:e.recommendation_title||e.title,isSimple:!0}:{title:e.recommendation_title||e.title,description:e.recommendation_description||e.description||e.reason,ctaText:e.recommendation_title||e.title},h=D("admesh-component","admesh-card","relative p-4 sm:p-5 rounded-xl bg-gradient-to-br from-white to-gray-50 dark:from-slate-800 dark:to-slate-900 border border-gray-200/50 dark:border-slate-700/50 shadow-lg hover:shadow-xl transition-all duration-300 hover:-translate-y-1",l),_=t?{"--admesh-primary":t.primaryColor||t.accentColor||"#3b82f6","--admesh-secondary":t.secondaryColor||"#10b981","--admesh-accent":t.accentColor||"#3b82f6","--admesh-background":t.backgroundColor,"--admesh-surface":t.surfaceColor,"--admesh-border":t.borderColor,"--admesh-text":t.textColor,"--admesh-text-secondary":t.textSecondaryColor,"--admesh-radius":t.borderRadius||"12px","--admesh-shadow-sm":(f=t.shadows)==null?void 0:f.small,"--admesh-shadow-md":(N=t.shadows)==null?void 0:N.medium,"--admesh-shadow-lg":(T=t.shadows)==null?void 0:T.large,"--admesh-spacing-sm":(R=t.spacing)==null?void 0:R.small,"--admesh-spacing-md":($=t.spacing)==null?void 0:$.medium,"--admesh-spacing-lg":(L=t.spacing)==null?void 0:L.large,"--admesh-font-size-sm":(O=t.fontSize)==null?void 0:O.small,"--admesh-font-size-base":(C=t.fontSize)==null?void 0:C.base,"--admesh-font-size-lg":(A=t.fontSize)==null?void 0:A.large,"--admesh-font-size-title":(M=t.fontSize)==null?void 0:M.title,fontFamily:t.fontFamily,width:((E=(S=t.components)==null?void 0:S.productCard)==null?void 0:E.width)||"100%"}:{width:"100%"};return d==="simple"?a.jsxs("div",{className:D("admesh-component admesh-simple-ad","inline-block text-sm leading-relaxed",l),style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(F=t==null?void 0:t.components)==null?void 0:F.productCard,...c},"data-admesh-theme":t==null?void 0:t.mode,children:[a.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(t==null?void 0:t.accentColor)||"#2563eb",backgroundColor:(t==null?void 0:t.mode)==="dark"?"#374151":"#f3f4f6",padding:"2px 6px",borderRadius:"4px",marginRight:"8px"},title:oe(e,Y(e)),children:Y(e)}),a.jsxs("span",{style:{color:(t==null?void 0:t.mode)==="dark"?"#f3f4f6":"#374151",marginRight:"4px"},children:[p.description," "]}),a.jsx(H,{adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,trackingData:{title:e.title,matchScore:e.intent_match_score,component:"simple_ad_cta"},children:a.jsx("span",{style:{color:(t==null?void 0:t.accentColor)||"#2563eb",textDecoration:"underline",cursor:"pointer",fontSize:"inherit",fontFamily:"inherit"},children:p.ctaText})}),a.jsx("span",{style:{fontSize:"10px",color:(t==null?void 0:t.mode)==="dark"?"#9ca3af":"#6b7280",marginLeft:"8px"},children:"(Sponsored • Powered by AdMesh)"})]}):a.jsx("div",{className:h,style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(s=t==null?void 0:t.components)==null?void 0:s.productCard,...c},"data-admesh-theme":t==null?void 0:t.mode,children:a.jsxs("div",{className:"h-full flex flex-col",style:_,children:[a.jsx("div",{className:"mb-3",children:a.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(t==null?void 0:t.accentColor)||"#2563eb",backgroundColor:(t==null?void 0:t.mode)==="dark"?"#374151":"#f3f4f6",padding:"2px 6px",borderRadius:"4px"},title:oe(e,Y(e)),children:Y(e)})}),a.jsxs("div",{className:"flex justify-between items-center gap-3 mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.product_logo&&a.jsx("img",{src:e.product_logo.url,alt:`${e.title} logo`,className:"w-6 h-6 rounded flex-shrink-0",onError:b=>{b.target.style.display="none"}}),a.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm sm:text-base truncate",children:p.title})]}),a.jsx("div",{className:"flex-shrink-0",children:a.jsx(H,{adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,trackingData:{title:e.title,matchScore:e.intent_match_score,component:"product_card_cta"},children:a.jsxs("button",{className:"text-xs px-2 py-1 sm:px-3 sm:py-2 rounded-full bg-gradient-to-r from-purple-500 to-pink-500 text-white hover:from-purple-600 hover:to-pink-600 flex items-center transition-all duration-200 transform hover:scale-105 shadow-md hover:shadow-lg whitespace-nowrap",children:["Visit",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-6",children:a.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 leading-relaxed",children:p.description})}),e.features&&e.features.length>0&&a.jsxs("div",{className:"mb-3",children:[a.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 font-medium",children:"✨ Key Features"}),a.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[e.features.slice(0,4).map((b,m)=>a.jsxs("span",{className:"text-xs px-2 py-1 rounded-full bg-gradient-to-r from-indigo-100 to-purple-100 dark:from-indigo-900/30 dark:to-purple-900/30 text-indigo-700 dark:text-indigo-300 border border-indigo-200 dark:border-indigo-700",children:[a.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-indigo-500",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"})}),b]},m)),e.features.length>4&&a.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 px-2 py-1",children:["+",e.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",children:"Powered by AdMesh"})]})})]})})};ne.displayName="AdMeshProductCard";const se=({recommendation:e,theme:t,variation:o="default",expandable:r=!1,className:d,style:i})=>{var p,h,_;const[l,c]=w.useState(!1),x=(()=>{const f=e.content_variations;return o==="question"&&(f!=null&&f.question)?{title:f.question.cta||e.recommendation_title||e.title,description:f.question.text,ctaText:f.question.cta||e.recommendation_title||e.title}:o==="statement"&&(f!=null&&f.statement)?{title:e.recommendation_title||e.title,description:f.statement.text,ctaText:f.statement.cta||e.recommendation_title||e.title}:{title:e.recommendation_title||e.title,description:e.recommendation_description||e.reason||"",ctaText:e.recommendation_title||e.title}})(),v=D("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":r&&(o==="question"||o==="statement")},d);return a.jsx("div",{className:v,style:{fontFamily:(t==null?void 0:t.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:((h=(p=t==null?void 0:t.components)==null?void 0:p.inlineRecommendation)==null?void 0:h.width)||"100%",...(_=t==null?void 0:t.components)==null?void 0:_.productCard,...i},"data-admesh-theme":t==null?void 0:t.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:[e.product_logo&&a.jsx("img",{src:e.product_logo.url,alt:`${e.title} logo`,className:"w-5 h-5 rounded flex-shrink-0",onError:f=>{f.target.style.display="none"}}),a.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm truncate",children:x.title})]}),a.jsx("div",{className:"flex-shrink-0",children:a.jsx(H,{adId:e.ad_id,admeshLink:e.admesh_link,productId:e.product_id,trackingData:{title:e.title,matchScore:e.intent_match_score,component:"inline_card_cta"},children: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"})})]})})})]}),x.description&&a.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 line-clamp-2",children:x.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",children:"Powered by AdMesh"})]})})]})})};se.displayName="AdMeshInlineCard";const Le=(e,t,o)=>{let r=e;if(t.forEach((i,l)=>{const c=`link_${l+1}`,g=`{product${l+1}}`,x=`{recommendation${l+1}}`;o.set(c,i),r.includes(g)?r=r.replace(g,`{{LINK_${c}_${i.title}}}`):r.includes(x)&&(r=r.replace(x,`{{LINK_${c}_${i.title}}}`))}),r.match(/\{product\}/g)&&t.length>0){const i="link_1";o.set(i,t[0]),r=r.replace("{product}",`{{LINK_${i}_${t[0].title}}}`)}return{text:r,linkMap:o}},Fe=(e,t,o,r)=>{let d=e;return o.forEach((i,l)=>{const c=Math.min(i.recommendationIndex,t.length-1),g=t[c];if(g){const x=`link_${l+1}`;r.set(x,g);const v=i.linkText||g.title,p=typeof i.pattern=="string"?new RegExp(i.pattern.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"gi"):i.pattern;d=d.replace(p,h=>`${h} {{LINK_${x}_${v}}}`)}}),{text:d,linkMap:r}},ze=(e,t,o)=>{let r=e;return t.forEach((d,i)=>{const l=`link_${i+1}`;o.set(l,d),i===0?r+=` Check out {{LINK_${l}_${d.title}}}`:i===t.length-1&&t.length>1?r+=` and {{LINK_${l}_${d.title}}}`:r+=`, {{LINK_${l}_${d.title}}}`}),{text:r,linkMap:o}},Oe=(e,t,o,r)=>{let d=e;return r.forEach((i,l)=>{const c=new RegExp(`\\b${l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");c.test(d)&&(d=d.replace(c,g=>`{{EXTERNAL_LINK_${g}_${i}}}`))}),t.forEach((i,l)=>{const c=`link_${l+1}`,g=i.title;o.set(c,i);const x=new RegExp(`\\b${g.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if(x.test(d))d=d.replace(x,v=>`{{LINK_${c}_${v}}}`);else{const v=i.keywords||[];let p=!1;for(const h of v){const _=new RegExp(`\\b${h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if(_.test(d)&&!p){d=d.replace(_,f=>(p=!0,`${f} {{LINK_${c}_${g}}}`));break}}p||(d+=` {{LINK_${c}_${g}}}`)}}),{text:d,linkMap:o}},ue=({recommendations:e,conversationTextLinks:t,theme:o,citationStyle:r="numbered",onCitationHover:d,className:i,style:l,dynamicTemplate:c,linkInsertionStrategy:g="auto",customLinkPatterns:x,onTextUpdate:v,enableRealTimeUpdates:p=!1})=>{var L,O,C;const[h,_]=w.useState(null),f=w.useMemo(()=>t?t instanceof Map?t:new Map(Object.entries(t)):new Map,[t]),N=w.useMemo(()=>{var E;if(!e.length)return{text:"",linkMap:new Map};const A=new Map,M=[...e].sort((F,s)=>s.intent_match_score-F.intent_match_score),S=((E=M[0])==null?void 0:E.conversationText)||c||"";return S?g==="template"&&c?Le(c,M,A):g==="keywords"&&x?Fe(S,M,x,A):g==="append"?ze(S,M,A):Oe(S,M,A,f):{text:"",linkMap:new Map}},[e,c,g,x,f]);w.useEffect(()=>{if(p&&v){const{text:A}=N,M=A.replace(/\{\{LINK_[^}]+\}\}/g,S=>{const E=S.match(/\{\{LINK_link_\d+_(.+?)\}\}/);return E?E[1]:S});v(M)}},[N,p,v]);const T=()=>{const{text:A,linkMap:M}=N;return A.split(/(\{\{(?:LINK_|EXTERNAL_LINK_)[^}]+\}\})/).map((E,F)=>{const s=E.match(/\{\{LINK_(link_\d+)_(.+?)\}\}/),b=E.match(/\{\{EXTERNAL_LINK_(.+?)_(.+?)\}\}/);if(s){const m=s[1],y=s[2],k=M.get(m);if(k)return a.jsx("span",{className:"admesh-inline-link",onMouseEnter:()=>{_(k),d==null||d(k)},onMouseLeave:()=>_(null),children:a.jsx("a",{href:k.admesh_link||k.url,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",style:{textDecorationThickness:"1px",textUnderlineOffset:"2px",color:(o==null?void 0:o.accentColor)||void 0},onClick:z=>{k.ad_id&&console.log("AdMesh link clicked:",{adId:k.ad_id,title:k.title,url:k.admesh_link||k.url})},children:y})},`link-${m}-${F}`)}else if(b){const m=b[1],y=b[2];return a.jsx("a",{href:y,target:"_blank",rel:"noopener noreferrer",className:"text-purple-600 dark:text-purple-400 hover:text-purple-800 dark:hover:text-purple-300 underline decoration-purple-600 dark:decoration-purple-400 hover:decoration-purple-800 dark:hover:decoration-purple-300 transition-colors duration-200",style:{textDecorationThickness:"1px",textUnderlineOffset:"2px"},onClick:()=>{console.log("External link clicked:",{companyName:m,url:y})},children:m},`external-${F}`)}return a.jsx("span",{children:E},F)})},R=D("admesh-citation-unit","rounded-xl shadow-sm border border-gray-200 dark:border-gray-800 p-4 bg-white dark:bg-slate-900",i),$=o!=null&&o.accentColor?{"--admesh-primary":o.accentColor}:void 0;return a.jsxs("div",{className:R,style:{...$,fontFamily:(o==null?void 0:o.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:((O=(L=o==null?void 0:o.components)==null?void 0:L.citationUnit)==null?void 0:O.width)||"100%",...(C=o==null?void 0:o.components)==null?void 0:C.citationUnit,...l},"data-admesh-theme":o==null?void 0:o.mode,children:[a.jsx("div",{className:"admesh-citation-text text-gray-800 dark:text-gray-200 leading-relaxed",children:T()}),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",children:"Powered by AdMesh"})]})]})},fe=({products:e=[],recommendations:t=[],title:o="Product Recommendations",showTitle:r=!0,className:d="",cardClassName:i="",onProductClick:l,showPricing:c=!0,showRatings:g=!0,showBrand:x=!0,showSource:v=!1,showShipping:p=!0,maxCards:h=10,cardWidth:_="md",theme:f="auto",borderRadius:N="md",shadow:T="sm"})=>{const R=t.map(s=>({id:s.id||s.ad_id||s.product_id||`product-${Math.random()}`,title:s.title||"Product Title",price:s.price||99.99,original_price:s.original_price||s.price||129.99,image_url:s.image_url||s.logo_url||"https://via.placeholder.com/300x300?text=Product",brand:s.brand||s.company_name||"Brand",rating:s.rating||4.5,review_count:s.review_count||100,url:s.admesh_link||s.url||"#",source:s.source||s.recommendation_source||"admesh",availability:s.availability||"in_stock",shipping_info:s.shipping_info||{free_shipping_over_35:!0,two_day_shipping:!0},discount_percentage:s.discount_percentage||(s.original_price&&s.price?Math.round((s.original_price-s.price)/s.original_price*100):0),description:s.description||s.reason||"Product description",admesh_link:s.admesh_link||s.url||"#",external_id:s.external_id,trust_score:s.trust_score,intent_match_score:s.intent_match_score,features:s.features||[]})),L=(t.length>0?R:e).slice(0,h),O=()=>{switch(_){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"}},C=()=>{switch(N){case"none":return"rounded-none";case"sm":return"rounded-sm";case"md":return"rounded-lg";case"lg":return"rounded-xl";default:return"rounded-lg"}},A=()=>{switch(T){case"none":return"";case"sm":return"shadow-sm hover:shadow-md";case"md":return"shadow-md hover:shadow-lg";case"lg":return"shadow-lg hover:shadow-xl";default:return"shadow-sm hover:shadow-md"}},M=()=>f==="dark"?"bg-gray-900 text-white":f==="light"?"bg-white text-gray-900":"bg-white dark:bg-gray-900 text-gray-900 dark:text-white",S=s=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:2}).format(s),E=s=>{const b=[],m=Math.floor(s),y=s%1!==0;for(let z=0;z<m;z++)b.push(a.jsx("span",{className:"text-yellow-400",children:"★"},z));y&&b.push(a.jsx("span",{className:"text-yellow-400",children:"☆"},"half"));const k=5-Math.ceil(s);for(let z=0;z<k;z++)b.push(a.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"☆"},`empty-${z}`));return b},F=s=>{if(l)l(s);else{const b=s.admesh_link||s.url;b&&window.open(b,"_blank","noopener,noreferrer")}};return!e||e.length===0?null:a.jsxs("div",{className:D("w-full",d),children:[r&&a.jsxs("div",{className:"mb-4",children:[a.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:o}),a.jsx("div",{className:"mt-1 h-0.5 w-12 bg-blue-500"})]}),a.jsxs("div",{className:"relative",children:[L.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:L.map(s=>{var b;return a.jsxs("div",{className:D(O(),C(),A(),M(),"flex-shrink-0 border border-gray-200 dark:border-gray-700 transition-all duration-200 cursor-pointer hover:scale-[1.02]",i),onClick:()=>F(s),children:[a.jsxs("div",{className:"relative aspect-square w-full overflow-hidden",children:[s.image_url?a.jsx("img",{src:s.image_url,alt:s.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"})})}),c&&s.discount_percentage&&s.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(s.discount_percentage),"%"]}),v&&s.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:s.source.toUpperCase()})]}),a.jsxs("div",{className:"p-3",children:[x&&s.brand&&a.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1 uppercase tracking-wide",children:s.brand}),a.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white line-clamp-2 mb-2 leading-tight",children:s.title}),g&&s.rating&&a.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[a.jsx("div",{className:"flex text-sm",children:E(s.rating)}),a.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["(",s.review_count||0,")"]})]}),c&&s.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:S(s.price)}),s.original_price&&s.original_price>s.price&&a.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 line-through",children:S(s.original_price)})]})}),p&&((b=s.shipping_info)==null?void 0:b.free_shipping_over_35)&&a.jsx("div",{className:"text-xs text-green-600 dark:text-green-400 font-medium",children:"Free shipping over $35"}),s.availability&&s.availability!=="unknown"&&a.jsx("div",{className:D("text-xs font-medium mt-1",s.availability==="in_stock"?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"),children:s.availability==="in_stock"?"In Stock":"Out of Stock"})]})]},s.id)})}),L.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",children:"Powered by AdMesh"})]}),a.jsx("style",{dangerouslySetInnerHTML:{__html:`
695
695
  .scrollbar-hide {
696
696
  -ms-overflow-style: none;
697
697
  scrollbar-width: none;
@@ -705,5 +705,5 @@ React keys must be passed directly to JSX without using spread:
705
705
  -webkit-box-orient: vertical;
706
706
  overflow: hidden;
707
707
  }
708
- `}})]})},Ue=e=>{switch(e){case"citation":return"Recommendations";case"inline":return"Recommendations";case"ecommerce":return"Featured Products";case"product":return"Suggested Solutions";default:return"Recommendations"}},De=({recommendations:e=[],conversationTextLinks:t,layout:o,layoutConfig:r,theme:d,className:s,style:c,maxItems:l,columns:h="auto",spacing:x="md",showTitle:v=!0,title:p,productCardProps:u={},citationUnitProps:_={},ecommerceCardsProps:g={},onRecommendationClick:T,onProductClick:N,onCitationHover:R})=>{const{admeshRecommendations:$,walmartRecommendations:L}=w.useMemo(()=>{const m=e.filter(k=>!k.recommendation_source||k.recommendation_source==="admesh"),y=e.filter(k=>k.recommendation_source==="walmart");return{admeshRecommendations:m,walmartRecommendations:y}},[e]),O=w.useMemo(()=>o||(e.some(y=>y.source==="walmart"||y.recommendation_source==="walmart")?"ecommerce":"product"),[o,e]),A=w.useMemo(()=>{if(l!==void 0)return l;switch(O){case"ecommerce":return 3;case"product":case"inline":case"citation":default:return 1}},[l,O]),C=w.useMemo(()=>{if(!r)return{};const m={};return r.backgroundColor&&(m.backgroundColor=r.backgroundColor),r.textColor&&(m.color=r.textColor),r.borderColor&&(m.borderColor=r.borderColor),r.borderRadius&&(m.borderRadius=r.borderRadius),r.fontSize&&(m.fontSize=r.fontSize),r.fontFamily&&(m.fontFamily=r.fontFamily),r.fontWeight&&(m.fontWeight=r.fontWeight),r.lineHeight&&(m.lineHeight=r.lineHeight),r.padding&&(m.padding=r.padding),r.margin&&(m.margin=r.margin),r.shadow&&(m.boxShadow=r.shadow),m},[r]),M=w.useMemo(()=>{if(!r)return{};const m={};return r.primaryColor&&(m["--admesh-primary-color"]=r.primaryColor),r.secondaryColor&&(m["--admesh-secondary-color"]=r.secondaryColor),r.accentColor&&(m["--admesh-accent-color"]=r.accentColor),r.linkColor&&(m["--admesh-link-color"]=r.linkColor),r.hoverColor&&(m["--admesh-hover-color"]=r.hoverColor),r.borderColor&&(m["--admesh-border-color"]=r.borderColor),r.textColor&&(m["--admesh-text-color"]=r.textColor),m},[r]),S=w.useMemo(()=>$.slice(0,A),[$,A]);w.useMemo(()=>L.slice(0,A),[L,A]);const E=w.useMemo(()=>{const m="grid gap-4";let y="";o==="product"?A===1?y="grid-cols-1":h==="auto"?y="grid-cols-1 sm:grid-cols-2 lg:grid-cols-3":typeof h=="number"?y=`grid-cols-1 sm:grid-cols-${Math.min(h,2)} lg:grid-cols-${h}`:y=h:y="grid-cols-1";let k="";switch(x){case"sm":k="gap-2";break;case"md":k="gap-4";break;case"lg":k="gap-6";break;case"xl":k="gap-8";break;default:k=x}return`${m} ${y} ${k}`},[h,x,A,o]),F=()=>{if(!v)return null;const m=p||Ue(o);return a.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100 mb-4",style:{color:r==null?void 0:r.textColor,fontSize:r==null?void 0:r.fontSize,fontFamily:r==null?void 0:r.fontFamily,fontWeight:r==null?void 0:r.fontWeight},children:m})},i=()=>{switch(O){case"citation":return a.jsx(ue,{recommendations:e,conversationTextLinks:t,theme:d,onCitationHover:R,..._});case"ecommerce":return a.jsx(fe,{recommendations:e.slice(0,A),theme:(d==null?void 0:d.mode)||"auto",onProductClick:N,...g});case"product":return a.jsx("div",{className:E,children:S.map((m,y)=>a.jsx(ne,{recommendation:m,theme:d,...u},m.ad_id||y))});case"inline":return a.jsx("div",{className:"space-y-3",children:S.map((m,y)=>a.jsx(se,{recommendation:m,theme:d},m.ad_id||y))});default:return a.jsx("div",{className:"text-gray-500 dark:text-gray-400 text-center py-8",children:"No content to display"})}},b={fontFamily:(d==null?void 0:d.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:o==="ecommerce"?"auto":"100%",...C,...M,...c};return a.jsxs("div",{className:D("admesh-layout",`admesh-layout--${o}`,{"admesh-layout--dark":(d==null?void 0:d.mode)==="dark"||(r==null?void 0:r.darkMode),"admesh-layout--light":(d==null?void 0:d.mode)==="light"||!(r!=null&&r.darkMode)&&(r==null?void 0:r.darkMode)!==void 0},s),style:b,children:[(r==null?void 0:r.customCSS)&&a.jsx("style",{dangerouslySetInnerHTML:{__html:r.customCSS}}),F(),i()]})},We={"Top Match":"primary","Free Tier":"success","AI Powered":"secondary",Popular:"warning",New:"primary","Trial Available":"success"},Be={"Top Match":"★","Free Tier":"◆","AI Powered":"◉",Popular:"▲",New:"●","Trial Available":"◈"},ge=({type:e,variant:t,size:o="md",className:r,style:d})=>{const s=t||We[e]||"secondary",c=Be[e],l=D("admesh-component","admesh-badge",`admesh-badge--${s}`,`admesh-badge--${o}`,r);return a.jsxs("span",{className:l,style:d,children:[c&&a.jsx("span",{className:"admesh-badge__icon",children:c}),a.jsx("span",{className:"admesh-badge__text",children:e})]})};ge.displayName="AdMeshBadge";const q=(e={})=>{const t={mode:"light",primaryColor:"#3b82f6",secondaryColor:"#10b981",accentColor:"#3b82f6",backgroundColor:"#ffffff",surfaceColor:"#f9fafb",borderColor:"#e5e7eb",textColor:"#111827",textSecondaryColor:"#6b7280",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:{small:"12px",base:"14px",large:"16px",title:"18px"},borderRadius:"8px",spacing:{small:"4px",medium:"8px",large:"16px"},shadows:{small:"0 1px 3px rgba(0, 0, 0, 0.1)",medium:"0 4px 6px rgba(0, 0, 0, 0.1)",large:"0 10px 15px rgba(0, 0, 0, 0.1)"},icons:{expandIcon:"▼",collapseIcon:"▲",starIcon:"★",checkIcon:"✓",arrowIcon:"→"},gradients:{primary:"linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)",secondary:"linear-gradient(135deg, #10b981 0%, #059669 100%)",accent:"linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%)"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"},card:{width:"auto"},button:{width:"auto"}}},o={...t,...e,fontSize:{...t.fontSize,...e.fontSize},spacing:{...t.spacing,...e.spacing},shadows:{...t.shadows,...e.shadows},icons:{...t.icons,...e.icons},components:{...t.components,...e.components}};return Ye(o)},qe=(e={})=>q({...{mode:"dark",backgroundColor:"#1f2937",surfaceColor:"#374151",borderColor:"#4b5563",textColor:"#f9fafb",textSecondaryColor:"#9ca3af",shadows:{small:"0 1px 3px rgba(0, 0, 0, 0.3)",medium:"0 4px 6px rgba(0, 0, 0, 0.3)",large:"0 10px 15px rgba(0, 0, 0, 0.3)"}},...e}),Ve={minimal: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)"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}}),vibrant:q({primaryColor:"#8b5cf6",secondaryColor:"#06b6d4",accentColor:"#f59e0b",borderRadius:"12px",gradients:{primary:"linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%)",secondary:"linear-gradient(135deg, #06b6d4 0%, #10b981 100%)",accent:"linear-gradient(135deg, #f59e0b 0%, #ef4444 100%)"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}}),corporate: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%"}}}),highContrast: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%"}}})},Ye=(e={})=>{var o,r,d,s,c,l,h;const t={productCard:{width:"100%",...(o=e.components)==null?void 0:o.productCard},citationUnit:{width:"100%",...(r=e.components)==null?void 0:r.citationUnit},inlineRecommendation:{width:"100%",...(d=e.components)==null?void 0:d.inlineRecommendation},expandableUnit:{width:"100%",...(s=e.components)==null?void 0:s.expandableUnit},compareTable:{width:"100%",...(c=e.components)==null?void 0:c.compareTable},card:{width:"auto",...(l=e.components)==null?void 0:l.card},button:{width:"auto",...(h=e.components)==null?void 0:h.button}};return{...e,components:{...e.components,...t}}},Ke=(...e)=>{const t=q();return e.reduce((o,r)=>r?q({...o,...r}):o,t)},Ge=e=>{var o,r,d,s,c,l;const t=getComputedStyle(e);return{primaryColor:((o=t.getPropertyValue("--admesh-primary-color"))==null?void 0:o.trim())||void 0,secondaryColor:((r=t.getPropertyValue("--admesh-secondary-color"))==null?void 0:r.trim())||void 0,backgroundColor:((d=t.getPropertyValue("--admesh-background-color"))==null?void 0:d.trim())||void 0,textColor:((s=t.getPropertyValue("--admesh-text-color"))==null?void 0:s.trim())||void 0,borderRadius:((c=t.getPropertyValue("--admesh-border-radius"))==null?void 0:c.trim())||void 0,fontFamily:((l=t.getPropertyValue("--admesh-font-family"))==null?void 0:l.trim())||void 0}},He="0.2.1",Je={trackingEnabled:!0,debug:!1,theme:{mode:"light",accentColor:"#2563eb"}};exports.AdMeshBadge=ge;exports.AdMeshCitationUnit=ue;exports.AdMeshEcommerceCards=fe;exports.AdMeshInlineCard=se;exports.AdMeshLayout=De;exports.AdMeshLinkTracker=H;exports.AdMeshProductCard=ne;exports.DEFAULT_CONFIG=Je;exports.VERSION=He;exports.buildAdMeshLink=Ne;exports.createAdMeshTheme=q;exports.createDarkTheme=qe;exports.extractTrackingData=Te;exports.getBadgeText=Ce;exports.getCtaText=Pe;exports.getInlineDisclosure=Ee;exports.getInlineTooltip=Ae;exports.getLabelTooltip=oe;exports.getPoweredByText=$e;exports.getRecommendationLabel=Y;exports.getSectionDisclosure=Me;exports.hasHighQualityMatches=Ie;exports.mergeThemes=Ke;exports.setAdMeshTrackerConfig=Se;exports.themeFromCSSProperties=Ge;exports.themePresets=Ve;exports.useAdMeshStyles=he;exports.useAdMeshTracker=pe;
708
+ `}})]})},Ue=e=>{switch(e){case"citation":return"Recommendations";case"inline":return"Recommendations";case"ecommerce":return"Featured Products";case"product":return"Suggested Solutions";default:return"Recommendations"}},De=({recommendations:e=[],conversationTextLinks:t,layout:o,layoutConfig:r,theme:d,className:i,style:l,maxItems:c,columns:g="auto",spacing:x="md",showTitle:v=!0,title:p,productCardProps:h={},citationUnitProps:_={},ecommerceCardsProps:f={},onRecommendationClick:N,onProductClick:T,onCitationHover:R})=>{const{admeshRecommendations:$,walmartRecommendations:L}=w.useMemo(()=>{const m=e.filter(k=>!k.recommendation_source||k.recommendation_source==="admesh"),y=e.filter(k=>k.recommendation_source==="walmart");return{admeshRecommendations:m,walmartRecommendations:y}},[e]),O=w.useMemo(()=>o||(e.some(y=>y.source==="walmart"||y.recommendation_source==="walmart")?"ecommerce":"product"),[o,e]),C=w.useMemo(()=>{if(c!==void 0)return c;switch(O){case"ecommerce":return 3;case"product":case"inline":case"citation":default:return 1}},[c,O]),A=w.useMemo(()=>{if(!r)return{};const m={};return r.backgroundColor&&(m.backgroundColor=r.backgroundColor),r.textColor&&(m.color=r.textColor),r.borderColor&&(m.borderColor=r.borderColor),r.borderRadius&&(m.borderRadius=r.borderRadius),r.fontSize&&(m.fontSize=r.fontSize),r.fontFamily&&(m.fontFamily=r.fontFamily),r.fontWeight&&(m.fontWeight=r.fontWeight),r.lineHeight&&(m.lineHeight=r.lineHeight),r.padding&&(m.padding=r.padding),r.margin&&(m.margin=r.margin),r.shadow&&(m.boxShadow=r.shadow),m},[r]),M=w.useMemo(()=>{if(!r)return{};const m={};return r.primaryColor&&(m["--admesh-primary-color"]=r.primaryColor),r.secondaryColor&&(m["--admesh-secondary-color"]=r.secondaryColor),r.accentColor&&(m["--admesh-accent-color"]=r.accentColor),r.linkColor&&(m["--admesh-link-color"]=r.linkColor),r.hoverColor&&(m["--admesh-hover-color"]=r.hoverColor),r.borderColor&&(m["--admesh-border-color"]=r.borderColor),r.textColor&&(m["--admesh-text-color"]=r.textColor),m},[r]),S=w.useMemo(()=>$.slice(0,C),[$,C]);w.useMemo(()=>L.slice(0,C),[L,C]);const E=w.useMemo(()=>{const m="grid gap-4";let y="";o==="product"?C===1?y="grid-cols-1":g==="auto"?y="grid-cols-1 sm:grid-cols-2 lg:grid-cols-3":typeof g=="number"?y=`grid-cols-1 sm:grid-cols-${Math.min(g,2)} lg:grid-cols-${g}`:y=g:y="grid-cols-1";let k="";switch(x){case"sm":k="gap-2";break;case"md":k="gap-4";break;case"lg":k="gap-6";break;case"xl":k="gap-8";break;default:k=x}return`${m} ${y} ${k}`},[g,x,C,o]),F=()=>{if(!v)return null;const m=p||Ue(o);return a.jsx("h2",{className:"text-xl font-semibold text-gray-900 dark:text-gray-100 mb-4",style:{color:r==null?void 0:r.textColor,fontSize:r==null?void 0:r.fontSize,fontFamily:r==null?void 0:r.fontFamily,fontWeight:r==null?void 0:r.fontWeight},children:m})},s=()=>{switch(O){case"citation":return a.jsx(ue,{recommendations:e,conversationTextLinks:t,theme:d,onCitationHover:R,..._});case"ecommerce":return a.jsx(fe,{recommendations:e.slice(0,C),theme:(d==null?void 0:d.mode)||"auto",onProductClick:T,...f});case"product":return a.jsx("div",{className:E,children:S.map((m,y)=>a.jsx(ne,{recommendation:m,theme:d,...h},m.ad_id||y))});case"inline":return a.jsx("div",{className:"space-y-3",children:S.map((m,y)=>a.jsx(se,{recommendation:m,theme:d},m.ad_id||y))});default:return a.jsx("div",{className:"text-gray-500 dark:text-gray-400 text-center py-8",children:"No content to display"})}},b={fontFamily:(d==null?void 0:d.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',width:o==="ecommerce"?"auto":"100%",...A,...M,...l};return a.jsxs("div",{className:D("admesh-layout",`admesh-layout--${o}`,{"admesh-layout--dark":(d==null?void 0:d.mode)==="dark"||(r==null?void 0:r.darkMode),"admesh-layout--light":(d==null?void 0:d.mode)==="light"||!(r!=null&&r.darkMode)&&(r==null?void 0:r.darkMode)!==void 0},i),style:b,children:[(r==null?void 0:r.customCSS)&&a.jsx("style",{dangerouslySetInnerHTML:{__html:r.customCSS}}),F(),s()]})},We={"Top Match":"primary","Free Tier":"success","AI Powered":"secondary",Popular:"warning",New:"primary","Trial Available":"success"},Be={"Top Match":"★","Free Tier":"◆","AI Powered":"◉",Popular:"▲",New:"●","Trial Available":"◈"},ge=({type:e,variant:t,size:o="md",className:r,style:d})=>{const i=t||We[e]||"secondary",l=Be[e],c=D("admesh-component","admesh-badge",`admesh-badge--${i}`,`admesh-badge--${o}`,r);return a.jsxs("span",{className:c,style:d,children:[l&&a.jsx("span",{className:"admesh-badge__icon",children:l}),a.jsx("span",{className:"admesh-badge__text",children:e})]})};ge.displayName="AdMeshBadge";const q=(e={})=>{const t={mode:"light",primaryColor:"#3b82f6",secondaryColor:"#10b981",accentColor:"#3b82f6",backgroundColor:"#ffffff",surfaceColor:"#f9fafb",borderColor:"#e5e7eb",textColor:"#111827",textSecondaryColor:"#6b7280",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',fontSize:{small:"12px",base:"14px",large:"16px",title:"18px"},borderRadius:"8px",spacing:{small:"4px",medium:"8px",large:"16px"},shadows:{small:"0 1px 3px rgba(0, 0, 0, 0.1)",medium:"0 4px 6px rgba(0, 0, 0, 0.1)",large:"0 10px 15px rgba(0, 0, 0, 0.1)"},icons:{expandIcon:"▼",collapseIcon:"▲",starIcon:"★",checkIcon:"✓",arrowIcon:"→"},gradients:{primary:"linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%)",secondary:"linear-gradient(135deg, #10b981 0%, #059669 100%)",accent:"linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%)"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"},card:{width:"auto"},button:{width:"auto"}}},o={...t,...e,fontSize:{...t.fontSize,...e.fontSize},spacing:{...t.spacing,...e.spacing},shadows:{...t.shadows,...e.shadows},icons:{...t.icons,...e.icons},components:{...t.components,...e.components}};return Ye(o)},qe=(e={})=>q({...{mode:"dark",backgroundColor:"#1f2937",surfaceColor:"#374151",borderColor:"#4b5563",textColor:"#f9fafb",textSecondaryColor:"#9ca3af",shadows:{small:"0 1px 3px rgba(0, 0, 0, 0.3)",medium:"0 4px 6px rgba(0, 0, 0, 0.3)",large:"0 10px 15px rgba(0, 0, 0, 0.3)"}},...e}),Ve={minimal: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)"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}}),vibrant:q({primaryColor:"#8b5cf6",secondaryColor:"#06b6d4",accentColor:"#f59e0b",borderRadius:"12px",gradients:{primary:"linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%)",secondary:"linear-gradient(135deg, #06b6d4 0%, #10b981 100%)",accent:"linear-gradient(135deg, #f59e0b 0%, #ef4444 100%)"},components:{productCard:{width:"100%"},citationUnit:{width:"100%"},inlineRecommendation:{width:"100%"},expandableUnit:{width:"100%"},compareTable:{width:"100%"}}}),corporate: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%"}}}),highContrast: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%"}}})},Ye=(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}}},Ke=(...e)=>{const t=q();return e.reduce((o,r)=>r?q({...o,...r}):o,t)},Ge=e=>{var o,r,d,i,l,c;const t=getComputedStyle(e);return{primaryColor:((o=t.getPropertyValue("--admesh-primary-color"))==null?void 0:o.trim())||void 0,secondaryColor:((r=t.getPropertyValue("--admesh-secondary-color"))==null?void 0:r.trim())||void 0,backgroundColor:((d=t.getPropertyValue("--admesh-background-color"))==null?void 0:d.trim())||void 0,textColor:((i=t.getPropertyValue("--admesh-text-color"))==null?void 0:i.trim())||void 0,borderRadius:((l=t.getPropertyValue("--admesh-border-radius"))==null?void 0:l.trim())||void 0,fontFamily:((c=t.getPropertyValue("--admesh-font-family"))==null?void 0:c.trim())||void 0}},He="0.2.1",Je={trackingEnabled:!0,debug:!1,theme:{mode:"light",accentColor:"#2563eb"}};exports.AdMeshBadge=ge;exports.AdMeshCitationUnit=ue;exports.AdMeshEcommerceCards=fe;exports.AdMeshInlineCard=se;exports.AdMeshLayout=De;exports.AdMeshLinkTracker=H;exports.AdMeshProductCard=ne;exports.DEFAULT_CONFIG=Je;exports.VERSION=He;exports.buildAdMeshLink=Te;exports.createAdMeshTheme=q;exports.createDarkTheme=qe;exports.extractTrackingData=Ne;exports.getBadgeText=Ae;exports.getCtaText=Pe;exports.getInlineDisclosure=Ee;exports.getInlineTooltip=Ce;exports.getLabelTooltip=oe;exports.getPoweredByText=$e;exports.getRecommendationLabel=Y;exports.getSectionDisclosure=Me;exports.hasHighQualityMatches=Ie;exports.mergeThemes=Ke;exports.setAdMeshTrackerConfig=Se;exports.themeFromCSSProperties=Ge;exports.themePresets=Ve;exports.useAdMeshStyles=he;exports.useAdMeshTracker=pe;
709
709
  //# sourceMappingURL=index.js.map