@mindexec/cli 0.2.382 → 0.2.383

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.
@@ -1,4 +1,4 @@
1
- import{j as t,r as m}from"./vendor-react-BXzpOyCS.js";import{g as te,a as q,d as ne,b as se,c as re}from"./marketingTools-DN_rnHeB.js";import{$ as oe}from"./canvas-runtime-CF8ukxQK.js";import{R as f}from"./app-runtime-xD2Z3NdN.js";import{b as ie}from"./toolHandoff-D5e5f7t5.js";import{u as ae,aU as Q,aV as le,aW as ce,aX as de,F as ue,aY as pe,Q as R,ab as he,aZ as me,T as Y,i as K,g as fe,f as U,aj as xe}from"./vendor-icons-DE3gIReG.js";const W=2*1024*1024,ke=".md,.markdown,.txt,text/markdown,text/plain",G={"markdown-preview":ue,"markdown-outline":de,"markdown-table":ce,"markdown-links":le,notepad:Q,clipboard:ae};function $(e,n,r){const s=document.head.querySelector(e),o=s??n(),l=o.getAttribute("content"),i=!s;return i&&document.head.appendChild(o),o.setAttribute("content",r),()=>{i?o.remove():l===null?o.removeAttribute("content"):o.setAttribute("content",l)}}function je(e){const n=document.createElement("meta");return n.setAttribute("name",e),n}function M(e){const n=document.createElement("meta");return n.setAttribute("property",e),n}function be(e,n){const r=document.title,s=n?e.liveUrl:`https://mindexec.pages.dev/tools/${e.key}`,o=n?`${e.title} - Free local browser tool`:`${e.title} | MindExec`,l=n?e.heroSubtitle:e.description,i=document.head.querySelector('link[rel="canonical"]')??document.createElement("link"),c=!i.parentElement,d=i.getAttribute("href");i.setAttribute("rel","canonical"),i.setAttribute("href",s),c&&document.head.appendChild(i),document.title=o;const p=[$('meta[name="description"]',()=>je("description"),l),$('meta[property="og:title"]',()=>M("og:title"),o),$('meta[property="og:description"]',()=>M("og:description"),l),$('meta[property="og:url"]',()=>M("og:url"),s)];return()=>{document.title=r,p.forEach(h=>h()),c?i.remove():d===null?i.removeAttribute("href"):i.setAttribute("href",d)}}function _e({navigate:e}){const n=te();return t.jsxs("div",{className:"page tools-directory-page",children:[t.jsxs("section",{className:"section-head",children:[t.jsx("div",{className:"eyebrow",children:"Free local-first tools"}),t.jsx("h1",{children:"Markdown, notes, and clipboard tools from MindExec"}),t.jsx("p",{children:"Use lightweight browser tools with no login and no database save. When the work gets bigger, move into MindCanvas for saved projects, AI workflows, and visual organization."})]}),t.jsx("div",{className:"tools-directory-groups",children:n.map(r=>t.jsxs("section",{className:"tools-directory-section",children:[t.jsxs("div",{className:"tools-directory-head",children:[t.jsx("h2",{children:r.title}),t.jsx("p",{children:r.description})]}),t.jsx("div",{className:"tools-directory-grid",children:r.entries.map(s=>{const o=G[s.kind];return t.jsxs("article",{className:"tools-directory-card","data-testid":"tool-directory-card","data-tool-key":s.key,children:[t.jsxs("div",{className:"tool-card-topline",children:[t.jsx("span",{children:s.label}),t.jsx(o,{size:18})]}),t.jsx("h3",{children:s.title}),t.jsx("p",{children:s.description}),t.jsxs("button",{type:"button",className:"btn btn-secondary",onClick:()=>e(`/tools/${s.key}`),children:["Open tool",t.jsx(pe,{size:16})]}),t.jsxs("a",{className:"tool-live-link",href:s.liveUrl,target:"_blank",rel:"noreferrer",children:[t.jsx(R,{size:14}),"Standalone"]})]},s.key)})})]},r.id))}),t.jsxs("section",{className:"tools-directory-cta",children:[t.jsxs("div",{children:[t.jsx("h2",{children:"Need a bigger workspace?"}),t.jsx("p",{children:"MindCanvas is where these small tasks turn into saved canvases, larger document sets, AI workflows, and cloud projects inside MindExec."})]}),t.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>e("/mindcanvas"),children:"Open MindCanvas"})]})]})}function De({toolKey:e,navigate:n,miniHost:r=!1}){const s=q(e);return s?t.jsx(ge,{tool:s,navigate:n,miniHost:r}):t.jsx("div",{className:"page tools-directory-page",children:t.jsxs("section",{className:"section-head",children:[t.jsx("div",{className:"eyebrow",children:"Tool not found"}),t.jsx("h1",{children:"This local tool is not enabled."}),t.jsx("p",{children:"Open the tools directory and pick one of the current MindExec browser tools."}),t.jsx("div",{className:"action-row",children:t.jsx("button",{className:"btn btn-primary",type:"button",onClick:()=>n("/tools"),children:"Back to tools"})})]})})}function ge({tool:e,navigate:n,miniHost:r}){const[s,o]=m.useState(()=>S(e.kind)),[l,i]=m.useState(""),[c,d]=m.useState(["Pricing proof from a user conversation","Demo clip idea for English-first launch","Competitor headline worth comparing"]),[p,h]=m.useState(null),[B,y]=m.useState(""),T=m.useRef(null),C=m.useRef(null),b=m.useMemo(()=>Ne(e,s,c),[c,s,e]),V=G[e.kind],X=e.relatedKeys.map(a=>q(a)).filter(a=>!!a),z=ve(e.kind),w=e.key==="bulk-markdown-viewer";m.useEffect(()=>{const a=be(e,r);return f.emit("tool.meta.applied",{toolKey:e.key,host:window.location.hostname,miniHost:r,canonical:r?e.liveUrl:`https://mindexec.pages.dev/tools/${e.key}`}),r&&f.emit("tool.hostProfile.applied",{toolKey:e.key,host:window.location.hostname}),a},[r,e]),m.useEffect(()=>{o(S(e.kind)),y(""),h(null)},[e.key,e.kind]);const P=async(a,x,k)=>{try{const u=await oe(x);h(a),f.emit("tool.copy",{toolKey:e.key,ok:!0,method:u,chars:x.length}),window.setTimeout(()=>h(null),1400)}catch(u){const j=k==="source"?T.current:C.current;if(j){j.focus(),j.select(),h(k==="source"?"Source selected":"Output selected"),f.emit("tool.copy",{toolKey:e.key,ok:!1,selected:!0,target:k,message:u instanceof Error?u.message:String(u)});return}h("Copy failed"),f.emit("tool.copy",{toolKey:e.key,ok:!1,target:k,message:u instanceof Error?u.message:String(u)})}},Z=()=>{o(S(e.kind)),y("Sample loaded."),f.emit("tool.sample.loaded",{toolKey:e.key})},J=()=>{o(""),y(""),f.emit("tool.source.cleared",{toolKey:e.key})},O=()=>{ie({toolKey:e.key,toolTitle:e.title,sourceTitle:`${e.label} source`,sourceBody:e.kind==="clipboard"?c.join(`
1
+ import{j as t,r as m}from"./vendor-react-BXzpOyCS.js";import{g as te,a as q,d as ne,b as se,c as re}from"./marketingTools-DN_rnHeB.js";import{$ as oe}from"./canvas-runtime-Bc1G-FZ_.js";import{R as f}from"./app-runtime-xD2Z3NdN.js";import{b as ie}from"./toolHandoff-D5e5f7t5.js";import{u as ae,aU as Q,aV as le,aW as ce,aX as de,F as ue,aY as pe,Q as R,ab as he,aZ as me,T as Y,i as K,g as fe,f as U,aj as xe}from"./vendor-icons-DE3gIReG.js";const W=2*1024*1024,ke=".md,.markdown,.txt,text/markdown,text/plain",G={"markdown-preview":ue,"markdown-outline":de,"markdown-table":ce,"markdown-links":le,notepad:Q,clipboard:ae};function $(e,n,r){const s=document.head.querySelector(e),o=s??n(),l=o.getAttribute("content"),i=!s;return i&&document.head.appendChild(o),o.setAttribute("content",r),()=>{i?o.remove():l===null?o.removeAttribute("content"):o.setAttribute("content",l)}}function je(e){const n=document.createElement("meta");return n.setAttribute("name",e),n}function M(e){const n=document.createElement("meta");return n.setAttribute("property",e),n}function be(e,n){const r=document.title,s=n?e.liveUrl:`https://mindexec.pages.dev/tools/${e.key}`,o=n?`${e.title} - Free local browser tool`:`${e.title} | MindExec`,l=n?e.heroSubtitle:e.description,i=document.head.querySelector('link[rel="canonical"]')??document.createElement("link"),c=!i.parentElement,d=i.getAttribute("href");i.setAttribute("rel","canonical"),i.setAttribute("href",s),c&&document.head.appendChild(i),document.title=o;const p=[$('meta[name="description"]',()=>je("description"),l),$('meta[property="og:title"]',()=>M("og:title"),o),$('meta[property="og:description"]',()=>M("og:description"),l),$('meta[property="og:url"]',()=>M("og:url"),s)];return()=>{document.title=r,p.forEach(h=>h()),c?i.remove():d===null?i.removeAttribute("href"):i.setAttribute("href",d)}}function _e({navigate:e}){const n=te();return t.jsxs("div",{className:"page tools-directory-page",children:[t.jsxs("section",{className:"section-head",children:[t.jsx("div",{className:"eyebrow",children:"Free local-first tools"}),t.jsx("h1",{children:"Markdown, notes, and clipboard tools from MindExec"}),t.jsx("p",{children:"Use lightweight browser tools with no login and no database save. When the work gets bigger, move into MindCanvas for saved projects, AI workflows, and visual organization."})]}),t.jsx("div",{className:"tools-directory-groups",children:n.map(r=>t.jsxs("section",{className:"tools-directory-section",children:[t.jsxs("div",{className:"tools-directory-head",children:[t.jsx("h2",{children:r.title}),t.jsx("p",{children:r.description})]}),t.jsx("div",{className:"tools-directory-grid",children:r.entries.map(s=>{const o=G[s.kind];return t.jsxs("article",{className:"tools-directory-card","data-testid":"tool-directory-card","data-tool-key":s.key,children:[t.jsxs("div",{className:"tool-card-topline",children:[t.jsx("span",{children:s.label}),t.jsx(o,{size:18})]}),t.jsx("h3",{children:s.title}),t.jsx("p",{children:s.description}),t.jsxs("button",{type:"button",className:"btn btn-secondary",onClick:()=>e(`/tools/${s.key}`),children:["Open tool",t.jsx(pe,{size:16})]}),t.jsxs("a",{className:"tool-live-link",href:s.liveUrl,target:"_blank",rel:"noreferrer",children:[t.jsx(R,{size:14}),"Standalone"]})]},s.key)})})]},r.id))}),t.jsxs("section",{className:"tools-directory-cta",children:[t.jsxs("div",{children:[t.jsx("h2",{children:"Need a bigger workspace?"}),t.jsx("p",{children:"MindCanvas is where these small tasks turn into saved canvases, larger document sets, AI workflows, and cloud projects inside MindExec."})]}),t.jsx("button",{type:"button",className:"btn btn-primary",onClick:()=>e("/mindcanvas"),children:"Open MindCanvas"})]})]})}function De({toolKey:e,navigate:n,miniHost:r=!1}){const s=q(e);return s?t.jsx(ge,{tool:s,navigate:n,miniHost:r}):t.jsx("div",{className:"page tools-directory-page",children:t.jsxs("section",{className:"section-head",children:[t.jsx("div",{className:"eyebrow",children:"Tool not found"}),t.jsx("h1",{children:"This local tool is not enabled."}),t.jsx("p",{children:"Open the tools directory and pick one of the current MindExec browser tools."}),t.jsx("div",{className:"action-row",children:t.jsx("button",{className:"btn btn-primary",type:"button",onClick:()=>n("/tools"),children:"Back to tools"})})]})})}function ge({tool:e,navigate:n,miniHost:r}){const[s,o]=m.useState(()=>S(e.kind)),[l,i]=m.useState(""),[c,d]=m.useState(["Pricing proof from a user conversation","Demo clip idea for English-first launch","Competitor headline worth comparing"]),[p,h]=m.useState(null),[B,y]=m.useState(""),T=m.useRef(null),C=m.useRef(null),b=m.useMemo(()=>Ne(e,s,c),[c,s,e]),V=G[e.kind],X=e.relatedKeys.map(a=>q(a)).filter(a=>!!a),z=ve(e.kind),w=e.key==="bulk-markdown-viewer";m.useEffect(()=>{const a=be(e,r);return f.emit("tool.meta.applied",{toolKey:e.key,host:window.location.hostname,miniHost:r,canonical:r?e.liveUrl:`https://mindexec.pages.dev/tools/${e.key}`}),r&&f.emit("tool.hostProfile.applied",{toolKey:e.key,host:window.location.hostname}),a},[r,e]),m.useEffect(()=>{o(S(e.kind)),y(""),h(null)},[e.key,e.kind]);const P=async(a,x,k)=>{try{const u=await oe(x);h(a),f.emit("tool.copy",{toolKey:e.key,ok:!0,method:u,chars:x.length}),window.setTimeout(()=>h(null),1400)}catch(u){const j=k==="source"?T.current:C.current;if(j){j.focus(),j.select(),h(k==="source"?"Source selected":"Output selected"),f.emit("tool.copy",{toolKey:e.key,ok:!1,selected:!0,target:k,message:u instanceof Error?u.message:String(u)});return}h("Copy failed"),f.emit("tool.copy",{toolKey:e.key,ok:!1,target:k,message:u instanceof Error?u.message:String(u)})}},Z=()=>{o(S(e.kind)),y("Sample loaded."),f.emit("tool.sample.loaded",{toolKey:e.key})},J=()=>{o(""),y(""),f.emit("tool.source.cleared",{toolKey:e.key})},O=()=>{ie({toolKey:e.key,toolTitle:e.title,sourceTitle:`${e.label} source`,sourceBody:e.kind==="clipboard"?c.join(`
2
2
 
3
3
  `):s,resultTitle:b.title,resultBody:b.text,taskBody:`Review this ${e.title} output and propose the next concrete step for a global MindExec launch workflow.`}),n("/mindcanvas")},ee=async a=>{const x=Array.from(a.currentTarget.files??[]);if(a.currentTarget.value="",!z||x.length===0)return;const k=x.slice(0,w?12:1),u=k.filter(g=>g.size>W),j=k.filter(g=>g.size<=W);if(j.length===0){y("Selected file is over the 2 MB local preview limit."),f.emit("tool.file.rejected",{toolKey:e.key,reason:"size-limit",count:k.length});return}try{const v=(await Promise.all(j.map(async F=>{const I=(await F.text()).trim();return w?[`# ${F.name}`,"",I].join(`
4
4
  `):I}))).filter(Boolean).join(`
@@ -1,4 +1,4 @@
1
- import{r as i,j as e}from"./vendor-react-BXzpOyCS.js";import{g as H,j as fe,s as M,y as xe,ao as Se,D as we}from"./canvas-runtime-CF8ukxQK.js";import{R as d}from"./app-runtime-xD2Z3NdN.js";import{b as je}from"./toolHandoff-D5e5f7t5.js";import{an as ke,aA as Ce,a_ as te,f as Le,a$ as Te,au as $e,Q as Ne}from"./vendor-icons-DE3gIReG.js";const ae=[{id:"yt-ai-workflow-1",videoId:"mexecAI0001",title:"AI workflow systems for solo founders",channel:"Indie Build Lab",publishedAt:"2026-06-18",duration:"12:34",views:"42,180",url:"https://www.youtube.com/watch?v=mexecAI0001",thumbnailUrl:"/assets/mindexecution-mindcanvas.png",summary:"A practical breakdown of capture, planning, execution, and proof loops for one-person products."},{id:"yt-canvas-ops-2",videoId:"mexecRC0002",title:"Building a visual operating system with React canvas",channel:"Product Runtime",publishedAt:"2026-06-14",duration:"18:09",views:"31,904",url:"https://www.youtube.com/watch?v=mexecRC0002",thumbnailUrl:"/assets/mindexecution-mindcanvas.png",summary:"Covers node layout, local persistence, keyboard workflows, and avoiding heavy runtimes in the browser."},{id:"yt-launch-3",videoId:"mexecLN0003",title:"From prototype to paid users in seven days",channel:"Global SaaS Notes",publishedAt:"2026-06-11",duration:"09:52",views:"88,430",url:"https://www.youtube.com/watch?v=mexecLN0003",thumbnailUrl:"/assets/mindexecution-mindcanvas.png",summary:"Launch checklist focused on proof assets, lead capture, pricing pressure, and distribution sequencing."},{id:"yt-local-first-4",videoId:"mexecLF0004",title:"Local-first web apps that feel instant",channel:"Frontend Engine Room",publishedAt:"2026-06-07",duration:"22:18",views:"17,609",url:"https://www.youtube.com/watch?v=mexecLF0004",thumbnailUrl:"/assets/mindexecution-mindcanvas.png",summary:"Explains local state, cache boundaries, browser storage, and sync contracts for fast product surfaces."},{id:"yt-agent-5",videoId:"mexecAD0005",title:"Agent dashboards for real business execution",channel:"Ops With AI",publishedAt:"2026-06-01",duration:"15:21",views:"56,112",url:"https://www.youtube.com/watch?v=mexecAD0005",thumbnailUrl:"/assets/mindexecution-mindcanvas.png",summary:"Maps agent tasks to approvals, artifacts, execution evidence, and human-gated external actions."}],Be=["relevance","date","viewCount","rating","title"],Ae=["any","day","week","month","year"],Ie=["any","short","medium","long"],Re=["any","live","upcoming","completed"],Ue=["moderate","none","strict"];function qe(a,t){const c=t.toLowerCase(),g=`${a.title} ${a.channel} ${a.summary}`.toLowerCase();return c?c.split(/\s+/).filter(n=>g.includes(n)).length+1:1}function se(a,t,c){return ae.map(n=>({...n,title:a.trim()?`${n.title}: ${a.trim()}`:n.title,score:qe(n,a)})).sort((n,u)=>t==="date"?u.publishedAt.localeCompare(n.publishedAt):t==="viewCount"?Number(u.views.replace(/,/g,""))-Number(n.views.replace(/,/g,"")):t==="title"?n.title.localeCompare(u.title):u.score-n.score).slice(0,c).map(({score:n,...u})=>({...u,source:"sample"}))}function Pe(a){return a.map((t,c)=>[`${c+1}. ${t.title}`,` - Channel: ${t.channel}`,` - Published: ${t.publishedAt}`,` - Duration: ${t.duration}`,` - Views: ${t.views}`,` - URL: ${t.url}`,t.thumbnailUrl?` - Thumbnail: ${t.thumbnailUrl}`:"",` - Note: ${t.summary}`].filter(Boolean).join(`
1
+ import{r as i,j as e}from"./vendor-react-BXzpOyCS.js";import{g as H,j as fe,s as M,y as xe,ao as Se,D as we}from"./canvas-runtime-Bc1G-FZ_.js";import{R as d}from"./app-runtime-xD2Z3NdN.js";import{b as je}from"./toolHandoff-D5e5f7t5.js";import{an as ke,aA as Ce,a_ as te,f as Le,a$ as Te,au as $e,Q as Ne}from"./vendor-icons-DE3gIReG.js";const ae=[{id:"yt-ai-workflow-1",videoId:"mexecAI0001",title:"AI workflow systems for solo founders",channel:"Indie Build Lab",publishedAt:"2026-06-18",duration:"12:34",views:"42,180",url:"https://www.youtube.com/watch?v=mexecAI0001",thumbnailUrl:"/assets/mindexecution-mindcanvas.png",summary:"A practical breakdown of capture, planning, execution, and proof loops for one-person products."},{id:"yt-canvas-ops-2",videoId:"mexecRC0002",title:"Building a visual operating system with React canvas",channel:"Product Runtime",publishedAt:"2026-06-14",duration:"18:09",views:"31,904",url:"https://www.youtube.com/watch?v=mexecRC0002",thumbnailUrl:"/assets/mindexecution-mindcanvas.png",summary:"Covers node layout, local persistence, keyboard workflows, and avoiding heavy runtimes in the browser."},{id:"yt-launch-3",videoId:"mexecLN0003",title:"From prototype to paid users in seven days",channel:"Global SaaS Notes",publishedAt:"2026-06-11",duration:"09:52",views:"88,430",url:"https://www.youtube.com/watch?v=mexecLN0003",thumbnailUrl:"/assets/mindexecution-mindcanvas.png",summary:"Launch checklist focused on proof assets, lead capture, pricing pressure, and distribution sequencing."},{id:"yt-local-first-4",videoId:"mexecLF0004",title:"Local-first web apps that feel instant",channel:"Frontend Engine Room",publishedAt:"2026-06-07",duration:"22:18",views:"17,609",url:"https://www.youtube.com/watch?v=mexecLF0004",thumbnailUrl:"/assets/mindexecution-mindcanvas.png",summary:"Explains local state, cache boundaries, browser storage, and sync contracts for fast product surfaces."},{id:"yt-agent-5",videoId:"mexecAD0005",title:"Agent dashboards for real business execution",channel:"Ops With AI",publishedAt:"2026-06-01",duration:"15:21",views:"56,112",url:"https://www.youtube.com/watch?v=mexecAD0005",thumbnailUrl:"/assets/mindexecution-mindcanvas.png",summary:"Maps agent tasks to approvals, artifacts, execution evidence, and human-gated external actions."}],Be=["relevance","date","viewCount","rating","title"],Ae=["any","day","week","month","year"],Ie=["any","short","medium","long"],Re=["any","live","upcoming","completed"],Ue=["moderate","none","strict"];function qe(a,t){const c=t.toLowerCase(),g=`${a.title} ${a.channel} ${a.summary}`.toLowerCase();return c?c.split(/\s+/).filter(n=>g.includes(n)).length+1:1}function se(a,t,c){return ae.map(n=>({...n,title:a.trim()?`${n.title}: ${a.trim()}`:n.title,score:qe(n,a)})).sort((n,u)=>t==="date"?u.publishedAt.localeCompare(n.publishedAt):t==="viewCount"?Number(u.views.replace(/,/g,""))-Number(n.views.replace(/,/g,"")):t==="title"?n.title.localeCompare(u.title):u.score-n.score).slice(0,c).map(({score:n,...u})=>({...u,source:"sample"}))}function Pe(a){return a.map((t,c)=>[`${c+1}. ${t.title}`,` - Channel: ${t.channel}`,` - Published: ${t.publishedAt}`,` - Duration: ${t.duration}`,` - Views: ${t.views}`,` - URL: ${t.url}`,t.thumbnailUrl?` - Thumbnail: ${t.thumbnailUrl}`:"",` - Note: ${t.summary}`].filter(Boolean).join(`
2
2
  `)).join(`
3
3
 
4
4
  `)}function De(a){return a.map(t=>({id:t.id,kind:"youtube-video",title:t.title,url:t.url,videoId:t.videoId,thumbnailUrl:t.thumbnailUrl,summary:t.summary,channel:t.channel,publishedAt:t.publishedAt,duration:t.duration,views:t.views,source:t.source||"sample"}))}function Ye(a){if(!a)return"-";const t=Date.parse(a);return Number.isFinite(t)?new Date(t).toISOString().slice(0,10):a}function Ee(a){return typeof a!="number"||!Number.isFinite(a)?"-":a.toLocaleString("en-US")}function ze(a){const t=String(a.videoId||"").trim(),c=String(a.title||"").trim();if(!t||!c)return null;const g=String(a.url||"").trim()||`https://www.youtube.com/watch?v=${t}`,n=String(a.channelTitle||"").trim()||"Unknown channel",u=String(a.durationText||a.duration||"").trim()||"-",y=Ye(a.publishedAt),C=Ee(a.viewCount);return{id:t,videoId:t,title:c,channel:n,publishedAt:y,duration:u,views:C,url:g,thumbnailUrl:String(a.thumbnailUrl||"").trim()||void 0,summary:`Live YouTube result from ${n}. Published ${y}; duration ${u}; views ${C}.`,source:"bridge"}}function Fe(){return{state:M()?"idle":"blocked",baseUrl:H(),message:M()?"LocalBridge not checked yet.":"Hosted LocalBridge access is gated."}}function Qe({navigate:a}){const t=i.useRef(0),[c,g]=i.useState(()=>H()),[n,u]=i.useState(()=>Fe()),[y,C]=i.useState("AI workflow for solo founders"),[L,ne]=i.useState("relevance"),[$,re]=i.useState("any"),[N,oe]=i.useState("any"),[B,ie]=i.useState("any"),[A,le]=i.useState("moderate"),[I,ce]=i.useState("en"),[R,ue]=i.useState("US"),[U,de]=i.useState(10),[m,O]=i.useState(()=>se("AI workflow for solo founders","relevance",5)),[q,v]=i.useState(()=>new Set(["yt-ai-workflow-1"])),[be,f]=i.useState("Local sample results loaded. Search will use LocalBridge /api/youtube/search on loopback or after enabling local bridge access."),[T,P]=i.useState(!1),[w,W]=i.useState("sample"),[V,Q]=i.useState(""),[_,G]=i.useState(""),[K,J]=i.useState(!1),[X,Z]=i.useState(""),D=i.useMemo(()=>m.filter(s=>q.has(s.id)),[m,q]),Y=(s,l="fallback",r)=>{const b=(r==null?void 0:r.query)??y,x=(r==null?void 0:r.order)??L,o=(r==null?void 0:r.maxResults)??U,S=se(b,x,Math.min(o,ae.length));O(S),v(new Set),W(l),Q(""),G(""),J(!1),Z(""),f(s)},E=async(s,l="")=>{s==null||s.preventDefault();const r=y.trim();if(!r){f("Enter a query before searching.");return}const b=t.current+1;t.current=b;const x=()=>t.current===b,o={query:r,order:L,publishedWithin:$,videoDuration:N,eventType:B,safeSearch:A,language:I.trim(),region:R.trim(),maxResults:U};P(!0);const S=H();if(g(S),d.emit("youtube.search.local",{requestSeq:b,q:o.query,order:o.order,pageToken:!!l}),!M()){u({state:"blocked",baseUrl:S,message:"Hosted LocalBridge access is gated."}),Y("Hosted LocalBridge access is gated. Showing local sample results only.","blocked",o),d.emit("youtube.search.fallback",{requestSeq:b,reason:"hosted-localbridge-gated",order:o.order,publishedWithin:o.publishedWithin,videoDuration:o.videoDuration,eventType:o.eventType,safeSearch:o.safeSearch,language:o.language,region:o.region}),P(!1);return}try{const p=await xe(S);if(!x()){d.emit("youtube.search.staleIgnored",{requestSeq:b,stage:"bridge-status"});return}if(u(p),p.state!=="connected"){Y(`${p.message||"LocalBridge is unavailable."} Showing local sample results.`,"fallback",o),d.emit("youtube.search.fallback",{requestSeq:b,reason:"localbridge-unavailable",state:p.state});return}const h=await Se({q:o.query,order:o.order,publishedWithin:o.publishedWithin,videoDuration:o.videoDuration,eventType:o.eventType,safeSearch:o.safeSearch,relevanceLanguage:o.language,regionCode:o.region,maxResults:o.maxResults,pageToken:l},S);if(!x()){d.emit("youtube.search.staleIgnored",{requestSeq:b,stage:"bridge-results"});return}const j=(h.items||[]).map(ze).filter(z=>!!z);O(j),v(l?z=>new Set(j.filter(F=>z.has(F.id)).map(F=>F.id)):new Set),Q(String(h.nextPageToken||"")),G(String(h.prevPageToken||"")),J(h.fromCache===!0),Z(h.fetchedAt||new Date().toISOString()),W("bridge"),f(j.length>0?`Live YouTube search complete: ${j.length} results${h.fromCache?" from cache":""}.`:"Live YouTube search returned no videos."),d.emit("youtube.search.bridge",{requestSeq:b,count:j.length,fromCache:h.fromCache===!0,hasNext:!!h.nextPageToken,hasPrevious:!!h.prevPageToken})}catch(p){if(!x()){d.emit("youtube.search.staleIgnored",{requestSeq:b,stage:"bridge-error"});return}const h=p instanceof Error?p.message:String(p);Y(`${h} Showing local sample results.`,"fallback",o),d.emit("youtube.search.fallback",{requestSeq:b,reason:"bridge-search-error",message:h})}finally{x()&&P(!1)}},he=()=>{we(!0),u({state:"idle",baseUrl:c,message:"Hosted LocalBridge access enabled. Search again to use the live adapter."}),f("Hosted LocalBridge access enabled. Search again to use LocalBridge /api/youtube/search."),d.emit("youtube.bridge.hostedAccess.enabled")},ge=s=>{v(l=>{const r=new Set(l);return r.has(s)?r.delete(s):r.add(s),d.emit("youtube.selection.changed",{count:r.size}),r})},me=()=>{v(new Set(m.map(s=>s.id))),d.emit("youtube.selection.all",{count:m.length})},pe=()=>{v(new Set),d.emit("youtube.selection.clear")},ee=s=>{const l=s==="selected"?D:m;if(l.length===0){f("Select at least one video before creating MindCanvas nodes.");return}const r=Pe(l);je({toolKey:"youtube-search",toolTitle:"YouTube Search",sourceTitle:`YouTube search: ${y.trim()}`,sourceBody:`Filters: order=${L}, period=${$}, duration=${N}, event=${B}, safe=${A}, lang=${I}, region=${R}`,resultTitle:`${l.length} YouTube candidates`,resultBody:r,taskBody:"Turn these YouTube candidates into a MindExec content or research plan. Extract buyer pain, proof angles, and next launch asset ideas.",resultItems:De(l)}),d.emit("youtube.nodes.created",{mode:s,count:l.length}),f(`${l.length} video records prepared for MindCanvas handoff.`),a("/mindcanvas")},ye=n.state==="connected"?"live adapter":n.state==="blocked"?"bridge gated":n.state==="unavailable"?"bridge unavailable":"local bridge ready",ve=w==="bridge"?K?"live cache":"live":w==="blocked"?"gated sample":w==="fallback"?"fallback sample":"sample";return e.jsxs("div",{className:"page youtube-page","data-youtube-bridge-state":n.state,"data-youtube-result-source":w,children:[e.jsxs("section",{className:"youtube-hero",children:[e.jsxs("div",{children:[e.jsx("div",{className:"eyebrow",children:"Content Capture"}),e.jsx("h1",{children:"YouTube Search"}),e.jsx("p",{children:"Search, filter, select, and send video candidates into MindCanvas as research nodes. Live search runs through the LocalBridge YouTube proxy when local bridge access is available."})]}),e.jsx("span",{className:`youtube-badge youtube-badge--${w}`,"data-testid":"youtube-result-source",children:ve})]}),e.jsxs("form",{className:"youtube-search-panel","data-testid":"youtube-search-form",onSubmit:s=>void E(s),children:[e.jsxs("div",{className:"youtube-query-row",children:[e.jsx("input",{"data-testid":"youtube-query-input","aria-label":"YouTube query",value:y,onChange:s=>C(s.target.value),placeholder:"Search terms"}),e.jsxs("button",{className:"btn btn-primary","data-testid":"youtube-search-submit",type:"submit",disabled:T,children:[T?e.jsx(ke,{size:16,className:"spin-icon"}):e.jsx(Ce,{size:16}),"Search"]})]}),e.jsxs("div",{className:"youtube-filter-grid",children:[e.jsx(k,{label:"Order",value:L,options:Be,onChange:ne}),e.jsx(k,{label:"Period",value:$,options:Ae,onChange:re}),e.jsx(k,{label:"Duration",value:N,options:Ie,onChange:oe}),e.jsx(k,{label:"Live",value:B,options:Re,onChange:ie}),e.jsx(k,{label:"Safe search",value:A,options:Ue,onChange:le}),e.jsxs("label",{children:["Language",e.jsx("input",{maxLength:8,value:I,onChange:s=>ce(s.target.value)})]}),e.jsxs("label",{children:["Region",e.jsx("input",{maxLength:4,value:R,onChange:s=>ue(s.target.value)})]}),e.jsxs("label",{children:["Count",e.jsxs("select",{value:U,onChange:s=>de(Number(s.target.value)),children:[e.jsx("option",{value:"5",children:"5"}),e.jsx("option",{value:"10",children:"10"}),e.jsx("option",{value:"25",children:"25"})]})]})]})]}),e.jsxs("section",{className:"youtube-banner","data-testid":"youtube-status-banner",children:[e.jsx(te,{size:18}),e.jsxs("span",{children:[be,e.jsxs("small",{children:[ye,X?`, fetched ${new Date(X).toLocaleTimeString()}`:""]})]}),n.state==="blocked"&&!fe()&&e.jsx("button",{className:"btn btn-secondary","data-testid":"youtube-enable-local-bridge",type:"button",onClick:he,children:"Enable local bridge"})]}),e.jsxs("section",{className:"youtube-actions-row",children:[e.jsxs("div",{children:[e.jsxs("strong",{children:[m.length," results"]}),e.jsxs("span",{children:[D.length," selected",K?" (cache)":""]})]}),e.jsxs("div",{className:"youtube-actions",children:[e.jsx("button",{className:"btn btn-secondary","data-testid":"youtube-select-visible",type:"button",onClick:me,children:"Select visible"}),e.jsx("button",{className:"btn btn-secondary","data-testid":"youtube-clear-selection",type:"button",onClick:pe,children:"Clear"}),e.jsxs("button",{className:"btn btn-primary","data-testid":"youtube-send-selected",type:"button",onClick:()=>ee("selected"),disabled:D.length===0,children:[e.jsx(Le,{size:15}),"Send selected"]}),e.jsx("button",{className:"btn btn-primary","data-testid":"youtube-send-all",type:"button",onClick:()=>ee("all"),disabled:m.length===0,children:"Send all"})]})]}),e.jsxs("section",{className:"youtube-pagination","aria-label":"YouTube result pages",children:[e.jsx("button",{className:"btn btn-secondary",type:"button",onClick:()=>void E(void 0,_),disabled:T||!_,children:"Previous"}),e.jsx("button",{className:"btn btn-secondary",type:"button",onClick:()=>void E(void 0,V),disabled:T||!V,children:"Next"})]}),e.jsx("section",{className:"youtube-results-grid",children:m.map((s,l)=>{const r=q.has(s.id);return e.jsxs("article",{className:`youtube-card ${r?"is-selected":""}`,"data-testid":"youtube-result-card","data-video-id":s.videoId||"",children:[e.jsxs("div",{className:"youtube-card-top",children:[e.jsxs("button",{className:"youtube-select-button","data-testid":"youtube-result-select",type:"button",onClick:()=>ge(s.id),"aria-label":`${r?"Unselect":"Select"} ${s.title}`,children:[r?e.jsx(Te,{size:17}):e.jsx($e,{size:17}),r?"Selected":"Select"]}),e.jsxs("a",{href:s.url,target:"_blank",rel:"noreferrer",children:[e.jsx(Ne,{size:15}),"YouTube"]})]}),e.jsxs("div",{className:"youtube-thumb",children:[s.thumbnailUrl?e.jsx("img",{src:s.thumbnailUrl,alt:"",loading:"lazy"}):e.jsx(te,{size:34}),e.jsx("span",{children:String(l+1).padStart(2,"0")})]}),e.jsx("h2",{children:s.title}),e.jsx("p",{children:s.summary}),e.jsxs("div",{className:"youtube-meta",children:[e.jsx("span",{children:s.channel}),e.jsx("span",{children:s.publishedAt}),e.jsx("span",{children:s.duration}),e.jsxs("span",{children:[s.views," views"]})]})]},s.id)})})]})}function k({label:a,value:t,options:c,onChange:g}){return e.jsxs("label",{children:[a,e.jsx("select",{value:t,onChange:n=>g(n.target.value),children:c.map(n=>e.jsx("option",{value:n,children:n},n))})]})}export{Qe as YouTubeSearchPage};