1import{c as f,K as O,r as h,i as A,j as e,a as R,S as $,C as P}from"./app-DDm4dLCY.js";import{I as G}from"./input-error-Wh-X1cuu.js";import{S as Y}from"./snapto-logo-Cs9TAaBN.js";import{B as b}from"./button-D9X3vUxO.js";import{C as q,a as B,b as D,c as F,d as H,e as K}from"./card-DifmMaC0.js";import{I as j}from"./input-BjisokTd.js";import{I as X,b as C,a as V}from"./input-group-D1JyTM92.js";import{L as y}from"./label-ByReZhaM.js";import{d as J,C as W}from"./index-CwmF_DoX.js";import{A as Z}from"./arrow-left-b-Kv1Ly1.js";import{T as Q}from"./trash-2-pwk1GwC3.js";import{P as ee}from"./plus-BXg4Gnan.js";/* empty css *//** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const te=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],I=f("ArrowRight",te);/** 7 * @license lucide-react v0.475.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const se=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],ae=f("Github",se);/** 12 * @license lucide-react v0.475.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const ne=[["rect",{width:"20",height:"20",x:"2",y:"2",rx:"5",ry:"5",key:"2e1cvw"}],["path",{d:"M16 11.37A4 4 0 1 1 12.63 8 4 4 0 0 1 16 11.37z",key:"9exkf1"}],["line",{x1:"17.5",x2:"17.51",y1:"6.5",y2:"6.5",key:"r4j83e"}]],re=f("Instagram",ne);/** 17 * @license lucide-react v0.475.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const ie=[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]],le=f("Music2",ie);/** 22 * @license lucide-react v0.475.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const oe=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],ce=f("Music",oe);/** 27 * @license lucide-react v0.475.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const de=[["path",{d:"M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z",key:"pff0z6"}]],ue=f("Twitter",de);/** 32 * @license lucide-react v0.475.0 - ISC 33 * 34 * This source code is licensed under the ISC license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const me=[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]],he=f("Youtube",me),pe=[{key:"instagram",icon:re},{key:"tiktok",icon:le},{key:"youtube_channel",icon:he},{key:"twitter",icon:ue},{key:"spotify",icon:ce},{key:"github",icon:ae}],z={1:["Set up your page","Pick your handle and tell visitors who you are."],2:["Add your links","Connect a few socials and drop in any links. All optional."],3:["Pick a theme","Choose a starting look. You can fully customise it later."]};function xe(){const i=document.querySelector('meta[name="csrf-token"]');if(i)return{"X-CSRF-TOKEN":i.getAttribute("content")};const u=document.cookie.match(/(?:^|;\s*)XSRF-TOKEN=([^;]*)/);return u?{"X-XSRF-TOKEN":decodeURIComponent(u[1])}:{}}function Te({templates:i=[],socials:u={},subscribed:n=!1}){const l=O().props.app.url.replace("https://","").replace(/\/$/,""),[a,x]=h.useState(1),[k,v]=h.useState(null),[N,g]=h.useState(null),[t,d]=h.useState(()=>{var s;return{name:"",url:"",bio:"",template_id:((s=i[0])==null?void 0:s.id)??"",socials:{},links:[{title:"",url:""}]}}),o=h.useRef(t);o.current=t;const r=s=>
36d(m=>({...m,...s})),w=h.useMemo(()=>J(s=>{if(g(null),v(null),s!==""){if(!s.match(/^[0-9a-zA-Z._-]+$/)||s.indexOf(" ")>=0||s.indexOf(".")===0){g("The url format is invalid.");return}A.get(route("profile.url.validate"),{params:{url:s}}).then(m=>m.data.success?v(!0):g(m.data.message)).catch(()=>{})}},250),[]),T=s=>{r({url:s}),w(s)},U=()=>{o.current.url===""&&o.current.name!==""&&A.get(route("profile.url.generate"),{params:{text:o.current.name}}).then(s=>{if(s.data.data.length>0){const m=s.data.data[0].toLowerCase();r({url:m}),w(m)}})};h.useEffect(()=>{const s=new URLSearchParams(window.location.search).get("profileurl")||localStorage.getItem("snapto.profileurl");s&&s!=="null"&&(r({url:s}),w(s))},[]);const S=t.name.trim()!==""&&t.url.trim()!==""&&k===!0&&!N;function _(){const s=Object.entries(t.socials).map(([p,M])=>({platform:p,handle:(M||"").trim()})).filter(p=>p.handle!==""),m=t.links.map(p=>({title:(p.title||"").trim(),url:(p.url||"").trim()})).filter(p=>p.url!==""),L={url:t.url.trim(),name:t.name.trim(),title:t.name.trim(),bio:t.bio.trim(),template_id:t.template_id||null,socials:s,links:m};localStorage.setItem("snapto.onboarding",JSON.stringify(L)),localStorage.removeItem("snapto.profileurl"),$.get(n?route("onboarding.finish"):route("subscription.upgrade"))}const E={step:a,setStep:x,step1Ready:S,publish:_,data:t,set:r,appUrl:l,validUrl:k,urlError:N,onUrl:T,generateUrl:U,socials:u,templates:i};return e.jsxs("div",{className:"bg-background flex min-h-svh flex-col",children:[e.jsx("header",{className:"flex h-16 shrink-0 items-center px-6 sm:px-10",children:e.jsx(Y,{})}),e.jsxs("div",{className:"mx-auto flex w-full max-w-5xl flex-1 flex-col items-center justify-center gap-10 px-6 py-8 lg:flex-row lg:items-center",children:[e.jsxs(q,{className:"w-full max-w-lg",children:[e.jsxs(B,{children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-muted-foreground text-sm font-medium",children:["Step ",a," of 3"]}),e.jsx("div",{className:"flex items-center gap-1.5",children:[1,2,3].map(s=>e.jsx("span",{className:R("h-1.5 rounded-full transition-all duration-300",s===a?"w-6 bg-[#f74b71]":s<a?"w-1.5 bg-[#f74b71]":"w-1.5 bg-border")},s))})]}),e.jsx(D,{className:"text-2xl",children:z[a][0]}),e.jsx(F,{className:"text-base",children:z[a][1]})]}),e.jsx(H,{children:e.jsx(fe,{p:E})}),e.jsxs(K,{className:"justify-between",children:[a>1?e.jsxs(b,{type:"button",variant:"ghost",onClick:()=>x(a-1),children:[e.jsx(Z,{className:"size-4"})," Back"]}):e.jsx("span",{}),a<3?e.jsxs(b,{type:"button",disabled:a===1&&!S,onClick:()=>x(a+1),children:["Continue ",e.jsx(I,{className:"size-4"})]}):e.jsxs(b,{type:"button",onClick:_,children:["Publish my page ",e.jsx(I,{className:"size-4"})]})]})]}),e.jsx("div",{className:"hidden w-[290px] shrink-0 lg:block",children:e.jsx(ge,{data:t})})]})]})}function fe({p:i}){const{step:u,data:n,set:c,appUrl:l,validUrl:a,urlError:x,onUrl:k,generateUrl:v,socials:N,templates:g}=i;return u===1?e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Your name"}),e.jsx(j,{value:n.name,onBlur:v,onChange:t=>c({name:t.target.value}),placeholder:"Ada Lovelace"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Your link"}),e.jsxs(X,{children:[e.jsx(C,{children:`${l}/`}),e.jsx(V,{value:n.url,onChange:t=>k(t.target.value),placeholder:"your-unique-name","aria-invalid":x?!0:void 0}),x?e.jsx(C,{align:"inline-end",children:e.jsx(W,{className:"text-destructive"})}):a===!0?e.jsx(C,{align:"inline-end",children:e.jsx(P,{className:"text-green-600"})}):null]}),e.jsx(G,{message:x})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Short bio"}),e.jsx(j,{value:n.bio,maxLength:255,onChange:t=>c({bio:t.target.value}),placeholder:"Building things on the internet."}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Optional. You can change this any time."})]})]}):u===2?e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(y,{children:"Socials"}),pe.map(({key:t,icon:d})=>{const o=N[t]||{};return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"bg-background text-muted-foreground flex size-10 shrink-0 items-center justify-center rounded-lg border",children:e.jsx(d,{className:"size-5"})}),e.jsx(j,{value:n.socials[t]??"",onChange:r=>c({socials:{...n.socials,[t]:r.target.value}}),placeholder:o.handle?`${o.name}: ${o.handle}`:o.name})]},t)})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(y,{children:"Custom links"}),n.links.map((t,d)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{value:t.title,onChange:o=>{const r=[...n.links];r[d]={...r[d],title:o.target.value},c({links:r})},placeholder:"Title",className:"w-2/5"}),e.jsx(j,{value:t.url,onChange:o=>{const r=[...n.links];r[d]={...r[d],url:o.target.value},c({links:r})},placeholder:"https://..."}),n.links.length>1&&e.jsx(b,{type:"button",variant:"ghost",size:"icon",onClick:()=>c({links:n.links.filter((o,r)=>r!==d)}),children:e.jsx(Q,{className:"size-4"})})]},d)),e.jsxs(b,{type:"button",variant:"outline",size:"sm",onClick:()=>c({links:[...n.links,{title:"",url:""}]}),children:[e.jsx(ee,{className:"size-4"})," Add link"]})]})]}):e.jsx("div",{className:"grid grid-cols-3 gap-3 sm:grid-cols-4 lg:grid-cols-5",children:g.map(t=>e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>c({template_id:t.id}),className:`${n.template_id===t.id?"ring-ring ring-2 ring-offset-2":""} focus:ring-ring relative block w-full overflow-hidden rounded-xl bg-cover bg-center transition-shadow focus:ring-2 focus:ring-offset-2 focus:outline-none`,children:[e.jsx("img",{src:t.screenshot,alt:t.name,className:"w-full"}),e.jsx("div",{className:"absolute inset-0 rounded-xl border border-black/10"})]}),e.jsx("p",{className:"text-muted-foreground mt-1.5 block truncate text-center text-xs",children:t.name})]},t.id))})}function ge({data:i}){const[u,n]=h.useState(""),c=JSON.stringify({name:i.name,title:i.name,bio:i.bio,url:i.url,template_id:i.template_id,socials:Object.entries(i.socials).map(([l,a])=>({platform:l,handle:a})).filter(l=>(l.handle||"").trim()!==""),links:i.links.filter(l=>(l.url||"").trim()!=="").map(l=>({title:l.title,url:l.url}))});return h.useEffect(()=>{const l=setTimeout(()=>{fetch(route("onboarding.preview"),{method:"POST",headers:{"Content-Type":"application/json",...xe()},body:c}).then(a=>a.text()).then(n).catch(()=>{})},300);return()=>clearTimeout(l)},[c]),e.jsx("div",{className:"mx-auto aspect-[37/72] w-full max-w-[290px] overflow-hidden rounded-[2.5rem] border-2 border-dashed border-zinc-400 bg-white",children:e.jsx("iframe",{title:"Live preview",srcDoc:u,className:"h-full w-full"})})}export{Te as default};
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.