@cedros/pay-react 1.1.23 → 1.1.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/{AISettingsSection-DpMIk431.mjs → AISettingsSection-Dw0ZlxMf.mjs} +2 -2
  2. package/dist/{AISettingsSection-DAztmwnN.js → AISettingsSection-IXS1Wt_1.js} +1 -1
  3. package/dist/{AutosaveIndicator-BRCqAWqP.mjs → AutosaveIndicator-BJsg_kFZ.mjs} +1 -1
  4. package/dist/{AutosaveIndicator-BnQkKxzr.js → AutosaveIndicator-CY_YHM1D.js} +1 -1
  5. package/dist/{CedrosContext-BlArEF7k.mjs → CedrosContext-DQUbL8yP.mjs} +17 -17
  6. package/dist/{CryptoButton-CREryx1l.mjs → CryptoButton-D1BCZBk4.mjs} +51 -51
  7. package/dist/{FAQSection-yw64HLy3.js → FAQSection-BmgmzDN5.js} +1 -1
  8. package/dist/{FAQSection-Ruzs7a-0.mjs → FAQSection-C78MnK4k.mjs} +1 -1
  9. package/dist/{MessagingSection-Dp_SaXsv.js → MessagingSection-CWLZcg11.js} +1 -1
  10. package/dist/{MessagingSection-BLRjfBQT.mjs → MessagingSection-De3t8bSI.mjs} +2 -2
  11. package/dist/{OrdersSection-C2dyWqrR.js → OrdersSection-BKOxsZw0.js} +1 -1
  12. package/dist/{OrdersSection-l-MtP9EN.mjs → OrdersSection-_xKVzjSZ.mjs} +1 -1
  13. package/dist/{PaymentSettingsSection-C5bhLgU7.js → PaymentSettingsSection-BTEn9Dxb.js} +1 -1
  14. package/dist/{PaymentSettingsSection-Bbq93UtC.mjs → PaymentSettingsSection-KjU_dN_d.mjs} +1 -1
  15. package/dist/{SettingsSection-DorqCFXE.mjs → SettingsSection-8QHZB59k.mjs} +1 -1
  16. package/dist/{SettingsSection-D_pKPRrP.js → SettingsSection-cKF0tLnS.js} +1 -1
  17. package/dist/{SingleCategorySettings-BAND8Zkw.mjs → SingleCategorySettings--LK0TZW0.mjs} +3 -3
  18. package/dist/{SingleCategorySettings-Cg-zuJfr.js → SingleCategorySettings-CRXTMTo5.js} +1 -1
  19. package/dist/{StorefrontSection-QZPEZ6Lz.js → StorefrontSection-C9DzCmOf.js} +1 -1
  20. package/dist/{StorefrontSection-FSOxBclu.mjs → StorefrontSection-CeCpr8hn.mjs} +2 -2
  21. package/dist/{SubscriptionsSection-C4TDXCX2.mjs → SubscriptionsSection-C2xk8ApF.mjs} +1 -1
  22. package/dist/{SubscriptionsSection-DYr99VzB.js → SubscriptionsSection-Dn5SY6S_.js} +1 -1
  23. package/dist/{Token22Section-D3nnUyim.js → Token22Section-DUUl59dZ.js} +1 -1
  24. package/dist/{Token22Section-Cmn2lKcd.mjs → Token22Section-HygkDNtL.mjs} +2 -2
  25. package/dist/{WalletManager-peBN6RDH.mjs → WalletManager-CXvQ0Zu9.mjs} +1 -1
  26. package/dist/{bn-CHdpZHQm.mjs → bn-Bv2sKQMU.mjs} +1 -1
  27. package/dist/{bn-RbgIlcHc.js → bn-CHyy7EgJ.js} +1 -1
  28. package/dist/crypto-only.js +1 -1
  29. package/dist/crypto-only.mjs +7 -7
  30. package/dist/{index-CKNB7XsA.mjs → index-BHF82XBB.mjs} +625 -625
  31. package/dist/{index-vEe2Y39x.js → index-OaWkrl0G.js} +8 -8
  32. package/dist/index.js +1 -1
  33. package/dist/index.mjs +3 -3
  34. package/dist/{sections-Cklkxd85.js → sections-8e5Y3ukY.js} +1 -1
  35. package/dist/sections-C1rb9YRh.mjs +9 -0
  36. package/dist/stripe-only.mjs +2 -2
  37. package/dist/{styles-2VMpwuaI.mjs → styles-Ag-7ZvAB.mjs} +46 -46
  38. package/dist/testing/index.mjs +1 -1
  39. package/dist/{walletPool-DgQsh7Se.mjs → walletPool-C_0P4mTw.mjs} +1 -1
  40. package/package.json +6 -1
  41. package/dist/sections-Dt6vxDU4.mjs +0 -8
