/")+"/"),Na(i,t,r,"",function(p){return p})):i!=null&&(es(i)&&(i=uf(i,r+(!i.key||o&&o.key===i.key?"":(""+i.key).replace(Ql,"/")+"/")+e)),t.push(i)),1;if(o=0,a=a===""?".":a+":",Vl(e))for(var l=0;l"u")return;const e=(t=window.Telegram)==null?void 0:t.WebApp;if(e){if(typeof e.showAlert=="function"&&e.showAlert.__yodaccStub!==!0){const r=jf;r.__yodaccStub=!0,e.showAlert=r}if(typeof e.showPopup=="function"&&e.showPopup.__yodaccStub!==!0){const r=kf;r.__yodaccStub=!0,e.showPopup=r}if(typeof e.showConfirm=="function"&&e.showConfirm.__yodaccStub!==!0){const r=Nf;r.__yodaccStub=!0,e.showConfirm=r}}}let Sf=0;function Gl(){rs(),Sf++<80&&setTimeout(Gl,50)}rs(),Gl(),typeof document<"u"&&document.addEventListener("DOMContentLoaded",rs);var ns={},Jl={exports:{}},gt={},Xl={exports:{}},Zl={};/** * @license React * scheduler.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */(function(e){function t(E,F){var W=E.length;E.push(F);e:for(;0>>1,Y=E[J];if(0>>1;Ji(Q,W))hei(ye,Q)?(E[J]=ye,E[he]=W,J=he):(E[J]=Q,E[oe]=W,J=oe);else if(hei(ye,W))E[J]=ye,E[he]=W,J=he;else break e}}return F}function i(E,F){var W=E.sortIndex-F.sortIndex;return W!==0?W:E.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();e.unstable_now=function(){return o.now()-l}}var d=[],p=[],x=1,b=null,m=3,w=!1,j=!1,C=!1,q=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,u=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function f(E){for(var F=r(p);F!==null;){if(F.callback===null)a(p);else if(F.startTime<=E)a(p),F.sortIndex=F.expirationTime,t(d,F);else break;F=r(p)}}function y(E){if(C=!1,f(E),!j)if(r(d)!==null)j=!0,$(L);else{var F=r(p);F!==null&&X(y,F.startTime-E)}}function L(E,F){j=!1,C&&(C=!1,g(D),D=-1),w=!0;var W=m;try{for(f(F),b=r(d);b!==null&&(!(b.expirationTime>F)||E&&!pe());){var J=b.callback;if(typeof J=="function"){b.callback=null,m=b.priorityLevel;var Y=J(b.expirationTime<=F);F=e.unstable_now(),typeof Y=="function"?b.callback=Y:b===r(d)&&a(d),f(F)}else a(d);b=r(d)}if(b!==null)var ve=!0;else{var oe=r(p);oe!==null&&X(y,oe.startTime-F),ve=!1}return ve}finally{b=null,m=W,w=!1}}var P=!1,I=null,D=-1,R=5,U=-1;function pe(){return!(e.unstable_now()-UE||125J?(E.sortIndex=W,t(p,E),r(d)===null&&E===r(p)&&(C?(g(D),D=-1):C=!0,X(y,W-J))):(E.sortIndex=Y,t(d,E),j||w||(j=!0,$(L))),E},e.unstable_shouldYield=pe,e.unstable_wrapCallback=function(E){var F=m;return function(){var W=m;m=F;try{return E.apply(this,arguments)}finally{m=W}}}})(Zl),Xl.exports=Zl;var Ef=Xl.exports;/** * @license React * react-dom.production.min.js * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Cf=c,xt=Ef;function _(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),as=Object.prototype.hasOwnProperty,zf=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,td={},rd={};function Pf(e){return as.call(rd,e)?!0:as.call(td,e)?!1:zf.test(e)?rd[e]=!0:(td[e]=!0,!1)}function Tf(e,t,r,a){if(r!==null&&r.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return a?!1:r!==null?!r.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function _f(e,t,r,a){if(t===null||typeof t>"u"||Tf(e,t,r,a))return!0;if(a)return!1;if(r!==null)switch(r.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function tt(e,t,r,a,i,s,o){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=a,this.attributeNamespace=i,this.mustUseProperty=r,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var $e={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){$e[e]=new tt(e,0,!1,e,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];$e[t]=new tt(t,1,!1,e[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(e){$e[e]=new tt(e,2,!1,e.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){$e[e]=new tt(e,2,!1,e,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){$e[e]=new tt(e,3,!1,e.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(e){$e[e]=new tt(e,3,!0,e,null,!1,!1)}),["capture","download"].forEach(function(e){$e[e]=new tt(e,4,!1,e,null,!1,!1)}),["cols","rows","size","span"].forEach(function(e){$e[e]=new tt(e,6,!1,e,null,!1,!1)}),["rowSpan","start"].forEach(function(e){$e[e]=new tt(e,5,!1,e.toLowerCase(),null,!1,!1)});var is=/[\-:]([a-z])/g;function ss(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(is,ss);$e[t]=new tt(t,1,!1,e,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(is,ss);$e[t]=new tt(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(is,ss);$e[t]=new tt(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(e){$e[e]=new tt(e,1,!1,e.toLowerCase(),null,!1,!1)}),$e.xlinkHref=new tt("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(e){$e[e]=new tt(e,1,!1,e.toLowerCase(),null,!0,!0)});function os(e,t,r,a){var i=$e.hasOwnProperty(t)?$e[t]:null;(i!==null?i.type!==0:a||!(2l||i[o]!==s[l]){var d=` `+i[o].replace(" at new "," at ");return e.displayName&&d.includes("")&&(d=d.replace("",e.displayName)),d}while(1<=o&&0<=l);break}}}finally{hs=!1,Error.prepareStackTrace=r}return(e=e?e.displayName||e.name:"")?Pn(e):""}function Lf(e){switch(e.tag){case 5:return Pn(e.type);case 16:return Pn("Lazy");case 13:return Pn("Suspense");case 19:return Pn("SuspenseList");case 0:case 2:case 15:return e=gs(e.type,!1),e;case 11:return e=gs(e.type.render,!1),e;case 1:return e=gs(e.type,!0),e;default:return""}}function xs(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Kr:return"Fragment";case Yr:return"Portal";case ds:return"Profiler";case ls:return"StrictMode";case us:return"Suspense";case ps:return"SuspenseList"}if(typeof e=="object")switch(e.$typeof){case ad:return(e.displayName||"Context")+".Consumer";case nd:return(e._context.displayName||"Context")+".Provider";case cs:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case fs:return t=e.displayName||null,t!==null?t:xs(e.type)||"Memo";case lr:t=e._payload,e=e._init;try{return xs(e(t))}catch{}}return null}function If(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return xs(t);case 8:return t===ls?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function dr(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function od(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Mf(e){var t=od(e)?"checked":"value",r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),a=""+e[t];if(!e.hasOwnProperty(t)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var i=r.get,s=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(o){a=""+o,s.call(this,o)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return a},setValue:function(o){a=""+o},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function za(e){e._valueTracker||(e._valueTracker=Mf(e))}function ld(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var r=t.getValue(),a="";return e&&(a=od(e)?e.checked?"true":"false":e.value),e=a,e!==r?(t.setValue(e),!0):!1}function Pa(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function bs(e,t){var r=t.checked;return Se({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??e._wrapperState.initialChecked})}function dd(e,t){var r=t.defaultValue==null?"":t.defaultValue,a=t.checked!=null?t.checked:t.defaultChecked;r=dr(t.value!=null?t.value:r),e._wrapperState={initialChecked:a,initialValue:r,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function cd(e,t){t=t.checked,t!=null&&os(e,"checked",t,!1)}function vs(e,t){cd(e,t);var r=dr(t.value),a=t.type;if(r!=null)a==="number"?(r===0&&e.value===""||e.value!=r)&&(e.value=""+r):e.value!==""+r&&(e.value=""+r);else if(a==="submit"||a==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?ys(e,t.type,r):t.hasOwnProperty("defaultValue")&&ys(e,t.type,dr(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function ud(e,t,r){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var a=t.type;if(!(a!=="submit"&&a!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,r||t===e.value||(e.value=t),e.defaultValue=t}r=e.name,r!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,r!==""&&(e.name=r)}function ys(e,t,r){(t!=="number"||Pa(e.ownerDocument)!==e)&&(r==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+r&&(e.defaultValue=""+r))}var Tn=Array.isArray;function Gr(e,t,r,a){if(e=e.options,t){t={};for(var i=0;i"+t.valueOf().toString()+"",t=Ta.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function _n(e,t){if(t){var r=e.firstChild;if(r&&r===e.lastChild&&r.nodeType===3){r.nodeValue=t;return}}e.textContent=t}var Ln={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Af=["Webkit","ms","Moz","O"];Object.keys(Ln).forEach(function(e){Af.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ln[t]=Ln[e]})});function xd(e,t,r){return t==null||typeof t=="boolean"||t===""?"":r||typeof t!="number"||t===0||Ln.hasOwnProperty(e)&&Ln[e]?(""+t).trim():t+"px"}function bd(e,t){e=e.style;for(var r in t)if(t.hasOwnProperty(r)){var a=r.indexOf("--")===0,i=xd(r,t[r],a);r==="float"&&(r="cssFloat"),a?e.setProperty(r,i):e[r]=i}}var Df=Se({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ks(e,t){if(t){if(Df[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(_(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(_(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(_(61))}if(t.style!=null&&typeof t.style!="object")throw Error(_(62))}}function Ns(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ss=null;function Es(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Cs=null,Jr=null,Xr=null;function vd(e){if(e=ea(e)){if(typeof Cs!="function")throw Error(_(280));var t=e.stateNode;t&&(t=Za(t),Cs(e.stateNode,e.type,t))}}function yd(e){Jr?Xr?Xr.push(e):Xr=[e]:Jr=e}function wd(){if(Jr){var e=Jr,t=Xr;if(Xr=Jr=null,vd(e),t)for(e=0;e>>=0,e===0?32:31-(Qf(e)/Yf|0)|0}var Aa=64,Da=4194304;function Dn(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Fa(e,t){var r=e.pendingLanes;if(r===0)return 0;var a=0,i=e.suspendedLanes,s=e.pingedLanes,o=r&268435455;if(o!==0){var l=o&~i;l!==0?a=Dn(l):(s&=o,s!==0&&(a=Dn(s)))}else o=r&~i,o!==0?a=Dn(o):s!==0&&(a=Dn(s));if(a===0)return 0;if(t!==0&&t!==a&&!(t&i)&&(i=a&-a,s=t&-t,i>=s||i===16&&(s&4194240)!==0))return t;if(a&4&&(a|=r&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=a;0r;r++)t.push(e);return t}function Fn(e,t,r){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Mt(t),e[t]=r}function Xf(e,t){var r=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var a=e.eventTimes;for(e=e.expirationTimes;0=Wn),Kd=" ",Gd=!1;function Jd(e,t){switch(e){case"keyup":return Em.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Xd(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var tn=!1;function zm(e,t){switch(e){case"compositionend":return Xd(t);case"keypress":return t.which!==32?null:(Gd=!0,Kd);case"textInput":return e=t.data,e===Kd&&Gd?null:e;default:return null}}function Pm(e,t){if(tn)return e==="compositionend"||!Ws&&Jd(e,t)?(e=Vd(),Ua=Os=mr=null,tn=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:r,offset:t-e};e=a}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=ic(r)}}function oc(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?oc(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function lc(){for(var e=window,t=Pa();t instanceof e.HTMLIFrameElement;){try{var r=typeof t.contentWindow.location.href=="string"}catch{r=!1}if(r)e=t.contentWindow;else break;t=Pa(e.document)}return t}function Ys(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Rm(e){var t=lc(),r=e.focusedElem,a=e.selectionRange;if(t!==r&&r&&r.ownerDocument&&oc(r.ownerDocument.documentElement,r)){if(a!==null&&Ys(r)){if(t=a.start,e=a.end,e===void 0&&(e=t),"selectionStart"in r)r.selectionStart=t,r.selectionEnd=Math.min(e,r.value.length);else if(e=(t=r.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=r.textContent.length,s=Math.min(a.start,i);a=a.end===void 0?s:Math.min(a.end,i),!e.extend&&s>a&&(i=a,a=s,s=i),i=sc(r,s);var o=sc(r,a);i&&o&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==o.node||e.focusOffset!==o.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),s>a?(e.addRange(t),e.extend(o.node,o.offset)):(t.setEnd(o.node,o.offset),e.addRange(t)))}}for(t=[],e=r;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r=document.documentMode,rn=null,Ks=null,Kn=null,Gs=!1;function dc(e,t,r){var a=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;Gs||rn==null||rn!==Pa(a)||(a=rn,"selectionStart"in a&&Ys(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),Kn&&Yn(Kn,a)||(Kn=a,a=Ga(Ks,"onSelect"),0ln||(e.current=lo[ln],lo[ln]=null,ln--)}function be(e,t){ln++,lo[ln]=e.current,e.current=t}var br={},We=xr(br),st=xr(!1),Lr=br;function dn(e,t){var r=e.type.contextTypes;if(!r)return br;var a=e.stateNode;if(a&&a.__reactInternalMemoizedUnmaskedChildContext===t)return a.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in r)i[s]=t[s];return a&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function ot(e){return e=e.childContextTypes,e!=null}function ei(){je(st),je(We)}function Nc(e,t,r){if(We.current!==br)throw Error(_(168));be(We,t),be(st,r)}function Sc(e,t,r){var a=e.stateNode;if(t=t.childContextTypes,typeof a.getChildContext!="function")return r;a=a.getChildContext();for(var i in a)if(!(i in t))throw Error(_(108,If(e)||"Unknown",i));return Se({},r,a)}function ti(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||br,Lr=We.current,be(We,e),be(st,st.current),!0}function Ec(e,t,r){var a=e.stateNode;if(!a)throw Error(_(169));r?(e=Sc(e,t,Lr),a.__reactInternalMemoizedMergedChildContext=e,je(st),je(We),be(We,e)):je(st),be(st,r)}var Xt=null,ri=!1,co=!1;function Cc(e){Xt===null?Xt=[e]:Xt.push(e)}function Gm(e){ri=!0,Cc(e)}function vr(){if(!co&&Xt!==null){co=!0;var e=0,t=me;try{var r=Xt;for(me=1;e>=o,i-=o,Zt=1<<32-Mt(t)+i|r<D?(R=I,I=null):R=I.sibling;var U=m(g,I,f[D],y);if(U===null){I===null&&(I=R);break}e&&I&&U.alternate===null&&t(g,I),u=s(U,u,D),P===null?L=U:P.sibling=U,P=U,I=R}if(D===f.length)return r(g,I),Ne&&Mr(g,D),L;if(I===null){for(;DD?(R=I,I=null):R=I.sibling;var pe=m(g,I,U.value,y);if(pe===null){I===null&&(I=R);break}e&&I&&pe.alternate===null&&t(g,I),u=s(pe,u,D),P===null?L=pe:P.sibling=pe,P=pe,I=R}if(U.done)return r(g,I),Ne&&Mr(g,D),L;if(I===null){for(;!U.done;D++,U=f.next())U=b(g,U.value,y),U!==null&&(u=s(U,u,D),P===null?L=U:P.sibling=U,P=U);return Ne&&Mr(g,D),L}for(I=a(g,I);!U.done;D++,U=f.next())U=w(I,g,D,U.value,y),U!==null&&(e&&U.alternate!==null&&I.delete(U.key===null?D:U.key),u=s(U,u,D),P===null?L=U:P.sibling=U,P=U);return e&&I.forEach(function(ie){return t(g,ie)}),Ne&&Mr(g,D),L}function q(g,u,f,y){if(typeof f=="object"&&f!==null&&f.type===Kr&&f.key===null&&(f=f.props.children),typeof f=="object"&&f!==null){switch(f.$typeof){case Ca:e:{for(var L=f.key,P=u;P!==null;){if(P.key===L){if(L=f.type,L===Kr){if(P.tag===7){r(g,P.sibling),u=i(P,f.props.children),u.return=g,g=u;break e}}else if(P.elementType===L||typeof L=="object"&&L!==null&&L.$typeof===lr&&Ic(L)===P.type){r(g,P.sibling),u=i(P,f.props),u.ref=ta(g,P,f),u.return=g,g=u;break e}r(g,P);break}else t(g,P);P=P.sibling}f.type===Kr?(u=Ur(f.props.children,g.mode,y,f.key),u.return=g,g=u):(y=Ti(f.type,f.key,f.props,null,g.mode,y),y.ref=ta(g,u,f),y.return=g,g=y)}return o(g);case Yr:e:{for(P=f.key;u!==null;){if(u.key===P)if(u.tag===4&&u.stateNode.containerInfo===f.containerInfo&&u.stateNode.implementation===f.implementation){r(g,u.sibling),u=i(u,f.children||[]),u.return=g,g=u;break e}else{r(g,u);break}else t(g,u);u=u.sibling}u=ol(f,g.mode,y),u.return=g,g=u}return o(g);case lr:return P=f._init,q(g,u,P(f._payload),y)}if(Tn(f))return j(g,u,f,y);if(zn(f))return C(g,u,f,y);si(g,f)}return typeof f=="string"&&f!==""||typeof f=="number"?(f=""+f,u!==null&&u.tag===6?(r(g,u.sibling),u=i(u,f),u.return=g,g=u):(r(g,u),u=sl(f,g.mode,y),u.return=g,g=u),o(g)):r(g,u)}return q}var fn=Mc(!0),Ac=Mc(!1),oi=xr(null),li=null,mn=null,go=null;function xo(){go=mn=li=null}function bo(e){var t=oi.current;je(oi),e._currentValue=t}function vo(e,t,r){for(;e!==null;){var a=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,a!==null&&(a.childLanes|=t)):a!==null&&(a.childLanes&t)!==t&&(a.childLanes|=t),e===r)break;e=e.return}}function hn(e,t){li=e,go=mn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(lt=!0),e.firstContext=null)}function zt(e){var t=e._currentValue;if(go!==e)if(e={context:e,memoizedValue:t,next:null},mn===null){if(li===null)throw Error(_(308));mn=e,li.dependencies={lanes:0,firstContext:e}}else mn=mn.next=e;return t}var Ar=null;function yo(e){Ar===null?Ar=[e]:Ar.push(e)}function Dc(e,t,r,a){var i=t.interleaved;return i===null?(r.next=r,yo(t)):(r.next=i.next,i.next=r),t.interleaved=r,tr(e,a)}function tr(e,t){e.lanes|=t;var r=e.alternate;for(r!==null&&(r.lanes|=t),r=e,e=e.return;e!==null;)e.childLanes|=t,r=e.alternate,r!==null&&(r.childLanes|=t),r=e,e=e.return;return r.tag===3?r.stateNode:null}var yr=!1;function wo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Fc(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function rr(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function wr(e,t,r){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,de&2){var i=a.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),a.pending=t,tr(e,r)}return i=a.interleaved,i===null?(t.next=t,yo(a)):(t.next=i.next,i.next=t),a.interleaved=t,tr(e,r)}function di(e,t,r){if(t=t.updateQueue,t!==null&&(t=t.shared,(r&4194240)!==0)){var a=t.lanes;a&=e.pendingLanes,r|=a,t.lanes=r,Ms(e,r)}}function Rc(e,t){var r=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,r===a)){var i=null,s=null;if(r=r.firstBaseUpdate,r!==null){do{var o={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};s===null?i=s=o:s=s.next=o,r=r.next}while(r!==null);s===null?i=s=t:s=s.next=t}else i=s=t;r={baseState:a.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:a.shared,effects:a.effects},e.updateQueue=r;return}e=r.lastBaseUpdate,e===null?r.firstBaseUpdate=t:e.next=t,r.lastBaseUpdate=t}function ci(e,t,r,a){var i=e.updateQueue;yr=!1;var s=i.firstBaseUpdate,o=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var d=l,p=d.next;d.next=null,o===null?s=p:o.next=p,o=d;var x=e.alternate;x!==null&&(x=x.updateQueue,l=x.lastBaseUpdate,l!==o&&(l===null?x.firstBaseUpdate=p:l.next=p,x.lastBaseUpdate=d))}if(s!==null){var b=i.baseState;o=0,x=p=d=null,l=s;do{var m=l.lane,w=l.eventTime;if((a&m)===m){x!==null&&(x=x.next={eventTime:w,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var j=e,C=l;switch(m=t,w=r,C.tag){case 1:if(j=C.payload,typeof j=="function"){b=j.call(w,b,m);break e}b=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=C.payload,m=typeof j=="function"?j.call(w,b,m):j,m==null)break e;b=Se({},b,m);break e;case 2:yr=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,m=i.effects,m===null?i.effects=[l]:m.push(l))}else w={eventTime:w,lane:m,tag:l.tag,payload:l.payload,callback:l.callback,next:null},x===null?(p=x=w,d=b):x=x.next=w,o|=m;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;m=l,l=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(!0);if(x===null&&(d=b),i.baseState=d,i.firstBaseUpdate=p,i.lastBaseUpdate=x,t=i.shared.interleaved,t!==null){i=t;do o|=i.lane,i=i.next;while(i!==t)}else s===null&&(i.shared.lanes=0);Rr|=o,e.lanes=o,e.memoizedState=b}}function Oc(e,t,r){if(e=t.effects,t.effects=null,e!==null)for(t=0;tr?r:4,e(!0);var a=Eo.transition;Eo.transition={};try{e(!1),t()}finally{me=r,Eo.transition=a}}function au(){return Pt().memoizedState}function eh(e,t,r){var a=Sr(e);if(r={lane:a,action:r,hasEagerState:!1,eagerState:null,next:null},iu(e))su(t,r);else if(r=Dc(e,t,r,a),r!==null){var i=nt();$t(r,e,a,i),ou(r,t,a)}}function th(e,t,r){var a=Sr(e),i={lane:a,action:r,hasEagerState:!1,eagerState:null,next:null};if(iu(e))su(t,i);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var o=t.lastRenderedState,l=s(o,r);if(i.hasEagerState=!0,i.eagerState=l,At(l,o)){var d=t.interleaved;d===null?(i.next=i,yo(t)):(i.next=d.next,d.next=i),t.interleaved=i;return}}catch{}finally{}r=Dc(e,t,i,a),r!==null&&(i=nt(),$t(r,e,a,i),ou(r,t,a))}}function iu(e){var t=e.alternate;return e===Ce||t!==null&&t===Ce}function su(e,t){ia=fi=!0;var r=e.pending;r===null?t.next=t:(t.next=r.next,r.next=t),e.pending=t}function ou(e,t,r){if(r&4194240){var a=t.lanes;a&=e.pendingLanes,r|=a,t.lanes=r,Ms(e,r)}}var gi={readContext:zt,useCallback:He,useContext:He,useEffect:He,useImperativeHandle:He,useInsertionEffect:He,useLayoutEffect:He,useMemo:He,useReducer:He,useRef:He,useState:He,useDebugValue:He,useDeferredValue:He,useTransition:He,useMutableSource:He,useSyncExternalStore:He,useId:He,unstable_isNewReconciler:!1},rh={readContext:zt,useCallback:function(e,t){return Wt().memoizedState=[e,t===void 0?null:t],e},useContext:zt,useEffect:Gc,useImperativeHandle:function(e,t,r){return r=r!=null?r.concat([e]):null,mi(4194308,4,Zc.bind(null,t,e),r)},useLayoutEffect:function(e,t){return mi(4194308,4,e,t)},useInsertionEffect:function(e,t){return mi(4,2,e,t)},useMemo:function(e,t){var r=Wt();return t=t===void 0?null:t,e=e(),r.memoizedState=[e,t],e},useReducer:function(e,t,r){var a=Wt();return t=r!==void 0?r(t):t,a.memoizedState=a.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},a.queue=e,e=e.dispatch=eh.bind(null,Ce,e),[a.memoizedState,e]},useRef:function(e){var t=Wt();return e={current:e},t.memoizedState=e},useState:Yc,useDebugValue:Io,useDeferredValue:function(e){return Wt().memoizedState=e},useTransition:function(){var e=Yc(!1),t=e[0];return e=Zm.bind(null,e[1]),Wt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,r){var a=Ce,i=Wt();if(Ne){if(r===void 0)throw Error(_(407));r=r()}else{if(r=t(),Re===null)throw Error(_(349));Fr&30||Vc(a,t,r)}i.memoizedState=r;var s={value:r,getSnapshot:t};return i.queue=s,Gc(Wc.bind(null,a,s,e),[e]),a.flags|=2048,la(9,qc.bind(null,a,s,r,t),void 0,null),r},useId:function(){var e=Wt(),t=Re.identifierPrefix;if(Ne){var r=er,a=Zt;r=(a&~(1<<32-Mt(a)-1)).toString(32)+r,t=":"+t+"R"+r,r=sa++,0<\/script>",e=e.removeChild(e.firstChild)):typeof a.is=="string"?e=o.createElement(r,{is:a.is}):(e=o.createElement(r),r==="select"&&(o=e,a.multiple?o.multiple=!0:a.size&&(o.size=a.size))):e=o.createElementNS(e,r),e[Vt]=t,e[Zn]=a,Cu(e,t,!1,!1),t.stateNode=e;e:{switch(o=Ns(r,a),r){case"dialog":we("cancel",e),we("close",e),i=a;break;case"iframe":case"object":case"embed":we("load",e),i=a;break;case"video":case"audio":for(i=0;iyn&&(t.flags|=128,a=!0,da(s,!1),t.lanes=4194304)}else{if(!a)if(e=ui(o),e!==null){if(t.flags|=128,a=!0,r=e.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),da(s,!0),s.tail===null&&s.tailMode==="hidden"&&!o.alternate&&!Ne)return Qe(t),null}else 2*Te()-s.renderingStartTime>yn&&r!==1073741824&&(t.flags|=128,a=!0,da(s,!1),t.lanes=4194304);s.isBackwards?(o.sibling=t.child,t.child=o):(r=s.last,r!==null?r.sibling=o:t.child=o,s.last=o)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=Te(),t.sibling=null,r=Ee.current,be(Ee,a?r&1|2:r&1),t):(Qe(t),null);case 22:case 23:return nl(),a=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==a&&(t.flags|=8192),a&&t.mode&1?wt&1073741824&&(Qe(t),t.subtreeFlags&6&&(t.flags|=8192)):Qe(t),null;case 24:return null;case 25:return null}throw Error(_(156,t.tag))}function ch(e,t){switch(po(t),t.tag){case 1:return ot(t.type)&&ei(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return gn(),je(st),je(We),So(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return ko(t),null;case 13:if(je(Ee),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(_(340));pn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return je(Ee),null;case 4:return gn(),null;case 10:return bo(t.type._context),null;case 22:case 23:return nl(),null;case 24:return null;default:return null}}var yi=!1,Ye=!1,uh=typeof WeakSet=="function"?WeakSet:Set,B=null;function bn(e,t){var r=e.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(a){Pe(e,t,a)}else r.current=null}function Wo(e,t,r){try{r()}catch(a){Pe(e,t,a)}}var Tu=!1;function ph(e,t){if(ro=$a,e=lc(),Ys(e)){if("selectionStart"in e)var r={start:e.selectionStart,end:e.selectionEnd};else e:{r=(r=e.ownerDocument)&&r.defaultView||window;var a=r.getSelection&&r.getSelection();if(a&&a.rangeCount!==0){r=a.anchorNode;var i=a.anchorOffset,s=a.focusNode;a=a.focusOffset;try{r.nodeType,s.nodeType}catch{r=null;break e}var o=0,l=-1,d=-1,p=0,x=0,b=e,m=null;t:for(;;){for(var w;b!==r||i!==0&&b.nodeType!==3||(l=o+i),b!==s||a!==0&&b.nodeType!==3||(d=o+a),b.nodeType===3&&(o+=b.nodeValue.length),(w=b.firstChild)!==null;)m=b,b=w;for(;;){if(b===e)break t;if(m===r&&++p===i&&(l=o),m===s&&++x===a&&(d=o),(w=b.nextSibling)!==null)break;b=m,m=b.parentNode}b=w}r=l===-1||d===-1?null:{start:l,end:d}}else r=null}r=r||{start:0,end:0}}else r=null;for(no={focusedElem:e,selectionRange:r},$a=!1,B=t;B!==null;)if(t=B,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,B=e;else for(;B!==null;){t=B;try{var j=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(j!==null){var C=j.memoizedProps,q=j.memoizedState,g=t.stateNode,u=g.getSnapshotBeforeUpdate(t.elementType===t.type?C:Ft(t.type,C),q);g.__reactInternalSnapshotBeforeUpdate=u}break;case 3:var f=t.stateNode.containerInfo;f.nodeType===1?f.textContent="":f.nodeType===9&&f.documentElement&&f.removeChild(f.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(_(163))}}catch(y){Pe(t,t.return,y)}if(e=t.sibling,e!==null){e.return=t.return,B=e;break}B=t.return}return j=Tu,Tu=!1,j}function ca(e,t,r){var a=t.updateQueue;if(a=a!==null?a.lastEffect:null,a!==null){var i=a=a.next;do{if((i.tag&e)===e){var s=i.destroy;i.destroy=void 0,s!==void 0&&Wo(t,r,s)}i=i.next}while(i!==a)}}function wi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var r=t=t.next;do{if((r.tag&e)===e){var a=r.create;r.destroy=a()}r=r.next}while(r!==t)}}function Ho(e){var t=e.ref;if(t!==null){var r=e.stateNode;switch(e.tag){case 5:e=r;break;default:e=r}typeof t=="function"?t(e):t.current=e}}function _u(e){var t=e.alternate;t!==null&&(e.alternate=null,_u(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Vt],delete t[Zn],delete t[oo],delete t[Ym],delete t[Km])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Lu(e){return e.tag===5||e.tag===3||e.tag===4}function Iu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Lu(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Qo(e,t,r){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?r.nodeType===8?r.parentNode.insertBefore(e,t):r.insertBefore(e,t):(r.nodeType===8?(t=r.parentNode,t.insertBefore(e,r)):(t=r,t.appendChild(e)),r=r._reactRootContainer,r!=null||t.onclick!==null||(t.onclick=Xa));else if(a!==4&&(e=e.child,e!==null))for(Qo(e,t,r),e=e.sibling;e!==null;)Qo(e,t,r),e=e.sibling}function Yo(e,t,r){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?r.insertBefore(e,t):r.appendChild(e);else if(a!==4&&(e=e.child,e!==null))for(Yo(e,t,r),e=e.sibling;e!==null;)Yo(e,t,r),e=e.sibling}var Be=null,Rt=!1;function jr(e,t,r){for(r=r.child;r!==null;)Mu(e,t,r),r=r.sibling}function Mu(e,t,r){if(Ut&&typeof Ut.onCommitFiberUnmount=="function")try{Ut.onCommitFiberUnmount(Ma,r)}catch{}switch(r.tag){case 5:Ye||bn(r,t);case 6:var a=Be,i=Rt;Be=null,jr(e,t,r),Be=a,Rt=i,Be!==null&&(Rt?(e=Be,r=r.stateNode,e.nodeType===8?e.parentNode.removeChild(r):e.removeChild(r)):Be.removeChild(r.stateNode));break;case 18:Be!==null&&(Rt?(e=Be,r=r.stateNode,e.nodeType===8?so(e.parentNode,r):e.nodeType===1&&so(e,r),Un(e)):so(Be,r.stateNode));break;case 4:a=Be,i=Rt,Be=r.stateNode.containerInfo,Rt=!0,jr(e,t,r),Be=a,Rt=i;break;case 0:case 11:case 14:case 15:if(!Ye&&(a=r.updateQueue,a!==null&&(a=a.lastEffect,a!==null))){i=a=a.next;do{var s=i,o=s.destroy;s=s.tag,o!==void 0&&(s&2||s&4)&&Wo(r,t,o),i=i.next}while(i!==a)}jr(e,t,r);break;case 1:if(!Ye&&(bn(r,t),a=r.stateNode,typeof a.componentWillUnmount=="function"))try{a.props=r.memoizedProps,a.state=r.memoizedState,a.componentWillUnmount()}catch(l){Pe(r,t,l)}jr(e,t,r);break;case 21:jr(e,t,r);break;case 22:r.mode&1?(Ye=(a=Ye)||r.memoizedState!==null,jr(e,t,r),Ye=a):jr(e,t,r);break;default:jr(e,t,r)}}function Au(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var r=e.stateNode;r===null&&(r=e.stateNode=new uh),t.forEach(function(a){var i=wh.bind(null,e,a);r.has(a)||(r.add(a),a.then(i,i))})}}function Ot(e,t){var r=t.deletions;if(r!==null)for(var a=0;ai&&(i=o),a&=~s}if(a=i,a=Te()-a,a=(120>a?120:480>a?480:1080>a?1080:1920>a?1920:3e3>a?3e3:4320>a?4320:1960*mh(a/1960))-a,10e?16:e,Nr===null)var a=!1;else{if(e=Nr,Nr=null,Ei=0,de&6)throw Error(_(331));var i=de;for(de|=4,B=e.current;B!==null;){var s=B,o=s.child;if(B.flags&16){var l=s.deletions;if(l!==null){for(var d=0;dTe()-Jo?$r(e,0):Go|=r),ct(e,t)}function Yu(e,t){t===0&&(e.mode&1?(t=Da,Da<<=1,!(Da&130023424)&&(Da=4194304)):t=1);var r=nt();e=tr(e,t),e!==null&&(Fn(e,t,r),ct(e,r))}function yh(e){var t=e.memoizedState,r=0;t!==null&&(r=t.retryLane),Yu(e,r)}function wh(e,t){var r=0;switch(e.tag){case 13:var a=e.stateNode,i=e.memoizedState;i!==null&&(r=i.retryLane);break;case 19:a=e.stateNode;break;default:throw Error(_(314))}a!==null&&a.delete(t),Yu(e,r)}var Ku;Ku=function(e,t,r){if(e!==null)if(e.memoizedProps!==t.pendingProps||st.current)lt=!0;else{if(!(e.lanes&r)&&!(t.flags&128))return lt=!1,lh(e,t,r);lt=!!(e.flags&131072)}else lt=!1,Ne&&t.flags&1048576&&zc(t,ai,t.index);switch(t.lanes=0,t.tag){case 2:var a=t.type;vi(e,t),e=t.pendingProps;var i=dn(t,We.current);hn(t,r),i=zo(null,t,a,e,i,r);var s=Po();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ot(a)?(s=!0,ti(t)):s=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,wo(t),i.updater=xi,t.stateNode=i,i._reactInternals=t,Ao(t,a,e,r),t=Oo(null,t,a,!0,s,r)):(t.tag=0,Ne&&s&&uo(t),rt(null,t,i,r),t=t.child),t;case 16:a=t.elementType;e:{switch(vi(e,t),e=t.pendingProps,i=a._init,a=i(a._payload),t.type=a,i=t.tag=kh(a),e=Ft(a,e),i){case 0:t=Ro(null,t,a,e,r);break e;case 1:t=wu(null,t,a,e,r);break e;case 11:t=gu(null,t,a,e,r);break e;case 14:t=xu(null,t,a,Ft(a.type,e),r);break e}throw Error(_(306,a,""))}return t;case 0:return a=t.type,i=t.pendingProps,i=t.elementType===a?i:Ft(a,i),Ro(e,t,a,i,r);case 1:return a=t.type,i=t.pendingProps,i=t.elementType===a?i:Ft(a,i),wu(e,t,a,i,r);case 3:e:{if(ju(t),e===null)throw Error(_(387));a=t.pendingProps,s=t.memoizedState,i=s.element,Fc(e,t),ci(t,a,null,r);var o=t.memoizedState;if(a=o.element,s.isDehydrated)if(s={element:a,isDehydrated:!1,cache:o.cache,pendingSuspenseBoundaries:o.pendingSuspenseBoundaries,transitions:o.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){i=xn(Error(_(423)),t),t=ku(e,t,a,r,i);break e}else if(a!==i){i=xn(Error(_(424)),t),t=ku(e,t,a,r,i);break e}else for(yt=gr(t.stateNode.containerInfo.firstChild),vt=t,Ne=!0,Dt=null,r=Ac(t,null,a,r),t.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(pn(),a===i){t=nr(e,t,r);break e}rt(e,t,a,r)}t=t.child}return t;case 5:return $c(t),e===null&&mo(t),a=t.type,i=t.pendingProps,s=e!==null?e.memoizedProps:null,o=i.children,ao(a,i)?o=null:s!==null&&ao(a,s)&&(t.flags|=32),yu(e,t),rt(e,t,o,r),t.child;case 6:return e===null&&mo(t),null;case 13:return Nu(e,t,r);case 4:return jo(t,t.stateNode.containerInfo),a=t.pendingProps,e===null?t.child=fn(t,null,a,r):rt(e,t,a,r),t.child;case 11:return a=t.type,i=t.pendingProps,i=t.elementType===a?i:Ft(a,i),gu(e,t,a,i,r);case 7:return rt(e,t,t.pendingProps,r),t.child;case 8:return rt(e,t,t.pendingProps.children,r),t.child;case 12:return rt(e,t,t.pendingProps.children,r),t.child;case 10:e:{if(a=t.type._context,i=t.pendingProps,s=t.memoizedProps,o=i.value,be(oi,a._currentValue),a._currentValue=o,s!==null)if(At(s.value,o)){if(s.children===i.children&&!st.current){t=nr(e,t,r);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var l=s.dependencies;if(l!==null){o=s.child;for(var d=l.firstContext;d!==null;){if(d.context===a){if(s.tag===1){d=rr(-1,r&-r),d.tag=2;var p=s.updateQueue;if(p!==null){p=p.shared;var x=p.pending;x===null?d.next=d:(d.next=x.next,x.next=d),p.pending=d}}s.lanes|=r,d=s.alternate,d!==null&&(d.lanes|=r),vo(s.return,r,t),l.lanes|=r;break}d=d.next}}else if(s.tag===10)o=s.type===t.type?null:s.child;else if(s.tag===18){if(o=s.return,o===null)throw Error(_(341));o.lanes|=r,l=o.alternate,l!==null&&(l.lanes|=r),vo(o,r,t),o=s.sibling}else o=s.child;if(o!==null)o.return=s;else for(o=s;o!==null;){if(o===t){o=null;break}if(s=o.sibling,s!==null){s.return=o.return,o=s;break}o=o.return}s=o}rt(e,t,i.children,r),t=t.child}return t;case 9:return i=t.type,a=t.pendingProps.children,hn(t,r),i=zt(i),a=a(i),t.flags|=1,rt(e,t,a,r),t.child;case 14:return a=t.type,i=Ft(a,t.pendingProps),i=Ft(a.type,i),xu(e,t,a,i,r);case 15:return bu(e,t,t.type,t.pendingProps,r);case 17:return a=t.type,i=t.pendingProps,i=t.elementType===a?i:Ft(a,i),vi(e,t),t.tag=1,ot(a)?(e=!0,ti(t)):e=!1,hn(t,r),du(t,a,i),Ao(t,a,i,r),Oo(null,t,a,!0,e,r);case 19:return Eu(e,t,r);case 22:return vu(e,t,r)}throw Error(_(156,t.tag))};function Gu(e,t){return Pd(e,t)}function jh(e,t,r,a){this.tag=e,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=a,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _t(e,t,r,a){return new jh(e,t,r,a)}function il(e){return e=e.prototype,!(!e||!e.isReactComponent)}function kh(e){if(typeof e=="function")return il(e)?1:0;if(e!=null){if(e=e.$typeof,e===cs)return 11;if(e===fs)return 14}return 2}function Cr(e,t){var r=e.alternate;return r===null?(r=_t(e.tag,t,e.key,e.mode),r.elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=t,r.type=e.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=e.flags&14680064,r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,t=e.dependencies,r.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r}function Ti(e,t,r,a,i,s){var o=2;if(a=e,typeof e=="function")il(e)&&(o=1);else if(typeof e=="string")o=5;else e:switch(e){case Kr:return Ur(r.children,i,s,t);case ls:o=8,i|=8;break;case ds:return e=_t(12,r,t,i|2),e.elementType=ds,e.lanes=s,e;case us:return e=_t(13,r,t,i),e.elementType=us,e.lanes=s,e;case ps:return e=_t(19,r,t,i),e.elementType=ps,e.lanes=s,e;case id:return _i(r,i,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$typeof){case nd:o=10;break e;case ad:o=9;break e;case cs:o=11;break e;case fs:o=14;break e;case lr:o=16,a=null;break e}throw Error(_(130,e==null?e:typeof e,""))}return t=_t(o,r,t,i),t.elementType=e,t.type=a,t.lanes=s,t}function Ur(e,t,r,a){return e=_t(7,e,a,t),e.lanes=r,e}function _i(e,t,r,a){return e=_t(22,e,a,t),e.elementType=id,e.lanes=r,e.stateNode={isHidden:!1},e}function sl(e,t,r){return e=_t(6,e,null,t),e.lanes=r,e}function ol(e,t,r){return t=_t(4,e.children!==null?e.children:[],e.key,t),t.lanes=r,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Nh(e,t,r,a,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Is(0),this.expirationTimes=Is(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Is(0),this.identifierPrefix=a,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function ll(e,t,r,a,i,s,o,l,d){return e=new Nh(e,t,r,l,d),t===1?(t=1,s===!0&&(t|=8)):t=0,s=_t(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:a,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},wo(s),e}function Sh(e,t,r){var a=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(rp)}catch(e){console.error(e)}}rp(),Jl.exports=gt;var np=Jl.exports,ap=np;ns.createRoot=ap.createRoot,ns.hydrateRoot=ap.hydrateRoot;const pl="autoshop_access_token";function Th(){if(typeof sessionStorage>"u")return null;try{return sessionStorage.getItem(pl)}catch{return null}}function ip(e){if(!(typeof sessionStorage>"u"))try{e?sessionStorage.setItem(pl,e):sessionStorage.removeItem(pl)}catch{}}function sp(){ip(null)}function _h(){const e=Th();return e?{Authorization:`Bearer ${e}`}:{}}function Lh(){const e="/api";return String(e).trim()===""?"/api":String(e).replace(/\/$/,"")}const Ih=Lh();async function ne(e,t={}){const{skipAuth:r=!1,...a}=t,i={...a.headers||{}};return r||Object.assign(i,_h()),fetch(`${Ih}${e}`,{...a,headers:i})}async function ae(e,{authCall:t=!1}={}){if(!e.ok){const i=(await e.text()).trim();if(i.startsWith(""u")return null;const e=(a=window.Telegram)==null?void 0:a.WebApp;if(!e)return null;let t=(i=e.initDataUnsafe)==null?void 0:i.user;if(t)return t;const r=e.initData;if(typeof r=="string"&&r.length>0)try{const o=new URLSearchParams(r).get("user");if(o)return JSON.parse(o)}catch{}return null}function gl(){const[e,t]=c.useState(()=>gp());return c.useEffect(()=>{var l,d;const r=()=>{const p=gp();p&&t(x=>Number(x==null?void 0:x.id)===Number(p.id)?x:p)};r();const a=(l=window.Telegram)==null?void 0:l.WebApp;if(a)try{a.ready(),(d=a.expand)==null||d.call(a)}catch{}const i=[0,16,50,100,200,400,800,1500,3e3,5e3].map(p=>setTimeout(r,p)),s=()=>r();document.addEventListener("visibilitychange",s);let o=null;if(a&&typeof a.onEvent=="function"){const p=()=>r();a.onEvent("viewportChanged",p);try{a.onEvent("themeChanged",p)}catch{}o=()=>{var x,b;try{(x=a.offEvent)==null||x.call(a,"viewportChanged",p),(b=a.offEvent)==null||b.call(a,"themeChanged",p)}catch{}}}return()=>{i.forEach(clearTimeout),document.removeEventListener("visibilitychange",s),o==null||o()}},[]),e}function ag({onSpaceSelect:e,onOpenProfile:t}){const r=gl(),[a,i]=c.useState(!1),[s,o]=c.useState(null),l=(r==null?void 0:r.photo_url)||"",d=c.useMemo(()=>{const m=(r==null?void 0:r.username)||(r==null?void 0:r.first_name)||"Yoda CC";return String(m).trim()||"Yoda CC"},[r]),p=c.useMemo(()=>((r==null?void 0:r.username)||(r==null?void 0:r.first_name)||"Yoda").slice(0,2).toUpperCase(),[r]),x=(r==null?void 0:r.id)||"0000000000",b=c.useMemo(()=>{const m=[],w=(s==null?void 0:s.admin)||(s==null?void 0:s.owner),j=s==null?void 0:s.reseller;return w&&m.push("Admin"),(w||j)&&m.push("Revendeur"),m},[s]);return c.useEffect(()=>{var m,w,j,C,q;if((m=window.Telegram)!=null&&m.WebApp){window.Telegram.WebApp.ready(),window.Telegram.WebApp.expand();try{(j=(w=window.Telegram.WebApp).setHeaderColor)==null||j.call(w,"#050910"),(q=(C=window.Telegram.WebApp).setBackgroundColor)==null||q.call(C,"#050910")}catch{}}},[]),c.useEffect(()=>{let m=!0;async function w(){if(!(r!=null&&r.id)){m&&o(null);return}try{const j=await dp();m&&o(j&&typeof j=="object"?j:null)}catch{m&&o(null)}}return w(),()=>{m=!1}},[r]),c.useEffect(()=>{if(!a)return;const m=()=>{i(!1)},w=j=>{j.key==="Escape"&&i(!1)};return window.addEventListener("click",m),window.addEventListener("keydown",w),()=>{window.removeEventListener("click",m),window.removeEventListener("keydown",w)}},[a]),n.jsxs("div",{className:"header-shell",children:[n.jsxs("div",{className:"header-page-title",children:[n.jsx("h1",{children:"Yoda CC"}),n.jsx("p",{className:"header-page-subtitle",children:"Boutique"})]}),n.jsxs("header",{className:"header",children:[n.jsxs("div",{className:"header-left",children:[n.jsx("button",{type:"button",className:"header-logo header-logo-btn","aria-label":"Ouvrir mon profil",onClick:()=>t==null?void 0:t(),children:l?n.jsx("img",{src:l,alt:"",className:"header-logo-img"}):p}),n.jsxs("div",{className:"header-main",children:[n.jsx("h1",{className:"header-title",children:d}),n.jsxs("p",{className:"header-id",children:["ID: ",x]})]})]}),b.length?n.jsxs("div",{className:"spaces-menu",children:[n.jsxs("button",{type:"button",className:"spaces-trigger",onClick:m=>{m.stopPropagation(),i(w=>!w)},"aria-haspopup":"menu","aria-expanded":a,children:[n.jsx("span",{children:"Espaces"}),n.jsx("svg",{className:"spaces-trigger-chevron",viewBox:"0 0 12 12",fill:"none","aria-hidden":"true",children:n.jsx("path",{d:"M3 4.5 6 7.5 9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),a?n.jsx("div",{className:"spaces-dropdown",role:"menu",children:b.map(m=>n.jsx("button",{type:"button",className:"spaces-option spaces-option-role",role:"menuitem",onClick:()=>{i(!1),e==null||e(m)},children:m},m))}):null]}):n.jsx("div",{className:"header-client-label",children:"Compte client"})]}),n.jsx("div",{className:"header-separator","aria-hidden":"true"})]})}function ig(e){const t=Number(e);return Number.isNaN(t)?"0,00€":`${new Intl.NumberFormat("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:4}).format(t).replace(/\s/g,"")}€`}function sg({balanceRefreshKey:e=0,telegramId:t,authReady:r=!0}){var p,x,b,m;const[a,i]=c.useState(null),[s,o]=c.useState(!0),l=t??(typeof window<"u"?(m=(b=(x=(p=window.Telegram)==null?void 0:p.WebApp)==null?void 0:x.initDataUnsafe)==null?void 0:b.user)==null?void 0:m.id:null);c.useEffect(()=>{if(l==null){i(0),o(!1);return}let w=!1;return o(!0),Ah().then(j=>{w||i((j==null?void 0:j.balance_eur)??0)}).catch(()=>{w||i(0)}).finally(()=>{w||o(!1)}),()=>{w=!0}},[l,e,r]);const d=s?"…":ig(a??0);return n.jsx("section",{className:"top-section",children:n.jsx("div",{className:"top-section-head",children:n.jsxs("div",{className:"balance-card",children:[n.jsx("span",{className:"balance-inline-label",children:"SOLDE DISPONIBLE"}),n.jsx("span",{className:"balance-inline-amount",children:d})]})})})}function ha(e){const t=Number(e);return Number.isFinite(t)?new Intl.NumberFormat("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:2}).format(t)+" €":"0,00 €"}function og(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":new Intl.DateTimeFormat("fr-FR",{day:"2-digit",month:"2-digit",year:"numeric"}).format(t)}function lg({onClose:e,onOpenCommandes:t,onToast:r}){const a=gl(),[i,s]=c.useState(!0),[o,l]=c.useState(null),[d,p]=c.useState(""),x=(a==null?void 0:a.photo_url)||"",b=c.useMemo(()=>{const f=o==null?void 0:o.username;if(f&&String(f).trim())return String(f).trim().replace(/^@/,"");const y=[o==null?void 0:o.first_name,o==null?void 0:o.last_name].filter(Boolean).join(" ").trim();return y||(a==null?void 0:a.username)||(a==null?void 0:a.first_name)||"Yoda CC"},[o,a]),m=c.useMemo(()=>o!=null&&o.owner?"Propriétaire":o!=null&&o.admin?"Administrateur":o!=null&&o.reseller?"Revendeur":"Petit curieux",[o]),w=c.useCallback(async()=>{s(!0);try{const f=await dp();l(f&&typeof f=="object"?f:null)}catch{l(null),r==null||r("Impossible de charger le profil.","error")}finally{s(!1)}},[r]);c.useEffect(()=>{w()},[w]),c.useEffect(()=>{const f=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=f}},[]),c.useEffect(()=>{var P;const f=typeof window<"u"?(P=window.Telegram)==null?void 0:P.WebApp:null,y=f==null?void 0:f.BackButton;if(!y||typeof y.show!="function")return;const L=()=>e==null?void 0:e();try{y.show(),typeof y.onClick=="function"&&y.onClick(L)}catch{}return()=>{try{typeof y.offClick=="function"&&y.offClick(L),y.hide()}catch{}}},[e]);const j=(o==null?void 0:o.stats)||{},C=(a==null?void 0:a.id)??(o==null?void 0:o.telegram_id),q=c.useMemo(()=>{const f="YodaCCs_bot".trim().replace(/^@/,""),y=Number(C);return!f||!Number.isFinite(y)||y<=0?"":`https://t.me/${f}?start=ref_${y}`},[C]),g=async()=>{var f,y,L,P;if(!q){r==null||r("Ajoute VITE_TELEGRAM_BOT_USERNAME (sans @) dans .env puis reconstruis le site pour le lien de parrainage.","error");return}try{if((f=navigator.clipboard)!=null&&f.writeText)await navigator.clipboard.writeText(q);else throw new Error("clipboard");r==null||r("Lien copié dans le presse-papiers.","success")}catch{try{(P=(L=(y=window.Telegram)==null?void 0:y.WebApp)==null?void 0:L.showAlert)==null||P.call(L,`Copie ce lien : ${q}`)}catch{r==null||r("Copie impossible sur cet appareil.","error")}}},u=f=>{if(f.preventDefault(),!String(d||"").trim()){r==null||r("Saisis un code.","error");return}r==null||r("Les codes promo ne sont pas encore activés sur cette boutique.","error")};return n.jsxs("div",{className:"profile-overlay",role:"dialog","aria-modal":"true","aria-labelledby":"profile-title",children:[n.jsx("div",{className:"profile-overlay-backdrop",onClick:e,"aria-hidden":"true"}),n.jsxs("div",{className:"profile-sheet",children:[n.jsxs("header",{className:"profile-topbar",children:[n.jsx("h1",{id:"profile-title",className:"profile-topbar-title",children:"Profil"}),n.jsx("span",{className:"profile-topbar-balance",children:i?"…":ha((o==null?void 0:o.balance_eur)??0)})]}),n.jsxs("div",{className:"profile-user-card",children:[n.jsx("div",{className:"profile-user-avatar","aria-hidden":"true",children:x?n.jsx("img",{src:x,alt:"",className:"profile-user-avatar-img"}):n.jsx("svg",{className:"profile-user-avatar-placeholder",viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:n.jsx("path",{d:"M12 12a4 4 0 1 0-4-4 4 4 0 0 0 4 4Zm0 2c-4 0-7 2-7 4v1h14v-1c0-2-3-4-7-4Z",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})})}),n.jsxs("div",{className:"profile-user-text",children:[n.jsx("div",{className:"profile-user-name",children:i?"…":b}),n.jsx("div",{className:"profile-user-tag",children:m}),n.jsx("div",{className:"profile-user-date",children:og(o==null?void 0:o.created_at)})]}),n.jsx("button",{type:"button",className:"profile-info-dot","aria-label":"Infos compte",disabled:!0,children:"i"})]}),n.jsxs("form",{className:"profile-code-row",onSubmit:u,children:[n.jsx("input",{type:"text",className:"profile-code-input",placeholder:"Utiliser un code",value:d,onChange:f=>p(f.target.value),autoComplete:"off",spellCheck:"false"}),n.jsx("button",{type:"submit",className:"profile-code-submit","aria-label":"Valider le code",children:n.jsx("span",{"aria-hidden":!0,children:"→"})})]}),n.jsxs("button",{type:"button",className:"profile-banner-cta",onClick:()=>{e==null||e(),t==null||t()},children:[n.jsx("span",{children:"Voir mes commandes"}),n.jsx("span",{"aria-hidden":!0,className:"profile-banner-arrow",children:"→"})]}),n.jsxs("section",{className:"profile-stats-card","aria-labelledby":"profile-stats-money",children:[n.jsx("h2",{id:"profile-stats-money",className:"visually-hidden",children:"Statistiques financières"}),n.jsxs("ul",{className:"profile-stats-list",children:[n.jsxs("li",{children:[n.jsx("span",{children:"Dépôts totaux"}),n.jsx("strong",{children:ha(j.depositsTotalEur??0)})]}),n.jsxs("li",{children:[n.jsx("span",{children:"Total dépensé"}),n.jsx("strong",{children:ha(j.spentTotalEur??0)})]}),n.jsxs("li",{children:[n.jsx("span",{children:"Remise totale"}),n.jsx("strong",{children:ha(j.discountTotalEur??0)})]})]}),n.jsxs("button",{type:"button",className:"profile-action-btn",onClick:()=>r==null?void 0:r("Pour recharger, utilise le bot Telegram (menu dépôt / crypto).","success"),children:[n.jsx("span",{children:"Recharger votre solde"}),n.jsx("span",{"aria-hidden":!0,children:"→"})]})]}),n.jsxs("section",{className:"profile-stats-card profile-stats-card--ref","aria-labelledby":"profile-stats-ref",children:[n.jsx("h2",{id:"profile-stats-ref",className:"visually-hidden",children:"Parrainage"}),n.jsxs("ul",{className:"profile-stats-list",children:[n.jsxs("li",{children:[n.jsx("span",{children:"Vos parrainages"}),n.jsx("strong",{children:j.referralsCount??0})]}),n.jsxs("li",{children:[n.jsx("span",{children:"Pourcentage actuel"}),n.jsxs("strong",{children:[(Number((o==null?void 0:o.referralPercentDisplay)??0)||0).toLocaleString("fr-FR",{minimumFractionDigits:2,maximumFractionDigits:2}),"%"]})]}),n.jsxs("li",{children:[n.jsx("span",{children:"Argent gagné"}),n.jsx("strong",{children:ha((o==null?void 0:o.referralEarnedEur)??0)})]})]}),n.jsxs("button",{type:"button",className:"profile-action-btn",onClick:g,children:[n.jsx("span",{children:"Obtenir un lien de parrainage"}),n.jsx("span",{"aria-hidden":!0,children:"→"})]})]}),n.jsx("button",{type:"button",className:"profile-close-text",onClick:e,children:"Fermer"})]})]})}function dg({active:e,onChange:t}){return n.jsxs("div",{className:"filter-tabs",children:[n.jsx("button",{className:`filter-tab ${e==="tous"?"active":""}`,onClick:()=>t("tous"),children:"Liste"}),n.jsx("button",{className:`filter-tab ${e==="nouveautes"?"active":""}`,onClick:()=>t("nouveautes"),children:"Box"})]})}function cg({count:e,searchQuery:t,onSearchChange:r,onOpenFilters:a}){const i=e>1?"resultats":"resultat";return n.jsxs("section",{className:"featured-banner",children:[n.jsxs("div",{className:"banner-tools",children:[n.jsxs("label",{className:"banner-search",children:[n.jsxs("svg",{className:"banner-search-icon",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[n.jsx("circle",{cx:"9",cy:"9",r:"5.5",stroke:"currentColor",strokeWidth:"1.7"}),n.jsx("path",{d:"M13.5 13.5 17 17",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round"})]}),n.jsx("input",{type:"text",value:t,onChange:s=>r==null?void 0:r(s.target.value),placeholder:"Rechercher par bin, nom, ville","aria-label":"Rechercher un produit"})]}),n.jsxs("button",{type:"button",className:"banner-filter",onClick:a,children:[n.jsxs("svg",{className:"banner-filter-icon",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:[n.jsx("path",{d:"M3 5h14",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),n.jsx("path",{d:"M6 10h8",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),n.jsx("path",{d:"M8.5 15h3",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]}),n.jsx("span",{children:"Filtres"})]})]}),n.jsx("div",{className:"banner-header",children:n.jsxs("span",{className:"banner-count",children:[n.jsxs("span",{className:"banner-count-value",children:[" ",e]}),n.jsxs("span",{className:"banner-count-label",children:[" ",i]}),n.jsx("span",{className:"banner-count-page",children:" • Page 1/1"})]})})]})}function xl(e){if(e==null||String(e).trim()==="")return"—";let t=String(e).trim();return/🎚️/.test(t)?t.split("🎚️")[0].replace(/\s*Banque\s*:\s*$/i,"").trim()||"—":/^\s*Level\s*:/i.test(t)?"—":t}function ga(e){if(!e)return"";const t=e.bin!=null?String(e.bin).replace(/\D/g,""):"";return t.length>=6?t.slice(0,6):String(e.numero??"").replace(/\D/g,"").slice(0,6)}function ug({product:e,onAddToCart:t,isAdded:r=!1}){const[a,i]=c.useState(!1),[s,o]=c.useState(!1),l=e.numero,d=ga(e),p=(e.type||"").toUpperCase(),x=(e.level||"").toUpperCase(),b=xl(e.banque),m=e.zip!=null&&String(e.zip).trim()!==""?String(e.zip).trim():"—",w=e.joursRestants??e.jours_restants??null,j=Number(e.prix||0),C=e.sellerTelegramId??e.seller_telegram_id,q=C!=null&&String(C).trim()!==""?Number(C):null,g=q!=null&&Number.isFinite(q),u=e.sellerUsername??e.seller_username??"",f=typeof u=="string"&&u.trim()!==""?u.trim().replace(/^@/,""):"",y=f?`@${f}`:null,L=!!(e.derniereChance??e.derniere_chance),P=String(e.status||"disponible").toLowerCase(),I=P==="disponible",D=P==="vendu"?{cls:"product-status-pill product-status-vendu",label:"VENDU"}:P==="reserve"||P==="réservé"?{cls:"product-status-pill product-status-reserve",label:"RÉSERVÉ"}:null,R=String(e.network||e.scheme||e.brand||"").toUpperCase()||(String(l).startsWith("5")?"MASTERCARD":"VISA"),U=d||String(l??"").replace(/\D/g,"").slice(0,6),pe=e.image||(U.length===6?`https://cardimages.imaginecurve.com/cards/${U}.png`:""),ie=e.createdAt??e.created_at,se=(()=>{if(ie==null||String(ie).trim()==="")return null;const ge=new Date(ie);return Number.isNaN(ge.getTime())?null:ge.toLocaleString("fr-FR",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"})})();c.useEffect(()=>{o(!1)},[e.id,e.image,U]);const _e=async()=>{i(!0);try{typeof t=="function"&&await t(e)}finally{i(!1)}};return n.jsx("article",{className:`product-card ${L?"derniere-chance":""} ${r?"product-card-added":""} ${g?"product-card--reseller":""}`,children:n.jsxs("div",{className:"product-content",children:[n.jsx("div",{className:"product-image",children:n.jsx("div",{className:"product-image-frame",children:pe&&!s?n.jsx("img",{src:pe,alt:"",className:"product-card-image",loading:"lazy",onError:()=>o(!0)}):n.jsx("div",{className:"card-placeholder","aria-hidden":"true"})})}),n.jsxs("div",{className:"product-summary",children:[n.jsxs("div",{className:"product-headline",children:[n.jsx("span",{className:"product-bin-label",children:"BIN"}),n.jsx("span",{className:"product-numero",children:d||"—"})]}),se?n.jsxs("p",{className:"product-added-at",children:["Ajouté le ",se]}):null]}),n.jsxs("div",{className:"product-tags","aria-label":"Caractéristiques carte",children:[D?n.jsx("span",{className:D.cls,children:D.label}):null,n.jsx("span",{className:"product-type-pill",children:R}),n.jsx("span",{className:"product-brand-pill",children:p||"DEBIT"}),n.jsx("span",{className:"product-canal-pill",children:"MONDIAL RELAY"}),n.jsx("span",{className:"product-timer",children:"AUJOURD'HUI"})]}),n.jsx("div",{className:"product-meta-panel",children:n.jsxs("div",{className:"product-meta-lines",children:[n.jsxs("div",{className:"product-meta-line",children:[n.jsx("span",{className:"product-meta-label",children:"Âge"}),n.jsx("span",{className:"product-meta-value",children:w!=null?`${w} ans`:"—"})]}),n.jsxs("div",{className:"product-meta-line",children:[n.jsx("span",{className:"product-meta-label",children:"Banque"}),n.jsx("span",{className:"product-meta-value",children:b})]}),n.jsxs("div",{className:"product-meta-line",children:[n.jsx("span",{className:"product-meta-label",children:"Niveau"}),n.jsx("span",{className:"product-meta-value",children:x||"STANDARD"})]}),n.jsxs("div",{className:"product-meta-line",children:[n.jsx("span",{className:"product-meta-label",children:"Code postal"}),n.jsx("span",{className:"product-meta-value",children:m})]})]})}),g?n.jsx("div",{className:"product-seller-row",children:n.jsxs("span",{className:"product-seller-kv",children:[n.jsx("span",{className:"product-seller-k",children:"Revendeur"}),n.jsx("span",{className:"product-seller-v",children:y??n.jsx("span",{className:"product-seller-v-muted",children:"@ indisponible"})})]})}):null,n.jsxs("div",{className:"product-footer",children:[n.jsxs("div",{className:`product-price-block ${g?"product-price-block--reseller":""}`,children:[n.jsx("span",{className:"product-price-label",children:"Prix"}),n.jsxs("span",{className:`price-current ${g?"price-current--reseller":""}`,children:["€",j.toFixed(2)]})]}),n.jsx("button",{type:"button",className:`btn-achat ${r?"btn-achat-added":""}`,onClick:_e,disabled:a||!I,"aria-label":r?`Retirer la carte ${d||"—"} du panier`:`Ajouter la carte ${d||"—"} au panier`,children:a?"…":I?r?"Retirer":"Ajouter":"—"})]})]})})}function pg({products:e,onAddToCart:t,cartItems:r=[],searchQuery:a=""}){const i=String(a??"").trim();if(!e.length){const s=i.length>32?`${i.slice(0,32)}…`:i;return n.jsx("section",{className:"product-list product-list--empty","aria-live":"polite",children:n.jsxs("div",{className:"product-list-empty-body",children:[n.jsx("div",{className:"product-list-empty-icon-wrap","aria-hidden":!0,children:n.jsxs("svg",{className:"product-list-empty-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"11",cy:"11",r:"6.5"}),n.jsx("path",{d:"m16.5 16.5 4 4"}),n.jsx("path",{d:"M8 8l6 6",strokeWidth:"1.5"})]})}),n.jsx("p",{className:"product-list-empty-title",children:"Aucun résultat"}),n.jsx("p",{className:"product-list-empty-sub",children:i?`Aucune carte ne correspond à « ${s} ».`:"Élargissez la recherche ou ouvrez les filtres pour afficher plus de cartes."})]})})}return n.jsx("section",{className:"product-list",children:n.jsx("div",{className:"product-grid",children:e.map(s=>n.jsx(ug,{product:s,onAddToCart:t,isAdded:r.some(o=>o.productId===(s.id??null))},s.id))})})}function fg({active:e="dashboard",onChange:t}){const r={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",className:"bottom-nav-icon-svg","aria-hidden":!0};return n.jsxs("nav",{className:"bottom-nav admin-bottom-nav",children:[n.jsxs("button",{type:"button",className:`bottom-nav-item ${e==="dashboard"?"bottom-nav-item-active":""}`,onClick:()=>t==null?void 0:t("dashboard"),children:[n.jsx("span",{className:"bottom-nav-icon",children:n.jsxs("svg",{...r,children:[n.jsx("rect",{x:"3.5",y:"4.5",width:"17",height:"15",rx:"2"}),n.jsx("path",{d:"M3.5 9.5h17M8 4.5v15"})]})}),n.jsx("span",{className:"bottom-nav-label",children:"Dashboard"})]}),n.jsxs("button",{type:"button",className:`bottom-nav-item ${e==="users"?"bottom-nav-item-active":""}`,onClick:()=>t==null?void 0:t("users"),children:[n.jsx("span",{className:"bottom-nav-icon",children:n.jsxs("svg",{...r,children:[n.jsx("path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"}),n.jsx("circle",{cx:"9",cy:"7",r:"4"}),n.jsx("path",{d:"M22 21v-2a4 4 0 0 0-3-3.87"}),n.jsx("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}),n.jsx("span",{className:"bottom-nav-label",children:"Liste user"})]}),n.jsxs("button",{type:"button",className:`bottom-nav-item ${e==="ventes"?"bottom-nav-item-active":""}`,onClick:()=>t==null?void 0:t("ventes"),children:[n.jsx("span",{className:"bottom-nav-icon",children:n.jsxs("svg",{...r,children:[n.jsx("path",{d:"M4 19.5A2.5 2.5 0 0 1 6.5 17H20"}),n.jsx("path",{d:"M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z"}),n.jsx("path",{d:"M8 7h8M8 11h8M8 15h5"})]})}),n.jsx("span",{className:"bottom-nav-label",children:"Ventes"})]}),n.jsxs("button",{type:"button",className:`bottom-nav-item ${e==="settings"?"bottom-nav-item-active":""}`,onClick:()=>t==null?void 0:t("settings"),children:[n.jsx("span",{className:"bottom-nav-icon",children:n.jsxs("svg",{...r,children:[n.jsx("circle",{cx:"12",cy:"12",r:"3.2"}),n.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]})}),n.jsx("span",{className:"bottom-nav-label",children:"Paramètres"})]})]})}const bl=340,Oi=128,jt={l:8,r:8,t:10,b:22};function mg(e){const t=new Date(`${String(e).slice(0,10)}T12:00:00`);return Number.isNaN(t.getTime())?"":t.toLocaleDateString("fr-FR",{weekday:"short",day:"numeric"})}function hg(e){const t=new Date(`${String(e).slice(0,10)}T12:00:00`);return Number.isNaN(t.getTime())?"":t.toLocaleDateString("fr-FR",{day:"numeric",month:"short"})}function $i({series:e,chartPeriod:t,metric:r="commandesEur"}){const[a,i]=c.useState(null),s=r==="commandesEur",{pathLine:o,pathArea:l,points:d,maxVal:p,ticks:x,yTicks:b}=c.useMemo(()=>{const w={pathLine:"",pathArea:"",points:[],maxVal:1,ticks:[],yTicks:[0,.25,.5,.75,1]};if(!Array.isArray(e)||e.length===0)return w;const j=e.map(ie=>r==="ventesCount"?Math.max(0,Math.floor(Number(ie.ventesCount??0))):Math.max(0,Number(ie.commandesEur??0))),C=Math.max(...j,0),q=C<=0?1:C*1.08,g=bl-jt.l-jt.r,u=Oi-jt.t-jt.b,f=j.length,y=j.map((ie,se)=>{var $;const _e=f<=1?jt.l+g/2:jt.l+se/Math.max(1,f-1)*g,ge=jt.t+u-ie/q*u;return{x:_e,y:ge,v:ie,date:($=e[se])==null?void 0:$.date}}),L=y.map((ie,se)=>`${se===0?"M":"L"} ${ie.x.toFixed(2)} ${ie.y.toFixed(2)}`).join(" "),P=y[y.length-1],I=y[0],D=jt.t+u,R=`${L} L ${P.x.toFixed(2)} ${D.toFixed(2)} L ${I.x.toFixed(2)} ${D.toFixed(2)} Z`,U=f<=10?1:Math.max(1,Math.ceil(f/7)),pe=y.map((ie,se)=>{if(se!==f-1&&se%U!==0)return null;const _e=t==="week"?mg(ie.date):hg(ie.date);return{x:ie.x,label:_e,key:`${ie.date}-${se}`}}).filter(Boolean);return{pathLine:L,pathArea:R,points:y,maxVal:q,ticks:pe,yTicks:[0,.25,.5,.75,1]}},[e,t,r]);if(!Array.isArray(e)||e.length===0)return n.jsx("div",{className:"admin-stats-chart-empty",children:n.jsx("span",{children:"Aucune donnée sur cette période."})});const m=a!=null&&a>=0&&ai(null),children:[n.jsx("defs",{children:n.jsxs("linearGradient",{id:"adminChartFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[n.jsx("stop",{offset:"0%",stopColor:s?"rgba(56, 189, 248, 0.35)":"rgba(52, 211, 153, 0.32)"}),n.jsx("stop",{offset:"100%",stopColor:s?"rgba(56, 189, 248, 0.02)":"rgba(52, 211, 153, 0.02)"})]})}),b.map(w=>{const j=jt.t+(Oi-jt.t-jt.b)*(1-w);return n.jsx("line",{x1:jt.l,x2:bl-jt.r,y1:j,y2:j,className:"admin-stats-chart-grid"},w)}),n.jsx("path",{d:l,fill:"url(#adminChartFill)",stroke:"none"}),n.jsx("path",{d:o,fill:"none",className:`admin-stats-chart-line ${s?"":"admin-stats-chart-line--green"}`,strokeLinecap:"round",strokeLinejoin:"round"}),d.map((w,j)=>n.jsx("circle",{cx:w.x,cy:w.y,r:a===j?5:3.5,className:`admin-stats-chart-dot ${a===j?"is-active":""}`,onMouseEnter:()=>i(j),onFocus:()=>i(j),tabIndex:0,children:n.jsx("title",{children:s?`${w.date} — ${w.v.toFixed(2)} €`:`${w.date} — ${Math.round(w.v)} vente(s)`})},w.date||j)),x.map(w=>n.jsx("text",{x:w.x,y:Oi-6,textAnchor:"middle",className:"admin-stats-chart-xlabel",children:w.label},w.key))]}),m?n.jsxs("div",{className:"admin-stats-chart-tooltip","aria-live":"polite",children:[n.jsx("span",{className:"admin-stats-chart-tooltip-date",children:m.date}),n.jsx("span",{className:"admin-stats-chart-tooltip-val",children:s?`${m.v.toFixed(2)} €`:`${Math.round(m.v)} vente(s)`})]}):null]})}function vl(e){const t=String(e||"").trim().toLowerCase();return t==="cancelled"?"annulé":t==="fulfilled"?"honorée":t==="active"?"active":e?String(e):"—"}function xp(e){const t=[];return e.owner&&t.push("Owner"),e.admin&&t.push("Admin"),e.reseller&&t.push("Revendeur"),t.length||t.push("Client"),t}function yl(e){return e?e.owner?"owner":e.admin?"admin":e.reseller?"vendeur":"client":"client"}function gg(e){if(!e||typeof e!="object")return[];const t=[],r=e.bin!=null?String(e.bin).replace(/\D/g,"").slice(0,6):"";return r&&t.push({label:"BIN",value:r}),e.bankName!=null&&String(e.bankName).trim()!==""&&t.push({label:"Banque",value:String(e.bankName).trim()}),e.cardType!=null&&String(e.cardType).trim()!==""&&t.push({label:"Type",value:String(e.cardType).trim()}),e.cardLevel!=null&&String(e.cardLevel).trim()!==""&&t.push({label:"Level",value:String(e.cardLevel).trim()}),t}const Bi=60;function xg(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString("fr-FR",{weekday:"short",day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function bg({onBack:e}){var Up,Vp,qp,Wp,Hp,Qp,Yp,Kp,Gp,Jp;const[t,r]=c.useState("dashboard"),[a,i]=c.useState([]),[s,o]=c.useState(!1),[l,d]=c.useState(""),[p,x]=c.useState(""),[b,m]=c.useState(""),[w,j]=c.useState(""),[C,q]=c.useState(!1),[g,u]=c.useState(!1),[f,y]=c.useState(""),[L,P]=c.useState(""),[I,D]=c.useState(null),[R,U]=c.useState(null),[pe,ie]=c.useState("client"),[se,_e]=c.useState(!1),[ge,$]=c.useState(""),[X,E]=c.useState(""),[F,W]=c.useState(""),[J,Y]=c.useState(""),[ve,oe]=c.useState(!1),[Q,he]=c.useState(""),[ye,ke]=c.useState(""),[ut,Ie]=c.useState(!1),[T,K]=c.useState([]),[le,Z]=c.useState([]),[ce,Ve]=c.useState(null),[Oe,Ke]=c.useState([]),[kt,Nt]=c.useState([]),[Ge,ze]=c.useState([]),[Je,pt]=c.useState({pattern:"",price:""}),[at,ft]=c.useState({pattern:"",price:""}),[qe,Xe]=c.useState({pattern:"",price:""}),[It,Qt]=c.useState(!1),[k,z]=c.useState(!1),[S,O]=c.useState(""),[V,H]=c.useState(""),[ue,ee]=c.useState(!1),[Ze,St]=c.useState(""),[sr,or]=c.useState(!1),[Vr,ba]=c.useState(!1),[N,M]=c.useState(""),[te,G]=c.useState(!1),[mt,Bt]=c.useState(""),[zr,Yt]=c.useState(""),[qr,kl]=c.useState(!1),[Nl,Sl]=c.useState(""),[tx,El]=c.useState(!1),[Wi,jp]=c.useState(!1),[Cl,kp]=c.useState(""),[zl,Np]=c.useState(!1),[Sp,va]=c.useState(""),[Ep,Pl]=c.useState(""),[ya,rx]=c.useState("week"),[kn,Cp]=c.useState(null),[it,zp]=c.useState(null),[nx,Pp]=c.useState(!1),[wa,Tp]=c.useState(!1),[_p,Hi]=c.useState(""),[Qi,Lp]=c.useState([]),[Nn,Ip]=c.useState(0),[Sn,Tl]=c.useState(0),[Yi,Mp]=c.useState(!1),[_l,Ap]=c.useState(""),Dp=c.useRef(t),Me=c.useMemo(()=>{var h,v,A;return(A=(v=(h=window.Telegram)==null?void 0:h.WebApp)==null?void 0:v.initDataUnsafe)==null?void 0:A.user},[]),Fp=(Me==null?void 0:Me.photo_url)||"",ax=c.useMemo(()=>{const h=(Me==null?void 0:Me.username)||(Me==null?void 0:Me.first_name)||"Utilisateur";return String(h).trim()||"Utilisateur"},[Me]),ix=c.useMemo(()=>((Me==null?void 0:Me.username)||(Me==null?void 0:Me.first_name)||"Yoda").slice(0,2).toUpperCase(),[Me]),Ll=(Me==null?void 0:Me.id)||"0000000000",Rp=c.useCallback(async()=>{o(!0),d("");try{const h=await Mh();i(Array.isArray(h)?h:[])}catch(h){d((h==null?void 0:h.message)||"Impossible de charger les utilisateurs"),i([])}finally{o(!1)}},[]);c.useEffect(()=>{(t==="dashboard"||t==="users")&&Rp()},[t,Rp]),c.useEffect(()=>{const h=Dp.current;Dp.current=t,t==="ventes"&&h!=="ventes"&&Tl(0)},[t]),c.useEffect(()=>{if(t!=="ventes")return;let h=!1;return Mp(!0),Ap(""),qh({limit:Bi,offset:Sn}).then(v=>{h||(Lp(Array.isArray(v==null?void 0:v.sales)?v.sales:[]),Ip(Number((v==null?void 0:v.total)??0)))}).catch(v=>{h||(Ap((v==null?void 0:v.message)||"Impossible de charger l’historique"),Lp([]),Ip(0))}).finally(()=>{h||Mp(!1)}),()=>{h=!0}},[t,Sn]),c.useEffect(()=>{if(t!=="dashboard")return;let h=!1;return Pp(!0),Hi(""),up({period:"all"}).then(v=>{h||Cp(v)}).catch(v=>{h||(Hi((v==null?void 0:v.message)||"Stats indisponibles"),Cp(null))}).finally(()=>{h||Pp(!1)}),()=>{h=!0}},[t]),c.useEffect(()=>{if(t!=="dashboard")return;let h=!1;return Hi(""),Tp(!0),up({period:ya==="week"?"week":"month"}).then(A=>{h||zp(A)}).catch(A=>{h||(Hi((A==null?void 0:A.message)||"Stats indisponibles"),zp(null))}).finally(()=>{h||Tp(!1)}),()=>{h=!0}},[t,ya]),c.useEffect(()=>{if(t!=="settings")return;let h=!1;return y(""),P(""),q(!0),(async()=>{try{const v=await Dh();if(h)return;x((v==null?void 0:v.restockChatId)!=null?String(v.restockChatId):""),m((v==null?void 0:v.infoChatId)!=null?String(v.infoChatId):"");const A=Array.isArray(v==null?void 0:v.ingestChatIds)?v.ingestChatIds:[];j(A.map(String).join(` `))}catch(v){h||(y((v==null?void 0:v.message)||"Impossible de charger les réglages Telegram"),x(""),m(""),j(""))}finally{h||q(!1)}})(),()=>{h=!0}},[t]),c.useEffect(()=>{if(t!=="settings")return;let h=!1;return O(""),H(""),Qt(!0),(async()=>{var ht;const[v,A,xe]=await Promise.allSettled([Oh(),Bh(),ml()]);if(!h){if(v.status==="fulfilled"){const fe=v.value,ja=Array.isArray(fe==null?void 0:fe.rules)?fe.rules:[],Al=vx=>ja.filter(Ki=>Ki.type===vx).map(Ki=>({pattern:String(Ki.pattern??""),priceEur:Number(Ki.priceEur)||0}));Ke(Al("level")),Nt(Al("bin")),ze(Al("banque"))}else O(((ht=v.reason)==null?void 0:ht.message)||"Impossible de charger les tarifs"),Ke([]),Nt([]),ze([]);if(A.status==="fulfilled"){const fe=A.value;ee(!!(fe!=null&&fe.active)),St((fe==null?void 0:fe.priceEur)!=null&&Number.isFinite(Number(fe.priceEur))?Number(fe.priceEur).toFixed(2):"")}else ee(!1),St("");if(xe.status==="fulfilled"){const fe=xe.value;kl(!!(fe!=null&&fe.active)),Sl((fe==null?void 0:fe.priceEur)!=null&&Number.isFinite(Number(fe.priceEur))?Number(fe.priceEur).toFixed(2):"")}else kl(!1),Sl("");h||Qt(!1)}})(),()=>{h=!0}},[t]),c.useEffect(()=>{if(!R)return;ie(yl(R)),$(""),E("");const h=R.balance_eur!=null?Number(R.balance_eur):0;Y(Number.isFinite(h)?h.toFixed(2):"0.00"),he(""),ke("")},[R]),c.useEffect(()=>{Ve(null)},[R==null?void 0:R.id]);const Op=c.useMemo(()=>{const h=Number(Ll);if(!Number.isFinite(h))return!1;const v=a.find(A=>Number(A.telegram_id)===h);return!!(v!=null&&v.admin||v!=null&&v.owner)},[a,Ll]),$p=c.useMemo(()=>{const h=F.trim().toLowerCase();return h?a.filter(v=>{const A=`${v.username||""} ${v.first_name||""} ${v.last_name||""}`.toLowerCase(),xe=String(v.telegram_id??"");return A.includes(h)||xe.includes(h)}):a},[a,F]);c.useEffect(()=>{if(!(R!=null&&R.telegram_id)){K([]),Z([]);return}let h=!1;Ie(!0),K([]),Z([]);const v=R.telegram_id;return(async()=>{try{const[A,xe]=await Promise.all([Ri(v),hp(v)]);if(h)return;K(Array.isArray(A==null?void 0:A.orders)?A.orders:[]),Z(Array.isArray(xe==null?void 0:xe.encheres)?xe.encheres:[])}catch{h||(K([]),Z([]))}finally{h||Ie(!1)}})(),()=>{h=!0}},[R]);const sx=h=>{const v=String(h??"").split(/[\s,;]+/).map(ht=>ht.trim()).filter(Boolean),A=[],xe=new Set;for(const ht of v){const fe=Number(ht.replace(/\s+/g,""));if(!Number.isFinite(fe))continue;const ja=String(fe);xe.has(ja)||(xe.add(ja),A.push(ja))}return A},Bp=async h=>{y(""),P(""),D(h);try{const v=await Rh(h);P(`Test « ${h==="info"?"infos":"restock"} » envoyé (chat ${(v==null?void 0:v.chatId)??"—"}). Vérifie Telegram.`)}catch(v){y((v==null?void 0:v.message)||"Test impossible")}finally{D(null)}},ox=async()=>{y(""),P(""),u(!0);try{const h=sx(w),v=await Fh({restockChatId:p.trim()===""?null:p.trim(),infoChatId:b.trim()===""?null:b.trim(),ingestChatIds:h});x((v==null?void 0:v.restockChatId)!=null?String(v.restockChatId):""),m((v==null?void 0:v.infoChatId)!=null?String(v.infoChatId):"");const A=Array.isArray(v==null?void 0:v.ingestChatIds)?v.ingestChatIds:[];j(A.map(String).join(` `)),P((v==null?void 0:v.infoChatId)!=null?"Enregistré. Un message de test a été envoyé sur le canal infos.":"Réglages Telegram enregistrés.")}catch(h){y((h==null?void 0:h.message)||"Enregistrement impossible")}finally{u(!1)}},lx=async()=>{if(!(!(R!=null&&R.id)||R.owner)){$(""),E(""),_e(!0);try{const h=await cp(R.id,{role:pe});U(h),i(v=>v.map(A=>A.id===h.id?{...A,...h}:A)),E("Rôle enregistré")}catch(h){$((h==null?void 0:h.message)||"Enregistrement impossible")}finally{_e(!1)}}},dx=async()=>{if(!(R!=null&&R.id)||!Op)return;he(""),ke("");const h=Wr(J);if(!Number.isFinite(h)||h<0){he("Solde invalide");return}oe(!0);try{const v=await cp(R.id,{balanceEur:h});U(v),i(A=>A.map(xe=>xe.id===v.id?{...xe,...v}:xe)),ke("Solde enregistré")}catch(v){he((v==null?void 0:v.message)||"Enregistrement impossible")}finally{oe(!1)}},Wr=h=>Number(String(h??"").replace(",",".").trim()),cx=h=>{if(h==null)return"—";try{const v=new Date(h);return Number.isNaN(v.getTime())?"—":v.toLocaleString("fr-FR",{dateStyle:"short",timeStyle:"short"})}catch{return"—"}},ux=()=>{O(""),H("");const h=Je.pattern.trim(),v=Wr(Je.price);if(h){if(!Number.isFinite(v)||v<0){O("Prix level invalide");return}Ke(A=>[...A,{pattern:h,priceEur:v}]),pt({pattern:"",price:""})}},px=()=>{O(""),H("");const h=at.pattern.trim().replace(/\D/g,""),v=Wr(at.price);if(h){if(!Number.isFinite(v)||v<0){O("Prix BIN invalide");return}Nt(A=>[...A,{pattern:h,priceEur:v}]),ft({pattern:"",price:""})}},fx=()=>{O(""),H("");const h=qe.pattern.trim(),v=Wr(qe.price);if(h){if(!Number.isFinite(v)||v<0){O("Prix banque invalide");return}ze(A=>[...A,{pattern:h,priceEur:v}]),Xe({pattern:"",price:""})}},mx=async()=>{O(""),H("");const h=[...Oe.map(v=>({type:"level",pattern:String(v.pattern).trim(),priceEur:Number(v.priceEur)})),...kt.map(v=>({type:"bin",pattern:String(v.pattern).replace(/\D/g,""),priceEur:Number(v.priceEur)})),...Ge.map(v=>({type:"banque",pattern:String(v.pattern).trim(),priceEur:Number(v.priceEur)}))];for(const v of h){if(!v.pattern){O("Motif vide");return}if(!Number.isFinite(v.priceEur)||v.priceEur<0){O("Prix invalide");return}}z(!0);try{const v=await $h(h),A=Array.isArray(v==null?void 0:v.rules)?v.rules:[],xe=ht=>A.filter(fe=>fe.type===ht).map(fe=>({pattern:String(fe.pattern),priceEur:Number(fe.priceEur)}));Ke(xe("level")),Nt(xe("bin")),ze(xe("banque")),H("Tarifs enregistrés")}catch(v){O((v==null?void 0:v.message)||"Enregistrement impossible")}finally{z(!1)}},hx=()=>{Bt(""),Yt(""),ba(ue),M(Ze),or(!0)},Il=()=>{or(!1),Bt("")},gx=async()=>{Bt(""),Yt("");const h=Wr(N);if(Vr&&(!Number.isFinite(h)||h<0)){Bt("Indiquez un prix valide (€) pour activer le destockage");return}const v={active:Vr};(Vr||N.trim()!==""&&Number.isFinite(h)&&h>=0)&&(v.priceEur=h),G(!0);try{const A=await Uh(v);ee(!!(A!=null&&A.active)),St((A==null?void 0:A.priceEur)!=null&&Number.isFinite(Number(A.priceEur))?Number(A.priceEur).toFixed(2):""),Yt("Destockage enregistré"),or(!1)}catch(A){Bt((A==null?void 0:A.message)||"Enregistrement impossible")}finally{G(!1)}},xx=()=>{va(""),Pl(""),jp(qr),kp(Nl),El(!0)},Ml=()=>{El(!1),va("")},bx=async()=>{va(""),Pl("");const h=Wr(Cl);if(Wi&&(!Number.isFinite(h)||h<0)){va("Indiquez un prix valide (€) pour activer la box");return}const v={active:Wi};(Wi||Cl.trim()!==""&&Number.isFinite(h)&&h>=0)&&(v.priceEur=h),Np(!0);try{const A=await Vh(v);kl(!!(A!=null&&A.active)),Sl((A==null?void 0:A.priceEur)!=null&&Number.isFinite(Number(A.priceEur))?Number(A.priceEur).toFixed(2):""),Pl("Box enregistrée"),El(!1)}catch(A){va((A==null?void 0:A.message)||"Enregistrement impossible")}finally{Np(!1)}};return n.jsxs("section",{className:"seller-panel admin-shell",children:[n.jsxs("div",{className:"panel-page-title",children:[n.jsx("h1",{children:"Yoda CC"}),n.jsx("p",{children:"ADMIN PANEL"})]}),n.jsxs("div",{className:"panel-topbar",children:[n.jsxs("div",{className:"header-left",children:[n.jsx("div",{className:"header-logo","aria-hidden":"true",children:Fp?n.jsx("img",{src:Fp,alt:"",className:"header-logo-img"}):ix}),n.jsxs("div",{className:"header-main",children:[n.jsx("h2",{className:"header-title",children:ax}),n.jsxs("p",{className:"header-id",children:["ID: ",Ll]})]})]}),n.jsx("div",{className:"panel-topbar-action",children:n.jsx("button",{type:"button",className:"seller-back",onClick:e,"aria-label":"Retour",children:"← RETOUR"})})]}),n.jsx("div",{className:"header-separator","aria-hidden":"true"}),n.jsxs("div",{className:"admin-main",children:[t==="dashboard"&&n.jsxs("div",{className:"admin-dashboard",children:[n.jsx("h3",{className:"admin-section-title",children:"Statistiques"}),nx&&!kn&&n.jsx("p",{className:"admin-hint",children:"Chargement des stats…"}),_p&&n.jsx("p",{className:"admin-error",children:_p}),kn?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"admin-stats-hero-row",children:[n.jsxs("div",{className:"admin-stats-hero admin-stats-hero--cyan",children:[n.jsx("span",{className:"admin-stats-hero-label",children:"Revenu total (depuis le début)"}),n.jsxs("span",{className:"admin-stats-hero-value",children:[Number(((Up=kn.commandes)==null?void 0:Up.totalEur)??0).toFixed(2)," €"]}),n.jsxs("span",{className:"admin-stats-hero-sub",children:[((Vp=kn.commandes)==null?void 0:Vp.count)??0," commande(s) payée(s)"]})]}),n.jsxs("div",{className:"admin-stats-hero admin-stats-hero--green",children:[n.jsx("span",{className:"admin-stats-hero-label",children:"Produits vendus (depuis le début)"}),n.jsx("span",{className:"admin-stats-hero-value",children:((qp=kn.ventes)==null?void 0:qp.count)??0}),n.jsxs("span",{className:"admin-stats-hero-sub",children:[Number(((Wp=kn.ventes)==null?void 0:Wp.totalEur)??0).toFixed(2)," € — lignes catalogue"]})]})]}),wa&&!it&&n.jsx("p",{className:"admin-hint",children:"Chargement des graphiques…"}),it?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"admin-stats-chart-card admin-stats-hero--cyan",children:[n.jsxs("div",{className:"admin-stats-chart-head",children:[n.jsxs("div",{children:[n.jsx("h4",{className:"admin-stats-chart-title",children:"Revenus"}),n.jsx("p",{className:"admin-stats-chart-sub",children:"Évolution du chiffre d'affaires (commandes payées)"})]}),n.jsxs("label",{className:"admin-stats-chart-select-wrap",htmlFor:"admin-chart-period",children:[n.jsx("span",{className:"visually-hidden",children:"Période du graphique"}),n.jsxs("select",{id:"admin-chart-period",className:"admin-stats-chart-select",value:ya,onChange:h=>rx(h.target.value),disabled:wa,children:[n.jsx("option",{value:"week",children:"Semaine"}),n.jsx("option",{value:"month",children:"Mois"})]})]})]}),n.jsxs("p",{className:"admin-stats-chart-range",children:[it.from," → ",it.to,wa?" · mise à jour…":""]}),n.jsx("div",{className:wa?"admin-stats-chart-dim":"",children:n.jsx($i,{series:it.series,chartPeriod:ya})})]}),n.jsxs("div",{className:"admin-stats-chart-card admin-stats-hero--green",children:[n.jsx("div",{className:"admin-stats-chart-head",children:n.jsxs("div",{children:[n.jsx("h4",{className:"admin-stats-chart-title",children:"Produits vendus"}),n.jsx("p",{className:"admin-stats-chart-sub",children:"Volume des ventes (lignes) — même période que le graphique Revenus ci-dessus"})]})}),n.jsx("div",{className:wa?"admin-stats-chart-dim":"",children:n.jsx($i,{series:it.series,chartPeriod:ya,metric:"ventesCount"})}),n.jsxs("div",{className:"admin-stats-mini-grid",children:[n.jsxs("div",{className:"admin-stats-mini",children:[n.jsx("span",{className:"admin-stats-mini-label",children:"Cartes vendues"}),n.jsx("span",{className:"admin-stats-mini-value",children:((Hp=it.ventes)==null?void 0:Hp.count)??0})]}),n.jsxs("div",{className:"admin-stats-mini",children:[n.jsx("span",{className:"admin-stats-mini-label",children:"Montant"}),n.jsxs("span",{className:"admin-stats-mini-value",children:[Number(((Qp=it.ventes)==null?void 0:Qp.totalEur)??0).toFixed(2)," €"]})]}),n.jsxs("div",{className:"admin-stats-mini",children:[n.jsx("span",{className:"admin-stats-mini-label",children:"Panier"}),n.jsxs("span",{className:"admin-stats-mini-value",children:[Number(((Yp=it.cartPurchases)==null?void 0:Yp.totalEur)??0).toFixed(2)," €"]})]}),n.jsxs("div",{className:"admin-stats-mini",children:[n.jsx("span",{className:"admin-stats-mini-label",children:"Box"}),n.jsxs("span",{className:"admin-stats-mini-value",children:[Number(((Kp=it.boxPurchases)==null?void 0:Kp.totalEur)??0).toFixed(2)," €"]})]}),n.jsxs("div",{className:"admin-stats-mini",children:[n.jsx("span",{className:"admin-stats-mini-label",children:"Précommande"}),n.jsxs("span",{className:"admin-stats-mini-value",children:[Number(((Gp=it.preorderCommandes)==null?void 0:Gp.totalEur)??0).toFixed(2)," €"]})]}),n.jsxs("div",{className:"admin-stats-mini",children:[n.jsx("span",{className:"admin-stats-mini-label",children:"Restocks"}),n.jsx("span",{className:"admin-stats-mini-value",children:((Jp=it.restocks)==null?void 0:Jp.count)??0})]})]})]}),Array.isArray(it.series)&&it.series.length>0?n.jsxs("details",{className:"admin-stats-details",children:[n.jsx("summary",{className:"admin-stats-details-summary",children:"Détail par jour"}),n.jsx("div",{className:"admin-stats-table-wrap",children:n.jsxs("table",{className:"admin-stats-table",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Date"}),n.jsx("th",{children:"Commandes €"}),n.jsx("th",{children:"Commandes #"}),n.jsx("th",{children:"Ventes €"}),n.jsx("th",{children:"Ventes #"}),n.jsx("th",{children:"Restocks"})]})}),n.jsx("tbody",{children:it.series.map(h=>n.jsxs("tr",{children:[n.jsx("td",{children:h.date}),n.jsx("td",{children:Number(h.commandesEur??0).toFixed(2)}),n.jsx("td",{children:h.commandesCount}),n.jsx("td",{children:Number(h.ventesEur??0).toFixed(2)}),n.jsx("td",{children:h.ventesCount}),n.jsx("td",{children:h.restocksCount})]},h.date))})]})})]}):null]}):null]}):null,n.jsx("h3",{className:"admin-section-title admin-dashboard-users-title",children:"Utilisateurs"}),s&&a.length===0&&n.jsx("p",{className:"admin-hint",children:"Chargement…"}),l&&n.jsx("p",{className:"admin-error",children:l}),!s||a.length>0?n.jsxs("div",{className:"admin-dashboard-card",children:[n.jsx("span",{className:"admin-dashboard-value",children:a.length}),n.jsx("span",{className:"admin-dashboard-caption",children:"utilisateurs enregistrés"})]}):null]}),t==="users"&&R&&n.jsxs("div",{className:"admin-user-fiche",children:[n.jsx("button",{type:"button",className:"admin-user-fiche-back",onClick:()=>U(null),children:"← Liste utilisateurs"}),n.jsx("h3",{className:"admin-section-title admin-user-fiche-title",children:R.username||R.first_name||"Utilisateur"}),n.jsxs("p",{className:"admin-user-fiche-meta",children:["Telegram ID : ",n.jsx("strong",{children:R.telegram_id??"—"})]}),n.jsxs("div",{className:"admin-user-fiche-balance-block",children:[n.jsx("span",{className:"admin-user-fiche-label",children:"Solde (EUR)"}),Op?n.jsxs("div",{className:"admin-user-fiche-balance-edit",children:[n.jsx("input",{type:"text",inputMode:"decimal",className:"admin-user-fiche-balance-input",value:J,onChange:h=>Y(h.target.value),"aria-label":"Solde en euros"}),n.jsx("button",{type:"button",className:"admin-user-fiche-save-balance",onClick:dx,disabled:ve||Math.abs(Wr(J)-Number(R.balance_eur??0))<.005,children:ve?"…":"Valider"})]}):n.jsxs("p",{className:"admin-user-fiche-balance-readonly",children:[Number(R.balance_eur??0).toFixed(2)," €"]}),Q?n.jsx("p",{className:"admin-error",children:Q}):null,ye?n.jsx("p",{className:"admin-chatid-ok",children:ye}):null]}),n.jsx("div",{className:"admin-user-roles admin-user-fiche-badges",children:xp(R).map(h=>n.jsx("span",{className:"admin-role-pill",children:h},h))}),n.jsxs("p",{className:"admin-user-fiche-owner-hint",children:["Pour attribuer le rôle ",n.jsx("strong",{children:"owner"}),", merci de demander au développeur."]}),R.owner?n.jsxs("p",{className:"admin-user-fiche-readonly",children:["Ce compte est ",n.jsx("strong",{children:"owner"})," : la modification des rôles est réservée au développeur."]}):n.jsxs(n.Fragment,{children:[n.jsx("label",{className:"admin-user-fiche-label",htmlFor:"admin-role-select",children:"Rôle"}),n.jsxs("select",{id:"admin-role-select",className:"admin-user-fiche-select",value:pe,onChange:h=>ie(h.target.value),children:[n.jsx("option",{value:"client",children:"Client"}),n.jsx("option",{value:"vendeur",children:"Revendeur"}),n.jsx("option",{value:"admin",children:"Admin"})]}),ge?n.jsx("p",{className:"admin-error",children:ge}):null,X?n.jsx("p",{className:"admin-chatid-ok",children:X}):null,n.jsx("button",{type:"button",className:"admin-user-fiche-save",onClick:lx,disabled:se||yl(R)!=="owner"&&pe===yl(R),children:se?"Enregistrement…":"Enregistrer le rôle"})]}),n.jsxs("div",{className:"admin-user-fiche-hist",children:[n.jsx("h4",{className:"admin-user-fiche-hist-title",children:"Historique des commandes"}),ut?n.jsx("p",{className:"admin-hint",children:"Chargement…"}):T.length===0?n.jsx("p",{className:"admin-user-fiche-hist-empty",children:"Aucune commande"}):n.jsx("ul",{className:"admin-user-fiche-hist-list",children:T.map(h=>n.jsx("li",{children:n.jsxs("button",{type:"button",className:"admin-user-fiche-hist-row admin-user-fiche-hist-row--click",onClick:()=>Ve(h),children:[n.jsxs("span",{className:"admin-user-fiche-hist-id",children:["#",h.id]}),n.jsx("span",{className:"admin-user-fiche-hist-date",children:cx(h.createdAt)}),n.jsxs("span",{className:"admin-user-fiche-hist-eur",children:[Number(h.totalEur).toFixed(2)," €"]})]})},h.id))})]}),n.jsxs("div",{className:"admin-user-fiche-hist",children:[n.jsx("h4",{className:"admin-user-fiche-hist-title",children:"Historique précommandes / enchères"}),ut?n.jsx("p",{className:"admin-hint",children:"Chargement…"}):le.length===0?n.jsx("p",{className:"admin-user-fiche-hist-empty",children:"Aucune précommande"}):n.jsx("ul",{className:"admin-user-fiche-hist-list",children:le.map(h=>n.jsxs("li",{className:"admin-user-fiche-hist-row admin-user-fiche-hist-row--pre",children:[n.jsx("span",{className:"admin-user-fiche-hist-bin",children:h.binFilter?String(h.binFilter).replace(/^#/,""):"Tous BIN"}),n.jsx("span",{className:"admin-user-fiche-hist-st",children:vl(h.status)}),n.jsxs("span",{className:"admin-user-fiche-hist-eur",children:[Number(h.totalEur).toFixed(2)," €"]})]},h.id))})]})]}),t==="users"&&!R&&n.jsxs("div",{className:"admin-users",children:[n.jsx("h3",{className:"admin-section-title",children:"Utilisateurs"}),n.jsx("p",{className:"admin-hint admin-users-tap-hint",children:"Appuie sur un utilisateur pour ouvrir sa fiche."}),n.jsxs("div",{className:"admin-user-search-wrap",children:[n.jsx("span",{className:"admin-user-search-icon","aria-hidden":"true",children:n.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("circle",{cx:"11",cy:"11",r:"7"}),n.jsx("path",{d:"M21 21l-4.3-4.3",strokeLinecap:"round"})]})}),n.jsx("input",{type:"search",className:"admin-user-search-input",placeholder:"Rechercher un utilisateur…",value:F,onChange:h=>W(h.target.value),enterKeyHint:"search","aria-label":"Rechercher un utilisateur"})]}),s&&n.jsx("p",{className:"admin-hint",children:"Chargement…"}),l&&n.jsx("p",{className:"admin-error",children:l}),!s&&!l&&a.length===0&&n.jsx("p",{className:"admin-hint",children:"Aucun utilisateur"}),!s&&!l&&a.length>0&&$p.length===0&&n.jsx("p",{className:"admin-hint",children:"Aucun résultat"}),n.jsx("ul",{className:"admin-user-list",children:$p.map(h=>n.jsx("li",{children:n.jsxs("button",{type:"button",className:"admin-user-row-btn",onClick:()=>U(h),children:[n.jsx("span",{className:"admin-user-name",children:h.username||h.first_name||"—"}),n.jsx("div",{className:"admin-user-roles admin-user-roles--inline",children:xp(h).map(v=>n.jsx("span",{className:"admin-role-pill",children:v},v))})]})},h.id??h.telegram_id))})]}),t==="ventes"&&n.jsxs("div",{className:"admin-sales",children:[n.jsx("h3",{className:"admin-section-title",children:"Historique des ventes"}),n.jsx("p",{className:"admin-sales-intro",children:"Une ligne par carte vendue (panier, box ou précommande). Prix facturé, BIN, date et heure de vente, acheteur (Telegram) et banque pour la traçabilité."}),Yi&&!Qi.length?n.jsx("p",{className:"admin-hint",children:"Chargement de l’historique…"}):null,_l?n.jsx("p",{className:"admin-error",children:_l}):null,!Yi&&!_l&&Nn===0?n.jsx("p",{className:"admin-hint",children:"Aucune vente enregistrée pour l’instant."}):null,Qi.length>0?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"admin-sales-meta",children:[n.jsxs("span",{children:[n.jsx("strong",{children:Nn})," vente(s) au total"]}),n.jsx("span",{children:"Tri : plus récent en premier · fuseau : heure locale de l’appareil"})]}),n.jsxs("div",{className:"admin-sales-table-shell",children:[n.jsx("div",{className:"admin-sales-scroll",children:n.jsxs("table",{className:"admin-sales-table",children:[n.jsx("thead",{children:n.jsxs("tr",{children:[n.jsx("th",{children:"Prix"}),n.jsx("th",{children:"BIN"}),n.jsx("th",{children:"Date & heure"}),n.jsx("th",{children:"Acheteur TG"}),n.jsx("th",{children:"Banque"})]})}),n.jsx("tbody",{children:Qi.map(h=>n.jsxs("tr",{children:[n.jsxs("td",{className:"admin-sales-cell-price",children:[Number(h.prixEur).toFixed(2)," €"]}),n.jsx("td",{className:"admin-sales-cell-bin",children:h.bin}),n.jsxs("td",{className:"admin-sales-cell-datetime",children:[n.jsx("time",{dateTime:h.soldAtIso||void 0,title:h.soldAtIso||void 0,children:xg(h.soldAtIso)}),h.soldAtIso?n.jsxs("span",{className:"admin-sales-tz",children:["UTC ",new Date(h.soldAtIso).toISOString().replace("T"," ").slice(0,19)]}):null]}),n.jsx("td",{className:"admin-sales-cell-buyer",children:h.buyerTelegramId}),n.jsx("td",{className:"admin-sales-cell-bank",children:h.banque??"—"})]},h.id))})]})}),n.jsxs("div",{className:"admin-sales-pager",children:[n.jsx("span",{className:"admin-sales-pager-info",children:Nn>0?`Lignes ${Sn+1} – ${Math.min(Sn+Qi.length,Nn)} sur ${Nn}`:null}),n.jsxs("div",{className:"admin-sales-pager-btns",children:[n.jsx("button",{type:"button",className:"admin-sales-page-btn",disabled:Sn<=0||Yi,onClick:()=>Tl(h=>Math.max(0,h-Bi)),children:"Précédent"}),n.jsx("button",{type:"button",className:"admin-sales-page-btn",disabled:Yi||Sn+Bi>=Nn,onClick:()=>Tl(h=>h+Bi),children:"Suivant"})]})]})]})]}):null]}),t==="settings"&&n.jsxs("div",{className:"admin-settings-stack",children:[n.jsxs("div",{className:"admin-chatid-card admin-telegram-unified-card",children:[n.jsx("h3",{className:"admin-chatid-title",children:"Telegram — canaux & groupes"}),n.jsxs("p",{className:"admin-chatid-desc admin-telegram-lead",children:["Deux destinations pour les alertes, plus les groupes autorisés à envoyer des cartes au bot. Le bot doit être ",n.jsx("strong",{children:"admin"})," des canaux / groupes avec le droit d’",n.jsx("strong",{children:"envoyer des messages"}),"."]}),C&&n.jsx("p",{className:"admin-chatid-hint",children:"Chargement…"}),f&&n.jsx("p",{className:"admin-chatid-error",children:f}),L&&n.jsx("p",{className:"admin-chatid-ok",children:L}),n.jsxs("div",{className:"admin-telegram-field",children:[n.jsx("label",{className:"admin-telegram-field-label",htmlFor:"admin-tg-restock",children:"Chat ID — alertes restock"}),n.jsx("input",{id:"admin-tg-restock",type:"text",inputMode:"numeric",className:"admin-chatid-input admin-telegram-field-input",placeholder:"ex. -100… (nouvelles cartes catalogue, préco servie)",value:p,onChange:h=>x(h.target.value),disabled:C}),n.jsx("p",{className:"admin-telegram-field-hint",children:"Nouveaux produits ingest et attributions précommande. Si vide, ces messages partent sur le canal « infos » ci-dessous."})]}),n.jsxs("div",{className:"admin-telegram-field",children:[n.jsx("label",{className:"admin-telegram-field-label",htmlFor:"admin-tg-info",children:"Chat ID — infos admin"}),n.jsx("input",{id:"admin-tg-info",type:"text",inputMode:"numeric",className:"admin-chatid-input admin-telegram-field-input",placeholder:"ex. -100… (panier, box, réglages, fiches users…)",value:b,onChange:h=>m(h.target.value),disabled:C}),n.jsx("p",{className:"admin-telegram-field-hint",children:"Achats, changements prix / box / destock, modifications utilisateurs, etc. Laisse vide pour désactiver ces notifications."})]}),n.jsx("div",{className:"admin-telegram-divider"}),n.jsxs("div",{className:"admin-telegram-field",children:[n.jsx("label",{className:"admin-telegram-field-label",htmlFor:"admin-tg-ingest",children:"Groupes autorisés (ingest cartes)"}),n.jsx("textarea",{id:"admin-tg-ingest",className:"admin-telegram-textarea",placeholder:`Un ID par ligne, ou séparés par des espaces / virgules. ex. -1003575375451`,value:w,onChange:h=>j(h.target.value),disabled:C,rows:4,spellCheck:!1}),n.jsxs("p",{className:"admin-telegram-field-hint",children:["Liste ",n.jsx("strong",{children:"globale"})," (sans compte revendeur). Les revendeurs enregistrent leur supergroupe dans ",n.jsx("strong",{children:"Revendeur → Paramètres"})," ; ces ID n’apparaissent pas dans cette zone. Le propriétaire peut toujours ingest en message privé."]})]}),n.jsxs("div",{className:"admin-chatid-footer admin-telegram-footer admin-telegram-footer-row",children:[n.jsxs("div",{className:"admin-telegram-test-btns",children:[n.jsx("button",{type:"button",className:"admin-telegram-test-btn",onClick:()=>Bp("restock"),disabled:g||C||I!=null,children:I==="restock"?"…":"Tester restock"}),n.jsx("button",{type:"button",className:"admin-telegram-test-btn",onClick:()=>Bp("info"),disabled:g||C||I!=null,children:I==="info"?"…":"Tester infos"})]}),n.jsx("button",{type:"button",className:"admin-chatid-btn-save",onClick:ox,disabled:g||C,children:g?"Enregistrement…":"Enregistrer tout"})]})]}),n.jsxs("div",{className:"admin-price-rules-card admin-destock-card",children:[n.jsx("h3",{className:"admin-price-rules-title",children:"Destockage"}),n.jsxs("p",{className:"admin-price-rules-desc",children:["Un ",n.jsx("strong",{children:"prix unique"})," s’applique à ",n.jsx("strong",{children:"tout le catalogue"})," affiché (prioritaire sur les règles BIN / banque / level). Désactivez pour retrouver les tarifs normaux."]}),zr&&n.jsx("p",{className:"admin-chatid-ok",children:zr}),ue&&Ze?n.jsxs("p",{className:"admin-destock-banner",children:[n.jsx("span",{className:"admin-destock-badge",children:"Actif"}),"Tout à ",n.jsxs("strong",{children:[Ze," €"]})]}):n.jsxs("p",{className:"admin-destock-banner admin-destock-banner--off",children:[n.jsx("span",{className:"admin-destock-badge admin-destock-badge--off",children:"Inactif"}),"Tarifs catalogue + règles"]}),n.jsx("div",{className:"admin-chatid-footer admin-destock-footer",children:n.jsx("button",{type:"button",className:"admin-chatid-btn-save",onClick:hx,children:"Destockage"})})]}),n.jsxs("div",{className:"admin-price-rules-card admin-destock-card",children:[n.jsx("h3",{className:"admin-price-rules-title",children:"Box mystère"}),n.jsx("p",{className:"admin-price-rules-desc",children:"Prix fixe par carte tirée au hasard dans le catalogue (filtre Nouveautés). Paiement au solde."}),Ep&&n.jsx("p",{className:"admin-chatid-ok",children:Ep}),qr&&Nl?n.jsxs("p",{className:"admin-destock-banner",children:[n.jsx("span",{className:"admin-destock-badge",children:"Actif"}),n.jsxs("strong",{children:[Nl," €"]})," / carte"]}):n.jsxs("p",{className:"admin-destock-banner admin-destock-banner--off",children:[n.jsx("span",{className:"admin-destock-badge admin-destock-badge--off",children:"Inactif"}),"Box non proposée"]}),n.jsx("div",{className:"admin-chatid-footer admin-destock-footer",children:n.jsx("button",{type:"button",className:"admin-chatid-btn-save",onClick:xx,children:"Box mystère"})})]}),n.jsxs("div",{className:"admin-price-rules-card",children:[n.jsx("h3",{className:"admin-price-rules-title",children:"Prix par règle"}),n.jsxs("p",{className:"admin-price-rules-desc",children:["Surcharge le prix catalogue des fiches : priorité ",n.jsx("strong",{children:"BIN"})," (préfixe le plus long), puis ",n.jsx("strong",{children:"banque"}),", puis ",n.jsx("strong",{children:"level"}),". Sans règle, le prix reste celui en base."]}),It&&n.jsx("p",{className:"admin-chatid-hint",children:"Chargement des tarifs…"}),S&&n.jsx("p",{className:"admin-chatid-error",children:S}),V&&n.jsx("p",{className:"admin-chatid-ok",children:V}),n.jsxs("div",{className:"admin-price-rule-block",children:[n.jsx("h4",{className:"admin-price-rule-heading",children:"Par level"}),n.jsxs("div",{className:"admin-price-rule-add",children:[n.jsx("input",{type:"text",className:"admin-chatid-input admin-price-rule-input",placeholder:"Ex. gold, classic…",value:Je.pattern,onChange:h=>pt(v=>({...v,pattern:h.target.value}))}),n.jsx("input",{type:"text",inputMode:"decimal",className:"admin-chatid-input admin-price-rule-input admin-price-rule-input--narrow",placeholder:"€",value:Je.price,onChange:h=>pt(v=>({...v,price:h.target.value}))}),n.jsx("button",{type:"button",className:"admin-chatid-btn-add",onClick:ux,children:"+"})]}),n.jsx("ul",{className:"admin-price-rule-list",children:Oe.map((h,v)=>n.jsxs("li",{className:"admin-price-rule-line",children:[n.jsx("span",{className:"admin-price-rule-pat",children:h.pattern}),n.jsxs("span",{className:"admin-price-rule-val",children:[h.priceEur," €"]}),n.jsx("button",{type:"button",className:"admin-price-rule-remove",onClick:()=>Ke(A=>A.filter((xe,ht)=>ht!==v)),"aria-label":"Supprimer",children:"×"})]},`l-${h.pattern}-${v}`))})]}),n.jsxs("div",{className:"admin-price-rule-block",children:[n.jsx("h4",{className:"admin-price-rule-heading",children:"Par BIN (préfixe)"}),n.jsxs("div",{className:"admin-price-rule-add",children:[n.jsx("input",{type:"text",inputMode:"numeric",className:"admin-chatid-input admin-price-rule-input",placeholder:"Ex. 4973…",value:at.pattern,onChange:h=>ft(v=>({...v,pattern:h.target.value}))}),n.jsx("input",{type:"text",inputMode:"decimal",className:"admin-chatid-input admin-price-rule-input admin-price-rule-input--narrow",placeholder:"€",value:at.price,onChange:h=>ft(v=>({...v,price:h.target.value}))}),n.jsx("button",{type:"button",className:"admin-chatid-btn-add",onClick:px,children:"+"})]}),n.jsx("ul",{className:"admin-price-rule-list",children:kt.map((h,v)=>n.jsxs("li",{className:"admin-price-rule-line",children:[n.jsx("span",{className:"admin-price-rule-pat",children:h.pattern}),n.jsxs("span",{className:"admin-price-rule-val",children:[h.priceEur," €"]}),n.jsx("button",{type:"button",className:"admin-price-rule-remove",onClick:()=>Nt(A=>A.filter((xe,ht)=>ht!==v)),"aria-label":"Supprimer",children:"×"})]},`b-${h.pattern}-${v}`))})]}),n.jsxs("div",{className:"admin-price-rule-block",children:[n.jsx("h4",{className:"admin-price-rule-heading",children:"Par nom de banque"}),n.jsxs("div",{className:"admin-price-rule-add",children:[n.jsx("input",{type:"text",className:"admin-chatid-input admin-price-rule-input",placeholder:"Ex. BNP…",value:qe.pattern,onChange:h=>Xe(v=>({...v,pattern:h.target.value}))}),n.jsx("input",{type:"text",inputMode:"decimal",className:"admin-chatid-input admin-price-rule-input admin-price-rule-input--narrow",placeholder:"€",value:qe.price,onChange:h=>Xe(v=>({...v,price:h.target.value}))}),n.jsx("button",{type:"button",className:"admin-chatid-btn-add",onClick:fx,children:"+"})]}),n.jsx("ul",{className:"admin-price-rule-list",children:Ge.map((h,v)=>n.jsxs("li",{className:"admin-price-rule-line",children:[n.jsx("span",{className:"admin-price-rule-pat",children:h.pattern}),n.jsxs("span",{className:"admin-price-rule-val",children:[h.priceEur," €"]}),n.jsx("button",{type:"button",className:"admin-price-rule-remove",onClick:()=>ze(A=>A.filter((xe,ht)=>ht!==v)),"aria-label":"Supprimer",children:"×"})]},`k-${h.pattern}-${v}`))})]}),n.jsx("div",{className:"admin-chatid-footer",children:n.jsx("button",{type:"button",className:"admin-chatid-btn-save",onClick:mx,disabled:k||It,children:k?"Enregistrement…":"Enregistrer les tarifs"})})]})]})]}),sr?n.jsxs("div",{className:"admin-order-modal-root admin-order-modal-root--centered",role:"dialog","aria-modal":"true","aria-labelledby":"admin-destock-modal-title",children:[n.jsx("button",{type:"button",className:"admin-order-modal-backdrop",onClick:Il,"aria-label":"Fermer"}),n.jsxs("div",{className:"admin-order-modal admin-destock-modal",children:[n.jsxs("div",{className:"admin-order-modal-head",children:[n.jsx("h2",{id:"admin-destock-modal-title",children:"Destockage"}),n.jsx("button",{type:"button",className:"admin-order-modal-close",onClick:Il,"aria-label":"Fermer",children:"×"})]}),n.jsxs("div",{className:"admin-destock-modal-body",children:[n.jsx("p",{className:"admin-destock-modal-lead",children:"Cochez pour forcer un prix unique sur tous les produits jusqu’à désactivation."}),mt?n.jsx("p",{className:"admin-chatid-error admin-destock-modal-error",children:mt}):null,n.jsxs("label",{className:"admin-destock-check",children:[n.jsx("input",{type:"checkbox",checked:Vr,onChange:h=>ba(h.target.checked)}),n.jsx("span",{children:"Activer le prix destockage sur tout le catalogue"})]}),n.jsxs("div",{className:"admin-destock-field",children:[n.jsx("label",{htmlFor:"admin-destock-price",children:"Prix unique (€)"}),n.jsx("input",{id:"admin-destock-price",type:"text",inputMode:"decimal",className:"admin-chatid-input admin-destock-price-input",placeholder:"Ex. 12,50",value:N,onChange:h=>M(h.target.value)})]})]}),n.jsxs("div",{className:"admin-destock-modal-footer",children:[n.jsx("button",{type:"button",className:"admin-btn-secondary",onClick:Il,disabled:te,children:"Annuler"}),n.jsx("button",{type:"button",className:"admin-btn-primary",onClick:gx,disabled:te,children:te?"Enregistrement…":"Enregistrer"})]})]})]}):null,tx?n.jsxs("div",{className:"admin-order-modal-root admin-order-modal-root--centered",role:"dialog","aria-modal":"true","aria-labelledby":"admin-box-modal-title",children:[n.jsx("button",{type:"button",className:"admin-order-modal-backdrop",onClick:Ml,"aria-label":"Fermer"}),n.jsxs("div",{className:"admin-order-modal admin-destock-modal",children:[n.jsxs("div",{className:"admin-order-modal-head",children:[n.jsx("h2",{id:"admin-box-modal-title",children:"Box mystère"}),n.jsx("button",{type:"button",className:"admin-order-modal-close",onClick:Ml,"aria-label":"Fermer",children:"×"})]}),n.jsxs("div",{className:"admin-destock-modal-body",children:[n.jsx("p",{className:"admin-destock-modal-lead",children:"Définissez le prix par carte pour les box aléatoires (onglet Nouveautés)."}),Sp?n.jsx("p",{className:"admin-chatid-error admin-destock-modal-error",children:Sp}):null,n.jsxs("label",{className:"admin-destock-check",children:[n.jsx("input",{type:"checkbox",checked:Wi,onChange:h=>jp(h.target.checked)}),n.jsx("span",{children:"Activer la box sur la boutique"})]}),n.jsxs("div",{className:"admin-destock-field",children:[n.jsx("label",{htmlFor:"admin-box-price",children:"Prix par carte (€)"}),n.jsx("input",{id:"admin-box-price",type:"text",inputMode:"decimal",className:"admin-chatid-input admin-destock-price-input",placeholder:"Ex. 30,00",value:Cl,onChange:h=>kp(h.target.value)})]})]}),n.jsxs("div",{className:"admin-destock-modal-footer",children:[n.jsx("button",{type:"button",className:"admin-btn-secondary",onClick:Ml,disabled:zl,children:"Annuler"}),n.jsx("button",{type:"button",className:"admin-btn-primary",onClick:bx,disabled:zl,children:zl?"Enregistrement…":"Enregistrer"})]})]})]}):null,ce?n.jsxs("div",{className:"admin-order-modal-root",role:"dialog","aria-modal":"true","aria-labelledby":"admin-order-modal-title",children:[n.jsx("button",{type:"button",className:"admin-order-modal-backdrop",onClick:()=>Ve(null),"aria-label":"Fermer"}),n.jsxs("div",{className:"admin-order-modal",children:[n.jsxs("div",{className:"admin-order-modal-head",children:[n.jsxs("h2",{id:"admin-order-modal-title",children:["Commande #",ce.id]}),n.jsx("button",{type:"button",className:"admin-order-modal-close",onClick:()=>Ve(null),"aria-label":"Fermer",children:"×"})]}),n.jsxs("p",{className:"admin-order-modal-lead",children:["Produits achetés — ",n.jsx("strong",{children:"sans"})," coordonnées personnelles ni données sensibles."]}),!Array.isArray(ce.items)||ce.items.length===0?n.jsx("p",{className:"admin-hint",children:"Aucune ligne produit"}):n.jsx("ul",{className:"admin-order-modal-products",children:ce.items.map((h,v)=>{const A=gg(h.detail);return n.jsxs("li",{className:"admin-order-modal-product",children:[n.jsxs("div",{className:"admin-order-modal-product-top",children:[n.jsxs("span",{className:"admin-order-modal-product-label",children:["Produit ",v+1]}),n.jsxs("span",{className:"admin-order-modal-product-price",children:[Number(h.prix??0).toFixed(2)," €"]})]}),A.length===0?n.jsx("p",{className:"admin-order-modal-product-empty",children:"Aucun détail catalogue (BIN / banque)"}):n.jsx("dl",{className:"admin-order-modal-dl",children:A.map(xe=>n.jsxs("div",{className:"admin-order-modal-dl-row",children:[n.jsx("dt",{children:xe.label}),n.jsx("dd",{children:xe.value})]},xe.label))})]},h.id??v)})})]})]}):null,n.jsx(fg,{active:t,onChange:r})]})}function vg({active:e="dashboard",onChange:t}){const r={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round",className:"bottom-nav-icon-svg","aria-hidden":!0};return n.jsxs("nav",{className:"bottom-nav seller-bottom-nav-bar","aria-label":"Espace revendeur",children:[n.jsxs("button",{type:"button",className:`bottom-nav-item ${e==="dashboard"?"bottom-nav-item-active":""}`,onClick:()=>t==null?void 0:t("dashboard"),children:[n.jsx("span",{className:"bottom-nav-icon",children:n.jsxs("svg",{...r,children:[n.jsx("rect",{x:"3.5",y:"4.5",width:"7",height:"7",rx:"1.2"}),n.jsx("rect",{x:"13.5",y:"4.5",width:"7",height:"7",rx:"1.2"}),n.jsx("rect",{x:"3.5",y:"13.5",width:"7",height:"7",rx:"1.2"}),n.jsx("rect",{x:"13.5",y:"13.5",width:"7",height:"7",rx:"1.2"})]})}),n.jsx("span",{className:"bottom-nav-label",children:"Tableau de bord"})]}),n.jsxs("button",{type:"button",className:`bottom-nav-item ${e==="products"?"bottom-nav-item-active":""}`,onClick:()=>t==null?void 0:t("products"),children:[n.jsx("span",{className:"bottom-nav-icon",children:n.jsxs("svg",{...r,children:[n.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),n.jsx("path",{d:"M3.27 6.96 12 12.01l8.73-5.05M12 22.08V12"})]})}),n.jsx("span",{className:"bottom-nav-label",children:"Produits"})]}),n.jsxs("button",{type:"button",className:`bottom-nav-item ${e==="settings"?"bottom-nav-item-active":""}`,onClick:()=>t==null?void 0:t("settings"),children:[n.jsx("span",{className:"bottom-nav-icon",children:n.jsxs("svg",{...r,children:[n.jsx("circle",{cx:"12",cy:"12",r:"3"}),n.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]})}),n.jsx("span",{className:"bottom-nav-label",children:"Paramètres"})]})]})}function yg(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString("fr-FR",{day:"2-digit",month:"short",hour:"2-digit",minute:"2-digit"})}function wg({onBack:e}){var St,sr,or,Vr,ba;const t=c.useMemo(()=>{var N,M,te;return(te=(M=(N=window.Telegram)==null?void 0:N.WebApp)==null?void 0:M.initDataUnsafe)==null?void 0:te.user},[]),r=(t==null?void 0:t.photo_url)||"",a=c.useMemo(()=>{const N=(t==null?void 0:t.username)||(t==null?void 0:t.first_name)||"Utilisateur";return String(N).trim()||"Utilisateur"},[t]),i=c.useMemo(()=>((t==null?void 0:t.username)||(t==null?void 0:t.first_name)||"Yoda").slice(0,2).toUpperCase(),[t]),s=(t==null?void 0:t.id)||"0000000000",[o,l]=c.useState("dashboard"),[d,p]=c.useState(null),[x,b]=c.useState(null),[m,w]=c.useState("week"),[j,C]=c.useState(!1),[q,g]=c.useState(!1),[u,f]=c.useState(""),[y,L]=c.useState([]),[P,I]=c.useState(!1),[D,R]=c.useState(""),[U,pe]=c.useState("online"),[ie,se]=c.useState([]),[_e,ge]=c.useState(!1),[$,X]=c.useState(""),[E,F]=c.useState([]),[W,J]=c.useState(""),[Y,ve]=c.useState(!1),[oe,Q]=c.useState(!1),[he,ye]=c.useState(""),[ke,ut]=c.useState(""),[Ie,T]=c.useState(""),[K,le]=c.useState(!1),[Z,ce]=c.useState(""),[Ve,Oe]=c.useState(""),[Ke,kt]=c.useState([]),[Nt,Ge]=c.useState([]),[ze,Je]=c.useState([]),[pt,at]=c.useState({pattern:"",price:""}),[ft,qe]=c.useState({pattern:"",price:""}),[Xe,It]=c.useState({pattern:"",price:""}),Qt=N=>Number(String(N??"").replace(",",".").trim()),k=c.useCallback(()=>{ve(!0),ye(""),ut(""),ce(""),Oe(""),Promise.all([Qh(),Yh()]).then(([N,M])=>{const te=Array.isArray(N==null?void 0:N.rows)?N.rows:[];F(te);const G=(N==null?void 0:N.ingestChatId)!=null?String(N.ingestChatId):"";J(G);const mt=M==null?void 0:M.defaultPriceEur;mt!=null&&Number.isFinite(Number(mt))?T(String(Number(mt))):T("");const Bt=Array.isArray(M==null?void 0:M.rules)?M.rules:[],zr=Yt=>Bt.filter(qr=>qr.type===Yt).map(qr=>({pattern:String(qr.pattern??""),priceEur:Number(qr.priceEur)}));kt(zr("level")),Ge(zr("bin")),Je(zr("banque")),at({pattern:"",price:""}),qe({pattern:"",price:""}),It({pattern:"",price:""})}).catch(N=>{ye((N==null?void 0:N.message)||"Impossible de charger les paramètres."),F([]),J(""),T(""),kt([]),Ge([]),Je([])}).finally(()=>ve(!1))},[]);c.useEffect(()=>{o==="settings"&&k()},[o,k]);const z=c.useCallback(()=>{Q(!0),ye(""),ut("");const N=W.trim().replace(/\s+/g,"");fp({chatId:N===""?null:N}).then(M=>{const te=(M==null?void 0:M.ingestChatId)!=null?String(M.ingestChatId):"";J(te);const G=(M==null?void 0:M.rowId)!=null?Number(M.rowId):0;F(te?[{id:G,chatId:te}]:[]),ut(te?"Groupe enregistré. L’ingest est autorisé pour ce supergroupe.":"Aucun groupe enregistré.")}).catch(M=>{ye((M==null?void 0:M.message)||"Enregistrement impossible.")}).finally(()=>Q(!1))},[W]),S=c.useCallback(()=>{Q(!0),ye(""),ut(""),fp({chatId:null}).then(()=>{J(""),F([]),ut("Groupe retiré.")}).catch(N=>{ye((N==null?void 0:N.message)||"Suppression impossible.")}).finally(()=>Q(!1))},[]),O=c.useCallback(()=>{ce(""),Oe("");const N=pt.pattern.trim(),M=Qt(pt.price);if(N){if(!Number.isFinite(M)||M<0){ce("Prix level invalide");return}kt(te=>[...te,{pattern:N,priceEur:M}]),at({pattern:"",price:""})}},[pt]),V=c.useCallback(()=>{ce(""),Oe("");const N=ft.pattern.trim().replace(/\D/g,""),M=Qt(ft.price);if(N){if(!Number.isFinite(M)||M<0){ce("Prix BIN invalide");return}Ge(te=>[...te,{pattern:N,priceEur:M}]),qe({pattern:"",price:""})}},[ft]),H=c.useCallback(()=>{ce(""),Oe("");const N=Xe.pattern.trim(),M=Qt(Xe.price);if(N){if(!Number.isFinite(M)||M<0){ce("Prix banque invalide");return}Je(te=>[...te,{pattern:N,priceEur:M}]),It({pattern:"",price:""})}},[Xe]),ue=c.useCallback(()=>{le(!0),ce(""),Oe("");const N=[...Ke.map(G=>({type:"level",pattern:String(G.pattern).trim(),priceEur:Number(G.priceEur)})),...Nt.map(G=>({type:"bin",pattern:String(G.pattern).replace(/\D/g,""),priceEur:Number(G.priceEur)})),...ze.map(G=>({type:"banque",pattern:String(G.pattern).trim(),priceEur:Number(G.priceEur)}))];for(const G of N){if(!G.pattern){ce("Motif vide"),le(!1);return}if(!Number.isFinite(G.priceEur)||G.priceEur<0){ce("Prix invalide"),le(!1);return}}const M=Ie.trim().replace(",",".");let te=null;if(M!==""){const G=Number(M);if(!Number.isFinite(G)||G<0){ce("Prix de base invalide."),le(!1);return}te=G}mp({defaultPriceEur:te,rules:N}).then(G=>{const mt=Array.isArray(G==null?void 0:G.rules)?G.rules:[],Bt=zr=>mt.filter(Yt=>Yt.type===zr).map(Yt=>({pattern:String(Yt.pattern),priceEur:Number(Yt.priceEur)}));kt(Bt("level")),Ge(Bt("bin")),Je(Bt("banque")),(G==null?void 0:G.defaultPriceEur)==null?T(""):T(String(Number(G.defaultPriceEur))),Oe("Tarifs enregistrés.")}).catch(G=>{ce((G==null?void 0:G.message)||"Enregistrement impossible.")}).finally(()=>le(!1))},[Ie,Ke,Nt,ze]),ee=c.useCallback(()=>{le(!0),ce(""),Oe(""),mp({defaultPriceEur:null}).then(N=>{if(T(""),Array.isArray(N==null?void 0:N.rules)){const M=te=>N.rules.filter(G=>G.type===te).map(G=>({pattern:String(G.pattern??""),priceEur:Number(G.priceEur)}));kt(M("level")),Ge(M("bin")),Je(M("banque"))}Oe("Prix de base effacé (bot). Tes règles BIN / banque / level restent en place.")}).catch(N=>{ce((N==null?void 0:N.message)||"Réinitialisation impossible.")}).finally(()=>le(!1))},[]);c.useEffect(()=>{if(o!=="dashboard")return;let N=!1;return C(!0),f(""),pp({period:"all"}).then(M=>{N||p(M)}).catch(M=>{N||(f((M==null?void 0:M.message)||"Impossible de charger les statistiques"),p(null))}).finally(()=>{N||C(!1)}),()=>{N=!0}},[o]),c.useEffect(()=>{if(o!=="dashboard")return;let N=!1;return f(""),g(!0),pp({period:m==="week"?"week":"month"}).then(te=>{N||b(te)}).catch(te=>{N||(f((te==null?void 0:te.message)||"Impossible de charger les statistiques"),b(null))}).finally(()=>{N||g(!1)}),()=>{N=!0}},[o,m]);const Ze=c.useCallback(()=>{I(!0),R(""),Wh().then(N=>{L(Array.isArray(N)?N:[])}).catch(N=>{R((N==null?void 0:N.message)||"Impossible de charger le catalogue"),L([])}).finally(()=>I(!1))},[]);return c.useEffect(()=>{o==="products"&&Ze()},[o,Ze]),c.useEffect(()=>{if(o!=="products"||U!=="sold")return;let N=!1;return ge(!0),X(""),Hh({limit:80,offset:0}).then(M=>{N||se(Array.isArray(M==null?void 0:M.sales)?M.sales:[])}).catch(M=>{N||(X((M==null?void 0:M.message)||"Impossible de charger les ventes"),se([]))}).finally(()=>{N||ge(!1)}),()=>{N=!0}},[o,U]),n.jsxs("section",{className:"seller-panel admin-shell",children:[n.jsxs("div",{className:"panel-page-title",children:[n.jsx("h1",{children:"Yoda CC"}),n.jsx("p",{children:"REVENDEUR"})]}),n.jsxs("div",{className:"panel-topbar",children:[n.jsxs("div",{className:"header-left",children:[n.jsx("div",{className:"header-logo","aria-hidden":"true",children:r?n.jsx("img",{src:r,alt:"",className:"header-logo-img"}):i}),n.jsxs("div",{className:"header-main",children:[n.jsx("h2",{className:"header-title",children:a}),n.jsxs("p",{className:"header-id",children:["ID: ",s]})]})]}),n.jsx("div",{className:"panel-topbar-action",children:n.jsx("button",{type:"button",className:"seller-back",onClick:e,"aria-label":"Retour",children:"← RETOUR"})})]}),n.jsx("div",{className:"header-separator","aria-hidden":"true"}),n.jsxs("div",{className:"admin-main seller-main",children:[o==="dashboard"&&n.jsxs("div",{className:"seller-dash",children:[n.jsx("h3",{className:"admin-section-title seller-section-heading",children:"Tes performances"}),u&&!d&&!x?n.jsx("p",{className:"admin-error",children:u}):null,j&&!d?n.jsx("p",{className:"admin-hint",children:"Chargement des stats…"}):null,d?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"admin-stats-hero-row",children:[n.jsxs("div",{className:"admin-stats-hero admin-stats-hero--cyan",children:[n.jsx("span",{className:"admin-stats-hero-label",children:"CA de tes cartes vendues (total)"}),n.jsxs("span",{className:"admin-stats-hero-value",children:[Number(((St=d.commandes)==null?void 0:St.totalEur)??0).toFixed(2)," €"]}),n.jsx("span",{className:"admin-stats-hero-sub",children:"Uniquement les cartes ingérées depuis ton groupe (attribuées à ton compte)."})]}),n.jsxs("div",{className:"admin-stats-hero admin-stats-hero--green",children:[n.jsx("span",{className:"admin-stats-hero-label",children:"Nombre de tes cartes vendues"}),n.jsx("span",{className:"admin-stats-hero-value",children:((sr=d.ventes)==null?void 0:sr.count)??0}),n.jsxs("span",{className:"admin-stats-hero-sub",children:[Number(((or=d.ventes)==null?void 0:or.totalEur)??0).toFixed(2)," € cumulés sur ces ventes"]})]})]}),u&&d?n.jsx("p",{className:"admin-error",children:u}):null,q&&!x?n.jsx("p",{className:"admin-hint",children:"Chargement des graphiques…"}):null,x?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"admin-stats-chart-card admin-stats-hero--cyan",children:[n.jsxs("div",{className:"admin-stats-chart-head",children:[n.jsxs("div",{children:[n.jsx("h4",{className:"admin-stats-chart-title",children:"CA (tes cartes)"}),n.jsx("p",{className:"admin-stats-chart-sub",children:"Montant des ventes de tes cartes sur la période"})]}),n.jsxs("label",{className:"admin-stats-chart-select-wrap",htmlFor:"seller-chart-period",children:[n.jsx("span",{className:"visually-hidden",children:"Période du graphique"}),n.jsxs("select",{id:"seller-chart-period",className:"admin-stats-chart-select",value:m,onChange:N=>w(N.target.value),disabled:q,children:[n.jsx("option",{value:"week",children:"Semaine"}),n.jsx("option",{value:"month",children:"Mois"})]})]})]}),n.jsxs("p",{className:"admin-stats-chart-range",children:[x.from," → ",x.to,q?" · mise à jour…":""]}),n.jsx("div",{className:q?"admin-stats-chart-dim":"",children:n.jsx($i,{series:x.series,chartPeriod:m})})]}),n.jsxs("div",{className:"admin-stats-chart-card admin-stats-hero--green",children:[n.jsx("div",{className:"admin-stats-chart-head",children:n.jsxs("div",{children:[n.jsx("h4",{className:"admin-stats-chart-title",children:"Volume (tes cartes)"}),n.jsx("p",{className:"admin-stats-chart-sub",children:"Nombre de cartes vendues — même période que le graphique CA"})]})}),n.jsx("div",{className:q?"admin-stats-chart-dim":"",children:n.jsx($i,{series:x.series,chartPeriod:m,metric:"ventesCount"})}),n.jsxs("div",{className:"admin-stats-mini-grid",children:[n.jsxs("div",{className:"admin-stats-mini",children:[n.jsx("span",{className:"admin-stats-mini-label",children:"Cartes vendues"}),n.jsx("span",{className:"admin-stats-mini-value",children:((Vr=x.ventes)==null?void 0:Vr.count)??0})]}),n.jsxs("div",{className:"admin-stats-mini",children:[n.jsx("span",{className:"admin-stats-mini-label",children:"Montant"}),n.jsxs("span",{className:"admin-stats-mini-value",children:[Number(((ba=x.ventes)==null?void 0:ba.totalEur)??0).toFixed(2)," €"]})]})]})]})]}):q?null:n.jsx("p",{className:"admin-hint",children:"Aucune donnée sur cette période."})]}):null]}),o==="products"&&n.jsxs("div",{className:"seller-products-section",children:[n.jsx("h3",{className:"admin-section-title seller-section-heading",children:"Tes cartes"}),n.jsxs("div",{className:"seller-subtabs",role:"tablist","aria-label":"Filtre produits",children:[n.jsx("button",{type:"button",role:"tab","aria-selected":U==="online",className:`seller-subtab ${U==="online"?"seller-subtab--active":""}`,onClick:()=>pe("online"),children:"En ligne"}),n.jsx("button",{type:"button",role:"tab","aria-selected":U==="sold",className:`seller-subtab ${U==="sold"?"seller-subtab--active":""}`,onClick:()=>pe("sold"),children:"Vendus"})]}),U==="online"&&n.jsxs(n.Fragment,{children:[P&&n.jsx("p",{className:"admin-hint",children:"Chargement…"}),D&&n.jsx("p",{className:"admin-error",children:D}),!P&&!y.length?n.jsxs("div",{className:"seller-empty-block",children:[n.jsx("div",{className:"seller-empty-icon-wrap","aria-hidden":!0,children:n.jsxs("svg",{className:"seller-empty-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"11",cy:"11",r:"6.5"}),n.jsx("path",{d:"m16.5 16.5 4 4"}),n.jsx("path",{d:"M8 8l6 6",strokeWidth:"1.5"})]})}),n.jsx("p",{className:"seller-empty-title",children:"Aucun produit"}),n.jsx("p",{className:"seller-empty-sub",children:"Aucune carte à toi en ligne. Vérifie ton groupe d’ingest (Paramètres) et poste depuis ce supergroupe."})]}):n.jsx("ul",{className:"seller-products-list seller-products-list--flush",children:y.map(N=>{const M=ga(N),te=xl(N.banque);return n.jsxs("li",{className:"seller-product-row",children:[n.jsxs("div",{children:[n.jsxs("strong",{children:["#",N.id]}),n.jsxs("p",{children:["BIN ",M||"—"," · ",te,N.ville?` · ${N.ville}`:""]})]}),n.jsxs("span",{children:[Number(N.prix??0).toFixed(2)," €"]})]},N.id)})})]}),U==="sold"&&n.jsxs(n.Fragment,{children:[_e&&n.jsx("p",{className:"admin-hint",children:"Chargement…"}),&n.jsx("p",{className:"admin-error",children:$}),!_e&&!ie.length?n.jsxs("div",{className:"seller-empty-block",children:[n.jsx("div",{className:"seller-empty-icon-wrap","aria-hidden":!0,children:n.jsxs("svg",{className:"seller-empty-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2"}),n.jsx("path",{d:"M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v0a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v0Z"}),n.jsx("path",{d:"M9 12h6M9 16h4"})]})}),n.jsx("p",{className:"seller-empty-title",children:"Aucune vente à afficher"}),n.jsx("p",{className:"seller-empty-sub",children:"Seules les ventes de cartes qui t’étaient attribuées (ingest depuis ton groupe) apparaissent ici."})]}):n.jsx("ul",{className:"seller-products-list seller-products-list--flush",children:ie.map(N=>n.jsxs("li",{className:"seller-product-row",children:[n.jsxs("div",{children:[n.jsxs("strong",{children:["BIN ",N.bin||"—"]}),n.jsxs("p",{children:[N.banque||"—"," · ",yg(N.soldAtIso)]})]}),n.jsxs("span",{children:[Number(N.prixEur??0).toFixed(2)," €"]})]},N.id))})]})]}),o==="settings"&&n.jsxs("div",{className:"seller-settings-section",children:[n.jsx("h3",{className:"admin-section-title seller-section-heading",children:"Paramètres"}),n.jsxs("div",{className:"seller-settings-card seller-ingest-card",children:[n.jsx("h4",{className:"seller-ingest-card-title",children:"Groupe pour l’ingest des cartes"}),n.jsxs("p",{className:"seller-settings-lead seller-ingest-intro",children:["Indique l’ID du ",n.jsx("strong",{children:"supergroupe"})," où tu postes les cartes : il sera lié à ton compte Telegram ",n.jsx("strong",{children:s})," dans la table ",n.jsx("code",{className:"seller-ingest-code",children:"chatid"})]}),n.jsxs("p",{className:"seller-settings-lead seller-ingest-intro seller-ingest-privacy-hint",children:[n.jsx("strong",{children:"Important :"})," chez BotFather, pour ce bot, ",n.jsx("code",{className:"seller-ingest-code",children:"/setprivacy"})," ","→ ",n.jsx("strong",{children:"Disable"}),". Sinon Telegram n’envoie pas les messages du groupe au bot (transferts ignorés). Dans le groupe, ",n.jsx("code",{className:"seller-ingest-code",children:"/pingingest"})," vérifie que l’ID est bien enregistré."]}),Y?n.jsx("p",{className:"admin-hint",children:"Chargement…"}):null,he?n.jsx("p",{className:"admin-error",children:he}):null,ke?n.jsx("p",{className:"admin-hint seller-ingest-ok",children:ke}):null,n.jsxs("div",{className:"seller-group-form seller-ingest-form",children:[n.jsx("input",{type:"text",inputMode:"numeric",className:"seller-ingest-input",placeholder:"ID de groupe (ex. -1001234567890)",value:W,onChange:N=>J(N.target.value),disabled:Y||oe||K,autoComplete:"off"}),n.jsx("button",{type:"button",className:"seller-ingest-add-btn",onClick:z,disabled:Y||oe||K,children:oe?"…":"Enregistrer"})]}),n.jsxs("div",{className:"seller-ingest-table-wrap",children:[n.jsxs("div",{className:"seller-group-row seller-group-row-head","aria-hidden":!0,children:[n.jsx("span",{children:"#"}),n.jsx("span",{children:"ID de groupe"}),n.jsx("span",{children:"Actions"})]}),!Y&&E.length===0?n.jsx("p",{className:"seller-ingest-table-empty",children:"Aucun groupe lié à ton compte."}):E.map((N,M)=>n.jsxs("div",{className:"seller-group-row",children:[n.jsx("span",{children:M+1}),n.jsx("span",{className:"seller-ingest-table-chat",children:N.chatId}),n.jsx("button",{type:"button",className:"seller-group-delete seller-ingest-remove",onClick:S,disabled:oe||K,children:"Retirer"})]},`${N.id}-${N.chatId}`))]})]}),n.jsxs("div",{className:"seller-settings-card seller-price-card",children:[n.jsx("h4",{className:"seller-ingest-card-title",children:"Prix de tes cartes"}),n.jsxs("p",{className:"seller-settings-lead seller-ingest-intro",children:["Même logique que l’admin : priorité ",n.jsx("strong",{children:"BIN"})," (préfixe le plus long), puis"," ",n.jsx("strong",{children:"banque"}),", puis ",n.jsx("strong",{children:"level"}),". Sinon le"," ",n.jsx("strong",{children:"prix de base"})," ci‑dessous (ou le prix du bot s’il est vide). Les règles admin / destockage ne s’appliquent pas à tes cartes."]}),Z?n.jsx("p",{className:"admin-error",children:Z}):null,Ve?n.jsx("p",{className:"admin-hint seller-ingest-ok",children:Ve}):null,n.jsxs("div",{className:"admin-price-rule-block",children:[n.jsx("h4",{className:"admin-price-rule-heading",children:"Prix de base (€)"}),n.jsxs("p",{className:"admin-price-rules-desc",style:{marginTop:0},children:["Stocké pour chaque nouvelle carte ingérée si aucune règle ne correspond. Laisse vide pour le prix du bot (",n.jsx("code",{className:"seller-ingest-code",children:"CARD_DEFAULT_PRICE"}),")."]}),n.jsx("div",{className:"admin-price-rule-add",children:n.jsx("input",{id:"seller-default-price",type:"text",inputMode:"decimal",className:"admin-chatid-input admin-price-rule-input admin-price-rule-input--narrow",placeholder:"€",value:Ie,onChange:N=>T(N.target.value),disabled:Y||K||oe,autoComplete:"off"})})]}),n.jsxs("div",{className:"admin-price-rules-card seller-price-rules-nested",children:[n.jsx("h3",{className:"admin-price-rules-title",children:"Prix par règle"}),n.jsxs("p",{className:"admin-price-rules-desc",children:["Surcharge le prix de base de tes fiches : priorité ",n.jsx("strong",{children:"BIN"})," (préfixe le plus long), puis"," ",n.jsx("strong",{children:"banque"}),", puis ",n.jsx("strong",{children:"level"}),". Sans règle, le prix reste le prix de base."]}),n.jsxs("div",{className:"admin-price-rule-block",children:[n.jsx("h4",{className:"admin-price-rule-heading",children:"Par level"}),n.jsxs("div",{className:"admin-price-rule-add",children:[n.jsx("input",{type:"text",className:"admin-chatid-input admin-price-rule-input",placeholder:"Ex. gold, classic…",value:pt.pattern,onChange:N=>at(M=>({...M,pattern:N.target.value})),disabled:Y||K||oe}),n.jsx("input",{type:"text",inputMode:"decimal",className:"admin-chatid-input admin-price-rule-input admin-price-rule-input--narrow",placeholder:"€",value:pt.price,onChange:N=>at(M=>({...M,price:N.target.value})),disabled:Y||K||oe}),n.jsx("button",{type:"button",className:"admin-chatid-btn-add",onClick:O,disabled:Y||K||oe,children:"+"})]}),n.jsx("ul",{className:"admin-price-rule-list",children:Ke.map((N,M)=>n.jsxs("li",{className:"admin-price-rule-line",children:[n.jsx("span",{className:"admin-price-rule-pat",children:N.pattern}),n.jsxs("span",{className:"admin-price-rule-val",children:[N.priceEur," €"]}),n.jsx("button",{type:"button",className:"admin-price-rule-remove",onClick:()=>kt(te=>te.filter((G,mt)=>mt!==M)),"aria-label":"Supprimer",children:"×"})]},`l-${N.pattern}-${M}`))})]}),n.jsxs("div",{className:"admin-price-rule-block",children:[n.jsx("h4",{className:"admin-price-rule-heading",children:"Par BIN (préfixe)"}),n.jsxs("div",{className:"admin-price-rule-add",children:[n.jsx("input",{type:"text",inputMode:"numeric",className:"admin-chatid-input admin-price-rule-input",placeholder:"Ex. 4973…",value:ft.pattern,onChange:N=>qe(M=>({...M,pattern:N.target.value})),disabled:Y||K||oe}),n.jsx("input",{type:"text",inputMode:"decimal",className:"admin-chatid-input admin-price-rule-input admin-price-rule-input--narrow",placeholder:"€",value:ft.price,onChange:N=>qe(M=>({...M,price:N.target.value})),disabled:Y||K||oe}),n.jsx("button",{type:"button",className:"admin-chatid-btn-add",onClick:V,disabled:Y||K||oe,children:"+"})]}),n.jsx("ul",{className:"admin-price-rule-list",children:Nt.map((N,M)=>n.jsxs("li",{className:"admin-price-rule-line",children:[n.jsx("span",{className:"admin-price-rule-pat",children:N.pattern}),n.jsxs("span",{className:"admin-price-rule-val",children:[N.priceEur," €"]}),n.jsx("button",{type:"button",className:"admin-price-rule-remove",onClick:()=>Ge(te=>te.filter((G,mt)=>mt!==M)),"aria-label":"Supprimer",children:"×"})]},`b-${N.pattern}-${M}`))})]}),n.jsxs("div",{className:"admin-price-rule-block",children:[n.jsx("h4",{className:"admin-price-rule-heading",children:"Par nom de banque"}),n.jsxs("div",{className:"admin-price-rule-add",children:[n.jsx("input",{type:"text",className:"admin-chatid-input admin-price-rule-input",placeholder:"Ex. BNP…",value:Xe.pattern,onChange:N=>It(M=>({...M,pattern:N.target.value})),disabled:Y||K||oe}),n.jsx("input",{type:"text",inputMode:"decimal",className:"admin-chatid-input admin-price-rule-input admin-price-rule-input--narrow",placeholder:"€",value:Xe.price,onChange:N=>It(M=>({...M,price:N.target.value})),disabled:Y||K||oe}),n.jsx("button",{type:"button",className:"admin-chatid-btn-add",onClick:H,disabled:Y||K||oe,children:"+"})]}),n.jsx("ul",{className:"admin-price-rule-list",children:ze.map((N,M)=>n.jsxs("li",{className:"admin-price-rule-line",children:[n.jsx("span",{className:"admin-price-rule-pat",children:N.pattern}),n.jsxs("span",{className:"admin-price-rule-val",children:[N.priceEur," €"]}),n.jsx("button",{type:"button",className:"admin-price-rule-remove",onClick:()=>Je(te=>te.filter((G,mt)=>mt!==M)),"aria-label":"Supprimer",children:"×"})]},`k-${N.pattern}-${M}`))})]}),n.jsx("div",{className:"admin-chatid-footer",children:n.jsx("button",{type:"button",className:"admin-chatid-btn-save",onClick:ue,disabled:Y||K||oe,children:K?"Enregistrement…":"Enregistrer les tarifs"})})]}),n.jsx("button",{type:"button",className:"seller-price-reset-btn",onClick:ee,disabled:Y||K||oe,children:"Réinitialiser le prix de base (prix du bot)"})]})]})]}),n.jsx(vg,{active:o,onChange:l})]})}function jg({active:e="accueil",onChange:t,cartCount:r=0}){const a={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round",className:"bottom-nav-icon-svg","aria-hidden":!0},i=Number(r)||0,s=i>99?"99+":String(i);return n.jsxs("nav",{className:"bottom-nav",children:[n.jsxs("button",{type:"button",className:`bottom-nav-item ${e==="accueil"?"bottom-nav-item-active":""}`,onClick:()=>t==null?void 0:t("accueil"),children:[n.jsx("span",{className:"bottom-nav-icon",children:n.jsxs("svg",{...a,children:[n.jsx("path",{d:"m3 10 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),n.jsx("path",{d:"M9 22V12h6v10"})]})}),n.jsx("span",{className:"bottom-nav-label",children:"Accueil"})]}),n.jsxs("button",{type:"button",className:`bottom-nav-item ${e==="panier"?"bottom-nav-item-active":""}`,onClick:()=>t==null?void 0:t("panier"),children:[n.jsxs("span",{className:"bottom-nav-icon-wrap",children:[n.jsx("span",{className:"bottom-nav-icon",children:n.jsxs("svg",{...a,children:[n.jsx("path",{d:"M8 7V5.5a4 4 0 0 1 8 0V7"}),n.jsx("path",{d:"M5 8.5h14l-1.35 10.2a2 2 0 0 1-2 1.8H8.35a2 2 0 0 1-2-1.8L5 8.5Z"}),n.jsx("path",{d:"M10 12v3M14 12v3"})]})}),i>0?n.jsx("span",{className:"bottom-nav-badge",children:s}):null]}),n.jsx("span",{className:"bottom-nav-label",children:"Panier"})]}),n.jsxs("button",{type:"button",className:`bottom-nav-item ${e==="precommande"?"bottom-nav-item-active":""}`,onClick:()=>t==null?void 0:t("precommande"),children:[n.jsx("span",{className:"bottom-nav-icon",children:n.jsxs("svg",{...a,children:[n.jsx("circle",{cx:"12",cy:"13",r:"7.5"}),n.jsx("path",{d:"M12 9.5V13l3 1.8"}),n.jsx("path",{d:"M7 4.5h10"}),n.jsx("path",{d:"M12 4.5V2.5"})]})}),n.jsx("span",{className:"bottom-nav-label",children:"Précommande"})]}),n.jsxs("button",{type:"button",className:`bottom-nav-item ${e==="commandes"?"bottom-nav-item-active":""}`,onClick:()=>t==null?void 0:t("commandes"),children:[n.jsx("span",{className:"bottom-nav-icon",children:n.jsxs("svg",{...a,children:[n.jsx("rect",{x:"7",y:"4",width:"10",height:"16",rx:"2"}),n.jsx("path",{d:"M10 4V3a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v1"}),n.jsx("path",{d:"M10 10h4M10 14h4M10 18h3"})]})}),n.jsx("span",{className:"bottom-nav-label",children:"Commandes"})]})]})}function kg({active:e="accueil",onChange:t,cartCount:r=0}){const a={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round",className:"top-shop-nav-icon-svg","aria-hidden":!0},i=Number(r)||0,s=i>99?"99+":String(i);return n.jsxs("nav",{className:"top-shop-nav","aria-label":"Navigation principale",children:[n.jsxs("button",{type:"button",className:`top-shop-nav-item ${e==="accueil"?"top-shop-nav-item-active":""}`,onClick:()=>t==null?void 0:t("accueil"),children:[n.jsx("span",{className:"top-shop-nav-icon",children:n.jsxs("svg",{...a,children:[n.jsx("path",{d:"m3 10 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"}),n.jsx("path",{d:"M9 22V12h6v10"})]})}),n.jsx("span",{className:"top-shop-nav-label",children:"Accueil"})]}),n.jsxs("button",{type:"button",className:`top-shop-nav-item ${e==="panier"?"top-shop-nav-item-active":""}`,onClick:()=>t==null?void 0:t("panier"),children:[n.jsxs("span",{className:"top-shop-nav-icon-wrap",children:[n.jsx("span",{className:"top-shop-nav-icon",children:n.jsxs("svg",{...a,children:[n.jsx("path",{d:"M8 7V5.5a4 4 0 0 1 8 0V7"}),n.jsx("path",{d:"M5 8.5h14l-1.35 10.2a2 2 0 0 1-2 1.8H8.35a2 2 0 0 1-2-1.8L5 8.5Z"}),n.jsx("path",{d:"M10 12v3M14 12v3"})]})}),i>0?n.jsx("span",{className:"top-shop-nav-badge",children:s}):null]}),n.jsx("span",{className:"top-shop-nav-label",children:"Panier"})]}),n.jsxs("button",{type:"button",className:`top-shop-nav-item ${e==="precommande"?"top-shop-nav-item-active":""}`,onClick:()=>t==null?void 0:t("precommande"),children:[n.jsx("span",{className:"top-shop-nav-icon",children:n.jsxs("svg",{...a,children:[n.jsx("circle",{cx:"12",cy:"13",r:"7.5"}),n.jsx("path",{d:"M12 9.5V13l3 1.8"}),n.jsx("path",{d:"M7 4.5h10"}),n.jsx("path",{d:"M12 4.5V2.5"})]})}),n.jsx("span",{className:"top-shop-nav-label",children:"Précommande"})]}),n.jsxs("button",{type:"button",className:`top-shop-nav-item ${e==="commandes"?"top-shop-nav-item-active":""}`,onClick:()=>t==null?void 0:t("commandes"),children:[n.jsx("span",{className:"top-shop-nav-icon",children:n.jsxs("svg",{...a,children:[n.jsx("rect",{x:"7",y:"4",width:"10",height:"16",rx:"2"}),n.jsx("path",{d:"M10 4V3a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1v1"}),n.jsx("path",{d:"M10 10h4M10 14h4M10 18h3"})]})}),n.jsx("span",{className:"top-shop-nav-label",children:"Commandes"})]})]})}const Ng=["Tous","ANDROID","IOS"];function wl(e,t){const r=new Set;for(const a of e){const i=t(a);i!=null&&String(i).trim()!==""&&r.add(String(i))}return["Tous",...Array.from(r).sort((a,i)=>a.localeCompare(i))]}function Ui({label:e,value:t,options:r,onChange:a}){const[i,s]=c.useState(!1),o=c.useRef(null),l=c.useId();return c.useEffect(()=>{if(!i)return;const d=x=>{o.current&&!o.current.contains(x.target)&&s(!1)},p=x=>{x.key==="Escape"&&s(!1)};return document.addEventListener("mousedown",d),document.addEventListener("touchstart",d,{passive:!0}),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("touchstart",d),document.removeEventListener("keydown",p)}},[i]),n.jsxs("div",{className:"filters-line",children:[n.jsx("span",{id:l,children:e}),n.jsxs("div",{className:`filters-dropdown ${i?"filters-dropdown--open":""}`,ref:o,children:[n.jsxs("button",{type:"button",className:"filters-dropdown-trigger","aria-expanded":i,"aria-haspopup":"listbox","aria-labelledby":l,onClick:()=>s(d=>!d),children:[n.jsx("span",{className:"filters-dropdown-value",children:t}),n.jsx("span",{className:"filters-dropdown-chevron","aria-hidden":!0})]}),i?n.jsx("ul",{className:"filters-dropdown-menu",role:"listbox",children:r.map(d=>n.jsx("li",{role:"none",children:n.jsx("button",{type:"button",role:"option","aria-selected":d===t,className:`filters-dropdown-option ${d===t?"filters-dropdown-option--current":""}`,onClick:()=>{a(d),s(!1)},children:d})},d))}):null]})]})}function Sg({products:e,initialFilters:t,onApply:r,onClose:a}){const[i,s]=c.useState(t);c.useEffect(()=>{const x=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=x}},[]);const o=c.useMemo(()=>({type:wl(e,x=>{var b;return(b=x.type)==null?void 0:b.toUpperCase()}),banque:wl(e,x=>x.banque),level:wl(e,x=>{var b;return(b=x.level)==null?void 0:b.toUpperCase()})}),[e]),l=(x,b)=>{s(m=>({...m,[x]:b}))},d=()=>{s({type:"Tous",banque:"Tous",level:"Tous",systeme:"Tous",departementCodes:"",minPrice:"",maxPrice:"",minAge:"",maxAge:""})},p=()=>{r(i),a()};return n.jsx("div",{className:"filters-page",role:"dialog","aria-modal":"true","aria-labelledby":"filters-page-title",children:n.jsxs("div",{className:"filters-page-shell",children:[n.jsxs("header",{className:"filters-page-header",children:[n.jsx("button",{type:"button",className:"filters-page-back",onClick:a,"aria-label":"Retour",children:n.jsx("span",{"aria-hidden":!0,children:"‹"})}),n.jsx("h1",{id:"filters-page-title",className:"filters-page-title",children:"Filtres"})]}),n.jsxs("div",{className:"filters-page-body",children:[n.jsx("p",{className:"filters-page-lead",children:"Affine la liste du catalogue."}),n.jsxs("div",{className:"filters-stack",children:[n.jsx(Ui,{label:"Type",value:i.type,options:o.type,onChange:x=>l("type",x)}),n.jsx(Ui,{label:"Banque",value:i.banque,options:o.banque,onChange:x=>l("banque",x)}),n.jsx(Ui,{label:"Niveau",value:i.level,options:o.level,onChange:x=>l("level",x)}),n.jsx(Ui,{label:"Système",value:i.systeme,options:Ng,onChange:x=>l("systeme",x)}),n.jsxs("label",{className:"filters-line",children:[n.jsx("span",{children:"Départements (depuis le CP)"}),n.jsx("input",{type:"text",inputMode:"numeric",autoComplete:"postal-code",placeholder:"ex. 92 75 33",value:i.departementCodes??"",onChange:x=>l("departementCodes",x.target.value)})]}),n.jsxs("div",{className:"filters-pair",children:[n.jsxs("label",{className:"filters-line",children:[n.jsx("span",{children:"Prix min (€)"}),n.jsx("input",{type:"number",inputMode:"decimal",placeholder:"—",value:i.minPrice,onChange:x=>l("minPrice",x.target.value)})]}),n.jsxs("label",{className:"filters-line",children:[n.jsx("span",{children:"Prix max (€)"}),n.jsx("input",{type:"number",inputMode:"decimal",placeholder:"—",value:i.maxPrice,onChange:x=>l("maxPrice",x.target.value)})]})]}),n.jsxs("div",{className:"filters-pair",children:[n.jsxs("label",{className:"filters-line",children:[n.jsx("span",{children:"Âge min"}),n.jsx("input",{type:"number",inputMode:"numeric",placeholder:"—",value:i.minAge,onChange:x=>l("minAge",x.target.value)})]}),n.jsxs("label",{className:"filters-line",children:[n.jsx("span",{children:"Âge max"}),n.jsx("input",{type:"number",inputMode:"numeric",placeholder:"—",value:i.maxAge,onChange:x=>l("maxAge",x.target.value)})]})]})]})]}),n.jsxs("footer",{className:"filters-page-footer",children:[n.jsx("button",{type:"button",className:"filters-page-btn filters-page-btn--ghost",onClick:d,children:"Réinitialiser"}),n.jsx("button",{type:"button",className:"filters-page-btn filters-page-btn--primary",onClick:p,children:"Appliquer"})]})]})})}function Eg(e=""){const t=String(e);return t.trim()?/iPhone|iPod/i.test(t)?"iPhone":/iPad/i.test(t)?"iPad":/Android/i.test(t)?"Android":"—":"—"}function Cg(e=""){const t=Eg(e);return t==="—"?"Android / iPhone":t}function zg(e){if(e==null)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString("fr-FR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})}function bp(e,t=""){const r=s=>s==null||String(s).trim()===""?"—":String(s).trim(),a=e||{},i=r(a.bin).replace(/^#/,"");return`🏦 Informations personnelles ├ 🧑 Nom complet : ${r(a.fullName)} ├ 🏠 Adresse : ${r(a.address)} ├ 📮 Code postal : ${r(a.zip)} ├ 🗺️ Région : ${r(a.region)} ├ 📲 Numéro de téléphone : ${r(a.phone)} ├ 📧 Email : ${r(a.email)} └ 🎂 Date de naissance : ${r(a.birthDate)} 💳 Carte de paiement ├ 🧑 Titulaire : ${r(a.holder)} ├ 💳 Numéro de carte : ${r(a.cardNumber)} ├ 🗓️ Expiration : ${r(a.exp)} └ 🔒 Cryptogramme (CVV) : ${r(a.cvc)} 🏦 Coordonnées bancaires ├ 🔢 BIN : #${i} ├ 🏛️ Banque : ${r(a.bankName)} ├ 🧾 Type : ${r(a.cardType)} └ 🌟 Niveau : ${r(a.cardLevel)} 🧩 Informations supplémentaires ├ 🖊️ Auteur : Yoda CC ├ 📦 Base : Mondial Relay ├ 📱 Système : ${Cg(t)} ├ 🎯 UA : ${r(a.clientUa)} ├ 🎯 Region : ${r(a.region)} └ 📅 Date : ${zg(a.arrivalAt)}`}function Pg(e){const t=i=>i==null||String(i).trim()===""?"—":String(i).trim(),r=e||{},a=t(r.bin).replace(/^#/,"");return`💳 Carte de paiement ├ 🧑 Titulaire : ${t(r.holder)} ├ 💳 Numéro de carte : ${t(r.cardNumber)} ├ 🗓️ Expiration : ${t(r.exp)} └ 🔒 Cryptogramme (CVV) : ${t(r.cvc)} 🏦 Coordonnées bancaires ├ 🔢 BIN : #${a} ├ 🏛️ Banque : ${t(r.bankName)} ├ 🧾 Type : ${t(r.cardType)} └ 🌟 Niveau : ${t(r.cardLevel)}`}const Tg=[{value:"aucun",label:"Aucun"},{value:"no_rep",label:"No rep"},{value:"deja_call",label:"Déjà call"}];function _g(e){const t=e==null?void 0:e.contactTag;return t==null||t===""||t==="aucun"?"aucun":t==="deja_call"?"deja_call":"no_rep"}function Lg(){return n.jsx("svg",{className:"order-detail-cc-copy-svg",viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":!0,children:n.jsx("path",{fill:"currentColor",d:"M16 1H4c-1.1 0-2 .9-2 2v12h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})})}function Ig(){return n.jsx("svg",{className:"order-detail-cc-copy-svg",viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":!0,children:n.jsx("path",{fill:"currentColor",d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})})}function Mg(){return n.jsx("svg",{className:"order-detail-action-icon",viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":!0,children:n.jsx("path",{fill:"currentColor",d:"M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"})})}function Ag(){return n.jsx("svg",{className:"order-detail-action-icon",viewBox:"0 0 24 24",width:"18",height:"18","aria-hidden":!0,children:n.jsx("path",{fill:"currentColor",d:"M2.01 21L23 12 2.01 3 2 10l15 2-15 2z"})})}function Dg({options:e,value:t,disabled:r,isOpen:a,onToggle:i,onClose:s,onPick:o,ariaLabel:l}){var x;const d=c.useRef(null);c.useEffect(()=>{if(!a)return;const b=w=>{d.current&&!d.current.contains(w.target)&&s()},m=w=>{w.key==="Escape"&&s()};return document.addEventListener("mousedown",b),document.addEventListener("touchstart",b,{passive:!0}),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("touchstart",b),document.removeEventListener("keydown",m)}},[a,s]);const p=((x=e.find(b=>b.value===t))==null?void 0:x.label)??"—";return n.jsxs("div",{ref:d,className:`order-detail-tag-wrap ${a?"order-detail-tag-wrap--open":""}`,children:[n.jsxs("button",{type:"button",className:"order-detail-tag-trigger",disabled:r,"aria-expanded":a,"aria-haspopup":"listbox","aria-label":l,onClick:i,children:[n.jsx("span",{className:"order-detail-tag-trigger-label",children:p}),n.jsx("span",{className:`order-detail-tag-trigger-chevron ${a?"order-detail-tag-trigger-chevron--open":""}`,"aria-hidden":!0})]}),a?n.jsx("ul",{className:"order-detail-tag-menu",role:"listbox",children:e.map(b=>n.jsx("li",{role:"none",children:n.jsx("button",{type:"button",role:"option","aria-selected":b.value===t,className:`order-detail-tag-option ${b.value===t?"order-detail-tag-option--current":""}`,onClick:()=>{o(b.value),s()},children:b.label})},b.value))}):null]})}function Fg({order:e,onBack:t,userAgent:r,telegramId:a,onContactTagSaved:i,onArchiveStateChanged:s}){const o=r||(typeof navigator<"u"?navigator.userAgent:"—"),l=Array.isArray(e==null?void 0:e.items)?e.items:[],[d,p]=c.useState(()=>new Set),[x,b]=c.useState(null),[m,w]=c.useState(null),[j,C]=c.useState(null),[q,g]=c.useState(!1),[u,f]=c.useState(!1),y=c.useRef(null),L=c.useCallback(()=>w(null),[]);c.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]);const P=$=>{p(X=>{const E=new Set(X);return E.has($)?E.delete($):E.add($),E})},I=e!=null&&e.createdAt?new Date(e.createdAt).toLocaleString("fr-FR",{day:"2-digit",month:"long",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—",D=(e==null?void 0:e.fromPreorder)===!0,R=(e==null?void 0:e.archivedAt)!=null&&String(e.archivedAt).trim()!=="",U=async($,X)=>{const E=$.productSellId;if(!(E==null||Number.isNaN(Number(E))||!a)){b($.id);try{await Zh(a,E,X),i==null||i()}catch{}finally{b(null)}}},pe=async $=>{const X=Pg($.detail||{});try{await navigator.clipboard.writeText(X),C($.id),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>C(null),2e3)}catch{try{const E=document.createElement("textarea");E.value=X,E.style.position="fixed",E.style.left="-9999px",document.body.appendChild(E),E.select(),document.execCommand("copy"),document.body.removeChild(E),C($.id),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>C(null),2e3)}catch{}}},ie=()=>{const $=` ${"─".repeat(36)} `,X=l.map((J,Y)=>`=== Commande #${e.id} — Produit ${Y+1} === ${bp(J.detail||{},o)}`),E=new Blob([X.join($)],{type:"text/plain;charset=utf-8"}),F=URL.createObjectURL(E),W=document.createElement("a");W.href=F,W.download=`commande-${e.id}-ccs.txt`,W.click(),URL.revokeObjectURL(F)},se=$=>{var F;const X=typeof window<"u"?window:null,E=(F=X==null?void 0:X.Telegram)==null?void 0:F.WebApp;typeof(E==null?void 0:E.showAlert)=="function"?E.showAlert($):X&&X.alert($)},_e=async()=>{if(!(!a||(e==null?void 0:e.id)==null)){g(!0);try{const $=await eg(a,e.id);se(`Envoyé sur Telegram : ${$.messagesSent} message(s).`)}catch($){se(($==null?void 0:$.message)||"Erreur envoi Telegram")}finally{g(!1)}}},ge=async()=>{if(!(!a||(e==null?void 0:e.id)==null)){f(!0);try{await Xh(a,e.id,!R),se(R?"Commande remise dans l’historique actif.":"Commande archivée."),s==null||s()}catch($){se(($==null?void 0:$.message)||"Erreur archive")}finally{f(!1)}}};return n.jsxs("section",{className:"menu-panel order-detail-panel",children:[n.jsxs("button",{type:"button",className:"order-detail-back",onClick:t,children:[n.jsx("span",{className:"order-detail-back-icon","aria-hidden":!0,children:"‹"}),"Retour"]}),n.jsxs("h2",{className:"menu-panel-title order-detail-title",children:["Commande #",e.id]}),D?n.jsxs("p",{className:"order-detail-preorder-banner",role:"status",children:[n.jsx("span",{className:"order-detail-preorder-banner-icon","aria-hidden":"true",children:"✓"}),n.jsxs("span",{children:[n.jsx("strong",{children:"Précommande"})," — cette commande provient de ton enchère précommande (restock automatique). Le montant affiché était déjà couvert par ta réservation."]})]}):null,n.jsxs("p",{className:"menu-panel-text order-detail-meta",children:[I," · ",Number(e.totalEur??0).toFixed(2)," € · ",l.length," article",l.length>1?"s":""]}),n.jsxs("div",{className:"order-detail-archive-row",children:[n.jsx("button",{type:"button",className:`order-detail-archive-btn ${R?"order-detail-archive-btn--restore":""}`,onClick:ge,disabled:!a||u,children:u?"…":R?"Remettre dans Mes commandes":"Archiver"}),n.jsx("span",{className:"order-detail-archive-hint",children:R?"Visible dans l’onglet Archives.":"Après utilisation de la carte, archive pour te repérer."})]}),l.length>0?n.jsxs("div",{className:"order-detail-actions",children:[n.jsxs("button",{type:"button",className:"order-detail-action-btn",onClick:ie,children:[n.jsx(Mg,{}),n.jsx("span",{children:"Télécharger les CC (.txt)"})]}),n.jsxs("button",{type:"button",className:"order-detail-action-btn",onClick:_e,disabled:!a||q,children:[n.jsx(Ag,{}),n.jsx("span",{children:q?"Envoi…":"M’envoyer sur Telegram"})]})]}):null,n.jsx("div",{className:"order-detail-products",children:l.map(($,X)=>{const E=bp($.detail||{},o),F=d.has($.id),W=E.split(` `).slice(0,6).join(` `),J=_g($.detail),Y=$.productSellId!=null&&a;return n.jsxs("article",{className:`order-detail-block ${F?"order-detail-block-open":""}`,children:[n.jsxs("div",{className:"order-detail-block-head",children:[n.jsxs("span",{children:["Produit ",X+1]}),n.jsxs("div",{className:"order-detail-block-head-right",children:[n.jsx("button",{type:"button",className:`order-detail-cc-copy ${j===$.id?"order-detail-cc-copy--done":""}`,onClick:()=>pe($),"aria-label":j===$.id?"Copié":`Copier la CC produit ${X+1}`,children:j===$.id?n.jsx(Ig,{}):n.jsx(Lg,{})}),Y?n.jsx(Dg,{options:Tg,value:J,disabled:x===$.id,isOpen:m===$.id,onToggle:()=>w(ve=>ve===$.id?null:$.id),onClose:L,onPick:ve=>U($,ve),ariaLabel:`Tag suivi produit ${X+1}`}):null]})]}),F?null:n.jsxs("div",{className:"order-detail-collapsed",children:[n.jsx("pre",{className:"order-detail-pre order-detail-pre-preview",children:W}),n.jsx("div",{className:"order-detail-preview-fade","aria-hidden":"true"})]}),n.jsxs("button",{type:"button",className:"order-detail-toggle",onClick:()=>P($.id),"aria-expanded":F,"aria-label":F?`Replier le produit ${X+1}`:`Dérouler le produit ${X+1}`,children:[n.jsx("span",{className:"order-detail-toggle-label",children:F?"Replier":"Dérouler"}),n.jsx("span",{className:`order-detail-toggle-chevron ${F?"order-detail-toggle-chevron-open":""}`,"aria-hidden":!0,children:"▼"})]}),F?n.jsx("pre",{className:"order-detail-pre",children:E}):null]},$.id)})})]})}const ir=40;function Rg(e){if(!e)return"?";const t=(e.first_name||"").trim(),r=(e.last_name||"").trim();if(t||r){const i=`${t.slice(0,1)}${r.slice(0,1)}`.toUpperCase().trim();if(i)return i}const a=(e.username||"").trim();return a?a.slice(0,2).toUpperCase():"?"}function jl(e){return e==="android"?"ANDROID":e==="any"?"Tous":"IOS"}function Og(e,t,r){const a=r?"cette ville":"ce BIN";return e==null||t==null?"Priorité : prix par carte (enchère unitaire), puis date d’inscription.":e===1?`Votre réservation est 1re dans la file pour ${a} (${t} enchère(s) active(s)). Aucune autre enchère n’a une priorité supérieure à la vôtre 👑`:`Vous êtes ${e}e sur ${t} pour ${a}. Les enchères les plus élevées par carte sont servies en premier ; à égalité de prix, le plus ancien passe avant.`}function $g(e){let t=String(e??"").replace(",",".").replace(/[^\d.]/g,"");const r=t.indexOf(".");if(r!==-1&&(t=`${t.slice(0,r+1)}${t.slice(r+1).replace(/\./g,"").slice(0,2)}`),t===""||t===".")return t;if(t.endsWith(".")){const i=t.slice(0,-1);return i===""?".":`${parseInt(i,10)}.`}const a=parseFloat(t);return Number.isFinite(a)?String(a):t}function Bg(e){const t=String(e??"").replace(/\D/g,"");return t===""?"":String(Math.min(999,parseInt(t,10)))}function Ug({binFilter:e,isCriteria:t}){const[r,a]=c.useState(!1),i=String(e??"").replace(/\D/g,"").slice(0,6),s=!t&&i.length===6&&!r,o=s?`https://cardimages.imaginecurve.com/cards/${i}.png`:"";return n.jsx("div",{className:"preorder-active-thumb",children:s&&o?n.jsx("img",{src:o,alt:"",className:"preorder-active-thumb-img",loading:"lazy",referrerPolicy:"no-referrer",decoding:"async",onError:()=>a(!0)}):n.jsx("div",{className:"preorder-active-thumb-fallback","aria-hidden":!0,children:t?n.jsx("span",{className:"preorder-active-thumb-fallback-label",children:"Critères"}):n.jsx("span",{className:"preorder-active-thumb-fallback-bin",children:i||"—"})})})}function Vg(){return n.jsx("svg",{className:"preorder-active-crown-ic",viewBox:"0 0 24 24","aria-hidden":"true",children:n.jsx("path",{fill:"currentColor",d:"M5 16L3 5l5.5 3L12 4l3.5 4L21 5l-2 11H5zm2.1-2h9.8l.5-5.3-3.1-2L12 12.5 8.7 6.7l-3.1 2 .5 5.3z"})})}function Lt(e){var r;const t=typeof window<"u"?(r=window.Telegram)==null?void 0:r.WebApp:null;typeof(t==null?void 0:t.showAlert)=="function"?t.showAlert(e):typeof window<"u"&&window.alert(e)}function Vi(e){const t=Number(e);return!Number.isFinite(t)||t===0?"—":t.toFixed(2)}function qg(e){const t=Math.floor(Number(e));return Number.isFinite(t)&&t>0?t:null}function Wg(){return n.jsx("div",{className:"preorder-empty-icon-wrap","aria-hidden":"true",children:n.jsxs("svg",{className:"preorder-empty-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("circle",{cx:"12",cy:"12",r:"9"}),n.jsx("path",{d:"M12 7v5l3 2"})]})})}function Hg({telegramId:e,telegramUser:t,panelVisible:r=!0,onBalanceRefresh:a,onOpenOrderDetail:i}){const[s,o]=c.useState([]),[l,d]=c.useState(!1),[p,x]=c.useState(!1),[b,m]=c.useState(""),[w,j]=c.useState("any"),[C,q]=c.useState(String(ir)),[g,u]=c.useState("1"),[f,y]=c.useState(!1),[L,P]=c.useState(null),[I,D]=c.useState(null),[R,U]=c.useState(null),[pe,ie]=c.useState(""),[se,_e]=c.useState(!1),[ge,$]=c.useState("current"),X=c.useMemo(()=>I!=null?s.find(T=>T.id===I):null,[I,s]),E=c.useMemo(()=>{const T=parseFloat(String(C).replace(",",".")),K=Math.max(0,parseInt(String(g).replace(/\D/g,""),10)||0),le=Number.isFinite(T)?T:0;return Math.round(Math.max(0,le)*Math.max(1,K)*100)/100},[C,g]),F=c.useMemo(()=>s.filter(T=>String(T.status||"").toLowerCase()!=="cancelled"),[s]),W=c.useMemo(()=>s.filter(T=>String(T.status||"").toLowerCase()==="cancelled"),[s]),J=ge==="cancelled"?W:F,Y=c.useMemo(()=>String(b).replace(/\D/g,""),[b]),ve=Y.length>=6,oe=ve,Q=c.useCallback(async(T={})=>{const{silent:K=!1}=T;if(e==null){o([]);return}K||d(!0);let le=null;for(let Z=0;Z<3;Z+=1)try{const ce=await hp(e),Ve=Array.isArray(ce==null?void 0:ce.encheres)?ce.encheres:[];o(Ve),le=null;break}catch(ce){le=ce,Z<2&&await new Promise(Ve=>setTimeout(Ve,350*(Z+1)))}le!=null&&(K||Lt("Impossible de charger les précommandes. Vérifiez la connexion puis réessayez.")),K||d(!1)},[e]),he=c.useRef(!1);c.useEffect(()=>{!r||e==null||(Q({silent:he.current}),he.current=!0)},[r,Q,e]),c.useEffect(()=>{if(!r||e==null)return;const T=window.setInterval(()=>{Q({silent:!0})},3e4);return()=>window.clearInterval(T)},[r,e,Q]),c.useEffect(()=>{const T=()=>{document.visibilityState!=="visible"||!r||Q({silent:!0})};return document.addEventListener("visibilitychange",T),()=>document.removeEventListener("visibilitychange",T)},[r,Q]);const ye=()=>{if(!e){Lt("Ouvrez la boutique depuis Telegram pour enchérir.");return}m(""),j("any"),u("1"),q(String(ir)),x(!0)},ke=async()=>{if(!e)return;if(!ve){Lt("Indiquez un BIN d’au moins 6 chiffres.");return}const T=parseFloat(String(C).replace(",","."));if(!Number.isFinite(T)||T{if(e){P(T);try{await rg(e,T),a==null||a(),await Q({silent:!0}),Lt("Enchère annulée.")}catch(K){Lt((K==null?void 0:K.message)||"Erreur")}finally{P(null)}}},Ie=async T=>{if(!e)return;const K=Number(pe);if(Number.isNaN(K)||K{const K=Array.isArray(T.fulfillmentCommandeIds)?T.fulfillmentCommandeIds:[],le=K.length>0&&typeof i=="function",Z=T.status==="active",ce=Vi(T.bidPerUnitEur),Ve=Vi(T.totalEur),Oe=T.status==="fulfilled"?`${ce} €`:`${Ve} €`,Ke=T.preorderMode==="criteria",kt=Ke?T.filterVille?String(T.filterVille).trim():"—":T.binFilter?String(T.binFilter).replace(/^#/,"").replace(/\D/g,"").slice(0,8):"—",Nt=Number(T.bidPerUnitEur),Ge=Vi(Nt),ze=Number(T.totalEur??0),Je=Vi(ze),pt=T.bestBidPerUnitEur,at=Number(pt),ft=pt!=null&&Number.isFinite(at)&&at>0?at.toFixed(2):null,qe=qg(T.quantity),Xe=T.queuePosition,It=T.queueSize,Qt=Xe===1;return Z?n.jsx("div",{className:"preorder-mes-card preorder-mes-card--active",children:n.jsxs("div",{className:"preorder-active-card",children:[n.jsxs("div",{className:"preorder-active-card-main",children:[n.jsxs("div",{className:"preorder-active-left-col",children:[n.jsx("div",{className:"preorder-active-crown-slot",children:Qt?n.jsx(Vg,{}):n.jsxs("span",{className:"preorder-active-rank-badge","aria-hidden":"true",children:["#",Xe??"?"]})}),n.jsx(Ug,{binFilter:T.binFilter,isCriteria:Ke})]}),n.jsxs("div",{className:"preorder-active-details",children:[n.jsx("div",{className:"preorder-active-head-row",children:n.jsxs("div",{className:"preorder-active-total-pill",children:[n.jsx("span",{className:"preorder-active-total-label",children:"Total réservé"}),n.jsx("span",{className:"preorder-active-total-value",children:Je==="—"?"—":`${Je} €`})]})}),n.jsx("p",{className:"preorder-active-line preorder-active-line--bid",children:n.jsxs("span",{className:"preorder-active-bid-row",children:[n.jsxs("span",{className:"preorder-active-bid-text",children:["Votre enchère :"," ",Ge==="—"?"—":n.jsxs(n.Fragment,{children:[n.jsxs("strong",{children:[Ge," €"]})," / carte",qe!=null?` × ${qe}`:""]})]}),n.jsxs("span",{className:"preorder-active-pos-inline",children:[n.jsxs("span",{className:"preorder-active-pos-label",children:["Position :"," ",n.jsx("strong",{children:Xe??"—"}),It!=null?` / ${It}`:""]}),n.jsx("button",{type:"button",className:"preorder-active-info-btn","aria-expanded":I===T.id,"aria-haspopup":"dialog","aria-label":"Explication priorité de la file",title:"Comment fonctionne la priorité ?",onClick:()=>D(k=>k===T.id?null:T.id),children:n.jsx("span",{className:"preorder-active-info-btn-char","aria-hidden":"true",children:"i"})})]})]})}),ft!=null?n.jsxs("p",{className:"preorder-active-line preorder-active-line--market",children:["Plus haute enchère (par carte) sur"," ",Ke?"cette ville":"ce BIN"," : ",n.jsxs("strong",{children:[ft," €"]})," ",n.jsx("span",{className:"preorder-active-line-hint",children:"(tous utilisateurs)"})]}):null,n.jsxs("p",{className:"preorder-active-bin-line",children:[Ke?"Ville : ":"BIN : ",n.jsx("strong",{children:kt})]}),n.jsx("p",{className:"preorder-active-meta-line",children:(()=>{const k=[T.filterVille?`Ville: ${T.filterVille}`:null].filter(Boolean),z=qe!=null?`×${qe}`:null,S=[jl(T.telephone),z,"En cours"].filter(Boolean).join(" · ");return k.length?`${k.join(" · ")} · ${S}`:S})()}),R===T.id?n.jsxs("div",{className:"preorder-active-edit-bid",children:[n.jsxs("label",{className:"preorder-active-edit-label",children:["Nouveau prix par carte (min. ",ir," €)",n.jsx("input",{type:"number",min:ir,step:.5,className:"preorder-active-edit-input",value:pe,onChange:k=>ie(k.target.value)})]}),n.jsxs("div",{className:"preorder-active-edit-actions",children:[n.jsx("button",{type:"button",className:"preorder-active-edit-save",disabled:se,onClick:()=>Ie(T.id),children:se?"…":"Enregistrer"}),n.jsx("button",{type:"button",className:"preorder-active-edit-cancel",disabled:se,onClick:()=>U(null),children:"Annuler"})]})]}):n.jsx("button",{type:"button",className:"preorder-active-link-edit",onClick:()=>{U(T.id),ie(String(T.bidPerUnitEur??""))},children:"Modifier le prix (par carte)"})]})]}),n.jsx("button",{type:"button",className:"preorder-active-btn-cancel-full",disabled:L===T.id,onClick:()=>ut(T.id),children:L===T.id?"Annulation…":"Annuler la précommande"})]})},T.id):n.jsx("div",{className:"preorder-mes-card",children:le?n.jsxs("button",{type:"button",className:"preorder-mes-card-hit",onClick:()=>i(K[0]),children:[n.jsxs("div",{className:"preorder-mes-head",children:[n.jsx("span",{className:"preorder-mes-bin",children:T.binFilter?String(T.binFilter).replace(/^#/,""):"—"}),n.jsx("span",{className:"preorder-mes-total",children:Oe})]}),n.jsxs("div",{className:"preorder-mes-meta",children:[jl(T.telephone)," ·"," ",`${vl(T.status)} · voir commande`]}),n.jsx("span",{className:"preorder-mes-open-hint",children:"Ouvrir le détail (comme Commandes) ›"})]}):n.jsxs("div",{className:"preorder-mes-card-body",children:[n.jsxs("div",{className:"preorder-mes-head",children:[n.jsx("span",{className:"preorder-mes-bin",children:T.binFilter?String(T.binFilter).replace(/^#/,""):"—"}),n.jsx("span",{className:"preorder-mes-total",children:Oe})]}),n.jsxs("div",{className:"preorder-mes-meta",children:[jl(T.telephone)," · ",vl(T.status),K.length?null:n.jsx("span",{children:" · voir aussi dans Commandes"})]})]})},T.id)})}),n.jsxs("div",{className:"preorder-mes-tabbar",role:"tablist","aria-label":"Filtrer vos précommandes",children:[n.jsxs("button",{type:"button",role:"tab",id:"preorder-tab-current","aria-selected":ge==="current","aria-controls":"preorder-mes-panel",className:`preorder-mes-tab ${ge==="current"?"preorder-mes-tab--active":""}`,onClick:()=>$("current"),children:["En cours",F.length>0?n.jsx("span",{className:"preorder-mes-tab-count",children:F.length}):null]}),n.jsxs("button",{type:"button",role:"tab",id:"preorder-tab-cancelled","aria-selected":ge==="cancelled","aria-controls":"preorder-mes-panel",className:`preorder-mes-tab ${ge==="cancelled"?"preorder-mes-tab--active":""}`,onClick:()=>$("cancelled"),children:["Annulées",W.length>0?n.jsx("span",{className:"preorder-mes-tab-count",children:W.length}):null]})]})]}):n.jsxs("div",{className:"preorder-empty-mes",children:[n.jsx(Wg,{}),n.jsx("p",{className:"preorder-empty-mes-title",children:"Aucune précommande"}),n.jsx("p",{className:"preorder-empty-mes-sub",children:"Vous n'avez pas encore créé de précommande."})]}):n.jsx("div",{className:"preorder-empty",children:"Connectez-vous via Telegram pour voir vos enchères."})}),p?n.jsxs("div",{className:"preorder-modal-root",role:"dialog","aria-modal":"true","aria-labelledby":"preorder-modal-title",children:[n.jsx("button",{type:"button",className:"preorder-modal-backdrop",onClick:()=>x(!1),"aria-label":"Fermer"}),n.jsxs("div",{className:"preorder-modal",children:[n.jsxs("div",{className:"preorder-modal-head",children:[n.jsx("h2",{id:"preorder-modal-title",children:"Précommande"}),n.jsx("button",{type:"button",className:"preorder-modal-close",onClick:()=>x(!1),"aria-label":"Fermer",children:"×"})]}),n.jsxs("label",{className:"preorder-field",children:[n.jsx("span",{className:"preorder-field-label",children:"BIN (ex. 497011, 497099, 513001)"}),n.jsx("input",{className:"preorder-field-input",placeholder:"BIN",inputMode:"numeric",autoComplete:"off",value:b,onChange:T=>m(T.target.value)})]}),n.jsxs("label",{className:"preorder-field",children:[n.jsx("span",{className:"preorder-field-label",children:"Système (carte)"}),n.jsxs("select",{className:"preorder-field-input",value:w,onChange:T=>j(T.target.value),children:[n.jsx("option",{value:"any",children:"Tous"}),n.jsx("option",{value:"iphone_ios",children:"iPhone / iOS"}),n.jsx("option",{value:"android",children:"Android"})]})]}),n.jsxs("div",{className:"preorder-modal-row2",children:[n.jsxs("label",{className:"preorder-field",children:[n.jsx("span",{className:"preorder-field-label",children:"Votre prix (par cc)"}),n.jsx("input",{className:"preorder-field-input",type:"text",inputMode:"decimal",placeholder:`min ${ir}€`,value:C,onChange:T=>q($g(T.target.value))})]}),n.jsxs("label",{className:"preorder-field",children:[n.jsx("span",{className:"preorder-field-label",children:"Montant (à réserver)"}),n.jsx("input",{className:"preorder-field-input",type:"text",inputMode:"numeric",placeholder:"min 1",value:g,onChange:T=>u(Bg(T.target.value))})]})]}),n.jsx("p",{className:"preorder-modal-hint",children:"Cible : préfixe BIN. Priorité : prix par carte, puis ancienneté."}),n.jsxs("div",{className:"preorder-modal-summary",children:[n.jsx("span",{children:"À réserver"}),n.jsx("strong",{children:E>0?`€${E.toFixed(2)}`:"—"})]}),n.jsx("p",{className:"preorder-modal-footnote",children:"Le montant sera débité immédiatement et remboursé si annulation."}),n.jsxs("div",{className:"preorder-modal-actions",children:[n.jsx("button",{type:"button",className:"preorder-modal-btn-secondary",onClick:()=>x(!1),children:"Annuler"}),n.jsx("button",{type:"button",className:"preorder-modal-btn-primary",disabled:f||E<=0||!oe,onClick:ke,children:f?"…":"Faire une précommande"})]})]})]}):null]}),X&&I!=null&&typeof document<"u"?np.createPortal(n.jsx("div",{className:"preorder-hint-portal-backdrop",role:"presentation",onClick:()=>D(null),children:n.jsxs("div",{className:"preorder-hint-portal-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"preorder-hint-portal-title",onClick:T=>T.stopPropagation(),children:[n.jsx("div",{className:"preorder-hint-portal-head",children:n.jsx("p",{className:"preorder-hint-portal-title",id:"preorder-hint-portal-title",children:"Priorité dans la file"})}),n.jsx("p",{className:"preorder-hint-portal-text",children:Og(X.queuePosition,X.queueSize,X.preorderMode==="criteria")}),n.jsx("button",{type:"button",className:"preorder-hint-portal-close",onClick:()=>D(null),children:"Fermer"})]})}),document.body):null]})}function Qg({reason:e="session",onRetry:t}){const r=e==="TOKEN_EXPIRED"||e==="expired",a=e==="no_telegram",i=e==="backup_gate",s="yodaccs_backup_bot".trim().replace(/^@/,""),o=()=>{var d,p,x;if(!s)return;const l=`https://t.me/${s}`;try{(x=(p=(d=window.Telegram)==null?void 0:d.WebApp)==null?void 0:p.openTelegramLink)==null||x.call(p,l)}catch{window.open(l,"_blank","noopener,noreferrer")}};return n.jsx("div",{className:"telegram-auth-gate",children:n.jsxs("div",{className:"telegram-auth-gate-card",children:[n.jsx("div",{className:"telegram-auth-gate-icon-wrap","aria-hidden":"true",children:n.jsx("span",{className:"telegram-auth-gate-icon",children:"⛔"})}),n.jsx("h1",{className:"telegram-auth-gate-title",children:"Authentification requise"}),i?n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"telegram-auth-gate-text",children:["Ouvre d’abord le ",n.jsx("strong",{children:"bot backup"}),", envoie ",n.jsx("strong",{children:"/start"}),", puis reviens ouvrir la boutique depuis le bot principal."]}),s?n.jsxs(n.Fragment,{children:[n.jsxs("p",{className:"telegram-auth-gate-instruction",children:["Bot backup : ",n.jsxs("strong",{children:["@",s]})]}),n.jsxs("button",{type:"button",className:"telegram-auth-gate-retry",onClick:o,children:["Ouvrir @",s]})]}):n.jsxs("p",{className:"telegram-auth-gate-instruction",children:["Définis ",n.jsx("strong",{children:"VITE_BACKUP_BOT_USERNAME"})," (sans @) pour un lien direct depuis l’écran boutique."]})]}):a?n.jsx("p",{className:"telegram-auth-gate-text",children:"Ouvrez cette boutique depuis Telegram (bouton WebApp du bot), pas depuis le navigateur seul."}):n.jsxs(n.Fragment,{children:[n.jsx("p",{className:"telegram-auth-gate-text",children:r?"Votre session a expiré.":"Impossible de valider votre session Telegram."}),n.jsxs("p",{className:"telegram-auth-gate-instruction",children:["Lancez la commande ",n.jsx("strong",{children:"/start"})," sur le bot, puis rouvrez la boutique depuis le menu."]})]}),t?n.jsx("button",{type:"button",className:"telegram-auth-gate-retry",onClick:t,children:"Réessayer"}):null]})})}const xa="yodacc_cart_v2",vp="dzcc_cart_v2";function Yg(){try{let e=localStorage.getItem(xa);if(e||(e=localStorage.getItem(vp),e&&(localStorage.setItem(xa,e),localStorage.removeItem(vp))),!e)return null;const t=JSON.parse(e);return!t||!Array.isArray(t.items)?null:t}catch{return null}}function jn(e,t){try{const r=t==null?void 0:t.filter(a=>a.productId!=null).map(a=>({productId:Number(a.productId),quantity:Number(a.quantity)||1}));if(!(r!=null&&r.length)){localStorage.removeItem(xa);return}localStorage.setItem(xa,JSON.stringify({telegramId:e!=null?Number(e):null,items:r,at:Date.now()}))}catch{}}function Kg(){try{localStorage.removeItem(xa)}catch{}}function yp(){var t,r;if(typeof window>"u")return"";const e=(r=(t=window.Telegram)==null?void 0:t.WebApp)==null?void 0:r.initData;return typeof e=="string"?e.trim():""}function Gg(e){return new Promise(t=>window.setTimeout(t,e))}function qi(e,t,r){let a=null;const i=new Promise((s,o)=>{a=window.setTimeout(()=>{o(new Error(`${r||"operation"} timeout`))},t)});return Promise.race([e,i]).finally(()=>{a&&window.clearTimeout(a)})}async function wp(e=4500){var i,s,o;if(typeof window>"u")return"";const t=[0,40,120,260,500,900,1500,2300,3200,4500],r=Date.now();for(let l=0;l=e)break;await Gg(Math.max(0,Math.min(x-t[l],e-b)))}const a=yp();return console.log("[ycc-shop] initData fin attente",{len:String(a||"").length,hasHash:/(?:^|&)hash=/.test(String(a||"")),ms:Date.now()-r}),a}function Jg(e){const t=String(e.clientUa??e.client_ua??"").trim();return t!==""?t.toLowerCase():String(e.telephone??e.phone??"").trim().toLowerCase()}function Xg(e){const t=String(e??"").replace(/\D/g,"");return t.length<2?null:t.startsWith("97")||t.startsWith("98")?t.slice(0,Math.min(3,t.length)):t.slice(0,2)}function Zg(e){const t=String(e??"").trim();if(!t)return null;const r=t.split(/[\s,;]+/).map(i=>i.trim()).filter(Boolean),a=new Set;for(const i of r){const s=i.replace(/\D/g,"");s&&(s.length>=3&&(s.startsWith("97")||s.startsWith("98"))?a.add(s.slice(0,3)):s.length>=2&&a.add(s.slice(0,2)))}return a.size?a:null}function ex(){const[e,t]=c.useState(typeof window<"u"&&window.location.pathname==="/vendeurPanel"?"seller":typeof window<"u"&&window.location.pathname==="/adminPanel"?"admin":"shop"),[r,a]=c.useState("tous"),[i,s]=c.useState(""),[o,l]=c.useState("accueil"),[d,p]=c.useState(!1),[x,b]=c.useState(5),[m,w]=c.useState(null),[j,C]=c.useState(!1),[q,g]=c.useState(!1),[u,f]=c.useState([]),[y,L]=c.useState([]),[P,I]=c.useState([]),[D,R]=c.useState(!1),[U,pe]=c.useState(0),[ie,se]=c.useState(!1),[_e,ge]=c.useState(0),[$,X]=c.useState("active"),[E,F]=c.useState([]),[W,J]=c.useState(!1),[Y,ve]=c.useState(null),oe=gl(),Q=oe==null?void 0:oe.id,he=c.useRef(0),ye=c.useRef(null),[ke,ut]=c.useState(null),[Ie,T]=c.useState("loading"),[K,le]=c.useState("session"),[Z,ce]=c.useState({type:"Tous",banque:"Tous",level:"Tous",systeme:"Tous",departementCodes:"",minPrice:"",maxPrice:"",minAge:"",maxAge:""});c.useEffect(()=>{const k=()=>{window.scrollTo({top:0,left:0,behavior:"auto"}),document.documentElement.scrollTop=0,document.body.scrollTop=0};k();const z=requestAnimationFrame(k),S=setTimeout(k,0),O=setTimeout(k,120),V=H=>{H.persisted&&k()};return window.addEventListener("pageshow",V),()=>{cancelAnimationFrame(z),clearTimeout(S),clearTimeout(O),window.removeEventListener("pageshow",V)}},[]),c.useEffect(()=>{console.log("[ycc-shop] phase auth",{shopAuthPhase:Ie,authBlockReason:K})},[Ie,K]);const Ve=c.useCallback(async()=>{console.log("[ycc-shop] runTelegramAuth début",{href:typeof window<"u"?String(window.location.href||"").slice(0,200):""}),T("loading"),le("session");const k=await wp();if(!String(k||"").trim()){console.warn("[ycc-shop] pas d’initData après attente → écran bloqué no_telegram"),T("blocked"),le("no_telegram");return}const z=S=>(S==null?void 0:S.code)==="BACKUP_GATE_REQUIRED"?"backup_gate":"invalid";try{console.log("[ycc-shop] login API…"),await qi(op(k),15e3,"auth login"),console.log("[ycc-shop] login OK → shopAuthPhase ready"),T("ready"),qi(lp(),12e3,"profile upsert").catch(S=>{console.warn("[ycc-shop] profil upsert échoué (non bloquant)",(S==null?void 0:S.message)||S)})}catch(S){console.warn("[ycc-shop] login erreur",{message:S==null?void 0:S.message,code:S==null?void 0:S.code,name:S==null?void 0:S.name});const O=await wp(2200);if(O&&O!==k)try{console.log("[ycc-shop] nouvel initData, 2e tentative login…"),await qi(op(O),15e3,"auth login retry"),console.log("[ycc-shop] login retry OK → ready"),T("ready"),qi(lp(),12e3,"profile upsert").catch(V=>{console.warn("[ycc-shop] profil upsert échoué après retry",(V==null?void 0:V.message)||V)});return}catch(V){console.warn("[ycc-shop] login retry erreur",{message:V==null?void 0:V.message,code:V==null?void 0:V.code}),T("blocked"),le(z(V));return}T("blocked"),le(z(S))}},[]);c.useEffect(()=>{console.log("[ycc-shop] App montée"),Ve()},[Ve]),c.useEffect(()=>{const k=z=>{var S;le(((S=z.detail)==null?void 0:S.code)==="TOKEN_EXPIRED"?"TOKEN_EXPIRED":"session"),T("blocked")};return window.addEventListener("autoshop:auth-required",k),()=>window.removeEventListener("autoshop:auth-required",k)},[]),c.useEffect(()=>{async function k(){try{const z=await fl();Array.isArray(z)&&f(z)}catch{}}k()},[]),c.useEffect(()=>{if(Ie!=="ready"||!Q)return;const k=he.current;(async()=>{var z;try{const S=await Jh(Q);if(k!==he.current)return;let O=Array.isArray(S.items)?S.items:[];if(O.length===0){const V=Yg();if((z=V==null?void 0:V.items)!=null&&z.length&&(V.telegramId==null||Number(V.telegramId)===Number(Q))){he.current+=1;const ue=he.current;try{const ee=await hl(Q,V.items);if(ue!==he.current)return;O=Array.isArray(ee.items)?ee.items:[],jn(Q,O.map(Ze=>({productId:Ze.productId,quantity:Number(Ze.quantity)||1})))}catch(ee){console.error("[panier] localStorage → BDD",ee)}}}else jn(Q,O.map(V=>({productId:V.productId,quantity:Number(V.quantity)||1})));I(V=>{if(O.length>0)return O;if(V.length===0)return[];const H=V.filter(ee=>ee.productId!=null).map(ee=>({productId:ee.productId,quantity:Number(ee.quantity)||1}));he.current+=1;const ue=he.current;return hl(Q,H).then(ee=>{if(ue!==he.current)return;const Ze=Array.isArray(ee.items)?ee.items:V;I(Ze),jn(Q,Ze.map(St=>({productId:St.productId,quantity:Number(St.quantity)||1})))}).catch(ee=>console.error("Sync panier → serveur:",ee)),V})}catch{k===he.current&&I([])}})()},[Q,Ie]),c.useEffect(()=>()=>{ye.current&&clearTimeout(ye.current)},[]);const Oe=async k=>{const z=k.filter(S=>S.productId!=null).map(S=>({productId:S.productId,quantity:Number(S.quantity)||1}));if(!Q){console.warn("[panier] Pas de telegramId — sauvegarde locale seulement ; sera envoyé en BDD dès connexion Telegram.",{nextCount:k.length,payload:z}),I(k),jn(null,z);return}he.current+=1,console.log("[panier] PUT /cart → serveur",{telegramId:Q,payload:z,rawItems:k.length});try{const S=await hl(Q,z),O=Array.isArray(S.items)?S.items.length:0;console.log("[panier] Réponse API OK",{itemsReturned:O,data:S}),I(Array.isArray(S.items)?S.items:[]),jn(Q,z)}catch(S){console.error("[panier] Échec putCart (rien écrit en cart_items si erreur réseau/API)",{message:S==null?void 0:S.message,telegramId:Q,payload:z}),I(k),jn(Q,z)}};c.useEffect(()=>{let k=u;if(i){const H=i.toLowerCase().trim(),ue=H.replace(/\s/g,"");k=k.filter(ee=>{const Ze=ga(ee).toLowerCase(),St=String(ee.numero??"").toLowerCase().replace(/\s/g,""),sr=String(ee.holderName||ee.nom||"").toLowerCase().trim();return Ze.includes(ue)||St.includes(ue)||sr.includes(H)||String(ee.type||"").toLowerCase().includes(H)||String(ee.banque||"").toLowerCase().includes(H)||String(ee.ville||"").toLowerCase().includes(H)})}r==="nouveautes"?k=k.filter(H=>H.isNew):r==="derniere-chance"&&(k=k.filter(H=>H.derniereChance)),Z.type!=="Tous"&&(k=k.filter(H=>String(H.type||"").toUpperCase()===Z.type)),Z.banque!=="Tous"&&(k=k.filter(H=>String(H.banque||"")===Z.banque)),Z.level!=="Tous"&&(k=k.filter(H=>String(H.level||"").toUpperCase()===Z.level));{const H=Zg(Z.departementCodes);H&&(k=k.filter(ue=>{const ee=Xg(ue.zip);return ee!=null&&H.has(ee)}))}Z.systeme!=="Tous"&&(k=k.filter(H=>{const ue=Jg(H);return ue===""?!1:Z.systeme==="ANDROID"?ue==="android"||ue.includes("android"):Z.systeme==="IOS"?ue==="iphone"||ue==="iphone_ios"||ue.includes("iphone")||ue.includes("ios"):!0}));const z=Number(Z.minPrice),S=Number(Z.maxPrice);Z.minPrice!==""&&!Number.isNaN(z)&&(k=k.filter(H=>Number(H.prix||0)>=z)),Z.maxPrice!==""&&!Number.isNaN(S)&&(k=k.filter(H=>Number(H.prix||0)<=S));const O=Number(Z.minAge),V=Number(Z.maxAge);Z.minAge!==""&&!Number.isNaN(O)&&(k=k.filter(H=>Number(H.joursRestants??H.jours_restants??0)>=O)),Z.maxAge!==""&&!Number.isNaN(V)&&(k=k.filter(H=>Number(H.joursRestants??H.jours_restants??0)<=V)),L(k)},[r,i,u,Z]);const Ke=async k=>{const z=k.id??null;if(z==null)return;const S=P.some(V=>V.productId===z);let O;S?O=P.filter(V=>V.productId!==z):O=[{id:Date.now(),productId:z,numero:k.numero,bin:ga(k),type:k.type,level:k.level,banque:k.banque,ville:k.ville,zip:k.zip??null,prix:k.prix??0,quantity:1,image:k.image??null,sellerTelegramId:k.sellerTelegramId??null,sellerUsername:k.sellerUsername??null},...P],await Oe(O)},kt=k=>{const z=P.filter(S=>S.id!==k);Oe(z)},Nt=()=>{Oe([])},Ge=()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),ut(null)},ze=(k,z="success",S={})=>{const{persist:O=!1,successMeta:V=null}=S;ye.current&&clearTimeout(ye.current),ut({text:k,kind:z,persist:O,successMeta:V}),O||(ye.current=window.setTimeout(()=>{ut(null),ye.current=null},5200))};c.useEffect(()=>{if(Ie!=="ready"||o!=="accueil"||r!=="nouveautes")return;let k=!1;return C(!0),ml().then(z=>{k||w(z)}).catch(()=>{k||w(null)}).finally(()=>{k||C(!1)}),()=>{k=!0}},[o,r,Ie]),c.useEffect(()=>{if((m==null?void 0:m.maxQuantity)==null)return;const k=Number(m.maxQuantity);b(z=>{if(k<5)return 5;const S=Math.min(k,z),O=Math.floor(S/5)*5;return O>=5?O:5})},[m==null?void 0:m.maxQuantity]);const Je=async()=>{if(!Q){ze("Connectez-vous via Telegram pour payer.","error");return}const k=[...new Set(P.map(z=>z.productId).filter(z=>z!=null))];if(!k.length){ze("Panier invalide (produits sans identifiant).","error");return}R(!0);try{const z=await Gh(Q,k),S=k.length;I([]),Kg(),pe(V=>V+1),ge(V=>V+1);const O=await fl();Array.isArray(O)&&f(O),ze("Paiement effectué","success",{persist:!0,successMeta:{total:Number((z==null?void 0:z.total)??0),commandeId:(z==null?void 0:z.commandeId)??null,itemCount:S,newBalance:(z==null?void 0:z.newBalance)!=null?Number(z.newBalance):null}})}catch(z){let S=(z==null?void 0:z.message)||"Paiement impossible";try{const O=JSON.parse(S);O!=null&&O.message&&(S=O.message)}catch{}String(S).toLowerCase().includes("solde")?ze("Solde insuffisant. Rechargez votre compte.","error"):ze(S,"error")}finally{R(!1)}},pt=async()=>{if(!Q){ze("Connectez-vous via Telegram pour payer.","error");return}if(!(m!=null&&m.active)||m.priceEur==null){ze("Box indisponible : prix non configuré dans l’admin.","error");return}g(!0);try{const k=await Kh(Q,x);pe(O=>O+1),ge(O=>O+1);const[z,S]=await Promise.all([fl(),ml()]);Array.isArray(z)&&f(z),S&&typeof S=="object"&&w(S),ze(`Box : ${k.quantity} carte(s) — commande #${k.commandeId} — ${Number(k.totalEur).toFixed(2)} €`,"success")}catch(k){let z=(k==null?void 0:k.message)||"Paiement box impossible";try{const S=JSON.parse(z);S!=null&&S.message&&(z=S.message)}catch{}String(z).toLowerCase().includes("solde")?ze("Solde insuffisant. Rechargez votre compte.","error"):ze(z,"error")}finally{g(!1)}},at=()=>{const k=m!=null&&m.priceEur!=null&&Number.isFinite(Number(m.priceEur))?Number(m.priceEur):null,z=k!=null?Math.round(k*x*100)/100:null,S=Number((m==null?void 0:m.maxQuantity)??0),O=Number((m==null?void 0:m.availableForSale)??0),V=S>=5,H=j||!(m!=null&&m.active)||k==null||k<0||!V;return n.jsxs("section",{className:"box-panel",children:[n.jsxs("div",{className:"box-info",children:[n.jsx("h3",{children:"Information"}),n.jsxs("p",{children:["Chaque box tire au hasard des cartes ",n.jsx("strong",{children:"en vente"})," dans le catalogue (même prix unitaire par carte, défini par l’admin). Quantités possibles : ",n.jsx("strong",{children:"5, 10, 15…"})," par pas de 5, sans dépasser le stock disponible."]}),!j&&m!=null?n.jsx("p",{className:"box-panel-hint",children:V?`${O} carte(s) en vente — tu peux prendre jusqu’à ${S} carte(s) en box.`:`Pas assez de cartes en vente pour une box (il en faut au moins 5). Actuellement : ${O}.`}):null,j?n.jsx("p",{className:"box-panel-hint",children:"Chargement du tarif…"}):null,!j&&!(m!=null&&m.active)?n.jsx("p",{className:"box-panel-hint box-panel-hint--warn",children:"Box désactivée pour le moment."}):null]}),n.jsxs("div",{className:"box-qty-card",children:[n.jsxs("div",{className:"box-qty-card-head",children:[n.jsx("h3",{className:"box-title box-title--inline",children:"Quantité"}),n.jsx("span",{className:"box-qty-step-badge",children:"par 5"})]}),n.jsxs("div",{className:"box-qty-row",children:[n.jsx("button",{type:"button",className:"box-qty-btn",disabled:!V||x<=5,"aria-label":"Retirer 5 cartes",onClick:()=>b(ue=>Math.max(5,ue-5)),children:n.jsx("span",{className:"box-qty-btn-symbol","aria-hidden":!0,children:"−"})}),n.jsxs("div",{className:"box-qty-value",children:[n.jsx("strong",{children:x}),n.jsx("span",{children:"cartes"})]}),n.jsx("button",{type:"button",className:"box-qty-btn",disabled:!V||x>=S,"aria-label":"Ajouter 5 cartes",onClick:()=>b(ue=>Math.min(S,ue+5)),children:n.jsx("span",{className:"box-qty-btn-symbol","aria-hidden":!0,children:"+"})})]}),n.jsx("input",{type:"range",min:5,max:Math.max(5,S),step:5,value:V?x:5,className:"box-slider",disabled:!V,onChange:ue=>b(Number(ue.target.value)),"aria-label":"Ajuster la quantité"})]}),n.jsxs("div",{className:"box-total-card",children:[n.jsxs("div",{children:[n.jsx("span",{children:"Prix unitaire :"}),n.jsx("strong",{children:k!=null?`${k.toFixed(2)} €`:"—"})]}),n.jsxs("div",{children:[n.jsx("span",{children:"Quantité :"}),n.jsx("strong",{children:x})]}),n.jsxs("div",{className:"box-total-line",children:[n.jsx("span",{children:"Total :"}),n.jsx("strong",{children:z!=null?`${z.toFixed(2)} €`:"—"})]})]}),n.jsx("button",{type:"button",className:"box-pay-btn",onClick:pt,disabled:q||H,children:q?"Paiement…":"PAYER"})]})},ft=()=>{if(!P.length)return n.jsxs("section",{className:"menu-panel cart-panel cart-panel--empty empty-panel",children:[n.jsx("h2",{className:"cart-panel-heading",children:"Mon Panier"}),n.jsx("p",{className:"cart-panel-lead",children:"Vérifiez votre sélection"}),n.jsxs("div",{className:"cart-empty-body",children:[n.jsx("div",{className:"cart-empty-icon-wrap","aria-hidden":!0,children:n.jsxs("svg",{className:"cart-empty-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M8 7V5.5a4 4 0 0 1 8 0V7"}),n.jsx("path",{d:"M5 8.5h14l-1.35 10.2a2 2 0 0 1-2 1.8H8.35a2 2 0 0 1-2-1.8L5 8.5Z"}),n.jsx("path",{d:"M10 12v3M14 12v3"})]})}),n.jsx("div",{className:"empty-state cart-empty-hint",children:"Panier vide"})]})]});const k=P.reduce((S,O)=>S+Number(O.prix||0)*Number(O.quantity||1),0),z=P.reduce((S,O)=>S+Number(O.quantity||1),0);return n.jsxs("section",{className:"menu-panel cart-panel",children:[n.jsx("h2",{className:"cart-panel-heading",children:"Mon Panier"}),n.jsx("p",{className:"cart-panel-lead",children:"Vérifiez votre sélection"}),n.jsx("div",{className:"cart-list",children:P.map(S=>{const O=S.bin||ga(S),V=xl(S.banque),H=S.zip,ue=H!=null&&String(H).trim()!==""?String(H).trim():null,ee=S.sellerUsername!=null&&String(S.sellerUsername).trim()!==""?String(S.sellerUsername).trim().replace(/^@/,""):"",Ze=S.sellerTelegramId!=null&&Number.isFinite(Number(S.sellerTelegramId))?ee?`Revendeur @${ee}`:"Revendeur":null,St=[V!=="—"?V:null,ue?`CP: ${ue}`:null,Ze].filter(Boolean).join(" | "),sr=String(O||"").replace(/\D/g,"").slice(0,6),or=S.image||(sr.length===6?`https://cardimages.imaginecurve.com/cards/${sr}.png`:"");return n.jsxs("div",{className:"cart-item-card",children:[n.jsx("div",{className:"cart-item-thumb-wrap",children:or?n.jsx("img",{className:"cart-item-thumb",src:or,alt:"",loading:"lazy"}):n.jsx("div",{className:"cart-item-thumb cart-item-thumb--placeholder","aria-hidden":!0})}),n.jsxs("div",{className:"cart-item-info",children:[n.jsx("div",{className:"cart-item-title",children:O||"—"}),n.jsx("p",{className:"cart-item-meta",children:St||"—"})]}),n.jsxs("div",{className:"cart-item-side",children:[n.jsxs("span",{className:"cart-item-price",children:["€",Number(S.prix||0).toFixed(2)]}),n.jsx("button",{type:"button",className:"cart-item-remove",onClick:()=>kt(S.id),"aria-label":"Retirer du panier",children:n.jsx("span",{"aria-hidden":!0,children:"×"})})]})]},S.id)})}),n.jsxs("div",{className:"cart-summary-card",children:[n.jsxs("div",{className:"cart-summary-row",children:[n.jsx("span",{className:"cart-summary-label",children:"Articles"}),n.jsx("span",{className:"cart-summary-accent",children:z})]}),n.jsx("div",{className:"cart-summary-rule"}),n.jsxs("div",{className:"cart-summary-row cart-summary-row-total",children:[n.jsx("span",{className:"cart-summary-total-label",children:"Total"}),n.jsxs("span",{className:"cart-summary-total-value",children:["€",k.toFixed(2)]})]})]}),n.jsxs("div",{className:"cart-actions",children:[n.jsxs("button",{type:"button",className:"cart-pay-btn",onClick:Je,disabled:D,children:[n.jsx("svg",{className:"cart-pay-icon",viewBox:"0 0 24 24",width:"22",height:"22","aria-hidden":!0,children:n.jsx("path",{fill:"currentColor",d:"M20 4H4c-1.11 0-1.99.89-1.99 2L2 18c0 1.11.89 2 2 2h16c1.11 0 2-.89 2-2V6c0-1.11-.89-2-2-2zm0 14H4v-6h16v6zm0-10H4V6h16v2z"})}),n.jsx("span",{children:D?"Paiement…":"PAYER"})]}),n.jsx("button",{type:"button",className:"cart-clear-btn",onClick:Nt,children:"Vider le panier"})]})]})};c.useEffect(()=>{if(Ie!=="ready"||o!=="commandes"||!Q)return;let k=!1;return J(!0),Ri(Q,{archived:$==="archived"}).then(z=>{k||F(Array.isArray(z==null?void 0:z.orders)?z.orders:[])}).catch(()=>{k||F([])}).finally(()=>{k||J(!1)}),()=>{k=!0}},[o,Q,_e,Ie,$]),c.useEffect(()=>{o!=="commandes"&&ve(null)},[o]),c.useEffect(()=>{ve(null)},[$]);const qe=n.jsxs("div",{className:"orders-archive-tabs",role:"tablist","aria-label":"Filtre commandes",children:[n.jsx("button",{type:"button",role:"tab","aria-selected":$==="active",className:`orders-archive-tab ${$==="active"?"orders-archive-tab--active":""}`,onClick:()=>X("active"),children:"Actives"}),n.jsx("button",{type:"button",role:"tab","aria-selected":$==="archived",className:`orders-archive-tab ${$==="archived"?"orders-archive-tab--active":""}`,onClick:()=>X("archived"),children:"Archives"})]}),Xe=()=>{if(!Q)return n.jsxs("section",{className:"menu-panel empty-panel orders-panel orders-panel--empty",children:[n.jsx("h2",{className:"menu-panel-title",children:"Mes Commandes"}),n.jsx("p",{className:"menu-panel-text",children:"Ouvrez la boutique depuis Telegram pour voir l'historique."}),n.jsxs("div",{className:"orders-empty-body orders-empty-body--compact",children:[n.jsx("div",{className:"orders-empty-icon-wrap orders-empty-icon-wrap--telegram","aria-hidden":!0,children:n.jsx("svg",{className:"orders-empty-icon orders-empty-icon--sm",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round",children:n.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),n.jsx("div",{className:"empty-state orders-empty-hint",children:"Connexion requise"})]})]});if(W)return n.jsxs("section",{className:"menu-panel empty-panel orders-panel orders-panel--loading",children:[n.jsx("h2",{className:"menu-panel-title",children:"Mes Commandes"}),n.jsx("p",{className:"menu-panel-text",children:"Historique des achats"}),n.jsxs("div",{className:"orders-loading-body",role:"status","aria-live":"polite",children:[n.jsx("div",{className:"orders-loading-ring","aria-hidden":!0}),n.jsx("span",{className:"orders-loading-label",children:"Chargement"}),n.jsxs("span",{className:"orders-loading-dots","aria-hidden":!0,children:[n.jsx("span",{}),n.jsx("span",{}),n.jsx("span",{})]})]})]});if(!E.length)return n.jsxs("section",{className:"menu-panel empty-panel orders-panel orders-panel--empty",children:[n.jsx("h2",{className:"menu-panel-title",children:"Mes Commandes"}),n.jsx("p",{className:"menu-panel-text",children:"Historique des achats"}),qe,n.jsxs("div",{className:"orders-empty-body",children:[n.jsx("div",{className:"orders-empty-icon-wrap","aria-hidden":!0,children:n.jsxs("svg",{className:"orders-empty-icon",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.65",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2"}),n.jsx("path",{d:"M9 5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v0a2 2 0 0 1-2 2h-2a2 2 0 0 1-2-2v0Z"}),n.jsx("path",{d:"M9 12h6M9 16h4.5M9 8h6"})]})}),n.jsx("div",{className:"empty-state orders-empty-hint",children:$==="archived"?"Aucune commande archivée":"Aucun achat"})]})]});const k=Y!=null?E.find(z=>z.id===Y):null;return k?n.jsx(Fg,{order:k,onBack:()=>ve(null),telegramId:Q,onContactTagSaved:()=>ge(z=>z+1),onArchiveStateChanged:()=>{ge(z=>z+1),ve(null)}}):n.jsxs("section",{className:"menu-panel orders-panel",children:[n.jsx("h2",{className:"menu-panel-title",children:"Mes Commandes"}),n.jsx("p",{className:"menu-panel-text",children:"Historique des achats — touchez une commande pour le détail"}),qe,n.jsx("div",{className:"orders-list",children:E.map(z=>{const S=(z.items||[]).length;return n.jsxs("button",{type:"button",className:"order-card order-card-clickable",onClick:()=>ve(z.id),children:[n.jsxs("div",{className:"order-card-head",children:[n.jsx("span",{className:"order-date",children:z.createdAt?new Date(z.createdAt).toLocaleString("fr-FR",{day:"2-digit",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}),n.jsxs("span",{className:"order-total",children:[Number(z.totalEur??0).toFixed(2)," €"]})]}),z.fromPreorder?n.jsx("div",{className:"order-card-preorder-row",children:n.jsx("span",{className:"order-card-preorder-pill",children:"Précommande"})}):null,n.jsxs("div",{className:"order-card-foot",children:[n.jsxs("span",{className:"order-article-count",children:[S," article",S>1?"s":""]}),n.jsx("span",{className:"order-card-chevron","aria-hidden":!0,children:"›"})]})]},z.id)})})]})},It=()=>n.jsx(Hg,{telegramId:Q,telegramUser:oe,panelVisible:o==="precommande",onBalanceRefresh:()=>pe(k=>k+1),onOpenOrderDetail:async k=>{if(Q!=null){l("commandes"),J(!0);try{const[z,S]=await Promise.all([Ri(Q,{archived:!1}),Ri(Q,{archived:!0})]),O=Array.isArray(z==null?void 0:z.orders)?z.orders:[],V=Array.isArray(S==null?void 0:S.orders)?S.orders:[],H=O.some(ee=>ee.id===k),ue=V.some(ee=>ee.id===k);if(!H&&!ue){X("active"),F(O),ve(null);return}ue&&!H?(X("archived"),F(V)):(X("active"),F(O)),ve(k)}catch{F([]),ve(null)}finally{J(!1)}}}});if(Ie==="loading")return n.jsx("div",{className:"app app-auth-loading-wrap",children:n.jsxs("div",{className:"app-auth-loading",role:"status","aria-live":"polite",children:[n.jsx("span",{className:"app-auth-loading-ring","aria-hidden":!0}),n.jsx("span",{className:"app-auth-loading-label",children:"Connexion sécurisée"}),n.jsxs("span",{className:"app-auth-loading-dots","aria-hidden":!0,children:[n.jsx("span",{}),n.jsx("span",{}),n.jsx("span",{})]})]})});if(Ie==="blocked")return n.jsx("div",{className:"app",children:n.jsx(Qg,{reason:K,onRetry:Ve})});if(e==="admin")return n.jsx("div",{className:"app app-admin",children:n.jsx(bg,{onBack:()=>{t("shop"),typeof window<"u"&&window.history.pushState({},"","/")}})});if(e==="seller")return n.jsx("div",{className:"app app-seller",children:n.jsx(wg,{onBack:()=>{t("shop"),typeof window<"u"&&window.history.pushState({},"","/")}})});const Qt=()=>o==="accueil"?n.jsxs(n.Fragment,{children:[n.jsx(dg,{active:r,onChange:a}),n.jsx(cg,{count:y.length,searchQuery:i,onSearchChange:s,onOpenFilters:()=>p(!0)}),r==="nouveautes"?at():n.jsx(pg,{products:y,onAddToCart:Ke,cartItems:P,searchQuery:i})]}):o==="panier"?ft():o==="commandes"?Xe():null;return n.jsxs("div",{className:"app",children:[n.jsx(ag,{onOpenProfile:()=>se(!0),onSpaceSelect:k=>{if(!(typeof window>"u")){if(k==="Admin"){t("admin"),window.history.pushState({},"","/adminPanel");return}k==="Revendeur"&&(t("seller"),window.history.pushState({},"","/vendeurPanel"))}}}),n.jsx("div",{className:"top-shop-nav-outer",children:n.jsx(kg,{active:o,onChange:l,cartCount:P.length})}),n.jsx(sg,{balanceRefreshKey:U,telegramId:Q,authReady:Ie==="ready"}),Qt(),n.jsx("div",{className:o==="precommande"?"app-menu-panel":"app-menu-panel app-menu-panel--hidden","aria-hidden":o!=="precommande",children:It()}),d&&n.jsx(Sg,{products:u,initialFilters:Z,onApply:ce,onClose:()=>p(!1)}),ie?n.jsx(lg,{onClose:()=>se(!1),onOpenCommandes:()=>{se(!1),l("commandes")},onToast:ze}):null,n.jsx(jg,{active:o,onChange:l,cartCount:P.length}),ke?n.jsxs("div",{className:`app-toast-root ${ke.successMeta?"app-toast-root-checkout":""}`,role:"dialog","aria-modal":"true","aria-labelledby":ke.successMeta?"app-toast-checkout-title":"app-toast-title",children:[n.jsx("button",{type:"button",className:"app-toast-backdrop",onClick:Ge,"aria-label":"Fermer la notification"}),n.jsxs("div",{className:`app-toast-card ${ke.kind==="error"?"app-toast-card-error":"app-toast-card-success"} ${ke.successMeta?"app-toast-card-checkout":""}`,children:[n.jsx("button",{type:"button",className:"app-toast-close-x",onClick:Ge,"aria-label":"Fermer",children:"×"}),ke.kind==="success"&&ke.successMeta?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"app-toast-checkout-icon","aria-hidden":"true",children:n.jsxs("svg",{viewBox:"0 0 48 48",width:"48",height:"48",fill:"none",children:[n.jsx("circle",{cx:"24",cy:"24",r:"22",stroke:"currentColor",strokeWidth:"2",opacity:"0.35"}),n.jsx("path",{d:"M14 24l7 7 13-14",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),n.jsx("h2",{id:"app-toast-checkout-title",className:"app-toast-checkout-title",children:"Paiement confirmé"}),n.jsx("p",{className:"app-toast-checkout-lead",children:"Votre commande a bien été enregistrée."}),n.jsxs("div",{className:"app-toast-checkout-summary",children:[n.jsxs("div",{className:"app-toast-checkout-row",children:[n.jsx("span",{children:"Total payé"}),n.jsxs("strong",{children:[ke.successMeta.total.toFixed(2)," €"]})]}),ke.successMeta.commandeId!=null?n.jsxs("div",{className:"app-toast-checkout-row",children:[n.jsx("span",{children:"N° de commande"}),n.jsxs("strong",{className:"app-toast-checkout-mono",children:["#",ke.successMeta.commandeId]})]}):null,n.jsxs("div",{className:"app-toast-checkout-row",children:[n.jsxs("span",{children:["Article",ke.successMeta.itemCount>1?"s":""]}),n.jsx("strong",{children:ke.successMeta.itemCount})]}),ke.successMeta.newBalance!=null&&!Number.isNaN(ke.successMeta.newBalance)?n.jsxs("div",{className:"app-toast-checkout-row app-toast-checkout-row-muted",children:[n.jsx("span",{children:"Nouveau solde"}),n.jsxs("strong",{children:[ke.successMeta.newBalance.toFixed(2)," €"]})]}):null]}),n.jsx("button",{type:"button",className:"app-toast-checkout-cta",onClick:Ge,children:"Continuer"})]}):n.jsx("p",{id:"app-toast-title",className:"app-toast-text",children:ke.text})]})]}):null]})}typeof window<"u"&&"scrollRestoration"in window.history&&(window.history.scrollRestoration="manual"),window.__BUILD_TS__=Date.now(),typeof window<"u"&&(console.log("[ycc-shop] main.jsx",{buildTs:window.__BUILD_TS__,hasRoot:!!document.getElementById("root")}),fetch("/api/ping-webapp?phase=react-main",{method:"GET",cache:"no-store"}).catch(()=>{}),window.addEventListener("error",e=>{console.error("[ycc-shop] window.error",{message:e.message,file:e.filename,line:e.lineno})}),window.addEventListener("unhandledrejection",e=>{console.error("[ycc-shop] unhandledrejection",e.reason)})),ns.createRoot(document.getElementById("root")).render(n.jsx(hf.StrictMode,{children:n.jsx(ex,{})}))})();