'use strict';

var swapModule_entry = require('./swap-module-BZ0C_ywD.js');
var index = require('./index-CAgSYWnN.js');
require('./index-Mw_M0XDo.js');
require('./index-Bq66f3r7.js');
var ifDefined = require('./if-defined-C8-lLqpT.js');
require('./index-DYShkd_q.js');
require('./index-ClB8inJV.js');

var dayjs_min$1 = {exports: {}};

var dayjs_min = dayjs_min$1.exports;

var hasRequiredDayjs_min;

function requireDayjs_min () {
	if (hasRequiredDayjs_min) return dayjs_min$1.exports;
	hasRequiredDayjs_min = 1;
	(function (module, exports) {
		!function(t,e){module.exports=e();}(dayjs_min,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,true),this.parse(t),this.$x=this.$x||t.x||{},this[p]=true;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,false)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case "YY":return String(e.$y).slice(-2);case "YYYY":return b.s(e.$y,4,"0");case "M":return a+1;case "MM":return b.s(a+1,2,"0");case "MMM":return h(n.monthsShort,a,c,3);case "MMMM":return h(c,a);case "D":return e.$D;case "DD":return b.s(e.$D,2,"0");case "d":return String(e.$W);case "dd":return h(n.weekdaysMin,e.$W,o,2);case "ddd":return h(n.weekdaysShort,e.$W,o,3);case "dddd":return o[e.$W];case "H":return String(s);case "HH":return b.s(s,2,"0");case "h":return d(1);case "hh":return d(2);case "a":return $(s,u,true);case "A":return $(s,u,false);case "m":return String(u);case "mm":return b.s(u,2,"0");case "s":return String(e.$s);case "ss":return b.s(e.$s,2,"0");case "SSS":return b.s(e.$ms,3,"0");case "Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g;}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,true);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=true),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O})); 
	} (dayjs_min$1));
	return dayjs_min$1.exports;
}

var dayjs_minExports = requireDayjs_min();
var dayjs = /*@__PURE__*/swapModule_entry.getDefaultExportFromCjs(dayjs_minExports);

var en$1 = {exports: {}};

var en = en$1.exports;

var hasRequiredEn;

function requireEn () {
	if (hasRequiredEn) return en$1.exports;
	hasRequiredEn = 1;
	(function (module, exports) {
		!function(e,n){module.exports=n();}(en,(function(){return {name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var n=["th","st","nd","rd"],t=e%100;return "["+e+(n[(t-20)%10]||n[t]||n[0])+"]"}}})); 
	} (en$1));
	return en$1.exports;
}

var enExports = requireEn();
var englishLocale = /*@__PURE__*/swapModule_entry.getDefaultExportFromCjs(enExports);

var relativeTime$2 = {exports: {}};

var relativeTime$1 = relativeTime$2.exports;

var hasRequiredRelativeTime;

function requireRelativeTime () {
	if (hasRequiredRelativeTime) return relativeTime$2.exports;
	hasRequiredRelativeTime = 1;
	(function (module, exports) {
		!function(r,e){module.exports=e();}(relativeTime$1,(function(){return function(r,e,t){r=r||{};var n=e.prototype,o={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function i(r,e,t,o){return n.fromToBase(r,e,t,o)}t.en.relativeTime=o,n.fromToBase=function(e,n,i,d,u){for(var f,a,s,l=i.$locale().relativeTime||o,h=r.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],m=h.length,c=0;c<m;c+=1){var y=h[c];y.d&&(f=d?t(e).diff(i,y.d,true):i.diff(e,y.d,true));var p=(r.rounding||Math.round)(Math.abs(f));if(s=f>0,p<=y.r||!y.r){p<=1&&c>0&&(y=h[c-1]);var v=l[y.l];u&&(p=u(""+p)),a="string"==typeof v?v.replace("%d",p):v(p,n,y.l,s);break}}if(n)return a;var M=s?l.future:l.past;return "function"==typeof M?M(a):M.replace("%s",a)},n.to=function(r,e){return i(r,e,this,true)},n.from=function(r,e){return i(r,e,this)};var d=function(r){return r.$u?t.utc():t()};n.toNow=function(r){return this.to(d(this),r)},n.fromNow=function(r){return this.from(d(this),r)};}})); 
	} (relativeTime$2));
	return relativeTime$2.exports;
}

var relativeTimeExports = requireRelativeTime();
var relativeTime = /*@__PURE__*/swapModule_entry.getDefaultExportFromCjs(relativeTimeExports);

var updateLocale$2 = {exports: {}};

var updateLocale$1 = updateLocale$2.exports;

var hasRequiredUpdateLocale;

function requireUpdateLocale () {
	if (hasRequiredUpdateLocale) return updateLocale$2.exports;
	hasRequiredUpdateLocale = 1;
	(function (module, exports) {
		!function(e,n){module.exports=n();}(updateLocale$1,(function(){return function(e,n,t){t.updateLocale=function(e,n){var o=t.Ls[e];if(o)return (n?Object.keys(n):[]).forEach((function(e){o[e]=n[e];})),o};}})); 
	} (updateLocale$2));
	return updateLocale$2.exports;
}

var updateLocaleExports = requireUpdateLocale();
var updateLocale = /*@__PURE__*/swapModule_entry.getDefaultExportFromCjs(updateLocaleExports);

