(()=>{var e={};e.id=9984,e.ids=[9984],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 E;t.d(T,{A:()=>N});var r=t(3498),s=t.n(r),i=t(29021),a=t.n(i),n=t(33873),o=t.n(n);try{E=t(46293)}catch(e){console.warn("sql.js not installed or failed to load")}let l=null,c=null;try{l=s().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 d(){if(c)return c;if(!E)throw Error("sql.js is not available");console.log("Initializing in-memory SQLite database...");let e=new(await E()).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(a().existsSync(T)){console.log("Loading mobile_insights.sql into SQLite...");let t=a().readFileSync(T,"utf8"),E=[],r="",s=!1;for(let e=0;e<t.length;e++){let T=t[e];if("'"===T&&"\\"!==t[e-1]&&(s=!s),";"!==T||s)r+=T;else{let e=r.trim();e&&!e.startsWith("--")&&E.push(e),r=""}}let i=0;for(let T of E)if(T)try{e.run(T),i++}catch(e){T.trimStart().toUpperCase().startsWith("INSERT")||console.warn("SQL init warning:",T.substring(0,80),"|",e.message)}console.log(`Loaded ${i}/${E.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(a().existsSync(t)){var T;for(let T of a().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 N={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 d(),E=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(E)){t.run(E,T);let e=0,r=0;try{let T=t.exec("SELECT last_insert_rowid()");T.length>0&&(e=T[0].values[0][0]);let E=t.exec("SELECT changes()");E.length>0&&(r=E[0].values[0][0])}catch(e){}return[{insertId:e,affectedRows:r},void 0]}{let e=t.exec(E,T);if(0===e.length)return[[],void 0];let r=e[0].columns;return[e[0].values.map(e=>{let T={};return r.forEach((t,E)=>{T[t]=e[E]}),T}),void 0]}}}},6545:(e,T,t)=>{"use strict";t.r(T),t.d(T,{patchFetch:()=>u,routeModule:()=>l,serverHooks:()=>N,workAsyncStorage:()=>c,workUnitAsyncStorage:()=>d});var E={};t.r(E),t.d(E,{GET:()=>o});var r=t(96559),s=t(48088),i=t(37719),a=t(32190),n=t(5069);async function o(){try{let[e]=await n.A.execute(`
      SELECT b.name, b.gsmarena_url, COUNT(d.id) AS device_count
      FROM brands b
      LEFT JOIN devices d ON d.brand_id = b.id
      GROUP BY b.id, b.name, b.gsmarena_url
      ORDER BY b.name
    `);return a.NextResponse.json({brands:e})}catch{return a.NextResponse.json({error:"Database error"},{status:500})}}let l=new r.AppRouteRouteModule({definition:{kind:s.RouteKind.APP_ROUTE,page:"/api/brands/route",pathname:"/api/brands",filename:"route",bundlePath:"app/api/brands/route"},resolvedPagePath:"C:\\Users\\Taukeer19\\Desktop\\Website\\mobile-site\\mobile-insights-hub\\src\\app\\api\\brands\\route.ts",nextConfigOutput:"standalone",userland:E}),{workAsyncStorage:c,workUnitAsyncStorage:d,serverHooks:N}=l;function u(){return(0,i.patchFetch)({workAsyncStorage:c,workUnitAsyncStorage:d})}},10846:e=>{"use strict";e.exports=require("next/dist/compiled/next-server/app-page.runtime.prod.js")},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),E=T.X(0,[4447,580],()=>t(6545));module.exports=E})();