1import{n as h,f as b,g as v}from"./OperationQueueKzEpmh-u.js";import{i as I,d as N,a as U}from"./appUsageDisplayBY7OQki1.js";const S={"redd.it":"reddit.com","youtu.be":"youtube.com","youtube-nocookie.com":"youtube.com"};function l(n){if(!n)return null;try{return new URL(n)}catch{try{return new URL(`https://${n}`)}catch{return null}}}function $(n){var e;return((e=l(n))==null?void 0:e.hostname.toLowerCase())||null}function z(n){return/^\d{1,3}(\.\d{1,3}){3}$/.test(n)?!0:n.includes(":")}function L(n){const e=String(n||"").trim().toLowerCase();if(!e)return null;if(e==="localhost"||z(e))return e;const t=e.split(".").filter(Boolean);return t.length<=2?e:t.slice(-2).join(".")}function s(n){return String(n||"").replace(/^www\./,"")}function C(n){const e=s(n).trim().toLowerCase();return e?S[e]||e:null}function w(n){const e=String(n||"").trim();return!e||e==="/"?"":e.replace(/\/+$/,"")}function A(n){var e;return((e=l(n))==null?void 0:e.toString())||null}function D(n){return`https://${n}`}function k(n){return{id:`domain:${n}`,label:n,shortLabel:null,entityType:"domain",resolverSource:"domain",visitUrl:D(n)}}function T(n,e,t){const r=l(n==null?void 0:n.url),i=s(e),o=w(r==null?void 0:r.pathname),u=i?o?`${i}${o}`:i:t;return{id:`activity:${u}`,label:u,shortLabel:null,entityType:"activity",resolverSource:"url",visitUrl:(r==null?void 0:r.toString())||null}}function H(n){var r;const e=((r=n==null?void 0:n.contentInfo)==null?void 0:r.meta)||{},t=[e==null?void 0:e.handleId,e==null?void 0:e.channelId,...Array.isArray(e==null?void 0:e.youtubeChannelIds)?e.youtubeChannelIds:[],...v((n==null?void 0:n.url)||"")];for(const i of t){const o=h(i);if(o)return o}return null}function y(n,e){var i;const t=((i=n==null?void 0:n.contentInfo)==null?void 0:i.meta)||{},r=typeof(t==null?void 0:t.handleId)=="string"?t.handleId.trim():"";if(r){const o=r.replace(/^@+/,"");return o?`youtube.com/${o}`:"youtube.com"}return e.startsWith("UC")?`youtube.com/channel/${e}`:`youtube.com/${e.replace(/^@+/,"")}`}function P(n,e){return`https://${y(n,e)}`}function V(n){var m;const e=typeof(n==null?void 0:n.url)=="string"?n.url:"";if(I(n)){const p={id:`app:${N(n)||"app"}`,label:U(n),shortLabel:null,entityType:"site",resolverSource:"url",visitUrl:null};return{topNode:p,activityNode:p,channelNode:null,sampleUrl:e||null}}const t=$(e),r=L(t),i=typeof((m=n==null?void 0:n.contentInfo)==null?void 0:m.title)=="string"?n.contentInfo.title.trim():"",o=s(t),u=s(r),a=C(u||o);if(a){const c=a==="youtube.com"?H(n):null;return{topNode:k(a),activityNode:T(n,o||a,a),channelNode:c?{id:`channel:${c}`,label:y(n,c),shortLabel:null,entityType:"creator",resolverSource:"log-channel",visitUrl:P(n,c)}:null,sampleUrl:e||null}}const d=o||i||"Unknown site",f={id:`site:${d}`,label:d,shortLabel:null,entityType:"site",resolverSource:"url",visitUrl:A(e)};return{topNode:f,activityNode:f,channelNode:null,sampleUrl:e||null}}function B(n){var r;const e=V(n),t=new Set([e.topNode.id,e.activityNode.id]);for(const i of b(((r=n==null?void 0:n.contentInfo)==null?void 0:r.meta)||null,(n==null?void 0:n.url)||null))t.add(`channel:${i}`);return Array.from(t)}function W(n,e){const t=String(e||"").trim();if(!t)return!1;const r=B(n);if(r.includes(t))return!0;if(t.startsWith("channel:")){const i=h(t.slice(8));return i?r.includes(`channel:${i}`):!1}return!1}export{W as l,A as n,V as r};
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.