dayjs.extend(relativeTime);
dayjs.extend(updateLocale);
const localeObject = {
    ...englishLocale,
    name: 'en-web3-modal',
    relativeTime: {
        future: 'in %s',
        past: '%s ago',
        s: '%d sec',
        m: '1 min',
        mm: '%d min',
        h: '1 hr',
        hh: '%d hrs',
        d: '1 d',
        dd: '%d d',
        M: '1 mo',
        MM: '%d mo',
        y: '1 yr',
        yy: '%d yr'
    }
};
const MONTH_NAMES = [
    'January',
    'February',
    'March',
    'April',
    'May',
    'June',
    'July',
    'August',
    'September',
    'October',
    'November',
    'December'
];
dayjs.locale('en-web3-modal', localeObject);
const DateUtil = {
    getMonthNameByIndex(monthIndex) {
        return MONTH_NAMES[monthIndex];
    },
    getYear(date = new Date().toISOString()) {
        return dayjs(date).year();
    },
    getRelativeDateFromNow(date) {
        return dayjs(date).locale('en-web3-modal').fromNow(true);
    },
    formatDate(date, format = 'DD MMM') {
        return dayjs(date).format(format);
    }
};

const FLOAT_FIXED_VALUE = 3;
const GAS_FEE_THRESHOLD = 0.1;
const plusTypes = ['receive', 'deposit', 'borrow', 'claim'];
const minusTypes = ['withdraw', 'repay', 'burn'];
const TransactionUtil = {
    getTransactionGroupTitle(year, month) {
        const currentYear = DateUtil.getYear();
        const monthName = DateUtil.getMonthNameByIndex(month);
        const isCurrentYear = year === currentYear;
        const groupTitle = isCurrentYear ? monthName : `${monthName} ${year}`;
        return groupTitle;
    },
    getTransactionImages(transfers) {
        const [transfer] = transfers;
        const hasMultipleTransfers = transfers?.length > 1;
        if (hasMultipleTransfers) {
            return transfers.map(item => this.getTransactionImage(item));
        }
        return [this.getTransactionImage(transfer)];
    },
    getTransactionImage(transfer) {
        return {
            type: TransactionUtil.getTransactionTransferTokenType(transfer),
            url: TransactionUtil.getTransactionImageURL(transfer)
        };
    },
    getTransactionImageURL(transfer) {
        let imageURL = undefined;
        const isNFT = Boolean(transfer?.nft_info);
        const isFungible = Boolean(transfer?.fungible_info);
        if (transfer && isNFT) {
            imageURL = transfer?.nft_info?.content?.preview?.url;
        }
        else if (transfer && isFungible) {
            imageURL = transfer?.fungible_info?.icon?.url;
        }
        return imageURL;
    },
    getTransactionTransferTokenType(transfer) {
        if (transfer?.fungible_info) {
            return 'FUNGIBLE';
        }
        else if (transfer?.nft_info) {
            return 'NFT';
        }
        return undefined;
    },
    getTransactionDescriptions(transaction, mergedTransfers) {
        const type = transaction?.metadata?.operationType;
        const transfers = mergedTransfers || transaction?.transfers;
        const hasTransfer = transfers && transfers.length > 0;
        const hasMultipleTransfers = transfers && transfers.length > 1;
        const isFungible = hasTransfer && transfers.every(transfer => Boolean(transfer?.fungible_info));
        const [firstTransfer, secondTransfer] = transfers || [];
        let firstDescription = this.getTransferDescription(firstTransfer);
        let secondDescription = this.getTransferDescription(secondTransfer);
        if (!hasTransfer) {
            const isSendOrReceive = type === 'send' || type === 'receive';
            if (isSendOrReceive && isFungible) {
                firstDescription = index.UiHelperUtil.getTruncateString({
                    string: transaction?.metadata.sentFrom,
                    charsStart: 4,
                    charsEnd: 6,
                    truncate: 'middle'
                });
                secondDescription = index.UiHelperUtil.getTruncateString({
                    string: transaction?.metadata.sentTo,
                    charsStart: 4,
                    charsEnd: 6,
                    truncate: 'middle'
                });
                return [firstDescription, secondDescription];
            }
            return [transaction.metadata.status];
        }
        if (hasMultipleTransfers) {
            return transfers?.map(item => this.getTransferDescription(item));
        }
        let prefix = '';
        if (plusTypes.includes(type)) {
            prefix = '+';
        }
        else if (minusTypes.includes(type)) {
            prefix = '-';
        }
        firstDescription = prefix.concat(firstDescription);
        return [firstDescription];
    },
    getTransferDescription(transfer) {
        let description = '';
        if (!transfer) {
            return description;
        }
        if (transfer?.nft_info) {
            description = transfer?.nft_info?.name || '-';
        }
        else if (transfer?.fungible_info) {
            description = this.getFungibleTransferDescription(transfer) || '-';
        }
        return description;
    },
    getFungibleTransferDescription(transfer) {
        if (!transfer) {
            return null;
        }
        const quantity = this.getQuantityFixedValue(transfer?.quantity.numeric);
        const description = [quantity, transfer?.fungible_info?.symbol].join(' ').trim();
        return description;
    },
    mergeTransfers(transfers) {
        if (transfers?.length <= 1) {
            return transfers;
        }
        const filteredTransfers = this.filterGasFeeTransfers(transfers);
        const mergedTransfers = filteredTransfers.reduce((acc, t) => {
            const name = t?.fungible_info?.name;
            const existingTransfer = acc.find(({ fungible_info, direction }) => name && name === fungible_info?.name && direction === t.direction);
            if (existingTransfer) {
                const quantity = Number(existingTransfer.quantity.numeric) + Number(t.quantity.numeric);
                existingTransfer.quantity.numeric = quantity.toString();
                existingTransfer.value = (existingTransfer.value || 0) + (t.value || 0);
            }
            else {
                acc.push(t);
            }
            return acc;
        }, []);
        let finalTransfers = mergedTransfers;
        if (mergedTransfers.length > 2) {
            finalTransfers = mergedTransfers.sort((a, b) => (b.value || 0) - (a.value || 0)).slice(0, 2);
        }
        finalTransfers = finalTransfers.sort((a, b) => {
            if (a.direction === 'out' && b.direction === 'in') {
                return -1;
            }
            if (a.direction === 'in' && b.direction === 'out') {
                return 1;
            }
            return 0;
        });
        return finalTransfers;
    },
    filterGasFeeTransfers(transfers) {
        const tokenGroups = transfers?.reduce((groups, transfer) => {
            const tokenName = transfer?.fungible_info?.name;
            if (tokenName) {
                if (!groups[tokenName]) {
                    groups[tokenName] = [];
                }
                groups[tokenName].push(transfer);
            }
            return groups;
        }, {});
        const filteredTransfers = [];
        Object.values(tokenGroups ?? {}).forEach(tokenTransfers => {
            if (tokenTransfers.length === 1) {
                const firstTransfer = tokenTransfers[0];
                if (firstTransfer) {
                    filteredTransfers.push(firstTransfer);
                }
            }
            else {
                const inTransfers = tokenTransfers.filter(t => t.direction === 'in');
                const outTransfers = tokenTransfers.filter(t => t.direction === 'out');
                if (inTransfers.length === 1 && outTransfers.length === 1) {
                    const inTransfer = inTransfers[0];
                    const outTransfer = outTransfers[0];
                    let didApplyGasFeeFilter = false;
                    if (inTransfer && outTransfer) {
                        const inAmount = Number(inTransfer.quantity.numeric);
                        const outAmount = Number(outTransfer.quantity.numeric);
                        if (outAmount < inAmount * GAS_FEE_THRESHOLD) {
                            filteredTransfers.push(inTransfer);
                            didApplyGasFeeFilter = true;
                        }
                        else if (inAmount < outAmount * GAS_FEE_THRESHOLD) {
                            filteredTransfers.push(outTransfer);
                            didApplyGasFeeFilter = true;
                        }
                    }
                    if (!didApplyGasFeeFilter) {
                        filteredTransfers.push(...tokenTransfers);
                    }
                }
                else {
                    const significantTransfers = this.filterGasFeesFromTokenGroup(tokenTransfers);
                    filteredTransfers.push(...significantTransfers);
                }
            }
        });
        transfers?.forEach(transfer => {
            if (!transfer?.fungible_info?.name) {
                filteredTransfers.push(transfer);
            }
        });
        return filteredTransfers;
    },
    filterGasFeesFromTokenGroup(tokenTransfers) {
        if (tokenTransfers.length <= 1) {
            return tokenTransfers;
        }
        const amounts = tokenTransfers?.map(t => Number(t.quantity.numeric));
        const maxAmount = Math.max(...amounts);
        const minAmount = Math.min(...amounts);
        const extremeGasThreshold = 0.01;
        if (minAmount < maxAmount * extremeGasThreshold) {
            const filtered = tokenTransfers?.filter(t => {
                const amount = Number(t.quantity.numeric);
                return amount >= maxAmount * extremeGasThreshold;
            });
            return filtered;
        }
        const inTransfers = tokenTransfers?.filter(t => t.direction === 'in');
        const outTransfers = tokenTransfers?.filter(t => t.direction === 'out');
        if (inTransfers.length === 1 && outTransfers.length === 1) {
            const inTransfer = inTransfers[0];
            const outTransfer = outTransfers[0];
            if (inTransfer && outTransfer) {
                const inAmount = Number(inTransfer.quantity.numeric);
                const outAmount = Number(outTransfer.quantity.numeric);
                if (outAmount < inAmount * GAS_FEE_THRESHOLD) {
                    return [inTransfer];
                }
                else if (inAmount < outAmount * GAS_FEE_THRESHOLD) {
                    return [outTransfer];
                }
            }
        }
        return tokenTransfers;
    },
    getQuantityFixedValue(value) {
        if (!value) {
            return null;
        }
        const parsedValue = parseFloat(value);
        return parsedValue.toFixed(FLOAT_FIXED_VALUE);
    }
};

