@realtimex/realtimex-alchemy 1.0.39 → 1.0.40
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/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.0.40] - 2026-01-24
|
|
9
|
+
|
|
10
|
+
### Improved
|
|
11
|
+
- **UI**: Standardized the styling of disabled input fields in Account Settings (Email field) to match the new `bg-black/5` convention, ensuring consistent visual language and readability across the app.
|
|
12
|
+
|
|
8
13
|
## [1.0.39] - 2026-01-24
|
|
9
14
|
|
|
10
15
|
### Fixed
|
|
@@ -74,7 +74,7 @@ localhost:
|
|
|
74
74
|
facebook.com
|
|
75
75
|
twitter.com
|
|
76
76
|
instagram.com
|
|
77
|
-
linkedin.com/feed`,className:"w-full h-40 px-4 py-3 rounded-xl border border-border bg-surface text-fg text-sm placeholder:text-fg/40 focus:outline-none focus:border-[var(--border-hover)] transition-all resize-none"}),h.jsx("p",{className:"text-xs text-fg/50 ml-1",children:"Examples: google.com/search, localhost:, facebook.com, twitter.com"})]}),h.jsx("div",{className:"flex justify-end pt-2",children:h.jsxs("button",{onClick:Be,disabled:ie,className:"px-6 py-3 bg-gradient-to-r from-primary to-accent text-white font-bold rounded-xl shadow-lg glow-primary hover:scale-[1.02] active:scale-95 transition-all flex items-center gap-2",children:[ie?h.jsx($n,{size:18,className:"animate-spin"}):h.jsx(ms,{size:18}),"Save Blacklist"]})})]})]})})]})]})})]})}const rb=P.createContext(null);function EP({children:e}){const[t,n]=P.useState(!1),r=()=>n(!0),o=()=>n(!1);return h.jsx(rb.Provider,{value:{isExpanded:t,setIsExpanded:n,openTerminal:r,closeTerminal:o},children:e})}function jP(){const e=P.useContext(rb);if(!e)throw new Error("useTerminal must be used within a TerminalProvider");return e}function TP({isExpanded:e,onToggle:t,onNavigate:n,liftUp:r}={}){const[o,a]=P.useState([]),{isExpanded:l,setIsExpanded:c}=jP(),[d,p]=P.useState({}),m=e!==void 0?e:l,y=t||(()=>c(!l)),x=r?"bottom-32":"bottom-6";P.useEffect(()=>{w();const k=ce.channel("processing_events_feed").on("postgres_changes",{event:"INSERT",schema:"public",table:"processing_events"},_=>{const j=_.new;j.event_type==="error"&&p(C=>({...C,[j.id]:!0})),a(C=>{const L=[j,...C];return L.length>50?L.slice(0,50):L})}).subscribe();return()=>{ce.removeChannel(k)}},[]);const w=async()=>{const{data:k}=await ce.from("processing_events").select("*").order("created_at",{ascending:!1}).limit(30);k&&a(k)},b=k=>{p(_=>({..._,[k]:!_[k]}))},E=(k,_,j,C)=>{if(_==="debug")return h.jsx(nS,{size:14,className:"text-fg/40"});if(j?.is_completion||C?.is_completion)return h.jsx(vs,{size:14,className:"text-success"});switch(k){case"analysis":return h.jsx(Rx,{size:14,className:"text-primary"});case"action":return h.jsx(Bn,{size:14,className:"text-accent"});case"error":return h.jsx(zg,{size:14,className:"text-error"});case"system":return h.jsx(Yl,{size:14,className:"text-success"});default:return h.jsx(Ix,{size:14,className:"text-fg/40"})}};return m?h.jsxs($e.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},className:"fixed bottom-6 right-6 z-50 w-[450px] max-h-[600px] glass shadow-2xl flex flex-col overflow-hidden border-primary/10",children:[h.jsxs("div",{className:"p-4 border-b border-border/10 flex items-center justify-between bg-surface/50",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Jd,{size:18,className:"text-primary"}),h.jsx("span",{className:"text-xs font-bold uppercase tracking-widest",children:"Alchemist Engine"}),h.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] font-bold bg-success/10 text-success px-2 py-0.5 rounded-full border border-success/10 animate-pulse ml-2",children:[h.jsx(Yk,{size:10})," LIVE"]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("button",{onClick:()=>a([]),className:"text-[10px] uppercase font-bold text-fg/40 hover:text-fg px-2 py-1 transition-colors",children:"Clear"}),h.jsx("button",{onClick:y,className:"text-fg/40 hover:text-fg p-1 transition-colors",children:h.jsx(kS,{size:18})})]})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 custom-scrollbar bg-black/20",children:[o.length===0&&h.jsx("div",{className:"text-center py-12 text-fg/20 italic text-xs",children:"Idle. Awaiting signal mining events..."}),o.map(k=>h.jsxs("div",{className:"relative flex items-start gap-3 group",children:[h.jsx("div",{className:`mt-1 flex-shrink-0 w-6 h-6 rounded-full bg-surface border flex items-center justify-center ${k.metadata?.is_completion||k.details?.is_completion?"border-success/50 bg-success/5":"border-white/5"}`,children:E(k.event_type,k.level,k.metadata,k.details)}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[h.jsx("span",{className:"text-xs font-mono text-fg/60 shrink-0",children:new Date(k.created_at||Date.now()).toLocaleTimeString()}),h.jsx("span",{className:`text-xs font-bold uppercase tracking-wider ${k.level==="error"?"text-error":k.level==="warn"?"text-orange-400":k.event_type==="analysis"?"text-primary":"text-fg/90"}`,children:k.agent_state}),k.metadata?.actionable&&n&&h.jsxs("button",{onClick:()=>n("logs",k.metadata?.actionable),className:"ml-auto flex items-center gap-1 bg-primary/10 text-primary border border-primary/20 px-1.5 py-0.5 rounded text-[10px] uppercase font-bold tracking-wider hover:bg-primary/20 transition-all font-mono",children:[k.metadata.actionable.label,h.jsx(mi,{size:10,className:"-rotate-90"})]}),k.duration_ms&&!k.metadata?.actionable&&h.jsxs("span",{className:"ml-auto text-[10px] font-mono bg-bg/50 px-1.5 py-0.5 rounded flex items-center gap-1 text-fg/40",children:[h.jsx(gi,{size:10}),k.duration_ms,"ms"]})]}),k.metadata?.is_completion||k.details?.is_completion?h.jsxs("div",{className:"bg-success/5 border border-success/20 rounded-lg p-3 space-y-2 mt-2",children:[h.jsxs("div",{className:"flex items-center gap-2 text-success font-bold uppercase text-[9px] tracking-[0.2em]",children:[h.jsx(vs,{className:"w-3.5 h-3.5"}),"Mining Run Completed"]}),h.jsxs("div",{className:"grid grid-cols-3 gap-4 pt-1",children:[h.jsxs("div",{className:"space-y-0.5",children:[h.jsx("p",{className:"text-[10px] text-fg/40 uppercase",children:"Signals"}),h.jsx("p",{className:"text-sm font-bold text-primary",children:k.metadata?.signals_found||k.details?.signals_found||0})]}),h.jsxs("div",{className:"space-y-0.5",children:[h.jsx("p",{className:"text-[10px] text-fg/40 uppercase",children:"URLs"}),h.jsx("p",{className:"text-sm font-bold",children:k.metadata?.total_urls||k.details?.total_urls||0})]}),h.jsxs("div",{className:"space-y-0.5",children:[h.jsx("p",{className:"text-[10px] text-fg/40 uppercase",children:"Skipped"}),h.jsx("p",{className:"text-sm font-bold text-fg/60",children:k.metadata?.skipped||k.details?.skipped||0})]})]}),(k.metadata?.errors||k.details?.errors)>0&&h.jsxs("div",{className:"pt-1 border-t border-success/10 flex items-center justify-between mt-1",children:[h.jsxs("p",{className:"text-[10px] text-error font-bold flex items-center gap-1.5",children:[h.jsx(zg,{size:12}),k.metadata?.errors||k.details?.errors," URLs failed to process"]}),n&&h.jsxs("button",{onClick:()=>n("logs",{filter:"errors"}),className:"flex items-center gap-1 text-[9px] uppercase font-bold text-error bg-error/10 border border-error/20 px-2 py-1 rounded hover:bg-error/20 transition-all group/btn",children:["View Logs",h.jsx(jl,{size:10,className:"group-hover/btn:translate-x-0.5 transition-transform"})]})]})]}):h.jsx("p",{className:`text-sm break-words leading-relaxed ${k.level==="debug"?"text-fg/50 font-mono text-xs":""}`,children:k.message}),(k.details||k.metadata)&&h.jsxs("div",{className:"mt-2 text-xs",children:[h.jsxs("button",{onClick:()=>b(k.id),className:"flex items-center gap-1 text-fg/40 hover:text-primary transition-colors",children:[d[k.id]?h.jsx(Ox,{size:12}):h.jsx(mi,{size:12}),d[k.id]?"Hide Details":"View Details"]}),h.jsx(Zt,{children:d[k.id]&&h.jsx($e.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:h.jsx("pre",{className:"mt-2 p-3 bg-bg/50 rounded border border-white/5 font-mono text-[10px] overflow-x-auto text-fg/70",children:JSON.stringify({...k.details,...k.metadata},null,2)})})})]})]})]},k.id))]})]}):h.jsxs("button",{onClick:y,className:`fixed ${x} right-6 z-50 glass p-4 flex items-center gap-3 hover:bg-surface transition-all shadow-xl group border-primary/10`,children:[h.jsxs("div",{className:"relative",children:[h.jsx(Jd,{size:20,className:"text-primary"}),o.length>0&&h.jsxs("span",{className:"absolute -top-1 -right-1 flex h-2 w-2",children:[h.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75"}),h.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-primary"})]})]}),h.jsx("span",{className:"text-xs font-bold uppercase tracking-widest hidden group-hover:block animate-in fade-in slide-in-from-right-2",children:"Live Engine Log"})]})}const sb="1.0.0",CP="20260125000004";async function NP(e){try{const{data:t,error:n}=await e.rpc("get_latest_migration_timestamp");return n?n.code==="42883"?{version:null,latestMigrationTimestamp:"0"}:{version:null,latestMigrationTimestamp:null}:{version:sb,latestMigrationTimestamp:t||null}}catch{return{version:null,latestMigrationTimestamp:null}}}async function AP(e){const t=sb,n=CP,r=await NP(e);if(r.latestMigrationTimestamp&&r.latestMigrationTimestamp.trim()!==""){const o=n,a=r.latestMigrationTimestamp;return o>a?{needsMigration:!0,appVersion:t,dbVersion:r.version,latestMigrationTimestamp:a,message:`New migrations available. Database is at ${a}, app has ${o}.`}:{needsMigration:!1,appVersion:t,dbVersion:r.version,latestMigrationTimestamp:a,message:"Database schema is up-to-date."}}return{needsMigration:!0,appVersion:t,dbVersion:null,latestMigrationTimestamp:null,message:"Database schema unknown. Migration required."}}function PP(){const[e,t]=P.useState("profile"),[n,r]=P.useState(!1);return h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[h.jsxs("header",{className:"px-8 py-6 border-b border-border",children:[h.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Account Configuration"}),h.jsx("p",{className:"text-sm text-fg/50 font-medium",children:"Manage your Alchemist profile and essence links."})]}),h.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[h.jsxs("aside",{className:"w-64 border-r border-border p-4 space-y-1",children:[h.jsx(Rd,{active:e==="profile",onClick:()=>t("profile"),icon:h.jsx(Xl,{size:18}),label:"Profile"}),h.jsx(Rd,{active:e==="security",onClick:()=>t("security"),icon:h.jsx(Lx,{size:18}),label:"Security"}),h.jsx(Rd,{active:e==="supabase",onClick:()=>t("supabase"),icon:h.jsx(Do,{size:18}),label:"Supabase"})]}),h.jsxs("main",{className:"flex-1 overflow-y-auto custom-scrollbar p-8",children:[e==="profile"&&h.jsx(RP,{}),e==="security"&&h.jsx(OP,{}),e==="supabase"&&h.jsx(IP,{})]})]})]})}function RP(){const[e,t]=P.useState(""),[n,r]=P.useState(""),[o,a]=P.useState(""),[l,c]=P.useState(!1),[d,p]=P.useState(!1),[m,y]=P.useState(null),[x,w]=P.useState(!0);P.useEffect(()=>{b()},[]);const b=async()=>{const{data:{user:_}}=await ce.auth.getUser();if(!_)return;a(_.email||"");const{data:j}=await ce.from("profiles").select("*").eq("id",_.id).maybeSingle();j&&(t(j.first_name||""),r(j.last_name||""),y(j.avatar_url));const{data:C}=await ce.from("alchemy_settings").select("sound_enabled").eq("user_id",_.id).maybeSingle();C&&w(C.sound_enabled??!0)},E=async()=>{c(!0);const{data:{user:_}}=await ce.auth.getUser();_&&(await ce.from("profiles").upsert({id:_.id,first_name:e,last_name:n,full_name:e&&n?`${e} ${n}`:e||n||null}),await ce.from("alchemy_settings").update({sound_enabled:x}).eq("user_id",_.id),c(!1))},k=async _=>{const j=_.target.files?.[0];if(j){p(!0);try{const{data:{user:C}}=await ce.auth.getUser();if(!C)return;const L=j.name.split(".").pop(),U=`${C.id}/avatar-${Date.now()}.${L}`,{error:O}=await ce.storage.from("avatars").upload(U,j,{upsert:!0});if(O)throw O;const{data:{publicUrl:q}}=ce.storage.from("avatars").getPublicUrl(U);await ce.from("profiles").update({avatar_url:q}).eq("id",C.id),y(q)}catch(C){console.error("Avatar upload failed:",C)}finally{p(!1)}}};return h.jsxs("div",{className:"max-w-2xl space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-500",children:[h.jsxs("section",{className:"flex items-start gap-8",children:[h.jsxs("div",{className:"relative group",children:[h.jsx("div",{className:"w-32 h-32 rounded-3xl bg-surface border border-border flex items-center justify-center overflow-hidden shadow-xl",children:m?h.jsx("img",{src:m,alt:"Avatar",className:"w-full h-full object-cover"}):h.jsx(Xl,{size:48,className:"text-fg/20"})}),h.jsxs("label",{className:"absolute inset-0 flex items-center justify-center bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer rounded-3xl",children:[h.jsx(sS,{size:24,className:"text-white"}),h.jsx("input",{type:"file",className:"hidden",accept:"image/*",onChange:k,disabled:d})]}),d&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40 rounded-3xl",children:h.jsx($n,{size:24,className:"text-primary animate-spin"})})]}),h.jsxs("div",{className:"flex-1 space-y-4",children:[h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsx(Wl,{label:"First Name",value:e,onChange:t,placeholder:"Zosimos"}),h.jsx(Wl,{label:"Last Name",value:n,onChange:r,placeholder:"of Panopolis"})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"text-[10px] font-bold uppercase text-fg/30 ml-1",children:"Email Address (Locked)"}),h.jsx("input",{type:"email",value:o,readOnly:!0,className:"w-full bg-surface/50 border border-border rounded-xl py-3 px-4 text-sm text-fg/40 cursor-not-allowed"})]})]})]}),h.jsxs("section",{className:"glass p-6 space-y-4",children:[h.jsxs("h3",{className:"text-lg font-bold flex items-center gap-2",children:[x?h.jsx(qg,{size:20,className:"text-primary"}):h.jsx(Hg,{size:20,className:"text-fg/40"}),"Sound Effects"]}),h.jsx("p",{className:"text-xs text-fg/40",children:"Enable audio feedback for sync events and signal discoveries."}),h.jsx("button",{onClick:()=>w(!x),className:`w-full p-4 rounded-xl border-2 transition-all ${x?"bg-primary/10 border-primary/30 text-primary":"bg-surface border-border text-fg/40"}`,children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"font-semibold text-sm",children:x?"Enabled":"Disabled"}),x?h.jsx(qg,{size:18}):h.jsx(Hg,{size:18})]})})]}),h.jsxs("section",{className:"glass p-6 space-y-4",children:[h.jsxs("h3",{className:"text-lg font-bold flex items-center gap-2",children:[h.jsx(Bg,{size:20,className:"text-error"}),"Sign Out"]}),h.jsx("p",{className:"text-xs text-fg/40",children:"End your current session and return to the login screen."}),h.jsx("button",{onClick:()=>ce.auth.signOut(),className:"w-full p-4 rounded-xl border-2 bg-error/10 border-error/30 text-error hover:bg-error hover:text-white transition-all",children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"font-semibold text-sm",children:"Logout"}),h.jsx(Bg,{size:18})]})})]}),h.jsx("div",{className:"flex justify-end pt-4 border-t border-border",children:h.jsxs("button",{onClick:E,disabled:l,className:"px-6 py-3 bg-gradient-to-r from-primary to-accent text-white font-bold rounded-xl shadow-lg glow-primary hover:scale-[1.02] active:scale-95 transition-all flex items-center gap-2",children:[l?h.jsx($n,{size:18,className:"animate-spin"}):h.jsx(ms,{size:18}),"Preserve Profile"]})})]})}function OP(){const[e,t]=P.useState(""),[n,r]=P.useState(""),[o,a]=P.useState(!1),[l,c]=P.useState(null),[d,p]=P.useState(!1),m=async()=>{if(!e||e!==n){c("Complexity keys do not match.");return}if(e.length<8){c("Entropy too low. Minimum 8 characters.");return}a(!0),c(null),p(!1);const{error:y}=await ce.auth.updateUser({password:e});y?c(y.message):(p(!0),t(""),r("")),a(!1)};return h.jsx("div",{className:"max-w-2xl space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-500",children:h.jsxs("div",{className:"glass p-6 space-y-6",children:[h.jsxs("h3",{className:"text-lg font-bold flex items-center gap-2",children:[h.jsx(gS,{size:20,className:"text-error"})," Update Entropy Key"]}),h.jsxs("div",{className:"space-y-4",children:[h.jsx(Wl,{label:"New Password",type:"password",value:e,onChange:t,placeholder:"••••••••"}),h.jsx(Wl,{label:"Confirm Password",type:"password",value:n,onChange:r,placeholder:"••••••••"})]}),l&&h.jsx("p",{className:"text-xs text-error font-mono bg-error/5 p-3 rounded-lg border border-error/10",children:l}),d&&h.jsx("p",{className:"text-xs text-success font-mono bg-success/5 p-3 rounded-lg border border-success/10",children:"Key rotation successful."}),h.jsx("div",{className:"flex justify-end pt-2",children:h.jsxs("button",{onClick:m,disabled:o,className:"px-6 py-3 bg-error/10 text-error hover:bg-error hover:text-white font-bold rounded-xl border border-error/20 transition-all flex items-center gap-2",children:[o?h.jsx($n,{size:18,className:"animate-spin"}):h.jsx(Lx,{size:18}),"Rotate Key"]})})]})})}function IP(){const[e,t]=P.useState(!1),[n,r]=P.useState(null),o=Nf(),a=pP();P.useEffect(()=>{o&&AP(ce).then(r)},[]);const l=()=>{confirm("Sever connection to this essence? This will reset local resonance.")&&(hP(),window.location.reload())};return h.jsxs("div",{className:"max-w-2xl space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-500",children:[h.jsxs("section",{className:"space-y-6",children:[h.jsx("div",{className:"flex items-center justify-between",children:h.jsxs("div",{children:[h.jsxs("h3",{className:"text-lg font-bold flex items-center gap-2",children:[h.jsx(Do,{size:20,className:"text-primary"})," Essence Resonance"]}),h.jsx("p",{className:"text-xs text-fg/40 font-medium",children:"Bring Your Own Keys (BYOK) for intelligence persistence."})]})}),h.jsx("div",{className:"glass p-8 space-y-8",children:o?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-start gap-4 p-4 glass bg-emerald-500/5 border border-emerald-500/20 rounded-2xl",children:[h.jsx(vs,{className:"w-6 h-6 text-emerald-500 mt-1"}),h.jsxs("div",{className:"flex-1 space-y-1",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"font-bold text-fg italic uppercase tracking-tighter",children:"Established Link"}),n?.latestMigrationTimestamp&&h.jsxs("span",{className:"text-[10px] font-mono bg-emerald-500/10 text-emerald-500 px-2 py-0.5 rounded-full border border-emerald-500/20",children:["v",n.latestMigrationTimestamp]})]}),h.jsx("p",{className:"text-xs font-mono text-fg/40 break-all",children:o.url})]})]}),a==="env"&&h.jsxs("div",{className:"flex items-center gap-3 p-3 bg-amber-500/5 border border-amber-500/10 rounded-xl",children:[h.jsx(Br,{size:16,className:"text-amber-500"}),h.jsx("p",{className:"text-[10px] text-amber-500 font-bold uppercase tracking-widest leading-none",children:"Active from environment variables. UI override enabled."})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("button",{onClick:()=>t(!0),className:"px-4 py-3 glass hover:bg-surface text-xs font-bold uppercase tracking-widest transition-all flex items-center justify-center gap-2",children:[h.jsx(Yl,{size:14})," Realign Link"]}),a==="ui"&&h.jsxs("button",{onClick:l,className:"px-4 py-3 glass border-error/10 hover:bg-error/10 text-error/60 hover:text-error text-xs font-bold uppercase tracking-widest transition-all flex items-center justify-center gap-2",children:[h.jsx(Mx,{size:14})," Sever Link"]})]}),h.jsxs("div",{className:"space-y-1 pt-4 border-t border-border/10",children:[h.jsx("label",{className:"text-[9px] font-bold uppercase tracking-widest text-fg/20 ml-1",children:"Anon Secret Fragment"}),h.jsxs("div",{className:"p-3 bg-surface/50 rounded-xl font-mono text-[11px] text-fg/30 break-all border border-border",children:[o.anonKey.substring(0,32),"..."]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-6",children:[h.jsx(Do,{size:48,className:"text-fg/10"}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-bold italic uppercase tracking-tighter",children:"No Essence Resonance"}),h.jsx("p",{className:"text-xs text-fg/40 max-w-[240px]",children:"The Alchemist requires a cloud core to store intelligence fragments."})]}),h.jsx("button",{onClick:()=>t(!0),className:"px-8 py-3 bg-primary text-white font-bold rounded-xl shadow-lg glow-primary hover:scale-[1.02] transition-all uppercase tracking-widest text-xs",children:"Initiate Link"})]})})]}),h.jsx(eb,{open:e,onComplete:()=>t(!1),canClose:!0})]})}function Rd({active:e,icon:t,label:n,onClick:r}){return h.jsxs("button",{onClick:r,className:`w-full flex items-center gap-3 px-4 py-3 rounded-xl transition-all ${e?"glass bg-primary/10 text-primary border-primary/20 shadow-sm":"text-fg/40 hover:bg-surface hover:text-fg"}`,children:[e?Oo.cloneElement(t,{className:"text-primary"}):t,h.jsx("span",{className:"font-semibold text-sm",children:n})]})}function Wl({label:e,value:t,onChange:n,placeholder:r,type:o="text"}){return h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"text-[10px] font-bold uppercase text-fg/30 ml-1",children:e}),h.jsx("input",{type:o,value:t,onChange:a=>n(a.target.value),className:"w-full bg-surface border border-border rounded-xl py-3 px-4 text-sm text-fg placeholder:text-fg/40 focus:border-[var(--border-hover)] outline-none transition-all",placeholder:r})]})}function DP({signal:e,onClose:t}){const[n,r]=Oo.useState(!1);if(!e)return null;const o=()=>{const c=`# ${e.title}
|
|
77
|
+
linkedin.com/feed`,className:"w-full h-40 px-4 py-3 rounded-xl border border-border bg-surface text-fg text-sm placeholder:text-fg/40 focus:outline-none focus:border-[var(--border-hover)] transition-all resize-none"}),h.jsx("p",{className:"text-xs text-fg/50 ml-1",children:"Examples: google.com/search, localhost:, facebook.com, twitter.com"})]}),h.jsx("div",{className:"flex justify-end pt-2",children:h.jsxs("button",{onClick:Be,disabled:ie,className:"px-6 py-3 bg-gradient-to-r from-primary to-accent text-white font-bold rounded-xl shadow-lg glow-primary hover:scale-[1.02] active:scale-95 transition-all flex items-center gap-2",children:[ie?h.jsx($n,{size:18,className:"animate-spin"}):h.jsx(ms,{size:18}),"Save Blacklist"]})})]})]})})]})]})})]})}const rb=P.createContext(null);function EP({children:e}){const[t,n]=P.useState(!1),r=()=>n(!0),o=()=>n(!1);return h.jsx(rb.Provider,{value:{isExpanded:t,setIsExpanded:n,openTerminal:r,closeTerminal:o},children:e})}function jP(){const e=P.useContext(rb);if(!e)throw new Error("useTerminal must be used within a TerminalProvider");return e}function TP({isExpanded:e,onToggle:t,onNavigate:n,liftUp:r}={}){const[o,a]=P.useState([]),{isExpanded:l,setIsExpanded:c}=jP(),[d,p]=P.useState({}),m=e!==void 0?e:l,y=t||(()=>c(!l)),x=r?"bottom-32":"bottom-6";P.useEffect(()=>{w();const k=ce.channel("processing_events_feed").on("postgres_changes",{event:"INSERT",schema:"public",table:"processing_events"},_=>{const j=_.new;j.event_type==="error"&&p(C=>({...C,[j.id]:!0})),a(C=>{const L=[j,...C];return L.length>50?L.slice(0,50):L})}).subscribe();return()=>{ce.removeChannel(k)}},[]);const w=async()=>{const{data:k}=await ce.from("processing_events").select("*").order("created_at",{ascending:!1}).limit(30);k&&a(k)},b=k=>{p(_=>({..._,[k]:!_[k]}))},E=(k,_,j,C)=>{if(_==="debug")return h.jsx(nS,{size:14,className:"text-fg/40"});if(j?.is_completion||C?.is_completion)return h.jsx(vs,{size:14,className:"text-success"});switch(k){case"analysis":return h.jsx(Rx,{size:14,className:"text-primary"});case"action":return h.jsx(Bn,{size:14,className:"text-accent"});case"error":return h.jsx(zg,{size:14,className:"text-error"});case"system":return h.jsx(Yl,{size:14,className:"text-success"});default:return h.jsx(Ix,{size:14,className:"text-fg/40"})}};return m?h.jsxs($e.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},className:"fixed bottom-6 right-6 z-50 w-[450px] max-h-[600px] glass shadow-2xl flex flex-col overflow-hidden border-primary/10",children:[h.jsxs("div",{className:"p-4 border-b border-border/10 flex items-center justify-between bg-surface/50",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx(Jd,{size:18,className:"text-primary"}),h.jsx("span",{className:"text-xs font-bold uppercase tracking-widest",children:"Alchemist Engine"}),h.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] font-bold bg-success/10 text-success px-2 py-0.5 rounded-full border border-success/10 animate-pulse ml-2",children:[h.jsx(Yk,{size:10})," LIVE"]})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("button",{onClick:()=>a([]),className:"text-[10px] uppercase font-bold text-fg/40 hover:text-fg px-2 py-1 transition-colors",children:"Clear"}),h.jsx("button",{onClick:y,className:"text-fg/40 hover:text-fg p-1 transition-colors",children:h.jsx(kS,{size:18})})]})]}),h.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 custom-scrollbar bg-black/20",children:[o.length===0&&h.jsx("div",{className:"text-center py-12 text-fg/20 italic text-xs",children:"Idle. Awaiting signal mining events..."}),o.map(k=>h.jsxs("div",{className:"relative flex items-start gap-3 group",children:[h.jsx("div",{className:`mt-1 flex-shrink-0 w-6 h-6 rounded-full bg-surface border flex items-center justify-center ${k.metadata?.is_completion||k.details?.is_completion?"border-success/50 bg-success/5":"border-white/5"}`,children:E(k.event_type,k.level,k.metadata,k.details)}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[h.jsx("span",{className:"text-xs font-mono text-fg/60 shrink-0",children:new Date(k.created_at||Date.now()).toLocaleTimeString()}),h.jsx("span",{className:`text-xs font-bold uppercase tracking-wider ${k.level==="error"?"text-error":k.level==="warn"?"text-orange-400":k.event_type==="analysis"?"text-primary":"text-fg/90"}`,children:k.agent_state}),k.metadata?.actionable&&n&&h.jsxs("button",{onClick:()=>n("logs",k.metadata?.actionable),className:"ml-auto flex items-center gap-1 bg-primary/10 text-primary border border-primary/20 px-1.5 py-0.5 rounded text-[10px] uppercase font-bold tracking-wider hover:bg-primary/20 transition-all font-mono",children:[k.metadata.actionable.label,h.jsx(mi,{size:10,className:"-rotate-90"})]}),k.duration_ms&&!k.metadata?.actionable&&h.jsxs("span",{className:"ml-auto text-[10px] font-mono bg-bg/50 px-1.5 py-0.5 rounded flex items-center gap-1 text-fg/40",children:[h.jsx(gi,{size:10}),k.duration_ms,"ms"]})]}),k.metadata?.is_completion||k.details?.is_completion?h.jsxs("div",{className:"bg-success/5 border border-success/20 rounded-lg p-3 space-y-2 mt-2",children:[h.jsxs("div",{className:"flex items-center gap-2 text-success font-bold uppercase text-[9px] tracking-[0.2em]",children:[h.jsx(vs,{className:"w-3.5 h-3.5"}),"Mining Run Completed"]}),h.jsxs("div",{className:"grid grid-cols-3 gap-4 pt-1",children:[h.jsxs("div",{className:"space-y-0.5",children:[h.jsx("p",{className:"text-[10px] text-fg/40 uppercase",children:"Signals"}),h.jsx("p",{className:"text-sm font-bold text-primary",children:k.metadata?.signals_found||k.details?.signals_found||0})]}),h.jsxs("div",{className:"space-y-0.5",children:[h.jsx("p",{className:"text-[10px] text-fg/40 uppercase",children:"URLs"}),h.jsx("p",{className:"text-sm font-bold",children:k.metadata?.total_urls||k.details?.total_urls||0})]}),h.jsxs("div",{className:"space-y-0.5",children:[h.jsx("p",{className:"text-[10px] text-fg/40 uppercase",children:"Skipped"}),h.jsx("p",{className:"text-sm font-bold text-fg/60",children:k.metadata?.skipped||k.details?.skipped||0})]})]}),(k.metadata?.errors||k.details?.errors)>0&&h.jsxs("div",{className:"pt-1 border-t border-success/10 flex items-center justify-between mt-1",children:[h.jsxs("p",{className:"text-[10px] text-error font-bold flex items-center gap-1.5",children:[h.jsx(zg,{size:12}),k.metadata?.errors||k.details?.errors," URLs failed to process"]}),n&&h.jsxs("button",{onClick:()=>n("logs",{filter:"errors"}),className:"flex items-center gap-1 text-[9px] uppercase font-bold text-error bg-error/10 border border-error/20 px-2 py-1 rounded hover:bg-error/20 transition-all group/btn",children:["View Logs",h.jsx(jl,{size:10,className:"group-hover/btn:translate-x-0.5 transition-transform"})]})]})]}):h.jsx("p",{className:`text-sm break-words leading-relaxed ${k.level==="debug"?"text-fg/50 font-mono text-xs":""}`,children:k.message}),(k.details||k.metadata)&&h.jsxs("div",{className:"mt-2 text-xs",children:[h.jsxs("button",{onClick:()=>b(k.id),className:"flex items-center gap-1 text-fg/40 hover:text-primary transition-colors",children:[d[k.id]?h.jsx(Ox,{size:12}):h.jsx(mi,{size:12}),d[k.id]?"Hide Details":"View Details"]}),h.jsx(Zt,{children:d[k.id]&&h.jsx($e.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:h.jsx("pre",{className:"mt-2 p-3 bg-bg/50 rounded border border-white/5 font-mono text-[10px] overflow-x-auto text-fg/70",children:JSON.stringify({...k.details,...k.metadata},null,2)})})})]})]})]},k.id))]})]}):h.jsxs("button",{onClick:y,className:`fixed ${x} right-6 z-50 glass p-4 flex items-center gap-3 hover:bg-surface transition-all shadow-xl group border-primary/10`,children:[h.jsxs("div",{className:"relative",children:[h.jsx(Jd,{size:20,className:"text-primary"}),o.length>0&&h.jsxs("span",{className:"absolute -top-1 -right-1 flex h-2 w-2",children:[h.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75"}),h.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-primary"})]})]}),h.jsx("span",{className:"text-xs font-bold uppercase tracking-widest hidden group-hover:block animate-in fade-in slide-in-from-right-2",children:"Live Engine Log"})]})}const sb="1.0.0",CP="20260125000004";async function NP(e){try{const{data:t,error:n}=await e.rpc("get_latest_migration_timestamp");return n?n.code==="42883"?{version:null,latestMigrationTimestamp:"0"}:{version:null,latestMigrationTimestamp:null}:{version:sb,latestMigrationTimestamp:t||null}}catch{return{version:null,latestMigrationTimestamp:null}}}async function AP(e){const t=sb,n=CP,r=await NP(e);if(r.latestMigrationTimestamp&&r.latestMigrationTimestamp.trim()!==""){const o=n,a=r.latestMigrationTimestamp;return o>a?{needsMigration:!0,appVersion:t,dbVersion:r.version,latestMigrationTimestamp:a,message:`New migrations available. Database is at ${a}, app has ${o}.`}:{needsMigration:!1,appVersion:t,dbVersion:r.version,latestMigrationTimestamp:a,message:"Database schema is up-to-date."}}return{needsMigration:!0,appVersion:t,dbVersion:null,latestMigrationTimestamp:null,message:"Database schema unknown. Migration required."}}function PP(){const[e,t]=P.useState("profile"),[n,r]=P.useState(!1);return h.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[h.jsxs("header",{className:"px-8 py-6 border-b border-border",children:[h.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Account Configuration"}),h.jsx("p",{className:"text-sm text-fg/50 font-medium",children:"Manage your Alchemist profile and essence links."})]}),h.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[h.jsxs("aside",{className:"w-64 border-r border-border p-4 space-y-1",children:[h.jsx(Rd,{active:e==="profile",onClick:()=>t("profile"),icon:h.jsx(Xl,{size:18}),label:"Profile"}),h.jsx(Rd,{active:e==="security",onClick:()=>t("security"),icon:h.jsx(Lx,{size:18}),label:"Security"}),h.jsx(Rd,{active:e==="supabase",onClick:()=>t("supabase"),icon:h.jsx(Do,{size:18}),label:"Supabase"})]}),h.jsxs("main",{className:"flex-1 overflow-y-auto custom-scrollbar p-8",children:[e==="profile"&&h.jsx(RP,{}),e==="security"&&h.jsx(OP,{}),e==="supabase"&&h.jsx(IP,{})]})]})]})}function RP(){const[e,t]=P.useState(""),[n,r]=P.useState(""),[o,a]=P.useState(""),[l,c]=P.useState(!1),[d,p]=P.useState(!1),[m,y]=P.useState(null),[x,w]=P.useState(!0);P.useEffect(()=>{b()},[]);const b=async()=>{const{data:{user:_}}=await ce.auth.getUser();if(!_)return;a(_.email||"");const{data:j}=await ce.from("profiles").select("*").eq("id",_.id).maybeSingle();j&&(t(j.first_name||""),r(j.last_name||""),y(j.avatar_url));const{data:C}=await ce.from("alchemy_settings").select("sound_enabled").eq("user_id",_.id).maybeSingle();C&&w(C.sound_enabled??!0)},E=async()=>{c(!0);const{data:{user:_}}=await ce.auth.getUser();_&&(await ce.from("profiles").upsert({id:_.id,first_name:e,last_name:n,full_name:e&&n?`${e} ${n}`:e||n||null}),await ce.from("alchemy_settings").update({sound_enabled:x}).eq("user_id",_.id),c(!1))},k=async _=>{const j=_.target.files?.[0];if(j){p(!0);try{const{data:{user:C}}=await ce.auth.getUser();if(!C)return;const L=j.name.split(".").pop(),U=`${C.id}/avatar-${Date.now()}.${L}`,{error:O}=await ce.storage.from("avatars").upload(U,j,{upsert:!0});if(O)throw O;const{data:{publicUrl:q}}=ce.storage.from("avatars").getPublicUrl(U);await ce.from("profiles").update({avatar_url:q}).eq("id",C.id),y(q)}catch(C){console.error("Avatar upload failed:",C)}finally{p(!1)}}};return h.jsxs("div",{className:"max-w-2xl space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-500",children:[h.jsxs("section",{className:"flex items-start gap-8",children:[h.jsxs("div",{className:"relative group",children:[h.jsx("div",{className:"w-32 h-32 rounded-3xl bg-surface border border-border flex items-center justify-center overflow-hidden shadow-xl",children:m?h.jsx("img",{src:m,alt:"Avatar",className:"w-full h-full object-cover"}):h.jsx(Xl,{size:48,className:"text-fg/20"})}),h.jsxs("label",{className:"absolute inset-0 flex items-center justify-center bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer rounded-3xl",children:[h.jsx(sS,{size:24,className:"text-white"}),h.jsx("input",{type:"file",className:"hidden",accept:"image/*",onChange:k,disabled:d})]}),d&&h.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40 rounded-3xl",children:h.jsx($n,{size:24,className:"text-primary animate-spin"})})]}),h.jsxs("div",{className:"flex-1 space-y-4",children:[h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsx(Wl,{label:"First Name",value:e,onChange:t,placeholder:"Zosimos"}),h.jsx(Wl,{label:"Last Name",value:n,onChange:r,placeholder:"of Panopolis"})]}),h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"text-[10px] font-bold uppercase text-fg/30 ml-1",children:"Email Address (Locked)"}),h.jsx("input",{type:"email",value:o,readOnly:!0,className:"w-full bg-black/5 border border-border rounded-xl py-3 px-4 text-sm text-fg/40 cursor-not-allowed"})]})]})]}),h.jsxs("section",{className:"glass p-6 space-y-4",children:[h.jsxs("h3",{className:"text-lg font-bold flex items-center gap-2",children:[x?h.jsx(qg,{size:20,className:"text-primary"}):h.jsx(Hg,{size:20,className:"text-fg/40"}),"Sound Effects"]}),h.jsx("p",{className:"text-xs text-fg/40",children:"Enable audio feedback for sync events and signal discoveries."}),h.jsx("button",{onClick:()=>w(!x),className:`w-full p-4 rounded-xl border-2 transition-all ${x?"bg-primary/10 border-primary/30 text-primary":"bg-surface border-border text-fg/40"}`,children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"font-semibold text-sm",children:x?"Enabled":"Disabled"}),x?h.jsx(qg,{size:18}):h.jsx(Hg,{size:18})]})})]}),h.jsxs("section",{className:"glass p-6 space-y-4",children:[h.jsxs("h3",{className:"text-lg font-bold flex items-center gap-2",children:[h.jsx(Bg,{size:20,className:"text-error"}),"Sign Out"]}),h.jsx("p",{className:"text-xs text-fg/40",children:"End your current session and return to the login screen."}),h.jsx("button",{onClick:()=>ce.auth.signOut(),className:"w-full p-4 rounded-xl border-2 bg-error/10 border-error/30 text-error hover:bg-error hover:text-white transition-all",children:h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"font-semibold text-sm",children:"Logout"}),h.jsx(Bg,{size:18})]})})]}),h.jsx("div",{className:"flex justify-end pt-4 border-t border-border",children:h.jsxs("button",{onClick:E,disabled:l,className:"px-6 py-3 bg-gradient-to-r from-primary to-accent text-white font-bold rounded-xl shadow-lg glow-primary hover:scale-[1.02] active:scale-95 transition-all flex items-center gap-2",children:[l?h.jsx($n,{size:18,className:"animate-spin"}):h.jsx(ms,{size:18}),"Preserve Profile"]})})]})}function OP(){const[e,t]=P.useState(""),[n,r]=P.useState(""),[o,a]=P.useState(!1),[l,c]=P.useState(null),[d,p]=P.useState(!1),m=async()=>{if(!e||e!==n){c("Complexity keys do not match.");return}if(e.length<8){c("Entropy too low. Minimum 8 characters.");return}a(!0),c(null),p(!1);const{error:y}=await ce.auth.updateUser({password:e});y?c(y.message):(p(!0),t(""),r("")),a(!1)};return h.jsx("div",{className:"max-w-2xl space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-500",children:h.jsxs("div",{className:"glass p-6 space-y-6",children:[h.jsxs("h3",{className:"text-lg font-bold flex items-center gap-2",children:[h.jsx(gS,{size:20,className:"text-error"})," Update Entropy Key"]}),h.jsxs("div",{className:"space-y-4",children:[h.jsx(Wl,{label:"New Password",type:"password",value:e,onChange:t,placeholder:"••••••••"}),h.jsx(Wl,{label:"Confirm Password",type:"password",value:n,onChange:r,placeholder:"••••••••"})]}),l&&h.jsx("p",{className:"text-xs text-error font-mono bg-error/5 p-3 rounded-lg border border-error/10",children:l}),d&&h.jsx("p",{className:"text-xs text-success font-mono bg-success/5 p-3 rounded-lg border border-success/10",children:"Key rotation successful."}),h.jsx("div",{className:"flex justify-end pt-2",children:h.jsxs("button",{onClick:m,disabled:o,className:"px-6 py-3 bg-error/10 text-error hover:bg-error hover:text-white font-bold rounded-xl border border-error/20 transition-all flex items-center gap-2",children:[o?h.jsx($n,{size:18,className:"animate-spin"}):h.jsx(Lx,{size:18}),"Rotate Key"]})})]})})}function IP(){const[e,t]=P.useState(!1),[n,r]=P.useState(null),o=Nf(),a=pP();P.useEffect(()=>{o&&AP(ce).then(r)},[]);const l=()=>{confirm("Sever connection to this essence? This will reset local resonance.")&&(hP(),window.location.reload())};return h.jsxs("div",{className:"max-w-2xl space-y-8 animate-in fade-in slide-in-from-bottom-2 duration-500",children:[h.jsxs("section",{className:"space-y-6",children:[h.jsx("div",{className:"flex items-center justify-between",children:h.jsxs("div",{children:[h.jsxs("h3",{className:"text-lg font-bold flex items-center gap-2",children:[h.jsx(Do,{size:20,className:"text-primary"})," Essence Resonance"]}),h.jsx("p",{className:"text-xs text-fg/40 font-medium",children:"Bring Your Own Keys (BYOK) for intelligence persistence."})]})}),h.jsx("div",{className:"glass p-8 space-y-8",children:o?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex items-start gap-4 p-4 glass bg-emerald-500/5 border border-emerald-500/20 rounded-2xl",children:[h.jsx(vs,{className:"w-6 h-6 text-emerald-500 mt-1"}),h.jsxs("div",{className:"flex-1 space-y-1",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("p",{className:"font-bold text-fg italic uppercase tracking-tighter",children:"Established Link"}),n?.latestMigrationTimestamp&&h.jsxs("span",{className:"text-[10px] font-mono bg-emerald-500/10 text-emerald-500 px-2 py-0.5 rounded-full border border-emerald-500/20",children:["v",n.latestMigrationTimestamp]})]}),h.jsx("p",{className:"text-xs font-mono text-fg/40 break-all",children:o.url})]})]}),a==="env"&&h.jsxs("div",{className:"flex items-center gap-3 p-3 bg-amber-500/5 border border-amber-500/10 rounded-xl",children:[h.jsx(Br,{size:16,className:"text-amber-500"}),h.jsx("p",{className:"text-[10px] text-amber-500 font-bold uppercase tracking-widest leading-none",children:"Active from environment variables. UI override enabled."})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("button",{onClick:()=>t(!0),className:"px-4 py-3 glass hover:bg-surface text-xs font-bold uppercase tracking-widest transition-all flex items-center justify-center gap-2",children:[h.jsx(Yl,{size:14})," Realign Link"]}),a==="ui"&&h.jsxs("button",{onClick:l,className:"px-4 py-3 glass border-error/10 hover:bg-error/10 text-error/60 hover:text-error text-xs font-bold uppercase tracking-widest transition-all flex items-center justify-center gap-2",children:[h.jsx(Mx,{size:14})," Sever Link"]})]}),h.jsxs("div",{className:"space-y-1 pt-4 border-t border-border/10",children:[h.jsx("label",{className:"text-[9px] font-bold uppercase tracking-widest text-fg/20 ml-1",children:"Anon Secret Fragment"}),h.jsxs("div",{className:"p-3 bg-surface/50 rounded-xl font-mono text-[11px] text-fg/30 break-all border border-border",children:[o.anonKey.substring(0,32),"..."]})]})]}):h.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center space-y-6",children:[h.jsx(Do,{size:48,className:"text-fg/10"}),h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"font-bold italic uppercase tracking-tighter",children:"No Essence Resonance"}),h.jsx("p",{className:"text-xs text-fg/40 max-w-[240px]",children:"The Alchemist requires a cloud core to store intelligence fragments."})]}),h.jsx("button",{onClick:()=>t(!0),className:"px-8 py-3 bg-primary text-white font-bold rounded-xl shadow-lg glow-primary hover:scale-[1.02] transition-all uppercase tracking-widest text-xs",children:"Initiate Link"})]})})]}),h.jsx(eb,{open:e,onComplete:()=>t(!1),canClose:!0})]})}function Rd({active:e,icon:t,label:n,onClick:r}){return h.jsxs("button",{onClick:r,className:`w-full flex items-center gap-3 px-4 py-3 rounded-xl transition-all ${e?"glass bg-primary/10 text-primary border-primary/20 shadow-sm":"text-fg/40 hover:bg-surface hover:text-fg"}`,children:[e?Oo.cloneElement(t,{className:"text-primary"}):t,h.jsx("span",{className:"font-semibold text-sm",children:n})]})}function Wl({label:e,value:t,onChange:n,placeholder:r,type:o="text"}){return h.jsxs("div",{className:"space-y-1",children:[h.jsx("label",{className:"text-[10px] font-bold uppercase text-fg/30 ml-1",children:e}),h.jsx("input",{type:o,value:t,onChange:a=>n(a.target.value),className:"w-full bg-surface border border-border rounded-xl py-3 px-4 text-sm text-fg placeholder:text-fg/40 focus:border-[var(--border-hover)] outline-none transition-all",placeholder:r})]})}function DP({signal:e,onClose:t}){const[n,r]=Oo.useState(!1);if(!e)return null;const o=()=>{const c=`# ${e.title}
|
|
78
78
|
|
|
79
79
|
**Category**: ${e.category||"Research"}
|
|
80
80
|
**Intelligence Score**: ${e.score}/100
|
|
@@ -121,4 +121,4 @@ ${e.content}`:""}`,d=new Blob([c],{type:"text/markdown"}),p=URL.createObjectURL(
|
|
|
121
121
|
`}),n}function kx(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Sx(e,t){const n=II(e,t),r=n.one(e,void 0),o=SI(n),a=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return o&&a.children.push({type:"text",value:`
|
|
122
122
|
`},o),a}function UI(e,t){return e&&"run"in e?async function(n,r){const o=Sx(n,{file:r,...t});await e.run(o,r)}:function(n,r){return Sx(n,{file:r,...e||t})}}function _x(e){if(e)throw e}var zd,Ex;function FI(){if(Ex)return zd;Ex=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=function(p){return typeof Array.isArray=="function"?Array.isArray(p):t.call(p)==="[object Array]"},a=function(p){if(!p||t.call(p)!=="[object Object]")return!1;var m=e.call(p,"constructor"),y=p.constructor&&p.constructor.prototype&&e.call(p.constructor.prototype,"isPrototypeOf");if(p.constructor&&!m&&!y)return!1;var x;for(x in p);return typeof x>"u"||e.call(p,x)},l=function(p,m){n&&m.name==="__proto__"?n(p,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):p[m.name]=m.newValue},c=function(p,m){if(m==="__proto__")if(e.call(p,m)){if(r)return r(p,m).value}else return;return p[m]};return zd=function d(){var p,m,y,x,w,b,E=arguments[0],k=1,_=arguments.length,j=!1;for(typeof E=="boolean"&&(j=E,E=arguments[1]||{},k=2),(E==null||typeof E!="object"&&typeof E!="function")&&(E={});k<_;++k)if(p=arguments[k],p!=null)for(m in p)y=c(E,m),x=c(p,m),E!==x&&(j&&x&&(a(x)||(w=o(x)))?(w?(w=!1,b=y&&o(y)?y:[]):b=y&&a(y)?y:{},l(E,{name:m,newValue:d(j,b,x)})):typeof x<"u"&&l(E,{name:m,newValue:x}));return E},zd}var $I=FI();const Ud=Jl($I);function Dh(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function BI(){const e=[],t={run:n,use:r};return t;function n(...o){let a=-1;const l=o.pop();if(typeof l!="function")throw new TypeError("Expected function as last argument, not "+l);c(null,...o);function c(d,...p){const m=e[++a];let y=-1;if(d){l(d);return}for(;++y<o.length;)(p[y]===null||p[y]===void 0)&&(p[y]=o[y]);o=p,m?VI(m,c)(...p):l(null,...p)}}function r(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),t}}function VI(e,t){let n;return r;function r(...l){const c=e.length>l.length;let d;c&&l.push(o);try{d=e.apply(this,l)}catch(p){const m=p;if(c&&n)throw m;return o(m)}c||(d&&d.then&&typeof d.then=="function"?d.then(a,o):d instanceof Error?o(d):a(d))}function o(l,...c){n||(n=!0,t(l,...c))}function a(l){o(null,l)}}const Xn={basename:qI,dirname:HI,extname:WI,join:KI,sep:"/"};function qI(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');ia(e);let n=0,r=-1,o=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(a){n=o+1;break}}else r<0&&(a=!0,r=o+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let l=-1,c=t.length-1;for(;o--;)if(e.codePointAt(o)===47){if(a){n=o+1;break}}else l<0&&(a=!0,l=o+1),c>-1&&(e.codePointAt(o)===t.codePointAt(c--)?c<0&&(r=o):(c=-1,r=l));return n===r?r=l:r<0&&(r=e.length),e.slice(n,r)}function HI(e){if(ia(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function WI(e){ia(e);let t=e.length,n=-1,r=0,o=-1,a=0,l;for(;t--;){const c=e.codePointAt(t);if(c===47){if(l){r=t+1;break}continue}n<0&&(l=!0,n=t+1),c===46?o<0?o=t:a!==1&&(a=1):o>-1&&(a=-1)}return o<0||n<0||a===0||a===1&&o===n-1&&o===r+1?"":e.slice(o,n)}function KI(...e){let t=-1,n;for(;++t<e.length;)ia(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":GI(n)}function GI(e){ia(e);const t=e.codePointAt(0)===47;let n=JI(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function JI(e,t){let n="",r=0,o=-1,a=0,l=-1,c,d;for(;++l<=e.length;){if(l<e.length)c=e.codePointAt(l);else{if(c===47)break;c=47}if(c===47){if(!(o===l-1||a===1))if(o!==l-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",r=0):(n=n.slice(0,d),r=n.length-1-n.lastIndexOf("/")),o=l,a=0;continue}}else if(n.length>0){n="",r=0,o=l,a=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(o+1,l):n=e.slice(o+1,l),r=l-o-1;o=l,a=0}else c===46&&a>-1?a++:a=-1}return n}function ia(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const YI={cwd:XI};function XI(){return"/"}function Lh(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function QI(e){if(typeof e=="string")e=new URL(e);else if(!Lh(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return ZI(e)}function ZI(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(t)}const Fd=["history","path","basename","stem","extname","dirname"];class Bb{constructor(t){let n;t?Lh(t)?n={path:t}:typeof t=="string"||eD(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":YI.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Fd.length;){const a=Fd[r];a in n&&n[a]!==void 0&&n[a]!==null&&(this[a]=a==="history"?[...n[a]]:n[a])}let o;for(o in n)Fd.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?Xn.basename(this.path):void 0}set basename(t){Bd(t,"basename"),$d(t,"basename"),this.path=Xn.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Xn.dirname(this.path):void 0}set dirname(t){jx(this.basename,"dirname"),this.path=Xn.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Xn.extname(this.path):void 0}set extname(t){if($d(t,"extname"),jx(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Xn.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Lh(t)&&(t=QI(t)),Bd(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Xn.basename(this.path,this.extname):void 0}set stem(t){Bd(t,"stem"),$d(t,"stem"),this.path=Xn.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const o=this.message(t,n,r);throw o.fatal=!0,o}info(t,n,r){const o=this.message(t,n,r);return o.fatal=void 0,o}message(t,n,r){const o=new Vt(t,n,r);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function $d(e,t){if(e&&e.includes(Xn.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Xn.sep+"`")}function Bd(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function jx(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function eD(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const tD=(function(e){const r=this.constructor.prototype,o=r[e],a=function(){return o.apply(a,arguments)};return Object.setPrototypeOf(a,r),a}),nD={}.hasOwnProperty;class Hf extends tD{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=BI()}copy(){const t=new Hf;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Ud(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Hd("data",this.frozen),this.namespace[t]=n,this):nD.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Hd("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const o=n.call(t,...r);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=El(t),r=this.parser||this.Parser;return Vd("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Vd("process",this.parser||this.Parser),qd("process",this.compiler||this.Compiler),n?o(void 0,n):new Promise(o);function o(a,l){const c=El(t),d=r.parse(c);r.run(d,c,function(m,y,x){if(m||!y||!x)return p(m);const w=y,b=r.stringify(w,x);iD(b)?x.value=b:x.result=b,p(m,x)});function p(m,y){m||!y?l(m):a?a(y):n(void 0,y)}}}processSync(t){let n=!1,r;return this.freeze(),Vd("processSync",this.parser||this.Parser),qd("processSync",this.compiler||this.Compiler),this.process(t,o),Cx("processSync","process",n),r;function o(a,l){n=!0,_x(a),r=l}}run(t,n,r){Tx(t),this.freeze();const o=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?a(void 0,r):new Promise(a);function a(l,c){const d=El(n);o.run(t,d,p);function p(m,y,x){const w=y||t;m?c(m):l?l(w):r(void 0,w,x)}}}runSync(t,n){let r=!1,o;return this.run(t,n,a),Cx("runSync","run",r),o;function a(l,c){_x(l),o=c,r=!0}}stringify(t,n){this.freeze();const r=El(n),o=this.compiler||this.Compiler;return qd("stringify",o),Tx(t),o(t,r)}use(t,...n){const r=this.attachers,o=this.namespace;if(Hd("use",this.frozen),t!=null)if(typeof t=="function")d(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):l(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function a(p){if(typeof p=="function")d(p,[]);else if(typeof p=="object")if(Array.isArray(p)){const[m,...y]=p;d(m,y)}else l(p);else throw new TypeError("Expected usable value, not `"+p+"`")}function l(p){if(!("plugins"in p)&&!("settings"in p))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(p.plugins),p.settings&&(o.settings=Ud(!0,o.settings,p.settings))}function c(p){let m=-1;if(p!=null)if(Array.isArray(p))for(;++m<p.length;){const y=p[m];a(y)}else throw new TypeError("Expected a list of plugins, not `"+p+"`")}function d(p,m){let y=-1,x=-1;for(;++y<r.length;)if(r[y][0]===p){x=y;break}if(x===-1)r.push([p,...m]);else if(m.length>0){let[w,...b]=m;const E=r[x][1];Dh(E)&&Dh(w)&&(w=Ud(!0,E,w)),r[x]=[p,w,...b]}}}}const rD=new Hf().freeze();function Vd(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function qd(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Hd(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Tx(e){if(!Dh(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Cx(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function El(e){return sD(e)?e:new Bb(e)}function sD(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function iD(e){return typeof e=="string"||oD(e)}function oD(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const aD="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Nx=[],Ax={allowDangerousHtml:!0},lD=/^(https?|ircs?|mailto|xmpp)$/i,uD=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Vb(e){const t=cD(e),n=dD(e);return hD(t.runSync(t.parse(n),n),e)}function cD(e){const t=e.rehypePlugins||Nx,n=e.remarkPlugins||Nx,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Ax}:Ax;return rD().use(q4).use(n).use(UI,r).use(t)}function dD(e){const t=e.children||"",n=new Bb;return typeof t=="string"&&(n.value=t),n}function hD(e,t){const n=t.allowedElements,r=t.allowElement,o=t.components,a=t.disallowedElements,l=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||fD;for(const m of uD)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+aD+m.id,void 0);return $b(e,p),SR(e,{Fragment:h.Fragment,components:o,ignoreInvalidStyle:!0,jsx:h.jsx,jsxs:h.jsxs,passKeys:!0,passNode:!0});function p(m,y,x){if(m.type==="raw"&&x&&typeof y=="number")return l?x.children.splice(y,1):x.children[y]={type:"text",value:m.value},y;if(m.type==="element"){let w;for(w in Dd)if(Object.hasOwn(Dd,w)&&Object.hasOwn(m.properties,w)){const b=m.properties[w],E=Dd[w];(E===null||E.includes(m.tagName))&&(m.properties[w]=d(String(b||""),w,m))}}if(m.type==="element"){let w=n?!n.includes(m.tagName):a?a.includes(m.tagName):!1;if(!w&&r&&typeof y=="number"&&(w=!r(m,y,x)),w&&x&&typeof y=="number")return c&&m.children?x.children.splice(y,1,...m.children):x.children.splice(y,1),y}}}function fD(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),o=e.indexOf("/");return t===-1||o!==-1&&t>o||n!==-1&&t>n||r!==-1&&t>r||lD.test(e.slice(0,t))?e:""}function pD({message:e}){const t=e.role==="user";return h.jsx("div",{className:`flex w-full ${t?"justify-end":"justify-start"}`,children:h.jsxs("div",{className:`flex gap-3 max-w-[85%] ${t?"flex-row-reverse":"flex-row"}`,children:[h.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center shrink-0 ${t?"bg-primary text-white":"bg-gradient-to-br from-indigo-500 to-purple-600 text-white shadow-lg glow-primary"}`,children:t?h.jsx(Xl,{size:16}):h.jsx(eS,{size:16})}),h.jsxs("div",{className:`flex flex-col ${t?"items-end":"items-start"}`,children:[h.jsx("div",{className:`px-5 py-3.5 rounded-2xl text-sm leading-relaxed shadow-sm ${t?"bg-primary/10 text-fg border border-primary/20 rounded-tr-none":"bg-surface/80 backdrop-blur-md text-fg border border-border/40 rounded-tl-none"}`,children:t?h.jsx("p",{className:"whitespace-pre-wrap",children:e.content}):h.jsx("div",{className:"markdown-body",children:h.jsx(Vb,{components:{p:({node:n,...r})=>h.jsx("p",{className:"mb-2 last:mb-0",...r}),a:({node:n,...r})=>h.jsx("a",{className:"text-primary hover:underline",...r}),ul:({node:n,...r})=>h.jsx("ul",{className:"list-disc ml-4 mb-2",...r}),ol:({node:n,...r})=>h.jsx("ol",{className:"list-decimal ml-4 mb-2",...r}),code:({node:n,...r})=>h.jsx("code",{className:"bg-black/20 rounded px-1 py-0.5 font-mono text-xs",...r})},children:e.content})})}),h.jsx("span",{className:"text-[10px] text-fg/30 mt-1 px-1",children:new Date(e.created_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]})]})})}function mD({sessionId:e,onContextUpdate:t,onNewSession:n,onSessionCreated:r}){const[o,a]=P.useState([]),[l,c]=P.useState(""),[d,p]=P.useState(!1),[m,y]=P.useState(!1),x=P.useRef(null),w=P.useRef(null);P.useEffect(()=>{e?b(e):(a([]),t([]))},[e,t]),P.useEffect(()=>{x.current&&x.current.scrollIntoView({behavior:"smooth"})},[o,m]);const b=async _=>{try{const{data:{session:j}}=await ce.auth.getSession();if(!j)return;const C=await He.get(`/api/chat/sessions/${_}/messages`,{headers:{"x-user-id":j.user.id}});if(C.data.success){a(C.data.messages);const L=C.data.messages[C.data.messages.length-1];L&&L.role==="assistant"&&L.context_sources&&t(L.context_sources)}}catch(j){console.error("Failed to fetch messages",j)}},E=async _=>{if(_?.preventDefault(),!l.trim()||d)return;const j=l.trim();c(""),w.current&&(w.current.style.height="auto");const{data:{session:C}}=await ce.auth.getSession();if(!C)return;const L=C.user.id;p(!0),y(!0);try{let U=e;if(!U){const V=await He.post("/api/chat/sessions",{},{headers:{"x-user-id":L}});if(V.data.success)U=V.data.session.id,r(U);else throw new Error("Failed to create session")}const O={id:"temp-"+Date.now(),role:"user",content:j,created_at:new Date().toISOString()};a(V=>[...V,O]);const q=await He.post("/api/chat/message",{sessionId:U,content:j},{headers:{"x-user-id":L}});if(q.data.success){const V=q.data.message;a(X=>[...X,V]),V.context_sources&&t(V.context_sources)}}catch(U){console.error("Message failed",U),a(O=>[...O,{id:"err-"+Date.now(),role:"assistant",content:"Sorry, I encountered an error processing your request.",created_at:new Date().toISOString()}])}finally{p(!1),y(!1)}},k=_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),E())};return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-6",children:[o.length===0?h.jsxs("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center opacity-60",children:[h.jsx("div",{className:"w-16 h-16 bg-primary/10 rounded-2xl flex items-center justify-center mb-4 text-primary animate-pulse",children:h.jsx(CS,{size:32})}),h.jsx("h3",{className:"text-xl font-bold mb-2",children:"Ask Alchemist"}),h.jsx("p",{className:"text-sm max-w-md mx-auto mb-8",children:"I can help you recall information, summarize topics, and find insights from your browsing history."}),h.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 max-w-lg w-full",children:["What have I read about React recently?","Summarize the latest AI news I visited.","Do I have any notes on Finance?","Find articles about 'Performance'"].map((_,j)=>h.jsx("button",{onClick:()=>c(_),className:"text-left p-3 text-xs bg-surface/50 hover:bg-surface border border-border/30 rounded-xl transition-all hover:scale-[1.02]",children:_},j))})]}):h.jsxs(h.Fragment,{children:[o.map((_,j)=>h.jsx(pD,{message:_},_.id||j)),m&&h.jsx($e.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},className:"flex justify-start w-full",children:h.jsxs("div",{className:"bg-surface/50 border border-border/30 rounded-2xl px-4 py-3 flex items-center gap-3",children:[h.jsxs("div",{className:"flex gap-1",children:[h.jsx("span",{className:"w-1.5 h-1.5 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"0s"}}),h.jsx("span",{className:"w-1.5 h-1.5 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),h.jsx("span",{className:"w-1.5 h-1.5 bg-primary/60 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]}),h.jsx("span",{className:"text-xs text-fg/50 font-mono",children:"Exploring memory..."})]})})]}),h.jsx("div",{ref:x})]}),h.jsx("div",{className:"p-4 bg-surface/30 border-t border-border/10 backdrop-blur-md",children:h.jsx("form",{onSubmit:E,className:"relative max-w-4xl mx-auto",children:h.jsxs("div",{className:"relative flex items-end gap-2 bg-surface/80 border border-border/40 rounded-2xl px-2 py-2 shadow-sm focus-within:ring-2 focus-within:ring-primary/50 focus-within:border-primary/50 transition-all",children:[h.jsx("textarea",{ref:w,value:l,onChange:_=>{c(_.target.value),_.target.style.height="auto",_.target.style.height=_.target.scrollHeight+"px"},onKeyDown:k,placeholder:"Ask about your history...",rows:1,className:"w-full bg-transparent border-none focus:ring-0 focus:outline-none py-2 pl-2 text-fg resize-none min-h-[24px] max-h-[200px] placeholder:text-fg/40",disabled:d}),h.jsx("button",{type:"submit",disabled:!l.trim()||d,className:"p-2 mb-0.5 bg-primary text-white rounded-xl shadow-lg hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-all shrink-0",children:d?h.jsx(Yl,{size:18,className:"animate-spin"}):h.jsx(ES,{size:18})})]})})})]})}function gD({sources:e,onClose:t}){return!e||e.length===0?null:h.jsxs($e.div,{initial:{opacity:0,x:20,width:0},animate:{opacity:1,x:0,width:300},exit:{opacity:0,x:20,width:0},className:"glass rounded-2xl border border-border/40 overflow-hidden flex flex-col",children:[h.jsxs("div",{className:"p-4 border-b border-border/10 flex items-center justify-between bg-surface/30",children:[h.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-fg/80",children:[h.jsx(Px,{size:16,className:"text-secondary"}),h.jsx("span",{children:"Relevant Context"})]}),h.jsx("button",{onClick:t,className:"p-1 hover:bg-surface rounded-md text-fg/40 hover:text-fg transition-colors",children:h.jsx(tr,{size:14})})]}),h.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-3",children:e.map((n,r)=>h.jsxs("div",{className:"p-3 bg-surface/40 hover:bg-surface/60 border border-border/20 rounded-xl transition-all group",children:[h.jsxs("div",{className:"flex justify-between items-start mb-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"flex items-center justify-center w-4 h-4 bg-primary/10 text-primary text-[10px] font-bold rounded",children:r+1}),h.jsxs("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded border ${n.score>=80?"bg-yellow-500/10 text-yellow-500 border-yellow-500/20":"bg-blue-500/10 text-blue-400 border-blue-500/20"}`,children:[n.score,"% Match"]})]}),h.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"opacity-0 group-hover:opacity-100 text-fg/40 hover:text-primary transition-opacity",children:h.jsx(bi,{size:12})})]}),h.jsx("a",{href:n.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-bold text-fg/90 block mb-1 hover:text-primary transition-colors line-clamp-2",children:n.title}),h.jsx("p",{className:"text-[10px] text-fg/50 line-clamp-3 leading-relaxed",children:n.summary})]},r))}),h.jsxs("div",{className:"p-3 border-t border-border/10 bg-surface/30 text-[10px] text-center text-fg/30",children:["Alchemist used these ",e.length," signals to answer"]})]})}function yD(){const[e,t]=P.useState(null),[n,r]=P.useState([]),[o,a]=P.useState(!0);return h.jsxs("div",{className:"flex h-full gap-4 overflow-hidden",children:[h.jsx(GP,{activeSessionId:e,onSelectSession:t}),h.jsx("div",{className:"flex-1 flex flex-col min-w-0 glass rounded-2xl overflow-hidden border border-border/40 relative",children:h.jsx(mD,{sessionId:e,onContextUpdate:l=>{r(l),l.length>0&&a(!0)},onNewSession:()=>t(null),onSessionCreated:l=>t(l)})}),o&&h.jsx(gD,{sources:n,onClose:()=>a(!1)})]})}function xD({isOpen:e,onClose:t}){const[n,r]=P.useState(""),[o,a]=P.useState(!0);P.useEffect(()=>{e&&l()},[e]);const l=async()=>{a(!0);try{const d=await(await fetch("/CHANGELOG.md")).text();r(d)}catch(c){console.error("Failed to load changelog:",c),r(`# Error
|
|
123
123
|
|
|
124
|
-
Failed to load changelog.`)}finally{a(!1)}};return h.jsx(Zt,{children:e&&h.jsxs(h.Fragment,{children:[h.jsx($e.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:t,className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-50"}),h.jsx($e.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{type:"spring",damping:25,stiffness:300},className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:h.jsxs("div",{className:"glass w-full max-w-3xl max-h-[80vh] overflow-hidden pointer-events-auto shadow-2xl",children:[h.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(Px,{size:24,className:"text-primary"}),h.jsx("h2",{className:"text-xl font-bold",children:"Release Notes"})]}),h.jsx("button",{onClick:t,className:"p-2 hover:bg-surface rounded-lg transition-colors",children:h.jsx(tr,{size:20,className:"text-fg/60"})})]}),h.jsx("div",{className:"p-6 overflow-y-auto custom-scrollbar max-h-[calc(80vh-88px)]",children:o?h.jsx("div",{className:"flex items-center justify-center py-12",children:h.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-primary border-t-transparent"})}):h.jsx(Vb,{components:{h1:({children:c})=>h.jsx("h1",{className:"text-2xl font-bold text-fg mb-6 mt-0",children:c}),h2:({children:c})=>h.jsx("h2",{className:"text-xl font-bold text-fg mt-8 mb-3 pb-2 border-b border-border first:mt-0",children:c}),h3:({children:c})=>h.jsx("h3",{className:"text-lg font-bold text-primary mt-6 mb-2",children:c}),p:({children:c})=>h.jsx("p",{className:"text-sm text-fg/70 mb-3 leading-relaxed",children:c}),ul:({children:c})=>h.jsx("ul",{className:"list-none space-y-1 mb-4 ml-0",children:c}),li:({children:c})=>h.jsx("li",{className:"text-sm text-fg/80 ml-4 mb-1 before:content-['•'] before:mr-2 before:text-primary",children:c}),a:({href:c,children:d})=>h.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:text-primary/80 underline transition-colors",children:d}),code:({children:c})=>h.jsx("code",{className:"bg-surface/50 text-accent px-1.5 py-0.5 rounded text-xs font-mono border border-border",children:c}),strong:({children:c})=>h.jsx("strong",{className:"font-bold text-fg",children:c})},children:n})})]})})]})})}class vD{audioContext=null;enabled=!0;constructor(){}getAudioContext(){return this.audioContext||(this.audioContext=new(window.AudioContext||window.webkitAudioContext)),this.audioContext}setEnabled(t){this.enabled=t}isEnabled(){return this.enabled}playTone(t,n,r=.3){if(this.enabled)try{const o=this.getAudioContext(),a=o.createOscillator(),l=o.createGain();a.connect(l),l.connect(o.destination),a.frequency.value=t,a.type="sine",l.gain.setValueAtTime(r,o.currentTime),l.gain.exponentialRampToValueAtTime(.01,o.currentTime+n),a.start(o.currentTime),a.stop(o.currentTime+n)}catch(o){console.warn("[Sound] Failed to play tone:",o)}}playSequence(t,n=.3){if(!this.enabled)return;let r=0;t.forEach(o=>{setTimeout(()=>{this.playTone(o.freq,o.duration,n)},r),r+=o.delay})}syncStart(){this.playSequence([{freq:261.63,duration:.15,delay:0},{freq:329.63,duration:.15,delay:100},{freq:392,duration:.2,delay:100}],.2)}signalFound(){this.playSequence([{freq:392,duration:.1,delay:0},{freq:523.25,duration:.15,delay:80}],.25)}syncComplete(){this.playSequence([{freq:261.63,duration:.12,delay:0},{freq:329.63,duration:.12,delay:80},{freq:392,duration:.12,delay:80},{freq:523.25,duration:.2,delay:80}],.2)}error(){this.playSequence([{freq:329.63,duration:.15,delay:0},{freq:261.63,duration:.2,delay:100}],.3)}click(){this.playTone(440,.05,.15)}}const xo=new vD;function wD(){const[e,t]=P.useState([]),[n,r]=P.useState([]),[o,a]=P.useState("discovery"),[l,c]=P.useState(!1),[d,p]=P.useState(null),[m,y]=P.useState(!0),[x,w]=P.useState(!W0),[b,E]=P.useState(!0),[k,_]=P.useState(!1),[j,C]=P.useState(!1),[L,U]=P.useState(null),[O,q]=P.useState(!1),[V,X]=P.useState(!1),[ge,ie]=P.useState(!1),[oe,Se]=P.useState(!0),[re,Q]=P.useState(()=>localStorage.getItem("theme")||"dark"),[we,me]=P.useState(null),K=P.useRef(null);P.useMemo(()=>{const ne=n.length;let ye=0,ue=0,he=null;for(const We of n){ye+=We.score,We.score>ue&&(ue=We.score);const It=new Date(We.date);(!he||It>new Date(he.date))&&(he=We)}const Ne=ne?Math.round(ye/ne):0,Be=he?new Date(he.date):null;return{total:ne,average:Ne,top:ue,latestTimestamp:Be,latestTitle:he?.title??he?.category??null}},[n]),P.useEffect(()=>{(async()=>{if(!W0){w(!0),y(!1);return}try{const{data:ue,error:he}=await ce.from("init_state").select("is_initialized").single();he?(console.warn("[App] Init check error (might be fresh DB):",he),he.code==="42P01"&&E(!1)):E(ue.is_initialized>0);const{data:{session:Ne}}=await ce.auth.getSession();p(Ne?.user??null)}catch(ue){console.error("[App] Status check failed:",ue)}finally{y(!1)}})();const{data:{subscription:ye}}=ce.auth.onAuthStateChange((ue,he)=>{p(he?.user??null)});return()=>ye.unsubscribe()},[]),P.useEffect(()=>{document.documentElement.setAttribute("data-theme",re),localStorage.setItem("theme",re)},[re]);const[ae,T]=P.useState({});P.useEffect(()=>{(async()=>{if(!d)return;const{data:ye}=await ce.from("alchemy_settings").select("sync_start_date, last_sync_checkpoint").eq("user_id",d.id).maybeSingle();ye&&T(ye)})()},[d,O]),P.useEffect(()=>{if(!d)return;(async()=>{const{data:ue}=await ce.from("alchemy_settings").select("sound_enabled").eq("user_id",d.id).maybeSingle();if(ue){const he=ue.sound_enabled??!0;Se(he),xo.setEnabled(he)}})();const ye=ce.channel("processing_events").on("postgres_changes",{event:"INSERT",schema:"public",table:"processing_events",filter:`user_id=eq.${d.id}`},ue=>{const he=ue.new;he.agent_state==="Mining"&&!V&&(X(!0),ie(!0),oe&&xo.syncStart()),he.agent_state==="Signal"&&oe&&xo.signalFound(),he.agent_state==="Completed"&&(X(!1),oe&&(he.metadata?.errors>0?xo.error():xo.syncComplete()),setTimeout(()=>{ie(!1)},5e3),I())}).subscribe();return()=>{ce.removeChannel(ye)}},[d,V,oe]),P.useEffect(()=>{const ne=new EventSource("/events");return ne.onmessage=ye=>{const ue=JSON.parse(ye.data);ue.type==="history"?t(he=>[...ue.data,...he].slice(0,100)):t(he=>[ue,...he].slice(0,100))},I(),()=>ne.close()},[d]),P.useEffect(()=>{K.current&&K.current.scrollIntoView({behavior:"smooth"})},[e]);const I=async()=>{try{if(d){const{data:ye,error:ue}=await ce.from("signals").select("*").order("created_at",{ascending:!1});if(!ue&&ye){r(ye.map(he=>({id:he.id,title:he.title,score:he.score,summary:he.summary,date:he.created_at,category:he.category,entities:he.entities})));return}}const ne=await He.get("/api/signals");r(ne.data)}catch(ne){console.error("Failed to fetch signals",ne)}},H=async()=>{c(!0);try{await He.post("/api/mine"),I()}catch(ne){console.error("Mining failed:",ne)}finally{c(!1)}},N=(ne,ye)=>{ne==="logs"?(me(ye),a("logs")):a(ne)};return m?h.jsx("div",{className:"flex items-center justify-center h-screen bg-bg",children:h.jsx("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})}):x?h.jsx(eb,{onComplete:()=>w(!1)}):d?h.jsx(bP,{children:h.jsx(EP,{children:h.jsxs("div",{className:"flex h-screen w-screen overflow-hidden bg-bg text-fg",children:[h.jsxs($e.aside,{animate:{width:k?72:240},className:"glass m-4 mr-0 flex flex-col relative",children:[h.jsxs("div",{className:`px-4 py-3 pb-4 flex items-center gap-3 ${k?"justify-center":""}`,children:[h.jsx("div",{className:"w-10 h-10 min-w-[40px] bg-gradient-to-br from-primary to-accent rounded-xl flex items-center justify-center shadow-lg glow-primary",children:h.jsx(Bn,{className:"text-white fill-current",size:24})}),!k&&h.jsx($e.h1,{initial:{opacity:0},animate:{opacity:1},className:"text-xl font-bold tracking-tight",children:"Alchemist"})]}),h.jsxs("nav",{className:"flex-1 flex flex-col gap-1 px-3",children:[h.jsx(vo,{active:o==="discovery",onClick:()=>a("discovery"),icon:h.jsx(xS,{size:20}),label:"Discovery",collapsed:k}),h.jsx(vo,{active:o==="chat",onClick:()=>a("chat"),icon:h.jsx(Kd,{size:20}),label:"Chat",collapsed:k}),h.jsx(vo,{active:o==="engine",onClick:()=>a("engine"),icon:h.jsx(zh,{size:20}),label:"Engine",collapsed:k}),h.jsx(vo,{active:o==="logs",onClick:()=>a("logs"),icon:h.jsx(Jd,{size:20}),label:"System Logs",collapsed:k}),h.jsx(vo,{active:o==="account",onClick:()=>a("account"),icon:h.jsx(Xl,{size:20}),label:"Account",collapsed:k})]}),h.jsx("div",{className:"px-3 pb-2",children:h.jsxs("button",{onClick:()=>Q(re==="dark"?"light":"dark"),className:`w-full flex items-center ${k?"justify-center":"gap-3"} px-4 py-2.5 rounded-lg text-fg/40 hover:text-fg hover:bg-surface/50 transition-all text-xs font-medium`,title:k?re==="dark"?"Switch to Light Mode":"Switch to Dark Mode":"",children:[h.jsx("div",{className:"min-w-[20px] flex justify-center",children:re==="dark"?h.jsx(AS,{size:18}):h.jsx(SS,{size:18})}),!k&&h.jsx($e.span,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},className:"whitespace-nowrap",children:re==="dark"?"Light Mode":"Dark Mode"})]})}),h.jsxs("div",{className:"px-3 pb-3",children:[h.jsx("button",{onClick:()=>_(!k),className:`w-full flex items-center px-4 py-2.5 rounded-lg text-fg/40 hover:text-fg hover:bg-surface/50 transition-all text-xs font-medium ${k?"justify-center":"gap-3"}`,children:k?h.jsx(aS,{size:20}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"min-w-[20px] flex justify-center",children:h.jsx(oS,{size:20})}),h.jsx("span",{children:"Collapse"})]})}),h.jsxs("button",{onClick:()=>C(!0),className:"w-full flex items-center justify-center gap-2 px-3 py-2 mt-2 text-[10px] font-mono text-fg/30 hover:text-primary hover:bg-surface/30 rounded-lg transition-all group",title:"View Changelog",children:[!k&&h.jsxs(h.Fragment,{children:[h.jsx(Gd,{size:12,className:"group-hover:text-primary transition-colors"}),h.jsxs("span",{children:["v","1.0.39"]})]}),k&&h.jsx(Gd,{size:14,className:"group-hover:text-primary transition-colors"})]})]})]}),h.jsxs("main",{className:"flex-1 flex flex-col p-4 gap-4 overflow-hidden relative",children:[o==="discovery"&&h.jsxs(h.Fragment,{children:[h.jsxs("header",{className:"flex justify-between items-center px-4 py-2",children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-2xl font-bold",children:"Discovery"}),h.jsx("p",{className:"text-sm text-fg/50",children:"Passive intelligence mining from your browser history."})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs("button",{onClick:()=>q(!0),className:"px-6 py-3 glass hover:bg-surface transition-colors flex items-center gap-2 text-sm font-medium",children:[h.jsx(jS,{size:16}),h.jsxs("div",{className:"flex flex-col items-start",children:[h.jsx("span",{children:"Sync Settings"}),h.jsx("span",{className:"text-[10px] text-fg/40 font-mono",children:ae.sync_start_date?`From: ${new Date(ae.sync_start_date).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:ae.last_sync_checkpoint?`Checkpoint: ${new Date(ae.last_sync_checkpoint).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:"All time"})]})]}),h.jsxs("button",{onClick:H,disabled:V,className:"px-6 py-3 bg-gradient-to-r from-primary to-accent text-white font-bold rounded-xl shadow-lg glow-primary hover:scale-105 active:scale-95 transition-all flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:scale-100",children:[h.jsx(Yl,{size:18,className:V?"animate-spin":""}),V?"Syncing...":"Sync History"]})]})]}),h.jsx(KP,{onOpenUrl:ne=>window.open(ne,"_blank","noopener,noreferrer"),onCopyText:ne=>{navigator.clipboard.writeText(ne)}})]}),o==="chat"&&h.jsx(yD,{}),o==="engine"&&h.jsx(_P,{}),o==="account"&&h.jsx(PP,{}),o==="logs"&&h.jsx($P,{initialState:we}),h.jsx(TP,{isExpanded:ge,onToggle:()=>ie(!ge),onNavigate:N,liftUp:o==="chat"})]}),h.jsx(DP,{signal:L,onClose:()=>U(null)}),h.jsx(LP,{isOpen:O,onClose:()=>q(!1)}),h.jsx(xD,{isOpen:j,onClose:()=>C(!1)})]})})}):h.jsx(xP,{onAuthSuccess:()=>I(),isInitialized:b})}function vo({active:e,icon:t,label:n,onClick:r,collapsed:o}){return h.jsx("button",{onClick:r,title:o?n:"",className:`w-full flex items-center ${o?"justify-center":"gap-3"} px-4 py-3 rounded-xl transition-all ${e?"bg-primary/10 text-primary shadow-sm":"text-fg/60 hover:bg-surface hover:text-fg"}`,children:o?Oo.cloneElement(t,{className:e?"text-primary":""}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"min-w-[20px] flex justify-center",children:Oo.cloneElement(t,{className:e?"text-primary":""})}),h.jsx($e.span,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},className:"font-semibold text-sm whitespace-nowrap",children:n})]})})}function bD(){He.interceptors.request.use(async e=>{try{const{data:{session:t}}=await ce.auth.getSession();t?.access_token&&(e.headers.Authorization=`Bearer ${t.access_token}`);const n=Nf();n&&(e.headers["x-supabase-url"]=n.url,e.headers["x-supabase-key"]=n.anonKey)}catch(t){console.error("[Axios] Error injecting headers:",t)}return e})}bD();Kk.createRoot(document.getElementById("root")).render(h.jsx(Oo.StrictMode,{children:h.jsx(wD,{})}));
|
|
124
|
+
Failed to load changelog.`)}finally{a(!1)}};return h.jsx(Zt,{children:e&&h.jsxs(h.Fragment,{children:[h.jsx($e.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},onClick:t,className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-50"}),h.jsx($e.div,{initial:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:20},transition:{type:"spring",damping:25,stiffness:300},className:"fixed inset-0 z-50 flex items-center justify-center p-4 pointer-events-none",children:h.jsxs("div",{className:"glass w-full max-w-3xl max-h-[80vh] overflow-hidden pointer-events-auto shadow-2xl",children:[h.jsxs("div",{className:"flex items-center justify-between p-6 border-b border-border",children:[h.jsxs("div",{className:"flex items-center gap-3",children:[h.jsx(Px,{size:24,className:"text-primary"}),h.jsx("h2",{className:"text-xl font-bold",children:"Release Notes"})]}),h.jsx("button",{onClick:t,className:"p-2 hover:bg-surface rounded-lg transition-colors",children:h.jsx(tr,{size:20,className:"text-fg/60"})})]}),h.jsx("div",{className:"p-6 overflow-y-auto custom-scrollbar max-h-[calc(80vh-88px)]",children:o?h.jsx("div",{className:"flex items-center justify-center py-12",children:h.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-2 border-primary border-t-transparent"})}):h.jsx(Vb,{components:{h1:({children:c})=>h.jsx("h1",{className:"text-2xl font-bold text-fg mb-6 mt-0",children:c}),h2:({children:c})=>h.jsx("h2",{className:"text-xl font-bold text-fg mt-8 mb-3 pb-2 border-b border-border first:mt-0",children:c}),h3:({children:c})=>h.jsx("h3",{className:"text-lg font-bold text-primary mt-6 mb-2",children:c}),p:({children:c})=>h.jsx("p",{className:"text-sm text-fg/70 mb-3 leading-relaxed",children:c}),ul:({children:c})=>h.jsx("ul",{className:"list-none space-y-1 mb-4 ml-0",children:c}),li:({children:c})=>h.jsx("li",{className:"text-sm text-fg/80 ml-4 mb-1 before:content-['•'] before:mr-2 before:text-primary",children:c}),a:({href:c,children:d})=>h.jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:text-primary/80 underline transition-colors",children:d}),code:({children:c})=>h.jsx("code",{className:"bg-surface/50 text-accent px-1.5 py-0.5 rounded text-xs font-mono border border-border",children:c}),strong:({children:c})=>h.jsx("strong",{className:"font-bold text-fg",children:c})},children:n})})]})})]})})}class vD{audioContext=null;enabled=!0;constructor(){}getAudioContext(){return this.audioContext||(this.audioContext=new(window.AudioContext||window.webkitAudioContext)),this.audioContext}setEnabled(t){this.enabled=t}isEnabled(){return this.enabled}playTone(t,n,r=.3){if(this.enabled)try{const o=this.getAudioContext(),a=o.createOscillator(),l=o.createGain();a.connect(l),l.connect(o.destination),a.frequency.value=t,a.type="sine",l.gain.setValueAtTime(r,o.currentTime),l.gain.exponentialRampToValueAtTime(.01,o.currentTime+n),a.start(o.currentTime),a.stop(o.currentTime+n)}catch(o){console.warn("[Sound] Failed to play tone:",o)}}playSequence(t,n=.3){if(!this.enabled)return;let r=0;t.forEach(o=>{setTimeout(()=>{this.playTone(o.freq,o.duration,n)},r),r+=o.delay})}syncStart(){this.playSequence([{freq:261.63,duration:.15,delay:0},{freq:329.63,duration:.15,delay:100},{freq:392,duration:.2,delay:100}],.2)}signalFound(){this.playSequence([{freq:392,duration:.1,delay:0},{freq:523.25,duration:.15,delay:80}],.25)}syncComplete(){this.playSequence([{freq:261.63,duration:.12,delay:0},{freq:329.63,duration:.12,delay:80},{freq:392,duration:.12,delay:80},{freq:523.25,duration:.2,delay:80}],.2)}error(){this.playSequence([{freq:329.63,duration:.15,delay:0},{freq:261.63,duration:.2,delay:100}],.3)}click(){this.playTone(440,.05,.15)}}const xo=new vD;function wD(){const[e,t]=P.useState([]),[n,r]=P.useState([]),[o,a]=P.useState("discovery"),[l,c]=P.useState(!1),[d,p]=P.useState(null),[m,y]=P.useState(!0),[x,w]=P.useState(!W0),[b,E]=P.useState(!0),[k,_]=P.useState(!1),[j,C]=P.useState(!1),[L,U]=P.useState(null),[O,q]=P.useState(!1),[V,X]=P.useState(!1),[ge,ie]=P.useState(!1),[oe,Se]=P.useState(!0),[re,Q]=P.useState(()=>localStorage.getItem("theme")||"dark"),[we,me]=P.useState(null),K=P.useRef(null);P.useMemo(()=>{const ne=n.length;let ye=0,ue=0,he=null;for(const We of n){ye+=We.score,We.score>ue&&(ue=We.score);const It=new Date(We.date);(!he||It>new Date(he.date))&&(he=We)}const Ne=ne?Math.round(ye/ne):0,Be=he?new Date(he.date):null;return{total:ne,average:Ne,top:ue,latestTimestamp:Be,latestTitle:he?.title??he?.category??null}},[n]),P.useEffect(()=>{(async()=>{if(!W0){w(!0),y(!1);return}try{const{data:ue,error:he}=await ce.from("init_state").select("is_initialized").single();he?(console.warn("[App] Init check error (might be fresh DB):",he),he.code==="42P01"&&E(!1)):E(ue.is_initialized>0);const{data:{session:Ne}}=await ce.auth.getSession();p(Ne?.user??null)}catch(ue){console.error("[App] Status check failed:",ue)}finally{y(!1)}})();const{data:{subscription:ye}}=ce.auth.onAuthStateChange((ue,he)=>{p(he?.user??null)});return()=>ye.unsubscribe()},[]),P.useEffect(()=>{document.documentElement.setAttribute("data-theme",re),localStorage.setItem("theme",re)},[re]);const[ae,T]=P.useState({});P.useEffect(()=>{(async()=>{if(!d)return;const{data:ye}=await ce.from("alchemy_settings").select("sync_start_date, last_sync_checkpoint").eq("user_id",d.id).maybeSingle();ye&&T(ye)})()},[d,O]),P.useEffect(()=>{if(!d)return;(async()=>{const{data:ue}=await ce.from("alchemy_settings").select("sound_enabled").eq("user_id",d.id).maybeSingle();if(ue){const he=ue.sound_enabled??!0;Se(he),xo.setEnabled(he)}})();const ye=ce.channel("processing_events").on("postgres_changes",{event:"INSERT",schema:"public",table:"processing_events",filter:`user_id=eq.${d.id}`},ue=>{const he=ue.new;he.agent_state==="Mining"&&!V&&(X(!0),ie(!0),oe&&xo.syncStart()),he.agent_state==="Signal"&&oe&&xo.signalFound(),he.agent_state==="Completed"&&(X(!1),oe&&(he.metadata?.errors>0?xo.error():xo.syncComplete()),setTimeout(()=>{ie(!1)},5e3),I())}).subscribe();return()=>{ce.removeChannel(ye)}},[d,V,oe]),P.useEffect(()=>{const ne=new EventSource("/events");return ne.onmessage=ye=>{const ue=JSON.parse(ye.data);ue.type==="history"?t(he=>[...ue.data,...he].slice(0,100)):t(he=>[ue,...he].slice(0,100))},I(),()=>ne.close()},[d]),P.useEffect(()=>{K.current&&K.current.scrollIntoView({behavior:"smooth"})},[e]);const I=async()=>{try{if(d){const{data:ye,error:ue}=await ce.from("signals").select("*").order("created_at",{ascending:!1});if(!ue&&ye){r(ye.map(he=>({id:he.id,title:he.title,score:he.score,summary:he.summary,date:he.created_at,category:he.category,entities:he.entities})));return}}const ne=await He.get("/api/signals");r(ne.data)}catch(ne){console.error("Failed to fetch signals",ne)}},H=async()=>{c(!0);try{await He.post("/api/mine"),I()}catch(ne){console.error("Mining failed:",ne)}finally{c(!1)}},N=(ne,ye)=>{ne==="logs"?(me(ye),a("logs")):a(ne)};return m?h.jsx("div",{className:"flex items-center justify-center h-screen bg-bg",children:h.jsx("div",{className:"w-12 h-12 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})}):x?h.jsx(eb,{onComplete:()=>w(!1)}):d?h.jsx(bP,{children:h.jsx(EP,{children:h.jsxs("div",{className:"flex h-screen w-screen overflow-hidden bg-bg text-fg",children:[h.jsxs($e.aside,{animate:{width:k?72:240},className:"glass m-4 mr-0 flex flex-col relative",children:[h.jsxs("div",{className:`px-4 py-3 pb-4 flex items-center gap-3 ${k?"justify-center":""}`,children:[h.jsx("div",{className:"w-10 h-10 min-w-[40px] bg-gradient-to-br from-primary to-accent rounded-xl flex items-center justify-center shadow-lg glow-primary",children:h.jsx(Bn,{className:"text-white fill-current",size:24})}),!k&&h.jsx($e.h1,{initial:{opacity:0},animate:{opacity:1},className:"text-xl font-bold tracking-tight",children:"Alchemist"})]}),h.jsxs("nav",{className:"flex-1 flex flex-col gap-1 px-3",children:[h.jsx(vo,{active:o==="discovery",onClick:()=>a("discovery"),icon:h.jsx(xS,{size:20}),label:"Discovery",collapsed:k}),h.jsx(vo,{active:o==="chat",onClick:()=>a("chat"),icon:h.jsx(Kd,{size:20}),label:"Chat",collapsed:k}),h.jsx(vo,{active:o==="engine",onClick:()=>a("engine"),icon:h.jsx(zh,{size:20}),label:"Engine",collapsed:k}),h.jsx(vo,{active:o==="logs",onClick:()=>a("logs"),icon:h.jsx(Jd,{size:20}),label:"System Logs",collapsed:k}),h.jsx(vo,{active:o==="account",onClick:()=>a("account"),icon:h.jsx(Xl,{size:20}),label:"Account",collapsed:k})]}),h.jsx("div",{className:"px-3 pb-2",children:h.jsxs("button",{onClick:()=>Q(re==="dark"?"light":"dark"),className:`w-full flex items-center ${k?"justify-center":"gap-3"} px-4 py-2.5 rounded-lg text-fg/40 hover:text-fg hover:bg-surface/50 transition-all text-xs font-medium`,title:k?re==="dark"?"Switch to Light Mode":"Switch to Dark Mode":"",children:[h.jsx("div",{className:"min-w-[20px] flex justify-center",children:re==="dark"?h.jsx(AS,{size:18}):h.jsx(SS,{size:18})}),!k&&h.jsx($e.span,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},className:"whitespace-nowrap",children:re==="dark"?"Light Mode":"Dark Mode"})]})}),h.jsxs("div",{className:"px-3 pb-3",children:[h.jsx("button",{onClick:()=>_(!k),className:`w-full flex items-center px-4 py-2.5 rounded-lg text-fg/40 hover:text-fg hover:bg-surface/50 transition-all text-xs font-medium ${k?"justify-center":"gap-3"}`,children:k?h.jsx(aS,{size:20}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"min-w-[20px] flex justify-center",children:h.jsx(oS,{size:20})}),h.jsx("span",{children:"Collapse"})]})}),h.jsxs("button",{onClick:()=>C(!0),className:"w-full flex items-center justify-center gap-2 px-3 py-2 mt-2 text-[10px] font-mono text-fg/30 hover:text-primary hover:bg-surface/30 rounded-lg transition-all group",title:"View Changelog",children:[!k&&h.jsxs(h.Fragment,{children:[h.jsx(Gd,{size:12,className:"group-hover:text-primary transition-colors"}),h.jsxs("span",{children:["v","1.0.40"]})]}),k&&h.jsx(Gd,{size:14,className:"group-hover:text-primary transition-colors"})]})]})]}),h.jsxs("main",{className:"flex-1 flex flex-col p-4 gap-4 overflow-hidden relative",children:[o==="discovery"&&h.jsxs(h.Fragment,{children:[h.jsxs("header",{className:"flex justify-between items-center px-4 py-2",children:[h.jsxs("div",{children:[h.jsx("h2",{className:"text-2xl font-bold",children:"Discovery"}),h.jsx("p",{className:"text-sm text-fg/50",children:"Passive intelligence mining from your browser history."})]}),h.jsxs("div",{className:"flex gap-2",children:[h.jsxs("button",{onClick:()=>q(!0),className:"px-6 py-3 glass hover:bg-surface transition-colors flex items-center gap-2 text-sm font-medium",children:[h.jsx(jS,{size:16}),h.jsxs("div",{className:"flex flex-col items-start",children:[h.jsx("span",{children:"Sync Settings"}),h.jsx("span",{className:"text-[10px] text-fg/40 font-mono",children:ae.sync_start_date?`From: ${new Date(ae.sync_start_date).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:ae.last_sync_checkpoint?`Checkpoint: ${new Date(ae.last_sync_checkpoint).toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}`:"All time"})]})]}),h.jsxs("button",{onClick:H,disabled:V,className:"px-6 py-3 bg-gradient-to-r from-primary to-accent text-white font-bold rounded-xl shadow-lg glow-primary hover:scale-105 active:scale-95 transition-all flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:scale-100",children:[h.jsx(Yl,{size:18,className:V?"animate-spin":""}),V?"Syncing...":"Sync History"]})]})]}),h.jsx(KP,{onOpenUrl:ne=>window.open(ne,"_blank","noopener,noreferrer"),onCopyText:ne=>{navigator.clipboard.writeText(ne)}})]}),o==="chat"&&h.jsx(yD,{}),o==="engine"&&h.jsx(_P,{}),o==="account"&&h.jsx(PP,{}),o==="logs"&&h.jsx($P,{initialState:we}),h.jsx(TP,{isExpanded:ge,onToggle:()=>ie(!ge),onNavigate:N,liftUp:o==="chat"})]}),h.jsx(DP,{signal:L,onClose:()=>U(null)}),h.jsx(LP,{isOpen:O,onClose:()=>q(!1)}),h.jsx(xD,{isOpen:j,onClose:()=>C(!1)})]})})}):h.jsx(xP,{onAuthSuccess:()=>I(),isInitialized:b})}function vo({active:e,icon:t,label:n,onClick:r,collapsed:o}){return h.jsx("button",{onClick:r,title:o?n:"",className:`w-full flex items-center ${o?"justify-center":"gap-3"} px-4 py-3 rounded-xl transition-all ${e?"bg-primary/10 text-primary shadow-sm":"text-fg/60 hover:bg-surface hover:text-fg"}`,children:o?Oo.cloneElement(t,{className:e?"text-primary":""}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"min-w-[20px] flex justify-center",children:Oo.cloneElement(t,{className:e?"text-primary":""})}),h.jsx($e.span,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},className:"font-semibold text-sm whitespace-nowrap",children:n})]})})}function bD(){He.interceptors.request.use(async e=>{try{const{data:{session:t}}=await ce.auth.getSession();t?.access_token&&(e.headers.Authorization=`Bearer ${t.access_token}`);const n=Nf();n&&(e.headers["x-supabase-url"]=n.url,e.headers["x-supabase-key"]=n.anonKey)}catch(t){console.error("[Axios] Error injecting headers:",t)}return e})}bD();Kk.createRoot(document.getElementById("root")).render(h.jsx(Oo.StrictMode,{children:h.jsx(wD,{})}));
|
package/dist/index.html
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
10
10
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
11
11
|
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Outfit:wght@300;400;600;800&display=swap" rel="stylesheet">
|
|
12
|
-
<script type="module" crossorigin src="/assets/index-
|
|
12
|
+
<script type="module" crossorigin src="/assets/index-DHpzssGy.js"></script>
|
|
13
13
|
<link rel="stylesheet" crossorigin href="/assets/index-Ck7Fq1Iu.css">
|
|
14
14
|
</head>
|
|
15
15
|
<body>
|
package/package.json
CHANGED