@@ -1 +1 @@
1
- "use strict";var Se=Object.create;var ue=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var we=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty;var Ae=(t,s,n,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of ke(s))!Te.call(t,r)&&r!==n&&ue(t,r,{get:()=>s[r],enumerable:!(i=Ce(s,r))||i.enumerable});return t};var me=(t,s,n)=>(n=t!=null?Se(we(t)):{},Ae(s||!t||!t.__esModule?ue(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react"),pe=require("./index-vEe2Y39x.js"),re=require("./configApi-CxEbCAgG.js"),be=[{value:"text",label:"Short Text"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"address",label:"Address"},{value:"textarea",label:"Long Text"},{value:"dropdown",label:"Dropdown"},{value:"file_upload",label:"File Upload"}],he={fields:[],requiresApproval:!0},E={width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",boxSizing:"border-box"},O={display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},Y={padding:"0.4rem 1rem",borderRadius:6,border:"1px solid rgba(0,0,0,0.2)",background:"white",cursor:"pointer",fontSize:"0.85rem"};function Ne(){return{id:Math.random().toString(36).slice(2),label:"",fieldType:"text",required:!1,options:[],placeholder:""}}function ge({field:t,onSave:s,onCancel:n}){const[i,r]=d.useState(t),[o,u]=d.useState(""),m=l=>r(h=>({...h,...l})),y=()=>{const l=o.trim();l&&(m({options:[...i.options,l]}),u(""))};return e.jsxs("div",{style:{padding:"0.75rem",border:"1px solid rgba(37,99,235,0.3)",borderRadius:6,background:"#eff6ff",marginTop:6},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.6rem",marginBottom:"0.6rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:O,children:"Label *"}),e.jsx("input",{style:E,value:i.label,onChange:l=>m({label:l.target.value}),placeholder:"e.g., Full Name"})]}),e.jsxs("div",{children:[e.jsx("label",{style:O,children:"Field Type"}),e.jsx("select",{style:E,value:i.fieldType,onChange:l=>m({fieldType:l.target.value,options:[]}),children:be.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:"0.6rem",alignItems:"end",marginBottom:"0.6rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:O,children:"Placeholder"}),e.jsx("input",{style:E,value:i.placeholder??"",onChange:l=>m({placeholder:l.target.value}),placeholder:"Optional hint text"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"0.85rem",cursor:"pointer",paddingBottom:2},children:[e.jsx("input",{type:"checkbox",checked:i.required,onChange:l=>m({required:l.target.checked})})," Required"]})]}),i.fieldType==="dropdown"&&e.jsxs("div",{style:{marginBottom:"0.6rem"},children:[e.jsx("label",{style:O,children:"Options"}),i.options.map((l,h)=>e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:4},children:[e.jsx("span",{style:{flex:1,fontSize:"0.85rem",padding:"0.25rem 0.5rem",background:"white",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4},children:l}),e.jsx("button",{type:"button",onClick:()=>m({options:i.options.filter((f,_)=>_!==h)}),style:{padding:"0.2rem 0.5rem",borderRadius:4,border:"1px solid rgba(0,0,0,0.2)",background:"white",cursor:"pointer",fontSize:"0.8rem",color:"#dc2626"},children:"x"})]},h)),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("input",{style:{...E,flex:1},value:o,onChange:l=>u(l.target.value),onKeyDown:l=>l.key==="Enter"&&(l.preventDefault(),y()),placeholder:"Add option..."}),e.jsx("button",{type:"button",onClick:y,style:Y,children:"Add"})]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",onClick:()=>s(i),disabled:!i.label.trim(),style:{padding:"0.35rem 1rem",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:i.label.trim()?"pointer":"not-allowed",fontSize:"0.85rem",opacity:i.label.trim()?1:.5},children:"Save Field"}),e.jsx("button",{type:"button",onClick:n,style:Y,children:"Cancel"})]})]})}function ze({fields:t,instructions:s}){const n={...E,fontSize:"0.85rem",background:"white",opacity:.6};return e.jsxs("div",{style:{padding:"1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,background:"rgba(0,0,0,0.02)"},children:[e.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"rgba(0,0,0,0.4)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"0.75rem"},children:"Preview — Redeemer View"}),s&&e.jsx("div",{style:{padding:"0.6rem 0.75rem",background:"#fffbeb",border:"1px solid #fcd34d",borderRadius:6,fontSize:"0.85rem",marginBottom:"0.75rem",color:"#92400e"},children:s}),t.length===0&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.35)",fontStyle:"italic"},children:"No fields added yet."}),t.map(i=>e.jsxs("div",{style:{marginBottom:"0.6rem"},children:[e.jsxs("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:[i.label||"Unlabelled field",i.required&&e.jsx("span",{style:{color:"#dc2626",marginLeft:2},children:"*"})]}),i.fieldType==="textarea"&&e.jsx("textarea",{disabled:!0,rows:2,placeholder:i.placeholder??"",style:{...n,resize:"none"}}),i.fieldType==="file_upload"&&e.jsx("div",{style:{padding:"0.5rem",border:"1px dashed rgba(0,0,0,0.25)",borderRadius:4,fontSize:"0.8rem",color:"rgba(0,0,0,0.4)",textAlign:"center"},children:"File upload"}),i.fieldType==="dropdown"&&e.jsxs("select",{disabled:!0,style:n,children:[e.jsx("option",{children:i.placeholder||"Select..."}),i.options.map((r,o)=>e.jsx("option",{children:r},o))]}),!["textarea","file_upload","dropdown"].includes(i.fieldType)&&e.jsx("input",{disabled:!0,type:i.fieldType==="email"?"email":i.fieldType==="phone"?"tel":"text",placeholder:i.placeholder??"",style:n})]},i.id))]})}function Be({value:t,onChange:s}){const n=t!==null,i=t??he,[r,o]=d.useState(null),[u,m]=d.useState(null),[y,l]=d.useState(!1),h=p=>s({...i,...p}),f=()=>{o(null),m(null)},_=p=>{s(p?{...he}:null),f()},b=()=>{const p=Ne();m(p),o("new")},g=p=>{m({...p}),o(p.id)},j=p=>{h({fields:r==="new"?[...i.fields,p]:i.fields.map(C=>C.id===p.id?p:C)}),f()},k=p=>{r===p&&f(),h({fields:i.fields.filter(C=>C.id!==p)})};return e.jsxs("div",{children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",marginBottom:n?"1rem":4,fontSize:"0.9rem",fontWeight:500},children:[e.jsx("input",{type:"checkbox",checked:n,onChange:p=>_(p.target.checked)}),"Enable Redemption Form"]}),!n&&e.jsx("div",{style:{fontSize:"0.8rem",color:"rgba(0,0,0,0.4)"},children:"No redemption form — token holders cannot request physical redemption."}),n&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:O,children:"Instructions shown to redeemer"}),e.jsx("textarea",{value:i.instructions??"",onChange:p=>h({instructions:p.target.value||void 0}),placeholder:"Describe requirements, turnaround times, etc.",rows:3,style:{...E,resize:"vertical"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"1rem",alignItems:"center",padding:"0.6rem 0.75rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:6,background:"rgba(0,0,0,0.02)"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"0.85rem",cursor:"pointer",whiteSpace:"nowrap"},children:[e.jsx("input",{type:"checkbox",checked:i.requiresApproval,onChange:p=>h({requiresApproval:p.target.checked})})," Requires admin approval"]}),e.jsxs("div",{children:[e.jsx("label",{style:O,children:"Estimated processing days"}),e.jsx("input",{type:"number",min:0,value:i.estimatedProcessingDays??"",onChange:p=>h({estimatedProcessingDays:p.target.value?Number(p.target.value):void 0}),placeholder:"e.g., 5",style:{...E,maxWidth:120}})]})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:500,marginBottom:"0.5rem"},children:["Form Fields (",i.fields.length,")"]}),i.fields.length===0&&r!=="new"&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.35)",fontStyle:"italic",marginBottom:"0.5rem"},children:"No fields yet. Add fields below."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.4rem"},children:[i.fields.map(p=>e.jsxs("div",{children:[e.jsxs("div",{style:{padding:"0.5rem 0.75rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:6,background:"white",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:"0.9rem"},children:p.label||e.jsx("em",{style:{color:"rgba(0,0,0,0.35)"},children:"Unlabelled"})}),e.jsx("span",{style:{padding:"2px 8px",borderRadius:10,background:"#dbeafe",color:"#1d4ed8",fontSize:"0.75rem"},children:be.find(C=>C.value===p.fieldType)?.label??p.fieldType}),p.required&&e.jsx("span",{style:{padding:"2px 8px",borderRadius:10,background:"#fef3c7",color:"#92400e",fontSize:"0.75rem"},children:"required"})]}),e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx("button",{type:"button",onClick:()=>g(p),style:{...Y,padding:"0.25rem 0.6rem",fontSize:"0.8rem"},children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>k(p.id),style:{padding:"0.25rem 0.6rem",borderRadius:4,border:"1px solid rgba(220,38,38,0.3)",background:"white",cursor:"pointer",fontSize:"0.8rem",color:"#dc2626"},children:"Delete"})]})]}),r===p.id&&u&&e.jsx(ge,{field:u,onSave:j,onCancel:f})]},p.id)),r==="new"&&u&&e.jsx(ge,{field:u,onSave:j,onCancel:f})]}),r===null&&e.jsx("button",{type:"button",onClick:b,style:{...Y,marginTop:"0.5rem"},children:"+ Add Field"})]}),e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>l(p=>!p),style:{...Y,background:y?"rgba(0,0,0,0.05)":"white"},children:y?"Hide Preview":"Show Preview"}),y&&e.jsx("div",{style:{marginTop:"0.75rem"},children:e.jsx(ze,{fields:i.fields,instructions:i.instructions})})]})]})]})}const Pe=[{value:"securities",label:"Securities (fungible)"},{value:"commodities",label:"Commodities (fungible)"},{value:"property",label:"Property (non-fungible)"},{value:"collectibles",label:"Collectibles (non-fungible)"}],Me=t=>t==="securities"||t==="commodities";function De({c:t,onDeployPool:s,onEdit:n,onDelete:i}){const r=t.tokenizationConfig,o=Me(r.assetClass);return e.jsxs("div",{style:{padding:"0.75rem 1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,background:"white"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:t.name}),e.jsx("span",{style:{marginLeft:8,fontSize:"0.8rem",padding:"2px 8px",borderRadius:10,background:o?"#dbeafe":"#fef3c7",color:o?"#1d4ed8":"#92400e"},children:r.assetClass}),r.tokenSymbol&&e.jsx("span",{style:{marginLeft:6,fontSize:"0.8rem",color:"rgba(0,0,0,0.5)"},children:r.tokenSymbol})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:"0.8rem"},children:[r.mintAddress?e.jsx("span",{style:{color:"#16a34a"},children:"Mint initialized"}):e.jsx("span",{style:{color:"rgba(0,0,0,0.4)"},children:"No mint"}),o&&r.mintAddress&&(r.liquidityPoolAddress?e.jsxs("span",{style:{padding:"2px 8px",borderRadius:10,background:"#dcfce7",color:"#15803d",fontSize:"0.75rem"},children:["Pool Active · ",r.liquidityPoolAddress.slice(0,4),"...",r.liquidityPoolAddress.slice(-4)]}):e.jsx("button",{type:"button",onClick:s,style:{padding:0,border:"none",background:"none",color:"#2563eb",cursor:"pointer",fontSize:"0.8rem",textDecoration:"underline"},children:"Deploy Pool"}))]})]}),t.description&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.5)",marginTop:4},children:t.description}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:6},children:[e.jsxs("div",{style:{display:"flex",gap:"1rem",flexWrap:"wrap",fontSize:"0.8rem",color:"rgba(0,0,0,0.4)"},children:[e.jsxs("span",{children:["Fee: ",r.transferFeeBps," bps"]}),r.treasuryAddress&&e.jsxs("span",{children:["Treasury: ",r.treasuryAddress.slice(0,8),"..."]}),r.allowedJurisdictions?.length>0&&e.jsxs("span",{style:{padding:"1px 7px",borderRadius:10,background:"#f3f4f6",color:"rgba(0,0,0,0.55)"},children:[r.allowedJurisdictions.length," jurisdiction",r.allowedJurisdictions.length!==1?"s":"",": ",r.allowedJurisdictions.join(", ")]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[n&&e.jsx("button",{type:"button",onClick:n,style:{padding:"2px 10px",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4,background:"white",cursor:"pointer",fontSize:"0.75rem",color:"#2563eb"},children:"Edit"}),i&&e.jsx("button",{type:"button",onClick:i,style:{padding:"2px 10px",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4,background:"white",cursor:"pointer",fontSize:"0.75rem",color:"#dc2626"},children:"Delete"})]})]})]})}const ne={name:"",description:"",assetClass:"securities",tokenSymbol:"",tokenDecimals:2,transferFeeBps:250,maxTransferFee:500,treasuryAddress:"",regulatoryNotice:"",jurisdictions:"",redemptionConfig:null};function Re({serverUrl:t,apiKey:s,authManager:n,onNavigateToLiquidity:i}){const[r,o]=d.useState([]),[u,m]=d.useState(!0),[y,l]=d.useState(null),[h,f]=d.useState(!1),[_,b]=d.useState(!1),[g,j]=d.useState(ne),[k,p]=d.useState(null),C=d.useCallback(async(c,x)=>{if(n?.isAuthenticated())return n.fetchWithAuth(c,x);const D={"Content-Type":"application/json"};s&&(D["X-API-Key"]=s);const v=await fetch(`${t}${c}`,{...x,headers:{...D,...x?.headers}});if(!v.ok){const N=await v.text().catch(()=>`HTTP ${v.status}`);throw new Error(N)}return v.json()},[t,s,n]),w=d.useCallback(async()=>{try{m(!0),l(null);const c=await C("/admin/collections");o((c.collections||[]).filter(x=>x.tokenizationConfig))}catch(c){l(c instanceof Error?c.message:"Failed to load asset classes")}finally{m(!1)}},[C]);d.useEffect(()=>{w()},[w]);const a=()=>({name:g.name.trim(),description:g.description||void 0,active:!0,productIds:[],tokenizationConfig:{assetClass:g.assetClass,tokenSymbol:g.tokenSymbol||void 0,tokenDecimals:g.tokenDecimals,transferFeeBps:g.transferFeeBps,maxTransferFee:g.maxTransferFee,treasuryAddress:g.treasuryAddress||void 0,regulatoryNotice:g.regulatoryNotice||void 0,allowedJurisdictions:g.jurisdictions?g.jurisdictions.split(",").map(c=>c.trim().toUpperCase()).filter(Boolean):[],redemptionConfig:g.redemptionConfig||void 0}}),S=async()=>{if(g.name.trim()){b(!0),l(null);try{k?await C(`/admin/collections/${encodeURIComponent(k)}`,{method:"PUT",body:JSON.stringify(a())}):await C("/admin/collections",{method:"POST",body:JSON.stringify(a())}),j(ne),f(!1),p(null),await w()}catch(c){l(c instanceof Error?c.message:`Failed to ${k?"update":"create"} asset class`)}finally{b(!1)}}},A=c=>{const x=c.tokenizationConfig;j({name:c.name,description:c.description??"",assetClass:x.assetClass,tokenSymbol:x.tokenSymbol??"",tokenDecimals:x.tokenDecimals,transferFeeBps:x.transferFeeBps,maxTransferFee:x.maxTransferFee,treasuryAddress:x.treasuryAddress??"",regulatoryNotice:x.regulatoryNotice??"",jurisdictions:x.allowedJurisdictions.join(", "),redemptionConfig:null}),p(c.id),f(!0)},T=async c=>{if(window.confirm(`Delete asset class "${c.name}"? This cannot be undone.`)){l(null);try{await C(`/admin/collections/${encodeURIComponent(c.id)}`,{method:"DELETE"}),await w()}catch(x){l(x instanceof Error?x.message:"Failed to delete asset class")}}};return u?e.jsx("div",{style:{padding:"1rem 0",color:"rgba(0,0,0,0.5)"},children:"Loading asset classes..."}):e.jsxs("div",{children:[y&&e.jsx("div",{style:{padding:"0.75rem 1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:6,color:"#dc2626",marginBottom:"1rem",fontSize:"0.9rem"},children:y}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem"},children:[e.jsxs("h4",{style:{margin:0},children:["Asset Classes (",r.length,")"]}),e.jsx("button",{type:"button",onClick:()=>{f(!h),h&&(p(null),j(ne))},style:{padding:"0.4rem 1rem",borderRadius:6,border:"1px solid rgba(0,0,0,0.2)",background:h?"rgba(0,0,0,0.05)":"white",cursor:"pointer",fontSize:"0.85rem"},children:h?"Cancel":"+ New Asset Class"})]}),h&&e.jsxs("div",{style:{padding:"1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,marginBottom:"1rem",background:"rgba(0,0,0,0.02)"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",marginBottom:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Name *"}),e.jsx("input",{type:"text",value:g.name,onChange:c=>j(x=>({...x,name:c.target.value})),placeholder:"e.g., Gold Tokens",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Asset Class *"}),e.jsx("select",{value:g.assetClass,onChange:c=>j(x=>({...x,assetClass:c.target.value})),style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"},children:Pe.map(c=>e.jsx("option",{value:c.value,children:c.label},c.value))})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"0.75rem",marginBottom:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Token Symbol"}),e.jsx("input",{type:"text",value:g.tokenSymbol,onChange:c=>j(x=>({...x,tokenSymbol:c.target.value})),placeholder:"e.g., GOLD",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Transfer Fee (bps)"}),e.jsx("input",{type:"number",value:g.transferFeeBps,onChange:c=>j(x=>({...x,transferFeeBps:Number(c.target.value)})),style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Treasury Address"}),e.jsx("input",{type:"text",value:g.treasuryAddress,onChange:c=>j(x=>({...x,treasuryAddress:c.target.value})),placeholder:"Solana address",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Allowed Jurisdictions"}),e.jsx("input",{type:"text",value:g.jurisdictions,onChange:c=>j(x=>({...x,jurisdictions:c.target.value})),placeholder:"US, CA, GB (comma-separated, leave empty for all)",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Regulatory Notice"}),e.jsx("textarea",{value:g.regulatoryNotice,onChange:c=>j(x=>({...x,regulatoryNotice:c.target.value})),placeholder:"Shown to buyers before purchase",rows:2,style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",resize:"vertical"}})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:600,marginBottom:8},children:"Redemption Form"}),e.jsx(Be,{value:g.redemptionConfig,onChange:c=>j(x=>({...x,redemptionConfig:c}))})]}),e.jsx("button",{type:"button",onClick:S,disabled:_||!g.name.trim(),style:{padding:"0.5rem 1.5rem",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:_?"wait":"pointer",fontSize:"0.9rem",opacity:_?.6:1},children:_?"Saving...":k?"Save Changes":"Create Asset Class"})]}),r.length===0?e.jsx("div",{style:{padding:"2rem",textAlign:"center",color:"rgba(0,0,0,0.4)",fontSize:"0.9rem"},children:"No asset classes configured. Create one to start tokenizing off-chain assets."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:r.map(c=>e.jsx(De,{c,onDeployPool:i,onEdit:()=>A(c),onDelete:()=>T(c)},c.id))})]})}const Ie=[{value:"",label:"All statuses"},{value:"pending_info",label:"Pending Info"},{value:"info_submitted",label:"Info Submitted"},{value:"under_review",label:"Under Review"},{value:"approved",label:"Approved"},{value:"completed",label:"Completed"},{value:"rejected",label:"Rejected"}];function Fe(t){switch(t){case"pending_info":return"cedros-admin__badge cedros-admin__badge--muted";case"info_submitted":return"cedros-admin__badge cedros-admin__badge--info";case"under_review":return"cedros-admin__badge cedros-admin__badge--warning";case"approved":return"cedros-admin__badge cedros-admin__badge--success";case"completed":return"cedros-admin__badge cedros-admin__badge--success";case"rejected":return"cedros-admin__badge cedros-admin__badge--failed";default:return"cedros-admin__badge cedros-admin__badge--muted"}}function Le(t){return t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Ee(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function q(t){return t.length>12?`${t.slice(0,8)}…`:t}function ye(t){return`https://solscan.io/tx/${t}`}function Oe({redemption:t,onAction:s,onComplete:n,actionBusy:i}){const[r,o]=d.useState(t.adminNotes??""),u=Object.entries(t.formData??{});return e.jsx("div",{style:{padding:"1rem 1.25rem",background:"rgba(0,0,0,0.02)",borderTop:"1px solid rgba(0,0,0,0.08)"},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"1.5rem"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:"0.8rem",marginBottom:8,textTransform:"uppercase",letterSpacing:"0.05em",opacity:.6},children:"Form Data"}),u.length===0?e.jsx("div",{style:{fontSize:"0.85rem",opacity:.5},children:"No form data submitted."}):e.jsx("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",fontSize:"0.85rem"},children:u.map(([m,y])=>e.jsxs(e.Fragment,{children:[e.jsx("dt",{style:{fontWeight:500,color:"rgba(0,0,0,0.6)",whiteSpace:"nowrap"},children:m},`k-${m}`),e.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:String(y??"—")},`v-${m}`)]}))}),(t.tokenMintSignature||t.tokenBurnSignature)&&e.jsxs("div",{style:{marginTop:12,fontSize:"0.8rem"},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4,opacity:.6,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Signatures"}),t.tokenMintSignature&&e.jsxs("div",{children:["Mint:"," ",e.jsx("a",{href:ye(t.tokenMintSignature),target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:q(t.tokenMintSignature)})]}),t.tokenBurnSignature&&e.jsxs("div",{children:["Burn:"," ",e.jsx("a",{href:ye(t.tokenBurnSignature),target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:q(t.tokenBurnSignature)})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Admin Notes"}),e.jsx("textarea",{value:r,onChange:m=>o(m.target.value),rows:4,style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.85rem",resize:"vertical",boxSizing:"border-box"},placeholder:"Internal notes (not shown to user)..."}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:8,flexWrap:"wrap"},children:[t.status==="info_submitted"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:i,onClick:()=>s(t.id,"under_review",r),children:i?"Saving...":"Mark Under Review"}),t.status==="under_review"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:i,onClick:()=>s(t.id,"approved",r),children:i?"Saving...":"Approve"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",disabled:i,onClick:()=>s(t.id,"rejected",r),children:i?"Saving...":"Reject"})]}),t.status==="approved"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:i,onClick:()=>n(t.id),children:i?"Processing...":"Complete"})]})]})]})})}function qe({serverUrl:t,apiKey:s,authManager:n}){const[i,r]=d.useState([]),[o,u]=d.useState(!0),[m,y]=d.useState(null),[l,h]=d.useState(""),[f,_]=d.useState(null),[b,g]=d.useState(null),j=d.useCallback(async(a,S)=>{if(n?.isAuthenticated())return n.fetchWithAuth(a,S);const A={"Content-Type":"application/json"};s&&(A["X-API-Key"]=s);const T=await fetch(`${t}${a}`,{...S,headers:{...A,...S?.headers}});if(!T.ok){const c=await T.text().catch(()=>`HTTP ${T.status}`);throw new Error(c)}return T.json()},[t,s,n]),k=d.useCallback(async()=>{u(!0),y(null);try{const a=l?`?status=${encodeURIComponent(l)}&limit=50&offset=0`:"?limit=50&offset=0",S=await j(`/admin/asset-redemptions${a}`);r(S.redemptions??[])}catch(a){y(a instanceof Error?a.message:"Failed to load redemptions")}finally{u(!1)}},[j,l]);d.useEffect(()=>{k()},[k]);const p=d.useCallback(async(a,S,A)=>{g(a),y(null);try{await j(`/admin/asset-redemptions/${a}/status`,{method:"PATCH",body:JSON.stringify({status:S,adminNotes:A})}),_(null),await k()}catch(T){y(T instanceof Error?T.message:"Failed to update status")}finally{g(null)}},[j,k]),C=d.useCallback(async a=>{g(a),y(null);try{await j(`/admin/asset-redemptions/${a}/complete`,{method:"POST"}),_(null),await k()}catch(S){y(S instanceof Error?S.message:"Failed to complete redemption")}finally{g(null)}},[j,k]),w=a=>{_(S=>S===a?null:a)};return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"1rem",flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Status"}),e.jsx("select",{value:l,onChange:a=>{h(a.target.value),_(null)},style:{padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",minWidth:160},children:Ie.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))})]}),e.jsx("div",{style:{alignSelf:"flex-end"},children:e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline",onClick:k,disabled:o,children:o?"Loading...":"Refresh"})})]}),m&&e.jsx("div",{style:{padding:"0.75rem 1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:6,color:"#dc2626",marginBottom:"1rem",fontSize:"0.9rem"},children:m}),o?e.jsx("div",{className:"cedros-admin__loading",children:"Loading redemptions..."}):i.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No redemption requests found."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Product"}),e.jsx("th",{children:"Collection"}),e.jsx("th",{children:"User"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:i.map(a=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{style:{cursor:"pointer"},onClick:()=>w(a.id),children:[e.jsx("td",{children:Ee(a.createdAt)}),e.jsx("td",{children:e.jsx("code",{title:a.orderId,children:q(a.orderId)})}),e.jsx("td",{children:e.jsx("code",{title:a.productId,children:q(a.productId)})}),e.jsx("td",{children:e.jsx("code",{title:a.collectionId,children:q(a.collectionId)})}),e.jsx("td",{children:a.userId?e.jsx("code",{title:a.userId,children:q(a.userId)}):e.jsx("span",{style:{opacity:.4},children:"—"})}),e.jsx("td",{children:e.jsx("span",{className:Fe(a.status),children:Le(a.status)})}),e.jsx("td",{onClick:S=>S.stopPropagation(),children:e.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[(a.status==="info_submitted"||a.status==="under_review"||a.status==="approved")&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--sm",onClick:()=>w(a.id),children:f===a.id?"Close":"Review"}),a.status==="under_review"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:b===a.id,onClick:()=>p(a.id,"approved",a.adminNotes??""),children:"Approve"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",disabled:b===a.id,onClick:()=>p(a.id,"rejected",a.adminNotes??""),children:"Reject"})]}),a.status==="approved"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:b===a.id,onClick:()=>C(a.id),children:b===a.id?"Processing...":"Complete"})]})})]},a.id),f===a.id&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,style:{padding:0},children:e.jsx(Oe,{redemption:a,onAction:p,onComplete:C,actionBusy:b===a.id})})},`${a.id}-detail`)]}))})]})})]})}const $e={CA:{cashOutCents:1500,expirationProhibited:!0,escheatmentYears:3,notes:"Cash-out threshold increases to $15 on April 1, 2026."},CO:{cashOutCents:500,escheatmentYears:5},CT:{cashOutCents:300,escheatmentYears:3},FL:{expirationProhibited:!0,escheatmentYears:5},ME:{cashOutCents:500,escheatmentYears:3},MA:{cashOutCents:500,escheatmentYears:3,notes:"Cash-out also required when 90% of value is used."},MT:{cashOutCents:500,escheatmentYears:5},NJ:{cashOutCents:500,escheatmentYears:3},OR:{cashOutCents:500,escheatmentYears:3,notes:"May require at least one prior transaction."},RI:{cashOutCents:100,escheatmentYears:3},TX:{cashOutCents:250,escheatmentYears:3},VT:{cashOutCents:100,escheatmentYears:3},WA:{cashOutCents:500,escheatmentYears:5},PR:{cashOutCents:500,escheatmentYears:5}},ae={escheatmentYears:5},V=1e6,We={AL:"Alabama",AK:"Alaska",AZ:"Arizona",AR:"Arkansas",CA:"California",CO:"Colorado",CT:"Connecticut",DE:"Delaware",FL:"Florida",GA:"Georgia",HI:"Hawaii",ID:"Idaho",IL:"Illinois",IN:"Indiana",IA:"Iowa",KS:"Kansas",KY:"Kentucky",LA:"Louisiana",ME:"Maine",MD:"Maryland",MA:"Massachusetts",MI:"Michigan",MN:"Minnesota",MS:"Mississippi",MO:"Missouri",MT:"Montana",NE:"Nebraska",NV:"Nevada",NH:"New Hampshire",NJ:"New Jersey",NM:"New Mexico",NY:"New York",NC:"North Carolina",ND:"North Dakota",OH:"Ohio",OK:"Oklahoma",OR:"Oregon",PA:"Pennsylvania",RI:"Rhode Island",SC:"South Carolina",SD:"South Dakota",TN:"Tennessee",TX:"Texas",UT:"Utah",VT:"Vermont",VA:"Virginia",WA:"Washington",WV:"West Virginia",WI:"Wisconsin",WY:"Wyoming",DC:"District of Columbia",PR:"Puerto Rico"};function Ye({serverUrl:t,authManager:s}){const[n,i]=d.useState(null),[r,o]=d.useState(null),[u,m]=d.useState(null),[y,l]=d.useState(!0),h=d.useCallback(async()=>{try{const j=(await new re.ConfigApiClient(t,void 0,s).getConfig("gift_cards")).config??{};i(j.business_state||null),o(j.min_gift_card_value_cents!=null?Number(j.min_gift_card_value_cents):null),m(j.max_gift_card_value_cents!=null?Number(j.max_gift_card_value_cents):null)}catch{}finally{l(!1)}},[t,s]);if(d.useEffect(()=>{h()},[h]),y)return e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"Loading compliance data..."});const f=n?$e[n]??ae:null,_=n?We[n]??n:null;return e.jsx("div",{children:n?e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:["Compliance Guidance — ",_]}),e.jsxs("div",{style:{display:"grid",gap:"1rem",maxWidth:720},children:[e.jsx(Ke,{reg:f,minValueCents:r}),e.jsx(He,{reg:f}),e.jsx(Ge,{reg:f}),e.jsx(Je,{maxValueCents:u})]}),e.jsx(Ve,{reg:f,minValueCents:r,maxValueCents:u})]}):e.jsx(Ue,{})})}function Ue(){return e.jsxs("div",{style:{padding:"2rem",textAlign:"center"},children:[e.jsx("p",{style:{fontSize:15,opacity:.7,marginBottom:"0.5rem"},children:"No business state configured."}),e.jsxs("p",{style:{fontSize:13,opacity:.5},children:["Set your ",e.jsx("strong",{children:"business_state"})," in the Gift Cards config category to see state-specific compliance guidance."]})]})}function U({title:t,children:s}){return e.jsxs("div",{style:{border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,padding:"1rem 1.25rem"},children:[e.jsx("h4",{style:{margin:"0 0 0.5rem",fontSize:14,fontWeight:600},children:t}),e.jsx("div",{style:{fontSize:13,lineHeight:1.6},children:s})]})}function Ke({reg:t,minValueCents:s}){if(!t.cashOutCents)return e.jsx(U,{title:"Cash-Out Threshold",children:e.jsx("p",{style:{margin:0},children:"Your state does not have a specific cash-out threshold for gift cards. Federal law does not require cash redemption."})});const n=(t.cashOutCents/100).toFixed(2),i=s!=null&&s>t.cashOutCents;return e.jsxs(U,{title:"Cash-Out Threshold",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Your state requires cash redemption for gift cards with a remaining balance of ",e.jsxs("strong",{children:["$",n]})," or less."]}),e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Since this system uses ",e.jsx("strong",{children:"one-shot full redemption"})," (entire gift card value is converted to credits at once), cash-out is avoided by setting the minimum gift card face value above the threshold."]}),i?e.jsxs(X,{ok:!0,children:["Min value ($",((s??0)/100).toFixed(2),") exceeds threshold"]}):e.jsxs(X,{ok:!1,children:["Set ",e.jsx("code",{children:"min_gift_card_value_cents"})," above ",t.cashOutCents," to avoid cash-out obligations"]}),t.notes&&e.jsx("p",{style:{margin:"0.5rem 0 0",opacity:.7,fontStyle:"italic"},children:t.notes})]})}function He({reg:t}){return e.jsx(U,{title:"Expiration Rules",children:t.expirationProhibited?e.jsxs("p",{style:{margin:0},children:["Your state ",e.jsx("strong",{children:"prohibits"})," gift card expiration. Do not set expiration dates on gift cards."]}):e.jsxs("p",{style:{margin:0},children:["Federal law (CARD Act) requires gift cards to remain valid for at least ",e.jsx("strong",{children:"5 years"})," from purchase or last reload. Your state follows the federal minimum."]})})}function Ge({reg:t}){const s=t.escheatmentYears??ae.escheatmentYears;return e.jsxs(U,{title:"Escheatment (Unclaimed Property)",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Gift card balances unredeemed for ",e.jsxs("strong",{children:[s," years"]})," may need to be reported and remitted to the state as unclaimed property."]}),e.jsxs("p",{style:{margin:0,opacity:.7},children:["The system tracks ",e.jsx("code",{children:"last_activity_at"})," on gift card redemptions to help identify dormant balances approaching the escheatment window."]})]})}function Je({maxValueCents:t}){const s=t??V,n=s<=V;return e.jsxs(U,{title:"Anti-Money Laundering (AML)",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["FinCEN requires closed-loop prepaid cards to stay at or below ",e.jsx("strong",{children:"$10,000"})," per card. The server enforces this cap on product creation."]}),n?e.jsxs(X,{ok:!0,children:["Max value ($",(s/100).toFixed(2),") within AML limit"]}):e.jsxs(X,{ok:!1,children:[e.jsx("code",{children:"max_gift_card_value_cents"})," exceeds $10,000 AML cap"]})]})}function X({ok:t,children:s}){return e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:6,fontSize:13,fontWeight:500,background:t?"rgba(34,197,94,0.1)":"rgba(234,179,8,0.15)",color:t?"#16a34a":"#a16207"},children:[e.jsx("span",{children:t?"✓":"⚠"}),s]})}function Ve({reg:t,minValueCents:s,maxValueCents:n}){const r=[{label:"AML: Max card value ≤ $10,000",ok:(n??V)<=V},...t.cashOutCents?[{label:`Cash-out: Min value > $${(t.cashOutCents/100).toFixed(2)} threshold`,ok:s!=null&&s>t.cashOutCents}]:[],{label:t.expirationProhibited?"Expiration: State prohibits expiration (no action needed)":"Expiration: Federal 5-year minimum applies",ok:!0},{label:`Escheatment: ${t.escheatmentYears??ae.escheatmentYears}-year dormancy tracking enabled`,ok:!0}];return e.jsxs("div",{style:{marginTop:"1.5rem"},children:[e.jsx("h4",{style:{fontSize:14,fontWeight:600,marginBottom:"0.75rem"},children:"Compliance Checklist"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:r.map((o,u)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[e.jsx("span",{style:{color:o.ok?"#16a34a":"#d97706",fontWeight:600},children:o.ok?"✓":"⚠"}),e.jsx("span",{children:o.label})]},u))})]})}const Xe=0;class Ze{dlmmModule=null;bnClass=null;keypairClass=null;async loadDLMM(){if(this.dlmmModule)return this.dlmmModule;try{const s=await Promise.resolve().then(()=>require("./pay-react_false-DaeIe3_l.js"));return this.dlmmModule=s.default??s,this.dlmmModule}catch{throw new Error("Install @meteora-ag/dlmm to enable pool deployment: npm install @meteora-ag/dlmm")}}async loadBN(){if(this.bnClass)return this.bnClass;const s=await Promise.resolve().then(()=>require("./bn-RbgIlcHc.js")).then(n=>n.bn);return this.bnClass=s.default??s,this.bnClass}async loadKeypair(){if(this.keypairClass)return this.keypairClass;const{Keypair:s}=await import("@solana/web3.js");return this.keypairClass=s,this.keypairClass}async computeBinId(s,n,i,r=1){const o=await this.loadDLMM(),u=o.getPricePerLamport(n,i,s);return o.getBinIdFromPrice(u,r,!0)}async findPresetParameter(s,n,i){const r=await this.loadDLMM(),o=i?{cluster:i}:void 0,{presetParameter2:u}=await r.getAllPresetParameters(s,o),m=u.find(y=>y.account.binStep===n);if(!m)throw new Error(`No PresetParameter2 found for binStep=${n}. Available: ${u.map(y=>y.account.binStep).join(", ")}`);return m.publicKey}async createPool(s,n,i,r,o,u=1,m){const y=await this.loadDLMM(),l=await this.loadBN(),h=m?{cluster:m}:void 0,f=await this.findPresetParameter(s,u,m),_=await y.createLbPair2(s,n,i,r,f,new l(o),h),b=_.instructions[0]?.keys?.[1]?.pubkey;if(!b)throw new Error("Failed to extract pool address from transaction");return{transaction:_,poolAddress:b}}async addBuybackLiquidity(s,n,i,r,o,u){const m=await this.loadDLMM(),y=await this.loadBN(),l=await this.loadKeypair(),h=u?{cluster:u}:void 0,f=await m.create(s,i,h),_=l.generate(),b=o-1,g=o;return{transaction:await f.initializePositionAndAddLiquidityByStrategy({positionPubKey:_.publicKey,totalXAmount:new y(0),totalYAmount:new y(r),strategy:{maxBinId:g,minBinId:b,strategyType:Xe},user:n,slippage:1}),positionKeypair:_}}async getPoolStatus(s,n,i){const r=await this.loadDLMM(),o=i?{cluster:i}:void 0,u=await r.create(s,n,o),m=await u.getActiveBin();return{address:n.toBase58(),activeBinId:m.binId,activeBinPrice:m.price,binStep:u.lbPair.binStep}}}const W=6,ie=1,Qe="https://solscan.io/account",et="https://app.meteora.ag/dlmm";function tt({serverUrl:t,authManager:s,mintConfigured:n,mintAddress:i,tokenDecimals:r=2}){const[o,u]=d.useState({liquidityPoolAddress:null,buybackRateBps:null,rpcUrl:null,usdcMint:null,usdcAmount:null,deployedAt:null}),[m,y]=d.useState(!0),[l,h]=d.useState(80),[f,_]=d.useState(250),[b,g]=d.useState("idle"),[j,k]=d.useState(null),[p,C]=d.useState(null),[w,a]=d.useState(null),S=d.useRef(new Ze),A=d.useCallback(async()=>{try{const z=new re.ConfigApiClient(t,void 0,s),[R,F]=await Promise.all([z.getConfig("gift_cards"),z.getConfig("x402")]),B=R.config??{},P=F.config??{},M=B.liquidity_pool_address||null;u({liquidityPoolAddress:M,buybackRateBps:B.buyback_rate_bps!=null?Number(B.buyback_rate_bps):null,rpcUrl:P.rpc_url||null,usdcMint:P.token_mint||null,usdcAmount:B.liquidity_usdc_amount!=null?Number(B.liquidity_usdc_amount):null,deployedAt:B.liquidity_deployed_at||null}),M&&C(M),B.buyback_rate_bps!=null&&h(Number(B.buyback_rate_bps)/100)}catch{}finally{y(!1)}},[t,s]);d.useEffect(()=>{A()},[A]);const T=typeof window<"u"&&!!window.solana?.publicKey,c=!!o.rpcUrl,x=!!o.usdcMint,D=n&&T&&c&&x&&b==="idle",v=async z=>{if(!(!i||!o.rpcUrl||!o.usdcMint)){g(z),k(null),a(null);try{const{Connection:R,PublicKey:F,Keypair:B}=await import("@solana/web3.js"),P=new R(o.rpcUrl,"confirmed"),M=window.solana;if(!M?.publicKey||!M.signTransaction)throw new Error("Wallet not connected");const H=S.current,oe=new F(M.publicKey.toBase58()),je=l/100,ve=await H.computeBinId(je,r,W,ie);let L=p;if(z==="creating_pool"){const $=new F(i),Z=new F(o.usdcMint),G=await H.computeBinId(1,r,W,ie),{transaction:Q,poolAddress:ee}=await H.createPool(P,oe,$,Z,G,ie),te=await M.signTransaction(Q),se=await P.sendRawTransaction(te.serialize());await P.confirmTransaction(se,"confirmed"),L=ee.toBase58(),C(L)}if(z==="creating_pool"||z==="adding_liquidity"){if(g("adding_liquidity"),!L)throw new Error("Pool address not available");const $=new F(L),Z=Math.round(f*10**W),{transaction:G,positionKeypair:Q}=await H.addBuybackLiquidity(P,oe,$,Z,ve),ee=B.fromSecretKey(Q.secretKey);G.partialSign(ee);const te=await M.signTransaction(G),se=await P.sendRawTransaction(te.serialize());await P.confirmTransaction(se,"confirmed")}if(g("saving_config"),!L)throw new Error("Pool address not available");const _e=new re.ConfigApiClient(t,void 0,s),le=Math.round(l*100),de=Math.round(f*10**W),ce=new Date().toISOString();await _e.patchConfig("gift_cards",{liquidity_pool_address:L,buyback_rate_bps:le,liquidity_usdc_amount:de,liquidity_deployed_at:ce},"Meteora DLMM pool deployed for gift card buyback"),u($=>({...$,liquidityPoolAddress:L,buybackRateBps:le,usdcAmount:de,deployedAt:ce})),g("done")}catch(R){a(b==="idle"?z:b),k(R instanceof Error?R.message:"Deployment failed"),g("error")}}},N=()=>{D&&v("creating_pool")},K=()=>{!w||w==="idle"||w==="done"||w==="error"||v(w)};return m?e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"Loading pool configuration..."}):o.liquidityPoolAddress?e.jsx(it,{poolAddress:o.liquidityPoolAddress,buybackRateBps:o.buybackRateBps,usdcAmount:o.usdcAmount,deployedAt:o.deployedAt}):b!=="idle"&&b!=="error"?e.jsx(nt,{step:b,poolAddress:p}):e.jsx(st,{buybackCents:l,setBuybackCents:h,usdcAmount:f,setUsdcAmount:_,mintConfigured:n,walletConnected:T,hasRpcUrl:c,hasUsdcMint:x,canDeploy:D,onDeploy:N,errorMessage:j,canRetry:!!w&&w!=="creating_pool",onRetry:K})}function st({buybackCents:t,setBuybackCents:s,usdcAmount:n,setUsdcAmount:i,mintConfigured:r,walletConnected:o,hasRpcUrl:u,hasUsdcMint:m,canDeploy:y,onDeploy:l,errorMessage:h,canRetry:f,onRetry:_}){const b=((100-t)/100).toFixed(2);return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"0.5rem"},children:"Deploy Buyback Liquidity Pool"}),e.jsx("p",{style:{opacity:.7,marginBottom:"1rem",fontSize:14},children:"Create a Meteora DLMM pool to buy back gift card tokens at a discount. You earn the spread when tokens are resold at face value."}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Buyback rate (cents per $1.00)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:t,onChange:g=>s(Math.max(1,Math.min(99,parseInt(g.target.value)||80))),min:"1",max:"99"}),e.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:["You earn $",b," profit per gift card redeemed"]})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"USDC amount"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n,onChange:g=>i(Math.max(1,parseFloat(g.target.value)||250)),min:"1",step:"1"}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Minimum recommended: $250"})]})]}),e.jsxs("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",gap:6},children:[e.jsx(J,{label:"Token-22 mint initialized",met:r}),e.jsx(J,{label:"Wallet connected",met:o}),e.jsx(J,{label:"RPC URL configured",met:u}),e.jsx(J,{label:"USDC mint configured",met:m})]}),h&&e.jsx("div",{style:{padding:"0.5rem 0.75rem",marginBottom:"0.75rem",borderRadius:6,background:"rgba(239,68,68,0.1)",color:"#dc2626",fontSize:13},children:h}),e.jsx("div",{style:{display:"flex",gap:"0.75rem",alignItems:"center"},children:f?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:_,children:"Retry (Resume from Failed Step)"}):e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:l,disabled:!y,children:"Deploy Liquidity Pool"})})]})}const xe=[{key:"creating_pool",label:"Creating DLMM pool..."},{key:"adding_liquidity",label:"Depositing USDC liquidity..."},{key:"saving_config",label:"Saving configuration..."},{key:"done",label:"Complete"}];function nt({step:t,poolAddress:s}){return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Deploying Pool..."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:xe.map((n,i)=>{const r=xe.findIndex(y=>y.key===t),o=i,u=o<r||t==="done",m=o===r&&t!=="done";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14},children:[e.jsx("span",{style:{width:20,textAlign:"center",fontWeight:600},children:u?"✓":m?"▶":"○"}),e.jsx("span",{style:{opacity:u||m?1:.4},children:n.label})]},n.key)})}),s&&e.jsxs("div",{style:{marginTop:"1rem",fontSize:13,opacity:.7},children:["Pool: ",e.jsx("code",{style:{fontSize:12},children:s})]})]})}function it({poolAddress:t,buybackRateBps:s,usdcAmount:n,deployedAt:i}){const r=s!=null?`$${(s/1e4).toFixed(2)}`:"Unknown",o=n!=null?`$${(n/10**W).toFixed(2)}`:null,u=i?new Date(i).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):null,m=t.length>16?`${t.slice(0,8)}...${t.slice(-8)}`:t;return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Liquidity Pool Active"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",maxWidth:600},children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Pool Address"}),e.jsxs("div",{style:{fontSize:13,fontFamily:"monospace",wordBreak:"break-all"},children:[m,e.jsxs("span",{style:{marginLeft:8,display:"inline-flex",gap:6},children:[e.jsx(rt,{text:t}),e.jsx(fe,{href:`${Qe}/${t}`,label:"Solscan"}),e.jsx(fe,{href:`${et}/${t}`,label:"Meteora"})]})]}),e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Buyback Rate"}),e.jsxs("div",{style:{fontSize:13},children:[r," per $1.00"]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"USDC Deposited"}),e.jsx("div",{style:{fontSize:13},children:o})]}),u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Deployed"}),e.jsx("div",{style:{fontSize:13},children:u})]})]})]})}function J({label:t,met:s}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[e.jsx("span",{style:{color:s?"#16a34a":"#dc2626",fontWeight:600},children:s?"✓":"✗"}),e.jsx("span",{style:{opacity:s?.8:.5},children:t})]})}function rt({text:t}){const[s,n]=d.useState(!1),i=()=>{navigator.clipboard.writeText(t).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})};return e.jsx("button",{type:"button",onClick:i,style:{background:"none",border:"none",cursor:"pointer",fontSize:12,opacity:.7,padding:0},children:s?"Copied":"Copy"})}function fe({href:t,label:s}){return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,opacity:.7},children:s})}function at({serverUrl:t,apiKey:s,authManager:n}){const[i,r]=d.useState(null),[o,u]=d.useState([]),[m,y]=d.useState(!0),[l,h]=d.useState(null),[f,_]=d.useState("mint"),[b,g]=d.useState({treasuryAddress:"",tokenSymbol:"storeUSD",tokenDecimals:2,transferFeeBps:250,maxTransferFee:500}),[j,k]=d.useState(!1),[p,C]=d.useState(!1),[w,a]=d.useState(null),S=d.useCallback(async(v,N)=>{if(n?.isAuthenticated())return n.fetchWithAuth(v,N);const K={"Content-Type":"application/json"};s&&(K["X-API-Key"]=s);const z=await fetch(`${t}${v}`,{...N,headers:{...K,...N?.headers}});if(!z.ok){const R=await z.text().catch(()=>`HTTP ${z.status}`);throw new Error(R)}return z.json()},[t,s,n]),A=d.useCallback(async()=>{try{h(null);const v=await S("/admin/token22/status");r(v)}catch{h("Failed to load Token-22 status")}finally{y(!1)}},[S]),T=d.useCallback(async()=>{try{const v=await S("/admin/gift-card-redemptions?limit=50");u(v.redemptions||[])}catch{u([])}},[S]);d.useEffect(()=>{A(),T()},[A,T]);const c=async v=>{if(v.preventDefault(),!!b.treasuryAddress){k(!0),a(null);try{const N=await S("/admin/token22/initialize",{method:"POST",body:JSON.stringify({treasuryAddress:b.treasuryAddress,tokenSymbol:b.tokenSymbol,tokenDecimals:b.tokenDecimals,transferFeeBps:b.transferFeeBps,maxTransferFee:b.maxTransferFee})});a(`Mint created: ${N.mintAddress}`),A()}catch(N){a(`Error: ${N instanceof Error?N.message:"Failed to initialize"}`)}finally{k(!1)}}},x=async()=>{C(!0),a(null);try{const v=await S("/admin/token22/harvest-fees",{method:"POST"});a(v.message)}catch(v){a(`Error: ${v instanceof Error?v.message:"Failed to harvest"}`)}finally{C(!1)}},D=v=>{try{return new Date(v).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return v}};return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(pe.ErrorBanner,{message:l,onRetry:A}),e.jsx("div",{style:{display:"flex",gap:0,borderBottom:"1px solid rgba(0,0,0,0.1)",marginBottom:"1rem"},children:["mint","redemptions","compliance","liquidity","asset-classes","asset-redemptions"].map(v=>{const N={mint:"Token-22 Mint",redemptions:"Gift Card Redemptions",compliance:"Compliance",liquidity:"Liquidity","asset-classes":"Asset Classes","asset-redemptions":"Asset Redemptions"};return e.jsx("button",{type:"button",onClick:()=>_(v),style:{padding:"0.5rem 1rem",background:"none",border:"none",borderBottom:f===v?"2px solid currentColor":"2px solid transparent",fontWeight:f===v?600:400,cursor:"pointer",opacity:f===v?1:.6},children:N[v]},v)})}),m?e.jsxs("div",{className:"cedros-admin__loading",children:[pe.Icons.loading," Loading..."]}):f==="mint"?e.jsx(ot,{mintStatus:i,initForm:b,setInitForm:g,isInitializing:j,isHarvesting:p,actionMessage:w,onInitialize:c,onHarvestFees:x,formatDate:D}):f==="redemptions"?e.jsx(lt,{redemptions:o,formatDate:D}):f==="compliance"?e.jsx(Ye,{serverUrl:t,apiKey:s,authManager:n}):f==="liquidity"?e.jsx(tt,{serverUrl:t,authManager:n,mintConfigured:!!i?.configured,mintAddress:i?.mintAddress,tokenDecimals:i?.tokenDecimals}):f==="asset-classes"?e.jsx(Re,{serverUrl:t,apiKey:s,authManager:n,onNavigateToLiquidity:()=>_("liquidity")}):e.jsx(qe,{serverUrl:t,apiKey:s,authManager:n})]})}function ot({mintStatus:t,initForm:s,setInitForm:n,isInitializing:i,isHarvesting:r,actionMessage:o,onInitialize:u,onHarvestFees:m,formatDate:y}){return t?.configured?e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Token-22 Mint Status"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",maxWidth:600},children:[e.jsx(I,{label:"Mint Address",value:t.mintAddress,mono:!0}),e.jsx(I,{label:"Token Symbol",value:t.tokenSymbol}),e.jsx(I,{label:"Decimals",value:String(t.tokenDecimals)}),e.jsx(I,{label:"Transfer Fee",value:`${t.transferFeeBps} bps (${((t.transferFeeBps??0)/100).toFixed(2)}%)`}),e.jsx(I,{label:"Max Transfer Fee",value:String(t.maxTransferFee)}),e.jsx(I,{label:"Treasury",value:t.treasuryAddress,mono:!0}),e.jsx(I,{label:"Authority",value:t.mintAuthority,mono:!0}),e.jsx(I,{label:"Created",value:t.createdAt?y(t.createdAt):"—"})]}),e.jsxs("div",{style:{marginTop:"1.5rem",display:"flex",gap:"0.75rem",alignItems:"center"},children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:m,disabled:r,children:r?"Harvesting...":"Harvest Transfer Fees"}),o&&e.jsx("span",{style:{fontSize:13,opacity:.8},children:o})]})]}):e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"0.5rem"},children:"Initialize Token-22 Mint"}),e.jsx("p",{style:{opacity:.7,marginBottom:"1rem",fontSize:14},children:"Create a Token-22 mint with transfer fee extension for the secondary market. This is a one-time operation per tenant."}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Treasury address (Solana)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:s.treasuryAddress,onChange:l=>n(h=>({...h,treasuryAddress:l.target.value})),placeholder:"e.g., 7xKX...",required:!0})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Token symbol"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:s.tokenSymbol,onChange:l=>n(h=>({...h,tokenSymbol:l.target.value})),placeholder:"storeUSD"})]})]}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Token decimals"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:s.tokenDecimals,onChange:l=>n(h=>({...h,tokenDecimals:parseInt(l.target.value)||2})),min:"0",max:"9"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Transfer fee (basis points)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:s.transferFeeBps,onChange:l=>n(h=>({...h,transferFeeBps:parseInt(l.target.value)||0})),min:"0",max:"10000"}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"e.g., 250 = 2.5% fee on secondary market transfers"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max transfer fee (atomic)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:s.maxTransferFee,onChange:l=>n(h=>({...h,maxTransferFee:parseInt(l.target.value)||0})),min:"0"})]})]}),e.jsxs("div",{className:"cedros-admin__form-actions",style:{marginTop:"1rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:i,children:i?"Creating Mint...":"Initialize Mint"}),o&&e.jsx("span",{style:{marginLeft:"0.75rem",fontSize:13,opacity:.8},children:o})]})]})]})}function I({label:t,value:s,mono:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:t}),e.jsx("div",{style:{fontSize:13,fontFamily:n?"monospace":"inherit",wordBreak:n?"break-all":"normal",opacity:s?1:.5},children:s||"—"})]})}function lt({redemptions:t,formatDate:s}){return t.length?e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Product"}),e.jsx("th",{children:"Buyer"}),e.jsx("th",{children:"Recipient"}),e.jsx("th",{children:"Value"}),e.jsx("th",{children:"Token Minted"})]})}),e.jsx("tbody",{children:t.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{whiteSpace:"nowrap"},children:s(n.createdAt)}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.orderId.slice(0,8),"..."]})}),e.jsx("td",{children:e.jsx("code",{style:{fontSize:12},children:n.productId})}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.buyerUserId.slice(0,8),"..."]})}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.recipientUserId.slice(0,8),"..."]})}),e.jsxs("td",{children:["$",(n.faceValueCents/100).toFixed(2)," ",n.currency.toUpperCase()]}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge ${n.tokenMinted?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:n.tokenMinted?"Yes":"No"})})]},n.id))})]})}):e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"No gift card redemptions yet."})}exports.Token22Section=at;
1
+ "use strict";var Se=Object.create;var ue=Object.defineProperty;var Ce=Object.getOwnPropertyDescriptor;var ke=Object.getOwnPropertyNames;var we=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty;var Ae=(t,s,n,i)=>{if(s&&typeof s=="object"||typeof s=="function")for(let r of ke(s))!Te.call(t,r)&&r!==n&&ue(t,r,{get:()=>s[r],enumerable:!(i=Ce(s,r))||i.enumerable});return t};var me=(t,s,n)=>(n=t!=null?Se(we(t)):{},Ae(s||!t||!t.__esModule?ue(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("react"),pe=require("./index-OaWkrl0G.js"),re=require("./configApi-CxEbCAgG.js"),be=[{value:"text",label:"Short Text"},{value:"email",label:"Email"},{value:"phone",label:"Phone"},{value:"address",label:"Address"},{value:"textarea",label:"Long Text"},{value:"dropdown",label:"Dropdown"},{value:"file_upload",label:"File Upload"}],he={fields:[],requiresApproval:!0},E={width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",boxSizing:"border-box"},O={display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},Y={padding:"0.4rem 1rem",borderRadius:6,border:"1px solid rgba(0,0,0,0.2)",background:"white",cursor:"pointer",fontSize:"0.85rem"};function Ne(){return{id:Math.random().toString(36).slice(2),label:"",fieldType:"text",required:!1,options:[],placeholder:""}}function ge({field:t,onSave:s,onCancel:n}){const[i,r]=d.useState(t),[o,u]=d.useState(""),m=l=>r(h=>({...h,...l})),y=()=>{const l=o.trim();l&&(m({options:[...i.options,l]}),u(""))};return e.jsxs("div",{style:{padding:"0.75rem",border:"1px solid rgba(37,99,235,0.3)",borderRadius:6,background:"#eff6ff",marginTop:6},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.6rem",marginBottom:"0.6rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:O,children:"Label *"}),e.jsx("input",{style:E,value:i.label,onChange:l=>m({label:l.target.value}),placeholder:"e.g., Full Name"})]}),e.jsxs("div",{children:[e.jsx("label",{style:O,children:"Field Type"}),e.jsx("select",{style:E,value:i.fieldType,onChange:l=>m({fieldType:l.target.value,options:[]}),children:be.map(l=>e.jsx("option",{value:l.value,children:l.label},l.value))})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:"0.6rem",alignItems:"end",marginBottom:"0.6rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:O,children:"Placeholder"}),e.jsx("input",{style:E,value:i.placeholder??"",onChange:l=>m({placeholder:l.target.value}),placeholder:"Optional hint text"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"0.85rem",cursor:"pointer",paddingBottom:2},children:[e.jsx("input",{type:"checkbox",checked:i.required,onChange:l=>m({required:l.target.checked})})," Required"]})]}),i.fieldType==="dropdown"&&e.jsxs("div",{style:{marginBottom:"0.6rem"},children:[e.jsx("label",{style:O,children:"Options"}),i.options.map((l,h)=>e.jsxs("div",{style:{display:"flex",gap:6,marginBottom:4},children:[e.jsx("span",{style:{flex:1,fontSize:"0.85rem",padding:"0.25rem 0.5rem",background:"white",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4},children:l}),e.jsx("button",{type:"button",onClick:()=>m({options:i.options.filter((f,_)=>_!==h)}),style:{padding:"0.2rem 0.5rem",borderRadius:4,border:"1px solid rgba(0,0,0,0.2)",background:"white",cursor:"pointer",fontSize:"0.8rem",color:"#dc2626"},children:"x"})]},h)),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("input",{style:{...E,flex:1},value:o,onChange:l=>u(l.target.value),onKeyDown:l=>l.key==="Enter"&&(l.preventDefault(),y()),placeholder:"Add option..."}),e.jsx("button",{type:"button",onClick:y,style:Y,children:"Add"})]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",onClick:()=>s(i),disabled:!i.label.trim(),style:{padding:"0.35rem 1rem",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:i.label.trim()?"pointer":"not-allowed",fontSize:"0.85rem",opacity:i.label.trim()?1:.5},children:"Save Field"}),e.jsx("button",{type:"button",onClick:n,style:Y,children:"Cancel"})]})]})}function ze({fields:t,instructions:s}){const n={...E,fontSize:"0.85rem",background:"white",opacity:.6};return e.jsxs("div",{style:{padding:"1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,background:"rgba(0,0,0,0.02)"},children:[e.jsx("div",{style:{fontSize:"0.75rem",fontWeight:600,color:"rgba(0,0,0,0.4)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"0.75rem"},children:"Preview — Redeemer View"}),s&&e.jsx("div",{style:{padding:"0.6rem 0.75rem",background:"#fffbeb",border:"1px solid #fcd34d",borderRadius:6,fontSize:"0.85rem",marginBottom:"0.75rem",color:"#92400e"},children:s}),t.length===0&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.35)",fontStyle:"italic"},children:"No fields added yet."}),t.map(i=>e.jsxs("div",{style:{marginBottom:"0.6rem"},children:[e.jsxs("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:[i.label||"Unlabelled field",i.required&&e.jsx("span",{style:{color:"#dc2626",marginLeft:2},children:"*"})]}),i.fieldType==="textarea"&&e.jsx("textarea",{disabled:!0,rows:2,placeholder:i.placeholder??"",style:{...n,resize:"none"}}),i.fieldType==="file_upload"&&e.jsx("div",{style:{padding:"0.5rem",border:"1px dashed rgba(0,0,0,0.25)",borderRadius:4,fontSize:"0.8rem",color:"rgba(0,0,0,0.4)",textAlign:"center"},children:"File upload"}),i.fieldType==="dropdown"&&e.jsxs("select",{disabled:!0,style:n,children:[e.jsx("option",{children:i.placeholder||"Select..."}),i.options.map((r,o)=>e.jsx("option",{children:r},o))]}),!["textarea","file_upload","dropdown"].includes(i.fieldType)&&e.jsx("input",{disabled:!0,type:i.fieldType==="email"?"email":i.fieldType==="phone"?"tel":"text",placeholder:i.placeholder??"",style:n})]},i.id))]})}function Be({value:t,onChange:s}){const n=t!==null,i=t??he,[r,o]=d.useState(null),[u,m]=d.useState(null),[y,l]=d.useState(!1),h=p=>s({...i,...p}),f=()=>{o(null),m(null)},_=p=>{s(p?{...he}:null),f()},b=()=>{const p=Ne();m(p),o("new")},g=p=>{m({...p}),o(p.id)},j=p=>{h({fields:r==="new"?[...i.fields,p]:i.fields.map(C=>C.id===p.id?p:C)}),f()},k=p=>{r===p&&f(),h({fields:i.fields.filter(C=>C.id!==p)})};return e.jsxs("div",{children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",marginBottom:n?"1rem":4,fontSize:"0.9rem",fontWeight:500},children:[e.jsx("input",{type:"checkbox",checked:n,onChange:p=>_(p.target.checked)}),"Enable Redemption Form"]}),!n&&e.jsx("div",{style:{fontSize:"0.8rem",color:"rgba(0,0,0,0.4)"},children:"No redemption form — token holders cannot request physical redemption."}),n&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:O,children:"Instructions shown to redeemer"}),e.jsx("textarea",{value:i.instructions??"",onChange:p=>h({instructions:p.target.value||void 0}),placeholder:"Describe requirements, turnaround times, etc.",rows:3,style:{...E,resize:"vertical"}})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"1rem",alignItems:"center",padding:"0.6rem 0.75rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:6,background:"rgba(0,0,0,0.02)"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,fontSize:"0.85rem",cursor:"pointer",whiteSpace:"nowrap"},children:[e.jsx("input",{type:"checkbox",checked:i.requiresApproval,onChange:p=>h({requiresApproval:p.target.checked})})," Requires admin approval"]}),e.jsxs("div",{children:[e.jsx("label",{style:O,children:"Estimated processing days"}),e.jsx("input",{type:"number",min:0,value:i.estimatedProcessingDays??"",onChange:p=>h({estimatedProcessingDays:p.target.value?Number(p.target.value):void 0}),placeholder:"e.g., 5",style:{...E,maxWidth:120}})]})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:"0.8rem",fontWeight:500,marginBottom:"0.5rem"},children:["Form Fields (",i.fields.length,")"]}),i.fields.length===0&&r!=="new"&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.35)",fontStyle:"italic",marginBottom:"0.5rem"},children:"No fields yet. Add fields below."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"0.4rem"},children:[i.fields.map(p=>e.jsxs("div",{children:[e.jsxs("div",{style:{padding:"0.5rem 0.75rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:6,background:"white",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:"0.9rem"},children:p.label||e.jsx("em",{style:{color:"rgba(0,0,0,0.35)"},children:"Unlabelled"})}),e.jsx("span",{style:{padding:"2px 8px",borderRadius:10,background:"#dbeafe",color:"#1d4ed8",fontSize:"0.75rem"},children:be.find(C=>C.value===p.fieldType)?.label??p.fieldType}),p.required&&e.jsx("span",{style:{padding:"2px 8px",borderRadius:10,background:"#fef3c7",color:"#92400e",fontSize:"0.75rem"},children:"required"})]}),e.jsxs("div",{style:{display:"flex",gap:4},children:[e.jsx("button",{type:"button",onClick:()=>g(p),style:{...Y,padding:"0.25rem 0.6rem",fontSize:"0.8rem"},children:"Edit"}),e.jsx("button",{type:"button",onClick:()=>k(p.id),style:{padding:"0.25rem 0.6rem",borderRadius:4,border:"1px solid rgba(220,38,38,0.3)",background:"white",cursor:"pointer",fontSize:"0.8rem",color:"#dc2626"},children:"Delete"})]})]}),r===p.id&&u&&e.jsx(ge,{field:u,onSave:j,onCancel:f})]},p.id)),r==="new"&&u&&e.jsx(ge,{field:u,onSave:j,onCancel:f})]}),r===null&&e.jsx("button",{type:"button",onClick:b,style:{...Y,marginTop:"0.5rem"},children:"+ Add Field"})]}),e.jsxs("div",{children:[e.jsx("button",{type:"button",onClick:()=>l(p=>!p),style:{...Y,background:y?"rgba(0,0,0,0.05)":"white"},children:y?"Hide Preview":"Show Preview"}),y&&e.jsx("div",{style:{marginTop:"0.75rem"},children:e.jsx(ze,{fields:i.fields,instructions:i.instructions})})]})]})]})}const Pe=[{value:"securities",label:"Securities (fungible)"},{value:"commodities",label:"Commodities (fungible)"},{value:"property",label:"Property (non-fungible)"},{value:"collectibles",label:"Collectibles (non-fungible)"}],Me=t=>t==="securities"||t==="commodities";function De({c:t,onDeployPool:s,onEdit:n,onDelete:i}){const r=t.tokenizationConfig,o=Me(r.assetClass);return e.jsxs("div",{style:{padding:"0.75rem 1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,background:"white"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("strong",{children:t.name}),e.jsx("span",{style:{marginLeft:8,fontSize:"0.8rem",padding:"2px 8px",borderRadius:10,background:o?"#dbeafe":"#fef3c7",color:o?"#1d4ed8":"#92400e"},children:r.assetClass}),r.tokenSymbol&&e.jsx("span",{style:{marginLeft:6,fontSize:"0.8rem",color:"rgba(0,0,0,0.5)"},children:r.tokenSymbol})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:"0.8rem"},children:[r.mintAddress?e.jsx("span",{style:{color:"#16a34a"},children:"Mint initialized"}):e.jsx("span",{style:{color:"rgba(0,0,0,0.4)"},children:"No mint"}),o&&r.mintAddress&&(r.liquidityPoolAddress?e.jsxs("span",{style:{padding:"2px 8px",borderRadius:10,background:"#dcfce7",color:"#15803d",fontSize:"0.75rem"},children:["Pool Active · ",r.liquidityPoolAddress.slice(0,4),"...",r.liquidityPoolAddress.slice(-4)]}):e.jsx("button",{type:"button",onClick:s,style:{padding:0,border:"none",background:"none",color:"#2563eb",cursor:"pointer",fontSize:"0.8rem",textDecoration:"underline"},children:"Deploy Pool"}))]})]}),t.description&&e.jsx("div",{style:{fontSize:"0.85rem",color:"rgba(0,0,0,0.5)",marginTop:4},children:t.description}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:6},children:[e.jsxs("div",{style:{display:"flex",gap:"1rem",flexWrap:"wrap",fontSize:"0.8rem",color:"rgba(0,0,0,0.4)"},children:[e.jsxs("span",{children:["Fee: ",r.transferFeeBps," bps"]}),r.treasuryAddress&&e.jsxs("span",{children:["Treasury: ",r.treasuryAddress.slice(0,8),"..."]}),r.allowedJurisdictions?.length>0&&e.jsxs("span",{style:{padding:"1px 7px",borderRadius:10,background:"#f3f4f6",color:"rgba(0,0,0,0.55)"},children:[r.allowedJurisdictions.length," jurisdiction",r.allowedJurisdictions.length!==1?"s":"",": ",r.allowedJurisdictions.join(", ")]})]}),e.jsxs("div",{style:{display:"flex",gap:6},children:[n&&e.jsx("button",{type:"button",onClick:n,style:{padding:"2px 10px",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4,background:"white",cursor:"pointer",fontSize:"0.75rem",color:"#2563eb"},children:"Edit"}),i&&e.jsx("button",{type:"button",onClick:i,style:{padding:"2px 10px",border:"1px solid rgba(0,0,0,0.15)",borderRadius:4,background:"white",cursor:"pointer",fontSize:"0.75rem",color:"#dc2626"},children:"Delete"})]})]})]})}const ne={name:"",description:"",assetClass:"securities",tokenSymbol:"",tokenDecimals:2,transferFeeBps:250,maxTransferFee:500,treasuryAddress:"",regulatoryNotice:"",jurisdictions:"",redemptionConfig:null};function Re({serverUrl:t,apiKey:s,authManager:n,onNavigateToLiquidity:i}){const[r,o]=d.useState([]),[u,m]=d.useState(!0),[y,l]=d.useState(null),[h,f]=d.useState(!1),[_,b]=d.useState(!1),[g,j]=d.useState(ne),[k,p]=d.useState(null),C=d.useCallback(async(c,x)=>{if(n?.isAuthenticated())return n.fetchWithAuth(c,x);const D={"Content-Type":"application/json"};s&&(D["X-API-Key"]=s);const v=await fetch(`${t}${c}`,{...x,headers:{...D,...x?.headers}});if(!v.ok){const N=await v.text().catch(()=>`HTTP ${v.status}`);throw new Error(N)}return v.json()},[t,s,n]),w=d.useCallback(async()=>{try{m(!0),l(null);const c=await C("/admin/collections");o((c.collections||[]).filter(x=>x.tokenizationConfig))}catch(c){l(c instanceof Error?c.message:"Failed to load asset classes")}finally{m(!1)}},[C]);d.useEffect(()=>{w()},[w]);const a=()=>({name:g.name.trim(),description:g.description||void 0,active:!0,productIds:[],tokenizationConfig:{assetClass:g.assetClass,tokenSymbol:g.tokenSymbol||void 0,tokenDecimals:g.tokenDecimals,transferFeeBps:g.transferFeeBps,maxTransferFee:g.maxTransferFee,treasuryAddress:g.treasuryAddress||void 0,regulatoryNotice:g.regulatoryNotice||void 0,allowedJurisdictions:g.jurisdictions?g.jurisdictions.split(",").map(c=>c.trim().toUpperCase()).filter(Boolean):[],redemptionConfig:g.redemptionConfig||void 0}}),S=async()=>{if(g.name.trim()){b(!0),l(null);try{k?await C(`/admin/collections/${encodeURIComponent(k)}`,{method:"PUT",body:JSON.stringify(a())}):await C("/admin/collections",{method:"POST",body:JSON.stringify(a())}),j(ne),f(!1),p(null),await w()}catch(c){l(c instanceof Error?c.message:`Failed to ${k?"update":"create"} asset class`)}finally{b(!1)}}},A=c=>{const x=c.tokenizationConfig;j({name:c.name,description:c.description??"",assetClass:x.assetClass,tokenSymbol:x.tokenSymbol??"",tokenDecimals:x.tokenDecimals,transferFeeBps:x.transferFeeBps,maxTransferFee:x.maxTransferFee,treasuryAddress:x.treasuryAddress??"",regulatoryNotice:x.regulatoryNotice??"",jurisdictions:x.allowedJurisdictions.join(", "),redemptionConfig:null}),p(c.id),f(!0)},T=async c=>{if(window.confirm(`Delete asset class "${c.name}"? This cannot be undone.`)){l(null);try{await C(`/admin/collections/${encodeURIComponent(c.id)}`,{method:"DELETE"}),await w()}catch(x){l(x instanceof Error?x.message:"Failed to delete asset class")}}};return u?e.jsx("div",{style:{padding:"1rem 0",color:"rgba(0,0,0,0.5)"},children:"Loading asset classes..."}):e.jsxs("div",{children:[y&&e.jsx("div",{style:{padding:"0.75rem 1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:6,color:"#dc2626",marginBottom:"1rem",fontSize:"0.9rem"},children:y}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1rem"},children:[e.jsxs("h4",{style:{margin:0},children:["Asset Classes (",r.length,")"]}),e.jsx("button",{type:"button",onClick:()=>{f(!h),h&&(p(null),j(ne))},style:{padding:"0.4rem 1rem",borderRadius:6,border:"1px solid rgba(0,0,0,0.2)",background:h?"rgba(0,0,0,0.05)":"white",cursor:"pointer",fontSize:"0.85rem"},children:h?"Cancel":"+ New Asset Class"})]}),h&&e.jsxs("div",{style:{padding:"1rem",border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,marginBottom:"1rem",background:"rgba(0,0,0,0.02)"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",marginBottom:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Name *"}),e.jsx("input",{type:"text",value:g.name,onChange:c=>j(x=>({...x,name:c.target.value})),placeholder:"e.g., Gold Tokens",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Asset Class *"}),e.jsx("select",{value:g.assetClass,onChange:c=>j(x=>({...x,assetClass:c.target.value})),style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"},children:Pe.map(c=>e.jsx("option",{value:c.value,children:c.label},c.value))})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"0.75rem",marginBottom:"0.75rem"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Token Symbol"}),e.jsx("input",{type:"text",value:g.tokenSymbol,onChange:c=>j(x=>({...x,tokenSymbol:c.target.value})),placeholder:"e.g., GOLD",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Transfer Fee (bps)"}),e.jsx("input",{type:"number",value:g.transferFeeBps,onChange:c=>j(x=>({...x,transferFeeBps:Number(c.target.value)})),style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Treasury Address"}),e.jsx("input",{type:"text",value:g.treasuryAddress,onChange:c=>j(x=>({...x,treasuryAddress:c.target.value})),placeholder:"Solana address",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Allowed Jurisdictions"}),e.jsx("input",{type:"text",value:g.jurisdictions,onChange:c=>j(x=>({...x,jurisdictions:c.target.value})),placeholder:"US, CA, GB (comma-separated, leave empty for all)",style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem"}})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Regulatory Notice"}),e.jsx("textarea",{value:g.regulatoryNotice,onChange:c=>j(x=>({...x,regulatoryNotice:c.target.value})),placeholder:"Shown to buyers before purchase",rows:2,style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",resize:"vertical"}})]}),e.jsxs("div",{style:{marginBottom:"0.75rem"},children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:600,marginBottom:8},children:"Redemption Form"}),e.jsx(Be,{value:g.redemptionConfig,onChange:c=>j(x=>({...x,redemptionConfig:c}))})]}),e.jsx("button",{type:"button",onClick:S,disabled:_||!g.name.trim(),style:{padding:"0.5rem 1.5rem",borderRadius:6,border:"none",background:"#2563eb",color:"white",cursor:_?"wait":"pointer",fontSize:"0.9rem",opacity:_?.6:1},children:_?"Saving...":k?"Save Changes":"Create Asset Class"})]}),r.length===0?e.jsx("div",{style:{padding:"2rem",textAlign:"center",color:"rgba(0,0,0,0.4)",fontSize:"0.9rem"},children:"No asset classes configured. Create one to start tokenizing off-chain assets."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.5rem"},children:r.map(c=>e.jsx(De,{c,onDeployPool:i,onEdit:()=>A(c),onDelete:()=>T(c)},c.id))})]})}const Ie=[{value:"",label:"All statuses"},{value:"pending_info",label:"Pending Info"},{value:"info_submitted",label:"Info Submitted"},{value:"under_review",label:"Under Review"},{value:"approved",label:"Approved"},{value:"completed",label:"Completed"},{value:"rejected",label:"Rejected"}];function Fe(t){switch(t){case"pending_info":return"cedros-admin__badge cedros-admin__badge--muted";case"info_submitted":return"cedros-admin__badge cedros-admin__badge--info";case"under_review":return"cedros-admin__badge cedros-admin__badge--warning";case"approved":return"cedros-admin__badge cedros-admin__badge--success";case"completed":return"cedros-admin__badge cedros-admin__badge--success";case"rejected":return"cedros-admin__badge cedros-admin__badge--failed";default:return"cedros-admin__badge cedros-admin__badge--muted"}}function Le(t){return t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Ee(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function q(t){return t.length>12?`${t.slice(0,8)}…`:t}function ye(t){return`https://solscan.io/tx/${t}`}function Oe({redemption:t,onAction:s,onComplete:n,actionBusy:i}){const[r,o]=d.useState(t.adminNotes??""),u=Object.entries(t.formData??{});return e.jsx("div",{style:{padding:"1rem 1.25rem",background:"rgba(0,0,0,0.02)",borderTop:"1px solid rgba(0,0,0,0.08)"},children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"1.5rem"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:"0.8rem",marginBottom:8,textTransform:"uppercase",letterSpacing:"0.05em",opacity:.6},children:"Form Data"}),u.length===0?e.jsx("div",{style:{fontSize:"0.85rem",opacity:.5},children:"No form data submitted."}):e.jsx("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",fontSize:"0.85rem"},children:u.map(([m,y])=>e.jsxs(e.Fragment,{children:[e.jsx("dt",{style:{fontWeight:500,color:"rgba(0,0,0,0.6)",whiteSpace:"nowrap"},children:m},`k-${m}`),e.jsx("dd",{style:{margin:0,wordBreak:"break-word"},children:String(y??"—")},`v-${m}`)]}))}),(t.tokenMintSignature||t.tokenBurnSignature)&&e.jsxs("div",{style:{marginTop:12,fontSize:"0.8rem"},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:4,opacity:.6,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Signatures"}),t.tokenMintSignature&&e.jsxs("div",{children:["Mint:"," ",e.jsx("a",{href:ye(t.tokenMintSignature),target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:q(t.tokenMintSignature)})]}),t.tokenBurnSignature&&e.jsxs("div",{children:["Burn:"," ",e.jsx("a",{href:ye(t.tokenBurnSignature),target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:q(t.tokenBurnSignature)})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Admin Notes"}),e.jsx("textarea",{value:r,onChange:m=>o(m.target.value),rows:4,style:{width:"100%",padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.85rem",resize:"vertical",boxSizing:"border-box"},placeholder:"Internal notes (not shown to user)..."}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginTop:8,flexWrap:"wrap"},children:[t.status==="info_submitted"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:i,onClick:()=>s(t.id,"under_review",r),children:i?"Saving...":"Mark Under Review"}),t.status==="under_review"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:i,onClick:()=>s(t.id,"approved",r),children:i?"Saving...":"Approve"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",disabled:i,onClick:()=>s(t.id,"rejected",r),children:i?"Saving...":"Reject"})]}),t.status==="approved"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:i,onClick:()=>n(t.id),children:i?"Processing...":"Complete"})]})]})]})})}function qe({serverUrl:t,apiKey:s,authManager:n}){const[i,r]=d.useState([]),[o,u]=d.useState(!0),[m,y]=d.useState(null),[l,h]=d.useState(""),[f,_]=d.useState(null),[b,g]=d.useState(null),j=d.useCallback(async(a,S)=>{if(n?.isAuthenticated())return n.fetchWithAuth(a,S);const A={"Content-Type":"application/json"};s&&(A["X-API-Key"]=s);const T=await fetch(`${t}${a}`,{...S,headers:{...A,...S?.headers}});if(!T.ok){const c=await T.text().catch(()=>`HTTP ${T.status}`);throw new Error(c)}return T.json()},[t,s,n]),k=d.useCallback(async()=>{u(!0),y(null);try{const a=l?`?status=${encodeURIComponent(l)}&limit=50&offset=0`:"?limit=50&offset=0",S=await j(`/admin/asset-redemptions${a}`);r(S.redemptions??[])}catch(a){y(a instanceof Error?a.message:"Failed to load redemptions")}finally{u(!1)}},[j,l]);d.useEffect(()=>{k()},[k]);const p=d.useCallback(async(a,S,A)=>{g(a),y(null);try{await j(`/admin/asset-redemptions/${a}/status`,{method:"PATCH",body:JSON.stringify({status:S,adminNotes:A})}),_(null),await k()}catch(T){y(T instanceof Error?T.message:"Failed to update status")}finally{g(null)}},[j,k]),C=d.useCallback(async a=>{g(a),y(null);try{await j(`/admin/asset-redemptions/${a}/complete`,{method:"POST"}),_(null),await k()}catch(S){y(S instanceof Error?S.message:"Failed to complete redemption")}finally{g(null)}},[j,k]),w=a=>{_(S=>S===a?null:a)};return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.75rem",marginBottom:"1rem",flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"0.8rem",fontWeight:500,marginBottom:4},children:"Status"}),e.jsx("select",{value:l,onChange:a=>{h(a.target.value),_(null)},style:{padding:"0.4rem 0.6rem",border:"1px solid rgba(0,0,0,0.2)",borderRadius:4,fontSize:"0.9rem",minWidth:160},children:Ie.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))})]}),e.jsx("div",{style:{alignSelf:"flex-end"},children:e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline",onClick:k,disabled:o,children:o?"Loading...":"Refresh"})})]}),m&&e.jsx("div",{style:{padding:"0.75rem 1rem",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:6,color:"#dc2626",marginBottom:"1rem",fontSize:"0.9rem"},children:m}),o?e.jsx("div",{className:"cedros-admin__loading",children:"Loading redemptions..."}):i.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No redemption requests found."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Product"}),e.jsx("th",{children:"Collection"}),e.jsx("th",{children:"User"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Actions"})]})}),e.jsx("tbody",{children:i.map(a=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{style:{cursor:"pointer"},onClick:()=>w(a.id),children:[e.jsx("td",{children:Ee(a.createdAt)}),e.jsx("td",{children:e.jsx("code",{title:a.orderId,children:q(a.orderId)})}),e.jsx("td",{children:e.jsx("code",{title:a.productId,children:q(a.productId)})}),e.jsx("td",{children:e.jsx("code",{title:a.collectionId,children:q(a.collectionId)})}),e.jsx("td",{children:a.userId?e.jsx("code",{title:a.userId,children:q(a.userId)}):e.jsx("span",{style:{opacity:.4},children:"—"})}),e.jsx("td",{children:e.jsx("span",{className:Fe(a.status),children:Le(a.status)})}),e.jsx("td",{onClick:S=>S.stopPropagation(),children:e.jsxs("div",{style:{display:"flex",gap:"0.4rem",flexWrap:"wrap"},children:[(a.status==="info_submitted"||a.status==="under_review"||a.status==="approved")&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--sm",onClick:()=>w(a.id),children:f===a.id?"Close":"Review"}),a.status==="under_review"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:b===a.id,onClick:()=>p(a.id,"approved",a.adminNotes??""),children:"Approve"}),e.jsx("button",{className:"cedros-admin__button cedros-admin__button--outline cedros-admin__button--danger cedros-admin__button--sm",disabled:b===a.id,onClick:()=>p(a.id,"rejected",a.adminNotes??""),children:"Reject"})]}),a.status==="approved"&&e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary cedros-admin__button--sm",disabled:b===a.id,onClick:()=>C(a.id),children:b===a.id?"Processing...":"Complete"})]})})]},a.id),f===a.id&&e.jsx("tr",{children:e.jsx("td",{colSpan:7,style:{padding:0},children:e.jsx(Oe,{redemption:a,onAction:p,onComplete:C,actionBusy:b===a.id})})},`${a.id}-detail`)]}))})]})})]})}const $e={CA:{cashOutCents:1500,expirationProhibited:!0,escheatmentYears:3,notes:"Cash-out threshold increases to $15 on April 1, 2026."},CO:{cashOutCents:500,escheatmentYears:5},CT:{cashOutCents:300,escheatmentYears:3},FL:{expirationProhibited:!0,escheatmentYears:5},ME:{cashOutCents:500,escheatmentYears:3},MA:{cashOutCents:500,escheatmentYears:3,notes:"Cash-out also required when 90% of value is used."},MT:{cashOutCents:500,escheatmentYears:5},NJ:{cashOutCents:500,escheatmentYears:3},OR:{cashOutCents:500,escheatmentYears:3,notes:"May require at least one prior transaction."},RI:{cashOutCents:100,escheatmentYears:3},TX:{cashOutCents:250,escheatmentYears:3},VT:{cashOutCents:100,escheatmentYears:3},WA:{cashOutCents:500,escheatmentYears:5},PR:{cashOutCents:500,escheatmentYears:5}},ae={escheatmentYears:5},V=1e6,We={AL:"Alabama",AK:"Alaska",AZ:"Arizona",AR:"Arkansas",CA:"California",CO:"Colorado",CT:"Connecticut",DE:"Delaware",FL:"Florida",GA:"Georgia",HI:"Hawaii",ID:"Idaho",IL:"Illinois",IN:"Indiana",IA:"Iowa",KS:"Kansas",KY:"Kentucky",LA:"Louisiana",ME:"Maine",MD:"Maryland",MA:"Massachusetts",MI:"Michigan",MN:"Minnesota",MS:"Mississippi",MO:"Missouri",MT:"Montana",NE:"Nebraska",NV:"Nevada",NH:"New Hampshire",NJ:"New Jersey",NM:"New Mexico",NY:"New York",NC:"North Carolina",ND:"North Dakota",OH:"Ohio",OK:"Oklahoma",OR:"Oregon",PA:"Pennsylvania",RI:"Rhode Island",SC:"South Carolina",SD:"South Dakota",TN:"Tennessee",TX:"Texas",UT:"Utah",VT:"Vermont",VA:"Virginia",WA:"Washington",WV:"West Virginia",WI:"Wisconsin",WY:"Wyoming",DC:"District of Columbia",PR:"Puerto Rico"};function Ye({serverUrl:t,authManager:s}){const[n,i]=d.useState(null),[r,o]=d.useState(null),[u,m]=d.useState(null),[y,l]=d.useState(!0),h=d.useCallback(async()=>{try{const j=(await new re.ConfigApiClient(t,void 0,s).getConfig("gift_cards")).config??{};i(j.business_state||null),o(j.min_gift_card_value_cents!=null?Number(j.min_gift_card_value_cents):null),m(j.max_gift_card_value_cents!=null?Number(j.max_gift_card_value_cents):null)}catch{}finally{l(!1)}},[t,s]);if(d.useEffect(()=>{h()},[h]),y)return e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"Loading compliance data..."});const f=n?$e[n]??ae:null,_=n?We[n]??n:null;return e.jsx("div",{children:n?e.jsxs(e.Fragment,{children:[e.jsxs("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:["Compliance Guidance — ",_]}),e.jsxs("div",{style:{display:"grid",gap:"1rem",maxWidth:720},children:[e.jsx(Ke,{reg:f,minValueCents:r}),e.jsx(He,{reg:f}),e.jsx(Ge,{reg:f}),e.jsx(Je,{maxValueCents:u})]}),e.jsx(Ve,{reg:f,minValueCents:r,maxValueCents:u})]}):e.jsx(Ue,{})})}function Ue(){return e.jsxs("div",{style:{padding:"2rem",textAlign:"center"},children:[e.jsx("p",{style:{fontSize:15,opacity:.7,marginBottom:"0.5rem"},children:"No business state configured."}),e.jsxs("p",{style:{fontSize:13,opacity:.5},children:["Set your ",e.jsx("strong",{children:"business_state"})," in the Gift Cards config category to see state-specific compliance guidance."]})]})}function U({title:t,children:s}){return e.jsxs("div",{style:{border:"1px solid rgba(0,0,0,0.1)",borderRadius:8,padding:"1rem 1.25rem"},children:[e.jsx("h4",{style:{margin:"0 0 0.5rem",fontSize:14,fontWeight:600},children:t}),e.jsx("div",{style:{fontSize:13,lineHeight:1.6},children:s})]})}function Ke({reg:t,minValueCents:s}){if(!t.cashOutCents)return e.jsx(U,{title:"Cash-Out Threshold",children:e.jsx("p",{style:{margin:0},children:"Your state does not have a specific cash-out threshold for gift cards. Federal law does not require cash redemption."})});const n=(t.cashOutCents/100).toFixed(2),i=s!=null&&s>t.cashOutCents;return e.jsxs(U,{title:"Cash-Out Threshold",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Your state requires cash redemption for gift cards with a remaining balance of ",e.jsxs("strong",{children:["$",n]})," or less."]}),e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Since this system uses ",e.jsx("strong",{children:"one-shot full redemption"})," (entire gift card value is converted to credits at once), cash-out is avoided by setting the minimum gift card face value above the threshold."]}),i?e.jsxs(X,{ok:!0,children:["Min value ($",((s??0)/100).toFixed(2),") exceeds threshold"]}):e.jsxs(X,{ok:!1,children:["Set ",e.jsx("code",{children:"min_gift_card_value_cents"})," above ",t.cashOutCents," to avoid cash-out obligations"]}),t.notes&&e.jsx("p",{style:{margin:"0.5rem 0 0",opacity:.7,fontStyle:"italic"},children:t.notes})]})}function He({reg:t}){return e.jsx(U,{title:"Expiration Rules",children:t.expirationProhibited?e.jsxs("p",{style:{margin:0},children:["Your state ",e.jsx("strong",{children:"prohibits"})," gift card expiration. Do not set expiration dates on gift cards."]}):e.jsxs("p",{style:{margin:0},children:["Federal law (CARD Act) requires gift cards to remain valid for at least ",e.jsx("strong",{children:"5 years"})," from purchase or last reload. Your state follows the federal minimum."]})})}function Ge({reg:t}){const s=t.escheatmentYears??ae.escheatmentYears;return e.jsxs(U,{title:"Escheatment (Unclaimed Property)",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["Gift card balances unredeemed for ",e.jsxs("strong",{children:[s," years"]})," may need to be reported and remitted to the state as unclaimed property."]}),e.jsxs("p",{style:{margin:0,opacity:.7},children:["The system tracks ",e.jsx("code",{children:"last_activity_at"})," on gift card redemptions to help identify dormant balances approaching the escheatment window."]})]})}function Je({maxValueCents:t}){const s=t??V,n=s<=V;return e.jsxs(U,{title:"Anti-Money Laundering (AML)",children:[e.jsxs("p",{style:{margin:"0 0 0.5rem"},children:["FinCEN requires closed-loop prepaid cards to stay at or below ",e.jsx("strong",{children:"$10,000"})," per card. The server enforces this cap on product creation."]}),n?e.jsxs(X,{ok:!0,children:["Max value ($",(s/100).toFixed(2),") within AML limit"]}):e.jsxs(X,{ok:!1,children:[e.jsx("code",{children:"max_gift_card_value_cents"})," exceeds $10,000 AML cap"]})]})}function X({ok:t,children:s}){return e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 10px",borderRadius:6,fontSize:13,fontWeight:500,background:t?"rgba(34,197,94,0.1)":"rgba(234,179,8,0.15)",color:t?"#16a34a":"#a16207"},children:[e.jsx("span",{children:t?"✓":"⚠"}),s]})}function Ve({reg:t,minValueCents:s,maxValueCents:n}){const r=[{label:"AML: Max card value ≤ $10,000",ok:(n??V)<=V},...t.cashOutCents?[{label:`Cash-out: Min value > $${(t.cashOutCents/100).toFixed(2)} threshold`,ok:s!=null&&s>t.cashOutCents}]:[],{label:t.expirationProhibited?"Expiration: State prohibits expiration (no action needed)":"Expiration: Federal 5-year minimum applies",ok:!0},{label:`Escheatment: ${t.escheatmentYears??ae.escheatmentYears}-year dormancy tracking enabled`,ok:!0}];return e.jsxs("div",{style:{marginTop:"1.5rem"},children:[e.jsx("h4",{style:{fontSize:14,fontWeight:600,marginBottom:"0.75rem"},children:"Compliance Checklist"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:r.map((o,u)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[e.jsx("span",{style:{color:o.ok?"#16a34a":"#d97706",fontWeight:600},children:o.ok?"✓":"⚠"}),e.jsx("span",{children:o.label})]},u))})]})}const Xe=0;class Ze{dlmmModule=null;bnClass=null;keypairClass=null;async loadDLMM(){if(this.dlmmModule)return this.dlmmModule;try{const s=await Promise.resolve().then(()=>require("./pay-react_false-DaeIe3_l.js"));return this.dlmmModule=s.default??s,this.dlmmModule}catch{throw new Error("Install @meteora-ag/dlmm to enable pool deployment: npm install @meteora-ag/dlmm")}}async loadBN(){if(this.bnClass)return this.bnClass;const s=await Promise.resolve().then(()=>require("./bn-CHyy7EgJ.js")).then(n=>n.bn);return this.bnClass=s.default??s,this.bnClass}async loadKeypair(){if(this.keypairClass)return this.keypairClass;const{Keypair:s}=await import("@solana/web3.js");return this.keypairClass=s,this.keypairClass}async computeBinId(s,n,i,r=1){const o=await this.loadDLMM(),u=o.getPricePerLamport(n,i,s);return o.getBinIdFromPrice(u,r,!0)}async findPresetParameter(s,n,i){const r=await this.loadDLMM(),o=i?{cluster:i}:void 0,{presetParameter2:u}=await r.getAllPresetParameters(s,o),m=u.find(y=>y.account.binStep===n);if(!m)throw new Error(`No PresetParameter2 found for binStep=${n}. Available: ${u.map(y=>y.account.binStep).join(", ")}`);return m.publicKey}async createPool(s,n,i,r,o,u=1,m){const y=await this.loadDLMM(),l=await this.loadBN(),h=m?{cluster:m}:void 0,f=await this.findPresetParameter(s,u,m),_=await y.createLbPair2(s,n,i,r,f,new l(o),h),b=_.instructions[0]?.keys?.[1]?.pubkey;if(!b)throw new Error("Failed to extract pool address from transaction");return{transaction:_,poolAddress:b}}async addBuybackLiquidity(s,n,i,r,o,u){const m=await this.loadDLMM(),y=await this.loadBN(),l=await this.loadKeypair(),h=u?{cluster:u}:void 0,f=await m.create(s,i,h),_=l.generate(),b=o-1,g=o;return{transaction:await f.initializePositionAndAddLiquidityByStrategy({positionPubKey:_.publicKey,totalXAmount:new y(0),totalYAmount:new y(r),strategy:{maxBinId:g,minBinId:b,strategyType:Xe},user:n,slippage:1}),positionKeypair:_}}async getPoolStatus(s,n,i){const r=await this.loadDLMM(),o=i?{cluster:i}:void 0,u=await r.create(s,n,o),m=await u.getActiveBin();return{address:n.toBase58(),activeBinId:m.binId,activeBinPrice:m.price,binStep:u.lbPair.binStep}}}const W=6,ie=1,Qe="https://solscan.io/account",et="https://app.meteora.ag/dlmm";function tt({serverUrl:t,authManager:s,mintConfigured:n,mintAddress:i,tokenDecimals:r=2}){const[o,u]=d.useState({liquidityPoolAddress:null,buybackRateBps:null,rpcUrl:null,usdcMint:null,usdcAmount:null,deployedAt:null}),[m,y]=d.useState(!0),[l,h]=d.useState(80),[f,_]=d.useState(250),[b,g]=d.useState("idle"),[j,k]=d.useState(null),[p,C]=d.useState(null),[w,a]=d.useState(null),S=d.useRef(new Ze),A=d.useCallback(async()=>{try{const z=new re.ConfigApiClient(t,void 0,s),[R,F]=await Promise.all([z.getConfig("gift_cards"),z.getConfig("x402")]),B=R.config??{},P=F.config??{},M=B.liquidity_pool_address||null;u({liquidityPoolAddress:M,buybackRateBps:B.buyback_rate_bps!=null?Number(B.buyback_rate_bps):null,rpcUrl:P.rpc_url||null,usdcMint:P.token_mint||null,usdcAmount:B.liquidity_usdc_amount!=null?Number(B.liquidity_usdc_amount):null,deployedAt:B.liquidity_deployed_at||null}),M&&C(M),B.buyback_rate_bps!=null&&h(Number(B.buyback_rate_bps)/100)}catch{}finally{y(!1)}},[t,s]);d.useEffect(()=>{A()},[A]);const T=typeof window<"u"&&!!window.solana?.publicKey,c=!!o.rpcUrl,x=!!o.usdcMint,D=n&&T&&c&&x&&b==="idle",v=async z=>{if(!(!i||!o.rpcUrl||!o.usdcMint)){g(z),k(null),a(null);try{const{Connection:R,PublicKey:F,Keypair:B}=await import("@solana/web3.js"),P=new R(o.rpcUrl,"confirmed"),M=window.solana;if(!M?.publicKey||!M.signTransaction)throw new Error("Wallet not connected");const H=S.current,oe=new F(M.publicKey.toBase58()),je=l/100,ve=await H.computeBinId(je,r,W,ie);let L=p;if(z==="creating_pool"){const $=new F(i),Z=new F(o.usdcMint),G=await H.computeBinId(1,r,W,ie),{transaction:Q,poolAddress:ee}=await H.createPool(P,oe,$,Z,G,ie),te=await M.signTransaction(Q),se=await P.sendRawTransaction(te.serialize());await P.confirmTransaction(se,"confirmed"),L=ee.toBase58(),C(L)}if(z==="creating_pool"||z==="adding_liquidity"){if(g("adding_liquidity"),!L)throw new Error("Pool address not available");const $=new F(L),Z=Math.round(f*10**W),{transaction:G,positionKeypair:Q}=await H.addBuybackLiquidity(P,oe,$,Z,ve),ee=B.fromSecretKey(Q.secretKey);G.partialSign(ee);const te=await M.signTransaction(G),se=await P.sendRawTransaction(te.serialize());await P.confirmTransaction(se,"confirmed")}if(g("saving_config"),!L)throw new Error("Pool address not available");const _e=new re.ConfigApiClient(t,void 0,s),le=Math.round(l*100),de=Math.round(f*10**W),ce=new Date().toISOString();await _e.patchConfig("gift_cards",{liquidity_pool_address:L,buyback_rate_bps:le,liquidity_usdc_amount:de,liquidity_deployed_at:ce},"Meteora DLMM pool deployed for gift card buyback"),u($=>({...$,liquidityPoolAddress:L,buybackRateBps:le,usdcAmount:de,deployedAt:ce})),g("done")}catch(R){a(b==="idle"?z:b),k(R instanceof Error?R.message:"Deployment failed"),g("error")}}},N=()=>{D&&v("creating_pool")},K=()=>{!w||w==="idle"||w==="done"||w==="error"||v(w)};return m?e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"Loading pool configuration..."}):o.liquidityPoolAddress?e.jsx(it,{poolAddress:o.liquidityPoolAddress,buybackRateBps:o.buybackRateBps,usdcAmount:o.usdcAmount,deployedAt:o.deployedAt}):b!=="idle"&&b!=="error"?e.jsx(nt,{step:b,poolAddress:p}):e.jsx(st,{buybackCents:l,setBuybackCents:h,usdcAmount:f,setUsdcAmount:_,mintConfigured:n,walletConnected:T,hasRpcUrl:c,hasUsdcMint:x,canDeploy:D,onDeploy:N,errorMessage:j,canRetry:!!w&&w!=="creating_pool",onRetry:K})}function st({buybackCents:t,setBuybackCents:s,usdcAmount:n,setUsdcAmount:i,mintConfigured:r,walletConnected:o,hasRpcUrl:u,hasUsdcMint:m,canDeploy:y,onDeploy:l,errorMessage:h,canRetry:f,onRetry:_}){const b=((100-t)/100).toFixed(2);return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"0.5rem"},children:"Deploy Buyback Liquidity Pool"}),e.jsx("p",{style:{opacity:.7,marginBottom:"1rem",fontSize:14},children:"Create a Meteora DLMM pool to buy back gift card tokens at a discount. You earn the spread when tokens are resold at face value."}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Buyback rate (cents per $1.00)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:t,onChange:g=>s(Math.max(1,Math.min(99,parseInt(g.target.value)||80))),min:"1",max:"99"}),e.jsxs("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:["You earn $",b," profit per gift card redeemed"]})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"USDC amount"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:n,onChange:g=>i(Math.max(1,parseFloat(g.target.value)||250)),min:"1",step:"1"}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"Minimum recommended: $250"})]})]}),e.jsxs("div",{style:{margin:"1rem 0",display:"flex",flexDirection:"column",gap:6},children:[e.jsx(J,{label:"Token-22 mint initialized",met:r}),e.jsx(J,{label:"Wallet connected",met:o}),e.jsx(J,{label:"RPC URL configured",met:u}),e.jsx(J,{label:"USDC mint configured",met:m})]}),h&&e.jsx("div",{style:{padding:"0.5rem 0.75rem",marginBottom:"0.75rem",borderRadius:6,background:"rgba(239,68,68,0.1)",color:"#dc2626",fontSize:13},children:h}),e.jsx("div",{style:{display:"flex",gap:"0.75rem",alignItems:"center"},children:f?e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:_,children:"Retry (Resume from Failed Step)"}):e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:l,disabled:!y,children:"Deploy Liquidity Pool"})})]})}const xe=[{key:"creating_pool",label:"Creating DLMM pool..."},{key:"adding_liquidity",label:"Depositing USDC liquidity..."},{key:"saving_config",label:"Saving configuration..."},{key:"done",label:"Complete"}];function nt({step:t,poolAddress:s}){return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Deploying Pool..."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:xe.map((n,i)=>{const r=xe.findIndex(y=>y.key===t),o=i,u=o<r||t==="done",m=o===r&&t!=="done";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:14},children:[e.jsx("span",{style:{width:20,textAlign:"center",fontWeight:600},children:u?"✓":m?"▶":"○"}),e.jsx("span",{style:{opacity:u||m?1:.4},children:n.label})]},n.key)})}),s&&e.jsxs("div",{style:{marginTop:"1rem",fontSize:13,opacity:.7},children:["Pool: ",e.jsx("code",{style:{fontSize:12},children:s})]})]})}function it({poolAddress:t,buybackRateBps:s,usdcAmount:n,deployedAt:i}){const r=s!=null?`$${(s/1e4).toFixed(2)}`:"Unknown",o=n!=null?`$${(n/10**W).toFixed(2)}`:null,u=i?new Date(i).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"}):null,m=t.length>16?`${t.slice(0,8)}...${t.slice(-8)}`:t;return e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Liquidity Pool Active"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",maxWidth:600},children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Pool Address"}),e.jsxs("div",{style:{fontSize:13,fontFamily:"monospace",wordBreak:"break-all"},children:[m,e.jsxs("span",{style:{marginLeft:8,display:"inline-flex",gap:6},children:[e.jsx(rt,{text:t}),e.jsx(fe,{href:`${Qe}/${t}`,label:"Solscan"}),e.jsx(fe,{href:`${et}/${t}`,label:"Meteora"})]})]}),e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Buyback Rate"}),e.jsxs("div",{style:{fontSize:13},children:[r," per $1.00"]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"USDC Deposited"}),e.jsx("div",{style:{fontSize:13},children:o})]}),u&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:"Deployed"}),e.jsx("div",{style:{fontSize:13},children:u})]})]})]})}function J({label:t,met:s}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13},children:[e.jsx("span",{style:{color:s?"#16a34a":"#dc2626",fontWeight:600},children:s?"✓":"✗"}),e.jsx("span",{style:{opacity:s?.8:.5},children:t})]})}function rt({text:t}){const[s,n]=d.useState(!1),i=()=>{navigator.clipboard.writeText(t).then(()=>{n(!0),setTimeout(()=>n(!1),1500)})};return e.jsx("button",{type:"button",onClick:i,style:{background:"none",border:"none",cursor:"pointer",fontSize:12,opacity:.7,padding:0},children:s?"Copied":"Copy"})}function fe({href:t,label:s}){return e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,opacity:.7},children:s})}function at({serverUrl:t,apiKey:s,authManager:n}){const[i,r]=d.useState(null),[o,u]=d.useState([]),[m,y]=d.useState(!0),[l,h]=d.useState(null),[f,_]=d.useState("mint"),[b,g]=d.useState({treasuryAddress:"",tokenSymbol:"storeUSD",tokenDecimals:2,transferFeeBps:250,maxTransferFee:500}),[j,k]=d.useState(!1),[p,C]=d.useState(!1),[w,a]=d.useState(null),S=d.useCallback(async(v,N)=>{if(n?.isAuthenticated())return n.fetchWithAuth(v,N);const K={"Content-Type":"application/json"};s&&(K["X-API-Key"]=s);const z=await fetch(`${t}${v}`,{...N,headers:{...K,...N?.headers}});if(!z.ok){const R=await z.text().catch(()=>`HTTP ${z.status}`);throw new Error(R)}return z.json()},[t,s,n]),A=d.useCallback(async()=>{try{h(null);const v=await S("/admin/token22/status");r(v)}catch{h("Failed to load Token-22 status")}finally{y(!1)}},[S]),T=d.useCallback(async()=>{try{const v=await S("/admin/gift-card-redemptions?limit=50");u(v.redemptions||[])}catch{u([])}},[S]);d.useEffect(()=>{A(),T()},[A,T]);const c=async v=>{if(v.preventDefault(),!!b.treasuryAddress){k(!0),a(null);try{const N=await S("/admin/token22/initialize",{method:"POST",body:JSON.stringify({treasuryAddress:b.treasuryAddress,tokenSymbol:b.tokenSymbol,tokenDecimals:b.tokenDecimals,transferFeeBps:b.transferFeeBps,maxTransferFee:b.maxTransferFee})});a(`Mint created: ${N.mintAddress}`),A()}catch(N){a(`Error: ${N instanceof Error?N.message:"Failed to initialize"}`)}finally{k(!1)}}},x=async()=>{C(!0),a(null);try{const v=await S("/admin/token22/harvest-fees",{method:"POST"});a(v.message)}catch(v){a(`Error: ${v instanceof Error?v.message:"Failed to harvest"}`)}finally{C(!1)}},D=v=>{try{return new Date(v).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}catch{return v}};return e.jsxs("div",{className:"cedros-admin__page",children:[e.jsx(pe.ErrorBanner,{message:l,onRetry:A}),e.jsx("div",{style:{display:"flex",gap:0,borderBottom:"1px solid rgba(0,0,0,0.1)",marginBottom:"1rem"},children:["mint","redemptions","compliance","liquidity","asset-classes","asset-redemptions"].map(v=>{const N={mint:"Token-22 Mint",redemptions:"Gift Card Redemptions",compliance:"Compliance",liquidity:"Liquidity","asset-classes":"Asset Classes","asset-redemptions":"Asset Redemptions"};return e.jsx("button",{type:"button",onClick:()=>_(v),style:{padding:"0.5rem 1rem",background:"none",border:"none",borderBottom:f===v?"2px solid currentColor":"2px solid transparent",fontWeight:f===v?600:400,cursor:"pointer",opacity:f===v?1:.6},children:N[v]},v)})}),m?e.jsxs("div",{className:"cedros-admin__loading",children:[pe.Icons.loading," Loading..."]}):f==="mint"?e.jsx(ot,{mintStatus:i,initForm:b,setInitForm:g,isInitializing:j,isHarvesting:p,actionMessage:w,onInitialize:c,onHarvestFees:x,formatDate:D}):f==="redemptions"?e.jsx(lt,{redemptions:o,formatDate:D}):f==="compliance"?e.jsx(Ye,{serverUrl:t,apiKey:s,authManager:n}):f==="liquidity"?e.jsx(tt,{serverUrl:t,authManager:n,mintConfigured:!!i?.configured,mintAddress:i?.mintAddress,tokenDecimals:i?.tokenDecimals}):f==="asset-classes"?e.jsx(Re,{serverUrl:t,apiKey:s,authManager:n,onNavigateToLiquidity:()=>_("liquidity")}):e.jsx(qe,{serverUrl:t,apiKey:s,authManager:n})]})}function ot({mintStatus:t,initForm:s,setInitForm:n,isInitializing:i,isHarvesting:r,actionMessage:o,onInitialize:u,onHarvestFees:m,formatDate:y}){return t?.configured?e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"1rem"},children:"Token-22 Mint Status"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"0.75rem",maxWidth:600},children:[e.jsx(I,{label:"Mint Address",value:t.mintAddress,mono:!0}),e.jsx(I,{label:"Token Symbol",value:t.tokenSymbol}),e.jsx(I,{label:"Decimals",value:String(t.tokenDecimals)}),e.jsx(I,{label:"Transfer Fee",value:`${t.transferFeeBps} bps (${((t.transferFeeBps??0)/100).toFixed(2)}%)`}),e.jsx(I,{label:"Max Transfer Fee",value:String(t.maxTransferFee)}),e.jsx(I,{label:"Treasury",value:t.treasuryAddress,mono:!0}),e.jsx(I,{label:"Authority",value:t.mintAuthority,mono:!0}),e.jsx(I,{label:"Created",value:t.createdAt?y(t.createdAt):"—"})]}),e.jsxs("div",{style:{marginTop:"1.5rem",display:"flex",gap:"0.75rem",alignItems:"center"},children:[e.jsx("button",{className:"cedros-admin__button cedros-admin__button--primary",onClick:m,disabled:r,children:r?"Harvesting...":"Harvest Transfer Fees"}),o&&e.jsx("span",{style:{fontSize:13,opacity:.8},children:o})]})]}):e.jsxs("div",{children:[e.jsx("h3",{className:"cedros-admin__section-title",style:{marginBottom:"0.5rem"},children:"Initialize Token-22 Mint"}),e.jsx("p",{style:{opacity:.7,marginBottom:"1rem",fontSize:14},children:"Create a Token-22 mint with transfer fee extension for the secondary market. This is a one-time operation per tenant."}),e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Treasury address (Solana)"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:s.treasuryAddress,onChange:l=>n(h=>({...h,treasuryAddress:l.target.value})),placeholder:"e.g., 7xKX...",required:!0})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Token symbol"}),e.jsx("input",{type:"text",className:"cedros-admin__input",value:s.tokenSymbol,onChange:l=>n(h=>({...h,tokenSymbol:l.target.value})),placeholder:"storeUSD"})]})]}),e.jsxs("div",{className:"cedros-admin__form-row",children:[e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Token decimals"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:s.tokenDecimals,onChange:l=>n(h=>({...h,tokenDecimals:parseInt(l.target.value)||2})),min:"0",max:"9"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Transfer fee (basis points)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:s.transferFeeBps,onChange:l=>n(h=>({...h,transferFeeBps:parseInt(l.target.value)||0})),min:"0",max:"10000"}),e.jsx("div",{style:{marginTop:4,fontSize:12,opacity:.75},children:"e.g., 250 = 2.5% fee on secondary market transfers"})]}),e.jsxs("div",{className:"cedros-admin__field",children:[e.jsx("label",{className:"cedros-admin__field-label",children:"Max transfer fee (atomic)"}),e.jsx("input",{type:"number",className:"cedros-admin__input",value:s.maxTransferFee,onChange:l=>n(h=>({...h,maxTransferFee:parseInt(l.target.value)||0})),min:"0"})]})]}),e.jsxs("div",{className:"cedros-admin__form-actions",style:{marginTop:"1rem"},children:[e.jsx("button",{type:"submit",className:"cedros-admin__button cedros-admin__button--primary",disabled:i,children:i?"Creating Mint...":"Initialize Mint"}),o&&e.jsx("span",{style:{marginLeft:"0.75rem",fontSize:13,opacity:.8},children:o})]})]})]})}function I({label:t,value:s,mono:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:13},children:t}),e.jsx("div",{style:{fontSize:13,fontFamily:n?"monospace":"inherit",wordBreak:n?"break-all":"normal",opacity:s?1:.5},children:s||"—"})]})}function lt({redemptions:t,formatDate:s}){return t.length?e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Date"}),e.jsx("th",{children:"Order"}),e.jsx("th",{children:"Product"}),e.jsx("th",{children:"Buyer"}),e.jsx("th",{children:"Recipient"}),e.jsx("th",{children:"Value"}),e.jsx("th",{children:"Token Minted"})]})}),e.jsx("tbody",{children:t.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:{whiteSpace:"nowrap"},children:s(n.createdAt)}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.orderId.slice(0,8),"..."]})}),e.jsx("td",{children:e.jsx("code",{style:{fontSize:12},children:n.productId})}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.buyerUserId.slice(0,8),"..."]})}),e.jsx("td",{children:e.jsxs("code",{style:{fontSize:12},children:[n.recipientUserId.slice(0,8),"..."]})}),e.jsxs("td",{children:["$",(n.faceValueCents/100).toFixed(2)," ",n.currency.toUpperCase()]}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge ${n.tokenMinted?"cedros-admin__badge--success":"cedros-admin__badge--muted"}`,children:n.tokenMinted?"Yes":"No"})})]},n.id))})]})}):e.jsx("div",{style:{padding:"2rem",textAlign:"center",opacity:.6},children:"No gift card redemptions yet."})}exports.Token22Section=at;
@@ -1,6 +1,6 @@
1
1
  import { jsxs as t, jsx as e, Fragment as O } from "react/jsx-runtime";
2
2
  import { useState as y, useCallback as D, useEffect as J, useRef as we } from "react";
3
- import { E as ke, I as Te } from "./index-CKNB7XsA.mjs";
3
+ import { E as ke, I as Te } from "./index-BHF82XBB.mjs";
4
4
  import { a as de } from "./configApi-Ch0Rr7TD.mjs";
5
5
  const _e = [
6
6
  { value: "text", label: "Short Text" },
@@ -983,7 +983,7 @@ class Ve {
983
983
  /** Dynamic import of BN.js (bundled with @solana/web3.js) */
984
984
  async loadBN() {
985
985
  if (this.bnClass) return this.bnClass;
986
- const i = await import("./bn-CHdpZHQm.mjs").then((r) => r.b);
986
+ const i = await import("./bn-Bv2sKQMU.mjs").then((r) => r.b);
987
987
  return this.bnClass = i.default ?? i, this.bnClass;
988
988
  }
989
989
  /** Dynamic import of Keypair */
@@ -1,6 +1,6 @@
1
1
  import { clusterApiUrl as C, Connection as b, Transaction as P, PublicKey as l, TransactionInstruction as R, LAMPORTS_PER_SOL as x } from "@solana/web3.js";
2
2
  import { getAssociatedTokenAddress as T, createTransferInstruction as A } from "@solana/spl-token";
3
- import { c as v, b as B, i as u, k as S, r as m, g, e as w, l as f, m as M } from "./CedrosContext-BlArEF7k.mjs";
3
+ import { h as v, f as B, i as u, k as S, r as m, e as g, b as w, l as f, m as M } from "./CedrosContext-DQUbL8yP.mjs";
4
4
  import { b as k } from "./index-BFt38o8Q.mjs";
5
5
  class z {
6
6
  connection;
@@ -669,7 +669,7 @@ function xi() {
669
669
  var f = 67108863 ^ 67108863 >>> r << r;
670
670
  this.words[this.length - 1] &= f;
671
671
  }
672
- return this._strip();
672
+ return this.length === 0 && (this.words[0] = 0, this.length = 1), this._strip();
673
673
  }, l.prototype.maskn = function(t) {
674
674
  return this.clone().imaskn(t);
675
675
  }, l.prototype.iaddn = function(t) {
@@ -1 +1 @@
1
- "use strict";function mi(it,nt){for(var ft=0;ft<nt.length;ft++){const d=nt[ft];if(typeof d!="string"&&!Array.isArray(d)){for(const rt in d)if(rt!=="default"&&!(rt in it)){const l=Object.getOwnPropertyDescriptor(d,rt);l&&Object.defineProperty(it,rt,l.get?l:{enumerable:!0,get:()=>d[rt]})}}}return Object.freeze(Object.defineProperty(it,Symbol.toStringTag,{value:"Module"}))}function pi(it){return it&&it.__esModule&&Object.prototype.hasOwnProperty.call(it,"default")?it.default:it}function Mi(it){if(Object.prototype.hasOwnProperty.call(it,"__esModule"))return it;var nt=it.default;if(typeof nt=="function"){var ft=function d(){var rt=!1;try{rt=this instanceof d}catch{}return rt?Reflect.construct(nt,arguments,this.constructor):nt.apply(this,arguments)};ft.prototype=nt.prototype}else ft={};return Object.defineProperty(ft,"__esModule",{value:!0}),Object.keys(it).forEach(function(d){var rt=Object.getOwnPropertyDescriptor(it,d);Object.defineProperty(ft,d,rt.get?rt:{enumerable:!0,get:function(){return it[d]}})}),ft}const ci={},gi=Object.freeze(Object.defineProperty({__proto__:null,default:ci},Symbol.toStringTag,{value:"Module"}));var lt={exports:{}};const wi=Mi(gi);var yi=lt.exports,oi;function xi(){return oi||(oi=1,(function(it){(function(nt,ft){function d(o,t){if(!o)throw new Error(t||"Assertion failed")}function rt(o,t){o.super_=t;var r=function(){};r.prototype=t.prototype,o.prototype=new r,o.prototype.constructor=o}function l(o,t,r){if(l.isBN(o))return o;this.negative=0,this.words=null,this.length=0,this.red=null,o!==null&&((t==="le"||t==="be")&&(r=t,t=10),this._init(o||0,t||10,r||"be"))}typeof nt=="object"?nt.exports=l:ft.BN=l,l.BN=l,l.wordSize=26;var ot;try{typeof window<"u"&&typeof window.Buffer<"u"?ot=window.Buffer:ot=wi.Buffer}catch{}l.isBN=function(t){return t instanceof l?!0:t!==null&&typeof t=="object"&&t.constructor.wordSize===l.wordSize&&Array.isArray(t.words)},l.max=function(t,r){return t.cmp(r)>0?t:r},l.min=function(t,r){return t.cmp(r)<0?t:r},l.prototype._init=function(t,r,e){if(typeof t=="number")return this._initNumber(t,r,e);if(typeof t=="object")return this._initArray(t,r,e);r==="hex"&&(r=16),d(r===(r|0)&&r>=2&&r<=36),t=t.toString().replace(/\s+/g,"");var f=0;t[0]==="-"&&(f++,this.negative=1),f<t.length&&(r===16?this._parseHex(t,f,e):(this._parseBase(t,r,f),e==="le"&&this._initArray(this.toArray(),r,e)))},l.prototype._initNumber=function(t,r,e){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[t&67108863],this.length=1):t<4503599627370496?(this.words=[t&67108863,t/67108864&67108863],this.length=2):(d(t<9007199254740992),this.words=[t&67108863,t/67108864&67108863,1],this.length=3),e==="le"&&this._initArray(this.toArray(),r,e)},l.prototype._initArray=function(t,r,e){if(d(typeof t.length=="number"),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var f=0;f<this.length;f++)this.words[f]=0;var s,a,u=0;if(e==="be")for(f=t.length-1,s=0;f>=0;f-=3)a=t[f]|t[f-1]<<8|t[f-2]<<16,this.words[s]|=a<<u&67108863,this.words[s+1]=a>>>26-u&67108863,u+=24,u>=26&&(u-=26,s++);else if(e==="le")for(f=0,s=0;f<t.length;f+=3)a=t[f]|t[f+1]<<8|t[f+2]<<16,this.words[s]|=a<<u&67108863,this.words[s+1]=a>>>26-u&67108863,u+=24,u>=26&&(u-=26,s++);return this._strip()};function Zt(o,t){var r=o.charCodeAt(t);if(r>=48&&r<=57)return r-48;if(r>=65&&r<=70)return r-55;if(r>=97&&r<=102)return r-87;d(!1,"Invalid character in "+o)}function Et(o,t,r){var e=Zt(o,r);return r-1>=t&&(e|=Zt(o,r-1)<<4),e}l.prototype._parseHex=function(t,r,e){this.length=Math.ceil((t.length-r)/6),this.words=new Array(this.length);for(var f=0;f<this.length;f++)this.words[f]=0;var s=0,a=0,u;if(e==="be")for(f=t.length-1;f>=r;f-=2)u=Et(t,r,f)<<s,this.words[a]|=u&67108863,s>=18?(s-=18,a+=1,this.words[a]|=u>>>26):s+=8;else{var h=t.length-r;for(f=h%2===0?r+1:r;f<t.length;f+=2)u=Et(t,r,f)<<s,this.words[a]|=u&67108863,s>=18?(s-=18,a+=1,this.words[a]|=u>>>26):s+=8}this._strip()};function Tt(o,t,r,e){for(var f=0,s=0,a=Math.min(o.length,r),u=t;u<a;u++){var h=o.charCodeAt(u)-48;f*=e,h>=49?s=h-49+10:h>=17?s=h-17+10:s=h,d(h>=0&&s<e,"Invalid character"),f+=s}return f}l.prototype._parseBase=function(t,r,e){this.words=[0],this.length=1;for(var f=0,s=1;s<=67108863;s*=r)f++;f--,s=s/r|0;for(var a=t.length-e,u=a%f,h=Math.min(a,a-u)+e,i=0,n=e;n<h;n+=f)i=Tt(t,n,n+f,r),this.imuln(s),this.words[0]+i<67108864?this.words[0]+=i:this._iaddn(i);if(u!==0){var m=1;for(i=Tt(t,n,t.length,r),n=0;n<u;n++)m*=r;this.imuln(m),this.words[0]+i<67108864?this.words[0]+=i:this._iaddn(i)}this._strip()},l.prototype.copy=function(t){t.words=new Array(this.length);for(var r=0;r<this.length;r++)t.words[r]=this.words[r];t.length=this.length,t.negative=this.negative,t.red=this.red};function It(o,t){o.words=t.words,o.length=t.length,o.negative=t.negative,o.red=t.red}if(l.prototype._move=function(t){It(t,this)},l.prototype.clone=function(){var t=new l(null);return this.copy(t),t},l.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},l.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},l.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{l.prototype[Symbol.for("nodejs.util.inspect.custom")]=ut}catch{l.prototype.inspect=ut}else l.prototype.inspect=ut;function ut(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var zt=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],li=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],ui=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];l.prototype.toString=function(t,r){t=t||10,r=r|0||1;var e;if(t===16||t==="hex"){e="";for(var f=0,s=0,a=0;a<this.length;a++){var u=this.words[a],h=((u<<f|s)&16777215).toString(16);s=u>>>24-f&16777215,f+=2,f>=26&&(f-=26,a--),s!==0||a!==this.length-1?e=zt[6-h.length]+h+e:e=h+e}for(s!==0&&(e=s.toString(16)+e);e.length%r!==0;)e="0"+e;return this.negative!==0&&(e="-"+e),e}if(t===(t|0)&&t>=2&&t<=36){var i=li[t],n=ui[t];e="";var m=this.clone();for(m.negative=0;!m.isZero();){var v=m.modrn(n).toString(t);m=m.idivn(n),m.isZero()?e=v+e:e=zt[i-v.length]+v+e}for(this.isZero()&&(e="0"+e);e.length%r!==0;)e="0"+e;return this.negative!==0&&(e="-"+e),e}d(!1,"Base should be between 2 and 36")},l.prototype.toNumber=function(){var t=this.words[0];return this.length===2?t+=this.words[1]*67108864:this.length===3&&this.words[2]===1?t+=4503599627370496+this.words[1]*67108864:this.length>2&&d(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-t:t},l.prototype.toJSON=function(){return this.toString(16,2)},ot&&(l.prototype.toBuffer=function(t,r){return this.toArrayLike(ot,t,r)}),l.prototype.toArray=function(t,r){return this.toArrayLike(Array,t,r)};var di=function(t,r){return t.allocUnsafe?t.allocUnsafe(r):new t(r)};l.prototype.toArrayLike=function(t,r,e){this._strip();var f=this.byteLength(),s=e||Math.max(1,f);d(f<=s,"byte array longer than desired length"),d(s>0,"Requested array length <= 0");var a=di(t,s),u=r==="le"?"LE":"BE";return this["_toArrayLike"+u](a,f),a},l.prototype._toArrayLikeLE=function(t,r){for(var e=0,f=0,s=0,a=0;s<this.length;s++){var u=this.words[s]<<a|f;t[e++]=u&255,e<t.length&&(t[e++]=u>>8&255),e<t.length&&(t[e++]=u>>16&255),a===6?(e<t.length&&(t[e++]=u>>24&255),f=0,a=0):(f=u>>>24,a+=2)}if(e<t.length)for(t[e++]=f;e<t.length;)t[e++]=0},l.prototype._toArrayLikeBE=function(t,r){for(var e=t.length-1,f=0,s=0,a=0;s<this.length;s++){var u=this.words[s]<<a|f;t[e--]=u&255,e>=0&&(t[e--]=u>>8&255),e>=0&&(t[e--]=u>>16&255),a===6?(e>=0&&(t[e--]=u>>24&255),f=0,a=0):(f=u>>>24,a+=2)}if(e>=0)for(t[e--]=f;e>=0;)t[e--]=0},Math.clz32?l.prototype._countBits=function(t){return 32-Math.clz32(t)}:l.prototype._countBits=function(t){var r=t,e=0;return r>=4096&&(e+=13,r>>>=13),r>=64&&(e+=7,r>>>=7),r>=8&&(e+=4,r>>>=4),r>=2&&(e+=2,r>>>=2),e+r},l.prototype._zeroBits=function(t){if(t===0)return 26;var r=t,e=0;return(r&8191)===0&&(e+=13,r>>>=13),(r&127)===0&&(e+=7,r>>>=7),(r&15)===0&&(e+=4,r>>>=4),(r&3)===0&&(e+=2,r>>>=2),(r&1)===0&&e++,e},l.prototype.bitLength=function(){var t=this.words[this.length-1],r=this._countBits(t);return(this.length-1)*26+r};function vi(o){for(var t=new Array(o.bitLength()),r=0;r<t.length;r++){var e=r/26|0,f=r%26;t[r]=o.words[e]>>>f&1}return t}l.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,r=0;r<this.length;r++){var e=this._zeroBits(this.words[r]);if(t+=e,e!==26)break}return t},l.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},l.prototype.toTwos=function(t){return this.negative!==0?this.abs().inotn(t).iaddn(1):this.clone()},l.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},l.prototype.isNeg=function(){return this.negative!==0},l.prototype.neg=function(){return this.clone().ineg()},l.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},l.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]|t.words[r];return this._strip()},l.prototype.ior=function(t){return d((this.negative|t.negative)===0),this.iuor(t)},l.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},l.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},l.prototype.iuand=function(t){var r;this.length>t.length?r=t:r=this;for(var e=0;e<r.length;e++)this.words[e]=this.words[e]&t.words[e];return this.length=r.length,this._strip()},l.prototype.iand=function(t){return d((this.negative|t.negative)===0),this.iuand(t)},l.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},l.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},l.prototype.iuxor=function(t){var r,e;this.length>t.length?(r=this,e=t):(r=t,e=this);for(var f=0;f<e.length;f++)this.words[f]=r.words[f]^e.words[f];if(this!==r)for(;f<r.length;f++)this.words[f]=r.words[f];return this.length=r.length,this._strip()},l.prototype.ixor=function(t){return d((this.negative|t.negative)===0),this.iuxor(t)},l.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},l.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},l.prototype.inotn=function(t){d(typeof t=="number"&&t>=0);var r=Math.ceil(t/26)|0,e=t%26;this._expand(r),e>0&&r--;for(var f=0;f<r;f++)this.words[f]=~this.words[f]&67108863;return e>0&&(this.words[f]=~this.words[f]&67108863>>26-e),this._strip()},l.prototype.notn=function(t){return this.clone().inotn(t)},l.prototype.setn=function(t,r){d(typeof t=="number"&&t>=0);var e=t/26|0,f=t%26;return this._expand(e+1),r?this.words[e]=this.words[e]|1<<f:this.words[e]=this.words[e]&~(1<<f),this._strip()},l.prototype.iadd=function(t){var r;if(this.negative!==0&&t.negative===0)return this.negative=0,r=this.isub(t),this.negative^=1,this._normSign();if(this.negative===0&&t.negative!==0)return t.negative=0,r=this.isub(t),t.negative=1,r._normSign();var e,f;this.length>t.length?(e=this,f=t):(e=t,f=this);for(var s=0,a=0;a<f.length;a++)r=(e.words[a]|0)+(f.words[a]|0)+s,this.words[a]=r&67108863,s=r>>>26;for(;s!==0&&a<e.length;a++)r=(e.words[a]|0)+s,this.words[a]=r&67108863,s=r>>>26;if(this.length=e.length,s!==0)this.words[this.length]=s,this.length++;else if(e!==this)for(;a<e.length;a++)this.words[a]=e.words[a];return this},l.prototype.add=function(t){var r;return t.negative!==0&&this.negative===0?(t.negative=0,r=this.sub(t),t.negative^=1,r):t.negative===0&&this.negative!==0?(this.negative=0,r=t.sub(this),this.negative=1,r):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},l.prototype.isub=function(t){if(t.negative!==0){t.negative=0;var r=this.iadd(t);return t.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var e=this.cmp(t);if(e===0)return this.negative=0,this.length=1,this.words[0]=0,this;var f,s;e>0?(f=this,s=t):(f=t,s=this);for(var a=0,u=0;u<s.length;u++)r=(f.words[u]|0)-(s.words[u]|0)+a,a=r>>26,this.words[u]=r&67108863;for(;a!==0&&u<f.length;u++)r=(f.words[u]|0)+a,a=r>>26,this.words[u]=r&67108863;if(a===0&&u<f.length&&f!==this)for(;u<f.length;u++)this.words[u]=f.words[u];return this.length=Math.max(this.length,u),f!==this&&(this.negative=1),this._strip()},l.prototype.sub=function(t){return this.clone().isub(t)};function Pt(o,t,r){r.negative=t.negative^o.negative;var e=o.length+t.length|0;r.length=e,e=e-1|0;var f=o.words[0]|0,s=t.words[0]|0,a=f*s,u=a&67108863,h=a/67108864|0;r.words[0]=u;for(var i=1;i<e;i++){for(var n=h>>>26,m=h&67108863,v=Math.min(i,t.length-1),p=Math.max(0,i-o.length+1);p<=v;p++){var et=i-p|0;f=o.words[et]|0,s=t.words[p]|0,a=f*s+m,n+=a/67108864|0,m=a&67108863}r.words[i]=m|0,h=n|0}return h!==0?r.words[i]=h|0:r.length--,r._strip()}var Kt=function(t,r,e){var f=t.words,s=r.words,a=e.words,u=0,h,i,n,m=f[0]|0,v=m&8191,p=m>>>13,et=f[1]|0,M=et&8191,c=et>>>13,Ct=f[2]|0,w=Ct&8191,y=Ct>>>13,Ut=f[3]|0,x=Ut&8191,_=Ut>>>13,Jt=f[4]|0,b=Jt&8191,S=Jt>>>13,Wt=f[5]|0,A=Wt&8191,B=Wt>>>13,Gt=f[6]|0,k=Gt&8191,q=Gt>>>13,Qt=f[7]|0,N=Qt&8191,R=Qt>>>13,Vt=f[8]|0,L=Vt&8191,O=Vt>>>13,Xt=f[9]|0,Z=Xt&8191,E=Xt>>>13,Yt=s[0]|0,T=Yt&8191,I=Yt>>>13,jt=s[1]|0,z=jt&8191,P=jt>>>13,ti=s[2]|0,K=ti&8191,D=ti>>>13,ii=s[3]|0,F=ii&8191,$=ii>>>13,ri=s[4]|0,H=ri&8191,C=ri>>>13,ei=s[5]|0,U=ei&8191,J=ei>>>13,hi=s[6]|0,W=hi&8191,G=hi>>>13,fi=s[7]|0,Q=fi&8191,V=fi>>>13,ni=s[8]|0,X=ni&8191,Y=ni>>>13,si=s[9]|0,j=si&8191,tt=si>>>13;e.negative=t.negative^r.negative,e.length=19,h=Math.imul(v,T),i=Math.imul(v,I),i=i+Math.imul(p,T)|0,n=Math.imul(p,I);var mt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,h=Math.imul(M,T),i=Math.imul(M,I),i=i+Math.imul(c,T)|0,n=Math.imul(c,I),h=h+Math.imul(v,z)|0,i=i+Math.imul(v,P)|0,i=i+Math.imul(p,z)|0,n=n+Math.imul(p,P)|0;var pt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(pt>>>26)|0,pt&=67108863,h=Math.imul(w,T),i=Math.imul(w,I),i=i+Math.imul(y,T)|0,n=Math.imul(y,I),h=h+Math.imul(M,z)|0,i=i+Math.imul(M,P)|0,i=i+Math.imul(c,z)|0,n=n+Math.imul(c,P)|0,h=h+Math.imul(v,K)|0,i=i+Math.imul(v,D)|0,i=i+Math.imul(p,K)|0,n=n+Math.imul(p,D)|0;var Mt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,h=Math.imul(x,T),i=Math.imul(x,I),i=i+Math.imul(_,T)|0,n=Math.imul(_,I),h=h+Math.imul(w,z)|0,i=i+Math.imul(w,P)|0,i=i+Math.imul(y,z)|0,n=n+Math.imul(y,P)|0,h=h+Math.imul(M,K)|0,i=i+Math.imul(M,D)|0,i=i+Math.imul(c,K)|0,n=n+Math.imul(c,D)|0,h=h+Math.imul(v,F)|0,i=i+Math.imul(v,$)|0,i=i+Math.imul(p,F)|0,n=n+Math.imul(p,$)|0;var ct=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(ct>>>26)|0,ct&=67108863,h=Math.imul(b,T),i=Math.imul(b,I),i=i+Math.imul(S,T)|0,n=Math.imul(S,I),h=h+Math.imul(x,z)|0,i=i+Math.imul(x,P)|0,i=i+Math.imul(_,z)|0,n=n+Math.imul(_,P)|0,h=h+Math.imul(w,K)|0,i=i+Math.imul(w,D)|0,i=i+Math.imul(y,K)|0,n=n+Math.imul(y,D)|0,h=h+Math.imul(M,F)|0,i=i+Math.imul(M,$)|0,i=i+Math.imul(c,F)|0,n=n+Math.imul(c,$)|0,h=h+Math.imul(v,H)|0,i=i+Math.imul(v,C)|0,i=i+Math.imul(p,H)|0,n=n+Math.imul(p,C)|0;var gt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,h=Math.imul(A,T),i=Math.imul(A,I),i=i+Math.imul(B,T)|0,n=Math.imul(B,I),h=h+Math.imul(b,z)|0,i=i+Math.imul(b,P)|0,i=i+Math.imul(S,z)|0,n=n+Math.imul(S,P)|0,h=h+Math.imul(x,K)|0,i=i+Math.imul(x,D)|0,i=i+Math.imul(_,K)|0,n=n+Math.imul(_,D)|0,h=h+Math.imul(w,F)|0,i=i+Math.imul(w,$)|0,i=i+Math.imul(y,F)|0,n=n+Math.imul(y,$)|0,h=h+Math.imul(M,H)|0,i=i+Math.imul(M,C)|0,i=i+Math.imul(c,H)|0,n=n+Math.imul(c,C)|0,h=h+Math.imul(v,U)|0,i=i+Math.imul(v,J)|0,i=i+Math.imul(p,U)|0,n=n+Math.imul(p,J)|0;var wt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,h=Math.imul(k,T),i=Math.imul(k,I),i=i+Math.imul(q,T)|0,n=Math.imul(q,I),h=h+Math.imul(A,z)|0,i=i+Math.imul(A,P)|0,i=i+Math.imul(B,z)|0,n=n+Math.imul(B,P)|0,h=h+Math.imul(b,K)|0,i=i+Math.imul(b,D)|0,i=i+Math.imul(S,K)|0,n=n+Math.imul(S,D)|0,h=h+Math.imul(x,F)|0,i=i+Math.imul(x,$)|0,i=i+Math.imul(_,F)|0,n=n+Math.imul(_,$)|0,h=h+Math.imul(w,H)|0,i=i+Math.imul(w,C)|0,i=i+Math.imul(y,H)|0,n=n+Math.imul(y,C)|0,h=h+Math.imul(M,U)|0,i=i+Math.imul(M,J)|0,i=i+Math.imul(c,U)|0,n=n+Math.imul(c,J)|0,h=h+Math.imul(v,W)|0,i=i+Math.imul(v,G)|0,i=i+Math.imul(p,W)|0,n=n+Math.imul(p,G)|0;var yt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,h=Math.imul(N,T),i=Math.imul(N,I),i=i+Math.imul(R,T)|0,n=Math.imul(R,I),h=h+Math.imul(k,z)|0,i=i+Math.imul(k,P)|0,i=i+Math.imul(q,z)|0,n=n+Math.imul(q,P)|0,h=h+Math.imul(A,K)|0,i=i+Math.imul(A,D)|0,i=i+Math.imul(B,K)|0,n=n+Math.imul(B,D)|0,h=h+Math.imul(b,F)|0,i=i+Math.imul(b,$)|0,i=i+Math.imul(S,F)|0,n=n+Math.imul(S,$)|0,h=h+Math.imul(x,H)|0,i=i+Math.imul(x,C)|0,i=i+Math.imul(_,H)|0,n=n+Math.imul(_,C)|0,h=h+Math.imul(w,U)|0,i=i+Math.imul(w,J)|0,i=i+Math.imul(y,U)|0,n=n+Math.imul(y,J)|0,h=h+Math.imul(M,W)|0,i=i+Math.imul(M,G)|0,i=i+Math.imul(c,W)|0,n=n+Math.imul(c,G)|0,h=h+Math.imul(v,Q)|0,i=i+Math.imul(v,V)|0,i=i+Math.imul(p,Q)|0,n=n+Math.imul(p,V)|0;var xt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,h=Math.imul(L,T),i=Math.imul(L,I),i=i+Math.imul(O,T)|0,n=Math.imul(O,I),h=h+Math.imul(N,z)|0,i=i+Math.imul(N,P)|0,i=i+Math.imul(R,z)|0,n=n+Math.imul(R,P)|0,h=h+Math.imul(k,K)|0,i=i+Math.imul(k,D)|0,i=i+Math.imul(q,K)|0,n=n+Math.imul(q,D)|0,h=h+Math.imul(A,F)|0,i=i+Math.imul(A,$)|0,i=i+Math.imul(B,F)|0,n=n+Math.imul(B,$)|0,h=h+Math.imul(b,H)|0,i=i+Math.imul(b,C)|0,i=i+Math.imul(S,H)|0,n=n+Math.imul(S,C)|0,h=h+Math.imul(x,U)|0,i=i+Math.imul(x,J)|0,i=i+Math.imul(_,U)|0,n=n+Math.imul(_,J)|0,h=h+Math.imul(w,W)|0,i=i+Math.imul(w,G)|0,i=i+Math.imul(y,W)|0,n=n+Math.imul(y,G)|0,h=h+Math.imul(M,Q)|0,i=i+Math.imul(M,V)|0,i=i+Math.imul(c,Q)|0,n=n+Math.imul(c,V)|0,h=h+Math.imul(v,X)|0,i=i+Math.imul(v,Y)|0,i=i+Math.imul(p,X)|0,n=n+Math.imul(p,Y)|0;var _t=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,h=Math.imul(Z,T),i=Math.imul(Z,I),i=i+Math.imul(E,T)|0,n=Math.imul(E,I),h=h+Math.imul(L,z)|0,i=i+Math.imul(L,P)|0,i=i+Math.imul(O,z)|0,n=n+Math.imul(O,P)|0,h=h+Math.imul(N,K)|0,i=i+Math.imul(N,D)|0,i=i+Math.imul(R,K)|0,n=n+Math.imul(R,D)|0,h=h+Math.imul(k,F)|0,i=i+Math.imul(k,$)|0,i=i+Math.imul(q,F)|0,n=n+Math.imul(q,$)|0,h=h+Math.imul(A,H)|0,i=i+Math.imul(A,C)|0,i=i+Math.imul(B,H)|0,n=n+Math.imul(B,C)|0,h=h+Math.imul(b,U)|0,i=i+Math.imul(b,J)|0,i=i+Math.imul(S,U)|0,n=n+Math.imul(S,J)|0,h=h+Math.imul(x,W)|0,i=i+Math.imul(x,G)|0,i=i+Math.imul(_,W)|0,n=n+Math.imul(_,G)|0,h=h+Math.imul(w,Q)|0,i=i+Math.imul(w,V)|0,i=i+Math.imul(y,Q)|0,n=n+Math.imul(y,V)|0,h=h+Math.imul(M,X)|0,i=i+Math.imul(M,Y)|0,i=i+Math.imul(c,X)|0,n=n+Math.imul(c,Y)|0,h=h+Math.imul(v,j)|0,i=i+Math.imul(v,tt)|0,i=i+Math.imul(p,j)|0,n=n+Math.imul(p,tt)|0;var bt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,h=Math.imul(Z,z),i=Math.imul(Z,P),i=i+Math.imul(E,z)|0,n=Math.imul(E,P),h=h+Math.imul(L,K)|0,i=i+Math.imul(L,D)|0,i=i+Math.imul(O,K)|0,n=n+Math.imul(O,D)|0,h=h+Math.imul(N,F)|0,i=i+Math.imul(N,$)|0,i=i+Math.imul(R,F)|0,n=n+Math.imul(R,$)|0,h=h+Math.imul(k,H)|0,i=i+Math.imul(k,C)|0,i=i+Math.imul(q,H)|0,n=n+Math.imul(q,C)|0,h=h+Math.imul(A,U)|0,i=i+Math.imul(A,J)|0,i=i+Math.imul(B,U)|0,n=n+Math.imul(B,J)|0,h=h+Math.imul(b,W)|0,i=i+Math.imul(b,G)|0,i=i+Math.imul(S,W)|0,n=n+Math.imul(S,G)|0,h=h+Math.imul(x,Q)|0,i=i+Math.imul(x,V)|0,i=i+Math.imul(_,Q)|0,n=n+Math.imul(_,V)|0,h=h+Math.imul(w,X)|0,i=i+Math.imul(w,Y)|0,i=i+Math.imul(y,X)|0,n=n+Math.imul(y,Y)|0,h=h+Math.imul(M,j)|0,i=i+Math.imul(M,tt)|0,i=i+Math.imul(c,j)|0,n=n+Math.imul(c,tt)|0;var St=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(St>>>26)|0,St&=67108863,h=Math.imul(Z,K),i=Math.imul(Z,D),i=i+Math.imul(E,K)|0,n=Math.imul(E,D),h=h+Math.imul(L,F)|0,i=i+Math.imul(L,$)|0,i=i+Math.imul(O,F)|0,n=n+Math.imul(O,$)|0,h=h+Math.imul(N,H)|0,i=i+Math.imul(N,C)|0,i=i+Math.imul(R,H)|0,n=n+Math.imul(R,C)|0,h=h+Math.imul(k,U)|0,i=i+Math.imul(k,J)|0,i=i+Math.imul(q,U)|0,n=n+Math.imul(q,J)|0,h=h+Math.imul(A,W)|0,i=i+Math.imul(A,G)|0,i=i+Math.imul(B,W)|0,n=n+Math.imul(B,G)|0,h=h+Math.imul(b,Q)|0,i=i+Math.imul(b,V)|0,i=i+Math.imul(S,Q)|0,n=n+Math.imul(S,V)|0,h=h+Math.imul(x,X)|0,i=i+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=n+Math.imul(_,Y)|0,h=h+Math.imul(w,j)|0,i=i+Math.imul(w,tt)|0,i=i+Math.imul(y,j)|0,n=n+Math.imul(y,tt)|0;var At=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(At>>>26)|0,At&=67108863,h=Math.imul(Z,F),i=Math.imul(Z,$),i=i+Math.imul(E,F)|0,n=Math.imul(E,$),h=h+Math.imul(L,H)|0,i=i+Math.imul(L,C)|0,i=i+Math.imul(O,H)|0,n=n+Math.imul(O,C)|0,h=h+Math.imul(N,U)|0,i=i+Math.imul(N,J)|0,i=i+Math.imul(R,U)|0,n=n+Math.imul(R,J)|0,h=h+Math.imul(k,W)|0,i=i+Math.imul(k,G)|0,i=i+Math.imul(q,W)|0,n=n+Math.imul(q,G)|0,h=h+Math.imul(A,Q)|0,i=i+Math.imul(A,V)|0,i=i+Math.imul(B,Q)|0,n=n+Math.imul(B,V)|0,h=h+Math.imul(b,X)|0,i=i+Math.imul(b,Y)|0,i=i+Math.imul(S,X)|0,n=n+Math.imul(S,Y)|0,h=h+Math.imul(x,j)|0,i=i+Math.imul(x,tt)|0,i=i+Math.imul(_,j)|0,n=n+Math.imul(_,tt)|0;var Bt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h=Math.imul(Z,H),i=Math.imul(Z,C),i=i+Math.imul(E,H)|0,n=Math.imul(E,C),h=h+Math.imul(L,U)|0,i=i+Math.imul(L,J)|0,i=i+Math.imul(O,U)|0,n=n+Math.imul(O,J)|0,h=h+Math.imul(N,W)|0,i=i+Math.imul(N,G)|0,i=i+Math.imul(R,W)|0,n=n+Math.imul(R,G)|0,h=h+Math.imul(k,Q)|0,i=i+Math.imul(k,V)|0,i=i+Math.imul(q,Q)|0,n=n+Math.imul(q,V)|0,h=h+Math.imul(A,X)|0,i=i+Math.imul(A,Y)|0,i=i+Math.imul(B,X)|0,n=n+Math.imul(B,Y)|0,h=h+Math.imul(b,j)|0,i=i+Math.imul(b,tt)|0,i=i+Math.imul(S,j)|0,n=n+Math.imul(S,tt)|0;var kt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,h=Math.imul(Z,U),i=Math.imul(Z,J),i=i+Math.imul(E,U)|0,n=Math.imul(E,J),h=h+Math.imul(L,W)|0,i=i+Math.imul(L,G)|0,i=i+Math.imul(O,W)|0,n=n+Math.imul(O,G)|0,h=h+Math.imul(N,Q)|0,i=i+Math.imul(N,V)|0,i=i+Math.imul(R,Q)|0,n=n+Math.imul(R,V)|0,h=h+Math.imul(k,X)|0,i=i+Math.imul(k,Y)|0,i=i+Math.imul(q,X)|0,n=n+Math.imul(q,Y)|0,h=h+Math.imul(A,j)|0,i=i+Math.imul(A,tt)|0,i=i+Math.imul(B,j)|0,n=n+Math.imul(B,tt)|0;var qt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(qt>>>26)|0,qt&=67108863,h=Math.imul(Z,W),i=Math.imul(Z,G),i=i+Math.imul(E,W)|0,n=Math.imul(E,G),h=h+Math.imul(L,Q)|0,i=i+Math.imul(L,V)|0,i=i+Math.imul(O,Q)|0,n=n+Math.imul(O,V)|0,h=h+Math.imul(N,X)|0,i=i+Math.imul(N,Y)|0,i=i+Math.imul(R,X)|0,n=n+Math.imul(R,Y)|0,h=h+Math.imul(k,j)|0,i=i+Math.imul(k,tt)|0,i=i+Math.imul(q,j)|0,n=n+Math.imul(q,tt)|0;var Nt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,h=Math.imul(Z,Q),i=Math.imul(Z,V),i=i+Math.imul(E,Q)|0,n=Math.imul(E,V),h=h+Math.imul(L,X)|0,i=i+Math.imul(L,Y)|0,i=i+Math.imul(O,X)|0,n=n+Math.imul(O,Y)|0,h=h+Math.imul(N,j)|0,i=i+Math.imul(N,tt)|0,i=i+Math.imul(R,j)|0,n=n+Math.imul(R,tt)|0;var Rt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,h=Math.imul(Z,X),i=Math.imul(Z,Y),i=i+Math.imul(E,X)|0,n=Math.imul(E,Y),h=h+Math.imul(L,j)|0,i=i+Math.imul(L,tt)|0,i=i+Math.imul(O,j)|0,n=n+Math.imul(O,tt)|0;var Lt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,h=Math.imul(Z,j),i=Math.imul(Z,tt),i=i+Math.imul(E,j)|0,n=Math.imul(E,tt);var Ot=(u+h|0)+((i&8191)<<13)|0;return u=(n+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,a[0]=mt,a[1]=pt,a[2]=Mt,a[3]=ct,a[4]=gt,a[5]=wt,a[6]=yt,a[7]=xt,a[8]=_t,a[9]=bt,a[10]=St,a[11]=At,a[12]=Bt,a[13]=kt,a[14]=qt,a[15]=Nt,a[16]=Rt,a[17]=Lt,a[18]=Ot,u!==0&&(a[19]=u,e.length++),e};Math.imul||(Kt=Pt);function Dt(o,t,r){r.negative=t.negative^o.negative,r.length=o.length+t.length;for(var e=0,f=0,s=0;s<r.length-1;s++){var a=f;f=0;for(var u=e&67108863,h=Math.min(s,t.length-1),i=Math.max(0,s-o.length+1);i<=h;i++){var n=s-i,m=o.words[n]|0,v=t.words[i]|0,p=m*v,et=p&67108863;a=a+(p/67108864|0)|0,et=et+u|0,u=et&67108863,a=a+(et>>>26)|0,f+=a>>>26,a&=67108863}r.words[s]=u,e=a,a=f}return e!==0?r.words[s]=e:r.length--,r._strip()}function Ft(o,t,r){return Dt(o,t,r)}l.prototype.mulTo=function(t,r){var e,f=this.length+t.length;return this.length===10&&t.length===10?e=Kt(this,t,r):f<63?e=Pt(this,t,r):f<1024?e=Dt(this,t,r):e=Ft(this,t,r),e},l.prototype.mul=function(t){var r=new l(null);return r.words=new Array(this.length+t.length),this.mulTo(t,r)},l.prototype.mulf=function(t){var r=new l(null);return r.words=new Array(this.length+t.length),Ft(this,t,r)},l.prototype.imul=function(t){return this.clone().mulTo(t,this)},l.prototype.imuln=function(t){var r=t<0;r&&(t=-t),d(typeof t=="number"),d(t<67108864);for(var e=0,f=0;f<this.length;f++){var s=(this.words[f]|0)*t,a=(s&67108863)+(e&67108863);e>>=26,e+=s/67108864|0,e+=a>>>26,this.words[f]=a&67108863}return e!==0&&(this.words[f]=e,this.length++),this.length=t===0?1:this.length,r?this.ineg():this},l.prototype.muln=function(t){return this.clone().imuln(t)},l.prototype.sqr=function(){return this.mul(this)},l.prototype.isqr=function(){return this.imul(this.clone())},l.prototype.pow=function(t){var r=vi(t);if(r.length===0)return new l(1);for(var e=this,f=0;f<r.length&&r[f]===0;f++,e=e.sqr());if(++f<r.length)for(var s=e.sqr();f<r.length;f++,s=s.sqr())r[f]!==0&&(e=e.mul(s));return e},l.prototype.iushln=function(t){d(typeof t=="number"&&t>=0);var r=t%26,e=(t-r)/26,f=67108863>>>26-r<<26-r,s;if(r!==0){var a=0;for(s=0;s<this.length;s++){var u=this.words[s]&f,h=(this.words[s]|0)-u<<r;this.words[s]=h|a,a=u>>>26-r}a&&(this.words[s]=a,this.length++)}if(e!==0){for(s=this.length-1;s>=0;s--)this.words[s+e]=this.words[s];for(s=0;s<e;s++)this.words[s]=0;this.length+=e}return this._strip()},l.prototype.ishln=function(t){return d(this.negative===0),this.iushln(t)},l.prototype.iushrn=function(t,r,e){d(typeof t=="number"&&t>=0);var f;r?f=(r-r%26)/26:f=0;var s=t%26,a=Math.min((t-s)/26,this.length),u=67108863^67108863>>>s<<s,h=e;if(f-=a,f=Math.max(0,f),h){for(var i=0;i<a;i++)h.words[i]=this.words[i];h.length=a}if(a!==0)if(this.length>a)for(this.length-=a,i=0;i<this.length;i++)this.words[i]=this.words[i+a];else this.words[0]=0,this.length=1;var n=0;for(i=this.length-1;i>=0&&(n!==0||i>=f);i--){var m=this.words[i]|0;this.words[i]=n<<26-s|m>>>s,n=m&u}return h&&n!==0&&(h.words[h.length++]=n),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},l.prototype.ishrn=function(t,r,e){return d(this.negative===0),this.iushrn(t,r,e)},l.prototype.shln=function(t){return this.clone().ishln(t)},l.prototype.ushln=function(t){return this.clone().iushln(t)},l.prototype.shrn=function(t){return this.clone().ishrn(t)},l.prototype.ushrn=function(t){return this.clone().iushrn(t)},l.prototype.testn=function(t){d(typeof t=="number"&&t>=0);var r=t%26,e=(t-r)/26,f=1<<r;if(this.length<=e)return!1;var s=this.words[e];return!!(s&f)},l.prototype.imaskn=function(t){d(typeof t=="number"&&t>=0);var r=t%26,e=(t-r)/26;if(d(this.negative===0,"imaskn works only with positive numbers"),this.length<=e)return this;if(r!==0&&e++,this.length=Math.min(e,this.length),r!==0){var f=67108863^67108863>>>r<<r;this.words[this.length-1]&=f}return this._strip()},l.prototype.maskn=function(t){return this.clone().imaskn(t)},l.prototype.iaddn=function(t){return d(typeof t=="number"),d(t<67108864),t<0?this.isubn(-t):this.negative!==0?this.length===1&&(this.words[0]|0)<=t?(this.words[0]=t-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},l.prototype._iaddn=function(t){this.words[0]+=t;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},l.prototype.isubn=function(t){if(d(typeof t=="number"),d(t<67108864),t<0)return this.iaddn(-t);if(this.negative!==0)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this._strip()},l.prototype.addn=function(t){return this.clone().iaddn(t)},l.prototype.subn=function(t){return this.clone().isubn(t)},l.prototype.iabs=function(){return this.negative=0,this},l.prototype.abs=function(){return this.clone().iabs()},l.prototype._ishlnsubmul=function(t,r,e){var f=t.length+e,s;this._expand(f);var a,u=0;for(s=0;s<t.length;s++){a=(this.words[s+e]|0)+u;var h=(t.words[s]|0)*r;a-=h&67108863,u=(a>>26)-(h/67108864|0),this.words[s+e]=a&67108863}for(;s<this.length-e;s++)a=(this.words[s+e]|0)+u,u=a>>26,this.words[s+e]=a&67108863;if(u===0)return this._strip();for(d(u===-1),u=0,s=0;s<this.length;s++)a=-(this.words[s]|0)+u,u=a>>26,this.words[s]=a&67108863;return this.negative=1,this._strip()},l.prototype._wordDiv=function(t,r){var e=this.length-t.length,f=this.clone(),s=t,a=s.words[s.length-1]|0,u=this._countBits(a);e=26-u,e!==0&&(s=s.ushln(e),f.iushln(e),a=s.words[s.length-1]|0);var h=f.length-s.length,i;if(r!=="mod"){i=new l(null),i.length=h+1,i.words=new Array(i.length);for(var n=0;n<i.length;n++)i.words[n]=0}var m=f.clone()._ishlnsubmul(s,1,h);m.negative===0&&(f=m,i&&(i.words[h]=1));for(var v=h-1;v>=0;v--){var p=(f.words[s.length+v]|0)*67108864+(f.words[s.length+v-1]|0);for(p=Math.min(p/a|0,67108863),f._ishlnsubmul(s,p,v);f.negative!==0;)p--,f.negative=0,f._ishlnsubmul(s,1,v),f.isZero()||(f.negative^=1);i&&(i.words[v]=p)}return i&&i._strip(),f._strip(),r!=="div"&&e!==0&&f.iushrn(e),{div:i||null,mod:f}},l.prototype.divmod=function(t,r,e){if(d(!t.isZero()),this.isZero())return{div:new l(0),mod:new l(0)};var f,s,a;return this.negative!==0&&t.negative===0?(a=this.neg().divmod(t,r),r!=="mod"&&(f=a.div.neg()),r!=="div"&&(s=a.mod.neg(),e&&s.negative!==0&&s.iadd(t)),{div:f,mod:s}):this.negative===0&&t.negative!==0?(a=this.divmod(t.neg(),r),r!=="mod"&&(f=a.div.neg()),{div:f,mod:a.mod}):(this.negative&t.negative)!==0?(a=this.neg().divmod(t.neg(),r),r!=="div"&&(s=a.mod.neg(),e&&s.negative!==0&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new l(0),mod:this}:t.length===1?r==="div"?{div:this.divn(t.words[0]),mod:null}:r==="mod"?{div:null,mod:new l(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new l(this.modrn(t.words[0]))}:this._wordDiv(t,r)},l.prototype.div=function(t){return this.divmod(t,"div",!1).div},l.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},l.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},l.prototype.divRound=function(t){var r=this.divmod(t);if(r.mod.isZero())return r.div;var e=r.div.negative!==0?r.mod.isub(t):r.mod,f=t.ushrn(1),s=t.andln(1),a=e.cmp(f);return a<0||s===1&&a===0?r.div:r.div.negative!==0?r.div.isubn(1):r.div.iaddn(1)},l.prototype.modrn=function(t){var r=t<0;r&&(t=-t),d(t<=67108863);for(var e=(1<<26)%t,f=0,s=this.length-1;s>=0;s--)f=(e*f+(this.words[s]|0))%t;return r?-f:f},l.prototype.modn=function(t){return this.modrn(t)},l.prototype.idivn=function(t){var r=t<0;r&&(t=-t),d(t<=67108863);for(var e=0,f=this.length-1;f>=0;f--){var s=(this.words[f]|0)+e*67108864;this.words[f]=s/t|0,e=s%t}return this._strip(),r?this.ineg():this},l.prototype.divn=function(t){return this.clone().idivn(t)},l.prototype.egcd=function(t){d(t.negative===0),d(!t.isZero());var r=this,e=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var f=new l(1),s=new l(0),a=new l(0),u=new l(1),h=0;r.isEven()&&e.isEven();)r.iushrn(1),e.iushrn(1),++h;for(var i=e.clone(),n=r.clone();!r.isZero();){for(var m=0,v=1;(r.words[0]&v)===0&&m<26;++m,v<<=1);if(m>0)for(r.iushrn(m);m-- >0;)(f.isOdd()||s.isOdd())&&(f.iadd(i),s.isub(n)),f.iushrn(1),s.iushrn(1);for(var p=0,et=1;(e.words[0]&et)===0&&p<26;++p,et<<=1);if(p>0)for(e.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(i),u.isub(n)),a.iushrn(1),u.iushrn(1);r.cmp(e)>=0?(r.isub(e),f.isub(a),s.isub(u)):(e.isub(r),a.isub(f),u.isub(s))}return{a,b:u,gcd:e.iushln(h)}},l.prototype._invmp=function(t){d(t.negative===0),d(!t.isZero());var r=this,e=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var f=new l(1),s=new l(0),a=e.clone();r.cmpn(1)>0&&e.cmpn(1)>0;){for(var u=0,h=1;(r.words[0]&h)===0&&u<26;++u,h<<=1);if(u>0)for(r.iushrn(u);u-- >0;)f.isOdd()&&f.iadd(a),f.iushrn(1);for(var i=0,n=1;(e.words[0]&n)===0&&i<26;++i,n<<=1);if(i>0)for(e.iushrn(i);i-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);r.cmp(e)>=0?(r.isub(e),f.isub(s)):(e.isub(r),s.isub(f))}var m;return r.cmpn(1)===0?m=f:m=s,m.cmpn(0)<0&&m.iadd(t),m},l.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var r=this.clone(),e=t.clone();r.negative=0,e.negative=0;for(var f=0;r.isEven()&&e.isEven();f++)r.iushrn(1),e.iushrn(1);do{for(;r.isEven();)r.iushrn(1);for(;e.isEven();)e.iushrn(1);var s=r.cmp(e);if(s<0){var a=r;r=e,e=a}else if(s===0||e.cmpn(1)===0)break;r.isub(e)}while(!0);return e.iushln(f)},l.prototype.invm=function(t){return this.egcd(t).a.umod(t)},l.prototype.isEven=function(){return(this.words[0]&1)===0},l.prototype.isOdd=function(){return(this.words[0]&1)===1},l.prototype.andln=function(t){return this.words[0]&t},l.prototype.bincn=function(t){d(typeof t=="number");var r=t%26,e=(t-r)/26,f=1<<r;if(this.length<=e)return this._expand(e+1),this.words[e]|=f,this;for(var s=f,a=e;s!==0&&a<this.length;a++){var u=this.words[a]|0;u+=s,s=u>>>26,u&=67108863,this.words[a]=u}return s!==0&&(this.words[a]=s,this.length++),this},l.prototype.isZero=function(){return this.length===1&&this.words[0]===0},l.prototype.cmpn=function(t){var r=t<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;this._strip();var e;if(this.length>1)e=1;else{r&&(t=-t),d(t<=67108863,"Number is too big");var f=this.words[0]|0;e=f===t?0:f<t?-1:1}return this.negative!==0?-e|0:e},l.prototype.cmp=function(t){if(this.negative!==0&&t.negative===0)return-1;if(this.negative===0&&t.negative!==0)return 1;var r=this.ucmp(t);return this.negative!==0?-r|0:r},l.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var r=0,e=this.length-1;e>=0;e--){var f=this.words[e]|0,s=t.words[e]|0;if(f!==s){f<s?r=-1:f>s&&(r=1);break}}return r},l.prototype.gtn=function(t){return this.cmpn(t)===1},l.prototype.gt=function(t){return this.cmp(t)===1},l.prototype.gten=function(t){return this.cmpn(t)>=0},l.prototype.gte=function(t){return this.cmp(t)>=0},l.prototype.ltn=function(t){return this.cmpn(t)===-1},l.prototype.lt=function(t){return this.cmp(t)===-1},l.prototype.lten=function(t){return this.cmpn(t)<=0},l.prototype.lte=function(t){return this.cmp(t)<=0},l.prototype.eqn=function(t){return this.cmpn(t)===0},l.prototype.eq=function(t){return this.cmp(t)===0},l.red=function(t){return new g(t)},l.prototype.toRed=function(t){return d(!this.red,"Already a number in reduction context"),d(this.negative===0,"red works only with positives"),t.convertTo(this)._forceRed(t)},l.prototype.fromRed=function(){return d(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},l.prototype._forceRed=function(t){return this.red=t,this},l.prototype.forceRed=function(t){return d(!this.red,"Already a number in reduction context"),this._forceRed(t)},l.prototype.redAdd=function(t){return d(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},l.prototype.redIAdd=function(t){return d(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},l.prototype.redSub=function(t){return d(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},l.prototype.redISub=function(t){return d(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},l.prototype.redShl=function(t){return d(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},l.prototype.redMul=function(t){return d(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},l.prototype.redIMul=function(t){return d(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},l.prototype.redSqr=function(){return d(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},l.prototype.redISqr=function(){return d(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},l.prototype.redSqrt=function(){return d(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},l.prototype.redInvm=function(){return d(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},l.prototype.redNeg=function(){return d(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},l.prototype.redPow=function(t){return d(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var dt={k256:null,p224:null,p192:null,p25519:null};function ht(o,t){this.name=o,this.p=new l(t,16),this.n=this.p.bitLength(),this.k=new l(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}ht.prototype._tmp=function(){var t=new l(null);return t.words=new Array(Math.ceil(this.n/13)),t},ht.prototype.ireduce=function(t){var r=t,e;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),e=r.bitLength();while(e>this.n);var f=e<this.n?-1:r.ucmp(this.p);return f===0?(r.words[0]=0,r.length=1):f>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},ht.prototype.split=function(t,r){t.iushrn(this.n,0,r)},ht.prototype.imulK=function(t){return t.imul(this.k)};function at(){ht.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}rt(at,ht),at.prototype.split=function(t,r){for(var e=4194303,f=Math.min(t.length,9),s=0;s<f;s++)r.words[s]=t.words[s];if(r.length=f,t.length<=9){t.words[0]=0,t.length=1;return}var a=t.words[9];for(r.words[r.length++]=a&e,s=10;s<t.length;s++){var u=t.words[s]|0;t.words[s-10]=(u&e)<<4|a>>>22,a=u}a>>>=22,t.words[s-10]=a,a===0&&t.length>10?t.length-=10:t.length-=9},at.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var r=0,e=0;e<t.length;e++){var f=t.words[e]|0;r+=f*977,t.words[e]=r&67108863,r=f*64+(r/67108864|0)}return t.words[t.length-1]===0&&(t.length--,t.words[t.length-1]===0&&t.length--),t};function $t(){ht.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}rt($t,ht);function Ht(){ht.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}rt(Ht,ht);function vt(){ht.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}rt(vt,ht),vt.prototype.imulK=function(t){for(var r=0,e=0;e<t.length;e++){var f=(t.words[e]|0)*19+r,s=f&67108863;f>>>=26,t.words[e]=s,r=f}return r!==0&&(t.words[t.length++]=r),t},l._prime=function(t){if(dt[t])return dt[t];var r;if(t==="k256")r=new at;else if(t==="p224")r=new $t;else if(t==="p192")r=new Ht;else if(t==="p25519")r=new vt;else throw new Error("Unknown prime "+t);return dt[t]=r,r};function g(o){if(typeof o=="string"){var t=l._prime(o);this.m=t.p,this.prime=t}else d(o.gtn(1),"modulus must be greater than 1"),this.m=o,this.prime=null}g.prototype._verify1=function(t){d(t.negative===0,"red works only with positives"),d(t.red,"red works only with red numbers")},g.prototype._verify2=function(t,r){d((t.negative|r.negative)===0,"red works only with positives"),d(t.red&&t.red===r.red,"red works only with red numbers")},g.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(It(t,t.umod(this.m)._forceRed(this)),t)},g.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},g.prototype.add=function(t,r){this._verify2(t,r);var e=t.add(r);return e.cmp(this.m)>=0&&e.isub(this.m),e._forceRed(this)},g.prototype.iadd=function(t,r){this._verify2(t,r);var e=t.iadd(r);return e.cmp(this.m)>=0&&e.isub(this.m),e},g.prototype.sub=function(t,r){this._verify2(t,r);var e=t.sub(r);return e.cmpn(0)<0&&e.iadd(this.m),e._forceRed(this)},g.prototype.isub=function(t,r){this._verify2(t,r);var e=t.isub(r);return e.cmpn(0)<0&&e.iadd(this.m),e},g.prototype.shl=function(t,r){return this._verify1(t),this.imod(t.ushln(r))},g.prototype.imul=function(t,r){return this._verify2(t,r),this.imod(t.imul(r))},g.prototype.mul=function(t,r){return this._verify2(t,r),this.imod(t.mul(r))},g.prototype.isqr=function(t){return this.imul(t,t.clone())},g.prototype.sqr=function(t){return this.mul(t,t)},g.prototype.sqrt=function(t){if(t.isZero())return t.clone();var r=this.m.andln(3);if(d(r%2===1),r===3){var e=this.m.add(new l(1)).iushrn(2);return this.pow(t,e)}for(var f=this.m.subn(1),s=0;!f.isZero()&&f.andln(1)===0;)s++,f.iushrn(1);d(!f.isZero());var a=new l(1).toRed(this),u=a.redNeg(),h=this.m.subn(1).iushrn(1),i=this.m.bitLength();for(i=new l(2*i*i).toRed(this);this.pow(i,h).cmp(u)!==0;)i.redIAdd(u);for(var n=this.pow(i,f),m=this.pow(t,f.addn(1).iushrn(1)),v=this.pow(t,f),p=s;v.cmp(a)!==0;){for(var et=v,M=0;et.cmp(a)!==0;M++)et=et.redSqr();d(M<p);var c=this.pow(n,new l(1).iushln(p-M-1));m=m.redMul(c),n=c.redSqr(),v=v.redMul(n),p=M}return m},g.prototype.invm=function(t){var r=t._invmp(this.m);return r.negative!==0?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},g.prototype.pow=function(t,r){if(r.isZero())return new l(1).toRed(this);if(r.cmpn(1)===0)return t.clone();var e=4,f=new Array(1<<e);f[0]=new l(1).toRed(this),f[1]=t;for(var s=2;s<f.length;s++)f[s]=this.mul(f[s-1],t);var a=f[0],u=0,h=0,i=r.bitLength()%26;for(i===0&&(i=26),s=r.length-1;s>=0;s--){for(var n=r.words[s],m=i-1;m>=0;m--){var v=n>>m&1;if(a!==f[0]&&(a=this.sqr(a)),v===0&&u===0){h=0;continue}u<<=1,u|=v,h++,!(h!==e&&(s!==0||m!==0))&&(a=this.mul(a,f[u]),h=0,u=0)}i=26}return a},g.prototype.convertTo=function(t){var r=t.umod(this.m);return r===t?r.clone():r},g.prototype.convertFrom=function(t){var r=t.clone();return r.red=null,r},l.mont=function(t){return new st(t)};function st(o){g.call(this,o),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new l(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}rt(st,g),st.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},st.prototype.convertFrom=function(t){var r=this.imod(t.mul(this.rinv));return r.red=null,r},st.prototype.imul=function(t,r){if(t.isZero()||r.isZero())return t.words[0]=0,t.length=1,t;var e=t.imul(r),f=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=e.isub(f).iushrn(this.shift),a=s;return s.cmp(this.m)>=0?a=s.isub(this.m):s.cmpn(0)<0&&(a=s.iadd(this.m)),a._forceRed(this)},st.prototype.mul=function(t,r){if(t.isZero()||r.isZero())return new l(0)._forceRed(this);var e=t.mul(r),f=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=e.isub(f).iushrn(this.shift),a=s;return s.cmp(this.m)>=0?a=s.isub(this.m):s.cmpn(0)<0&&(a=s.iadd(this.m)),a._forceRed(this)},st.prototype.invm=function(t){var r=this.imod(t._invmp(this.m).mul(this.r2));return r._forceRed(this)}})(it,yi)})(lt)),lt.exports}var ai=xi();const _i=pi(ai),bi=mi({__proto__:null,default:_i},[ai]);exports.bn=bi;
1
+ "use strict";function mi(it,nt){for(var ft=0;ft<nt.length;ft++){const d=nt[ft];if(typeof d!="string"&&!Array.isArray(d)){for(const rt in d)if(rt!=="default"&&!(rt in it)){const l=Object.getOwnPropertyDescriptor(d,rt);l&&Object.defineProperty(it,rt,l.get?l:{enumerable:!0,get:()=>d[rt]})}}}return Object.freeze(Object.defineProperty(it,Symbol.toStringTag,{value:"Module"}))}function pi(it){return it&&it.__esModule&&Object.prototype.hasOwnProperty.call(it,"default")?it.default:it}function Mi(it){if(Object.prototype.hasOwnProperty.call(it,"__esModule"))return it;var nt=it.default;if(typeof nt=="function"){var ft=function d(){var rt=!1;try{rt=this instanceof d}catch{}return rt?Reflect.construct(nt,arguments,this.constructor):nt.apply(this,arguments)};ft.prototype=nt.prototype}else ft={};return Object.defineProperty(ft,"__esModule",{value:!0}),Object.keys(it).forEach(function(d){var rt=Object.getOwnPropertyDescriptor(it,d);Object.defineProperty(ft,d,rt.get?rt:{enumerable:!0,get:function(){return it[d]}})}),ft}const ci={},gi=Object.freeze(Object.defineProperty({__proto__:null,default:ci},Symbol.toStringTag,{value:"Module"}));var lt={exports:{}};const wi=Mi(gi);var yi=lt.exports,oi;function xi(){return oi||(oi=1,(function(it){(function(nt,ft){function d(o,t){if(!o)throw new Error(t||"Assertion failed")}function rt(o,t){o.super_=t;var r=function(){};r.prototype=t.prototype,o.prototype=new r,o.prototype.constructor=o}function l(o,t,r){if(l.isBN(o))return o;this.negative=0,this.words=null,this.length=0,this.red=null,o!==null&&((t==="le"||t==="be")&&(r=t,t=10),this._init(o||0,t||10,r||"be"))}typeof nt=="object"?nt.exports=l:ft.BN=l,l.BN=l,l.wordSize=26;var ot;try{typeof window<"u"&&typeof window.Buffer<"u"?ot=window.Buffer:ot=wi.Buffer}catch{}l.isBN=function(t){return t instanceof l?!0:t!==null&&typeof t=="object"&&t.constructor.wordSize===l.wordSize&&Array.isArray(t.words)},l.max=function(t,r){return t.cmp(r)>0?t:r},l.min=function(t,r){return t.cmp(r)<0?t:r},l.prototype._init=function(t,r,e){if(typeof t=="number")return this._initNumber(t,r,e);if(typeof t=="object")return this._initArray(t,r,e);r==="hex"&&(r=16),d(r===(r|0)&&r>=2&&r<=36),t=t.toString().replace(/\s+/g,"");var f=0;t[0]==="-"&&(f++,this.negative=1),f<t.length&&(r===16?this._parseHex(t,f,e):(this._parseBase(t,r,f),e==="le"&&this._initArray(this.toArray(),r,e)))},l.prototype._initNumber=function(t,r,e){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[t&67108863],this.length=1):t<4503599627370496?(this.words=[t&67108863,t/67108864&67108863],this.length=2):(d(t<9007199254740992),this.words=[t&67108863,t/67108864&67108863,1],this.length=3),e==="le"&&this._initArray(this.toArray(),r,e)},l.prototype._initArray=function(t,r,e){if(d(typeof t.length=="number"),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var f=0;f<this.length;f++)this.words[f]=0;var s,a,u=0;if(e==="be")for(f=t.length-1,s=0;f>=0;f-=3)a=t[f]|t[f-1]<<8|t[f-2]<<16,this.words[s]|=a<<u&67108863,this.words[s+1]=a>>>26-u&67108863,u+=24,u>=26&&(u-=26,s++);else if(e==="le")for(f=0,s=0;f<t.length;f+=3)a=t[f]|t[f+1]<<8|t[f+2]<<16,this.words[s]|=a<<u&67108863,this.words[s+1]=a>>>26-u&67108863,u+=24,u>=26&&(u-=26,s++);return this._strip()};function Zt(o,t){var r=o.charCodeAt(t);if(r>=48&&r<=57)return r-48;if(r>=65&&r<=70)return r-55;if(r>=97&&r<=102)return r-87;d(!1,"Invalid character in "+o)}function Et(o,t,r){var e=Zt(o,r);return r-1>=t&&(e|=Zt(o,r-1)<<4),e}l.prototype._parseHex=function(t,r,e){this.length=Math.ceil((t.length-r)/6),this.words=new Array(this.length);for(var f=0;f<this.length;f++)this.words[f]=0;var s=0,a=0,u;if(e==="be")for(f=t.length-1;f>=r;f-=2)u=Et(t,r,f)<<s,this.words[a]|=u&67108863,s>=18?(s-=18,a+=1,this.words[a]|=u>>>26):s+=8;else{var h=t.length-r;for(f=h%2===0?r+1:r;f<t.length;f+=2)u=Et(t,r,f)<<s,this.words[a]|=u&67108863,s>=18?(s-=18,a+=1,this.words[a]|=u>>>26):s+=8}this._strip()};function Tt(o,t,r,e){for(var f=0,s=0,a=Math.min(o.length,r),u=t;u<a;u++){var h=o.charCodeAt(u)-48;f*=e,h>=49?s=h-49+10:h>=17?s=h-17+10:s=h,d(h>=0&&s<e,"Invalid character"),f+=s}return f}l.prototype._parseBase=function(t,r,e){this.words=[0],this.length=1;for(var f=0,s=1;s<=67108863;s*=r)f++;f--,s=s/r|0;for(var a=t.length-e,u=a%f,h=Math.min(a,a-u)+e,i=0,n=e;n<h;n+=f)i=Tt(t,n,n+f,r),this.imuln(s),this.words[0]+i<67108864?this.words[0]+=i:this._iaddn(i);if(u!==0){var m=1;for(i=Tt(t,n,t.length,r),n=0;n<u;n++)m*=r;this.imuln(m),this.words[0]+i<67108864?this.words[0]+=i:this._iaddn(i)}this._strip()},l.prototype.copy=function(t){t.words=new Array(this.length);for(var r=0;r<this.length;r++)t.words[r]=this.words[r];t.length=this.length,t.negative=this.negative,t.red=this.red};function It(o,t){o.words=t.words,o.length=t.length,o.negative=t.negative,o.red=t.red}if(l.prototype._move=function(t){It(t,this)},l.prototype.clone=function(){var t=new l(null);return this.copy(t),t},l.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},l.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},l.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{l.prototype[Symbol.for("nodejs.util.inspect.custom")]=ut}catch{l.prototype.inspect=ut}else l.prototype.inspect=ut;function ut(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var zt=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],li=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],ui=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];l.prototype.toString=function(t,r){t=t||10,r=r|0||1;var e;if(t===16||t==="hex"){e="";for(var f=0,s=0,a=0;a<this.length;a++){var u=this.words[a],h=((u<<f|s)&16777215).toString(16);s=u>>>24-f&16777215,f+=2,f>=26&&(f-=26,a--),s!==0||a!==this.length-1?e=zt[6-h.length]+h+e:e=h+e}for(s!==0&&(e=s.toString(16)+e);e.length%r!==0;)e="0"+e;return this.negative!==0&&(e="-"+e),e}if(t===(t|0)&&t>=2&&t<=36){var i=li[t],n=ui[t];e="";var m=this.clone();for(m.negative=0;!m.isZero();){var v=m.modrn(n).toString(t);m=m.idivn(n),m.isZero()?e=v+e:e=zt[i-v.length]+v+e}for(this.isZero()&&(e="0"+e);e.length%r!==0;)e="0"+e;return this.negative!==0&&(e="-"+e),e}d(!1,"Base should be between 2 and 36")},l.prototype.toNumber=function(){var t=this.words[0];return this.length===2?t+=this.words[1]*67108864:this.length===3&&this.words[2]===1?t+=4503599627370496+this.words[1]*67108864:this.length>2&&d(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-t:t},l.prototype.toJSON=function(){return this.toString(16,2)},ot&&(l.prototype.toBuffer=function(t,r){return this.toArrayLike(ot,t,r)}),l.prototype.toArray=function(t,r){return this.toArrayLike(Array,t,r)};var di=function(t,r){return t.allocUnsafe?t.allocUnsafe(r):new t(r)};l.prototype.toArrayLike=function(t,r,e){this._strip();var f=this.byteLength(),s=e||Math.max(1,f);d(f<=s,"byte array longer than desired length"),d(s>0,"Requested array length <= 0");var a=di(t,s),u=r==="le"?"LE":"BE";return this["_toArrayLike"+u](a,f),a},l.prototype._toArrayLikeLE=function(t,r){for(var e=0,f=0,s=0,a=0;s<this.length;s++){var u=this.words[s]<<a|f;t[e++]=u&255,e<t.length&&(t[e++]=u>>8&255),e<t.length&&(t[e++]=u>>16&255),a===6?(e<t.length&&(t[e++]=u>>24&255),f=0,a=0):(f=u>>>24,a+=2)}if(e<t.length)for(t[e++]=f;e<t.length;)t[e++]=0},l.prototype._toArrayLikeBE=function(t,r){for(var e=t.length-1,f=0,s=0,a=0;s<this.length;s++){var u=this.words[s]<<a|f;t[e--]=u&255,e>=0&&(t[e--]=u>>8&255),e>=0&&(t[e--]=u>>16&255),a===6?(e>=0&&(t[e--]=u>>24&255),f=0,a=0):(f=u>>>24,a+=2)}if(e>=0)for(t[e--]=f;e>=0;)t[e--]=0},Math.clz32?l.prototype._countBits=function(t){return 32-Math.clz32(t)}:l.prototype._countBits=function(t){var r=t,e=0;return r>=4096&&(e+=13,r>>>=13),r>=64&&(e+=7,r>>>=7),r>=8&&(e+=4,r>>>=4),r>=2&&(e+=2,r>>>=2),e+r},l.prototype._zeroBits=function(t){if(t===0)return 26;var r=t,e=0;return(r&8191)===0&&(e+=13,r>>>=13),(r&127)===0&&(e+=7,r>>>=7),(r&15)===0&&(e+=4,r>>>=4),(r&3)===0&&(e+=2,r>>>=2),(r&1)===0&&e++,e},l.prototype.bitLength=function(){var t=this.words[this.length-1],r=this._countBits(t);return(this.length-1)*26+r};function vi(o){for(var t=new Array(o.bitLength()),r=0;r<t.length;r++){var e=r/26|0,f=r%26;t[r]=o.words[e]>>>f&1}return t}l.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,r=0;r<this.length;r++){var e=this._zeroBits(this.words[r]);if(t+=e,e!==26)break}return t},l.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},l.prototype.toTwos=function(t){return this.negative!==0?this.abs().inotn(t).iaddn(1):this.clone()},l.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},l.prototype.isNeg=function(){return this.negative!==0},l.prototype.neg=function(){return this.clone().ineg()},l.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},l.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var r=0;r<t.length;r++)this.words[r]=this.words[r]|t.words[r];return this._strip()},l.prototype.ior=function(t){return d((this.negative|t.negative)===0),this.iuor(t)},l.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},l.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},l.prototype.iuand=function(t){var r;this.length>t.length?r=t:r=this;for(var e=0;e<r.length;e++)this.words[e]=this.words[e]&t.words[e];return this.length=r.length,this._strip()},l.prototype.iand=function(t){return d((this.negative|t.negative)===0),this.iuand(t)},l.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},l.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},l.prototype.iuxor=function(t){var r,e;this.length>t.length?(r=this,e=t):(r=t,e=this);for(var f=0;f<e.length;f++)this.words[f]=r.words[f]^e.words[f];if(this!==r)for(;f<r.length;f++)this.words[f]=r.words[f];return this.length=r.length,this._strip()},l.prototype.ixor=function(t){return d((this.negative|t.negative)===0),this.iuxor(t)},l.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},l.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},l.prototype.inotn=function(t){d(typeof t=="number"&&t>=0);var r=Math.ceil(t/26)|0,e=t%26;this._expand(r),e>0&&r--;for(var f=0;f<r;f++)this.words[f]=~this.words[f]&67108863;return e>0&&(this.words[f]=~this.words[f]&67108863>>26-e),this._strip()},l.prototype.notn=function(t){return this.clone().inotn(t)},l.prototype.setn=function(t,r){d(typeof t=="number"&&t>=0);var e=t/26|0,f=t%26;return this._expand(e+1),r?this.words[e]=this.words[e]|1<<f:this.words[e]=this.words[e]&~(1<<f),this._strip()},l.prototype.iadd=function(t){var r;if(this.negative!==0&&t.negative===0)return this.negative=0,r=this.isub(t),this.negative^=1,this._normSign();if(this.negative===0&&t.negative!==0)return t.negative=0,r=this.isub(t),t.negative=1,r._normSign();var e,f;this.length>t.length?(e=this,f=t):(e=t,f=this);for(var s=0,a=0;a<f.length;a++)r=(e.words[a]|0)+(f.words[a]|0)+s,this.words[a]=r&67108863,s=r>>>26;for(;s!==0&&a<e.length;a++)r=(e.words[a]|0)+s,this.words[a]=r&67108863,s=r>>>26;if(this.length=e.length,s!==0)this.words[this.length]=s,this.length++;else if(e!==this)for(;a<e.length;a++)this.words[a]=e.words[a];return this},l.prototype.add=function(t){var r;return t.negative!==0&&this.negative===0?(t.negative=0,r=this.sub(t),t.negative^=1,r):t.negative===0&&this.negative!==0?(this.negative=0,r=t.sub(this),this.negative=1,r):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},l.prototype.isub=function(t){if(t.negative!==0){t.negative=0;var r=this.iadd(t);return t.negative=1,r._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var e=this.cmp(t);if(e===0)return this.negative=0,this.length=1,this.words[0]=0,this;var f,s;e>0?(f=this,s=t):(f=t,s=this);for(var a=0,u=0;u<s.length;u++)r=(f.words[u]|0)-(s.words[u]|0)+a,a=r>>26,this.words[u]=r&67108863;for(;a!==0&&u<f.length;u++)r=(f.words[u]|0)+a,a=r>>26,this.words[u]=r&67108863;if(a===0&&u<f.length&&f!==this)for(;u<f.length;u++)this.words[u]=f.words[u];return this.length=Math.max(this.length,u),f!==this&&(this.negative=1),this._strip()},l.prototype.sub=function(t){return this.clone().isub(t)};function Pt(o,t,r){r.negative=t.negative^o.negative;var e=o.length+t.length|0;r.length=e,e=e-1|0;var f=o.words[0]|0,s=t.words[0]|0,a=f*s,u=a&67108863,h=a/67108864|0;r.words[0]=u;for(var i=1;i<e;i++){for(var n=h>>>26,m=h&67108863,v=Math.min(i,t.length-1),p=Math.max(0,i-o.length+1);p<=v;p++){var et=i-p|0;f=o.words[et]|0,s=t.words[p]|0,a=f*s+m,n+=a/67108864|0,m=a&67108863}r.words[i]=m|0,h=n|0}return h!==0?r.words[i]=h|0:r.length--,r._strip()}var Kt=function(t,r,e){var f=t.words,s=r.words,a=e.words,u=0,h,i,n,m=f[0]|0,v=m&8191,p=m>>>13,et=f[1]|0,M=et&8191,c=et>>>13,Ct=f[2]|0,w=Ct&8191,y=Ct>>>13,Ut=f[3]|0,x=Ut&8191,_=Ut>>>13,Jt=f[4]|0,b=Jt&8191,S=Jt>>>13,Wt=f[5]|0,A=Wt&8191,B=Wt>>>13,Gt=f[6]|0,k=Gt&8191,q=Gt>>>13,Qt=f[7]|0,N=Qt&8191,R=Qt>>>13,Vt=f[8]|0,L=Vt&8191,O=Vt>>>13,Xt=f[9]|0,Z=Xt&8191,E=Xt>>>13,Yt=s[0]|0,T=Yt&8191,I=Yt>>>13,jt=s[1]|0,z=jt&8191,P=jt>>>13,ti=s[2]|0,K=ti&8191,D=ti>>>13,ii=s[3]|0,F=ii&8191,$=ii>>>13,ri=s[4]|0,H=ri&8191,C=ri>>>13,ei=s[5]|0,U=ei&8191,J=ei>>>13,hi=s[6]|0,W=hi&8191,G=hi>>>13,fi=s[7]|0,Q=fi&8191,V=fi>>>13,ni=s[8]|0,X=ni&8191,Y=ni>>>13,si=s[9]|0,j=si&8191,tt=si>>>13;e.negative=t.negative^r.negative,e.length=19,h=Math.imul(v,T),i=Math.imul(v,I),i=i+Math.imul(p,T)|0,n=Math.imul(p,I);var mt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(mt>>>26)|0,mt&=67108863,h=Math.imul(M,T),i=Math.imul(M,I),i=i+Math.imul(c,T)|0,n=Math.imul(c,I),h=h+Math.imul(v,z)|0,i=i+Math.imul(v,P)|0,i=i+Math.imul(p,z)|0,n=n+Math.imul(p,P)|0;var pt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(pt>>>26)|0,pt&=67108863,h=Math.imul(w,T),i=Math.imul(w,I),i=i+Math.imul(y,T)|0,n=Math.imul(y,I),h=h+Math.imul(M,z)|0,i=i+Math.imul(M,P)|0,i=i+Math.imul(c,z)|0,n=n+Math.imul(c,P)|0,h=h+Math.imul(v,K)|0,i=i+Math.imul(v,D)|0,i=i+Math.imul(p,K)|0,n=n+Math.imul(p,D)|0;var Mt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,h=Math.imul(x,T),i=Math.imul(x,I),i=i+Math.imul(_,T)|0,n=Math.imul(_,I),h=h+Math.imul(w,z)|0,i=i+Math.imul(w,P)|0,i=i+Math.imul(y,z)|0,n=n+Math.imul(y,P)|0,h=h+Math.imul(M,K)|0,i=i+Math.imul(M,D)|0,i=i+Math.imul(c,K)|0,n=n+Math.imul(c,D)|0,h=h+Math.imul(v,F)|0,i=i+Math.imul(v,$)|0,i=i+Math.imul(p,F)|0,n=n+Math.imul(p,$)|0;var ct=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(ct>>>26)|0,ct&=67108863,h=Math.imul(b,T),i=Math.imul(b,I),i=i+Math.imul(S,T)|0,n=Math.imul(S,I),h=h+Math.imul(x,z)|0,i=i+Math.imul(x,P)|0,i=i+Math.imul(_,z)|0,n=n+Math.imul(_,P)|0,h=h+Math.imul(w,K)|0,i=i+Math.imul(w,D)|0,i=i+Math.imul(y,K)|0,n=n+Math.imul(y,D)|0,h=h+Math.imul(M,F)|0,i=i+Math.imul(M,$)|0,i=i+Math.imul(c,F)|0,n=n+Math.imul(c,$)|0,h=h+Math.imul(v,H)|0,i=i+Math.imul(v,C)|0,i=i+Math.imul(p,H)|0,n=n+Math.imul(p,C)|0;var gt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(gt>>>26)|0,gt&=67108863,h=Math.imul(A,T),i=Math.imul(A,I),i=i+Math.imul(B,T)|0,n=Math.imul(B,I),h=h+Math.imul(b,z)|0,i=i+Math.imul(b,P)|0,i=i+Math.imul(S,z)|0,n=n+Math.imul(S,P)|0,h=h+Math.imul(x,K)|0,i=i+Math.imul(x,D)|0,i=i+Math.imul(_,K)|0,n=n+Math.imul(_,D)|0,h=h+Math.imul(w,F)|0,i=i+Math.imul(w,$)|0,i=i+Math.imul(y,F)|0,n=n+Math.imul(y,$)|0,h=h+Math.imul(M,H)|0,i=i+Math.imul(M,C)|0,i=i+Math.imul(c,H)|0,n=n+Math.imul(c,C)|0,h=h+Math.imul(v,U)|0,i=i+Math.imul(v,J)|0,i=i+Math.imul(p,U)|0,n=n+Math.imul(p,J)|0;var wt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(wt>>>26)|0,wt&=67108863,h=Math.imul(k,T),i=Math.imul(k,I),i=i+Math.imul(q,T)|0,n=Math.imul(q,I),h=h+Math.imul(A,z)|0,i=i+Math.imul(A,P)|0,i=i+Math.imul(B,z)|0,n=n+Math.imul(B,P)|0,h=h+Math.imul(b,K)|0,i=i+Math.imul(b,D)|0,i=i+Math.imul(S,K)|0,n=n+Math.imul(S,D)|0,h=h+Math.imul(x,F)|0,i=i+Math.imul(x,$)|0,i=i+Math.imul(_,F)|0,n=n+Math.imul(_,$)|0,h=h+Math.imul(w,H)|0,i=i+Math.imul(w,C)|0,i=i+Math.imul(y,H)|0,n=n+Math.imul(y,C)|0,h=h+Math.imul(M,U)|0,i=i+Math.imul(M,J)|0,i=i+Math.imul(c,U)|0,n=n+Math.imul(c,J)|0,h=h+Math.imul(v,W)|0,i=i+Math.imul(v,G)|0,i=i+Math.imul(p,W)|0,n=n+Math.imul(p,G)|0;var yt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(yt>>>26)|0,yt&=67108863,h=Math.imul(N,T),i=Math.imul(N,I),i=i+Math.imul(R,T)|0,n=Math.imul(R,I),h=h+Math.imul(k,z)|0,i=i+Math.imul(k,P)|0,i=i+Math.imul(q,z)|0,n=n+Math.imul(q,P)|0,h=h+Math.imul(A,K)|0,i=i+Math.imul(A,D)|0,i=i+Math.imul(B,K)|0,n=n+Math.imul(B,D)|0,h=h+Math.imul(b,F)|0,i=i+Math.imul(b,$)|0,i=i+Math.imul(S,F)|0,n=n+Math.imul(S,$)|0,h=h+Math.imul(x,H)|0,i=i+Math.imul(x,C)|0,i=i+Math.imul(_,H)|0,n=n+Math.imul(_,C)|0,h=h+Math.imul(w,U)|0,i=i+Math.imul(w,J)|0,i=i+Math.imul(y,U)|0,n=n+Math.imul(y,J)|0,h=h+Math.imul(M,W)|0,i=i+Math.imul(M,G)|0,i=i+Math.imul(c,W)|0,n=n+Math.imul(c,G)|0,h=h+Math.imul(v,Q)|0,i=i+Math.imul(v,V)|0,i=i+Math.imul(p,Q)|0,n=n+Math.imul(p,V)|0;var xt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(xt>>>26)|0,xt&=67108863,h=Math.imul(L,T),i=Math.imul(L,I),i=i+Math.imul(O,T)|0,n=Math.imul(O,I),h=h+Math.imul(N,z)|0,i=i+Math.imul(N,P)|0,i=i+Math.imul(R,z)|0,n=n+Math.imul(R,P)|0,h=h+Math.imul(k,K)|0,i=i+Math.imul(k,D)|0,i=i+Math.imul(q,K)|0,n=n+Math.imul(q,D)|0,h=h+Math.imul(A,F)|0,i=i+Math.imul(A,$)|0,i=i+Math.imul(B,F)|0,n=n+Math.imul(B,$)|0,h=h+Math.imul(b,H)|0,i=i+Math.imul(b,C)|0,i=i+Math.imul(S,H)|0,n=n+Math.imul(S,C)|0,h=h+Math.imul(x,U)|0,i=i+Math.imul(x,J)|0,i=i+Math.imul(_,U)|0,n=n+Math.imul(_,J)|0,h=h+Math.imul(w,W)|0,i=i+Math.imul(w,G)|0,i=i+Math.imul(y,W)|0,n=n+Math.imul(y,G)|0,h=h+Math.imul(M,Q)|0,i=i+Math.imul(M,V)|0,i=i+Math.imul(c,Q)|0,n=n+Math.imul(c,V)|0,h=h+Math.imul(v,X)|0,i=i+Math.imul(v,Y)|0,i=i+Math.imul(p,X)|0,n=n+Math.imul(p,Y)|0;var _t=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(_t>>>26)|0,_t&=67108863,h=Math.imul(Z,T),i=Math.imul(Z,I),i=i+Math.imul(E,T)|0,n=Math.imul(E,I),h=h+Math.imul(L,z)|0,i=i+Math.imul(L,P)|0,i=i+Math.imul(O,z)|0,n=n+Math.imul(O,P)|0,h=h+Math.imul(N,K)|0,i=i+Math.imul(N,D)|0,i=i+Math.imul(R,K)|0,n=n+Math.imul(R,D)|0,h=h+Math.imul(k,F)|0,i=i+Math.imul(k,$)|0,i=i+Math.imul(q,F)|0,n=n+Math.imul(q,$)|0,h=h+Math.imul(A,H)|0,i=i+Math.imul(A,C)|0,i=i+Math.imul(B,H)|0,n=n+Math.imul(B,C)|0,h=h+Math.imul(b,U)|0,i=i+Math.imul(b,J)|0,i=i+Math.imul(S,U)|0,n=n+Math.imul(S,J)|0,h=h+Math.imul(x,W)|0,i=i+Math.imul(x,G)|0,i=i+Math.imul(_,W)|0,n=n+Math.imul(_,G)|0,h=h+Math.imul(w,Q)|0,i=i+Math.imul(w,V)|0,i=i+Math.imul(y,Q)|0,n=n+Math.imul(y,V)|0,h=h+Math.imul(M,X)|0,i=i+Math.imul(M,Y)|0,i=i+Math.imul(c,X)|0,n=n+Math.imul(c,Y)|0,h=h+Math.imul(v,j)|0,i=i+Math.imul(v,tt)|0,i=i+Math.imul(p,j)|0,n=n+Math.imul(p,tt)|0;var bt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(bt>>>26)|0,bt&=67108863,h=Math.imul(Z,z),i=Math.imul(Z,P),i=i+Math.imul(E,z)|0,n=Math.imul(E,P),h=h+Math.imul(L,K)|0,i=i+Math.imul(L,D)|0,i=i+Math.imul(O,K)|0,n=n+Math.imul(O,D)|0,h=h+Math.imul(N,F)|0,i=i+Math.imul(N,$)|0,i=i+Math.imul(R,F)|0,n=n+Math.imul(R,$)|0,h=h+Math.imul(k,H)|0,i=i+Math.imul(k,C)|0,i=i+Math.imul(q,H)|0,n=n+Math.imul(q,C)|0,h=h+Math.imul(A,U)|0,i=i+Math.imul(A,J)|0,i=i+Math.imul(B,U)|0,n=n+Math.imul(B,J)|0,h=h+Math.imul(b,W)|0,i=i+Math.imul(b,G)|0,i=i+Math.imul(S,W)|0,n=n+Math.imul(S,G)|0,h=h+Math.imul(x,Q)|0,i=i+Math.imul(x,V)|0,i=i+Math.imul(_,Q)|0,n=n+Math.imul(_,V)|0,h=h+Math.imul(w,X)|0,i=i+Math.imul(w,Y)|0,i=i+Math.imul(y,X)|0,n=n+Math.imul(y,Y)|0,h=h+Math.imul(M,j)|0,i=i+Math.imul(M,tt)|0,i=i+Math.imul(c,j)|0,n=n+Math.imul(c,tt)|0;var St=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(St>>>26)|0,St&=67108863,h=Math.imul(Z,K),i=Math.imul(Z,D),i=i+Math.imul(E,K)|0,n=Math.imul(E,D),h=h+Math.imul(L,F)|0,i=i+Math.imul(L,$)|0,i=i+Math.imul(O,F)|0,n=n+Math.imul(O,$)|0,h=h+Math.imul(N,H)|0,i=i+Math.imul(N,C)|0,i=i+Math.imul(R,H)|0,n=n+Math.imul(R,C)|0,h=h+Math.imul(k,U)|0,i=i+Math.imul(k,J)|0,i=i+Math.imul(q,U)|0,n=n+Math.imul(q,J)|0,h=h+Math.imul(A,W)|0,i=i+Math.imul(A,G)|0,i=i+Math.imul(B,W)|0,n=n+Math.imul(B,G)|0,h=h+Math.imul(b,Q)|0,i=i+Math.imul(b,V)|0,i=i+Math.imul(S,Q)|0,n=n+Math.imul(S,V)|0,h=h+Math.imul(x,X)|0,i=i+Math.imul(x,Y)|0,i=i+Math.imul(_,X)|0,n=n+Math.imul(_,Y)|0,h=h+Math.imul(w,j)|0,i=i+Math.imul(w,tt)|0,i=i+Math.imul(y,j)|0,n=n+Math.imul(y,tt)|0;var At=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(At>>>26)|0,At&=67108863,h=Math.imul(Z,F),i=Math.imul(Z,$),i=i+Math.imul(E,F)|0,n=Math.imul(E,$),h=h+Math.imul(L,H)|0,i=i+Math.imul(L,C)|0,i=i+Math.imul(O,H)|0,n=n+Math.imul(O,C)|0,h=h+Math.imul(N,U)|0,i=i+Math.imul(N,J)|0,i=i+Math.imul(R,U)|0,n=n+Math.imul(R,J)|0,h=h+Math.imul(k,W)|0,i=i+Math.imul(k,G)|0,i=i+Math.imul(q,W)|0,n=n+Math.imul(q,G)|0,h=h+Math.imul(A,Q)|0,i=i+Math.imul(A,V)|0,i=i+Math.imul(B,Q)|0,n=n+Math.imul(B,V)|0,h=h+Math.imul(b,X)|0,i=i+Math.imul(b,Y)|0,i=i+Math.imul(S,X)|0,n=n+Math.imul(S,Y)|0,h=h+Math.imul(x,j)|0,i=i+Math.imul(x,tt)|0,i=i+Math.imul(_,j)|0,n=n+Math.imul(_,tt)|0;var Bt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(Bt>>>26)|0,Bt&=67108863,h=Math.imul(Z,H),i=Math.imul(Z,C),i=i+Math.imul(E,H)|0,n=Math.imul(E,C),h=h+Math.imul(L,U)|0,i=i+Math.imul(L,J)|0,i=i+Math.imul(O,U)|0,n=n+Math.imul(O,J)|0,h=h+Math.imul(N,W)|0,i=i+Math.imul(N,G)|0,i=i+Math.imul(R,W)|0,n=n+Math.imul(R,G)|0,h=h+Math.imul(k,Q)|0,i=i+Math.imul(k,V)|0,i=i+Math.imul(q,Q)|0,n=n+Math.imul(q,V)|0,h=h+Math.imul(A,X)|0,i=i+Math.imul(A,Y)|0,i=i+Math.imul(B,X)|0,n=n+Math.imul(B,Y)|0,h=h+Math.imul(b,j)|0,i=i+Math.imul(b,tt)|0,i=i+Math.imul(S,j)|0,n=n+Math.imul(S,tt)|0;var kt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(kt>>>26)|0,kt&=67108863,h=Math.imul(Z,U),i=Math.imul(Z,J),i=i+Math.imul(E,U)|0,n=Math.imul(E,J),h=h+Math.imul(L,W)|0,i=i+Math.imul(L,G)|0,i=i+Math.imul(O,W)|0,n=n+Math.imul(O,G)|0,h=h+Math.imul(N,Q)|0,i=i+Math.imul(N,V)|0,i=i+Math.imul(R,Q)|0,n=n+Math.imul(R,V)|0,h=h+Math.imul(k,X)|0,i=i+Math.imul(k,Y)|0,i=i+Math.imul(q,X)|0,n=n+Math.imul(q,Y)|0,h=h+Math.imul(A,j)|0,i=i+Math.imul(A,tt)|0,i=i+Math.imul(B,j)|0,n=n+Math.imul(B,tt)|0;var qt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(qt>>>26)|0,qt&=67108863,h=Math.imul(Z,W),i=Math.imul(Z,G),i=i+Math.imul(E,W)|0,n=Math.imul(E,G),h=h+Math.imul(L,Q)|0,i=i+Math.imul(L,V)|0,i=i+Math.imul(O,Q)|0,n=n+Math.imul(O,V)|0,h=h+Math.imul(N,X)|0,i=i+Math.imul(N,Y)|0,i=i+Math.imul(R,X)|0,n=n+Math.imul(R,Y)|0,h=h+Math.imul(k,j)|0,i=i+Math.imul(k,tt)|0,i=i+Math.imul(q,j)|0,n=n+Math.imul(q,tt)|0;var Nt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(Nt>>>26)|0,Nt&=67108863,h=Math.imul(Z,Q),i=Math.imul(Z,V),i=i+Math.imul(E,Q)|0,n=Math.imul(E,V),h=h+Math.imul(L,X)|0,i=i+Math.imul(L,Y)|0,i=i+Math.imul(O,X)|0,n=n+Math.imul(O,Y)|0,h=h+Math.imul(N,j)|0,i=i+Math.imul(N,tt)|0,i=i+Math.imul(R,j)|0,n=n+Math.imul(R,tt)|0;var Rt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,h=Math.imul(Z,X),i=Math.imul(Z,Y),i=i+Math.imul(E,X)|0,n=Math.imul(E,Y),h=h+Math.imul(L,j)|0,i=i+Math.imul(L,tt)|0,i=i+Math.imul(O,j)|0,n=n+Math.imul(O,tt)|0;var Lt=(u+h|0)+((i&8191)<<13)|0;u=(n+(i>>>13)|0)+(Lt>>>26)|0,Lt&=67108863,h=Math.imul(Z,j),i=Math.imul(Z,tt),i=i+Math.imul(E,j)|0,n=Math.imul(E,tt);var Ot=(u+h|0)+((i&8191)<<13)|0;return u=(n+(i>>>13)|0)+(Ot>>>26)|0,Ot&=67108863,a[0]=mt,a[1]=pt,a[2]=Mt,a[3]=ct,a[4]=gt,a[5]=wt,a[6]=yt,a[7]=xt,a[8]=_t,a[9]=bt,a[10]=St,a[11]=At,a[12]=Bt,a[13]=kt,a[14]=qt,a[15]=Nt,a[16]=Rt,a[17]=Lt,a[18]=Ot,u!==0&&(a[19]=u,e.length++),e};Math.imul||(Kt=Pt);function Dt(o,t,r){r.negative=t.negative^o.negative,r.length=o.length+t.length;for(var e=0,f=0,s=0;s<r.length-1;s++){var a=f;f=0;for(var u=e&67108863,h=Math.min(s,t.length-1),i=Math.max(0,s-o.length+1);i<=h;i++){var n=s-i,m=o.words[n]|0,v=t.words[i]|0,p=m*v,et=p&67108863;a=a+(p/67108864|0)|0,et=et+u|0,u=et&67108863,a=a+(et>>>26)|0,f+=a>>>26,a&=67108863}r.words[s]=u,e=a,a=f}return e!==0?r.words[s]=e:r.length--,r._strip()}function Ft(o,t,r){return Dt(o,t,r)}l.prototype.mulTo=function(t,r){var e,f=this.length+t.length;return this.length===10&&t.length===10?e=Kt(this,t,r):f<63?e=Pt(this,t,r):f<1024?e=Dt(this,t,r):e=Ft(this,t,r),e},l.prototype.mul=function(t){var r=new l(null);return r.words=new Array(this.length+t.length),this.mulTo(t,r)},l.prototype.mulf=function(t){var r=new l(null);return r.words=new Array(this.length+t.length),Ft(this,t,r)},l.prototype.imul=function(t){return this.clone().mulTo(t,this)},l.prototype.imuln=function(t){var r=t<0;r&&(t=-t),d(typeof t=="number"),d(t<67108864);for(var e=0,f=0;f<this.length;f++){var s=(this.words[f]|0)*t,a=(s&67108863)+(e&67108863);e>>=26,e+=s/67108864|0,e+=a>>>26,this.words[f]=a&67108863}return e!==0&&(this.words[f]=e,this.length++),this.length=t===0?1:this.length,r?this.ineg():this},l.prototype.muln=function(t){return this.clone().imuln(t)},l.prototype.sqr=function(){return this.mul(this)},l.prototype.isqr=function(){return this.imul(this.clone())},l.prototype.pow=function(t){var r=vi(t);if(r.length===0)return new l(1);for(var e=this,f=0;f<r.length&&r[f]===0;f++,e=e.sqr());if(++f<r.length)for(var s=e.sqr();f<r.length;f++,s=s.sqr())r[f]!==0&&(e=e.mul(s));return e},l.prototype.iushln=function(t){d(typeof t=="number"&&t>=0);var r=t%26,e=(t-r)/26,f=67108863>>>26-r<<26-r,s;if(r!==0){var a=0;for(s=0;s<this.length;s++){var u=this.words[s]&f,h=(this.words[s]|0)-u<<r;this.words[s]=h|a,a=u>>>26-r}a&&(this.words[s]=a,this.length++)}if(e!==0){for(s=this.length-1;s>=0;s--)this.words[s+e]=this.words[s];for(s=0;s<e;s++)this.words[s]=0;this.length+=e}return this._strip()},l.prototype.ishln=function(t){return d(this.negative===0),this.iushln(t)},l.prototype.iushrn=function(t,r,e){d(typeof t=="number"&&t>=0);var f;r?f=(r-r%26)/26:f=0;var s=t%26,a=Math.min((t-s)/26,this.length),u=67108863^67108863>>>s<<s,h=e;if(f-=a,f=Math.max(0,f),h){for(var i=0;i<a;i++)h.words[i]=this.words[i];h.length=a}if(a!==0)if(this.length>a)for(this.length-=a,i=0;i<this.length;i++)this.words[i]=this.words[i+a];else this.words[0]=0,this.length=1;var n=0;for(i=this.length-1;i>=0&&(n!==0||i>=f);i--){var m=this.words[i]|0;this.words[i]=n<<26-s|m>>>s,n=m&u}return h&&n!==0&&(h.words[h.length++]=n),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},l.prototype.ishrn=function(t,r,e){return d(this.negative===0),this.iushrn(t,r,e)},l.prototype.shln=function(t){return this.clone().ishln(t)},l.prototype.ushln=function(t){return this.clone().iushln(t)},l.prototype.shrn=function(t){return this.clone().ishrn(t)},l.prototype.ushrn=function(t){return this.clone().iushrn(t)},l.prototype.testn=function(t){d(typeof t=="number"&&t>=0);var r=t%26,e=(t-r)/26,f=1<<r;if(this.length<=e)return!1;var s=this.words[e];return!!(s&f)},l.prototype.imaskn=function(t){d(typeof t=="number"&&t>=0);var r=t%26,e=(t-r)/26;if(d(this.negative===0,"imaskn works only with positive numbers"),this.length<=e)return this;if(r!==0&&e++,this.length=Math.min(e,this.length),r!==0){var f=67108863^67108863>>>r<<r;this.words[this.length-1]&=f}return this.length===0&&(this.words[0]=0,this.length=1),this._strip()},l.prototype.maskn=function(t){return this.clone().imaskn(t)},l.prototype.iaddn=function(t){return d(typeof t=="number"),d(t<67108864),t<0?this.isubn(-t):this.negative!==0?this.length===1&&(this.words[0]|0)<=t?(this.words[0]=t-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},l.prototype._iaddn=function(t){this.words[0]+=t;for(var r=0;r<this.length&&this.words[r]>=67108864;r++)this.words[r]-=67108864,r===this.length-1?this.words[r+1]=1:this.words[r+1]++;return this.length=Math.max(this.length,r+1),this},l.prototype.isubn=function(t){if(d(typeof t=="number"),d(t<67108864),t<0)return this.iaddn(-t);if(this.negative!==0)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var r=0;r<this.length&&this.words[r]<0;r++)this.words[r]+=67108864,this.words[r+1]-=1;return this._strip()},l.prototype.addn=function(t){return this.clone().iaddn(t)},l.prototype.subn=function(t){return this.clone().isubn(t)},l.prototype.iabs=function(){return this.negative=0,this},l.prototype.abs=function(){return this.clone().iabs()},l.prototype._ishlnsubmul=function(t,r,e){var f=t.length+e,s;this._expand(f);var a,u=0;for(s=0;s<t.length;s++){a=(this.words[s+e]|0)+u;var h=(t.words[s]|0)*r;a-=h&67108863,u=(a>>26)-(h/67108864|0),this.words[s+e]=a&67108863}for(;s<this.length-e;s++)a=(this.words[s+e]|0)+u,u=a>>26,this.words[s+e]=a&67108863;if(u===0)return this._strip();for(d(u===-1),u=0,s=0;s<this.length;s++)a=-(this.words[s]|0)+u,u=a>>26,this.words[s]=a&67108863;return this.negative=1,this._strip()},l.prototype._wordDiv=function(t,r){var e=this.length-t.length,f=this.clone(),s=t,a=s.words[s.length-1]|0,u=this._countBits(a);e=26-u,e!==0&&(s=s.ushln(e),f.iushln(e),a=s.words[s.length-1]|0);var h=f.length-s.length,i;if(r!=="mod"){i=new l(null),i.length=h+1,i.words=new Array(i.length);for(var n=0;n<i.length;n++)i.words[n]=0}var m=f.clone()._ishlnsubmul(s,1,h);m.negative===0&&(f=m,i&&(i.words[h]=1));for(var v=h-1;v>=0;v--){var p=(f.words[s.length+v]|0)*67108864+(f.words[s.length+v-1]|0);for(p=Math.min(p/a|0,67108863),f._ishlnsubmul(s,p,v);f.negative!==0;)p--,f.negative=0,f._ishlnsubmul(s,1,v),f.isZero()||(f.negative^=1);i&&(i.words[v]=p)}return i&&i._strip(),f._strip(),r!=="div"&&e!==0&&f.iushrn(e),{div:i||null,mod:f}},l.prototype.divmod=function(t,r,e){if(d(!t.isZero()),this.isZero())return{div:new l(0),mod:new l(0)};var f,s,a;return this.negative!==0&&t.negative===0?(a=this.neg().divmod(t,r),r!=="mod"&&(f=a.div.neg()),r!=="div"&&(s=a.mod.neg(),e&&s.negative!==0&&s.iadd(t)),{div:f,mod:s}):this.negative===0&&t.negative!==0?(a=this.divmod(t.neg(),r),r!=="mod"&&(f=a.div.neg()),{div:f,mod:a.mod}):(this.negative&t.negative)!==0?(a=this.neg().divmod(t.neg(),r),r!=="div"&&(s=a.mod.neg(),e&&s.negative!==0&&s.isub(t)),{div:a.div,mod:s}):t.length>this.length||this.cmp(t)<0?{div:new l(0),mod:this}:t.length===1?r==="div"?{div:this.divn(t.words[0]),mod:null}:r==="mod"?{div:null,mod:new l(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new l(this.modrn(t.words[0]))}:this._wordDiv(t,r)},l.prototype.div=function(t){return this.divmod(t,"div",!1).div},l.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},l.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},l.prototype.divRound=function(t){var r=this.divmod(t);if(r.mod.isZero())return r.div;var e=r.div.negative!==0?r.mod.isub(t):r.mod,f=t.ushrn(1),s=t.andln(1),a=e.cmp(f);return a<0||s===1&&a===0?r.div:r.div.negative!==0?r.div.isubn(1):r.div.iaddn(1)},l.prototype.modrn=function(t){var r=t<0;r&&(t=-t),d(t<=67108863);for(var e=(1<<26)%t,f=0,s=this.length-1;s>=0;s--)f=(e*f+(this.words[s]|0))%t;return r?-f:f},l.prototype.modn=function(t){return this.modrn(t)},l.prototype.idivn=function(t){var r=t<0;r&&(t=-t),d(t<=67108863);for(var e=0,f=this.length-1;f>=0;f--){var s=(this.words[f]|0)+e*67108864;this.words[f]=s/t|0,e=s%t}return this._strip(),r?this.ineg():this},l.prototype.divn=function(t){return this.clone().idivn(t)},l.prototype.egcd=function(t){d(t.negative===0),d(!t.isZero());var r=this,e=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var f=new l(1),s=new l(0),a=new l(0),u=new l(1),h=0;r.isEven()&&e.isEven();)r.iushrn(1),e.iushrn(1),++h;for(var i=e.clone(),n=r.clone();!r.isZero();){for(var m=0,v=1;(r.words[0]&v)===0&&m<26;++m,v<<=1);if(m>0)for(r.iushrn(m);m-- >0;)(f.isOdd()||s.isOdd())&&(f.iadd(i),s.isub(n)),f.iushrn(1),s.iushrn(1);for(var p=0,et=1;(e.words[0]&et)===0&&p<26;++p,et<<=1);if(p>0)for(e.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(i),u.isub(n)),a.iushrn(1),u.iushrn(1);r.cmp(e)>=0?(r.isub(e),f.isub(a),s.isub(u)):(e.isub(r),a.isub(f),u.isub(s))}return{a,b:u,gcd:e.iushln(h)}},l.prototype._invmp=function(t){d(t.negative===0),d(!t.isZero());var r=this,e=t.clone();r.negative!==0?r=r.umod(t):r=r.clone();for(var f=new l(1),s=new l(0),a=e.clone();r.cmpn(1)>0&&e.cmpn(1)>0;){for(var u=0,h=1;(r.words[0]&h)===0&&u<26;++u,h<<=1);if(u>0)for(r.iushrn(u);u-- >0;)f.isOdd()&&f.iadd(a),f.iushrn(1);for(var i=0,n=1;(e.words[0]&n)===0&&i<26;++i,n<<=1);if(i>0)for(e.iushrn(i);i-- >0;)s.isOdd()&&s.iadd(a),s.iushrn(1);r.cmp(e)>=0?(r.isub(e),f.isub(s)):(e.isub(r),s.isub(f))}var m;return r.cmpn(1)===0?m=f:m=s,m.cmpn(0)<0&&m.iadd(t),m},l.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var r=this.clone(),e=t.clone();r.negative=0,e.negative=0;for(var f=0;r.isEven()&&e.isEven();f++)r.iushrn(1),e.iushrn(1);do{for(;r.isEven();)r.iushrn(1);for(;e.isEven();)e.iushrn(1);var s=r.cmp(e);if(s<0){var a=r;r=e,e=a}else if(s===0||e.cmpn(1)===0)break;r.isub(e)}while(!0);return e.iushln(f)},l.prototype.invm=function(t){return this.egcd(t).a.umod(t)},l.prototype.isEven=function(){return(this.words[0]&1)===0},l.prototype.isOdd=function(){return(this.words[0]&1)===1},l.prototype.andln=function(t){return this.words[0]&t},l.prototype.bincn=function(t){d(typeof t=="number");var r=t%26,e=(t-r)/26,f=1<<r;if(this.length<=e)return this._expand(e+1),this.words[e]|=f,this;for(var s=f,a=e;s!==0&&a<this.length;a++){var u=this.words[a]|0;u+=s,s=u>>>26,u&=67108863,this.words[a]=u}return s!==0&&(this.words[a]=s,this.length++),this},l.prototype.isZero=function(){return this.length===1&&this.words[0]===0},l.prototype.cmpn=function(t){var r=t<0;if(this.negative!==0&&!r)return-1;if(this.negative===0&&r)return 1;this._strip();var e;if(this.length>1)e=1;else{r&&(t=-t),d(t<=67108863,"Number is too big");var f=this.words[0]|0;e=f===t?0:f<t?-1:1}return this.negative!==0?-e|0:e},l.prototype.cmp=function(t){if(this.negative!==0&&t.negative===0)return-1;if(this.negative===0&&t.negative!==0)return 1;var r=this.ucmp(t);return this.negative!==0?-r|0:r},l.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var r=0,e=this.length-1;e>=0;e--){var f=this.words[e]|0,s=t.words[e]|0;if(f!==s){f<s?r=-1:f>s&&(r=1);break}}return r},l.prototype.gtn=function(t){return this.cmpn(t)===1},l.prototype.gt=function(t){return this.cmp(t)===1},l.prototype.gten=function(t){return this.cmpn(t)>=0},l.prototype.gte=function(t){return this.cmp(t)>=0},l.prototype.ltn=function(t){return this.cmpn(t)===-1},l.prototype.lt=function(t){return this.cmp(t)===-1},l.prototype.lten=function(t){return this.cmpn(t)<=0},l.prototype.lte=function(t){return this.cmp(t)<=0},l.prototype.eqn=function(t){return this.cmpn(t)===0},l.prototype.eq=function(t){return this.cmp(t)===0},l.red=function(t){return new g(t)},l.prototype.toRed=function(t){return d(!this.red,"Already a number in reduction context"),d(this.negative===0,"red works only with positives"),t.convertTo(this)._forceRed(t)},l.prototype.fromRed=function(){return d(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},l.prototype._forceRed=function(t){return this.red=t,this},l.prototype.forceRed=function(t){return d(!this.red,"Already a number in reduction context"),this._forceRed(t)},l.prototype.redAdd=function(t){return d(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},l.prototype.redIAdd=function(t){return d(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},l.prototype.redSub=function(t){return d(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},l.prototype.redISub=function(t){return d(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},l.prototype.redShl=function(t){return d(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},l.prototype.redMul=function(t){return d(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},l.prototype.redIMul=function(t){return d(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},l.prototype.redSqr=function(){return d(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},l.prototype.redISqr=function(){return d(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},l.prototype.redSqrt=function(){return d(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},l.prototype.redInvm=function(){return d(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},l.prototype.redNeg=function(){return d(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},l.prototype.redPow=function(t){return d(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var dt={k256:null,p224:null,p192:null,p25519:null};function ht(o,t){this.name=o,this.p=new l(t,16),this.n=this.p.bitLength(),this.k=new l(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}ht.prototype._tmp=function(){var t=new l(null);return t.words=new Array(Math.ceil(this.n/13)),t},ht.prototype.ireduce=function(t){var r=t,e;do this.split(r,this.tmp),r=this.imulK(r),r=r.iadd(this.tmp),e=r.bitLength();while(e>this.n);var f=e<this.n?-1:r.ucmp(this.p);return f===0?(r.words[0]=0,r.length=1):f>0?r.isub(this.p):r.strip!==void 0?r.strip():r._strip(),r},ht.prototype.split=function(t,r){t.iushrn(this.n,0,r)},ht.prototype.imulK=function(t){return t.imul(this.k)};function at(){ht.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}rt(at,ht),at.prototype.split=function(t,r){for(var e=4194303,f=Math.min(t.length,9),s=0;s<f;s++)r.words[s]=t.words[s];if(r.length=f,t.length<=9){t.words[0]=0,t.length=1;return}var a=t.words[9];for(r.words[r.length++]=a&e,s=10;s<t.length;s++){var u=t.words[s]|0;t.words[s-10]=(u&e)<<4|a>>>22,a=u}a>>>=22,t.words[s-10]=a,a===0&&t.length>10?t.length-=10:t.length-=9},at.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var r=0,e=0;e<t.length;e++){var f=t.words[e]|0;r+=f*977,t.words[e]=r&67108863,r=f*64+(r/67108864|0)}return t.words[t.length-1]===0&&(t.length--,t.words[t.length-1]===0&&t.length--),t};function $t(){ht.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}rt($t,ht);function Ht(){ht.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}rt(Ht,ht);function vt(){ht.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}rt(vt,ht),vt.prototype.imulK=function(t){for(var r=0,e=0;e<t.length;e++){var f=(t.words[e]|0)*19+r,s=f&67108863;f>>>=26,t.words[e]=s,r=f}return r!==0&&(t.words[t.length++]=r),t},l._prime=function(t){if(dt[t])return dt[t];var r;if(t==="k256")r=new at;else if(t==="p224")r=new $t;else if(t==="p192")r=new Ht;else if(t==="p25519")r=new vt;else throw new Error("Unknown prime "+t);return dt[t]=r,r};function g(o){if(typeof o=="string"){var t=l._prime(o);this.m=t.p,this.prime=t}else d(o.gtn(1),"modulus must be greater than 1"),this.m=o,this.prime=null}g.prototype._verify1=function(t){d(t.negative===0,"red works only with positives"),d(t.red,"red works only with red numbers")},g.prototype._verify2=function(t,r){d((t.negative|r.negative)===0,"red works only with positives"),d(t.red&&t.red===r.red,"red works only with red numbers")},g.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(It(t,t.umod(this.m)._forceRed(this)),t)},g.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},g.prototype.add=function(t,r){this._verify2(t,r);var e=t.add(r);return e.cmp(this.m)>=0&&e.isub(this.m),e._forceRed(this)},g.prototype.iadd=function(t,r){this._verify2(t,r);var e=t.iadd(r);return e.cmp(this.m)>=0&&e.isub(this.m),e},g.prototype.sub=function(t,r){this._verify2(t,r);var e=t.sub(r);return e.cmpn(0)<0&&e.iadd(this.m),e._forceRed(this)},g.prototype.isub=function(t,r){this._verify2(t,r);var e=t.isub(r);return e.cmpn(0)<0&&e.iadd(this.m),e},g.prototype.shl=function(t,r){return this._verify1(t),this.imod(t.ushln(r))},g.prototype.imul=function(t,r){return this._verify2(t,r),this.imod(t.imul(r))},g.prototype.mul=function(t,r){return this._verify2(t,r),this.imod(t.mul(r))},g.prototype.isqr=function(t){return this.imul(t,t.clone())},g.prototype.sqr=function(t){return this.mul(t,t)},g.prototype.sqrt=function(t){if(t.isZero())return t.clone();var r=this.m.andln(3);if(d(r%2===1),r===3){var e=this.m.add(new l(1)).iushrn(2);return this.pow(t,e)}for(var f=this.m.subn(1),s=0;!f.isZero()&&f.andln(1)===0;)s++,f.iushrn(1);d(!f.isZero());var a=new l(1).toRed(this),u=a.redNeg(),h=this.m.subn(1).iushrn(1),i=this.m.bitLength();for(i=new l(2*i*i).toRed(this);this.pow(i,h).cmp(u)!==0;)i.redIAdd(u);for(var n=this.pow(i,f),m=this.pow(t,f.addn(1).iushrn(1)),v=this.pow(t,f),p=s;v.cmp(a)!==0;){for(var et=v,M=0;et.cmp(a)!==0;M++)et=et.redSqr();d(M<p);var c=this.pow(n,new l(1).iushln(p-M-1));m=m.redMul(c),n=c.redSqr(),v=v.redMul(n),p=M}return m},g.prototype.invm=function(t){var r=t._invmp(this.m);return r.negative!==0?(r.negative=0,this.imod(r).redNeg()):this.imod(r)},g.prototype.pow=function(t,r){if(r.isZero())return new l(1).toRed(this);if(r.cmpn(1)===0)return t.clone();var e=4,f=new Array(1<<e);f[0]=new l(1).toRed(this),f[1]=t;for(var s=2;s<f.length;s++)f[s]=this.mul(f[s-1],t);var a=f[0],u=0,h=0,i=r.bitLength()%26;for(i===0&&(i=26),s=r.length-1;s>=0;s--){for(var n=r.words[s],m=i-1;m>=0;m--){var v=n>>m&1;if(a!==f[0]&&(a=this.sqr(a)),v===0&&u===0){h=0;continue}u<<=1,u|=v,h++,!(h!==e&&(s!==0||m!==0))&&(a=this.mul(a,f[u]),h=0,u=0)}i=26}return a},g.prototype.convertTo=function(t){var r=t.umod(this.m);return r===t?r.clone():r},g.prototype.convertFrom=function(t){var r=t.clone();return r.red=null,r},l.mont=function(t){return new st(t)};function st(o){g.call(this,o),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new l(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}rt(st,g),st.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},st.prototype.convertFrom=function(t){var r=this.imod(t.mul(this.rinv));return r.red=null,r},st.prototype.imul=function(t,r){if(t.isZero()||r.isZero())return t.words[0]=0,t.length=1,t;var e=t.imul(r),f=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=e.isub(f).iushrn(this.shift),a=s;return s.cmp(this.m)>=0?a=s.isub(this.m):s.cmpn(0)<0&&(a=s.iadd(this.m)),a._forceRed(this)},st.prototype.mul=function(t,r){if(t.isZero()||r.isZero())return new l(0)._forceRed(this);var e=t.mul(r),f=e.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),s=e.isub(f).iushrn(this.shift),a=s;return s.cmp(this.m)>=0?a=s.isub(this.m):s.cmpn(0)<0&&(a=s.iadd(this.m)),a._forceRed(this)},st.prototype.invm=function(t){var r=this.imod(t._invmp(this.m).mul(this.r2));return r._forceRed(this)}})(it,yi)})(lt)),lt.exports}var ai=xi();const _i=pi(ai),bi=mi({__proto__:null,default:_i},[ai]);exports.bn=bi;