var TransactionTypePastTense;
(function (TransactionTypePastTense) {
    TransactionTypePastTense["approve"] = "approved";
    TransactionTypePastTense["bought"] = "bought";
    TransactionTypePastTense["borrow"] = "borrowed";
    TransactionTypePastTense["burn"] = "burnt";
    TransactionTypePastTense["cancel"] = "canceled";
    TransactionTypePastTense["claim"] = "claimed";
    TransactionTypePastTense["deploy"] = "deployed";
    TransactionTypePastTense["deposit"] = "deposited";
    TransactionTypePastTense["execute"] = "executed";
    TransactionTypePastTense["mint"] = "minted";
    TransactionTypePastTense["receive"] = "received";
    TransactionTypePastTense["repay"] = "repaid";
    TransactionTypePastTense["send"] = "sent";
    TransactionTypePastTense["sell"] = "sold";
    TransactionTypePastTense["stake"] = "staked";
    TransactionTypePastTense["trade"] = "swapped";
    TransactionTypePastTense["unstake"] = "unstaked";
    TransactionTypePastTense["withdraw"] = "withdrawn";
})(TransactionTypePastTense || (TransactionTypePastTense = {}));

var styles$4 = swapModule_entry.css `
  :host > wui-flex {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 40px;
    height: 40px;
    box-shadow: inset 0 0 0 1px ${({ tokens }) => tokens.core.glass010};
    background-color: ${({ tokens }) => tokens.theme.foregroundPrimary};
  }

  :host([data-no-images='true']) > wui-flex {
    background-color: ${({ tokens }) => tokens.theme.foregroundPrimary};
    border-radius: ${({ borderRadius }) => borderRadius[3]} !important;
  }

  :host > wui-flex wui-image {
    display: block;
  }

  :host > wui-flex,
  :host > wui-flex wui-image,
  .swap-images-container,
  .swap-images-container.nft,
  wui-image.nft {
    border-top-left-radius: var(--local-left-border-radius);
    border-top-right-radius: var(--local-right-border-radius);
    border-bottom-left-radius: var(--local-left-border-radius);
    border-bottom-right-radius: var(--local-right-border-radius);
  }

  .swap-images-container {
    position: relative;
    width: 40px;
    height: 40px;
    overflow: hidden;
  }

  .swap-images-container wui-image:first-child {
    position: absolute;
    width: 40px;
    height: 40px;
    top: 0;
    left: 0%;
    clip-path: inset(0px calc(50% + 2px) 0px 0%);
  }

  .swap-images-container wui-image:last-child {
    clip-path: inset(0px 0px 0px calc(50% + 2px));
  }

  .swap-fallback-container {
    position: absolute;
    inset: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .swap-fallback-container.first {
    clip-path: inset(0px calc(50% + 2px) 0px 0%);
  }

  .swap-fallback-container.last {
    clip-path: inset(0px 0px 0px calc(50% + 2px));
  }

  wui-flex.status-box {
    position: absolute;
    right: 0;
    bottom: 0;
    transform: translate(20%, 20%);
    border-radius: ${({ borderRadius }) => borderRadius[4]};
    background-color: ${({ tokens }) => tokens.theme.backgroundPrimary};
    box-shadow: 0 0 0 2px ${({ tokens }) => tokens.theme.backgroundPrimary};
    overflow: hidden;
    width: 16px;
    height: 16px;
  }
`;

