PageSourceSearch

https://myechoboard.com/assets/Boards-BU3HYjzf.js

js myechoboard.com collected 2026-10-02 00:19:06 UTC 116,858 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/BoardEditor-Bo450zR3.js","assets/vendor-react-BfgFmtGS.js","assets/button-CYJdLL_L.js","assets/index-h37mMD1s.js","assets/index-nwDrq1j8.js","assets/runtime-utils-GN4cODRt.js","assets/input-Cv-gXlbe.js","assets/switch-D6ZBFPtn.js","assets/index-Bj_QpGJn.js","assets/index-DvGZCNsD.js","assets/index-BqeBQ1B3.js","assets/index-YTuft30H.js","assets/checkbox-BodSXXPo.js","assets/check-0D421DYe.js","assets/createLucideIcon-D9HkCDkl.js","assets/avatar-DkgobaOn.js","assets/index-BjK_cEYO.js","assets/select-CqFAxzgg.js","assets/index-jVOyRz7F.js","assets/index-DpcxEmoq.js","assets/index-X6GuMWhc.js","assets/index-8Q0hjuah.js","assets/Combination-BntiNnUt.js","assets/vendor-supabase-BL1taoPA.js","assets/index-DYDcV3bE.js","assets/index-BQmzLb9B.js","assets/index-iLL8Ykfz.js","assets/chevron-down-B1qfJDmk.js","assets/chevron-up-BtWriVc7.js","assets/dialog-C7V6oQ1v.js","assets/index-BRWrGhkK.js","assets/x-DV2I6wJI.js","assets/alert-dialog-DEiWzkJW.js","assets/useBoards-B6p3dWJB.js","assets/supabase-client-2CObC91N.js","assets/startup-platform-OWIpYyjW.js","assets/supabase-config-BOS-KsQP.js","assets/boardPreviewBatch-DDWXX98y.js","assets/boundedRequest-B4Q3Iimu.js","assets/boardPreviewPolicy-CiaGHKpD.js","assets/echoTypePolicy-D6McwraQ.js","assets/useAuth-DynbexoK.js","assets/useUserSettings-COWmNJt_.js","assets/runtime-preload-CFP917pd.js","assets/vendor-query-XXY4vl9u.js","assets/startup-core-CGeUO7uJ.js","assets/startup-diagnostics-bridge-BB8dzHvV.js","assets/app-_uSXIk0p.js","assets/vendor-capacitor-8exTJy5k.js","assets/documentVisibilitySubscriptions-CqVNm4Da.js","assets/nativeAppStateSubscriptions-Cv_2m-ZS.js","assets/perfConfig-SmqTTOuO.js","assets/useSubscription-qVychEH1.js","assets/UpgradeModal-DmrzVSpI.js","assets/drawer-YADT050z.js","assets/use-mobile-CmledQOG.js","assets/mediaQueryStore-tM2KFt8V.js","assets/vendor-router-QOYqHwMx.js","assets/zap-Cfd9IgAT.js","assets/sparkles-Bqh4sfNh.js","assets/dbMetrics-D5Q8D3iF.js","assets/idleStorage-DCX8Fjfi.js","assets/boardCardSize-DMpJ9b3m.js","assets/boundedAsyncPool-BG_N2Lbq.js","assets/rpcCapabilityCache-CVP6KxZ_.js","assets/image-utils-BFdDQ3hX.js","assets/useSharedBoards-BlwWTy6S.js","assets/shareUrls-CnKIAmlW.js","assets/boardViewSettings-ZyAkPc6J.js","assets/boardSectionMemberships-CyLE2d-C.js","assets/MoveToBoardDialog-DNnF48Ei.js","assets/BoardPreviewAvatar-BIAe0D67.js","assets/VideoPosterOnly-CkOjVgFa.js","assets/videoUtils-CgPXwgg1.js","assets/performanceTier-CKmYu9lG.js","assets/loader-circle-fXsKc0TP.js","assets/video-Bo3AcXon.js","assets/useMemoryPreviews-DvkAtlwZ.js","assets/search-D_LVchoc.js","assets/useImageCompression-C5-5tVrZ.js","assets/heic-Djb0Owx7.js","assets/r2-upload-CPZy4FTa.js","assets/inviteCandidates-D32NnMx2.js","assets/VideoPreview-D9BEa8DQ.js","assets/usePerfBudget-BZdR-G4y.js","assets/pencil-CKJsa8Hu.js","assets/chevron-right-aaxqAI6v.js","assets/shuffle-CCDvuPLx.js","assets/lock-D3L7n1Hp.js","assets/eye-off-YQaMGNXO.js","assets/globe-xPKErxGR.js","assets/copy-DMAO1SyF.js","assets/upload-flOywKXj.js","assets/plus-O3w64FuI.js","assets/grid-3x3-DNX2wcmy.js","assets/trash-2-CLE9ZDje.js","assets/log-out-B_mtl7aJ.js","assets/info-CT5rZD9C.js","assets/image-Cz6bY_bo.js","assets/users-BxEfMauC.js","assets/grip-vertical-BcPAzYyS.js","assets/clock-BF-8ZufU.js","assets/eye-CImpNXgw.js","assets/user-plus-E0L9d7C2.js","assets/mail-DexW5LxU.js","assets/user-minus-C1lCRWWA.js","assets/BoardCreator-WWAzYfm-.js","assets/visualViewportSubscriptions-22yhik8G.js","assets/BoardsCanvasReorderGrid-dP7Ejok3.js","assets/vendor-dnd-CDsjj_ID.js","assets/ExploreFollowing-BwTnsrNp.js","assets/dropdown-menu-BAlvmeJa.js","assets/index-DqIkKHbu.js","assets/circle-BwVhTjDX.js","assets/useFollowing-abh79vyt.js","assets/ExploreBoardCard-B-nVbGvW.js","assets/displayText-C8gylbfe.js","assets/flame-DueLJnbo.js","assets/ban-DClk00Tq.js","assets/useExplore-DqWdtfN5.js","assets/useBlocking-S4XmiyS5.js","assets/ellipsis-CLimiuxH.js","assets/vendor-animation-C4YilBxg.js","assets/compass-D3UAMNj_.js","assets/PageHeader-BnvONm3p.js","assets/feedBatchMonitorVisibility-Dzs90-gC.js","assets/SpacesIcon-BIw1RF34.js","assets/house-C9Hke4X6.js","assets/layout-grid-Bpg0VprM.js","assets/heart-CdAafllh.js","assets/bell-Bjv_251G.js","assets/UserMenu-BOK_l6jx.js","assets/ThemeContext-3fFp6cUT.js","assets/echoReview-DxeV6pFI.js","assets/appStore-CvVedgBE.js","assets/chromeExtension-Ba1XSCfq.js","assets/navigationPlacement-DOicjMCP.js","assets/lazyWithRetry-DcZLR5wu.js","assets/routeModulePrefetch-GdwohIex.js","assets/user-Ds9XOBLy.js","assets/clock-3-DTtizs3s.js","assets/star-Dj4Zt46N.js","assets/list-filter-v4BTBw0j.js","assets/sliders-horizontal-D56n2gim.js","assets/palette-BMwl0Vi7.js","assets/settings-DFBLyPRM.js","assets/shield-CoYdFdVE.js","assets/activity-Cs2H8ktv.js","assets/keyboard-D2j3K7oh.js","assets/external-link-BI4-_4re.js","assets/PublicNavbar-ZBBCJgpR.js","assets/AnimatedLogo-CcNVjI0Q.js","assets/passiveScrollSubscriptions-CS-jkkI4.js","assets/ActiveBoardContext-Bdq9TZD9.js","assets/likedPrefetch-D8IdXKms.js","assets/exploreRoutePrefetch-breOUS78.js","assets/directExploreWarmup-BLvRRSbD.js","assets/popover-DbMJLCIq.js","assets/log-in-Ba3zWN2K.js","assets/MemoryFeed-BtWuNLBH.js","assets/exploreExposureOutbox-tTL9X-9f.js","assets/exploreSeenStorage-B3zkLirJ.js","assets/boundedCollections-Bt9IAViC.js","assets/exploreContentIdentity-D-Otu-po.js","assets/exploreViewportExposure-p9xfc4T3.js","assets/feedMotion-544R1MDZ.js","assets/virtualFeed-DtYnMqs-.js","assets/userFilters-BGK54pGs.js","assets/imageLoadFailurePolicy-DJD2yr3u.js","assets/memory-CJrksfzy.js","assets/exploreFilterSemantics-DQb3RKye.js","assets/memoryBoardContext-vG9PRs0o.js","assets/collectionNavigation-BzW6Q-na.js","assets/feedMutationCoordinator-BmmwsaC2.js","assets/feedPageRetention-BpW01ZQR.js","assets/viewportLoadMoreObserver-CThDFSVJ.js","assets/mediaAspectRatio-CzPF2_Hw.js","assets/useEchoEntranceObserver-BzIMWQEF.js","assets/MemoryCard-CBHoggUJ.js","assets/useHaptics-8-HNWVFX.js","assets/useOfflineSource-Dd
1dWgYFb.js","assets/offline-DAh7TwkE.js","assets/useNetworkStatus-CCCthbIH.js","assets/asyncSemaphore-KO0g8gsf.js","assets/useDesktopCardEffects-DqDYC36w.js","assets/memoryDisplayTitle-BcAkzk0a.js","assets/MoodContext-C3yPuVY1.js","assets/moodConstants-Cjtnp2iF.js","assets/music-jZP0GveI.js","assets/file-text-B5ffPq62.js","assets/mic-B76gHqs6.js","assets/link-BWGgyG-h.js","assets/wifi-off-BMcFBFDl.js","assets/chevron-left-BP2GmtNQ.js","assets/share-2-D-X1XWTM.js","assets/flag-CvKwGhpJ.js","assets/bookmark-cuJqy2X3.js","assets/folder-Di4waGig.js","assets/useAiContentVisibility-BmvTig1b.js","assets/windowResizeSubscriptions-C3xwW4pN.js","assets/feedSettingsSubscriptions-BbSMaSgy.js","assets/memoryNoteEchoPages-2Sw1W3Y3.js","assets/searchGateway-BA4YS4Yv.js","assets/circle-alert-BGsFuKp2.js","assets/BoardReadOnlyMemoryGrid-CfxCh4KS.js","assets/ExploreFeedControls-Bkegtl0a.js","assets/documentVisibleInterval-kwPiY7AC.js","assets/index-B6-VXpe3.js","assets/shapes-D77jYaj4.js","assets/colorPreview-DNHK2pWR.js","assets/exploreFilterPerformance-VAtWhBOs.js","assets/tag-BQDlDWAb.js","assets/wand-sparkles-D2YQFHAf.js","assets/smile-CC4Oy885.js","assets/user-round-BcYO0cxJ.js","assets/layers-3-497JDkty.js","assets/frame-CxxCvDkS.js","assets/waves-CwRN987q.js","assets/history-b6dUHGlm.js","assets/lightbulb-DpO86COG.js","assets/camera-mi4n2-UJ.js","assets/book-open-eeQ0OULm.js","assets/network-bjEsWUR2.js","assets/scan-search-CLcoJbD5.js","assets/exploreAiFilterOptions-D0sjnMkh.js","assets/public-client-O4dRGMZv.js","assets/BulkTagCompletionSummary-DRmm1JfK.js","assets/circle-check-DpwBxCoL.js","assets/BulkTagPicker-BtNUKSOH.js","assets/memoryDetailMetadata-C0EKg-x9.js","assets/minus-Dwrlx31Q.js"])))=>i.map(i=>d[i]);
2import{_ as e}from"./runtime-preload-CFP917pd.js";import{j as r,r as t}from"./vendor-react-BfgFmtGS.js";import{d as s,u as a,a as i}from"./vendor-query-XXY4vl9u.js";import{B as o}from"./button-CYJdLL_L.js";import{I as n}from"./input-Cv-gXlbe.js";import{A as l,a as d,b as c}from"./avatar-DkgobaOn.js";import{S as u}from"./switch-D6ZBFPtn.js";import{u as m}from"./useBoards-B6p3dWJB.js";import{u as f}from"./useTags-C47l7F-j.js";import{u as h,a as p}from"./useAuth-DynbexoK.js";import{u as x}from"./useFollowing-abh79vyt.js";import{u as g}from"./ThemeContext-3fFp6cUT.js";import{supabase as b}from"./supabase-client-2CObC91N.js";import{c as v,u as y,g as w,B as j}from"./useBoardLibraryColumns-DKFiH_hC.js";import{S as _}from"./SEOHead-CHXhs1CK.js";import{a as N}from"./runtime-utils-GN4cODRt.js";import{a as k}from"./withTimeout-B5iNojGk.js";import{B as C}from"./BoardPreviewAvatar-BIAe0D67.js";import{D as S,n as M,l as P,e as E}from"./boardViewSettings-ZyAkPc6J.js";import{a as T,s as D,p as F}from"./boardSectionMemberships-CyLE2d-C.js";import{s as A}from"./feedSettingsSubscriptions-BbSMaSgy.js";import{c as O}from"./clipboard-CZdO1ppt.js";import{a as I}from"./startup-platform-OWIpYyjW.js";import{u as B}from"./usePerfBudget-BZdR-G4y.js";import{o as q}from"./viewportLoadMoreObserver-CThDFSVJ.js";import{c as L}from"./shareUrls-CnKIAmlW.js";import{P as $,g as R}from"./explorePublicFilters-FfjSDOQ4.js";import{o as z,e as Q,s as K,h as H,p as U,q as V}from"./exploreFilterSemantics-DQb3RKye.js";import{d as G,e as W}from"./useUserSettings-COWmNJt_.js";import{s as Y}from"./idleStorage-DCX8Fjfi.js";import{c as J}from"./perfConfig-SmqTTOuO.js";import{n as X}from"./inviteCandidates-D32NnMx2.js";import{l as Z,a as ee,g as re,f as te}from"./bulkMemoryTags-C-B68sMr.js";import{a as se}from"./lazyWithRetry-DcZLR5wu.js";import{i as ae,c as ie}from"./echoTypePolicy-D6McwraQ.js";import{B as oe,A as ne,M as le}from"./BoardLibraryViewMenu-DqOvPkpK.js";import{i as de,j as ce,k as ue,c as me,D as fe,a as he,b as pe,d as xe}from"./dropdown-menu-BAlvmeJa.js";import{B as ge,a as be,b as ve,D as ye,g as we,n as je,r as _e}from"./boardCardSize-DMpJ9b3m.js";import{M as Ne}from"./maximize-2-CiYgHWMA.js";import{c as ke}from"./createLucideIcon-D9HkCDkl.js";import{R as Ce,S as Se}from"./square-UvGz4Vxg.js";import{C as Me}from"./check-0D421DYe.js";import{VideoPreview as Pe}from"./VideoPreview-D9BEa8DQ.js";import{V as Ee}from"./VideoPosterOnly-CkOjVgFa.js";import{a as Te,b as De,c as Fe,g as Ae}from"./image-utils-BFdDQ3hX.js";import{L as Oe}from"./loader-circle-fXsKc0TP.js";import{I as Ie}from"./image-plus-DCkYnJWf.js";
2import{a as Be,m as qe,n as Le}from"./boardFolderResilience-Ch9izbQY.js";import{f as $e,r as Re}from"./memoryQueryCache-B47lTB9L.js";import{h as ze,b as Qe,r as Ke}from"./feedMutationCoordinator-BmmwsaC2.js";import{D as He,a as Ue,b as Ve,c as Ge,d as We}from"./dialog-C7V6oQ1v.js";import{A as Ye,a as Je,b as Xe,c as Ze,d as er,e as rr,f as tr,g as sr}from"./alert-dialog-DEiWzkJW.js";import{u as ar,a as ir,c as or}from"./vendor-router-QOYqHwMx.js";import{S as nr}from"./search-D_LVchoc.js";import{T as lr}from"./triangle-alert-GY7W0Pyh.js";import{R as dr}from"./refresh-cw-BjP_646P.js";import{B as cr}from"./bookmark-cuJqy2X3.js";import{U as ur}from"./upload-flOywKXj.js";import{H as mr}from"./heart-CdAafllh.js";import{P as fr}from"./plus-O3w64FuI.js";import{A as hr}from"./arrow-left-DAvP91ch.js";import{P as pr}from"./pencil-CKJsa8Hu.js";import{S as xr}from"./share-2-D-X1XWTM.js";import{T as gr}from"./trash-2-CLE9ZDje.js";import{X as br}from"./x-DV2I6wJI.js";import{T as vr}from"./tag-BQDlDWAb.js";import{F as yr}from"./folder-open-BFC5J5Fo.js";import{U as wr}from"./users-BxEfMauC.js";import{C as jr}from"./chevron-down-B1qfJDmk.js";import{E as _r}from"./ellipsis-CLimiuxH.js";import{F as Nr}from"./folder-Di4waGig.js";import{S as kr}from"./settings-DFBLyPRM.js";import{E as Cr}from"./eye-off-YQaMGNXO.js";import{G as Sr}from"./globe-xPKErxGR.js";import{L as Mr}from"./lock-D3L7n1Hp.js";import{E as Pr}from"./eye-CImpNXgw.js";const Er=ke("ArrowDownAZ",[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M20 8h-5",key:"1vsyxs"}],["path",{d:"M15 10V6.5a2.5 2.5 0 0 1 5 0V10",key:"ag13bf"}],["path",{d:"M15 14h5l-5 6h5",key:"ur5jdg"}]]),Tr=ke("Columns3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),Dr=ke("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),Fr=ke("RectangleVertical",[["rect",{width:"12",height:"20",x:"6",y:"2",rx:"2",key:"1oxtiu"}]]),Ar=new Intl.Collator(void 0,{sensitivity:"base",numeric:!0}),Or={"1x1":Se,"2x1":Ce,"1x2":Fr,"2x2":Ne};function Ir({value:e,onChange:t,onSelect:s}){const a=Or[e];return r.jsxs(de,{children:[r.jsxs(ce,{className:"rounded-xl gap-2.5 font-medium cursor-pointer",children:[r.jsx(a,{className:"h-4 w-4"}),"Card size"]}
2),r.jsx(ue,{className:"w-56 rounded-2xl border-foreground/10 p-1.5",children:ge.map(a=>{const i=Or[a];return r.jsxs(me,{className:"cursor-pointer rounded-xl gap-2.5 font-medium",onClick:()=>{t(a),null==s||s()},children:[r.jsx(i,{className:"h-4 w-4 shrink-0"}),r.jsx("span",{className:"flex-1",children:be[a]}),r.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:ve[a]}),e===a&&r.jsx(Me,{className:"h-4 w-4 shrink-0"})]},a)})})]})}function Br({value:e,onChange:t,className:s}){return r.jsx("div",{className:N("grid grid-cols-2 gap-2",s),children:ge.map(s=>{const a=Or[s],i=e===s;return r.jsxs("button",{type:"button",onClick:()=>t(s),"aria-pressed":i,className:N("flex items-center gap-3 rounded-xl border px-3 py-2.5 text-left transition-all active:scale-[0.98] touch-manipulation",i?"border-primary bg-primary/10 text-foreground":"border-border/50 bg-background/50 text-muted-foreground hover:border-primary/40 hover:text-foreground"),children:[r.jsx(a,{className:N("h-5 w-5 shrink-0",i?"text-primary":"text-muted-foreground")}),r.jsxs("span",{className:"min-w-0 flex-1",children:[r.jsx("span",{className:"block truncate text-sm font-bold",children:be[s]}),r.jsx("span",{className:"block truncate text-[10px] font-semibold uppercase tracking-wider opacity-70",children:ve[s]})]}),i&&r.jsx(Me,{className:"h-4 w-4 shrink-0 text-primary"})]},s)})})}const qr=({memory:e})=>{const t="image"===e.type&&e.image_url?e.image_url:(e=>{const r=e.metadata||{};return[r.thumbnail_url,r.thumbnailUrl,r.poster_url,r.posterUrl,r.image_url,r.imageUrl,r.og_image,r.ogImage].find(e=>"string"==typeof e&&e.trim().length>0)||e.image_url||null})(e),s="video"===e.type?Te({thumbnailUrl:t,videoUrl:e.video_url,size:"medium"})||t:null,a="video"===e.type?s:De(t,"thumbnail")||t,i="video"===e.type?null:Fe(t,"thumbnail"),o="video"===e.type?Ae(e.video_url)||e.video_url:null;return"video"===e.type&&o?r.jsx(Pe,{src:o,fallbackSrc:e.video_url,posterSrc:s,posterFallbackSrc:t,className:"h-full w-full",playMode:"never",showOverlay:!1}):a?r.jsx("img",{src:a,srcSet:i||void 0,sizes:"(min-width: 640px) 200px, 50vw",alt:"",className:"h-full w-full object-cover",loading:"lazy",decoding:"async"}):o||"video"===e.type?r.jsx(Ee,{posterSrc:s,posterFallbackSrc:t,videoSrc:o,videoFallbackSrc:e.video_url,className:"h-full w-full",showBadge:!1}):r.jsx(Ie,{className:"h-5 w-5 text-primary"})};function Lr({board:e,selectedMemoryId:a,isSaving:i,onSelect:n,fetchBoardMemoriesPaginated:l}){var d;const[c,u]=t.useState(!1),m=t.useRef(null);t.useEffect(()=>{const e=m.current;if(e&&!c)return q(e,()=>u(!0),"ahead")},[c]);const f=s({queryKey:["folder-preview-board-memories",e.id],enabled:c,initialPageParam:0,staleTime:3e5,queryFn:async({pageParam:r,signal:t})=>{const s="number"==typeof r?r:0,a=await l(e.id,60,s,null,t);return{items:a.filter(e=>ae(e)),rawCount:a.length,offset:s}},getNextPageParam:e=>60===e.rawCount?e.offset+60:void 0}),h=t.useMemo(()=>{var e;const r=new Set,t=[];for(const s of(null==(e=f.data)?void 0:e.pages)||[])for(const e of s.items)r.has(e.id)||(r.add(e.id),t.push(e));return t},[f.data]),p=(null==(d=f.data)?void 0:d.pages)||[],x=p[p.length-1],g=(null==x?void 0:x.items.length)??0,{hasNextPage:b,isFetchingNextPage:v,fetchNextPage:y}=f;t.useEffect(()=>{c&&b&&!v&&(g>0||p.length>=4||y())},[c,b,v,g,p.length,y]);const w=c&&f.isLoading&&0===h.length,j=c&&!f.isLoading&&0===h.length&&!f.hasNextPage;return r.jsxs("section",{ref:m,className:"scroll-mt-2",children:[r.jsxs("div",{className:"mb-3 flex items-center justify-between gap-3",children:[r.jsx("h3",{className:"truncate text-sm font-bold text-foreground",children:e.name}),h.length>0&&r.jsxs("span",{className:"shrink-0 text-[11px] font-bold uppercase tracking-widest text-muted-foreground",children:[h.length,f.hasNextPage?"+":""]})]}),w?r.jsx("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:r.jsx(Oe,{className:"h-5 w-5 animate-spin"})}):j?r.jsx("div",{className:"rounded-2xl border border-dashed border-border/50 p-6 text-center text-sm text-muted-foreground",children:"No preview-able echoes in this board yet."}):r.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:h.map(e=>{const t=a===e.id;return r.jsxs("button",{type:"button",disabled:i,onClick:()=>n(e.id),className:N("group relative aspect-square overflow-hidden rounded-[1.35rem] bg-card text-left transition-transform hover:scale-[0.985]",t&&"ring-2 ring-primary ring-offset-2 ring-offset-background"),children:[r.jsx(qr,{memory:e}),r.jsx("div",{className:"pointer-events-none absolute inset-0 bg-gradient-to-t from-black/45 via-trans
2parent to-transparent opacity-0 transition-opacity group-hover:opacity-100"}),t&&r.jsx("div",{className:"absolute right-3 top-3 flex h-9 w-9 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-float",children:r.jsx(Me,{className:"h-5 w-5"})}),r.jsx("div",{className:"absolute bottom-3 left-3 rounded-full bg-black/45 px-3 py-1 text-[10px] font-bold uppercase tracking-widest text-white/90 opacity-0 backdrop-blur-md transition-opacity group-hover:opacity-100",children:t?"Current":"Set preview"})]},e.id)})}),f.hasNextPage&&r.jsx("div",{className:"mt-3 flex justify-center",children:r.jsxs(o,{type:"button",size:"sm",variant:"outline",className:"rounded-full",disabled:i||f.isFetchingNextPage,onClick:()=>{f.fetchNextPage()},children:[f.isFetchingNextPage?r.jsx(Oe,{className:"mr-2 h-4 w-4 animate-spin"}):null,"Load more"]})})]})}function $r({boards:e,activeBoardId:s,selectedMemoryId:a,isSaving:i,onSelect:o,fetchBoardMemoriesPaginated:n}){const l=t.useMemo(()=>"all"===s?e:e.filter(e=>e.id===s),[s,e]);return 0===l.length?r.jsx("div",{className:"rounded-2xl border border-dashed border-border/50 p-8 text-center text-sm text-muted-foreground",children:"all"===s?"Add boards with echoes to this folder, then pick one as the preview.":"No echoes in this board yet."}):r.jsx("div",{className:"space-y-7",children:l.map(e=>r.jsx(Lr,{board:e,selectedMemoryId:a,isSaving:i,onSelect:o,fetchBoardMemoriesPaginated:n},e.id))})}const Rr=se("BoardEditor",()=>e(()=>import("./BoardEditor-Bo450zR3.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105])),"BoardEditor"),zr=se("BoardCreator",()=>e(()=>import("./BoardCreator-WWAzYfm-.js"),__vite__mapDeps([106,1,2,3,4,5,6,29,30,8,9,24,21,16,22,23,31,14,54,55,56,12,10,11,13,42,34,35,36,43,44,45,46,47,48,49,50,51,107,62])),"BoardCreator"),Qr=()=>e(()=>import("./MoveToBoardDialog-DNnF48Ei.js"),__vite__mapDeps([70,1,71,43,44,34,23,35,36,5,65,72,73,74,56,49,50,75,14,76,77,38,40,39,6,68,61,51,62,29,30,8,9,3,24,21,16,22,31,78,27])),Kr=se("MoveToBoardDialog",Qr,"MoveToBoardDialog"),Hr=se("BoardsCanvasReorderGrid",()=>e(()=>import("./BoardsCanvasReorderGrid-dP7Ejok3.js"),__vite__mapDeps([108,1,109,5,35,62,75,14,100])),"BoardsCanvasReorderGrid"),Ur=se("ExploreFollowing",()=>e(()=>import("./ExploreFollowing-BwTnsrNp.js"),__vite__mapDeps([110,1,15,9,3,16,5,2,4,111,8,19,20,21,22,23,24,25,11,112,13,14,86,113,114,44,34,35,36,41,42,43,45,46,47,48,49,50,51,39,40,115,116,65,67,83,72,73,74,56,75,76,84,57,117,118,93,89,119,120,61,99,121,105,94,122,123])),"ExploreFollowing"),Vr=se("BoardsPageHeader",()=>e(()=>import("./PageHeader-BnvONm3p.js"),__vite__mapDeps([124,43,1,125,126,14,42,34,23,35,36,44,45,46,47,48,49,50,51,127,78,128,93,129,130,5,131,41,132,56,61,133,134,135,55,136,65,111,8,9,3,19,20,21,16,22,24,25,11,112,13,86,113,29,30,31,137,138,57,139,117,140,141,142,95,143,144,145,27,146,147,96,148,149,102,150,2,4,151,152,99,153,154,155,156,157,123,158])),"PageHeader"),Gr=se("BoardsMemoryFeed",()=>e(()=>import("./MemoryFeed-BtWuNLBH.js").then(e=>e.a),__vite__mapDeps([159,43,1,160,61,51,50,35,49,161,162,163,164,165,152,166,5,167,14,45,42,34,23,36,44,46,47,48,168,41,169,170,171,172,173,38,174,175,176,177,178,111,8,9,3,19,20,21,16,22,24,25,11,112,13,86,113,179,180,181,182,183,68,62,65,84,74,56,184,55,83,72,73,75,76,185,116,67,40,186,52,132,187,188,189,190,191,98,192,193,102,129,93,121,194,118,95,195,59,196,197,57,2,4,198,199,200,201,202,203,31])),"MemoryFeed"),Wr=se("BoardsReadOnlyMemoryGrid",()=>e(()=>import("./BoardReadOnlyMemoryGrid-CfxCh4KS.js"),__vite__mapDeps([204,1,159,43,160,61,51,50,35,49,161,162,163,164,165,152,166,5,167,14,45,42,34,23,36,44,46,47,48,168,41,169,170,171,172,173,38,174,175,176,177,178,111,8,9,3,19,20,21,16,22,24,25,11,112,13,86,113,179,180,181,182,183,68,62,65,84,74,56,184,55,83,72,73,75,76,185,116,67,40,186,52,132,187,188,189,190,191,98,192,193,102,129,93,121,194,118,95,195,59,196,197,5
27,2,4,198,199,200,201,202,203,31])),"BoardReadOnlyMemoryGrid"),Yr=se("BoardsExploreFeedControls",()=>e(()=>import("./ExploreFeedControls-Bkegtl0a.js"),__vite__mapDeps([205,1,56,206,49,50,43,35,5,207,8,9,3,24,6,17,18,19,20,21,16,22,23,25,11,10,26,27,14,13,28,12,54,30,157,55,42,34,36,44,45,46,47,48,51,59,144,129,208,193,86,209,116,210,169,211,212,94,213,214,215,216,217,218,147,219,220,102,58,221,222,223,78,31,224,225,170,61,123,75,143])),"ExploreFeedControls"),Jr=se("BoardsBulkTagCompletionSummary",()=>e(()=>import("./BulkTagCompletionSummary-DRmm1JfK.js"),__vite__mapDeps([226,1,2,3,4,5,227,14])),"BulkTagCompletionSummary"),Xr=se("BoardsBulkTagPicker",()=>e(()=>import("./BulkTagPicker-BtNUKSOH.js"),__vite__mapDeps([228,1,2,3,4,5,229,31,14,78,13,230,211])),"BulkTagPicker"),Zr="echo_board_folders_last_known_v1",et="echo_board_folder_presentation_last_known_v1",rt=e=>`echo-board-collection-sort-mode:${e||"anonymous"}`,tt=(e,r)=>`echo-board-collection-order:${e||"anonymous"}:${r||"root"}`,st=e=>{if("undefined"==typeof window||!e)return[];try{const r=window.localStorage.getItem(`${Zr}:${e}`);return r?Le(JSON.parse(r),e):[]}catch{return[]}},at=(e,r)=>{if("undefined"!=typeof window&&e)try{Y(`${Zr}:${e}`,JSON.stringify(r))}catch{}},it=e=>e.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"folder",ot=e=>(e||"").split("/").map(e=>decodeURIComponent(e).trim()).filter(Boolean).join("/"),nt=(e,r)=>yt(e,r).map(e=>it(e.name)).join("/"),lt=(e,r)=>{const t=nt(e,r);return t?`/boards/${t}`:"/boards"},dt=e=>"recent"===e||"alphabetical"===e||"canvas"===e,ct=[{value:"library",label:"Library",icon:mr},{value:"following",label:"Following",icon:wr},{value:"saved",label:"Saved",icon:cr},{value:"uploaded",label:"Uploaded",icon:ur}],ut=z(),mt=$.reduce((e,r)=>(e[r]=[],e),{}),ft=(e,r)=>`echo_board_filter_options_v1:${e}:${r}`,ht=e=>new Date(e.last_memory_added_at||e.created_at).getTime(),pt="id, user_id, type, title, content, description, html_content, image_url, video_url, source_url, ai_description, hearts, watch_count, metadata, created_at, updated_at, deleted_at",xt=e=>Object.fromEntries(Object.entries(e).map(([e,r])=>[e,Array.isArray(r)?r.filter(Boolean):[]]).filter(([,e])=>e.length>0)),gt=(e,r)=>V(e,r),bt=async e=>{const r=[];for(const s of e)try{const{error:e}=await Ke(e=>b.rpc("soft_delete_memory",{p_memory_id:s}).abortSignal(e),"Moving Echo to Trash");if(e)throw e;r.push(s)}catch(t){throw Object.assign(t instanceof Error?t:new Error("Could not move every Echo to Trash."),{deletedIds:[...r],failedId:s})}return r},vt=(e,r)=>{const t=r.trim().toLowerCase();return!t||[e.name,"description"in e?e.description:null,"ai_title"in e?e.ai_title:null,"ai_description"in e?e.ai_description:null].filter(Boolean).join(" ").toLowerCase().includes(t)},yt=(e,r)=>{if(!r)return[];const t=new Map(e.map(e=>[e.id,e])),s=[],a=new Set;let i=t.get(r);for(;i&&!a.has(i.id);)a.add(i.id),s.unshift(i),i=i.parent_folder_id?t.get(i.parent_folder_id):void 0;return s},wt=(e,r)=>{const t=new Map;for(const i of e){if(!i.parent_folder_id)continue;const e=t.get(i.parent_folder_id)||[];e.push(i),t.set(i.parent_folder_id,e)}const s=new Set,a=[...t.get(r)||[]];for(;a.length>0;){const e=a.pop();e&&!s.has(e.id)&&(s.add(e.id),a.push(...t.get(e.id)||[]))}return s},jt=(e,r,t="")=>{const s=e.filter(ie).filter(e=>Q(e,r));return t.trim()?s.sort((e,r)=>{const s=K(r,t)-K(e,t);return 0!==s?s:new Date(r.created_at).getTime()-new Date(e.created_at).getTime()}):s.sort((e,r)=>new Date(r.created_at).getTime()-new Date(e.created_at).getTime())},_t=e=>Object.values(e).some(e=>H(e).length>0),Nt=async(e,r,t="")=>{const s=e.filter(e=>ie(e)&&gt(e,t));if(!_t(r))return jt(s,r,t);const a=await(async e=>{const r=new Map,t=Array.from(new Set(e.filter(Boolean)));if(0===t.length)return r;for(let s=0;s<t.length;s+=200){const e=t.slice(s,s+200),{data:a,error:i}=await b.from("public_explore_memory_filter_term_tokens").select("memory_id, group_name, value").in("memory_id",e).returns();if(i)return r;for(const t of a||[]){const e=t.group_name;if(!$.includes(e))continue;const s=H([t.value])[0];if(!s)continue;let a=r.get(t.memory_id);a||(a=new Map,r.set(t.memory_id,a));let i=a.get(e);i||(i=new Set,a.set(e,i)),i.add(s)}}return r})(s.map(e=>e.id));let i=s.filter(e=>((e,r,t)=>{const s=t.get(e.id);return s?$.every(t=>{const a=H(r[t]||[]);if(0===a.length)return!0;const i=s.get(t);return!(!i||!a.some(e=>i.has(e)))||Q(e,{...ut,[t]:a})}):Q(e,r)})(e,r,a));if(0===i.length&&s.length>0){const e=$.map(e=>H(r[e]||[])).filter(e=>e.length>0);i=s.filter(r=>{const t=U(r);return e.every(e=>e.some(e=>t.includes(e)))})}return t.trim()?i.sort((e,r)=>{const s=K(r,t)-K(e,t);return 0!==s?s:new Date(r.created_at).getTime()-new Date(e.created_at).getTime()}):i.sort((e,r)=>new Date(r.created_at).getTime()-new Date(e.created_at).getTime())},kt=(e,r)=>({...e,type:e.type,hearts:e.hearts||0,watch_count:e.watch_count||0,added_by:e.user_id||null,owner_id:e.user_id||null,owner_username:e.owner_username||(e.user_id===(null==r?void 0:r.id)?null==r?void 0:r.username:null)||null,owner_avatar:e.owner_avatar||(e.user_id===(null==r?void 0:r.id)?null==r?void 0:r.avatar_url:null)||null,added_by_username:e.added_by_username||(e.user_id===(null==r?void 0:r.id)?null==r?void 0:r.username:null)||null,added_by_avatar:e.added_by_avatar||(e.user_id===(null==r?void 0:r.id)?null==r?void 0:r.avatar_url:null)||null}),Ct=(e,r)=>({...kt(e,r),result_origin:e.result_origin||"board-scoped-hybrid-search",search_rank:e.search_rank??null,matched_terms:Array.isArray(e.matched_terms)?e.matched_terms:[],matched_sources:Array.isArray(e.matched_sources)?e.matched_sources:["search-document"]}),St=e=>{const r=$.reduce((e,r)=>(e[r]=[],e),{});for(const t of e){const e=t.group_name;if(!$.includes(e))continue;const s=H([t.value])[0];s&&r[e].push({value:s,count:Number(t.count||0),countStatus:"ready",previewImageUrl:t.preview_image_url||null,availability:"available",disabled:!1,disabledReason:null})}for(const t of $)r[t].sort((e,r)=>Number(r.count||0)-Number(e.count||0)||e.value.localeCompare(r.value));return r};function Mt({mode:e,onModeChange:s,canCreate:a,createDestinationLabel:i,onCreateBoard:o,onCreateFolder:n}){const[l,d]=t.useState(!1),c=ct.find(r=>r.value===e)||ct[0],u=c.icon;return r.jsxs(fe,{open:l,onOpenChange:d,children:[r.jsx(he,{asChild:!0,children:r.jsxs("button",{type:"button",className:"glass flex items-center gap-2 rounded-full bg-background/40 px-5 py-2.5 text-foreground shadow-soft transition-all hover:bg-background/60 hover:scale-[1.02]","aria-label":"Boards view",children:[r.jsxs("span",{className:"flex items-center gap-2 text-sm font-bold uppercase tracking-tight",children:[r.jsx(u,{className:"h-[18px] w-[18px] text-current",strokeWidth:2.2}),c.label]}),r.jsx(jr,{className:N("h-3.5 w-3.5 text-ink/80 transition-transform duration-300",l&&"rotate-180")}
2)]})}),r.jsxs(pe,{className:"mt-2 w-64 rounded-[2.5rem] border border-foreground/10 bg-background p-3 shadow-float animate-in fade-in zoom-in duration-200",children:[r.jsx("div",{className:"px-3 py-2 text-[10px] font-bold uppercase tracking-widest text-[hsl(var(--label-foreground))]",children:"Boards"}),ct.map(t=>{const a=t.icon,i=t.value===e;return r.jsxs(me,{onClick:()=>s(t.value),className:N("mb-1 flex cursor-pointer items-center gap-3 rounded-2xl px-4 py-3 transition-all duration-200",i?"bg-background font-bold text-primary shadow-soft":"text-ink/75 hover:bg-primary/5"),children:[r.jsx(a,{className:"h-5 w-5",strokeWidth:2.2}),r.jsx("span",{className:"flex-1",children:t.label}),i&&r.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-primary"})]},t.value)}),a&&r.jsxs(r.Fragment,{children:[r.jsx(xe,{className:"mx-2 my-2 bg-foreground/10"}),r.jsxs("div",{className:"px-1 pb-1",children:[r.jsxs("div",{className:"truncate px-3 pb-2 pt-1 text-[10px] font-bold uppercase tracking-widest text-muted-foreground",children:["Create in ",i]}),r.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[r.jsxs(me,{className:"cursor-pointer justify-center gap-1.5 rounded-xl border border-primary/60 bg-primary/5 px-2 py-2.5 text-xs font-bold text-primary transition-colors focus:bg-primary/10 focus:text-primary",onSelect:o,"aria-label":"Create Board",children:[r.jsx(fr,{className:"h-4 w-4",strokeWidth:2.4}),"Board"]}),r.jsxs(me,{className:"cursor-pointer justify-center gap-1.5 rounded-xl border border-primary/60 bg-primary/5 px-2 py-2.5 text-xs font-bold text-primary transition-colors focus:bg-primary/10 focus:text-primary",onSelect:n,"aria-label":"Create Folder",children:[r.jsx(Dr,{className:"h-4 w-4",strokeWidth:2.2}),"Folder"]})]})]})]})]})]})}const Pt=[{value:"recent",label:"Recent",icon:ne},{value:"alphabetical",label:"Alphabetical",icon:Er},{value:"canvas",label:"Canvas",icon:le}],Et=({folder:e,previewBoard:t,imageLoading:s="lazy"})=>e.preview_memory_id?r.jsx(C,{boardId:`folder-preview-${e.id}-${e.preview_memory_id}`,previewIds:[e.preview_memory_id],maxItems:1,className:"absolute inset-0",videoPlayMode:"never",imageLoading:s,fallbackIcon:r.jsx(yr,{className:"h-10 w-10 text-primary"})}):t?r.jsx(C,{boardId:t.id,previewIds:t.preview_image_ids,previewMedia:t.preview_media,className:"absolute inset-0",videoPlayMode:"never",imageLoading:s,fallbackIcon:r.jsx(yr,{className:"h-10 w-10 text-primary"})}):null;function Tt({value:e,publicSharingDisabled:s,onChange:a}){const[i,o]=t.useState(()=>({isPublic:!s&&e.isPublic,isHidden:e.isHidden})),[n,l]=t.useState(!1);t.useEffect(()=>{o({isPublic:!s&&e.isPublic,isHidden:e.isHidden})},[s,e.isHidden,e.isPublic]);const d=async e=>{if(n)return;const r=i;o(e),l(!0);try{await a(e)||o(r)}catch{o(r)}finally{l(!1)}};return r.jsxs(r.Fragment,{children:[r.jsx(xe,{}),r.jsxs(me,{className:"cursor-pointer rounded-xl gap-2.5 font-medium",disabled:s||n,role:"menuitemcheckbox","aria-checked":i.isPublic,"aria-label":i.isPublic?"Make private":"Make public",onSelect:e=>{e.preventDefault(),d({...i,isPublic:!i.isPublic})},children:[i.isPublic?r.jsx(Sr,{className:"h-4 w-4 text-emerald-500"}):r.jsx(Mr,{className:"h-4 w-4 text-orange-500"}),r.jsx("span",{children:i.isPublic?"Public":"Private"}),r.jsx(u,{checked:i.isPublic,tabIndex:-1,"aria-hidden":"true",className:"pointer-events-none ml-auto scale-75 data-[state=checked]:bg-emerald-500"})]}),r.jsxs(me,{className:"cursor-pointer rounded-xl gap-2.5 font-medium",disabled:n,role:"menuitemcheckbox","aria-checked":i.isHidden,"aria-label":i.isHidden?"Show in feeds":"Hide from feeds",onSelect:e=>{e.preventDefault(),d({...i,isHidden:!i.isHidden})},children:[i.isHidden?r.jsx(Cr,{className:"h-4 w-4 text-purple-500"}):r.jsx(Pr,{className:"h-4 w-4"}),r.jsx("span",{children:i.isHidden?"Hidden":"Showing"}),r.jsx(u,{checked:i.isHidden,tabIndex:-1,"aria-hidden":"true",className:"pointer-events-none ml-auto scale-75 data-[state=checked]:bg-purple-500"})]})]})}const Dt=({folder:e,itemCount:t,previewBoard:s,moveTargets:a,onOpen:i,onSetPreview:o,onSettings:n,onVisibilityChange:l,onMove:d,onDelete:c,publicSharingDisabled:u,priority:m=!1,cardSize:f,onCardSizeChange:h})=>{const p=Boolean(e.preview_memory_id||s),x=I();return r.jsxs("div",{className:N("group block",f&&"flex h-full flex-col"),children:[r.jsx("button",{type:"button",onClick:i,"aria-label":`Open folder ${e.name}`,className:N("block w-full text-left",f&&"min-h-0 flex-1"),children:r.jsxs("div",{className:N(f?"h-full":"h-36 sm:h-40 lg:h-48","relative overflow-hidden rounded-[1.5rem] bg-card transition-all duration-300",x&&"transition-none",p?"border-0 shadow-none":"border border-primary/60 group-hover:border-primary group-hover:bg-muted/20"),style:x?void 0:{WebkitMaskImage:"-webkit-radial-gradient(white, black)",isolation:"isolate"},children:[r.jsx(Et,{folder:e,previewBoard:s,imageLoading:m?"eager":"lazy"}),!p&&r.jsxs("div",{className:"relative flex h-full flex-col items-center justify-center gap-3 text-center",children:[r.jsx("div",{className:N("flex h-16 w-16 items-center justify-center rounded-2xl bg-background/75 text-primary shadow-sm",!x&&"backdrop-blur-md"),children:r.jsx(yr,{className:"h-8 w-8"})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-sm font-black uppercase tracking-[0.18em] text-primary",children:"Folder"}),r.jsxs("div",{className:"mt-1 text-xs font-bold uppercase tracking-widest text-muted-foreground",children:[t," ",1===t?"board":"boards"]})]})]})]})}),r.jsxs("div",{className:N("mt-3 flex items-start justify-between gap-2 px-1",f&&"shrink-0"),children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx(Nr,{className:"h-4 w-4 shrink-0 text-primary"}),r.jsx("h3",{className:"truncate text-base font-bold text-foreground",children:e.name}),e.has_shared_access&&r.jsx(wr,{className:"h-3 w-3 shrink-0 text-blue-500"}),e.is_hidden&&r.jsx(Cr,{className:"h-3 w-3 shrink-0 text-purple-500"}),e.is_public&&r.jsx(Sr,{className:"h-3 w-3 shrink-0 text-emerald-500"})]}),r.jsxs("div",{className:"mt-1 text-xs font-bold uppercase tracking-widest text-muted-foreground",children:[t," ",1===t?"board":"boards"]})]}),r.jsxs(fe,{children:[r.jsx(he,{asChild:!0,children:r.jsx("button",{className:"rounded-lg p-1.5 text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",children:r.jsx(_r,{className:"h-4 w-4"})})}),r.jsxs(pe,{align:"end",className:"w-44 rounded-2xl border-foreground
2/10 p-1.5",children:[e.is_owner&&r.jsxs(me,{className:"cursor-pointer rounded-xl gap-2.5 font-medium",onClick:o,children:[r.jsx(Ie,{className:"h-4 w-4"}),"Set Preview Echo"]}),e.is_owner&&r.jsxs(me,{className:"cursor-pointer rounded-xl gap-2.5 font-medium",onClick:n,children:[r.jsx(kr,{className:"h-4 w-4"}),"Folder Settings"]}),e.is_owner&&h&&r.jsx(Ir,{value:je(e.card_size),onChange:h}),e.is_owner&&r.jsx(Tt,{value:{isPublic:!!e.is_public,isHidden:!!e.is_hidden},publicSharingDisabled:u,onChange:l}),e.is_owner&&a.length>0&&r.jsxs(de,{children:[r.jsxs(ce,{className:"rounded-xl gap-2.5 font-medium cursor-pointer",children:[r.jsx(Nr,{className:"h-4 w-4"}),"Move to folder"]}),r.jsx(ue,{className:"w-48 rounded-2xl border-foreground/10 p-1.5",children:a.map(e=>r.jsxs(me,{className:"rounded-xl gap-2.5 font-medium cursor-pointer",onClick:()=>d(e.id),children:[r.jsx(Nr,{className:"h-4 w-4"}),e.name]},e.id))})]}),e.is_owner&&e.parent_folder_id&&r.jsxs(me,{className:"cursor-pointer rounded-xl gap-2.5 font-medium",onClick:()=>d(null),children:[r.jsx(br,{className:"h-4 w-4"}),"Move outside folders"]}),e.is_owner&&r.jsx(xe,{}),e.is_owner&&r.jsxs(me,{className:"cursor-pointer rounded-xl gap-2.5 font-medium text-destructive focus:text-destructive",onClick:c,children:[r.jsx(gr,{className:"h-4 w-4"}),"Delete folder"]})]})]})]})]})};function Ft({folder:e,open:s,onOpenChange:i,onRename:m,onVisibilityChange:f,onColumnsChange:x}){const{toast:g}=h(),v=a(),{user:j,profile:_}=p(),k=!!(null==_?void 0:_.public_sharing_disabled),{globalDesktopColumns:C,globalMobileColumns:S}=y(),[M,P]=t.useState(!1),[E,T]=t.useState(!1),[D,F]=t.useState(""),[A,O]=t.useState(!1),[I,B]=t.useState(!1),[q,L]=t.useState(null),[$,R]=t.useState(null),[z,Q]=t.useState(!1),[K,H]=t.useState([]),[U,V]=t.useState("edit"),[G,W]=t.useState(""),[Y,J]=t.useState(""),[Z,ee]=t.useState([]),[re,te]=t.useState(null),[se,ae]=t.useState(!1),[ie,oe]=t.useState(!1),ne=null!=q||null!=$;t.useEffect(()=>{e&&s&&(P(!k&&!!e.is_public),T(!!e.is_hidden),F(e.name),L(e.columns_desktop??null),R(e.columns_mobile??null),W(""),J(""),te(null),ee([]))},[e,s,k]),t.useEffect(()=>{const e=window.setTimeout(()=>J(G.trim()),180);return()=>window.clearTimeout(e)},[G]);const le=t.useCallback(async()=>{if(!e)return;const{data:r,error:t}=await b.rpc("get_board_folder_members",{p_folder_id:e.id});H(t?[]:r||[])},[e]);t.useEffect(()=>{s&&le()},[le,s]),t.useEffect(()=>{if(!s||!e)return;if(Y.length<2)return void ee([]);let r=!1;return(async()=>{ae(!0);const{data:t,error:s}=await b.rpc("search_invitable_folder_users",{p_folder_id:e.id,p_query:Y,p_limit:8});r||(ee(s?[]:X(t)),ae(!1))})(),()=>{r=!0}},[Y,e,s]);const de=t.useMemo(()=>{if(re)return re;const e=G.trim().toLowerCase();if(!e)return null;const r=e.replace(/^@/,"");return Z.find(t=>{var s;return t.username.toLowerCase()===r||(null==(s=t.full_name)?void 0:s.toLowerCase())===e})||null},[Z,G,re]),ce=e=>e.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2),ue=async()=>{if(!e)return;const r=D.trim();if(!r||r===e.name)return void F(e.name);O(!0);const t=await m(e,r);O(!1),t&&F(r)},me=async(r,t)=>{if(!e||z)return;const s=q,a=$;L(r),R(t),Q(!0);const i=await x(e,{desktop:r,mobile:t});Q(!1),i||(L(s),R(a))},fe=async()=>{if(!e||!de)return;oe(!0);const{error:r}=await b.rpc("add_board_folder_member",{p_folder_id:e.id,p_user_id:de.user_id,p_permission:U});oe(!1),r?g({title:"Failed to invite user",description:r.message,variant:"error"}):(g({title:`Folder shared with @${de.username}`}),W(""),J(""),te(null),ee([]),await Promise.all([le(),v.invalidateQueries({queryKey:["boards"]})]))};if(!e)return null;const he=K.filter(e=>"owner"!==e.role||e.user_id!==(null==j?void 0:j.id));return r.jsx(He,{open:s,onOpenChange:i,children:r.jsxs(Ue,{className:"sm:max-w-lg bg-background/95 backdrop-blur-xl !border-0 rounded-3xl",onOpenAutoFocus:e=>e.preventDefault(),children:[r.jsx(Ve,{children:r.jsx(Ge,{className:"text-xl font-bold",children:"Folder Settings"})}),r.jsxs("div",{className:"max-h-[74vh] space-y-6 overflow-y-auto pr-1",children:[r.jsxs("div",{className:"space-y-3 rounded-2xl border border-border/10 bg-muted/20 p-4",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-bold",children:"Folder Name"}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Rename this folder without changing its boards."})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(n,{value:D,onChange:e=>F(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),ue())},className:"h-10 rounded-xl bg-background/80 font-semibold",placeholder:"Folder name",maxLength:80}),r.jsxs(o,{type:"button",className:"h-10 shrink-0 rounded-xl",onClick:()=>{ue()},disabled:A||!D.trim()||D.trim()===e.name,children:[A?r.jsx(Oe,{className:"mr-2 h-4 w-4 animate-spin"}):r.jsx(pr,{className:"mr-2 h-4 w-4"}),"Save"]})]})]}),r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-2xl border border-border/10 bg-muted/30 p-4",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[r.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-xl bg-purple-500/10 text-purple-500",children:r.jsx(Cr,{className:"h-4 w-4"})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"text-sm font-semibold",children:"Hidden Folder"}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:E?"Applies hidden to every board and nested folder. You can change individual items afterward.":"Applies showing to every board and nested folder. Public visibility stays separate."})]})]}),r.jsx(u,{checked:E,disabled:I,onCheckedChange:r=>{if(I)return;const t=E;T(r),B(!0),f(e,{isPublic:M,isHidden:r}).then(e=>{e||T(t)}).finally(()=>B(!1))},className:"data-[state=checked]:bg-purple-500"})]}),r.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-2xl border border-border/10 bg-muted/30 p-4",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[r.jsx("div",{className:N("flex h-8 w-8 shrink-0 items-center justify-center rounded-xl",M?"bg-emerald-500/10 text-emerald-500":"bg-orange-500/10 text-orange-500"),children:M?r.jsx(Sr,{className:"h-4 w-4"}):r.jsx(Mr,{className:"h-4 w-4"})}),r.jsxs("div",{className:"min-w-0",children:[r.jsx("p",{className:"text-sm font-semibold",children:k?"Private Folder":M?"Public Folder":"Private Folder"}),r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:k?"Public publishing is unavailable for this account.":M?"Applies public to every board and nested folder. You can change individual items afterward.":"Applies private to every board and nested folder. You can change individual items afterward."})]})]}),r.jsx(u,{checked:!k&&M,disabled:k||I,onCheckedChange:r=>{if(k||I)return;const t=M;P(r),B(!0),f(e,{isPublic:r,isHidden:E}
2).then(e=>{e||P(t)}).finally(()=>B(!1))},className:"data-[state=checked]:bg-primary"})]})]}),r.jsxs("div",{className:"space-y-3 rounded-2xl border border-border/10 bg-muted/20 p-4",children:[r.jsxs("div",{className:"flex items-start justify-between gap-3",children:[r.jsxs("div",{className:"min-w-0",children:[r.jsxs("h4",{className:"flex items-center gap-2 text-sm font-bold",children:[r.jsx(Tr,{className:"h-4 w-4 text-primary"}),"Columns in this folder"]}),r.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Choose how many columns this folder uses when you open it. This applies to this folder only and overrides your global column setting — other folders keep their own layout."})]}),r.jsx(u,{checked:ne,disabled:z,onCheckedChange:e=>{e?me(C,S):me(null,null)},className:"data-[state=checked]:bg-primary"})]}),ne?r.jsxs("div",{className:"space-y-3 pt-1",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("span",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground",children:"Desktop"}),r.jsx("div",{className:"flex gap-1.5",children:w(!1).map(e=>r.jsx("button",{type:"button",disabled:z,onClick:()=>{me(e,$)},className:N("h-9 w-9 rounded-lg text-xs font-bold tabular-nums transition-colors active:scale-95",q===e?"bg-primary text-primary-foreground shadow-sm":"bg-background/70 text-muted-foreground hover:bg-muted hover:text-foreground"),children:e},`desktop-${e}`))})]}),r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsx("span",{className:"text-xs font-bold uppercase tracking-widest text-muted-foreground",children:"Mobile"}),r.jsx("div",{className:"flex gap-1.5",children:w(!0).map(e=>r.jsx("button",{type:"button",disabled:z,onClick:()=>{me(q,e)},className:N("h-9 w-9 rounded-lg text-xs font-bold tabular-nums transition-colors active:scale-95",$===e?"bg-primary text-primary-foreground shadow-sm":"bg-background/70 text-muted-foreground hover:bg-muted hover:text-foreground"),children:e},`mobile-${e}`))})]})]}):r.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Using your global column setting. Turn this on to give this folder its own layout."})]}),r.jsxs("div",{className:"space-y-3 rounded-2xl border border-border/10 bg-muted/20 p-4",children:[r.jsxs("div",{className:"flex items-center justify-between gap-3",children:[r.jsxs("div",{children:[r.jsx("h4",{className:"text-sm font-bold",children:"Collaborators"}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"Invited users get access to all boards inside."})]}),r.jsx(wr,{className:"h-4 w-4 text-muted-foreground"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("button",{type:"button",onClick:()=>V("edit"),className:N("flex-1 rounded-xl py-2 text-xs font-bold transition-colors","edit"===U?"bg-primary text-primary-foreground":"bg-background/70 text-muted-foreground hover:bg-muted"),children:[r.jsx(pr,{className:"mr-1 inline h-3 w-3"}),"Can edit"]}),r.jsxs("button",{type:"button",onClick:()=>V("read"),className:N("flex-1 rounded-xl py-2 text-xs font-bold transition-colors","read"===U?"bg-primary text-primary-foreground":"bg-background/70 text-muted-foreground hover:bg-muted"),children:[r.jsx(Pr,{className:"mr-1 inline h-3 w-3"}),"View only"]})]}),r.jsxs("div",{className:"relative",children:[r.jsx(nr,{className:"absolute left-3.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),r.jsx(n,{value:G,onChange:e=>{W(e.target.value),te(null)},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),fe())},placeholder:"Search by nickname or username...",className:"h-11 rounded-xl bg-background pl-10"})]}),re&&r.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-primary/30 bg-primary/5 px-3 py-2",children:[r.jsxs(l,{className:"h-7 w-7",children:[r.jsx(d,{src:re.avatar_url||void 0}),r.jsx(c,{className:"text-xs",children:ce(re.full_name||re.username)})]}),r.jsxs("div",{className:"min-w-0 flex-1",children:[re.full_name&&r.jsx("p",{className:"truncate text-sm font-medium",children:re.full_name}),r.jsxs("p",{className:N("truncate",re.full_name?"text-xs text-muted-foreground":"text-sm font-medium"),children:["@",re.username]})]}),r.jsx("button",{type:"button",className:"text-xs text-muted-foreground hover:text-foreground",onClick:()=>te(null),children:"Clear"})]}),!re&&Y.length>=2&&r.jsx("div",{className:"max-h-44 overflow-y-auto rounded-xl border bg-background/70",children:se?r.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching users..."}):0===Z.length?r.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matching registered users found."}):Z.map(e=>r.jsxs("button",{type:"button",onClick:()=>{te(e),W(e.username)},className:"flex w-full items-center gap-2 px-3 py-2 text-left transition-colors hover:bg-muted",children:[r.jsxs(l,{className:"h-7 w-7",children:[r.jsx(d,{src:e.avatar_url||void 0}),r.jsx(c,{className:"text-xs",children:ce(e.full_name||e.username)})]}),r.jsxs("div",{className:"min-w-0",children:[e.full_name&&r.jsx("p",{className:"truncate text-sm font-medium",children:e.full_name}),r.jsxs("p",{className:N("truncate",e.full_name?"text-xs text-muted-foreground":"text-sm font-medium"),children:["@",e.username]})]})]},e.user_id))}),r.jsxs(o,{className:"h-10 rounded-xl",onClick:fe,disabled:!de||ie,children:[ie?r.jsx(Oe,{className:"mr-2 h-4 w-4 animate-spin"}):r.jsx(wr,{className:"mr-2 h-4 w-4"}),"Invite User"]}),r.jsx("div",{className:"space-y-2",children:0===he.length?r.jsx("p",{className:"rounded-xl bg-background/60 px-3 py-3 text-xs text-muted-foreground",children:"No folder collaborators yet."}):he.map(t=>r.jsxs("div",{className:"flex items-center gap-3 rounded-xl bg-background/70 p-3",children:[r.jsxs(l,{className:"h-8 w-8",children:[r.jsx(d,{src:t.avatar_url||void 0}),r.jsx(c,{className:"text-xs",children:ce(t.username)})]}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsxs("p",{className:"truncate text-sm font-semibold",children:["@",t.username]}),r.jsx("p",{className:"text-xs text-muted-foreground",children:"read"===t.permission?"View only":"Can edit"})]}),r.jsxs("select",{value:"read"===t.permission?"read":"edit",onCh
2ange:r=>{(async(r,t)=>{if(!e||!r.user_id)return;const{error:s}=await b.rpc("update_board_folder_member_permission",{p_folder_id:e.id,p_user_id:r.user_id,p_permission:t});s?g({title:"Failed to update permission",description:s.message,variant:"error"}):await Promise.all([le(),v.invalidateQueries({queryKey:["boards"]})])})(t,r.target.value)},className:"h-8 rounded-lg border border-border/40 bg-background px-2 text-xs font-semibold",children:[r.jsx("option",{value:"edit",children:"Edit"}),r.jsx("option",{value:"read",children:"View"})]}),r.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>{(async r=>{if(!e||!r.user_id)return;const{error:t}=await b.rpc("remove_board_folder_member",{p_folder_id:e.id,p_user_id:r.user_id});t?g({title:"Failed to remove member",description:t.message,variant:"error"}):await Promise.all([le(),v.invalidateQueries({queryKey:["boards"]})])})(t)},children:r.jsx(br,{className:"h-4 w-4"})})]},t.id))})]})]})]})})}const At=Object.freeze(Object.defineProperty({__proto__:null,default:()=>{var e,l;const{boards:d,isLoading:c,isFetching:u,isError:z,isLibraryHydrating:Q,createBoard:K,updateBoard:H,deleteBoard:U,addMemoriesToBoard:V,fetchUnsortedMemories:X,fetchBoards:se,fetchBoardMemoriesPaginated:ae,UpgradeModalElement:ne}=m({libraryProjection:!0}),{toast:le}=h(),ge=a(),{user:be,profile:ve}=p(),{isDarkMode:Ne}=g(),ke=!!(null==ve?void 0:ve.public_sharing_disabled),[Ce,Se]=t.useState(!1),{tags:Pe,refreshTags:Ee}=f({enabled:Ce}),Te=ar(),De=ir(),{"*":Fe}=or(),Ae=I(),wr=B(),jr=t.useMemo(()=>ot(Fe),[Fe]),Cr=t.useMemo(()=>d.filter(e=>!e.is_following&&(e.is_owner||e.can_edit)),[d]),Sr=t.useMemo(()=>new Set(Cr.map(e=>e.id)),[Cr]),Mr=t.useMemo(()=>d.filter(e=>!e.is_following),[d]),Pr=t.useMemo(()=>d.filter(e=>e.is_following),[d]),[Er,Tr]=t.useState("library"),[Fr,Or]=t.useState(null),[qr,Lr]=t.useState(!1),[Zr,ct]=t.useState(!1),[At,Ot]=t.useState(null),It=t.useRef(null),Bt=t.useRef(!1),qt=t.useRef(null),[Lt,$t]=t.useState(!1),[Rt,zt]=t.useState(!1),[Qt,Kt]=t.useState(null),[Ht,Ut]=t.useState(null),[Vt,Gt]=t.useState(null),[Wt,Yt]=t.useState(null),[Jt,Xt]=t.useState(null),[Zt,es]=t.useState(!1),[rs,ts]=t.useState(null),[ss,as]=t.useState("all"),[is,os]=t.useState(""),[ns,ls]=t.useState(ye),[ds,cs]=t.useState(()=>{if("undefined"==typeof window)return"recent";const e=window.localStorage.getItem(rt(null==be?void 0:be.id));return dt(e)?e:"recent"}),[us,ms]=t.useState(null);t.useEffect(()=>()=>{null!==qt.current&&window.clearTimeout(qt.current)},[]);const fs=t.useCallback(e=>{Tr(e),Or(null),"/boards"!==De.pathname&&Te("/boards")},[De.pathname,Te]);t.useEffect(()=>{qr&&At&&Ot(null)},[qr,At]),t.useEffect(()=>{if(!be)return;let e=!1;return(async()=>{const r=window.localStorage.getItem(rt(be.id));dt(r)&&cs(r);const{data:t,error:s}=await b.from("profiles").select("board_sort_mode").eq("id",be.id).maybeSingle();if(e||s)return;const a=null==t?void 0:t.board_sort_mode;dt(a)&&(cs(a),Y(rt(be.id),a))})(),()=>{e=!0}},[be]);const hs=t.useCallback(e=>{be&&(cs(e),ms(null),Y(rt(be.id),e),b.from("profiles").update({board_sort_mode:e,updated_at:(new Date).toISOString()}).eq("id",be.id).then(({error:e})=>{if(e){const r="42703"===e.code||"PGRST204"===e.code||e.message.toLowerCase().includes("board_sort_mode");le({title:"Sort preference saved on this device",description:r?"Run the latest database migration to sync it to your public profile.":e.message,variant:r?"default":"error"})}}))},[le,be]),ps=i({queryKey:["board-folders",null==be?void 0:be.id],queryFn:async()=>{var e;if(!be)return{folders:[],completeness:"complete"};const r=st(be.id);let{data:t,error:s}=await b.rpc("get_my_board_folders");if(!s&&Array.isArray(t)&&0===t.length){const{data:r,error:a}=await b.auth.getUser();if(a||(null==(e=r.user)?void 0:e.id)!==be.id)throw a||new Error("Board folders authentication is still restoring");await new Promise(e=>window.setTimeout(e,120)),({data:t,error:s}=await b.rpc("get_my_board_folders"))}if(!s&&Array.isArray(t)&&0===t.length&&r.length>0){const[{data:e,error:t},{data:s,error:a}]=await Promise.all([b.from("board_folders").select("id").eq("user_id",be.id).limit(1),b.from("board_folder_members").select("folder_id").eq("user_id",be.id).limit(1)]);if(t||a||((null==e?void 0:e.length)||0)>0||((null==s?void 0:s.length)||0)>0)return{folders:r,completeness:"degraded"}}if(s){const{data:e,error:t}=await b.from("board_folders").select("*").eq("user_id",be.id).order("sort_order",{ascending:!0}).order("created_at",{ascending:!0});if(t){if(r.length>0)return{folders:r,completeness:"degraded"};throw t}const s=Be(e,be.id);return{folders:qe(s,r,be.id),completeness:"degraded"}}const a=Le(t,be.id);return at(be.id,a),{folders:a,completeness:"complete"}},enabled:!!be,placeholderData:()=>
2{if(!be)return;const e=st(be.id);return e.length>0?{folders:e,completeness:"degraded"}:void 0},staleTime:Ae?6e5:12e4,gcTime:Ae?12e5:18e5,refetchInterval:e=>{var r;return!(!Array.isArray(e.state.data)&&"degraded"!==(null==(r=e.state.data)?void 0:r.completeness))&&3e4},retry:2,refetchOnReconnect:!Ae,refetchOnMount:e=>!!Array.isArray(e.state.data)&&"always",refetchOnWindowFocus:!1}),xs=ps.data,gs=t.useMemo(()=>Array.isArray(xs)?xs:(null==xs?void 0:xs.folders)||[],[xs]),bs=!Array.isArray(xs)&&"complete"===(null==xs?void 0:xs.completeness),{isFetched:vs,isFetching:ys}=ps,ws=t.useMemo(()=>gs.find(e=>e.id===Fr)||null,[Fr,gs]),js=t.useMemo(()=>gs.find(e=>e.id===Qt)||null,[gs,Qt]),_s=t.useMemo(()=>yt(gs,Fr),[Fr,gs]),Ns=(null==ws?void 0:ws.parent_folder_id)||null,ks=!ws||!!ws.is_owner||!!ws.can_edit,Cs=t.useMemo(()=>gs.find(e=>e.id===Jt)||null,[gs,Jt]),Ss=t.useCallback((e,r)=>{Tr("library"),Or(e);const t=lt(gs,e);De.pathname!==t&&Te(t,{replace:null==r?void 0:r.replace})},[gs,De.pathname,Te]),Ms=t.useCallback(async()=>{var e;if(!ws)return;const r=nt(gs,ws.id),t=(null==ve?void 0:ve.username)||(null==(e=null==be?void 0:be.user_metadata)?void 0:e.username)||null,s=ws.is_public&&t?`${L()}/u/${encodeURIComponent(t)}/${r.split("/").map(encodeURIComponent).join("/")}`:`${window.location.origin}${lt(gs,ws.id)}`;try{const e=await O(s,"Copy this folder link:");le({title:"copied"===e?"Folder link copied":"Folder link ready",description:s,variant:"success"})}catch(a){le({title:"Copy failed",description:"Could not copy the folder link.",variant:"error"})}},[ws,gs,null==ve?void 0:ve.username,le,null==(e=null==be?void 0:be.user_metadata)?void 0:e.username]);t.useEffect(()=>{if(!jr)return void(Fr&&Or(null));const e=((e,r)=>{const t=ot(r).split("/").filter(Boolean).map(it);return 0===t.length?null:e.find(r=>{const s=yt(e,r.id).map(e=>it(e.name));return s.length===t.length&&s.every((e,r)=>e===t[r])})||null})(gs,jr);if(!e){if(!vs||!bs)return;return Or(null),void Te("/boards",{replace:!0})}Tr("library"),Fr!==e.id&&Or(e.id);const r=lt(gs,e.id);De.pathname!==r&&Te(r,{replace:!0})},[Fr,gs,bs,vs,De.pathname,Te,jr]),t.useEffect(()=>{bs&&Fr&&!ws&&Ss(null,{replace:!0})},[ws,Fr,bs,Ss]);const Ps=t.useCallback(()=>{const e=is.trim();if(!e||!be)return;const r=!ke&&!!(null==ws?void 0:ws.is_public);(async()=>{const t={user_id:be.id,name:e,parent_folder_id:Fr,is_public:r,is_private:!r,is_hidden:(null==ws?void 0:ws.is_hidden)||!1,sort_order:gs.length,card_size:ns};let{error:s}=await b.from("board_folders").insert(t);if(s&&("42703"===s.code||"PGRST204"===s.code||s.message.toLowerCase().includes("card_size"))){const{card_size:e,...r}=t;({error:s}=await b.from("board_folders").insert(r))}s?le({title:"Failed to create folder",description:s.message,variant:"error"}):(await ge.invalidateQueries({queryKey:["board-folders",be.id]}),le({title:"Folder created"}))})(),os(""),ls(ye),ct(!1)},[ws,Fr,gs.length,ns,is,ke,ge,le,be]),Es=t.useCallback((e,r)=>{(async()=>{const t=["boards",null==be?void 0:be.id],s=ge.getQueriesData({queryKey:t});ge.setQueriesData({queryKey:t},t=>Array.isArray(t)?t.map(t=>t.id===e?{...t,folder_id:r}:t):t);const{error:a}=await b.from("boards").update({folder_id:r,updated_at:(new Date).toISOString()}).eq("id",e);a&&(le({title:"Failed to move board",description:a.message,variant:"error"}),s.forEach(([e,r])=>ge.setQueryData(e,r)))})()},[ge,le,null==be?void 0:be.id]),Ts=t.useCallback(async(e,r)=>{const t={isPublic:!ke&&r.isPublic,isHidden:!!ke||r.isHidden},s=wt(gs,e),a=[e,...Array.from(s)],i=Mr.filter(e=>e.folder_id&&a.includes(e.folder_id)).map(e=>e.id),o=await b.rpc("set_board_folder_visibility",{p_folder_id:e,p_is_public:t.isPublic,p_is_hidden:t.isHidden});if(!o.error)return b.rpc("enqueue_board_folder_visibility_projection",{p_folder_id:e}),null;const n=String(o.error.message||"");if("42501"===o.error.code||n.toLowerCase().includes("not authorized"))return o.error;const l=[{is_public:t.isPublic,is_private:!t.isPublic,is_hidden:t.isHidden},{is_public:t.isPublic,is_hidden:t.isHidden},{is_hidden:t.isHidden},{is_public:t.isPublic,is_private:!t.isPublic},{is_public:t.isPublic}];let d=null;for(const u of l){const e=await b.from("board_folders").update(u).in("id",a).eq("user_id",(null==be?void 0:be.id)||"");if(!e.error){d=null;break}d=e.error;const r=String(e.error.message||"").toLowerCase();if(!("PGRST204"===e.error.code||r.includes("schema cache")||r.includes("is_hidden")||r.includes("is_private")))break}let c=null;if(i.length>0){const e={is_public:t.isPublic,is_private:!t.isPublic,is_hidden:t.isHidden},{data:r,error:s}=await b.from("boards").update(e).in("id",i).select("id");c=s||((r||[]).length!==i.length?new Error("Some boards could not be updated to match the folder visibility."):null)}return d?(le({title:"Boards updated",description:"Apply the folder visibility migration so the folder itself can store public/hidden state."}),null):(c&&le({title:"Folder updated",description:"Some board visibility syncing failed, but the folder visibility was saved."}),null)},[gs,Mr,ke,le,null==be?void 0:be.id]),Ds=t.useCallback((e,r)=>{(async()=>{const t=r?gs.find(e=>e.id===r):null,s=!ke&&!!(null==t?void 0:t.is_public),{error:a}=await b.from("board_folders").update({parent_folder_id:r,...t?{is_public:s,is_private:!s,is_hidden:!!ke||t.is_hidden||!1}:{}}).eq("id",e).eq("user_id",(null==be?void 0:be.id)||"");if(a)le({title:"Failed to move folder",description:a.message,variant:"error"});else{if(t){const r=await Ts(e,{isPublic:s,isHidden:!!ke||!!t.is_hidden});r&&le({title:"Folder moved, but visibility sync failed",description:r.message,variant:"error"})}
2await ge.invalidateQueries({queryKey:["board-folders",null==be?void 0:be.id]}),await ge.invalidateQueries({queryKey:["boards"]})}})()},[gs,Ts,ke,ge,le,null==be?void 0:be.id]),Fs=t.useCallback(async(e,r)=>{const t={isPublic:!ke&&r.isPublic,isHidden:!!ke||r.isHidden},s=new Set([e.id,...wt(gs,e.id)]),a=["board-folders",null==be?void 0:be.id],i=ge.getQueryData(a),o=ge.getQueriesData({queryKey:["boards"]}),n=i?i.folders.map(e=>s.has(e.id)?{...e,is_public:t.isPublic,is_private:!t.isPublic,is_hidden:t.isHidden}:e):null;n&&(ge.setQueryData(a,{...i,folders:n}),at(null==be?void 0:be.id,n)),ge.setQueriesData({queryKey:["boards"]},e=>Array.isArray(e)?e.map(e=>e.folder_id&&s.has(e.folder_id)?{...e,is_public:t.isPublic,is_private:!t.isPublic,is_hidden:t.isHidden}:e):e);const l=await Ts(e.id,t);if(l){ge.setQueryData(a,i);for(const[e,r]of o)ge.setQueryData(e,r);return i&&at(null==be?void 0:be.id,i.folders),le({title:"Failed to update folder",description:l.message,variant:"error"}),!1}return await Promise.all([ge.invalidateQueries({queryKey:["board-folders",null==be?void 0:be.id]}),ge.invalidateQueries({queryKey:["boards"]}),ge.invalidateQueries({queryKey:["memories"]})]),le({title:"Folder updated"}),!0},[gs,Ts,ke,ge,le,null==be?void 0:be.id]),As=t.useCallback(async(e,r)=>{if(!e.is_owner)return!1;const t=ge.getQueriesData({queryKey:["boards"]}).flatMap(([,e])=>Array.isArray(e)?e:[]).find(r=>r.id===e.id)||e,s="boolean"==typeof t.is_public?t.is_public:!t.is_private,a={};if(r.isPublic!==s&&(a.is_public=r.isPublic,a.is_private=!r.isPublic),r.isHidden!==!!t.is_hidden&&(a.is_hidden=r.isHidden),0===Object.keys(a).length)return!0;await ge.cancelQueries({queryKey:["boards"]});const i=ge.getQueriesData({queryKey:["boards"]});ge.setQueriesData({queryKey:["boards"]},r=>Array.isArray(r)?r.map(r=>r.id===e.id?{...r,...a}:r):r);try{if(await H(e.id,a))return!0}catch(o){le({title:"Failed to update",description:o instanceof Error?o.message:void 0,variant:"error"})}for(const[n,l]of i)ge.setQueryData(n,l);return!1},[ge,le,H]),Os=t.useCallback(async(e,r)=>{try{const{data:t}=await b.from("boards").select("view_config").eq("id",e.id).maybeSingle(),s=(null==t?void 0:t.view_config)??e.view_config??S,a=M({...M(s),cardSize:r}),i=await T(e.id,a,{currentConfig:s});await H(e.id,{view_config:D(i)})||le({title:"Failed to resize card",variant:"error"})}catch(t){le({title:"Failed to resize card",description:t instanceof Error?t.message:void 0,variant:"error"})}},[le,H]),Is=t.useCallback(async(e,r)=>{const t=null==be?void 0:be.id;if(!t)return;const s=ge.getQueryData(["board-folders",t]);s&&ge.setQueryData(["board-folders",t],{...s,folders:s.folders.map(t=>t.id===e.id?{...t,card_size:r}:t)});const{error:a}=await b.from("board_folders").update({card_size:r}).eq("id",e.id).eq("user_id",t);if(a){s&&ge.setQueryData(["board-folders",t],s);const e="42703"===a.code||"PGRST204"===a.code||a.message.toLowerCase().includes("card_size");return void le({title:"Failed to resize folder",description:e?"The folder card size database migration has not been applied yet.":a.message,variant:"error"})}await ge.invalidateQueries({queryKey:["board-folders",t]})},[ge,le,null==be?void 0:be.id]),Bs=t.useCallback(async(e,r)=>{const t=null==be?void 0:be.id;if(!t||!e.is_owner)return!1;const s={columns_desktop:v(r.desktop,!1),columns_mobile:v(r.mobile,!0)},a=ge.getQueryData(["board-folders",t]);a&&ge.setQueryData(["board-folders",t],{...a,folders:a.folders.map(r=>r.id===e.id?{...r,...s}:r)});const{error:i}=await b.from("board_folders").update(s).eq("id",e.id).eq("user_id",t);if(i){a&&ge.setQueryData(["board-folders",t],a);const e="42703"===i.code||"PGRST204"===i.code||i.message.toLowerCase().includes("columns_desktop")||i.message.toLowerCase().includes("columns_mobile");return le({title:"Failed to update folder columns",description:e?"The folder columns database migration has not been applied yet.":i.message,variant:"error"}),!1}return await ge.invalidateQueries({queryKey:["board-folders",t]}),!0},[ge,le,null==be?void 0:be.id]),qs=t.useCallback(async(e,r)=>{const t=r.trim();if(!t||!be)return!1;const s=ge.getQueryData(["board-folders",be.id]),a=s?s.folders.map(r=>r.id===e.id?{...r,name:t,updated_at:(new Date).toISOString()}:r):null;a&&ge.setQueryData(["board-folders",be.id],{...s,folders:a});const{error:i}=await b.from("board_folders").update({name:t,updated_at:(new Date).toISOString()}).eq("id",e.id).eq("user_id",be.id);return i?(s&&ge.setQueryData(["board-folders",be.id],s),le({title:"Failed to rename folder",description:i.message,variant:"error"}
2),!1):(await ge.invalidateQueries({queryKey:["board-folders",be.id]}),Fr===e.id&&a&&Te(lt(a,e.id),{replace:!0}),le({title:"Folder renamed"}),!0)},[Fr,Te,ge,le,be]),Ls=t.useCallback(e=>{(async()=>{const{error:r}=await b.from("board_folders").delete().eq("id",e);r?le({title:"Failed to delete folder",description:r.message,variant:"error"}):(Or(r=>r===e?(Te("/boards",{replace:!0}),null):r),await Promise.all([ge.invalidateQueries({queryKey:["board-folders",null==be?void 0:be.id]}),ge.invalidateQueries({queryKey:["boards"]})]))})()},[Te,ge,le,null==be?void 0:be.id]),$s=t.useMemo(()=>new Set(gs.map(e=>e.id)),[gs]),Rs=t.useMemo(()=>Mr.filter(e=>!e.folder_id||!$s.has(e.folder_id)),[Mr,$s]),zs=c&&0===d.length,Qs=ps.isError||vs&&!bs&&!ys,Ks=!zs&&(bs||gs.length>0),Hs=t.useMemo(()=>gs.filter(e=>!e.parent_folder_id),[gs]),Us=t.useMemo(()=>Fr?Mr.filter(e=>e.folder_id===Fr):[],[Fr,Mr]),Vs=t.useMemo(()=>Fr?gs.filter(e=>e.parent_folder_id===Fr):[],[Fr,gs]),Gs=t.useMemo(()=>Jt?wt(gs,Jt):new Set,[gs,Jt]),Ws=t.useMemo(()=>Jt?Mr.filter(e=>e.folder_id===Jt||e.folder_id&&Gs.has(e.folder_id)):[],[Gs,Jt,Mr]),Ys=t.useMemo(()=>{const e=new Map;for(const r of gs){if(!r.parent_folder_id)continue;const t=e.get(r.parent_folder_id)||[];t.push(r),e.set(r.parent_folder_id,t)}return e},[gs]),Js=t.useMemo(()=>{const e=new Map;for(const r of Mr){if(!r.folder_id)continue;const t=e.get(r.folder_id)||[];t.push(r),e.set(r.folder_id,t)}return e},[Mr]),Xs=t.useMemo(()=>{const e=new Map;for(const r of gs){const t=new Set,s=[...Ys.get(r.id)||[]];for(;s.length>0;){const e=s.pop();e&&!t.has(e.id)&&(t.add(e.id),s.push(...Ys.get(e.id)||[]))}e.set(r.id,t)}return e},[gs,Ys]),Zs=t.useMemo(()=>{var e,r;const t=new Map;for(const s of gs){let a=(null==(e=Js.get(s.id))?void 0:e.length)||0;for(const e of Xs.get(s.id)||[])a+=(null==(r=Js.get(e))?void 0:r.length)||0;t.set(s.id,a)}return t},[gs,Js,Xs]),ea=t.useMemo(()=>{const e=new Map;for(const r of gs){const t=Xs.get(r.id)||new Set;e.set(r.id,gs.filter(e=>e.id!==r.id&&!t.has(e.id)))}return e},[gs,Xs]),ra=t.useMemo(()=>{const e=new Map,r=(r,t)=>{const s=e.get(r);(!s||ht(t)>ht(s))&&e.set(r,t)};for(const t of gs){for(const e of Js.get(t.id)||[])r(t.id,e);for(const e of Xs.get(t.id)||[])for(const s of Js.get(e)||[])r(t.id,s)}return e},[gs,Js,Xs]),ta=t.useMemo(()=>(e=>{const r=new Map;if("undefined"==typeof window||!e)return r;try{const t=window.localStorage.getItem(`${et}:${e}`);if(!t)return r;const s=JSON.parse(t);if(!Array.isArray(s))return r;for(const e of s)(null==e?void 0:e.folderId)&&r.set(e.folderId,e)}catch{}return r})(null==be?void 0:be.id),[null==be?void 0:be.id]),sa=t.useMemo(()=>gs.map(e=>({folderId:e.id,itemCount:Zs.get(e.id)||0,previewBoard:ra.get(e.id)||null})),[gs,Zs,ra]);t.useEffect(()=>{if(!(null==be?void 0:be.id))return;const e=sa.filter(e=>e.itemCount>0||e.previewBoard);((e,r)=>{if("undefined"!=typeof window&&e&&0!==r.length)try{Y(`${et}:${e}`,JSON.stringify(r))}catch{}})(be.id,e)},[sa,null==be?void 0:be.id]);const aa=c||u||Q,ia=t.useCallback(e=>{var r;const t=Zs.get(e)||0;return aa?Math.max(t,(null==(r=ta.get(e))?void 0:r.itemCount)||0):t},[ta,Zs,aa]),oa=t.useCallback(e=>{var r;const t=ra.get(e)||null;return t||!aa?t:(null==(r=ta.get(e))?void 0:r.previewBoard)||t},[ta,ra,aa]),[na,la]=t.useState(""),[da,ca]=t.useState(!1),[ua,ma]=t.useState(ut),{followedProfiles:fa}=x({profilesEnabled:"following"===Er||da,boardsEnabled:!1,feedEnabled:!1}),[ha,pa]=t.useState(""),xa=t.useRef(!1);t.useEffect(()=>{if(!xa.current)return xa.current=!0,void pa(na);const e=setTimeout(()=>pa(na),300);return()=>clearTimeout(e)},[na]);const ga=Object.values(ua).reduce((e,r)=>e+r.length,0),ba=t.useMemo(()=>{switch(Er){case"following":return"Search followed echoes";case"saved":return"Search saved echoes";case"uploaded":return"Search your uploaded echoes";default:return"Search your library"}},[Er]),va=t.useMemo(()=>((e,r="library")=>{if("undefined"==typeof window||!e)return null;try{const t=window.localStorage.getItem(ft(e,r));if(!t)return null;const s=JSON.parse(t);if(!(null==s?void 0:s.data)||"object"!=typeof s.data)return null;const a=$.reduce((e,r)=>(e[r]=Array.isArray(s.data[r])?s.data[r].filter(e=>"string"==typeof(null==e?void 0:e.value)&&e.value.trim()):[],e),{});return Object.values(a).some(e=>e.length>0)?a:null}catch{return null}})(null==be?void 0:be.id,Er),[Er,null==be?void 0:be.id]),{data:ya=mt}=i({queryKey:["boards-public-explore-filter-options","all_time",null,100],queryFn:async()=>{const{data:e,error:r}=await R({timeRange:"all_time",typeFilter:null,limit:100});if(r)throw r;const t=Array.isArray(e)?e:[];return St(t)},enabled:!!be&&da&&!va,staleTime:6e5,gcTime:18e5,retry:1,refetchOnWindowFocus:!1}),{data:wa=mt,isLoading:ja,isFetching:_a}=i({queryKey:["boards-library-ai-filter-options",4,Er,null==be?void 0:be.id],queryFn:async()=>
2{if(!be)return mt;const e=await k(b.rpc("get_board_scoped_explore_filter_options",{p_scope:Er,p_limit_per_group:60}),12e3,null);if(!e)throw new Error("Board filter catalogue timed out");const{data:r,error:t}=e;if(t)throw t;const s=Array.isArray(r)?r:[],a=St(s);return((e,r,t)=>{"undefined"!=typeof window&&Object.values(t).some(e=>e.length>0)&&Y(ft(e,r),JSON.stringify({savedAt:Date.now(),data:t}))})(be.id,Er,a),a},enabled:!!be&&da,placeholderData:e=>e??va??mt,staleTime:6e5,gcTime:18e5,retry:2,retryDelay:e=>Math.min(500*2**e,2e3),refetchOnMount:!1,refetchOnWindowFocus:!1}),Na=t.useMemo(()=>[wa,va,ya].find(e=>e&&Object.values(e).some(e=>e.length>0))??mt,[va,ya,wa]),ka=t.useMemo(()=>Object.values(Na).some(e=>e.length>0),[Na]),Ca=t.useCallback((e,r)=>{ma(t=>{const s=t[e]||[],a=s.includes(r)?s.filter(e=>e!==r):[...s,r];return{...t,[e]:a}})},[]),Sa=t.useMemo(()=>(Fr?Us:Ks?Rs:[]).filter(e=>vt(e,ha)),[Us,Fr,Ks,ha,Rs]),Ma=t.useMemo(()=>(Fr?Vs:Hs).filter(e=>vt(e,ha)),[Vs,Fr,ha,Hs]),Pa=t.useMemo(()=>{const e=[...Ma.map((e,r)=>({id:`folder:${e.id}`,type:"folder",folder:e,fallbackOrder:e.sort_order??r})),...Sa.map((e,r)=>({id:`board:${e.id}`,type:"board",board:e,fallbackOrder:e.canvas_sort_order??Ma.length+r}))];if("alphabetical"===ds)return e.sort((e,r)=>function(e,r){return Ar.compare(e.name.trim(),r.name.trim())||e.id.localeCompare(r.id)}({id:e.id,name:"folder"===e.type?e.folder.name:e.board.name},{id:r.id,name:"folder"===r.type?r.folder.name:r.board.name}));if("canvas"!==ds)return e;const r=new Map((us||[]).map((e,r)=>[e,r]));return[...e].sort((e,t)=>{const s=r.get(e.id),a=r.get(t.id);if(void 0!==s||void 0!==a)return(s??Number.MAX_SAFE_INTEGER)-(a??Number.MAX_SAFE_INTEGER);const i="folder"===e.type?e.folder.sort_order:e.board.canvas_sort_order,o="folder"===t.type?t.folder.sort_order:t.board.canvas_sort_order;return null!=i||null!=o?(i??Number.MAX_SAFE_INTEGER)-(o??Number.MAX_SAFE_INTEGER):e.fallbackOrder!==t.fallbackOrder?e.fallbackOrder-t.fallbackOrder:"board"===e.type&&"board"===t.type?ht(t.board)-ht(e.board):0})},[ds,us,Sa,Ma]),Ea=t.useMemo(()=>Pa.map(e=>e.id),[Pa]),Ta=Fr?J.largeGridInitialItems:"constrained"===wr.tier?J.androidBoardCollectionInitialItems:Ae?24:J.largeGridInitialItems,Da="constrained"===wr.tier?J.androidBoardCollectionStepItems:Ae?18:48,[Fa,Aa]=t.useState(Ta),Oa=t.useRef(null),Ia=Pa.length>Ta,Ba=t.useMemo(()=>Ia?Pa.slice(0,Fa):Pa,[Fa,Pa,Ia]),qa=t.useMemo(()=>Ba.map(e=>e.id),[Ba]),La=t.useMemo(()=>new Set(Ba.slice(0,4).map(e=>e.id)),[Ba]),$a=Ba.length<Pa.length;t.useEffect(()=>{Aa(Ta)},[Fr,ds,Ta,ha,Er]),t.useEffect(()=>{if(!Ia||!$a)return;const e=Oa.current;return e?q(e,()=>{Aa(e=>Math.min(Pa.length,e+Da))}):void 0},[Pa.length,Da,Ba.length,$a,Ia]),t.useEffect(()=>{if("canvas"===ds&&be)try{const e=window.localStorage.getItem(tt(be.id,Fr)),r=e?JSON.parse(e):null;ms(Array.isArray(r)?r:null)}catch{ms(null)}else ms(null)},[Fr,ds,be]);const Ra=t.useCallback(e=>{if(be){try{Y(tt(be.id,Fr),JSON.stringify(e))}catch{}(async()=>{const{error:r}=await b.rpc("set_my_board_library_order",{p_items:e});if(r){const e="42703"===r.code||"PGRST202"===r.code||r.message.toLowerCase().includes("set_my_board_library_order");le({title:"Could not save Canvas order",description:e?"Run the latest database migration to enable board ordering.":r.message,variant:e?"default":"error"})}})()}},[Fr,le,be]),za=t.useCallback(e=>{"canvas"===ds&&(ms(e),Ra(e))},[ds,Ra]),Qa=e=>"folder"===e.type?je(e.folder.card_size):_e(e.board),Ka=(e,s=!1)=>
2{if("folder"===e.type){const t=e.folder;return r.jsx(Dt,{folder:t,itemCount:ia(t.id),previewBoard:oa(t.id),moveTargets:ea.get(t.id)||[],onOpen:()=>Ss(t.id),onSetPreview:()=>{Xt(t.id),zt(!0)},onSettings:()=>Kt(t.id),onVisibilityChange:e=>Fs(t,e),onMove:e=>Ds(t.id,e),onDelete:()=>Ls(t.id),publicSharingDisabled:ke,priority:s,cardSize:je(t.card_size),onCardSizeChange:t.is_owner?e=>Is(t,e):void 0})}const a=e.board;return r.jsx(j,{board:a,priority:s,cardSize:Qa(e),actionMenu:Sr.has(a.id)?r.jsxs(r.Fragment,{children:[r.jsxs(fe,{open:Ht===a.id,onOpenChange:e=>Ut(e?a.id:null),children:[r.jsx(he,{asChild:!0,children:r.jsx("button",{className:"rounded-lg p-1.5 text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground",children:r.jsx(_r,{className:"h-4 w-4"})})}),r.jsxs(pe,{align:"end",className:"w-52 rounded-2xl border-foreground/10 p-1.5",children:[r.jsxs(me,{className:"rounded-xl gap-2.5 font-medium cursor-pointer",onClick:()=>{Ut(null),Gt(a.id)},children:[r.jsx(Ie,{className:"h-4 w-4"}),"Set Preview Echo"]}),r.jsx(Ir,{value:_e(a),onChange:e=>Os(a,e),onSelect:()=>Ut(null)}),gs.length>0?r.jsxs(de,{children:[r.jsxs(ce,{className:"rounded-xl gap-2.5 font-medium cursor-pointer",children:[r.jsx(Nr,{className:"h-4 w-4"}),"Move to folder"]}
2),r.jsx(ue,{className:"w-48 rounded-2xl border-foreground/10 p-1.5",children:gs.map(e=>r.jsxs(me,{className:"rounded-xl gap-2.5 font-medium cursor-pointer",onClick:()=>Es(a.id,e.id),children:[r.jsx(Nr,{className:"h-4 w-4"}),e.name]},e.id))})]}):r.jsxs(me,{className:"rounded-xl gap-2.5 font-medium cursor-pointer",onClick:()=>ct(!0),children:[r.jsx(Dr,{className:"h-4 w-4"}),"Create folder"]}),a.folder_id&&r.jsxs(r.Fragment,{children:[r.jsx(xe,{}),r.jsxs(me,{className:"rounded-xl gap-2.5 font-medium cursor-pointer",onClick:()=>Es(a.id,null),children:[r.jsx(br,{className:"h-4 w-4"}),"Remove from folder"]})]}),r.jsx(xe,{}),r.jsxs(me,{className:"rounded-xl gap-2.5 font-medium cursor-pointer",onClick:()=>{Ut(null),Yt(a.id)},children:[r.jsx(kr,{className:"h-4 w-4"}),"Board Settings"]}),a.is_owner&&r.jsx(Tt,{value:{isPublic:"boolean"==typeof a.is_public?a.is_public:!a.is_private,isHidden:!!a.is_hidden},publicSharingDisabled:ke,onChange:e=>As(a,e)})]})]}),Vt===a.id?r.jsx(t.Suspense,{fallback:null,children:r.jsx(Rr,{board:a,onUpdate:H,onDelete:U,isOwner:Boolean(a.is_owner),initialSection:"preview",open:!0,onOpenChange:e=>Gt(e?a.id:null),hideTrigger:!0})}):null,Wt===a.id?r.jsx(t.Suspense,{fallback:null,children:r.jsx(Rr,{board:a,onUpdate:H,onDelete:U,isOwner:Boolean(a.is_owner),open:!0,onOpenChange:e=>Yt(e?a.id:null),hideTrigger:!0})}):null]}):void 0})},Ha=()=>ks?r.jsxs(fe,{open:"grid"===At,onOpenChange:Lo,children:[r.jsx(he,{asChild:!0,children:r.jsxs("div",{className:"group flex h-full cursor-pointer flex-col touch-pan-y",onPointerDown:$o,onPointerUp:Ro,onPointerCancel:zo,onClickCapture:Qo,children:[r.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center rounded-[1.5rem] border-2 border-dashed border-border/40 transition-colors group-hover:bg-primary/5",children:r.jsx(fr,{className:"w-8 h-8 text-primary/20 group-hover:text-primary/40 transition-colors"})}),r.jsx("div",{className:"mt-3 shrink-0 px-1",children:r.jsx("h3",{className:"font-bold text-base text-muted-foreground/60",children:"Create"})})]})}),r.jsxs(pe,{align:"start",className:"w-44 rounded-2xl border-foreground
2/10 p-1.5",children:[r.jsxs(me,{className:"rounded-xl gap-2.5 font-medium cursor-pointer",onSelect:qo,children:[r.jsx(fr,{className:"w-4 h-4"}),"Board"]}),r.jsxs(me,{className:"rounded-xl gap-2.5 font-medium cursor-pointer",onClick:()=>{Ot(null),ct(!0)},children:[r.jsx(Dr,{className:"w-4 h-4"}),"Folder"]})]})]}):null;t.useEffect(()=>{Rt&&(as("all"),ts(null))},[Rt,Jt]),t.useEffect(()=>{const e=null==be?void 0:be.id;if(!e)return;const r=()=>{ge.invalidateQueries({queryKey:["board-folders",e]})};return G(()=>b.channel(W("board-folders-sync",e)).on("postgres_changes",{event:"*",schema:"public",table:"board_folders",filter:`user_id=eq.${e}`},r).on("postgres_changes",{event:"*",schema:"public",table:"board_folder_members",filter:`user_id=eq.${e}`},r).subscribe(),{suspendWhenHidden:Ae,minimumHiddenDurationMs:1e4,resumeIdleTimeoutMs:3e3,onResume:r})},[Ae,ge,null==be?void 0:be.id]);const Ua=t.useCallback(async(e,r,t,s,a,i,o)=>K(e,r,t,s,a,i,Fr,o),[Fr,K]),Va=t.useCallback(e=>{Cs&&(async()=>{ts(null),es(!0);const{error:r}=await b.from("board_folders").update({preview_memory_id:e}).eq("id",Cs.id);if(es(!1),r){const e="42703"===r.code||"PGRST204"===r.code||r.message.toLowerCase().includes("preview_memory_id")?"The folder preview database migration has not been applied yet.":r.message;return ts(e),void le({title:"Failed to set folder preview",description:e,variant:"error"})}await ge.invalidateQueries({queryKey:["board-folders",null==be?void 0:be.id]}),le({title:e?"Folder preview set":"Folder preview reset"}),zt(!1)})()},[Cs,ge,le,null==be?void 0:be.id]),[Ga,Wa]=t.useState(new Set),Ya=t.useRef(0),Ja=t.useRef(null),Xa=t.useRef(null),Za=t.useRef(null);Ya.current=Ga.size;const ei=Ae?12:24,ri=t.useRef(null),[ti,si]=t.useState(!1);t.useEffect(()=>{if(jr||ti)return;const e=ri.current;if(!e||"undefined"==typeof IntersectionObserver)return void si(!0);const r=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(si(!0),r.disconnect())},{rootMargin:Ae?"500px 0px":"900px 0px"});return r.observe(e),()=>r.disconnect()},[Ae,jr,ti]);const{data:ai,isLoading:ii,isFetching:oi,isFetched:ni,isError:li,error:di,fetchNextPage:ci,hasNextPage:ui,refetch:mi}=s({queryKey:["board-unsorted",null==be?void 0:be.id,5,ha],queryFn:async({pageParam:e=0})=>X(ha,ei,e),initialPageParam:0,enabled:!!be&&!jr&&ti,staleTime:6e4,gcTime:18e5,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!0,retry:1,getNextPageParam:e=>{if(e&&!(e.nextOffset>=e.total))return e.nextOffset}}),fi=t.useMemo(()=>((null==ai?void 0:ai.pages.flatMap(e=>e.memories))||[]).filter(ie),[ai]),hi=t.useMemo(()=>jt(fi,ua,ha),[ha,ua,fi]),pi=Xa.current,xi=t.useMemo(()=>{if(Ga.size>0&&pi){const e=new Set(pi.map(e=>e.id));return[...pi,...hi.filter(r=>!e.has(r.id))].filter(ie)}return hi.filter(ie)},[Ga.size,pi,hi]),gi=null==ai?void 0:ai.pages.reduce((e,r)=>Math.max(e,r.total),0),bi=Math.max(gi??0,fi.length+(ui?1:0)),vi=ii,yi=oi&&!!ai,wi=vi&&!ai,ji=!!ui,_i=!jr&&(bi>0||vi||li||ni&&d.length>0&&!c),Ni=!jr&&(!ni||_i),ki=t.useCallback(async()=>{await ge.invalidateQueries({queryKey:["board-unsorted",null==be?void 0:be.id]}),await mi()},[ge,mi,null==be?void 0:be.id]),Ci=t.useCallback(async()=>{ui&&!oi&&await ci()},[ci,ui,oi]),[Si,Mi]=t.useState(null),[Pi,Ei]=t.useState(!1);t.useEffect(()=>{if(!Si||"undefined"==typeof IntersectionObserver)return void Ei(!1);const e=new IntersectionObserver(([e])=>Ei(e.isIntersecting),{rootMargin:"0px 0px -30% 0px"});return e.observe(Si),()=>e.disconnect()},[Si]);const Ti=t.useRef(null);t.useEffect(()=>{if(!ui)return;const e=Ti.current;return e?q(e,()=>{Ci()}):void 0},[Ci,xi.length,ui,oi]);const Di=Boolean(ha.trim())||ga>0,Fi=Di?20:ei,Ai=t.useCallback(async(e,r,t,s,a)=>{var i,o;if(!be)return{memories:[],total:0,rawCount:0,nextOffset:a};const n=r.trim(),l=_t(t),d=Boolean(n)||l;if(d){if(l)try{const{data:r,error:o}=await b.rpc("search_board_scoped_filter_tokens",{p_scope:e,p_query:n||null,p_limit:s,p_offset:a,p_ai_filters:xt(t)});if(o)throw o;const l=Array.isArray(r)?r:[],d=Number((null==(i=l[0])?void 0:i.total_count)??0);return{memories:l.map(e=>Ct(e,ve)).filter(ie),total:d,rawCount:l.length,nextOffset:a+l.length}}catch(y){throw y}try{const{data:r,error:i}=await b.rpc("search_board_scoped_explore_hybrid",{p_scope:e,p_query:n||null,p_limit:s,p_offset:a,p_ai_filters:xt(t),p_search_sort:"relevant"});if(i)throw i;const l=Array.isArray(r)?r:[];if(l.length>0||a>0){const e=Number((null==(o=l[0])?void 0:o.total_count)??a+l.length);return{memories:l.map(e=>Ct(e,ve)).filter(ie),total:e,rawCount:l.length,nextOffset:a+l.length}}}catch(y){throw y}}const c=e=>ie(e)&&gt(e,n),u=e=>{const r=e.filter(ie),t=r.slice(a,a+s);return{memories:t,total:r.length,rawCount:t.length,nextOffset:a+t.length}};if("uploaded"===e){if(!d){const{data:e,error:r,count:t}=await b.from("memories").select(pt,{count:"exact"}).eq("user_id",be.id).is("deleted_at",null).order("created_at",{ascending:!1}).range(a,a+s-1);if(r)throw r;const i=e||[];return{memories:i.map(e=>kt(e,ve)).filter(ie),total:t??a+i.length,rawCount:i.length,nextOffset:a+i.length}}const e=Math.max(a+8*s,800);let r=b.from("memories").select(pt).eq("user_id",be.id).is("deleted_at",null);r=r.order("created_at",{ascending:!1}),r=r.limit(e);const{data:i,error:o}=await r;if(o)throw o;const l=(i||[]).map(e=>kt(e,ve));return u(await Nt(l.filter(c),t,n))}const m="following"===e?Pr.map(e=>e.id):Mr.map(e=>e.id),f="following"===e?fa.map(e=>
2e.id).filter(Boolean):[];if(0===m.length&&0===f.length&&"library"!==e)return{memories:[],total:0,rawCount:0,nextOffset:a};const h=Math.max(a+8*s,800),p=new Set,x=[],g=e=>{if(!(null==e?void 0:e.id)||p.has(e.id))return;const r=kt(e,ve);c(r)&&(p.add(e.id),x.push(r))};if(m.length>0){const{data:e,error:r}=await b.from("memory_boards").select(`\n          created_at,\n          board_id,\n          memories (\n            ${pt}\n          )\n        `).in("board_id",m).order("created_at",{ascending:!1}).limit(h);if(r)throw r;for(const t of e||[])g(t.memories)}if("library"===e||f.length>0){let r=b.from("memories").select(pt).is("deleted_at",null).order("created_at",{ascending:!1}).limit(h);r="library"===e?r.eq("user_id",be.id):r.in("user_id",f);const{data:t,error:s}=await r;if(s)throw s;for(const e of t||[])g(e)}const v=await Nt(x,t,n);return u("saved"===e?v.filter(e=>e.user_id!==be.id):v)},[Pr,fa,Mr,ve,be]),{data:Oi,isLoading:Ii,isFetching:Bi,isError:qi,error:Li,fetchNextPage:$i,hasNextPage:Ri,refetch:zi}=s({queryKey:["boards-mode-memories",5,Er,null==be?void 0:be.id,Mr.map(e=>e.id).join(","),Pr.map(e=>e.id).join(","),fa.map(e=>e.id).join(","),ha,ua],queryFn:async({pageParam:e=0})=>Ai(Er,ha,ua,Fi,e),initialPageParam:0,enabled:!!be&&("saved"===Er||"uploaded"===Er||Di),staleTime:Ae?3e5:3e4,gcTime:Ae?6e5:18e5,refetchOnMount:!1,refetchOnWindowFocus:!1,retry:1,getNextPageParam:e=>{if(e&&!(e.rawCount<=0||e.nextOffset>=e.total))return e.nextOffset}}),Qi=t.useMemo(()=>((null==Oi?void 0:Oi.pages.flatMap(e=>e.memories))||[]).filter(ie),[Oi]),Ki=(null==(l=null==Oi?void 0:Oi.pages[0])?void 0:l.total)||0,Hi=Ii||Bi,Ui=t.useCallback(async()=>{Ri&&!Bi&&await $i()},[Ri,Bi,$i]),Vi=t.useCallback(()=>{zi()},[zi]),Gi=t.useCallback(async e=>{if(ze(e))return;const r=Qe({memoryIds:[e],kind:"trash",scope:{type:"global"}});let t=!1;try{const{error:s}=await Ke(r=>b.rpc("soft_delete_memory",{p_memory_id:e}).abortSignal(r),"Moving Echo to Trash");if(s)throw s;await r.hidden;const a=r=>$e(r,r=>r.id!==e);ge.setQueriesData({queryKey:["boards-mode-memories"]},a),ge.setQueriesData({queryKey:["memories"]},a),ge.setQueriesData({queryKey:["board-unsorted",null==be?void 0:be.id]},r=>Re(r,new Set([e]))),ge.removeQueries({queryKey:["memory",e]}),t=!0,le({title:"Echo moved to trash"})}catch(s){throw le({title:"Delete failed",description:s instanceof Error?s.message:void 0,variant:"error"}),s}finally{t?r.finish():r.rollback()}},[ge,le,null==be?void 0:be.id]),Wi=t.useCallback((e,r)=>{const t=!!(null==r?void 0:r.shiftKey);0===Ya.current&&(Xa.current=hi);const s=window.scrollY;Za.current=s,Wa(r=>{const s=new Set(r),a=(Xa.current||hi).map(e=>e.id).filter(Boolean),i=Ja.current;if(t&&i){const r=a.indexOf(i),t=a.indexOf(e);if(-1!==r&&-1!==t){const i=Math.min(r,t),o=Math.max(r,t);return a.slice(i,o+1).forEach(e=>s.add(e)),Ja.current=e,s}}return s.has(e)?s.delete(e):s.add(e),Ja.current=e,0===s.size&&(Xa.current=null),s})},[hi]);t.useLayoutEffect(()=>{const e=Za.current;null!==e&&(Za.current=null,Math.abs(window.scrollY-e)>2&&window.scrollTo({top:e,left:window.scrollX,behavior:"auto"}))},[Ga]);const Yi=t.useCallback(()=>{Wa(new Set),Ja.current=null,Xa.current=null},[]);t.useEffect(()=>{Yi()},[Yi,Er]);const[Ji,Xi]=t.useState(!1),[Zi,eo]=t.useState(!1),[ro,to]=t.useState([]),[so,ao]=t.useState("add"),[io,oo]=t.useState([]),[no,lo]=t.useState(!1),[co,uo]=t.useState(null),mo=t.useCallback(()=>{const e=new Set(Ga);return xi.map(e=>e.id).filter(r=>e.has(r))},[xi,Ga]),fo=t.useMemo(()=>mo(),[mo]),ho=t.useMemo(()=>{if(!(null==be?void 0:be.id))return 0;const e=new Set(fo);return xi.filter(r=>e.has(r.id)&&(Boolean(r.is_owner)||r.owner_id===be.id||r.user_id===be.id)).length},[fo,xi,null==be?void 0:be.id]),{data:po={manualCoverage:{},metadataTags:[]},isLoading:xo}=i({queryKey:["bulk-tag-coverage",fo],queryFn:()=>te(fo,be.id),enabled:Ce&&fo.length>0&&!!(null==be?void 0:be.id),staleTime:1e4});t.useEffect(()=>{Ce&&!co&&oo(Z())},[co,Ce]);const go=t.useCallback(async()=>{if(!be||no)return;const e=fo;if(0!==ro.length)if(0!==e.length){lo(!0);try{const r=await ee(ro,e,be.id,so);
2await Promise.all([ge.invalidateQueries({queryKey:["memory-tags"]}),ge.invalidateQueries({queryKey:["memory-filter-assignments"]}),ge.invalidateQueries({queryKey:["tags",be.id]}),ge.invalidateQueries({queryKey:["bulk-tag-coverage"]}),ge.invalidateQueries({queryKey:["manual-filtered-memories"]}),ge.invalidateQueries({queryKey:["manual-filter-library-stats"]})]),Ee(),uo(r),le({title:r.insertedCount>0?`${r.tagNames.length} tag${1===r.tagNames.length?"":"s"} ${"add"===so?"applied":"removed"}`:"add"===so?"Those tags were already present":"Those tags were not present",description:r.insertedCount>0?[`${r.insertedCount.toLocaleString()} tag assignment${1!==r.insertedCount?"s":""} ${"add"===so?"added":"removed"}`,r.skippedCount>0?`${r.skippedCount.toLocaleString()} ${"add"===so?"already present":"not present"}`:null,r.deniedCount>0?`${r.deniedCount.toLocaleString()} echoes not editable`:null].filter(Boolean).join(", ")+".":"add"===so?`All selected echoes already had ${1===r.tagNames.length?"that tag":"those tags"}.`:`None of the selected echoes had ${1===r.tagNames.length?"that tag":"those tags"}.`,variant:"success"})}catch(r){le({title:"Could not add tag",description:re(r),variant:"error"})}finally{lo(!1)}}else le({title:"No echoes selected",variant:"error"});else le({title:"Select at least one tag",variant:"error"})},[fo,so,ro,no,ge,Ee,le,be]),[bo,vo]=t.useState(!1),[yo,wo]=t.useState(!1),[jo,_o]=t.useState(()=>P()),No=t.useMemo(()=>ws?{desktop:ws.columns_desktop??null,mobile:ws.columns_mobile??null}:null,[ws]),ko=!!ws&&(null!=ws.columns_desktop||null!=ws.columns_mobile),{columns:Co,rowHeight:So,isMobile:Mo,isFolderOverride:Po}=y(ko?No:null),Eo=!!(null==ws?void 0:ws.is_owner),To=t.useMemo(()=>{if(ws&&Po)return{columns:Co,options:w(Mo),onSelect:e=>{Bs(ws,Mo?{desktop:ws.columns_desktop??null,mobile:e}:{desktop:e,mobile:ws.columns_mobile??null})},disabled:!Eo,scopeLabel:Eo?"Applies to this folder only and overrides your global columns.":"Set by the folder owner for this folder only."}},[ws,Eo,Co,Po,Mo,Bs]);t.useEffect(()=>A(()=>_o(P())),[]);const Do=t.useCallback(async()=>{if(0===Ga.size)return;const e=Array.from(Ga);if(e.some(ze))return;vo(!0);const r=Qe({memoryIds:e,kind:"trash",scope:{type:"global"}});let t=!1;try{const s=await bt(e);await r.hidden;const a=new Set(s);ge.setQueriesData({queryKey:["board-unsorted",null==be?void 0:be.id]},e=>Re(e,a)),ge.setQueriesData({queryKey:["memories"]},e=>$e(e,e=>!a.has(e.id)));const i=s.length;Yi(),t=!0,le({title:"Echoes trashed 🗑️",description:`Moved ${i} memor${1!==i?"ies":"y"} to the trash.`})}catch(s){const a=Array.isArray(null==s?void 0:s.deletedIds)?s.deletedIds.filter(e=>"string"==typeof e&&e.length>0):[];if(a.length>0){await r.hidden;const s=new Set(a);ge.setQueriesData({queryKey:["board-unsorted",null==be?void 0:be.id]},e=>Re(e,s)),ge.setQueriesData({queryKey:["memories"]},e=>$e(e,e=>!s.has(e.id))),await ki(),Yi(),t=!0,le({title:`${a.length.toLocaleString()} ${1===a.length?"Echo":"Echoes"} trashed`,description:e.length-a.length+" could not be changed. Unsorted was refreshed from the server.",variant:"error"})}else await ki(),Yi(),le({title:"Delete could not be verified",description:"Unsorted was refreshed from the server so the feed reflects the final state. Please retry anything still present.",variant:"error"})}finally{t?r.finish():r.rollback(),vo(!1)}},[Yi,ki,ge,Ga,le,null==be?void 0:be.id]),Fo=t.useCallback(async e=>{if(bo||ze(e))return;vo(!0);const r=Qe({memoryIds:[e],kind:"trash",scope:{type:"global"}});let t=!1;try{await bt([e]),await r.hidden,ge.setQueriesData({queryKey:["board-unsorted",null==be?void 0:be.id]},r=>Re(r,new Set([e]))),Yi(),ge.setQueriesData({queryKey:["memories"]},r=>$e(r,r=>r.id!==e)),t=!0,le({title:"Echo trashed 🗑️",description:"Moved 1 memory to the trash."})}catch(s){await ki(),Yi(),le({title:"Delete could not be verified",description:"Unsorted was refreshed from the server. Please retry the Echo if it is still present.",variant:"error"})}finally{t?r.finish():r.rollback(),vo(!1)}},[Yi,bo,ki,ge,le,null==be?void 0:be.id]),Ao=t.useCallback(async e=>{if(!be||ze(e))return;const r=Qe({memoryIds:[e],kind:"remove",scope:{type:"surface",surfaceId:"boards-saved"}});let t=!1;try{const{data:s,error:a}=await Ke(r=>b.rpc("remove_saved_memory_from_library_safe",{p_memory_id:e}).abortSignal(r),"Removing Echo from library");if(a)throw a;const i=Array.isArray(s)?s[0]:s;if(0===Number((null==i?void 0:i.removed_count)||0))throw new Error("This echo is not saved in one of your editable boards.");await r.hidden;const o=r=>$e(r,r=>r.id!==e);ge.setQueriesData({queryKey:["boards-mode-memories"]},o),ge.setQueriesData({queryKey:["memories"]},o),t=!0,le({title:"Echo removed from library"})}catch(s){throw le({title:"Remove failed",description:s instanceof Error?s.message:void 0,variant:"error"}),s}finally{t?r.finish():r.rollback()}},[ge,le,be]),Oo=Ga.size===xi.length&&xi.length>0,Io="following"===Er?"Following Echoes":"saved"===Er?"Saved Echoes":"uploaded"===Er?"Uploaded Echoes":"Library Echoes",Bo="following"===Er?"Echoes from boards and creators you follow":"saved"===Er?"Echoes from other creators that you saved into your boards":"uploaded"===Er?"Echoes you uploaded to Echo":"Echoes across your library, including boards and unsorted uploads",qo=()=>{Ot(null),window.setTimeout(()=>Lr(!0),0)},Lo=e=>{e&&Bt.current||Ot(e?"grid":null)},$o=e=>{"touch"!==e.pointerType&&"pen"!==e.pointerType||(null!==qt.current&&(window.clearTimeout(qt.current),qt.current=null),Bt.current=!1,It.current={x:e.clientX,y:e.clientY})},Ro=e=>{const r=It.current;if(!r)return;const t=Math.abs(e.clientX-r.x),s=Math.abs(e.clientY-r.y);(t>10||s>10)&&(Bt.current=!0,qt.current=window.setTimeout(()=>{Bt.current=!1,qt.current=null},400)),It.current=null},zo=()=>{It.current=null},Qo=e=>{Bt.current&&(e.preventDefault(),e.stopPropagation(),Bt.current=!1,null!==qt.current&&(window.clearTimeout(qt.current),qt.current=null))};return r.jsxs("div",{className:"app-screen pb-20 bg-background [overflow-anchor:none]",children:[r.jsx(_,{title:"Boards",noindex:!0}),r.jsx(t.Suspense,{fallback:null,children:r.jsx(Vr,{})}),r.jsx("main",{className:"px-4 pt-[max(2.5rem,calc(max(env(safe-area-inset-top),var(--native-safe-top,0px))+0.75rem))] sm:px-6 md:pt-6 lg:pt-8 [overflow-anchor:none]",children:r.jsxs("div",{className:N("mx-auto",jo.edgeToEdgeDesktop?"w-full max-w-none":"max-w-7xl"),children:[r.jsx("div",{className:"mb-5 flex justify-center",children:r.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2 sm:gap-3",children:[r.jsxs("button",{type:"button",onClick:()=>ca(e=>!e),className:N("glass relative inline-flex h-12 w-12 shrink-0 items-center justify-center rounded-full bg-background/40 text-foreground shadow-soft transition-all hover:bg-background/60 hover:scale-[1.02] active:scale-95",(da||na.trim()||ga>0)&&"text-primary"),"aria-label":da?"Hide library search":"Search library",children:[r.jsx(nr,{className:"h-[19px] w-[19px]",strokeWidth:2.35}),ga>0&&r.jsx("span",{className:"absolute -right-0.5 -top-0.5 flex h-5 min-w-5 items-center justify-center rounded-full bg-primary px-1 text-[10px] font-black text-primary-foreground",children:ga})]}),r.jsx(Mt,{mode:Er,onModeChange:fs,canCreate:ks,createDestinationLabel:(null==ws?void 0:ws.name)||"Library",onCreateBoard:qo,onCreateFolder:()=>{Ot(null),window.setTimeout(()=>ct(!0),0)}}),r.jsx(oe,{mode:ds,onModeChange:hs,options:Pt,columnControl:To,triggerClassName:"glass inline-flex h-12 shrink-0 items-center gap-2 rounded-full bg-background/40 px-4 text-foreground shadow-soft transition-all hover:bg-background/60 hover:scale-[1.02] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-foreground
2/20 active:scale-95"})]})}),da&&r.jsx("div",{className:"mx-auto mb-10 max-w-5xl animate-in fade-in slide-in-from-top-2 duration-200",children:r.jsx(t.Suspense,{fallback:r.jsx("div",{className:"h-14 animate-pulse rounded-2xl bg-muted/40"}),children:r.jsx(Yr,{query:na,isSearching:vi||Hi,mode:"new",darkMode:Ne,activeFilterCount:ga,aiFilterOptions:Na,aiFilterOptionsSource:"loaded",aiFilters:ua,isLoadingMoreAiFilterOptions:!ka&&(ja||_a),showModeSelector:!1,placeholder:ba,filterOptionCaption:`Labels and previews from ${Io.toLowerCase()}`,showAiFilterOptionCounts:!0,scope:"personal",compact:!0,inlineControls:!0,className:"mb-0 px-0 md:mb-0",onQueryChange:la,onClear:()=>la(""),onModeChange:()=>{},onToggleQuickFilter:Ca})})}),"library"===Er&&Qs&&r.jsxs("div",{className:"mx-auto mb-6 flex max-w-3xl items-start gap-3 rounded-2xl border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm",role:"status",children:[r.jsx(lr,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"font-semibold",children:"Some folders may be temporarily unavailable"}),r.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Echo is showing the last available folder list and will keep retrying automatically."})]}),r.jsxs(o,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 rounded-full",disabled:ys,onClick:()=>{ps.refetch()},children:[r.jsx(dr,{className:N("mr-1.5 h-3.5 w-3.5",ys&&"animate-spin")}),"Retry"]})]}),"library"===Er&&z&&r.jsxs("div",{className:"mx-auto mb-6 flex max-w-3xl items-start gap-3 rounded-2xl border border-amber-500/30 bg-amber-500/10 px-4 py-3 text-sm",role:"alert",children:[r.jsx(lr,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"font-semibold",children:"Some boards may be temporarily unavailable"}),r.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"Echo kept your last-known library visible and will not treat this read failure as an empty folder."})]}),r.jsxs(o,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 rounded-full",disabled:u,onClick:()=>{se()},children:[r.jsx(dr,{className:N("mr-1.5 h-3.5 w-3.5",u&&"animate-spin")}),"Retry"]})]}),Di||"saved"===Er||"uploaded"===Er?r.jsxs("div",{className:"pb-24",children:[r.jsx("div",{className:"mb-6 flex flex-col gap-3 md:flex-row md:items-center md:justify-between",children:r.jsxs("div",{children:[r.jsxs("h2",{className:"text-xl font-bold tracking-tight flex items-center gap-2",children:[Io,r.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:ha.trim()||ga>0?`(${Qi.length} of ${Ki})`:`(${Ki})`})]}),r.jsx("p",{className:"mt-0.5 text-xs text-muted-foreground",children:Bo})]})}),Hi&&0===Qi.length?r.jsx("div",{className:"flex items-center justify-center py-24",children:r.jsx(Oe,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):qi&&0===Qi.length?r.jsxs("div",{className:"mx-auto max-w-md py-24 text-center",children:[r.jsx("div",{className:"mx-auto mb-6 flex h-20 w-20 items-center justify-center rounded-full bg-destructive/10",children:r.jsx(dr,{className:"h-9 w-9 text-destructive"})}),r.jsx("h3",{className:"mb-2 text-xl font-bold",children:"Couldn’t search your library"}),r.jsx("p",{className:"mb-5 text-sm text-muted-foreground",children:Li instanceof Error?Li.message:"The search service did not respond. Your Echoes are still safe."}),r.jsxs(o,{variant:"outline",onClick:Vi,children:[r.jsx(dr,{className:"mr-1.5 h-3.5 w-3.5"}),"Retry"]})]}):0===Qi.length?r.jsxs("div",{className:"mx-auto max-w-md py-24 text-center",children:[r.jsx("div",{className:"mx-auto mb-6 flex h-20 w-20 items-center justify-center rounded-full bg-primary/10",children:"saved"===Er?r.jsx(cr,{className:"h-9 w-9 text-primary"}):"uploaded"===Er?r.jsx(ur,{className:"h-9 w-9 text-primary"}):r.jsx(mr,{className:"h-9 w-9 text-primary"})}),r.jsx("h3",{className:"mb-2 text-xl font-bold",children:Di?"No echoes matched":`No ${Io.toLowerCase()} yet`}),r.jsx("p",{className:"text-sm text-muted-foreground",children:Di?"Try a broader search or remove one of the filters.":Bo})]}
2):r.jsx(t.Suspense,{fallback:r.jsx("div",{className:"min-h-[45vh] animate-pulse rounded-3xl bg-muted/25"}),children:r.jsx(Gr,{memories:Qi,searchQuery:na,isLoading:Hi,hasInitiallyLoaded:!Ii,onRetry:Vi,onDelete:"uploaded"===Er?Gi:"saved"===Er?Ao:void 0,deleteActionLabel:"saved"===Er?"Remove from library":void 0,deleteActionKind:"saved"===Er?"remove":void 0,mutationSurfaceId:"saved"===Er?"boards-saved":void 0,onLoadMore:Ui,hasMore:!!Ri,isLoadingMore:Bi&&Qi.length>0,showFeedSettingsTrigger:!1,columnPlacement:"balanced",performanceSurface:"board_feed"})})]}):"following"===Er?r.jsx("div",{className:"mx-auto max-w-7xl px-0 pb-24",children:r.jsx(t.Suspense,{fallback:null,children:r.jsx(Ur,{query:ha})})}):r.jsxs(r.Fragment,{children:[zs?r.jsx("div",{className:"mx-auto grid max-w-7xl animate-pulse grid-cols-2 gap-3 px-2 py-6",style:{gridTemplateColumns:`repeat(${Co}, minmax(0, 1fr))`},role:"status","aria-label":"Loading boards","aria-busy":"true",children:Array.from({length:8},(e,t)=>r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"aspect-[4/3] rounded-2xl bg-muted/45"}),r.jsx("div",{className:"h-4 w-3/4 rounded bg-muted/60"})]},t))}):0===d.length&&0===gs.length&&bs?r.jsxs("div",{className:"text-center py-32 max-w-md mx-auto",children:[r.jsx("div",{className:"w-24 h-24 rounded-[2rem] glass flex items-center justify-center mx-auto mb-8 shadow-float",children:r.jsx(fr,{className:"w-8 h-8 text-primary"})}),r.jsx("h2",{className:"text-2xl font-bold mb-3 tracking-tight",children:"Start your first collection"}),r.jsx("p",{className:"text-muted-foreground font-medium mb-8",children:"Create boards to organize your echoes into themed collections."}),r.jsxs(o,{className:"h-14 px-8 rounded-full font-bold text-lg bg-primary hover:scale-105 transition-transform",onClick:()=>Lr(!0),children:[r.jsx(fr,{className:"w-5 h-5 mr-2"}),"Create Your First Board"]})]}):r.jsxs(r.Fragment,{children:[ws&&r.jsxs("div",{className:"mb-6 flex flex-col gap-3 sm:mb-8 md:flex-row md:items-center md:justify-between md:gap-4",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[r.jsx(o,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0 rounded-full",onClick:()=>Ss(Ns),children:r.jsx(hr,{className:"h-4 w-4"})}),r.jsxs("div",{className:"min-w-0",children:[r.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r.jsx("h2",{className:"truncate text-2xl font-black tracking-tight",children:ws.name}),ws.is_owner&&r.jsx(o,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 rounded-full",onClick:()=>Kt(ws.id),"aria-label":`Edit ${ws.name}`,children:r.jsx(pr,{className:"h-4 w-4"})}),r.jsx(o,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 rounded-full",onClick:Ms,"aria-label":`Copy link to ${ws.name}`,children:r.jsx(xr,{className:"h-4 w-4"})})]}),r.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-1 text-xs font-bold uppercase tracking-widest text-muted-foreground",children:[r.jsx("button",{type:"button",className:"hover:text-foreground",onClick:()=>Ss(null),children:"Library"}),_s.map(e=>r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("span",{children:"/"}),r.jsx("button",{type:"button",className:"max-w-32 truncate hover:text-foreground",onClick:()=>Ss(e.id),children:e.name})]},e.id)),r.jsx("span",{className:"ml-1",children:z?"· board count unavailable":`· ${ia(ws.id)} ${1===ia(ws.id)?"board":"boards"}`}),Q&&r.jsxs("span",{className:"ml-1 inline-flex items-center gap-1 normal-case tracking-normal",role:"status",children:[r.jsx(Oe,{className:"h-3 w-3 animate-spin"}),"Syncing"]})]})]})]}),r.jsx("div",{className:"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-2 md:flex md:shrink-0",children:ws.is_owner&&r.jsxs(r.Fragment,{children:[r.jsxs(o,{className:"h-10 rounded-full bg-primary px-3 text-xs font-bold text-primary-foreground gap-2 sm:text-sm md:px-4",onClick:()=>$t(!0),children:[r.jsx(Dr,{className:"h-4 w-4"}),r.jsx("span",{className:"truncate",children:"Move Boards"})]}),r.jsxs(o,{variant:"outline",className:"h-10 rounded-full gap-2 border-primary/40 bg-background/40 px-3 text-xs font-bold text-primary hover:bg-primary/10 sm:text-sm md:px-4",onClick:()=>{Xt(ws.id),zt(!0)},children:[r.jsx(Ie,{className:"h-4 w-4"}),r.jsx("span",{className:"truncate",children:"Set Preview"})]}),r.jsx(o,{variant:"ghost",size:"icon",className:"h-10 w-10 shrink-0 rounded-full text-destructive hover:text-destructive",onClick:()=>Ls(ws.id),"aria-label":"Delete folder",children:r.jsx(gr,{className:"h-4 w-4"})})]})})]}),"canvas"===ds?r.jsx(t.Suspense,{fallback:null,children:r.jsx(Hr,{allItemIds:Ea,displayedItemIds:qa,displayedItems:Ba,shouldWindowItems:Ia,hasMoreDisplayedItems:$a,loadMoreRef:Oa,renderItem:e=>Ka(e,La.has(e.id)),renderCreateItem:Ha,onReorder:za,columns:Co,rowHeight:So,getItemSize:e=>Qa(e)})}):r.jsxs("div",{className:"grid grid-cols-2 gap-4 sm:gap-5 lg:gap-8",style:{gridTemplateColumns:`repeat(${Co}, minmax(0, 1fr))`,gridAutoRows:So},children:[Ba.map((e,t)=>{const s=we(Qa(e),Co);return r.jsx("div",{className:"folder"===e.type?void 0:"relative",style:{gridColumn:`span ${s.columnSpan}`,gridRow:`span ${s.rowSpan}`},children:Ka(e,t<4)},e.id)}),$a&&r.jsxs("div",{ref:Oa,className:"flex min-h-20 items-center justify-center py-4 text-xs font-bold uppercase tracking-widest text-muted-foreground",style:{gridColumn:"1 / -1"},children:[r.jsx(Oe,{className:"mr-2 h-4 w-4 animate-spin"}),"Loading more boards"]}),r.jsx("div",{children:Ha()})]})]}),!jr&&!ti&&r.jsx("div",{ref:ri,"aria-hidden":"true",className:"h-px w-full"}),Ni&&r.jsx("div",{ref:Mi,className:"mt-16 min-h-[28rem] border-t border-border/20 pt-12",children:zs||!ti||wi?r.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[r.jsx(Oe,{className:"w-7 h-7 animate-spin text-muted-foreground mb-4"}),r.jsx("h3",{className:"text-xl font-bold mb-2",children:"Checking unsorted echoes..."}),r.jsx("p",{className:"text-muted-foreground max-w-sm",children:"Looking for echoes that still need a board."})]}):li?r.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[r.jsx("h3",{className:"text-xl font-bold mb-2",children:"Couldn’t check unsorted echoes"}),r.jsx("p",{className:"text-muted-foreground max-w-sm",children:di instanceof Error?di.message:"The unsorted library could not be loaded."}),r.jsx(o,{type:"button",variant:"outline",className:"mt-5 rounded-full",onClick:()=>{mi()},children:"Try again"})]}):ni&&0===bi?r.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[r.jsx("div",{className:"w-20 h-20 rounded-full bg-primary/10 flex items-center justify-center mb-6",children:r.jsx(Me,{className:"w-10 h-10 text-primary"})}),r.jsx("h3",{className:"text-xl font-bold mb-2",children:"All sorted! 🎉"}),r.jsx("p",{className:"text-muted-foreground max-w-sm",children:"All your echoes are organized into boards. Nice work!"})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex items-start justify-between mb-6",children:r.jsxs("div",{children:[r.jsxs("h2",{className:"text-xl font-bold tracking-tight flex items-center gap-2",children:["Unsorted Echoes",r.jsx("span",{className:"text-sm font-normal text-muted-foreground",children:na.trim()?`(${hi.length} of ${bi})`:`(${bi}${ji?"+":""})`})]}),r.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Tap to select · add to a board to sort"})]})}),r.jsx("div",{className:"space-y-4",children:wi?r.jsx("div",{className:"flex items-center justify-center py-12",children:r.jsx(Oe,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):r.jsxs("div",{className:"relative pb-28",onPointerDownCapture:e=>{e.target instanceof Element&&e.target.closest("[data-echo-memory-card]")&&Qr()}
2,children:[r.jsx(t.Suspense,{fallback:r.jsx("div",{className:"min-h-[45vh] animate-pulse rounded-3xl bg-muted/25"}),children:r.jsx(Wr,{memories:xi,mutationSurfaceId:"boards-unsorted",performanceSurface:"boards_unsorted",onDelete:Fo,isSelected:e=>Ga.has(e),onSelect:Wi,isSelectionMode:!0,columns:jo.columns,gap:jo.gap})}),ji&&r.jsx("div",{ref:Ti,className:"flex justify-center py-8",children:r.jsxs(o,{type:"button",variant:"outline",className:"rounded-full gap-2",onClick:()=>{Ci()},disabled:yi,children:[yi?r.jsx(Oe,{className:"h-4 w-4 animate-spin"}):null,yi?"Loading...":"Load more"]})})]})})]})})]})]})}),!jr&&_i&&xi.length>0&&Ga.size>0&&r.jsx("div",{className:N("echo-bottom-action-bar fixed flex","bottom-[calc(max(env(safe-area-inset-bottom),var(--native-safe-bottom,0px))+1rem)] left-0 right-0 z-[70] justify-center px-4 pointer-events-none"),children:r.jsxs("div",{className:"no-scrollbar pointer-events-auto flex w-fit max-w-full items-center gap-1 overflow-x-auto rounded-full border border-border bg-card/90 p-1.5 text-card-foreground shadow-float backdrop-blur-xl animate-in slide-in-from-bottom-3 duration-200",children:[r.jsxs(o,{variant:"ghost",onClick:()=>{if(Ga.size===xi.length&&xi.length>0)Wa(new Set),Ja.current=null,Xa.current=null;else{Xa.current=hi;const e=hi.map(e=>e.id);Wa(new Set(e)),Ja.current=e[e.length-1]||null}},className:"h-9 shrink-0 gap-2 rounded-full px-3 text-sm font-medium","aria-label":Oo?"Deselect all":"Select all",children:[r.jsx(Me,{className:"h-4 w-4"}),r.jsx("span",{className:N(Ga.size>0&&"max-sm:hidden"),children:Oo?"Deselect all":"Select all"})]}),0===Ga.size?r.jsx("span",{className:"hidden whitespace-nowrap pl-1 pr-3 text-sm text-muted-foreground sm:inline",children:"or tap echoes to select"}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"mx-1 h-5 w-px shrink-0 bg-border","aria-hidden":"true"}),r.jsxs("span",{className:"shrink-0 whitespace-nowrap px-1 text-sm font-medium tabular-nums",children:[Ga.size," selected"]}),r.jsx(o,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 rounded-full text-muted-foreground",onClick:Yi,"aria-label":"Clear selection",children:r.jsx(br,{className:"h-4 w-4"})}),r.jsx("span",{className:"mx-1 h-5 w-px shrink-0 bg-border","aria-hidden":"true"}),r.jsx(o,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0 rounded-full text-destructive",onClick:()=>wo(!0),disabled:bo,"aria-label":"Delete selected echoes",children:bo?r.jsx(Oe,{className:"h-4 w-4 animate-spin"}):r.jsx(gr,{className:"h-4 w-4"})}),r.jsxs(o,{variant:"ghost",className:"h-9 shrink-0 gap-2 rounded-full px-3 text-sm font-medium max-sm:w-9 max-sm:px-0",onClick:()=>Se(!0),disabled:no,"aria-label":"Add tag to selected echoes",children:[no?r.jsx(Oe,{className:"h-4 w-4 animate-spin"}):r.jsx(vr,{className:"h-4 w-4"}),r.jsx("span",{className:"hidden sm:inline",children:"Add tag"})]}),r.jsx(t.Suspense,{fallback:r.jsxs(o,{className:"h-9 shrink-0 gap-2 rounded-full bg-primary px-4 text-sm font-medium text-primary-foreground",disabled:!0,"aria-label":"Preparing add to board action",children:[r.jsx(Oe,{className:"h-4 w-4 animate-spin"}),"Add to board"]}),children:r.jsx(Kr,{open:Zi,onOpenChange:eo,boards:Cr,onMove:async(e,r)=>{if(Ji)return;const s=d.find(r=>r.id===e);if(!s||s.is_following)return void le({title:"Cannot add to this board",description:"You can only sort echoes into boards you can edit.",variant:"error"});const a=document.activeElement;a instanceof HTMLElement&&a.blur(),Xi(!0),eo(!1);let i=null,o=!1;try{const s=new Set(Ga),a=xi.map(e=>e.id).filter(e=>s.has(e));if(0===a.length)return;if(a.some(ze))return;i=Qe({memoryIds:a,kind:"move",scope:{type:"surface",surfaceId:"boards-unsorted"}});const d=await V(a,e,{suppressBoardsInvalidation:!0});if(d.ok){const s=Boolean(d.partial)||Number(d.failedCount||0)>0;let c=a;if(s)try{c=await(async(e,r)=>{const t=new Set;for(let s=0;s<r.length;s+=100){const a=r.slice(s,s+100),{data:i,error:o}=await Ke(r=>b.from("memory_boards").select("memory_id").eq("board_id",e).in("memory_id",a).abortSignal(r),"Verifying sorted Echoes");if(o)throw o;(i||[]).forEach(e=>{"string"==typeof(null==e?void 0:e.memory_id)&&t.add(e.memory_id)})}return r.filter(e=>t.has(e))})(e,a)}catch(n){return await ki(),Yi(),void le({title:"Board updated;
2 feed refreshed",description:"The save partly completed, so Echo refreshed Unsorted from the server instead of guessing."})}await i.hidden;const u=new Set(c);if(ge.setQueriesData({queryKey:["board-unsorted",null==be?void 0:be.id]},e=>Re(e,u)),ge.setQueriesData({queryKey:["boards",null==be?void 0:be.id]},r=>{if(!Array.isArray(r)||0===c.length)return r;const t=(new Date).toISOString(),s=Math.max(0,Number(d.addedCount??c.length));return r.map(r=>r.id===e?{...r,memory_count:Math.max(0,Number(r.memory_count||0))+s,last_memory_added_at:t}:r)}),o=c.length>0,r&&c.length>0)try{const t=await Ke(()=>F({boardId:e,memoryIds:c,sectionId:r,mode:"replace"}),"Placing sorted Echoes in board section");E(e,t)}catch(l){le({title:"Added without a section",description:"The echoes are safe in the board. You can place them in the section there.",variant:"error"})}const m=c.length,f=a.filter(e=>!u.has(e)),h=f.length;t.startTransition(()=>{f.length>0?(Xa.current=(Xa.current||xi).filter(e=>!u.has(e.id)),Wa(new Set(f))):(Yi(),la(""))}),le({title:"Added to board ✓",description:h>0?`${m} of ${a.length} echo${1!==a.length?"es":""} sorted. The rest remain selected.`:`${m} echo${1!==m?"es":""} sorted.`})}else le({title:"Could not add to board",description:d.message||"That board may no longer be editable. Please try again.",variant:"error"})}catch(c){null==i||i.rollback(),le({title:"Could not add to board",description:"Something went wrong while sorting those echoes.",variant:"error"})}finally{i&&(o?i.finish():i.rollback()),Xi(!1)}},disabled:Ji,description:`Select a board for your ${Ga.size} echo${1!==Ga.size?"es":""}.`,trigger:r.jsxs(o,{className:"h-9 shrink-0 gap-2 rounded-full bg-primary px-4 text-sm font-medium text-primary-foreground",disabled:Ji||0===Cr.length,children:[Ji?r.jsx(Oe,{className:"h-4 w-4 animate-spin"}):r.jsx(Dr,{className:"h-4 w-4"}),Ji?"Adding...":"Add to board"]})})})]})]})}),r.jsx(He,{open:Ce,onOpenChange:e=>{Se(e),e||no||(to([]),ao("add"),uo(null))},children:r.jsxs(Ue,{className:"rounded-3xl sm:max-w-xl",children:[r.jsxs(Ve,{children:[r.jsx(Ge,{children:co?"Tags applied":"Tag selected echoes"}),r.jsx(We,{children:co?`Results for ${co.selectedCount.toLocaleString()} selected echo${1===co.selectedCount?"":"es"}.`:"Choose several existing tags or create new ones. Existing matches are skipped."})]}),r.jsx(t.Suspense,{fallback:r.jsx("div",{className:"h-36 animate-pulse rounded-2xl bg-muted/35"}),children:co?r.jsx(Jr,{result:co,onDone:()=>{Se(!1),to([]),ao("add"),uo(null)},onApplyMore:()=>{to([]),uo(null)}}):r.jsx(Xr,{availableTags:Pe,selectedTags:ro,onSelectedTagsChange:to,selectedEchoCount:Ga.size,editableEchoCount:ho,tagCoverage:po.manualCoverage,metadataTags:po.metadataTags,isCoverageLoading:xo,operation:so,onOperationChange:ao,recentTagIds:io,isApplying:no,onApply:()=>{go()},onCancel:()=>{Se(!1),to([]),ao("add"),uo(null)}})})]})}),qr?r.jsx(t.Suspense,{fallback:null,children:r.jsx(zr,{onCreateBoard:Ua,open:!0,onOpenChange:Lr})}):null,r.jsx(Ye,{open:yo,onOpenChange:wo,children:r.jsxs(Je,{className:"rounded-3xl",children:[r.jsxs(Xe,{children:[r.jsxs(Ze,{children:["Move ",Ga.size," echo",1!==Ga.size?"es":""," to trash?"]}),r.jsx(er,{children:"These echoes will be moved to trash and stay recoverable until you permanently delete them."})]}),r.jsxs(rr,{children:[r.jsx(tr,{className:"rounded-full",children:"Cancel"}),r.jsx(sr,{onClick:()=>{Do(),wo(!1)},className:"rounded-full bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Move to Trash"})]})]})}),r.jsx(He,{open:Zr,onOpenChange:ct,children:r.jsxs(Ue,{className:"sm:max-w-md bg-background/95 backdrop-blur-xl border-border/50 rounded-3xl",onOpenAutoFocus:e=>e.preventDefault(),children:[r.jsx(Ve,{children:r.jsxs(Ge,{className:"text-xl font-bold",children:["Create Folder",ws?` in ${ws.name}`:""]})}),r.jsxs("div",{className:"space-y-5 py-2",children:[r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-muted-foreground mb-2 block",children:"Folder Name"}),r.jsx(n,{value:is,onChange:e=>os(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),Ps())},placeholder:"Projects",className:"h-12 rounded-xl bg-background/50 border-border/50"})]}),r.jsxs("div",{children:[r.jsx("label",{className:"text-sm font-medium text-muted-foreground mb-2 block",children:"Card size"}),r.jsx(Br,{value:ns,onChange:ls})]}),r.jsxs("div",{className:"flex justify-end gap-3",children:[r.jsx(o,{type:"button",variant:"ghost",onClick:()=>ct(!1),className:"rounded-full",children:"Cancel"}),r.jsx(o,{type:"button",onClick:Ps,disabled:!is.trim(),className:"rounded-full bg-primary px-6",children:"Create Folder"})]})]})]})}),r.jsx(He,{open:Lt,onOpenChange:$t,children:r.jsxs(Ue,{className:"sm:max-w-lg bg-background/95 backdrop-blur-xl !border-0 rounded-3xl",onOpenAutoFocus:e=>e.preventDefault(),children:[r.jsx(Ve,{children:r.jsxs(Ge,{className:"text-xl font-bold",children:["Move Boards",ws?` to ${ws.name}`:""]})}),r.jsx("div",{className:"mt-4 max-h-[60vh] overflow-y-auto pr-1",children:ws&&(Cr.length>0||gs.length>1)?r.jsxs("div",{className:"space-y-2",children:[gs.filter(e=>e.id!==ws.id&&!wt(gs,e.id).has(ws.id)).map(e=>{const t=e.parent_folder_id===ws.id,s=e.parent_folder_id?gs.find(r=>r.id===e.parent_folder_id):null,a=oa(e.id),i=Boolean(e.preview_memory_id||a);return r.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-border/40 bg-muted/20 p-3",children:[r.jsx("div",{className:"relative flex h-12 w-12 shrink-0 items-center justify-center overflow-hidden rounded-full bg-card text-primary shadow-soft",children:i?r.jsx(Et,{folder:e,previewBoard:a}):r.jsx(yr,{className:"h-5 w-5"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-bold",children:e.name}),r.jsx("div",{className:"text-[11px] font-bold uppercase tracking-widest text-muted-foreground",children:t?"In this folder":s?`In ${s.name}`:"No folder"})]}),r.jsx(o,{size:"sm",variant:t?"outline":"default",className:"shrink-0 rounded-full",onClick:()=>Ds(e.id,t?null:ws.id),children:t?"Remove":"Move Here"})]},e.id)}),Cr.map(e=>{const t=e.folder_id===ws.id,s=e.folder_id?gs.find(r=>r.id===e.folder_id):null;return r.jsxs("div",{className:"flex items-center gap-3 rounded-2xl border border-border/40 bg-muted/20 p-3",children:[r.jsx("div",{className:"flex h-12 w-12 shrink-0 items-center justify-center overflow-hidden rounded-full bg-card text-primary shadow-soft",children:r.jsx(C,{boardId:e.id,previewIds:e.preview_image_ids,previewMedia:e.preview_media,fallbackIcon:r.jsx("span",{className:"text-lg","aria-hidden":"true",children:e.icon||r.jsx(Ie,{className:"h-5 w-5"})}),maxItems:1,videoPlayMode:"never"})}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("div",{className:"truncate text-sm font-bold",children:e.name}),r.jsx("div",{className:"text-[11px] font-bold uppercase tracking-widest text-muted-foreground",children:t?"In this folder":s?`In ${s.name}`:"No folder"})]}),r.jsx(o,{size:"sm",variant:t?"outline":"default",className:"shrink-0 rounded-full",onClick:()=>Es(e.id,t?null:ws.id),children:t?"Remove":"Move Here"})]},e.id)})]}):r.jsx("div",{className:"rounded-2xl border border-dashed border-border/50 p-8 text-center text-sm text-muted-foreground",children:"No editable boards available."})})]})}),r.jsx(Ft,{folder:js,open:!!js,onOpenChange:e=>{e||Kt(null)},onRename:qs,onVisibilityChange:Fs,onColumnsChange:Bs}),r.jsx(He,{open:Rt,onOpenChange:e=>{zt(e),e||Xt(null)},children:r.jsxs(Ue,{className:"sm:max-w-2xl bg-background/95 backdrop-blur-xl !border-0 rounded-3xl",onOpenAutoFocus:e=>e.preventDefault(),children:[r.jsx(Ve,{children:r.jsxs(Ge,{className:"text-xl font-bold",children:["Set Preview Echo",Cs?` for ${Cs.name}`:""]})}),r.jsxs("div",{className:"mt-4 max-h-[65vh] overflow-y-auto pr-1",children:[rs&&r.jsx("div",{className:"mb-4 rounded-2xl border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm font-medium text-destructive",children:rs}),Ws.length>1&&r.jsxs("div",{className:"mb-4 flex gap-2 overflow-x-auto pb-1",children:[r.jsx(o,{type:"button",size:"sm",variant:"all"===ss?"default":"outline",className:"shrink-0 rounded-full",onClick:()=>as("all"),children:"All"}),Ws.map(e=>r.jsx(o,{type:"button",size:"sm",variant:ss===e.id?"default":"outline",className:"shrink-0 rounded-full",onClick:()=>as(e.id),children:e.name},e.id))]}),r.jsx($r,{boards:Ws,activeBoardId:ss,selectedMemoryId:(null==Cs?void 0:Cs.preview_memory_id)??null,isSaving:Zt,onSelect:Va,fetchBoardMemoriesPaginated:ae})]})]})}),ne]})}},Symbol.toStringTag,{value:"Module"}));
2export{Br as B,At as a};

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.