var injected=(function(){"use strict";function H(a){return a}const h={matches:["http://*/*","https://*/*"],runAt:"document_start",world:"MAIN",main(){const a=window.postMessage.bind(window),O=window.addEventListener.bind(window),p=window.crypto,M=p.getRandomValues.bind(p),C=window.setTimeout.bind(window),D=window.clearTimeout.bind(window),v=Map,S=Object.entries,y=Object.create,R=Object.defineProperty,P="1am",U="com.midnight.1am",G="1AM",L="4.0.0",z="1am-injected",B="1am-content",A=new v;function j(){const i=new Uint8Array(8);M(i);const e=Array.from(i,t=>t.toString(16).padStart(2,"0")).join("");return`${Date.now()}-${e}`}function o(i,e){return new Promise((t,r)=>{const n=j();A.set(n,{resolve:t,reject:r});const c=C(()=>{A.delete(n),r(m("InternalError","Request timed out"))},6e4),s=A.get(n);s&&(s.timeout=c),a({source:z,type:i,id:n,payload:e},window.location.origin)})}function m(i,e){const t=new Error(e);return t.type="DAppConnectorAPIError",t.code=i,t.reason=e,t}O("message",i=>{if(i.source!==window||i.data?.source!==B)return;const{id:e,success:t,data:r,error:n,type:c}=i.data;if(c==="ONEAM_SET_ICON"){const u=i.data.icon,E=50*1024;typeof u=="string"&&(u.startsWith("chrome-extension://")||u.startsWith("moz-extension://")||u.startsWith("data:image/")&&u.length<=E)&&(T.icon=u);return}const s=A.get(e);if(!s)return;const l=s.timeout;l&&D(l),A.delete(e),t?s.resolve(r):s.reject(m(n?.code||"InternalError",n?.reason||"Unknown error"))});let I=!1;function K(){return{async getShieldedBalances(){const e=await o("ONEAM_GET_SHIELDED_BALANCES"),t=y(null);for(const[r,n]of S(e))Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=BigInt(n));return t},async getUnshieldedBalances(){const e=await o("ONEAM_GET_UNSHIELDED_BALANCES"),t=y(null);for(const[r,n]of S(e))Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=BigInt(n));return t},async getDustBalance(){const e=await o("ONEAM_GET_DUST_BALANCE");return{cap:BigInt(e.cap),balance:BigInt(e.balance)}},async getShieldedAddresses(){return o("ONEAM_GET_SHIELDED_ADDRESSES")},async getUnshieldedAddress(){return o("ONEAM_GET_UNSHIELDED_ADDRESS")},async getDustAddress(){return o("ONEAM_GET_DUST_ADDRESS")},async getTxHistory(e,t){return o("ONEAM_GET_TX_HISTORY",{pageNumber:e,pageSize:t})},async balanceUnsealedTransaction(e){return o("ONEAM_BALANCE_UNSEALED_TX",{tx:e})},async balanceSealedTransaction(e){return o("ONEAM_BALANCE_SEALED_TX",{tx:e})},async makeTransfer(e){const t=e.map(r=>({...r,value:r.value.toString()}));return o("ONEAM_MAKE_TRANSFER",{desiredOutputs:t})},async makeIntent(e,t,r){const n=e.map(s=>({...s,value:s.value.toString()})),c=t.map(s=>({...s,value:s.value.toString()}));return o("ONEAM_MAKE_INTENT",{desiredInputs:n,desiredOutputs:c,options:r})},async signData(e,t){return o("ONEAM_SIGN_DATA",{data:e,options:t})},async submitTransaction(e){await o("ONEAM_SUBMIT_TRANSACTION",{tx:e})},async getProvingProvider(e){const t=async r=>{const n=new CompressionStream("gzip"),c=n.writable.getWriter();c.write(r),c.close();const s=[],l=n.readable.getReader();for(;;){const{done:d,value:N}=await l.read();if(d)break;s.push(N)}const u=s.reduce((d,N)=>d+N.length,0),E=new Uint8Array(u);let g=0;for(const d of s)E.set(d,g),g+=d.length;let w="";for(let d=0;d<E.length;d++)w+=String.fromCharCode(E[d]);return btoa(w)};return{async check(r,n){const c=await e.getZKIR(n).catch(()=>{});return(await o("ONEAM_PROVING_CHECK",{serializedPreimage:Array.from(r),keyLocation:n,zkir:c?Array.from(c):void 0})).map(l=>l===null?void 0:BigInt(l))},async prove(r,n,c){const[s,l,u]=await Promise.all([e.getZKIR(n).catch(()=>{}),e.getProverKey(n).catch(()=>{}),e.getVerifierKey(n).catch(()=>{})]),[E,g,w]=await Promise.all([s?t(s):void 0,l?t(l):void 0,u?t(u):void 0]),d=await o("ONEAM_PROVING_PROVE",{serializedPreimage:Array.from(r),keyLocation:n,overwriteBindingInput:c?.toString(),zkirGz:E,proverKeyGz:g,verifierKeyGz:w});return new Uint8Array(d)}}},async getConfiguration(){return o("ONEAM_GET_CONFIGURATION")},async getConnectionStatus(){return I?o("ONEAM_GET_CONNECTION_STATUS"):{status:"disconnected"}},async hintUsage(e){await o("ONEAM_HINT_USAGE",{methodNames:e})}}}const T={rdns:U,name:G,icon:"",apiVersion:L,async connect(i){const e=await o("ONEAM_CONNECT",{networkId:i});if(!e.authorized)throw m("Rejected","Connection request was rejected by the user");return I=!0,e.networkId,K()}},f=window;f.midnight||(f.midnight={}),R(f.midnight,P,{value:T,writable:!1,enumerable:!0,configurable:!1})}};function V(){}function _(a,...O){}const b={debug:(...a)=>_(console.debug,...a),log:(...a)=>_(console.log,...a),warn:(...a)=>_(console.warn,...a),error:(...a)=>_(console.error,...a)};return(async()=>{try{return await h.main()}catch(a){throw b.error('The content script "injected" crashed on startup!',a),a}})()})();
injected;
