PageSourceSearch

https://app.brandstory.ai/_next/static/chunks/83510-1f5f6c0bf2205879.js

js brandstory.ai collected 2026-10-05 11:53:24 UTC 10,516 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[83510],{10984:(e,t,a)=>{a.d(t,{E:()=>n});var l=a(56613),r=a(28519);async function s(){let{uid:e}=await (0,r.getFirebaseUserData)(),t=e??await (0,r.getFirebaseUid)();if(!t)throw Error("Please log in to open Media Library");return t}async function i(e){let t=e??await s(),a=await fetch(`/api/ai-media/list?firebaseUid=${encodeURIComponent(t)}`),l=await a.json();if(!a.ok||!l.success||!l.data)throw Error(l.error||"Failed to load Media Library");return l.data}async function n(e){let t=await i(e);return(0,l.wY)(t)}},15997:(e,t,a)=>{a.d(t,{dA:()=>r});let l={"social-posts":"Social Post",carousels:"Carousel",infographics:"Infographic","twitter-threads":"X Thread","reels-shorts":"Reel / Short","ad-copy":"Ad Copy"};function r(e){return e?l[e]||e.replace(/-/g," "):"Social Post"}},23025:(e,t,a)=>{a.d(t,{A:()=>m});var l=a(95155),r=a(12115),s=a(98500),i=a.n(s),n=a(35137),o=a(15997),d=a(10984),c=a(48273),u=a(56613);function m({isOpen:e,onClose:t,title:a="Media Library",images:s,loading:y=!1,onSelect:x,sessionImages:g=[],onSelectSessionImage:p}){let{canUseProduct:h}=(0,c.N)(),[f,b]=(0,r.useState)(!1),[v,j]=(0,r.useState)([]),[w,N]=(0,r.useState)(!1),[k,K]=(0,r.useState)(null),[S,$]=(0,r.useState)("all"),[C,_]=(0,r.useState)("all"),[M,O]=(0,r.useState)(""),[U,A]=(0,r.useState)(""),E=!!s;(0,r.useEffect)(()=>{if(!e||E)return;let t=!1;return N(!0),K(null),(async()=>{try{let e=await (0,d.E)();t||j(e)}catch(e){t||(j([]),K(e instanceof Error?e.message:"Failed to load Media Library"))}finally{t||N(!1)}})(),()=>{t=!0}},[e,E]),(0,r.useEffect)(()=>{e||($("all"),_("all"),O(""),A(""))},[e]);let L=(0,r.useMemo)(()=>E&&s?s.map(e=>({id:e.id,key:e.s3Key,url:e.imageUrl,source:"blog"===e.source?"blog":"social"===e.source?"social":"image-gen",dateKey:"",label:e.title,title:e.title,monthKey:"",dateOnly:""})):v,[E,s,v]),I=(0,r.useMemo)(()=>(0,u.Sn)(L),[L]),F=(0,r.useMemo)(()=>(0,u.KM)(L,{source:S,contentType:C,monthKey:M||void 0,search:U}),[L,S,C,M,U]),T=E?y:w;if(!e)return null;let z=async e=>{b(!0);try{await x((0,u.ao)(e)),t()}finally{b(!1)}},G=g.length>0,P=F.length>0;return(0,l.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 backdrop-blur-sm p-4",children:(0,l.jsxs)("div",{className:"bg-white rounded-2xl shadow-2xl w-full max-w-3xl max-h-[90vh] flex flex-col animate-in zoom-in-95 fade-in duration-200",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between gap-3 p-4 border-b border-gray-200",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,l.jsx)("div",{className:"w-10 h-10 shrink-0 bg-primary/10 text-primary rounded-xl flex items-center justify-center",children:(0,l.jsx)(n.QPV,{size:20})}),(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("h3",{className:"text-lg font-bold text-gray-900 truncate",children:a}),(0,l.jsx)("p",{className:"text-xs text-gray-500",children:"Your S3 images — filter by type, month, or search"})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[h("media-library")?(0,l.jsx)(i(),{href:"/ai-media",className:"hidden sm:inline text-xs font-semibold text-primary hover:underline",onClick:t,children:"Open full library"}):null,(0,l.jsx)("button",{type:"button",onClick:t,className:"p-2 text-gray-400 hover:text-gray-600 rounded-lg transition-colors",children:(0,l.jsx)(n.yGN,{size:20})})]})]}),(0,l.jsxs)("div",{className:"px-4 pt-3 pb-2 border-b border-gray-100 space-y-3",children:[(0,l.jsx)("div",{className:"flex flex-wrap gap-2",children:u.c1.map(e=>(0,l.jsx)("button",{type:"button",onClick:()=>$(e.value),className:`rounded-lg px-3 py-1.5 text-xs font-semibold transition-colors ${S===e.value?"bg-primary text-white":"bg-gray-100 text-gray-700 hover:bg-gray-200"}`,children:e.label},e.value))}),(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:["social"===S&&(0,l.jsxs)("select",{value:C,onChange:e=>_(e.target.value),className:"rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs text-gray-800",children:[(0,l.jsx)("option",{value:"all",children:"All formats"}),(0,l.jsx)("option",{value:"social-posts",children:(0,o.dA)("social-posts")}),(0,l.jsx)("option",{value:"carousels",children:(0,o.dA)("carousels")})]}),(0,l.jsxs)("select",{value:M,onChange:e=>O(e.target.value),className:"rounded-lg border border-gray-200 bg-white px-3 py-2 text-xs text-gray-800 min-w-[130px]",children:[(0,l.jsx)("option",{value:"",children:"All months"}),I.map(e=>(0,l.jsx)("option",{value:e,children:(0,u.Nt)(e)},e))]}),(0,l.jsxs)("div",{className:"relative flex-1 min-w-[160px]",children:[(0,l.jsx)(n.CKj,{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400",size:14}),(0,l.jsx)("input",{type:"text",value:U,onChange:e=>A(e.target.value),placeholder:"Search by name...",className:"w-full rounded-lg border border-gray-200 bg-white pl-9 pr-3 py-2 text-xs text-gray-800 placeholder:text-gray-400"})]})]})]}),(0,l.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 custom-scrollbar",children:[G&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)("p",{className:"text-xs font-bold uppercase tracking-wider text-gray-500 mb-2",children:"From this session"}),(0,l.jsx)("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-3 mb-6",children:g.map(e=>(0,l.jsxs)("button",{type:"button",onClick:()=>{p?.(e.imageUrl),t()},className:"relative aspect-square rounded-xl border-2 border-gray-200 overflow-hidden bg-gray-50 hover:border-primary hover:ring-2 hover:ring-primary/20 transition-all",children:[(0,l.jsx)("img",{src:e.imageUrl,alt:e.title,className:"w-full h-full object-cover"}),(0,l.jsx)("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-white text-[10px] font-semibold px-2 py-1 truncate",children:e.title||"Generated"})]},e.id))})]}),(0,l.jsx)("p",{className:"text-xs font-bold uppercase tracking-wider text-gray-500 mb-2",children:"Your library"}),k&&(0,l.jsx)("div",{className:"mb-3 rounded-lg bg-red-50 px-3 py-2 text-xs text-red-700",children:k}),T?(0,l.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,l.jsx)("div",{className:"w-10 h-10 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})}):P?(0,l.jsx)("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-3",children:F.map(e=>(0,l.jsxs)("button",{type:"button",onClick:()=>void z(e),disabled:f,className:"relative aspect-square rounded-xl border-2 border-gray-200 overflow-hidden bg-gray-50 hover:border-primary hover:ring-2 hover:ring-primary/20 transition-all disabled:opacity-60",children:[(0,l.jsx)("img",{src:e.url,alt:e.title,className:"w-full h-full object-cover"}),(0,l.jsxs)("div",{className:"absolute bottom-0 left-0 right-0 bg-black/60 text-white text-[10px] font-semibold px-2 py-1 truncate",children:[e.source," \xb7 ",e.title||"Untitled"]})]},e.id))}):(0,l.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-gray-400",children:[(0,l.jsx)(n.QPV,{size:36,className:"mb-2 opacity-50"}),(0,l.jsx)("p",{className:"text-sm font-medium",children:0===L.length?"No images in your library yet.":"No items match your filters."}),L.length>0&&(0,l.jsx)("button",{type:"button",onClick:()=>{$("all"),_("all"),O(""),A("")},className:"mt-2 text-xs font-semibold text-primary hover:underline",children:"Clear filters"})]})]})]})})}},56613:(e,t,a)=>{a.d(t,{KM:()=>d,Nt:()=>i,Sn:()=>c,ao:()=>u,c1:()=>l,mg:()=>n,wY:()=>o});let l=[{value:"all",label:"All"},{value:"image-gen",label:"Image Gen"},{value:"social",label:"Social Media"},{value:"blog",label:"Blog"}],r={"01":"Jan","02":"Feb","03":"Mar","04":"Apr","05":"May","06":"Jun","07":"Jul","08":"Aug","09":"Sep",10:"Oct",11:"Nov",12:"Dec"};function s(e){if(!e)return{monthKey:"",dateOnly:""};let t=e.trim();if(/^\d{8}_/.test(t)){let e=t.slice(0,4),a=t.slice(4,6),l=t.slice(6,8);return{monthKey:`${e}-${a}`,dateOnly:`${e}-${a}-${l}`}}let a=t.slice(0,10);if(/^\d{4}-\d{2}-\d{2}$/.test(a)){let[e,t,l]=a.split("-");return{monthKey:`${e}-${t}`,dateOnly:a}}return{monthKey:t.slice(0,7),dateOnly:t.slice(0,10)}}
1function i(e){let[t,a]=e.split("-");return t&&a?`${r[a]||a} ${t}`:e}function n(e){let t=e.split("-");if(3!==t.length)return e;let[,a,l]=t;return`${r[a]||a} ${l}, ${t[0]}`}function o(e){if(!e)return[];if(e.items&&e.items.length>0)return[...e.items].sort((e,t)=>t.dateKey<e.dateKey?-1:+(t.dateKey>e.dateKey));let t=[],a=new Set;for(let l of e.aiGenImages||[]){if(a.has(l.key))continue;a.add(l.key);let{monthKey:e,dateOnly:r}=s(l.date),i=l.sessionId||"Image Gen";t.push({id:l.key,key:l.key,url:l.url,source:"image-gen",dateKey:l.date,label:`${i} ${l.date}`,title:i,monthKey:e,dateOnly:r})}for(let l of e.socialMediaRuns||[]){let{monthKey:e,dateOnly:r}=s(l.timestamp_date);for(let s of l.assets){if(a.has(s.key))continue;a.add(s.key);let i=/^post_\d+_slide_\d+$/.test(s.slugOrKey||""),n=s.slugOrKey?.startsWith("calendar_"),o=s.slugOrKey||"Social";t.push({id:s.key,key:s.key,url:s.url,source:"social",dateKey:l.timestamp_date,label:`${o} ${l.timestamp_date}`,title:n?o.replace(/^calendar_/,"").replace(/_/g," "):o,monthKey:e,dateOnly:r,contentType:i?"carousels":"social-posts"})}}for(let l of e.blogRuns||[]){let{monthKey:e,dateOnly:r}=s(l.timestamp_date);for(let s of l.assets){if(a.has(s.key))continue;a.add(s.key);let i=s.slug||"Blog";t.push({id:s.key,key:s.key,url:s.url,source:"blog",dateKey:l.timestamp_date,label:`${i} ${l.timestamp_date}`,title:i,monthKey:e,dateOnly:r})}}return t.sort((e,t)=>t.dateKey<e.dateKey?-1:+(t.dateKey>e.dateKey))}function d(e,t){let a=e,l=t.source??"all";"all"!==l&&(a=a.filter(e=>e.source===l)),"social"===l&&t.contentType&&"all"!==t.contentType&&(a=a.filter(e=>e.contentType===t.contentType)),t.monthKey&&(a=a.filter(e=>e.monthKey===t.monthKey)),t.dateOnly&&(a=a.filter(e=>e.dateOnly===t.dateOnly));let r=t.search?.trim().toLowerCase();return r&&(a=a.filter(e=>e.label.toLowerCase().includes(r)||e.title.toLowerCase().includes(r)||e.key.toLowerCase().includes(r))),a}function c(e){let t=new Set;return e.forEach(e=>{e.monthKey&&t.add(e.monthKey)}),Array.from(t).sort().reverse()}function u(e){return{id:e.id,s3Key:e.key,imageUrl:e.url,title:e.title,source:e.source,folderName:null,contentId:e.id,label:"blog"===e.source?"Blog":"social"===e.source?"Social":"Image Gen"}}},98054:(e,t,a)=>{a.d(t,{RM:()=>l});function l(e,t={}){let a=new URLSearchParams({s3Key:e});"raw"===t.format&&a.set("format","raw");let r=t.firebaseUid?.trim();return r&&a.set("firebaseUid",r),`/api/content-writer/download-image?${a.toString()}`}}}]);

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.