admesh-ui-sdk 0.10.1 → 0.11.0
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 +24 -0
- package/dist/components/AdMeshEcommerceCards.d.ts +43 -0
- package/dist/components/AdMeshEcommerceCards.d.ts.map +1 -0
- package/dist/components/AdMeshProductCard.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +876 -708
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +40 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react");function Le(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ee={exports:{}},Q={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var he;function
|
|
9
|
+
*/var he;function Te(){if(he)return Q;he=1;var t=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function s(i,n,a){var d=null;if(a!==void 0&&(d=""+a),n.key!==void 0&&(d=""+n.key),"key"in n){a={};for(var c in n)c!=="key"&&(a[c]=n[c])}else a=n;return n=a.ref,{$$typeof:t,type:i,key:d,ref:n!==void 0?n:null,props:a}}return Q.Fragment=r,Q.jsx=s,Q.jsxs=s,Q}var X={};/**
|
|
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 ue;function Ae(){return ue||(ue=1,process.env.NODE_ENV!=="production"&&function(){function t(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===P?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case
|
|
17
|
+
*/var ue;function Ae(){return ue||(ue=1,process.env.NODE_ENV!=="production"&&function(){function t(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===P?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case u:return"Fragment";case j:return"Profiler";case f:return"StrictMode";case L:return"Suspense";case R:return"SuspenseList";case A:return"Activity"}if(typeof l=="object")switch(typeof l.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),l.$$typeof){case w:return"Portal";case C:return(l.displayName||"Context")+".Provider";case b:return(l._context.displayName||"Context")+".Consumer";case T:var M=l.render;return l=l.displayName,l||(l=M.displayName||M.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case N:return M=l.displayName||null,M!==null?M:t(l.type)||"Memo";case x:M=l._payload,l=l._init;try{return t(l(M))}catch{}}return null}function r(l){return""+l}function s(l){try{r(l);var M=!1}catch{M=!0}if(M){M=console;var E=M.error,W=typeof Symbol=="function"&&Symbol.toStringTag&&l[Symbol.toStringTag]||l.constructor.name||"Object";return E.call(M,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",W),r(l)}}function i(l){if(l===u)return"<>";if(typeof l=="object"&&l!==null&&l.$$typeof===x)return"<...>";try{var M=t(l);return M?"<"+M+">":"<...>"}catch{return"<...>"}}function n(){var l=I.A;return l===null?null:l.getOwner()}function a(){return Error("react-stack-top-frame")}function d(l){if(O.call(l,"key")){var M=Object.getOwnPropertyDescriptor(l,"key").get;if(M&&M.isReactWarning)return!1}return l.key!==void 0}function c(l,M){function E(){v||(v=!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)",M))}E.isReactWarning=!0,Object.defineProperty(l,"key",{get:E,configurable:!0})}function p(){var l=t(this.type);return B[l]||(B[l]=!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.")),l=this.props.ref,l!==void 0?l:null}function m(l,M,E,W,H,V,oe,ne){return E=V.ref,l={$$typeof:y,type:l,key:M,props:V,_owner:H},(E!==void 0?E:null)!==null?Object.defineProperty(l,"ref",{enumerable:!1,get:p}):Object.defineProperty(l,"ref",{enumerable:!1,value:null}),l._store={},Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(l,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(l,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:oe}),Object.defineProperty(l,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ne}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}function g(l,M,E,W,H,V,oe,ne){var F=M.children;if(F!==void 0)if(W)if(z(F)){for(W=0;W<F.length;W++)h(F[W]);Object.freeze&&Object.freeze(F)}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 h(F);if(O.call(M,"key")){F=t(l);var G=Object.keys(M).filter(function(Se){return Se!=="key"});W=0<G.length?"{key: someKey, "+G.join(": ..., ")+": ...}":"{key: someKey}",J[F+W]||(G=0<G.length?"{"+G.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,
|
|
22
|
+
<%s key={someKey} {...props} />`,W,F,G,F),J[F+W]=!0)}if(F=null,E!==void 0&&(s(E),F=""+E),d(M)&&(s(M.key),F=""+M.key),"key"in M){E={};for(var le in M)le!=="key"&&(E[le]=M[le])}else E=M;return F&&c(E,typeof l=="function"?l.displayName||l.name||"Unknown":l),m(l,F,V,H,n(),E,oe,ne)}function h(l){typeof l=="object"&&l!==null&&l.$$typeof===y&&l._store&&(l._store.validated=1)}var o=k,y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),u=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),C=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),L=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),P=Symbol.for("react.client.reference"),I=o.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,O=Object.prototype.hasOwnProperty,z=Array.isArray,S=console.createTask?console.createTask:function(){return null};o={"react-stack-bottom-frame":function(l){return l()}};var v,B={},$=o["react-stack-bottom-frame"].bind(o,a)(),K=S(i(a)),J={};X.Fragment=u,X.jsx=function(l,M,E,W,H){var V=1e4>I.recentlyCreatedOwnerStacks++;return g(l,M,E,!1,W,H,V?Error("react-stack-top-frame"):$,V?S(i(l)):K)},X.jsxs=function(l,M,E,W,H){var V=1e4>I.recentlyCreatedOwnerStacks++;return g(l,M,E,!0,W,H,V?Error("react-stack-top-frame"):$,V?S(i(l)):K)}}()),X}var pe;function Re(){return pe||(pe=1,process.env.NODE_ENV==="production"?ee.exports=Te():ee.exports=Ae()),ee.exports}var e=Re(),ie={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 ge;function Ee(){return ge||(ge=1,function(t){(function(){var r={}.hasOwnProperty;function s(){for(var a="",d=0;d<arguments.length;d++){var c=arguments[d];c&&(a=n(a,i(c)))}return a}function i(a){if(typeof a=="string"||typeof a=="number")return a;if(typeof a!="object")return"";if(Array.isArray(a))return s.apply(null,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var d="";for(var c in a)r.call(a,c)&&a[c]&&(d=n(d,c));return d}function n(a,d){return d?a?a+" "+d:a+d:a}t.exports?(s.default=s,t.exports=s):window.classNames=s})()}(ie)),ie.exports}var Ie=Ee();const
|
|
26
|
+
*/var ge;function Ee(){return ge||(ge=1,function(t){(function(){var r={}.hasOwnProperty;function s(){for(var a="",d=0;d<arguments.length;d++){var c=arguments[d];c&&(a=n(a,i(c)))}return a}function i(a){if(typeof a=="string"||typeof a=="number")return a;if(typeof a!="object")return"";if(Array.isArray(a))return s.apply(null,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var d="";for(var c in a)r.call(a,c)&&a[c]&&(d=n(d,c));return d}function n(a,d){return d?a?a+" "+d:a+d:a}t.exports?(s.default=s,t.exports=s):window.classNames=s})()}(ie)),ie.exports}var Ie=Ee();const _=Le(Ie),Pe="https://api.useadmesh.com/track";let ce={apiBaseUrl:Pe,enabled:!0,debug:!1,retryAttempts:3,retryDelay:1e3};const ze=t=>{ce={...ce,...t}},fe=t=>{const[r,s]=k.useState(!1),[i,n]=k.useState(null),a=k.useMemo(()=>({...ce,...t}),[t]),d=k.useCallback((h,o)=>{a.debug&&console.log(`[AdMesh Tracker] ${h}`,o)},[a.debug]),c=k.useCallback(async(h,o)=>{if(!a.enabled){d("Tracking disabled, skipping event",{eventType:h,data:o});return}if(!o.adId||!o.admeshLink){const f="Missing required tracking data: adId and admeshLink are required";d(f,o),n(f);return}s(!0),n(null);const y={event_type:h,ad_id:o.adId,admesh_link:o.admeshLink,product_id:o.productId,user_id:o.userId,session_id:o.sessionId,revenue:o.revenue,conversion_type:o.conversionType,metadata:o.metadata,timestamp:new Date().toISOString(),user_agent:navigator.userAgent,referrer:document.referrer,page_url:window.location.href};d(`Sending ${h} event`,y);let w=null;for(let f=1;f<=(a.retryAttempts||3);f++)try{const j=await fetch(`${a.apiBaseUrl}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(y)});if(!j.ok)throw new Error(`HTTP ${j.status}: ${j.statusText}`);const b=await j.json();d(`${h} event tracked successfully`,b),s(!1);return}catch(j){w=j,d(`Attempt ${f} failed for ${h} event`,j),f<(a.retryAttempts||3)&&await new Promise(b=>setTimeout(b,(a.retryDelay||1e3)*f))}const u=`Failed to track ${h} event after ${a.retryAttempts} attempts: ${w==null?void 0:w.message}`;d(u,w),n(u),s(!1)},[a,d]),p=k.useCallback(async h=>c("click",h),[c]),m=k.useCallback(async h=>c("view",h),[c]),g=k.useCallback(async h=>(!h.revenue&&!h.conversionType&&d("Warning: Conversion tracking without revenue or conversion type",h),c("conversion",h)),[c,d]);return{trackClick:p,trackView:m,trackConversion:g,isTracking:r,error:i}},Be=(t,r,s)=>{try{const i=new URL(t);return i.searchParams.set("ad_id",r),i.searchParams.set("utm_source","admesh"),i.searchParams.set("utm_medium","recommendation"),s&&Object.entries(s).forEach(([n,a])=>{i.searchParams.set(n,a)}),i.toString()}catch(i){return console.warn("[AdMesh] Invalid URL provided to buildAdMeshLink:",t,i),t}},We=(t,r)=>({adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,...r}),D=({adId:t,admeshLink:r,productId:s,children:i,trackingData:n,className:a,style:d})=>{const{trackClick:c,trackView:p}=fe(),m=k.useRef(null),g=k.useRef(!1);k.useEffect(()=>{if(!m.current||g.current)return;const o=new IntersectionObserver(y=>{y.forEach(w=>{w.isIntersecting&&!g.current&&(g.current=!0,p({adId:t,admeshLink:r,productId:s,...n}).catch(console.error))})},{threshold:.5,rootMargin:"0px"});return o.observe(m.current),()=>{o.disconnect()}},[t,r,s,n,p]);const h=k.useCallback(async o=>{try{await c({adId:t,admeshLink:r,productId:s,...n})}catch(u){console.error("Failed to track click:",u)}o.target.closest("a")||window.open(r,"_blank","noopener,noreferrer")},[t,r,s,n,c]);return e.jsx("div",{ref:m,className:a,onClick:h,style:{cursor:"pointer",...d},children:i})};D.displayName="AdMeshLinkTracker";const Fe=`
|
|
27
27
|
/* AdMesh UI SDK - Complete Self-Contained Styles */
|
|
28
28
|
|
|
29
29
|
/* CSS Reset for AdMesh components */
|
|
@@ -667,5 +667,19 @@ React keys must be passed directly to JSX without using spread:
|
|
|
667
667
|
.admesh-component .lg\\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
668
668
|
.admesh-component .lg\\:col-span-1 { grid-column: span 1 / span 1; }
|
|
669
669
|
}
|
|
670
|
-
`;let de=!1;const re=()=>{y.useEffect(()=>{if(de)return;const t=document.createElement("style");return t.id="admesh-ui-sdk-styles",t.textContent=Fe,document.getElementById("admesh-ui-sdk-styles")||(document.head.appendChild(t),de=!0),()=>{const r=document.getElementById("admesh-ui-sdk-styles");r&&document.head.contains(r)&&(document.head.removeChild(r),de=!1)}},[])},Y=(t,r={})=>{const s=t.intent_match_score||0,i=r.customLabels||{};return s>=.8?i.smartPick||"Smart Pick":s>=.6?i.partnerMatch||"Partner Match":s>=.3?i.promotedOption||"Promoted Option":i.relatedOption||"Related Option"},Z=(t,r)=>{const s=t.intent_match_score||0;return s>=.8?"This recommendation is from a partner who compensates us when you engage. We've matched it to your needs based on your query.":s>=.6?"Top-rated partner solution matched to your specific requirements. Partner compensates us for qualified referrals.":s>=.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."},Oe=(t=!0,r=!1)=>t?r?"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.",te=(t,r=!1)=>{const s=t.intent_match_score||0;return r?"Promoted Match":s>=.8?"Smart Pick":s>=.6?"Partner Match":"Promoted Option"},se=()=>"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.",be=t=>({"Top Match":"Top Match","Smart Pick":"Smart Pick","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"})[t]||t,$e=(t,r="button")=>{const s=t.recommendation_title||t.title;return r==="link"?s:t.trial_days&&t.trial_days>0?`Try ${s}`:"Learn More"},De=t=>t.some(r=>(r.intent_match_score||0)>=.8),Ve=(t=!1)=>t?"Powered by AdMesh":"Recommendations powered by AdMesh",ae=({recommendation:t,theme:r,showMatchScore:s=!1,showBadges:i=!0,variation:n="default",className:a,style:d})=>{var w,b,N,S,M,A,j,T,E,P,I,F,V;re();const[c,p]=y.useState(!1),m=y.useMemo(()=>{var K;const x=[];Y(t)==="Smart Pick"&&x.push("Top Match"),t.trial_days&&t.trial_days>0&&x.push("Trial Available");const U=["ai","artificial intelligence","machine learning","ml","automation"];return(((K=t.keywords)==null?void 0:K.some(q=>U.some(l=>q.toLowerCase().includes(l))))||t.title.toLowerCase().includes("ai"))&&x.push("AI Powered"),t.badges&&t.badges.length>0&&t.badges.forEach(q=>{["Top Match","Free Tier","AI Powered","Popular","New","Trial Available"].includes(q)&&!x.includes(q)&&x.push(q)}),x},[t]),u=te(t,!1),h=se(),o=Math.round(t.intent_match_score*100),f=(()=>{const x=t.content_variations;return n==="simple"?{title:t.recommendation_title||t.title,description:t.recommendation_description||t.description||t.reason,ctaText:t.recommendation_title||t.title,isSimple:!0}:n==="question"&&(x!=null&&x.question)?{title:x.question.cta||t.recommendation_title||t.title,description:x.question.text,ctaText:x.question.cta||t.recommendation_title||t.title}:n==="statement"&&(x!=null&&x.statement)?{title:t.recommendation_title||t.title,description:x.statement.text,ctaText:x.statement.cta||t.recommendation_title||t.title}:{title:t.recommendation_title||t.title,description:t.recommendation_description||t.description||t.reason,ctaText:t.recommendation_title||t.title}})(),k=C("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",a),g=r?{"--admesh-primary":r.primaryColor||r.accentColor||"#3b82f6","--admesh-secondary":r.secondaryColor||"#10b981","--admesh-accent":r.accentColor||"#3b82f6","--admesh-background":r.backgroundColor,"--admesh-surface":r.surfaceColor,"--admesh-border":r.borderColor,"--admesh-text":r.textColor,"--admesh-text-secondary":r.textSecondaryColor,"--admesh-radius":r.borderRadius||"12px","--admesh-shadow-sm":(w=r.shadows)==null?void 0:w.small,"--admesh-shadow-md":(b=r.shadows)==null?void 0:b.medium,"--admesh-shadow-lg":(N=r.shadows)==null?void 0:N.large,"--admesh-spacing-sm":(S=r.spacing)==null?void 0:S.small,"--admesh-spacing-md":(M=r.spacing)==null?void 0:M.medium,"--admesh-spacing-lg":(A=r.spacing)==null?void 0:A.large,"--admesh-font-size-sm":(j=r.fontSize)==null?void 0:j.small,"--admesh-font-size-base":(T=r.fontSize)==null?void 0:T.base,"--admesh-font-size-lg":(E=r.fontSize)==null?void 0:E.large,"--admesh-font-size-title":(P=r.fontSize)==null?void 0:P.title,fontFamily:r.fontFamily}:void 0;return n==="simple"?e.jsxs("div",{className:C("admesh-component admesh-simple-ad","inline-block text-sm leading-relaxed",a),style:{fontFamily:(r==null?void 0:r.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(I=r==null?void 0:r.components)==null?void 0:I.productCard,...d},"data-admesh-theme":r==null?void 0:r.mode,children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(r==null?void 0:r.accentColor)||"#2563eb",backgroundColor:(r==null?void 0:r.mode)==="dark"?"#374151":"#f3f4f6",padding:"2px 6px",borderRadius:"4px",marginRight:"8px"},title:Z(t,Y(t)),children:Y(t)}),e.jsxs("span",{style:{color:(r==null?void 0:r.mode)==="dark"?"#f3f4f6":"#374151",marginRight:"4px"},children:[f.description," "]}),e.jsx(W,{adId: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:e.jsx("span",{style:{color:(r==null?void 0:r.accentColor)||"#2563eb",textDecoration:"underline",cursor:"pointer",fontSize:"inherit",fontFamily:"inherit"},children:f.ctaText})}),e.jsxs("span",{style:{fontSize:"10px",color:(r==null?void 0:r.mode)==="dark"?"#9ca3af":"#6b7280",marginLeft:"8px"},title:h,children:["(",u,")"]})]}):n==="question"||n==="statement"?e.jsx("div",{className:C("admesh-component admesh-expandable-variation transition-all duration-300",c?"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":"p-4 rounded-lg bg-white dark:bg-slate-800 border border-gray-200 dark:border-slate-700 shadow-sm hover:shadow-md",a),style:{fontFamily:(r==null?void 0:r.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(F=r==null?void 0:r.components)==null?void 0:F.productCard,...d},"data-admesh-theme":r==null?void 0:r.mode,children:c?e.jsxs("div",{className:"h-full flex flex-col",style:g,"data-admesh-theme":r==null?void 0:r.mode,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-start gap-3 mb-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 flex-1 min-w-0",children:[i&&m.includes("Top Match")&&e.jsx("span",{className:"text-xs font-semibold text-white px-3 py-1 rounded-full w-fit shadow-md",style:{backgroundColor:(r==null?void 0:r.primaryColor)||(r==null?void 0:r.accentColor)||"#f59e0b",borderRadius:(r==null?void 0:r.borderRadius)||"9999px"},title:Z(t),children:be("Top Match")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.product_logo&&e.jsx("img",{src:t.product_logo.url,alt:`${t.title} logo`,className:"w-6 h-6 rounded flex-shrink-0",onError:x=>{x.target.style.display="none"}}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm sm:text-base truncate",children:f.title})]})]}),e.jsxs("div",{className:"flex gap-3 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>p(!1),className:"flex items-center gap-2 px-3 py-2 text-xs font-medium text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-800/50 rounded-lg transition-all duration-200 border border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600",title:"Show less details",children:[e.jsx("span",{children:"Less Details"}),e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})]}),e.jsx(W,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:t.intent_match_score,component:"product_card_cta"},children:e.jsxs("button",{className:"text-xs sm:text-sm px-3 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",children:[n==="question"?"Try":"Visit"," ",f.ctaText,e.jsx("svg",{className:"ml-1 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})})]})})]})]}),e.jsx("div",{className:"mb-6",children:e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 leading-relaxed",children:f.description})}),e.jsx("div",{className:"mb-6",children:e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 leading-relaxed",title:h,children:u})}),s&&typeof t.intent_match_score=="number"&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs sm:text-sm text-gray-600 dark:text-gray-300 mb-2",children:[e.jsx("span",{className:"font-medium",children:"Match Score"}),e.jsxs("span",{className:"font-bold text-transparent bg-clip-text bg-gradient-to-r from-green-500 to-blue-500 whitespace-nowrap",children:[o,"% match"]})]}),e.jsx("div",{className:"w-full bg-gray-200 dark:bg-slate-600 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-gradient-to-r from-green-400 to-blue-500 h-2 rounded-full transition-all duration-500 ease-out",style:{width:`${o}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-3",children:[t.pricing&&e.jsxs("span",{className:"flex items-center px-2 py-1 rounded-full bg-gradient-to-r from-green-100 to-emerald-100 dark:from-green-900/30 dark:to-emerald-900/30 text-green-700 dark:text-green-300 border border-green-200 dark:border-green-700",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"})}),t.pricing]}),t.trial_days&&t.trial_days>0&&e.jsxs("span",{className:"flex items-center px-2 py-1 rounded-full bg-gradient-to-r from-blue-100 to-cyan-100 dark:from-blue-900/30 dark:to-cyan-900/30 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3a2 2 0 012-2h4a2 2 0 012 2v4m-6 4v10m6-10v10m-6 0h6"})}),t.trial_days,"-day trial"]})]}),t.features&&t.features.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 font-medium",children:"✨ Key Features"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.features.slice(0,4).map((x,L)=>e.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:[e.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-indigo-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})}),x]},L)),t.features.length>4&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 px-2 py-1",children:["+",t.features.length-4," more"]})]})]}),t.integrations&&t.integrations.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 font-medium",children:"🔗 Integrations"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.integrations.slice(0,3).map((x,L)=>e.jsxs("span",{className:"text-xs px-2 py-1 rounded-full bg-gradient-to-r from-orange-100 to-red-100 dark:from-orange-900/30 dark:to-red-900/30 text-orange-700 dark:text-orange-300 border border-orange-200 dark:border-orange-700",children:[e.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-orange-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),x]},L)),t.integrations.length>3&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 px-2 py-1",children:["+",t.integrations.length-3," more"]})]})]}),e.jsx("div",{className:"flex justify-end mt-auto pt-2",children:e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Powered by AdMesh"})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(r==null?void 0:r.accentColor)||"#2563eb",backgroundColor:(r==null?void 0:r.mode)==="dark"?"#374151":"#f3f4f6",padding:"2px 6px",borderRadius:"4px"},title:Z(t,Y(t)),children:Y(t)})}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed",children:[f.description," ",e.jsx(W,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:t.intent_match_score,component:"simple_variation_cta"},children:e.jsx("span",{className:"text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 underline cursor-pointer font-medium transition-colors",children:f.ctaText})})]})}),e.jsx("div",{className:"flex items-center gap-3 flex-shrink-0",children:e.jsxs("button",{onClick:()=>p(!0),className:"flex items-center gap-2 px-3 py-2 text-xs font-medium text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-lg transition-all duration-200 border border-blue-200 dark:border-blue-700 hover:border-blue-300 dark:hover:border-blue-600",title:"View more details",children:[e.jsx("span",{children:"More Details"}),e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})]})})]})]})}):e.jsx("div",{className:k,style:{fontFamily:(r==null?void 0:r.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(V=r==null?void 0:r.components)==null?void 0:V.productCard,...d},"data-admesh-theme":r==null?void 0:r.mode,children:e.jsxs("div",{className:"h-full flex flex-col",style:g,children:[e.jsx("div",{className:"mb-3",children:e.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(r==null?void 0:r.accentColor)||"#2563eb",backgroundColor:(r==null?void 0:r.mode)==="dark"?"#374151":"#f3f4f6",padding:"2px 6px",borderRadius:"4px"},title:Z(t,Y(t)),children:Y(t)})}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-start gap-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[t.product_logo&&e.jsx("img",{src:t.product_logo.url,alt:`${t.title} logo`,className:"w-6 h-6 rounded flex-shrink-0",onError:x=>{x.target.style.display="none"}}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm sm:text-base truncate",children:f.title})]}),e.jsx("div",{className:"flex gap-2 flex-shrink-0",children:e.jsx(W,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:t.intent_match_score,component:"product_card_cta"},children:e.jsxs("button",{className:"text-xs sm:text-sm px-3 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",children:["Visit ",f.ctaText,e.jsx("svg",{className:"ml-1 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})})]})})})]}),e.jsx("div",{className:"mb-6",children:e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 leading-relaxed",children:f.description})}),s&&typeof t.intent_match_score=="number"&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs sm:text-sm text-gray-600 dark:text-gray-300 mb-2",children:[e.jsx("span",{className:"font-medium",children:"Match Score"}),e.jsxs("span",{className:"font-bold text-transparent bg-clip-text bg-gradient-to-r from-green-500 to-blue-500 whitespace-nowrap",children:[o,"% match"]})]}),e.jsx("div",{className:"w-full bg-gray-200 dark:bg-slate-600 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-gradient-to-r from-green-400 to-blue-500 h-2 rounded-full transition-all duration-500 ease-out",style:{width:`${o}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-3",children:[t.pricing&&e.jsxs("span",{className:"flex items-center px-2 py-1 rounded-full bg-gradient-to-r from-green-100 to-emerald-100 dark:from-green-900/30 dark:to-emerald-900/30 text-green-700 dark:text-green-300 border border-green-200 dark:border-green-700",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"})}),t.pricing]}),t.trial_days&&t.trial_days>0&&e.jsxs("span",{className:"flex items-center px-2 py-1 rounded-full bg-gradient-to-r from-blue-100 to-cyan-100 dark:from-blue-900/30 dark:to-cyan-900/30 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3a2 2 0 012-2h4a2 2 0 012 2v4m-6 4v10m6-10v10m-6 0h6"})}),t.trial_days,"-day trial"]})]}),t.features&&t.features.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 font-medium",children:"✨ Key Features"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.features.slice(0,4).map((x,L)=>e.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:[e.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-indigo-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})}),x]},L)),t.features.length>4&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 px-2 py-1",children:["+",t.features.length-4," more"]})]})]}),t.integrations&&t.integrations.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 font-medium",children:"🔗 Integrations"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.integrations.slice(0,3).map((x,L)=>e.jsxs("span",{className:"text-xs px-2 py-1 rounded-full bg-gradient-to-r from-orange-100 to-red-100 dark:from-orange-900/30 dark:to-red-900/30 text-orange-700 dark:text-orange-300 border border-orange-200 dark:border-orange-700",children:[e.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-orange-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),x]},L)),t.integrations.length>3&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 px-2 py-1",children:["+",t.integrations.length-3," more"]})]})]}),e.jsx("div",{className:"mt-auto pt-3 border-t border-gray-100 dark:border-slate-700",children:e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[e.jsx("span",{title:h,children:u}),e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Powered by AdMesh"})]})})]})})};ae.displayName="AdMeshProductCard";const ye=({recommendations:t,theme:r,maxProducts:s=3,showMatchScores:i=!0,showFeatures:n=!0,className:a,style:d})=>{var u,h;re();const c=y.useMemo(()=>t.slice(0,s),[t,s]),p=C("admesh-component","admesh-compare-layout",a),m=r!=null&&r.accentColor?{"--admesh-primary":r.accentColor}:void 0;return c.length===0?e.jsx("div",{className:p,style:{...m,fontFamily:(r==null?void 0:r.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(u=r==null?void 0:r.components)==null?void 0:u.compareTable,...d},"data-admesh-theme":r==null?void 0:r.mode,children:e.jsx("div",{className:"p-8 text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"No products to compare"})})}):e.jsx("div",{className:p,style:{...m,fontFamily:(r==null?void 0:r.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(h=r==null?void 0:r.components)==null?void 0:h.compareTable,...d},"data-admesh-theme":r==null?void 0:r.mode,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("svg",{className:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200",children:"Smart Comparison"})]}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[c.length," intelligent matches found"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:c.map((o,v)=>e.jsxs("div",{className:"relative p-4 rounded-lg bg-white dark:bg-slate-800 border border-gray-200 dark:border-slate-700 shadow-sm hover:shadow transition-shadow",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[v===0&&e.jsx("span",{className:"text-xs font-semibold text-white bg-black px-2 py-0.5 rounded-full",children:"Top Match"}),e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:["#",v+1]})]}),i&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap",children:[Math.round(o.intent_match_score*100),"% match"]})]}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 mb-2",children:o.title}),i&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx("span",{children:"Match Score"}),e.jsxs("span",{className:"whitespace-nowrap",children:[Math.round(o.intent_match_score*100),"% match"]})]}),e.jsx("div",{className:"w-full bg-gray-200 dark:bg-slate-600 rounded h-1.5 overflow-hidden",children:e.jsx("div",{className:"bg-black h-1.5",style:{width:`${Math.round(o.intent_match_score*100)}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-3",children:[o.pricing&&e.jsxs("span",{className:"flex items-center text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"})}),o.pricing]}),o.trial_days&&o.trial_days>0&&e.jsxs("span",{className:"flex items-center text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3a2 2 0 012-2h4a2 2 0 012 2v4m-6 4v10m6-10v10m-6 0h6"})}),o.trial_days,"-day trial"]})]}),n&&o.features&&o.features.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Key Features:"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[o.features.slice(0,4).map((f,k)=>e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 dark:bg-slate-700 text-gray-700 dark:text-gray-300",children:[e.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})}),f]},k)),(o.features.length||0)>4&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:["+",o.features.length-4," more"]})]})]}),e.jsx(W,{adId:o.ad_id,admeshLink:o.admesh_link,productId:o.product_id,trackingData:{title:o.title,matchScore:o.intent_match_score,component:"compare_table_cta"},children:e.jsxs("button",{className:"w-full text-xs px-3 py-2 rounded-lg bg-black text-white hover:bg-gray-800 flex items-center justify-center gap-1 mt-auto transition-colors",children:["Visit Offer",e.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})})]})})]},o.product_id||v))}),e.jsx("div",{className:"flex items-center justify-center mt-6 pt-4 border-t border-gray-200/50 dark:border-gray-700/50",children:e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-gray-400 dark:text-gray-500",children:[e.jsx("svg",{className:"w-3 h-3 text-indigo-500",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M11.3 1.046A1 1 0 0112 2v5h4a1 1 0 01.82 1.573l-7 10A1 1 0 018 18v-5H4a1 1 0 01-.82-1.573l7-10a1 1 0 011.12-.38z",clipRule:"evenodd"})}),e.jsx("span",{className:"font-medium",children:"Powered by"}),e.jsx("span",{className:"font-semibold text-indigo-600 dark:text-indigo-400",children:"AdMesh"})]})})]})})};ye.displayName="AdMeshCompareTable";const Ue={"Top Match":"primary","Free Tier":"success","AI Powered":"secondary",Popular:"warning",New:"primary","Trial Available":"success"},qe={"Top Match":"★","Free Tier":"◆","AI Powered":"◉",Popular:"▲",New:"●","Trial Available":"◈"},ke=({type:t,variant:r,size:s="md",className:i,style:n})=>{const a=r||Ue[t]||"secondary",d=qe[t],c=C("admesh-component","admesh-badge",`admesh-badge--${a}`,`admesh-badge--${s}`,i);return e.jsxs("span",{className:c,style:n,children:[d&&e.jsx("span",{className:"admesh-badge__icon",children:d}),e.jsx("span",{className:"admesh-badge__text",children:t})]})};ke.displayName="AdMeshBadge";const He=({recommendation:t,theme:r={mode:"light"},className:s="",style:i,showPoweredBy:n=!0,initialExpanded:a=!1,sections:d,ctaText:c,collapsible:p=!0})=>{var S,M,A,j,T,E,P,I,F,V;re();const[m,u]=y.useState(a),h=()=>{p&&u(!m)},o=t.feature_sections||[],v=[{title:"Documentation",description:`Learn more about ${t.recommendation_title||t.title}. Start exploring the features and capabilities.`,icon:"◆"},{title:"Talk To An Expert",description:`Ready to learn more about ${t.recommendation_title||t.title}? Reach out to a platform specialist for personalized guidance.`,icon:"◉"},{title:`${t.recommendation_title||t.title} Features`,description:t.recommendation_description||t.description||`${t.recommendation_title||t.title} offers comprehensive solutions for your needs. Discover the full potential.`,icon:"▲"},{title:"How it Works",description:`Learn how to get started with ${t.recommendation_title||t.title}. Begin your journey today.`,icon:"●"}],f=te(t,!1),k=se(),g=d||(o.length>0?o:v),w=c||`Try ${t.recommendation_title||t.title}`,b={background:r.backgroundColor||(r.mode==="dark"?"#1f2937":"#ffffff"),surface:r.surfaceColor||(r.mode==="dark"?"#374151":"#f9fafb"),border:r.borderColor||(r.mode==="dark"?"#4b5563":"#e5e7eb"),text:r.textColor||(r.mode==="dark"?"#f9fafb":"#111827"),textSecondary:r.textSecondaryColor||(r.mode==="dark"?"#9ca3af":"#6b7280"),accent:r.accentColor||r.primaryColor||"#3b82f6",secondary:r.secondaryColor||"#10b981",headerBg:((S=r.gradients)==null?void 0:S.primary)||(r.mode==="dark"?"#374151":"#f8fafc"),sectionBg:((M=r.gradients)==null?void 0:M.secondary)||(r.mode==="dark"?"#4b5563":"#ffffff")},N=r.disableDefaultStyles?{}:{fontFamily:r.fontFamily||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',borderRadius:r.borderRadius||"12px",border:`1px solid ${b.border}`,background:b.background,overflow:"hidden",maxWidth:"420px",boxShadow:((A=r.shadows)==null?void 0:A.medium)||(r.mode==="dark"?"0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2)":"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"),position:"relative",transition:"all 0.2s ease"};return e.jsxs("div",{className:`admesh-component admesh-expandable-unit ${s}`,style:{...N,...(j=r.components)==null?void 0:j.expandableUnit,...i},"data-admesh-theme":r.mode,children:[e.jsx("div",{style:{background:b.headerBg,padding:"20px",borderBottom:m||!p?`1px solid ${b.border}`:"none",position:"relative",transition:"all 0.2s ease"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px",flex:1,minWidth:0},children:[e.jsx("div",{style:{width:"40px",height:"40px",borderRadius:r.borderRadius||"8px",background:b.accent,display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontSize:((T=r.fontSize)==null?void 0:T.base)||"16px",fontWeight:"600",boxShadow:((E=r.shadows)==null?void 0:E.small)||"0 2px 4px rgba(0, 0, 0, 0.1)",border:`1px solid ${b.border}`},children:(t.recommendation_title||t.title).charAt(0).toUpperCase()}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("h3",{style:{margin:0,fontSize:"18px",fontWeight:"600",color:b.text,lineHeight:"1.4",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.recommendation_title||t.title}),e.jsxs("p",{style:{margin:"8px 0 0 0",fontSize:"13px",color:b.textSecondary,fontWeight:"400",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:k,children:[f," • ",new URL(t.url||t.admesh_link).hostname]})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[!m&&p&&e.jsx(W,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.recommendation_title||t.title,component:"expandable_unit",expanded:!1,location:"header"},children:e.jsx("button",{style:{padding:(P=r.spacing)!=null&&P.small?`${r.spacing.small} ${r.spacing.medium||"12px"}`:"6px 12px",backgroundColor:b.accent,color:"white",border:"none",borderRadius:r.borderRadius||"6px",fontSize:((I=r.fontSize)==null?void 0:I.small)||"12px",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease",boxShadow:((F=r.shadows)==null?void 0:F.small)||"0 1px 3px rgba(0, 0, 0, 0.1)",whiteSpace:"nowrap",...(V=r.components)==null?void 0:V.button},onMouseOver:x=>{var L;r.disableDefaultStyles||(x.currentTarget.style.transform="translateY(-1px)",x.currentTarget.style.boxShadow=((L=r.shadows)==null?void 0:L.medium)||"0 2px 6px rgba(0, 0, 0, 0.15)")},onMouseOut:x=>{var L;r.disableDefaultStyles||(x.currentTarget.style.transform="translateY(0)",x.currentTarget.style.boxShadow=((L=r.shadows)==null?void 0:L.small)||"0 1px 3px rgba(0, 0, 0, 0.1)")},children:w})}),p&&e.jsxs("button",{onClick:h,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:r.mode==="dark"?"#374151":"#f3f4f6",border:`1px solid ${r.mode==="dark"?"#4b5563":"#d1d5db"}`,borderRadius:"8px",cursor:"pointer",color:r.accentColor||"#2563eb",fontSize:"12px",fontWeight:"600",transition:"all 0.2s ease"},onMouseEnter:x=>{x.currentTarget.style.background=r.mode==="dark"?"#4b5563":"#e5e7eb",x.currentTarget.style.borderColor=r.accentColor||"#2563eb"},onMouseLeave:x=>{x.currentTarget.style.background=r.mode==="dark"?"#374151":"#f3f4f6",x.currentTarget.style.borderColor=r.mode==="dark"?"#4b5563":"#d1d5db"},"aria-label":m?"Show less details":"Show more details",children:[e.jsx("span",{children:m?"Less Details":"More Details"}),e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:m?e.jsx("path",{d:"M5 12h14"}):e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})})]})]})]})}),(m||!p)&&e.jsxs("div",{style:{padding:"0"},children:[g.map((x,L)=>e.jsxs("div",{style:{padding:"24px",backgroundColor:L%2===0?b.background:b.sectionBg,borderBottom:L<g.length-1?`1px solid ${b.border}`:"none"},children:[e.jsxs("h4",{style:{margin:"0 0 12px 0",fontSize:"15px",fontWeight:"600",color:b.text,display:"flex",alignItems:"center",gap:"12px"},children:[x.icon&&e.jsx("span",{children:x.icon}),x.title]}),e.jsx("p",{style:{margin:0,fontSize:"14px",color:b.textSecondary,lineHeight:"1.6"},children:x.description})]},L)),(m||!p)&&e.jsx("div",{style:{padding:"24px",borderTop:`1px solid ${b.border}`,backgroundColor:b.background},children:e.jsx(W,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,component:"expandable_unit",expanded:m,location:"footer"},children:e.jsx("button",{style:{width:"100%",padding:"14px 28px",background:b.accent,color:"white",border:"none",borderRadius:"12px",fontSize:"15px",fontWeight:"600",cursor:"pointer",transition:"all 0.3s ease",boxShadow:"0 4px 12px rgba(99, 102, 241, 0.3)",position:"relative",overflow:"hidden"},onMouseOver:x=>{x.currentTarget.style.transform="translateY(-2px) scale(1.02)",x.currentTarget.style.boxShadow="0 8px 20px rgba(99, 102, 241, 0.4)"},onMouseOut:x=>{x.currentTarget.style.transform="translateY(0) scale(1)",x.currentTarget.style.boxShadow="0 4px 12px rgba(99, 102, 241, 0.3)"},children:w})})}),n&&e.jsx("div",{style:{padding:"8px 16px",borderTop:`1px solid ${b.border}`,backgroundColor:b.headerBg},children:e.jsxs("div",{style:{fontSize:"11px",color:b.textSecondary,textAlign:"center"},children:["powered by ",e.jsx("strong",{style:{color:b.text},children:"AdMesh"})]})})]})]})},D=({recommendation:t,theme:r,compact:s=!1,showReason:i=!0,className:n,style:a})=>{var h;const d=Math.round(t.intent_match_score*100),c=te(t,s),p=se(),m=C("admesh-inline-recommendation","group cursor-pointer transition-all duration-200",{"p-2 sm:p-3 rounded-md bg-gray-50 dark:bg-slate-800/50 hover:bg-gray-100 dark:hover:bg-slate-800 border border-gray-200 dark:border-slate-700":!s,"p-1.5 sm:p-2 rounded hover:bg-gray-50 dark:hover:bg-slate-800/30":s},n),u=r!=null&&r.accentColor?{"--admesh-primary":r.accentColor}:void 0;return e.jsx(W,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:t.intent_match_score},className:m,style:{fontFamily:(r==null?void 0:r.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(h=r==null?void 0:r.components)==null?void 0:h.inlineRecommendation,...a},children:e.jsxs("div",{className:"flex items-start gap-3",style:u,"data-admesh-theme":r==null?void 0:r.mode,children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:t.offer_images&&t.offer_images.length>0?e.jsx("div",{className:"w-6 h-6 rounded-full overflow-hidden border border-gray-200 dark:border-gray-600",children:e.jsx("img",{src:t.offer_images[0].url,alt:t.recommendation_title||t.title,className:"w-full h-full object-cover"})}):t.product_logo?e.jsx("div",{className:"w-6 h-6 rounded-full overflow-hidden border border-gray-200 dark:border-gray-600",children:e.jsx("img",{src:t.product_logo.url,alt:t.recommendation_title||t.title,className:"w-full h-full object-cover"})}):t.intent_match_score>=.8?e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}):e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start sm:items-center gap-2 mb-1 flex-col sm:flex-row",children:[e.jsx("h4",{className:C("font-medium transition-colors duration-200 flex-shrink-0","text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300","cursor-pointer hover:underline",s?"text-sm sm:text-base":"text-base sm:text-lg"),children:t.recommendation_title||t.title}),t.intent_match_score>=.7&&e.jsxs("span",{className:C("inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium flex-shrink-0 whitespace-nowrap",t.intent_match_score>=.8?"bg-green-100 text-green-800 dark:bg-green-800/80 dark:text-green-100":"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400"),children:[d,"% match"]})]}),i&&(t.recommendation_description||t.reason)&&e.jsx("p",{className:C("text-gray-600 dark:text-gray-400 line-clamp-2",s?"text-xs":"text-sm"),children:t.recommendation_description||t.reason}),e.jsx("p",{className:C("text-gray-500 dark:text-gray-400 mt-1","text-xs"),title:p,children:c}),!s&&t.keywords&&t.keywords.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[t.keywords.slice(0,3).map((o,v)=>e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-800 dark:bg-slate-700 dark:text-gray-300",children:o},v)),t.keywords.length>3&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["+",t.keywords.length-3," more"]})]}),!s&&t.trial_days&&t.trial_days>0&&e.jsx("div",{className:"flex items-center gap-2 mt-2",children:e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",children:[t.trial_days,"-day trial"]})})]}),e.jsx("div",{className:"flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("svg",{className:"w-4 h-4 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})})},ve=({recommendations:t,conversationSummary:r,theme:s,showTopRecommendations:i=3,onRecommendationClick:n,onStartNewConversation:a,className:d})=>{const c=t.sort((u,h)=>h.intent_match_score-u.intent_match_score).slice(0,i),p=C("admesh-conversation-summary","bg-white dark:bg-black","rounded-lg border border-gray-200 dark:border-gray-800 p-4 sm:p-6","font-sans",d),m=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:p,style:m,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 bg-black dark:bg-white rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 sm:w-5 sm:h-5 text-white dark:text-black",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})})})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-black dark:text-white",children:"Conversation Summary"}),e.jsx("p",{className:"text-xs sm:text-sm text-gray-600 dark:text-gray-300",children:"Here's what we discussed and found for you"})]})]}),e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:e.jsx("p",{className:"text-gray-800 dark:text-gray-200 leading-relaxed",children:r})})}),c.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("svg",{className:"w-5 h-5 text-black dark:text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("h4",{className:"font-medium text-black dark:text-white",children:"Top Recommendations"})]}),e.jsx("div",{className:"space-y-2",children:c.map((u,h)=>e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute -left-2 top-2 z-10",children:e.jsx("div",{className:C("w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold",h===0?"bg-black dark:bg-white text-white dark:text-black":h===1?"bg-gray-600 dark:bg-gray-400 text-white dark:text-black":"bg-gray-800 dark:bg-gray-200 text-white dark:text-black"),children:h+1})}),e.jsx("div",{className:"ml-4",children:e.jsx(D,{recommendation:u,theme:s,compact:!0,showReason:!0,onClick:n})})]},u.ad_id||h))})]}),t.length>i&&e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-lg p-3 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 text-black dark:text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:[t.length-i," additional recommendation",t.length-i>1?"s":""," available"]})]})})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[a&&e.jsxs("button",{onClick:a,className:"flex-1 bg-black dark:bg-white hover:bg-gray-800 dark:hover:bg-gray-100 text-white dark:text-black font-medium py-2.5 px-4 rounded-lg transition-all duration-200 flex items-center justify-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),"Start New Conversation"]}),e.jsxs("button",{onClick:()=>{c.length>0&&(n==null||n(c[0].ad_id,c[0].admesh_link))},className:"flex-1 bg-white dark:bg-gray-900 hover:bg-gray-50 dark:hover:bg-gray-800 text-black dark:text-white font-medium py-2.5 px-4 rounded-lg border border-gray-300 dark:border-gray-600 transition-all duration-200 flex items-center justify-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})}),"View Top Pick"]})]}),e.jsx("div",{className:"flex justify-center mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Powered by AdMesh"})})]})},me=({recommendation:t,citationNumber:r,citationStyle:s="numbered",theme:i,showTooltip:n=!0,onHover:a,className:d,style:c})=>{const[p,m]=y.useState(!1),u=()=>{m(!0),a==null||a(t)},h=()=>{m(!1)},o=()=>{switch(s){case"bracketed":return`[${r}]`;case"superscript":return r.toString();case"numbered":default:return r.toString()}},v=C("admesh-citation-reference","inline-flex items-center justify-center","cursor-pointer transition-all duration-200","text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300","font-medium",{"w-5 h-5 bg-blue-100 dark:bg-blue-900/30 rounded-full text-xs border border-blue-300 dark:border-blue-700 hover:bg-blue-200 dark:hover:bg-blue-900/50":s==="numbered","px-1 text-sm hover:underline":s==="bracketed","text-xs align-super hover:underline":s==="superscript"},d),f=i!=null&&i.accentColor?{"--admesh-primary":i.accentColor}:void 0;return e.jsxs("span",{className:"relative inline-block",children:[e.jsx(W,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:t.intent_match_score,citationNumber:r,citationStyle:s},className:v,style:c,children:e.jsx("span",{style:f,"data-admesh-theme":i==null?void 0:i.mode,onMouseEnter:u,onMouseLeave:h,children:o()})}),n&&p&&e.jsx("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 z-50",children:e.jsxs("div",{className:"bg-gray-900 dark:bg-gray-100 text-white dark:text-gray-900 text-xs rounded-lg px-3 py-2 shadow-lg max-w-xs",children:[e.jsx("div",{className:"font-semibold mb-1",children:t.title}),t.reason&&e.jsx("div",{className:"text-gray-300 dark:text-gray-600 text-xs",children:t.reason.length>100?`${t.reason.substring(0,100)}...`:t.reason}),t.intent_match_score>=.7&&e.jsxs("div",{className:"text-green-400 dark:text-green-600 text-xs mt-1",children:[Math.round(t.intent_match_score*100),"% match"]}),e.jsx("div",{className:"text-gray-400 dark:text-gray-500 text-xs mt-1 italic",children:"Click to visit product page"}),e.jsx("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-900 dark:border-t-gray-100"})]})})]})},we=({recommendations:t,conversationText:r,theme:s,showCitationList:i=!0,citationStyle:n="numbered",onCitationHover:a,className:d,style:c})=>{var f;const[p,m]=y.useState(null),u=y.useMemo(()=>{if(!r||t.length===0)return{text:r,citationMap:new Map};let k=r;const g=new Map;return[...t].sort((b,N)=>N.intent_match_score-b.intent_match_score).forEach((b,N)=>{const S=N+1,M=b.title;g.set(S,b);const A=new RegExp(`\\b${M.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if(A.test(k))k=k.replace(A,j=>`${j}{{CITATION_${S}}}`);else{const j=b.keywords||[];let T=!1;for(const E of j){const P=new RegExp(`\\b${E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if(P.test(k)&&!T){k=k.replace(P,I=>(T=!0,`${I}{{CITATION_${S}}}`));break}}T||(k+=`{{CITATION_${S}}}`)}}),{text:k,citationMap:g}},[r,t]),h=()=>{const{text:k,citationMap:g}=u;return k.split(/(\{\{CITATION_\d+\}\})/).map((b,N)=>{const S=b.match(/\{\{CITATION_(\d+)\}\}/);if(S){const M=parseInt(S[1]),A=g.get(M);if(A)return e.jsx(me,{recommendation:A,citationNumber:M,citationStyle:n,theme:s,showTooltip:!0,onHover:j=>{m(j),a==null||a(j)}},`citation-${M}-${N}`)}return e.jsx("span",{children:b},N)})},o=C("admesh-citation-unit","space-y-4",d),v=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:o,style:{...v,fontFamily:(s==null?void 0:s.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(f=s==null?void 0:s.components)==null?void 0:f.citationUnit,...c},"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsx("div",{className:"admesh-citation-text text-gray-800 dark:text-gray-200 leading-relaxed",children:h()}),i&&t.length>0&&e.jsx("div",{className:"admesh-citation-list",children:e.jsxs("div",{className:"border-t border-gray-200 dark:border-slate-700 pt-4",children:[e.jsxs("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3 flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),"References"]}),e.jsx("div",{className:"space-y-2",children:t.sort((k,g)=>g.intent_match_score-k.intent_match_score).map((k,g)=>e.jsxs("div",{className:C("flex items-start gap-3 p-2 rounded-lg transition-colors duration-200",{"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800":(p==null?void 0:p.ad_id)===k.ad_id,"hover:bg-gray-50 dark:hover:bg-slate-800/50":(p==null?void 0:p.ad_id)!==k.ad_id}),children:[e.jsx("div",{className:"flex-shrink-0 mt-1",children:e.jsx(me,{recommendation:k,citationNumber:g+1,citationStyle:n,theme:s,showTooltip:!1})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(D,{recommendation:k,theme:s,compact:!0,showReason:!1})})]},k.ad_id||g))})]})})]})},xe=({recommendations:t,config:r,theme:s,conversationSummary:i,sessionId:n,onRecommendationClick:a,onDismiss:d,className:c})=>{const[p,m]=y.useState(r.autoShow!==!1),[u,h]=y.useState(!1);if(y.useEffect(()=>{if(r.delayMs&&r.delayMs>0){const N=setTimeout(()=>{m(!0),h(!0)},r.delayMs);return()=>clearTimeout(N)}else h(!0)},[r.delayMs]),!p||t.length===0)return null;const o=r.maxRecommendations||3,v=t.slice(0,o),f=(N,S)=>{a==null||a(N,S)},k=()=>{m(!1),d==null||d()},g=()=>{switch(r.displayMode){case"summary":return i?e.jsx(ve,{recommendations:v,conversationSummary:i,theme:s,showTopRecommendations:o,onRecommendationClick:f,onStartNewConversation:d}):null;case"inline":return e.jsx("div",{className:"space-y-2",children:v.map((N,S)=>e.jsx(D,{recommendation:N,theme:s,compact:!0,showReason:!0,onClick:f},N.ad_id||S))});case"minimal":return v.length>0?e.jsxs("div",{className:"admesh-minimal-unit",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[v.length," intelligent match",v.length>1?"es":""," found"]})]}),e.jsx(D,{recommendation:v[0],theme:s,compact:!0,showReason:!1,onClick:f}),v.length>1&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["+",v.length-1," more recommendation",v.length>2?"s":""]})]}):null;case"citation":return i?e.jsx(we,{recommendations:v,conversationText:i,theme:s,showCitationList:!0,citationStyle:"numbered",onRecommendationClick:f}):null;case"floating":return e.jsxs("div",{className:"admesh-floating-unit bg-white dark:bg-slate-800 rounded-lg shadow-lg border border-gray-200 dark:border-slate-700 p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),e.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200",children:"Recommended for you"})]}),d&&e.jsx("button",{onClick:k,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Dismiss recommendations",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"space-y-2",children:v.map((N,S)=>e.jsx(D,{recommendation:N,theme:s,compact:!0,showReason:!1,onClick:f},N.ad_id||S))})]});default:return e.jsx("div",{className:"space-y-3",children:v.map((N,S)=>e.jsx(ae,{recommendation:N,theme:s,showMatchScore:!1,showBadges:!0,onClick:f},N.ad_id||S))})}},w=C("admesh-conversational-unit","transition-all duration-300 ease-in-out",{"opacity-0 translate-y-2":!u,"opacity-100 translate-y-0":u,"fixed bottom-4 right-4 max-w-sm z-50":r.displayMode==="floating","my-3":r.displayMode==="inline","mt-4 pt-4 border-t border-gray-200 dark:border-slate-700":r.displayMode==="summary"},c),b=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:w,style:b,"data-admesh-theme":s==null?void 0:s.mode,"data-admesh-context":r.context,"data-session-id":n,children:[g(),r.showPoweredBy!==!1&&e.jsx("div",{className:"flex justify-end mt-2",children:e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Powered by AdMesh"})})]})},je=({message:t,theme:r,onRecommendationClick:s,className:i})=>{const n=t.role==="user",a=t.role==="assistant",d=C("admesh-chat-message","flex items-start gap-3",{"flex-row-reverse":n},i),c=C("max-w-xs lg:max-w-sm px-4 py-3 rounded-lg text-sm",{"bg-gradient-to-r from-blue-600 to-indigo-600 text-white":n,"bg-gray-100 dark:bg-slate-800 text-gray-900 dark:text-gray-100":a,"bg-yellow-100 dark:bg-yellow-900 text-yellow-900 dark:text-yellow-100":t.role==="system"}),p=r!=null&&r.accentColor?{"--admesh-primary":r.accentColor}:void 0,m=u=>u.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:d,style:p,"data-admesh-theme":r==null?void 0:r.mode,children:[!n&&e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-blue-600 to-indigo-600 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-4 h-4 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),n&&e.jsx("div",{className:"w-8 h-8 bg-gray-300 dark:bg-slate-600 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}),e.jsxs("div",{className:`flex flex-col ${n?"items-end":"items-start"} flex-1`,children:[e.jsx("div",{className:c,children:e.jsx("div",{className:"whitespace-pre-wrap break-words",children:t.content})}),e.jsx("div",{className:C("text-xs text-gray-500 dark:text-gray-400 mt-1",{"text-right":n}),children:m(t.timestamp)}),t.recommendations&&t.recommendations.length>0&&e.jsxs("div",{className:"mt-3 w-full max-w-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("svg",{className:"w-4 h-4 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[t.recommendations.length," recommendation",t.recommendations.length>1?"s":""," found"]})]}),e.jsx(xe,{recommendations:t.recommendations,config:{displayMode:"inline",context:"chat",maxRecommendations:3,showPoweredBy:!1,autoShow:!0,delayMs:300},theme:r,onRecommendationClick:s,className:"bg-gray-50 dark:bg-slate-800/50 rounded-lg p-3 border border-gray-200 dark:border-slate-700"})]})]})]})},Ne=({placeholder:t="Type your message...",disabled:r=!1,suggestions:s=[],theme:i,onSendMessage:n,className:a})=>{const[d,c]=y.useState(""),[p,m]=y.useState(!1),[u,h]=y.useState([]),o=y.useRef(null),v=M=>{const A=M.target.value;if(c(A),A.trim()&&s.length>0){const j=s.filter(T=>T.toLowerCase().includes(A.toLowerCase()));h(j),m(j.length>0)}else m(!1);o.current&&(o.current.style.height="auto",o.current.style.height=`${Math.min(o.current.scrollHeight,120)}px`)},f=M=>{M.key==="Enter"&&!M.shiftKey&&(M.preventDefault(),k())},k=()=>{const M=d.trim();M&&!r&&n&&(n(M),c(""),m(!1),o.current&&(o.current.style.height="auto"))},g=M=>{c(M),m(!1),o.current&&o.current.focus()},w=C("admesh-chat-input","relative",a),b=C("w-full resize-none rounded-lg border border-gray-300 dark:border-slate-600","bg-white dark:bg-slate-800 text-gray-900 dark:text-gray-100","placeholder-gray-500 dark:placeholder-gray-400","focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent","transition-all duration-200 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-slate-600","pr-12 pl-4 py-3 text-sm leading-5",{"opacity-50 cursor-not-allowed":r}),N=C("absolute right-2 bottom-2 p-2 rounded-lg transition-all duration-200","flex items-center justify-center",{"bg-blue-600 hover:bg-blue-700 text-white":d.trim()&&!r,"bg-gray-200 dark:bg-slate-700 text-gray-400 dark:text-gray-500 cursor-not-allowed":!d.trim()||r}),S=i!=null&&i.accentColor?{"--admesh-primary":i.accentColor}:void 0;return e.jsxs("div",{className:w,style:S,"data-admesh-theme":i==null?void 0:i.mode,children:[p&&u.length>0&&e.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-slate-800 border border-gray-200 dark:border-slate-700 rounded-lg shadow-lg max-h-40 overflow-y-auto z-10",children:u.slice(0,5).map((M,A)=>e.jsx("button",{onClick:()=>g(M),className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-slate-700 transition-colors first:rounded-t-lg last:rounded-b-lg",children:M},A))}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:o,value:d,onChange:v,onKeyDown:f,placeholder:t,disabled:r,rows:1,className:b,style:{minHeight:"44px",maxHeight:"120px"}}),e.jsx("button",{onClick:k,disabled:!d.trim()||r,className:N,"aria-label":"Send message",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx("span",{children:"Press Enter to send, Shift+Enter for new line"}),e.jsxs("span",{className:C("transition-opacity duration-200",{"opacity-0":d.length<100}),children:[d.length,"/500"]})]})]})},_e=({messages:t,config:r,theme:s,isLoading:i=!1,onSendMessage:n,onRecommendationClick:a,className:d})=>{const c=y.useRef(null),p=y.useRef(null);y.useEffect(()=>{c.current&&c.current.scrollIntoView({behavior:"smooth"})},[t]);const m=C("admesh-chat-interface","flex flex-col h-full bg-white dark:bg-slate-900",d),u=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0,h=r.maxMessages?t.slice(-r.maxMessages):t;return e.jsxs("div",{className:m,style:u,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsx("div",{ref:p,className:"flex-1 overflow-y-auto p-4 space-y-4 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-slate-600",children:h.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-blue-100 to-indigo-100 dark:from-blue-900 dark:to-indigo-900 rounded-full flex items-center justify-center mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:"Welcome to AdMesh AI"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 max-w-xs",children:"Ask me anything about products, tools, or services. I'll provide personalized recommendations just for you!"})]}):e.jsxs(e.Fragment,{children:[h.map(o=>e.jsx(je,{message:o,theme:s,onRecommendationClick:a},o.id)),i&&r.enableTypingIndicator!==!1&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-blue-600 to-indigo-600 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-4 h-4 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),e.jsx("div",{className:"bg-gray-100 dark:bg-slate-800 rounded-lg px-4 py-3 max-w-xs",children:e.jsxs("div",{className:"flex space-x-1",children:[e.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce"}),e.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),e.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]}),e.jsx("div",{ref:c})]})}),r.enableSuggestions&&r.suggestions&&r.suggestions.length>0&&t.length===0&&e.jsxs("div",{className:"px-4 pb-2",children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:"Quick suggestions:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.suggestions.slice(0,3).map((o,v)=>e.jsx("button",{onClick:()=>n==null?void 0:n(o),className:"px-3 py-1.5 text-xs bg-gray-100 dark:bg-slate-800 hover:bg-gray-200 dark:hover:bg-slate-700 text-gray-700 dark:text-gray-300 rounded-full transition-colors",children:o},v))})]}),r.showInputField!==!1&&n&&e.jsx("div",{className:"border-t border-gray-200 dark:border-slate-700 p-4",children:e.jsx(Ne,{placeholder:r.placeholder||"Ask me about products, tools, or services...",disabled:i,suggestions:r.suggestions,theme:s,onSendMessage:n})})]})},Ye=({config:t,theme:r,title:s="AI Assistant",subtitle:i="Get personalized recommendations",isOpen:n,onToggle:a,onSendMessage:d,onRecommendationClick:c,autoRecommendations:p,autoRecommendationTrigger:m,showInputField:u=!0,autoShowRecommendations:h=!1,onAutoRecommendationDismiss:o,className:v})=>{const[f,k]=y.useState(t.autoOpen||!1),[g,w]=y.useState([]),[b,N]=y.useState(!1),[S,M]=y.useState(!1),A=n!==void 0?n:f;y.useEffect(()=>{if(t.showWelcomeMessage&&t.welcomeMessage&&g.length===0){const x={id:"welcome",role:"assistant",content:t.welcomeMessage,timestamp:new Date};w([x])}},[t.showWelcomeMessage,t.welcomeMessage,g.length]),y.useEffect(()=>{if(p&&p.length>0&&h){const x={id:`auto-${Date.now()}`,role:"assistant",content:m?`Based on "${m}", here are some relevant recommendations:`:"I found some relevant recommendations for you:",timestamp:new Date,recommendations:p};n===void 0&&k(!0),w(L=>L.some(O=>O.id.startsWith("auto-"))?L.map(O=>O.id.startsWith("auto-")?x:O):[...L,x])}},[p,h,m,n]);const j=()=>{a?a():k(!f),M(!0)},T=async x=>{if(!d)return;const L={id:`user-${Date.now()}`,role:"user",content:x,timestamp:new Date};w(U=>[...U,L]),N(!0);try{await d(x)}catch(U){console.error("Error sending message:",U);const O={id:`error-${Date.now()}`,role:"assistant",content:"Sorry, I encountered an error. Please try again.",timestamp:new Date};w(K=>[...K,O])}finally{N(!1)}},E=()=>{switch(t.size){case"sm":return"w-80 h-96";case"md":return"w-96 h-[32rem]";case"lg":return"w-[28rem] h-[36rem]";case"xl":return"w-[32rem] h-[40rem]";default:return"w-96 h-[32rem]"}},I=C("admesh-floating-chat","fixed z-50 transition-all duration-300 ease-in-out",(()=>{switch(t.position){case"bottom-right":return"bottom-4 right-4";case"bottom-left":return"bottom-4 left-4";case"top-right":return"top-4 right-4";case"top-left":return"top-4 left-4";default:return"bottom-4 right-4"}})(),v),F=C("bg-white dark:bg-slate-900 rounded-lg shadow-2xl border border-gray-200 dark:border-slate-700 overflow-hidden",E(),{"opacity-0 scale-95 pointer-events-none":!A,"opacity-100 scale-100":A}),V=r!=null&&r.accentColor?{"--admesh-primary":r.accentColor}:void 0;return e.jsxs("div",{className:I,style:V,"data-admesh-theme":r==null?void 0:r.mode,children:[e.jsx("div",{className:F,children:A&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gradient-to-r from-blue-600 to-indigo-600 text-white",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-white bg-opacity-20 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-sm",children:s}),e.jsx("p",{className:"text-xs text-blue-100",children:i})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[p&&p.length>0&&o&&e.jsx("button",{onClick:()=>{o(),w(x=>x.filter(L=>!L.id.startsWith("auto-")))},className:"p-1 rounded-full hover:bg-white hover:bg-opacity-20 transition-colors","aria-label":"Dismiss recommendations",title:"Dismiss recommendations",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L3 3m6.878 6.878L21 21"})})}),e.jsx("button",{onClick:j,className:"p-1 rounded-full hover:bg-white hover:bg-opacity-20 transition-colors","aria-label":"Close chat",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),e.jsx(_e,{messages:g,config:{...t,showInputField:u},theme:r,isLoading:b,onSendMessage:u?T:()=>{},onRecommendationClick:c,className:"h-full"})]})}),!A&&e.jsxs("button",{onClick:j,className:C("w-14 h-14 bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700","text-white rounded-full shadow-lg hover:shadow-xl transition-all duration-200","flex items-center justify-center relative"),"aria-label":"Open chat",children:[e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),!S&&e.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full animate-pulse"})]}),A&&e.jsx("div",{className:"absolute bottom-2 right-2 text-xs text-gray-400 dark:text-gray-500 bg-white dark:bg-slate-900 px-2 py-1 rounded shadow-sm",children:"Powered by AdMesh"})]})},Ce=({title:t,theme:r,collapsible:s=!1,isCollapsed:i=!1,onToggle:n,onSearch:a,showSearch:d=!1,className:c})=>{const[p,m]=y.useState(""),[u,h]=y.useState(!1),[o,v]=y.useState(!1);y.useEffect(()=>{const b=()=>{v(window.innerWidth<640)};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[]);const f=b=>{const N=b.target.value;m(N),a==null||a(N)},k=()=>{m(""),a==null||a("")},g=C("admesh-sidebar-header","flex flex-col p-4 border-b border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-800",c),w=r!=null&&r.accentColor?{"--admesh-primary":r.accentColor}:void 0;return e.jsxs("div",{className:g,style:w,"data-admesh-theme":r==null?void 0:r.mode,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 truncate",children:t}),e.jsxs("div",{className:"flex items-center gap-2",children:[o&&n&&e.jsx("button",{onClick:n,className:"p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-slate-700 transition-colors flex-shrink-0 sm:hidden",title:"Close sidebar",children:e.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),s&&e.jsx("button",{onClick:n,className:"p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-slate-700 transition-colors flex-shrink-0 hidden sm:block",title:i?"Expand sidebar":"Collapse sidebar",children:e.jsx("svg",{className:C("w-4 h-4 text-gray-600 dark:text-gray-400 transition-transform duration-200",{"rotate-180":i}),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]})]}),d&&!i&&e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:C("relative flex items-center transition-all duration-200",{"ring-2 ring-blue-500 dark:ring-blue-400":u}),children:[e.jsx("div",{className:"absolute left-3 pointer-events-none",children:e.jsx("svg",{className:"w-4 h-4 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),e.jsx("input",{type:"text",value:p,onChange:f,onFocus:()=>h(!0),onBlur:()=>h(!1),placeholder:"Search recommendations...",className:C("w-full pl-10 pr-10 py-2 text-sm bg-white dark:bg-slate-900 border border-gray-300 dark:border-slate-600 rounded-lg","placeholder-gray-400 dark:placeholder-gray-500 text-gray-900 dark:text-gray-100","focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent","transition-all duration-200")}),p&&e.jsx("button",{onClick:k,className:"absolute right-3 p-0.5 rounded-full hover:bg-gray-200 dark:hover:bg-slate-700 transition-colors",title:"Clear search",children:e.jsx("svg",{className:"w-3 h-3 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),p&&e.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:"Search results will be filtered in real-time"})]}),!i&&e.jsxs("div",{className:"mt-3 flex items-center gap-4 text-xs text-gray-500 dark:text-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),e.jsx("span",{children:"Live recommendations"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("span",{children:"AI-powered"})]})]})]})},Me=({recommendations:t,displayMode:r,theme:s,maxRecommendations:i,onRecommendationClick:n,className:a})=>{const[d,c]=y.useState(!1),[p,m]=y.useState("all"),u=i?t.slice(0,i):t,o=(()=>{switch(p){case"top":return u.filter(g=>g.intent_match_score>=.8).slice(0,5);case"recent":return u.slice(0,3);default:return u}})(),v=C("admesh-sidebar-content","flex flex-col h-full",a),f=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0,k=()=>{if(o.length===0)return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-100 dark:bg-slate-800 rounded-full flex items-center justify-center mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-2",children:"No recommendations found"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Try adjusting your search or filters"})]});switch(r){case"recommendations":return e.jsx("div",{className:"space-y-3",children:o.map((g,w)=>e.jsx(D,{recommendation:g,theme:s,compact:!0,showReason:!0,onClick:n},g.ad_id||w))});case"history":return e.jsx("div",{className:"space-y-2",children:o.map((g,w)=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-gray-50 dark:hover:bg-slate-800 transition-colors",children:[e.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:g.title}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[Math.round(g.intent_match_score*100),"% match"]})]})]},g.ad_id||w))});case"favorites":return e.jsx("div",{className:"space-y-3",children:o.slice(0,3).map((g,w)=>e.jsxs("div",{className:"relative",children:[e.jsx(D,{recommendation:g,theme:s,compact:!0,showReason:!1,onClick:n}),e.jsx("button",{className:"absolute top-2 right-2 p-1 rounded-full hover:bg-gray-100 dark:hover:bg-slate-700 transition-colors",children:e.jsx("svg",{className:"w-3 h-3 text-yellow-500",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})})]},g.ad_id||w))});case"mixed":return e.jsxs("div",{className:"space-y-4",children:[o[0]&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-2",children:"Top Pick"}),e.jsx(ae,{recommendation:o[0],theme:s,showMatchScore:!0,showBadges:!0,onClick:n,className:"text-xs"})]}),o.slice(1).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-2",children:"More Options"}),e.jsx("div",{className:"space-y-2",children:o.slice(1,4).map((g,w)=>e.jsx(D,{recommendation:g,theme:s,compact:!0,showReason:!1,onClick:n},g.ad_id||w))})]})]});default:return e.jsx("div",{className:"space-y-3",children:o.map((g,w)=>e.jsx(D,{recommendation:g,theme:s,compact:!0,showReason:!0,onClick:n},g.ad_id||w))})}};return e.jsxs("div",{className:v,style:f,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsxs("div",{className:"flex border-b border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900",children:[e.jsxs("button",{onClick:()=>m("all"),className:C("flex-1 px-3 py-2 text-xs font-medium transition-colors",p==="all"?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:["All (",t.length,")"]}),e.jsx("button",{onClick:()=>m("top"),className:C("flex-1 px-3 py-2 text-xs font-medium transition-colors",p==="top"?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:"Top"}),e.jsx("button",{onClick:()=>m("recent"),className:C("flex-1 px-3 py-2 text-xs font-medium transition-colors",p==="recent"?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:"Recent"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 min-h-0",style:{WebkitOverflowScrolling:"touch",overscrollBehavior:"contain"},children:k()}),e.jsx("div",{className:"p-3 border-t border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-800",children:e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[o.length," recommendation",o.length!==1?"s":""]}),e.jsx("button",{onClick:()=>c(!d),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors",children:"Filters"})]})})]})},Ge=({recommendations:t,config:r,theme:s,title:i="Recommendations",isOpen:n=!0,onToggle:a,onRecommendationClick:d,onSearch:c,className:p,containerMode:m=!1})=>{const[u,h]=y.useState(r.defaultCollapsed||!1),[o,v]=y.useState(""),[f]=y.useState({}),[k,g]=y.useState(!1);y.useEffect(()=>{const j=()=>{g(window.innerWidth<640)};return j(),window.addEventListener("resize",j),()=>window.removeEventListener("resize",j)},[]),y.useEffect(()=>{if(k&&n&&!u&&!m){const j=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",()=>{document.body.style.overflow=j,document.body.style.position="",document.body.style.width=""}}},[k,n,u,m]),y.useEffect(()=>{if(r.autoRefresh&&r.refreshInterval){const j=setInterval(()=>{console.log("Auto-refreshing recommendations...")},r.refreshInterval);return()=>clearInterval(j)}},[r.autoRefresh,r.refreshInterval]);const w=y.useMemo(()=>{let j=[...t];if(o.trim()){const T=o.toLowerCase();j=j.filter(E=>{var P;return E.title.toLowerCase().includes(T)||E.reason.toLowerCase().includes(T)||((P=E.keywords)==null?void 0:P.some(I=>I.toLowerCase().includes(T)))})}return f.categories&&f.categories.length>0&&(j=j.filter(T=>{var E;return(E=T.categories)==null?void 0:E.some(P=>{var I;return(I=f.categories)==null?void 0:I.includes(P)})})),f.hasFreeTier,f.hasTrial&&(j=j.filter(T=>T.trial_days&&T.trial_days>0)),f.minMatchScore!==void 0&&(j=j.filter(T=>T.intent_match_score>=f.minMatchScore)),j.sort((T,E)=>E.intent_match_score-T.intent_match_score),r.maxRecommendations&&(j=j.slice(0,r.maxRecommendations)),j},[t,o,f,r.maxRecommendations]),b=()=>{r.collapsible&&(h(!u),a==null||a())},N=j=>{v(j),c==null||c(j)},M=C("admesh-sidebar","flex flex-col bg-white dark:bg-slate-900 border-gray-200 dark:border-slate-700 shadow-lg transition-all duration-300 ease-in-out",(()=>{if(u)return"w-12";switch(r.size){case"sm":return"w-full sm:w-64 max-w-[90vw] sm:max-w-sm";case"md":return"w-full sm:w-80 max-w-[90vw] sm:max-w-md";case"lg":return"w-full sm:w-96 max-w-[90vw] sm:max-w-lg";case"xl":return"w-full sm:w-[28rem] max-w-[90vw] sm:max-w-xl";default:return"w-full sm:w-80 max-w-[90vw] sm:max-w-md"}})(),{"border-r":r.position==="left","border-l":r.position==="right","fixed top-0 bottom-0 z-[9999]":!m,"relative h-full":m,"left-0":r.position==="left"&&!m,"right-0":r.position==="right"&&!m,"transform -translate-x-full":r.position==="left"&&!n&&!m,"transform translate-x-full":r.position==="right"&&!n&&!m,"min-h-0":!0,"overflow-hidden":!m},p),A=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return!n&&!r.collapsible?null:e.jsxs(e.Fragment,{children:[n&&!u&&e.jsx("div",{className:C("bg-black bg-opacity-50 z-[9998] sm:hidden transition-opacity duration-300",m?"absolute inset-0":"fixed inset-0"),onClick:()=>a==null?void 0:a(),style:{position:m?"absolute":"fixed",top:0,left:0,right:0,bottom:0,touchAction:"none"}}),e.jsxs("div",{className:M,style:A,"data-admesh-theme":s==null?void 0:s.mode,"data-sidebar-position":r.position,"data-sidebar-size":r.size,"data-mobile-open":k&&n&&!u?"true":"false","data-container-mode":m?"true":"false",children:[r.showHeader!==!1&&e.jsx(Ce,{title:i,theme:s,collapsible:r.collapsible,isCollapsed:u,onToggle:b,onSearch:r.showSearch?N:void 0,showSearch:r.showSearch&&!u}),!u&&e.jsx(Me,{recommendations:w,displayMode:r.displayMode,theme:s,maxRecommendations:r.maxRecommendations,onRecommendationClick:d,className:"flex-1 overflow-hidden min-h-0"}),u&&r.collapsible&&e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-2",children:[e.jsx("button",{onClick:b,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",title:"Expand sidebar",children:e.jsx("svg",{className:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),e.jsx("div",{className:"mt-4 text-xs text-gray-500 dark:text-gray-400 transform -rotate-90 whitespace-nowrap",children:w.length})]}),!u&&e.jsx("div",{className:"p-3 border-t border-gray-200 dark:border-slate-700",children:e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 text-center",children:"Powered by AdMesh"})})]})]})},Ke=({recommendations:t,trigger:r,theme:s,title:i="AI Recommendations",position:n="bottom-right",size:a="md",autoShow:d=!0,showDelay:c=1e3,onRecommendationClick:p,onDismiss:m,className:u})=>{const[h,o]=y.useState(!1),[v,f]=y.useState(!1);y.useEffect(()=>{if(d&&t.length>0){const S=setTimeout(()=>{o(!0),f(!0)},c);return()=>clearTimeout(S)}},[d,t.length,c]);const k=()=>{o(!1),m==null||m()},g=()=>{switch(a){case"sm":return"w-72 max-h-80";case"md":return"w-80 max-h-96";case"lg":return"w-96 max-h-[28rem]";default:return"w-80 max-h-96"}},w=()=>{switch(n){case"bottom-right":return"bottom-4 right-4";case"bottom-left":return"bottom-4 left-4";case"top-right":return"top-4 right-4";case"top-left":return"top-4 left-4";default:return"bottom-4 right-4"}};if(!h||t.length===0)return null;const b=C("admesh-auto-recommendation-widget","fixed z-50 transition-all duration-500 ease-out",w(),g(),{"opacity-0 scale-95 translate-y-2":!v,"opacity-100 scale-100 translate-y-0":v},u),N=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsx("div",{className:b,style:N,"data-admesh-theme":s==null?void 0:s.mode,children:e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg shadow-2xl border border-gray-200 dark:border-slate-700 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gradient-to-r from-blue-600 to-indigo-600 text-white",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-white bg-opacity-20 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-sm",children:i}),r&&e.jsxs("p",{className:"text-xs text-blue-100 truncate max-w-48",children:['Based on: "',r,'"']})]})]}),e.jsx("button",{onClick:k,className:"p-1 rounded-full hover:bg-white hover:bg-opacity-20 transition-colors","aria-label":"Dismiss recommendations",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"p-4 max-h-80 overflow-y-auto scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-slate-600",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[t.length," intelligent match",t.length>1?"es":""," found"]})]}),e.jsx(xe,{recommendations:t,config:{displayMode:"inline",context:"assistant",maxRecommendations:3,showPoweredBy:!1,autoShow:!0,delayMs:200},theme:s,onRecommendationClick:p})]}),e.jsx("div",{className:"px-4 py-3 bg-gray-50 dark:bg-slate-800 border-t border-gray-200 dark:border-slate-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Powered by AdMesh"}),e.jsx("button",{onClick:k,className:"text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors",children:"Dismiss"})]})})]})})},G=(t={})=>{const r={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:"→"}};return{...r,...t,fontSize:{...r.fontSize,...t.fontSize},spacing:{...r.spacing,...t.spacing},shadows:{...r.shadows,...t.shadows},icons:{...r.icons,...t.icons},components:{...r.components,...t.components}}},Je=(t={})=>G({...{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)"}},...t}),Qe={minimal:G({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)"}}),vibrant:G({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%)"}}),corporate:G({primaryColor:"#1e40af",secondaryColor:"#059669",backgroundColor:"#f8fafc",surfaceColor:"#ffffff",borderColor:"#cbd5e1",borderRadius:"6px",fontFamily:'"Inter", -apple-system, BlinkMacSystemFont, sans-serif'}),highContrast:G({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"}})},Xe=(...t)=>{const r=G();return t.reduce((s,i)=>i?G({...s,...i}):s,r)},Ze=t=>{var s,i,n,a,d,c;const r=getComputedStyle(t);return{primaryColor:((s=r.getPropertyValue("--admesh-primary-color"))==null?void 0:s.trim())||void 0,secondaryColor:((i=r.getPropertyValue("--admesh-secondary-color"))==null?void 0:i.trim())||void 0,backgroundColor:((n=r.getPropertyValue("--admesh-background-color"))==null?void 0:n.trim())||void 0,textColor:((a=r.getPropertyValue("--admesh-text-color"))==null?void 0:a.trim())||void 0,borderRadius:((d=r.getPropertyValue("--admesh-border-radius"))==null?void 0:d.trim())||void 0,fontFamily:((c=r.getPropertyValue("--admesh-font-family"))==null?void 0:c.trim())||void 0}},er="0.2.1",rr={trackingEnabled:!0,debug:!1,theme:{mode:"light",accentColor:"#2563eb"}};exports.AdMeshAutoRecommendationWidget=Ke;exports.AdMeshBadge=ke;exports.AdMeshChatInput=Ne;exports.AdMeshChatInterface=_e;exports.AdMeshChatMessage=je;exports.AdMeshCitationReference=me;exports.AdMeshCitationUnit=we;exports.AdMeshCompareTable=ye;exports.AdMeshConversationSummary=ve;exports.AdMeshConversationalUnit=xe;exports.AdMeshExpandableUnit=He;exports.AdMeshFloatingChat=Ye;exports.AdMeshInlineRecommendation=D;exports.AdMeshLinkTracker=W;exports.AdMeshProductCard=ae;exports.AdMeshSidebar=Ge;exports.AdMeshSidebarContent=Me;exports.AdMeshSidebarHeader=Ce;exports.DEFAULT_CONFIG=rr;exports.VERSION=er;exports.buildAdMeshLink=Be;exports.createAdMeshTheme=G;exports.createDarkTheme=Je;exports.extractTrackingData=We;exports.getBadgeText=be;exports.getCtaText=$e;exports.getInlineDisclosure=te;exports.getInlineTooltip=se;exports.getLabelTooltip=Z;exports.getPoweredByText=Ve;exports.getRecommendationLabel=Y;exports.getSectionDisclosure=Oe;exports.hasHighQualityMatches=De;exports.mergeThemes=Xe;exports.setAdMeshTrackerConfig=ze;exports.themeFromCSSProperties=Ze;exports.themePresets=Qe;exports.useAdMeshStyles=re;exports.useAdMeshTracker=fe;
|
|
670
|
+
`;let de=!1;const re=()=>{k.useEffect(()=>{if(de)return;const t=document.createElement("style");return t.id="admesh-ui-sdk-styles",t.textContent=Fe,document.getElementById("admesh-ui-sdk-styles")||(document.head.appendChild(t),de=!0),()=>{const r=document.getElementById("admesh-ui-sdk-styles");r&&document.head.contains(r)&&(document.head.removeChild(r),de=!1)}},[])},q=(t,r={})=>{const s=t.intent_match_score||0,i=r.customLabels||{};return s>=.8?i.smartPick||"Smart Pick":s>=.6?i.partnerMatch||"Partner Match":s>=.3?i.promotedOption||"Promoted":i.relatedOption||"Related"},Z=(t,r)=>{const s=t.intent_match_score||0;return s>=.8?"This recommendation is from a partner who compensates us when you engage. We've matched it to your needs based on your query.":s>=.6?"Top-rated partner solution matched to your specific requirements. Partner compensates us for qualified referrals.":s>=.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."},Oe=(t=!0,r=!1)=>t?r?"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.",te=(t,r=!1)=>{const s=t.intent_match_score||0;return r?"Promoted":s>=.8?"Smart Recommendation":s>=.6?"Partner Match":"Promoted"},se=()=>"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.",be=t=>({"Top Match":"Top Match","Smart Pick":"Smart Pick","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"})[t]||t,$e=(t,r="button")=>{const s=t.recommendation_title||t.title;return r==="link"?s:t.trial_days&&t.trial_days>0?`Try ${s}`:"Learn More"},De=t=>t.some(r=>(r.intent_match_score||0)>=.8),Ve=(t=!1)=>t?"Powered by AdMesh":"Recommendations powered by AdMesh",ae=({recommendation:t,theme:r,showMatchScore:s=!1,showBadges:i=!0,variation:n="default",expandable:a=!1,className:d,style:c})=>{var b,C,T,L,R,N,x,A,P,I,O,z,S;re();const[p,m]=k.useState(!1),g=k.useMemo(()=>{var J;const v=[];q(t)==="Smart Pick"&&v.push("Top Match"),t.trial_days&&t.trial_days>0&&v.push("Trial Available");const $=["ai","artificial intelligence","machine learning","ml","automation"];return(((J=t.keywords)==null?void 0:J.some(l=>$.some(M=>l.toLowerCase().includes(M))))||t.title.toLowerCase().includes("ai"))&&v.push("AI Powered"),t.badges&&t.badges.length>0&&t.badges.forEach(l=>{["Top Match","Free Tier","AI Powered","Popular","New","Trial Available"].includes(l)&&!v.includes(l)&&v.push(l)}),v},[t]),h=te(t,!1),o=se(),y=Math.round(t.intent_match_score*100),u=(()=>{const v=t.content_variations;return n==="simple"?{title:t.recommendation_title||t.title,description:t.recommendation_description||t.description||t.reason,ctaText:t.recommendation_title||t.title,isSimple:!0}:n==="question"&&(v!=null&&v.question)?{title:v.question.cta||t.recommendation_title||t.title,description:v.question.text,ctaText:v.question.cta||t.recommendation_title||t.title}:n==="statement"&&(v!=null&&v.statement)?{title:t.recommendation_title||t.title,description:v.statement.text,ctaText:v.statement.cta||t.recommendation_title||t.title}:{title:t.recommendation_title||t.title,description:t.recommendation_description||t.description||t.reason,ctaText:t.recommendation_title||t.title}})(),f=_("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",d),j=r?{"--admesh-primary":r.primaryColor||r.accentColor||"#3b82f6","--admesh-secondary":r.secondaryColor||"#10b981","--admesh-accent":r.accentColor||"#3b82f6","--admesh-background":r.backgroundColor,"--admesh-surface":r.surfaceColor,"--admesh-border":r.borderColor,"--admesh-text":r.textColor,"--admesh-text-secondary":r.textSecondaryColor,"--admesh-radius":r.borderRadius||"12px","--admesh-shadow-sm":(b=r.shadows)==null?void 0:b.small,"--admesh-shadow-md":(C=r.shadows)==null?void 0:C.medium,"--admesh-shadow-lg":(T=r.shadows)==null?void 0:T.large,"--admesh-spacing-sm":(L=r.spacing)==null?void 0:L.small,"--admesh-spacing-md":(R=r.spacing)==null?void 0:R.medium,"--admesh-spacing-lg":(N=r.spacing)==null?void 0:N.large,"--admesh-font-size-sm":(x=r.fontSize)==null?void 0:x.small,"--admesh-font-size-base":(A=r.fontSize)==null?void 0:A.base,"--admesh-font-size-lg":(P=r.fontSize)==null?void 0:P.large,"--admesh-font-size-title":(I=r.fontSize)==null?void 0:I.title,fontFamily:r.fontFamily}:void 0;return n==="simple"?e.jsxs("div",{className:_("admesh-component admesh-simple-ad","inline-block text-sm leading-relaxed",d),style:{fontFamily:(r==null?void 0:r.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(O=r==null?void 0:r.components)==null?void 0:O.productCard,...c},"data-admesh-theme":r==null?void 0:r.mode,children:[e.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(r==null?void 0:r.accentColor)||"#2563eb",backgroundColor:(r==null?void 0:r.mode)==="dark"?"#374151":"#f3f4f6",padding:"2px 6px",borderRadius:"4px",marginRight:"8px"},title:Z(t,q(t)),children:q(t)}),e.jsxs("span",{style:{color:(r==null?void 0:r.mode)==="dark"?"#f3f4f6":"#374151",marginRight:"4px"},children:[u.description," "]}),e.jsx(D,{adId: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:e.jsx("span",{style:{color:(r==null?void 0:r.accentColor)||"#2563eb",textDecoration:"underline",cursor:"pointer",fontSize:"inherit",fontFamily:"inherit"},children:u.ctaText})}),e.jsxs("span",{style:{fontSize:"10px",color:(r==null?void 0:r.mode)==="dark"?"#9ca3af":"#6b7280",marginLeft:"8px"},title:o,children:["(",h,")"]})]}):n==="question"||n==="statement"?e.jsx("div",{className:_("admesh-component admesh-expandable-variation transition-all duration-300",a&&p?"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":"p-4 rounded-lg bg-white dark:bg-slate-800 border border-gray-200 dark:border-slate-700 shadow-sm hover:shadow-md",d),style:{fontFamily:(r==null?void 0:r.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(z=r==null?void 0:r.components)==null?void 0:z.productCard,...c},"data-admesh-theme":r==null?void 0:r.mode,children:!a||!p?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mb-2",children:e.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(r==null?void 0:r.accentColor)||"#2563eb",backgroundColor:(r==null?void 0:r.mode)==="dark"?"#374151":"#f3f4f6",padding:"2px 6px",borderRadius:"4px"},title:Z(t,q(t)),children:q(t)})}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300 leading-relaxed",children:[u.description," ",e.jsx(D,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:t.intent_match_score,component:"simple_variation_cta"},children:e.jsx("span",{className:"text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 underline cursor-pointer font-medium transition-colors",children:u.ctaText})})]})}),a&&e.jsx("div",{className:"flex items-center gap-3 flex-shrink-0",children:e.jsxs("button",{onClick:()=>m(!0),className:"flex items-center gap-2 px-3 py-2 text-xs font-medium text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-lg transition-all duration-200 border border-blue-200 dark:border-blue-700 hover:border-blue-300 dark:hover:border-blue-600",title:"View more details",children:[e.jsx("span",{children:"More Details"}),e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})]})})]})]}):e.jsxs("div",{className:"h-full flex flex-col",style:j,"data-admesh-theme":r==null?void 0:r.mode,children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-start gap-3 mb-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 flex-1 min-w-0",children:[i&&g.includes("Top Match")&&e.jsx("span",{className:"text-xs font-semibold text-white px-3 py-1 rounded-full w-fit shadow-md",style:{backgroundColor:(r==null?void 0:r.primaryColor)||(r==null?void 0:r.accentColor)||"#f59e0b",borderRadius:(r==null?void 0:r.borderRadius)||"9999px"},title:Z(t),children:be("Top Match")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.product_logo&&e.jsx("img",{src:t.product_logo.url,alt:`${t.title} logo`,className:"w-6 h-6 rounded flex-shrink-0",onError:v=>{v.target.style.display="none"}}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm sm:text-base truncate",children:u.title})]})]}),e.jsxs("div",{className:"flex gap-3 flex-shrink-0",children:[e.jsxs("button",{onClick:()=>m(!1),className:"flex items-center gap-2 px-3 py-2 text-xs font-medium text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-800/50 rounded-lg transition-all duration-200 border border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600",title:"Show less details",children:[e.jsx("span",{children:"Less Details"}),e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M20 12H4"})})]}),e.jsx(D,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:t.intent_match_score,component:"product_card_cta"},children:e.jsxs("button",{className:"text-xs sm:text-sm px-3 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",children:[n==="question"?"Try":"Visit"," ",u.ctaText,e.jsx("svg",{className:"ml-1 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})})]})})]})]}),e.jsx("div",{className:"mb-6",children:e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 leading-relaxed",children:u.description})}),e.jsx("div",{className:"mb-6",children:e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 leading-relaxed",title:o,children:h})}),s&&typeof t.intent_match_score=="number"&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs sm:text-sm text-gray-600 dark:text-gray-300 mb-2",children:[e.jsx("span",{className:"font-medium",children:"Match Score"}),e.jsxs("span",{className:"font-bold text-transparent bg-clip-text bg-gradient-to-r from-green-500 to-blue-500 whitespace-nowrap",children:[y,"% match"]})]}),e.jsx("div",{className:"w-full bg-gray-200 dark:bg-slate-600 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-gradient-to-r from-green-400 to-blue-500 h-2 rounded-full transition-all duration-500 ease-out",style:{width:`${y}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-3",children:[t.pricing&&e.jsxs("span",{className:"flex items-center px-2 py-1 rounded-full bg-gradient-to-r from-green-100 to-emerald-100 dark:from-green-900/30 dark:to-emerald-900/30 text-green-700 dark:text-green-300 border border-green-200 dark:border-green-700",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"})}),t.pricing]}),t.trial_days&&t.trial_days>0&&e.jsxs("span",{className:"flex items-center px-2 py-1 rounded-full bg-gradient-to-r from-blue-100 to-cyan-100 dark:from-blue-900/30 dark:to-cyan-900/30 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3a2 2 0 012-2h4a2 2 0 012 2v4m-6 4v10m6-10v10m-6 0h6"})}),t.trial_days,"-day trial"]})]}),t.features&&t.features.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 font-medium",children:"✨ Key Features"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.features.slice(0,4).map((v,B)=>e.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:[e.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-indigo-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})}),v]},B)),t.features.length>4&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 px-2 py-1",children:["+",t.features.length-4," more"]})]})]}),t.integrations&&t.integrations.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 font-medium",children:"🔗 Integrations"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.integrations.slice(0,3).map((v,B)=>e.jsxs("span",{className:"text-xs px-2 py-1 rounded-full bg-gradient-to-r from-orange-100 to-red-100 dark:from-orange-900/30 dark:to-red-900/30 text-orange-700 dark:text-orange-300 border border-orange-200 dark:border-orange-700",children:[e.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-orange-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),v]},B)),t.integrations.length>3&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 px-2 py-1",children:["+",t.integrations.length-3," more"]})]})]}),e.jsx("div",{className:"flex justify-end mt-auto pt-2",children:e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Powered by AdMesh"})})]})}):e.jsx("div",{className:f,style:{fontFamily:(r==null?void 0:r.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(S=r==null?void 0:r.components)==null?void 0:S.productCard,...c},"data-admesh-theme":r==null?void 0:r.mode,children:e.jsxs("div",{className:"h-full flex flex-col",style:j,children:[e.jsx("div",{className:"mb-3",children:e.jsx("span",{style:{fontSize:"11px",fontWeight:"600",color:(r==null?void 0:r.accentColor)||"#2563eb",backgroundColor:(r==null?void 0:r.mode)==="dark"?"#374151":"#f3f4f6",padding:"2px 6px",borderRadius:"4px"},title:Z(t,q(t)),children:q(t)})}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:justify-between sm:items-start gap-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[t.product_logo&&e.jsx("img",{src:t.product_logo.url,alt:`${t.title} logo`,className:"w-6 h-6 rounded flex-shrink-0",onError:v=>{v.target.style.display="none"}}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 text-sm sm:text-base truncate",children:u.title})]}),e.jsx("div",{className:"flex gap-2 flex-shrink-0",children:e.jsx(D,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:t.intent_match_score,component:"product_card_cta"},children:e.jsxs("button",{className:"text-xs sm:text-sm px-3 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",children:["Visit ",u.ctaText,e.jsx("svg",{className:"ml-1 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})})]})})})]}),e.jsx("div",{className:"mb-6",children:e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 leading-relaxed",children:u.description})}),s&&typeof t.intent_match_score=="number"&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs sm:text-sm text-gray-600 dark:text-gray-300 mb-2",children:[e.jsx("span",{className:"font-medium",children:"Match Score"}),e.jsxs("span",{className:"font-bold text-transparent bg-clip-text bg-gradient-to-r from-green-500 to-blue-500 whitespace-nowrap",children:[y,"% match"]})]}),e.jsx("div",{className:"w-full bg-gray-200 dark:bg-slate-600 rounded-full h-2 overflow-hidden",children:e.jsx("div",{className:"bg-gradient-to-r from-green-400 to-blue-500 h-2 rounded-full transition-all duration-500 ease-out",style:{width:`${y}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-3",children:[t.pricing&&e.jsxs("span",{className:"flex items-center px-2 py-1 rounded-full bg-gradient-to-r from-green-100 to-emerald-100 dark:from-green-900/30 dark:to-emerald-900/30 text-green-700 dark:text-green-300 border border-green-200 dark:border-green-700",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"})}),t.pricing]}),t.trial_days&&t.trial_days>0&&e.jsxs("span",{className:"flex items-center px-2 py-1 rounded-full bg-gradient-to-r from-blue-100 to-cyan-100 dark:from-blue-900/30 dark:to-cyan-900/30 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3a2 2 0 012-2h4a2 2 0 012 2v4m-6 4v10m6-10v10m-6 0h6"})}),t.trial_days,"-day trial"]})]}),t.features&&t.features.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 font-medium",children:"✨ Key Features"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.features.slice(0,4).map((v,B)=>e.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:[e.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-indigo-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})}),v]},B)),t.features.length>4&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 px-2 py-1",children:["+",t.features.length-4," more"]})]})]}),t.integrations&&t.integrations.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-300 mb-2 font-medium",children:"🔗 Integrations"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.integrations.slice(0,3).map((v,B)=>e.jsxs("span",{className:"text-xs px-2 py-1 rounded-full bg-gradient-to-r from-orange-100 to-red-100 dark:from-orange-900/30 dark:to-red-900/30 text-orange-700 dark:text-orange-300 border border-orange-200 dark:border-orange-700",children:[e.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-orange-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})}),v]},B)),t.integrations.length>3&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 px-2 py-1",children:["+",t.integrations.length-3," more"]})]})]}),e.jsx("div",{className:"mt-auto pt-3 border-t border-gray-100 dark:border-slate-700",children:e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 dark:text-gray-400",children:[e.jsx("span",{title:o,children:h}),e.jsx("span",{className:"text-gray-400 dark:text-gray-500",children:"Powered by AdMesh"})]})})]})})};ae.displayName="AdMeshProductCard";const Ue=({products:t,title:r="Product Recommendations",showTitle:s=!0,className:i="",cardClassName:n="",onProductClick:a,showPricing:d=!0,showRatings:c=!0,showBrand:p=!0,showSource:m=!1,showShipping:g=!0,maxCards:h=10,cardWidth:o="md",theme:y="auto",borderRadius:w="md",shadow:u="sm"})=>{const f=t.slice(0,h),j=()=>{switch(o){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"}},b=()=>{switch(w){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(u){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"}},T=()=>y==="dark"?"bg-gray-900 text-white":y==="light"?"bg-white text-gray-900":"bg-white dark:bg-gray-900 text-gray-900 dark:text-white",L=x=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:0,maximumFractionDigits:2}).format(x),R=x=>{const A=[],P=Math.floor(x),I=x%1!==0;for(let z=0;z<P;z++)A.push(e.jsx("span",{className:"text-yellow-400",children:"★"},z));I&&A.push(e.jsx("span",{className:"text-yellow-400",children:"☆"},"half"));const O=5-Math.ceil(x);for(let z=0;z<O;z++)A.push(e.jsx("span",{className:"text-gray-300 dark:text-gray-600",children:"☆"},`empty-${z}`));return A},N=x=>{if(a)a(x);else{const A=x.admesh_link||x.url;A&&window.open(A,"_blank","noopener,noreferrer")}};return!t||t.length===0?null:e.jsxs("div",{className:_("w-full",i),children:[s&&e.jsxs("div",{className:"mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:r}),e.jsx("div",{className:"mt-1 h-0.5 w-12 bg-blue-500"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"flex gap-4 overflow-x-auto pb-4 scrollbar-hide",children:f.map(x=>{var A;return e.jsxs("div",{className:_(j(),b(),C(),T(),"flex-shrink-0 border border-gray-200 dark:border-gray-700 transition-all duration-200 cursor-pointer hover:scale-[1.02]",n),onClick:()=>N(x),children:[e.jsxs("div",{className:"relative aspect-square w-full overflow-hidden",children:[x.image_url?e.jsx("img",{src:x.image_url,alt:x.title,className:"h-full w-full object-cover transition-transform duration-200 hover:scale-105",loading:"lazy"}):e.jsx("div",{className:"flex h-full w-full items-center justify-center bg-gray-100 dark:bg-gray-800",children:e.jsx("svg",{className:"h-12 w-12 text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"})})}),d&&x.discount_percentage&&x.discount_percentage>0&&e.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(x.discount_percentage),"%"]}),m&&x.source&&e.jsx("div",{className:"absolute top-2 right-2 bg-blue-500 text-white text-xs font-medium px-2 py-1 rounded",children:x.source.toUpperCase()})]}),e.jsxs("div",{className:"p-3",children:[p&&x.brand&&e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1 uppercase tracking-wide",children:x.brand}),e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white line-clamp-2 mb-2 leading-tight",children:x.title}),c&&x.rating&&e.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[e.jsx("div",{className:"flex text-sm",children:R(x.rating)}),e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["(",x.review_count||0,")"]})]}),d&&x.price&&e.jsx("div",{className:"mb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-lg font-bold text-gray-900 dark:text-white",children:L(x.price)}),x.original_price&&x.original_price>x.price&&e.jsx("span",{className:"text-sm text-gray-500 dark:text-gray-400 line-through",children:L(x.original_price)})]})}),g&&((A=x.shipping_info)==null?void 0:A.free_shipping_over_35)&&e.jsx("div",{className:"text-xs text-green-600 dark:text-green-400 font-medium",children:"Free shipping over $35"}),x.availability&&x.availability!=="unknown"&&e.jsx("div",{className:_("text-xs font-medium mt-1",x.availability==="in_stock"?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"),children:x.availability==="in_stock"?"In Stock":"Out of Stock"})]})]},x.id)})}),e.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:e.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}),e.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:e.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]}),e.jsx("style",{jsx:!0,children:`
|
|
671
|
+
.scrollbar-hide {
|
|
672
|
+
-ms-overflow-style: none;
|
|
673
|
+
scrollbar-width: none;
|
|
674
|
+
}
|
|
675
|
+
.scrollbar-hide::-webkit-scrollbar {
|
|
676
|
+
display: none;
|
|
677
|
+
}
|
|
678
|
+
.line-clamp-2 {
|
|
679
|
+
display: -webkit-box;
|
|
680
|
+
-webkit-line-clamp: 2;
|
|
681
|
+
-webkit-box-orient: vertical;
|
|
682
|
+
overflow: hidden;
|
|
683
|
+
}
|
|
684
|
+
`})]})},ye=({recommendations:t,theme:r,maxProducts:s=3,showMatchScores:i=!0,showFeatures:n=!0,className:a,style:d})=>{var g,h;re();const c=k.useMemo(()=>t.slice(0,s),[t,s]),p=_("admesh-component","admesh-compare-layout",a),m=r!=null&&r.accentColor?{"--admesh-primary":r.accentColor}:void 0;return c.length===0?e.jsx("div",{className:p,style:{...m,fontFamily:(r==null?void 0:r.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(g=r==null?void 0:r.components)==null?void 0:g.compareTable,...d},"data-admesh-theme":r==null?void 0:r.mode,children:e.jsx("div",{className:"p-8 text-center text-gray-500 dark:text-gray-400",children:e.jsx("p",{children:"No products to compare"})})}):e.jsx("div",{className:p,style:{...m,fontFamily:(r==null?void 0:r.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(h=r==null?void 0:r.components)==null?void 0:h.compareTable,...d},"data-admesh-theme":r==null?void 0:r.mode,children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2 mb-2",children:[e.jsx("svg",{className:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-800 dark:text-gray-200",children:"Smart Comparison"})]}),e.jsxs("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:[c.length," intelligent matches found"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:c.map((o,y)=>e.jsxs("div",{className:"relative p-4 rounded-lg bg-white dark:bg-slate-800 border border-gray-200 dark:border-slate-700 shadow-sm hover:shadow transition-shadow",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[y===0&&e.jsx("span",{className:"text-xs font-semibold text-white bg-black px-2 py-0.5 rounded-full",children:"Top Match"}),e.jsxs("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:["#",y+1]})]}),i&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap",children:[Math.round(o.intent_match_score*100),"% match"]})]}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 mb-2",children:o.title}),i&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs text-gray-500 dark:text-gray-400 mb-1",children:[e.jsx("span",{children:"Match Score"}),e.jsxs("span",{className:"whitespace-nowrap",children:[Math.round(o.intent_match_score*100),"% match"]})]}),e.jsx("div",{className:"w-full bg-gray-200 dark:bg-slate-600 rounded h-1.5 overflow-hidden",children:e.jsx("div",{className:"bg-black h-1.5",style:{width:`${Math.round(o.intent_match_score*100)}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-3",children:[o.pricing&&e.jsxs("span",{className:"flex items-center text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1"})}),o.pricing]}),o.trial_days&&o.trial_days>0&&e.jsxs("span",{className:"flex items-center text-gray-600 dark:text-gray-400",children:[e.jsx("svg",{className:"h-3 w-3 mr-1",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7V3a2 2 0 012-2h4a2 2 0 012 2v4m-6 4v10m6-10v10m-6 0h6"})}),o.trial_days,"-day trial"]})]}),n&&o.features&&o.features.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Key Features:"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[o.features.slice(0,4).map((w,u)=>e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 dark:bg-slate-700 text-gray-700 dark:text-gray-300",children:[e.jsx("svg",{className:"h-3 w-3 mr-0.5 inline text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})}),w]},u)),(o.features.length||0)>4&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:["+",o.features.length-4," more"]})]})]}),e.jsx(D,{adId:o.ad_id,admeshLink:o.admesh_link,productId:o.product_id,trackingData:{title:o.title,matchScore:o.intent_match_score,component:"compare_table_cta"},children:e.jsxs("button",{className:"w-full text-xs px-3 py-2 rounded-lg bg-black text-white hover:bg-gray-800 flex items-center justify-center gap-1 mt-auto transition-colors",children:["Visit Offer",e.jsx("svg",{className:"h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})})]})})]},o.product_id||y))}),e.jsx("div",{className:"flex items-center justify-center mt-6 pt-4 border-t border-gray-200/50 dark:border-gray-700/50",children:e.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-gray-400 dark:text-gray-500",children:[e.jsx("svg",{className:"w-3 h-3 text-indigo-500",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M11.3 1.046A1 1 0 0112 2v5h4a1 1 0 01.82 1.573l-7 10A1 1 0 018 18v-5H4a1 1 0 01-.82-1.573l7-10a1 1 0 011.12-.38z",clipRule:"evenodd"})}),e.jsx("span",{className:"font-medium",children:"Powered by"}),e.jsx("span",{className:"font-semibold text-indigo-600 dark:text-indigo-400",children:"AdMesh"})]})})]})})};ye.displayName="AdMeshCompareTable";const He={"Top Match":"primary","Free Tier":"success","AI Powered":"secondary",Popular:"warning",New:"primary","Trial Available":"success"},qe={"Top Match":"★","Free Tier":"◆","AI Powered":"◉",Popular:"▲",New:"●","Trial Available":"◈"},ke=({type:t,variant:r,size:s="md",className:i,style:n})=>{const a=r||He[t]||"secondary",d=qe[t],c=_("admesh-component","admesh-badge",`admesh-badge--${a}`,`admesh-badge--${s}`,i);return e.jsxs("span",{className:c,style:n,children:[d&&e.jsx("span",{className:"admesh-badge__icon",children:d}),e.jsx("span",{className:"admesh-badge__text",children:t})]})};ke.displayName="AdMeshBadge";const Ye=({recommendation:t,theme:r={mode:"light"},className:s="",style:i,showPoweredBy:n=!0,initialExpanded:a=!1,sections:d,ctaText:c,collapsible:p=!0})=>{var T,L,R,N,x,A,P,I,O,z;re();const[m,g]=k.useState(a),h=()=>{p&&g(!m)},o=t.feature_sections||[],y=[{title:"Documentation",description:`Learn more about ${t.recommendation_title||t.title}. Start exploring the features and capabilities.`,icon:"◆"},{title:"Talk To An Expert",description:`Ready to learn more about ${t.recommendation_title||t.title}? Reach out to a platform specialist for personalized guidance.`,icon:"◉"},{title:`${t.recommendation_title||t.title} Features`,description:t.recommendation_description||t.description||`${t.recommendation_title||t.title} offers comprehensive solutions for your needs. Discover the full potential.`,icon:"▲"},{title:"How it Works",description:`Learn how to get started with ${t.recommendation_title||t.title}. Begin your journey today.`,icon:"●"}],w=te(t,!1),u=se(),f=d||(o.length>0?o:y),j=c||`Try ${t.recommendation_title||t.title}`,b={background:r.backgroundColor||(r.mode==="dark"?"#1f2937":"#ffffff"),surface:r.surfaceColor||(r.mode==="dark"?"#374151":"#f9fafb"),border:r.borderColor||(r.mode==="dark"?"#4b5563":"#e5e7eb"),text:r.textColor||(r.mode==="dark"?"#f9fafb":"#111827"),textSecondary:r.textSecondaryColor||(r.mode==="dark"?"#9ca3af":"#6b7280"),accent:r.accentColor||r.primaryColor||"#3b82f6",secondary:r.secondaryColor||"#10b981",headerBg:((T=r.gradients)==null?void 0:T.primary)||(r.mode==="dark"?"#374151":"#f8fafc"),sectionBg:((L=r.gradients)==null?void 0:L.secondary)||(r.mode==="dark"?"#4b5563":"#ffffff")},C=r.disableDefaultStyles?{}:{fontFamily:r.fontFamily||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',borderRadius:r.borderRadius||"12px",border:`1px solid ${b.border}`,background:b.background,overflow:"hidden",maxWidth:"420px",boxShadow:((R=r.shadows)==null?void 0:R.medium)||(r.mode==="dark"?"0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2)":"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)"),position:"relative",transition:"all 0.2s ease"};return e.jsxs("div",{className:`admesh-component admesh-expandable-unit ${s}`,style:{...C,...(N=r.components)==null?void 0:N.expandableUnit,...i},"data-admesh-theme":r.mode,children:[e.jsx("div",{style:{background:b.headerBg,padding:"20px",borderBottom:m||!p?`1px solid ${b.border}`:"none",position:"relative",transition:"all 0.2s ease"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px",flex:1,minWidth:0},children:[e.jsx("div",{style:{width:"40px",height:"40px",borderRadius:r.borderRadius||"8px",background:b.accent,display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontSize:((x=r.fontSize)==null?void 0:x.base)||"16px",fontWeight:"600",boxShadow:((A=r.shadows)==null?void 0:A.small)||"0 2px 4px rgba(0, 0, 0, 0.1)",border:`1px solid ${b.border}`},children:(t.recommendation_title||t.title).charAt(0).toUpperCase()}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("h3",{style:{margin:0,fontSize:"18px",fontWeight:"600",color:b.text,lineHeight:"1.4",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.recommendation_title||t.title}),e.jsxs("p",{style:{margin:"8px 0 0 0",fontSize:"13px",color:b.textSecondary,fontWeight:"400",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:u,children:[w," • ",new URL(t.url||t.admesh_link).hostname]})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[!m&&p&&e.jsx(D,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.recommendation_title||t.title,component:"expandable_unit",expanded:!1,location:"header"},children:e.jsx("button",{style:{padding:(P=r.spacing)!=null&&P.small?`${r.spacing.small} ${r.spacing.medium||"12px"}`:"6px 12px",backgroundColor:b.accent,color:"white",border:"none",borderRadius:r.borderRadius||"6px",fontSize:((I=r.fontSize)==null?void 0:I.small)||"12px",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease",boxShadow:((O=r.shadows)==null?void 0:O.small)||"0 1px 3px rgba(0, 0, 0, 0.1)",whiteSpace:"nowrap",...(z=r.components)==null?void 0:z.button},onMouseOver:S=>{var v;r.disableDefaultStyles||(S.currentTarget.style.transform="translateY(-1px)",S.currentTarget.style.boxShadow=((v=r.shadows)==null?void 0:v.medium)||"0 2px 6px rgba(0, 0, 0, 0.15)")},onMouseOut:S=>{var v;r.disableDefaultStyles||(S.currentTarget.style.transform="translateY(0)",S.currentTarget.style.boxShadow=((v=r.shadows)==null?void 0:v.small)||"0 1px 3px rgba(0, 0, 0, 0.1)")},children:j})}),p&&e.jsxs("button",{onClick:h,style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:r.mode==="dark"?"#374151":"#f3f4f6",border:`1px solid ${r.mode==="dark"?"#4b5563":"#d1d5db"}`,borderRadius:"8px",cursor:"pointer",color:r.accentColor||"#2563eb",fontSize:"12px",fontWeight:"600",transition:"all 0.2s ease"},onMouseEnter:S=>{S.currentTarget.style.background=r.mode==="dark"?"#4b5563":"#e5e7eb",S.currentTarget.style.borderColor=r.accentColor||"#2563eb"},onMouseLeave:S=>{S.currentTarget.style.background=r.mode==="dark"?"#374151":"#f3f4f6",S.currentTarget.style.borderColor=r.mode==="dark"?"#4b5563":"#d1d5db"},"aria-label":m?"Show less details":"Show more details",children:[e.jsx("span",{children:m?"Less Details":"More Details"}),e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:m?e.jsx("path",{d:"M5 12h14"}):e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M12 16v-4"}),e.jsx("path",{d:"M12 8h.01"})]})})]})]})]})}),(m||!p)&&e.jsxs("div",{style:{padding:"0"},children:[f.map((S,v)=>e.jsxs("div",{style:{padding:"24px",backgroundColor:v%2===0?b.background:b.sectionBg,borderBottom:v<f.length-1?`1px solid ${b.border}`:"none"},children:[e.jsxs("h4",{style:{margin:"0 0 12px 0",fontSize:"15px",fontWeight:"600",color:b.text,display:"flex",alignItems:"center",gap:"12px"},children:[S.icon&&e.jsx("span",{children:S.icon}),S.title]}),e.jsx("p",{style:{margin:0,fontSize:"14px",color:b.textSecondary,lineHeight:"1.6"},children:S.description})]},v)),(m||!p)&&e.jsx("div",{style:{padding:"24px",borderTop:`1px solid ${b.border}`,backgroundColor:b.background},children:e.jsx(D,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,component:"expandable_unit",expanded:m,location:"footer"},children:e.jsx("button",{style:{width:"100%",padding:"14px 28px",background:b.accent,color:"white",border:"none",borderRadius:"12px",fontSize:"15px",fontWeight:"600",cursor:"pointer",transition:"all 0.3s ease",boxShadow:"0 4px 12px rgba(99, 102, 241, 0.3)",position:"relative",overflow:"hidden"},onMouseOver:S=>{S.currentTarget.style.transform="translateY(-2px) scale(1.02)",S.currentTarget.style.boxShadow="0 8px 20px rgba(99, 102, 241, 0.4)"},onMouseOut:S=>{S.currentTarget.style.transform="translateY(0) scale(1)",S.currentTarget.style.boxShadow="0 4px 12px rgba(99, 102, 241, 0.3)"},children:j})})}),n&&e.jsx("div",{style:{padding:"8px 16px",borderTop:`1px solid ${b.border}`,backgroundColor:b.headerBg},children:e.jsxs("div",{style:{fontSize:"11px",color:b.textSecondary,textAlign:"center"},children:["powered by ",e.jsx("strong",{style:{color:b.text},children:"AdMesh"})]})})]})]})},U=({recommendation:t,theme:r,compact:s=!1,showReason:i=!0,className:n,style:a})=>{var h;const d=Math.round(t.intent_match_score*100),c=te(t,s),p=se(),m=_("admesh-inline-recommendation","group cursor-pointer transition-all duration-200",{"p-2 sm:p-3 rounded-md bg-gray-50 dark:bg-slate-800/50 hover:bg-gray-100 dark:hover:bg-slate-800 border border-gray-200 dark:border-slate-700":!s,"p-1.5 sm:p-2 rounded hover:bg-gray-50 dark:hover:bg-slate-800/30":s},n),g=r!=null&&r.accentColor?{"--admesh-primary":r.accentColor}:void 0;return e.jsx(D,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:t.intent_match_score},className:m,style:{fontFamily:(r==null?void 0:r.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(h=r==null?void 0:r.components)==null?void 0:h.inlineRecommendation,...a},children:e.jsxs("div",{className:"flex items-start gap-3",style:g,"data-admesh-theme":r==null?void 0:r.mode,children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:t.offer_images&&t.offer_images.length>0?e.jsx("div",{className:"w-6 h-6 rounded-full overflow-hidden border border-gray-200 dark:border-gray-600",children:e.jsx("img",{src:t.offer_images[0].url,alt:t.recommendation_title||t.title,className:"w-full h-full object-cover"})}):t.product_logo?e.jsx("div",{className:"w-6 h-6 rounded-full overflow-hidden border border-gray-200 dark:border-gray-600",children:e.jsx("img",{src:t.product_logo.url,alt:t.recommendation_title||t.title,className:"w-full h-full object-cover"})}):t.intent_match_score>=.8?e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}):e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start sm:items-center gap-2 mb-1 flex-col sm:flex-row",children:[e.jsx("h4",{className:_("font-medium transition-colors duration-200 flex-shrink-0","text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300","cursor-pointer hover:underline",s?"text-sm sm:text-base":"text-base sm:text-lg"),children:t.recommendation_title||t.title}),t.intent_match_score>=.7&&e.jsxs("span",{className:_("inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium flex-shrink-0 whitespace-nowrap",t.intent_match_score>=.8?"bg-green-100 text-green-800 dark:bg-green-800/80 dark:text-green-100":"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400"),children:[d,"% match"]})]}),i&&(t.recommendation_description||t.reason)&&e.jsx("p",{className:_("text-gray-600 dark:text-gray-400 line-clamp-2",s?"text-xs":"text-sm"),children:t.recommendation_description||t.reason}),e.jsx("p",{className:_("text-gray-500 dark:text-gray-400 mt-1","text-xs"),title:p,children:c}),!s&&t.keywords&&t.keywords.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[t.keywords.slice(0,3).map((o,y)=>e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-800 dark:bg-slate-700 dark:text-gray-300",children:o},y)),t.keywords.length>3&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["+",t.keywords.length-3," more"]})]}),!s&&t.trial_days&&t.trial_days>0&&e.jsx("div",{className:"flex items-center gap-2 mt-2",children:e.jsxs("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400",children:[t.trial_days,"-day trial"]})})]}),e.jsx("div",{className:"flex-shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("svg",{className:"w-4 h-4 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})})},ve=({recommendations:t,conversationSummary:r,theme:s,showTopRecommendations:i=3,onRecommendationClick:n,onStartNewConversation:a,className:d})=>{const c=t.sort((g,h)=>h.intent_match_score-g.intent_match_score).slice(0,i),p=_("admesh-conversation-summary","bg-white dark:bg-black","rounded-lg border border-gray-200 dark:border-gray-800 p-4 sm:p-6","font-sans",d),m=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:p,style:m,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 bg-black dark:bg-white rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4 sm:w-5 sm:h-5 text-white dark:text-black",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})})})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"text-base sm:text-lg font-semibold text-black dark:text-white",children:"Conversation Summary"}),e.jsx("p",{className:"text-xs sm:text-sm text-gray-600 dark:text-gray-300",children:"Here's what we discussed and found for you"})]})]}),e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-700",children:e.jsx("p",{className:"text-gray-800 dark:text-gray-200 leading-relaxed",children:r})})}),c.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("svg",{className:"w-5 h-5 text-black dark:text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("h4",{className:"font-medium text-black dark:text-white",children:"Top Recommendations"})]}),e.jsx("div",{className:"space-y-2",children:c.map((g,h)=>e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute -left-2 top-2 z-10",children:e.jsx("div",{className:_("w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold",h===0?"bg-black dark:bg-white text-white dark:text-black":h===1?"bg-gray-600 dark:bg-gray-400 text-white dark:text-black":"bg-gray-800 dark:bg-gray-200 text-white dark:text-black"),children:h+1})}),e.jsx("div",{className:"ml-4",children:e.jsx(U,{recommendation:g,theme:s,compact:!0,showReason:!0,onClick:n})})]},g.ad_id||h))})]}),t.length>i&&e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"bg-gray-100 dark:bg-gray-800 rounded-lg p-3 border border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 text-black dark:text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("span",{className:"text-sm font-medium text-gray-800 dark:text-gray-200",children:[t.length-i," additional recommendation",t.length-i>1?"s":""," available"]})]})})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[a&&e.jsxs("button",{onClick:a,className:"flex-1 bg-black dark:bg-white hover:bg-gray-800 dark:hover:bg-gray-100 text-white dark:text-black font-medium py-2.5 px-4 rounded-lg transition-all duration-200 flex items-center justify-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),"Start New Conversation"]}),e.jsxs("button",{onClick:()=>{c.length>0&&(n==null||n(c[0].ad_id,c[0].admesh_link))},className:"flex-1 bg-white dark:bg-gray-900 hover:bg-gray-50 dark:hover:bg-gray-800 text-black dark:text-white font-medium py-2.5 px-4 rounded-lg border border-gray-300 dark:border-gray-600 transition-all duration-200 flex items-center justify-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.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"})}),"View Top Pick"]})]}),e.jsx("div",{className:"flex justify-center mt-4 pt-4 border-t border-gray-200 dark:border-gray-700",children:e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Powered by AdMesh"})})]})},me=({recommendation:t,citationNumber:r,citationStyle:s="numbered",theme:i,showTooltip:n=!0,onHover:a,className:d,style:c})=>{const[p,m]=k.useState(!1),g=()=>{m(!0),a==null||a(t)},h=()=>{m(!1)},o=()=>{switch(s){case"bracketed":return`[${r}]`;case"superscript":return r.toString();case"numbered":default:return r.toString()}},y=_("admesh-citation-reference","inline-flex items-center justify-center","cursor-pointer transition-all duration-200","text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300","font-medium",{"w-5 h-5 bg-blue-100 dark:bg-blue-900/30 rounded-full text-xs border border-blue-300 dark:border-blue-700 hover:bg-blue-200 dark:hover:bg-blue-900/50":s==="numbered","px-1 text-sm hover:underline":s==="bracketed","text-xs align-super hover:underline":s==="superscript"},d),w=i!=null&&i.accentColor?{"--admesh-primary":i.accentColor}:void 0;return e.jsxs("span",{className:"relative inline-block",children:[e.jsx(D,{adId:t.ad_id,admeshLink:t.admesh_link,productId:t.product_id,trackingData:{title:t.title,matchScore:t.intent_match_score,citationNumber:r,citationStyle:s},className:y,style:c,children:e.jsx("span",{style:w,"data-admesh-theme":i==null?void 0:i.mode,onMouseEnter:g,onMouseLeave:h,children:o()})}),n&&p&&e.jsx("div",{className:"absolute bottom-full left-1/2 transform -translate-x-1/2 mb-2 z-50",children:e.jsxs("div",{className:"bg-gray-900 dark:bg-gray-100 text-white dark:text-gray-900 text-xs rounded-lg px-3 py-2 shadow-lg max-w-xs",children:[e.jsx("div",{className:"font-semibold mb-1",children:t.title}),t.reason&&e.jsx("div",{className:"text-gray-300 dark:text-gray-600 text-xs",children:t.reason.length>100?`${t.reason.substring(0,100)}...`:t.reason}),t.intent_match_score>=.7&&e.jsxs("div",{className:"text-green-400 dark:text-green-600 text-xs mt-1",children:[Math.round(t.intent_match_score*100),"% match"]}),e.jsx("div",{className:"text-gray-400 dark:text-gray-500 text-xs mt-1 italic",children:"Click to visit product page"}),e.jsx("div",{className:"absolute top-full left-1/2 transform -translate-x-1/2 w-0 h-0 border-l-4 border-r-4 border-t-4 border-transparent border-t-gray-900 dark:border-t-gray-100"})]})})]})},we=({recommendations:t,conversationText:r,theme:s,showCitationList:i=!0,citationStyle:n="numbered",onCitationHover:a,className:d,style:c})=>{var w;const[p,m]=k.useState(null),g=k.useMemo(()=>{if(!r||t.length===0)return{text:r,citationMap:new Map};let u=r;const f=new Map;return[...t].sort((b,C)=>C.intent_match_score-b.intent_match_score).forEach((b,C)=>{const T=C+1,L=b.title;f.set(T,b);const R=new RegExp(`\\b${L.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if(R.test(u))u=u.replace(R,N=>`${N}{{CITATION_${T}}}`);else{const N=b.keywords||[];let x=!1;for(const A of N){const P=new RegExp(`\\b${A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if(P.test(u)&&!x){u=u.replace(P,I=>(x=!0,`${I}{{CITATION_${T}}}`));break}}x||(u+=`{{CITATION_${T}}}`)}}),{text:u,citationMap:f}},[r,t]),h=()=>{const{text:u,citationMap:f}=g;return u.split(/(\{\{CITATION_\d+\}\})/).map((b,C)=>{const T=b.match(/\{\{CITATION_(\d+)\}\}/);if(T){const L=parseInt(T[1]),R=f.get(L);if(R)return e.jsx(me,{recommendation:R,citationNumber:L,citationStyle:n,theme:s,showTooltip:!0,onHover:N=>{m(N),a==null||a(N)}},`citation-${L}-${C}`)}return e.jsx("span",{children:b},C)})},o=_("admesh-citation-unit","space-y-4",d),y=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:o,style:{...y,fontFamily:(s==null?void 0:s.fontFamily)||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...(w=s==null?void 0:s.components)==null?void 0:w.citationUnit,...c},"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsx("div",{className:"admesh-citation-text text-gray-800 dark:text-gray-200 leading-relaxed",children:h()}),i&&t.length>0&&e.jsx("div",{className:"admesh-citation-list",children:e.jsxs("div",{className:"border-t border-gray-200 dark:border-slate-700 pt-4",children:[e.jsxs("h4",{className:"text-sm font-semibold text-gray-700 dark:text-gray-300 mb-3 flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),"References"]}),e.jsx("div",{className:"space-y-2",children:t.sort((u,f)=>f.intent_match_score-u.intent_match_score).map((u,f)=>e.jsxs("div",{className:_("flex items-start gap-3 p-2 rounded-lg transition-colors duration-200",{"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800":(p==null?void 0:p.ad_id)===u.ad_id,"hover:bg-gray-50 dark:hover:bg-slate-800/50":(p==null?void 0:p.ad_id)!==u.ad_id}),children:[e.jsx("div",{className:"flex-shrink-0 mt-1",children:e.jsx(me,{recommendation:u,citationNumber:f+1,citationStyle:n,theme:s,showTooltip:!1})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(U,{recommendation:u,theme:s,compact:!0,showReason:!1})})]},u.ad_id||f))})]})})]})},xe=({recommendations:t,config:r,theme:s,conversationSummary:i,sessionId:n,onRecommendationClick:a,onDismiss:d,className:c})=>{const[p,m]=k.useState(r.autoShow!==!1),[g,h]=k.useState(!1);if(k.useEffect(()=>{if(r.delayMs&&r.delayMs>0){const C=setTimeout(()=>{m(!0),h(!0)},r.delayMs);return()=>clearTimeout(C)}else h(!0)},[r.delayMs]),!p||t.length===0)return null;const o=r.maxRecommendations||3,y=t.slice(0,o),w=(C,T)=>{a==null||a(C,T)},u=()=>{m(!1),d==null||d()},f=()=>{switch(r.displayMode){case"summary":return i?e.jsx(ve,{recommendations:y,conversationSummary:i,theme:s,showTopRecommendations:o,onRecommendationClick:w,onStartNewConversation:d}):null;case"inline":return e.jsx("div",{className:"space-y-2",children:y.map((C,T)=>e.jsx(U,{recommendation:C,theme:s,compact:!0,showReason:!0,onClick:w},C.ad_id||T))});case"minimal":return y.length>0?e.jsxs("div",{className:"admesh-minimal-unit",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[y.length," intelligent match",y.length>1?"es":""," found"]})]}),e.jsx(U,{recommendation:y[0],theme:s,compact:!0,showReason:!1,onClick:w}),y.length>1&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["+",y.length-1," more recommendation",y.length>2?"s":""]})]}):null;case"citation":return i?e.jsx(we,{recommendations:y,conversationText:i,theme:s,showCitationList:!0,citationStyle:"numbered",onRecommendationClick:w}):null;case"floating":return e.jsxs("div",{className:"admesh-floating-unit bg-white dark:bg-slate-800 rounded-lg shadow-lg border border-gray-200 dark:border-slate-700 p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 bg-blue-500 rounded-full"}),e.jsx("span",{className:"text-sm font-semibold text-gray-800 dark:text-gray-200",children:"Recommended for you"})]}),d&&e.jsx("button",{onClick:u,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors","aria-label":"Dismiss recommendations",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsx("div",{className:"space-y-2",children:y.map((C,T)=>e.jsx(U,{recommendation:C,theme:s,compact:!0,showReason:!1,onClick:w},C.ad_id||T))})]});default:return e.jsx("div",{className:"space-y-3",children:y.map((C,T)=>e.jsx(ae,{recommendation:C,theme:s,showMatchScore:!1,showBadges:!0,onClick:w},C.ad_id||T))})}},j=_("admesh-conversational-unit","transition-all duration-300 ease-in-out",{"opacity-0 translate-y-2":!g,"opacity-100 translate-y-0":g,"fixed bottom-4 right-4 max-w-sm z-50":r.displayMode==="floating","my-3":r.displayMode==="inline","mt-4 pt-4 border-t border-gray-200 dark:border-slate-700":r.displayMode==="summary"},c),b=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:j,style:b,"data-admesh-theme":s==null?void 0:s.mode,"data-admesh-context":r.context,"data-session-id":n,children:[f(),r.showPoweredBy!==!1&&e.jsx("div",{className:"flex justify-end mt-2",children:e.jsx("span",{className:"text-xs text-gray-400 dark:text-gray-500",children:"Powered by AdMesh"})})]})},je=({message:t,theme:r,onRecommendationClick:s,className:i})=>{const n=t.role==="user",a=t.role==="assistant",d=_("admesh-chat-message","flex items-start gap-3",{"flex-row-reverse":n},i),c=_("max-w-xs lg:max-w-sm px-4 py-3 rounded-lg text-sm",{"bg-gradient-to-r from-blue-600 to-indigo-600 text-white":n,"bg-gray-100 dark:bg-slate-800 text-gray-900 dark:text-gray-100":a,"bg-yellow-100 dark:bg-yellow-900 text-yellow-900 dark:text-yellow-100":t.role==="system"}),p=r!=null&&r.accentColor?{"--admesh-primary":r.accentColor}:void 0,m=g=>g.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:d,style:p,"data-admesh-theme":r==null?void 0:r.mode,children:[!n&&e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-blue-600 to-indigo-600 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-4 h-4 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),n&&e.jsx("div",{className:"w-8 h-8 bg-gray-300 dark:bg-slate-600 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-300",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}),e.jsxs("div",{className:`flex flex-col ${n?"items-end":"items-start"} flex-1`,children:[e.jsx("div",{className:c,children:e.jsx("div",{className:"whitespace-pre-wrap break-words",children:t.content})}),e.jsx("div",{className:_("text-xs text-gray-500 dark:text-gray-400 mt-1",{"text-right":n}),children:m(t.timestamp)}),t.recommendations&&t.recommendations.length>0&&e.jsxs("div",{className:"mt-3 w-full max-w-lg",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("svg",{className:"w-4 h-4 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[t.recommendations.length," recommendation",t.recommendations.length>1?"s":""," found"]})]}),e.jsx(xe,{recommendations:t.recommendations,config:{displayMode:"inline",context:"chat",maxRecommendations:3,showPoweredBy:!1,autoShow:!0,delayMs:300},theme:r,onRecommendationClick:s,className:"bg-gray-50 dark:bg-slate-800/50 rounded-lg p-3 border border-gray-200 dark:border-slate-700"})]})]})]})},Ne=({placeholder:t="Type your message...",disabled:r=!1,suggestions:s=[],theme:i,onSendMessage:n,className:a})=>{const[d,c]=k.useState(""),[p,m]=k.useState(!1),[g,h]=k.useState([]),o=k.useRef(null),y=L=>{const R=L.target.value;if(c(R),R.trim()&&s.length>0){const N=s.filter(x=>x.toLowerCase().includes(R.toLowerCase()));h(N),m(N.length>0)}else m(!1);o.current&&(o.current.style.height="auto",o.current.style.height=`${Math.min(o.current.scrollHeight,120)}px`)},w=L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),u())},u=()=>{const L=d.trim();L&&!r&&n&&(n(L),c(""),m(!1),o.current&&(o.current.style.height="auto"))},f=L=>{c(L),m(!1),o.current&&o.current.focus()},j=_("admesh-chat-input","relative",a),b=_("w-full resize-none rounded-lg border border-gray-300 dark:border-slate-600","bg-white dark:bg-slate-800 text-gray-900 dark:text-gray-100","placeholder-gray-500 dark:placeholder-gray-400","focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent","transition-all duration-200 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-slate-600","pr-12 pl-4 py-3 text-sm leading-5",{"opacity-50 cursor-not-allowed":r}),C=_("absolute right-2 bottom-2 p-2 rounded-lg transition-all duration-200","flex items-center justify-center",{"bg-blue-600 hover:bg-blue-700 text-white":d.trim()&&!r,"bg-gray-200 dark:bg-slate-700 text-gray-400 dark:text-gray-500 cursor-not-allowed":!d.trim()||r}),T=i!=null&&i.accentColor?{"--admesh-primary":i.accentColor}:void 0;return e.jsxs("div",{className:j,style:T,"data-admesh-theme":i==null?void 0:i.mode,children:[p&&g.length>0&&e.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 bg-white dark:bg-slate-800 border border-gray-200 dark:border-slate-700 rounded-lg shadow-lg max-h-40 overflow-y-auto z-10",children:g.slice(0,5).map((L,R)=>e.jsx("button",{onClick:()=>f(L),className:"w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-slate-700 transition-colors first:rounded-t-lg last:rounded-b-lg",children:L},R))}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:o,value:d,onChange:y,onKeyDown:w,placeholder:t,disabled:r,rows:1,className:b,style:{minHeight:"44px",maxHeight:"120px"}}),e.jsx("button",{onClick:u,disabled:!d.trim()||r,className:C,"aria-label":"Send message",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 19l9 2-9-18-9 18 9-2zm0 0v-8"})})})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2 text-xs text-gray-500 dark:text-gray-400",children:[e.jsx("span",{children:"Press Enter to send, Shift+Enter for new line"}),e.jsxs("span",{className:_("transition-opacity duration-200",{"opacity-0":d.length<100}),children:[d.length,"/500"]})]})]})},_e=({messages:t,config:r,theme:s,isLoading:i=!1,onSendMessage:n,onRecommendationClick:a,className:d})=>{const c=k.useRef(null),p=k.useRef(null);k.useEffect(()=>{c.current&&c.current.scrollIntoView({behavior:"smooth"})},[t]);const m=_("admesh-chat-interface","flex flex-col h-full bg-white dark:bg-slate-900",d),g=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0,h=r.maxMessages?t.slice(-r.maxMessages):t;return e.jsxs("div",{className:m,style:g,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsx("div",{ref:p,className:"flex-1 overflow-y-auto p-4 space-y-4 scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-slate-600",children:h.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-gradient-to-br from-blue-100 to-indigo-100 dark:from-blue-900 dark:to-indigo-900 rounded-full flex items-center justify-center mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-blue-600 dark:text-blue-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 mb-2",children:"Welcome to AdMesh AI"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 max-w-xs",children:"Ask me anything about products, tools, or services. I'll provide personalized recommendations just for you!"})]}):e.jsxs(e.Fragment,{children:[h.map(o=>e.jsx(je,{message:o,theme:s,onRecommendationClick:a},o.id)),i&&r.enableTypingIndicator!==!1&&e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-gradient-to-br from-blue-600 to-indigo-600 rounded-full flex items-center justify-center flex-shrink-0",children:e.jsx("svg",{className:"w-4 h-4 text-white",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),e.jsx("div",{className:"bg-gray-100 dark:bg-slate-800 rounded-lg px-4 py-3 max-w-xs",children:e.jsxs("div",{className:"flex space-x-1",children:[e.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce"}),e.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),e.jsx("div",{className:"w-2 h-2 bg-gray-400 dark:bg-gray-500 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})]}),e.jsx("div",{ref:c})]})}),r.enableSuggestions&&r.suggestions&&r.suggestions.length>0&&t.length===0&&e.jsxs("div",{className:"px-4 pb-2",children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-2",children:"Quick suggestions:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:r.suggestions.slice(0,3).map((o,y)=>e.jsx("button",{onClick:()=>n==null?void 0:n(o),className:"px-3 py-1.5 text-xs bg-gray-100 dark:bg-slate-800 hover:bg-gray-200 dark:hover:bg-slate-700 text-gray-700 dark:text-gray-300 rounded-full transition-colors",children:o},y))})]}),r.showInputField!==!1&&n&&e.jsx("div",{className:"border-t border-gray-200 dark:border-slate-700 p-4",children:e.jsx(Ne,{placeholder:r.placeholder||"Ask me about products, tools, or services...",disabled:i,suggestions:r.suggestions,theme:s,onSendMessage:n})})]})},Ge=({config:t,theme:r,title:s="AI Assistant",subtitle:i="Get personalized recommendations",isOpen:n,onToggle:a,onSendMessage:d,onRecommendationClick:c,autoRecommendations:p,autoRecommendationTrigger:m,showInputField:g=!0,autoShowRecommendations:h=!1,onAutoRecommendationDismiss:o,className:y})=>{const[w,u]=k.useState(t.autoOpen||!1),[f,j]=k.useState([]),[b,C]=k.useState(!1),[T,L]=k.useState(!1),R=n!==void 0?n:w;k.useEffect(()=>{if(t.showWelcomeMessage&&t.welcomeMessage&&f.length===0){const S={id:"welcome",role:"assistant",content:t.welcomeMessage,timestamp:new Date};j([S])}},[t.showWelcomeMessage,t.welcomeMessage,f.length]),k.useEffect(()=>{if(p&&p.length>0&&h){const S={id:`auto-${Date.now()}`,role:"assistant",content:m?`Based on "${m}", here are some relevant recommendations:`:"I found some relevant recommendations for you:",timestamp:new Date,recommendations:p};n===void 0&&u(!0),j(v=>v.some($=>$.id.startsWith("auto-"))?v.map($=>$.id.startsWith("auto-")?S:$):[...v,S])}},[p,h,m,n]);const N=()=>{a?a():u(!w),L(!0)},x=async S=>{if(!d)return;const v={id:`user-${Date.now()}`,role:"user",content:S,timestamp:new Date};j(B=>[...B,v]),C(!0);try{await d(S)}catch(B){console.error("Error sending message:",B);const $={id:`error-${Date.now()}`,role:"assistant",content:"Sorry, I encountered an error. Please try again.",timestamp:new Date};j(K=>[...K,$])}finally{C(!1)}},A=()=>{switch(t.size){case"sm":return"w-80 h-96";case"md":return"w-96 h-[32rem]";case"lg":return"w-[28rem] h-[36rem]";case"xl":return"w-[32rem] h-[40rem]";default:return"w-96 h-[32rem]"}},I=_("admesh-floating-chat","fixed z-50 transition-all duration-300 ease-in-out",(()=>{switch(t.position){case"bottom-right":return"bottom-4 right-4";case"bottom-left":return"bottom-4 left-4";case"top-right":return"top-4 right-4";case"top-left":return"top-4 left-4";default:return"bottom-4 right-4"}})(),y),O=_("bg-white dark:bg-slate-900 rounded-lg shadow-2xl border border-gray-200 dark:border-slate-700 overflow-hidden",A(),{"opacity-0 scale-95 pointer-events-none":!R,"opacity-100 scale-100":R}),z=r!=null&&r.accentColor?{"--admesh-primary":r.accentColor}:void 0;return e.jsxs("div",{className:I,style:z,"data-admesh-theme":r==null?void 0:r.mode,children:[e.jsx("div",{className:O,children:R&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gradient-to-r from-blue-600 to-indigo-600 text-white",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-white bg-opacity-20 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-sm",children:s}),e.jsx("p",{className:"text-xs text-blue-100",children:i})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[p&&p.length>0&&o&&e.jsx("button",{onClick:()=>{o(),j(S=>S.filter(v=>!v.id.startsWith("auto-")))},className:"p-1 rounded-full hover:bg-white hover:bg-opacity-20 transition-colors","aria-label":"Dismiss recommendations",title:"Dismiss recommendations",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.875 18.825A10.05 10.05 0 0112 19c-4.478 0-8.268-2.943-9.543-7a9.97 9.97 0 011.563-3.029m5.858.908a3 3 0 114.243 4.243M9.878 9.878l4.242 4.242M9.878 9.878L3 3m6.878 6.878L21 21"})})}),e.jsx("button",{onClick:N,className:"p-1 rounded-full hover:bg-white hover:bg-opacity-20 transition-colors","aria-label":"Close chat",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),e.jsx(_e,{messages:f,config:{...t,showInputField:g},theme:r,isLoading:b,onSendMessage:g?x:()=>{},onRecommendationClick:c,className:"h-full"})]})}),!R&&e.jsxs("button",{onClick:N,className:_("w-14 h-14 bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700","text-white rounded-full shadow-lg hover:shadow-xl transition-all duration-200","flex items-center justify-center relative"),"aria-label":"Open chat",children:[e.jsx("svg",{className:"w-6 h-6",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})}),!T&&e.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full animate-pulse"})]}),R&&e.jsx("div",{className:"absolute bottom-2 right-2 text-xs text-gray-400 dark:text-gray-500 bg-white dark:bg-slate-900 px-2 py-1 rounded shadow-sm",children:"Powered by AdMesh"})]})},Ce=({title:t,theme:r,collapsible:s=!1,isCollapsed:i=!1,onToggle:n,onSearch:a,showSearch:d=!1,className:c})=>{const[p,m]=k.useState(""),[g,h]=k.useState(!1),[o,y]=k.useState(!1);k.useEffect(()=>{const b=()=>{y(window.innerWidth<640)};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[]);const w=b=>{const C=b.target.value;m(C),a==null||a(C)},u=()=>{m(""),a==null||a("")},f=_("admesh-sidebar-header","flex flex-col p-4 border-b border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-800",c),j=r!=null&&r.accentColor?{"--admesh-primary":r.accentColor}:void 0;return e.jsxs("div",{className:f,style:j,"data-admesh-theme":r==null?void 0:r.mode,children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100 truncate",children:t}),e.jsxs("div",{className:"flex items-center gap-2",children:[o&&n&&e.jsx("button",{onClick:n,className:"p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-slate-700 transition-colors flex-shrink-0 sm:hidden",title:"Close sidebar",children:e.jsx("svg",{className:"w-4 h-4 text-gray-600 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),s&&e.jsx("button",{onClick:n,className:"p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-slate-700 transition-colors flex-shrink-0 hidden sm:block",title:i?"Expand sidebar":"Collapse sidebar",children:e.jsx("svg",{className:_("w-4 h-4 text-gray-600 dark:text-gray-400 transition-transform duration-200",{"rotate-180":i}),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})})]})]}),d&&!i&&e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:_("relative flex items-center transition-all duration-200",{"ring-2 ring-blue-500 dark:ring-blue-400":g}),children:[e.jsx("div",{className:"absolute left-3 pointer-events-none",children:e.jsx("svg",{className:"w-4 h-4 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),e.jsx("input",{type:"text",value:p,onChange:w,onFocus:()=>h(!0),onBlur:()=>h(!1),placeholder:"Search recommendations...",className:_("w-full pl-10 pr-10 py-2 text-sm bg-white dark:bg-slate-900 border border-gray-300 dark:border-slate-600 rounded-lg","placeholder-gray-400 dark:placeholder-gray-500 text-gray-900 dark:text-gray-100","focus:outline-none focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 focus:border-transparent","transition-all duration-200")}),p&&e.jsx("button",{onClick:u,className:"absolute right-3 p-0.5 rounded-full hover:bg-gray-200 dark:hover:bg-slate-700 transition-colors",title:"Clear search",children:e.jsx("svg",{className:"w-3 h-3 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),p&&e.jsx("div",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:"Search results will be filtered in real-time"})]}),!i&&e.jsxs("div",{className:"mt-3 flex items-center gap-4 text-xs text-gray-500 dark:text-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),e.jsx("span",{children:"Live recommendations"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("svg",{className:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsx("span",{children:"AI-powered"})]})]})]})},Me=({recommendations:t,displayMode:r,theme:s,maxRecommendations:i,onRecommendationClick:n,className:a})=>{const[d,c]=k.useState(!1),[p,m]=k.useState("all"),g=i?t.slice(0,i):t,o=(()=>{switch(p){case"top":return g.filter(f=>f.intent_match_score>=.8).slice(0,5);case"recent":return g.slice(0,3);default:return g}})(),y=_("admesh-sidebar-content","flex flex-col h-full",a),w=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0,u=()=>{if(o.length===0)return e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-6 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-100 dark:bg-slate-800 rounded-full flex items-center justify-center mb-4",children:e.jsx("svg",{className:"w-8 h-8 text-gray-400 dark:text-gray-500",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}),e.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 mb-2",children:"No recommendations found"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Try adjusting your search or filters"})]});switch(r){case"recommendations":return e.jsx("div",{className:"space-y-3",children:o.map((f,j)=>e.jsx(U,{recommendation:f,theme:s,compact:!0,showReason:!0,onClick:n},f.ad_id||j))});case"history":return e.jsx("div",{className:"space-y-2",children:o.map((f,j)=>e.jsxs("div",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-gray-50 dark:hover:bg-slate-800 transition-colors",children:[e.jsx("div",{className:"w-2 h-2 bg-gray-400 rounded-full flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-gray-100 truncate",children:f.title}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[Math.round(f.intent_match_score*100),"% match"]})]})]},f.ad_id||j))});case"favorites":return e.jsx("div",{className:"space-y-3",children:o.slice(0,3).map((f,j)=>e.jsxs("div",{className:"relative",children:[e.jsx(U,{recommendation:f,theme:s,compact:!0,showReason:!1,onClick:n}),e.jsx("button",{className:"absolute top-2 right-2 p-1 rounded-full hover:bg-gray-100 dark:hover:bg-slate-700 transition-colors",children:e.jsx("svg",{className:"w-3 h-3 text-yellow-500",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"})})})]},f.ad_id||j))});case"mixed":return e.jsxs("div",{className:"space-y-4",children:[o[0]&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-2",children:"Top Pick"}),e.jsx(ae,{recommendation:o[0],theme:s,showMatchScore:!0,showBadges:!0,onClick:n,className:"text-xs"})]}),o.slice(1).length>0&&e.jsxs("div",{children:[e.jsx("h4",{className:"text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-2",children:"More Options"}),e.jsx("div",{className:"space-y-2",children:o.slice(1,4).map((f,j)=>e.jsx(U,{recommendation:f,theme:s,compact:!0,showReason:!1,onClick:n},f.ad_id||j))})]})]});default:return e.jsx("div",{className:"space-y-3",children:o.map((f,j)=>e.jsx(U,{recommendation:f,theme:s,compact:!0,showReason:!0,onClick:n},f.ad_id||j))})}};return e.jsxs("div",{className:y,style:w,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsxs("div",{className:"flex border-b border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900",children:[e.jsxs("button",{onClick:()=>m("all"),className:_("flex-1 px-3 py-2 text-xs font-medium transition-colors",p==="all"?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:["All (",t.length,")"]}),e.jsx("button",{onClick:()=>m("top"),className:_("flex-1 px-3 py-2 text-xs font-medium transition-colors",p==="top"?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:"Top"}),e.jsx("button",{onClick:()=>m("recent"),className:_("flex-1 px-3 py-2 text-xs font-medium transition-colors",p==="recent"?"text-blue-600 dark:text-blue-400 border-b-2 border-blue-600 dark:border-blue-400":"text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300"),children:"Recent"})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4 min-h-0",style:{WebkitOverflowScrolling:"touch",overscrollBehavior:"contain"},children:u()}),e.jsx("div",{className:"p-3 border-t border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-800",children:e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-gray-500 dark:text-gray-400",children:[o.length," recommendation",o.length!==1?"s":""]}),e.jsx("button",{onClick:()=>c(!d),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors",children:"Filters"})]})})]})},Ke=({recommendations:t,config:r,theme:s,title:i="Recommendations",isOpen:n=!0,onToggle:a,onRecommendationClick:d,onSearch:c,className:p,containerMode:m=!1})=>{const[g,h]=k.useState(r.defaultCollapsed||!1),[o,y]=k.useState(""),[w]=k.useState({}),[u,f]=k.useState(!1);k.useEffect(()=>{const N=()=>{f(window.innerWidth<640)};return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[]),k.useEffect(()=>{if(u&&n&&!g&&!m){const N=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.width="100%",()=>{document.body.style.overflow=N,document.body.style.position="",document.body.style.width=""}}},[u,n,g,m]),k.useEffect(()=>{if(r.autoRefresh&&r.refreshInterval){const N=setInterval(()=>{console.log("Auto-refreshing recommendations...")},r.refreshInterval);return()=>clearInterval(N)}},[r.autoRefresh,r.refreshInterval]);const j=k.useMemo(()=>{let N=[...t];if(o.trim()){const x=o.toLowerCase();N=N.filter(A=>{var P;return A.title.toLowerCase().includes(x)||A.reason.toLowerCase().includes(x)||((P=A.keywords)==null?void 0:P.some(I=>I.toLowerCase().includes(x)))})}return w.categories&&w.categories.length>0&&(N=N.filter(x=>{var A;return(A=x.categories)==null?void 0:A.some(P=>{var I;return(I=w.categories)==null?void 0:I.includes(P)})})),w.hasFreeTier,w.hasTrial&&(N=N.filter(x=>x.trial_days&&x.trial_days>0)),w.minMatchScore!==void 0&&(N=N.filter(x=>x.intent_match_score>=w.minMatchScore)),N.sort((x,A)=>A.intent_match_score-x.intent_match_score),r.maxRecommendations&&(N=N.slice(0,r.maxRecommendations)),N},[t,o,w,r.maxRecommendations]),b=()=>{r.collapsible&&(h(!g),a==null||a())},C=N=>{y(N),c==null||c(N)},L=_("admesh-sidebar","flex flex-col bg-white dark:bg-slate-900 border-gray-200 dark:border-slate-700 shadow-lg transition-all duration-300 ease-in-out",(()=>{if(g)return"w-12";switch(r.size){case"sm":return"w-full sm:w-64 max-w-[90vw] sm:max-w-sm";case"md":return"w-full sm:w-80 max-w-[90vw] sm:max-w-md";case"lg":return"w-full sm:w-96 max-w-[90vw] sm:max-w-lg";case"xl":return"w-full sm:w-[28rem] max-w-[90vw] sm:max-w-xl";default:return"w-full sm:w-80 max-w-[90vw] sm:max-w-md"}})(),{"border-r":r.position==="left","border-l":r.position==="right","fixed top-0 bottom-0 z-[9999]":!m,"relative h-full":m,"left-0":r.position==="left"&&!m,"right-0":r.position==="right"&&!m,"transform -translate-x-full":r.position==="left"&&!n&&!m,"transform translate-x-full":r.position==="right"&&!n&&!m,"min-h-0":!0,"overflow-hidden":!m},p),R=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return!n&&!r.collapsible?null:e.jsxs(e.Fragment,{children:[n&&!g&&e.jsx("div",{className:_("bg-black bg-opacity-50 z-[9998] sm:hidden transition-opacity duration-300",m?"absolute inset-0":"fixed inset-0"),onClick:()=>a==null?void 0:a(),style:{position:m?"absolute":"fixed",top:0,left:0,right:0,bottom:0,touchAction:"none"}}),e.jsxs("div",{className:L,style:R,"data-admesh-theme":s==null?void 0:s.mode,"data-sidebar-position":r.position,"data-sidebar-size":r.size,"data-mobile-open":u&&n&&!g?"true":"false","data-container-mode":m?"true":"false",children:[r.showHeader!==!1&&e.jsx(Ce,{title:i,theme:s,collapsible:r.collapsible,isCollapsed:g,onToggle:b,onSearch:r.showSearch?C:void 0,showSearch:r.showSearch&&!g}),!g&&e.jsx(Me,{recommendations:j,displayMode:r.displayMode,theme:s,maxRecommendations:r.maxRecommendations,onRecommendationClick:d,className:"flex-1 overflow-hidden min-h-0"}),g&&r.collapsible&&e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-2",children:[e.jsx("button",{onClick:b,className:"p-2 rounded-lg hover:bg-gray-100 dark:hover:bg-slate-800 transition-colors",title:"Expand sidebar",children:e.jsx("svg",{className:"w-5 h-5 text-gray-600 dark:text-gray-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})}),e.jsx("div",{className:"mt-4 text-xs text-gray-500 dark:text-gray-400 transform -rotate-90 whitespace-nowrap",children:j.length})]}),!g&&e.jsx("div",{className:"p-3 border-t border-gray-200 dark:border-slate-700",children:e.jsx("div",{className:"text-xs text-gray-400 dark:text-gray-500 text-center",children:"Powered by AdMesh"})})]})]})},Je=({recommendations:t,trigger:r,theme:s,title:i="AI Recommendations",position:n="bottom-right",size:a="md",autoShow:d=!0,showDelay:c=1e3,onRecommendationClick:p,onDismiss:m,className:g})=>{const[h,o]=k.useState(!1),[y,w]=k.useState(!1);k.useEffect(()=>{if(d&&t.length>0){const T=setTimeout(()=>{o(!0),w(!0)},c);return()=>clearTimeout(T)}},[d,t.length,c]);const u=()=>{o(!1),m==null||m()},f=()=>{switch(a){case"sm":return"w-72 max-h-80";case"md":return"w-80 max-h-96";case"lg":return"w-96 max-h-[28rem]";default:return"w-80 max-h-96"}},j=()=>{switch(n){case"bottom-right":return"bottom-4 right-4";case"bottom-left":return"bottom-4 left-4";case"top-right":return"top-4 right-4";case"top-left":return"top-4 left-4";default:return"bottom-4 right-4"}};if(!h||t.length===0)return null;const b=_("admesh-auto-recommendation-widget","fixed z-50 transition-all duration-500 ease-out",j(),f(),{"opacity-0 scale-95 translate-y-2":!y,"opacity-100 scale-100 translate-y-0":y},g),C=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsx("div",{className:b,style:C,"data-admesh-theme":s==null?void 0:s.mode,children:e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg shadow-2xl border border-gray-200 dark:border-slate-700 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-gradient-to-r from-blue-600 to-indigo-600 text-white",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 bg-white bg-opacity-20 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-sm",children:i}),r&&e.jsxs("p",{className:"text-xs text-blue-100 truncate max-w-48",children:['Based on: "',r,'"']})]})]}),e.jsx("button",{onClick:u,className:"p-1 rounded-full hover:bg-white hover:bg-opacity-20 transition-colors","aria-label":"Dismiss recommendations",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("div",{className:"p-4 max-h-80 overflow-y-auto scrollbar-thin scrollbar-thumb-gray-300 dark:scrollbar-thumb-slate-600",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),e.jsxs("span",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:[t.length," intelligent match",t.length>1?"es":""," found"]})]}),e.jsx(xe,{recommendations:t,config:{displayMode:"inline",context:"assistant",maxRecommendations:3,showPoweredBy:!1,autoShow:!0,delayMs:200},theme:s,onRecommendationClick:p})]}),e.jsx("div",{className:"px-4 py-3 bg-gray-50 dark:bg-slate-800 border-t border-gray-200 dark:border-slate-700",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Powered by AdMesh"}),e.jsx("button",{onClick:u,className:"text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors",children:"Dismiss"})]})})]})})},Y=(t={})=>{const r={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:"→"}};return{...r,...t,fontSize:{...r.fontSize,...t.fontSize},spacing:{...r.spacing,...t.spacing},shadows:{...r.shadows,...t.shadows},icons:{...r.icons,...t.icons},components:{...r.components,...t.components}}},Qe=(t={})=>Y({...{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)"}},...t}),Xe={minimal:Y({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)"}}),vibrant:Y({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%)"}}),corporate:Y({primaryColor:"#1e40af",secondaryColor:"#059669",backgroundColor:"#f8fafc",surfaceColor:"#ffffff",borderColor:"#cbd5e1",borderRadius:"6px",fontFamily:'"Inter", -apple-system, BlinkMacSystemFont, sans-serif'}),highContrast:Y({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"}})},Ze=(...t)=>{const r=Y();return t.reduce((s,i)=>i?Y({...s,...i}):s,r)},er=t=>{var s,i,n,a,d,c;const r=getComputedStyle(t);return{primaryColor:((s=r.getPropertyValue("--admesh-primary-color"))==null?void 0:s.trim())||void 0,secondaryColor:((i=r.getPropertyValue("--admesh-secondary-color"))==null?void 0:i.trim())||void 0,backgroundColor:((n=r.getPropertyValue("--admesh-background-color"))==null?void 0:n.trim())||void 0,textColor:((a=r.getPropertyValue("--admesh-text-color"))==null?void 0:a.trim())||void 0,borderRadius:((d=r.getPropertyValue("--admesh-border-radius"))==null?void 0:d.trim())||void 0,fontFamily:((c=r.getPropertyValue("--admesh-font-family"))==null?void 0:c.trim())||void 0}},rr="0.2.1",tr={trackingEnabled:!0,debug:!1,theme:{mode:"light",accentColor:"#2563eb"}};exports.AdMeshAutoRecommendationWidget=Je;exports.AdMeshBadge=ke;exports.AdMeshChatInput=Ne;exports.AdMeshChatInterface=_e;exports.AdMeshChatMessage=je;exports.AdMeshCitationReference=me;exports.AdMeshCitationUnit=we;exports.AdMeshCompareTable=ye;exports.AdMeshConversationSummary=ve;exports.AdMeshConversationalUnit=xe;exports.AdMeshEcommerceCards=Ue;exports.AdMeshExpandableUnit=Ye;exports.AdMeshFloatingChat=Ge;exports.AdMeshInlineRecommendation=U;exports.AdMeshLinkTracker=D;exports.AdMeshProductCard=ae;exports.AdMeshSidebar=Ke;exports.AdMeshSidebarContent=Me;exports.AdMeshSidebarHeader=Ce;exports.DEFAULT_CONFIG=tr;exports.VERSION=rr;exports.buildAdMeshLink=Be;exports.createAdMeshTheme=Y;exports.createDarkTheme=Qe;exports.extractTrackingData=We;exports.getBadgeText=be;exports.getCtaText=$e;exports.getInlineDisclosure=te;exports.getInlineTooltip=se;exports.getLabelTooltip=Z;exports.getPoweredByText=Ve;exports.getRecommendationLabel=q;exports.getSectionDisclosure=Oe;exports.hasHighQualityMatches=De;exports.mergeThemes=Ze;exports.setAdMeshTrackerConfig=ze;exports.themeFromCSSProperties=er;exports.themePresets=Xe;exports.useAdMeshStyles=re;exports.useAdMeshTracker=fe;
|
|
671
685
|
//# sourceMappingURL=index.js.map
|