PageSourceSearch

https://verto.health/assets/NewsManager-BvnfL_fK.js

js verto.health collected 2026-09-24 17:18:34 UTC 41,721 bytes, 5 lines download raw bytes

1import{i as Qt,k as zt,x as it,r as n,m as ie,j as e,A as Gt,P as G,n as M,y as de,z as lt,D as Yt,C as Xt,o as ze,E as Zt,V as Jt,F as es,l as Ye,G as ts,H as ss,I as rs,c as ue,J as ns,w as os,B as V,s as ce,v as B}from"./index-B-WFEHhe.js";import{u as Xe}from"./useQuery-DLqvTLyX.js";import{u as be,T as as}from"./useMutation-RD4ZLgsp.js";import{I as se}from"./input-hz8GuV64.js";import{u as is,U as ls,D as cs,a as Me,b as Ze,c as Fe,d as Ie,e as Te,L as D,T as Oe,S as Re,f as ds,P as us}from"./dialog-B83Y6mdt.js";import{B as Ve}from"./badge-BtapsOTI.js";import{u as ps}from"./index-BY-LacK5.js";import{h as hs,u as ms,R as fs,F as xs}from"./Combination-DAs1HXB7.js";import{C as ct}from"./chevron-down-K-yF1ULl.js";import{C as gs}from"./check-BygIA1kT.js";import{T as Je,a as et,b as _e,c as ae,d as tt,e as re}from"./table-Di-KyDQ_.js";import{A as st,E as vs}from"./AdminLayout-BpOih_fv.js";import{u as ws}from"./usePageTitle-D6pG6Hat.js";import{L as Pe}from"./loader-circle-BBPSF0Os.js";import{S as Be}from"./sparkles-CEUrp5KU.js";import{P as js}from"./plus-Boo_PvHh.js";import{o as Ss,s as fe,b as rt}from"./types-BEgSMWDi.js";import"./verto-logo-black-DI3ZzDjh.js";import"./log-out-BcUcnzlS.js";import"./file-text-BLfbqGGw.js";import"./breadcrumb-gm4huI7l.js";function nt(r,[o,s]){return Math.min(s,Math.max(o,r))}var ys=[" ","Enter","ArrowUp","ArrowDown"],bs=[" ","Enter"],ge="Select",[Ae,De,_s]=Qt(ge),[je,jr]=zt(ge,[_s,it]),ke=it(),[Cs,pe]=je(ge),[Ns,Is]=je(ge),dt=r=>{const{__scopeSelect:o,children:s,open:l,defaultOpen:u,onOpenChange:v,value:a,defaultValue:d,onValueChange:c,dir:x,name:b,autoComplete:I,disabled:E,required:P,form:R}=r,m=ke(o),[j,N]=n.useState(null),[i,g]=n.useState(null),[_,T]=n.useState(!1),k=ps(x),[F,U]=Ye({prop:l,defaultProp:u??!1,onChange:v,caller:ge}),[Y,W]=Ye({prop:a,defaultProp:d,onChange:c,caller:ge}),X=n.useRef(null),J=j?R||!!j.closest("form"):!0,[$,H]=n.useState(new Set),ee=Array.from($).map(O=>O.props.value).join(";");return e.jsx(ts,{...m,children:e.jsxs(Cs,{required:P,scope:o,trigger:j,onTriggerChange:N,valueNode:i,onValueNodeChange:g,valueNodeHasChildren:_,onValueNodeHasChildrenChange:T,contentId:ze(),value:Y,onValueChange:W,open:F,onOpenChange:U,dir:k,triggerPointerDownPosRef:X,disabled:E,children:[e.jsx(Ae.Provider,{scope:o,children:e.jsx(Ns,{scope:r.__scopeSelect,onNativeOptionAdd:n.useCallback(O=>{H(Z=>new Set(Z).add(O))},[]),onNativeOptionRemove:n.useCallback(O=>{H(Z=>{const te=new Set(Z);return te.delete(O),te})},[]),children:s})}),J?e.jsxs(kt,{"aria-hidden":!0,required:P,tabIndex:-1,name:b,autoComplete:I,value:Y,onChange:O=>W(O.target.value),disabled:E,form:R,children:[Y===void 0?e.jsx("option",{value:""}):null,Array.from($)]},ee):null]})})};dt.displayName=ge;var ut="SelectTrigger",pt=n.forwardRef((r,o)=>{const{__scopeSelect:s,disabled:l=!1,...u}=r,v=ke(s),a=pe(ut,s),d=a.disabled||l,c=ie(o,a.onTriggerChange),x=De(s),b=n.useRef("touch"),[I,E,P]=Mt(m=>{const j=x().filter(g=>!g.disabled),N=j.find(g=>g.value===a.value),i=Ft(j,m,N);i!==void 0&&a.onValueChange(i.value)}),R=m=>{d||(a.onOpenChange(!0),P()),m&&(a.triggerPointerDownPosRef.current={x:Math.round(m.pageX),y:Math.round(m.pageY)})};return e.jsx(Gt,{asChild:!0,...v,children:e.jsx(G.button,{type:"button",role:"combobox","aria-controls":a.contentId,"aria-expanded":a.open,"aria-required":a.required,"aria-autocomplete":"none",dir:a.dir,"data-state":a.open?"open":"closed",disabled:d,"data-disabled":d?"":void 0,"data-placeholder":Lt(a.value)?"":void 0,...u,ref:c,onClick:M(u.onClick,m=>{m.currentTarget.focus(),b.current!=="mouse"&&R(m)}),onPointerDown:M(u.onPointerDown,m=>{b.current=m.pointerType;const j=m.target;j.hasPointerCapture(m.pointerId)&&j.releasePointerCapture(m.pointerId),m.button===0&&m.ctrlKey===!1&&m.pointerType==="mouse"&&(R(m),m.preventDefault())}),onKeyDown:M(u.onKeyDown,m=>{const j=I.current!=="";!(m.ctrlKey||m.altKey||m.metaKey)&&m.key.length===1&&E(m.key),!(j&&m.key===" ")&&ys.includes(m.key)&&(R(),m.preventDefault())})})})});pt.displayName=ut;var ht="SelectValue",mt=n.forwardRef((r,o)=>{const{__scopeSelect:s,className:l,style:u,children:v,placeholder:a="",...d}=r,c=pe(ht,s),{onValueNodeHasChildrenChange:x}=c,b=v!==void 0,I=ie(o,c.onValueNodeChange);return de(()=>{x(b)},[x,b]),e.jsx(G.span,{...d,ref:I,style:{pointerEvents:"none"},children:Lt(c.value)?e.jsx(e.Fragment,{children:a}):v})});mt.displayName=ht;var Ts="SelectIcon",ft=n.forwardRef((r,o)=>{const{__scopeSelect:s,children:l,...u}=r;return e.jsx(G.span,{"aria-hidden":!0,...u,ref:o,children:l||"▼"})});ft.displayName=Ts;var Rs="SelectPortal",xt=r=>e.jsx(ss,{asChild:!0,...r});xt.displayName=Rs;var ve="SelectContent",gt=n.forwardRef((r,o)=>{const s=pe(ve,r.__scopeSelect),[l,u]=n.useState();if(de(()=>{u(new DocumentFragment)},[]),!s.open){const v=l;return v?lt.createPortal(e.jsx(vt,{scope:r.__scopeSelect,children:e.jsx(Ae.Slot,{scope:r.__scopeSelect,children:e.jsx("div",{children:r.children})})}),v):null}return e.jsx(wt,{...r,ref:o})});gt.displayName=ve;var ne=10,[vt,he]=je(ve),Ps="SelectContentImpl",Es=rs("SelectContent.RemoveScroll"),wt=n.forwardRef((r,o)=>{const{__scopeSelect:s,position:l="item-aligned",onCloseAutoFocus:u,onEscapeKeyDown:v,onPointerDownOutside:a,side:d,sideOffset:c,align:x,alignOffset:b,arrowPadding:I,collisionBoundary:E,collisionPadding:P,sticky:R,hideWhenDetached:m,avoidCollisions:j,...N}=r,i=pe(ve,s),[g,_]=n.useState(null),[T,k]=n.useState(null),F=ie(o,p=>
1_(p)),[U,Y]=n.useState(null),[W,X]=n.useState(null),J=De(s),[$,H]=n.useState(!1),ee=n.useRef(!1);n.useEffect(()=>{if(g)return hs(g)},[g]),ms();const O=n.useCallback(p=>{const[w,...A]=J().map(h=>h.ref.current),[S]=A.slice(-1),y=document.activeElement;for(const h of p)if(h===y||(h==null||h.scrollIntoView({block:"nearest"}),h===w&&T&&(T.scrollTop=0),h===S&&T&&(T.scrollTop=T.scrollHeight),h==null||h.focus(),document.activeElement!==y))return},[J,T]),Z=n.useCallback(()=>O([U,g]),[O,U,g]);n.useEffect(()=>{$&&Z()},[$,Z]);const{onOpenChange:te,triggerPointerDownPosRef:oe}=i;n.useEffect(()=>{if(g){let p={x:0,y:0};const w=S=>{var y,h;p={x:Math.abs(Math.round(S.pageX)-(((y=oe.current)==null?void 0:y.x)??0)),y:Math.abs(Math.round(S.pageY)-(((h=oe.current)==null?void 0:h.y)??0))}},A=S=>{p.x<=10&&p.y<=10?S.preventDefault():g.contains(S.target)||te(!1),document.removeEventListener("pointermove",w),oe.current=null};return oe.current!==null&&(document.addEventListener("pointermove",w),document.addEventListener("pointerup",A,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",w),document.removeEventListener("pointerup",A,{capture:!0})}}},[g,te,oe]),n.useEffect(()=>{const p=()=>te(!1);return window.addEventListener("blur",p),window.addEventListener("resize",p),()=>{window.removeEventListener("blur",p),window.removeEventListener("resize",p)}},[te]);const[Se,we]=Mt(p=>{const w=J().filter(y=>!y.disabled),A=w.find(y=>y.ref.current===document.activeElement),S=Ft(w,p,A);S&&setTimeout(()=>S.ref.current.focus())}),ye=n.useCallback((p,w,A)=>{const S=!ee.current&&!A;(i.value!==void 0&&i.value===w||S)&&(Y(p),S&&(ee.current=!0))},[i.value]),me=n.useCallback(()=>g==null?void 0:g.focus(),[g]),le=n.useCallback((p,w,A)=>{const S=!ee.current&&!A;(i.value!==void 0&&i.value===w||S)&&X(p)},[i.value]),t=l==="popper"?Ue:jt,f=t===Ue?{side:d,sideOffset:c,align:x,alignOffset:b,arrowPadding:I,collisionBoundary:E,collisionPadding:P,sticky:R,hideWhenDetached:m,avoidCollisions:j}:{};return e.jsx(vt,{scope:s,content:g,viewport:T,onViewportChange:k,itemRefCallback:ye,selectedItem:U,onItemLeave:me,itemTextRefCallback:le,focusSelectedItem:Z,selectedItemText:W,position:l,isPositioned:$,searchRef:Se,children:e.jsx(fs,{as:Es,allowPinchZoom:!0,children:e.jsx(xs,{asChild:!0,trapped:i.open,onMountAutoFocus:p=>{p.preventDefault()},onUnmountAutoFocus:M(u,p=>{var w;(w=i.trigger)==null||w.focus({preventScroll:!0}),p.preventDefault()}),children:e.jsx(Yt,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:v,onPointerDownOutside:a,onFocusOutside:p=>p.preventDefault(),onDismiss:()=>i.onOpenChange(!1),children:e.jsx(t,{role:"listbox",id:i.contentId,"data-state":i.open?"open":"closed",dir:i.dir,onContextMenu:p=>p.preventDefault(),...N,...f,onPlaced:()=>H(!0),ref:F,style:{display:"flex",flexDirection:"column",outline:"none",...N.style},onKeyDown:M(N.onKeyDown,p=>{const w=p.ctrlKey||p.altKey||p.metaKey;if(p.key==="Tab"&&p.preventDefault(),!w&&p.key.length===1&&we(p.key),["ArrowUp","ArrowDown","Home","End"].includes(p.key)){let S=J().filter(y=>!y.disabled).map(y=>y.ref.current);if(["ArrowUp","End"].includes(p.key)&&(S=S.slice().reverse()),["ArrowUp","ArrowDown"].includes(p.key)){const y=p.target,h=S.indexOf(y);S=S.slice(h+1)}setTimeout(()=>O(S)),p.preventDefault()}})})})})})})});wt.displayName=Ps;var As="SelectItemAlignedPosition",jt=n.forwardRef((r,o)=>{const{__scopeSelect:s,onPlaced:l,...u}=r,v=pe(ve,s),a=he(ve,s),[d,c]=n.useState(null),[x,b]=n.useState(null),I=ie(o,F=>b(F)),E=De(s),P=n.useRef(!1),R=n.useRef(!0),{viewport:m,selectedItem:j,selectedItemText:N,focusSelectedItem:i}=a,g=n.useCallback(()=>{if(v.trigger&&v.valueNode&&d&&x&&m&&j&&N){const F=v.trigger.getBoundingClientRect(),U=x.getBoundingClientRect(),Y=v.valueNode.getBoundingClientRect(),W=N.getBoundingClientRect();if(v.dir!=="rtl"){const y=W.left-U.left,h=Y.left-y,C=F.left-h,L=F.width+C,q=Math.max(L,U.width),K=window.innerWidth-ne,Q=nt(h,[ne,Math.max(ne,K-q)]);d.style.minWidth=L+"px",d.style.left=Q+"px"}else{const y=U.right-W.right,h=window.innerWidth-Y.right-y,C=window.innerWidth-F.right-h,L=F.width+C,q=Math.max(L,U.width),K=window.innerWidth-ne,Q=nt(h,[ne,Math.max(ne,K-q)]);d.style.minWidth=L+"px",d.style.right=Q+"px"}const X=E(),J=window.innerHeight-ne*2,$=m.scrollHeight,H=window.getComputedStyle(x),ee=parseInt(H.borderTopWidth,10),O=parseInt(H.paddingTop,10),Z=parseInt(H.borderBottomWidth,10),te=parseInt(H.paddingBottom,10),oe=ee+O+$+te+Z,Se=Math.min(j.offsetHeight*5,oe),we=window.getComputedStyle(m),ye=parseInt(we.paddingTop,10),me=parseInt(we.paddingBottom,10),le=F.top+F.height/2-ne,t=J-le,f=j.offsetHeight/2,p=j.offsetTop+f,w=ee+O+p,A=oe-w;if(w<=le){const y=X.length>0&&j===X[X.length-1].ref.current;d.style.bottom="0px";const h=x.clientHeight-m.offsetTop-m.offsetHeight,C=Math.max(t,f+(y?me:0)+h+Z),L=w+C;d.style.height=L+"px"}else{const y=X.length>0&&j===X[0].ref.current;d.style.top="0px";const C=Math.max(le,ee+m.offsetTop+(y?ye:0)+f)+A;d.style.height=C+"px",m.scrollTop=w-le+m.offsetTop}d.style.margin=`${ne}px 0`,d.style.minHeight=Se+"px",d.style.maxHeight=J+"px",l==null||l(),requestAnimationFrame(()=>P.current=!0)}},[E,v.trigger,v.valueNode,d,x,m,j,N,v.dir,l]);de(()=>g(),[g]);const[_,T]=n.useState();de(()=>{x&&T(window.getComputedStyle(x).zIndex)},[x]);const k=n.useCallback(F=>{F&&R.current===!0&&(g(),i==null||i(),R.current=!1)},[g,i]);return e.jsx(ks,{scope:s,contentWrapper:d,shouldExpandOnScrollRef:P,onScrollButtonChange:k,children:e.jsx("div",{ref:c,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:_},children:e.jsx(G.div,{...u,ref:I,style:{boxSizing:"border-box",maxHeight:"100%",...u.
1style}})})})});jt.displayName=As;var Ds="SelectPopperPosition",Ue=n.forwardRef((r,o)=>{const{__scopeSelect:s,align:l="start",collisionPadding:u=ne,...v}=r,a=ke(s);return e.jsx(Xt,{...a,...v,ref:o,align:l,collisionPadding:u,style:{boxSizing:"border-box",...v.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Ue.displayName=Ds;var[ks,Ge]=je(ve,{}),He="SelectViewport",St=n.forwardRef((r,o)=>{const{__scopeSelect:s,nonce:l,...u}=r,v=he(He,s),a=Ge(He,s),d=ie(o,v.onViewportChange),c=n.useRef(0);return e.jsxs(e.Fragment,{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:l}),e.jsx(Ae.Slot,{scope:s,children:e.jsx(G.div,{"data-radix-select-viewport":"",role:"presentation",...u,ref:d,style:{position:"relative",flex:1,overflow:"hidden auto",...u.style},onScroll:M(u.onScroll,x=>{const b=x.currentTarget,{contentWrapper:I,shouldExpandOnScrollRef:E}=a;if(E!=null&&E.current&&I){const P=Math.abs(c.current-b.scrollTop);if(P>0){const R=window.innerHeight-ne*2,m=parseFloat(I.style.minHeight),j=parseFloat(I.style.height),N=Math.max(m,j);if(N<R){const i=N+P,g=Math.min(R,i),_=i-g;I.style.height=g+"px",I.style.bottom==="0px"&&(b.scrollTop=_>0?_:0,I.style.justifyContent="flex-end")}}}c.current=b.scrollTop})})})]})});St.displayName=He;var yt="SelectGroup",[Ls,Ms]=je(yt),Fs=n.forwardRef((r,o)=>{const{__scopeSelect:s,...l}=r,u=ze();return e.jsx(Ls,{scope:s,id:u,children:e.jsx(G.div,{role:"group","aria-labelledby":u,...l,ref:o})})});Fs.displayName=yt;var bt="SelectLabel",_t=n.forwardRef((r,o)=>{const{__scopeSelect:s,...l}=r,u=Ms(bt,s);return e.jsx(G.div,{id:u.id,...l,ref:o})});_t.displayName=bt;var Ee="SelectItem",[Os,Ct]=je(Ee),Nt=n.forwardRef((r,o)=>{const{__scopeSelect:s,value:l,disabled:u=!1,textValue:v,...a}=r,d=pe(Ee,s),c=he(Ee,s),x=d.value===l,[b,I]=n.useState(v??""),[E,P]=n.useState(!1),R=ie(o,i=>{var g;return(g=c.itemRefCallback)==null?void 0:g.call(c,i,l,u)}),m=ze(),j=n.useRef("touch"),N=()=>{u||(d.onValueChange(l),d.onOpenChange(!1))};if(l==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return e.jsx(Os,{scope:s,value:l,disabled:u,textId:m,isSelected:x,onItemTextChange:n.useCallback(i=>{I(g=>g||((i==null?void 0:i.textContent)??"").trim())},[]),children:e.jsx(Ae.ItemSlot,{scope:s,value:l,disabled:u,textValue:b,children:e.jsx(G.div,{role:"option","aria-labelledby":m,"data-highlighted":E?"":void 0,"aria-selected":x&&E,"data-state":x?"checked":"unchecked","aria-disabled":u||void 0,"data-disabled":u?"":void 0,tabIndex:u?void 0:-1,...a,ref:R,onFocus:M(a.onFocus,()=>P(!0)),onBlur:M(a.onBlur,()=>P(!1)),onClick:M(a.onClick,()=>{j.current!=="mouse"&&N()}),onPointerUp:M(a.onPointerUp,()=>{j.current==="mouse"&&N()}),onPointerDown:M(a.onPointerDown,i=>{j.current=i.pointerType}),onPointerMove:M(a.onPointerMove,i=>{var g;j.current=i.pointerType,u?(g=c.onItemLeave)==null||g.call(c):j.current==="mouse"&&i.currentTarget.focus({preventScroll:!0})}),onPointerLeave:M(a.onPointerLeave,i=>{var g;i.currentTarget===document.activeElement&&((g=c.onItemLeave)==null||g.call(c))}),onKeyDown:M(a.onKeyDown,i=>{var _;((_=c.searchRef)==null?void 0:_.current)!==""&&i.key===" "||(bs.includes(i.key)&&N(),i.key===" "&&i.preventDefault())})})})})});Nt.displayName=Ee;var Ce="SelectItemText",It=n.forwardRef((r,o)=>{const{__scopeSelect:s,className:l,style:u,...v}
1=r,a=pe(Ce,s),d=he(Ce,s),c=Ct(Ce,s),x=Is(Ce,s),[b,I]=n.useState(null),E=ie(o,N=>I(N),c.onItemTextChange,N=>{var i;return(i=d.itemTextRefCallback)==null?void 0:i.call(d,N,c.value,c.disabled)}),P=b==null?void 0:b.textContent,R=n.useMemo(()=>e.jsx("option",{value:c.value,disabled:c.disabled,children:P},c.value),[c.disabled,c.value,P]),{onNativeOptionAdd:m,onNativeOptionRemove:j}=x;return de(()=>(m(R),()=>j(R)),[m,j,R]),e.jsxs(e.Fragment,{children:[e.jsx(G.span,{id:c.textId,...v,ref:E}),c.isSelected&&a.valueNode&&!a.valueNodeHasChildren?lt.createPortal(v.children,a.valueNode):null]})});It.displayName=Ce;var Tt="SelectItemIndicator",Rt=n.forwardRef((r,o)=>{const{__scopeSelect:s,...l}=r;return Ct(Tt,s).isSelected?e.jsx(G.span,{"aria-hidden":!0,...l,ref:o}):null});Rt.displayName=Tt;var qe="SelectScrollUpButton",Pt=n.forwardRef((r,o)=>{const s=he(qe,r.__scopeSelect),l=Ge(qe,r.__scopeSelect),[u,v]=n.useState(!1),a=ie(o,l.onScrollButtonChange);return de(()=>{if(s.viewport&&s.isPositioned){let d=function(){const x=c.scrollTop>0;v(x)};const c=s.viewport;return d(),c.addEventListener("scroll",d),()=>c.removeEventListener("scroll",d)}},[s.viewport,s.isPositioned]),u?e.jsx(At,{...r,ref:a,onAutoScroll:()=>{const{viewport:d,selectedItem:c}=s;d&&c&&(d.scrollTop=d.scrollTop-c.offsetHeight)}}):null});Pt.displayName=qe;var Ke="SelectScrollDownButton",Et=n.forwardRef((r,o)=>{const s=he(Ke,r.__scopeSelect),l=Ge(Ke,r.__scopeSelect),[u,v]=n.useState(!1),a=ie(o,l.onScrollButtonChange);return de(()=>{if(s.viewport&&s.isPositioned){let d=function(){const x=c.scrollHeight-c.clientHeight,b=Math.ceil(c.scrollTop)<x;v(b)};const c=s.viewport;return d(),c.addEventListener("scroll",d),()=>c.removeEventListener("scroll",d)}},[s.viewport,s.isPositioned]),u?e.jsx(At,{...r,ref:a,onAutoScroll:()=>{const{viewport:d,selectedItem:c}=s;d&&c&&(d.scrollTop=d.scrollTop+c.offsetHeight)}}):null});Et.displayName=Ke;var At=n.forwardRef((r,o)=>{const{__scopeSelect:s,onAutoScroll:l,...u}=r,v=he("SelectScrollButton",s),a=n.useRef(null),d=De(s),c=n.useCallback(()=>{a.current!==null&&(window.clearInterval(a.current),a.current=null)},[]);return n.useEffect(()=>()=>c(),[c]),de(()=>{var b;const x=d().find(I=>I.ref.current===document.activeElement);(b=x==null?void 0:x.ref.current)==null||b.scrollIntoView({block:"nearest"})},[d]),e.jsx(G.div,{"aria-hidden":!0,...u,ref:o,style:{flexShrink:0,...u.style},onPointerDown:M(u.onPointerDown,()=>{a.current===null&&(a.current=window.setInterval(l,50))}),onPointerMove:M(u.onPointerMove,()=>{var x;(x=v.onItemLeave)==null||x.call(v),a.current===null&&(a.current=window.setInterval(l,50))}),onPointerLeave:M(u.onPointerLeave,()=>{c()})})}),Vs="SelectSeparator",Dt=n.forwardRef((r,o)=>{const{__scopeSelect:s,...l}=r;return e.jsx(G.div,{"aria-hidden":!0,...l,ref:o})});Dt.displayName=Vs;var We="SelectArrow",Bs=n.forwardRef((r,o)=>{const{__scopeSelect:s,...l}=r,u=ke(s),v=pe(We,s),a=he(We,s);return v.open&&a.position==="popper"?e.jsx(Zt,{...u,...l,ref:o}):null});Bs.displayName=We;var Us="SelectBubbleInput",kt=n.forwardRef(({__scopeSelect:r,value:o,...s},l)=>{const u=n.useRef(null),v=ie(l,u),a=is(o);return n.useEffect(()=>{const d=u.current;if(!d)return;const c=window.HTMLSelectElement.prototype,b=Object.getOwnPropertyDescriptor(c,"value").set;if(a!==o&&b){const I=new Event("change",{bubbles:!0});b.call(d,o),d.dispatchEvent(I)}},[a,o]),e.jsx(G.select,{...s,style:{...Jt,...s.style},ref:v,defaultValue:o})});kt.displayName=Us;function Lt(r){return r===""||r===void 0}function Mt(r){const o=es(r),s=n.useRef(""),l=n.useRef(0),u=n.useCallback(a=>{const d=s.current+a;o(d),function c(x){s.current=x,window.clearTimeout(l.current),x!==""&&(l.current=window.setTimeout(()=>c(""),1e3))}(d)},[o]),v=n.useCallback(()=>{s.current="",window.clearTimeout(l.current)},[]);return n.useEffect(()=>()=>window.clearTimeout(l.current),[]),[s,u,v]}function Ft(r,o,s){const u=o.length>1&&Array.from(o).every(x=>x===o[0])?o[0]:o,v=s?r.indexOf(s):-1;let a=Hs(r,Math.max(v,0));u.length===1&&(a=a.filter(x=>x!==s));const c=a.find(x=>x.textValue.toLowerCase().startsWith(u.toLowerCase()));return c!==s?c:void 0}function Hs(r,o){return r.map((s,l)=>r[(o+l)%r.length])}var qs=dt,Ot=pt,Ks=mt,Ws=ft,$s=xt,Vt=gt,Qs=St,Bt=_t,Ut=Nt,zs=It,Gs=Rt,Ht=Pt,qt=Et,Kt=Dt;const ot=qs,at=Ks,$e=n.forwardRef(({className:r,children:o,...s},l)=>e.jsxs(Ot,{ref:l,className:ue("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm r
1ing-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",r),...s,children:[o,e.jsx(Ws,{asChild:!0,children:e.jsx(ct,{className:"h-4 w-4 opacity-50"})})]}));$e.displayName=Ot.displayName;const Wt=n.forwardRef(({className:r,...o},s)=>e.jsx(Ht,{ref:s,className:ue("flex cursor-default items-center justify-center py-1",r),...o,children:e.jsx(ns,{className:"h-4 w-4"})}));Wt.displayName=Ht.displayName;const $t=n.forwardRef(({className:r,...o},s)=>e.jsx(qt,{ref:s,className:ue("flex cursor-default items-center justify-center py-1",r),...o,children:e.jsx(ct,{className:"h-4 w-4"})}));$t.displayName=qt.displayName;const Qe=n.forwardRef(({className:r,children:o,position:s="popper",...l},u)=>e.jsx($s,{children:e.jsxs(Vt,{ref:u,className:ue("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",r),position:s,...l,children:[e.jsx(Wt,{}),e.jsx(Qs,{className:ue("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:o}),e.jsx($t,{})]})}));Qe.displayName=Vt.displayName;const Ys=n.forwardRef(({className:r,...o},s)=>e.jsx(Bt,{ref:s,className:ue("py-1.5 pl-8 pr-2 text-sm font-semibold",r),...o}));Ys.displayName=Bt.displayName;const xe=n.forwardRef(({className:r,children:o,...s},l)=>e.jsxs(Ut,{ref:l,className:ue("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",r),...s,children:[e.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(Gs,{children:e.jsx(gs,{className:"h-4 w-4"})})}),e.jsx(zs,{children:o})]}));xe.displayName=Ut.displayName;const Xs=n.forwardRef(({className:r,...o},s)=>e.jsx(Kt,{ref:s,className:ue("-mx-1 my-1 h-px bg-muted",r),...o}));Xs.displayName=Kt.displayName;const Zs=Ss({title:fe().min(1,"Title is required"),description:fe().optional(),source:fe().min(1,"Source is required"),publish_date:fe().min(1,"Publish date is required"),external_url:fe().url("Must be a valid URL"),featured_image:fe().optional(),is_featured:rt().optional(),is_published:rt().optional(),region:fe().optional()}),Sr=()=>{ws("News Manager");const r=os(),[o,s]=n.useState(!1),[l,u]=n.useState(null),v=n.useRef(null),[a,d]=n.useState(null),[c,x]=n.useState(!1),[b,I]=n.useState([]),[E,P]=n.useState(!1),[R,m]=n.useState("input"),[j,N]=n.useState({url:"",rawContent:""}),[i,g]=n.useState({title:"",description:"",source:"LinkedIn",publish_date:"",external_url:"",featured_image:"",is_featured:!1,is_published:!1,region:"all"}),[_,T]=n.useState({title:"",description:"",source:"",publish_date:"",external_url:"",featured_image:"",is_featured:!1,is_published:!0,region:"all"}),{data:k,isLoading:F}=Xe({queryKey:["admin-news-articles"],queryFn:async()=>{const{data:t,error:f}=await ce.from("news_articles").select("*").order("publish_date",{ascending:!1});if(f)throw f;return t}}),{data:U}=Xe({queryKey:["news-sources"],queryFn:async()=>{const{data:t,error:f}=await ce.from("news_sources").select("name").order("name");if(f)throw f;return t.map(p=>p.name)}}),Y=be({mutationFn:async({url:t,rawContent:f})=>{const{data:p,error:w}=await ce.functions.invoke("parse-linkedin-news",{body:{url:t,rawContent:f}});if(w)throw w;if(p.error)throw new Error(p.error);return p},onSuccess:t=>{g({title:t.title||"",description:t.description||"",source:"LinkedIn",publish_date:t.publish_date||new Date().toISOString().split("T")[0],external_url:j.url,featured_image:"",is_featured:!1,is_published:!1,region:"all"}),m("preview"),B.success("Content parsed successfully! Review and edit below.")},onError:t=>{B.error("Failed to parse content: "+t.message)}}),W=be({mutationFn:async t=>{const{error:f}
1=await ce.from("news_articles").insert([{title:t.title,description:t.description||null,source:t.source,publish_date:t.publish_date,external_url:t.external_url,featured_image:t.featured_image||null,is_featured:t.is_featured,is_published:t.is_published,region:t.region}]);if(f)throw f},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-news-articles"]}),r.invalidateQueries({queryKey:["news-articles"]}),r.invalidateQueries({queryKey:["latest-news"]}),B.success("Article created successfully"),$(),s(!1),H()},onError:t=>{B.error("Failed to create article: "+t.message)}}),X=be({mutationFn:async({id:t,data:f})=>{const{error:p}=await ce.from("news_articles").update({title:f.title,description:f.description||null,source:f.source,publish_date:f.publish_date,external_url:f.external_url,featured_image:f.featured_image||null,is_featured:f.is_featured,is_published:f.is_published,region:f.region}).eq("id",t);if(p)throw p},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-news-articles"]}),r.invalidateQueries({queryKey:["news-articles"]}),r.invalidateQueries({queryKey:["latest-news"]}),B.success("Article updated successfully"),$(),s(!1)},onError:t=>{B.error("Failed to update article: "+t.message)}}),J=be({mutationFn:async t=>{const{error:f}=await ce.from("news_articles").delete().eq("id",t);if(f)throw f},onSuccess:()=>{r.invalidateQueries({queryKey:["admin-news-articles"]}),r.invalidateQueries({queryKey:["news-articles"]}),r.invalidateQueries({queryKey:["latest-news"]}),B.success("Article deleted successfully")},onError:t=>{B.error("Failed to delete article: "+t.message)}}),$=()=>{T({title:"",description:"",source:"",publish_date:"",external_url:"",featured_image:"",is_featured:!1,is_published:!0,region:"all"}),u(null)},H=()=>{P(!1),m("input"),N({url:"",rawContent:""}),g({title:"",description:"",source:"LinkedIn",publish_date:"",external_url:"",featured_image:"",is_featured:!1,is_published:!1,region:"all"})},ee=t=>{u(t),T({title:t.title,description:t.description||"",source:t.source,publish_date:t.publish_date,external_url:t.external_url,featured_image:t.featured_image||"",is_featured:t.is_featured||!1,is_published:t.is_published??!0,region:t.region||"all"}),s(!0)},O=t=>{t.preventDefault(),l?X.mutate({id:l.id,data:_}):W.mutate(_)},Z=()=>{if(!j.rawContent.trim()){B.error("Please paste the LinkedIn post content");return}Y.mutate(j)},te=t=>{t.preventDefault(),W.mutate(i)},oe=t=>new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}),Se=()=>{if(!k||k.length===0){B.error("No articles to export");return}const t=["title","description","source","publish_date","external_url","featured_image","is_featured","is_published","region"],f=h=>{if(h==null)return"";const C=String(h);return C.includes(",")||C.includes('"')||C.includes(`
2`)?`"${C.replace(/"/g,'""')}"`:C},p=k.map(h=>[f(h.title),f(h.description),f(h.source),f(h.publish_date),f(h.external_url),f(h.featured_image),h.is_featured?"true":"false",h.is_published?"true":"false",f(h.region)].join(",")),w=[t.join(","),...p].join(`
3`),A=new Blob([w],{type:"text/csv;charset=utf-8;"}),S=URL.createObjectURL(A),y=document.createElement("a");y.href=S,y.download=`news-articles-export-${new Date().toISOString().split("T")[0]}.csv`,y.click(),URL.revokeObjectURL(S),B.success(`Exported ${k.length} news articles`)},we=t=>{const f=t.split(`
4`),p=f[0].split(",").map(h=>h.trim().toLowerCase()),w=h=>{const C=[];let L="",q=!1;for(let K=0;K<h.length;K++){const Q=h[K];Q==='"'?q&&h[K+1]==='"'?(L+='"',K++):q=!q:Q===","&&!q?(C.push(L),L=""):L+=Q}return C.push(L),C},A=[];let S="",y=!1;for(let h=1;h<f.length;h++)S+=(S?`
5`:"")+f[h],y=(S.match(/"/g)||[]).length%2!==0,y||(S.trim()&&A.push(w(S)),S="");return A.map(h=>{const C=K=>{var Ne;const Q=p.indexOf(K);return Q>=0&&((Ne=h[Q])==null?void 0:Ne.trim())||""},L={title:C("title"),description:C("description"),source:C("source"),publish_date:C("publish_date")||new Date().toISOString().split("T")[0],external_url:C("external_url"),featured_image:C("featured_image"),is_featured:C("is_featured").toLowerCase()==="true",is_published:C("is_published").toLowerCase()!=="false",region:C("region")||"all"},q=Zs.safeParse(L);return q.success||(L.validationError=q.error.errors[0].message),L})},ye=async t=>{var w;const f=(w=t.target.files)==null?void 0:w[0];if(!f)return;if(!f.name.endsWith(".csv")){B.error("Please select a CSV file");return}const p=new FileReader;p.onload=async A=>{var S;try{const y=(S=A.target)==null?void 0:S.result,h=we(y);if(h.length===0){B.error("No valid articles found in CSV");return}const C=h.map(z=>z.external_url),L=C.filter((z,Le)=>z&&C.indexOf(z)!==Le),q=C.filter(z=>z);let K=[];if(q.length>0){const{data:z}=await ce.from("news_articles").select("external_url").in("external_url",q);K=(z==null?void 0:z.map(Le=>Le.external_url))||[]}const Q=[...new Set([...L,...K])];I(Q);const Ne=h.map(z=>
5({...z,isDuplicate:Q.includes(z.external_url)}));d(Ne),x(!0)}catch(y){B.error("Failed to parse CSV file"),console.error(y)}},p.readAsText(f),t.target.value=""},me=be({mutationFn:async t=>{const f=t.map(w=>({title:w.title,description:w.description||null,source:w.source,publish_date:w.publish_date,external_url:w.external_url,featured_image:w.featured_image||null,is_featured:w.is_featured,is_published:w.is_published,region:w.region||"all"})),{error:p}=await ce.from("news_articles").insert(f);if(p)throw p;return t.length},onSuccess:t=>{r.invalidateQueries({queryKey:["admin-news-articles"]}),r.invalidateQueries({queryKey:["news-articles"]}),r.invalidateQueries({queryKey:["latest-news"]}),B.success(`Successfully imported ${t} news articles`),d(null),x(!1)},onError:t=>{B.error(`Import failed: ${t.message}`)}}),le=(a==null?void 0:a.filter(t=>!t.isDuplicate&&!t.validationError).length)||0;return F?e.jsx(st,{title:"News Manager",breadcrumbs:[{label:"News Articles"}],children:e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Pe,{className:"h-8 w-8 animate-spin text-primary"})})}):e.jsxs(st,{title:"News Manager",breadcrumbs:[{label:"News Articles"}],children:[e.jsxs("div",{className:"flex justify-end gap-2 mb-6",children:[e.jsx("input",{type:"file",ref:v,onChange:ye,accept:".csv",className:"hidden"}),e.jsxs(V,{variant:"outline",onClick:()=>{var t;return(t=v.current)==null?void 0:t.click()},className:"gap-2",children:[e.jsx(ls,{className:"h-4 w-4"}),"Import CSV"]}),e.jsxs(V,{variant:"outline",onClick:Se,disabled:!(k!=null&&k.length),className:"gap-2",children:[e.jsx(cs,{className:"h-4 w-4"}),"Export CSV"]}),e.jsxs(Me,{open:E,onOpenChange:t=>{t?P(!0):H()},children:[e.jsx(Ze,{asChild:!0,children:e.jsxs(V,{variant:"outline",children:[e.jsx(Be,{className:"w-4 h-4 mr-2"}),"AI Import"]})}),e.jsx(Fe,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:R==="input"?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{children:e.jsxs(Te,{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-5 w-5 text-primary"}),"AI News Importer"]})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Paste a LinkedIn post URL and its content. AI will extract the title, description, and publish date."}),e.jsxs("div",{children:[e.jsx(D,{htmlFor:"ai-url",children:"LinkedIn Post URL"}),e.jsx(se,{id:"ai-url",type:"url",placeholder:"https://www.linkedin.com/posts/...",value:j.url,onChange:t=>N({...j,url:t.target.value})})]}),e.jsxs("div",{children:[e.jsx(D,{htmlFor:"ai-content",children:"Post Content *"}),e.jsx(Oe,{id:"ai-content",placeholder:"Paste the LinkedIn post content here (including emojis, hashtags, mentions, etc.)...",value:j.rawContent,onChange:t=>N({...j,rawContent:t.target.value}),rows:12,className:"font-mono text-sm"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:'Copy the entire post text including dates like "2 weeks ago"'})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(V,{variant:"outline",onClick:H,children:"Cancel"}),e.jsx(V,{onClick:Z,disabled:Y.isPending||!j.rawContent.trim(),children:Y.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:"w-4 h-4 mr-2 animate-spin"}),"Parsing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"w-4 h-4 mr-2"}),"Parse with AI"]})})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{children:e.jsx(Te,{children:"Review & Edit Parsed Content"})}),e.jsxs("form",{onSubmit:te,className:"space-y-4 pt-2",children:[e.jsx("div",{className:"bg-muted/50 rounded-lg p-3 text-sm",children:e.jsx("p",{className:"text-muted-foreground",children:"Review the AI-extracted content below. Edit as needed before saving."})}),e.jsxs("div",{children:[e.jsx(D,{htmlFor:"ai-title",children:"Title *"}),e.jsx(se,{id:"ai-title",value:i.title,onChange:t=>g({...i,title:t.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(D,{htmlFor:"ai-description",children:"Description"}),e.jsx(Oe,{id:"ai-description",value:i.description,onChange:t=>g({...i,description:t.target.value}),rows:4})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(D,{htmlFor:"ai-source",children:"Source"}
5),e.jsx(se,{id:"ai-source",value:i.source,onChange:t=>g({...i,source:t.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(D,{htmlFor:"ai-publish_date",children:"Publish Date *"}),e.jsx(se,{id:"ai-publish_date",type:"date",value:i.publish_date,onChange:t=>g({...i,publish_date:t.target.value}),required:!0})]})]}),e.jsxs("div",{children:[e.jsx(D,{htmlFor:"ai-external_url",children:"External URL *"}),e.jsx(se,{id:"ai-external_url",type:"url",value:i.external_url,onChange:t=>g({...i,external_url:t.target.value}),required:!0,placeholder:"https://..."})]}),e.jsxs("div",{children:[e.jsx(D,{htmlFor:"ai-featured_image",children:"Featured Image URL"}),e.jsx(se,{id:"ai-featured_image",type:"url",value:i.featured_image,onChange:t=>g({...i,featured_image:t.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{children:[e.jsx(D,{htmlFor:"ai-region",children:"Region"}),e.jsxs(ot,{value:i.region,onValueChange:t=>g({...i,region:t}),children:[e.jsx($e,{children:e.jsx(at,{})}),e.jsxs(Qe,{children:[e.jsx(xe,{value:"all",children:"All Regions"}),e.jsx(xe,{value:"canada",children:"Canada"}),e.jsx(xe,{value:"us",children:"United States"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-8",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{id:"ai-is_featured",checked:i.is_featured,onCheckedChange:t=>g({...i,is_featured:t})}),e.jsx(D,{htmlFor:"ai-is_featured",children:"Featured"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{id:"ai-is_published",checked:i.is_published,onCheckedChange:t=>g({...i,is_published:t})}),e.jsx(D,{htmlFor:"ai-is_published",children:"Published"})]})]}),e.jsxs("div",{className:"flex justify-between pt-4",children:[e.jsx(V,{type:"button",variant:"ghost",onClick:()=>m("input"),children:"Back"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(V,{type:"button",variant:"outline",onClick:H,children:"Cancel"}),e.jsx(V,{type:"submit",disabled:W.isPending,children:W.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Pe,{className:"w-4 h-4 mr-2 animate-spin"}),"Saving..."]}):"Create Article"})]})]})]})]})})]}),e.jsxs(Me,{open:o,onOpenChange:t=>{s(t),t||$()},children:[e.jsx(Ze,{asChild:!0,children:e.jsxs(V,{children:[e.jsx(js,{className:"w-4 h-4 mr-2"}),"Add Article"]})}),e.jsxs(Fe,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ie,{children:e.jsx(Te,{children:l?"Edit Article":"Add New Article"})}),e.jsxs("form",{onSubmit:O,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(D,{htmlFor:"title",children:"Title *"}),e.jsx(se,{id:"title",value:_.title,onChange:t=>T({..._,title:t.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(D,{htmlFor:"description",children:"Description"}),e.jsx(Oe,{id:"description",value:_.description,onChange:t=>T({..._,description:t.target.value}),rows:3})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(D,{htmlFor:"source",children:"Source *"}),e.jsx(se,{id:"source",value:_.source,onChange:t=>T({..._,source:t.target.value}),required:!0,list:"sources-list"}),e.jsx("datalist",{id:"sources-list",children:U==null?void 0:U.map(t=>e.jsx("option",{value:t},t))})]}),e.jsxs("div",{children:[e.jsx(D,{htmlFor:"publish_date",children:"Publish Date *"}),e.jsx(se,{id:"publish_date",type:"date",value:_.publish_date,onChange:t=>T({..._,publish_date:t.target.value}),required:!0})]})]}),e.jsxs("div",{children:[e.jsx(D,{htmlFor:"external_url",children:"External URL *"}),e.jsx(se,{id:"external_url",type:"url",value:_.external_url,onChange:t=>T({..._,external_url:t.target.value}),required:!0,placeholder:"https://..."})]}),e.jsxs("div",{children:[e.jsx(D,{htmlFor:"featured_image",children:"Featured Image URL"}),e.jsx(se,{id:"featured_image",type:"url",value:_.featured_image,onChange:t=>T({..._,featured_image:t.target.value}),placeholder:"https://..."})]}),e.jsxs("div",{children:[e.jsx(D,{htmlFor:"region",children:"Region"}),e.jsxs(ot,{value:_.region,onValueChange:t=>T({..._,region:t}),children:[e.jsx($e,{children:e.jsx(at,{})}),e.jsxs(Qe,{children:[e.jsx(xe,{value:"all",children:"All Regions"}),e.jsx(xe,{value:"canada",children:"Canada"}),e.jsx(xe,{value:"us",children:"United States"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-8",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{id:"is_featured",checked:_.is_featured,onCheckedChange:t=>T({..._,is_featured:t})}),e.jsx(D,{htmlFor:"is_featured",children:"Featured"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Re,{id:"is_published",checked:_.is_published,onCheckedChange:t=>T({..._,is_published:t})}),e.jsx(D,{htmlFor:"is_published",children:"Published"})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(V,{type:"button",variant:"outline",onClick:()=>{s(!1),$()},children:"Cancel"}
5),e.jsx(V,{type:"submit",disabled:W.isPending||X.isPending,children:l?"Update":"Create"})]})]})]})]})]}),e.jsx(Me,{open:c,onOpenChange:x,children:e.jsxs(Fe,{className:"max-w-3xl",children:[e.jsx(Ie,{children:e.jsxs(Te,{children:["Import ",a==null?void 0:a.length," News Articles"]})}),b.length>0&&e.jsxs("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-4 flex items-start gap-3",children:[e.jsx(ds,{className:"h-5 w-5 text-amber-600 dark:text-amber-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-amber-800 dark:text-amber-200",children:[b.length," duplicate URL(s) detected"]}),e.jsx("p",{className:"text-sm text-amber-700 dark:text-amber-300",children:"Articles with duplicate URLs (highlighted below) will be skipped during import."})]})]}),e.jsx("div",{className:"max-h-[400px] overflow-y-auto",children:e.jsxs(Je,{children:[e.jsx(et,{children:e.jsxs(_e,{children:[e.jsx(ae,{children:"Title"}),e.jsx(ae,{children:"Source"}),e.jsx(ae,{children:"Date"}),e.jsx(ae,{children:"Status"})]})}),e.jsx(tt,{children:a==null?void 0:a.map((t,f)=>e.jsxs(_e,{className:t.isDuplicate||t.validationError?"bg-amber-50 dark:bg-amber-950/20":"",children:[e.jsx(re,{className:"font-medium max-w-xs truncate",children:t.title||"(No title)"}),e.jsx(re,{children:t.source||"(No source)"}),e.jsx(re,{children:t.publish_date}),e.jsx(re,{children:t.validationError?e.jsx(Ve,{variant:"destructive",className:"text-xs",children:t.validationError}):t.isDuplicate?e.jsx(Ve,{variant:"outline",className:"text-amber-600 dark:text-amber-400 border-amber-300 dark:border-amber-700",children:"Duplicate"}):e.jsx(Ve,{variant:"secondary",children:"Ready"})})]},f))})]})}),e.jsxs("div",{className:"flex justify-end gap-3 mt-4",children:[e.jsx(V,{variant:"outline",onClick:()=>x(!1),children:"Cancel"}),e.jsxs(V,{onClick:()=>{const t=(a==null?void 0:a.filter(f=>!f.isDuplicate&&!f.validationError))||[];t.length>0&&me.mutate(t)},disabled:me.isPending||le===0,children:[me.isPending&&e.jsx(Pe,{className:"h-4 w-4 animate-spin mr-2"}),"Import ",le," Articles"]})]})]})}),e.jsx("div",{className:"bg-card rounded-lg border",children:e.jsxs(Je,{children:[e.jsx(et,{children:e.jsxs(_e,{children:[e.jsx(ae,{children:"Title"}),e.jsx(ae,{children:"Source"}),e.jsx(ae,{children:"Date"}),e.jsx(ae,{children:"Region"}),e.jsx(ae,{children:"Status"}),e.jsx(ae,{className:"text-right",children:"Actions"})]})}),e.jsxs(tt,{children:[k==null?void 0:k.map(t=>e.jsxs(_e,{children:[e.jsx(re,{className:"font-medium max-w-xs truncate",children:e.jsxs("div",{className:"flex items-center gap-2",children:[t.is_featured&&e.jsx("span",{className:"text-xs bg-primary/10 text-primary px-2 py-0.5 rounded",children:"Featured"}),t.title]})}),e.jsx(re,{children:t.source}),e.jsx(re,{children:oe(t.publish_date)}),e.jsx(re,{className:"capitalize",children:t.region||"all"}),e.jsx(re,{children:e.jsx("span",{className:`text-xs px-2 py-1 rounded ${t.is_published?"bg-green-500/10 text-green-600":"bg-yellow-500/10 text-yellow-600"}`,children:t.is_published?"Published":"Draft"})}),e.jsx(re,{className:"text-right",children:e.jsxs("div",{className:"flex justify-end gap-2",children:[t.external_url&&t.external_url!=="#"&&e.jsx(V,{variant:"ghost",size:"icon",onClick:()=>window.open(t.external_url,"_blank"),children:e.jsx(vs,{className:"w-4 h-4"})}),e.jsx(V,{variant:"ghost",size:"icon",onClick:()=>ee(t),children:e.jsx(us,{className:"w-4 h-4"})}),e.jsx(V,{variant:"ghost",size:"icon",onClick:()=>{confirm("Are you sure you want to delete this article?")&&J.mutate(t.id)},children:e.jsx(as,{className:"w-4 h-4"})})]})})]},t.id)),(k==null?void 0:k.length)===0&&e.jsx(_e,{children:e.jsx(re,{colSpan:6,className:"text-center py-12 text-muted-foreground",children:"No news articles yet. Add your first article!"})})]})]})})]})};export{Sr 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.