admesh-ui-sdk 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AdMeshSidebar.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +558 -554
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdMeshSidebar.d.ts","sourceRoot":"","sources":["../../src/components/AdMeshSidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,gBAAgB,CAAC;AAIzE,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,
|
|
1
|
+
{"version":3,"file":"AdMeshSidebar.d.ts","sourceRoot":"","sources":["../../src/components/AdMeshSidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAuC,MAAM,OAAO,CAAC;AAE5D,OAAO,KAAK,EAAE,kBAAkB,EAAkB,MAAM,gBAAgB,CAAC;AAIzE,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA0MtD,CAAC"}
|
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 f=require("react");function Ne(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var K={exports:{}},U={};/**
|
|
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 de;function _e(){if(de)return U;de=1;var r=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function t(
|
|
9
|
+
*/var de;function _e(){if(de)return U;de=1;var r=Symbol.for("react.transitional.element"),s=Symbol.for("react.fragment");function t(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 u in n)u!=="key"&&(a[u]=n[u])}else a=n;return n=a.ref,{$$typeof:r,type:i,key:d,ref:n!==void 0?n:null,props:a}}return U.Fragment=s,U.jsx=t,U.jsxs=t,U}var Y={};/**
|
|
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 ie;function Ce(){return ie||(ie=1,process.env.NODE_ENV!=="production"&&function(){function r(
|
|
17
|
+
*/var ie;function Ce(){return ie||(ie=1,process.env.NODE_ENV!=="production"&&function(){function r(o){if(o==null)return null;if(typeof o=="function")return o.$$typeof===q?null:o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case k:return"Fragment";case p:return"Profiler";case y:return"StrictMode";case v:return"Suspense";case w:return"SuspenseList";case I:return"Activity"}if(typeof o=="object")switch(typeof o.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),o.$$typeof){case x:return"Portal";case _:return(o.displayName||"Context")+".Provider";case A:return(o._context.displayName||"Context")+".Consumer";case C:var j=o.render;return o=o.displayName,o||(o=j.displayName||j.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case L:return j=o.displayName||null,j!==null?j:r(o.type)||"Memo";case R:j=o._payload,o=o._init;try{return r(o(j))}catch{}}return null}function s(o){return""+o}function t(o){try{s(o);var j=!1}catch{j=!0}if(j){j=console;var M=j.error,S=typeof Symbol=="function"&&Symbol.toStringTag&&o[Symbol.toStringTag]||o.constructor.name||"Object";return M.call(j,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",S),s(o)}}function i(o){if(o===k)return"<>";if(typeof o=="object"&&o!==null&&o.$$typeof===R)return"<...>";try{var j=r(o);return j?"<"+j+">":"<...>"}catch{return"<...>"}}function n(){var o=D.A;return o===null?null:o.getOwner()}function a(){return Error("react-stack-top-frame")}function d(o){if(G.call(o,"key")){var j=Object.getOwnPropertyDescriptor(o,"key").get;if(j&&j.isReactWarning)return!1}return o.key!==void 0}function u(o,j){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)",j))}M.isReactWarning=!0,Object.defineProperty(o,"key",{get:M,configurable:!0})}function g(){var o=r(this.type);return W[o]||(W[o]=!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.")),o=this.props.ref,o!==void 0?o:null}function m(o,j,M,S,$,O,X,Z){return M=O.ref,o={$$typeof:b,type:o,key:j,props:O,_owner:$},(M!==void 0?M:null)!==null?Object.defineProperty(o,"ref",{enumerable:!1,get:g}):Object.defineProperty(o,"ref",{enumerable:!1,value:null}),o._store={},Object.defineProperty(o._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(o,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(o,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.defineProperty(o,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Z}),Object.freeze&&(Object.freeze(o.props),Object.freeze(o)),o}function l(o,j,M,S,$,O,X,Z){var T=j.children;if(T!==void 0)if(S)if(Q(T)){for(S=0;S<T.length;S++)h(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 h(T);if(G.call(j,"key")){T=r(o);var V=Object.keys(j).filter(function(we){return we!=="key"});S=0<V.length?"{key: someKey, "+V.join(": ..., ")+": ...}":"{key: someKey}",oe[T+S]||(V=0<V.length?"{"+V.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,S,T,V,T),oe[T+S]=!0)}if(T=null,M!==void 0&&(t(M),T=""+M),
|
|
22
|
+
<%s key={someKey} {...props} />`,S,T,V,T),oe[T+S]=!0)}if(T=null,M!==void 0&&(t(M),T=""+M),d(j)&&(t(j.key),T=""+j.key),"key"in j){M={};for(var ee in j)ee!=="key"&&(M[ee]=j[ee])}else M=j;return T&&u(M,typeof o=="function"?o.displayName||o.name||"Unknown":o),m(o,T,O,$,n(),M,X,Z)}function h(o){typeof o=="object"&&o!==null&&o.$$typeof===b&&o._store&&(o._store.validated=1)}var c=f,b=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),p=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),_=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),w=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),R=Symbol.for("react.lazy"),I=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,E=console.createTask?console.createTask:function(){return null};c={"react-stack-bottom-frame":function(o){return o()}};var P,W={},z=c["react-stack-bottom-frame"].bind(c,a)(),J=E(i(a)),oe={};Y.Fragment=k,Y.jsx=function(o,j,M,S,$){var O=1e4>D.recentlyCreatedOwnerStacks++;return l(o,j,M,!1,S,$,O?Error("react-stack-top-frame"):z,O?E(i(o)):J)},Y.jsxs=function(o,j,M,S,$){var O=1e4>D.recentlyCreatedOwnerStacks++;return l(o,j,M,!0,S,$,O?Error("react-stack-top-frame"):z,O?E(i(o)):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:{}};/*!
|
|
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 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=l(a,d(u)))}return a}function d(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=l(o,u));return o}function l(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}},he=r=>{const[s,t]=b.useState(!1),[d,l]=b.useState(null),a=b.useMemo(()=>({...te,...r}),[r]),o=b.useCallback((h,c)=>{a.debug&&console.log(`[AdMesh Tracker] ${h}`,c)},[a.debug]),u=b.useCallback(async(h,c)=>{if(!a.enabled){o("Tracking disabled, skipping event",{eventType:h,data:c});return}if(!c.adId||!c.admeshLink){const y="Missing required tracking data: adId and admeshLink are required";o(y,c),l(y);return}t(!0),l(null);const f={event_type:h,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 ${h} 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(`${h} event tracked successfully`,A),t(!1);return}catch(p){m=p,o(`Attempt ${y} failed for ${h} event`,p),y<(a.retryAttempts||3)&&await new Promise(A=>setTimeout(A,(a.retryDelay||1e3)*y))}const v=`Failed to track ${h} event after ${a.retryAttempts} attempts: ${m==null?void 0:m.message}`;o(v,m),l(v),t(!1)},[a,o]),g=b.useCallback(async h=>u("click",h),[u]),x=b.useCallback(async h=>u("view",h),[u]),i=b.useCallback(async h=>(!h.revenue&&!h.conversionType&&o("Warning: Conversion tracking without revenue or conversion type",h),u("conversion",h)),[u,o]);return{trackClick:g,trackView:x,trackConversion:i,isTracking:s,error:d}},Re=(r,s,t)=>{try{const d=new URL(r);return d.searchParams.set("ad_id",s),d.searchParams.set("utm_source","admesh"),d.searchParams.set("utm_medium","recommendation"),t&&Object.entries(t).forEach(([l,a])=>{d.searchParams.set(l,a)}),d.toString()}catch(d){return console.warn("[AdMesh] Invalid URL provided to buildAdMeshLink:",r,d),r}},Ee=(r,s)=>({adId:r.ad_id,admeshLink:r.admesh_link,productId:r.product_id,...s}),$=({adId:r,admeshLink:s,productId:t,children:d,onClick:l,trackingData:a,className:o})=>{const{trackClick:u,trackView:g}=he(),x=b.useRef(null),i=b.useRef(!1);b.useEffect(()=>{if(!x.current||i.current)return;const c=new IntersectionObserver(f=>{f.forEach(m=>{m.isIntersecting&&!i.current&&(i.current=!0,g({adId:r,admeshLink:s,productId:t,...a}).catch(console.error))})},{threshold:.5,rootMargin:"0px"});return c.observe(x.current),()=>{c.disconnect()}},[r,s,t,a,g]);const h=b.useCallback(async c=>{try{await u({adId:r,admeshLink:s,productId:t,...a})}catch(v){console.error("Failed to track click:",v)}l&&l(),c.target.closest("a")||window.open(s,"_blank","noopener,noreferrer")},[r,s,t,a,u,l]);return e.jsx("div",{ref:x,className:o,onClick:h,style:{cursor:"pointer"},children:d})};$.displayName="AdMeshLinkTracker";const H=({recommendation:r,theme:s,showMatchScore:t=!0,showBadges:d=!0,onClick:l,className:a})=>{const o=b.useMemo(()=>{var f;const i=[];r.intent_match_score>=.8&&i.push("Top Match"),r.has_free_tier&&i.push("Free Tier"),r.trial_days&&r.trial_days>0&&i.push("Trial Available");const h=["ai","artificial intelligence","machine learning","ml","automation"];return(((f=r.keywords)==null?void 0:f.some(m=>h.some(v=>m.toLowerCase().includes(v))))||r.title.toLowerCase().includes("ai"))&&i.push("AI Powered"),i},[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),x=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor,"--admesh-primary-hover":s.accentColor+"dd"}:void 0;return e.jsx($,{adId:r.ad_id,admeshLink:r.admesh_link,productId:r.product_id,onClick:()=>l==null?void 0:l(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:x,"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:[d&&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((i,h)=>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"})}),i]},h))})]}),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((i,h)=>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"})}),i]},h))})]}),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:d=!0,showFeatures:l=!0,onProductClick:a,className:o})=>{const u=b.useMemo(()=>r.slice(0,t),[r,t]),g=N("admesh-component","admesh-compare-layout",o),x=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:x,"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((i,h)=>e.jsxs($,{adId:i.ad_id,admeshLink:i.admesh_link,productId:i.product_id,onClick:()=>a==null?void 0:a(i.ad_id,i.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:[h===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:["#",h+1]})]}),d&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[Math.round(i.intent_match_score*100),"% match"]})]}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 mb-2",children:i.title}),d&&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(i.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(i.intent_match_score*100)}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-3",children:[i.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"})}),i.pricing]}),i.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"]}),i.trial_days&&i.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"})}),i.trial_days,"-day trial"]})]}),l&&i.features&&i.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:[i.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)),(i.features.length||0)>4&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:["+",i.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"})})]})]},i.product_id||h))}),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"},ze={"Top Match":"★","Free Tier":"◆","AI Powered":"◉",Popular:"▲",New:"●","Trial Available":"◈"},xe=({type:r,variant:s,size:t="md",className:d})=>{const l=s||Ie[r]||"secondary",a=ze[r],o=N("admesh-component","admesh-badge",`admesh-badge--${l}`,`admesh-badge--${t}`,d);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})]})};xe.displayName="AdMeshBadge";const Pe=`
|
|
26
|
+
*/var ue;function Ae(){return ue||(ue=1,function(r){(function(){var s={}.hasOwnProperty;function t(){for(var a="",d=0;d<arguments.length;d++){var u=arguments[d];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 d="";for(var u in a)s.call(a,u)&&a[u]&&(d=n(d,u));return d}function n(a,d){return d?a?a+" "+d:a+d: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}},he=r=>{const[s,t]=f.useState(!1),[i,n]=f.useState(null),a=f.useMemo(()=>({...te,...r}),[r]),d=f.useCallback((h,c)=>{a.debug&&console.log(`[AdMesh Tracker] ${h}`,c)},[a.debug]),u=f.useCallback(async(h,c)=>{if(!a.enabled){d("Tracking disabled, skipping event",{eventType:h,data:c});return}if(!c.adId||!c.admeshLink){const y="Missing required tracking data: adId and admeshLink are required";d(y,c),n(y);return}t(!0),n(null);const b={event_type:h,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};d(`Sending ${h} event`,b);let x=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(b)});if(!p.ok)throw new Error(`HTTP ${p.status}: ${p.statusText}`);const A=await p.json();d(`${h} event tracked successfully`,A),t(!1);return}catch(p){x=p,d(`Attempt ${y} failed for ${h} event`,p),y<(a.retryAttempts||3)&&await new Promise(A=>setTimeout(A,(a.retryDelay||1e3)*y))}const k=`Failed to track ${h} event after ${a.retryAttempts} attempts: ${x==null?void 0:x.message}`;d(k,x),n(k),t(!1)},[a,d]),g=f.useCallback(async h=>u("click",h),[u]),m=f.useCallback(async h=>u("view",h),[u]),l=f.useCallback(async h=>(!h.revenue&&!h.conversionType&&d("Warning: Conversion tracking without revenue or conversion type",h),u("conversion",h)),[u,d]);return{trackClick:g,trackView:m,trackConversion:l,isTracking:s,error:i}},Re=(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}},Ee=(r,s)=>({adId:r.ad_id,admeshLink:r.admesh_link,productId:r.product_id,...s}),F=({adId:r,admeshLink:s,productId:t,children:i,onClick:n,trackingData:a,className:d})=>{const{trackClick:u,trackView:g}=he(),m=f.useRef(null),l=f.useRef(!1);f.useEffect(()=>{if(!m.current||l.current)return;const c=new IntersectionObserver(b=>{b.forEach(x=>{x.isIntersecting&&!l.current&&(l.current=!0,g({adId:r,admeshLink:s,productId:t,...a}).catch(console.error))})},{threshold:.5,rootMargin:"0px"});return c.observe(m.current),()=>{c.disconnect()}},[r,s,t,a,g]);const h=f.useCallback(async c=>{try{await u({adId:r,admeshLink:s,productId:t,...a})}catch(k){console.error("Failed to track click:",k)}n&&n(),c.target.closest("a")||window.open(s,"_blank","noopener,noreferrer")},[r,s,t,a,u,n]);return e.jsx("div",{ref:m,className:d,onClick:h,style:{cursor:"pointer"},children:i})};F.displayName="AdMeshLinkTracker";const H=({recommendation:r,theme:s,showMatchScore:t=!0,showBadges:i=!0,onClick:n,className:a})=>{const d=f.useMemo(()=>{var b;const l=[];r.intent_match_score>=.8&&l.push("Top Match"),r.has_free_tier&&l.push("Free Tier"),r.trial_days&&r.trial_days>0&&l.push("Trial Available");const h=["ai","artificial intelligence","machine learning","ml","automation"];return(((b=r.keywords)==null?void 0:b.some(x=>h.some(k=>x.toLowerCase().includes(k))))||r.title.toLowerCase().includes("ai"))&&l.push("AI Powered"),l},[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),m=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor,"--admesh-primary-hover":s.accentColor+"dd"}:void 0;return e.jsx(F,{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:m,"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&&d.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((l,h)=>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"})}),l]},h))})]}),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((l,h)=>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"})}),l]},h))})]}),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:d})=>{const u=f.useMemo(()=>r.slice(0,t),[r,t]),g=N("admesh-component","admesh-compare-layout",d),m=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:m,"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((l,h)=>e.jsxs(F,{adId:l.ad_id,admeshLink:l.admesh_link,productId:l.product_id,onClick:()=>a==null?void 0:a(l.ad_id,l.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:[h===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:["#",h+1]})]}),i&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[Math.round(l.intent_match_score*100),"% match"]})]}),e.jsx("h4",{className:"font-semibold text-gray-800 dark:text-gray-200 mb-2",children:l.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(l.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(l.intent_match_score*100)}%`}})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs mb-3",children:[l.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"})}),l.pricing]}),l.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"]}),l.trial_days&&l.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"})}),l.trial_days,"-day trial"]})]}),n&&l.features&&l.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:[l.features.slice(0,4).map((c,b)=>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]},b)),(l.features.length||0)>4&&e.jsxs("span",{className:"text-xs text-gray-500 dark:text-gray-400 italic",children:["+",l.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"})})]})]},l.product_id||h))}),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"},ze={"Top Match":"★","Free Tier":"◆","AI Powered":"◉",Popular:"▲",New:"●","Trial Available":"◈"},xe=({type:r,variant:s,size:t="md",className:i})=>{const n=s||Ie[r]||"secondary",a=ze[r],d=N("admesh-component","admesh-badge",`admesh-badge--${n}`,`admesh-badge--${t}`,i);return e.jsxs("span",{className:d,children:[a&&e.jsx("span",{className:"admesh-badge__icon",children:a}),e.jsx("span",{className:"admesh-badge__text",children:r})]})};xe.displayName="AdMeshBadge";const Pe=`
|
|
27
27
|
/* AdMesh UI SDK Scoped Styles - Smart Recommendations Design */
|
|
28
28
|
.admesh-component {
|
|
29
29
|
--admesh-primary: #6366f1;
|
|
@@ -344,5 +344,5 @@ React keys must be passed directly to JSX without using spread:
|
|
|
344
344
|
padding: 0.5rem;
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
`;let se=!1;const me=()=>{b.useEffect(()=>{if(se)return;const r=document.createElement("style");return r.id="admesh-ui-sdk-styles",r.textContent=Pe,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 d=r.length;if(d>=2&&d<=4){const l=r.some(o=>o.features&&o.features.length>0),a=r.some(o=>o.pricing);if(l||a)return"compare"}return"cards"},ge=({recommendations:r,intentType:s,theme:t,maxDisplayed:d=6,showMatchScores:l=!0,showFeatures:a=!0,autoLayout:o=!0,onProductClick:u,onTrackView:g,className:x})=>{me();const i=b.useMemo(()=>r.slice(0,d),[r,d]),h=b.useMemo(()=>Oe(i,s,o),[i,s,o]),c=N("admesh-component",x),f=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return i.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:h==="compare"?e.jsx(le,{recommendations:i,theme:t,maxProducts:Math.min(i.length,4),showMatchScores:l,showFeatures:a,onProductClick:u}):e.jsx("div",{className:"space-y-4",children:i.map((m,v)=>e.jsx(H,{recommendation:m,theme:t,showMatchScore:l,showBadges:!0,maxKeywords:3,onClick:u,onTrackView:g},m.product_id||m.ad_id||v))})})};ge.displayName="AdMeshLayout";const Be=({recommendation:r,theme:s={mode:"light"},className:t="",onClick:d,showPoweredBy:l=!0,variation:a="question"})=>{const o=()=>{d==null||d(r.ad_id,r.admesh_link)},u=r.title,g=()=>{var x,i,h;if(a==="question")return`Looking for ${((i=(x=r.keywords)==null?void 0:x[0])==null?void 0:i.toLowerCase())||"solutions"} for your business? Try ${u}`;{const c=((h=r.reason)==null?void 0:h.split(".")[0])||"offering best solutions for your business";return`${u} is ${c.toLowerCase()}, visit`}};return e.jsx($,{adId:r.ad_id,admeshLink:r.admesh_link,productId:r.product_id,onClick:o,trackingData:{title:r.title,variation:a,component:"simple_ad"},className:`admesh-simple-ad ${t}`,children:e.jsxs("div",{"data-admesh-theme":s.mode,style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${s.mode==="dark"?"#374151":"#e5e7eb"}`,backgroundColor:s.mode==="dark"?"#1f2937":"#ffffff",fontSize:"14px",lineHeight:"1.5",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[e.jsxs("div",{style:{marginBottom:l?"8px":"0"},children:[e.jsx("span",{style:{color:s.mode==="dark"?"#f3f4f6":"#374151",marginRight:"4px"},children:g()}),e.jsx("span",{style:{color:s.accentColor||"#2563eb",textDecoration:"underline",cursor:"pointer",fontSize:"inherit",fontFamily:"inherit"},children:u})]}),l&&e.jsxs("div",{style:{fontSize:"11px",color:s.mode==="dark"?"#9ca3af":"#6b7280",textAlign:"right"},children:["powered by ",e.jsx("strong",{children:"AdMesh"})]})]})})},O=({recommendation:r,theme:s,compact:t=!1,showReason:d=!0,onClick:l,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($,{adId:r.ad_id,admeshLink:r.admesh_link,productId:r.product_id,onClick:()=>l==null?void 0:l(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"]})]}),d&&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((x,i)=>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:x},i)),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:d=3,onRecommendationClick:l,onStartNewConversation:a,className:o})=>{const u=r.sort((i,h)=>h.intent_match_score-i.intent_match_score).slice(0,d),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),x=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return e.jsxs("div",{className:g,style:x,"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((i,h)=>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",h===0?"bg-yellow-500":h===1?"bg-gray-400":"bg-orange-400"),children:h+1})}),e.jsx("div",{className:"ml-4",children:e.jsx(O,{recommendation:i,theme:t,compact:!1,showReason:!0,onClick:l})})]},i.ad_id||h))})]}),r.length>d&&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-d," additional recommendation",r.length-d>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&&(l==null||l(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:d,showTooltip:l=!0,onClick:a,onHover:o,className:u})=>{const[g,x]=b.useState(!1),i=()=>{x(!0),o==null||o(r)},h=()=>{x(!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=d!=null&&d.accentColor?{"--admesh-primary":d.accentColor}:void 0;return e.jsxs("span",{className:"relative inline-block",children:[e.jsx($,{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":d==null?void 0:d.mode,onMouseEnter:i,onMouseLeave:h,children:f()})}),l&&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:d=!0,citationStyle:l="numbered",onRecommendationClick:a,onCitationHover:o,className:u})=>{const[g,x]=b.useState(null),i=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 R of C){const F=new RegExp(`\\b${R.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if(F.test(m)&&!L){m=m.replace(F,q=>(L=!0,`${q}{{CITATION_${_}}}`));break}}L||(m+=`{{CITATION_${_}}}`)}}),{text:m,citationMap:v}},[s,r]),h=()=>{const{text:m,citationMap:v}=i;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:l,theme:t,showTooltip:!0,onClick:a,onHover:C=>{x(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:h()}),d&&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:l,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:d,sessionId:l,onRecommendationClick:a,onDismiss:o,className:u})=>{const[g,x]=b.useState(s.autoShow!==!1),[i,h]=b.useState(!1);if(b.useEffect(()=>{if(s.delayMs&&s.delayMs>0){const _=setTimeout(()=>{x(!0),h(!0)},s.delayMs);return()=>clearTimeout(_)}else h(!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=()=>{x(!1),o==null||o()},y=()=>{switch(s.displayMode){case"summary":return d?e.jsx(fe,{recommendations:f,conversationSummary:d,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 d?e.jsx(be,{recommendations:f,conversationText:d,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":!i,"opacity-100 translate-y-0":i,"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":l,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=({message:r,theme:s,onRecommendationClick:t,className:d})=>{const l=r.role==="user",a=r.role==="assistant",o=N("admesh-chat-message","flex items-start gap-3",{"flex-row-reverse":l},d),u=N("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":l,"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":r.role==="system"}),g=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0,x=i=>i.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:o,style:g,"data-admesh-theme":s==null?void 0:s.mode,children:[!l&&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"})})}),l&&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 ${l?"items-end":"items-start"} flex-1`,children:[e.jsx("div",{className:u,children:e.jsx("div",{className:"whitespace-pre-wrap break-words",children:r.content})}),e.jsx("div",{className:N("text-xs text-gray-500 dark:text-gray-400 mt-1",{"text-right":l}),children:x(r.timestamp)}),r.recommendations&&r.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:[r.recommendations.length," recommendation",r.recommendations.length>1?"s":""," found"]})]}),e.jsx(ne,{recommendations:r.recommendations,config:{displayMode:"inline",context:"chat",maxRecommendations:3,showPoweredBy:!1,autoShow:!0,delayMs:300},theme:s,onRecommendationClick:t,className:"bg-gray-50 dark:bg-slate-800/50 rounded-lg p-3 border border-gray-200 dark:border-slate-700"})]})]})]})},ye=({placeholder:r="Type your message...",disabled:s=!1,suggestions:t=[],theme:d,onSendMessage:l,className:a})=>{const[o,u]=b.useState(""),[g,x]=b.useState(!1),[i,h]=b.useState([]),c=b.useRef(null),f=j=>{const C=j.target.value;if(u(C),C.trim()&&t.length>0){const L=t.filter(R=>R.toLowerCase().includes(C.toLowerCase()));h(L),x(L.length>0)}else x(!1);c.current&&(c.current.style.height="auto",c.current.style.height=`${Math.min(c.current.scrollHeight,120)}px`)},m=j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),v())},v=()=>{const j=o.trim();j&&!s&&l&&(l(j),u(""),x(!1),c.current&&(c.current.style.height="auto"))},y=j=>{u(j),x(!1),c.current&&c.current.focus()},p=N("admesh-chat-input","relative",a),A=N("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":s}),_=N("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":o.trim()&&!s,"bg-gray-200 dark:bg-slate-700 text-gray-400 dark:text-gray-500 cursor-not-allowed":!o.trim()||s}),k=d!=null&&d.accentColor?{"--admesh-primary":d.accentColor}:void 0;return e.jsxs("div",{className:p,style:k,"data-admesh-theme":d==null?void 0:d.mode,children:[g&&i.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:i.slice(0,5).map((j,C)=>e.jsx("button",{onClick:()=>y(j),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:j},C))}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:c,value:o,onChange:f,onKeyDown:m,placeholder:r,disabled:s,rows:1,className:A,style:{minHeight:"44px",maxHeight:"120px"}}),e.jsx("button",{onClick:v,disabled:!o.trim()||s,className:_,"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:N("transition-opacity duration-200",{"opacity-0":o.length<100}),children:[o.length,"/500"]})]})]})},ve=({messages:r,config:s,theme:t,isLoading:d=!1,onSendMessage:l,onRecommendationClick:a,className:o})=>{const u=b.useRef(null),g=b.useRef(null);b.useEffect(()=>{u.current&&u.current.scrollIntoView({behavior:"smooth"})},[r]);const x=N("admesh-chat-interface","flex flex-col h-full bg-white dark:bg-slate-900",o),i=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0,h=s.maxMessages?r.slice(-s.maxMessages):r;return e.jsxs("div",{className:x,style:i,"data-admesh-theme":t==null?void 0:t.mode,children:[e.jsx("div",{ref:g,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(c=>e.jsx(pe,{message:c,theme:t,onRecommendationClick:a},c.id)),d&&s.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:u})]})}),s.enableSuggestions&&s.suggestions&&s.suggestions.length>0&&r.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:s.suggestions.slice(0,3).map((c,f)=>e.jsx("button",{onClick:()=>l==null?void 0:l(c),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:c},f))})]}),s.showInputField!==!1&&l&&e.jsx("div",{className:"border-t border-gray-200 dark:border-slate-700 p-4",children:e.jsx(ye,{placeholder:s.placeholder||"Ask me about products, tools, or services...",disabled:d,suggestions:s.suggestions,theme:t,onSendMessage:l})})]})},We=({config:r,theme:s,title:t="AI Assistant",subtitle:d="Get personalized recommendations",isOpen:l,onToggle:a,onSendMessage:o,onRecommendationClick:u,autoRecommendations:g,autoRecommendationTrigger:x,showInputField:i=!0,autoShowRecommendations:h=!1,onAutoRecommendationDismiss:c,className:f})=>{const[m,v]=b.useState(r.autoOpen||!1),[y,p]=b.useState([]),[A,_]=b.useState(!1),[k,j]=b.useState(!1),C=l!==void 0?l:m;b.useEffect(()=>{if(r.showWelcomeMessage&&r.welcomeMessage&&y.length===0){const E={id:"welcome",role:"assistant",content:r.welcomeMessage,timestamp:new Date};p([E])}},[r.showWelcomeMessage,r.welcomeMessage,y.length]),b.useEffect(()=>{if(g&&g.length>0&&h){const E={id:`auto-${Date.now()}`,role:"assistant",content:x?`Based on "${x}", here are some relevant recommendations:`:"I found some relevant recommendations for you:",timestamp:new Date,recommendations:g};l===void 0&&v(!0),p(z=>z.some(I=>I.id.startsWith("auto-"))?z.map(I=>I.id.startsWith("auto-")?E:I):[...z,E])}},[g,h,x,l]);const L=()=>{a?a():v(!m),j(!0)},R=async E=>{if(!o)return;const z={id:`user-${Date.now()}`,role:"user",content:E,timestamp:new Date};p(B=>[...B,z]),_(!0);try{const B=await o(E);p(I=>[...I,B])}catch(B){console.error("Error sending message:",B);const I={id:`error-${Date.now()}`,role:"assistant",content:"Sorry, I encountered an error. Please try again.",timestamp:new Date};p(J=>[...J,I])}finally{_(!1)}},F=()=>{switch(r.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]"}},D=N("admesh-floating-chat","fixed z-50 transition-all duration-300 ease-in-out",(()=>{switch(r.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"}})(),f),G=N("bg-white dark:bg-slate-900 rounded-lg shadow-2xl border border-gray-200 dark:border-slate-700 overflow-hidden",F(),{"opacity-0 scale-95 pointer-events-none":!C,"opacity-100 scale-100":C}),Q=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:D,style:Q,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsx("div",{className:G,children:C&&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:t}),e.jsx("p",{className:"text-xs text-blue-100",children:d})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[g&&g.length>0&&c&&e.jsx("button",{onClick:()=>{c(),p(E=>E.filter(z=>!z.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:L,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(ve,{messages:y,config:{...r,showInputField:i},theme:s,isLoading:A,onSendMessage:i?R:void 0,onRecommendationClick:u,className:"h-full"})]})}),!C&&e.jsxs("button",{onClick:L,className:N("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"})}),!k&&e.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full animate-pulse"})]}),C&&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"})]})},ke=({title:r,theme:s,collapsible:t=!1,isCollapsed:d=!1,onToggle:l,onSearch:a,showSearch:o=!1,className:u})=>{const[g,x]=b.useState(""),[i,h]=b.useState(!1),c=y=>{const p=y.target.value;x(p),a==null||a(p)},f=()=>{x(""),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:l,className:"p-1.5 rounded-lg hover:bg-gray-200 dark:hover:bg-slate-700 transition-colors flex-shrink-0",title:d?"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":d}),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&&!d&&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":i}),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:()=>h(!0),onBlur:()=>h(!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"})]}),!d&&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"})]})]})]})},je=({recommendations:r,displayMode:s,theme:t,maxRecommendations:d,onRecommendationClick:l,className:a})=>{const[o,u]=b.useState(!1),[g,x]=b.useState("all"),i=d?r.slice(0,d):r,c=(()=>{switch(g){case"top":return i.filter(y=>y.intent_match_score>=.8).slice(0,5);case"recent":return i.slice(0,3);default:return i}})(),f=N("admesh-sidebar-content","flex flex-col h-full",a),m=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0,v=()=>{if(c.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(s){case"recommendations":return e.jsx("div",{className:"space-y-3",children:c.map((y,p)=>e.jsx(O,{recommendation:y,theme:t,compact:!0,showReason:!0,onClick:l},y.ad_id||p))});case"history":return e.jsx("div",{className:"space-y-2",children:c.map((y,p)=>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:y.title}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[Math.round(y.intent_match_score*100),"% match"]})]})]},y.ad_id||p))});case"favorites":return e.jsx("div",{className:"space-y-3",children:c.slice(0,3).map((y,p)=>e.jsxs("div",{className:"relative",children:[e.jsx(O,{recommendation:y,theme:t,compact:!0,showReason:!1,onClick:l}),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"})})})]},y.ad_id||p))});case"mixed":return e.jsxs("div",{className:"space-y-4",children:[c[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(H,{recommendation:c[0],theme:t,showMatchScore:!0,showBadges:!0,onClick:l,className:"text-xs"})]}),c.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:c.slice(1,4).map((y,p)=>e.jsx(O,{recommendation:y,theme:t,compact:!0,showReason:!1,onClick:l},y.ad_id||p))})]})]});default:return e.jsx("div",{className:"space-y-3",children:c.map((y,p)=>e.jsx(O,{recommendation:y,theme:t,compact:!0,showReason:!0,onClick:l},y.ad_id||p))})}};return e.jsxs("div",{className:f,style:m,"data-admesh-theme":t==null?void 0:t.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:()=>x("all"),className:N("flex-1 px-3 py-2 text-xs font-medium transition-colors",g==="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 (",r.length,")"]}),e.jsx("button",{onClick:()=>x("top"),className:N("flex-1 px-3 py-2 text-xs font-medium transition-colors",g==="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:()=>x("recent"),className:N("flex-1 px-3 py-2 text-xs font-medium transition-colors",g==="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",children:v()}),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:[c.length," recommendation",c.length!==1?"s":""]}),e.jsx("button",{onClick:()=>u(!o),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors",children:"Filters"})]})})]})},$e=({recommendations:r,config:s,theme:t,title:d="Recommendations",isOpen:l=!0,onToggle:a,onRecommendationClick:o,onSearch:u,className:g})=>{const[x,i]=b.useState(s.defaultCollapsed||!1),[h,c]=b.useState(""),[f]=b.useState({});b.useEffect(()=>{if(s.autoRefresh&&s.refreshInterval){const k=setInterval(()=>{console.log("Auto-refreshing recommendations...")},s.refreshInterval);return()=>clearInterval(k)}},[s.autoRefresh,s.refreshInterval]);const m=b.useMemo(()=>{let k=[...r];if(h.trim()){const j=h.toLowerCase();k=k.filter(C=>{var L;return C.title.toLowerCase().includes(j)||C.reason.toLowerCase().includes(j)||((L=C.keywords)==null?void 0:L.some(R=>R.toLowerCase().includes(j)))})}return f.categories&&f.categories.length>0&&(k=k.filter(j=>{var C;return(C=j.categories)==null?void 0:C.some(L=>{var R;return(R=f.categories)==null?void 0:R.includes(L)})})),f.hasFreeTier&&(k=k.filter(j=>j.has_free_tier)),f.hasTrial&&(k=k.filter(j=>j.trial_days&&j.trial_days>0)),f.minMatchScore!==void 0&&(k=k.filter(j=>j.intent_match_score>=f.minMatchScore)),k.sort((j,C)=>C.intent_match_score-j.intent_match_score),s.maxRecommendations&&(k=k.slice(0,s.maxRecommendations)),k},[r,h,f,s.maxRecommendations]),v=()=>{s.collapsible&&(i(!x),a==null||a())},y=k=>{c(k),u==null||u(k)},A=N("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",(()=>{switch(s.size){case"sm":return x?"w-12":"w-64";case"md":return x?"w-12":"w-80";case"lg":return x?"w-12":"w-96";case"xl":return x?"w-12":"w-[28rem]";default:return x?"w-12":"w-80"}})(),{"border-r":s.position==="left","border-l":s.position==="right","fixed top-0 bottom-0 z-50":!0,"left-0":s.position==="left","right-0":s.position==="right","transform -translate-x-full":s.position==="left"&&!l,"transform translate-x-full":s.position==="right"&&!l},g),_=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return!l&&!s.collapsible?null:e.jsxs(e.Fragment,{children:[l&&!x&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-40 lg:hidden",onClick:()=>a==null?void 0:a()}),e.jsxs("div",{className:A,style:_,"data-admesh-theme":t==null?void 0:t.mode,"data-sidebar-position":s.position,"data-sidebar-size":s.size,children:[s.showHeader!==!1&&e.jsx(ke,{title:d,theme:t,collapsible:s.collapsible,isCollapsed:x,onToggle:v,onSearch:s.showSearch?y:void 0,showSearch:s.showSearch&&!x}),!x&&e.jsx(je,{recommendations:m,displayMode:s.displayMode,theme:t,maxRecommendations:s.maxRecommendations,onRecommendationClick:o,className:"flex-1 overflow-hidden"}),x&&s.collapsible&&e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-2",children:[e.jsx("button",{onClick:v,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:m.length})]}),!x&&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"})})]})]})},Fe=({recommendations:r,trigger:s,theme:t,title:d="AI Recommendations",position:l="bottom-right",size:a="md",autoShow:o=!0,showDelay:u=1e3,onRecommendationClick:g,onDismiss:x,className:i})=>{const[h,c]=b.useState(!1),[f,m]=b.useState(!1);b.useEffect(()=>{if(o&&r.length>0){const k=setTimeout(()=>{c(!0),m(!0)},u);return()=>clearTimeout(k)}},[o,r.length,u]);const v=()=>{c(!1),x==null||x()},y=()=>{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"}},p=()=>{switch(l){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||r.length===0)return null;const A=N("admesh-auto-recommendation-widget","fixed z-50 transition-all duration-500 ease-out",p(),y(),{"opacity-0 scale-95 translate-y-2":!f,"opacity-100 scale-100 translate-y-0":f},i),_=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return e.jsx("div",{className:A,style:_,"data-admesh-theme":t==null?void 0:t.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:d}),s&&e.jsxs("p",{className:"text-xs text-blue-100 truncate max-w-48",children:['Based on: "',s,'"']})]})]}),e.jsx("button",{onClick:v,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:[r.length," intelligent match",r.length>1?"es":""," found"]})]}),e.jsx(ne,{recommendations:r,config:{displayMode:"inline",context:"assistant",maxRecommendations:3,showPoweredBy:!1,autoShow:!0,delayMs:200},theme:t,onRecommendationClick:g})]}),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:v,className:"text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors",children:"Dismiss"})]})})]})})},Ve="0.2.1",De={trackingEnabled:!0,debug:!1,theme:{mode:"light",accentColor:"#2563eb"}};exports.AdMeshAutoRecommendationWidget=Fe;exports.AdMeshBadge=xe;exports.AdMeshChatInput=ye;exports.AdMeshChatInterface=ve;exports.AdMeshChatMessage=pe;exports.AdMeshCitationReference=ae;exports.AdMeshCitationUnit=be;exports.AdMeshCompareTable=le;exports.AdMeshConversationSummary=fe;exports.AdMeshConversationalUnit=ne;exports.AdMeshFloatingChat=We;exports.AdMeshInlineRecommendation=O;exports.AdMeshLayout=ge;exports.AdMeshLinkTracker=$;exports.AdMeshProductCard=H;exports.AdMeshSidebar=$e;exports.AdMeshSidebarContent=je;exports.AdMeshSidebarHeader=ke;exports.AdMeshSimpleAd=Be;exports.DEFAULT_CONFIG=De;exports.VERSION=Ve;exports.buildAdMeshLink=Re;exports.extractTrackingData=Ee;exports.setAdMeshTrackerConfig=Te;exports.useAdMeshStyles=me;exports.useAdMeshTracker=he;
|
|
347
|
+
`;let se=!1;const me=()=>{f.useEffect(()=>{if(se)return;const r=document.createElement("style");return r.id="admesh-ui-sdk-styles",r.textContent=Pe,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(d=>d.features&&d.features.length>0),a=r.some(d=>d.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:d=!0,onProductClick:u,onTrackView:g,className:m})=>{me();const l=f.useMemo(()=>r.slice(0,i),[r,i]),h=f.useMemo(()=>Oe(l,s,d),[l,s,d]),c=N("admesh-component",m),b=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return l.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:b,"data-admesh-theme":t==null?void 0:t.mode,children:h==="compare"?e.jsx(le,{recommendations:l,theme:t,maxProducts:Math.min(l.length,4),showMatchScores:n,showFeatures:a,onProductClick:u}):e.jsx("div",{className:"space-y-4",children:l.map((x,k)=>e.jsx(H,{recommendation:x,theme:t,showMatchScore:n,showBadges:!0,maxKeywords:3,onClick:u,onTrackView:g},x.product_id||x.ad_id||k))})})};ge.displayName="AdMeshLayout";const Be=({recommendation:r,theme:s={mode:"light"},className:t="",onClick:i,showPoweredBy:n=!0,variation:a="question"})=>{const d=()=>{i==null||i(r.ad_id,r.admesh_link)},u=r.title,g=()=>{var m,l,h;if(a==="question")return`Looking for ${((l=(m=r.keywords)==null?void 0:m[0])==null?void 0:l.toLowerCase())||"solutions"} for your business? Try ${u}`;{const c=((h=r.reason)==null?void 0:h.split(".")[0])||"offering best solutions for your business";return`${u} is ${c.toLowerCase()}, visit`}};return e.jsx(F,{adId:r.ad_id,admeshLink:r.admesh_link,productId:r.product_id,onClick:d,trackingData:{title:r.title,variation:a,component:"simple_ad"},className:`admesh-simple-ad ${t}`,children:e.jsxs("div",{"data-admesh-theme":s.mode,style:{padding:"12px 16px",borderRadius:"8px",border:`1px solid ${s.mode==="dark"?"#374151":"#e5e7eb"}`,backgroundColor:s.mode==="dark"?"#1f2937":"#ffffff",fontSize:"14px",lineHeight:"1.5",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[e.jsxs("div",{style:{marginBottom:n?"8px":"0"},children:[e.jsx("span",{style:{color:s.mode==="dark"?"#f3f4f6":"#374151",marginRight:"4px"},children:g()}),e.jsx("span",{style:{color:s.accentColor||"#2563eb",textDecoration:"underline",cursor:"pointer",fontSize:"inherit",fontFamily:"inherit"},children:u})]}),n&&e.jsxs("div",{style:{fontSize:"11px",color:s.mode==="dark"?"#9ca3af":"#6b7280",textAlign:"right"},children:["powered by ",e.jsx("strong",{children:"AdMesh"})]})]})})},B=({recommendation:r,theme:s,compact:t=!1,showReason:i=!0,onClick:n,className:a})=>{const d=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(F,{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:[d,"% 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((m,l)=>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:m},l)),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:d})=>{const u=r.sort((l,h)=>h.intent_match_score-l.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",d),m=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return e.jsxs("div",{className:g,style:m,"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((l,h)=>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",h===0?"bg-yellow-500":h===1?"bg-gray-400":"bg-orange-400"),children:h+1})}),e.jsx("div",{className:"ml-4",children:e.jsx(B,{recommendation:l,theme:t,compact:!1,showReason:!0,onClick:n})})]},l.ad_id||h))})]}),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:d,className:u})=>{const[g,m]=f.useState(!1),l=()=>{m(!0),d==null||d(r)},h=()=>{m(!1)},c=()=>{a==null||a(r.ad_id,r.admesh_link)},b=()=>{switch(t){case"bracketed":return`[${s}]`;case"superscript":return s.toString();case"numbered":default:return s.toString()}},x=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),k=i!=null&&i.accentColor?{"--admesh-primary":i.accentColor}:void 0;return e.jsxs("span",{className:"relative inline-block",children:[e.jsx(F,{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:x,children:e.jsx("span",{style:k,"data-admesh-theme":i==null?void 0:i.mode,onMouseEnter:l,onMouseLeave:h,children:b()})}),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:d,className:u})=>{const[g,m]=f.useState(null),l=f.useMemo(()=>{if(!s||r.length===0)return{text:s,citationMap:new Map};let x=s;const k=new Map;return[...r].sort((p,A)=>A.intent_match_score-p.intent_match_score).forEach((p,A)=>{const _=A+1,C=p.title;k.set(_,p);const v=new RegExp(`\\b${C.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if(v.test(x))x=x.replace(v,w=>`${w}{{CITATION_${_}}}`);else{const w=p.keywords||[];let L=!1;for(const R of w){const I=new RegExp(`\\b${R.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"gi");if(I.test(x)&&!L){x=x.replace(I,q=>(L=!0,`${q}{{CITATION_${_}}}`));break}}L||(x+=`{{CITATION_${_}}}`)}}),{text:x,citationMap:k}},[s,r]),h=()=>{const{text:x,citationMap:k}=l;return x.split(/(\{\{CITATION_\d+\}\})/).map((p,A)=>{const _=p.match(/\{\{CITATION_(\d+)\}\}/);if(_){const C=parseInt(_[1]),v=k.get(C);if(v)return e.jsx(ae,{recommendation:v,citationNumber:C,citationStyle:n,theme:t,showTooltip:!0,onClick:a,onHover:w=>{m(w),d==null||d(w)}},`citation-${C}`)}return e.jsx("span",{children:p},A)})},c=N("admesh-citation-unit","space-y-4",u),b=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return e.jsxs("div",{className:c,style:b,"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:h()}),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((x,k)=>k.intent_match_score-x.intent_match_score).map((x,k)=>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)===x.ad_id,"hover:bg-gray-50 dark:hover:bg-slate-800/50":(g==null?void 0:g.ad_id)!==x.ad_id}),children:[e.jsx("div",{className:"flex-shrink-0 mt-1",children:e.jsx(ae,{recommendation:x,citationNumber:k+1,citationStyle:n,theme:t,showTooltip:!1,onClick:a})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(B,{recommendation:x,theme:t,compact:!0,showReason:!1,onClick:a})})]},x.ad_id||k))})]})})]})},ne=({recommendations:r,config:s,theme:t,conversationSummary:i,sessionId:n,onRecommendationClick:a,onDismiss:d,className:u})=>{const[g,m]=f.useState(s.autoShow!==!1),[l,h]=f.useState(!1);if(f.useEffect(()=>{if(s.delayMs&&s.delayMs>0){const _=setTimeout(()=>{m(!0),h(!0)},s.delayMs);return()=>clearTimeout(_)}else h(!0)},[s.delayMs]),!g||r.length===0)return null;const c=s.maxRecommendations||3,b=r.slice(0,c),x=(_,C)=>{a==null||a(_,C)},k=()=>{m(!1),d==null||d()},y=()=>{switch(s.displayMode){case"summary":return i?e.jsx(fe,{recommendations:b,conversationSummary:i,theme:t,showTopRecommendations:c,onRecommendationClick:x,onStartNewConversation:d}):null;case"inline":return e.jsx("div",{className:"space-y-2",children:b.map((_,C)=>e.jsx(B,{recommendation:_,theme:t,compact:!0,showReason:!0,onClick:x},_.ad_id||C))});case"minimal":return b.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:[b.length," intelligent match",b.length>1?"es":""," found"]})]}),e.jsx(B,{recommendation:b[0],theme:t,compact:!0,showReason:!1,onClick:x}),b.length>1&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400 mt-1",children:["+",b.length-1," more recommendation",b.length>2?"s":""]})]}):null;case"citation":return i?e.jsx(be,{recommendations:b,conversationText:i,theme:t,showCitationList:!0,citationStyle:"numbered",onRecommendationClick:x}):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:b.map((_,C)=>e.jsx(B,{recommendation:_,theme:t,compact:!0,showReason:!1,onClick:x},_.ad_id||C))})]});default:return e.jsx("div",{className:"space-y-3",children:b.map((_,C)=>e.jsx(H,{recommendation:_,theme:t,showMatchScore:!1,showBadges:!0,onClick:x},_.ad_id||C))})}},p=N("admesh-conversational-unit","transition-all duration-300 ease-in-out",{"opacity-0 translate-y-2":!l,"opacity-100 translate-y-0":l,"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=({message:r,theme:s,onRecommendationClick:t,className:i})=>{const n=r.role==="user",a=r.role==="assistant",d=N("admesh-chat-message","flex items-start gap-3",{"flex-row-reverse":n},i),u=N("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":r.role==="system"}),g=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0,m=l=>l.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:d,style:g,"data-admesh-theme":s==null?void 0:s.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:u,children:e.jsx("div",{className:"whitespace-pre-wrap break-words",children:r.content})}),e.jsx("div",{className:N("text-xs text-gray-500 dark:text-gray-400 mt-1",{"text-right":n}),children:m(r.timestamp)}),r.recommendations&&r.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:[r.recommendations.length," recommendation",r.recommendations.length>1?"s":""," found"]})]}),e.jsx(ne,{recommendations:r.recommendations,config:{displayMode:"inline",context:"chat",maxRecommendations:3,showPoweredBy:!1,autoShow:!0,delayMs:300},theme:s,onRecommendationClick:t,className:"bg-gray-50 dark:bg-slate-800/50 rounded-lg p-3 border border-gray-200 dark:border-slate-700"})]})]})]})},ye=({placeholder:r="Type your message...",disabled:s=!1,suggestions:t=[],theme:i,onSendMessage:n,className:a})=>{const[d,u]=f.useState(""),[g,m]=f.useState(!1),[l,h]=f.useState([]),c=f.useRef(null),b=v=>{const w=v.target.value;if(u(w),w.trim()&&t.length>0){const L=t.filter(R=>R.toLowerCase().includes(w.toLowerCase()));h(L),m(L.length>0)}else m(!1);c.current&&(c.current.style.height="auto",c.current.style.height=`${Math.min(c.current.scrollHeight,120)}px`)},x=v=>{v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),k())},k=()=>{const v=d.trim();v&&!s&&n&&(n(v),u(""),m(!1),c.current&&(c.current.style.height="auto"))},y=v=>{u(v),m(!1),c.current&&c.current.focus()},p=N("admesh-chat-input","relative",a),A=N("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":s}),_=N("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()&&!s,"bg-gray-200 dark:bg-slate-700 text-gray-400 dark:text-gray-500 cursor-not-allowed":!d.trim()||s}),C=i!=null&&i.accentColor?{"--admesh-primary":i.accentColor}:void 0;return e.jsxs("div",{className:p,style:C,"data-admesh-theme":i==null?void 0:i.mode,children:[g&&l.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:l.slice(0,5).map((v,w)=>e.jsx("button",{onClick:()=>y(v),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:v},w))}),e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{ref:c,value:d,onChange:b,onKeyDown:x,placeholder:r,disabled:s,rows:1,className:A,style:{minHeight:"44px",maxHeight:"120px"}}),e.jsx("button",{onClick:k,disabled:!d.trim()||s,className:_,"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:N("transition-opacity duration-200",{"opacity-0":d.length<100}),children:[d.length,"/500"]})]})]})},ve=({messages:r,config:s,theme:t,isLoading:i=!1,onSendMessage:n,onRecommendationClick:a,className:d})=>{const u=f.useRef(null),g=f.useRef(null);f.useEffect(()=>{u.current&&u.current.scrollIntoView({behavior:"smooth"})},[r]);const m=N("admesh-chat-interface","flex flex-col h-full bg-white dark:bg-slate-900",d),l=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0,h=s.maxMessages?r.slice(-s.maxMessages):r;return e.jsxs("div",{className:m,style:l,"data-admesh-theme":t==null?void 0:t.mode,children:[e.jsx("div",{ref:g,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(c=>e.jsx(pe,{message:c,theme:t,onRecommendationClick:a},c.id)),i&&s.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:u})]})}),s.enableSuggestions&&s.suggestions&&s.suggestions.length>0&&r.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:s.suggestions.slice(0,3).map((c,b)=>e.jsx("button",{onClick:()=>n==null?void 0:n(c),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:c},b))})]}),s.showInputField!==!1&&n&&e.jsx("div",{className:"border-t border-gray-200 dark:border-slate-700 p-4",children:e.jsx(ye,{placeholder:s.placeholder||"Ask me about products, tools, or services...",disabled:i,suggestions:s.suggestions,theme:t,onSendMessage:n})})]})},We=({config:r,theme:s,title:t="AI Assistant",subtitle:i="Get personalized recommendations",isOpen:n,onToggle:a,onSendMessage:d,onRecommendationClick:u,autoRecommendations:g,autoRecommendationTrigger:m,showInputField:l=!0,autoShowRecommendations:h=!1,onAutoRecommendationDismiss:c,className:b})=>{const[x,k]=f.useState(r.autoOpen||!1),[y,p]=f.useState([]),[A,_]=f.useState(!1),[C,v]=f.useState(!1),w=n!==void 0?n:x;f.useEffect(()=>{if(r.showWelcomeMessage&&r.welcomeMessage&&y.length===0){const E={id:"welcome",role:"assistant",content:r.welcomeMessage,timestamp:new Date};p([E])}},[r.showWelcomeMessage,r.welcomeMessage,y.length]),f.useEffect(()=>{if(g&&g.length>0&&h){const E={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:g};n===void 0&&k(!0),p(P=>P.some(z=>z.id.startsWith("auto-"))?P.map(z=>z.id.startsWith("auto-")?E:z):[...P,E])}},[g,h,m,n]);const L=()=>{a?a():k(!x),v(!0)},R=async E=>{if(!d)return;const P={id:`user-${Date.now()}`,role:"user",content:E,timestamp:new Date};p(W=>[...W,P]),_(!0);try{const W=await d(E);p(z=>[...z,W])}catch(W){console.error("Error sending message:",W);const z={id:`error-${Date.now()}`,role:"assistant",content:"Sorry, I encountered an error. Please try again.",timestamp:new Date};p(J=>[...J,z])}finally{_(!1)}},I=()=>{switch(r.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]"}},D=N("admesh-floating-chat","fixed z-50 transition-all duration-300 ease-in-out",(()=>{switch(r.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"}})(),b),G=N("bg-white dark:bg-slate-900 rounded-lg shadow-2xl border border-gray-200 dark:border-slate-700 overflow-hidden",I(),{"opacity-0 scale-95 pointer-events-none":!w,"opacity-100 scale-100":w}),Q=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:D,style:Q,"data-admesh-theme":s==null?void 0:s.mode,children:[e.jsx("div",{className:G,children:w&&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:t}),e.jsx("p",{className:"text-xs text-blue-100",children:i})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[g&&g.length>0&&c&&e.jsx("button",{onClick:()=>{c(),p(E=>E.filter(P=>!P.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:L,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(ve,{messages:y,config:{...r,showInputField:l},theme:s,isLoading:A,onSendMessage:l?R:void 0,onRecommendationClick:u,className:"h-full"})]})}),!w&&e.jsxs("button",{onClick:L,className:N("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"})}),!C&&e.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full animate-pulse"})]}),w&&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"})]})},ke=({title:r,theme:s,collapsible:t=!1,isCollapsed:i=!1,onToggle:n,onSearch:a,showSearch:d=!1,className:u})=>{const[g,m]=f.useState(""),[l,h]=f.useState(!1),c=y=>{const p=y.target.value;m(p),a==null||a(p)},b=()=>{m(""),a==null||a("")},x=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),k=s!=null&&s.accentColor?{"--admesh-primary":s.accentColor}:void 0;return e.jsxs("div",{className:x,style:k,"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"})})})]}),d&&!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":l}),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:()=>h(!0),onBlur:()=>h(!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:b,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",{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"})]})]})]})},je=({recommendations:r,displayMode:s,theme:t,maxRecommendations:i,onRecommendationClick:n,className:a})=>{const[d,u]=f.useState(!1),[g,m]=f.useState("all"),l=i?r.slice(0,i):r,c=(()=>{switch(g){case"top":return l.filter(y=>y.intent_match_score>=.8).slice(0,5);case"recent":return l.slice(0,3);default:return l}})(),b=N("admesh-sidebar-content","flex flex-col h-full",a),x=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0,k=()=>{if(c.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(s){case"recommendations":return e.jsx("div",{className:"space-y-3",children:c.map((y,p)=>e.jsx(B,{recommendation:y,theme:t,compact:!0,showReason:!0,onClick:n},y.ad_id||p))});case"history":return e.jsx("div",{className:"space-y-2",children:c.map((y,p)=>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:y.title}),e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:[Math.round(y.intent_match_score*100),"% match"]})]})]},y.ad_id||p))});case"favorites":return e.jsx("div",{className:"space-y-3",children:c.slice(0,3).map((y,p)=>e.jsxs("div",{className:"relative",children:[e.jsx(B,{recommendation:y,theme:t,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"})})})]},y.ad_id||p))});case"mixed":return e.jsxs("div",{className:"space-y-4",children:[c[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(H,{recommendation:c[0],theme:t,showMatchScore:!0,showBadges:!0,onClick:n,className:"text-xs"})]}),c.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:c.slice(1,4).map((y,p)=>e.jsx(B,{recommendation:y,theme:t,compact:!0,showReason:!1,onClick:n},y.ad_id||p))})]})]});default:return e.jsx("div",{className:"space-y-3",children:c.map((y,p)=>e.jsx(B,{recommendation:y,theme:t,compact:!0,showReason:!0,onClick:n},y.ad_id||p))})}};return e.jsxs("div",{className:b,style:x,"data-admesh-theme":t==null?void 0:t.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:N("flex-1 px-3 py-2 text-xs font-medium transition-colors",g==="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 (",r.length,")"]}),e.jsx("button",{onClick:()=>m("top"),className:N("flex-1 px-3 py-2 text-xs font-medium transition-colors",g==="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:N("flex-1 px-3 py-2 text-xs font-medium transition-colors",g==="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",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:[c.length," recommendation",c.length!==1?"s":""]}),e.jsx("button",{onClick:()=>u(!d),className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 transition-colors",children:"Filters"})]})})]})},$e=({recommendations:r,config:s,theme:t,title:i="Recommendations",isOpen:n=!0,onToggle:a,onRecommendationClick:d,onSearch:u,className:g,containerMode:m=!1})=>{const[l,h]=f.useState(s.defaultCollapsed||!1),[c,b]=f.useState(""),[x]=f.useState({});f.useEffect(()=>{if(s.autoRefresh&&s.refreshInterval){const v=setInterval(()=>{console.log("Auto-refreshing recommendations...")},s.refreshInterval);return()=>clearInterval(v)}},[s.autoRefresh,s.refreshInterval]);const k=f.useMemo(()=>{let v=[...r];if(c.trim()){const w=c.toLowerCase();v=v.filter(L=>{var R;return L.title.toLowerCase().includes(w)||L.reason.toLowerCase().includes(w)||((R=L.keywords)==null?void 0:R.some(I=>I.toLowerCase().includes(w)))})}return x.categories&&x.categories.length>0&&(v=v.filter(w=>{var L;return(L=w.categories)==null?void 0:L.some(R=>{var I;return(I=x.categories)==null?void 0:I.includes(R)})})),x.hasFreeTier&&(v=v.filter(w=>w.has_free_tier)),x.hasTrial&&(v=v.filter(w=>w.trial_days&&w.trial_days>0)),x.minMatchScore!==void 0&&(v=v.filter(w=>w.intent_match_score>=x.minMatchScore)),v.sort((w,L)=>L.intent_match_score-w.intent_match_score),s.maxRecommendations&&(v=v.slice(0,s.maxRecommendations)),v},[r,c,x,s.maxRecommendations]),y=()=>{s.collapsible&&(h(!l),a==null||a())},p=v=>{b(v),u==null||u(v)},_=N("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",(()=>{switch(s.size){case"sm":return l?"w-12":"w-64";case"md":return l?"w-12":"w-80";case"lg":return l?"w-12":"w-96";case"xl":return l?"w-12":"w-[28rem]";default:return l?"w-12":"w-80"}})(),{"border-r":s.position==="left","border-l":s.position==="right","fixed top-0 bottom-0 z-50":!m,"relative h-full":m,"left-0":s.position==="left"&&!m,"right-0":s.position==="right"&&!m,"transform -translate-x-full":s.position==="left"&&!n&&!m,"transform translate-x-full":s.position==="right"&&!n&&!m},g),C=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return!n&&!s.collapsible?null:e.jsxs(e.Fragment,{children:[!m&&n&&!l&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-40 lg:hidden",onClick:()=>a==null?void 0:a()}),e.jsxs("div",{className:_,style:C,"data-admesh-theme":t==null?void 0:t.mode,"data-sidebar-position":s.position,"data-sidebar-size":s.size,children:[s.showHeader!==!1&&e.jsx(ke,{title:i,theme:t,collapsible:s.collapsible,isCollapsed:l,onToggle:y,onSearch:s.showSearch?p:void 0,showSearch:s.showSearch&&!l}),!l&&e.jsx(je,{recommendations:k,displayMode:s.displayMode,theme:t,maxRecommendations:s.maxRecommendations,onRecommendationClick:d,className:"flex-1 overflow-hidden"}),l&&s.collapsible&&e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center p-2",children:[e.jsx("button",{onClick:y,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:k.length})]}),!l&&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"})})]})]})},Fe=({recommendations:r,trigger:s,theme:t,title:i="AI Recommendations",position:n="bottom-right",size:a="md",autoShow:d=!0,showDelay:u=1e3,onRecommendationClick:g,onDismiss:m,className:l})=>{const[h,c]=f.useState(!1),[b,x]=f.useState(!1);f.useEffect(()=>{if(d&&r.length>0){const C=setTimeout(()=>{c(!0),x(!0)},u);return()=>clearTimeout(C)}},[d,r.length,u]);const k=()=>{c(!1),m==null||m()},y=()=>{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"}},p=()=>{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||r.length===0)return null;const A=N("admesh-auto-recommendation-widget","fixed z-50 transition-all duration-500 ease-out",p(),y(),{"opacity-0 scale-95 translate-y-2":!b,"opacity-100 scale-100 translate-y-0":b},l),_=t!=null&&t.accentColor?{"--admesh-primary":t.accentColor}:void 0;return e.jsx("div",{className:A,style:_,"data-admesh-theme":t==null?void 0:t.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}),s&&e.jsxs("p",{className:"text-xs text-blue-100 truncate max-w-48",children:['Based on: "',s,'"']})]})]}),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:[r.length," intelligent match",r.length>1?"es":""," found"]})]}),e.jsx(ne,{recommendations:r,config:{displayMode:"inline",context:"assistant",maxRecommendations:3,showPoweredBy:!1,autoShow:!0,delayMs:200},theme:t,onRecommendationClick:g})]}),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"})]})})]})})},Ve="0.2.1",De={trackingEnabled:!0,debug:!1,theme:{mode:"light",accentColor:"#2563eb"}};exports.AdMeshAutoRecommendationWidget=Fe;exports.AdMeshBadge=xe;exports.AdMeshChatInput=ye;exports.AdMeshChatInterface=ve;exports.AdMeshChatMessage=pe;exports.AdMeshCitationReference=ae;exports.AdMeshCitationUnit=be;exports.AdMeshCompareTable=le;exports.AdMeshConversationSummary=fe;exports.AdMeshConversationalUnit=ne;exports.AdMeshFloatingChat=We;exports.AdMeshInlineRecommendation=B;exports.AdMeshLayout=ge;exports.AdMeshLinkTracker=F;exports.AdMeshProductCard=H;exports.AdMeshSidebar=$e;exports.AdMeshSidebarContent=je;exports.AdMeshSidebarHeader=ke;exports.AdMeshSimpleAd=Be;exports.DEFAULT_CONFIG=De;exports.VERSION=Ve;exports.buildAdMeshLink=Re;exports.extractTrackingData=Ee;exports.setAdMeshTrackerConfig=Te;exports.useAdMeshStyles=me;exports.useAdMeshTracker=he;
|
|
348
348
|
//# sourceMappingURL=index.js.map
|