"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@argent/x-shared"),s=require("lodash-es"),w=require("object-hash"),o=require("react"),d=require("url-join"),l=require("../../http/swr.cjs"),g=({apiData:{apiBaseUrl:e,apiHeaders:n},address:t,network:r,transactionReviewEnabled:c=!0,transactions:i})=>{const u=o.useCallback(async()=>{if(!t||!r)return;if(!e)throw"Transaction review endpoint is not defined";const T=d(e,"reviewer/transactions/review/starknet"),v=s.isArray(i)?i:[i],f={network:r,account:t,calls:v};return p.fetchData(T,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(f)})},[t,r,i]),y=o.useMemo(()=>w({transactions:i,address:t,network:r}),[i,t,r]);return l.useConditionallyEnabledSWR(!!c,[y,"transactionReview"],u)},h=e=>{if(!e)return{};const n=e.assessment==="warn"&&e.reason!=="contract_is_not_verified",t=e.reason?` (Reason: ${s.lowerCase(e.reason)})`:"",r=n?e.reason==="recipient_is_token_address"?"You are sending tokens to their own address. This is likely to burn them.":`This transaction has been flagged as dangerous. We recommend you reject this transaction unless you are sure.${t}`:void 0;return{warn:n,reason:r}},a=e=>{var n;if(e){for(const t of e.reviews)if(((n=t.activity)==null?void 0:n.type)==="swap")return t}},R=e=>{},S=(e,n)=>{var t;if(n){for(const r of n.reviews)if(((t=r.activity)==null?void 0:t.type)===e)return r.activity}},A=e=>!!a(e),_=e=>{var n,t;if(e){for(const r of e.reviews)if((n=r.activity)!=null&&n.type)return{...r,type:(t=r.activity)==null?void 0:t.type}}};exports.getDisplayWarnAndReasonForTransactionReview=h;exports.getNFTTransferActivity=R;exports.getTransactionReviewActivityOfType=S;exports.getTransactionReviewHasSwap=A;exports.getTransactionReviewSwap=a;exports.getTransactionReviewWithType=_;exports.useTransactionReview=g;