var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
let WuiTransactionVisual = class WuiTransactionVisual extends swapModule_entry.i {
    constructor() {
        super(...arguments);
        this.images = [];
        this.secondImage = {
            type: undefined,
            url: ''
        };
        this.failedImageUrls = new Set();
    }
    handleImageError(url) {
        return (event) => {
            event.stopPropagation();
            this.failedImageUrls.add(url);
            this.requestUpdate();
        };
    }
    render() {
        const [firstImage, secondImage] = this.images;
        if (!this.images.length) {
            this.dataset['noImages'] = 'true';
        }
        const isLeftNFT = firstImage?.type === 'NFT';
        const isRightNFT = secondImage?.url ? secondImage.type === 'NFT' : isLeftNFT;
        const leftRadius = isLeftNFT ? 'var(--apkt-borderRadius-3)' : 'var(--apkt-borderRadius-5)';
        const rightRadius = isRightNFT ? 'var(--apkt-borderRadius-3)' : 'var(--apkt-borderRadius-5)';
        this.style.cssText = `
    --local-left-border-radius: ${leftRadius};
    --local-right-border-radius: ${rightRadius};
    `;
        return swapModule_entry.b `<wui-flex> ${this.templateVisual()} ${this.templateIcon()} </wui-flex>`;
    }
    templateVisual() {
        const [firstImage, secondImage] = this.images;
        const hasTwoImages = this.images.length === 2;
        if (hasTwoImages && (firstImage?.url || secondImage?.url)) {
            return this.renderSwapImages(firstImage, secondImage);
        }
        if (firstImage?.url && !this.failedImageUrls.has(firstImage.url)) {
            return this.renderSingleImage(firstImage);
        }
        if (firstImage?.type === 'NFT') {
            return this.renderPlaceholderIcon('nftPlaceholder');
        }
        return this.renderPlaceholderIcon('coinPlaceholder');
    }
    renderSwapImages(firstImage, secondImage) {
        return swapModule_entry.b `<div class="swap-images-container">
      ${firstImage?.url ? this.renderImageOrFallback(firstImage, 'first', true) : null}
      ${secondImage?.url ? this.renderImageOrFallback(secondImage, 'last', true) : null}
    </div>`;
    }
    renderSingleImage(image) {
        return this.renderImageOrFallback(image, undefined, false);
    }
    renderImageOrFallback(image, position, isInSwapContainer = false) {
        if (!image.url) {
            return null;
        }
        if (this.failedImageUrls.has(image.url)) {
            if (isInSwapContainer && position) {
                return this.renderFallbackIconInContainer(position);
            }
            return this.renderFallbackIcon();
        }
        return swapModule_entry.b `<wui-image
      src=${image.url}
      alt="Transaction image"
      @onLoadError=${this.handleImageError(image.url)}
    ></wui-image>`;
    }
    renderFallbackIconInContainer(position) {
        return swapModule_entry.b `<div class="swap-fallback-container ${position}">${this.renderFallbackIcon()}</div>`;
    }
    renderFallbackIcon() {
        return swapModule_entry.b `<wui-icon
      size="xl"
      weight="regular"
      color="default"
      name="networkPlaceholder"
    ></wui-icon>`;
    }
    renderPlaceholderIcon(iconName) {
        return swapModule_entry.b `<wui-icon size="xl" weight="regular" color="default" name=${iconName}></wui-icon>`;
    }
    templateIcon() {
        let color = 'accent-primary';
        let icon = undefined;
        icon = this.getIcon();
        if (this.status) {
            color = this.getStatusColor();
        }
        if (!icon) {
            return null;
        }
        return swapModule_entry.b `
      <wui-flex alignItems="center" justifyContent="center" class="status-box">
        <wui-icon-box size="sm" color=${color} icon=${icon}></wui-icon-box>
      </wui-flex>
    `;
    }
    getDirectionIcon() {
        switch (this.direction) {
            case 'in':
                return 'arrowBottom';
            case 'out':
                return 'arrowTop';
            default:
                return undefined;
        }
    }
    getIcon() {
        if (this.onlyDirectionIcon) {
            return this.getDirectionIcon();
        }
        if (this.type === 'trade') {
            return 'swapHorizontal';
        }
        else if (this.type === 'approve') {
            return 'checkmark';
        }
        else if (this.type === 'cancel') {
            return 'close';
        }
        return this.getDirectionIcon();
    }
    getStatusColor() {
        switch (this.status) {
            case 'confirmed':
                return 'success';
            case 'failed':
                return 'error';
            case 'pending':
                return 'inverse';
            default:
                return 'accent-primary';
        }
    }
};
WuiTransactionVisual.styles = [styles$4];
__decorate$4([
    index.n()
], WuiTransactionVisual.prototype, "type", void 0);
__decorate$4([
    index.n()
], WuiTransactionVisual.prototype, "status", void 0);
__decorate$4([
    index.n()
], WuiTransactionVisual.prototype, "direction", void 0);
__decorate$4([
    index.n({ type: Boolean })
], WuiTransactionVisual.prototype, "onlyDirectionIcon", void 0);
__decorate$4([
    index.n({ type: Array })
], WuiTransactionVisual.prototype, "images", void 0);
__decorate$4([
    index.n({ type: Object })
], WuiTransactionVisual.prototype, "secondImage", void 0);
__decorate$4([
    index.r()
], WuiTransactionVisual.prototype, "failedImageUrls", void 0);
WuiTransactionVisual = __decorate$4([
    index.customElement('wui-transaction-visual')
], WuiTransactionVisual);

