UNPKG

admesh-ui-sdk

Version:

Beautiful, modern React components for displaying AI-powered product recommendations with citation-based conversation ads, auto-triggered widgets, floating chat, conversational interfaces, persistent sidebar, and built-in tracking

276 lines (243 loc) 77 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react");function Ne(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var K={exports:{}},U={};/** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var ie;function _e(){if(ie)return U;ie=1;var r=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function t(i,n,a){var o=null;if(a!==void 0&&(o=""+a),n.key!==void 0&&(o=""+n.key),"key"in n){a={};for(var u in n)u!=="key"&&(a[u]=n[u])}else a=n;return n=a.ref,{$$typeof:r,type:i,key:o,ref:n!==void 0?n:null,props:a}}return U.Fragment=s,U.jsx=t,U.jsxs=t,U}var Y={};/** * @license React * react-jsx-runtime.development.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var de;function Ce(){return de||(de=1,process.env.NODE_ENV!=="production"&&function(){function r(l){if(l==null)return null;if(typeof l=="function")return l.$$typeof===q?null:l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case v:return"Fragment";case p:return"Profiler";case y:return"StrictMode";case j:return"Suspense";case C:return"SuspenseList";case $: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 m:return"Portal";case _:return(l.displayName||"Context")+".Provider";case A:return(l._context.displayName||"Context")+".Consumer";case k:var w=l.render;return l=l.displayName,l||(l=w.displayName||w.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case L:return w=l.displayName||null,w!==null?w:r(l.type)||"Memo";case E:w=l._payload,l=l._init;try{return r(l(w))}catch{}}return null}function s(l){return""+l}function t(l){try{s(l);var w=!1}catch{w=!0}if(w){w=console;var M=w.error,S=typeof Symbol=="function"&&Symbol.toStringTag&&l[Symbol.toStringTag]||l.constructor.name||"Object";return M.call(w,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",S),s(l)}}function i(l){if(l===v)return"<>";if(typeof l=="object"&&l!==null&&l.$$typeof===E)return"<...>";try{var w=r(l);return w?"<"+w+">":"<...>"}catch{return"<...>"}}function n(){var l=D.A;return l===null?null:l.getOwner()}function a(){return Error("react-stack-top-frame")}function o(l){if(G.call(l,"key")){var w=Object.getOwnPropertyDescriptor(l,"key").get;if(w&&w.isReactWarning)return!1}return l.key!==void 0}function u(l,w){function M(){P||(P=!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)",w))}M.isReactWarning=!0,Object.defineProperty(l,"key",{get:M,configurable:!0})}function g(){var l=r(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 h(l,w,M,S,W,z,X,Z){return M=z.ref,l={$$typeof:f,type:l,key:w,props:z,_owner:W},(M!==void 0?M:null)!==null?Object.defineProperty(l,"ref",{enumerable:!1,get:g}):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:X}),Object.defineProperty(l,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Z}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l}function d(l,w,M,S,W,z,X,Z){var T=w.children;if(T!==void 0)if(S)if(Q(T)){for(S=0;S<T.length;S++)x(T[S]);Object.freeze&&Object.freeze(T)}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 x(T);if(G.call(w,"key")){T=r(l);var F=Object.keys(w).filter(function(we){return we!=="key"});S=0<F.length?"{key: someKey, "+F.join(": ..., ")+": ...}":"{key: someKey}",oe[T+S]||(F=0<F.length?"{"+F.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX: let props = %s; <%s {...props} /> React keys must be passed directly to JSX without using spread: let props = %s; <%s key={someKey} {...props} />`,S,T,F,T),oe[T+S]=!0)}if(T=null,M!==void 0&&(t(M),T=""+M),o(w)&&(t(w.key),T=""+w.key),"key"in w){M={};for(var ee in w)ee!=="key"&&(M[ee]=w[ee])}else M=w;return T&&u(M,typeof l=="function"?l.displayName||l.name||"Unknown":l),h(l,T,z,W,n(),M,X,Z)}function x(l){typeof l=="object"&&l!==null&&l.$$typeof===f&&l._store&&(l._store.validated=1)}var c=b,f=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),_=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),$=Symbol.for("react.activity"),q=Symbol.for("react.client.reference"),D=c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=Object.prototype.hasOwnProperty,Q=Array.isArray,R=console.createTask?console.createTask:function(){return null};c={"react-stack-bottom-frame":function(l){return l()}};var P,B={},I=c["react-stack-bottom-frame"].bind(c,a)(),J=R(i(a)),oe={};Y.Fragment=v,Y.jsx=function(l,w,M,S,W){var z=1e4>D.recentlyCreatedOwnerStacks++;return d(l,w,M,!1,S,W,z?Error("react-stack-top-frame"):I,z?R(i(l)):J)},Y.jsxs=function(l,w,M,S,W){var z=1e4>D.recentlyCreatedOwnerStacks++;return d(l,w,M,!0,S,W,z?Error("react-stack-top-frame"):I,z?R(i(l)):J)}}()),Y}var ce;function Me(){return ce||(ce=1,process.env.NODE_ENV==="production"?K.exports=_e():K.exports=Ce()),K.exports}var e=Me(),re={exports:{}};/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */var ue;function Ae(){return ue||(ue=1,function(r){(function(){var s={}.hasOwnProperty;function t(){for(var a="",o=0;o<arguments.length;o++){var u=arguments[o];u&&(a=n(a,i(u)))}return a}function i(a){if(typeof a=="string"||typeof a=="number")return a;if(typeof a!="object")return"";if(Array.isArray(a))return t.apply(null,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var o="";for(var u in a)s.call(a,u)&&a[u]&&(o=n(o,u));return o}function n(a,o){return o?a?a+" "+o:a+o:a}r.exports?(t.default=t,r.exports=t):window.classNames=t})()}(re)),re.exports}var Le=Ae();const N=Ne(Le),Se="https://api.useadmesh.com/track";let te={apiBaseUrl:Se,enabled:!0,debug:!1,retryAttempts:3,retryDelay:1e3};const Te=r=>{te={...te,...r}},xe=r=>{const[s,t]=b.useState(!1),[i,n]=b.useState(null),a=b.useMemo(()=>({...te,...r}),[r]),o=b.useCallback((x,c)=>{a.debug&&console.log(`[AdMesh Tracker] ${x}`,c)},[a.debug]),u=b.useCallback(async(x,c)=>{if(!a.enabled){o("Tracking disabled, skipping event",{eventType:x,data:c});return}if(!c.adId||!c.admeshLink){const y="Missing required tracking data: adId and admeshLink are required";o(y,c),n(y);return}t(!0),n(null);const f={event_type:x,ad_id:c.adId,admesh_link:c.admeshLink,product_id:c.productId,user_id:c.userId,session_id:c.sessionId,revenue:c.revenue,conversion_type:c.conversionType,metadata:c.metadata,timestamp:new Date().toISOString(),user_agent:navigator.userAgent,referrer:document.referrer,page_url:window.location.href};o(`Sending ${x} event`,f);let m=null;for(let y=1;y<=(a.retryAttempts||3);y++)try{const p=await fetch(`${a.apiBaseUrl}/events`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!p.ok)throw new Error(`HTTP ${p.status}: ${p.statusText}`);const A=await p.json();o(`${x} event tracked successfully`,A),t(!1);return}catch(p){m=p,o(`Attempt ${y} failed for ${x} event`,p),y<(a.retryAttempts||3)&&await new Promise(A=>setTimeout(A,(a.retryDelay||1e3)*y))}const v=`Failed to track ${x} event after ${a.retryAttempts} attempts: ${m==null?void 0:m.message}`;o(v,m),n(v),t(!1)},[a,o]),g=b.useCallback(async x=>u("click",x),[u]),h=b.useCallback(async x=>u("view",x),[u]),d=b.useCallback(async x=>(!x.revenue&&!x.conversionType&&o("Warning: Conversion tracking without revenue or conversion type",x),u("conversion",x)),[u,o]);return{trackClick:g,trackView:h,trackConversion:d,isTracking:s,error:i}},Ee=(r,s,t)=>{try{const i=new URL(r);return i.searchParams.set("ad_id",s),i.searchParams.set("utm_source","admesh"),i.searchParams.set("utm_medium","recommendation"),t&&Object.entries(t).forEach(([n,a])=>{i.searchParams.set(n,a)}),i.toString()}catch(i){return console.warn("[AdMesh] Invalid URL provided to buildAdMeshLink:",r,i),r}},Re=(r,s)=>({adId:r.ad_id,admeshLink:r.admesh_link,productId:r.product_id,...s}),V=({adId:r,admeshLink:s,productId:t,children:i,onClick:n,trackingData:a,className:o})=>{const{trackClick:u,trackView:g}=xe(),h=b.useRef(null),d=b.useRef(!1);b.useEffect(()=>{if(!h.current||d.current)return;const c=new IntersectionObserver(f=>{f.forEach(m=>{m.isIntersecting&&!d.current&&(d.current=!0,g({adId:r,admeshLink:s,productId:t,...a}).catch(console.error))})},{threshold:.5,rootMargin:"0px"});return c.observe(h.current),()=>{c.disconnect()}},[r,s,t,a,g]);const x=b.useCallback(async c=>{try{await u({adId:r,admeshLink:s,productId:t,...a})}catch(v){console.error("Failed to track click:",v)}n&&n(),c.target.closest("a")||window.open(s,"_blank","noopener,noreferrer")},[r,s,t,a,u,n]);return e.jsx("div",{ref:h,className:o,onClick:x,style:{cursor:"pointer"},children:i})};V.displayName="AdMeshLinkTracker";const H=({recommendation:r,theme:s,showMatchScore:t=!0,showBadges:i=!0,onClick:n,className:a})=>{const o=b.useMemo(()=>{var f;const d=[];r.intent_match_score>=.8&&d.push("Top Match"),r.has_free_tier&&d.push("Free Tier"),r.trial_days&&r.trial_days>0&&d.push("Trial Available");const x=["ai","artificial intelligence","machine learning","ml","automation"];return(((f=r.keywords)==null?void 0:f.some(m=>x.some(v=>m.toLowerCase().includes(v))))||r.title.toLowerCase().includes("ai"))&&d.push("AI Powered"),d},[r]),u=Math.round(r.intent_match_score*100),g=N("admesh-component","admesh-card","relative p-3 rounded-lg bg-white dark:bg-slate-800 border border-gray-200 dark:border-slate-700 shadow-sm hover:shadow transition-shadow cursor-pointer",a),h=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor,"--admesh-primary-hover":s.accentColor+"dd"}:void 0;return e.jsx(V,{adId:r.ad_id,admeshLink:r.admesh_link,productId:r.product_id,onClick:()=>n==null?void 0:n(r.ad_id,r.admesh_link),trackingData:{title:r.title,matchScore:r.intent_match_score},className:g,children:e.jsxs("div",{className:"h-full flex flex-col",style:h,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsx("div",{className:"flex justify-between items-start mb-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[i&&o.includes("Top Match")&&e.jsx("span",{className:"text-xs font-semibold text-white bg-black px-2 py-0.5 rounded-full",children:"Top Match"}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200",children:r.title}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{className:"text-xs px-2 py-1 rounded-full bg-black text-white hover:bg-gray-800 flex items-center",children:["Visit",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("p",{className:"text-sm text-gray-700 dark:text-gray-300 mb-3",children:r.reason}),t&&typeof r.intent_match_score=="number"&&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:"Confidence"}),e.jsxs("span",{children:[u,"%"]})]}),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:`${u}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-2",children:[r.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"})}),r.pricing]}),r.has_free_tier&&e.jsxs("span",{className:"flex items-center px-1.5 py-0.5 bg-gray-100 dark:bg-gray-900/30 text-gray-700 dark:text-gray-400 rounded-full",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 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4M5 12v7a2 2 0 002 2h10a2 2 0 002-2v-7"})}),"Free Tier"]}),r.trial_days&&r.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"})}),r.trial_days,"-day trial"]})]}),r.features&&r.features.length>0&&e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Features:"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.features.map((d,x)=>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"})}),d]},x))})]}),r.integrations&&r.integrations.length>0&&e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"text-xs text-gray-500 dark:text-gray-400 mb-1",children:"Integrates with:"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.integrations.map((d,x)=>e.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-gray-100 dark:bg-gray-900/30 text-gray-700 dark:text-gray-300",children:[e.jsx("svg",{className:"h-3 w-3 mr-0.5 inline",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"})}),d]},x))})]}),r.reviews_summary&&e.jsx("div",{className:"text-xs text-gray-600 dark:text-gray-400 mt-2",children:r.reviews_summary}),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"})})]})})};H.displayName="AdMeshProductCard";const le=({recommendations:r,theme:s,maxProducts:t=3,showMatchScores:i=!0,showFeatures:n=!0,onProductClick:a,className:o})=>{const u=b.useMemo(()=>r.slice(0,t),[r,t]),g=N("admesh-component","admesh-compare-layout",o),h=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return u.length===0?e.jsx("div",{className:g,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:g,style:h,"data-admesh-theme":s==null?void 0:s.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:[u.length," intelligent matches found"]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:u.map((d,x)=>e.jsxs(V,{adId:d.ad_id,admeshLink:d.admesh_link,productId:d.product_id,onClick:()=>a==null?void 0:a(d.ad_id,d.admesh_link),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:[x===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:["#",x+1]})]}),i&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[Math.round(d.intent_match_score*100),"% match"]})]}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 mb-2",children:d.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:"Confidence"}),e.jsxs("span",{children:[Math.round(d.intent_match_score*100),"%"]})]}),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(d.intent_match_score*100)}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-3",children:[d.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"})}),d.pricing]}),d.has_free_tier&&e.jsxs("span",{className:"flex items-center px-1.5 py-0.5 bg-gray-100 dark:bg-gray-900/30 text-gray-700 dark:text-gray-400 rounded-full",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 8v13m0-13V6a2 2 0 112 2h-2zm0 0V5.5A2.5 2.5 0 109.5 8H12zm-7 4h14M5 12a2 2 0 110-4h14a2 2 0 110 4M5 12v7a2 2 0 002 2h10a2 2 0 002-2v-7"})}),"Free Tier"]}),d.trial_days&&d.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"})}),d.trial_days,"-day trial"]})]}),n&&d.features&&d.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:[d.features.slice(0,4).map((c,f)=>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"})}),c]},f)),(d.features.length||0)>4&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:["+",d.features.length-4," more"]})]})]}),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",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"})})]})]},d.product_id||x))}),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"})]})})]})})};le.displayName="AdMeshCompareTable";const Ie={"Top Match":"primary","Free Tier":"success","AI Powered":"secondary",Popular:"warning",New:"primary","Trial Available":"success"},Pe={"Top Match":"★","Free Tier":"◆","AI Powered":"◉",Popular:"▲",New:"●","Trial Available":"◈"},he=({type:r,variant:s,size:t="md",className:i})=>{const n=s||Ie[r]||"secondary",a=Pe[r],o=N("admesh-component","admesh-badge",`admesh-badge--${n}`,`admesh-badge--${t}`,i);return e.jsxs("span",{className:o,children:[a&&e.jsx("span",{className:"admesh-badge__icon",children:a}),e.jsx("span",{className:"admesh-badge__text",children:r})]})};he.displayName="AdMeshBadge";const ze=` /* AdMesh UI SDK Scoped Styles - Smart Recommendations Design */ .admesh-component { --admesh-primary: #6366f1; --admesh-primary-hover: #4f46e5; --admesh-secondary: #8b5cf6; --admesh-accent: #06b6d4; --admesh-background: #ffffff; --admesh-surface: #ffffff; --admesh-border: #e2e8f0; --admesh-text: #0f172a; --admesh-text-muted: #64748b; --admesh-text-light: #94a3b8; --admesh-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); --admesh-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1); --admesh-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); --admesh-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1); --admesh-radius: 0.75rem; --admesh-radius-sm: 0.375rem; --admesh-radius-lg: 1rem; --admesh-radius-xl: 1.5rem; } .admesh-component[data-admesh-theme="dark"] { --admesh-background: #111827; --admesh-surface: #1f2937; --admesh-border: #374151; --admesh-text: #f9fafb; --admesh-text-muted: #9ca3af; } /* Layout Styles */ .admesh-layout { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--admesh-text); background-color: var(--admesh-background); border-radius: var(--admesh-radius); padding: 1.5rem; box-shadow: var(--admesh-shadow); border: 1px solid var(--admesh-border); } .admesh-layout__header { margin-bottom: 1.5rem; text-align: center; } .admesh-layout__title { font-size: 1.25rem; font-weight: 600; color: var(--admesh-text); margin-bottom: 0.5rem; } .admesh-layout__subtitle { font-size: 0.875rem; color: var(--admesh-text-muted); } .admesh-layout__cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; } .admesh-layout__more-indicator { text-align: center; padding: 1rem; color: var(--admesh-text-muted); font-size: 0.875rem; } .admesh-layout__empty { text-align: center; padding: 3rem 1rem; } .admesh-layout__empty-content h3 { font-size: 1.125rem; font-weight: 600; color: var(--admesh-text-muted); margin-bottom: 0.5rem; } .admesh-layout__empty-content p { font-size: 0.875rem; color: var(--admesh-text-muted); } /* Product Card Styles */ .admesh-product-card { background-color: var(--admesh-surface); border: 1px solid var(--admesh-border); border-radius: var(--admesh-radius); padding: 1.5rem; transition: all 0.2s ease-in-out; position: relative; overflow: hidden; } .admesh-product-card:hover { box-shadow: var(--admesh-shadow-lg); transform: translateY(-2px); border-color: var(--admesh-primary); } .admesh-product-card__header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; } .admesh-product-card__title { font-size: 1.125rem; font-weight: 600; color: var(--admesh-text); margin-bottom: 0.5rem; line-height: 1.4; } .admesh-product-card__reason { font-size: 0.875rem; color: var(--admesh-text-muted); line-height: 1.5; margin-bottom: 1rem; } .admesh-product-card__match-score { margin-bottom: 1rem; } .admesh-product-card__match-score-label { display: flex; justify-content: space-between; align-items: center; font-size: 0.75rem; color: var(--admesh-text-muted); margin-bottom: 0.25rem; } .admesh-product-card__match-score-bar { width: 100%; height: 0.375rem; background-color: var(--admesh-border); border-radius: var(--admesh-radius-sm); overflow: hidden; } .admesh-product-card__match-score-fill { height: 100%; background: linear-gradient(90deg, var(--admesh-primary), #8b5cf6); border-radius: var(--admesh-radius-sm); transition: width 0.3s ease-in-out; } .admesh-product-card__badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; } .admesh-product-card__badge { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.25rem 0.5rem; background-color: var(--admesh-primary); color: white; font-size: 0.75rem; font-weight: 500; border-radius: var(--admesh-radius-sm); } .admesh-product-card__badge--secondary { background-color: var(--admesh-secondary); } .admesh-product-card__keywords { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 1rem; } .admesh-product-card__keyword { padding: 0.125rem 0.375rem; background-color: var(--admesh-border); color: var(--admesh-text-muted); font-size: 0.75rem; border-radius: var(--admesh-radius-sm); } .admesh-product-card__footer { display: flex; justify-content: flex-end; margin-top: 1.5rem; } .admesh-product-card__button { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.75rem 1.5rem; background: linear-gradient(90deg, var(--admesh-primary), var(--admesh-primary-hover)); color: white; font-size: 0.875rem; font-weight: 500; border: none; border-radius: var(--admesh-radius); cursor: pointer; transition: all 0.2s ease-in-out; text-decoration: none; } .admesh-product-card__button:hover { transform: translateY(-1px); box-shadow: var(--admesh-shadow-lg); } /* Utility Classes */ .admesh-text-xs { font-size: 0.75rem; } .admesh-text-sm { font-size: 0.875rem; } .admesh-text-base { font-size: 1rem; } .admesh-text-lg { font-size: 1.125rem; } .admesh-text-xl { font-size: 1.25rem; } .admesh-font-medium { font-weight: 500; } .admesh-font-semibold { font-weight: 600; } .admesh-font-bold { font-weight: 700; } .admesh-text-muted { color: var(--admesh-text-muted); } /* Responsive Design */ @media (max-width: 768px) { .admesh-layout { padding: 1rem; } .admesh-layout__cards-grid { grid-template-columns: 1fr; gap: 0.75rem; } .admesh-product-card { padding: 1rem; } } `;let se=!1;const me=()=>{b.useEffect(()=>{if(se)return;const r=document.createElement("style");return r.id="admesh-ui-sdk-styles",r.textContent=ze,document.getElementById("admesh-ui-sdk-styles")||(document.head.appendChild(r),se=!0),()=>{const s=document.getElementById("admesh-ui-sdk-styles");s&&document.head.contains(s)&&(document.head.removeChild(s),se=!1)}},[])},Oe=(r,s,t)=>{if(!t&&s)switch(s){case"compare_products":return"compare";case"best_for_use_case":case"trial_demo":case"budget_conscious":return"cards";default:return"cards"}const i=r.length;if(i>=2&&i<=4){const n=r.some(o=>o.features&&o.features.length>0),a=r.some(o=>o.pricing);if(n||a)return"compare"}return"cards"},ge=({recommendations:r,intentType:s,theme:t,maxDisplayed:i=6,showMatchScores:n=!0,showFeatures:a=!0,autoLayout:o=!0,onProductClick:u,onTrackView:g,className:h})=>{me();const d=b.useMemo(()=>r.slice(0,i),[r,i]),x=b.useMemo(()=>Oe(d,s,o),[d,s,o]),c=N("admesh-component",h),f=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return d.length===0?e.jsx("div",{className:c,children:e.jsx("div",{className:"admesh-layout__empty",children:e.jsxs("div",{className:"admesh-layout__empty-content",children:[e.jsx("div",{className:"flex items-center justify-center mb-3",children:e.jsx("svg",{className:"w-8 h-8 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("h3",{className:"admesh-text-lg admesh-font-semibold admesh-text-muted",children:"No smart recommendations found"}),e.jsx("p",{className:"admesh-text-sm admesh-text-muted",children:"Try refining your search or check back later for new matches."})]})})}):e.jsx("div",{className:c,style:f,"data-admesh-theme":t==null?void 0:t.mode,children:x==="compare"?e.jsx(le,{recommendations:d,theme:t,maxProducts:Math.min(d.length,4),showMatchScores:n,showFeatures:a,onProductClick:u}):e.jsx("div",{className:"space-y-4",children:d.map((m,v)=>e.jsx(H,{recommendation:m,theme:t,showMatchScore:n,showBadges:!0,maxKeywords:3,onClick:u,onTrackView:g},m.product_id||m.ad_id||v))})})};ge.displayName="AdMeshLayout";const O=({recommendation:r,theme:s,compact:t=!1,showReason:i=!0,onClick:n,className:a})=>{const o=Math.round(r.intent_match_score*100),u=N("admesh-inline-recommendation","group cursor-pointer transition-all duration-200",{"p-2 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":!t,"p-1.5 rounded hover:bg-gray-50 dark:hover:bg-slate-800/30":t},a),g=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsx(V,{adId:r.ad_id,admeshLink:r.admesh_link,productId:r.product_id,onClick:()=>n==null?void 0:n(r.ad_id,r.admesh_link),trackingData:{title:r.title,matchScore:r.intent_match_score},className:u,children:e.jsxs("div",{className:"flex items-start gap-3",style:g,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsx("div",{className:"flex-shrink-0 mt-0.5",children:r.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-center gap-2 mb-1",children:[e.jsx("h4",{className:N("font-medium truncate transition-colors duration-200","text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-300","cursor-pointer hover:underline",t?"text-sm":"text-base"),children:r.title}),r.intent_match_score>=.7&&e.jsxs("span",{className:N("inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-medium",r.intent_match_score>=.8?"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400":"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-400"),children:[o,"% match"]})]}),i&&r.reason&&e.jsx("p",{className:N("text-gray-600 dark:text-gray-400 line-clamp-2",t?"text-xs":"text-sm"),children:r.reason}),!t&&r.keywords&&r.keywords.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[r.keywords.slice(0,3).map((h,d)=>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:h},d)),r.keywords.length>3&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:["+",r.keywords.length-3," more"]})]}),!t&&(r.has_free_tier||r.trial_days)&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[r.has_free_tier&&e.jsx("span",{className:"inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400",children:"Free tier"}),r.trial_days&&r.trial_days>0&&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:[r.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"})})})]})})},fe=({recommendations:r,conversationSummary:s,theme:t,showTopRecommendations:i=3,onRecommendationClick:n,onStartNewConversation:a,className:o})=>{const u=r.sort((d,x)=>x.intent_match_score-d.intent_match_score).slice(0,i),g=N("admesh-conversation-summary","bg-gradient-to-br from-slate-50 to-blue-50 dark:from-slate-900 dark:to-slate-800","rounded-lg border border-gray-200 dark:border-slate-700 p-6",o),h=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return e.jsxs("div",{className:g,style:h,"data-admesh-theme":t==null?void 0:t.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-10 h-10 bg-gradient-to-br from-blue-500 to-indigo-600 rounded-full flex items-center justify-center",children:e.jsx("svg",{className:"w-5 h-5 text-white",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",{children:[e.jsx("h3",{className:"text-lg font-semibold text-gray-900 dark:text-gray-100",children:"Conversation Summary"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Here's what we discussed and found for you"})]})]}),e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"bg-white dark:bg-slate-800 rounded-lg p-4 border border-gray-100 dark:border-slate-700",children:e.jsx("p",{className:"text-gray-700 dark:text-gray-300 leading-relaxed",children:s})})}),u.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-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("h4",{className:"font-medium text-gray-900 dark:text-gray-100",children:"Top Recommendations"})]}),e.jsx("div",{className:"space-y-2",children:u.map((d,x)=>e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute -left-2 top-2 z-10",children:e.jsx("div",{className:N("w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold text-white",x===0?"bg-yellow-500":x===1?"bg-gray-400":"bg-orange-400"),children:x+1})}),e.jsx("div",{className:"ml-4",children:e.jsx(O,{recommendation:d,theme:t,compact:!1,showReason:!0,onClick:n})})]},d.ad_id||x))})]}),r.length>i&&e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 rounded-lg p-3 border border-blue-200 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-center gap-2",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 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-blue-800 dark:text-blue-300",children:[r.length-i," additional recommendation",r.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-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 text-white 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:()=>{u.length>0&&(n==null||n(u[0].ad_id,u[0].admesh_link))},className:"flex-1 bg-white dark:bg-slate-800 hover:bg-gray-50 dark:hover:bg-slate-700 text-gray-700 dark:text-gray-300 font-medium py-2.5 px-4 rounded-lg border border-gray-300 dark:border-slate-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-slate-700",children:e.jsx("span",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Powered by AdMesh"})})]})},ae=({recommendation:r,citationNumber:s,citationStyle:t="numbered",theme:i,showTooltip:n=!0,onClick:a,onHover:o,className:u})=>{const[g,h]=b.useState(!1),d=()=>{h(!0),o==null||o(r)},x=()=>{h(!1)},c=()=>{a==null||a(r.ad_id,r.admesh_link)},f=()=>{switch(t){case"bracketed":return`[${s}]`;case"superscript":return s.toString();case"numbered":default:return s.toString()}},m=N("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":t==="numbered","px-1 text-sm hover:underline":t==="bracketed","text-xs align-super hover:underline":t==="superscript"},u),v=i!=null&&i.accentColor?{"--admesh-primary":i.accentColor}:void 0;return e.jsxs("span",{className:"relative inline-block",children:[e.jsx(V,{adId:r.ad_id,admeshLink:r.admesh_link,productId:r.product_id,onClick:c,trackingData:{title:r.title,matchScore:r.intent_match_score,citationNumber:s,citationStyle:t},className:m,children:e.jsx("span",{style:v,"data-admesh-theme":i==null?void 0:i.mode,onMouseEnter:d,onMouseLeave:x,children:f()})}),n&&g&&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:r.title}),r.reason&&e.jsx("div",{className:"text-gray-300 dark:text-gray-600 text-xs",children:r.reason.length>100?`${r.reason.substring(0,100)}...`:r.reason}),r.intent_match_score>=.7&&e.jsxs("div",{className:"text-green-400 dark:text-green-600 text-xs mt-1",children:[Math.round(r.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"})]})})]})},be=({recommendations:r,conversationText:s,theme:t,showCitationList:i=!0,citationStyle:n="numbered",onRecommendationClick:a,onCitationHover:o,className:u})=>{const[g,h]=b.useState(null),d=b.useMemo(()=>{if(!s||r.length===0)return{text:s,citationMap:new Map};let m=s;const v=new Map;return[...r].sort((p,A)=>A.intent_match_score-p.intent_match_score).forEach((p,A)=>{const _=A+1,k=p.title;v.set(_,p);const j=new RegExp(`\\b${k.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if(j.test(m))m=m.replace(j,C=>`${C}{{CITATION_${_}}}`);else{const C=p.keywords||[];let L=!1;for(const E of C){const $=new RegExp(`\\b${E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if($.test(m)&&!L){m=m.replace($,q=>(L=!0,`${q}{{CITATION_${_}}}`));break}}L||(m+=`{{CITATION_${_}}}`)}}),{text:m,citationMap:v}},[s,r]),x=()=>{const{text:m,citationMap:v}=d;return m.split(/(\{\{CITATION_\d+\}\})/).map((p,A)=>{const _=p.match(/\{\{CITATION_(\d+)\}\}/);if(_){const k=parseInt(_[1]),j=v.get(k);if(j)return e.jsx(ae,{recommendation:j,citationNumber:k,citationStyle:n,theme:t,showTooltip:!0,onClick:a,onHover:C=>{h(C),o==null||o(C)}},`citation-${k}`)}return e.jsx("span",{children:p},A)})},c=N("admesh-citation-unit","space-y-4",u),f=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return e.jsxs("div",{className:c,style:f,"data-admesh-theme":t==null?void 0:t.mode,children:[e.jsx("div",{className:"admesh-citation-text text-gray-800 dark:text-gray-200 leading-relaxed",children:x()}),i&&r.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:r.sort((m,v)=>v.intent_match_score-m.intent_match_score).map((m,v)=>e.jsxs("div",{className:N("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":(g==null?void 0:g.ad_id)===m.ad_id,"hover:bg-gray-50 dark:hover:bg-slate-800/50":(g==null?void 0:g.ad_id)!==m.ad_id}),children:[e.jsx("div",{className:"flex-shrink-0 mt-1",children:e.jsx(ae,{recommendation:m,citationNumber:v+1,citationStyle:n,theme:t,showTooltip:!1,onClick:a})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(O,{recommendation:m,theme:t,compact:!0,showReason:!1,onClick:a})})]},m.ad_id||v))})]})})]})},ne=({recommendations:r,config:s,theme:t,conversationSummary:i,sessionId:n,onRecommendationClick:a,onDismiss:o,className:u})=>{const[g,h]=b.useState(s.autoShow!==!1),[d,x]=b.useState(!1);if(b.useEffect(()=>{if(s.delayMs&&s.delayMs>0){const _=setTimeout(()=>{h(!0),x(!0)},s.delayMs);return()=>clearTimeout(_)}else x(!0)},[s.delayMs]),!g||r.length===0)return null;const c=s.maxRecommendations||3,f=r.slice(0,c),m=(_,k)=>{a==null||a(_,k)},v=()=>{h(!1),o==null||o()},y=()=>{switch(s.displayMode){case"summary":return i?e.jsx(fe,{recommendations:f,conversationSummary:i,theme:t,showTopRecommendations:c,onRecommendationClick:m,onStartNewConversation:o}):null;case"inline":return e.jsx("div",{className:"space-y-2",children:f.map((_,k)=>e.jsx(O,{recommendation:_,theme:t,compact:!0,showReason:!0,onClick:m},_.ad_id||k))});case"minimal":return f.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:[f.length," intelligent match",f.length>1?"es":""," found"]})]}),e.jsx(O,{recommendation:f[0],theme:t,compact:!0,showReason:!1,onClick:m}),f.length>1&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["+",f.length-1," more recommendation",f.length>2?"s":""]})]}):null;case"citation":return i?e.jsx(be,{recommendations:f,conversationText:i,theme:t,showCitationList:!0,citationStyle:"numbered",onRecommendationClick:m}):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"})]}),o&&e.jsx("button",{onClick:v,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:f.map((_,k)=>e.jsx(O,{recommendation:_,theme:t,compact:!0,showReason:!1,onClick:m},_.ad_id||k))})]});default:return e.jsx("div",{className:"space-y-3",children:f.map((_,k)=>e.jsx(H,{recommendation:_,theme:t,showMatchScore:!1,showBadges:!0,onClick:m},_.ad_id||k))})}},p=N("admesh-conversational-unit","transition-all duration-300 ease-in-out",{"opacity-0 translate-y-2":!d,"opacity-100 translate-y-0":d,"fixed bottom-4 right-4 max-w-sm z-50":s.displayMode==="floating","my-3":s.displayMode==="inline","mt-4 pt-4 border-t border-gray-200 dark:border-slate-700":s.displayMode==="summary"},u),A=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return e.jsxs("div",{className:p,style:A,"data-admesh-theme":t==null?void 0:t.mode,"data-admesh-context":s.context,"data-session-id":n,children:[y(),s.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"})})]})},pe=({title:r,theme:s,collapsible:t=!1,isCollapsed:i=!1,onToggle:n,onSearch:a,showSearch:o=!1,className:u})=>{const[g,h]=b.useState(""),[d,x]=b.useState(!1),c=y=>{const p=y.target.value;h(p),a==null||a(p)},f=()=>{h(""),a==null||a("")},m=N("admesh-sidebar-header","flex flex-col p-4 border-b border-gray-200 dark:border-slate-700 bg-gray-50 dark:bg-slate-800",u),v=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:m,style:v,"data-admesh-theme":s==null?void 0:s.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:r}),t&&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",title:i?"Expand sidebar":"Collapse sidebar",children:e.jsx("svg",{className:N("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"})})})]}),o&&!i&&e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:N("relative flex items-center transition-all duration-200",{"ring-2 ring-blue-500 dark:ring-blue-400":d}),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:g,onChange:c,onFocus:()=>x(!0),onBlur:()=>x(!1),placeholder:"Search recommendations...",className:N("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")}),g&&e.jsx("button",{onClick:f,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"})})})]}),g&&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",{cl