1// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later 2// @source: https://gitlab.com/soapbox-pub/ditto/-/tree/main 3import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{qi as t}from"./lucide-icons-CItI72Jx.js";import{t as n}from"./jsx-runtime-CFwixLRt.js";import{t as r}from"./useAppContext-DJPYVUf_.js";import{r as i}from"./useEncryptedSettings-kUKRqdMX.js";import{t as a}from"./useCurrentUser-C_Di2And.js";import{t as o}from"./utils-BFSTDHdM.js";import{u as s}from"./LayoutContext-Dj3E1oyB.js";var c=e(t(),1),l=n(),u=crypto.getRandomValues(new Uint8Array(1))[0]<13,d=16;function f(){return new Promise((e,t)=>{let n=new Image;n.onload=()=>{let r=document.createElement(`canvas`);r.width=d,r.height=d;let i=r.getContext(`2d`);if(!i)return t(Error(`Canvas not supported`));i.drawImage(n,0,0,d,d);let a=i.getImageData(0,0,d,d),o=Array.from({length:d},()=>Array(d).fill(0));for(let e=0;e<d;e++)for(let t=0;t<d;t++)o[e][t]=a.data[(e*d+t)*4+3];let s=(e,t)=>e<0||e>=d||t<0||t>=d?0:o[e][t],c=document.createElement(`canvas`);c.width=d,c.height=d;let l=c.getContext(`2d`);if(!l)return t(Error(`Canvas not supported`));for(let e=0;e<d;e++)for(let t=0;t<d;t++){let n=o[e][t];if(n<=25)continue;let r=[[s(e,t-1),s(e,t+1)],[s(e-1,t),s(e+1,t)],[s(e-1,t-1),s(e+1,t+1)],[s(e-1,t+1),s(e+1,t-1)]],i=!1;for(let[e,t]of r)if(n>=e&&n>=t&&(e<=25||t<=25)){i=!0;break}i&&(l.fillStyle=`#000`,l.fillRect(t,e,1,1))}e(c.toDataURL())},n.onerror=()=>t(Error(`Failed to load logo`)),n.src=`/logo.svg`})}var p=null,m=null;function h(){return p?Promise.resolve(p):(m||=f().then(e=>(p=e,e)),m)}function g({className:e,size:t=40}){let{user:n}=a(),{config:i}=r();return u&&n?(0,l.jsx)(_,{className:e,size:t}):(0,l.jsx)(`div`,{role:`img`,"aria-label":i.appName,style:{width:t,height:t,backgroundColor:`hsl(var(--primary))`,maskImage:`url(/logo.svg)`,maskSize:`contain`,maskRepeat:`no-repeat`,maskPosition:`center`,WebkitMaskImage:`url(/logo.svg)`,WebkitMaskSize:`contain`,WebkitMaskRepeat:`no-repeat`,WebkitMaskPosition:`center`},className:o(e)})}function _({className:e,size:t=40}){let n=(0,c.useRef)(null),[i,a]=(0,c.useState)(!!p),{config:s}=r();return(0,c.useEffect)(()=>{let e=n.current;e&&h().then(t=>{e.style.maskImage=`url(${t})`,e.style.webkitMaskImage=`url(${t})`,e.style.maskSize=`contain`,e.style.webkitMaskSize=`contain`,e.style.maskRepeat=`no-repeat`,e.style.webkitMaskRepeat=`no-repeat`,e.style.maskPosition=`center`,e.style.webkitMaskPosition=`center`,e.style.imageRendering=`pixelated`,a(!0)})},[]),(0,l.jsx)(`div`,{ref:n,role:`img`,"aria-label":s.appName,style:{width:t,height:t,backgroundColor:`hsl(var(--primary))`,imageRendering:`pixelated`,opacity:+!!i,transition:`opacity 0.1s`},className:o(e)})}var v=2e3,y=300,b=2e3,x=new Map;function S(e,t){if(!(!e||t<=0)&&(x.delete(e),x.set(e,t),x.size>b)){let e=x.keys().next().value;e!==void 0&&x.delete(e)}}var C=new Map,w=null;function T(){return typeof IntersectionObserver>`u`?null:(w??=new IntersectionObserver(e=>{for(let t of e)C.get(t.target)?.(t)},{rootMargin:`${v}px 0px`}),w)}function E(e,t){let n=T();return n?(C.set(e,t),n.observe(e),()=>{n.unobserve(e),C.delete(e)}):()=>{}}function D({children:e,initialInView:t=!1,className:n,cacheKey:r}){let i=(0,c.useRef)(null),[a,o]=(0,c.useState)(t),s=(0,c.useRef)(r&&x.get(r)||y),u=(0,c.useRef)(r);return u.current=r,(0,c.useEffect)(()=>{let e=i.current;if(e)return E(e,e=>{let t=e.boundingClientRect.height;t>0&&(e.isIntersecting||(s.current=t),S(u.current,t)),o(e.isIntersecting)})},[]),(0,c.useLayoutEffect)(()=>{let e=i.current;return()=>{e&&S(u.current,e.offsetHeight)}},[]),(0,l.jsx)(`div`,{ref:i,className:n,"data-scroll-key":r,style:{containIntrinsicSize:`auto ${s.current}px`},children:a?e:(0,l.jsx)(`div`,{style:{height:s.current},"aria-hidden":`true`})})}function O(){let{user:e}=a(),{settings:t,updateSettings:n,isLoading:r,isError:o,error:s,hasNip44Support:l}=i(),u=(0,c.useMemo)(()=>t?.contentFilters||[],[t]),d={mutateAsync:async t=>{if(!e)throw Error(`User not logged in`);let r=u,i={...t,id:crypto.randomUUID(),createdAt:Date.now(),updatedAt:Date.now()},a=[...r,i];return await n.mutateAsync({contentFilters:a}),i},isPending:n.isPending},f={mutateAsync:async t=>{if(!e)throw Error(`User not logged in`);let r=u.map(e=>e.id===t.id?{...t,updatedAt:Date.now()}:e);return await n.mutateAsync({contentFilters:r}),t},isPending:n.isPending},p={mutateAsync:async t=>{if(!e)throw Error(`User not logged in`);let r=u.filter(e=>e.id!==t);await n.mutateAsync({contentFilters:r})},isPending:n.isPending},m={mutateAsync:async t=>{if(!e)throw Error(`User not logged in`);let r=u.map(e=>e.id===t?{...e,enabled:!e.enabled,updatedAt:Date.now()}:e);await n.mutateAsync({contentFilters:r})},isPending:n.isPending},h=e=>{let t=u.filter(e=>e.enabled);return t.length===0?!1:t.some(t=>t.rules.every(t=>g(e,t)))},g=(e,t)=>{let{type:n,field:r,operator:i,value:a,caseSensitive:o=!1}=t,s=(e,t)=>{let n=o?e:e.toLowerCase(),r=o?t:t.toLowerCase();switch(i){case`equals`:return n===r;case`not-equals`:return n!==r;case`contains`:return n.includes(r);case`not-contains`:return!n.includes(r);case`regex`:try{return new RegExp(r,o?``:`i`).test(n)}catch{return!1}default:return!1}};switch(n){case`kind`:return s(String(e.kind),a);case`content-regex`:return s(e.content||``,a);case`tag`:{if(!r)return!1;let t=e.tags.find(e=>e[0]===r)?.[1];return t?s(t,a):!1}case`author-metadata`:return!1;default:return!1}};return{filters:u,isLoading:r,isError:o,error:s,addFilter:d,updateFilter:f,deleteFilter:p,toggleFilter:m,shouldFilterEvent:h,hasNip44Support:l}}
3function k({count:e,onClick:t}){let n=s();return e<=0?null:(0,l.jsx)(`div`,{className:o(`sticky new-posts-pill z-10 flex justify-center pointer-events-none`,`max-sidebar:transition-opacity max-sidebar:duration-300 max-sidebar:ease-in-out`,n&&`max-sidebar:opacity-0 max-sidebar:pointer-events-none`),style:{marginBottom:`-3rem`},children:(0,l.jsxs)(`button`,{onClick:t,className:`pointer-events-auto px-4 py-1.5 rounded-full bg-primary text-primary-foreground text-sm font-medium shadow-lg hover:bg-primary/90 transition-colors animate-in fade-in slide-in-from-top-2 duration-300`,children:[e,` new post`,e===1?``:`s`]})})}export{g as i,O as n,D as r,k as t}; 4// @license-end
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.