1import{j as e}from"./jsx-runtime-D_zvdyIk.js";import{r as m}from"./index-CMt9tOoS.js";import{a as P,b as z}from"./chunk-KS7C4IRE-XN3z5z9o.js";import{u as E}from"./ArticleBookmarksContext-DoWA9NN5.js";import{S as V}from"./SEO-BsZSMxC0.js";import{p as O,S as U,a as X,i as T,t as _,f as M,y as q,B as K}from"./dateUtils-93twbziG.js";import{a as W,C as G,S as H,L as Y}from"./share-2-DW_CFLPM.js";import{X as J}from"./x-BrH3z1BF.js";import{A as Q}from"./arrow-left-BPBrWQqH.js";import{C as Z,A as ee}from"./Header-DFpVVTw-.js";import{M as te}from"./mail-BVTHuyqV.js";import"./logger-C2O-ANe3.js";const se=({entries:t,currentISO:s,onPick:a,onClose:c})=>{const o=O(s),[n,i]=m.useState({y:o.y,m:o.m}),p=m.useMemo(()=>{const l={};return t.forEach(u=>{l[u.date]=u}),l},[t]),r=m.useMemo(()=>t.map(l=>l.date).sort(),[t]),v=r[0],k=r[r.length-1],$=(new Date(n.y,n.m,1).getDay()+6)%7,D=new Date(n.y,n.m+1,0).getDate(),b=[];for(let l=0;l<$;l++)b.push(null);for(let l=1;l<=D;l++)b.push(l);for(;b.length%7!==0;)b.push(null);const S=l=>{const u=new Date(n.y,n.m+l,1);i({y:u.getFullYear(),m:u.getMonth()})};let j=!0,f=!0;if(v){const l=O(v);j=n.y>l.y||n.y===l.y&&n.m>l.m}else j=!1;if(k){const l=O(k);f=n.y<l.y||n.y===l.y&&n.m<l.m}else f=!1;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"dd-cal-backdrop fixed inset-0 z-[70]",style:{background:"color-mix(in oklab, var(--vk-surface-inverse) 55%, transparent)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)"},onClick:c}),e.jsxs("div",{role:"dialog","aria-label":"Kalender",className:"dd-cal-popover fixed left-1/2 z-[80] p-6 border vk-border-subtle vk-bg-page",style:{bottom:80,width:"min(520px, calc(100vw - 32px))",transform:"translateX(-50%)",boxShadow:"0 20px 60px rgba(15,14,13,.18)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-[18px]",children:[e.jsxs("div",{className:"font-serif font-normal text-[22px] tracking-[-0.01em] vk-text-primary",children:[U[n.m]," ",n.y]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(F,{ariaLabel:"Föregående månad",disabled:!j,onClick:()=>S(-1),children:e.jsx(W,{className:"w-4 h-4"})}),e.jsx(F,{ariaLabel:"Nästa månad",disabled:!f,onClick:()=>S(1),children:e.jsx(G,{className:"w-4 h-4"})}),e.jsx(F,{ariaLabel:"Stäng",onClick:c,children:e.jsx(J,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"grid grid-cols-7 gap-0.5",children:[X.map(l=>e.jsx("div",{className:"font-mono text-[9px] tracking-[0.2em] uppercase vk-text-muted py-1.5 text-center",children:l},l)),b.map((l,u)=>{if(!l)return e.jsx("div",{className:"aspect-square opacity-25 pointer-events-none"},u);const C=`${n.y}-${String(n.m+1).padStart(2,"0")}-${String(l).padStart(2,"0")}`,h=!!p[C],g=C===s;return e.jsxs("button",{type:"button",disabled:!h,onClick:()=>h&&a(C),className:`relative aspect-square flex items-center justify-center font-mono text-[13px] border border-transparent transition-all duration-150 disabled:cursor-default ${g?"":h?"cursor-pointer hover:border-[color:var(--vk-border-subtle)]":""}`,style:{color:g?"var(--vk-interactive-fg)":h?"var(--vk-text-primary)":"var(--vk-text-tertiary)",background:g?"var(--vk-interactive-bg)":void 0},onMouseEnter:I=>{h&&!g&&(I.currentTarget.style.background="var(--vk-surface-2)")},onMouseLeave:I=>{h&&!g&&(I.currentTarget.style.background="")},children:[l,h&&e.jsx("span",{className:"absolute bottom-1.5 left-1/2 w-1 h-1",style:{transform:"translateX(-50%)",background:"var(--vk-brand)"}})]},u)})]}),e.jsxs("div",{className:"mt-[18px] pt-3.5 border-t vk-border-subtle flex justify-between items-center font-mono text-[10px] tracking-[0.25em] uppercase vk-text-muted",children:[e.jsx("span",{children:"Publicerade datum är markerade"}),e.jsxs("span",{children:[t.length," st"]})]})]})]})},F=({children:t,onClick:s,disabled:a,ariaLabel:c})=>e.jsx("button",{type:"button","aria-label":c,disabled:a,onClick:s,className:"w-8 h-8 inline-flex items-center justify-center border vk-border-subtle transition-all duration-200 disabled:opacity-30 disabled:cursor-not-allowed enabled:hover:text-brand-600 enabled:hover:border-brand-600",style:{color:"var(--vk-text-tertiary)"},children:t}),ae=t=>t.filter(s=>typeof s.date=="string"&&T(s.date)).sort((s,a)=>a.date.localeCompare(s.date)),re=(t,s)=>{var i;const a=((i=t[0])==null?void 0:i.date)??null,c=s&&T(s)?s:a||"",o=t.findIndex(p=>p.date===c),n=o>=0?t[o]??null:null;return{latestISO:a,currentISO:c,currentIdx:o,entry:n,nextEntry:o>0?t[o-1]??null:null,prevEntry:o>=0&&o<t.length-1?t[o+1]??null:null}},R=(t,s)=>t[s]==="*"&&t[s-1]!=="*"&&t[s+1]!=="*",ne=(t,s)=>{for(let a=s+1;a<t.length;a+=1)if(R(t,a))return a;return-1},A=t=>{const s=[];let a=0,c=0;for(;a<t.length;){const o=t.indexOf("*",a);if(o===-1){s.push(t.slice(a));break}if(!R(t,o)){s.push(t.slice(a,o+1)),a=o+1;continue}const n=ne(t,o);if(n===-1){s.push(t.slice(a));break}const i=t.slice(o+1,n);if(!i||i.trim()!==i||i.includes(` 2`)){s.push(t.slice(a,o+1)),a=o+1;continue}o>a&&s.push(t.slice(a,o)),s.push(e.jsx("em",{children:i},`em-${c+=1}`)),a=n+1}return s},Ne=({initialEntry:t=null})=>{const{datum:s}=P(),a=z(),{dagensDatum:c,isLoading:o}=E(),n=m.useMemo(()=>{const d=new Map;for(const x of c)x!=null&&x.date&&d.set(x.date,x);return t!=null&&t.date&&!d.has(t.date)&&d.set(t.date,t),ae(Array.from(d.values())
2)},[c,t]),{latestISO:i,currentISO:p,entry:r,nextEntry:v,prevEntry:k}=m.useMemo(()=>re(n,s),[n,s]),[y,$]=m.useState(null),[D,b]=m.useState(!1),S=m.useRef(null),j=m.useRef("");m.useEffect(()=>{if(!p)return;const d=j.current;if(d&&d!==p){const x=n.findIndex(w=>w.date===d),N=n.findIndex(w=>w.date===p);x>=0&&N>=0&&$(N<x?"next":"prev"),requestAnimationFrame(()=>{var w;(w=S.current)==null||w.scrollIntoView({behavior:"smooth",block:"start"})})}j.current=p},[p]),m.useEffect(()=>{o||i&&(!s||!T(s))&&a(`/dagens-datum/${i}`,{replace:!0})},[s,i,o,a]);const f=m.useCallback(d=>{a(`/dagens-datum/${d}`)},[a]),l=m.useCallback(()=>{k&&f(k.date)},[k,f]),u=m.useCallback(()=>{v&&f(v.date)},[v,f]),C=m.useCallback(()=>{i&&f(i)},[i,f]),h=!!i&&p===i;m.useEffect(()=>{const d=x=>{if(D){x.key==="Escape"&&b(!1);return}const N=x.target;N&&(N.matches("input, textarea")||N.isContentEditable)||(x.key==="ArrowLeft"?(x.preventDefault(),l()):x.key==="ArrowRight"&&(x.preventDefault(),u()))};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[D,l,u]);const g=(r==null?void 0:r.seoTitle)||(r!=null&&r.title?`${r.title} â Dagens datum`:"Dagens datum"),I=(r==null?void 0:r.seoDescription)||(r==null?void 0:r.eyebrow)||(r==null?void 0:r.lede)||"",L=(r==null?void 0:r.seoImageUrl)||(r==null?void 0:r.image);m.useEffect(()=>{if(!y)return;const d=window.setTimeout(()=>$(null),500);return()=>window.clearTimeout(d)},[y]);const B=y==="next"?"4%":y==="prev"?"-4%":"0";return e.jsxs("div",{className:"bg-[var(--vk-surface-0)]",children:[e.jsx(V,{title:g,description:I,image:L,imageAlt:r==null?void 0:r.imageAlt,type:"article",url:`/dagens-datum/${p||""}`,publishedTime:r==null?void 0:r.publishedAt,section:"Dagens datum"}),e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12 lg:py-16",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-8 font-sans font-semibold text-[10px] uppercase tracking-[0.32em] vk-text-muted",children:[e.jsx("span",{className:"w-6 h-px bg-brand-600"}),e.jsx("span",{children:"Dagens datum"}),(r==null?void 0:r.tag)&&e.jsxs(e.Fragment,{children:[e.jsx("span",{"aria-hidden":!0,children:"â"}),e.jsx("span",{className:"text-brand-600",children:r.tag})]})]}),e.jsxs("div",{ref:S,className:"dd-article dd-article-fade grid grid-cols-1 lg:grid-cols-[minmax(0,5fr)_minmax(0,7fr)] gap-8 lg:gap-16",style:{"--dd-enter-from":B},children:[e.jsx("div",{className:"lg:sticky lg:top-24 lg:self-start",children:e.jsx(le,{entry:r})}),e.jsx(oe,{entry:r})]},p),e.jsx(ce,{prevEntry:k,nextEntry:v,isOnToday:h,onPrev:l,onNext:u,onOpenCalendar:()=>b(!0),onGoToday:C})]}),D&&e.jsx(se,{entries:n,currentISO:p,onPick:d=>{b(!1),f(d)},onClose:()=>b(!1)})]})},le=({entry:t})=>{const s=(t==null?void 0:t.isoDate)||(t==null?void 0:t.date),a=(t==null?void 0:t.tag)||"Dagens datum",c=_(),o=(t==null?void 0:t.date)===c;return e.jsxs("div",{className:"relative",children:[s&&e.jsxs("span",{className:"absolute z-[5] inline-flex items-center gap-2.5 px-2.5 py-1.5 font-mono text-[10px] uppercase tracking-[0.3em] vk-text-muted border vk-border-subtle pointer-events-none",style:{top:16,left:16,background:"color-mix(in oklab, var(--vk-surface-0) 80%, transparent)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)"},children:[e.jsx("span",{children:M(s)}),e.jsx("span",{className:"text-brand-600",children:"·"}),e.jsx("span",{children:a}),o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-brand-600",children:"·"}),e.jsx("span",{className:"text-brand-600",children:"Idag"})]})]}),e.jsx("div",{className:"dd-article",children:e.jsxs("div",{className:"dd-image-frame",children:[e.jsx("span",{className:"dd-corner tl"}),e.jsx("span",{className:"dd-corner tr"}),e.jsx("span",{className:"dd-corner bl"}),e.jsx("span",{className:"dd-corner br"}),t!=null&&t.image?e.jsx("img",{src:t.image,alt:t.imageAlt||"",loading:"eager"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center font-serif text-[28px] bg-gradient-to-br from-ink-800 via-ink-900 to-brand-950 text-brand-400/50",children:"Bild kommer"})]})})]})},oe=({entry:t})=>t?e.jsxs("article",{className:"dd-article max-w-[640px]",children:[e.jsx("h1",{className:"font-serif font-light leading-[0.98] tracking-[-0.025em] vk-text-primary mb-4 text-balance",style:{fontSize:"clamp(2.5rem, 4vw, 4rem)"},children:t.title}),t.eyebrow&&e.jsx("p",{className:"font-serif font-normal text-[22px] leading-[1.35] mb-7 text-pretty",style:{color:"var(--vk-text-tertiary)"},children:t.eyebrow}),e.jsxs("div",{className:"flex items-center gap-3 my-6",children:[e.jsx("span",{className:"h-px flex-1 max-w-[64px]",style:{background:"linear-gradient(90deg, var(--vk-brand), transparent)"}}),e.jsxs("span",{className:"font-mono text-[10px] uppercase tracking-[0.3em] vk-text-muted",children:[M(t.isoDate||t.date),(()=>{const s=t.isoDate?q(t.isoDate):0;return s>0?` · ${s} Ã¥r sedan`:""})()]})]}),t.lede&&e.jsx("p",{className:"dd-lede",children:A(t.lede)}),e.jsx("div",{children:(t.body||[]).map((s,a)=>s?s.kind==="h2"?e.jsx("h2",{className:"dd-h2",children:A(s.text)},a):s.kind==="pull"?e.jsx("blockquote",{className:"dd-pull",children:A(s.text)},a):e.jsx("p",{className:"font-sans text-[17px] leading-[1.75] mb-[22px] text-pretty whitespace-pre-line",style:{color:"var(--vk-text-secondary)"},children:A(s.text)},a):null)}),e.jsx(ie,{entry:t})]}):e.jsxs("article",{className:"dd-article max-w-[640px]",children:[e.jsx("h1",{className:"font-serif font-light leading-[0.98] tracking-[-0.025em] vk-text-primary mb-4 text-balance",style:{fontSize:"clamp(2.5rem, 4vw, 4rem)"},children:"Inget publicerat"}),e.jsx("p",{className:"font-serif text-[20px] leading-[1.55] vk-text-secondary",children:"För det här datumet finns ännu ingen artikel publicerad. Bläddra vidare till nästa datum eller välj ett tidigare datum frÃ¥n kalendern."})]}),ie=({entry:t})=>{const s=typeof window<"u"?`${window.location.protocol}//${window.location.host}/dagens-datum/${t.date}`:`https://www.vaardkasen.se/dagens-datum/${t.date}`,a=t.title,c=`https://twitter.com/intent/tweet?text=${encodeURIComponent(a+" â Dagens datum")}&url=${encodeURIComponent(s)}`,o=`mailto:?subject=${encodeURIComponent(a+" â VÃ¥rdkasen")}&body=${encodeURIComponent(s)}`,n=async()=>
2{if(typeof navigator<"u"&&navigator.clipboard)try{await navigator.clipboard.writeText(s)}catch{}};return e.jsxs("div",{className:"mt-14 pt-7 flex flex-wrap items-center justify-between gap-4 border-t vk-border-subtle",children:[e.jsx("span",{className:"font-sans font-semibold text-[10px] uppercase tracking-[0.3em] vk-text-muted",children:"Dela"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("a",{href:c,target:"_blank",rel:"noreferrer noopener","aria-label":"Dela på X",className:"w-9 h-9 inline-flex items-center justify-center transition-colors hover:text-brand-600",style:{color:"var(--vk-text-tertiary)"},children:e.jsx(H,{className:"w-4 h-4"})}),e.jsx("a",{href:o,"aria-label":"Maila",className:"w-9 h-9 inline-flex items-center justify-center transition-colors hover:text-brand-600",style:{color:"var(--vk-text-tertiary)"},children:e.jsx(te,{className:"w-4 h-4"})}),e.jsx("button",{type:"button",onClick:n,"aria-label":"Kopiera länk",className:"w-9 h-9 inline-flex items-center justify-center transition-colors hover:text-brand-600",style:{color:"var(--vk-text-tertiary)"},children:e.jsx(Y,{className:"w-4 h-4"})}),e.jsx("button",{type:"button","aria-label":"Spara",className:"w-9 h-9 inline-flex items-center justify-center transition-colors hover:text-brand-600",style:{color:"var(--vk-text-tertiary)"},children:e.jsx(K,{className:"w-4 h-4"})})]})]})},ce=({prevEntry:t,nextEntry:s,isOnToday:a,onPrev:c,onNext:o,onOpenCalendar:n,onGoToday:i})=>e.jsxs("nav",{className:"mt-16 lg:mt-24 pt-8 border-t vk-border-subtle grid grid-cols-1 sm:grid-cols-3 gap-6 items-center",children:[e.jsx("div",{className:"flex justify-start",children:t?e.jsxs("button",{type:"button",onClick:c,className:"group inline-flex items-start gap-3 text-left transition-colors",children:[e.jsx(Q,{className:"w-5 h-5 mt-0.5 text-brand-600 flex-shrink-0"}),e.jsxs("span",{className:"block",children:[e.jsxs("span",{className:"block font-mono text-[10px] uppercase tracking-[0.28em] vk-text-muted",children:["Föregående · ",M(t.date)]}),e.jsx("span",{className:"block font-serif italic text-[16px] mt-1 vk-text-secondary group-hover:text-brand-600 transition-colors",children:t.title})]})]}):e.jsx("span",{})}),e.jsxs("div",{className:"flex items-center justify-center gap-4",children:[e.jsxs("button",{type:"button",onClick:n,className:"inline-flex items-center gap-2.5 px-3.5 py-2 font-sans font-semibold text-[10px] tracking-[0.3em] uppercase transition-colors hover:text-brand-600",style:{color:"var(--vk-text-secondary)"},children:[e.jsx(Z,{className:"w-4 h-4"}),"Kalender"]}),e.jsx("span",{className:"w-px h-5 vk-border-subtle border-r"}),e.jsx("button",{type:"button",onClick:i,disabled:a,className:"inline-flex items-center gap-2 px-4 py-2 font-sans font-semibold text-[10px] tracking-[0.3em] uppercase border vk-border-strong transition-all disabled:opacity-35 disabled:cursor-not-allowed enabled:hover:border-brand-600 enabled:hover:text-brand-600",style:{color:"var(--vk-text-secondary)"},children:"Idag"})]}),e.jsx("div",{className:"flex justify-end",children:s?e.jsxs("button",{type:"button",onClick:o,className:"group inline-flex items-start gap-3 text-right transition-colors",children:[e.jsxs("span",{className:"block",children:[e.jsxs("span",{className:"block font-mono text-[10px] uppercase tracking-[0.28em] vk-text-muted",children:["Nästa · ",M(s.date)]}),e.jsx("span",{className:"block font-serif italic text-[16px] mt-1 vk-text-secondary group-hover:text-brand-600 transition-colors",children:s.title})]}),e.jsx(ee,{className:"w-5 h-5 mt-0.5 text-brand-600 flex-shrink-0"})]}):e.jsx("span",{})})]});export{Ne as DagensDatumPage,Ne as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.