1import{ai as s,s as d,aj as m}from"./index-DnWsV7cE.js";import"./animation-CddyXVCz.js";import"./react-vendor-CbN3pvl2.js";import"./supabase-iKSPld20.js";import"./docgen-Bp8WKBAE.js";import"./query-DPqpbKNH.js";const a="/api/portfolio",h=()=>{if(!d)throw new Error("Supabase client is not configured");return d};async function u(t,e={}){const o=h(),{data:{session:r}}=await o.auth.getSession(),n=r==null?void 0:r.access_token;if(!n)throw new Error("Authentication required");return fetch(t,{...e,headers:{"Content-Type":"application/json",...e.headers||{},Authorization:`Bearer ${n}`}})}async function f(t,e){const o=await t.json().catch(()=>({}));return new Error(m(o,e))}function g(t){if(!t)throw new Error("Profile snapshot is required");if(!t.fullName||s(t.fullName)==="")throw new Error("Profile must have a fullName");if(!t.experience&&!t.skills&&!t.education)throw new Error("Profile must have at least one of: experience, skills, or education")}async function p(t,e){if(!t||typeof t!="string")throw new Error("Valid slug is required");const o=s(t);if(!o)throw new Error("Slug cannot be empty");const r=e?`?password=${encodeURIComponent(e)}`:"",n=await fetch(`/api/portfolio/by-slug/${encodeURIComponent(o)}${r}`);if(n.status===404)return null;if(n.status===403){const i=await n.json().catch(()=>({}));if(i!=null&&i.invalidPassword)throw new Error("INVALID_PORTFOLIO_PASSWORD");if(i!=null&&i.requiresPassword)throw new Error("PORTFOLIO_PASSWORD_REQUIRED")}if(!n.ok)throw new Error("Failed to load portfolio");return n.json()}async function E(){const t=await u(`${a}/my`,{method:"GET"});if(t.status===404)return null;if(!t.ok)throw await f(t,"Failed to load portfolio");return t.json()}async function S(t){if(!t)throw new Error("Portfolio input is required");if(g(t.profile_snapshot),!t.slug||typeof t.slug!="string")throw new Error("Slug is required");const e=s(t.slug);if(!e)throw new Error("Slug cannot be empty");const o=await u(a,{method:"POST",body:JSON.stringify({...t,slug:e})});if(!o.ok)throw await f(o,"Failed to create portfolio");return o.json()}async function P(t){if(!t)throw new Error("Portfolio input is required");if(t.profile_snapshot&&g(t.profile_snapshot),t.slug&&!s(t.slug))throw new Error("Slug cannot be empty");const e=t.slug?s(t.slug):void 0,o=await u(a,{method:"PUT",body:JSON.stringify({...t,...e?{slug:e}:{}})});if(!o.ok)throw await f(o,"Failed to update portfolio");return o.json()}async function b(t){return p(t)}async function k(){const t=h(),{data:{session:e}}=await t.auth.getSession(),o=e==null?void 0:e.access_token;if(!o)throw new Error("Authentication required");const r=await fetch("/api/portfolio/analytics",{headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`}});if(!r.ok)throw new Error("Failed to load portfolio analytics");return r.json()}async function A(t){if(!t||typeof t!="string")throw new Error("Valid slug is required");const e=s(t);if(!e)throw new Error("Slug cannot be empty");const o=await u(a,{method:"PUT",body:JSON.stringify({slug:e,is_public:!0})});if(!o.ok)throw await f(o,"Failed to publish portfolio")}async function $(){const t=await u(a,{method:"PUT",body:JSON.stringify({is_public:!1})});if(!t.ok)throw await f(t,"Failed to unpublish portfolio")}async function T(t){const e=s(t);if(!e)return!1;const o=await fetch(`${a}/check-slug/${encodeURIComponent(e)}`);
1if(!o.ok)throw new Error("Unable to verify slug availability");const r=await o.json().catch(()=>({available:!1}));return!!(r!=null&&r.available)}function y(t){return s(t).toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-{2,}/g,"-").replace(/^-+|-+$/g,"").slice(0,50)}function q(t){const e=y(t||"");return e.length>=3?e:e.padEnd(3,"a")}async function O(t){if(!t)throw new Error("Portfolio ID is required");const e=h(),{data:{session:o}}=await e.auth.getSession(),r=o==null?void 0:o.access_token;if(!r)throw new Error("Authentication required");const n=await fetch(`${a}/${t}/suggestions`,{method:"GET",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},credentials:"include"});if(!n.ok){const l=await n.text();throw new Error(`Failed to fetch suggestions: ${l||n.statusText}`)}return await n.json()}async function j(t,e){if(!t)throw new Error("Portfolio ID is required");if(!e)throw new Error("Content generation options are required");const o=h(),{data:{session:r}}=await o.auth.getSession(),n=r==null?void 0:r.access_token;if(!n)throw new Error("Authentication required");let i,l;if(e.type==="seo")i=`${a}/${t}/generate-seo`,l={targetKeywords:e.targetKeywords};else{const c=e.summaryOptions||{};i=`${a}/${t}/generate-summary`,l={tone:c.tone,length:c.length,targetAudience:c.targetAudience,useSimilarContext:c.useSimilarContext??!1}}const w=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},credentials:"include",body:JSON.stringify(l)});if(!w.ok){const c=await w.text();throw new Error(`Failed to generate content: ${c||w.statusText}`)}return w.json()}const N={getPortfolioBySlug:p,getMyPortfolio:E,createPortfolio:S,updatePortfolio:P,getPortfolioAnalytics:k,getPublicPortfolioData:b,publishPortfolio:A,unpublishPortfolio:$,checkSlugAvailability:T,sanitizeSlug:y,generateSlugFromName:q,getContentSuggestions:O,generateAIContent:j};export{T as checkSlugAvailability,S as createPortfolio,j as generateAIContent,q as generateSlugFromName,O as getContentSuggestions,E as getMyPortfolio,k as getPortfolioAnalytics,p as getPortfolioBySlug,b as getPublicPortfolioData,N as portfolioService,A as publishPortfolio,y as sanitizeSlug,$ as unpublishPortfolio,P as updatePortfolio};
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.