`,title:`Content ${b.id}`,className:`feed-iframe ${V[b.id]?"loaded":""}`,sandbox:"allow-scripts allow-same-origin",onLoad:v=>{S(b.id);const k=v.target,D=k.contentDocument;D&&new ResizeObserver(()=>{const $=D.body.offsetHeight;k.style.height=`${$}px`}).observe(D.body)},style:{width:"100%",border:"none",overflow:"hidden"}})});case"text":return a("div",{className:"content-container text-content",ref:v=>v&&x(v,b.id),children:a("pre",{className:"feed-text",children:b.content})});case"image":return a("div",{className:"content-container image-content",ref:v=>v&&x(v,b.id),children:a("img",{src:b.content,alt:"Content",className:`feed-image ${V[b.id]?"loaded":""}`,onLoad:()=>S(b.id),loading:"lazy"})});default:return a("div",{className:"content-container unknown-content",children:"Unable to display content"})}};return o?r?m("div",{className:"embedded-content",ref:I,children:[a("div",{className:"feed-items",children:[...c].reverse().map((b,v)=>a("div",{className:"feed-item",children:w(b)},`${b.id}-${v}`))}),g&&!u&&a("button",{className:"load-more-btn",onClick:()=>A(B+1),children:"Load More"}),u&&a("div",{className:"loading",children:"Loading more..."})]}):a("div",{className:"modal active",children:m("div",{className:"modal-content feed-modal",children:[a("span",{className:"close-modal",onClick:e,children:"×"}),a("h2",{className:"modal-title",children:s}),d?a("div",{className:"modal-loading",children:n}):m("div",{className:"feed-content",ref:I,children:[a("div",{className:"feed-items",children:[...c].reverse().map((b,v)=>a("div",{className:"feed-item",children:w(b)},`${b.id}-${v}`))}),g&&!u&&a("button",{className:"load-more-btn",onClick:()=>A(B+1),children:"Load More"}),u&&a("div",{className:"modal-loading",children:"Loading more..."})]})]})}):null},ht=async o=>new Promise((e,t)=>{const s=new FileReader;s.onload=()=>{const n=s.result.split(",")[1];e({content:n,contentType:o.type||"application/octet-stream",payloadType:"BASE_64"})},s.onerror=()=>t(new Error("Failed to read file")),s.readAsDataURL(o)}),Hn=o=>{const t=btoa(JSON.stringify({typ:"JWT",alg:"none"})),s=btoa(JSON.stringify(o));return`${t}.${s}.`},Ft=async({payload:o,onFinish:e,onCancel:t})=>{var s;try{const n=(s=window.XverseProviders)==null?void 0:s.BitcoinProvider;if(console.log("Starting inscription with provider:",n),!n)throw new Error("Xverse provider not found");const r=Hn(o);console.log("Created inscription request token:",r);const i=await n.createInscription(r);if(console.log("Received inscription response:",i),!i)throw new Error("No response from provider");if(i.error)throw new Error(i.error.message||"Provider returned an error");const c={txId:i.txId,inscriptionId:i.inscriptionId};return console.log("Inscription successful:",c),e==null||e(c),c}catch(n){if(console.error("Inscription error:",n),n.code===4001)return t==null||t(),null;throw n}},Un={GIGACHAD:{title:"GIGACHAD Member! 🎯",message:`Thank you for your exceptional support! As a GIGACHAD member, you'll be among the first to know about all Bitmap.Nexus developments. We will send updates directly to your wallet as inscriptions. As a solo dev project, we focus on delivery rather than strict dates. Rest assured, you'll be first in line when milestones are reached. Please bookmark this page to stay informed! Note: Bitmap.Nexus operates solely on Bitcoin. We have no X/Twitter or social media presence. Welcome to the new frontier!`},GOLD_MEMBER:{title:"GOLD Member Confirmation! 🌟",message:`Thank you for securing your Bitmap.Nexus Portal parcel! You'll receive your parcel before the WL entry goes live. Important Instructions: - Your parcel will be allocated automatically. - To request a specific parcel number, send an inscription with the desired number to bitmap 4's wallet. - Specific parcel requests are first-come, first-served. - Requests must be received before launch for processing. Please bookmark this page for ongoing updates! Note: We operate exclusively on Bitcoin - no social media presence.`},BASED:{title:"BASED Supporter! 💎",message:`Thank you for your BASED support! Your wallet is now whitelisted and will receive a discount on parcel purchases during the WL event. Please bookmark this page for updates! Welcome to the future of Bitcoin-native development!`},SMOL:{title:"Thank You! 🙏",message:"Thank you for your support! Please bookmark this page to stay informed!"}},jn=({isOpen:o,onClose:e})=>{const[t,s]=y(null),[n,r]=y(null),[i,c]=y(15e3),[l,d]=y(!1),[h,u]=y(!1),[p,g]=y(null),[M,B]=y(2),E={SMOL:{name:"SMOL SAT",amount:1500,description:"Pre-Public Release Wallet WL Entry",benefits:["Access to WL before public release","Ability to participate in WL event"]},BASED:{name:"BASED",amount:15e3,description:"WL Entry + Discount",benefits:["Early WL access","Discount on Portal parcel during WL event","Guaranteed spot in WL phase"]},GIGACHAD:{name:"GIGACHAD",amount:1e5,description:"Priority Access + Direct Notifications",benefits:["First to know about Nexus and Portal openings","Messages sent to your wallet as inscriptions when Portal goes live","Special gift inscription","All BASED tier benefits"]},GOLD_MEMBER:{name:"GOLD MEMBER",amount:5e5,description:"Ultimate Early Access",benefits:["Guaranteed Nexus Portal parcel before WL","Early entry to Bitmap.Nexus","Messages sent to your wallet as inscriptions when WL goes live","Premium position in the ecosystem","All GIGACHAD tier benefits"]}};oe(()=>{const w=async()=>{const b=await Bt();B(b)};if(o){w();const b=setInterval(w,12e4);return()=>clearInterval(b)}},[o]);const R=()=>{d(!1),s(null),r(null),c(15e3),e()},C=async()=>{if(!t){U("Please connect your wallet","error");return}const w=Number(i);if(isNaN(w)||w{console.log("Inscription successful:",_)},onCancel:()=>{throw new Error("Inscription cancelled by user")}});if(!(D!=null&&D.txId))throw new Error("Inscription failed");X(D.txId,b),e(),d(!1)}else{const b=await Ot(t,se.RECIPIENT_ADDRESS,w);if(b.success){const v=V(w);if(!v)throw new Error("Invalid amount for membership level");X(b.txid,v),e(),d(!1)}else throw new Error(b.error)}}catch(b){console.error("Transaction failed:",b),U(b.message||"Transaction failed","error")}},H=w=>{const b=E[w];b&&c(b.amount)},I=()=>m("div",{className:"wallet-info",children:[m("div",{className:"scrollable-content",children:[m("div",{className:"info-grid",children:[m("div",{className:"tip-section-title",children:[a("h3",{children:"Bitmap.Nexus Whitelist Registration"}),a("div",{className:"tip-section-subtitle",children:"Sign up for the Bitmap.Nexus Whitelist to receive exclusive benefits and early access to Bitmap.Nexus and the Nexus Portal."})]}),m("div",{className:"info-section",children:[a("h3",{className:"section-title",children:"Connected Wallet"}),m("div",{className:"address-box",children:[a("div",{className:"wallet-type",children:t}),m("div",{className:"address",children:[n,t==="xverse"&&p&&m("div",{className:"ordinals-address",children:[a("div",{style:{marginTop:"8px",fontWeight:"bold"},children:"Ordinals Address:"}),a("div",{children:p})]})]})]})]}),m("div",{className:"info-section",children:[m("h3",{className:"section-title",children:["Recipient",a("span",{className:"recipient-label",children:"Send funds to Bitmap.Nexus:"})]}),a("div",{className:"address-box",children:a("div",{className:"address",children:se.RECIPIENT_ADDRESS})})]})]}),a("div",{className:"amount-section",children:m("div",{className:"tip-options",children:[Object.entries(E).map(([w,b])=>m("button",{className:`tip-preset-btn ${i===b.amount?"selected":""} ${w==="GOLD_MEMBER"?"gold-member-btn":""}`,"data-amount":b.amount,onClick:()=>H(w),children:[a("div",{className:"preset-name",children:b.name}),m("div",{className:"preset-amount",children:[b.amount," sats",a("div",{className:"preset-description",children:b.description}),b.benefits&&a("div",{className:"benefits-list",children:b.benefits.map((v,k)=>m("div",{className:"benefit-item",children:["• ",v]},k))})]})]},w)),n&&se.RECIPIENT_ADDRESS&&i&&a("div",{style:{gridColumn:"1 / -1",order:1e3},children:a(Dt,{fromAddress:n,toAddress:se.RECIPIENT_ADDRESS,amount:i,ordinalsAddress:t==="xverse"?p:null})})]})})]}),a("div",{className:"sticky-footer",children:a("button",{className:"wallet-btn send-btn",onClick:C,children:"Enter WL"})})]}),V=w=>w>=E.GOLD_MEMBER.amount?"GOLD_MEMBER":w>=E.GIGACHAD.amount?"GIGACHAD":w>=E.BASED.amount?"BASED":w>=E.SMOL.amount?"SMOL":null,U=(w,b="success")=>{const v=document.createElement("div");v.className="success-animation",v.innerHTML=`
${b==="success"?"🎉":"❌"}
${w}
`,document.body.appendChild(v),setTimeout(()=>v.remove(),3e3)},X=(w,b)=>{const v=Un[b];if(!v)throw new Error("Invalid message type");const k=document.createElement("div");k.className="success-modal",k.innerHTML=`

${v.title}