var styles$3 = swapModule_entry.css `
  :host {
    width: 100%;
  }

  :host > wui-flex:first-child {
    align-items: center;
    column-gap: ${({ spacing }) => spacing[2]};
    padding: ${({ spacing }) => spacing[1]} ${({ spacing }) => spacing[2]};
    width: 100%;
  }

  :host > wui-flex:first-child wui-text:nth-child(1) {
    text-transform: capitalize;
  }

  wui-transaction-visual {
    width: 40px;
    height: 40px;
  }

  wui-flex {
    flex: 1;
  }

  :host wui-flex wui-flex {
    overflow: hidden;
  }

  :host .description-container wui-text span {
    word-break: break-all;
  }

  :host .description-container wui-text {
    overflow: hidden;
  }

  :host .description-separator-icon {
    margin: 0px 6px;
  }

  :host wui-text > span {
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
  }
`;

var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
let WuiTransactionListItem = class WuiTransactionListItem extends swapModule_entry.i {
    constructor() {
        super(...arguments);
        this.type = 'approve';
        this.onlyDirectionIcon = false;
        this.images = [];
    }
    render() {
        return swapModule_entry.b `
      <wui-flex>
        <wui-transaction-visual
          .status=${this.status}
          direction=${ifDefined.o(this.direction)}
          type=${this.type}
          .onlyDirectionIcon=${this.onlyDirectionIcon}
          .images=${this.images}
        ></wui-transaction-visual>
        <wui-flex flexDirection="column" gap="1">
          <wui-text variant="lg-medium" color="primary">
            ${TransactionTypePastTense[this.type] || this.type}
          </wui-text>
          <wui-flex class="description-container">
            ${this.templateDescription()} ${this.templateSecondDescription()}
          </wui-flex>
        </wui-flex>
        <wui-text variant="sm-medium" color="secondary"><span>${this.date}</span></wui-text>
      </wui-flex>
    `;
    }
    templateDescription() {
        const description = this.descriptions?.[0];
        return description
            ? swapModule_entry.b `
          <wui-text variant="md-regular" color="secondary">
            <span>${description}</span>
          </wui-text>
        `
            : null;
    }
    templateSecondDescription() {
        const description = this.descriptions?.[1];
        return description
            ? swapModule_entry.b `
          <wui-icon class="description-separator-icon" size="sm" name="arrowRight"></wui-icon>
          <wui-text variant="md-regular" color="secondary">
            <span>${description}</span>
          </wui-text>
        `
            : null;
    }
};
WuiTransactionListItem.styles = [swapModule_entry.resetStyles, styles$3];
__decorate$3([
    index.n()
], WuiTransactionListItem.prototype, "type", void 0);
__decorate$3([
    index.n({ type: Array })
], WuiTransactionListItem.prototype, "descriptions", void 0);
__decorate$3([
    index.n()
], WuiTransactionListItem.prototype, "date", void 0);
__decorate$3([
    index.n({ type: Boolean })
], WuiTransactionListItem.prototype, "onlyDirectionIcon", void 0);
__decorate$3([
    index.n()
], WuiTransactionListItem.prototype, "status", void 0);
__decorate$3([
    index.n()
], WuiTransactionListItem.prototype, "direction", void 0);
__decorate$3([
    index.n({ type: Array })
], WuiTransactionListItem.prototype, "images", void 0);
WuiTransactionListItem = __decorate$3([
    index.customElement('wui-transaction-list-item')
], WuiTransactionListItem);

