1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1989],{2530:(t,e,l)=>{l.d(e,{U:()=>a});var n=l(12115);function a(t){let[e,l]=(0,n.useState)(!1),[a,i]=(0,n.useState)(!1);return(0,n.useEffect)(()=>{let e=window.matchMedia(t),n=()=>l(e.matches);return n(),i(!0),e.addEventListener("change",n),()=>e.removeEventListener("change",n)},[t]),{matches:e,ready:a}}},81989:(t,e,l)=>{l.d(e,{i:()=>x});var n=l(95155),a=l(20063),i=l(12115),c=l(99776),s=l(28),o=l(8196),r=l(42262),u=l(52397),d=l(81818),h=l(87107),m=l(52197);function _(t){let{videoUrl:e,title:l,inboxId:n,mobile:a}=t;return"".concat(a?"/app/add-analysis":"/app/home","?youtube=").concat(encodeURIComponent(e),"&title=").concat(encodeURIComponent(l),"&watchlist_inbox=").concat(encodeURIComponent(n))}var v=l(1086),w=l(79208),b=l(2530),f=l(68111);function x(t){let{className:e="",mode:l="rail",visibility:s="any",publicOnly:x=!1,onReady:g,onFreshReady:N}=t,k=(0,a.useRouter)(),C=(0,c.jE)(),M=(0,f.k)(),E=!!((null==M?void 0:M.key)&&"unknown"!==M.key),[F,U]=(0,i.useState)([]),[Y,L]=(0,i.useState)([]),[I,R]=(0,i.useState)(5),[A,W]=(0,i.useState)(!0),[z,D]=(0,i.useState)(null),[P,q]=(0,i.useState)(null),[K,O]=(0,i.useState)(null),[V,B]=(0,i.useTransition)(),[G,H]=(0,i.useState)([]),J=(0,i.useRef)(new Map),Q=(0,i.useRef)(g),Z=(0,i.useRef)(N),{matches:X,ready:$}=(0,b.U)("mobile"===s?"(max-width: 919px)":"(min-width: 920px)"),{matches:tt,ready:te}=(0,b.U)("(max-width: 759px)"),{matches:tl,ready:tn}=(0,b.U)("(max-width: 919px)"),{matches:ta,ready:ti}=(0,b.U)("(min-width: 1440px)"),tc="any"===s||$&&X;function ts(t){var e;let n=t.video,a=(null==n?void 0:n.youtube_url)||((null==n?void 0:n.youtube_video_id)?"https://www.youtube.com/watch?v=".concat(n.youtube_video_id):"");if(!a)return;let i=_({videoUrl:a,title:(null==n?void 0:n.title)||(null==(e=t.channel)?void 0:e.title)||"YouTube video",inboxId:t.id,mobile:window.matchMedia("(max-width: 759px)").matches});(0,m.sx)("watchlist_analysis_clicked",{surface:l,watchlist_item_id:t.id,source_type:"youtube"}),O(t.id),B(()=>k.push(i))}function to(t,e){if(x)return;let l=t.watchlist_id;if(!l)return;let n=(J.current.get(l)||0)+1;J.current.set(l,n),H(t=>t.includes(l)?t:[...t,l]),q(null),U(t=>t.map(t=>t.watchlist_id===l?{...t,is_fixed:e}:t)),h.FH.updateYoutubeWatchlistChannel(l,e).then(t=>{q(null),(0,v.VN)(C),(0,w.I2)((0,w.v_)(10,(null==M?void 0:M.key)||"unknown")),J.current.get(l)===n&&U(e=>e.map(e=>e.watchlist_id===l?{...e,...t}:e))}).catch(t=>{J.current.get(l)===n&&(U(t=>t.map(t=>t.watchlist_id===l?{...t,is_fixed:!e}:t)),q(t instanceof Error?t.message:"Favorite could not be updated. Try again."))}).finally(()=>{J.current.get(l)===n&&(J.current.delete(l),H(t=>t.filter(t=>t!==l)))})}(0,i.useEffect)(()=>{V||null===K||O(null)},[K,V]),(0,i.useEffect)(()=>{Q.current=g},[g]),(0,i.useEffect)(()=>{Z.current=N},[N]),(0,i.useEffect)(()=>{let t=!1;if(!tc)return()=>{t=!0};D(null);let e=!1;return(async function(){var l,n,a,i,c,s,o;if(x||!E){let e=await (0,v.Ck)(C);if(t)return;U(e.channels.channels||[]),L(e.inbox.items||[]),R(e.slot_limit||5),D(null),W(!1),null==(a=Q.current)||a.call(Q),null==(i=Z.current)||i.call(Z);return}let r=(0,w.v_)(10,(null==M?void 0:M.key)||"unknown"),u=E?(0,w.gy)(r):null,d=u||(null==M?void 0:M.ownerType)!=="visitor"?null:C.getQueryData(v._c);if(d&&!t?(U(d.channels.channels||[]),L(d.inbox.items||[]),R(d.slot_limit||5),D(null),W(!1),e=!0,null==(c=Q.current)||c.call(Q)):u||t||(U([]),L([]),W(!0)),u&&!t&&(U(u.data.channels.channels||[]),L(u.data.inbox.items||[]),R(u.data.slot_limit||5),D(null),W(!1),e=!0,null==(s=Q.current)||s.call(Q),Date.now()-u.savedAt<v.rT)){null==(o=Z.current)||o.call(Z);return}let h=await (0,v.hq)(C,10),m=h.channels,_=h.inbox;t||(U(m.channels||[]),L(_.items||[]),R(h.slot_limit||5),D(null),W(!1),null==(l=Q.current)||l.call(Q),E&&(0,w.LC)(r,h),null==(n=Z.current)||n.call(Z))})().catch(l=>{var n,a;t||(e||D(l instanceof Error?l.message:"Watchlist could not be loaded."),null==(n=Q.current)||n.call(Q),null==(a=Z.current)||a.call(Z))}).finally(()=>{t||W(!1)}),()=>{t=!0}},[l,null==M?void 0:M.key,E,x,C,tc]),(0,i.useEffect)(()=>
1{if(!tc||!x&&!E)return;let t=!1,e=()=>{"hidden"!==document.visibilityState&&(x?(0,v.Ck)(C):(0,v.hq)(C,10)).then(e=>{!t&&(U(e.channels.channels||[]),L(e.inbox.items||[]),R(e.slot_limit||5),x||(0,w.LC)((0,w.v_)(10,(null==M?void 0:M.key)||"unknown"),e))}).catch(()=>null)},l=window.setInterval(e,18e4);return window.addEventListener("focus",e),()=>{t=!0,window.clearInterval(l),window.removeEventListener("focus",e)}},[null==M?void 0:M.key,E,x,C,tc]);let tr=(0,i.useMemo)(()=>(function(t,e,l){let n=new Map;for(let t of[...e].sort((t,e)=>{var l,n;return S((null==(l=e.video)?void 0:l.published_at)||e.created_at)-S((null==(n=t.video)?void 0:n.published_at)||t.created_at)})){let e=T(t.channel);e&&!n.has(e)&&n.set(e,t)}return t.flatMap(t=>{let e=n.get(T(t));return e?[{channel:t,item:e}]:[]}).slice(0,l)})(F,Y,I),[F,Y,I]),tu="discover"===l?ti&&ta?5:4:I,td=Math.max(0,tr.length-tu),[th,tm]=(0,i.useState)(0),t_="discover"===l&&!(tn&&tl),tv=tr.filter(t=>t.item).length,tw="home-mobile"===l,tb="discover"===l||tw,tf="home"===l||tw?"":A?"Checking recent channels":F.length?"".concat(tv," latest video").concat(1===tv?"":"s"," from recent YouTube channels"):"Analyze YouTube videos to fill recent channels";return(0,i.useEffect)(()=>{tm(t=>Math.min(t,td))},[td]),(0,n.jsxs)(o.Z,{className:"watchlist-card watchlist-card--".concat(l).concat(e?" ".concat(e):""),children:[tw?null:(0,n.jsxs)("div",{className:"watchlist-card__header",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"card-title",children:"Watchlist"}),tf?(0,n.jsx)("p",{className:"card-copy",children:tf}):null]}),"home"===l?(0,n.jsx)("a",{className:"watchlist-card__see-all",href:"/app/discover",children:"See all"}):(0,n.jsx)("div",{className:"watchlist-card__header-actions",children:F.length?(0,n.jsx)("span",{className:"watchlist-card__count",children:F.length}):null})]}),P?(0,n.jsx)("p",{className:"watchlist-card__action-error",role:"alert",children:P}):null,z?(0,n.jsx)(u.W,{title:"Watchlist unavailable",copy:z}):null,!z&&A?(0,n.jsx)(j,{slotCount:I}):null,z||A||F.length||"discover"!==l?null:(0,n.jsx)(r.p,{title:"No recent channels yet",copy:"Analyze YouTube videos and their channels will appear here."}),z||A||!(F.length>0)||tr.length?null:(0,n.jsx)(r.p,{title:"No recent videos yet",copy:"Eligible videos from your Watchlist channels will appear here."}),z||A?null:(0,n.jsxs)("div",{className:t_?"watchlist-carousel":void 0,children:[t_&&th>0?(0,n.jsx)("button",{className:"watchlist-carousel__button watchlist-carousel__button--previous",type:"button","aria-label":"Previous Watchlist cards",onClick:()=>tm(t=>Math.max(0,t-1)),children:(0,n.jsx)(d.YJ,{})}):null,(0,n.jsx)("div",{className:"watchlist-card__grid","aria-label":"Latest videos from recent YouTube channels",children:(t_?tr.slice(th,th+tu):tr).map((t,e)=>{var a,i,c,s;let o=t_?th+e:e,r=(null==(a=t.item)?void 0:a.id)||(null==(i=t.channel)?void 0:i.watchlist_id)||"empty-".concat(o),u=!!((null==(c=t.channel)?void 0:c.watchlist_id)&&G.includes(t.channel.watchlist_id));return tb?(0,n.jsx)(y,{slot:t,index:o,mobileAnalysis:te&&tt,showSourceRibbon:"discover"===l||tw,updatingFixed:u,onToggleFixed:x?void 0:to},r):(0,n.jsx)(p,{slot:t,index:o,analyzing:V&&K===(null==(s=t.item)?void 0:s.id),updatingFixed:u,onAnalyze:ts,onToggleFixed:x?void 0:to},r)})}),t_&&th<td?(0,n.jsx)("button",{className:"watchlist-carousel__button watchlist-carousel__button--next",type:"button","aria-label":"Next Watchlist cards",onClick:()=>tm(t=>Math.min(td,t+1)),children:(0,n.jsx)(d.vK,{})}):null]})]})}function p(t){let{slot:e,index:l,analyzing:a,updatingFixed:i,onAnalyze:c,onToggleFixed:s}=t,o=e.item,r=e.channel||k(o),u=null==o?void 0:o.video,d=(null==u?void 0:u.youtube_url)||((null==u?void 0:u.youtube_video_id)?"https://www.youtube.com/watch?v=".concat(u.youtube_video_id):"");return u?(0,n.jsxs)("div",{className:"watchlist-slot",children:[(0,n.jsx)("div",{className:"watchlist-slot__media",role:d?"button":void 0,tabIndex:d&&!a?0:void 0,"aria-disabled":a||void 0,onClick:()=>{d&&!a&&c(o)},onKeyDown:t=>{d&&!a&&("Enter"===t.key||" "===t.key)&&(t.preventDefault(),c(o))},children:(0,n.jsx)(g,{video:u,index:l})}),(0,n.jsxs)("div",{className:"watchlist-slot__meta",children:[d?(0,n.jsx)("a",{className:"watchlist-slot__title",href:d,target:"_blank",rel:"noreferrer",children:u.title||"Untitled YouTube video"}):(0,n.jsx)("strong",{children:u.title||"Untitled YouTube video"}),(0,n.jsx)("span",{children:(null==r?void 0:r.title)||"YouTube channel"}),(0,n.jsxs)("div",{className:"watchlist-slot__actions",children:[d?(0,n.jsx)("button",{className:"watchlist-slot__analyze",type:"button",disabled:a,onClick:()=>c(o),children:a?"Opening":"Analyse"}):null,(0,n.jsx)("span",{className:"watchlist-slot__time",children:C(u.published_at||o.created_at)})]})]}),r&&s?(0,n.jsx)(N,{channel:r,updating:i,onToggleFixed:s}):null]}):null}function y(t){let{slot:e,index:l,mobileAnalysis:a,showSourceRibbon:i=!1,updatingFixed:c,onToggleFixed:o}=t,r=e.item,u=e.channel||k(r),d=null==r?void 0:r.video;
1if(!d)return null;let h=d.youtube_url||(d.youtube_video_id?"https://www.youtube.com/watch?v=".concat(d.youtube_video_id):""),v=d.title||(null==u?void 0:u.title)||"Untitled YouTube video",w=M(d.duration_seconds),b=d.published_at||r.created_at,f=(null==u?void 0:u.title)||"YouTube channel",x=h?_({videoUrl:h,title:v,inboxId:r.id,mobile:a}):"/app/add-analysis",p=[w,b?C(b):""].filter(Boolean);return(0,n.jsxs)("div",{className:"watchlist-asset-card-wrap",children:[(0,n.jsx)(s.h,{id:r.id,className:"watchlist-asset-card watchlist-asset-card--flush-media",title:v,cardNavigation:!1,showTitleLink:!1,description:d.description||"".concat(f," latest upload"),href:x,actionLabel:"Analyse",thumbnailUrl:d.thumbnail_url||"",thumbnailLoading:0===l?"eager":"lazy",sourceType:"youtube",sourceRibbon:i?"watchlist":void 0,tags:[f],showMetadata:!1,hubPlacement:"footer",outputLabels:p,outputCount:0,onOpen:()=>(0,m.sx)("watchlist_analysis_clicked",{surface:"asset-card",watchlist_item_id:r.id,source_type:"youtube"})}),u&&o?(0,n.jsx)(N,{channel:u,updating:c,onToggleFixed:o}):null]})}function g(t){let{video:e,index:l}=t,a=M(e.duration_seconds);return(0,n.jsx)(n.Fragment,{children:(0,n.jsxs)("div",{className:"watchlist-slot__thumb",children:[e.thumbnail_url?(0,n.jsx)("img",{"data-kp-card-thumbnail":"true",src:e.thumbnail_url,alt:"Thumbnail for ".concat(e.title||"YouTube video"),width:320,height:180,sizes:"(max-width: 919px) 100vw, 320px",loading:"eager",decoding:"async",fetchPriority:0===l?"high":"auto"}):(0,n.jsx)("div",{className:"watchlist-slot__empty-thumb","aria-hidden":"true"}),a?(0,n.jsx)("span",{className:"watchlist-slot__duration","aria-label":"Video length ".concat(a),children:a}):null]})})}function j(t){let{slotCount:e=5}=t;return(0,n.jsx)("div",{className:"watchlist-card__grid","aria-hidden":"true",children:Array.from({length:e}).map((t,e)=>(0,n.jsxs)("div",{className:"watchlist-slot watchlist-slot--loading",children:[(0,n.jsx)("div",{className:"watchlist-slot__empty-thumb","aria-hidden":"true"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("strong",{children:"Loading"}),(0,n.jsx)("span",{children:"Checking channel"})]})]},e))})}function N(t){let{channel:e,updating:l,onToggleFixed:a}=t,i=!!e.is_fixed;return(0,n.jsx)("button",{className:"watchlist-slot__pin".concat(i?" watchlist-slot__pin--fixed":""),type:"button","aria-label":i?"Unfix ".concat(e.title||"channel"," in watchlist"):"Fix ".concat(e.title||"channel"," in watchlist"),"aria-pressed":i,"aria-busy":l?"true":void 0,title:i?"Fixed in watchlist":"Fix this channel in the watchlist",disabled:!e.watchlist_id,onClick:t=>{t.stopPropagation(),a(e,!i)},children:(0,n.jsx)(d.Gg,{"aria-hidden":"true",className:"watchlist-slot__pin-icon",fill:i?"currentColor":"none"})})}function k(t){if(null==t?void 0:t.channel)return{id:t.channel.id,youtube_channel_id:t.channel.youtube_channel_id||void 0,handle:t.channel.handle,title:t.channel.title,thumbnail_url:t.channel.thumbnail_url}}function T(t){return String((null==t?void 0:t.id)||(null==t?void 0:t.youtube_channel_id)||"").trim()}function S(t){if(!t)return 0;let e=Date.parse(t);return Number.isFinite(e)?e:0}function C(t){let e=S(t);if(!e)return"New";let l=Math.max(1,Math.floor((Date.now()-e)/1e3));if(l<60)return"now";let n=Math.floor(l/60);if(n<60)return"".concat(n,"m ago");let a=Math.floor(n/60);if(a<48)return"".concat(a,"h ago");let i=Math.floor(a/24);if(i<30)return"".concat(i,"d ago");let c=Math.floor(i/30);return"".concat(c,"mo ago")}function M(t){let e=Math.floor(Number(t));if(!Number.isFinite(e)||e<=0)return"";let l=Math.floor(e/3600),n=Math.floor(e%3600/60),a=e%60;return l>0?"".concat(l,":").concat(String(n).padStart(2,"0"),":").concat(String(a).padStart(2,"0")):"".concat(n,":").concat(String(a).padStart(2,"0"))}}}]);
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.