1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BNB7oB7v.js","assets/constants-BBB3i-qT.js","assets/ui-utils-C1rVVF17.js","assets/markdown-BXfohX-5.js","assets/utils-CJ9cKvh6.js","assets/constants-76wEiz8Q.css","assets/workbench-DWj3uRMc.js","assets/background-D_l8dy4N.js","assets/Sidebar-e6ka033K.js","assets/auth-kit-DsbJR9YV.js","assets/index-XrPMGToq.js","assets/theme-BUoCvDZk.js","assets/chat-C88qXW9Z.js"])))=>i.map(i=>d[i]); 2import{j as e}from"./markdown-BXfohX-5.js";import{r as t,u as s}from"./ui-utils-C1rVVF17.js";import{C as a,u as l,k as i,a as n,S as r,R as c,H as o}from"./Sidebar-e6ka033K.js";import{g as d,l as m,i as p,j as x,k as h,m as f,t as u,o as j,v as g,r as y,S as w,f as b,y as N,c as v,s as _,p as k}from"./constants-BBB3i-qT.js";import{F as S}from"./Footer-B1qIaqo9.js";import{_ as C}from"./auth-kit-DsbJR9YV.js";import{D as E}from"./Dialog-D81WG5vE.js";import{H as T}from"./Heading-DAGxg877.js";import{W as L}from"./WalletConnectButton-WdA-LtkG.js";import{L as F}from"./LoadingDots-AjehHfEx.js";import"./LoadingBar-DyMGkXQQ.js";import{b as R,g as O}from"./background-D_l8dy4N.js";import{t as A}from"./theme-BUoCvDZk.js";import"./utils-CJ9cKvh6.js";import"./index-XrPMGToq.js";import"./index-BGk31iYq.js";const P={as:{type:"enum",values:["h1","h2","h3","h4","h5","h6"],default:"h1"},...j,size:{type:"enum",className:"rt-r-size",values:["1","2","3","4","5","6","7","8","9"],default:"6",responsive:!0},...u,...f,...h,...x,...p,...m,...d},D=t.forwardRef((e,s)=>{const{children:a,className:l,asChild:i,as:n="h1",color:r,...c}=g(e,P,y);return t.createElement(w,{"data-accent-color":r,...c,ref:s,className:b("rt-Heading",l)},i?a:t.createElement(n,null,a))});D.displayName="Heading";const I=({template:s,isOpen:a,onClose:r,onTemplateLoaded:c})=>{const[o,d]=t.useState(!1),{address:m}=l(),p=t.useCallback(async()=>{d(!0);try{let t=s;if(!s.files){const e=await fetch(`/api/template-files/${s.id}`),a=await e.json();if(!a.success)throw new Error("Failed to fetch template files");t={...s,files:a.files}}const[{webcontainer:a}]=await Promise.all([C(()=>import("./index-BNB7oB7v.js"),__vite__mapDeps([0,1,2,3,4,5])),C(()=>import("./workbench-DWj3uRMc.js").then(e=>e.g),__vite__mapDeps([6,7,2,8,1,3,4,5,9,10,11,0]))]),l=await a;for(const e of t.files){const t=e.file_path.substring(0,e.file_path.lastIndexOf("/"));t&&await l.fs.mkdir(t,{recursive:!0}),await l.fs.writeFile(e.file_path,e.file_content)}const[{chatStore:i},{workbenchStore:n}]=await Promise.all([C(()=>import("./chat-C88qXW9Z.js"),__vite__mapDeps([12,2])),C(()=>import("./workbench-DWj3uRMc.js").then(e=>e.g),__vite__mapDeps([6,7,2,8,1,3,4,5,9,10,11,0]))]);i.setKey("started",!0),n.showWorkbench.set(!0);for(const e of t.files)await n.addFile(e.file_path,e.file_content);await new Promise(e=>setTimeout(e,100));const o=n.files.get();if(n.setDocuments(o),n.showWorkbench.set(!0),sessionStorage.setItem("template-id",s.id),m)try{await fetch("/api/templates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"increment_remix_count",templateId:s.id,walletAddress:m})})}catch(e){console.error("Failed to increment remix count:",e)}N.success(`Template "${s.title}" loaded successfully!`),c?.(),r(),globalThis.location.href=`/create/?templateId=${s.id}`}catch(e){console.error("Failed to load template:",e),N.error("Failed to load template into workbench")}finally{d(!1)}},[s,c,r]);return e.jsx(i,{open:a,onOpenChange:e=>!e&&r(),children:e.jsx(E,{className:"bg-chat text-chat",onClose:r,children:e.jsxs("div",{className:"p-6 max-w-2xl mx-auto flex flex-col gap-y-4",children:[e.jsx(T,{className:"heading-3",title:"Use Template",iconName:"construction"}),e.jsxs("div",{className:"flex flex-col gap-y-4",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx("p",{children:"Title:"}),e.jsx("p",{children:s.title})]}),e.jsx("div",{className:"bg-transparent-white p-2",children:s.description}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Category:"}),e.jsx("span",{className:"ml-2 capitalize",children:s.category})]}),e.jsxs("div",{children:[e.jsx("span",{children:"Complexity:"}),e.jsx("span",{className:"ml-2 capitalize",children:s.complexity})]})]}),s.tech_stack&&s.tech_stack.length>0&&e.jsxs("div",{className:"flex flex-col gap-y-2",children:[e.jsx("span",{children:"Tech Stack:"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:s.tech_stack.map(t=>e.jsx("span",{className:"px-2 py-1 bg-transparent-white",children:t},t))})]}),e.jsxs("div",{className:"flex justify-end space-x-3 pt-4",children:[e.jsx(n,{title:"Cancel",theme:"light-button",onClick:r,disabled:o}),e.jsx(n,{title:o?"Loading...":"Load Template",theme:"action-button",onClick:p,disabled:o})]})]})]})})})},z=t=>e.jsx(a,{fallback:e.jsx("div",{children:"Loading..."}),children:()=>e.jsx(I,{...t})}),M=({template:s})=>{const[a,i]=t.useState(!1),{isConnected:r}=l();return e.jsxs(e.Fragment,{children:[e.jsx("section",{className:v(_.hoverMultiShadowYellow,"z-0 transition-all duration-200 w-full rounded-none"),children:e.jsxs("article",{className:v("p-5 flex flex-col border border-transparent-white bg-chat gap-y-4 h-full max-h-[750px] max-w-2xl rounded-none",_.hoverGradientBorder),children:[s.preview_image_url?e.jsx("img",{src:s.preview_image_url,alt:s.title,className:"w-full h-56 object-cover rounded-none",crossOrigin:"anonymous"}):e.jsx("div",{className:"w-full h-48 bg-gray-200 flex items-center justify-center",children:e.jsx("div",{className:"i-ph:image text-4xl text-gray-400"})}),e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx(D,{className:"heading-2 text-left flex-1",children:s.title}),s.is_featured&&e.jsx("span",{className:"px-2 py-1 bg-yellow-100 text-yellow-800 text-xs rounded-full ml-2",children:"Featured"})]}),e.jsxs("div",{className:"flex flex-col gap-y-4 mt-auto",children:[e.jsx("p",{className:"bg-transparent-white p-2 max-h-40 min-h-24 overflow-y-auto",children:s.description.length>100?e.jsxs("span",{children:[s.description.slice(0,100)," ..."]}):e.jsx("span",{children:s.description})}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:v("font-medium w-max flex items-center gap-x-2"),children:["Difficulty:"," ",e.jsx("div",{className:"flex items-center gap-x-1",children:(()=>{const t={beginner:1,intermediate:2,advanced:3}[s.complexity]??1;return[0,1,2].map(s=>e.jsx("span",{className:v("material-symbols-outlined",s<t?"text-speedrun-orange-gradient":"text-chat opacity-50"),children:"trophy"},s))})()})]}),e.jsxs("span",{className:"font-medium",children:["#",s.category.charAt(0).toUpperCase()+s.category.slice(1)]})]}),e.jsx("div",{className:"flex items-center justify-between mt-auto",children:e.jsx("div",{className:"flex items-center space-x-4",children:s.rating&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"i-ph:star-fill text-yellow-400 mr-1"}),e.jsx("span",{children:s.rating.toFixed(1)}),e.jsxs("span",{className:"ml-1",children:["(",s.rating_count,")"]})]})})}),r?e.jsx(n,{title:"Try",size:"small",iconClass:"icon-light",rightIcon:"arrow_forward_ios",theme:"light-button",className:"w-max",onClick:()=>{i(!0)}}):e.jsx(L,{className:"w-max",size:"sm"})]})]})}),e.jsx(z,{template:s,isOpen:a,onClose:()=>i(!1)})]})},B=()=>{const[s,a]=t.useState([]),[l,i]=t.useState([]),[n,r]=t.useState(!0),[c,o]=t.useState(null),[d,m]=t.useState({search_term:"",category:"",complexity:"",framework:""}),[p,x]=t.useState(!0),[h,f]=t.useState(0),u=t.useCallback(async(e=!1)=>{try{r(!0),o(null);const t=new URLSearchParams({...d,limit:"12",offset:e?"0":h.toString()}),s=await fetch(`/api/templates?${t}`),l=await s.json();l.success?(e?(a(l.templates),f(0)):a(e=>[...e,...l.templates]),x(l.pagination.has_more),f(e=>e+l.templates.length)):o(l.error||"Failed to load templates")}
2catch(t){console.error("Error loading templates:",t),o("Failed to load templates")}finally{r(!1)}},[d,h]),j=t.useCallback(async()=>{try{const e=await fetch("/api/template-categories"),t=await e.json();t.success&&i(t.categories)}catch(e){console.error("Error loading categories:",e)}},[]);t.useCallback(e=>{m(t=>({...t,...e}))},[]);const g=t.useCallback(()=>{!n&&p&&u(!1)},[n,p,u]);return t.useEffect(()=>{j(),u(!0)},[]),t.useEffect(()=>{u(!0)},[d]),c?e.jsx("div",{className:"flex flex-col items-center justify-center py-12",children:e.jsxs("div",{className:"text-red-500 text-center",children:[e.jsx("div",{className:"i-ph:warning-circle text-4xl mb-4"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Failed to load templates"}),e.jsx("p",{className:"text-sm",children:c}),e.jsx("button",{onClick:()=>u(!0),className:"mt-4 px-4 py-2 bg-blue-500 text-white rounded-md hover:bg-blue-600",children:"Try Again"})]})}):e.jsx("div",{className:"w-full max-w-7xl mx-auto",children:n&&0===s.length?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(F,{text:"Loading templates..."})}):0===s.length?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"i-ph:folder-open text-4xl text-gray-400 mb-4"}),e.jsx("h3",{className:"text-lg font-semibold text-gray-900 mb-2",children:"No templates found"}),e.jsx("p",{className:"text-gray-600 text-center",children:"Try adjusting your search criteria or check back later for new templates."})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid xl:grid-cols-3 md:grid-cols-2 grid-cols-1 gap-6 text-chat",children:s.map(t=>e.jsx(M,{template:t},t.id))}),p&&e.jsx("div",{className:"flex justify-center mt-8",children:e.jsx("button",{onClick:g,disabled:n,className:"px-6 py-3 bg-blue-500 text-white rounded-md hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed",children:n?"Loading...":"Load More Templates"})})]})})},H=()=>e.jsx(a,{fallback:e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(F,{text:"Loading templates..."})}),children:()=>e.jsx(B,{})}),V=()=>[{title:"SpeedRun | Explore Templates - Community App Templates"},{name:"description",content:"Explore community-made templates for building onchain apps. Find inspiration from hundreds of templates updated regularly to help you build faster."},{property:"og:title",content:"SpeedRun | Explore Templates - Community App Templates"},{property:"og:description",content:"Explore community-made templates for building onchain apps on SpeedRun."},{property:"og:type",content:"website"},{property:"og:url",content:"https://speedrunapp.com/explore"},{property:"og:image",content:"https://www.datocms-assets.com/86369/1758565842-speedrun-og-banner.jpg"},{property:"og:site_name",content:"SpeedRun"},{name:"twitter:card",content:"summary_large_image"},{name:"twitter:title",content:"SpeedRun | Explore Templates"},{name:"twitter:description",content:"Explore community-made templates for building onchain apps."},{name:"twitter:image",content:"https://www.datocms-assets.com/86369/1758565842-speedrun-og-banner.jpg"},{name:"viewport",content:"width=device-width, initial-scale=1"},{name:"theme-color",content:"#000000"},{tagName:"link",rel:"canonical",href:"https://speedrunapp.com/explore"}];function W(){const t="dark"===s(A),l=s(R.isBaseMiniAppMode);return e.jsxs(e.Fragment,{children:[" ",e.jsx(a,{children:()=>e.jsx(r,{})}),e.jsxs(c,{className:v("flex overflow-y-auto flex-col min-h-screen justify-between gap-y-10 min-h-screen",{"bg-app-hero":!l}),style:l?O(t):void 0,children:[e.jsx(o,{}),e.jsx("section",{className:"text-chat flex flex-col justify-between",children:e.jsxs("article",{className:"flex flex-col gap-y-16 justify-center items-center",children:[e.jsx("div",{className:"z-0",children:e.jsxs("div",{className:v(_.GradientBorder,_.MultiShadowYellow,"flex flex-col gap-y-5 max-w-2xl items-center bg-chat p-6"),children:[e.jsx(T,{className:"text-speedrun-orange-gradient text-center heading-1",title:"EXPLORE TEMPLATES",iconName:"search"}),e.jsx(k,{children:"Explore community-made templates, new ones added every other day to keep your library fresh and inspiring."})]})}),e.jsx(H,{})]})}),e.jsx(S,{})]})]})}export{W as default,V as meta};
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.