1import{j as d,u as T,r as E}from"./vendor-react-DfYGAhtm.js";import{m as x,e as m}from"./index-DsBgCU7r.js";import{a as _,T as b}from"./vendor-ui-DA_r9yXk.js";import{g as A,b as I}from"./contentfulPreview-UQGJUROZ.js";import{k,f as g}from"./vendor-state-BsBVN-fX.js";const j=({message:e="Preview mode â showing draft Contentful content. Unpublished changes are visible only when the CMS preview API is enabled."})=>d.jsx(_,{w:"100%",bg:x.navy[500],color:"white",px:{base:4,md:6},py:2,position:"sticky",top:0,zIndex:"sticky",children:d.jsx(b,{fontSize:"sm",fontWeight:"medium",textAlign:"center",children:e})}),G=()=>{const{search:e}=T();return E.useMemo(()=>A(e),[e])},p={nodeType:"document",data:{},content:[]},C=e=>e?e.startsWith("//")?`https:${e}`:e:"",f=e=>new Map((e??[]).map(t=>[t.sys.id,t])),q=(e,t)=>{const s=e?t.get(e.sys.id):void 0;return{url:C(s?.fields.file?.url),title:s?.fields.title??"",description:s?.fields.description??""}},h=(e,t)=>({id:e.sys.id,title:e.fields.title??"",emphasis:e.fields.emphasis??"",heroImage:q(e.fields.heroImage,t),createdAt:e.sys.createdAt,updatedAt:e.sys.updatedAt}),c=(e,t)=>{const s=e.data.target,i=s?.sys?.linkType==="Asset"?t.get(s.sys.id):void 0,o=i?{...e.data,target:{...s,fields:i.fields}}:e.data,r=e.content?.map(n=>c(n,t));return{...e,data:o,...r?{content:r}:{}}},O=(e,t)=>({...h(e,t),heroText:c(e.fields.heroText??p,t),paragraphs:c(e.fields.paragraphs??p,t)}),y="insuranceBlog",w="/api/v1/blog/entries",u=["dashboard","blog","posts"],R=[...u,"infinite"],S=e=>[...u,"detail",e],v=e=>{if(!e.success)throw new Error(e.message||"Blog request failed");return e.data},P=e=>I(e),B=async(e={},t=null)=>{const s=e.limit??10,i=e.skip??0,o=P(t),{data:r}=await m.get(w,{params:{content_type:y,order:"-sys.createdAt",limit:s,skip:i,...e.preview||t?.isPreview?{preview:"true"}:{},...o.params},...o.headers?{headers:o.headers}:{}}),n=v(r),a=f(n.includes?.Asset);return{total:n.total,skip:n.skip,limit:n.limit,posts:n.items.map(l=>h(l,a))}},Q=async(e,t=null)=>{const s=P(t),{data:i}=await m.get(w,{params:{content_type:y,"sys.id":e,limit:1,...t?.isPreview?{preview:"true"}:{},...s.params},...s.headers?{headers:s.headers}:{}}),o=v(i),r=o.items[0];if(!r)throw new Error("Blog post not found");return O(r,f(o.includes?.Asset))},H=(e={},t=null)=>{const s=e.limit??10,i=e.skip??0,o=!!(e.preview||t?.isPreview);return g({queryKey:[...u,{limit:s,skip:i,preview:o}],queryFn:()=>B({limit:s,skip:i,...o?{preview:!0}:{}},t),staleTime:o?0:6e4})},M=(e,t=null)=>{const s=!!t?.isPreview;return k({queryKey:[...R,e,{preview:s}],queryFn:({pageParam:i})=>B({limit:e,skip:i,...s?{preview:!0}:{}},t),initialPageParam:0,getNextPageParam:(i,o)=>{const r=o[0]?.total??0,n=o.reduce((a,l)=>a+l.posts.length,0);if(!(n>=r||i.posts.length===0))return n},staleTime:s?0:6e4})},U=(e,t=null)=>{const s=!!t?.isPreview;return g({queryKey:[...S(e??""),{preview:s}],queryFn:()=>Q(e,t),enabled:!!(e&&e.length>0),staleTime:s?0:6e4})};export{j as C,H as a,M as b,U as c,G as u};
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.