(function () { var NUA_COLLECTOR = { api: "https://nua-collector-codes.casanua.workers.dev", appStoreId: "" }; var APPKIT = "https://cdn.jsdelivr.net/npm/\x40reown/appkit-cdn\x401.8.24/dist/appkit.js"; var T = { en: { title: "Collector Edition", how: "Connect a wallet linked to your 6529 consolidation and sign one verification message. No transaction is sent.", rule: "Casa NUA community members can try the Collector Edition for 3 months, and nothing is charged when they end. You can request a new one every three months.", nextOn: "Your next code opens on {d}.", tooSoon: "This wallet, or one linked to it, received a code on {d}. The next one opens on {d2}.", connect: "Connect wallet", free: "A signature only — never a transaction, never a cost.", choosing: "Choose your wallet…", signing: "Sign the message in your wallet.", checking: "Checking the chain…", yourCode: "Your Collector code", copy: "Copy", copied: "Copied", open: "Open in the App Store", redeemHow: "To redeem it: App Store → your picture → Redeem Gift Card or Code.", notHolder: "This wallet, with the wallets linked to it, holds none of the Casa NUA Memes.", empty: "There are no codes available right now. Please come back soon.", unread: "We could not read the chain just now. Please try again in a minute.", contract: "This wallet cannot sign here. Sign with the wallet that is a Casa NUA holder, or a wallet it has consolidated with on 6529.", badSig: "That signature did not check out. Please try again.", cancelled: "Signing was cancelled.", noWallet: "No wallet could be opened on this page.", another: "Use another wallet", retry: "Try again", back: "Back" }, pt: { title: "Collector Edition", how: "Conecte uma carteira ligada à sua consolidação no 6529 e assine uma mensagem de verificação. Nenhuma transação é enviada.", rule: "Membros da comunidade Casa NUA podem experimentar a Collector Edition por 3 meses, e nada é cobrado quando eles terminam. Você pode pedir um novo código a cada três meses.", nextOn: "Seu próximo código abre em {d}.", tooSoon: "Esta carteira, ou uma ligada a ela, recebeu um código em {d}. O próximo abre em {d2}.", connect: "Conectar carteira", free: "Só uma assinatura — nunca uma transação, nunca um custo.", choosing: "Escolha sua carteira…", signing: "Assine a mensagem na sua carteira.", checking: "Consultando a blockchain…", yourCode: "Seu código Collector", copy: "Copiar", copied: "Copiado", open: "Abrir na App Store", redeemHow: "Para resgatar: App Store → sua foto → Resgatar Cartão-Presente ou Código.", notHolder: "Esta carteira, com as carteiras ligadas a ela, não tem nenhum dos Memes da Casa NUA.", empty: "Não há códigos disponíveis agora. Volte em breve.", unread: "Não conseguimos consultar a blockchain agora. Tente de novo em um minuto.", contract: "Esta carteira não consegue assinar aqui. Assine com a carteira que é membro da Casa NUA, ou com uma carteira consolidada com ela no 6529.", badSig: "A assinatura não confere. Tente de novo.", cancelled: "A assinatura foi cancelada.", noWallet: "Nenhuma carteira pôde ser aberta nesta página.", another: "Usar outra carteira", retry: "Tentar de novo", back: "Voltar" }, es: { title: "Collector Edition", how: "Conecta una billetera vinculada a tu consolidación en 6529 y firma un mensaje de verificación. No se envía ninguna transacción.", rule: "Los miembros de la comunidad Casa NUA pueden probar la Collector Edition durante 3 meses, y no se cobra nada cuando terminan. Puedes pedir uno nuevo cada tres meses.", nextOn: "Tu próximo código se abre el {d}.", tooSoon: "Esta billetera, o una vinculada a ella, recibió un código el {d}. El próximo se abre el {d2}.", connect: "Conectar billetera", free: "Solo una firma — nunca una transacción, nunca un costo.", choosing: "Elige tu billetera…", signing: "Firma el mensaje en tu billetera.", checking: "Consultando la cadena…", yourCode: "Tu código Collector", copy: "Copiar", copied: "Copiado", open: "Abrir en la App Store", redeemHow: "Para canjearlo: App Store → tu foto → Canjear tarjeta regalo o código.", notHolder: "Esta billetera, con las billeteras vinculadas a ella, no tiene ninguno de los Memes de Casa NUA.", empty: "No hay códigos disponibles ahora. Vuelve pronto.", unread: "No pudimos consultar la cadena ahora. Inténtalo de nuevo en un minuto.", contract: "Esta billetera no puede firmar aquí. Firma con la billetera que es miembro de Casa NUA, o con una billetera consolidada con ella en 6529.", badSig: "La firma no es válida. Inténtalo de nuevo.", cancelled: "La firma fue cancelada.", noWallet: "No se pudo abrir ninguna billetera en esta página.", another: "Usar otra billetera", retry: "Reintentar", back: "Volver" }, fr: { title: "Collector Edition", how: "Connectez un portefeuille lié à votre consolidation 6529 et signez un message de vérification. Aucune transaction n’est envoyée.", rule: "Les membres de la communauté Casa NUA peuvent essayer la Collector Edition pendant 3 mois, et rien n’est facturé à leur fin. Vous pouvez en demander un nouveau tous les trois mois.", nextOn: "Votre prochain code s’ouvre le {d}.", tooSoon: "Ce portefeuille, ou un portefeuille lié, a reçu un code le {d}. Le prochain s’ouvre le {d2}.", connect: "Connecter le portefeuille", free: "Une simple signature — jamais une transaction, jamais un coût.", choosing: "Choisissez votre portefeuille…", signing: "Signez le message dans votre portefeuille.", checking: "Lecture de la blockchain…", yourCode: "Votre code Collector", copy: "Copier", copied: "Copié", open: "Ouvrir dans l’App Store", redeemHow: "Pour l’utiliser : App Store → votre photo → Utiliser une carte cadeau ou un code.", notHolder: "Ce portefeuille, avec les portefeuilles qui lui sont liés, ne détient aucun des Memes Casa NUA.", empty: "Aucun code n’est disponible pour le moment. Revenez bientôt.", unread: "Impossible de lire la blockchain pour le moment. Réessayez dans une minute.", contract: "Ce portefeuille ne peut pas signer ici. Signez avec le portefeuille membre de Casa NUA, ou un portefeuille consolidé avec lui sur 6529.", badSig: "Cette signature n’est pas valide. Réessayez.", cancelled: "La signature a été annulée.", noWallet: "Aucun portefeuille n’a pu être ouvert sur cette page.", another: "Utiliser un autre portefeuille", retry: "Réessayer", back: "Retour" } }; var lang = String((navigator.languages && navigator.languages[0]) || navigator.language || "en").slice(0, 2).toLowerCase(); if (!T[lang]) lang = "en"; var t = T[lang]; var el = document.getElementById("nua-meme"); el.setAttribute("lang", lang); var day = function (ms) { try { return new Date(ms).toLocaleDateString(lang, { day: "numeric", month: "long", year: "numeric", timeZone: "UTC" }); } catch (e) { return new Date(ms).toISOString().slice(0, 10); } }; var fill = function (s, a, b) { return s.replace("{d}", a == null ? "" : day(a)).replace("{d2}", b == null ? "" : day(b)); }; var esc = function (s) { return String(s).replace(/[&\x3c>"]/g, function (c) { return { "\x26": "\x26amp;", "\x3c": "\x26lt;", ">": "\x26gt;", '"': "\x26quot;" }[c]; }); }; var api = function (path, body) { return fetch(NUA_COLLECTOR.api + path, body ? { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) } : {}) .then(function (r) { return r.json(); }); }; var available = true, busy = false, kit = null, account = null, choosing = false; function head() { return "\x3ch2>" + esc(t.title) + "\x3c/h2>" + (t.sub ? '\x3cp class="nua-sub">' + esc(t.sub) + "\x3c/p>" : ""); } function btn(label, act, small) { return '\x3cbutton class="nua-primary" data-act="' + act + '">' + esc(label) + (small ? "\x3csmall>" + esc(small) + "\x3c/small>" : "") + "\x3c/button>"; } function secondary(label, act) { return '\x3cbutton class="nua-secondary" data-act="' + act + '">' + esc(label) + "\x3c/button>"; } function intro(note) { el.innerHTML = head() + '\x3cp class="nua-sub">' + esc(t.how) + "\x3c/p>" + '\x3cp class="nua-rule">' + esc(t.rule) + "\x3c/p>" + btn(t.connect, "connect", t.free) + (note ? '\x3cp class="nua-note">' + esc(note) + "\x3c/p>" : (!available ? '\x3cp class="nua-note">' + esc(t.empty) + "\x3c/p>" : "")) + (t.keeps ? '\x3cp class="nua-note">' + esc(t.keeps) + "\x3c/p>" : ""); } function working(line) { el.innerHTML = head() + '\x3cdiv class="nua-msg">' + esc(line) + "\x3c/div>" + '\x3cbutton class="nua-primary" disabled>' + esc(t.connect) + "\x3c/button>"; } function message(line, withAnother, withRetry) { el.innerHTML = head() + '\x3cdiv class="nua-msg">' + esc(line) + "\x3c/div>" + (withRetry ? secondary(t.retry, "connect") : "") + (withAnother ? secondary(t.another, "another") : "") + secondary(t.back, "back"); } function showCode(r) { var id = String(NUA_COLLECTOR.appStoreId || "").trim(); var url = id ? "https://apps.apple.com/redeem?ctx=offercodes\x26id=" + encodeURIComponent(id) + "\x26code=" + encodeURIComponent(r.code) : ""; el.innerHTML = head() + '\x3cdiv class="nua-label">' + esc(t.yourCode) + "\x3c/div>" + '\x3cdiv class="nua-code">' + esc(r.code) + "\x3c/div>" + (url ? '\x3ca class="nua-primary" href="' + esc(url) + '" rel="noopener">' + esc(t.open) + "\x3c/a>" : "") + secondary(t.copy, "copy") + '\x3cp class="nua-note">' + esc(t.redeemHow) + "\x3c/p>" + (r.nextAt ? '\x3cp class="nua-note">' + esc(fill(t.nextOn, r.nextAt)) + "\x3c/p>" : ""); el.setAttribute("data-code", r.code); } function result(r) { busy = false; if (!r || !r.state) return message(t.unread, false, true); if (r.state === "code") return showCode(r); if (r.state === "too_soon") return message(fill(t.tooSoon, r.claimedAt, r.nextAt), true); if (r.state === "not_holder") return message(t.notHolder, true); if (r.state === "empty") return message(t.empty, false); if (r.state === "bad_signature") return message(r.why === "contract" ? t.contract : t.badSig, true); return message(t.unread, false, true); } function toHex(s) { var b = new TextEncoder().encode(s), h = "0x"; for (var i = 0; i < b.length; i++) h += (b[i] < 16 ? "0" : "") + b[i].toString(16); return h; } function signWith(provider, address) { if (busy) return; busy = true; choosing = false; working(t.signing); api("/nonce", { address: address, lang: lang }).then(function (n) { if (!n || !n.message || !n.ticket) throw { unread: true }; return provider.request({ method: "personal_sign", params: [toHex(n.message), address] }).then(function (sig) { working(t.checking); return api("/verify", { ticket: n.ticket, signature: sig }); }); }).then(result, function (e) { busy = false; if (e && e.unread) return message(t.unread, false, true); var code = e && (e.code || (e.data && e.data.code)); if (code === 4001 || /reject|denied|cancel/i.test(String(e && e.message))) return intro(t.cancelled); message(t.unread, false, true); }); } function connect() { var p0 = kit && account && kit.getWalletProvider && kit.getWalletProvider(); if (p0) return signWith(p0, account); working(t.choosing); choosing = true; api("/config").then(function (cfg) { var pid = cfg && cfg.reownProjectId; if (!pid) throw new Error("no project id"); return import(APPKIT).then(function (m) { if (!kit) { var adapter = new m.WagmiAdapter({ projectId: pid, networks: [m.networks.mainnet] }); kit = m.createAppKit({ adapters: [adapter], networks: [m.networks.mainnet], projectId: pid, metadata: { name: "NUA", description: "Casa NUA holders", url: location.origin, icons: [] }, features: { analytics: false, email: false, socials: false, swaps: false, onramp: false, send: false, history: false }, themeMode: "dark", themeVariables: { "--w3m-accent": "#ecebe6", "--w3m-font-family": "Inter, system-ui, sans-serif" } }); kit.subscribeAccount(function (a) { var addr = a && a.isConnected && a.address; if (!addr || addr === account) return; account = addr; var p = kit.getWalletProvider(); if (p) { signWith(p, addr); if (kit.close) kit.close(); } }); kit.subscribeState && kit.subscribeState(function (s) { if (s && s.open === false && choosing && !busy) { choosing = false; intro(); } }); } return kit.open(); }); }).catch(function () { var eth = window.ethereum; if (!eth) return intro(t.noWallet); eth.request({ method: "eth_requestAccounts" }).then(function (list) { if (list && list[0]) signWith(eth, list[0]); else intro(t.cancelled); }, function () { intro(t.cancelled); }); }); } el.addEventListener("click", function (ev) { var b = ev.target.closest && ev.target.closest("[data-act]"); if (!b) return; var act = b.getAttribute("data-act"); if (act === "connect") connect(); if (act === "back") intro(); if (act === "another") { account = null; var go = function () { intro(); connect(); }; if (kit && kit.disconnect) kit.disconnect().then(go, go); else go(); } if (act === "copy") { var code = el.getAttribute("data-code") || ""; var done = function () { b.textContent = t.copied; }; if (navigator.clipboard) navigator.clipboard.writeText(code).then(done, function () {}); else done(); } }); intro(); api("/status").then(function (s) { if (s && s.available === false) { available = false; if (!busy && !account) intro(); } }, function () {}); })();