var styles$2 = swapModule_entry.css `
  wui-flex {
    position: relative;
    display: inline-flex;
    justify-content: center;
    align-items: center;
  }

  wui-image {
    border-radius: ${({ borderRadius }) => borderRadius[128]};
  }

  .fallback-icon {
    color: ${({ tokens }) => tokens.theme.iconInverse};
    border-radius: ${({ borderRadius }) => borderRadius[3]};
    background-color: ${({ tokens }) => tokens.theme.foregroundPrimary};
  }

  .direction-icon,
  .status-image {
    position: absolute;
    right: 0;
    bottom: 0;
    border-radius: ${({ borderRadius }) => borderRadius[128]};
    border: 2px solid ${({ tokens }) => tokens.theme.backgroundPrimary};
  }

  .direction-icon {
    padding: ${({ spacing }) => spacing['01']};
    color: ${({ tokens }) => tokens.core.iconSuccess};

    background-color: color-mix(
      in srgb,
      ${({ tokens }) => tokens.core.textSuccess} 30%,
      ${({ tokens }) => tokens.theme.backgroundPrimary} 70%
    );
  }

  /* -- Sizes --------------------------------------------------- */
  :host([data-size='sm']) > wui-image:not(.status-image),
  :host([data-size='sm']) > wui-flex {
    width: 24px;
    height: 24px;
  }

  :host([data-size='lg']) > wui-image:not(.status-image),
  :host([data-size='lg']) > wui-flex {
    width: 40px;
    height: 40px;
  }

  :host([data-size='sm']) .fallback-icon {
    height: 16px;
    width: 16px;
    padding: ${({ spacing }) => spacing[1]};
  }

  :host([data-size='lg']) .fallback-icon {
    height: 32px;
    width: 32px;
    padding: ${({ spacing }) => spacing[1]};
  }

  :host([data-size='sm']) .direction-icon,
  :host([data-size='sm']) .status-image {
    transform: translate(40%, 30%);
  }

  :host([data-size='lg']) .direction-icon,
  :host([data-size='lg']) .status-image {
    transform: translate(40%, 10%);
  }

  :host([data-size='sm']) .status-image {
    height: 14px;
    width: 14px;
  }

  :host([data-size='lg']) .status-image {
    height: 20px;
    width: 20px;
  }

  /* -- Crop effects --------------------------------------------------- */
  .swap-crop-left-image,
  .swap-crop-right-image {
    position: absolute;
    top: 0;
    bottom: 0;
  }

  .swap-crop-left-image {
    left: 0;
    clip-path: inset(0px calc(50% + 1.5px) 0px 0%);
  }

  .swap-crop-right-image {
    right: 0;
    clip-path: inset(0px 0px 0px calc(50% + 1.5px));
  }
`;

var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const ICON_SIZE = {
    sm: 'xxs',
    lg: 'md'
};
let WuiTransactionThumbnail = class WuiTransactionThumbnail extends swapModule_entry.i {
    constructor() {
        super(...arguments);
        this.type = 'approve';
        this.size = 'lg';
        this.statusImageUrl = '';
        this.images = [];
    }
    render() {
        return swapModule_entry.b `<wui-flex>${this.templateVisual()} ${this.templateIcon()}</wui-flex>`;
    }
    templateVisual() {
        this.dataset['size'] = this.size;
        switch (this.type) {
            case 'trade':
                return this.swapTemplate();
            case 'fiat':
                return this.fiatTemplate();
            case 'unknown':
                return this.unknownTemplate();
            default:
                return this.tokenTemplate();
        }
    }
    swapTemplate() {
        const [firstImageUrl, secondImageUrl] = this.images;
        const twoImages = this.images.length === 2 && (firstImageUrl || secondImageUrl);
        if (twoImages) {
            return swapModule_entry.b `
        <wui-image class="swap-crop-left-image" src=${firstImageUrl} alt="Swap image"></wui-image>
        <wui-image class="swap-crop-right-image" src=${secondImageUrl} alt="Swap image"></wui-image>
      `;
        }
        if (firstImageUrl) {
            return swapModule_entry.b `<wui-image src=${firstImageUrl} alt="Swap image"></wui-image>`;
        }
        return null;
    }
    fiatTemplate() {
        return swapModule_entry.b `<wui-icon
      class="fallback-icon"
      size=${ICON_SIZE[this.size]}
      name="dollar"
    ></wui-icon>`;
    }
    unknownTemplate() {
        return swapModule_entry.b `<wui-icon
      class="fallback-icon"
      size=${ICON_SIZE[this.size]}
      name="questionMark"
    ></wui-icon>`;
    }
    tokenTemplate() {
        const [imageUrl] = this.images;
        if (imageUrl) {
            return swapModule_entry.b `<wui-image src=${imageUrl} alt="Token image"></wui-image> `;
        }
        return swapModule_entry.b `<wui-icon
      class="fallback-icon"
      name=${this.type === 'nft' ? 'image' : 'coinPlaceholder'}
    ></wui-icon>`;
    }
    templateIcon() {
        if (this.statusImageUrl) {
            return swapModule_entry.b `<wui-image
        class="status-image"
        src=${this.statusImageUrl}
        alt="Status image"
      ></wui-image>`;
        }
        return swapModule_entry.b `<wui-icon
      class="direction-icon"
      size=${ICON_SIZE[this.size]}
      name=${this.getTemplateIcon()}
    ></wui-icon>`;
    }
    getTemplateIcon() {
        if (this.type === 'trade') {
            return 'arrowClockWise';
        }
        return 'arrowBottom';
    }
};
WuiTransactionThumbnail.styles = [styles$2];
__decorate$2([
    index.n()
], WuiTransactionThumbnail.prototype, "type", void 0);
__decorate$2([
    index.n()
], WuiTransactionThumbnail.prototype, "size", void 0);
__decorate$2([
    index.n()
], WuiTransactionThumbnail.prototype, "statusImageUrl", void 0);
__decorate$2([
    index.n({ type: Array })
], WuiTransactionThumbnail.prototype, "images", void 0);
WuiTransactionThumbnail = __decorate$2([
    index.customElement('wui-transaction-thumbnail')
], WuiTransactionThumbnail);

var styles$1 = swapModule_entry.css `
  :host > wui-flex:first-child {
    gap: ${({ spacing }) => spacing[2]};
    padding: ${({ spacing }) => spacing[3]};
    width: 100%;
  }

  wui-flex {
    display: flex;
    flex: 1;
  }
`;

