PageSourceSearch

https://www.lofty.ai/assets/property-deal-BQk-71ge.js

js lofty.ai collected 2026-09-28 05:46:18 UTC 454,944 bytes, 93 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PriceLineChart-CWNj0Tqt.js","assets/rolldown-runtime-BG2f4sTM.js","assets/react-CYsHstG7.js","assets/state-C4IzlkDq.js","assets/tokenProvider-PNp6AHBO.js","assets/auth-BBx1qYVo.js","assets/amplifyCredentials.client-BiRoZKNq.js","assets/hooks-Dr3i4SJb.js","assets/preload-helper-Czpn1I53.js","assets/analytics-DyulWhN4.js","assets/env-B8hvVhPP.js","assets/chunkLoadRecovery-D7Od6NEj.js","assets/jsx-runtime-CqqR4vFp.js","assets/assetUrl-BlQwC3Gy.js","assets/icons-BPGyB4it.js","assets/buffer-BakxX7f8.js","assets/useQuery-BhDSG0wj.js","assets/property-cuwonSdw.js","assets/split-on-first-DQh-h8Jc.js","assets/Toast-CGSK31on.js","assets/esm-DnIqL4Sc.js","assets/format-sNN-Y9cn.js","assets/dist-DLo1NUuX.js","assets/chartjs-plugin-zoom.esm-CDMW2z4j.js","assets/YieldLineChart-CVUQ9czY.js"])))=>i.map(i=>d[i]);
2import{s as e,t}from"./rolldown-runtime-BG2f4sTM.js";import{t as n}from"./react-CYsHstG7.js";import{m as r}from"./tokenProvider-PNp6AHBO.js";import{I as i,a,i as o,s}from"./hooks-Dr3i4SJb.js";import{c,l}from"./components-DBQ8KnQG.js";import{i as u,t as d}from"./lib-DFHwdoKZ.js";import{t as f}from"./preload-helper-Czpn1I53.js";import{$ as p,$t as m,Ct as h,D as g,Dn as _,Dt as v,En as y,Et as b,It as x,J as S,Lt as C,Pt as w,Q as T,Qt as E,Rt as D,Tn as ee,Tt as O,Ut as k,Vt as A,W as j,Xt as te,Yt as ne,Z as M,Zt as re,_t as N,a as P,bn as ie,fn as ae,ft as oe,gt as se,i as ce,j as le,ln as ue,lt as de,n as fe,q as F,st as pe,tn as I,vn as L,vt as me,wn as he,wt as ge,yt as _e}from"./state-C4IzlkDq.js";import{$r as ve,$t as ye,A as be,Ai as xe,Ar as R,Ci as Se,Cr as z,Di as Ce,Fi as we,Gr as Te,Hi as Ee,Ir as B,J as De,Jn as Oe,Kr as ke,Li as V,M as Ae,Mi as je,Mr as Me,Nr as H,O as Ne,Oi as Pe,Or as U,Pi as Fe,Pn as Ie,Pr as W,Qn as Le,Qr as Re,Qt as ze,Ti as Be,Ui as Ve,Un as He,Wn as Ue,Wr as We,Xn as Ge,Xr as G,Yn as Ke,Yr as qe,Yt as Je,Zr as Ye,_ as Xe,ai as Ze,an as Qe,bi as $e,d as K,ei as et,en as tt,f as nt,fi as rt,fn as it,g as at,ht as ot,i as st,ii as ct,j as lt,ji as q,jt as ut,ki as dt,l as ft,m as pt,mi as mt,mt as ht,n as gt,ni as _t,o as vt,oi as yt,on as bt,or as xt,p as St,qn as Ct,qr as wt,qt as Tt,r as Et,ri as Dt,rn as Ot,rt as kt,st as At,t as J,ti as jt,ur as Mt,xi as Y,xr as Nt,xt as Pt,yt as Ft,zr as It}from"./analytics-DyulWhN4.js";import{t as Lt}from"./jsx-runtime-CqqR4vFp.js";import{i as Rt,m as zt,t as Bt,u as Vt}
2from"./icons-BPGyB4it.js";import{a as Ht,c as Ut,i as Wt,l as Gt,o as Kt,r as qt,s as Jt,t as Yt}from"./Lightbox-DoCLFeLI.js";import{a as Xt}from"./seo-CIV4jX_7.js";import{i as Zt,t as Qt}from"./meta-ByzlqKjN.js";import{t as $t}from"./buffer-BakxX7f8.js";import{_ as en,a as tn,c as nn,d as rn,f as an,g as on,h as sn,i as cn,l as ln,m as un,n as dn,o as fn,p as pn,r as mn,s as hn,t as gn,u as _n,v as vn,y as yn}from"./format-sNN-Y9cn.js";import{$t as bn,Bt as xn,Gt as Sn,Ht as Cn,Jt as wn,Kt as Tn,Qt as En,Ut as Dn,Vt as On,Wt as kn,Xt as An,Yt as jn,Zt as Mn,a as Nn,an as Pn,at as Fn,c as In,cn as Ln,ct as Rn,dn as zn,en as Bn,fn as Vn,i as Hn,in as Un,it as Wn,l as Gn,ln as Kn,n as qn,nn as Jn,o as Yn,on as Xn,ot as Zn,qt as Qn,r as $n,rn as er,rt as tr,s as nr,t as rr,un as ir,ut as ar,zt as or}from"./BrowserProvidersGate-B_LwMme5.js";import{t as sr}from"./checkoutFailureTelemetry-bcnBBp_y.js";import{t as cr}from"./UnreadBadge-D4atx0mh.js";import{L as lr,M as ur,N as dr,R as fr,z as pr}from"./useQuery-BhDSG0wj.js";import{a as mr,n as hr,s as gr}from"./Toast-CGSK31on.js";import{t as _r}from"./esm-DnIqL4Sc.js";import{n as vr,t as yr}from"./stripeReturnContext-BAYwQ1FA.js";import{n as br}from"./ShoppingCartContext-CaewOugh.js";import{n as xr}from"./AuthNavLoading-CW-2RjJA.js";import{t as Sr}from"./Tooltip-Dv7KDgP2.js";import{n as Cr,r as wr,t as Tr}from"./PropertyBadges-DWcnUSP7.js";import{i as Er,r as Dr,t as Or}from"./mock-partners-DMuHeabI.js";import{t as kr}from"./AppHeader-CrzBarHp.js";import{t as Ar}from"./NotFound-DYNdPg72.js";import{i as jr}from"./pendingBuyIntent-Cjhv-Ey7.js";import"./AppDataContext-P5Y6hy9y.js";import{t as Mr}from"./lp-rewards-Dj9c8CU-.js";import{t as Nr}from"./PriceLineChart-CWNj0Tqt.js";import{i as Pr,n as Fr,t as Ir}from"./AlgoSdkConnectContext-B2E0ZIH3.js";import{t as Lr}from"./NumericInput-QhJUN1JC.js";import{t as Rr}from"./arrays-VI7XjGhB.js";import{t as zr}from"./algosdk-Dn-k5j1n.js";import{t as Br}from"./OrderSubmitted-SXAfFBtF.js";function Vr(e,t){en(2,arguments);var n=on(e),r=vn(t);if(isNaN(r))return new Date(NaN);if(!r)return n;var i=n.getDate(),a=new Date(n.getTime());return a.setMonth(n.getMonth()+r+1,0),i>=a.getDate()?a:(n.setFullYear(a.getFullYear(),a.getMonth(),i),n)}function Hr(e,t){if(en(2,arguments),!t||yn(t)!==`object`)return new Date(NaN);var n=t.years?vn(t.years):0,r=t.months?vn(t.months):0,i=t.weeks?vn(t.weeks):0,a=t.days?vn(t.days):0,o=t.hours?vn(t.hours):0,s=t.minutes?vn(t.minutes):0,c=t.seconds?vn(t.seconds):0,l=on(e),u=r||n?Vr(l,r+n*12):l,d=a||i?Vn(u,a+i*7):u,f=(c+(s+o*60)*60)*1e3;return new Date(d.getTime()+f)}function Ur(e,t){if(e==null)throw TypeError(`assign requires that input parameter not be null or undefined`);for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}function Wr(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Gr(e,t){if(e){if(typeof e==`string`)return Wr(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Wr(e,t):void 0}}function Kr(e,t){var n=typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(!n){if(Array.isArray(e)||(n=Gr(e))||t&&e&&typeof e.length==`number`){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw TypeError(`Invalid attempt to iterate non-iterable instance.
3In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a,o=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||n.return==null||n.return()}finally{if(s)throw a}}}}function X(e){if(e===void 0)throw ReferenceError(`this hasn't been initialised - super() hasn't been called`);return e}function qr(e,t){return qr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},qr(e,t)}function Jr(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Super expression must either be null or a function`);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&qr(e,t)}function Yr(e){return Yr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Yr(e)}function Xr(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Xr=function(){return!!e})()}function Zr(e,t){if(t&&(yn(t)==`object`||typeof t==`function`))return t;if(t!==void 0)throw TypeError(`Derived constructors may only return object or undefined`);return X(e)}function Qr(e){var t=Xr();return function(){var n,r=Yr(e);if(t){var i=Yr(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return Zr(this,n)}}function $r(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}function ei(e,t){if(yn(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(yn(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function ti(e){var t=ei(e,`string`);return yn(t)==`symbol`?t:t+``}function ni(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,ti(r.key),r)}}function ri(e,t,n){return t&&ni(e.prototype,t),n&&ni(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Z(e,t,n){return(t=ti(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var ii=10,ai=function(){function e(){$r(this,e),Z(this,`priority`,void 0),Z(this,`subPriority`,0)}return ri(e,[{key:`validate`,value:function(e,t){return!0}}]),e}(),oi=function(e){Jr(n,e);var t=Qr(n);function n(e,r,i,a,o){var s;return $r(this,n),s=t.call(this),s.value=e,s.validateValue=r,s.setValue=i,s.priority=a,o&&(s.subPriority=o),s}return ri(n,[{key:`validate`,value:function(e,t){return this.validateValue(e,this.value,t)}},{key:`set`,value:function(e,t,n){return this.setValue(e,t,this.value,
3n)}}]),n}(ai),si=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,ii),Z(X(e),`subPriority`,-1),e}return ri(n,[{key:`set`,value:function(e,t){if(t.timestampIsSet)return e;var n=new Date(0);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}}]),n}(ai),ci=function(){function e(){$r(this,e),Z(this,`incompatibleTokens`,void 0),Z(this,`priority`,void 0),Z(this,`subPriority`,void 0)}return ri(e,[{key:`run`,value:function(e,t,n,r){var i=this.parse(e,t,n,r);return i?{setter:new oi(i.value,this.validate,this.set,this.priority,this.subPriority),rest:i.rest}:null}},{key:`validate`,value:function(e,t,n){return!0}}]),e}(),li=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,140),Z(X(e),`incompatibleTokens`,[`R`,`u`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`G`:case`GG`:case`GGG`:return n.era(e,{width:`abbreviated`})||n.era(e,{width:`narrow`});case`GGGGG`:return n.era(e,{width:`narrow`});default:return n.era(e,{width:`wide`})||n.era(e,{width:`abbreviated`})||n.era(e,{width:`narrow`})}}},{key:`set`,value:function(e,t,n){return t.era=n,e.setUTCFullYear(n,0,1),e.setUTCHours(0,0,0,0),e}}]),n}(ci),ui={month:/^(1[0-2]|0?\d)/,date:/^(3[0-1]|[0-2]?\d)/,dayOfYear:/^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,week:/^(5[0-3]|[0-4]?\d)/,hour23h:/^(2[0-3]|[0-1]?\d)/,hour24h:/^(2[0-4]|[0-1]?\d)/,hour11h:/^(1[0-1]|0?\d)/,hour12h:/^(1[0-2]|0?\d)/,minute:/^[0-5]?\d/,second:/^[0-5]?\d/,singleDigit:/^\d/,twoDigits:/^\d{1,2}/,threeDigits:/^\d{1,3}/,fourDigits:/^\d{1,4}/,anyDigitsSigned:/^-?\d+/,singleDigitSigned:/^-?\d/,twoDigitsSigned:/^-?\d{1,2}/,threeDigitsSigned:/^-?\d{1,3}/,fourDigitsSigned:/^-?\d{1,4}/},di={basicOptionalMinutes:/^([+-])(\d{2})(\d{2})?|Z/,basic:/^([+-])(\d{2})(\d{2})|Z/,basicOptionalSeconds:/^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,extended:/^([+-])(\d{2}):(\d{2})|Z/,extendedOptionalSeconds:/^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/};function fi(e,t){return e&&{value:t(e.value),rest:e.rest}}function pi(e,t){var n=t.match(e);return n?{value:parseInt(n[0],10),rest:t.slice(n[0].length)}:null}function mi(e,t){var n=t.match(e);if(!n)return null;if(n[0]===`Z`)return{value:0,rest:t.slice(1)};var r=n[1]===`+`?1:-1,i=n[2]?parseInt(n[2],10):0,a=n[3]?parseInt(n[3],10):0,o=n[5]?parseInt(n[5],10):0;return{value:r*(i*Kn+a*ir+o*zn),rest:t.slice(n[0].length)}}function hi(e){return pi(ui.anyDigitsSigned,e)}function gi(e,t){switch(e){case 1:return pi(ui.singleDigit,t);case 2:return pi(ui.twoDigits,t);case 3:return pi(ui.threeDigits,t);case 4:return pi(ui.fourDigits,t);default:return pi(RegExp(`^\\d{1,`+e+`}`),t)}}function _i(e,t){switch(e){case 1:return pi(ui.singleDigitSigned,t);case 2:return pi(ui.twoDigitsSigned,t);case 3:return pi(ui.threeDigitsSigned,t);case 4:return pi(ui.fourDigitsSigned,t);default:return pi(RegExp(`^-?\\d{1,`+e+`}`),t)}}function vi(e){switch(e){case`morning`:return 4;case`evening`:return 17;case`pm`:case`noon`:case`afternoon`:return 12;default:return 0}}function yi(e,t){var n=t>0,r=n?t:1-t,i;if(r<=50)i=e||100;else{var a=r+50,o=Math.floor(a/100)*100,s=e>=a%100;i=e+o-(s?100:0)}return n?i:1-i}function bi(e){return e%400==0||e%4==0&&e%100!=0}var xi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,130),Z(X(e),`incompatibleTokens`,[`Y`,`R`,`u`,`w`,`I`,`i`,`e`,`c`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){var r=function(e){return{year:e,isTwoDigitYear:t===`yy`}};switch(t){case`y`:return fi(gi(4,e),r);case`yo`:return fi(n.ordinalNumber(e,{unit:`year`}),r);default:return fi(gi(t.length,e),r)}}},{key:`validate`,value:function(e,t){return t.isTwoDigitYear||t.year>0}},{key:`set`,value:function(e,t,n){var r=e.getUTCFullYear();if(n.isTwoDigitYear){var i=yi(n.year,r);return e.setUTCFullYear(i,0,1),e.setUTCHours(0,0,0,0),e}var a=!(`era`in t)||t.era===1?n.year:1-n.year;return e.setUTCFullYear(a,0,1),e.setUTCHours(0,0,0,0),e}}]),n}(ci),Si=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,130),Z(X(e),`incompatibleTokens`,[`y`,`R`,`u`,`Q`,`q`,`M`,`L`,`I`,`d`,`D`,`i`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){var r=function(e){return{year:e,isTwoDigitYear:t===`YY`}};switch(t){case`Y`:return fi(gi(4,e),r);case`Yo`:return fi(n.ordinalNumber(e,{unit:`year`}),r);default:return fi(gi(t.length,e),r)}}},{key:`validate`,value:function(e,t){return t.isTwoDigitYear||t.year>0}},{key:`set`,value:function(e,t,n,r){var i=nn(e,r);if(n.isTwoDigitYear){var a=yi(n.year,i);return e.setUTCFullYear(a,0,r.firstWeekContainsDate),e.setUTCHours(0,0,0,0),ln(e,r)}var o=!(`era`in t)||t.era===1?n.year:1-n.year;return e.setUTCFullYear(o,0,r.firstWeekContainsDate),e.setUTCHours(0,0,0,0),ln(e,r)}}]),n}(ci),Ci=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,130),Z(X(e),`incompatibleTokens`,[`G`,`y`,`Y`,`u`,`Q`,`q`,`M`,`L`,`w`,`d`,`D`,`e`,`c`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t){return _i(t===`R`?4:t.length,e)}},{key:`set`,value:function(e,t,n){var r=new Date(0);return r.setUTCFullYear(n,0,4),r.setUTCHours(0,0,0,0),rn(r)}}]),n}(ci),wi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,130),Z(X(e),`incompatibleTokens`,[`G`,`y`,`Y`,`R`,`w`,`I`,`i`,`e`,`c`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t){return _i(t===`u`?4:t.length,e)}},{key:`set`,value:function(e,t,n){return e.setUTCFullYear(n,0,1),e.setUTCHours(0,0,0,0),e}}]),n}(ci),Ti=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,120),Z(X(e),`incompatibleTokens`,[`Y`,`R`,`q`,`M`,`L`,`w`,`I`,`d`,`D`,`i`,`e`,`c`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`Q`:case`QQ`:return gi(t.length,e);case`Qo`:return n.ordinalNumber(e,{unit:`quarter`});case`QQQ`:return n.quarter(e,{width:`abbreviated`,context:`formatting`})||n.quarter(e,{width:`narrow`,context:`formatting`});case`QQQQQ`:return n.quarter(e,{width:`narrow`,context:`formatting`});default:return n.quarter(e,{width:`wide`,context:`formatting`})||n.quarter(e,{width:`abbreviated`,context:`formatting`})||n.quarter(e,{width:`narrow`,context:`formatting`})}}},{key:`validate`,value:function(e,t){return t>=1&&t<=4}},{key:`set`,value:function(e,t,n){return e.setUTCMonth((n-1)*3,1),e.setUTCHours(0,0,0,0),e}}]),n}(ci),Ei=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,120),Z(X(e),`incompatibleTokens`,[`Y`,`R`,`Q`,`M`,`L`,`w`,`I`,`d`,`D`,`i`,`e`,`c`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`q`:case`qq`:return gi(t.length,e);case`qo`:return n.ordinalNumber(e,{unit:`quarter`});case`qqq`:return n.quarter(e,{width:`abbreviated`,context:`standalone`})||n.quarter(e,{width:`narrow`,context:`standalone`});case`qqqqq`:return n.quarter(e,{width:`narrow`,context:`standalone`});default:return n.quarter(e,{width:`wide`,context:`standalone`})||n.quarter(e,{width:`abbreviated`,context:`standalone`})||n.quarter(e,{width:`narrow`,context:`standalone`})}}},{key:`validate`,value:function(e,t){return t>=1&&t<=4}},{key:`set`,value:function(e,t,n){return e.setUTCMonth((n-1)*3,1),e.setUTCHours(0,0,0,0),e}}]),n}(ci),Di=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`incompatibleTokens`,[`Y`,`R`,`q`,`Q`,`L`,`w`,`I`,`D`,`i`,`e`,`c`,`t`,`T`]),Z(X(e),`priority`,110),e}return ri(n,[{key:`parse`,value:function(e,t,n){var r=function(e){return e-1};switch(t){case`M`:return fi(pi(ui.month,e),r);case`MM`:return fi(gi(2,e),r);case`Mo`:return fi(n.ordinalNumber(e,{unit:`month`}),r);case`MMM`:return n.month(e,{width:`abbreviated`,context:`formatting`})||n.month(e,{width:`narrow`,context:`formatting`});case`MMMMM`:return n.month(e,{width:`narrow`,context:`formatting`});default:return n.month(e,{width:`wide`,context:`formatting`})||n.month(e,{width:`abbreviated`,context:`formatting`})||n.month(e,{width:`narrow`,context:`formatting`})}}},{key:`validate`,value:function(e,t){return t>=0&&t<=11}},{key:`set`,value:function(e,t,n){return e.setUTCMonth(n,1),e.setUTCHours(0,0,0,0),e}}]),n}(ci),Oi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,110),Z(X(e),`incompatibleTokens`,[`Y`,`R`,`q`,`Q`,`M`,`w`,`I`,`D`,`i`,`e`,`c`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){var r=function(e){return e-1};switch(t){case`L`:return fi(pi(ui.month,e),r);case`LL`:return fi(gi(2,e),r);case`Lo`:return fi(n.ordinalNumber(e,{unit:`month`}),r);case`LLL`:return n.month(e,{width:`abbreviated`,context:`standalone`})||n.month(e,{width:`narrow`,context:`standalone`});case`LLLLL`:return n.month(e,{width:`narrow`,context:`standalone`});default:return n.month(e,{width:`wide`,context:`standalone`})||n.month(e,{width:`abbreviated`,context:`standalone`})||n.month(e,{width:`narrow`,context:`standalone`})}}},{key:`validate`,value:function(e,t){return t>=0&&t<=11}},{key:`set`,value:function(e,t,n){return e.setUTCMonth(n,1),e.setUTCHours(0,0,0,0),e}}]),n}(ci);function ki(e,t,n){en(2,arguments);var r=on(e),i=vn(t),a=hn(r,n)-i;return r.setUTCDate(r.getUTCDate()-a*7),r}var Ai=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,100),Z(X(e),`incompatibleTokens`,[`y`,`R`,`u`,`q`,`Q`,`M`,`L`,`I`,`d`,`D`,`i`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`w`:return pi(ui.week,e);case`wo`:return n.ordinalNumber(e,{unit:`week`});default:return gi(t.length,e)}}},{key:`validate`,value:function(e,t){return t>=1&&t<=53}},{key:`set`,value:function(e,t,n,r){return ln(ki(e,n,r),r)}}]),n}(ci);function ji(e,t){en(2,arguments);var n=on(e),r=vn(t),i=_n(n)-r;return n.setUTCDate(n.getUTCDate()-i*7),n}var Mi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,100),Z(X(e),`incompatibleTokens`,[`y`,`Y`,`u`,`q`,`Q`,`M`,`L`,`w`,`d`,`D`,`e`,`c`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`I`:return pi(ui.week,e);case`Io`:return n.ordinalNumber(e,{unit:`week`});default:return gi(t.length,e)}}},{key:`validate`,value:function(e,t){return t>=1&&t<=53}},{key:`set`,value:function(e,t,n){return rn(ji(e,n))}}]),n}(ci),Ni=[31,28,31,30,31,30,31,31,30,31,30,31],Pi=[31,29,31,30,31,30,31,31,30,31,30,31],Fi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,90),Z(X(e),`subPriority`,1),Z(X(e),`incompatibleTokens`,[`Y`,`R`,`q`,`Q`,`w`,`I`,`D`,`i`,`e`,`c`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`d`:return pi(ui.date,e);case`do`:return n.ordinalNumber(e,{unit:`date`});default:return gi(t.length,e)}}},{key:`validate`,value:function(e,t){var n=bi(e.getUTCFullYear()),r=e.getUTCMonth();return n?t>=1&&t<=Pi[r]:t>=1&&t<=Ni[r]}},{key:`set`,value:function(e,t,n){return e.setUTCDate(n),e.setUTCHours(0,0,0,0),e}}]),n}(ci),Ii=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,90),Z(X(e),`subpriority`,1),Z(X(e),`incompatibleTokens`,[`Y`,`R`,`q`,`Q`,`M`,`L`,`w`,`I`,`d`,`E`,`i`,`e`,`c`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`D`:case`DD`:return pi(ui.dayOfYear,e);case`Do`:return n.ordinalNumber(e,{unit:`date`});default:return gi(t.length,e)}}},{key:`validate`,value:function(e,t){return bi(e.getUTCFullYear())?t>=1&&t<=366:t>=1&&t<=365}},{key:`set`,value:function(e,t,n){return e.setUTCMonth(0,n),e.setUTCHours(0,0,0,0),e}}]),n}(ci);function Li(e,t,n){var r;en(2,arguments);var i=sn(),a=vn(n?.weekStartsOn??(n==null||(r=n.locale)==null?void 0:r.options?.weekStartsOn)??i.weekStartsOn??i.locale?.options?.weekStartsOn??0);if(!(a>=0&&a<=6))throw RangeError(`weekStartsOn must be between 0 and 6 inclusively`);var o=on(e),s=vn(t),c=o.getUTCDay(),l=((s%7+7)%7<a?7:0)+s-c;return o.setUTCDate(o.getUTCDate()+l),o}var Ri=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,90),Z(X(e),`incompatibleTokens`,[`D`,`i`,`e`,`c`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`E`:case`EE`:case`EEE`
3:return n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});case`EEEEE`:return n.day(e,{width:`narrow`,context:`formatting`});case`EEEEEE`:return n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});default:return n.day(e,{width:`wide`,context:`formatting`})||n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`})}}},{key:`validate`,value:function(e,t){return t>=0&&t<=6}},{key:`set`,value:function(e,t,n,r){return e=Li(e,n,r),e.setUTCHours(0,0,0,0),e}}]),n}(ci),zi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,90),Z(X(e),`incompatibleTokens`,[`y`,`R`,`u`,`q`,`Q`,`M`,`L`,`I`,`d`,`D`,`E`,`i`,`c`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n,r){var i=function(e){var t=Math.floor((e-1)/7)*7;return(e+r.weekStartsOn+6)%7+t};switch(t){case`e`:case`ee`:return fi(gi(t.length,e),i);case`eo`:return fi(n.ordinalNumber(e,{unit:`day`}),i);case`eee`:return n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});case`eeeee`:return n.day(e,{width:`narrow`,context:`formatting`});case`eeeeee`:return n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`});default:return n.day(e,{width:`wide`,context:`formatting`})||n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`})}}},{key:`validate`,value:function(e,t){return t>=0&&t<=6}},{key:`set`,value:function(e,t,n,r){return e=Li(e,n,r),e.setUTCHours(0,0,0,0),e}}]),n}(ci),Bi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,90),Z(X(e),`incompatibleTokens`,[`y`,`R`,`u`,`q`,`Q`,`M`,`L`,`I`,`d`,`D`,`E`,`i`,`e`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n,r){var i=function(e){var t=Math.floor((e-1)/7)*7;return(e+r.weekStartsOn+6)%7+t};switch(t){case`c`:case`cc`:return fi(gi(t.length,e),i);case`co`:return fi(n.ordinalNumber(e,{unit:`day`}),i);case`ccc`:return n.day(e,{width:`abbreviated`,context:`standalone`})||n.day(e,{width:`short`,context:`standalone`})||n.day(e,{width:`narrow`,context:`standalone`});case`ccccc`:return n.day(e,{width:`narrow`,context:`standalone`});case`cccccc`:return n.day(e,{width:`short`,context:`standalone`})||n.day(e,{width:`narrow`,context:`standalone`});default:return n.day(e,{width:`wide`,context:`standalone`})||n.day(e,{width:`abbreviated`,context:`standalone`})||n.day(e,{width:`short`,context:`standalone`})||n.day(e,{width:`narrow`,context:`standalone`})}}},{key:`validate`,value:function(e,t){return t>=0&&t<=6}},{key:`set`,value:function(e,t,n,r){return e=Li(e,n,r),e.setUTCHours(0,0,0,0),e}}]),n}(ci);function Vi(e,t){en(2,arguments);var n=vn(t);n%7==0&&(n-=7);var r=1,i=on(e),a=i.getUTCDay(),o=((n%7+7)%7<r?7:0)+n-a;return i.setUTCDate(i.getUTCDate()+o),i}var Hi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,90),Z(X(e),`incompatibleTokens`,[`y`,`Y`,`u`,`q`,`Q`,`M`,`L`,`w`,`d`,`D`,`E`,`e`,`c`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){var r=function(e){return e===0?7:e};switch(t){case`i`:case`ii`:return gi(t.length,e);case`io`:return n.ordinalNumber(e,{unit:`day`});case`iii`:return fi(n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`}),r);case`iiiii`:return fi(n.day(e,{width:`narrow`,context:`formatting`}),r);case`iiiiii`:return fi(n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`}),r);default:return fi(n.day(e,{width:`wide`,context:`formatting`})||n.day(e,{width:`abbreviated`,context:`formatting`})||n.day(e,{width:`short`,context:`formatting`})||n.day(e,{width:`narrow`,context:`formatting`}),r)}}},{key:`validate`,value:function(e,t){return t>=1&&t<=7}},{key:`set`,value:function(e,t,n){return e=Vi(e,n),e.setUTCHours(0,0,0,0),e}}]),n}(ci),Ui=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,80),Z(X(e),`incompatibleTokens`,[`b`,`B`,`H`,`k`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`a`:case`aa`:case`aaa`:return n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`});case`aaaaa`:return n.dayPeriod(e,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(e,{width:`wide`,context:`formatting`})||n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`})}}},{key:`set`,value:function(e,t,n){return e.setUTCHours(vi(n),0,0,0),e}}]),n}(ci),Wi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,80),Z(X(e),`incompatibleTokens`,[`a`,`B`,`H`,`k`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`b`:case`bb`:case`bbb`:return n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`});case`bbbbb`:return n.dayPeriod(e,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(e,{width:`wide`,context:`formatting`})||n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`})}}},{key:`set`,value:function(e,t,n){return e.setUTCHours(vi(n),0,0,0),e}}]),n}(ci),Gi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,80),Z(X(e),`incompatibleTokens`,[`a`,`b`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`B`:case`BB`:case`BBB`:return n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`});case`BBBBB`:return n.dayPeriod(e,{width:`narrow`,context:`formatting`});default:return n.dayPeriod(e,{width:`wide`,context:`formatting`})||n.dayPeriod(e,{width:`abbreviated`,context:`formatting`})||n.dayPeriod(e,{width:`narrow`,context:`formatting`})}}},{key:`set`,value:function(e,t,n){return e.setUTCHours(vi(n),0,0,0),e}}]),n}(ci),Ki=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,70),Z(X(e),`incompatibleTokens`,[`H`,`K`,`k`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`h`:return pi(ui.hour12h,e);case`ho`:return n.ordinalNumber(e,{unit:`hour`});default:return gi(t.length,e)}}},{key:`validate`,value:function(e,t){return t>=1&&t<=12}},{key:`set`,value:function(e,t,n){var r=e.getUTCHours()>=12;return r&&n<12?e.setUTCHours(n+12,0,0,0):!r&&n===12?e.setUTCHours(0,0,0,0):e.setUTCHours(n,0,0,0),e}}]),n}(ci),qi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,70),Z(X(e),`incompatibleTokens`,[`a`,`b`,`h`,`K`,`k`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`H`:return pi(ui.hour23h,e);case`Ho`:return n.ordinalNumber(e,{unit:`hour`});default:return gi(t.length,e)}}},{key:`validate`,value:function(e,t){return t>=0&&t<=23}},{key:`set`,value:function(e,t,n){return e.setUTCHours(n,0,0,0),e}}]),n}(ci),Ji=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,70),Z(X(e),`incompatibleTokens`,[`h`,`H`,`k`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`K`:return pi(ui.hour11h,e);case`Ko`:return n.ordinalNumber(e,{unit:`hour`});default:return gi(t.length,e)}}},{key:`validate`,value:function(e,t){return t>=0&&t<=11}},{key:`set`,value:function(e,t,n){return e.getUTCHours()>=12&&n<12?e.setUTCHours(n+12,0,0,0):e.setUTCHours(n,0,0,0),e}}]),n}(ci),Yi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,70),Z(X(e),`incompatibleTokens`,[`a`,`b`,`h`,`H`,`K`,`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`k`:return pi(ui.hour24h,e);case`ko`:return n.ordinalNumber(e,{unit:`hour`});default:return gi(t.length,e)}}},{key:`validate`,value:function(e,t){return t>=1&&t<=24}},{key:`set`,value:function(e,t,n){var r=n<=24?n%24:n;return e.setUTCHours(r,0,0,0),e}}]),n}(ci),Xi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,60),Z(X(e),`incompatibleTokens`,[`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`m`:return pi(ui.minute,e);case`mo`:return n.ordinalNumber(e,{unit:`minute`});default:return gi(t.length,e)}}},{key:`validate`,value:function(e,t){return t>=0&&t<=59}},{key:`set`,value:function(e,t,n){return e.setUTCMinutes(n,0,0),e}}]),n}(ci),Zi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,50),Z(X(e),`incompatibleTokens`,[`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t,n){switch(t){case`s`:return pi(ui.second,e);case`so`:return n.ordinalNumber(e,{unit:`second`});default:return gi(t.length,e)}}},{key:`validate`,value:function(e,t){return t>=0&&t<=59}},{key:`set`,value:function(e,t,n){return e.setUTCSeconds(n,0),e}}]),n}(ci),Qi=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,30),Z(X(e),`incompatibleTokens`,[`t`,`T`]),e}return ri(n,[{key:`parse`,value:function(e,t){return fi(gi(t.length,e),function(e){return Math.floor(e*10**(-t.length+3))})}},{key:`set`,value:function(e,t,n){return e.setUTCMilliseconds(n),e}}]),n}(ci),$i=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,10),Z(X(e),`incompatibleTokens`,[`t`,`T`,`x`]),e}return ri(n,[{key:`parse`,value:function(e,t){switch(t){case`X`:return mi(di.basicOptionalMinutes,e);case`XX`:return mi(di.basic,e);case`XXXX`:return mi(di.basicOptionalSeconds,e);case`XXXXX`:return mi(di.extendedOptionalSeconds,e);default:return mi(di.extended,e)}}},{key:`set`,value:function(e,t,n){return t.timestampIsSet?e:new Date(e.getTime()-n)}}]),n}(ci),ea=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,10),Z(X(e),`incompatibleTokens`,[`t`,`T`,`X`]),e}return ri(n,[{key:`parse`,value:function(e,t){switch(t){case`x`:return mi(di.basicOptionalMinutes,e);case`xx`:return mi(di.basic,e);case`xxxx`:return mi(di.basicOptionalSeconds,e);case`xxxxx`:return mi(di.extendedOptionalSeconds,e);default:return mi(di.extended,e)}}},{key:`set`,value:function(e,t,n){return t.timestampIsSet?e:new Date(e.getTime()-n)}}]),n}(ci),ta=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,40),Z(X(e),`incompatibleTokens`,`*`),e}return ri(n,[{key:`parse`,value:function(e){return hi(e)}},{key:`set`,value:function(e,t,n){return[new Date(n*1e3),{timestampIsSet:!0}]}}]),n}(ci),na=function(e){Jr(n,e);var t=Qr(n);function n(){var e;$r(this,n);var r=[...arguments];return e=t.call.apply(t,[this].concat(r)),Z(X(e),`priority`,20),Z(X(e),`incompatibleTokens`,`*`),e}return ri(n,[{key:`parse`,value:function(e){return hi(e)}},{key:`set`,value:function(e,t,n){return[new Date(n),{timestampIsSet:!0}]}}]),n}(ci),ra={G:new li,y:new xi,Y:new Si,R:new Ci,u:new wi,Q:new Ti,q:new Ei,M:new Di,L:new Oi,w:new Ai,I:new Mi,d:new Fi,D:new Ii,E:new Ri,e:new zi,c:new Bi,i:new Hi,a:new Ui,b:new Wi,B:new Gi,h:new Ki,H:new qi,K:new Ji,k:new Yi,m:new Xi,s:new Zi,S:new Qi,X:new $i,x:new ea,t:new ta,T:new na},ia=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,aa=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,oa=/^'([^]*?)'?$/,sa=/''/g,ca=/\S/,la=/[a-zA-Z]/;function ua(e,t,n,r){var i,a;en(3,arguments);var o=String(e),s=String(t),c=sn(),l=r?.locale??c.locale??dn;
3if(!l.match)throw RangeError(`locale must contain match property`);var u=vn(r?.firstWeekContainsDate??(r==null||(i=r.locale)==null?void 0:i.options?.firstWeekContainsDate)??c.firstWeekContainsDate??c.locale?.options?.firstWeekContainsDate??1);if(!(u>=1&&u<=7))throw RangeError(`firstWeekContainsDate must be between 1 and 7 inclusively`);var d=vn(r?.weekStartsOn??(r==null||(a=r.locale)==null?void 0:a.options?.weekStartsOn)??c.weekStartsOn??c.locale?.options?.weekStartsOn??0);if(!(d>=0&&d<=6))throw RangeError(`weekStartsOn must be between 0 and 6 inclusively`);if(s===``)return o===``?on(n):new Date(NaN);var f={firstWeekContainsDate:u,weekStartsOn:d,locale:l},p=[new si],m=s.match(aa).map(function(e){var t=e[0];if(t in fn){var n=fn[t];return n(e,l.formatLong)}return e}).join(``).match(ia),h=[],g=Kr(m),_;try{var v=function(){var t=_.value;!(r!=null&&r.useAdditionalWeekYearTokens)&&cn(t)&&tn(t,s,e),!(r!=null&&r.useAdditionalDayOfYearTokens)&&mn(t)&&tn(t,s,e);var n=t[0],i=ra[n];if(i){var a=i.incompatibleTokens;if(Array.isArray(a)){var c=h.find(function(e){return a.includes(e.token)||e.token===n});if(c)throw RangeError(`The format string mustn't contain \`${c.fullToken}\` and \`${t}\` at the same time`)}else if(i.incompatibleTokens===`*`&&h.length>0)throw RangeError(`The format string mustn't contain \`${t}\` and any other token at the same time`);h.push({token:n,fullToken:t});var u=i.run(o,t,l.match,f);if(!u)return{v:new Date(NaN)};p.push(u.setter),o=u.rest}else{if(n.match(la))throw RangeError("Format string contains an unescaped latin alphabet character `"+n+"`");if(t===`''`?t=`'`:n===`'`&&(t=da(t)),o.indexOf(t)===0)o=o.slice(t.length);else return{v:new Date(NaN)}}};for(g.s();!(_=g.n()).done;){var y=v();if(yn(y)===`object`)return y.v}}catch(e){g.e(e)}finally{g.f()}if(o.length>0&&ca.test(o))return new Date(NaN);var b=p.map(function(e){return e.priority}).sort(function(e,t){return t-e}).filter(function(e,t,n){return n.indexOf(e)===t}).map(function(e){return p.filter(function(t){return t.priority===e}).sort(function(e,t){return t.subPriority-e.subPriority})}).map(function(e){return e[0]}),x=on(n);if(isNaN(x.getTime()))return new Date(NaN);var S=an(x,un(x)),C={},w=Kr(b),T;try{for(w.s();!(T=w.n()).done;){var E=T.value;if(!E.validate(S,f))return new Date(NaN);var D=E.set(S,C,f);Array.isArray(D)?(S=D[0],Ur(C,D[1])):S=D}}catch(e){w.e(e)}finally{w.f()}return S}function da(e){return e.match(oa)[1].replace(sa,`'`)}var fa=function(e){return e.TokenPurchase=`Token Purchase`,e}({}),Q=e(n(),1),$=Lt(),pa=()=>(0,$.jsxs)(`div`,{className:`lg:hidden flex flex-col gap-6 pb-24`,"aria-hidden":`true`,children:[(0,$.jsxs)(`div`,{className:`relative h-[60vh] supports-[height:100dvh]:h-[60dvh] max-h-[480px] min-h-[280px] w-full overflow-hidden`,children:[(0,$.jsx)(Xn,{className:`absolute inset-0 rounded-none`}),(0,$.jsxs)(`div`,{className:`absolute top-3 left-3 right-3 flex justify-between`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-full bg-white/80 dark:bg-lofty-purple-700/70`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-full bg-white/80 dark:bg-lofty-purple-700/70`}),(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-full bg-white/80 dark:bg-lofty-purple-700/70`}),(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-full bg-white/80 dark:bg-lofty-purple-700/70`})]})]})]}),(0,$.jsxs)(`div`,{className:`px-4 flex flex-col gap-3`,children:[(0,$.jsx)(Xn,{className:`h-7 w-3/4`}),(0,$.jsx)(Xn,{className:`h-4 w-1/2`}),(0,$.jsxs)(`div`,{className:`flex gap-2 mt-2`,children:[(0,$.jsx)(Xn,{className:`h-7 w-20 rounded-full`}),(0,$.jsx)(Xn,{className:`h-7 w-24 rounded-full`}),(0,$.jsx)(Xn,{className:`h-7 w-16 rounded-full`})]})]}),(0,$.jsx)(`div`,{className:`px-4`,children:(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 p-4 flex flex-col gap-3 shadow-sm dark:shadow-none`,children:[(0,$.jsx)(Xn,{className:`h-3 w-24`}),(0,$.jsx)(Xn,{className:`h-9 w-40`}),(0,$.jsx)(Xn,{className:`h-3 w-32`}),(0,$.jsx)(Xn,{className:`h-[200px] w-full mt-2`}),(0,$.jsx)(`div`,{className:`flex gap-2 mt-2`,children:[`1D`,`7D`,`30D`,`90D`,`1Y`].map(e=>(0,$.jsx)(Xn,{className:`h-7 w-12 rounded-full`},e))})]})}),(0,$.jsx)(`div`,{className:`px-4`,children:(0,$.jsx)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 p-4 grid grid-cols-2 gap-x-4 gap-y-5 shadow-sm dark:shadow-none`,children:Array.from({length:8}).map((e,t)=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(Xn,{className:`h-2.5 w-16`}),(0,$.jsx)(Xn,{className:`h-5 w-24`})]},t))})}),Array.from({length:4}).map((e,t)=>(0,$.jsx)(`div`,{className:`px-4`,children:(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 p-5 flex flex-col gap-3 shadow-sm dark:shadow-none`,children:[(0,$.jsx)(Xn,{className:`h-5 w-40`}),(0,$.jsx)(Xn,{className:`h-3 w-full`}),(0,$.jsx)(Xn,{className:`h-3 w-5/6`}),(0,$.jsx)(Xn,{className:`h-3 w-3/4`})]})},t))]}),ma=()=>(0,$.jsxs)(`div`,{className:`hidden lg:block pb-20`,"aria-hidden":`true`,children:[(0,$.jsx)(`section`,{className:`w-full mx-auto max-w-1600-px pt-6`,children:(0,$.jsx)(`div`,{className:`px-14 xl:px-20 2xl:px-40`,children:(0,$.jsx)(Xn,{className:`h-[420px] w-full rounded-2xl`})})}),(0,$.jsx)(`section`,{className:`flex w-full mt-8`,children:(0,$.jsxs)(`div`,{className:`flex w-full gap-10 p-0 mx-auto my-0 max-w-1600-px px-14 xl:px-20 2xl:px-40`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 flex flex-col gap-5`,children:[(0,$.jsx)(Xn,{className:`h-8 w-2/3`}),(0,$.jsx)(Xn,{className:`h-4 w-1/3`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Xn,{className:`h-7 w-20 rounded-full`}),(0,$.jsx)(Xn,{className:`h-7 w-24 rounded-full`}),(0,$.jsx)(Xn,{className:`h-7 w-16 rounded-full`})]}),Array.from({length:3}).map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 p-6 flex flex-col gap-3`,children:[(0,$.jsx)(Xn,{className:`h-5 w-40`}),(0,$.jsx)(Xn,{className:`h-3 w-full`}),(0,$.jsx)(Xn,{className:`h-3 w-5/6`}),(0,$.jsx)(Xn,{className:`h-3 w-2/3`})]},t))]}),(0,$.jsx)(`div`,{className:`w-[380px] shrink-0`,children:(0,$.jsxs)(`div`,{className:`rounded-2xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 p-6 flex flex-col gap-4`,children:[(0,$.jsx)(Xn,{className:`h-3 w-24`}),(0,$.jsx)(Xn,{className:`h-10 w-40`}),(0,$.jsx)(Xn,{className:`h-12 w-full rounded-xl`}),(0,$.jsx)(Xn,{className:`h-12 w-full rounded-xl`})]})})]})})]}),ha=()=>(0,$.jsxs)(`div`,{className:`bg-white dark:bg-lofty-purple-800 min-h-screen`,children:[(0,$.jsx)(`span`,{className:`sr-only`,role:`status`,children:`Loading property`}),(0,$.jsx)(kr,{mobilePropertyOverlay:!0}),(0,$.jsx)(pa,{}),(0,$.jsx)(ma,{})]}),ga=e(t(((e,t)=>{(function(e,n){e||={},typeof define==`function`&&define.amd?define([],function(){return e.Swipe=n(),e.Swipe}):typeof t==`object`&&t.exports?t.exports=n():e.Swipe=n()})(e,function(){var e=typeof self==`object`&&self.self===self&&self||typeof globalThis==`object`&&globalThis.global===globalThis&&globalThis||this,t=e.document;function n(n,r){r||={};var i={},a={},o,s=r.auto||0,c,l=!1,u=function(){},d=function(e){setTimeout(e||u,0)},f=function(e,t){t||=100;var n=null;function r(){n&&clearTimeout(n)}function i(){var i=this,a=arguments;r(),n=setTimeout(function(){n=null,e.apply(i,a)},t)}return i.cancel=r,i},p=function(e){return e?typeof e.cancelable!=`boolean`||e.cancelable:!1};Element.prototype.matches||(Element.prototype.matches=Element.prototype.matchesSelector||Element.prototype.mozMatchesSelector||Element.prototype.msMatchesSelector||Element.prototype.oMatchesSelector||Element.prototype.webkitMatchesSelector||function(e){for(var t=(this.document||this.ownerDocument).querySelectorAll(e),n=t.length;--n>=0&&t.item(n)!==this;);return n>-1});var m={addEventListener:!!e.addEventListener,passiveEvents:(function(){var t=!1;try{var n=Object.defineProperty({},"passive",{get:function(){t=!0}});e.addEventListener(`testEvent`,null,n),e.removeEventListener(`testEvent`,null,n)}catch{t=!1}return t})(),touch:`ontouchstart`in e||e.DocumentTouch&&t instanceof DocumentTouch,transitions:(function(e){var t=[`transitionProperty`,`WebkitTransition`,`MozTransition`,`OTransition`,`msTransition`];for(var n in t)if(e.style[t[n]]!==void 0)return!0;return!1})(t.createElement(`swipe`))};if(!n)return;var h=n.children[0],g,_,v,y,b=parseInt(r.startSlide,10)||0,x=r.speed||300;r.continuous=r.continuous===void 0||r.continuous;var S=(function(t,n,r){return t.currentStyle?r=t.currentStyle[n]:e.getComputedStyle&&(r=e.getComputedStyle(t,null).getPropertyValue(n)),r
3===`rtl`?`right`:`left`})(n,`direction`);r.autoRestart=r.autoRestart!==void 0&&r.autoRestart;var C=f(ee),w={handleEvent:function(e){if(!(l&&e.type!==`resize`)){switch(e.type){case`mousedown`:case`touchstart`:this.start(e);break;case`mousemove`:case`touchmove`:this.move(e);break;case`mouseup`:case`mouseleave`:case`touchend`:this.end(e);break;case`webkitTransitionEnd`:case`msTransitionEnd`:case`oTransitionEnd`:case`otransitionend`:case`transitionend`:this.transitionEnd(e);break;case`resize`:C();break}r.stopPropagation&&e.stopPropagation()}},start:function(e){var t=de(e)?e:e.touches[0];r.ignore&&t.target.matches(r.ignore)||(de(e)&&e.preventDefault(),i={x:t.pageX,y:t.pageY,time:+new Date},o=void 0,a={},de(e)?(h.addEventListener(`mousemove`,this,!1),h.addEventListener(`mouseup`,this,!1),h.addEventListener(`mouseleave`,this,!1)):(h.addEventListener(`touchmove`,this,m.passiveEvents?{passive:!1}:!1),h.addEventListener(`touchend`,this,!1)),te(re(),g[b]))},move:function(e){var t;if(de(e))t=e;else{if(e.touches.length>1||e.scale&&e.scale!==1)return;r.disableScroll&&p(e)&&e.preventDefault(),t=e.touches[0]}a={x:t.pageX-i.x,y:t.pageY-i.y},o===void 0&&(o=!!(o||Math.abs(a.x)<Math.abs(a.y))),o||(p(e)&&e.preventDefault(),se(),r.continuous?(ie(M(b-1),a.x+_[M(b-1)],0),ie(b,a.x+_[b],0),ie(M(b+1),a.x+_[M(b+1)],0)):(a.x/=!b&&a.x>0||b===g.length-1&&a.x<0?Math.abs(a.x)/v+1:1,ie(b-1,a.x+_[b-1],0),ie(b,a.x+_[b],0),ie(b+1,a.x+_[b+1],0)))},end:function(e){var t=+new Date-i.time,n=Number(t)<250&&Math.abs(a.x)>20||Math.abs(a.x)>v/2,s=!b&&a.x>0||b===g.length-1&&a.x<0;r.continuous&&(s=!1);var c=Math.abs(a.x)/a.x;o||(n&&!s?(c<0?(r.continuous?(P(M(b-1),-v,0),P(M(b+2),v,0)):P(b-1,-v,0),P(b,_[b]-v,x),P(M(b+1),_[M(b+1)]-v,x),b=M(b+1)):(r.continuous?(P(M(b+1),v,0),P(M(b-2),-v,0)):P(b+1,v,0),P(b,_[b]+v,x),P(M(b-1),_[M(b-1)]+v,x),b=M(b-1)),A(re(),g[b],c)):r.continuous?(P(M(b-1),-v,x),P(b,0,x),P(M(b
3+1),v,x)):(P(b-1,-v,x),P(b,0,x),P(b+1,v,x))),de(e)?(h.removeEventListener(`mousemove`,w,!1),h.removeEventListener(`mouseup`,w,!1),h.removeEventListener(`mouseleave`,w,!1)):(h.removeEventListener(`touchmove`,w,m.passiveEvents?{passive:!1}:!1),h.removeEventListener(`touchend`,w,!1)),ne(re(),g[b])},transitionEnd:function(e){parseInt(e.target.getAttribute(`data-index`),10)===b&&((s||r.autoRestart)&&ce(),j(re(),g[b]))}};return ee(),oe(),{setup:ee,slide:function(e,t){se(),N(e,t)},prev:function(){se(),O()},next:function(){se(),k()},restart:ce,stop:se,getPos:re,disable:le,enable:ue,getNumSlides:function(){return y},kill:fe};function T(){m.addEventListener?(h.removeEventListener(`touchstart`,w,m.passiveEvents?{passive:!0}:!1),h.removeEventListener(`mousedown`,w,!1),h.removeEventListener(`webkitTransitionEnd`,w,!1),h.removeEventListener(`msTransitionEnd`,w,!1),h.removeEventListener(`oTransitionEnd`,w,!1),h.removeEventListener(`otransitionend`,w,!1),h.removeEventListener(`transitionend`,w,!1),e.removeEventListener(`resize`,w,!1)):e.onresize=null}function E(){m.addEventListener?(m.touch&&h.addEventListener(`touchstart`,w,m.passiveEvents?{passive:!0}:!1),r.draggable&&h.addEventListener(`mousedown`,w,!1),m.transitions&&(h.addEventListener(`webkitTransitionEnd`,w,!1),h.addEventListener(`msTransitionEnd`,w,!1),h.addEventListener(`oTransitionEnd`,w,!1),h.addEventListener(`otransitionend`,w,!1),h.addEventListener(`transitionend`,w,!1)),e.addEventListener(`resize`,w,!1)):e.onresize=C}function D(e){var t=e.cloneNode(!0);h.appendChild(t),t.setAttribute(`data-cloned`,!0),t.removeAttribute(`id`)}function ee(e){if(e!=null)for(var t in e)r[t]=e[t];g=h.children,y=g.length;for(var i=0;i<g.length;i++)g[i].getAttribute(`data-cloned`)&&y--;if(g.length<2&&(r.continuous=!1),m.transitions&&r.continuous&&g.length<3&&(D(g[0]),D(g[1]),g=h.children),S===`right`)for(var a=0;a<g.length;a++)g[a].style.float=`right`;_=Array(g.length),v=n.getBoundingClientRect().width||n.offsetWidth,h.style.width=g.length*v*2+`px`;for(var o=g.length;o--;){var s=g[o];s.style.width=v+`px`,s.setAttribute(`data-index`,o),m.transitions&&(s.style[S]=o*-v+`px`,P(o,b>o?-v:b<o?v:0,0))}r.continuous&&m.transitions&&(P(M(b-1),-v,0),P(M(b+1),v,0)),m.transitions||(h.style[S]=b*-v+`px`),n.style.visibility=`visible`,T(),E()}function O(){l||(r.continuous||b)&&N(b-1)}function k(){l||(r.continuous||b<g.length-1)&&N(b+1)}function A(e,t,n){r.callback&&r.callback(e,t,n)}function j(e,t){r.transitionEnd&&r.transitionEnd(e,t)}function te(e,t){r.dragStart&&r.dragStart(e,t)}function ne(e,t){r.dragEnd&&r.dragEnd(e,t)}function M(e){return(g.length+e%g.length)%g.length}function re(){var e=b;return e>=y&&(e-=y),e}function N(e,t){if(e=typeof e==`number`?e:parseInt(e,10),b!==e){if(m.transitions){var n=Math.abs(b-e)/(b-e);if(r.continuous){var i=n;n=-_[M(e)]/v,n!==i&&(e=-n*g.length+e)}for(var a=Math.abs(b-e)-1;a--;)P(M((e>b?e:b)-a-1),v*n,0);e=M(e),P(b,v*n,t||x),P(e,0,t||x),r.continuous&&P(M(e-n),-(v*n),0)}else e=M(e),ae(b*-v,e*-v,t||x);b=e,d(function(){A(re(),g[b],n)})}}function P(e,t,n){ie(e,t,n),_[e]=t}function ie(e,t,n){var r=g[e],i=r&&r.style;i&&(i.webkitTransitionDuration=i.MozTransitionDuration=i.msTransitionDuration=i.OTransitionDuration=i.transitionDuration=n+`ms`,i.webkitTransform=i.msTransform=i.MozTransform=i.OTransform=i.transform=`translateX(`+t+`px)`)}function ae(e,t,n){if(!n){h.style[S]=t+`px`;return}var i=+new Date,a=setInterval(function(){var o=+new Date-i;if(o>n){h.style[S]=t+`px`,(s||r.autoRestart)&&ce(),j(re(),g[b]),clearInterval(a);return}h.style[S]=(t-e)*(Math.floor(o/n*100)/100)+e+`px`},4)}function oe(){s=r.auto||0,s&&(c=setTimeout(k,s))}function se(){s=0,clearTimeout(c)}function ce(){se(),oe()}function le(){se(),l=!0}function ue(){l=!1,ce()}function de(e){return/^mouse/.test(e.type)}function fe(){se(),n.style.visibility=``,h.style.width=``,h.style[S]=``;for(var e=g.length;e--;){m.transitions&&ie(e,0,0);var t=g[e];t.getAttribute(`data-cloned`)&&t.parentElement.removeChild(t),t.style.width=``,t.style[S]=``,t.style.webkitTransitionDuration=t.style.MozTransitionDuration=t.style.msTransitionDuration=t.style.OTransitionDuration=t.style.transitionDuration=``,t.style.webkitTransform=t.style.msTransform=t.style.MozTransform=t.style.OTransform=``}T(),C.cancel()}}return(e.jQuery||e.Zepto)&&(function(e){e.fn.Swipe=function(t){return this.each(function(){e(this).data(`Swipe`,new n(e(this)[0],t))})}})(e.jQuery||e.Zepto),n})}))(),1);function _a({images:e,fallbackImage:t,startSlide:n=0}){let r=(0,Q.useRef)(null),i=(0,Q.useRef)(null),[a,o]=(0,Q.useState)(n+1),s=C({targetKey:`ArrowLeft`,preventDefault:!0,stopPropagation:!0}),c=C({targetKey:`ArrowRight`,preventDefault:!0,stopPropagation:!0});(0,Q.useLayoutEffect)(()=>
3(r.current&&(i.current=new ga.default(r.current,{startSlide:n,auto:0,draggable:!0,continuous:!0,disableScroll:!0,stopPropagation:!0,ignore:`.scroller`,transitionEnd:e=>o(e+1)})),()=>{i.current?.kill(),i.current=null}),[e]),(0,Q.useEffect)(()=>{i.current&&i.current.restart()},[i.current,e]),(0,Q.useEffect)(()=>{s&&s&&l()},[s]),(0,Q.useEffect)(()=>{c&&c&&u()},[c]);let l=()=>i.current?.prev(),u=()=>i.current?.next();return(0,$.jsxs)(`div`,{className:`h-full w-full flex items-center`,children:[(0,$.jsx)(`div`,{id:`property-images-slider`,ref:r,className:`swipe lightbox w-full`,children:(0,$.jsxs)(`div`,{className:`swipe-wrap w-full h-full`,children:[e.map(({url:e,id:t})=>(0,$.jsx)(`div`,{className:`slider-image flex items-center justify-center sm:px-16 h-full w-full`,children:(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,children:(0,$.jsx)(`img`,{src:e,alt:``,className:`max-h-full max-w-full object-contain`})})},t)),!e.length&&t&&(0,$.jsx)(`div`,{style:{backgroundImage:`url(${t})`},className:`slider-image bg-center bg-no-repeat bg-cover p-0 border border-solid border-neutral-300 h-250-px md:px-4 lg:h-500-px lg:px-4`})]})}),(0,$.jsx)(`div`,{className:`absolute top-0 bottom-0 hidden sm:flex items-center ml-0 left-2`,children:(0,$.jsx)(`button`,{type:`button`,id:`slider-back`,title:`View previous image`,className:`w-12 h-12 overflow-hidden slider-button lightbox cursor-pointer disabled:cursor-default rounded-full flex justify-center items-center whitespace-nowrap select-none p-0.5 transition-all border-2 border-white bg-white/60 hover:bg-white/100 dark:hover:bg-blue-700`,onClick:l,children:(0,$.jsx)(`i`,{className:`fa-regular fa-chevron-left text-themeBlue text-sm dark:text-gray-200`})})}),(0,$.jsx)(`div`,{className:`absolute top-0 bottom-0 hidden sm:flex items-center mr-0 right-2`,children:(0,$.jsx)(`button`,{type:`button`,id:`slider-next`,title:`View next image`,className:`w-12 h-12 overflow-hidden slider-button lightbox cursor-pointer disabled:cursor-default rounded-full flex justify-center items-center whitespace-nowrap select-none p-0.5 transition-all border-2 border-white bg-white/60 hover:bg-white/100 dark:hover:bg-blue-700`,onClick:u,children:(0,$.jsx)(`i`,{className:`fa-regular fa-chevron-right text-themeBlue text-sm dark:text-gray-200`})})}),(0,$.jsx)(`div`,{className:`absolute top-0 bottom-0 sm:hidden flex items-center ml-0 left-2`,children:(0,$.jsx)(`button`,{type:`button`,title:`View previous image`,className:`w-10 h-10 slider-button lightbox cursor-pointer rounded-full flex justify-center items-center bg-white/70`,onClick:l,children:(0,$.jsx)(`i`,{className:`fa-regular fa-chevron-left text-black text-sm`})})}),(0,$.jsx)(`div`,{className:`absolute top-0 bottom-0 sm:hidden flex items-center mr-0 right-2`,children:(0,$.jsx)(`button`,{type:`button`,title:`View next image`,className:`w-10 h-10 slider-button lightbox cursor-pointer rounded-full flex justify-center items-center bg-white/70`,onClick:u,children:(0,$.jsx)(`i`,{className:`fa-regular fa-chevron-right text-black text-sm`})})}),e.length&&(0,$.jsx)(`div`,{className:`absolute left-0 right-0 mx-auto flex items-center justify-center rounded-lg`,style:{bottom:`calc(env(safe-area-inset-bottom, 0px) + 1.5rem)`},children:(0,$.jsxs)(`div`,{className:`rounded-full bg-black/60 px-3 py-1 text-sm font-semibold text-white backdrop-blur-md`,children:[(0,$.jsx)(`span`,{className:`meta-count`,children:a}),` / `,(0,$.jsx)(`span`,{children:e.length})]})})]})}var va=(e,t=!0)=>{let n=t?Math.min(5,e.length):e.length;return e.slice(0,n).map((e,t)=>({id:e.split(`/`).pop()?.split(`.`)[0]??e,url:e,position:t}))};function ya(e){let[t,n]=(0,Q.useState)(1),[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(1),[s,c]=(0,Q.useState)(()=>va(e.images)),l=(0,Q.useRef)(null),u=(0,Q.useRef)(null),d=e.images.join(`
4`),f=(0,Q.useRef)(d),{isLightboxOpen:p,openLightbox:m,closeLightbox:h}=Yt(),g=E(),[_,v]=(0,Q.useState)(!1),y=g.minWidth>=re.md,b=!_||y,x=!_||!y,S=s.map(e=>e.url).join(`
5`),C=(0,Q.useRef)(t);C.current=t;let w=s&&s.length>0,T=Math.min(e.images.length,8),D=Math.min(t-1,T-1),ee=()=>{g.minWidth<=re.md?o(2):g.minWidth<=re.xl?o(3):g.minWidth<=re[`2xl`]&&o(4)},O=(0,Q.useCallback)((t=!0)=>{c(n=>{let r=n.length,i=t?Math.min(r+5,e.images.length):e.images.length,a=va(e.images.slice(r,i),!1).map((e,t)=>({...e,position:r+t}));return a.length>0?[...n,...a]:n})},[e.images]);(0,Q.useLayoutEffect)(()=>
5{if(!x||!l.current)return;let e=l.current.querySelectorAll(`.slider-image`).length;return u.current=new ga.default(l.current,{startSlide:Math.max(0,Math.min(C.current-1,e-1)),auto:0,draggable:!0,continuous:!0,disableScroll:!1,stopPropagation:!1,ignore:`.scroller`,transitionEnd:e=>n(e+1)}),()=>{u.current?.kill(),u.current=null}},[x,S]),(0,Q.useEffect)(()=>{v(!0)},[]),(0,Q.useEffect)(()=>{t>1&&O(!1)},[t,O]),(0,Q.useEffect)(()=>{f.current!==d&&(f.current=d,n(1),i(0),c(va(e.images))),ee()},[d,e.images]);let k=()=>{O(!1),m()},A=e=>{O(!1),i(e),m()},j=()=>{i(0),h()};return(0,$.jsxs)(`section`,{id:`hero-image`,className:`relative w-full mx-auto my-0 block max-w-1600-px`,children:[w&&(0,$.jsx)(qt,{id:`property-gallery-ligthbox`,isOpen:p,onBackdropClick:j,onRequestClose:j,children:(0,$.jsx)(_a,{images:s,fallbackImage:e.fallbackImage,startSlide:r})}),b&&(0,$.jsx)(`div`,{className:`hidden md:block`,children:(0,$.jsxs)(`div`,{className:`flex relative justify-center max-h-50-vh min-h-400-px overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`flex`,children:s?s.slice(0,a).map(({url:e,id:t,position:n})=>(0,$.jsx)(`div`,{onClick:()=>A(n),className:`max-h-50-vh min-h-400-px w-full transition duration-300 ease-out hover:cursor-pointer hover:brightness-90`,children:(0,$.jsxs)(`picture`,{children:[(0,$.jsx)(`source`,{type:`image/webp`,srcSet:`${e} 1024w`,sizes:`(max-width:1024px) 100vw, 1024px`}),(0,$.jsx)(`source`,{type:`image/jpeg`,srcSet:`${e.replace(`webp`,`jpg`)} 1024w`}),(0,$.jsx)(`img`,{src:e.replace(`webp`,`jpg`),alt:``,className:`w-full h-full object-cover`})]})},t+n)):(0,$.jsx)(Xn,{})}),(0,$.jsx)(`div`,{className:`max-w-1140-px w-full absolute mx-auto right-0 left-0 top-4 flex justify-end pointer-events-none`,children:w&&(0,$.jsxs)(`button`,{onClick:k,className:`pointer-events-auto flex justify-center items-center font-semibold py-3 px-5 rounded-md shadow-lg cursor-pointer active:scale-95 bg-white`,children:[(0,$.jsx)(`i`,{className:`fas fa-image mr-2 text-sm text-lofty-purple-600 opacity-50`}),(0,$.jsx)(`span`,{className:`text-black`,children:`View all photos`})]})})]})}),x&&(0,$.jsxs)(`div`,{className:`block md:hidden relative`,children:[(0,$.jsx)(`div`,{onClick:k,id:`property-images-slider`,ref:l,className:`swipe touch-pan-y`,children:(0,$.jsxs)(`div`,{className:`swipe-wrap`,children:[s.map(({id:e,position:t,url:n},r)=>(0,$.jsx)(`div`,{className:`slider-image flex aspect-[4/3] items-center justify-center bg-center bg-no-repeat bg-cover p-0`,children:(0,$.jsxs)(`picture`,{className:`block h-full w-full`,children:[(0,$.jsx)(`source`,{type:`image/webp`,srcSet:`${n} 1024w`,sizes:`100vw`}),(0,$.jsx)(`source`,{type:`image/jpeg`,srcSet:`${n.replace(`webp`,`jpg`)} 1024w`}),(0,$.jsx)(`img`,{src:n.replace(`webp`,`jpg`),alt:``,className:`w-full h-full object-cover`,loading:r===0?`eager`:`lazy`,fetchPriority:r===0?`high`:`auto`})]})},`${e}-${t}`)),!s.length&&e.fallbackImage&&(0,$.jsx)(`div`,{style:{backgroundImage:`url(${e.fallbackImage})`},className:`slider-image aspect-[4/3] bg-center bg-no-repeat bg-cover p-0 border border-solid border-neutral-300`})]})}),(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`absolute bottom-0 left-0 right-0 h-20 bg-gradient-to-t from-black/45 to-transparent pointer-events-none`}),e.images.length>1&&(0,$.jsx)(`div`,{className:`absolute bottom-4 left-0 right-0 flex justify-center gap-1.5 pointer-events-none`,children:Array.from({length:T}).map((e,t)=>{let n=t===D;return(0,$.jsx)(`span`,{"aria-current":n?`true`:void 0,className:[`block rounded-full transition-all duration-200`,n?`w-2 h-2 bg-white`:`w-1.5 h-1.5 bg-white/55`].join(` `)},t)})}),e.images.length>0&&(0,$.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),k()},className:`absolute bottom-3 right-3 min-h-11 touch-manipulation inline-flex items-center gap-1.5 rounded-full bg-black/55 px-3 py-1.5 text-xs font-semibold text-white backdrop-blur-md active:scale-95 transition-transform`,children:[(0,$.jsx)(`i`,{className:`fas fa-images text-[11px]`}),`View all `,e.images.length,` photos`]})]})]})}var ba=e(r(),1),xa=()=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`h-8 mb-2 bg-blue-200 dark:bg-blue-900 rounded w-full`}),(0,$.jsx)(`div`,{className:`h-8 mb-2 bg-blue-200 dark:bg-blue-900 rounded w-full`}),(0,$.jsx)(`div`,{className:`h-8 mb-2 bg-blue-200 dark:bg-blue-900 rounded w-full`})]}),Sa=()=>(0,$.jsx)(`div`,{className:`h-70-px mb-0 bg-blue-200 dark:bg-blue-900 rounded-3xl 2xl:rounded-[32px] w-full`}),Ca=({row:e=(0,$.jsx)(xa,{}),className:t=`w-full mx-0 mb-4`})=>(0,$.jsx)(`div`,{className:t,children:(0,$.jsx)(`div`,{className:`animate-pulse flex`,children:(0,$.jsx)(`div`,{className:`flex flex-1 flex-col`,children:e})})}),wa={card:`text-sm font-semibold text-themeBlue-800 flex justify-center bg-white dark:bg-blue-300 dark:text-gray-900`},Ta=({to:e,type:t=`card`,callback:n})=>{let{countDown:r,locales:i,units:a}=x(e,n);return r.diff<=0?null:(0,$.jsxs)(`div`,{className:`flex gap-x-2 items-center justify-center`,children:[(0,$.jsx)(`span`,{className:`text-sm`,children:`Starts in `}),(0,$.jsx)(`div`,{className:wa[t],children:a.map((e,t)=>r.significance.includes(e)?(0,$.jsx)(`span`,{className:`mr-1`,children:(e===`sec`||r[e]>0)&&`${r[e]}${i[t]}`},e):null)})]})},Ea=({totalTokens:e,soldPct:t,numSold:n,isComingSoon:r,isSellbackComingSoon:i})=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`rounded bg-lofty-gray-100/25 dark:bg-lofty-purple-600/25 h-1.5`,title:`${n.toLocaleStr
5ing()} sold of ${e.toLocaleString()} total shares`,children:(0,$.jsx)(`div`,{style:{width:`${t}%`},className:`h-full rounded bg-lofty`})}),(0,$.jsxs)(`div`,{className:`flex justify-between pt-1 xl:pt-2 text-xs sm:text-base lg:text-sm xl:text-base`,children:[(!r||i)&&(0,$.jsxs)(`span`,{className:`flex-1 text-left text-lofty`,children:[Math.floor(t??0).toFixed(0),`%`]}),(0,$.jsxs)(`span`,{className:`flex-1 text-right text-lofty-purple-600 opacity-60`,children:[(e-n).toLocaleString(),` `,r&&!i?`total shares`:`shares left`]})]})]}),Da=(e,t={})=>{let{enabled:n=!0,initialData:r,refetchIntervalMs:i,deps:a=[]}=t,[o,s]=(0,Q.useState)(r),[c,l]=(0,Q.useState)(null),[u,d]=(0,Q.useState)(n&&r===void 0),[f,p]=(0,Q.useState)(r!==void 0),m=(0,Q.useRef)(e);m.current=e;let h=(0,Q.useRef)(0),g=async()=>{let e=++h.current;d(!0);try{let t=await m.current();return e===h.current?(s(t),l(null),p(!0),t):void 0}catch(t){if(e!==h.current)return;let n=t instanceof Error?t:Error(String(t));l(n),p(!0);return}finally{e===h.current&&d(!1)}};return(0,Q.useEffect)(()=>{n&&g()},[n,...a]),(0,Q.useEffect)(()=>{if(!n||i==null)return;let e=!1,t,r=n=>{let a=typeof i==`function`?i(n):i;a===!1||a<=0||(t=setTimeout(async()=>{if(e)return;let t=await g();e||r(t??n)},a))};return r(o),()=>{e=!0,t&&clearTimeout(t)}},[n,i]),{data:o,error:c,isLoading:u,isFetched:f,refetch:g}},Oa=({label:e,tooltip:t,className:n=``})=>t?(0,$.jsxs)(Sr,{className:`inline-flex items-center gap-1 cursor-pointer`,placement:`auto`,content:(0,$.jsx)(`span`,{className:`block max-w-[260px]`,children:t}),children:[(0,$.jsx)(`span`,{className:n,children:e}),(0,$.jsx)(`i`,{className:`far fa-circle-question text-[11px] text-lofty-purple/40`})]}):(0,$.jsx)(`span`,{className:n,children:e}),ka=({label:e,value:t,tooltip:n})=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-3`,children:[(0,$.jsx)(Oa,{label:e,tooltip:n,className:`text-[13px] text-lofty-purple-600/75`}),(0,$.jsx)(`span`,{className:`text-[15px] font-semibold text-lofty-purple-500 tabular-nums`,children:t})]}),Aa=({children:e,onClick:t,disabled:n,variant:r=`primary`,compact:i=!1})=>(0,$.jsx)(`button`,{type:`button`,disabled:n,onClick:t,className:[`flex-1 font-semibold transition-all duration-200 disabled:cursor-not-allowed`,i?`rounded-xl px-5 py-2.5 text-sm`:`rounded-[14px] px-5 py-3.5 text-[15px]`,r===`primary`?`bg-lofty text-white shadow-[0_2px_12px_rgba(77,63,237,0.3)] hover:bg-lofty-purple hover:shadow-[0_4px_20px_rgba(77,63,237,0.4)] active:scale-[0.98] disabled:bg-lofty-gray dark:disabled:bg-lofty-purple-700 disabled:text-lofty-gray-500 disabled:shadow-none`:`border border-lofty/60 bg-white text-lofty hover:border-lofty hover:bg-lofty-purple-50 active:scale-[0.98] disabled:border-lofty-purple/30 disabled:bg-white disabled:text-lofty-purple-600/40`].join(` `),children:e}),ja=({listing:e,price:t,currentPropertyInfo:n,numSold:r,soldPct:i,quantityOwned:a,lpStakedShares:o=0,startingDate:s,displayConfig:c,onBuyClick:l,onSellClick:u,onTimerEnd:d,averageHistoricalYield:f})=>{let{isPropertyUpcoming:p=!1,isPropertyPrimarySale:m,isStickied:h=!1,isSellbackComingSoon:g,interactive:_,isRedirect:v}=c,y=N(),b=rt[e.id],x=!!e.isTimeShare,S=se(e,t,n?.lastPrice),C=b&&!S.hasSecondaryMin?b.year1.coc:n?.coc,w=dr(e),T=h&&w.hiddenBuy&&w.hiddenSell,E=Da(async()=>(await Tt(e.id)).data,{enabled:!!e?.id,deps:[e.id]}).data,D=Da(async()=>fr({queryKey:[`propertyOraclePrice`,{id:e.id}]}),{enabled:!!e?.id,deps:[e.id]}).data?.pricePerToken?.mid??0,ee=E?.numIssued??e.numIssued??e.tokens??0,O=E?.bestAsk??E?.lastPrice??n?.lastPrice??t??0,k=ee>0&&O>0?ee*O:null,A=D>0&&ee>0?D*ee:null,j=`text-yellow-500 dark:text-yellow-400`;k!=null&&A!=null&&(k<A?j=`text-lofty`:k>A&&(j=`text-red-500 dark:text-red-400`));let te=k!=null&&A!=null&&A>0?Math.abs((k-A)/A*100):0,ne=te<1?W(te,2):W(te,0),M=k!=null&&A!=null&&k===A,re=`Overvalued`;M?re=`Fairly valued`:k!=null&&A!=null&&k<A&&(re=`Undervalued`);let P=k!=null&&A!=null&&(M||te>0),ie=p,ae=p||m,oe=R(H(S.minimumPrice??0,2,!1),{minimumFractionDigits:2}),ce=`Compare with fair value`;P&&(ce=M?re:`${ne}% ${re.toLowerCase()}`);let le=e.totalInvestors!=null&&e.totalInvestors>0;return h?(0,$.jsx)(`div`,{className:[`fixed bottom-0 left-0 right-0 z-30`,`bg-[rgba(252,251,255,0.96)]`,`backdrop-blur-md`,`border-t border-lofty-purple/10`,`shadow-[0_-8px_28px_rgba(5,12,48,0.16)]`,T?`hidden`:``].filter(
5Boolean).join(` `),style:{paddingBottom:`env(safe-area-inset-bottom, 0px)`},children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-1`,children:[(0,$.jsxs)(`span`,{className:`text-lg font-bold text-lofty tabular-nums tracking-tight`,children:[`$`,oe]}),(0,$.jsx)(`span`,{className:`text-xs text-lofty-purple-600/70 font-medium`,children:`/share`})]}),!x&&(0,$.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-lofty-purple-600/70 font-medium`,children:[H(f??0,2,!1),`% avg yield`]}),y&&(0,$.jsx)(`div`,{className:`mt-0.5 text-[11px] font-semibold text-lofty`,children:`Buy $50, get $50 free`})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2 shrink-0`,children:_?(0,$.jsxs)($.Fragment,{children:[!w.hiddenBuy&&(0,$.jsx)(Aa,{disabled:ie,onClick:l,compact:!0,children:`Buy`}),!v&&!w.hiddenSell&&(0,$.jsx)(Aa,{disabled:ae,onClick:u,compact:!0,variant:`secondary`,children:`Sell`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ca,{row:(0,$.jsx)(Sa,{}),className:`mx-0 w-24`}),(0,$.jsx)(Ca,{row:(0,$.jsx)(Sa,{}),className:`mx-0 w-24`})]})})]})}):(0,$.jsxs)(`div`,{className:[`overflow-hidden w-full`,`bg-white`,`rounded-2xl`,`border border-lofty-purple/10`,`shadow-[0_16px_44px_rgba(5,12,48,0.16)]`,`min-w-transactCard max-w-2xl lg:min-w-transactCard lg:max-w-transactCard-2xl`,`xl:min-w-transactCard-2xl 2xl:min-w-transactCard-2xl 2xl:max-w-transactCard-2xl`].filter(
5Boolean).join(` `),children:[(0,$.jsxs)(`div`,{className:`bg-exchange-lightpurple px-6 pt-7 pb-7 border-b border-lofty-purple/10`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsxs)(`div`,{className:`flex items-baseline gap-1`,children:[(0,$.jsxs)(`span`,{className:`text-[42px] font-bold text-lofty tabular-nums tracking-tight leading-none`,children:[`$`,oe]}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-lofty-purple-600/70`,children:`/share`})]})}),le&&(0,$.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1.5 rounded-full bg-lofty-purple-50 px-3 py-1.5 text-xs text-lofty-purple-600`,children:[(0,$.jsx)(`i`,{className:`fas fa-user-group text-[10px] text-lofty`}),(0,$.jsx)(`span`,{className:`font-medium`,children:e.totalInvestors?.toLocaleString()})]})]}),y&&(0,$.jsx)(`p`,{className:`mt-3 text-sm font-semibold text-lofty`,children:`Buy $50, get $50 free`})]}),a>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 bg-lofty-purple-50/60 px-6 py-3 border-b border-lofty-purple/10`,children:[(0,$.jsx)(`i`,{className:`fas fa-wallet text-[11px] text-lofty`}),(0,$.jsx)(`span`,{className:`text-[13px] text-lofty-purple-600/75`,children:`Your position`}),(0,$.jsxs)(`span`,{className:`ml-auto flex flex-col items-end gap-0.5 min-w-0`,children:[(0,$.jsxs)(`span`,{className:`text-[13px] font-semibold text-lofty tabular-nums`,children:[R(a,Nt),` `,a===1?`share`:`shares`]}),o>0&&(0,$.jsxs)(`span`,{className:`text-[11px] text-lofty-purple-600/60 tabular-nums`,children:[R(o,Nt),` staked in liquidity pool`]})]})]}),(m||p)&&(0,$.jsxs)(`div`,{className:`mx-6 mb-4 rounded-xl bg-lofty-purple-50 p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[13px] font-medium text-lofty-purple-500`,children:`Availability`}),(0,$.jsx)(`span`,{className:`text-xs font-medium text-lofty-purple-600/70`,children:p?`Upcoming`:`${W(i,0)}% funded`})]}),(0,$.jsx)(Ea,{totalTokens:e.tokens,soldPct:i,numSold:r,isComingSoon:p,isSellbackComingSoon:g}),s&&p&&(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(Ta,{to:s,callback:d})})]}),(0,$.jsx)(`div`,{className:`mx-6 border-t border-lofty-purple/10`,children:!x&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ka,{label:`Avg Rental Yield`,tooltip:`Average annualized rental yield based on historical exchange yield data.`,value:`${H(f??0,2,!1)}%`}),(0,$.jsx)(`div`,{className:`border-t border-lofty-purple/10`}),(0,$.jsx)(ka,{label:`Current Rental Yield`,tooltip:`The previous month's realized rental yield, annualized.`,value:(0,$.jsxs)(`span`,{children:[C,`%`,!!b&&(0,$.jsx)(`span`,{className:`ml-0.5 text-lofty-gray-500`,children:`*`})]})}),k!=null&&A!=null&&e.slug!==`TalonEdge-DAO_---`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`border-t border-lofty-purple/10`}),(0,$.jsxs)(`div`,{className:`py-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[13px] text-lofty-purple-600/75`,children:`Valuation`}),(0,$.jsx)(`span`,{className:`text-[13px] font-semibold ${j}`,children:ce})]}),(0,$.jsxs)(`p`,{className:`mt-1.5 text-[11px] text-lofty-purple-600/70`,children:[`Market `,z(H(k,0,!1),{minimumFractionDigits:0,maximumFractionDigits:0}),` vs fair value `,z(H(A,0,!1),{minimumFractionDigits:0,maximumFractionDigits:0})]})]})]})]})}),s&&(0,$.jsxs)(`div`,{className:`px-6 pb-6 pt-4`,children:[(0,$.jsx)(`div`,{className:`flex gap-3`,children:_?(0,$.jsxs)($.Fragment,{children:[!w.hiddenBuy&&(0,$.jsx)(Aa,{disabled:ie,onClick:l,children:`Buy`}),!v&&!w.hiddenSell&&(0,$.jsx)(Aa,{disabled:ae,onClick:u,variant:`secondary`,children:`Sell`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ca,{row:(0,$.jsx)(Sa,{}),className:`mx-0 w-full flex-1`}),(0,$.jsx)(Ca,{row:(0,$.jsx)(Sa,{}),className:`mx-0 w-full flex-1`})]})}),!!b&&(0,$.jsxs)(`p`,{className:`mt-4 text-[11px] leading-relaxed text-lofty-purple-600/70`,children:[`* Promotional returns shown for year 1. Starting in year 2, estimated IRR is `,W(b.year2.irr,1),`% and CoC is `,W(b.year2.coc,1),`%.`,` `,(0,$.jsx)(`a`,{href:`https://www.lofty.ai/help/october-2022-incentive`,target:`_blank`,rel:`noreferrer`,className:`underline text-lofty-link hover:text-lofty-purple`,children:`Learn more`})]})]})]})},Ma=e=>(0,$.jsx)(`div`,{className:`bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-200 flex overflow-hidden mx-auto max-w-4xl flex-1`,children:(0,$.jsxs)(`div`,{className:[`flex flex-col items-center`,e.pad?`px-10 py-5 sm:px-6`:``,e.useContainer?``:`overflow-y-scroll`].join(` `),children:[(0,$.jsx)(`h2`,{className:`text-3xl leading-6 font-semibold mb-4`,children:`Notice`}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-sm`,children:[(0,$.jsx)(`p`,{className:`font-semibold text-center mb-2 text-xl`,children:`Due to regulatory constraints, until further notice New York investors are not allowed to purchase any properties listed after February 9th, 2022.`}),e.showHomeLink&&(0,$.jsx)(d,{to:`/account/dashboard`,className:`inline-flex items-center justify-center px-4 py-2 mt-4 border border-transparent shadow-sm text-base font-medium rounded-md !text-white bg-themeBlue-600 hover:bg-themeBlue-700 dark:bg-themeBlue-dark dark:hover:bg-themeBlue-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-themeBlue-500`,children:`Go to Dashboard`})]})]})}),Na={direction:Se.Buy,state:void 0,inProgress:!1,isCommitting:!1,isAwaitingCommit:!1,isCanceling:!1,canceled:!1,isCreating:!1,isDryrunLoading:!1,orderCreated:!1,selectedMarket:Pe.Primary,attemptId:``,isPending:!1,message:``},Pa=he({key:`orderStatus`,default:Na}),Fa=(0,Q.createContext)(null),Ia=()=>Date.now()-B.days(30),La=()=>{let e=(0,Q.useContext)(Fa);if(!e)throw Error(`PropertyContext must be used in a component tree below PropertyContextProvider`);return e},Ra=e=>{let{propertyKey:t,initialProperty:n,initialOraclePrice:r=null,children:i}=e,a=y(Pa),[o,s]=(0,Q.useState)(n),[c,l]=(0,Q.useState)(void 0),[u,d]=(0,Q.useState)(r);(0,Q.useEffect)(()=>{s(n)},[n]),(0,Q.useEffect)(()=>{d(r)},[r]);let f=(0,Q.useCallback)(async()=>{let e=o?.id;if(e)try{let t=await lr({queryKey:[`propertyDealInfo`,{id:e,startTime:Ia()}]});t.lastPrice===null&&o&&(t.lastPrice=pt(o,1)?.totalPricePerToken??0),t.transactions.sort((e,t)=>
5e.updatedAt-t.updatedAt),l(t)}catch(e){console.error(`PropertyContext::refreshCurrentProperty`,e)}},[o]);(0,Q.useEffect)(()=>{let e=o?.id;if(!e||a.inProgress)return;let t=!1,n,r=async()=>{try{let n=await lr({queryKey:[`propertyDealInfo`,{id:e,startTime:Ia()}]});if(t)return;n.lastPrice===null&&o&&(n.lastPrice=pt(o,1)?.totalPricePerToken??0),n.transactions.sort((e,t)=>e.updatedAt-t.updatedAt),l(n)}catch(e){console.error(`PropertyContext::propertyInfo`,e)}finally{t||(n=setTimeout(r,B.minutes(5)))}};return r(),()=>{t=!0,n&&clearTimeout(n)}},[o?.id,a.inProgress]),(0,Q.useEffect)(()=>{let e=o?.id;if(!e||r)return;let t=!1;return(async()=>{try{let n=await fr({queryKey:[`propertyOraclePrice`,{id:e}]});t||d(n)}catch{}})(),()=>{t=!0}},[o?.id,r]);let p=(0,Q.useMemo)(()=>{let e=o&&{...o};if(e){let t=null;if(u?.pricePerToken?.mid?t=u.pricePerToken.mid:e.trading?.sell?.min?t=e.trading.sell.min:e.liquidity?.marketPrice.priceLow,t){let n=ur(e,t);e.coc=n.coc,e.irr=n.irr,e.projected_rental_yield=n.projected_rental_yield}}return{currentPropertyQuery:{data:e,isLoading:!1,isError:!1,isFetching:!1,isFetched:!0,status:`success`,fetchStatus:`idle`},currentProperty:e,currentPropertyInfoQuery:{data:c,isLoading:!c,isError:!1,isFetching:!1,isFetched:!!c,status:c?`success`:`pending`,fetchStatus:`idle`},currentPropertyInfo:c,oraclePrice:u,refreshCurrentProperty:()=>{f()},propertyKey:t}},[o,c,u,f,t]);return(0,$.jsx)(Fa.Provider,{value:p,children:i})},za=e=>e?.error?.code===`no_algo_token_wallet`,Ba=({isOpen:e,onClose:t})=>(0,$.jsxs)(ue,{id:`regblock-infobox`,isOpen:e,onBackdropClick:t,onRequestClose:t,children:[(0,$.jsx)(Ma,{}),(0,$.jsx)(`button`,{type:`button`,className:`inline-flex items-center justify-center self-end w-36 px-4 py-2 mt-2 border border-transparent shadow-sm text-lg font-medium rounded-md text-white bg-themeBlue-600 hover:bg-themeBlue-700 dark:bg-themeBlue-dark dark:hover:bg-themeBlue-500'} focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-themeBlue-500`,onClick:t,children:`Close`})]}),Va=e=>(0,$.jsx)(ja,{...e,displayConfig:{...e.displayConfig,isStickied:e.sticky}});function Ha({price:e,openOrderBookModal:t,showOrderBookLink:n=!1,variant:r,kycVerified:i,userOrderData:a,tradingDisabled:o,interactive:c,averageHistoricalYield:l,disableSticky:u=!1,onRefreshUserOrderData:d,renderTrigger:f,orderRequestRef:m}){let h=E(),{currentProperty:g,refreshCurrentProperty:_,currentPropertyInfo:y}=La(),{sold:b,soldPct:x,isComingSoon:C,isSold:w,isSellbackReleaseComingSoon:T}=D(g),O=s(),{authState:{isAuth:k},authMethods:{updateLocalUserData:j},promptPendingMfaSetup:ne}=ce(),{regBlock:M,acceptedDisclaimer:N,hasIDV:P,isVerified:ie,algoTokenWallet:ae,sharedWalletAddress:oe}=te(),[se,le]=(0,Q.useState)({acceptedDisclaimer:N,orderDirection:null}),[ue,de]=(0,Q.useState)(0),fe=br(),{getSummaryListing:F}=A(),pe=S(),[I,L]=ee(Pa),[me,he]=ee(p),ge=(0,Q.useRef)(!1),_e=(0,Q.useRef)(null),ve=v(_e,{}),[ye,xe]=(0,Q.useState)(!1),R=(M??!1)&&g.original_starting_date>=16443864e5,z=!u&&ye&&r===`small`&&h.minWidth<re.lg,Ce=(0,Q.useMemo)(()=>me.find(e=>e.shared&&e.defaultWallet)?.address??me.find(e=>e.shared)?.address??oe??``,[me,oe]),we=F(g.id)?.currentTokens??0,Te=or(me,g),Ee=we>0?we:Te,B=Ee/g.tokens*100;(0,Q.useEffect)(()=>{let e=!1;return(async()=>{if(!k||!Ce||!g.id){de(0);return}try{let t=(await be(Ce))?.data?.summary?.pools??{},n=Object.values(t).reduce((e,t)=>t?.participant?.propertyId===g.id?e+Cn(t):e,0);e||de(n)}catch{e||de(0)}})(),()=>{e=!0}},[k,Ce,g.id]);let De=!!g.redirect&&g.redirect.length>0,Oe=(!w||!1)&&!C,ke=w&&!C,V=!!k&&Oe,Ae=!!k&&ke&&i,je=n&&Ae,Me=Oe?Pe.Primary:Pe.Secondary,Ne=!ie&&!!k&&ke&&Me===Pe.Secondary,U=C&&!w,Fe=U||Oe,Ie=l??g.coc??0,W=()=>_(),Le=(e,t,r)=>J.trackBreadcrumb(`PropertyMaxOwnership`,{source:t,direction:e,kycVerified:i,userOrderData:a??null,userBuyQuantityMax:r,currentOwned:Ee,ownedPct:B,tradingDisabled:o,marketplaceStatus:{isSold:w,isComingSoon:C,marketplaceEnabled:!0,isPropertyPrimarySale:Oe,isPropertyTradingEnabled:ke,canUserBuyPrimary:V,canUserBuySecondary:Ae,showOrderBookLink:n,orderbookLinkVisible:je,requireVerification:Ne,isAuth:k}}),Re=e=>{if(R){pe.openModal();return}let t=gt(g);if(J.trackEvent(`Property : Invest : Began`,{...t,quantity:1,amount_due:H(t.property_price_per_token??50,2,!1)}),De&&window.location.replace(g.redirect??``),w&&(o||!ke)){let e=g.platform_sold||!ke?`This property has been sold and can no longer be traded.`:`You can trade this property once all open funding payments have settled and the property is fully funded.`;gr.fire({text:e});return}if(!w){L({...I,direction:e,inProgress:!0,selectedMarket:Pe.Primary});return}if(P&&Ne){gr.fire({text:`Please visit your Wallet Settings to complete wallet verification`});return}if(e===Se.Sell){let e=a?.properties[g.id]?.orders,t=[...e?.active??[],...e?.executing??[],...e?.pending??[],...e?.intent??[]].length>0;if(we>0&&Te<=0&&ue<=0&&!t){gr.fire({title:`Shares in an unlinked wallet`,text:`Your shares of this property appear to be in an external wallet that is no longer linked to your Lofty account. Re-link that wallet from Account Settings to sell them, or contact support for help.`});return}if(Ee<=0&&Te<=0){gr.fire({title:`No shares available to sell`,text:ue>0?`We couldn't find any shares of this property in your Lofty account. Shares lent to provide liquidity can't be sold until you withdraw those shares.`:`We couldn't find any shares of this property in your Lofty account.`});return}}L({...I,direction:e,inProgress:!0,canceled:!1,orderCreated:!1,isCanceling:!1,isCommitting:!1,isCreating:!1,isDryrunLoading:!1,selectedMarket:Pe.Secondary})},ze=e=>{if(fe.addOrUpdateItem(g.id,fe.shoppingItem?.quantity??1),!k){O(`/signup`);return}if(Ne&&e===Se.Buy){jr(g.slug),J.trackEvent(`Property : Invest : Verify : Prompted`,gt(g)),O(`/verify-identity`);return}ne()||Re(e)},Be=(e,t)=>{e.currentTarget.blur(),ze(t)};(0,Q.useEffect)(()=>
5{if(m)return m.current=ze,()=>{m.current=null}}),(0,Q.useEffect)(()=>{let e=w?`secondary-2`:`secondary-1`,t=a?.properties[g.id]?.orderValidation,n=t?.maxTokensAllowed;if(typeof n==`number`&&n<=0&&I.inProgress&&I.direction===Se.Buy){if(Le(I.direction,e,n),L(Na),Ne){gr.fire({title:`Verify your identity to invest`,text:`Verification takes a couple of minutes. We will bring you back to this property.`,showCancelButton:!0,confirmButtonText:`Verify now`,cancelButtonText:`Not now`}).then(e=>{e.isConfirmed&&(jr(g.slug),O(`/verify-identity`))});return}if(za(t)||!ae&&Ce){if(ge.current)return;ge.current=!0,(async()=>{if(!Ce){(await gr.fire({title:`Default wallet required`,text:`Your account needs a default wallet before you can buy shares. Open Wallet settings to set one up.`,showCancelButton:!0,confirmButtonText:`Open Wallet settings`,cancelButtonText:`Not now`})).isConfirmed&&O(`/account/wallet`);return}let e=await gr.fire({title:`Set a default wallet`,text:`Your account needs a default wallet to buy shares. Most older accounts should use the Lofty Wallet. You can change this later in Account > Wallet.`,showCancelButton:!0,showDenyButton:!0,confirmButtonText:`Use Lofty Wallet`,denyButtonText:`Wallet settings`,cancelButtonText:`Not now`});if(e.isDenied){O(`/account/wallet`);return}if(e.isConfirmed)try{let e=await bt({wallet:Ce});if(!e.success){hr.fire({text:e.error||`Failed to set your default wallet. Please try again from Account > Wallet.`});return}let t=e.data?.defaultWallet??Ce,n=e.data?.defaultPaymentMethod;j({algoTokenWallet:t,...n?{defaultPaymentMethod:n}:{}}),he(e=>e.map(e=>({...e,defaultWallet:e.address===t}))),J.updateUserTraits({default_wallet:`lofty-wallet`}),await d?.(),mr.fire({icon:`success`,title:`Lofty Wallet set as default. Click Buy to continue.`})}catch(e){Mt(e,`InvestNowBox::setDefaultLoftyWallet`,{sharedWalletAddress:Ce}),hr.fire({text:`Failed to set your default wallet. Please try again from Account > Wallet.`})}})().finally(()=>{ge.current=!1});return}
5gr.fire({text:`You already own 15% of this property, which is the maximum allowed ownership.`})}},[a,I]),(0,Q.useEffect)(()=>{N&&le(e=>({...e,acceptedDisclaimer:N})),se.acceptedDisclaimer&&se.orderDirection!==null&&Re(se.orderDirection)},[N,se.acceptedDisclaimer]),(0,Q.useEffect)(()=>{if(r===`small`){let e=!!ve?.isIntersecting;xe(!e)}},[ve]);let Ve={listing:g,numSold:b,soldPct:x,price:e,coc:g.coc,quantityOwned:Ee,lpStakedShares:ue,ownedPct:B,startingDate:g.starting_date,onOrderBookClick:t,onBuyClick:e=>Be(e,Se.Buy),onSellClick:e=>Be(e,Se.Sell),onTimerEnd:W,currentPropertyInfo:y,averageHistoricalYield:Ie,isAverageHistoricalYieldEnabled:!0,displayConfig:{interactive:c,kycVerified:i,isRedirect:De,isSold:w,isPropertyUpcoming:C&&!w,isSellbackComingSoon:T,orderbookLinkVisible:je,isPropertyPrimarySale:Oe,isPropertyTradingEnabled:ke,marketplaceEnabled:!0,requireVerification:Ne,canUserBuyPrimary:V,canUserBuySecondary:Ae}};return f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ba,{isOpen:pe.isModalOpen,onClose:pe.closeModal}),f({onBuyClick:e=>Be(e,Se.Buy),onSellClick:e=>Be(e,Se.Sell),buyDisabled:U,sellDisabled:Fe,interactive:c})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ba,{isOpen:pe.isModalOpen,onClose:pe.closeModal}),(0,$.jsx)(`section`,{className:[`flex flex-col items-center w-full lg:w-auto relative`,r===`large`?`hidden lg:flex -top-28`:`lg:hidden flex`,`min-w-transactCard lg:min-w-transactCard lg:max-w-transactCard-2xl xl:min-w-transactCard-2xl 2xl:min-w-transactCard-xl 2xl:max-w-transactCard-2xl`].filter(
5Boolean).join(` `),children:(0,$.jsxs)(`div`,{ref:_e,className:[`flex flex-col items-center w-full lg:w-auto`,r===`large`?`hidden lg:flex sticky lg:top-12 xl:top-14 2xl:top-16`:``,r===`small`?`lg:hidden flex`:``].filter(Boolean).join(` `),children:[(0,$.jsx)(Va,{...Ve}),z&&ba.createPortal((0,$.jsx)(Va,{...Ve,sticky:!0}),document.body)]})})]})}function Ua(){return(0,Q.useEffect)(()=>{setTimeout(()=>window.scrollTo(0,0),100)},[]),null}var Wa=e=>{let t=e.result?.finalVotes??{},n=Object.values(t).reduce((e,t)=>e+Number(t||0),0),r=e.result?.calculationBasis===`absolute_property_percentage`;return e.choices.map(e=>{let i=Number(t[e]||0);return{choice:e,votes:i,percent:r?i:n>0?i/n*100:0}})};function Ga({propertyId:e}){let[t,n]=(0,Q.useState)([]),{authState:r}=ce(),i=r.isAuth===!0;return(0,Q.useEffect)(()=>{if(!i){n([]);return}let t=!0;return it(e).then(e=>{t&&n((e.data??[]).filter(e=>e.status===`done`))}).catch(()=>{t&&n([])}),()=>{t=!1}},[e,i]),t.length===0?null:(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 bg-white shadow-sm dark:border-lofty-purple-700/40 dark:bg-lofty-purple-800/20 dark:shadow-none`,children:[(0,$.jsx)(`div`,{className:`border-b border-gray-200 bg-gray-50 px-5 py-3.5 dark:border-transparent dark:bg-lofty-purple-700/30`,children:(0,$.jsxs)(`h3`,{className:`text-lg font-bold text-lofty-purple-600 dark:text-lofty-gray`,children:[(0,$.jsx)(`i`,{className:`fas fa-gavel mr-2 text-lofty-purple`}),`Governance Results`]})}),(0,$.jsx)(`div`,{className:`space-y-6 p-5 md:p-6`,children:t.map(e=>(0,$.jsxs)(`article`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h4`,{className:`font-semibold text-lofty-purple-700 dark:text-white`,children:e.name}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-gray-600 dark:text-lofty-gray/80`,children:e.question}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs font-semibold text-gray-600 dark:text-lofty-gray/80`,children:[e.type===`Ranking`?`Ranked choice`:`Multiple choice`,` · 60% threshold`]})]}),(0,$.jsx)(d,{to:e.forumActivityId?`/account/community/${encodeURIComponent(e.propertyId)}/post/${encodeURIComponent(e.forumActivityId)}`:`/account/community/${encodeURIComponent(e.propertyId)}`,className:`text-sm font-semibold text-lofty-purple hover:text-lofty`,children:`View in forum →`})]}),e.result&&(0,$.jsxs)(`div`,{className:`mt-3 space-y-2 text-sm text-lofty-purple-700 dark:text-white`,children:[(0,$.jsx)(`p`,{children:(0,$.jsx)(`strong`,{children:e.result.status===`won`?`Winning choice: ${e.result.mostPopularChoice??`Result unavailable`}`:e.result.status===`no_consensus`?`No choice reached the required consensus.`:`No eligible votes were cast.`})}),(0,$.jsxs)(`p`,{className:`text-xs text-gray-600 dark:text-lofty-gray/80`,children:[e.result.calculationBasis===`absolute_property_percentage`?`Needed 60% of the property's total voting power to pass.`:`Needed 60% of the voting power cast to pass.`,e.type===`Ranking`?` Values shown are final-round voting power.`:``]})]}),(0,$.jsx)(`div`,{className:`mt-3 space-y-2`,children:Wa(e).map(t=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex justify-between gap-3 text-xs text-gray-600 dark:text-lofty-gray/80`,children:[(0,$.jsx)(`span`,{children:t.choice}),(0,$.jsxs)(`span`,{children:[e.result?.calculationBasis===`absolute_property_percentage`?`${t.percent.toFixed(2)}% of the property`:`${t.votes.toLocaleString()} ${t.votes===1?`share`:`shares`} (${t.percent.toFixed(1)}%)`,e.type===`Ranking`?` · final round`:``]})]}),(0,$.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-gray-200 dark:bg-lofty-purple-600`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-lofty`,style:{width:`${Math.min(t.percent,100)}%`}})})]},t.choice))})]},e.id))})]})}function Ka({property:e,mobileCopy:t=!1}){let n=e.createdAt>1655168933e3,r=e.sale_price;e.avmHistory?.overall?.pctChange&&(r=H(r*(e.avmHistory.overall.pctChange+1),0,!0));let i=!!(e.current_loan&&e.current_loan>0),a=e.tokens>0?e.total_investment/e.tokens:0,o=e.numIssued??e.tokens,s=H(Math.max(0,e.tokens-o)*a,2,!0),c,l;i?(c=H(o*a,2,!0),l=s>0?s:e.current_loan):(l=0,c=r-l);
5let u=[{label:`Equity`,value:`$${c.toLocaleString()}`,tooltip:`The equity portion of the property value — the underlying asset price minus any outstanding debt.`}],d=l>0&&!new Set([`01JWM9CKG1PV7XH2AJTBKQVFX8`,`01K2FFVKT70CRA8WMSY9DEPHP9`]).has(e.id);return l>0?(u.push({label:`Debt`,value:U(l),tooltip:d?`The co-owner makes the mortgage payments directly, so investors are not responsible for principal or interest payments. As the loan principal is paid down, shares representing that principal reduction are distributed to the original owner, since they are covering the mortgage themselves. To review all related loan documents, select "Due Diligence Documents" above.`:`This property has an existing mortgage. Payments are deducted from rental income before distributions.`}),e.monthly_loan_repayment&&e.monthly_loan_repayment>0&&u.push({label:`Monthly Loan Repayment`,value:U(e.monthly_loan_repayment)})):wr(e.id,e.current_loan)&&u.push({label:`Debt`,value:`None`,tooltip:`This listing has no mortgage and no outstanding loans.`}),e.closing_costs&&u.push({label:`Closing Costs${n?` (incl. inspection & appraisal)`:``}`,value:U(e.closing_costs)}),e.city_transfer_tax&&u.push({label:`City Transfer Tax`,value:U(e.city_transfer_tax)}),e.llc_admin_fee_upfront&&u.push({label:`LLC Formation`,value:U(e.llc_admin_fee_upfront)}),u.push({label:`Operating Reserve`,value:U(e.curr_maintenance_reserve??0),tooltip:`The operating reserve is a cash buffer set aside from the offering to cover unexpected expenses like repairs, vacancies, or maintenance without reducing investor distributions.`}),(0,$.jsxs)(`div`,{className:t?`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-gray-50 dark:bg-lofty-purple-800/20 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5`,children:(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-bold flex items-center gap-2`,children:[(0,$.jsx)(`i`,{className:`far fa-file-invoice-dollar text-lofty-purple`}),(0,$.jsx)(`span`,{children:t?`About this offering`:`Offering Details`})]})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700/30`,children:[(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-medium`,children:`Total Property Value`}),(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-semibold`,children:U(e.total_investment)})]}),u.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700/30`,children:[(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-medium flex items-center gap-1.5`,children:e.tooltip?(0,$.jsxs)(Sr,{className:`flex items-center mr-px p-0 cursor-pointer`,placement:`auto`,content:(0,$.jsx)(`span`,{className:`block max-w-[280px]`,children:e.tooltip}),children:[(0,$.jsx)(`span`,{children:e.label}),(0,$.jsx)(`i`,{className:`far fa-circle-question text-xs text-lofty-gray-500 ml-1.5`})]}):e.label}),(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-semibold flex items-center gap-2`,children:e.value})]},e.label))]})}var qa=new g,Ja=e=>`/account/community/${encodeURIComponent(e)}`,Ya=/^[ \t]*[-*]?[ \t]*\*\*\s*Property Update\s*[-–—:]?\s*\(?([^)\n*]+?)\)?\s*:?\s*\*\*\s*:?[ \t]*(.*)$/gim,Xa=/^##\s+(.+)$/gm,Za=[`M/d/yyyy`,`M/d/yy`,`MM/dd/yyyy`,`MM/dd/yy`,`MMMM d, yyyy`,`MMM d, yyyy`,`yyyy-MM-dd`];function Qa(e){let t=e.trim();for(let e of Za){let n=ua(t,e,new Date);if(pn(n))return n}let n=new Date(t);return pn(n)&&!Number.isNaN(n.getTime())?n:null}function $a(e){let t=e.split(`
6`),n=1/0;for(let e of t){if(!e.trim())continue;let t=e.match(/^[ \t]*/),r=t?t[0].replace(/\t/g,`    `).length:0;r<n&&(n=r)}return!isFinite(n)||n===0?e.trim():t.map(e=>e.replace(/^\t+/g,e=>` `.repeat(e.length*4)).slice(n)).join(`
7`).trim()}function eo(e){let t=[];Ya.lastIndex=0;let n;for(;(n=Ya.exec(e))!==null;)t.push({index:n.index,length:n[0].length,rawDate:n[1],inlineBody:n[2].trim()});if(t.length===0)return[];let r=[];for(let n=0;n<t.length;n++){let i=t[n].index+t[n].length,a=n+1<t.length?t[n+1].index:e.length,o=$a(e.slice(i,a)),s=[t[n].inlineBody,o].filter(
7Boolean).join(`
8
9`);r.push({rawDate:t[n].rawDate.trim(),parsedDate:Qa(t[n].rawDate),body:s})}return r}function to(e){let t=(e||``).trim();if(!t)return[];let n=[];Xa.lastIndex=0;let r;for(;(r=Xa.exec(t))!==null;)n.push({index:r.index,length:r[0].length,heading:r[1].trim()});let i=[];if(n.length===0){let e=eo(t);return i.push({heading:null,entries:e,fallbackBody:e.length===0?t:null}),i}if(n[0].index>0){let e=t.slice(0,n[0].index).trim();if(e){let t=eo(e);i.push({heading:null,entries:t,fallbackBody:t.length===0?e:null})}}for(let e=0;e<n.length;e++){let r=n[e].index+n[e].length,a=e+1<n.length?n[e+1].index:t.length,o=t.slice(r,a).trim(),s=eo(o);i.push({heading:n[e].heading,entries:s,fallbackBody:s.length===0&&o?o:null})}return i}var no=/^\s*(?:[-*+]\s+|\d+[.)]\s+)/,ro=/^\s*(?:[-*+]\s|\d+[.)]\s|#{1,6}\s|>|```)/,io=/\[View Results in Community\]\([^)]+\)/;function ao(e){return e.replace(/([\\`*_[\]{}#+|<>~-])/g,`\\$1`).replace(/^(\s*\d+)([.)])(?=\s)/gm,(e,t,n)=>`${t}\\${n}`)}function oo(e){return e.split(`
10`).map(e=>e.replace(no,``).trim()).filter(Boolean).map(e=>`- ${ao(e)}`).join(`
11`)}function so(e){let t=e.split(`
12`);return t.map((e,n)=>{let r=t[n+1];return r!==void 0&&r.trim()&&!ro.test(e)&&!ro.test(r)?`${e}  `:e}).join(`
13`)}function co(e){return io.test(e)?so(e):oo(e)}function lo(e,t){let n=t?Ja(t):void 0;return(e??[]).map(e=>{let[t]=e.createdAt.split(`T`),r=io.test(e.body);return{rawDate:t,parsedDate:Qa(t),body:co(e.body),title:e.title||void 0,discussionHref:r?void 0:n}})}function uo(e,t){if(t.length===0)return e;let n=e.findIndex(e=>e.heading===null);return n===-1?[{heading:null,entries:t,fallbackBody:null},...e]:e.map((e,r)=>r===n?{...e,entries:[...e.entries,...t]}:e)}function fo(e){return[...e].sort((e,t)=>e.parsedDate&&t.parsedDate?t.parsedDate.getTime()-e.parsedDate.getTime():e.parsedDate?-1:+!!t.parsedDate)}function po(e){return e.parsedDate?gn(e.parsedDate,`MMM d, yyyy`):e.rawDate}var mo=1,ho=({markdown:e})=>(0,$.jsx)(`div`,{className:`rendered-text md-item text-base leading-relaxed text-lofty-purple-600 dark:text-lofty-gray
14      [&_a]:text-lofty-purple [&_a:hover]:text-lofty
15      [&_h2]:text-lofty-purple-600 dark:[&_h2]:text-lofty-gray [&_h2]:font-bold
16      [&_h3]:text-lofty-purple-600 dark:[&_h3]:text-lofty-gray [&_h3]:font-bold
17      [&_p:first-child]:mt-0 [&_p:last-child]:mb-0
18      [&_ul:first-child]:mt-0 [&_ol:first-child]:mt-0`,dangerouslySetInnerHTML:{__html:qa.render(e)}}),go=({href:e,onOpen:t})=>(0,$.jsxs)(`p`,{className:`mt-3 text-base leading-relaxed text-lofty-purple-600 dark:text-lofty-gray`,children:[`Click`,` `,(0,$.jsx)(d,{to:e,onClick:t,className:`font-medium text-lofty-purple underline underline-offset-2 hover:text-lofty`,children:`here`}),` `,`to view this discussion and chat with the property manager and other investors.`]}),_o=({entry:e,onOpenDiscussion:t})=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-baseline gap-x-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`font-semibold text-lofty-purple-600 dark:text-lofty-gray`,children:`Update`}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`text-gray-400 dark:text-lofty-gray/40`,children:`·`}),(0,$.jsx)(`span`,{className:`text-gray-600 dark:text-lofty-gray/70`,children:po(e)})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 bg-white p-4 dark:border-lofty-purple-700/30 dark:bg-lofty-purple-800/15 md:p-5`,children:[e.title&&(0,$.jsx)(`p`,{className:`mb-2 text-base font-bold text-lofty-purple-600 dark:text-lofty-gray`,children:e.title}),e.body&&(0,$.jsx)(ho,{markdown:e.body}),!e.title&&!e.body&&(0,$.jsx)(`p`,{className:`text-sm italic text-gray-500 dark:text-lofty-gray/60`,children:`No additional details provided.`}),e.discussionHref&&(0,$.jsx)(go,{href:e.discussionHref,onOpen:t})]})]}),vo=({section:e,onOpenDiscussion:t})=>{let n=(0,Q.useMemo)(()=>fo(e.entries),[e.entries]),[r,i]=(0,Q.useState)(!1),a=n.length>0,o=r?n:n.slice(0,mo),s=n.length-o.length;return(0,$.jsxs)(`div`,{children:[e.heading&&(0,$.jsx)(`h4`,{className:`mb-4 text-base font-bold text-lofty-purple-600 dark:text-lofty-gray`,children:e.heading}),a&&(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:o.map((e,n)=>(0,$.jsx)(_o,{entry:e,onOpenDiscussion:t},`${e.rawDate}-${n}`))}),a&&s>0&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`mt-4 text-lofty-purple font-medium text-sm hover:text-lofty transition-colors`,children:`See ${s} more update${s===1?``:`s`}`}),a&&r&&n.length>mo&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(!1),className:`mt-4 text-lofty-purple font-medium text-sm hover:text-lofty transition-colors`,children:`See less`}),e.fallbackBody&&(0,$.jsx)(`div`,{className:`rounded-xl border border-gray-200 bg-white p-4 dark:border-lofty-purple-700/30 dark:bg-lofty-purple-800/15 md:p-
185 ${a?`mt-6`:``}`,children:(0,$.jsx)(ho,{markdown:e.fallbackBody})})]})},yo=({markdown:e,forumUpdates:t,propertyId:n})=>{let r=(0,Q.useMemo)(()=>uo(to(e),lo(t,n)),[e,t,n]);return r.length===0?null:(0,$.jsx)(`div`,{className:`flex flex-col gap-8`,children:r.map((e,t)=>(0,$.jsx)(vo,{section:e},`${e.heading??`section`}-${t}`))})},bo=new g,xo=2,So=({property:e,currentOwned:t,ownedPct:n,userProjectedAnnualReturn:r,userRentalYield:i,userProjectedRentalYield:a,listingDescription:o,listingUpdates:s,forumUpdates:c,hidden:l,reviews:u,reviewsRef:f,showReviews:p,isLoadingReviews:m=!1,mobileVariant:h=!1,userReview:g,onWriteReview:_})=>{let v=!!_&&t>0&&!g,{unreadByProperty:y}=fe(),b=y[e.id]??0,x=!!s||!!c?.length,S=o.startsWith(`[##]`)?o.substring(4):o,C=!!e.isDaoOnly,w=!!e.isPrivate,T=Er(e.id)??Dr(e.managerId??``),E=T?.name||`Property Manager`,D=T,ee=D?.name||E,O=T?.description||`Property manager details coming soon.`,k=e.documents||[],A=e.state===`OH`?`Ohio`:e.state,j=[e.city,A].filter(Boolean).join(`, `),te=[e.address_line1,e.city,e.state,e.zipcode].filter(Boolean).join(`, `),ne=te?`https://www.google.com/maps?q=${encodeURIComponent(te)}&output=embed`:``,M=j?`${j} offers a mix of neighborhood livability, local employment centers, and day-to-day amenities that support long-term housing demand. The area benefits from access to major commuter routes, schools, and retail services, while continuing to attract residents looking for affordability and convenience. As population and job activity remain steady across the broader region, rental demand is generally supported by both local households and in-migration trends.`:``,re=[{q:`How Lofty works`,a:`Property owners transfer their properties into Wyoming LLCs through quitclaim deeds before listing them on the Lofty marketplace. The original owner, often serving as the property manager, can then sell up to 90% of their equity shares peer-to-peer to investors through a co-ownership model. If the original owner sells 20% of their equity, they retain 80% ownership of the LLC and receive 80% of the rental income. Shares purchased by investors represent direct ownership in the Wyoming LLC — whose sole asset is the property — and provide rights to rental income, appreciation, ownership, and governance voting on property decisions. Investors earn daily rental income, share prices may fluctuate with market conditions, and shares can be sold at any time`},{q:`What returns can I expect, and how often are rental payments distributed to investors?`,a:`Investing in properties on Lofty can generate returns for investors in two primary ways:
19
20Rental income, with expected rent distributed to investors daily based on each property’s performance.
21
22Appreciation, driven by changes in property share value, which updates in real time as marketplace trades occur.`},{q:`How does leverage work?`,a:`Properties listed on Lofty may include existing mortgages. In some cases, the original owner makes the mortgage payments directly, while in others, payments are deducted from rental income before distributions are made to investors. You can determine whether a property uses leverage in the “Offering Details” section, and review all related loan documents by selecting “Due Diligence Documents” above. The original owner may only sell shares representing equity in the property. As the loan principal is paid down, shares reflecting that principal reduction are either distributed to the original owner if they are covering the mortgage themselves, or burned (removed from supply) when mortgage payments are funded through rental income.`},{q:`How are property decisions made?`,a:`Owners use their shares to vote on decisions for the properties they co-own, with voting power tied to the number of shares held. When a decision arises, owners receive an email prompt to vote, and discussions can take place with other investors in the property’s Community channel. Votes may cover a wide range of topics, from rent adjustments and refinances to converting a long-term rental into an Airbnb, and more. For certain votes, owners also have the option to defer to the Property Manager’s recommendation.`},...w?[]:[{q:`Where can I communicate with the other co-owners?`,a:(0,$.jsxs)($.Fragment,{children:[`Every property has its own channel in the`,` `,(0,$.jsx)(d,{to:`/account/community/${encodeURIComponent(e.id)}`,className:`text-lofty-purple underline underline-offset-4 hover:text-lofty`,children:`Community`}),`. Property managers post updates there so you can discuss them and request more information, and 
22you can chat with the property manager and other investors in the property. Votes happen in that same channel, where you can file a motion, discuss it, and cast your vote.`]})}]],N=`https://www.lofty.ai`,[P,ie]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(!1),[se,ce]=(0,Q.useState)(!1),[le,ue]=(0,Q.useState)(!1),[de,F]=(0,Q.useState)(!1),pe=(0,Q.useRef)(null),I=(0,Q.useRef)(null),[L,me]=(0,Q.useState)(null),he=(e,t,n,r)=>{(0,Q.useLayoutEffect)(()=>{let r=e.current;if(!r)return;let i=()=>{if(t){n(!0);return}n(r.scrollHeight>r.clientHeight+1)};if(i(),typeof ResizeObserver>`u`)return;let a=new ResizeObserver(i);return a.observe(r),()=>a.disconnect()},r)};he(pe,P,ue,[S,P]),he(I,ae,F,[O,ae]);let ge=e=>{let t=Math.floor(e),n=[];for(let e=0;e<5;e++)e<t?n.push((0,$.jsx)(`i`,{className:`fas fa-star text-lofty-purple`},e)):n.push((0,$.jsx)(`i`,{className:`far fa-star text-lofty-purple`},e));return n},_e=e=>{let t=typeof e==`string`?parseFloat(e):e;return Number.isInteger(t)?t.toFixed(0):t.toFixed(1)},ve=u.length>0?_e(u.reduce((e,t)=>e+t.rating,0)/u.length):`N/A`,ye=se?u:u.slice(0,xo),be=u.length-ye.length,xe=e=>`${e.slice(0,4)}....${e.slice(-4)}`,R=(e,t,n)=>e===1?t:n,Se=(e,t)=>e.txnId||`${e.propertyId}-${e.wallet}-${e.createdAt}-${t}`,z=(e,t)=>t?(0,$.jsx)(`img`,{src:t,alt:e,className:`w-10 h-10 rounded-full bg-lofty-gray dark:bg-lofty-purple-700 ${Or(t)?`object-contain p-1 bg-white`:`object-cover`}`,onError:e=>{e.target.src=`/static/img/No_Image_Available.jpg`}}):(0,$.jsx)(`div`,{className:`w-10 h-10 rounded-full bg-lofty flex items-center justify-center text-white text-xs font-bold`,children:e.split(` `).filter(Boolean).slice(0,2).map(e=>e[0]).join(``).toUpperCase()});return(0,$.jsxs)(`div`,{className:`${l?`hidden`:``} pt-4 text-lofty-purple-600 dark:text-lofty-gray`,role:`tabpanel`,children:[t>0&&(0,$.jsx)(`div`,{className:`${h?`hidden lg:block`:`block`} mt-8`,children:(0,$.jsxs)(`div`,{className:`rounded-2xl bg-white dark:bg-gradient-to-br dark:from-lofty-purple-800 dark:via-lofty-purple-700 dark:to-lofty-purple-600 border border-gray-200 dark:border-lofty-purple-700/60 overflow-hidden shadow-sm dark:shadow-cardDark`,children:[(0,$.jsx)(`div`,{className:`px-6 pt-6 pb-5`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-gray-500 dark:text-lofty-gray-400 text-xs font-medium tracking-widest uppercase mb-2`,children:`Your Ownership`}),(0,$.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,$.jsx)(`span`,{className:`text-4xl md:text-5xl font-bold text-lofty-purple-600 dark:text-lofty-gray tracking-tight`,children:t.toLocaleString()}),(0,$.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-lofty-gray-300`,children:R(t,`share`,`shares`)})]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center mt-2 text-lofty-purple-600 dark:text-lofty text-sm font-semibold bg-lofty-purple-50 dark:bg-lofty/10 px-2.5 py-0.5 rounded-full`,children:[n,`% of property`]})]}),(0,$.jsx)(`div`,{className:`w-11 h-11 rounded-xl bg-lofty-purple-50 dark:bg-lofty/10 flex items-center justify-center shrink-0`,children:(0,$.jsx)(`i`,{className:`far fa-chart-pie text-lofty-purple-600 dark:text-lofty text-lg`})})]})}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 border-t border-gray-200 dark:border-white/[0.08]`,children:[(0,$.jsxs)(`div`,{className:`px-6 py-5 bg-gray-50 dark:bg-lofty-purple-800/20 sm:border-r border-gray-200 dark:border-white/[0.08]`,children:[(0,$.jsx)(Sr,{className:`flex items-start justify-start mr-px p-0 cursor-pointer`,placement:`auto`,content:(0,$.jsx)(`span`,{className:`block max-w-[280px]`,children:`Your Projected Annual Return is calculated by adding the Projected Annual Appreciation from a third party provider and the Average Rental Yield based on historical data for this property.`}),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`span`,{className:`text-gray-600 dark:text-lofty-gray-300 text-sm`,children:`Projected Annual Return`}),(0,$.jsx)(`i`,{className:`far fa-circle-question text-xs text-gray-400 dark:text-lofty-gray-500`})]})}),(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-2xl font-bold text-lofty-purple-600 dar
22k:text-lofty-gray tracking-tight`,children:[W(r,2),`%`]}),r>0&&(0,$.jsx)(`span`,{className:`text-lofty-green-500 dark:text-lofty-green text-xs font-medium flex items-center gap-0.5`,children:(0,$.jsx)(`i`,{className:`fas fa-arrow-trend-up text-[10px]`})})]})]}),(0,$.jsxs)(`div`,{className:`px-6 py-5 bg-gray-50/60 dark:bg-lofty-purple-800/10 border-t sm:border-t-0 border-gray-200 dark:border-white/[0.08]`,children:[(0,$.jsx)(Sr,{className:`flex items-start justify-start mr-px p-0 cursor-pointer`,placement:`auto`,content:(0,$.jsx)(`span`,{className:`block max-w-[280px]`,children:`Your rental yield is calculated by the current net cashflow you're receiving based on your unique average cost basis, then annualized into an annual percentage yield. This can differ than what's quoted on a property page, which is based on the lowest available entry price for that property at the time.`}),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`span`,{className:`text-gray-600 dark:text-lofty-gray-300 text-sm`,children:`Your Rental Yield`}),(0,$.jsx)(`i`,{className:`far fa-circle-question text-xs text-gray-400 dark:text-lofty-gray-500`})]})}),(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-2xl font-bold text-lofty-purple-600 dark:text-lofty-gray tracking-tight`,children:[W(i,2),`%`]}),i>0&&(0,$.jsx)(`span`,{className:`text-lofty-green-500 dark:text-lofty-green text-xs font-medium flex items-center gap-0.5`,children:(0,$.jsx)(`i`,{className:`fas fa-arrow-trend-up text-[10px]`})})]})]})]})]})}),(0,$.jsx)(`section`,{className:`mt-6`,children:(0,$.jsx)(`div`,{className:h?`rounded-xl border border-gray-200 dark:border-lofty-purple-700 bg-white dark:bg-transparent px-4 py-3 shadow-sm dark:shadow-none`:`rounded-xl border border-gray-200 dark:border-lofty-purple-700 px-4 py-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[D?(0,$.jsx)(d,{to:`/propertymanager/${D.slug}`,target:`_blank`,rel:`noopener noreferrer`,"aria-label":ee,className:`shrink-0 hover:opacity-85 transition-opacity duration-200`,children:z(ee,D.photoUrl)}):(0,$.jsx)(`a`,{href:N,target:`_blank`,rel:`noopener noreferrer`,"aria-label":ee,className:`shrink-0 hover:opacity-85 transition-opacity duration-200`,children:z(ee)}),(0,$.jsx)(`div`,{className:`min-w-0`,children:D?(0,$.jsxs)(d,{to:`/propertymanager/${D.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-medium leading-tight hover:text-lofty-purple transition-colors duration-200`,children:[`Property managed by `,E]}):(0,$.jsxs)(`a`,{href:N,target:`_blank`,rel:`noopener noreferrer`,className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-medium leading-tight hover:text-lofty-purple transition-colors duration-200`,children:[`Property managed by `,E]})})]})})}),(0,$.jsxs)(`div`,{className:`space-y-5 mt-6`,children:[!w&&(0,$.jsxs)(d,{to:`/account/community/${encodeURIComponent(e.id)}`,className:`flex items-center justify-between rounded-xl border border-gray-200 bg-white px-5 py-4 shadow-sm transition-colors hover:border-lofty focus:outline-none focus-visible:ring-2 focus-visible:ring-lofty-purple focus-visible:ring-offset-2 dark:border-lofty-purple-700/40 dark:bg-lofty-purple-800/20 dark:shadow-none`,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-lg font-bold text-lofty-purple-600 dark:text-lofty-gray`,children:[(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`i`,{className:`far fa-comments mr-2 text-lofty-purple`,"aria-hidden":`true`}),`Community`]}),(0,$.jsx)(cr,{count:b,label:`unread posts in this property's community`,singularLabel:`unread post in this property's community`})]}),(0,$.jsx)(`span`,{className:`mt-1 block text-sm text-gray-600 dark:text-lofty-gray-200`,children:b>0?`New activity since you last visited this community`:`Discuss this property with investors and the property manager`})]}),(0,$.jsx)(`i`,{className:`fas fa-chevron-right text-gray-400`,"aria-hidden":`true`})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`,children:[(0,$.jsx)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5 border-b border-gray-200 dark:border-transparent`,children:(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dar
22k:text-lofty-gray text-lg font-bold`,children:[(0,$.jsx)(`i`,{className:`far fa-building mr-2 text-lofty-purple-600 dark:text-lofty-purple`}),`About`]})}),(0,$.jsxs)(`div`,{className:`p-5 md:p-6`,children:[(0,$.jsx)(`div`,{ref:pe,className:`text-base leading-relaxed text-gray-700 dark:text-lofty-gray [&_a]:text-lofty-purple-600 dark:[&_a]:text-lofty-purple [&_a:hover]:text-lofty [&_h2]:text-lofty-purple-600 dark:[&_h2]:text-lofty-gray [&_h2]:font-bold [&_h3]:text-lofty-purple-600 dark:[&_h3]:text-lofty-gray [&_h3]:font-bold transition-all duration-300 ${P?``:`line-clamp-4`}`,children:(0,$.jsx)(`div`,{className:`rendered-text md-item`,dangerouslySetInnerHTML:{__html:bo.render(S)}})}),le&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>ie(e=>!e),className:`inline-flex min-h-11 touch-manipulation items-center text-lofty-purple-600 dark:text-lofty-purple font-medium text-sm mt-2 hover:text-lofty transition-colors`,children:P?`See less`:`See more`})]})]}),!C&&(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`,children:[(0,$.jsx)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5 border-b border-gray-200 dark:border-transparent`,children:(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-bold`,children:[(0,$.jsx)(`i`,{className:`far fa-briefcase mr-2 text-lofty-purple-600 dark:text-lofty-purple`}),`Property Management`]})}),(0,$.jsxs)(`div`,{className:`p-5 md:p-6`,children:[(0,$.jsx)(`p`,{className:`font-bold mb-2 text-lofty-purple-600 dark:text-lofty-gray`,children:E}),(0,$.jsx)(`p`,{ref:I,className:`text-gray-700 dark:text-lofty-gray text-base leading-relaxed ${ae?``:`line-clamp-3`}`,children:O}),de&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>oe(e=>!e),className:`inline-flex min-h-11 touch-manipulation items-center text-lofty-purple-600 dark:text-lofty-purple font-medium text-sm mt-2 hover:text-lofty transition-colors`,children:ae?`See less`:`See more`})]})]}),!C&&k.length>0&&(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`,children:[(0,$.jsx)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5 border-b border-gray-200 dark:border-transparent`,children:(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-bold`,children:[(0,$.jsx)(`i`,{className:`far fa-folder-open mr-2 text-lofty-purple`}),`Due Diligence Documents`]})}),(0,$.jsx)(`div`,{className:`p-5 md:p-6`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:k.map((e,t)=>(0,$.jsxs)(`a`,{href:e.targetUrl,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center justify-between py-2.5 text-lofty-purple-600 dark:text-lofty-gray
23                      border-b border-gray-200 dark:border-lofty-purple-700/30 last:border-b-0 hover:text-lofty-purple
24                      transition-colors duration-200`,children:[(0,$.jsx)(`span`,{className:`text-base`,children:`Inspection report, appraisal, LLC docs, and more`}),(0,$.jsx)(Vt,{color:`text-lofty-purple`})]},`${e.targetUrl}-${t}`))})})]}),!C&&(0,$.jsx)(`div`,{className:`pt-4`,children:(0,$.jsx)(Ka,{property:e,mobileCopy:h})}),!C&&ne&&(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`,children:[(0,$.jsx)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5 border-b border-gray-200 dark:border-transparent`,children:(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-bold`,children:[(0,$.jsx)(`i`,{className:`far fa-map-location-dot mr-2 text-lofty-purple`}),`The Market`]})}),(0,$.jsxs)(`div`,{className:`p-5 md:p-6`,children:[(0,$.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-lofty-gray/70 mb-4`,children:j}),(0,$.jsx)(`div`,{className:`rounded-xl overflow-hidden border border-gray-200 dark:border-lofty-purple-700/40`,children:(0,$.jsx)(`iframe`,{title:`Map for ${te}`,src:ne,className:`w-full h-[360px]`,loading:`lazy`,referrerPolicy:`no-referrer-when-downgrade`})}),(0,$.jsx)(`p`,{className:`text-base leading-relaxed text-lofty-purple-600 dar
24k:text-lofty-gray mt-4`,children:M})]})]}),x&&(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`,children:[(0,$.jsx)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5 border-b border-gray-200 dark:border-transparent`,children:(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-bold`,children:[(0,$.jsx)(`i`,{className:`far fa-bullhorn mr-2 text-lofty-purple`}),C?`DAO`:`Property`,` Updates`]})}),(0,$.jsx)(`div`,{className:`p-5 md:p-6`,children:(0,$.jsx)(yo,{markdown:s??``,forumUpdates:c,propertyId:e.id})})]}),(0,$.jsx)(Ga,{propertyId:e.id}),p&&m&&(0,$.jsxs)(`div`,{className:`scroll-mt-20 rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`,ref:f,"aria-busy":`true`,"data-testid":`investor-reviews-loading`,children:[(0,$.jsx)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5 border-b border-gray-200 dark:border-transparent`,children:(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-bold`,children:[(0,$.jsx)(`i`,{className:`far fa-star mr-2 text-lofty-purple`}),`Investor Reviews`]})}),(0,$.jsx)(`div`,{className:`p-5 md:p-6`,children:(0,$.jsx)(Ln,{lines:3})})]}),p&&!m&&(0,$.jsxs)(`div`,{className:`scroll-mt-20 rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`,ref:f,children:[(0,$.jsxs)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5 border-b border-gray-200 dark:border-transparent flex flex-col sm:flex-row sm:items-center gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:flex-1 min-w-0`,children:[(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-bold mr-4`,children:[(0,$.jsx)(`i`,{className:`far fa-star mr-2 text-lofty-purple`}),`Investor Reviews`]}),(0,$.jsxs)(`span`,{className:`flex items-center text-sm mt-1 sm:mt-0 text-lofty-purple-600 dark:text-lofty-gray`,children:[ge(Number(ve)),(0,$.jsxs)(`span`,{className:`ml-2`,children:[ve,`/5`]}),(0,$.jsxs)(`span`,{className:`ml-2 text-gray-600 dark:text-lofty-gray/70`,children:[`(`,u.length,` `,u.length===1?`review`:`reviews`,`)`]})]})]}),v&&(0,$.jsxs)(`button`,{type:`button`,onClick:_,className:`inline-flex items-center justify-center gap-2 rounded-lg
25                    min-h-11 touch-manipulation bg-lofty px-4 py-2 text-sm font-semibold text-white shadow-subtle
26                    hover:bg-lofty-purple hover:shadow-md
27                    active:scale-[0.98]
28                    transition-all duration-150 sm:shrink-0`,children:[(0,$.jsx)(`i`,{className:`far fa-pen-to-square text-xs`}),`Write a review`]})]}),(0,$.jsxs)(`div`,{className:`p-5 md:p-6`,children:[u.length===0&&(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center py-6 text-lofty-purple-600 dark:text-lofty-gray`,children:[(0,$.jsx)(`i`,{className:`far fa-comment-dots text-lofty-purple text-2xl mb-3`}),(0,$.jsx)(`p`,{className:`text-base font-medium`,children:`No reviews yet`}),(0,$.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-lofty-gray/70 mt-1`,children:v?`Be the first investor to share your experience with this property.`:`Investors haven't shared their experience with this property yet.`}),v&&(0,$.jsxs)(`button`,{type:`button`,onClick:_,className:`inline-flex items-center justify-center gap-2 mt-4 rounded-lg
29                        min-h-11 touch-manipulation bg-lofty px-4 py-2 text-sm font-semibold text-white shadow-subtle
30                        hover:bg-lofty-purple hover:shadow-md
31                        active:scale-[0.98]
32                        transition-all duration-150`,children:[(0,$.jsx)(`i`,{className:`far fa-pen-to-square text-xs`}),`Write a review`]})]}),(0,$.jsx)(`div`,{children:ye.map((t,n)=>(0,$.jsxs)(`div`,{className:`py-4 border-b border-gray-200 dark:border-lofty-purple-700/30 last:border-b-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`a`,{href:`https://allo.info/account/${t.wallet}`,target:`_blank`,rel:`noopener noreferrer`,className:`font-semibold text-lofty-purple hover:text-lofty`,children:xe(t.wallet)}
32),(0,$.jsxs)(`span`,{className:`text-sm text-gray-600 dark:text-lofty-gray/70`,children:[`Investor holds: `,t.currentTokens||0,` `,R(t.currentTokens||0,`share`,`shares`),` `,t.currentTokens&&(e.numIssued||e.tokens)?`(${(t.currentTokens/(e.numIssued||e.tokens)*100).toFixed(2)}% ownership in property)`:``]})]}),(0,$.jsxs)(`div`,{className:`flex justify-between items-center mt-2`,children:[(0,$.jsxs)(`p`,{className:`font-medium flex items-center text-base text-lofty-purple-600 dark:text-lofty-gray`,children:[`Rating: `,ge(t.rating),` `,_e(t.rating),`/5`]}),(0,$.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-lofty-gray/70`,children:new Date(t.createdAt).toLocaleDateString()})]}),(0,$.jsx)(`p`,{className:`mt-1 text-base leading-relaxed text-lofty-purple-600 dark:text-lofty-gray`,children:t.text})]},Se(t,n)))}),be>0&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>ce(!0),className:`inline-flex min-h-11 touch-manipulation items-center text-lofty-purple font-medium text-sm mt-2 hover:text-lofty transition-colors`,children:`See ${be} more review${be===1?``:`s`}`}),se&&u.length>xo&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>ce(!1),className:`inline-flex min-h-11 touch-manipulation items-center text-lofty-purple font-medium text-sm mt-2 hover:text-lofty transition-colors`,children:`See less`})]})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`,children:[(0,$.jsx)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5 border-b border-gray-200 dark:border-transparent`,children:(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-bold`,children:[(0,$.jsx)(`i`,{className:`far fa-circle-question mr-2 text-lofty-purple`}),`Frequently Asked Questions`]})}),(0,$.jsx)(`div`,{className:`p-5 md:p-6`,children:re.map((e,t)=>(0,$.jsxs)(`div`,{className:`border-b border-gray-200 dark:border-lofty-purple-700/30 last:border-b-0`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>me(t=>t===e.q?null:e.q),className:`w-full touch-manipulation px-1 py-4 text-left flex items-center justify-between hover:text-lofty-purple
33                    transition-colors duration-200`,"aria-label":`FAQ question ${t+1}`,"aria-expanded":L===e.q,children:[(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-base`,children:e.q}),(0,$.jsx)(`i`,{className:`fa-solid text-sm ml-4 shrink-0 transition-transform duration-200 ${L===e.q?`fa-minus text-lofty-purple`:`fa-plus text-gray-500 dark:text-lofty-gray/60`}`})]}),L===e.q&&(0,$.jsx)(`p`,{className:`pb-4 px-1 text-sm leading-relaxed whitespace-pre-line text-gray-700 dark:text-lofty-gray/85`,children:e.a})]},e.q))})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`,children:[(0,$.jsx)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5 border-b border-gray-200 dark:border-transparent`,children:(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-bold`,children:[(0,$.jsx)(`i`,{className:`far fa-headset mr-2 text-lofty-purple`}),h?`Have questions?`:`Need Help?`]})}),(0,$.jsx)(`div`,{className:`p-5 md:p-6`,children:(0,$.jsxs)(`p`,{className:`text-base leading-relaxed text-lofty-purple-600 dark:text-lofty-gray`,children:[`Have other questions?`,` `,(0,$.jsx)(`a`,{href:`/how-it-works`,target:`_blank`,rel:`noopener noreferrer`,className:`text-lofty-purple underline underline-offset-4 hover:text-lofty transition-colors duration-200`,children:`Learn how Lofty works`})]})})]})]})]})},Co=e=>{let{listing:t,propertyInfo:n,averageHistoricalYield:r,hideTopSection:i=!1,mobileVariant:a=!1}=e,o=t.createdAt>1655168933e3,s=t.sale_price;t.avmHistory?.overall?.pctChange&&(s=H(s*(t.avmHistory.overall.pctChange+1),0,!0));let c=t.avmHistory?.overall?.pctChange?H(t.avmHistory?.overall?.pctChange*100,2):0,l=t.monthly_rent??0,u=[{label:`Property Taxes`,amount:(t.taxes??0)/12},{label:`Insurance`,amount:(t.insurance??0)/12},...t.utilities_water_sewer?[{label:`Lawn / Water / Sewer`,amount:t.utilities_water_sewer/12}]:[],{label:`Property Management`,amount:(t.management_fees??0)/12},...t.utilities?[{label:`Utilities`,amount:t.utilities/12}]:[],...t.llc_admin_fee_yearly?[{label:`LLC Admin & Filing`,amount:t.llc_admin_fee_yearly/12}]:[],...t.or_replenishment?[{label:`Operating Reserve Replenishment`,amount:t.or_replenishment/12}]:[]],d=u.reduce((e,t)=>
33e+t.amount,0),f=(t.cash_flow??0)/12,p=e=>U(e,{minimumFractionDigits:2,maximumFractionDigits:2});return(0,$.jsxs)(`div`,{children:[!i&&(0,$.jsxs)(`div`,{className:`rounded-xl shadow-xl bg-lofty-gray-100 dark:bg-lofty-purple-600 border border-gray-200 dark:border-lofty-purple-700`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between p-6 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700`,children:[(0,$.jsx)(`span`,{className:`font-bold text-xl md:text-2xl`,children:`Total Investment Value`}),(0,$.jsxs)(`span`,{className:`text-lofty-purple text-xl md:text-2xl`,children:[`$`,t.total_investment.toLocaleString()]})]}),(0,$.jsxs)(`div`,{className:`flex justify-between p-6 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700`,children:[(0,$.jsx)(`span`,{className:`font-bold md:text-lg`,children:`Underlying asset price`}),(0,$.jsxs)(`span`,{className:`md:text-lg flex items-center`,children:[(0,$.jsxs)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray`,children:[`$`,s.toLocaleString()]}),c!==0&&(0,$.jsx)(`div`,{className:`flex bg-lofty/20 text-lofty-purple px-2 py-1 ml-2 rounded-3xl`,children:(0,$.jsxs)(`span`,{className:`text-12 leading-3 flex items-center`,children:[(0,$.jsx)(`i`,{className:`mr-1 text-12 leading-4 fas ${c>0?`fa-arrow-up`:`fa-arrow-down`}`}),c,`%`]})})]})]}),!!t.closing_costs&&(0,$.jsxs)(`div`,{className:`flex justify-between p-6 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700`,children:[(0,$.jsxs)(`span`,{className:`font-bold md:text-lg`,children:[`Closing costs `,o&&`(includes inspection & appraisal costs)`]}),(0,$.jsxs)(`span`,{className:`md:text-lg`,children:[`$`,t.closing_costs.toLocaleString()]})]}),!!t.city_transfer_tax&&(0,$.jsxs)(`div`,{className:`flex justify-between p-6 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700`,children:[(0,$.jsx)(`span`,{className:`font-bold md:text-lg`,children:`City Transfer Tax`}),(0,$.jsxs)(`span`,{className:`md:text-lg`,children:[`$`,t.city_transfer_tax.toLocaleString()]})]}),!!t.llc_admin_fee_upfront&&(0,$.jsxs)(`div`,{className:`flex justify-between p-6 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700`,children:[(0,$.jsx)(`span`,{className:`font-bold md:text-lg`,children:`Upfront DAO LLC fees:`}),(0,$.jsx)(`span`,{className:`md:text-lg`,children:U(t.llc_admin_fee_upfront)})]}),(0,$.jsxs)(`div`,{className:`flex justify-between p-6 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700`,children:[(0,$.jsxs)(`span`,{className:`font-bold md:text-lg`,children:[`Operating reserve (`,t.maintenance_reserve>0?H((t.curr_maintenance_reserve??0)/t.maintenance_reserve*100,1,!0):0,`%)`]}),(0,$.jsxs)(`span`,{className:`md:text-lg`,children:[U(t.curr_maintenance_reserve??0),` / `,U(t.maintenance_reserve)]})]}),!!t.vacancy_reserve&&(0,$.jsxs)(`div`,{className:`flex justify-between p-6 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700`,children:[(0,$.jsxs)(`span`,{className:`font-bold md:text-lg`,children:[`Vacancy reserve (`,H(t.vacancy_reserve/s*100,1,!0),`%)`]}),(0,$.jsxs)(`span`,{className:`md:text-lg`,children:[`$`,t.vacancy_reserve.toLocaleString()]})]}),!!t.listing_fee&&(0,$.jsxs)(`div`,{className:`flex justify-between p-6 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700`,children:[(0,$.jsxs)(`span`,{className:`font-bold md:text-lg`,children:[`Lofty AI listing fee`,s>1e5?` (${(t.listing_fee/s*100).toFixed(0)}%)`:``]}),(0,$.jsxs)(`span`,{className:`md:text-lg`,children:[`$`,t.listing_fee.toLocaleString()]})]})]}),(0,$.jsxs)(`div`,{className:a?`mt-8 rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`:`mt-8 rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-gray-50 dark:bg-lofty-purple-800/20 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5`,children:(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dar
33k:text-lofty-gray text-lg font-bold flex items-center gap-2`,children:[(0,$.jsx)(`i`,{className:`far fa-chart-line text-lofty-purple`}),(0,$.jsx)(`span`,{children:`Returns`})]})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700/30`,children:[(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-medium`,children:`Projected Annual Return`}),(0,$.jsxs)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-semibold`,children:[W(r+(t.appreciation??0),2),`%`]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700/30`,children:[(0,$.jsx)(Sr,{className:`flex items-start justify-start mr-px p-0 cursor-pointer`,placement:`auto`,content:(0,$.jsx)(`span`,{className:`block max-w-[280px]`,children:`This is the average annualized rental yield an investor can expect for this property, based on a simple average of all historical yield data since the property has been listed on the Lofty exchange.`}),children:(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-medium`,children:`Average Rental Yield`}),(0,$.jsx)(`i`,{className:`far fa-circle-question text-xs text-lofty-gray-500 ml-2`})]})}),(0,$.jsxs)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-semibold`,children:[W(r??0,2),`%`]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700/30`,children:[(0,$.jsx)(Sr,{className:`flex items-start justify-start mr-px p-0 cursor-pointer`,placement:`auto`,content:(0,$.jsx)(`span`,{className:`block max-w-[280px]`,children:`Projected appreciation is a measure of the estimated increase in value of a property over a one year time period.`}),children:(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-medium`,children:`Projected Appreciation`}),(0,$.jsx)(`i`,{className:`far fa-circle-question text-xs text-lofty-gray-500 ml-2`})]})}),(0,$.jsxs)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-semibold`,children:[W(t.appreciation,2),`%`]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700/30`,children:[(0,$.jsx)(Sr,{className:`flex items-start justify-start mr-px p-0 cursor-pointer`,placement:`auto`,content:(0,$.jsx)(`span`,{className:`block max-w-[280px]`,children:`The current rental yield is this month's realized rental yield, annualized. This value is based on the lowest purchase price available at the time, so it can differ from the yield you see in your account based on your unique cost basis.`}),children:(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-medium`,children:`Current Rental Yield`}),(0,$.jsx)(`i`,{className:`far fa-circle-question text-xs text-lofty-gray-500 ml-2`})]})}),(0,$.jsxs)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-semibold`,children:[W(n?.coc??0,2),`%`]})]})]}),(0,$.jsxs)(`div`,{className:a?`mt-5 rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`:`mt-5 rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-gray-50 dark:bg-lofty-purple-800/20 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5`,children:(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-bold flex items-center gap-2`,children:[(0,$.jsx)(`i`,{className:`far fa-money-bill-wave text-lofty-purple`}),(0,$.jsx)(`span`,{children:`Monthly Operating Statement`})]})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 text-lofty-purple-600 dar
33k:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700/30`,children:[(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-medium`,children:`Gross Rent`}),(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-semibold tabular-nums`,children:p(l)})]}),u.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700/30`,children:[(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-medium`,children:e.label}),(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-semibold tabular-nums`,children:p(e.amount)})]},e.label)),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700/30`,children:[(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-medium`,children:`Total Expenses`}),(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-semibold tabular-nums`,children:p(d)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 text-lofty-purple-600 dark:text-lofty-gray border-b border-gray-200 dark:border-lofty-purple-700/30`,children:[(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray font-medium`,children:`Net Monthly Cash Flow`}),(0,$.jsx)(`span`,{className:`font-semibold tabular-nums ${f>=0?`text-lofty-green-500 dark:text-lofty-green`:`text-red-600 dark:text-red-400`}`,children:p(f)})]})]})]})},wo=7,To=.03,Eo=.055,Do=(e,t,n,r=wo)=>{let i=[],a=e;for(let e=1;e<=r;e+=1){let r=t+n*1.03**(e-1);a*=1+r/100,i.push(a)}return i};function Oo({averageHistoricalYield:e,mobileVariant:t=!1}){let[n,r]=(0,Q.useState)(`us20`),i=[{id:`us10`,value:8,label:`10 Yr US Avg`},{id:`us20`,value:4.5,label:`20 Yr US Avg`}],a=1e3,o=4.5,s=Math.round((e??0)*100)/100,[c,l]=(0,Q.useState)(s),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(a),[m,h]=(0,Q.useState)(o),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)({rentalYield:String(s),investmentAmount:`1000`,annualAppreciation:`4.5`});(0,Q.useEffect)(()=>{u||l(s)},[s,u]);let b=(0,Q.useCallback)((e,t)=>{let n=String(t);y(t=>t[e]===n?t:{...t,[e]:n})},[]);(0,Q.useEffect)(()=>{g!==`rentalYield`&&b(`rentalYield`,c)},[c,g,b]),(0,Q.useEffect)(()=>{g!==`investmentAmount`&&b(`investmentAmount`,f)},[f,g,b]),(0,Q.useEffect)(()=>{g!==`annualAppreciation`&&b(`annualAppreciation`,m)},[m,g,b]);let x=c,S=(0,Q.useMemo)(()=>Do(f,m,x,wo),[f,m,x]),C=(S[S.length-1]??0)*(1-Eo),w=f>0?((C/f)**(1/wo)-1)*100:0,T=Math.max(...S),E=Math.min(...S),[D,ee]=(0,Q.useState)(null),O=(0,Q.useCallback)(()=>ee(null),[]),k=(e,t)=>{let n=e.replace(/,/g,``).replace(/[^0-9.-]/g,``).replace(/(?!^)-/g,``);if(t===`currency`){let e=n.indexOf(`.`);e!==-1&&(n=n.slice(0,e))}else{let e=n.indexOf(`.`);e!==-1&&(n=`${n.slice(0,e+1)}${n.slice(e+1).replace(/\./g,``)}`)}return n},A=e=>{if(e===``||e===`-`||e===`.`||e===`-.`)return null;let t=Number(e);return Number.isFinite(t)?t:null},j=(e,t)=>{if(e===`rentalYield`){d(!0),l(t);return}if(e===`investmentAmount`){p(Math.max(0,Math.round(t)));return}r(`custom`),h(t)},te=(e,t,n)=>{let r=k(n,t);y(t=>t[e]===r?t:{...t,[e]:r});let i=A(r);i!==null&&j(e,i)},ne=(e,t)=>{_(t=>t===e?null:t);let i=A(v[e]);if(i===null){e===`rentalYield`?b(`rentalYield`,c):e===`investmentAmount`?b(`investmentAmount`,f):b(`annualAppreciation`,m);return}if(t===`currency`){let e=Math.max(0,Math.round(i));p(e),b(`investmentAmount`,e);return}let a=Math.round(i*100)/100;if(e===`rentalYield`){a!==c&&(d(!0),l(a)),b(`rentalYield`,a);return}(a!==m||n===`custom`)&&(r(`custom`),h(a)),b(`annualAppreciation`,a)},M=(e,t)=>Number.isFinite(e)?t===`currency`?Math.round(e).toLocaleString(`en-US`):e.toLocaleString(`en-US`,{maximumFractionDigits:2}):``,re=e=>e>=1e6?`$${(e/1e6).toFixed(1)}M`:e>=1e4?`$${Math.round(e/1e3).toLocaleString()}K`:e>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${Math.round(e).toLocaleString()}`,N=e=>{if(e.length<2)return e.length===1?`M ${e[0][0]} ${e[0][1]}`:``;let t=`M ${e[0][0]} ${e[0][1]}`;for(let n=0;n<e.length-1;n+=1){let r=e[n-1]??e[n],i=e[n],a=e[n+1],o=e[n+2]??a,s=i[0]+(a[0]-r[0])/6,c=i[1]+(a[1]-r[1])/6,l=a[0]-(o[0]-i[0])/6,u=a[
331]-(o[1]-i[1])/6;t+=` C ${s} ${c}, ${l} ${u}, ${a[0]} ${a[1]}`}return t},P=C-f,ie=w>=0,ae=ie?t?`text-emerald-600 dark:text-emerald-400`:`text-emerald-400`:t?`text-red-600 dark:text-red-400`:`text-red-400`,oe=()=>{r(`us20`),l(s),d(!1),p(a),h(o),_(null),y({rentalYield:String(s),investmentAmount:`1000`,annualAppreciation:`4.5`})};return(0,$.jsxs)(`section`,{className:t?`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 shadow-sm dark:shadow-none`:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-gray-50 dark:bg-lofty-purple-800/20`,children:[(0,$.jsxs)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-4 md:px-5 py-3.5 md:py-4 rounded-t-xl flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-base md:text-lg font-bold flex items-center`,children:[(0,$.jsx)(`i`,{className:`far fa-calculator mr-2 text-lofty-purple`}),(0,$.jsx)(`span`,{children:`Projected Returns Calculator`})]}),(0,$.jsxs)(`p`,{className:`text-[11px] md:text-xs leading-relaxed text-gray-500 dark:text-lofty-gray/60 mt-1 max-w-[34rem]`,children:[`Adjust the assumptions below to model how this property could grow over `,wo,` years.`]})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:oe,className:`hidden md:inline-flex items-center text-xs text-gray-500 dark:text-lofty-gray/60 hover:text-lofty
34            transition-colors duration-150 mt-1 shrink-0`,children:[(0,$.jsx)(`i`,{className:`fas fa-rotate-left mr-1.5`}),`Reset`]})]}),(0,$.jsxs)(`div`,{className:`p-3.5 sm:p-4 md:p-6`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-1 xl:grid-cols-[1fr_320px] gap-4 md:gap-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-3.5 md:space-y-4`,children:[(0,$.jsx)(`div`,{className:t?`rounded-xl border border-gray-200 dark:border-lofty-purple-700/55 bg-white dark:bg-lofty-purple-800/20 p-3.5 sm:p-4 md:p-5`:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/55 bg-gray-50 dark:bg-lofty-purple-800/20 p-3.5 sm:p-4 md:p-5`,children:(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-x-3 gap-y-3.5 md:gap-y-4`,children:[{id:`rentalYield`,label:`Rental Yield`,kind:`percent`,value:c},{id:`investmentAmount`,label:`Investment Amount`,kind:`currency`,value:f},{id:`annualAppreciation`,label:`Annual Appreciation`,kind:`percent`,value:m}].map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col cursor-text group`,children:[(0,$.jsx)(`span`,{className:`text-[10px] md:text-[11px] uppercase tracking-wider text-gray-500 dark:text-lofty-gray/60 mb-1.5 md:mb-2`,children:e.label}),(0,$.jsxs)(`div`,{className:`flex items-center rounded-lg md:rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-[#0A1233]/70 px-3.5 md:px-4 h-11 md:h-12
35                        transition-all duration-150
36                        group-hover:border-gray-300 dark:group-hover:border-lofty-purple-700
37                        focus-within:border-lofty focus-within:ring-2 focus-within:ring-lofty/30 focus-within:bg-white dark:focus-within:bg-[#0A1233]`,children:[e.kind===`currency`&&(0,$.jsx)(`span`,{className:`text-gray-500 dark:text-lofty-gray/50 text-base md:text-lg font-medium mr-2 select-none`,children:`$`}),(0,$.jsx)(`input`,{type:`text`,inputMode:e.kind===`currency`?`numeric`:`decimal`,value:g===e.id?v[e.id]:M(e.value,e.kind),onChange:t=>te(e.id,e.kind,t.target.value),onFocus:()=>_(e.id),onBlur:()=>ne(e.id,e.kind),className:`w-full bg-transparent text-left text-lofty-purple-600 dark:text-lofty-gray text-base md:text-lg font-semibold outline-none placeholder:text-gray-400 dark:placeholder:text-lofty-gray/40`}),e.kind===`percent`&&(0,$.jsx)(`span`,{className:`text-gray-500 dark:text-lofty-gray/50 text-base md:text-lg font-medium ml-2 select-none`,children:`%`})]})]},e.label))})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-[10px] md:text-[11px] uppercase tracking-wider text-gray-500 dark:text-lofty-gray/60 mb-2`,children:`Quick Appreciation Presets`}),(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-2.5`,children:i.map(e=>{let t=n===e.id;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{r(e.id),h(e.value)},"aria-pressed":t,className:[`relative rounded-xl border px-2.5 md:px-3 py-3 md:py-3.5 text-center flex flex-col items-center`,`transition-all duration-200`,t?`border-lofty bg-lofty/10 ring-2 ring-lofty/30`:`border-gray-200 dark:border-lofty-purple-700/60 bg-white dark:bg-lofty-purple-800/15 hover:border-lofty/70 hover:bg-lofty-purple-50 dark:hover:bg-lofty-purple-800/30`].join(` `),children:[t&&(0,$.jsx)(`i`,{className:`far fa-check absolute top-2 right-2.5 text-[10px] text-lofty`}),(0,$.jsxs)(`div`,{className:[`text-[15px] md:text-lg font-semibold leading-tight`,t?`text-lofty`:`text-lofty-purple-600 dar
37k:text-lofty-gray`].join(` `),children:[`+`,W(e.value,1),`%`]}),(0,$.jsx)(`div`,{className:`text-[10px] md:text-[11px] text-gray-600 dark:text-lofty-gray/70 mt-1 leading-snug`,children:e.label})]},e.id)})})]})]}),(0,$.jsxs)(`div`,{className:t?`rounded-xl border border-gray-200 dark:border-lofty-purple-700/55 bg-white dark:bg-lofty-purple-800/25 p-3.5 sm:p-4 md:p-5 h-full flex flex-col gap-3.5 md:gap-4`:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/55 bg-gray-50 dark:bg-lofty-purple-800/25 p-3.5 sm:p-4 md:p-5 h-full flex flex-col gap-3.5 md:gap-4`,children:[(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-[#0A1233] px-3.5 md:px-4 py-3 md:py-3.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`p`,{className:`text-[10px] md:text-[11px] uppercase tracking-wider text-gray-500 dark:text-lofty-gray/60`,children:`Annualized Return`}),(0,$.jsx)(`i`,{className:`fas ${ie?t?`fa-arrow-trend-up text-emerald-600 dark:text-emerald-400/80`:`fa-arrow-trend-up text-emerald-400/80`:t?`fa-arrow-trend-down text-red-600 dark:text-red-400/80`:`fa-arrow-trend-down text-red-400/80`} text-[10px]`})]}),(0,$.jsxs)(`p`,{className:`text-[28px] sm:text-3xl font-bold mt-1 leading-tight ${ae}`,children:[ie?`+`:``,W(w,1),`%`]}),(0,$.jsxs)(`p`,{className:`text-[10px] md:text-[11px] text-gray-500 dark:text-lofty-gray/60 mt-1`,children:[`per year over `,wo,` years`]})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-[#0A1233] px-3.5 md:px-4 py-3 md:py-3.5`,children:[(0,$.jsxs)(`p`,{className:`text-[10px] md:text-[11px] uppercase tracking-wider text-gray-500 dark:text-lofty-gray/60`,children:[wo,`-Year Projection`]}),(0,$.jsx)(`p`,{className:`text-[28px] sm:text-3xl font-bold mt-1 text-lofty-purple-600 dark:text-lofty-gray leading-tight`,children:z(C,{minimumFractionDigits:0,maximumFractionDigits:0})}),(0,$.jsxs)(`p`,{className:`text-[10px] md:text-[11px] mt-1 ${ie?t?`text-emerald-600 dark:text-emerald-400/80`:`text-emerald-400/80`:t?`text-red-600 dark:text-red-400/80`:`text-red-400/80`}`,children:[ie?`+`:`−`,z(Math.abs(P),{minimumFractionDigits:0,maximumFractionDigits:0}),(0,$.jsx)(`span`,{className:`text-gray-500 dark:text-lofty-gray/55`,children:` vs. initial `}),z(f,{minimumFractionDigits:0,maximumFractionDigits:0})]})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:oe,className:[`md:hidden mt-1 w-full rounded-lg border border-gray-200 dark:border-lofty-purple-700 px-4 py-3`,`text-sm font-semibold text-lofty-purple-600 dark:text-lofty-gray hover:border-lofty hover:text-lofty transition-colors duration-200`,t?`bg-white dark:bg-lofty-purple-600`:`bg-lofty-gray-100 dark:bg-lofty-purple-600`].join(` `),children:[(0,$.jsx)(`i`,{className:`fas fa-rotate-left mr-1.5`}),`Reset Calculator`]})]})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/55 bg-white dark:bg-[#0A1233]/80 p-3.5 sm:p-4 md:p-5 mt-4 md:mt-5 overflow-visible`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between mb-2.5 md:mb-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`text-[10px] md:text-[11px] uppercase tracking-wider text-gray-600 dark:text-lofty-gray/70`,children:[wo,`-Year Projection Trend`]}),(0,$.jsx)(`div`,{className:`text-[10px] md:text-[11px] text-gray-400 dark:text-lofty-gray/45 mt-0.5`,children:`Hover or tap the line to see year-by-year value`})]}),(0,$.jsxs)(`div`,{className:`hidden sm:flex items-center gap-1.5 text-[11px] text-gray-500 dark:text-lofty-gray/55`,children:[(0,$.jsx)(`span`,{className:`inline-block w-3 h-[2px] bg-[#9383FF] rounded-full`}),`Projected value`]})]}),(()=>{let e=Math.min(f,E),t=T,n=Math.max(t-e,1)*.08,r=e-n,i=t+n,a=i-r,o=e=>56+e/(S.length-1)*620,s=e=>224-(e-r)/a*200,c=S.map((e,t)=>[o(t),s(e)]),l=N(c),u=`${l} L ${c[c.length-1][0]} 224 L ${c[0][0]} 224 Z`,d=s(f);return(0,$.jsxs)(`svg`,{viewBox:`0 0 700 260`,className:`w-full h-[220px] sm:h-[240px] md:h-[260px]`,overflow:`visible`,onMouseLeave:O,children:[(0,$.jsxs)(`defs`,{children:[(0,$.jsxs)(`linearGradient`,{id:`chartAreaGradient`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:`#9383FF`,stopOpacity:`0.35`}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:`#9383FF`,stopOpacity:`0`})]}),(0,$.jsx)(`filter`,{id:`chartTooltipShadow`,x:`-50%`,y:`-50%`,width:`200%`,height:`200%`,children:(0,$.jsx)(`feDropShadow`,{dx:`0`,dy:`2`,stdDeviation:`3`,floodColor:`#000000`,floodOpacity:`0.35`})})]}),[0,.25,.5,.75,1].map(e=>{let t=224-e*200,n=r+a*e;return(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`line`,{x1:56,y1:t,x2:676,y2:t,stroke:`#2a335a`,strokeWidth:`1`,strokeDasharray:`2 4`}),(0,$.jsx)(`text`,{x:48,y:t+3,fill:`#8b94ad`,fontSize:`10`,textAnchor:`end`,children:re(n)})]},e)}),f>=r&&f<=i&&(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`line`,{x1:56,y1:d,x2:676,y2:d,stroke:`#5d6a91`,strokeWidth:`1`,strokeDasharray:`4 4`,opacity:`0.55`}),(0,$.jsxs)(`text`,{x:676,y:d-6,fill:`#8b94ad`,fontSize:`9`,textAnchor:`end`,fontWeight:`500`,children:[`Initial `,z(f,{minimumFractionDigits:0,maximumFractionDigits:0})]})]}),(0,$.jsx)(`path`,{d:u,fill:`url(#chartAreaGradient)`}),(0,$.jsx)(`path`,{d:l,fill:`none`,stroke:`#9383FF`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),S.map((e,t)=>{let n=o(t),r=s(e),i=D===t;return(0,$.jsxs)(`g`,{children:[i&&(0,$.jsx)(`line`,{x1:n,y1:24,x2:n,y2:224,stroke:`#9383FF`,strokeWidth:`1`,strokeDasharray:`3 3`,opacity:`0.5`}),(0,$.jsx)(`circle`,{cx:n,cy:r,r:i?6:4,fill:i?`#9383FF`:`#0E153D`,stroke:`#9383FF`,strokeWidth:`2.25`,className:`transition-all duration-150`})]},`pt-${t}`)}),D!==null&&(()=>{let e=D,t=S[e],n=o(e),r=s(t),i=n<116?56:n>676-120/2?556:n-120/2,a=Math.max(24,r-44-14);return(0,$.jsxs)(`g`,{style:{pointerEvents:`none`},filter:`url(#chartTooltipShadow)`,children:[(0,$.jsx)(`rect`,{x:i,y:a,width:120,height:44,rx:8,fill:`#141c44`,stroke:`#9383FF`,strokeOpacity:`0.6`,strokeWidth:`1`}),(0,$.jsxs)(`text`,{x:i+120/2,y:a+16,fill:`#a8b0c8`,fontSize:`10`,fontWeight:`500`,textAnchor:`middle`,children:[`Year `,e+1]}),(0,$.jsx)(`text`,{x:i+120/2,y:a+33,fill:`#ffffff`,fontSize:`13`,fontWeight:`700`,textAnchor:`middle`,children:z(t,{minimumFractionDigits:0,maximumFractionDigits:0})})]})})(),S.map((e,t)=>{let n=o(t),r=620/(S.length-1)/2;return(0,$.jsx)(`rect`,{x:n-r,y:24,width:r*2,height:200,fill:`transparent`,className:`curs
37or-pointer`,onMouseEnter:()=>ee(t)},`hit-${t}`)}),Array.from({length:wo},(e,t)=>t).map(e=>(0,$.jsx)(`text`,{x:o(e),y:242,fill:`#8b94ad`,fontSize:`10`,textAnchor:`middle`,fontWeight:D===e?700:500,children:`Yr ${e+1}`},`xl-${e}`))]})})()]}),(0,$.jsxs)(`div`,{className:`mt-4 md:mt-5 pt-3.5 md:pt-4 border-t border-gray-200 dark:border-lofty-purple-700/40 flex gap-2.5 md:gap-3`,children:[(0,$.jsx)(`i`,{className:`fas fa-circle-info text-gray-400 dark:text-lofty-gray/40 text-xs md:text-sm mt-0.5 shrink-0`}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{className:`text-[10px] md:text-[11px] leading-relaxed text-gray-500 dark:text-lofty-gray/55`,children:[`This calculator is for illustrative purposes only and displays a range of hypothetical investment outcomes based on the inputs you provide. Actual investment outcomes depend on many factors and cannot be determined before the investment period ends.`,(0,$.jsx)(`span`,{className:`text-gray-700 dark:text-lofty-gray/75 font-semibold`,children:` Historical performance is not indicative of future results.`})]}),(0,$.jsxs)(`p`,{className:`text-[10px] md:text-[11px] leading-relaxed text-gray-500 dark:text-lofty-gray/55`,children:[`The calculations assume a `,wo,`-year hold period and an average annual net operating income increase of `,W(To*100,0),`%. The 10- and 20-year averages are based on data from the Z
37HVI Single Family Homes Time Series and reflect averages for single-family homes in the 35th to 65th percentile by home price.`]})]})]})]})]})}var ko=({hidden:e,property:t,propertyInfo:n,averageHistoricalYield:r,mobileVariant:i=!1})=>{let a=t.monthly_rent??0,o=[t.taxes??0,t.insurance??0,t.utilities_water_sewer??0,t.management_fees??0,t.utilities??0,t.llc_admin_fee_yearly??0,t.or_replenishment??0].reduce((e,t)=>e+t,0)/12,s=a-o;return(0,$.jsxs)(`div`,{className:`${e?`hidden`:``} pt-4 space-y-5`,role:`tabpanel`,children:[(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`,children:[(0,$.jsx)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5 border-b border-gray-200 dark:border-transparent`,children:(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-bold flex items-center gap-2`,children:[(0,$.jsx)(`i`,{className:`far fa-chart-line text-lofty-purple-600 dark:text-lofty-purple`}),(0,$.jsx)(`span`,{children:`Projected Returns`})]})}),(0,$.jsx)(`div`,{className:`p-5 md:p-6`,children:(0,$.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-[300px_1fr] gap-4 md:gap-5 items-start`,children:[(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/50 bg-gray-50 dark:bg-lofty-purple-800/30 px-4 md:px-6 py-4 md:py-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-2 text-lofty-purple-600 dark:text-lofty-gray text-sm font-medium uppercase tracking-wide`,children:[(0,$.jsx)(`i`,{className:`far fa-chart-line text-lofty-purple-600 dark:text-lofty-purple`}),(0,$.jsx)(`span`,{children:`Total Return Model`})]}),(0,$.jsxs)(`div`,{className:`my-4 flex flex-col gap-2`,children:[(0,$.jsx)(`div`,{className:`rounded-lg border border-lofty-purple-50 dark:border-lofty-purple-700/50 bg-lofty-purple-50 dark:bg-lofty-purple-600/20 px-3 py-2 text-center text-lofty-purple-600 dark:text-lofty-gray font-medium`,children:`Annual Cash Flow`}),(0,$.jsx)(`div`,{className:`text-center text-lofty-purple-600 dark:text-lofty-purple font-semibold`,children:`+`}),(0,$.jsx)(`div`,{className:`rounded-lg border border-lofty-purple-50 dark:border-lofty-purple-700/50 bg-lofty-purple-50 dark:bg-lofty-purple-600/20 px-3 py-2 text-center text-lofty-purple-600 dark:text-lofty-gray font-medium`,children:`Appreciation`})]})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-lofty-purple-50 dark:border-lofty-purple-700/40 bg-lofty-purple-50 dark:bg-lofty-purple-800/15 p-4 md:p-5 text-lofty-purple-600 dark:text-lofty-gray text-sm md:text-base leading-relaxed`,children:[(0,$.jsx)(`p`,{className:`mb-3 text-lofty-purple-600 dark:text-lofty-gray font-semibold`,children:`Investing with Lofty can generate returns in two ways:`}),(0,$.jsxs)(`p`,{className:`mb-2 text-gray-700 dark:text-lofty-gray`,children:[(0,$.jsx)(`span`,{className:`font-semibold text-lofty-purple-600 dark:text-lofty-gray`,children:`1) Annual cash flow`}),` from rental income.`]}),(0,$.jsxs)(`p`,{className:`text-gray-700 dark:text-lofty-gray`,children:[(0,$.jsx)(`span`,{className:`font-semibold text-lofty-purple-600 dark:text-lofty-gray`,children:`2) Annual appreciation`}),` from long-term property value changes.`]})]})]})})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`,children:[(0,$.jsx)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5 border-b border-gray-200 dark:border-transparent`,children:(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-bold flex items-center gap-2`,children:[(0,$.jsx)(`i`,{className:`far fa-money-check-dollar-pen text-lofty-purple-600 dark:text-lofty-purple`}),(0,$.jsx)(`span`,{children:`Monthly Cash Flow`})]})}),(0,$.jsx)(`div`,{className:i?`p-4 md:p-6`:`p-5 md:p-6`,children:(0,$.jsxs)(`div`,{className:i?`grid grid-cols-3 gap-2 sm:gap-3`:`grid grid-cols-1 md:grid-cols-3 gap-3`,children:[(0,$.jsxs)(`div`,{className:i?`rounded-xl border border-gray-200 dark:border-lofty-purple-700/50 bg-gray-50 dark:bg-lofty-purple-800/30 p-3 md:px-5 md:py-4 min-w-0`:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/50 bg-gray-50 dark:bg-lofty-purple-800/30 px-4 md:px-5 py-3.5 md:py-4`,children:[(0,$.jsx)(`p`,{className:i?`text-lofty-purple-600 dar
37k:text-lofty-gray text-base sm:text-xl md:text-2xl font-bold tracking-tight tabular-nums truncate`:`text-lofty-purple-600 dark:text-lofty-gray text-xl md:text-2xl font-bold tracking-tight`,children:U(a,{maximumFractionDigits:0})}),(0,$.jsx)(`p`,{className:i?`text-xs sm:text-sm text-gray-600 dark:text-lofty-gray/70 mt-1`:`text-sm text-gray-600 dark:text-lofty-gray/70 mt-1`,children:`Monthly Rent`})]}),(0,$.jsxs)(`div`,{className:i?`rounded-xl border border-gray-200 dark:border-lofty-purple-700/50 bg-gray-50 dark:bg-lofty-purple-800/30 p-3 md:px-5 md:py-4 min-w-0`:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/50 bg-gray-50 dark:bg-lofty-purple-800/30 px-4 md:px-5 py-3.5 md:py-4`,children:[(0,$.jsx)(`p`,{className:i?`text-lofty-purple-600 dark:text-lofty-gray text-base sm:text-xl md:text-2xl font-bold tracking-tight tabular-nums truncate`:`text-lofty-purple-600 dark:text-lofty-gray text-xl md:text-2xl font-bold tracking-tight`,children:U(o,{maximumFractionDigits:0})}),(0,$.jsx)(`p`,{className:i?`text-xs sm:text-sm text-gray-600 dark:text-lofty-gray/70 mt-1`:`text-sm text-gray-600 dark:text-lofty-gray/70 mt-1`,children:`Monthly Expenses`})]}),(0,$.jsxs)(`div`,{className:i?`rounded-xl border border-gray-200 dark:border-lofty-purple-700/50 bg-gray-50 dark:bg-lofty-purple-800/30 p-3 md:px-5 md:py-4 min-w-0`:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/50 bg-gray-50 dark:bg-lofty-purple-800/30 px-4 md:px-5 py-3.5 md:py-4`,children:[(0,$.jsxs)(`div`,{className:i?`flex items-center gap-1.5`:`flex items-center gap-2`,children:[(0,$.jsx)(`p`,{className:i?`text-lofty-purple-600 dark:text-lofty-gray text-base sm:text-xl md:text-2xl font-bold tracking-tight tabular-nums truncate`:`text-lofty-purple-600 dark:text-lofty-gray text-xl md:text-2xl font-bold tracking-tight`,children:U(s,{maximumFractionDigits:0})}),s>0&&(0,$.jsx)(`i`,{className:`fas fa-arrow-trend-up text-lofty-green-500 dark:text-lofty-green ${i?`text-xs shrink-0`:`text-sm`}`})]}),(0,$.jsx)(`p`,{className:i?`text-xs sm:text-sm text-gray-600 dark:text-lofty-gray/70 mt-1`:`text-sm text-gray-600 dark:text-lofty-gray/70 mt-1`,children:`Net Monthly Cash Flow`})]})]})})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`,children:[(0,$.jsx)(`div`,{className:`bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5 border-b border-gray-200 dark:border-transparent`,children:(0,$.jsxs)(`h3`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-lg font-bold flex items-center gap-2`,children:[(0,$.jsx)(`i`,{className:`far fa-chart-column text-lofty-purple-600 dark:text-lofty-purple`}),(0,$.jsx)(`span`,{children:`Annual Appreciation`})]})}),(0,$.jsx)(`div`,{className:`p-5 md:p-6`,children:(0,$.jsxs)(`div`,{className:`rounded-xl border border-lofty-purple-50 dark:border-lofty-purple-700/50 bg-lofty-purple-50 dark:bg-lofty-purple-800/15 px-4 md:px-5 py-4 space-y-3 text-gray-700 dark:text-lofty-gray text-sm leading-relaxed`,children:[(0,$.jsxs)(`p`,{className:`max-w-4xl`,children:[`Based on the Zillow Value Home Index (ZHVI) Single Family Homes Time Series, single family homes appreciated an average of `,(0,$.jsx)(`span`,{className:`font-semibold text-lofty-purple-600 dark:text-lofty-gray`,children:`11% per year`}),` over the last 20 years (March 31, 2003 - March 31, 2023).`]}),(0,$.jsx)(`p`,{className:`max-w-4xl`,children:`This figure reflects a national benchmark for single family homes in the 35th to 65th home-price percentile range and may not represent this specific property's zip code. Real-world returns can also vary based on investment costs, hold period, and leverage.`}),(0,$.jsx)(`p`,{children:`Use the returns calculator below to explore how different assumptions can impact your hypothetical investment outcome.`})]})})]}),!t.isDaoOnly&&(0,$.jsx)(Oo,{averageHistoricalYield:r,mobileVariant:i}),!t.isDaoOnly&&(0,$.jsx)(Ka,{property:t,mobileCopy:i}),(0,$.jsx)(Co,{listing:t,propertyInfo:n,averageHistoricalYield:r,hideTopSection:!0,mobileVariant:i})]})},Ao=({text:e,tabPosition:t,currentTab:n,setCurrentTab:r})=>{let i=n===t;return(0,$.jsx)(`li`,{role:`presentation`,className:`mr-6 last:mr-0 md:mr-10 md:last:mr-0`,children:(0,$.jsx)(`button`,{onClick:()=>r(t),className:[`min-h-11 touch-manipulation whitespace-nowrap inline-block`,`text-base md:text-lg`,`py-3 px-1`,`border-b-[3px]`,`focus:outline-none active:opacity-70 transition-colors duration-200`,i?`text-lofty-purple border-lofty-purple font-bold`:`text-gray-500 dark:text-lofty-gray/60 border-transparent font-semibold hover:text-lofty-purple-600 dar
37k:hover:text-lofty-gray hover:border-lofty-purple-600/30 dark:hover:border-lofty-gray/30`].filter(Boolean).join(` `),type:`button`,role:`tab`,"aria-selected":i,children:e})},t)},jo=(0,Q.lazy)(()=>f(()=>import(`./PriceLineChart-CWNj0Tqt.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),Mo=(0,Q.lazy)(()=>f(()=>import(`./YieldLineChart-CVUQ9czY.js`).then(e=>e.n),__vite__mapDeps([24,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),No=[`1D`,`7D`,`30D`,`90D`,`1Y`,`All`],Po=[`3M`,`6M`,`9M`,`1Y`,`All`],Fo=`MMM yyyy`,Io=(e,t)=>{if(!e||e.length===0)return[];if(t===`All`)return e;let n=Date.now(),r={"1D":n-B.days(1),"7D":n-B.days(7),"30D":n-B.days(30),"90D":n-B.days(90),"1Y":n-B.days(365)};return e.filter(e=>e.t>=r[t])},Lo=(e,t)=>{if(!e||e.length===0)return[];if(t===`All`)return e;let n=Date.now(),r={"3M":n-B.days(90),"6M":n-B.days(180),"9M":n-B.days(270),"1Y":n-B.days(365)};return e.filter(e=>e.t>=r[t])},Ro=({pricePerToken:e,chartPoints:t,yieldData:n,hasFilledOrders:r,isSecondaryMarket:i})=>{let a=e>0,o=n.length>0,s=a&&o,[c,l]=(0,Q.useState)(a?`price`:`yield`),u=(0,Q.useDeferredValue)(c),d=c===`price`&&i&&r,[f,p]=(0,Q.useState)(`30D`),m=(0,Q.useDeferredValue)(f),[h,g]=(0,Q.useState)(`1Y`),_=(0,Q.useDeferredValue)(h),{ref:v,visible:y}=b(),[x,S]=(0,Q.useState)(!1),C=y||x;(0,Q.useEffect)(()=>{c===`price`&&!a&&o&&l(`yield`),c===`yield`&&!o&&a&&l(`price`)},[c,a,o]);let w=(0,Q.useMemo)(()=>Io(t,m),[t,m]),T=(0,Q.useMemo)(()=>Lo(n,_),[_,n]);if(!a&&!o)return(0,$.jsx)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 p-5 text-center shadow-sm dark:shadow-none`,children:(0,$.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-lofty-gray/70`,children:`Trading history will appear here once this property reaches the secondary market.`})});let E=e=>[`min-h-11 touch-manipulation whitespace-nowrap text-sm font-semibold py-2.5 px-1 mr-6 border-b-[3px] -mb-px transition-colors focus:outline-none active:opacity-70`,e?`text-lofty-purple border-lofty-purple`:`text-gray-500 dark:text-lofty-gray/60 border-transparent hover:text-lofty-purple-600 dark:hover:text-lofty-gray hover:border-lofty-purple-600/30 dark:hover:border-lofty-gray/30`].join(` `),D=e=>[`min-h-11 min-w-11 touch-manipulation px-2.5 py-1 rounded-full text-xs font-medium transition-colors active:scale-95`,e?`bg-lofty text-white dark:bg-lofty-purple-600 dark:text-lofty-purple shadow-sm`:`text-gray-500 dark:text-lofty-gray/60 hover:text-lofty-purple`].join(` `);return(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 p-4 shadow-sm dark:shadow-none`,children:[s&&(0,$.jsx)(`div`,{className:`-mx-4 px-4 mb-4 border-b border-gray-200 dark:border-lofty-purple-700/60`,children:(0,$.jsxs)(`div`,{className:`flex`,role:`tablist`,children:[(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":c===`price`,onClick:()=>{S(!0),l(`price`)},className:E(c===`price`),children:`Price`}),(0,$.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":c===`yield`,onClick:()=>{S(!0),l(`yield`)},className:E(c===`yield`),children:`Yield`})]})}),(0,$.jsxs)(`div`,{ref:v,className:`relative min-h-52`,children:[d&&(0,$.jsxs)(`span`,{"aria-hidden":`true`,className:`absolute right-2 top-2 z-10 inline-flex items-center gap-1 rounded-full bg-white/90 dark:bg-lofty-purple-800/70 px-2 py-0.5 text-[10px] font-semibold text-lofty-purple-600 dark:text-lofty-gray shadow-sm dark:shadow-none`,children:[(0,$.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5`,children:[(0,$.jsx)(`span`,{className:`absolute inset-0 rounded-full bg-lofty-green animate-ping opacity-75`}),(0,$.jsx)(`span`,{className:`relative h-1.5 w-1.5 rounded-full bg-lofty-green`})]}),`Live`]}),C&&(0,$.jsxs)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-52`,"aria-hidden":`true`}),children:[u===`price`&&a&&(0,$.jsx)(jo,{chartPoints:w,defaultPrice:e,heightClassName:`h-52`,disableZoom:!0,disableAnimation:!0,dateFormat:Fo}
37),u===`yield`&&o&&(0,$.jsx)(Mo,{data:T,heightClassName:`h-52`,disableZoom:!0,disableAnimation:!0,dateFormat:Fo})]})]}),(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:(c===`price`?No:Po).map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>{S(!0),c===`price`?p(e):g(e)},"aria-pressed":c===`price`?f===e:h===e,className:D(c===`price`?f===e:h===e),children:e},e))})]})},zo=`pointer-events-auto flex h-11 w-11 touch-manipulation items-center justify-center rounded-full backdrop-blur-md transition-colors`,Bo=`bg-white/85 text-lofty-purple-700 shadow-property hover:bg-white`,Vo=({title:e})=>{let t=s(),[n,r]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{let e=()=>{r(window.scrollY>220)};return window.addEventListener(`scroll`,e,{passive:!0}),e(),()=>window.removeEventListener(`scroll`,e)},[]),(0,$.jsx)(`div`,{className:[`lg:hidden`,`fixed top-0 left-0 right-0 z-40`,`pointer-events-none`,`transition-colors duration-200`,n?`bg-lofty-purple-800/95 backdrop-blur-md border-b border-lofty-purple-700/60`:`bg-transparent`].join(` `),children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2.5`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>{window.history.length>1?t(-1):t(`/marketplace`)},"aria-label":`Back`,className:`${zo} ${Bo} shrink-0`,children:(0,$.jsx)(`i`,{className:`fas fa-chevron-left text-base`})}),(0,$.jsx)(`div`,{className:[`flex-1 min-w-0 text-center px-2 transition-opacity duration-200`,n?`opacity-100`:`opacity-0`].join(` `),children:(0,$.jsx)(`p`,{className:`truncate text-sm font-semibold text-white`,children:e})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:async()=>{let t={title:e,text:`Check out ${e} on Lofty`,url:window.location.href},n=async()=>{try{await navigator.clipboard.writeText(window.location.href),mr.fire({icon:`success`,title:`Link copied to clipboard`})}catch{mr.fire({icon:`error`,title:`Could not share this link`})}};try{if(navigator.share){await navigator.share(t);return}await n()}catch(e){if(e instanceof DOMException&&e.name===`AbortError`)return;await n()}},"aria-label":`Share`,className:`${zo} ${Bo}`,children:(0,$.jsx)(`i`,{className:`fas fa-arrow-up-from-bracket text-base`})}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`h-11 w-11 shrink-0 invisible`})]})]})})},Ho=({tooltipText:e,className:t=`bg-lofty-gray-100 dark:bg-lofty-purple-600 text-lofty-purple-600 dark:text-lofty-gray border border-gray-200 dark:border-lofty-purple-700 p-2 rounded-md`})=>(0,$.jsx)(`div`,{className:`block max-w-350-px text-left ${t}`,children:typeof e==`string`?(0,$.jsx)(`span`,{children:e}):e}),Uo={"Latest share price":`fa-chart-line`,"Estimated value per share":`fa-scale-balanced`,"Trading activity":`fa-arrow-trend-up`,"Estimated property value":`fa-building-columns`,Investors:`fa-users`},Wo=(e,t=2)=>e===0?`-`:R(e,{minimumFractionDigits:t,round:t===0?`floor`:void 0}),Go=({headline:e,value:t,subtitle:n,tooltipText:r,valuePrecision:i,isModal:a,persistTooltip:o,showCurrency:s=!0})=>{let c=Uo[e]??`fa-chart-simple`,l=s&&t!==0,u=(0,$.jsxs)(`div`,{className:`flex h-full flex-col rounded-xl border border-gray-200 bg-white p-4 shadow-sm transition-colors duration-200 hover:border-lofty-purple/30 dark:border-lofty-purple-700/50 dark:bg-lofty-purple-800/35 dark:hover:border-lofty-purple/60
38        ${a?`lg:p-4`:`sm:p-5`}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-lofty-gray/60`,children:e}),(0,$.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-lofty-purple-50 text-lofty dark:bg-lofty/10 dark:text-lofty-purple`,children:(0,$.jsx)(`i`,{className:`far ${c} text-[11px]`})})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-baseline gap-1 text-lofty-purple-600 dark:text-lofty-gray`,children:[l&&(0,$.jsx)(`span`,{className:`text-base font-semibold leading-none`,children:`$`}),(0,$.jsx)(`span`,{className:`text-2xl font-bold leading-none tracking-tight sm:text-[28px]`,children:Wo(t,i)})]}),(0,$.jsx)(`div`,{className:`mt-2 text-xs leading-5 text-gray-500 dark:text-lofty-gray/60`,children:n})]});
38return r?(0,$.jsx)(Sr,{placement:`top`,persist:o,content:(0,$.jsx)(Ho,{tooltipText:r,className:`max-w-[280px] rounded-xl border border-gray-200 bg-white p-3.5 text-sm leading-5 text-gray-600 shadow-md dark:border-lofty-purple-700/50 dark:bg-lofty-purple-800 dark:text-lofty-gray/75`}),children:u}):u},Ko=({summary:e,expanded:t,hasRange:n,onToggle:r,children:i})=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-y-1 text-xs`,children:[e&&(0,$.jsx)(`span`,{children:e}),n&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,"aria-expanded":t,onClick:e=>{e.stopPropagation(),r()},className:`mt-1 w-fit text-xs font-semibold text-lofty-purple hover:text-lofty dark:text-lofty-purple dark:hover:text-lofty-gray`,children:t?`Hide range`:`View range`}),t&&(0,$.jsx)(`div`,{className:`mt-1 flex flex-col gap-y-1 text-gray-500 dark:text-lofty-gray/60`,children:i})]})]}),qo=({propertyInfo:e,property:t,pricing:n,isModal:r})=>{let[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),c=Da(async()=>(await Tt(t.id)).data,{enabled:!!t?.id,deps:[t.id]}).data,l=Da(async()=>fr({queryKey:[`propertyOraclePrice`,{id:t.id}]}),{enabled:!!t?.id,deps:[t.id]}),u=l.data?.pricePerToken?.mid??0,d=l.data?.pricePerToken?.low??0,f=l.data?.pricePerToken?.high??0,p=(c?.numIssued??t.numIssued??t.tokens)||t.tokens,m=e?.lastPrice??0,h=t.tokens*(n.startingPrice??0),g=t.totalInvestors??0,_=d>0||f>0,v=(0,$.jsxs)(Ko,{summary:_?`Based on recent trading and third-party estimates.`:void 0,expanded:i,hasRange:_,onToggle:()=>a(e=>!e),children:[d>0&&(0,$.jsxs)(`span`,{children:[`Low estimate: $`,R(d,{minimumFractionDigits:0,maximumFractionDigits:2})]}),f>0&&(0,$.jsxs)(`span`,{children:[`High estimate: $`,R(f,{minimumFractionDigits:0,maximumFractionDigits:2})]})]}),y=u>0?u:(c?.marketCap??0)>0&&p>0?(c?.marketCap??0)/p:n.startingPrice??0,b=n.bestBuyPrice>0?n.bestBuyPrice:c?.bestBid??0,x=n.bestSellPrice>0?n.bestSellPrice:c?.bestAsk??0,S=b>0&&x>0?(b+x)/2:0,C=m>0?m:S>0?S:u,w=C>0?C*t.tokens:c?.marketCap??h,T=b>0?b*t.tokens:0,E=x>0?x*t.tokens:0,D=t.numIssued!==void 0&&t.numIssued!==null&&t.numIssued>0?`${R(t.numIssued,{minimumFractionDigits:0,maximumFractionDigits:0})}/${R(t.tokens,{minimumFractionDigits:0,maximumFractionDigits:0})} shares`:Me(t.tokens,`share`).phrase,ee=(0,$.jsxs)(Ko,{summary:D,expanded:o,hasRange:T>0&&E>0,onToggle:()=>s(e=>!e),children:[T>0&&(0,$.jsxs)(`span`,{children:[`Low (best bid): $`,R(T,{minimumFractionDigits:0,maximumFractionDigits:0})]}),E>0&&(0,$.jsxs)(`span`,{children:[`High (best ask): $`,R(E,{minimumFractionDigits:0,maximumFractionDigits:0})]})]});return(0,$.jsx)(`section`,{id:`orderbook-components-topsummary`,className:`rounded-xl border border-gray-200 bg-gray-50 p-3 shadow-sm dark:border-lofty-purple-700/50 dark:bg-lofty-purple-800/30 sm:p-4`,children:(0,$.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,$.jsx)(Go,{headline:`Latest share price`,value:m,subtitle:`From the most recent completed trade.`,tooltipText:`The most recent price someone paid or received for one share of this property.`,isModal:r}),(0,$.jsx)(Go,{headline:`Estimated value per share`,value:H(y),subtitle:v,tooltipText:`An estimate of what one share may be worth today. We use recent Lofty trading activity and third-party property value estimates to calculate this range.`,
38isModal:r}),(0,$.jsx)(Go,{headline:`Investors`,value:g,valuePrecision:0,showCurrency:!1,subtitle:`Currently own shares of this property.`,tooltipText:`The number of investors who currently own shares of this property.`,isModal:r}),(0,$.jsx)(Go,{headline:`Estimated property value`,value:w,valuePrecision:0,subtitle:ee,tooltipText:`An estimate of the property’s value on Lofty: the last traded share price multiplied by the total number of shares for the property. It may differ from what the home would sell for in the traditional real estate market. The x/y shares label shows how many shares investors currently own out of the total possible shares.`,isModal:r})]})})},Jo=10,Yo=5,Xo=e=>z(H(e,2,!1),{minimumFractionDigits:2}),Zo=e=>`${R(e,{minimumFractionDigits:0})} ${e===1?`share`:`shares`}`,Qo=({title:e,trailing:t,children:n})=>(0,$.jsxs)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 overflow-hidden shadow-sm dark:shadow-none`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 bg-gray-50 dark:bg-lofty-purple-700/30 px-5 py-3.5`,children:[(0,$.jsx)(`h2`,{className:`text-lofty-purple-600 dark:text-lofty-gray text-base font-bold`,children:e}),t]}),(0,$.jsx)(`div`,{className:`p-4`,children:n})]}),$o=({order:e,direction:t,maxQty:n,bestLabel:r})=>{let i=Math.max(3,Math.floor(e.quantity/n*100)),a=t===Se.Buy?`rgba(111, 207, 151, 0.16)`:`rgba(235, 87, 87, 0.16)`,o=t===Se.Buy?`text-lofty-green`:`text-lofty-red`;return(0,$.jsxs)(`div`,{className:`grid grid-cols-2 items-center rounded-lg px-3 py-2 text-sm tabular-nums ${r?`ring-1 ring-lofty-purple/20`:``}`,style:{background:`linear-gradient(to left, ${a} ${i}%, transparent ${i}%)`},children:[(0,$.jsxs)(`span`,{className:`font-semibold ${o}`,children:[Xo(e.price),r&&(0,$.jsx)(`span`,{className:`ml-2 rounded-full bg-white/80 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-gray-500 ring-1 ring-gray-200 dark:bg-lofty-purple-800/80 dark:text-lofty-gray/60 dark:ring-lofty-purple-700/60`,children:r})]}),(0,$.jsx)(`span`,{className:`text-right text-lofty-purple-600 dark:text-lofty-gray`,children:Zo(e.quantity)})]})},es=({orderBook:e})=>{let t=e?.orderBook?.buyOrders??[],n=e?.orderBook?.sellOrders??[],r=(0,Q.useMemo)(()=>[...t].sort((e,t)=>t.price-e.price),[t]),i=(0,Q.useMemo)(()=>[...n].sort((e,t)=>e.price-t.price),[n]),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),l=Math.max(1,...t.map(e=>e.quantity)),u=Math.max(1,...n.map(e=>e.quantity)),d=a?r:r.slice(0,Yo),f=[...s?i:i.slice(0,Yo)].reverse(),p=i[0]?.id,m=r[0]?.id,h=r[0]?.price??0,g=i[0]?.price??0,_=h>0&&g>0?g-h:null,v=_===null?void 0:(0,$.jsxs)(`span`,{className:`rounded-full bg-white px-2 py-0.5 text-[11px] font-semibold text-lofty-purple-600 ring-1 ring-gray-200 dark:bg-lofty-purple-800/80 dark:text-lofty-gray dark:ring-lofty-purple-700/60`,children:[`Spread `,Xo(_)]});return t.length===0&&n.length===0?(0,$.jsx)(Qo,{title:`Open orders`,children:(0,$.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-lofty-gray/60 text-center py-2`,children:`No open orders right now.`})}):(0,$.jsxs)(Qo,{title:`Open orders`,trailing:v,children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 mb-1.5`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-lofty-red`,children:`Sellers asking`}),(0,$.jsxs)(`div`,{className:`grid min-w-[112px] grid-cols-2 gap-3 text-right text-[10px] uppercase tracking-wide text-gray-500 dark:text-lofty-gray/50`,children:[(0,$.jsx)(`span`,{children:`Price`}),(0,$.jsx)(`span`,{children:`Shares`})]})]}),n.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-sm text-gray-500 dark:text-lofty-gray/50`,children:`No sell orders`}):(0,$.jsxs)($.Fragment,{children:[i.length>Yo&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>c(e=>!e),className:`block min-h-11 touch-manipulation w-full text-center text-xs font-semibold text-lofty-purple hover:text-lofty py-2`,children:s?`Show less`:`Show ${i.length-Yo} more`}),f.map(e=>(0,$.jsx)($o,{order:e,direction:Se.Sell,maxQty:u,bestLabel:e.id===p?`Best ask`:void 0},e.id))]})]}),_!==null&&(0,$.jsxs)(`div`,{className:`my-2 flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex-1 border-t border-gray-200 dark:border-lofty-purple-700/60`}),(0,$.jsxs)(`span`,{className:`text-[10px] font-medium uppercase tracking-wide text-gray-500 dark:text-lofty-gray/50 tabular-nums`,children:[`Spread `,Xo(_)]}),(0,$.jsx)(`div`,{className:`flex-1 border-t border-gray-200 dark:border-lofty-purple-700/60`})]}),(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 mb-1.5`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-lofty-green`,children:`Buyers bidding`}),(0,$.jsxs)(`div`,{className:`grid min-w-[112px] grid-cols-2 gap-3 text-right text-[10px] uppercase tracking-wide text-gray-500 dark:text-lofty-gray/50`,children:[(0,$.jsx)(`span`,{children:`Price`}),(0,$.jsx)(`span`,{children:`Shares`})]})]}),t.length===0?(0,$.jsx)(`p`,{className:`px-3 py-2 text-sm text-gray-500 dark:text-lofty-gray/50`,children:`No buy orders`}):(0,$.jsxs)($.Fragment,{children:[d.map(e=>(0,$.jsx)($o,{order:e,direction:Se.Buy,maxQty:l,bestLabel:e.id===m?`Best bid`:void 0},e.id)),r.length>Yo&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`block min-h-11 touch-manipulation w-full text-center text-xs font-semibold text-lofty-purple hover:text-lofty py-2`,children:a?`Show less`:`Show ${r.length-Yo} more`})]})]})]})},ts=({propertyInfo:e})=>{let t=(0,Q.useMemo)(()=>[...e?.transactions??[]].sort((e,t)=>
38t.updatedAt-e.updatedAt).reduce((e,t)=>(!t.type&&t.swappedAmount&&t.status===`completed`?e.push({...t,type:Se.Buy},{...t,type:Se.Sell}):e.push(t),e),[]),[e?.transactions]),n=t.slice(0,Jo);return t.length===0?(0,$.jsx)(Qo,{title:`Recent trades`,children:(0,$.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-lofty-gray/60 text-center py-2`,children:`No trades yet.`})}):(0,$.jsxs)(Qo,{title:`Recently filled orders`,children:[(0,$.jsx)(`div`,{className:`flex flex-col`,children:n.map((e,t)=>{let n=e.type===Se.Buy;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr_auto] items-center gap-3 py-2.5 border-b border-gray-200 dark:border-lofty-purple-700/30 last:border-b-0`,children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-flex h-7 w-7 items-center justify-center rounded-full text-xs ${n?`bg-lofty-green/15 text-lofty-green`:`bg-lofty-red/15 text-lofty-red`}`,children:(0,$.jsx)(`i`,{className:`fas ${n?`fa-arrow-down`:`fa-arrow-up`}`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-semibold text-lofty-purple-600 dark:text-lofty-gray capitalize`,children:e.type??`trade`}),(0,$.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-lofty-gray/60 tabular-nums`,children:Zo(e.quantity)})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-gray-500 dark:text-lofty-gray/50 tabular-nums`,children:gn(e.updatedAt,`MMM d, yyyy`)})]}),(0,$.jsx)(`span`,{className:`text-sm font-semibold text-lofty-purple-600 dark:text-lofty-gray tabular-nums`,children:Xo(e.price)})]},`${e.id}-${t}`)})}),(0,$.jsx)(`p`,{className:`mt-3 text-center text-xs text-gray-500 dark:text-lofty-gray/60`,children:`Only showing most recent trades`})]})},ns=({property:e,orderBook:t,propertyInfo:n,pricing:r,isSecondaryMarket:i,hidden:a})=>i?n?(0,$.jsxs)(`div`,{className:`${a?`hidden`:``} pt-4 flex flex-col gap-4`,role:`tabpanel`,children:[(0,$.jsx)(qo,{property:e,propertyInfo:n,pricing:r,isModal:!1}),(0,$.jsx)(es,{orderBook:t}),(0,$.jsx)(ts,{propertyInfo:n})]}):(0,$.jsx)(`div`,{className:`${a?`hidden`:``} pt-4 flex flex-col gap-4`,role:`tabpanel`,children:(0,$.jsx)(Qo,{title:`Order book`,children:(0,$.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-lofty-gray/60 text-center py-2`,children:`Loading order book…`})})}):(0,$.jsx)(`div`,{className:`${a?`hidden`:``} pt-4 flex flex-col gap-4`,role:`tabpanel`,children:(0,$.jsx)(Qo,{title:`Order book`,children:(0,$.jsxs)(`div`,{className:`py-2 text-center`,children:[(0,$.jsx)(`i`,{className:`far fa-chart-simple text-lofty-purple text-2xl`}),(0,$.jsx)(`p`,{className:`mt-3 text-base font-semibold text-lofty-purple-600 dark:text-lofty-gray`,children:`Trading has not opened yet`}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-gray-600 dark:text-lofty-gray/65`,children:`The order book appears once this property reaches the secondary market and investors can place buy and sell orders.`})]})})}),rs=({stat:e})=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-medium uppercase tracking-wide text-gray-500 dark:text-lofty-gray-400 truncate`,children:e.label}),(0,$.jsx)(`span`,{className:`text-base font-semibold text-lofty-purple-600 dark:text-lofty-gray tabular-nums`,children:e.value})]}),is=({property:e,propertyInfo:t,pricePerToken:n,averageHistoricalYield:r})=>{let i=!!e.isDaoOnly,a=t?.coc??e.coc??0,o=[{id:`share-price`,label:`Share price`,value:n>0?z(H(n,2,!1),{minimumFractionDigits:2}):`—`},!i&&{id:`avg-yield`,label:`Avg yield`,value:r>0?`${H(r,2,!1)}%`:`—`},!i&&{id:`current-yield`,label:`Current yield`,value:`${H(a,2,!1)}%`}].filter(Boolean);return o.length===0?null:(0,$.jsx)(`div`,{className:`rounded-xl border border-gray-200 dark:border-lofty-purple-700/40 bg-white dark:bg-lofty-purple-800/20 p-5 shadow-sm dark:shadow-none`,children:(0,$.jsx)(`div`,{className:`grid grid-cols-3 gap-3`,children:o.map(e=>(0,$.jsx)(rs,{stat:e},e.id))})})},as=({property:e,pricePerToken:t,averageHistoricalYield:n,showOrderBookLink:r,openOrderBookModal:i,userOrderData:a,kycVerified:o,tradingDisabled:s,interactive:c,hasBottomTabBar:l,onRefreshUserOrderData:u,orderRequestRef:d})=>{let{isComingSoon:f,isSold:p}=D(e),m=y(Pa),h=N(),g=(a?.properties?.[e.id]?.orderValidation?.propertyAssetBalance??0)>0,_=f&&!p,v={bottom:l?`var(--mobile-bottom-tab-bar-height, 0px)`:`0px`,paddingBottom:l?`0px`:`var(--safe-area-inset-bottom, 0px)`};return m.inProgress?null:_?(0,$.jsx)(Ha,{variant:`small`,interactive:c,price:t,averageHistoricalYield:n,showOrderBookLink:r,openOrderBookModal:i,userOrderData:a,kycVerified:o,tradingDisabled:s,disableSticky:!0,onRefreshUserOrderData:u,orderRequestRef:d,renderTrigger:({onBuyClick:e,buyDisabled:t})=>(0,$.jsx)(`div`,{className:`lg:hidden fixed left-0 right-0 z-40 border-t border-lofty-purple/10 bg-white/95 backdrop-blur-md dark:border-white/10 dark:bg-lofty-purple-800/95`,style:v,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pl-4 pr-16 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-lofty-purple-600/70 dark:text-white/50`,children:`Coming soon`}),(0,$.jsx)(`p`,{className:`text-base font-semibold text-lofty-purple-600 dar
38k:text-white`,children:`Be the first to invest`})]}),(0,$.jsx)(`button`,{type:`button`,onClick:e,disabled:t||!c,className:`min-h-[44px] touch-manipulation rounded-xl bg-lofty px-5 text-sm font-semibold text-white shadow-[0_2px_12px_rgba(77,63,237,0.3)] transition-colors hover:bg-lofty-purple active:scale-[0.98] disabled:bg-lofty-gray disabled:shadow-none dark:disabled:bg-white/15 dark:disabled:text-white/40`,children:`Notify me`})]})})}):(0,$.jsx)(Ha,{variant:`small`,interactive:c,price:t,averageHistoricalYield:n,showOrderBookLink:r,openOrderBookModal:i,userOrderData:a,kycVerified:o,tradingDisabled:s,disableSticky:!0,onRefreshUserOrderData:u,orderRequestRef:d,renderTrigger:({onBuyClick:e,onSellClick:r,buyDisabled:i,sellDisabled:a})=>(0,$.jsx)(`div`,{className:`lg:hidden fixed left-0 right-0 z-40 border-t border-lofty-purple/10 bg-white/95 backdrop-blur-md shadow-[0_-8px_28px_rgba(5,12,48,0.16)] dark:border-white/10 dark:bg-lofty-purple-800/95 dark:shadow-[0_-8px_28px_rgba(0,0,0,0.5)]`,style:v,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 text-left`,"aria-label":`Share price details`,children:[(0,$.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-lofty-purple-600/70 dark:text-white/50`,children:`Share price`}),(0,$.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xl font-bold leading-tight tracking-tight text-lofty tabular-nums dark:text-white`,children:t>0?z(H(t,2,!1),{minimumFractionDigits:2}):`—`}),n>0&&(0,$.jsxs)(`span`,{className:`truncate text-[11px] font-medium text-lofty-purple-600/70 tabular-nums dark:text-white/55`,children:[H(n,2,!1),`% yield`]})]}),h&&(0,$.jsx)(`span`,{className:`mt-1 inline-block rounded-full bg-lofty/10 px-2 py-0.5 text-[10px] font-semibold text-lofty dark:bg-lofty-purple-500/25 dark:text-lofty-purple-100`,children:`Buy $50, get $50 free`})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:e,disabled:i||!c,className:[`touch-manipulation rounded-xl bg-lofty text-white font-semibold transition-colors active:scale-[0.98]`,`min-h-[44px] hover:bg-lofty-purple disabled:bg-lofty-gray disabled:shadow-none`,`shadow-[0_2px_12px_rgba(77,63,237,0.3)] dark:disabled:bg-white/15 dark:disabled:text-white/40`,g?`text-sm px-5`:`text-base px-7`].join(` `),children:`Buy`}),(0,$.jsx)(`button`,{type:`button`,onClick:r,disabled:a||!c,"aria-label":`Sell shares`,className:[`touch-manipulation rounded-xl border border-lofty/60 bg-white text-lofty font-semibold transition-colors active:scale-[0.98]`,`min-h-[44px] hover:border-lofty hover:bg-lofty-purple-50`,`disabled:border-lofty-purple/30 disabled:text-lofty-purple-600/40`,`dark:border-white/25 dark:bg-transparent dark:text-white dark:hover:border-white/60 dark:hover:bg-white/10`,`dark:disabled:border-white/10 dark:disabled:text-white/30`,g?`text-sm px-5`:`text-xs px-3`].join(` `),children:`Sell`})]})]})})})},os=({filled:e})=>(0,$.jsx)(`i`,{className:`${e?`fas`:`far`} fa-star text-lofty-purple text-xs`}),ss=e=>{let t=Math.floor(e);return Array.from({length:5}).map((e,n)=>(0,$.jsx)(os,{filled:n<t},n))},cs=`flex h-11 w-11 touch-manipulation shrink-0 items-center justify-center rounded-full border border-lofty-purple-700/15 bg-white/80 dark:border-lofty-purple-500/30 dark:bg-lofty-purple-700/40 transition-colors`,ls=({addressLine1:e,addressLine2:t,averageRating:n,reviewCount:r,showReviews:i,onReviewClick:a,onWriteReview:o,isAuth:s,isWatchlisted:c,hasAlerts:l,onWatchlistToggle:u,onAlertToggle:d})=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsx)(`h1`,{className:`min-w-0 flex-1 text-2xl font-bold text-lofty-purple-600 dark:text-lofty-gray leading-tight tracking-tight`,children:e}),s&&u&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:u,"aria-label":c?`Remove from watchlist`:`Save to watchlist`,"aria-pressed":c,className:cs,children:(0,$.jsx)(`i`,{className:`${c?`fas text-lofty-purple`:`far text-lofty-gray-700 dark:text-lofty-gray`} fa-heart text-base transition-colors`})}),c&&d&&(0,$.jsx)(`button`,{type:`button`,onClick:d,"aria-label":l?`Disable price alerts`:`Enable price alerts`,"aria-pressed":l,className:cs,children:(0,$.jsx)(`i`,{className:`${l?`fas text-yellow-500`:`far text-lofty-gray-700 dark:text-lofty-gray`} fa-bell text-base transition-colors`})})]})]}),t&&(0,$.jsx)(`p`,{className:`text-base text-gray-600 dark:text-lofty-gray/80 leading-snug`,children:t}),i&&r>0&&(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex min-h-11 touch-manipulation min-w-0 items-center gap-1.5 text-sm text-lofty-purple-600 dar
38k:text-lofty-gray hover:text-lofty-purple transition-colors`,children:[(0,$.jsx)(`span`,{className:`flex items-center gap-0.5`,children:ss(Number(n))}),(0,$.jsx)(`span`,{className:`font-semibold`,children:n}),(0,$.jsx)(`span`,{className:`text-gray-500 dark:text-lofty-gray/70`,children:`·`}),(0,$.jsxs)(`span`,{className:`underline underline-offset-2 text-gray-600 dark:text-lofty-gray/80`,children:[r,` `,r===1?`review`:`reviews`]})]}),o&&(0,$.jsx)(`button`,{type:`button`,onClick:o,className:`min-h-11 touch-manipulation shrink-0 text-sm font-semibold text-lofty-purple underline underline-offset-2`,children:`Write a review`})]})]}),us={"9 country club ln n":`https://www.airbnb.com/rooms/787566047369924760`,"88 madison ave":`https://www.airbnb.com/rooms/28868857`,"2208 murray ave":`https://www.airbnb.com/rooms/48625738`,"6601 e hearn rd":`https://www.airbnb.com/rooms/746195521284356998`,"3761 jade ave":`https://www.airbnb.com/rooms/949523090151519006`,"581 san francisco st":`https://www.airbnb.com/rooms/867554343434536160`,"230 seacrest ln":`https://www.airbnb.com/rooms/953574064762289816`,"503 colorado street unit 4":`https://www.airbnb.com/rooms/781291789881263806`,"14018 arcadia road ne":`https://www.airbnb.com/rooms/47431712`,"2221 e chase st":`https://www.airbnb.com/rooms/1026811102614021650`,"11604 d k ranch rd":`https://www.airbnb.com/rooms/1111158091075903436`,"86 madison ave":`https://www.airbnb.com/rooms/1298067362380112500`,"217 mcclallen dr":`https://www.airbnb.com/rooms/729713`,"90 madison ave":`https://www.airbnb.com/rooms/1061814091773376272`,"222 57th st":`https://www.airbnb.com/rooms/1043041225996074062`,"25 rocky ridge rd":`https://www.airbnb.com/rooms/150659`,"84 madison ave":`https://www.airbnb.com/rooms/1448501719166920474`,"22164 umland cir":`https://www.airbnb.com/rooms/22449666`,"tepuy juan dolio 102 b":`https://www.airbnb.com/rooms/1382774625348827312`},ds=e=>(e??``).trim().toLowerCase(),fs=e=>e.airbnbUrl?e.airbnbUrl:us[ds(e.address_line1)]??null,ps=({isActive:e,isComingSoon:t,hasSellOrders:n,isSold:r})=>{let i=``;return t&&(i=`Coming soon`),r&&t&&(i=`Sold`),i?(0,$.jsx)(`div`,{className:[`self-start border-2 rounded-2xl sm:rounded-3xl transition-colors duration-200`,`text-xs sm:text-lg lg:text-sm xl:text-lg 2xl:text-2xl !leading-none`,`px-3 py-1.5 sm:py-2.5 md:px-4.5 2xl:px-6 2xl:py-3`,t?`bg-lofty-gray-100 dark:bg-lofty-purple-600 text-gray-500 dark:text-lofty-gray/60 border-gray-200 dark:border-lofty-purple-700`:``,r&&t?`bg-white dark:bg-lofty-purple-800 text-gray-500 dark:text-lofty-gray/60 border-gray-200 dark:border-lofty-purple-700`:``].filter(Boolean).join(` `),children:i}):null},ms=({property:e,isActive:t,isComingSoon:n,isSold:r,hasSellOrders:i})=>{let a=Cr({propertyId:e.id,propertyType:e.property_type||void 0,isOccupied:e.is_occupied,isDelinquent:e.is_delinquent,coc:e.coc,isOwnerOccupied:e.isOwnerOccupied,isSellerBuyBack:e.isSellerBuyBack,currentLoan:e.current_loan}),o=fs(e);return a.length===0&&!n&&!r&&!o?null:(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(ps,{isActive:t,isComingSoon:n,isSold:r,hasSellOrders:i}),(0,$.jsx)(Tr,{size:`md`,badges:a}),o&&(0,$.jsxs)(`a`,{href:o,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded-full border border-lofty-purple-600/30 dark:border-lofty-purple-700/60 bg-white dark:bg-lofty-purple-800/30 px-3 py-1 text-xs font-medium text-lofty-purple-600 dark:text-lofty-gray hover:border-lofty-purple transition-colors`,children:[(0,$.jsx)(`img`,{src:`/static/img/airbnb-logo.png`,alt:``,"aria-hidden":`true`,className:`h-4 w-4`}),`Airbnb listing`]})]})})},hs=100,gs=1e5,_s=({label:e,value:t,valueClassName:n=`text-lofty-purple-600 dark:text-lofty-gray`,caption:r})=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-gray-500 dark:text-lofty-gray-400`,children:e}),(0,$.jsx)(`span`,{className:`text-lg font-semibold tabular-nums ${n}`,children:t}),r&&(0,$.jsx)(`span`,{className:`text-[11px] text-gray-500 dark:text-lofty-gray/70 tabular-nums`,children:r})]}),vs=({summary:e,ownedPct:t,livePrice:n})=>{if(!e||e.currentTokens<=0)return null;let r=e.currentTokens,i=r*((e.costBasis??0)/hs),a=(e.totalRentEarned??0)/gs,o=n>0?r*n:(e.currentValue??0)/hs,s=o+a-i,c=i>0?s/i*100:0,l=s>0,u=l?`text-lofty-green`:s<0?`text-lofty-red`:`text-lofty-purple-600 dar
38k:text-lofty-gray`;return(0,$.jsxs)(`div`,{className:`rounded-xl bg-white dark:bg-lofty-purple-700 border border-lofty-purple/10 dark:border-lofty-purple-500/40 p-5 shadow-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-4 gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-widest text-lofty-purple-600/80 dark:text-lofty-gray-400 shrink min-w-0`,children:`Your investment`}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-lofty-purple-50 dark:bg-lofty-purple-600/40 px-2.5 py-0.5 text-[11px] font-semibold text-lofty-purple-600 dark:text-lofty-purple-50 shrink-0`,children:[t,`% owned`]})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-5`,children:[(0,$.jsx)(_s,{label:r===1?`Share`:`Shares`,value:R(r,{minimumFractionDigits:0}),valueClassName:`text-lofty-purple-600 dark:text-lofty-gray`}),(0,$.jsx)(_s,{label:`Cost basis`,value:z(H(i,2,!1),{minimumFractionDigits:2}),valueClassName:`text-lofty-purple-600 dark:text-lofty-gray`}),(0,$.jsx)(_s,{label:`Market value`,value:z(H(o,2,!1),{minimumFractionDigits:2}),valueClassName:`text-lofty-purple-600 dark:text-lofty-gray`}),(0,$.jsx)(_s,{label:`Total return`,value:(0,$.jsx)(`span`,{className:`flex items-baseline gap-1`,children:(0,$.jsxs)(`span`,{children:[l?`+`:``,z(H(s,2,!1),{minimumFractionDigits:2})]})}),valueClassName:u,caption:(0,$.jsxs)(`span`,{className:u,children:[l?`+`:``,c.toFixed(2),`%`]})})]})]})},ys={details:`Details`,financials:`Financials`,orderbook:`Order book`,"order-book":`Order book`},bs=(e,t)=>{let n=ys[t.toLowerCase()];if(!n)return;let r=e.indexOf(n);return r>=0?r:void 0},xs=({property:e,orderBook:t,propertyInfo:n,pricing:r,userOrderData:i,isActive:o,isComingSoon:s,isSold:c,hasSellOrders:l,hasFilledOrders:u,isSecondaryMarket:d,tradingDisabled:f,kycVerified:p,hideTabs:m,chartPoints:h,yieldData:g,averageHistoricalYield:_,reviews:v,averageRating:y,showReviews:b,reviewsRef:x,isLoadingReviews:S,userReview:C,onWriteReview:w,currentOwned:T,ownedPct:E,userProjectedAnnualReturn:D,userRentalYield:ee,userProjectedRentalYield:O,listingDescription:k,listingUpdates:j,forumUpdates:ne,groupItems:M,isWatchlisted:re,hasAlerts:N,onWatchlistToggle:P,onAlertToggle:ie,onShowOrderBook:ae,onRefreshUserOrderData:oe,orderRequestRef:ce})=>{let{isAuth:le}=te(),{getSummaryListing:ue}=A(),de=ue(e.id),fe=a(),F=(0,Q.useMemo)(()=>m?[`Details`,`Order book`]:[`Details`,`Financials`,`Order book`],[m]),[pe,I]=(0,Q.useState)(0),L=(0,Q.useDeferredValue)(pe),me=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{let e=new URLSearchParams(fe.search).get(`tab`);if(!e)return;let t=bs(F,e);typeof t==`number`&&I(t)},[fe.search,F]),(0,Q.useEffect)(()=>{if(L!==F.indexOf(`Details`)||!me.current)return;let e=requestAnimationFrame(()=>{x.current?.scrollIntoView({behavior:`smooth`,block:`start`}),me.current=!1});return()=>cancelAnimationFrame(e)},[L,x,F]);let he=T>0,ge=m?1:2,_e=se(e,r.startingPrice??0,n?.lastPrice).minimumPrice??r.startingPrice??0,ve=!!le,ye=ve?`calc(var(--mobile-bottom-tab-bar-height, 0px) + 5.5rem)`:`calc(var(--safe-area-inset-bottom, 0px) + 5.5rem)`;return(0,$.jsxs)(`div`,{className:`lg:hidden w-full overflow-x-clip`,children:[(0,$.jsx)(Vo,{title:e.address_line1}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,style:{paddingBottom:ye},children:[(0,$.jsx)(ls,{addressLine1:e.address_line1,addressLine2:e.address_line2,averageRating:y,reviewCount:v.length,showReviews:b&&!S,isAuth:!!le,isWatchlisted:re,hasAlerts:N,onWatchlistToggle:P,onAlertToggle:ie,onReviewClick:()=>{let e=F.indexOf(`Details`);e>=0&&pe!==e?(me.current=!0,I(e)):x.current?.scrollIntoView({behavior:`smooth`,block:`start`})},onWriteReview:T>0&&!C?w:void 0}),(0,$.jsx)(ms,{property:e,isActive:o,isComingSoon:s,isSold:c,hasSellOrders:l}),he&&(0,$.jsx)(vs,{summary:de,ownedPct:E,livePrice:_e}),(0,$.jsx)(Ro,{pricePerToken:r.startingPrice??0,chartPoints:h,yieldData:g,hasFilledOrders:!!u,isSecondaryMarket:!!d}),(0,$.jsx)(is,{property:e,propertyInfo:n,pricePerToken:_e,averageHistoricalYield:_}),F.length>1&&(0,$.jsx)(`section`,{className:`flex flex-col`,children:(0,$.jsx)(`div`,{className:`border-b border-lofty-purple-700 overflow-hidden`,children:(0,$.jsx)(`ul`,{className:`flex -mb-px touch-pan-y`,role:`tablist`,children:F.map((e,t)=>
38(0,$.jsx)(Ao,{text:e,tabPosition:t,currentTab:pe,setCurrentTab:I},e))})})}),(0,$.jsxs)(`section`,{children:[L===0&&(0,$.jsx)(So,{property:e,currentOwned:T,ownedPct:E,userProjectedAnnualReturn:D,userRentalYield:ee,userProjectedRentalYield:O,listingDescription:k,listingUpdates:j,forumUpdates:ne,hidden:!1,reviews:v,reviewsRef:x,showReviews:b,isLoadingReviews:S,userReview:C,onWriteReview:w,mobileVariant:!0}),m&&L===1&&(0,$.jsx)(ns,{property:e,orderBook:t,propertyInfo:n,pricing:r,isSecondaryMarket:!!d,hidden:!1}),!m&&L===1&&(0,$.jsx)(ko,{property:e,propertyInfo:n,groupItems:M,hidden:!1,averageHistoricalYield:_,mobileVariant:!0}),!m&&L===ge&&(0,$.jsx)(ns,{property:e,orderBook:t,propertyInfo:n,pricing:r,isSecondaryMarket:!!d,hidden:!1})]})]}),(0,$.jsx)(as,{property:e,pricePerToken:_e,averageHistoricalYield:_,showOrderBookLink:!1,openOrderBookModal:ae,userOrderData:i,kycVerified:p,tradingDisabled:f,interactive:!!n&&(!le||!!i),hasBottomTabBar:ve,onRefreshUserOrderData:oe,orderRequestRef:ce})]})},Ss=300*1e3,Cs=null,ws=null,Ts=async(e=!1)=>{if(!e&&Cs&&Date.now()-Cs.fetchedAt<Ss)return Cs.properties;if(!e&&ws)return ws;ws=(async()=>{let e=(await Mr())?.properties??[];return Cs={properties:e,fetchedAt:Date.now()},e})();try{return await ws}finally{ws=null}},Es=()=>{let[e,t]=(0,Q.useState)(Cs?.properties??[]),[n,r]=(0,Q.useState)(!Cs);(0,Q.useEffect)(()=>{let e=!1,n,i=async(n=!1)=>{try{let i=await Ts(n);e||(t(i),r(!1))}catch{e||r(!1)}};return i(!1),n=setInterval(()=>{i(!0)},Ss),()=>{e=!0,n&&clearInterval(n)}},[]);let i=(0,Q.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.propertyId,n);return t},[e]);return{map:i,isLoading:n,getByPropertyId:e=>e?i.get(e):void 0}},Ds=10*6e4,Os=5*6e4,ks=e=>{let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0},As=e=>Ds+ks(e)%Os,js=(e,t,n)=>{if(!n)return null;let r=e.filter(e=>e.quantity>=n.minContracts).map(e=>e.price),i=t.filter(e=>e.quantity>=n.minContracts).map(e=>e.price);if(!r.length||!i.length)return null;let a=Math.max(...r),o=Math.min(...i);return{midpoint:(a+o)/2,bestBid:a,bestAsk:o}},Ms=(e,t)=>{let n=[],r=t.now??Date.now();return t.config||n.push(`no_rewards`),t.midpoint??n.push(`no_midpoint`),r-e.createdAt<As(e.orderId)&&n.push(`order_too_young`),t.config&&e.qtyRemaining<t.config.minContracts&&n.push(`below_min_size`),t.config&&t.midpoint!=null&&Math.abs(e.price-t.midpoint)>t.config.allowedSpread&&n.push(`outside_spread`),n},Ns=({eligible:e})=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide ${e?`bg-emerald-100 text-emerald-700 dark:bg-emerald-500/15 dark:text-emerald-300`:`bg-lofty-gray-300 text-lofty-gray-700 dark:bg-lofty-purple-700 dark:text-lofty-purple-50/60`}`,title:e?`Earning Property Offer Rewards`:`Not earning Property Offer Rewards`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${e?`bg-emerald-500 animate-pulse`:`bg-lofty-gray-500`}`}),e?`Earning`:`Not earning`]}),Ps=({order:e,openDetail:t,lpEligibility:n})=>{let r=[Be.PENDING,Be.INTENT].includes(e.status);return(0,$.jsxs)(`button`,{type:`button`,onClick:t,className:`appearance-none cursor-pointer flex flex-row flex-1 justify-between w-full
39        border border-gray-200 dark:border-lofty-purple-700 rounded-xl pl-5 pt-5 pb-5 pr-3 mb-3 items-center
40        bg-lofty-gray-100 dark:bg-lofty-purple-600 hover:bg-lofty-gray dark:hover:bg-lofty-purple-700 transition-colors duration-200`,children:[(0,$.jsxs)(`div`,{className:`flex justify-start items-center min-w-0`,children:[(0,$.jsx)(`i`,{className:`fas fa-solid fa-file-invoice-dollar text-lofty-purple text-5xl`}),(0,$.jsxs)(`div`,{className:`ml-3 flex flex-col items-start gap-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,$.jsx)(`div`,{className:`font-abc-favorit-trial text-lofty-purple-600 dark:text-lofty-gray font-semibold`,children:`${r?`Pending`:`Open`} ${e.direction} order`}),(0,$.jsx)(`div`,{className:`font-abc-favorit-trial text-gray-500 dark:text-lofty-gray/60 font-normal`,children:Me(e.quantity,`share`).phrase})]}),n&&(0,$.jsx)(Ns,{eligible:n.isEligible})]})]}),(0,$.jsx)(`div`,{className:`flex items-center font-abc-favorit-tr
40ial text-lofty-purple font-medium font-semibold`,children:z(e.price,{minimumFractionDigits:2,maximumFractionDigits:2})})]})},Fs=({transactions:e,isModal:t})=>(0,$.jsxs)(`div`,{className:`overflow-hidden rounded-lg border border-gray-200 dark:border-lofty-purple-700/50`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-[1.1fr_1fr_1fr_0.8fr] gap-3 bg-gray-50 px-4 py-2.5 text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:bg-lofty-purple-700/30 dark:text-lofty-gray/55`,children:[(0,$.jsx)(`span`,{children:`Filled`}),(0,$.jsx)(`span`,{className:`text-right`,children:`Size`}),(0,$.jsx)(`span`,{className:`text-right`,children:`Price`}),(0,$.jsx)(`span`,{className:`text-right`,children:`Type`})]}),e.map((e,n)=>{let r=e.type===Se.Buy?`text-lofty-green-500 dark:text-lofty-green`:`text-lofty-red dark:text-red-400`;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[1.1fr_1fr_1fr_0.8fr] gap-3 border-b border-gray-200 px-4 py-3 text-sm tabular-nums transition-colors last:border-b-0 hover:bg-lofty-gray-100/70 dark:border-lofty-purple-700/40 dark:hover:bg-lofty-purple-700/30 ${t?`xl:text-base`:`sm:text-base`}`,children:[(0,$.jsx)(`span`,{className:`font-medium text-lofty-purple-600 dark:text-lofty-gray`,title:new Date(e.updatedAt).toLocaleString(),children:gn(e.updatedAt,`MMM d`)}),(0,$.jsxs)(`span`,{className:`text-right text-lofty-purple-600 dark:text-lofty-gray`,children:[R(e.quantity,Nt),` `,Me(e.quantity,`share`).word]}),(0,$.jsxs)(`span`,{className:`text-right font-semibold text-lofty-purple-600 dark:text-lofty-gray`,children:[`$`,R(H(e.price,2,!1),{minimumFractionDigits:2})]}),(0,$.jsx)(`span`,{className:`text-right font-semibold capitalize ${e.type?r:`text-gray-500 dark:text-lofty-gray/60`}`,children:e.type??`trade`})]},e.id+n)})]}),Is=10,Ls=({propertyInfo:e,isModal:t})=>{let n=(e?.transactions.length??0)>0,r=[...e?.transactions??[]].sort((e,t)=>t.updatedAt-e.updatedAt).slice(0,Is);return r=r.reduce((e,t)=>(!t.type&&t.swappedAmount&&t.status===`completed`?e.push({...t,type:Se.Buy},{...t,type:Se.Sell}):e.push(t),e),[]),(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm dark:border-lofty-purple-700/50 dark:bg-lofty-purple-800/30 dark:shadow-none`,children:[(0,$.jsx)(`div`,{className:`flex flex-col gap-1 border-b border-gray-200 bg-gray-50 px-5 py-4 dark:border-lofty-purple-700/40 dark:bg-lofty-purple-700/30`,children:(0,$.jsx)(`h1`,{className:`text-lg font-bold leading-6 text-lofty-purple-600 dark:text-lofty-gray ${t?`xl:text-xl`:`sm:text-2xl`}`,children:`Recently filled orders`})}),(0,$.jsxs)(`div`,{className:`p-4 sm:p-5`,children:[n&&(0,$.jsx)(Fs,{transactions:r,isModal:t}),(0,$.jsx)(`p`,{className:`w-full text-sm text-gray-500 dark:text-lofty-gray/60 ${n?`mt-4 text-center`:`rounded-lg border border-dashed border-gray-200 px-5 py-6 text-center dark:border-lofty-purple-700/60`}`,children:n?`Only showing most recent orders`:`No recently filled orders`})]})]})},Rs=e=>U(e,{minimumFractionDigits:2});function zs({propertyId:e,onActiveChange:t}){let{getByPropertyId:n}=Es(),r=n(e??void 0),[i,a]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(null),l=i||o;return(0,Q.useEffect)(()=>{t?.(l)},[l,t]),(0,Q.useEffect)(()=>{if(!o)return;let e=e=>{c.current?.contains(e.target)||s(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]),r?(0,$.jsxs)(`div`,{ref:c,className:`relative inline-flex`,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":l,className:`inline-flex items-center gap-1.5 rounded-full bg-emerald-500/15 px-2.5 py-1 text-[11px] font-bold uppercase tracking-wider text-emerald-700 ring-1 ring-inset ring-emerald-500/30 hover:bg-emerald-500/25 dark:bg-emerald-500/15 dark:text-emerald-300 dark:ring-emerald-400/30`,children:[(0,$.jsx)(`i`,{className:`far fa-coins text-[10px]`}),`Rewards`]}),l&&(0,$.jsxs)(`div`,{className:`absolute right-0 top-[calc(100%+6px)] z-30 w-[280px] rounded-lg border border-emerald-500/30 bg-lofty-purple-800 p-3 text-xs text-white shadow-lg ring-1 ring-black/5`,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[(0,$.jsx)(`div`,{className:`mb-2 font-semibold`,children:`Earn USDC by placing limit orders near the midpoint.`}),(0,$.jsxs)(`div`,{className:`space-y-1 text-white/90`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-white/60`,children:`Daily pool`}),(0,$.jsx)(`span`,{className:`font-semibold tabular-nums`,children:Rs(r.totalRewards)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-white/60`,children:`Max spread`}),(0,$.jsxs)(`span`,{className:`font-semibold tabular-nums`,children:[`±`,Rs(r.allowedSpread)]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-white/60`,children:`Min order size`}),(0,$.jsxs)(`span`,{className:`font-semibold tabular-nums`,children:[r.minContracts,` shares`]})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3 border-t border-white/15 pt-2`,children:[(0,$.jsx)(d,{to:`/lp-rewards`,className:`text-white/70 hover:text-white`,children:`How it works`}),(0,$.jsx)(d,{to:`/account/lp-rewards`,className:`font-semibold text-emerald-300 hover:text-emerald-200`,children:`View your rewards →`})]})]})]}):null}var Bs=5,Vs=e=>z(H(e,2,!1),{minimumFractionDigits:2}),Hs=e=>`${R(e,{minimumFractionDigits:0})} ${Me(e,`share`).word}`,Us=(e,t)=>Math.max(3,Math.floor(e/t*100)),Ws=({order:e,direction:t,maxQuantity:n,bestLabel:r,rewardsHighlight:i})=>{let a=t===Se.Buy,o=Us(e.quantity,n),s=a?`rgba(111, 207, 151, 0.12)`:`rgba(235, 87, 87, 0.12)`,c=a?`text-lofty-green-500 dark:text-lofty-green`:`text-lofty-red dark:text-red-400`,l=a?`ring-lofty-green/30`:`ring-lofty-red/30`,u=!!i&&i.active&&Math.abs(e.price-i.midpoint)<=i.allowedSpread,d=u&&!!i&&e.quantity>=i.minContracts,f=u&&!!i&&e.quantity<i.minContracts,p=d?`ring-2 ring-emerald-400/60 bg-emerald-500/5 dark:bg-emerald-500/10`:f?`opacity-60`:``;return(0,$.jsxs)(`div`,{className:`grid grid-cols-[1fr_auto] items-center rounded-lg px-4 py-2.5 text-sm sm:text-base tabular-nums transition-all hover:bg-lofty-gray-100/70 dark:hover:bg-lofty-purple-700/30 ${r&&!d?`ring-1 ${l}`:``} ${p}`,style:{background:`linear-gradient(to left, ${s} ${o}%, transparent ${o}%)`},children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`font-semibold ${c}`,children:Vs(e.price)}),r&&(0,$.jsx)(`span`,{className:`rounded-full bg-white/80 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-gray-500 ring-1 ring-gray-200 dark:bg-lofty-purple-800/80 dark:text-lofty-gray/60 dark:ring-lofty-purple-700/60`,children:r}),d&&(0,$.jsxs)(`span`,{className:`rounded-full bg-emerald-500/20 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(`i`,{className:`far fa-coins mr-1`}),`Earning`]}),f&&i&&(0,$.jsxs)(`span`,{className:`rounded-full bg-gray-400/15 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-gray-500 dark:text-lofty-gray/50`,children:[`Too small · min `,i.minContracts]})]}),(0,$.jsx)(`span`,{className:`text-right font-medium text-lofty-purple-600 dar
40k:text-lofty-gray`,children:Hs(e.quantity)})]})},Gs=({label:e})=>(0,$.jsx)(`div`,{className:`rounded-lg border border-dashed border-gray-200 dark:border-lofty-purple-700/60 px-4 py-4 text-sm text-gray-500 dark:text-lofty-gray/60`,children:e}),Ks=({title:e,direction:t,orders:n,maxQuantity:r,reverseDisplay:i=!1,rewardsHighlight:a})=>{let o=t===Se.Buy,s=o?`text-lofty-green-500 dark:text-lofty-green`:`text-lofty-red dark:text-red-400`,[c,l]=(0,Q.useState)(!1),u=c?n:n.slice(0,Bs),d=i?[...u].reverse():u,f=n[0]?.id,p=n.length-Bs,m=p>0&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`block w-full rounded-lg py-2 text-center text-xs font-semibold text-lofty-purple hover:bg-lofty-gray-100/70 hover:text-lofty dark:hover:bg-lofty-purple-700/30`,children:c?`Show less`:`Show ${p} more`});return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3 px-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full ${o?`bg-lofty-green`:`bg-lofty-red`}`}),(0,$.jsx)(`span`,{className:`text-xs font-bold uppercase tracking-wide ${s}`,children:e})]}),(0,$.jsxs)(`div`,{className:`grid min-w-[140px] grid-cols-2 gap-4 text-right text-[11px] font-semibold uppercase tracking-wide text-gray-500 dark:text-lofty-gray/55`,children:[(0,$.jsx)(`span`,{children:`Price`}),(0,$.jsx)(`span`,{children:`Shares`})]})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-1`,children:n.length===0?(0,$.jsx)(Gs,{label:`No ${o?`buy`:`sell`} orders`}):(0,$.jsxs)($.Fragment,{children:[i&&m,d.map(e=>(0,$.jsx)(Ws,{order:e,direction:t,maxQuantity:r,bestLabel:e.id===f?o?`Best bid`:`Best ask`:void 0,rewardsHighlight:a},e.id)),!i&&m]})})]})},qs=({orderBook:e,buyMaxTokens:t,sellMaxTokens:n,isModal:r,propertyId:i})=>{let a=Mn(e),o=e?.orderBook?.buyOrders??[],s=e?.orderBook?.sellOrders??[],c=(0,Q.useMemo)(()=>[...o].sort((e,t)=>t.price-e.price),[o]),l=(0,Q.useMemo)(()=>[...s].sort((e,t)=>e.price-t.price),[s]),u=c[0]?.price??0,d=l[0]?.price??0,f=u>0&&d>0?d-u:null,{getByPropertyId:p}=Es(),m=p(i),[h,g]=(0,Q.useState)(!1),_=(0,Q.useMemo)(()=>js(c,l,m),[c,l,m]),v=m&&_?{active:h,midpoint:_.midpoint,allowedSpread:m.allowedSpread,minContracts:m.minContracts}:void 0;return(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm dark:border-lofty-purple-700/50 dark:bg-lofty-purple-800/30 dark:shadow-none`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-b border-gray-200 bg-gray-50 px-5 py-4 dark:border-lofty-purple-700/40 dark:bg-lofty-purple-700/30 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`h1`,{className:`text-lg font-bold leading-6 text-lofty-purple-600 dark:text-lofty-gray ${r?`xl:text-xl`:`sm:text-2xl`}`,children:`Open orders`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(zs,{propertyId:i,onActiveChange:g}),f!==null&&(0,$.jsxs)(`div`,{className:`rounded-full bg-white px-3 py-1.5 text-xs font-semibold text-lofty-purple-600 shadow-sm ring-1 ring-gray-200 dark:bg-lofty-purple-800/80 dark:text-lofty-gray dark:ring-lofty-purple-700/60`,children:[`Spread `,Vs(f)]})]})]}),(0,$.jsxs)(`div`,{className:`p-4 sm:p-5`,children:[!a&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-dashed border-gray-200 px-5 py-6 text-center dark:border-lofty-purple-700/60`,children:[(0,$.jsx)(`i`,{className:`far fa-chart-simple text-2xl text-lofty-purple`}),(0,$.jsx)(`p`,{className:`mt-3 text-sm font-semibold text-lofty-purple-600 dark:text-lofty-gray`,children:`No open orders right now`}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-lofty-gray/60`,children:`Buy and sell interest will appear here once investors place limit orders.`})]}),a&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(Ks,{title:`Sellers asking`,direction:Se.Sell,orders:l,maxQuantity:n,reverseDisplay:!0,rewardsHighlight:v}),f!==null&&(0,$.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,$.jsx)(`div`,{className:`h-px flex-1 bg-gray-200 dark:bg-lofty-purple-700/60`}),(0,$.jsxs)(`div`,{className:`rounded-full bg-lofty-purple-50 px-3 py-1 text-[11px] font-semibold uppercase tracking-wide text-lofty-purple-600 dar
40k:bg-lofty-purple-700/50 dark:text-lofty-gray/70`,children:[`Spread `,Vs(f)]}),(0,$.jsx)(`div`,{className:`h-px flex-1 bg-gray-200 dark:bg-lofty-purple-700/60`})]}),(0,$.jsx)(Ks,{title:`Buyers bidding`,direction:Se.Buy,orders:c,maxQuantity:t,rewardsHighlight:v})]})]})]})},Js=({property:e,propertyInfo:t,pricing:n,orderBook:r})=>{let i=F(),a=r?.orderBook?.buyOrders??[],o=r?.orderBook?.sellOrders??[],s=(0,Q.useMemo)(()=>a.length>0?Math.max(1,...a.map(e=>e.quantity)):1,[a]),c=(0,Q.useMemo)(()=>o.length>0?Math.max(1,...o.map(e=>e.quantity)):1,[o]);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-y-5`,children:[(0,$.jsx)(qo,{property:e,propertyInfo:t,pricing:n,isModal:i.isModal}),(0,$.jsx)(qs,{orderBook:r,buyMaxTokens:s,sellMaxTokens:c,isModal:i.isModal,propertyId:e.id}),(0,$.jsx)(Ls,{propertyInfo:t,isModal:i.isModal})]})},Ys=({property:e,orderBook:t,pricing:n,propertyInfo:r,isOpen:i,onClose:a})=>{let{isSold:o}=D(e),s=r?.secondaryEnabled===!1,c=r?.transactions&&r?.transactions.length>0,l=r&&o&&!s,[u,d]=(0,Q.useState)([]),[f,p]=(0,Q.useState)(`30D`),[m,h]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{i&&(async()=>{try{let t=await Tt(e.id);d(t.data.chartPoints||[]),h(!0)}catch(e){console.error(`Error fetching list view data:`,e),d([]),h(!0)}})()},[e.id,i]),(0,$.jsx)(ue,{id:`orderBookModal`,isOpen:i,onBackdropClick:a,onRequestClose:a,className:{container:`border-none bg-white dark:bg-lofty-purple-800 border border-gray-200 dark:border-lofty-purple-700`,overflow:`auto`,content:`flex flex-1 flex-col p-4.5 sm:p-6 lg:p-4.5 xl:p-6 2xl:p-8 relative`},roundCloseButton:!0,minHeight:`auto`,children:(0,$.jsxs)(`div`,{className:`flex flex-col justify-center gap-y-7`,children:[(0,$.jsx)(`div`,{className:`text-28 leading-tight sm:text-4xl lg:text-28 xl:text-4xl 2xl:text-64
41          font-bold text-lofty-purple-600 dark:text-lofty-gray text-left mt-4.5`,children:`Price history & order book`}),c&&l&&(0,$.jsxs)(`section`,{className:`pt-6`,children:[(0,$.jsx)(`div`,{className:`flex mb-4 bg-lofty-gray-100 dark:bg-lofty-purple-600 rounded-full p-1 w-fit`,children:[`1D`,`7D`,`30D`,`90D`,`1Y`,`All`].map(e=>(0,$.jsx)(`button`,{onClick:()=>p(e),className:`
42                    px-3 py-1 text-sm font-medium rounded-full transition-colors duration-200
43                    ${f===e?`bg-lofty text-white`:`text-gray-500 dark:text-lofty-gray/60 hover:text-lofty-purple`}
44                  `,children:e},e))}),m&&(0,$.jsx)(Nr,{chartPoints:(e=>{if(!u||u.length===0)return[];if(e===`All`)return u;let t=Date.now(),n={"1D":t-B.days(1),"7D":t-B.days(7),"30D":t-B.days(30),"90D":t-B.days(90),"1Y":t-B.days(365)};return u.filter(t=>t.t>=n[e])})(f),defaultPrice:n.startingPrice})]}),(0,$.jsx)(Js,{property:e,pricing:n,orderBook:t,propertyInfo:r})]})})},Xs=({property:e,orderBook:t,pricing:n,propertyInfo:r,hidden:i})=>r?(0,$.jsx)(`div`,{className:`${i?`hidden`:``} pt-4 bg-white dark:bg-lofty-purple-800 text-lofty-purple-600 dark:text-lofty-gray`,role:`tabpanel`,children:(0,$.jsx)(Js,{property:e,pricing:n,orderBook:t,propertyInfo:r})}):(0,$.jsx)($.Fragment,{}),Zs=({property:e})=>{let t=[];return e.beds>0&&t.push({id:`beds`,icon:`fa-bed`,text:`${e.beds} ${e.beds===1?`Bed`:`Beds`}`}),e.baths>0&&t.push({id:`baths`,icon:`fa-bath`,text:`${e.baths} ${e.baths===1?`Bath`:`Baths`}`}),(e.sqft??0)>0&&t.push({id:`sqft`,icon:`fa-ruler-combined`,text:`${e.sqft.toLocaleString()} Sqft`}),(e.acres??0)>0&&t.push({id:`acres`,icon:`fa-tree`,text:`${e.acres} ${e.acres===1?`Acre`:`Acres`}`}),t.length?(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 mb-5`,children:t.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2 rounded-full border border-gray-200 dark:border-lofty-purple-700/60 bg-gray-50 dark:bg-lofty-purple-800/30 px-3 py-1.5 text-sm text-lofty-purple-600 dark:text-lofty-gray`,children:[(0,$.jsx)(`i`,{className:`fas ${e.icon} text-xs text-lofty-purple`}),(0,$.jsx)(`span`,{children:e.text})]},e.id))}):null},Qs=[``,`Poor`,`Okay`,`Good`,`Great`,`Excellent`],$s=1e3,ec=({propertyId:e,onClose:t,onSubmit:n})=>{let[r,i]=(0,Q.useState)(0),[a,o]=(0,Q.useState)(0),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(`idle`),p=s.trim(),m=s.length,h=a||r,g=r>0&&p.length>0&&!l;return(0,$.jsxs)(`div`,{className:`bg-white dark:bg-lofty-purple-600 rounded-2xl shadow-cardLight dark:shadow-cardDark
45        ring-1 ring-black/5 dark:ring-white/5 overflow-hidden`,style:{width:`540px`,maxWidth:`94vw`},children:[(0,$.jsxs)(`div`,{className:`relative px-5 pt-6 pb-5 sm:px-7 sm:pt-7`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full
46            bg-lofty/10 dark:bg-lofty-purple/15
47            text-lofty dark:text-lofty-purple
48            px-2.5 py-1 text-[11px] font-bold uppercase tracking-[0.08em]`,children:[(0,$.jsx)(`i`,{className:`fas fa-star text-[9px]`}),`Investor Review`]}),(0,$.jsx)(`h2`,{className:`mt-3 text-[22px] sm:text-[24px] font-bold leading-[1.25] tracking-tight
49          text-gray-900 dark:text-white pr-10`,children:`How is your experience as an investor?`}),(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed text-gray-500 dark:text-lofty-gray/85`,children:`Your honest feedback helps other investors make informed decisions.`}),(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close`,className:`absolute top-5 right-5 w-8 h-8 rounded-full flex items-center justify-center
50            text-gray-400 dark:text-lofty-gray/80
51            hover:text-gray-700 dark:hover:text-white
52            hover:bg-gray-100 dark:hover:bg-white/10
53            transition-colors duration-200`,children:(0,$.jsx)(`i`,{className:`fas fa-xmark text-lg`})})]}),(0,$.jsx)(`div`,{className:`mx-5 sm:mx-7 h-px bg-gradient-to-r from-transparent via-gray-200 to-transparent
54        dark:via-white/10`}),(0,$.jsxs)(`div`,{className:`px-5 py-5 sm:px-7 sm:py-6 space-y-6`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between mb-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-gray-900 dark:text-white`,children:`Overall rating`}),(0,$.jsx)(`span`,{"aria-live":`polite`,className:`text-sm font-semibold tabular-nums transition-opacity duration-200 ${h>0?`opacity-100 text-lofty dark:text-lofty-purple`:`opacity-0`}`,children:h>0?`${h}.0 · ${Qs[h]}`:`0.0`})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,onMouseLeave:()=>o(0),role:`radiogroup`,"aria-label":`Overall rating`,onKeyDown:e=>{(e.key===`ArrowRight`||e.key===`ArrowUp`)&&(e.preventDefault(),i(e=>Math.min(5,Math.max(1,e+1)))),(e.key===`ArrowLeft`||e.key===`ArrowDown`)&&(e.preventDefault(),i(e=>Math.max(0,e-1)))},tabIndex:0,children:[1,2,3,4,5].map(e=>{let t=h>=e;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(e),onMouseEnter:()=>o(e),className:`group p-1 -m-1 rounded-lg
55                    focus:outline-none focus-visible:ring-2 focus-visible:ring-lofty/50`,"aria-label":`${e} star${e===1?``:`s`} — ${Qs[e]}`,"aria-checked":r===e,role:`radio`,children:(0,$.jsx)(`svg`,{width:`40`,height:`40`,viewBox:`0 0 24 24`,className:`transition-all duration-150 ease-out
56                      group-hover:-translate-y-0.5 group-active:scale-95
57                      ${t?`text-lofty drop-shadow-[0_4px_10px_rgba(77,63,237,0.45)]`:`text-gray-200 dark:text-white/25 group-hover:text-lofty/40 dark:group-hover:text-lofty-purple/70`}`,children:(0,$.jsx)(`path`,{fill:`currentColor`,d:`M12 2l3.09 6.26L22 9.27l-5 4.87L18.18 22 12 18.27 5.82 22 7 14.14 2 9.27l6.91-1.01L12 2z`})})},e)})}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-lofty-gray/80`,children:`Pick a star rating, then add details below.`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`review-text`,className:`block text-sm font-semibold text-gray-900 dark:text-white mb-2`,children:`Tell us about your experience`}),(0,$.jsx)(`textarea`,{id:`review-text`,value:s,onChange:e=>c(e.target.value),placeholder:`What stands out about investing in this property? How are the rental income, communication, and property management?`,rows:4,maxLength:$s,className:`w-full rounded-xl
58              border border-gray-200 dark:border-white/15
59              bg-gray-50 dark:bg-lofty-purple-700
60              text-[15px] leading-relaxed text-gray-900 dark:text-white
61              px-4 py-3.5 resize-none
62              placeholder:text-gray-400 dark:placeholder:text-lofty-gray/70
63              focus:outline-none focus:border-lofty focus:ring-4 focus:ring-lofty/15
64              focus:bg-white dark:focus:bg-lofty-purple-700
65              transition-all duration-150`}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-3 text-xs`,children:[(0,$.jsxs)(`p`,{className:`inline-flex items-center gap-1.5 text-gray-500 dark:text-lofty-gray/80`,children:[(0,$.jsx)(`i`,{className:`fas fa-eye`}),(0,$.jsx)(`span`,{children:`Your review will be public.`})]}),(0,$.jsxs)(`span`,{className:`tabular-nums font-medium transition-colors duration-150 ${m===0?`text-transparent`:m>$s-50?`text-lofty-red`:`text-gray-500 dark:text-lofty-gray/80`}`,children:[m,`/`,$s]})]})]}),d===`success`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-xl bg-green-50 dark:bg-lofty-green/10
66            border border-green-200 dark:border-lofty-green/30 px-4 py-3`,children:[(0,$.jsx)(`i`,{className:`fas fa-circle-check text-green-600 dark:text-lofty-green`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-green-700 dark:text-lofty-green`,children:`Review submitted. Thanks for sharing!`})]}),d===`error`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-xl bg-red-50 dark:bg-lofty-red/10
67            border border-red-200 dark:border-lofty-red/30 px-4 py-3`,children:[(0,$.jsx)(`i`,{className:`fas fa-circle-exclamation text-red-600 dark:text-lofty-red`}),(0,$.jsx)(`span`,{className:`text-sm font-medium text-red-700 dark:text-lofty-red`,children:`Something went wrong. Please try again.`})]})]}),(0,$.jsxs)(`div`,{className:`px-5 py-4 sm:px-7 flex items-center justify-between gap-3
68        bg-gray-50/70 dark:bg-lofty-purple-800/40
69        border-t border-gray-100 dark:border-white/5`,children:[(0,$.jsx)(`div`,{className:`hidden sm:block min-h-[20px] flex-1`,children:!g&&(0,$.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-lofty-gray/80`,children:`Add a rating and a few details to submit.`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:t,className:`text-sm font-semibold underline-offset-4 hover:underline
70              text-gray-700 dark:text-lofty-gray
71              transition-colors duration-200`,children:`Cancel`}),(0,$.jsx)(`button`,{type:`button`,onClick:async()=>{u(!0),f(`idle`);try{await At({rating:r,text:p,propertyId:e}),f(`success`),setTimeout(()=>{n(),t()},1500)}catch(e){console.error(`Error submitting review:`,e),f(`error`)}finally{u(!1)}},disabled:!g,className:`rounded-xl bg-lofty px-6 py-2.5 text-sm font-semibold text-white
72              shadow-subtle
73              hover:bg-lofty-purple hover:shadow-md
74              active:scale-[0.98]
75              disabled:bg-gray-200 dark:disabled:bg-lofty-purple-700
76              disabled:text-gray-400 dark:disabled:text-lofty-gray/40
77              disabled:cursor-not-allowed disabled:shadow-none disabled:active:scale-100
78              transition-all duration-150
79              inline-flex items-center justify-center gap-2 min-w-[140px]`,children:l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zt,{className:`w-4 h-4`}),`Submitting...`]}):`Submit review`})]})]})]})},tc=(0,Q.lazy)(()=>f(()=>import(`./PriceLineChart-CWNj0Tqt.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),nc=(0,Q.lazy)(()=>f(()=>import(`./YieldLineChart-CVUQ9czY.js`).then(e=>e.n),__vite__mapDeps([24,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),rc=e=>e.filter(e=>(e.currentTokens??0)>0);function ic({property:e,orderBook:t,propertyInfo:n,pricing:r,userOrderData:i,forumUpdates:a,yieldData:o,orderRequestRef:s,onShowOrderBook:c,onOrderCanceled:l,onRefreshUserOrderData:u}){let[d,f]=(0,Q.useState)(0),p=(0,Q.useDeferredValue)(d),m=E(),[h,g]=(0,Q.useState)(!1),_=m.minWidth>=re.lg,v=!h||!_,y=!h||_,{isActive:x,isComingSoon:C,isSold:w}=D(e),{isModalOpen:T,openModal:ee,closeModal:O}=S(),[k,j]=(0,Q.useState)(),{getSummaryListing:ne}=A(),[M,N]=(0,Q.useState)([]),[P,ie]=(0,Q.useState)(`30D`),ae=(0,Q.useDeferredValue)(P),[oe,se]=(0,Q.useState)(`1Y`),ce=(0,Q.useDeferredValue)(oe),[le,de]=(0,Q.useState)(0),fe=(0,Q.useDeferredValue)(le),[F,pe]=(0,Q.useState)([]),[I,L]=(0,Q.useState)(null),[me,he]=(0,Q.useState)(!0),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(null),{ref:ve,visible:ye}=b(),[be,xe]=(0,Q.useState)(!1),[R,Se]=(0,Q.useState)(!1),[z,Ce]=(0,Q.useState)(!1),[we,Te]=(0,Q.useState)(!1),[Ee,De]=(0,Q.useState)(!1),{isAuth:Oe,email:ke}=te();(0,Q.useEffect)(()=>{g(!0)},[]),(0,Q.useEffect)(()=>{(ye||h&&!_)&&xe(!0)},[ye,h,_]),(0,Q.useEffect)(()=>
79{if(typeof IntersectionObserver>`u`){Se(!0);return}let e=[ge.current,_e.current].filter(Boolean);if(e.length===0)return;let t=new IntersectionObserver(([e])=>{e.isIntersecting&&Se(!0)},{rootMargin:`240px`});return e.forEach(e=>t.observe(e)),()=>t.disconnect()},[e.id,y,v]),(0,Q.useEffect)(()=>{if(!be)return;let t=!1;return N([]),Tt(e.id).then(e=>{t||N(e.data?.chartPoints??[])}).catch(e=>{t||console.error(`Error fetching list view data:`,e)}),()=>{t=!0}},[e.id,be]),(0,Q.useEffect)(()=>{if(!R)return;let t=!1;return pe([]),he(!0),ze(e.id).then(e=>{t||pe(rc(e.data||[]))}).catch(e=>{t||console.error(`Error fetching property reviews:`,e)}).finally(()=>{t||he(!1)}),()=>{t=!0}},[e.id,R]),(0,Q.useEffect)(()=>{if(!Oe){L(null);return}if(!R)return;let t=!1;return(async()=>{try{let n=await Ft({extraInfo:!1});if(t)return;let r=n.data?.find(t=>t.propertyId===e.id);L(r||null)}catch(e){t||console.error(`Error fetching user review:`,e)}})(),()=>{t=!0}},[ke,Oe,e.id,R]);let V=(0,Q.useMemo)(()=>{if(F.length===0)return`N/A`;let e=(F.reduce((e,t)=>e+t.rating,0)/F.length).toFixed(1);return e.endsWith(`.0`)?e.slice(0,-2):e},[F]),Ae=e=>{if(M.length===0)return[];if(e===`All`)return M;let t=Date.now(),n={"1D":t-B.days(1),"7D":t-B.days(7),"30D":t-B.days(30),"90D":t-B.days(90),"1Y":t-B.days(365)};return M.filter(t=>t.t>=n[e])},je=e=>{if(o.length===0)return[];if(e===`All`)return o;let t=Date.now(),n={"3M":t-B.days(90),"6M":t-B.days(180),"9M":t-B.days(270),"1Y":t-B.days(365)};return o.filter(t=>t.t>=n[e])},Me=(0,Q.useMemo)(()=>o.length===0?n?.coc||0:o.reduce((e,t)=>e+t.y,0)/o.length,[o,n?.coc]),H=ne(e.id),Ne=H?.currentTokens??0,Pe=Ne/e.tokens*100,U=Pe>=1?Pe.toFixed(1):Pe.toFixed(2),Fe=H?.propertyInfo.coc??0,Ie=n?.secondaryEnabled===!1,W=Me+(e.appreciation??0),Le=Fe,Re=e.projected_rental_yield??0,{groupItems:Be,listingDescription:Ve,listingUpdates:He}=(0,Q.useMemo)(()=>{let t=Array.isArray(e.groupItems)?[...e.groupItems].sort((e,t)=>t.year_built-e.year_built):null;return{groupItems:t,listingDescription:t?[e.description,...t.map(e=>e.description?[`## ${e.address_line1}`,e.description].join(`
80
81`):[])??[]].join(`
82
83`):e.description,listingUpdates:t?[e.updates,...t.map(e=>e.updates?[`## ${e.address_line1}`,e.updates].join(`
84
85`):[])??[]].join(`
86
87`):e.updates}},[e.groupItems,e.description]),Ue=i?.properties[e.id]?.orders,We=[...Ue?.pending??[],...Ue?.intent??[]],{getByPropertyId:Ge}=Es(),G=Ge(e.id),Ke=(0,Q.useMemo)(()=>js(t?.orderBook?.buyOrders??[],t?.orderBook?.sellOrders??[],G)?.midpoint??null,[t,G]),qe=e=>{if(!G)return;let t=Ms({orderId:e.id,price:e.price,qtyRemaining:e.quantity,createdAt:e.createdAt??0},{config:G,midpoint:Ke});return{isEligible:t.length===0,reasons:t}},Je=n?.transactions&&n?.transactions.length>0,Ye=n&&w&&!Ie,Xe=(t?.orderBook?.sellOrders??[]).length>0,Ze=!!i?.kyc?.external,Qe=!!e.isTimeShare||!!e.isDaoOnly,$e=Qe,K=fs(e),et=()=>Qe?[`Details`,$e?`Order book`:void 0].filter(Boolean):[`Details`,`Financials`,n&&w&&!Ie?`Order book`:void 0].filter(Boolean),tt=(e,t)=>{j({orderId:e,direction:t}),ee()},{isModalOpen:nt,openModal:rt,closeModal:it}=S(),at=()=>{rt()},ot=async()=>{try{let t=await ze(e.id);pe(rc(t.data||[]))}catch(e){console.error(`Error refreshing property reviews:`,e)}if(Oe)try{let t=(await Ft({extraInfo:!1})).data?.find(t=>t.propertyId===e.id);L(t||null)}catch(e){console.error(`Error refreshing user review:`,e)}},st=async()=>{await ot(),it()},ct=()=>{ge.current?.scrollIntoView({behavior:`smooth`})},lt=e=>{let t=Math.floor(e),n=[];for(let e=0;e<5;e++)e<t?n.push((0,$.jsx)(`i`,{className:`fas fa-star text-lofty-purple`},e)):n.push((0,$.jsx)(`i`,{className:`far fa-star text-lofty-purple`},e));return n};(0,Q.useEffect)(()=>{(async()=>{if(Oe&&ke)try{let t=await Pt();if(t.success&&Array.isArray(t.data)){let n=t.data.find(t=>t.propertyId===e.id);Ce(!!n?.turnedOn),Te(!!n?.alerts)}}catch(e){console.error(`Failed to fetch watchlist:`,e)}})()},[Oe,ke,e.id]);let q=async()=>{if(Oe&&ke){Ce(e=>!e),z||(De(!0),setTimeout(()=>De(!1),1e3),Te(!0));try{z?await ut({propertyId:e.id,alerts:!1,turnedOn:!1}):await kt({propertyId:e.id})}catch(e){console.error(`Failed to update watchlist:`,e),Ce(e=>!e),z||Te(!1)}}},dt=async()=>
87{if(Oe&&ke){Te(e=>!e);try{await ut({propertyId:e.id,alerts:!we,turnedOn:z})}catch(e){console.error(`Failed to update alerts:`,e),Te(e=>!e)}}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ua,{}),(0,$.jsx)(ue,{id:`ListingOrderDetailModal`,isOpen:T,onBackdropClick:O,onRequestClose:O,className:{container:`border-none w-full h-full lg:min-w-300-px lg:min-h-300-px lg:w-[80%] lg:h-[80%]`,content:`m-0 p-0 h-full flex flex-1`,overflow:`hidden`},minHeight:`400px`,fullScreen:!0,showCloseBtn:!1,children:(0,$.jsx)(Rn,{property:e,orderId:k?.orderId,direction:k?.direction,onClose:O,onOrderCanceled:l})}),(0,$.jsx)(ue,{id:`reviewModal`,isOpen:nt,onBackdropClick:it,onRequestClose:it,showCloseBtn:!1,className:{container:`w-auto border-none`,containerColors:`bg-transparent border-transparent`,content:`m-0 p-0`},minHeight:`auto`,children:(0,$.jsx)(ec,{propertyId:e.id,onClose:it,onSubmit:st})}),v&&(0,$.jsx)(xs,{property:e,orderBook:t,propertyInfo:n,pricing:r,userOrderData:i,isActive:x,isComingSoon:C,isSold:w,hasSellOrders:Xe,hasFilledOrders:!!Je,isSecondaryMarket:!!Ye,tradingDisabled:Ie,kycVerified:Ze,hideTabs:Qe,chartPoints:M,yieldData:o,averageHistoricalYield:Me,reviews:F,averageRating:V,showReviews:!0,reviewsRef:_e,isLoadingReviews:me,userReview:I,onWriteReview:Ne>0?at:void 0,currentOwned:Ne,ownedPct:U,userProjectedAnnualReturn:W,userRentalYield:Le,userProjectedRentalYield:Re,listingDescription:Ve,listingUpdates:He,forumUpdates:a,groupItems:Be,isWatchlisted:z,hasAlerts:we,onWatchlistToggle:q,onAlertToggle:dt,onShowOrderBook:c,onRefreshUserOrderData:u,orderRequestRef:s}),y&&(0,$.jsxs)(`section`,{className:`hidden lg:flex min-w-0 flex-1 flex-col mr-0 lg:mr-8 xl:mr-16 w-full lg:w-auto`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 md:gap-3 mt-6 md:mt-8`,children:[(0,$.jsx)(ps,{isActive:x,isComingSoon:C,isSold:w,hasSellOrders:Xe}),(0,$.jsx)(Tr,{size:`md`,badges:Cr({propertyId:e.id,propertyType:e.property_type||void 0,isOccupied:e.is_occupied,isDelinquent:e.is_delinquent,coc:e.coc,isOwnerOccupied:e.isOwnerOccupied,isSellerBuyBack:e.isSellerBuyBack,currentLoan:e.current_loan})}),K&&(0,$.jsxs)(`a`,{href:K,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-2 text-sm md:text-base font-medium text-lofty-purple hover:text-lofty underline underline-offset-2`,children:[(0,$.jsx)(`img`,{src:`/static/img/airbnb-logo.png`,alt:``,"aria-hidden":`true`,className:`h-5 w-5 md:h-6 md:w-6`}),`Airbnb Listing`]})]}),(0,$.jsx)(`div`,{className:`flex flex-col md:flex-row md:items-start md:justify-between mt-6 md:mt-8`,children:(0,$.jsxs)(`div`,{className:`mr-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsx)(`h1`,{className:`text-2xl md:text-5xl font-bold text-lofty-purple-600 dark:text-lofty-gray`,children:e.address_line1}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`button`,{onClick:q,className:`focus:outline-none`,children:z?(0,$.jsx)(`i`,{className:`fas fa-heart text-lofty-purple text-xl transition-transform duration-300`,style:{animation:Ee?`heartBeat 1s ease-in-out`:`none`}}):(0,$.jsx)(`i`,{className:`far fa-heart text-gray-400 hover:text-lofty-purple text-xl transition-colors duration-300`})}),(0,$.jsx)(`button`,{onClick:dt,className:`focus:outline-none`,children:(0,$.jsx)(`i`,{className:`${we?`fas`:`far`} fa-bell text-xl ${we?`text-yellow-400`:`text-gray-400 hover:text-yellow-400 transition-colors duration-300`}`})})]})]}),(0,$.jsx)(`h4`,{className:`mb-2.5 text-lg md:text-2xl font-normal text-lofty-purple-600 dark:text-lofty-gray`,children:e.address_line2}),(0,$.jsx)(Zs,{property:e}),!me&&(0,$.jsx)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center mb-4 gap-2 sm:gap-3`,children:(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:ct,className:`text-lg font-semibold mr-2 text-lofty-purple hover:text-lofty underline cursor-pointer`,children:`Investor Reviews:`}),(0,$.jsx)(`span`,{className:`text-lofty-purple-600 dark:text-lofty-gray mr-1`,children:lt(Number(V))}),(0,$.jsxs)(`span`,{children:[V,`/5`]}
87),(0,$.jsxs)(`span`,{className:`ml-2 text-lofty-purple-600 dark:text-lofty-gray`,children:[`(`,F.length,` `,F.length===1?`review`:`reviews`,`)`]})]})})]})}),We.length>0&&We?.map(e=>(0,$.jsx)(Ps,{order:e,openDetail:()=>tt(e.id,e.direction),lpEligibility:qe(e)},e.id)),Ue?.active?.map(e=>(0,$.jsx)(Ps,{order:e,openDetail:()=>tt(e.id,e.direction),lpEligibility:qe(e)},e.id)),Je&&Ye&&(0,$.jsxs)(`section`,{ref:ve,className:`pt-12`,children:[(0,$.jsx)(`div`,{className:`mb-4 border-b border-gray-200 dark:border-lofty-purple-700 overflow-hidden`,children:(0,$.jsxs)(`ul`,{className:`flex -mb-px overflow-x-auto`,role:`tablist`,children:[(0,$.jsx)(Ao,{text:`Price`,tabPosition:0,currentTab:le,setCurrentTab:de},`Price`),o.length>0&&(0,$.jsx)(Ao,{text:`Yield`,tabPosition:1,currentTab:le,setCurrentTab:de},`Yield`)]})}),fe===0&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex mb-4 bg-gray-100 dark:bg-lofty-purple-800 rounded-full p-1 w-fit border border-gray-200 dark:border-transparent`,children:[`1D`,`7D`,`30D`,`90D`,`1Y`,`All`].map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>{xe(!0),ie(e)},"aria-pressed":P===e,className:`
88                        min-h-11 min-w-11 touch-manipulation px-3 py-1 text-sm font-medium rounded-full transition-colors duration-200
89                        ${P===e?`bg-white dark:bg-lofty-purple-600 text-lofty-purple-600 dark:text-lofty-purple shadow-sm`:`text-gray-600 dark:text-lofty-gray/60 hover:text-lofty-purple-600 dark:hover:text-lofty-purple`}
90                      `,children:e},e))}),(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-64`,"aria-hidden":`true`}),children:(0,$.jsx)(tc,{chartPoints:Ae(ae),defaultPrice:r.startingPrice})})]}),fe===1&&o.length>0&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex mb-4 bg-gray-100 dark:bg-lofty-purple-800 rounded-full p-1 w-fit border border-gray-200 dark:border-transparent`,children:[`3M`,`6M`,`9M`,`1Y`,`All`].map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>{xe(!0),se(e)},"aria-pressed":oe===e,className:`
91                        min-h-11 min-w-11 touch-manipulation px-3 py-1 text-sm font-medium rounded-full transition-colors duration-200
92                        ${oe===e?`bg-white dark:bg-lofty-purple-600 text-lofty-purple-600 dark:text-lofty-purple shadow-sm`:`text-gray-600 dark:text-lofty-gray/60 hover:text-lofty-purple-600 dark:hover:text-lofty-purple`}
93                      `,children:e},e))}),(0,$.jsx)(Q.Suspense,{fallback:(0,$.jsx)(`div`,{className:`h-64`,"aria-hidden":`true`}),children:(0,$.jsx)(nc,{data:je(ce)})})]})]}),et().length>1&&(0,$.jsx)(`section`,{className:`flex flex-col mt-8 2xl:mt-12`,children:(0,$.jsx)(`div`,{className:`mb-4 border-b border-gray-200 dark:border-lofty-purple-700 overflow-hidden`,children:(0,$.jsx)(`ul`,{className:`flex -mb-px overflow-x-auto`,role:`tablist`,children:et().map((e,t)=>(0,$.jsx)(Ao,{text:e,tabPosition:t,currentTab:d,setCurrentTab:f},e))})})}),(0,$.jsxs)(`section`,{children:[p===0&&(0,$.jsx)(So,{property:e,currentOwned:Ne,ownedPct:U,userProjectedAnnualReturn:W,userRentalYield:Le,userProjectedRentalYield:Re,listingDescription:Ve,listingUpdates:He,forumUpdates:a,hidden:!1,reviews:F,reviewsRef:ge,showReviews:!0,isLoadingReviews:me,userReview:I,onWriteReview:Ne>0?at:void 0}),$e&&p===1&&(0,$.jsx)(Xs,{property:e,orderBook:t,propertyInfo:n,pricing:r,hidden:!1}),!Qe&&(p===1||!h)&&(0,$.jsx)(ko,{property:e,propertyInfo:n,groupItems:Be,hidden:p!==1,averageHistoricalYield:Me}),!Qe&&p===2&&(0,$.jsx)(Xs,{property:e,orderBook:t,propertyInfo:n,pricing:r,hidden:!1})]})]})]})}var ac=e=>{let{processingFee:t,operatingReserveFee:n,poolFee:r,isMarketOrder:i,isBuyOrder:a,isInternalPmmV2:o,isWalletPayment:s}=e,c=!o&&i&&a?1:0;return(s?0:t)+n+(i?r:0)+c};Be.EXECUTED,Be.CANCELLED,Be.EXPIRED,V.Canceled,V.Failed,V.Refunded,V.Success;var oc=(e,t)=>e||!Number.isFinite(t)||t===0,sc=(e,t)=>e==null||e>=t-1e-9,cc=({reinvestOn:e,amountTooSmall:t,usdMode:n,usdFocused:r,usdAmount:i,usdMax:a,recurringMinUsd:o})=>!(!e||!t||n&&oc(r,i)||n&&i>0&&(o==null||sc(a,o))),lc=({reinvestOn:e,usdMode:t,usdFocused:n,usdAmount:r,recurringMinUsd:i,usdMax:a})=>!e||!t||n||!sc(a,i)?!1:r>0&&r<i-1e-9,uc=({usdMode:e,usdFocused:t,usdAmount:n,usdMax:r})=>!e||t||r==null?!1:n>r+.01,dc=(e,t)=>t==null||e<=t+.01,fc=({levels:e,quantity:t,isSellOrder:n})=>{if(!Number.isFinite(t)||t<=0)return;let r=e.filter(({price:e,quantity:t})=>Number.isFinite(e)&&e>0&&Number.isFinite(t)&&t>0).sort((e,t)=>
93n?t.price-e.price:e.price-t.price),i=t,a=0,o=0;for(let e of r){let t=Math.min(i,e.quantity);if(!(t<=0)&&(a=e.price,o+=t*e.price,i-=t,i<=1e-9))break}if(!(i>1e-9||a<=0))return{capPrice:a,filledNotional:o}},pc=({levels:e,quantityMax:t,isSellOrder:n})=>{let r=fc({levels:e,quantity:t,isSellOrder:n});if(!r)return;let i=r.filledNotional*100;return(n?Math.floor(i+1e-9):Math.ceil(i-1e-9))/100},mc=({usdMode:e,intentChanged:t,previousQuantity:n,baseCandidateQuantity:r,quotedCandidateQuantity:i,isSellOrder:a,quantityMax:o})=>{if(!e)return 0;let s=t?r:a?Math.max(n,i):Math.min(n,i),c=Number.isFinite(s)?Math.max(0,s):0;return o==null?c:Math.min(c,o)},hc=e=>e<.005,gc=({title:e,subtitle:t,onClick:n,highlightText:r,style:i=`button`,active:a})=>(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col justify-center relative self-stretch`,children:[(0,$.jsxs)(`button`,{type:`button`,className:[i===`button`?`border border-lofty`:``,a?`bg-lofty-purple border-lofty-purple`:`bg-transparent`,`appearance-none rounded-lg flex flex-col items-center justify-center h-full`,`py-1 px-1.5 gap-y-0.5`,`sm:py-1.5 sm:px-2`,`2xl:px-2.5 2xl:gap-y-1`].filter(Boolean).join(` `),onClick:n,children:[(0,$.jsx)(`span`,{className:[a?`text-white`:`text-lofty dark:text-white/80`,i===`link`?`underline`:``,`text-mxs sm:text-sm 2xl:text-lg whitespace-nowrap`].filter(Boolean).join(` `),children:e}),!!t&&(0,$.jsx)(`span`,{className:[`text-sxs sm:text-mxs 2xl:text-sm whitespace-nowrap`,a?`text-white`:`text-lofty/60 dark:text-white/80`].join(` `),children:t})]}),!!r&&(0,$.jsx)(`span`,{className:`absolute left-0 right-0 -bottom-5 uppercase mt-1.5 text-sxs text-black dark:text-white/60 -tracking-tight text-center overflow-visible whitespace-nowrap`,children:r})]}),_c={title:`Custom`,value:`custom`,id:`custom`,active:!1},vc=e=>!!e.find(e=>!!e.highlightText),yc=e=>(0,$.jsx)(`div`,{className:`flex w-full items-start gap-x-1.5 sm:gap-x-2 mt-3 overflow-x-auto -mx-1 px-1 no-scrollbar ${vc(e.items)?`mb-7`:`mb-2`}`,children:e.items.map(t=>(0,$.jsx)(gc,{title:t.title,subtitle:t.subtitle,highlightText:t.highlightText,active:t.active,onClick:()=>e.onSelected(t),style:`button`},t.id))}),bc=[1,10,25,50,100],xc=(e,t)=>bc.map(n=>({title:`${n} ${n===1?`share`:`shares`}`,subtitle:`${z(H(n*e,0,!0),{minimumFractionDigits:0,maximumFractionDigits:0})}`,value:n,id:`${n}-tokens`,highlightText:n===25?`Most Popular`:void 0,active:n===t})),Sc=e=>!e||e<=0?0:e;function Cc(e){let{options:t,name:n,label:r,text:i,subText:a,tooltip:o,icon:s,control:c,disabled:l,selectorOptions:u,min:d=1,max:f,step:p=1,incrementStep:m,suggestedValue:h,showInput:g=!0,showMaxButton:_=!1,onLimitHit:v,onFocus:y,onBlur:b,inlineValueIcon:x=!1}=e,[S,C]=(0,Q.useState)(!1),[w]=(0,Q.useState)(g),T=(0,Q.useRef)(null),E=(0,Q.useRef)(null),D=(0,Q.useRef)(!1),ee=()=>{let e=E.current;!e||D.current||(D.current=!0,e.classList.add(`order-value-pop`))},O=e=>{T.current?.onChange({type:`input`,target:{value:e,name:n}})},k=()=>{let e=T.current?.value;return typeof e==`number`?e:Number(e)||0},A=Math.max(0,-Math.floor(Math.log10(p))),j=e=>Number(e.toFixed(A)),te=e=>{let t=k(),n=t+e*(m??p),r=j(Math.max(d,f==null?n:Math.min(n,f)));e>0&&f!=null&&n>f&&v?.(),r!==t&&ee(),O(r)},ne=l||f!=null&&f<=0,M=e=>{e.id===_c.id?O(h??d):O(e.value)},re=u?Sc(u.price):0,N=(f??0)>0&&a?()=>O(f):void 0,P=!!r,ie=u?.enabled&&P;return(0,$.jsxs)(`div`,{className:P?`py-2`:``,children:[P&&(0,$.jsxs)(`div`,{className:`flex flex-row justify-between items-center`,children:[(0,$.jsx)(Nn,{label:r,tooltip:o,htmlFor:n,nowrap:!0}),a&&(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-xs text-right text-lofty-gray-500 dark:text-slate-300`,children:[(0,$.jsx)(`span`,{onClick:N,children:a}),_&&!!N&&(0,$.jsx)(`button`,{type:`button`,onClick:N,className:`px-2 py-0.5 rounded-full border border-lofty-purple text-lofty-purple text-xs font-semibold hover:opacity-80`,children:`Max`})]})]}),ie&&(0,$.jsx)(yc,{items:xc(re,u.quantity),customVisible:w,onSelected:M}),(0,$.jsxs)(`div`,{className:[`border bg-white dark:bg-white/[0.03] rounded-2xl flex items-center gap-2 sm:gap-3 px-2.5 sm:px-3.5 py-3 sm:py-4 transition-colors`,w?``:`hidden`,S?`border-lofty shadow-[0_0_0_3px_rgba(77,63,237,0.12)]`:`border-lofty-gray-300 dark:border-white/15`].join(` `),children:[!l&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>te(-1),disabled:ne,"aria-label":`Decrease quantity`,className:`shrink-0 w-12 h-12 sm:w-14 sm:h-14 flex items-center justify-center rounded-xl bg-lofty-purple-50 dark:bg-white/10 text-lofty-purple-600 dar
93k:text-white text-3xl font-light hover:bg-lofty/10 dark:hover:bg-white/20 active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed transition-all`,children:`−`}),(!!s||!!i)&&!x&&(0,$.jsxs)(`div`,{className:`font-medium whitespace-nowrap text-lofty-gray-700 dark:text-white flex items-center text-sm`,children:[s,!!i&&(0,$.jsx)(`span`,{children:i})]}),(0,$.jsx)(L,{name:n,control:c,rules:t,render:({field:e})=>(T.current=e,(0,$.jsx)(`div`,{ref:E,className:`flex-1 min-w-0`,onAnimationEnd:e=>{e.target===e.currentTarget&&(e.currentTarget.classList.remove(`order-value-pop`),D.current=!1)},children:(()=>{let t=(0,$.jsx)(Lr,{...e,id:n,min:d,max:f,step:p,precision:A,trimTrailingZeros:x,spinner:!1,inputClassName:`appearance-none text-4xl sm:text-5xl bg-transparent border-0 w-full h-full shadow-none text-lofty-purple-600 dark:text-white font-bold ${x?`text-left`:`text-center`} focus:outline-none focus:border-0 focus-visible:border-0 focus:ring-0 tabular-nums`,overrideDefaultStyles:!0,disabled:l,onChange:O,onFocus:()=>{C(!0),y?.()},onBlur:()=>{C(!1),b?.()}});if(!x)return t;let r=Number(e.value),i=String(S||!Number.isFinite(r)?e.value??``:r),a=Math.max(1,i.length);return(0,$.jsxs)(`div`,{className:`flex items-center justify-center translate-x-[0.5ch] text-4xl sm:text-5xl`,children:[s,(0,$.jsx)(`div`,{className:`min-w-0 max-w-full text-4xl sm:text-5xl font-bold tabular-nums`,style:{width:`calc(${a+1}ch)`},children:t})]})})()}))}),!l&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>te(1),disabled:ne,"aria-label":`Increase quantity`,className:`shrink-0 w-12 h-12 sm:w-14 sm:h-14 flex items-center justify-center rounded-xl bg-lofty text-white text-3xl font-light hover:brightness-110 active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed shadow-[0_4px_12px_rgba(77,63,237,0.25)] transition-all`,children:`+`})]})]})}var wc=e=>{let t=e.marketOrderValidation;if(!e.isInternalPmmV2||!e.isMarketOrder||!e.isBuyOrder||e.isPrimaryOrder||t?.buyMaintainerFeeAsset!==`quote`||!t.includedFees||e.quantity<=0)return;let n=e.smartRoute,r=n?n.ammQty/e.quantity:1;if(r<=0)return;let i=H(t.includedFees.liquidity*r,2)+H(t.includedFees.maintainer*r,2),a=n?Math.abs(n.bookAllIn-n.bookGrossCost):0,o=[Y.Shared,Y.External].includes(e.paymentMethod?.type);return{fees:i+a+(o?0:e.processingFee),pricePerToken:(H(e.totalUsdPrice,2)-i)/e.quantity}},Tc=(e,t)=>{let n=e.isInternalPmmV2&&e.isMarketOrder,r=`${e.v2DollarQuoteContextKey}:${e.orderType}:${e.isBuyOrder}:${e.usdMode}`,i=n?e.v2DollarQuote.error:null,a=n&&(e.v2DollarQuote.pending||!!i||!e.marketOrderValidation?.result.value),o=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{n&&!a&&(o.current={key:r,data:e,fees:t})},[n,a,r,e,t]);let s=a&&o.current?.key===r?o.current:null;return{data:s?.data??e,fees:s?.fees??t,awaitingQuote:a,quoteError:i,hasColdQuote:a&&!s,showQuoteSpinner:a&&!i}},Ec=1e6,Dc=({control:e,options:t,name:n,bids:r,price:i,coc:a,selectedCurrency:o,sell:s=!1})=>{let c=ge({id:`PriceInput`,requireUpdates:!0}),[l,u]=(0,Q.useState)(!1),d=c.getExchangeRate(o)?.rate??1,f=c.currentRates?i/d:0,p=!s&&!!o&&o.toUpperCase()!==`USDC`,m=r?.hc??0;return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:[`border bg-white dark:bg-white/[0.03] rounded-2xl flex items-center px-4 py-3 transition-colors`,l?`border-lofty shadow-[0_0_0_3px_rgba(77,63,237,0.12)]`:`border-lofty-gray-300 dark:border-white/15`].join(` `),children:[(0,$.jsx)(`span`,{className:`text-3xl sm:text-4xl font-bold text-lofty-gray-700 dark:text-white/40 tabular-nums`,children:`$`}),!s&&!o?(0,$.jsx)(`div`,{className:`flex-1 h-12 flex items-center justify-end`,children:(0,$.jsx)(zt,{color:`text-lofty dark:text-slate-300`})}):(0,$.jsx)(L,{name:n,control:e,rules:t,render:({field:e})=>(0,$.jsx)(Lr,{...e,id:n,min:1,max:Ec,step:.01,precision:2,fixedDecimalScale:!0,spinner:!1,inputClassName:`appearance-none flex-1 text-3xl sm:text-4xl bg-transparent border-0 w-full shadow-none text-lofty-purple-600 dark:text-white font-bold text-right focus:outline-none focus:border-0 focus-visible:border-0 focus:ring-0 tabular-nums`,overrideDefaultStyles:!0,onChange:t=>e.onChange({type:`input`,target:{value:t,name:n}}),onFocus:()=>u(!0),onBlur:()=>u(!1)})})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between mt-2 px-1 text-xs gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[m>0&&(0,$.jsxs)(`span`,{className:`text-lofty-gray-700 dark:text-white/60 truncate`,children:[`Fair value `,(0,$.jsx)(`span`,{className:`font-semibold text-lofty-purple-600 dar
93k:text-white`,children:z(m,{minimumFractionDigits:2,maximumFractionDigits:2})})]}),!s&&a>0&&(0,$.jsxs)(`span`,{className:`text-lofty-gray-700 dark:text-white/60 truncate`,children:[`Yield `,(0,$.jsxs)(`span`,{className:`font-semibold text-lofty-purple-600 dark:text-white`,children:[W(a,2),`%`]})]})]}),p&&(0,$.jsx)(`span`,{className:`text-lofty-gray-700 dark:text-white/60 whitespace-nowrap shrink-0`,children:c.isLoading?(0,$.jsx)(zt,{color:`text-lofty dark:text-slate-300`,className:`w-3 h-3`}):(0,$.jsxs)($.Fragment,{children:[`≈ `,(0,$.jsx)(`span`,{className:`font-semibold text-lofty-purple-600 dark:text-white tabular-nums`,children:W(f,4)}),` `,o.toUpperCase()]})})]})]})},Oc=(e,t,n)=>Math.max(0,H((Number.isFinite(e)?e:0)*(t?n:1),2,!1)),kc=(e,t)=>H(Math.min(Math.max(0,Number.isFinite(e)?e:0),Math.max(0,Number.isFinite(t)?t:0)),2,!1),Ac=(e,t)=>t===Y.Shared?e.find(e=>e.shared):e.find(e=>!e.shared),jc=(e,t)=>e?.cryptoAssets?.find(e=>e.symbol===t)?.amount??0,Mc=(e,t)=>{let n=Ac(e,t);return G.some(e=>jc(n,e.symbol)>0)},Nc=e=>Mc(e,Y.Shared)||Mc(e,Y.External),Pc=e=>G.find(t=>t.symbol===e),Fc=(e,t,n,r)=>{if(!(n>0))return Mc(e,t);let i=Pc(r)??G[0],a=Sn(Ac(e,t),i.symbol,n,t===Y.Shared);return a.hasPayment&&a.hasFee},Ic=(e,t,n)=>Fc(e,Y.Shared,t,n)||Fc(e,Y.External,t,n),Lc=(e,t,n)=>{let r=Ac(e,t),i=Pc(n);return i&&jc(r,i.symbol)>0?i.symbol:G.find(e=>jc(r,e.symbol)>0)?.symbol},Rc=(e,t)=>e.find(e=>e.id===t)??e[0],zc=e=>e.find(e=>e.type===Y.Card&&e.default)??e.find(e=>e.type===Y.Card),Bc=e=>e.type!==Y.Bank&&e.type!==Y.NewBank,Vc=e=>e.some(e=>e.type===Y.Card),Hc=(e,t,{isMarketOrder:n,isSellOrder:r,hideWallet:i})=>{let a=t.find(e=>e.defaultWallet),o=!a||a.shared?Y.Shared:Y.External;if(r)return e.find(e=>e.type===o);let s=e.filter(Bc);return n?!i&&Mc(t,o)?s.find(e=>e.type===o):zc(s):i?zc(s):s.find(e=>e.default)},Uc=1e-4,Wc=.01,Gc=Math.max(0,-Math.floor(Math.log10(Uc))),Kc=1,qc=[{title:`Every Week`,value:`weekly`},{title:`Every 2 Weeks`,value:`two_weeks`},{title:`Every Month`,value:`monthly`}],Jc=2,Yc={minimumFractionDigits:2,maximumFractionDigits:2},Xc=e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase(),Zc=[Y.Card,Y.Bank,Y.Shared,Y.External],Qc=({hasCheckoutBalances:e,selectableCount:t,isFirstInvestment:n,paymentMissing:r})=>e?!1:t===0||n&&r;function $c({bestBuyPrice:e,bestSellPrice:t,startingPrice:n,property:r,orderFormData:i,requestOrderBook:a,orderBook:o,sellMax:s,buyMax:c,buyFundsAvailable:l,suggestedBuy:u,addPaymentMethod:d,paymentMethods:f,useBalances:m,reinvest:h,setReinvest:g,feesData:_,currentStep:v,isFirstInvestment:b,existingRecurringPlan:x}){let C=te(),w=Tc(i,_),T=N(),E=Oc(m.rent,C.shouldWithhold,ke),D=C.shouldWithhold&&m.rent>0?`Unlock your full rent balance by sending a W-8BEN form to [email protected]. 30% tax withholding applies to international investors without a W-8 exception.`:void 0,ee=S(),O=S(),[k,j]=(0,Q.useState)(!1),[ne,M]=(0,Q.useState)(!1),[re,P]=(0,Q.useState)(!1),[ie,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1),[ce,le]=(0,Q.useState)(!1),de=i.giftEscrowLockupSummary,fe=de?.nextUnlockTs?Math.max(0,Math.ceil((de.nextUnlockTs-Date.now())/(1440*60*1e3))):0,[F,pe]=(0,Q.useState)([]),[I,L]=(0,Q.useState)(!1),[me,he]=(0,Q.useState)(null),ge=y(p),_e=(0,Q.useMemo)(()=>ge.find(e=>e.shared&&e.defaultWallet)?.address??ge.find(e=>e.shared)?.address??``,[ge]),[ye,Se]=(0,Q.useState)(0),we=ur(r,i.pricePerToken),Ee=i.isMarketOrder&&i.limits.marketDepthMax!==null,B=i.isSellOrder?r.liquidity?.marketPrice.priceLow??0:r.liquidity?.marketPrice.priceHigh??0,De=!!r.liquidity&&B>0,Oe=De&&i.isInternalPmmV2,V=Oe?B:i.isSellOrder?e:t,Ae=V&&V>0?V:i.pricePerToken,je=r.assetDecimals??0,Ne=xn({screen:Te,assetDecimals:je,isMarketOrder:i.isMarketOrder,isBuyOrder:i.isBuyOrder,pricePerToken:Ae}),Pe=Ne===`whole-shares`,U=Pe?1:Uc,Fe=Pe?1:Wc,Ie=Pe?1:Wc,W=mt(je),Le=i.isSellOrder?s>0?s:void 0:c>0?c:void 0,Re=Pe&&Le!=null?Math.floor(Le):Le,ze=i.pricePerToken>0?i.pricePerToken:Ae,Be=Ne===`dollars`,[Ve,He]=(0,Q.useState)(!1),{v2DollarQuote:Ue}=i,We=i.isInternalPmmV2?i.usdMode:Ve,Ge=i.isInternalPmmV2?i.setUsdMode:He,[Ke,Je]=(0,Q.useState)(!1),Ye=(0,Q.useRef)(!1),Xe=(0,Q.useRef)(!1),Qe=i.isInternalPmmV2&&i.isBuyOrder&&i.isMarketOrder,$e=Dn(Ae,Uc,Kc,Wc),K=(!Oe&&Re!=null?pc({levels:i.isSellOrder?o?.orderBook?.buyOrders??[]:o?.orderBook?.sellOrders??[],quantityMax:Re,isSellOrder:i.isSellOrder}):void 0)??(Re!=null&&Ae>0?Math.floor(Re*Ae*100)/100:void 0),tt=K==null?$e:Math.min($e,K),nt=(e,t)=>
93{if(!Number.isFinite(e)||e<=0||t<=0)return 0;if(i.isSellOrder&&Re!=null&&K!=null&&e>=K-1e-9)return Re;let n=Math.floor(e/t/Uc+1e-9)*Uc;return Number((Re==null?n:Math.min(n,Re)).toFixed(Gc))},rt=e=>nt(e,ze);(0,Q.useEffect)(()=>{if(!Be){Ge(!1);return}if(!Ye.current)if(Ge(!0),Xe.current)K!=null&&Number(i.form.getValues(`usdAmount`)??0)>K&&i.form.setValue(`usdAmount`,K,{shouldDirty:!0,shouldValidate:!0});else{Xe.current=!0;let e=K==null?100:Math.min(100,K);i.form.setValue(`usdAmount`,e,{shouldDirty:!1,shouldValidate:!0})}},[Be,i.isBuyOrder]);let it=Number(i.form.watch(`usdAmount`)??0),at=Number(i.form.watch(`tokenQuantity`)??0),st=We?rt(it):0,lt=We?nt(it,Ae):0,ut=`${We?`usd`:`shares`}:${i.isSellOrder?`sell`:`buy`}:${it}`,[dt,ft]=(0,Q.useState)({intentKey:ut,quantity:lt}),pt=dt.quantity;(0,Q.useEffect)(()=>{Ue.active||ft(e=>{let t=e.intentKey!==ut;if(!t&&We&&it>0&&st<=0)return e;let n=mc({usdMode:We,intentChanged:t,previousQuantity:e.quantity,baseCandidateQuantity:lt,quotedCandidateQuantity:st,isSellOrder:i.isSellOrder,quantityMax:Re});return e.intentKey===ut&&e.quantity===n?e:{intentKey:ut,quantity:n}})},[i.isSellOrder,Re,lt,st,We,ut,it,Ue.active]),(0,Q.useEffect)(()=>{!We||Ue.active||Ke&&pt===0||Math.abs(at-pt)<1e-9||i.form.setValue(`tokenQuantity`,pt,{shouldDirty:!0,shouldValidate:!0})},[We,pt,at,Ke,Ue.active]);let[ht,gt]=(0,Q.useState)(0),_t=(0,Q.useRef)(null),vt=(0,Q.useRef)(null),yt=()=>{let e=_t.current;e&&!e.classList.contains(`order-limit-shake`)&&e.classList.add(`order-limit-shake`),gt(e=>e+1),vt.current&&window.clearTimeout(vt.current),vt.current=window.setTimeout(()=>gt(0),2600)};(0,Q.useEffect)(()=>()=>{vt.current&&window.clearTimeout(vt.current)},[]);let bt=(0,Q.useRef)(!1),xt=(0,Q.useRef)(void 0);(0,Q.useEffect)(()=>{if(!We||K==null){bt.current=!1,xt.current=K;return}let e=it>K+1e-9,t=xt.current!==K;e&&!bt.current&&!t&&yt(),bt.current=e,xt.current=K},[We,K,it]),(0,Q.useEffect)(()=>{uc({usdMode:We,usdFocused:Ke,usdAmount:Number(i.form.getValues(`usdAmount`)??0),usdMax:K})&&i.form.setValue(`usdAmount`,K,{shouldDirty:!0,shouldValidate:!0})},[We,K,it,Ke]);let St=(()=>{if(K==null)return null;let e=`$${R(K,Yc)}`;return i.isSellOrder?`Max reached - ${e} is your whole position.`:Ee&&Re!=null&&i.limits.marketDepthMax===Re?`Max reached - ${e} is all that's for sale right now.`:`Max reached - ${e} is the most you can buy right now.`})(),Ct=()=>{if(Ye.current=!0,!We){let e=at>0&&ze>0?Number(Qe?Math.max(0,at*ze-(i.marketOrderValidation?.includedFees?.maintainer??0)-(i.marketOrderValidation?.includedFees?.liquidity??0)).toFixed(2):(at*ze).toFixed(2)):K==null?100:Math.min(100,K);i.form.setValue(`usdAmount`,e,{shouldDirty:!0,shouldValidate:!0})}Ge(e=>!e)},wt=(e,t)=>(0,$.jsxs)(`div`,{className:`border bg-white dark:bg-white/[0.03] rounded-2xl flex items-center gap-2 sm:gap-3 px-2.5 sm:px-3.5 py-3 sm:py-4 border-lofty-gray-300 dark:border-white/15`,"aria-hidden":!0,children:[(0,$.jsx)(`span`,{className:`shrink-0 w-12 h-12 sm:w-14 sm:h-14 flex items-center justify-center rounded-xl bg-lofty-purple-50 dark:bg-white/10 text-lofty-purple-600 dark:text-white text-3xl font-light`,children:`−`}),(0,$.jsxs)(`span`,{className:`flex-1 min-w-0 flex items-center justify-center truncate`,children:[t&&(0,$.jsx)(`span`,{className:`text-3xl sm:text-4xl font-bold select-none text-lofty-purple-300 dark:text-white/40`,children:`$`}),(0,$.jsx)(`span`,{className:`text-4xl sm:text-5xl text-lofty-purple-600 dark:text-white font-bold tabular-nums`,children:e})]}),(0,$.jsx)(`span`,{className:`shrink-0 w-12 h-12 sm:w-14 sm:h-14 flex items-center justify-center rounded-xl bg-lofty text-white text-3xl font-light shadow-[0_4px_12px_rgba(77,63,237,0.25)]`,children:`+`})]}),Tt=()=>(0,$.jsx)(Cc,{name:`tokenQuantity`,register:i.form.register,control:i.form.control,label:``,text:``,icon:null,subText:void 0,selectorOptions:void 0,min:Fe,max:Re,step:U,incrementStep:Ie,suggestedValue:u,errors:i.form.formState.errors,options:{required:`This field is required`,min:{value:0,message:`error message`},validate:{positive:e=>e>0,withinMax:e=>Re==null||Number(e)<=Re||`You can trade at most ${Re} share${Re===1?``:`s`}`,onStep:e=>Pe?Number.isInteger(Number(e))||`Enter a whole number of shares`:Math.abs(Number(e)/Uc-Math.round(Number(e)/Uc))<1e-9||`Enter a multiple of ${Uc} shares`,meetsMinimum:e=>Pe||Number(e)>=Wc-1e-9||`The minimum order is ${Wc} shares`}},tooltip:``,showMaxButton:!1}),Et=i.isMarketSelectable,Dt=qe.filter(e=>e.name===Ce.Limit||e.name===Ce.Market&&Et||e.name===Ce.Optimized&&i.optimizedOrderEligible),Ot=Dt.length>1,kt=W&&!i.isPrimaryOrder,At=xe(i.orderType),J=Ze.find(e=>e.name===i.orderType),jt=i.form.watch(`triggerPrice`),Mt=i.form.watch(`triggerLimitPrice`),Pt=i.form.watch(`trailPercent`),Ft=i.form.watch(`referenceWindowDays`)??30,It=(0,Q.useMemo)(()=>
93{if(!xe(i.orderType))return``;let e=i.isSellOrder,t=`${Ft}-day average price`;if(i.orderType===Ce.TrailingStop){let n=Number(Pt)||0;return n?e?`Triggers when the ${t} falls ${n}% from its high — then sells at the best available price.`:`Triggers when the ${t} recovers ${n}% from its low — then buys at the best available price.`:``}let n=Number(jt)||0;if(!n)return``;let r=e?`falls`:`climbs`,a=`$${R(n,Yc)}`;if(i.orderType===Ce.StopLimit){let n=Number(Mt)||0,i=n?` at $${R(n,Yc)}`:``;return`Triggers when the ${t} ${r} to ${a} — then places a limit ${e?`sell`:`buy`}${i}.`}return`Triggers when the ${t} ${r} to ${a} — then ${e?`sells`:`buys`} at the best available price.`},[i.orderType,i.isSellOrder,jt,Mt,Pt,Ft]);(0,Q.useEffect)(()=>{i.orderType===Ce.TrailingStop&&!i.form.getValues(`trailPercent`)&&i.form.setValue(`trailPercent`,5,{shouldValidate:!0}),xe(i.orderType)&&!i.form.getValues(`referenceWindowDays`)&&i.form.setValue(`referenceWindowDays`,30,{shouldValidate:!0})},[i.orderType]),(0,Q.useEffect)(()=>{if(!xe(i.orderType))return;let e=Number(Mt)||Number(jt)||0;e>0&&Math.abs(Number(i.form.getValues(`price`))-e)>1e-9&&i.form.setValue(`price`,e,{shouldDirty:!0,shouldValidate:!0})},[i.orderType,jt,Mt]);let Lt=We&&Number(it)>0?H(Number(it),2,!1):H(i.totalUsdPrice,2,!1);(0,Q.useEffect)(()=>{h&&Math.abs(Number(i.form.getValues(`recurringUsdAmount`)??0)-Lt)>.005&&i.form.setValue(`recurringUsdAmount`,Lt)},[h,Lt]);let Bt=Lt<4.999999999,Vt=ge.find(e=>e.address===_e)?.cryptoAssets?.find(e=>e.symbol===`USDC`),Ht=Vt?Vt.amount/10**Vt.decimals:0,Ut=!f.some(e=>e.type===Y.Card)&&!(Lt>0&&Ht>=Lt),Wt=Bt||Ut,{hasLoaded:Gt}=A(),Kt=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(!(Kt.current||!g)&&!(!W||!i.isBuyOrder||!i.isMarketOrder)&&Gt){if(x){Kt.current=!0;return}Kt.current=!0,!b&&!h&&!Wt&&g(`monthly`)}},[Gt,b,W,i.isBuyOrder,i.isMarketOrder,x,Wt]),(0,Q.useEffect)(()=>{h&&Ut&&g?.(``)},[h,Ut,g]),(0,Q.useEffect)(()=>{lc({reinvestOn:!!h,usdMode:We,usdFocused:Ke,usdAmount:Number(it),recurringMinUsd:5,usdMax:K})&&i.form.setValue(`usdAmount`,5,{shouldValidate:!0})},[h,We,it,Ke,K]),(0,Q.useEffect)(()=>{g&&cc({reinvestOn:!!h,amountTooSmall:Bt,usdMode:We,usdFocused:Ke,usdAmount:Number(it),usdMax:K,recurringMinUsd:5})&&g(``)},[h,Bt,We,Ke,it,K]),(0,Q.useEffect)(()=>{if(!xe(i.orderType))return;m.appliedRent>0&&m.onAddBalance(q.Rent,0),m.appliedGift>0&&m.onAddBalance(q.Gift,0);let e=f.find(e=>e.type===Y.Shared);e&&i.form.getValues(`paymentMethod`)!==e.name&&i.form.setValue(`paymentMethod`,e.name,{shouldDirty:!0,shouldValidate:!0})},[i.orderType,m.appliedRent,m.appliedGift]);let qt=e=>Ze.find(t=>t.name===e)?.title??Xc(e),Jt=Ot||kt||!!r.liquidity&&!De,Yt=i.isBuyOrder&&i.isWalletPayment,Xt=i.isMarketOrder,Zt=(0,Q.useMemo)(()=>[...o?.orderBook?.sellOrders??[]].sort((e,t)=>e.price-t.price).slice(0,5),[o?.orderBook?.sellOrders]),Qt=(0,Q.useMemo)(()=>[...o?.orderBook?.buyOrders??[]].sort((e,t)=>t.price-e.price).slice(0,5),[o?.orderBook?.buyOrders]),$t=f.filter(e=>e.type===Y.Shared||e.type===Y.External),en=$t.find(e=>e.name===i.form.watch(`paymentMethod`))??$t[0],tn=(0,Q.useMemo)(()=>F.reduce((e,t)=>e+(t.amountLocked??0),0),[F]);return(0,Q.useEffect)(()=>{(async()=>{if(!i.isSellOrder){pe([]),he(null);return}L(!0),he(null);try{let e=await ot(r.id);pe(e?.lockups??[])}catch{he(`Unable to load gift escrow details.`)}finally{L(!1)}})()},[i.isSellOrder,r.id]),(0,Q.useEffect)(()=>{let e=!1;return(async()=>{if(!i.isSellOrder||!_e){Se(0);return}try{let t=(await be(_e))?.data?.summary?.pools??{},n=Object.values(t).reduce((e,t)=>{if(t?.participant?.propertyId!==r.id)return e;let n=Cn(t);return e+(Number.isFinite(n)&&n>0?n:0)},0);e||Se(n)}catch{e||Se(0)}})(),()=>{e=!0}},[i.isSellOrder,_e,r.id]),(0,Q.useEffect)(()=>{i.showLimitPriceInput||ae(!1)},[i.showLimitPriceInput]),(0,$.jsxs)(`div`,{className:`w-full`,children:[(0,$.jsx)(ue,{id:`gift-escrow-lockups`,isOpen:ee.isModalOpen,onRequestClose:ee.closeModal,className:{container:`w-full mx-6 md:max-w-md !rounded-3xl border border-gray-200 dark:border-white/10 p-2`,containerColors:`bg-white dark:bg-[#0B122A]`,content:`sm:p-2`},children:(0,$.jsxs)(`div`,{className:`p-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col text-center items-center justify-center mb-6 mt-2`,children:[(0,$.jsx)(`h3`,{className:`text-2xl font-bold text-gray-900 dark:text-white mb-2`,children:`Gift escrow release schedule`}),(0,$.jsx)(`p`,{className:`text-base text-gray-500 dark:text-gray-400`,children:`These shares cannot be sold until their release date.`})]}),(0,$.jsxs)(`div`,{className:`mt-2 w-full`,children:[I&&(0,$.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center`,children:`Loading lockups...`}),me&&(0,$.jsx)(`div`,{className:`text-sm text-red-500 text-center`,children:me}),!I&&!me&&F.length>0&&(0,$.jsxs)(`div`,{className:`border border-gray-200 dark:border-white/10 rounded-2xl overflow-hidden w-full`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 bg-gray-50 dark:bg-white/5 px-6 py-4 text-xs font-semibold text-gray-600 dark:text-gray-300 uppercase tracking-wider`,children:[(0,$.jsx)(`div`,{children:`Locked Shares`}),(0,$.jsx)(`div`,{children:`Release Date`})]}),F.map((e,t)=>(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 px-6 py-4 text-sm border-t border-gray-100 dark:border-white/10 text-gray-900 dark:text-white font-medium`,children:[(0,$.jsx)(`div`,{children:R(e.amountLocked??0,Nt)}),(0,$.jsx)(`div`,{children:e.expiryTs?gn(new Date(e.expiryTs),`MMM d, yyyy`):`-`})]},`${e.expiryTs}-${t}`))]})]})]})}),(0,$.jsx)(`form`,{children:(0,$.jsx)(`div`,{className:`mx-auto relative pb-1`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex flex-col gap-y-3`,children:[b&&T&&i.isBuyOrder&&(0,$.jsxs)(`div`,{className:`rounded-2xl bg-lofty/[0.08] border border-lofty/20 px-4 py-3 flex items-start gap-3`,children:[(0,$.jsx)(`span`,{className:`shrink-0 flex h-7 w-7 items-center justify-center rounded-full bg-lofty/15`,children:(0,$.jsx)(`i`,{className:`fas fa-sparkles text-xs text-lofty`})}),(0,$.jsxs)(`p`,{className:`mt-1 text-sm leading-snug text-lofty-purple-600 dar
93k:text-white/90`,children:[(0,$.jsx)(`span`,{className:`font-bold`,children:`Buy $50 of real estate, get $50 free.`}),` `,`Spend it on more shares.`]})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex items-end justify-between mb-2 px-1`,children:[(0,$.jsx)(`h2`,{className:`text-base sm:text-lg font-bold text-lofty-purple-600 dark:text-white`,children:We?Qe?`Amount before fees`:`Amount`:`Shares`}),Be&&(0,$.jsxs)(`button`,{type:`button`,onClick:Ct,className:`flex items-center gap-1.5 pb-0.5 text-xs font-semibold text-lofty hover:opacity-75 active:scale-95 transition-all`,"aria-label":We?`Switch to entering shares`:`Switch to entering dollars`,children:[(0,$.jsx)(`i`,{className:`fas fa-exchange-alt text-[10px]`,"aria-hidden":!0}),We?`Enter shares`:`Enter dollars`]})]}),Be?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{ref:_t,className:`grid`,onAnimationEnd:e=>{e.target===e.currentTarget&&e.currentTarget.classList.remove(`order-limit-shake`)},children:[(0,$.jsx)(`div`,{className:`order-mode-pane`,"data-active":We,children:We?(0,$.jsx)(Cc,{name:`usdAmount`,register:i.form.register,control:i.form.control,label:``,text:``,icon:(0,$.jsx)(`span`,{className:`text-3xl sm:text-4xl font-bold text-lofty-purple-300 dark:text-white/40 select-none`,children:`$`}),inlineValueIcon:!0,subText:void 0,selectorOptions:void 0,min:tt,max:K,step:.01,incrementStep:10,errors:i.form.formState.errors,options:{required:We?`This field is required`:!1,validate:{positive:e=>!We||Number(e)>0,coversMinimum:e=>!We||rt(Number(e))>=Wc-1e-9||`The minimum order is ${z($e)}`,meetsNotional:e=>!We||rt(Number(e))*ze>=Kc-1e-9||`The minimum order is ${z($e)}`,withinMax:e=>!We||K==null||dc(Number(e),K)||(i.isSellOrder?`You can sell at most ${z(K)}`:`You can spend at most ${z(K)}`)}},tooltip:``,showMaxButton:!1,onLimitHit:yt,onFocus:()=>Je(!0),onBlur:()=>Je(!1)}):wt(R(it,{minimumFractionDigits:0,maximumFractionDigits:2}),!0)}),(0,$.jsx)(`div`,{className:`order-mode-pane`,"data-active":!We,children:We?wt(R(pt,Nt),!1):Tt()})]}),(0,$.jsx)(el,{show:We&&(ht>0&&!!St||!!i.form.formState.errors?.usdAmount?.message),animate:!0,children:ht>0&&St?(0,$.jsx)(`p`,{"aria-live":`polite`,className:`order-limit-hint mt-1 px-1 text-xs text-center font-semibold text-amber-600 dark:text-amber-400`,children:St},ht):(0,$.jsx)(`p`,{className:`mt-1 px-1 text-xs text-center text-red-500 dark:text-red-400`,children:String(i.form.formState.errors?.usdAmount?.message??``)})})]}):Tt(),(0,$.jsx)(el,{show:i.isSellOrder&&s>0,animate:W,children:(0,$.jsx)(`div`,{className:`flex items-center justify-end mt-1.5 px-1 text-xs`,children:(0,$.jsxs)(`button`,{type:`button`,className:`text-lofty hover:underline font-medium`,onClick:()=>{We&&K!=null?i.form.setValue(`usdAmount`,K,{shouldDirty:!0,shouldValidate:!0}):i.form.setValue(`tokenQuantity`,s,{shouldDirty:!0,shouldValidate:!0})},children:[`Max: `,R(Math.max(s,0),Nt),` available`]})})}),(0,$.jsx)(el,{show:i.isSellOrder&&ye>0,animate:W,children:(0,$.jsxs)(`p`,{className:`text-xs text-lofty-gray-700 dark:text-white/60 mt-1.5 px-1`,children:[R(ye,Nt),` `,ye===1?`share is`:`shares are`,` staked in the liquidity pool and can’t be sold until you withdraw them.`]})}),(0,$.jsx)(el,{show:Ee&&(i.isSellOrder||!W),animate:W,children:(0,$.jsx)(`p`,{className:`text-xs text-lofty-gray-700 dark:text-white/60 mt-1.5 px-1`,children:i.isSellOrder?`This pool can only buy back ${Me(i.limits.marketDepthMax??0,`share`).phrase} right now (limited pool liquidity). Sell fewer, or use a limit order.`:`Only ${R(i.limits.marketDepthMax??0,Nt)} shares are available to buy right now.`})}),(0,$.jsx)(el,{show:i.isSellOrder&&tn>0,animate:W,children:(0,$.jsxs)(`div`,{className:`mt-2 flex items-center justify-between text-xs text-lofty-purple-600 dark:text-white/70 px-1`,children:[(0,$.jsxs)(`span`,{children:[R(tn,Nt),` shares locked in gift escrow`]}),(0,$.jsx)(`button`,{type:`button`,className:`text-lofty hover:underline font-medium`,onClick:ee.openModal,children:`View details`})]})}),(0,$.jsx)(el,{show:i.isSellOrder&&(de?.lockedAmountTotal??0)>0,animate:W,children:(0,$.jsxs)(`p`,{className:`text-xs text-lofty-purple-600/70 dark:text-white/50 pt-1 px-1`,children:[de?.lockedAmountTotal,` shares unlock in `,fe,` days. You still earn rent from them in the meantime.`]})})]}),!i.isPrimaryOrder&&(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":Jt?re:void 0,disabled:!Jt,onClick:()=>Jt&&P(e=>!e),className:[`w-full flex items-center justify-between gap-3 rounded-xl px-3.5 py-2.5 text-left border bg-white dark:bg-white/[0.03] border-lofty-gray-300 dark:border-white/10 transition-colors`,Jt?`hover:border-lofty/40`:`cursor-default`].join(` `),children:[(0,$.jsxs)(`span`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-semibold text-lofty-purple-600 dar
93k:text-white`,children:`Order type`}),(0,$.jsx)(`span`,{className:`block text-[11px] mt-0.5 truncate text-lofty-gray-700 dark:text-white/50`,children:qt(i.orderType)})]}),Jt&&(0,$.jsx)(`i`,{className:`fas fa-chevron-${re?`up`:`down`} text-[10px] text-lofty`})]}),re&&Jt&&(0,$.jsxs)(`div`,{className:`mt-2`,children:[(Ot||kt)&&(0,$.jsx)(`div`,{className:`flex gap-2 p-1 bg-lofty-purple-50 dark:bg-white/[0.04] rounded-xl`,children:Dt.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>{i.markUserOrderTypeChoice(),i.form.setValue(`orderType`,e.name,{shouldDirty:!0,shouldValidate:!0})},className:[`flex-1 py-2 rounded-lg text-sm font-semibold transition-all capitalize`,i.orderType===e.name?`bg-white dark:bg-lofty-purple-500/40 text-lofty-purple-600 dark:text-white shadow-sm`:`text-lofty-gray-700 dark:text-white/60 hover:text-lofty-purple-600 dark:hover:text-white`].join(` `),children:e.name},e.name))}),kt&&(0,$.jsx)(`div`,{className:`flex gap-2 p-1 mt-2 bg-lofty-purple-50 dark:bg-white/[0.04] rounded-xl`,children:Ze.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>{i.markUserOrderTypeChoice(),i.form.setValue(`orderType`,e.name,{shouldDirty:!0,shouldValidate:!0})},className:[`flex-1 py-2 rounded-lg text-sm font-semibold transition-all`,i.orderType===e.name?`bg-white dark:bg-lofty-purple-500/40 text-lofty-purple-600 dark:text-white shadow-sm`:`text-lofty-gray-700 dark:text-white/60 hover:text-lofty-purple-600 dark:hover:text-white`].join(` `),children:e.title},e.name))}),(0,$.jsx)(el,{show:!!J,animate:W,children:(0,$.jsx)(`p`,{className:`text-xs text-lofty-gray-700 dark:text-white/60 mt-2 px-1`,children:J?.subtitle})}),!!r.liquidity&&!De&&(0,$.jsx)(`p`,{className:`text-xs text-lofty-gray-700 dark:text-white/60 mt-2 px-1`,children:`Market orders unavailable — pool liquidity is 0. Place a limit order instead.`})]})]}),(0,$.jsx)(el,{show:At&&!i.isPrimaryOrder,animate:W,children:(0,$.jsxs)(`section`,{children:[(0,$.jsx)(tl,{children:i.orderType===Ce.TrailingStop?`Trail distance`:`Trigger price`}),(i.orderType===Ce.StopLoss||i.orderType===Ce.StopLimit)&&(0,$.jsx)(Cc,{name:`triggerPrice`,register:i.form.register,control:i.form.control,label:``,text:`USD`,icon:(0,$.jsx)(Rt,{color:`text-lofty-purple mr-2 2xl:mr-3.5 inline`}),min:.01,step:.01,incrementStep:1,errors:i.form.formState.errors,options:{required:`Enter a trigger price`,validate:{positive:e=>Number(e)>0||`Enter a trigger price`}},tooltip:i.isSellOrder?`Your order activates once the price falls to this level.`:`Your order activates once the price climbs to this level.`,showMaxButton:!1}),i.orderType===Ce.StopLimit&&(0,$.jsxs)(`div`,{className:`mt-2`,children:[(0,$.jsx)(tl,{children:`Then place a limit at`}),(0,$.jsx)(Cc,{name:`triggerLimitPrice`,register:i.form.register,control:i.form.control,label:``,text:`USD`,icon:(0,$.jsx)(Rt,{color:`text-lofty-purple mr-2 2xl:mr-3.5 inline`}),min:.01,step:.01,incrementStep:1,errors:i.form.formState.errors,options:{required:`Enter a limit price`,validate:{positive:e=>Number(e)>0||`Enter a limit price`,reachable:e=>{let t=Number(jt);return!t||!Number(e)?!0:i.isSellOrder?Number(e)<=t||`For a stop limit sell, the limit price must be at or below the trigger price.`:Number(e)>=t||`For a stop limit buy, the limit price must be at or above the trigger price.`}}},tooltip:i.isSellOrder?`Once triggered, you will not sell below this price.`:`Once triggered, you will not pay more than this price.`,showMaxButton:!1})]}),i.orderType===Ce.TrailingStop&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`input`,{type:`hidden`,...i.form.register(`trailPercent`,{required:!0})}),(0,$.jsx)(`div`,{className:`flex gap-2 p-1 bg-lofty-purple-50 dark:bg-white/[0.04] rounded-xl`,children:ct.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i.form.setValue(`trailPercent`,e,{shouldDirty:!0,shouldValidate:!0}),className:[`flex-1 py-2 rounded-lg text-sm font-semibold transition-all`,Number(Pt)===e?`bg-white dark:bg-lofty-purple-500/40 text-lofty-purple-600 dark:text-white shadow-sm`:`text-lofty-gray-700 dark:text-white/60 hover:text-lofty-purple-600 dark:hover:text-white`].join(` `),children:[e,`%`]},e))})]}),(0,$.jsxs)(`div`,{className:`mt-2`,children:[(0,$.jsx)(tl,{children:`Price measured as`}),(0,$.jsx)(`div`,{className:`flex gap-2 p-1 bg-lofty-purple-50 dark:bg-white/[0.04] rounded-xl`,children:et.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i.form.setValue(`referenceWindowDays`,e,{shouldDirty:!0,shouldValidate:!0}),className:[`flex-1 py-2 rounded-lg text-sm font-semibold transition-all`,Number(Ft)===e?`bg-white dark:bg-lofty-purple-500/40 text-lofty-purple-600 dar
93k:text-white shadow-sm`:`text-lofty-gray-700 dark:text-white/60 hover:text-lofty-purple-600 dark:hover:text-white`].join(` `),children:[e,`-day avg`]},e))}),(0,$.jsx)(`p`,{className:`text-[11px] text-lofty-gray-700 dark:text-white/50 mt-1 px-1`,children:`Your trigger watches the volume-weighted average of real trades over this window — a single trade can’t set it off.`})]}),(()=>{let e=i.form.formState.errors.triggerLimitPrice?.message??i.form.formState.errors.triggerPrice?.message;return(0,$.jsx)(el,{show:typeof e==`string`&&!!e,animate:W,children:(0,$.jsx)(`p`,{className:`text-xs text-lofty-red dark:text-red-400 mt-2 px-1`,children:e})})})(),(0,$.jsx)(el,{show:!!It,animate:W,children:(0,$.jsx)(`p`,{className:`text-xs text-lofty-gray-700 dark:text-white/60 mt-2 px-1`,children:It})}),(0,$.jsx)(el,{show:i.isBuyOrder,animate:W,children:(0,$.jsx)(`p`,{className:`text-[11px] text-lofty-gray-700 dark:text-white/50 mt-1 px-1`,children:`Paid from your Lofty Wallet USDC balance when it executes. Keep enough there — the order cancels if the balance runs short.`})}),(0,$.jsx)(`p`,{className:`text-[11px] text-lofty-gray-700 dark:text-white/50 mt-1 px-1`,children:`Order good for 90 days unless triggered or cancelled.`})]})}),(0,$.jsx)(el,{show:!!i.noAmmMarketInfo&&(i.isSellOrder||!W),animate:W,children:i.noAmmMarketInfo&&(i.isSellOrder||!W)&&(0,$.jsxs)(`div`,{className:`rounded-xl border border-exchange-ligthgray dark:border-white/15 px-4 py-3 space-y-1 bg-lofty-purple-50/40 dark:bg-white/[0.03]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,$.jsx)(`span`,{className:`text-lofty-gray-700 dark:text-white/70`,children:i.isSellOrder?`Min price`:`Max price`}),(0,$.jsxs)(`span`,{className:`font-bold text-lofty-purple-600 dark:text-white`,children:[`$`,R(i.noAmmMarketInfo.effectivePrice,Yc),`/share`]})]}),(0,$.jsx)(el,{show:i.noAmmMarketInfo.slippagePct>=Jc,animate:W,children:(0,$.jsxs)(`p`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:[`Your order is big enough to move the price `,i.isSellOrder?`down`:`up`,`.`]})}),(0,$.jsx)(`p`,{className:`text-[11px] text-lofty-gray-700 dark:text-white/50`,children:i.isSellOrder?`Submitted as a limit order — you won't receive less than this per share.`:`Submitted as a limit order — you won't pay more than this per share.`})]})}),!i.isPrimaryOrder&&i.showLimitPriceInput&&(0,$.jsxs)(`section`,{children:[(0,$.jsx)(tl,{children:i.isOptimizedOrder?`Your price limit`:`Your limit price`}),(0,$.jsx)(Dc,{coc:we.coc,name:`price`,control:i.form.control,label:``,register:i.form.register,errors:i.form.formState.errors,options:{required:`This field is required`,min:{value:0,message:`error message`},validate:{positive:e=>e>0}},text:`USD`,icon:(0,$.jsx)(Rt,{color:`text-lofty-purple mr-2 2xl:mr-3.5 inline`}),price:i.pricePerToken,bids:{bid:e,ask:t,hc:i.fairShareValue},tooltip:i.isSellOrder?`Minimum price per share you will accept.`:`Maximum price per share you will pay.`,sell:i.isSellOrder,subText:``,selectedCurrency:i.selectedCurrency,requestOrderBook:a}),(0,$.jsxs)(`button`,{type:`button`,className:`mt-2 w-full flex items-center justify-between text-xs text-lofty-gray-700 dark:text-white/60 hover:text-lofty-purple-600 dark:hover:text-white transition-colors px-1`,onClick:()=>ae(e=>!e),children:[(0,$.jsxs)(`span`,{className:`font-medium`,children:[ie?`Hide`:`View`,` order book`]}),(0,$.jsx)(`i`,{className:`fas fa-chevron-${ie?`up`:`down`} text-[10px]`})]}),ie&&(0,$.jsx)(fl,{bids:Qt,asks:Zt,onPickPrice:e=>i.form.setValue(`price`,e,{shouldDirty:!0,shouldValidate:!0})}),i.isOptimizedOrder&&(0,$.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,$.jsx)(tl,{children:`Execution window`}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:i.optimizedOrderConfig.windowPresetsDays.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i.form.setValue(`optimizedWindowDays`,e,{shouldDirty:!0}),className:[`px-3 py-1.5 rounded-lg text-sm font-semibold border transition-colors`,i.optimizedWindowDays===e?`bg-lofty text-white border-lofty`:`bg-white dark:bg-white/[0.03] border-lofty-gray-300 dark:border-white/10 text-lofty-purple-600 dar
93k:text-white/80`].join(` `),children:[e,` `,e===1?`day`:`days`]},e))}),(0,$.jsx)(`p`,{className:`text-[11px] text-lofty-gray-700 dark:text-white/50 px-1`,children:`Lofty works your order over this window via the order book and liquidity pool. Unfilled quantity is cancelled at the deadline.`})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-lofty-gray-700 dark:text-white/50 mt-2 px-1`,children:i.isOptimizedOrder?`Optimized order runs for ${i.optimizedWindowDays} ${i.optimizedWindowDays===1?`day`:`days`}.`:`Order good for 90 days.`})]}),i.isSellOrder&&$t.length>0&&(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":$t.length>1?ce:void 0,disabled:$t.length<=1,onClick:()=>$t.length>1&&le(e=>!e),className:[`w-full flex items-center justify-between gap-3 rounded-xl px-3.5 py-2.5 text-left border bg-white dark:bg-white/[0.03] border-lofty-gray-300 dark:border-white/10 transition-colors`,$t.length>1?`hover:border-lofty/40`:`cursor-default`].join(` `),children:[(0,$.jsxs)(`span`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-semibold text-lofty-purple-600 dark:text-white`,children:`Sell from`}),(0,$.jsx)(`span`,{className:`block text-[11px] mt-0.5 truncate text-lofty-gray-700 dark:text-white/50`,children:en?ul(en):`Lofty Wallet`})]}),$t.length>1&&(0,$.jsx)(`i`,{className:`fas fa-chevron-${ce?`up`:`down`} text-[10px] text-lofty`})]}),ce&&$t.length>1&&(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsx)(dl,{wallets:$t,selectedName:i.form.watch(`paymentMethod`),onChange:e=>i.form.setValue(`paymentMethod`,e,{shouldDirty:!0,shouldValidate:!0})})})]}),i.isBuyOrder&&!At&&(()=>{let e=i.paymentMethod,t=!e,n=f.filter(e=>{if(!Bc(e))return!1;let t=e.type===Y.Shared||e.type===Y.External;return t&&i.isMarketOrder&&!Fc(ge,e.type,i.cryptoSubtotal,i.selectedCurrency)||b&&t&&!Mc(ge,e.type)?!1:!i.isMarketOrder||Zc.includes(e.type)}),r=i.isWalletPayment&&i.isUSDC?`$${R(l,Yc)} available`:void 0,a=m.gift>0||E>0,o=m.appliedGift+m.appliedRent,s=m.appliedGift>0,c=m.appliedRent>0,u=s&&c,p=u?`rent + gift balances`:c?`rent balance`:`gift balance`,h=u?`Rent + gift balances`:c?`Rent balance`:`Gift balance`,g=!w.hasColdQuote&&o>0&&hc(w.data.finalTotal),_=e=>{let t=e===q.Gift?m.gift:E,n=e===q.Gift?m.appliedRent:m.appliedGift,r=H(Math.min(t,i.subTotal),2,!1),a=H(Math.min(n,Math.max(0,i.subTotal-r)),2,!1),o=e===q.Gift?q.Rent:q.Gift;a!==n&&m.onAddBalance(o,a),m.onAddBalance(e,r)},v=(0,$.jsx)(hl,{methods:n,selectedName:i.form.watch(`paymentMethod`),onChange:e=>i.form.setValue(`paymentMethod`,e,{shouldDirty:!0,shouldValidate:!0}),onAddPaymentMethod:d,walletSubText:r,isFirstInvestment:b,animateCollapse:W});return Qc({hasCheckoutBalances:a,selectableCount:n.length,isFirstInvestment:!!b,paymentMissing:t})?(0,$.jsx)(`section`,{children:v}):(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":oe,onClick:()=>se(e=>!e),className:[`w-full flex items-center justify-between gap-3 rounded-xl px-3.5 py-2.5 text-left`,`border bg-white dark:bg-white/[0.03] transition-colors`,t?`border-lofty/60`:`border-lofty-gray-300 dark:border-white/10 hover:border-lofty/40`].join(` `),children:[(0,$.jsxs)(`span`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-semibold text-lofty-purple-600 dark:text-white`,children:`Payment method`}),t?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`block text-[11px] mt-0.5 truncate text-lofty font-medium`,children:`Tap to choose payment method`}),o>0&&(0,$.jsx)(`span`,{className:`block text-xs mt-0.5 font-semibold text-lofty dark:text-lofty-purple-300 truncate`,children:g?`Fully covered by your ${p}`:`${h} ${u?`cover`:`covers`} $${R(o,Yc)} of this order`})]}):W&&g?(0,$.jsxs)(`span`,{className:`block text-xs mt-0.5 font-semibold text-lofty dark:text-lofty-purple-300 truncate`,children:[`Fully covered by your `,p]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 mt-0.5 text-[11px] text-lofty-gray-700 dark:text-white/50 truncate`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:ml(e)}),e.number&&(0,$.jsx)(`span`,{className:`text-lofty-gray-700/80 dark:text-white/40 font-light tracking-wider truncate`,children:e.number}),r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`shrink-0`,"aria-hidden":`true`,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0`,children:r})]})]}),W&&o>0&&(0,$.jsx)(`span`,{className:`block text-xs mt-0.5 font-semibold text-lofty dark:text-lofty-purple-300 truncate`,children:`${h} ${u?`cover`:`covers`} $${R(o,Yc)} of this order`})]})]}),(0,$.jsx)(`i`,{className:`fas fa-chevron-${oe?`up`:`down`} text-[10px] text-lofty`})]}),W?(0,$.jsx)(`div`,{className:`collapse-grid`,"data-open":oe,children:(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`mt-3 space-y-2.5`,children:[a?(()=>{let e=Math.max(0,w.data.finalTotal),t=!w.hasColdQuote&&o>0&&e<.005,n=`bg-lofty text-white`,r=`bg-lofty-purple-50 dark:bg-white/10 text-lofty-purple-600 dar
93k:text-white/70`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`relative flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`absolute left-3 top-7 -bottom-1 w-px bg-lofty-gray-300 dark:bg-white/15`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`relative flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs font-bold ${o>0?n:r}`,children:o>0?(0,$.jsx)(`i`,{className:`fas fa-check text-[10px]`}):`1`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 pb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-semibold text-lofty-purple-600 dark:text-white`,children:`Use your balances`}),(0,$.jsx)(`span`,{className:`text-sm font-semibold tabular-nums shrink-0 ${o>0?`text-lofty dark:text-lofty-purple-300`:`text-lofty-gray-700 dark:text-white/40`}`,children:o>0?`−$${R(o,Yc)}`:`Optional`})]}),(0,$.jsx)(`p`,{className:`text-xs text-lofty-gray-700 dark:text-white/60 mt-0.5 mb-2`,children:`Comes off your order first.`}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[m.gift>0&&(0,$.jsx)(nl,{type:q.Gift,available:m.gift,applied:m.appliedGift,maxApplicable:Math.max(0,i.subTotal-m.appliedRent),onChange:e=>m.onAddBalance(q.Gift,e),onQuickApply:()=>_(q.Gift)}),E>0&&(0,$.jsx)(nl,{type:q.Rent,available:E,applied:m.appliedRent,maxApplicable:Math.max(0,i.subTotal-m.appliedGift),onChange:e=>m.onAddBalance(q.Rent,e),onQuickApply:()=>_(q.Rent),note:D})]})]})]}),(0,$.jsxs)(`div`,{className:`relative flex items-start gap-3 !mt-0`,children:[(0,$.jsx)(`span`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs font-bold ${t?n:r}`,children:t?(0,$.jsx)(`i`,{className:`fas fa-check text-[10px]`}):`2`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-semibold text-lofty-purple-600 dark:text-white`,children:`Pay the rest`}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-sm font-semibold tabular-nums shrink-0 text-lofty-purple-600 dark:text-white`,children:[!w.hasColdQuote&&`$${R(e,Yc)}`,w.showQuoteSpinner&&(0,$.jsx)(zt,{className:`h-3 w-3`}),w.hasColdQuote&&w.quoteError&&`—`]})]}),(0,$.jsx)(`p`,{className:`text-xs text-lofty-gray-700 dark:text-white/60 mt-0.5 mb-2`,children:t?`Fully covered by your ${p} - nothing to charge today.`:`Charged to your payment method.`}),v]})]})]})})():(0,$.jsxs)(`div`,{children:[(0,$.jsx)(tl,{children:`Pay with`}),v]}),Yt&&(0,$.jsxs)(`button`,{type:`button`,className:`w-full flex items-center justify-center gap-1.5 text-[11px] text-lofty-gray-700 dark:text-white/50 hover:text-lofty-purple-600 dark:hover:text-white transition-colors mt-1`,onClick:()=>M(e=>!e),children:[(0,$.jsx)(`span`,{children:`Advanced`}),(0,$.jsx)(`i`,{className:`fas fa-chevron-${ne?`up`:`down`} text-[8px]`})]}),ne&&i.isWalletPayment&&(0,$.jsx)(`div`,{children:(0,$.jsx)(Hn,{control:i.form.control,currencies:G,compareField:`symbol`,errors:i.form.formState.errors,sell:!1,currency:!0,title:`Payment currency`,description:`Type of crypto used to fund this order`,compact:!0})})]})})}):oe&&(0,$.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,$.jsx)(tl,{children:`Pay with`}),v,(m.rent>0||m.gift>0)&&(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[m.gift>0&&(0,$.jsx)(rl,{type:q.Gift,available:m.gift,applied:m.appliedGift,maxApplicable:Math.max(0,i.subTotal-m.appliedRent),onChange:e=>m.onAddBalance(q.Gift,e)}),E>0&&(0,$.jsx)(rl,{type:q.Rent,available:E,applied:m.appliedRent,maxApplicable:Math.max(0,i.subTotal-m.appliedGift),onChange:e=>m.onAddBalance(q.Rent,e),note:D})]}),Yt&&(0,$.jsxs)(`button`,{type:`button`,className:`w-full flex items-center justify-center gap-1.5 text-[11px] text-lofty-gray-700 dark:text-white/50 hover:text-lofty-purple-600 dark:hover:text-white transition-colors mt-1`,onClick:()=>M(e=>!e),children:[(0,$.jsx)(`span`,{children:`Advanced`}),(0,$.jsx)(`i`,{className:`fas fa-chevron-${ne?`up`:`down`} text-[8px]`})]}),ne&&i.isWalletPayment&&(0,$.jsx)(`div`,{children:(0,$.jsx)(Hn,{control:i.form.control,currencies:G,compareField:`symbol`,errors:i.form.formState.errors,sell:!1,currency:!0,title:`Payment currency`,description:`Type of crypto used to fund this order`,compact:!0})})]})]})})(),W&&i.isBuyOrder&&i.isMarketOrder&&!!g&&(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`label`,{className:[`flex items-center gap-2.5 px-1 select-none`,Wt?`cursor-not-allowed opacity-60`:`cursor-pointer`].join(` `),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`peer sr-only`,checked:!!h&&!Wt,"aria-disabled":Wt,"aria-describedby":Ut&&k?`recurring-funding-message`:void 0,disabled:Bt&&!Ut,onChange:e=>{if(Ut){j(!0);return}Wt||g(e.target.checked?`monthly`:``)}}
93),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`h-5 w-5 shrink-0 rounded-md border-2 flex items-center justify-center transition-all border-lofty-gray-300 dark:border-white/25 bg-white dark:bg-white/[0.03] peer-checked:bg-lofty peer-checked:border-lofty peer-focus-visible:ring-2 peer-focus-visible:ring-lofty/40 [&>i]:opacity-0 peer-checked:[&>i]:opacity-100`,children:(0,$.jsx)(`i`,{className:`fas fa-check text-[10px] text-white transition-opacity`})}),(0,$.jsx)(`span`,{className:`text-sm font-semibold text-lofty-purple-600 dark:text-white`,children:`Make this a recurring investment`})]}),Ut&&k&&(0,$.jsxs)(`div`,{id:`recurring-funding-message`,role:`status`,className:`mt-2 rounded-lg bg-lofty-purple-50 dark:bg-white/[0.05] px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-lofty-gray-700 dark:text-white/80`,children:`Add a card to enable recurring investments. Your Lofty Wallet does not have enough USDC to cover this amount.`}),(0,$.jsx)(`button`,{type:`button`,onClick:O.openModal,className:`mt-1.5 text-xs font-semibold text-lofty dark:text-white underline underline-offset-2`,children:`Add a card`})]}),O.isModalOpen&&(0,$.jsx)(In,{isOpen:!0,onClose:O.closeModal,addPaymentMethod:e=>{d(e),O.closeModal()},onSuccess:()=>{},wallets:ge,isMarketOrder:!0,cardOnly:!0}),Bt&&(0,$.jsxs)(`p`,{className:`mt-1.5 px-1 text-xs text-lofty-gray-700 dark:text-white/60`,children:[`Recurring investments start at `,z(5,{minimumFractionDigits:0,maximumFractionDigits:0}),`.`]}),!!x&&!Bt&&(0,$.jsxs)(`div`,{className:`mt-2 rounded-lg bg-lofty-purple-50 dark:bg-white/[0.05] px-3 py-2`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-lofty-purple-600 dark:text-white`,children:[(0,$.jsx)(`i`,{className:`fas fa-rotate mr-1.5`,"aria-hidden":!0}),`You already invest`,` `,(0,$.jsxs)(`span`,{className:`font-semibold`,children:[z(x.usdAmount,{minimumFractionDigits:2,maximumFractionDigits:2}),` `,ve[x.cadence]??x.cadence]}),` `,`in this property.`]}),!!h&&(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-lofty-gray-700 dark:text-white/60`,children:`Ticking this replaces that plan with the amount and schedule above.`})]}),(0,$.jsx)(el,{show:!!h&&!Wt,animate:W,children:(0,$.jsx)(`div`,{className:`mt-2 flex gap-2 p-1 bg-lofty-purple-50 dark:bg-white/[0.04] rounded-xl`,children:qc.map(({title:e,value:t})=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(t),className:[`flex-1 py-2 rounded-lg text-xs sm:text-sm font-semibold whitespace-nowrap transition-all`,h===t?`bg-white dark:bg-lofty-purple-500/40 text-lofty-purple-600 dark:text-white shadow-sm`:`text-lofty-gray-700 dark:text-white/60 hover:text-lofty-purple-600 dark:hover:text-white`].join(` `),children:e},t))})})]}),(0,$.jsx)(sl,{display:w,currentStep:v,paymentMethods:f,showMarketPriceNote:Xt})]})})})]})}var el=({show:e,animate:t,children:n})=>{let r=(0,Q.useRef)(n);return e&&(r.current=n),t?(0,$.jsx)(`div`,{className:`reveal-grid`,"data-open":e,children:(0,$.jsx)(`div`,{children:e?n:r.current})}):e?(0,$.jsx)($.Fragment,{children:n}):null},tl=({children:e})=>(0,$.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-[0.08em] text-lofty-gray-700 dark:text-white/50 mb-1 px-1`,children:e}),nl=({type:e,available:t,applied:n,maxApplicable:r,onChange:i,note:a,onQuickApply:o})=>{let[s,c]=(0,Q.useState)(!1),l=n>0,u=e===q.Rent?`Rent balance`:`Gift balance`,d=e===q.Rent?`fa-wallet`:`fa-gift`,f=Math.max(0,Math.min(t,r+n));return(0,$.jsxs)(`div`,{className:[`rounded-xl border transition-all`,l?`bg-lofty/[0.08] border-lofty/40 dark:border-lofty/60`:`bg-white dark:bg-white/[0.03] border-lofty-gray-300 dark:border-white/10 hover:border-lofty/40`].join(` `),children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{s?c(!1):l?c(!0):o?o():i(f)},className:`w-full flex items-center justify-between gap-3 px-3.5 py-2.5 text-left`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2.5 min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`flex h-7 w-7 items-center justify-center rounded-full shrink-0 ${l?`bg-lofty text-white`:`bg-lofty-purple-50 dark:bg-white/10 text-lofty-purple-600 dark:text-white/70`}`,children:(0,$.jsx)(`i`,{className:`fas ${l?`fa-check`:d} text-xs`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold text-lofty-purple-600 dar
93k:text-white truncate`,children:u}),(0,$.jsx)(`span`,{className:`block text-xs text-lofty-gray-700 dark:text-white/60 truncate`,children:l?`Using $${R(n,Yc)} of $${R(t,Yc)}`:`$${R(t,Yc)} available`})]})]}),(0,$.jsx)(`span`,{className:`text-xs font-semibold text-lofty whitespace-nowrap`,children:s?`Done`:l?`Change`:`Apply`})]}),(0,$.jsx)(el,{show:!!a,animate:!0,children:(0,$.jsx)(`p`,{className:`px-3.5 pb-2.5 -mt-1 text-xs leading-relaxed text-lofty dark:text-lofty-purple-300`,children:a})}),(0,$.jsx)(`div`,{className:`collapse-grid`,"data-open":s,children:(0,$.jsx)(`div`,{children:(0,$.jsxs)(`div`,{className:`px-3.5 pb-3.5 pt-1 space-y-2 border-t border-lofty/10 dark:border-white/10 mt-1`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:f,step:.01,value:Math.min(n,f),onChange:e=>i(Number(e.target.value)),className:`w-full h-1.5 bg-lofty-purple-50 dark:bg-white/10 rounded-full appearance-none cursor-pointer accent-lofty`}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1 flex items-center gap-1 px-3 py-1.5 rounded-lg bg-white dark:bg-white/5 border border-lofty-gray-300 dark:border-white/10`,children:[(0,$.jsx)(`span`,{className:`text-sm text-lofty-gray-700 dark:text-white/60`,children:`$`}),(0,$.jsx)(`input`,{type:`number`,inputMode:`decimal`,min:0,max:f,step:.01,value:n||``,onChange:e=>{i(H(Math.max(0,Math.min(f,Number(e.target.value)||0)),2,!1))},className:`flex-1 min-w-0 bg-transparent border-0 outline-none text-sm font-semibold text-lofty-purple-600 dark:text-white tabular-nums focus:ring-0`}),(0,$.jsxs)(`span`,{className:`text-[10px] sm:text-[11px] text-lofty-gray-700 dark:text-white/40 whitespace-nowrap`,children:[`/ $`,R(f,Yc)]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(f),className:`flex-1 sm:flex-none px-3 py-1.5 rounded-lg text-xs font-semibold text-lofty bg-lofty/[0.08] hover:bg-lofty/[0.15] transition-colors whitespace-nowrap`,children:`Max`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{i(0),c(!1)},className:`flex-1 sm:flex-none px-3 py-1.5 rounded-lg text-xs font-semibold text-lofty-gray-700 dark:text-white/60 hover:text-lofty-purple-600 dark:hover:text-white whitespace-nowrap`,children:`Remove`})]})]})]})})})]})},rl=({type:e,available:t,applied:n,maxApplicable:r,onChange:i,note:a})=>{let[o,s]=(0,Q.useState)(!1),c=n>0,l=e===q.Rent?`Rent balance`:`Gift balance`,u=e===q.Rent?`fa-wallet`:`fa-gift`,d=Math.max(0,Math.min(t,r+n));return(0,$.jsxs)(`div`,{className:[`rounded-xl border transition-all`,c?`bg-lofty/[0.08] border-lofty/40 dark:border-lofty/60`:`bg-white dark:bg-white/[0.03] border-lofty-gray-300 dark:border-white/10 hover:border-lofty/40`].join(` `),children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{o?s(!1):c?s(!0):i(d)},className:`w-full flex items-center justify-between gap-3 px-3.5 py-2.5 text-left`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2.5 min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`flex h-7 w-7 items-center justify-center rounded-full shrink-0 ${c?`bg-lofty/20 text-lofty`:`bg-lofty-purple-50 dark:bg-white/10 text-lofty-purple-600 dark:text-white/70`}`,children:(0,$.jsx)(`i`,{className:`fas ${u} text-xs`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold text-lofty-purple-600 dark:text-white truncate`,children:c?`Applied $${R(n,Yc)} from ${l.toLowerCase()}`:`Apply ${l.toLowerCase()}`}),(0,$.jsxs)(`span`,{className:`block text-[11px] text-lofty-gray-700 dark:text-white/50 truncate`,children:[`$`,R(t,Yc),` available to invest`]})]})]}),(0,$.jsx)(`span`,{className:`text-xs font-semibold text-lofty whitespace-nowrap`,children:o?`Done`:c?`Change`:`Apply`})]}),a&&(0,$.jsx)(`p`,{className:`px-3.5 pb-2.5 -mt-1 text-[11px] leading-snug text-lofty dark:text-lofty-purple-300`,children:a}),o&&(0,$.jsxs)(`div`,{className:`px-3.5 pb-3.5 pt-1 space-y-2 border-t border-lofty/10 dark:border-white/10 mt-1`,children:[(0,$.jsx)(`input`,{type:`range`,min:0,max:d,step:.01,value:Math.min(n,d),onChange:e=>i(Number(e.target.value)),className:`w-full h-1.5 bg-lofty-purple-50 dark:bg-white/10 rounded-full appearance-none cursor-pointer accent-lofty`}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1 flex items-center gap-1 px-3 py-1.5 rounded-lg bg-white dark:bg-white/5 border border-lofty-gray-300 dark:border-white/10`,children:[(0,$.jsx)(`span`,{className:`text-sm text-lofty-gray-700 dark:text-white/60`,children:`$`}),(0,$.jsx)(`input`,{type:`number`,inputMode:`decimal`,min:0,max:d,step:.01,value:n||``,onChange:e=>{i(H(Math.max(0,Math.min(d,Number(e.target.value)||0)),2,!1))},className:`flex-1 min-w-0 bg-transparent border-0 outline-none text-sm font-semibold text-lofty-purple-600 dar
93k:text-white tabular-nums focus:ring-0`}),(0,$.jsxs)(`span`,{className:`text-[10px] sm:text-[11px] text-lofty-gray-700 dark:text-white/40 whitespace-nowrap`,children:[`/ $`,R(d,Yc)]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(d),className:`flex-1 sm:flex-none px-3 py-1.5 rounded-lg text-xs font-semibold text-lofty bg-lofty/[0.08] hover:bg-lofty/[0.15] transition-colors whitespace-nowrap`,children:`Max`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{i(0),s(!1)},className:`flex-1 sm:flex-none px-3 py-1.5 rounded-lg text-xs font-semibold text-lofty-gray-700 dark:text-white/60 hover:text-lofty-purple-600 dark:hover:text-white whitespace-nowrap`,children:`Remove`})]})]})]})]})},il=wt.buy.buffer/100,al=2,ol=5,sl=({display:e,paymentMethods:t,showMarketPriceNote:n})=>{let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),{data:s,fees:c,hasColdQuote:l,showQuoteSpinner:u,quoteError:d,awaitingQuote:f}=e,p=s.isBuyOrder,m=s.quantity,h=s.totalUsdPrice,g=s.isInternalPmmV2&&s.isMarketOrder,_=s.smartRoute,v=g?p?s.marketOrderValidation?.includedFees:s.marketOrderValidation?.tradingFees:void 0,y=_?m>0?_.ammQty/m:0:1,b=g&&y>0,x=b?v:void 0,S=x?Math.round(x.maintainer*y*100)/100:0,C=x?Math.round(x.liquidity*y*100)/100:0,w=S+C,T=p&&b?Math.round(h*100)/100-w:h,E=p&&b&&m>0?T/m:s.pricePerToken,D=g&&_?Math.abs(_.bookAllIn-_.bookGrossCost):x?0:s.platformFee,ee=s.isInternalPmmV2,O=ee?s.priceBuffer:0,k=ee&&[Y.Shared,Y.External].includes(s.paymentMethod?.type)?0:s.processingFee,A=x||g&&_?0:c.poolFee??0,j=s.useRent,te=s.useGift,ne=!ee&&p&&s.isMarketOrder&&!!c.poolId,M=ne?il:0,re=p?1:-1,N=ee?s.subTotal+k*re:T+(D+k+M+A)*re,P=ee?Math.round(k*100)/100:k,ie=D+P+M+A+w,ae=T,oe=p&&ae>0?ie/ae*100:0,se=p&&j+te>0,ce=s.finalTotal,le=se&&hc(ce),ue=se?`Cash today`:p?`Order total`:`You receive`,de=se?ce:N,fe=j>0&&te>0?`Covered by your rent + gift balance`:j>0?`Covered by your rent balance`:`Covered by your gift balance`,F=t.some(e=>e.type===Y.Shared||e.type===Y.External),pe=s.waivedProcessingFee??0,I=p&&pe>0,L=ee&&p&&s.isMarketOrder&&s.usdMode&&s.smartRoute?.route===`book`&&s.paymentMethod?.type===Y.Card,me=p&&P>0&&!I&&!c.isWalletPayment&&F,he=s.marketOrderValidation?.slippage?.value??0,ge=s.marketOrderValidation?.priceImpact?.value??0,_e=s.noAmmMarketInfo?.slippagePct??0,ve=he||_e,ye=s.isMarketOrder&&ve>0,be=e=>R(e,Yc);return(0,$.jsx)(`div`,{children:(0,$.jsxs)(`section`,{className:`rounded-2xl border border-lofty-gray-300/80 dark:border-white/10 bg-white dark:bg-white/[0.03] px-4 py-3.5 shadow-[0_8px_24px_rgba(15,23,42,0.04)]`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":r,className:`w-full flex items-center justify-between gap-3 text-left`,onClick:()=>i(e=>!e),children:[(0,$.jsxs)(`span`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-sm font-bold text-lofty-purple-600 dark:text-white`,children:ue}),!l&&le&&(0,$.jsx)(`span`,{className:`text-[10px] text-lofty-gray-700/80 dark:text-white/40 leading-tight`,children:fe})]}),(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-2xl font-bold tracking-tight text-lofty-purple-600 dark:text-white`,children:[!l&&(0,$.jsxs)(`span`,{children:[`$`,be(de)]}),u&&(0,$.jsx)(`span`,{role:`status`,"aria-label":`Updating quote`,children:(0,$.jsx)(zt,{className:`h-5 w-5`,color:``})}),l&&d&&`Quote unavailable`,(0,$.jsx)(`i`,{className:`fas fa-chevron-${r?`up`:`down`} text-xs text-lofty`})]})]}),d&&(0,$.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-lofty-red`,children:d}),r&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`mt-3 pt-3 border-t border-lofty-gray-300 dark:border-white/10 space-y-1.5 text-sm`,children:l?(0,$.jsx)(cl,{left:`Shares`,right:u?(0,$.jsx)(`span`,{role:`status`,"aria-label":`Loading share quote`,children:(0,$.jsx)(zt,{className:`h-4 w-4`,color:``})}):`Quote unavailable`}):(0,$.jsx)(cl,{left:`${m} ${m===1?`share`:`shares`} × $${be(E)}`,right:`$${be(T)}`})}),!l&&(ie>0||b)&&(0,$.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-lofty-gray-300 dark:border-white/10`,children:[(0,$.jsxs)(`button`,{type:`button`,"aria-expanded":a,className:`w-full flex items-center justify-between gap-3 text-left`,onClick:()=>o(e=>!e),children:[(0,$.jsxs)(`span`,{className:`flex flex-col min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-sm font-semibold text-lofty-purple-600 dar
93k:text-white`,children:`Fees`}),(0,$.jsx)(`span`,{className:`text-[10px] text-lofty-gray-700/80 dark:text-white/40 leading-tight truncate`,children:`View details`})]}),(0,$.jsxs)(`span`,{className:`flex items-center gap-2 shrink-0 text-sm font-semibold tabular-nums text-lofty-purple-600 dark:text-white`,children:[(0,$.jsxs)(`span`,{children:[b&&!x?u?(0,$.jsx)(`span`,{role:`status`,"aria-label":`Loading fee breakdown`,children:(0,$.jsx)(zt,{className:`h-4 w-4`,color:``})}):`Breakdown unavailable`:`$${be(ie)}`,(!b||x)&&oe>0&&(0,$.jsxs)(`span`,{className:`ml-1 text-[11px] font-medium text-lofty-gray-700 dark:text-white/50`,children:[`(`,oe.toFixed(1),`%)`]})]}),(0,$.jsx)(`i`,{className:`fas fa-chevron-${a?`up`:`down`} text-[10px] text-lofty`})]})]}),a&&(0,$.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-dashed border-lofty-gray-300 dark:border-white/10 space-y-1.5 text-sm`,children:[x&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(cl,{left:`Lofty trading fee (maintainer)`,right:`${p?`+`:`−`}$${be(S)}`,muted:!0}),(0,$.jsx)(cl,{left:`Liquidity provider fee`,right:`${p?`+`:`−`}$${be(C)}`,muted:!0}),(0,$.jsx)(`p`,{className:`text-[10px] text-lofty-gray-700/80 dark:text-white/40 leading-tight`,children:_?.route===`split`?`Split-route fees are estimates. We check the final total before payment.`:p?`Added to the share value above.`:`Deducted from the share value above.`})]}),D>0&&(0,$.jsx)(cl,{left:g&&_?`Order book trading fee`:`Trading fee`,right:`${p?`+`:`−`}$${be(D)}`,muted:!0}),(P>0||I)&&!c.isWalletPayment&&(0,$.jsx)(cl,{left:(0,$.jsxs)(`span`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{children:L?`Card processing fee estimate`:`Card processing fee`}),(0,$.jsx)(`span`,{className:`text-[10px] text-lofty-gray-700/80 dark:text-white/40 leading-tight`,children:L?`Partial fills can change fees. The approved order total stays the maximum.`:I?P>0?`Reduced for your first purchase`:`Free (first purchase)`:me?`Pay with wallet to avoid card processing fees`:`Charged by Stripe, not Lofty`})]}),right:I?(0,$.jsxs)(`span`,{children:[(0,$.jsxs)(`s`,{className:`opacity-60`,children:[`+$`,be(pe+P)]}),` `,(0,$.jsx)(`span`,{className:`font-medium text-lofty-green-500 dark:text-lofty-green`,children:P>0?`+$${be(P)}`:`Free (first purchase)`})]}):`+$${be(P)}`,muted:!0}),A>0&&(0,$.jsx)(cl,{left:(0,$.jsxs)(`span`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{children:`Instant trade fee`}),(0,$.jsx)(`span`,{className:`text-[10px] text-lofty-gray-700/80 dark:text-white/40 leading-tight`,children:`Only for market orders, which fill instantly`})]}),right:`${p?`+`:`−`}$${be(A)}`,muted:!0}),ye&&!ee&&(0,$.jsx)(ll,{percent:ve,perShare:ge,isSell:s.isSellOrder}),ne&&(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`flex flex-col text-lofty-gray-700 dark:text-white/60`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`span`,{children:`Price movement buffer`}),(0,$.jsx)(Sr,{placement:`top`,wrapperComponent:`span`,className:`inline-flex`,content:(0,$.jsxs)(`span`,{className:`block max-w-230-px text-xs`,children:[`Includes a $`,be(M),` refundable buffer. If the price does not move, this amount is returned.`]}),children:(0,$.jsxs)(`button`,{type:`button`,className:`text-[10px] text-lofty hover:text-lofty-purple-600 dark:text-lofty-purple`,children:[(0,$.jsx)(`i`,{className:`fas fa-circle-info`}),(0,$.jsx)(`span`,{className:`sr-only`,children:`Price movement buffer details`})]})})]})}),(0,$.jsxs)(`span`,{className:`font-medium tabular-nums text-lofty-gray-700 dark:text-white/60`,children:[`+$`,be(M)]})]})]})]}),!l&&ye&&ee&&(0,$.jsx)(`div`,{className:`mt-3 pt-3 border-t border-lofty-gray-300 dark:border-white/10 space-y-1.5 text-sm`,children:(0,$.jsx)(ll,{percent:ve,perShare:ge,isSell:s.isSellOrder,included:!0})}),!l&&O>0&&(0,$.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-lofty-gray-300 dark:border-white/10 text-sm`,children:[(0,$.jsx)(cl,{left:`Price movement buffer`,right:`${ee?`+$`:`+`}${be(O)}`,muted:!0}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] text-lofty-gray-700 dark:text-white/50`,children:`Included in the maximum payment, not in fees. Any unused amount is not charged or is returned.`})]}),!l&&se&&(0,$.jsxs)(`div`,{className:`mt-3 pt-3 border-t border-lofty-gray-300 dark:border-white/10 space-y-1.5 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-semibold text-lofty-purple-600 dar
93k:text-white`,children:`Order total`}),(0,$.jsxs)(`span`,{className:`font-semibold tabular-nums text-lofty-purple-600 dark:text-white`,children:[`$`,be(N)]})]}),j>0&&(0,$.jsx)(cl,{left:`Rent balance applied`,right:`−$${be(j)}`,muted:!0}),te>0&&(0,$.jsx)(cl,{left:`Gift balance applied`,right:`−$${be(te)}`,muted:!0})]}),n&&(0,$.jsx)(`p`,{className:`mt-3 pt-3 border-t border-lofty-gray-300 dark:border-white/10 text-center text-[10px] leading-snug text-lofty-gray-700 dark:text-white/45`,children:`The market price is approximate and may fluctuate while placing your order.`})]})]})})},cl=({left:e,right:t,muted:n=!1})=>(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:n?`text-lofty-gray-700 dark:text-white/60`:`text-lofty-purple-600 dark:text-white`,children:e}),(0,$.jsx)(`span`,{className:`font-medium tabular-nums ${n?`text-lofty-gray-700 dark:text-white/60`:`text-lofty-purple-600 dark:text-white`}`,children:t})]}),ll=({percent:e,perShare:t,isSell:n,included:r=!1})=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,$.jsxs)(`span`,{className:`flex flex-col text-lofty-gray-700 dark:text-white/60`,children:[(0,$.jsx)(`span`,{children:`Price movement estimate`}),(0,$.jsx)(`span`,{className:`text-[10px] text-lofty-gray-700/80 dark:text-white/40 leading-tight`,children:r?`Included in the quoted price, not an extra fee`:`Larger orders can move the price`})]}),(0,$.jsxs)(`span`,{className:`font-medium tabular-nums ${e>=ol?`text-lofty-red`:e>=al?`text-amber-500 dark:text-amber-400`:`text-lofty-gray-700 dark:text-white/60`}`,children:[e.toFixed(2),`%`,t>0&&(0,$.jsxs)(`span`,{className:`text-[10px] ml-1`,children:[`(`,z(t,Yc),`/share)`]})]})]}),e>=ol&&(0,$.jsxs)(`p`,{className:`text-xs text-red-600 dark:text-red-400 leading-snug`,children:[`⚠️ High price impact from low pool liquidity — you may `,n?`receive noticeably less`:`pay noticeably more`,` than the market price. Consider `,n?`selling`:`buying`,` a smaller amount or using a limit order.`]})]}),ul=e=>e.type===Y.Shared?`Lofty Wallet`:e.type===Y.External?e.displayName||`External Wallet`:e.displayName||e.name,dl=({wallets:e,selectedName:t,onChange:n})=>{let r=e.find(e=>e.name===t)??e[0];return e.length===1?(0,$.jsxs)(`div`,{className:`flex items-center gap-3 px-3.5 py-2.5 rounded-xl border border-lofty-gray-300 dark:border-white/10 bg-white dark:bg-white/[0.03]`,children:[(0,$.jsx)(`span`,{className:`flex h-7 w-7 items-center justify-center rounded-full bg-lofty-purple-50 dark:bg-white/10 text-lofty-purple-600 dark:text-white shrink-0`,children:(0,$.jsx)(`i`,{className:`fas fa-wallet text-xs`})}),(0,$.jsx)(`span`,{className:`text-sm font-semibold text-lofty-purple-600 dark:text-white truncate`,children:ul(r)})]}):(0,$.jsx)(`div`,{className:`rounded-xl border border-lofty-gray-300 dark:border-white/10 p-1.5 space-y-1 bg-lofty-purple-50/40 dark:bg-white/[0.02]`,children:e.map(e=>{let t=e.name===r.name;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.name),className:[`w-full flex items-center justify-between gap-3 px-2.5 py-2 rounded-lg text-left transition-colors`,t?`bg-lofty/[0.12] text-lofty-purple-600 dark:text-white`:`hover:bg-white dark:hover:bg-white/[0.05] text-lofty-purple-600 dark:text-white/90`].join(` `),children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,$.jsx)(`span`,{className:`flex h-6 w-6 items-center justify-center rounded-full shrink-0 ${t?`bg-lofty/20 text-lofty`:`bg-lofty-purple-50 dark:bg-white/10 text-lofty-purple-600 dark:text-white/70`}`,children:(0,$.jsx)(`i`,{className:`fas fa-wallet text-[10px]`})}),(0,$.jsx)(`span`,{className:`text-sm font-medium truncate`,children:ul(e)})]}),t&&(0,$.jsx)(`i`,{className:`fas fa-check text-xs text-lofty shrink-0`})]},e.name)})})},fl=({bids:e,asks:t,onPickPrice:n})=>e.length===0&&t.length===0?(0,$.jsx)(`div`,{className:`mt-2 rounded-xl border border-lofty-gray-300 dark:border-white/10 bg-lofty-purple-50/40 dark:bg-white/[0.02] py-6 text-center`,children:(0,$.jsx)(`p`,{className:`text-xs text-lofty-gray-700 dark:text-white/50`,children:`No open orders right now.`})}):(0,$.jsxs)(`div`,{className:`mt-2 rounded-xl border border-lofty-gray-300 dark:border-white/10 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`bg-lofty-green/[0.04] dark:bg-lofty-green/[0.06]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 text-[10px] font-bold uppercase tracking-wider text-lofty-green-500 dark:text-lofty-green border-b border-lofty-gray-300/50 dark:border-white/5`,children:[(0,$.jsx)(`span`,{children:`Bids`}),(0,$.jsx)(`span`,{children:`Shares`})]}),e.length===0?(0,$.jsx)(`div`,{className:`px-3 py-3 text-[11px] text-lofty-gray-700 dark:text-white/40`,children:`—`}):e.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.price),className:`w-full flex items-center justify-between px-3 py-1.5 text-xs font-medium hover:bg-lofty-green/[0.10] dark:hover:bg-lofty-green/[0.12] transition-colors`,children:[(0,$.jsxs)(`span`,{className:`text-lofty-green-500 dark:text-lofty-green tabular-nums`,children:[`$`,R(e.price,{minimumFractionDigits:2})]}),(0,$.jsx)(`span`,{className:`text-lofty-gray-700 dark:text-white/60 tabular-nums`,children:R(e.quantity,Nt)})]},e.id))]}),(0,$.jsxs)(`div`,{className:`bg-lofty/[0.04] dark:bg-lofty/[0.08] border-l border-lofty-gray-300/50 dark:border-white/5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 text-[10px] font-bold uppercase tracking-wider text-lofty dark:text-lofty-purple border-b border-lofty-gray-300/50 dark:border-white/5`,children:[(0,$.jsx)(`span`,{children:`Asks`}),(0,$.jsx)(`span`,{children:`Shares`})]}),t.length===0?(0,$.jsx)(`div`,{className:`px-3 py-3 text-[11px] text-lofty-gray-700 dark:text-white/40`,children:`—`}):t.map(e=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.price),className:`w-full flex items-center justify-between px-3 py-1.5 text-xs font-medium hover:bg-lofty/[0.10] dark:hover:bg-lofty/[0.16] transition-colors`,children:[(0,$.jsxs)(`span`,{className:`text-lofty dark:text-lofty-purple tabular-nums`,children:[`$`,R(e.price,{minimumFractionDigits:2})]}),(0,$.jsx)(`span`,{className:`text-lofty-gray-700 dark:text-white/60 tabular-nums`,children:R(e.quantity,Nt)})]},e.id))]})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-lofty-gray-700/80 dark:text-white/40 px-3 py-1.5 bg-lofty-purple-50/60 dark:bg-white/[0.02] border-t border-lofty-gray-300/50 dark:border-white/5`,children:`Tap any price to use it as your limit.`})]}),pl=e=>{switch(e){case Y.Card:return`fa-credit-card`;case Y.Shared:case Y.External:return`fa-wallet`;default:return`fa-credit-card`}},ml=e=>e.displayName?e.displayName.charAt(0).toUpperCase()+e.displayName.slice(1):e.name,hl=({methods:e,selectedName:t,onChange:n,onAddPaymentMethod:r,walletSubText:i,isFirstInvestment:a,animateCollapse:o=!1})=>{let[c,l]=(0,Q.useState)(!1),u=S(),d=y(p),f=s(),m=_(Pa),h=e.find(e=>e.name===t),g=e.length>0,v=()=>{u.openModal()},b=()=>{m(Na),f(`/account/deposits`)},x=a?(0,$.jsxs)(`button`,{type:`button`,onClick:b,className:`w-full flex items-center justify-center gap-2 px-3.5 py-3 rounded-xl border border-dashed border-lofty/40 dark:border-lofty-purple/40 bg-white dark:bg-white/[0.03] text-sm font-semibold text-lofty hover:bg-lofty/[0.04] dark:hover:bg-white/[0.05] transition-colors`,children:[(0,$.jsx)(`i`,{className:`fas fa-university text-xs`}),`Deposit from your bank`]}):(0,$.jsxs)(`p`,{className:`mt-2 px-1 text-center text-[11px] text-lofty-gray-700 dark:text-white/50`,children:[`Or`,` `,(0,$.jsx)(`button`,{type:`button`,onClick:b,className:`font-semibold text-lofty hover:underline`,children:`deposit from your bank`})]});if(!g)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tl,{children:`Choose a payment method`}),(0,$.jsxs)(`div`,{className:`mt-1.5 space-y-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:v,className:`w-full flex items-center justify-center gap-2 px-3.5 py-3 rounded-xl border border-dashed border-lofty/40 dark:border-lofty-purple/40 bg-white dark:bg-white/[0.03] text-sm font-semibold text-lofty hover:bg-lofty/[0.04] dark:hover:bg-white/[0.05] transition-colors`,children:[(0,$.jsx)(`i`,{className:`fas fa-plus text-xs`}),`Add a new card`]}),x]}),(0,$.jsx)(In,{isOpen:u.isModalOpen,onClose:u.closeModal,addPaymentMethod:e=>{r(e),u.closeModal()},onSuccess:()=>{},wallets:d,isMarketOrder:!0,cardOnly:!0,cardFlow:`checkout`})]});let C=(0,$.jsxs)(`div`,{className:`border-t border-lofty-gray-300 dark:border-white/10 p-1.5 space-y-1 bg-lofty-purple-50/40 dark:bg-white/[0.02]`,children:[e.map(e=>{let t=e.name===h?.name;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{n(e.name),l(!1)},className:[`w-full flex items-center justify-between gap-3 px-2.5 py-2 rounded-lg text-left transition-colors`,t?`bg-lofty/[0.12] text-lofty-purple-600 dar
93k:text-white`:`hover:bg-white dark:hover:bg-white/[0.05] text-lofty-purple-600 dark:text-white/90`].join(` `),children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,$.jsx)(`span`,{className:`flex h-6 w-6 items-center justify-center rounded-full shrink-0 ${t?`bg-lofty/20 text-lofty`:`bg-lofty-purple-50 dark:bg-white/10 text-lofty-purple-600 dark:text-white/70`}`,children:(0,$.jsx)(`i`,{className:`fas ${pl(e.type)} text-[10px]`})}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-medium`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:ml(e)}),e.number&&(0,$.jsx)(`span`,{className:`text-xs font-light text-lofty-purple-600/60 dark:text-white/50 tracking-wider truncate`,children:e.number})]}),e.subtitle&&(0,$.jsx)(`span`,{className:`block text-[10px] text-lofty-gray-700/80 dark:text-white/40 leading-tight`,children:e.subtitle})]})]}),t&&(0,$.jsx)(`i`,{className:`fas fa-check text-xs text-lofty shrink-0`})]},e.name)}),(0,$.jsxs)(`button`,{type:`button`,onClick:v,className:`w-full flex items-center justify-center gap-1.5 px-2.5 py-2 mt-1 rounded-lg border border-dashed border-lofty/30 dark:border-lofty-purple/30 text-xs font-semibold text-lofty hover:bg-lofty/[0.04] dark:hover:bg-white/[0.05] transition-colors`,children:[(0,$.jsx)(`i`,{className:`fas fa-plus text-[10px]`}),`Add a new card`]}),x]});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`rounded-xl border border-lofty-gray-300 dark:border-white/10 bg-white dark:bg-white/[0.03] overflow-hidden`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>l(e=>!e),className:`w-full flex items-center justify-between gap-3 px-3.5 py-2.5 text-left hover:bg-lofty-purple-50/50 dark:hover:bg-white/[0.05] transition-colors`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`flex h-7 w-7 items-center justify-center rounded-full bg-lofty-purple-50 dark:bg-white/10 text-lofty-purple-600 dark:text-white shrink-0`,children:(0,$.jsx)(`i`,{className:`fas ${h?pl(h.type):`fa-plus`} text-xs`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold text-lofty-purple-600 dark:text-white`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:h?ml(h):`Choose a payment method`}),h?.number&&(0,$.jsx)(`span`,{className:`text-lofty-purple-600/70 dark:text-white/50 font-light tracking-wider truncate`,children:h.number})]}),i&&(0,$.jsx)(`span`,{className:`block text-[11px] text-lofty-gray-700 dark:text-white/50 truncate`,children:i})]})]}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-lofty whitespace-nowrap`,children:[c?`Done`:`Change`,(0,$.jsx)(`i`,{className:`fas fa-chevron-${c?`up`:`down`} text-[9px]`})]})]}),o?(0,$.jsx)(`div`,{className:`collapse-grid`,"data-open":c,children:(0,$.jsx)(`div`,{children:C})}):c&&C]}),(0,$.jsx)(In,{isOpen:u.isModalOpen,onClose:u.closeModal,addPaymentMethod:e=>{r(e),u.closeModal(),l(!1)},onSuccess:()=>{},wallets:d,isMarketOrder:!0,cardOnly:!0,cardFlow:`checkout`})]})},gl=(e,t)=>{let n=t.includedFees;if(!n||!Number.isFinite(n.liquidity)||n.liquidity<0||!Number.isFinite(n.maintainer)||n.maintainer<0)throw Error(`Refresh the quote to load the trading fees.`);let r=e-n.liquidity-n.maintainer;if(!Number.isFinite(r)||r<=0)throw Error(`Invalid pre-fee quote.`);return r},_l=e=>e!==void 0&&[Y.Card,Y.Bank,Y.NewBank].includes(e),vl=(e,t)=>{let n=Math.max(0,H(e*100,0)),r=Math.min(n,Math.max(0,H(t.giftCapacity*100,0,!1))),i=Math.min(n-r,Math.max(0,H(t.rentCapacity*100,0,!1))),a=()=>n-r-i,o=e=>e+Math.max(0,H(t.processingFee(e/100)*100,0)),s=Math.max(0,H((t.minimumPayment??0)*100,0));if(a()>0&&o(a())<s){let e=a(),n=s;for(;e<n;){let t=e+Math.floor((n-e)/2);o(t)>=s?n=t:e=t+1}let c=e-a();if(t.autoRent){let e=Math.min(i,c);i-=e,c-=e}t.autoGift&&(r-=Math.min(r,c))}return{useGift:r/100,useRent:i/100}},yl=(e,t)=>{let n=Math.max(0,Math.round(H(e,2,!0)*100))+Math.max(0,H(t.priceBuffer*100,0)),r=t.allocateBalance?.(n/100)??t.appliedBalance,i=n-Math.min(n,Math.max(0,H(r*100,0,!1)));return(n+(i>0?Math.max(0,H(t.processingFee(i/100)*100,0)):0))/100},bl=1e4,xl=100,Sl=16,Cl=6e4,wl=3e4,Tl=`Unable to calculate this dollar amount. Try a smaller amount or enter shares.`,El=new Map,Dl=e=>{e===void 0?El.clear():(El.delete(e),El.delete(`${e}:sell`))},Ol=e=>{let{budget:t,unitPrice:n,quote:r}=e,i=e.sell?`${e.contextKey}:sell`:e.contextKey,a=Math.floor(e.quantityMax*bl+1e-8);if(!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0||!Number.isSafeInteger(a)||a<xl)return Promise.reject(Error(Tl));let o=El.get(i);o||(o={samples:new Map,resolved:new Map,inFlight:new Map},El.set(i,o));let s=o,c=`${t}:${a}`,l=Math.max(0,Math.min(e.maxAgeMs??wl,wl)),u=e=>Date.now()-e.at<l,d=o.resolved.get(c);if(d&&u(d))return Promise.resolve(d);let f=o.inFlight.get(c);if(f)return f;let p=!1,m=!1,h,g=new Promise((e,t)=>
93{h=setTimeout(()=>{p=!0,t(Error(Tl))},Cl)}),_=()=>{if(p||m||El.get(i)!==s)throw Error(Tl)},v=Promise.race([(async()=>{let i=new Map(Array.from(s.samples).filter(([,e])=>u(e)&&e.ticks<=a)),o,l,f=0,p=async t=>{if(_(),f>=Sl)throw Error(Tl);f++;let n=t/bl,i=await r(n);if(_(),!i||!Number.isFinite(i.actualPrice)||i.actualPrice<=0||!Number.isFinite(i.dryrunResult.result.value)||i.dryrunResult.result.value<=0)throw Error(Tl);let a=i.quotedAt??Date.now();if(!Number.isFinite(a)||a>Date.now()||Date.now()-a>=wl)throw Error(Tl);return{quantity:n,ticks:t,quote:i,cost:e.sell?i.dryrunResult.result.value:gl(i.actualPrice*n,i.dryrunResult),at:a}},m=e=>{i.set(e.ticks,e),s.samples.set(e.ticks,e),o=l,l=e;for(let[e,t]of s.samples)(Date.now()-t.at>=wl||s.samples.size>64)&&s.samples.delete(e)};for(d&&d.upperTicks===d.ticks+1&&d.upperTicks<=a&&(await Promise.all([p(d.ticks),p(d.upperTicks)])).forEach(m);f<=Sl;){_();for(let[e,t]of s.samples){let n=i.get(e);e<=a&&u(t)&&(!n||t.at>n.at)&&i.set(e,t)}for(let[e,t]of i)Date.now()-t.at>=wl&&i.delete(e);let e=Array.from(i.values()).sort((e,t)=>e.ticks-t.ticks),r=e.filter(e=>e.cost<=t).at(-1),h=e.find(e=>e.ticks>(r?.ticks??0)&&e.cost>t);if(r&&(t-r.cost<=.01||r.ticks===a||h&&h.ticks-r.ticks<=1)){let e=h&&h.ticks===r.ticks+1&&t-r.cost>.01?h.ticks:void 0;for(s.resolved.delete(c),s.resolved.set(c,{...r,upperTicks:e});s.resolved.size>32;)s.resolved.delete(s.resolved.keys().next().value);return r}if(h&&h.ticks<=xl&&!r||f===Sl)throw Error(Tl);let g=r?.ticks??0,v=r?.cost??0,y=h?.ticks??a+1,b=d?.ticks??t/n*bl;if(h?b=g+(t-v)*(h.ticks-g)/(h.cost-v):r&&(b=r.ticks*t/r.cost),o&&l&&o.cost!==l.cost){let e=l.ticks+(t-l.cost)*(l.ticks-o.ticks)/(l.cost-o.cost);Number.isFinite(e)&&e>g&&e<y&&(b=e)}else if(!h&&r&&e.length>1){let n=e.filter(e=>e.ticks<r.ticks&&e.cost<r.cost).at(-1);n&&(b=r.ticks+(t-r.cost)*(r.ticks-n.ticks)/(r.cost-n.cost))}let x=Math.max(xl,Math.min(y-1,Math.max(g+1,Math.floor(b))));if(!Number.isSafeInteger(x)||x>a||i.has(x))throw Error(Tl);m(await p(x))}throw Error(Tl)})(),g]).finally(()=>{m=!0,clearTimeout(h),s.inFlight.delete(c)});return s.inFlight.set(c,v),v},kl=({enabled:e,editing:t,budget:n,sell:r=!1,unitPrice:i,quantityMax:a,quantity:o,contextKey:s,quote:c,onResolved:l})=>{let u=`${s}:${r}`,d=`${e}:${t}:${u}:${n}:${a}:${i}`,f=(0,Q.useRef)(u);f.current=u;let p=(0,Q.useRef)({quote:c,onResolved:l});p.current={quote:c,onResolved:l};let[m,h]=(0,Q.useState)(),g=m?.key===d?m:void 0,_=g?.result&&o!==void 0&&o!==g.result.quantity;return(0,Q.useEffect)(()=>{if(!e||!t){h(void 0);return}let o=!1,c=()=>Ol({budget:n,sell:r,unitPrice:i,quantityMax:a,contextKey:s,quote:e=>f.current===u?p.current.quote(e):Promise.reject(Error(Tl))}).then(e=>{o||(p.current.onResolved(e.quantity,e.quote),h({key:d,result:e}))}).catch(()=>{o||h({key:d,error:Tl})}),l=`${n}:${Math.floor(a*bl+1e-8)}`,m=El.get(r?`${s}:sell`:s),g=m?.resolved.get(l),_=g&&Date.now()-g.at<wl||m?.inFlight.has(l),v=_?void 0:setTimeout(()=>{c()},180);return _&&c(),()=>{o=!0,clearTimeout(v)}},[d,e,t,n,r,i,a,s,u]),{active:e,quantity:g?.result?.quantity??0,pending:e&&t&&(!g||!!_),error:e&&t?g?.error:void 0}},Al=e=>{let t=(0,Q.useRef)(null);t.current||=j();let n=t.current,[r,i]=(0,Q.useState)({attempt:1,currentInterval:e.startInterval,stopped:!(e.immediateStart??!0),reset:n}),a=(0,Q.useRef)({working:!1,didReset:n}),o=e=>!!(r.stopped||a.current.didReset!==e),s=async()=>{if(a.current.working||r.stopped)return;let t=r.reset;if(!e.maxRetries||e.maxRetries&&r.attempt<=e.maxRetries){if(a.current.working=!0,r.attempt===1&&e.delayFirst&&(await at(e.startInterval),o(t))||(await e.fn(),o(t))||(await at(r.currentInterval),o(t)))return;let n=e.factor??2,s=e.startInterval*n**r.attempt;if(e.maxInterval&&!Number.isNaN(e.maxInterval)&&(s=Math.min(e.maxInterval,s)),e.jitter){let t=Math.max(0,Math.min(1,Math.abs(e.jitterWindow??.2)));s=Xe(Math.max(0,s*(1-t)),s*(1+t/100))}let c=j();a.current={working:!1,didReset:c},i(e=>({...e,attempt:e.attempt+1,currentInterval:H(s,0,!1),stopped:!1,reset:c}));return}i(e=>({...e,stopped:!0}))},c=()=>{let t=j();a.current={working:!1,didReset:t},i({attempt:1,currentInterval:e.startInterval,stopped:!1,reset:t})},l=()=>{r.stopped&&c()},u=()=>{i(e=>({...e,stopped:!0}))};(0,Q.useEffect)(()=>{s()},[r.reset]),(0,Q.useEffect)(()=>{r.stopped&&e.maxRetries&&r.attempt>=e.maxRetries&&e.onComplete?.()},[r.stopped]);let d=-1;return(e.maxRetries??0)>0&&e.maxInterval===e.startInterval&&(d=(e.maxRetries-r.attempt)*e.maxInterval),{start:l,stop:u,reset:c,state:r,timeRemaining:d}},jl=500,Ml=()=>(0,$.jsx)(`div`,{className:`flex items-center justify-center animate-pulse`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`h-16 w-16 rounded-full bg-lofty-gray-300 dark:bg-lofty-purple-500/30`}),(0,$.jsx)(`div`,{className:`h-3 w-32 rounded bg-lofty-gray-300 dark:bg-lofty-purple-500/30`})]})}),Nl=e=>{let[t,n]=(0,Q.useState)({remaining:e.duration,completed:!1}),r=(0,Q.useCallback)(()=>{n(e=>({...e,remaining:Math.max(0,e.remaining-jl)}))},[]),i=(0,Q.useCallback)(()=>{n(e=>({...e,remaining:0,completed:!0})),e.timerEnabled&&e.onComplete?.()},[e.onComplete,e.timerEnabled]),a=Al((0,Q.useMemo)(()=>({id:`PlaceOrderLoadingDialogTimer`,fn:r,onComplete:i,immediateStart:e.timerEnabled,startInterval:jl,max
93Interval:jl,maxRetries:e.duration/jl,factor:1}),[r,i]));return(0,Q.useEffect)(()=>{e.timerEnabled?a.start():a.stop()},[e.timerEnabled]),(0,$.jsx)(ue,{id:`PlaceOrderLoadingDialog`,isOpen:e.isOpen,zIndexBase:e.zIndexBase??30,showCloseBtn:!1,minHeight:``,className:{container:`border-none outline-none w-full h-full lg:w-1/2 lg:h-1/2 lg:min-h-400-px lg:max-w-2xl 2xl:min-h-[500px]`,content:`m-0 p-0 h-full flex`,overflow:`hidden`},children:(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center gap-y-8 p-8`,children:[e.showLoader&&(0,$.jsx)(`div`,{className:``,children:(0,$.jsx)(Ml,{})}),(0,$.jsx)(`h1`,{className:`text-xl 2xl:text-2xl font-semibold text-center max-w-md`,children:e.contents.title}),!!e.contents.subTitle&&(0,$.jsx)(`p`,{className:`text-lofty-gray-700 text-sxs sm:text-xs lg:text-base mt-2 text-center max-w-md`,children:e.contents.subTitle}),(0,$.jsx)(`div`,{children:e.timerEnabled&&t.remaining>0?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`font-semibold text-xl`,children:H(t.remaining/1e3,0,!1)}),(0,$.jsx)(`span`,{children:` seconds until order expires`})]}):null}),e.onClose&&(0,$.jsx)(`button`,{type:`button`,onClick:e.onClose,className:`lofty-link-button flex items-center justify-center`,children:`Close`})]})})},Pl=e=>Math.round(e*100),Fl=(e,t,n,r=0)=>Pl(e+bn(n)(e,t,r))/100,Il=({isMarketOrder:e,hasAmmLiquidity:t,hasValidatedMarketQuote:n,hasBookCoverage:r})=>e&&(t&&n||r),Ll=({quantity:e,useRent:t,useGift:n,orderType:r,selectedMarket:i})=>JSON.stringify([e,t,n,r,i]),Rl=(e,t,n=!1)=>{let r=Number(e),i=Number.isFinite(r)?Math.max(0,n?Number(r.toFixed(4)):Math.trunc(r)):0,a=`${i} ${i===1?`share`:`shares`}`,o=(t??``).trim();return o?`${a} · ${o}`:a},zl=(e,t,n)=>{let r=Pl(e),i=Math.max(0,r-Pl(t));return i>0?[{name:n,amount:r-i},{name:`Card processing fee`,amount:i}]:[{name:n,amount:r}]},Bl=(e,t)=>Pl(t)<=e,Vl=[{availabilityKey:`applePay`,expressPaymentType:`apple_pay`,label:`Apple Pay`}],Hl={light:`#ffffff`,dark:`#020724`},Ul={light:`#08165D`,dark:`#ffffff`},Wl=16,Gl=52,Kl=`inset(0 round ${Wl}px)`,ql=[`[class*="HeightObserverProvider"]`,`[data-testid="payment-form-ece-wrapper"]`,`[class*="ExpressCheckoutView"]`,`[class*="ExpressCheckoutButtonGroup"]`,`[class*="ThirdPartyButtonContainer"]`,`[class*="ApplePayFrame"]`].join(`, `),Jl=(e,t,n)=>{e.style.backgroundColor=t,e.style.colorScheme=n,e.style.clipPath=Kl},Yl=(e,t,n)=>{e.querySelectorAll(ql).forEach(e=>{e.style.backgroundColor=t,e.style.colorScheme=n})},Xl=e=>{let t=e?Hl.dark:Hl.light;return{theme:e?`night`:`stripe`,variables:{borderRadius:`${Wl}px`,buttonBorderRadius:`${Wl}px`,buttonExpressCheckoutBorderRadius:`${Wl}px`,colorPrimary:`#4D3FED`,colorBackground:t,colorText:e?Ul.dark:Ul.light,gridRowSpacing:`0px`,gridColumnSpacing:`0px`},rules:{".Block":{backgroundColor:t,border:`none`,boxShadow:`none`,padding:`0`,borderRadius:`${Wl}px`},".Button":{borderRadius:`${Wl}px`}}}},Zl=(e,t)=>{let n=t?Hl.dark:Hl.light,r=t?`dark`:`light`;Jl(e,n,r),Yl(e,n,r)},Ql=e=>{let t={applePay:typeof e?.applePay==`boolean`?e.applePay:!!e?.applePay?.available};return{availability:t,hasSupportedWallet:Object.values(t).some(Boolean)}},$l=e=>Vl.find(t=>t.expressPaymentType===e)?.label??`Card`,eu=(e,t)=>({type:Y.Card,id:e.id,created:e.created??Date.now(),country:e.card?.country??``,bankName:``,routingNumber:``,institutionId:``,last4:e.card?.last4??``,brand:$l(t),expireMonth:e.card?.exp_month??0,expireYear:e.card?.exp_year??0,billing_details:e.billing_details??{},default:!1}),tu=({amount:e,cashDueToday:t,orderLabel:n,disabled:r,quoteKey:i,beforeAuthorize:a,onPaymentMethod:o})=>{let s=Pn(),c=Un(),{isDark:l}=I(),[u,d]=(0,Q.useState)(`pending`),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)({disabled:r,onPaymentMethod:o});m.current={disabled:r,onPaymentMethod:o};let h=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]),(0,Q.useEffect)(()=>{a||d(`pending`)},[i,e,a]);let g=(0,Q.useMemo)(()=>Xl(l),[l]),_=(0,Q.useMemo)(()=>({business:{name:`Lofty`},emailRequired:!0,billingAddressRequired:!0,paymentMethodOrder:[`apple_pay`],paymentMethods:{applePay:`always`,googlePay:`never`,link:`
93never`,paypal:`never`,amazonPay:`never`,klarna:`never`},layout:{maxColumns:1,maxRows:1,overflow:`auto`},buttonHeight:Gl,buttonTheme:{applePay:l?`white`:`black`},buttonType:{applePay:`buy`}}),[l]);(0,Q.useEffect)(()=>{c&&c.update({appearance:g})},[g,c]),(0,Q.useEffect)(()=>{let e=p.current;if(!e||u!==`pending`)return;let t=0,n=0,r=()=>{let t=Date.now();t-n<100||(n=t,Zl(e,l))};r();let i=new MutationObserver(()=>{cancelAnimationFrame(t),t=requestAnimationFrame(r)});return i.observe(e,{childList:!0,subtree:!0}),()=>{cancelAnimationFrame(t),i.disconnect()}},[u,l]);let v=e=>{let{availability:t,hasSupportedWallet:n}=Ql(e);return d(n?`available`:`unavailable`),{availability:t,hasSupportedWallet:n}},y=({availablePaymentMethods:e})=>{let{availability:t,hasSupportedWallet:n}=v(e);console.info(`[Stripe] Express checkout availability evaluated`,{source:`ready`,...t,hasSupportedWallet:n}),p.current&&Zl(p.current,l)},b=({paymentMethods:e})=>{let{availability:t,hasSupportedWallet:n}=v(e);console.info(`[Stripe] Express checkout availability evaluated`,{source:`availablepaymentmethodschange`,...t,hasSupportedWallet:n}),p.current&&Zl(p.current,l)},x=async e=>{let t=f.current;if(f.current=null,!s||!c||!t||r){e.paymentFailed({reason:`fail`});return}if(e.expressPaymentType===`google_pay`){e.paymentFailed({reason:`fail`,message:`Google Pay is not available. Please use Apple Pay or pay by card.`}),mr.fire({icon:`error`,title:`Google Pay is not available. Please use Apple Pay or pay by card.`});return}try{let{error:n}=await c.submit();if(n)throw Error(n.message??`Wallet payment could not be validated`);let{error:r,paymentMethod:i}=await s.createPaymentMethod({elements:c});if(r||!i)throw Error(r?.message??`Unable to read wallet payment details`);if(a&&(!h.current||m.current.disabled)){e.paymentFailed({reason:`fail`});return}let l=await(a?m.current.onPaymentMethod:o)(eu(i,e.expressPaymentType),e.expressPaymentType,t);l.accepted||e.paymentFailed({reason:`fail`,message:l.message??`The order total changed. Review it and authorize the wallet again.`})}catch(t){Mt(t,`ExpressCheckoutButtons::onConfirm`,{expressPaymentType:e.expressPaymentType}),e.paymentFailed({reason:`fail`}),mr.fire({icon:`error`,title:`${$l(e.expressPaymentType)} didn't complete. Please try again or pay by card.`})}};if(u===`unavailable`)return null;let S=u===`available`;return(0,$.jsxs)(`div`,{className:S?`mb-3`:`invisible h-0 min-h-0 overflow-hidden`,"aria-hidden":!S,children:[(0,$.jsx)(`div`,{ref:p,"aria-disabled":r,className:[`w-full`,r?`pointer-events-none opacity-50`:void 0].filter(Boolean).join(` `),inert:r||void 0,style:{height:Gl,clipPath:Kl,backgroundColor:l?Hl.dark:Hl.light,colorScheme:l?`dark`:`light`},children:(0,$.jsx)(er,{options:_,onReady:y,onAvailablePaymentMethodsChange:b,onClick:o=>{if(r||a&&!a()){f.current=null,o.reject();return}let s=Pl(e);f.current={amountInCents:s,quoteKey:i},o.resolve({lineItems:zl(e,t,n)})},onConfirm:x,onCancel:()=>{f.current=null},onLoadError:e=>{d(`unavailable`),Mt(Error(e.error?.message??`Express checkout element failed to load`),`ExpressCheckoutButtons::onLoadError`,{})}})}),S&&(0,$.jsxs)(`div`,{className:`mt-3 flex items-center gap-3`,"aria-hidden":`true`,children:[(0,$.jsx)(`span`,{className:`h-px flex-1 bg-lofty-gray-300/60 dark:bg-white/10`}),(0,$.jsx)(`span`,{className:`text-[11px] font-medium lowercase tracking-wide text-lofty-gray-600 dark:text-white/50`,children:`or`}),(0,$.jsx)(`span`,{className:`h-px flex-1 bg-lofty-gray-300/60 dark:bg-white/10`})]})]})},nu=({amount:e,cashDueToday:t,orderLabel:n,disabled:r,quoteKey:i,beforeAuthorize:a,onPaymentMethod:o})=>{let s=y(tr),{isDark:c}=I(),l=Pl(e),u=c?`dark`:`light`,d=(0,Q.useMemo)(()=>Xl(c),[c]),f=(0,Q.useMemo)(()=>({mode:`payment`,currency:`usd`,amount:l,paymentMethodTypes:[`card`],setupFutureUsage:`off_session`,paymentMethodCreation:`manual`,appearance:d}),[l,d]);return!We.isProd||!s||e<.5?null:(0,$.jsx)(Jn,{stripe:s,options:f,children:(0,$.jsx)(tu,{amount:e,cashDueToday:t,orderLabel:n,disabled:r,quoteKey:i,beforeAuthorize:a,onPaymentMethod:o})},u)},ru=e=>{let t=Fr(),{thumbnail:n,tokens:r,walletAddress:i,assetId:a,assetUnit:o,note:s,onClose:c,onComplete:l}=e,u=y(p),{walletData:d}=t,[f,m]=(0,Q.useState)(!1),h=S(),[g,_]=(0,Q.useState)(!1),{thumbMinJpg:v}=w(n);J.trackEvent(`Wallet Opt-In : Landed`,e.analyticsProperties);let b=async()=>{let{isOptedIn:n,walletInfo:r}=await t.getOptInStatus(i,a);n&&l();let{availableBalance:c,availableBalanceRequired:u}=t.balancesForWallet(r),f={pera:{isConnected:d.connected&&d.accounts.includes(i),wallet:i}};if(c>u){let n;if(f.pera.isConnected&&(J.trackEvent(`Wallet Opt-In : Algorand QR Code : Shown`,e.analyticsProperties),n=await t.optInToAssetWallet(i,a,o,s??``)),!n?.success)throw _(!1),m(!0),Error(`Opt in failed`);J.trackEvent(`Wallet Opt-In : Succeeded`,e.analyticsProperties),l()}_(!1)},x=()=>{_(!0),m(!1),{pera:{isConnected:d.connected&&d.accounts.includes(i),wallet:i}}.pera.isConnected?b():h.openModal()};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(In,{isOpen:h.isModalOpen,wallets:u.filter(e=>!e.shared),onClose:h.closeModal,onSuccess:b,mode:Gn.ConnectWallet}),(0,$.jsxs)(`div`,{className:`relative flex flex-col h-full justify-between pt-4.5 sm:pt-6 lg:pt-8 overflow-hidden ${f?`bg-lofty-lightNegative`:`bg-[#F0EFFF]`}`,children:[(0,$.jsx)(`div`,{className:`mb-4.5 px-4.5 sm:px-6 lg:px-8`,children:(0,$.jsx)(ae,{onClick:c})}),(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col lg:flex-row h-full lg:gap-x-4 px-4.5 sm:px-6 lg:px-8 overflow-y-auto`,children:[(0,$.jsx)(`div`,{className:`flex flex-col lg:flex-1`,children:(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`h1`,{className:`text-28 sm:text-4xl lg:text-5xl 2xl:text-64 font-bold ${f?`text-white`:`text-lofty-purple-600`}`,children:`Opt in to your shares`}),(0,$.jsx)(`p`,{className:`text-sm sm:text-lg 2xl:text-2xl mt-4 ${f?`text-white`:`text-lofty-gray-700`}`,children:`In order to receive the shares you just purchased, you will first need to accept the transaction and add the property asset to your external Algorand wallet. You will not recieve your shares until you have manually opted in.`})]})}),(0,$.jsx)(`div`,{className:`flex flex-1 pr-1 pt-12 lg:pt-0 w-full ${f?`text-white`:`text-lofty-purple-600`}`,children:(0,$.jsx)(`div`,{className:`w-full`,children:(0,$.jsxs)(`div`,{className:`border-2 rounded-md py-3 pr-3 flex items-center ${f?`border-white`:`border-lofty-purple/60 sm:flex-col`}`,children:[(0,$.jsx)(`div`,{className:`${f?``:`w-1/4 2xl:w-1/3`}`,children:f?(0,$.jsx)(`i`,{className:`fas fa-triangle-exclamation text-3xl px-4 sm:text-5xl lg:text-5xl`}):(0,$.jsx)(Bt,{src:v})}),(0,$.jsxs)(`div`,{className:`w-3/4 sm:w-full sm:px-4 sm:text-center`,children:[(0,$.jsx)(`p`,{className:`text-xs font-bold mb-2 sm:text-28 lg:text-xl 2xl:text-3xl leading-tight`,children:f?`Transaction cancelled in External Wallet`:`${r?`${r}`:`Your`} shares will be sent to your External Wallet`}),(0,$.jsx)(`p`,{className:`text-xs break-all sm:text-2xl lg:text-lg 2xl:text-2xl`,children:i})]})]})})})]}),!f&&(0,$.jsx)(`div`,{className:`flex px-6 py-6 lg:justify-end`,children:(0,$.jsx)(`button`,{onClick:x,className:`lofty-link-button py-4 px-5 w-full rounded-3xl font-medium text-lg lg:w-1/2 lg:font-semibold lg:text-2xl`,children:g?(0,$.jsx)(zt,{className:`h-6 w-6`}):`Send shares`})}),f?(0,$.jsx)(`div`,{className:`flex px-6 py-6 lg:justify-end`,children:(0,$.jsx)(`button`,{onClick:x,className:`bg-white text-lofty-lightNegative py-4 px-5 w-full rounded-3xl font-medium text-lg lg:w-1/2 lg:font-semibold lg:text-2xl`,children:`Resend shares`})}):(0,$.jsxs)(`div`,{className:`bg-lofty-purple flex items-center space-x-2 px-4.5 py-6 sm:px-6 lg:px-8 lg:py-3 xl:px-12 xl:py-4 2xl:px-16 text-white`,children:[(0,$.jsx)(`p`,{children:(0,$.jsx)(`i`,{className:`fas fa-gift text-3xl`})}),(0,$.jsx)(`p`,{className:`text-xs lg:text-lg 2xl:text-2xl`,children:`We have sent a gift of 0.101 ALGO to your wallet to cover the Algorand fee to add a new asset`})]})]})]})},iu=$t(),au=e=>e===`amex`?`American Express`:e,ou=(e,t)=>{if(e)return t.find(t=>t.name===e)??t[0]},su=(e,t,n=0,r=6)=>H(e*t*10**n,r),cu=(e,t,n,r)=>{let i=H(r,2,!1);if(n>=i)return q.Gift;if(t>=i)return q.Rent;if(t+n>=i)return t>=n?q.Rent:q.Gift;if(Tn(e)||jn(e))return q.Bank;if(Qn(e))return q.Card;if(e===Y.Shared||e===Y.External||!e)return q.Crypto;throw Error(`Invalid payment method`)},lu=async e=>{let{property:t,payerWallet:n,paymentTxnId:r,paymentNonce:i,paymentDue:a,isOptedIn:o,selectedCrypto:s,algoContext:c}=e;return await c.optInToAssetAndPaymentWallet({payerWallet:n,tokenWallet:n,assetId:t.assetId,assetUnit:t.assetUnit,meta:r,amount:su(a,1,s.decimals,0),paymentAsset:s.assetId,paymentAssetDecimals:s.decimals,note:`${i};${r}`,receivingWallet:s.receivingWallet,optIn:!o,onBeginWaiting:async e=>{await St({transactionId:r,nonce:i,algoPmtTxnId:e.groupId?`group:${e.groupId}`:void 0,txnIds:void 0,walletType:`pera-wallet`,reason:`txinit`})}})}
93,uu=async({quantity:e,userData:t,property:n,paymentIntentId:r,appliedRent:i,appliedGift:a,paymentType:o,symbol:s,network:c,exchangeRateId:l,paymentMethodId:u,walletType:d,expectedCardFeeWaiverCapCents:f,expectedCardFeeCents:p,recurringPurchaseIntent:m})=>{let h=await Et({user:t,paymentIntentId:r,propertyId:n.id,quantity:e,useRent:i,useGift:a,paymentMethodSelected:o,symbol:s,network:c,exchangeRateId:l,paymentMethodId:u,selectedMarket:Pe.Primary,walletType:d,expectedCardFeeWaiverCapCents:f,expectedCardFeeCents:p,recurringPurchaseIntent:m});if(h.error){if(h.code===`quantity_changed`)throw h.availableQuantity?Error(`Only ${h.availableQuantity} tokens are available to buy`):Error(`Tokens are no longer available`);let e=(h.error??`Unknown error`)||`Server error`,t=Error(e);throw t.code=h.code,t}if(h.confirmedQuantity&&h.txnId&&o===q.Crypto||h.confirmedQuantity&&h.txnId&&h.freeResult||h.confirmedQuantity&&h.txnId&&h.paymentIntentId&&h.clientSecret)return h;throw J.trackError(`PaymentPage::beginTokenPurchase reached an impossible condition`,`PaymentPage::beginTokenPurchase`,{}),Error(`Unable to begin payment - Server Error`)},du=async({userData:e,property:t,quantity:n,paymentIntentId:r,appliedRent:i,appliedGift:a,paymentType:o,paymentMethod:s,clientSecret:c,stripe:l,selectedMarket:u,expectedCardFeeWaiverCapCents:d,expectedCardFeeCents:f,recurringPurchaseIntent:p})=>{if(!l)throw Error(`Stripe not initialized`);let m=await uu({quantity:n,userData:e,property:t,paymentIntentId:r,appliedRent:i,appliedGift:a,paymentType:o,paymentMethodId:s.symbol,expectedCardFeeWaiverCapCents:d,expectedCardFeeCents:f,recurringPurchaseIntent:p}),h=m.txnId,g=m.clientSecret||c,_=m.paymentIntentId||r;if(o===q.Bank){let e=await vt({txnId:m.txnId,paymentMethodId:s.symbol,selectedMarket:Pe.Primary});if(e.error)throw Mt(`Bank charge failed: ${e.error}`,`PrimaryOrder::Bank`,{quantity:n,propertyId:t.id,saved:!0,txnId:m.txnId,paymentIntentId:_,paymentType:o,appliedRent:i,appliedGift:a,selectedMarket:Pe.Primary}),tt({status:V.Failed,txnId:h}),Error(`Bank payment failed: ${e.error}`)}else{if(!g)throw Error(`No payment intent id`);let r=vr({flow:`payment`,txnId:m.txnId,paymentType:o,selectedMarket:u}),c=await l.confirmPayment({clientSecret:g,confirmParams:{payment_method:s.symbol,receipt_email:e.email,return_url:r.returnUrl},redirect:`if_required`}).finally(()=>yr(r.id));if(c.error)throw Mt(`Card charge failed: ${c.error.message}`,`PrimaryOrder::Card`,{quantity:n,propertyId:t.id,saved:!0,txnId:m.txnId,paymentIntentId:_,paymentType:o,appliedRent:i,appliedGift:a,selectedMarket:Pe.Primary}),u===Pe.Primary&&tt({status:V.Failed,txnId:m.txnId}),Error(`Payment failed: ${c.error.message}`)}return h},fu=async(e,t,n,r,i,a,o,s)=>{let c=await uu({quantity:n,userData:e,property:t,paymentIntentId:r,appliedRent:i,appliedGift:a,paymentType:o,recurringPurchaseIntent:s});if(!c.freeResult)throw Error(`Unable to complete free payment`);return c.txnId},pu=async e=>{let{userData:t,property:n,paymentIntentId:r,paymentType:i,quantity:a,appliedRent:o,appliedGift:s,paymentMethod:c,exchangeRate:l,clientSecret:u,stripe:d,algoContext:f,receivingWallet:p,walletAddress:m,currentSelectedCrypto:h,externalWalletType:g,selectedMarket:_,expectedCardFeeWaiverCapCents:v,expectedCardFeeCents:y,recurringPurchaseIntent:b}=e,x=c.type===Y.Shared,S=c.type===Y.External;if(i===q.Gift||i===q.Rent)return await fu(t,n,a,r,o,s,i,b);if(i===q.Crypto){if(!p||!x&&!m)throw Error(`No receiving wallet found`);let e=await uu({quantity:a,userData:t,property:n,paymentIntentId:r,appliedRent:o,appliedGift:s,paymentType:i,symbol:h.symbol,network:h.network,exchangeRateId:h.exchangeRateId,recurringPurchaseIntent:b,walletType:x?`lofty`:S&&g===$e.PeraWallet?`pera`:void 0});if(!e.txnId||!e.nonce||e.error){let t=(e.error??`Unknown error`)||`Server error`;throw Error(t)}if(x)return e.txnId;if(!x&&g===$e.PeraWallet){let t=await lu({property:n,payerWallet:m,paymentTxnId:e.txnId,paymentNonce:e.nonce,paymentDue:e.cryptoDue,isOptedIn:!0,algoContext:f,captured:e.captured,selectedCrypto:{symbol:c.symbol,assetId:h.assetId??0,exchangeRate:l,decimals:h.decimals,cryptoTotal:1/l,receivingWallet:p}});if(!t.success)throw Error(t.failReason);return e.txnId}}if(i===q.Card||i===q.Bank)return await du({userData:t,property:n,quantity:a,paymentIntentId:r,a
93ppliedRent:o,appliedGift:s,paymentType:i,paymentMethod:c,clientSecret:u,stripe:d,selectedMarket:_,expectedCardFeeWaiverCapCents:v,expectedCardFeeCents:y,recurringPurchaseIntent:b});throw Error(`Unable to process payment`)},mu=e=>{let t=e.message===`popups_blocked`,n=e.message===`user_reject`,r=e.message===`signing_timeout`,i=e.message.toLowerCase().includes(`overspend`)||e.message.toLowerCase().includes(`underflow on subtracting`),a=e.message.toLowerCase().includes(`minimum balance`),o=e.message.includes(`txn dead`);if(n||o)mr.fire({icon:`info`,title:`The order has been canceled`});else if(r)mr.fire({icon:`info`,title:`The order has been canceled`});else if(e.message===`user_cannot_honor`||i||a){let t=a?e.message:`Your payment method has insufficient funds. Add funds and resubmit your order.`;mr.fire({icon:`error`,title:t})}else t?hr.fire({title:`Please try again`,text:`You did not sign this order with your external wallet within 60 seconds. Please try again, and ensure that any popup blockers are disabled`,showConfirmButton:!0,confirmButtonText:`Ok`}):e.message===`Error signing the Txns.`?mr.fire({icon:`error`,title:`Error signing the transactions. Please try again`}):e.message===`Wallet not connected`?mr.fire({icon:`error`,title:`Please re-connect your wallet using the "Add payment or Wallet" Button`}):/doesn.t have trading enabled/i.test(e.message)?hr.fire({title:`The transaction did not complete successfully`,text:`The property doesn’t have trading enabled, likely because it’s listed for sale on the real estate market`,showConfirmButton:!0,confirmButtonText:`Ok`}):hr.fire({title:`The transaction did not complete successfully`,text:`Please reach out to support for help with the following information: ${e.message}`,showConfirmButton:!0,confirmButtonText:`Ok`})},hu=4,gu=(e,t)=>{let n=H(Math.max(0,Math.min(e.useRent??0,t)),2,!1),r=H(Math.min(e.useGift??0,Math.max(0,t-n)),2,!1);return{useRent:n,useGift:r,cryptoSubtotal:e.isInternalPmmV2&&e.isBuyOrder&&e.isMarketOrder&&e.v2DollarTotalBudget!==void 0?H(Math.max(0,t-n-r),6,!1):t}},_u=(e,t,n=e.quantity)=>{if(!(!e.isInternalPmmV2||!e.isBuyOrder||!e.isMarketOrder||e.v2DollarTotalBudget===void 0)){if(!Number.isFinite(e.v2DollarMaxTotal)||e.v2DollarMaxTotal<=0)throw Error(`Refresh the order total before buying.`);if(!t)return e.v2DollarMaxTotal;if(t.contextKey!==e.v2DollarQuoteContextKey||t.totalBudget!==e.v2DollarTotalBudget||t.quantity!==n||t.useGift!==e.useGift||t.useRent!==e.useRent||!Number.isFinite(t.maxTotalUsd)||t.maxTotalUsd<=0)throw Error(`Your wallet order changed. Review the quote and authorize the wallet again.`);return Math.min(e.v2DollarMaxTotal,t.maxTotalUsd)}},vu=(e,t=e.totalUsdPrice,n=e.v2DollarMaxTotal)=>{if(!e.isInternalPmmV2||!e.isBuyOrder||!e.isMarketOrder||e.v2DollarTotalBudget===void 0)return;let r=e.getV2BuyTotal(t),i=n??e.v2DollarMaxTotal;if(!Number.isFinite(t)||t<=0||!Number.isFinite(e.v2DollarTotalBudget)||e.v2DollarTotalBudget<=0||!Number.isFinite(e.v2DollarMaxTotal)||e.v2DollarMaxTotal<=0||!Number.isFinite(i)||i<=0||!Number.isFinite(r)||r>Math.min(e.v2DollarMaxTotal,i)+1e-8)throw Error(`Your order total changed. Review the updated quote before buying.`)},yu=async e=>{try{if(!e.dryRun){if(vu(e,void 0,e.v2ApprovedTotalUsd),!e.connectWalletData.useWalletAddress)throw Error(`Pool payment: a connected wallet is required`);if(e.connectWalletData.paymentMethod===je.LoftyWallet&&!e.kyc?.shared)throw Error(`Pool payment: A KYC asset ID is required but not found in your Lofty Wallet`);if(e.connectWalletData.paymentMethod===je.ExternalWallet&&(e.kyc?.external??0)<=0)throw Error(`Pool payment: A KYC asset ID is required but not found in your linked external wallet (${e.connectWalletData.useWalletAddress})`)}let t=Gt.SwapBuy;e.isSellOrder&&(t=Gt.SwapSell);let n=e.connectWalletData.paymentMethod,r=e.cryptoSubtotal;if(!e.dryRun&&e.isInternalPmmV2&&e.isBuyOrder&&e.isMarketOrder&&e.v2DollarTotalBudget!==void 0){let t=e.exchangeRate?.rate;if(!t||!Number.isFinite(t)||t<=0||!Number.isFinite(e.paymentAmount)||e.paymentAmount<0)throw Error(`Refresh the payment quote before buying.`);r=Math.min(r,H(e.paymentAmount/t,6,!1))}let i=e.isBuyOrder?H(r*10**6,0,!1):void 0,a=e.marketOrderValidation,o=e.isInternalPmmV2&&e.isSellOrder&&!e.dryRun?{minQuoteReceived:a?.minQuoteReceived!==void 0&&(a.quantity??0)>0?e.quantity===a.quantity?a.minQuoteReceived:Math.ceil(a.minQuoteReceived*e.quantity/a.quantity):Math.floor(e.subTotal*1e6)}:void 0;if(o&&(!Number.isSafeInteger(o.minQuoteReceived)||o.minQuoteReceived<=0))throw Error(`Refresh the sale preview before submitting`);let s={base:{quantity:e.quantity}},c={};t===Gt.SwapBuy&&(e.lockResultTxnId&&(c.lockResultTxnId=e.lockResultTxnId),e.paymentMethod?.type===Y.Card&&(c.paymentIntentId=e.paymentIntentId),e.selectedCrypto?.symbol===Fe.Algorand&&(c.algoAmount=i));let l={source:n};e.connectWalletData.paymentMethod===je.ExternalWallet&&(l.wallet=e.connectWalletData.useWalletAddress);let u=!!(e.connectWalletData.paymentMethod===je.ExternalWallet&&c?.algoAmount&&t===Gt.SwapBuy),d=await Ne({poolId:e.poolId,txnRequest:{mode:e.dryRun?Ut.DryRun:Ut.Execute,authInfo:l,params:{type:t,assets:s,bounds:o,amount:i,paymentConversion:c}}});if(We.debug&&console.log(`Got createPoolTransaction result:`,{result:d}),!d.success)throw Error(d.error);if(d.data){if(u&&e.provider){let n=d.data.batchId;try{let r=d.data.txn;if(!r)throw console.error(`executeTransaction ~ no algoTxnId:`,d),mr.fire({text:`Server error, please try again. 0765`,icon:`error`}),Error(`No algoTxnId`);let a=new Uint8Array(iu.Buffer.from(r,`base64`)),u=(await e.provider.signTransactions([a])).filter(e=>e!==null);u.length!==1&&(console.error(`Transaction signing incomplete. Please sign all transactions.`),mr.fire({text:`Transaction signing incomplete. Please sign all transactions`,icon:`error`}));let f=await e.provider.algodClient.sendRawTransaction(u).do();if(await _r.waitForConfirmation(e.provider.algodClient,f.txId,hu),f.txId){let r=await Ne({poolId:e.poolId,txnRequest:{mode:Ut.Execute,authInfo:{...l,source:je.LoftyWallet},params:{batchId:n,type:t,assets:s,bounds:o,amount:i,paymentConversion:c}}});if(!r.success)throw Error(r.error);if(r.data)return r.data.mode===Ut.Execute?{error:null,data:{mode:Ut.Execute,batchId:r.data.batchId}}:{error:null,data:r.data}}}catch(e){throw console.error(`executeTransaction ~ error:`,e),console.log(`executeTransaction ~ error.message:`,e.message),n&&await Ae({batchId:n,status:V.Failed}),e.message.includes(`the user has rejected the transaction`)?(mr.fire({text:`The transaction was rejected`,icon:`error`}),Error(`The transaction was rejected`)):(mr.fire({text:`The transaction failed, please try again. Error: ${e.message}`,icon:`error`}),Error(`External wallet transaction error, please try again`))}}else if(d.data.mode===Ut.Execute){if(d.data.batchId&&!d.data.result)return{error:null,data:{mode:Ut.Execute,batchId:d.data.batchId}};if(Rr(d.data.result)&&e.provider){let t=d.data,n=t.batchId;try{let r=await zr.encodeUnsignedTransactionGroups(t);if(!r)throw console.error(`executeTransaction ~ no encodedTransactions:`,t),mr.fire({text:`Server error, please try again`,icon:`error`}),e.setStep(Sd.Preview),Error(`No encodedTransactions`);let i=[];for(let t of r){let{groupName:r,encodedTransactions:a}=t,o=(await e.provider.signTransactions(a)).filter(e=>e!==null);o.length!==a.length&&(console.error(`Transaction signing incomplete. Please sign all transactions.`),mr.fire({text:`Transaction signing incomplete. Please sign all transactions`,icon:`error`}));let s=await e.provider.algodClient.sendRawTransaction(o).do();if(await _r.waitForConfirmation(e.provider.algodClient,s.txId,hu),s.txId){let{txId:e}=s;await at(1e3),await Ae({batchId:n,txnId:e,groupName:r,status:V.Success}),i.push(s)}}let a={mode:Ut.Execute,result:i.map(e=>({type:je.ExternalWallet,confirmedBlock:e[`confirmed-round`],txnId:e.txId}))};return console.log(`🚀 ~ data:`,a),mr.fire({text:`Your transaction is being processed`,icon:`success`}),{error:null,data:{mode:Ut.Execute,batchId:n}}}catch(t){console.error(`executeTransaction ~ error:`,t),console.log(`executeTransaction ~ error.message:`,t.message),await Ae({batchId:n,status:V.Failed}),t.message.includes(`the user has rejected the transaction`)?mr.fire({text:`The transaction was rejected`,icon:`error`}):mr.fire({text:`The transaction failed, please try again. Error: ${t.message}`,icon:`error`}),e.setStep(Sd.Preview)}}if(Array.isArray(d.data.result))for(let e of d.data.result)Array.isArray(e)||`transactionGroups`in e;return{error:null,data:d.data}}}if(d.data.mode===Ut.DryRun&&Array.isArray(d.data.result)&&d.data.result.length>0)return{error:null,data:{mode:Ut.DryRun,batchId:d.data.batchId,result:d.data.result}};throw Error(`No results received for dryrun`)}catch(t){return e.suppressErrors||(hr.fire({text:`Pool transaction failed: ${t.message}`}),Mt(t,`marketPayments::handleLiquidityPayment`,e)),{data:null,error:t}}},bu=(e,t)=>
93e.quoteKey!==t.quoteKey||e.quantity!==t.quantity||Pl(e.amount)!==Pl(t.amount)||Pl(e.cashDueToday)!==Pl(t.cashDueToday),xu=(e,t,n=!1)=>{let r=(0,Q.useRef)({...e,eligible:!1});n||(r.current=e);let i=ne(n?r.current:e,t);return{settled:i,settling:bu(i,e)}},Su=3e4,Cu=e=>{let{enabled:t,editing:n,contextKey:r,totalBudget:i,unitPrice:a,quantityMax:o,priceBuffer:s,giftCapacity:c,rentCapacity:l,autoGift:u,autoRent:d,feeConfig:f,country:p,waiverCap:m}=e,h=(0,Q.useRef)(e.quote);h.current=e.quote;let g=(0,Q.useRef)(r);g.current=r;let _=JSON.stringify([t,r,i,a,o,s,c,l,u,d,f,p,m]),[v,y]=(0,Q.useState)(0),[b,x]=(0,Q.useState)(),S=b?.key===_?b:void 0,C=S?.candidate;(0,Q.useEffect)(()=>{if(!t||!n)return;let e=!1,v=setTimeout(()=>{let t={giftCapacity:c,rentCapacity:l,autoGift:u,autoRent:d,minimumPayment:.5,processingFee:e=>bn(p)(e,f,m)};Ol({budget:i,unitPrice:a,quantityMax:o,contextKey:r,quote:e=>g.current===r?h.current(e):Promise.reject(Error(`Wallet quote context changed.`))}).then(({quantity:n,quote:a})=>{if(e)return;let o=n*a.actualPrice;if(gl(o,a.dryrunResult)<.999999999)throw Error(`The wallet order is below the minimum share value.`);let c=H(o,2,!0)+s,{useGift:l,useRent:u}=vl(c,t),d=H(Math.max(0,c-l-u),2,!0),h=Fl(d,f,p,m);if(d>0&&h<.5)throw Error(`Adjust the selected credits to meet the minimum card charge.`);x({key:_,candidate:{quantity:n,quote:a,quoteKey:JSON.stringify([r,i,n,l,u,p,f,m]),cashDueToday:d,amount:h,useGift:l,useRent:u,totalBudget:i,quotedAt:a.quotedAt??Date.now()}})}).catch(()=>{e||x({key:_,error:`Unable to calculate this wallet amount.`})})},180);return()=>{e=!0,clearTimeout(v)}},[_,t,n,v]);let w=()=>{let e=C?Date.now()-C.quotedAt:1/0;return t&&n&&C&&e>=0&&e<Su?!0:(C&&(x(void 0),y(e=>e+1)),!1)};return{candidate:C,pending:t&&n&&!S,error:S?.error,ready:w,authorize:(e,t)=>{if(!w()||!C||t.quoteKey!==C.quoteKey)return{accepted:!1,reason:`quote`};let n=Fl(C.cashDueToday,f,e,m);return Bn(e)!==Bn(p)||!Bl(t.amountInCents,Math.max(n,C.amount))?{accepted:!1,reason:`fee`}:{accepted:!0,candidate:C}}}},wu=`The name on this payment method must match your Lofty account name. Please use a card or wallet in that same name.`,Tu=e=>{let t=typeof e==`string`?e.trim().toLowerCase():``;return t?t.split(/\s+/).map(e=>e.replace(/^[^a-z0-9]+|[^a-z0-9]+$/g,``)).filter(Boolean):[]},Eu=(e,t)=>{let n=typeof e==`string`?e.trim().toLowerCase():``,r=typeof t==`string`?t.trim().toLowerCase():``;if(n&&r&&n===r)return!0;let i=Tu(e),a=Tu(t);if(!i.length||!a.length)return!1;let[o,s]=i.length<=a.length?[i,a]:[a,i];return o.every(e=>s.includes(e))},Du=(e,t)=>`Property : Exchange : ${e===`buy`?`BuyOrder`:`SellOrder`} : ${t}`,Ou=Object.values(Be),ku=e=>e&&Ou.includes(e)?e:null,Au=async e=>{let t=await Ue(e);if(t.outcome===`canceled`)return{canceled:!0};let n=t.outcome===`challenge`?{error:`Verification is required to cancel this order`,code:`mfa_required`}:{error:t.error,code:t.code};return{canceled:!1,orderStatus:ku((await Le(e.orderId)).data?.order?.status),...n}},ju=(e,t)=>({orderId:t.orderId,propertyId:t.propertyId,canceled:!1,orderCreated:e.orderStatus!==Be.EXECUTED,inProgress:!0,isCanceling:!1,isCommitting:!1,isAwaitingCommit:!1,isCreating:!1,closeReason:void 0,message:e.error}),Mu=(e,t)=>e.canceled?t.filled>0?{icon:`warning`,title:`Order partially filled`,text:`${t.filled} of ${t.placedQuantity} shares filled at the better order-book price. The rest couldn't fill in time and was canceled — place a new order for the remainder.`}:{icon:`warning`,title:`Order canceled`,text:`The better order-book price was taken before your order could fill. Your funds were returned — please try again.`}:e.orderStatus===Be.EXECUTED?{icon:`success`,title:`Market order filled`,text:`Filled on the order book at the better price.`}:Pu(e),Nu=(e,t)=>!e.canceled&&e.orderStatus===Be.EXECUTED?0:t,Pu=e=>{switch(e.orderStatus){case Be.EXECUTED:return{icon:`info`,title:`Order already filled`,text:`This order executed before it could be cancelled, so nothing was cancelled.`};case Be.EXECUTING:return{icon:`warning`,title:`Cancellation not confirmed`,text:`This order is settling a match and cannot be cancelled right now. Check your orders for the final result.`};case Be.CANCELLED:case Be.EXPIRED:return{icon:`info`,title:`Order status refreshed`,text:`The latest order status is ${e.orderStatus}. Please review it in your orders before taking another action.`};case Be.ACTIVE:case Be.PENDING:case Be.INTENT:return{icon:`warning`,title:`Cancellation not confirmed`,text:`Your order is still open (${e.error}). Please review it in your orders and cancel it again if needed.`};default:return{icon:`warning`,title:`Cancellation not confirmed`,text:`We could not confirm that your order was cancelled (${e.error}). Please check your orders before retrying.`}}},Fu=e=>e===Y.Card||e===Y.Bank||e===Y.NewBank,Iu=e=>e===Y.Card?`card`:e===Y.Bank||e===Y.NewBank?`bank`:e===Y.Shared||e===Y.External?`wallet`:`unknown`,Lu=class extends 
93Error{constructor(e=`Stripe not loaded`){super(e),this.name=`StripeUnavailableError`}},Ru=e=>e instanceof Lu||e instanceof Error&&e.message===`Stripe not loaded`,zu=`Property : Invest : Checkout : Deferred Order Accepted`,Bu=e=>{let t=Math.max(0,e.placedQuantity-e.remainingQuantity);return{emit:!e.alreadyEmitted&&t>0,filledQuantity:t}},Vu=({isBuyOrder:e,approvedPrice:t,requotedPrice:n,isCardFundedBuy:r=!1,tolerancePct:i=1})=>{let a=e?n>t:n<t,o=t>0?Math.abs(n-t)/t*100:0;return{isAdverse:a,movedPct:o,needsApproval:a&&o>=i,hardStop:r&&a}},Hu=.01,Uu=.001,Wu=(e,t)=>t?Math.floor(e*100+1e-9)/100:Math.ceil(e*100-1e-9)/100,Gu=(e,t,n)=>t?e*(1-(n.mtSellFeePct??0)-(n.lpFeePct??0)):n.pmmVersion===`v2`?e:e*(1+(n.mtBuyFeePct??0)+(n.lpFeePct??0)+(n.orFeePct??0)),Ku=(e,t)=>{let n=e?.routing,r=n?performance.now()-n.requestStartedAt:NaN;if(!(!t||!n||n.routingUserId!==t||n.propertyId!==e.propertyId||!Number.isFinite(n.quotedAt)||!Number.isFinite(r)||r<0||r>9e4))return n.orderBook},qu=(e,t)=>Wu(e.totalAllIn+(!t&&e.ammQty>0?wt.buy.buffer/100:0),t),Ju=(e,t,n)=>Math.abs(e.bookQty+e.ammQty-t.bookQty-t.ammQty)>5e-7?!1:n?e.totalAllIn>=t.totalAllIn&&e.capPrice>=t.capPrice:e.totalAllIn<=t.totalAllIn&&e.capPrice<=t.capPrice&&qu(e,!1)<=qu(t,!1),Yu=e=>{let{hasRouteQuote:t,route:n,paymentMethodType:r,isBuyOrder:i,appliedBalance:a}=e;return t?r===Y.Shared||n!==`split`&&!!(r===Y.Card&&i||!r&&i&&a<=0):!1},Xu=e=>{let{orderBook:t,userId:n,quantity:r,isSellOrder:i,ammGrossPricePerToken:a,liquidity:o}=e,s=Ku(t,n);if(!s||!o||!Number.isFinite(r)||r<=0||!Number.isFinite(a)||a<=0)return null;let c=(i?[...s.buyOrders].sort((e,t)=>t.price-e.price):[...s.sellOrders].sort((e,t)=>e.price-t.price)).filter(e=>Number.isFinite(e.price)&&e.price>0&&Number.isFinite(e.quantity)&&e.quantity>0&&e.expireAt>Date.now());if(c.length===0)return null;let l=i?Re:Ye,u=Gu(a,i,o);if(!Number.isFinite(u)||u<=0)return null;let d=u*r,f=0,p=0,m=Math.round(r*1e6);if(!Number.isSafeInteger(m)||m<=0)return null;for(let e of c){if(m<=0)break;let t=i?e.price*(1-l):e.price*(1+l);if(!(i?t>u:t<u))break;let n=Math.round(e.quantity*1e6),r=Math.min(m,n);if(o.pmmVersion===`v2`&&(!i&&n>r&&n-r<1e4&&(r=Math.max(0,n-1e4)),r=Math.floor(r/100)*100),r<=0)continue;let a=r/1e6;p=e.price,f+=a,m-=r}if(f<=0)return null;f=Math.round(f*1e6)/1e6,p=Wu(p,i);let h=f*p;if(o.pmmVersion===`v2`&&(f<.01||f*p<1))return null;let g=m/1e6,_=Wu(i?h*(1-l):h*(1+l),i),v=a*g,y=Wu(u*g,i),b=(Math.round(_*100)+Math.round(y*100))/100;if(!Number.isFinite(b))return null;let x=i?b-d:d-b;if(x<Hu||x<d*Uu)return null;let S=h+v,C=Math.abs(_-h)+Math.abs(y-v);return{route:g>0?`split`:`book`,bookQty:f,ammQty:g,capPrice:p,bookGrossCost:H(h,2,!0),ammGrossCost:H(v,2,!0),bookAllIn:_,ammAllIn:y,totalAllIn:b,totalGross:H(S,2,!0),totalFees:H(C,2,!0),savings:H(x,2,!0)}},Zu=()=>{try{window.Atlas?.recording?.stop?.()}catch{}},Qu=180*1e3,$u=3*1e3,ed=720*60*60*1e3,td=240*1e3,nd=30*1e3,rd=new Map,id=new Map,ad=new Map,od=10*1e3,sd=e=>{J.dataLayerEvent(`purchase`,{ecommerce:{currency:`USD`,value:e.price,transaction_id:e.txnId,items:[{item_name:e.address,item_id:e.listingId,price:e.price,quantity:e.quantity}]}})},cd=`Please remove and re-add this card with the cardholder name before using it for card payments.`,ld=e=>{let{orderFormData:t,orderState:n,property:r,orderBook:i,refetchOrderBook:a,connectModalState:o,orderLoadingModalState:c,cancelToken:l,mfaState:u,pollingData:d,setPollingData:f,setAmmPollData:m,setCurrentStep:h,setOrderState:g,setMfaState:_,getAnalyticsProperties:v}=e,[b,x]=ee(Pa),S=y(p),C=s(),[w,T]=(0,Q.useState)(``),E=Pn(),D=(0,Q.useRef)(null);E&&(D.current=E);let O=te(),k=Fr(),A=Pr(),ne=async()=>{if(E)return D.current=E,E;if(D.current)return D.current;let e=Wn?await Wn:null;if(!e)throw new Lu;return D.current=e,e},M=()=>{let e=E??D.current;if(!e)throw new Lu;return e},re=P(),N=b.direction===Se.Buy,ie=b.direction===Se.Sell,ae=pt(r,1),oe=(0,Q.useRef)(0),se=(0,Q.useRef)(!1),ce=(0,Q.useRef)(null),le=(0,Q.useRef)(null),ue=(e,t)=>`${r.liquidity?.poolId??0}#${t??ie?`sell`:`buy`}#${e}`,de=(e,t)=>{let n=rd.get(ue(e,t));return n&&Date.now()-n.at<nd?n:null},fe=()=>{let e=r.liquidity?.poolId??0;t.isInternalPmmV2&&ad.set(e,(ad.get(e)??0)+1);let n=`${e}#`;for(let e of Array.from(rd.keys()))e.startsWith(n)&&rd.delete(e);Dl(),le.current=null}
93,F=e=>{e===`payment_quote_changed`&&g(e=>({...e,firstPurchaseCardFeeWaiverCap:0,paymentIntentId:``,clientSecret:void 0}))},pe=()=>({quantity:n.order?.quantity,value:(n.order?.quantity??1)*(n.order?.price??1),price:n.order?.price,hcPrice:ae.totalPricePerToken,property:r.address,propertyId:r.id}),I=()=>({email:O.email,paymentIntentId:n.paymentIntentId,propertyId:r.id,quantity:t.quantity,useRent:t.useRent,useGift:t.useGift,paymentMethodSelected:t.paymentType,selectedMarket:b.selectedMarket}),L=()=>{if(t.paymentMethod?.type!==Y.Card)return;let e=[O.firstName,O.lastName].map(e=>typeof e==`string`?e.trim():``).filter(Boolean).join(` `),n=typeof t.paymentMethod.billing_details?.name==`string`?t.paymentMethod.billing_details.name.trim():``;if(n&&e&&!Eu(n,e))throw Error(wu);if(!n&&!e)throw Error(cd)},me=(e,n)=>{let a=n??i;if(!t.isMarketOrder||r.liquidity||!a?.orderBook||e<=0)return null;let o=N?a.orderBook.sellOrders:a.orderBook.buyOrders,s=fc({levels:o,quantity:e,isSellOrder:!N});if(!s)return null;let c=o.reduce((e,t)=>e+t.quantity,0);return{fallbackPrice:H(s.capPrice,2,!0),maxFillableQuantity:c}},he=e=>{let n=me(e);if(!n)throw Error(`Insufficient market liquidity to fully match this quantity. Reduce quantity and try again.`);return t.form.setValue(`price`,n.fallbackPrice),g(e=>({...e,order:e.order?{...e.order,price:n.fallbackPrice}:e.order})),n.fallbackPrice},ge=async e=>{let t=(e.paymentMethod??``).toString().toLowerCase()===`external`?je.ExternalWallet:je.LoftyWallet,n=t===je.ExternalWallet,r=(t===je.LoftyWallet?S.find(e=>e.shared):S.find(e=>!e.shared))?.address,i=k.isActive&&k.activeAccount?.address===r,a=i?$e.PeraWallet:void 0;if(e.isWalletPmt&&n&&(!i||!r)){let e=await o.openModal();if(!e?.success)return;a=$e.PeraWallet,r=e.connectedAccount,i=!0}return{paymentMethod:t,externalConnected:i,externalWalletType:a,useWalletAddress:r,isExternal:n}},_e=(e,n,r,i={})=>{let a=pt(e,n);J.logRevenue(e.id,a.totalPricePerToken,n,fa.TokenPurchase,{...v(),...i},`Property : Invest : Checkout : Payment : Succeeded`),J.updateUserTraits({last_invested_at:new Date,last_payment_method_used:r});let o=i.txnId??i.orderId??j();J.trackAdsPurchase(`MkrNCKDc390cELCF_4Ap`,{value:a.totalPricePerToken*n,transaction_id:o,email:O.email});let s=typeof i.price==`number`?i.price:void 0;sd({txnId:i.txnId??``,address:e.address,listingId:e.id,price:s??a.totalPricePerToken,quantity:t.quantity})},ve=()=>{let e=Number(t.form.getValues(`recurringUsdAmount`))||0;return H(e>0?e:t.totalUsdPrice,2,!1)},ye=async e=>{if(!(!w||!t.isMarketOrder))try{let n=t.paymentMethod?.type===Y.Card,i=await Ge({propertyId:r.id,usdAmount:ve(),cadence:w,fundingPreference:`auto`,savedPaymentMethodId:n?t.paymentMethod?.symbol:void 0,orderPaidWithCard:n||t.paymentType===q.Card,createdFromOrderId:e});if(!i.success||!i.data){let t=i.message??i.error??``;Mt(Error(`recurring plan creation failed: ${t}`),`useOrderExecution::handleCreateReinvest`,{propertyId:r.id,createdOrderId:e})}}catch(t){Mt(t,`useOrderExecution::handleCreateReinvest`,{propertyId:r.id,createdOrderId:e})}},be=()=>{x(e=>({...e,orderId:void 0,propertyId:r.id,canceled:!1,orderCreated:!1,isCanceling:!1,isCommitting:!1,isAwaitingCommit:!1,isPending:!1,isCreating:!0,closeReason:void 0,message:``}))},R=async(e,i)=>{try{let a=t.paymentMethod?.type===Y.Card,o=a&&n.paymentIntentId||void 0,s=await ge({isWalletPmt:!0,paymentAssetId:0,paymentMethod:a||e?`shared`:n.order?.paymentMethod??`shared`});if(!s)return x(e=>({...e,isCreating:!1,message:``})),console.warn(`Wallet connection failed or was canceled, abandoning transaction`),!1;x(e=>({...e,isCreating:!0,attemptId:j()}));let c=i??n.ammLeg,l=await yu({...t,...c??{},connectWalletData:s,poolId:r.liquidity.poolId,paymentIntentId:o,pollingData:d,provider:A,lockResultTxnId:e,v2ApprovedTotalUsd:_u(t,n.v2ExpressApproval??n.v2DollarApproval),setStep:h});if(l.data)return fe(),await at(3e3),m({poll:!0,batchId:l.data.batchId}),!0;throw Error(`Pool transaction failed`)}catch(e){return J.trackEvent(`Property : Invest : MarketOrder : Payment : Failed`,{...v(),...J.errorProperties(e.message)}),x(e=>({...e,isCreating:!1})),!1}},z=async e=>{let{order:n,propertyId:i,assetId:a,isExternal:o,externalWalletType:s,useWalletAddress:c,suppressDoneStep:d,useRentOverride:f,useGiftOverride:p}=e,m,g=!1;try{x(e=>({...e,isCreating:!0,attemptId:j()}));let e=xe(t.orderType),g=await Ct(b.direction,{...n,orderType:t.orderType,useRent:N&&!e?f??t.useRent:0,useGift:N&&!e?p??t.useGift:0,mfaRequest:u.mfaRequest??void 0});if(!g.data&&!g.success)throw _(e=>({...e,modeRequired:Ee.None,otp:null,mfaRequest:null,error:null})),Error(g.message??g.error??`There was an error creating your order`);if(`challenge`in g.data){let e=g.data;if(g.data.reason===Ve.MfaRequired){_(t=>({...t,modeRequired:e.challenge,otp:null,mfaRequest:null}));return}else if(e.reason===Ve.MfaError){_(t=>({...t,modeRequired:e.challenge,otp:null,mfaRequest:null,error:`Invalid authentication token`}));return}else throw _(e=>({...e,modeRequired:Ee.None,otp:null,mfaRequest:null,error:null})),Error(`Invalid verification when placing order`)}_(e=>({...e,modeRequired:Ee.None,otp:null,mfaRequest:null,error:null})),m=g.data.orderId,l.current={...l.current,opToken:g.data.opToken??``};let[v]=await Promise.all([nt(m,i),w?ye(m):Promise.resolve()]);if(o){let e=null,n=N&&t.selectedCurrency===Fe.Algorand;x(e=>({...e,orderId:m,propertyId:i,isCreating:!1,isAwaitingCommit:!1,isCommitting:!0}));let{appId:r,applicationAddress:o,amountToCommit:l,controlAppId:u,quantity:d,note:f}=v,p=N?l:Number(d);if(s===$e.PeraWallet){let s=null;if(n){let e=m,n=i;s=await k.optInToAssetAndPaymentWallet({optIn:!1,payerWallet:c,amount:p,receivingWallet:t.exchangeRate.receiving,paymentAsset:t.exchangeRate.assetId,paymentAssetDecimals:t.exchangeRate.decimals,note:`Lofty Secondary;Purchase for order:${m},app:${r};OrderType:buy;`,onBeginWaiting:async t=>{let r=Array.isArray(t.txnIds)?t.txnIds[0]:void 0;r&&await He(`ALGO_PAYMENT`,r,e,n)},assetUnit:``,tokenWallet:``,assetId:0,meta:``})}else if(!o&&re){let e=S.find(e=>e.shared)?.address;if(!e)throw Error(`Unable to find Lofty wallet address for transfer`);let t=G.find(e=>e.symbol===Fe.USDCoin),n=m,r=i;s=await k.optInToAssetAndPaymentWallet({optIn:!1,payerWallet:c,amount:p,receivingWallet:e,paymentAsset:t?.assetId??0,paymentAssetDecimals:6,note:`Lofty Secondary;Transfer to Lofty wallet for order:${m};OrderType:buy;`,onBeginWaiting:async e=>{let t=Array.isArray(e.txnIds)?e.txnIds[0]:void 0;t&&await He(`USDC_TRANSFER`,t,n,r)},assetUnit:``,tokenWallet:``,assetId:0,meta:``})}else s=await k.executeWalletConnectEscrowAndCall({address:c,appId:r,appAddress:o,amount:p,assetId:a,controlAppId:u,note:f});if(!s?.success)throw Error(s?.failReason);e=s.results[0].txId}if(!e)throw Error(`An error occurred while signing the transactions to place an order. [T]`);n||await He(`COMMIT`,e,m,i)}if(_e(r,t.quantity,q.Crypto,{crypto_currency:t.paymentMethod?.symbol,crypto_currency_exchange_rate:1/(t.exchangeRate?.rate??1
93),exchange:!0,txnId:m}),d||h(Sd.Done),o)return}catch(e){if(J.trackEvent(`Crypto : Buy : Checkout : Payment : Failed`,{...v(),...J.errorProperties(e)}),await new Promise(e=>{x(t=>(e(t.canceled||t.isCanceling),t))}))return;if(mu(e),m&&i){x(t=>({...t,isCanceling:!0,isCreating:!1,isCommitting:!1,isAwaitingCommit:!1,message:e.message}));let t=await Au({propertyId:i,orderId:m,reason:dt.USER_SIGN_CANCEL,mfaRequest:l.current});if(!t.canceled){mr.fire({...Pu(t),timer:1e4}),x(e=>({...e,...ju(t,{orderId:m,propertyId:i})}));return}}g=!0}x(e=>({...e,orderId:m,propertyId:i,canceled:g,orderCreated:!g,inProgress:!0,isCanceling:!1,isCommitting:!1,isAwaitingCommit:!1,isCreating:!1}))},Te=async()=>{be();try{J.trackEvent(`Property : Invest : Checkout : Payment : Submitted`,v());let e=await ge({isWalletPmt:t.isWalletPayment,paymentAssetId:0,paymentMethod:n.order?.paymentMethod??`shared`});if(!e){console.warn(`Wallet connection failed or was canceled, abandoning transaction`),x(e=>({...e,isCreating:!1,message:``}));return}x(e=>({...e,isCreating:!0,attemptId:j()}));let i=await pu({userData:O,property:r,paymentIntentId:n.paymentIntentId||void 0,paymentType:t.paymentType,quantity:t.quantity,appliedRent:t.useRent,appliedGift:t.useGift,paymentMethod:t.paymentMethod,assetId:t.raw.selectedCurrency?.assetId,exchangeRate:t.exchangeRate.rate,clientSecret:n.clientSecret,stripe:M(),algoContext:k,receivingWallet:t.exchangeRate?.receiving,walletAddress:e.useWalletAddress??``,currentSelectedCrypto:t.selectedCrypto,externalWalletType:e.externalWalletType,selectedMarket:Pe.Primary,expectedCardFeeWaiverCapCents:Math.round(n.firstPurchaseCardFeeWaiverCap*100),expectedCardFeeCents:Math.round(t.processingFee*100),recurringPurchaseIntent:w?{usdAmount:ve(),cadence:w}:void 0});if(t.isGiftPay||t.isRentPay){let e=t.isGiftPay?q.Gift:q.Rent;_e(r,t.quantity,e,{txnId:i})}else if(t.isCryptoPayment)_e(r,t.quantity,q.Crypto,{crypto_currency:t.paymentMethod.symbol,crypto_currency_exchange_rate:1/(t.exchangeRate?.rate??1
93),txnId:i});else{let[e,n]=t.isCardPay?[{payment_method:`CARD`,payment_provider:`stripe`,txnId:i},q.Card]:[{payment_method:`ACH`,payment_provider:`stripe`,txnId:i},q.Bank];_e(r,t.quantity,n,e)}if(i)f({poll:!0,txnId:i,paymentType:t.paymentType}),w&&await ye(i);else throw Error(`Payment failed`)}catch(e){F(e.code),J.trackEvent(`Property : Invest : Checkout : Payment : Failed`,{...v(),...J.errorProperties(e.message)}),mu(e),x(e=>({...e,isCreating:!1}))}T(``),Zu()},B=async()=>{let e=r.id,i=O.isVerified;be(),g(e=>e.ammLeg?{...e,ammLeg:null}:e);try{J.trackEvent(`Property : Invest : MarketOrder : Payment : Submitted`,v());let a=n.order,o=t.useGift+t.useRent>0,s=t.isWalletPayment&&o;if(N||s){try{J.trackEvent(`Crypto : Buy : Checkout : Payment : Submitted`,{quantity:n.order?.quantity,value:(n.order?.quantity??1)*(n.order?.price??1),price:n.order?.price,hcPrice:ae.totalPricePerToken,property:r.address,propertyId:r.id,usdSource:t.paymentMethod?.type===`bank_account`?`ach`:`card`,isKycComplete:i}),x(e=>({...e,isCreating:!0,attemptId:j()}));let s=await Et({user:O,paymentIntentId:n.paymentIntentId||void 0,propertyId:e,quantity:a.quantity,useRent:t.useRent,useGift:t.useGift,paymentMethodSelected:t.paymentType,symbol:`usdc`,network:we.Algorand,exchangeRateId:t.exchangeRate?.
93id??``,selectedMarket:Pe.Secondary,paymentMethodId:t.paymentMethod?.symbol,cryptoToBuy:`usdc`,price:a.price,expireAt:a.expireAt,poolId:r.liquidity.poolId,priceImpact:a.marketOrderValidation?.priceImpact.value??0,expectedCardFeeWaiverCapCents:Math.round(n.firstPurchaseCardFeeWaiverCap*100),expectedCardFeeCents:Math.round(t.processingFee*100),maxTotalUsd:_u(t,n.v2ExpressApproval??n.v2DollarApproval,a.quantity)});if(!s.txnId||s.error){F(s.code);let e=(s.error??`Unknown error`)||`Server error`;throw Mt(`BeginPayment failed: ${s.error}`,`PlaceOrder::BeginPayment`,{...I(),price:a.price,txnId:s.txnId}),Error(e)}w&&await ye(s.txnId);let c=t.paymentType===q.Card&&(s.paymentDue??0)>0,l=t.isMarketOrder&&t.isFiatPay&&!c,u=s.clientSecret||n.clientSecret;if((s.paymentIntentId||s.clientSecret)&&g(e=>({...e,paymentIntentId:s.paymentIntentId||e.paymentIntentId,clientSecret:s.clientSecret||e.clientSecret})),c&&(f({poll:!0,txnId:s.txnId,paymentType:q.Card}),i)){if(!u)throw Mt(`Card charge failed: No Client Secret`,`PlaceOrder::Card`,{...I(),price:a.price,txnId:s.txnId,source:t.paymentMethod.symbol}),Error(`An error occurred generating client payment parameters`);L();let e=vr({flow:`payment`,txnId:s.txnId,paymentType:q.Card,selectedMarket:Pe.Secondary}),n=await M().confirmPayment({clientSecret:u,confirmParams:{payment_method:t.paymentMethod.symbol,receipt_email:O.email,return_url:e.returnUrl},redirect:`if_required`}).finally(()=>yr(e.id));if(n.error)throw Mt(`Card charge failed: ${n.error.message}`,`PlaceOrder::Card`,{...I(),price:a.price,txnId:s.txnId,source:t.paymentMethod.symbol}),Error(`Payment failed: ${n.error.message}`);f({poll:!0,txnId:s.txnId,paymentType:q.Card,chargeConfirmed:!0})}if(t.paymentType===q.Bank&&(s.paymentDue??0)>0){f({poll:!0,txnId:s.txnId,paymentType:q.Bank});let e=await vt({txnId:s.txnId,paymentMethodId:t.paymentMethod.symbol,selectedMarket:Pe.Secondary});if(e.error)throw Mt(`Bank charge failed: ${e.error}`,`PlaceOrder::Market::Bank`,{...I(),price:a.price,txnId:s.txnId,source:t.paymentMethod.symbol}),Error(`Bank payment failed: ${e.error}`)}if(t.isWalletPayment){let e=t.selectedCrypto?.symbol===Fe.Algorand||t.selectedCrypto?.symbol===Fe.USDCoin;o&&(e=!1),f({poll:!0,txnId:s.txnId,paymentType:t.paymentType,skipAlgoTxn:e})}(t.paymentType===q.Gift||t.paymentType===q.Rent)&&f({poll:!0,txnId:s.txnId,paymentType:t.paymentType});let[d,p]=t.paymentType===q.Bank?[{payment_method:`ACH`,payment_provider:`stripe`,exchange:!0,txnId:s.txnId,price:a.price},q.Bank]:[{payment_method:`CARD`,payment_provider:`stripe`,exchange:!0,txnId:s.txnId,price:a.price},q.Card];l&&f({poll:!0,txnId:s.txnId,paymentType:t.paymentType,chargeConfirmed:!0}),_e(r,n.order?.quantity??0,p,d)}catch(t){J.trackEvent(`Property : Invest : Checkout : Payment : Failed`,{...v(),...J.errorProperties(t)}),hr.fire({title:`Unable to complete payment`,text:t.message}),x(n=>({...n,propertyId:e,canceled:!1,orderCreated:!1,inProgress:!0,isCanceling:!1,isCommitting:!1,isAwaitingCommit:!1,isCreating:!1,message:t.message??``}))}if(c.closeModal(),t.isFiatPay||t.isBalancePay)return}let l=ie&&t.paymentMethod?.type!==Y.Card;!o&&l&&await R()}catch(e){J.trackEvent(`Property : Invest : MarketOrder : Payment : Failed`,{...v(),...J.errorProperties(e.message)}),x(e=>({...e,isCreating:!1}))}finally{T(``),Zu()}},De=async(e,t,n,r)=>{let i=Date.now()+td,a=null,o=n,s,c=!1,u=e=>{let t=Bu({placedQuantity:n,remainingQuantity:e,alreadyEmitted:c});t.emit&&(c=!0,r?.(t.filledQuantity))};for(;;){await at($u);try{let t=await Le(e),n=t.data?.order;if(n){if(s=n.status,o=Math.max(0,Number(n.quantity??o)),n.status===Be.CANCELLED||n.status===Be.EXPIRED){let e=t.data?.streams?.find(e=>e.cancelReason)?.cancelReason,r=ar({cancelReason:e,subType:n.subType});r&&mr.fire({icon:`error`,title:r.title,text:r.text,timer:8e3});return}if(n.status===Be.EXECUTED||o<=0){u(o),mr.fire({icon:`success`,title:`Market order filled`,text:`Filled on the order book at the better price.`});return}a===null&&n.isMatchEligible!==!1&&(a=Date.now()+Qu)}}catch{}if(a===null){if(Date.now()>i)break}else if(Date.now()>a)break}if(s===Be.EXECUTING)return;let d=Math.max(0,n-o),f=await Au({propertyId:t,orderId:e,reason:dt.USER_SIGN_CANCEL,mfaRequest:l.current});u(Nu(f,o)),mr.fire({...Mu(f,{filled:d,placedQuantity:n}),timer:1e4})},ke=async e=>{let{ammQty:i}=e,a=await ze({quantity:i,silent:!0,showLoading:!1,forceFresh:!0});if(!a)return!1;let o=r.liquidity,s=Gu(a.dryrunResult.actualPrice.value,ie,o)*i;if(!Number.isFinite(s)||(ie?s<e.ammAllIn:s>
93e.ammAllIn))return!1;let c=Wu(s+(N?wt.buy.buffer/100:0),ie),l=gu(t,c),u={quantity:i,cryptoSubtotal:l.cryptoSubtotal,marketOrderValidation:a.dryrunResult};if(g(e=>({...e,ammLeg:u})),N){let{useRent:s,useGift:u}=l,d=s+u>0,p=_u(t,n.v2ExpressApproval??n.v2DollarApproval),m=p===void 0?void 0:Math.min(c,H(p-Wu(e.bookAllIn,!1),2,!1));if(m!==void 0&&m<c)return!1;let h=await Et({user:O,paymentIntentId:n.paymentIntentId||void 0,propertyId:r.id,quantity:i,useRent:s,useGift:u,paymentMethodSelected:t.paymentType,symbol:`usdc`,network:we.Algorand,exchangeRateId:t.exchangeRate?.id??``,selectedMarket:Pe.Secondary,paymentMethodId:t.paymentMethod?.symbol,cryptoToBuy:`usdc`,price:a.actualPrice,expireAt:n.order?.expireAt??Date.now(),poolId:o.poolId,priceImpact:a.dryrunResult.priceImpact.value??0,expectedCardFeeWaiverCapCents:Math.round(n.firstPurchaseCardFeeWaiverCap*100),maxTotalUsd:m});if(!h.txnId||h.error)return F(h.code),Mt(`Split AMM leg BeginPayment failed: ${h.error}`,`PlaceOrder::SplitAmmLeg`,{...I(),ammQty:i,price:a.actualPrice}),!1;if(t.paymentMethod?.type===Y.Card){if(f({poll:!0,txnId:h.txnId,paymentType:q.Card}),(h.paymentDue??0)>0){let e=h.clientSecret||n.clientSecret;if((h.paymentIntentId||h.clientSecret)&&g(e=>({...e,paymentIntentId:h.paymentIntentId||e.paymentIntentId,clientSecret:h.clientSecret||e.clientSecret})),!e)return Mt(`Split AMM leg card charge failed: No Client Secret`,`PlaceOrder::SplitAmmLeg`,{...I(),ammQty:i,txnId:h.txnId,source:t.paymentMethod.symbol}),!1;L();let r=vr({flow:`payment`,txnId:h.txnId,paymentType:q.Card,selectedMarket:Pe.Secondary}),a=await M().confirmPayment({clientSecret:e,confirmParams:{payment_method:t.paymentMethod.symbol,receipt_email:O.email,return_url:r.returnUrl},redirect:`if_required`}).finally(()=>yr(r.id));if(a.error)return Mt(`Split AMM leg card charge failed: ${a.error.message}`,`PlaceOrder::SplitAmmLeg`,{...I(),ammQty:i,txnId:h.txnId,source:t.paymentMethod.symbol}),!1}return f({poll:!0,txnId:h.txnId,paymentType:q.Card,chargeConfirmed:!0}),_e(r,i,q.Card,{payment_method:`CARD`,payment_provider:`stripe`,exchange:!0,txnId:h.txnId,price:a.actualPrice}),!0}return f({poll:!0,txnId:h.txnId,paymentType:t.paymentType,skipAlgoTxn:!d}),!0}return await R(void 0,u)},V=async()=>{let e=r.id;be();try{let i=n.order,o=n.routingApproval,s=o?.userId===O.id&&o.propertyId===e?o.quote:null;g(e=>({...e,ammLeg:null}));let c;try{let e=le.current;le.current=null,c=(e&&Date.now()-e.at<od?await e.promise:await a?.())?.data??void 0}catch{}let u=Xu({orderBook:c,userId:O.id,quantity:i.quantity,isSellOrder:ie,ammGrossPricePerToken:i.marketOrderValidation?.actualPrice.value??i.price,liquidity:r.liquidity});if(!u||!s||!Ju(u,s,ie)||!Yu({hasRouteQuote:!!u,route:u?.route,paymentMethodType:t.paymentMethod?.type,isBuyOrder:N,appliedBalance:t.useRent+t.useGift})){x(e=>({...e,isCreating:!1})),h(Sd.OrderOptions),hr.fire({title:`Market prices moved`,text:`The quoted route is no longer available for this payment method. Review the updated quote and resubmit your order.`});return}let d=u.route===`split`&&u.ammQty>0,f=N&&t.paymentMethod?.type===Y.Card;if(J.trackEvent(`Property : Invest : MarketOrder : Payment : Submitted`,{...v(),route:u.route,bookQty:u.bookQty,ammQty:u.ammQty,cardRouted:f}),f){if(!O.isVerified){await B();return}let a=_u(t,n.v2ExpressApproval??n.v2DollarApproval,i.quantity),o=await Ke({propertyId:e,price:u.capPrice,expireAt:Date.now()+ed,orderType:Ce.Market,routedMarketOrder:!0,quantity:u.bookQty,usdSource:`card`,useRent:t.useRent,useGift:t.useGift,savedPaymentMethodId:t.paymentMethod?.symbol,...a===void 0?{}:{maxTotalUsd:a}});if(!o.success)throw Mt(`Routed card BeginPayment failed: ${o.error}`,`PlaceOrder::RoutedCardOrder`,{...I(),price:u.capPrice}),Error(o.message??`There was an error creating your order`);let s=o.data.orderId;l.current={...l.current,opToken:o.data.opToken??``},h(Sd.Done),await De(s,e,u.bookQty,e=>{_e(r,e,q.Card,{payment_method:`CARD`,payment_provider:`stripe`,exchange:!0,orderId:s,price:u.capPrice})});return}let p={direction:b.direction,propertyId:e,price:u.capPrice,expireAt:Date.now()+ed,orderType:Ce.Market,routedMarketOrder:!0,quantity:u.bookQty,paymentMethod:i.paymentMethod,paymentCurrency:i.paymentCurrency,hcPrice:ae.totalPricePerToken,property:r.address},m=N?G.find(e=>e.symbol===p.paymentCurrency)?.assetId:r.assetId;if(!m&&m!==0){Mt(Error(`No assetId found`),`PlaceOrder::handleRoutedMarketOrder`,{}),mr.fire({icon:`error`,title:`Something went wrong`,text:`Please contact support.`});return}let y=await ge({isWalletPmt:!0,paymentAssetId:0,paymentMethod:`shared`});if(!y){x(e=>({...e,isCreating:!1,message:``})),console.warn(`Wallet connection failed or was canceled, abandoning transaction`);return}if(d&&!await ke(u)){x(e=>({...e,isCreating:!1})),h(Sd.OrderOptions),hr.fire({title:`Unable to quote market order`,text:`We could not start the market-pool part of your order. Review the updated quote and resubmit.`});return}let S={order:p,propertyId:e,assetId:m,useWalletAddress:y.useWalletAddress,isExternal:!1,suppressDoneStep:d,useRentOverride:d?0:void 0,useGiftOverride:d?0:void 0};_(e=>({...e,mfaCycleParameters:{parameters:S}})),await z(S);let C=await new Promise(e=>{x(t=>(e({orderId:t.orderId,canceled:t.canceled}),t))});if(!C.orderId){C.canceled&&d&&mr.fire({icon:`warning`,title:`Order partially placed`,text:`The order-book part could not be placed; the market-pool part is still processing.`,timer:8e3});return}if(C.canceled){d&&mr.fire({icon:`warning`,title:`Order partially placed`,text:`The order-book part could not be placed; the market-pool part is still processing.`,timer:8e3});return}await De(C.orderId,e,p.quantity)}catch(e){J.trackEvent(`Property : Invest : MarketOrder : Payment : Failed`,{...v(),...J.errorProperties(e.message)}),x(e=>({...e,isCreating:!1}))}finally{T(``),Zu()}},Ae=async()=>
93{J.trackEvent(Du(b.direction,`Submit`),pe());let e,i=r.id,o=O.isVerified;be();let s=n.order;if(t.isMarketOrder&&t.isInternalPmmV2&&(s={...s,orderType:Ce.Market,routedMarketOrder:!0,expireAt:Date.now()+ed}),t.isMarketOrder&&!r.liquidity){let e;try{e=(await a?.())?.data??void 0}catch{}let n=me(s.quantity,e);if(!n)throw Error(`Insufficient market liquidity to fully match this quantity. Reduce quantity and try again.`);let r=N&&!t.isWalletPayment&&t.paymentMethod?.type!==`bank_account`,i=s.price,o=n.fallbackPrice,c=Vu({isBuyOrder:N,approvedPrice:i,requotedPrice:o,isCardFundedBuy:r});if(c.isAdverse&&J.trackEvent(`Property : Exchange : Market Order : Requoted`,{...v(),approvedPrice:i,requotedPrice:o,movedPct:c.movedPct,quantity:s.quantity,hardStopped:c.hardStop,needsApproval:c.needsApproval}),c.hardStop){x(e=>({...e,isCreating:!1})),t.form.setValue(`price`,o),h(Sd.OrderOptions),hr.fire({title:`Market prices moved`,text:`The order book price changed before your order could be placed. Nothing was charged — review the updated quote and resubmit your order.`});return}if(c.needsApproval){let e=N?`pay`:`receive`,n=o*s.quantity;if(!(await gr.fire({title:`The price moved`,html:`Someone traded ahead of you, so this order no longer fills at $${i.toFixed(2)} a share.<br/><br/>You would now ${e} <b>$${o.toFixed(2)}</b> a share &mdash; <b>$${n.toFixed(2)}</b> for ${s.quantity} ${s.quantity===1?`share`:`shares`}, before fees.<br/><br/>Nothing has been placed yet.`,showCancelButton:!0,confirmButtonText:`Continue at $${o.toFixed(2)}`,cancelButtonText:`Cancel`})).isConfirmed){x(e=>({...e,isCreating:!1})),t.form.setValue(`price`,o),h(Sd.OrderOptions);return}}s={...s,price:o},t.form.setValue(`price`,o)}if(N&&(!t.isWalletPayment||t.isBalancePay)){try{if(J.trackEvent(`Crypto : Buy : Checkout : Payment : Submitted`,{quantity:n.order?.quantity,value:(n.order?.quantity??1)*(n.order?.price??1),price:n.order?.price,hcPrice:ae.totalPricePerToken,property:r.address,propertyId:r.id,usdSource:t.paymentMethod?.type===`bank_account`?`ach`:`card`,isKycComplete:o}),x(e=>({...e,isCreating:!0,attemptId:j()})),o){let a=t.paymentMethod?.type!==`bank_account`,o=await Ke({propertyId:r.id,price:s.price,expireAt:s.expireAt,...t.isInternalPmmV2?{orderType:s.orderType,routedMarketOrder:s.routedMarketOrder}:{},quantity:s.quantity,usdSource:a?`card`:`ach`,useRent:t.useRent,useGift:t.useGift,savedPaymentMethodId:re&&a?t.paymentMethod?.symbol:void 0});if(!o.success)throw c.closeModal(),Mt(`BeginPayment failed: ${o.error}`,`PlaceOrder::CreatePendingOrder`,{...I(),price:s.price,orderId:e}),Error(o.message??`There was an error creating your order`);if(e=o.data.orderId,e&&w&&await ye(e),l.current={...l.current,opToken:o.data.opToken??``},re&&a){J.trackEvent(zu,{...v(),orderId:e,price:s.price,quantity:n.order?.quantity??0,payment_method:`CARD`,exchange:!0}),h(Sd.Done),c.closeModal(),t.isMarketOrder&&!r.liquidity&&e&&await De(e,i,s.quantity);return}}let a=await Et({user:O,paymentIntentId:n.paymentIntentId||void 0,propertyId:i,quantity:s.quantity,useRent:t.useRent,useGift:t.useGift,paymentMethodSelected:t.paymentType,symbol:`usdc`,network:we.Algorand,exchangeRateId:t.exchangeRate?.
93id??``,selectedMarket:Pe.Secondary,paymentMethodId:t.paymentMethod?.symbol,cryptoToBuy:`usdc`,orderId:e,price:s.price,expireAt:s.expireAt,expectedCardFeeWaiverCapCents:Math.round(n.firstPurchaseCardFeeWaiverCap*100),expectedCardFeeCents:Math.round(t.processingFee*100)});if(!a.txnId||a.error){F(a.code);let t=(a.error??`Unknown error`)||`Server error`;throw Mt(`BeginPayment failed: ${a.error}`,`PlaceOrder::BeginPayment`,{...I(),price:s.price,txnId:a.txnId,orderId:e}),Error(t)}if(t.isBalancePay){h(Sd.Done);return}if(t.paymentType===q.Bank){f({poll:!0,txnId:a.txnId,paymentType:q.Bank});let i=await vt({txnId:a.txnId,paymentMethodId:t.paymentMethod.symbol,selectedMarket:Pe.Secondary});if(i.error)throw Mt(`Bank charge failed: ${i.error}`,`PlaceOrder::Bank::newBank`,{...I(),saved:!0,price:s.price,txnId:a.txnId,orderId:e,source:t.paymentMethod.symbol}),Error(`Bank payment failed: ${i.error}`);let[o,c]=[{payment_method:`ACH`,payment_provider:`stripe`,exchange:!0,txnId:a.txnId,price:s.price},q.Bank];_e(r,n.order?.quantity??0,c,o),h(Sd.Done);return}if(t.paymentType===q.Card){if(f({poll:!0,txnId:a.txnId,paymentType:q.Card}),o){let r=a.clientSecret||n.clientSecret;if((a.paymentIntentId||a.clientSecret)&&g(e=>({...e,paymentIntentId:a.paymentIntentId||e.paymentIntentId,clientSecret:a.clientSecret||e.clientSecret})),!r)throw Mt(`Card charge failed: No Client Secret`,`PlaceOrder::Card`,{...I(),price:s.price,txnId:a.txnId,orderId:e,source:t.paymentMethod.symbol}),Error(`An error occurred generating client payment parameters`);L();let i=vr({flow:`payment`,txnId:a.txnId,paymentType:q.Card,selectedMarket:Pe.Secondary}),o=await M().confirmPayment({clientSecret:r,confirmParams:{payment_method:t.paymentMethod.symbol,receipt_email:O.email,return_url:i.returnUrl},redirect:`if_required`}).finally(()=>yr(i.id));if(o.error)throw Mt(`Card charge failed: ${o.error.message}`,`PlaceOrder::Card`,{...I(),price:s.price,txnId:a.txnId,orderId:e,source:t.paymentMethod.symbol}),Error(`Payment failed: ${o.error.message}`)}let[i,c]=[{payment_method:`CARD`,payment_provider:`stripe`,exchange:!0,txnId:a.txnId,price:s.price},q.Card];_e(r,n.order?.quantity??0,c,i),h(Sd.Done);return}}catch(t){J.trackEvent(`Property : Invest : Checkout : Payment : Failed`,{...v(),...J.errorProperties(t)}),hr.fire({title:`Unable to complete payment`,text:t.message}),e&&i&&Ue({propertyId:i,orderId:e,reason:dt.NO_SIGN_CANCEL,mfaRequest:l.current}),x(n=>({...n,orderId:e,propertyId:i,canceled:!1,orderCreated:!1,inProgress:!0,isCanceling:!1,isCommitting:!1,isAwaitingCommit:!1,isCreating:!1,message:t.message??``}))}c.closeModal();return}let u=N?G.find(e=>e.symbol===s.paymentCurrency)?.assetId:r.assetId;if(!u&&u!==0){Mt(Error(`No address or assetId found`),`PlaceOrder::handleSubmit`,{}),mr.fire({icon:`error`,title:`Something went wrong`,text:`Please contact support.`});return}let d=await ge({isWalletPmt:!0,paymentAssetId:0,paymentMethod:n.order?.paymentMethod??`shared`});if(!d){x(e=>({...e,orderCreated:!1,inProgress:!0,isCanceling:!1,isCreating:!1,isCommitting:!1,isAwaitingCommit:!1,message:``})),console.warn(`Wallet connection failed or was canceled, abandoning transaction`);return}if(o){J.trackEvent(`Crypto : Buy : Checkout : Payment : Submitted`,{quantity:n.order?.quantity,value:(n.order?.quantity??1)*(n.order?.price??1),price:n.order?.quantity,hcPrice:ae.totalPricePerToken,property:r.address,propertyId:r.id,usdSource:d.isExternal?je.ExternalWallet:je.LoftyWallet});let e={order:s,propertyId:i,assetId:u,useWalletAddress:d.useWalletAddress,isExternal:d.isExternal,externalWalletType:d.externalWalletType};_(t=>({...t,mfaCycleParameters:{parameters:e}})),await z(e)}T(``),Zu()},Me=async()=>{let e=n.order;n.routingApproval||vu(t,e?e.price*e.quantity:void 0,_u(t,n.v2ExpressApproval??n.v2DollarApproval,e?.quantity));let i=t.paymentMethod?.type;Fu(i)&&await ne();let a=N&&t.isBalancePay&&!t.isPrimaryOrder;if(!t.paymentMethod&&!a)throw Error(`Payment Methods not correctly loaded`);if(!t.exchangeRate&&t.isWalletPayment)throw Error(`Crypto exchange rates are not available`);if(t.isMarketOrder&&!r.liquidity&&he(t.quantity),ie){let e=or(S,r);if(t.quantity>e)throw Error(e>0?`You can sell up to ${e} ${e===1?`share`:`shares`} right now. Any remaining shares are staked in the liquidity pool — withdraw them first to sell.`:`These shares are staked in the liquidity pool and must be withdrawn before you can sell them.`)}},Ne=(0,Q.useCallback)(async(e={})=>
93{let n=r.liquidity?.poolId??0,i=ad.get(n)??0,a=e.data?.tokenQuantity??e.quantity??t.quantity,o=t.quantity>0?a/t.quantity:1,s=e.cacheOnly&&e.sellOverride!==void 0?e.sellOverride:t.isSellOrder,c=!s,l={...t,quantity:a,isSellOrder:s,isBuyOrder:c,cryptoSubtotal:c?t.cryptoSubtotal*o:t.cryptoSubtotal},u=t.isBuyOrder&&t.isMarketOrder?t.limits.buyMax:null;if(!(e.cacheOnly?t.orderType===Ce.Market:t.isMarketOrder)||!r.liquidity||a<=0)return e.cacheOnly?(console.info(`[MarketQuote] prewarm skipped`,{quantity:a,orderType:t.orderType,hasLiquidity:!!r.liquidity}),null):(oe.current+=1,g(e=>({...e,marketOrderValidation:null,marketOrderValidationQuantity:null})),null);if(!e.cacheOnly&&u!==null&&a>u)return oe.current+=1,g(e=>({...e,marketOrderValidation:null,marketOrderValidationQuantity:null})),t.quantity>u&&t.form.setValue(`tokenQuantity`,Math.max(0,u),{shouldDirty:!0,shouldValidate:!0}),e.silent||(h(Sd.OrderOptions),hr.fire({title:`Not enough market liquidity`,text:`This market order is limited to ${u} ${u===1?`share`:`shares`} right now. Try a smaller quantity or place a limit order.`})),null;let d=e.cacheOnly||e.forceFresh?null:de(a);if(d)return oe.current+=1,g(e=>({...e,marketOrderValidation:d.dryrunResult,marketOrderValidationQuantity:a})),{actualPrice:d.actualPrice,dryrunResult:d.dryrunResult};let f=e.cacheOnly?oe.current:++oe.current,p=()=>!e.cacheOnly&&f!==oe.current,m=await ge({isWalletPmt:!1,paymentAssetId:0,paymentMethod:`shared`});if(!m)return p()?null:e.cacheOnly?(console.info(`[MarketQuote] prewarm aborted`,{quantity:a,reason:`wallet connection unavailable`}),null):(g(e=>({...e,marketOrderValidation:null,marketOrderValidationQuantity:null})),e.silent||(x(e=>({...e,isCreating:!1,message:``})),h(Sd.OrderOptions)),null);e.showLoading&&x(e=>({...e,isDryrunLoading:!0}));let _;try{_=await yu({...l,connectWalletData:m,poolId:r.liquidity.poolId,dryRun:!0,suppressErrors:!0,setStep:h})}catch(t){return p()?null:e.cacheOnly?(console.info(`[MarketQuote] prewarm dryrun threw`,{quantity:a,message:t?.message}),null):(g(e=>({...e,marketOrderValidation:null,marketOrderValidationQuantity:null})),e.silent||(h(Sd.OrderOptions),hr.fire({title:`Unable to quote market order`,text:`We could not quote ${a} ${a===1?`share`:`shares`} against current market liquidity. Try a smaller quantity or place a limit order.`})),null)}finally{e.showLoading&&x(e=>({...e,isDryrunLoading:!1}))}if(p())return null;if(_?.data&&_.data.mode===Ut.DryRun){let r=_.data.result[0],o=H(r.actualPrice.value,2,!0);return o>0&&r.result.value>0?(ad.get(n)??0)===i?(rd.set(ue(a,s),{actualPrice:o,dryrunResult:r,at:Date.now()}),e.cacheOnly||g(e=>({...e,marketOrderValidation:r,marketOrderValidationQuantity:a})),{actualPrice:o,dryrunResult:r}):null:e.cacheOnly?(console.info(`[MarketQuote] prewarm: no executable liquidity`,{quantity:a,actualPrice:o}),null):(g(e=>({...e,marketOrderValidation:null,marketOrderValidationQuantity:null})),e.silent||(h(Sd.OrderOptions),t.form.setValue(`orderType`,Ce.Limit,{shouldDirty:!0,shouldValidate:!0}),hr.fire({title:`No market liquidity available`,text:`This market order 
93cannot be submitted because the pool currently has 0 liquidity. Place a limit order or try again after liquidity is added.`})),null)}return e.cacheOnly?(console.info(`[MarketQuote] prewarm: dryrun returned no result`,{quantity:a,error:_?.error?.message??null}),null):(g(e=>({...e,marketOrderValidation:null,marketOrderValidationQuantity:null})),e.silent||(h(Sd.OrderOptions),hr.fire({title:`Unable to quote market order`,text:`We could not quote ${a} ${a===1?`share`:`shares`} against current market liquidity. Try a smaller quantity or place a limit order.`})),null)},[ie,t,r.liquidity,h,g,x]),U=(0,Q.useCallback)(()=>{oe.current+=1,ce.current?.resolve(null),ce.current=null,x(e=>({...e,isDryrunLoading:!1}))},[x]),Ie=(0,Q.useCallback)((e,t)=>{U(),g(n=>({...n,marketOrderValidation:t.dryrunResult,marketOrderValidationQuantity:e}))},[U,g]),W=(0,Q.useCallback)((e,t=nd,n=!1)=>{let i=ue(e,n),a=rd.get(i);if(a&&Date.now()-a.at<t)return Promise.resolve({...a,quotedAt:a.at});let o=`${O.id}:${ad.get(r.liquidity?.poolId??0)??0}:${i}`,s=id.get(o);if(s)return s;let c=Ne({quantity:e,cacheOnly:!0,sellOverride:n,silent:!0,showLoading:!1}).then(e=>e?{...e,quotedAt:Date.now()}:null).finally(()=>{id.delete(o)});return id.set(o,c),c},[Ne,O.id,r.liquidity?.poolId]),Re=(0,Q.useCallback)(e=>W(e,nd,!0),[W]),ze=(0,Q.useCallback)((e={})=>new Promise(n=>{let i=e.data?.tokenQuantity??e.quantity??t.quantity;if(!e.cacheOnly&&(i<=0||!t.isMarketOrder||!r.liquidity)){oe.current+=1,g(e=>({...e,marketOrderValidation:null,marketOrderValidationQuantity:null})),n(null);return}let a=t.isBuyOrder&&t.isMarketOrder?t.limits.buyMax:null,o=a===null||i<=a;if(!e.cacheOnly&&!e.forceFresh&&t.isMarketOrder&&r.liquidity&&i>0&&o){let e=de(i),t=rd.get(ue(i));if(console.info(`[MarketQuote] validate`,{quantity:i,cacheHit:!!e,quoteAgeMs:t?Date.now()-t.at:null}),e){oe.current+=1,g(t=>({...t,marketOrderValidation:e.dryrunResult,marketOrderValidationQuantity:i})),n({actualPrice:e.actualPrice,dryrunResult:e.dryrunResult});return}}if(e.cacheOnly){Ne({...e,showLoading:!1}).then(n);return}let s={params:e,run:Ne,resolve:n},c=async e=>{se.current=!0;let t=e;for(;t;){let e=t;x(t=>({...t,isDryrunLoading:!e.params.cacheOnly}));let n=await e.run({...e.params,showLoading:!1});e.resolve(n),t=ce.current,ce.current=null}se.current=!1,x(e=>({...e,isDryrunLoading:!1}))};if(se.current){ce.current&&ce.current.resolve(null),ce.current=s,x(e=>({...e,isDryrunLoading:!0}));return}c(s)}),[Ne,x,g,t,r.liquidity,ie]),We=(0,Q.useCallback)(async(e,t)=>{let n=Math.min(t?.maxAgeMs??nd,nd),r=t?.sell,i=e=>{let t=rd.get(ue(e,r));return!!t&&Date.now()-t.at<n};for(let t of e){if(t<=0||i(t))continue;let e=Date.now(),n=!1;for(let e=0;e<2&&!n;e+=1)n=!!await ze({quantity:t,silent:!0,showLoading:!1,cacheOnly:!0,sellOverride:r});console.info(`[MarketQuote] prewarm`,{quantity:t,sell:r??ie,landed:n,ms:Date.now()-e})}},[ze,ie]),qe=async e=>{J.trackEvent(`Property : Invest : Checkout : Proceeded to Payment`,v());let i=t.smartRoute?{quote:t.smartRoute,userId:O.id,propertyId:r.id}:null;if(!t.isMarketOrder){let t=xe(e.orderType);g(n=>({...n,routingApproval:null,order:{direction:b.direction,propertyId:r.id,price:t?e.triggerLimitPrice??e.triggerPrice??e.price:e.price,expireAt:Number(gn(Hr(new Date,{days:e.expireAt}),`T`)),quantity:e.tokenQuantity,paymentMethod:e.paymentMethodSymbol,paymentCurrency:e.paymentCurrency,hcPrice:ae.totalPricePerToken,property:r.address,...t?{triggerPrice:e.triggerPrice,triggerLimitPrice:e.triggerLimitPrice,trailPercent:e.trailPercent,referenceWindowDays:e.referenceWindowDays}:{}}}))}if(N&&t.isWalletPayment&&!t.hasBuyFunds){let e=!t.hasBuyFee&&t.hasBuyTotal?` to cover the fee on this order`:` to cover this order`,r=zc(n.paymentMethods),i=await hr.fire({title:`Not enough in your wallet`,text:`Your wallet does not have enough${e}. Add funds, or pay by card to buy right now.`,showDenyButton:!0,confirmButtonText:`Add funds`,denyButtonText:r?`Pay by card`:`Close`});i.isConfirmed?(x(Na),C(`/account/deposits`)):i.isDenied&&r&&(t.form.setValue(`paymentMethod`,r.name,{shouldDirty:!0,shouldValidate:!0}),J.trackEvent(`Property : Invest : Checkout : Payment Method : Chosen`,{...v(),payment_type:r.type,payment_type_is_saved:!0}
93),mr.fire({icon:`success`,title:`Switched to your card. Submit again to buy.`}));return}if(h(Sd.Preview),t.isMarketOrder){if(!r.liquidity){let t;try{t=he(e.tokenQuantity)}catch(e){h(Sd.OrderOptions),hr.fire({title:`Order cannot be placed`,text:String(e instanceof Error?e.message:e)});return}g(n=>({...n,routingApproval:null,order:{direction:b.direction,propertyId:r.id,price:t,expireAt:Number(gn(Hr(new Date,{days:e.expireAt}),`T`)),quantity:e.tokenQuantity,paymentMethod:e.paymentMethodSymbol,paymentCurrency:e.paymentCurrency,hcPrice:ae.totalPricePerToken,property:r.address}}));return}a&&(le.current={promise:a().catch(()=>void 0),at:Date.now()});let o=await ze({data:e,silent:!1,showLoading:!0});if(!o)return;let s=null;try{let r=_u(t,n.v2ExpressApproval,e.tokenQuantity);i||vu(t,o.actualPrice*e.tokenQuantity,r),r!==void 0&&(s={contextKey:t.v2DollarQuoteContextKey,totalBudget:t.v2DollarTotalBudget,quantity:e.tokenQuantity,useGift:t.useGift,useRent:t.useRent,maxTotalUsd:r})}catch(e){fe(),g(e=>({...e,v2ExpressApproval:null})),h(Sd.OrderOptions),hr.fire({title:`Quote changed`,text:e.message});return}t.form.setValue(`price`,o.actualPrice),g(t=>({...t,routingApproval:i,v2DollarApproval:s,order:{direction:b.direction,propertyId:r.id,price:o.actualPrice,expireAt:Number(gn(Hr(new Date,{days:e.expireAt}),`T`)),quantity:e.tokenQuantity,paymentMethod:e.paymentMethodSymbol,paymentCurrency:e.paymentCurrency,hcPrice:ae.totalPricePerToken,property:r.address,marketOrderValidation:o.dryrunResult}}))}},Je=async()=>{J.trackEvent(Du(b.direction,`Submit`),pe()),be();let e=n.order;if(!t.isWalletPayment)throw Error(`Optimized orders require payment from your Lofty wallet`);x(e=>({...e,isCreating:!0,attemptId:j()})),_(e=>({...e,mfaCycleParameters:{...e.mfaCycleParameters,retryAction:`optimized`,parameters:null}}));let i=t.optimizedWindowDays??t.form.getValues(`optimizedWindowDays`)??7,a=await Oe({propertyId:r.id,direction:b.direction,totalQuantity:e.quantity,priceLimit:e.price,windowDays:i,paymentMethod:je.LoftyWallet,mfaRequest:u.mfaRequest??void 0});if(!a.success||!a.data)throw _(e=>({...e,modeRequired:Ee.None,otp:null,mfaRequest:null,error:null})),Error(typeof a.error==`string`?a.error:`Failed to submit optimized order`);if(`challenge`in a.data){let e=a.data;if(e.reason===Ve.MfaRequired){_(t=>({...t,modeRequired:e.challenge,otp:null,mfaRequest:null})),x(e=>({...e,isCreating:!1}));return}if(e.reason===Ve.MfaError){_(t=>({...t,modeRequired:e.challenge,otp:null,mfaRequest:null,error:`Invalid authentication token`})),x(e=>({...e,isCreating:!1}));return}throw _(e=>({...e,modeRequired:Ee.None,otp:null,mfaRequest:null,error:null})),Error(`Invalid verification when placing optimized order`)}let o=a.data;_(e=>({...e,modeRequired:Ee.None,otp:null,mfaRequest:null,error:null,mfaCycleParameters:{retryAction:null,parameters:null}})),x(e=>({...e,isCreating:!1,orderId:o.id})),h(Sd.Done),c.closeModal()};return{reinvest:w,setReinvest:T,previewOrder:qe,executeOrder:async()=>{let e=Iu(t.paymentMethod?.type);try{if(await Me(),t.isPrimaryOrder)await Te();else if(t.isOptimizedOrder)await Je();else if(t.isMarketOrder&&r.liquidity)n.routingApproval?await V():await B();else if(t.isSecondaryOrder)await Ae();else throw Error(`Unable to process selected market: ${b.selectedMarket}`)}catch(t){if(Ru(t)){await Fn({source:`pre_submit`,paymentCategory:e});return}let n=t instanceof Error?t.message:`Something went wrong. Please try again.`;sr({stage:`pre_submit`,errorCode:n===`Payment Methods not correctly loaded`?`payment_methods_missing`:n===`Crypto exchange rates are not available`?`exchange_rate_missing`:`unhandled_submit`,stripeReady:!!(E??D.current),paymentCategory:e}),hr.fire({text:n})}},executeLiquidityPayment:R,processSecondaryPaymentStep:z,handleOptimizedOrder:Je,validateMarketOrder:ze,quoteMarketBuy:W,quoteMarketSell:Re,adoptMarketBuyQuote:Ie,discardMarketValidation:U,prewarmMarketQuotes:We,resetMarketQuoteCache:fe}},ud=[It.OptimizedOrderEnabled,It.OptimizedOrderConfig],dd=e=>H(e,2,!0),fd=e=>typeof e==`number`&&e>0,pd=(e,t)=>{let n=t?e?.orderBook?.sellOrders:e?.orderBook?.buyOrders,r=t?e?.ranges?.sell?.min:e?.ranges?.buy?.max,i=[...(n??[]).map(e=>e.price),r].filter(fd);return i.length>0?t?Math.min(...i):Math.max(...i):null},md=e=>{let t=[];for(let n of e.quotes){let e=$n.find(e=>e.symbol===n.symbol&&e.network===n.network);if(e){let{id:r,...i}=e,{id:a,...o}=n;if(e.id===`ETH`)continue;t.push({...i,...o,id:r,exchangeRateId:a})}}return t},hd=e=>{let t={maintainer:e.isBuyOrder?Ye:Re,operatingReserve:(e.isBuyOrder,0),liquidity:0};if(e.isMarketOrder&&e.liquidity){let n=e.isBuyOrder&&e.liquidity.pmmVersion===`v2`;t.maintainer=n?0:(e.isBuyOrder?e.liquidity?.mtBuyFeePct:e.liquidity?.mtSellFeePct)??0,t.operatingReserve=n?0:(e.isBuyOrder?e.liquidity?.orFeePct:0)??0,t.liquidity=n?0:e.liquidity?.lpFeePct??0}return t},gd=e=>{let{direction:t,startingPrice:n,initialLimitPrice:r,property:i,selectedMarket:a,paymentMethods:o,feeConfig:s,quantityOwned:c,userOrderData:l,marketOrderValidation:u,marketOrderValidationQuantity:d,orderBook:f,bestBuyPrice:m,bestSellPrice:h,smartRoutingEnabled:g,firstPurchaseCardFeeWaiverCap:_}=e,v=y(p),b=ge({id:`PlaceOrder`,requireUpdates:!0}),[x,S]=(0,Q.useState)(null),[C,w]=(0,Q.useState)(!1),T=t===Se.Buy,E=t===Se.Sell?i.liquidity?.marketPrice.priceLow??0:i.liquidity?.marketPrice.priceHigh??0,D=i.liquidity?.pmmVersion===`v2`,ee=D||!1,k=!!i.liquidity&&E>0,A=T?(f?.orderBook?.sellOrders??[]).length>0:(f?.orderBook?.buyOrders??[]).length>0,j=k&&ee||A,ne=l?.properties[i.id]?.orderValidation.maxTokensAllowed??0,M=p
93d(f,T),re=Da(async()=>(await Tt(i.id)).data,{enabled:!!i?.id,deps:[i.id]}),N=Da(async()=>fr({queryKey:[`propertyOraclePrice`,{id:i.id}]}),{enabled:!!i?.id,deps:[i.id]}),P=N.data?.pricePerToken?.mid??0,ae=re.data?.marketCap??0,oe=(re.data?.numIssued??i.numIssued??i.tokens)||i.tokens,se=ae>0&&oe>0?ae/oe:0,ce=P>0||se>0,le=N.isFetched&&re.isFetched,ue=P>0?P:se>0?se:n,de=T?re.data?.bestAsk:re.data?.bestBid,fe=T?h:m,F=ce||le?ue:0,pe=fd(r),I=pe?r:M??(fd(fe)?fe:null)??(fd(de)?de:null)??F,L=ie({mode:`onChange`,defaultValues:{tokenQuantity:1,paymentCurrency:G[0].symbol,orderType:pe?Ce.Limit:j?Ce.Market:Ce.Limit,paymentMethod:void 0,paymentMethodSymbol:void 0,price:dd(I),expireAt:90,appliedRent:0,appliedGift:0,optimizedWindowDays:7}}),{register:me,unregister:he}=L;(0,Q.useEffect)(()=>(me(`paymentMethod`),()=>he(`paymentMethod`)),[me,he]);let _e=L.watch(`tokenQuantity`),ve=L.watch(`price`),ye=L.watch(`paymentCurrency`),be=L.watch(`paymentMethod`),xe=L.watch(`orderType`),R=L.watch(`appliedGift`),z=L.watch(`appliedRent`),we=L.watch(`optimizedWindowDays`),{isOn:Te,value:Ee}=O(ud),B=xe===Ce.Market,De=t===Se.Sell,Oe=a===Pe.Primary,ke=Oe?n:ve,V=!Oe&&B,Ae=xe&&xe===Ce.Limit,je=xe===Ce.Optimized,Me=Ae||je,Ne=k&&ee,U=d===_e?u:void 0,Ie=(0,Q.useRef)(pe),W=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{pe&&(Ie.current=!0)},[pe]),(0,Q.useEffect)(()=>{let e=L.watch((e,t)=>{t.name===`orderType`&&!W.current&&(Ie.current=!0)});return()=>e.unsubscribe()},[]);let Le=(0,Q.useCallback)(()=>{Ie.current=!0},[]);(0,Q.useEffect)(()=>{let e=xe===Ce.Market;if(e&&!j){W.current=!0,L.setValue(`orderType`,Ce.Limit,{shouldValidate:!0}),W.current=!1;return}!e&&j&&!Ie.current&&(W.current=!0,L.setValue(`orderType`,Ce.Market,{shouldValidate:!0}),W.current=!1)},[j,xe]);let Re=(0,Q.useMemo)(()=>{let e=f?.orderBook;if(!V||Ne||!e||_e<=0)return null;let t=De?e.buyOrders??[]:e.sellOrders??[],n=fc({levels:t,quantity:_e,isSellOrder:De});if(!n)return null;let r=t.map(e=>e.price).filter(e=>Number.isFinite(e)&&e>0);if(r.length===0)return null;let i=De?Math.max(...r):Math.min(...r);return{capPrice:H(n.capPrice,2,!0),averagePrice:H(n.filledNotional/_e,2,!0),bestPrice:i}},[V,Ne,f,_e,De]),ze=ou(be,o),{id:Be,isAuth:Ve}=te(),He=(0,Q.useMemo)(()=>!g||!V||!Ne||!U?null:Xu({orderBook:f,userId:Ve?Be:void 0,quantity:_e,isSellOrder:De,ammGrossPricePerToken:U.actualPrice.value,liquidity:i.liquidity}),[g,V,Ne,U,f,Be,Ve,_e,De,i.liquidity]),Ue=Yu({hasRouteQuote:!!He,route:He?.route,paymentMethodType:ze?.type,isBuyOrder:T,appliedBalance:R+z}),We=ke;V&&i.liquidity&&ee?(We=Ue&&He?He.totalGross/_e:U?U.actualPrice.value:De?i.liquidity.marketPrice.priceLow:i.liquidity.marketPrice.priceHigh,Ue||(We=dd(We))):V&&!Ne&&Re&&(We=Re.averagePrice),(0,Q.useEffect)(()=>{if(!De){S(null);return}ht(i.id).then(e=>S(e??null)).catch(()=>S(null))},[De,i.id]),(0,Q.useEffect)(()=>{ze?.symbol&&L.setValue(`paymentMethodSymbol`,ze.symbol)},[ze?.symbol]);let Ge=b.getExchangeRate(ye),Ke=T?1:-1,qe=hd({isBuyOrder:T,isSellOrder:De,isMarketOrder:V,liquidity:i.liquidity});Ue&&He&&(qe.maintainer=He.totalGross>0?He.totalFees/He.totalGross:qe.maintainer,qe.operatingReserve=0,qe.liquidity=0);let Je=Ue&&He?He.totalGross:D&&De&&V&&U?.tradingFees?U.result.value:We*_e,Ye=D&&De&&V&&!Ue&&U?.tradingFees?U.tradingFees.maintainer:Oe?0:H(Je*qe.maintainer,2,!0),Xe=D&&De&&V&&!Ue&&U?.tradingFees?U.tradingFees.liquidity:!Oe&&V?H(Je*qe.liquidity,2,!0):0,Ze=(Oe?0:H(Je*qe.maintainer,6,!0))+0+(!Oe&&V?H(Je*qe.liquidity,6,!0):0);Ze=Ue&&He?He.totalFees:H(Ze,2,!0),D&&De&&V&&!Ue&&U?.tradingFees&&(Ze=Ye+Xe);let Qe=D&&T&&V,$e=V&&T&&Ne&&(!Ue||(He?.ammQty??0)>0)?wt.buy.buffer/100:0,K=Ue&&He?qu(He,De):Je+Ze*Ke;K=H(K,2,!0),V&&T&&Ne&&!Ue&&(K+=wt.buy.buffer/100);let{useGift:et,useRent:tt}=Qe?vl(K,{giftCapacity:R,rentCapacity:z,autoGift:!1,autoRent:!1,processingFee:()=>0}):{useGift:R,useRent:z},nt=T?et+tt:0,rt=Math.max(0,K-nt),it=_??0,at=V&&T&&Ne&&(!Ue||(He?.ammQty??0)>0)&&!D?Math.max(0,H(Je+H(Je*.05,2,!0)+wt.buy.buffer/100,2,!1)-nt):rt,ot=ze?.fee(at,s,it)??0,st=it>0?ze?.fee(at,s)??0:ot,ct=H(Math.max(0,st-ot),2,!0),lt=[Y.Shared,Y.External].includes(ze?.type),ut=D&&V&&lt?0:ot,dt=rt+ut*Ke,ft=Ze+ot,pt=Ge?H(dt/Ge.rate,6,!1):0,mt=cu(ze?.type,tt,et,K),gt=mt===q.Gift,vt=mt===q.Rent,yt=gt||vt,bt=[Y.Shared,Y.External].includes(ze?.type)&&!yt,xt=[Y.Bank,Y.NewBank,Y.Card].includes(ze?.type)&&!yt,St=Pc(ye),Ct=Math.min(c,An(be,v,i)),Et=(i.assetDecimals??0)>0?1e-4:1,Dt=(i.assetDecimals??0)>0?.01:1,Ot=e=>Et>
93=1?Math.max(0,Math.floor(e)):Math.max(0,H(Math.floor(H(e/Et,6))*Et,6,!1)),kt=V&&!Ne?Ot(De?(f?.orderBook?.buyOrders??[]).reduce((e,t)=>e+t.quantity,0):(f?.orderBook?.sellOrders??[]).reduce((e,t)=>e+t.quantity,0)):null,At=V&&T&&Ne&&typeof i.liquidity?.baseStaked==`number`?Ot(i.liquidity.baseStaked):null,J=i.liquidity?.marketPrice?.priceLow??0,jt=V&&De&&Ne&&typeof i.liquidity?.liquidQuoteUSD==`number`&&J>0?Ot(i.liquidity.liquidQuoteUSD/J):null,Mt=kt??At??jt,Nt=De&&Mt!==null?Math.min(Ct,Mt):Ct,Pt=T&&Mt!==null?Math.min(ne,Mt):ne,Ft=e=>lt?0:ze?.fee(e,s,it)??0,Lt={giftCapacity:e.v2DollarBalanceBudget?.gift??R,rentCapacity:e.v2DollarBalanceBudget?.rent??z,autoGift:e.v2DollarBalanceBudget?.gift!==void 0,autoRent:e.v2DollarBalanceBudget?.rent!==void 0,processingFee:Ft,minimumPayment:_l(ze?.type)?_t:0},Rt={priceBuffer:Qe?wt.buy.buffer/100:$e,appliedBalance:(e.v2DollarBalanceBudget?.gift??R)+(e.v2DollarBalanceBudget?.rent??z),processingFee:Ft,allocateBalance:e=>{let t=vl(e,Lt);return t.useGift+t.useRent}},zt=Qe&&C?Number(L.watch(`usdAmount`)??0):void 0,Bt=zt===void 0?void 0:H(K+ut,2,!0),Vt=Math.floor(Nt*E*100)/100,Ht=D&&De&&V&&C&&Number(L.watch(`usdAmount`)??0)<Vt-1e-9,Ut=kl({enabled:(D&&T&&V&&C||Ht)&&!!l?.kyc?.shared,sell:De,editing:e.isEditing,budget:zt??Number(L.watch(`usdAmount`)??0),unitPrice:E,quantityMax:De?Nt:Pt,quantity:_e,contextKey:`${Be}:${i.liquidity?.poolId}`,quote:De?e.quoteV2Sell:e.quoteV2Buy,onResolved:(t,n)=>{e.onV2DollarQuoteResolved(t,n),L.setValue(`tokenQuantity`,t,{shouldDirty:!0,shouldValidate:!0})}}),Wt=(0,Q.useMemo)(()=>{if(!Re)return null;let{capPrice:e,averagePrice:t,bestPrice:n}=Re;return{capPrice:e,averagePrice:t,effectivePrice:e,bestPrice:n,slippagePct:n>0?H(Math.abs((t-n)/n)*100,2,!0):0}},[Re]),Gt=(0,Q.useMemo)(()=>{let e=Ee[It.OptimizedOrderConfig];return{impactThresholdPct:typeof e?.impactThresholdPct==`number`?e.impactThresholdPct:2,windowPresetsDays:Array.isArray(e?.windowPresetsDays)&&e.windowPresetsDays.length?e.windowPresetsDays:[1,3,7,14]}},[Ee]),Kt=(0,Q.useMemo)(()=>{if(_e<=0)return 0;if(Wt)return Wt.slippagePct;if(V&&U&&i.liquidity){let e=De?i.liquidity.marketPrice.priceLow:i.liquidity.marketPrice.priceHigh,t=U.actualPrice.value;return e>0?H(Math.abs((t-e)/e)*100,2,!0):0}return 0},[_e,Wt,V,U,i.liquidity,De]),qt=!!Te[It.OptimizedOrderEnabled],Jt=qt&&j&&ze?.type===Y.Shared&&R<=0&&z<=0&&Kt>=Gt.impactThresholdPct,Yt=On(be,ye,pt,v),Xt=b.currentRates&&md(b.currentRates),Zt=Xt&&Rc(Xt,St?.symbol),Qt=(0,Q.useRef)(!1),$t=(0,Q.useRef)(t);$t.current!==t&&(Qt.current=!1,$t.current=t),(0,Q.useEffect)(()=>{if(!l)return;let e=Dt;if(De){Qt.current?Nt>0&&_e>Nt?L.setValue(`tokenQuantity`,Nt):_e<=0&&L.setValue(`tokenQuantity`,Nt>0?Math.min(e,Nt):e):(L.setValue(`tokenQuantity`,Nt>0?Math.min(Math.max(_e,e),Nt):e),Qt.current=!0);return}!Qt.current&&!L.getFieldState(`tokenQuantity`).isDirty?(L.setValue(`tokenQuantity`,Pt>0?Math.max(e,Math.min(1,Pt)):e),Qt.current=!0):Pt>0&&_e>Pt?L.setValue(`tokenQuantity`,Pt):_e<=0&&L.setValue(`tokenQuantity`,Pt>0?Math.min(e,Pt):e)},[Nt,Pt,1,l]);let en=(0,Q.useRef)(t),tn=(0,Q.useRef)(null),nn=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{let e=en.current!==t;e&&(en.current=t,tn.current=null,nn.current=null,L.resetField(`tokenQuantity`,{keepDirty:!1,defaultValue:1}));let n=dd(I);if(n<=0)return;let r=Number(L.getValues(`price`));if(Math.abs(r-n)<.005){tn.current=n;return}let i=tn.current,a=nn.current,o=a!==null&&Math.abs(n-a)<.005&&r<=1&&n>1,s=i===null&&r<=1&&n>1,c=i!==null&&Math.abs(r-i)<.005;(e||!L.getFieldState(`price`).isDirty||o||s||c)&&(L.resetField(`price`,{defaultValue:n}),L.setValue(`price`,n,{shouldDirty:!1,shouldTouch:!1,shouldValidate:!0}),tn.current=n,nn.current=n,setTimeout(()=>{nn.current===n&&(nn.current=null)},0))},[I,t,ve]),(0,Q.useEffect)(()=>{if(K<0&&T){let e=R-Math.abs(K),t=z;e<=0&&(t=Math.max(0,z-Math.abs(e))),e=Math.max(0,e),t=Math.max(0,t),L.setValue(`appliedGift`,H(e,2,!0)),L.setValue(`appliedRent`,H(t,2,!0))}},[t,_e,ve,R,z,K]);let rn={isInternalPmmV2:D,platformFee:Ye,processingFee:ot,operatingReserveFee:0,poolFee:Xe,allFees:ft,isBuyOrder:T,isBalancePay:yt,isWalletPayment:bt,isPrimaryOrder:Oe,isMarketOrder:V,poolId:i.liquidity?.poolId??0};return{usdMode:C,setUsdMode:w,v2DollarQuote:Ut,v2DollarTotalBudget:zt,v2DollarMaxTotal:Bt,allocateV2BuyBalances:e=>vl(e,Lt),v2FiatChargeBelowMinimum:Qe&&C&&_l(ze?.type)&&rt>0&&H(dt,2,!0)<.5,getV2BuyTotal:e=>yl(e,Rt),v2DollarQuoteContextKey:`${Be}:${i.liquidity?.poolId}`,isInternalPmmV2:D,form:L,isBuyOrder:T,isSellOrder:De,isPrimaryOrder:Oe,isSecondaryOrder:a===Pe.Secondary,isMarketOrder:V,isLimitOrder:Ae,isOptimizedOrder:je,showLimitPriceInput:Me,isMarketSelectable:j,markUserOrderTypeChoice:Le,hasOpposingOrders:A,isFiatPay:xt,isCardPay:mt===q.Card,isGiftPay:gt,isRentPay:vt,isBalancePay:yt,isWalletPayment:bt,isCryptoPayment:mt===q.Crypto,orderType:xe,kyc:l?.kyc??null,quantity:_e,pricePerToken:We,useRent:tt,useGift:et,totalUsdPrice:Je,platformFee:Ye,totalPlatformFee:Ze,operatingReserveFee:0,subTotal:K,priceBuffer:$e,paymentAmount:rt,finalTotal:dt,processingFee:ot,waivedProcessingFee:ct,cryptoSubtotal:pt,paymentType:mt,paymentMethod:ze,selectedCurrency:ye,selectedCrypto:Zt,isUSDC:ye===Fe.USDCoin,hasBuyFunds:Yt.wallets.hasPayment&&Yt.wallets.hasFee,hasBuyFee:Yt.w
93allets.hasFee,hasBuyTotal:Yt.wallets.hasPayment,buyFundsAvailable:H(Yt.wallets.availableCurrency/10**Yt.wallets.currencyDecimals,Yt.wallets.currencyDecimals,!1),limits:{buyMax:Pt,sellMax:Nt,suggestedBuy:1,marketDepthMax:Mt},feesData:rn,exchangeRate:Ge,raw:{buyFundsAvailable:Yt,selectedCurrency:St},marketOrderValidation:U,smartRoute:Ue?He:null,potentialSmartRoute:He,giftEscrowLockupSummary:x,noAmmMarketInfo:Wt,fairShareValue:F,hasResolvedFairShareValue:ce,optimizedOrderEnabled:qt,optimizedOrderEligible:Jt,optimizedOrderConfig:Gt,marketImpactPct:Kt,optimizedWindowDays:we??7}},_d=`This order changed while you were authorizing. Review the updated total and authorize the wallet again.`,vd=450,yd=e=>e===Y.Shared||e===Y.External,bd=(e,t,n,r)=>{if(r||e.formState.dirtyFields.paymentCurrency||!t||!yd(t.type))return;let i=Lc(n,t.type,e.getValues(`paymentCurrency`));i&&e.setValue(`paymentCurrency`,i,{shouldDirty:!1,shouldValidate:!0})},xd=!0,Sd=function(e){return e[e.Closed=0]=`Closed`,e[e.Loading=1]=`Loading`,e[e.OrderOptions=2]=`OrderOptions`,e[e.Preview=3]=`Preview`,e[e.Optin=4]=`Optin`,e[e.Done=5]=`Done`,e}({}),Cd=[V.PendingKYC,V.PendingReview,V.Pending,V.Success],wd=[V.Canceled,V.Failed],Td=(e,t)=>e.isCreating?{title:`Creating your order...`}:e.isCommitting?{title:`Please manually open your External Wallet and sign this transaction within 60 seconds, otherwise your order will be cancelled.`}:e.isCanceling||e.canceled?{title:`This order is cancelled due to error or because you did not sign it with your External Wallet.`}:e.orderCreated?{title:t?`Thanks! You have signed the transaction and your order is submitted.`:`Your order is active`,subTitle:(0,$.jsxs)(`span`,{children:[`Your order will be filled if it can be matched. Payments and tokens are (1) always sent to your Lofty Wallet to guarantee delivery; and (2) taken from your lofty wallet at the time their is an available counterparty.\xA0`,(0,$.jsx)(`a`,{className:`text-lofty ml-1`,href:`/learn/articles/6516366-learn-how-to-trade-real-estate-in-lofty-s-marketplace`,target:`_blank`,rel:`noreferrer`,children:`Learn more`})]})}:{title:``},Ed=(e,t)=>({displayName:Tn(e.type)?(e.bankName??`Bank account`).toLowerCase():(au(e.brand)??`Card`).toLowerCase(),name:Tn(e.type)?`${e.bankName??`Bank Account`}:${e?.id}`.toLowerCase():`${au(e.brand)??`Credit Card`}:${e?.id}`.toLowerCase(),subtitle:Tn(e.type)?yt:``,number:(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`inline mr-1 sm:mr-2 whitespace-nowrap tracking-tighter sm:tracking-normal`,children:`• • • •`}),(0,$.jsx)(`span`,{children:e.last4})]}),symbol:e.id,type:e.type,billing_details:e.billing_details,fee:Tn(e.type)?En:bn(e.country),default:e.id===t.defaultPaymentMethod}),Dd={poll:!1,txnId:``,paymentType:q.None,skipAlgoTxn:!1,chargeConfirmed:!1},Od=()=>(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col min-h-[70vh] supports-[height:100dvh]:min-h-[70dvh] sm:min-h-[640px] animate-pulse overflow-hidden bg-white dark:bg-lofty-purple-700`,children:[(0,$.jsxs)(`div`,{className:`px-4 sm:px-5 pt-3 pb-2 flex items-center gap-2.5 border-b border-lofty-gray-300/40 dark:border-white/10`,children:[(0,$.jsx)(`div`,{className:`h-8 w-8 shrink-0 rounded-lg bg-lofty-gray-300 dark:bg-lofty-purple-500/30`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2`,children:[(0,$.jsx)(`div`,{className:`h-3.5 w-2/3 rounded bg-lofty-gray-300 dark:bg-lofty-purple-500/30`}),(0,$.jsx)(`div`,{className:`h-2.5 w-1/2 rounded bg-lofty-gray-300 dark:bg-lofty-purple-500/30`})]}),(0,$.jsx)(`div`,{className:`h-9 w-9 rounded-full bg-lofty-gray-300 dark:bg-lofty-purple-500/30`})]}),(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col gap-3 px-5 sm:px-6 pt-4 pb-4 bg-lofty-gray/30 dark:bg-lofty-purple-700`,children:[(0,$.jsx)(`div`,{className:`h-16 rounded-2xl bg-lofty-gray-300 dark:bg-lofty-purple-500/30`}),(0,$.jsx)(`div`,{className:`grid grid-cols-5 gap-1.5`,children:Array.from({length:5}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-14 rounded-xl bg-lofty-gray-300 dark:bg-lofty-purple-500/30`},t))}),(0,$.jsx)(`div`,{className:`h-24 rounded-2xl bg-lofty-gray-300 dark:bg-lofty-purple-500/30`}),(0,$.jsx)(`div`,{className:`h-20 rounded-2xl bg-lofty-gray-300 dark:bg-lofty-purple-500/30`}),(0,$.jsxs)(`div`,{className:`mt-auto rounded-2xl border border-lofty-gray-300/40 dark:border-white/10 p-4 space-y-3`,children:[(0,$.jsx)(`div`,{className:`h-3 w-32 rounded bg-lofty-gray-300 dark:bg-lofty-purple-500/30`}),(0,$.jsx)(`div`,{className:`h-3 w-full rounded bg-lofty-gray-300 dark:bg-lofty-purple-500/30`}),(0,$.jsx)(`div`,{className:`h-3 w-5/6 rounded bg-lofty-gray-300 dark:bg-lofty-purple-500/30`})]})]}),(0,$.jsxs)(`div`,{className:`bg-white dark:bg-lofty-purple-800 flex flex-col shrink-0 px-5 py-3 sm:px-6 sm:py-4 border-t border-lofty-gray-300/50 dark:border-white/10`,children:[(0,$.jsx)(`div`,{className:`h-12 rounded-2xl bg-lofty-gray-300 dark:bg-lofty-purple-500/30`}),(0,$.jsx)(`div`,{className:`mt-2 h-2.5 w-2/3 self-center rounded bg-lofty-gray-300 dark:bg-lofty-purple-500/30`})]})]}),kd=({isOpen:e,initialLimitPrice:t,onClose:n,property:r,orderBook:i,bestBuyPrice:a,bestSellPrice:o,startingPrice:c,requestOrderBook:l,refetchOrderBook:u,userOrderData:d,quantityOwned:f,isFirstInvestment:m,onSuccess:h})=>{let g=s(),v=te(),b=Fr(),x=S(),C=S(),w=S(),E=S(),D=(0,Q.useRef)({opToken:``,target:`TOTP.MarketplaceCancel`}),O=(0,Q.useRef)(!1),[A,j]=ee(Pa),re=_(Wt),N=_(k),P=y(k),ie=T(),ae=y(p),oe=ae.find(e=>e.shared)?.address,[se,ce]=(0,Q.useState)([]),[de,fe]=(0,Q.useState)(null),[F,pe]=(0,Q.useState)(Dd),[I,L]=(0,Q.useState)({poll:!1,batchId:``}),[he,ge]=(0,Q.useState)(0),[_e,ve]=(0,Q.useState)(!1),[ye,be]=(0,Q.useState)(`US`),xe=(0,Q.useRef)(null),R=(0,Q.useRef)(new Set),we=(0,Q.useRef)(!1),Te=(0,Q.useRef)(!1),De=(0,Q.useRef)(!1),Oe=(0,Q.useRef)(null),Ae=(0,Q.useRef)(!1),je=(0,Q.useRef)(0),Me=(0,Q.useRef)(!1),Ne=(0,Q.useRef)(!1),Pe=(0,Q.useRef)(!1),[U,Fe]=(0,Q.useState)({otp:null,modeRequired:Ee.None,error:null,mfaRequest:null,mfaCycleParameters:{parameters:null,retryAction:null}}),{isVerified:Ie}=v,[W,Le]=(0,Q.useState)({order:null,marketOrderValidation:null,marketOrderValidationQuantity:null,paymentIntentId:``,paymentMethods:(()=>{let e=st(ae,v.defaultPaymentMethod);return Ie?e:e.filter(e=>e.type!==Y.Shared)})(),balances:{giftBalance:0,availableRent:0},feeConfig:null,startingPrice:50,firstPurchaseCardFeeWaiverCap:0}),Re=(0,Q.useRef)(async()=>null),ze=(0,Q.useCallback)(e=>Re.current(e),[]),Be=(0,Q.useRef)(async()=>null),Ve=(0,Q.useCallback)(e=>Be.current(e),[]),He=(0,Q.useRef)(()=>void 0),Ue=(0,Q.useCallback)((e,t)=>He.current(e,t),[]),Ge={gift:De.current?void 0:W.balances.giftBalance,rent:Te.current?void 0:Oc(W.balances.availableRent,v.shouldWithhold,ke)},G=gd({quoteV2Buy:Ve,quoteV2Sell:ze,onV2DollarQuoteResolved:Ue,isEditing:e&&he===2&&!A.isCreating&&!A.orderCreated,direction:A.direction,startingPrice:c,initialLimitPrice:t,property:r,selectedMarket:A.selectedMarket,paymentMethods:W.paymentMethods,feeConfig:W.feeConfig,quantityOwned:f,userOrderData:d,marketOrderValidation:W.marketOrderValidation??W.order?.marketOrderValidation,marketOrderValidationQuantity:W.marketOrderValidation?W.marketOrderValidationQuantity:W.order?.marketOrderValidation?W.order?.quantity:W.marketOrderValidationQuantity,orderBook:i,bestBuyPrice:a,bestSellPrice:o,isFirstInvestment:m,smartRoutingEnabled:xd,firstPurchaseCardFeeWaiverCap:W.firstPurchaseCardFeeWaiverCap,v2DollarBalanceBudget:Ge}),Ke=G.form.setValue;(0,Q.useEffect)(()=>{!e||!t||t<=0||(Ke(`orderType`,Ce.Limit,{shouldDirty:!1,shouldValidate:!0}),Ke(`price`,H(t,2),{shouldDirty:!0,shouldValidate:!0}))},[t,e,Ke]);let qe=ne(G.quantity,350),Je=e=>e===he,Ye=()=>m&&!Nc(ae)?!0:G.isMarketOrder&&!Ic(ae,G.cryptoSubtotal,G.selectedCurrency),Xe=pt(r,1),Ze=A.direction===Se.Sell,$e=A.direction===Se.Buy,et=A.isCreating||A.isDryrunLoading||A.isCommitting||A.isAwaitingCommit||A.isCanceling,tt=$e&&G.limits.buyMax<=0||Ze&&G.limits.sellMax<=0,nt=$e&&G.isBalancePay&&!G.isPrimaryOrder,rt=G.v2DollarQuote.pending||!!G.v2DollarQuote.error,it=rt||G.v2FiatChargeBelowMinimum||!G.form.formState.isValid||G.quantity<=0||tt||$e&&!G.exchangeRate||et||!G.paymentMethod&&!nt||A.orderCreated,at=G.v2DollarTotalBudget!==void 0,ot=Cu({enabled:We.isProd&&e&&at&&v.
93isVerified&&!!G.kyc?.shared,editing:he===2&&!A.isCreating&&!A.orderCreated,contextKey:G.v2DollarQuoteContextKey,totalBudget:G.v2DollarTotalBudget??0,unitPrice:r.liquidity?.marketPrice.priceHigh??0,quantityMax:G.limits.buyMax,priceBuffer:wt.buy.buffer/100,giftCapacity:Ge.gift??G.useGift,rentCapacity:Ge.rent??G.useRent,autoGift:!De.current,autoRent:!Te.current,feeConfig:W.feeConfig,country:ye,waiverCap:W.firstPurchaseCardFeeWaiverCap,quote:Ve}),ct=at?ot.candidate:void 0,ut=at?ot.pending||!!ot.error||!ct:rt,ht=Il({isPrimaryOrder:G.isPrimaryOrder,isMarketOrder:G.isMarketOrder,hasAmmLiquidity:!!r.liquidity,hasValidatedMarketQuote:at?!!ct:!!G.marketOrderValidation,hasBookCoverage:!!G.noAmmMarketInfo}),vt=ct?.cashDueToday??G.paymentAmount,St=ct?.quantity??G.quantity,Ct=ct?.amount??Fl(G.paymentAmount,W.feeConfig,ye,W.firstPurchaseCardFeeWaiverCap),Tt=ct?.quoteKey??Ll({quantity:G.quantity,useRent:G.useRent,useGift:G.useGift,orderType:G.orderType,selectedMarket:A.selectedMarket}),{settled:Et,settling:kt}=xu((0,Q.useMemo)(()=>({eligible:ht,amount:Ct,cashDueToday:vt,quoteKey:Tt,quantity:St}),[ht,Ct,vt,Tt,St]),vd,ut),At=We.isProd&&$e&&v.isVerified&&Et.eligible,Nt=ut||!ht||kt||!at&&!G.form.formState.isValid||St<=0||tt||!G.exchangeRate||et||A.orderCreated;(0,Q.useEffect)(()=>{e&&console.info(`[Express Checkout] Eligibility evaluated`,{isBuyOrder:$e,isVerified:v.isVerified,isPrimaryOrder:G.isPrimaryOrder,isMarketOrder:G.isMarketOrder,hasAmmLiquidity:!!r.liquidity,hasLoftyWallet:!!oe,hasKycAsset:!!G.kyc?.shared,hasValidatedMarketQuote:!!G.marketOrderValidation,hasBookCoverage:!!G.noAmmMarketInfo,hasPotentialSmartRoute:!!G.potentialSmartRoute,amount:Ct,willRender:At})},[Ct,$e,e,oe,G.isMarketOrder,G.isPrimaryOrder,G.kyc?.shared,G.marketOrderValidation,G.noAmmMarketInfo,G.potentialSmartRoute,r.liquidity,At,v.isVerified]),(0,Q.useEffect)(()=>{if(!I.poll||!v.isAuth||!I.batchId)return;let e=!1,t,n=0,r=e=>{let t=I.batchId,n=e?.txn;return!t||!n||![V.Success,V.Failed].includes(n.status)?!1:(L({poll:!1,batchId:``}),n.status===V.Failed?(n.failureReasonCode===`pool_insufficient_liquidity`?hr.fire({title:`Not enough pool liquidity for this order`,html:[`<span>The liquidity pool for this property doesn't currently have enough USDC to fill your order at this size.`,`Try a smaller quantity, or place a limit order on the order book and wait for a buyer.`,`<br /><br />Transaction ID: ${t}</span>`].join(` `),showConfirmButton:!0,confirmButtonText:`Ok`}):hr.fire({title:`Market order did not complete successfully`,html:[`<span>Please reach out to support for help with the following information:`,`Transaction ID: ${t}`,`</span>`].filter(Boolean).join(`<br />`),showConfirmButton:!0,confirmButtonText:`Ok`}),j(e=>({...e,isCreating:!1,message:``})),!0):(j(e=>({...e,isCreating:!1,inProgress:!1,message:``})),ge(5),!0))},i=async()=>{try{let t=await lt({queryKey:[`loggedUser`,`poolBatchItemStatus`,{batchId:I.batchId,internal:G.isInternalPmmV2&&G.isSellOrder}]});if(e||r(t))return}catch(t){if(e)return;L({poll:!1,batchId:``}),hr.fire({text:`Market order failed with response: ${t.message}`}),j(e=>({...e,isCreating:!1,message:``}));return}if(e)return;n+=1;let a=Math.min(B.seconds(2)*1.08**n,B.seconds(5));t=setTimeout(i,a)};return i(),()=>{e=!0,t&&clearTimeout(t)}},[I.poll,I.batchId,v.isAuth,G.isInternalPmmV2,G.isSellOrder]);let Pt=A.isCanceling||A.isCommitting||A.isCreating?void 0:n,Ft=A.isCanceling||A.canceled?C.closeModal:A.orderCreated?()=>gn(!1):void 0,It=async e=>{if((e.code||e.token)&&e.AccessToken){let t={code:e.code??``,token:e.token??``},n={otp:t,AccessToken:e.AccessToken};Fe(e=>({...e,otp:t,mfaRequest:n}))}return await Promise.resolve(!0)},Lt=(e,t)=>{E.closeModal(),e||(C.closeModal(),Fe(e=>({...e,modeRequired:Ee.None,otp:null,mfaRequest:null,error:null})),j(e=>({...e,canceled:!0,orderCreated:!1,isCanceling:!1,isCommitting:!1,isAwaitingCommit:!1,isCreating:!1,closeReason:void 0,message:``})))},Rt=async()=>{if(Ae.current){Me.current=!0;return}Ae.current=!0;let e=++je.current;try{let[t,n]=await Promise.all([Ot(),Qe(r?.id)]);if(e!==je.current)return;Pe.current=Vc(t?.data??[]);let i=[...(t?.data??[]).map(e=>Ed(e,v)),...st(ae,v.defaultPaymentMethod)];i=Ie?i:i.filter(e=>e.type!==Y.Shared);let a=Hc(i,ae,{isMarketOrder:G.isMarketOrder,isSellOrder:Ze,hideWallet:Ye()});ce(t?.data??[]),!Ze&&mt(r.assetDecimals)&&xt().then(t=>{if(e!==je.current)return;let n=(t.data?.plans??[]).find(e=>e.propertyId===r.id&&(e.status===`active`||e.status===`paused`));fe(n??null)}
93).catch(()=>{}),Le(e=>({...e,balances:{...n.data.balances,availableRent:Math.max(0,n.data.balances?.availableRent??0)},paymentMethods:i,paymentIntentId:``,clientSecret:void 0,feeConfig:jt,startingPrice:n.data.startingPrice||50,receivingWallet:n.data.receivingWallet,receivingWalletAddress:n.data.receivingWalletAddress,optedIn:n.data.optedIn,firstPurchaseCardFeeWaiverCap:(n.data.firstPurchaseCardFeeWaiverCapCents??0)/100})),G.form.setValue(`paymentMethod`,a?.name??``,{shouldDirty:!1,shouldValidate:!0}),bd(G.form,a,ae,Ze),a&&J.trackEvent(`Property : Invest : Checkout : Payment Method : Chosen`,{...Gt(),payment_type:a.type,payment_type_is_saved:!0}),ge(2)}finally{e===je.current&&(Ae.current=!1,Me.current&&(Me.current=!1,Rt()))}},Bt=(e,t)=>{let n=e=>G.isFiatPay&&e!==0&&e<.5&&!(at&&_l(G.paymentMethod?.type));if(e===q.Gift?J.trackEvent(`Property : Invest : Checkout : Gift Balance : Changed`,{...Gt(),gift_balance_used:t}):e===q.Rent&&J.trackEvent(`Property : Invest : Checkout : Rent Balance : Changed`,{...Gt(),rent_balance_used:t}),e===q.Gift&&(n(H(G.subTotal-G.useRent-t,2,!1))?(G.form.setValue(`appliedGift`,H(G.totalUsdPrice-G.useRent-_t,2,!1)),mr.fire({icon:`warning`,title:Dt})):G.form.setValue(`appliedGift`,t)),e===q.Rent){let e=Oc(W.balances.availableRent,v.shouldWithhold,ke),r=kc(t,e);if(n(H(G.subTotal-G.useGift-r,2,!1))){let t=H(G.totalUsdPrice-G.useGift-_t,2,!1);G.form.setValue(`appliedRent`,kc(t,e)),mr.fire({icon:`warning`,title:Dt})}else G.form.setValue(`appliedRent`,r)}},Vt=(e,t)=>{if(e===q.Rent?Te.current=!0:e===q.Gift&&(De.current=!0),Bt(e,t),at&&_l(G.paymentMethod?.type)){let n=e===q.Gift?t:G.useGift,r=e===q.Rent?t:G.useRent,i=Math.max(0,H(G.subTotal-n-r,2,!0)),a=G.paymentMethod?.fee(i,W.feeConfig,W.firstPurchaseCardFeeWaiverCap)??0;i>0&&H(i+a,2,!0)<.5&&mr.fire({icon:`warning`,title:Dt})}},Ut=(e,t)=>{let n={displayName:Tn(e.type)?e.bankName??`Bank Account`:(au(e.brand)??`Credit Card`).toLowerCase(),name:Tn(e.type)?`${e.bankName??`Bank Account`}:${e.id}`:`${au(e.brand)??`Credit Card`}:${e.id}`.toLowerCase(),subtitle:Tn(e.type)?yt:``,number:(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`inline mr-1 sm:mr-2 whitespace-nowrap tracking-tighter sm:tracking-normal`,children:`• • • •`}),(0,$.jsx)(`span`,{children:e.last4})]}),symbol:e.id,type:e.type,billing_details:e.billing_details,fee:Tn(e.type)?En:bn(t??e.country),default:!1};G.form.setValue(`paymentMethod`,n.name,{shouldDirty:!0,shouldValidate:!0}),ce(t=>t.some(t=>t.id===e.id)?t:[...t,e]),Le(e=>({...e,paymentMethods:[...e.paymentMethods,n],selectedPaymentMethod:n})),J.trackEvent(`Property : Invest : Checkout : Payment Method : Chosen`,{...Gt(),payment_type:e.type,payment_type_is_saved:!0,is_new:!0,saved_payment_method_id:e.id})},Gt=()=>({...gt(r),quantity:G.quantity,rent_balance_used:G.useRent,rent_balance_available:H(W.balances.availableRent,2,!1),gift_balance_used:G.useGift,gift_balance_available:H(W.balances.giftBalance,2,!1),amount_due:G.finalTotal,selectedMarket:A.selectedMarket}),qt=()=>J.trackEvent(`Property : Invest : Terms of Service : Viewed`,Gt()),Yt=()=>({quantity:W.order?.quantity,value:(W.order?.quantity??1)*(W.order?.price??1),price:W.order?.price,hcPrice:Xe.totalPricePerToken,property:r.address,propertyId:r.id}),{previewOrder:Xt,executeOrder:Zt,processSecondaryPaymentStep:Qt,handleOptimizedOrder:$t,executeLiquidityPayment:en,validateMarketOrder:tn,quoteMarketBuy:nn,quoteMarketSell:rn,adoptMarketBuyQuote:an,discardMarketValidation:on,prewarmMarketQuotes:sn,reinvest:cn,setReinvest:ln}=ld({orderFormData:G,orderState:W,property:r,orderBook:i,refetchOrderBook:u,pollingData:F,setPollingData:pe,setCurrentStep:ge,getAnalyticsProperties:Gt,connectModalState:x,orderLoadingModalState:C,setAmmPollData:L,cancelToken:D,mfaState:U,setMfaState:Fe,setOrderState:Le});(0,Q.useLayoutEffect)(()=>{Be.current=nn,Re.current=rn,He.current=an},[nn,rn,an]),(0,Q.useLayoutEffect)(()=>{G.v2DollarQuote.active&&on()},[G.v2DollarQuote.active,on]),(0,Q.useEffect)(()=>{if(!G.v2DollarQuote.active){if(!e||!G.isMarketOrder||!r.liquidity||qe<=0||!G.kyc?.shared||!oe){tn({quantity:0,silent:!0,showLoading:!1});return}Je(2)&&tn({quantity:qe,silent:!0,showLoading:!1})}},[he,qe,G.v2DollarQuote.active,e,oe,G.isMarketOrder,G.kyc?.shared,r.liquidity]);let un=B.seconds(20),dn=G.orderType===Ce.Market;(0,Q.useEffect)(()=>
93{if(console.info(`[MarketQuote] warmer gates`,{modalOpen:e,isAuth:v.isAuth,isBuyOrder:$e,willOpenAsMarketBuy:dn,hasLiquidity:!!r.liquidity}),e||!v.isAuth||!$e||!dn||!r.liquidity)return;let t=async()=>{if(!document.hidden){if(r.liquidity?.pmmVersion===`v2`){let e=G.limits.buyMax||r.liquidity.baseStaked||0,t=Math.min(e,r.liquidity.baseStaked??e);if(t>0){let{marketPrice:e,poolId:n}=r.liquidity,i=Math.floor(t*e.priceHigh*100)/100,a=[Math.min(100,i)];await Promise.all(Array.from(new Set(a)).filter(e=>e>0).map(r=>Ol({budget:r,unitPrice:e.priceHigh,quantityMax:t,contextKey:`${v.id}:${n}`,maxAgeMs:B.seconds(5),quote:e=>nn(e,B.seconds(5))}).catch(()=>void 0)))}}else await sn([1,2],{maxAgeMs:B.seconds(5),sell:!1});f>0&&await sn([1],{maxAgeMs:B.seconds(5),sell:!0})}},n=()=>{!document.hidden&&r.liquidity?.pmmVersion===`v2`&&t()};document.addEventListener(`visibilitychange`,n),t();let i=setInterval(()=>{t()},un);return()=>{clearInterval(i),document.removeEventListener(`visibilitychange`,n)}},[e,v.isAuth,$e,dn,r.liquidity,f,v.id,G.limits.buyMax]);let fn=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{if(fn.current||G.isInternalPmmV2||!e||!G.isMarketOrder||!r.liquidity||!G.kyc?.shared||!oe||!Je(2))return;let t=G.quantity;t>0&&W.marketOrderValidationQuantity!==t||(fn.current=!0,sn([1,2],{sell:Ze}))},[he,e,$e,oe,G.isMarketOrder,G.kyc?.shared,G.quantity,G.isInternalPmmV2,W.marketOrderValidationQuantity,r.liquidity]);let pn=async e=>{if(e&&xe.current!==e&&!R.current.has(e)){xe.current=e,pe(Dd);try{await en(e)&&R.current.add(e)}finally{xe.current===e&&(xe.current=null)}}},mn=(0,Q.useRef)({isMarketOrder:G.isMarketOrder,receivingWallet:W.receivingWallet,optedIn:W.optedIn,orderMessage:A.message,algoContext:b,executeLiquidityPaymentOnce:pn});mn.current={isMarketOrder:G.isMarketOrder,receivingWallet:W.receivingWallet,optedIn:W.optedIn,orderMessage:A.message,algoContext:b,executeLiquidityPaymentOnce:pn},(0,Q.useEffect)(()=>{if(!F.poll||!v.isAuth||!F.txnId)return;let e=!1,t,n=0,r=F.txnId,i=F.skipAlgoTxn,a=async()=>{try{let t=await ft({queryKey:[`loggedUser`,`paymentStatus`,{id:r}]});if(e)return;let{isMarketOrder:n,receivingWallet:a,optedIn:o,orderMessage:s,algoContext:c,executeLiquidityPaymentOnce:l}=mn.current;if(t&&Cd.includes(t.status)){if(!n){let e=a===Y.External&&!o;ge(e?4:5),pe(Dd),j(e=>({...e,isCreating:!1,inProgress:!1,message:``}));return}if(i){await l(r);return}if(t.algoPmtTxnId){let n=await c.waitForTransaction(t.algoPmtTxnId);if(e)return;if(n){await l(r);return}}}else if(t&&wd.includes(t.status)){pe(Dd);let e=K(t);hr.fire({title:e?`Your payment didn't go through`:`The transaction did not complete successfully`,html:[...e?[`<span>${e}</span>`,`&nbsp;`]:[],`<span>Please reach out to support for help with the following information:`,`Transaction ID: ${r}`,s,`</span>`].filter(Boolean).join(`<br />`),showConfirmButton:!0,confirmButtonText:`Ok`}),j(e=>({...e,isCreating:!1,message:``}));return}}catch(e){console.error(`PlaceOrderModal::paymentStatus poll`,e)}if(e)return;n+=1;let o=Math.min(B.seconds(2)*1.08**n,B.seconds(5));t=setTimeout(a,o)};return a(),()=>{e=!0,t&&clearTimeout(t)}},[F.poll,F.txnId,F.skipAlgoTxn,v.isAuth]);let hn=B.seconds(1);(0,Q.useEffect)(()=>{if(G.isInternalPmmV2&&G.isSellOrder&&G.isMarketOrder)return;let e=W.receivingWallet===Y.External,t=F.poll&&!!F.txnId&&!G.isMarketOrder&&!e,n=F.poll&&!!F.txnId&&!!F.chargeConfirmed&&G.isMarketOrder&&$e&&!!r.liquidity&&!e,i=I.poll&&!!I.batchId&&!e;if(!t&&!i&&!n||!v.isVerified)return;let a=setTimeout(()=>{let e=i?{kind:`ammBatch`,batchId:I.batchId}:n?{kind:`marketSwap`,txnId:F.txnId,skipAlgoTxn:!!F.skipAlgoTxn,poolId:r.liquidity.poolId,swapQuantity:W.ammLeg?.quantity??G.quantity,swapMaxPayMicroUsdc:H((W.ammLeg?.cryptoSubtotal??G.cryptoSubtotal)*1e6,0,!1),paymentIntentId:W.paymentIntentId||void 0}:{kind:`payment`,txnId:F.txnId};i?L({poll:!1,batchId:``}):(e.kind===`marketSwap`&&R.current.add(F.txnId),pe(Dd)),O.current=!0;let t=A.direction===Se.Sell,a=t?Math.max(0,f-G.quantity):void 0,o=P.userSummary.totals.totalCurrentTokens??0,s=A.direction===Se.Buy&&!G.isOptimizedOrder?(P.userSummary.totals.totalPendingTokens??0)+G.quantity:void 0;t&&typeof a==`number`&&N(e=>Ht(e,r.id,a)),re(t=>[...t,{clientId:`${Date.now()}-${Math.round(Math.random()*1e6)}`,...e,propertyId:r.id,propertyLabel:r.address_line1||r.address||`your order`,direction:A.direction,quantity:G.quantity,expectedCurrentTokensAfterFill:a,expectedMinPendingTokens:s,preTradeTotalCurrentTokens:A.direction===Se.Buy?o:void 0,submittedAt:Date.now()}]),ge(5)},hn);return()=>clearTimeout(a)},[F.poll,F.txnId,F.chargeConfirmed,I.poll,I.batchId,G.isMarketOrder,G.isInternalPmmV2,G.isSellOrder,W.receivingWallet,v.isVerified]);let gn=async(e=!0)=>{let{orderId:t,propertyId:n}=A;if(e){if(t&&n){j(e=>({...e,isCanceling:!0,isCreating:!1,isCommitting:!1,isAwaitingCommit:!1,message:``}));let e=await Au({propertyId:n,orderId:t,reason:dt.USER_SIGN_CANCEL,mfaRequest:D.current});if(!e.canceled){mr.fire({...Pu(e),timer:1e4}),j(r=>({...r,...ju(e,{orderId:t,propertyId:n})}));return}}}else C.closeModal();j(r=>({...r,orderId:t,propertyId:n,canceled:e,orderCreated:!e,inProgress:e,isCanceling:!1,isCommitting:!1,isAwaitingCommit:!1,isCreating:!1,closeReason:e?void 0:`user_request`,message:``}))},_n=(0,Q.useRef)(!1),vn=(0,Q.useRef)(!1),yn=(0,Q.useRef)(!1),xn=(0,Q.useRef)(null),Sn=()=>{xn.current=null,Le(e=>e.v2ExpressApproval?{...e,v2ExpressApproval:null}:e)},Cn=async(e=!1)=>
93{if(!it){if(!e&&W.v2ExpressApproval){yn.current=!0,Sn();return}if(v.email){if(!v.isVerified){J.trackEvent(`Property : Invest : Verify : Prompted`,Gt()),jr(r.slug),g(`/verify-identity`);return}if(!Je(3)||!W.order)return vn.current=!0,J.trackEvent(Du(A.direction,`Preview`),Yt()),await G.form.handleSubmit(Xt)();_n.current||(_n.current=!0,Zt().finally(()=>{_n.current=!1}))}}};(0,Q.useEffect)(()=>{yn.current&&!W.v2ExpressApproval&&(yn.current=!1,e&&Cn())},[W.v2ExpressApproval,e]);let Dn=(e,t,n)=>{let r=[v.firstName,v.lastName].map(e=>typeof e==`string`?e.trim():``).filter(Boolean).join(` `),i=typeof e.billing_details?.name==`string`?e.billing_details.name.trim():``;if(i&&r&&!Eu(i,r))return Sn(),mr.fire({icon:`error`,title:wu}),{accepted:!1,message:wu};let a=i||!r?e:{...e,billing_details:{...e.billing_details??{},name:r}},o=at?ot.authorize(a.country,n):void 0,s=Fl(vt,W.feeConfig,a.country,W.firstPurchaseCardFeeWaiverCap),c=ht&&(at?o?.accepted:!rt&&n.quoteKey===Tt&&Bl(n.amountInCents,s));if(Ut(a,a.country),!c){be(a.country||`ZZ`),Sn();let e=!(o&&!o.accepted&&o.reason===`fee`)&&Pl(s)===Pl(Ct)?_d:`Your wallet card has a different processing fee. Review the updated total and authorize the wallet again.`;return mr.fire({icon:`info`,title:e}),{accepted:!1,message:e}}if(o?.accepted){let{quantity:e,quote:t,useGift:r,useRent:i}=o.candidate;Ue(e,t),G.form.setValue(`tokenQuantity`,e,{shouldDirty:!0,shouldValidate:!0}),G.form.setValue(`appliedGift`,r,{shouldValidate:!0}),G.form.setValue(`appliedRent`,i,{shouldValidate:!0}),Le(t=>({...t,v2ExpressApproval:{contextKey:G.v2DollarQuoteContextKey,totalBudget:o.candidate.totalBudget,quantity:e,useGift:r,useRent:i,maxTotalUsd:H(n.amountInCents/100+r+i,2,!0)}}))}return J.trackEvent(`Property : Invest : Checkout : Express Wallet : Authorized`,{...Gt(),payment_type:q.Card,express_payment_type:t}),xn.current={paymentMethodId:a.id,quoteKey:n.quoteKey,authorizedAmountInCents:n.amountInCents,v2Approval:o?.accepted?{totalBudget:o.candidate.totalBudget,contextKey:G.v2DollarQuoteContextKey,quantity:o.candidate.quantity,useGift:o.candidate.useGift,useRent:o.candidate.useRent}:void 0},{accepted:!0}};(0,Q.useEffect)(()=>{let t=xn.current;if(t){if(!e){xn.current=null,Le(e=>e.v2ExpressApproval?{...e,v2ExpressApproval:null}:e);return}if(t.v2Approval){let e=t.v2Approval;if(e.contextKey!==G.v2DollarQuoteContextKey||e.totalBudget!==G.v2DollarTotalBudget){Sn(),mr.fire({icon:`info`,title:_d});return}if(rt||ut)return;if(G.quantity!==e.quantity||G.useGift!==e.useGift||G.useRent!==e.useRent||!Bl(t.authorizedAmountInCents,G.finalTotal)||Pl(G.subTotal+G.processingFee)>t.authorizedAmountInCents+Pl(e.useGift+e.useRent)){Sn(),mr.fire({icon:`info`,title:_d});return}}if(!A.isDryrunLoading){if(!ht||t.quoteKey!==Tt){Sn(),mr.fire({icon:`info`,title:_d});return}if(!Bl(t.authorizedAmountInCents,Ct)){Sn(),mr.fire({icon:`info`,title:_d});return}if(G.paymentMethod?.symbol&&G.paymentMethod.symbol!==t.paymentMethodId){Sn();return}G.paymentMethod?.symbol===t.paymentMethodId&&(it||(xn.current=null,Cn(!0)))}}},[G.paymentMethod?.symbol,it,ht,Tt,Ct,A.isDryrunLoading,e,rt,ut,G.quantity,G.useGift,G.useRent,G.finalTotal,G.subTotal,G.processingFee,G.v2DollarQuoteContextKey,G.v2DollarTotalBudget]),(0,Q.useEffect)(()=>{he===3&&vn.current&&(_n.current||W.order&&(A.isDryrunLoading||(vn.current=!1,_n.current=!0,Zt().finally(()=>{_n.current=!1}))))},[he,W.order,A.isDryrunLoading]);let On=()=>{J.trackEvent(`Property : Invest : Dao Agreement : Signed`,{quantity:W.order?.quantity,value:(W.order?.quantity??1)*(W.order?.price??1),price:W.order?.price,hcPrice:Xe.totalPricePerToken,property:r.address,propertyId:r.id}),w.closeModal(),Zt()};(0,Q.useEffect)(()=>{v.isAuth&&e&&(Ne.current||ge(1),Ne.current=!0,Rt()),e||(Ne.current=!1,Me.current=!1,je.current+=1,Ae.current=!1,ge(0),C.closeModal(),Fe({otp:null,modeRequired:Ee.None,error:null,mfaRequest:null,mfaCycleParameters:{parameters:null,retryAction:null}}),G.form.resetField(`paymentMethod`,{defaultValue:``}),_n.current=!1,vn.current=!1,yn.current=!1,xn.current=null,be(`US`),xe.current=null,R.current.clear(),fn.current=!1,we.current=!1,Te.current=!1,De.current=!1,ve(!1),Le(e=>({...e,order:null,v2ExpressApproval:null,v2DollarApproval:null,marketOrderValidation:null,marketOrderValidationQuantity:null,paymentIntentId:``,clientSecret:void 0})))},[v.isAuth,e,G.orderType]),(0,Q.useEffect)(()=>{v.isAuth&&e&&J.trackEvent(Du(A.direction,`Started`),{quantity:G.quantity,value:G.quantity*G.pricePerToken,price:G.pricePerToken,hcPrice:Xe.totalPricePerToken,property:r.address,propertyId:r.id})},[v.isAuth,e]),(0,Q.useEffect)(()=>{!e||we.current||wn(v.defaultPaymentMethod)&&(we.current=!0,ve(!0))},[e,v.defaultPaymentMethod]),(0,Q.useEffect)(()=>{U.modeRequired!==Ee.None&&(U.mfaRequest&&U.mfaCycleParameters.retryAction===`optimized`?$t():U.mfaRequest&&U.mfaCycleParameters.parameters?Qt(U.mfaCycleParameters.parameters):!E.isModalOpen&&E.openModal())},[U.modeRequired,U.mfaRequest]);let kn=H(Math.max(0,G.subTotal-G.useRent-G.useGift),2,!1),An=G.paymentType===q.Card?`Card`:[q.Bank,q.NewBank].includes(G.paymentType)?`Bank`:G.paymentType===q.Crypto&&G.paymentMethod?.type===Y.External?`Exter
93nal Wallet`:`Lofty Wallet`;(0,Q.useEffect)(()=>{let e=Je(5),t=v.isVerified;if(e&&t){let e=O.current;O.current=!1;let t=P.userSummary.totals.totalCurrentTokens??0,i=G.isBuyOrder&&!G.isOptimizedOrder?(P.userSummary.totals.totalPendingTokens??0)+G.quantity:void 0;if(typeof i==`number`&&N(e=>Kt(e,i)),!e){let e=r.id,n=Math.max(0,f-G.quantity),a=!G.isBuyOrder&&G.isMarketOrder,o=typeof i==`number`;ie(a||o?{reconcileSummary:r=>{let s=r;return a&&(s=Ht(s,e,n)),o&&(s=Jt(s,i,t)),s}}:void 0)}let a=G.isBuyOrder&&(G.isPrimaryOrder||G.isMarketOrder),o=!!m&&a;o&&v.email&&me(v.email);let s=[q.Bank,q.NewBank].includes(G.paymentType);a&&!s&&v.email&&M({account:v.email,expectsGift:o,tokensBefore:t,propertiesBefore:P.userSummary.summaries.length,giftBefore:P.userSummary.totals?.balances?.gift?.balance??0,expectedQuantity:G.quantity});let c=wc(G),l=c?.fees??G.platformFee+ac(G.feesData),u=G.isBuyOrder?1:-1,d=r.address_line1||r.address,p=r.address_line2?.split(`,`)[0]||r.address_line2,g={address:p?`${d} in ${p}`:d,thumbnail:r.thumbnail,propertyUrl:r.slug?`${window.location.origin}/property_deal/${r.slug}`:``,isPrimaryOrder:G.isPrimaryOrder,paymentType:G.paymentType,direction:A.direction,orderType:G.orderType,wasFirstPurchase:o,orderSummary:{quantity:G.quantity,pricePerToken:c?.pricePerToken??G.pricePerToken,total:G.isInternalPmmV2?G.subTotal+(G.isWalletPayment?0:G.processingFee)*u:G.totalUsdPrice+l*u,fees:l,priceBuffer:G.isInternalPmmV2?G.priceBuffer:0,isInternalPmmV2:G.isInternalPmmV2},paymentBreakdown:{rent:H(G.useRent,2,!1),gift:H(G.useGift,2,!1),primary:kn,primaryLabel:An}};J.trackEvent(`Property : Invest : Success : Landed`,Gt());let _=G.paymentMethod,y=_?.symbol,b=_?.type===Y.Card,x=G.isGiftPay||G.isRentPay;y&&b&&!x&&!Pe.current&&v.defaultPaymentMethod!==y&&bt({paymentId:y}).catch(e=>{Mt(e,`PlaceOrderModal::saveDefaultPaymentAfterOrder`,{usedPaymentSymbol:y,paymentType:_?.type})}),h(g),n()}},[he]),(0,Q.useEffect)(()=>{let t=[...se.map(e=>Ed(e,v)),...st(ae,v.defaultPaymentMethod)];if(t=Ie?t:t.filter(e=>e.type!==Y.Shared),Le(e=>({...e,paymentMethods:t})),e&&!rt&&!G.form.formState.dirtyFields.paymentMethod){let e=Hc(t,ae,{isMarketOrder:G.isMarketOrder,isSellOrder:Ze,hideWallet:Ye()});G.form.getValues(`paymentMethod`)!==e?.name&&(G.form.setValue(`paymentMethod`,e?.name??``,{shouldDirty:!1,shouldValidate:!0}),e&&J.trackEvent(`Property : Invest : Checkout : Payment Method : Chosen`,{...Gt(),payment_type:e.type,payment_type_is_saved:!0}
93)),bd(G.form,e,ae,Ze)}},[ae,se,e,Ie,Ze,m,G.isMarketOrder,G.form,v.defaultPaymentMethod,rt]),(0,Q.useLayoutEffect)(()=>{if(Oe.current!==A.direction&&(Oe.current=A.direction,Te.current=!1,De.current=!1),$e&&!Je(3)){let e=G.subTotal;if(at){let t=G.allocateV2BuyBalances(e),n=G.form.getValues(`appliedGift`),r=G.form.getValues(`appliedRent`);(!De.current||n>t.useGift)&&Bt(q.Gift,t.useGift),(!Te.current||r>t.useRent)&&Bt(q.Rent,t.useRent);return}let{giftBalance:t,availableRent:n}=W.balances,r=H(e,2,!1),i=0;if(De.current?i=Math.min(G.useGift,r):(i=Math.min(t,r),Bt(q.Gift,H(i,2,!1))),r-=i,!Te.current){let e=Oc(n,v.shouldWithhold,ke),t=Math.max(0,Math.min(e,r));Bt(q.Rent,H(t,2,!1))}}else Ze&&(Bt(q.Gift,H(0,2,!1)),Bt(q.Rent,H(0,2,!1)))},[G.quantity,W.balances,G.subTotal,A.direction,G.orderType,G.isMarketOrder,at,at?G.paymentMethod:null,at?W.firstPurchaseCardFeeWaiverCap:null]);let jn=W.order?.paymentMethod===Y.External;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ue,{id:`wallet-send-2fa-code-verify`,isOpen:E.isModalOpen,zIndexBase:35,showCloseBtn:!1,fullScreen:!0,className:{container:`border-none max-w-md pb-6 sm:pb-0`,containerColors:`bg-white dark:bg-lofty-purple-800 border-slate-200 dark:border-lofty-purple-800 text-slate-700 dark:text-lofty-gray`},minHeight:`auto`,children:(0,$.jsx)(le,{mode:`verify`,verifyMode:U.modeRequired,operation:`TOTP.WalletWithdrawal`,authUser:v.authUser,isVisible:E.isModalOpen,errorMessage:U.error,isLoading:!1,onCancel:Lt,onComplete:e=>Lt(!0,e?.opToken),onRequestConfirm:It})}),(0,$.jsx)(ue,{id:`placeOrderModal`,isOpen:e,zIndexBase:35,onBackdropClick:Pt,onRequestClose:Pt,className:{container:[`border-none w-full`,`sm:w-[600px] sm:max-h-[96vh] sm:supports-[height:100dvh]:max-h-[96dvh]`,`lg:w-[640px]`].join(` `),containerColors:`bg-white dark:bg-lofty-purple-700 border-white dark:border-lofty-purple-700 text-lofty-purple-600 dark:text-white`,content:`m-0 p-0 flex flex-col flex-1 min-h-0`,overflow:`hidden`},minHeight:`auto`,showCloseBtn:!1,children:(0,$.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0`,children:[(0,$.jsx)(In,{isOpen:x.isModalOpen,zIndexBase:35,wallets:ae.filter(e=>!e.shared),onClose:x.closeModal,onSuccess:x.closeModal,mode:Gn.ConnectWallet,isMarketOrder:G.isMarketOrder}),(0,$.jsx)(nr,{isOpen:_e,zIndexBase:36,onClose:()=>ve(!1),onAddBank:()=>{ve(!1),n(),g(`/account/wallet`)}}),(0,$.jsx)(qn,{propertyInfo:r,isOpen:w.isModalOpen,onSigned:On}),(0,$.jsx)(Nl,{contents:Td(A,jn),duration:61*1e3,isOpen:C.isModalOpen,zIndexBase:35,showLoader:A.isCreating||A.isCommitting||A.isAwaitingCommit,timerEnabled:A.isCommitting||A.isAwaitingCommit,onClose:Ft,onComplete:gn},A.attemptId),Je(0)||Je(1)?(0,$.jsx)(Od,{}):(0,$.jsxs)($.Fragment,{children:[Je(4)&&(0,$.jsx)(ru,{assetName:r.assetName,assetId:r.assetId,assetUnit:r.assetUnit,thumbnail:r.thumbnail,note:`txnId:${F.txnId}`,walletAddress:W.receivingWalletAddress??``,onClose:()=>ge(5),onComplete:()=>ge(5),analyticsProperties:Gt()}),!Je(4)&&(0,$.jsxs)(`div`,{className:`bg-white dark:bg-lofty-purple-700 relative flex flex-col flex-1 min-h-0 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`px-5 sm:px-6 pt-4 pb-3.5 sm:pt-5 sm:pb-4 flex items-center gap-3.5 border-b border-lofty-gray-300/40 dark:border-white/10`,children:[(0,$.jsx)(`div`,{className:`h-12 w-12 sm:h-14 sm:w-14 shrink-0 rounded-xl overflow-hidden bg-lofty-gray-200 dark:bg-lofty-purple-600 ring-1 ring-black/5 dark:ring-white/10 flex items-center justify-center shadow-sm`,children:r.thumbnail?(0,$.jsx)(`img`,{src:r.thumbnail,alt:r.address_line1||r.address,className:`h-full w-full object-cover`,onError:e=>{e.currentTarget.style.display=`none`}}):(0,$.jsx)(`i`,{className:`fas fa-home text-base text-lofty-gray-700/70 dark:text-white/60`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`h1`,{className:`text-base sm:text-lg leading-tight text-lofty-purple-600 dark:text-white font-bold truncate`,children:r.address_line1||r.address}),r.address_line2&&(0,$.jsx)(`p`,{className:`text-xs sm:text-sm leading-tight text-lofty-gray-700 dark:text-white/55 truncate mt-1`,children:r.address_line2})]}),(0,$.jsx)(`button`,{type:`button`,onClick:Pt,disabled:!Pt,"aria-label":`Close`,className:`w-9 h-9 flex items-center justify-center rounded-full text-lofty-purple-600/70 dark:text-white/60 hover:text-lofty-purple-600 dar
93k:hover:text-white hover:bg-lofty-purple/[0.08] dark:hover:bg-white/[0.08] active:scale-95 disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent transition-all`,children:(0,$.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:(0,$.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M6 18L18 6M6 6l12 12`})})})]}),(0,$.jsx)(`div`,{className:`flex flex-1 flex-col min-h-0 px-5 sm:px-6 pt-2 pb-4 overflow-y-auto overscroll-contain dao-agreement-scrollbar bg-lofty-gray/30 dark:bg-lofty-purple-700`,style:{scrollbarGutter:`stable both-edges`},children:(0,$.jsx)(`div`,{className:`flex flex-1`,children:(Je(2)||Je(3))&&(0,$.jsx)($c,{property:r,direction:A.direction,bestBuyPrice:a,bestSellPrice:o,startingPrice:c,feesData:G.feesData,orderFormData:G,reinvest:cn,setReinvest:ln,paymentMethods:W.paymentMethods,selectedPaymentMethod:G.paymentMethod,addPaymentMethod:Ut,requestOrderBook:l,orderBook:i,sellMax:G.limits.sellMax,buyMax:G.limits.buyMax,suggestedBuy:G.limits.suggestedBuy,selectedMarket:A.selectedMarket,buyFundsAvailable:G.buyFundsAvailable,useBalances:{gift:W.balances.giftBalance,rent:W.balances.availableRent,appliedGift:G.useGift,appliedRent:G.useRent,totalPrice:G.totalUsdPrice,onAddBalance:Vt},currentStep:he,isFirstInvestment:m,existingRecurringPlan:de})})}),(0,$.jsxs)(`div`,{className:`bg-white dark:bg-lofty-purple-800 flex flex-col shrink-0 px-5 py-3 sm:px-6 sm:py-4 text-lofty-gray-700 border-t border-lofty-gray-300/50 dark:border-white/10`,children:[At&&(0,$.jsx)(nu,{amount:Et.amount,cashDueToday:Et.cashDueToday,orderLabel:Rl(Et.quantity,r.address_line1||r.address,at),disabled:Nt,quoteKey:Et.quoteKey,beforeAuthorize:at?ot.ready:void 0,onPaymentMethod:Dn}),(0,$.jsx)(`button`,{type:`submit`,onClick:()=>{Cn()},className:[`group relative w-full overflow-hidden rounded-2xl px-6 py-3.5 text-white font-semibold text-base`,`shadow-[0_8px_24px_rgba(77,63,237,0.35)] hover:shadow-[0_10px_28px_rgba(77,63,237,0.45)]`,`active:scale-[0.99] transition-all`,`flex items-center justify-center gap-2`,`disabled:opacity-50 disabled:cursor-not-allowed disabled:shadow-none`,$e?`bg-gradient-to-r from-lofty to-lofty-purple hover:brightness-110`:`bg-gradient-to-r from-lofty-purple-600 to-lofty hover:brightness-110`].join(` `),disabled:it,"aria-busy":G.v2DollarQuote.pending,"aria-label":G.v2DollarQuote.pending?`Updating quote`:void 0,children:rt?G.v2DollarQuote.error?(0,$.jsx)(`span`,{children:`Quote unavailable`}):(0,$.jsx)(zt,{className:`h-5 w-5`}):et?(0,$.jsxs)(`span`,{className:`flex items-center justify-center gap-2`,children:[(0,$.jsx)(zt,{className:`h-5 w-5 inline`}),(0,$.jsxs)(`span`,{className:`text-white text-sm`,children:[A.isCreating&&(0,$.jsx)(Yn,{label:`Submitting`}),A.isDryrunLoading&&(0,$.jsx)(Yn,{label:`Validating`}),(A.isCommitting||A.isAwaitingCommit)&&(0,$.jsx)(Yn,{label:`Committing to escrow`})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`flex items-baseline gap-2`,children:(()=>{let e=G.quantity,t=$e?`Buy`:`Sell`,n=e===1?`share`:`shares`,r=G.finalTotal,i=G.useRent+G.useGift>0,a=z(r,{minimumFractionDigits:2});return $e?hc(r)?(0,$.jsxs)(`span`,{children:[t,` `,e,` `,n,` · `,(0,$.jsx)(`span`,{className:`font-bold tabular-nums`,children:`$0 cash today`})]}):i?(0,$.jsxs)(`span`,{children:[t,` `,e,` `,n,` · `,(0,$.jsx)(`span`,{className:`font-bold tabular-nums`,children:a}),` cash today`]}):(0,$.jsxs)(`span`,{children:[t,` `,e,` `,n,` · `,(0,$.jsx)(`span`,{className:`font-bold tabular-nums`,children:a})]}):(0,$.jsxs)(`span`,{children:[t,` `,e,` `,n,` · receive `,(0,$.jsx)(`span`,{className:`font-bold tabular-nums`,children:a})]})})()}),(0,$.jsx)(`i`,{className:`fas fa-arrow-right text-xs ml-1 transition-transform group-hover:translate-x-0.5`})]})}),(0,$.jsxs)(`p`,{className:`mt-2 text-center text-[10px] leading-snug text-lofty-gray-700/75 dark:text-white/45`,children:[G.isLimitOrder&&!G.isPrimaryOrder&&`Cancel anytime before fill. `,`By submitting you agree to Lofty's`,` `,(0,$.jsx)(`a`,{onClick:qt,href:`/terms`,target:`_blank`,className:`underline`,rel:`noreferrer`,children:`Terms`}),`.`]})]})]})]})]})})]})},Ad=e=>{if(e.get(`orderType`)!==`limit`)return null;let t=e.get(`trade`),n=t===`buy`?Se.Buy:t===`sell`?Se.Sell:null,r=Number(e.get(`price`));return!n||!Number.isFinite(r)||r<=0?null:{direction:n,price:r}},jd=e=>{let t=Array.isArray(e.groupItems)?e.groupItems:null;return t?t.reduce((e,t)=>
93(e.push(...t.images),e),[]):e.images??[]};function Md({orderBook:e,userOrderData:t,onOrderCanceled:n,refetchOrderBook:r,onTradingDataRefresh:i}){let a=i,{currentProperty:o,currentPropertyInfo:s}=La(),c=E(),[l,d]=(0,Q.useState)(!1),f=c.minWidth>=re.lg,m=!l||f,{isComingSoon:h,isSold:g}=D(o),{isAuth:_,email:v}=te(),{userSummary:b,isFirstInvestment:x,getSummaryListing:C}=A(),w=S(),T=S(),O=y(p),[k,j]=ee(Pa),[ne,M]=u(),N=Ad(ne),P=(0,Q.useRef)(!1),ie=(0,Q.useRef)(null),[ae,oe]=(0,Q.useState)(!1),[se,ce]=(0,Q.useState)(!1),[le,ue]=(0,Q.useState)(N),de=(0,Q.useMemo)(()=>jd(o),[o]),[fe,F]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{d(!0)},[]);let I=()=>{j(Na)},L=()=>{ue(null),w.closeModal(),I()},me=e=>{F(e),i?.()},he=()=>{let e=fe?.wasFirstPurchase;F(null),!(!e||!v)&&pe(v)};(0,Q.useEffect)(()=>{if(!l||!N||P.current)return;let e=ie.current;if(!e)return;P.current=!0,ue(N),e(N.direction);let t=new URLSearchParams(ne);t.delete(`trade`),t.delete(`orderType`),t.delete(`price`),M(t,{replace:!0})},[l,N,ne,M]),(0,Q.useEffect)(()=>{k.inProgress?w.openModal():w.closeModal()},[k.inProgress,k.closeReason]),(0,Q.useEffect)(()=>{!w.isModalOpen&&k.inProgress&&L()},[w.isModalOpen]),(0,Q.useEffect)(()=>{T.isModalOpen&&oe(!0)},[T.isModalOpen]),(0,Q.useEffect)(()=>{w.isModalOpen&&ce(!0)},[w.isModalOpen]);let ge=kn({property:o,orderBook:e,propertyInfo:s,isComingSoon:h,isSold:g}),_e=O.some(e=>e.shared&&e.defaultWallet)||!!t?.kyc?.external,ve=C(o.id)?.currentTokens??0,be=or(O,o),xe=ve>0?ve:be,R=b.summaries.find(e=>e.propertyId===o.id)?.hasSignedDaoAgreement??!1,Se=s?.secondaryEnabled===!1,z=Da(async()=>{let e=await ye(o.id);return Array.isArray(e?.data)?e.data:[]},{enabled:!!o.id,deps:[o.id]}).data??[],Ce=Da(async()=>{let e=await Ie(o.id);return Array.isArray(e?.data)?e.data:[]},{enabled:!!o.id,deps:[o.id]}).data??[],we=(0,Q.useMemo)(()=>z.length===0?s?.coc??o.coc??0:z.reduce((e,t)=>e+t.y,0)/z.length,[o.coc,s?.coc,z]);return(0,$.jsxs)($.Fragment,{children:[(ae||T.isModalOpen)&&(0,$.jsx)(Ys,{property:o,orderBook:e,pricing:ge,propertyInfo:s,isOpen:T.isModalOpen,onClose:T.closeModal}),(se||w.isModalOpen)&&(0,$.jsx)(kd,{hasSignedDao:R,isFirstInvestment:x,isOpen:w.isModalOpen,initialLimitPrice:le?.price,onClose:L,property:o,orderBook:e,bestBuyPrice:ge.bestBuyPrice,bestSellPrice:ge.bestSellPrice,startingPrice:ge.startingPrice,requestOrderBook:T.openModal,refetchOrderBook:r,quantityOwned:xe,userOrderData:t,onSuccess:me}),fe&&(0,$.jsx)(Br,{isOpen:!0,address:fe.address,thumbnail:fe.thumbnail,targetUrl:fe.propertyUrl,isPrimaryOrder:fe.isPrimaryOrder,paymentType:fe.paymentType,direction:fe.direction,orderType:fe.orderType,orderSummary:fe.orderSummary,paymentBreakdown:fe.paymentBreakdown,onClose:he}),(0,$.jsxs)(`div`,{className:`bg-white dark:bg-lofty-purple-800 min-h-screen`,children:[(0,$.jsx)(`section`,{className:`w-full mx-auto max-w-1600-px pt-0 lg:pt-6`,children:(0,$.jsx)(`div`,{className:`p-0 mx-auto my-0 max-w-1600-px`,children:(0,$.jsx)(ya,{fallbackImage:`/static/img/No_Image_Available.jpg`,images:de})})}),(0,$.jsx)(`section`,{className:`flex w-full mt-3 mb-20 text-lofty-purple-600 dark:text-lofty-gray`,children:(0,$.jsxs)(`div`,{className:`flex w-full p-0 mx-auto my-0 max-w-1600-px px-4.5 sm:px-6 lg:px-14 xl:px-20 2xl:px-40`,children:[(0,$.jsx)(ic,{property:o,orderBook:e,propertyInfo:s,pricing:ge,userOrderData:t,forumUpdates:Ce,yieldData:z,onShowOrderBook:T.openModal,onOrderCanceled:n,onRefreshUserOrderData:a,orderRequestRef:l&&!f?ie:void 0}),m&&(0,$.jsx)(Ha,{variant:`large`,interactive:!!s&&(!_||!!t),price:ge.startingPrice??0,showOrderBookLink:Mn(e)&&!Se,openOrderBookModal:T.openModal,userOrderData:t,kycVerified:_e,tradingDisabled:Se,averageHistoricalYield:we,onRefreshUserOrderData:a,orderRequestRef:l&&f?ie:void 0})]})})]})]})}var Nd=[It.PmmV2InternalEnabled],Pd=class extends Q.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e){console.error(`Stripe Elements failed; rendering property without Stripe`,e)}render(){return(0,$.jsx)(Jn,{stripe:this.state.failed?null:this.props.stripe,children:this.props.children})}};function Fd(e){let t=y(tr),n=(0,Q.useRef)(!1);return(0,Q.useEffect)(()=>
93{if(!t||n.current)return;let e=!1;return(async()=>{let r=await t;e||r||n.current||(n.current=!0,sr({stage:`stripe_load`,errorCode:`stripe_unavailable`,stripeReady:!1,paymentCategory:`unknown`}),Zn())})(),()=>{e=!0}},[t]),(0,$.jsx)(rr,{children:(0,$.jsx)(Pd,{stripe:t,children:(0,$.jsx)(Ir,{children:(0,$.jsx)(Id,{...e})})})})}function Id({propertyKey:e,initialProperty:t}){(0,Q.useLayoutEffect)(()=>{window.scrollTo(0,0)},[]);let[n,r]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e,t=()=>{e=window.setTimeout(()=>r(!0),2500)};return document.readyState===`complete`?t():window.addEventListener(`load`,t,{once:!0}),()=>{window.removeEventListener(`load`,t),e!==void 0&&window.clearTimeout(e)}},[]),oe(n?`//loader.wisepops.com/get-loader.js?v=1&site=wcQtNJanq4`:null,{category:`advertising`}),m(`Property Detail`,{...gt(t)});let i=s(),a=y(Pa),{isAuth:o,id:c}=te(),l=O(Nd),u=o&&l.ready&&l.isOn[It.PmmV2InternalEnabled],d=h(),f=_(p),[g,v]=(0,Q.useState)(void 0),[b,x]=(0,Q.useState)(void 0),S=(0,Q.useMemo)(()=>{let e=t.liquidity?.pmmVersion===`v2`?{...t,liquidity:void 0}:t,n=u&&g?.routing?.routingUserId===c&&g.routing.propertyId===t.id?g?.routing?.liquidity:void 0;return n?{...e,liquidity:n}:e},[t,g?.routing,u,c]),C=(0,Q.useCallback)(async()=>{let e=t?.id;if(!e)return{data:void 0};try{let t=await pr({queryKey:[`propertyDealOrderbook`,{id:e,routingUserId:u?c:void 0}]});return v(t),{data:t}}catch(e){return console.error(`PropertyDeal::refetchOrderBook`,e),{data:void 0}}},[t?.id,u,c]),w=(0,Q.useCallback)(async()=>{if(!(!o||!t?.id))try{let e=await de({queryKey:[`loggedUser`,`userOrderData`,{id:t.id}]});x(e)}catch(e){console.error(`PropertyDeal::refreshUserOrderData`,e)}},[o,t?.id]);(0,Q.useEffect)(()=>{let e=t?.id;if(!e||a.inProgress)return;let n=!1,r,i=async()=>{try{let t=await pr({queryKey:[`propertyDealOrderbook`,{id:e,routingUserId:u?c:void 0}]});n||v(t)}catch{}finally{n||(r=setTimeout(i,B.minutes(1)))}};return i(),()=>{n=!0,r&&clearTimeout(r)}},[t?.id,a.inProgress,u,c]);let T=e=>{if(typeof requestIdleCallback==`function`){let t=requestIdleCallback(e,{timeout:2e3});return()=>cancelIdleCallback(t)}let t=window.setTimeout(e,2e3);return()=>window.clearTimeout(t)};return(0,Q.useEffect)(()=>{if(!o||!t?.id){x(void 0);return}let e=!1,n,r,i=async()=>{try{let n=await de({queryKey:[`loggedUser`,`userOrderData`,{id:t.id}]});e||x(n)}catch{}finally{e||(n=setTimeout(i,B.seconds(15)))}};return r=T(()=>{e||i()}),()=>{e=!0,r?.(),n&&clearTimeout(n)}},[o,t?.id]),(0,Q.useEffect)(()=>{if(!o||!t?.id)return;let e=!1,n,r,i=async()=>{try{let t=await De();e||f(t)}catch{}finally{if(!e){let e=d.pageVisible?B.minutes(1):B.minutes(5);n=setTimeout(i,e)}}};return r=T(()=>{e||i()}),()=>{e=!0,r?.(),n&&clearTimeout(n)}},[o,t?.id,d.pageVisible,f]),(0,Q.useEffect)(()=>{(a.orderCreated||a.canceled)&&(w(),C())},[a.orderCreated,a.canceled,w,C]),(0,Q.useEffect)(()=>{a.inProgress&&w()},[a.inProgress,w]),(0,Q.useEffect)(()=>{t?.id||i(`/marketplace`,{replace:!0})},[t?.id,i]),t?.id?(0,$.jsx)(Ra,{propertyKey:e,initialProperty:S,children:(0,$.jsxs)(`div`,{className:`bg-white dark:bg-lofty-purple-800 min-h-screen`,children:[(0,$.jsx)(kr,{mobilePropertyOverlay:!0}),(0,$.jsx)(Md,{orderBook:g,userOrderData:b,onOrderCanceled:e=>{if(!t?.id||!b)return;let n=b.properties[t.id]?.orders;if(!n)return;let r=!1;n[Be.ACTIVE]&&(n[Be.ACTIVE]=n[Be.ACTIVE].filter(t=>t.id!==e),r=!0),n[Be.PENDING]&&(n[Be.PENDING]=n[Be.PENDING].filter(t=>t.id!==e),r=!0),r&&(x({...b}),w(),C())},refetchOrderBook:C,onTradingDataRefresh:()=>{w(),C()}}),(0,$.jsx)(xr,{})]})}):null}var Ld=e=>e.includes(`CognitoIdentityServiceProvider`),Rd=[250,500,1e3],zd=e=>{let{accessGroup:t,...n}=e;return{...n,...t?{isPrivate:!0}:{}}},Bd=(e,t)=>!!(t||e.isPrivate),Vd=e=>({"@context":`https://schema.org`,"@type":`RealEstateListing`,name:e.address_line1,description:e.description,identifier:e.id,image:e.images?.[0],url:`https://www.lofty.ai/property_deal/${e.slug}`,contentLocation:{"@type":`Place`,name:e.address_line1,address:{"@type":`PostalAddress`,addressLocality:e.city,addressRegion:e.state,postalCode:e.zipcode,streetAddress:e.address_line1}},provider:{"@type":`Organization`,name:`Lofty`,url:`https://www.lofty.ai`}}),Hd=e=>{if(!e.property)return{title:e.gatedAuthPending?`Property | Lofty`:`Property Not Found | Lofty`,description:e.gatedAuthPending?`Loading property.`:`The requested property could not be found.`,noindex:!0};let t=Bd(e.property,e.gated);return{...Xt(e.property),noindex:t||void 0,jsonLd:t?void 0:Vd(e.property)}},Ud=async e=>{for(let t=0;t<=Rd.length;t+=1)try{let n=await Je({key:e}),r=n?.data?.property;if(r)return zd(r);if(n?.code===`credentials_error`&&t<Rd.length){await new Promise(e=>{setTimeout(e,Rd[t])});continue}return null}catch{return null}return null},Wd=(e,t)=>({propertyKey:e,property:t,...t.isPrivate?{gated:!0}:{}});async function Gd({serverLoader:e,params:t}){let n;try{n=await e()}catch{n={propertyKey:t.id??``}}if(n.property||!t.id||typeof document<`u`&&!Ld(document.cookie))return n;let r=await Ud(t.id);return r?Wd(t.id,r):n}Gd.hydrate=!0;var Kd=({loaderData:e})=>{let t=e;return Zt(t?Hd(t):{title:`Property Not Found | Lofty`,description:`The requested property could not be found.`,noindex:!0})},qd=({property:e,propertyKey:t,gated:n})=>((0,Q.useLayoutEffect)(()=>{let r=Hd({propertyKey:t,property:e,gated:n});Qt(r);let i=new MutationObserver(()=>{document.title!==r.title&&Qt(r)});return i.observe(document.head,{subtree:!0,childList:!0,characterData:!0}
93),()=>i.disconnect()},[n,e,t]),(0,$.jsx)(Fd,{initialProperty:e,propertyKey:t})),Jd=({propertyKey:e})=>{let{isAuth:t,isAuthPending:n}=_e(),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1);return(0,Q.useEffect)(()=>{if(t!==!0){i(null),o(!1);return}let n=!1;return o(!1),(async()=>{let t=await Ud(e);if(!n){if(t){i(t);return}o(!0)}})(),()=>{n=!0}},[t,e]),r?(0,$.jsx)(qd,{property:r,propertyKey:e,gated:r.isPrivate}):n||t===!0&&!a?(0,$.jsx)(ha,{}):(0,$.jsx)(Ar,{})},Yd=l(function({error:e,params:t}){return i(e)&&e.status===404&&t.id?(0,$.jsx)(Jd,{propertyKey:t.id}):(0,$.jsx)(Ar,{})}),Xd=c(function(){let e=o();return e.gatedAuthPending||!e.property?(0,$.jsx)(Jd,{propertyKey:e.propertyKey}):(0,$.jsx)(qd,{property:e.property,propertyKey:e.propertyKey,gated:e.gated})});export{Xd as i,Gd as n,Kd as r,Yd as t};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.