1import{a as je,j as i}from"./vendor-query-nkyHp8gL.js";import{r as j,f as We}from"./vendor-react-BNT0nzvx.js";import{D as $e,b as Ke}from"./DashboardLayout-BQArLa03.js";import{W as Xe,h as X,al as Et,i as Z,ad as Ee,n as D,B as k,X as St,I as At,M as de,O as Tt,aq as Bt,s as T}from"./index-BG1hbjB_.js";import{s as Pt}from"./content-sanitizer-Ctif98Tc.js";import{I as H}from"./input-Bgy44vCT.js";import{L as V}from"./label-BGAtk8Ij.js";import{g as It,a as Mt,i as Dt}from"./password-strength-BclMmEUH.js";import{A as Se,a as Ae,b as Te,c as Be,d as Pe,e as Ie,f as Me,g as De}from"./alert-dialog-B5uVNgde.js";import{U as Rt}from"./user-CoO5YSF1.js";import{S as Lt}from"./save-CkVTcoKu.js";import{M as ue}from"./mail-Ctx5pgaL.js";import{C as kt}from"./check-YdSavKRT.js";import{E as _t}from"./eye-off-ByOImRsy.js";import{E as Ut}from"./eye-CbHUV7pU.js";import{S as fe}from"./shield-check-BjMYzFta.js";import{A as he}from"./arrow-right-left-DBIpjppQ.js";import{U as Ye}from"./users-qXgsJLD-.js";import{T as Ft}from"./trash-2-D8mh_ZKl.js";import"./input-otp-BmijqesX.js";import"./shield-D2cqmhBs.js";import"./chevron-right-Bjkf53ML.js";import"./mail-check-D7o3uZkb.js";import"./newspaper-CxHmHB1y.js";import"./crown-CsNa2Jyx.js";import"./target-DCR3Hpgj.js";import"./list-CCtzf_Gh.js";import"./flag-BAn4BLiN.js";import"./vendor-ui-DPPUfW-O.js";import"./vendor-charts-B_MCcq71.js";import"./vendor-supabase-BRDBMtg7.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const qe=Xe("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const zt=Xe("ShieldOff",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);var ee={},Ot=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},Ze={},M={};let Re;const Vt=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];M.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17};M.getSymbolTotalCodewords=function(e){return Vt[e]};M.getBCHDigit=function(t){let e=0;for(;t!==0;)e++,t>>>=1;return e};M.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');Re=e};M.isKanjiModeEnabled=function(){return typeof Re<"u"};M.toSJIS=function(e){return Re(e)};var ie={};(function(t){t.L={bit:1},t.M={bit:0},t.Q={bit:3},t.H={bit:2};function e(o){if(typeof o!="string")throw new Error("Param is not a string");switch(o.toLowerCase()){case"l":case"low":return t.L;case"m":case"medium":return t.M;case"q":case"quartile":return t.Q;case"h":case"high":return t.H;default:throw new Error("Unknown EC Level: "+o)}}t.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},t.from=function(r,n){if(t.isValid(r))return r;try{return e(r)}catch{return n}}})(ie);function et(){this.buffer=[],this.length=0}et.prototype={get:function(t){const e=Math.floor(t/8);return(this.buffer[e]>>>7-t%8&1)===1},put:function(t,e){for(let o=0;o<e;o++)this.putBit((t>>>e-o-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(t){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var Ht=et;function te(t){if(!t||t<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new Uint8Array(t*t),this.reservedBit=new Uint8Array(t*t)}te.prototype.set=function(t,e,o,r){const n=t*this.size+e;this.data[n]=o,r&&(this.reservedBit[n]=!0)};te.prototype.get=function(t,e){return this.data[t*this.size+e]};te.prototype.xor=function(t,e,o){this.data[t*this.size+e]^=o};te.prototype.isReserved=function(t,e){return this.reservedBit[t*this.size+e]};var $t=te,tt={};(function(t){const e=M.getSymbolSize;t.getRowColCoords=function(r){if(r===1)return[];const n=Math.floor(r/7)+2,s=e(r),a=s===145?26:Math.ceil((s-13)/(2*n-2))*2,c=[s-7];for(let l=1;l<n-1;l++)c[l]=c[l-1]-a;return c.push(6),c.reverse()},t.getPositions=function(r){const n=[],s=t.getRowColCoords(r),a=s.length;for(let c=0;c<a;c++)for(let l=0;l<a;l++)c===0&&l===0||c===0&&l===a-1||c===a-1&&l===0||n.push([s[c],s[l]]);return n}})(tt);var nt={};const Kt=M.getSymbolSize,Je=7;nt.getPositions=function(e){const o=Kt(e);return[[0,0],[o-Je,0],[0,o-Je]]};var rt={};(function(t){t.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e={N1:3,N2:3,N3:40,N4:10};t.isValid=function(n){return n!=null&&n!==""&&!isNaN(n)&&n>=0&&n<=7},t.from=function(n){return t.isValid(n)?parseInt(n,10):void 0},t.getPenaltyN1=function(n){const s=n.size;let a=0,c=0,l=0,u=null,d=null;for(let C=0;C<s;C++){c=l=0,u=d=null;for(let g=0;g<s;g++){let h=n.get(C,g);h===u?c++:(c>
vendor: 1,391 bytes, line 11
11=5&&(a+=e.N1+(c-5)),u=h,c=1),h=n.get(g,C),h===d?l++:(l>=5&&(a+=e.N1+(l-5)),d=h,l=1)}c>=5&&(a+=e.N1+(c-5)),l>=5&&(a+=e.N1+(l-5))}return a},t.getPenaltyN2=function(n){const s=n.size;let a=0;for(let c=0;c<s-1;c++)for(let l=0;l<s-1;l++){const u=n.get(c,l)+n.get(c,l+1)+n.get(c+1,l)+n.get(c+1,l+1);(u===4||u===0)&&a++}return a*e.N2},t.getPenaltyN3=function(n){const s=n.size;let a=0,c=0,l=0;for(let u=0;u<s;u++){c=l=0;for(let d=0;d<s;d++)c=c<<1&2047|n.get(u,d),d>=10&&(c===1488||c===93)&&a++,l=l<<1&2047|n.get(d,u),d>=10&&(l===1488||l===93)&&a++}return a*e.N3},t.getPenaltyN4=function(n){let s=0;const a=n.data.length;for(let l=0;l<a;l++)s+=n.data[l];return Math.abs(Math.ceil(s*100/a/5)-10)*e.N4};function o(r,n,s){switch(r){case t.Patterns.PATTERN000:return(n+s)%2===0;case t.Patterns.PATTERN001:return n%2===0;case t.Patterns.PATTERN010:return s%3===0;case t.Patterns.PATTERN011:return(n+s)%3===0;case t.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(s/3))%2===0;case t.Patterns.PATTERN101:return n*s%2+n*s%3===0;case t.Patterns.PATTERN110:return(n*s%2+n*s%3)%2===0;case t.Patterns.PATTERN111:return(n*s%3+(n+s)%2)%2===0;default:throw new Error("bad maskPattern:"+r)}}t.applyMask=function(n,s){const a=s.size;for(let c=0;c<a;c++)for(let l=0;l<a;l++)s.isReserved(l,c)||s.xor(l,c,o(n,l,c))},t.getBestMask=function(n,s){const a=Object.keys(t.Patterns).length;let c=0,l=1/0;for(let u=0;u<a;
11u++){s(u),t.applyMask(u,n);const d=t.getPenaltyN1(n)+t.getPenaltyN2(n)+t.getPenaltyN3(n)+t.getPenaltyN4(n);t.applyMask(u,n),d<l&&(l=d,c=u)}return c}})(rt);var ae={};const F=ie,ne=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],re=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];ae.getBlocksCount=function(e,o){switch(o){case F.L:return ne[(e-1)*4+0];case F.M:return ne[(e-1)*4+1];case F.Q:return ne[(e-1)*4+2];case F.H:return ne[(e-1)*4+3];default:return}};ae.getTotalCodewordsCount=function(e,o){switch(o){case F.L:return re[(e-1)*4+0];case F.M:return re[(e-1)*4+1];case F.Q:return re[(e-1)*4+2];case F.H:return re[(e-1)*4+3];default:return}};var st={},le={};const G=new Uint8Array(512),se=new Uint8Array(256);(function(){let e=1;for(let o=0;o<255;o++)G[o]=e,se[e]=o,e<<=1,e&256&&(e^=285);for(let o=255;o<512;o++)G[o]=G[o-255]})();le.log=function(e){if(e<1)throw new Error("log("+e+")");return se[e]};le.exp=function(e){return G[e]};le.mul=function(e,o){return e===0||o===0?0:G[se[e]+se[o]]};(function(t){const e=le;t.mul=function(r,n){const s=new Uint8Array(r.length+n.length-1);for(let a=0;a<r.length;a++)for(let c=0;c<n.length;
11c++)s[a+c]^=e.mul(r[a],n[c]);return s},t.mod=function(r,n){let s=new Uint8Array(r);for(;s.length-n.length>=0;){const a=s[0];for(let l=0;l<n.length;l++)s[l]^=e.mul(n[l],a);let c=0;for(;c<s.length&&s[c]===0;)c++;s=s.slice(c)}return s},t.generateECPolynomial=function(r){let n=new Uint8Array([1]);for(let s=0;s<r;s++)n=t.mul(n,new Uint8Array([1,e.exp(s)]));return n}})(st);const ot=st;function Le(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}Le.prototype.initialize=function(e){this.degree=e,this.genPoly=ot.generateECPolynomial(this.degree)};Le.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");const o=new Uint8Array(e.length+this.degree);o.set(e);const r=ot.mod(o,this.genPoly),n=this.degree-r.length;if(n>0){const s=new Uint8Array(this.degree);return s.set(r,n),s}return r};var Yt=Le,it={},z={},ke={};ke.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40};var _={};const at="[0-9]+",qt="[A-Z $%*+\\-./:]+";let W="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";W=W.replace(/u/g,"\\u");const Jt="(?:(?![A-Z0-9 $%*+\\-./:]|"+W+`)(?:.|[\r 12]))+`;_.KANJI=new RegExp(W,"g");_.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");_.BYTE=new RegExp(Jt,"g");_.NUMERIC=new RegExp(at,"g");_.ALPHANUMERIC=new RegExp(qt,"g");const Qt=new RegExp("^"+W+"$"),Gt=new RegExp("^"+at+"$"),Wt=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");_.testKanji=function(e){return Qt.test(e)};_.testNumeric=function(e){return Gt.test(e)};_.testAlphanumeric=function(e){return Wt.test(e)};(function(t){const e=ke,o=_;t.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},t.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},t.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},t.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},t.MIXED={bit:-1},t.getCharCountIndicator=function(s,a){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!e.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?s.ccBits[0]:a<27?s.ccBits[1]:s.ccBits[2]},t.getBestModeForData=function(s){return o.testNumeric(s)?t.NUMERIC:o.testAlphanumeric(s)?t.ALPHANUMERIC:o.testKanji(s)?t.KANJI:t.BYTE},t.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},t.isValid=function(s){return s&&s.bit&&s.ccBits};function r(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"numeric":return t.NUMERIC;case"alphanumeric":return t.ALPHANUMERIC;case"kanji":return t.KANJI;case"byte":return t.BYTE;default:throw new Error("Unknown mode: "+n)}}t.from=function(s,a){if(t.isValid(s))return s;try{return r(s)}catch{return a}}})(z);(function(t){const e=M,o=ae,r=ie,n=z,s=ke,a=7973,c=e.getBCHDigit(a);function l(g,h,m){for(let N=1;N<=40;N++)if(h<=t.getCapacity(N,m,g))return N}function u(g,h){return n.getCharCountIndicator(g,h)+4}function d(g,h){let m=0;return g.forEach(function(N){const x=u(N.mode,h);m+=x+N.getBitsLength()}),m}function C(g,h){for(let m=1;m<=40;m++)if(d(g,m)<=t.getCapacity(m,h,n.MIXED))return m}t.from=function(h,m){return s.isValid(h)?parseInt(h,10):m},t.getCapacity=function(h,m,N){if(!s.isValid(h))throw new Error("Invalid QR Code version");typeof N>"u"&&(N=n.BYTE);const x=e.getSymbolTotalCodewords(h),f=o.getTotalCodewordsCount(h,m),y=(x-f)*8;if(N===n.MIXED)return y;const p=y-u(N,h);switch(N){case n.NUMERIC:return Math.floor(p/10*3);case n.ALPHANUMERIC:return Math.floor(p/11*2);case n.KANJI:return Math.floor(p/13);case n.BYTE:default:return Math.floor(p/8)}},t.getBestVersionForData=function(h,m){let N;const x=r.from(m,r.M);if(Array.isArray(h)){if(h.length>1)return C(h,x);if(h.length===0)return 1;N=h[0]}else N=h;return l(N.mode,N.getLength(),x)},t.getEncodedBits=function(h){if(!s.isValid(h)||h<7)throw new Error("Invalid QR Code version");let m=h<<12;for(;e.getBCHDigit(m)-c>=0;)m^=a<<e.getBCHDigit(m)-c;return h<<12|m}})(it);var lt={};const Ne=M,ct=1335,Xt=21522,Qe=Ne.getBCHDigit(ct);lt.getEncodedBits=function(e,o){const r=e.bit<<3|o;let n=r<<10;for(;
12Ne.getBCHDigit(n)-Qe>=0;)n^=ct<<Ne.getBCHDigit(n)-Qe;return(r<<10|n)^Xt};var dt={};const Zt=z;function $(t){this.mode=Zt.NUMERIC,this.data=t.toString()}$.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)};$.prototype.getLength=function(){return this.data.length};$.prototype.getBitsLength=function(){return $.getBitsLength(this.data.length)};$.prototype.write=function(e){let o,r,n;for(o=0;o+3<=this.data.length;o+=3)r=this.data.substr(o,3),n=parseInt(r,10),e.put(n,10);const s=this.data.length-o;s>0&&(r=this.data.substr(o),n=parseInt(r,10),e.put(n,s*3+1))};var en=$;const tn=z,me=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function K(t){this.mode=tn.ALPHANUMERIC,this.data=t}K.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)};K.prototype.getLength=function(){return this.data.length};K.prototype.getBitsLength=function(){return K.getBitsLength(this.data.length)};K.prototype.write=function(e){let o;for(o=0;o+2<=this.data.length;o+=2){let r=me.indexOf(this.data[o])*45;r+=me.indexOf(this.data[o+1]),e.put(r,11)}this.data.length%2&&e.put(me.indexOf(this.data[o]),6)};var nn=K;const rn=z;function Y(t){this.mode=rn.BYTE,typeof t=="string"?this.data=new TextEncoder().encode(t):this.data=new Uint8Array(t)}Y.getBitsLength=function(e){return e*8};Y.prototype.getLength=function(){return this.data.length};Y.prototype.getBitsLength=function(){return Y.getBitsLength(this.data.length)};Y.prototype.write=function(t){for(let e=0,o=this.data.length;e<o;e++)t.put(this.data[e],8)};var sn=Y;const on=z,an=M;function q(t){this.mode=on.KANJI,this.data=t}q.getBitsLength=function(e){return e*13};q.prototype.getLength=function(){return this.data.length};q.prototype.getBitsLength=function(){return q.getBitsLength(this.data.length)};q.prototype.write=function(t){let e;for(e=0;e<this.data.length;e++){let o=an.toSJIS(this.data[e]);if(o>=33088&&o<=40956)o-=33088;else if(o>=57408&&o<=60351)o-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+` 13Make sure your charset is UTF-8`);o=(o>>>8&255)*192+(o&255),t.put(o,13)}};var ln=q,ut={exports:{}};(function(t){var e={single_source_shortest_paths:function(o,r,n){var s={},a={};a[r]=0;var c=e.PriorityQueue.make();c.push(r,0);for(var l,u,d,C,g,h,m,N,x;!c.empty();){l=c.pop(),u=l.value,C=l.cost,g=o[u]||{};for(d in g)g.hasOwnProperty(d)&&(h=g[d],m=C+h,N=a[d],x=typeof a[d]>"u",(x||N>m)&&(a[d]=m,c.push(d,m),s[d]=u))}if(typeof n<"u"&&typeof a[n]>"u"){var f=["Could not find a path from ",r," to ",n,"."].join("");throw new Error(f)}return s},extract_shortest_path_from_predecessor_list:function(o,r){for(var n=[],s=r;s;)n.push(s),o[s],s=o[s];return n.reverse(),n},find_path:function(o,r,n){var s=e.single_source_shortest_paths(o,r,n);return e.extract_shortest_path_from_predecessor_list(s,n)},PriorityQueue:{make:function(o){var r=e.PriorityQueue,n={},s;o=o||{};for(s in r)r.hasOwnProperty(s)&&(n[s]=r[s]);return n.queue=[],n.sorter=o.sorter||r.default_sorter,n},default_sorter:function(o,r){return o.cost-r.cost},push:function(o,r){var n={value:o,cost:r};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t.exports=e})(ut);var cn=ut.exports;(function(t){const e=z,o=en,r=nn,n=sn,s=ln,a=_,c=M,l=cn;function u(f){return unescape(encodeURIComponent(f)).length}function d(f,y,p){const w=[];let E;for(;(E=f.exec(p))!==null;)w.push({data:E[0],index:E.index,mode:y,length:E[0].length});return w}function C(f){const y=d(a.NUMERIC,e.NUMERIC,f),p=d(a.ALPHANUMERIC,e.ALPHANUMERIC,f);let w,E;return c.isKanjiModeEnabled()?(w=d(a.BYTE,e.BYTE,f),E=d(a.KANJI,e.KANJI,f)):(w=d(a.BYTE_KANJI,e.BYTE,f),E=[]),y.concat(p,w,E).sort(function(A,P){return A.index-P.index}).map(function(A){return{data:A.data,mode:A.mode,length:A.length}})}function g(f,y){switch(y){case e.NUMERIC:return o.getBitsLength(f);case e.ALPHANUMERIC:return r.getBitsLength(f);case e.KANJI:return s.getBitsLength(f);case e.BYTE:return n.getBitsLength(f)}}function h(f){return f.reduce(function(y,p){const w=y.length-1>=0?y[y.length-1]:null;return w&&w.mode===p.mode?(y[y.length-1].data+=p.data,y):(y.push(p),y)},[])}function m(f){const y=[];for(let p=0;p<f.length;p++){const w=f[p];switch(w.mode){case e.NUMERIC:y.push([w,{data:w.data,mode:e.ALPHANUMERIC,length:w.length},{data:w.data,mode:e.BYTE,length:w.length}]);break;case e.ALPHANUMERIC:y.push([w,{data:w.data,mode:e.BYTE,length:w.length}]);break;case e.KANJI:y.push([w,{data:w.data,mode:e.BYTE,length:u(w.data)}]);break;case e.BYTE:y.push([{data:w.data,mode:e.BYTE,length:u(w.data)}])}}return y}function N(f,y){const p={},w={start:{}};let E=["start"];for(let S=0;S<f.length;S++){const A=f[S],P=[];for(let b=0;b<A.length;b++){const I=A[b],U=""+S+b;P.push(U),p[U]={node:I,lastCount:0},w[U]={};for(let J=0;J<E.length;J++){const R=E[J];p[R]&&p[R].node.mode===I.mode?(w[R][U]=g(p[R].lastCount+I.length,I.mode)-g(p[R].lastCount,I.mode),p[R].lastCount+=I.length):(p[R]&&(p[R].lastCount=I.length),w[R][U]=g(I.length,I.mode)+4+e.getCharCountIndicator(I.mode,y))}}E=P}for(let S=0;S<E.length;S++)w[E[S]].end=0;return{map:w,table:p}}function x(f,y){let p;
vendor: 5,443 bytes, lines 13-17
13const w=e.getBestModeForData(f);if(p=e.from(y,w),p!==e.BYTE&&p.bit<w.bit)throw new Error('"'+f+'" cannot be encoded with mode '+e.toString(p)+`. 14 Suggested mode is: `+e.toString(w));switch(p===e.KANJI&&!c.isKanjiModeEnabled()&&(p=e.BYTE),p){case e.NUMERIC:return new o(f);case e.ALPHANUMERIC:return new r(f);case e.KANJI:return new s(f);case e.BYTE:return new n(f)}}t.fromArray=function(y){return y.reduce(function(p,w){return typeof w=="string"?p.push(x(w,null)):w.data&&p.push(x(w.data,w.mode)),p},[])},t.fromString=function(y,p){const w=C(y,c.isKanjiModeEnabled()),E=m(w),S=N(E,p),A=l.find_path(S.map,"start","end"),P=[];for(let b=1;b<A.length-1;b++)P.push(S.table[A[b]].node);return t.fromArray(h(P))},t.rawSplit=function(y){return t.fromArray(C(y,c.isKanjiModeEnabled()))}})(dt);const ce=M,ge=ie,dn=Ht,un=$t,fn=tt,hn=nt,Ce=rt,ve=ae,mn=Yt,oe=it,gn=lt,pn=z,pe=dt;function wn(t,e){const o=t.size,r=hn.getPositions(e);for(let n=0;n<r.length;n++){const s=r[n][0],a=r[n][1];for(let c=-1;c<=7;c++)if(!(s+c<=-1||o<=s+c))for(let l=-1;l<=7;l++)a+l<=-1||o<=a+l||(c>=0&&c<=6&&(l===0||l===6)||l>=0&&l<=6&&(c===0||c===6)||c>=2&&c<=4&&l>=2&&l<=4?t.set(s+c,a+l,!0,!0):t.set(s+c,a+l,!1,!0))}}function xn(t){const e=t.size;for(let o=8;o<e-8;o++){const r=o%2===0;t.set(o,6,r,!0),t.set(6,o,r,!0)}}function yn(t,e){const o=fn.getPositions(e);for(let r=0;r<o.length;r++){const n=o[r][0],s=o[r][1];for(let a=-2;a<=2;a++)for(let c=-2;c<=2;c++)a===-2||a===2||c===-2||c===2||a===0&&c===0?t.set(n+a,s+c,!0,!0):t.set(n+a,s+c,!1,!0)}}function Nn(t,e){const o=t.size,r=oe.getEncodedBits(e);let n,s,a;for(let c=0;c<18;c++)n=Math.floor(c/3),s=c%3+o-8-3,a=(r>>c&1)===1,t.set(n,s,a,!0),t.set(s,n,a,!0)}function we(t,e,o){const r=t.size,n=gn.getEncodedBits(e,o);let s,a;for(s=0;s<15;s++)a=(n>>s&1)===1,s<6?t.set(s,8,a,!0):s<8?t.set(s+1,8,a,!0):t.set(r-15+s,8,a,!0),s<8?t.set(8,r-s-1,a,!0):s<9?t.set(8,15-s-1+1,a,!0):t.set(8,15-s-1,a,!0);t.set(r-8,8,1,!0)}function Cn(t,e){const o=t.size;let r=-1,n=o-1,s=7,a=0;for(let c=o-1;c>0;c-=2)for(c===6&&c--;;){for(let l=0;l<2;l++)if(!t.isReserved(n,c-l)){let u=!1;a<e.length&&(u=(e[a]>>>s&1)===1),t.set(n,c-l,u),s--,s===-1&&(a++,s=7)}if(n+=r,n<0||o<=n){n-=r,r=-r;break}}}function vn(t,e,o){const r=new dn;o.forEach(function(l){r.put(l.mode.bit,4),r.put(l.getLength(),pn.getCharCountIndicator(l.mode,t)),l.write(r)});const n=ce.getSymbolTotalCodewords(t),s=ve.getTotalCodewordsCount(t,e),a=(n-s)*8;for(r.getLengthInBits()+4<=a&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const c=(a-r.getLengthInBits())/8;for(let l=0;l<c;l++)r.put(l%2?17:236,8);return bn(r,t,e)}function bn(t,e,o){const r=ce.getSymbolTotalCodewords(e),n=ve.getTotalCodewordsCount(e,o),s=r-n,a=ve.getBlocksCount(e,o),c=r%a,l=a-c,u=Math.floor(r/a),d=Math.floor(s/a),C=d+1,g=u-d,h=new mn(g);let m=0;const N=new Array(a),x=new Array(a);let f=0;const y=new Uint8Array(t.buffer);for(let A=0;A<a;A++){const P=A<l?d:C;N[A]=y.slice(m,m+P),x[A]=h.encode(N[A]),m+=P,f=Math.max(f,P)}const p=new Uint8Array(r);let w=0,E,S;for(E=0;E<f;E++)for(S=0;S<a;S++)E<N[S].length&&(p[w++]=N[S][E]);for(E=0;E<g;E++)for(S=0;S<a;S++)p[w++]=x[S][E];return p}function jn(t,e,o,r){let n;if(Array.isArray(t))n=pe.fromArray(t);else if(typeof t=="string"){let u=e;if(!u){const d=pe.rawSplit(t);u=oe.getBestVersionForData(d,o)}n=pe.fromString(t,u||40)}else throw new Error("Invalid data");const s=oe.getBestVersionForData(n,o);if(!s)throw new Error("The amount of data is too big to be stored in a QR Code");if(!e)e=s;else if(e<s)throw new Error(` 15The chosen QR Code version cannot contain this amount of data. 16Minimum version required to store current data is: `+s+`. 17`);const a=vn(e,o,n),c=ce.getSymbolSize(e),l=new un(c);return wn(l,e),xn(l),yn(l,e),we(l,o,0),e>=7&&Nn(l,e),Cn(l,a),isNaN(r)&&(r=Ce.getBestMask(l,we.bind(null,l,o))),Ce.applyMask(r,l),we(l,o,r),{modules:l,version:e,errorCorrectionLevel:o,maskPattern:r,segments:n}}Ze.create=function(e,o){if(typeof e>"u"||e==="")throw new Error("No input text");let r=ge.M,n,s;return typeof o<"u"&&(r=ge.from(o.errorCorrectionLevel,ge.M),n=oe.from(o.version),s=Ce.from(o.maskPattern),o.toSJISFunc&&ce.setToSJISFunction(o.toSJISFunc)),jn(e,n,r,s)};var ft={},_e={};(function(t){function e(o){if(typeof o=="number"&&(o=o.toString()),typeof o!="string")throw new Error("Color should be defined as hex string");let r=o.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+o);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(s){return[s,s]}))),r.length===6&&r.push("F","F");const n=parseInt(r.join(""),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:"#"+r.slice(0,6).join("")}}t.getOptions=function(r){r||(r={}),r.color||(r.color={});const n=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,s=r.width&&r.width>=21?r.width:void 0,a=r.scale||4;return{width:s,scale:s?4:a,margin:n,color:{dark:e(r.color.dark||"#000000ff"),light:e(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},t.getScale=function(r,n){return n.width&&n.width>=r+n.margin*2?n.width/(r+n.margin*2):n.scale},t.getImageWidth=function(r,n){const s=t.getScale(r,n);return Math.floor((r+n.margin*2)*s)},t.qrToImageData=function(r,n,s){const a=n.modules.size,c=n.modules.data,l=t.getScale(a,s),u=Math.floor((a+s.margin*2)*l),d=s.margin*l,C=[s.color.light,s.color.dark];for(let g=0;g<u;g++)for(let h=0;h<u;h++){let m=(g*u+h)*4,N=s.color.light;if(g>=d&&h>
17=d&&g<u-d&&h<u-d){const x=Math.floor((g-d)/l),f=Math.floor((h-d)/l);N=C[c[x*a+f]?1:0]}r[m++]=N.r,r[m++]=N.g,r[m++]=N.b,r[m]=N.a}}})(_e);(function(t){const e=_e;function o(n,s,a){n.clearRect(0,0,s.width,s.height),s.style||(s.style={}),s.height=a,s.width=a,s.style.height=a+"px",s.style.width=a+"px"}function r(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}t.render=function(s,a,c){let l=c,u=a;typeof l>"u"&&(!a||!a.getContext)&&(l=a,a=void 0),a||(u=r()),l=e.getOptions(l);const d=e.getImageWidth(s.modules.size,l),C=u.getContext("2d"),g=C.createImageData(d,d);return e.qrToImageData(g.data,s,l),o(C,u,d),C.putImageData(g,0,0),u},t.renderToDataURL=function(s,a,c){let l=c;typeof l>"u"&&(!a||!a.getContext)&&(l=a,a=void 0),l||(l={});const u=t.render(s,a,l),d=l.type||"image/png",C=l.rendererOpts||{};return u.toDataURL(d,C.quality)}})(ft);var ht={};const En=_e;function Ge(t,e){const o=t.a/255,r=e+'="'+t.hex+'"';return o<1?r+" "+e+'-opacity="'+o.toFixed(2).slice(1)+'"':r}function xe(t,e,o){let r=t+e;return typeof o<"u"&&(r+=" "+o),r}function Sn(t,e,o){let r="",n=0,s=!1,a=0;for(let c=0;c<t.length;c++){const l=Math.floor(c%e),u=Math.floor(c/e);!l&&!s&&(s=!0),t[c]?(a++,c>0&&l>0&&t[c-1]||(r+=s?xe("M",l+o,.5+u+o):xe("m",n,0),n=0,s=!1),l+1<e&&t[c+1]||(r+=xe("h",a),a=0)):n++}return r}ht.render=function(e,o,r){const n=En.getOptions(o),s=e.modules.size,a=e.modules.data,c=s+n.margin*2,l=n.color.light.a?"<path "+Ge(n.color.light,"fill")+' d="M0 0h'+c+"v"+c+'H0z"/>':"",u="<path "+Ge(n.color.dark,"stroke")+' d="'+Sn(a,s,n.margin)+'"/>',d='viewBox="0 0 '+c+" "+c+'"',g='<svg xmlns="http://www.w3.org/2000/svg" '+(n.width?'width="'+n.width+'" height="'+n.width+'" ':"")+d+' shape-rendering="crispEdges">'+l+u+`</svg> 18`;return typeof r=="function"&&r(null,g),g};const An=Ot,be=Ze,mt=ft,Tn=ht;function Ue(t,e,o,r,n){const s=[].slice.call(arguments,1),a=s.length,c=typeof s[a-1]=="function";if(!c&&!An())throw new Error("Callback required as last argument");if(c){if(a<2)throw new Error("Too few arguments provided");a===2?(n=o,o=e,e=r=void 0):a===3&&(e.getContext&&typeof n>"u"?(n=r,r=void 0):(n=r,r=o,o=e,e=void 0))}else{if(a<1)throw new Error("Too few arguments provided");return a===1?(o=e,e=r=void 0):a===2&&!e.getContext&&(r=o,o=e,e=void 0),new Promise(function(l,u){try{const d=be.create(o,r);l(t(d,e,r))}catch(d){u(d)}})}try{const l=be.create(o,r);n(null,t(l,e,r))}catch(l){n(l)}}ee.create=be.create;ee.toCanvas=Ue.bind(null,mt.render);ee.toDataURL=Ue.bind(null,mt.renderToDataURL);ee.toString=Ue.bind(null,function(t,e,o){return Tn.render(t,o)});const ye=({value:t,onChange:e,placeholder:o,maxLength:r=128})=>{const[n,s]=j.useState(!1);return i.jsxs("div",{className:"relative",children:[i.jsx(H,{type:n?"text":"password",value:t,onChange:a=>e(a.target.value),placeholder:o,maxLength:r,className:"pr-10"}),i.jsx("button",{type:"button",onClick:()=>s(!n),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,children:n?i.jsx(_t,{className:"w-4 h-4"}):i.jsx(Ut,{className:"w-4 h-4"})})]})},Bn=({password:t})=>{if(!t)return null;const{score:e,label:o,color:r}=Mt(t);return i.jsxs("div",{className:"space-y-1",children:[i.jsx("div",{className:"flex gap-1",children:[0,1,2,3].map(n=>i.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-colors ${n<=e-1?r:"bg-secondary"}`},n))}),i.jsx("p",{className:"text-xs text-muted-foreground",children:o})]})},Pn=()=>{const{isImpersonating:t}=Ee(),{user:e}=X(),{toast:o}=Z(),[r,n]=j.useState(!0),[s,a]=j.useState(null),[c,l]=j.useState(!1),[u,d]=j.useState(null),[C,g]=j.useState(null),[h,m]=j.useState(""),[N,x]=j.useState(!1),[f,y]=j.useState(!1),[p,w]=j.useState(!1),[E,S]=j.useState([]),[A,P]=j.useState(!1),[b,I]=j.useState(!1),U=async()=>{n(!0);try{const{data:v,error:B}=await T.auth.mfa.listFactors();if(B)throw B;const L=v.totp?.find(Q=>Q.status==="verified");a(L??null)}catch{}finally{n(!1)}},J=async()=>{if(e){P(!0);try{const{data:v,error:B}=await T.from("trusted_devices").select("id, device_name, expires_at, created_at").eq("user_id",e.id).gte("expires_at",new Date().toISOString()).order("created_at",{ascending:!1});if(B)throw B;S(v||[])}catch{}finally{P(!1)}}};if(j.useEffect(()=>{t||(U(),J())},[t]),t)return null;const R=async()=>
18{l(!0);try{const{data:v,error:B}=await T.auth.mfa.listFactors();if(B)throw B;const L=v?.totp??[];if(L.some(O=>O.status==="verified")){o({title:"Two-factor authentication is already enabled."});return}const Q=L.filter(O=>O.status!=="verified");for(const O of Q){const{error:He}=await T.auth.mfa.unenroll({factorId:O.id});if(He)throw He}const{data:Nt,error:Fe}=await T.auth.mfa.listFactors();if(Fe)throw Fe;if((Nt?.totp??[]).some(O=>O.status!=="verified"))throw new Error("Could not clear the previous 2FA setup. Please try again.");const{data:ze,error:Oe}=await T.auth.mfa.enroll({factorType:"totp",friendlyName:"RubPage"});if(Oe)throw Oe;const Ct=ze.totp.secret,Ve="RubPage",vt=e?.email??"user",bt=`otpauth://totp/${encodeURIComponent(`${Ve}:${vt}`)}?secret=${Ct}&issuer=${encodeURIComponent(Ve)}&algorithm=SHA1&digits=6&period=30`,jt=await ee.toDataURL(bt,{width:200,margin:2});d(jt),g(ze.id)}catch(v){o({title:"Error",description:v.message,variant:"destructive"})}finally{l(!1)}},gt=async()=>{if(!(!C||h.length!==6)){x(!0);try{const{data:v,error:B}=await T.auth.mfa.challenge({factorId:C});if(B)throw B;const{error:L}=await T.auth.mfa.verify({factorId:C,challengeId:v.id,code:h});if(L)throw L;o({title:"2FA enabled!"}),d(null),g(null),m(""),U()}catch(v){o({title:"Verification failed",description:v.message,variant:"destructive"})}finally{x(!1)}}},pt=async()=>{if(s){w(!0);try{const{error:v}=await T.auth.mfa.unenroll({factorId:s.id});if(v)throw v;o({title:"2FA disabled"}),a(null)}catch(v){o({title:"Error",description:v.message,variant:"destructive"})}finally{w(!1),y(!1)}}},wt=async v=>{try{const{error:B}=await T.from("trusted_devices").delete().eq("id",v);if(B)throw B;S(L=>L.filter(Q=>Q.id!==v)),o({title:"Device revoked"})}catch(B){o({title:"Error",description:B.message,variant:"destructive"})}},xt=async()=>{if(e){I(!0);try{const{error:v}=await T.from("trusted_devices").delete().eq("user_id",e.id);if(v)throw v;S([]),localStorage.removeItem("rubpage_trusted_device"),o({title:"All trusted devices revoked"})}catch(v){o({title:"Error",description:v.message,variant:"destructive"})}finally{I(!1)}}},yt=v=>{if(!v)return"Unknown device";const B=v.match(/(Chrome|Firefox|Safari|Edge|Opera)\/[\d.]+/),L=v.match(/(Windows|Mac|Linux|Android|iPhone|iPad)/i);return`${B?.[0]??"Browser"} · ${L?.[1]??"Unknown OS"}`};return r?null:i.jsxs("div",{className:"border border-border rounded-lg p-5",children:[i.jsxs("h2",{className:"text-sm font-medium text-foreground mb-1 flex items-center gap-2",children:[i.jsx(fe,{className:"w-4 h-4 text-muted-foreground"})," Two-Factor Authentication (2FA)"]}),i.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Add an extra layer of security with an authenticator app."}),s?i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("span",{className:"text-xs text-green-500 font-medium flex items-center gap-1",children:[i.jsx(fe,{className:"w-3.5 h-3.5"})," Enabled"]}),i.jsxs(k,{variant:"outline",size:"sm",onClick:()=>y(!0),disabled:p,children:[p?i.jsx(D,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):i.jsx(zt,{className:"w-3.5 h-3.5 mr-1.5"}),"Disable 2FA"]})]}):u?i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-xs text-muted-foreground",children:"Scan this QR code with your authenticator app, then enter the 6-digit code below."}),i.jsx("img",{src:u,alt:"TOTP QR Code",className:"w-48 h-48 rounded-lg border border-border"}),i.jsxs("div",{className:"flex gap-2 max-w-xs",children:[i.jsx(H,{value:h,onChange:v=>m(v.target.value.replace(/\D/g,"").slice(0,6)),placeholder:"123456",maxLength:6,className:"font-mono tracking-widest"}),i.jsx(k,{onClick:gt,disabled:N||h.length!==6,size:"sm",children:N?i.jsx(D,{className:"w-3.5 h-3.5 animate-spin"}):"Verify"})]})]}):i.jsxs(k,{variant:"outline",size:"sm",onClick:R,disabled:c,children:[c?i.jsx(D,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):i.jsx(fe,{className:"w-3.5 h-3.5 mr-1.5"}),"Enable 2FA"]}),s&&i.jsxs("div",{className:"mt-5 pt-5 border-t border-border",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"text-xs font-medium text-foreground",children:"Trusted Devices"}),E.length>0&&i.jsxs(k,{variant:"ghost",size:"sm",className:"text-xs h-7 text-destructive hover:text-destructive",onClick:xt,disabled:b,children:[b?i.jsx(D,{className:"w-3 h-3 mr-1 animate-spin"}):null,"Revoke All"]})]}),A?i.jsx(D,{className:"w-4 h-4 animate-spin text-muted-foreground"}):E.length===0?i.jsx("p",{className:"text-xs text-muted-foreground",children:'No trusted devices. Check "Trust this device" during 2FA login to skip the code next time.'}):i.jsx("div",{className:"space-y-2",children:E.map(v=>i.jsxs("div",{className:"flex items-center justify-between bg-secondary/30 rounded-md px-3 py-2",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-xs font-medium text-foreground",children:yt(v.device_name)}),i.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Expires ",new Date(v.expires_at).toLocaleDateString()]})]}),i.jsx(k,{variant:"ghost",size:"sm",className:"h-7 text-xs text-destructive hover:text-destructive",onClick:()=>wt(v.id),children:"Revoke"})]},v.id))})]}),i.jsx(Se,{open:f,onOpenChange:y,children:i.jsxs(Ae,{children:[i.jsxs(Te,{children:[i.jsx(Be,{children:"Disable Two-Factor Authentication?"}),i.jsx(Pe,{children:"This will remove the extra security layer from your account."})]}),i.jsxs(Ie,{children:[i.jsx(Me,{children:"Cancel"}),i.jsxs(De,{onClick:pt,disabled:p,children:[p&&i.jsx(D,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),"Disable"]})]})]})})]})},In=({preferredCityId:t})=>{const{user:e}=X(),{data:o}=At(),{toast:r}=Z(),n=je(),[s,a]=j.useState(""),[c,l]=j.useState(!1),[u,d]=j.useState(!1),C=j.useRef(null),g=j.useRef(null),h=o?.find(x=>x.id===t),m=s.length>=1?(o??[]).filter(x=>{const f=s.toLowerCase();return x.name.toLowerCase().includes(f)||x.state?.toLowerCase().includes(f)}).sort((x,f)=>(f.listing_count??0)-(x.listing_count??0)).slice(0,6):[];j.useEffect(()=>{const x=f=>{g.current&&!g.current.contains(f.target)&&C.current&&!C.current.contains(f.target)&&l(!1)};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[]);const N=async(x,f)=>{if(e){d(!0);try{const{error:y}=await T.from("profiles").update({preferred_city_id:x,updated_at:new Date().toISOString()}).eq("id",e.id);if(y)throw y;n.invalidateQueries({queryKey:["profile"]}
18),r({title:`${f} set as your city`}),a(""),l(!1)}catch(y){r({title:"Error",description:y.message,variant:"destructive"})}finally{d(!1)}}};return i.jsxs("div",{className:"border border-border rounded-lg p-5",children:[i.jsxs("h2",{className:"text-sm font-medium text-foreground mb-1 flex items-center gap-2",children:[i.jsx(de,{className:"w-4 h-4 text-muted-foreground"})," Preferred City"]}),i.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Your home city for quick access on the dashboard."}),h&&i.jsx("div",{className:"flex items-center gap-2 mb-3",children:i.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full bg-primary/10 text-primary text-sm font-medium",children:[i.jsx(de,{className:"w-3.5 h-3.5"}),h.name,", ",h.state]})}),i.jsxs("div",{className:"relative max-w-sm",children:[i.jsx(Tt,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground z-10"}),i.jsx("input",{ref:C,type:"text",placeholder:h?"Change city...":"Search for your city...",value:s,onChange:x=>{a(x.target.value),l(!0)},onFocus:()=>l(!0),className:"w-full h-9 pl-9 pr-3 rounded-md border border-border bg-muted/40 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring/20 focus:bg-background transition-all",name:"city-search",autoComplete:"off","data-1p-ignore":!0,"data-lpignore":"true"}),c&&m.length>0&&i.jsx("div",{ref:g,className:"absolute top-full left-0 right-0 mt-1 bg-card border border-border rounded-lg shadow-lg z-[60] overflow-hidden",children:m.map(x=>i.jsxs("button",{type:"button",onClick:()=>N(x.id,x.name),disabled:u,className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground hover:bg-secondary/50 transition-colors text-left",children:[i.jsx(de,{className:"w-3.5 h-3.5 text-muted-foreground shrink-0"}),i.jsx("span",{className:"font-medium",children:x.name}),x.state&&i.jsx("span",{className:"text-xs text-muted-foreground",children:x.state}),x.id===t&&i.jsx("span",{className:"text-xs text-primary ml-auto",children:"Current"})]},x.id))})]})]})},Mn=()=>{const{user:t}=X(),{toast:e}=Z(),o=We(),r=je(),[n,s]=j.useState(!1),[a,c]=j.useState(""),[l,u]=j.useState(!1),{isImpersonating:d,impersonatedRole:C}=Ee(),{data:g}=Bt();if(!d&&g==="admin")return null;if(d){const f=C==="advertiser"?"Advertiser":"Client";return i.jsxs("div",{className:"border border-border rounded-lg p-5",children:[i.jsxs("h2",{className:"text-sm font-medium text-foreground mb-1 flex items-center gap-2",children:[i.jsx(he,{className:"w-4 h-4 text-muted-foreground"})," Account Type"]}),i.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"This user's account type."}),i.jsxs("span",{className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm font-medium ${C==="advertiser"?"bg-green-500/10 text-green-600":"bg-blue-500/10 text-blue-600"}`,children:[C==="advertiser"?i.jsx(Ke,{className:"w-3.5 h-3.5"}):i.jsx(Ye,{className:"w-3.5 h-3.5"}),f]})]})}const h=t?.user_metadata?.role,m=h==="provider"||h==="advertiser"?"advertiser":"client",N=m==="advertiser"?"client":"advertiser",x=async()=>{if(a==="SWITCH"){u(!0);try{const{data:f}=await T.auth.getSession(),y=f?.session?.access_token;if(!y)throw new Error("Session expired");const{data:p,error:w}=await T.functions.invoke("switch-role",{headers:{Authorization:`Bearer ${y}`},body:{targetRole:N}});if(w)throw w;if(p?.error)throw new Error(p.error);await T.auth.refreshSession(),r.invalidateQueries({queryKey:["profile"]}),e({title:"Account type switched!",description:`You are now a ${N}.`}),s(!1),c(""),o("/dashboard",{replace:!0}),window.location.reload()}catch(f){e({title:"Switch failed",description:f.message,variant:"destructive"})}finally{u(!1)}}};return i.jsxs("div",{className:"border border-border rounded-lg p-5",children:[i.jsxs("h2",{className:"text-sm font-medium text-foreground mb-1 flex items-center gap-2",children:[i.jsx(he,{className:"w-4 h-4 text-muted-foreground"})," Account Type"]}),i.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Your account determines what features you can access."}),i.jsx("div",{className:"flex items-center gap-3 mb-4",children:i.jsxs("span",{className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-sm font-medium ${m==="advertiser"?"bg-green-500/10 text-green-600":"bg-blue-500/10 text-blue-600"}`,children:[m==="advertiser"?i.jsx(Ke,{className:"w-3.5 h-3.5"}):i.jsx(Ye,{className:"w-3.5 h-3.5"}),m==="advertiser"?"Advertiser":"Client"]})}),i.jsxs(k,{variant:"outline",size:"sm",onClick:()=>s(!0),children:[i.jsx(he,{className:"w-3.5 h-3.5 mr-1.5"}),"Switch to ",N==="advertiser"?"Advertiser":"Client"]}),i.jsx(Se,{open:n,onOpenChange:s,children:i.jsxs(Ae,{children:[i.jsxs(Te,{children:[i.jsxs(Be,{children:["Switch to ",N==="advertiser"?"Advertiser":"Client","?"]}),i.jsx(Pe,{asChild:!0,children:i.jsxs("div",{className:"space-y-3",children:[i.jsx("p",{className:"font-medium text-foreground",children:"This will permanently affect your account:"}),m==="advertiser"?i.jsxs("ul",{className:"list-disc pl-5 text-xs space-y-1",children:[i.jsx("li",{className:"text-destructive font-medium",children:"All your listings will be permanently deleted"}),i.jsx("li",{children:"All listing images will be removed"}),i.jsx("li",{children:"Active promotions will be cancelled"}),i.jsx("li",{children:"Feed posts will be deleted"}),i.jsx("li",{className:"text-primary",children:"Your wallet balance will be preserved"})]}):i.jsxs("ul",{className:"list-disc pl-5 text-xs space-y-1",children:[i.jsx("li",{className:"text-destructive font-medium",children:"Active membership will be cancelled (no refund)"}),i.jsx("li",{children:"All favorites will be removed"}),i.jsx("li",{children:"Contact history will be cleared"}),i.jsx("li",{className:"text-primary",children:"Your wallet balance will be preserved"})]}),i.jsxs("p",{className:"text-xs text-muted-foreground",children:["You will start fresh as a ",N,". This cannot be undone."]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(V,{className:"text-xs",children:"Type SWITCH to confirm"}),i.jsx(H,{value:a,onChange:f=>c(f.target.value.toUpperCase()),placeholder:"SWITCH",className:"font-mono"})]})]})})]}),i.jsxs(Ie,{children:[i.jsx(Me,{disabled:l,children:"Cancel"}),i.jsxs(De,{onClick:x,disabled:l||a!=="SWITCH",className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[l&&i.jsx(D,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),"Switch Account Type"]})]})]})})]})},Dn=()=>{const{user:t}=X(),{toast:e}=Z(),o=We(),[r,n]=j.useState(!1),[s,a]=j.useState(""),[c,l]=j.useState(!1),u=async()=>
18{if(!(!t||s!=="DELETE")){l(!0);try{const{data:d}=await T.auth.getSession(),C=d?.session?.access_token;if(!C)throw new Error("Session expired");const g=await T.functions.invoke("delete-account",{headers:{Authorization:`Bearer ${C}`}});if(g.error)throw new Error(g.error.message||"Deletion failed");if(g.data?.error)throw new Error(g.data.error);await T.auth.signOut(),o("/"),e({title:"Account deleted",description:"Your account and all data have been permanently removed."})}catch(d){e({title:"Error",description:d.message,variant:"destructive"})}finally{l(!1),n(!1),a("")}}};return i.jsxs("div",{className:"border border-destructive/30 rounded-lg p-5",children:[i.jsxs("h2",{className:"text-sm font-medium text-destructive mb-1 flex items-center gap-2",children:[i.jsx(Ft,{className:"w-4 h-4"})," Delete Account"]}),i.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Permanently delete your account, all listings, and data. This action cannot be undone."}),i.jsx(k,{variant:"destructive",size:"sm",onClick:()=>n(!0),children:"Delete My Account"}),i.jsx(Se,{open:r,onOpenChange:n,children:i.jsxs(Ae,{children:[i.jsxs(Te,{children:[i.jsx(Be,{children:"Are you absolutely sure?"}),i.jsx(Pe,{asChild:!0,children:i.jsxs("div",{className:"space-y-3",children:[i.jsx("p",{children:"This will permanently delete:"}),i.jsxs("ul",{className:"list-disc pl-5 text-xs space-y-1",children:[i.jsx("li",{children:"Your account and profile"}),i.jsx("li",{children:"All your listings"}),i.jsx("li",{children:"Your wallet balance and transaction history"}),i.jsx("li",{children:"All favorites and contact history"})]}),i.jsx("p",{className:"font-medium text-destructive",children:"This action cannot be undone."}),i.jsxs("div",{className:"space-y-1",children:[i.jsx(V,{className:"text-xs",children:"Type DELETE to confirm"}),i.jsx(H,{value:s,onChange:d=>a(d.target.value.toUpperCase()),placeholder:"DELETE",className:"font-mono"})]})]})})]}),i.jsxs(Ie,{children:[i.jsx(Me,{disabled:c,children:"Cancel"}),i.jsxs(De,{onClick:u,disabled:c||s!=="DELETE",className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:[c&&i.jsx(D,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}),"Delete Everything"]})]})]})})]})},fr=()=>{const{user:t}=X(),{data:e,isLoading:o}=Et(),{toast:r}=Z(),n=je(),{isImpersonating:s}=Ee(),[a,c]=j.useState(!1),[l,u]=j.useState(""),[d,C]=j.useState(""),[g,h]=j.useState(""),[m,N]=j.useState(""),[x,f]=j.useState(""),[y,p]=j.useState(!1);j.useEffect(()=>{e&&u(e.display_name??""),s?C(e?.email??""):t&&C(t.email??"")},[e,t,s]);const w=async()=>{if(t){c(!0);try{const{error:b}=await T.from("profiles").update({display_name:l.trim(),updated_at:new Date().toISOString()}).eq("id",t.id);if(b)throw b;r({title:"Profile updated"}),n.invalidateQueries({queryKey:["profile"]})}catch(b){r({title:"Error",description:b.message,variant:"destructive"})}finally{c(!1)}}},E=async()=>{if(!(!d.trim()||d===t?.email)){c(!0);try{const{error:b}=await T.auth.updateUser({email:d.trim()});if(b)throw b;r({title:"Confirmation sent",description:"Check your new email to confirm the change."})}catch(b){r({title:"Error",description:b.message,variant:"destructive"})}finally{c(!1)}}},S=async()=>{if(!Dt(m)){r({title:"Password too weak",description:"Please meet all password requirements.",variant:"destructive"});return}if(m!==x){r({title:"Passwords don't match",variant:"destructive"});return}if(!g){r({title:"Current password required",variant:"destructive"});return}p(!0);try{const{error:b}=await T.auth.signInWithPassword({email:t?.email??"",password:g});if(b){r({title:"Current password is incorrect",variant:"destructive"});return}const{error:I}=await T.auth.updateUser({password:m});if(I)throw I;r({title:"Password updated!"}),h(""),N(""),f("")}catch(b){r({title:"Error",description:b.message,variant:"destructive"})}finally{p(!1)}},A=m&&x&&m===x,P=x&&m!==x;return o?i.jsx($e,{children:i.jsx("div",{className:"flex justify-center py-16",children:i.jsx(D,{className:"w-5 h-5 animate-spin text-muted-foreground"})})}):i.jsxs($e,{children:[i.jsx("h1",{className:"text-xl font-medium text-foreground mb-6",children:"Settings"}),i.jsxs("div",{className:"max-w-lg space-y-8",children:[i.jsxs("div",{className:"border border-border rounded-lg p-5",children:[i.jsxs("h2",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[i.jsx(Rt,{className:"w-4 h-4 text-muted-foreground"})," Profile Info"]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(V,{children:"Display Name"}
18),i.jsx(H,{value:l,onChange:b=>u(Pt(b.target.value)),placeholder:"Your name",maxLength:100,disabled:s})]}),!s&&i.jsxs(k,{onClick:w,disabled:a,size:"sm",children:[a?i.jsx(D,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):i.jsx(Lt,{className:"w-3.5 h-3.5 mr-1.5"}),"Save Name"]})]})]}),i.jsx(In,{preferredCityId:e?.preferred_city_id}),i.jsx(Mn,{}),s?i.jsxs("div",{className:"border border-border rounded-lg p-5",children:[i.jsxs("h2",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[i.jsx(ue,{className:"w-4 h-4 text-muted-foreground"})," Email Address"]}),i.jsx("p",{className:"text-sm text-foreground",children:d||"No email on file"})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"border border-border rounded-lg p-5",children:[i.jsxs("h2",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[i.jsx(ue,{className:"w-4 h-4 text-muted-foreground"})," Email Address"]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(V,{children:"Email"}),i.jsx(H,{type:"email",value:d,onChange:b=>C(b.target.value),placeholder:"[email protected]",maxLength:255}),d!==t?.email&&i.jsx("p",{className:"text-xs text-muted-foreground",children:"A confirmation will be sent to your new email."})]}),i.jsxs(k,{onClick:E,disabled:a||d===t?.email||!d.trim(),size:"sm",variant:"outline",children:[a?i.jsx(D,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):i.jsx(ue,{className:"w-3.5 h-3.5 mr-1.5"}),"Update Email"]})]})]}),i.jsxs("div",{className:"border border-border rounded-lg p-5",children:[i.jsxs("h2",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[i.jsx(qe,{className:"w-4 h-4 text-muted-foreground"})," Change Password"]}),i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"space-y-2",children:[i.jsx(V,{children:"Current Password"}),i.jsx(ye,{value:g,onChange:h,placeholder:"Enter current password"})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(V,{children:"New Password"}),i.jsx(ye,{value:m,onChange:N,placeholder:"Min 8 characters"}),i.jsx(Bn,{password:m}),m&&i.jsx("div",{className:"space-y-1.5 text-xs",children:It(m).map(b=>i.jsxs("div",{className:`flex items-center gap-1.5 ${b.met?"text-green-500":"text-muted-foreground"}`,children:[b.met?i.jsx(kt,{className:"w-3 h-3"}):i.jsx(St,{className:"w-3 h-3"}),b.label]},b.key))})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx(V,{children:"Confirm New Password"}),i.jsx(ye,{value:x,onChange:f,placeholder:"Repeat password"}),A&&i.jsx("p",{className:"text-xs text-green-500",children:"Passwords match â"}),P&&i.jsx("p",{className:"text-xs text-destructive",children:"Passwords don't match"})]}),i.jsxs(k,{onClick:S,disabled:y||!m||!g,size:"sm",variant:"outline",children:[y?i.jsx(D,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):i.jsx(qe,{className:"w-3.5 h-3.5 mr-1.5"}),"Update Password"]})]})]}),i.jsx(Pn,{}),i.jsx(Dn,{})]})]})]})};export{fr as default};
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.