function Bf(e,t){for(var n=0;nr[l]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))r(l);new MutationObserver(l=>{for(const s of l)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(l){const s={};return l.integrity&&(s.integrity=l.integrity),l.referrerPolicy&&(s.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?s.credentials="include":l.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(l){if(l.ep)return;l.ep=!0;const s=n(l);fetch(l.href,s)}})();function bf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var bu={exports:{}},ql={},Wu={exports:{}},I={};/** * @license React * react.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 Ar=Symbol.for("react.element"),Wf=Symbol.for("react.portal"),Vf=Symbol.for("react.fragment"),Hf=Symbol.for("react.strict_mode"),Qf=Symbol.for("react.profiler"),Kf=Symbol.for("react.provider"),Yf=Symbol.for("react.context"),Gf=Symbol.for("react.forward_ref"),qf=Symbol.for("react.suspense"),Jf=Symbol.for("react.memo"),Xf=Symbol.for("react.lazy"),ho=Symbol.iterator;function Zf(e){return e===null||typeof e!="object"?null:(e=ho&&e[ho]||e["@@iterator"],typeof e=="function"?e:null)}var Vu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Hu=Object.assign,Qu={};function Fn(e,t,n){this.props=e,this.context=t,this.refs=Qu,this.updater=n||Vu}Fn.prototype.isReactComponent={};Fn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Fn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Ku(){}Ku.prototype=Fn.prototype;function oa(e,t,n){this.props=e,this.context=t,this.refs=Qu,this.updater=n||Vu}var ua=oa.prototype=new Ku;ua.constructor=oa;Hu(ua,Fn.prototype);ua.isPureReactComponent=!0;var mo=Array.isArray,Yu=Object.prototype.hasOwnProperty,ca={current:null},Gu={key:!0,ref:!0,__self:!0,__source:!0};function qu(e,t,n){var r,l={},s=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(s=""+t.key),t)Yu.call(t,r)&&!Gu.hasOwnProperty(r)&&(l[r]=t[r]);var o=arguments.length-2;if(o===1)l.children=n;else if(1>>1,X=R[V];if(0>>1;Vl(js,z))$tl(Or,js)?(R[V]=Or,R[$t]=z,V=$t):(R[V]=js,R[Ot]=z,V=Ot);else if($tl(Or,z))R[V]=Or,R[$t]=z,V=$t;else break e}}return _}function l(R,_){var z=R.sortIndex-_.sortIndex;return z!==0?z:R.id-_.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var a=Date,o=a.now();e.unstable_now=function(){return a.now()-o}}var u=[],c=[],p=1,m=null,g=3,v=!1,x=!1,j=!1,N=typeof setTimeout=="function"?setTimeout:null,f=typeof clearTimeout=="function"?clearTimeout:null,d=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function h(R){for(var _=n(c);_!==null;){if(_.callback===null)r(c);else if(_.startTime<=R)r(c),_.sortIndex=_.expirationTime,t(u,_);else break;_=n(c)}}function y(R){if(j=!1,h(R),!x)if(n(u)!==null)x=!0,Ve(S);else{var _=n(c);_!==null&&Xe(y,_.startTime-R)}}function S(R,_){x=!1,j&&(j=!1,f(C),C=-1),v=!0;var z=g;try{for(h(_),m=n(u);m!==null&&(!(m.expirationTime>_)||R&&!O());){var V=m.callback;if(typeof V=="function"){m.callback=null,g=m.priorityLevel;var X=V(m.expirationTime<=_);_=e.unstable_now(),typeof X=="function"?m.callback=X:m===n(u)&&r(u),h(_)}else r(u);m=n(u)}if(m!==null)var nn=!0;else{var Ot=n(c);Ot!==null&&Xe(y,Ot.startTime-_),nn=!1}return nn}finally{m=null,g=z,v=!1}}var E=!1,k=null,C=-1,M=5,A=-1;function O(){return!(e.unstable_now()-AR||125V?(R.sortIndex=z,t(c,R),n(u)===null&&R===n(c)&&(j?(f(C),C=-1):j=!0,Xe(y,z-V))):(R.sortIndex=X,t(u,R),x||v||(x=!0,Ve(S))),R},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(R){var _=g;return function(){var z=g;g=_;try{return R.apply(this,arguments)}finally{g=z}}}})(tc);ec.exports=tc;var fp=ec.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 pp=w,Ee=fp;function P(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ri=Object.prototype.hasOwnProperty,hp=/^[: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]*$/,vo={},yo={};function mp(e){return ri.call(yo,e)?!0:ri.call(vo,e)?!1:hp.test(e)?yo[e]=!0:(vo[e]=!0,!1)}function gp(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function vp(e,t,n,r){if(t===null||typeof t>"u"||gp(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.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 me(e,t,n,r,l,s,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=l,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=a}var ae={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){ae[e]=new me(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];ae[t]=new me(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){ae[e]=new me(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){ae[e]=new me(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){ae[e]=new me(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){ae[e]=new me(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){ae[e]=new me(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){ae[e]=new me(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){ae[e]=new me(e,5,!1,e.toLowerCase(),null,!1,!1)});var fa=/[\-:]([a-z])/g;function pa(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(fa,pa);ae[t]=new me(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(fa,pa);ae[t]=new me(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(fa,pa);ae[t]=new me(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){ae[e]=new me(e,1,!1,e.toLowerCase(),null,!1,!1)});ae.xlinkHref=new me("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){ae[e]=new me(e,1,!1,e.toLowerCase(),null,!0,!0)});function ha(e,t,n,r){var l=ae.hasOwnProperty(t)?ae[t]:null;(l!==null?l.type!==0:r||!(2o||l[a]!==s[o]){var u=` `+l[a].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=a&&0<=o);break}}}finally{Cs=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?qn(e):""}function yp(e){switch(e.tag){case 5:return qn(e.type);case 16:return qn("Lazy");case 13:return qn("Suspense");case 19:return qn("SuspenseList");case 0:case 2:case 15:return e=Es(e.type,!1),e;case 11:return e=Es(e.type.render,!1),e;case 1:return e=Es(e.type,!0),e;default:return""}}function ai(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 on:return"Fragment";case an:return"Portal";case li:return"Profiler";case ma:return"StrictMode";case si:return"Suspense";case ii:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case lc:return(e.displayName||"Context")+".Consumer";case rc:return(e._context.displayName||"Context")+".Provider";case ga:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case va:return t=e.displayName||null,t!==null?t:ai(e.type)||"Memo";case pt:t=e._payload,e=e._init;try{return ai(e(t))}catch{}}return null}function xp(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 ai(t);case 8:return t===ma?"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 At(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function ic(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function wp(e){var t=ic(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var l=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return l.call(this)},set:function(a){r=""+a,s.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function br(e){e._valueTracker||(e._valueTracker=wp(e))}function ac(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=ic(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function wl(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 oi(e,t){var n=t.checked;return Y({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function wo(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=At(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function oc(e,t){t=t.checked,t!=null&&ha(e,"checked",t,!1)}function ui(e,t){oc(e,t);var n=At(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?ci(e,t.type,n):t.hasOwnProperty("defaultValue")&&ci(e,t.type,At(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function jo(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function ci(e,t,n){(t!=="number"||wl(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Jn=Array.isArray;function xn(e,t,n,r){if(e=e.options,t){t={};for(var l=0;l"+t.valueOf().toString()+"",t=Wr.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function dr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var er={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},jp=["Webkit","ms","Moz","O"];Object.keys(er).forEach(function(e){jp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),er[t]=er[e]})});function fc(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||er.hasOwnProperty(e)&&er[e]?(""+t).trim():t+"px"}function pc(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,l=fc(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,l):e[n]=l}}var Sp=Y({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 pi(e,t){if(t){if(Sp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(P(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(P(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(P(61))}if(t.style!=null&&typeof t.style!="object")throw Error(P(62))}}function hi(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 mi=null;function ya(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var gi=null,wn=null,jn=null;function Co(e){if(e=zr(e)){if(typeof gi!="function")throw Error(P(280));var t=e.stateNode;t&&(t=ts(t),gi(e.stateNode,e.type,t))}}function hc(e){wn?jn?jn.push(e):jn=[e]:wn=e}function mc(){if(wn){var e=wn,t=jn;if(jn=wn=null,Co(e),t)for(e=0;e>>=0,e===0?32:31-(_p(e)/zp|0)|0}var Vr=64,Hr=4194304;function Xn(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 Cl(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,l=e.suspendedLanes,s=e.pingedLanes,a=n&268435455;if(a!==0){var o=a&~l;o!==0?r=Xn(o):(s&=a,s!==0&&(r=Xn(s)))}else a=n&~l,a!==0?r=Xn(a):s!==0&&(r=Xn(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&l)&&(l=r&-r,s=t&-t,l>=s||l===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Mr(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Be(t),e[t]=n}function Up(e,t){var n=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 r=e.eventTimes;for(e=e.expirationTimes;0=nr),_o=" ",zo=!1;function Ic(e,t){switch(e){case"keyup":return fh.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Dc(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var un=!1;function hh(e,t){switch(e){case"compositionend":return Dc(t);case"keypress":return t.which!==32?null:(zo=!0,_o);case"textInput":return e=t.data,e===_o&&zo?null:e;default:return null}}function mh(e,t){if(un)return e==="compositionend"||!ka&&Ic(e,t)?(e=_c(),ul=Na=vt=null,un=!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:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Uo(n)}}function $c(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?$c(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Bc(){for(var e=window,t=wl();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=wl(e.document)}return t}function Pa(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 Ch(e){var t=Bc(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&$c(n.ownerDocument.documentElement,n)){if(r!==null&&Pa(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var l=n.textContent.length,s=Math.min(r.start,l);r=r.end===void 0?s:Math.min(r.end,l),!e.extend&&s>r&&(l=r,r=s,s=l),l=Oo(n,s);var a=Oo(n,r);l&&a&&(e.rangeCount!==1||e.anchorNode!==l.node||e.anchorOffset!==l.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(l.node,l.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,cn=null,Si=null,lr=null,Ni=!1;function $o(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ni||cn==null||cn!==wl(r)||(r=cn,"selectionStart"in r&&Pa(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),lr&&vr(lr,r)||(lr=r,r=Pl(Si,"onSelect"),0pn||(e.current=Ti[pn],Ti[pn]=null,pn--)}function $(e,t){pn++,Ti[pn]=e.current,e.current=t}var Mt={},de=zt(Mt),ye=zt(!1),Gt=Mt;function kn(e,t){var n=e.type.contextTypes;if(!n)return Mt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},s;for(s in n)l[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function xe(e){return e=e.childContextTypes,e!=null}function Tl(){b(ye),b(de)}function Ko(e,t,n){if(de.current!==Mt)throw Error(P(168));$(de,t),$(ye,n)}function qc(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(P(108,xp(e)||"Unknown",l));return Y({},n,r)}function Ll(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Mt,Gt=de.current,$(de,e),$(ye,ye.current),!0}function Yo(e,t,n){var r=e.stateNode;if(!r)throw Error(P(169));n?(e=qc(e,t,Gt),r.__reactInternalMemoizedMergedChildContext=e,b(ye),b(de),$(de,e)):b(ye),$(ye,n)}var et=null,ns=!1,Os=!1;function Jc(e){et===null?et=[e]:et.push(e)}function Dh(e){ns=!0,Jc(e)}function It(){if(!Os&&et!==null){Os=!0;var e=0,t=F;try{var n=et;for(F=1;e>=a,l-=a,tt=1<<32-Be(t)+l|n<C?(M=k,k=null):M=k.sibling;var A=g(f,k,h[C],y);if(A===null){k===null&&(k=M);break}e&&k&&A.alternate===null&&t(f,k),d=s(A,d,C),E===null?S=A:E.sibling=A,E=A,k=M}if(C===h.length)return n(f,k),W&&bt(f,C),S;if(k===null){for(;CC?(M=k,k=null):M=k.sibling;var O=g(f,k,A.value,y);if(O===null){k===null&&(k=M);break}e&&k&&O.alternate===null&&t(f,k),d=s(O,d,C),E===null?S=O:E.sibling=O,E=O,k=M}if(A.done)return n(f,k),W&&bt(f,C),S;if(k===null){for(;!A.done;C++,A=h.next())A=m(f,A.value,y),A!==null&&(d=s(A,d,C),E===null?S=A:E.sibling=A,E=A);return W&&bt(f,C),S}for(k=r(f,k);!A.done;C++,A=h.next())A=v(k,f,C,A.value,y),A!==null&&(e&&A.alternate!==null&&k.delete(A.key===null?C:A.key),d=s(A,d,C),E===null?S=A:E.sibling=A,E=A);return e&&k.forEach(function(Te){return t(f,Te)}),W&&bt(f,C),S}function N(f,d,h,y){if(typeof h=="object"&&h!==null&&h.type===on&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case Br:e:{for(var S=h.key,E=d;E!==null;){if(E.key===S){if(S=h.type,S===on){if(E.tag===7){n(f,E.sibling),d=l(E,h.props.children),d.return=f,f=d;break e}}else if(E.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===pt&&Jo(S)===E.type){n(f,E.sibling),d=l(E,h.props),d.ref=Kn(f,E,h),d.return=f,f=d;break e}n(f,E);break}else t(f,E);E=E.sibling}h.type===on?(d=Yt(h.props.children,f.mode,y,h.key),d.return=f,f=d):(y=vl(h.type,h.key,h.props,null,f.mode,y),y.ref=Kn(f,d,h),y.return=f,f=y)}return a(f);case an:e:{for(E=h.key;d!==null;){if(d.key===E)if(d.tag===4&&d.stateNode.containerInfo===h.containerInfo&&d.stateNode.implementation===h.implementation){n(f,d.sibling),d=l(d,h.children||[]),d.return=f,f=d;break e}else{n(f,d);break}else t(f,d);d=d.sibling}d=Ks(h,f.mode,y),d.return=f,f=d}return a(f);case pt:return E=h._init,N(f,d,E(h._payload),y)}if(Jn(h))return x(f,d,h,y);if(bn(h))return j(f,d,h,y);Xr(f,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,d!==null&&d.tag===6?(n(f,d.sibling),d=l(d,h),d.return=f,f=d):(n(f,d),d=Qs(h,f.mode,y),d.return=f,f=d),a(f)):n(f,d)}return N}var Rn=td(!0),nd=td(!1),_l=zt(null),zl=null,gn=null,Aa=null;function Ma(){Aa=gn=zl=null}function _a(e){var t=_l.current;b(_l),e._currentValue=t}function Mi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Nn(e,t){zl=e,Aa=gn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(ve=!0),e.firstContext=null)}function ze(e){var t=e._currentValue;if(Aa!==e)if(e={context:e,memoizedValue:t,next:null},gn===null){if(zl===null)throw Error(P(308));gn=e,zl.dependencies={lanes:0,firstContext:e}}else gn=gn.next=e;return t}var Ht=null;function za(e){Ht===null?Ht=[e]:Ht.push(e)}function rd(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,za(t)):(n.next=l.next,l.next=n),t.interleaved=n,at(e,r)}function at(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var ht=!1;function Ia(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ld(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 lt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Et(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,D&2){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,at(e,n)}return l=r.interleaved,l===null?(t.next=t,za(r)):(t.next=l.next,l.next=t),r.interleaved=t,at(e,n)}function dl(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,wa(e,n)}}function Xo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?l=s=a:s=s.next=a,n=n.next}while(n!==null);s===null?l=s=t:s=s.next=t}else l=s=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Il(e,t,n,r){var l=e.updateQueue;ht=!1;var s=l.firstBaseUpdate,a=l.lastBaseUpdate,o=l.shared.pending;if(o!==null){l.shared.pending=null;var u=o,c=u.next;u.next=null,a===null?s=c:a.next=c,a=u;var p=e.alternate;p!==null&&(p=p.updateQueue,o=p.lastBaseUpdate,o!==a&&(o===null?p.firstBaseUpdate=c:o.next=c,p.lastBaseUpdate=u))}if(s!==null){var m=l.baseState;a=0,p=c=u=null,o=s;do{var g=o.lane,v=o.eventTime;if((r&g)===g){p!==null&&(p=p.next={eventTime:v,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var x=e,j=o;switch(g=t,v=n,j.tag){case 1:if(x=j.payload,typeof x=="function"){m=x.call(v,m,g);break e}m=x;break e;case 3:x.flags=x.flags&-65537|128;case 0:if(x=j.payload,g=typeof x=="function"?x.call(v,m,g):x,g==null)break e;m=Y({},m,g);break e;case 2:ht=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,g=l.effects,g===null?l.effects=[o]:g.push(o))}else v={eventTime:v,lane:g,tag:o.tag,payload:o.payload,callback:o.callback,next:null},p===null?(c=p=v,u=m):p=p.next=v,a|=g;if(o=o.next,o===null){if(o=l.shared.pending,o===null)break;g=o,o=g.next,g.next=null,l.lastBaseUpdate=g,l.shared.pending=null}}while(!0);if(p===null&&(u=m),l.baseState=u,l.firstBaseUpdate=c,l.lastBaseUpdate=p,t=l.shared.interleaved,t!==null){l=t;do a|=l.lane,l=l.next;while(l!==t)}else s===null&&(l.shared.lanes=0);Xt|=a,e.lanes=a,e.memoizedState=m}}function Zo(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Bs.transition;Bs.transition={};try{e(!1),t()}finally{F=n,Bs.transition=r}}function jd(){return Ie().memoizedState}function $h(e,t,n){var r=Pt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Sd(e))Nd(t,n);else if(n=rd(e,t,n,r),n!==null){var l=pe();be(n,e,r,l),Cd(n,t,r)}}function Bh(e,t,n){var r=Pt(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Sd(e))Nd(t,l);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var a=t.lastRenderedState,o=s(a,n);if(l.hasEagerState=!0,l.eagerState=o,We(o,a)){var u=t.interleaved;u===null?(l.next=l,za(t)):(l.next=u.next,u.next=l),t.interleaved=l;return}}catch{}finally{}n=rd(e,t,l,r),n!==null&&(l=pe(),be(n,e,r,l),Cd(n,t,r))}}function Sd(e){var t=e.alternate;return e===Q||t!==null&&t===Q}function Nd(e,t){sr=Fl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Cd(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,wa(e,n)}}var Ul={readContext:ze,useCallback:oe,useContext:oe,useEffect:oe,useImperativeHandle:oe,useInsertionEffect:oe,useLayoutEffect:oe,useMemo:oe,useReducer:oe,useRef:oe,useState:oe,useDebugValue:oe,useDeferredValue:oe,useTransition:oe,useMutableSource:oe,useSyncExternalStore:oe,useId:oe,unstable_isNewReconciler:!1},bh={readContext:ze,useCallback:function(e,t){return Qe().memoizedState=[e,t===void 0?null:t],e},useContext:ze,useEffect:tu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,pl(4194308,4,gd.bind(null,t,e),n)},useLayoutEffect:function(e,t){return pl(4194308,4,e,t)},useInsertionEffect:function(e,t){return pl(4,2,e,t)},useMemo:function(e,t){var n=Qe();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Qe();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=$h.bind(null,Q,e),[r.memoizedState,e]},useRef:function(e){var t=Qe();return e={current:e},t.memoizedState=e},useState:eu,useDebugValue:Wa,useDeferredValue:function(e){return Qe().memoizedState=e},useTransition:function(){var e=eu(!1),t=e[0];return e=Oh.bind(null,e[1]),Qe().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Q,l=Qe();if(W){if(n===void 0)throw Error(P(407));n=n()}else{if(n=t(),le===null)throw Error(P(349));Jt&30||od(r,t,n)}l.memoizedState=n;var s={value:n,getSnapshot:t};return l.queue=s,tu(cd.bind(null,r,s,e),[e]),r.flags|=2048,Er(9,ud.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=Qe(),t=le.identifierPrefix;if(W){var n=nt,r=tt;n=(r&~(1<<32-Be(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Nr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[Ke]=t,e[wr]=r,zd(e,t,!1,!1),t.stateNode=e;e:{switch(a=hi(n,r),n){case"dialog":B("cancel",e),B("close",e),l=r;break;case"iframe":case"object":case"embed":B("load",e),l=r;break;case"video":case"audio":for(l=0;lAn&&(t.flags|=128,r=!0,Yn(s,!1),t.lanes=4194304)}else{if(!r)if(e=Dl(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Yn(s,!0),s.tail===null&&s.tailMode==="hidden"&&!a.alternate&&!W)return ue(t),null}else 2*J()-s.renderingStartTime>An&&n!==1073741824&&(t.flags|=128,r=!0,Yn(s,!1),t.lanes=4194304);s.isBackwards?(a.sibling=t.child,t.child=a):(n=s.last,n!==null?n.sibling=a:t.child=a,s.last=a)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=J(),t.sibling=null,n=H.current,$(H,r?n&1|2:n&1),t):(ue(t),null);case 22:case 23:return Ga(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Se&1073741824&&(ue(t),t.subtreeFlags&6&&(t.flags|=8192)):ue(t),null;case 24:return null;case 25:return null}throw Error(P(156,t.tag))}function qh(e,t){switch(Ta(t),t.tag){case 1:return xe(t.type)&&Tl(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Tn(),b(ye),b(de),Ua(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Fa(t),null;case 13:if(b(H),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(P(340));Pn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return b(H),null;case 4:return Tn(),null;case 10:return _a(t.type._context),null;case 22:case 23:return Ga(),null;case 24:return null;default:return null}}var el=!1,ce=!1,Jh=typeof WeakSet=="function"?WeakSet:Set,T=null;function vn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){q(e,t,r)}else n.current=null}function Bi(e,t,n){try{n()}catch(r){q(e,t,r)}}var fu=!1;function Xh(e,t){if(Ci=El,e=Bc(),Pa(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var a=0,o=-1,u=-1,c=0,p=0,m=e,g=null;t:for(;;){for(var v;m!==n||l!==0&&m.nodeType!==3||(o=a+l),m!==s||r!==0&&m.nodeType!==3||(u=a+r),m.nodeType===3&&(a+=m.nodeValue.length),(v=m.firstChild)!==null;)g=m,m=v;for(;;){if(m===e)break t;if(g===n&&++c===l&&(o=a),g===s&&++p===r&&(u=a),(v=m.nextSibling)!==null)break;m=g,g=m.parentNode}m=v}n=o===-1||u===-1?null:{start:o,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ei={focusedElem:e,selectionRange:n},El=!1,T=t;T!==null;)if(t=T,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,T=e;else for(;T!==null;){t=T;try{var x=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(x!==null){var j=x.memoizedProps,N=x.memoizedState,f=t.stateNode,d=f.getSnapshotBeforeUpdate(t.elementType===t.type?j:Ue(t.type,j),N);f.__reactInternalSnapshotBeforeUpdate=d}break;case 3:var h=t.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(P(163))}}catch(y){q(t,t.return,y)}if(e=t.sibling,e!==null){e.return=t.return,T=e;break}T=t.return}return x=fu,fu=!1,x}function ir(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var s=l.destroy;l.destroy=void 0,s!==void 0&&Bi(t,n,s)}l=l.next}while(l!==r)}}function ss(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function bi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Fd(e){var t=e.alternate;t!==null&&(e.alternate=null,Fd(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ke],delete t[wr],delete t[Ri],delete t[zh],delete t[Ih])),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 Ud(e){return e.tag===5||e.tag===3||e.tag===4}function pu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Ud(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 Wi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Rl));else if(r!==4&&(e=e.child,e!==null))for(Wi(e,t,n),e=e.sibling;e!==null;)Wi(e,t,n),e=e.sibling}function Vi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Vi(e,t,n),e=e.sibling;e!==null;)Vi(e,t,n),e=e.sibling}var se=null,Oe=!1;function ft(e,t,n){for(n=n.child;n!==null;)Od(e,t,n),n=n.sibling}function Od(e,t,n){if(Ye&&typeof Ye.onCommitFiberUnmount=="function")try{Ye.onCommitFiberUnmount(Jl,n)}catch{}switch(n.tag){case 5:ce||vn(n,t);case 6:var r=se,l=Oe;se=null,ft(e,t,n),se=r,Oe=l,se!==null&&(Oe?(e=se,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):se.removeChild(n.stateNode));break;case 18:se!==null&&(Oe?(e=se,n=n.stateNode,e.nodeType===8?Us(e.parentNode,n):e.nodeType===1&&Us(e,n),mr(e)):Us(se,n.stateNode));break;case 4:r=se,l=Oe,se=n.stateNode.containerInfo,Oe=!0,ft(e,t,n),se=r,Oe=l;break;case 0:case 11:case 14:case 15:if(!ce&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var s=l,a=s.destroy;s=s.tag,a!==void 0&&(s&2||s&4)&&Bi(n,t,a),l=l.next}while(l!==r)}ft(e,t,n);break;case 1:if(!ce&&(vn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){q(n,t,o)}ft(e,t,n);break;case 21:ft(e,t,n);break;case 22:n.mode&1?(ce=(r=ce)||n.memoizedState!==null,ft(e,t,n),ce=r):ft(e,t,n);break;default:ft(e,t,n)}}function hu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Jh),t.forEach(function(r){var l=am.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function Fe(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=a),r&=~s}if(r=l,r=J()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*em(r/1960))-r,10e?16:e,yt===null)var r=!1;else{if(e=yt,yt=null,Bl=0,D&6)throw Error(P(331));var l=D;for(D|=4,T=e.current;T!==null;){var s=T,a=s.child;if(T.flags&16){var o=s.deletions;if(o!==null){for(var u=0;uJ()-Ka?Kt(e,0):Qa|=n),we(e,t)}function Kd(e,t){t===0&&(e.mode&1?(t=Hr,Hr<<=1,!(Hr&130023424)&&(Hr=4194304)):t=1);var n=pe();e=at(e,t),e!==null&&(Mr(e,t,n),we(e,n))}function im(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Kd(e,n)}function am(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(P(314))}r!==null&&r.delete(t),Kd(e,n)}var Yd;Yd=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||ye.current)ve=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return ve=!1,Yh(e,t,n);ve=!!(e.flags&131072)}else ve=!1,W&&t.flags&1048576&&Xc(t,Ml,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;hl(e,t),e=t.pendingProps;var l=kn(t,de.current);Nn(t,n),l=$a(null,t,r,e,l,n);var s=Ba();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,xe(r)?(s=!0,Ll(t)):s=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Ia(t),l.updater=ls,t.stateNode=l,l._reactInternals=t,zi(t,r,e,n),t=Fi(null,t,r,!0,s,n)):(t.tag=0,W&&s&&Ra(t),fe(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(hl(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=um(r),e=Ue(r,e),l){case 0:t=Di(null,t,r,e,n);break e;case 1:t=uu(null,t,r,e,n);break e;case 11:t=au(null,t,r,e,n);break e;case 14:t=ou(null,t,r,Ue(r.type,e),n);break e}throw Error(P(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ue(r,l),Di(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ue(r,l),uu(e,t,r,l,n);case 3:e:{if(Ad(t),e===null)throw Error(P(387));r=t.pendingProps,s=t.memoizedState,l=s.element,ld(e,t),Il(t,r,null,n);var a=t.memoizedState;if(r=a.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){l=Ln(Error(P(423)),t),t=cu(e,t,r,n,l);break e}else if(r!==l){l=Ln(Error(P(424)),t),t=cu(e,t,r,n,l);break e}else for(Ne=Ct(t.stateNode.containerInfo.firstChild),Ce=t,W=!0,$e=null,n=nd(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Pn(),r===l){t=ot(e,t,n);break e}fe(e,t,r,n)}t=t.child}return t;case 5:return sd(t),e===null&&Ai(t),r=t.type,l=t.pendingProps,s=e!==null?e.memoizedProps:null,a=l.children,ki(r,l)?a=null:s!==null&&ki(r,s)&&(t.flags|=32),Ld(e,t),fe(e,t,a,n),t.child;case 6:return e===null&&Ai(t),null;case 13:return Md(e,t,n);case 4:return Da(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Rn(t,null,r,n):fe(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ue(r,l),au(e,t,r,l,n);case 7:return fe(e,t,t.pendingProps,n),t.child;case 8:return fe(e,t,t.pendingProps.children,n),t.child;case 12:return fe(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,s=t.memoizedProps,a=l.value,$(_l,r._currentValue),r._currentValue=a,s!==null)if(We(s.value,a)){if(s.children===l.children&&!ye.current){t=ot(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var o=s.dependencies;if(o!==null){a=s.child;for(var u=o.firstContext;u!==null;){if(u.context===r){if(s.tag===1){u=lt(-1,n&-n),u.tag=2;var c=s.updateQueue;if(c!==null){c=c.shared;var p=c.pending;p===null?u.next=u:(u.next=p.next,p.next=u),c.pending=u}}s.lanes|=n,u=s.alternate,u!==null&&(u.lanes|=n),Mi(s.return,n,t),o.lanes|=n;break}u=u.next}}else if(s.tag===10)a=s.type===t.type?null:s.child;else if(s.tag===18){if(a=s.return,a===null)throw Error(P(341));a.lanes|=n,o=a.alternate,o!==null&&(o.lanes|=n),Mi(a,n,t),a=s.sibling}else a=s.child;if(a!==null)a.return=s;else for(a=s;a!==null;){if(a===t){a=null;break}if(s=a.sibling,s!==null){s.return=a.return,a=s;break}a=a.return}s=a}fe(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,Nn(t,n),l=ze(l),r=r(l),t.flags|=1,fe(e,t,r,n),t.child;case 14:return r=t.type,l=Ue(r,t.pendingProps),l=Ue(r.type,l),ou(e,t,r,l,n);case 15:return Rd(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:Ue(r,l),hl(e,t),t.tag=1,xe(r)?(e=!0,Ll(t)):e=!1,Nn(t,n),Ed(t,r,l),zi(t,r,l,n),Fi(null,t,r,!0,e,n);case 19:return _d(e,t,n);case 22:return Td(e,t,n)}throw Error(P(156,t.tag))};function Gd(e,t){return Sc(e,t)}function om(e,t,n,r){this.tag=e,this.key=n,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=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Me(e,t,n,r){return new om(e,t,n,r)}function Ja(e){return e=e.prototype,!(!e||!e.isReactComponent)}function um(e){if(typeof e=="function")return Ja(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ga)return 11;if(e===va)return 14}return 2}function Rt(e,t){var n=e.alternate;return n===null?(n=Me(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function vl(e,t,n,r,l,s){var a=2;if(r=e,typeof e=="function")Ja(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case on:return Yt(n.children,l,s,t);case ma:a=8,l|=8;break;case li:return e=Me(12,n,t,l|2),e.elementType=li,e.lanes=s,e;case si:return e=Me(13,n,t,l),e.elementType=si,e.lanes=s,e;case ii:return e=Me(19,n,t,l),e.elementType=ii,e.lanes=s,e;case sc:return as(n,l,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case rc:a=10;break e;case lc:a=9;break e;case ga:a=11;break e;case va:a=14;break e;case pt:a=16,r=null;break e}throw Error(P(130,e==null?e:typeof e,""))}return t=Me(a,n,t,l),t.elementType=e,t.type=r,t.lanes=s,t}function Yt(e,t,n,r){return e=Me(7,e,r,t),e.lanes=n,e}function as(e,t,n,r){return e=Me(22,e,r,t),e.elementType=sc,e.lanes=n,e.stateNode={isHidden:!1},e}function Qs(e,t,n){return e=Me(6,e,null,t),e.lanes=n,e}function Ks(e,t,n){return t=Me(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function cm(e,t,n,r,l){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=Ps(0),this.expirationTimes=Ps(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ps(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function Xa(e,t,n,r,l,s,a,o,u){return e=new cm(e,t,n,o,u),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Me(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ia(s),e}function dm(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Zd)}catch(e){console.error(e)}}Zd(),Zu.exports=ke;var gm=Zu.exports,ef,Su=gm;ef=Su.createRoot,Su.hydrateRoot;/** * @remix-run/router v1.23.4 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Pr(){return Pr=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function tf(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function ym(){return Math.random().toString(36).substr(2,8)}function Cu(e,t){return{usr:e.state,key:e.key,idx:t}}function Gi(e,t,n,r){return n===void 0&&(n=null),Pr({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?$n(t):t,{state:n,key:t&&t.key||r||ym()})}function Vl(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function $n(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function xm(e,t,n,r){r===void 0&&(r={});let{window:l=document.defaultView,v5Compat:s=!1}=r,a=l.history,o=xt.Pop,u=null,c=p();c==null&&(c=0,a.replaceState(Pr({},a.state,{idx:c}),""));function p(){return(a.state||{idx:null}).idx}function m(){o=xt.Pop;let N=p(),f=N==null?null:N-c;c=N,u&&u({action:o,location:j.location,delta:f})}function g(N,f){o=xt.Push;let d=Gi(j.location,N,f);c=p()+1;let h=Cu(d,c),y=j.createHref(d);try{a.pushState(h,"",y)}catch(S){if(S instanceof DOMException&&S.name==="DataCloneError")throw S;l.location.assign(y)}s&&u&&u({action:o,location:j.location,delta:1})}function v(N,f){o=xt.Replace;let d=Gi(j.location,N,f);c=p();let h=Cu(d,c),y=j.createHref(d);a.replaceState(h,"",y),s&&u&&u({action:o,location:j.location,delta:0})}function x(N){let f=l.location.origin!=="null"?l.location.origin:l.location.href,d=typeof N=="string"?N:Vl(N);return d=d.replace(/ $/,"%20"),K(f,"No window.location.(origin|href) available to create URL for href: "+d),new URL(d,f)}let j={get action(){return o},get location(){return e(l,a)},listen(N){if(u)throw new Error("A history only accepts one active listener");return l.addEventListener(Nu,m),u=N,()=>{l.removeEventListener(Nu,m),u=null}},createHref(N){return t(l,N)},createURL:x,encodeLocation(N){let f=x(N);return{pathname:f.pathname,search:f.search,hash:f.hash}},push:g,replace:v,go(N){return a.go(N)}};return j}var Eu;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Eu||(Eu={}));function wm(e,t,n){return n===void 0&&(n="/"),jm(e,t,n)}function jm(e,t,n,r){let l=typeof t=="string"?$n(t):t,s=Mn(l.pathname||"/",n);if(s==null)return null;let a=nf(e);Sm(a);let o=null,u=_m(s);for(let c=0;o==null&&c{let u={relativePath:o===void 0?s.path||"":o,caseSensitive:s.caseSensitive===!0,childrenIndex:a,route:s};u.relativePath.startsWith("/")&&(K(u.relativePath.startsWith(r),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(r.length));let c=Tt([r,u.relativePath]),p=n.concat(u);s.children&&s.children.length>0&&(K(s.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+c+'".')),nf(s.children,t,p,c)),!(s.path==null&&!s.index)&&t.push({path:c,score:Tm(c,s.index),routesMeta:p})};return e.forEach((s,a)=>{var o;if(s.path===""||!((o=s.path)!=null&&o.includes("?")))l(s,a);else for(let u of rf(s.path))l(s,a,u)}),t}function rf(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,l=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return l?[s,""]:[s];let a=rf(r.join("/")),o=[];return o.push(...a.map(u=>u===""?s:[s,u].join("/"))),l&&o.push(...a),o.map(u=>e.startsWith("/")&&u===""?"/":u)}function Sm(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Lm(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const Nm=/^:[\w-]+$/,Cm=3,Em=2,km=1,Pm=10,Rm=-2,ku=e=>e==="*";function Tm(e,t){let n=e.split("/"),r=n.length;return n.some(ku)&&(r+=Rm),t&&(r+=Em),n.filter(l=>!ku(l)).reduce((l,s)=>l+(Nm.test(s)?Cm:s===""?km:Pm),r)}function Lm(e,t){return e.length===t.length&&e.slice(0,-1).every((r,l)=>r===t[l])?e[e.length-1]-t[t.length-1]:0}function Am(e,t,n){let{routesMeta:r}=e,l={},s="/",a=[];for(let o=0;o{let{paramName:g,isOptional:v}=p;if(g==="*"){let j=o[m]||"";a=s.slice(0,s.length-j.length).replace(/(.)\/+$/,"$1")}const x=o[m];return v&&!x?c[g]=void 0:c[g]=(x||"").replace(/%2F/g,"/"),c},{}),pathname:s,pathnameBase:a,pattern:e}}function Mm(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),tf(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(a,o,u)=>(r.push({paramName:o,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,t?void 0:"i"),r]}function _m(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return tf(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Mn(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}function zm(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:l=""}=typeof e=="string"?$n(e):e,s;return n?(n=lf(n),n.startsWith("/")?s=Pu(n.substring(1),"/"):s=Pu(n,t)):s=t,{pathname:s,search:Fm(r),hash:Um(l)}}function Pu(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(l=>{l===".."?n.length>1&&n.pop():l!=="."&&n.push(l)}),n.length>1?n.join("/"):"/"}function Ys(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Im(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function no(e,t){let n=Im(e);return t?n.map((r,l)=>l===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function ro(e,t,n,r){r===void 0&&(r=!1);let l;typeof e=="string"?l=$n(e):(l=Pr({},e),K(!l.pathname||!l.pathname.includes("?"),Ys("?","pathname","search",l)),K(!l.pathname||!l.pathname.includes("#"),Ys("#","pathname","hash",l)),K(!l.search||!l.search.includes("#"),Ys("#","search","hash",l)));let s=e===""||l.pathname==="",a=s?"/":l.pathname,o;if(a==null)o=n;else{let m=t.length-1;if(!r&&a.startsWith("..")){let g=a.split("/");for(;g[0]==="..";)g.shift(),m-=1;l.pathname=g.join("/")}o=m>=0?t[m]:"/"}let u=zm(l,o),c=a&&a!=="/"&&a.endsWith("/"),p=(s||a===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(c||p)&&(u.pathname+="/"),u}const lf=e=>e.replace(/\/\/+/g,"/"),Tt=e=>lf(e.join("/")),Dm=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Fm=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Um=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Om(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const sf=["post","put","patch","delete"];new Set(sf);const $m=["get",...sf];new Set($m);/** * React Router v6.30.6 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Rr(){return Rr=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),w.useCallback(function(c,p){if(p===void 0&&(p={}),!o.current)return;if(typeof c=="number"){r.go(c);return}let m=ro(c,JSON.parse(a),s,p.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:Tt([t,m.pathname])),(p.replace?r.replace:r.push)(m,p.state,p)},[t,r,a,s,e])}const Wm=w.createContext(null);function Vm(e){let t=w.useContext(qe).outlet;return t&&w.createElement(Wm.Provider,{value:e},t)}function cf(){let{matches:e}=w.useContext(qe),t=e[e.length-1];return t?t.params:{}}function hs(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=w.useContext(dt),{matches:l}=w.useContext(qe),{pathname:s}=Dt(),a=JSON.stringify(no(l,r.v7_relativeSplatPath));return w.useMemo(()=>ro(e,JSON.parse(a),s,n==="path"),[e,a,s,n])}function Hm(e,t){return Qm(e,t)}function Qm(e,t,n,r){Bn()||K(!1);let{navigator:l}=w.useContext(dt),{matches:s}=w.useContext(qe),a=s[s.length-1],o=a?a.params:{};a&&a.pathname;let u=a?a.pathnameBase:"/";a&&a.route;let c=Dt(),p;if(t){var m;let N=typeof t=="string"?$n(t):t;u==="/"||(m=N.pathname)!=null&&m.startsWith(u)||K(!1),p=N}else p=c;let g=p.pathname||"/",v=g;if(u!=="/"){let N=u.replace(/^\//,"").split("/");v="/"+g.replace(/^\//,"").split("/").slice(N.length).join("/")}let x=wm(e,{pathname:v}),j=Jm(x&&x.map(N=>Object.assign({},N,{params:Object.assign({},o,N.params),pathname:Tt([u,l.encodeLocation?l.encodeLocation(N.pathname).pathname:N.pathname]),pathnameBase:N.pathnameBase==="/"?u:Tt([u,l.encodeLocation?l.encodeLocation(N.pathnameBase).pathname:N.pathnameBase])})),s,n,r);return t&&j?w.createElement(ps.Provider,{value:{location:Rr({pathname:"/",search:"",hash:"",state:null,key:"default"},p),navigationType:xt.Pop}},j):j}function Km(){let e=tg(),t=Om(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,l={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return w.createElement(w.Fragment,null,w.createElement("h2",null,"Unexpected Application Error!"),w.createElement("h3",{style:{fontStyle:"italic"}},t),n?w.createElement("pre",{style:l},n):null,null)}const Ym=w.createElement(Km,null);class Gm extends w.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?w.createElement(qe.Provider,{value:this.props.routeContext},w.createElement(of.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function qm(e){let{routeContext:t,match:n,children:r}=e,l=w.useContext(fs);return l&&l.static&&l.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(l.staticContext._deepestRenderedBoundaryId=n.route.id),w.createElement(qe.Provider,{value:t},r)}function Jm(e,t,n,r){var l;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var s;if(!n)return null;if(n.errors)e=n.matches;else if((s=r)!=null&&s.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,o=(l=n)==null?void 0:l.errors;if(o!=null){let p=a.findIndex(m=>m.route.id&&(o==null?void 0:o[m.route.id])!==void 0);p>=0||K(!1),a=a.slice(0,Math.min(a.length,p+1))}let u=!1,c=-1;if(n&&r&&r.v7_partialHydration)for(let p=0;p=0?a=a.slice(0,c+1):a=[a[0]];break}}}return a.reduceRight((p,m,g)=>{let v,x=!1,j=null,N=null;n&&(v=o&&m.route.id?o[m.route.id]:void 0,j=m.route.errorElement||Ym,u&&(c<0&&g===0?(rg("route-fallback"),x=!0,N=null):c===g&&(x=!0,N=m.route.hydrateFallbackElement||null)));let f=t.concat(a.slice(0,g+1)),d=()=>{let h;return v?h=j:x?h=N:m.route.Component?h=w.createElement(m.route.Component,null):m.route.element?h=m.route.element:h=p,w.createElement(qm,{match:m,routeContext:{outlet:p,matches:f,isDataRoute:n!=null},children:h})};return n&&(m.route.ErrorBoundary||m.route.errorElement||g===0)?w.createElement(Gm,{location:n.location,revalidation:n.revalidation,component:j,error:v,children:d(),routeContext:{outlet:null,matches:f,isDataRoute:!0}}):d()},null)}var df=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(df||{}),ff=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(ff||{});function Xm(e){let t=w.useContext(fs);return t||K(!1),t}function Zm(e){let t=w.useContext(af);return t||K(!1),t}function eg(e){let t=w.useContext(qe);return t||K(!1),t}function pf(e){let t=eg(),n=t.matches[t.matches.length-1];return n.route.id||K(!1),n.route.id}function tg(){var e;let t=w.useContext(of),n=Zm(),r=pf();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function ng(){let{router:e}=Xm(df.UseNavigateStable),t=pf(ff.UseNavigateStable),n=w.useRef(!1);return uf(()=>{n.current=!0}),w.useCallback(function(l,s){s===void 0&&(s={}),n.current&&(typeof l=="number"?e.navigate(l):e.navigate(l,Rr({fromRouteId:t},s)))},[e,t])}const Ru={};function rg(e,t,n){Ru[e]||(Ru[e]=!0)}function lg(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function yl(e){let{to:t,replace:n,state:r,relative:l}=e;Bn()||K(!1);let{future:s,static:a}=w.useContext(dt),{matches:o}=w.useContext(qe),{pathname:u}=Dt(),c=Ft(),p=ro(t,no(o,s.v7_relativeSplatPath),u,l==="path"),m=JSON.stringify(p);return w.useEffect(()=>c(JSON.parse(m),{replace:n,state:r,relative:l}),[c,m,l,n,r]),null}function sg(e){return Vm(e.context)}function G(e){K(!1)}function ig(e){let{basename:t="/",children:n=null,location:r,navigationType:l=xt.Pop,navigator:s,static:a=!1,future:o}=e;Bn()&&K(!1);let u=t.replace(/^\/*/,"/"),c=w.useMemo(()=>({basename:u,navigator:s,static:a,future:Rr({v7_relativeSplatPath:!1},o)}),[u,o,s,a]);typeof r=="string"&&(r=$n(r));let{pathname:p="/",search:m="",hash:g="",state:v=null,key:x="default"}=r,j=w.useMemo(()=>{let N=Mn(p,u);return N==null?null:{location:{pathname:N,search:m,hash:g,state:v,key:x},navigationType:l}},[u,p,m,g,v,x,l]);return j==null?null:w.createElement(dt.Provider,{value:c},w.createElement(ps.Provider,{children:n,value:j}))}function Ji(e){let{children:t,location:n}=e;return Hm(Xi(t),n)}new Promise(()=>{});function Xi(e,t){t===void 0&&(t=[]);let n=[];return w.Children.forEach(e,(r,l)=>{if(!w.isValidElement(r))return;let s=[...t,l];if(r.type===w.Fragment){n.push.apply(n,Xi(r.props.children,s));return}r.type!==G&&K(!1),!r.props.index||!r.props.children||K(!1);let a={id:r.props.id||s.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(a.children=Xi(r.props.children,s)),n.push(a)}),n}/** * React Router DOM v6.30.6 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */function Hl(){return Hl=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let r=e[n];return t.concat(Array.isArray(r)?r.map(l=>[n,l]):[[n,r]])},[]))}function ug(e,t){let n=Zi(e);return t&&t.forEach((r,l)=>{n.has(l)||t.getAll(l).forEach(s=>{n.append(l,s)})}),n}const cg=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],dg=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],fg="6";try{window.__reactRouterVersion=fg}catch{}const pg=w.createContext({isTransitioning:!1}),hg="startTransition",Tu=sp[hg];function mg(e){let{basename:t,children:n,future:r,window:l}=e,s=w.useRef();s.current==null&&(s.current=vm({window:l,v5Compat:!0}));let a=s.current,[o,u]=w.useState({action:a.action,location:a.location}),{v7_startTransition:c}=r||{},p=w.useCallback(m=>{c&&Tu?Tu(()=>u(m)):u(m)},[u,c]);return w.useLayoutEffect(()=>a.listen(p),[a,p]),w.useEffect(()=>lg(r),[r]),w.createElement(ig,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:a,future:r})}const gg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",vg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,De=w.forwardRef(function(t,n){let{onClick:r,relative:l,reloadDocument:s,replace:a,state:o,target:u,to:c,preventScrollReset:p,viewTransition:m}=t,g=hf(t,cg),{basename:v}=w.useContext(dt),x,j=!1;if(typeof c=="string"&&vg.test(c)&&(x=c,gg))try{let h=new URL(window.location.href),y=c.startsWith("//")?new URL(h.protocol+c):new URL(c),S=Mn(y.pathname,v);y.origin===h.origin&&S!=null?c=S+y.search+y.hash:j=!0}catch{}let N=Bm(c,{relative:l}),f=xg(c,{replace:a,state:o,target:u,preventScrollReset:p,relative:l,viewTransition:m});function d(h){r&&r(h),h.defaultPrevented||f(h)}return w.createElement("a",Hl({},g,{href:x||N,onClick:j||s?r:d,ref:n,target:u}))}),xl=w.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:l=!1,className:s="",end:a=!1,style:o,to:u,viewTransition:c,children:p}=t,m=hf(t,dg),g=hs(u,{relative:m.relative}),v=Dt(),x=w.useContext(af),{navigator:j,basename:N}=w.useContext(dt),f=x!=null&&wg(g)&&c===!0,d=j.encodeLocation?j.encodeLocation(g).pathname:g.pathname,h=v.pathname,y=x&&x.navigation&&x.navigation.location?x.navigation.location.pathname:null;l||(h=h.toLowerCase(),y=y?y.toLowerCase():null,d=d.toLowerCase()),y&&N&&(y=Mn(y,N)||y);const S=d!=="/"&&d.endsWith("/")?d.length-1:d.length;let E=h===d||!a&&h.startsWith(d)&&h.charAt(S)==="/",k=y!=null&&(y===d||!a&&y.startsWith(d)&&y.charAt(d.length)==="/"),C={isActive:E,isPending:k,isTransitioning:f},M=E?r:void 0,A;typeof s=="function"?A=s(C):A=[s,E?"active":null,k?"pending":null,f?"transitioning":null].filter(Boolean).join(" ");let O=typeof o=="function"?o(C):o;return w.createElement(De,Hl({},m,{"aria-current":M,className:A,ref:n,style:O,to:u,viewTransition:c}),typeof p=="function"?p(C):p)});var ea;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(ea||(ea={}));var Lu;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Lu||(Lu={}));function yg(e){let t=w.useContext(fs);return t||K(!1),t}function xg(e,t){let{target:n,replace:r,state:l,preventScrollReset:s,relative:a,viewTransition:o}=t===void 0?{}:t,u=Ft(),c=Dt(),p=hs(e,{relative:a});return w.useCallback(m=>{if(og(m,n)){m.preventDefault();let g=r!==void 0?r:Vl(c)===Vl(p);u(e,{replace:g,state:l,preventScrollReset:s,relative:a,viewTransition:o})}},[c,u,p,r,l,n,e,s,a,o])}function lo(e){let t=w.useRef(Zi(e)),n=w.useRef(!1),r=Dt(),l=w.useMemo(()=>ug(r.search,n.current?null:t.current),[r.search]),s=Ft(),a=w.useCallback((o,u)=>{const c=Zi(typeof o=="function"?o(l):o);n.current=!0,s("?"+c,u)},[s,l]);return[l,a]}function wg(e,t){t===void 0&&(t={});let n=w.useContext(pg);n==null&&K(!1);let{basename:r}=yg(ea.useViewTransitionState),l=hs(e,{relative:t.relative});if(!n.isTransitioning)return!1;let s=Mn(n.currentLocation.pathname,r)||n.currentLocation.pathname,a=Mn(n.nextLocation.pathname,r)||n.nextLocation.pathname;return qi(l.pathname,a)!=null||qi(l.pathname,s)!=null}const Tr="https://api.monespacepro.eu",ms="mep.admin.refresh",so="mep.admin.kind";let Lt=null,mf=()=>{};class gs extends Error{constructor(t,n){super(n),this.status=t}}function ta(e){return e?`${Tr}${e}`:null}function jg(e){mf=e}function Sg(){try{return localStorage.getItem(ms)?localStorage.getItem(so)==="staff"?"staff":"admin":null}catch{return null}}function io(e,t){Lt=e.accessToken;try{localStorage.setItem(ms,e.refreshToken),t&&localStorage.setItem(so,t)}catch{}}function ao(){Lt=null;try{localStorage.removeItem(ms),localStorage.removeItem(so)}catch{}mf()}async function Ng(e,t){const n=await rt("POST","/api/auth/admin/login",{email:e,password:t},!1);io(n,"admin")}async function Cg(e,t){const n=await rt("POST","/api/auth/staff/login",{email:e,password:t},!1);io(n,"staff")}const Au={get:e=>rt("GET",e,void 0,!1),post:(e,t)=>rt("POST",e,t,!1)};let Gs=null;async function Ql(){let e=null;try{e=localStorage.getItem(ms)}catch{}return e?(Gs??(Gs=fetch(`${Tr}/api/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:e})}).then(async t=>t.ok?(io(await t.json()),!0):!1).catch(()=>!1).finally(()=>{Gs=null})),Gs):!1}async function rt(e,t,n,r=!0,l=!0){r&&!Lt&&await Ql();const s=n instanceof FormData,a=await fetch(`${Tr}${t}`,{method:e,headers:{...n!==void 0&&!s&&{"Content-Type":"application/json"},...r&&Lt&&{Authorization:`Bearer ${Lt}`}},body:n===void 0?void 0:s?n:JSON.stringify(n)});if(a.status===401&&r){if(l&&await Ql())return rt(e,t,n,r,!1);ao()}if(!a.ok){const u=await a.json().catch(()=>({})),c=Array.isArray(u.message)?u.message.join(" · "):u.message;throw new gs(a.status,c||"Une erreur est survenue")}const o=await a.text();return o?JSON.parse(o):null}async function na(e,t){Lt||await Ql();let n=await fetch(`${Tr}${e}`,{headers:{Authorization:`Bearer ${Lt}`}});if(n.status===401&&await Ql()&&(n=await fetch(`${Tr}${e}`,{headers:{Authorization:`Bearer ${Lt}`}})),!n.ok)throw new gs(n.status,"Téléchargement impossible");const r=URL.createObjectURL(await n.blob());Object.assign(document.createElement("a"),{href:r,download:t}).click(),setTimeout(()=>URL.revokeObjectURL(r),1e4)}const U={get:e=>rt("GET",e),post:(e,t)=>rt("POST",e,t??{}),put:(e,t)=>rt("PUT",e,t),patch:(e,t)=>rt("PATCH",e,t)},ut={ESSENTIEL:"Essentiel",PRO:"Pro",RESEAU:"Réseau"};function Eg({size:e=32}){return i.jsxs("svg",{width:e,height:e,viewBox:"0.5 -2 64 64","aria-hidden":"true",children:[i.jsx("path",{d:"M12 54V32a9 9 0 0 1 18 0v22M30 32a9 9 0 0 1 18 0v22",fill:"none",stroke:"var(--brand-arch)",strokeWidth:"8"}),i.jsx("circle",{cx:"51",cy:"12",r:"6",fill:"#F2B544"})]})}function Dr({admin:e=!0}){return i.jsxs("div",{className:"brand",children:[i.jsx(Eg,{}),i.jsxs("span",{className:"brand-name",children:["MonEspace",i.jsx("b",{children:"Pro"})]}),e&&i.jsx("span",{className:"badge DRAFT",style:{marginLeft:"auto",height:22},children:"Admin"})]})}function kg(){return i.jsxs("div",{className:"shell",children:[i.jsxs("aside",{className:"sidebar",children:[i.jsx(Dr,{}),i.jsx("nav",{"aria-label":"Navigation principale",children:i.jsx(xl,{to:"/magasins",children:"Magasins"})}),i.jsx("div",{className:"bottom",children:i.jsx("button",{type:"button",className:"btn secondary small",onClick:ao,children:"Se déconnecter"})})]}),i.jsx("main",{className:"main",children:i.jsx("div",{className:"container",children:i.jsx(sg,{})})})]})}const gf={DRAFT:"Brouillon",ACTIVE:"Actif",SUSPENDED:"Suspendu",CLOSED:"Fermé"};function vf({status:e}){return i.jsx("span",{className:`badge ${e}`,children:gf[e]})}function Pg({onLogin:e}){const t=Ft(),[n,r]=w.useState(""),[l,s]=w.useState(""),[a,o]=w.useState(null),[u,c]=w.useState(!1);async function p(m){m.preventDefault(),c(!0),o(null);try{await Ng(n,l),e(),t("/magasins")}catch(g){o(g.message)}finally{c(!1)}}return i.jsx("main",{style:{minHeight:"100vh",display:"grid",placeItems:"center",padding:16},children:i.jsxs("form",{className:"card",onSubmit:p,style:{width:"100%",maxWidth:420,display:"flex",flexDirection:"column",gap:20},children:[i.jsx(Dr,{}),i.jsxs("div",{children:[i.jsx("h1",{style:{fontSize:26},children:"Connexion"}),i.jsx("p",{className:"muted",style:{margin:0},children:"Espace d'administration MonEspacePro"})]}),a&&i.jsx("div",{className:"alert error",role:"alert",children:a}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"email",children:"E-mail"}),i.jsx("input",{id:"email",className:"input",type:"email",autoComplete:"username",required:!0,value:n,onChange:m=>r(m.target.value)})]}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"password",children:"Mot de passe"}),i.jsx("input",{id:"password",className:"input",type:"password",autoComplete:"current-password",required:!0,minLength:8,value:l,onChange:m=>s(m.target.value)})]}),i.jsx("button",{className:"btn",disabled:u,children:u?"Connexion…":"Se connecter"})]})})}const Rg=["ALL","DRAFT","ACTIVE","SUSPENDED","CLOSED"];function Tg(e){return e.split(" ").filter(t=>t.length>2).slice(-2).map(t=>t[0]).join("").toUpperCase()}function Lg(e){return e==="ACTIVE"?i.jsx("span",{style:{color:"var(--ok)",fontWeight:600},children:"Actif"}):e==="PAST_DUE"?i.jsx("span",{style:{color:"var(--err)",fontWeight:600},children:"Impayé"}):e==="INCOMPLETE"?i.jsx("span",{className:"muted",children:"En attente"}):i.jsx("span",{className:"muted",children:"—"})}function Ag(){const e=Ft(),[t,n]=w.useState(""),[r,l]=w.useState("ALL"),[s,a]=w.useState(null),[o,u]=w.useState(null);w.useEffect(()=>{const v=setTimeout(()=>{const x=new URLSearchParams;t.trim()&&x.set("q",t.trim()),r!=="ALL"&&x.set("status",r),U.get(`/api/admin/stores?${x}`).then(a).catch(j=>u(j.message))},250);return()=>clearTimeout(v)},[t,r]);const c=s?Object.values(s.counts).reduce((v,x)=>v+(x??0),0):0,p=(s==null?void 0:s.items.filter(v=>v.subscriptionStatus==="PAST_DUE").length)??0,m=(s==null?void 0:s.items.reduce((v,x)=>v+x.customers,0))??0,g=(s==null?void 0:s.counts.DRAFT)??0;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"row between",style:{alignItems:"flex-end"},children:[i.jsxs("div",{children:[i.jsx("h1",{children:"Magasins"}),i.jsxs("p",{className:"muted",style:{margin:0},children:[c," magasins inscrits"]})]}),i.jsx(De,{to:"/magasins/nouveau",className:"btn",children:"+ Nouveau magasin"})]}),i.jsxs("div",{className:"kpis",children:[i.jsxs("div",{className:"kpi ok",children:[i.jsx("b",{children:(s==null?void 0:s.counts.ACTIVE)??"—"}),i.jsx("span",{children:"magasins ouverts"})]}),i.jsxs("div",{className:`kpi${g?" warn":""}`,children:[i.jsx("b",{children:s?g:"—"}),i.jsx("span",{children:"en cours d’ouverture"})]}),i.jsxs("div",{className:`kpi${p?" err":""}`,children:[i.jsx("b",{children:s?p:"—"}),i.jsx("span",{children:"abonnements impayés"})]}),i.jsxs("div",{className:"kpi",children:[i.jsx("b",{children:s?m.toLocaleString("fr-FR"):"—"}),i.jsx("span",{children:"cartes clients"})]})]}),i.jsxs("div",{className:"row",children:[i.jsxs("div",{style:{flex:"1 1 320px",maxWidth:420},children:[i.jsx("label",{htmlFor:"search",className:"sr-only",children:"Rechercher un magasin"}),i.jsx("input",{id:"search",type:"search",className:"input",placeholder:"Rechercher par nom ou ville",value:t,onChange:v=>n(v.target.value)})]}),i.jsx("div",{role:"group","aria-label":"Filtrer par statut",className:"row",style:{gap:8},children:Rg.map(v=>i.jsxs("button",{type:"button",className:"chip","aria-pressed":r===v,onClick:()=>l(v),children:[v==="ALL"?"Tous":gf[v],i.jsx("span",{style:{opacity:.8,fontWeight:500},children:v==="ALL"?c:(s==null?void 0:s.counts[v])??0})]},v))})]}),o&&i.jsx("div",{className:"alert error",children:o}),i.jsxs("div",{className:"table-wrap",children:[i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{style:{minWidth:860},children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{scope:"col",style:{paddingLeft:24},children:"Magasin"}),i.jsx("th",{scope:"col",children:"Ville"}),i.jsx("th",{scope:"col",children:"Statut"}),i.jsx("th",{scope:"col",className:"num",children:"Clients"}),i.jsx("th",{scope:"col",children:"Abonnement"}),i.jsx("th",{scope:"col",children:"Créé le"})]})}),i.jsx("tbody",{children:s==null?void 0:s.items.map(v=>i.jsxs("tr",{className:"clickable",onClick:()=>e(`/magasins/${v.id}`),children:[i.jsx("td",{style:{paddingLeft:24},children:i.jsxs(De,{to:`/magasins/${v.id}`,style:{display:"inline-flex",alignItems:"center",gap:12,color:"var(--text)",fontWeight:600,textDecoration:"none"},children:[i.jsx("span",{style:{width:36,height:36,borderRadius:10,background:"var(--primary-soft)",color:"var(--primary)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:800},children:Tg(v.name)}),v.name]})}),i.jsx("td",{children:v.city}),i.jsx("td",{children:i.jsx(vf,{status:v.status})}),i.jsx("td",{className:"num",children:v.customers}),i.jsxs("td",{children:[Lg(v.subscriptionStatus),v.plan&&i.jsxs("span",{className:"muted",style:{fontSize:14},children:[" · ",ut[v.plan]]})]}),i.jsx("td",{className:"muted",children:new Date(v.createdAt).toLocaleDateString("fr-FR",{day:"numeric",month:"short",year:"numeric"})})]},v.id))})]})}),s&&s.items.length===0&&i.jsxs("div",{style:{padding:"48px 24px",textAlign:"center"},children:[i.jsx("strong",{children:"Aucun magasin trouvé"}),i.jsx("p",{className:"muted",style:{margin:0},children:"Essayez un autre nom, une autre ville ou retirez le filtre de statut."})]})]})]})}const Mg={name:"",siret:"",addressLine:"",postalCode:"",city:"",contactName:"",contactEmail:"",contactPhone:"",maxAmountEuros:500,minScanIntervalMin:5};function yf({initial:e,submitLabel:t,onSubmit:n}){const[r,l]=w.useState(e),[s,a]=w.useState(null),[o,u]=w.useState(!1),c=g=>v=>l(x=>({...x,[g]:typeof x[g]=="number"?Number(v.target.value):v.target.value}));async function p(g){g.preventDefault(),u(!0),a(null);try{await n(r)}catch(v){a(v.message)}finally{u(!1)}}const m=(g,v,x={})=>i.jsxs("div",{className:"field",children:[i.jsxs("label",{htmlFor:g,children:[v," *"]}),i.jsx("input",{id:g,className:"input",required:!0,value:r[g],onChange:c(g),...x})]});return i.jsxs("form",{onSubmit:p,style:{display:"flex",flexDirection:"column",gap:24},children:[i.jsx("p",{className:"muted",style:{margin:0},children:"Les champs marqués d'un astérisque (*) sont obligatoires."}),s&&i.jsx("div",{className:"alert error",role:"alert",children:s}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:20},children:[i.jsx("h2",{children:"Commerce"}),i.jsxs("div",{className:"grid-2",children:[m("name","Nom du magasin"),m("siret","SIRET",{placeholder:"14 chiffres",inputMode:"numeric",pattern:"[0-9 ]{14,17}"})]}),m("addressLine","Adresse",{placeholder:"Numéro et nom de rue"}),i.jsxs("div",{className:"grid-2",children:[m("postalCode","Code postal",{placeholder:"5 chiffres",inputMode:"numeric",pattern:"[0-9]{5}"}),m("city","Ville")]})]}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:20},children:[i.jsx("h2",{children:"Contact"}),m("contactName","Nom du contact",{placeholder:"Prénom Nom"}),i.jsxs("div",{className:"grid-2",children:[m("contactEmail","E-mail",{type:"email",placeholder:"contact@exemple.fr"}),m("contactPhone","Téléphone",{type:"tel",placeholder:"06 12 34 56 78"})]})]}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:20},children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Anti-triche"}),i.jsx("p",{className:"muted",style:{margin:0},children:"Limitent les crédits abusifs. Une opération hors limites est refusée et apparaît dans l'onglet Opérations."})]}),i.jsxs("div",{className:"grid-2",children:[i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"maxAmountEuros",children:"Plafond par opération (€) *"}),i.jsx("input",{id:"maxAmountEuros",className:"input",type:"number",min:1,max:1e4,required:!0,value:r.maxAmountEuros,onChange:c("maxAmountEuros")})]}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"minScanIntervalMin",children:"Délai minimum entre deux crédits (min) *"}),i.jsx("input",{id:"minScanIntervalMin",className:"input",type:"number",min:0,max:1440,required:!0,value:r.minScanIntervalMin,onChange:c("minScanIntervalMin")})]})]})]}),i.jsx("div",{children:i.jsx("button",{className:"btn",disabled:o,children:o?"Enregistrement…":t})})]})}function _g(){const e=Ft(),[t,n]=w.useState("PRO"),[r,l]=w.useState("MONTH"),[s,a]=w.useState(null);return s?i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx(De,{to:"/magasins",children:"← Magasins"}),i.jsxs("h1",{children:[s.name," est créé"]})]}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:12},children:[s.link.emailedTo?i.jsxs("div",{className:"alert ok",children:["Lien de paiement (formule ",ut[t],", ",r==="YEAR"?"annuelle":"mensuelle",") envoyé à ",i.jsx("strong",{children:s.link.emailedTo}),s.manager&&", avec ses identifiants Dirigeant",". Le magasin s'ouvrira automatiquement dès le paiement validé et la carte conçue."]}):i.jsxs("div",{className:"alert warn",children:["Le lien de paiement n'a pas pu être envoyé : ",s.link.error,". Renvoyez-le depuis l'onglet Facturation."]}),s.manager?i.jsxs(i.Fragment,{children:[i.jsxs("p",{style:{margin:0},children:["Compte Dirigeant : ",i.jsx("strong",{children:s.manager.email}),", mot de passe provisoire :"]}),i.jsx("div",{className:"password-box",children:s.manager.provisionalPassword})]}):i.jsx("div",{className:"alert warn",children:"Un compte existe déjà avec l'e-mail du contact : créez le Dirigeant à la main dans l'onglet Employés."}),i.jsx("div",{className:"row",style:{justifyContent:"flex-end"},children:i.jsx("button",{className:"btn",onClick:()=>e(`/magasins/${s.id}/carte`),children:"Concevoir la carte"})})]})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{children:[i.jsx(De,{to:"/magasins",children:"← Magasins"}),i.jsx("h1",{children:"Nouveau magasin"}),i.jsx("p",{className:"muted",style:{margin:0},children:"À la création, le contact reçoit automatiquement par e-mail le lien de paiement de la formule choisie et ses identifiants Dirigeant."})]}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:16},children:[i.jsx("h2",{children:"Formule *"}),i.jsx("div",{role:"radiogroup","aria-label":"Formule",className:"row",style:{gap:8},children:["ESSENTIEL","PRO","RESEAU"].map(o=>i.jsx("button",{type:"button",className:"chip",role:"radio","aria-checked":t===o,"aria-pressed":t===o,onClick:()=>n(o),children:ut[o]},o))}),i.jsxs("div",{role:"radiogroup","aria-label":"Périodicité",className:"row",style:{gap:8},children:[i.jsx("button",{type:"button",className:"chip",role:"radio","aria-checked":r==="MONTH","aria-pressed":r==="MONTH",onClick:()=>l("MONTH"),children:"Mensuel"}),i.jsx("button",{type:"button",className:"chip",role:"radio","aria-checked":r==="YEAR","aria-pressed":r==="YEAR",onClick:()=>l("YEAR"),children:"Annuel — 2 mois offerts"})]})]}),i.jsx(yf,{initial:Mg,submitLabel:"Créer le magasin",onSubmit:async o=>{a(await U.post("/api/admin/stores",{...o,plan:t,interval:r}))}})]})}function xf({size:e}){const n=e/21,r=(s,a)=>i.jsxs("g",{children:[i.jsx("rect",{x:s*n,y:a*n,width:7*n,height:7*n,fill:"#000"}),i.jsx("rect",{x:(s+1)*n,y:(a+1)*n,width:5*n,height:5*n,fill:"#fff"}),i.jsx("rect",{x:(s+2)*n,y:(a+2)*n,width:3*n,height:3*n,fill:"#000"})]},`${s}-${a}`),l=[];for(let s=0;s<21;s++)for(let a=0;a<21;a++)!(a<8&&s<8||a>12&&s<8||a<8&&s>12)&&(a*7+s*13+a*s)%3===0&&l.push(i.jsx("rect",{x:a*n,y:s*n,width:n,height:n,fill:"#000"},`${a}.${s}`));return i.jsxs("svg",{width:e,height:e,"aria-hidden":"true",children:[i.jsx("rect",{width:e,height:e,fill:"#fff"}),r(0,0),r(14,0),r(0,14),l]})}function wf(e){return e.pointsMode==="STAMP"?{label:"TAMPONS",value:"7"}:{label:"POINTS",value:"120"}}function Kl(e){const t=e.pointsMode==="STAMP"?7:120,n=(e.rewards??[]).filter(s=>s.active!==!1&&s.label.trim()).sort((s,a)=>s.cost-a.cost);if(!n.length)return null;const r=n.filter(s=>s.cost<=t);if(r.length)return`${r[r.length-1].label} : disponible !`;const l=n[0].cost-t;return`${n[0].label} : encore ${l} ${e.pointsMode==="STAMP"?"tampon":"point"}${l>1?"s":""}`}function zg({d:e}){const t=wf(e);return i.jsxs("div",{style:{width:320,borderRadius:14,overflow:"hidden",background:e.backgroundColor,color:e.foregroundColor,boxShadow:"0 12px 32px rgb(0 0 0 / 0.25)",fontFamily:"-apple-system, system-ui, sans-serif"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 14px",height:50},children:[e.logoUrl?i.jsx("img",{src:e.logoUrl,alt:"",style:{maxHeight:34,maxWidth:140,objectFit:"contain"}}):i.jsx("span",{style:{fontWeight:700},children:e.storeName}),i.jsxs("div",{style:{textAlign:"right"},children:[i.jsx("div",{style:{fontSize:10,fontWeight:600,color:e.labelColor},children:t.label}),i.jsx("div",{style:{fontSize:18},children:t.value})]})]}),i.jsx("div",{style:{position:"relative",height:123,background:e.stripUrl?`center/cover url(${e.stripUrl})`:"rgb(255 255 255 / 0.08)"},children:i.jsxs("div",{style:{position:"absolute",left:14,bottom:10},children:[i.jsx("div",{style:{fontSize:11,fontWeight:600,color:e.labelColor,textShadow:e.stripUrl?"0 1px 2px rgb(0 0 0 / 0.5)":void 0},children:"SOLDE"}),i.jsx("div",{style:{fontSize:36,lineHeight:1,textShadow:e.stripUrl?"0 1px 3px rgb(0 0 0 / 0.5)":void 0},children:t.value})]})}),i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",padding:"10px 14px"},children:[i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:10,fontWeight:600,color:e.labelColor},children:"PROGRAMME"}),i.jsx("div",{style:{fontSize:14},children:e.programName||"—"})]}),i.jsxs("div",{style:{textAlign:"right"},children:[i.jsx("div",{style:{fontSize:10,fontWeight:600,color:e.labelColor},children:"MEMBRE"}),i.jsx("div",{style:{fontSize:14},children:"Camille"})]})]}),Kl(e)&&i.jsxs("div",{style:{padding:"0 14px 6px"},children:[i.jsx("div",{style:{fontSize:10,fontWeight:600,color:e.labelColor},children:"PROCHAINE RÉCOMPENSE"}),i.jsx("div",{style:{fontSize:14},children:Kl(e)})]}),i.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"14px 0 20px"},children:i.jsx("div",{style:{background:"#fff",padding:8,borderRadius:6},children:i.jsx(xf,{size:120})})})]})}function Ig({d:e}){const t=wf(e);return i.jsxs("div",{style:{width:320,borderRadius:20,overflow:"hidden",background:e.backgroundColor,color:e.foregroundColor,boxShadow:"0 12px 32px rgb(0 0 0 / 0.25)",fontFamily:"Roboto, system-ui, sans-serif"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 16px"},children:[i.jsx("span",{style:{width:32,height:32,borderRadius:"50%",background:"#fff",overflow:"hidden",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:e.logoUrl&&i.jsx("img",{src:e.logoUrl,alt:"",style:{width:"100%",height:"100%",objectFit:"contain"}})}),i.jsx("span",{style:{fontSize:14},children:e.storeName})]}),i.jsx("div",{style:{padding:"0 16px 12px",fontSize:22},children:e.programName||"—"}),i.jsxs("div",{style:{display:"flex",gap:32,padding:"0 16px 16px"},children:[i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:11,opacity:.8},children:t.label==="POINTS"?"Points":"Tampons"}),i.jsx("div",{style:{fontSize:18},children:t.value})]}),i.jsxs("div",{children:[i.jsx("div",{style:{fontSize:11,opacity:.8},children:"Membre"}),i.jsx("div",{style:{fontSize:18},children:"Camille"})]})]}),Kl(e)&&i.jsxs("div",{style:{padding:"0 16px 12px"},children:[i.jsx("div",{style:{fontSize:11,opacity:.8},children:"Prochaine récompense"}),i.jsx("div",{style:{fontSize:15},children:Kl(e)})]}),i.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"8px 0 16px"},children:i.jsx("div",{style:{background:"#fff",padding:10,borderRadius:12},children:i.jsx(xf,{size:120})})}),e.stripUrl&&i.jsx("img",{src:e.stripUrl,alt:"",style:{display:"block",width:"100%",aspectRatio:"1125 / 432",objectFit:"cover"}})]})}var Fr={},Dg=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},jf={},Re={};let oo;const Fg=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];Re.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};Re.getSymbolTotalCodewords=function(t){return Fg[t]};Re.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};Re.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');oo=t};Re.isKanjiModeEnabled=function(){return typeof oo<"u"};Re.toSJIS=function(t){return oo(t)};var vs={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(n){if(typeof n!="string")throw new Error("Param is not a string");switch(n.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+n)}}e.isValid=function(r){return r&&typeof r.bit<"u"&&r.bit>=0&&r.bit<4},e.from=function(r,l){if(e.isValid(r))return r;try{return t(r)}catch{return l}}})(vs);function Sf(){this.buffer=[],this.length=0}Sf.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let n=0;n>>t-n-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var Ug=Sf;function Ur(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}Ur.prototype.set=function(e,t,n,r){const l=e*this.size+t;this.data[l]=n,r&&(this.reservedBit[l]=!0)};Ur.prototype.get=function(e,t){return this.data[e*this.size+t]};Ur.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n};Ur.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var Og=Ur,Nf={};(function(e){const t=Re.getSymbolSize;e.getRowColCoords=function(r){if(r===1)return[];const l=Math.floor(r/7)+2,s=t(r),a=s===145?26:Math.ceil((s-13)/(2*l-2))*2,o=[s-7];for(let u=1;u=0&&l<=7},e.from=function(l){return e.isValid(l)?parseInt(l,10):void 0},e.getPenaltyN1=function(l){const s=l.size;let a=0,o=0,u=0,c=null,p=null;for(let m=0;m=5&&(a+=t.N1+(o-5)),c=v,o=1),v=l.get(g,m),v===p?u++:(u>=5&&(a+=t.N1+(u-5)),p=v,u=1)}o>=5&&(a+=t.N1+(o-5)),u>=5&&(a+=t.N1+(u-5))}return a},e.getPenaltyN2=function(l){const s=l.size;let a=0;for(let o=0;o=10&&(o===1488||o===93)&&a++,u=u<<1&2047|l.get(p,c),p>=10&&(u===1488||u===93)&&a++}return a*t.N3},e.getPenaltyN4=function(l){let s=0;const a=l.data.length;for(let u=0;u=0;){const a=s[0];for(let u=0;u0){const s=new Uint8Array(this.degree);return s.set(r,l),s}return r};var Bg=uo,Rf={},Ut={},co={};co.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var Je={};const Tf="[0-9]+",bg="[A-Z $%*+\\-./:]+";let Lr="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Lr=Lr.replace(/u/g,"\\u");const Wg="(?:(?![A-Z0-9 $%*+\\-./:]|"+Lr+`)(?:.|[\r ]))+`;Je.KANJI=new RegExp(Lr,"g");Je.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");Je.BYTE=new RegExp(Wg,"g");Je.NUMERIC=new RegExp(Tf,"g");Je.ALPHANUMERIC=new RegExp(bg,"g");const Vg=new RegExp("^"+Lr+"$"),Hg=new RegExp("^"+Tf+"$"),Qg=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");Je.testKanji=function(t){return Vg.test(t)};Je.testNumeric=function(t){return Hg.test(t)};Je.testAlphanumeric=function(t){return Qg.test(t)};(function(e){const t=co,n=Je;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(s,a){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!t.isValid(a))throw new Error("Invalid version: "+a);return a>=1&&a<10?s.ccBits[0]:a<27?s.ccBits[1]:s.ccBits[2]},e.getBestModeForData=function(s){return n.testNumeric(s)?e.NUMERIC:n.testAlphanumeric(s)?e.ALPHANUMERIC:n.testKanji(s)?e.KANJI:e.BYTE},e.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},e.isValid=function(s){return s&&s.bit&&s.ccBits};function r(l){if(typeof l!="string")throw new Error("Param is not a string");switch(l.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+l)}}e.from=function(s,a){if(e.isValid(s))return s;try{return r(s)}catch{return a}}})(Ut);(function(e){const t=Re,n=ys,r=vs,l=Ut,s=co,a=7973,o=t.getBCHDigit(a);function u(g,v,x){for(let j=1;j<=40;j++)if(v<=e.getCapacity(j,x,g))return j}function c(g,v){return l.getCharCountIndicator(g,v)+4}function p(g,v){let x=0;return g.forEach(function(j){const N=c(j.mode,v);x+=N+j.getBitsLength()}),x}function m(g,v){for(let x=1;x<=40;x++)if(p(g,x)<=e.getCapacity(x,v,l.MIXED))return x}e.from=function(v,x){return s.isValid(v)?parseInt(v,10):x},e.getCapacity=function(v,x,j){if(!s.isValid(v))throw new Error("Invalid QR Code version");typeof j>"u"&&(j=l.BYTE);const N=t.getSymbolTotalCodewords(v),f=n.getTotalCodewordsCount(v,x),d=(N-f)*8;if(j===l.MIXED)return d;const h=d-c(j,v);switch(j){case l.NUMERIC:return Math.floor(h/10*3);case l.ALPHANUMERIC:return Math.floor(h/11*2);case l.KANJI:return Math.floor(h/13);case l.BYTE:default:return Math.floor(h/8)}},e.getBestVersionForData=function(v,x){let j;const N=r.from(x,r.M);if(Array.isArray(v)){if(v.length>1)return m(v,N);if(v.length===0)return 1;j=v[0]}else j=v;return u(j.mode,j.getLength(),N)},e.getEncodedBits=function(v){if(!s.isValid(v)||v<7)throw new Error("Invalid QR Code version");let x=v<<12;for(;t.getBCHDigit(x)-o>=0;)x^=a<=0;)l^=Af<0&&(r=this.data.substr(n),l=parseInt(r,10),t.put(l,s*3+1))};var Gg=_n;const qg=Ut,qs=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function zn(e){this.mode=qg.ALPHANUMERIC,this.data=e}zn.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};zn.prototype.getLength=function(){return this.data.length};zn.prototype.getBitsLength=function(){return zn.getBitsLength(this.data.length)};zn.prototype.write=function(t){let n;for(n=0;n+2<=this.data.length;n+=2){let r=qs.indexOf(this.data[n])*45;r+=qs.indexOf(this.data[n+1]),t.put(r,11)}this.data.length%2&&t.put(qs.indexOf(this.data[n]),6)};var Jg=zn;const Xg=Ut;function In(e){this.mode=Xg.BYTE,typeof e=="string"?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}In.getBitsLength=function(t){return t*8};In.prototype.getLength=function(){return this.data.length};In.prototype.getBitsLength=function(){return In.getBitsLength(this.data.length)};In.prototype.write=function(e){for(let t=0,n=this.data.length;t=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+` Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}};var nv=Dn,_f={exports:{}};(function(e){var t={single_source_shortest_paths:function(n,r,l){var s={},a={};a[r]=0;var o=t.PriorityQueue.make();o.push(r,0);for(var u,c,p,m,g,v,x,j,N;!o.empty();){u=o.pop(),c=u.value,m=u.cost,g=n[c]||{};for(p in g)g.hasOwnProperty(p)&&(v=g[p],x=m+v,j=a[p],N=typeof a[p]>"u",(N||j>x)&&(a[p]=x,o.push(p,x),s[p]=c))}if(typeof l<"u"&&typeof a[l]>"u"){var f=["Could not find a path from ",r," to ",l,"."].join("");throw new Error(f)}return s},extract_shortest_path_from_predecessor_list:function(n,r){for(var l=[],s=r;s;)l.push(s),n[s],s=n[s];return l.reverse(),l},find_path:function(n,r,l){var s=t.single_source_shortest_paths(n,r,l);return t.extract_shortest_path_from_predecessor_list(s,l)},PriorityQueue:{make:function(n){var r=t.PriorityQueue,l={},s;n=n||{};for(s in r)r.hasOwnProperty(s)&&(l[s]=r[s]);return l.queue=[],l.sorter=n.sorter||r.default_sorter,l},default_sorter:function(n,r){return n.cost-r.cost},push:function(n,r){var l={value:n,cost:r};this.queue.push(l),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(_f);var rv=_f.exports;(function(e){const t=Ut,n=Gg,r=Jg,l=Zg,s=nv,a=Je,o=Re,u=rv;function c(f){return unescape(encodeURIComponent(f)).length}function p(f,d,h){const y=[];let S;for(;(S=f.exec(h))!==null;)y.push({data:S[0],index:S.index,mode:d,length:S[0].length});return y}function m(f){const d=p(a.NUMERIC,t.NUMERIC,f),h=p(a.ALPHANUMERIC,t.ALPHANUMERIC,f);let y,S;return o.isKanjiModeEnabled()?(y=p(a.BYTE,t.BYTE,f),S=p(a.KANJI,t.KANJI,f)):(y=p(a.BYTE_KANJI,t.BYTE,f),S=[]),d.concat(h,y,S).sort(function(k,C){return k.index-C.index}).map(function(k){return{data:k.data,mode:k.mode,length:k.length}})}function g(f,d){switch(d){case t.NUMERIC:return n.getBitsLength(f);case t.ALPHANUMERIC:return r.getBitsLength(f);case t.KANJI:return s.getBitsLength(f);case t.BYTE:return l.getBitsLength(f)}}function v(f){return f.reduce(function(d,h){const y=d.length-1>=0?d[d.length-1]:null;return y&&y.mode===h.mode?(d[d.length-1].data+=h.data,d):(d.push(h),d)},[])}function x(f){const d=[];for(let h=0;h=0&&o<=6&&(u===0||u===6)||u>=0&&u<=6&&(o===0||o===6)||o>=2&&o<=4&&u>=2&&u<=4?e.set(s+o,a+u,!0,!0):e.set(s+o,a+u,!1,!0))}}function fv(e){const t=e.size;for(let n=8;n>o&1)===1,e.set(l,s,a,!0),e.set(s,l,a,!0)}function Zs(e,t,n){const r=e.size,l=uv.getEncodedBits(t,n);let s,a;for(s=0;s<15;s++)a=(l>>s&1)===1,s<6?e.set(s,8,a,!0):s<8?e.set(s+1,8,a,!0):e.set(r-15+s,8,a,!0),s<8?e.set(8,r-s-1,a,!0):s<9?e.set(8,15-s-1+1,a,!0):e.set(8,15-s-1,a,!0);e.set(r-8,8,1,!0)}function mv(e,t){const n=e.size;let r=-1,l=n-1,s=7,a=0;for(let o=n-1;o>0;o-=2)for(o===6&&o--;;){for(let u=0;u<2;u++)if(!e.isReserved(l,o-u)){let c=!1;a>>s&1)===1),e.set(l,o-u,c),s--,s===-1&&(a++,s=7)}if(l+=r,l<0||n<=l){l-=r,r=-r;break}}}function gv(e,t,n){const r=new lv;n.forEach(function(u){r.put(u.mode.bit,4),r.put(u.getLength(),cv.getCharCountIndicator(u.mode,e)),u.write(r)});const l=ws.getSymbolTotalCodewords(e),s=sa.getTotalCodewordsCount(e,t),a=(l-s)*8;for(r.getLengthInBits()+4<=a&&r.put(0,4);r.getLengthInBits()%8!==0;)r.putBit(0);const o=(a-r.getLengthInBits())/8;for(let u=0;u=7&&hv(u,t),mv(u,a),isNaN(r)&&(r=la.getBestMask(u,Zs.bind(null,u,n))),la.applyMask(r,u),Zs(u,n,r),{modules:u,version:t,errorCorrectionLevel:n,maskPattern:r,segments:l}}jf.create=function(t,n){if(typeof t>"u"||t==="")throw new Error("No input text");let r=Js.M,l,s;return typeof n<"u"&&(r=Js.from(n.errorCorrectionLevel,Js.M),l=Gl.from(n.version),s=la.from(n.maskPattern),n.toSJISFunc&&ws.setToSJISFunction(n.toSJISFunc)),yv(t,l,r,s)};var zf={},fo={};(function(e){function t(n){if(typeof n=="number"&&(n=n.toString()),typeof n!="string")throw new Error("Color should be defined as hex string");let r=n.slice().replace("#","").split("");if(r.length<3||r.length===5||r.length>8)throw new Error("Invalid hex color: "+n);(r.length===3||r.length===4)&&(r=Array.prototype.concat.apply([],r.map(function(s){return[s,s]}))),r.length===6&&r.push("F","F");const l=parseInt(r.join(""),16);return{r:l>>24&255,g:l>>16&255,b:l>>8&255,a:l&255,hex:"#"+r.slice(0,6).join("")}}e.getOptions=function(r){r||(r={}),r.color||(r.color={});const l=typeof r.margin>"u"||r.margin===null||r.margin<0?4:r.margin,s=r.width&&r.width>=21?r.width:void 0,a=r.scale||4;return{width:s,scale:s?4:a,margin:l,color:{dark:t(r.color.dark||"#000000ff"),light:t(r.color.light||"#ffffffff")},type:r.type,rendererOpts:r.rendererOpts||{}}},e.getScale=function(r,l){return l.width&&l.width>=r+l.margin*2?l.width/(r+l.margin*2):l.scale},e.getImageWidth=function(r,l){const s=e.getScale(r,l);return Math.floor((r+l.margin*2)*s)},e.qrToImageData=function(r,l,s){const a=l.modules.size,o=l.modules.data,u=e.getScale(a,s),c=Math.floor((a+s.margin*2)*u),p=s.margin*u,m=[s.color.light,s.color.dark];for(let g=0;g=p&&v>=p&&g"u"&&(!a||!a.getContext)&&(u=a,a=void 0),a||(c=r()),u=t.getOptions(u);const p=t.getImageWidth(s.modules.size,u),m=c.getContext("2d"),g=m.createImageData(p,p);return t.qrToImageData(g.data,s,u),n(m,c,p),m.putImageData(g,0,0),c},e.renderToDataURL=function(s,a,o){let u=o;typeof u>"u"&&(!a||!a.getContext)&&(u=a,a=void 0),u||(u={});const c=e.render(s,a,u),p=u.type||"image/png",m=u.rendererOpts||{};return c.toDataURL(p,m.quality)}})(zf);var If={};const xv=fo;function zu(e,t){const n=e.a/255,r=t+'="'+e.hex+'"';return n<1?r+" "+t+'-opacity="'+n.toFixed(2).slice(1)+'"':r}function ei(e,t,n){let r=e+t;return typeof n<"u"&&(r+=" "+n),r}function wv(e,t,n){let r="",l=0,s=!1,a=0;for(let o=0;o0&&u>0&&e[o-1]||(r+=s?ei("M",u+n,.5+c+n):ei("m",l,0),l=0,s=!1),u+1':"",c="',p='viewBox="0 0 '+o+" "+o+'"',g=''+u+c+` `;return typeof r=="function"&&r(null,g),g};const jv=Dg,ia=jf,Df=zf,Sv=If;function po(e,t,n,r,l){const s=[].slice.call(arguments,1),a=s.length,o=typeof s[a-1]=="function";if(!o&&!jv())throw new Error("Callback required as last argument");if(o){if(a<2)throw new Error("Too few arguments provided");a===2?(l=n,n=t,t=r=void 0):a===3&&(t.getContext&&typeof l>"u"?(l=r,r=void 0):(l=r,r=n,n=t,t=void 0))}else{if(a<1)throw new Error("Too few arguments provided");return a===1?(n=t,t=r=void 0):a===2&&!t.getContext&&(r=n,n=t,t=void 0),new Promise(function(u,c){try{const p=ia.create(n,r);u(e(p,t,r))}catch(p){c(p)}})}try{const u=ia.create(n,r);l(null,e(u,t,r))}catch(u){l(u)}}Fr.create=ia.create;Fr.toCanvas=po.bind(null,Df.render);Fr.toDataURL=po.bind(null,Df.renderToDataURL);Fr.toString=po.bind(null,function(e,t,n){return Sv.render(e,n)});const Nv={A5:{w:148,h:210,pad:12,logo:14,store:6,eyebrow:3.8,title:10,qr:66,qrWithRewards:50,body:4.5,small:4,maxRewards:4},A6:{w:105,h:148,pad:8,logo:10,store:4.5,eyebrow:3,title:7,qr:46,qrWithRewards:34,body:3.4,small:3.1,maxRewards:3}};function Ff(e){const t=Nv[e.format],n=(e.rewards??[]).filter(c=>c.active!==!1&&c.label.trim()).sort((c,p)=>c.cost-p.cost),r=n.slice(0,t.maxRewards),l=e.pointsMode==="STAMP"?"tampons":"points",s=r.length?t.qrWithRewards:t.qr,[a,o]=w.useState("");w.useEffect(()=>{Fr.toString(e.url,{type:"svg",errorCorrectionLevel:"Q",margin:0,color:{dark:"#111111",light:"#FFFFFF"}}).then(o)},[e.url]);const u=c=>`${c}mm`;return i.jsxs("div",{className:"poster",style:{width:u(t.w),height:u(t.h),padding:u(t.pad),boxSizing:"border-box",background:e.backgroundColor,color:e.foregroundColor,fontFamily:"'Figtree', system-ui, sans-serif",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"space-between",textAlign:"center",overflow:"hidden",printColorAdjust:"exact",WebkitPrintColorAdjust:"exact"},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:u(3)},children:[e.logoUrl&&i.jsx("img",{src:e.logoUrl,alt:"",style:{width:u(t.logo),height:u(t.logo),objectFit:"contain",borderRadius:u(2.5),background:"#fff"}}),i.jsx("span",{style:{fontSize:u(t.store),fontWeight:700},children:e.storeName})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:u(2.5)},children:[i.jsx("span",{style:{fontSize:u(t.eyebrow),fontWeight:700,letterSpacing:"0.1em",textTransform:"uppercase",color:e.labelColor},children:e.programName}),i.jsx("span",{style:{fontSize:u(t.title),lineHeight:1.12,fontWeight:800,letterSpacing:"-0.02em",maxWidth:"92%"},children:"Scannez pour obtenir votre carte de fidélité"})]}),i.jsx("div",{role:"img","aria-label":"QR code d'inscription",style:{background:"#fff",borderRadius:u(3.5),padding:u(4),width:u(s),height:u(s),boxSizing:"content-box"},dangerouslySetInnerHTML:{__html:a}}),r.length>0&&i.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:u(1.6)},children:[i.jsx("span",{style:{fontSize:u(t.small),fontWeight:700,letterSpacing:"0.1em",textTransform:"uppercase",color:e.labelColor},children:"Vos récompenses"}),i.jsx("ul",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:u(1.2)},children:r.map(c=>i.jsxs("li",{style:{display:"flex",justifyContent:"space-between",alignItems:"baseline",gap:u(3),padding:`${u(1.4)} ${u(3)}`,borderRadius:u(2.5),background:"rgba(255,255,255,0.12)",fontSize:u(t.body),lineHeight:1.25},children:[i.jsx("span",{style:{fontWeight:700,textAlign:"left"},children:c.label}),i.jsxs("span",{style:{whiteSpace:"nowrap",color:e.labelColor,fontWeight:600},children:[c.cost," ",l]})]},`${c.label}-${c.cost}`))}),n.length>r.length&&i.jsxs("span",{style:{fontSize:u(t.small),color:e.labelColor},children:["et ",n.length-r.length," autre(s) à découvrir sur votre carte"]})]}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:u(1.5)},children:[i.jsx("span",{style:{fontSize:u(t.body),lineHeight:1.4,fontWeight:600},children:"Ajoutez-la à Apple Wallet ou Google Wallet."}),i.jsx("span",{style:{fontSize:u(t.small),lineHeight:1.4,color:e.labelColor},children:"Gratuit, sans application à télécharger."})]})]})}function Uf(e){return new Promise((t,n)=>{const r=URL.createObjectURL(e),l=new Image;l.onload=()=>{URL.revokeObjectURL(r),t(l)},l.onerror=()=>n(new Error("Image illisible")),l.src=r})}function Of(e){return new Promise((t,n)=>e.toBlob(r=>r?t(r):n(new Error("Conversion impossible")),"image/png"))}async function Cv(e){const t=await Uf(e),n=1125,r=432,l=Math.max(n/t.width,r/t.height),s=n/l,a=r/l,o=Object.assign(document.createElement("canvas"),{width:n,height:r});return o.getContext("2d").drawImage(t,(t.width-s)/2,(t.height-a)/2,s,a,0,0,n,r),Of(o)}async function Ev(e){const t=await Uf(e),n=Math.min(1,480/Math.max(t.width,t.height)),r=Object.assign(document.createElement("canvas"),{width:Math.round(t.width*n),height:Math.round(t.height*n)});return r.getContext("2d").drawImage(t,0,0,r.width,r.height),Of(r)}async function kv(e){const t=new Image;t.crossOrigin="anonymous",t.src=e;try{await t.decode()}catch{return null}const r=Object.assign(document.createElement("canvas"),{width:48,height:48}).getContext("2d");r.drawImage(t,0,0,48,48);let l;try{l=r.getImageData(0,0,48,48).data}catch{return null}const s=new Map;for(let u=0;u235&&p>235&&m>235)continue;const v=`${c>>5}${p>>5}${m>>5}`,x=s.get(v)??{n:0,r:0,g:0,b:0};s.set(v,{n:x.n+1,r:x.r+c,g:x.g+p,b:x.b+m})}const a=[...s.values()].sort((u,c)=>c.n-u.n)[0];if(!a)return null;const o=u=>Math.round(u/a.n).toString(16).padStart(2,"0");return`#${o(a.r)}${o(a.g)}${o(a.b)}`.toUpperCase()}function Iu(e,t){const n=s=>{const[a,o,u]=[1,3,5].map(c=>{const p=parseInt(s.slice(c,c+2),16)/255;return p<=.03928?p/12.92:((p+.055)/1.055)**2.4});return .2126*a+.7152*o+.0722*u},[r,l]=[n(e),n(t)].sort((s,a)=>a-s);return(r+.05)/(l+.05)}const ti=["Identité","Couleurs","Règle de points","Récompenses","Récapitulatif"];function Pv(e){return{programName:`Fidélité ${e.name}`.slice(0,40),backgroundColor:"#1F2937",foregroundColor:"#FFFFFF",labelColor:"#D1D5DB",pointsMode:"AMOUNT",pointsPerEuro:1,rewards:[]}}function $f({store:e,onSaved:t,base:n=`/api/admin/stores/${e.id}/card-design`,posterHref:r=`/magasins/${e.id}/affichette`,draftNote:l}){const[s,a]=w.useState(0),[o,u]=w.useState(null),[c,p]=w.useState({logoUrl:null,stripUrl:null}),[m,g]=w.useState(!1),[v,x]=w.useState("apple"),[j,N]=w.useState(null),[f,d]=w.useState(!1),[h,y]=w.useState(null);function S(L){const{logoUrl:ne,stripUrl:je,...Ve}=L;u(Ve),p({logoUrl:ta(ne),stripUrl:ta(je)}),g(!0)}if(w.useEffect(()=>{U.get(n).then(L=>L?S(L):u(Pv(e))).catch(L=>N(L.message))},[n,e]),w.useEffect(()=>{c.logoUrl&&kv(c.logoUrl).then(y)},[c.logoUrl]),!o)return j?i.jsx("div",{className:"alert error",children:j}):i.jsx("p",{className:"muted",children:"Chargement…"});const E=(L,ne)=>u({...o,[L]:ne});async function k(){N(null),d(!0);try{const{programName:L,backgroundColor:ne,foregroundColor:je,labelColor:Ve,pointsMode:Xe,pointsPerEuro:R}=o,_=o.rewards.map(({id:z,label:V,cost:X,active:nn})=>({id:z,label:V,cost:X,active:nn}));return S(await U.put(n,{programName:L,backgroundColor:ne,foregroundColor:je,labelColor:Ve,pointsMode:Xe,pointsPerEuro:R,rewards:_})),t(),!0}catch(L){return N(L.message),!1}finally{d(!1)}}async function C(){await k()&&a(L=>Math.min(L+1,ti.length-1))}async function M(L,ne){var Ve;const je=(Ve=ne.target.files)==null?void 0:Ve[0];if(ne.target.value="",!!je&&!(!m&&!await k())){d(!0),N(null);try{const Xe=L==="logo"?await Ev(je):await Cv(je),R=new FormData;R.append("file",Xe,`${L}.png`),S(await U.post(`${n}/images/${L}`,R))}catch(Xe){N(Xe.message)}finally{d(!1)}}}const A={...o,...c,storeName:e.name},O=Iu(o.backgroundColor,o.foregroundColor),Te=Iu(o.backgroundColor,o.labelColor);return i.jsxs("div",{className:"wizard",children:[i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:24},children:[i.jsx("ol",{className:"steps","aria-label":"Étapes",children:ti.map((L,ne)=>i.jsx("li",{children:i.jsxs("button",{type:"button","aria-current":ne===s?"step":void 0,onClick:()=>a(ne),children:[ne+1," · ",L]})},L))}),j&&i.jsx("div",{className:"alert error",role:"alert",children:j}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:20},children:[s===0&&i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Identité"}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"programName",children:"Nom du programme *"}),i.jsx("input",{id:"programName",className:"input",maxLength:40,value:o.programName,onChange:L=>E("programName",L.target.value)})]}),i.jsxs("div",{className:"field",children:[i.jsx("span",{style:{fontWeight:600},children:"Logo"}),i.jsxs("div",{className:"upload-drop",children:[c.logoUrl&&i.jsx("img",{src:c.logoUrl,alt:"Logo actuel"}),i.jsxs("label",{className:"btn secondary small",children:[c.logoUrl?"Remplacer":"Choisir un fichier",i.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp",className:"sr-only",onChange:L=>M("logo",L),disabled:f})]}),i.jsx("span",{className:"hint",children:"PNG carré conseillé, fond transparent."})]})]}),i.jsxs("div",{className:"field",children:[i.jsx("span",{style:{fontWeight:600},children:"Bandeau"}),i.jsxs("div",{className:"upload-drop",children:[c.stripUrl&&i.jsx("img",{src:c.stripUrl,alt:"Bandeau actuel"}),i.jsxs("label",{className:"btn secondary small",children:[c.stripUrl?"Remplacer":"Choisir un fichier",i.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp",className:"sr-only",onChange:L=>M("strip",L),disabled:f})]}),i.jsx("span",{className:"hint",children:"Recadré automatiquement au format Wallet (1125 × 432)."})]})]})]}),s===1&&i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Couleurs"}),h&&h!==o.backgroundColor&&i.jsxs("div",{className:"row",style:{gap:12},children:[i.jsx("span",{style:{width:28,height:28,borderRadius:8,background:h,border:"1px solid var(--border)"}}),i.jsxs("span",{children:["Couleur extraite du logo : ",h]}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:()=>E("backgroundColor",h),children:"Utiliser comme fond"})]}),[["backgroundColor","Fond"],["foregroundColor","Texte"],["labelColor","Libellés"]].map(([L,ne])=>i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:L,children:ne}),i.jsxs("div",{className:"color-row",children:[i.jsx("input",{type:"color","aria-label":`${ne} (sélecteur)`,value:o[L],onChange:je=>E(L,je.target.value.toUpperCase())}),i.jsx("input",{id:L,className:"input",style:{maxWidth:160},value:o[L],pattern:"#[0-9A-Fa-f]{6}",onChange:je=>E(L,je.target.value)})]})]},L)),O<4.5&&i.jsxs("div",{className:"alert warn",children:["Contraste texte/fond insuffisant (",O.toFixed(1),":1, minimum 4,5:1) : le solde sera difficile à lire."]}),Te<3&&i.jsxs("div",{className:"alert warn",children:["Contraste libellés/fond faible (",Te.toFixed(1),":1, minimum conseillé 3:1)."]})]}),s===2&&i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Règle de points"}),i.jsxs("div",{className:"mode-cards",role:"radiogroup",children:[i.jsxs("label",{className:"mode-card",children:[i.jsx("input",{type:"radio",name:"mode",checked:o.pointsMode==="AMOUNT",onChange:()=>E("pointsMode","AMOUNT")}),i.jsxs("span",{children:[i.jsx("strong",{children:"Points selon le montant"}),i.jsx("br",{}),i.jsx("span",{className:"muted",children:"X points par euro dépensé"})]})]}),i.jsxs("label",{className:"mode-card",children:[i.jsx("input",{type:"radio",name:"mode",checked:o.pointsMode==="STAMP",onChange:()=>E("pointsMode","STAMP")}),i.jsxs("span",{children:[i.jsx("strong",{children:"Tampons"}),i.jsx("br",{}),i.jsx("span",{className:"muted",children:"1 tampon par passage"})]})]})]}),o.pointsMode==="AMOUNT"?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"ppe",children:"Points par euro *"}),i.jsx("input",{id:"ppe",className:"input",type:"number",step:"0.01",min:.01,max:100,style:{maxWidth:160},value:o.pointsPerEuro,onChange:L=>E("pointsPerEuro",Number(L.target.value))})]}),i.jsxs("p",{className:"muted",style:{margin:0},children:["Exemple : un panier de 23,50 € = ",i.jsxs("strong",{children:[Math.floor(23.5*o.pointsPerEuro)," points"]})," (arrondi à l'inférieur)."]})]}):i.jsx("p",{className:"muted",style:{margin:0},children:"Chaque passage validé par un employé ajoute un tampon, quel que soit le montant."})]}),s===3&&i.jsx(Rv,{rewards:o.rewards,unit:o.pointsMode==="STAMP"?"tampons":"points",onChange:L=>E("rewards",L)}),s===4&&i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Récapitulatif"}),i.jsxs("ul",{style:{margin:0,paddingLeft:20,lineHeight:1.8},children:[i.jsxs("li",{children:["Programme : ",i.jsx("strong",{children:o.programName})]}),i.jsxs("li",{children:["Règle : ",o.pointsMode==="STAMP"?"1 tampon par passage":`${o.pointsPerEuro} point(s) par euro`]}),i.jsxs("li",{children:["Récompenses : ",o.rewards.filter(L=>L.active!==!1).map(L=>`${L.label} (${L.cost})`).join(", ")||"aucune"]}),i.jsxs("li",{children:["Logo : ",c.logoUrl?"oui":i.jsx("span",{style:{color:"var(--warn)"},children:"manquant"})," · Bandeau : ",c.stripUrl?"oui":"non"]})]}),i.jsx("h3",{style:{margin:"8px 0 0"},children:"Affichette du comptoir"}),i.jsxs("div",{style:{display:"flex",gap:24,flexWrap:"wrap",alignItems:"flex-start"},children:[i.jsx("div",{style:{width:222,height:315,overflow:"hidden",borderRadius:8,boxShadow:"0 4px 16px rgb(0 0 0 / 0.15)"},children:i.jsx("div",{style:{transform:"scale(0.4)",transformOrigin:"top left"},children:i.jsx(Ff,{format:"A5",url:e.enrollUrl,storeName:e.name,programName:o.programName,logoUrl:c.logoUrl,backgroundColor:o.backgroundColor,foregroundColor:o.foregroundColor,labelColor:o.labelColor,rewards:o.rewards,pointsMode:o.pointsMode})})}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,flex:"1 1 220px"},children:[i.jsx("p",{style:{margin:0},children:"Le QR mène à la page d'inscription :"}),i.jsx("a",{href:e.enrollUrl,target:"_blank",rel:"noreferrer",style:{wordBreak:"break-all"},children:e.enrollUrl}),i.jsx(De,{to:r,className:"btn secondary",children:"Imprimer l'affichette (A5 / A6)"})]})]}),e.status==="DRAFT"&&(l??i.jsxs("p",{style:{margin:0},children:["Le programme s'ouvre automatiquement dès que l'abonnement est payé. Sinon, utilisez le bouton ",i.jsx("strong",{children:"Activer"})," en haut de la fiche."]}))]}),i.jsxs("div",{className:"row between",children:[i.jsx("button",{type:"button",className:"btn secondary",disabled:s===0,onClick:()=>a(s-1),children:"Précédent"}),sx("apple"),children:"Apple Wallet"}),i.jsx("button",{type:"button",className:"chip","aria-pressed":v==="google",onClick:()=>x("google"),children:"Google Wallet"})]}),v==="apple"?i.jsx(zg,{d:A}):i.jsx(Ig,{d:A}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Aperçu indicatif — QR et solde fictifs."})]})]})}function Rv({rewards:e,unit:t,onChange:n}){const r=(l,s)=>n(e.map((a,o)=>o===l?{...a,...s}:a));return i.jsxs(i.Fragment,{children:[i.jsx("h2",{children:"Récompenses"}),e.length===0&&i.jsxs("p",{className:"muted",style:{margin:0},children:["Aucune récompense. Exemple : « Café offert » pour 10 ",t,"."]}),e.map((l,s)=>i.jsxs("div",{className:"row",style:{alignItems:"flex-end",opacity:l.active===!1?.6:1},children:[i.jsxs("div",{className:"field",style:{flex:"1 1 240px"},children:[i.jsx("label",{htmlFor:`rw-label-${s}`,children:"Libellé"}),i.jsx("input",{id:`rw-label-${s}`,className:"input",maxLength:60,value:l.label,onChange:a=>r(s,{label:a.target.value})})]}),i.jsxs("div",{className:"field",style:{width:140},children:[i.jsxs("label",{htmlFor:`rw-cost-${s}`,children:["Coût (",t,")"]}),i.jsx("input",{id:`rw-cost-${s}`,className:"input",type:"number",min:1,value:l.cost,onChange:a=>r(s,{cost:Number(a.target.value)})})]}),l.active===!1?i.jsx("button",{type:"button",className:"btn secondary",onClick:()=>r(s,{active:!0}),children:"Réactiver"}):i.jsx("button",{type:"button",className:"btn secondary","aria-label":`Retirer ${l.label||"la récompense"}`,onClick:()=>n(e.filter((a,o)=>o!==s)),children:"Retirer"})]},l.id??`new-${s}`)),i.jsx("div",{children:i.jsx("button",{type:"button",className:"btn secondary",disabled:e.length>=20,onClick:()=>n([...e,{label:"",cost:10}]),children:"+ Ajouter une récompense"})})]})}const aa={MANAGER:"Dirigeant",EMPLOYEE:"Employé"};function Tv({storeId:e}){const t=`/api/admin/stores/${e}/staff`,[n,r]=w.useState([]),[l,s]=w.useState(null),[a,o]=w.useState(null),u=w.useRef(null),c=w.useRef(null),p=w.useCallback(()=>{U.get(t).then(r).catch(d=>s(d.message))},[t]);w.useEffect(p,[p]);function m(d){var h;o(d),(h=c.current)==null||h.showModal(),p()}async function g(d){try{await U.patch(`${t}/${d.id}`,{active:!d.active}),p()}catch(h){s(h.message)}}async function v(d){if(window.confirm(`Générer un nouveau mot de passe pour ${d.displayName} ? Ses sessions seront fermées.`))try{m(await U.post(`${t}/${d.id}/reset-password`))}catch(h){s(h.message)}}async function x(d){const h=d.role==="MANAGER"?"EMPLOYEE":"MANAGER";if(window.confirm(`${d.displayName} devient ${aa[h]}. Ses sessions ouvertes seront fermées.`))try{await U.patch(`${t}/${d.id}`,{role:h}),p()}catch(y){s(y.message)}}const j=n.filter(d=>d.active),N=j.filter(d=>d.role==="MANAGER").length,f=[...n].sort((d,h)=>Number(h.active)-Number(d.active)||d.role.localeCompare(h.role)||d.displayName.localeCompare(h.displayName));return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"row between",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Employés"}),i.jsxs("p",{className:"muted",style:{margin:0},children:[j.length," compte",j.length>1?"s":""," actif",j.length>1?"s":""," · ",N," dirigeant",N>1?"s":""]})]}),i.jsx("button",{className:"btn",onClick:()=>{var d;return(d=u.current)==null?void 0:d.showModal()},children:"+ Nouvel employé"})]}),l&&i.jsx("div",{className:"alert error",role:"alert",children:l}),n.length>0&&N===0&&i.jsx("div",{className:"alert warn",children:"Aucun Dirigeant actif : personne ne peut configurer le magasin depuis l’app. Créez un compte Dirigeant ou changez le rôle d’un employé."}),n.length===0?i.jsxs("section",{className:"card",style:{textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:12,padding:40},children:[i.jsx("span",{className:"staff-avatar big","aria-hidden":"true",children:"👥"}),i.jsx("h3",{style:{margin:0},children:"Aucun compte pour l’instant"}),i.jsx("p",{className:"muted",style:{margin:0,maxWidth:420},children:"Créez au moins un Dirigeant : il pourra ensuite ajouter lui-même son équipe depuis l’app MonEspacePro."}),i.jsx("button",{className:"btn",onClick:()=>{var d;return(d=u.current)==null?void 0:d.showModal()},children:"Créer le premier compte"})]}):i.jsx("div",{className:"staff-grid",children:f.map(d=>i.jsxs("article",{className:`card staff-card${d.active?"":" off"}`,children:[i.jsxs("div",{className:"row",style:{gap:12,flexWrap:"nowrap"},children:[i.jsx("span",{className:`staff-avatar${d.role==="MANAGER"?" mgr":""}`,"aria-hidden":"true",children:d.displayName.charAt(0).toUpperCase()}),i.jsxs("div",{style:{minWidth:0},children:[i.jsx("strong",{style:{display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.displayName}),i.jsx("span",{className:"muted",style:{fontSize:14,display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.email})]})]}),i.jsxs("div",{className:"row",style:{gap:6},children:[i.jsx("span",{className:`role-pill${d.role==="MANAGER"?" mgr":""}`,children:aa[d.role]}),d.active?i.jsx("span",{className:"badge ACTIVE",children:"Actif"}):i.jsx("span",{className:"badge DRAFT",children:"Désactivé"}),i.jsxs("span",{className:"muted",style:{fontSize:13},children:["depuis le ",new Date(d.createdAt).toLocaleDateString("fr-FR",{day:"numeric",month:"short",year:"numeric"})]})]}),i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsx("button",{className:"btn secondary small",onClick:()=>x(d),children:d.role==="MANAGER"?"Passer Employé":"Passer Dirigeant"}),i.jsx("button",{className:"btn secondary small",onClick:()=>v(d),children:"Nouveau mot de passe"}),i.jsx("button",{className:"btn secondary small",onClick:()=>g(d),children:d.active?"Désactiver":"Réactiver"})]})]},d.id))}),i.jsx("dialog",{ref:u,"aria-labelledby":"new-staff-title",children:i.jsx(Lv,{base:t,onCancel:()=>{var d;return(d=u.current)==null?void 0:d.close()},onCreated:d=>{var h;(h=u.current)==null||h.close(),m(d)}})}),i.jsx("dialog",{ref:c,"aria-labelledby":"pwd-title",children:i.jsxs("div",{className:"dialog-body",children:[i.jsx("h2",{id:"pwd-title",children:"Mot de passe provisoire"}),i.jsxs("p",{style:{margin:0},children:["Communiquez-le à ",i.jsx("strong",{children:a==null?void 0:a.displayName})," (",a==null?void 0:a.email,"). Il ne sera plus affiché ensuite."]}),i.jsx("div",{className:"password-box",children:a==null?void 0:a.provisionalPassword}),i.jsxs("div",{className:"row",style:{justifyContent:"flex-end"},children:[i.jsx("button",{className:"btn secondary",onClick:()=>{var d;return(d=navigator.clipboard)==null?void 0:d.writeText((a==null?void 0:a.provisionalPassword)??"")},children:"Copier"}),i.jsx("button",{className:"btn",onClick:()=>{var d;return(d=c.current)==null?void 0:d.close()},children:"J'ai noté le mot de passe"})]})]})})]})}function Lv({base:e,onCancel:t,onCreated:n}){const[r,l]=w.useState(""),[s,a]=w.useState(""),[o,u]=w.useState("EMPLOYEE"),[c,p]=w.useState(null),[m,g]=w.useState(!1);async function v(x){x.preventDefault(),g(!0),p(null);try{n(await U.post(e,{displayName:r,email:s,role:o})),l(""),a(""),u("EMPLOYEE")}catch(j){p(j.message)}finally{g(!1)}}return i.jsxs("form",{className:"dialog-body",onSubmit:v,children:[i.jsx("h2",{id:"new-staff-title",children:"Nouvel employé"}),c&&i.jsx("div",{className:"alert error",role:"alert",children:c}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"staff-name",children:"Prénom et nom *"}),i.jsx("input",{id:"staff-name",className:"input",required:!0,placeholder:"Prénom Nom",value:r,onChange:x=>l(x.target.value)})]}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"staff-email",children:"E-mail *"}),i.jsx("input",{id:"staff-email",className:"input",type:"email",required:!0,placeholder:"prenom@exemple.fr",value:s,onChange:x=>a(x.target.value)})]}),i.jsxs("fieldset",{style:{border:0,padding:0,margin:0},className:"field",children:[i.jsx("legend",{style:{fontWeight:600,marginBottom:6},children:"Rôle *"}),i.jsx("div",{className:"mode-cards",children:["EMPLOYEE","MANAGER"].map(x=>i.jsxs("label",{className:"mode-card",children:[i.jsx("input",{type:"radio",name:"role",checked:o===x,onChange:()=>u(x)}),i.jsxs("span",{children:[i.jsx("strong",{children:aa[x]}),i.jsx("br",{}),i.jsx("span",{className:"muted",style:{fontSize:14},children:x==="MANAGER"?"Toute la configuration : carte, modules, campagnes, employés, statistiques":"Scanne les cartes et crédite les points, voit ses opérations"})]})]},x))})]}),i.jsx("p",{className:"muted",style:{margin:0,fontSize:14},children:"Un mot de passe provisoire sera généré à la création."}),i.jsxs("div",{className:"row",style:{justifyContent:"flex-end"},children:[i.jsx("button",{type:"button",className:"btn secondary",onClick:t,children:"Annuler"}),i.jsx("button",{className:"btn",disabled:m,children:"Créer le compte"})]})]})}const Du={ACTIVE:["Actif","ACTIVE"],INCOMPLETE:["En attente de paiement","DRAFT"],PAST_DUE:["Impayé","SUSPENDED"],CANCELED:["Résilié","CLOSED"]},Av={multiStore:"Carte commune à plusieurs magasins"},sl=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:e%100?2:0}),ln=e=>new Date(e).toLocaleDateString("fr-FR",{day:"numeric",month:"short",year:"numeric"});function Mv({storeId:e,contactEmail:t,onChange:n}){const[r,l]=w.useState(null),[s,a]=w.useState(null),[o,u]=w.useState(null),[c,p]=w.useState(!1),[m,g]=w.useState(null),[v,x]=w.useState(null),j=w.useCallback(()=>{U.get(`/api/admin/stores/${e}/billing`).then(l).catch(C=>a(C.message))},[e]);w.useEffect(j,[j]);async function N(C,M,A){p(!0),a(null);try{const O=await U.post(M,A);u({...O,label:C}),j(),n()}catch(O){a(O.message)}finally{p(!1)}}if(!r)return s?i.jsx("div",{className:"alert error",children:s}):i.jsx("p",{className:"muted",children:"Chargement…"});const f=r.subscription,d=f&&f.status!=="CANCELED"&&f.hasSubscription?r.catalog.find(C=>C.plan===f.plan):null,h=!d,y=m??(f==null?void 0:f.plan)??"PRO",S=v??(f==null?void 0:f.interval)??"MONTH",E=r.invoices.filter(C=>C.paidAt).reduce((C,M)=>C+M.amountCents,0),k=r.invoices.filter(C=>!C.paidAt).length;return i.jsxs(i.Fragment,{children:[r.testMode&&i.jsx("div",{className:"alert warn",children:"Stripe est en mode test : aucun paiement réel n'est encaissé (carte de test 4242 4242 4242 4242)."}),s&&i.jsx("div",{className:"alert error",role:"alert",children:s}),i.jsxs("div",{className:"kpis",children:[i.jsxs("div",{className:`kpi${d?" ok":""}`,children:[i.jsx("b",{children:d?d.name:"—"}),i.jsx("span",{children:d?`formule ${f.interval==="YEAR"?"annuelle":"mensuelle"}`:(f==null?void 0:f.status)==="INCOMPLETE"?`en attente · ${ut[f.plan]} choisie`:"aucune formule"})]}),i.jsxs("div",{className:"kpi",children:[i.jsx("b",{children:d?sl(d.priceCents[f.interval]):"—"}),i.jsx("span",{children:d?`par ${f.interval==="YEAR"?"an":"mois"}`:"montant"})]}),i.jsxs("div",{className:`kpi${f!=null&&f.cancelAtPeriodEnd?" warn":""}`,children:[i.jsx("b",{style:{fontSize:20,lineHeight:"34px"},children:f!=null&&f.currentPeriodEnd&&f.status==="ACTIVE"?ln(f.currentPeriodEnd):"—"}),i.jsx("span",{children:f!=null&&f.cancelAtPeriodEnd?"fin de l’abonnement":"prochain prélèvement"})]}),i.jsxs("div",{className:`kpi${k?" err":""}`,children:[i.jsx("b",{children:sl(E)}),i.jsxs("span",{children:[r.invoices.length," facture",r.invoices.length>1?"s":"",k?` · ${k} impayée${k>1?"s":""}`:" · tout est réglé"]})]})]}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:16},children:[i.jsxs("div",{className:"row between",children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Abonnement"}),i.jsx("p",{className:"muted",style:{margin:0},children:d?`Formule ${d.name}${f.legacyPrice?" (tarif fondateur)":""} — ${f.interval==="YEAR"?"annuelle":"mensuelle"}`:"Aucune formule souscrite. Sans abonnement actif, le magasin a les droits de la formule Essentiel."})]}),i.jsx("span",{className:`badge ${f?Du[f.status][1]:"DRAFT"}`,children:f?Du[f.status][0]:"Aucun abonnement"})]}),(f==null?void 0:f.cancelAtPeriodEnd)&&f.currentPeriodEnd&&i.jsxs("div",{className:"alert warn",children:["Résiliation demandée : l'abonnement s'arrête le ",i.jsx("strong",{children:ln(f.currentPeriodEnd)}),"."]}),(f==null?void 0:f.currentPeriodEnd)&&f.status==="ACTIVE"&&!f.cancelAtPeriodEnd&&i.jsxs("p",{style:{margin:0},children:["Prochain prélèvement le ",i.jsx("strong",{children:ln(f.currentPeriodEnd)}),"."]}),r.billingSuspended&&i.jsx("div",{className:"alert warn",children:"Magasin suspendu automatiquement pour impayé. Il sera réactivé dès que le paiement passera."}),d&&i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsxs("button",{className:"btn",disabled:c,onClick:()=>N("Espace abonnement",`/api/admin/stores/${e}/billing/portal-link`,{sendEmail:!0}),children:["Envoyer l'espace abonnement à ",t]}),i.jsx("button",{className:"btn secondary",disabled:c,onClick:()=>N("Espace abonnement",`/api/admin/stores/${e}/billing/portal-link`,{sendEmail:!1}),children:"Ouvrir l'espace abonnement"}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Changer de formule, de moyen de paiement, résilier."})]})]}),h&&i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:20},children:[i.jsxs("div",{className:"row between",children:[i.jsx("h2",{children:"Choisir une formule"}),i.jsxs("div",{role:"group","aria-label":"Périodicité",className:"row",style:{gap:8},children:[i.jsx("button",{type:"button",className:"chip","aria-pressed":S==="MONTH",onClick:()=>x("MONTH"),children:"Mensuel"}),i.jsx("button",{type:"button",className:"chip","aria-pressed":S==="YEAR",onClick:()=>x("YEAR"),children:"Annuel — 2 mois offerts"})]})]}),i.jsx("div",{className:"mode-cards",role:"radiogroup","aria-label":"Formule",children:r.catalog.map(C=>i.jsxs("label",{className:"mode-card",style:{flexDirection:"column",gap:8},children:[i.jsxs("span",{className:"row",style:{gap:10},children:[i.jsx("input",{type:"radio",name:"plan",checked:y===C.plan,onChange:()=>g(C.plan)}),i.jsx("strong",{style:{fontSize:18},children:C.name}),C.plan==="PRO"&&i.jsx("span",{className:"badge ACTIVE",style:{height:22},children:"Conseillée"})]}),i.jsxs("span",{style:{fontSize:24,fontWeight:800},children:[sl(C.priceCents[S]),i.jsxs("span",{className:"muted",style:{fontSize:14,fontWeight:500},children:[" / ",S==="YEAR"?"an":"mois",C.plan==="RESEAU"?" / magasin":""]})]}),i.jsx("span",{className:"muted",style:{fontSize:14},children:C.tagline}),i.jsxs("ul",{style:{margin:0,paddingLeft:18,fontSize:14,lineHeight:1.6},children:[i.jsx("li",{children:C.limits.maxStaff?`${C.limits.maxStaff} employés`:"Employés illimités"}),i.jsx("li",{children:"Carte Wallet, points ou tampons, récompenses, mises à jour en direct"}),C.features.map(M=>i.jsx("li",{children:Av[M]??M},M))]}),i.jsx("span",{style:{fontSize:14,fontWeight:700},children:C.modules.length?`Modules inclus (${C.modules.length})`:"Aucun module inclus"}),C.modules.length>0&&i.jsx("ul",{style:{margin:0,paddingLeft:18,fontSize:14,lineHeight:1.6},children:C.modules.map(M=>i.jsx("li",{title:M.tagline,children:M.name},M.id))})]},C.plan))}),i.jsxs("div",{className:"copy-line",style:{flexWrap:"wrap"},children:[i.jsx("span",{className:"muted",children:"Lien de paiement permanent :"}),i.jsx("code",{children:r.subscribeUrl}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:()=>{var C;return(C=navigator.clipboard)==null?void 0:C.writeText(r.subscribeUrl)},children:"Copier"})]}),i.jsx("p",{className:"muted",style:{margin:0,fontSize:14},children:"Il ne périme pas. Le commerçant peut saisir un code promo sur la page de paiement (codes à créer dans Stripe → Coupons)."}),i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsxs("button",{className:"btn",disabled:c,onClick:()=>N("Lien d'abonnement",`/api/admin/stores/${e}/billing/checkout-link`,{plan:y,interval:S,sendEmail:!0}),children:["Envoyer le lien à ",t]}),i.jsx("button",{className:"btn secondary",disabled:c,onClick:()=>N("Lien d'abonnement",`/api/admin/stores/${e}/billing/checkout-link`,{plan:y,interval:S,sendEmail:!1}),children:"Enregistrer la formule sans envoyer"})]})]}),o&&i.jsxs("div",{className:"alert ok",children:[o.label," ",o.emailedTo?i.jsxs(i.Fragment,{children:["envoyé à ",i.jsx("strong",{children:o.emailedTo}),". "]}):"créé. ",i.jsx("a",{href:o.url,target:"_blank",rel:"noreferrer",style:{wordBreak:"break-all"},children:o.url})]}),i.jsxs("div",{className:"row between",style:{marginTop:8},children:[i.jsx("h2",{children:"Factures"}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Émises et envoyées automatiquement à chaque paiement."})]}),i.jsxs("div",{className:"table-wrap",children:[i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{style:{minWidth:720},children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{scope:"col",style:{paddingLeft:24},children:"Facture"}),i.jsx("th",{scope:"col",children:"Objet"}),i.jsx("th",{scope:"col",children:"Période"}),i.jsx("th",{scope:"col",className:"num",children:"Montant"}),i.jsx("th",{scope:"col",children:"Statut"}),i.jsx("th",{scope:"col",children:i.jsx("span",{className:"sr-only",children:"PDF"})})]})}),i.jsx("tbody",{children:r.invoices.map(C=>i.jsxs("tr",{children:[i.jsx("td",{style:{paddingLeft:24,fontWeight:600},children:C.number}),i.jsx("td",{style:{fontSize:14},children:C.description.replace("Abonnement MonEspacePro — ","")}),i.jsxs("td",{children:[ln(C.periodStart)," → ",ln(C.periodEnd)]}),i.jsx("td",{className:"num",children:sl(C.amountCents)}),i.jsx("td",{children:C.paidAt?i.jsxs("span",{className:"badge ACTIVE",children:["Payée le ",ln(C.paidAt)]}):i.jsx("span",{className:"badge SUSPENDED",children:"Impayée"})}),i.jsx("td",{style:{textAlign:"right",paddingRight:24},children:i.jsx("button",{className:"btn secondary small",onClick:()=>na(`/api/admin/invoices/${C.id}/pdf`,`${C.number}.pdf`).catch(M=>a(M.message)),children:"PDF"})})]},C.id))})]})}),r.invoices.length===0&&i.jsx("p",{className:"muted",style:{padding:24,margin:0,textAlign:"center"},children:"Aucune facture pour l'instant. Elles sont créées automatiquement à chaque paiement."})]})]})}const Fu=e=>new Date(e).toLocaleString("fr-FR",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"});function _v({storeId:e,storeName:t}){const[n,r]=w.useState(null),[l,s]=w.useState(""),[a,o]=w.useState(null),[u,c]=w.useState(null),[p,m]=w.useState(null),[g,v]=w.useState(!1),x=w.useCallback(()=>{U.get(`/api/admin/stores/${e}/campaigns`).then(r).catch(d=>c(d.message))},[e]);if(w.useEffect(x,[x]),!n)return u?i.jsx("div",{className:"alert error",children:u}):i.jsx("p",{className:"muted",children:"Chargement…"});const j=l.trim(),N=!n.allowed||!!n.nextAllowedAt;async function f(){if(confirm(`Envoyer ce message aux ${n.audience.cards} cartes de ${t} ? « ${j} »`)){v(!0),c(null);try{await U.post(`/api/admin/stores/${e}/campaigns`,{message:j,title:(a??n.defaultTitle).trim()}),s(""),m("Campagne envoyée. Les cartes se mettent à jour dans les minutes qui suivent."),x()}catch(d){c(d.message)}finally{v(!1)}}}return i.jsxs(i.Fragment,{children:[u&&i.jsx("div",{className:"alert error",role:"alert",children:u}),p&&i.jsx("div",{className:"alert ok",role:"status",children:p}),i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:16},children:[i.jsxs("div",{children:[i.jsx("h2",{children:"Nouvelle campagne"}),i.jsxs("p",{className:"muted",style:{margin:0},children:["Le message apparaît en notification sur le téléphone des clients et reste visible sur leur carte. Audience : ",i.jsx("strong",{children:n.audience.cards})," cartes, dont ",i.jsx("strong",{children:n.audience.appleDevices})," iPhone joignables (Google Wallet : tous les clients qui ont ajouté la carte)."]})]}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"campaign-title",children:"Titre de la notification"}),i.jsx("input",{id:"campaign-title",className:"input",maxLength:40,value:a??n.defaultTitle,onChange:d=>o(d.target.value),disabled:N||g}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"Affiché sur Google Wallet. Sur iPhone, le nom du magasin apparaît toujours en titre."})]}),i.jsx("label",{htmlFor:"campaign-msg",children:"Message"}),i.jsx("textarea",{id:"campaign-msg",className:"input",rows:3,maxLength:n.maxLength,placeholder:"Ex. : -20 % sur les viennoiseries ce samedi, sur présentation de votre carte !",value:l,onChange:d=>s(d.target.value),disabled:N||g}),i.jsxs("div",{className:"row between",children:[i.jsxs("span",{className:"muted",style:{fontSize:14},children:[j.length," / ",n.maxLength," caractères · 1 campagne toutes les ",n.minIntervalHours," h maximum"]}),i.jsx("button",{className:"btn",disabled:N||g||j.length<5,onClick:f,children:g?"Envoi…":"Envoyer la campagne"})]}),n.nextAllowedAt&&i.jsxs("div",{className:"alert warn",children:["Prochain envoi possible le ",Fu(n.nextAllowedAt),"."]})]}),i.jsxs("section",{className:"card",children:[i.jsx("h2",{children:"Historique"}),n.items.length===0?i.jsx("p",{className:"muted",style:{margin:0},children:"Aucune campagne envoyée pour l'instant."}):i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{scope:"col",children:"Date"}),i.jsx("th",{scope:"col",children:"Message"}),i.jsx("th",{scope:"col",children:"Envoyée par"}),i.jsx("th",{scope:"col",className:"num",children:"Cartes"})]})}),i.jsx("tbody",{children:n.items.map(d=>i.jsxs("tr",{children:[i.jsx("td",{className:"muted",style:{whiteSpace:"nowrap"},children:Fu(d.createdAt)}),i.jsxs("td",{children:[d.title&&i.jsxs("strong",{children:[d.title," · "]}),d.message]}),i.jsx("td",{children:d.sentByName}),i.jsx("td",{className:"num",children:d.cards})]},d.id))})]})})]})]})}const zv={campaigns:"📣",reminders:"⏰",birthday:"🎂",reviews:"⭐",referral:"🤝",stats:"📊",whiteLabel:"🏷️"},Uu=e=>e.type==="text"||e.type==="textarea";function Iv({m:e}){const[t,n]=e.override===!0?["Ajouté sur mesure","ACTIVE"]:e.override===!1?["Retiré","CLOSED"]:e.inPlan?["Inclus dans la formule","ACTIVE"]:["Non inclus","DRAFT"];return i.jsx("span",{className:`badge ${n}`,children:t})}function Dv({f:e,value:t,onChange:n}){var o;const r=`f-${e.key}`,l=i.jsxs(i.Fragment,{children:[e.help&&i.jsxs("span",{className:"muted",style:{fontSize:14},children:[e.help," "]}),"variables"in e&&((o=e.variables)!=null&&o.length)?i.jsxs("span",{className:"muted",style:{fontSize:14},children:["Variables : ",e.variables.map(u=>i.jsx("code",{style:{marginRight:6},children:u},u))]}):null]});if(e.type==="boolean")return i.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,fontWeight:600},children:[i.jsx("input",{type:"checkbox",checked:!!t,onChange:u=>n(u.target.checked)}),e.label,e.help&&i.jsxs("span",{className:"muted",style:{fontWeight:400,fontSize:14},children:["— ",e.help]})]});if(e.type==="int"||e.type==="hour")return i.jsxs("div",{children:[i.jsx("label",{htmlFor:r,style:{fontWeight:600},children:e.label}),i.jsxs("div",{className:"row",style:{gap:8,alignItems:"center"},children:[i.jsx("input",{id:r,className:"input",type:"number",style:{width:120},min:e.min,max:e.max,value:Number(t),onChange:u=>n(Math.floor(Number(u.target.value)||0))}),i.jsx("span",{className:"muted",children:e.type==="hour"?"h":e.unit})]}),l]});const s=e,a=String(t??"");return i.jsxs("div",{children:[i.jsx("label",{htmlFor:r,style:{fontWeight:600},children:e.label}),s.type==="textarea"?i.jsx("textarea",{id:r,className:"input",rows:2,maxLength:s.maxLength,value:a,onChange:u=>n(u.target.value)}):i.jsx("input",{id:r,className:"input",type:s.type==="url"?"url":"text",maxLength:s.maxLength,value:a,onChange:u=>n(u.target.value)}),i.jsxs("div",{className:"row between",style:{gap:8},children:[i.jsx("span",{children:l}),i.jsxs("span",{className:"muted",style:{fontSize:13},children:[a.length," / ",s.maxLength]})]}),s.type!=="url"&&a!==s.default&&i.jsx("button",{type:"button",className:"link",style:{fontSize:14},onClick:()=>n(s.default),children:"Remettre le texte par défaut"})]})}function Fv({storeId:e,storeName:t,initial:n,onChanged:r}){const[l,s]=w.useState(n),[a,o]=w.useState(n.config),[u,c]=w.useState(!1),[p,m]=w.useState(!1),[g,v]=w.useState(null),[x,j]=w.useState(null),N=`/api/admin/stores/${e}/modules/${l.id}`,f=y=>{s(y),o(y.config)};w.useEffect(()=>{u&&U.get(N).then(f).catch(y=>v(y.message))},[u,N]);async function d(y,S){m(!0),v(null),j(null);try{f(await y()),j(S),r()}catch(E){v(E.message)}finally{m(!1)}}const h=JSON.stringify(a)!==JSON.stringify(l.config);return i.jsxs("section",{className:"card",style:{display:"flex",flexDirection:"column",gap:14},children:[i.jsxs("div",{className:"row between",style:{alignItems:"flex-start",gap:12},children:[i.jsxs("div",{style:{flex:"1 1 320px",display:"flex",gap:14},children:[i.jsx("span",{className:`mod-ic${l.available&&l.config.enabled?" on":""}`,"aria-hidden":"true",children:zv[l.id]??"🧩"}),i.jsxs("div",{children:[i.jsxs("div",{className:"row",style:{gap:10,alignItems:"center"},children:[i.jsx("h2",{style:{margin:0},children:l.name}),i.jsx(Iv,{m:l})]}),i.jsx("p",{className:"muted",style:{margin:"6px 0 0"},children:l.description})]})]}),i.jsxs("div",{className:"row",style:{gap:8},children:[l.available&&i.jsxs("label",{className:"switch",title:l.config.enabled?"Désactiver le module":"Activer le module",children:[i.jsx("input",{type:"checkbox",checked:l.config.enabled,disabled:p,onChange:y=>{const S=y.target.checked;d(()=>U.put(N,{enabled:S}),S?"Module activé.":"Module désactivé.")}}),i.jsx("span",{"aria-hidden":"true"}),i.jsx("span",{className:"sr-only",children:"Module activé"})]}),i.jsx("label",{className:"sr-only",htmlFor:`ov-${l.id}`,children:"Disponibilité du module"}),i.jsxs("select",{id:`ov-${l.id}`,className:"input",style:{width:"auto"},disabled:p,value:l.override===null?"plan":l.override?"add":"remove",onChange:y=>{const S=y.target.value==="plan"?null:y.target.value==="add";d(()=>U.put(`${N}/override`,{value:S}),S===null?"Module remis selon la formule.":S?"Module ajouté sur mesure.":"Module retiré.")},children:[i.jsxs("option",{value:"plan",children:["Selon la formule",l.inPlan?" (inclus)":" (non inclus)"]}),i.jsx("option",{value:"add",children:"Ajouter sur mesure"}),i.jsx("option",{value:"remove",children:"Retirer"})]}),i.jsx("button",{type:"button",className:"btn secondary",onClick:()=>c(!u),"aria-expanded":u,children:u?"Fermer":"Personnaliser"})]})]}),g&&i.jsx("div",{className:"alert error",role:"alert",children:g}),x&&i.jsx("div",{className:"alert ok",role:"status",children:x}),u&&i.jsxs(i.Fragment,{children:[!l.available&&i.jsx("div",{className:"alert warn",children:"Module non disponible pour ce magasin : ajoutez-le sur mesure ou changez de formule pour l'activer. Vous pouvez déjà préparer ses réglages."}),l.stats&&i.jsx("div",{className:"kpis",children:Object.entries(l.stats).map(([y,S])=>i.jsxs("div",{className:"kpi",children:[i.jsx("b",{children:S??"—"}),i.jsx("span",{children:y})]},y))}),[["Réglages",l.fields.filter(y=>!Uu(y)),"mod-grid"],["Messages",l.fields.filter(Uu),"mod-stack"]].map(([y,S,E])=>S.length?i.jsxs("fieldset",{className:"mod-group",children:[i.jsx("legend",{children:y}),i.jsx("div",{className:E,children:S.map(k=>i.jsx(Dv,{f:k,value:a[k.key],onChange:C=>o({...a,[k.key]:C})},k.key))})]},y):null),l.id==="stats"&&i.jsx(De,{to:"../statistiques",children:"Voir les statistiques du magasin →"}),i.jsxs("div",{className:`row mod-save${h?" dirty":""}`,style:{gap:8,justifyContent:"flex-end"},children:[h&&i.jsx("span",{className:"muted",style:{marginRight:"auto",fontSize:14},children:"Modifications non enregistrées"}),h&&i.jsx("button",{type:"button",className:"btn secondary",disabled:p,onClick:()=>o(l.config),children:"Annuler"}),i.jsx("button",{type:"button",className:"btn",disabled:p||!h,onClick:()=>d(()=>U.put(N,a),"Réglages enregistrés."),children:p?"Enregistrement…":"Enregistrer"})]}),l.id==="campaigns"&&l.available&&l.config.enabled&&i.jsx(_v,{storeId:e,storeName:t})]})]})}function Uv({storeId:e,storeName:t}){const[n,r]=w.useState(null),[l,s]=w.useState(null),a=w.useCallback(()=>{U.get(`/api/admin/stores/${e}/modules`).then(r).catch(p=>s(p.message))},[e]);if(w.useEffect(a,[a]),!n)return l?i.jsx("div",{className:"alert error",children:l}):i.jsx("p",{className:"muted",children:"Chargement…"});const o=n.filter(p=>p.available&&p.config.enabled).length,u=n.filter(p=>p.available).length,c=n.filter(p=>p.override!==null).length;return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"kpis",children:[i.jsxs("div",{className:"kpi ok",children:[i.jsx("b",{children:o}),i.jsx("span",{children:"modules activés"})]}),i.jsxs("div",{className:"kpi",children:[i.jsxs("b",{children:[u," / ",n.length]}),i.jsx("span",{children:"disponibles pour ce magasin"})]}),i.jsxs("div",{className:"kpi",children:[i.jsx("b",{children:c}),i.jsx("span",{children:"ajout(s) ou retrait(s) sur mesure"})]})]}),i.jsx("p",{className:"muted",style:{margin:0},children:"Chaque module est inclus ou non dans la formule ; vous pouvez l’ajouter ou le retirer sur mesure. L’interrupteur l’active d’un clic, « Personnaliser » ouvre tous ses textes et réglages. Le dirigeant peut aussi les régler depuis l’app MonEspacePro."}),n.map(p=>i.jsx(Fv,{storeId:e,storeName:t,initial:p,onChanged:a},p.id))]})}const Ov=[[30,"30 jours"],[90,"3 mois"],[365,"12 mois"]],ni=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",maximumFractionDigits:e>=1e5?0:2}),sn=e=>e.toLocaleString("fr-FR");function $v({value:e}){if(e===null)return null;const t=e>=0;return i.jsxs("span",{style:{fontSize:13,fontWeight:700,color:t?"var(--ok)":"var(--err)"},children:[t?"▲":"▼"," ",Math.abs(e).toLocaleString("fr-FR")," %"]})}function Bt({icon:e,label:t,value:n,hint:r,change:l}){return i.jsxs("div",{className:"card",style:{padding:16,display:"flex",flexDirection:"column",gap:4},children:[i.jsxs("span",{className:"muted",style:{fontSize:14,display:"flex",gap:8,alignItems:"center"},children:[i.jsx("span",{"aria-hidden":"true",children:e}),t]}),i.jsx("span",{style:{fontSize:26,fontWeight:800},children:n}),i.jsxs("span",{style:{display:"flex",gap:8,alignItems:"baseline"},children:[l!==void 0&&i.jsx($v,{value:l}),r&&i.jsx("span",{className:"muted",style:{fontSize:13},children:r})]})]})}function Bv({series:e}){const t=Math.max(1,...e.map(l=>Math.max(l.visits,l.newCards))),n=100/e.length,r=Math.ceil(e.length/8);return i.jsxs("svg",{viewBox:"0 0 100 46",preserveAspectRatio:"none",style:{width:"100%",height:220},role:"img","aria-label":"Passages et nouvelles cartes sur la période",children:[e.map((l,s)=>i.jsxs("g",{children:[i.jsx("title",{children:`${l.label} : ${l.visits} passage(s), ${l.newCards} nouvelle(s) carte(s)`}),i.jsx("rect",{x:s*n+n*.1,y:40-l.visits/t*38,width:n*.45,height:l.visits/t*38,fill:"var(--primary)"}),i.jsx("rect",{x:s*n+n*.55,y:40-l.newCards/t*38,width:n*.35,height:l.newCards/t*38,fill:"var(--primary-soft)",stroke:"var(--primary)",strokeWidth:.1}),s%r===0&&i.jsx("text",{x:s*n+n/2,y:45,fontSize:2.2,textAnchor:"middle",fill:"currentColor",opacity:.6,children:l.label})]},s)),i.jsx("line",{x1:0,x2:100,y1:40,y2:40,stroke:"var(--border)",strokeWidth:.2})]})}function bv({heat:e}){const t=Array.from({length:15},(r,l)=>l+7),n=Math.max(1,...e.values.flat());return i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{style:{borderCollapse:"separate",borderSpacing:3,minWidth:560},children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{}),t.map(r=>i.jsxs("th",{style:{fontSize:12,fontWeight:500,padding:0,textAlign:"center"},children:[r,"h"]},r))]})}),i.jsx("tbody",{children:e.weekdays.map((r,l)=>i.jsxs("tr",{children:[i.jsx("th",{scope:"row",style:{fontSize:13,fontWeight:600,padding:"0 8px 0 0"},children:r}),t.map(s=>{const a=e.values[l][s];return i.jsx("td",{title:`${r} ${s} h : ${a} passage(s)`,style:{padding:0,height:26,borderRadius:4,background:a?`color-mix(in srgb, var(--primary) ${Math.round(15+a/n*85)}%, transparent)`:"var(--surface-2)"}},s)})]},r))})]})})}function Wv({storeId:e,storeSlug:t}){const[n,r]=w.useState(30),[l,s]=w.useState(null),[a,o]=w.useState(null),[u,c]=w.useState(null);w.useEffect(()=>{o(null),U.get(`/api/admin/stores/${e}/stats?days=${n}`).then(s).catch(v=>o(v.message))},[e,n]);async function p(v){c(v);try{const x=new Date().toISOString().slice(0,10);v==="customers"?await na(`/api/admin/stores/${e}/export/customers`,`clients-${t}-${x}.csv`):await na(`/api/admin/stores/${e}/export/transactions?days=${n}`,`operations-${t}-${n}j-${x}.csv`)}catch(x){o(x.message)}finally{c(null)}}const m=l==null?void 0:l.kpis,g=(l==null?void 0:l.pointsMode)==="STAMP"?"tampons":"points";return i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"row between",style:{alignItems:"center"},children:[i.jsx("div",{role:"group","aria-label":"Période",className:"s-seg",children:Ov.map(([v,x])=>i.jsx("button",{type:"button","aria-pressed":n===v,onClick:()=>r(v),children:x},v))}),i.jsxs("div",{className:"row",style:{gap:8},children:[i.jsx("button",{className:"btn secondary",disabled:!!u,onClick:()=>p("customers"),children:u==="customers"?"Export…":"📇 Clients (CSV)"}),i.jsx("button",{className:"btn secondary",disabled:!!u,onClick:()=>p("transactions"),children:u==="transactions"?"Export…":"🧾 Opérations (CSV)"})]})]}),a&&i.jsx("div",{className:"alert error",role:"alert",children:a}),l&&!l.allowed&&i.jsx("div",{className:"alert warn",children:"Ce magasin n'a pas la formule Pro : il ne voit pas ces statistiques dans son app (vous, si)."}),!l||!m?!a&&i.jsx("p",{className:"muted",children:"Chargement…"}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(190px, 1fr))",gap:12},children:[i.jsx(Bt,{icon:"🚶",label:"Passages",value:sn(m.visits),change:m.visitsChange,hint:"vs période précédente"}),i.jsx(Bt,{icon:"🆕",label:"Nouvelles cartes",value:sn(m.newCards),change:m.newCardsChange,hint:`${sn(m.cardsTotal)} au total`}),i.jsx(Bt,{icon:"👥",label:"Clients actifs",value:sn(m.activeCustomers),hint:`${m.visitsPerCustomer.toLocaleString("fr-FR")} passage(s) par client`}),i.jsx(Bt,{icon:"🔁",label:"Clients fidèles",value:m.returningRate===null?"—":`${m.returningRate.toLocaleString("fr-FR")} %`,hint:"venus au moins 2 fois"}),l.pointsMode==="AMOUNT"&&i.jsx(Bt,{icon:"💶",label:"Achats enregistrés",value:ni(m.revenueCents),hint:m.averageBasketCents===null?void 0:`panier moyen ${ni(m.averageBasketCents)}`}),i.jsx(Bt,{icon:"🎁",label:"Récompenses",value:sn(m.rewardsRedeemed),hint:`${sn(m.pointsGiven)} ${g} distribués`}),i.jsx(Bt,{icon:"📱",label:"Cartes dans Apple Wallet",value:m.appleWalletRate===null?"—":`${m.appleWalletRate.toLocaleString("fr-FR")} %`,hint:"iPhone joignables"})]}),i.jsxs("div",{className:"stats-pair",children:[i.jsxs("section",{className:"card",children:[i.jsx("h2",{children:"Fréquentation"}),i.jsxs("p",{className:"muted",style:{marginTop:0,fontSize:14},children:[i.jsx("span",{style:{display:"inline-block",width:10,height:10,background:"var(--primary)",borderRadius:2}})," Passages   ",i.jsx("span",{style:{display:"inline-block",width:10,height:10,background:"var(--primary-soft)",border:"1px solid var(--primary)",borderRadius:2}})," Nouvelles cartes"]}),i.jsx(Bv,{series:l.series})]}),i.jsxs("section",{className:"card",children:[i.jsx("h2",{children:"Heures d'affluence"}),i.jsx("p",{className:"muted",style:{marginTop:0},children:l.busiest?`Créneau le plus fréquenté : ${l.busiest}.`:"Pas encore de passage sur la période."}),i.jsx(bv,{heat:l.heatmap})]})]}),i.jsxs("section",{className:"card",children:[i.jsx("h2",{children:"Meilleurs clients"}),l.top.length===0?i.jsx("p",{className:"muted",style:{margin:0},children:"Pas encore de passage sur la période."}):i.jsx("div",{className:"table-scroll",children:i.jsxs("table",{children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{scope:"col",style:{width:56},children:"Rang"}),i.jsx("th",{scope:"col",children:"Client"}),i.jsx("th",{scope:"col",className:"num",children:"Passages"}),l.pointsMode==="AMOUNT"&&i.jsx("th",{scope:"col",className:"num",children:"Achats"}),i.jsx("th",{scope:"col",className:"num",children:"Solde"})]})}),i.jsx("tbody",{children:l.top.map((v,x)=>i.jsxs("tr",{children:[i.jsx("td",{children:i.jsx("span",{className:`rank${x<3?" top":""}`,children:["🥇","🥈","🥉"][x]??x+1})}),i.jsx("td",{style:{fontWeight:600},children:v.firstName}),i.jsx("td",{className:"num",children:v.visits}),l.pointsMode==="AMOUNT"&&i.jsx("td",{className:"num",children:ni(v.amountCents)}),i.jsx("td",{className:"num",children:v.balance})]},x))})]})})]})]})]})}const Vv=[["infos","Infos"],["carte","Carte de fidélité"],["employes","Employés"],["modules","Modules"],["statistiques","Statistiques"],["facturation","Facturation"]];function Hv(){var c,p,m;const{id:e}=cf(),[t,n]=w.useState(null),[r,l]=w.useState(null),[s,a]=w.useState(null),o=w.useCallback(()=>{U.get(`/api/admin/stores/${e}`).then(n).catch(g=>l(g.message))},[e]);w.useEffect(o,[o]);async function u(g,v){if(!(v&&!window.confirm(v))){l(null);try{await U.patch(`/api/admin/stores/${e}/status`,{status:g}),o()}catch(x){l(x.message)}}}return t?i.jsxs(i.Fragment,{children:[i.jsx(De,{to:"/magasins",children:"← Magasins"}),i.jsxs("section",{className:"card store-head",children:[i.jsxs("div",{className:"store-id",children:[i.jsx("span",{className:"store-avatar","aria-hidden":"true",children:t.name.charAt(0).toUpperCase()}),i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsxs("div",{className:"row",style:{gap:12},children:[i.jsx("h1",{style:{fontSize:28,lineHeight:"34px"},children:t.name}),i.jsx(vf,{status:t.status}),((c=t.subscription)==null?void 0:c.stripeSubscriptionId)&&t.subscription.status!=="CANCELED"&&i.jsx(xl,{to:"facturation",className:"badge DRAFT",style:{textDecoration:"none"},title:"Formule d'abonnement",children:ut[t.subscription.plan]})]}),i.jsxs("p",{className:"muted",style:{margin:0},children:[t.city," · ",t.counts.cards," clients · ",t.counts.staff," employés · ",t.contactName]}),i.jsxs("ul",{className:"open-steps","aria-label":"Étapes d’ouverture",children:[i.jsxs("li",{className:((p=t.subscription)==null?void 0:p.status)==="ACTIVE"?"done":"",children:[((m=t.subscription)==null?void 0:m.status)==="ACTIVE"?"✓":"○"," Abonnement payé"]}),i.jsxs("li",{className:t.hasCard?"done":"",children:[t.hasCard?"✓":"○"," Carte conçue"]}),i.jsxs("li",{className:t.status==="ACTIVE"?"done":"",children:[t.status==="ACTIVE"?"✓":"○"," Programme ouvert"]})]})]})]}),i.jsxs("div",{className:"row",style:{gap:8},children:[(t.status==="DRAFT"||t.status==="CLOSED")&&i.jsx("button",{className:"btn",onClick:()=>u("ACTIVE"),children:"Activer"}),t.status==="SUSPENDED"&&i.jsx("button",{className:"btn",onClick:()=>u("ACTIVE"),children:"Réactiver"}),t.status==="ACTIVE"&&i.jsx("button",{className:"btn secondary",onClick:()=>u("SUSPENDED","Suspendre ce magasin ? Les employés ne pourront plus scanner."),children:"Suspendre"}),t.status!=="CLOSED"&&i.jsx("button",{className:"btn secondary",onClick:()=>u("CLOSED","Fermer ce magasin ?"),children:"Fermer"})]}),i.jsxs("div",{className:"copy-line",style:{flexBasis:"100%"},children:[i.jsx("span",{className:"muted",children:"Lien d’inscription :"}),i.jsx("code",{children:t.enrollUrl}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:()=>{var g;return(g=navigator.clipboard)==null?void 0:g.writeText(t.enrollUrl).then(()=>a("Lien copié."))},children:"Copier"})]})]}),t.status==="SUSPENDED"&&i.jsxs("div",{className:"alert warn",role:"status",children:["Magasin suspendu",t.billingSuspended?" pour impayé":""," : les scans et les nouvelles inscriptions sont refusés.",t.billingSuspended&&i.jsxs(i.Fragment,{children:[" Voir l'onglet ",i.jsx(xl,{to:"facturation",children:"Facturation"}),"."]})]}),r&&i.jsx("div",{className:"alert error",role:"alert",children:r}),s&&i.jsx("div",{className:"alert ok",role:"status",children:s}),i.jsx("nav",{className:"tabs","aria-label":"Sections du magasin",children:Vv.map(([g,v])=>i.jsx(xl,{to:g,children:v},g))}),i.jsxs(Ji,{children:[i.jsx(G,{index:!0,element:i.jsx(yl,{to:"infos",replace:!0})}),i.jsx(G,{path:"infos",element:i.jsx(yf,{initial:t,submitLabel:"Enregistrer",onSubmit:async g=>{const{name:v,siret:x,addressLine:j,postalCode:N,city:f,contactName:d,contactEmail:h,contactPhone:y,maxAmountEuros:S,minScanIntervalMin:E}=g;await U.patch(`/api/admin/stores/${e}`,{name:v,siret:x,addressLine:j,postalCode:N,city:f,contactName:d,contactEmail:h,contactPhone:y,maxAmountEuros:S,minScanIntervalMin:E}),a("Modifications enregistrées."),o()}},t.id)}),i.jsx(G,{path:"carte",element:i.jsx($f,{store:t,onSaved:o})}),i.jsx(G,{path:"employes",element:i.jsx(Tv,{storeId:t.id})}),i.jsx(G,{path:"modules",element:i.jsx(Uv,{storeId:t.id,storeName:t.name})}),i.jsx(G,{path:"statistiques",element:i.jsx(Wv,{storeId:t.id,storeSlug:t.slug})}),i.jsx(G,{path:"facturation",element:i.jsx(Mv,{storeId:t.id,contactEmail:t.contactEmail,onChange:o})})]})]}):r?i.jsx("div",{className:"alert error",children:r}):i.jsx("p",{className:"muted",children:"Chargement…"})}function Ou({merchant:e=!1}){const{id:t}=cf(),n=e?"/api/staff/store":`/api/admin/stores/${t}`,r=e?"/api/staff/card-design":`/api/admin/stores/${t}/card-design`,[l,s]=lo(),a=l.get("format")==="A6"?"A6":"A5",[o,u]=w.useState(null),[c,p]=w.useState(null),[m,g]=w.useState(null);return w.useEffect(()=>{Promise.all([U.get(n),U.get(r)]).then(([v,x])=>{u(v),p(x)}).catch(v=>g(v.message))},[n,r]),m?i.jsx("div",{className:"alert error",style:{margin:24},children:m}):o?c?i.jsxs("div",{className:"poster-page",children:[i.jsx("style",{children:`@page{size:${a};margin:0}@media print{.no-print{display:none!important}body{background:#fff}.poster-page{padding:0!important}}`}),i.jsxs("div",{className:"no-print row between",style:{padding:16},children:[i.jsx(De,{to:e?"/espace":`/magasins/${t}/carte`,children:"← Retour à la carte"}),i.jsxs("div",{className:"row",style:{gap:8},children:[["A5","A6"].map(v=>i.jsx("button",{type:"button",className:"chip","aria-pressed":a===v,onClick:()=>s({format:v}),children:v},v)),i.jsx("button",{type:"button",className:"btn",onClick:()=>window.print(),children:"Imprimer"})]})]}),o.status!=="ACTIVE"&&i.jsx("div",{className:"alert warn no-print",style:{margin:"0 16px 16px"},children:"Le magasin n'est pas actif : le QR mène pour l'instant à une page « introuvable » ou « indisponible »."}),i.jsx("div",{style:{display:"flex",justifyContent:"center",padding:16},className:"poster-page",children:i.jsx(Ff,{format:a,url:o.enrollUrl,storeName:o.name,programName:c.programName,logoUrl:ta(c.logoUrl),backgroundColor:c.backgroundColor,foregroundColor:c.foregroundColor,labelColor:c.labelColor,rewards:c.rewards,pointsMode:c.pointsMode})}),i.jsx("p",{className:"no-print muted",style:{textAlign:"center"},children:o.enrollUrl})]}):i.jsx("div",{className:"alert warn",style:{margin:24},children:"Concevez d'abord la carte de fidélité."}):i.jsx("p",{className:"muted",style:{margin:24},children:"Chargement…"})}const $u=e=>(e/100).toLocaleString("fr-FR",{style:"currency",currency:"EUR",minimumFractionDigits:e%100?2:0}),Bu=["ESSENTIEL","PRO","RESEAU"],Qv=[["name","Nom du commerce",{autoComplete:"organization",placeholder:"Boulangerie Kerlann",maxLength:120}],["siret","SIRET",{inputMode:"numeric",placeholder:"123 456 789 00012"}],["addressLine","Adresse",{autoComplete:"street-address",maxLength:200}],["postalCode","Code postal",{autoComplete:"postal-code",inputMode:"numeric",maxLength:5}],["city","Ville",{autoComplete:"address-level2",maxLength:120}],["contactName","Prénom et nom",{autoComplete:"name",maxLength:120}],["contactPhone","Téléphone",{autoComplete:"tel",type:"tel"}],["contactEmail","E-mail (votre identifiant de connexion)",{autoComplete:"email",type:"email"}]];function Kv(){const[e]=lo(),t=(e.get("formule")??"").toUpperCase(),[n,r]=w.useState(Bu.includes(t)?t:"PRO"),[l,s]=w.useState(e.get("periode")==="annuel"?"YEAR":"MONTH"),[a,o]=w.useState([]),[u,c]=w.useState({name:"",siret:"",addressLine:"",postalCode:"",city:"",contactName:"",contactPhone:"",contactEmail:"",password:""}),[p,m]=w.useState(!1),[g,v]=w.useState(e.get("annule")?"Paiement annulé : rien n’a été prélevé. Vous pouvez reprendre quand vous voulez.":null),[x,j]=w.useState(!1);w.useEffect(()=>{const y=S=>S.persisted&&j(!1);return window.addEventListener("pageshow",y),()=>window.removeEventListener("pageshow",y)},[]),w.useEffect(()=>{Au.get("/api/public/signup/plans").then(o).catch(()=>{})},[]);async function N(y){y.preventDefault(),j(!0),v(null);try{const{url:S}=await Au.post("/api/public/signup",{...u,plan:n,interval:l,cgv:p});window.location.assign(S)}catch(S){v(S.message),j(!1),window.scrollTo({top:0,behavior:"smooth"})}}const f=a.find(y=>y.plan===n),d=a.length?a:Bu.map(y=>({plan:y,name:ut[y],tagline:"",priceCents:{MONTH:0,YEAR:0},modules:[],limits:{maxStaff:null}})),h=y=>{const[,S,E]=Qv.find(([k])=>k===y);return i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:`s-${y}`,children:S}),i.jsx("input",{id:`s-${y}`,className:"input",required:!0,value:u[y],onChange:k=>c({...u,[y]:k.target.value}),...E})]},y)};return i.jsxs("main",{className:"s-page",children:[i.jsxs("header",{className:"s-head",children:[i.jsx("a",{href:"https://monespacepro.eu/",style:{textDecoration:"none",color:"inherit"},"aria-label":"MonEspacePro, accueil",children:i.jsx(Dr,{admin:!1})}),i.jsxs("span",{className:"muted",style:{fontSize:14},children:["Déjà inscrit ? ",i.jsx(De,{to:"/espace",children:"Se connecter"})]})]}),i.jsxs("form",{onSubmit:N,className:"s-layout",children:[i.jsxs("div",{className:"s-main",children:[i.jsxs("div",{children:[i.jsx("h1",{children:"Créer mon programme de fidélité"}),i.jsx("p",{className:"muted",style:{margin:"6px 0 0"},children:"Trois minutes, sans engagement. Votre espace est prêt dès le paiement validé."})]}),g&&i.jsx("div",{className:"alert error",role:"alert",children:g}),i.jsxs("section",{className:"card s-section",children:[i.jsxs("div",{className:"s-title",children:[i.jsx("span",{className:"s-num",children:"1"}),i.jsx("h2",{children:"Votre formule"})]}),i.jsxs("div",{role:"group","aria-label":"Périodicité",className:"s-seg",children:[i.jsx("button",{type:"button","aria-pressed":l==="MONTH",onClick:()=>s("MONTH"),children:"Mensuel"}),i.jsx("button",{type:"button","aria-pressed":l==="YEAR",onClick:()=>s("YEAR"),children:"Annuel · 2 mois offerts"})]}),i.jsx("div",{className:"s-plans",role:"radiogroup","aria-label":"Formule",children:d.map(y=>i.jsxs("label",{className:`s-plan${n===y.plan?" on":""}`,children:[i.jsx("input",{type:"radio",name:"plan",className:"sr-only",checked:n===y.plan,onChange:()=>r(y.plan)}),y.plan==="PRO"&&i.jsx("span",{className:"s-tag",children:"Conseillée"}),i.jsx("strong",{children:y.name}),y.priceCents[l]>0&&i.jsxs("span",{className:"s-price",children:[$u(y.priceCents[l]),i.jsxs("small",{children:[" / ",l==="YEAR"?"an":"mois"]})]}),i.jsx("span",{className:"muted",style:{fontSize:14},children:y.tagline})]},y.plan))})]}),i.jsxs("section",{className:"card s-section",children:[i.jsxs("div",{className:"s-title",children:[i.jsx("span",{className:"s-num",children:"2"}),i.jsx("h2",{children:"Votre commerce"})]}),h("name"),h("siret"),h("addressLine"),i.jsxs("div",{className:"s-two",children:[h("postalCode"),h("city")]})]}),i.jsxs("section",{className:"card s-section",children:[i.jsxs("div",{className:"s-title",children:[i.jsx("span",{className:"s-num",children:"3"}),i.jsx("h2",{children:"Vos identifiants"})]}),i.jsxs("div",{className:"s-two",children:[h("contactName"),h("contactPhone")]}),h("contactEmail"),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"s-password",children:"Mot de passe"}),i.jsx("input",{id:"s-password",className:"input",type:"password",required:!0,minLength:10,autoComplete:"new-password",value:u.password,onChange:y=>c({...u,password:y.target.value})}),i.jsx("span",{className:"muted",style:{fontSize:14},children:"10 caractères minimum. Il ouvre votre espace web et l’app MonEspacePro."})]})]})]}),i.jsx("aside",{className:"s-side",children:i.jsxs("section",{className:"card s-summary",children:[i.jsx("span",{className:"muted",style:{fontSize:13,textTransform:"uppercase",letterSpacing:".05em"},children:"Récapitulatif"}),i.jsxs("div",{className:"row between",style:{alignItems:"baseline"},children:[i.jsxs("strong",{style:{fontSize:20},children:["Formule ",(f==null?void 0:f.name)??ut[n]]}),f&&i.jsxs("span",{style:{fontSize:22,fontWeight:800},children:[$u(f.priceCents[l]),i.jsxs("span",{className:"muted",style:{fontSize:14,fontWeight:500},children:[" / ",l==="YEAR"?"an":"mois"]})]})]}),f&&i.jsxs("ul",{className:"s-list",children:[i.jsx("li",{children:"Carte dans Apple Wallet et Google Wallet"}),i.jsx("li",{children:f.limits.maxStaff?`${f.limits.maxStaff} employés`:"Employés illimités"}),f.modules.map(y=>i.jsx("li",{children:y.name},y.id))]}),i.jsxs("label",{className:"row",style:{gap:10,alignItems:"flex-start",flexWrap:"nowrap",fontSize:14},children:[i.jsx("input",{type:"checkbox",required:!0,checked:p,onChange:y=>m(y.target.checked),style:{marginTop:3}}),i.jsxs("span",{children:["J’accepte les ",i.jsx("a",{href:"https://monespacepro.eu/cgv/",target:"_blank",rel:"noreferrer",children:"CGV"})," et la"," ",i.jsx("a",{href:"https://monespacepro.eu/confidentialite/",target:"_blank",rel:"noreferrer",children:"politique de confidentialité"}),"."]})]}),i.jsx("button",{className:"btn",disabled:x,style:{width:"100%"},children:x?"Redirection vers le paiement…":"Continuer vers le paiement"}),i.jsxs("ul",{className:"s-trust",children:[i.jsx("li",{children:"🔒 Paiement sécurisé par Stripe"}),i.jsx("li",{children:"💳 Carte bancaire ou prélèvement SEPA"}),i.jsx("li",{children:"↩︎ Sans engagement, résiliable à tout moment"})]})]})})]})]})}function Yv({onLogin:e}){const t=Ft(),[n]=lo(),r=n.has("bienvenue"),[l,s]=w.useState(""),[a,o]=w.useState(""),[u,c]=w.useState(null),[p,m]=w.useState(!1);async function g(v){v.preventDefault(),m(!0),c(null);try{await Cg(l,a),e(),t("/espace",{replace:!0})}catch(x){c(r&&x instanceof gs&&x.status===401?"Votre espace est en cours de création. Réessayez dans quelques secondes.":x.message)}finally{m(!1)}}return i.jsx("main",{style:{minHeight:"100vh",display:"grid",placeItems:"center",padding:16},children:i.jsxs("form",{className:"card",onSubmit:g,style:{width:"100%",maxWidth:420,display:"flex",flexDirection:"column",gap:20},children:[i.jsx(Dr,{admin:!1}),r&&i.jsx("div",{className:"alert ok",children:"Paiement reçu, merci ! Connectez-vous avec l’e-mail et le mot de passe choisis à l’inscription."}),i.jsxs("div",{children:[i.jsx("h1",{style:{fontSize:26},children:"Mon espace"}),i.jsx("p",{className:"muted",style:{margin:0},children:"Mêmes identifiants que l’app MonEspacePro."})]}),u&&i.jsx("div",{className:"alert error",role:"alert",children:u}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"m-email",children:"E-mail"}),i.jsx("input",{id:"m-email",className:"input",type:"email",autoComplete:"username",required:!0,value:l,onChange:v=>s(v.target.value)})]}),i.jsxs("div",{className:"field",children:[i.jsx("label",{htmlFor:"m-password",children:"Mot de passe"}),i.jsx("input",{id:"m-password",className:"input",type:"password",autoComplete:"current-password",required:!0,value:a,onChange:v=>o(v.target.value)})]}),i.jsx("button",{className:"btn",disabled:p,children:p?"Connexion…":"Se connecter"}),i.jsxs("p",{className:"muted",style:{margin:0,fontSize:14,textAlign:"center"},children:["Pas encore client ? ",i.jsx(De,{to:"/inscription",children:"Créer mon programme"})]})]})})}function Gv(){const[e,t]=w.useState(null),[n,r]=w.useState(null),[l,s]=w.useState(!1),[a,o]=w.useState(null),u=w.useCallback(()=>{U.get("/api/staff/store").then(t).catch(x=>r(x instanceof gs&&x.status===403?"Cet espace est réservé au Dirigeant du magasin. Utilisez l’app MonEspacePro pour scanner les cartes.":x.message)),U.get("/api/staff/card-design").then(x=>o(!!x)).catch(()=>o(null))},[]);w.useEffect(u,[u]);function c(x){var j;(j=navigator.clipboard)==null||j.writeText(x).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)})}const p=!!e&&!e.subscribeUrl,m=(e==null?void 0:e.status)==="ACTIVE",g=[["Abonnement",p?`Formule ${e!=null&&e.subscription?ut[e.subscription.plan]:""} active`:"En attente du paiement",p],["Carte de fidélité",a?"Conçue":"Logo, couleurs, récompenses",!!a],["Programme ouvert",m?"Vos clients peuvent s’inscrire":"S’ouvre automatiquement",m]],v=g.findIndex(([,,x])=>!x);return i.jsxs("div",{style:{minHeight:"100vh"},children:[i.jsxs("header",{className:"m-top",children:[i.jsx(Dr,{admin:!1}),i.jsx("span",{className:"grow"}),e&&i.jsx("span",{className:"muted",style:{fontSize:14},children:e.name}),e&&i.jsx("span",{className:"m-avatar","aria-hidden":"true",children:e.name.charAt(0).toUpperCase()}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:ao,children:"Se déconnecter"})]}),i.jsxs("main",{className:"container",style:{padding:24,display:"flex",flexDirection:"column",gap:24},children:[n&&i.jsx("div",{className:"alert error",role:"alert",children:n}),!e&&!n&&i.jsx("p",{className:"muted",children:"Chargement…"}),e&&i.jsxs(i.Fragment,{children:[i.jsxs("section",{className:"m-hero",children:[i.jsxs("div",{children:[i.jsx("h1",{children:e.name}),i.jsxs("p",{children:[e.subscription?`Formule ${ut[e.subscription.plan]}`:"Aucune formule"," ·"," ",m?"programme ouvert à vos clients":e.status==="SUSPENDED"?"programme suspendu":"programme pas encore ouvert"]})]}),e.subscribeUrl&&i.jsx("a",{className:"btn",href:e.subscribeUrl,children:"Activer mon abonnement"})]}),e.status==="SUSPENDED"&&i.jsx("div",{className:"alert warn",children:"Programme suspendu. Il rouvre automatiquement dès le paiement de l’abonnement régularisé."}),i.jsx("ol",{className:"m-steps","aria-label":"Étapes d’ouverture",children:g.map(([x,j,N],f)=>i.jsxs("li",{className:`m-step${N?" done":""}${f===v?" current":""}`,"aria-current":f===v?"step":void 0,children:[i.jsx("span",{className:"dot",children:N?"✓":f+1}),i.jsxs("div",{children:[i.jsx("strong",{children:x}),i.jsx("span",{children:j})]})]},x))}),i.jsxs("div",{className:"m-grid",children:[i.jsxs("section",{className:"card m-tile",children:[i.jsx("span",{className:"ico","aria-hidden":"true",children:"🔗"}),i.jsx("h2",{children:"Lien d’inscription"}),i.jsx("p",{className:"muted",style:{margin:0,fontSize:14},children:"Vos clients s’inscrivent ici (c’est le QR code de l’affichette)."}),i.jsxs("div",{className:"m-copy",children:[i.jsx("code",{children:e.enrollUrl}),i.jsx("button",{type:"button",className:"btn secondary small",onClick:()=>c(e.enrollUrl),children:l?"Copié ✓":"Copier"})]})]}),i.jsxs("section",{className:"card m-tile",children:[i.jsx("span",{className:"ico","aria-hidden":"true",children:"🖨️"}),i.jsx("h2",{children:"Affichette du comptoir"}),i.jsx("p",{className:"muted",style:{margin:0,fontSize:14},children:"À imprimer en A5 ou A6 et à poser près de la caisse."}),i.jsx("div",{children:a?i.jsx(De,{className:"btn secondary",to:"/espace/affichette",children:"Imprimer l’affichette"}):i.jsx("span",{className:"muted",style:{fontSize:14},children:"Disponible une fois la carte conçue."})})]}),i.jsxs("section",{className:"card m-tile",children:[i.jsx("span",{className:"ico","aria-hidden":"true",children:"📱"}),i.jsx("h2",{children:"App MonEspacePro"}),i.jsx("p",{className:"muted",style:{margin:0,fontSize:14},children:"Scan des cartes, employés, modules (campagnes, anniversaire, relances…) et statistiques : avec les mêmes identifiants."})]})]}),i.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:12},children:[i.jsx("h2",{children:"Ma carte de fidélité"}),i.jsx($f,{store:e,onSaved:u,base:"/api/staff/card-design",posterHref:"/espace/affichette",draftNote:i.jsx("p",{style:{margin:0},children:e.subscribeUrl?"Votre programme s’ouvrira automatiquement dès votre abonnement activé.":"Enregistrez la carte : votre programme s’ouvre automatiquement à vos clients."})})]})]})]})]})}function qv(){const e=Ft(),t=Dt(),[n,r]=w.useState(Sg()),l=t.pathname.startsWith("/espace");w.useEffect(()=>{jg(()=>{r(null),e(l?"/espace":"/connexion")})},[e,l]);const s=i.jsx(Yv,{onLogin:()=>r("staff")});return n!=="admin"||t.pathname==="/inscription"?i.jsxs(Ji,{children:[i.jsx(G,{path:"/inscription",element:i.jsx(Kv,{})}),n==="staff"?i.jsxs(i.Fragment,{children:[i.jsx(G,{path:"/espace/affichette",element:i.jsx(Ou,{merchant:!0})}),i.jsx(G,{path:"/espace",element:i.jsx(Gv,{})}),i.jsx(G,{path:"*",element:i.jsx(yl,{to:"/espace",replace:!0})})]}):i.jsxs(i.Fragment,{children:[i.jsx(G,{path:"/espace",element:s}),i.jsx(G,{path:"/connexion",element:i.jsx(Pg,{onLogin:()=>r("admin")})}),i.jsx(G,{path:"*",element:i.jsx(yl,{to:l?"/espace":"/connexion",replace:!0})})]})]}):i.jsxs(Ji,{children:[i.jsx(G,{path:"/espace",element:s}),i.jsx(G,{path:"/magasins/:id/affichette",element:i.jsx(Ou,{})}),i.jsxs(G,{element:i.jsx(kg,{}),children:[i.jsx(G,{path:"/magasins",element:i.jsx(Ag,{})}),i.jsx(G,{path:"/magasins/nouveau",element:i.jsx(_g,{})}),i.jsx(G,{path:"/magasins/:id/*",element:i.jsx(Hv,{})})]}),i.jsx(G,{path:"*",element:i.jsx(yl,{to:"/magasins",replace:!0})})]})}ef(document.getElementById("root")).render(i.jsx(w.StrictMode,{children:i.jsx(mg,{future:{v7_startTransition:!0},children:i.jsx(qv,{})})}));