(()=>{var e={};e.id=5976,e.ids=[5976],e.modules={3295:e=>{"use strict";e.exports=require("next/dist/server/app-render/after-task-async-storage.external.js")},3498:e=>{"use strict";e.exports=require("mysql2/promise")},5069:(e,T,t)=>{"use strict";let r;t.d(T,{A:()=>p});var s=t(3498),E=t.n(s),a=t(29021),i=t.n(a),n=t(33873),o=t.n(n);try{r=t(46293)}catch(e){console.warn("sql.js not installed or failed to load")}let l=null,c=null;try{l=E().createPool({host:process.env.DB_HOST||"localhost",port:Number(process.env.DB_PORT)||3306,user:process.env.DB_USER||"root",password:process.env.DB_PASSWORD||"",database:process.env.DB_NAME||"mobile_insights",charset:"utf8mb4",waitForConnections:!0,connectionLimit:10,connectTimeout:1e3})}catch(e){console.warn("MySQL pool creation failed, using SQLite fallback:",e)}async function u(){if(c)return c;if(!r)throw Error("sql.js is not available");console.log("Initializing in-memory SQLite database...");let e=new(await r()).Database;for(let T of[`CREATE TABLE IF NOT EXISTS brands (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      name TEXT NOT NULL UNIQUE,
      gsmarena_url TEXT NOT NULL,
      device_count INTEGER DEFAULT 0,
      scraped_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    )`,`CREATE TABLE IF NOT EXISTS devices (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      brand_id INTEGER NOT NULL,
      name TEXT NOT NULL,
      gsmarena_url TEXT NOT NULL UNIQUE,
      thumbnail_url TEXT DEFAULT NULL,
      summary TEXT DEFAULT NULL,
      scraped_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    )`,`CREATE TABLE IF NOT EXISTS device_specs (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      device_id INTEGER NOT NULL UNIQUE,
      announced TEXT, status TEXT, network TEXT, os TEXT,
      chipset TEXT, cpu TEXT, gpu TEXT,
      display_size TEXT, display_type TEXT, display_res TEXT,
      ram TEXT, storage TEXT,
      main_camera TEXT, selfie_camera TEXT,
      battery TEXT, charging TEXT,
      nfc TEXT, usb TEXT, bluetooth TEXT, wlan TEXT,
      colors TEXT, weight TEXT, dimensions TEXT,
      sim TEXT, sensors TEXT, popularity TEXT,
      fans TEXT, rating TEXT, full_specs_json TEXT,
      scraped_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    )`,`CREATE TABLE IF NOT EXISTS device_pictures (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      device_id INTEGER NOT NULL,
      url TEXT NOT NULL,
      position INTEGER DEFAULT 0,
      UNIQUE(device_id, url)
    )`,`CREATE TABLE IF NOT EXISTS wishlist (
      user_id INTEGER NOT NULL,
      device_slug TEXT NOT NULL,
      PRIMARY KEY (user_id, device_slug)
    )`,`CREATE TABLE IF NOT EXISTS comparisons_log (
      slug1 TEXT NOT NULL,
      slug2 TEXT NOT NULL,
      count INTEGER DEFAULT 1,
      last_compared TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      PRIMARY KEY (slug1, slug2)
    )`,`CREATE TABLE IF NOT EXISTS users (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      name TEXT NOT NULL,
      email TEXT NOT NULL UNIQUE,
      password_hash TEXT NOT NULL,
      is_admin INTEGER DEFAULT 0,
      avatar_url TEXT,
      wishlist TEXT DEFAULT '[]',
      created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    )`,`CREATE TABLE IF NOT EXISTS seo_meta (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      page_key TEXT NOT NULL UNIQUE,
      title TEXT, description TEXT, keywords TEXT,
      og_title TEXT, og_image TEXT, canonical TEXT,
      json_ld TEXT, noindex INTEGER DEFAULT 0,
      twitter_card TEXT, twitter_title TEXT,
      twitter_description TEXT, twitter_image TEXT,
      schema_type TEXT
    )`,`CREATE TABLE IF NOT EXISTS site_settings (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      key_name TEXT NOT NULL UNIQUE,
      value TEXT
    )`,`CREATE TABLE IF NOT EXISTS news_articles (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      slug TEXT NOT NULL UNIQUE,
      title TEXT NOT NULL,
      excerpt TEXT,
      category TEXT DEFAULT 'news',
      author TEXT DEFAULT 'MobilePhoneCompare',
      thumbnail_url TEXT,
      related_device_slug TEXT,
      related_brand TEXT,
      published_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
      is_featured INTEGER DEFAULT 0,
      views INTEGER DEFAULT 0
    )`,`CREATE TABLE IF NOT EXISTS upcoming_phones (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      slug TEXT NOT NULL UNIQUE,
      name TEXT NOT NULL,
      brand TEXT NOT NULL,
      brand_color TEXT DEFAULT '#ff6e14',
      expected_price TEXT,
      launch_quarter TEXT,
      launch_date TEXT,
      status TEXT DEFAULT 'Rumored',
      thumbnail_url TEXT,
      chipset TEXT, ram TEXT, camera TEXT, battery TEXT, display TEXT,
      hype INTEGER DEFAULT 0,
      followers TEXT DEFAULT '0',
      description TEXT,
      created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
    )`])try{e.run(T)}catch(e){console.warn("CREATE TABLE warning:",e.message)}try{let T=o().join(process.cwd(),"mobile_insights.sql");if(i().existsSync(T)){console.log("Loading mobile_insights.sql into SQLite...");let t=i().readFileSync(T,"utf8"),r=[],s="",E=!1;for(let e=0;e<t.length;e++){let T=t[e];if("'"===T&&"\\"!==t[e-1]&&(E=!E),";"!==T||E)s+=T;else{let e=s.trim();e&&!e.startsWith("--")&&r.push(e),s=""}}let a=0;for(let T of r)if(T)try{e.run(T),a++}catch(e){T.trimStart().toUpperCase().startsWith("INSERT")||console.warn("SQL init warning:",T.substring(0,80),"|",e.message)}console.log(`Loaded ${a}/${r.length} statements from mobile_insights.sql`)}else console.warn("mobile_insights.sql not found — run: node scripts/csv_to_sql.mjs")}catch(e){console.error("Failed to load mobile_insights.sql:",e)}try{let t=o().join(process.cwd(),"seed.sql");if(i().existsSync(t)){var T;for(let T of i().readFileSync(t,"utf8").replace(/^\s*--.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"").replace(/START TRANSACTION;/gi,"").replace(/COMMIT;/gi,"").replace(/LOCK TABLES `[^`]+` WRITE;/gi,"").replace(/UNLOCK TABLES;/gi,"").replace(/SET SQL_MODE[\s\S]*?;/gi,"").replace(/SET time_zone[\s\S]*?;/gi,"").replace(/ALTER TABLE `[^`]+`[\s\S]*?;/gi,"").replace(/ON UPDATE current_timestamp\(\)/gi,"").replace(/DEFAULT current_timestamp\(\)/gi,"DEFAULT CURRENT_TIMESTAMP").replace(/\b(?:int|integer|tinyint|smallint|mediumint|bigint)\(\d+\)(?:\s+unsigned)?/gi,"INTEGER").replace(/\b(?:double|decimal\(\d+,\d+\))\b/gi,"REAL").replace(/\bunsigned\b/gi,"").replace(/\bdatetime\b/gi,"TIMESTAMP").replace(/\blongtext\b/gi,"TEXT").replace(/COLLATE \w+/gi,"").replace(/CHARACTER SET \w+/gi,"").replace(/DEFAULT CHARSET=\w+/gi,"").replace(/ENGINE=InnoDB\b[^;]*;?/gi,";").replace(/\\'/g,"''").replace(/\\"/g,'"').replace(/INSERT IGNORE INTO/gi,"INSERT OR IGNORE INTO").split(";"))if(T=T.trim())try{e.run(T)}catch{}}}catch(e){console.error("Failed to load seed.sql:",e)}return c=e,console.log("In-memory SQLite database initialized successfully."),c}let p={execute:async(e,T=[])=>{if(l)try{return await l.execute(e,T)}catch(e){if(!("ECONNREFUSED"===e.code||"PROTOCOL_CONNECTION_LOST"===e.code||"ETIMEDOUT"===e.code||e.message?.includes("connect")))throw e;console.warn("MySQL connection failed. Falling back to SQLite database...")}let t=await u(),r=function(e){let T=e.replace(/\bUNSIGNED\b/gi,"INTEGER");return(T=T.replace(/\bNOW\(\)/gi,"datetime('now')")).replace(/ON DUPLICATE KEY UPDATE[\s\S]*$/gi,"")}(e);if(/^\s*(INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|ALTER)/i.test(r)){t.run(r,T);let e=0,s=0;try{let T=t.exec("SELECT last_insert_rowid()");T.length>0&&(e=T[0].values[0][0]);let r=t.exec("SELECT changes()");r.length>0&&(s=r[0].values[0][0])}catch(e){}return[{insertId:e,affectedRows:s},void 0]}{let e=t.exec(r,T);if(0===e.length)return[[],void 0];let s=e[0].columns;return[e[0].values.map(e=>{let T={};return s.forEach((t,r)=>{T[t]=e[r]}),T}),void 0]}}}},10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},12964:(e,T,t)=>{"use strict";t.r(T),t.d(T,{patchFetch:()=>d,routeModule:()=>c,serverHooks:()=>N,workAsyncStorage:()=>u,workUnitAsyncStorage:()=>p});var r={};t.r(r),t.d(r,{GET:()=>o,POST:()=>l});var s=t(96559),E=t(48088),a=t(37719),i=t(32190),n=t(5069);async function o(e){let T=e.nextUrl.searchParams,t=T.get("brand")||"",r=T.get("quarter")||"",s=T.get("status")||"",E=T.get("search")||"",a=["1=1"],o=[];t&&(a.push("brand = ?"),o.push(t)),r&&(a.push("launch_quarter = ?"),o.push(r)),s&&(a.push("status = ?"),o.push(s)),E&&(a.push("(name LIKE ? OR brand LIKE ?)"),o.push(`%${E}%`,`%${E}%`));try{let[e]=await n.A.execute(`SELECT * FROM upcoming_phones WHERE ${a.join(" AND ")} ORDER BY hype DESC`,o);return i.NextResponse.json({upcoming:e})}catch(e){return console.error("upcoming error:",e),i.NextResponse.json({error:"Database error"},{status:500})}}async function l(e){try{let{slug:T,name:t,brand:r,brand_color:s,expected_price:E,launch_quarter:a,launch_date:o,status:l,thumbnail_url:c,chipset:u,ram:p,camera:N,battery:d,display:L,hype:R,followers:A,description:I}=await e.json();if(!T||!t||!r)return i.NextResponse.json({error:"slug, name, brand required"},{status:400});return await n.A.execute(`INSERT INTO upcoming_phones (slug,name,brand,brand_color,expected_price,launch_quarter,launch_date,status,thumbnail_url,chipset,ram,camera,battery,display,hype,followers,description)
       VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
       ON DUPLICATE KEY UPDATE name=VALUES(name),brand=VALUES(brand),hype=VALUES(hype),updated_at=NOW()`,[T,t,r,s||"#ff6e14",E||"TBA",a||null,o||null,l||"Rumored",c||null,u||null,p||null,N||null,d||null,L||null,R||50,A||"0",I||null]),i.NextResponse.json({ok:!0})}catch(e){return console.error("upcoming POST error:",e),i.NextResponse.json({error:"Database error"},{status:500})}}let c=new s.AppRouteRouteModule({definition:{kind:E.RouteKind.APP_ROUTE,page:"/api/upcoming/route",pathname:"/api/upcoming",filename:"route",bundlePath:"app/api/upcoming/route"},resolvedPagePath:"C:\\Users\\Taukeer19\\Desktop\\Website\\mobile-site\\mobile-insights-hub\\src\\app\\api\\upcoming\\route.ts",nextConfigOutput:"standalone",userland:r}),{workAsyncStorage:u,workUnitAsyncStorage:p,serverHooks:N}=c;function d(){return(0,a.patchFetch)({workAsyncStorage:u,workUnitAsyncStorage:p})}},29021:e=>{"use strict";e.exports=require("fs")},29294:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-async-storage.external.js")},33873:e=>{"use strict";e.exports=require("path")},44870:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-route.runtime.prod.js")},46293:e=>{"use strict";e.exports=require("sql.js")},63033:e=>{"use strict";e.exports=require("next/dist/server/app-render/work-unit-async-storage.external.js")},78335:()=>{},96487:()=>{}};var T=require("../../../webpack-runtime.js");T.C(e);var t=e=>T(T.s=e),r=T.X(0,[4447,580],()=>t(12964));module.exports=r})();