${t==="xverse"?"Inscription":"Transaction"} ID: ${w}
${v.message} ${t==="xverse"?`
Your membership inscription will be available in your ordinals wallet shortly.
`:""}
`,document.body.appendChild(k);const D=k.querySelector(".close-success-btn");D.onclick=()=>k.remove()},q=(w,b)=>{s(w),r(b.address),d(!0)},A=async w=>{var b,v;try{if(w==="unisat"){const k=await window.unisat.requestAccounts();q(w,{address:k[0],purpose:"payment"});return}if(w==="xverse"){const k=(b=window.XverseProviders)==null?void 0:b.BitcoinProvider;if(!k)throw new Error("Xverse provider not found");const D=await k.request("getAccounts",{purposes:["payment","ordinals"]});if(!((v=D==null?void 0:D.result)!=null&&v.length))throw new Error("No accounts found");const _=D.result.find(K=>K.purpose==="payment"),$=D.result.find(K=>K.purpose==="ordinals");if(!_||!$)throw new Error("Missing required addresses");q(w,{address:_.address,ordinalsAddress:$.address}),g($.address);return}if(w==="okx"){const k=await window.okxwallet.bitcoin.requestAccounts();q(w,{address:k[0],purpose:"payment"});return}}catch(k){console.error("Wallet connection error:",k),U("Failed to connect wallet","error")}},x=()=>{u(!0)};return a("div",{className:`modal ${o?"active":""}`,children:m("div",{className:"modal-content",children:[a("span",{className:"close-modal",onClick:R,children:"×"}),l?I():(()=>{var w,b;return m("div",{className:"welcome-container",children:[a("h2",{children:"Connect Your Wallet To Enter WL Phase"}),h&&a("div",{className:"desktop-notice",children:"⚠️ For optimal experience, we recommend using a desktop browser when interacting with Bitmap.Nexus"}),h?m("div",{className:"wallet-list",children:[a("button",{className:"wallet-btn",onClick:()=>window.unisat?A("unisat"):null,disabled:!window.unisat,children:window.unisat?"Unisat":"Unisat Extension Required"}),a("button",{className:"wallet-btn",onClick:()=>window.okxwallet?A("okx"):null,disabled:!window.okxwallet,children:window.okxwallet?"OKX":"OKX Extension Required"}),a("button",{className:"wallet-btn",onClick:()=>{var v;return(v=window.XverseProviders)!=null&&v.BitcoinProvider?A("xverse"):null},disabled:!((w=window.XverseProviders)!=null&&w.BitcoinProvider),children:(b=window.XverseProviders)!=null&&b.BitcoinProvider?"Xverse":"Xverse Extension Required"})]}):m("div",{className:"loading-container",children:[a("div",{className:"loading-bar",children:a("div",{className:"loading-progress"})}),a("div",{className:"loading-text",children:"Loading Bitmap.Nexus content..."})]}),a("div",{className:"welcome-text",children:a(rt,{isOpen:!0,onClose:()=>{},contentId:se.WLID,title:"",loadingMessage:"Loading content...",embedded:!0,onContentLoaded:x})})]})})()]})})},he={TEXT:"text",BITMAP:"bitmap",BRC20:"brc20",UPLOAD:"upload"},_e={BRC20_DEPLOY:60,BRC20_MINT:50,BRC20_TRANSFER:51,PLAIN_TEXT:61,IMAGE:62},pt={title:"Inscription Successful! 🎨",message:`Your inscription has been created and will be processed shortly. You can track your inscription using the transaction IDs below: Note: The inscription process typically takes 5-10 minutes to complete. Bookmark this page to stay updated on future Bitmap.Nexus developments.`},Wn=o=>new Promise((e,t)=>{const s=new FileReader;s.onload=()=>{const n=new Uint8Array(s.result),r=Array.from(n).map(i=>i.toString(16).padStart(2,"0")).join("");e(r)},s.onerror=()=>t("Error reading file."),s.readAsArrayBuffer(o)}),Xn=["text/plain","text/html","application/json","text/markdown","application/xml","text/css","application/javascript"],Vn=`⚠️ Important Notice: 1. This bitmap number may already be registered by someone else 2. Multiple users might be attempting to register the same bitmap 3. A successful transaction doesn't guarantee ownership 4. Always verify the bitmap status before inscribing`,Kn=`⚠️ Unrecognized File Type The MIME type for this file isn't standard. Please verify it's correct: {mimeType} Incorrect MIME types may result in invalid inscriptions. Do you want to proceed with this MIME type?`,je={title:"OKX Wallet Required",message:"Please install OKX Wallet browser extension to inscribe.",downloadLink:"https://www.okx.com/web3"},zn=({isOpen:o,onClose:e})=>{const[t,s]=y(null),[n,r]=y(null),[i,c]=y(""),[l,d]=y(!1),[h,u]=y(!1),[p,g]=y("text/html"),[M,B]=y(""),[E,R]=y([]),[C,H]=y("text"),[I,V]=y(null),[U,X]=y(""),[q,A]=y(""),[x,S]=y(!1),[w,b]=y(""),[v,k]=y(!1),[D,_]=y(null),[$,K]=y(2),[j,ee]=y(null);oe(()=>{const O=async()=>{try{const Z=await(await fetch(`${se.baseUrl}/r/blockheight`)).text();V(parseInt(Z.trim()))}catch(L){console.error("Failed to fetch block height:",L)}};if(o){O();const L=setInterval(O,3e4);return()=>clearInterval(L)}},[o]),oe(()=>{const O=async()=>{const L=await fetchCurrentFeeRate();K(L)};if(o){O();const L=setInterval(O,12e4);return()=>clearInterval(L)}},[o]),oe(()=>{I&&D&&I!==D&&(k(!0),setTimeout(()=>k(!1),1e3)),_(I)},[I]);const te=O=>/^\d+$/.test(O)?I&&parseInt(O)>I?(A(`Bitmap number cannot exceed current block height (${I})`),!1):(A(""),!0):(A("Bitmap number must be a positive integer"),!1),Q=O=>{const L=O.target.value;X(L),L&&te(L)},ne=()=>te(U)?`${U}.bitmap`:null,P=()=>{s(null),r(null),c(""),d(!1),u(!1),g("text/html"),X(""),R([]),B(""),b(""),S(!1),A(""),e()},F=(O,L="success")=>{const Z=document.createElement("div");Z.className="success-animation",Z.innerHTML=`
${L==="success"?"🎉":"❌"}
${O}
`,document.body.appendChild(Z),setTimeout(()=>Z.remove(),3e3)},N=async O=>{try{const L=await st[O]();L!=null&&L.address&&(s(O),r(L.address),L.ordinalsAddress&&ee(L.ordinalsAddress),d(!0),F(`Connected to ${O}`))}catch(L){console.error("Wallet connection error:",L),F("Failed to connect wallet","error")}},T=(O,L=null)=>{const Z=document.createElement("div");Z.className="success-modal";const ie=L?`
Reveal Transaction${L.includes(` `)?"s":""}: ${L.split(` `).map(xe=>`${xe}`).join("")}
`:"";Z.innerHTML=`

${pt.title}

Commit Transaction: ${O}
${ie}
${pt.message}
Note: The inscription process requires two steps: 1. Commit transaction 2. Reveal transaction
Please wait for both transactions to confirm.
${L?` `:""}
`,document.body.appendChild(Z);const ge=Z.querySelector(".close-success-btn");ge.onclick=()=>{Z.style.opacity="0",setTimeout(()=>Z.remove(),300)}},f=async()=>{var O;if(!t||!n){F("Please connect your wallet first","error");return}if(t==="xverse"&&!j){F("Ordinals address is required for inscriptions","error");return}u(!0);try{let L={from:t==="xverse"?j:n,inscriptions:[]};switch(L.suggestedMinerFeeRate=$,C){case he.BITMAP:const ie=ne();if(!ie)throw new Error("Invalid bitmap format");L.type=_e.PLAIN_TEXT,L.inscriptions=[{contentType:"text/plain;charset=utf-8",body:ie}];break;case he.TEXT:L.type=_e.PLAIN_TEXT,L.inscriptions=[{contentType:p,body:i}];break;case he.BRC20:if(!M)throw new Error("Please enter a BRC-20 token tick");L.type=_e.BRC20_TRANSFER,L.inscriptions=[{contentType:"text/plain;charset=utf-8",body:JSON.stringify({p:"brc-20",op:"transfer",tick:M.toLowerCase()})}];break;case he.UPLOAD:if(E.length===0)throw new Error("Please select at least one file");L.type=_e.IMAGE,L.inscriptions=await Promise.all(E.map(async ge=>{if(ge.type.startsWith("image/")){const xe=await Wn(ge);return{contentType:ge.type,body:xe}}else throw new Error("Only image files are supported")}));break}const Z=await window.okxwallet.bitcoin.mint(L);Z!=null&&Z.commitTx&&(T(Z.commitTx,(O=Z.revealTxs)==null?void 0:O.join(` `)),P())}catch(L){console.error("Inscription failed:",L),F(L.message,"error")}finally{u(!1)}},W=()=>m("div",{className:"welcome-container",children:[a("h2",{children:"Connect Your Wallet To Inscribe"}),a("div",{className:"wallet-list",children:window.okxwallet?a("button",{className:"wallet-btn",onClick:()=>N("okx"),children:"OKX"}):m("div",{className:"wallet-download-prompt",children:[a("h3",{children:je.title}),a("p",{children:je.message}),a("button",{onClick:()=>{navigator.clipboard.writeText(je.downloadLink).then(()=>alert("Download link copied to clipboard!"))},className:"wallet-download-btn",children:"Copy Download Link"})]})})]}),G=O=>{const L=O.target.value;L==="custom"?(S(!0),g(w||"")):(S(!1),g(L))},Y=O=>{const L=O.target.value;b(L),g(L)},J=()=>m("div",{className:"text-inscription-container",children:[m("div",{className:"content-type-control",children:[a("label",{htmlFor:"contentType",children:"Content Type:"}),m("select",{id:"contentType",value:x?"custom":p,onChange:G,className:"content-type-input",children:[Xn.map(O=>a("option",{value:O,children:O},O)),a("option",{value:"custom",children:"Custom MIME Type"})]}),x&&a("input",{type:"text",value:w,onChange:Y,placeholder:"Enter custom MIME type (e.g., application/x-custom)",className:"content-type-input",style:{marginTop:"8px"}})]}),a("textarea",{className:"inscription-text enhanced",value:i,onChange:O=>c(O.target.value),placeholder:"Enter your inscription text...",rows:10})]}),de=(O,L,Z)=>{const ie=document.createElement("div");ie.className="warning-modal",ie.innerHTML=`

Warning

