PageSourceSearch

https://www.dealkeep.io/assets/AddToolTabs-DurCIrf-.js

js dealkeep.io collected 2026-10-02 00:05:07 UTC 46,855 bytes, 1 lines download raw bytes

1import{f as Fe,j as e,L as Je,r as d}from"./vendor-react-Dqm4a0k5.js";import{T as Ze,a as es,b as ee,c as se}from"./ComprehensiveEmailSystemTester-Bl9mskwR.js";import{B as C,u as ss,C as ue,e as ts,f as as,h as rs,a as xe,g as Q,s as G,J as P,S as ns,y as X,z as J,c as I}from"./index-DsUIL5GE.js";import{u as is,a as ls,F as os,D as cs,t as ds,b as ye,c as T,d as _,e as A,f as D,g as E,h as ms,Q as ve,i as Ne,C as us}from"./ConsoleAddTools-DGIl5W7q.js";import{u as Ie,i as xs}from"./toolIcon-YB1AsfrO.js";import{C as hs,L as te}from"./useSupportTickets-CnThGNgw.js";import{ao as ie,ap as ps,ae as fs,aj as gs,Z as he,af as js,g as bs,d as ys,bh as vs,T as Z,L as W,a3 as Ns,aE as ws,U as le,E as Le,s as we,Q as Cs,r as Ss,D as ks,au as Ts,aa as _s,v as As,b5 as Ds,q as Ce,A as Se,b as ae,w as Rs,f as Pe,av as Es,bb as Fs,bi as Is,aQ as Ls,aw as ke,l as Ps,_ as Us,b1 as Ue,bj as Vs,bk as zs}from"./vendor-icons-Dv6Y7wXg.js";import{C as Te}from"./ChromeExtensionPairingCard-BM8cNNUe.js";import{A as Os,a as Ms,b as Bs,c as qs,d as Ys,e as $s,f as Ks,g as Hs,C as Qs}from"./CategoryPicker-BkyA6_xL.js";import{u as Ws}from"./MobilePageTransitionAnimated-DWrSTtDD.js";import{F as _e,s as Gs,j as Xs,a as Js,I as Zs,J as et,K as st}from"./FullShell-BTCb9qm-.js";import{S as oe,a as ce,b as de,c as me,d as q,g as tt}from"./categories-CnNOkcF1.js";import{I as H}from"./validation-CGvnU7tg.js";import{b as at,u as rt}from"./useTeamTools-D9TZe2kJ.js";import{u as nt}from"./useUnifiedToolsData-ErNYeZbC.js";import{u as it}from"./useDebounce-DCfSo_dz.js";import{a as lt}from"./vendor-utils-KLhAiGEE.js";import{T as ot}from"./placeholderStyles-CdYy8nri.js";import{a as ct,u as dt}from"./use-toast-BNXfqiu9.js";import{R as mt,a as Ae}from"./EditAvgCostDialog-enn5ipJB.js";import{A as ut,m as xt}from"./vendor-motion-uI1IlCbt.js";import{o as ht,s as L,e as De,Z as re}from"./types-BWQbS8eK.js";import{S as pt,a as ft,c as gt,d as jt,e as bt,f as yt}from"./bulkCategorize-CdHQZGGC.js";import{S as vt}from"./licenseCodes-B5ZGh3nu.js";import"./vendor-radix-DFc8vCWX.js";import"./radix-react-compose-refs-IIetlP92.js";import"./radix-react-slot-CrO6XSQS.js";import"./vendor-supabase-RijQlDjE.js";import"./vendor-query-BQV4-hhd.js";import"./shimmer-BjVfa2M3.js";import"./TrialEndedToast-ZIBSGSVL.js";import"./ScreenshotAttachments-CtJpF-IN.js";import"./ConsoleKit-bxgSP4de.js";import"./command-a-V8Ol3i.js";import"./useOwnedToolCount-CYnp2XgJ.js";import"./usePlanLimitedData-CvjlhalW.js";function Re(){const{canAccessChromeExtension:n}=Ie(),i=Fe(),o=()=>{if(!n){i("/app/settings/section?section=billing");return}window.open(hs,"_blank","noopener,noreferrer")};return e.jsxs("div",{className:"border-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10 rounded-lg p-8 text-center space-y-6",children:[e.jsx("div",{className:"flex items-center justify-center gap-2 mb-2",children:e.jsx("div",{className:"bg-gradient-to-br from-primary to-primary/80 p-3 rounded-xl",children:e.jsx(ie,{className:"h-6 w-6 text-primary-foreground"})})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"DealKeep Chrome Extension"}),e.jsxs("p",{className:"text-sm text-muted-foreground max-w-md mx-auto mb-3",children:["The ",e.jsx("span",{className:"font-semibold text-primary",children:"recommended way"})," for AppSumo users to import their purchases. One-click import, automatic sync, and smart deadline tracking."]}),e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-full bg-amber-100/50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800",children:[e.jsx(ps,{className:"h-3.5 w-3.5 text-amber-600 dark:text-amber-400"}),e.jsx("span",{className:"text-xs font-medium text-amber-700 dark:text-amber-300",children:"Currently optimized for AppSumo • More platforms coming soon"})]})]}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(fs,{className:"h-4 w-4 text-primary"}),e.jsx("span",{children:"One-click import"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(gs,{className:"h-4 w-4 text-primary"}),e.jsx("span",{children:"Auto-sync"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(he,{className:"h-4 w-4 text-primary"}),e.jsx("span",{children:"Smart detection"})]})]}),e.jsx("div",{className:"space-y-3",children:n?e.jsxs(e.Fragment,{children:[e.jsxs(C,{onClick:o,size:"lg",className:"gap-2",children:[e.jsx(ie,{className:"h-4 w-4"}
1),"Install Extension",e.jsx(js,{className:"h-4 w-4"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Works with your AppSumo account"})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-4 py-2 rounded-full bg-amber-100/80 dark:bg-amber-900/30 border border-amber-200 dark:border-amber-800",children:[e.jsx(bs,{className:"h-4 w-4 text-amber-600 dark:text-amber-400"}),e.jsx("span",{className:"text-sm font-medium text-amber-700 dark:text-amber-300",children:"Starter or Pro plan required"})]}),e.jsxs(C,{onClick:()=>i("/app/settings/section?section=billing"),size:"lg",className:"gap-2",variant:"default",children:[e.jsx(ys,{className:"h-4 w-4"}),"Upgrade to Access"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Chrome extension is available on Starter and Pro plans"})]})}),e.jsx("div",{className:"border-t border-primary/10 my-2"}),e.jsxs("div",{className:"text-left space-y-4",children:[e.jsx("h4",{className:"font-semibold text-base text-center",children:"How to Install & Import Your Tools"}),e.jsx("ol",{className:"space-y-3 text-sm",children:[e.jsxs(e.Fragment,{children:["Log in to DealKeep and go to ",e.jsx("strong",{children:"Tools → Chrome Install"})," to download the Chrome extension."]}),e.jsxs(e.Fragment,{children:["Open your ",e.jsx("a",{href:"https://appsumo.com/account/products/",target:"_blank",rel:"noopener noreferrer",className:"text-primary underline underline-offset-2 hover:text-primary/80",children:"AppSumo products page"})," and click the DealKeep extension icon in your browser toolbar."]}),e.jsxs(e.Fragment,{children:["Confirm the extension is connected to the correct DealKeep account.",e.jsxs("ul",{className:"mt-1.5 ml-5 space-y-1 text-muted-foreground list-disc",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Starter"})," supports ",e.jsx("strong",{children:"1"})," account connection"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Pro"})," supports up to ",e.jsx("strong",{children:"5"})," account connections"]})]})]}),e.jsxs(e.Fragment,{children:["Return to your AppSumo active products page and click ",e.jsx("strong",{children:'"Scrape All Tools"'})," in the extension popup to import your active tools into DealKeep."]}),e.jsxs(e.Fragment,{children:["After the import, the extension keeps working for a few more minutes, linking each tool to its official website — a ",e.jsx("strong",{children:"progress counter on the AppSumo page"})," shows how much time is left. Keep that tab open until it says ",e.jsx("strong",{children:'"Full import completed ✅"'})," (you can browse in other tabs meanwhile). Closing early is safe; unreached tools keep their AppSumo link until your next import."]}),e.jsxs(e.Fragment,{children:["If your tools do not appear in DealKeep, refresh your browser. If they still do not appear, check that the extension is not connected to a different email address, especially on the ",e.jsx("strong",{children:"Pro"})," plan."]}),e.jsxs(e.Fragment,{children:["If you still see errors or missing tools, contact support through the ",e.jsx(Je,{to:"/app/help",className:"text-primary underline underline-offset-2 hover:text-primary/80",children:"Help & Support"})," or email ",e.jsx("a",{href:"mailto:[email protected]",className:"text-primary underline underline-offset-2 hover:text-primary/80",children:"[email protected]"}),"."]})].map((g,x)=>e.jsxs("li",{className:"flex gap-3",children:[e.jsx("span",{className:"flex-shrink-0 w-6 h-6 rounded-full bg-primary/10 text-primary text-xs font-semibold flex items-center justify-center mt-0.5",children:x+1}),e.jsx("span",{className:"text-muted-foreground",children:g})]},x))})]})]})}function Ee(){const{user:n}=ss(),{plan:i}=Ws(),[o,g]=d.useState([]),[x,y]=d.useState(!0),[v,p]=d.useState(null),[h,m]=d.useState(null),[u,S]=d.useState(null),F=async()=>{if(!n)return;y(!0);const{data:t,error:N}=await G.from("extension_devices").select("id, device_public_id, device_name, last_seen_at, status, plan_snapshot, browser_info, user_agent").eq("user_id",n.id).is("revoked_at",null).eq("status","active").order("last_seen_at",{ascending:!1});N?console.warn("Failed to fetch extension devices:",N):g(t||[]),y(!1)},b=async()=>
1{if(!n)return;const{count:t}=await G.from("appsumo_products").select("*",{count:"exact",head:!0}).eq("user_id",n.id);S(t??0)};d.useEffect(()=>{F(),b()},[n?.id]);const w=t=>{m(t)},U=async t=>{if(n){p(t),m(null);try{const{data:{session:N}}=await G.auth.getSession();if(!N?.access_token){P.error("Not signed in. Please log in and try again."),p(null);return}const f=await fetch(`${ns}/functions/v1/extension-revoke-device`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${N.access_token}`},body:JSON.stringify({device_id:t,delete_products:!0})}),a=await f.json().catch(()=>({}));if(!f.ok||!a.ok)P.error(a.error||"Failed to remove device.");else{const z=a.products_deleted??0;P.success(z>0?`Device removed and ${z} imported product${z===1?"":"s"} deleted.`:"Device removed. The extension will lose access."),g($=>$.filter(O=>O.id!==t)),S($=>$!=null?Math.max(0,$-z):null)}}catch{P.error("Network error removing device.")}p(null)}},Y=t=>{try{return new Date(t).toLocaleString(void 0,{dateStyle:"short",timeStyle:"short"})}catch{return t}},V=t=>!t||t.length<=12?t:t.slice(0,6)+"…"+t.slice(-4);return n?e.jsxs(e.Fragment,{children:[e.jsxs(ue,{className:"clay-card border-0",children:[e.jsxs(ts,{children:[e.jsxs(as,{className:"flex items-center gap-2",children:[e.jsx(vs,{className:"h-5 w-5"}),"Extension devices"]}),e.jsx(rs,{children:"Each DealKeep account pairs with one Chrome extension at a time. Removing or unpairing a device permanently deletes every imported tool from your Tools page and from Earn from Your Stack."})]}),e.jsxs(xe,{children:[!x&&o.length>0&&e.jsxs("div",{role:"note","data-testid":"extension-unpair-warning",className:"mb-3 flex items-start gap-2 rounded-md border border-destructive/30 bg-destructive/10 p-3 text-sm",children:[e.jsx(Z,{className:"mt-0.5 h-4 w-4 shrink-0 text-destructive","aria-hidden":"true"}),e.jsxs("p",{children:[e.jsxs("strong",{children:["Removing or unpairing this extension deletes all",u!=null&&u>0?` ${u}`:""," of your tools"]})," ","— from the Tools page and from Earn from Your Stack. This cannot be undone. Export your tools first if you need a copy."]})]}),x&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(W,{className:"h-4 w-4 animate-spin"})," Loading devices…"]}),!x&&o.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No paired devices."}),!x&&o.length>0&&e.jsx("div",{className:"space-y-3",children:o.map(t=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-muted/30 border",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium",children:t.device_name||"Chrome Extension"}),e.jsx(Q,{variant:"outline",className:"text-xs",children:t.status}),i&&e.jsx(Q,{variant:"secondary",className:"text-xs capitalize",children:i.toLowerCase()})]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(Ns,{className:"h-3 w-3"}),e.jsx("span",{children:n.email})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["ID: ",V(t.device_public_id)," · Last active: ",Y(t.last_seen_at)]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"hidden text-right text-xs text-destructive sm:block","data-testid":"extension-unpair-note",children:["Removing deletes all tools",e.jsx("br",{}),"(Tools + Earn from Your Stack)"]}),e.jsx(C,{variant:"ghost",size:"sm",onClick:()=>w(t),disabled:v===t.id,className:"text-destructive hover:text-destructive",title:"Remove device — deletes all tools from the Tools page and Earn from Your Stack",children:v===t.id?e.jsx(W,{className:"h-4 w-4 animate-spin"}):e.jsx(ws,{className:"h-4 w-4"})})]})]},t.id))})]})]}),e.jsx(Os,{open:!!h,onOpenChange:()=>m(null),children:e.jsxs(Ms,{children:[e.jsxs(Bs,{children:[e.jsxs(qs,{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"h-5 w-5 text-destructive"}),"Remove extension device?"]}),e.jsx(Ys,{asChild:!0,children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("p",{children:["You are about to remove the extension device",h?.device_name?` "${h.device_name}"`:""," paired to ",e.jsx("strong",{children:n.email}),"."]}),e.jsxs("div",{className:"rounded-md bg-destructive/10 border border-destructive/20 p-3 text-sm",children:[e.jsx("strong",{children:"Warning:"})," Removing this extension permanently deletes",u!=null&&u>0?` all ${u} of your tools`:" all of your tools"," ","— from the Tools page and from Earn from Your Stack. This action cannot be undone."]}),e.jsx("p",{className:"text-sm",children:"The extension will be immediately disconnected and will need to be re-paired to import products again."})]})})]}),e.jsxs($s,{children:[e.jsx(Ks,{children:"Cancel"}),e.jsx(Hs,{variant:"destructive",onClick:()=>h&&U(h.id),children:"Remove device & delete products"})]})]})})]}):null}
1function ne(){const[n,i]=d.useState(""),[o,g]=d.useState([]),[x,y]=d.useState(!1),v=it(n,300),{userTeams:p,selectedTeam:h,userRole:m,canManageTools:u,setSelectedTeam:S,addUnifiedToolsToTeam:F}=at(),{data:b}=nt({search:v,limit:1e3,skipPlanLimit:!0}),w=b?.tools??[],U=t=>{g(N=>N.includes(t)?N.filter(f=>f!==t):[...N,t])},Y=()=>{o.length===w.length?g([]):g(w.map(t=>t.id))},V=async()=>{if(!(o.length===0||!h)){y(!0);try{const t=w.filter(f=>o.includes(f.id)).map(f=>({id:f.id,type:f.type,name:f.name,description:f.description,url:f.url,image:f.image,category:f.category,status:f.status,price:f.price,purchase_date:f.purchase_date,refund_deadline:f.refund_deadline,redemption_deadline:f.redemption_deadline})),N=await F(t);N.added>0?(P.success(`Added ${N.added} tools to team`),N.skipped>0&&P.info(`Skipped ${N.skipped} tools already in team`),g([])):N.skipped>0&&P.info("All selected tools are already in the team")}catch{P.error("Failed to add tools to team")}finally{y(!1)}}};return p.length===0?e.jsx("div",{className:"bg-card rounded-lg border p-8",children:e.jsxs("div",{className:"text-center py-16",children:[e.jsx(le,{className:"h-12 w-12 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Teams Available"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"You're not a member of any teams yet. Create or join a team to start sharing tools."})]})}):e.jsxs("div",{className:"bg-card rounded-lg border p-8",children:[e.jsxs("div",{className:"mb-8 text-center",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Add Tools to Team"}),e.jsx("p",{className:"text-muted-foreground",children:"Select tools from your personal library to share with your team"})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(te,{htmlFor:"team-select",children:"Select Team"}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs(oe,{value:h,onValueChange:S,children:[e.jsx(ce,{className:"w-64",id:"team-select",children:e.jsx(de,{placeholder:"Choose a team"})}),e.jsx(me,{children:p.map(t=>e.jsx(q,{value:t.id,children:t.name},t.id))})]}),m&&e.jsxs(Q,{variant:m==="VIEWER"?"secondary":"outline",className:"flex items-center gap-1",children:[e.jsx(Le,{className:"w-3 h-3"}),m.toLowerCase()]})]})]}),!u&&h&&e.jsxs(X,{children:[e.jsx(we,{className:"h-4 w-4"}),e.jsx(J,{children:"You don't have permission to add tools to this team. Only team owners, admins, and members can add tools."})]}),u&&h&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(te,{htmlFor:"search",children:"Search Your Tools"}),e.jsxs("div",{className:"relative",children:[e.jsx(Cs,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground h-4 w-4"}),e.jsx(H,{id:"search",placeholder:"Search your personal tools...",value:n,onChange:t=>i(t.target.value),className:"pl-10"})]})]}),e.jsx("div",{className:"space-y-4",children:w.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"w-16 h-16 bg-muted rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(Ss,{className:"h-8 w-8 text-muted-foreground"})}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Personal Tools Found"}),e.jsx("p",{className:"text-muted-foreground",children:n?"No tools match your search.":"You don't have any personal tools yet."}),!n&&e.jsx("p",{className:"text-muted-foreground mt-2",children:"Add some tools to your personal library first, then come back to share them with your team."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(_e,{id:"select-all",checked:o.length===w.length,onCheckedChange:Y}),e.jsxs(te,{htmlFor:"select-all",className:"text-sm font-medium",children:["Select All (",w.length," tools)"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[o.length," selected"]}),e.jsx(C,{onClick:V,disabled:o.length===0||x,size:"sm",children:x?"Adding...":`Add ${o.length} to Team`})]})]}),e.jsx("div",{className:"space-y-3 max-h-96 overflow-y-auto",children:w.map(t=>e.jsx(ue,{className:"relative",children:e.jsx(xe,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx(_e,{id:`tool-${t.id}`,checked:o.includes(t.id),onCheckedChange:()=>U(t.id),className:"mt-1"}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex-1",children:[e.jsx("h4",{className:"font-medium text-foreground",children:t.name}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mt-1",children:t.description}),e.jsxs("div",{className:"flex items-center gap-4 mt-3",children:[t.category&&e.jsx(Q,{variant:"secondary",className:"text-xs",children:t.category}),t.status&&e.jsx(Q,{variant:"outline",className:"text-xs whitespace-nowrap",children:Gs(t.status,t.refund_deadline)}),t.price&&e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(ks,{className:"w-3 h-3"}),"$",t.price]}),t.purchase_date&&e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(Ts,{className:"w-3 h-3"}),lt(new Date(t.purchase_date),{addSuffix:!0})]})]})]})})})]})})},t.id))})]})})]}),!h&&e.jsxs(X,{children:[e.jsx(we,{className:"h-4 w-4"}),e.jsx(J,{children:"Please select a team to continue adding tools."})]})]})]})}const B=(n="light")=>{if("vibrate"in navigator){const i={light:10,medium:25,heavy:50,success:[10,50,10],error:[50,30,50]};navigator.vibrate(i[n])}},Nt=(n,i,o={})=>{const{threshold:g=50,enabled:x=!0}=o,y=d.useRef(null),v=d.useRef(null),p=d.useRef(null),h=d.useCallback(u=>{x&&(y.current=u.touches[0].clientX,v.current=u.touches[0].clientY)},[x]),m=d.useCallback(u=>{if(!x||y.current===null||v.current===null)return;const S=u.changedTouches[0].clientX,F=u.changedTouches[0].clientY,b=S-y.current,w=F-v.current;Math.abs(b)>Math.abs(w)&&Math.abs(b)>g&&(b>0?i():n()),y.current=null,v.current=null},[x,g,n,i]);return d.useEffect(()=>{const u=p.current;if(u)return u.addEventListener("touchstart",h,{passive:!0}),u.addEventListener("touchend",m,{passive:!0}),()=>{u.removeEventListener("touchstart",h),u.removeEventListener("touchend",m)}},[h,m]),p},K=[{id:"url",label:"URL",icon:_s,description:"Enter tool URL"},{id:"details",label:"Details",icon:As,description:"Tool information"},{id:"category",label:"Category",icon:Ds,description:"Categorization"},{id:"review",label:"Review",icon:Le,description:"Confirm & submit"}],wt=ht({url:L().min(1,"URL is required"),title:L().min(1,"Title is required"),description:L().optional(),status:L().min(1,"Status is required"),notes:L().optional(),purchase_date:L().optional(),redeem_by_date:L().optional(),refund_deadline_days:De(["30","60"]),category_mode:De(["auto","manual"]),manual_category:L().optional()}).superRefine((n,i)=>{if(n.category_mode==="manual"&&(!n.manual_category||!String(n.manual_category).trim())&&i.addIssue({code:re.custom,message:"Please select or enter a category when using manual mode",path:["manual_category"]}),n.status==="Purchased"||n.status==="Refunded"){const g=!!n.purchase_date?.trim(),x=!!n.redeem_by_date?.trim();!g&&!x?i.addIssue({code:re.custom,message:"Enter either Purchase Date or Redeem-by Date",path:["purchase_date"]}):g&&x&&i.addIssue({code:re.custom,message:"Enter only one date (Purchase Date or Redeem-by Date), not both",path:["redeem_by_date"]})}});function Ct({onComplete:n}){const{toast:i}=ct(),o=is(),{data:g=[],isLoading:x}=Xs(),{data:y=[]}=Js(),v=d.useMemo(()=>Zs(g,y),[g,y]),[p,h]=d.useState("url"),[m,u]=d.useState(!1),[S,F]=d.useState(!1),[b,w]=d.use
1State(null),[U,Y]=d.useState(!1),[V,t]=d.useState(null),[N,f]=d.useState(!1),a=ls({resolver:ds(wt),defaultValues:{url:"",title:"",description:"",status:"Purchased",notes:"",purchase_date:"",redeem_by_date:"",refund_deadline_days:"60",category_mode:"auto",manual_category:""}}),z=tt(y),$=d.useMemo(()=>{const s=z,r=[...et],j=new Set([...r,...s]);return Array.from(j).sort((c,l)=>c==="Other"?1:l==="Other"?-1:c.localeCompare(l))},[z]),O=K.findIndex(s=>s.id===p),pe=async s=>{if(s){u(!0);try{const r=await ye.analyzeUrl(s);r.isValid&&(r.title&&a.setValue("title",r.title),r.description&&a.setValue("description",r.description),r.favicon&&t(r.favicon),Y(!0),i({title:"URL Analyzed",description:"Tool details have been auto-filled"}))}catch(r){console.error("URL analysis failed:",r)}finally{u(!1)}}},Ve=a.watch("title"),ze=a.watch("url");d.useEffect(()=>{if(x){w(null);return}const s=a.getValues("title"),r=a.getValues("url");if(!s.trim()){w(null);return}const j=st({title:s,url:r},v);w(j.isDuplicate||j.isPotentialDuplicate?j:null)},[Ve,ze,x,v,a]);const fe=async()=>{switch(p){case"url":{const s=a.getValues("url");return s?ye.validateUrl(s).isValid?(U||await pe(s),!0):(a.setError("url",{message:"Please enter a valid URL"}),!1):(a.setError("url",{message:"URL is required"}),!1)}case"details":{const s=a.getValues("title"),r=a.getValues("status"),j=(a.getValues("purchase_date")||"").trim(),c=(a.getValues("redeem_by_date")||"").trim();if(!(s||"").trim())return a.setError("title",{message:"Title is required"}),!1;if(r==="Purchased"||r==="Refunded"){if(!j&&!c)return a.setError("purchase_date",{message:"Enter either Purchase Date or Redeem-by Date for purchased/refunded tools"}),!1;if(j&&c)return a.setError("redeem_by_date",{message:"Enter only one date (Purchase Date or Redeem-by Date), not both"}),!1}return!0}case"category":{const s=a.getValues("category_mode"),r=(a.getValues("manual_category")||"").trim();return s==="manual"&&!r?(a.setError("manual_category",{message:"Please select or enter a category"}),!1):!0}case"review":return!0;default:return!0}},ge=async()=>{if(!await fe()){B("error");return}const r=O+1;r<K.length&&(B("light"),h(K[r].id))},je=()=>{const s=O-1;s>=0&&(B("light"),h(K[s].id))},Oe=d.useCallback(async()=>{p==="review"||m||S||await ge()},[p,m,S]),Me=d.useCallback(()=>{p==="url"||S||je()},[p,S]),Be=Nt(Oe,Me,{threshold:60,enabled:!S}),qe=s=>{const r=s instanceof Error?s.message:"",j=s?.code??"";return/authenticated|must be signed in|user_id|RLS/i.test(r)||j==="PGRST301"?{title:"Sign-in required",description:"You need to be signed in to add tools. Please sign in and try again."}:/duplicate|unique|already exists|23505/i.test(r)?{title:"Duplicate tool",description:"A tool with this title or URL may already exist. Check your list or use a different title/URL."}:/foreign key|23503|violates foreign key/i.test(r)?{title:"Invalid data",description:"One of the values is not allowed. Try changing the category or status and submit again."}:/network|fetch|failed to fetch|timeout/i.test(r)?{title:"Connection problem",description:"Check your internet connection and try again. If it persists, try again in a few minutes."}:r&&r.length<120?{title:"Couldn't add tool",description:r}:{title:"Couldn't add tool",description:"Something went wrong on our side. Please check that all fields are valid and try again. If it keeps happening, try refreshing the page."}},be=async()=>{const s=a.getValues();if(!await a.trigger(void 0,{shouldFocus:!0})){const c=a.formState.errors,l=Object.keys(c)[0],R=l?c[l]?.message:void 0;B("error"),i({title:"Please fix the form",description:R||"Some required fields are missing or invalid. Check the fields marked in red.",variant:"destructive"});const k={url:"url",title:"details",description:"details",status:"details",purchase_date:"details",redeem_by_date:"details",refund_deadline_days:"details",notes:"details",category_mode:"category",manual_category:"category"};l&&k[l]&&k[l]!==p&&h(k[l]);return}if(!await fe()){B("error");const c=a.formState.errors,l=c.url?.message??c.title?.message??c.purchase_date?.message??c.redeem_by_date?.message??c.manual_category?.message;i({title:"Please fix the form",description:l||"Check the fields marked in red and try again.",variant:"destructive"});return}F(!0);try{let c=null;const l=s.purchase_date||s.redeem_by_date;if(l){const k=new Date(l),M=parseInt(s.refund_deadline_days);c=new Date(k.getTime()+M*24*60*60*1e3).toISOString()}
1const R=await o.mutateAsync({url:s.url,title:s.title,description:s.description||null,status:s.status,notes:s.notes||null,purchase_date:s.purchase_date?new Date(s.purchase_date).toISOString():void 0,refund_deadline:c,category:s.category_mode==="manual"&&s.manual_category||null,image:V&&!xs(V)?V:null,skipDuplicateCheck:!0});if(s.category_mode==="auto")try{await G.functions.invoke("categorize-tool",{body:{title:s.title,description:s.description||"",url:s.url,toolId:R.id,context:"add"}})}catch(k){console.error("AI categorization failed:",k)}B("success"),i({title:"🎉 Tool Added!",description:`${s.title} has been added with refund tracking.`}),a.reset(),h("url"),Y(!1),w(null),t(null),f(!1),n?.()}catch(c){console.error("Error creating tool:",c),B("error");const{title:l,description:R}=qe(c);i({title:l,description:R,variant:"destructive"})}finally{F(!1)}},Ye=async()=>{if(b?.isDuplicate&&b?.matchConfidence==="high"){f(!0);return}await be()},$e=async()=>{f(!1),await be()},Ke=()=>e.jsx("div",{className:"flex items-center justify-between mb-6 px-2",children:K.map((s,r)=>{const j=s.icon,c=s.id===p,l=r<O;return e.jsxs("div",{className:"flex items-center",children:[e.jsxs("div",{className:"flex flex-col items-center",children:[e.jsx("div",{className:I("w-10 h-10 rounded-full flex items-center justify-center transition-all duration-300",c&&"bg-primary text-primary-foreground ring-4 ring-primary/20",l&&"bg-primary text-primary-foreground",!c&&!l&&"bg-muted text-muted-foreground"),children:l?e.jsx(ae,{className:"h-5 w-5"}):e.jsx(j,{className:"h-5 w-5"})}),e.jsx("span",{className:I("text-xs mt-1 font-medium transition-colors",c&&"text-primary",l&&"text-primary",!c&&!l&&"text-muted-foreground"),children:s.label})]}),r<K.length-1&&e.jsx("div",{className:I("h-0.5 w-8 mx-1 transition-colors",r<O?"bg-primary":"bg-muted")})]},s.id)})}),He=()=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Enter Tool URL"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"We'll auto-fill details from the URL"})]}),e.jsx(T,{control:a.control,name:"url",render:({field:s})=>e.jsxs(_,{children:[e.jsxs(E,{children:["URL ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{children:e.jsx(H,{placeholder:"https://example.com or paste URL",className:"h-12 text-base",...s,onBlur:()=>{s.value&&!U&&pe(s.value)}})}),e.jsx(D,{})]})}),m&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground p-3 bg-muted/50 rounded-lg",children:[e.jsx(W,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:"Analyzing URL..."})]}),U&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-primary p-3 bg-primary/10 rounded-lg",children:[e.jsx(ae,{className:"h-4 w-4"}),e.jsx("span",{children:"URL analyzed successfully!"})]})]}),Qe=()=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Tool Details"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Confirm or edit the tool information"})]}),e.jsx(T,{control:a.control,name:"title",render:({field:s})=>e.jsxs(_,{children:[e.jsxs(E,{children:["Title ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(A,{children:e.jsx(H,{placeholder:"Tool name",className:"h-12 text-base",...s})}),e.jsx(D,{})]})}),b&&(()=>{const s=b.isDuplicate&&b.matchConfidence==="high",r=b.matchConfidence,j=()=>r==="high"?"border-destructive/50 bg-destructive/10":r==="medium"?"border-amber-500/50 bg-amber-500/10":"border-blue-500/50 bg-blue-500/10",c=()=>r==="high"?"text-destructive":r==="medium"?"text-amber-700 dark:text-amber-400":"text-blue-700 dark:text-blue-400",l=()=>r==="high"?e.jsx(Z,{className:"h-4 w-4"}):e.jsx(Fs,{className:"h-4 w-4"});return e.jsxs(X,{className:I("border",j()),children:[e.jsx("div",{className:c(),children:l()}),e.jsxs(J,{className:c(),children:[b.message,!s&&e.jsx("span",{className:"block text-xs mt-1 opacity-80",children:"You can still proceed with adding this tool."})]})]})})(),e.jsx(T,{control:a.control,name:"description",render:({field:s})=>e.jsxs(_,{children:[e.jsx(E,{children:"Description"}),e.jsx(A,{children:e.jsx(ot,{placeholder:"Brief description",className:"min-h-[80px]",...s})}),e.jsx(D,{})]})}),e.jsx(T,{control:a.control,name:"status",render:({field:s})=>e.jsxs(_,{children:[e.jsx(E,{children:"Status"}),e.jsxs(oe,{onValueChange:s.onChange,defaultValue:s.value,children:[e.jsx(A,{children:e.jsx(ce,{className:"h-12",children:e.jsx(de,{placeholder:"Select status"})})}),e.jsxs(me,{children:[e.jsx(q,{value:"Purchased",children:"Purchased"}),e.jsx(q,{value:"To Buy Later",children:"To Buy Later"}),e.jsx(q,{value:"Refunded",children:"Refunded"}),e.jsx(q,{value:"Bookmarked",children:"Favorited"})]})]}),e.jsx(D,{})]})}),(()=>{const s=a.watch("status"),r=s==="Purchased"||s==="Refunded",j=(a.watch("purchase_date")||"").trim(),l=!!(a.watch("redeem_by_date")||"").trim(),R=!!j;return e.jsxs(e.Fragment,{children:[r&&e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Required: enter ",e.jsx("strong",{children:"one"})," date — either Purchase Date or Redeem-by Date (not both)."]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(T,{control:a.control,name:"purchase_date",render:({field:k})=>e.jsxs(_,{children:[e.jsxs(E,{children:["Purchase Date",r?e.jsx(e.Fragment,{children:e.jsx("span",{className:"text-destructive",children:"*"})}):""]}),e.jsx(A,{children:e.jsx(H,{type:"date",className:"h-12",disabled:l,"aria-disabled":l,...k,onChange:M=>{k.onChange(M),(M.target.value||"").trim()&&a.setValue("redeem_by_date","")}})}),l&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Redeem-by Date is set — clear it to use Purchase Date."}),e.jsx(D,{})]})}),e.jsx(T,{control:a.control,name:"redeem_by_date",render:({field:k})=>e.jsxs(_,{children:[e.jsxs(E,{children:["Redeem-by Date",r?e.jsx(e.Fragment,{children:e.jsx("span",{className:"text-destructive",children:"*"})}):""]}),e.jsx(A,{children:e.jsx(H,{type:"date",className:"h-12",disabled:R,"aria-disabled":R,...k,onChange:M=>{k.onChange(M),(M.target.value||"").trim()&&a.setValue("purchase_date","")}})}),R&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Purchase Date is set — clear it to use Redeem-by Date."}),e.jsx(D,{})]})})]})]})})(),e.jsx(T,{control:a.control,name:"refund_deadline_days",render:({field:s})=>e.jsxs(_,{children:[e.jsx(E,{children:"Refund Deadline"}),e.jsxs(oe,{onValueChange:s.onChange,defaultValue:s.value,children:[e.jsx(A,{children:e.jsx(ce,{className:"h-12",children:e.jsx(de,{placeholder:"Select refund deadline"})})}),e.jsxs(me,{children:[e.jsx(q,{value:"30",children:"30 days"}),e.jsx(q,{value:"60",children:"60 days"})]})]}),e.jsx(D,{})]})}),e.jsx(T,{control:a.control,name:"notes",render:({field:s})=>e.jsxs(_,{children:[e.jsx(E,{children:"Notes"}),e.jsx(A,{children:e.jsx(H,{placeholder:"Additional notes",className:"h-12",...s})}),e.jsx(D,{})]})})]}),We=()=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Categorization"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Choose how to categorize this tool"})]}),e.jsx(T,{control:a.control,name:"category_mode",render:({field:s})=>e.jsxs(_,{children:[e.jsx(A,{children:e.jsxs(mt,{onValueChange:s.onChange,defaultValue:s.value,className:"space-y-3",children:[e.jsxs("div",{className:I("flex items-center space-x-3 border rounded-xl p-4 transition-all",s.value==="auto"&&"border-primary bg-primary/5"),children:[e.jsx(Ae,{value:"auto",id:"auto"}),e.jsxs("label",{htmlFor:"auto",className:"flex items-center gap-3 cursor-pointer flex-1",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(he,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Auto (AI)"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Let AI categorize automatically"})]})]})]}),e.jsxs("div",{className:I("flex items-center space-x-3 border rounded-xl p-4 transition-all",s.value==="manual"&&"border-primary bg-primary/5"),children:[e.jsx(Ae,{value:"manual",id:"manual"}),e.jsxs("label",{htmlFor:"manual",className:"flex items-center gap-3 cursor-pointer flex-1",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center",children:e.jsx(Es,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:"Manual"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Choose category yourself"})]})]})]})]})}),e.jsx(D,{})]})}),a.watch("category_mode")==="manual"&&e.jsx(T,{control:a.control,name:"manual_category",render:({field:s})=>e.jsxs(_,{children:[e.jsx(E,{children:"Category"}),e.jsx(A,{children:e.jsx(Qs,{value:s.value||"",onChange:s.onChange,options:$,placeholder:"Select or create category...",className:"w-full"})}),e.jsx(D,{})]})})]}),Ge=()=>{const s=a.getValues();return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Review & Submit"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Confirm the details before adding"})]}),e.jsx(ue,{className:"border-2",children:e.jsxs(xe,{className:"pt-6 space-y-3",children:[e.jsxs("div",{className:"flex justify-between items-start gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Title"}),e.jsx("span",{className:"font-medium text-right break-words min-w-0",children:s.title})]}),e.jsxs("div",{className:"flex justify-between items-start gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"URL"}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 justify-end",children:[e.jsx("span",{className:"text-sm text-right break-all text-primary min-w-0",children:s.url}),e.jsx(C,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>s.url&&navigator.clipboard.writeText(s.url),title:"Copy URL",children:e.jsx(Rs,{className:"h-4 w-4"})})]})]}),s.description&&e.jsxs("div",{className:"flex justify-between items-start gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Description"}),e.jsx("span",{className:"text-sm text-right break-words min-w-0",children:s.description})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Status"}),e.jsx("span",{className:"text-sm font-medium",children:s.status})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Refund Deadline"}),e.jsxs("span",{className:"text-sm font-medium",children:[s.refund_deadline_days," days"]})]}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Category"}),e.jsx("span",{className:"text-sm font-medium flex items-center gap-1",children:s.category_mode==="auto"?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:"h-3 w-3 text-primary"}),"AI Auto"]}):s.manual_category||"Not set"})]}),(s.purchase_date||s.redeem_by_date)&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:s.purchase_date?"Purchase Date":"Redeem-by Date"}),e.jsx("span",{className:"text-sm font-medium",children:new Date(s.purchase_date||s.redeem_by_date||"").toLocaleDateString()})]}),s.notes&&e.jsxs("div",{className:"flex justify-between items-start gap-3",children:[e.jsx("span",{className:"text-sm text-muted-foreground shrink-0",children:"Notes"}),e.jsx("span",{className:"text-sm text-right break-words min-w-0",children:s.notes})]})]})}),b&&(()=>{const r=b.isDuplicate&&b.matchConfidence==="high",j=b.matchConfidence,c=()=>j==="high"?"border-destructive/50 bg-destructive/10":j==="medium"?"border-amber-500/50 bg-amber-500/10":"border-blue-500/50 bg-blue-500/10",l=()=>j==="high"?"text-destructive":j==="medium"?"text-amber-700 dark:text-amber-400":"text-blue-700 dark:text-blue-400";return e.jsxs(X,{className:I("border",c()),children:[e.jsx(Z,{className:I("h-4 w-4",l())}),e.jsxs(J,{className:l(),children:[b.message,!r&&" You can still add this tool."]})]})})()]})},Xe=()=>{switch(p){case"url":return He();case"details":return Qe();case"category":return We();case"review":return Ge();default:return null}};return e.jsxs(os,{...a,children:[e.jsxs("form",{onSubmit:s=>s.preventDefault(),className:"flex flex-col h-full",children:[Ke(),e.jsxs("div",{className:"text-center text-xs text-muted-foreground mb-2 flex items-center justify-center gap-1",children:[e.jsx(Ce,{className:"h-3 w-3"}),e.jsx("span",{children:"Swipe to navigate"}),e.jsx(Se,{className:"h-3 w-3"})]}),e.jsx("div",{ref:Be,className:"flex-1 overflow-y-auto px-1 pb-4 touch-p
1an-y",children:e.jsx(ut,{mode:"wait",children:e.jsx(xt.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},transition:{duration:.2},children:Xe()},p)})}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t mt-auto",children:[O>0&&e.jsxs(C,{type:"button",variant:"outline",onClick:je,className:"flex-1 h-12",children:[e.jsx(Ce,{className:"h-4 w-4 mr-2"}),"Back"]}),p==="review"?e.jsx(C,{type:"button",onClick:Ye,disabled:S,className:"flex-1 h-12",children:S?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"h-4 w-4 mr-2 animate-spin"}),"Adding..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"h-4 w-4 mr-2"}),"Add Tool"]})}):e.jsx(C,{type:"button",onClick:ge,disabled:m,className:"flex-1 h-12",children:m?e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"h-4 w-4 mr-2 animate-spin"}),"Analyzing..."]}):e.jsxs(e.Fragment,{children:["Next",e.jsx(Se,{className:"h-4 w-4 ml-2"})]})})]})]}),e.jsx(cs,{open:N,onOpenChange:f,duplicateInfo:b,pendingToolTitle:a.getValues("title"),onProceed:$e,onCancel:()=>f(!1)})]})}function St({trigger:n,actions:i="main"}){const o=Fe(),v=i==="tools"?[{icon:Is,label:"Filter Tools",description:"Filter by status, category, etc.",action:()=>{}},{icon:Ls,label:"Sort Tools",description:"Change sorting options",action:()=>{}}]:i==="addTool"?[{icon:ke,label:"Import CSV",description:"Paste CSV or go to Add Tools to import from file",action:()=>o("/app/tools?tab=add")}]:[{icon:ke,label:"Import CSV",description:"Bulk import from spreadsheet",action:()=>o("/app/tools?tab=add")},{icon:Ps,label:"Settings",description:"App preferences and account",action:()=>o("/app/settings")},{icon:Us,label:"Help & Support",description:"Get help using the app",action:()=>o("/app/settings?tab=help")}],p=e.jsxs(C,{variant:"outline",size:"sm",className:"gap-2",children:[e.jsx(Ue,{className:"h-4 w-4"}),"More"]});return e.jsxs(pt,{children:[e.jsx(ft,{asChild:!0,children:n||p}),e.jsxs(gt,{side:"bottom",className:"h-auto max-h-[80vh]",children:[e.jsxs(jt,{className:"text-left",children:[e.jsx(bt,{children:"Quick Actions"}),e.jsx(yt,{children:"Choose an action to perform"})]}),e.jsx("div",{className:"grid gap-2 pt-4",children:v.map((h,m)=>{const u=h.icon;return e.jsxs("div",{children:[e.jsxs(C,{variant:"ghost",className:"flex items-start gap-3 p-4 h-auto justify-start w-full",onClick:h.action,children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(u,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"font-medium",children:h.label}),e.jsx("div",{className:"text-sm text-muted-foreground",children:h.description})]})]}),m<v.length-1&&e.jsx(vt,{})]},h.label)})})]})]})}function oa(){const[n,i]=d.useState(()=>{const m=new URLSearchParams(window.location.search),u=m.get("subtab");return u==="extension"?"extension":u==="team"||m.get("tab")==="team"?"team":"tools"}),[o,g]=d.useState("stepper"),x=Ie(),y=dt(),v=rt(),p=d.useRef(null),h=d.useCallback(()=>{const m=p.current;m&&(m.scrollIntoView({behavior:"smooth",block:"start"}),requestAnimationFrame(()=>{m.querySelector('input:not([type="hidden"]):not([disabled]), textarea:not([disabled])')?.focus({preventScroll:!0})}
1))},[]);return v&&!y?e.jsx(ms,{initialMethod:n==="extension"?"extension":n==="team"?"team":"csv",canTeam:x.canAccessTeamFeatures,extensionPane:e.jsxs("div",{className:"space-y-6",children:[e.jsx(Re,{}),e.jsx(Te,{}),e.jsx(Ee,{})]}),teamPane:e.jsx(ne,{}),onMethodChange:m=>i(m==="extension"||m==="team"?m:"tools")}):y?e.jsxs("div",{className:"w-full max-w-none mobile-padding flex flex-col min-h-[calc(100vh-200px)] pb-20",children:[e.jsxs("div",{className:"flex gap-2 mb-4 flex-wrap",children:[e.jsxs(C,{variant:n==="tools"&&o==="stepper"?"default":"outline",size:"sm",onClick:()=>{i("tools"),g("stepper")},className:"flex-1 min-h-[44px] touch-manipulation",children:[e.jsx(Vs,{className:"h-4 w-4 mr-1.5"}),"Guided"]}),e.jsxs(C,{variant:n==="tools"&&o==="quick"?"default":"outline",size:"sm",onClick:()=>{i("tools"),g("quick")},className:"flex-1 min-h-[44px] touch-manipulation",children:[e.jsx(he,{className:"h-4 w-4 mr-1.5"}),"Quick"]}),e.jsxs(C,{variant:n==="tools"&&o==="advanced"?"default":"outline",size:"sm",onClick:()=>{i("tools"),g("advanced")},className:"flex-1 min-h-[44px] touch-manipulation",children:[e.jsx(zs,{className:"h-4 w-4 mr-1.5"}),"Full"]}),x.canAccessTeamFeatures&&e.jsxs(C,{variant:n==="team"?"default":"outline",size:"sm",onClick:()=>i("team"),className:"flex-1 min-h-[44px] touch-manipulation",children:[e.jsx(le,{className:"h-4 w-4 mr-1.5"}),"Team"]})]}),e.jsx("div",{className:"flex-1 mb-6",children:n==="team"?e.jsx(ne,{}):o==="stepper"?e.jsx(Ct,{}):o==="quick"?e.jsx(ve,{onSwitchToAdvanced:()=>g("advanced")}):e.jsx(Ne,{})}),e.jsx("div",{className:"flex justify-center mb-4",children:e.jsx(St,{actions:"addTool",trigger:e.jsxs(C,{variant:"outline",size:"lg",className:"gap-2 w-full sm:w-auto min-h-[48px] touch-manipulation",children:[e.jsx(Ue,{className:"h-5 w-5"}),"More Options"]})})})]}):e.jsx("div",{className:"w-full max-w-none",children:e.jsxs(Ze,{value:n,onValueChange:i,className:"w-full",children:[e.jsxs(es,{className:`grid w-full ${x.canAccessTeamFeatures?"grid-cols-3":"grid-cols-2"} mb-6 sm:mb-8 bg-muted/50`,children:[e.jsxs(ee,{value:"tools",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Pe,{className:"h-4 w-4"}),"Add Tools"]}),e.jsxs(ee,{value:"extension",className:"flex items-center gap-2 data-[state=active]:bg-background relative",children:[e.jsx(ie,{className:"h-4 w-4"}),"Extension",e.jsx("span",{className:"absolute -top-2 -right-2 px-1.5 py-0.5 text-[9px] font-medium bg-primary text-primary-foreground rounded-full leading-none hidden sm:inline-flex whitespace-nowrap",children:"Recommended"})]}),x.canAccessTeamFeatures&&e.jsxs(ee,{value:"team",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(le,{className:"h-4 w-4"}),"Add to Team"]})]}),e.jsxs(se,{value:"tools",className:"mt-0 border-0 p-0 space-y-6",children:[e.jsx(ve,{onSwitchToAdvanced:h}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-3 text-muted-foreground",children:"Or add with full details"})})]}),e.jsx("div",{ref:p,id:"advanced-add-tool-form",tabIndex:-1,children:e.jsx(Ne,{})}),e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 flex items-center",children:e.jsx("span",{className:"w-full border-t"})}),e.jsx("div",{className:"relative flex justify-center text-xs uppercase",children:e.jsx("span",{className:"bg-background px-3 text-muted-foreground",children:"Or import a spreadsheet"})})]}),e.jsx(us,{})]}),e.jsx(se,{value:"extension",className:"mt-0 border-0 p-0",children:e.jsxs("div",{className:"bg-card rounded-lg border p-8",children:[e.jsxs("div",{className:"mb-8 text-center",children:[e.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Browser Extension"}),e.jsx("p",{className:"text-muted-foreground",children:"One-click import from your favorite platforms"})]}),e.jsx(Re,{}),e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsx(Te,{}),e.jsx(Ee,{})]})]})}),x.canAccessTeamFeatures&&e.jsx(se,{value:"team",className:"mt-0 border-0 p-0",children:e.jsx(ne,{})})]})})}export{oa as AddToolTabs};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.