var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
let WuiTransactionListItemLoader = class WuiTransactionListItemLoader extends swapModule_entry.i {
    render() {
        return swapModule_entry.b `
      <wui-flex alignItems="center" .padding=${['1', '2', '1', '2']}>
        <wui-shimmer width="40px" height="40px" rounded></wui-shimmer>
        <wui-flex flexDirection="column" gap="1">
          <wui-shimmer width="124px" height="16px" rounded></wui-shimmer>
          <wui-shimmer width="60px" height="14px" rounded></wui-shimmer>
        </wui-flex>
        <wui-shimmer width="24px" height="12px" rounded></wui-shimmer>
      </wui-flex>
    `;
    }
};
WuiTransactionListItemLoader.styles = [swapModule_entry.resetStyles, styles$1];
WuiTransactionListItemLoader = __decorate$1([
    index.customElement('wui-transaction-list-item-loader')
], WuiTransactionListItemLoader);

var styles = swapModule_entry.css `
  :host {
    min-height: 100%;
  }

  .group-container[last-group='true'] {
    padding-bottom: ${({ spacing }) => spacing['3']};
  }

  .contentContainer {
    height: 280px;
  }

  .contentContainer > wui-icon-box {
    width: 40px;
    height: 40px;
    border-radius: ${({ borderRadius }) => borderRadius['3']};
  }

  .contentContainer > .textContent {
    width: 65%;
  }

  .emptyContainer {
    height: 100%;
  }
`;

