import{r as R,B as N,A as $,U as b}from"./wWjeKwgK.js";import{d as x,r as L,w as c}from"./DzEwxqd5.js";function Z(e){return(e==null?void 0:e.length)!==void 0?e:Array.from(e)}function q(e,t){$(e,1,1,()=>{t.delete(e.key)})}function J(e,t,s,i,n,o,a,u,l,y,g,p){let m=e.length,w=o.length,h=m;const T={};for(;h--;)T[e[h].key]=h;const _=[],I=new Map,A=new Map,C=[];for(h=w;h--;){const r=p(n,o,h),f=s(r);let d=a.get(f);d?C.push(()=>d.p(r,t)):(d=y(f,r),d.c()),I.set(f,_[h]=d),f in T&&A.set(f,Math.abs(h-T[f]))}const D=new Set,v=new Set;function M(r){N(r,1),r.m(u,g),a.set(r.key,r),g=r.first,w--}for(;m&&w;){const r=_[w-1],f=e[m-1],d=r.key,S=f.key;r===f?(g=r.first,m--,w--):I.has(S)?!a.has(d)||D.has(d)?M(r):v.has(S)?m--:A.get(d)>A.get(S)?(v.add(d),M(r)):(D.add(S),m--):(l(f,a),m--)}for(;m--;){const r=e[m];I.has(r.key)||l(r,a)}for(;w;)M(_[w-1]);return R(C),_}function O(e,t){if(!e||!t)return 0;const s=e.length>t.length?e:t,i=e.length>t.length?t:e;if(s.length===0)return 1;const n=G(s.toLowerCase(),i.toLowerCase());return(s.length-n)/s.length}function G(e,t){const s=[];for(let i=0;i<=t.length;i++)s[i]=[i];for(let i=0;i<=e.length;i++)s[0][i]=i;for(let i=1;i<=t.length;i++)for(let n=1;n<=e.length;n++)t.charAt(i-1)===e.charAt(n-1)?s[i][n]=s[i-1][n-1]:s[i][n]=Math.min(s[i-1][n-1]+1,s[i][n-1]+1,s[i-1][n]+1);return s[t.length][e.length]}function K(e,t){if(!Array.isArray(e)||!Array.isArray(t))return{ids:[],report:{total:0,migrated:0,failed:[],suggestions:[]}};const s=[],i={total:e.length,migrated:0,failed:[],suggestions:[]};for(const n of e){if(typeof n=="number"){s.push(n),i.migrated++;continue}if(!n||typeof n!="object")continue;let o=null,a="";if(n.name&&(o=t.find(u=>u.name===n.name),o&&(a="exact_name")),!o&&n.url&&(o=t.find(u=>u.url===n.url),o&&(a="exact_url")),!o&&n.name){let l=null,y=0;for(const g of t){if(!g.name)continue;const p=O(n.name,g.name);p>y&&p>=.65&&(y=p,l=g)}l&&(o=l,a=`fuzzy_name (${Math.round(y*100)}% similar)`)}if(!o&&n.url){const u=E(n.url);u&&(o=t.find(l=>l.url?E(l.url)===u:!1),o&&(a="domain_match"))}if(o&&o.id)s.push(o.id),i.migrated++,console.log(`✅ Migrated "${n.name}" → "${o.name}" (ID: ${o.id}) [${a}]`);else{const u={name:n.name||"Unknown",url:n.url||"Unknown",reason:"No suitable match found"};if(i.failed.push(u),n.name){const l=U(n.name,t,3);l.length>0&&i.suggestions.push({original:n.name,suggestions:l})}console.warn(`❌ Could not migrate "${n.name||n.url}"`)}}return{ids:s,report:i}}function E(e){try{return new URL(e).hostname.replace("www.","")}catch{return null}}function U(e,t,s=3){return t.filter(n=>n.name).map(n=>({name:n.name,similarity:O(e,n.name)})).filter(n=>n.similarity>.5).sort((n,o)=>o.similarity-n.similarity).slice(0,s).map(n=>n.name)}function j(e,t){return!Array.isArray(e)||!Array.isArray(t)?[]:e.map(s=>t.find(i=>i.id===s)).filter(Boolean)}function X(e){return!Array.isArray(e)||e.length===0?!1:e.some(t=>typeof t=="object"&&t!==null)}let ee=c([]),te=c([]),F=c([]),H=c([]),ne=c([]),ie=c(""),se=c({}),oe=c([]),P=c([]),re=x([P,F],([e,t])=>j(e,t)),ae=c(""),le=c(""),ce=c({}),ue=L(["Card/Board Games","Colors","Estimation","Food","Geography","History","Math/Logic","Movies/TV","Music","Science/Nature","Shapes/Patterns","Sports","Trivia","Vehicles","Video Games","Miscellaneous","Words"]),fe=L({"Card/Board Games":"hsl(0, 90%, 50%, 45%)",Colors:"hsl(24, 90%, 50%, 45%)",Estimation:"hsl(48, 90%, 50%, 45%)",Food:"hsl(72, 90%, 50%, 45%)",Geography:"hsl(96, 90%, 50%, 45%)",History:"hsl(108, 90%, 50%, 45%)","Math/Logic":"hsl(120, 90%, 50%, 45%)","Movies/TV":"hsl(144, 90%, 50%, 45%)",Music:"hsl(168, 90%, 50%, 45%)","Science/Nature":"hsl(192, 90%, 50%, 45%)","Shapes/Patterns":"hsl(216, 90%, 50%, 45%)",Sponsors:"hsl(226, 90%, 50%, 45%)",Sports:"hsl(240, 90%, 50%, 45%)",Trivia:"hsl(264, 90%, 50%, 45%)",Vehicles:"hsl(288, 90%, 50%, 45%)","Video Games":"hsl(312, 90%, 50%, 45%)",Words:"hsl(336, 90%, 50%, 45%)",Miscellaneous:"hsl(0, 0%, 49%, 45%)"});const k={DEDICATED_SECTION:"dles-of-the-week",REGULAR_SECTION:"regular-section-dle-of-week"};function de(e,t,s,i,n=null){const o={dle_name:e.name,dle_id:e.id,click_type:t,section:i},a=V(e,i,n);return a&&(o.position_id=a),o}function V(e,t,s){if(s!==null&&t==="dles-of-the-week")return`${k.DEDICATED_SECTION}-${s+1}`;if(t==="regular"){const i=W(e);if(i!==-1)return`${k.REGULAR_SECTION}-${i+1}`}return null}function W(e){return b(H).findIndex(s=>s.id===e.id)}function z(e,t,s=""){typeof window<"u"&&window.umami&&window.umami.track(e,t)}function me(){let e="test";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch{return!1}}function B(e,t=null){if(t){const s={dle_name:t.dle_name,dle_id:t.dle_id,click_type:t.click_type,section:t.section||"random"};t.position_id&&t.section&&t.section.includes("dles-of-the-week")&&(s.position_id=t.position_id),z("game-click",s)}Object.assign(document.createElement("a"),{target:"_blank",rel:"noopener",href:e}).click()}function he(e,t=null){if(e.length!=0){const s=e[Math.floor(Math.random()*e.length)],i=t||{dle_name:s.name,dle_id:s.id,click_type:"random-button",section:"random"};t&&(i.dle_name=s.name,i.dle_id=s.id),B(s.url,i)}}function ge(e){const t=new Date,s=new Date(t.toLocaleString("en-US",{timeZone:"America/New_York"}));for(const i of e)if(new Date(i.date)<s)return i;return e[e.length-1]}function we(e,t,s=!1){if(!t.trim())return e;const i=t.toLowerCase().trim().split(/\s+/);return e.filter(n=>{const o=[n.name,...s?[n.description]:[]].join(" ").toLowerCase();return i.every(a=>o.includes(a))})}export{ge as A,re as a,fe as b,ne as c,ee as d,Z as e,P as f,we as g,F as h,ae as i,me as j,B as k,ue as l,ce as m,te as n,q as o,he as p,H as q,se as r,le as s,z as t,J as u,de as v,oe as w,ie as x,X as y,K as z};