${O}
`,document.body.appendChild(ie),ie.querySelector(".confirm-btn").onclick=()=>{L(),ie.remove()},ie.querySelector(".cancel-btn").onclick=()=>{Z==null||Z(),ie.remove()}},ae=async O=>{var ie;const L=(ie=O.name.split(".").pop())==null?void 0:ie.toLowerCase();return{png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml"}[L]||"application/octet-stream"},fe=async O=>{const L=O[0];if(L)if(!L.type||L.type==="application/octet-stream"){const Z=await ae(L);de(Kn.replace("{mimeType}",Z),()=>{R([{...L,type:Z}])},()=>{R([])})}else R([L])},we=()=>m("div",{className:"brc20-controls enhanced",children:[a("input",{type:"text",value:M,onChange:O=>B(O.target.value.toUpperCase()),placeholder:"Enter BRC-20 token tick (e.g., ORDI)",className:"tick-input",maxLength:4}),a("div",{className:"info-text",children:"BRC-20 ticks are typically 4 characters in length"})]});return a("div",{className:`modal ${o?"active":""}`,children:m("div",{className:"modal-content",children:[a("span",{className:"close-modal",onClick:P,children:"×"}),l?(()=>m("div",{className:"wallet-info",children:[a("div",{className:"scrollable-content",children:m("div",{className:"info-grid",children:[a("div",{className:"tip-section-title",children:a("h3",{children:"Create Inscription"})}),m("div",{className:"info-section",children:[m("div",{className:"address-box",children:[a("div",{className:"wallet-type",children:t}),a("div",{className:"address",children:n})]}),a("div",{className:"inscription-type-selector",children:Object.values(he).map(O=>a("button",{className:`menu-item ${C===O?"active":""}`,onClick:()=>H(O),children:O.charAt(0).toUpperCase()+O.slice(1)},O))}),C===he.BITMAP&&m("div",{className:"bitmap-inscription-container",children:[m("div",{className:"block-height-info",children:["Current Block Height: ",I||"Loading...",m("button",{className:"use-height-btn",onClick:()=>{X((I==null?void 0:I.toString())||""),te((I==null?void 0:I.toString())||"")},disabled:!I,children:["Use Current Block Height: ",I||"..."]})]}),a("div",{className:"bitmap-warning",children:a("pre",{children:Vn})}),a("input",{type:"number",value:U,onChange:Q,placeholder:`Current block height: ${I||"..."}`,className:"content-type-input",max:I}),q&&a("div",{className:"validation-error",children:q}),U&&!q&&m("div",{className:"preview-text",children:["Will inscribe: ",U,".bitmap"]})]}),C===he.TEXT&&J(),C===he.BRC20&&we(),C===he.UPLOAD&&m("div",{className:"universal-controls enhanced",children:[m("div",{className:"file-upload-zone",onDrop:O=>{O.preventDefault(),fe(O.dataTransfer.files)},onDragOver:O=>O.preventDefault(),children:[a("input",{type:"file",accept:"image/*",multiple:!0,onChange:O=>fe(O.target.files),className:"file-input",id:"file-input"}),a("label",{htmlFor:"file-input",children:"Drop image files here or click to upload"})]}),a("div",{className:"selected-files",children:Array.from(E).map((O,L)=>m("div",{className:"file-item",children:[a("span",{className:"file-icon",children:"📄"}),a("span",{className:"file-name",children:O.name}),m("span",{className:"file-size",children:[(O.size/1024).toFixed(2)," KB"]}),a("button",{className:"remove-file",onClick:()=>R(E.filter((Z,ie)=>ie!==L)),children:"×"})]},L))})]})]})]})}),a("div",{className:"sticky-footer",children:a("button",{className:"send-btn",onClick:f,disabled:h||C===he.BITMAP&&(!U||q),children:h?"Creating Inscription...":"Inscribe Now"})})]}))():W()]})})},qn=()=>{const[o,e]=y({status:ye.DISCONNECTED,wallet:null,address:null,ordinalsAddress:null,error:null}),t=async n=>{e(i=>({...i,status:ye.CONNECTING}));const r=await Gn(n);return e({status:r.success?ye.CONNECTED:ye.ERROR,wallet:r.success?r.wallet:null,address:r.success?r.address:null,ordinalsAddress:r.success?r.ordinalsAddress:null,error:r.success?null:r.error}),r},s=async()=>{o.wallet&&(await $n[o.wallet](),e({status:ye.DISCONNECTED,wallet:null,address:null,ordinalsAddress:null,error:null}))};return{...o,isConnected:o.status===ye.CONNECTED,isConnecting:o.status===ye.CONNECTING,connect:t,disconnect:s}},We=({type:o,onConnect:e,className:t="",disabled:s=!1})=>{const n=_t(o),r=o.charAt(0).toUpperCase()+o.slice(1);return a("button",{className:`wallet-btn ${t}`,onClick:()=>n?e(o):null,disabled:s||!n,children:n?r:`${r} Extension Required`})},Yn=({onConnect:o,disabled:e})=>m("div",{className:"wallet-list",children:[a(We,{type:"unisat",onConnect:o,disabled:e}),a(We,{type:"xverse",onConnect:o,disabled:e}),a(We,{type:"okx",onConnect:o,disabled:e})]}),mt={title:"Bitmap Validation Process",steps:[{title:"Format Validation",description:"Confirm the bitmap follows the [number].bitmap or parcel follows the [parcel].[bitmap].bitmap naming convention"},{title:"Inscription ID Lookup",description:"Query the OCI (Onchain Indexer) to find the inscription ID for this bitmap number"},{title:"Content Verification",description:"Verify that the inscription contains valid bitmap data in the correct format"},{title:"Chain Validation",description:"Verify the inscription exists on the Bitcoin blockchain"},{title:"IMPORTANT DISCLAIMER",description:"WARNING: Always verify wallet addresses carefully before sending any BTC. We are not responsible for any losses due to incorrect wallet addresses or transaction errors. Double-check all addresses - funds sent to incorrect addresses cannot be recovered. By proceeding, you acknowledge that you are solely responsible for verifying transaction details."}]},Qn=()=>({showValidationProcess:e=>{if(!e)return;const t=document.createElement("div");t.className="success-modal",t.innerHTML=`

${mt.title}

${mt.steps.map((n,r)=>`
${r+1}

${n.title}

${n.description}

${e?'
':""}
`).join("")}
`,document.body.appendChild(t);const s=t.querySelector(".close-success-btn");s.onclick=()=>{t.style.opacity="0",setTimeout(()=>t.remove(),300)}}}),$t="https://funcollection.btc.onl",Ye=Array(8).fill(0),Jn=["/content/01bba6c58af39d7f199aa2bceeaaba1ba91b23d2663bc4ef079a4b5e442dbf74i0","/content/bb01dfa977a5cd0ee6e900f1d1f896b5ec4b1e3c7b18f09c952f25af6591809fi0","/content/bb02e94f3062facf6aa2e47eeed348d017fd31c97614170dddb58fc59da304efi0","/content/bb037ec98e6700e8415f95d1f5ca1fe1ba23a3f0c5cb7284d877e9ac418d0d32i0","/content/bb9438f4345f223c6f4f92adf6db12a82c45d1724019ecd7b6af4fcc3f5786cei0","/content/bb0542d4606a9e7eb4f31051e91f7696040db06ca1383dff98505618c34d7df7i0","/content/bb06a4dffba42b6b513ddee452b40a67688562be4a1345127e4d57269e6b2ab6i0","/content/bb076934c1c22007b315dd1dc0f8c4a2f9d52f348320cfbadc7c0bd99eaa5e18i0","/content/bb084ed0d70c336861e794c5a2d41a19df8b5531b51ffe71a868695c20cafed2i0"];async function Zn(o){const e=`${$t}${Jn[o]}`;let t=await fetch(e).then(r=>r.text());if(o===2||o===3)t="["+t+"]",t=JSON.parse(t),t=[t.slice(0,99999),t.slice(1e5,199999)];else{try{t=JSON.parse(t.replaceAll("\\n ",""))}catch{}try{t=JSON.parse(t.replaceAll(" ",""))}catch{}}const s=[];t[0].forEach((r,i)=>{i===0?s.push(parseInt(r)):s.push(parseInt(s[i-1])+parseInt(r))});let n=Array(1e5).fill(0);t[1].forEach((r,i)=>{n[r]=s[i]}),Ye[o]=n}async function Fe(o){const e=Math.floor(o/1e5);return Ye[e]||await Zn(e),Ye[e][o%1e5]}function es(o){return o%1e5}async function ft(o){var n;const e=await Fe(o);return(n=(await(await fetch(`${$t}/r/sat/${e}/at/0`)).json()).id)==null?void 0:n.toLowerCase()}typeof window<"u"&&(window.getBitmapSat=Fe);const Gt=()=>{const[o,e]=y([]),[t,s]=y({}),[n,r]=y(!1),[i,c]=y(null),[l,d]=y(0),[h,u]=y(null),[p,g]=y(null),[M,B]=y(null),E=re(async A=>{let S=null;for(let w=0;w<3;w++)try{const b=Pe(A);console.log(`Attempting fetch (try ${w+1}/3):`,b);const v=await fetch(b);if(!v.ok)throw new Error(`HTTP error! status: ${v.status}`);return v}catch(b){S=b,console.warn(`Fetch attempt ${w+1} failed:`,b),w<3-1&&await new Promise(v=>setTimeout(v,1e3*(w+1)))}throw console.error("All fetch attempts failed:",A),new Error(`Failed to fetch ${A}: ${(S==null?void 0:S.message)||"Unknown error"}`)},[]),R=re(async A=>{console.log("Fetching inscription content:",A);const w=(await(await E(`/content/${A}`)).text()).trim().replace(/\s+/g,"");return console.log("Inscription content:",{inscriptionId:A,cleanContent:w}),w},[E]),C=re(async A=>{console.log("Fetching inscription details:",A);const S=await(await E(`/r/inscription/${A}`)).json();return console.log("Inscription details:",{inscriptionId:A,details:S}),S},[E]),H=re(async A=>{console.log("Fetching children inscriptions for:",A);const x=[];let S=0;for(;;){const w=S===0?`/r/children/${A}`:`/r/children/${A}/${S}`;console.log(`Fetching page ${S} of children`);const v=await(await E(w)).json();if(!v.ids||v.ids.length===0||(x.push(...v.ids),console.log(`Found ${v.ids.length} children on page ${S}`),!v.more))break;S++}return console.log("Total children found:",x.length),x},[E]);re(async A=>{console.log("Fetching bitmap SAT for:",A);try{const x=await Fe(A);return console.log("Bitmap SAT data:",{bitmapNumber:A,satNumber:x}),x}catch(x){return console.error("Error fetching bitmap SAT:",x),console.log("Falling back to direct content validation"),null}},[]),re(async A=>{console.log("Fetching inscription IDs for SAT:",A);const S=await(await E(`/r/sat/${A}`)).json();return console.log("SAT inscription IDs:",S.ids),S.ids||[]},[E]);const I=re(async(A,x)=>{if(console.log("Verifying bitmap inscription:",A),await R(A)===`${x}.bitmap`){const w=await C(A);return console.log("Valid bitmap inscription found:",{inscriptionId:A,details:w}),{isValid:!0,details:w}}return{isValid:!1}},[R,C]);re(async(A,x)=>{console.log("Finding valid bitmap inscription among:",A);for(const S of A){const w=await I(S,x);if(w.isValid)return{inscriptionId:S,details:w.details}}throw new Error("No valid bitmap inscription found")},[I]);const V=re(async A=>{console.log("Fetching block info:",A);const S=await(await E(`/r/blockinfo/${A}`)).json();return console.log("Block info:",S),B(S),S},[E]),U=re(async A=>{const{childId:x,bitmapNumber:S,txCount:w,bitmapGenesisHeight:b}=A;console.log("Validating parcel:",{childId:x,bitmapNumber:S,txCount:w});try{const v=await R(x),k=v.split(".");if(k.length!==3||k[2]!=="bitmap")return console.log("Invalid format:",{content:v,parts:k}),{isValid:!1,reason:"Invalid format"};const[D,_]=k,$=parseInt(D,10);if(_!==S.toString())return console.log("Block number mismatch:",{expected:S,found:_}),{isValid:!1,reason:"Block number mismatch"};if(isNaN($)||$<0)return console.log("Invalid parcel number:",D),{isValid:!1,reason:"Invalid parcel number"};if(w!==null&&$>w)return console.log("Parcel number exceeds transaction count:",{parcelNum:$,txCount:w}),{isValid:!1,reason:"Parcel number exceeds transaction count"};const K=await C(x),j=K.genesis_height||K.height;return j{console.log("Starting bitmap validation:",A);try{r(!0),c(null),d(0);let x=0,S=0,w=0;const b=await R(A);console.log("Bitmap content:",b);const v=b.match(/^(\d+)\.bitmap$/);if(!v)throw new Error("Invalid bitmap format");const k=parseInt(v[1],10),D=await ft(k);if(console.log("OCI Validation:",{providedInscriptionId:A,ociInscriptionId:D,match:A===D,bitmapNumber:k}),A!==D)throw console.error("Bitmap validation failed: Inscription ID mismatch with OCI"),new Error("Invalid bitmap: Inscription ID does not match OCI records");const $=(await V(k)).transaction_count-1,K=await Fe(k);if(u(K),K){const j=es(k);g(A);const ee=await C(A),te=ee.genesis_height||ee.height,Q=await H(A);console.log(`Found ${Q.length} children to validate`);for(const N of Q)(await R(N)).endsWith(".bitmap")&&(w++,S++);const ne=new Map;for(const N of Q){const T=await U({childId:N,bitmapNumber:k.toString(),bitmapGenesisHeight:te,txCount:$});if(T.isValid){x++;const f=T.parcel.parcelNumber;ne.has(f)||ne.set(f,[]),ne.get(f).push({id:N,...T.parcel})}}const P=[],F={};return ne.forEach((N,T)=>{if(N.length>0){N.sort((W,G)=>{if(W.height!==G.height)return W.height-G.height;const Y=parseInt(W.id.split("i")[1]),J=parseInt(G.id.split("i")[1]);return Y-J});const f=N[0];P.push(f.id),F[f.id]=f}}),S=w-P.length,console.log("Bitmap validation statistics:",{totalChildren:Q.length,totalBitmapInscriptions:w,validParcels:P.length,invalidBitmapParcels:S,invalidPercent:(S/w*100).toFixed(2)+"%",validPercent:(P.length/w*100).toFixed(2)+"%"}),e(P),s(F),{validParcels:P,parcelData:F}}return{validParcels:[],parcelData:{}}}catch(x){return console.error("Bitmap validation failed:",x),c(x.message),{validParcels:[],parcelData:{}}}finally{r(!1)}},[R,C,H,U,V]),q=re(async(A,x=null)=>{try{const S=await ft(parseInt(A));if(!S)throw new Error("Bitmap not found");const w=await C(S),b=await V(A),v={bitmap:{number:A,inscriptionId:S,address:w.address,details:w,blockInfo:b}};if(x!==null){const k=await H(S);let D=null;for(const _ of k){const $=await R(_),K=await U({childId:_,bitmapNumber:A.toString(),bitmapGenesisHeight:w.genesis_height,txCount:b.transaction_count-1});if(K.isValid&&K.parcel.parcelNumber===parseInt(x)){const j=await C(_);D={number:x,inscriptionId:_,address:j.address,content:$,details:j};break}}if(!D)throw new Error(`Parcel ${x} not found in bitmap ${A}`);v.parcel=D}return{success:!0,data:v}}catch(S){return console.error("Error fetching bitmap info:",S),{success:!1,error:S.message}}},[C,V,H,R,U]);return{validParcels:o,validParcelData:t,isLoading:n,error:i,progress:l,validateBitmap:X,bitmapSat:h,bitmapInscriptionId:p,blockInfo:M,getBitmapInfo:q}},gt={title:"Transaction Successful! 🎉",message:`Your transaction has been sent successfully. Transaction Details: • Amount: {amount} sats • To Bitmap: #{bitmapNumber} • Inscription ID: {inscriptionId} You can track your transaction using the ID below. Note: Bitcoin transactions typically take 10-30 minutes to confirm.`},ts=({isOpen:o,onClose:e})=>{const t=qn(),[s,n]=y(!1),[r,i]=y(""),[c,l]=y(""),[d,h]=y(""),[u,p]=y(!1),[g,M]=y(1500),[B,E]=y(null),[R,C]=y(null),{showValidationProcess:H}=Qn(),[I,V]=y(""),[U,X]=y(!1),q=Gt(),A={MIN_SAT:{name:"MIN SAT",amount:1500},CUSTOM:{name:"CUSTOM",amount:null}},x=N=>{if(!N)return{sats:"0",btc:"0.00000000"};const T=(N/1e8).toFixed(8);return{sats:N.toLocaleString(),btc:T.toString()}},S=()=>{i(""),l(""),h(""),n(!1),p(!1),M(1500),E(null),C(null),t.disconnect(),e()},w=(N,T="success")=>{const f=document.createElement("div");f.className="success-animation",f.setAttribute("data-type",T),f.innerHTML=`
${T==="success"?"🎉":T==="info"?"✨":"❌"}
${N}
`,document.body.appendChild(f),setTimeout(()=>f.remove(),3e3)},b=async N=>{const T=await t.connect(N);T.success?(n(!0),w(`Connected to ${N}`)):w(T.error,"error")},v=async(N,T)=>{try{await navigator.clipboard.writeText(N),w(`${T} copied to clipboard! ✨`,"info")}catch(f){console.error("Failed to copy:",f),w("Failed to copy to clipboard","error")}},k=N=>{const T=document.createElement("div");T.className="success-modal";const f=gt.message.replace("{amount}",g).replace("{bitmapNumber}",r).replace("{inscriptionId}",d);T.innerHTML=`