var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
const PAGINATOR_ID = 'last-transaction';
const LOADING_ITEM_COUNT = 7;
let W3mActivityList = class W3mActivityList extends swapModule_entry.i {
    constructor() {
        super();
        this.unsubscribe = [];
        this.paginationObserver = undefined;
        this.page = 'activity';
        this.caipAddress = swapModule_entry.ChainController.state.activeCaipAddress;
        this.transactionsByYear = swapModule_entry.TransactionsController.state.transactionsByYear;
        this.loading = swapModule_entry.TransactionsController.state.loading;
        this.empty = swapModule_entry.TransactionsController.state.empty;
        this.next = swapModule_entry.TransactionsController.state.next;
        swapModule_entry.TransactionsController.clearCursor();
        this.unsubscribe.push(...[
            swapModule_entry.ChainController.subscribeKey('activeCaipAddress', val => {
                if (val) {
                    if (this.caipAddress !== val) {
                        swapModule_entry.TransactionsController.resetTransactions();
                        swapModule_entry.TransactionsController.fetchTransactions(val);
                    }
                }
                this.caipAddress = val;
            }),
            swapModule_entry.ChainController.subscribeKey('activeCaipNetwork', () => {
                this.updateTransactionView();
            }),
            swapModule_entry.TransactionsController.subscribe(val => {
                this.transactionsByYear = val.transactionsByYear;
                this.loading = val.loading;
                this.empty = val.empty;
                this.next = val.next;
            })
        ]);
    }
    firstUpdated() {
        this.updateTransactionView();
        this.createPaginationObserver();
    }
    updated() {
        this.setPaginationObserver();
    }
    disconnectedCallback() {
        this.unsubscribe.forEach(unsubscribe => unsubscribe());
    }
    render() {
        return swapModule_entry.b ` ${this.empty ? null : this.templateTransactionsByYear()}
    ${this.loading ? this.templateLoading() : null}
    ${!this.loading && this.empty ? this.templateEmpty() : null}`;
    }
    updateTransactionView() {
        swapModule_entry.TransactionsController.resetTransactions();
        if (this.caipAddress) {
            swapModule_entry.TransactionsController.fetchTransactions(swapModule_entry.CoreHelperUtil.getPlainAddress(this.caipAddress));
        }
    }
    templateTransactionsByYear() {
        const sortedYearKeys = Object.keys(this.transactionsByYear).sort().reverse();
        return sortedYearKeys.map(year => {
            const yearInt = parseInt(year, 10);
            const sortedMonthIndexes = new Array(12)
                .fill(null)
                .map((_, idx) => {
                const groupTitle = TransactionUtil.getTransactionGroupTitle(yearInt, idx);
                const transactions = this.transactionsByYear[yearInt]?.[idx];
                return {
                    groupTitle,
                    transactions
                };
            })
                .filter(({ transactions }) => transactions)
                .reverse();
            return sortedMonthIndexes.map(({ groupTitle, transactions }, index) => {
                const isLastGroup = index === sortedMonthIndexes.length - 1;
                if (!transactions) {
                    return null;
                }
                return swapModule_entry.b `
          <wui-flex
            flexDirection="column"
            class="group-container"
            last-group="${isLastGroup ? 'true' : 'false'}"
            data-testid="month-indexes"
          >
            <wui-flex
              alignItems="center"
              flexDirection="row"
              .padding=${['2', '3', '3', '3']}
            >
              <wui-text variant="md-medium" color="secondary" data-testid="group-title">
                ${groupTitle}
              </wui-text>
            </wui-flex>
            <wui-flex flexDirection="column" gap="2">
              ${this.templateTransactions(transactions, isLastGroup)}
            </wui-flex>
          </wui-flex>
        `;
            });
        });
    }
    templateRenderTransaction(transaction, isLastTransaction) {
        const { date, descriptions, direction, images, status, type, transfers, isAllNFT } = this.getTransactionListItemProps(transaction);
        return swapModule_entry.b `
      <wui-transaction-list-item
        date=${date}
        .direction=${direction}
        id=${isLastTransaction && this.next ? PAGINATOR_ID : ''}
        status=${status}
        type=${type}
        .images=${images}
        .onlyDirectionIcon=${isAllNFT || transfers.length === 1}
        .descriptions=${descriptions}
      ></wui-transaction-list-item>
    `;
    }
    templateTransactions(transactions, isLastGroup) {
        return transactions.map((transaction, index) => {
            const isLastTransaction = isLastGroup && index === transactions.length - 1;
            return swapModule_entry.b `${this.templateRenderTransaction(transaction, isLastTransaction)}`;
        });
    }
    emptyStateActivity() {
        return swapModule_entry.b `<wui-flex
      class="emptyContainer"
      flexGrow="1"
      flexDirection="column"
      justifyContent="center"
      alignItems="center"
      .padding=${['10', '5', '10', '5']}
      gap="5"
      data-testid="empty-activity-state"
    >
      <wui-icon-box color="default" icon="wallet" size="xl"></wui-icon-box>
      <wui-flex flexDirection="column" alignItems="center" gap="2">
        <wui-text align="center" variant="lg-medium" color="primary">No Transactions yet</wui-text>
        <wui-text align="center" variant="lg-regular" color="secondary"
          >Start trading on dApps <br />
          to grow your wallet!</wui-text
        >
      </wui-flex>
    </wui-flex>`;
    }
    emptyStateAccount() {
        return swapModule_entry.b `<wui-flex
      class="contentContainer"
      alignItems="center"
      justifyContent="center"
      flexDirection="column"
      gap="4"
      data-testid="empty-account-state"
    >
      <wui-icon-box icon="swapHorizontal" size="lg" color="default"></wui-icon-box>
      <wui-flex
        class="textContent"
        gap="2"
        flexDirection="column"
        justifyContent="center"
        flexDirection="column"
      >
        <wui-text variant="md-regular" align="center" color="primary">No activity yet</wui-text>
        <wui-text variant="sm-regular" align="center" color="secondary"
          >Your next transactions will appear here</wui-text
        >
      </wui-flex>
      <wui-link @click=${this.onReceiveClick.bind(this)}>Trade</wui-link>
    </wui-flex>`;
    }
    templateEmpty() {
        if (this.page === 'account') {
            return swapModule_entry.b `${this.emptyStateAccount()}`;
        }
        return swapModule_entry.b `${this.emptyStateActivity()}`;
    }
    templateLoading() {
        if (this.page === 'activity') {
            return swapModule_entry.b ` <wui-flex flexDirection="column" width="100%">
        <wui-flex .padding=${['2', '3', '3', '3']}>
          <wui-shimmer width="70px" height="16px" rounded></wui-shimmer>
        </wui-flex>
        <wui-flex flexDirection="column" gap="2" width="100%">
          ${Array(LOADING_ITEM_COUNT)
                .fill(swapModule_entry.b ` <wui-transaction-list-item-loader></wui-transaction-list-item-loader> `)
                .map(item => item)}
        </wui-flex>
      </wui-flex>`;
        }
        return null;
    }
    onReceiveClick() {
        swapModule_entry.RouterController.push('WalletReceive');
    }
    createPaginationObserver() {
        const { projectId } = swapModule_entry.OptionsController.state;
        this.paginationObserver = new IntersectionObserver(([element]) => {
            if (element?.isIntersecting && !this.loading) {
                swapModule_entry.TransactionsController.fetchTransactions(swapModule_entry.CoreHelperUtil.getPlainAddress(this.caipAddress));
                swapModule_entry.EventsController.sendEvent({
                    type: 'track',
                    event: 'LOAD_MORE_TRANSACTIONS',
                    properties: {
                        address: swapModule_entry.CoreHelperUtil.getPlainAddress(this.caipAddress),
                        projectId,
                        cursor: this.next,
                        isSmartAccount: swapModule_entry.getPreferredAccountType(swapModule_entry.ChainController.state.activeChain) ===
                            swapModule_entry.W3mFrameRpcConstants.ACCOUNT_TYPES.SMART_ACCOUNT
                    }
                });
            }
        }, {});
        this.setPaginationObserver();
    }
    setPaginationObserver() {
        this.paginationObserver?.disconnect();
        const lastItem = this.shadowRoot?.querySelector(`#${PAGINATOR_ID}`);
        if (lastItem) {
            this.paginationObserver?.observe(lastItem);
        }
    }
    getTransactionListItemProps(transaction) {
        const date = DateUtil.formatDate(transaction?.metadata?.minedAt);
        const transfers = TransactionUtil.mergeTransfers(transaction?.transfers || []);
        const descriptions = TransactionUtil.getTransactionDescriptions(transaction, transfers);
        const transfer = transfers?.[0];
        const isAllNFT = Boolean(transfer) && transfers?.every(item => Boolean(item.nft_info));
        const images = TransactionUtil.getTransactionImages(transfers);
        return {
            date,
            direction: transfer?.direction,
            descriptions,
            isAllNFT,
            images,
            status: transaction.metadata?.status,
            transfers,
            type: transaction.metadata?.operationType
        };
    }
};
W3mActivityList.styles = styles;
__decorate([
    index.n()
], W3mActivityList.prototype, "page", void 0);
__decorate([
    index.r()
], W3mActivityList.prototype, "caipAddress", void 0);
__decorate([
    index.r()
], W3mActivityList.prototype, "transactionsByYear", void 0);
__decorate([
    index.r()
], W3mActivityList.prototype, "loading", void 0);
__decorate([
    index.r()
], W3mActivityList.prototype, "empty", void 0);
__decorate([
    index.r()
], W3mActivityList.prototype, "next", void 0);
W3mActivityList = __decorate([
    index.customElement('w3m-activity-list')
], W3mActivityList);
//# sourceMappingURL=index-B9CN_mr3.js.map

//# sourceMappingURL=index-B9CN_mr3.js.map