PageSourceSearch

https://shadesurfer.io/assets/Library-Cc-qhc4y.js

js shadesurfer.io collected 2026-10-02 01:58:20 UTC 36,562 bytes, 45 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/jspdf.es.min-BmWmejPr.js","assets/index-ChbMu8x1.js","assets/index-CE8ksyqd.css"])))=>i.map(i=>d[i]);
2import{e as U,an as ae,z as kt,at as ze,r as d,j as e,n as Pt,O as Et,E as qe,au as Rt,k as Ft,F as $t,T as It,D as Lt,l as He,m as Ut,P as Mt,av as Ot,g as S,aw as Ve,u as zt,a as qt,o as Ht,b as Vt,c as Bt,s as C,H as Yt,i as Wt,B as b,S as Gt,I as Re,ag as te,ah as Y,ai as W,ax as ge,ay as ve,az as we,aA as D,t as Fe,aj as G,aB as Xt,X as Zt,aC as $e,aD as Qt,M as Jt,Q as Kt,aE as ea,_ as ta}from"./index-ChbMu8x1.js";import{Footer as aa}from"./Footer-BLMUOdFb.js";import{C as Ie}from"./card-vu4T6uRL.js";import{D as sa,a as ra,b as oa,c as na,d as la,e as ia}from"./dialog-C6XgwX9U.js";import{C as Le}from"./checkbox-DIwr6owX.js";import{c as Be,s as Ue,S as be,C as ye}from"./startOfDay-B_UKJTZP.js";import{P as ca}from"./palette-DAbPXjTP.js";import{C as da}from"./camera-C3taFm9b.js";import{S as ma}from"./square-pen-BGWorfkc.js";import{A as ua}from"./arrow-up-Dgs2MFG7.js";import"./emailValidation-DKnEvLpy.js";import"./edgeFunctionError-NtQcrOfj.js";/**
3 * @license lucide-react v0.462.0 - ISC
4 *
5 * This source code is licensed under the ISC license.
6 * See the LICENSE file in the root directory of this source tree.
7 */const ha=U("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/**
8 * @license lucide-react v0.462.0 - ISC
9 *
10 * This source code is licensed under the ISC license.
11 * See the LICENSE file in the root directory of this source tree.
12 */const pa=U("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/**
13 * @license lucide-react v0.462.0 - ISC
14 *
15 * This source code is licensed under the ISC license.
16 * See the LICENSE file in the root directory of this source tree.
17 */const fa=U("EllipsisVertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);/**
18 * @license lucide-react v0.462.0 - ISC
19 *
20 * This source code is licensed under the ISC license.
21 * See the LICENSE file in the root directory of this source tree.
22 */const xa=U("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
23 * @license lucide-react v0.462.0 - ISC
24 *
25 * This source code is licensed under the ISC license.
26 * See the LICENSE file in the root directory of this source tree.
27 */const ga=U("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
28 * @license lucide-react v0.462.0 - ISC
29 *
30 * This source code is licensed under the ISC license.
31 * See the LICENSE file in the root directory of this source tree.
32 */const va=U("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
33 * @license lucide-react v0.462.0 - ISC
34 *
35 * This source code is licensed under the ISC license.
36 * See the LICENSE file in the root directory of this source tree.
37 */const Me=U("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);function wa(o,l){const c=ae(o);return isNaN(l)?Be(o,NaN):(l&&c.setDate(c.getDate()+l),c)}function Ye(o){return Be(o,Date.now())}function We(o,l){const c=Ue(o),u=Ue(l);return+c==+u}function ba(o){return We(o,Ye(o))}function Oe(o,l){const c=+ae(o),[u,h]=[+ae(l.start),+ae(l.end)].sort((F,y)=>F-y);return c>=u&&c<=h}function De(o,l){return wa(o,-l)}function ya(o){return We(o,De(Ye(o),1))}var Ge="AlertDialog",[ja,Wa]=kt(Ge,[ze]),T=ze(),Xe=o=>{const{__scopeAlertDialog:l,...c}=o,u=T(l);return e.jsx(Ut,{...u,...c,modal:!0})};Xe.displayName=Ge;var Na="AlertDialogTrigger",Ze=d.forwardRef((o,l)=>{const{__scopeAlertDialog:c,...u}=o,h=T(c);return e.jsx(Pt,{...h,...u,ref:l})});Ze.displayName=Na;var Da="AlertDialogPortal",Qe=o=>{const{__scopeAlertDialog:l,...c}=o,u=T(l);return e.jsx(Mt,{...u,...c})};Qe.displayName=Da;var Ca="AlertDialogOverlay",Je=d.forwardRef((o,l)=>{const{__scopeAlertDialog:c,...u}=o,h=T(c);return e.jsx(Et,{...h,...u,ref:l})});Je.displayName=Ca;var O="AlertDialogContent",[Sa,Aa]=ja(O),_a=Ot("AlertDialogContent"),Ke=d.forwardRef((o,l)=>{const{__scopeAlertDialog:c,children:u,...h}=o,F=T(c),y=d.useRef(null),X=qe(l,y),A=d.useRef(null);return e.jsx(Rt,{contentName:O,titleName:et,docsSlug:"alert-dialog",children:e.jsx(Sa,{scope:c,cancelRef:A,children:e.jsxs(Ft,{role:"alertdialog",...F,...h,ref:X,onOpenAutoFocus:$t(h.onOpenAutoFocus,k=>{var P;k.preventDefault(),(P=A.current)==null||P.focus({preventScroll:!0})}),onPointerDownOutside:k=>k.preventDefault(),onInteractOutside:k=>k.preventDefault(),children:[e.jsx(_a,{children:u}),e.jsx(ka,{contentRef:y})]})})})});Ke.displayName=O;var et="AlertDialogTitle",tt=d.forwardRef((o,l)=>{const{__scopeAlertDialog:c,...u}=o,h=T(c);return e.jsx(It,{...h,...u,ref:l})});tt.displayName=et;var at="AlertDialogDescription",st=d.forwardRef((o,l)=>{const{__scopeAlertDialog:c,...u}=o,h=T(c);return e.jsx(Lt,{...h,...u,ref:l})});st.displayName=at;var Ta="AlertDialogAction",rt=d.forwardRef((o,l)=>{const{__scopeAlertDialog:c,...u}=o,h=T(c);return e.jsx(He,{...h,...u,ref:l})});rt.displayName=Ta;var ot="AlertDialogCancel",nt=d.forwardRef((o,l)=>{const{__scopeAlertDialog:c,...u}=o,{cancelRef:h}=Aa(ot,c),F=T(c),y=qe(l,h);return e.jsx(He,{...F,...u,ref:y})});nt.displayName=ot;var ka=({contentRef:o})=>{const l=`\`${O}\` requires a description for the component to be accessible for screen reader users.
38
39You can add a description to the \`${O}\` by passing a \`${at}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
40
41Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${O}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
42
43For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return d.useEffect(()=>{var u;document.getElementById((u=o.current)==null?void 0:u.getAttribute("aria-describedby"))||console.warn(l)},[l,o]),null},Pa=Xe,Ea=Ze,Ra=Qe,lt=Je,it=Ke,ct=rt,dt=nt,mt=tt,ut=st;const je=Pa,Ne=Ea,Fa=Ra,ht=d.forwardRef(({className:o,...l},c)=>e.jsx(lt,{className:S("fixed inset-0 z-50 bg-black/80  data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",o),...l,ref:c}));ht.displayName=lt.displayName;const se=d.forwardRef(({className:o,...l},c)=>e.jsxs(Fa,{children:[e.jsx(ht,{}),e.jsx(it,{ref:c,className:S("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",o),...l})]}));se.displayName=it.displayName;const re=({className:o,...l})=>e.jsx("div",{className:S("flex flex-col space-y-2 text-center sm:text-left",o),...l});re.displayName="AlertDialogHeader";const oe=({className:o,...l})=>e.jsx("div",{className:S("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",o),...l});oe.displayName="AlertDialogFooter";const ne=d.forwardRef(({className:o,...l},c)=>e.jsx(mt,{ref:c,className:S("text-lg font-semibold",o),...l}));ne.displayName=mt.displayName;const le=d.forwardRef(({className:o,...l},c)=>e.jsx(ut,{ref:c,className:S("text-sm text-muted-foreground",o),...l}));le.displayName=ut.displayName;const ie=d.forwardRef(({className:o,...l},c)=>e.jsx(ct,{ref:c,className:S(Ve(),o),...l}));ie.displayName=ct.displayName;const ce=d.forwardRef(({className:o,...l},c)=>e.jsx(dt,{ref:c,className:S(Ve({variant:"outline"}),"mt-2 sm:mt-0",o),...l}));ce.displayName=dt.displayName;const Ga=()=>{const[o,l]=d.useState([]),[c,u]=d.useState(!0),[h,F]=d.useState(""),[y,X]=d.useState(!1),[A,k]=d.useState("all"),[P,pt]=d.useState("newest"),[M,Z]=d.useState(null),[z,q]=d.useState(""),[$,I]=d.useState(new Set),_=d.useRef(null),{user:p}=zt(),{toast:f}=qt(),Ce=Ht(),Se=Vt(),Ae=Bt();d.useEffect(()=>{var t;(t=Ae.state)!=null&&t.scrollToLibrary?setTimeout(()=>{const a=document.querySelector("h1");if(a){const r=a.getBoundingClientRect().top+window.pageYOffset-100;window.scrollTo({top:r,behavior:"smooth"})}},100):window.scrollTo({top:0,behavior:"auto"})},[Ae.state]);const _e=(t,a)=>{if(a==="all")return!0;const s=new Date(Math.max(new Date(t.created_at).getTime(),new Date(t.updated_at).getTime())),r=new Date;switch(a){case"today":return ba(s);case"yesterday":return ya(s);case"last30days":return Oe(s,{start:De(r,30),end:r});case"last90days":return Oe(s,{start:De(r,90),end:r});default:return!0}},de=[{value:"newest",label:"Newest edited",icon:ye},{value:"oldest",label:"Oldest edited",icon:ye},{value:"alphabetical",label:"Alphabetical (A-Z)",icon:ua},{value:"reverse-alphabetical",label:"Alphabetical (Z-A)",icon:ea}];d.useEffect(()=>{if(!p){Se("/login");return}H()},[p,Se]),d.useEffect(()=>{const t=()=>{p&&H()};return window.addEventListener("focus",t),()=>window.removeEventListener("focus",t)},[p]),d.useEffect(()=>{if(!p)return;console.log("Setting up real-time subscription for user:",p.id);const t=s=>{const r=s.detail;console.log("Immediate palette save event:",r),l(n=>n.some(i=>i.id===r.id)?n:[r,...n])};window.addEventListener("palette-saved-immediate",t);const a=C.channel("saved_palettes_changes",{config:{broadcast:{self:!0},presence:{key:p.id}}}).on("postgres_changes",{event:"INSERT",schema:"public",table:"saved_palettes",filter:`user_id=eq.${p.id}`},s=>{console.log("Real-time: New palette saved:",s),l(r=>r.some(m=>m.id===s.new.id)?r:(console.log("Adding new palette to state, current count:",r.length),[s.new,...r]))}).on("postgres_changes",{event:"UPDATE",schema:"public",table:"saved_palettes",filter:`user_id=eq.${p.id}`},s=>{console.log("Real-time: Palette updated:",s),l(r=>r.map(n=>n.id===s.new.id?s.new:n))}).on("postgres_changes",{event:"DELETE",schema:"public",table:"saved_palettes",filter:`user_id=eq.${p.id}`},s=>{console.log("Real-time: Palette deleted:",s),l(r=>r.filter(n=>n.id!==s.old.id))}).subscribe(s=>{console.log("Real-time subscription status:",s),s==="SUBSCRIBED"&&console.log("Real-time connection established successfully")});return()=>{console.log("Cleaning up real-time subscription"),window.removeEventListener("palette-saved-immediate",t),C.removeChannel(a)}},[p]),d.useEffect(()=>{if(!p)return;const t=setInterval(async()=>{var s,r;const{data:a}=await C.from("saved_palettes").select("id, created_at").eq("user_id",p.id).order("created_at",{ascending:!1}).limit(5);if(a&&a.length>0){const n=(s=o[0])==null?void 0:s.created_at,m=(r=a[0])==null?void 0:r.created_at;(!n||m&&new Date(m)>new Date(n))&&(console.log("Detected missing palettes, refreshing..."),H())}},6e4);return()=>clearInterval(t)},[p,o]),d.useEffect(()=>{I(t=>{const a=o.filter(n=>{const m=n.name.toLowerCase().includes(h.toLowerCase()),i=!y||n.favorite,g=_e(n,A);return m&&i&&g}),s=new Set(a.map(n=>n.id));return new Set(Array.from(t).filter(n=>s.has(n)))})},[y,A,h,o]),d.useEffect(()=>{const t=a=>{if(a.code==="Space"){const r=document.querySelectorAll('[data-state="open"]').length>0,n=document.activeElement,m=n&&(n.tagName==="BUTTON"||n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.hasAttribute("role")||n!==document.body);if(!r&&!m){a.preventDefault();const i=document.querySelector("[data-generate-button]");i&&i.click()}}};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[]);const H=async()=>
43{if(p)try{const{data:t,error:a}=await C.from("saved_palettes").select("*").eq("user_id",p.id).order("created_at",{ascending:!1});if(a)throw a;l(t||[])}catch(t){console.error("Error fetching palettes:",t),f({title:"Load Failed",description:"Unable to load your saved palettes.",variant:"destructive"})}finally{u(!1)}},ft=async t=>{try{const{error:a}=await C.from("saved_palettes").delete().eq("id",t);if(a)throw a;l(s=>s.filter(r=>r.id!==t))}catch(a){console.error("Error deleting palette:",a),f({title:"Delete Failed",description:"Unable to delete palette. Please try again.",variant:"destructive"})}},xt=async()=>{if(!(!M||!z.trim()))try{const{error:t}=await C.from("saved_palettes").update({name:z.trim()}).eq("id",M.id);if(t)throw t;const a=new Date().toISOString();l(s=>s.map(r=>r.id===M.id?{...r,name:z.trim(),updated_at:a}:r)),Z(null),q(""),f({title:"Palette Updated",description:"Palette name has been updated."})}catch(t){console.error("Error updating palette:",t),f({title:"Update Failed",description:"Unable to update palette name.",variant:"destructive"})}},gt=async t=>{try{const a=!t.favorite,{error:s}=await C.from("saved_palettes").update({favorite:a}).eq("id",t.id);if(s)throw s;l(r=>r.map(n=>n.id===t.id?{...n,favorite:a}:n)),f({title:a?"Added to Favorites":"Removed from Favorites",description:`${t.name} ${a?"added to":"removed from"} favorites.`})}catch(a){console.error("Error toggling favorite:",a),f({title:"Update Failed",description:"Unable to update favorite status.",variant:"destructive"})}},vt=(t,a)=>{I(s=>{const r=new Set(s);return a?r.add(t):r.delete(t),r})},wt=t=>{I(t?new Set(N.map(a=>a.id)):new Set)},bt=async()=>{try{const t=new Set(N.map(r=>r.id)),a=Array.from($).filter(r=>t.has(r)),{error:s}=await C.from("saved_palettes").delete().in("id",a);if(s)throw s;l(r=>r.filter(n=>!a.includes(n.id))),I(new Set)}catch(t){console.error("Error deleting palettes:",t),f({title:"Delete Failed",description:"Unable to delete selected palettes.",variant:"destructive"})}},yt=()=>{const t=new Set(N.map(a=>a.id));return Array.from($).filter(a=>t.has(a))},me=()=>yt().filter(a=>{const s=o.find(r=>r.id===a);return s&&!s.favorite}),jt=async()=>{try{const t=me();if(t.length===0){f({title:"No Changes",description:"Selected palettes are already favorited."});return}const{error:a}=await C.from("saved_palettes").update({favorite:!0}).in("id",t);if(a)throw a;l(s=>s.map(r=>t.includes(r.id)?{...r,favorite:!0}:r)),I(new Set),f({title:"Added to Favorites",description:`${t.length} palette${t.length>1?"s":""} added to favorites.`})}catch(t){console.error("Error updating favorites:",t),f({title:"Update Failed",description:"Unable to update favorite status.",variant:"destructive"})}},ue=async(t,a)=>{f({title:"Downloading palette",description:"Your palette download is in progress...",duration:3e3});try{const s=Math.max(window.devicePixelRatio||1,1.5),r=1200,n=800,m=document.createElement("canvas"),i=m.getContext("2d");if(!i){f({title:"Download Failed",description:"Unable to create canvas for download",variant:"destructive"});return}m.width=r*s,m.height=n*s,m.style.width=`${r}px`,m.style.height=`${n}px`,i.scale(s,s),i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="high",i.fillStyle="#ffffff",i.fillRect(0,0,r,n);const g=200,V=600,Te=t.colors.filter(v=>v!==""&&v!=="#FFFFFF"),At=Te.length*g,_t=(r-At)/2,he=80;Te.forEach((v,x)=>{const w=_t+x*g,j=20;i.fillStyle=v,i.beginPath(),i.roundRect(w,he,g,V,j),i.fill(),i.fillStyle="#ffffff",i.font="bold 24px Inter, system-ui, sans-serif",i.textAlign="left",i.fillText(v.toUpperCase(),w+20,he+V-80);const E=t.color_names[x];if(E&&E.trim()){const fe=g-40,xe=E.split(" "),B=[];let R="";i.font="18px Inter, system-ui, sans-serif";for(const K of xe){const ee=R+(R?" ":"")+K;i.measureText(ee).width>fe&&R?(B.push(R),R=K):R=ee}R&&B.push(R),B.forEach((K,ee)=>{const Ee=he+V-49+ee*22;i.fillStyle="#ffffff",i.fillText(K,w+20,Ee-1)})}});const L=new Image;L.crossOrigin="anonymous";let J=!1,pe;const Tt=()=>{if(J)return;J=!0,clearTimeout(pe);const v=200,x=L.height*v/L.width,w=n-x-5;i.drawImage(L,r-v-40,w,v,x),i.fillStyle="#666666",i.font="20px Inter, system-ui, sans-serif",i.textAlign="left";const j=n-35;i.fillText(t.name,40,j),Pe()},ke=()=>{if(J)return;J=!0,clearTimeout(pe);const v=n-5;i.fillStyle="#2563eb",i.font="bold 28px Inter, system-ui, sans-serif",i.textAlign="right",i.fillText("SHADESURFER",r-40,v),i.fillStyle="#666666",i.font="20px Inter, system-ui, sans-serif",i.textAlign="left";const x=n-35;i.fillText(t.name,40,x),Pe()};L.onload=Tt,L.onerror=ke,L.src="/lovable-uploads/cb05765d-8bbf-4b73-9dcd-02dae145c852.png",pe=setTimeout(ke,5e3);async function Pe(){try{const v=`${t.name.replace(/[^a-z0-9 ]/gi,"_")}`;if(a==="pdf"){const{jsPDF:x}=await ta(async()=>{const{jsPDF:xe}=await import("./jspdf.es.min-BmWmejPr.js").then(B=>B.j);return{jsPDF:xe}},__vite__mapDeps([0,1,2])),w=m.toDataURL("image/png",1);if(!w||w==="data:,")throw new Error("Canvas is empty");const j=new x("l","mm","a4"),E=297,fe=m.height*E/m.width;j.addImage(w,"PNG",0,0,E,fe,void 0,"FAST"),j.save(`${v}.pdf`)}else{const x=document.createElement("canvas"),w=x.getContext("2d");if(!w)throw new Error("Could not create final canvas context");x.width=r,x.height=n,w.imageSmoothingEnabled=!0,w.imageSmoothingQuality="high",w.drawImage(m,0,0,r,n);const j=document.createElement("a");j.download=`${v}.${a}`;const E=a==="jpeg"?.95:1;j.href=x.toDataURL(`image/${a}`,E),j.click()}try{const w=await(await fetch("https://api.ipify.org?format=json")).json(),j=Intl.DateTimeFormat().resolvedOptions().timeZone;await C.functions.invoke("log-palette-download",{body:{user_id:p==null?void 0:p.id,colors:t.colors,color_names:t.color_names,file_type:a,source_page:"library",palette_name:t.name,ip_address:w.ip,user_agent:navigator.userAgent,t
43imezone:j}})}catch(x){console.error("Failed to log download:",x)}}catch(v){console.error("Download completion error:",v),f({title:"Download Failed",description:"Unable to complete download",variant:"destructive"})}}}catch(s){console.error("Download error:",s),f({title:"Download Failed",description:"Unable to download palette",variant:"destructive"})}},Q=async(t,a)=>{const s=t.colors.map(i=>i.replace("#","")).join(","),r=encodeURIComponent(t.color_names.join(","));let n=`${window.location.origin}/?colors=${s}`;r&&r!==encodeURIComponent(",".repeat(t.colors.length-1))&&(n+=`&names=${r}`),n+="#palette-generator";const m=`Check out my "${t.name}" palette on ShadeSurfer!`;if(a==="facebook")if(Ce){const i=`fb://facewebmodal/f?href=${encodeURIComponent(n)}`,g=`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(n)}`;window.location.href=i,setTimeout(()=>{window.open(g,"_blank")},2e3)}else{const i=`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(n)}`;window.open(i,"_blank","width=600,height=400")}else if(a==="twitter")if(Ce){const i=`twitter://post?message=${encodeURIComponent(`${m} ${n}`)}`,g=`https://twitter.com/intent/tweet?text=${encodeURIComponent(m)}&url=${encodeURIComponent(n)}`;window.location.href=i,setTimeout(()=>{window.open(g,"_blank")},2e3)}else{const i=`https://twitter.com/intent/tweet?text=${encodeURIComponent(m)}&url=${encodeURIComponent(n)}`;window.open(i,"_blank","width=600,height=400")}else if(a==="email"){const i=encodeURIComponent(`ShadeSurfer Color Palette: ${t.name}`),g=encodeURIComponent(`${m}
44
45${n}`);window.location.href=`mailto:?subject=${i}&body=${g}`}else if(a==="copy")try{await navigator.clipboard.writeText(n),f({title:"Link Copied",description:"Palette link copied to clipboard"})}catch(i){console.error("Copy failed:",i),f({title:"Copy Failed",description:"Unable to copy link to clipboard",variant:"destructive"})}},Nt=async t=>{try{const a=t.colors.map(s=>s.toUpperCase()).join(", ");await navigator.clipboard.writeText(a),f({title:"Hex Codes Copied",description:`Copied: ${a}`})}catch(a){console.error("Copy failed:",a),f({title:"Copy Failed",description:"Unable to copy hex codes to clipboard",variant:"destructive"})}},Dt=async(t,a)=>{try{const s=t.toUpperCase();await navigator.clipboard.writeText(s);let r=s+" copied to clipboard";a&&(r=a+" - "+s+" copied to clipboard"),f({title:"Color Copied",description:r})}catch(s){console.error("Copy failed:",s),f({title:"Copy Failed",description:"Unable to copy color to clipboard",variant:"destructive"})}},Ct=(t,a)=>{const s=new Date(t),r=new Date,n=new Date(r.getFullYear(),r.getMonth(),r.getDate()),m=new Date(n.getTime()-24*60*60*1e3),i=new Date(s.getFullYear(),s.getMonth(),s.getDate()),g=s.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"});if(i.getTime()===n.getTime())return`${a} today at ${g}`;if(i.getTime()===m.getTime())return`${a} yesterday at ${g}`;{const V=s.toLocaleDateString(void 0,{month:"short",day:"numeric",year:s.getFullYear()!==r.getFullYear()?"numeric":void 0});return`${a} on ${V} at ${g}`}},St=t=>{_.current&&(_.current.loadPalette(t.colors,t.color_names,t.id,t.name),window.scrollTo({top:0,behavior:"smooth"}))},N=o.filter(t=>{const a=t.name.toLowerCase().includes(h.toLowerCase()),s=!y||t.favorite,r=_e(t,A);return a&&s&&r}).sort((t,a)=>{switch(P){case"newest":const s=t.updated_at!==t.created_at?new Date(t.updated_at):new Date(t.created_at);return(a.updated_at!==a.created_at?new Date(a.updated_at):new Date(a.created_at)).getTime()-s.getTime();case"oldest":const n=t.updated_at!==t.created_at?new Date(t.updated_at):new Date(t.created_at),m=a.updated_at!==a.created_at?new Date(a.updated_at):new Date(a.created_at);return n.getTime()-m.getTime();case"alphabetical":return t.name.toLowerCase().localeCompare(a.name.toLowerCase());case"reverse-alphabetical":return a.name.toLowerCase().localeCompare(t.name.toLowerCase());default:return 0}});return p?e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(Yt,{}),e.jsx("div",{className:"w-full",children:e.jsx(Wt,{ref:_,hideHelpText:!0,startWithBlankBlocks:!0,onSavedPaletteView:()=>{H(),setTimeout(()=>{const t=document.querySelector("main");t&&t.scrollIntoView({behavior:"smooth"})},100)},onPaletteUpdated:()=>{H()}})}),e.jsxs("main",{className:"max-w-6xl mx-auto px-4 py-4",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex items-center gap-3 mb-4",children:e.jsx("h1",{className:"text-4xl font-bold",children:"My Library"})}),e.jsx("p",{className:"text-xl text-muted-foreground mb-6",children:"Manage your saved color palettes"}),$.size>0&&e.jsxs("div",{className:"mb-4 p-4 bg-muted/50 rounded-lg space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:(()=>{const t=Array.from($).filter(a=>N.some(s=>s.id===a)).length;return`${t} palette${t>1?"s":""} selected`})()}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>I(new Set),children:"Clear Selection"})]}),e.jsxs("div",{className:"flex gap-2 justify-center sm:justify-start",children:[e.jsxs(je,{children:[e.jsx(Ne,{asChild:!0,children:e.jsxs(b,{variant:"outline",size:"sm",disabled:me().length===0,className:"flex-1 sm:flex-none",children:[e.jsx(be,{className:"w-4 h-4 mr-2"}),"Add to Favorites"]})}),e.jsxs(se,{children:[e.jsxs(re,{children:[e.jsx(ne,{children:"Add to Favorites"}),e.jsx(le,{children:(()=>{const t=me().length;return`Are you sure you want to add ${t} palette${t>1?"s":""} to favorites?`})()})]}),e.jsxs(oe,{children:[e.jsx(ce,{children:"Cancel"}),e.jsx(ie,{onClick:jt,children:"Add to Favorites"})]})]})]}),e.jsxs(je,{children:[e.jsx(Ne,{asChild:!0,children:e.jsxs(b,{variant:"destructive",size:"sm",className:"flex-1 sm:flex-none",children:[e.jsx(Me,{className:"w-4 h-4 mr-2"}),"Delete Selected"]})}),e.jsxs(se,{children:[e.jsxs(re,{children:[e.jsx(ne,{children:"Delete Palettes"}),e.jsx(le,{children:(()=>{const t=Array.from($).filter(a=>N.some(s=>s.id===a)).length;return`Are you sure you want to delete ${t} palette${t>1?"s":""}? This action cannot be undone.`})()})]}),e.jsxs(oe,{children:[e.jsx(ce,{children:"Cancel"}),e.jsx(ie,{onClick:bt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative w-full md:max-w-2xl",children:[e.jsx(Gt,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground w-4 h-4"}),e.jsx(Re,{placeholder:"Search palettes...",value:h,onChange:t=>F(t.target.value),className:"pl-10 text-base w-full"})]}),e.jsx("div",{className:"flex gap-3 justify-start",children:e.jsxs(te,{children:[e.jsxs(Y,{children:[e.jsx(W,{asChild:!0,children:e.jsxs(ge,{children:[e.jsx(ve,{asChild:!0,children:e.jsxs(b,{variant:"outline",className:"flex items-center gap-2 md:w-auto min-w-[100px] w-auto justify-start",children:[e.jsx(ha,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:(()=>{const t=de.find(a=>a.value===P);return(t==null?void 0:t.label)||"Sort by"})()}),e.jsx("span",{className:"sm:hidden text-left flex-1 truncate",children:(()=>{const t=de.find(a=>a.value===P);return(t==null?void 0:t.label)||"Sort by"})()})]})}),e.jsxs(we,{align:"start",className:"w-64 p-2 bg-card/95 backdrop-blur-sm border border-border/50 shadow-2xl rounded-xl",sideOffset:8,children:[e.jsx("div",{className:"px-3 py-2 text-sm font-semibold border-b border-border/50 mb-2",children:"Sort By"}),de.map(t=>{const a=t.icon;return e.jsxs(D,{onClick:()=>
45pt(t.value),className:S("rounded-lg p-3 hover:bg-accent/50 transition-colors cursor-pointer flex items-center gap-3",P===t.value&&"bg-primary/10 text-primary"),children:[e.jsx(a,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"font-medium",children:t.label}),P===t.value&&e.jsx(Fe,{className:"w-4 h-4 ml-auto text-primary"})]},t.value)})]})]})}),e.jsx(G,{children:e.jsx("p",{children:"Arrange"})})]}),e.jsxs(Y,{children:[e.jsx(W,{asChild:!0,children:e.jsxs(ge,{children:[e.jsx(ve,{asChild:!0,children:e.jsxs(b,{variant:y||A!=="all"?"default":"outline",className:"flex items-center gap-2",children:[e.jsx(ga,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Filter"})]})}),e.jsxs(we,{align:"start",className:"w-64 p-2 bg-card/95 backdrop-blur-sm border border-border/50 shadow-2xl rounded-xl",sideOffset:8,children:[e.jsx("div",{className:"px-3 py-2 text-sm font-semibold border-b border-border/50 mb-2",children:"Filters"}),e.jsxs(D,{onClick:()=>X(!y),className:"rounded-lg p-3 hover:bg-accent/50 transition-colors cursor-pointer flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 rounded flex items-center justify-center",children:y&&e.jsx(Fe,{className:"w-3 h-3 text-primary"})}),e.jsx(be,{className:"w-5 h-5 text-yellow-400"}),e.jsx("span",{className:"font-medium",children:"Favorites only"})]}),e.jsx("div",{className:"my-2 border-t border-border/50"}),e.jsx("div",{className:"px-3 py-2 text-sm font-semibold border-b border-border/50 mb-2",children:"Last Modified"}),[{value:"all",label:"All time"},{value:"today",label:"Today"},{value:"yesterday",label:"Yesterday"},{value:"last30days",label:"Last 30 days"},{value:"last90days",label:"Last 90 days"}].map(t=>e.jsxs(D,{onClick:()=>k(t.value),className:"rounded-lg p-3 hover:bg-accent/50 transition-colors cursor-pointer flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 rounded-full flex items-center justify-center",children:A===t.value&&e.jsx("div",{className:"w-2.5 h-2.5 bg-primary rounded-full"})}),e.jsx(ye,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"font-medium",children:t.label})]},t.value)),(y||A!=="all")&&e.jsxs(e.Fragment,{children:[e.jsx(Xt,{}),e.jsxs(D,{onClick:()=>{X(!1),k("all")},className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Zt,{className:"w-4 h-4"}),"Clear all filters"]})]})]})]})}),e.jsx(G,{children:e.jsx("p",{children:"Filter palettes"})})]})]})}),N.length>0&&e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Le,{checked:$.size===N.length&&N.length>0,onCheckedChange:wt,className:"w-5 h-5 border-primary/50"}),e.jsx("span",{className:"text-base text-muted-foreground",children:"Select all"})]}),e.jsx(te,{children:e.jsxs(Y,{children:[e.jsx(W,{asChild:!0,children:e.jsxs(b,{onClick:()=>{_.current&&(_.current.loadPalette(["","","","",""],["","","","",""],"","New Palette"),window.scrollTo({top:0,behavior:"smooth"}))},className:"flex items-center gap-2 bg-gradient-to-r from-blue-500 to-blue-600 hover:from-blue-600 hover:to-blue-700 text-white shadow-xl shadow-blue-500/25",children:[e.jsx($e,{className:"w-5 h-5"}),"Create New"]})}),e.jsx(G,{children:e.jsx("p",{children:"Create a new blank palette"})})]})})]}),!c&&N.length===0&&e.jsx("div",{className:"flex justify-end",children:e.jsx(te,{children:e.jsxs(Y,{children:[e.jsx(W,{asChild:!0,children:e.jsxs(b,{onClick:()=>{_.current&&(_.current.loadPalette(["","","","",""],["","","","",""],"","New Palette"),window.scrollTo({top:0,behavior:"smooth"}))},className:"flex items-center gap-2 bg-gradient-to-r from-blue-500 to-blue-600 hover:from-blue-600 hover:to-blue-700 text-white shadow-xl shadow-blue-500/25",children:[e.jsx($e,{className:"w-5 h-5"}),"Create New"]})}),e.jsx(G,{children:e.jsx("p",{children:"Create a new blank palette"})})]})})})]})]}),c?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[...Array(6)].map((t,a)=>e.jsxs(Ie,{className:"p-6 animate-pulse",children:[e.jsx("div",{className:"h-4 bg-muted rounded mb-4"}),e.jsx("div",{className:"flex gap-2 mb-4",children:[...Array(5)].map((s,r)=>e.jsx("div",{className:"w-8 h-8 bg-muted rounded"},r))}),e.jsx("div",{className:"h-8 bg-muted rounded"})]},a))}):N.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(ca,{className:"w-16 h-16 text-muted-foreground mx-auto mb-4"}),e.jsx("h3",{className:"text-xl font-semibold mb-2",children:h?"No palettes found":"No saved palettes yet"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:h?"Try adjusting your search terms":"Create and save your first color palette to get started"}),!h&&e.jsx(b,{onClick:()=>{_.current&&(_.current.loadPalette(["","","","",""],["","","","",""],"","New Palette"),window.scrollTo({top:0,behavior:"smooth"}))},className:"bg-gradient-to-r from-blue-500 to-blue-600 hover:from-blue-600 hover:to-blue-700 text-white shadow-xl shadow-blue-500/25",children:"Create Palette"})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:N.map(t=>e.jsxs(Ie,{className:"p-6 hover:shadow-lg transition-shadow relative",children:[e.jsx("div",{className:"absolute top-4 left-4",children:e.jsx(Le,{checked:$.has(t.id),onCheckedChange:a=>
45vt(t.id,a),className:"w-5 h-5 border-primary/50"})}),e.jsx("div",{className:"absolute top-2 right-20",children:e.jsx(b,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:()=>gt(t),children:e.jsx(be,{className:S("h-4 w-4",t.favorite?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400")})})}),e.jsx("div",{className:"absolute top-2 right-12",children:e.jsxs(ge,{children:[e.jsx(ve,{asChild:!0,children:e.jsx(b,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 focus-visible:ring-0 focus-visible:ring-offset-0",children:e.jsx(fa,{className:"h-4 w-4"})})}),e.jsxs(we,{align:"end",className:"w-56 p-2 bg-card/95 backdrop-blur-sm border border-border/50 shadow-2xl rounded-xl",sideOffset:8,children:[e.jsxs(D,{onClick:()=>ue(t,"png"),className:"rounded-lg p-3 hover:bg-accent/50 transition-colors cursor-pointer",children:[e.jsx(Qt,{className:"mr-3 h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:"Download PNG"})]}),e.jsxs(D,{onClick:()=>ue(t,"jpeg"),className:"rounded-lg p-3 hover:bg-accent/50 transition-colors cursor-pointer",children:[e.jsx(da,{className:"mr-3 h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:"Download JPEG"})]}),e.jsxs(D,{onClick:()=>ue(t,"pdf"),className:"rounded-lg p-3 hover:bg-accent/50 transition-colors cursor-pointer",children:[e.jsx(xa,{className:"mr-3 h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:"Download PDF"})]}),e.jsx("div",{className:"my-2 border-t border-border/50"}),e.jsxs(D,{onClick:()=>Q(t,"copy"),className:"rounded-lg p-3 hover:bg-accent/50 transition-colors cursor-pointer",children:[e.jsx(va,{className:"mr-3 h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:"Copy Link"})]}),e.jsxs(D,{onClick:()=>Q(t,"email"),className:"rounded-lg p-3 hover:bg-accent/50 transition-colors cursor-pointer",children:[e.jsx(Jt,{className:"mr-3 h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:"Share via Email"})]}),e.jsxs(D,{onClick:()=>Q(t,"facebook"),className:"rounded-lg p-3 hover:bg-accent/50 transition-colors cursor-pointer",children:[e.jsx(Kt,{className:"mr-3 h-5 w-5 text-primary"}),e.jsx("span",{className:"font-medium",children:"Share on Facebook"})]}),e.jsxs(D,{onClick:()=>Q(t,"twitter"),className:"rounded-lg p-3 hover:bg-accent/50 transition-colors cursor-pointer",children:[e.jsx("svg",{className:"mr-3 h-5 w-5 text-primary",fill:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),e.jsx("span",{className:"font-medium",children:"Share on X (Twitter)"})]})]})]})}),e.jsx("div",{className:"absolute top-2 right-4",children:e.jsxs(je,{children:[e.jsx(Ne,{asChild:!0,children:e.jsx(b,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",children:e.jsx(Me,{className:"h-4 w-4"})})}),e.jsxs(se,{children:[e.jsxs(re,{children:[e.jsx(ne,{children:"Delete Palette"}),e.jsxs(le,{children:['Are you sure you want to delete "',t.name,'"? This action cannot be undone.']})]}),e.jsxs(oe,{children:[e.jsx(ce,{children:"Cancel"}),e.jsx(ie,{onClick:()=>ft(t.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})}),e.jsxs("div",{className:"mb-4 pr-8 pl-8 mt-3",children:[e.jsx("h3",{className:"font-semibold text-lg mb-2 truncate",title:t.name,children:t.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:e.jsx("p",{children:Ct(new Date(t.updated_at)>new Date(t.created_at)?t.updated_at:t.created_at,"Last modified")})})]}),e.jsx("div",{className:"flex gap-1 mb-4 rounded overflow-hidden",children:t.colors.map((a,s)=>e.jsx(te,{children:e.jsxs(Y,{children:[e.jsx(W,{asChild:!0,children:e.jsx("div",{className:"flex-1 h-12 cursor-pointer hover:scale-105 transition-transform",style:{backgroundColor:a},onClick:()=>Dt(a,t.color_names[s])})}),e.jsx(G,{children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:t.color_names[s]||"Unnamed"}),e.jsx("p",{className:"text-sm opacity-80",children:a.toUpperCase()})]})})]})},s))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(b,{variant:"outline",size:"sm",onClick:()=>St(t),className:"flex-1",children:"View"}),e.jsxs(sa,{open:(M==null?void 0:M.id)===t.id,onOpenChange:a=>{a||(Z(null),q(""))},children:[e.jsx(ra,{asChild:!0,children:e.jsx(b,{variant:"outline",size:"sm",onClick:()=>{Z(t),q(t.name)},children:e.jsx(ma,{className:"w-4 h-4"})})}
45),e.jsxs(oa,{className:"z-50",children:[e.jsxs(na,{children:[e.jsx(la,{children:"Edit Palette Name"}),e.jsx(ia,{children:"Change the name of your palette"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"text-sm font-medium text-foreground",children:["Palette name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(Re,{value:z,onChange:a=>q(a.target.value),placeholder:"Palette name",maxLength:50,required:!0})]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(b,{variant:"outline",onClick:()=>{Z(null),q("")},children:"Cancel"}),e.jsx(b,{onClick:xt,disabled:!z.trim(),children:"Save Changes"})]})]})]})]}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>Nt(t),title:"Copy hex codes to clipboard",children:e.jsx(pa,{className:"w-4 h-4"})})]})]},t.id))})]}),e.jsx(aa,{})]}):null};export{Ga 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.