${gt.title}

Transaction ID: ${N}
${f.split(` `).map(J=>`

${J.trim()}

`).join("")}
`,document.body.appendChild(T);const W=T.querySelector(".view-tx-btn:first-child"),G=T.querySelector(".view-tx-btn:nth-child(2)"),Y=T.querySelector(".close-success-btn");W.onclick=()=>v(`https://mempool.space/tx/${N}`,"Mempool link"),G.onclick=()=>v(`https://ordinals.com/inscription/${d}`,"Bitmap link"),Y.onclick=()=>{T.style.opacity="0",setTimeout(()=>{T.remove(),S()},300)}},D=async()=>{if(!t.isConnected||!c){w("Please connect wallet and select a recipient","error");return}try{const N=await Ot(t.wallet,c,g);if(N.success)k(N.txid);else throw new Error(N.error)}catch(N){console.error("Send failed:",N),w(N.message||"Transaction failed","error")}},_=async(N,T=null)=>{try{const f=await q.getBitmapInfo(N,T);if(!f.success)throw new Error(f.error);const{bitmap:W,parcel:G}=f.data;return G?(h(G.inscriptionId),l(G.address),C({number:`${G.number}.${W.number}`,type:"parcel"})):(h(W.inscriptionId),l(W.address),C({number:W.number,type:"bitmap"})),setTimeout(()=>{$((G==null?void 0:G.inscriptionId)||W.inscriptionId)},100),E(!0),w(G?`Bitmap parcel ${G.number} found and validated!`:"Bitmap found and validated!","info"),!0}catch(f){return console.error("Error fetching bitmap/parcel:",f),w(f.message,"error"),h(""),l(""),E(!1),C(null),!1}},$=N=>{if(!c){console.warn("No recipient address available");return}const T=document.createElement("div");T.className="verification-alert",T.innerHTML=`

⚠️ Verify Transaction Details

Recipient Address: ${c}

Please verify that this address belongs to the intended recipient before proceeding.

`;const f=T.querySelector(".confirm-btn");f.onclick=()=>{T.style.opacity="0",setTimeout(()=>T.remove(),300)}},K=async N=>{if(N.preventDefault(),!r){w("Please enter a bitmap number","error");return}await _(r,U&&I?I:null)},j=N=>{const T=A[N];N==="CUSTOM"?p(!0):(p(!1),M(T.amount))},ee=()=>{if(!R)return null;const N=B===null?"Validating...":B?`Valid ${R.type==="parcel"?"Parcel":"Bitmap"} #${R.number} ✅`:`Invalid ${R.type==="parcel"?"Parcel":"Bitmap"} ❌`;return a("div",{className:`validation-btn ${B===!0?"valid":B===!1?"invalid":""}`,onClick:()=>H(B),style:{cursor:B?"pointer":"default"},children:N})},te=()=>a("form",{className:"bitmap-search-form",onSubmit:K,children:m("div",{className:"bitmap-input-group",children:[a("input",{type:"number",value:r,onChange:N=>i(N.target.value),placeholder:"Enter bitmap number",className:"content-type-input"}),a("div",{className:"parcel-toggle",children:m("label",{children:[a("input",{type:"checkbox",checked:U,onChange:N=>{X(N.target.checked),N.target.checked||V("")}}),"Include Parcel"]})}),U&&a("input",{type:"number",value:I,onChange:N=>V(N.target.value),placeholder:"Enter parcel number",className:"content-type-input parcel-input"}),m("button",{type:"submit",className:"send-btn",children:["Find ",U?"Parcel":"Bitmap"]})]})}),Q=()=>m("div",{className:"custom-amount-inputs custom-inline",children:[a("input",{type:"number",placeholder:`Min ${A.MIN_SAT.amount} sats`,min:A.MIN_SAT.amount,value:g||"",onChange:N=>{const T=N.target.value?Number(N.target.value):"";M(T)},className:"sats-input"}),g>0&&m("div",{className:"amount-conversion",children:["= ",x(g).btc," BTC"]})]}),ne=()=>a("div",{className:"tip-options",children:Object.entries(A).map(([N,T])=>m("button",{className:`tip-preset-btn ${g===T.amount?"selected":""} ${N==="CUSTOM"?"custom-btn":""}`,onClick:()=>j(N),children:[a("div",{className:"preset-name",children:T.name}),T.amount?m("div",{className:"preset-amounts",children:[m("div",{className:"preset-amount",children:[x(T.amount).sats," sats"]}),m("div",{className:"preset-amount-btc",children:[x(T.amount).btc," BTC"]})]}):u?Q():a("div",{className:"preset-description",children:"Enter custom amount"})]},N))}),P=()=>m("div",{className:"wallet-info",children:[m("div",{className:"scrollable-content",children:[m("div",{className:"info-grid",children:[a("div",{className:"tip-section-title",children:a("h3",{children:"Send Funds to a Bitmap"})}),m("div",{className:"info-section",children:[a("h3",{className:"section-title",children:"Connected Wallet"}),m("div",{className:"address-box",children:[a("div",{className:"wallet-type",children:t.wallet}),a("div",{className:"address",children:t.address}),t.ordinalsAddress&&m("div",{className:"ordinals-address",children:[a("div",{style:{marginTop:"8px",fontWeight:"bold"},children:"Ordinals Address:"}),a("div",{children:t.ordinalsAddress})]})]})]}),m("div",{className:"info-section",children:[m("h3",{className:"section-title",children:["Send Funds to a ",U?"Bitmap Parcel":"Bitmap"]}),m("div",{className:"address-box",children:[te(),d&&m("div",{className:"recipient-details",children:[m("div",{className:"address-label",children:[a("span",{children:"Inscription ID:"})," ",d]}),m("div",{className:"wallet-address",children:[a("span",{children:"Wallet Address:"}),a("div",{className:"address",children:c})]}),ee()]})]})]})]}),m("div",{className:"amount-section",children:[ne(),t.isConnected&&c&&g>0&&a(Dt,{fromAddress:t.address,toAddress:c,amount:g})]})]}),a("div",{className:"sticky-footer",children:a("button",{className:"wallet-btn send-btn",onClick:D,disabled:!c,children:"Send Funds"})})]}),F=()=>m("div",{className:"welcome-container",children:[a("h2",{children:"Connect Your Wallet"}),a(Yn,{onConnect:b})]});return a("div",{className:`modal ${o?"active":""}`,children:m("div",{className:"modal-content",children:[a("span",{className:"close-modal",onClick:S,children:"×"}),t.isConnected?P():F()]})})},ns=({isOpen:o,onClose:e})=>a(rt,{isOpen:o,onClose:e,contentId:se.feedId,title:"Keep up to date with Bitmap Nexus News Feed",loadingMessage:"Updating feed..."});const ss=({items:o})=>{const[e,t]=y(!1),s=ce(null);oe(()=>{const r=i=>{s.current&&!s.current.contains(i.target)&&t(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[]);const n=r=>{r(),t(!1)};return m("div",{className:"dropdown-container",ref:s,children:[m("button",{className:`menu-toggle-btn ${e?"active":""}`,onClick:()=>t(!e),children:["Menu",a("span",{className:"menu-icon",children:e?"▼":"▲"})]}),a("div",{className:`dropdown-menu ${e?"active":""}`,children:a("div",{className:"menu-items",children:o.map((r,i)=>a("button",{className:"menu-item",onClick:()=>n(r.action),children:r.label},i))})})]})};function bt(o,e){if(e===Kt)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===ze||e===Et){let t=o.getIndex();if(t===null){const i=[],c=o.getAttribute("position");if(c!==void 0){for(let l=0;l=2.0 are supported."));return}const d=new Os(r,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});d.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h=0&&c[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}d.setExtensions(i),d.setPlugins(c),d.parse(s,n)}parseAsync(e,t){const s=this;return new Promise(function(n,r){s.parse(e,t,n,r)})}}function rs(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const z={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class is{constructor(e){this.parser=e,this.name=z.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let s=0,n=t.length;s=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r.source,i)}}class vs{constructor(e){this.parser=e,this.name=z.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],c=n.images[i.source];let l=s.textureLoader;if(c.uri){const d=s.options.manager.getHandler(c.uri);d!==null&&(l=d)}return this.detectSupport().then(function(d){if(d)return s.loadTextureImage(e,i.source,l);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class ws{constructor(e){this.parser=e,this.name=z.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const t=this.name,s=this.parser,n=s.json,r=n.textures[e];if(!r.extensions||!r.extensions[t])return null;const i=r.extensions[t],c=n.images[i.source];let l=s.textureLoader;if(c.uri){const d=s.options.manager.getHandler(c.uri);d!==null&&(l=d)}return this.detectSupport().then(function(d){if(d)return s.loadTextureImage(e,i.source,l);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return s.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(t.height===1)}})),this.isSupported}}class ys{constructor(e){this.name=z.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,s=t.bufferViews[e];if(s.extensions&&s.extensions[this.name]){const n=s.extensions[this.name],r=this.parser.getDependency("buffer",n.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(c){const l=n.byteOffset||0,d=n.byteLength||0,h=n.count,u=n.byteStride,p=new Uint8Array(c,l,d);return i.decodeGltfBufferAsync?i.decodeGltfBufferAsync(h,u,p,n.mode,n.filter).then(function(g){return g.buffer}):i.ready.then(function(){const g=new ArrayBuffer(h*u);return i.decodeGltfBuffer(new Uint8Array(g),h,u,p,n.mode,n.filter),g})})}else return null}}class Ts{constructor(e){this.name=z.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,s=t.nodes[e];if(!s.extensions||!s.extensions[this.name]||s.mesh===void 0)return null;const n=t.meshes[s.mesh];for(const d of n.primitives)if(d.mode!==ue.TRIANGLES&&d.mode!==ue.TRIANGLE_STRIP&&d.mode!==ue.TRIANGLE_FAN&&d.mode!==void 0)return null;const i=s.extensions[this.name].attributes,c=[],l={};for(const d in i)c.push(this.parser.getDependency("accessor",i[d]).then(h=>(l[d]=h,l[d])));return c.length<1?null:(c.push(this.parser.createNodeMesh(e)),Promise.all(c).then(d=>{const h=d.pop(),u=h.isGroup?h.children:[h],p=d[0].count,g=[];for(const M of u){const B=new De,E=new Ee,R=new Rt,C=new Ee(1,1,1),H=new Jt(M.geometry,M.material,p);for(let I=0;I0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const _s=new De;class Os{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new rs,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let s=!1,n=!1,r=-1;typeof navigator<"u"&&(s=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,n=navigator.userAgent.indexOf("Firefox")>-1,r=n?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||s||n&&r<98?this.textureLoader=new en(this.options.manager):this.textureLoader=new tn(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new It(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const s=this,n=this.json,r=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(i){return i._markDefs&&i._markDefs()}),Promise.all(this._invokeAll(function(i){return i.beforeRoot&&i.beforeRoot()})).then(function(){return Promise.all([s.getDependencies("scene"),s.getDependencies("animation"),s.getDependencies("camera")])}).then(function(i){const c={scene:i[0][n.scene||0],scenes:i[0],animations:i[1],cameras:i[2],asset:n.asset,parser:s,userData:{}};return Te(r,c,n),ve(c,n),Promise.all(s._invokeAll(function(l){return l.afterRoot&&l.afterRoot(c)})).then(function(){e(c)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],s=this.json.meshes||[];for(let n=0,r=t.length;n{const l=this.associations.get(i);l!=null&&this.associations.set(c,l);for(const[d,h]of i.children.entries())r(h,c.children[d])};return r(s,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let s=0;s=2&&E.setY(A,U[X*l+1]),l>=3&&E.setZ(A,U[X*l+2]),l>=4&&E.setW(A,U[X*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return E})}loadTexture(e){const t=this.json,s=this.options,r=t.textures[e].source,i=t.images[r];let c=this.textureLoader;if(i.uri){const l=s.manager.getHandler(i.uri);l!==null&&(c=l)}return this.loadTextureImage(e,r,c)}loadTextureImage(e,t,s){const n=this,r=this.json,i=r.textures[e],c=r.images[t],l=(c.uri||c.bufferView)+":"+i.sampler;if(this.textureCache[l])return this.textureCache[l];const d=this.loadImageSource(t,s).then(function(h){h.flipY=!1,h.name=i.name||c.name||"",h.name===""&&typeof c.uri=="string"&&c.uri.startsWith("data:image/")===!1&&(h.name=c.uri);const p=(r.samplers||{})[i.sampler]||{};return h.magFilter=yt[p.magFilter]||St,h.minFilter=yt[p.minFilter]||Lt,h.wrapS=Tt[p.wrapS]||qe,h.wrapT=Tt[p.wrapT]||qe,n.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=d,d}loadImageSource(e,t){const s=this,n=this.json,r=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const i=n.images[e],c=self.URL||self.webkitURL;let l=i.uri||"",d=!1;if(i.bufferView!==void 0)l=s.getDependency("bufferView",i.bufferView).then(function(u){d=!0;const p=new Blob([u],{type:i.mimeType});return l=c.createObjectURL(p),l});else if(i.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(u){return new Promise(function(p,g){let M=p;t.isImageBitmapLoader===!0&&(M=function(B){const E=new ct(B);E.needsUpdate=!0,p(E)}),t.load(Se.resolveURL(u,r.path),M,void 0,g)})}).then(function(u){return d===!0&&c.revokeObjectURL(l),u.userData.mimeType=i.mimeType||Ps(i.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=h,h}assignTexture(e,t,s,n){const r=this;return this.getDependency("texture",s.index).then(function(i){if(!i)return null;if(s.texCoord!==void 0&&s.texCoord>0&&(i=i.clone(),i.channel=s.texCoord),r.extensions[z.KHR_TEXTURE_TRANSFORM]){const c=s.extensions!==void 0?s.extensions[z.KHR_TEXTURE_TRANSFORM]:void 0;if(c){const l=r.associations.get(i);i=r.extensions[z.KHR_TEXTURE_TRANSFORM].extendTexture(i,c),r.associations.set(i,l)}}return n!==void 0&&(i.colorSpace=n),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let s=e.material;const n=t.attributes.tangent===void 0,r=t.attributes.color!==void 0,i=t.attributes.normal===void 0;if(e.isPoints){const c="PointsMaterial:"+s.uuid;let l=this.cache.get(c);l||(l=new rn,He.prototype.copy.call(l,s),l.color.copy(s.color),l.map=s.map,l.sizeAttenuation=!1,this.cache.add(c,l)),s=l}else if(e.isLine){const c="LineBasicMaterial:"+s.uuid;let l=this.cache.get(c);l||(l=new on,He.prototype.copy.call(l,s),l.color.copy(s.color),l.map=s.map,this.cache.add(c,l)),s=l}if(n||r||i){let c="ClonedMaterial:"+s.uuid+":";n&&(c+="derivative-tangents:"),r&&(c+="vertex-colors:"),i&&(c+="flat-shading:");let l=this.cache.get(c);l||(l=s.clone(),r&&(l.vertexColors=!0),i&&(l.flatShading=!0),n&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(c,l),this.associations.set(l,this.associations.get(s))),s=l}e.material=s}getMaterialType(){return kt}loadMaterial(e){const t=this,s=this.json,n=this.extensions,r=s.materials[e];let i;const c={},l=r.extensions||{},d=[];if(l[z.KHR_MATERIALS_UNLIT]){const u=n[z.KHR_MATERIALS_UNLIT];i=u.getMaterialType(),d.push(u.extendParams(c,r,t))}else{const u=r.pbrMetallicRoughness||{};if(c.color=new Ae(1,1,1),c.opacity=1,Array.isArray(u.baseColorFactor)){const p=u.baseColorFactor;c.color.setRGB(p[0],p[1],p[2],pe),c.opacity=p[3]}u.baseColorTexture!==void 0&&d.push(t.assignTexture(c,"map",u.baseColorTexture,Le)),c.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,c.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(d.push(t.assignTexture(c,"metalnessMap",u.metallicRoughnessTexture)),d.push(t.assignTexture(c,"roughnessMap",u.metallicRoughnessTexture))),i=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),d.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,c)})))}r.doubleSided===!0&&(c.side=an);const h=r.alphaMode||Ve.OPAQUE;if(h===Ve.BLEND?(c.transparent=!0,c.depthWrite=!1):(c.transparent=!1,h===Ve.MASK&&(c.alphaTest=r.alphaCutoff!==void 0?r.alphaCutoff:.5)),r.normalTexture!==void 0&&i!==Me&&(d.push(t.assignTexture(c,"normalMap",r.normalTexture)),c.normalScale=new Ct(1,1),r.normalTexture.scale!==void 0)){const u=r.normalTexture.scale;c.normalScale.set(u,u)}if(r.occlusionTexture!==void 0&&i!==Me&&(d.push(t.assignTexture(c,"aoMap",r.occlusionTexture)),r.occlusionTexture.strength!==void 0&&(c.aoMapIntensity=r.occlusionTexture.strength)),r.emissiveFactor!==void 0&&i!==Me){const u=r.emissiveFactor;c.emissive=new Ae().setRGB(u[0],u[1],u[2],pe)}return r.emissiveTexture!==void 0&&i!==Me&&d.push(t.assignTexture(c,"emissiveMap",r.emissiveTexture,Le)),Promise.all(d).then(function(){const u=new i(c);return r.name&&(u.name=r.name),ve(u,r),t.associations.set(u,{materials:e}),r.extensions&&Te(n,u,r),u})}createUniqueName(e){const t=cn.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,s=this.extensions,n=this.primitiveCache;function r(c){return s[z.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(c,t).then(function(l){return At(l,c,t)})}const i=[];for(let c=0,l=e.length;c0&&Ls(R,r),R.name=t.createUniqueName(r.name||"mesh_"+e),ve(R,r),E.extensions&&Te(n,R,E),t.assignFinalMaterial(R),u.push(R)}for(let g=0,M=u.length;g1?h=new Ue:d.length===1?h=d[0]:h=new Mt,h!==d[0])for(let u=0,p=d.length;u{const u=new Map;for(const[p,g]of n.associations)(p instanceof He||p instanceof ct)&&u.set(p,g);return h.traverse(p=>{const g=n.associations.get(p);g!=null&&u.set(p,g)}),u};return n.associations=d(r),r})}_createAnimationTracks(e,t,s,n,r){const i=[],c=e.name?e.name:e.uuid,l=[];be[r.path]===be.weights?e.traverse(function(p){p.morphTargetInfluences&&l.push(p.name?p.name:p.uuid)}):l.push(c);let d;switch(be[r.path]){case be.weights:d=dt;break;case be.rotation:d=ut;break;case be.position:case be.scale:d=lt;break;default:switch(s.itemSize){case 1:d=dt;break;case 2:case 3:default:d=lt;break}break}const h=n.interpolation!==void 0?Rs[n.interpolation]:Pt,u=this._getArrayFromAccessor(s);for(let p=0,g=l.length;pa("div",{className:"inscription-skeleton",children:a("div",{className:"skeleton-animation"})}),Gs=o=>{try{const e=localStorage.getItem(`${Ze}_${o}`);if(!e)return null;const{data:t,timestamp:s}=JSON.parse(e);return Date.now()-s>Ds?(localStorage.removeItem(`${Ze}_${o}`),null):t}catch{return null}},Hs=(o,e)=>{try{localStorage.setItem(`${Ze}_${o}`,JSON.stringify({data:e,timestamp:Date.now()}))}catch(t){console.warn("Failed to cache inscriptions:",t)}},$e={queue:new Set,inProgress:new Set,cache:$s,async preload(o,e=!1){if(!(this.cache.has(o)||this.inProgress.has(o))){this.inProgress.add(o);try{const s=await(await fetch(o,{headers:e?{Accept:"model/gltf-binary,model/gltf+json,*/*"}:{}})).blob(),n=URL.createObjectURL(s);this.cache.set(o,n)}catch(t){console.error("Preload failed:",t)}finally{this.inProgress.delete(o)}}},getContent(o){return this.cache.get(o)},clear(){this.cache.forEach(o=>URL.revokeObjectURL(o)),this.cache.clear(),this.queue.clear(),this.inProgress.clear()}},Us=async o=>{try{const e=await fetch(Pe(se.endpoints.content(o)));if(!e.ok)throw new Error("Failed to fetch inscription content");return(await e.text()).trim()}catch(e){throw console.error("Error fetching inscription content:",e),e}},js=async o=>{try{return(await fetch(o,{method:"HEAD"})).headers.get("content-type")}catch(e){return console.error("Error detecting MIME type:",e),null}},Ws=({url:o,onError:e,onLoad:t})=>{const[s,n]=y(null),[r,i]=y(null),[c,l]=y(null);return oe(()=>{let d=!0;return(async()=>{if(!o){i("No URL provided for 3D content."),e&&e("No URL provided for 3D content.");return}try{const u=await js(o);d&&l(u);let p;u!=null&&u.includes("model/gltf")?p=new vt:(console.warn("Attempting to load as GLTF anyway:",o),p=new vt),p.load(o,g=>{if(!d)return;const M=g.scene||g;n(M),t&&t()},void 0,g=>{console.error("Error loading 3D model:",g),d&&(i("Failed to load 3D model."),e&&e("Failed to load 3D model."))})}catch(u){if(console.error("Error in content loading:",u),!d)return;i(u.message),e&&e(u.message)}})(),()=>{d=!1}},[o,e,t]),r?null:s?a("primitive",{object:s,scale:[1,1,1],position:[0,0,0],rotation:[0,0,0]}):null},tt=o=>/<[a-z][\s\S]*>/i.test(o),jt=o=>{const t=`https://ordinals.com/content/${o.split("/").pop()}`;navigator.clipboard.writeText(t).then(()=>{const s=document.createElement("div");s.className="copy-feedback",s.textContent="Copied to clipboard!",document.body.appendChild(s),setTimeout(()=>s.remove(),2e3)}).catch(s=>console.error("Failed to copy:",s))},nt=({src:o,title:e,inscriptionId:t})=>{const s=ce(null),[n,r]=y(!0);return m("div",{className:"iframe-loader-container",children:[a("button",{className:"copy-inscription-button",onClick:c=>{c.preventDefault(),c.stopPropagation(),jt(t)},title:"Copy inscription link",children:a("span",{children:"📋"})}),n&&m("div",{className:"iframe-loading",children:[a("div",{className:"loader-spinner"}),a("div",{className:"loader-text",children:"Loading content..."})]}),a("iframe",{ref:s,src:o,title:e,className:`iframe-content ${n?"loading":""}`,onLoad:()=>{r(!1)},loading:"lazy"})]})};function Wt(o,e){return o.includes("html")||e&&tt(e)?"html":o.includes("model/gltf")||o.includes("model/gltf-binary")||o.includes("model/gltf+json")?"3d":o.includes("text")?"text":o.includes("video")?"video":o.includes("audio")?"audio":o.includes("image")?"image":"other"}const Xs=({content:o})=>a("pre",{className:"text-content-pre",children:o}),Vs=({url:o})=>{const[e,t]=y(""),[s,n]=y(null),[r,i]=y(!0),[c,l]=y(null);if(oe(()=>{const d=new AbortController;return(async()=>{try{const u=await fetch(o,{signal:d.signal});if(!u.ok)throw new Error("Failed to fetch content");const p=u.headers.get("content-type")||"",g=await u.text(),M=Wt(p.toLowerCase(),g);n(M),t(g)}catch(u){d.signal.aborted||(l("Failed to load content"),console.error("Error loading text:",u))}finally{i(!1)}})(),()=>d.abort()},[o]),r)return a("div",{className:"text-loading",children:"Loading..."});if(c)return a("div",{className:"text-error",children:c});switch(s){case"html":return a(nt,{src:o,title:"HTML Content",className:"html-content"});case"text":return a(Xs,{content:e});default:return a(nt,{src:o,title:"Content",className:"iframe-content"})}},Ks=({status:o,type:e,className:t})=>{const s={valid:{icon:"✓",class:"valid",title:`Valid ${e||"Bitmap"}`},invalid:{icon:"×",class:"invalid",title:`Invalid ${e||"Bitmap"}`},outOfRange:{icon:"?",class:"out-of-range",title:"Out of Range"}},n=s[o]||s.invalid;return a("div",{className:`validation-icon ${n.class}`,title:n.title,children:n.icon})},Ce={content:new Map,metadata:new Map,setContent(o,e){this.content.set(o,e)},getContent(o){return this.content.get(o)},setMetadata(o,e){this.metadata.set(o,e)},getMetadata(o){return this.metadata.get(o)},clear(){this.content.clear(),this.metadata.clear()}},zs=async(o,e)=>{const s=[],n=o.length;let r=0;try{for(let i=0;i{const u=h.id||h.inscriptionId;try{if(Ce.getContent(u))return{id:u,content:Ce.getContent(u)};const p=await fetch(Pe(se.endpoints.content(u)));if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);const g=await p.text();return Ce.setContent(u,g),{id:u,content:g}}catch(p){return console.error(`Failed to fetch content for ${u}:`,p),{id:u,error:p.message}}}),d=await Promise.all(l);s.push(...d),r+=c.length,e&&e(Math.min(r/n*100,100))}return s}catch(i){throw console.error("Batch fetching error:",i),i}},qs=({inscription:o,isVisible:e})=>{var C;const[t,s]=y(!1),[n,r]=y(null),[i,c]=y(null),{getBitmapInfo:l}=Gt(),d=((C=o.contentType)==null?void 0:C.toLowerCase())||"",h=o.id||o.inscriptionId,u=h?Pe(se.endpoints.content(h)):null;if(o.mimeType,oe(()=>{u&&e&&$e.preload(u,d==="3d").then(()=>{s(!0)}).catch(H=>{console.error("Preload failed for URL:",u,H),r("invalid")})},[u,e,d]),oe(()=>{(async()=>{var I,V,U;if(!(!e||!h))try{console.log("🔍 Starting bitmap validation:",{inscriptionId:h,contentType:d});const X=await Us(h);if(console.log("📄 Content fetched:",X),!X.endsWith(".bitmap")){console.log("❌ Not a bitmap inscription");return}const q=X.match(/^(\d+)\.(\d+)\.bitmap$/);if(q){const[,A,x]=q;if(console.log("🔢 Parsed parcel format:",{parcelNumber:parseInt(A,10),bitmapNumber:parseInt(x,10),isParcel:!0}),x<0||x>84e4){console.log("⚠️ Bitmap number out of range:",x),r("outOfRange");return}const S=await l(parseInt(x,10),parseInt(A,10));if(!S.success){console.log("❌ Parcel validation failed:",S.error),r("invalid");return}const w=(V=(I=S.data.parcel)==null?void 0:I.inscriptionId)==null?void 0:V.toLowerCase(),b=w===h.toLowerCase();console.log("🔍 Parcel validation:",{expected:w,actual:h.toLowerCase(),matches:b}),r(b?"valid":"invalid")}else{const A=X.match(/^(\d+)\.bitmap$/);if(A){const[,x]=A;if(console.log("🔢 Parsed bitmap format:",{bitmapNumber:parseInt(x,10),isParcel:!1}),x<0||x>84e4){console.log("⚠️ Bitmap number out of range:",x),r("outOfRange");return}const S=await l(parseInt(x,10));if(!S.success){console.log("❌ Bitmap validation failed:",S.error),r("invalid");return}const w=(U=S.data.bitmap.inscriptionId)==null?void 0:U.toLowerCase(),b=w===h.toLowerCase();console.log("🔍 Bitmap validation:",{expected:w,actual:h.toLowerCase(),matches:b}),r(b?"valid":"invalid")}else console.log("❌ Invalid bitmap format"),r("invalid")}}catch(X){console.error("❌ Validation error:",X),r("invalid")}})()},[h,e,l]),!u)return a("div",{className:"inscription-error",children:"Invalid inscription ID"});const p=$e.getContent(u);if(!t&&e)return a(et,{});const g=()=>n?a(Ks,{status:n}):null,M=()=>a("button",{className:"copy-inscription-button",onClick:H=>{H.preventDefault(),H.stopPropagation(),jt(h)},title:"Copy inscription link",children:a("span",{children:"📋"})}),B=H=>{c(H)},E=()=>{};return a("div",{className:"inscription-container",children:m("div",{className:"inscription-content-wrapper",children:[a(M,{}),(()=>{var I;switch(Wt(((I=o.contentType)==null?void 0:I.toLowerCase())||"",o.content)){case"3d":return m("div",{className:"inscription-3d-container",children:[i&&m("div",{className:"model-loading",children:["Error: ",i]}),a(Pn,{camera:{position:[0,0,5],fov:75},children:m(Xt,{fallback:null,children:[a("ambientLight",{intensity:.5}),a("pointLight",{position:[10,10,10]}),a(Ws,{url:p||u,onError:B,onLoad:E}),a(_n,{makeDefault:!0,minPolarAngle:0,maxPolarAngle:Math.PI})]})}),g()]});case"video":return m("div",{className:"inscription-video-container",children:[a("video",{src:p||u,controls:!0,loading:"lazy"}),g()]});case"audio":return m("div",{className:"inscription-audio-container",children:[a("audio",{src:p||u,controls:!0}),g()]});case"text":case"html":return m("div",{className:"inscription-text-container",children:[a(Vs,{url:p||u}),g()]});case"image":return m("div",{className:"inscription-image-container",children:[a("img",{src:p||u,alt:`Inscription ${h}`,loading:"lazy"}),g()]});default:return m("div",{className:"inscription-iframe-container",children:[a(nt,{src:p||u,title:`Inscription ${h}`,inscriptionId:h}),g()]})}})()]})})},Ys=({children:o})=>{const[e,t]=y(!1),s=ce(null);return oe(()=>{const n=new IntersectionObserver(([r])=>{t(r.isIntersecting)},{rootMargin:"100px 0px",threshold:.1});return s.current&&n.observe(s.current),()=>n.disconnect()},[]),a("div",{ref:s,children:xt.cloneElement(o,{isVisible:e})})},Qs=({onSearch:o})=>{const[e,t]=y(""),s=ce(null),n=r=>{t(r),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o(r)},300)};return m("div",{className:"search-bar-wrapper",children:[a("div",{className:"search-icon",children:"🔍"}),a("input",{type:"text",value:e,onChange:r=>n(r.target.value),placeholder:"Search inscriptions...",className:"search-input"}),e&&a("button",{className:"clear-search",onClick:()=>n(""),"aria-label":"Clear search",children:"×"})]})},Js={contentType:[{id:"text",label:"Text",icon:"📝"},{id:"image",label:"Images",icon:"🖼️"},{id:"html",label:"HTML",icon:"🌐"},{id:"code",label:"Code",icon:"💻"},{id:"bitmap",label:"Bitmaps",icon:"🟧"},{id:"parcel",label:"Parcels",icon:"📦"},{id:"3d",label:"3D Models",icon:"🤖"},{id:"video",label:"Video",icon:"🎥"},{id:"audio",label:"Audio",icon:"🎵"}]},Zs=({filters:o={},onFilterChange:e,onClearAll:t})=>m("div",{className:"filters-container",children:[a("div",{className:"filter-dropdown",children:m("select",{value:o.contentType||"",onChange:s=>e("contentType",s.target.value||null),className:"filter-select",children:[a("option",{value:"",children:"All Content Types"}),Js.contentType.map(({id:s,label:n,icon:r})=>m("option",{value:s,children:[r," ",n]},s))]})}),o.contentType&&a("button",{className:"clear-filters",onClick:t,children:"Clear All Filters ×"})]}),er=({isOpen:o,onClose:e})=>{var D;const[t,s]=y([]),[n,r]=y([]),[i,c]=y(null),[l,d]=y(!1),[h,u]=y(null),[p,g]=y(1),M=ce(null),B=ce(null),[E,R]=y(0),[C,H]=y(""),[I,V]=y({contentType:null}),[U,X]=y([]),q=(_,$)=>{V(K=>({...K,[_]:K[_]===$?null:$}))},A=re(()=>{V({contentType:null}),H("")},[]),x=re(()=>{const _=(p-1)*Oe,$=p*Oe,K=t.slice(_,$),j=$,ee=Math.min($+Fs,t.length);t.slice(j,ee).forEach(Q=>{const ne=Pe(se.endpoints.content(Q.id||Q.inscriptionId));$e.preload(ne)}),r(Q=>[...Q,...K]),g(Q=>Q+1)},[p,t]);oe(()=>{if(!M.current)return;const _=new IntersectionObserver($=>{$[0].isIntersecting&&!l&&x()},{threshold:.1});return _.observe(M.current),()=>_.disconnect()},[x,l]);const S=async _=>{var $;d(!0),u(null),R(0);try{const K=Gs(_);if(K){s(K),r(K.slice(0,Oe)),g(2),d(!1);return}let j=[],ee=0,te=!0;for(;te;){let Q=[];switch(_){case"xverse":Q=(($=(await window.XverseProviders.BitcoinProvider.request("ord_getInscriptions",{offset:ee,limit:100})).result)==null?void 0:$.inscriptions)||[];break;case"unisat":Q=(await window.unisat.getInscriptions(ee,100)).list||[];break;case"okx":const F=await window.okxwallet.bitcoin.getInscriptions(ee,100);Q=(F==null?void 0:F.list)||[];break;default:Q=[]}if(console.log(`Fetched batch from ${_}:`,Q),Q.length===0)te=!1;else{const ne=Q.filter(P=>P.id||P.inscriptionId);console.log("Valid inscriptions in batch:",ne),j=[...j,...ne],ee+=Q.length}}j.length>0?(Hs(_,j),s(j),(await zs(j,ne=>{R(ne)})).forEach(({id:ne,content:P})=>{P&&!P.error&&Ce.setContent(ne,P)}),r(j.slice(0,Oe)),g(2)):u("No inscriptions found.")}catch(K){console.error("Failed to fetch inscriptions:",K),u("Failed to load inscriptions.")}finally{d(!1),R(100)}},w=async _=>{try{let $;switch(_){case"unisat":$={address:(await window.unisat.requestAccounts())[0]};break;case"xverse":$=(await window.XverseProviders.BitcoinProvider.request("getAccounts",{purposes:["payment"]})).result[0];break;case"okx":$={address:(await window.okxwallet.bitcoin.requestAccounts())[0]};break}$&&(c(_),await S(_))}catch($){console.error("Wallet connection error:",$)}};oe(()=>()=>{$e.clear()},[]),oe(()=>()=>{Ce.clear()},[]);const b=re(_=>_.filter($=>{var ne,P,F;const K=$.id||$.inscriptionId,j=((ne=Ce.getContent(K))==null?void 0:ne.trim())||"",ee=((P=$.contentType)==null?void 0:P.toLowerCase())||"";let te=!0;if(I.contentType)switch(I.contentType){case"bitmap":te=ee.includes("text/plain")&&/^\d+\.bitmap$/.test(j.trim());break;case"parcel":te=ee.includes("text/plain")&&/^\d+\.\d+\.bitmap$/.test(j.trim());break;case"text":te=ee.includes("text/plain")&&!(/^\d+\.bitmap$/.test(j.trim())||/^\d+\.\d+\.bitmap$/.test(j.trim()))&&!tt(j);break;case"html":te=ee.includes("text/html")||ee.includes("text")&&tt(j);break;case"image":te=ee.startsWith("image/");break;case"code":const N=["function","class","import","export","const ","let ","var ",".js",".json",".css",".html",".xml","{","}","=>","++;","j.toLowerCase().includes(T.toLowerCase()));break;case"3d":te=ee.includes("model/")||/\.(gltf|glb)$/i.test(j);break;case"video":te=ee.startsWith("video/");break;case"audio":te=ee.startsWith("audio/");break}let Q=!0;if(C){const N=C.toLowerCase();Q=[j,K,(F=$.number)==null?void 0:F.toString(),$.contentType,...j.match(/^\d+\.bitmap$/)?[j.split(".")[0]]:[],...j.match(/^\d+\.\d+\.bitmap$/)?[j.split(".")[0],j.split(".")[1],`${j.split(".")[0]}.${j.split(".")[1]}`]:[]].filter(Boolean).join(" ").toLowerCase().includes(N)}return te&&Q}),[I,C]);return oe(()=>{const _=b(n);X(_)},[n,I,C,b]),m("div",{className:`modal ${o?"active":""}`,children:[l&&a(({progress:_})=>m("div",{className:"loading-overlay",children:[a("div",{className:"loader-spinner"}),m("div",{className:"loading-text",children:["Loading inscriptions... ",Math.floor(_),"%"]})]}),{progress:E}),m("div",{className:"inscription-content profile-content",ref:B,children:[a("span",{className:"close-modal",onClick:e,children:"×"}),i?m("div",{className:"inscriptions-container",children:[(()=>m("div",{className:"inscriptions-container",children:[a("div",{className:"filters-wrapper",children:m("div",{className:"filters-row",children:[a(Qs,{onSearch:H}),a(Zs,{filters:I,onFilterChange:q,onClearAll:A})]})}),a("h2",{className:"profile-header",children:"Your Inscriptions"}),m("div",{className:"inscriptions-grid",children:[U.map(_=>a(Ys,{children:a(qs,{inscription:_})},_.id||_.inscriptionId)),U.length===0&&a("div",{className:"no-results",children:"No inscriptions found matching your criteria"})]})]}))(),l&&m(Nt,{children:[m("div",{className:"loading-status",children:["Loading inscriptions... ",Math.floor(E),"%"]}),Array(4).fill(0).map((_,$)=>a(et,{},`skeleton-${$}`))]}),!l&&n.lengthw("unisat"),children:"Unisat"}),((D=window.XverseProviders)==null?void 0:D.BitcoinProvider)&&a("button",{className:"wallet-btn",onClick:()=>w("xverse"),children:"Xverse"}),window.okxwallet&&a("button",{className:"wallet-btn",onClick:()=>w("okx"),children:"OKX"})]})]})]})]})},tr=({isOpen:o,onClose:e})=>a(rt,{isOpen:o,onClose:e,contentId:se.infoId,title:"About Bitmap.Nexus",loadingMessage:"Loading info..."});class ke{static async init(){await this.waitForWalletProviders(),window.addEventListener("message",this.handleMessage)}static async waitForWalletProviders(){var s,n,r,i;for(let c=0;c<10&&!((s=window.XverseProviders)!=null&&s.BitcoinProvider||(n=window.okxwallet)!=null&&n.bitcoin||window.unisat);c++)await new Promise(l=>setTimeout(l,1e3));!((r=window.XverseProviders)!=null&&r.BitcoinProvider)&&!((i=window.okxwallet)!=null&&i.bitcoin)&&!window.unisat&&console.warn("Wallet providers are not available.")}static async handleMessage(e){var t;if(((t=e.data)==null?void 0:t.type)==="WALLET_CONNECT_REQUEST"){const{walletType:s}=e.data;try{const n=await st[s]();ke.broadcastToFrames({type:"WALLET_CONNECTED_RESPONSE",walletType:s,account:n})}catch(n){ke.broadcastToFrames({type:"WALLET_CONNECTED_RESPONSE",walletType:s,error:n.message})}}}static broadcastToFrames(e){window.frames.forEach(t=>{try{t.postMessage(e,"*")}catch(s){console.error("Frame message error:",s)}})}static cleanup(){window.removeEventListener("message",this.handleMessage)}}const Be={PLAIN:"text/plain",HTML:"text/html",JSON:"application/json",BITMAP:"text/plain;charset=utf-8",IMAGE_PNG:"image/png",IMAGE_JPEG:"image/jpeg",IMAGE_GIF:"image/gif",IMAGE_WEBP:"image/webp"},le={TEXT:"text",BITMAP:"bitmap",BRC20:"brc20",UPLOAD:"upload"},nr=`⚠️ Important Notice: 1. This bitmap number may already be registered by someone else 2. Multiple users might be attempting to register the same bitmap 3. A successful transaction doesn't guarantee ownership 4. Always verify the bitmap status before inscribing`,sr=({isOpen:o,onClose:e})=>{const[t,s]=y(Be.PLAIN),[n,r]=y(""),[i,c]=y(null),[l,d]=y(!1),[h,u]=y(""),[p,g]=y(!1),[M,B]=y(null),[E,R]=y(null),[C,H]=y(le.TEXT),[I,V]=y(""),[U,X]=y(""),[q,A]=y(2),[x,S]=y(null),[w,b]=y("");oe(()=>{},[p]),oe(()=>{const P=async()=>{const F=await Bt();A(F)};if(o){P();const F=setInterval(P,12e4);return()=>clearInterval(F)}},[o]),oe(()=>{const P=async()=>{try{const N=await(await fetch(`${se.baseUrl}/r/blockheight`)).text();S(parseInt(N.trim()))}catch(F){console.error("Failed to fetch block height:",F)}};if(o){P();const F=setInterval(P,3e4);return()=>clearInterval(F)}},[o]);const v=(P,F="success")=>{const N=document.createElement("div");N.className="success-animation",N.innerHTML=`
${F==="success"?"🎉":"❌"}
${P}
`,document.body.appendChild(N),setTimeout(()=>N.remove(),3e3)},k=P=>{const F=document.createElement("div");F.className="success-modal",F.innerHTML=`

Inscription Successful! 🎨

Transaction ID: ${P}

Your inscription has been created and will be processed shortly.

You can track your inscription using Mempool.

Note: The inscription process typically takes 5-10 minutes to complete.
`,document.body.appendChild(F);const N=F.querySelector(".close-success-btn");N.onclick=()=>{F.remove(),e()}},D=async P=>{var F,N;try{const T=(F=window.XverseProviders)==null?void 0:F.BitcoinProvider;if(!T){u("Xverse provider not found");return}const f=await T.request("getAccounts",{purposes:["payment","ordinals"]});console.log("Wallet connection success:",f),(N=f==null?void 0:f.result)!=null&&N[0]?(R("Xverse"),B(f.result[0].address),g(!0),v("Connected to Xverse")):u("No Xverse accounts found")}catch(T){console.error("Wallet connection error:",T),u((T==null?void 0:T.message)||"Failed to connect wallet")}},_=async P=>{const F=P.target.files[0];if(F)try{c(F);const{content:N,contentType:T}=await ht(F);r(N),s(T),u("")}catch{u("Failed to process file"),c(null)}},$=async()=>{var P,F;try{console.log("Starting inscription process..."),d(!0),u("");const N=(P=window.XverseProviders)==null?void 0:P.BitcoinProvider;if(console.log("Provider check:",{available:!!N,methods:N?Object.getOwnPropertyNames(N):[]}),!N)throw new Error("Xverse provider not found");const T=await N.request("getAccounts",{purposes:["ordinals"]});console.log("Got accounts:",T);const f=(F=T.result.find(ae=>ae.purpose==="ordinals"))==null?void 0:F.address;if(!f)throw new Error("Ordinals address not found");let W=n,G=t,Y="PLAIN_TEXT";if(C===le.BITMAP)W=`${U}.bitmap`,G=Be.BITMAP;else if(C===le.BRC20)W=JSON.stringify({p:"brc-20",op:"transfer",tick:I.toLowerCase()}),G="application/json";else if(C===le.UPLOAD&&i){const ae=await ht(i);W=ae.content,G=ae.contentType,Y="BASE_64"}const J={network:{type:"Mainnet"},contentType:G,content:W,payloadType:Y,appFeeAddress:se.SERVICE_ADDRESS,appFee:se.SERVICE_FEE,suggestedMinerFeeRate:q,address:f};console.log("Creating inscription with payload:",J);const de=await Ft({payload:J,onFinish:ae=>{console.log("Inscription completed successfully:",ae),ae!=null&&ae.txId&&(k(ae.txId),e())},onCancel:()=>{console.log("Inscription cancelled by user"),v("Inscription cancelled by user","error"),d(!1)}});de!=null&&de.txId&&console.log("Inscription transaction created:",de)}catch(N){console.error("Inscription error:",N),v(N.message||"Failed to create inscription","error"),u(N.message||"Failed to create inscription")}finally{d(!1)}},K=()=>{var P,F;return m("div",{className:"welcome-container",children:[a("h2",{children:"Connect Xverse Wallet"}),a("div",{className:"wallet-list",children:a("button",{className:"wallet-btn",onClick:()=>{var N;return(N=window.XverseProviders)!=null&&N.BitcoinProvider?D():null},disabled:!((P=window.XverseProviders)!=null&&P.BitcoinProvider),children:(F=window.XverseProviders)!=null&&F.BitcoinProvider?"Xverse":"Xverse Extension Required"})}),h&&a("div",{className:"error-message",children:h})]})},j=()=>m("div",{className:"brc20-controls enhanced",children:[a("input",{type:"text",value:I,onChange:P=>V(P.target.value.toUpperCase()),placeholder:"Enter BRC-20 token tick (e.g., ORDI)",className:"tick-input",maxLength:4}),a("div",{className:"info-text",children:"BRC-20 ticks are typically 4 characters in length"})]}),ee=()=>m("div",{className:"bitmap-inscription-container",children:[m("div",{className:"block-height-info",children:["Current Block Height: ",x||"Loading...",m("button",{className:"use-height-btn",onClick:()=>{X((x==null?void 0:x.toString())||""),ne((x==null?void 0:x.toString())||"")},disabled:!x,children:["Use Current Block Height: ",x||"..."]})]}),a("div",{className:"bitmap-warning",children:a("pre",{children:nr})}),a("input",{type:"number",value:U,onChange:P=>{X(P.target.value),ne(P.target.value)},placeholder:`Current block height: ${x||"..."}`,className:"content-type-input",max:x}),w&&a("div",{className:"validation-error",children:w}),U&&!w&&m("div",{className:"preview-text",children:["Will inscribe: ",U,".bitmap"]})]}),te=()=>m("div",{className:"wallet-info",children:[a("div",{className:"scrollable-content",children:m("div",{className:"info-grid",children:[a("div",{className:"tip-section-title",children:a("h3",{children:"Create Xverse Inscription"})}),m("div",{className:"info-section",children:[m("div",{className:"address-box",children:[a("div",{className:"wallet-type",children:E}),a("div",{className:"address",children:M})]}),a("div",{className:"inscription-type-selector",children:Object.values(le).map(P=>a("button",{className:`menu-item ${C===P?"active":""}`,onClick:()=>H(P),children:P.charAt(0).toUpperCase()+P.slice(1)},P))}),C===le.TEXT&&m("div",{className:"text-inscription-container",children:[m("div",{className:"input-group",children:[a("label",{children:"Content Type:"}),a("select",{value:t,onChange:P=>s(P.target.value),children:Object.entries(Be).map(([P,F])=>a("option",{value:F,children:F},P))})]}),a("textarea",{className:"inscription-text enhanced",value:n,onChange:P=>r(P.target.value),placeholder:"Enter your inscription text...",rows:6})]}),C===le.BRC20&&j(),C===le.BITMAP&&ee(),C===le.UPLOAD&&m("div",{className:"universal-controls enhanced",children:[m("div",{className:"file-upload-zone",children:[a("input",{type:"file",onChange:_,accept:"image/*,text/*,application/json",className:"file-input",id:"file-input"}),a("label",{htmlFor:"file-input",children:"Drop files here or click to upload"})]}),i&&m("div",{className:"file-preview",children:[m("p",{children:["Selected file: ",i.name]}),a("button",{className:"remove-file-btn",onClick:()=>{c(null),r(""),s(Be.PLAIN)},children:"Remove File"})]})]})]})]})}),a("div",{className:"sticky-footer",children:a("button",{className:"inscribe-button",onClick:$,disabled:l||!Q(),children:l?"Creating Inscription...":"Create Inscription"})})]}),Q=()=>{switch(C){case le.TEXT:return n.trim().length>0;case le.BITMAP:return U.trim().length>0;case le.BRC20:return I.trim().length>0;case le.UPLOAD:return i!==null;default:return!1}},ne=P=>/^\d+$/.test(P)?x&&parseInt(P)>x?(b(`Bitmap number cannot exceed current block height (${x})`),!1):(b(""),!0):(b("Bitmap number must be a positive integer"),!1);return a("div",{className:`modal ${o?"active":""}`,children:m("div",{className:"modal-content",children:[a("span",{className:"close-modal",onClick:e,children:"×"}),p?te():K()]})})};function rr(){const[o,e]=y(null),[t,s]=y(!1);oe(()=>{if(/Mobi|Android/i.test(navigator.userAgent)){const c=document.createElement("div");c.style.cssText=` position: fixed; bottom: 0; left: 0; width: 100%; background: #ffcc00; color: black; text-align: center; padding: 10px; z-index: 1000; `,c.innerHTML=` ⚠️ For optimal experience, we recommend using a desktop browser when interacting with Bitmap.Nexus `,document.body.appendChild(c),setTimeout(()=>{document.body.contains(c)&&c.remove()},1e4)}return(async()=>{try{await Fn(),s(!0)}catch(c){console.error(c)}})(),ke.init(),()=>{ke.cleanup()}},[]);const n=re(()=>{e(null)},[]),r=[{label:"Nexus WL",action:()=>e("wallet")},{label:"My Profile",action:()=>e("profile")},{label:"NewsFeed",action:()=>e("feed")},{label:"₿-2-Bitmap",action:()=>e("bitmapAdd")},{label:"OKX Inscriber",action:()=>e("inscribe")},{label:"Xverse Inscriber",action:()=>e("xverseInscribe")},{label:"About Nexus",action:()=>e("info")}];return t?m("div",{className:"relative w-full min-h-screen bg-black",children:[a("div",{className:"absolute top-4 right-4 z-50",children:a(ss,{items:r})}),a("div",{className:"relative w-full h-screen",children:a(Bn,{})}),o==="wallet"&&a(jn,{isOpen:!0,onClose:n}),o==="profile"&&a(er,{isOpen:!0,onClose:n}),o==="inscribe"&&a(zn,{isOpen:!0,onClose:n}),o==="bitmapAdd"&&a(ts,{isOpen:!0,onClose:n}),o==="feed"&&a(ns,{isOpen:!0,onClose:n}),o==="info"&&a(tr,{isOpen:!0,onClose:n}),o==="xverseInscribe"&&a(sr,{isOpen:!0,onClose:n})]}):a("div",{className:"loading-app",children:a("p",{children:"Initializing..."})})}Vt.createRoot(document.getElementById("root")).render(a(xt.StrictMode,{children:a(rr,{})}));
True Web3 @Switch_900