@tuongaz/seeflow 0.1.26 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/web/assets/{index-BMaMEi2a.js → index-CdNWAi1U.js} +4 -4
- package/dist/web/assets/{index.es-M1iBDKG6.js → index.es-CPyvUCV3.js} +1 -1
- package/dist/web/assets/{jspdf.es.min-xZpq8bcn.js → jspdf.es.min-Dkq0NSxE.js} +3 -3
- package/dist/web/index.html +1 -1
- package/examples/ecommerce-platform/.seeflow/{seeflow.json → architecture.json} +14 -77
- package/examples/ecommerce-platform/.seeflow/details/api-gateway.md +14 -0
- package/examples/ecommerce-platform/.seeflow/details/auth-service.md +9 -0
- package/examples/ecommerce-platform/.seeflow/details/cart-service.md +10 -0
- package/examples/ecommerce-platform/.seeflow/details/notification-service.md +13 -0
- package/examples/ecommerce-platform/.seeflow/details/order-service.md +16 -0
- package/examples/ecommerce-platform/.seeflow/details/payment-service.md +16 -0
- package/examples/ecommerce-platform/.seeflow/details/product-service.md +10 -0
- package/examples/ecommerce-platform/.seeflow/style.json +85 -0
- package/examples/order-pipeline/.seeflow/architecture.json +93 -0
- package/examples/order-pipeline/.seeflow/details/fulfillment-service.md +21 -0
- package/examples/order-pipeline/.seeflow/details/inventory-service.md +23 -0
- package/examples/order-pipeline/.seeflow/details/payment-service.md +23 -0
- package/examples/order-pipeline/.seeflow/details/post-orders.md +19 -0
- package/examples/order-pipeline/.seeflow/scripts/play.ts +2 -2
- package/examples/order-pipeline/.seeflow/style.json +42 -0
- package/package.json +1 -1
- package/src/api.ts +118 -118
- package/src/cli.ts +13 -13
- package/src/demo.ts +6 -6
- package/src/diagram.ts +4 -4
- package/src/events.ts +14 -14
- package/src/file-ref.ts +79 -0
- package/src/mcp.ts +117 -89
- package/src/merge.ts +190 -0
- package/src/operations.ts +415 -416
- package/src/proxy.ts +31 -31
- package/src/registry.ts +32 -20
- package/src/schema.ts +252 -8
- package/src/sdk-template.ts +2 -2
- package/src/sdk-writer.ts +2 -2
- package/src/server.ts +2 -2
- package/src/status-runner.ts +34 -38
- package/src/watcher.ts +165 -114
- package/examples/order-pipeline/.seeflow/seeflow.json +0 -123
|
@@ -37,7 +37,7 @@ function Qde(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"
|
|
|
37
37
|
`+o[i].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=i&&0<=s);break}}}finally{cj=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?lh(e):""}function Lhe(e){switch(e.tag){case 5:return lh(e.type);case 16:return lh("Lazy");case 13:return lh("Suspense");case 19:return lh("SuspenseList");case 0:case 2:case 15:return e=lj(e.type,!1),e;case 11:return e=lj(e.type.render,!1),e;case 1:return e=lj(e.type,!0),e;default:return""}}function IF(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 h1:return"Fragment";case d1:return"Portal";case CF:return"Profiler";case _B:return"StrictMode";case SF:return"Suspense";case LF:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Ote:return(e.displayName||"Context")+".Consumer";case qte:return(e._context.displayName||"Context")+".Provider";case RB:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case TB:return t=e.displayName||null,t!==null?t:IF(e.type)||"Memo";case Na:t=e._payload,e=e._init;try{return IF(e(t))}catch{}}return null}function Ihe(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 IF(t);case 8:return t===_B?"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 ri(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Hte(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Ehe(e){var t=Hte(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 o=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(i){r=""+i,a.call(this,i)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(i){r=""+i},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Qf(e){e._valueTracker||(e._valueTracker=Ehe(e))}function Bte(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Hte(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function v_(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 EF(e,t){var n=t.checked;return At({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function SU(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=ri(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 Vte(e,t){t=t.checked,t!=null&&PB(e,"checked",t,!1)}function AF(e,t){Vte(e,t);var n=ri(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")?PF(e,t.type,n):t.hasOwnProperty("defaultValue")&&PF(e,t.type,ri(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function LU(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 PF(e,t,n){(t!=="number"||v_(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var uh=Array.isArray;function L1(e,t,n,r){if(e=e.options,t){t={};for(var o=0;o<n.length;o++)t["$"+n[o]]=!0;for(n=0;n<e.length;n++)o=t.hasOwnProperty("$"+e[n].value),e[n].selected!==o&&(e[n].selected=o),o&&r&&(e[n].defaultSelected=!0)}else{for(n=""+ri(n),t=null,o=0;o<e.length;o++){if(e[o].value===n){e[o].selected=!0,r&&(e[o].defaultSelected=!0);return}t!==null||e[o].disabled||(t=e[o])}t!==null&&(t.selected=!0)}}function _F(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(fe(91));return At({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function IU(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(fe(92));if(uh(n)){if(1<n.length)throw Error(fe(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:ri(n)}}function $te(e,t){var n=ri(t.value),r=ri(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function EU(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function Ute(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function RF(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?Ute(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Jf,Wte=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,o){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,o)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Jf=Jf||document.createElement("div"),Jf.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Jf.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function g2(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Ch={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},Ahe=["Webkit","ms","Moz","O"];Object.keys(Ch).forEach(function(e){Ahe.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Ch[t]=Ch[e]})});function Gte(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Ch.hasOwnProperty(e)&&Ch[e]?(""+t).trim():t+"px"}function Kte(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,o=Gte(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}var Phe=At({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 TF(e,t){if(t){if(Phe[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(fe(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(fe(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(fe(61))}if(t.style!=null&&typeof t.style!="object")throw Error(fe(62))}}function jF(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 NF=null;function jB(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var zF=null,I1=null,E1=null;function AU(e){if(e=Q2(e)){if(typeof zF!="function")throw Error(fe(280));var t=e.stateNode;t&&(t=IR(t),zF(e.stateNode,e.type,t))}}function Zte(e){I1?E1?E1.push(e):E1=[e]:I1=e}function Xte(){if(I1){var e=I1,t=E1;if(E1=I1=null,AU(e),t)for(e=0;e<t.length;e++)AU(t[e])}}function Yte(e,t){return e(t)}function Qte(){}var uj=!1;function Jte(e,t,n){if(uj)return e(t,n);uj=!0;try{return Yte(e,t,n)}finally{uj=!1,(I1!==null||E1!==null)&&(Qte(),Xte())}}function k2(e,t){var n=e.stateNode;if(n===null)return null;var r=IR(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(fe(231,t,typeof n));return n}var DF=!1;if(Yo)try{var $d={};Object.defineProperty($d,"passive",{get:function(){DF=!0}}),window.addEventListener("test",$d,$d),window.removeEventListener("test",$d,$d)}catch{DF=!1}function _he(e,t,n,r,o,a,i,s,c){var l=Array.prototype.slice.call(arguments,3);try{t.apply(n,l)}catch(u){this.onError(u)}}var Sh=!1,x_=null,w_=!1,qF=null,Rhe={onError:function(e){Sh=!0,x_=e}};function The(e,t,n,r,o,a,i,s,c){Sh=!1,x_=null,_he.apply(Rhe,arguments)}function jhe(e,t,n,r,o,a,i,s,c){if(The.apply(this,arguments),Sh){if(Sh){var l=x_;Sh=!1,x_=null}else throw Error(fe(198));w_||(w_=!0,qF=l)}}function Tu(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function ene(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function PU(e){if(Tu(e)!==e)throw Error(fe(188))}function Nhe(e){var t=e.alternate;if(!t){if(t=Tu(e),t===null)throw Error(fe(188));return t!==e?null:e}for(var n=e,r=t;;){var o=n.return;if(o===null)break;var a=o.alternate;if(a===null){if(r=o.return,r!==null){n=r;continue}break}if(o.child===a.child){for(a=o.child;a;){if(a===n)return PU(o),e;if(a===r)return PU(o),t;a=a.sibling}throw Error(fe(188))}if(n.return!==r.return)n=o,r=a;else{for(var i=!1,s=o.child;s;){if(s===n){i=!0,n=o,r=a;break}if(s===r){i=!0,r=o,n=a;break}s=s.sibling}if(!i){for(s=a.child;s;){if(s===n){i=!0,n=a,r=o;break}if(s===r){i=!0,r=a,n=o;break}s=s.sibling}if(!i)throw Error(fe(189))}}if(n.alternate!==r)throw Error(fe(190))}if(n.tag!==3)throw Error(fe(188));return n.stateNode.current===n?e:t}function tne(e){return e=Nhe(e),e!==null?nne(e):null}function nne(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=nne(e);if(t!==null)return t;e=e.sibling}return null}var rne=nr.unstable_scheduleCallback,_U=nr.unstable_cancelCallback,zhe=nr.unstable_shouldYield,Dhe=nr.unstable_requestPaint,zt=nr.unstable_now,qhe=nr.unstable_getCurrentPriorityLevel,NB=nr.unstable_ImmediatePriority,one=nr.unstable_UserBlockingPriority,M_=nr.unstable_NormalPriority,Ohe=nr.unstable_LowPriority,ane=nr.unstable_IdlePriority,bR=null,vo=null;function Fhe(e){if(vo&&typeof vo.onCommitFiberRoot=="function")try{vo.onCommitFiberRoot(bR,e,void 0,(e.current.flags&128)===128)}catch{}}var Or=Math.clz32?Math.clz32:Vhe,Hhe=Math.log,Bhe=Math.LN2;function Vhe(e){return e>>>=0,e===0?32:31-(Hhe(e)/Bhe|0)|0}var e0=64,t0=4194304;function dh(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 b_(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,o=e.suspendedLanes,a=e.pingedLanes,i=n&268435455;if(i!==0){var s=i&~o;s!==0?r=dh(s):(a&=i,a!==0&&(r=dh(a)))}else i=n&~o,i!==0?r=dh(i):a!==0&&(r=dh(a));if(r===0)return 0;if(t!==0&&t!==r&&!(t&o)&&(o=r&-r,a=t&-t,o>=a||o===16&&(a&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-Or(t),o=1<<n,r|=e[n],t&=~o;return r}function $he(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 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 t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Uhe(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,o=e.expirationTimes,a=e.pendingLanes;0<a;){var i=31-Or(a),s=1<<i,c=o[i];c===-1?(!(s&n)||s&r)&&(o[i]=$he(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}}function OF(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function ine(){var e=e0;return e0<<=1,!(e0&4194240)&&(e0=64),e}function dj(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function X2(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Or(t),e[t]=n}function Whe(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<n;){var o=31-Or(n),a=1<<o;t[o]=0,r[o]=-1,e[o]=-1,n&=~a}}function zB(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Or(n),o=1<<r;o&t|e[r]&t&&(e[r]|=t),n&=~o}}var lt=0;function sne(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var cne,DB,lne,une,dne,FF=!1,n0=[],Ua=null,Wa=null,Ga=null,v2=new Map,x2=new Map,qa=[],Ghe="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function RU(e,t){switch(e){case"focusin":case"focusout":Ua=null;break;case"dragenter":case"dragleave":Wa=null;break;case"mouseover":case"mouseout":Ga=null;break;case"pointerover":case"pointerout":v2.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":x2.delete(t.pointerId)}}function Ud(e,t,n,r,o,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[o]},t!==null&&(t=Q2(t),t!==null&&DB(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,o!==null&&t.indexOf(o)===-1&&t.push(o),e)}function Khe(e,t,n,r,o){switch(t){case"focusin":return Ua=Ud(Ua,e,t,n,r,o),!0;case"dragenter":return Wa=Ud(Wa,e,t,n,r,o),!0;case"mouseover":return Ga=Ud(Ga,e,t,n,r,o),!0;case"pointerover":var a=o.pointerId;return v2.set(a,Ud(v2.get(a)||null,e,t,n,r,o)),!0;case"gotpointercapture":return a=o.pointerId,x2.set(a,Ud(x2.get(a)||null,e,t,n,r,o)),!0}return!1}function hne(e){var t=cu(e.target);if(t!==null){var n=Tu(t);if(n!==null){if(t=n.tag,t===13){if(t=ene(n),t!==null){e.blockedOn=t,dne(e.priority,function(){lne(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function U0(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=HF(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);NF=r,n.target.dispatchEvent(r),NF=null}else return t=Q2(n),t!==null&&DB(t),e.blockedOn=n,!1;t.shift()}return!0}function TU(e,t,n){U0(e)&&n.delete(t)}function Zhe(){FF=!1,Ua!==null&&U0(Ua)&&(Ua=null),Wa!==null&&U0(Wa)&&(Wa=null),Ga!==null&&U0(Ga)&&(Ga=null),v2.forEach(TU),x2.forEach(TU)}function Wd(e,t){e.blockedOn===t&&(e.blockedOn=null,FF||(FF=!0,nr.unstable_scheduleCallback(nr.unstable_NormalPriority,Zhe)))}function w2(e){function t(o){return Wd(o,e)}if(0<n0.length){Wd(n0[0],e);for(var n=1;n<n0.length;n++){var r=n0[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Ua!==null&&Wd(Ua,e),Wa!==null&&Wd(Wa,e),Ga!==null&&Wd(Ga,e),v2.forEach(t),x2.forEach(t),n=0;n<qa.length;n++)r=qa[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<qa.length&&(n=qa[0],n.blockedOn===null);)hne(n),n.blockedOn===null&&qa.shift()}var A1=aa.ReactCurrentBatchConfig,C_=!0;function Xhe(e,t,n,r){var o=lt,a=A1.transition;A1.transition=null;try{lt=1,qB(e,t,n,r)}finally{lt=o,A1.transition=a}}function Yhe(e,t,n,r){var o=lt,a=A1.transition;A1.transition=null;try{lt=4,qB(e,t,n,r)}finally{lt=o,A1.transition=a}}function qB(e,t,n,r){if(C_){var o=HF(e,t,n,r);if(o===null)wj(e,t,r,S_,n),RU(e,r);else if(Khe(o,e,t,n,r))r.stopPropagation();else if(RU(e,r),t&4&&-1<Ghe.indexOf(e)){for(;o!==null;){var a=Q2(o);if(a!==null&&cne(a),a=HF(e,t,n,r),a===null&&wj(e,t,r,S_,n),a===o)break;o=a}o!==null&&r.stopPropagation()}else wj(e,t,r,null,n)}}var S_=null;function HF(e,t,n,r){if(S_=null,e=jB(r),e=cu(e),e!==null)if(t=Tu(e),t===null)e=null;else if(n=t.tag,n===13){if(e=ene(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return S_=e,null}function fne(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(qhe()){case NB:return 1;case one:return 4;case M_:case Ohe:return 16;case ane:return 536870912;default:return 16}default:return 16}}var Va=null,OB=null,W0=null;function pne(){if(W0)return W0;var e,t=OB,n=t.length,r,o="value"in Va?Va.value:Va.textContent,a=o.length;for(e=0;e<n&&t[e]===o[e];e++);var i=n-e;for(r=1;r<=i&&t[n-r]===o[a-r];r++);return W0=o.slice(e,1<r?1-r:void 0)}function G0(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function r0(){return!0}function jU(){return!1}function ar(e){function t(n,r,o,a,i){this._reactName=n,this._targetInst=o,this.type=r,this.nativeEvent=a,this.target=i,this.currentTarget=null;for(var s in e)e.hasOwnProperty(s)&&(n=e[s],this[s]=n?n(a):a[s]);return this.isDefaultPrevented=(a.defaultPrevented!=null?a.defaultPrevented:a.returnValue===!1)?r0:jU,this.isPropagationStopped=jU,this}return At(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=r0)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=r0)},persist:function(){},isPersistent:r0}),t}var vd={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},FB=ar(vd),Y2=At({},vd,{view:0,detail:0}),Qhe=ar(Y2),hj,fj,Gd,CR=At({},Y2,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:HB,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Gd&&(Gd&&e.type==="mousemove"?(hj=e.screenX-Gd.screenX,fj=e.screenY-Gd.screenY):fj=hj=0,Gd=e),hj)},movementY:function(e){return"movementY"in e?e.movementY:fj}}),NU=ar(CR),Jhe=At({},CR,{dataTransfer:0}),e2e=ar(Jhe),t2e=At({},Y2,{relatedTarget:0}),pj=ar(t2e),n2e=At({},vd,{animationName:0,elapsedTime:0,pseudoElement:0}),r2e=ar(n2e),o2e=At({},vd,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),a2e=ar(o2e),i2e=At({},vd,{data:0}),zU=ar(i2e),s2e={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},c2e={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},l2e={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function u2e(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=l2e[e])?!!t[e]:!1}function HB(){return u2e}var d2e=At({},Y2,{key:function(e){if(e.key){var t=s2e[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=G0(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?c2e[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:HB,charCode:function(e){return e.type==="keypress"?G0(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?G0(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),h2e=ar(d2e),f2e=At({},CR,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),DU=ar(f2e),p2e=At({},Y2,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:HB}),y2e=ar(p2e),m2e=At({},vd,{propertyName:0,elapsedTime:0,pseudoElement:0}),g2e=ar(m2e),k2e=At({},CR,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),v2e=ar(k2e),x2e=[9,13,27,32],BB=Yo&&"CompositionEvent"in window,Lh=null;Yo&&"documentMode"in document&&(Lh=document.documentMode);var w2e=Yo&&"TextEvent"in window&&!Lh,yne=Yo&&(!BB||Lh&&8<Lh&&11>=Lh),qU=" ",OU=!1;function mne(e,t){switch(e){case"keyup":return x2e.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gne(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var f1=!1;function M2e(e,t){switch(e){case"compositionend":return gne(t);case"keypress":return t.which!==32?null:(OU=!0,qU);case"textInput":return e=t.data,e===qU&&OU?null:e;default:return null}}function b2e(e,t){if(f1)return e==="compositionend"||!BB&&mne(e,t)?(e=pne(),W0=OB=Va=null,f1=!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.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return yne&&t.locale!=="ko"?null:t.data;default:return null}}var C2e={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function FU(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!C2e[e.type]:t==="textarea"}function kne(e,t,n,r){Zte(r),t=L_(t,"onChange"),0<t.length&&(n=new FB("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Ih=null,M2=null;function S2e(e){Ane(e,0)}function SR(e){var t=m1(e);if(Bte(t))return e}function L2e(e,t){if(e==="change")return t}var vne=!1;if(Yo){var yj;if(Yo){var mj="oninput"in document;if(!mj){var HU=document.createElement("div");HU.setAttribute("oninput","return;"),mj=typeof HU.oninput=="function"}yj=mj}else yj=!1;vne=yj&&(!document.documentMode||9<document.documentMode)}function BU(){Ih&&(Ih.detachEvent("onpropertychange",xne),M2=Ih=null)}function xne(e){if(e.propertyName==="value"&&SR(M2)){var t=[];kne(t,M2,e,jB(e)),Jte(S2e,t)}}function I2e(e,t,n){e==="focusin"?(BU(),Ih=t,M2=n,Ih.attachEvent("onpropertychange",xne)):e==="focusout"&&BU()}function E2e(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return SR(M2)}function A2e(e,t){if(e==="click")return SR(t)}function P2e(e,t){if(e==="input"||e==="change")return SR(t)}function _2e(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Br=typeof Object.is=="function"?Object.is:_2e;function b2(e,t){if(Br(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var o=n[r];if(!bF.call(t,o)||!Br(e[o],t[o]))return!1}return!0}function VU(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function $U(e,t){var n=VU(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=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=VU(n)}}function wne(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?wne(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Mne(){for(var e=window,t=v_();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=v_(e.document)}return t}function VB(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 R2e(e){var t=Mne(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&wne(n.ownerDocument.documentElement,n)){if(r!==null&&VB(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 o=n.textContent.length,a=Math.min(r.start,o);r=r.end===void 0?a:Math.min(r.end,o),!e.extend&&a>r&&(o=r,r=a,a=o),o=$U(n,a);var i=$U(n,r);o&&i&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==i.node||e.focusOffset!==i.offset)&&(t=t.createRange(),t.setStart(o.node,o.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(i.node,i.offset)):(t.setEnd(i.node,i.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<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var T2e=Yo&&"documentMode"in document&&11>=document.documentMode,p1=null,BF=null,Eh=null,VF=!1;function UU(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;VF||p1==null||p1!==v_(r)||(r=p1,"selectionStart"in r&&VB(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}),Eh&&b2(Eh,r)||(Eh=r,r=L_(BF,"onSelect"),0<r.length&&(t=new FB("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=p1)))}function o0(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var y1={animationend:o0("Animation","AnimationEnd"),animationiteration:o0("Animation","AnimationIteration"),animationstart:o0("Animation","AnimationStart"),transitionend:o0("Transition","TransitionEnd")},gj={},bne={};Yo&&(bne=document.createElement("div").style,"AnimationEvent"in window||(delete y1.animationend.animation,delete y1.animationiteration.animation,delete y1.animationstart.animation),"TransitionEvent"in window||delete y1.transitionend.transition);function LR(e){if(gj[e])return gj[e];if(!y1[e])return e;var t=y1[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in bne)return gj[e]=t[n];return e}var Cne=LR("animationend"),Sne=LR("animationiteration"),Lne=LR("animationstart"),Ine=LR("transitionend"),Ene=new Map,WU="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function di(e,t){Ene.set(e,t),Ru(t,[e])}for(var kj=0;kj<WU.length;kj++){var vj=WU[kj],j2e=vj.toLowerCase(),N2e=vj[0].toUpperCase()+vj.slice(1);di(j2e,"on"+N2e)}di(Cne,"onAnimationEnd");di(Sne,"onAnimationIteration");di(Lne,"onAnimationStart");di("dblclick","onDoubleClick");di("focusin","onFocus");di("focusout","onBlur");di(Ine,"onTransitionEnd");W1("onMouseEnter",["mouseout","mouseover"]);W1("onMouseLeave",["mouseout","mouseover"]);W1("onPointerEnter",["pointerout","pointerover"]);W1("onPointerLeave",["pointerout","pointerover"]);Ru("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Ru("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Ru("onBeforeInput",["compositionend","keypress","textInput","paste"]);Ru("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Ru("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Ru("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var hh="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),z2e=new Set("cancel close invalid load scroll toggle".split(" ").concat(hh));function GU(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,jhe(r,t,void 0,e),e.currentTarget=null}function Ane(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],o=r.event;r=r.listeners;e:{var a=void 0;if(t)for(var i=r.length-1;0<=i;i--){var s=r[i],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&o.isPropagationStopped())break e;GU(o,s,l),a=c}else for(i=0;i<r.length;i++){if(s=r[i],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&o.isPropagationStopped())break e;GU(o,s,l),a=c}}}if(w_)throw e=qF,w_=!1,qF=null,e}function wt(e,t){var n=t[KF];n===void 0&&(n=t[KF]=new Set);var r=e+"__bubble";n.has(r)||(Pne(t,e,2,!1),n.add(r))}function xj(e,t,n){var r=0;t&&(r|=4),Pne(n,e,r,t)}var a0="_reactListening"+Math.random().toString(36).slice(2);function C2(e){if(!e[a0]){e[a0]=!0,Dte.forEach(function(n){n!=="selectionchange"&&(z2e.has(n)||xj(n,!1,e),xj(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[a0]||(t[a0]=!0,xj("selectionchange",!1,t))}}function Pne(e,t,n,r){switch(fne(t)){case 1:var o=Xhe;break;case 4:o=Yhe;break;default:o=qB}n=o.bind(null,t,n,e),o=void 0,!DF||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(o=!0),r?o!==void 0?e.addEventListener(t,n,{capture:!0,passive:o}):e.addEventListener(t,n,!0):o!==void 0?e.addEventListener(t,n,{passive:o}):e.addEventListener(t,n,!1)}function wj(e,t,n,r,o){var a=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var i=r.tag;if(i===3||i===4){var s=r.stateNode.containerInfo;if(s===o||s.nodeType===8&&s.parentNode===o)break;if(i===4)for(i=r.return;i!==null;){var c=i.tag;if((c===3||c===4)&&(c=i.stateNode.containerInfo,c===o||c.nodeType===8&&c.parentNode===o))return;i=i.return}for(;s!==null;){if(i=cu(s),i===null)return;if(c=i.tag,c===5||c===6){r=a=i;continue e}s=s.parentNode}}r=r.return}Jte(function(){var l=a,u=jB(n),d=[];e:{var f=Ene.get(e);if(f!==void 0){var p=FB,y=e;switch(e){case"keypress":if(G0(n)===0)break e;case"keydown":case"keyup":p=h2e;break;case"focusin":y="focus",p=pj;break;case"focusout":y="blur",p=pj;break;case"beforeblur":case"afterblur":p=pj;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":p=NU;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":p=e2e;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":p=y2e;break;case Cne:case Sne:case Lne:p=r2e;break;case Ine:p=g2e;break;case"scroll":p=Qhe;break;case"wheel":p=v2e;break;case"copy":case"cut":case"paste":p=a2e;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":p=DU}var k=(t&4)!==0,w=!k&&e==="scroll",v=k?f!==null?f+"Capture":null:f;k=[];for(var M=l,x;M!==null;){x=M;var b=x.stateNode;if(x.tag===5&&b!==null&&(x=b,v!==null&&(b=k2(M,v),b!=null&&k.push(S2(M,b,x)))),w)break;M=M.return}0<k.length&&(f=new p(f,y,null,n,u),d.push({event:f,listeners:k}))}}if(!(t&7)){e:{if(f=e==="mouseover"||e==="pointerover",p=e==="mouseout"||e==="pointerout",f&&n!==NF&&(y=n.relatedTarget||n.fromElement)&&(cu(y)||y[Qo]))break e;if((p||f)&&(f=u.window===u?u:(f=u.ownerDocument)?f.defaultView||f.parentWindow:window,p?(y=n.relatedTarget||n.toElement,p=l,y=y?cu(y):null,y!==null&&(w=Tu(y),y!==w||y.tag!==5&&y.tag!==6)&&(y=null)):(p=null,y=l),p!==y)){if(k=NU,b="onMouseLeave",v="onMouseEnter",M="mouse",(e==="pointerout"||e==="pointerover")&&(k=DU,b="onPointerLeave",v="onPointerEnter",M="pointer"),w=p==null?f:m1(p),x=y==null?f:m1(y),f=new k(b,M+"leave",p,n,u),f.target=w,f.relatedTarget=x,b=null,cu(u)===l&&(k=new k(v,M+"enter",y,n,u),k.target=x,k.relatedTarget=w,b=k),w=b,p&&y)t:{for(k=p,v=y,M=0,x=k;x;x=Xu(x))M++;for(x=0,b=v;b;b=Xu(b))x++;for(;0<M-x;)k=Xu(k),M--;for(;0<x-M;)v=Xu(v),x--;for(;M--;){if(k===v||v!==null&&k===v.alternate)break t;k=Xu(k),v=Xu(v)}k=null}else k=null;p!==null&&KU(d,f,p,k,!1),y!==null&&w!==null&&KU(d,w,y,k,!0)}}e:{if(f=l?m1(l):window,p=f.nodeName&&f.nodeName.toLowerCase(),p==="select"||p==="input"&&f.type==="file")var S=L2e;else if(FU(f))if(vne)S=P2e;else{S=E2e;var C=I2e}else(p=f.nodeName)&&p.toLowerCase()==="input"&&(f.type==="checkbox"||f.type==="radio")&&(S=A2e);if(S&&(S=S(e,l))){kne(d,S,n,u);break e}C&&C(e,f,l),e==="focusout"&&(C=f._wrapperState)&&C.controlled&&f.type==="number"&&PF(f,"number",f.value)}switch(C=l?m1(l):window,e){case"focusin":(FU(C)||C.contentEditable==="true")&&(p1=C,BF=l,Eh=null);break;case"focusout":Eh=BF=p1=null;break;case"mousedown":VF=!0;break;case"contextmenu":case"mouseup":case"dragend":VF=!1,UU(d,n,u);break;case"selectionchange":if(T2e)break;case"keydown":case"keyup":UU(d,n,u)}var L;if(BB)e:{switch(e){case"compositionstart":var P="onCompositionStart";break e;case"compositionend":P="onCompositionEnd";break e;case"compositionupdate":P="onCompositionUpdate";break e}P=void 0}else f1?mne(e,n)&&(P="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(P="onCompositionStart");P&&(yne&&n.locale!=="ko"&&(f1||P!=="onCompositionStart"?P==="onCompositionEnd"&&f1&&(L=pne()):(Va=u,OB="value"in Va?Va.value:Va.textContent,f1=!0)),C=L_(l,P),0<C.length&&(P=new zU(P,e,null,n,u),d.push({event:P,listeners:C}),L?P.data=L:(L=gne(n),L!==null&&(P.data=L)))),(L=w2e?M2e(e,n):b2e(e,n))&&(l=L_(l,"onBeforeInput"),0<l.length&&(u=new zU("onBeforeInput","beforeinput",null,n,u),d.push({event:u,listeners:l}),u.data=L))}Ane(d,t)})}function S2(e,t,n){return{instance:e,listener:t,currentTarget:n}}function L_(e,t){for(var n=t+"Capture",r=[];e!==null;){var o=e,a=o.stateNode;o.tag===5&&a!==null&&(o=a,a=k2(e,n),a!=null&&r.unshift(S2(e,a,o)),a=k2(e,t),a!=null&&r.push(S2(e,a,o))),e=e.return}return r}function Xu(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function KU(e,t,n,r,o){for(var a=t._reactName,i=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(c!==null&&c===r)break;s.tag===5&&l!==null&&(s=l,o?(c=k2(n,a),c!=null&&i.unshift(S2(n,c,s))):o||(c=k2(n,a),c!=null&&i.push(S2(n,c,s)))),n=n.return}i.length!==0&&e.push({event:t,listeners:i})}var D2e=/\r\n?/g,q2e=/\u0000|\uFFFD/g;function ZU(e){return(typeof e=="string"?e:""+e).replace(D2e,`
|
|
38
38
|
`).replace(q2e,"")}function i0(e,t,n){if(t=ZU(t),ZU(e)!==t&&n)throw Error(fe(425))}function I_(){}var $F=null,UF=null;function WF(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var GF=typeof setTimeout=="function"?setTimeout:void 0,O2e=typeof clearTimeout=="function"?clearTimeout:void 0,XU=typeof Promise=="function"?Promise:void 0,F2e=typeof queueMicrotask=="function"?queueMicrotask:typeof XU<"u"?function(e){return XU.resolve(null).then(e).catch(H2e)}:GF;function H2e(e){setTimeout(function(){throw e})}function Mj(e,t){var n=t,r=0;do{var o=n.nextSibling;if(e.removeChild(n),o&&o.nodeType===8)if(n=o.data,n==="/$"){if(r===0){e.removeChild(o),w2(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=o}while(n);w2(t)}function Ka(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function YU(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var xd=Math.random().toString(36).slice(2),po="__reactFiber$"+xd,L2="__reactProps$"+xd,Qo="__reactContainer$"+xd,KF="__reactEvents$"+xd,B2e="__reactListeners$"+xd,V2e="__reactHandles$"+xd;function cu(e){var t=e[po];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Qo]||n[po]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=YU(e);e!==null;){if(n=e[po])return n;e=YU(e)}return t}e=n,n=e.parentNode}return null}function Q2(e){return e=e[po]||e[Qo],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function m1(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(fe(33))}function IR(e){return e[L2]||null}var ZF=[],g1=-1;function hi(e){return{current:e}}function bt(e){0>g1||(e.current=ZF[g1],ZF[g1]=null,g1--)}function kt(e,t){g1++,ZF[g1]=e.current,e.current=t}var oi={},sn=hi(oi),Pn=hi(!1),gu=oi;function G1(e,t){var n=e.type.contextTypes;if(!n)return oi;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var o={},a;for(a in n)o[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function _n(e){return e=e.childContextTypes,e!=null}function E_(){bt(Pn),bt(sn)}function QU(e,t,n){if(sn.current!==oi)throw Error(fe(168));kt(sn,t),kt(Pn,n)}function _ne(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var o in r)if(!(o in t))throw Error(fe(108,Ihe(e)||"Unknown",o));return At({},n,r)}function A_(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||oi,gu=sn.current,kt(sn,e),kt(Pn,Pn.current),!0}function JU(e,t,n){var r=e.stateNode;if(!r)throw Error(fe(169));n?(e=_ne(e,t,gu),r.__reactInternalMemoizedMergedChildContext=e,bt(Pn),bt(sn),kt(sn,e)):bt(Pn),kt(Pn,n)}var $o=null,ER=!1,bj=!1;function Rne(e){$o===null?$o=[e]:$o.push(e)}function $2e(e){ER=!0,Rne(e)}function fi(){if(!bj&&$o!==null){bj=!0;var e=0,t=lt;try{var n=$o;for(lt=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}$o=null,ER=!1}catch(o){throw $o!==null&&($o=$o.slice(e+1)),rne(NB,fi),o}finally{lt=t,bj=!1}}return null}var k1=[],v1=0,P_=null,__=0,lr=[],ur=0,ku=null,Uo=1,Wo="";function Ri(e,t){k1[v1++]=__,k1[v1++]=P_,P_=e,__=t}function Tne(e,t,n){lr[ur++]=Uo,lr[ur++]=Wo,lr[ur++]=ku,ku=e;var r=Uo;e=Wo;var o=32-Or(r)-1;r&=~(1<<o),n+=1;var a=32-Or(t)+o;if(30<a){var i=o-o%5;a=(r&(1<<i)-1).toString(32),r>>=i,o-=i,Uo=1<<32-Or(t)+o|n<<o|r,Wo=a+e}else Uo=1<<a|n<<o|r,Wo=e}function $B(e){e.return!==null&&(Ri(e,1),Tne(e,1,0))}function UB(e){for(;e===P_;)P_=k1[--v1],k1[v1]=null,__=k1[--v1],k1[v1]=null;for(;e===ku;)ku=lr[--ur],lr[ur]=null,Wo=lr[--ur],lr[ur]=null,Uo=lr[--ur],lr[ur]=null}var Jn=null,Yn=null,St=!1,Nr=null;function jne(e,t){var n=fr(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function eW(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,Jn=e,Yn=Ka(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Jn=e,Yn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=ku!==null?{id:Uo,overflow:Wo}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=fr(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,Jn=e,Yn=null,!0):!1;default:return!1}}function XF(e){return(e.mode&1)!==0&&(e.flags&128)===0}function YF(e){if(St){var t=Yn;if(t){var n=t;if(!eW(e,t)){if(XF(e))throw Error(fe(418));t=Ka(n.nextSibling);var r=Jn;t&&eW(e,t)?jne(r,n):(e.flags=e.flags&-4097|2,St=!1,Jn=e)}}else{if(XF(e))throw Error(fe(418));e.flags=e.flags&-4097|2,St=!1,Jn=e}}}function tW(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Jn=e}function s0(e){if(e!==Jn)return!1;if(!St)return tW(e),St=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!WF(e.type,e.memoizedProps)),t&&(t=Yn)){if(XF(e))throw Nne(),Error(fe(418));for(;t;)jne(e,t),t=Ka(t.nextSibling)}if(tW(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(fe(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Yn=Ka(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Yn=null}}else Yn=Jn?Ka(e.stateNode.nextSibling):null;return!0}function Nne(){for(var e=Yn;e;)e=Ka(e.nextSibling)}function K1(){Yn=Jn=null,St=!1}function WB(e){Nr===null?Nr=[e]:Nr.push(e)}var U2e=aa.ReactCurrentBatchConfig;function Kd(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(fe(309));var r=n.stateNode}if(!r)throw Error(fe(147,e));var o=r,a=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===a?t.ref:(t=function(i){var s=o.refs;i===null?delete s[a]:s[a]=i},t._stringRef=a,t)}if(typeof e!="string")throw Error(fe(284));if(!n._owner)throw Error(fe(290,e))}return e}function c0(e,t){throw e=Object.prototype.toString.call(t),Error(fe(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function nW(e){var t=e._init;return t(e._payload)}function zne(e){function t(v,M){if(e){var x=v.deletions;x===null?(v.deletions=[M],v.flags|=16):x.push(M)}}function n(v,M){if(!e)return null;for(;M!==null;)t(v,M),M=M.sibling;return null}function r(v,M){for(v=new Map;M!==null;)M.key!==null?v.set(M.key,M):v.set(M.index,M),M=M.sibling;return v}function o(v,M){return v=Qa(v,M),v.index=0,v.sibling=null,v}function a(v,M,x){return v.index=x,e?(x=v.alternate,x!==null?(x=x.index,x<M?(v.flags|=2,M):x):(v.flags|=2,M)):(v.flags|=1048576,M)}function i(v){return e&&v.alternate===null&&(v.flags|=2),v}function s(v,M,x,b){return M===null||M.tag!==6?(M=Pj(x,v.mode,b),M.return=v,M):(M=o(M,x),M.return=v,M)}function c(v,M,x,b){var S=x.type;return S===h1?u(v,M,x.props.children,b,x.key):M!==null&&(M.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Na&&nW(S)===M.type)?(b=o(M,x.props),b.ref=Kd(v,M,x),b.return=v,b):(b=ep(x.type,x.key,x.props,null,v.mode,b),b.ref=Kd(v,M,x),b.return=v,b)}function l(v,M,x,b){return M===null||M.tag!==4||M.stateNode.containerInfo!==x.containerInfo||M.stateNode.implementation!==x.implementation?(M=_j(x,v.mode,b),M.return=v,M):(M=o(M,x.children||[]),M.return=v,M)}function u(v,M,x,b,S){return M===null||M.tag!==7?(M=pu(x,v.mode,b,S),M.return=v,M):(M=o(M,x),M.return=v,M)}function d(v,M,x){if(typeof M=="string"&&M!==""||typeof M=="number")return M=Pj(""+M,v.mode,x),M.return=v,M;if(typeof M=="object"&&M!==null){switch(M.$$typeof){case Yf:return x=ep(M.type,M.key,M.props,null,v.mode,x),x.ref=Kd(v,null,M),x.return=v,x;case d1:return M=_j(M,v.mode,x),M.return=v,M;case Na:var b=M._init;return d(v,b(M._payload),x)}if(uh(M)||Vd(M))return M=pu(M,v.mode,x,null),M.return=v,M;c0(v,M)}return null}function f(v,M,x,b){var S=M!==null?M.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return S!==null?null:s(v,M,""+x,b);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Yf:return x.key===S?c(v,M,x,b):null;case d1:return x.key===S?l(v,M,x,b):null;case Na:return S=x._init,f(v,M,S(x._payload),b)}if(uh(x)||Vd(x))return S!==null?null:u(v,M,x,b,null);c0(v,x)}return null}function p(v,M,x,b,S){if(typeof b=="string"&&b!==""||typeof b=="number")return v=v.get(x)||null,s(M,v,""+b,S);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case Yf:return v=v.get(b.key===null?x:b.key)||null,c(M,v,b,S);case d1:return v=v.get(b.key===null?x:b.key)||null,l(M,v,b,S);case Na:var C=b._init;return p(v,M,x,C(b._payload),S)}if(uh(b)||Vd(b))return v=v.get(x)||null,u(M,v,b,S,null);c0(M,b)}return null}function y(v,M,x,b){for(var S=null,C=null,L=M,P=M=0,T=null;L!==null&&P<x.length;P++){L.index>P?(T=L,L=null):T=L.sibling;var _=f(v,L,x[P],b);if(_===null){L===null&&(L=T);break}e&&L&&_.alternate===null&&t(v,L),M=a(_,M,P),C===null?S=_:C.sibling=_,C=_,L=T}if(P===x.length)return n(v,L),St&&Ri(v,P),S;if(L===null){for(;P<x.length;P++)L=d(v,x[P],b),L!==null&&(M=a(L,M,P),C===null?S=L:C.sibling=L,C=L);return St&&Ri(v,P),S}for(L=r(v,L);P<x.length;P++)T=p(L,v,P,x[P],b),T!==null&&(e&&T.alternate!==null&&L.delete(T.key===null?P:T.key),M=a(T,M,P),C===null?S=T:C.sibling=T,C=T);return e&&L.forEach(function(A){return t(v,A)}),St&&Ri(v,P),S}function k(v,M,x,b){var S=Vd(x);if(typeof S!="function")throw Error(fe(150));if(x=S.call(x),x==null)throw Error(fe(151));for(var C=S=null,L=M,P=M=0,T=null,_=x.next();L!==null&&!_.done;P++,_=x.next()){L.index>P?(T=L,L=null):T=L.sibling;var A=f(v,L,_.value,b);if(A===null){L===null&&(L=T);break}e&&L&&A.alternate===null&&t(v,L),M=a(A,M,P),C===null?S=A:C.sibling=A,C=A,L=T}if(_.done)return n(v,L),St&&Ri(v,P),S;if(L===null){for(;!_.done;P++,_=x.next())_=d(v,_.value,b),_!==null&&(M=a(_,M,P),C===null?S=_:C.sibling=_,C=_);return St&&Ri(v,P),S}for(L=r(v,L);!_.done;P++,_=x.next())_=p(L,v,P,_.value,b),_!==null&&(e&&_.alternate!==null&&L.delete(_.key===null?P:_.key),M=a(_,M,P),C===null?S=_:C.sibling=_,C=_);return e&&L.forEach(function(I){return t(v,I)}),St&&Ri(v,P),S}function w(v,M,x,b){if(typeof x=="object"&&x!==null&&x.type===h1&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case Yf:e:{for(var S=x.key,C=M;C!==null;){if(C.key===S){if(S=x.type,S===h1){if(C.tag===7){n(v,C.sibling),M=o(C,x.props.children),M.return=v,v=M;break e}}else if(C.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Na&&nW(S)===C.type){n(v,C.sibling),M=o(C,x.props),M.ref=Kd(v,C,x),M.return=v,v=M;break e}n(v,C);break}else t(v,C);C=C.sibling}x.type===h1?(M=pu(x.props.children,v.mode,b,x.key),M.return=v,v=M):(b=ep(x.type,x.key,x.props,null,v.mode,b),b.ref=Kd(v,M,x),b.return=v,v=b)}return i(v);case d1:e:{for(C=x.key;M!==null;){if(M.key===C)if(M.tag===4&&M.stateNode.containerInfo===x.containerInfo&&M.stateNode.implementation===x.implementation){n(v,M.sibling),M=o(M,x.children||[]),M.return=v,v=M;break e}else{n(v,M);break}else t(v,M);M=M.sibling}M=_j(x,v.mode,b),M.return=v,v=M}return i(v);case Na:return C=x._init,w(v,M,C(x._payload),b)}if(uh(x))return y(v,M,x,b);if(Vd(x))return k(v,M,x,b);c0(v,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,M!==null&&M.tag===6?(n(v,M.sibling),M=o(M,x),M.return=v,v=M):(n(v,M),M=Pj(x,v.mode,b),M.return=v,v=M),i(v)):n(v,M)}return w}var Z1=zne(!0),Dne=zne(!1),R_=hi(null),T_=null,x1=null,GB=null;function KB(){GB=x1=T_=null}function ZB(e){var t=R_.current;bt(R_),e._currentValue=t}function QF(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 P1(e,t){T_=e,GB=x1=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(En=!0),e.firstContext=null)}function mr(e){var t=e._currentValue;if(GB!==e)if(e={context:e,memoizedValue:t,next:null},x1===null){if(T_===null)throw Error(fe(308));x1=e,T_.dependencies={lanes:0,firstContext:e}}else x1=x1.next=e;return t}var lu=null;function XB(e){lu===null?lu=[e]:lu.push(e)}function qne(e,t,n,r){var o=t.interleaved;return o===null?(n.next=n,XB(t)):(n.next=o.next,o.next=n),t.interleaved=n,Jo(e,r)}function Jo(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 za=!1;function YB(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function One(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 Xo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Za(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,tt&2){var o=r.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),r.pending=t,Jo(e,n)}return o=r.interleaved,o===null?(t.next=t,XB(r)):(t.next=o.next,o.next=t),r.interleaved=t,Jo(e,n)}function K0(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,zB(e,n)}}function rW(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var o=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?o=a=i:a=a.next=i,n=n.next}while(n!==null);a===null?o=a=t:a=a.next=t}else o=a=t;n={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:a,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 j_(e,t,n,r){var o=e.updateQueue;za=!1;var a=o.firstBaseUpdate,i=o.lastBaseUpdate,s=o.shared.pending;if(s!==null){o.shared.pending=null;var c=s,l=c.next;c.next=null,i===null?a=l:i.next=l,i=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==i&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=o.baseState;i=0,u=l=c=null,s=a;do{var f=s.lane,p=s.eventTime;if((r&f)===f){u!==null&&(u=u.next={eventTime:p,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var y=e,k=s;switch(f=t,p=n,k.tag){case 1:if(y=k.payload,typeof y=="function"){d=y.call(p,d,f);break e}d=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=k.payload,f=typeof y=="function"?y.call(p,d,f):y,f==null)break e;d=At({},d,f);break e;case 2:za=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=o.effects,f===null?o.effects=[s]:f.push(s))}else p={eventTime:p,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,i|=f;if(s=s.next,s===null){if(s=o.shared.pending,s===null)break;f=s,s=f.next,f.next=null,o.lastBaseUpdate=f,o.shared.pending=null}}while(!0);if(u===null&&(c=d),o.baseState=c,o.firstBaseUpdate=l,o.lastBaseUpdate=u,t=o.shared.interleaved,t!==null){o=t;do i|=o.lane,o=o.next;while(o!==t)}else a===null&&(o.shared.lanes=0);xu|=i,e.lanes=i,e.memoizedState=d}}function oW(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],o=r.callback;if(o!==null){if(r.callback=null,r=n,typeof o!="function")throw Error(fe(191,o));o.call(r)}}}var J2={},xo=hi(J2),I2=hi(J2),E2=hi(J2);function uu(e){if(e===J2)throw Error(fe(174));return e}function QB(e,t){switch(kt(E2,t),kt(I2,e),kt(xo,J2),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:RF(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=RF(t,e)}bt(xo),kt(xo,t)}function X1(){bt(xo),bt(I2),bt(E2)}function Fne(e){uu(E2.current);var t=uu(xo.current),n=RF(t,e.type);t!==n&&(kt(I2,e),kt(xo,n))}function JB(e){I2.current===e&&(bt(xo),bt(I2))}var It=hi(0);function N_(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Cj=[];function eV(){for(var e=0;e<Cj.length;e++)Cj[e]._workInProgressVersionPrimary=null;Cj.length=0}var Z0=aa.ReactCurrentDispatcher,Sj=aa.ReactCurrentBatchConfig,vu=0,Et=null,Ut=null,Zt=null,z_=!1,Ah=!1,A2=0,W2e=0;function nn(){throw Error(fe(321))}function tV(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Br(e[n],t[n]))return!1;return!0}function nV(e,t,n,r,o,a){if(vu=a,Et=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Z0.current=e===null||e.memoizedState===null?X2e:Y2e,e=n(r,o),Ah){a=0;do{if(Ah=!1,A2=0,25<=a)throw Error(fe(301));a+=1,Zt=Ut=null,t.updateQueue=null,Z0.current=Q2e,e=n(r,o)}while(Ah)}if(Z0.current=D_,t=Ut!==null&&Ut.next!==null,vu=0,Zt=Ut=Et=null,z_=!1,t)throw Error(fe(300));return e}function rV(){var e=A2!==0;return A2=0,e}function lo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Zt===null?Et.memoizedState=Zt=e:Zt=Zt.next=e,Zt}function gr(){if(Ut===null){var e=Et.alternate;e=e!==null?e.memoizedState:null}else e=Ut.next;var t=Zt===null?Et.memoizedState:Zt.next;if(t!==null)Zt=t,Ut=e;else{if(e===null)throw Error(fe(310));Ut=e,e={memoizedState:Ut.memoizedState,baseState:Ut.baseState,baseQueue:Ut.baseQueue,queue:Ut.queue,next:null},Zt===null?Et.memoizedState=Zt=e:Zt=Zt.next=e}return Zt}function P2(e,t){return typeof t=="function"?t(e):t}function Lj(e){var t=gr(),n=t.queue;if(n===null)throw Error(fe(311));n.lastRenderedReducer=e;var r=Ut,o=r.baseQueue,a=n.pending;if(a!==null){if(o!==null){var i=o.next;o.next=a.next,a.next=i}r.baseQueue=o=a,n.pending=null}if(o!==null){a=o.next,r=r.baseState;var s=i=null,c=null,l=a;do{var u=l.lane;if((vu&u)===u)c!==null&&(c=c.next={lane:0,action:l.action,hasEagerState:l.hasEagerState,eagerState:l.eagerState,next:null}),r=l.hasEagerState?l.eagerState:e(r,l.action);else{var d={lane:u,action:l.action,hasEagerState:l.hasEagerState,eagerState:l.eagerState,next:null};c===null?(s=c=d,i=r):c=c.next=d,Et.lanes|=u,xu|=u}l=l.next}while(l!==null&&l!==a);c===null?i=r:c.next=s,Br(r,t.memoizedState)||(En=!0),t.memoizedState=r,t.baseState=i,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){o=e;do a=o.lane,Et.lanes|=a,xu|=a,o=o.next;while(o!==e)}else o===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Ij(e){var t=gr(),n=t.queue;if(n===null)throw Error(fe(311));n.lastRenderedReducer=e;var r=n.dispatch,o=n.pending,a=t.memoizedState;if(o!==null){n.pending=null;var i=o=o.next;do a=e(a,i.action),i=i.next;while(i!==o);Br(a,t.memoizedState)||(En=!0),t.memoizedState=a,t.baseQueue===null&&(t.baseState=a),n.lastRenderedState=a}return[a,r]}function Hne(){}function Bne(e,t){var n=Et,r=gr(),o=t(),a=!Br(r.memoizedState,o);if(a&&(r.memoizedState=o,En=!0),r=r.queue,oV(Une.bind(null,n,r,e),[e]),r.getSnapshot!==t||a||Zt!==null&&Zt.memoizedState.tag&1){if(n.flags|=2048,_2(9,$ne.bind(null,n,r,o,t),void 0,null),Xt===null)throw Error(fe(349));vu&30||Vne(n,t,o)}return o}function Vne(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Et.updateQueue,t===null?(t={lastEffect:null,stores:null},Et.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function $ne(e,t,n,r){t.value=n,t.getSnapshot=r,Wne(t)&&Gne(e)}function Une(e,t,n){return n(function(){Wne(t)&&Gne(e)})}function Wne(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Br(e,n)}catch{return!0}}function Gne(e){var t=Jo(e,1);t!==null&&Fr(t,e,1,-1)}function aW(e){var t=lo();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:P2,lastRenderedState:e},t.queue=e,e=e.dispatch=Z2e.bind(null,Et,e),[t.memoizedState,e]}function _2(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Et.updateQueue,t===null?(t={lastEffect:null,stores:null},Et.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function Kne(){return gr().memoizedState}function X0(e,t,n,r){var o=lo();Et.flags|=e,o.memoizedState=_2(1|t,n,void 0,r===void 0?null:r)}function AR(e,t,n,r){var o=gr();r=r===void 0?null:r;var a=void 0;if(Ut!==null){var i=Ut.memoizedState;if(a=i.destroy,r!==null&&tV(r,i.deps)){o.memoizedState=_2(t,n,a,r);return}}Et.flags|=e,o.memoizedState=_2(1|t,n,a,r)}function iW(e,t){return X0(8390656,8,e,t)}function oV(e,t){return AR(2048,8,e,t)}function Zne(e,t){return AR(4,2,e,t)}function Xne(e,t){return AR(4,4,e,t)}function Yne(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Qne(e,t,n){return n=n!=null?n.concat([e]):null,AR(4,4,Yne.bind(null,t,e),n)}function aV(){}function Jne(e,t){var n=gr();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&tV(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ere(e,t){var n=gr();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&tV(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function tre(e,t,n){return vu&21?(Br(n,t)||(n=ine(),Et.lanes|=n,xu|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,En=!0),e.memoizedState=n)}function G2e(e,t){var n=lt;lt=n!==0&&4>n?n:4,e(!0);var r=Sj.transition;Sj.transition={};try{e(!1),t()}finally{lt=n,Sj.transition=r}}function nre(){return gr().memoizedState}function K2e(e,t,n){var r=Ya(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},rre(e))ore(t,n);else if(n=qne(e,t,n,r),n!==null){var o=pn();Fr(n,e,r,o),are(n,t,r)}}function Z2e(e,t,n){var r=Ya(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(rre(e))ore(t,o);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var i=t.lastRenderedState,s=a(i,n);if(o.hasEagerState=!0,o.eagerState=s,Br(s,i)){var c=t.interleaved;c===null?(o.next=o,XB(t)):(o.next=c.next,c.next=o),t.interleaved=o;return}}catch{}finally{}n=qne(e,t,o,r),n!==null&&(o=pn(),Fr(n,e,r,o),are(n,t,r))}}function rre(e){var t=e.alternate;return e===Et||t!==null&&t===Et}function ore(e,t){Ah=z_=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function are(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,zB(e,n)}}var D_={readContext:mr,useCallback:nn,useContext:nn,useEffect:nn,useImperativeHandle:nn,useInsertionEffect:nn,useLayoutEffect:nn,useMemo:nn,useReducer:nn,useRef:nn,useState:nn,useDebugValue:nn,useDeferredValue:nn,useTransition:nn,useMutableSource:nn,useSyncExternalStore:nn,useId:nn,unstable_isNewReconciler:!1},X2e={readContext:mr,useCallback:function(e,t){return lo().memoizedState=[e,t===void 0?null:t],e},useContext:mr,useEffect:iW,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,X0(4194308,4,Yne.bind(null,t,e),n)},useLayoutEffect:function(e,t){return X0(4194308,4,e,t)},useInsertionEffect:function(e,t){return X0(4,2,e,t)},useMemo:function(e,t){var n=lo();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=lo();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=K2e.bind(null,Et,e),[r.memoizedState,e]},useRef:function(e){var t=lo();return e={current:e},t.memoizedState=e},useState:aW,useDebugValue:aV,useDeferredValue:function(e){return lo().memoizedState=e},useTransition:function(){var e=aW(!1),t=e[0];return e=G2e.bind(null,e[1]),lo().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Et,o=lo();if(St){if(n===void 0)throw Error(fe(407));n=n()}else{if(n=t(),Xt===null)throw Error(fe(349));vu&30||Vne(r,t,n)}o.memoizedState=n;var a={value:n,getSnapshot:t};return o.queue=a,iW(Une.bind(null,r,a,e),[e]),r.flags|=2048,_2(9,$ne.bind(null,r,a,n,t),void 0,null),n},useId:function(){var e=lo(),t=Xt.identifierPrefix;if(St){var n=Wo,r=Uo;n=(r&~(1<<32-Or(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=A2++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=W2e++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},Y2e={readContext:mr,useCallback:Jne,useContext:mr,useEffect:oV,useImperativeHandle:Qne,useInsertionEffect:Zne,useLayoutEffect:Xne,useMemo:ere,useReducer:Lj,useRef:Kne,useState:function(){return Lj(P2)},useDebugValue:aV,useDeferredValue:function(e){var t=gr();return tre(t,Ut.memoizedState,e)},useTransition:function(){var e=Lj(P2)[0],t=gr().memoizedState;return[e,t]},useMutableSource:Hne,useSyncExternalStore:Bne,useId:nre,unstable_isNewReconciler:!1},Q2e={readContext:mr,useCallback:Jne,useContext:mr,useEffect:oV,useImperativeHandle:Qne,useInsertionEffect:Zne,useLayoutEffect:Xne,useMemo:ere,useReducer:Ij,useRef:Kne,useState:function(){return Ij(P2)},useDebugValue:aV,useDeferredValue:function(e){var t=gr();return Ut===null?t.memoizedState=e:tre(t,Ut.memoizedState,e)},useTransition:function(){var e=Ij(P2)[0],t=gr().memoizedState;return[e,t]},useMutableSource:Hne,useSyncExternalStore:Bne,useId:nre,unstable_isNewReconciler:!1};function Rr(e,t){if(e&&e.defaultProps){t=At({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function JF(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:At({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var PR={isMounted:function(e){return(e=e._reactInternals)?Tu(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=pn(),o=Ya(e),a=Xo(r,o);a.payload=t,n!=null&&(a.callback=n),t=Za(e,a,o),t!==null&&(Fr(t,e,o,r),K0(t,e,o))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=pn(),o=Ya(e),a=Xo(r,o);a.tag=1,a.payload=t,n!=null&&(a.callback=n),t=Za(e,a,o),t!==null&&(Fr(t,e,o,r),K0(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=pn(),r=Ya(e),o=Xo(n,r);o.tag=2,t!=null&&(o.callback=t),t=Za(e,o,r),t!==null&&(Fr(t,e,r,n),K0(t,e,r))}};function sW(e,t,n,r,o,a,i){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,a,i):t.prototype&&t.prototype.isPureReactComponent?!b2(n,r)||!b2(o,a):!0}function ire(e,t,n){var r=!1,o=oi,a=t.contextType;return typeof a=="object"&&a!==null?a=mr(a):(o=_n(t)?gu:sn.current,r=t.contextTypes,a=(r=r!=null)?G1(e,o):oi),t=new t(n,a),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=PR,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=o,e.__reactInternalMemoizedMaskedChildContext=a),t}function cW(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&PR.enqueueReplaceState(t,t.state,null)}function eH(e,t,n,r){var o=e.stateNode;o.props=n,o.state=e.memoizedState,o.refs={},YB(e);var a=t.contextType;typeof a=="object"&&a!==null?o.context=mr(a):(a=_n(t)?gu:sn.current,o.context=G1(e,a)),o.state=e.memoizedState,a=t.getDerivedStateFromProps,typeof a=="function"&&(JF(e,t,a,n),o.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof o.getSnapshotBeforeUpdate=="function"||typeof o.UNSAFE_componentWillMount!="function"&&typeof o.componentWillMount!="function"||(t=o.state,typeof o.componentWillMount=="function"&&o.componentWillMount(),typeof o.UNSAFE_componentWillMount=="function"&&o.UNSAFE_componentWillMount(),t!==o.state&&PR.enqueueReplaceState(o,o.state,null),j_(e,n,o,r),o.state=e.memoizedState),typeof o.componentDidMount=="function"&&(e.flags|=4194308)}function Y1(e,t){try{var n="",r=t;do n+=Lhe(r),r=r.return;while(r);var o=n}catch(a){o=`
|
|
39
39
|
Error generating stack: `+a.message+`
|
|
40
|
-
`+a.stack}return{value:e,source:t,stack:o,digest:null}}function Ej(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function tH(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var J2e=typeof WeakMap=="function"?WeakMap:Map;function sre(e,t,n){n=Xo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){O_||(O_=!0,dH=r),tH(e,t)},n}function cre(e,t,n){n=Xo(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var o=t.value;n.payload=function(){return r(o)},n.callback=function(){tH(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch=="function"&&(n.callback=function(){tH(e,t),typeof r!="function"&&(Xa===null?Xa=new Set([this]):Xa.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function lW(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new J2e;var o=new Set;r.set(t,o)}else o=r.get(t),o===void 0&&(o=new Set,r.set(t,o));o.has(n)||(o.add(n),e=ffe.bind(null,e,t,n),t.then(e,e))}function uW(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function dW(e,t,n,r,o){return e.mode&1?(e.flags|=65536,e.lanes=o,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Xo(-1,1),t.tag=2,Za(n,t,1))),n.lanes|=1),e)}var efe=aa.ReactCurrentOwner,En=!1;function hn(e,t,n,r){t.child=e===null?Dne(t,null,n,r):Z1(t,e.child,n,r)}function hW(e,t,n,r,o){n=n.render;var a=t.ref;return P1(t,o),r=nV(e,t,n,r,a,o),n=rV(),e!==null&&!En?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,ea(e,t,o)):(St&&n&&$B(t),t.flags|=1,hn(e,t,r,o),t.child)}function fW(e,t,n,r,o){if(e===null){var a=n.type;return typeof a=="function"&&!fV(a)&&a.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=a,lre(e,t,a,r,o)):(e=ep(n.type,null,r,t,t.mode,o),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!(e.lanes&o)){var i=a.memoizedProps;if(n=n.compare,n=n!==null?n:b2,n(i,r)&&e.ref===t.ref)return ea(e,t,o)}return t.flags|=1,e=Qa(a,r),e.ref=t.ref,e.return=t,t.child=e}function lre(e,t,n,r,o){if(e!==null){var a=e.memoizedProps;if(b2(a,r)&&e.ref===t.ref)if(En=!1,t.pendingProps=r=a,(e.lanes&o)!==0)e.flags&131072&&(En=!0);else return t.lanes=e.lanes,ea(e,t,o)}return nH(e,t,n,r,o)}function ure(e,t,n){var r=t.pendingProps,o=r.children,a=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},kt(M1,Gn),Gn|=n;else{if(!(n&1073741824))return e=a!==null?a.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,kt(M1,Gn),Gn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a!==null?a.baseLanes:n,kt(M1,Gn),Gn|=r}else a!==null?(r=a.baseLanes|n,t.memoizedState=null):r=n,kt(M1,Gn),Gn|=r;return hn(e,t,o,n),t.child}function dre(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function nH(e,t,n,r,o){var a=_n(n)?gu:sn.current;return a=G1(t,a),P1(t,o),n=nV(e,t,n,r,a,o),r=rV(),e!==null&&!En?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,ea(e,t,o)):(St&&r&&$B(t),t.flags|=1,hn(e,t,n,o),t.child)}function pW(e,t,n,r,o){if(_n(n)){var a=!0;A_(t)}else a=!1;if(P1(t,o),t.stateNode===null)Y0(e,t),ire(t,n,r),eH(t,n,r,o),r=!0;else if(e===null){var i=t.stateNode,s=t.memoizedProps;i.props=s;var c=i.context,l=n.contextType;typeof l=="object"&&l!==null?l=mr(l):(l=_n(n)?gu:sn.current,l=G1(t,l));var u=n.getDerivedStateFromProps,d=typeof u=="function"||typeof i.getSnapshotBeforeUpdate=="function";d||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(s!==r||c!==l)&&cW(t,i,r,l),za=!1;var f=t.memoizedState;i.state=f,j_(t,r,i,o),c=t.memoizedState,s!==r||f!==c||Pn.current||za?(typeof u=="function"&&(JF(t,n,u,r),c=t.memoizedState),(s=za||sW(t,n,s,r,f,c,l))?(d||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(t.flags|=4194308)):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),i.props=r,i.state=c,i.context=l,r=s):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,One(e,t),s=t.memoizedProps,l=t.type===t.elementType?s:Rr(t.type,s),i.props=l,d=t.pendingProps,f=i.context,c=n.contextType,typeof c=="object"&&c!==null?c=mr(c):(c=_n(n)?gu:sn.current,c=G1(t,c));var p=n.getDerivedStateFromProps;(u=typeof p=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(s!==d||f!==c)&&cW(t,i,r,c),za=!1,f=t.memoizedState,i.state=f,j_(t,r,i,o);var y=t.memoizedState;s!==d||f!==y||Pn.current||za?(typeof p=="function"&&(JF(t,n,p,r),y=t.memoizedState),(l=za||sW(t,n,l,r,f,y,c)||!1)?(u||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,y,c),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,y,c)),typeof i.componentDidUpdate=="function"&&(t.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof i.componentDidUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=y),i.props=r,i.state=y,i.context=c,r=l):(typeof i.componentDidUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return rH(e,t,n,r,a,o)}function rH(e,t,n,r,o,a){dre(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return o&&JU(t,n,!1),ea(e,t,a);r=t.stateNode,efe.current=t;var s=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=Z1(t,e.child,null,a),t.child=Z1(t,null,s,a)):hn(e,t,s,a),t.memoizedState=r.state,o&&JU(t,n,!0),t.child}function hre(e){var t=e.stateNode;t.pendingContext?QU(e,t.pendingContext,t.pendingContext!==t.context):t.context&&QU(e,t.context,!1),QB(e,t.containerInfo)}function yW(e,t,n,r,o){return K1(),WB(o),t.flags|=256,hn(e,t,n,r),t.child}var oH={dehydrated:null,treeContext:null,retryLane:0};function aH(e){return{baseLanes:e,cachePool:null,transitions:null}}function fre(e,t,n){var r=t.pendingProps,o=It.current,a=!1,i=(t.flags&128)!==0,s;if((s=i)||(s=e!==null&&e.memoizedState===null?!1:(o&2)!==0),s?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(o|=1),kt(It,o&1),e===null)return YF(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(i=r.children,e=r.fallback,a?(r=t.mode,a=t.child,i={mode:"hidden",children:i},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=i):a=TR(i,r,0,null),e=pu(e,r,n,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=aH(n),t.memoizedState=oH,e):iV(t,i));if(o=e.memoizedState,o!==null&&(s=o.dehydrated,s!==null))return tfe(e,t,i,r,s,o,n);if(a){a=r.fallback,i=t.mode,o=e.child,s=o.sibling;var c={mode:"hidden",children:r.children};return!(i&1)&&t.child!==o?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=Qa(o,c),r.subtreeFlags=o.subtreeFlags&14680064),s!==null?a=Qa(s,a):(a=pu(a,i,n,null),a.flags|=2),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,i=e.child.memoizedState,i=i===null?aH(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},a.memoizedState=i,a.childLanes=e.childLanes&~n,t.memoizedState=oH,r}return a=e.child,e=a.sibling,r=Qa(a,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function iV(e,t){return t=TR({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function l0(e,t,n,r){return r!==null&&WB(r),Z1(t,e.child,null,n),e=iV(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function tfe(e,t,n,r,o,a,i){if(n)return t.flags&256?(t.flags&=-257,r=Ej(Error(fe(422))),l0(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(a=r.fallback,o=t.mode,r=TR({mode:"visible",children:r.children},o,0,null),a=pu(a,o,i,null),a.flags|=2,r.return=t,a.return=t,r.sibling=a,t.child=r,t.mode&1&&Z1(t,e.child,null,i),t.child.memoizedState=aH(i),t.memoizedState=oH,a);if(!(t.mode&1))return l0(e,t,i,null);if(o.data==="$!"){if(r=o.nextSibling&&o.nextSibling.dataset,r)var s=r.dgst;return r=s,a=Error(fe(419)),r=Ej(a,r,void 0),l0(e,t,i,r)}if(s=(i&e.childLanes)!==0,En||s){if(r=Xt,r!==null){switch(i&-i){case 4:o=2;break;case 16:o=8;break;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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:o=32;break;case 536870912:o=268435456;break;default:o=0}o=o&(r.suspendedLanes|i)?0:o,o!==0&&o!==a.retryLane&&(a.retryLane=o,Jo(e,o),Fr(r,e,o,-1))}return hV(),r=Ej(Error(fe(421))),l0(e,t,i,r)}return o.data==="$?"?(t.flags|=128,t.child=e.child,t=pfe.bind(null,e),o._reactRetry=t,null):(e=a.treeContext,Yn=Ka(o.nextSibling),Jn=t,St=!0,Nr=null,e!==null&&(lr[ur++]=Uo,lr[ur++]=Wo,lr[ur++]=ku,Uo=e.id,Wo=e.overflow,ku=t),t=iV(t,r.children),t.flags|=4096,t)}function mW(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),QF(e.return,t,n)}function Aj(e,t,n,r,o){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:o}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailMode=o)}function pre(e,t,n){var r=t.pendingProps,o=r.revealOrder,a=r.tail;if(hn(e,t,r.children,n),r=It.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&mW(e,n,t);else if(e.tag===19)mW(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(kt(It,r),!(t.mode&1))t.memoizedState=null;else switch(o){case"forwards":for(n=t.child,o=null;n!==null;)e=n.alternate,e!==null&&N_(e)===null&&(o=n),n=n.sibling;n=o,n===null?(o=t.child,t.child=null):(o=n.sibling,n.sibling=null),Aj(t,!1,o,n,a);break;case"backwards":for(n=null,o=t.child,t.child=null;o!==null;){if(e=o.alternate,e!==null&&N_(e)===null){t.child=o;break}e=o.sibling,o.sibling=n,n=o,o=e}Aj(t,!0,n,null,a);break;case"together":Aj(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Y0(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ea(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),xu|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(fe(153));if(t.child!==null){for(e=t.child,n=Qa(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Qa(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function nfe(e,t,n){switch(t.tag){case 3:hre(t),K1();break;case 5:Fne(t);break;case 1:_n(t.type)&&A_(t);break;case 4:QB(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,o=t.memoizedProps.value;kt(R_,r._currentValue),r._currentValue=o;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(kt(It,It.current&1),t.flags|=128,null):n&t.child.childLanes?fre(e,t,n):(kt(It,It.current&1),e=ea(e,t,n),e!==null?e.sibling:null);kt(It,It.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return pre(e,t,n);t.flags|=128}if(o=t.memoizedState,o!==null&&(o.rendering=null,o.tail=null,o.lastEffect=null),kt(It,It.current),r)break;return null;case 22:case 23:return t.lanes=0,ure(e,t,n)}return ea(e,t,n)}var yre,iH,mre,gre;yre=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};iH=function(){};mre=function(e,t,n,r){var o=e.memoizedProps;if(o!==r){e=t.stateNode,uu(xo.current);var a=null;switch(n){case"input":o=EF(e,o),r=EF(e,r),a=[];break;case"select":o=At({},o,{value:void 0}),r=At({},r,{value:void 0}),a=[];break;case"textarea":o=_F(e,o),r=_F(e,r),a=[];break;default:typeof o.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=I_)}TF(n,r);var i;n=null;for(l in o)if(!r.hasOwnProperty(l)&&o.hasOwnProperty(l)&&o[l]!=null)if(l==="style"){var s=o[l];for(i in s)s.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else l!=="dangerouslySetInnerHTML"&&l!=="children"&&l!=="suppressContentEditableWarning"&&l!=="suppressHydrationWarning"&&l!=="autoFocus"&&(m2.hasOwnProperty(l)?a||(a=[]):(a=a||[]).push(l,null));for(l in r){var c=r[l];if(s=o!=null?o[l]:void 0,r.hasOwnProperty(l)&&c!==s&&(c!=null||s!=null))if(l==="style")if(s){for(i in s)!s.hasOwnProperty(i)||c&&c.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in c)c.hasOwnProperty(i)&&s[i]!==c[i]&&(n||(n={}),n[i]=c[i])}else n||(a||(a=[]),a.push(l,n)),n=c;else l==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,s=s?s.__html:void 0,c!=null&&s!==c&&(a=a||[]).push(l,c)):l==="children"?typeof c!="string"&&typeof c!="number"||(a=a||[]).push(l,""+c):l!=="suppressContentEditableWarning"&&l!=="suppressHydrationWarning"&&(m2.hasOwnProperty(l)?(c!=null&&l==="onScroll"&&wt("scroll",e),a||s===c||(a=[])):(a=a||[]).push(l,c))}n&&(a=a||[]).push("style",n);var l=a;(t.updateQueue=l)&&(t.flags|=4)}};gre=function(e,t,n,r){n!==r&&(t.flags|=4)};function Zd(e,t){if(!St)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function rn(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var o=e.child;o!==null;)n|=o.lanes|o.childLanes,r|=o.subtreeFlags&14680064,r|=o.flags&14680064,o.return=e,o=o.sibling;else for(o=e.child;o!==null;)n|=o.lanes|o.childLanes,r|=o.subtreeFlags,r|=o.flags,o.return=e,o=o.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function rfe(e,t,n){var r=t.pendingProps;switch(UB(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return rn(t),null;case 1:return _n(t.type)&&E_(),rn(t),null;case 3:return r=t.stateNode,X1(),bt(Pn),bt(sn),eV(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(s0(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Nr!==null&&(pH(Nr),Nr=null))),iH(e,t),rn(t),null;case 5:JB(t);var o=uu(E2.current);if(n=t.type,e!==null&&t.stateNode!=null)mre(e,t,n,r,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(fe(166));return rn(t),null}if(e=uu(xo.current),s0(t)){r=t.stateNode,n=t.type;var a=t.memoizedProps;switch(r[po]=t,r[L2]=a,e=(t.mode&1)!==0,n){case"dialog":wt("cancel",r),wt("close",r);break;case"iframe":case"object":case"embed":wt("load",r);break;case"video":case"audio":for(o=0;o<hh.length;o++)wt(hh[o],r);break;case"source":wt("error",r);break;case"img":case"image":case"link":wt("error",r),wt("load",r);break;case"details":wt("toggle",r);break;case"input":SU(r,a),wt("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!a.multiple},wt("invalid",r);break;case"textarea":IU(r,a),wt("invalid",r)}TF(n,a),o=null;for(var i in a)if(a.hasOwnProperty(i)){var s=a[i];i==="children"?typeof s=="string"?r.textContent!==s&&(a.suppressHydrationWarning!==!0&&i0(r.textContent,s,e),o=["children",s]):typeof s=="number"&&r.textContent!==""+s&&(a.suppressHydrationWarning!==!0&&i0(r.textContent,s,e),o=["children",""+s]):m2.hasOwnProperty(i)&&s!=null&&i==="onScroll"&&wt("scroll",r)}switch(n){case"input":Qf(r),LU(r,a,!0);break;case"textarea":Qf(r),EU(r);break;case"select":case"option":break;default:typeof a.onClick=="function"&&(r.onclick=I_)}r=o,t.updateQueue=r,r!==null&&(t.flags|=4)}else{i=o.nodeType===9?o:o.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Ute(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[po]=t,e[L2]=r,yre(e,t,!1,!1),t.stateNode=e;e:{switch(i=jF(n,r),n){case"dialog":wt("cancel",e),wt("close",e),o=r;break;case"iframe":case"object":case"embed":wt("load",e),o=r;break;case"video":case"audio":for(o=0;o<hh.length;o++)wt(hh[o],e);o=r;break;case"source":wt("error",e),o=r;break;case"img":case"image":case"link":wt("error",e),wt("load",e),o=r;break;case"details":wt("toggle",e),o=r;break;case"input":SU(e,r),o=EF(e,r),wt("invalid",e);break;case"option":o=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},o=At({},r,{value:void 0}),wt("invalid",e);break;case"textarea":IU(e,r),o=_F(e,r),wt("invalid",e);break;default:o=r}TF(n,o),s=o;for(a in s)if(s.hasOwnProperty(a)){var c=s[a];a==="style"?Kte(e,c):a==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&Wte(e,c)):a==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&g2(e,c):typeof c=="number"&&g2(e,""+c):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&(m2.hasOwnProperty(a)?c!=null&&a==="onScroll"&&wt("scroll",e):c!=null&&PB(e,a,c,i))}switch(n){case"input":Qf(e),LU(e,r,!1);break;case"textarea":Qf(e),EU(e);break;case"option":r.value!=null&&e.setAttribute("value",""+ri(r.value));break;case"select":e.multiple=!!r.multiple,a=r.value,a!=null?L1(e,!!r.multiple,a,!1):r.defaultValue!=null&&L1(e,!!r.multiple,r.defaultValue,!0);break;default:typeof o.onClick=="function"&&(e.onclick=I_)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return rn(t),null;case 6:if(e&&t.stateNode!=null)gre(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(fe(166));if(n=uu(E2.current),uu(xo.current),s0(t)){if(r=t.stateNode,n=t.memoizedProps,r[po]=t,(a=r.nodeValue!==n)&&(e=Jn,e!==null))switch(e.tag){case 3:i0(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&i0(r.nodeValue,n,(e.mode&1)!==0)}a&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[po]=t,t.stateNode=r}return rn(t),null;case 13:if(bt(It),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(St&&Yn!==null&&t.mode&1&&!(t.flags&128))Nne(),K1(),t.flags|=98560,a=!1;else if(a=s0(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(fe(318));if(a=t.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(fe(317));a[po]=t}else K1(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;rn(t),a=!1}else Nr!==null&&(pH(Nr),Nr=null),a=!0;if(!a)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||It.current&1?Wt===0&&(Wt=3):hV())),t.updateQueue!==null&&(t.flags|=4),rn(t),null);case 4:return X1(),iH(e,t),e===null&&C2(t.stateNode.containerInfo),rn(t),null;case 10:return ZB(t.type._context),rn(t),null;case 17:return _n(t.type)&&E_(),rn(t),null;case 19:if(bt(It),a=t.memoizedState,a===null)return rn(t),null;if(r=(t.flags&128)!==0,i=a.rendering,i===null)if(r)Zd(a,!1);else{if(Wt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=N_(e),i!==null){for(t.flags|=128,Zd(a,!1),r=i.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)a=n,e=r,a.flags&=14680066,i=a.alternate,i===null?(a.childLanes=0,a.lanes=e,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,a.type=i.type,e=i.dependencies,a.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return kt(It,It.current&1|2),t.child}e=e.sibling}a.tail!==null&&zt()>Q1&&(t.flags|=128,r=!0,Zd(a,!1),t.lanes=4194304)}else{if(!r)if(e=N_(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Zd(a,!0),a.tail===null&&a.tailMode==="hidden"&&!i.alternate&&!St)return rn(t),null}else 2*zt()-a.renderingStartTime>Q1&&n!==1073741824&&(t.flags|=128,r=!0,Zd(a,!1),t.lanes=4194304);a.isBackwards?(i.sibling=t.child,t.child=i):(n=a.last,n!==null?n.sibling=i:t.child=i,a.last=i)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=zt(),t.sibling=null,n=It.current,kt(It,r?n&1|2:n&1),t):(rn(t),null);case 22:case 23:return dV(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Gn&1073741824&&(rn(t),t.subtreeFlags&6&&(t.flags|=8192)):rn(t),null;case 24:return null;case 25:return null}throw Error(fe(156,t.tag))}function ofe(e,t){switch(UB(t),t.tag){case 1:return _n(t.type)&&E_(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return X1(),bt(Pn),bt(sn),eV(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return JB(t),null;case 13:if(bt(It),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(fe(340));K1()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return bt(It),null;case 4:return X1(),null;case 10:return ZB(t.type._context),null;case 22:case 23:return dV(),null;case 24:return null;default:return null}}var u0=!1,on=!1,afe=typeof WeakSet=="function"?WeakSet:Set,Ce=null;function w1(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){_t(e,t,r)}else n.current=null}function sH(e,t,n){try{n()}catch(r){_t(e,t,r)}}var gW=!1;function ife(e,t){if($F=C_,e=Mne(),VB(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 o=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break e}var i=0,s=-1,c=-1,l=0,u=0,d=e,f=null;t:for(;;){for(var p;d!==n||o!==0&&d.nodeType!==3||(s=i+o),d!==a||r!==0&&d.nodeType!==3||(c=i+r),d.nodeType===3&&(i+=d.nodeValue.length),(p=d.firstChild)!==null;)f=d,d=p;for(;;){if(d===e)break t;if(f===n&&++l===o&&(s=i),f===a&&++u===r&&(c=i),(p=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=p}n=s===-1||c===-1?null:{start:s,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(UF={focusedElem:e,selectionRange:n},C_=!1,Ce=t;Ce!==null;)if(t=Ce,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Ce=e;else for(;Ce!==null;){t=Ce;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var k=y.memoizedProps,w=y.memoizedState,v=t.stateNode,M=v.getSnapshotBeforeUpdate(t.elementType===t.type?k:Rr(t.type,k),w);v.__reactInternalSnapshotBeforeUpdate=M}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(fe(163))}}catch(b){_t(t,t.return,b)}if(e=t.sibling,e!==null){e.return=t.return,Ce=e;break}Ce=t.return}return y=gW,gW=!1,y}function Ph(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var a=o.destroy;o.destroy=void 0,a!==void 0&&sH(t,n,a)}o=o.next}while(o!==r)}}function _R(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 cH(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 kre(e){var t=e.alternate;t!==null&&(e.alternate=null,kre(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[po],delete t[L2],delete t[KF],delete t[B2e],delete t[V2e])),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 vre(e){return e.tag===5||e.tag===3||e.tag===4}function kW(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||vre(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 lH(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=I_));else if(r!==4&&(e=e.child,e!==null))for(lH(e,t,n),e=e.sibling;e!==null;)lH(e,t,n),e=e.sibling}function uH(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(uH(e,t,n),e=e.sibling;e!==null;)uH(e,t,n),e=e.sibling}var Yt=null,Tr=!1;function La(e,t,n){for(n=n.child;n!==null;)xre(e,t,n),n=n.sibling}function xre(e,t,n){if(vo&&typeof vo.onCommitFiberUnmount=="function")try{vo.onCommitFiberUnmount(bR,n)}catch{}switch(n.tag){case 5:on||w1(n,t);case 6:var r=Yt,o=Tr;Yt=null,La(e,t,n),Yt=r,Tr=o,Yt!==null&&(Tr?(e=Yt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Yt.removeChild(n.stateNode));break;case 18:Yt!==null&&(Tr?(e=Yt,n=n.stateNode,e.nodeType===8?Mj(e.parentNode,n):e.nodeType===1&&Mj(e,n),w2(e)):Mj(Yt,n.stateNode));break;case 4:r=Yt,o=Tr,Yt=n.stateNode.containerInfo,Tr=!0,La(e,t,n),Yt=r,Tr=o;break;case 0:case 11:case 14:case 15:if(!on&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var a=o,i=a.destroy;a=a.tag,i!==void 0&&(a&2||a&4)&&sH(n,t,i),o=o.next}while(o!==r)}La(e,t,n);break;case 1:if(!on&&(w1(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){_t(n,t,s)}La(e,t,n);break;case 21:La(e,t,n);break;case 22:n.mode&1?(on=(r=on)||n.memoizedState!==null,La(e,t,n),on=r):La(e,t,n);break;default:La(e,t,n)}}function vW(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new afe),t.forEach(function(r){var o=yfe.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function Er(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var o=n[r];try{var a=e,i=t,s=i;e:for(;s!==null;){switch(s.tag){case 5:Yt=s.stateNode,Tr=!1;break e;case 3:Yt=s.stateNode.containerInfo,Tr=!0;break e;case 4:Yt=s.stateNode.containerInfo,Tr=!0;break e}s=s.return}if(Yt===null)throw Error(fe(160));xre(a,i,o),Yt=null,Tr=!1;var c=o.alternate;c!==null&&(c.return=null),o.return=null}catch(l){_t(o,t,l)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)wre(t,e),t=t.sibling}function wre(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Er(t,e),ao(e),r&4){try{Ph(3,e,e.return),_R(3,e)}catch(k){_t(e,e.return,k)}try{Ph(5,e,e.return)}catch(k){_t(e,e.return,k)}}break;case 1:Er(t,e),ao(e),r&512&&n!==null&&w1(n,n.return);break;case 5:if(Er(t,e),ao(e),r&512&&n!==null&&w1(n,n.return),e.flags&32){var o=e.stateNode;try{g2(o,"")}catch(k){_t(e,e.return,k)}}if(r&4&&(o=e.stateNode,o!=null)){var a=e.memoizedProps,i=n!==null?n.memoizedProps:a,s=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{s==="input"&&a.type==="radio"&&a.name!=null&&Vte(o,a),jF(s,i);var l=jF(s,a);for(i=0;i<c.length;i+=2){var u=c[i],d=c[i+1];u==="style"?Kte(o,d):u==="dangerouslySetInnerHTML"?Wte(o,d):u==="children"?g2(o,d):PB(o,u,d,l)}switch(s){case"input":AF(o,a);break;case"textarea":$te(o,a);break;case"select":var f=o._wrapperState.wasMultiple;o._wrapperState.wasMultiple=!!a.multiple;var p=a.value;p!=null?L1(o,!!a.multiple,p,!1):f!==!!a.multiple&&(a.defaultValue!=null?L1(o,!!a.multiple,a.defaultValue,!0):L1(o,!!a.multiple,a.multiple?[]:"",!1))}o[L2]=a}catch(k){_t(e,e.return,k)}}break;case 6:if(Er(t,e),ao(e),r&4){if(e.stateNode===null)throw Error(fe(162));o=e.stateNode,a=e.memoizedProps;try{o.nodeValue=a}catch(k){_t(e,e.return,k)}}break;case 3:if(Er(t,e),ao(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{w2(t.containerInfo)}catch(k){_t(e,e.return,k)}break;case 4:Er(t,e),ao(e);break;case 13:Er(t,e),ao(e),o=e.child,o.flags&8192&&(a=o.memoizedState!==null,o.stateNode.isHidden=a,!a||o.alternate!==null&&o.alternate.memoizedState!==null||(lV=zt())),r&4&&vW(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?(on=(l=on)||u,Er(t,e),on=l):Er(t,e),ao(e),r&8192){if(l=e.memoizedState!==null,(e.stateNode.isHidden=l)&&!u&&e.mode&1)for(Ce=e,u=e.child;u!==null;){for(d=Ce=u;Ce!==null;){switch(f=Ce,p=f.child,f.tag){case 0:case 11:case 14:case 15:Ph(4,f,f.return);break;case 1:w1(f,f.return);var y=f.stateNode;if(typeof y.componentWillUnmount=="function"){r=f,n=f.return;try{t=r,y.props=t.memoizedProps,y.state=t.memoizedState,y.componentWillUnmount()}catch(k){_t(r,n,k)}}break;case 5:w1(f,f.return);break;case 22:if(f.memoizedState!==null){wW(d);continue}}p!==null?(p.return=f,Ce=p):wW(d)}u=u.sibling}e:for(u=null,d=e;;){if(d.tag===5){if(u===null){u=d;try{o=d.stateNode,l?(a=o.style,typeof a.setProperty=="function"?a.setProperty("display","none","important"):a.display="none"):(s=d.stateNode,c=d.memoizedProps.style,i=c!=null&&c.hasOwnProperty("display")?c.display:null,s.style.display=Gte("display",i))}catch(k){_t(e,e.return,k)}}}else if(d.tag===6){if(u===null)try{d.stateNode.nodeValue=l?"":d.memoizedProps}catch(k){_t(e,e.return,k)}}else if((d.tag!==22&&d.tag!==23||d.memoizedState===null||d===e)&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===e)break e;for(;d.sibling===null;){if(d.return===null||d.return===e)break e;u===d&&(u=null),d=d.return}u===d&&(u=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:Er(t,e),ao(e),r&4&&vW(e);break;case 21:break;default:Er(t,e),ao(e)}}function ao(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(vre(n)){var r=n;break e}n=n.return}throw Error(fe(160))}switch(r.tag){case 5:var o=r.stateNode;r.flags&32&&(g2(o,""),r.flags&=-33);var a=kW(e);uH(e,a,o);break;case 3:case 4:var i=r.stateNode.containerInfo,s=kW(e);lH(e,s,i);break;default:throw Error(fe(161))}}catch(c){_t(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function sfe(e,t,n){Ce=e,Mre(e)}function Mre(e,t,n){for(var r=(e.mode&1)!==0;Ce!==null;){var o=Ce,a=o.child;if(o.tag===22&&r){var i=o.memoizedState!==null||u0;if(!i){var s=o.alternate,c=s!==null&&s.memoizedState!==null||on;s=u0;var l=on;if(u0=i,(on=c)&&!l)for(Ce=o;Ce!==null;)i=Ce,c=i.child,i.tag===22&&i.memoizedState!==null?MW(o):c!==null?(c.return=i,Ce=c):MW(o);for(;a!==null;)Ce=a,Mre(a),a=a.sibling;Ce=o,u0=s,on=l}xW(e)}else o.subtreeFlags&8772&&a!==null?(a.return=o,Ce=a):xW(e)}}function xW(e){for(;Ce!==null;){var t=Ce;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:on||_R(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!on)if(n===null)r.componentDidMount();else{var o=t.elementType===t.type?n.memoizedProps:Rr(t.type,n.memoizedProps);r.componentDidUpdate(o,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var a=t.updateQueue;a!==null&&oW(t,a,r);break;case 3:var i=t.updateQueue;if(i!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}oW(t,i,n)}break;case 5:var s=t.stateNode;if(n===null&&t.flags&4){n=s;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var l=t.alternate;if(l!==null){var u=l.memoizedState;if(u!==null){var d=u.dehydrated;d!==null&&w2(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(fe(163))}on||t.flags&512&&cH(t)}catch(f){_t(t,t.return,f)}}if(t===e){Ce=null;break}if(n=t.sibling,n!==null){n.return=t.return,Ce=n;break}Ce=t.return}}function wW(e){for(;Ce!==null;){var t=Ce;if(t===e){Ce=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Ce=n;break}Ce=t.return}}function MW(e){for(;Ce!==null;){var t=Ce;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{_R(4,t)}catch(c){_t(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var o=t.return;try{r.componentDidMount()}catch(c){_t(t,o,c)}}var a=t.return;try{cH(t)}catch(c){_t(t,a,c)}break;case 5:var i=t.return;try{cH(t)}catch(c){_t(t,i,c)}}}catch(c){_t(t,t.return,c)}if(t===e){Ce=null;break}var s=t.sibling;if(s!==null){s.return=t.return,Ce=s;break}Ce=t.return}}var cfe=Math.ceil,q_=aa.ReactCurrentDispatcher,sV=aa.ReactCurrentOwner,pr=aa.ReactCurrentBatchConfig,tt=0,Xt=null,Ht=null,Qt=0,Gn=0,M1=hi(0),Wt=0,R2=null,xu=0,RR=0,cV=0,_h=null,In=null,lV=0,Q1=1/0,Vo=null,O_=!1,dH=null,Xa=null,d0=!1,$a=null,F_=0,Rh=0,hH=null,Q0=-1,J0=0;function pn(){return tt&6?zt():Q0!==-1?Q0:Q0=zt()}function Ya(e){return e.mode&1?tt&2&&Qt!==0?Qt&-Qt:U2e.transition!==null?(J0===0&&(J0=ine()),J0):(e=lt,e!==0||(e=window.event,e=e===void 0?16:fne(e.type)),e):1}function Fr(e,t,n,r){if(50<Rh)throw Rh=0,hH=null,Error(fe(185));X2(e,n,r),(!(tt&2)||e!==Xt)&&(e===Xt&&(!(tt&2)&&(RR|=n),Wt===4&&Oa(e,Qt)),Rn(e,r),n===1&&tt===0&&!(t.mode&1)&&(Q1=zt()+500,ER&&fi()))}function Rn(e,t){var n=e.callbackNode;Uhe(e,t);var r=b_(e,e===Xt?Qt:0);if(r===0)n!==null&&_U(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&_U(n),t===1)e.tag===0?$2e(bW.bind(null,e)):Rne(bW.bind(null,e)),F2e(function(){!(tt&6)&&fi()}),n=null;else{switch(sne(r)){case 1:n=NB;break;case 4:n=one;break;case 16:n=M_;break;case 536870912:n=ane;break;default:n=M_}n=Pre(n,bre.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function bre(e,t){if(Q0=-1,J0=0,tt&6)throw Error(fe(327));var n=e.callbackNode;if(_1()&&e.callbackNode!==n)return null;var r=b_(e,e===Xt?Qt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=H_(e,r);else{t=r;var o=tt;tt|=2;var a=Sre();(Xt!==e||Qt!==t)&&(Vo=null,Q1=zt()+500,fu(e,t));do try{dfe();break}catch(s){Cre(e,s)}while(!0);KB(),q_.current=a,tt=o,Ht!==null?t=0:(Xt=null,Qt=0,t=Wt)}if(t!==0){if(t===2&&(o=OF(e),o!==0&&(r=o,t=fH(e,o))),t===1)throw n=R2,fu(e,0),Oa(e,r),Rn(e,zt()),n;if(t===6)Oa(e,r);else{if(o=e.current.alternate,!(r&30)&&!lfe(o)&&(t=H_(e,r),t===2&&(a=OF(e),a!==0&&(r=a,t=fH(e,a))),t===1))throw n=R2,fu(e,0),Oa(e,r),Rn(e,zt()),n;switch(e.finishedWork=o,e.finishedLanes=r,t){case 0:case 1:throw Error(fe(345));case 2:Ti(e,In,Vo);break;case 3:if(Oa(e,r),(r&130023424)===r&&(t=lV+500-zt(),10<t)){if(b_(e,0)!==0)break;if(o=e.suspendedLanes,(o&r)!==r){pn(),e.pingedLanes|=e.suspendedLanes&o;break}e.timeoutHandle=GF(Ti.bind(null,e,In,Vo),t);break}Ti(e,In,Vo);break;case 4:if(Oa(e,r),(r&4194240)===r)break;for(t=e.eventTimes,o=-1;0<r;){var i=31-Or(r);a=1<<i,i=t[i],i>o&&(o=i),r&=~a}if(r=o,r=zt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*cfe(r/1960))-r,10<r){e.timeoutHandle=GF(Ti.bind(null,e,In,Vo),r);break}Ti(e,In,Vo);break;case 5:Ti(e,In,Vo);break;default:throw Error(fe(329))}}}return Rn(e,zt()),e.callbackNode===n?bre.bind(null,e):null}function fH(e,t){var n=_h;return e.current.memoizedState.isDehydrated&&(fu(e,t).flags|=256),e=H_(e,t),e!==2&&(t=In,In=n,t!==null&&pH(t)),e}function pH(e){In===null?In=e:In.push.apply(In,e)}function lfe(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var o=n[r],a=o.getSnapshot;o=o.value;try{if(!Br(a(),o))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Oa(e,t){for(t&=~cV,t&=~RR,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Or(t),r=1<<n;e[n]=-1,t&=~r}}function bW(e){if(tt&6)throw Error(fe(327));_1();var t=b_(e,0);if(!(t&1))return Rn(e,zt()),null;var n=H_(e,t);if(e.tag!==0&&n===2){var r=OF(e);r!==0&&(t=r,n=fH(e,r))}if(n===1)throw n=R2,fu(e,0),Oa(e,t),Rn(e,zt()),n;if(n===6)throw Error(fe(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Ti(e,In,Vo),Rn(e,zt()),null}function uV(e,t){var n=tt;tt|=1;try{return e(t)}finally{tt=n,tt===0&&(Q1=zt()+500,ER&&fi())}}function wu(e){$a!==null&&$a.tag===0&&!(tt&6)&&_1();var t=tt;tt|=1;var n=pr.transition,r=lt;try{if(pr.transition=null,lt=1,e)return e()}finally{lt=r,pr.transition=n,tt=t,!(tt&6)&&fi()}}function dV(){Gn=M1.current,bt(M1)}function fu(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,O2e(n)),Ht!==null)for(n=Ht.return;n!==null;){var r=n;switch(UB(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&E_();break;case 3:X1(),bt(Pn),bt(sn),eV();break;case 5:JB(r);break;case 4:X1();break;case 13:bt(It);break;case 19:bt(It);break;case 10:ZB(r.type._context);break;case 22:case 23:dV()}n=n.return}if(Xt=e,Ht=e=Qa(e.current,null),Qt=Gn=t,Wt=0,R2=null,cV=RR=xu=0,In=_h=null,lu!==null){for(t=0;t<lu.length;t++)if(n=lu[t],r=n.interleaved,r!==null){n.interleaved=null;var o=r.next,a=n.pending;if(a!==null){var i=a.next;a.next=o,r.next=i}n.pending=r}lu=null}return e}function Cre(e,t){do{var n=Ht;try{if(KB(),Z0.current=D_,z_){for(var r=Et.memoizedState;r!==null;){var o=r.queue;o!==null&&(o.pending=null),r=r.next}z_=!1}if(vu=0,Zt=Ut=Et=null,Ah=!1,A2=0,sV.current=null,n===null||n.return===null){Wt=1,R2=t,Ht=null;break}e:{var a=e,i=n.return,s=n,c=t;if(t=Qt,s.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var l=c,u=s,d=u.tag;if(!(u.mode&1)&&(d===0||d===11||d===15)){var f=u.alternate;f?(u.updateQueue=f.updateQueue,u.memoizedState=f.memoizedState,u.lanes=f.lanes):(u.updateQueue=null,u.memoizedState=null)}var p=uW(i);if(p!==null){p.flags&=-257,dW(p,i,s,a,t),p.mode&1&&lW(a,l,t),t=p,c=l;var y=t.updateQueue;if(y===null){var k=new Set;k.add(c),t.updateQueue=k}else y.add(c);break e}else{if(!(t&1)){lW(a,l,t),hV();break e}c=Error(fe(426))}}else if(St&&s.mode&1){var w=uW(i);if(w!==null){!(w.flags&65536)&&(w.flags|=256),dW(w,i,s,a,t),WB(Y1(c,s));break e}}a=c=Y1(c,s),Wt!==4&&(Wt=2),_h===null?_h=[a]:_h.push(a),a=i;do{switch(a.tag){case 3:a.flags|=65536,t&=-t,a.lanes|=t;var v=sre(a,c,t);rW(a,v);break e;case 1:s=c;var M=a.type,x=a.stateNode;if(!(a.flags&128)&&(typeof M.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Xa===null||!Xa.has(x)))){a.flags|=65536,t&=-t,a.lanes|=t;var b=cre(a,s,t);rW(a,b);break e}}a=a.return}while(a!==null)}Ire(n)}catch(S){t=S,Ht===n&&n!==null&&(Ht=n=n.return);continue}break}while(!0)}function Sre(){var e=q_.current;return q_.current=D_,e===null?D_:e}function hV(){(Wt===0||Wt===3||Wt===2)&&(Wt=4),Xt===null||!(xu&268435455)&&!(RR&268435455)||Oa(Xt,Qt)}function H_(e,t){var n=tt;tt|=2;var r=Sre();(Xt!==e||Qt!==t)&&(Vo=null,fu(e,t));do try{ufe();break}catch(o){Cre(e,o)}while(!0);if(KB(),tt=n,q_.current=r,Ht!==null)throw Error(fe(261));return Xt=null,Qt=0,Wt}function ufe(){for(;Ht!==null;)Lre(Ht)}function dfe(){for(;Ht!==null&&!zhe();)Lre(Ht)}function Lre(e){var t=Are(e.alternate,e,Gn);e.memoizedProps=e.pendingProps,t===null?Ire(e):Ht=t,sV.current=null}function Ire(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=ofe(n,t),n!==null){n.flags&=32767,Ht=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Wt=6,Ht=null;return}}else if(n=rfe(n,t,Gn),n!==null){Ht=n;return}if(t=t.sibling,t!==null){Ht=t;return}Ht=t=e}while(t!==null);Wt===0&&(Wt=5)}function Ti(e,t,n){var r=lt,o=pr.transition;try{pr.transition=null,lt=1,hfe(e,t,n,r)}finally{pr.transition=o,lt=r}return null}function hfe(e,t,n,r){do _1();while($a!==null);if(tt&6)throw Error(fe(327));n=e.finishedWork;var o=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(fe(177));e.callbackNode=null,e.callbackPriority=0;var a=n.lanes|n.childLanes;if(Whe(e,a),e===Xt&&(Ht=Xt=null,Qt=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||d0||(d0=!0,Pre(M_,function(){return _1(),null})),a=(n.flags&15990)!==0,n.subtreeFlags&15990||a){a=pr.transition,pr.transition=null;var i=lt;lt=1;var s=tt;tt|=4,sV.current=null,ife(e,n),wre(n,e),R2e(UF),C_=!!$F,UF=$F=null,e.current=n,sfe(n),Dhe(),tt=s,lt=i,pr.transition=a}else e.current=n;if(d0&&(d0=!1,$a=e,F_=o),a=e.pendingLanes,a===0&&(Xa=null),Fhe(n.stateNode),Rn(e,zt()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)o=t[n],r(o.value,{componentStack:o.stack,digest:o.digest});if(O_)throw O_=!1,e=dH,dH=null,e;return F_&1&&e.tag!==0&&_1(),a=e.pendingLanes,a&1?e===hH?Rh++:(Rh=0,hH=e):Rh=0,fi(),null}function _1(){if($a!==null){var e=sne(F_),t=pr.transition,n=lt;try{if(pr.transition=null,lt=16>e?16:e,$a===null)var r=!1;else{if(e=$a,$a=null,F_=0,tt&6)throw Error(fe(331));var o=tt;for(tt|=4,Ce=e.current;Ce!==null;){var a=Ce,i=a.child;if(Ce.flags&16){var s=a.deletions;if(s!==null){for(var c=0;c<s.length;c++){var l=s[c];for(Ce=l;Ce!==null;){var u=Ce;switch(u.tag){case 0:case 11:case 15:Ph(8,u,a)}var d=u.child;if(d!==null)d.return=u,Ce=d;else for(;Ce!==null;){u=Ce;var f=u.sibling,p=u.return;if(kre(u),u===l){Ce=null;break}if(f!==null){f.return=p,Ce=f;break}Ce=p}}}var y=a.alternate;if(y!==null){var k=y.child;if(k!==null){y.child=null;do{var w=k.sibling;k.sibling=null,k=w}while(k!==null)}}Ce=a}}if(a.subtreeFlags&2064&&i!==null)i.return=a,Ce=i;else e:for(;Ce!==null;){if(a=Ce,a.flags&2048)switch(a.tag){case 0:case 11:case 15:Ph(9,a,a.return)}var v=a.sibling;if(v!==null){v.return=a.return,Ce=v;break e}Ce=a.return}}var M=e.current;for(Ce=M;Ce!==null;){i=Ce;var x=i.child;if(i.subtreeFlags&2064&&x!==null)x.return=i,Ce=x;else e:for(i=M;Ce!==null;){if(s=Ce,s.flags&2048)try{switch(s.tag){case 0:case 11:case 15:_R(9,s)}}catch(S){_t(s,s.return,S)}if(s===i){Ce=null;break e}var b=s.sibling;if(b!==null){b.return=s.return,Ce=b;break e}Ce=s.return}}if(tt=o,fi(),vo&&typeof vo.onPostCommitFiberRoot=="function")try{vo.onPostCommitFiberRoot(bR,e)}catch{}r=!0}return r}finally{lt=n,pr.transition=t}}return!1}function CW(e,t,n){t=Y1(n,t),t=sre(e,t,1),e=Za(e,t,1),t=pn(),e!==null&&(X2(e,1,t),Rn(e,t))}function _t(e,t,n){if(e.tag===3)CW(e,e,n);else for(;t!==null;){if(t.tag===3){CW(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Xa===null||!Xa.has(r))){e=Y1(n,e),e=cre(t,e,1),t=Za(t,e,1),e=pn(),t!==null&&(X2(t,1,e),Rn(t,e));break}}t=t.return}}function ffe(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=pn(),e.pingedLanes|=e.suspendedLanes&n,Xt===e&&(Qt&n)===n&&(Wt===4||Wt===3&&(Qt&130023424)===Qt&&500>zt()-lV?fu(e,0):cV|=n),Rn(e,t)}function Ere(e,t){t===0&&(e.mode&1?(t=t0,t0<<=1,!(t0&130023424)&&(t0=4194304)):t=1);var n=pn();e=Jo(e,t),e!==null&&(X2(e,t,n),Rn(e,n))}function pfe(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ere(e,n)}function yfe(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(fe(314))}r!==null&&r.delete(t),Ere(e,n)}var Are;Are=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Pn.current)En=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return En=!1,nfe(e,t,n);En=!!(e.flags&131072)}else En=!1,St&&t.flags&1048576&&Tne(t,__,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Y0(e,t),e=t.pendingProps;var o=G1(t,sn.current);P1(t,n),o=nV(null,t,r,e,o,n);var a=rV();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,_n(r)?(a=!0,A_(t)):a=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,YB(t),o.updater=PR,t.stateNode=o,o._reactInternals=t,eH(t,r,e,n),t=rH(null,t,r,!0,a,n)):(t.tag=0,St&&a&&$B(t),hn(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Y0(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=gfe(r),e=Rr(r,e),o){case 0:t=nH(null,t,r,e,n);break e;case 1:t=pW(null,t,r,e,n);break e;case 11:t=hW(null,t,r,e,n);break e;case 14:t=fW(null,t,r,Rr(r.type,e),n);break e}throw Error(fe(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Rr(r,o),nH(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Rr(r,o),pW(e,t,r,o,n);case 3:e:{if(hre(t),e===null)throw Error(fe(387));r=t.pendingProps,a=t.memoizedState,o=a.element,One(e,t),j_(t,r,null,n);var i=t.memoizedState;if(r=i.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){o=Y1(Error(fe(423)),t),t=yW(e,t,r,n,o);break e}else if(r!==o){o=Y1(Error(fe(424)),t),t=yW(e,t,r,n,o);break e}else for(Yn=Ka(t.stateNode.containerInfo.firstChild),Jn=t,St=!0,Nr=null,n=Dne(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(K1(),r===o){t=ea(e,t,n);break e}hn(e,t,r,n)}t=t.child}return t;case 5:return Fne(t),e===null&&YF(t),r=t.type,o=t.pendingProps,a=e!==null?e.memoizedProps:null,i=o.children,WF(r,o)?i=null:a!==null&&WF(r,a)&&(t.flags|=32),dre(e,t),hn(e,t,i,n),t.child;case 6:return e===null&&YF(t),null;case 13:return fre(e,t,n);case 4:return QB(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Z1(t,null,r,n):hn(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Rr(r,o),hW(e,t,r,o,n);case 7:return hn(e,t,t.pendingProps,n),t.child;case 8:return hn(e,t,t.pendingProps.children,n),t.child;case 12:return hn(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,a=t.memoizedProps,i=o.value,kt(R_,r._currentValue),r._currentValue=i,a!==null)if(Br(a.value,i)){if(a.children===o.children&&!Pn.current){t=ea(e,t,n);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var s=a.dependencies;if(s!==null){i=a.child;for(var c=s.firstContext;c!==null;){if(c.context===r){if(a.tag===1){c=Xo(-1,n&-n),c.tag=2;var l=a.updateQueue;if(l!==null){l=l.shared;var u=l.pending;u===null?c.next=c:(c.next=u.next,u.next=c),l.pending=c}}a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),QF(a.return,n,t),s.lanes|=n;break}c=c.next}}else if(a.tag===10)i=a.type===t.type?null:a.child;else if(a.tag===18){if(i=a.return,i===null)throw Error(fe(341));i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),QF(i,n,t),i=a.sibling}else i=a.child;if(i!==null)i.return=a;else for(i=a;i!==null;){if(i===t){i=null;break}if(a=i.sibling,a!==null){a.return=i.return,i=a;break}i=i.return}a=i}hn(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,P1(t,n),o=mr(o),r=r(o),t.flags|=1,hn(e,t,r,n),t.child;case 14:return r=t.type,o=Rr(r,t.pendingProps),o=Rr(r.type,o),fW(e,t,r,o,n);case 15:return lre(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Rr(r,o),Y0(e,t),t.tag=1,_n(r)?(e=!0,A_(t)):e=!1,P1(t,n),ire(t,r,o),eH(t,r,o,n),rH(null,t,r,!0,e,n);case 19:return pre(e,t,n);case 22:return ure(e,t,n)}throw Error(fe(156,t.tag))};function Pre(e,t){return rne(e,t)}function mfe(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 fr(e,t,n,r){return new mfe(e,t,n,r)}function fV(e){return e=e.prototype,!(!e||!e.isReactComponent)}function gfe(e){if(typeof e=="function")return fV(e)?1:0;if(e!=null){if(e=e.$$typeof,e===RB)return 11;if(e===TB)return 14}return 2}function Qa(e,t){var n=e.alternate;return n===null?(n=fr(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 ep(e,t,n,r,o,a){var i=2;if(r=e,typeof e=="function")fV(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case h1:return pu(n.children,o,a,t);case _B:i=8,o|=8;break;case CF:return e=fr(12,n,t,o|2),e.elementType=CF,e.lanes=a,e;case SF:return e=fr(13,n,t,o),e.elementType=SF,e.lanes=a,e;case LF:return e=fr(19,n,t,o),e.elementType=LF,e.lanes=a,e;case Fte:return TR(n,o,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case qte:i=10;break e;case Ote:i=9;break e;case RB:i=11;break e;case TB:i=14;break e;case Na:i=16,r=null;break e}throw Error(fe(130,e==null?e:typeof e,""))}return t=fr(i,n,t,o),t.elementType=e,t.type=r,t.lanes=a,t}function pu(e,t,n,r){return e=fr(7,e,r,t),e.lanes=n,e}function TR(e,t,n,r){return e=fr(22,e,r,t),e.elementType=Fte,e.lanes=n,e.stateNode={isHidden:!1},e}function Pj(e,t,n){return e=fr(6,e,null,t),e.lanes=n,e}function _j(e,t,n){return t=fr(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function kfe(e,t,n,r,o){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=dj(0),this.expirationTimes=dj(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=dj(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function pV(e,t,n,r,o,a,i,s,c){return e=new kfe(e,t,n,s,c),t===1?(t=1,a===!0&&(t|=8)):t=0,a=fr(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},YB(a),e}function vfe(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:d1,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function _re(e){if(!e)return oi;e=e._reactInternals;e:{if(Tu(e)!==e||e.tag!==1)throw Error(fe(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(_n(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(fe(171))}if(e.tag===1){var n=e.type;if(_n(n))return _ne(e,n,t)}return t}function Rre(e,t,n,r,o,a,i,s,c){return e=pV(n,r,!0,e,o,a,i,s,c),e.context=_re(null),n=e.current,r=pn(),o=Ya(n),a=Xo(r,o),a.callback=t??null,Za(n,a,o),e.current.lanes=o,X2(e,o,r),Rn(e,r),e}function jR(e,t,n,r){var o=t.current,a=pn(),i=Ya(o);return n=_re(n),t.context===null?t.context=n:t.pendingContext=n,t=Xo(a,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Za(o,t,i),e!==null&&(Fr(e,o,i,a),K0(e,o,i)),i}function B_(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function SW(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function yV(e,t){SW(e,t),(e=e.alternate)&&SW(e,t)}function xfe(){return null}var Tre=typeof reportError=="function"?reportError:function(e){console.error(e)};function mV(e){this._internalRoot=e}NR.prototype.render=mV.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(fe(409));jR(e,t,null,null)};NR.prototype.unmount=mV.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;wu(function(){jR(null,e,null,null)}),t[Qo]=null}};function NR(e){this._internalRoot=e}NR.prototype.unstable_scheduleHydration=function(e){if(e){var t=une();e={blockedOn:null,target:e,priority:t};for(var n=0;n<qa.length&&t!==0&&t<qa[n].priority;n++);qa.splice(n,0,e),n===0&&hne(e)}};function gV(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function zR(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function LW(){}function wfe(e,t,n,r,o){if(o){if(typeof r=="function"){var a=r;r=function(){var l=B_(i);a.call(l)}}var i=Rre(t,r,e,0,null,!1,!1,"",LW);return e._reactRootContainer=i,e[Qo]=i.current,C2(e.nodeType===8?e.parentNode:e),wu(),i}for(;o=e.lastChild;)e.removeChild(o);if(typeof r=="function"){var s=r;r=function(){var l=B_(c);s.call(l)}}var c=pV(e,0,!1,null,null,!1,!1,"",LW);return e._reactRootContainer=c,e[Qo]=c.current,C2(e.nodeType===8?e.parentNode:e),wu(function(){jR(t,c,n,r)}),c}function DR(e,t,n,r,o){var a=n._reactRootContainer;if(a){var i=a;if(typeof o=="function"){var s=o;o=function(){var c=B_(i);s.call(c)}}jR(t,i,e,o)}else i=wfe(n,t,e,o,r);return B_(i)}cne=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=dh(t.pendingLanes);n!==0&&(zB(t,n|1),Rn(t,zt()),!(tt&6)&&(Q1=zt()+500,fi()))}break;case 13:wu(function(){var r=Jo(e,1);if(r!==null){var o=pn();Fr(r,e,1,o)}}),yV(e,1)}};DB=function(e){if(e.tag===13){var t=Jo(e,134217728);if(t!==null){var n=pn();Fr(t,e,134217728,n)}yV(e,134217728)}};lne=function(e){if(e.tag===13){var t=Ya(e),n=Jo(e,t);if(n!==null){var r=pn();Fr(n,e,t,r)}yV(e,t)}};une=function(){return lt};dne=function(e,t){var n=lt;try{return lt=e,t()}finally{lt=n}};zF=function(e,t,n){switch(t){case"input":if(AF(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var o=IR(r);if(!o)throw Error(fe(90));Bte(r),AF(r,o)}}}break;case"textarea":$te(e,n);break;case"select":t=n.value,t!=null&&L1(e,!!n.multiple,t,!1)}};Yte=uV;Qte=wu;var Mfe={usingClientEntryPoint:!1,Events:[Q2,m1,IR,Zte,Xte,uV]},Xd={findFiberByHostInstance:cu,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},bfe={bundleType:Xd.bundleType,version:Xd.version,rendererPackageName:Xd.rendererPackageName,rendererConfig:Xd.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:aa.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=tne(e),e===null?null:e.stateNode},findFiberByHostInstance:Xd.findFiberByHostInstance||xfe,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var h0=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!h0.isDisabled&&h0.supportsFiber)try{bR=h0.inject(bfe),vo=h0}catch{}}or.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Mfe;or.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!gV(t))throw Error(fe(200));return vfe(e,t,null,n)};or.createRoot=function(e,t){if(!gV(e))throw Error(fe(299));var n=!1,r="",o=Tre;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(o=t.onRecoverableError)),t=pV(e,1,!1,null,null,n,!1,r,o),e[Qo]=t.current,C2(e.nodeType===8?e.parentNode:e),new mV(t)};or.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(fe(188)):(e=Object.keys(e).join(","),Error(fe(268,e)));return e=tne(t),e=e===null?null:e.stateNode,e};or.flushSync=function(e){return wu(e)};or.hydrate=function(e,t,n){if(!zR(t))throw Error(fe(200));return DR(null,e,t,!0,n)};or.hydrateRoot=function(e,t,n){if(!gV(e))throw Error(fe(405));var r=n!=null&&n.hydratedSources||null,o=!1,a="",i=Tre;if(n!=null&&(n.unstable_strictMode===!0&&(o=!0),n.identifierPrefix!==void 0&&(a=n.identifierPrefix),n.onRecoverableError!==void 0&&(i=n.onRecoverableError)),t=Rre(t,null,e,1,n??null,o,!1,a,i),e[Qo]=t.current,C2(e),r)for(e=0;e<r.length;e++)n=r[e],o=n._getVersion,o=o(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,o]:t.mutableSourceEagerHydrationData.push(n,o);return new NR(t)};or.render=function(e,t,n){if(!zR(t))throw Error(fe(200));return DR(null,e,t,!1,n)};or.unmountComponentAtNode=function(e){if(!zR(e))throw Error(fe(40));return e._reactRootContainer?(wu(function(){DR(null,null,e,!1,function(){e._reactRootContainer=null,e[Qo]=null})}),!0):!1};or.unstable_batchedUpdates=uV;or.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!zR(n))throw Error(fe(200));if(e==null||e._reactInternals===void 0)throw Error(fe(38));return DR(e,t,n,!1,r)};or.version="18.3.1-next-f1338f8080-20240426";function jre(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(jre)}catch(e){console.error(e)}}jre(),jte.exports=or;var wd=jte.exports;const Cfe=gd(wd);var IW=wd;MF.createRoot=IW.createRoot,MF.hydrateRoot=IW.hydrateRoot;const Sfe=async()=>{const e=await fetch("/api/demos");if(!e.ok)throw new Error(`GET /api/demos failed: ${e.status}`);return await e.json()},Nre=async e=>{const t=await fetch(`/api/demos/${e}`);if(!t.ok)throw new Error(`GET /api/demos/${e} failed: ${t.status}`);return await t.json()},Lfe=async e=>{const t=await fetch(`/api/demos/${encodeURIComponent(e)}`,{method:"DELETE"});if(!t.ok){let n=null;try{n=await t.json()}catch{}throw new Error((n==null?void 0:n.error)??`DELETE /api/demos/${e} → ${t.status}`)}return await t.json()},Ife=async e=>{const t=await fetch("/api/projects",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let n=null;try{n=await t.json()}catch{}throw new Error((n==null?void 0:n.error)??`POST /api/projects → ${t.status}`)}return await t.json()},Efe=async e=>{const t=await fetch(`/api/demos/${e}/reset`,{method:"POST",headers:{"content-type":"application/json"},body:"{}"});if(!t.ok){let n=null;try{n=await t.json()}catch{}throw new Error((n==null?void 0:n.error)??`POST /api/demos/${e}/reset → ${t.status}`)}return await t.json()},Afe=async(e,t)=>{const n=await fetch(`/api/demos/${e}/play/${t}`,{method:"POST",headers:{"content-type":"application/json"},body:"{}"});if(!n.ok){let r=null;try{r=await n.json()}catch{}throw new Error((r==null?void 0:r.error)??`POST /api/demos/${e}/play/${t} → ${n.status}`)}return await n.json()},zre={default:{border:"hsl(var(--primary))",background:"hsl(var(--card))",edge:"hsl(var(--muted-foreground))",headerBackground:"hsl(var(--muted))"},slate:{border:"hsl(215, 20%, 40%)",background:"hsl(215, 15%, 15%)",edge:"hsl(215, 16%, 47%)",headerBackground:"hsl(215, 15%, 11%)"},blue:{border:"hsl(213, 70%, 55%)",background:"hsl(214, 30%, 14%)",edge:"hsl(217, 91%, 60%)",headerBackground:"hsl(214, 30%, 10%)"},green:{border:"hsl(142, 50%, 45%)",background:"hsl(142, 25%, 13%)",edge:"hsl(142, 71%, 45%)",headerBackground:"hsl(142, 25%, 9%)"},amber:{border:"hsl(43, 70%, 50%)",background:"hsl(43, 30%, 14%)",edge:"hsl(38, 92%, 50%)",headerBackground:"hsl(43, 30%, 10%)"},red:{border:"hsl(0, 70%, 55%)",background:"hsl(0, 25%, 14%)",edge:"hsl(0, 84%, 60%)",headerBackground:"hsl(0, 25%, 10%)"},purple:{border:"hsl(270, 60%, 60%)",background:"hsl(270, 20%, 15%)",edge:"hsl(271, 91%, 65%)",headerBackground:"hsl(270, 20%, 11%)"},pink:{border:"hsl(330, 60%, 60%)",background:"hsl(330, 20%, 14%)",edge:"hsl(330, 81%, 60%)",headerBackground:"hsl(330, 20%, 10%)"}},Th=zre,ef="hsl(var(--card))";function ct(e,t){const n=e??"default",r=zre[n];return t==="edge"?{stroke:r.edge}:t==="text"?n==="default"?{}:{color:r.edge}:t==="node-header"?{backgroundColor:r.headerBackground}:{borderColor:r.border,backgroundColor:r.background}}/**
|
|
40
|
+
`+a.stack}return{value:e,source:t,stack:o,digest:null}}function Ej(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function tH(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var J2e=typeof WeakMap=="function"?WeakMap:Map;function sre(e,t,n){n=Xo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){O_||(O_=!0,dH=r),tH(e,t)},n}function cre(e,t,n){n=Xo(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var o=t.value;n.payload=function(){return r(o)},n.callback=function(){tH(e,t)}}var a=e.stateNode;return a!==null&&typeof a.componentDidCatch=="function"&&(n.callback=function(){tH(e,t),typeof r!="function"&&(Xa===null?Xa=new Set([this]):Xa.add(this));var i=t.stack;this.componentDidCatch(t.value,{componentStack:i!==null?i:""})}),n}function lW(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new J2e;var o=new Set;r.set(t,o)}else o=r.get(t),o===void 0&&(o=new Set,r.set(t,o));o.has(n)||(o.add(n),e=ffe.bind(null,e,t,n),t.then(e,e))}function uW(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function dW(e,t,n,r,o){return e.mode&1?(e.flags|=65536,e.lanes=o,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=Xo(-1,1),t.tag=2,Za(n,t,1))),n.lanes|=1),e)}var efe=aa.ReactCurrentOwner,En=!1;function hn(e,t,n,r){t.child=e===null?Dne(t,null,n,r):Z1(t,e.child,n,r)}function hW(e,t,n,r,o){n=n.render;var a=t.ref;return P1(t,o),r=nV(e,t,n,r,a,o),n=rV(),e!==null&&!En?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,ea(e,t,o)):(St&&n&&$B(t),t.flags|=1,hn(e,t,r,o),t.child)}function fW(e,t,n,r,o){if(e===null){var a=n.type;return typeof a=="function"&&!fV(a)&&a.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=a,lre(e,t,a,r,o)):(e=ep(n.type,null,r,t,t.mode,o),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!(e.lanes&o)){var i=a.memoizedProps;if(n=n.compare,n=n!==null?n:b2,n(i,r)&&e.ref===t.ref)return ea(e,t,o)}return t.flags|=1,e=Qa(a,r),e.ref=t.ref,e.return=t,t.child=e}function lre(e,t,n,r,o){if(e!==null){var a=e.memoizedProps;if(b2(a,r)&&e.ref===t.ref)if(En=!1,t.pendingProps=r=a,(e.lanes&o)!==0)e.flags&131072&&(En=!0);else return t.lanes=e.lanes,ea(e,t,o)}return nH(e,t,n,r,o)}function ure(e,t,n){var r=t.pendingProps,o=r.children,a=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},kt(M1,Gn),Gn|=n;else{if(!(n&1073741824))return e=a!==null?a.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,kt(M1,Gn),Gn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=a!==null?a.baseLanes:n,kt(M1,Gn),Gn|=r}else a!==null?(r=a.baseLanes|n,t.memoizedState=null):r=n,kt(M1,Gn),Gn|=r;return hn(e,t,o,n),t.child}function dre(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function nH(e,t,n,r,o){var a=_n(n)?gu:sn.current;return a=G1(t,a),P1(t,o),n=nV(e,t,n,r,a,o),r=rV(),e!==null&&!En?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,ea(e,t,o)):(St&&r&&$B(t),t.flags|=1,hn(e,t,n,o),t.child)}function pW(e,t,n,r,o){if(_n(n)){var a=!0;A_(t)}else a=!1;if(P1(t,o),t.stateNode===null)Y0(e,t),ire(t,n,r),eH(t,n,r,o),r=!0;else if(e===null){var i=t.stateNode,s=t.memoizedProps;i.props=s;var c=i.context,l=n.contextType;typeof l=="object"&&l!==null?l=mr(l):(l=_n(n)?gu:sn.current,l=G1(t,l));var u=n.getDerivedStateFromProps,d=typeof u=="function"||typeof i.getSnapshotBeforeUpdate=="function";d||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(s!==r||c!==l)&&cW(t,i,r,l),za=!1;var f=t.memoizedState;i.state=f,j_(t,r,i,o),c=t.memoizedState,s!==r||f!==c||Pn.current||za?(typeof u=="function"&&(JF(t,n,u,r),c=t.memoizedState),(s=za||sW(t,n,s,r,f,c,l))?(d||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount()),typeof i.componentDidMount=="function"&&(t.flags|=4194308)):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),i.props=r,i.state=c,i.context=l,r=s):(typeof i.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{i=t.stateNode,One(e,t),s=t.memoizedProps,l=t.type===t.elementType?s:Rr(t.type,s),i.props=l,d=t.pendingProps,f=i.context,c=n.contextType,typeof c=="object"&&c!==null?c=mr(c):(c=_n(n)?gu:sn.current,c=G1(t,c));var p=n.getDerivedStateFromProps;(u=typeof p=="function"||typeof i.getSnapshotBeforeUpdate=="function")||typeof i.UNSAFE_componentWillReceiveProps!="function"&&typeof i.componentWillReceiveProps!="function"||(s!==d||f!==c)&&cW(t,i,r,c),za=!1,f=t.memoizedState,i.state=f,j_(t,r,i,o);var y=t.memoizedState;s!==d||f!==y||Pn.current||za?(typeof p=="function"&&(JF(t,n,p,r),y=t.memoizedState),(l=za||sW(t,n,l,r,f,y,c)||!1)?(u||typeof i.UNSAFE_componentWillUpdate!="function"&&typeof i.componentWillUpdate!="function"||(typeof i.componentWillUpdate=="function"&&i.componentWillUpdate(r,y,c),typeof i.UNSAFE_componentWillUpdate=="function"&&i.UNSAFE_componentWillUpdate(r,y,c)),typeof i.componentDidUpdate=="function"&&(t.flags|=4),typeof i.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof i.componentDidUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=y),i.props=r,i.state=y,i.context=c,r=l):(typeof i.componentDidUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof i.getSnapshotBeforeUpdate!="function"||s===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return rH(e,t,n,r,a,o)}function rH(e,t,n,r,o,a){dre(e,t);var i=(t.flags&128)!==0;if(!r&&!i)return o&&JU(t,n,!1),ea(e,t,a);r=t.stateNode,efe.current=t;var s=i&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&i?(t.child=Z1(t,e.child,null,a),t.child=Z1(t,null,s,a)):hn(e,t,s,a),t.memoizedState=r.state,o&&JU(t,n,!0),t.child}function hre(e){var t=e.stateNode;t.pendingContext?QU(e,t.pendingContext,t.pendingContext!==t.context):t.context&&QU(e,t.context,!1),QB(e,t.containerInfo)}function yW(e,t,n,r,o){return K1(),WB(o),t.flags|=256,hn(e,t,n,r),t.child}var oH={dehydrated:null,treeContext:null,retryLane:0};function aH(e){return{baseLanes:e,cachePool:null,transitions:null}}function fre(e,t,n){var r=t.pendingProps,o=It.current,a=!1,i=(t.flags&128)!==0,s;if((s=i)||(s=e!==null&&e.memoizedState===null?!1:(o&2)!==0),s?(a=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(o|=1),kt(It,o&1),e===null)return YF(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(i=r.children,e=r.fallback,a?(r=t.mode,a=t.child,i={mode:"hidden",children:i},!(r&1)&&a!==null?(a.childLanes=0,a.pendingProps=i):a=TR(i,r,0,null),e=pu(e,r,n,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=aH(n),t.memoizedState=oH,e):iV(t,i));if(o=e.memoizedState,o!==null&&(s=o.dehydrated,s!==null))return tfe(e,t,i,r,s,o,n);if(a){a=r.fallback,i=t.mode,o=e.child,s=o.sibling;var c={mode:"hidden",children:r.children};return!(i&1)&&t.child!==o?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=Qa(o,c),r.subtreeFlags=o.subtreeFlags&14680064),s!==null?a=Qa(s,a):(a=pu(a,i,n,null),a.flags|=2),a.return=t,r.return=t,r.sibling=a,t.child=r,r=a,a=t.child,i=e.child.memoizedState,i=i===null?aH(n):{baseLanes:i.baseLanes|n,cachePool:null,transitions:i.transitions},a.memoizedState=i,a.childLanes=e.childLanes&~n,t.memoizedState=oH,r}return a=e.child,e=a.sibling,r=Qa(a,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function iV(e,t){return t=TR({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function l0(e,t,n,r){return r!==null&&WB(r),Z1(t,e.child,null,n),e=iV(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function tfe(e,t,n,r,o,a,i){if(n)return t.flags&256?(t.flags&=-257,r=Ej(Error(fe(422))),l0(e,t,i,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(a=r.fallback,o=t.mode,r=TR({mode:"visible",children:r.children},o,0,null),a=pu(a,o,i,null),a.flags|=2,r.return=t,a.return=t,r.sibling=a,t.child=r,t.mode&1&&Z1(t,e.child,null,i),t.child.memoizedState=aH(i),t.memoizedState=oH,a);if(!(t.mode&1))return l0(e,t,i,null);if(o.data==="$!"){if(r=o.nextSibling&&o.nextSibling.dataset,r)var s=r.dgst;return r=s,a=Error(fe(419)),r=Ej(a,r,void 0),l0(e,t,i,r)}if(s=(i&e.childLanes)!==0,En||s){if(r=Xt,r!==null){switch(i&-i){case 4:o=2;break;case 16:o=8;break;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:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:o=32;break;case 536870912:o=268435456;break;default:o=0}o=o&(r.suspendedLanes|i)?0:o,o!==0&&o!==a.retryLane&&(a.retryLane=o,Jo(e,o),Fr(r,e,o,-1))}return hV(),r=Ej(Error(fe(421))),l0(e,t,i,r)}return o.data==="$?"?(t.flags|=128,t.child=e.child,t=pfe.bind(null,e),o._reactRetry=t,null):(e=a.treeContext,Yn=Ka(o.nextSibling),Jn=t,St=!0,Nr=null,e!==null&&(lr[ur++]=Uo,lr[ur++]=Wo,lr[ur++]=ku,Uo=e.id,Wo=e.overflow,ku=t),t=iV(t,r.children),t.flags|=4096,t)}function mW(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),QF(e.return,t,n)}function Aj(e,t,n,r,o){var a=e.memoizedState;a===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:o}:(a.isBackwards=t,a.rendering=null,a.renderingStartTime=0,a.last=r,a.tail=n,a.tailMode=o)}function pre(e,t,n){var r=t.pendingProps,o=r.revealOrder,a=r.tail;if(hn(e,t,r.children,n),r=It.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&mW(e,n,t);else if(e.tag===19)mW(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(kt(It,r),!(t.mode&1))t.memoizedState=null;else switch(o){case"forwards":for(n=t.child,o=null;n!==null;)e=n.alternate,e!==null&&N_(e)===null&&(o=n),n=n.sibling;n=o,n===null?(o=t.child,t.child=null):(o=n.sibling,n.sibling=null),Aj(t,!1,o,n,a);break;case"backwards":for(n=null,o=t.child,t.child=null;o!==null;){if(e=o.alternate,e!==null&&N_(e)===null){t.child=o;break}e=o.sibling,o.sibling=n,n=o,o=e}Aj(t,!0,n,null,a);break;case"together":Aj(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Y0(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ea(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),xu|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(fe(153));if(t.child!==null){for(e=t.child,n=Qa(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Qa(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function nfe(e,t,n){switch(t.tag){case 3:hre(t),K1();break;case 5:Fne(t);break;case 1:_n(t.type)&&A_(t);break;case 4:QB(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,o=t.memoizedProps.value;kt(R_,r._currentValue),r._currentValue=o;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(kt(It,It.current&1),t.flags|=128,null):n&t.child.childLanes?fre(e,t,n):(kt(It,It.current&1),e=ea(e,t,n),e!==null?e.sibling:null);kt(It,It.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return pre(e,t,n);t.flags|=128}if(o=t.memoizedState,o!==null&&(o.rendering=null,o.tail=null,o.lastEffect=null),kt(It,It.current),r)break;return null;case 22:case 23:return t.lanes=0,ure(e,t,n)}return ea(e,t,n)}var yre,iH,mre,gre;yre=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};iH=function(){};mre=function(e,t,n,r){var o=e.memoizedProps;if(o!==r){e=t.stateNode,uu(xo.current);var a=null;switch(n){case"input":o=EF(e,o),r=EF(e,r),a=[];break;case"select":o=At({},o,{value:void 0}),r=At({},r,{value:void 0}),a=[];break;case"textarea":o=_F(e,o),r=_F(e,r),a=[];break;default:typeof o.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=I_)}TF(n,r);var i;n=null;for(l in o)if(!r.hasOwnProperty(l)&&o.hasOwnProperty(l)&&o[l]!=null)if(l==="style"){var s=o[l];for(i in s)s.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else l!=="dangerouslySetInnerHTML"&&l!=="children"&&l!=="suppressContentEditableWarning"&&l!=="suppressHydrationWarning"&&l!=="autoFocus"&&(m2.hasOwnProperty(l)?a||(a=[]):(a=a||[]).push(l,null));for(l in r){var c=r[l];if(s=o!=null?o[l]:void 0,r.hasOwnProperty(l)&&c!==s&&(c!=null||s!=null))if(l==="style")if(s){for(i in s)!s.hasOwnProperty(i)||c&&c.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in c)c.hasOwnProperty(i)&&s[i]!==c[i]&&(n||(n={}),n[i]=c[i])}else n||(a||(a=[]),a.push(l,n)),n=c;else l==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,s=s?s.__html:void 0,c!=null&&s!==c&&(a=a||[]).push(l,c)):l==="children"?typeof c!="string"&&typeof c!="number"||(a=a||[]).push(l,""+c):l!=="suppressContentEditableWarning"&&l!=="suppressHydrationWarning"&&(m2.hasOwnProperty(l)?(c!=null&&l==="onScroll"&&wt("scroll",e),a||s===c||(a=[])):(a=a||[]).push(l,c))}n&&(a=a||[]).push("style",n);var l=a;(t.updateQueue=l)&&(t.flags|=4)}};gre=function(e,t,n,r){n!==r&&(t.flags|=4)};function Zd(e,t){if(!St)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function rn(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var o=e.child;o!==null;)n|=o.lanes|o.childLanes,r|=o.subtreeFlags&14680064,r|=o.flags&14680064,o.return=e,o=o.sibling;else for(o=e.child;o!==null;)n|=o.lanes|o.childLanes,r|=o.subtreeFlags,r|=o.flags,o.return=e,o=o.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function rfe(e,t,n){var r=t.pendingProps;switch(UB(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return rn(t),null;case 1:return _n(t.type)&&E_(),rn(t),null;case 3:return r=t.stateNode,X1(),bt(Pn),bt(sn),eV(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(s0(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Nr!==null&&(pH(Nr),Nr=null))),iH(e,t),rn(t),null;case 5:JB(t);var o=uu(E2.current);if(n=t.type,e!==null&&t.stateNode!=null)mre(e,t,n,r,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(fe(166));return rn(t),null}if(e=uu(xo.current),s0(t)){r=t.stateNode,n=t.type;var a=t.memoizedProps;switch(r[po]=t,r[L2]=a,e=(t.mode&1)!==0,n){case"dialog":wt("cancel",r),wt("close",r);break;case"iframe":case"object":case"embed":wt("load",r);break;case"video":case"audio":for(o=0;o<hh.length;o++)wt(hh[o],r);break;case"source":wt("error",r);break;case"img":case"image":case"link":wt("error",r),wt("load",r);break;case"details":wt("toggle",r);break;case"input":SU(r,a),wt("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!a.multiple},wt("invalid",r);break;case"textarea":IU(r,a),wt("invalid",r)}TF(n,a),o=null;for(var i in a)if(a.hasOwnProperty(i)){var s=a[i];i==="children"?typeof s=="string"?r.textContent!==s&&(a.suppressHydrationWarning!==!0&&i0(r.textContent,s,e),o=["children",s]):typeof s=="number"&&r.textContent!==""+s&&(a.suppressHydrationWarning!==!0&&i0(r.textContent,s,e),o=["children",""+s]):m2.hasOwnProperty(i)&&s!=null&&i==="onScroll"&&wt("scroll",r)}switch(n){case"input":Qf(r),LU(r,a,!0);break;case"textarea":Qf(r),EU(r);break;case"select":case"option":break;default:typeof a.onClick=="function"&&(r.onclick=I_)}r=o,t.updateQueue=r,r!==null&&(t.flags|=4)}else{i=o.nodeType===9?o:o.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=Ute(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=i.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[po]=t,e[L2]=r,yre(e,t,!1,!1),t.stateNode=e;e:{switch(i=jF(n,r),n){case"dialog":wt("cancel",e),wt("close",e),o=r;break;case"iframe":case"object":case"embed":wt("load",e),o=r;break;case"video":case"audio":for(o=0;o<hh.length;o++)wt(hh[o],e);o=r;break;case"source":wt("error",e),o=r;break;case"img":case"image":case"link":wt("error",e),wt("load",e),o=r;break;case"details":wt("toggle",e),o=r;break;case"input":SU(e,r),o=EF(e,r),wt("invalid",e);break;case"option":o=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},o=At({},r,{value:void 0}),wt("invalid",e);break;case"textarea":IU(e,r),o=_F(e,r),wt("invalid",e);break;default:o=r}TF(n,o),s=o;for(a in s)if(s.hasOwnProperty(a)){var c=s[a];a==="style"?Kte(e,c):a==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&Wte(e,c)):a==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&g2(e,c):typeof c=="number"&&g2(e,""+c):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&(m2.hasOwnProperty(a)?c!=null&&a==="onScroll"&&wt("scroll",e):c!=null&&PB(e,a,c,i))}switch(n){case"input":Qf(e),LU(e,r,!1);break;case"textarea":Qf(e),EU(e);break;case"option":r.value!=null&&e.setAttribute("value",""+ri(r.value));break;case"select":e.multiple=!!r.multiple,a=r.value,a!=null?L1(e,!!r.multiple,a,!1):r.defaultValue!=null&&L1(e,!!r.multiple,r.defaultValue,!0);break;default:typeof o.onClick=="function"&&(e.onclick=I_)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return rn(t),null;case 6:if(e&&t.stateNode!=null)gre(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(fe(166));if(n=uu(E2.current),uu(xo.current),s0(t)){if(r=t.stateNode,n=t.memoizedProps,r[po]=t,(a=r.nodeValue!==n)&&(e=Jn,e!==null))switch(e.tag){case 3:i0(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&i0(r.nodeValue,n,(e.mode&1)!==0)}a&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[po]=t,t.stateNode=r}return rn(t),null;case 13:if(bt(It),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(St&&Yn!==null&&t.mode&1&&!(t.flags&128))Nne(),K1(),t.flags|=98560,a=!1;else if(a=s0(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(fe(318));if(a=t.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(fe(317));a[po]=t}else K1(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;rn(t),a=!1}else Nr!==null&&(pH(Nr),Nr=null),a=!0;if(!a)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||It.current&1?Wt===0&&(Wt=3):hV())),t.updateQueue!==null&&(t.flags|=4),rn(t),null);case 4:return X1(),iH(e,t),e===null&&C2(t.stateNode.containerInfo),rn(t),null;case 10:return ZB(t.type._context),rn(t),null;case 17:return _n(t.type)&&E_(),rn(t),null;case 19:if(bt(It),a=t.memoizedState,a===null)return rn(t),null;if(r=(t.flags&128)!==0,i=a.rendering,i===null)if(r)Zd(a,!1);else{if(Wt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(i=N_(e),i!==null){for(t.flags|=128,Zd(a,!1),r=i.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)a=n,e=r,a.flags&=14680066,i=a.alternate,i===null?(a.childLanes=0,a.lanes=e,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=i.childLanes,a.lanes=i.lanes,a.child=i.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=i.memoizedProps,a.memoizedState=i.memoizedState,a.updateQueue=i.updateQueue,a.type=i.type,e=i.dependencies,a.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return kt(It,It.current&1|2),t.child}e=e.sibling}a.tail!==null&&zt()>Q1&&(t.flags|=128,r=!0,Zd(a,!1),t.lanes=4194304)}else{if(!r)if(e=N_(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Zd(a,!0),a.tail===null&&a.tailMode==="hidden"&&!i.alternate&&!St)return rn(t),null}else 2*zt()-a.renderingStartTime>Q1&&n!==1073741824&&(t.flags|=128,r=!0,Zd(a,!1),t.lanes=4194304);a.isBackwards?(i.sibling=t.child,t.child=i):(n=a.last,n!==null?n.sibling=i:t.child=i,a.last=i)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=zt(),t.sibling=null,n=It.current,kt(It,r?n&1|2:n&1),t):(rn(t),null);case 22:case 23:return dV(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Gn&1073741824&&(rn(t),t.subtreeFlags&6&&(t.flags|=8192)):rn(t),null;case 24:return null;case 25:return null}throw Error(fe(156,t.tag))}function ofe(e,t){switch(UB(t),t.tag){case 1:return _n(t.type)&&E_(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return X1(),bt(Pn),bt(sn),eV(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return JB(t),null;case 13:if(bt(It),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(fe(340));K1()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return bt(It),null;case 4:return X1(),null;case 10:return ZB(t.type._context),null;case 22:case 23:return dV(),null;case 24:return null;default:return null}}var u0=!1,on=!1,afe=typeof WeakSet=="function"?WeakSet:Set,Ce=null;function w1(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){_t(e,t,r)}else n.current=null}function sH(e,t,n){try{n()}catch(r){_t(e,t,r)}}var gW=!1;function ife(e,t){if($F=C_,e=Mne(),VB(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 o=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break e}var i=0,s=-1,c=-1,l=0,u=0,d=e,f=null;t:for(;;){for(var p;d!==n||o!==0&&d.nodeType!==3||(s=i+o),d!==a||r!==0&&d.nodeType!==3||(c=i+r),d.nodeType===3&&(i+=d.nodeValue.length),(p=d.firstChild)!==null;)f=d,d=p;for(;;){if(d===e)break t;if(f===n&&++l===o&&(s=i),f===a&&++u===r&&(c=i),(p=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=p}n=s===-1||c===-1?null:{start:s,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(UF={focusedElem:e,selectionRange:n},C_=!1,Ce=t;Ce!==null;)if(t=Ce,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,Ce=e;else for(;Ce!==null;){t=Ce;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var k=y.memoizedProps,w=y.memoizedState,v=t.stateNode,M=v.getSnapshotBeforeUpdate(t.elementType===t.type?k:Rr(t.type,k),w);v.__reactInternalSnapshotBeforeUpdate=M}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(fe(163))}}catch(b){_t(t,t.return,b)}if(e=t.sibling,e!==null){e.return=t.return,Ce=e;break}Ce=t.return}return y=gW,gW=!1,y}function Ph(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var a=o.destroy;o.destroy=void 0,a!==void 0&&sH(t,n,a)}o=o.next}while(o!==r)}}function _R(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 cH(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 kre(e){var t=e.alternate;t!==null&&(e.alternate=null,kre(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[po],delete t[L2],delete t[KF],delete t[B2e],delete t[V2e])),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 vre(e){return e.tag===5||e.tag===3||e.tag===4}function kW(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||vre(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 lH(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=I_));else if(r!==4&&(e=e.child,e!==null))for(lH(e,t,n),e=e.sibling;e!==null;)lH(e,t,n),e=e.sibling}function uH(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(uH(e,t,n),e=e.sibling;e!==null;)uH(e,t,n),e=e.sibling}var Yt=null,Tr=!1;function La(e,t,n){for(n=n.child;n!==null;)xre(e,t,n),n=n.sibling}function xre(e,t,n){if(vo&&typeof vo.onCommitFiberUnmount=="function")try{vo.onCommitFiberUnmount(bR,n)}catch{}switch(n.tag){case 5:on||w1(n,t);case 6:var r=Yt,o=Tr;Yt=null,La(e,t,n),Yt=r,Tr=o,Yt!==null&&(Tr?(e=Yt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Yt.removeChild(n.stateNode));break;case 18:Yt!==null&&(Tr?(e=Yt,n=n.stateNode,e.nodeType===8?Mj(e.parentNode,n):e.nodeType===1&&Mj(e,n),w2(e)):Mj(Yt,n.stateNode));break;case 4:r=Yt,o=Tr,Yt=n.stateNode.containerInfo,Tr=!0,La(e,t,n),Yt=r,Tr=o;break;case 0:case 11:case 14:case 15:if(!on&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var a=o,i=a.destroy;a=a.tag,i!==void 0&&(a&2||a&4)&&sH(n,t,i),o=o.next}while(o!==r)}La(e,t,n);break;case 1:if(!on&&(w1(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){_t(n,t,s)}La(e,t,n);break;case 21:La(e,t,n);break;case 22:n.mode&1?(on=(r=on)||n.memoizedState!==null,La(e,t,n),on=r):La(e,t,n);break;default:La(e,t,n)}}function vW(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new afe),t.forEach(function(r){var o=yfe.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function Er(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var o=n[r];try{var a=e,i=t,s=i;e:for(;s!==null;){switch(s.tag){case 5:Yt=s.stateNode,Tr=!1;break e;case 3:Yt=s.stateNode.containerInfo,Tr=!0;break e;case 4:Yt=s.stateNode.containerInfo,Tr=!0;break e}s=s.return}if(Yt===null)throw Error(fe(160));xre(a,i,o),Yt=null,Tr=!1;var c=o.alternate;c!==null&&(c.return=null),o.return=null}catch(l){_t(o,t,l)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)wre(t,e),t=t.sibling}function wre(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Er(t,e),ao(e),r&4){try{Ph(3,e,e.return),_R(3,e)}catch(k){_t(e,e.return,k)}try{Ph(5,e,e.return)}catch(k){_t(e,e.return,k)}}break;case 1:Er(t,e),ao(e),r&512&&n!==null&&w1(n,n.return);break;case 5:if(Er(t,e),ao(e),r&512&&n!==null&&w1(n,n.return),e.flags&32){var o=e.stateNode;try{g2(o,"")}catch(k){_t(e,e.return,k)}}if(r&4&&(o=e.stateNode,o!=null)){var a=e.memoizedProps,i=n!==null?n.memoizedProps:a,s=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{s==="input"&&a.type==="radio"&&a.name!=null&&Vte(o,a),jF(s,i);var l=jF(s,a);for(i=0;i<c.length;i+=2){var u=c[i],d=c[i+1];u==="style"?Kte(o,d):u==="dangerouslySetInnerHTML"?Wte(o,d):u==="children"?g2(o,d):PB(o,u,d,l)}switch(s){case"input":AF(o,a);break;case"textarea":$te(o,a);break;case"select":var f=o._wrapperState.wasMultiple;o._wrapperState.wasMultiple=!!a.multiple;var p=a.value;p!=null?L1(o,!!a.multiple,p,!1):f!==!!a.multiple&&(a.defaultValue!=null?L1(o,!!a.multiple,a.defaultValue,!0):L1(o,!!a.multiple,a.multiple?[]:"",!1))}o[L2]=a}catch(k){_t(e,e.return,k)}}break;case 6:if(Er(t,e),ao(e),r&4){if(e.stateNode===null)throw Error(fe(162));o=e.stateNode,a=e.memoizedProps;try{o.nodeValue=a}catch(k){_t(e,e.return,k)}}break;case 3:if(Er(t,e),ao(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{w2(t.containerInfo)}catch(k){_t(e,e.return,k)}break;case 4:Er(t,e),ao(e);break;case 13:Er(t,e),ao(e),o=e.child,o.flags&8192&&(a=o.memoizedState!==null,o.stateNode.isHidden=a,!a||o.alternate!==null&&o.alternate.memoizedState!==null||(lV=zt())),r&4&&vW(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?(on=(l=on)||u,Er(t,e),on=l):Er(t,e),ao(e),r&8192){if(l=e.memoizedState!==null,(e.stateNode.isHidden=l)&&!u&&e.mode&1)for(Ce=e,u=e.child;u!==null;){for(d=Ce=u;Ce!==null;){switch(f=Ce,p=f.child,f.tag){case 0:case 11:case 14:case 15:Ph(4,f,f.return);break;case 1:w1(f,f.return);var y=f.stateNode;if(typeof y.componentWillUnmount=="function"){r=f,n=f.return;try{t=r,y.props=t.memoizedProps,y.state=t.memoizedState,y.componentWillUnmount()}catch(k){_t(r,n,k)}}break;case 5:w1(f,f.return);break;case 22:if(f.memoizedState!==null){wW(d);continue}}p!==null?(p.return=f,Ce=p):wW(d)}u=u.sibling}e:for(u=null,d=e;;){if(d.tag===5){if(u===null){u=d;try{o=d.stateNode,l?(a=o.style,typeof a.setProperty=="function"?a.setProperty("display","none","important"):a.display="none"):(s=d.stateNode,c=d.memoizedProps.style,i=c!=null&&c.hasOwnProperty("display")?c.display:null,s.style.display=Gte("display",i))}catch(k){_t(e,e.return,k)}}}else if(d.tag===6){if(u===null)try{d.stateNode.nodeValue=l?"":d.memoizedProps}catch(k){_t(e,e.return,k)}}else if((d.tag!==22&&d.tag!==23||d.memoizedState===null||d===e)&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===e)break e;for(;d.sibling===null;){if(d.return===null||d.return===e)break e;u===d&&(u=null),d=d.return}u===d&&(u=null),d.sibling.return=d.return,d=d.sibling}}break;case 19:Er(t,e),ao(e),r&4&&vW(e);break;case 21:break;default:Er(t,e),ao(e)}}function ao(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(vre(n)){var r=n;break e}n=n.return}throw Error(fe(160))}switch(r.tag){case 5:var o=r.stateNode;r.flags&32&&(g2(o,""),r.flags&=-33);var a=kW(e);uH(e,a,o);break;case 3:case 4:var i=r.stateNode.containerInfo,s=kW(e);lH(e,s,i);break;default:throw Error(fe(161))}}catch(c){_t(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function sfe(e,t,n){Ce=e,Mre(e)}function Mre(e,t,n){for(var r=(e.mode&1)!==0;Ce!==null;){var o=Ce,a=o.child;if(o.tag===22&&r){var i=o.memoizedState!==null||u0;if(!i){var s=o.alternate,c=s!==null&&s.memoizedState!==null||on;s=u0;var l=on;if(u0=i,(on=c)&&!l)for(Ce=o;Ce!==null;)i=Ce,c=i.child,i.tag===22&&i.memoizedState!==null?MW(o):c!==null?(c.return=i,Ce=c):MW(o);for(;a!==null;)Ce=a,Mre(a),a=a.sibling;Ce=o,u0=s,on=l}xW(e)}else o.subtreeFlags&8772&&a!==null?(a.return=o,Ce=a):xW(e)}}function xW(e){for(;Ce!==null;){var t=Ce;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:on||_R(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!on)if(n===null)r.componentDidMount();else{var o=t.elementType===t.type?n.memoizedProps:Rr(t.type,n.memoizedProps);r.componentDidUpdate(o,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var a=t.updateQueue;a!==null&&oW(t,a,r);break;case 3:var i=t.updateQueue;if(i!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}oW(t,i,n)}break;case 5:var s=t.stateNode;if(n===null&&t.flags&4){n=s;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var l=t.alternate;if(l!==null){var u=l.memoizedState;if(u!==null){var d=u.dehydrated;d!==null&&w2(d)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(fe(163))}on||t.flags&512&&cH(t)}catch(f){_t(t,t.return,f)}}if(t===e){Ce=null;break}if(n=t.sibling,n!==null){n.return=t.return,Ce=n;break}Ce=t.return}}function wW(e){for(;Ce!==null;){var t=Ce;if(t===e){Ce=null;break}var n=t.sibling;if(n!==null){n.return=t.return,Ce=n;break}Ce=t.return}}function MW(e){for(;Ce!==null;){var t=Ce;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{_R(4,t)}catch(c){_t(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var o=t.return;try{r.componentDidMount()}catch(c){_t(t,o,c)}}var a=t.return;try{cH(t)}catch(c){_t(t,a,c)}break;case 5:var i=t.return;try{cH(t)}catch(c){_t(t,i,c)}}}catch(c){_t(t,t.return,c)}if(t===e){Ce=null;break}var s=t.sibling;if(s!==null){s.return=t.return,Ce=s;break}Ce=t.return}}var cfe=Math.ceil,q_=aa.ReactCurrentDispatcher,sV=aa.ReactCurrentOwner,pr=aa.ReactCurrentBatchConfig,tt=0,Xt=null,Ht=null,Qt=0,Gn=0,M1=hi(0),Wt=0,R2=null,xu=0,RR=0,cV=0,_h=null,In=null,lV=0,Q1=1/0,Vo=null,O_=!1,dH=null,Xa=null,d0=!1,$a=null,F_=0,Rh=0,hH=null,Q0=-1,J0=0;function pn(){return tt&6?zt():Q0!==-1?Q0:Q0=zt()}function Ya(e){return e.mode&1?tt&2&&Qt!==0?Qt&-Qt:U2e.transition!==null?(J0===0&&(J0=ine()),J0):(e=lt,e!==0||(e=window.event,e=e===void 0?16:fne(e.type)),e):1}function Fr(e,t,n,r){if(50<Rh)throw Rh=0,hH=null,Error(fe(185));X2(e,n,r),(!(tt&2)||e!==Xt)&&(e===Xt&&(!(tt&2)&&(RR|=n),Wt===4&&Oa(e,Qt)),Rn(e,r),n===1&&tt===0&&!(t.mode&1)&&(Q1=zt()+500,ER&&fi()))}function Rn(e,t){var n=e.callbackNode;Uhe(e,t);var r=b_(e,e===Xt?Qt:0);if(r===0)n!==null&&_U(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&_U(n),t===1)e.tag===0?$2e(bW.bind(null,e)):Rne(bW.bind(null,e)),F2e(function(){!(tt&6)&&fi()}),n=null;else{switch(sne(r)){case 1:n=NB;break;case 4:n=one;break;case 16:n=M_;break;case 536870912:n=ane;break;default:n=M_}n=Pre(n,bre.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function bre(e,t){if(Q0=-1,J0=0,tt&6)throw Error(fe(327));var n=e.callbackNode;if(_1()&&e.callbackNode!==n)return null;var r=b_(e,e===Xt?Qt:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=H_(e,r);else{t=r;var o=tt;tt|=2;var a=Sre();(Xt!==e||Qt!==t)&&(Vo=null,Q1=zt()+500,fu(e,t));do try{dfe();break}catch(s){Cre(e,s)}while(!0);KB(),q_.current=a,tt=o,Ht!==null?t=0:(Xt=null,Qt=0,t=Wt)}if(t!==0){if(t===2&&(o=OF(e),o!==0&&(r=o,t=fH(e,o))),t===1)throw n=R2,fu(e,0),Oa(e,r),Rn(e,zt()),n;if(t===6)Oa(e,r);else{if(o=e.current.alternate,!(r&30)&&!lfe(o)&&(t=H_(e,r),t===2&&(a=OF(e),a!==0&&(r=a,t=fH(e,a))),t===1))throw n=R2,fu(e,0),Oa(e,r),Rn(e,zt()),n;switch(e.finishedWork=o,e.finishedLanes=r,t){case 0:case 1:throw Error(fe(345));case 2:Ti(e,In,Vo);break;case 3:if(Oa(e,r),(r&130023424)===r&&(t=lV+500-zt(),10<t)){if(b_(e,0)!==0)break;if(o=e.suspendedLanes,(o&r)!==r){pn(),e.pingedLanes|=e.suspendedLanes&o;break}e.timeoutHandle=GF(Ti.bind(null,e,In,Vo),t);break}Ti(e,In,Vo);break;case 4:if(Oa(e,r),(r&4194240)===r)break;for(t=e.eventTimes,o=-1;0<r;){var i=31-Or(r);a=1<<i,i=t[i],i>o&&(o=i),r&=~a}if(r=o,r=zt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*cfe(r/1960))-r,10<r){e.timeoutHandle=GF(Ti.bind(null,e,In,Vo),r);break}Ti(e,In,Vo);break;case 5:Ti(e,In,Vo);break;default:throw Error(fe(329))}}}return Rn(e,zt()),e.callbackNode===n?bre.bind(null,e):null}function fH(e,t){var n=_h;return e.current.memoizedState.isDehydrated&&(fu(e,t).flags|=256),e=H_(e,t),e!==2&&(t=In,In=n,t!==null&&pH(t)),e}function pH(e){In===null?In=e:In.push.apply(In,e)}function lfe(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var o=n[r],a=o.getSnapshot;o=o.value;try{if(!Br(a(),o))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Oa(e,t){for(t&=~cV,t&=~RR,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Or(t),r=1<<n;e[n]=-1,t&=~r}}function bW(e){if(tt&6)throw Error(fe(327));_1();var t=b_(e,0);if(!(t&1))return Rn(e,zt()),null;var n=H_(e,t);if(e.tag!==0&&n===2){var r=OF(e);r!==0&&(t=r,n=fH(e,r))}if(n===1)throw n=R2,fu(e,0),Oa(e,t),Rn(e,zt()),n;if(n===6)throw Error(fe(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Ti(e,In,Vo),Rn(e,zt()),null}function uV(e,t){var n=tt;tt|=1;try{return e(t)}finally{tt=n,tt===0&&(Q1=zt()+500,ER&&fi())}}function wu(e){$a!==null&&$a.tag===0&&!(tt&6)&&_1();var t=tt;tt|=1;var n=pr.transition,r=lt;try{if(pr.transition=null,lt=1,e)return e()}finally{lt=r,pr.transition=n,tt=t,!(tt&6)&&fi()}}function dV(){Gn=M1.current,bt(M1)}function fu(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,O2e(n)),Ht!==null)for(n=Ht.return;n!==null;){var r=n;switch(UB(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&E_();break;case 3:X1(),bt(Pn),bt(sn),eV();break;case 5:JB(r);break;case 4:X1();break;case 13:bt(It);break;case 19:bt(It);break;case 10:ZB(r.type._context);break;case 22:case 23:dV()}n=n.return}if(Xt=e,Ht=e=Qa(e.current,null),Qt=Gn=t,Wt=0,R2=null,cV=RR=xu=0,In=_h=null,lu!==null){for(t=0;t<lu.length;t++)if(n=lu[t],r=n.interleaved,r!==null){n.interleaved=null;var o=r.next,a=n.pending;if(a!==null){var i=a.next;a.next=o,r.next=i}n.pending=r}lu=null}return e}function Cre(e,t){do{var n=Ht;try{if(KB(),Z0.current=D_,z_){for(var r=Et.memoizedState;r!==null;){var o=r.queue;o!==null&&(o.pending=null),r=r.next}z_=!1}if(vu=0,Zt=Ut=Et=null,Ah=!1,A2=0,sV.current=null,n===null||n.return===null){Wt=1,R2=t,Ht=null;break}e:{var a=e,i=n.return,s=n,c=t;if(t=Qt,s.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var l=c,u=s,d=u.tag;if(!(u.mode&1)&&(d===0||d===11||d===15)){var f=u.alternate;f?(u.updateQueue=f.updateQueue,u.memoizedState=f.memoizedState,u.lanes=f.lanes):(u.updateQueue=null,u.memoizedState=null)}var p=uW(i);if(p!==null){p.flags&=-257,dW(p,i,s,a,t),p.mode&1&&lW(a,l,t),t=p,c=l;var y=t.updateQueue;if(y===null){var k=new Set;k.add(c),t.updateQueue=k}else y.add(c);break e}else{if(!(t&1)){lW(a,l,t),hV();break e}c=Error(fe(426))}}else if(St&&s.mode&1){var w=uW(i);if(w!==null){!(w.flags&65536)&&(w.flags|=256),dW(w,i,s,a,t),WB(Y1(c,s));break e}}a=c=Y1(c,s),Wt!==4&&(Wt=2),_h===null?_h=[a]:_h.push(a),a=i;do{switch(a.tag){case 3:a.flags|=65536,t&=-t,a.lanes|=t;var v=sre(a,c,t);rW(a,v);break e;case 1:s=c;var M=a.type,x=a.stateNode;if(!(a.flags&128)&&(typeof M.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Xa===null||!Xa.has(x)))){a.flags|=65536,t&=-t,a.lanes|=t;var b=cre(a,s,t);rW(a,b);break e}}a=a.return}while(a!==null)}Ire(n)}catch(S){t=S,Ht===n&&n!==null&&(Ht=n=n.return);continue}break}while(!0)}function Sre(){var e=q_.current;return q_.current=D_,e===null?D_:e}function hV(){(Wt===0||Wt===3||Wt===2)&&(Wt=4),Xt===null||!(xu&268435455)&&!(RR&268435455)||Oa(Xt,Qt)}function H_(e,t){var n=tt;tt|=2;var r=Sre();(Xt!==e||Qt!==t)&&(Vo=null,fu(e,t));do try{ufe();break}catch(o){Cre(e,o)}while(!0);if(KB(),tt=n,q_.current=r,Ht!==null)throw Error(fe(261));return Xt=null,Qt=0,Wt}function ufe(){for(;Ht!==null;)Lre(Ht)}function dfe(){for(;Ht!==null&&!zhe();)Lre(Ht)}function Lre(e){var t=Are(e.alternate,e,Gn);e.memoizedProps=e.pendingProps,t===null?Ire(e):Ht=t,sV.current=null}function Ire(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=ofe(n,t),n!==null){n.flags&=32767,Ht=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Wt=6,Ht=null;return}}else if(n=rfe(n,t,Gn),n!==null){Ht=n;return}if(t=t.sibling,t!==null){Ht=t;return}Ht=t=e}while(t!==null);Wt===0&&(Wt=5)}function Ti(e,t,n){var r=lt,o=pr.transition;try{pr.transition=null,lt=1,hfe(e,t,n,r)}finally{pr.transition=o,lt=r}return null}function hfe(e,t,n,r){do _1();while($a!==null);if(tt&6)throw Error(fe(327));n=e.finishedWork;var o=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(fe(177));e.callbackNode=null,e.callbackPriority=0;var a=n.lanes|n.childLanes;if(Whe(e,a),e===Xt&&(Ht=Xt=null,Qt=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||d0||(d0=!0,Pre(M_,function(){return _1(),null})),a=(n.flags&15990)!==0,n.subtreeFlags&15990||a){a=pr.transition,pr.transition=null;var i=lt;lt=1;var s=tt;tt|=4,sV.current=null,ife(e,n),wre(n,e),R2e(UF),C_=!!$F,UF=$F=null,e.current=n,sfe(n),Dhe(),tt=s,lt=i,pr.transition=a}else e.current=n;if(d0&&(d0=!1,$a=e,F_=o),a=e.pendingLanes,a===0&&(Xa=null),Fhe(n.stateNode),Rn(e,zt()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)o=t[n],r(o.value,{componentStack:o.stack,digest:o.digest});if(O_)throw O_=!1,e=dH,dH=null,e;return F_&1&&e.tag!==0&&_1(),a=e.pendingLanes,a&1?e===hH?Rh++:(Rh=0,hH=e):Rh=0,fi(),null}function _1(){if($a!==null){var e=sne(F_),t=pr.transition,n=lt;try{if(pr.transition=null,lt=16>e?16:e,$a===null)var r=!1;else{if(e=$a,$a=null,F_=0,tt&6)throw Error(fe(331));var o=tt;for(tt|=4,Ce=e.current;Ce!==null;){var a=Ce,i=a.child;if(Ce.flags&16){var s=a.deletions;if(s!==null){for(var c=0;c<s.length;c++){var l=s[c];for(Ce=l;Ce!==null;){var u=Ce;switch(u.tag){case 0:case 11:case 15:Ph(8,u,a)}var d=u.child;if(d!==null)d.return=u,Ce=d;else for(;Ce!==null;){u=Ce;var f=u.sibling,p=u.return;if(kre(u),u===l){Ce=null;break}if(f!==null){f.return=p,Ce=f;break}Ce=p}}}var y=a.alternate;if(y!==null){var k=y.child;if(k!==null){y.child=null;do{var w=k.sibling;k.sibling=null,k=w}while(k!==null)}}Ce=a}}if(a.subtreeFlags&2064&&i!==null)i.return=a,Ce=i;else e:for(;Ce!==null;){if(a=Ce,a.flags&2048)switch(a.tag){case 0:case 11:case 15:Ph(9,a,a.return)}var v=a.sibling;if(v!==null){v.return=a.return,Ce=v;break e}Ce=a.return}}var M=e.current;for(Ce=M;Ce!==null;){i=Ce;var x=i.child;if(i.subtreeFlags&2064&&x!==null)x.return=i,Ce=x;else e:for(i=M;Ce!==null;){if(s=Ce,s.flags&2048)try{switch(s.tag){case 0:case 11:case 15:_R(9,s)}}catch(S){_t(s,s.return,S)}if(s===i){Ce=null;break e}var b=s.sibling;if(b!==null){b.return=s.return,Ce=b;break e}Ce=s.return}}if(tt=o,fi(),vo&&typeof vo.onPostCommitFiberRoot=="function")try{vo.onPostCommitFiberRoot(bR,e)}catch{}r=!0}return r}finally{lt=n,pr.transition=t}}return!1}function CW(e,t,n){t=Y1(n,t),t=sre(e,t,1),e=Za(e,t,1),t=pn(),e!==null&&(X2(e,1,t),Rn(e,t))}function _t(e,t,n){if(e.tag===3)CW(e,e,n);else for(;t!==null;){if(t.tag===3){CW(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Xa===null||!Xa.has(r))){e=Y1(n,e),e=cre(t,e,1),t=Za(t,e,1),e=pn(),t!==null&&(X2(t,1,e),Rn(t,e));break}}t=t.return}}function ffe(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=pn(),e.pingedLanes|=e.suspendedLanes&n,Xt===e&&(Qt&n)===n&&(Wt===4||Wt===3&&(Qt&130023424)===Qt&&500>zt()-lV?fu(e,0):cV|=n),Rn(e,t)}function Ere(e,t){t===0&&(e.mode&1?(t=t0,t0<<=1,!(t0&130023424)&&(t0=4194304)):t=1);var n=pn();e=Jo(e,t),e!==null&&(X2(e,t,n),Rn(e,n))}function pfe(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ere(e,n)}function yfe(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(fe(314))}r!==null&&r.delete(t),Ere(e,n)}var Are;Are=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Pn.current)En=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return En=!1,nfe(e,t,n);En=!!(e.flags&131072)}else En=!1,St&&t.flags&1048576&&Tne(t,__,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Y0(e,t),e=t.pendingProps;var o=G1(t,sn.current);P1(t,n),o=nV(null,t,r,e,o,n);var a=rV();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,_n(r)?(a=!0,A_(t)):a=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,YB(t),o.updater=PR,t.stateNode=o,o._reactInternals=t,eH(t,r,e,n),t=rH(null,t,r,!0,a,n)):(t.tag=0,St&&a&&$B(t),hn(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Y0(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=gfe(r),e=Rr(r,e),o){case 0:t=nH(null,t,r,e,n);break e;case 1:t=pW(null,t,r,e,n);break e;case 11:t=hW(null,t,r,e,n);break e;case 14:t=fW(null,t,r,Rr(r.type,e),n);break e}throw Error(fe(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Rr(r,o),nH(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Rr(r,o),pW(e,t,r,o,n);case 3:e:{if(hre(t),e===null)throw Error(fe(387));r=t.pendingProps,a=t.memoizedState,o=a.element,One(e,t),j_(t,r,null,n);var i=t.memoizedState;if(r=i.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){o=Y1(Error(fe(423)),t),t=yW(e,t,r,n,o);break e}else if(r!==o){o=Y1(Error(fe(424)),t),t=yW(e,t,r,n,o);break e}else for(Yn=Ka(t.stateNode.containerInfo.firstChild),Jn=t,St=!0,Nr=null,n=Dne(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(K1(),r===o){t=ea(e,t,n);break e}hn(e,t,r,n)}t=t.child}return t;case 5:return Fne(t),e===null&&YF(t),r=t.type,o=t.pendingProps,a=e!==null?e.memoizedProps:null,i=o.children,WF(r,o)?i=null:a!==null&&WF(r,a)&&(t.flags|=32),dre(e,t),hn(e,t,i,n),t.child;case 6:return e===null&&YF(t),null;case 13:return fre(e,t,n);case 4:return QB(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Z1(t,null,r,n):hn(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Rr(r,o),hW(e,t,r,o,n);case 7:return hn(e,t,t.pendingProps,n),t.child;case 8:return hn(e,t,t.pendingProps.children,n),t.child;case 12:return hn(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,a=t.memoizedProps,i=o.value,kt(R_,r._currentValue),r._currentValue=i,a!==null)if(Br(a.value,i)){if(a.children===o.children&&!Pn.current){t=ea(e,t,n);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var s=a.dependencies;if(s!==null){i=a.child;for(var c=s.firstContext;c!==null;){if(c.context===r){if(a.tag===1){c=Xo(-1,n&-n),c.tag=2;var l=a.updateQueue;if(l!==null){l=l.shared;var u=l.pending;u===null?c.next=c:(c.next=u.next,u.next=c),l.pending=c}}a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),QF(a.return,n,t),s.lanes|=n;break}c=c.next}}else if(a.tag===10)i=a.type===t.type?null:a.child;else if(a.tag===18){if(i=a.return,i===null)throw Error(fe(341));i.lanes|=n,s=i.alternate,s!==null&&(s.lanes|=n),QF(i,n,t),i=a.sibling}else i=a.child;if(i!==null)i.return=a;else for(i=a;i!==null;){if(i===t){i=null;break}if(a=i.sibling,a!==null){a.return=i.return,i=a;break}i=i.return}a=i}hn(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,P1(t,n),o=mr(o),r=r(o),t.flags|=1,hn(e,t,r,n),t.child;case 14:return r=t.type,o=Rr(r,t.pendingProps),o=Rr(r.type,o),fW(e,t,r,o,n);case 15:return lre(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Rr(r,o),Y0(e,t),t.tag=1,_n(r)?(e=!0,A_(t)):e=!1,P1(t,n),ire(t,r,o),eH(t,r,o,n),rH(null,t,r,!0,e,n);case 19:return pre(e,t,n);case 22:return ure(e,t,n)}throw Error(fe(156,t.tag))};function Pre(e,t){return rne(e,t)}function mfe(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 fr(e,t,n,r){return new mfe(e,t,n,r)}function fV(e){return e=e.prototype,!(!e||!e.isReactComponent)}function gfe(e){if(typeof e=="function")return fV(e)?1:0;if(e!=null){if(e=e.$$typeof,e===RB)return 11;if(e===TB)return 14}return 2}function Qa(e,t){var n=e.alternate;return n===null?(n=fr(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 ep(e,t,n,r,o,a){var i=2;if(r=e,typeof e=="function")fV(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case h1:return pu(n.children,o,a,t);case _B:i=8,o|=8;break;case CF:return e=fr(12,n,t,o|2),e.elementType=CF,e.lanes=a,e;case SF:return e=fr(13,n,t,o),e.elementType=SF,e.lanes=a,e;case LF:return e=fr(19,n,t,o),e.elementType=LF,e.lanes=a,e;case Fte:return TR(n,o,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case qte:i=10;break e;case Ote:i=9;break e;case RB:i=11;break e;case TB:i=14;break e;case Na:i=16,r=null;break e}throw Error(fe(130,e==null?e:typeof e,""))}return t=fr(i,n,t,o),t.elementType=e,t.type=r,t.lanes=a,t}function pu(e,t,n,r){return e=fr(7,e,r,t),e.lanes=n,e}function TR(e,t,n,r){return e=fr(22,e,r,t),e.elementType=Fte,e.lanes=n,e.stateNode={isHidden:!1},e}function Pj(e,t,n){return e=fr(6,e,null,t),e.lanes=n,e}function _j(e,t,n){return t=fr(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function kfe(e,t,n,r,o){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=dj(0),this.expirationTimes=dj(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=dj(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function pV(e,t,n,r,o,a,i,s,c){return e=new kfe(e,t,n,s,c),t===1?(t=1,a===!0&&(t|=8)):t=0,a=fr(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},YB(a),e}function vfe(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:d1,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function _re(e){if(!e)return oi;e=e._reactInternals;e:{if(Tu(e)!==e||e.tag!==1)throw Error(fe(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(_n(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(fe(171))}if(e.tag===1){var n=e.type;if(_n(n))return _ne(e,n,t)}return t}function Rre(e,t,n,r,o,a,i,s,c){return e=pV(n,r,!0,e,o,a,i,s,c),e.context=_re(null),n=e.current,r=pn(),o=Ya(n),a=Xo(r,o),a.callback=t??null,Za(n,a,o),e.current.lanes=o,X2(e,o,r),Rn(e,r),e}function jR(e,t,n,r){var o=t.current,a=pn(),i=Ya(o);return n=_re(n),t.context===null?t.context=n:t.pendingContext=n,t=Xo(a,i),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Za(o,t,i),e!==null&&(Fr(e,o,i,a),K0(e,o,i)),i}function B_(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function SW(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function yV(e,t){SW(e,t),(e=e.alternate)&&SW(e,t)}function xfe(){return null}var Tre=typeof reportError=="function"?reportError:function(e){console.error(e)};function mV(e){this._internalRoot=e}NR.prototype.render=mV.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(fe(409));jR(e,t,null,null)};NR.prototype.unmount=mV.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;wu(function(){jR(null,e,null,null)}),t[Qo]=null}};function NR(e){this._internalRoot=e}NR.prototype.unstable_scheduleHydration=function(e){if(e){var t=une();e={blockedOn:null,target:e,priority:t};for(var n=0;n<qa.length&&t!==0&&t<qa[n].priority;n++);qa.splice(n,0,e),n===0&&hne(e)}};function gV(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function zR(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function LW(){}function wfe(e,t,n,r,o){if(o){if(typeof r=="function"){var a=r;r=function(){var l=B_(i);a.call(l)}}var i=Rre(t,r,e,0,null,!1,!1,"",LW);return e._reactRootContainer=i,e[Qo]=i.current,C2(e.nodeType===8?e.parentNode:e),wu(),i}for(;o=e.lastChild;)e.removeChild(o);if(typeof r=="function"){var s=r;r=function(){var l=B_(c);s.call(l)}}var c=pV(e,0,!1,null,null,!1,!1,"",LW);return e._reactRootContainer=c,e[Qo]=c.current,C2(e.nodeType===8?e.parentNode:e),wu(function(){jR(t,c,n,r)}),c}function DR(e,t,n,r,o){var a=n._reactRootContainer;if(a){var i=a;if(typeof o=="function"){var s=o;o=function(){var c=B_(i);s.call(c)}}jR(t,i,e,o)}else i=wfe(n,t,e,o,r);return B_(i)}cne=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=dh(t.pendingLanes);n!==0&&(zB(t,n|1),Rn(t,zt()),!(tt&6)&&(Q1=zt()+500,fi()))}break;case 13:wu(function(){var r=Jo(e,1);if(r!==null){var o=pn();Fr(r,e,1,o)}}),yV(e,1)}};DB=function(e){if(e.tag===13){var t=Jo(e,134217728);if(t!==null){var n=pn();Fr(t,e,134217728,n)}yV(e,134217728)}};lne=function(e){if(e.tag===13){var t=Ya(e),n=Jo(e,t);if(n!==null){var r=pn();Fr(n,e,t,r)}yV(e,t)}};une=function(){return lt};dne=function(e,t){var n=lt;try{return lt=e,t()}finally{lt=n}};zF=function(e,t,n){switch(t){case"input":if(AF(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var o=IR(r);if(!o)throw Error(fe(90));Bte(r),AF(r,o)}}}break;case"textarea":$te(e,n);break;case"select":t=n.value,t!=null&&L1(e,!!n.multiple,t,!1)}};Yte=uV;Qte=wu;var Mfe={usingClientEntryPoint:!1,Events:[Q2,m1,IR,Zte,Xte,uV]},Xd={findFiberByHostInstance:cu,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},bfe={bundleType:Xd.bundleType,version:Xd.version,rendererPackageName:Xd.rendererPackageName,rendererConfig:Xd.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:aa.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=tne(e),e===null?null:e.stateNode},findFiberByHostInstance:Xd.findFiberByHostInstance||xfe,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var h0=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!h0.isDisabled&&h0.supportsFiber)try{bR=h0.inject(bfe),vo=h0}catch{}}or.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=Mfe;or.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!gV(t))throw Error(fe(200));return vfe(e,t,null,n)};or.createRoot=function(e,t){if(!gV(e))throw Error(fe(299));var n=!1,r="",o=Tre;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(o=t.onRecoverableError)),t=pV(e,1,!1,null,null,n,!1,r,o),e[Qo]=t.current,C2(e.nodeType===8?e.parentNode:e),new mV(t)};or.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(fe(188)):(e=Object.keys(e).join(","),Error(fe(268,e)));return e=tne(t),e=e===null?null:e.stateNode,e};or.flushSync=function(e){return wu(e)};or.hydrate=function(e,t,n){if(!zR(t))throw Error(fe(200));return DR(null,e,t,!0,n)};or.hydrateRoot=function(e,t,n){if(!gV(e))throw Error(fe(405));var r=n!=null&&n.hydratedSources||null,o=!1,a="",i=Tre;if(n!=null&&(n.unstable_strictMode===!0&&(o=!0),n.identifierPrefix!==void 0&&(a=n.identifierPrefix),n.onRecoverableError!==void 0&&(i=n.onRecoverableError)),t=Rre(t,null,e,1,n??null,o,!1,a,i),e[Qo]=t.current,C2(e),r)for(e=0;e<r.length;e++)n=r[e],o=n._getVersion,o=o(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,o]:t.mutableSourceEagerHydrationData.push(n,o);return new NR(t)};or.render=function(e,t,n){if(!zR(t))throw Error(fe(200));return DR(null,e,t,!1,n)};or.unmountComponentAtNode=function(e){if(!zR(e))throw Error(fe(40));return e._reactRootContainer?(wu(function(){DR(null,null,e,!1,function(){e._reactRootContainer=null,e[Qo]=null})}),!0):!1};or.unstable_batchedUpdates=uV;or.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!zR(n))throw Error(fe(200));if(e==null||e._reactInternals===void 0)throw Error(fe(38));return DR(e,t,n,!1,r)};or.version="18.3.1-next-f1338f8080-20240426";function jre(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(jre)}catch(e){console.error(e)}}jre(),jte.exports=or;var wd=jte.exports;const Cfe=gd(wd);var IW=wd;MF.createRoot=IW.createRoot,MF.hydrateRoot=IW.hydrateRoot;const Sfe=async()=>{const e=await fetch("/api/flows");if(!e.ok)throw new Error(`GET /api/flows failed: ${e.status}`);return await e.json()},Nre=async e=>{const t=await fetch(`/api/flows/${e}`);if(!t.ok)throw new Error(`GET /api/flows/${e} failed: ${t.status}`);return await t.json()},Lfe=async e=>{const t=await fetch(`/api/flows/${encodeURIComponent(e)}`,{method:"DELETE"});if(!t.ok){let n=null;try{n=await t.json()}catch{}throw new Error((n==null?void 0:n.error)??`DELETE /api/flows/${e} → ${t.status}`)}return await t.json()},Ife=async e=>{const t=await fetch("/api/projects",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)});if(!t.ok){let n=null;try{n=await t.json()}catch{}throw new Error((n==null?void 0:n.error)??`POST /api/projects → ${t.status}`)}return await t.json()},Efe=async e=>{const t=await fetch(`/api/flows/${e}/reset`,{method:"POST",headers:{"content-type":"application/json"},body:"{}"});if(!t.ok){let n=null;try{n=await t.json()}catch{}throw new Error((n==null?void 0:n.error)??`POST /api/flows/${e}/reset → ${t.status}`)}return await t.json()},Afe=async(e,t)=>{const n=await fetch(`/api/flows/${e}/play/${t}`,{method:"POST",headers:{"content-type":"application/json"},body:"{}"});if(!n.ok){let r=null;try{r=await n.json()}catch{}throw new Error((r==null?void 0:r.error)??`POST /api/flows/${e}/play/${t} → ${n.status}`)}return await n.json()},zre={default:{border:"hsl(var(--primary))",background:"hsl(var(--card))",edge:"hsl(var(--muted-foreground))",headerBackground:"hsl(var(--muted))"},slate:{border:"hsl(215, 20%, 40%)",background:"hsl(215, 15%, 15%)",edge:"hsl(215, 16%, 47%)",headerBackground:"hsl(215, 15%, 11%)"},blue:{border:"hsl(213, 70%, 55%)",background:"hsl(214, 30%, 14%)",edge:"hsl(217, 91%, 60%)",headerBackground:"hsl(214, 30%, 10%)"},green:{border:"hsl(142, 50%, 45%)",background:"hsl(142, 25%, 13%)",edge:"hsl(142, 71%, 45%)",headerBackground:"hsl(142, 25%, 9%)"},amber:{border:"hsl(43, 70%, 50%)",background:"hsl(43, 30%, 14%)",edge:"hsl(38, 92%, 50%)",headerBackground:"hsl(43, 30%, 10%)"},red:{border:"hsl(0, 70%, 55%)",background:"hsl(0, 25%, 14%)",edge:"hsl(0, 84%, 60%)",headerBackground:"hsl(0, 25%, 10%)"},purple:{border:"hsl(270, 60%, 60%)",background:"hsl(270, 20%, 15%)",edge:"hsl(271, 91%, 65%)",headerBackground:"hsl(270, 20%, 11%)"},pink:{border:"hsl(330, 60%, 60%)",background:"hsl(330, 20%, 14%)",edge:"hsl(330, 81%, 60%)",headerBackground:"hsl(330, 20%, 10%)"}},Th=zre,ef="hsl(var(--card))";function ct(e,t){const n=e??"default",r=zre[n];return t==="edge"?{stroke:r.edge}:t==="text"?n==="default"?{}:{color:r.edge}:t==="node-header"?{backgroundColor:r.headerBackground}:{borderColor:r.border,backgroundColor:r.background}}/**
|
|
41
41
|
* @license lucide-react v0.453.0 - ISC
|
|
42
42
|
*
|
|
43
43
|
* This source code is licensed under the ISC license.
|
|
@@ -7760,7 +7760,7 @@ Error generating stack: `+a.message+`
|
|
|
7760
7760
|
+`).split(`
|
|
7761
7761
|
`)),u=l.reduce((d,f)=>d.concat(...f),[]);return[l,u]}return[[],[]]},[e]);return g.useEffect(()=>{const c=(t==null?void 0:t.target)??kQ,l=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const u=p=>{var w,v;if(o.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!o.current||o.current&&!l)&&Xae(p))return!1;const k=xQ(p.code,s);if(a.current.add(p[k]),vQ(i,a.current,!1)){const M=((v=(w=p.composedPath)==null?void 0:w.call(p))==null?void 0:v[0])||p.target,x=(M==null?void 0:M.nodeName)==="BUTTON"||(M==null?void 0:M.nodeName)==="A";t.preventDefault!==!1&&(o.current||!x)&&p.preventDefault(),r(!0)}},d=p=>{const y=xQ(p.code,s);vQ(i,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(p[y]),p.key==="Meta"&&a.current.clear(),o.current=!1},f=()=>{a.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",u),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",u),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function vQ(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function xQ(e,t){return t.includes(e)?"code":"key"}const Uwe=()=>{const e=vt();return g.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,o,a],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:o,minZoom:a,maxZoom:i,panZoom:s}=e.getState(),c=KV(t,r,o,a,i,(n==null?void 0:n.padding)??.1);return s?(await s.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:a,domNode:i}=e.getState();if(!i)return t;const{x:s,y:c}=i.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??o,d=n.snapToGrid??a;return hf(l,r,d,u)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:a}=r.getBoundingClientRect(),i=tR(t,n);return{x:i.x+o,y:i.y+a}}}),[])};function wie(e,t){const n=[],r=new Map,o=[];for(const a of e)if(a.type==="add"){o.push(a);continue}else if(a.type==="remove"||a.type==="replace")r.set(a.id,[a]);else{const i=r.get(a.id);i?i.push(a):r.set(a.id,[a])}for(const a of t){const i=r.get(a.id);if(!i){n.push(a);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}const s={...a};for(const c of i)Wwe(c,s);n.push(s)}return o.length&&o.forEach(a=>{a.index!==void 0?n.splice(a.index,0,{...a.item}):n.push({...a.item})}),n}function Wwe(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Mie(e,t){return wie(e,t)}function bie(e,t){return wie(e,t)}function iu(e,t){return{id:e,type:"select",selected:t}}function C1(e,t=new Set,n=!1){const r=[];for(const[o,a]of e){const i=t.has(o);!(a.selected===void 0&&!i)&&a.selected!==i&&(n&&(a.selected=i),r.push(iu(a.id,i)))}return r}function wQ({items:e=[],lookup:t}){var o;const n=[],r=new Map(e.map(a=>[a.id,a]));for(const[a,i]of e.entries()){const s=t.get(i.id),c=((o=s==null?void 0:s.internals)==null?void 0:o.userNode)??s;c!==void 0&&c!==i&&n.push({id:i.id,item:i,type:"replace"}),c===void 0&&n.push({item:i,type:"add",index:a})}for(const[a]of t)r.get(a)===void 0&&n.push({id:a,type:"remove"});return n}function MQ(e){return{id:e.id,type:"remove"}}const bQ=e=>n3e(e),Gwe=e=>Bae(e);function Cie(e){return g.forwardRef(e)}function CQ(e){const[t,n]=g.useState(BigInt(0)),[r]=g.useState(()=>Kwe(()=>n(o=>o+BigInt(1))));return RH(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function Kwe(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Sie=g.createContext(null);function Zwe({children:e}){const t=vt(),n=g.useCallback(s=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:u,onNodesChange:d,nodeLookup:f,fitViewQueued:p,onNodesChangeMiddlewareMap:y}=t.getState();let k=c;for(const v of s)k=typeof v=="function"?v(k):v;let w=wQ({items:k,lookup:f});for(const v of y.values())w=v(w);u&&l(k),w.length>0?d==null||d(w):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:v,nodes:M,setNodes:x}=t.getState();v&&x(M)})},[]),r=CQ(n),o=g.useCallback(s=>{const{edges:c=[],setEdges:l,hasDefaultEdges:u,onEdgesChange:d,edgeLookup:f}=t.getState();let p=c;for(const y of s)p=typeof y=="function"?y(p):y;u?l(p):d&&d(wQ({items:p,lookup:f}))},[]),a=CQ(o),i=g.useMemo(()=>({nodeQueue:r,edgeQueue:a}),[]);return m.jsx(Sie.Provider,{value:i,children:e})}function Xwe(){const e=g.useContext(Sie);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Ywe=e=>!!e.panZoom;function pT(){const e=Uwe(),t=vt(),n=Xwe(),r=Fe(Ywe),o=g.useMemo(()=>{const a=d=>t.getState().nodeLookup.get(d),i=d=>{n.nodeQueue.push(d)},s=d=>{n.edgeQueue.push(d)},c=d=>{var v,M;const{nodeLookup:f,nodeOrigin:p}=t.getState(),y=bQ(d)?d:f.get(d.id),k=y.parentId?Kae(y.position,y.measured,y.parentId,f,p):y.position,w={...y,position:k,width:((v=y.measured)==null?void 0:v.width)??y.width,height:((M=y.measured)==null?void 0:M.height)??y.height};return ad(w)},l=(d,f,p={replace:!1})=>{i(y=>y.map(k=>{if(k.id===d){const w=typeof f=="function"?f(k):f;return p.replace&&bQ(w)?w:{...k,...w}}return k}))},u=(d,f,p={replace:!1})=>{s(y=>y.map(k=>{if(k.id===d){const w=typeof f=="function"?f(k):f;return p.replace&&Gwe(w)?w:{...k,...w}}return k}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var f;return(f=a(d))==null?void 0:f.internals.userNode},getInternalNode:a,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(f=>({...f}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:i,setEdges:s,addNodes:d=>{const f=Array.isArray(d)?d:[d];n.nodeQueue.push(p=>[...p,...f])},addEdges:d=>{const f=Array.isArray(d)?d:[d];n.edgeQueue.push(p=>[...p,...f])},toObject:()=>{const{nodes:d=[],edges:f=[],transform:p}=t.getState(),[y,k,w]=p;return{nodes:d.map(v=>({...v})),edges:f.map(v=>({...v})),viewport:{x:y,y:k,zoom:w}}},deleteElements:async({nodes:d=[],edges:f=[]})=>{const{nodes:p,edges:y,onNodesDelete:k,onEdgesDelete:w,triggerNodeChanges:v,triggerEdgeChanges:M,onDelete:x,onBeforeDelete:b}=t.getState(),{nodes:S,edges:C}=await s3e({nodesToRemove:d,edgesToRemove:f,nodes:p,edges:y,onBeforeDelete:b}),L=C.length>0,P=S.length>0;if(L){const T=C.map(MQ);w==null||w(C),M(T)}if(P){const T=S.map(MQ);k==null||k(S),v(T)}return(P||L)&&(x==null||x({nodes:S,edges:C})),{deletedNodes:S,deletedEdges:C}},getIntersectingNodes:(d,f=!0,p)=>{const y=JY(d),k=y?d:c(d),w=p!==void 0;return k?(p||t.getState().nodes).filter(v=>{const M=t.getState().nodeLookup.get(v.id);if(M&&!y&&(v.id===d.id||!M.internals.positionAbsolute))return!1;const x=ad(w?v:M),b=O2(x,k);return f&&b>0||b>=x.width*x.height||b>=k.width*k.height}):[]},isNodeIntersecting:(d,f,p=!0)=>{const k=JY(d)?d:c(d);if(!k)return!1;const w=O2(k,f);return p&&w>0||w>=f.width*f.height||w>=k.width*k.height},updateNode:l,updateNodeData:(d,f,p={replace:!1})=>{l(d,y=>{const k=typeof f=="function"?f(y):f;return p.replace?{...y,data:k}:{...y,data:{...y.data,...k}}},p)},updateEdge:u,updateEdgeData:(d,f,p={replace:!1})=>{u(d,y=>{const k=typeof f=="function"?f(y):f;return p.replace?{...y,data:k}:{...y,data:{...y.data,...k}}},p)},getNodesBounds:d=>{const{nodeLookup:f,nodeOrigin:p}=t.getState();return r3e(d,{nodeLookup:f,nodeOrigin:p})},getHandleConnections:({type:d,id:f,nodeId:p})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${p}-${d}${f?`-${f}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:d,handleId:f,nodeId:p})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${p}${d?f?`-${d}-${f}`:`-${d}`:""}`))==null?void 0:y.values())??[])},fitView:async d=>{const f=t.getState().fitViewResolver??d3e();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:f}),n.nodeQueue.push(p=>[...p]),f.promise}}},[]);return g.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const SQ=e=>e.selected,Qwe=typeof window<"u"?window:void 0;function Jwe({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=vt(),{deleteElements:r}=pT(),o=B2(e,{actInsideInputWithModifier:!1}),a=B2(t,{target:Qwe});g.useEffect(()=>{if(o){const{edges:i,nodes:s}=n.getState();r({nodes:s.filter(SQ),edges:i.filter(SQ)}),n.setState({nodesSelectionActive:!1})}},[o]),g.useEffect(()=>{n.setState({multiSelectionActive:a})},[a])}function e6e(e){const t=vt();g.useEffect(()=>{const n=()=>{var o,a,i,s;if(!e.current||!(((a=(o=e.current).checkVisibility)==null?void 0:a.call(o))??!0))return!1;const r=ZV(e.current);(r.height===0||r.width===0)&&((s=(i=t.getState()).onError)==null||s.call(i,"004",bo.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const yT={position:"absolute",width:"100%",height:"100%",top:0,left:0},t6e=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function n6e({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:o=.5,panOnScrollMode:a=mu.Free,zoomOnDoubleClick:i=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:y,noWheelClassName:k,noPanClassName:w,onViewportChange:v,isControlledViewport:M,paneClickDistance:x,selectionOnDrag:b}){const S=vt(),C=g.useRef(null),{userSelectionActive:L,lib:P,connectionInProgress:T}=Fe(t6e,Ct),_=B2(f),A=g.useRef();e6e(C);const I=g.useCallback(V=>{v==null||v({x:V[0],y:V[1],zoom:V[2]}),M||S.setState({transform:V})},[v,M]);return g.useEffect(()=>{if(C.current){A.current=K3e({domNode:C.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:O=>S.setState(U=>U.paneDragging===O?U:{paneDragging:O}),onPanZoomStart:(O,U)=>{const{onViewportChangeStart:z,onMoveStart:N}=S.getState();N==null||N(O,U),z==null||z(U)},onPanZoom:(O,U)=>{const{onViewportChange:z,onMove:N}=S.getState();N==null||N(O,U),z==null||z(U)},onPanZoomEnd:(O,U)=>{const{onViewportChangeEnd:z,onMoveEnd:N}=S.getState();N==null||N(O,U),z==null||z(U)}});const{x:V,y:j,zoom:H}=A.current.getViewport();return S.setState({panZoom:A.current,transform:[V,j,H],domNode:C.current.closest(".react-flow")}),()=>{var O;(O=A.current)==null||O.destroy()}}},[]),g.useEffect(()=>{var V;(V=A.current)==null||V.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:o,panOnScrollMode:a,zoomOnDoubleClick:i,panOnDrag:s,zoomActivationKeyPressed:_,preventScrolling:p,noPanClassName:w,userSelectionActive:L,noWheelClassName:k,lib:P,onTransformChange:I,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:x})},[e,t,n,r,o,a,i,s,_,p,w,L,k,P,I,T,b,x]),m.jsx("div",{className:"react-flow__renderer",ref:C,style:yT,children:y})}const r6e=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function o6e(){const{userSelectionActive:e,userSelectionRect:t}=Fe(r6e,Ct);return e&&t?m.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const NO=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},a6e=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function i6e({isSelecting:e,selectionKeyPressed:t,selectionMode:n=rd.Full,panOnDrag:r,paneClickDistance:o,selectionOnDrag:a,onSelectionStart:i,onSelectionEnd:s,onPaneClick:c,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:f,onPaneMouseLeave:p,children:y}){const k=vt(),{userSelectionActive:w,elementsSelectable:v,dragging:M,connectionInProgress:x}=Fe(a6e,Ct),b=v&&(e||w),S=g.useRef(null),C=g.useRef(),L=g.useRef(new Set),P=g.useRef(new Set),T=g.useRef(!1),_=z=>{if(T.current||x){T.current=!1;return}c==null||c(z),k.getState().resetSelectedElements(),k.setState({nodesSelectionActive:!1})},A=z=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){z.preventDefault();return}l==null||l(z)},I=u?z=>u(z):void 0,V=z=>{T.current&&(z.stopPropagation(),T.current=!1)},j=z=>{var X,Y;const{domNode:N}=k.getState();if(C.current=N==null?void 0:N.getBoundingClientRect(),!C.current)return;const E=z.target===S.current;if(!E&&!!z.target.closest(".nokey")||!e||!(a&&E||t)||z.button!==0||!z.isPrimary)return;(Y=(X=z.target)==null?void 0:X.setPointerCapture)==null||Y.call(X,z.pointerId),T.current=!1;const{x:R,y:G}=qr(z.nativeEvent,C.current);k.setState({userSelectionRect:{width:0,height:0,startX:R,startY:G,x:R,y:G}}),E||(z.stopPropagation(),z.preventDefault())},H=z=>{const{userSelectionRect:N,transform:E,nodeLookup:W,edgeLookup:q,connectionLookup:R,triggerNodeChanges:G,triggerEdgeChanges:X,defaultEdgeOptions:Y,resetSelectedElements:oe}=k.getState();if(!C.current||!N)return;const{x:ee,y:ae}=qr(z.nativeEvent,C.current),{startX:ve,startY:Se}=N;if(!T.current){const Te=t?0:o;if(Math.hypot(ee-ve,ae-Se)<=Te)return;oe(),i==null||i(z)}T.current=!0;const be={startX:ve,startY:Se,x:ee<ve?ee:ve,y:ae<Se?ae:Se,width:Math.abs(ee-ve),height:Math.abs(ae-Se)},we=L.current,te=P.current;L.current=new Set(GV(W,be,E,n===rd.Partial,!0).map(Te=>Te.id)),P.current=new Set;const ie=(Y==null?void 0:Y.selectable)??!0;for(const Te of L.current){const Ae=R.get(Te);if(Ae)for(const{edgeId:at}of Ae.values()){const Qe=q.get(at);Qe&&(Qe.selectable??ie)&&P.current.add(at)}}if(!eQ(we,L.current)){const Te=C1(W,L.current,!0);G(Te)}if(!eQ(te,P.current)){const Te=C1(q,P.current);X(Te)}k.setState({userSelectionRect:be,userSelectionActive:!0,nodesSelectionActive:!1})},O=z=>{var N,E;z.button===0&&((E=(N=z.target)==null?void 0:N.releasePointerCapture)==null||E.call(N,z.pointerId),!w&&z.target===S.current&&k.getState().userSelectionRect&&(_==null||_(z)),k.setState({userSelectionActive:!1,userSelectionRect:null}),T.current&&(s==null||s(z),k.setState({nodesSelectionActive:L.current.size>0})))},U=r===!0||Array.isArray(r)&&r.includes(0);return m.jsxs("div",{className:Vt(["react-flow__pane",{draggable:U,dragging:M,selection:e}]),onClick:b?void 0:NO(_,S),onContextMenu:NO(A,S),onWheel:NO(I,S),onPointerEnter:b?void 0:d,onPointerMove:b?H:f,onPointerUp:b?O:void 0,onPointerDownCapture:b?j:void 0,onClickCapture:b?V:void 0,onPointerLeave:p,ref:S,style:yT,children:[y,m.jsx(o6e,{})]})}function TH({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:a,multiSelectionActive:i,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c==null||c("012",bo.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&i)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var u;return(u=r==null?void 0:r.current)==null?void 0:u.blur()})):o([e])}function Lie({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:a,nodeClickDistance:i}){const s=vt(),[c,l]=g.useState(!1),u=g.useRef();return g.useEffect(()=>{u.current=j3e({getStoreItems:()=>s.getState(),onNodeMouseDown:d=>{TH({id:d,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),g.useEffect(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:o,nodeClickDistance:i}),()=>{var d;(d=u.current)==null||d.destroy()}},[n,r,t,a,e,o,i]),c}const s6e=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Iie(){const e=vt();return g.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:a,nodesDraggable:i,onError:s,updateNodePositions:c,nodeLookup:l,nodeOrigin:u}=e.getState(),d=new Map,f=s6e(i),p=o?a[0]:5,y=o?a[1]:5,k=n.direction.x*p*n.factor,w=n.direction.y*y*n.factor;for(const[,v]of l){if(!f(v))continue;let M={x:v.internals.positionAbsolute.x+k,y:v.internals.positionAbsolute.y+w};o&&(M=df(M,a));const{position:x,positionAbsolute:b}=Vae({nodeId:v.id,nextPosition:M,nodeLookup:l,nodeExtent:r,nodeOrigin:u,onError:s});v.position=x,v.internals.positionAbsolute=b,d.set(v.id,v)}c(d)},[])}const t$=g.createContext(null),c6e=t$.Provider;t$.Consumer;const Eie=()=>g.useContext(t$),l6e=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),u6e=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:a,connection:i}=r,{fromHandle:s,toHandle:c,isValid:l}=i,u=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,connectingTo:u,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:a===nd.Strict?(s==null?void 0:s.type)!==n:e!==(s==null?void 0:s.nodeId)||t!==(s==null?void 0:s.id),connectionInProcess:!!s,clickConnectionInProcess:!!o,valid:u&&l}};function d6e({type:e="source",position:t=me.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:a=!0,id:i,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){var H,O;const y=i||null,k=e==="target",w=vt(),v=Eie(),{connectOnClick:M,noPanClassName:x,rfId:b}=Fe(l6e,Ct),{connectingFrom:S,connectingTo:C,clickConnecting:L,isPossibleEndHandle:P,connectionInProcess:T,clickConnectionInProcess:_,valid:A}=Fe(u6e(v,y,e),Ct);v||(O=(H=w.getState()).onError)==null||O.call(H,"010",bo.error010());const I=U=>{const{defaultEdgeOptions:z,onConnect:N,hasDefaultEdges:E}=w.getState(),W={...z,...U};if(E){const{edges:q,setEdges:R}=w.getState();R(k3e(W,q))}N==null||N(W),s==null||s(W)},V=U=>{if(!v)return;const z=Yae(U.nativeEvent);if(o&&(z&&U.button===0||!z)){const N=w.getState();_H.onPointerDown(U.nativeEvent,{handleDomNode:U.currentTarget,autoPanOnConnect:N.autoPanOnConnect,connectionMode:N.connectionMode,connectionRadius:N.connectionRadius,domNode:N.domNode,nodeLookup:N.nodeLookup,lib:N.lib,isTarget:k,handleId:y,nodeId:v,flowId:N.rfId,panBy:N.panBy,cancelConnection:N.cancelConnection,onConnectStart:N.onConnectStart,onConnectEnd:(...E)=>{var W,q;return(q=(W=w.getState()).onConnectEnd)==null?void 0:q.call(W,...E)},updateConnection:N.updateConnection,onConnect:I,isValidConnection:n||((...E)=>{var W,q;return((q=(W=w.getState()).isValidConnection)==null?void 0:q.call(W,...E))??!0}),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:N.autoPanSpeed,dragThreshold:N.connectionDragThreshold})}z?u==null||u(U):d==null||d(U)},j=U=>{const{onClickConnectStart:z,onClickConnectEnd:N,connectionClickStartHandle:E,connectionMode:W,isValidConnection:q,lib:R,rfId:G,nodeLookup:X,connection:Y}=w.getState();if(!v||!E&&!o)return;if(!E){z==null||z(U.nativeEvent,{nodeId:v,handleId:y,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:v,type:e,id:y}});return}const oe=Zae(U.target),ee=n||q,{connection:ae,isValid:ve}=_H.isValid(U.nativeEvent,{handle:{nodeId:v,id:y,type:e},connectionMode:W,fromNodeId:E.nodeId,fromHandleId:E.id||null,fromType:E.type,isValidConnection:ee,flowId:G,doc:oe,lib:R,nodeLookup:X});ve&&ae&&I(ae);const Se=structuredClone(Y);delete Se.inProgress,Se.toPosition=Se.toHandle?Se.toHandle.position:null,N==null||N(U,Se),w.setState({connectionClickStartHandle:null})};return m.jsx("div",{"data-handleid":y,"data-nodeid":v,"data-handlepos":t,"data-id":`${b}-${v}-${y}-${e}`,className:Vt(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,l,{source:!k,target:k,connectable:r,connectablestart:o,connectableend:a,clickconnecting:L,connectingfrom:S,connectingto:C,valid:A,connectionindicator:r&&(!T||P)&&(T||_?a:o)}]),onMouseDown:V,onTouchStart:V,onClick:M?j:void 0,ref:p,...f,children:c})}const ut=g.memo(Cie(d6e));function h6e({data:e,isConnectable:t,sourcePosition:n=me.Bottom}){return m.jsxs(m.Fragment,{children:[e==null?void 0:e.label,m.jsx(ut,{type:"source",position:n,isConnectable:t})]})}function f6e({data:e,isConnectable:t,targetPosition:n=me.Top,sourcePosition:r=me.Bottom}){return m.jsxs(m.Fragment,{children:[m.jsx(ut,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,m.jsx(ut,{type:"source",position:r,isConnectable:t})]})}function p6e(){return null}function y6e({data:e,isConnectable:t,targetPosition:n=me.Top}){return m.jsxs(m.Fragment,{children:[m.jsx(ut,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const nR={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},LQ={input:h6e,default:f6e,output:y6e,group:p6e};function m6e(e){var t,n,r,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const g6e=e=>{const{width:t,height:n,x:r,y:o}=uf(e.nodeLookup,{filter:a=>!!a.selected});return{width:Dr(t)?t:null,height:Dr(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function k6e({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=vt(),{width:o,height:a,transformString:i,userSelectionActive:s}=Fe(g6e,Ct),c=Iie(),l=g.useRef(null);g.useEffect(()=>{var p;n||(p=l.current)==null||p.focus({preventScroll:!0})},[n]);const u=!s&&o!==null&&a!==null;if(Lie({nodeRef:l,disabled:!u}),!u)return null;const d=e?p=>{const y=r.getState().nodes.filter(k=>k.selected);e(p,y)}:void 0,f=p=>{Object.prototype.hasOwnProperty.call(nR,p.key)&&(p.preventDefault(),c({direction:nR[p.key],factor:p.shiftKey?4:1}))};return m.jsx("div",{className:Vt(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:m.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:o,height:a}})})}const IQ=typeof window<"u"?window:void 0,v6e=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Aie({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:a,onPaneScroll:i,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:y,panActivationKeyCode:k,zoomActivationKeyCode:w,elementsSelectable:v,zoomOnScroll:M,zoomOnPinch:x,panOnScroll:b,panOnScrollSpeed:S,panOnScrollMode:C,zoomOnDoubleClick:L,panOnDrag:P,defaultViewport:T,translateExtent:_,minZoom:A,maxZoom:I,preventScrolling:V,onSelectionContextMenu:j,noWheelClassName:H,noPanClassName:O,disableKeyboardA11y:U,onViewportChange:z,isControlledViewport:N}){const{nodesSelectionActive:E,userSelectionActive:W}=Fe(v6e,Ct),q=B2(l,{target:IQ}),R=B2(k,{target:IQ}),G=R||P,X=R||b,Y=u&&G!==!0,oe=q||W||Y;return Jwe({deleteKeyCode:c,multiSelectionKeyCode:y}),m.jsx(n6e,{onPaneContextMenu:a,elementsSelectable:v,zoomOnScroll:M,zoomOnPinch:x,panOnScroll:X,panOnScrollSpeed:S,panOnScrollMode:C,zoomOnDoubleClick:L,panOnDrag:!q&&G,defaultViewport:T,translateExtent:_,minZoom:A,maxZoom:I,zoomActivationKeyCode:w,preventScrolling:V,noWheelClassName:H,noPanClassName:O,onViewportChange:z,isControlledViewport:N,paneClickDistance:s,selectionOnDrag:Y,children:m.jsxs(i6e,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:a,onPaneScroll:i,panOnDrag:G,isSelecting:!!oe,selectionMode:d,selectionKeyPressed:q,paneClickDistance:s,selectionOnDrag:Y,children:[e,E&&m.jsx(k6e,{onSelectionContextMenu:j,noPanClassName:O,disableKeyboardA11y:U})]})})}Aie.displayName="FlowRenderer";const x6e=g.memo(Aie),w6e=e=>t=>e?GV(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function M6e(e){return Fe(g.useCallback(w6e(e),[e]),Ct)}const b6e=e=>e.updateNodeInternals;function C6e(){const e=Fe(b6e),[t]=g.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const a=o.target.getAttribute("data-id");r.set(a,{id:a,nodeElement:o.target,force:!0})}),e(r)}));return g.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function S6e({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=vt(),a=g.useRef(null),i=g.useRef(null),s=g.useRef(e.sourcePosition),c=g.useRef(e.targetPosition),l=g.useRef(t),u=n&&!!e.internals.handleBounds;return g.useEffect(()=>{a.current&&!e.hidden&&(!u||i.current!==a.current)&&(i.current&&(r==null||r.unobserve(i.current)),r==null||r.observe(a.current),i.current=a.current)},[u,e.hidden]),g.useEffect(()=>()=>{i.current&&(r==null||r.unobserve(i.current),i.current=null)},[]),g.useEffect(()=>{if(a.current){const d=l.current!==t,f=s.current!==e.sourcePosition,p=c.current!==e.targetPosition;(d||f||p)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function L6e({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:a,onDoubleClick:i,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:y,rfId:k,nodeTypes:w,nodeClickDistance:v,onError:M}){const{node:x,internals:b,isParent:S}=Fe(ee=>{const ae=ee.nodeLookup.get(e),ve=ee.parentLookup.has(e);return{node:ae,internals:ae.internals,isParent:ve}},Ct);let C=x.type||"default",L=(w==null?void 0:w[C])||LQ[C];L===void 0&&(M==null||M("003",bo.error003(C)),C="default",L=(w==null?void 0:w.default)||LQ.default);const P=!!(x.draggable||s&&typeof x.draggable>"u"),T=!!(x.selectable||c&&typeof x.selectable>"u"),_=!!(x.connectable||l&&typeof x.connectable>"u"),A=!!(x.focusable||u&&typeof x.focusable>"u"),I=vt(),V=Gae(x),j=S6e({node:x,nodeType:C,hasDimensions:V,resizeObserver:d}),H=Lie({nodeRef:j,disabled:x.hidden||!P,noDragClassName:f,handleSelector:x.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:v}),O=Iie();if(x.hidden)return null;const U=ca(x),z=m6e(x),N=T||P||t||n||r||o,E=n?ee=>n(ee,{...b.userNode}):void 0,W=r?ee=>r(ee,{...b.userNode}):void 0,q=o?ee=>o(ee,{...b.userNode}):void 0,R=a?ee=>a(ee,{...b.userNode}):void 0,G=i?ee=>i(ee,{...b.userNode}):void 0,X=ee=>{const{selectNodesOnDrag:ae,nodeDragThreshold:ve}=I.getState();T&&(!ae||!P||ve>0)&&TH({id:e,store:I,nodeRef:j}),t&&t(ee,{...b.userNode})},Y=ee=>{if(!(Xae(ee.nativeEvent)||y)){if(qae.includes(ee.key)&&T){const ae=ee.key==="Escape";TH({id:e,store:I,unselect:ae,nodeRef:j})}else if(P&&x.selected&&Object.prototype.hasOwnProperty.call(nR,ee.key)){ee.preventDefault();const{ariaLabelConfig:ae}=I.getState();I.setState({ariaLiveMessage:ae["node.a11yDescription.ariaLiveMessage"]({direction:ee.key.replace("Arrow","").toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),O({direction:nR[ee.key],factor:ee.shiftKey?4:1})}}},oe=()=>{var te;if(y||!((te=j.current)!=null&&te.matches(":focus-visible")))return;const{transform:ee,width:ae,height:ve,autoPanOnNodeFocus:Se,setCenter:be}=I.getState();if(!Se)return;GV(new Map([[e,x]]),{x:0,y:0,width:ae,height:ve},ee,!0).length>0||be(x.position.x+U.width/2,x.position.y+U.height/2,{zoom:ee[2]})};return m.jsx("div",{className:Vt(["react-flow__node",`react-flow__node-${C}`,{[p]:P},x.className,{selected:x.selected,selectable:T,parent:S,draggable:P,dragging:H}]),ref:j,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:N?"all":"none",visibility:V?"visible":"hidden",...x.style,...z},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:E,onMouseMove:W,onMouseLeave:q,onContextMenu:R,onClick:X,onDoubleClick:G,onKeyDown:A?Y:void 0,tabIndex:A?0:void 0,onFocus:A?oe:void 0,role:x.ariaRole??(A?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${kie}-${k}`,"aria-label":x.ariaLabel,...x.domAttributes,children:m.jsx(c6e,{value:e,children:m.jsx(L,{id:e,data:x.data,type:C,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:x.selected??!1,selectable:T,draggable:P,deletable:x.deletable??!0,isConnectable:_,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:H,dragHandle:x.dragHandle,zIndex:b.z,parentId:x.parentId,...U})})})}var I6e=g.memo(L6e);const E6e=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Pie(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,onError:a}=Fe(E6e,Ct),i=M6e(e.onlyRenderVisibleElements),s=C6e();return m.jsx("div",{className:"react-flow__nodes",style:yT,children:i.map(c=>m.jsx(I6e,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:a},c))})}Pie.displayName="NodeRenderer";const A6e=g.memo(Pie);function P6e(e){return Fe(g.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const a=n.nodeLookup.get(o.source),i=n.nodeLookup.get(o.target);a&&i&&y3e({sourceNode:a,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),Ct)}const _6e=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return m.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},R6e=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return m.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},EQ={[q2.Arrow]:_6e,[q2.ArrowClosed]:R6e};function T6e(e){const t=vt();return g.useMemo(()=>{var o,a;return Object.prototype.hasOwnProperty.call(EQ,e)?EQ[e]:((a=(o=t.getState()).onError)==null||a.call(o,"009",bo.error009(e)),null)},[e])}const j6e=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:a="strokeWidth",strokeWidth:i,orient:s="auto-start-reverse"})=>{const c=T6e(t);return c?m.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:s,refX:"0",refY:"0",children:m.jsx(c,{color:n,strokeWidth:i})}):null},_ie=({defaultColor:e,rfId:t})=>{const n=Fe(a=>a.edges),r=Fe(a=>a.defaultEdgeOptions),o=g.useMemo(()=>b3e(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return o.length?m.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:m.jsx("defs",{children:o.map(a=>m.jsx(j6e,{id:a.id,type:a.type,color:a.color,width:a.width,height:a.height,markerUnits:a.markerUnits,strokeWidth:a.strokeWidth,orient:a.orient},a.id))})}):null};_ie.displayName="MarkerDefinitions";var N6e=g.memo(_ie);function Rie({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:a,labelBgPadding:i=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){const[d,f]=g.useState({x:1,y:0,width:0,height:0}),p=Vt(["react-flow__edge-textwrapper",l]),y=g.useRef(null);return g.useEffect(()=>{if(y.current){const k=y.current.getBBox();f({x:k.x,y:k.y,width:k.width,height:k.height})}},[n]),n?m.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?"visible":"hidden",...u,children:[o&&m.jsx("rect",{width:d.width+2*i[0],x:-i[0],y:-i[1],height:d.height+2*i[1],className:"react-flow__edge-textbg",style:a,rx:s,ry:s}),m.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:y,style:r,children:n}),c]}):null}Rie.displayName="EdgeText";const z6e=g.memo(Rie);function ff({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:a,labelBgStyle:i,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return m.jsxs(m.Fragment,{children:[m.jsx("path",{...u,d:e,fill:"none",className:Vt(["react-flow__edge-path",u.className])}),l?m.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,r&&Dr(t)&&Dr(n)?m.jsx(z6e,{x:t,y:n,label:r,labelStyle:o,labelShowBg:a,labelBgStyle:i,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function AQ({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===me.Left||e===me.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function Tie({sourceX:e,sourceY:t,sourcePosition:n=me.Bottom,targetX:r,targetY:o,targetPosition:a=me.Top}){const[i,s]=AQ({pos:n,x1:e,y1:t,x2:r,y2:o}),[c,l]=AQ({pos:a,x1:r,y1:o,x2:e,y2:t}),[u,d,f,p]=Qae({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:i,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${i},${s} ${c},${l} ${r},${o}`,u,d,f,p]}function jie(e){return g.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:a,sourcePosition:i,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:y,markerEnd:k,markerStart:w,interactionWidth:v})=>{const[M,x,b]=Tie({sourceX:n,sourceY:r,sourcePosition:i,targetX:o,targetY:a,targetPosition:s}),S=e.isInternal?void 0:t;return m.jsx(ff,{id:S,path:M,labelX:x,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:y,markerEnd:k,markerStart:w,interactionWidth:v})})}const D6e=jie({isInternal:!1}),Nie=jie({isInternal:!0});D6e.displayName="SimpleBezierEdge";Nie.displayName="SimpleBezierEdgeInternal";function zie(e){return g.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:a,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=me.Bottom,targetPosition:y=me.Top,markerEnd:k,markerStart:w,pathOptions:v,interactionWidth:M})=>{const[x,b,S]=H2({sourceX:n,sourceY:r,sourcePosition:p,targetX:o,targetY:a,targetPosition:y,borderRadius:v==null?void 0:v.borderRadius,offset:v==null?void 0:v.offset,stepPosition:v==null?void 0:v.stepPosition}),C=e.isInternal?void 0:t;return m.jsx(ff,{id:C,path:x,labelX:b,labelY:S,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:k,markerStart:w,interactionWidth:M})})}const Die=zie({isInternal:!1}),qie=zie({isInternal:!0});Die.displayName="SmoothStepEdge";qie.displayName="SmoothStepEdgeInternal";function Oie(e){return g.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return m.jsx(Die,{...n,id:r,pathOptions:g.useMemo(()=>{var a;return{borderRadius:0,offset:(a=n.pathOptions)==null?void 0:a.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const q6e=Oie({isInternal:!1}),Fie=Oie({isInternal:!0});q6e.displayName="StepEdge";Fie.displayName="StepEdgeInternal";function Hie(e){return g.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:a,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:y,interactionWidth:k})=>{const[w,v,M]=eie({sourceX:n,sourceY:r,targetX:o,targetY:a}),x=e.isInternal?void 0:t;return m.jsx(ff,{id:x,path:w,labelX:v,labelY:M,label:i,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:y,interactionWidth:k})})}const O6e=Hie({isInternal:!1}),Bie=Hie({isInternal:!0});O6e.displayName="StraightEdge";Bie.displayName="StraightEdgeInternal";function Vie(e){return g.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:a,sourcePosition:i=me.Bottom,targetPosition:s=me.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:y,markerEnd:k,markerStart:w,pathOptions:v,interactionWidth:M})=>{const[x,b,S]=uT({sourceX:n,sourceY:r,sourcePosition:i,targetX:o,targetY:a,targetPosition:s,curvature:v==null?void 0:v.curvature}),C=e.isInternal?void 0:t;return m.jsx(ff,{id:C,path:x,labelX:b,labelY:S,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:y,markerEnd:k,markerStart:w,interactionWidth:M})})}const F6e=Vie({isInternal:!1}),$ie=Vie({isInternal:!0});F6e.displayName="BezierEdge";$ie.displayName="BezierEdgeInternal";const PQ={default:$ie,straight:Bie,step:Fie,smoothstep:qie,simplebezier:Nie},_Q={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},H6e=(e,t,n)=>n===me.Left?e-t:n===me.Right?e+t:e,B6e=(e,t,n)=>n===me.Top?e-t:n===me.Bottom?e+t:e,RQ="react-flow__edgeupdater";function TQ({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:a,onMouseOut:i,type:s}){return m.jsx("circle",{onMouseDown:o,onMouseEnter:a,onMouseOut:i,className:Vt([RQ,`${RQ}-${s}`]),cx:H6e(t,r,e),cy:B6e(n,r,e),r,stroke:"transparent",fill:"transparent"})}function V6e({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:a,targetY:i,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){const y=vt(),k=(b,S)=>{if(b.button!==0)return;const{autoPanOnConnect:C,domNode:L,connectionMode:P,connectionRadius:T,lib:_,onConnectStart:A,cancelConnection:I,nodeLookup:V,rfId:j,panBy:H,updateConnection:O}=y.getState(),U=S.type==="target",z=(W,q)=>{f(!1),d==null||d(W,n,S.type,q)},N=W=>l==null?void 0:l(n,W),E=(W,q)=>{f(!0),u==null||u(b,n,S.type),A==null||A(W,q)};_H.onPointerDown(b.nativeEvent,{autoPanOnConnect:C,connectionMode:P,connectionRadius:T,domNode:L,handleId:S.id,nodeId:S.nodeId,nodeLookup:V,isTarget:U,edgeUpdaterType:S.type,lib:_,flowId:j,cancelConnection:I,panBy:H,isValidConnection:(...W)=>{var q,R;return((R=(q=y.getState()).isValidConnection)==null?void 0:R.call(q,...W))??!0},onConnect:N,onConnectStart:E,onConnectEnd:(...W)=>{var q,R;return(R=(q=y.getState()).onConnectEnd)==null?void 0:R.call(q,...W)},onReconnectEnd:z,updateConnection:O,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:b.currentTarget})},w=b=>k(b,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),v=b=>k(b,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),M=()=>p(!0),x=()=>p(!1);return m.jsxs(m.Fragment,{children:[(e===!0||e==="source")&&m.jsx(TQ,{position:s,centerX:r,centerY:o,radius:t,onMouseDown:w,onMouseEnter:M,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&m.jsx(TQ,{position:c,centerX:a,centerY:i,radius:t,onMouseDown:v,onMouseEnter:M,onMouseOut:x,type:"target"})]})}function $6e({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:a,onContextMenu:i,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:y,edgeTypes:k,noPanClassName:w,onError:v,disableKeyboardA11y:M}){let x=Fe(be=>be.edgeLookup.get(e));const b=Fe(be=>be.defaultEdgeOptions);x=b?{...b,...x}:x;let S=x.type||"default",C=(k==null?void 0:k[S])||PQ[S];C===void 0&&(v==null||v("011",bo.error011(S)),S="default",C=(k==null?void 0:k.default)||PQ.default);const L=!!(x.focusable||t&&typeof x.focusable>"u"),P=typeof d<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),T=!!(x.selectable||r&&typeof x.selectable>"u"),_=g.useRef(null),[A,I]=g.useState(!1),[V,j]=g.useState(!1),H=vt(),{zIndex:O,sourceX:U,sourceY:z,targetX:N,targetY:E,sourcePosition:W,targetPosition:q}=Fe(g.useCallback(be=>{const we=be.nodeLookup.get(x.source),te=be.nodeLookup.get(x.target);if(!we||!te)return{zIndex:x.zIndex,..._Q};const ie=M3e({id:e,sourceNode:we,targetNode:te,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:be.connectionMode,onError:v});return{zIndex:p3e({selected:x.selected,zIndex:x.zIndex,sourceNode:we,targetNode:te,elevateOnSelect:be.elevateEdgesOnSelect,zIndexMode:be.zIndexMode}),...ie||_Q}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),Ct),R=g.useMemo(()=>x.markerStart?`url('#${AH(x.markerStart,y)}')`:void 0,[x.markerStart,y]),G=g.useMemo(()=>x.markerEnd?`url('#${AH(x.markerEnd,y)}')`:void 0,[x.markerEnd,y]);if(x.hidden||U===null||z===null||N===null||E===null)return null;const X=be=>{var Te;const{addSelectedEdges:we,unselectNodesAndEdges:te,multiSelectionActive:ie}=H.getState();T&&(H.setState({nodesSelectionActive:!1}),x.selected&&ie?(te({nodes:[],edges:[x]}),(Te=_.current)==null||Te.blur()):we([e])),o&&o(be,x)},Y=a?be=>{a(be,{...x})}:void 0,oe=i?be=>{i(be,{...x})}:void 0,ee=s?be=>{s(be,{...x})}:void 0,ae=c?be=>{c(be,{...x})}:void 0,ve=l?be=>{l(be,{...x})}:void 0,Se=be=>{var we;if(!M&&qae.includes(be.key)&&T){const{unselectNodesAndEdges:te,addSelectedEdges:ie}=H.getState();be.key==="Escape"?((we=_.current)==null||we.blur(),te({edges:[x]})):ie([e])}};return m.jsx("svg",{style:{zIndex:O},children:m.jsxs("g",{className:Vt(["react-flow__edge",`react-flow__edge-${S}`,x.className,w,{selected:x.selected,animated:x.animated,inactive:!T&&!o,updating:A,selectable:T}]),onClick:X,onDoubleClick:Y,onContextMenu:oe,onMouseEnter:ee,onMouseMove:ae,onMouseLeave:ve,onKeyDown:L?Se:void 0,tabIndex:L?0:void 0,role:x.ariaRole??(L?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":L?`${vie}-${y}`:void 0,ref:_,...x.domAttributes,children:[!V&&m.jsx(C,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:T,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:U,sourceY:z,targetX:N,targetY:E,sourcePosition:W,targetPosition:q,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:R,markerEnd:G,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),P&&m.jsx(V6e,{edge:x,isReconnectable:P,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:U,sourceY:z,targetX:N,targetY:E,sourcePosition:W,targetPosition:q,setUpdateHover:I,setReconnecting:j})]})})}var U6e=g.memo($6e);const W6e=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Uie({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:a,onEdgeContextMenu:i,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:y,disableKeyboardA11y:k}){const{edgesFocusable:w,edgesReconnectable:v,elementsSelectable:M,onError:x}=Fe(W6e,Ct),b=P6e(t);return m.jsxs("div",{className:"react-flow__edges",children:[m.jsx(N6e,{defaultColor:e,rfId:n}),b.map(S=>m.jsx(U6e,{id:S,edgesFocusable:w,edgesReconnectable:v,elementsSelectable:M,noPanClassName:o,onReconnect:a,onContextMenu:i,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:y,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:k},S))]})}Uie.displayName="EdgeRenderer";const G6e=g.memo(Uie),K6e=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Z6e({children:e}){const t=Fe(K6e);return m.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function X6e(e){const t=pT(),n=g.useRef(!1);g.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Y6e=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function Q6e(e){const t=Fe(Y6e),n=vt();return g.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function J6e(e){return e.connection.inProgress?{...e.connection,to:hf(e.connection.to,e.transform)}:{...e.connection}}function e8e(e){return J6e}function t8e(e){const t=e8e();return Fe(t,Ct)}const n8e=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function r8e({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:a,height:i,isValid:s,inProgress:c}=Fe(n8e,Ct);return!(a&&o&&c)?null:m.jsx("svg",{style:e,width:a,height:i,className:"react-flow__connectionline react-flow__container",children:m.jsx("g",{className:Vt(["react-flow__connection",Hae(s)]),children:m.jsx(Wie,{style:t,type:n,CustomComponent:r,isValid:s})})})}const Wie=({style:e,type:t=Ha.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:a,fromNode:i,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=t8e();if(!o)return;if(n)return m.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:Hae(r),toNode:u,toHandle:d,pointer:p});let y="";const k={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case Ha.Bezier:[y]=uT(k);break;case Ha.SimpleBezier:[y]=Tie(k);break;case Ha.Step:[y]=H2({...k,borderRadius:0});break;case Ha.SmoothStep:[y]=H2(k);break;default:[y]=eie(k)}return m.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};Wie.displayName="ConnectionLine";const o8e={};function jQ(e=o8e){g.useRef(e),vt(),g.useEffect(()=>{},[e])}function a8e(){vt(),g.useRef(!1),g.useEffect(()=>{},[])}function Gie({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:a,onEdgeDoubleClick:i,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:y,connectionLineStyle:k,connectionLineComponent:w,connectionLineContainerStyle:v,selectionKeyCode:M,selectionOnDrag:x,selectionMode:b,multiSelectionKeyCode:S,panActivationKeyCode:C,zoomActivationKeyCode:L,deleteKeyCode:P,onlyRenderVisibleElements:T,elementsSelectable:_,defaultViewport:A,translateExtent:I,minZoom:V,maxZoom:j,preventScrolling:H,defaultMarkerColor:O,zoomOnScroll:U,zoomOnPinch:z,panOnScroll:N,panOnScrollSpeed:E,panOnScrollMode:W,zoomOnDoubleClick:q,panOnDrag:R,onPaneClick:G,onPaneMouseEnter:X,onPaneMouseMove:Y,onPaneMouseLeave:oe,onPaneScroll:ee,onPaneContextMenu:ae,paneClickDistance:ve,nodeClickDistance:Se,onEdgeContextMenu:be,onEdgeMouseEnter:we,onEdgeMouseMove:te,onEdgeMouseLeave:ie,reconnectRadius:Te,onReconnect:Ae,onReconnectStart:at,onReconnectEnd:Qe,noDragClassName:le,noWheelClassName:Q,noPanClassName:ue,disableKeyboardA11y:ge,nodeExtent:Me,rfId:qe,viewport:re,onViewportChange:he}){return jQ(e),jQ(t),a8e(),X6e(n),Q6e(re),m.jsx(x6e,{onPaneClick:G,onPaneMouseEnter:X,onPaneMouseMove:Y,onPaneMouseLeave:oe,onPaneContextMenu:ae,onPaneScroll:ee,paneClickDistance:ve,deleteKeyCode:P,selectionKeyCode:M,selectionOnDrag:x,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:S,panActivationKeyCode:C,zoomActivationKeyCode:L,elementsSelectable:_,zoomOnScroll:U,zoomOnPinch:z,zoomOnDoubleClick:q,panOnScroll:N,panOnScrollSpeed:E,panOnScrollMode:W,panOnDrag:R,defaultViewport:A,translateExtent:I,minZoom:V,maxZoom:j,onSelectionContextMenu:d,preventScrolling:H,noDragClassName:le,noWheelClassName:Q,noPanClassName:ue,disableKeyboardA11y:ge,onViewportChange:he,isControlledViewport:!!re,children:m.jsxs(Z6e,{children:[m.jsx(G6e,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:i,onReconnect:Ae,onReconnectStart:at,onReconnectEnd:Qe,onlyRenderVisibleElements:T,onEdgeContextMenu:be,onEdgeMouseEnter:we,onEdgeMouseMove:te,onEdgeMouseLeave:ie,reconnectRadius:Te,defaultMarkerColor:O,noPanClassName:ue,disableKeyboardA11y:ge,rfId:qe}),m.jsx(r8e,{style:k,type:y,component:w,containerStyle:v}),m.jsx("div",{className:"react-flow__edgelabel-renderer"}),m.jsx(A6e,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:Se,onlyRenderVisibleElements:T,noPanClassName:ue,noDragClassName:le,disableKeyboardA11y:ge,nodeExtent:Me,rfId:qe}),m.jsx("div",{className:"react-flow__viewport-portal"})]})})}Gie.displayName="GraphView";const i8e=g.memo(Gie),NQ=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:a,fitView:i,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f="basic"}={})=>{const p=new Map,y=new Map,k=new Map,w=new Map,v=r??t??[],M=n??e??[],x=u??[0,0],b=d??D2;rie(k,w,v);const{nodesInitialized:S}=PH(M,p,y,{nodeOrigin:x,nodeExtent:b,zIndexMode:f});let C=[0,0,1];if(i&&o&&a){const L=uf(p,{filter:A=>!!((A.width||A.initialWidth)&&(A.height||A.initialHeight))}),{x:P,y:T,zoom:_}=KV(L,o,a,c,l,(s==null?void 0:s.padding)??.1);C=[P,T,_]}return{rfId:"1",width:o??0,height:a??0,transform:C,nodes:M,nodesInitialized:S,nodeLookup:p,parentLookup:y,edges:v,edgeLookup:w,connectionLookup:k,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:D2,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:nd.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:x,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:i??!1,fitViewOptions:s,fitViewResolver:null,connection:{...Fae},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:c3e,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Oae,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},s8e=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:a,fitView:i,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>Lwe((p,y)=>{async function k(){const{nodeLookup:w,panZoom:v,fitViewOptions:M,fitViewResolver:x,width:b,height:S,minZoom:C,maxZoom:L}=y();v&&(await i3e({nodes:w,width:b,height:S,panZoom:v,minZoom:C,maxZoom:L},M),x==null||x.resolve(!0),p({fitViewResolver:null}))}return{...NQ({nodes:e,edges:t,width:o,height:a,fitView:i,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:w=>{const{nodeLookup:v,parentLookup:M,nodeOrigin:x,elevateNodesOnSelect:b,fitViewQueued:S,zIndexMode:C,nodesSelectionActive:L}=y(),{nodesInitialized:P,hasSelectedNodes:T}=PH(w,v,M,{nodeOrigin:x,nodeExtent:d,elevateNodesOnSelect:b,checkEquality:!0,zIndexMode:C}),_=L&&T;S&&P?(k(),p({nodes:w,nodesInitialized:P,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:_})):p({nodes:w,nodesInitialized:P,nodesSelectionActive:_})},setEdges:w=>{const{connectionLookup:v,edgeLookup:M}=y();rie(v,M,w),p({edges:w})},setDefaultNodesAndEdges:(w,v)=>{if(w){const{setNodes:M}=y();M(w),p({hasDefaultNodes:!0})}if(v){const{setEdges:M}=y();M(v),p({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:v,nodeLookup:M,parentLookup:x,domNode:b,nodeOrigin:S,nodeExtent:C,debug:L,fitViewQueued:P,zIndexMode:T}=y(),{changes:_,updatedInternals:A}=P3e(w,M,x,b,S,C,T);A&&(L3e(M,x,{nodeOrigin:S,nodeExtent:C,zIndexMode:T}),P?(k(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),(_==null?void 0:_.length)>0&&(L&&console.log("React Flow: trigger node changes",_),v==null||v(_)))},updateNodePositions:(w,v=!1)=>{const M=[];let x=[];const{nodeLookup:b,triggerNodeChanges:S,connection:C,updateConnection:L,onNodesChangeMiddlewareMap:P}=y();for(const[T,_]of w){const A=b.get(T),I=!!(A!=null&&A.expandParent&&(A!=null&&A.parentId)&&(_!=null&&_.position)),V={id:T,type:"position",position:I?{x:Math.max(0,_.position.x),y:Math.max(0,_.position.y)}:_.position,dragging:v};if(A&&C.inProgress&&C.fromNode.id===A.id){const j=Su(A,C.fromHandle,me.Left,!0);L({...C,from:j})}I&&A.parentId&&M.push({id:T,parentId:A.parentId,rect:{..._.internals.positionAbsolute,width:_.measured.width??0,height:_.measured.height??0}}),x.push(V)}if(M.length>0){const{parentLookup:T,nodeOrigin:_}=y(),A=e$(M,b,T,_);x.push(...A)}for(const T of P.values())x=T(x);S(x)},triggerNodeChanges:w=>{const{onNodesChange:v,setNodes:M,nodes:x,hasDefaultNodes:b,debug:S}=y();if(w!=null&&w.length){if(b){const C=Mie(w,x);M(C)}S&&console.log("React Flow: trigger node changes",w),v==null||v(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:v,setEdges:M,edges:x,hasDefaultEdges:b,debug:S}=y();if(w!=null&&w.length){if(b){const C=bie(w,x);M(C)}S&&console.log("React Flow: trigger edge changes",w),v==null||v(w)}},addSelectedNodes:w=>{const{multiSelectionActive:v,edgeLookup:M,nodeLookup:x,triggerNodeChanges:b,triggerEdgeChanges:S}=y();if(v){const C=w.map(L=>iu(L,!0));b(C);return}b(C1(x,new Set([...w]),!0)),S(C1(M))},addSelectedEdges:w=>{const{multiSelectionActive:v,edgeLookup:M,nodeLookup:x,triggerNodeChanges:b,triggerEdgeChanges:S}=y();if(v){const C=w.map(L=>iu(L,!0));S(C);return}S(C1(M,new Set([...w]))),b(C1(x,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:v}={})=>{const{edges:M,nodes:x,nodeLookup:b,triggerNodeChanges:S,triggerEdgeChanges:C}=y(),L=w||x,P=v||M,T=[];for(const A of L){if(!A.selected)continue;const I=b.get(A.id);I&&(I.selected=!1),T.push(iu(A.id,!1))}const _=[];for(const A of P)A.selected&&_.push(iu(A.id,!1));S(T),C(_)},setMinZoom:w=>{const{panZoom:v,maxZoom:M}=y();v==null||v.setScaleExtent([w,M]),p({minZoom:w})},setMaxZoom:w=>{const{panZoom:v,minZoom:M}=y();v==null||v.setScaleExtent([M,w]),p({maxZoom:w})},setTranslateExtent:w=>{var v;(v=y().panZoom)==null||v.setTranslateExtent(w),p({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:v,triggerNodeChanges:M,triggerEdgeChanges:x,elementsSelectable:b}=y();if(!b)return;const S=v.reduce((L,P)=>P.selected?[...L,iu(P.id,!1)]:L,[]),C=w.reduce((L,P)=>P.selected?[...L,iu(P.id,!1)]:L,[]);M(S),x(C)},setNodeExtent:w=>{const{nodes:v,nodeLookup:M,parentLookup:x,nodeOrigin:b,elevateNodesOnSelect:S,nodeExtent:C,zIndexMode:L}=y();w[0][0]===C[0][0]&&w[0][1]===C[0][1]&&w[1][0]===C[1][0]&&w[1][1]===C[1][1]||(PH(v,M,x,{nodeOrigin:b,nodeExtent:w,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:L}),p({nodeExtent:w}))},panBy:w=>{const{transform:v,width:M,height:x,panZoom:b,translateExtent:S}=y();return _3e({delta:w,panZoom:b,transform:v,translateExtent:S,width:M,height:x})},setCenter:async(w,v,M)=>{const{width:x,height:b,maxZoom:S,panZoom:C}=y();if(!C)return Promise.resolve(!1);const L=typeof(M==null?void 0:M.zoom)<"u"?M.zoom:S;return await C.setViewport({x:x/2-w*L,y:b/2-v*L,zoom:L},{duration:M==null?void 0:M.duration,ease:M==null?void 0:M.ease,interpolate:M==null?void 0:M.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...Fae}})},updateConnection:w=>{p({connection:w})},reset:()=>p({...NQ()})}},Object.is);function c8e({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:a,initialMinZoom:i,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){const[y]=g.useState(()=>s8e({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:a,fitView:l,minZoom:i,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return m.jsx(Iwe,{value:y,children:m.jsx(Zwe,{children:p})})}function l8e({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:a,height:i,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return g.useContext(fT)?m.jsx(m.Fragment,{children:e}):m.jsx(c8e,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:a,initialHeight:i,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}const u8e={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function d8e({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:a,edgeTypes:i,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:y,onConnectEnd:k,onClickConnectStart:w,onClickConnectEnd:v,onNodeMouseEnter:M,onNodeMouseMove:x,onNodeMouseLeave:b,onNodeContextMenu:S,onNodeDoubleClick:C,onNodeDragStart:L,onNodeDrag:P,onNodeDragStop:T,onNodesDelete:_,onEdgesDelete:A,onDelete:I,onSelectionChange:V,onSelectionDragStart:j,onSelectionDrag:H,onSelectionDragStop:O,onSelectionContextMenu:U,onSelectionStart:z,onSelectionEnd:N,onBeforeDelete:E,connectionMode:W,connectionLineType:q=Ha.Bezier,connectionLineStyle:R,connectionLineComponent:G,connectionLineContainerStyle:X,deleteKeyCode:Y="Backspace",selectionKeyCode:oe="Shift",selectionOnDrag:ee=!1,selectionMode:ae=rd.Full,panActivationKeyCode:ve="Space",multiSelectionKeyCode:Se=F2()?"Meta":"Control",zoomActivationKeyCode:be=F2()?"Meta":"Control",snapToGrid:we,snapGrid:te,onlyRenderVisibleElements:ie=!1,selectNodesOnDrag:Te,nodesDraggable:Ae,autoPanOnNodeFocus:at,nodesConnectable:Qe,nodesFocusable:le,nodeOrigin:Q=xie,edgesFocusable:ue,edgesReconnectable:ge,elementsSelectable:Me=!0,defaultViewport:qe=Fwe,minZoom:re=.5,maxZoom:he=2,translateExtent:Ie=D2,preventScrolling:He=!0,nodeExtent:Ue,defaultMarkerColor:Rt="#b1b1b7",zoomOnScroll:Oe=!0,zoomOnPinch:je=!0,panOnScroll:Pt=!1,panOnScrollSpeed:sr=.5,panOnScrollMode:Dt=mu.Free,zoomOnDoubleClick:Dn=!0,panOnDrag:en=!0,onPaneClick:$u,onPaneMouseEnter:Uu,onPaneMouseMove:da,onPaneMouseLeave:ha,onPaneScroll:Xr,onPaneContextMenu:gi,paneClickDistance:fa=1,nodeClickDistance:xr=0,children:Yr,onReconnect:wr,onReconnectStart:Wu,onReconnectEnd:Ve,onEdgeContextMenu:yt,onEdgeDoubleClick:Qr,onEdgeMouseEnter:Po,onEdgeMouseMove:qn,onEdgeMouseLeave:xn,reconnectRadius:_o=10,onNodesChange:On,onEdgesChange:Jr,noDragClassName:un="nodrag",noWheelClassName:Gt="nowheel",noPanClassName:eo="nopan",fitView:pa,fitViewOptions:to,connectOnClick:ki,attributionPosition:vi,proOptions:mt,defaultEdgeOptions:xi,elevateNodesOnSelect:ya=!0,elevateEdgesOnSelect:Mr=!1,disableKeyboardA11y:br=!1,autoPanOnConnect:cr,autoPanOnNodeDrag:ma,autoPanSpeed:wi,connectionRadius:Mi,isValidConnection:ga,onError:wn,style:Ro,id:ka,nodeDragThreshold:va,connectionDragThreshold:To,viewport:bi,onViewportChange:Mn,width:tn,height:Fn,colorMode:no="light",debug:jo,onScroll:Hn,ariaLabelConfig:xa,zIndexMode:Cr="basic",...st},Sr){const bn=ka||"1",Cn=$we(no),Ci=g.useCallback(Gu=>{Gu.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Hn==null||Hn(Gu)},[Hn]);return m.jsx("div",{"data-testid":"rf__wrapper",...st,onScroll:Ci,style:{...Ro,...u8e},ref:Sr,className:Vt(["react-flow",o,Cn]),id:ka,role:"application",children:m.jsxs(l8e,{nodes:e,edges:t,width:tn,height:Fn,fitView:pa,fitViewOptions:to,minZoom:re,maxZoom:he,nodeOrigin:Q,nodeExtent:Ue,zIndexMode:Cr,children:[m.jsx(Vwe,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:y,onConnectEnd:k,onClickConnectStart:w,onClickConnectEnd:v,nodesDraggable:Ae,autoPanOnNodeFocus:at,nodesConnectable:Qe,nodesFocusable:le,edgesFocusable:ue,edgesReconnectable:ge,elementsSelectable:Me,elevateNodesOnSelect:ya,elevateEdgesOnSelect:Mr,minZoom:re,maxZoom:he,nodeExtent:Ue,onNodesChange:On,onEdgesChange:Jr,snapToGrid:we,snapGrid:te,connectionMode:W,translateExtent:Ie,connectOnClick:ki,defaultEdgeOptions:xi,fitView:pa,fitViewOptions:to,onNodesDelete:_,onEdgesDelete:A,onDelete:I,onNodeDragStart:L,onNodeDrag:P,onNodeDragStop:T,onSelectionDrag:H,onSelectionDragStart:j,onSelectionDragStop:O,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:eo,nodeOrigin:Q,rfId:bn,autoPanOnConnect:cr,autoPanOnNodeDrag:ma,autoPanSpeed:wi,onError:wn,connectionRadius:Mi,isValidConnection:ga,selectNodesOnDrag:Te,nodeDragThreshold:va,connectionDragThreshold:To,onBeforeDelete:E,debug:jo,ariaLabelConfig:xa,zIndexMode:Cr}),m.jsx(i8e,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:M,onNodeMouseMove:x,onNodeMouseLeave:b,onNodeContextMenu:S,onNodeDoubleClick:C,nodeTypes:a,edgeTypes:i,connectionLineType:q,connectionLineStyle:R,connectionLineComponent:G,connectionLineContainerStyle:X,selectionKeyCode:oe,selectionOnDrag:ee,selectionMode:ae,deleteKeyCode:Y,multiSelectionKeyCode:Se,panActivationKeyCode:ve,zoomActivationKeyCode:be,onlyRenderVisibleElements:ie,defaultViewport:qe,translateExtent:Ie,minZoom:re,maxZoom:he,preventScrolling:He,zoomOnScroll:Oe,zoomOnPinch:je,zoomOnDoubleClick:Dn,panOnScroll:Pt,panOnScrollSpeed:sr,panOnScrollMode:Dt,panOnDrag:en,onPaneClick:$u,onPaneMouseEnter:Uu,onPaneMouseMove:da,onPaneMouseLeave:ha,onPaneScroll:Xr,onPaneContextMenu:gi,paneClickDistance:fa,nodeClickDistance:xr,onSelectionContextMenu:U,onSelectionStart:z,onSelectionEnd:N,onReconnect:wr,onReconnectStart:Wu,onReconnectEnd:Ve,onEdgeContextMenu:yt,onEdgeDoubleClick:Qr,onEdgeMouseEnter:Po,onEdgeMouseMove:qn,onEdgeMouseLeave:xn,reconnectRadius:_o,defaultMarkerColor:Rt,noDragClassName:un,noWheelClassName:Gt,noPanClassName:eo,rfId:bn,disableKeyboardA11y:br,nodeExtent:Ue,viewport:bi,onViewportChange:Mn}),m.jsx(Owe,{onSelectionChange:V}),Yr,m.jsx(jwe,{proOptions:mt,position:vi}),m.jsx(Twe,{rfId:bn,disableKeyboardA11y:br})]})})}var h8e=Cie(d8e);const f8e=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function p8e({children:e}){const t=Fe(f8e);return t?wd.createPortal(e,t):null}const y8e=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport-portal")};function m8e({children:e}){const t=Fe(y8e);return t?wd.createPortal(e,t):null}function g8e(){const e=vt();return g.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),o=Array.isArray(t)?t:[t],a=new Map;o.forEach(i=>{const s=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${i}"]`);s&&a.set(i,{id:i,nodeElement:s,force:!0})}),requestAnimationFrame(()=>r(a,{triggerFitView:!1}))},[])}function zQ(e){return Fe(g.useCallback(n=>n.nodeLookup.get(e),[e]),Ct)}function k8e({dimensions:e,lineWidth:t,variant:n,className:r}){return m.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Vt(["react-flow__background-pattern",n,r])})}function v8e({radius:e,className:t}){return m.jsx("circle",{cx:e,cy:e,r:e,className:Vt(["react-flow__background-pattern","dots",t])})}var ti;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ti||(ti={}));const x8e={[ti.Dots]:1,[ti.Lines]:1,[ti.Cross]:6},w8e=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Kie({id:e,variant:t=ti.Dots,gap:n=20,size:r,lineWidth:o=1,offset:a=0,color:i,bgColor:s,style:c,className:l,patternClassName:u}){const d=g.useRef(null),{transform:f,patternId:p}=Fe(w8e,Ct),y=r||x8e[t],k=t===ti.Dots,w=t===ti.Cross,v=Array.isArray(n)?n:[n,n],M=[v[0]*f[2]||1,v[1]*f[2]||1],x=y*f[2],b=Array.isArray(a)?a:[a,a],S=w?[x,x]:M,C=[b[0]*f[2]||1+S[0]/2,b[1]*f[2]||1+S[1]/2],L=`${p}${e||""}`;return m.jsxs("svg",{className:Vt(["react-flow__background",l]),style:{...c,...yT,"--xy-background-color-props":s,"--xy-background-pattern-color-props":i},ref:d,"data-testid":"rf__background",children:[m.jsx("pattern",{id:L,x:f[0]%M[0],y:f[1]%M[1],width:M[0],height:M[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`,children:k?m.jsx(v8e,{radius:x/2,className:u}):m.jsx(k8e,{dimensions:S,lineWidth:o,variant:t,className:u})}),m.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${L})`})]})}Kie.displayName="Background";const M8e=g.memo(Kie);function b8e(){return m.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:m.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function C8e(){return m.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:m.jsx("path",{d:"M0 0h32v4.2H0z"})})}function S8e(){return m.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:m.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function L8e(){return m.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:m.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function I8e(){return m.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:m.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function S1({children:e,className:t,...n}){return m.jsx("button",{type:"button",className:Vt(["react-flow__controls-button",t]),...n,children:e})}const E8e=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Zie({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:a,onZoomOut:i,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d="bottom-left",orientation:f="vertical","aria-label":p}){const y=vt(),{isInteractive:k,minZoomReached:w,maxZoomReached:v,ariaLabelConfig:M}=Fe(E8e,Ct),{zoomIn:x,zoomOut:b,fitView:S}=pT(),C=()=>{x(),a==null||a()},L=()=>{b(),i==null||i()},P=()=>{S(o),s==null||s()},T=()=>{y.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),c==null||c(!k)},_=f==="horizontal"?"horizontal":"vertical";return m.jsxs(cd,{className:Vt(["react-flow__controls",_,l]),position:d,style:e,"data-testid":"rf__controls","aria-label":p??M["controls.ariaLabel"],children:[t&&m.jsxs(m.Fragment,{children:[m.jsx(S1,{onClick:C,className:"react-flow__controls-zoomin",title:M["controls.zoomIn.ariaLabel"],"aria-label":M["controls.zoomIn.ariaLabel"],disabled:v,children:m.jsx(b8e,{})}),m.jsx(S1,{onClick:L,className:"react-flow__controls-zoomout",title:M["controls.zoomOut.ariaLabel"],"aria-label":M["controls.zoomOut.ariaLabel"],disabled:w,children:m.jsx(C8e,{})})]}),n&&m.jsx(S1,{className:"react-flow__controls-fitview",onClick:P,title:M["controls.fitView.ariaLabel"],"aria-label":M["controls.fitView.ariaLabel"],children:m.jsx(S8e,{})}),r&&m.jsx(S1,{className:"react-flow__controls-interactive",onClick:T,title:M["controls.interactive.ariaLabel"],"aria-label":M["controls.interactive.ariaLabel"],children:k?m.jsx(I8e,{}):m.jsx(L8e,{})}),u]})}Zie.displayName="Controls";const A8e=g.memo(Zie);function P8e({id:e,x:t,y:n,width:r,height:o,style:a,color:i,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){const{background:y,backgroundColor:k}=a||{},w=i||y||k;return m.jsx("rect",{className:Vt(["react-flow__minimap-node",{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:o,style:{fill:w,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?v=>p(v,e):void 0})}const _8e=g.memo(P8e),R8e=e=>e.nodes.map(t=>t.id),zO=e=>e instanceof Function?e:()=>e;function T8e({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:a=_8e,onClick:i}){const s=Fe(R8e,Ct),c=zO(t),l=zO(e),u=zO(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return m.jsx(m.Fragment,{children:s.map(f=>m.jsx(N8e,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:a,onClick:i,shapeRendering:d},f))})}function j8e({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:a,shapeRendering:i,NodeComponent:s,onClick:c}){const{node:l,x:u,y:d,width:f,height:p}=Fe(y=>{const k=y.nodeLookup.get(e);if(!k)return{node:void 0,x:0,y:0,width:0,height:0};const w=k.internals.userNode,{x:v,y:M}=k.internals.positionAbsolute,{width:x,height:b}=ca(w);return{node:w,x:v,y:M,width:x,height:b}},Ct);return!l||l.hidden||!Gae(l)?null:m.jsx(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:o,strokeColor:n(l),strokeWidth:a,shapeRendering:i,onClick:c,id:l.id})}const N8e=g.memo(j8e);var z8e=g.memo(T8e);const D8e=200,q8e=150,O8e=e=>!e.hidden,F8e=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?Wae(uf(e.nodeLookup,{filter:O8e}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},H8e="react-flow__minimap-desc";function Xie({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:a=5,nodeStrokeWidth:i,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f="bottom-right",onClick:p,onNodeClick:y,pannable:k=!1,zoomable:w=!1,ariaLabel:v,inversePan:M,zoomStep:x=1,offsetScale:b=5}){const S=vt(),C=g.useRef(null),{boundingRect:L,viewBB:P,rfId:T,panZoom:_,translateExtent:A,flowWidth:I,flowHeight:V,ariaLabelConfig:j}=Fe(F8e,Ct),H=(e==null?void 0:e.width)??D8e,O=(e==null?void 0:e.height)??q8e,U=L.width/H,z=L.height/O,N=Math.max(U,z),E=N*H,W=N*O,q=b*N,R=L.x-(E-L.width)/2-q,G=L.y-(W-L.height)/2-q,X=E+q*2,Y=W+q*2,oe=`${H8e}-${T}`,ee=g.useRef(0),ae=g.useRef();ee.current=N,g.useEffect(()=>{if(C.current&&_)return ae.current=F3e({domNode:C.current,panZoom:_,getTransform:()=>S.getState().transform,getViewScale:()=>ee.current}),()=>{var we;(we=ae.current)==null||we.destroy()}},[_]),g.useEffect(()=>{var we;(we=ae.current)==null||we.update({translateExtent:A,width:I,height:V,inversePan:M,pannable:k,zoomStep:x,zoomable:w})},[k,w,M,x,A,I,V]);const ve=p?we=>{var Te;const[te,ie]=((Te=ae.current)==null?void 0:Te.pointer(we))||[0,0];p(we,{x:te,y:ie})}:void 0,Se=y?g.useCallback((we,te)=>{const ie=S.getState().nodeLookup.get(te).internals.userNode;y(we,ie)},[]):void 0,be=v??j["minimap.ariaLabel"];return m.jsx(cd,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*N:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:Vt(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:m.jsxs("svg",{width:H,height:O,viewBox:`${R} ${G} ${X} ${Y}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":oe,ref:C,onClick:ve,children:[be&&m.jsx("title",{id:oe,children:be}),m.jsx(z8e,{onClick:Se,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:o,nodeStrokeWidth:i,nodeComponent:s}),m.jsx("path",{className:"react-flow__minimap-mask",d:`M${R-q},${G-q}h${X+q*2}v${Y+q*2}h${-X-q*2}z
|
|
7762
7762
|
M${P.x},${P.y}h${P.width}v${P.height}h${-P.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}Xie.displayName="MiniMap";g.memo(Xie);const B8e=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,V8e={[ii.Line]:"right",[ii.Handle]:"bottom-right"};function $8e({nodeId:e,position:t,variant:n=ii.Handle,className:r,style:o=void 0,children:a,color:i,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:y,onResizeStart:k,onResize:w,onResizeEnd:v}){const M=Eie(),x=typeof e=="string"?e:M,b=vt(),S=g.useRef(null),C=n===ii.Handle,L=Fe(g.useCallback(B8e(C&&p),[C,p]),Ct),P=g.useRef(null),T=t??V8e[n];g.useEffect(()=>{if(!(!S.current||!x))return P.current||(P.current=ewe({domNode:S.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:A,transform:I,snapGrid:V,snapToGrid:j,nodeOrigin:H,domNode:O}=b.getState();return{nodeLookup:A,transform:I,snapGrid:V,snapToGrid:j,nodeOrigin:H,paneDomNode:O}},onChange:(A,I)=>{const{triggerNodeChanges:V,nodeLookup:j,parentLookup:H,nodeOrigin:O}=b.getState(),U=[],z={x:A.x,y:A.y},N=j.get(x);if(N&&N.expandParent&&N.parentId){const E=N.origin??O,W=A.width??N.measured.width??0,q=A.height??N.measured.height??0,R={id:N.id,parentId:N.parentId,rect:{width:W,height:q,...Kae({x:A.x??N.position.x,y:A.y??N.position.y},{width:W,height:q},N.parentId,j,E)}},G=e$([R],j,H,O);U.push(...G),z.x=A.x?Math.max(E[0]*W,A.x):void 0,z.y=A.y?Math.max(E[1]*q,A.y):void 0}if(z.x!==void 0&&z.y!==void 0){const E={id:x,type:"position",position:{...z}};U.push(E)}if(A.width!==void 0&&A.height!==void 0){const W={id:x,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:A.width,height:A.height}};U.push(W)}for(const E of I){const W={...E,type:"position"};U.push(W)}V(U)},onEnd:({width:A,height:I})=>{const V={id:x,type:"dimensions",resizing:!1,dimensions:{width:A,height:I}};b.getState().triggerNodeChanges([V])}})),P.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:k,onResize:w,onResizeEnd:v,shouldResize:y}),()=>{var A;(A=P.current)==null||A.destroy()}},[T,s,c,l,u,d,k,w,v,y]);const _=T.split("-");return m.jsx("div",{className:Vt(["react-flow__resize-control","nodrag",..._,n,r]),ref:S,style:{...o,scale:L,...i&&{[C?"backgroundColor":"borderColor"]:i}},children:a})}const DQ=g.memo($8e),U8e=24,W8e=e=>({type:q2.ArrowClosed,width:18,height:18,...e?{color:e}:{}}),G8e={http:{},event:{strokeDasharray:"6 4"},queue:{strokeDasharray:"2 4"},default:{}},K8e={solid:{},dashed:{strokeDasharray:"6 4"},dotted:{strokeDasharray:"2 4"}},Z8e=3,qQ=new WeakMap,X8e=(e,t,n=!1)=>{const r=qQ.get(e);if(r&&r.isAdjacentToRunning===t&&r.selected===n)return r.edge;const o=e.style?K8e[e.style]:G8e[e.kind],a=ct(e.color,"edge"),i=e.borderSize??2,s=n?Math.max(Z8e,i):i,l={...o,...a,...n?{strokeWidth:s,opacity:1}:{strokeWidth:s}},u=e.direction??"forward",d=a.stroke,f=W8e(d),p=u==="backward"||u==="both"?f:void 0,y=u==="forward"||u==="both"?f:void 0,k={id:e.id,source:e.source,target:e.target,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle,type:"editableEdge",label:e.label,animated:t,data:{kind:e.kind,path:e.path,sourceHandleAutoPicked:e.sourceHandleAutoPicked,targetHandleAutoPicked:e.targetHandleAutoPicked,sourcePin:e.sourcePin,targetPin:e.targetPin,fontSize:e.fontSize},style:l,markerStart:p,markerEnd:y,interactionWidth:U8e};return qQ.set(e,{isAdjacentToRunning:t,selected:n,edge:k}),k},Y8e=(e,t={})=>{const n=t.setTimer??((l,u)=>globalThis.setTimeout(l,u)),r=t.clearTimer??(l=>{globalThis.clearTimeout(l)});let o=null,a=null;return{schedule:l=>{o!==null&&r(o),a=l,o=n(()=>{o=null;const u=a;a=null,u&&u()},e)},flush:()=>{o!==null&&(r(o),o=null);const l=a;a=null,l&&l()},cancel:()=>{o!==null&&(r(o),o=null),a=null},get pending(){return o!==null}}},Yie="seeflow:detail-panel-width",s1=380,jH=320,NH=800;function zH(e){return Number.isFinite(e)?e<jH?jH:e>NH?NH:e:s1}function Q8e(){if(typeof window>"u")return s1;try{const e=window.localStorage.getItem(Yie);if(e===null)return s1;const t=Number(e);return!Number.isFinite(t)||t<jH||t>NH?s1:t}catch{return s1}}function J8e(e){if(!(typeof window>"u"))try{const t=zH(e);window.localStorage.setItem(Yie,String(t))}catch{}}function eMe(e,t,n,r){const o=typeof window>"u"?null:window;if(!o)return;let a=zH(e);const i=c=>{a=zH(e+(t-c.clientX)),n.onWidth(a)},s=()=>{o.removeEventListener("pointermove",i),o.removeEventListener("pointerup",s),o.removeEventListener("pointercancel",s),n.onCommit(a)};o.addEventListener("pointermove",i),o.addEventListener("pointerup",s),o.addEventListener("pointercancel",s)}function Qie(e,t){return`/api/projects/${encodeURIComponent(e)}/files/${encodeURI(t)}`}const rR=(e,t)=>{const n=e.w/2,r=e.h/2,o=e.x+n,a=e.y+r,i=t.x-o,s=t.y-a;if(i===0&&s===0)return{x:o,y:a,side:"right"};const c=Math.abs(i),l=Math.abs(s),u=c===0?Number.POSITIVE_INFINITY:n/c,d=l===0?Number.POSITIVE_INFINITY:r/l,f=Math.min(u,d),p=o+i*f,y=a+s*f,k=c*r>=l*n?i>=0?"right":"left":s>=0?"bottom":"top";return{x:p,y,side:k}},DH=(e,t)=>{const n=Math.max(0,Math.min(e.w,t.x-e.x)),r=Math.max(0,Math.min(e.h,t.y-e.y)),o=n,a=e.w-n,i=r,s=e.h-r,c=Math.min(o,a,i,s),l=e.h===0?0:r/e.h,u=e.w===0?0:n/e.w;return c===o?{side:"left",t:l}:c===a?{side:"right",t:l}:c===i?{side:"top",t:u}:{side:"bottom",t:u}},oR=(e,t)=>{const n=Math.min(1,Math.max(0,t.t));let r,o;switch(t.side){case"top":r=e.x+n*e.w,o=e.y;break;case"bottom":r=e.x+n*e.w,o=e.y+e.h;break;case"left":r=e.x,o=e.y+n*e.h;break;case"right":r=e.x+e.w,o=e.y+n*e.h;break}return{x:r,y:o,side:t.side}},tMe=(e,t)=>{const n=r=>Math.min(1,Math.max(0,r));switch(t.side){case"top":case"bottom":return{side:t.side,t:e.w===0?0:n((t.x-e.x)/e.w)};case"left":case"right":return{side:t.side,t:e.h===0?0:n((t.y-e.y)/e.h)}}},nMe=(e,t)=>{const n=(e==null?void 0:e.fallback)??{x:0,y:0,side:"right"},r=(t==null?void 0:t.fallback)??{x:0,y:0,side:"left"};if(!e||!t)return{source:n,target:r};const o={x:e.box.x+e.box.w/2,y:e.box.y+e.box.h/2},a={x:t.box.x+t.box.w/2,y:t.box.y+t.box.h/2},i=e.pin?oR(e.box,e.pin):e.autoPicked===!1?e.fallback:rR(e.box,a),s=t.pin?oR(t.box,t.pin):t.autoPicked===!1?t.fallback:rR(t.box,o);return{source:i,target:s}};function go({initialValue:e,onCommit:t,onExit:n,multiline:r=!1,commitMode:o="enter-commits",required:a=!1,field:i,className:s,style:c,placeholder:l}){const u=r||o==="blur-only",d=g.useRef(null),[f,p]=g.useState(!1),[y,k]=g.useState(e.length===0),w=g.useRef(Y8e(400)),v=g.useRef(e),M=g.useRef(!1);g.useEffect(()=>{const A=d.current;if(!A)return;A.textContent=e,A.focus();const I=window.getSelection();if(I){const j=document.createRange();j.selectNodeContents(A),I.removeAllRanges(),I.addRange(j)}const V=w.current;return()=>{V.cancel()}},[]);const x=()=>{const A=d.current;return A?u?A.innerText:A.textContent??"":""},b=A=>{w.current.cancel(),A!==v.current&&(v.current=A,t(A))},S=()=>{const A=x();if(k(A.length===0),a&&A.trim().length===0){w.current.cancel();return}w.current.schedule(()=>b(A))},C=()=>{w.current.cancel();const A=x();if(a&&A.trim().length===0){const I=d.current;I&&(I.textContent=e),p(!0),setTimeout(()=>p(!1),320),n();return}b(A),n()},L=()=>{w.current.cancel();const A=d.current;A&&(A.textContent=e),n()},P=A=>{if(A.stopPropagation(),A.nativeEvent.stopPropagation(),A.key==="Enter"){if(o==="blur-only"||r&&A.shiftKey){A.preventDefault(),document.execCommand("insertText",!1,`
|
|
7763
|
-
`);return}A.preventDefault(),M.current=!0,C();return}A.key==="Escape"&&(A.preventDefault(),M.current=!0,L())},T=A=>{A.preventDefault();const I=A.clipboardData.getData("text/plain");document.execCommand("insertText",!1,I)},_=()=>{if(M.current){M.current=!1;return}C()};return m.jsx("div",{ref:d,"data-testid":"inline-edit-input","data-field":i,"data-placeholder":l,role:"textbox",tabIndex:0,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:S,onKeyDown:P,onPaste:T,onBlur:_,onMouseDown:A=>A.stopPropagation(),onClick:A=>A.stopPropagation(),onDoubleClick:A=>A.stopPropagation(),style:c,className:ce("nodrag nopan nowheel block w-full bg-transparent p-0 text-inherit outline-none","sf:whitespace-pre-wrap sf:wrap-break-word",y&&l?"inline-edit-empty":"",f?"inline-edit-shake":"",s)})}function Ed({className:e}){return m.jsx("span",{"data-testid":"node-lock-badge","aria-hidden":"true",className:ce("sf:absolute sf:-top-2 sf:-right-2 sf:z-10 sf:inline-flex sf:h-4 sf:w-4 sf:items-center sf:justify-center sf:rounded-sm sf:bg-background/90 sf:text-muted-foreground sf:shadow-sm sf:ring-1 sf:ring-border",e),children:m.jsx(Wh,{className:"sf:h-2.5 sf:w-2.5",strokeWidth:2.5})})}const Jie=8,OQ=12,FQ={height:`${Jie}px`,borderColor:"transparent"},HQ={width:`${Jie}px`,borderColor:"transparent"},rMe={width:`${OQ}px`,height:`${OQ}px`,background:"transparent",border:"none"},oMe={width:"calc(10px / var(--rf-zoom, 1))",height:"calc(10px / var(--rf-zoom, 1))",background:"hsl(var(--background))",border:"calc(1px / var(--rf-zoom, 1)) solid hsl(var(--primary) / 0.6)",borderRadius:"calc(2px / var(--rf-zoom, 1))",zIndex:1},aMe=[{position:"top",style:FQ},{position:"bottom",style:FQ},{position:"left",style:HQ},{position:"right",style:HQ}],iMe=["top-left","top-right","bottom-left","bottom-right"],BQ={pointerEvents:"none",cursor:"default"};function Ad({visible:e,minWidth:t=80,minHeight:n=40,onResizeStart:r,onResize:o,onResizeEnd:a,cornerVariant:i="invisible"}){const s=i==="visible"?oMe:rMe,c=u=>e?u:{...u,...BQ},l=e?s:{...s,opacity:0,...BQ};return m.jsxs(m.Fragment,{children:[aMe.map(({position:u,style:d})=>m.jsx(DQ,{position:u,variant:ii.Line,minWidth:t,minHeight:n,style:c(d),onResizeStart:r,onResize:o,onResizeEnd:a,children:m.jsx("span",{"data-testid":"resize-control","data-position":u})},u)),iMe.map(u=>m.jsx(DQ,{position:u,variant:ii.Handle,minWidth:t,minHeight:n,style:l,autoScale:!1,onResizeStart:r,onResize:o,onResizeEnd:a,children:m.jsx("span",{"data-testid":"resize-control","data-position":u})},u))]})}function Pd(e){const{onResize:t,onResizeFinal:n,setResizing:r}=e,[o,a]=g.useState(!1),i=g.useRef(null),s=g.useRef(t),c=g.useRef(n),l=g.useRef(r);g.useEffect(()=>{s.current=t},[t]),g.useEffect(()=>{c.current=n},[n]),g.useEffect(()=>{l.current=r},[r]);const u=g.useCallback((p,y)=>{var k;a(!0),(k=l.current)==null||k.call(l,!0),i.current=y?{x:y.x,y:y.y,width:y.width,height:y.height}:null},[]),d=g.useCallback((p,y)=>{var k;(k=s.current)==null||k.call(s,{x:y.x,y:y.y,width:y.width,height:y.height})},[]),f=g.useCallback((p,y)=>{var w,v,M;a(!1),(w=l.current)==null||w.call(l,!1);const k=i.current;i.current=null,!(k&&k.width===y.width&&k.height===y.height)&&((v=s.current)==null||v.call(s,{x:y.x,y:y.y,width:y.width,height:y.height}),k&&((M=c.current)==null||M.call(c,{x:y.x,y:y.y,width:y.width,height:y.height},k)))},[]);return{isResizing:o,onResizeStart:u,onResizeEvent:d,onResizeEnd:f}}const ld={width:48,height:48},VQ="help-circle",sMe=24,cMe=24,b0="sf:opacity-0 sf:transition-opacity";function lMe(e){return ct(e,"text").color??"currentColor"}const $Q=new Set;function uMe({id:e,data:t,selected:n,isConnectable:r}){const{onResizeStart:o,onResizeEvent:a,onResizeEnd:i}=Pd({onResize:v=>{var M;return(M=t.onResize)==null?void 0:M.call(t,e,v)},setResizing:t.setResizing}),s=t.width!==void 0||t.height!==void 0,c=!!t.onNameChange,[l,u]=g.useState(!1),d=J1[t.icon];!d&&!$Q.has(t.icon)&&($Q.add(t.icon),console.warn(`[iconNode] Unknown icon "${t.icon}"; falling back to "${VQ}".`));const f=d??J1[VQ],p=lMe(t.color),y=t.strokeWidth??2,k={...s?{}:{width:ld.width,height:ld.height}},w=v=>{!c||l||(v.stopPropagation(),u(!0))};return m.jsxs("div",{className:ce("sf:group sf:relative",s?"sf:h-full sf:w-full":""),style:k,"data-testid":"icon-node",onDoubleClick:w,children:[m.jsx(Ad,{visible:!!n&&!!t.onResize&&!l&&!t.locked,cornerVariant:"visible",minWidth:sMe,minHeight:cMe,onResizeStart:o,onResize:a,onResizeEnd:i}),t.locked?m.jsx(Ed,{}):null,m.jsx(ut,{type:"target",position:me.Top,id:"t",isConnectable:r,className:ce(b0,n&&"sf:opacity-100!")}),m.jsx(ut,{type:"target",position:me.Left,id:"l",isConnectable:r,className:ce(b0,n&&"sf:opacity-100!")}),f?m.jsx(f,{color:p,strokeWidth:y,absoluteStrokeWidth:!0,"aria-label":t.alt,className:"sf:block sf:h-full sf:w-full sf:pointer-events-none sf:select-none"}):null,l&&c?m.jsx("div",{className:"sf:absolute sf:left-0 sf:right-0 sf:top-full sf:mt-1 sf:text-center sf:text-xs sf:text-muted-foreground",children:m.jsx(go,{initialValue:t.name??"",field:"icon-node-label",onCommit:v=>{var M;return(M=t.onNameChange)==null?void 0:M.call(t,e,v)},onExit:()=>u(!1),placeholder:"Label"})}):t.name?m.jsx("span",{"data-testid":"icon-node-label",className:"sf:pointer-events-none sf:absolute sf:left-0 sf:right-0 sf:top-full sf:mt-1 sf:truncate sf:text-center sf:text-xs sf:text-muted-foreground sf:select-none",children:t.name}):null,m.jsx(ut,{type:"source",position:me.Right,id:"r",isConnectable:r,className:ce(b0,n&&"sf:opacity-100!")}),m.jsx(ut,{type:"source",position:me.Bottom,id:"b",isConnectable:r,className:ce(b0,n&&"sf:opacity-100!")})]})}function dMe(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const hMe=g.memo(uMe,dMe);function fMe(e,t){const n=e.screenToFlowPosition({x:t.width/2,y:t.height/2});return{x:n.x-ld.width/2,y:n.y-ld.height/2}}const ese="seeflow:icon-recents",pMe=16;function tse(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(ese);if(e===null)return[];const t=JSON.parse(e);return Array.isArray(t)?t.every(n=>typeof n=="string")?t:[]:[]}catch{return[]}}function yMe(e){if(!(typeof window>"u"))try{const n=tse().filter(o=>o!==e),r=[e,...n].slice(0,pMe);window.localStorage.setItem(ese,JSON.stringify(r))}catch{}}const mMe=typeof navigator<"u"&&typeof navigator.platform=="string"&&navigator.platform.toLowerCase().includes("mac"),gMe=e=>e.length===1?e.toUpperCase():e==="Escape"?"Esc":e,Nt=(e,t=mMe)=>{const n=gMe(e.key);if(t){let o="";return e.meta&&(o+="⌘"),e.alt&&(o+="⌥"),e.shift&&(o+="⇧"),`${o}${n}`}const r=[];return e.meta&&r.push("Ctrl"),e.shift&&r.push("Shift"),e.alt&&r.push("Alt"),r.push(n),r.join("+")},n$=[{id:"tool.select",label:"Select tool",description:"Switch to the selection / pan tool",category:"Tools",shortcut:Nt({key:"V"})},{id:"tool.rectangle",label:"Rectangle",description:"Draw rectangle nodes",category:"Tools",shortcut:Nt({key:"R"})},{id:"tool.ellipse",label:"Ellipse",description:"Draw ellipse nodes",category:"Tools",shortcut:Nt({key:"O"})},{id:"tool.text",label:"Text",description:"Add a text node",category:"Tools",shortcut:Nt({key:"T"})},{id:"tool.sticky",label:"Sticky note",description:"Add a sticky note",category:"Tools",shortcut:Nt({key:"S"})},{id:"tool.database",label:"Database",description:"Add a database node",category:"Tools",shortcut:Nt({key:"D"})},{id:"tool.server",label:"Server",description:"Add a server node",category:"Tools"},{id:"tool.user",label:"User",description:"Add a user node",category:"Tools"},{id:"tool.queue",label:"Queue",description:"Add a queue node",category:"Tools"},{id:"tool.cloud",label:"Cloud",description:"Add a cloud node",category:"Tools"},{id:"edit.undo",label:"Undo",category:"Edit",shortcut:Nt({meta:!0,key:"Z"}),enabled:e=>e.canUndo},{id:"edit.redo",label:"Redo",category:"Edit",shortcut:Nt({meta:!0,shift:!0,key:"Z"}),enabled:e=>e.canRedo},{id:"edit.copy",label:"Copy",category:"Edit",shortcut:Nt({meta:!0,key:"C"}),enabled:e=>e.hasSelection},{id:"edit.paste",label:"Paste",category:"Edit",shortcut:Nt({meta:!0,key:"V"}),enabled:e=>e.hasClipboard},{id:"edit.duplicate",label:"Duplicate",category:"Edit",shortcut:Nt({meta:!0,key:"D"}),enabled:e=>e.hasSelection},{id:"edit.delete",label:"Delete",category:"Edit",shortcut:Nt({key:"Delete"}),enabled:e=>e.hasSelection},{id:"edit.selectAll",label:"Select all",category:"Edit",shortcut:Nt({meta:!0,key:"A"})},{id:"view.fit",label:"Fit view",description:"Fit everything in the viewport",category:"View",shortcut:Nt({meta:!0,key:"0"})},{id:"view.zoomIn",label:"Zoom in",category:"View",shortcut:Nt({meta:!0,key:"="})},{id:"view.zoomOut",label:"Zoom out",category:"View",shortcut:Nt({meta:!0,key:"-"})},{id:"view.zoom100",label:"Zoom to 100%",category:"View",shortcut:Nt({key:"1"})},{id:"view.zoomToSelection",label:"Zoom to selection",category:"View",shortcut:Nt({key:"F"}),enabled:e=>e.hasSelection},{id:"layout.tidy",label:"Tidy layout",description:"Auto-layout the canvas or current selection",category:"Layout",shortcut:Nt({meta:!0,shift:!0,key:"L"})},{id:"selection.deselect",label:"Deselect",description:"Clear selection and exit draw mode",category:"Selection",shortcut:Nt({key:"Escape"})},{id:"help.commandPalette",label:"Open command palette",category:"Help",shortcut:Nt({meta:!0,key:"P"})},{id:"export.pdf",label:"Export to PDF",description:"Download the current canvas as a PDF",category:"File",enabled:e=>e.canExportDemo},{id:"export.png",label:"Export as image",description:"Download the current canvas as a PNG",category:"File",enabled:e=>e.canExportDemo},{id:"session.reset",label:"Restart the demo",description:"Stop running scripts and re-run the reset script",category:"File",enabled:e=>e.canResetSession}],UQ=e=>{const t=n$.find(n=>n.id===e);return t?t.shortcut?`${t.label} (${t.shortcut})`:t.label:""},kMe=1,vMe=10,xMe=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return null;const t=e.shiftKey?vMe:kMe;switch(e.key){case"ArrowLeft":return{dx:-t,dy:0};case"ArrowRight":return{dx:t,dy:0};case"ArrowUp":return{dx:0,dy:-t};case"ArrowDown":return{dx:0,dy:t};default:return null}},wMe=e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return null;switch(e.key){case"0":return"fit";case"=":case"+":return"in";case"-":case"_":return"out";default:return null}},MMe=(e,t,n)=>{if(t.length===0)return[];const r=new Map(n.map(a=>[a.id,a])),o=[];for(const a of t){const i=r.get(a);i&&o.push({id:a,position:{x:i.position.x+e.dx,y:i.position.y+e.dy}})}return o},bMe=({event:e,isEditableActive:t,hasNodes:n,hasConnectors:r,selectedIds:o,hasClipboard:a})=>{if(!(e.metaKey||e.ctrlKey))return{type:"noop"};if(e.shiftKey||e.altKey)return{type:"noop"};const i=e.key.toLowerCase();return i!=="a"&&i!=="c"&&i!=="v"&&i!=="d"?{type:"noop"}:t?{type:"noop"}:i==="a"?!n&&!r?{type:"noop"}:{type:"selectAll"}:i==="c"?o.length===0?{type:"noop"}:{type:"copy",ids:o}:i==="d"?o.length===0?{type:"noop"}:{type:"duplicate",ids:o}:a?{type:"paste"}:{type:"noop"}},CMe=e=>{if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return null;switch(e.key.toLowerCase()){case"v":return"select";case"r":return"rectangle";case"o":return"ellipse";case"t":return"text";case"s":return"sticky";case"d":return"database";default:return null}},Ai="seeflow",nse=e=>`${e}:last-used-style:v1`,DO=()=>({node:{},connector:{}}),qO=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),r$=e=>{var t;try{const n=(t=globalThis.localStorage)==null?void 0:t.getItem(nse(e));if(!n)return DO();const r=JSON.parse(n);if(!qO(r))return DO();const o=qO(r.node)?r.node:{},a=qO(r.connector)?r.connector:{};return{node:o,connector:a}}catch{return DO()}},rse=(e,t)=>{var n;try{(n=globalThis.localStorage)==null||n.setItem(nse(e),JSON.stringify(t))}catch{}},C0=e=>r$(e),WQ=(e,t)=>{const{alt:n,...r}=t,o={...r};o.borderSize!==void 0&&o.borderWidth===void 0?o.borderWidth=o.borderSize:o.borderWidth!==void 0&&o.borderSize===void 0&&(o.borderSize=o.borderWidth);const a=r$(e);rse(e,{...a,node:{...a.node,...o}})},SMe=(e,t)=>{const n=r$(e);rse(e,{...n,connector:{...n.connector,...t}})},o$=3,GQ=17,qH=(e,t)=>{if(!e)return{};const n={};for(const r of t)e[r]!==void 0&&(n[r]=e[r]);return n},LMe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize","cornerRadius"],IMe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize"],EMe=["fontSize"],AMe=["borderColor","borderWidth","borderStyle"];function KQ(e,t,n){if(e==="text")return{shape:e,width:t.width,height:t.height,fontSize:GQ,...qH(n,EMe)};const r=e==="ellipse"?IMe:LMe;return{shape:e,width:t.width,height:t.height,borderSize:o$,fontSize:GQ,...qH(n,r)}}function PMe(e,t,n){return{path:e,width:t.width,height:t.height,borderWidth:o$,...qH(n,AMe)}}const Ar=async(e,t,n,r)=>{const o={method:t};r!==void 0&&(o.headers={"content-type":"application/json"},o.body=JSON.stringify(r));const a=await e(n,o);if(!a.ok){let i=null;try{i=await a.json()}catch{}throw new Error((i==null?void 0:i.error)??`${t} ${n} → ${a.status}`)}return await a.json()},_Me=e=>{const{baseUrl:t,demoId:n}=e,r=e.fetch??globalThis.fetch.bind(globalThis),o=`${t}/api/demos/${n}`;return{async createNode(a){const i=await Ar(r,"POST",`${o}/nodes`,a);return{id:i.id,node:i.node}},async updateNode(a,i){await Ar(r,"PATCH",`${o}/nodes/${a}`,i)},async updateNodePosition(a,i){return await Ar(r,"PATCH",`${o}/nodes/${a}/position`,i)},async deleteNode(a){await Ar(r,"DELETE",`${o}/nodes/${a}`)},async reorderNode(a,i){await Ar(r,"PATCH",`${o}/nodes/${a}/order`,i)},async createConnector(a){return{id:(await Ar(r,"POST",`${o}/connectors`,a)).id}},async updateConnector(a,i){await Ar(r,"PATCH",`${o}/connectors/${a}`,i)},async deleteConnector(a){await Ar(r,"DELETE",`${o}/connectors/${a}`)},async uploadImage(a,i){const s=new FormData;s.append("file",a),s.append("filename",i);const c=`${t}/api/projects/${encodeURIComponent(n)}/files/upload`,l=await r(c,{method:"POST",body:s});if(!l.ok){let u=null;try{u=await l.json()}catch{}throw new Error((u==null?void 0:u.error)??`POST ${c} → ${l.status}`)}return await l.json()},async playNode(a){return await Ar(r,"POST",`${o}/play/${a}`,{})},async openFile(a){await Ar(r,"POST",`${t}/api/projects/${encodeURIComponent(n)}/files/open`,{path:a})},async revealFile(a){await Ar(r,"POST",`${t}/api/projects/${encodeURIComponent(n)}/files/reveal`,{path:a})}}};function RMe(e,t,n){let r=null,o=!1;const a=new ResizeObserver(()=>{o||(r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,!o&&n()},t))});return a.observe(e),()=>{o||(o=!0,r!==null&&(clearTimeout(r),r=null),a.disconnect())}}const TMe=new Set(["SCRIPT","STYLE","IFRAME","OBJECT","EMBED","LINK"]),jMe=new Set(["href","src"]),NMe=e=>/^on/i.test(e),zMe=e=>{let t=0;for(;t<e.length&&e.charCodeAt(t)<=32;)t+=1;return e.slice(t,t+11).toLowerCase()==="javascript:"};function DMe(e){if(typeof DOMParser>"u")return"";const t=new DOMParser().parseFromString(`<!doctype html><html><body>${e}</body></html>`,"text/html"),n=t.body,r=t.createTreeWalker(n,1),o=[];let a=r.nextNode();for(;a;){const i=a;if(TMe.has(i.tagName))o.push(i);else for(const s of Array.from(i.attributes)){if(NMe(s.name)){i.removeAttribute(s.name);continue}jMe.has(s.name.toLowerCase())&&zMe(s.value)&&i.removeAttribute(s.name)}a=r.nextNode()}for(const i of o)i.remove();return n.innerHTML}function ZQ(e){return{dangerouslySetInnerHTML:{__html:DMe(e)}}}const qMe="/runtime/tailwind.js",XQ="data-seeflow-tailwind-runtime";function OMe(){if(typeof document>"u"||document.querySelector(`script[${XQ}]`))return;const e=document.createElement("script");e.src=qMe,e.async=!0,e.setAttribute(XQ,"true"),document.head.appendChild(e)}const FMe=e=>typeof EventSource>"u"?null:new EventSource(e),S0=new Map;function HMe(e,t){let n=S0.get(e);if(!n){const o=FMe(`/api/events?demoId=${encodeURIComponent(e)}`);if(!o)return()=>{};const a={source:o,listeners:new Set,refCount:0};o.addEventListener("file:changed",i=>{let s;try{s=JSON.parse(i.data).path}catch{return}if(typeof s=="string")for(const c of a.listeners)c(s)}),S0.set(e,a),n=a}return n.listeners.add(t),n.refCount+=1,()=>{const r=S0.get(e);r&&(r.listeners.delete(t),r.refCount-=1,r.refCount===0&&(r.source.close(),S0.delete(e)))}}const Qu=new Map,YQ=(e,t)=>`${e}::${t}`;function BMe(e,t){const[n,r]=g.useState(()=>!e||!t?{kind:"loading"}:Qu.get(YQ(e,t))??{kind:"loading"});return g.useEffect(()=>{if(!e||!t){r({kind:"loading"});return}const o=YQ(e,t);let a=!1;const i=Qu.get(o);r(i||{kind:"loading"});const s=async()=>{try{const l=await fetch(Qie(e,t));if(a)return;if(l.status===404){const f={kind:"missing"};Qu.set(o,f),r(f);return}if(!l.ok){const f={kind:"error",message:`GET ${t} → ${l.status}`};Qu.set(o,f),r(f);return}const u=await l.text();if(a)return;const d={kind:"loaded",html:u};Qu.set(o,d),r(d)}catch(l){if(a)return;const u={kind:"error",message:l instanceof Error?l.message:String(l)};Qu.set(o,u),r(u)}};s();const c=HMe(e,l=>{l===t&&s()});return()=>{a=!0,c()}},[e,t]),n}const ose=g.createContext({custom:{}});function VMe({value:e,children:t}){return m.jsx(ose.Provider,{value:e,children:t})}function $Me(){return g.useContext(ose)}function Lu({name:e,as:t,size:n=16,fallback:r=Ofe,...o}){const a=$Me(),i=t??(e?a.custom[e]:void 0)??(e?J1[e]:void 0)??J1[r];return i?m.jsx(i,{size:n,...o}):null}function OO({message:e,variant:t="muted",className:n}){return m.jsx("div",{"data-testid":"placeholder-card","data-placeholder-variant":t,className:ce("sf:pointer-events-none sf:flex sf:h-full sf:w-full sf:select-none sf:items-center sf:justify-center sf:px-2 sf:text-center sf:text-xs",t==="destructive"?"sf:text-destructive":"sf:text-muted-foreground",n),children:e})}const QQ={width:320,height:200},UMe=80,WMe=40,L0="sf:opacity-0 sf:transition-opacity";function GMe({id:e,data:t,selected:n,isConnectable:r}){const{isResizing:o,onResizeStart:a,onResizeEvent:i,onResizeEnd:s}=Pd({onResize:v=>{var M;return(M=t.onResize)==null?void 0:M.call(t,e,v)},setResizing:t.setResizing}),c=t.autoSize??!0,l=o||!c,u={...t.backgroundColor!==void 0?{backgroundColor:ct(t.backgroundColor,"node").backgroundColor}:{},...t.borderColor!==void 0?{borderColor:ct(t.borderColor,"node").borderColor}:{},...t.borderSize!==void 0?{borderWidth:t.borderSize}:{},...t.borderStyle!==void 0?{borderStyle:t.borderStyle}:{},...t.cornerRadius!==void 0?{borderRadius:t.cornerRadius}:{},...t.fontSize!==void 0?{fontSize:`${t.fontSize}px`}:{},...ct(t.textColor,"text"),...l?{width:t.width,height:t.height}:{}};g.useEffect(()=>{OMe()},[]);const d=g.useRef(null),f=BMe(t.projectId,t.htmlPath),p=c&&f.kind==="loaded";let y;f.kind==="loaded"?y=l?m.jsx("div",{"data-testid":"html-node-content",className:"sf:h-full sf:w-full sf:overflow-auto",...ZQ(f.html)}):m.jsx("div",{ref:d,"data-testid":"html-node-content",className:"sf:inline-block",style:{maxWidth:800,maxHeight:600,overflow:"auto"},...ZQ(f.html)}):f.kind==="missing"?y=m.jsx(OO,{message:`Missing: ${t.htmlPath}`,variant:"destructive"}):f.kind==="error"?y=m.jsx(OO,{message:`Error: ${f.message}`,variant:"destructive"}):y=m.jsx(OO,{message:"Loading…"});const k=!l&&f.kind!=="loaded"?{width:QQ.width,height:QQ.height}:{},w={...u,...k};return m.jsxs("div",{className:ce("sf:group sf:relative sf:overflow-hidden",l?"sf:h-full sf:w-full":""),style:w,"data-testid":"html-node",children:[p?m.jsx(KMe,{nodeId:e,measureRef:d}):null,m.jsx(Ad,{visible:!!n&&!!t.onResize&&!t.locked,cornerVariant:"visible",minWidth:UMe,minHeight:WMe,onResizeStart:a,onResize:i,onResizeEnd:s}),t.locked?m.jsx(Ed,{}):null,n&&!t.locked&&!c&&!o&&typeof t.onFitToContent=="function"?m.jsx("button",{type:"button","data-testid":"html-node-fit-to-content",title:"Fit to content","aria-label":"Fit to content",className:"sf:absolute sf:top-1 sf:right-1 sf:z-10 sf:flex sf:h-5 sf:w-5 sf:cursor-pointer sf:items-center sf:justify-center sf:rounded sf:bg-background/80 sf:text-muted-foreground sf:opacity-0 sf:transition-opacity sf:hover:text-foreground sf:group-hover:opacity-100 sf:focus:opacity-100",onClick:v=>{var M;v.stopPropagation(),(M=t.onFitToContent)==null||M.call(t,e)},children:m.jsx(j1,{size:12,"aria-hidden":!0})}):null,m.jsx(ut,{type:"target",position:me.Top,id:"t",isConnectable:r,className:ce(L0,n&&"sf:opacity-100!")}),m.jsx(ut,{type:"target",position:me.Left,id:"l",isConnectable:r,className:ce(L0,n&&"sf:opacity-100!")}),y,m.jsx(ut,{type:"source",position:me.Right,id:"r",isConnectable:r,className:ce(L0,n&&"sf:opacity-100!")}),m.jsx(ut,{type:"source",position:me.Bottom,id:"b",isConnectable:r,className:ce(L0,n&&"sf:opacity-100!")}),t.name!==void 0&&t.name!==""?m.jsx("div",{"data-testid":"html-node-label",className:"sf:-bottom-5 sf:absolute sf:right-0 sf:left-0 sf:truncate sf:text-center sf:text-[11px] sf:text-muted-foreground",children:t.icon?m.jsxs("div",{className:"sf:flex sf:items-center sf:justify-center sf:gap-1",children:[m.jsx(Lu,{name:t.icon,size:12,"aria-hidden":!0}),m.jsx("span",{className:"truncate",children:t.name})]}):t.name}):null]})}function KMe({nodeId:e,measureRef:t}){const n=g8e();return g.useEffect(()=>{const r=t.current;if(r!==null)return RMe(r,150,()=>{n(e)})},[e,n,t]),null}function ZMe(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const XMe=g.memo(GMe,ZMe),JQ={width:200,height:150},YMe=40,QMe=40,I0="sf:opacity-0 sf:transition-opacity";function JMe({id:e,data:t,selected:n,isConnectable:r}){const{onResizeStart:o,onResizeEvent:a,onResizeEnd:i}=Pd({onResize:l=>{var u;return(u=t.onResize)==null?void 0:u.call(t,e,l)},setResizing:t.setResizing}),s=t.width!==void 0||t.height!==void 0,c={backgroundColor:t.backgroundColor!==void 0?ct(t.backgroundColor,"node").backgroundColor:ef,...t.borderColor!==void 0?{borderColor:ct(t.borderColor,"node").borderColor}:{},...t.borderWidth!==void 0?{borderWidth:t.borderWidth}:{},...t.borderStyle!==void 0?{borderStyle:t.borderStyle}:{},...t.cornerRadius!==void 0?{borderRadius:t.cornerRadius}:{},...s?{}:{width:JQ.width,height:JQ.height}};return m.jsxs("div",{className:ce("sf:group sf:relative sf:overflow-hidden",s?"sf:h-full sf:w-full":""),style:c,"data-testid":"image-node",children:[m.jsx(Ad,{visible:!!n&&!!t.onResize&&!t.locked,cornerVariant:"visible",minWidth:YMe,minHeight:QMe,onResizeStart:o,onResize:a,onResizeEnd:i}),t.locked?m.jsx(Ed,{}):null,m.jsx(ut,{type:"target",position:me.Top,id:"t",isConnectable:r,className:ce(I0,n&&"sf:opacity-100!")}),m.jsx(ut,{type:"target",position:me.Left,id:"l",isConnectable:r,className:ce(I0,n&&"sf:opacity-100!")}),t._uploading?m.jsx("div",{"data-testid":"image-node-placeholder","data-placeholder":"loading",className:"sf:flex sf:h-full sf:w-full sf:select-none sf:items-center sf:justify-center sf:text-xs sf:text-muted-foreground sf:pointer-events-none",children:"Loading…"}):t._uploadError?m.jsx("button",{type:"button","data-testid":"image-node-placeholder","data-placeholder":"failed",onClick:()=>{var l;return(l=t.onRetryUpload)==null?void 0:l.call(t,e)},title:t._uploadError,className:"sf:flex sf:h-full sf:w-full sf:cursor-pointer sf:select-none sf:items-center sf:justify-center sf:px-2 sf:text-center sf:text-xs sf:text-destructive",children:"Upload failed (click to retry)"}):m.jsx("img",{src:t.projectId?Qie(t.projectId,t.path):"",alt:t.alt??"",className:"sf:block sf:h-full sf:w-full sf:select-none sf:object-contain sf:pointer-events-none",draggable:!1}),m.jsx(ut,{type:"source",position:me.Right,id:"r",isConnectable:r,className:ce(I0,n&&"sf:opacity-100!")}),m.jsx(ut,{type:"source",position:me.Bottom,id:"b",isConnectable:r,className:ce(I0,n&&"sf:opacity-100!")})]})}function ebe(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const tbe=g.memo(JMe,ebe);function Le(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function eJ(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Co(...e){return t=>{let n=!1;const r=e.map(o=>{const a=eJ(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():eJ(e[o],null)}}}}function pt(...e){return g.useCallback(Co(...e),e)}function nbe(e,t){const n=g.createContext(t),r=a=>{const{children:i,...s}=a,c=g.useMemo(()=>s,Object.values(s));return m.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(a){const i=g.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,o]}function Kr(e,t=[]){let n=[];function r(a,i){const s=g.createContext(i),c=n.length;n=[...n,i];const l=d=>{var v;const{scope:f,children:p,...y}=d,k=((v=f==null?void 0:f[e])==null?void 0:v[c])||s,w=g.useMemo(()=>y,Object.values(y));return m.jsx(k.Provider,{value:w,children:p})};l.displayName=a+"Provider";function u(d,f){var k;const p=((k=f==null?void 0:f[e])==null?void 0:k[c])||s,y=g.useContext(p);if(y)return y;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${a}\``)}return[l,u]}const o=()=>{const a=n.map(i=>g.createContext(i));return function(s){const c=(s==null?void 0:s[e])||a;return g.useMemo(()=>({[`__scope${e}`]:{...s,[e]:c}}),[s,c])}};return o.scopeName=e,[r,rbe(o,...t)]}function rbe(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=r.reduce((s,{useScope:c,scopeName:l})=>{const d=c(a)[`__scope${l}`];return{...s,...d}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function ud(e){const t=obe(e),n=g.forwardRef((r,o)=>{const{children:a,...i}=r,s=g.Children.toArray(a),c=s.find(ibe);if(c){const l=c.props.children,u=s.map(d=>d===c?g.Children.count(l)>1?g.Children.only(null):g.isValidElement(l)?l.props.children:null:d);return m.jsx(t,{...i,ref:o,children:g.isValidElement(l)?g.cloneElement(l,void 0,u):null})}return m.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function obe(e){const t=g.forwardRef((n,r)=>{const{children:o,...a}=n;if(g.isValidElement(o)){const i=cbe(o),s=sbe(a,o.props);return o.type!==g.Fragment&&(s.ref=r?Co(r,i):i),g.cloneElement(o,s)}return g.Children.count(o)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ase=Symbol("radix.slottable");function abe(e){const t=({children:n})=>m.jsx(m.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=ase,t}function ibe(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ase}function sbe(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...s)=>{const c=a(...s);return o(...s),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function cbe(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var lbe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$e=lbe.reduce((e,t)=>{const n=ud(`Primitive.${t}`),r=g.forwardRef((o,a)=>{const{asChild:i,...s}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(c,{...s,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ise(e,t){e&&wd.flushSync(()=>e.dispatchEvent(t))}function So(e){const t=g.useRef(e);return g.useEffect(()=>{t.current=e}),g.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function ube(e,t=globalThis==null?void 0:globalThis.document){const n=So(e);g.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var dbe="DismissableLayer",OH="dismissableLayer.update",hbe="dismissableLayer.pointerDownOutside",fbe="dismissableLayer.focusOutside",tJ,sse=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),pf=g.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:s,...c}=e,l=g.useContext(sse),[u,d]=g.useState(null),f=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=g.useState({}),y=pt(t,L=>d(L)),k=Array.from(l.layers),[w]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),v=k.indexOf(w),M=u?k.indexOf(u):-1,x=l.layersWithOutsidePointerEventsDisabled.size>0,b=M>=v,S=mbe(L=>{const P=L.target,T=[...l.branches].some(_=>_.contains(P));!b||T||(o==null||o(L),i==null||i(L),L.defaultPrevented||s==null||s())},f),C=gbe(L=>{const P=L.target;[...l.branches].some(_=>_.contains(P))||(a==null||a(L),i==null||i(L),L.defaultPrevented||s==null||s())},f);return ube(L=>{M===l.layers.size-1&&(r==null||r(L),!L.defaultPrevented&&s&&(L.preventDefault(),s()))},f),g.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(tJ=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),nJ(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=tJ)}},[u,f,n,l]),g.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),nJ())},[u,l]),g.useEffect(()=>{const L=()=>p({});return document.addEventListener(OH,L),()=>document.removeEventListener(OH,L)},[]),m.jsx($e.div,{...c,ref:y,style:{pointerEvents:x?b?"auto":"none":void 0,...e.style},onFocusCapture:Le(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Le(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Le(e.onPointerDownCapture,S.onPointerDownCapture)})});pf.displayName=dbe;var pbe="DismissableLayerBranch",ybe=g.forwardRef((e,t)=>{const n=g.useContext(sse),r=g.useRef(null),o=pt(t,r);return g.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),m.jsx($e.div,{...e,ref:o})});ybe.displayName=pbe;function mbe(e,t=globalThis==null?void 0:globalThis.document){const n=So(e),r=g.useRef(!1),o=g.useRef(()=>{});return g.useEffect(()=>{const a=s=>{if(s.target&&!r.current){let c=function(){cse(hbe,n,l,{discrete:!0})};const l={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function gbe(e,t=globalThis==null?void 0:globalThis.document){const n=So(e),r=g.useRef(!1);return g.useEffect(()=>{const o=a=>{a.target&&!r.current&&cse(fbe,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function nJ(){const e=new CustomEvent(OH);document.dispatchEvent(e)}function cse(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?ise(o,a):o.dispatchEvent(a)}var FO=0;function a$(){g.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??rJ()),document.body.insertAdjacentElement("beforeend",e[1]??rJ()),FO++,()=>{FO===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),FO--}},[])}function rJ(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var HO="focusScope.autoFocusOnMount",BO="focusScope.autoFocusOnUnmount",oJ={bubbles:!1,cancelable:!0},kbe="FocusScope",mT=g.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[s,c]=g.useState(null),l=So(o),u=So(a),d=g.useRef(null),f=pt(t,k=>c(k)),p=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let k=function(x){if(p.paused||!s)return;const b=x.target;s.contains(b)?d.current=b:ja(d.current,{select:!0})},w=function(x){if(p.paused||!s)return;const b=x.relatedTarget;b!==null&&(s.contains(b)||ja(d.current,{select:!0}))},v=function(x){if(document.activeElement===document.body)for(const S of x)S.removedNodes.length>0&&ja(s)};document.addEventListener("focusin",k),document.addEventListener("focusout",w);const M=new MutationObserver(v);return s&&M.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",k),document.removeEventListener("focusout",w),M.disconnect()}}},[r,s,p.paused]),g.useEffect(()=>{if(s){iJ.add(p);const k=document.activeElement;if(!s.contains(k)){const v=new CustomEvent(HO,oJ);s.addEventListener(HO,l),s.dispatchEvent(v),v.defaultPrevented||(vbe(Cbe(lse(s)),{select:!0}),document.activeElement===k&&ja(s))}return()=>{s.removeEventListener(HO,l),setTimeout(()=>{const v=new CustomEvent(BO,oJ);s.addEventListener(BO,u),s.dispatchEvent(v),v.defaultPrevented||ja(k??document.body,{select:!0}),s.removeEventListener(BO,u),iJ.remove(p)},0)}}},[s,l,u,p]);const y=g.useCallback(k=>{if(!n&&!r||p.paused)return;const w=k.key==="Tab"&&!k.altKey&&!k.ctrlKey&&!k.metaKey,v=document.activeElement;if(w&&v){const M=k.currentTarget,[x,b]=xbe(M);x&&b?!k.shiftKey&&v===b?(k.preventDefault(),n&&ja(x,{select:!0})):k.shiftKey&&v===x&&(k.preventDefault(),n&&ja(b,{select:!0})):v===M&&k.preventDefault()}},[n,r,p.paused]);return m.jsx($e.div,{tabIndex:-1,...i,ref:f,onKeyDown:y})});mT.displayName=kbe;function vbe(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(ja(r,{select:t}),document.activeElement!==n)return}function xbe(e){const t=lse(e),n=aJ(t,e),r=aJ(t.reverse(),e);return[n,r]}function lse(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function aJ(e,t){for(const n of e)if(!wbe(n,{upTo:t}))return n}function wbe(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Mbe(e){return e instanceof HTMLInputElement&&"select"in e}function ja(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Mbe(e)&&t&&e.select()}}var iJ=bbe();function bbe(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=sJ(e,t),e.unshift(t)},remove(t){var n;e=sJ(e,t),(n=e[0])==null||n.resume()}}}function sJ(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Cbe(e){return e.filter(t=>t.tagName!=="A")}var si=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},Sbe=IB[" useId ".trim().toString()]||(()=>{}),Lbe=0;function yn(e){const[t,n]=g.useState(Sbe());return si(()=>{n(r=>r??String(Lbe++))},[e]),e||(t?`radix-${t}`:"")}const Ibe=["top","right","bottom","left"],ci=Math.min,Zn=Math.max,aR=Math.round,E0=Math.floor,Mo=e=>({x:e,y:e}),Ebe={left:"right",right:"left",bottom:"top",top:"bottom"};function FH(e,t,n){return Zn(e,ci(t,n))}function ra(e,t){return typeof e=="function"?e(t):e}function oa(e){return e.split("-")[0]}function _d(e){return e.split("-")[1]}function i$(e){return e==="x"?"y":"x"}function s$(e){return e==="y"?"height":"width"}function ko(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function c$(e){return i$(ko(e))}function Abe(e,t,n){n===void 0&&(n=!1);const r=_d(e),o=c$(e),a=s$(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=iR(i)),[i,iR(i)]}function Pbe(e){const t=iR(e);return[HH(e),t,HH(t)]}function HH(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const cJ=["left","right"],lJ=["right","left"],_be=["top","bottom"],Rbe=["bottom","top"];function Tbe(e,t,n){switch(e){case"top":case"bottom":return n?t?lJ:cJ:t?cJ:lJ;case"left":case"right":return t?_be:Rbe;default:return[]}}function jbe(e,t,n,r){const o=_d(e);let a=Tbe(oa(e),n==="start",r);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(HH)))),a}function iR(e){const t=oa(e);return Ebe[t]+e.slice(t.length)}function Nbe(e){return{top:0,right:0,bottom:0,left:0,...e}}function use(e){return typeof e!="number"?Nbe(e):{top:e,right:e,bottom:e,left:e}}function sR(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function uJ(e,t,n){let{reference:r,floating:o}=e;const a=ko(t),i=c$(t),s=s$(i),c=oa(t),l=a==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,f=r[s]/2-o[s]/2;let p;switch(c){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:d};break;case"left":p={x:r.x-o.width,y:d};break;default:p={x:r.x,y:r.y}}switch(_d(t)){case"start":p[i]-=f*(n&&l?-1:1);break;case"end":p[i]+=f*(n&&l?-1:1);break}return p}async function zbe(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:a,rects:i,elements:s,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=ra(t,e),y=use(p),w=s[f?d==="floating"?"reference":"floating":d],v=sR(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(w)))==null||n?w:w.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:l,rootBoundary:u,strategy:c})),M=d==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,x=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),b=await(a.isElement==null?void 0:a.isElement(x))?await(a.getScale==null?void 0:a.getScale(x))||{x:1,y:1}:{x:1,y:1},S=sR(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:M,offsetParent:x,strategy:c}):M);return{top:(v.top-S.top+y.top)/b.y,bottom:(S.bottom-v.bottom+y.bottom)/b.y,left:(v.left-S.left+y.left)/b.x,right:(S.right-v.right+y.right)/b.x}}const Dbe=50,qbe=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:i}=n,s=i.detectOverflow?i:{...i,detectOverflow:zbe},c=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=uJ(l,r,c),f=r,p=0;const y={};for(let k=0;k<a.length;k++){const w=a[k];if(!w)continue;const{name:v,fn:M}=w,{x,y:b,data:S,reset:C}=await M({x:u,y:d,initialPlacement:r,placement:f,strategy:o,middlewareData:y,rects:l,platform:s,elements:{reference:e,floating:t}});u=x??u,d=b??d,y[v]={...y[v],...S},C&&p<Dbe&&(p++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(l=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:u,y:d}=uJ(l,f,c)),k=-1)}return{x:u,y:d,placement:f,strategy:o,middlewareData:y}},Obe=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:a,platform:i,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=ra(e,t)||{};if(l==null)return{};const d=use(u),f={x:n,y:r},p=c$(o),y=s$(p),k=await i.getDimensions(l),w=p==="y",v=w?"top":"left",M=w?"bottom":"right",x=w?"clientHeight":"clientWidth",b=a.reference[y]+a.reference[p]-f[p]-a.floating[y],S=f[p]-a.reference[p],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l));let L=C?C[x]:0;(!L||!await(i.isElement==null?void 0:i.isElement(C)))&&(L=s.floating[x]||a.floating[y]);const P=b/2-S/2,T=L/2-k[y]/2-1,_=ci(d[v],T),A=ci(d[M],T),I=_,V=L-k[y]-A,j=L/2-k[y]/2+P,H=FH(I,j,V),O=!c.arrow&&_d(o)!=null&&j!==H&&a.reference[y]/2-(j<I?_:A)-k[y]/2<0,U=O?j<I?j-I:j-V:0;return{[p]:f[p]+U,data:{[p]:H,centerOffset:j-H-U,...O&&{alignmentOffset:U}},reset:O}}}),Fbe=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:a,rects:i,initialPlacement:s,platform:c,elements:l}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:k=!0,...w}=ra(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const v=oa(o),M=ko(s),x=oa(s)===s,b=await(c.isRTL==null?void 0:c.isRTL(l.floating)),S=f||(x||!k?[iR(s)]:Pbe(s)),C=y!=="none";!f&&C&&S.push(...jbe(s,k,y,b));const L=[s,...S],P=await c.detectOverflow(t,w),T=[];let _=((r=a.flip)==null?void 0:r.overflows)||[];if(u&&T.push(P[v]),d){const j=Abe(o,i,b);T.push(P[j[0]],P[j[1]])}if(_=[..._,{placement:o,overflows:T}],!T.every(j=>j<=0)){var A,I;const j=(((A=a.flip)==null?void 0:A.index)||0)+1,H=L[j];if(H&&(!(d==="alignment"?M!==ko(H):!1)||_.every(z=>ko(z.placement)===M?z.overflows[0]>0:!0)))return{data:{index:j,overflows:_},reset:{placement:H}};let O=(I=_.filter(U=>U.overflows[0]<=0).sort((U,z)=>U.overflows[1]-z.overflows[1])[0])==null?void 0:I.placement;if(!O)switch(p){case"bestFit":{var V;const U=(V=_.filter(z=>{if(C){const N=ko(z.placement);return N===M||N==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(N=>N>0).reduce((N,E)=>N+E,0)]).sort((z,N)=>z[1]-N[1])[0])==null?void 0:V[0];U&&(O=U);break}case"initialPlacement":O=s;break}if(o!==O)return{reset:{placement:O}}}return{}}}};function dJ(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function hJ(e){return Ibe.some(t=>e[t]>=0)}const Hbe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...a}=ra(e,t);switch(o){case"referenceHidden":{const i=await r.detectOverflow(t,{...a,elementContext:"reference"}),s=dJ(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:hJ(s)}}}case"escaped":{const i=await r.detectOverflow(t,{...a,altBoundary:!0}),s=dJ(i,n.floating);return{data:{escapedOffsets:s,escaped:hJ(s)}}}default:return{}}}}},dse=new Set(["left","top"]);async function Bbe(e,t){const{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=oa(n),s=_d(n),c=ko(n)==="y",l=dse.has(i)?-1:1,u=a&&c?-1:1,d=ra(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:y}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof y=="number"&&(p=s==="end"?y*-1:y),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}const Vbe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:a,placement:i,middlewareData:s}=t,c=await Bbe(t,e);return i===((n=s.offset)==null?void 0:n.placement)&&(r=s.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:a+c.y,data:{...c,placement:i}}}}},$be=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:a}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:c={fn:v=>{let{x:M,y:x}=v;return{x:M,y:x}}},...l}=ra(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=ko(oa(o)),p=i$(f);let y=u[p],k=u[f];if(i){const v=p==="y"?"top":"left",M=p==="y"?"bottom":"right",x=y+d[v],b=y-d[M];y=FH(x,y,b)}if(s){const v=f==="y"?"top":"left",M=f==="y"?"bottom":"right",x=k+d[v],b=k-d[M];k=FH(x,k,b)}const w=c.fn({...t,[p]:y,[f]:k});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[p]:i,[f]:s}}}}}},Ube=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:a,middlewareData:i}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=ra(e,t),u={x:n,y:r},d=ko(o),f=i$(d);let p=u[f],y=u[d];const k=ra(s,t),w=typeof k=="number"?{mainAxis:k,crossAxis:0}:{mainAxis:0,crossAxis:0,...k};if(c){const x=f==="y"?"height":"width",b=a.reference[f]-a.floating[x]+w.mainAxis,S=a.reference[f]+a.reference[x]-w.mainAxis;p<b?p=b:p>S&&(p=S)}if(l){var v,M;const x=f==="y"?"width":"height",b=dse.has(oa(o)),S=a.reference[d]-a.floating[x]+(b&&((v=i.offset)==null?void 0:v[d])||0)+(b?0:w.crossAxis),C=a.reference[d]+a.reference[x]+(b?0:((M=i.offset)==null?void 0:M[d])||0)-(b?w.crossAxis:0);y<S?y=S:y>C&&(y=C)}return{[f]:p,[d]:y}}}},Wbe=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:a,platform:i,elements:s}=t,{apply:c=()=>{},...l}=ra(e,t),u=await i.detectOverflow(t,l),d=oa(o),f=_d(o),p=ko(o)==="y",{width:y,height:k}=a.floating;let w,v;d==="top"||d==="bottom"?(w=d,v=f===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(v=d,w=f==="end"?"top":"bottom");const M=k-u.top-u.bottom,x=y-u.left-u.right,b=ci(k-u[w],M),S=ci(y-u[v],x),C=!t.middlewareData.shift;let L=b,P=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(P=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(L=M),C&&!f){const _=Zn(u.left,0),A=Zn(u.right,0),I=Zn(u.top,0),V=Zn(u.bottom,0);p?P=y-2*(_!==0||A!==0?_+A:Zn(u.left,u.right)):L=k-2*(I!==0||V!==0?I+V:Zn(u.top,u.bottom))}await c({...t,availableWidth:P,availableHeight:L});const T=await i.getDimensions(s.floating);return y!==T.width||k!==T.height?{reset:{rects:!0}}:{}}}};function gT(){return typeof window<"u"}function Rd(e){return hse(e)?(e.nodeName||"").toLowerCase():"#document"}function er(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Eo(e){var t;return(t=(hse(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function hse(e){return gT()?e instanceof Node||e instanceof er(e).Node:!1}function Vr(e){return gT()?e instanceof Element||e instanceof er(e).Element:!1}function la(e){return gT()?e instanceof HTMLElement||e instanceof er(e).HTMLElement:!1}function fJ(e){return!gT()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof er(e).ShadowRoot}function yf(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=$r(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function Gbe(e){return/^(table|td|th)$/.test(Rd(e))}function kT(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Kbe=/transform|translate|scale|rotate|perspective|filter/,Zbe=/paint|layout|strict|content/,Pi=e=>!!e&&e!=="none";let VO;function l$(e){const t=Vr(e)?$r(e):e;return Pi(t.transform)||Pi(t.translate)||Pi(t.scale)||Pi(t.rotate)||Pi(t.perspective)||!u$()&&(Pi(t.backdropFilter)||Pi(t.filter))||Kbe.test(t.willChange||"")||Zbe.test(t.contain||"")}function Xbe(e){let t=li(e);for(;la(t)&&!dd(t);){if(l$(t))return t;if(kT(t))return null;t=li(t)}return null}function u$(){return VO==null&&(VO=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),VO}function dd(e){return/^(html|body|#document)$/.test(Rd(e))}function $r(e){return er(e).getComputedStyle(e)}function vT(e){return Vr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function li(e){if(Rd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||fJ(e)&&e.host||Eo(e);return fJ(t)?t.host:t}function fse(e){const t=li(e);return dd(t)?e.ownerDocument?e.ownerDocument.body:e.body:la(t)&&yf(t)?t:fse(t)}function V2(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=fse(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),i=er(o);if(a){const s=BH(i);return t.concat(i,i.visualViewport||[],yf(o)?o:[],s&&n?V2(s):[])}else return t.concat(o,V2(o,[],n))}function BH(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function pse(e){const t=$r(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=la(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:r,s=aR(n)!==a||aR(r)!==i;return s&&(n=a,r=i),{width:n,height:r,$:s}}function d$(e){return Vr(e)?e:e.contextElement}function V1(e){const t=d$(e);if(!la(t))return Mo(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:a}=pse(t);let i=(a?aR(n.width):n.width)/r,s=(a?aR(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}const Ybe=Mo(0);function yse(e){const t=er(e);return!u$()||!t.visualViewport?Ybe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Qbe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==er(e)?!1:t}function Iu(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=d$(e);let i=Mo(1);t&&(r?Vr(r)&&(i=V1(r)):i=V1(e));const s=Qbe(a,n,r)?yse(a):Mo(0);let c=(o.left+s.x)/i.x,l=(o.top+s.y)/i.y,u=o.width/i.x,d=o.height/i.y;if(a){const f=er(a),p=r&&Vr(r)?er(r):r;let y=f,k=BH(y);for(;k&&r&&p!==y;){const w=V1(k),v=k.getBoundingClientRect(),M=$r(k),x=v.left+(k.clientLeft+parseFloat(M.paddingLeft))*w.x,b=v.top+(k.clientTop+parseFloat(M.paddingTop))*w.y;c*=w.x,l*=w.y,u*=w.x,d*=w.y,c+=x,l+=b,y=er(k),k=BH(y)}}return sR({width:u,height:d,x:c,y:l})}function xT(e,t){const n=vT(e).scrollLeft;return t?t.left+n:Iu(Eo(e)).left+n}function mse(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-xT(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Jbe(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const a=o==="fixed",i=Eo(r),s=t?kT(t.floating):!1;if(r===i||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Mo(1);const u=Mo(0),d=la(r);if((d||!d&&!a)&&((Rd(r)!=="body"||yf(i))&&(c=vT(r)),d)){const p=Iu(r);l=V1(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const f=i&&!d&&!a?mse(i,c):Mo(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function e7e(e){return Array.from(e.getClientRects())}function t7e(e){const t=Eo(e),n=vT(e),r=e.ownerDocument.body,o=Zn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Zn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+xT(e);const s=-n.scrollTop;return $r(r).direction==="rtl"&&(i+=Zn(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:i,y:s}}const pJ=25;function n7e(e,t){const n=er(e),r=Eo(e),o=n.visualViewport;let a=r.clientWidth,i=r.clientHeight,s=0,c=0;if(o){a=o.width,i=o.height;const u=u$();(!u||u&&t==="fixed")&&(s=o.offsetLeft,c=o.offsetTop)}const l=xT(r);if(l<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,y=Math.abs(r.clientWidth-d.clientWidth-p);y<=pJ&&(a-=y)}else l<=pJ&&(a+=l);return{width:a,height:i,x:s,y:c}}function r7e(e,t){const n=Iu(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=la(e)?V1(e):Mo(1),i=e.clientWidth*a.x,s=e.clientHeight*a.y,c=o*a.x,l=r*a.y;return{width:i,height:s,x:c,y:l}}function yJ(e,t,n){let r;if(t==="viewport")r=n7e(e,n);else if(t==="document")r=t7e(Eo(e));else if(Vr(t))r=r7e(t,n);else{const o=yse(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return sR(r)}function gse(e,t){const n=li(e);return n===t||!Vr(n)||dd(n)?!1:$r(n).position==="fixed"||gse(n,t)}function o7e(e,t){const n=t.get(e);if(n)return n;let r=V2(e,[],!1).filter(s=>Vr(s)&&Rd(s)!=="body"),o=null;const a=$r(e).position==="fixed";let i=a?li(e):e;for(;Vr(i)&&!dd(i);){const s=$r(i),c=l$(i);!c&&s.position==="fixed"&&(o=null),(a?!c&&!o:!c&&s.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||yf(i)&&!c&&gse(e,i))?r=r.filter(u=>u!==i):o=s,i=li(i)}return t.set(e,r),r}function a7e(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?kT(t)?[]:o7e(t,this._c):[].concat(n),r],s=yJ(t,i[0],o);let c=s.top,l=s.right,u=s.bottom,d=s.left;for(let f=1;f<i.length;f++){const p=yJ(t,i[f],o);c=Zn(p.top,c),l=ci(p.right,l),u=ci(p.bottom,u),d=Zn(p.left,d)}return{width:l-d,height:u-c,x:d,y:c}}function i7e(e){const{width:t,height:n}=pse(e);return{width:t,height:n}}function s7e(e,t,n){const r=la(t),o=Eo(t),a=n==="fixed",i=Iu(e,!0,a,t);let s={scrollLeft:0,scrollTop:0};const c=Mo(0);function l(){c.x=xT(o)}if(r||!r&&!a)if((Rd(t)!=="body"||yf(o))&&(s=vT(t)),r){const p=Iu(t,!0,a,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}else o&&l();a&&!r&&o&&l();const u=o&&!r&&!a?mse(o,s):Mo(0),d=i.left+s.scrollLeft-c.x-u.x,f=i.top+s.scrollTop-c.y-u.y;return{x:d,y:f,width:i.width,height:i.height}}function $O(e){return $r(e).position==="static"}function mJ(e,t){if(!la(e)||$r(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Eo(e)===n&&(n=n.ownerDocument.body),n}function kse(e,t){const n=er(e);if(kT(e))return n;if(!la(e)){let o=li(e);for(;o&&!dd(o);){if(Vr(o)&&!$O(o))return o;o=li(o)}return n}let r=mJ(e,t);for(;r&&Gbe(r)&&$O(r);)r=mJ(r,t);return r&&dd(r)&&$O(r)&&!l$(r)?n:r||Xbe(e)||n}const c7e=async function(e){const t=this.getOffsetParent||kse,n=this.getDimensions,r=await n(e.floating);return{reference:s7e(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function l7e(e){return $r(e).direction==="rtl"}const u7e={convertOffsetParentRelativeRectToViewportRelativeRect:Jbe,getDocumentElement:Eo,getClippingRect:a7e,getOffsetParent:kse,getElementRects:c7e,getClientRects:e7e,getDimensions:i7e,getScale:V1,isElement:Vr,isRTL:l7e};function vse(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function d7e(e,t){let n=null,r;const o=Eo(e);function a(){var s;clearTimeout(r),(s=n)==null||s.disconnect(),n=null}function i(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();const l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;const y=E0(d),k=E0(o.clientWidth-(u+f)),w=E0(o.clientHeight-(d+p)),v=E0(u),x={rootMargin:-y+"px "+-k+"px "+-w+"px "+-v+"px",threshold:Zn(0,ci(1,c))||1};let b=!0;function S(C){const L=C[0].intersectionRatio;if(L!==c){if(!b)return i();L?i(!1,L):r=setTimeout(()=>{i(!1,1e-7)},1e3)}L===1&&!vse(l,e.getBoundingClientRect())&&i(),b=!1}try{n=new IntersectionObserver(S,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,x)}n.observe(e)}return i(!0),a}function h7e(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,l=d$(e),u=o||a?[...l?V2(l):[],...t?V2(t):[]]:[];u.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),a&&v.addEventListener("resize",n)});const d=l&&s?d7e(l,n):null;let f=-1,p=null;i&&(p=new ResizeObserver(v=>{let[M]=v;M&&M.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var x;(x=p)==null||x.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let y,k=c?Iu(e):null;c&&w();function w(){const v=Iu(e);k&&!vse(k,v)&&n(),k=v,y=requestAnimationFrame(w)}return n(),()=>{var v;u.forEach(M=>{o&&M.removeEventListener("scroll",n),a&&M.removeEventListener("resize",n)}),d==null||d(),(v=p)==null||v.disconnect(),p=null,c&&cancelAnimationFrame(y)}}const f7e=Vbe,p7e=$be,y7e=Fbe,m7e=Wbe,g7e=Hbe,gJ=Obe,k7e=Ube,v7e=(e,t,n)=>{const r=new Map,o={platform:u7e,...n},a={...o.platform,_c:r};return qbe(e,t,{...o,platform:a})};var x7e=typeof document<"u",w7e=function(){},f_=x7e?g.useLayoutEffect:w7e;function cR(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!cR(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const a=o[r];if(!(a==="_owner"&&e.$$typeof)&&!cR(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function xse(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function kJ(e,t){const n=xse(e);return Math.round(t*n)/n}function UO(e){const t=g.useRef(e);return f_(()=>{t.current=e}),t}function M7e(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:a,floating:i}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=g.useState(r);cR(f,r)||p(r);const[y,k]=g.useState(null),[w,v]=g.useState(null),M=g.useCallback(z=>{z!==C.current&&(C.current=z,k(z))},[]),x=g.useCallback(z=>{z!==L.current&&(L.current=z,v(z))},[]),b=a||y,S=i||w,C=g.useRef(null),L=g.useRef(null),P=g.useRef(u),T=c!=null,_=UO(c),A=UO(o),I=UO(l),V=g.useCallback(()=>{if(!C.current||!L.current)return;const z={placement:t,strategy:n,middleware:f};A.current&&(z.platform=A.current),v7e(C.current,L.current,z).then(N=>{const E={...N,isPositioned:I.current!==!1};j.current&&!cR(P.current,E)&&(P.current=E,wd.flushSync(()=>{d(E)}))})},[f,t,n,A,I]);f_(()=>{l===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,d(z=>({...z,isPositioned:!1})))},[l]);const j=g.useRef(!1);f_(()=>(j.current=!0,()=>{j.current=!1}),[]),f_(()=>{if(b&&(C.current=b),S&&(L.current=S),b&&S){if(_.current)return _.current(b,S,V);V()}},[b,S,V,_,T]);const H=g.useMemo(()=>({reference:C,floating:L,setReference:M,setFloating:x}),[M,x]),O=g.useMemo(()=>({reference:b,floating:S}),[b,S]),U=g.useMemo(()=>{const z={position:n,left:0,top:0};if(!O.floating)return z;const N=kJ(O.floating,u.x),E=kJ(O.floating,u.y);return s?{...z,transform:"translate("+N+"px, "+E+"px)",...xse(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:N,top:E}},[n,s,O.floating,u.x,u.y]);return g.useMemo(()=>({...u,update:V,refs:H,elements:O,floatingStyles:U}),[u,V,H,O,U])}const b7e=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?gJ({element:r.current,padding:o}).fn(n):{}:r?gJ({element:r,padding:o}).fn(n):{}}}},C7e=(e,t)=>{const n=f7e(e);return{name:n.name,fn:n.fn,options:[e,t]}},S7e=(e,t)=>{const n=p7e(e);return{name:n.name,fn:n.fn,options:[e,t]}},L7e=(e,t)=>({fn:k7e(e).fn,options:[e,t]}),I7e=(e,t)=>{const n=y7e(e);return{name:n.name,fn:n.fn,options:[e,t]}},E7e=(e,t)=>{const n=m7e(e);return{name:n.name,fn:n.fn,options:[e,t]}},A7e=(e,t)=>{const n=g7e(e);return{name:n.name,fn:n.fn,options:[e,t]}},P7e=(e,t)=>{const n=b7e(e);return{name:n.name,fn:n.fn,options:[e,t]}};var _7e="Arrow",wse=g.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...a}=e;return m.jsx($e.svg,{...a,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});wse.displayName=_7e;var R7e=wse;function Mse(e){const[t,n]=g.useState(void 0);return si(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let i,s;if("borderBoxSize"in a){const c=a.borderBoxSize,l=Array.isArray(c)?c[0]:c;i=l.inlineSize,s=l.blockSize}else i=e.offsetWidth,s=e.offsetHeight;n({width:i,height:s})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var h$="Popper",[bse,Td]=Kr(h$),[T7e,Cse]=bse(h$),Sse=e=>{const{__scopePopper:t,children:n}=e,[r,o]=g.useState(null);return m.jsx(T7e,{scope:t,anchor:r,onAnchorChange:o,children:n})};Sse.displayName=h$;var Lse="PopperAnchor",Ise=g.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=Cse(Lse,n),i=g.useRef(null),s=pt(t,i),c=g.useRef(null);return g.useEffect(()=>{const l=c.current;c.current=(r==null?void 0:r.current)||i.current,l!==c.current&&a.onAnchorChange(c.current)}),r?null:m.jsx($e.div,{...o,ref:s})});Ise.displayName=Lse;var f$="PopperContent",[j7e,N7e]=bse(f$),Ese=g.forwardRef((e,t)=>{var oe,ee,ae,ve,Se,be;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:y,...k}=e,w=Cse(f$,n),[v,M]=g.useState(null),x=pt(t,we=>M(we)),[b,S]=g.useState(null),C=Mse(b),L=(C==null?void 0:C.width)??0,P=(C==null?void 0:C.height)??0,T=r+(a!=="center"?"-"+a:""),_=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},A=Array.isArray(l)?l:[l],I=A.length>0,V={padding:_,boundary:A.filter(D7e),altBoundary:I},{refs:j,floatingStyles:H,placement:O,isPositioned:U,middlewareData:z}=M7e({strategy:"fixed",placement:T,whileElementsMounted:(...we)=>h7e(...we,{animationFrame:p==="always"}),elements:{reference:w.anchor},middleware:[C7e({mainAxis:o+P,alignmentAxis:i}),c&&S7e({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?L7e():void 0,...V}),c&&I7e({...V}),E7e({...V,apply:({elements:we,rects:te,availableWidth:ie,availableHeight:Te})=>{const{width:Ae,height:at}=te.reference,Qe=we.floating.style;Qe.setProperty("--radix-popper-available-width",`${ie}px`),Qe.setProperty("--radix-popper-available-height",`${Te}px`),Qe.setProperty("--radix-popper-anchor-width",`${Ae}px`),Qe.setProperty("--radix-popper-anchor-height",`${at}px`)}}),b&&P7e({element:b,padding:s}),q7e({arrowWidth:L,arrowHeight:P}),f&&A7e({strategy:"referenceHidden",...V})]}),[N,E]=_se(O),W=So(y);si(()=>{U&&(W==null||W())},[U,W]);const q=(oe=z.arrow)==null?void 0:oe.x,R=(ee=z.arrow)==null?void 0:ee.y,G=((ae=z.arrow)==null?void 0:ae.centerOffset)!==0,[X,Y]=g.useState();return si(()=>{v&&Y(window.getComputedStyle(v).zIndex)},[v]),m.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:U?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:X,"--radix-popper-transform-origin":[(ve=z.transformOrigin)==null?void 0:ve.x,(Se=z.transformOrigin)==null?void 0:Se.y].join(" "),...((be=z.hide)==null?void 0:be.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(j7e,{scope:n,placedSide:N,onArrowChange:S,arrowX:q,arrowY:R,shouldHideArrow:G,children:m.jsx($e.div,{"data-side":N,"data-align":E,...k,ref:x,style:{...k.style,animation:U?void 0:"none"}})})})});Ese.displayName=f$;var Ase="PopperArrow",z7e={top:"bottom",right:"left",bottom:"top",left:"right"},Pse=g.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=N7e(Ase,r),i=z7e[a.placedSide];return m.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:m.jsx(R7e,{...o,ref:n,style:{...o.style,display:"block"}})})});Pse.displayName=Ase;function D7e(e){return e!==null}var q7e=e=>({name:"transformOrigin",options:e,fn(t){var w,v,M;const{placement:n,rects:r,middlewareData:o}=t,i=((w=o.arrow)==null?void 0:w.centerOffset)!==0,s=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[l,u]=_se(n),d={start:"0%",center:"50%",end:"100%"}[u],f=(((v=o.arrow)==null?void 0:v.x)??0)+s/2,p=(((M=o.arrow)==null?void 0:M.y)??0)+c/2;let y="",k="";return l==="bottom"?(y=i?d:`${f}px`,k=`${-c}px`):l==="top"?(y=i?d:`${f}px`,k=`${r.floating.height+c}px`):l==="right"?(y=`${-c}px`,k=i?d:`${p}px`):l==="left"&&(y=`${r.floating.width+c}px`,k=i?d:`${p}px`),{data:{x:y,y:k}}}});function _se(e){const[t,n="center"]=e.split("-");return[t,n]}var p$=Sse,wT=Ise,y$=Ese,m$=Pse,O7e="Portal",mf=g.forwardRef((e,t)=>{var s;const{container:n,...r}=e,[o,a]=g.useState(!1);si(()=>a(!0),[]);const i=n||o&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return i?Cfe.createPortal(m.jsx($e.div,{...r,ref:t}),i):null});mf.displayName=O7e;function F7e(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}var ir=e=>{const{present:t,children:n}=e,r=H7e(t),o=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),a=pt(r.ref,B7e(o));return typeof n=="function"||r.isPresent?g.cloneElement(o,{ref:a}):null};ir.displayName="Presence";function H7e(e){const[t,n]=g.useState(),r=g.useRef(null),o=g.useRef(e),a=g.useRef("none"),i=e?"mounted":"unmounted",[s,c]=F7e(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const l=A0(r.current);a.current=s==="mounted"?l:"none"},[s]),si(()=>{const l=r.current,u=o.current;if(u!==e){const f=a.current,p=A0(l);e?c("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(u&&f!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),si(()=>{if(t){let l;const u=t.ownerDocument.defaultView??window,d=p=>{const k=A0(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&k&&(c("ANIMATION_END"),!o.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",l=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},f=p=>{p.target===t&&(a.current=A0(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(l),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:g.useCallback(l=>{r.current=l?getComputedStyle(l):null,n(l)},[])}}function A0(e){return(e==null?void 0:e.animationName)||"none"}function B7e(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var V7e=IB[" useInsertionEffect ".trim().toString()]||si;function Ou({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,i]=$7e({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:o;{const u=g.useRef(e!==void 0);g.useEffect(()=>{const d=u.current;d!==s&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=s},[s,r])}const l=g.useCallback(u=>{var d;if(s){const f=U7e(u)?u(e):u;f!==e&&((d=i.current)==null||d.call(i,f))}else a(u)},[s,e,a,i]);return[c,l]}function $7e({defaultProp:e,onChange:t}){const[n,r]=g.useState(e),o=g.useRef(n),a=g.useRef(t);return V7e(()=>{a.current=t},[t]),g.useEffect(()=>{var i;o.current!==n&&((i=a.current)==null||i.call(a,n),o.current=n)},[n,o]),[n,r,a]}function U7e(e){return typeof e=="function"}var W7e=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ju=new WeakMap,P0=new WeakMap,_0={},WO=0,Rse=function(e){return e&&(e.host||Rse(e.parentNode))},G7e=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Rse(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},K7e=function(e,t,n,r){var o=G7e(t,Array.isArray(e)?e:[e]);_0[n]||(_0[n]=new WeakMap);var a=_0[n],i=[],s=new Set,c=new Set(o),l=function(d){!d||s.has(d)||(s.add(d),l(d.parentNode))};o.forEach(l);var u=function(d){!d||c.has(d)||Array.prototype.forEach.call(d.children,function(f){if(s.has(f))u(f);else try{var p=f.getAttribute(r),y=p!==null&&p!=="false",k=(Ju.get(f)||0)+1,w=(a.get(f)||0)+1;Ju.set(f,k),a.set(f,w),i.push(f),k===1&&y&&P0.set(f,!0),w===1&&f.setAttribute(n,"true"),y||f.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",f,v)}})};return u(t),s.clear(),WO++,function(){i.forEach(function(d){var f=Ju.get(d)-1,p=a.get(d)-1;Ju.set(d,f),a.set(d,p),f||(P0.has(d)||d.removeAttribute(r),P0.delete(d)),p||d.removeAttribute(n)}),WO--,WO||(Ju=new WeakMap,Ju=new WeakMap,P0=new WeakMap,_0={})}},g$=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=W7e(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),K7e(r,o,n,"aria-hidden")):function(){return null}},yo=function(){return yo=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},yo.apply(this,arguments)};function Tse(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Z7e(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var p_="right-scroll-bar-position",y_="width-before-scroll-bar",X7e="with-scroll-bars-hidden",Y7e="--removed-body-scroll-bar-size";function GO(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Q7e(e,t){var n=g.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var J7e=typeof window<"u"?g.useLayoutEffect:g.useEffect,vJ=new WeakMap;function e9e(e,t){var n=Q7e(null,function(r){return e.forEach(function(o){return GO(o,r)})});return J7e(function(){var r=vJ.get(n);if(r){var o=new Set(r),a=new Set(e),i=n.current;o.forEach(function(s){a.has(s)||GO(s,null)}),a.forEach(function(s){o.has(s)||GO(s,i)})}vJ.set(n,e)},[e]),n}function t9e(e){return e}function n9e(e,t){t===void 0&&(t=t9e);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(s){return s!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(s){return a(s)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var s=n;n=[],s.forEach(a),i=n}var c=function(){var u=i;i=[],u.forEach(a)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(u){i.push(u),l()},filter:function(u){return i=i.filter(u),n}}}};return o}function r9e(e){e===void 0&&(e={});var t=n9e(null);return t.options=yo({async:!0,ssr:!1},e),t}var jse=function(e){var t=e.sideCar,n=Tse(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return g.createElement(r,yo({},n))};jse.isSideCarExport=!0;function o9e(e,t){return e.useMedium(t),jse}var Nse=r9e(),KO=function(){},MT=g.forwardRef(function(e,t){var n=g.useRef(null),r=g.useState({onScrollCapture:KO,onWheelCapture:KO,onTouchMoveCapture:KO}),o=r[0],a=r[1],i=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,y=e.noIsolation,k=e.inert,w=e.allowPinchZoom,v=e.as,M=v===void 0?"div":v,x=e.gapMode,b=Tse(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=f,C=e9e([n,t]),L=yo(yo({},b),o);return g.createElement(g.Fragment,null,u&&g.createElement(S,{sideCar:Nse,removeScrollBar:l,shards:d,noRelative:p,noIsolation:y,inert:k,setCallbacks:a,allowPinchZoom:!!w,lockRef:n,gapMode:x}),i?g.cloneElement(g.Children.only(s),yo(yo({},L),{ref:C})):g.createElement(M,yo({},L,{className:c,ref:C}),s))});MT.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};MT.classNames={fullWidth:y_,zeroRight:p_};var a9e=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function i9e(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=a9e();return t&&e.setAttribute("nonce",t),e}function s9e(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function c9e(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var l9e=function(){var e=0,t=null;return{add:function(n){e==0&&(t=i9e())&&(s9e(t,n),c9e(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},u9e=function(){var e=l9e();return function(t,n){g.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},zse=function(){var e=u9e(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},d9e={left:0,top:0,right:0,gap:0},ZO=function(e){return parseInt(e||"",10)||0},h9e=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[ZO(n),ZO(r),ZO(o)]},f9e=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return d9e;var t=h9e(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},p9e=zse(),$1="data-scroll-locked",y9e=function(e,t,n,r){var o=e.left,a=e.top,i=e.right,s=e.gap;return n===void 0&&(n="margin"),`
|
|
7763
|
+
`);return}A.preventDefault(),M.current=!0,C();return}A.key==="Escape"&&(A.preventDefault(),M.current=!0,L())},T=A=>{A.preventDefault();const I=A.clipboardData.getData("text/plain");document.execCommand("insertText",!1,I)},_=()=>{if(M.current){M.current=!1;return}C()};return m.jsx("div",{ref:d,"data-testid":"inline-edit-input","data-field":i,"data-placeholder":l,role:"textbox",tabIndex:0,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:S,onKeyDown:P,onPaste:T,onBlur:_,onMouseDown:A=>A.stopPropagation(),onClick:A=>A.stopPropagation(),onDoubleClick:A=>A.stopPropagation(),style:c,className:ce("nodrag nopan nowheel block w-full bg-transparent p-0 text-inherit outline-none","sf:whitespace-pre-wrap sf:wrap-break-word",y&&l?"inline-edit-empty":"",f?"inline-edit-shake":"",s)})}function Ed({className:e}){return m.jsx("span",{"data-testid":"node-lock-badge","aria-hidden":"true",className:ce("sf:absolute sf:-top-2 sf:-right-2 sf:z-10 sf:inline-flex sf:h-4 sf:w-4 sf:items-center sf:justify-center sf:rounded-sm sf:bg-background/90 sf:text-muted-foreground sf:shadow-sm sf:ring-1 sf:ring-border",e),children:m.jsx(Wh,{className:"sf:h-2.5 sf:w-2.5",strokeWidth:2.5})})}const Jie=8,OQ=12,FQ={height:`${Jie}px`,borderColor:"transparent"},HQ={width:`${Jie}px`,borderColor:"transparent"},rMe={width:`${OQ}px`,height:`${OQ}px`,background:"transparent",border:"none"},oMe={width:"calc(10px / var(--rf-zoom, 1))",height:"calc(10px / var(--rf-zoom, 1))",background:"hsl(var(--background))",border:"calc(1px / var(--rf-zoom, 1)) solid hsl(var(--primary) / 0.6)",borderRadius:"calc(2px / var(--rf-zoom, 1))",zIndex:1},aMe=[{position:"top",style:FQ},{position:"bottom",style:FQ},{position:"left",style:HQ},{position:"right",style:HQ}],iMe=["top-left","top-right","bottom-left","bottom-right"],BQ={pointerEvents:"none",cursor:"default"};function Ad({visible:e,minWidth:t=80,minHeight:n=40,onResizeStart:r,onResize:o,onResizeEnd:a,cornerVariant:i="invisible"}){const s=i==="visible"?oMe:rMe,c=u=>e?u:{...u,...BQ},l=e?s:{...s,opacity:0,...BQ};return m.jsxs(m.Fragment,{children:[aMe.map(({position:u,style:d})=>m.jsx(DQ,{position:u,variant:ii.Line,minWidth:t,minHeight:n,style:c(d),onResizeStart:r,onResize:o,onResizeEnd:a,children:m.jsx("span",{"data-testid":"resize-control","data-position":u})},u)),iMe.map(u=>m.jsx(DQ,{position:u,variant:ii.Handle,minWidth:t,minHeight:n,style:l,autoScale:!1,onResizeStart:r,onResize:o,onResizeEnd:a,children:m.jsx("span",{"data-testid":"resize-control","data-position":u})},u))]})}function Pd(e){const{onResize:t,onResizeFinal:n,setResizing:r}=e,[o,a]=g.useState(!1),i=g.useRef(null),s=g.useRef(t),c=g.useRef(n),l=g.useRef(r);g.useEffect(()=>{s.current=t},[t]),g.useEffect(()=>{c.current=n},[n]),g.useEffect(()=>{l.current=r},[r]);const u=g.useCallback((p,y)=>{var k;a(!0),(k=l.current)==null||k.call(l,!0),i.current=y?{x:y.x,y:y.y,width:y.width,height:y.height}:null},[]),d=g.useCallback((p,y)=>{var k;(k=s.current)==null||k.call(s,{x:y.x,y:y.y,width:y.width,height:y.height})},[]),f=g.useCallback((p,y)=>{var w,v,M;a(!1),(w=l.current)==null||w.call(l,!1);const k=i.current;i.current=null,!(k&&k.width===y.width&&k.height===y.height)&&((v=s.current)==null||v.call(s,{x:y.x,y:y.y,width:y.width,height:y.height}),k&&((M=c.current)==null||M.call(c,{x:y.x,y:y.y,width:y.width,height:y.height},k)))},[]);return{isResizing:o,onResizeStart:u,onResizeEvent:d,onResizeEnd:f}}const ld={width:48,height:48},VQ="help-circle",sMe=24,cMe=24,b0="sf:opacity-0 sf:transition-opacity";function lMe(e){return ct(e,"text").color??"currentColor"}const $Q=new Set;function uMe({id:e,data:t,selected:n,isConnectable:r}){const{onResizeStart:o,onResizeEvent:a,onResizeEnd:i}=Pd({onResize:v=>{var M;return(M=t.onResize)==null?void 0:M.call(t,e,v)},setResizing:t.setResizing}),s=t.width!==void 0||t.height!==void 0,c=!!t.onNameChange,[l,u]=g.useState(!1),d=J1[t.icon];!d&&!$Q.has(t.icon)&&($Q.add(t.icon),console.warn(`[iconNode] Unknown icon "${t.icon}"; falling back to "${VQ}".`));const f=d??J1[VQ],p=lMe(t.color),y=t.strokeWidth??2,k={...s?{}:{width:ld.width,height:ld.height}},w=v=>{!c||l||(v.stopPropagation(),u(!0))};return m.jsxs("div",{className:ce("sf:group sf:relative",s?"sf:h-full sf:w-full":""),style:k,"data-testid":"icon-node",onDoubleClick:w,children:[m.jsx(Ad,{visible:!!n&&!!t.onResize&&!l&&!t.locked,cornerVariant:"visible",minWidth:sMe,minHeight:cMe,onResizeStart:o,onResize:a,onResizeEnd:i}),t.locked?m.jsx(Ed,{}):null,m.jsx(ut,{type:"target",position:me.Top,id:"t",isConnectable:r,className:ce(b0,n&&"sf:opacity-100!")}),m.jsx(ut,{type:"target",position:me.Left,id:"l",isConnectable:r,className:ce(b0,n&&"sf:opacity-100!")}),f?m.jsx(f,{color:p,strokeWidth:y,absoluteStrokeWidth:!0,"aria-label":t.alt,className:"sf:block sf:h-full sf:w-full sf:pointer-events-none sf:select-none"}):null,l&&c?m.jsx("div",{className:"sf:absolute sf:left-0 sf:right-0 sf:top-full sf:mt-1 sf:text-center sf:text-xs sf:text-muted-foreground",children:m.jsx(go,{initialValue:t.name??"",field:"icon-node-label",onCommit:v=>{var M;return(M=t.onNameChange)==null?void 0:M.call(t,e,v)},onExit:()=>u(!1),placeholder:"Label"})}):t.name?m.jsx("span",{"data-testid":"icon-node-label",className:"sf:pointer-events-none sf:absolute sf:left-0 sf:right-0 sf:top-full sf:mt-1 sf:truncate sf:text-center sf:text-xs sf:text-muted-foreground sf:select-none",children:t.name}):null,m.jsx(ut,{type:"source",position:me.Right,id:"r",isConnectable:r,className:ce(b0,n&&"sf:opacity-100!")}),m.jsx(ut,{type:"source",position:me.Bottom,id:"b",isConnectable:r,className:ce(b0,n&&"sf:opacity-100!")})]})}function dMe(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const hMe=g.memo(uMe,dMe);function fMe(e,t){const n=e.screenToFlowPosition({x:t.width/2,y:t.height/2});return{x:n.x-ld.width/2,y:n.y-ld.height/2}}const ese="seeflow:icon-recents",pMe=16;function tse(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(ese);if(e===null)return[];const t=JSON.parse(e);return Array.isArray(t)?t.every(n=>typeof n=="string")?t:[]:[]}catch{return[]}}function yMe(e){if(!(typeof window>"u"))try{const n=tse().filter(o=>o!==e),r=[e,...n].slice(0,pMe);window.localStorage.setItem(ese,JSON.stringify(r))}catch{}}const mMe=typeof navigator<"u"&&typeof navigator.platform=="string"&&navigator.platform.toLowerCase().includes("mac"),gMe=e=>e.length===1?e.toUpperCase():e==="Escape"?"Esc":e,Nt=(e,t=mMe)=>{const n=gMe(e.key);if(t){let o="";return e.meta&&(o+="⌘"),e.alt&&(o+="⌥"),e.shift&&(o+="⇧"),`${o}${n}`}const r=[];return e.meta&&r.push("Ctrl"),e.shift&&r.push("Shift"),e.alt&&r.push("Alt"),r.push(n),r.join("+")},n$=[{id:"tool.select",label:"Select tool",description:"Switch to the selection / pan tool",category:"Tools",shortcut:Nt({key:"V"})},{id:"tool.rectangle",label:"Rectangle",description:"Draw rectangle nodes",category:"Tools",shortcut:Nt({key:"R"})},{id:"tool.ellipse",label:"Ellipse",description:"Draw ellipse nodes",category:"Tools",shortcut:Nt({key:"O"})},{id:"tool.text",label:"Text",description:"Add a text node",category:"Tools",shortcut:Nt({key:"T"})},{id:"tool.sticky",label:"Sticky note",description:"Add a sticky note",category:"Tools",shortcut:Nt({key:"S"})},{id:"tool.database",label:"Database",description:"Add a database node",category:"Tools",shortcut:Nt({key:"D"})},{id:"tool.server",label:"Server",description:"Add a server node",category:"Tools"},{id:"tool.user",label:"User",description:"Add a user node",category:"Tools"},{id:"tool.queue",label:"Queue",description:"Add a queue node",category:"Tools"},{id:"tool.cloud",label:"Cloud",description:"Add a cloud node",category:"Tools"},{id:"edit.undo",label:"Undo",category:"Edit",shortcut:Nt({meta:!0,key:"Z"}),enabled:e=>e.canUndo},{id:"edit.redo",label:"Redo",category:"Edit",shortcut:Nt({meta:!0,shift:!0,key:"Z"}),enabled:e=>e.canRedo},{id:"edit.copy",label:"Copy",category:"Edit",shortcut:Nt({meta:!0,key:"C"}),enabled:e=>e.hasSelection},{id:"edit.paste",label:"Paste",category:"Edit",shortcut:Nt({meta:!0,key:"V"}),enabled:e=>e.hasClipboard},{id:"edit.duplicate",label:"Duplicate",category:"Edit",shortcut:Nt({meta:!0,key:"D"}),enabled:e=>e.hasSelection},{id:"edit.delete",label:"Delete",category:"Edit",shortcut:Nt({key:"Delete"}),enabled:e=>e.hasSelection},{id:"edit.selectAll",label:"Select all",category:"Edit",shortcut:Nt({meta:!0,key:"A"})},{id:"view.fit",label:"Fit view",description:"Fit everything in the viewport",category:"View",shortcut:Nt({meta:!0,key:"0"})},{id:"view.zoomIn",label:"Zoom in",category:"View",shortcut:Nt({meta:!0,key:"="})},{id:"view.zoomOut",label:"Zoom out",category:"View",shortcut:Nt({meta:!0,key:"-"})},{id:"view.zoom100",label:"Zoom to 100%",category:"View",shortcut:Nt({key:"1"})},{id:"view.zoomToSelection",label:"Zoom to selection",category:"View",shortcut:Nt({key:"F"}),enabled:e=>e.hasSelection},{id:"layout.tidy",label:"Tidy layout",description:"Auto-layout the canvas or current selection",category:"Layout",shortcut:Nt({meta:!0,shift:!0,key:"L"})},{id:"selection.deselect",label:"Deselect",description:"Clear selection and exit draw mode",category:"Selection",shortcut:Nt({key:"Escape"})},{id:"help.commandPalette",label:"Open command palette",category:"Help",shortcut:Nt({meta:!0,key:"P"})},{id:"export.pdf",label:"Export to PDF",description:"Download the current canvas as a PDF",category:"File",enabled:e=>e.canExportDemo},{id:"export.png",label:"Export as image",description:"Download the current canvas as a PNG",category:"File",enabled:e=>e.canExportDemo},{id:"session.reset",label:"Restart the demo",description:"Stop running scripts and re-run the reset script",category:"File",enabled:e=>e.canResetSession}],UQ=e=>{const t=n$.find(n=>n.id===e);return t?t.shortcut?`${t.label} (${t.shortcut})`:t.label:""},kMe=1,vMe=10,xMe=e=>{if(e.metaKey||e.ctrlKey||e.altKey)return null;const t=e.shiftKey?vMe:kMe;switch(e.key){case"ArrowLeft":return{dx:-t,dy:0};case"ArrowRight":return{dx:t,dy:0};case"ArrowUp":return{dx:0,dy:-t};case"ArrowDown":return{dx:0,dy:t};default:return null}},wMe=e=>{if(!(e.metaKey||e.ctrlKey)||e.altKey)return null;switch(e.key){case"0":return"fit";case"=":case"+":return"in";case"-":case"_":return"out";default:return null}},MMe=(e,t,n)=>{if(t.length===0)return[];const r=new Map(n.map(a=>[a.id,a])),o=[];for(const a of t){const i=r.get(a);i&&o.push({id:a,position:{x:i.position.x+e.dx,y:i.position.y+e.dy}})}return o},bMe=({event:e,isEditableActive:t,hasNodes:n,hasConnectors:r,selectedIds:o,hasClipboard:a})=>{if(!(e.metaKey||e.ctrlKey))return{type:"noop"};if(e.shiftKey||e.altKey)return{type:"noop"};const i=e.key.toLowerCase();return i!=="a"&&i!=="c"&&i!=="v"&&i!=="d"?{type:"noop"}:t?{type:"noop"}:i==="a"?!n&&!r?{type:"noop"}:{type:"selectAll"}:i==="c"?o.length===0?{type:"noop"}:{type:"copy",ids:o}:i==="d"?o.length===0?{type:"noop"}:{type:"duplicate",ids:o}:a?{type:"paste"}:{type:"noop"}},CMe=e=>{if(e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return null;switch(e.key.toLowerCase()){case"v":return"select";case"r":return"rectangle";case"o":return"ellipse";case"t":return"text";case"s":return"sticky";case"d":return"database";default:return null}},Ai="seeflow",nse=e=>`${e}:last-used-style:v1`,DO=()=>({node:{},connector:{}}),qO=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),r$=e=>{var t;try{const n=(t=globalThis.localStorage)==null?void 0:t.getItem(nse(e));if(!n)return DO();const r=JSON.parse(n);if(!qO(r))return DO();const o=qO(r.node)?r.node:{},a=qO(r.connector)?r.connector:{};return{node:o,connector:a}}catch{return DO()}},rse=(e,t)=>{var n;try{(n=globalThis.localStorage)==null||n.setItem(nse(e),JSON.stringify(t))}catch{}},C0=e=>r$(e),WQ=(e,t)=>{const{alt:n,...r}=t,o={...r};o.borderSize!==void 0&&o.borderWidth===void 0?o.borderWidth=o.borderSize:o.borderWidth!==void 0&&o.borderSize===void 0&&(o.borderSize=o.borderWidth);const a=r$(e);rse(e,{...a,node:{...a.node,...o}})},SMe=(e,t)=>{const n=r$(e);rse(e,{...n,connector:{...n.connector,...t}})},o$=3,GQ=17,qH=(e,t)=>{if(!e)return{};const n={};for(const r of t)e[r]!==void 0&&(n[r]=e[r]);return n},LMe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize","cornerRadius"],IMe=["borderColor","backgroundColor","borderSize","borderStyle","fontSize"],EMe=["fontSize"],AMe=["borderColor","borderWidth","borderStyle"];function KQ(e,t,n){if(e==="text")return{shape:e,width:t.width,height:t.height,fontSize:GQ,...qH(n,EMe)};const r=e==="ellipse"?IMe:LMe;return{shape:e,width:t.width,height:t.height,borderSize:o$,fontSize:GQ,...qH(n,r)}}function PMe(e,t,n){return{path:e,width:t.width,height:t.height,borderWidth:o$,...qH(n,AMe)}}const Ar=async(e,t,n,r)=>{const o={method:t};r!==void 0&&(o.headers={"content-type":"application/json"},o.body=JSON.stringify(r));const a=await e(n,o);if(!a.ok){let i=null;try{i=await a.json()}catch{}throw new Error((i==null?void 0:i.error)??`${t} ${n} → ${a.status}`)}return await a.json()},_Me=e=>{const{baseUrl:t,flowId:n}=e,r=e.fetch??globalThis.fetch.bind(globalThis),o=`${t}/api/flows/${n}`;return{async createNode(a){const i=await Ar(r,"POST",`${o}/nodes`,a);return{id:i.id,node:i.node}},async updateNode(a,i){await Ar(r,"PATCH",`${o}/nodes/${a}`,i)},async updateNodePosition(a,i){return await Ar(r,"PATCH",`${o}/nodes/${a}/position`,i)},async deleteNode(a){await Ar(r,"DELETE",`${o}/nodes/${a}`)},async reorderNode(a,i){await Ar(r,"PATCH",`${o}/nodes/${a}/order`,i)},async createConnector(a){return{id:(await Ar(r,"POST",`${o}/connectors`,a)).id}},async updateConnector(a,i){await Ar(r,"PATCH",`${o}/connectors/${a}`,i)},async deleteConnector(a){await Ar(r,"DELETE",`${o}/connectors/${a}`)},async uploadImage(a,i){const s=new FormData;s.append("file",a),s.append("filename",i);const c=`${t}/api/projects/${encodeURIComponent(n)}/files/upload`,l=await r(c,{method:"POST",body:s});if(!l.ok){let u=null;try{u=await l.json()}catch{}throw new Error((u==null?void 0:u.error)??`POST ${c} → ${l.status}`)}return await l.json()},async playNode(a){return await Ar(r,"POST",`${o}/play/${a}`,{})},async openFile(a){await Ar(r,"POST",`${t}/api/projects/${encodeURIComponent(n)}/files/open`,{path:a})},async revealFile(a){await Ar(r,"POST",`${t}/api/projects/${encodeURIComponent(n)}/files/reveal`,{path:a})}}};function RMe(e,t,n){let r=null,o=!1;const a=new ResizeObserver(()=>{o||(r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,!o&&n()},t))});return a.observe(e),()=>{o||(o=!0,r!==null&&(clearTimeout(r),r=null),a.disconnect())}}const TMe=new Set(["SCRIPT","STYLE","IFRAME","OBJECT","EMBED","LINK"]),jMe=new Set(["href","src"]),NMe=e=>/^on/i.test(e),zMe=e=>{let t=0;for(;t<e.length&&e.charCodeAt(t)<=32;)t+=1;return e.slice(t,t+11).toLowerCase()==="javascript:"};function DMe(e){if(typeof DOMParser>"u")return"";const t=new DOMParser().parseFromString(`<!doctype html><html><body>${e}</body></html>`,"text/html"),n=t.body,r=t.createTreeWalker(n,1),o=[];let a=r.nextNode();for(;a;){const i=a;if(TMe.has(i.tagName))o.push(i);else for(const s of Array.from(i.attributes)){if(NMe(s.name)){i.removeAttribute(s.name);continue}jMe.has(s.name.toLowerCase())&&zMe(s.value)&&i.removeAttribute(s.name)}a=r.nextNode()}for(const i of o)i.remove();return n.innerHTML}function ZQ(e){return{dangerouslySetInnerHTML:{__html:DMe(e)}}}const qMe="/runtime/tailwind.js",XQ="data-seeflow-tailwind-runtime";function OMe(){if(typeof document>"u"||document.querySelector(`script[${XQ}]`))return;const e=document.createElement("script");e.src=qMe,e.async=!0,e.setAttribute(XQ,"true"),document.head.appendChild(e)}const FMe=e=>typeof EventSource>"u"?null:new EventSource(e),S0=new Map;function HMe(e,t){let n=S0.get(e);if(!n){const o=FMe(`/api/events?flowId=${encodeURIComponent(e)}`);if(!o)return()=>{};const a={source:o,listeners:new Set,refCount:0};o.addEventListener("file:changed",i=>{let s;try{s=JSON.parse(i.data).path}catch{return}if(typeof s=="string")for(const c of a.listeners)c(s)}),S0.set(e,a),n=a}return n.listeners.add(t),n.refCount+=1,()=>{const r=S0.get(e);r&&(r.listeners.delete(t),r.refCount-=1,r.refCount===0&&(r.source.close(),S0.delete(e)))}}const Qu=new Map,YQ=(e,t)=>`${e}::${t}`;function BMe(e,t){const[n,r]=g.useState(()=>!e||!t?{kind:"loading"}:Qu.get(YQ(e,t))??{kind:"loading"});return g.useEffect(()=>{if(!e||!t){r({kind:"loading"});return}const o=YQ(e,t);let a=!1;const i=Qu.get(o);r(i||{kind:"loading"});const s=async()=>{try{const l=await fetch(Qie(e,t));if(a)return;if(l.status===404){const f={kind:"missing"};Qu.set(o,f),r(f);return}if(!l.ok){const f={kind:"error",message:`GET ${t} → ${l.status}`};Qu.set(o,f),r(f);return}const u=await l.text();if(a)return;const d={kind:"loaded",html:u};Qu.set(o,d),r(d)}catch(l){if(a)return;const u={kind:"error",message:l instanceof Error?l.message:String(l)};Qu.set(o,u),r(u)}};s();const c=HMe(e,l=>{l===t&&s()});return()=>{a=!0,c()}},[e,t]),n}const ose=g.createContext({custom:{}});function VMe({value:e,children:t}){return m.jsx(ose.Provider,{value:e,children:t})}function $Me(){return g.useContext(ose)}function Lu({name:e,as:t,size:n=16,fallback:r=Ofe,...o}){const a=$Me(),i=t??(e?a.custom[e]:void 0)??(e?J1[e]:void 0)??J1[r];return i?m.jsx(i,{size:n,...o}):null}function OO({message:e,variant:t="muted",className:n}){return m.jsx("div",{"data-testid":"placeholder-card","data-placeholder-variant":t,className:ce("sf:pointer-events-none sf:flex sf:h-full sf:w-full sf:select-none sf:items-center sf:justify-center sf:px-2 sf:text-center sf:text-xs",t==="destructive"?"sf:text-destructive":"sf:text-muted-foreground",n),children:e})}const QQ={width:320,height:200},UMe=80,WMe=40,L0="sf:opacity-0 sf:transition-opacity";function GMe({id:e,data:t,selected:n,isConnectable:r}){const{isResizing:o,onResizeStart:a,onResizeEvent:i,onResizeEnd:s}=Pd({onResize:v=>{var M;return(M=t.onResize)==null?void 0:M.call(t,e,v)},setResizing:t.setResizing}),c=t.autoSize??!0,l=o||!c,u={...t.backgroundColor!==void 0?{backgroundColor:ct(t.backgroundColor,"node").backgroundColor}:{},...t.borderColor!==void 0?{borderColor:ct(t.borderColor,"node").borderColor}:{},...t.borderSize!==void 0?{borderWidth:t.borderSize}:{},...t.borderStyle!==void 0?{borderStyle:t.borderStyle}:{},...t.cornerRadius!==void 0?{borderRadius:t.cornerRadius}:{},...t.fontSize!==void 0?{fontSize:`${t.fontSize}px`}:{},...ct(t.textColor,"text"),...l?{width:t.width,height:t.height}:{}};g.useEffect(()=>{OMe()},[]);const d=g.useRef(null),f=BMe(t.projectId,t.htmlPath),p=c&&f.kind==="loaded";let y;f.kind==="loaded"?y=l?m.jsx("div",{"data-testid":"html-node-content",className:"sf:h-full sf:w-full sf:overflow-auto",...ZQ(f.html)}):m.jsx("div",{ref:d,"data-testid":"html-node-content",className:"sf:inline-block",style:{maxWidth:800,maxHeight:600,overflow:"auto"},...ZQ(f.html)}):f.kind==="missing"?y=m.jsx(OO,{message:`Missing: ${t.htmlPath}`,variant:"destructive"}):f.kind==="error"?y=m.jsx(OO,{message:`Error: ${f.message}`,variant:"destructive"}):y=m.jsx(OO,{message:"Loading…"});const k=!l&&f.kind!=="loaded"?{width:QQ.width,height:QQ.height}:{},w={...u,...k};return m.jsxs("div",{className:ce("sf:group sf:relative sf:overflow-hidden",l?"sf:h-full sf:w-full":""),style:w,"data-testid":"html-node",children:[p?m.jsx(KMe,{nodeId:e,measureRef:d}):null,m.jsx(Ad,{visible:!!n&&!!t.onResize&&!t.locked,cornerVariant:"visible",minWidth:UMe,minHeight:WMe,onResizeStart:a,onResize:i,onResizeEnd:s}),t.locked?m.jsx(Ed,{}):null,n&&!t.locked&&!c&&!o&&typeof t.onFitToContent=="function"?m.jsx("button",{type:"button","data-testid":"html-node-fit-to-content",title:"Fit to content","aria-label":"Fit to content",className:"sf:absolute sf:top-1 sf:right-1 sf:z-10 sf:flex sf:h-5 sf:w-5 sf:cursor-pointer sf:items-center sf:justify-center sf:rounded sf:bg-background/80 sf:text-muted-foreground sf:opacity-0 sf:transition-opacity sf:hover:text-foreground sf:group-hover:opacity-100 sf:focus:opacity-100",onClick:v=>{var M;v.stopPropagation(),(M=t.onFitToContent)==null||M.call(t,e)},children:m.jsx(j1,{size:12,"aria-hidden":!0})}):null,m.jsx(ut,{type:"target",position:me.Top,id:"t",isConnectable:r,className:ce(L0,n&&"sf:opacity-100!")}),m.jsx(ut,{type:"target",position:me.Left,id:"l",isConnectable:r,className:ce(L0,n&&"sf:opacity-100!")}),y,m.jsx(ut,{type:"source",position:me.Right,id:"r",isConnectable:r,className:ce(L0,n&&"sf:opacity-100!")}),m.jsx(ut,{type:"source",position:me.Bottom,id:"b",isConnectable:r,className:ce(L0,n&&"sf:opacity-100!")}),t.name!==void 0&&t.name!==""?m.jsx("div",{"data-testid":"html-node-label",className:"sf:-bottom-5 sf:absolute sf:right-0 sf:left-0 sf:truncate sf:text-center sf:text-[11px] sf:text-muted-foreground",children:t.icon?m.jsxs("div",{className:"sf:flex sf:items-center sf:justify-center sf:gap-1",children:[m.jsx(Lu,{name:t.icon,size:12,"aria-hidden":!0}),m.jsx("span",{className:"truncate",children:t.name})]}):t.name}):null]})}function KMe({nodeId:e,measureRef:t}){const n=g8e();return g.useEffect(()=>{const r=t.current;if(r!==null)return RMe(r,150,()=>{n(e)})},[e,n,t]),null}function ZMe(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const XMe=g.memo(GMe,ZMe),JQ={width:200,height:150},YMe=40,QMe=40,I0="sf:opacity-0 sf:transition-opacity";function JMe({id:e,data:t,selected:n,isConnectable:r}){const{onResizeStart:o,onResizeEvent:a,onResizeEnd:i}=Pd({onResize:l=>{var u;return(u=t.onResize)==null?void 0:u.call(t,e,l)},setResizing:t.setResizing}),s=t.width!==void 0||t.height!==void 0,c={backgroundColor:t.backgroundColor!==void 0?ct(t.backgroundColor,"node").backgroundColor:ef,...t.borderColor!==void 0?{borderColor:ct(t.borderColor,"node").borderColor}:{},...t.borderWidth!==void 0?{borderWidth:t.borderWidth}:{},...t.borderStyle!==void 0?{borderStyle:t.borderStyle}:{},...t.cornerRadius!==void 0?{borderRadius:t.cornerRadius}:{},...s?{}:{width:JQ.width,height:JQ.height}};return m.jsxs("div",{className:ce("sf:group sf:relative sf:overflow-hidden",s?"sf:h-full sf:w-full":""),style:c,"data-testid":"image-node",children:[m.jsx(Ad,{visible:!!n&&!!t.onResize&&!t.locked,cornerVariant:"visible",minWidth:YMe,minHeight:QMe,onResizeStart:o,onResize:a,onResizeEnd:i}),t.locked?m.jsx(Ed,{}):null,m.jsx(ut,{type:"target",position:me.Top,id:"t",isConnectable:r,className:ce(I0,n&&"sf:opacity-100!")}),m.jsx(ut,{type:"target",position:me.Left,id:"l",isConnectable:r,className:ce(I0,n&&"sf:opacity-100!")}),t._uploading?m.jsx("div",{"data-testid":"image-node-placeholder","data-placeholder":"loading",className:"sf:flex sf:h-full sf:w-full sf:select-none sf:items-center sf:justify-center sf:text-xs sf:text-muted-foreground sf:pointer-events-none",children:"Loading…"}):t._uploadError?m.jsx("button",{type:"button","data-testid":"image-node-placeholder","data-placeholder":"failed",onClick:()=>{var l;return(l=t.onRetryUpload)==null?void 0:l.call(t,e)},title:t._uploadError,className:"sf:flex sf:h-full sf:w-full sf:cursor-pointer sf:select-none sf:items-center sf:justify-center sf:px-2 sf:text-center sf:text-xs sf:text-destructive",children:"Upload failed (click to retry)"}):m.jsx("img",{src:t.projectId?Qie(t.projectId,t.path):"",alt:t.alt??"",className:"sf:block sf:h-full sf:w-full sf:select-none sf:object-contain sf:pointer-events-none",draggable:!1}),m.jsx(ut,{type:"source",position:me.Right,id:"r",isConnectable:r,className:ce(I0,n&&"sf:opacity-100!")}),m.jsx(ut,{type:"source",position:me.Bottom,id:"b",isConnectable:r,className:ce(I0,n&&"sf:opacity-100!")})]})}function ebe(e,t){return e.selected===t.selected&&e.data===t.data&&e.width===t.width&&e.height===t.height}const tbe=g.memo(JMe,ebe);function Le(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(e==null||e(o),n===!1||!o.defaultPrevented)return t==null?void 0:t(o)}}function eJ(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Co(...e){return t=>{let n=!1;const r=e.map(o=>{const a=eJ(o,t);return!n&&typeof a=="function"&&(n=!0),a});if(n)return()=>{for(let o=0;o<r.length;o++){const a=r[o];typeof a=="function"?a():eJ(e[o],null)}}}}function pt(...e){return g.useCallback(Co(...e),e)}function nbe(e,t){const n=g.createContext(t),r=a=>{const{children:i,...s}=a,c=g.useMemo(()=>s,Object.values(s));return m.jsx(n.Provider,{value:c,children:i})};r.displayName=e+"Provider";function o(a){const i=g.useContext(n);if(i)return i;if(t!==void 0)return t;throw new Error(`\`${a}\` must be used within \`${e}\``)}return[r,o]}function Kr(e,t=[]){let n=[];function r(a,i){const s=g.createContext(i),c=n.length;n=[...n,i];const l=d=>{var v;const{scope:f,children:p,...y}=d,k=((v=f==null?void 0:f[e])==null?void 0:v[c])||s,w=g.useMemo(()=>y,Object.values(y));return m.jsx(k.Provider,{value:w,children:p})};l.displayName=a+"Provider";function u(d,f){var k;const p=((k=f==null?void 0:f[e])==null?void 0:k[c])||s,y=g.useContext(p);if(y)return y;if(i!==void 0)return i;throw new Error(`\`${d}\` must be used within \`${a}\``)}return[l,u]}const o=()=>{const a=n.map(i=>g.createContext(i));return function(s){const c=(s==null?void 0:s[e])||a;return g.useMemo(()=>({[`__scope${e}`]:{...s,[e]:c}}),[s,c])}};return o.scopeName=e,[r,rbe(o,...t)]}function rbe(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(a){const i=r.reduce((s,{useScope:c,scopeName:l})=>{const d=c(a)[`__scope${l}`];return{...s,...d}},{});return g.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return n.scopeName=t.scopeName,n}function ud(e){const t=obe(e),n=g.forwardRef((r,o)=>{const{children:a,...i}=r,s=g.Children.toArray(a),c=s.find(ibe);if(c){const l=c.props.children,u=s.map(d=>d===c?g.Children.count(l)>1?g.Children.only(null):g.isValidElement(l)?l.props.children:null:d);return m.jsx(t,{...i,ref:o,children:g.isValidElement(l)?g.cloneElement(l,void 0,u):null})}return m.jsx(t,{...i,ref:o,children:a})});return n.displayName=`${e}.Slot`,n}function obe(e){const t=g.forwardRef((n,r)=>{const{children:o,...a}=n;if(g.isValidElement(o)){const i=cbe(o),s=sbe(a,o.props);return o.type!==g.Fragment&&(s.ref=r?Co(r,i):i),g.cloneElement(o,s)}return g.Children.count(o)>1?g.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ase=Symbol("radix.slottable");function abe(e){const t=({children:n})=>m.jsx(m.Fragment,{children:n});return t.displayName=`${e}.Slottable`,t.__radixId=ase,t}function ibe(e){return g.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ase}function sbe(e,t){const n={...t};for(const r in t){const o=e[r],a=t[r];/^on[A-Z]/.test(r)?o&&a?n[r]=(...s)=>{const c=a(...s);return o(...s),c}:o&&(n[r]=o):r==="style"?n[r]={...o,...a}:r==="className"&&(n[r]=[o,a].filter(Boolean).join(" "))}return{...e,...n}}function cbe(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var lbe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],$e=lbe.reduce((e,t)=>{const n=ud(`Primitive.${t}`),r=g.forwardRef((o,a)=>{const{asChild:i,...s}=o,c=i?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(c,{...s,ref:a})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function ise(e,t){e&&wd.flushSync(()=>e.dispatchEvent(t))}function So(e){const t=g.useRef(e);return g.useEffect(()=>{t.current=e}),g.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}function ube(e,t=globalThis==null?void 0:globalThis.document){const n=So(e);g.useEffect(()=>{const r=o=>{o.key==="Escape"&&n(o)};return t.addEventListener("keydown",r,{capture:!0}),()=>t.removeEventListener("keydown",r,{capture:!0})},[n,t])}var dbe="DismissableLayer",OH="dismissableLayer.update",hbe="dismissableLayer.pointerDownOutside",fbe="dismissableLayer.focusOutside",tJ,sse=g.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),pf=g.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:s,...c}=e,l=g.useContext(sse),[u,d]=g.useState(null),f=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=g.useState({}),y=pt(t,L=>d(L)),k=Array.from(l.layers),[w]=[...l.layersWithOutsidePointerEventsDisabled].slice(-1),v=k.indexOf(w),M=u?k.indexOf(u):-1,x=l.layersWithOutsidePointerEventsDisabled.size>0,b=M>=v,S=mbe(L=>{const P=L.target,T=[...l.branches].some(_=>_.contains(P));!b||T||(o==null||o(L),i==null||i(L),L.defaultPrevented||s==null||s())},f),C=gbe(L=>{const P=L.target;[...l.branches].some(_=>_.contains(P))||(a==null||a(L),i==null||i(L),L.defaultPrevented||s==null||s())},f);return ube(L=>{M===l.layers.size-1&&(r==null||r(L),!L.defaultPrevented&&s&&(L.preventDefault(),s()))},f),g.useEffect(()=>{if(u)return n&&(l.layersWithOutsidePointerEventsDisabled.size===0&&(tJ=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),l.layersWithOutsidePointerEventsDisabled.add(u)),l.layers.add(u),nJ(),()=>{n&&l.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=tJ)}},[u,f,n,l]),g.useEffect(()=>()=>{u&&(l.layers.delete(u),l.layersWithOutsidePointerEventsDisabled.delete(u),nJ())},[u,l]),g.useEffect(()=>{const L=()=>p({});return document.addEventListener(OH,L),()=>document.removeEventListener(OH,L)},[]),m.jsx($e.div,{...c,ref:y,style:{pointerEvents:x?b?"auto":"none":void 0,...e.style},onFocusCapture:Le(e.onFocusCapture,C.onFocusCapture),onBlurCapture:Le(e.onBlurCapture,C.onBlurCapture),onPointerDownCapture:Le(e.onPointerDownCapture,S.onPointerDownCapture)})});pf.displayName=dbe;var pbe="DismissableLayerBranch",ybe=g.forwardRef((e,t)=>{const n=g.useContext(sse),r=g.useRef(null),o=pt(t,r);return g.useEffect(()=>{const a=r.current;if(a)return n.branches.add(a),()=>{n.branches.delete(a)}},[n.branches]),m.jsx($e.div,{...e,ref:o})});ybe.displayName=pbe;function mbe(e,t=globalThis==null?void 0:globalThis.document){const n=So(e),r=g.useRef(!1),o=g.useRef(()=>{});return g.useEffect(()=>{const a=s=>{if(s.target&&!r.current){let c=function(){cse(hbe,n,l,{discrete:!0})};const l={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=c,t.addEventListener("click",o.current,{once:!0})):c()}else t.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,n]),{onPointerDownCapture:()=>r.current=!0}}function gbe(e,t=globalThis==null?void 0:globalThis.document){const n=So(e),r=g.useRef(!1);return g.useEffect(()=>{const o=a=>{a.target&&!r.current&&cse(fbe,n,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function nJ(){const e=new CustomEvent(OH);document.dispatchEvent(e)}function cse(e,t,n,{discrete:r}){const o=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&o.addEventListener(e,t,{once:!0}),r?ise(o,a):o.dispatchEvent(a)}var FO=0;function a$(){g.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??rJ()),document.body.insertAdjacentElement("beforeend",e[1]??rJ()),FO++,()=>{FO===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),FO--}},[])}function rJ(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var HO="focusScope.autoFocusOnMount",BO="focusScope.autoFocusOnUnmount",oJ={bubbles:!1,cancelable:!0},kbe="FocusScope",mT=g.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[s,c]=g.useState(null),l=So(o),u=So(a),d=g.useRef(null),f=pt(t,k=>c(k)),p=g.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;g.useEffect(()=>{if(r){let k=function(x){if(p.paused||!s)return;const b=x.target;s.contains(b)?d.current=b:ja(d.current,{select:!0})},w=function(x){if(p.paused||!s)return;const b=x.relatedTarget;b!==null&&(s.contains(b)||ja(d.current,{select:!0}))},v=function(x){if(document.activeElement===document.body)for(const S of x)S.removedNodes.length>0&&ja(s)};document.addEventListener("focusin",k),document.addEventListener("focusout",w);const M=new MutationObserver(v);return s&&M.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",k),document.removeEventListener("focusout",w),M.disconnect()}}},[r,s,p.paused]),g.useEffect(()=>{if(s){iJ.add(p);const k=document.activeElement;if(!s.contains(k)){const v=new CustomEvent(HO,oJ);s.addEventListener(HO,l),s.dispatchEvent(v),v.defaultPrevented||(vbe(Cbe(lse(s)),{select:!0}),document.activeElement===k&&ja(s))}return()=>{s.removeEventListener(HO,l),setTimeout(()=>{const v=new CustomEvent(BO,oJ);s.addEventListener(BO,u),s.dispatchEvent(v),v.defaultPrevented||ja(k??document.body,{select:!0}),s.removeEventListener(BO,u),iJ.remove(p)},0)}}},[s,l,u,p]);const y=g.useCallback(k=>{if(!n&&!r||p.paused)return;const w=k.key==="Tab"&&!k.altKey&&!k.ctrlKey&&!k.metaKey,v=document.activeElement;if(w&&v){const M=k.currentTarget,[x,b]=xbe(M);x&&b?!k.shiftKey&&v===b?(k.preventDefault(),n&&ja(x,{select:!0})):k.shiftKey&&v===x&&(k.preventDefault(),n&&ja(b,{select:!0})):v===M&&k.preventDefault()}},[n,r,p.paused]);return m.jsx($e.div,{tabIndex:-1,...i,ref:f,onKeyDown:y})});mT.displayName=kbe;function vbe(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(ja(r,{select:t}),document.activeElement!==n)return}function xbe(e){const t=lse(e),n=aJ(t,e),r=aJ(t.reverse(),e);return[n,r]}function lse(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const o=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||o?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function aJ(e,t){for(const n of e)if(!wbe(n,{upTo:t}))return n}function wbe(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function Mbe(e){return e instanceof HTMLInputElement&&"select"in e}function ja(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Mbe(e)&&t&&e.select()}}var iJ=bbe();function bbe(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=sJ(e,t),e.unshift(t)},remove(t){var n;e=sJ(e,t),(n=e[0])==null||n.resume()}}}function sJ(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Cbe(e){return e.filter(t=>t.tagName!=="A")}var si=globalThis!=null&&globalThis.document?g.useLayoutEffect:()=>{},Sbe=IB[" useId ".trim().toString()]||(()=>{}),Lbe=0;function yn(e){const[t,n]=g.useState(Sbe());return si(()=>{n(r=>r??String(Lbe++))},[e]),e||(t?`radix-${t}`:"")}const Ibe=["top","right","bottom","left"],ci=Math.min,Zn=Math.max,aR=Math.round,E0=Math.floor,Mo=e=>({x:e,y:e}),Ebe={left:"right",right:"left",bottom:"top",top:"bottom"};function FH(e,t,n){return Zn(e,ci(t,n))}function ra(e,t){return typeof e=="function"?e(t):e}function oa(e){return e.split("-")[0]}function _d(e){return e.split("-")[1]}function i$(e){return e==="x"?"y":"x"}function s$(e){return e==="y"?"height":"width"}function ko(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function c$(e){return i$(ko(e))}function Abe(e,t,n){n===void 0&&(n=!1);const r=_d(e),o=c$(e),a=s$(o);let i=o==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[a]>t.floating[a]&&(i=iR(i)),[i,iR(i)]}function Pbe(e){const t=iR(e);return[HH(e),t,HH(t)]}function HH(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const cJ=["left","right"],lJ=["right","left"],_be=["top","bottom"],Rbe=["bottom","top"];function Tbe(e,t,n){switch(e){case"top":case"bottom":return n?t?lJ:cJ:t?cJ:lJ;case"left":case"right":return t?_be:Rbe;default:return[]}}function jbe(e,t,n,r){const o=_d(e);let a=Tbe(oa(e),n==="start",r);return o&&(a=a.map(i=>i+"-"+o),t&&(a=a.concat(a.map(HH)))),a}function iR(e){const t=oa(e);return Ebe[t]+e.slice(t.length)}function Nbe(e){return{top:0,right:0,bottom:0,left:0,...e}}function use(e){return typeof e!="number"?Nbe(e):{top:e,right:e,bottom:e,left:e}}function sR(e){const{x:t,y:n,width:r,height:o}=e;return{width:r,height:o,top:n,left:t,right:t+r,bottom:n+o,x:t,y:n}}function uJ(e,t,n){let{reference:r,floating:o}=e;const a=ko(t),i=c$(t),s=s$(i),c=oa(t),l=a==="y",u=r.x+r.width/2-o.width/2,d=r.y+r.height/2-o.height/2,f=r[s]/2-o[s]/2;let p;switch(c){case"top":p={x:u,y:r.y-o.height};break;case"bottom":p={x:u,y:r.y+r.height};break;case"right":p={x:r.x+r.width,y:d};break;case"left":p={x:r.x-o.width,y:d};break;default:p={x:r.x,y:r.y}}switch(_d(t)){case"start":p[i]-=f*(n&&l?-1:1);break;case"end":p[i]+=f*(n&&l?-1:1);break}return p}async function zbe(e,t){var n;t===void 0&&(t={});const{x:r,y:o,platform:a,rects:i,elements:s,strategy:c}=e,{boundary:l="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=ra(t,e),y=use(p),w=s[f?d==="floating"?"reference":"floating":d],v=sR(await a.getClippingRect({element:(n=await(a.isElement==null?void 0:a.isElement(w)))==null||n?w:w.contextElement||await(a.getDocumentElement==null?void 0:a.getDocumentElement(s.floating)),boundary:l,rootBoundary:u,strategy:c})),M=d==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,x=await(a.getOffsetParent==null?void 0:a.getOffsetParent(s.floating)),b=await(a.isElement==null?void 0:a.isElement(x))?await(a.getScale==null?void 0:a.getScale(x))||{x:1,y:1}:{x:1,y:1},S=sR(a.convertOffsetParentRelativeRectToViewportRelativeRect?await a.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:M,offsetParent:x,strategy:c}):M);return{top:(v.top-S.top+y.top)/b.y,bottom:(S.bottom-v.bottom+y.bottom)/b.y,left:(v.left-S.left+y.left)/b.x,right:(S.right-v.right+y.right)/b.x}}const Dbe=50,qbe=async(e,t,n)=>{const{placement:r="bottom",strategy:o="absolute",middleware:a=[],platform:i}=n,s=i.detectOverflow?i:{...i,detectOverflow:zbe},c=await(i.isRTL==null?void 0:i.isRTL(t));let l=await i.getElementRects({reference:e,floating:t,strategy:o}),{x:u,y:d}=uJ(l,r,c),f=r,p=0;const y={};for(let k=0;k<a.length;k++){const w=a[k];if(!w)continue;const{name:v,fn:M}=w,{x,y:b,data:S,reset:C}=await M({x:u,y:d,initialPlacement:r,placement:f,strategy:o,middlewareData:y,rects:l,platform:s,elements:{reference:e,floating:t}});u=x??u,d=b??d,y[v]={...y[v],...S},C&&p<Dbe&&(p++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(l=C.rects===!0?await i.getElementRects({reference:e,floating:t,strategy:o}):C.rects),{x:u,y:d}=uJ(l,f,c)),k=-1)}return{x:u,y:d,placement:f,strategy:o,middlewareData:y}},Obe=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:o,rects:a,platform:i,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=ra(e,t)||{};if(l==null)return{};const d=use(u),f={x:n,y:r},p=c$(o),y=s$(p),k=await i.getDimensions(l),w=p==="y",v=w?"top":"left",M=w?"bottom":"right",x=w?"clientHeight":"clientWidth",b=a.reference[y]+a.reference[p]-f[p]-a.floating[y],S=f[p]-a.reference[p],C=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l));let L=C?C[x]:0;(!L||!await(i.isElement==null?void 0:i.isElement(C)))&&(L=s.floating[x]||a.floating[y]);const P=b/2-S/2,T=L/2-k[y]/2-1,_=ci(d[v],T),A=ci(d[M],T),I=_,V=L-k[y]-A,j=L/2-k[y]/2+P,H=FH(I,j,V),O=!c.arrow&&_d(o)!=null&&j!==H&&a.reference[y]/2-(j<I?_:A)-k[y]/2<0,U=O?j<I?j-I:j-V:0;return{[p]:f[p]+U,data:{[p]:H,centerOffset:j-H-U,...O&&{alignmentOffset:U}},reset:O}}}),Fbe=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:o,middlewareData:a,rects:i,initialPlacement:s,platform:c,elements:l}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:k=!0,...w}=ra(e,t);if((n=a.arrow)!=null&&n.alignmentOffset)return{};const v=oa(o),M=ko(s),x=oa(s)===s,b=await(c.isRTL==null?void 0:c.isRTL(l.floating)),S=f||(x||!k?[iR(s)]:Pbe(s)),C=y!=="none";!f&&C&&S.push(...jbe(s,k,y,b));const L=[s,...S],P=await c.detectOverflow(t,w),T=[];let _=((r=a.flip)==null?void 0:r.overflows)||[];if(u&&T.push(P[v]),d){const j=Abe(o,i,b);T.push(P[j[0]],P[j[1]])}if(_=[..._,{placement:o,overflows:T}],!T.every(j=>j<=0)){var A,I;const j=(((A=a.flip)==null?void 0:A.index)||0)+1,H=L[j];if(H&&(!(d==="alignment"?M!==ko(H):!1)||_.every(z=>ko(z.placement)===M?z.overflows[0]>0:!0)))return{data:{index:j,overflows:_},reset:{placement:H}};let O=(I=_.filter(U=>U.overflows[0]<=0).sort((U,z)=>U.overflows[1]-z.overflows[1])[0])==null?void 0:I.placement;if(!O)switch(p){case"bestFit":{var V;const U=(V=_.filter(z=>{if(C){const N=ko(z.placement);return N===M||N==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(N=>N>0).reduce((N,E)=>N+E,0)]).sort((z,N)=>z[1]-N[1])[0])==null?void 0:V[0];U&&(O=U);break}case"initialPlacement":O=s;break}if(o!==O)return{reset:{placement:O}}}return{}}}};function dJ(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function hJ(e){return Ibe.some(t=>e[t]>=0)}const Hbe=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:o="referenceHidden",...a}=ra(e,t);switch(o){case"referenceHidden":{const i=await r.detectOverflow(t,{...a,elementContext:"reference"}),s=dJ(i,n.reference);return{data:{referenceHiddenOffsets:s,referenceHidden:hJ(s)}}}case"escaped":{const i=await r.detectOverflow(t,{...a,altBoundary:!0}),s=dJ(i,n.floating);return{data:{escapedOffsets:s,escaped:hJ(s)}}}default:return{}}}}},dse=new Set(["left","top"]);async function Bbe(e,t){const{placement:n,platform:r,elements:o}=e,a=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=oa(n),s=_d(n),c=ko(n)==="y",l=dse.has(i)?-1:1,u=a&&c?-1:1,d=ra(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:y}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof y=="number"&&(p=s==="end"?y*-1:y),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}const Vbe=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:o,y:a,placement:i,middlewareData:s}=t,c=await Bbe(t,e);return i===((n=s.offset)==null?void 0:n.placement)&&(r=s.arrow)!=null&&r.alignmentOffset?{}:{x:o+c.x,y:a+c.y,data:{...c,placement:i}}}}},$be=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:o,platform:a}=t,{mainAxis:i=!0,crossAxis:s=!1,limiter:c={fn:v=>{let{x:M,y:x}=v;return{x:M,y:x}}},...l}=ra(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=ko(oa(o)),p=i$(f);let y=u[p],k=u[f];if(i){const v=p==="y"?"top":"left",M=p==="y"?"bottom":"right",x=y+d[v],b=y-d[M];y=FH(x,y,b)}if(s){const v=f==="y"?"top":"left",M=f==="y"?"bottom":"right",x=k+d[v],b=k-d[M];k=FH(x,k,b)}const w=c.fn({...t,[p]:y,[f]:k});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[p]:i,[f]:s}}}}}},Ube=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:o,rects:a,middlewareData:i}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=ra(e,t),u={x:n,y:r},d=ko(o),f=i$(d);let p=u[f],y=u[d];const k=ra(s,t),w=typeof k=="number"?{mainAxis:k,crossAxis:0}:{mainAxis:0,crossAxis:0,...k};if(c){const x=f==="y"?"height":"width",b=a.reference[f]-a.floating[x]+w.mainAxis,S=a.reference[f]+a.reference[x]-w.mainAxis;p<b?p=b:p>S&&(p=S)}if(l){var v,M;const x=f==="y"?"width":"height",b=dse.has(oa(o)),S=a.reference[d]-a.floating[x]+(b&&((v=i.offset)==null?void 0:v[d])||0)+(b?0:w.crossAxis),C=a.reference[d]+a.reference[x]+(b?0:((M=i.offset)==null?void 0:M[d])||0)-(b?w.crossAxis:0);y<S?y=S:y>C&&(y=C)}return{[f]:p,[d]:y}}}},Wbe=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:o,rects:a,platform:i,elements:s}=t,{apply:c=()=>{},...l}=ra(e,t),u=await i.detectOverflow(t,l),d=oa(o),f=_d(o),p=ko(o)==="y",{width:y,height:k}=a.floating;let w,v;d==="top"||d==="bottom"?(w=d,v=f===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(v=d,w=f==="end"?"top":"bottom");const M=k-u.top-u.bottom,x=y-u.left-u.right,b=ci(k-u[w],M),S=ci(y-u[v],x),C=!t.middlewareData.shift;let L=b,P=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(P=x),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(L=M),C&&!f){const _=Zn(u.left,0),A=Zn(u.right,0),I=Zn(u.top,0),V=Zn(u.bottom,0);p?P=y-2*(_!==0||A!==0?_+A:Zn(u.left,u.right)):L=k-2*(I!==0||V!==0?I+V:Zn(u.top,u.bottom))}await c({...t,availableWidth:P,availableHeight:L});const T=await i.getDimensions(s.floating);return y!==T.width||k!==T.height?{reset:{rects:!0}}:{}}}};function gT(){return typeof window<"u"}function Rd(e){return hse(e)?(e.nodeName||"").toLowerCase():"#document"}function er(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Eo(e){var t;return(t=(hse(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function hse(e){return gT()?e instanceof Node||e instanceof er(e).Node:!1}function Vr(e){return gT()?e instanceof Element||e instanceof er(e).Element:!1}function la(e){return gT()?e instanceof HTMLElement||e instanceof er(e).HTMLElement:!1}function fJ(e){return!gT()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof er(e).ShadowRoot}function yf(e){const{overflow:t,overflowX:n,overflowY:r,display:o}=$r(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&o!=="inline"&&o!=="contents"}function Gbe(e){return/^(table|td|th)$/.test(Rd(e))}function kT(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Kbe=/transform|translate|scale|rotate|perspective|filter/,Zbe=/paint|layout|strict|content/,Pi=e=>!!e&&e!=="none";let VO;function l$(e){const t=Vr(e)?$r(e):e;return Pi(t.transform)||Pi(t.translate)||Pi(t.scale)||Pi(t.rotate)||Pi(t.perspective)||!u$()&&(Pi(t.backdropFilter)||Pi(t.filter))||Kbe.test(t.willChange||"")||Zbe.test(t.contain||"")}function Xbe(e){let t=li(e);for(;la(t)&&!dd(t);){if(l$(t))return t;if(kT(t))return null;t=li(t)}return null}function u$(){return VO==null&&(VO=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),VO}function dd(e){return/^(html|body|#document)$/.test(Rd(e))}function $r(e){return er(e).getComputedStyle(e)}function vT(e){return Vr(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function li(e){if(Rd(e)==="html")return e;const t=e.assignedSlot||e.parentNode||fJ(e)&&e.host||Eo(e);return fJ(t)?t.host:t}function fse(e){const t=li(e);return dd(t)?e.ownerDocument?e.ownerDocument.body:e.body:la(t)&&yf(t)?t:fse(t)}function V2(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const o=fse(e),a=o===((r=e.ownerDocument)==null?void 0:r.body),i=er(o);if(a){const s=BH(i);return t.concat(i,i.visualViewport||[],yf(o)?o:[],s&&n?V2(s):[])}else return t.concat(o,V2(o,[],n))}function BH(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function pse(e){const t=$r(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const o=la(e),a=o?e.offsetWidth:n,i=o?e.offsetHeight:r,s=aR(n)!==a||aR(r)!==i;return s&&(n=a,r=i),{width:n,height:r,$:s}}function d$(e){return Vr(e)?e:e.contextElement}function V1(e){const t=d$(e);if(!la(t))return Mo(1);const n=t.getBoundingClientRect(),{width:r,height:o,$:a}=pse(t);let i=(a?aR(n.width):n.width)/r,s=(a?aR(n.height):n.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!s||!Number.isFinite(s))&&(s=1),{x:i,y:s}}const Ybe=Mo(0);function yse(e){const t=er(e);return!u$()||!t.visualViewport?Ybe:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Qbe(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==er(e)?!1:t}function Iu(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const o=e.getBoundingClientRect(),a=d$(e);let i=Mo(1);t&&(r?Vr(r)&&(i=V1(r)):i=V1(e));const s=Qbe(a,n,r)?yse(a):Mo(0);let c=(o.left+s.x)/i.x,l=(o.top+s.y)/i.y,u=o.width/i.x,d=o.height/i.y;if(a){const f=er(a),p=r&&Vr(r)?er(r):r;let y=f,k=BH(y);for(;k&&r&&p!==y;){const w=V1(k),v=k.getBoundingClientRect(),M=$r(k),x=v.left+(k.clientLeft+parseFloat(M.paddingLeft))*w.x,b=v.top+(k.clientTop+parseFloat(M.paddingTop))*w.y;c*=w.x,l*=w.y,u*=w.x,d*=w.y,c+=x,l+=b,y=er(k),k=BH(y)}}return sR({width:u,height:d,x:c,y:l})}function xT(e,t){const n=vT(e).scrollLeft;return t?t.left+n:Iu(Eo(e)).left+n}function mse(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-xT(e,n),o=n.top+t.scrollTop;return{x:r,y:o}}function Jbe(e){let{elements:t,rect:n,offsetParent:r,strategy:o}=e;const a=o==="fixed",i=Eo(r),s=t?kT(t.floating):!1;if(r===i||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Mo(1);const u=Mo(0),d=la(r);if((d||!d&&!a)&&((Rd(r)!=="body"||yf(i))&&(c=vT(r)),d)){const p=Iu(r);l=V1(r),u.x=p.x+r.clientLeft,u.y=p.y+r.clientTop}const f=i&&!d&&!a?mse(i,c):Mo(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function e7e(e){return Array.from(e.getClientRects())}function t7e(e){const t=Eo(e),n=vT(e),r=e.ownerDocument.body,o=Zn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=Zn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+xT(e);const s=-n.scrollTop;return $r(r).direction==="rtl"&&(i+=Zn(t.clientWidth,r.clientWidth)-o),{width:o,height:a,x:i,y:s}}const pJ=25;function n7e(e,t){const n=er(e),r=Eo(e),o=n.visualViewport;let a=r.clientWidth,i=r.clientHeight,s=0,c=0;if(o){a=o.width,i=o.height;const u=u$();(!u||u&&t==="fixed")&&(s=o.offsetLeft,c=o.offsetTop)}const l=xT(r);if(l<=0){const u=r.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,y=Math.abs(r.clientWidth-d.clientWidth-p);y<=pJ&&(a-=y)}else l<=pJ&&(a+=l);return{width:a,height:i,x:s,y:c}}function r7e(e,t){const n=Iu(e,!0,t==="fixed"),r=n.top+e.clientTop,o=n.left+e.clientLeft,a=la(e)?V1(e):Mo(1),i=e.clientWidth*a.x,s=e.clientHeight*a.y,c=o*a.x,l=r*a.y;return{width:i,height:s,x:c,y:l}}function yJ(e,t,n){let r;if(t==="viewport")r=n7e(e,n);else if(t==="document")r=t7e(Eo(e));else if(Vr(t))r=r7e(t,n);else{const o=yse(e);r={x:t.x-o.x,y:t.y-o.y,width:t.width,height:t.height}}return sR(r)}function gse(e,t){const n=li(e);return n===t||!Vr(n)||dd(n)?!1:$r(n).position==="fixed"||gse(n,t)}function o7e(e,t){const n=t.get(e);if(n)return n;let r=V2(e,[],!1).filter(s=>Vr(s)&&Rd(s)!=="body"),o=null;const a=$r(e).position==="fixed";let i=a?li(e):e;for(;Vr(i)&&!dd(i);){const s=$r(i),c=l$(i);!c&&s.position==="fixed"&&(o=null),(a?!c&&!o:!c&&s.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||yf(i)&&!c&&gse(e,i))?r=r.filter(u=>u!==i):o=s,i=li(i)}return t.set(e,r),r}function a7e(e){let{element:t,boundary:n,rootBoundary:r,strategy:o}=e;const i=[...n==="clippingAncestors"?kT(t)?[]:o7e(t,this._c):[].concat(n),r],s=yJ(t,i[0],o);let c=s.top,l=s.right,u=s.bottom,d=s.left;for(let f=1;f<i.length;f++){const p=yJ(t,i[f],o);c=Zn(p.top,c),l=ci(p.right,l),u=ci(p.bottom,u),d=Zn(p.left,d)}return{width:l-d,height:u-c,x:d,y:c}}function i7e(e){const{width:t,height:n}=pse(e);return{width:t,height:n}}function s7e(e,t,n){const r=la(t),o=Eo(t),a=n==="fixed",i=Iu(e,!0,a,t);let s={scrollLeft:0,scrollTop:0};const c=Mo(0);function l(){c.x=xT(o)}if(r||!r&&!a)if((Rd(t)!=="body"||yf(o))&&(s=vT(t)),r){const p=Iu(t,!0,a,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}else o&&l();a&&!r&&o&&l();const u=o&&!r&&!a?mse(o,s):Mo(0),d=i.left+s.scrollLeft-c.x-u.x,f=i.top+s.scrollTop-c.y-u.y;return{x:d,y:f,width:i.width,height:i.height}}function $O(e){return $r(e).position==="static"}function mJ(e,t){if(!la(e)||$r(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Eo(e)===n&&(n=n.ownerDocument.body),n}function kse(e,t){const n=er(e);if(kT(e))return n;if(!la(e)){let o=li(e);for(;o&&!dd(o);){if(Vr(o)&&!$O(o))return o;o=li(o)}return n}let r=mJ(e,t);for(;r&&Gbe(r)&&$O(r);)r=mJ(r,t);return r&&dd(r)&&$O(r)&&!l$(r)?n:r||Xbe(e)||n}const c7e=async function(e){const t=this.getOffsetParent||kse,n=this.getDimensions,r=await n(e.floating);return{reference:s7e(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function l7e(e){return $r(e).direction==="rtl"}const u7e={convertOffsetParentRelativeRectToViewportRelativeRect:Jbe,getDocumentElement:Eo,getClippingRect:a7e,getOffsetParent:kse,getElementRects:c7e,getClientRects:e7e,getDimensions:i7e,getScale:V1,isElement:Vr,isRTL:l7e};function vse(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function d7e(e,t){let n=null,r;const o=Eo(e);function a(){var s;clearTimeout(r),(s=n)==null||s.disconnect(),n=null}function i(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();const l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;const y=E0(d),k=E0(o.clientWidth-(u+f)),w=E0(o.clientHeight-(d+p)),v=E0(u),x={rootMargin:-y+"px "+-k+"px "+-w+"px "+-v+"px",threshold:Zn(0,ci(1,c))||1};let b=!0;function S(C){const L=C[0].intersectionRatio;if(L!==c){if(!b)return i();L?i(!1,L):r=setTimeout(()=>{i(!1,1e-7)},1e3)}L===1&&!vse(l,e.getBoundingClientRect())&&i(),b=!1}try{n=new IntersectionObserver(S,{...x,root:o.ownerDocument})}catch{n=new IntersectionObserver(S,x)}n.observe(e)}return i(!0),a}function h7e(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:a=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,l=d$(e),u=o||a?[...l?V2(l):[],...t?V2(t):[]]:[];u.forEach(v=>{o&&v.addEventListener("scroll",n,{passive:!0}),a&&v.addEventListener("resize",n)});const d=l&&s?d7e(l,n):null;let f=-1,p=null;i&&(p=new ResizeObserver(v=>{let[M]=v;M&&M.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var x;(x=p)==null||x.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let y,k=c?Iu(e):null;c&&w();function w(){const v=Iu(e);k&&!vse(k,v)&&n(),k=v,y=requestAnimationFrame(w)}return n(),()=>{var v;u.forEach(M=>{o&&M.removeEventListener("scroll",n),a&&M.removeEventListener("resize",n)}),d==null||d(),(v=p)==null||v.disconnect(),p=null,c&&cancelAnimationFrame(y)}}const f7e=Vbe,p7e=$be,y7e=Fbe,m7e=Wbe,g7e=Hbe,gJ=Obe,k7e=Ube,v7e=(e,t,n)=>{const r=new Map,o={platform:u7e,...n},a={...o.platform,_c:r};return qbe(e,t,{...o,platform:a})};var x7e=typeof document<"u",w7e=function(){},f_=x7e?g.useLayoutEffect:w7e;function cR(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,o;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!cR(e[r],t[r]))return!1;return!0}if(o=Object.keys(e),n=o.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,o[r]))return!1;for(r=n;r--!==0;){const a=o[r];if(!(a==="_owner"&&e.$$typeof)&&!cR(e[a],t[a]))return!1}return!0}return e!==e&&t!==t}function xse(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function kJ(e,t){const n=xse(e);return Math.round(t*n)/n}function UO(e){const t=g.useRef(e);return f_(()=>{t.current=e}),t}function M7e(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:o,elements:{reference:a,floating:i}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=g.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=g.useState(r);cR(f,r)||p(r);const[y,k]=g.useState(null),[w,v]=g.useState(null),M=g.useCallback(z=>{z!==C.current&&(C.current=z,k(z))},[]),x=g.useCallback(z=>{z!==L.current&&(L.current=z,v(z))},[]),b=a||y,S=i||w,C=g.useRef(null),L=g.useRef(null),P=g.useRef(u),T=c!=null,_=UO(c),A=UO(o),I=UO(l),V=g.useCallback(()=>{if(!C.current||!L.current)return;const z={placement:t,strategy:n,middleware:f};A.current&&(z.platform=A.current),v7e(C.current,L.current,z).then(N=>{const E={...N,isPositioned:I.current!==!1};j.current&&!cR(P.current,E)&&(P.current=E,wd.flushSync(()=>{d(E)}))})},[f,t,n,A,I]);f_(()=>{l===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,d(z=>({...z,isPositioned:!1})))},[l]);const j=g.useRef(!1);f_(()=>(j.current=!0,()=>{j.current=!1}),[]),f_(()=>{if(b&&(C.current=b),S&&(L.current=S),b&&S){if(_.current)return _.current(b,S,V);V()}},[b,S,V,_,T]);const H=g.useMemo(()=>({reference:C,floating:L,setReference:M,setFloating:x}),[M,x]),O=g.useMemo(()=>({reference:b,floating:S}),[b,S]),U=g.useMemo(()=>{const z={position:n,left:0,top:0};if(!O.floating)return z;const N=kJ(O.floating,u.x),E=kJ(O.floating,u.y);return s?{...z,transform:"translate("+N+"px, "+E+"px)",...xse(O.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:N,top:E}},[n,s,O.floating,u.x,u.y]);return g.useMemo(()=>({...u,update:V,refs:H,elements:O,floatingStyles:U}),[u,V,H,O,U])}const b7e=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:o}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?gJ({element:r.current,padding:o}).fn(n):{}:r?gJ({element:r,padding:o}).fn(n):{}}}},C7e=(e,t)=>{const n=f7e(e);return{name:n.name,fn:n.fn,options:[e,t]}},S7e=(e,t)=>{const n=p7e(e);return{name:n.name,fn:n.fn,options:[e,t]}},L7e=(e,t)=>({fn:k7e(e).fn,options:[e,t]}),I7e=(e,t)=>{const n=y7e(e);return{name:n.name,fn:n.fn,options:[e,t]}},E7e=(e,t)=>{const n=m7e(e);return{name:n.name,fn:n.fn,options:[e,t]}},A7e=(e,t)=>{const n=g7e(e);return{name:n.name,fn:n.fn,options:[e,t]}},P7e=(e,t)=>{const n=b7e(e);return{name:n.name,fn:n.fn,options:[e,t]}};var _7e="Arrow",wse=g.forwardRef((e,t)=>{const{children:n,width:r=10,height:o=5,...a}=e;return m.jsx($e.svg,{...a,ref:t,width:r,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});wse.displayName=_7e;var R7e=wse;function Mse(e){const[t,n]=g.useState(void 0);return si(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const a=o[0];let i,s;if("borderBoxSize"in a){const c=a.borderBoxSize,l=Array.isArray(c)?c[0]:c;i=l.inlineSize,s=l.blockSize}else i=e.offsetWidth,s=e.offsetHeight;n({width:i,height:s})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var h$="Popper",[bse,Td]=Kr(h$),[T7e,Cse]=bse(h$),Sse=e=>{const{__scopePopper:t,children:n}=e,[r,o]=g.useState(null);return m.jsx(T7e,{scope:t,anchor:r,onAnchorChange:o,children:n})};Sse.displayName=h$;var Lse="PopperAnchor",Ise=g.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...o}=e,a=Cse(Lse,n),i=g.useRef(null),s=pt(t,i),c=g.useRef(null);return g.useEffect(()=>{const l=c.current;c.current=(r==null?void 0:r.current)||i.current,l!==c.current&&a.onAnchorChange(c.current)}),r?null:m.jsx($e.div,{...o,ref:s})});Ise.displayName=Lse;var f$="PopperContent",[j7e,N7e]=bse(f$),Ese=g.forwardRef((e,t)=>{var oe,ee,ae,ve,Se,be;const{__scopePopper:n,side:r="bottom",sideOffset:o=0,align:a="center",alignOffset:i=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:y,...k}=e,w=Cse(f$,n),[v,M]=g.useState(null),x=pt(t,we=>M(we)),[b,S]=g.useState(null),C=Mse(b),L=(C==null?void 0:C.width)??0,P=(C==null?void 0:C.height)??0,T=r+(a!=="center"?"-"+a:""),_=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},A=Array.isArray(l)?l:[l],I=A.length>0,V={padding:_,boundary:A.filter(D7e),altBoundary:I},{refs:j,floatingStyles:H,placement:O,isPositioned:U,middlewareData:z}=M7e({strategy:"fixed",placement:T,whileElementsMounted:(...we)=>h7e(...we,{animationFrame:p==="always"}),elements:{reference:w.anchor},middleware:[C7e({mainAxis:o+P,alignmentAxis:i}),c&&S7e({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?L7e():void 0,...V}),c&&I7e({...V}),E7e({...V,apply:({elements:we,rects:te,availableWidth:ie,availableHeight:Te})=>{const{width:Ae,height:at}=te.reference,Qe=we.floating.style;Qe.setProperty("--radix-popper-available-width",`${ie}px`),Qe.setProperty("--radix-popper-available-height",`${Te}px`),Qe.setProperty("--radix-popper-anchor-width",`${Ae}px`),Qe.setProperty("--radix-popper-anchor-height",`${at}px`)}}),b&&P7e({element:b,padding:s}),q7e({arrowWidth:L,arrowHeight:P}),f&&A7e({strategy:"referenceHidden",...V})]}),[N,E]=_se(O),W=So(y);si(()=>{U&&(W==null||W())},[U,W]);const q=(oe=z.arrow)==null?void 0:oe.x,R=(ee=z.arrow)==null?void 0:ee.y,G=((ae=z.arrow)==null?void 0:ae.centerOffset)!==0,[X,Y]=g.useState();return si(()=>{v&&Y(window.getComputedStyle(v).zIndex)},[v]),m.jsx("div",{ref:j.setFloating,"data-radix-popper-content-wrapper":"",style:{...H,transform:U?H.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:X,"--radix-popper-transform-origin":[(ve=z.transformOrigin)==null?void 0:ve.x,(Se=z.transformOrigin)==null?void 0:Se.y].join(" "),...((be=z.hide)==null?void 0:be.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(j7e,{scope:n,placedSide:N,onArrowChange:S,arrowX:q,arrowY:R,shouldHideArrow:G,children:m.jsx($e.div,{"data-side":N,"data-align":E,...k,ref:x,style:{...k.style,animation:U?void 0:"none"}})})})});Ese.displayName=f$;var Ase="PopperArrow",z7e={top:"bottom",right:"left",bottom:"top",left:"right"},Pse=g.forwardRef(function(t,n){const{__scopePopper:r,...o}=t,a=N7e(Ase,r),i=z7e[a.placedSide];return m.jsx("span",{ref:a.onArrowChange,style:{position:"absolute",left:a.arrowX,top:a.arrowY,[i]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[a.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[a.placedSide],visibility:a.shouldHideArrow?"hidden":void 0},children:m.jsx(R7e,{...o,ref:n,style:{...o.style,display:"block"}})})});Pse.displayName=Ase;function D7e(e){return e!==null}var q7e=e=>({name:"transformOrigin",options:e,fn(t){var w,v,M;const{placement:n,rects:r,middlewareData:o}=t,i=((w=o.arrow)==null?void 0:w.centerOffset)!==0,s=i?0:e.arrowWidth,c=i?0:e.arrowHeight,[l,u]=_se(n),d={start:"0%",center:"50%",end:"100%"}[u],f=(((v=o.arrow)==null?void 0:v.x)??0)+s/2,p=(((M=o.arrow)==null?void 0:M.y)??0)+c/2;let y="",k="";return l==="bottom"?(y=i?d:`${f}px`,k=`${-c}px`):l==="top"?(y=i?d:`${f}px`,k=`${r.floating.height+c}px`):l==="right"?(y=`${-c}px`,k=i?d:`${p}px`):l==="left"&&(y=`${r.floating.width+c}px`,k=i?d:`${p}px`),{data:{x:y,y:k}}}});function _se(e){const[t,n="center"]=e.split("-");return[t,n]}var p$=Sse,wT=Ise,y$=Ese,m$=Pse,O7e="Portal",mf=g.forwardRef((e,t)=>{var s;const{container:n,...r}=e,[o,a]=g.useState(!1);si(()=>a(!0),[]);const i=n||o&&((s=globalThis==null?void 0:globalThis.document)==null?void 0:s.body);return i?Cfe.createPortal(m.jsx($e.div,{...r,ref:t}),i):null});mf.displayName=O7e;function F7e(e,t){return g.useReducer((n,r)=>t[n][r]??n,e)}var ir=e=>{const{present:t,children:n}=e,r=H7e(t),o=typeof n=="function"?n({present:r.isPresent}):g.Children.only(n),a=pt(r.ref,B7e(o));return typeof n=="function"||r.isPresent?g.cloneElement(o,{ref:a}):null};ir.displayName="Presence";function H7e(e){const[t,n]=g.useState(),r=g.useRef(null),o=g.useRef(e),a=g.useRef("none"),i=e?"mounted":"unmounted",[s,c]=F7e(i,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return g.useEffect(()=>{const l=A0(r.current);a.current=s==="mounted"?l:"none"},[s]),si(()=>{const l=r.current,u=o.current;if(u!==e){const f=a.current,p=A0(l);e?c("MOUNT"):p==="none"||(l==null?void 0:l.display)==="none"?c("UNMOUNT"):c(u&&f!==p?"ANIMATION_OUT":"UNMOUNT"),o.current=e}},[e,c]),si(()=>{if(t){let l;const u=t.ownerDocument.defaultView??window,d=p=>{const k=A0(r.current).includes(CSS.escape(p.animationName));if(p.target===t&&k&&(c("ANIMATION_END"),!o.current)){const w=t.style.animationFillMode;t.style.animationFillMode="forwards",l=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=w)})}},f=p=>{p.target===t&&(a.current=A0(r.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{u.clearTimeout(l),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:g.useCallback(l=>{r.current=l?getComputedStyle(l):null,n(l)},[])}}function A0(e){return(e==null?void 0:e.animationName)||"none"}function B7e(e){var r,o;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var V7e=IB[" useInsertionEffect ".trim().toString()]||si;function Ou({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[o,a,i]=$7e({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:o;{const u=g.useRef(e!==void 0);g.useEffect(()=>{const d=u.current;d!==s&&console.warn(`${r} is changing from ${d?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=s},[s,r])}const l=g.useCallback(u=>{var d;if(s){const f=U7e(u)?u(e):u;f!==e&&((d=i.current)==null||d.call(i,f))}else a(u)},[s,e,a,i]);return[c,l]}function $7e({defaultProp:e,onChange:t}){const[n,r]=g.useState(e),o=g.useRef(n),a=g.useRef(t);return V7e(()=>{a.current=t},[t]),g.useEffect(()=>{var i;o.current!==n&&((i=a.current)==null||i.call(a,n),o.current=n)},[n,o]),[n,r,a]}function U7e(e){return typeof e=="function"}var W7e=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Ju=new WeakMap,P0=new WeakMap,_0={},WO=0,Rse=function(e){return e&&(e.host||Rse(e.parentNode))},G7e=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=Rse(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},K7e=function(e,t,n,r){var o=G7e(t,Array.isArray(e)?e:[e]);_0[n]||(_0[n]=new WeakMap);var a=_0[n],i=[],s=new Set,c=new Set(o),l=function(d){!d||s.has(d)||(s.add(d),l(d.parentNode))};o.forEach(l);var u=function(d){!d||c.has(d)||Array.prototype.forEach.call(d.children,function(f){if(s.has(f))u(f);else try{var p=f.getAttribute(r),y=p!==null&&p!=="false",k=(Ju.get(f)||0)+1,w=(a.get(f)||0)+1;Ju.set(f,k),a.set(f,w),i.push(f),k===1&&y&&P0.set(f,!0),w===1&&f.setAttribute(n,"true"),y||f.setAttribute(r,"true")}catch(v){console.error("aria-hidden: cannot operate on ",f,v)}})};return u(t),s.clear(),WO++,function(){i.forEach(function(d){var f=Ju.get(d)-1,p=a.get(d)-1;Ju.set(d,f),a.set(d,p),f||(P0.has(d)||d.removeAttribute(r),P0.delete(d)),p||d.removeAttribute(n)}),WO--,WO||(Ju=new WeakMap,Ju=new WeakMap,P0=new WeakMap,_0={})}},g$=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),o=W7e(e);return o?(r.push.apply(r,Array.from(o.querySelectorAll("[aria-live], script"))),K7e(r,o,n,"aria-hidden")):function(){return null}},yo=function(){return yo=Object.assign||function(t){for(var n,r=1,o=arguments.length;r<o;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},yo.apply(this,arguments)};function Tse(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}function Z7e(e,t,n){if(n||arguments.length===2)for(var r=0,o=t.length,a;r<o;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var p_="right-scroll-bar-position",y_="width-before-scroll-bar",X7e="with-scroll-bars-hidden",Y7e="--removed-body-scroll-bar-size";function GO(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function Q7e(e,t){var n=g.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var o=n.value;o!==r&&(n.value=r,n.callback(r,o))}}}})[0];return n.callback=t,n.facade}var J7e=typeof window<"u"?g.useLayoutEffect:g.useEffect,vJ=new WeakMap;function e9e(e,t){var n=Q7e(null,function(r){return e.forEach(function(o){return GO(o,r)})});return J7e(function(){var r=vJ.get(n);if(r){var o=new Set(r),a=new Set(e),i=n.current;o.forEach(function(s){a.has(s)||GO(s,null)}),a.forEach(function(s){o.has(s)||GO(s,i)})}vJ.set(n,e)},[e]),n}function t9e(e){return e}function n9e(e,t){t===void 0&&(t=t9e);var n=[],r=!1,o={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(s){return s!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(s){return a(s)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var s=n;n=[],s.forEach(a),i=n}var c=function(){var u=i;i=[],u.forEach(a)},l=function(){return Promise.resolve().then(c)};l(),n={push:function(u){i.push(u),l()},filter:function(u){return i=i.filter(u),n}}}};return o}function r9e(e){e===void 0&&(e={});var t=n9e(null);return t.options=yo({async:!0,ssr:!1},e),t}var jse=function(e){var t=e.sideCar,n=Tse(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return g.createElement(r,yo({},n))};jse.isSideCarExport=!0;function o9e(e,t){return e.useMedium(t),jse}var Nse=r9e(),KO=function(){},MT=g.forwardRef(function(e,t){var n=g.useRef(null),r=g.useState({onScrollCapture:KO,onWheelCapture:KO,onTouchMoveCapture:KO}),o=r[0],a=r[1],i=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,y=e.noIsolation,k=e.inert,w=e.allowPinchZoom,v=e.as,M=v===void 0?"div":v,x=e.gapMode,b=Tse(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=f,C=e9e([n,t]),L=yo(yo({},b),o);return g.createElement(g.Fragment,null,u&&g.createElement(S,{sideCar:Nse,removeScrollBar:l,shards:d,noRelative:p,noIsolation:y,inert:k,setCallbacks:a,allowPinchZoom:!!w,lockRef:n,gapMode:x}),i?g.cloneElement(g.Children.only(s),yo(yo({},L),{ref:C})):g.createElement(M,yo({},L,{className:c,ref:C}),s))});MT.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};MT.classNames={fullWidth:y_,zeroRight:p_};var a9e=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function i9e(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=a9e();return t&&e.setAttribute("nonce",t),e}function s9e(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function c9e(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var l9e=function(){var e=0,t=null;return{add:function(n){e==0&&(t=i9e())&&(s9e(t,n),c9e(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},u9e=function(){var e=l9e();return function(t,n){g.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},zse=function(){var e=u9e(),t=function(n){var r=n.styles,o=n.dynamic;return e(r,o),null};return t},d9e={left:0,top:0,right:0,gap:0},ZO=function(e){return parseInt(e||"",10)||0},h9e=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],o=t[e==="padding"?"paddingRight":"marginRight"];return[ZO(n),ZO(r),ZO(o)]},f9e=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return d9e;var t=h9e(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},p9e=zse(),$1="data-scroll-locked",y9e=function(e,t,n,r){var o=e.left,a=e.top,i=e.right,s=e.gap;return n===void 0&&(n="margin"),`
|
|
7764
7764
|
.`.concat(X7e,` {
|
|
7765
7765
|
overflow: hidden `).concat(r,`;
|
|
7766
7766
|
padding-right: `).concat(s,"px ").concat(r,`;
|
|
@@ -7832,7 +7832,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
7832
7832
|
`))+1))}const i="#".repeat(o),s=n.enter("headingAtx"),c=n.enter("phrasing");a.move(i+" ");let l=n.containerPhrasing(e,{before:"# ",after:`
|
|
7833
7833
|
`,...a.current()});return/^[\t ]/.test(l)&&(l=K2(l.charCodeAt(0))+l.slice(1)),l=l?i+" "+l:i,n.options.closeAtx&&(l+=" "+i),c(),s(),l}P1e.peek=qTe;function P1e(e){return e.value||""}function qTe(){return"<"}_1e.peek=OTe;function _1e(e,t,n,r){const o=J$(n),a=o==='"'?"Quote":"Apostrophe",i=n.enter("image");let s=n.enter("label");const c=n.createTracker(r);let l=c.move("![");return l+=c.move(n.safe(e.alt,{before:l,after:"]",...c.current()})),l+=c.move("]("),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter("destinationLiteral"),l+=c.move("<"),l+=c.move(n.safe(e.url,{before:l,after:">",...c.current()})),l+=c.move(">")):(s=n.enter("destinationRaw"),l+=c.move(n.safe(e.url,{before:l,after:e.title?" ":")",...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(" "+o),l+=c.move(n.safe(e.title,{before:l,after:o,...c.current()})),l+=c.move(o),s()),l+=c.move(")"),i(),l}function OTe(){return"!"}R1e.peek=FTe;function R1e(e,t,n,r){const o=e.referenceType,a=n.enter("imageReference");let i=n.enter("label");const s=n.createTracker(r);let c=s.move("![");const l=n.safe(e.alt,{before:c,after:"]",...s.current()});c+=s.move(l+"]["),i();const u=n.stack;n.stack=[],i=n.enter("reference");const d=n.safe(n.associationId(e),{before:c,after:"]",...s.current()});return i(),n.stack=u,a(),o==="full"||!l||l!==d?c+=s.move(d+"]"):o==="shortcut"?c=c.slice(0,-1):c+=s.move("]"),c}function FTe(){return"!"}T1e.peek=HTe;function T1e(e,t,n){let r=e.value||"",o="`",a=-1;for(;new RegExp("(^|[^`])"+o+"([^`]|$)").test(r);)o+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++a<n.unsafe.length;){const i=n.unsafe[a],s=n.compilePattern(i);let c;if(i.atBreak)for(;c=s.exec(r);){let l=c.index;r.charCodeAt(l)===10&&r.charCodeAt(l-1)===13&&l--,r=r.slice(0,l)+" "+r.slice(c.index+1)}}return o+r+o}function HTe(){return"`"}function j1e(e,t){const n=$$(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}N1e.peek=BTe;function N1e(e,t,n,r){const o=J$(n),a=o==='"'?"Quote":"Apostrophe",i=n.createTracker(r);let s,c;if(j1e(e,n)){const u=n.stack;n.stack=[],s=n.enter("autolink");let d=i.move("<");return d+=i.move(n.containerPhrasing(e,{before:d,after:">",...i.current()})),d+=i.move(">"),s(),n.stack=u,d}s=n.enter("link"),c=n.enter("label");let l=i.move("[");return l+=i.move(n.containerPhrasing(e,{before:l,after:"](",...i.current()})),l+=i.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),l+=i.move("<"),l+=i.move(n.safe(e.url,{before:l,after:">",...i.current()})),l+=i.move(">")):(c=n.enter("destinationRaw"),l+=i.move(n.safe(e.url,{before:l,after:e.title?" ":")",...i.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=i.move(" "+o),l+=i.move(n.safe(e.title,{before:l,after:o,...i.current()})),l+=i.move(o),c()),l+=i.move(")"),s(),l}function BTe(e,t,n){return j1e(e,n)?"<":"["}z1e.peek=VTe;function z1e(e,t,n,r){const o=e.referenceType,a=n.enter("linkReference");let i=n.enter("label");const s=n.createTracker(r);let c=s.move("[");const l=n.containerPhrasing(e,{before:c,after:"]",...s.current()});c+=s.move(l+"]["),i();const u=n.stack;n.stack=[],i=n.enter("reference");const d=n.safe(n.associationId(e),{before:c,after:"]",...s.current()});return i(),n.stack=u,a(),o==="full"||!l||l!==d?c+=s.move(d+"]"):o==="shortcut"?c=c.slice(0,-1):c+=s.move("]"),c}function VTe(){return"["}function eU(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function $Te(e){const t=eU(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function UTe(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function D1e(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function WTe(e,t,n,r){const o=n.enter("list"),a=n.bulletCurrent;let i=e.ordered?UTe(n):eU(n);const s=e.ordered?i==="."?")":".":$Te(n);let c=t&&n.bulletLastUsed?i===n.bulletLastUsed:!1;if(!e.ordered){const u=e.children?e.children[0]:void 0;if((i==="*"||i==="-")&&u&&(!u.children||!u.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),D1e(n)===i&&u){let d=-1;for(;++d<e.children.length;){const f=e.children[d];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){c=!0;break}}}}c&&(i=s),n.bulletCurrent=i;const l=n.containerFlow(e,r);return n.bulletLastUsed=i,n.bulletCurrent=a,o(),l}function GTe(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function KTe(e,t,n,r){const o=GTe(n);let a=n.bulletCurrent||eU(n);t&&t.type==="list"&&t.ordered&&(a=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let i=a.length+1;(o==="tab"||o==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(i=Math.ceil(i/4)*4);const s=n.createTracker(r);s.move(a+" ".repeat(i-a.length)),s.shift(i);const c=n.enter("listItem"),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(d,f,p){return f?(p?"":" ".repeat(i))+d:(p?a:a+" ".repeat(i-a.length))+d}}function ZTe(e,t,n,r){const o=n.enter("paragraph"),a=n.enter("phrasing"),i=n.containerPhrasing(e,r);return a(),o(),i}const XTe=GT(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function YTe(e,t,n,r){return(e.children.some(function(i){return XTe(i)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function QTe(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}q1e.peek=JTe;function q1e(e,t,n,r){const o=QTe(n),a=n.enter("strong"),i=n.createTracker(r),s=i.move(o+o);let c=i.move(n.containerPhrasing(e,{after:o,before:s,...i.current()}));const l=c.charCodeAt(0),u=kR(r.before.charCodeAt(r.before.length-1),l,o);u.inside&&(c=K2(l)+c.slice(1));const d=c.charCodeAt(c.length-1),f=kR(r.after.charCodeAt(0),d,o);f.inside&&(c=c.slice(0,-1)+K2(d));const p=i.move(o+o);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function JTe(e,t,n){return n.options.strong||"*"}function eje(e,t,n,r){return n.safe(e.value,r)}function tje(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function nje(e,t,n){const r=(D1e(n)+(n.options.ruleSpaces?" ":"")).repeat(tje(n));return n.options.ruleSpaces?r.slice(0,-1):r}const O1e={blockquote:STe,break:Pee,code:_Te,definition:TTe,emphasis:A1e,hardBreak:Pee,heading:DTe,html:P1e,image:_1e,imageReference:R1e,inlineCode:T1e,link:N1e,linkReference:z1e,list:WTe,listItem:KTe,paragraph:ZTe,root:YTe,strong:q1e,text:eje,thematicBreak:nje};function rje(){return{enter:{table:oje,tableData:_ee,tableHeader:_ee,tableRow:ije},exit:{codeText:sje,table:aje,tableData:yF,tableHeader:yF,tableRow:yF}}}function oje(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function aje(e){this.exit(e),this.data.inTable=void 0}function ije(e){this.enter({type:"tableRow",children:[]},e)}function yF(e){this.exit(e)}function _ee(e){this.enter({type:"tableCell",children:[]},e)}function sje(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,cje));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function cje(e,t){return t==="|"?t:e}function lje(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,o=t.stringLength,a=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
|
|
7834
7834
|
`,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:i,tableCell:c,tableRow:s}};function i(p,y,k,w){return l(u(p,k,w),p.align)}function s(p,y,k,w){const v=d(p,k,w),M=l([v]);return M.slice(0,M.indexOf(`
|
|
7835
|
-
`))}function c(p,y,k,w){const v=k.enter("tableCell"),M=k.enter("phrasing"),x=k.containerPhrasing(p,{...w,before:a,after:a});return M(),v(),x}function l(p,y){return bTe(p,{align:y,alignDelimiters:r,padding:n,stringLength:o})}function u(p,y,k){const w=p.children;let v=-1;const M=[],x=y.enter("table");for(;++v<w.length;)M[v]=d(w[v],y,k);return x(),M}function d(p,y,k){const w=p.children;let v=-1;const M=[],x=y.enter("tableRow");for(;++v<w.length;)M[v]=c(w[v],p,y,k);return x(),M}function f(p,y,k){let w=O1e.inlineCode(p,y,k);return k.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function uje(){return{exit:{taskListCheckValueChecked:Ree,taskListCheckValueUnchecked:Ree,paragraph:hje}}}function dje(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:fje}}}function Ree(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function hje(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const o=t.children;let a=-1,i;for(;++a<o.length;){const s=o[a];if(s.type==="paragraph"){i=s;break}}i===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function fje(e,t,n,r){const o=e.children[0],a=typeof e.checked=="boolean"&&o&&o.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",s=n.createTracker(r);a&&s.move(i);let c=O1e.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(u){return u+i}}function pje(){return[WRe(),fTe(),gTe(),rje(),uje()]}function yje(e){return{extensions:[GRe(),pTe(e),kTe(),lje(e),dje()]}}const mje={tokenize:Mje,partial:!0},F1e={tokenize:bje,partial:!0},H1e={tokenize:Cje,partial:!0},B1e={tokenize:Sje,partial:!0},gje={tokenize:Lje,partial:!0},V1e={name:"wwwAutolink",tokenize:xje,previous:U1e},$1e={name:"protocolAutolink",tokenize:wje,previous:W1e},ua={name:"emailAutolink",tokenize:vje,previous:G1e},Ao={};function kje(){return{text:Ao}}let _i=48;for(;_i<123;)Ao[_i]=ua,_i++,_i===58?_i=65:_i===91&&(_i=97);Ao[43]=ua;Ao[45]=ua;Ao[46]=ua;Ao[95]=ua;Ao[72]=[ua,$1e];Ao[104]=[ua,$1e];Ao[87]=[ua,V1e];Ao[119]=[ua,V1e];function vje(e,t,n){const r=this;let o,a;return i;function i(d){return!yB(d)||!G1e.call(r,r.previous)||tU(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(d))}function s(d){return yB(d)?(e.consume(d),s):d===64?(e.consume(d),c):n(d)}function c(d){return d===46?e.check(gje,u,l)(d):d===45||d===95||an(d)?(a=!0,e.consume(d),c):u(d)}function l(d){return e.consume(d),o=!0,c}function u(d){return a&&o&&fn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function xje(e,t,n){const r=this;return o;function o(i){return i!==87&&i!==119||!U1e.call(r,r.previous)||tU(r.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(mje,e.attempt(F1e,e.attempt(H1e,a),n),n)(i))}function a(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function wje(e,t,n){const r=this;let o="",a=!1;return i;function i(d){return(d===72||d===104)&&W1e.call(r,r.previous)&&!tU(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(d),e.consume(d),s):n(d)}function s(d){if(fn(d)&&o.length<5)return o+=String.fromCodePoint(d),e.consume(d),s;if(d===58){const f=o.toLowerCase();if(f==="http"||f==="https")return e.consume(d),c}return n(d)}function c(d){return d===47?(e.consume(d),a?l:(a=!0,c)):n(d)}function l(d){return d===null||yR(d)||ft(d)||Pu(d)||$T(d)?n(d):e.attempt(F1e,e.attempt(H1e,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function Mje(e,t,n){let r=0;return o;function o(i){return(i===87||i===119)&&r<3?(r++,e.consume(i),o):i===46&&r===3?(e.consume(i),a):n(i)}function a(i){return i===null?n(i):t(i)}}function bje(e,t,n){let r,o,a;return i;function i(l){return l===46||l===95?e.check(B1e,c,s)(l):l===null||ft(l)||Pu(l)||l!==45&&$T(l)?c(l):(a=!0,e.consume(l),i)}function s(l){return l===95?r=!0:(o=r,r=void 0),e.consume(l),i}function c(l){return o||r||!a?n(l):t(l)}}function Cje(e,t){let n=0,r=0;return o;function o(i){return i===40?(n++,e.consume(i),o):i===41&&r<n?a(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(B1e,t,a)(i):i===null||ft(i)||Pu(i)?t(i):(e.consume(i),o)}function a(i){return i===41&&r++,e.consume(i),o}}function Sje(e,t,n){return r;function r(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),r):s===38?(e.consume(s),a):s===93?(e.consume(s),o):s===60||s===null||ft(s)||Pu(s)?t(s):n(s)}function o(s){return s===null||s===40||s===91||ft(s)||Pu(s)?t(s):r(s)}function a(s){return fn(s)?i(s):n(s)}function i(s){return s===59?(e.consume(s),r):fn(s)?(e.consume(s),i):n(s)}}function Lje(e,t,n){return r;function r(a){return e.consume(a),o}function o(a){return an(a)?n(a):t(a)}}function U1e(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ft(e)}function W1e(e){return!fn(e)}function G1e(e){return!(e===47||yB(e))}function yB(e){return e===43||e===45||e===46||e===95||an(e)}function tU(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Ije={tokenize:Nje,partial:!0};function Eje(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Rje,continuation:{tokenize:Tje},exit:jje}},text:{91:{name:"gfmFootnoteCall",tokenize:_je},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Aje,resolveTo:Pje}}}}function Aje(e,t,n){const r=this;let o=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;o--;){const c=r.events[o][1];if(c.type==="labelImage"){i=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return s;function s(c){if(!i||!i._balanced)return n(c);const l=Hr(r.sliceSerialize({start:i.end,end:r.now()}));return l.codePointAt(0)!==94||!a.includes(l.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function Pje(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",o,t],["exit",o,t],["enter",a,t],["enter",i,t],["exit",i,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...s),e}function _je(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,i;return s;function s(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),c}function c(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(d){if(a>999||d===93&&!i||d===null||d===91||ft(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return o.includes(Hr(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return ft(d)||(i=!0),a++,e.consume(d),d===92?u:l}function u(d){return d===91||d===92||d===93?(e.consume(d),a++,l):l(d)}}function Rje(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,i=0,s;return c;function c(y){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),l}function l(y){return y===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(y)}function u(y){if(i>999||y===93&&!s||y===null||y===91||ft(y))return n(y);if(y===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return a=Hr(r.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return ft(y)||(s=!0),i++,e.consume(y),y===92?d:u}function d(y){return y===91||y===92||y===93?(e.consume(y),i++,u):u(y)}function f(y){return y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),o.includes(a)||o.push(a),et(e,p,"gfmFootnoteDefinitionWhitespace")):n(y)}function p(y){return t(y)}}function Tje(e,t,n){return e.check(Df,t,e.attempt(Ije,t,n))}function jje(e){e.exit("gfmFootnoteDefinition")}function Nje(e,t,n){const r=this;return et(e,o,"gfmFootnoteDefinitionIndent",5);function o(a){const i=r.events[r.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(a):n(a)}}function zje(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:o};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function o(i,s){let c=-1;for(;++c<i.length;)if(i[c][0]==="enter"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._close){let l=c;for(;l--;)if(i[l][0]==="exit"&&i[l][1].type==="strikethroughSequenceTemporary"&&i[l][1]._open&&i[c][1].end.offset-i[c][1].start.offset===i[l][1].end.offset-i[l][1].start.offset){i[c][1].type="strikethroughSequence",i[l][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},i[l][1].start),end:Object.assign({},i[c][1].end)},d={type:"strikethroughText",start:Object.assign({},i[l][1].end),end:Object.assign({},i[c][1].start)},f=[["enter",u,s],["enter",i[l][1],s],["exit",i[l][1],s],["enter",d,s]],p=s.parser.constructs.insideSpan.null;p&&tr(f,f.length,0,UT(p,i.slice(l+1,c),s)),tr(f,f.length,0,[["exit",d,s],["enter",i[c][1],s],["exit",i[c][1],s],["exit",u,s]]),tr(i,l-1,c-l+3,f),c=l+f.length-2;break}}for(c=-1;++c<i.length;)i[c][1].type==="strikethroughSequenceTemporary"&&(i[c][1].type="data");return i}function a(i,s,c){const l=this.previous,u=this.events;let d=0;return f;function f(y){return l===126&&u[u.length-1][1].type!=="characterEscape"?c(y):(i.enter("strikethroughSequenceTemporary"),p(y))}function p(y){const k=yd(l);if(y===126)return d>1?c(y):(i.consume(y),d++,p);if(d<2&&!n)return c(y);const w=i.exit("strikethroughSequenceTemporary"),v=yd(y);return w._open=!v||v===2&&!!k,w._close=!k||k===2&&!!v,s(y)}}}class Dje{constructor(){this.map=[]}add(t,n,r){qje(this,t,n,r)}consume(t){if(this.map.sort(function(a,i){return a[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let o=r.pop();for(;o;){for(const a of o)t.push(a);o=r.pop()}this.map.length=0}}function qje(e,t,n,r){let o=0;if(!(n===0&&r.length===0)){for(;o<e.map.length;){if(e.map[o][0]===t){e.map[o][1]+=n,e.map[o][2].push(...r);return}o+=1}e.map.push([t,n,r])}}function Oje(e,t){let n=!1;const r=[];for(;t<e.length;){const o=e[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Fje(){return{flow:{null:{name:"table",tokenize:Hje,resolveAll:Bje}}}}function Hje(e,t,n){const r=this;let o=0,a=0,i;return s;function s(_){let A=r.events.length-1;for(;A>-1;){const j=r.events[A][1].type;if(j==="lineEnding"||j==="linePrefix")A--;else break}const I=A>-1?r.events[A][1].type:null,V=I==="tableHead"||I==="tableRow"?C:c;return V===C&&r.parser.lazy[r.now().line]?n(_):V(_)}function c(_){return e.enter("tableHead"),e.enter("tableRow"),l(_)}function l(_){return _===124||(i=!0,a+=1),u(_)}function u(_){return _===null?n(_):De(_)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),p):n(_):Xe(_)?et(e,u,"whitespace")(_):(a+=1,i&&(i=!1,o+=1),_===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),i=!0,u):(e.enter("data"),d(_)))}function d(_){return _===null||_===124||ft(_)?(e.exit("data"),u(_)):(e.consume(_),_===92?f:d)}function f(_){return _===92||_===124?(e.consume(_),d):d(_)}function p(_){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(_):(e.enter("tableDelimiterRow"),i=!1,Xe(_)?et(e,y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):y(_))}function y(_){return _===45||_===58?w(_):_===124?(i=!0,e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),k):S(_)}function k(_){return Xe(_)?et(e,w,"whitespace")(_):w(_)}function w(_){return _===58?(a+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),v):_===45?(a+=1,v(_)):_===null||De(_)?b(_):S(_)}function v(_){return _===45?(e.enter("tableDelimiterFiller"),M(_)):S(_)}function M(_){return _===45?(e.consume(_),M):_===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(_))}function x(_){return Xe(_)?et(e,b,"whitespace")(_):b(_)}function b(_){return _===124?y(_):_===null||De(_)?!i||o!==a?S(_):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(_)):S(_)}function S(_){return n(_)}function C(_){return e.enter("tableRow"),L(_)}function L(_){return _===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),L):_===null||De(_)?(e.exit("tableRow"),t(_)):Xe(_)?et(e,L,"whitespace")(_):(e.enter("data"),P(_))}function P(_){return _===null||_===124||ft(_)?(e.exit("data"),L(_)):(e.consume(_),_===92?T:P)}function T(_){return _===92||_===124?(e.consume(_),P):P(_)}}function Bje(e,t){let n=-1,r=!0,o=0,a=[0,0,0,0],i=[0,0,0,0],s=!1,c=0,l,u,d;const f=new Dje;for(;++n<e.length;){const p=e[n],y=p[1];p[0]==="enter"?y.type==="tableHead"?(s=!1,c!==0&&(Tee(f,t,c,l,u),u=void 0,c=0),l={type:"table",start:Object.assign({},y.start),end:Object.assign({},y.end)},f.add(n,0,[["enter",l,t]])):y.type==="tableRow"||y.type==="tableDelimiterRow"?(r=!0,d=void 0,a=[0,0,0,0],i=[0,n+1,0,0],s&&(s=!1,u={type:"tableBody",start:Object.assign({},y.start),end:Object.assign({},y.end)},f.add(n,0,[["enter",u,t]])),o=y.type==="tableDelimiterRow"?2:u?3:1):o&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")?(r=!1,i[2]===0&&(a[1]!==0&&(i[0]=i[1],d=H0(f,t,a,o,void 0,d),a=[0,0,0,0]),i[2]=n)):y.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(i[0]=i[1],d=H0(f,t,a,o,void 0,d)),a=i,i=[a[1],n,0,0])):y.type==="tableHead"?(s=!0,c=n):y.type==="tableRow"||y.type==="tableDelimiterRow"?(c=n,a[1]!==0?(i[0]=i[1],d=H0(f,t,a,o,n,d)):i[1]!==0&&(d=H0(f,t,i,o,n,d)),o=0):o&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(i[3]=n)}for(c!==0&&Tee(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=Oje(t.events,n))}return e}function H0(e,t,n,r,o,a){const i=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},u1(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const c=u1(t.events,n[1]);if(a={type:i,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const l=u1(t.events,n[2]),u=u1(t.events,n[3]),d={type:s,start:Object.assign({},l),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const y=n[2]+1,k=n[3]-n[2]-1;e.add(y,k,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return o!==void 0&&(a.end=Object.assign({},u1(t.events,o)),e.add(o,0,[["exit",a,t]]),a=void 0),a}function Tee(e,t,n,r,o){const a=[],i=u1(t.events,n);o&&(o.end=Object.assign({},i),a.push(["exit",o,t])),r.end=Object.assign({},i),a.push(["exit",r,t]),e.add(n+1,0,a)}function u1(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Vje={name:"tasklistCheck",tokenize:Uje};function $je(){return{text:{91:Vje}}}function Uje(e,t,n){const r=this;return o;function o(c){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),a)}function a(c){return ft(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),i):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),i):n(c)}function i(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(c)}function s(c){return De(c)?t(c):Xe(c)?e.check({tokenize:Wje},t,n)(c):n(c)}}function Wje(e,t,n){return et(e,r,"whitespace");function r(o){return o===null?n(o):t(o)}}function Gje(e){return r1e([kje(),Eje(),zje(e),Fje(),$je()])}const Kje={};function Zje(e){const t=this,n=e||Kje,r=t.data(),o=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),i=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);o.push(Gje(n)),a.push(pje()),i.push(yje(n))}function Xje({demoId:e,node:t,connector:n,adapter:r,onNameChange:o,onDescriptionChange:a,onDetailChange:i,onIconChange:s,statusReport:c,onClose:l}){const u=(t==null?void 0:t.type)==="shapeNode"&&t.data.shape==="text",d=(t==null?void 0:t.type)==="shapeNode"?t.data.shape:void 0,f=d==="ellipse"||d==="sticky",p=u?null:t,y=p!==null||n!==null,k=p&&"name"in p.data?p.data.name??"":"",w=(p==null?void 0:p.data.description)??"",v=(p==null?void 0:p.data.detail)??"",M=p!==null&&!f,x=p!==null&&(p.type==="playNode"||p.type==="stateNode"),b=x&&typeof s=="function",S=x&&p&&"icon"in p.data?p.data.icon??null:null,[C,L]=g.useState(()=>Q8e()),P=_=>{_.preventDefault(),eMe(C,_.clientX,{onWidth:L,onCommit:J8e})},T={"--detail-panel-w":`${C}px`};return m.jsx(EIe,{open:y,modal:!1,onOpenChange:_=>{_||l()},children:m.jsxs(due,{side:"right",className:"sf:overflow-y-auto sf:bg-card/94 sf:backdrop-blur-[14px] sf:border-border sf:sm:w-(--detail-panel-w)! sf:sm:max-w-(--detail-panel-w)!",style:T,"data-testid":"detail-panel",onEscapeKeyDown:_=>{var I;const A=document.activeElement;(I=A==null?void 0:A.getAttribute("data-testid"))!=null&&I.endsWith("-editor")&&_.preventDefault()},onInteractOutside:_=>{var V;const A=document.activeElement;(V=A==null?void 0:A.getAttribute("data-testid"))!=null&&V.endsWith("-editor")&&A.blur();const I=_.target;I!=null&&I.closest(".react-flow__resize-control")&&_.preventDefault(),I!=null&&I.closest("[data-radix-popper-content-wrapper]")&&_.preventDefault(),I!=null&&I.closest('[data-testid="canvas-style-strip"]')&&_.preventDefault(),I!=null&&I.closest(".react-flow__node")&&_.preventDefault(),I!=null&&I.closest(".react-flow__edge")&&_.preventDefault()},children:[m.jsx("div",{"aria-label":"Resize detail panel",onPointerDown:P,"data-testid":"detail-panel-resize-handle",className:"sf:absolute sf:inset-y-0 sf:left-0 sf:z-10 sf:hidden sf:w-1.5 sf:cursor-col-resize sf:bg-transparent sf:transition-colors sf:hover:bg-border sf:sm:block"}),p?m.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-3",children:[m.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1",children:[M?m.jsx(m_,{"data-testid":"detail-panel-title",children:m.jsxs("div",{className:"sf:flex sf:items-center sf:gap-2",children:[b&&s?m.jsx(Yje,{nodeId:p.id,icon:S,onChange:s}):x&&S?m.jsx("span",{"data-testid":"detail-panel-icon-readonly","aria-hidden":!0,className:"sf:inline-flex sf:h-7 sf:w-7 sf:shrink-0 sf:items-center sf:justify-center sf:text-foreground",children:m.jsx(Lu,{name:S,size:16})}):null,m.jsx("div",{className:"sf:min-w-0 sf:flex-1",children:m.jsx(mF,{nodeId:p.id,value:k,placeholder:"Name",multiline:!1,ariaLabel:"Name",testIdBase:"detail-panel-name",onSave:o,textClassName:"sf:text-base sf:font-semibold"})})]})}):m.jsx(m_,{"data-testid":"detail-panel-title",className:"sr-only",children:p.id}),m.jsxs(JH,{className:"sr-only",children:[p.id," · ",p.type]})]}),m.jsxs("div",{className:"sf:mt-0 sf:flex sf:flex-col sf:gap-3",children:[c?m.jsx(tNe,{report:c}):null,m.jsx(mF,{nodeId:p.id,value:w,placeholder:"Short description shown on the node body",multiline:!0,ariaLabel:"Description",testIdBase:"detail-panel-description",onSave:a,textClassName:"sf:font-medium sf:text-muted-foreground"}),m.jsx(mF,{nodeId:p.id,value:v,placeholder:"Long-form notes, context, anything…",multiline:!0,ariaLabel:"Detail",testIdBase:"detail-panel-detail",onSave:i,markdown:!0}),p.type==="htmlNode"&&e?m.jsx(Qje,{adapter:r,htmlPath:p.data.htmlPath}):null]})]}):n?m.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-3",children:[m.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1",children:[m.jsx(m_,{"data-testid":"detail-panel-title",children:n.label??"Connector"}),m.jsxs(JH,{className:"sr-only",children:[n.id," · ",n.kind]})]}),m.jsx("div",{className:"sf:mt-0 sf:flex sf:flex-col sf:gap-3",children:m.jsx(nNe,{connector:n})})]}):null]})})}function mF({nodeId:e,value:t,placeholder:n,multiline:r,ariaLabel:o,testIdBase:a,onSave:i,textClassName:s,markdown:c=!1}){const[l,u]=g.useState(!1),d=g.useRef(null),f=g.useRef(!1);g.useEffect(()=>{if(!l)return;const S=d.current;if(!S)return;S.textContent=t,S.focus();const C=window.getSelection();if(C){const L=document.createRange();L.selectNodeContents(S),L.collapse(!1),C.removeAllRanges(),C.addRange(L)}},[l,t]);const p=t==="";if(!i)return m.jsx("div",{"data-testid":a,"aria-label":o,className:ce("sf:w-full sf:rounded-md sf:px-2 sf:py-1.5 sf:text-sm",p?"sf:italic sf:text-muted-foreground/50":"text-foreground",!c&&"sf:whitespace-pre-wrap sf:wrap-break-word",s),children:p?n:c?m.jsx(jee,{value:t}):t});const y=()=>{var C;const S=((C=d.current)==null?void 0:C.textContent)??t;i(e,S),u(!1)},k=()=>{u(!1)},w=S=>{if(S.stopPropagation(),S.nativeEvent.stopPropagation(),S.key==="Escape"){S.preventDefault(),f.current=!0,k();return}if(S.key==="Enter"){if(S.preventDefault(),S.shiftKey||!r){y();return}document.execCommand("insertText",!1,`
|
|
7835
|
+
`))}function c(p,y,k,w){const v=k.enter("tableCell"),M=k.enter("phrasing"),x=k.containerPhrasing(p,{...w,before:a,after:a});return M(),v(),x}function l(p,y){return bTe(p,{align:y,alignDelimiters:r,padding:n,stringLength:o})}function u(p,y,k){const w=p.children;let v=-1;const M=[],x=y.enter("table");for(;++v<w.length;)M[v]=d(w[v],y,k);return x(),M}function d(p,y,k){const w=p.children;let v=-1;const M=[],x=y.enter("tableRow");for(;++v<w.length;)M[v]=c(w[v],p,y,k);return x(),M}function f(p,y,k){let w=O1e.inlineCode(p,y,k);return k.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function uje(){return{exit:{taskListCheckValueChecked:Ree,taskListCheckValueUnchecked:Ree,paragraph:hje}}}function dje(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:fje}}}function Ree(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function hje(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const o=t.children;let a=-1,i;for(;++a<o.length;){const s=o[a];if(s.type==="paragraph"){i=s;break}}i===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function fje(e,t,n,r){const o=e.children[0],a=typeof e.checked=="boolean"&&o&&o.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",s=n.createTracker(r);a&&s.move(i);let c=O1e.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(u){return u+i}}function pje(){return[WRe(),fTe(),gTe(),rje(),uje()]}function yje(e){return{extensions:[GRe(),pTe(e),kTe(),lje(e),dje()]}}const mje={tokenize:Mje,partial:!0},F1e={tokenize:bje,partial:!0},H1e={tokenize:Cje,partial:!0},B1e={tokenize:Sje,partial:!0},gje={tokenize:Lje,partial:!0},V1e={name:"wwwAutolink",tokenize:xje,previous:U1e},$1e={name:"protocolAutolink",tokenize:wje,previous:W1e},ua={name:"emailAutolink",tokenize:vje,previous:G1e},Ao={};function kje(){return{text:Ao}}let _i=48;for(;_i<123;)Ao[_i]=ua,_i++,_i===58?_i=65:_i===91&&(_i=97);Ao[43]=ua;Ao[45]=ua;Ao[46]=ua;Ao[95]=ua;Ao[72]=[ua,$1e];Ao[104]=[ua,$1e];Ao[87]=[ua,V1e];Ao[119]=[ua,V1e];function vje(e,t,n){const r=this;let o,a;return i;function i(d){return!yB(d)||!G1e.call(r,r.previous)||tU(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(d))}function s(d){return yB(d)?(e.consume(d),s):d===64?(e.consume(d),c):n(d)}function c(d){return d===46?e.check(gje,u,l)(d):d===45||d===95||an(d)?(a=!0,e.consume(d),c):u(d)}function l(d){return e.consume(d),o=!0,c}function u(d){return a&&o&&fn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function xje(e,t,n){const r=this;return o;function o(i){return i!==87&&i!==119||!U1e.call(r,r.previous)||tU(r.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(mje,e.attempt(F1e,e.attempt(H1e,a),n),n)(i))}function a(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function wje(e,t,n){const r=this;let o="",a=!1;return i;function i(d){return(d===72||d===104)&&W1e.call(r,r.previous)&&!tU(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(d),e.consume(d),s):n(d)}function s(d){if(fn(d)&&o.length<5)return o+=String.fromCodePoint(d),e.consume(d),s;if(d===58){const f=o.toLowerCase();if(f==="http"||f==="https")return e.consume(d),c}return n(d)}function c(d){return d===47?(e.consume(d),a?l:(a=!0,c)):n(d)}function l(d){return d===null||yR(d)||ft(d)||Pu(d)||$T(d)?n(d):e.attempt(F1e,e.attempt(H1e,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function Mje(e,t,n){let r=0;return o;function o(i){return(i===87||i===119)&&r<3?(r++,e.consume(i),o):i===46&&r===3?(e.consume(i),a):n(i)}function a(i){return i===null?n(i):t(i)}}function bje(e,t,n){let r,o,a;return i;function i(l){return l===46||l===95?e.check(B1e,c,s)(l):l===null||ft(l)||Pu(l)||l!==45&&$T(l)?c(l):(a=!0,e.consume(l),i)}function s(l){return l===95?r=!0:(o=r,r=void 0),e.consume(l),i}function c(l){return o||r||!a?n(l):t(l)}}function Cje(e,t){let n=0,r=0;return o;function o(i){return i===40?(n++,e.consume(i),o):i===41&&r<n?a(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(B1e,t,a)(i):i===null||ft(i)||Pu(i)?t(i):(e.consume(i),o)}function a(i){return i===41&&r++,e.consume(i),o}}function Sje(e,t,n){return r;function r(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),r):s===38?(e.consume(s),a):s===93?(e.consume(s),o):s===60||s===null||ft(s)||Pu(s)?t(s):n(s)}function o(s){return s===null||s===40||s===91||ft(s)||Pu(s)?t(s):r(s)}function a(s){return fn(s)?i(s):n(s)}function i(s){return s===59?(e.consume(s),r):fn(s)?(e.consume(s),i):n(s)}}function Lje(e,t,n){return r;function r(a){return e.consume(a),o}function o(a){return an(a)?n(a):t(a)}}function U1e(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||ft(e)}function W1e(e){return!fn(e)}function G1e(e){return!(e===47||yB(e))}function yB(e){return e===43||e===45||e===46||e===95||an(e)}function tU(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Ije={tokenize:Nje,partial:!0};function Eje(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Rje,continuation:{tokenize:Tje},exit:jje}},text:{91:{name:"gfmFootnoteCall",tokenize:_je},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Aje,resolveTo:Pje}}}}function Aje(e,t,n){const r=this;let o=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;o--;){const c=r.events[o][1];if(c.type==="labelImage"){i=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return s;function s(c){if(!i||!i._balanced)return n(c);const l=Hr(r.sliceSerialize({start:i.end,end:r.now()}));return l.codePointAt(0)!==94||!a.includes(l.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function Pje(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},o={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};o.end.column++,o.end.offset++,o.end._bufferIndex++;const a={type:"gfmFootnoteCallString",start:Object.assign({},o.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",o,t],["exit",o,t],["enter",a,t],["enter",i,t],["exit",i,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...s),e}function _je(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,i;return s;function s(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),c}function c(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",l)}function l(d){if(a>999||d===93&&!i||d===null||d===91||ft(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return o.includes(Hr(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return ft(d)||(i=!0),a++,e.consume(d),d===92?u:l}function u(d){return d===91||d===92||d===93?(e.consume(d),a++,l):l(d)}}function Rje(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,i=0,s;return c;function c(y){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),l}function l(y){return y===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",u):n(y)}function u(y){if(i>999||y===93&&!s||y===null||y===91||ft(y))return n(y);if(y===93){e.exit("chunkString");const k=e.exit("gfmFootnoteDefinitionLabelString");return a=Hr(r.sliceSerialize(k)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(y),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return ft(y)||(s=!0),i++,e.consume(y),y===92?d:u}function d(y){return y===91||y===92||y===93?(e.consume(y),i++,u):u(y)}function f(y){return y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),o.includes(a)||o.push(a),et(e,p,"gfmFootnoteDefinitionWhitespace")):n(y)}function p(y){return t(y)}}function Tje(e,t,n){return e.check(Df,t,e.attempt(Ije,t,n))}function jje(e){e.exit("gfmFootnoteDefinition")}function Nje(e,t,n){const r=this;return et(e,o,"gfmFootnoteDefinitionIndent",5);function o(a){const i=r.events[r.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(a):n(a)}}function zje(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:a,resolveAll:o};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function o(i,s){let c=-1;for(;++c<i.length;)if(i[c][0]==="enter"&&i[c][1].type==="strikethroughSequenceTemporary"&&i[c][1]._close){let l=c;for(;l--;)if(i[l][0]==="exit"&&i[l][1].type==="strikethroughSequenceTemporary"&&i[l][1]._open&&i[c][1].end.offset-i[c][1].start.offset===i[l][1].end.offset-i[l][1].start.offset){i[c][1].type="strikethroughSequence",i[l][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},i[l][1].start),end:Object.assign({},i[c][1].end)},d={type:"strikethroughText",start:Object.assign({},i[l][1].end),end:Object.assign({},i[c][1].start)},f=[["enter",u,s],["enter",i[l][1],s],["exit",i[l][1],s],["enter",d,s]],p=s.parser.constructs.insideSpan.null;p&&tr(f,f.length,0,UT(p,i.slice(l+1,c),s)),tr(f,f.length,0,[["exit",d,s],["enter",i[c][1],s],["exit",i[c][1],s],["exit",u,s]]),tr(i,l-1,c-l+3,f),c=l+f.length-2;break}}for(c=-1;++c<i.length;)i[c][1].type==="strikethroughSequenceTemporary"&&(i[c][1].type="data");return i}function a(i,s,c){const l=this.previous,u=this.events;let d=0;return f;function f(y){return l===126&&u[u.length-1][1].type!=="characterEscape"?c(y):(i.enter("strikethroughSequenceTemporary"),p(y))}function p(y){const k=yd(l);if(y===126)return d>1?c(y):(i.consume(y),d++,p);if(d<2&&!n)return c(y);const w=i.exit("strikethroughSequenceTemporary"),v=yd(y);return w._open=!v||v===2&&!!k,w._close=!k||k===2&&!!v,s(y)}}}class Dje{constructor(){this.map=[]}add(t,n,r){qje(this,t,n,r)}consume(t){if(this.map.sort(function(a,i){return a[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let o=r.pop();for(;o;){for(const a of o)t.push(a);o=r.pop()}this.map.length=0}}function qje(e,t,n,r){let o=0;if(!(n===0&&r.length===0)){for(;o<e.map.length;){if(e.map[o][0]===t){e.map[o][1]+=n,e.map[o][2].push(...r);return}o+=1}e.map.push([t,n,r])}}function Oje(e,t){let n=!1;const r=[];for(;t<e.length;){const o=e[t];if(n){if(o[0]==="enter")o[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(o[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const a=r.length-1;r[a]=r[a]==="left"?"center":"right"}}else if(o[1].type==="tableDelimiterRow")break}else o[0]==="enter"&&o[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function Fje(){return{flow:{null:{name:"table",tokenize:Hje,resolveAll:Bje}}}}function Hje(e,t,n){const r=this;let o=0,a=0,i;return s;function s(_){let A=r.events.length-1;for(;A>-1;){const j=r.events[A][1].type;if(j==="lineEnding"||j==="linePrefix")A--;else break}const I=A>-1?r.events[A][1].type:null,V=I==="tableHead"||I==="tableRow"?C:c;return V===C&&r.parser.lazy[r.now().line]?n(_):V(_)}function c(_){return e.enter("tableHead"),e.enter("tableRow"),l(_)}function l(_){return _===124||(i=!0,a+=1),u(_)}function u(_){return _===null?n(_):De(_)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),p):n(_):Xe(_)?et(e,u,"whitespace")(_):(a+=1,i&&(i=!1,o+=1),_===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),i=!0,u):(e.enter("data"),d(_)))}function d(_){return _===null||_===124||ft(_)?(e.exit("data"),u(_)):(e.consume(_),_===92?f:d)}function f(_){return _===92||_===124?(e.consume(_),d):d(_)}function p(_){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(_):(e.enter("tableDelimiterRow"),i=!1,Xe(_)?et(e,y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(_):y(_))}function y(_){return _===45||_===58?w(_):_===124?(i=!0,e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),k):S(_)}function k(_){return Xe(_)?et(e,w,"whitespace")(_):w(_)}function w(_){return _===58?(a+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),v):_===45?(a+=1,v(_)):_===null||De(_)?b(_):S(_)}function v(_){return _===45?(e.enter("tableDelimiterFiller"),M(_)):S(_)}function M(_){return _===45?(e.consume(_),M):_===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(_),e.exit("tableDelimiterMarker"),x):(e.exit("tableDelimiterFiller"),x(_))}function x(_){return Xe(_)?et(e,b,"whitespace")(_):b(_)}function b(_){return _===124?y(_):_===null||De(_)?!i||o!==a?S(_):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(_)):S(_)}function S(_){return n(_)}function C(_){return e.enter("tableRow"),L(_)}function L(_){return _===124?(e.enter("tableCellDivider"),e.consume(_),e.exit("tableCellDivider"),L):_===null||De(_)?(e.exit("tableRow"),t(_)):Xe(_)?et(e,L,"whitespace")(_):(e.enter("data"),P(_))}function P(_){return _===null||_===124||ft(_)?(e.exit("data"),L(_)):(e.consume(_),_===92?T:P)}function T(_){return _===92||_===124?(e.consume(_),P):P(_)}}function Bje(e,t){let n=-1,r=!0,o=0,a=[0,0,0,0],i=[0,0,0,0],s=!1,c=0,l,u,d;const f=new Dje;for(;++n<e.length;){const p=e[n],y=p[1];p[0]==="enter"?y.type==="tableHead"?(s=!1,c!==0&&(Tee(f,t,c,l,u),u=void 0,c=0),l={type:"table",start:Object.assign({},y.start),end:Object.assign({},y.end)},f.add(n,0,[["enter",l,t]])):y.type==="tableRow"||y.type==="tableDelimiterRow"?(r=!0,d=void 0,a=[0,0,0,0],i=[0,n+1,0,0],s&&(s=!1,u={type:"tableBody",start:Object.assign({},y.start),end:Object.assign({},y.end)},f.add(n,0,[["enter",u,t]])),o=y.type==="tableDelimiterRow"?2:u?3:1):o&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")?(r=!1,i[2]===0&&(a[1]!==0&&(i[0]=i[1],d=H0(f,t,a,o,void 0,d),a=[0,0,0,0]),i[2]=n)):y.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(i[0]=i[1],d=H0(f,t,a,o,void 0,d)),a=i,i=[a[1],n,0,0])):y.type==="tableHead"?(s=!0,c=n):y.type==="tableRow"||y.type==="tableDelimiterRow"?(c=n,a[1]!==0?(i[0]=i[1],d=H0(f,t,a,o,n,d)):i[1]!==0&&(d=H0(f,t,i,o,n,d)),o=0):o&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(i[3]=n)}for(c!==0&&Tee(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=Oje(t.events,n))}return e}function H0(e,t,n,r,o,a){const i=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",s="tableContent";n[0]!==0&&(a.end=Object.assign({},u1(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const c=u1(t.events,n[1]);if(a={type:i,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const l=u1(t.events,n[2]),u=u1(t.events,n[3]),d={type:s,start:Object.assign({},l),end:Object.assign({},u)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const y=n[2]+1,k=n[3]-n[2]-1;e.add(y,k,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return o!==void 0&&(a.end=Object.assign({},u1(t.events,o)),e.add(o,0,[["exit",a,t]]),a=void 0),a}function Tee(e,t,n,r,o){const a=[],i=u1(t.events,n);o&&(o.end=Object.assign({},i),a.push(["exit",o,t])),r.end=Object.assign({},i),a.push(["exit",r,t]),e.add(n+1,0,a)}function u1(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const Vje={name:"tasklistCheck",tokenize:Uje};function $je(){return{text:{91:Vje}}}function Uje(e,t,n){const r=this;return o;function o(c){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(c):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),a)}function a(c){return ft(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),i):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),i):n(c)}function i(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),s):n(c)}function s(c){return De(c)?t(c):Xe(c)?e.check({tokenize:Wje},t,n)(c):n(c)}}function Wje(e,t,n){return et(e,r,"whitespace");function r(o){return o===null?n(o):t(o)}}function Gje(e){return r1e([kje(),Eje(),zje(e),Fje(),$je()])}const Kje={};function Zje(e){const t=this,n=e||Kje,r=t.data(),o=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),i=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);o.push(Gje(n)),a.push(pje()),i.push(yje(n))}function Xje({flowId:e,node:t,connector:n,adapter:r,onNameChange:o,onDescriptionChange:a,onDetailChange:i,onIconChange:s,statusReport:c,onClose:l}){const u=(t==null?void 0:t.type)==="shapeNode"&&t.data.shape==="text",d=(t==null?void 0:t.type)==="shapeNode"?t.data.shape:void 0,f=d==="ellipse"||d==="sticky",p=u?null:t,y=p!==null||n!==null,k=p&&"name"in p.data?p.data.name??"":"",w=(p==null?void 0:p.data.description)??"",v=(p==null?void 0:p.data.detail)??"",M=p!==null&&!f,x=p!==null&&(p.type==="playNode"||p.type==="stateNode"),b=x&&typeof s=="function",S=x&&p&&"icon"in p.data?p.data.icon??null:null,[C,L]=g.useState(()=>Q8e()),P=_=>{_.preventDefault(),eMe(C,_.clientX,{onWidth:L,onCommit:J8e})},T={"--detail-panel-w":`${C}px`};return m.jsx(EIe,{open:y,modal:!1,onOpenChange:_=>{_||l()},children:m.jsxs(due,{side:"right",className:"sf:overflow-y-auto sf:bg-card/94 sf:backdrop-blur-[14px] sf:border-border sf:sm:w-(--detail-panel-w)! sf:sm:max-w-(--detail-panel-w)!",style:T,"data-testid":"detail-panel",onEscapeKeyDown:_=>{var I;const A=document.activeElement;(I=A==null?void 0:A.getAttribute("data-testid"))!=null&&I.endsWith("-editor")&&_.preventDefault()},onInteractOutside:_=>{var V;const A=document.activeElement;(V=A==null?void 0:A.getAttribute("data-testid"))!=null&&V.endsWith("-editor")&&A.blur();const I=_.target;I!=null&&I.closest(".react-flow__resize-control")&&_.preventDefault(),I!=null&&I.closest("[data-radix-popper-content-wrapper]")&&_.preventDefault(),I!=null&&I.closest('[data-testid="canvas-style-strip"]')&&_.preventDefault(),I!=null&&I.closest(".react-flow__node")&&_.preventDefault(),I!=null&&I.closest(".react-flow__edge")&&_.preventDefault()},children:[m.jsx("div",{"aria-label":"Resize detail panel",onPointerDown:P,"data-testid":"detail-panel-resize-handle",className:"sf:absolute sf:inset-y-0 sf:left-0 sf:z-10 sf:hidden sf:w-1.5 sf:cursor-col-resize sf:bg-transparent sf:transition-colors sf:hover:bg-border sf:sm:block"}),p?m.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-3",children:[m.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1",children:[M?m.jsx(m_,{"data-testid":"detail-panel-title",children:m.jsxs("div",{className:"sf:flex sf:items-center sf:gap-2",children:[b&&s?m.jsx(Yje,{nodeId:p.id,icon:S,onChange:s}):x&&S?m.jsx("span",{"data-testid":"detail-panel-icon-readonly","aria-hidden":!0,className:"sf:inline-flex sf:h-7 sf:w-7 sf:shrink-0 sf:items-center sf:justify-center sf:text-foreground",children:m.jsx(Lu,{name:S,size:16})}):null,m.jsx("div",{className:"sf:min-w-0 sf:flex-1",children:m.jsx(mF,{nodeId:p.id,value:k,placeholder:"Name",multiline:!1,ariaLabel:"Name",testIdBase:"detail-panel-name",onSave:o,textClassName:"sf:text-base sf:font-semibold"})})]})}):m.jsx(m_,{"data-testid":"detail-panel-title",className:"sr-only",children:p.id}),m.jsxs(JH,{className:"sr-only",children:[p.id," · ",p.type]})]}),m.jsxs("div",{className:"sf:mt-0 sf:flex sf:flex-col sf:gap-3",children:[c?m.jsx(tNe,{report:c}):null,m.jsx(mF,{nodeId:p.id,value:w,placeholder:"Short description shown on the node body",multiline:!0,ariaLabel:"Description",testIdBase:"detail-panel-description",onSave:a,textClassName:"sf:font-medium sf:text-muted-foreground"}),m.jsx(mF,{nodeId:p.id,value:v,placeholder:"Long-form notes, context, anything…",multiline:!0,ariaLabel:"Detail",testIdBase:"detail-panel-detail",onSave:i,markdown:!0}),p.type==="htmlNode"&&e?m.jsx(Qje,{adapter:r,htmlPath:p.data.htmlPath}):null]})]}):n?m.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-3",children:[m.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1",children:[m.jsx(m_,{"data-testid":"detail-panel-title",children:n.label??"Connector"}),m.jsxs(JH,{className:"sr-only",children:[n.id," · ",n.kind]})]}),m.jsx("div",{className:"sf:mt-0 sf:flex sf:flex-col sf:gap-3",children:m.jsx(nNe,{connector:n})})]}):null]})})}function mF({nodeId:e,value:t,placeholder:n,multiline:r,ariaLabel:o,testIdBase:a,onSave:i,textClassName:s,markdown:c=!1}){const[l,u]=g.useState(!1),d=g.useRef(null),f=g.useRef(!1);g.useEffect(()=>{if(!l)return;const S=d.current;if(!S)return;S.textContent=t,S.focus();const C=window.getSelection();if(C){const L=document.createRange();L.selectNodeContents(S),L.collapse(!1),C.removeAllRanges(),C.addRange(L)}},[l,t]);const p=t==="";if(!i)return m.jsx("div",{"data-testid":a,"aria-label":o,className:ce("sf:w-full sf:rounded-md sf:px-2 sf:py-1.5 sf:text-sm",p?"sf:italic sf:text-muted-foreground/50":"text-foreground",!c&&"sf:whitespace-pre-wrap sf:wrap-break-word",s),children:p?n:c?m.jsx(jee,{value:t}):t});const y=()=>{var C;const S=((C=d.current)==null?void 0:C.textContent)??t;i(e,S),u(!1)},k=()=>{u(!1)},w=S=>{if(S.stopPropagation(),S.nativeEvent.stopPropagation(),S.key==="Escape"){S.preventDefault(),f.current=!0,k();return}if(S.key==="Enter"){if(S.preventDefault(),S.shiftKey||!r){y();return}document.execCommand("insertText",!1,`
|
|
7836
7836
|
`)}},v=S=>{S.preventDefault();const C=S.clipboardData.getData("text/plain");document.execCommand("insertText",!1,C)},M=S=>{},x=()=>{if(f.current){f.current=!1;return}y()},b=()=>{l||u(!0)};return m.jsx("div",{className:"relative","data-testid":a,"data-editing":l?"true":"false",children:l?m.jsx("div",{ref:d,contentEditable:"plaintext-only",suppressContentEditableWarning:!0,spellCheck:!1,tabIndex:0,onKeyDown:w,onPaste:v,onInput:M,onBlur:x,"data-testid":`${a}-editor`,className:ce("sf:block sf:w-full sf:whitespace-pre-wrap sf:wrap-break-word sf:rounded-md sf:px-2 sf:py-1.5 sf:text-sm sf:outline-hidden",s),role:"textbox","aria-multiline":r?"true":"false","aria-label":o}):m.jsx("button",{type:"button",onClick:b,"aria-label":`Edit ${o.toLowerCase()}`,className:ce("sf:block sf:w-full sf:cursor-text sf:rounded-md sf:px-2 sf:py-1.5 sf:text-left sf:text-sm sf:transition-colors sf:hover:bg-muted/50",p?"sf:italic sf:text-muted-foreground/50":"text-foreground",!c&&"sf:whitespace-pre-wrap sf:wrap-break-word",s),children:p?n:c?m.jsx(jee,{value:t}):t})})}function Yje({nodeId:e,icon:t,onChange:n}){const[r,o]=g.useState(!1);return m.jsx(ST,{open:r,onOpenChange:o,onPick:a=>{n(e,a),o(!1)},anchor:m.jsx("button",{type:"button","data-testid":"detail-panel-icon-trigger","aria-label":t?"Change icon":"Add icon","aria-pressed":r,className:ce("sf:inline-flex sf:h-7 sf:w-7 sf:shrink-0 sf:items-center sf:justify-center sf:rounded-md sf:text-foreground sf:transition-colors",t?"sf:hover:bg-muted":"sf:border sf:border-dashed sf:border-muted-foreground/40 sf:text-muted-foreground/60 sf:hover:border-muted-foreground sf:hover:text-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:t?m.jsx(Lu,{name:t,size:16,"aria-hidden":!0}):m.jsx(Vh,{className:"sf:h-4 sf:w-4","aria-hidden":!0})})})}function Qje({adapter:e,htmlPath:t}){const[n,r]=g.useState({kind:"idle"}),o=typeof(e==null?void 0:e.openFile)=="function",a=typeof(e==null?void 0:e.revealFile)=="function",i=async s=>{var c,l;r({kind:"pending"});try{s==="open"?await((c=e==null?void 0:e.openFile)==null?void 0:c.call(e,t)):await((l=e==null?void 0:e.revealFile)==null?void 0:l.call(e,t)),r({kind:"idle"})}catch(u){r({kind:"error",message:u instanceof Error?u.message:String(u)})}};return m.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-2 sf:rounded-md sf:border sf:bg-card sf:px-3 sf:py-2 sf:text-xs","data-testid":"detail-panel-html-node",children:[m.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1",children:[m.jsx("span",{className:"sf:font-mono sf:text-[11px] sf:text-muted-foreground sf:uppercase sf:tracking-widest",children:"Path"}),m.jsx("code",{"data-testid":"detail-panel-html-path",className:"sf:block sf:break-all sf:rounded sf:bg-muted/40 sf:px-2 sf:py-1 sf:font-mono sf:text-[11px]",children:t})]}),o||a?m.jsxs("div",{className:"sf:flex sf:flex-wrap sf:items-center sf:gap-2",children:[o?m.jsxs(Ft,{type:"button",size:"sm",variant:"outline",className:"sf:h-7 sf:gap-1.5 sf:px-2",onClick:()=>{i("open")},disabled:n.kind==="pending","data-testid":"detail-panel-html-open","aria-label":"Open in editor",children:[m.jsx(Zh,{className:"sf:h-3.5 sf:w-3.5"}),"Open in editor"]}):null,a?m.jsxs(Ft,{type:"button",size:"sm",variant:"outline",className:"sf:h-7 sf:gap-1.5 sf:px-2",onClick:()=>{i("reveal")},disabled:n.kind==="pending","data-testid":"detail-panel-html-reveal","aria-label":"Reveal in Finder/Explorer",children:[m.jsx(Bh,{className:"sf:h-3.5 sf:w-3.5"}),"Reveal"]}):null]}):null,n.kind==="error"?m.jsx("div",{"data-testid":"detail-panel-html-status","data-status":n.kind,className:ce("sf:text-[11px] sf:text-destructive"),children:n.message??""}):null]})}function Jje(e,t){const n=Math.max(0,t-e);if(n<1e3)return"just now";const r=Math.floor(n/1e3);if(r<60)return`${r}s ago`;const o=Math.floor(r/60);if(o<60)return`${o}m ago`;const a=Math.floor(o/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function eNe(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function tNe({report:e,now:t=Date.now()}){const n=e.data?Object.entries(e.data):[];return m.jsxs("section",{className:"sf:flex sf:flex-col sf:gap-2 sf:rounded-md sf:border sf:bg-card sf:px-3 sf:py-2 sf:text-xs","data-testid":"detail-panel-status","data-state":e.state,children:[m.jsxs("div",{className:"sf:flex sf:items-center sf:justify-between sf:gap-2",children:[m.jsx(tce,{state:e.state,summary:e.summary,"data-testid":"detail-panel-status-badge"}),m.jsx("span",{className:"sf:shrink-0 sf:text-[10px] sf:text-muted-foreground","data-testid":"detail-panel-status-relative-time",children:`Last updated: ${Jje(e.ts,t)}`})]}),e.detail?m.jsx("div",{"data-testid":"detail-panel-status-detail",className:"sf:whitespace-pre-wrap sf:wrap-break-word sf:rounded sf:bg-muted/40 sf:px-2 sf:py-1 sf:text-[11px] sf:text-foreground",children:e.detail}):null,n.length>0?m.jsx("dl",{"data-testid":"detail-panel-status-data",className:"sf:grid sf:grid-cols-[auto_1fr] sf:gap-x-3 sf:gap-y-1 sf:text-[11px]",children:n.map(([r,o])=>m.jsxs("div",{className:"contents","data-testid":"detail-panel-status-data-row",children:[m.jsx("dt",{className:"sf:truncate sf:font-medium sf:text-muted-foreground",children:r}),m.jsx("dd",{className:"sf:break-all sf:font-mono sf:text-foreground",children:eNe(o)})]},r))}):null]})}function jee({value:e}){return m.jsx(zRe,{remarkPlugins:[Zje],components:{h1:({children:t})=>m.jsx("h1",{className:"sf:mb-1 sf:text-base sf:font-bold sf:leading-snug",children:t}),h2:({children:t})=>m.jsx("h2",{className:"sf:mb-1 sf:text-sm sf:font-semibold sf:leading-snug",children:t}),h3:({children:t})=>m.jsx("h3",{className:"sf:mb-0.5 sf:text-sm sf:font-medium sf:leading-snug",children:t}),p:({children:t})=>m.jsx("p",{className:"sf:mb-2 sf:last:mb-0 sf:leading-relaxed",children:t}),ul:({children:t})=>m.jsx("ul",{className:"sf:mb-2 sf:list-disc sf:pl-4 sf:last:mb-0",children:t}),ol:({children:t})=>m.jsx("ol",{className:"sf:mb-2 sf:list-decimal sf:pl-4 sf:last:mb-0",children:t}),li:({children:t})=>m.jsx("li",{className:"mb-0.5",children:t}),code:({children:t,className:n})=>(n==null?void 0:n.includes("language-"))?m.jsx("code",{className:"sf:block sf:overflow-x-auto sf:rounded sf:bg-muted/60 sf:px-2 sf:py-1 sf:font-mono sf:text-xs",children:t}):m.jsx("code",{className:"sf:rounded sf:bg-muted/60 sf:px-1 sf:py-0.5 sf:font-mono sf:text-xs",children:t}),pre:({children:t})=>m.jsx("pre",{className:"sf:mb-2 sf:last:mb-0",children:t}),blockquote:({children:t})=>m.jsx("blockquote",{className:"sf:mb-2 sf:border-l-2 sf:border-muted-foreground/30 sf:pl-3 sf:italic sf:text-muted-foreground sf:last:mb-0",children:t}),a:({href:t,children:n})=>m.jsx("a",{href:t,target:"_blank",rel:"noreferrer",className:"sf:text-primary sf:underline sf:underline-offset-2",children:n}),strong:({children:t})=>m.jsx("strong",{className:"font-semibold",children:t}),em:({children:t})=>m.jsx("em",{className:"italic",children:t}),hr:()=>m.jsx("hr",{className:"sf:my-2 sf:border-border"}),table:({children:t})=>m.jsx("div",{className:"sf:mb-2 sf:overflow-x-auto sf:last:mb-0",children:m.jsx("table",{className:"sf:w-full sf:border-collapse sf:text-xs",children:t})}),th:({children:t})=>m.jsx("th",{className:"sf:border sf:border-border sf:bg-muted/40 sf:px-2 sf:py-1 sf:text-left sf:font-medium",children:t}),td:({children:t})=>m.jsx("td",{className:"sf:border sf:border-border sf:px-2 sf:py-1",children:t})},children:e})}function nNe({connector:e}){return m.jsx("div",{className:"sf:rounded-md sf:border sf:bg-card sf:px-3 sf:py-2 sf:text-xs",children:m.jsxs("dl",{className:"divide-y",children:[m.jsx(io,{label:"Source",value:e.source}),m.jsx(io,{label:"Target",value:e.target}),m.jsx(io,{label:"Kind",value:e.kind}),e.label?m.jsx(io,{label:"Label",value:e.label}):null,e.style?m.jsx(io,{label:"Style",value:e.style}):null,e.color?m.jsx(io,{label:"Color",value:e.color}):null,e.direction?m.jsx(io,{label:"Direction",value:e.direction}):null,e.kind==="http"&&e.url?m.jsx(io,{label:"URL",value:`${e.method??"GET"} ${e.url}`}):null,e.kind==="event"?m.jsx(io,{label:"Event",value:e.eventName}):null,e.kind==="queue"?m.jsx(io,{label:"Queue",value:e.queueName}):null]})})}function io({label:e,value:t}){return m.jsxs("div",{className:"sf:flex sf:items-start sf:gap-3 sf:py-2 sf:first:pt-0 sf:last:pb-0",children:[m.jsx("dt",{className:"sf:w-20 sf:shrink-0 sf:font-medium sf:text-muted-foreground",children:e}),m.jsx("dd",{className:"sf:flex-1 sf:break-all sf:font-mono",children:t})]})}const rNe="https://seeflow.dev/embed",oNe=e=>`${rNe}/${encodeURIComponent(e)}`,aNe=e=>e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<"),iNe=e=>[`<iframe src="${aNe(e)}"`,' width="100%"',' height="600"',' style="border:0"',' allow="fullscreen"',' loading="lazy"></iframe>'].join(`
|
|
7837
7837
|
`),sNe="Embed this canvas",cNe="Paste this iframe into any page to embed the canvas.",lNe="Copy snippet",uNe="Copied!",dNe="Press ⌘C to copy",hNe="Close",fNe=1500;function pNe({open:e,onOpenChange:t,projectId:n}){const r=iNe(oNe(n)),[o,a]=g.useState("idle"),i=g.useRef(null),s=g.useCallback(async()=>{try{await navigator.clipboard.writeText(r),a("copied"),setTimeout(()=>a("idle"),fNe)}catch{a("fallback");const c=i.current;c&&(c.focus(),c.select())}},[r]);return m.jsx(RT,{open:e,onOpenChange:t,children:m.jsxs(Sf,{"data-testid":"embed-dialog-content",children:[m.jsxs(Lf,{children:[m.jsx(If,{children:sNe}),m.jsx(Ef,{children:cNe})]}),m.jsx("textarea",{ref:i,"data-testid":"embed-dialog-snippet",readOnly:!0,rows:7,value:r,spellCheck:!1,onFocus:c=>c.currentTarget.select(),className:"sf:w-full sf:resize-none sf:rounded-md sf:border sf:border-border sf:bg-background sf:p-3 sf:font-mono sf:text-xs sf:leading-relaxed sf:text-foreground sf:focus:outline-hidden sf:focus:ring-2 sf:focus:ring-ring"}),o==="fallback"?m.jsx("p",{"data-testid":"embed-dialog-fallback-hint",className:"sf:text-xs sf:text-muted-foreground",children:dNe}):null,m.jsxs(fd,{children:[m.jsx(Ft,{variant:"outline","data-testid":"embed-dialog-close",onClick:()=>t(!1),children:hNe}),m.jsx(Ft,{"data-testid":"embed-dialog-copy",onClick:s,children:o==="copied"?uNe:lNe})]})]})})}const Nee="Share / download",yNe="Download PDF",mNe="Download PNG",gNe="Embed",kNe="Export to seeflow.dev";function vNe({mode:e,projectId:t,enableEmbed:n,onDownloadPdf:r,onDownloadPng:o,onExportToCloud:a,embedOpen:i,onEmbedOpenChange:s}){const[c,l]=g.useState(!1),[u,d]=g.useState(!1),[f,p]=g.useState(!1),y=i!==void 0,k=y?i:f,w=g.useCallback(L=>{y||p(L),s==null||s(L)},[y,s]),v=g.useCallback(()=>{!r||c||(l(!0),Promise.resolve(r()).finally(()=>l(!1)))},[r,c]),M=g.useCallback(()=>{!o||u||(d(!0),Promise.resolve(o()).finally(()=>d(!1)))},[o,u]),x=!!r,b=!!o,S=n&&typeof t=="string"&&t.length>0,C=e==="edit"&&!!a;return!x&&!b&&!S&&!C?null:m.jsxs(m.Fragment,{children:[m.jsxs(tIe,{children:[m.jsx(nIe,{asChild:!0,children:m.jsx("button",{type:"button","data-testid":"share-menu-trigger","aria-label":Nee,title:Nee,className:ce("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:border sf:border-border sf:bg-background/95 sf:text-muted-foreground sf:shadow-md sf:backdrop-blur-sm sf:transition-colors","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring"),children:m.jsx(n2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})})}),m.jsxs(Xle,{align:"end","data-testid":"share-menu-content",onCloseAutoFocus:L=>{L.preventDefault()},children:[x?m.jsxs(bh,{"data-testid":"share-menu-pdf",disabled:c,onSelect:L=>{L.preventDefault(),v()},children:[c?m.jsx(dr,{className:"sf:h-4 sf:w-4 sf:animate-spin","aria-hidden":"true"}):m.jsx(Hh,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),m.jsx("span",{children:yNe})]}):null,b?m.jsxs(bh,{"data-testid":"share-menu-png",disabled:u,onSelect:L=>{L.preventDefault(),M()},children:[u?m.jsx(dr,{className:"sf:h-4 sf:w-4 sf:animate-spin","aria-hidden":"true"}):m.jsx($h,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),m.jsx("span",{children:mNe})]}):null,S?m.jsxs(bh,{"data-testid":"share-menu-embed",onSelect:L=>{L.preventDefault(),w(!0)},children:[m.jsx(N1,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),m.jsx("span",{children:gNe})]}):null,C?m.jsxs(bh,{"data-testid":"share-menu-export-cloud",onSelect:()=>{a==null||a()},children:[m.jsx(i2,{className:"sf:h-4 sf:w-4","aria-hidden":"true"}),m.jsx("span",{children:kNe})]}):null]})]}),S&&t?m.jsx(pNe,{open:k,onOpenChange:w,projectId:t}):null]})}function xNe({onRestartDemo:e}){const[t,n]=g.useState(!1),r=g.useCallback(()=>{t||(n(!0),Promise.resolve(e()).finally(()=>{n(!1)}))},[e,t]);return m.jsxs(Tf,{children:[m.jsx(jf,{asChild:!0,children:m.jsx(Ft,{"data-testid":"header-restart-demo",type:"button",variant:"ghost",size:"icon","aria-label":"Restart demo",title:"Restart demo",disabled:t,onClick:r,className:"sf:h-8 sf:w-8",children:t?m.jsx(dr,{className:"sf:h-4 sf:w-4 sf:animate-spin","aria-hidden":"true"}):m.jsx(Qh,{className:"sf:h-4 sf:w-4","aria-hidden":"true"})})}),m.jsx(Dd,{side:"bottom",children:"Restart demo"})]})}const wNe=8;function MNe(e){let t=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY,a=!1;for(const i of e){const s=i.data.width,c=i.data.height;s===void 0||c===void 0||(a=!0,i.position.x<t&&(t=i.position.x),i.position.y<n&&(n=i.position.y),i.position.x+s>r&&(r=i.position.x+s),i.position.y+c>o&&(o=i.position.y+c))}return a?{x:t,y:n,width:r-t,height:o-n}:null}function bNe(e){return e.length>=2}function CNe({selectedNodes:e,onMultiResize:t,paddingPx:n=wNe}){pT();const[r,o]=g.useState(null),[a,i]=g.useState(null);if(g.useRef(!1),g.useRef(null),!bNe(e))return null;const s=MNe(e);if(!s)return null;const c=a??s;return c.x-n,c.y-n,c.width+n*2,c.height+n*2,null}const zee=22,Dee=11,qee=3,Oee=2,gF=8,SNe={http:"solid",event:"dashed",queue:"dotted",default:"solid"},K1e=["default","slate","blue","green","amber","red","purple","pink"],B0=[{value:"solid",icon:pR,label:"Solid",testId:"style-tab-border-style-solid"},{value:"dashed",icon:sue,label:"Dashed",testId:"style-tab-border-style-dashed"},{value:"dotted",icon:cue,label:"Dotted",testId:"style-tab-border-style-dotted"}],Fee=[{value:"solid",icon:pR,label:"Solid",testId:"style-tab-edge-style-solid"},{value:"dashed",icon:sue,label:"Dashed",testId:"style-tab-edge-style-dashed"},{value:"dotted",icon:cue,label:"Dotted",testId:"style-tab-edge-style-dotted"}],Hee=[{value:"curve",icon:lue,label:"Curve",testId:"style-tab-edge-path-curve"},{value:"step",icon:IIe,label:"Zigzag",testId:"style-tab-edge-path-step"}],Bee=[{value:"none",icon:Gh,label:"None",testId:"style-tab-direction-none"},{value:"backward",icon:Kh,label:"Backward",testId:"style-tab-direction-backward"},{value:"forward",icon:R1,label:"Forward",testId:"style-tab-direction-forward"},{value:"both",icon:jh,label:"Both",testId:"style-tab-direction-both"}];function LNe({nodes:e,connectors:t,onStyleNode:n,onStyleNodePreview:r,onStyleNodes:o,onStyleNodesPreview:a,onStyleConnector:i,onStyleConnectorPreview:s,onRequestIconReplace:c}){const l=e.length>0,u=t.length>0;if(!l&&!u)return null;const d=l&&!u,f=!l&&u,p=e[0],y=t[0],k=e.filter(ue=>ue.type!=="iconNode"),w=k[0],v=d&&e.every(ue=>ue.type==="iconNode"),M=v?e.find(ue=>ue.type==="iconNode"):void 0,x=d&&e.every(ue=>ue.type==="imageNode"),b=d&&(p==null?void 0:p.type)==="shapeNode"&&p.data.shape==="text",S=(f?y==null?void 0:y.color:w==null?void 0:w.data.borderColor)??"default",C=(w==null?void 0:w.data.backgroundColor)??"default",L=(w==null?void 0:w.data.borderStyle)??"solid",P=y?y.style??SNe[y.kind]:"solid",T=(y==null?void 0:y.direction)??"forward",_=(y==null?void 0:y.path)??"curve",A=ue=>{for(const ge of e)n(ge.id,{borderColor:ue});for(const ge of t)i(ge.id,{color:ue})},I=ue=>{for(const ge of e)n(ge.id,{backgroundColor:ue})},V=ue=>{for(const ge of e)n(ge.id,{borderStyle:ue});for(const ge of t)i(ge.id,{style:ue})},j=ue=>{for(const ge of e)n(ge.id,{borderSize:ue});for(const ge of t)i(ge.id,{borderSize:ue})},H=ue=>{for(const ge of e)r==null||r(ge.id,{borderSize:ue});for(const ge of t)s==null||s(ge.id,{borderSize:ue})},O=ue=>{if(e.length>1&&o)o(e.map(ge=>ge.id),{fontSize:ue});else for(const ge of e)n(ge.id,{fontSize:ue})},U=ue=>{if(e.length>1&&a)a(e.map(ge=>ge.id),{fontSize:ue});else for(const ge of e)r==null||r(ge.id,{fontSize:ue})},z=k.length>1&&new Set(k.map(ue=>ue.data.fontSize??zee)).size>1,N=ue=>{if(e.length>1&&o)o(e.map(ge=>ge.id),{textColor:ue});else for(const ge of e)n(ge.id,{textColor:ue})},E=(w==null?void 0:w.data.textColor)??(b?(w==null?void 0:w.data.borderColor)??"default":"default"),W=ue=>{for(const ge of t)i(ge.id,{fontSize:ue})},q=ue=>{for(const ge of t)s==null||s(ge.id,{fontSize:ue})},R=t.length>1&&new Set(t.map(ue=>ue.fontSize??Dee)).size>1,G=ue=>{for(const ge of e)n(ge.id,{cornerRadius:ue})},X=ue=>{for(const ge of e)r==null||r(ge.id,{cornerRadius:ue})},Y=k.length>1&&new Set(k.map(ue=>ue.data.cornerRadius??gF)).size>1,oe=ue=>{for(const ge of t)i(ge.id,{path:ue})},ee=ue=>{for(const ge of t)i(ge.id,{direction:ue})},ae=ue=>{for(const ge of e)n(ge.id,{color:ue})},ve=(M==null?void 0:M.data.color)??"default",Se=f?(y==null?void 0:y.borderSize)??Oee:(w==null?void 0:w.data.borderSize)??qee,be=f?Oee:qee,we=f?"edge":"border",te=f?"Connector color":b?"Color":"Border color",ie=f?"connector color":b?"color":"border color",Te=f?"style-tab-edge-color-trigger":b?"style-tab-color-trigger":"style-tab-border-color-trigger",Ae=f||b?"style-tab-color":"style-tab-border-color";if(v){const ue=!!c&&e.length===1&&!!M,ge=()=>{M&&c&&c(M.id)};return m.jsx(d2,{delayDuration:300,children:m.jsxs("div",{"data-testid":"canvas-style-strip",className:"sf:pointer-events-auto sf:flex sf:flex-col sf:items-center sf:gap-1 sf:rounded-lg sf:border sf:border-border sf:bg-background/95 sf:p-1 sf:shadow-md sf:backdrop-blur",children:[m.jsx(Vee,{testId:"style-strip-icon-color",tooltip:"Icon color",ariaLabel:"icon color",activeToken:ve,previewKind:"edge",tokenTestIdPrefix:"style-tab-icon-color",innerTestId:"style-tab-icon-color-trigger",onSelect:ae}),ue?m.jsxs(Tf,{children:[m.jsx(jf,{asChild:!0,children:m.jsx("button",{type:"button","data-testid":"style-strip-change-icon","aria-label":"change icon",title:"Change icon",onClick:ge,className:ce("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:m.jsx(D1,{className:"sf:h-4 sf:w-4"})})}),m.jsx(Dd,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:"Change icon"})]}):null]})})}if(x){const ue=e[0],ge=(ue==null?void 0:ue.data.borderColor)??"default",Me=(ue==null?void 0:ue.data.borderStyle)??"solid",qe=(ue==null?void 0:ue.data.borderWidth)??1,re=Oe=>{for(const je of e)n(je.id,{borderColor:Oe})},he=Oe=>{for(const je of e)n(je.id,{borderStyle:Oe})},Ie=Oe=>{for(const je of e)n(je.id,{borderWidth:Oe})},He=Oe=>{for(const je of e)r==null||r(je.id,{borderWidth:Oe})},Ue=Oe=>{for(const je of e)n(je.id,{cornerRadius:Oe})},Rt=Oe=>{for(const je of e)r==null||r(je.id,{cornerRadius:Oe})};return m.jsx(d2,{delayDuration:300,children:m.jsxs("div",{"data-testid":"canvas-style-strip",className:"sf:pointer-events-auto sf:flex sf:flex-col sf:items-center sf:gap-1 sf:rounded-lg sf:border sf:border-border sf:bg-background/95 sf:p-1 sf:shadow-md sf:backdrop-blur",children:[m.jsx(Vee,{testId:"style-strip-image-border-color",tooltip:"Border color",ariaLabel:"image border color",activeToken:ge,previewKind:"border",tokenTestIdPrefix:"style-tab-image-border-color",innerTestId:"style-tab-image-border-color-trigger",onSelect:re}),m.jsx(Ho,{testId:"style-strip-image-border-style",tooltip:"Border style",ariaLabel:"image border style",renderIcon:()=>{var je;const Oe=((je=B0.find(Pt=>Pt.value===Me))==null?void 0:je.icon)??pR;return m.jsx(Oe,{className:"sf:h-4 sf:w-4"})},children:m.jsx(nh,{ariaLabel:"Border style",value:Me,onChange:he,options:B0})}),m.jsx(Ho,{testId:"style-strip-image-border-width",tooltip:"Border width",ariaLabel:"image border width",renderIcon:()=>m.jsx("span",{className:"sf:font-mono sf:text-[10px] sf:tabular-nums",children:qe}),children:m.jsx(ah,{value:ue==null?void 0:ue.data.borderWidth,defaultValue:1,min:1,max:8,suffix:"px",onPreview:He,onCommit:Ie,testId:"style-tab-image-border-width-slider"})}),m.jsx(Ho,{testId:"style-strip-image-corner-radius",tooltip:"Corners",ariaLabel:"image corner radius",renderIcon:()=>m.jsx(z1,{className:"sf:h-4 sf:w-4"}),children:m.jsx(ah,{value:ue==null?void 0:ue.data.cornerRadius,defaultValue:gF,min:0,max:32,suffix:"px",onPreview:Rt,onCommit:Ue,testId:"style-tab-image-corner-radius-slider"})})]})})}const at=d&&!b,Qe=!b,le=!f,Q=()=>{if(f){const Me=Th[S].edge;return m.jsx("span",{className:"sf:inline-block sf:h-5 sf:w-5 sf:rounded-full sf:ring-1 sf:ring-border",style:{backgroundColor:Me}})}const ue=Th[S].border,ge=Th[C].background;return m.jsx("span",{className:"sf:inline-block sf:h-5 sf:w-5 sf:rounded-md sf:ring-1 sf:ring-border",style:{backgroundColor:ge,border:`2px solid ${ue}`}})};return m.jsx(d2,{delayDuration:300,children:m.jsxs("div",{"data-testid":"canvas-style-strip",className:"sf:pointer-events-auto sf:flex sf:flex-col sf:items-center sf:gap-1 sf:rounded-lg sf:border sf:border-border sf:bg-background/95 sf:p-1 sf:shadow-md sf:backdrop-blur",children:[b?null:m.jsx(Ho,{testId:"style-strip-colors",tooltip:"Colors",ariaLabel:"colors",renderIcon:Q,children:m.jsxs("div",{className:"sf:flex sf:w-56 sf:flex-col sf:gap-3",children:[m.jsx(o1,{label:te,children:m.jsx(kF,{testId:"style-strip-border-color",activeToken:S,previewKind:we,tokenTestIdPrefix:Ae,innerTestId:Te,ariaLabel:ie,onSelect:A})}),at?m.jsx(o1,{label:"Fill",children:m.jsx(kF,{testId:"style-strip-fill",activeToken:C,previewKind:"background",tokenTestIdPrefix:"style-tab-background-color",innerTestId:"style-tab-background-color-trigger",ariaLabel:"fill",onSelect:I})}):null]})}),Qe?m.jsx(Ho,{testId:"style-strip-border",tooltip:f?"Connector":"Border",ariaLabel:f?"connector":"border",renderIcon:()=>{var ge,Me;const ue=(f?(ge=Fee.find(qe=>qe.value===P))==null?void 0:ge.icon:(Me=B0.find(qe=>qe.value===L))==null?void 0:Me.icon)??pR;return m.jsx(ue,{className:"sf:h-4 sf:w-4"})},children:m.jsxs("div",{className:"sf:flex sf:w-56 sf:flex-col sf:gap-3",children:[m.jsx(o1,{label:"Style",testId:"style-strip-border-style",children:f?m.jsx(nh,{ariaLabel:"Connector style",value:P,onChange:ue=>V(ue),options:Fee}):m.jsx(nh,{ariaLabel:"Border style",value:L,onChange:ue=>V(ue),options:B0})}),m.jsx(o1,{label:"Width",testId:"style-strip-border-size",children:m.jsx(ah,{value:Se,defaultValue:be,min:1,max:8,suffix:"px",onPreview:H,onCommit:j,testId:f?"style-tab-stroke-width-slider":"style-tab-border-size-slider"})})]})}):null,l||f?m.jsx(Ho,{testId:"style-strip-text",tooltip:"Text",ariaLabel:"text",renderIcon:()=>m.jsx(q1,{className:"sf:h-4 sf:w-4"}),children:m.jsxs("div",{className:"sf:flex sf:w-56 sf:flex-col sf:gap-3",children:[m.jsx(o1,{label:"Size",testId:f?"style-strip-connector-font-size":"style-strip-font-size",children:m.jsx(ah,{value:f?y==null?void 0:y.fontSize:w==null?void 0:w.data.fontSize,defaultValue:f?Dee:zee,min:f?8:10,max:32,suffix:"px",indeterminate:f?R:z,onPreview:f?q:U,onCommit:f?W:O,testId:f?"style-tab-connector-font-size-slider":"style-tab-font-size-slider"})}),le?m.jsx(o1,{label:"Color",children:m.jsx(kF,{testId:"style-strip-text-color",activeToken:E,previewKind:"edge",tokenTestIdPrefix:"style-tab-text-color",innerTestId:"style-tab-text-color-trigger",ariaLabel:"text color",onSelect:N})}):null]})}):null,l&&!b?m.jsx(Ho,{testId:"style-strip-corner-radius",tooltip:"Corners",ariaLabel:"corner radius",renderIcon:()=>m.jsx(z1,{className:"sf:h-4 sf:w-4"}),children:m.jsx(ah,{value:w==null?void 0:w.data.cornerRadius,defaultValue:gF,min:0,max:32,suffix:"px",indeterminate:Y,onPreview:X,onCommit:G,testId:"style-tab-corner-radius-slider"})}):null,f?m.jsx(Ho,{testId:"style-strip-path",tooltip:"Connector path",ariaLabel:"connector path",renderIcon:()=>{var ge;const ue=((ge=Hee.find(Me=>Me.value===_))==null?void 0:ge.icon)??lue;return m.jsx(ue,{className:"sf:h-4 sf:w-4"})},children:m.jsx(nh,{ariaLabel:"Connector path",value:_,onChange:oe,options:Hee})}):null,f?m.jsx(Ho,{testId:"style-strip-direction",tooltip:"Direction",ariaLabel:"direction",renderIcon:()=>{var ge;const ue=((ge=Bee.find(Me=>Me.value===T))==null?void 0:ge.icon)??R1;return m.jsx(ue,{className:"sf:h-4 sf:w-4"})},children:m.jsx(nh,{ariaLabel:"Connector direction",value:T,onChange:ee,options:Bee})}):null]})})}function Z1e(e,t){const n=Th[e];return t==="background"?{backgroundColor:n.background,borderColor:n.border}:t==="edge"?{backgroundColor:n.edge,borderColor:n.edge}:{borderColor:n.border,backgroundColor:n.background}}function INe(e,t){const n=Th[e];return t==="background"?{backgroundColor:n.background}:t==="edge"?{backgroundColor:n.edge}:{backgroundColor:n.border}}function Vee({testId:e,tooltip:t,ariaLabel:n,activeToken:r,previewKind:o,tokenTestIdPrefix:a,innerTestId:i,onSelect:s}){const[c,l]=g.useState(!1),u=r==="default";return m.jsxs(Nd,{open:c,onOpenChange:l,children:[m.jsxs(Tf,{children:[m.jsx(jf,{asChild:!0,children:m.jsx(kf,{asChild:!0,children:m.jsx("button",{type:"button","data-testid":e,"data-active-token":r,"aria-label":`${n}: ${r}`,title:t,className:ce("sf:group sf:relative sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:m.jsx("span",{"data-testid":i,className:"sf:relative sf:h-5 sf:w-5 sf:rounded-full sf:ring-1 sf:ring-border",style:INe(r,o),children:u?m.jsx("span",{"aria-hidden":"true",className:"sf:pointer-events-none sf:absolute sf:inset-0 sf:rounded-full",style:{backgroundImage:"linear-gradient(45deg, transparent 45%, currentColor 45%, currentColor 55%, transparent 55%)",color:"hsl(var(--muted-foreground))",opacity:.5}}):null})})})}),m.jsx(Dd,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:t})]}),m.jsx(Fu,{side:"right",align:"start",className:"sf:w-auto sf:p-2","data-testid":`${i}-popover`,children:m.jsx("div",{className:"sf:grid sf:grid-cols-4 sf:gap-1.5",children:K1e.map(d=>{const f=r===d;return m.jsx("button",{type:"button",onClick:()=>{s(d),l(!1)},"data-testid":`${a}-${d}`,"data-active":f,"aria-label":`${n} ${d}`,"aria-pressed":f,title:d,className:ce("sf:relative sf:flex sf:h-7 sf:w-7 sf:items-center sf:justify-center sf:rounded-full sf:border-2 sf:transition-all",f?"sf:ring-2 sf:ring-ring sf:ring-offset-2 sf:ring-offset-popover":"sf:hover:scale-110"),style:Z1e(d,o),children:f?m.jsx(Ja,{className:"sf:h-3 sf:w-3 sf:drop-shadow-sm",style:{color:"hsl(var(--foreground))"}}):null},d)})})})]})}function kF({testId:e,activeToken:t,previewKind:n,tokenTestIdPrefix:r,innerTestId:o,ariaLabel:a,onSelect:i}){return m.jsx("div",{"data-testid":e,"data-active-token":t,"data-inner-testid":o,className:"sf:grid sf:grid-cols-4 sf:gap-1.5",children:K1e.map(s=>{const c=t===s;return m.jsx("button",{type:"button",onClick:()=>i(s),"data-testid":`${r}-${s}`,"data-active":c,"aria-label":`${a} ${s}`,"aria-pressed":c,title:s,className:ce("sf:relative sf:flex sf:h-7 sf:w-7 sf:items-center sf:justify-center sf:rounded-full sf:border-2 sf:transition-all",c?"sf:ring-2 sf:ring-ring sf:ring-offset-2 sf:ring-offset-popover":"sf:hover:scale-110"),style:Z1e(s,n),children:c?m.jsx(Ja,{className:"sf:h-3 sf:w-3 sf:drop-shadow-sm",style:{color:"hsl(var(--foreground))"}}):null},s)})})}function o1({label:e,testId:t,children:n}){return m.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-1.5","data-testid":t,children:[m.jsx("div",{className:"sf:text-[11px] sf:font-medium sf:uppercase sf:tracking-wide sf:text-muted-foreground",children:e}),n]})}function Ho({testId:e,tooltip:t,ariaLabel:n,renderIcon:r,children:o}){const[a,i]=g.useState(!1);return m.jsxs(Nd,{open:a,onOpenChange:i,children:[m.jsxs(Tf,{children:[m.jsx(jf,{asChild:!0,children:m.jsx(kf,{asChild:!0,children:m.jsx("button",{type:"button","data-testid":e,"aria-label":n,title:t,className:ce("sf:inline-flex sf:h-8 sf:w-8 sf:items-center sf:justify-center sf:rounded-md sf:text-muted-foreground sf:transition-colors sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus-visible:outline-hidden sf:focus-visible:ring-2 sf:focus-visible:ring-ring sf:focus-visible:ring-offset-1"),children:r()})})}),m.jsx(Dd,{side:"right",className:"sf:px-2 sf:py-1 sf:text-xs",children:t})]}),m.jsx(Fu,{side:"right",align:"start",className:"sf:w-auto sf:p-3",children:o})]})}function ah({value:e,defaultValue:t,min:n,max:r,suffix:o,indeterminate:a,onPreview:i,onCommit:s,testId:c}){const l=e??t,[u,d]=g.useState(l),[f,p]=g.useState(!1);g.useEffect(()=>{d(l),p(!1)},[l]);const y=a&&!f;return m.jsxs("div",{className:"sf:flex sf:w-48 sf:items-center sf:gap-3",children:[m.jsx(Eue,{min:n,max:r,step:1,value:[u],onValueChange:([k])=>{const w=k??n;d(w),p(!0),i==null||i(w)},onValueCommit:([k])=>s(k??n),"data-testid":c,"data-indeterminate":y?"true":void 0,className:ce("sf:flex-1",y&&"sf:opacity-60")}),m.jsx("span",{"data-testid":`${c}-value`,className:"sf:w-12 sf:shrink-0 sf:text-right sf:text-xs sf:tabular-nums sf:text-muted-foreground",children:y?"Mixed":m.jsxs(m.Fragment,{children:[u,o]})})]})}const ENe="modulepreload",ANe=function(e){return"/"+e},$ee={},PNe=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),s=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));o=Promise.allSettled(n.map(c=>{if(c=ANe(c),c in $ee)return;$ee[c]=!0;const l=c.endsWith(".css"),u=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const d=document.createElement("link");if(d.rel=l?"stylesheet":ENe,l||(d.as="script"),d.crossOrigin="",d.href=c,s&&d.setAttribute("nonce",s),document.head.appendChild(d),l)return new Promise((f,p)=>{d.addEventListener("load",f),d.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(i){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=i,window.dispatchEvent(s),!s.defaultPrevented)throw i}return o.then(i=>{for(const s of i||[])s.status==="rejected"&&a(s.reason);return t().catch(a)})};function _Ne(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),o=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(o),t&&(r.href=t),o.href=e,o.href}const RNe=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function ni(e){const t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}let a1=null;function X1e(e={}){return a1||(e.includeStyleProperties?(a1=e.includeStyleProperties,a1):(a1=ni(window.getComputedStyle(document.documentElement)),a1))}function vR(e,t){const r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function TNe(e){const t=vR(e,"border-left-width"),n=vR(e,"border-right-width");return e.clientWidth+t+n}function jNe(e){const t=vR(e,"border-top-width"),n=vR(e,"border-bottom-width");return e.clientHeight+t+n}function Y1e(e,t={}){const n=t.width||TNe(e),r=t.height||jNe(e);return{width:n,height:r}}function NNe(){let e,t;try{t=process}catch{}const n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const $n=16384;function zNe(e){(e.width>$n||e.height>$n)&&(e.width>$n&&e.height>$n?e.width>e.height?(e.height*=$n/e.width,e.width=$n):(e.width*=$n/e.height,e.height=$n):e.width>$n?(e.height*=$n/e.width,e.width=$n):(e.width*=$n/e.height,e.height=$n))}function xR(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function DNe(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function qNe(e,t,n){const r="http://www.w3.org/2000/svg",o=document.createElementNS(r,"svg"),a=document.createElementNS(r,"foreignObject");return o.setAttribute("width",`${t}`),o.setAttribute("height",`${n}`),o.setAttribute("viewBox",`0 0 ${t} ${n}`),a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.setAttribute("x","0"),a.setAttribute("y","0"),a.setAttribute("externalResourcesRequired","true"),o.appendChild(a),a.appendChild(e),DNe(o)}const Tn=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||Tn(n,t)};function ONe(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function FNe(e,t){return X1e(t).map(n=>{const r=e.getPropertyValue(n),o=e.getPropertyPriority(n);return`${n}: ${r}${o?" !important":""};`}).join(" ")}function HNe(e,t,n,r){const o=`.${e}:${t}`,a=n.cssText?ONe(n):FNe(n,r);return document.createTextNode(`${o}{${a}}`)}function Uee(e,t,n,r){const o=window.getComputedStyle(e,n),a=o.getPropertyValue("content");if(a===""||a==="none")return;const i=RNe();try{t.className=`${t.className} ${i}`}catch{return}const s=document.createElement("style");s.appendChild(HNe(i,n,o,r)),t.appendChild(s)}function BNe(e,t,n){Uee(e,t,":before",n),Uee(e,t,":after",n)}const Wee="application/font-woff",Gee="image/jpeg",VNe={woff:Wee,woff2:Wee,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Gee,jpeg:Gee,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function $Ne(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function nU(e){const t=$Ne(e).toLowerCase();return VNe[t]||""}function UNe(e){return e.split(/,/)[1]}function mB(e){return e.search(/^(data:)/)!==-1}function WNe(e,t){return`data:${t};base64,${e}`}async function Q1e(e,t,n){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const o=await r.blob();return new Promise((a,i)=>{const s=new FileReader;s.onerror=i,s.onloadend=()=>{try{a(n({res:r,result:s.result}))}catch(c){i(c)}},s.readAsDataURL(o)})}const vF={};function GNe(e,t,n){let r=e.replace(/\?.*/,"");return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function rU(e,t,n){const r=GNe(e,t,n.includeQueryParams);if(vF[r]!=null)return vF[r];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let o;try{const a=await Q1e(e,n.fetchRequestInit,({res:i,result:s})=>(t||(t=i.headers.get("Content-Type")||""),UNe(s)));o=WNe(a,t)}catch(a){o=n.imagePlaceholder||"";let i=`Failed to fetch resource: ${e}`;a&&(i=typeof a=="string"?a:a.message),i&&console.warn(i)}return vF[r]=o,o}async function KNe(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):xR(t)}async function ZNe(e,t){if(e.currentSrc){const a=document.createElement("canvas"),i=a.getContext("2d");a.width=e.clientWidth,a.height=e.clientHeight,i==null||i.drawImage(e,0,0,a.width,a.height);const s=a.toDataURL();return xR(s)}const n=e.poster,r=nU(n),o=await rU(n,r,t);return xR(o)}async function XNe(e,t){var n;try{if(!((n=e==null?void 0:e.contentDocument)===null||n===void 0)&&n.body)return await ZT(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function YNe(e,t){return Tn(e,HTMLCanvasElement)?KNe(e):Tn(e,HTMLVideoElement)?ZNe(e,t):Tn(e,HTMLIFrameElement)?XNe(e,t):e.cloneNode(J1e(e))}const QNe=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",J1e=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function JNe(e,t,n){var r,o;if(J1e(t))return t;let a=[];return QNe(e)&&e.assignedNodes?a=ni(e.assignedNodes()):Tn(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?a=ni(e.contentDocument.body.childNodes):a=ni(((o=e.shadowRoot)!==null&&o!==void 0?o:e).childNodes),a.length===0||Tn(e,HTMLVideoElement)||await a.reduce((i,s)=>i.then(()=>ZT(s,n)).then(c=>{c&&t.appendChild(c)}),Promise.resolve()),t}function eze(e,t,n){const r=t.style;if(!r)return;const o=window.getComputedStyle(e);o.cssText?(r.cssText=o.cssText,r.transformOrigin=o.transformOrigin):X1e(n).forEach(a=>{let i=o.getPropertyValue(a);a==="font-size"&&i.endsWith("px")&&(i=`${Math.floor(parseFloat(i.substring(0,i.length-2)))-.1}px`),Tn(e,HTMLIFrameElement)&&a==="display"&&i==="inline"&&(i="block"),a==="d"&&t.getAttribute("d")&&(i=`path(${t.getAttribute("d")})`),r.setProperty(a,i,o.getPropertyPriority(a))})}function tze(e,t){Tn(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),Tn(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function nze(e,t){if(Tn(e,HTMLSelectElement)){const n=t,r=Array.from(n.children).find(o=>e.value===o.getAttribute("value"));r&&r.setAttribute("selected","")}}function rze(e,t,n){return Tn(t,Element)&&(eze(e,t,n),BNe(e,t,n),tze(e,t),nze(e,t)),t}async function oze(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const r={};for(let a=0;a<n.length;a++){const s=n[a].getAttribute("xlink:href");if(s){const c=e.querySelector(s),l=document.querySelector(s);!c&&l&&!r[s]&&(r[s]=await ZT(l,t,!0))}}const o=Object.values(r);if(o.length){const a="http://www.w3.org/1999/xhtml",i=document.createElementNS(a,"svg");i.setAttribute("xmlns",a),i.style.position="absolute",i.style.width="0",i.style.height="0",i.style.overflow="hidden",i.style.display="none";const s=document.createElementNS(a,"defs");i.appendChild(s);for(let c=0;c<o.length;c++)s.appendChild(o[c]);e.appendChild(i)}return e}async function ZT(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(r=>YNe(r,t)).then(r=>JNe(e,r,t)).then(r=>rze(e,r,t)).then(r=>oze(r,t))}const ede=/url\((['"]?)([^'"]+?)\1\)/g,aze=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,ize=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function sze(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function cze(e){const t=[];return e.replace(ede,(n,r,o)=>(t.push(o),n)),t.filter(n=>!mB(n))}async function lze(e,t,n,r,o){try{const a=n?_Ne(t,n):t,i=nU(t);let s;return o||(s=await rU(a,i,r)),e.replace(sze(t),`$1${s}$3`)}catch{}return e}function uze(e,{preferredFontFormat:t}){return t?e.replace(ize,n=>{for(;;){const[r,,o]=aze.exec(n)||[];if(!o)return"";if(o===t)return`src: ${r};`}}):e}function tde(e){return e.search(ede)!==-1}async function nde(e,t,n){if(!tde(e))return e;const r=uze(e,n);return cze(r).reduce((a,i)=>a.then(s=>lze(s,i,t,n)),Promise.resolve(r))}async function i1(e,t,n){var r;const o=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(o){const a=await nde(o,null,n);return t.style.setProperty(e,a,t.style.getPropertyPriority(e)),!0}return!1}async function dze(e,t){await i1("background",e,t)||await i1("background-image",e,t),await i1("mask",e,t)||await i1("-webkit-mask",e,t)||await i1("mask-image",e,t)||await i1("-webkit-mask-image",e,t)}async function hze(e,t){const n=Tn(e,HTMLImageElement);if(!(n&&!mB(e.src))&&!(Tn(e,SVGImageElement)&&!mB(e.href.baseVal)))return;const r=n?e.src:e.href.baseVal,o=await rU(r,nU(r),t);await new Promise((a,i)=>{e.onload=a,e.onerror=t.onImageErrorHandler?(...c)=>{try{a(t.onImageErrorHandler(...c))}catch(l){i(l)}}:i;const s=e;s.decode&&(s.decode=a),s.loading==="lazy"&&(s.loading="eager"),n?(e.srcset="",e.src=o):e.href.baseVal=o})}async function fze(e,t){const r=ni(e.childNodes).map(o=>rde(o,t));await Promise.all(r).then(()=>e)}async function rde(e,t){Tn(e,Element)&&(await dze(e,t),await hze(e,t),await fze(e,t))}function pze(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(o=>{n[o]=r[o]}),e}const Kee={};async function Zee(e){let t=Kee[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},Kee[e]=t,t}async function Xee(e,t){let n=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,a=(n.match(/url\([^)]+\)/g)||[]).map(async i=>{let s=i.replace(r,"$1");return s.startsWith("https://")||(s=new URL(s,e.url).href),Q1e(s,t.fetchRequestInit,({result:c})=>(n=n.replace(i,`url(${c})`),[i,c]))});return Promise.all(a).then(()=>n)}function Yee(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(n,"");const o=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const c=o.exec(r);if(c===null)break;t.push(c[0])}r=r.replace(o,"");const a=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,i="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",s=new RegExp(i,"gi");for(;;){let c=a.exec(r);if(c===null){if(c=s.exec(r),c===null)break;a.lastIndex=s.lastIndex}else s.lastIndex=a.lastIndex;t.push(c[0])}return t}async function yze(e,t){const n=[],r=[];return e.forEach(o=>{if("cssRules"in o)try{ni(o.cssRules||[]).forEach((a,i)=>{if(a.type===CSSRule.IMPORT_RULE){let s=i+1;const c=a.href,l=Zee(c).then(u=>Xee(u,t)).then(u=>Yee(u).forEach(d=>{try{o.insertRule(d,d.startsWith("@import")?s+=1:o.cssRules.length)}catch(f){console.error("Error inserting rule from remote css",{rule:d,error:f})}})).catch(u=>{console.error("Error loading remote css",u.toString())});r.push(l)}})}catch(a){const i=e.find(s=>s.href==null)||document.styleSheets[0];o.href!=null&&r.push(Zee(o.href).then(s=>Xee(s,t)).then(s=>Yee(s).forEach(c=>{i.insertRule(c,i.cssRules.length)})).catch(s=>{console.error("Error loading remote stylesheet",s)})),console.error("Error inlining remote css file",a)}}),Promise.all(r).then(()=>(e.forEach(o=>{if("cssRules"in o)try{ni(o.cssRules||[]).forEach(a=>{n.push(a)})}catch(a){console.error(`Error while reading CSS rules from ${o.href}`,a)}}),n))}function mze(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>tde(t.style.getPropertyValue("src")))}async function gze(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=ni(e.ownerDocument.styleSheets),r=await yze(n,t);return mze(r)}function ode(e){return e.trim().replace(/["']/g,"")}function kze(e){const t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(a=>{t.add(ode(a))}),Array.from(r.children).forEach(a=>{a instanceof HTMLElement&&n(a)})}return n(e),t}async function vze(e,t){const n=await gze(e,t),r=kze(e);return(await Promise.all(n.filter(a=>r.has(ode(a.style.fontFamily))).map(a=>{const i=a.parentStyleSheet?a.parentStyleSheet.href:null;return nde(a.cssText,i,t)}))).join(`
|
|
7838
|
-
`)}async function xze(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await vze(e,t);if(n){const r=document.createElement("style"),o=document.createTextNode(n);r.appendChild(o),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function wze(e,t={}){const{width:n,height:r}=Y1e(e,t),o=await ZT(e,t,!0);return await xze(o,t),await rde(o,t),pze(o,t),await qNe(o,n,r)}async function Mze(e,t={}){const{width:n,height:r}=Y1e(e,t),o=await wze(e,t),a=await xR(o),i=document.createElement("canvas"),s=i.getContext("2d"),c=t.pixelRatio||NNe(),l=t.canvasWidth||n,u=t.canvasHeight||r;return i.width=l*c,i.height=u*c,t.skipAutoScale||zNe(i),i.style.width=`${l}`,i.style.height=`${u}`,t.backgroundColor&&(s.fillStyle=t.backgroundColor,s.fillRect(0,0,i.width,i.height)),s.drawImage(a,0,0,i.width,i.height),i}async function bze(e,t={}){return(await Mze(e,t)).toDataURL()}const Cze=e=>e instanceof Element?!(e.classList.contains("react-flow__minimap")||e.classList.contains("react-flow__controls")||e.classList.contains("react-flow__panel")):!0,Sze=async e=>{const t=await bze(e,{cacheBust:!0,filter:Cze}),n=await new Promise((r,o)=>{const a=new Image;a.onload=()=>r({width:a.naturalWidth,height:a.naturalHeight}),a.onerror=()=>o(new Error("Failed to decode captured image")),a.src=t});return{dataUrl:t,...n}},Lze=(e,t)=>{const n=document.createElement("a");n.href=e,n.download=t,n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()},Ize=e=>{const t=e.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");return t.length>0?t.slice(0,80):"canvas"},Qee=(e,t)=>`${Ize(e??"canvas")}.${t}`,Eze=({projectId:e,getReactFlow:t})=>{const[n,r]=g.useState(null),o=g.useCallback(()=>r(null),[]),a=g.useCallback(async()=>{const l=t();if(!l)return null;const u=document.querySelector(".react-flow__viewport");if(!u)return null;const d=l.getViewport();try{return await l.fitView({duration:0,padding:.1}),await new Promise(f=>requestAnimationFrame(()=>f())),await Sze(u)}finally{l.setViewport(d,{duration:0})}},[t]),i=g.useCallback(async()=>{r(null);try{const l=await a();if(!l)return;Lze(l.dataUrl,Qee(e,"png"))}catch(l){r(l instanceof Error?l.message:String(l))}},[a,e]),s=g.useCallback(async()=>{r(null);try{const l=await a();if(!l)return;const{jsPDF:u}=await PNe(async()=>{const{jsPDF:p}=await import("./jspdf.es.min-xZpq8bcn.js").then(y=>y.j);return{jsPDF:p}},[]),d=l.width>l.height?"landscape":"portrait",f=new u({orientation:d,unit:"px",format:[l.width,l.height],hotfixes:["px_scaling"]});f.addImage(l.dataUrl,"PNG",0,0,l.width,l.height),f.save(Qee(e,"pdf"))}catch(l){r(l instanceof Error?l.message:String(l))}},[a,e]),c=g.useCallback(async()=>{const l=await a();return l==null?void 0:l.dataUrl},[a]);return{exportPdf:s,exportPng:i,capturePreview:c,lastError:n,clearError:o}},Aze={showToolbar:!0,showStyleStrip:!0,showDetailPanel:!0,showStatusBadges:!0,showResizeHandles:!0,showControls:!0,showShareMenu:!0,showRestart:!0,enableKeyboard:!0,enableContextMenu:!0,enableDragDrop:!0,enableImageDrop:!0,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},Pze={showToolbar:!1,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!0,showResizeHandles:!1,showControls:!0,showShareMenu:!0,showRestart:!1,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},_ze={showToolbar:!1,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!1,showResizeHandles:!1,showControls:!1,showShareMenu:!1,showRestart:!1,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!1,enablePan:!1,enableSelection:!1,enableNodeMove:!1,enableEmbed:!1};function Rze(e){const t=e.mode==="edit"?Aze:e.mode==="mini"?_ze:Pze;return{showToolbar:e.showToolbar??t.showToolbar,showStyleStrip:e.showStyleStrip??t.showStyleStrip,showDetailPanel:e.showDetailPanel??t.showDetailPanel,showStatusBadges:e.showStatusBadges??t.showStatusBadges,showResizeHandles:e.showResizeHandles??t.showResizeHandles,showControls:e.showControls??t.showControls,showShareMenu:e.showShareMenu??t.showShareMenu,showRestart:e.showRestart??t.showRestart,enableKeyboard:e.enableKeyboard??t.enableKeyboard,enableContextMenu:e.enableContextMenu??t.enableContextMenu,enableDragDrop:e.enableDragDrop??t.enableDragDrop,enableImageDrop:e.enableImageDrop??t.enableImageDrop,enableZoom:e.enableZoom??t.enableZoom,enablePan:e.enablePan??t.enablePan,enableSelection:e.enableSelection??t.enableSelection,enableNodeMove:e.enableNodeMove??t.enableNodeMove,enableEmbed:e.enableEmbed??t.enableEmbed}}const Jee=40,ih={padding:.15,duration:300,includeHiddenNodes:!1};function Tze(e){return e===void 0||e===!1?{onMount:!1,onExternalNodeChange:!1}:e===!0?{onMount:!0,onExternalNodeChange:!0}:{onMount:e.onMount??!0,onExternalNodeChange:e.onExternalNodeChange??!0}}const ete=e=>{if("clientX"in e)return{clientX:e.clientX,clientY:e.clientY};const t=e.changedTouches[0]??e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null},jze=(e,t)=>{var r;const n=document.elementsFromPoint(e,t);for(const o of n){const a=(r=o.closest)==null?void 0:r.call(o,".react-flow__node");if(a)return a}return null},ade=15,xF=(e,t,n)=>{const r=jze(t,n);if(r)return r;if(!e)return null;let o=null,a=ade;const i=e.querySelectorAll(".react-flow__node");for(const s of i){const c=s.getBoundingClientRect();if(c.width===0||c.height===0)continue;const l=Math.max(c.left-t,0,t-c.right),u=Math.max(c.top-n,0,n-c.bottom),d=Math.hypot(l,u);d<=a&&(o=s,a=d)}return o};function tte(e,t,n,r,o){if(e==="source"?(r==null?void 0:r.targetPin)!==void 0||(r==null?void 0:r.targetHandleAutoPicked)===!1:(r==null?void 0:r.sourcePin)!==void 0||(r==null?void 0:r.sourceHandleAutoPicked)===!1)return;const i=e==="source"?n:t,s=e==="source"?t:n,c=o(i),l=o(s);if(!c||!l)return;const u=c.measured.width??c.width??0,d=c.measured.height??c.height??0,f=l.measured.width??l.width??0,p=l.measured.height??l.height??0;if(u===0||d===0||f===0||p===0)return;const y={x:c.internals.positionAbsolute.x,y:c.internals.positionAbsolute.y,w:u,h:d},k={x:l.internals.positionAbsolute.x+f/2,y:l.internals.positionAbsolute.y+p/2};return tMe(y,rR(y,k))}function Nze(e,t,n,r){if(r===null)return"no-op";const o=e==="source"?t:n;return r===(e==="source"?n:t)?"self-loop":r===o?"pin-own":"reconnect-and-pin"}const zze=(e,t)=>{if(!t)return e;const n=t.data?{...e.data,...t.data}:e.data;return{...e,...t,data:n}},Dze=(e,t)=>t?{...e,...t}:e,qze={playNode:dCe,stateNode:RCe,shapeNode:CCe,imageNode:tbe,iconNode:hMe,htmlNode:XMe},Oze={editableEdge:jCe},Fze={zIndex:0},Hze=8,nte=(e,t)=>e?typeof e=="string"?`url('#${e}')`:`url('#${`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`}')`:void 0,Bze=e=>function({fromX:n,fromY:r,toX:o,toY:a,fromPosition:i,toPosition:s,connectionLineStyle:c}){const l=Fe(W=>e.current?W.edges.find(q=>q.reconnectable===!0)??null:null),u=l==null?void 0:l.data,d=Fe(W=>{var R;const q=W.connection;return((R=q==null?void 0:q.fromHandle)==null?void 0:R.nodeId)??null}),f=Fe(W=>l!=null&&l.source?W.nodeLookup.get(l.source)??null:null),p=Fe(W=>l!=null&&l.target?W.nodeLookup.get(l.target)??null:null),y=Fe(W=>d?W.nodeLookup.get(d)??null:null),k=(l==null?void 0:l.source)===d,w=l?k?f:p:y,v=k?p:f,M=k?u==null?void 0:u.sourcePin:u==null?void 0:u.targetPin,x=k?u==null?void 0:u.sourceHandleAutoPicked:u==null?void 0:u.targetHandleAutoPicked;let b=n,S=r,C=i;if(w){const W=w.measured.width??w.width??0,q=w.measured.height??w.height??0;if(W>0&&q>0){const R={x:w.internals.positionAbsolute.x,y:w.internals.positionAbsolute.y,w:W,h:q};let G=null;if(M)G=oR(R,M);else if(x!==!1&&v){const X=v.measured.width??v.width??0,Y=v.measured.height??v.height??0;if(X>0&&Y>0){const oe={x:v.internals.positionAbsolute.x+X/2,y:v.internals.positionAbsolute.y+Y/2};G=rR(R,oe)}}G&&(b=G.x,S=G.y,C=rte[G.side])}}const L=Fe(W=>W.transform[2]),P=Fe(W=>W.nodeLookup),T=Fe(W=>{var q;return((q=W.connection.toHandle)==null?void 0:q.nodeId)??null});let _=o,A=a,I=s;if(L>0){const W=ade/L,q=l?k?l.target:l.source:null;let R=null;if(T&&T!==q){const G=P.get(T)??null;G&&(R=G)}if(!R){let G=W;for(const X of P.values()){if(q&&X.id===q||w&&X.id===w.id)continue;const Y=X.measured.width??X.width??0,oe=X.measured.height??X.height??0;if(Y===0||oe===0)continue;const ee=X.internals.positionAbsolute.x,ae=X.internals.positionAbsolute.y,ve=Math.max(ee-o,0,o-(ee+Y)),Se=Math.max(ae-a,0,a-(ae+oe)),be=Math.hypot(ve,Se);be<=G&&(G=be,R=X)}}if(!R&&l&&w){const G=w.measured.width??w.width??0,X=w.measured.height??w.height??0;if(G>0&&X>0){const Y=w.internals.positionAbsolute.x,oe=w.internals.positionAbsolute.y,ee=Math.max(Y-o,0,o-(Y+G)),ae=Math.max(oe-a,0,a-(oe+X));Math.hypot(ee,ae)<=W&&(R=w)}}if(R){const G=R.measured.width??R.width??0,X=R.measured.height??R.height??0;if(G>0&&X>0){const Y=DH({x:R.internals.positionAbsolute.x,y:R.internals.positionAbsolute.y,w:G,h:X},{x:o,y:a}),oe=oR({x:R.internals.positionAbsolute.x,y:R.internals.positionAbsolute.y,w:G,h:X},Y);_=oe.x,A=oe.y,I=rte[oe.side]}}}const V=(u==null?void 0:u.path)==="step",[j]=V?H2({sourceX:b,sourceY:S,sourcePosition:C,targetX:_,targetY:A,targetPosition:I,borderRadius:Hze}):uT({sourceX:b,sourceY:S,sourcePosition:C,targetX:_,targetY:A,targetPosition:I}),H=(l==null?void 0:l.style)??c??void 0,O=Fe(W=>W.rfId),U=k?l==null?void 0:l.markerStart:l==null?void 0:l.markerEnd,z=k?l==null?void 0:l.markerEnd:l==null?void 0:l.markerStart,N=nte(U,O),E=nte(z,O);return m.jsx("path",{d:j,fill:"none",className:"react-flow__connection-path",style:H,markerStart:N,markerEnd:E})},rte={top:me.Top,right:me.Right,bottom:me.Bottom,left:me.Left};function Vze({storeApiRef:e}){const t=vt();return g.useEffect(()=>(e.current=t,()=>{e.current===t&&(e.current=null)}),[t,e]),null}function $ze({wrapperRef:e}){const t=Fe(r=>r.transform[2]),n=e.current;return n&&n.style.setProperty("--rf-zoom",String(t)),null}const Uze=new Set(["INPUT","TEXTAREA","SELECT"]),ide=e=>e?Uze.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1;function Wze(e){const{event:t,selectedNodeIds:n,hasClipboard:r,activeElement:o,onCopySelection:a,onPasteSelection:i}=e;if(!(t.metaKey||t.ctrlKey)||t.shiftKey||t.altKey)return!1;const s=t.key.toLowerCase();return s!=="c"&&s!=="v"||ide(o)?!1:s==="c"?n.length===0||!a?!1:(t.preventDefault(),a([...n]),!0):!r||!i?!1:(t.preventDefault(),i(),!0)}const ote=(e,t)=>{var n;return((n=e==null?void 0:e[t])==null?void 0:n.status)??"idle"},Gze=(e,t)=>{var n;return(n=e==null?void 0:e[t])==null?void 0:n.status},Kze=(e,t)=>{var n,r;return((n=e==null?void 0:e[t])==null?void 0:n.status)==="error"?(r=e[t])==null?void 0:r.error:void 0};function Zze(e,t){var mU,gU;const{mode:n,adapter:r,projectId:o,nodes:a,connectors:i,selectedNodeIds:s,selectedConnectorIds:c,onSelectionChange:l,runtime:u,onPlayNode:d,onNodePositionChange:f,onNodePositionsChange:p,onNodeResize:y,onHtmlNodeFitToContent:k,onMultiResize:w,onNodeNameChange:v,onNodeDescriptionChange:M,onConnectorLabelChange:x,onCreateShapeNode:b,onCreateImageFromFile:S,onRetryImageUpload:C,onCreateHtmlNode:L,onCreateConnector:P,onReconnectConnector:T,onReorderNode:_,onDeleteNode:A,onCopyNode:I,onPasteAt:V,hasClipboard:j,onCopySelection:H,onPasteSelection:O,selectedNodes:U,selectedConnectors:z,onStyleNode:N,onStyleNodePreview:E,onStyleNodes:W,onStyleNodesPreview:q,onStyleConnector:R,onStyleConnectorPreview:G,onRfInit:X,onTidy:Y,onNodeClick:oe,onConnectorClick:ee,onPaneClick:ae,onCreateAndConnectFromPane:ve,pendingEditNodeId:Se,iconPickerOpen:be,onOpenIconPicker:we,onCloseIconPicker:te,onPickIcon:ie,onRequestIconReplace:Te,onPinEndpoint:Ae,onUnpinEndpoint:at,onToggleNodeLock:Qe,activeShape:le,onSelectShape:Q,disableSidebar:ue,statusReport:ge,onNameChange:Me,onDescriptionChange:qe,onDetailChange:re,onIconChange:he,autoFitView:Ie,autoFitViewSignal:He,customIcons:Ue,onExportToCloud:Rt,onRestartDemo:Oe,showToolbar:je,showStyleStrip:Pt,showDetailPanel:sr,showStatusBadges:Dt,showResizeHandles:Dn,showControls:en,showShareMenu:$u,showRestart:Uu,enableKeyboard:da,enableContextMenu:ha,enableDragDrop:Xr,enableImageDrop:gi,enableZoom:fa,enablePan:xr,enableSelection:Yr,enableNodeMove:wr,enableEmbed:Wu}=e,Ve=g.useMemo(()=>Rze({mode:n,showToolbar:je,showStyleStrip:Pt,showDetailPanel:sr,showStatusBadges:Dt,showResizeHandles:Dn,showControls:en,showShareMenu:$u,showRestart:Uu,enableKeyboard:da,enableContextMenu:ha,enableDragDrop:Xr,enableImageDrop:gi,enableZoom:fa,enablePan:xr,enableSelection:Yr,enableNodeMove:wr,enableEmbed:Wu}),[n,je,Pt,sr,Dt,Dn,en,$u,Uu,da,ha,Xr,gi,fa,xr,Yr,wr,Wu]),yt=n==="edit",Qr=g.useRef(Ve);g.useEffect(()=>{Qr.current=Ve},[Ve]);const Po=Ie??(n==="mini"?!0:void 0),qn=g.useMemo(()=>Tze(Po),[Po]),xn=u==null?void 0:u.runs,_o=u==null?void 0:u.statuses,On=(mU=u==null?void 0:u.pendingOverrides)==null?void 0:mU.nodes,Jr=(gU=u==null?void 0:u.pendingOverrides)==null?void 0:gU.connectors,un=g.useRef(null),Gt=g.useRef(null),eo=g.useRef(!1),pa=g.useRef(!1),to=g.useRef(!1),ki=g.useRef(qn);ki.current=qn,g.useEffect(()=>{if(eo.current||!qn.onMount||a.length===0)return;const K=Gt.current;K&&(K.fitView(ih),eo.current=!0)},[a,qn.onMount]);const vi=g.useRef(null),mt=le,xi=Q,ya=g.useRef(new Map),Mr=g.useCallback((K,J)=>(ya.current.set(K,J),()=>{ya.current.get(K)===J&&ya.current.delete(K)}),[]),[br,cr]=g.useState(!1),ma=g.useRef(!1);g.useEffect(()=>{ma.current=br},[br]);const wi=g.useRef(!1),Mi=g.useRef(!1),ga=g.useRef(!1),[wn,Ro]=g.useState(null),ka=g.useRef(null);g.useEffect(()=>{ka.current=wn},[wn]),g.useCallback(()=>{Ro(null)},[]);const va=g.useMemo(()=>Bze(ga),[]),To=g.useRef(null),bi=g.useRef(null),Mn=g.useCallback(K=>{const J=un.current;if(!J){To.current=K;return}const se=To.current;if(se&&se!==K){const de=J.querySelector(`.react-flow__node[data-id="${CSS.escape(se)}"]`);de==null||de.removeAttribute("data-connect-source")}if(K){const de=J.querySelector(`.react-flow__node[data-id="${CSS.escape(K)}"]`);de==null||de.setAttribute("data-connect-source","true")}To.current=K},[]),tn=g.useCallback(K=>{const J=un.current,se=bi.current;if(se!==K){if(J&&se){const de=J.querySelector(`.react-flow__node[data-id="${CSS.escape(se)}"]`);de==null||de.removeAttribute("data-connect-target")}if(J&&K){const de=J.querySelector(`.react-flow__node[data-id="${CSS.escape(K)}"]`);de==null||de.setAttribute("data-connect-target","true")}bi.current=K}},[]),Fn=g.useCallback(()=>{Mn(null),tn(null)},[Mn,tn]);g.useEffect(()=>{if(!br){tn(null);return}const K=J=>{const se=xF(un.current,J.clientX,J.clientY),de=(se==null?void 0:se.getAttribute("data-id"))??null;if(de&&de===To.current){tn(null);return}tn(de)};return document.addEventListener("pointermove",K),()=>{document.removeEventListener("pointermove",K)}},[br,tn]);const[no,jo]=g.useState(null),[Hn,xa]=g.useState(null),Cr=g.useRef(null),st=g.useRef(null),Sr=g.useRef(null),bn=g.useRef(!1);g.useEffect(()=>{Cr.current=mt},[mt]);const Cn=g.useCallback(()=>{xi(null),jo(null),xa(null),Cr.current=null,st.current=null,Sr.current=null,bn.current=!1},[xi]);g.useEffect(()=>{if(!Ve.enableKeyboard)return;const K=J=>{var ye,ze;if(J.key!=="Escape"||ide(document.activeElement))return;if(Cr.current){J.preventDefault(),Cn();return}if(ma.current){J.preventDefault(),wi.current=!0,Mi.current=!0;try{(ye=vi.current)==null||ye.getState().cancelConnection()}catch{}document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0})),cr(!1);return}if(ka.current){J.preventDefault(),Ro(null);return}const se=Ir.current.size>0,de=zo.current.size>0;(se||de)&&(J.preventDefault(),(ze=oo.current)==null||ze.call(oo,[],[]))};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[Cn,Ve.enableKeyboard]),g.useEffect(()=>{if(!Ve.enableKeyboard)return;const K=J=>{Wze({event:J,selectedNodeIds:s,hasClipboard:!!j,activeElement:document.activeElement,onCopySelection:H,onPasteSelection:O})};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[s,j,H,O,Ve.enableKeyboard]);const Ci=g.useCallback(K=>{var de,ye;if(!Cr.current)return;const J=K.target;if(!(J!=null&&J.classList.contains("react-flow__pane")))return;const se={x:K.clientX,y:K.clientY};bn.current=!0,st.current=se,Sr.current=se,jo(se),xa(se);try{(ye=(de=K.currentTarget).setPointerCapture)==null||ye.call(de,K.pointerId)}catch{}K.preventDefault(),K.stopPropagation()},[]),Gu=g.useCallback(K=>{if(!bn.current)return;const J={x:K.clientX,y:K.clientY};Sr.current=J,xa(J)},[]),YT=g.useCallback(K=>{var Sa,kU;if(!bn.current)return;bn.current=!1;try{(kU=(Sa=K.currentTarget).releasePointerCapture)==null||kU.call(Sa,K.pointerId)}catch{}const J=st.current,se=Sr.current,de=Cr.current,ye=Gt.current;if(Cn(),!J||!se||!de||!ye)return;const ze=Math.min(J.x,se.x),xe=Math.min(J.y,se.y),Ee=Math.max(J.x,se.x),Je=Math.max(J.y,se.y),ht=Ee-ze,qt=Je-xe,Re=ye.screenToFlowPosition({x:ze,y:xe}),rt=ye.screenToFlowPosition({x:Ee,y:Je}),Ze=rt.x-Re.x,Ei=rt.y-Re.y,Ca=ht<Jee||qt<Jee,Do=Ca?uR[de].width:Ze,Zf=Ca?uR[de].height:Ei;b==null||b(de,Re,{width:Do,height:Zf})},[Cn,b]),ro=g.useRef(!1),Ku=g.useRef(!1),Of=g.useRef(new Map),No=g.useCallback(()=>{var K;pa.current&&(Ku.current||ro.current||(pa.current=!1,(K=Gt.current)==null||K.fitView(ih)))},[]),Ff=g.useCallback(K=>{Ku.current=K,K||No()},[No]);g.useEffect(()=>{var K;if(!to.current){to.current=!0;return}if(ki.current.onExternalNodeChange){if(Ku.current||ro.current){pa.current=!0;return}(K=Gt.current)==null||K.fitView(ih)}},[He]);const Hd=!!_||!!A||!!I||!!V||!!at,[dn,F]=g.useState(null),[B,Z]=g.useState(!1),[$,D]=g.useState(null),[ne,Pe]=g.useState(null),ke=g.useRef(null),dt=g.useRef(null);g.useEffect(()=>{if(!dn)return;const K=dt.current;if(!K)return;const J=new MouseEvent("contextmenu",{clientX:dn.x,clientY:dn.y,bubbles:!0,cancelable:!0,button:2,buttons:2});K.dispatchEvent(J)},[dn]);const Tt=g.useCallback(K=>{const J=ke.current;!J||!_||_(J,K)},[_]),Sn=g.useCallback(()=>{const K=ke.current;!K||!A||A(K)},[A]),Kt=g.useCallback(()=>{const K=ke.current;!K||!I||I(K)},[I]),Lr=g.useCallback(()=>{const K=ke.current;!K||!Te||Te(K)},[Te]),wa=g.useCallback(()=>{if(!Qe)return;const K=ke.current,J=K?[K]:[...s];J.length!==0&&Qe(J)},[Qe,s]);g.useCallback((K,J,se,de,ye)=>{Qr.current.enableContextMenu&&(ke.current=null,Z(!1),D(null),Pe({connectorId:K,kind:J,pinned:se}),F({x:de,y:ye}))},[]);const Zu=g.useCallback(()=>{const K=ne;!K||!at||at(K.connectorId,K.kind)},[ne,at]),_e=g.useCallback(()=>{if(!V)return;const K=dn,J=Gt.current;if(!K||!J)return;const se=J.screenToFlowPosition({x:K.x,y:K.y});V(se)},[dn,V]),nt=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||""),Ne=nt?"⌘C":"Ctrl+C",it=nt?"⌘V":"Ctrl+V",jt=g.useMemo(()=>new Set(s),[s]),Bn=g.useMemo(()=>{const K=new Set;for(const J of a)J.data.locked===!0&&K.add(J.id);return K},[a]),Vn=g.useMemo(()=>new Set(c),[c]),QT=g.useMemo(()=>{if(s.length<2)return[];const K=On,J=[];for(const se of s){const de=a.find(Ee=>Ee.id===se);if(!de)continue;const ye=K==null?void 0:K[se],ze=(ye==null?void 0:ye.data)??{},xe=de.data;J.push({id:se,position:(ye==null?void 0:ye.position)??de.position,data:{width:ze.width??xe.width,height:ze.height??xe.height,locked:ze.locked??xe.locked}})}return J},[a,On,s]),JT=U??[],Si=g.useMemo(()=>{const K=ye=>{const ze=yt?void 0:Of.current.get(ye.id),xe={id:ye.id,type:ye.type,position:ze??ye.position,data:{...ye.data,projectId:o,onRetryUpload:C,status:Gze(xn,ye.id),errorMessage:Kze(xn,ye.id),statusReport:_o==null?void 0:_o[ye.id],onPlay:d,onResize:y,setResizing:Ff,onFitToContent:ye.type==="htmlNode"?k:void 0,onNameChange:(()=>{if(yt&&!(ye.type==="shapeNode"&&ye.data.shape==="ellipse"))return v})(),onDescriptionChange:(()=>{if(yt){if(ye.type==="shapeNode"){const Ee=ye.data.shape;return Ee==="rectangle"||Ee==="ellipse"||Ee==="sticky"?M:void 0}if(!(ye.type==="imageNode"||ye.type==="iconNode"))return M}})(),onIconChange:(()=>{if(yt&&!(ye.type!=="playNode"&&ye.type!=="stateNode"))return he})(),autoEditOnMount:Se===ye.id?!0:void 0},selected:jt.has(ye.id)};return ye.data.width!==void 0&&(xe.width=ye.data.width),ye.data.height!==void 0&&(xe.height=ye.data.height),jt.has(ye.id)||(xe.connectable=!1),ye.data.locked===!0&&(xe.draggable=!1),xe},J=a.map(ye=>K(zze(ye,On==null?void 0:On[ye.id]))),se=new Set(a.map(ye=>ye.id)),de=[];if(On)for(const[ye,ze]of Object.entries(On)){if(se.has(ye))continue;const xe=ze;typeof xe.type!="string"||!xe.position||!xe.data||de.push(K({...xe,id:ye}))}return[...J,...de]},[o,a,jt,xn,_o,d,y,k,Ff,On,v,M,he,C,Se,yt]),[ej,tj]=g.useState(Si);g.useEffect(()=>{ro.current||Ku.current||tj(Si)},[Si]),g.useEffect(()=>{Bd.current=ej},[ej]);const Ir=g.useRef(jt);g.useEffect(()=>{Ir.current=jt},[jt]);const oo=g.useRef(l);g.useEffect(()=>{oo.current=l},[l]);const zo=g.useRef(Vn);g.useEffect(()=>{zo.current=Vn},[Vn]);const Bd=g.useRef(Si),Li=g.useRef(!1),Hf=g.useRef(new Set),Bf=g.useRef(new Set),nj=g.useRef(new Set),rj=g.useRef(new Set),Ma=g.useRef(null),bde=g.useCallback(K=>{var rt;const J=Li.current?nj.current:(rt=Ma.current)!=null&&rt.shift?Ma.current.nodeIds:null,se=J&&J.size>0?K.filter(Ze=>Ze.type!=="select"?!0:!(Ze.selected===!1&&J.has(Ze.id))):K,de=new Set;for(const Ze of se)Ze.type==="select"&&de.add(Ze.id);const ye=Mie(se,Bd.current),ze=Ir.current,xe=Li.current||ze.size===0?ye:ye.map(Ze=>ze.has(Ze.id)&&!de.has(Ze.id)&&!Ze.selected?{...Ze,selected:!0}:Ze);if(Bd.current=xe,tj(xe),de.size===0)return;if(Li.current){for(const Ze of se)Ze.type==="select"&&(Ze.selected?Hf.current.add(Ze.id):Hf.current.delete(Ze.id));return}const Ee=oo.current;if(!Ee)return;const Je=xe.filter(Ze=>Ze.selected).map(Ze=>Ze.id),ht=Ir.current;ht.size===Je.length&&Je.every(Ze=>ht.has(Ze))||(Ir.current=new Set(Je),Ee(Je,[...zo.current]))},[]),Vf=g.useRef([]),Cde=g.useCallback(K=>{var qt;const J=Li.current?rj.current:(qt=Ma.current)!=null&&qt.shift?Ma.current.edgeIds:null,se=J&&J.size>0?K.filter(Re=>Re.type!=="select"?!0:!(Re.selected===!1&&J.has(Re.id))):K,de=new Set;for(const Re of se)Re.type==="select"&&de.add(Re.id);if(de.size===0)return;if(Li.current){for(const Re of se)Re.type==="select"&&(Re.selected?Bf.current.add(Re.id):Bf.current.delete(Re.id));return}const ye=oo.current;if(!ye)return;const xe=bie(se,Vf.current).filter(Re=>Re.selected).map(Re=>Re.id),Ee=zo.current;Ee.size===xe.length&&xe.every(Re=>Ee.has(Re))||(zo.current=new Set(xe),ye([...Ir.current],xe))},[]),Sde=g.useCallback(K=>{Li.current=!0;const J=Ma.current,se=(J==null?void 0:J.shift)??(K.shiftKey||K.metaKey||K.ctrlKey);nj.current=se?new Set((J==null?void 0:J.nodeIds)??Ir.current):new Set,rj.current=se?new Set((J==null?void 0:J.edgeIds)??zo.current):new Set,Hf.current=new Set(nj.current),Bf.current=new Set(rj.current)},[]),Lde=g.useCallback(()=>{Li.current=!1,Ma.current=null;const K=oo.current;if(!K)return;const J=[...Hf.current],se=new Set(J),de=new Set(Bf.current);for(const Je of Vf.current)se.has(Je.source)&&se.has(Je.target)&&de.add(Je.id);const ye=Ir.current,ze=zo.current,xe=ye.size===se.size&&J.every(Je=>ye.has(Je)),Ee=ze.size===de.size&&[...de].every(Je=>ze.has(Je));xe&&Ee||(Ir.current=new Set(J),zo.current=new Set(de),K(J,[...de]))},[]),Ide=g.useCallback(K=>{if(Ma.current=null,Cr.current||K.button!==0)return;const J=K.target;J!=null&&J.classList.contains("react-flow__pane")&&(Ma.current={shift:K.shiftKey||K.metaKey||K.ctrlKey,nodeIds:new Set(Ir.current),edgeIds:new Set(zo.current)})},[]),Ede=g.useCallback(K=>{if(!Qr.current.enableContextMenu||Ir.current.size<2)return;const se=K.target;se!==dt.current&&(se!=null&&se.closest(".seeflow-connector-endpoint-dot")||(K.preventDefault(),K.stopPropagation(),ke.current=null,Z(!0),D(null),Pe(null),F({x:K.clientX,y:K.clientY})))},[]),Ade=g.useCallback(K=>{const J=K.dataTransfer;if(!J)return;const se=J.types?Array.from(J.types):[],de=se.includes("Files"),ye=se.includes(zJ),ze=de&&!!S&&Ve.enableImageDrop,xe=ye&&!!L&&Ve.enableDragDrop;if(!(!ze&&!xe)){K.preventDefault();try{J.dropEffect="copy"}catch{}}},[S,L,Ve.enableImageDrop,Ve.enableDragDrop]),Pde=g.useCallback(K=>{const J=K.dataTransfer;if((J!=null&&J.types?Array.from(J.types):[]).includes(zJ)&&L&&Ve.enableDragDrop){K.preventDefault();const ze=Gt.current;if(!ze)return;const xe=ze.screenToFlowPosition({x:K.clientX,y:K.clientY});L({position:xe});return}if(!S||!Ve.enableImageDrop)return;const ye={x:K.clientX,y:K.clientY};K.preventDefault(),Vke({dataTransfer:J,clientPos:ye,rfInstance:Gt.current,computeDims:$ke,dispatch:S})},[S,L,Ve.enableImageDrop,Ve.enableDragDrop]),sU=!!T,cU=Vn.size===1?[...Vn][0]:null,oj=g.useMemo(()=>{const K=Ee=>{const Je=ote(xn,Ee.source)==="running"||ote(xn,Ee.target)==="running",ht=Vn.has(Ee.id),qt=X8e(Ee,Je,ht);ht&&(qt.selected=!0);const Re=sU&&Ee.id===cU,rt=Re?{...qt,reconnectable:!0}:qt;return{...rt,data:{...rt.data,onLabelChange:yt?x:void 0,reconnectable:Re,registerEditHandle:Mr}}},J=new Set(i.map(Ee=>Ee.id)),se=i.map(Ee=>K(Dze(Ee,Jr==null?void 0:Jr[Ee.id]))),de=[];if(Jr)for(const[Ee,Je]of Object.entries(Jr)){if(J.has(Ee))continue;const ht=Je;typeof ht.source!="string"||typeof ht.target!="string"||typeof ht.kind!="string"||de.push(K({...ht,id:Ee}))}const ye=[...se,...de],ze=[],xe=[];for(const Ee of ye)Vn.has(Ee.id)?xe.push(Ee):ze.push(Ee);return[...ze,...xe]},[i,xn,Vn,cU,Jr,x,sU,Mr,yt]);g.useEffect(()=>{Vf.current=oj},[oj]);const _de=g.useCallback(()=>{const K=Gt.current,J=Bd.current;if(J.length<2)return;const se=J.map(Re=>{var Do;const rt=(Do=K==null?void 0:K.getInternalNode(Re.id))==null?void 0:Do.measured,Ze=Re.data,Ei=(rt==null?void 0:rt.width)??Ze.width??200,Ca=(rt==null?void 0:rt.height)??Ze.height??120;return{id:Re.id,width:Ei,height:Ca,position:Re.position}}),de=Vf.current.map(Re=>({source:Re.source,target:Re.target})),ye=eae(se,de);let ze=Number.POSITIVE_INFINITY,xe=Number.POSITIVE_INFINITY,Ee=Number.POSITIVE_INFINITY,Je=Number.POSITIVE_INFINITY;for(const Re of se){Re.position.x<ze&&(ze=Re.position.x),Re.position.y<xe&&(xe=Re.position.y);const rt=ye.get(Re.id);rt&&(rt.x<Ee&&(Ee=rt.x),rt.y<Je&&(Je=rt.y))}const ht=Number.isFinite(ze)&&Number.isFinite(Ee)?ze-Ee:0,qt=Number.isFinite(xe)&&Number.isFinite(Je)?xe-Je:0;tj(Re=>Re.map(rt=>{const Ze=ye.get(rt.id);return Ze?{...rt,position:{x:Ze.x+ht,y:Ze.y+qt}}:rt}))},[]),$f=Y??(yt?void 0:_de),Uf=g.useRef(!1),lU=g.useRef(null),Rde=g.useCallback(K=>{var Ee;if(!yt||!P)return;const{source:J,target:se}=K;if(!J||!se||J===se)return;Uf.current=!0;const de=((Ee=lU.current)==null?void 0:Ee.nodeId)??null,ye=de!==null&&de===se&&de!==J;P(ye?se:J,ye?J:se)},[P,yt]),aj=g.useCallback(K=>{const J=se=>{if(!se)return!1;const de=Bd.current.find(ye=>ye.id===se);return de?de.type==="shapeNode"&&de.data.shape==="text":!1};return!J(K.source)&&!J(K.target)},[]),Tde=g.useCallback((K,J)=>{var qt;cr(!1),Fn();const se=Uf.current;if(Uf.current=!1,se||ga.current)return;if(wi.current){wi.current=!1;return}if(!P)return;const de=(qt=J.fromNode)==null?void 0:qt.id,ye=J.fromHandle;if(!de||!ye)return;const ze=ete(K);if(!ze)return;const xe=xF(un.current,ze.clientX,ze.clientY);if(!xe)return;const Ee=xe.getAttribute("data-id");if(!Ee||Ee===de||!aj({source:de,target:Ee,sourceHandle:null,targetHandle:null}))return;let Je;const ht=Gt.current;if(ht){const Re=ht.getInternalNode(Ee);if(Re){const rt=Re.measured.width??Re.width??0,Ze=Re.measured.height??Re.height??0;if(rt>0&&Ze>0){const Ei=ht.screenToFlowPosition({x:ze.clientX,y:ze.clientY});Je=DH({x:Re.internals.positionAbsolute.x,y:Re.internals.positionAbsolute.y,w:rt,h:Ze},Ei)}}}P(de,Ee,Je?{targetPin:Je}:void 0)},[P,Fn,aj]),Wf=g.useRef(!1),jde=g.useCallback((K,J)=>{if(!T)return;const{source:se,target:de,sourceHandle:ye,targetHandle:ze}=J;if(!se||!de||se===de)return;const xe={};if(se!==K.source&&(xe.source=se),de!==K.target&&(xe.target=de),typeof ye=="string"&&ye!==K.sourceHandle&&(xe.sourceHandle=ye),typeof ze=="string"&&ze!==K.targetHandle&&(xe.targetHandle=ze),xe.source===void 0&&xe.target===void 0&&xe.sourceHandle===void 0&&xe.targetHandle===void 0)return;(xe.source!==void 0||xe.sourceHandle!==void 0)&&(xe.sourceHandleAutoPicked=!1),(xe.target!==void 0||xe.targetHandle!==void 0)&&(xe.targetHandleAutoPicked=!1);const Ee=Gt.current;if(!(xe.source===void 0&&xe.target===void 0)&&Ee){const ht=xe.source!==void 0?"source":"target",qt=tte(ht,K.source,K.target,K.data,Re=>Ee.getInternalNode(Re)??null);qt&&(ht==="source"?xe.targetPin=qt:xe.sourcePin=qt)}Wf.current=!0,T(K.id,xe)},[T]),Nde=g.useCallback((K,J,se,de)=>{var Zf;cr(!1),Fn(),ga.current=!1;const ye=Wf.current;if(Wf.current=!1,ye)return;if(Mi.current){Mi.current=!1;return}if(!T)return;const ze=ete(K);let xe=((Zf=de.toNode)==null?void 0:Zf.id)??null;if(!xe&&ze){const Sa=xF(un.current,ze.clientX,ze.clientY);xe=(Sa==null?void 0:Sa.getAttribute("data-id"))??null}const Ee=se==="source"?"target":"source",Je=Nze(Ee,J.source,J.target,xe);if(Je==="no-op"||Je==="self-loop"||!ze)return;const ht=Gt.current;if(!ht)return;const qt=Je==="pin-own"?Ee==="source"?J.source:J.target:xe,Re=ht.getInternalNode(qt);if(!Re)return;const rt=Re.measured.width??Re.width??0,Ze=Re.measured.height??Re.height??0;if(rt===0||Ze===0)return;const Ei=ht.screenToFlowPosition({x:ze.clientX,y:ze.clientY}),Ca=DH({x:Re.internals.positionAbsolute.x,y:Re.internals.positionAbsolute.y,w:rt,h:Ze},Ei);if(Je==="pin-own"){if(!Ae)return;Ae(J.id,Ee,Ca);return}const Do=tte(Ee,J.source,J.target,J.data,Sa=>ht.getInternalNode(Sa)??null);Ee==="source"?T(J.id,{source:xe,sourceHandle:null,sourceHandleAutoPicked:!1,sourcePin:Ca,...Do?{targetPin:Do}:{}}):T(J.id,{target:xe,targetHandle:null,targetHandleAutoPicked:!1,targetPin:Ca,...Do?{sourcePin:Do}:{}})},[T,Fn,Ae]),Ii=g.useMemo(()=>{var Ee;if(!no||!Hn)return null;const K=(Ee=un.current)==null?void 0:Ee.getBoundingClientRect(),J=(K==null?void 0:K.left)??0,se=(K==null?void 0:K.top)??0,de=Math.min(no.x,Hn.x),ye=Math.min(no.y,Hn.y),ze=Math.abs(Hn.x-no.x),xe=Math.abs(Hn.y-no.y);return{left:de-J,top:ye-se,width:ze,height:xe}},[no,Hn]),zde=mt?nce(mt):"",Dde=mt?rce(mt):void 0,qde=mt==="text",[uU,dU]=g.useState(!1),[Ode,Gf]=g.useState(!1),[Fde,hU]=g.useState(!1),ba=Eze({projectId:o,getReactFlow:()=>Gt.current});g.useImperativeHandle(t,()=>({exportPdf:ba.exportPdf,exportPng:ba.exportPng,openEmbedDialog:()=>hU(!0),capturePreview:ba.capturePreview}),[ba.exportPdf,ba.exportPng,ba.capturePreview]),g.useEffect(()=>{if(!Ve.enableKeyboard)return;const K=de=>{if(!de)return!1;const ye=de.tagName;return ye==="INPUT"||ye==="TEXTAREA"||ye==="SELECT"?!0:de instanceof HTMLElement&&de.isContentEditable},J=de=>{de.code==="Space"&&(K(document.activeElement)||(de.preventDefault(),dU(!0)))},se=de=>{de.code==="Space"&&(dU(!1),Gf(!1))};return window.addEventListener("keydown",J),window.addEventListener("keyup",se),()=>{window.removeEventListener("keydown",J),window.removeEventListener("keyup",se)}},[Ve.enableKeyboard]);const Kf=g.useCallback(K=>{if(K.length!==0){if(!yt){const J=Of.current;for(const se of K)J.set(se.id,{x:se.position.x,y:se.position.y});return}if(K.length===1){const J=K[0];J&&f&&f(J.id,{x:J.position.x,y:J.position.y});return}if(p){p(K.map(J=>({id:J.id,position:{x:J.position.x,y:J.position.y}})));return}if(f)for(const J of K)f(J.id,{x:J.position.x,y:J.position.y})}},[f,p,yt]),Hde=g.useCallback((K,J,se)=>{ro.current=!1,Kf(se),No()},[Kf,No]),Bde=g.useCallback(()=>{ro.current=!0},[]),Vde=g.useCallback((K,J)=>{ro.current=!1,Kf(J),No()},[Kf,No]),$de=g.useCallback((K,J)=>{oe==null||oe(J.id)},[oe]),Ude=g.useCallback(K=>{ae==null||ae()},[ae]),Wde=g.useCallback((K,J)=>{ee==null||ee(J.id)},[ee]),fU=mt?"crosshair":uU?Ode?"grabbing":"grab":void 0,pU=s[0],yU=c[0],Gde=pU?a.find(K=>K.id===pU)??null:null,Kde=yU?i.find(K=>K.id===yU)??null:null,Zde=o??null,Xde=Ve.showDetailPanel&&!ue,Yde=g.useMemo(()=>({custom:Ue??{}}),[Ue]);return m.jsx(VMe,{value:Yde,children:m.jsx("div",{"data-testid":"seeflow-canvas","data-mode":n,ref:un,className:"seeflow-canvas-root sf:relative sf:h-full sf:w-full",style:fU?{cursor:fU}:void 0,onPointerDownCapture:Ide,onPointerDown:K=>{uU&&Gf(!0),Ci(K)},onPointerMove:Gu,onPointerUp:K=>{Gf(!1),YT(K)},onPointerCancel:()=>{bn.current=!1,st.current=null,Sr.current=null,jo(null),xa(null),Gf(!1)},onContextMenuCapture:Ede,onDragOver:Ade,onDrop:Pde,children:m.jsxs($9e,{containerRef:un,children:[m.jsxs(h8e,{nodes:ej,edges:oj,onNodesChange:bde,nodeTypes:qze,edgeTypes:Oze,proOptions:{hideAttribution:!0},fitView:!0,minZoom:n==="mini"?.05:.5,nodesDraggable:(yt?!!f:!0)&&!mt&&Ve.enableNodeMove,nodesConnectable:yt&&!!P&&!mt,deleteKeyCode:yt?["Backspace","Delete"]:null,zoomOnScroll:Ve.enableZoom,zoomOnPinch:Ve.enableZoom,className:br?"seeflow-connecting":void 0,onConnect:yt?Rde:void 0,isValidConnection:aj,onConnectStart:(K,J)=>{cr(!0),Uf.current=!1,lU.current={nodeId:J.nodeId??null,handleType:J.handleType??null},Mn(J.nodeId??null)},onConnectEnd:Tde,onReconnect:yt&&T?jde:void 0,onReconnectStart:(K,J,se)=>{cr(!0),Wf.current=!1,ga.current=!0;const de=se==="source"?J.source:J.target;Mn(de)},onReconnectEnd:Nde,connectionLineComponent:va,connectionLineStyle:{strokeWidth:2},connectionRadius:32,reconnectRadius:10,edgesReconnectable:!1,elevateNodesOnSelect:!1,elementsSelectable:!mt&&Ve.enableSelection,selectNodesOnDrag:!1,nodeClickDistance:5,selectionOnDrag:!mt&&Ve.enableSelection,panOnDrag:mt?!1:Ve.enablePan?[1,2]:!1,selectionMode:rd.Partial,selectionKeyCode:null,multiSelectionKeyCode:mt?null:["Meta","Shift"],panActivationKeyCode:mt?null:"Space",onSelectionStart:Sde,onSelectionEnd:Lde,defaultEdgeOptions:Fze,zoomOnDoubleClick:!1,onInit:K=>{Gt.current=K;const J=un.current;J&&J.style.setProperty("--rf-zoom",String(K.getZoom())),!eo.current&&qn.onMount&&a.length>0&&(K.fitView(ih),eo.current=!0),X==null||X(K)},onMove:(K,J)=>{ka.current&&Ro(null);const se=un.current;se&&se.style.setProperty("--rf-zoom",String(J.zoom))},onEdgesChange:Cde,onNodeDragStart:()=>{ro.current=!0},onNodeDragStop:Hde,onSelectionDragStart:Bde,onSelectionDragStop:Vde,onNodeClick:$de,onEdgeClick:Wde,onEdgeDoubleClick:(K,J)=>{var se;(se=ya.current.get(J.id))==null||se()},onPaneClick:Ude,onNodeContextMenu:Ve.enableContextMenu&&Hd?(K,J)=>{K.preventDefault(),ke.current=J.id,Z(!0),D(J.type??null),Pe(null),F({x:K.clientX,y:K.clientY})}:void 0,onPaneContextMenu:Ve.enableContextMenu&&V?K=>{K.preventDefault(),ke.current=null,Z(!1),D(null),Pe(null),F({x:K.clientX,y:K.clientY})}:void 0,children:[m.jsx(Vze,{storeApiRef:vi}),m.jsx($ze,{wrapperRef:un}),m.jsx(M8e,{gap:12,size:.6}),Ve.showControls?m.jsxs(A8e,{showInteractive:!1,showFitView:!1,children:[m.jsx(S1,{"data-testid":"controls-fit-view","aria-label":"Fit view",title:"Fit view",disabled:a.length===0,onClick:()=>{var K;(K=Gt.current)==null||K.fitView(ih)},children:m.jsx(j1,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})}),m.jsx(S1,{"data-testid":"controls-tidy","aria-label":"Tidy layout (⌘⇧L)",title:"Tidy layout (⌘⇧L)",disabled:!$f,onClick:()=>$f==null?void 0:$f(),children:m.jsx(Uh,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})})]}):null,Ve.showResizeHandles?m.jsx(CNe,{selectedNodes:QT,onMultiResize:w}):null,Ve.showToolbar&&b||Ve.showStyleStrip&&N&&R?m.jsx(cd,{position:"top-left",children:m.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-2",children:[Ve.showToolbar&&b?m.jsx(rEe,{activeShape:mt,onSelectShape:xi,iconPickerOpen:be??!1,onOpenIconPicker:we,onCloseIconPicker:te,onPickIcon:ie}):null,Ve.showStyleStrip&&N&&R?m.jsx(LNe,{nodes:JT,connectors:z??[],onStyleNode:N,onStyleNodePreview:E,onStyleNodes:W,onStyleNodesPreview:q,onStyleConnector:R,onStyleConnectorPreview:G,onRequestIconReplace:Te}):null]})}):null,Ve.showShareMenu||Ve.showRestart&&Oe?m.jsx(cd,{position:"top-right",children:m.jsxs("div",{className:"sf:flex sf:items-center sf:gap-1",children:[Ve.showRestart&&Oe?m.jsx(xNe,{onRestartDemo:Oe}):null,Ve.showShareMenu?m.jsx(vNe,{mode:n==="mini"?"view":n,projectId:o,enableEmbed:Ve.enableEmbed,onDownloadPdf:ba.exportPdf,onDownloadPng:ba.exportPng,onExportToCloud:Rt,embedOpen:Fde,onEmbedOpenChange:hU}):null]})}):null]}),Ii?m.jsx("div",{"data-testid":"canvas-draw-ghost","data-ghost-shape":mt??void 0,"aria-hidden":!0,className:ce("sf:pointer-events-none sf:absolute sf:z-10",zde,qde?"sf:rounded-sm sf:border sf:border-dashed sf:border-muted-foreground/40":""),style:{...Dde,left:Ii.left,top:Ii.top,width:Ii.width,height:Ii.height},children:(()=>{const K=mt?v$[mt]:void 0;return K?m.jsx(K,{width:Ii.width,height:Ii.height,borderColor:ct(void 0,"node").borderColor,backgroundColor:ef,borderSize:o$}):null})()}):null,Ve.enableContextMenu&&Hd?m.jsxs(ILe,{onOpenChange:K=>{K||(F(null),ke.current=null,D(null),Pe(null))},children:[m.jsx(ELe,{asChild:!0,children:m.jsx("div",{ref:dt,"data-testid":"node-context-menu-trigger","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(dn==null?void 0:dn.x)??0,top:(dn==null?void 0:dn.y)??0,width:0,height:0}})}),m.jsxs(Dle,{"data-testid":"node-context-menu",children:[ne!=null&&ne.pinned&&at?m.jsx(_r,{"data-testid":"connector-endpoint-context-menu-unpin",onSelect:Zu,children:"Unpin"}):null,B&&I?m.jsxs(_r,{"data-testid":"node-context-menu-copy",onSelect:Kt,children:["Copy",m.jsx(XH,{children:Ne})]}):null,V?m.jsxs(_r,{"data-testid":"node-context-menu-paste",disabled:!j,onSelect:_e,children:["Paste",m.jsx(XH,{children:it})]}):null,B&&(I||V)&&($==="iconNode"&&Te||_||A)?m.jsx(Mh,{}):null,B&&$==="iconNode"&&Te?m.jsx(_r,{"data-testid":"node-context-menu-change-icon",onSelect:Lr,children:"Change icon"}):null,B&&$==="iconNode"&&Te&&(_||A)?m.jsx(Mh,{}):null,B&&_?m.jsxs(m.Fragment,{children:[m.jsx(_r,{"data-testid":"node-context-menu-to-front",onSelect:()=>Tt({op:"toFront"}),children:"Bring to front"}),m.jsx(_r,{"data-testid":"node-context-menu-forward",onSelect:()=>Tt({op:"forward"}),children:"Bring forward"}),m.jsx(_r,{"data-testid":"node-context-menu-backward",onSelect:()=>Tt({op:"backward"}),children:"Send backward"}),m.jsx(_r,{"data-testid":"node-context-menu-to-back",onSelect:()=>Tt({op:"toBack"}),children:"Send to back"})]}):null,B&&_&&(Qe||A)?m.jsx(Mh,{}):null,B&&Qe?(()=>{const K=ke.current,J=K?[K]:s,se=J.length>0&&J.every(de=>Bn.has(de))?"Unlock":"Lock";return m.jsx(_r,{"data-testid":"node-context-menu-toggle-lock",onSelect:wa,disabled:J.length===0,children:se})})():null,B&&Qe&&A?m.jsx(Mh,{}):null,B&&A?m.jsx(_r,{"data-testid":"node-context-menu-delete",onSelect:Sn,disabled:ke.current?Bn.has(ke.current):!1,children:"Delete"}):null]})]}):null,ve?m.jsxs(Nd,{open:!!wn,onOpenChange:K=>{K||Ro(null)},children:[m.jsx(U9e,{asChild:!0,children:m.jsx("div",{"data-testid":"drop-popover-anchor","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(wn==null?void 0:wn.clientX)??0,top:(wn==null?void 0:wn.clientY)??0,width:0,height:0}})}),m.jsx(Fu,{"data-testid":"drop-popover",align:"start",side:"bottom",sideOffset:4,className:"sf:w-auto sf:p-1",onOpenAutoFocus:K=>{K.preventDefault()},children:m.jsx("div",{role:"menu","aria-label":"Create connected node",className:"sf:flex sf:flex-col sf:gap-0.5",children:nEe.map(({shape:K,label:J,Icon:se})=>m.jsxs("button",{type:"button",role:"menuitem","data-testid":`drop-popover-shape-${K}`,onClick:()=>{const de=wn;de&&(ve({sourceNodeId:de.sourceNodeId,position:{x:de.flowX,y:de.flowY},shape:K}),Ro(null))},className:ce("sf:flex sf:items-center sf:gap-2 sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-left sf:text-sm","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus:bg-accent sf:focus:text-accent-foreground sf:focus:outline-hidden"),children:[m.jsx(se,{className:"sf:h-4 sf:w-4 sf:text-muted-foreground","aria-hidden":"true"}),m.jsx("span",{children:J})]},K))})})]}):null,Xde?m.jsx(Xje,{demoId:Zde,node:Gde,connector:Kde,adapter:r??null,statusReport:ge,onNameChange:Me,onDescriptionChange:qe,onDetailChange:re,onIconChange:he,onClose:()=>{var K;(K=oo.current)==null||K.call(oo,[],[])}}):null]})})})}const Xze=g.forwardRef(Zze);function Yze({open:e,onOpenChange:t,onCreated:n}){const[r,o]=g.useState(""),[a,i]=g.useState(null),[s,c]=g.useState(!1);g.useEffect(()=>{e&&(o(""),i(null),c(!1))},[e]);const l=r.trim(),u=l.length>0&&!s,d=async f=>{if(f.preventDefault(),!!u){c(!0),i(null);try{const p=await Ife({name:l});n(p),t(!1)}catch(p){i(p instanceof Error?p.message:String(p)),c(!1)}}};return m.jsx(RT,{open:e,onOpenChange:t,children:m.jsxs(Sf,{className:"sm:max-w-md","data-testid":"create-project-dialog",onOpenAutoFocus:f=>{f.preventDefault();const p=document.querySelector('[data-testid="create-project-name-input"]');p==null||p.focus()},children:[m.jsxs(Lf,{children:[m.jsx(If,{children:"Create new project"}),m.jsxs(Ef,{children:["The project will be created at ",m.jsx("code",{children:"~/.seeflow/<slug>"}),"."]})]}),m.jsxs("form",{onSubmit:d,className:"flex flex-col gap-4",children:[m.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[m.jsx("span",{className:"font-medium",children:"Project name"}),m.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:r,onChange:f=>o(f.target.value),"data-testid":"create-project-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),a?m.jsx("div",{role:"alert","data-testid":"create-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:a}):null,m.jsxs(fd,{children:[m.jsx(Ft,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:s,children:"Cancel"}),m.jsx(Ft,{type:"submit",disabled:!u,"data-testid":"create-project-submit",children:s?"Creating…":"Create project"})]})]})]})})}const gB="seeflow:navigate",Qze=e=>(window.addEventListener("popstate",e),window.addEventListener(gB,e),()=>{window.removeEventListener("popstate",e),window.removeEventListener(gB,e)}),ate=()=>window.location.pathname,Jze=()=>g.useSyncExternalStore(Qze,ate,ate),md=e=>{e!==window.location.pathname&&(window.history.pushState({},"",e),window.dispatchEvent(new Event(gB)))};function eDe({demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:r}){const[o,a]=g.useState(!1),[i,s]=g.useState(!1),[c,l]=g.useState(null),[u,d]=g.useState(!1),[f,p]=g.useState(null);g.useEffect(()=>{const x=b=>{b.key==="k"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),a(S=>!S))};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[]);const y=e.find(x=>x.slug===t),k=x=>{n==null||n(x),md(`/d/${x.slug}`)},w=x=>{l(x),p(null)},v=()=>{u||(l(null),p(null))},M=async()=>{if(c){d(!0),p(null);try{await Lfe(c.id);const x=c.id;l(null),r==null||r(x)}catch(x){p(x instanceof Error?x.message:String(x))}finally{d(!1)}}};return m.jsxs(m.Fragment,{children:[m.jsxs(Nd,{open:o,onOpenChange:a,children:[m.jsx(kf,{asChild:!0,children:m.jsxs(Ft,{type:"button",variant:"outline",size:"sm","aria-label":"Switch demo","aria-expanded":o,className:"gap-2","data-testid":"project-switcher-trigger",children:[m.jsx("span",{className:"max-w-[180px] truncate text-sm",children:(y==null?void 0:y.name)??"Select demo"}),m.jsx(jce,{children:"⌘K"}),m.jsx(zh,{className:"h-3.5 w-3.5 opacity-60"})]})}),m.jsx(Fu,{align:"end",sideOffset:6,className:"w-[320px] p-0","data-testid":"project-switcher-popover",children:m.jsxs(Ace,{children:[m.jsx(Pce,{placeholder:"Search demos..."}),m.jsxs(_ce,{children:[m.jsx(Rce,{children:"No demos."}),e.length>0?m.jsx(WH,{heading:"Demos",children:e.map(x=>m.jsxs(GH,{value:`${x.name} ${x.slug}`,onSelect:()=>{a(!1),md(`/d/${x.slug}`)},className:"group flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[m.jsx("span",{className:"font-medium",children:x.name}),m.jsx("span",{className:"w-full truncate text-xs text-muted-foreground",children:x.repoPath})]}),m.jsx("button",{type:"button","aria-label":`Unregister ${x.name}`,className:"shrink-0 rounded p-0.5 opacity-0 transition-opacity hover:text-destructive group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:b=>{b.stopPropagation(),a(!1),w(x)},children:m.jsx(a2,{className:"h-3.5 w-3.5"})})]},x.id))}):null,e.length>0?m.jsx(Tce,{}):null,m.jsx(WH,{children:m.jsxs(GH,{value:"+ create new project",onSelect:()=>{a(!1),s(!0)},"data-testid":"project-switcher-create",className:"flex items-center gap-2 text-sm",children:[m.jsx(Yh,{className:"h-4 w-4 opacity-70"}),m.jsx("span",{className:"font-medium",children:"Create new project"})]})})]})]})})]}),m.jsx(Yze,{open:i,onOpenChange:s,onCreated:k}),m.jsx(RT,{open:c!==null,onOpenChange:x=>{x||v()},children:m.jsxs(Sf,{className:"sm:max-w-md","data-testid":"unregister-project-dialog",children:[m.jsxs(Lf,{children:[m.jsx(If,{children:"Unregister project?"}),m.jsxs(Ef,{children:["This removes ",m.jsx("strong",{children:c==null?void 0:c.name})," from SeeFlow. Your files at"," ",m.jsx("code",{className:"text-xs",children:c==null?void 0:c.repoPath})," will not be deleted."]})]}),f?m.jsx("div",{role:"alert","data-testid":"unregister-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:f}):null,m.jsxs(fd,{children:[m.jsx(Ft,{type:"button",variant:"ghost",onClick:v,disabled:u,children:"Cancel"}),m.jsx(Ft,{type:"button",variant:"destructive",onClick:M,disabled:u,"data-testid":"unregister-project-confirm",children:u?"Unregistering…":"Unregister"})]})]})})]})}function tDe({demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:r}){return m.jsxs("header",{className:"flex h-12 shrink-0 items-center justify-between border-b border-border bg-background px-4",children:[m.jsxs("button",{type:"button",onClick:()=>md("/"),style:{display:"flex",alignItems:"center",gap:6,fontWeight:700,fontSize:16,letterSpacing:"-0.02em",background:"none",border:"none",cursor:"pointer",padding:0},children:[m.jsx(c2,{size:20,strokeWidth:2,className:"text-emerald-400"}),"SeeFlow"]}),m.jsx("div",{className:"flex items-center gap-3",children:m.jsx(eDe,{demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:r})})]})}const nDe=e=>{const[t,n]=g.useState(null),[r,o]=g.useState(e!==null),[a,i]=g.useState(null),s=g.useCallback(()=>{e&&(o(!0),Nre(e).then(c=>{n(c),i(null)}).catch(c=>{console.error("[useDemoData] failed",c),i(String(c))}).finally(()=>o(!1)))},[e]);return g.useEffect(()=>{if(!e){n(null),o(!1);return}s()},[e,s]),{detail:t,loading:r,error:a,refresh:s}},rDe=()=>{const[e,t]=g.useState(null),[n,r]=g.useState(null),o=g.useCallback(()=>Sfe().then(a=>{t(a),r(null)}).catch(a=>{console.error("[useDemos] failed",a),t([]),r(String(a))}),[]);return g.useEffect(()=>{o()},[o]),{demos:e,error:n,refresh:o}},oDe=5,aDe={"node:running":"running","node:done":"done","node:error":"error"},iDe=(e,t)=>{if(t.type==="reset")return{};const n=e[t.nodeId]??[],r=[t.entry,...n].slice(0,oDe);return{...e,[t.nodeId]:r}},sDe=e=>{const[t,n]=g.useReducer(iDe,{}),r=g.useRef(n);r.current=n,g.useEffect(()=>{r.current({type:"reset"})},[e]);const o=g.useCallback(i=>{const s=aDe[i.type];if(!s)return;const c=typeof i.nodeId=="string"?i.nodeId:null;if(!c)return;const l=typeof i.runId=="string"?i.runId:void 0,u=typeof i.ts=="number"?i.ts:Date.now();r.current({type:"append",nodeId:c,entry:{status:s,ts:u,runId:l}})},[]),a=g.useCallback(()=>{r.current({type:"reset"})},[]);return{events:t,apply:o,reset:a}},cDe=(e,t)=>{var n,r;switch(t.type){case"reset":return{};case"running":return{...e,[t.nodeId]:{status:"running",runId:t.runId,ts:t.ts??Date.now()}};case"done":return{...e,[t.nodeId]:{...e[t.nodeId],status:"done",runId:t.runId??((n=e[t.nodeId])==null?void 0:n.runId),responseStatus:t.responseStatus,body:t.body,ts:t.ts??Date.now()}};case"error":return{...e,[t.nodeId]:{...e[t.nodeId],status:"error",runId:t.runId??((r=e[t.nodeId])==null?void 0:r.runId),error:t.message,ts:t.ts??Date.now()}}}},lDe=e=>{const[t,n]=g.useReducer(cDe,{}),r=g.useRef(n);r.current=n,g.useEffect(()=>{r.current({type:"reset"})},[e]);const o=g.useCallback(i=>{const s=typeof i.nodeId=="string"?i.nodeId:null;if(!s)return;const c=typeof i.runId=="string"?i.runId:void 0;if(i.type==="node:running"){r.current({type:"running",nodeId:s,runId:c,ts:i.ts});return}if(i.type==="node:done"){const l=typeof i.status=="number"?i.status:void 0;r.current({type:"done",nodeId:s,runId:c,responseStatus:l,body:i.body,ts:i.ts});return}if(i.type==="node:error"){const l=typeof i.message=="string"?i.message:void 0;r.current({type:"error",nodeId:s,runId:c,message:l,ts:i.ts})}},[]),a=g.useCallback(()=>{r.current({type:"reset"})},[]);return{runs:t,apply:o,reset:a}},uDe=new Set(["ok","warn","error","pending"]),dDe=(e,t)=>{if(t.type!=="node:status")return e;const n=typeof t.nodeId=="string"?t.nodeId:null;if(!n||typeof t.state!="string"||!uDe.has(t.state))return e;const r=typeof t.summary=="string"?t.summary:void 0,o=typeof t.detail=="string"?t.detail:void 0,a=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:void 0,i=typeof t.ts=="number"?t.ts:Date.now();return{...e,[n]:{state:t.state,summary:r,detail:o,data:a,ts:i}}},hDe=(e,t)=>{switch(t.type){case"reset":return{};case"event":return dDe(e,t.event)}},fDe=e=>{const[t,n]=g.useReducer(hDe,{}),r=g.useRef(n);r.current=n,g.useEffect(()=>{r.current({type:"reset"})},[e]);const o=g.useCallback(i=>{r.current({type:"event",event:i})},[]),a=g.useCallback(()=>{r.current({type:"reset"})},[]);return{statusByNode:t,apply:o,reset:a}},pDe=(e,t={})=>{const[n,r]=g.useState(null),[o,a]=g.useState(!1),{onReload:i,onEvent:s}=t;return g.useEffect(()=>{if(!e){r(null),a(!1);return}const c=`/api/events?demoId=${encodeURIComponent(e)}`,l=new EventSource(c);l.addEventListener("open",()=>a(!0)),l.addEventListener("error",()=>a(!1)),l.addEventListener("hello",()=>{i==null||i()}),l.addEventListener("demo:reload",u=>{const d=ite(u,"demo:reload");r(d),s==null||s(d),i==null||i()});for(const u of["node:running","node:done","node:error","node:status"])l.addEventListener(u,d=>{s==null||s(ite(d,u))});return()=>{l.close()}},[e,i,s]),{lastReload:n,connected:o}},ite=(e,t)=>{try{const n=JSON.parse(e.data);return{type:t,ts:Date.now(),...n}}catch{return{type:t,ts:Date.now()}}},sde="seeflow:last-project",yDe=()=>{if(typeof window>"u")return null;try{return window.localStorage.getItem(sde)}catch{return null}},ste=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(sde,e)}catch{}},mDe=(e,t)=>{if(e.length===0)return null;if(e.length===1)return e[0]??null;if(t){const n=e.find(r=>r.id===t);if(n)return n}return null},cte=["File","Edit","View","Tools","Layout","Selection","Help"],cde="seeflow:command-palette:recent",lde=5,ude=new Map(n$.map(e=>[e.id,e])),gDe=e=>typeof e=="string"&&ude.has(e),lte=()=>{if(typeof window>"u")return[];try{const e=window.localStorage.getItem(cde);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(gDe).slice(0,lde):[]}catch{return[]}},kDe=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(cde,JSON.stringify(e))}catch{}},ute=(e,t)=>e.enabled?e.enabled(t):!0,vDe=(e,t)=>t.length===0?!0:`${e.label} ${e.description??""}`.toLowerCase().includes(t);function xDe({open:e,onOpenChange:t,runCommand:n,ctx:r}){const[o,a]=g.useState(""),[i,s]=g.useState(0),[c,l]=g.useState(()=>lte()),u=g.useRef(null),d=g.useRef(null);g.useEffect(()=>{e&&(a(""),s(0),l(lte()))},[e]);const{groups:f,flat:p}=g.useMemo(()=>{const b=o.trim().toLowerCase();if(b.length===0){if(c.length===0)return{groups:[],flat:[]};const T=[];for(const A of c){const I=ude.get(A);I&&T.push({cmd:I,enabled:ute(I,r)})}return{groups:[{category:"Recent",rows:T}],flat:T}}const S=new Map;for(const T of n$){if(!vDe(T,b))continue;const _={cmd:T,enabled:ute(T,r)},A=S.get(T.category);A?A.push(_):S.set(T.category,[_])}const L=[...cte.filter(T=>S.has(T)),...Array.from(S.keys()).filter(T=>!cte.includes(T))].map(T=>({category:T,rows:S.get(T)??[]})),P=L.flatMap(T=>T.rows);return{groups:L,flat:P}},[o,r,c]);g.useEffect(()=>{if(p.length===0){s(0);return}s(b=>{var C;let S=b;if(S>=p.length&&(S=0),!((C=p[S])!=null&&C.enabled)){const L=p.findIndex(P=>P.enabled);L!==-1&&(S=L)}return S})},[p]);const y=g.useCallback(b=>{p.length!==0&&s(S=>{var L;let C=S;for(let P=0;P<p.length;P++)if(C=(C+b+p.length)%p.length,(L=p[C])!=null&&L.enabled)return C;return S})},[p]),k=g.useCallback(b=>{l(S=>{const C=[b,...S.filter(L=>L!==b)].slice(0,lde);return kDe(C),C})},[]),w=g.useCallback(b=>{const S=p[b];!S||!S.enabled||(k(S.cmd.id),n(S.cmd.id),t(!1))},[p,t,k,n]),v=g.useCallback(b=>{if(b.key==="ArrowDown"){b.preventDefault(),y(1);return}if(b.key==="ArrowUp"){b.preventDefault(),y(-1);return}b.key==="Enter"&&(b.preventDefault(),w(i))},[w,i,y]);g.useEffect(()=>{if(!e)return;const b=d.current;if(!b)return;const S=b.querySelector(`[data-command-row-index="${i}"]`);S&&typeof S.scrollIntoView=="function"&&S.scrollIntoView({block:"nearest"})},[i,e]);const x=o.trim().length>0;return m.jsx(IT,{open:e,onOpenChange:t,children:m.jsx(ET,{children:m.jsxs(zd,{className:ce("fixed left-0 right-0 top-[20%] z-50 mx-auto w-[480px] max-w-[90vw] border border-border bg-card shadow-lg duration-200","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","sm:rounded-lg"),"data-testid":"command-palette",onOpenAutoFocus:b=>{var S;b.preventDefault(),(S=u.current)==null||S.focus()},children:[m.jsx("div",{className:ce("border-b",p.length===0&&!x&&"border-b-0"),children:m.jsx("input",{ref:u,type:"text",value:o,onChange:b=>a(b.target.value),onKeyDown:v,placeholder:"Type a command…","data-testid":"command-palette-input","aria-label":"Search commands",autoComplete:"off",spellCheck:!1,className:"w-full bg-transparent px-4 py-3 text-sm outline-hidden placeholder:text-muted-foreground"})}),m.jsx("div",{ref:d,"data-testid":"command-palette-list","data-empty":p.length===0?"true":"false",className:ce("max-h-[50vh] overflow-y-auto",p.length>0?"py-1":"","seeflow-no-scrollbar"),children:p.length===0?x?m.jsxs("div",{"data-testid":"command-palette-empty",className:"px-4 py-6 text-center text-sm text-muted-foreground",children:['No commands match "',o,'"']}):null:(()=>{let b=-1;return f.map(S=>m.jsxs("div",{className:"py-1",children:[m.jsx("div",{className:"px-3 pb-1 pt-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:S.category}),S.rows.map(C=>{b+=1;const L=b,P=L===i;return m.jsxs("button",{type:"button","data-testid":`command-palette-row-${C.cmd.id}`,"data-command-row-index":L,"data-highlighted":P?"true":"false","aria-disabled":C.enabled?void 0:!0,disabled:!C.enabled,onMouseEnter:()=>{C.enabled&&s(L)},onClick:()=>w(L),className:ce("flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-sm outline-hidden",C.enabled?"cursor-pointer text-foreground hover:bg-muted":"cursor-not-allowed text-muted-foreground/50",P&&C.enabled?"bg-muted":""),children:[m.jsxs("div",{className:"flex min-w-0 flex-col",children:[m.jsx("span",{className:"truncate font-medium",children:C.cmd.label}),C.cmd.description?m.jsx("span",{className:"truncate text-xs text-muted-foreground",children:C.cmd.description}):null]}),C.cmd.shortcut?m.jsx("kbd",{"data-testid":`command-palette-shortcut-${C.cmd.id}`,className:"shrink-0 rounded border bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:C.cmd.shortcut}):null]},C.cmd.id)})]},S.category))})()})]})})})}var cn=Uint8Array,Qn=Uint16Array,oU=Int32Array,aU=new cn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),iU=new cn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),dte=new cn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dde=function(e,t){for(var n=new Qn(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var o=new oU(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)o[a]=a-n[r]<<5|r;return{b:n,r:o}},hde=dde(aU,2),wDe=hde.b,kB=hde.r;wDe[28]=258,kB[258]=28;var MDe=dde(iU,0),hte=MDe.r,vB=new Qn(32768);for(var Mt=0;Mt<32768;++Mt){var Ta=(Mt&43690)>>1|(Mt&21845)<<1;Ta=(Ta&52428)>>2|(Ta&13107)<<2,Ta=(Ta&61680)>>4|(Ta&3855)<<4,vB[Mt]=((Ta&65280)>>8|(Ta&255)<<8)>>1}var y2=function(e,t,n){for(var r=e.length,o=0,a=new Qn(t);o<r;++o)e[o]&&++a[e[o]-1];var i=new Qn(t);for(o=1;o<t;++o)i[o]=i[o-1]+a[o-1]<<1;var s;if(n){s=new Qn(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var l=o<<4|e[o],u=t-e[o],d=i[e[o]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[vB[d]>>c]=l}else for(s=new Qn(r),o=0;o<r;++o)e[o]&&(s[o]=vB[i[e[o]-1]++]>>15-e[o]);return s},_u=new cn(288);for(var Mt=0;Mt<144;++Mt)_u[Mt]=8;for(var Mt=144;Mt<256;++Mt)_u[Mt]=9;for(var Mt=256;Mt<280;++Mt)_u[Mt]=7;for(var Mt=280;Mt<288;++Mt)_u[Mt]=8;var wR=new cn(32);for(var Mt=0;Mt<32;++Mt)wR[Mt]=5;var bDe=y2(_u,9,0),CDe=y2(wR,5,0),fde=function(e){return(e+7)/8|0},pde=function(e,t,n){return(n==null||n>e.length)&&(n=e.length),new cn(e.subarray(t,n))},SDe=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],XT=function(e,t,n){var r=new Error(t||SDe[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,XT),!n)throw r;return r},Bo=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},sh=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},wF=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,a=n.slice();if(!o)return{t:mde,l:0};if(o==1){var i=new cn(n[0].s+1);return i[n[0].s]=1,{t:i,l:1}}n.sort(function(S,C){return S.f-C.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=o-1;)s=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,r=1;r<o;++r)a[r].s>f&&(f=a[r].s);var p=new Qn(f+1),y=xB(n[u-1],p,0);if(y>t){var r=0,k=0,w=y-t,v=1<<w;for(a.sort(function(C,L){return p[L.s]-p[C.s]||C.f-L.f});r<o;++r){var M=a[r].s;if(p[M]>t)k+=v-(1<<y-p[M]),p[M]=t;else break}for(k>>=w;k>0;){var x=a[r].s;p[x]<t?k-=1<<t-p[x]++-1:++r}for(;r>=0&&k;--r){var b=a[r].s;p[b]==t&&(--p[b],++k)}y=t}return{t:new cn(p),l:y}},xB=function(e,t,n){return e.s==-1?Math.max(xB(e.l,t,n+1),xB(e.r,t,n+1)):t[e.s]=n},fte=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Qn(++t),r=0,o=e[0],a=1,i=function(c){n[r++]=c},s=1;s<=t;++s)if(e[s]==o&&s!=t)++a;else{if(!o&&a>2){for(;a>138;a-=138)i(32754);a>2&&(i(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(i(o),--a;a>6;a-=6)i(8304);a>2&&(i(a-3<<5|8208),a=0)}for(;a--;)i(o);a=1,o=e[s]}return{c:n.subarray(0,r),n:t}},ch=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},yde=function(e,t,n){var r=n.length,o=fde(t+2);e[o]=r&255,e[o+1]=r>>8,e[o+2]=e[o]^255,e[o+3]=e[o+1]^255;for(var a=0;a<r;++a)e[o+a+4]=n[a];return(o+4+r)*8},pte=function(e,t,n,r,o,a,i,s,c,l,u){Bo(t,u++,n),++o[256];for(var d=wF(o,15),f=d.t,p=d.l,y=wF(a,15),k=y.t,w=y.l,v=fte(f),M=v.c,x=v.n,b=fte(k),S=b.c,C=b.n,L=new Qn(19),P=0;P<M.length;++P)++L[M[P]&31];for(var P=0;P<S.length;++P)++L[S[P]&31];for(var T=wF(L,7),_=T.t,A=T.l,I=19;I>4&&!_[dte[I-1]];--I);var V=l+5<<3,j=ch(o,_u)+ch(a,wR)+i,H=ch(o,f)+ch(a,k)+i+14+3*I+ch(L,_)+2*L[16]+3*L[17]+7*L[18];if(c>=0&&V<=j&&V<=H)return yde(t,u,e.subarray(c,c+l));var O,U,z,N;if(Bo(t,u,1+(H<j)),u+=2,H<j){O=y2(f,p,0),U=f,z=y2(k,w,0),N=k;var E=y2(_,A,0);Bo(t,u,x-257),Bo(t,u+5,C-1),Bo(t,u+10,I-4),u+=14;for(var P=0;P<I;++P)Bo(t,u+3*P,_[dte[P]]);u+=3*I;for(var W=[M,S],q=0;q<2;++q)for(var R=W[q],P=0;P<R.length;++P){var G=R[P]&31;Bo(t,u,E[G]),u+=_[G],G>15&&(Bo(t,u,R[P]>>5&127),u+=R[P]>>12)}}else O=bDe,U=_u,z=CDe,N=wR;for(var P=0;P<s;++P){var X=r[P];if(X>255){var G=X>>18&31;sh(t,u,O[G+257]),u+=U[G+257],G>7&&(Bo(t,u,X>>23&31),u+=aU[G]);var Y=X&31;sh(t,u,z[Y]),u+=N[Y],Y>3&&(sh(t,u,X>>5&8191),u+=iU[Y])}else sh(t,u,O[X]),u+=U[X]}return sh(t,u,O[256]),u+U[256]},LDe=new oU([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),mde=new cn(0),IDe=function(e,t,n,r,o,a){var i=a.z||e.length,s=new cn(r+i+5*(1+Math.ceil(i/7e3))+o),c=s.subarray(r,s.length-o),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var d=LDe[t-1],f=d>>13,p=d&8191,y=(1<<n)-1,k=a.p||new Qn(32768),w=a.h||new Qn(y+1),v=Math.ceil(n/3),M=2*v,x=function(te){return(e[te]^e[te+1]<<v^e[te+2]<<M)&y},b=new oU(25e3),S=new Qn(288),C=new Qn(32),L=0,P=0,T=a.i||0,_=0,A=a.w||0,I=0;T+2<i;++T){var V=x(T),j=T&32767,H=w[V];if(k[j]=H,w[V]=j,A<=T){var O=i-T;if((L>7e3||_>24576)&&(O>423||!l)){u=pte(e,c,0,b,S,C,P,_,I,T-I,u),_=L=P=0,I=T;for(var U=0;U<286;++U)S[U]=0;for(var U=0;U<30;++U)C[U]=0}var z=2,N=0,E=p,W=j-H&32767;if(O>2&&V==x(T-W))for(var q=Math.min(f,O)-1,R=Math.min(32767,T),G=Math.min(258,O);W<=R&&--E&&j!=H;){if(e[T+z]==e[T+z-W]){for(var X=0;X<G&&e[T+X]==e[T+X-W];++X);if(X>z){if(z=X,N=W,X>q)break;for(var Y=Math.min(W,X-2),oe=0,U=0;U<Y;++U){var ee=T-W+U&32767,ae=k[ee],ve=ee-ae&32767;ve>oe&&(oe=ve,H=ee)}}}j=H,H=k[j],W+=j-H&32767}if(N){b[_++]=268435456|kB[z]<<18|hte[N];var Se=kB[z]&31,be=hte[N]&31;P+=aU[Se]+iU[be],++S[257+Se],++C[be],A=T+z,++L}else b[_++]=e[T],++S[e[T]]}}for(T=Math.max(T,A);T<i;++T)b[_++]=e[T],++S[e[T]];u=pte(e,c,l,b,S,C,P,_,I,T-I,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=w,a.p=k,a.i=T,a.w=A)}else{for(var T=a.w||0;T<i+l;T+=65535){var we=T+65535;we>=i&&(c[u/8|0]=l,we=i),u=yde(c,u+1,e.subarray(T,we))}a.i=i}return pde(s,0,r+fde(u)+o)},EDe=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),ADe=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=EDe[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},gde=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,a=n.length|0,i=0;i!=a;){for(var s=Math.min(i+2655,a);i<s;++i)o+=r+=n[i];r=(r&65535)+15*(r>>16),o=(o&65535)+15*(o>>16)}e=r,t=o},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},kde=function(e,t,n,r,o){if(!o&&(o={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),i=new cn(a.length+e.length);i.set(a),i.set(e,a.length),e=i,o.w=a.length}return IDe(e,t.level==null?6:t.level,t.mem==null?o.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,o)},vde=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},$t=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},PDe=function(e,t){var n=t.level,r=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var o=gde();o.p(t.dictionary),$t(e,2,o.d())}};function _De(e,t){return kde(e,t||{},0,0)}function vqe(e,t){t||(t={});var n=gde();n.p(e);var r=kde(e,t,t.dictionary?6:2,4);return PDe(r,t),$t(r,r.length-4,n.d()),r}var xde=function(e,t,n,r){for(var o in e){var a=e[o],i=t+o,s=r;Array.isArray(a)&&(s=vde(r,a[1]),a=a[0]),a instanceof cn?n[i]=[a,s]:(n[i+="/"]=[new cn(0),s],xde(a,i,n,r))}},yte=typeof TextEncoder<"u"&&new TextEncoder,RDe=typeof TextDecoder<"u"&&new TextDecoder,TDe=0;try{RDe.decode(mde,{stream:!0}),TDe=1}catch{}function wB(e,t){var n;if(yte)return yte.encode(e);for(var r=e.length,o=new cn(e.length+(e.length>>1)),a=0,i=function(l){o[a++]=l},n=0;n<r;++n){if(a+5>o.length){var s=new cn(a+8+(r-n<<1));s.set(o),o=s}var c=e.charCodeAt(n);c<128||t?i(c):c<2048?(i(192|c>>6),i(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|e.charCodeAt(++n)&1023,i(240|c>>18),i(128|c>>12&63),i(128|c>>6&63),i(128|c&63)):(i(224|c>>12),i(128|c>>6&63),i(128|c&63))}return pde(o,0,a)}var MB=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&XT(9),t+=r+4}return t},mte=function(e,t,n,r,o,a,i,s){var c=r.length,l=n.extra,u=s&&s.length,d=MB(l);$t(e,t,i!=null?33639248:67324752),t+=4,i!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=o&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&XT(10),$t(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&($t(e,t,n.crc),$t(e,t+4,a<0?-a-2:a),$t(e,t+8,n.size)),$t(e,t+12,c),$t(e,t+14,d),t+=16,i!=null&&($t(e,t,u),$t(e,t+6,n.attrs),$t(e,t+10,i),t+=14),e.set(r,t),t+=c,d)for(var y in l){var k=l[y],w=k.length;$t(e,t,+y),$t(e,t+2,w),e.set(k,t+4),t+=4+w}return u&&(e.set(s,t),t+=u),t},jDe=function(e,t,n,r,o){$t(e,t,101010256),$t(e,t+8,n),$t(e,t+10,n),$t(e,t+12,r),$t(e,t+16,o)};function NDe(e,t){t||(t={});var n={},r=[];xde(e,"",n,t);var o=0,a=0;for(var i in n){var s=n[i],c=s[0],l=s[1],u=l.level==0?0:8,d=wB(i),f=d.length,p=l.comment,y=p&&wB(p),k=y&&y.length,w=MB(l.extra);f>65535&&XT(11);var v=u?_De(c,l):c,M=v.length,x=ADe();x.p(c),r.push(vde(l,{size:c.length,crc:x.d(),c:v,f:d,m:y,u:f!=i.length||y&&p.length!=k,o,compression:u})),o+=30+f+w+M,a+=76+2*(f+w)+(k||0)+M}for(var b=new cn(a+22),S=o,C=a-o,L=0;L<r.length;++L){var d=r[L];mte(b,d.o,d,d.f,d.u,d.c.length);var P=30+d.f.length+MB(d.extra);b.set(d.c,d.o+P),mte(b,o,d,d.f,d.u,d.c.length,d.o,d.m),o+=16+P+(d.m?d.m.length:0)}return jDe(b,o,r.length,C,S),b}const zDe="https://seeflow.dev/api";async function DDe(e,t,n,r,o){const a=await Nre(e);if(!a.demo)throw new Error("Demo has no data");const i=a.demo,s=new Set,c=[];for(const y of i.nodes)y.type==="imageNode"&&y.data.path&&!s.has(y.data.path)?(s.add(y.data.path),c.push(y.data.path)):y.type==="htmlNode"&&y.data.htmlPath&&!s.has(y.data.htmlPath)&&(s.add(y.data.htmlPath),c.push(y.data.htmlPath));const u={[r==="link"?"seeflow.private.json":"seeflow.json"]:wB(JSON.stringify(i))};if(o){const y=o.split(",")[1];y&&(u["preview.png"]=Uint8Array.from(atob(y),k=>k.charCodeAt(0)))}for(const y of c){const k=await fetch(`/api/projects/${encodeURIComponent(e)}/files/${y}`);k.ok&&(u[`files/${y}`]=new Uint8Array(await k.arrayBuffer()))}const d=NDe(u),f=await fetch(`${zDe}/flows?email=${encodeURIComponent(t)}&name=${encodeURIComponent(n)}`,{method:"POST",headers:{"content-type":"application/zip"},body:d.buffer});if(!f.ok)throw new Error(`Export failed with status ${f.status}`);const p=await f.json();if(typeof p.url!="string")throw new Error("Invalid response from cloud API: missing url");return{shareUrl:p.url}}function qDe(e){return g.useCallback((t,n,r,o)=>DDe(e,t,n,r,o),[e])}const gte="seeflow.export.email",kte="seeflow.export.name",vte="seeflow.export.visibility";function ODe({open:e,onOpenChange:t,projectId:n,onCapturePreview:r}){const[o,a]=g.useState(""),[i,s]=g.useState(""),[c,l]=g.useState("public"),[u,d]=g.useState({kind:"idle"}),[f,p]=g.useState(!1),y=qDe(n);g.useEffect(()=>{e&&(a(localStorage.getItem(gte)??""),s(localStorage.getItem(kte)??""),l(localStorage.getItem(vte)??"public"),d({kind:"idle"}),p(!1))},[e]);const k=g.useCallback(async()=>{d({kind:"loading"});try{const x=await(r==null?void 0:r()),{shareUrl:b}=await y(o.trim(),i.trim(),c,x);localStorage.setItem(gte,o.trim()),localStorage.setItem(kte,i.trim()),localStorage.setItem(vte,c),d({kind:"done",shareUrl:b})}catch(x){d({kind:"error",message:x instanceof Error?x.message:String(x)})}},[y,o,i,c,r]),w=g.useCallback(async()=>{if(u.kind==="done")try{await navigator.clipboard.writeText(u.shareUrl),p(!0),setTimeout(()=>p(!1),2e3)}catch(x){console.error("Failed to copy to clipboard:",x)}},[u]),v=u.kind==="loading",M=o.trim().length>0&&i.trim().length>0;return m.jsx(RT,{open:e,onOpenChange:t,children:m.jsxs(Sf,{className:"sm:max-w-md","data-testid":"export-dialog",onOpenAutoFocus:x=>{x.preventDefault();const b=document.querySelector('[data-testid="export-email-input"]');b==null||b.focus()},children:[m.jsxs(Lf,{children:[m.jsx(If,{children:"Export to seeflow.dev"}),m.jsx(Ef,{children:"Upload this diagram to the cloud and get a shareable link."})]}),u.kind!=="done"?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex flex-col gap-4",children:[m.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[m.jsx("span",{className:"font-medium",children:"Email"}),m.jsx("input",{type:"email",required:!0,autoComplete:"email",value:o,onChange:x=>a(x.target.value),disabled:v,"data-testid":"export-email-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"}),m.jsx("span",{className:"text-xs text-muted-foreground",children:"We'll use this to let you manage your flows in the future."})]}),m.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[m.jsx("span",{className:"font-medium",children:"Flow Name"}),m.jsx("input",{type:"text",required:!0,value:i,onChange:x=>s(x.target.value),disabled:v,"data-testid":"export-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"})]}),m.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[m.jsx("span",{className:"font-medium",children:"Visibility"}),m.jsxs("select",{value:c,onChange:x=>l(x.target.value),disabled:v,"data-testid":"export-visibility-select",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[m.jsx("option",{value:"public",children:"Public — anyone can discover it"}),m.jsx("option",{value:"link",children:"Anyone with the link"})]})]}),u.kind==="error"?m.jsx("div",{role:"alert","data-testid":"export-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u.message}):null]}),m.jsx(fd,{children:u.kind==="error"?m.jsxs(m.Fragment,{children:[m.jsx(Ft,{type:"button",variant:"ghost",onClick:()=>t(!1),"data-testid":"export-cancel",children:"Cancel"}),m.jsx(Ft,{type:"button",onClick:()=>d({kind:"idle"}),"data-testid":"export-retry",children:"Try again"})]}):m.jsxs(m.Fragment,{children:[m.jsx(Ft,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:v,"data-testid":"export-cancel",children:"Cancel"}),m.jsx(Ft,{type:"button",onClick:k,disabled:v||!M,"data-testid":"export-submit",children:v?m.jsxs(m.Fragment,{children:[m.jsx(dr,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),m.jsx("span",{children:"Uploading…"})]}):"Export"})]})})]}):m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex flex-col gap-3",children:[m.jsx("p",{className:"text-sm text-muted-foreground",children:"Your diagram is live. Share this link:"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("input",{type:"text",readOnly:!0,value:u.shareUrl,"data-testid":"export-share-url",className:"min-w-0 flex-1 rounded-md border bg-muted px-3 py-2 text-sm outline-hidden"}),m.jsx(Ft,{type:"button",variant:"outline",size:"icon",onClick:w,"aria-label":"Copy link","data-testid":"export-copy",children:f?m.jsx(Ja,{className:"h-4 w-4","aria-hidden":"true"}):m.jsx(T1,{className:"h-4 w-4","aria-hidden":"true"})}),m.jsx(Ft,{type:"button",variant:"outline",size:"icon",onClick:()=>window.open(u.shareUrl,"_blank"),"aria-label":"View in new tab","data-testid":"export-view",children:m.jsx(Fh,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),m.jsx(fd,{children:m.jsx(Ft,{type:"button",onClick:()=>t(!1),"data-testid":"export-done",children:"Done"})})]})]})})}const FDe=(e,t)=>{if(e.has(t))return e;const n=new Set(e);return n.add(t),n},HDe=(e,t)=>{if(t.length===0)return e;let n=!1;const r=new Set(e);for(const o of t)r.has(o)||(r.add(o),n=!0);return n?r:e},BDe=(e,t)=>{if(!e.has(t))return e;const n=new Set(e);return n.delete(t),n},VDe=(e,t)=>{if(t.length===0)return e;let n=!1;const r=new Set(e);for(const o of t)r.has(o)&&(r.delete(o),n=!0);return n?r:e},$De=(e,t)=>{if(e.size===0)return e;const n=new Set(t.map(a=>a.id));let r=!1;const o=new Set(e);for(const a of o)n.has(a)||(o.delete(a),r=!0);return r?o:e},xte=()=>{const[e,t]=g.useState(()=>new Set),n=g.useCallback(c=>{t(l=>FDe(l,c))},[]),r=g.useCallback(c=>{t(l=>HDe(l,c))},[]),o=g.useCallback(c=>{t(l=>BDe(l,c))},[]),a=g.useCallback(c=>{t(l=>VDe(l,c))},[]),i=g.useCallback(c=>{t(l=>$De(l,c))},[]),s=g.useCallback(()=>t(new Set),[]);return{ids:e,mark:n,markMany:r,unmark:o,unmarkMany:a,pruneAgainst:i,reset:s}},UDe=(e,t)=>e===t?!0:e==null||t==null||typeof e!=typeof t||typeof e!="object"?!1:JSON.stringify(e)===JSON.stringify(t),WDe=(e,t,n)=>({...e,[t]:{...e[t],...n}}),GDe=(e,t)=>{if(!(t in e))return e;const n={...e};return delete n[t],n},KDe=(e,t)=>{const n=Object.entries(e);if(n.length===0)return e;const r=new Map(t.map(i=>[i.id,i]));let o=!1;const a={...e};for(const[i,s]of n){const c=r.get(i);if(!c)continue;const l={};let u=!1;for(const d of Object.keys(s))UDe(s[d],c[d])?o=!0:(l[d]=s[d],u=!0);u?a[i]=l:(o=!0,delete a[i])}return o?a:e},wte=()=>{const[e,t]=g.useState({}),n=g.useCallback((i,s)=>{t(c=>WDe(c,i,s))},[]),r=g.useCallback(i=>{t(s=>GDe(s,i))},[]),o=g.useCallback(i=>{t(s=>KDe(s,i))},[]),a=g.useCallback(()=>t({}),[]);return{overrides:e,setOverride:n,dropOverride:r,pruneAgainst:o,reset:a}},ZDe=500,XDe=500,YDe={stack:[],cursor:0},QDe=(e,t,n)=>{const r=Date.now(),o=ZDe,a=XDe,{stack:i,cursor:s}=e;if(t.coalesceKey&&s>0){const u=i[s-1];if(u&&u.coalesceKey===t.coalesceKey&&r-u.capturedAt<=a){const d=i.slice(0,s);return d[s-1]={...u,do:t.do,capturedAt:r},{stack:d,cursor:s}}}const c=i.slice(0,s);c.push({...t,capturedAt:r});let l=s+1;for(;c.length>o;)c.shift(),l-=1;return l<0&&(l=0),{stack:c,cursor:l}},JDe=e=>e.cursor===0?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor-1},entry:e.stack[e.cursor-1]},eqe=e=>e.cursor===e.stack.length?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor+1},entry:e.stack[e.cursor]},tqe=()=>({stack:[],cursor:0}),nqe=e=>{if(e.cursor===0)return e;const t=e.stack.slice();return t.splice(e.cursor-1,1),{stack:t,cursor:e.cursor-1}},rqe=(e,t)=>t.state,oqe=()=>{const[e,t]=g.useReducer(rqe,YDe),n=g.useRef(e);n.current=e;const r=g.useRef(Promise.resolve()),o=g.useRef(0),a=g.useCallback(p=>{p!==n.current&&(n.current=p,t({type:"replace",state:p}))},[]),i=g.useCallback(p=>{const y={do:p.do,undo:p.undo,coalesceKey:p.coalesceKey,capturedAt:p.capturedAt??Date.now()};a(QDe(n.current,y))},[a]),s=g.useCallback(()=>{o.current=Date.now();const p=r.current.then(()=>{const y=JDe(n.current);if(y.entry)return a(y.state),{entry:y.entry}});return r.current=p.then(()=>{},()=>{}),p},[a]),c=g.useCallback(()=>{o.current=Date.now();const p=r.current.then(()=>{const y=eqe(n.current);if(y.entry)return a(y.state),{entry:y.entry}});return r.current=p.then(()=>{},()=>{}),p},[a]),l=g.useCallback(()=>{a(tqe())},[a]),u=g.useCallback(()=>{a(nqe(n.current))},[a]),d=g.useCallback(()=>{o.current=Date.now()},[]),f=g.useCallback(()=>o.current,[]);return{push:i,undo:s,redo:c,clear:l,dropTop:u,canUndo:e.cursor>0,canRedo:e.cursor<e.stack.length,markMutation:d,lastMutationAt:f}};function aqe({nodes:e,connectors:t,flowPos:n,nodeIdGen:r,connectorIdGen:o,defaultOffset:a={x:24,y:24}}){const i=new Map;for(const p of e)i.set(p.id,r(p.id));let s=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY;for(const p of e)p.position.x<s&&(s=p.position.x),p.position.y<c&&(c=p.position.y);Number.isFinite(s)||(s=0),Number.isFinite(c)||(c=0);const l=n?n.x-s:a.x,u=n?n.y-c:a.y,d=e.map(p=>{const y=i.get(p.id);if(y===void 0)throw new Error(`paste id missing for ${p.id}`);return{...p,id:y,position:{x:p.position.x+l,y:p.position.y+u}}}),f=t.map(p=>{const y=o(p.id);return{...p,id:y,source:i.get(p.source)??p.source,target:i.get(p.target)??p.target}});return{newNodes:d,newConnectors:f,idMap:i}}const iqe=e=>({type:"imageNode",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploading:!0}}),sqe=e=>({type:"imageNode",data:wde(e)}),cqe=e=>({type:"imageNode",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploadError:e.message}}),wde=e=>({...PMe(e.path,e.dims,e.lastUsed),alt:e.originalFilename}),lqe=async(e,t)=>{const{nodeId:n,demoId:r,file:o,originalFilename:a,position:i,dims:s,lastUsed:c}=e;t.rememberRetry(n,{file:o,originalFilename:a,position:i,dims:s}),t.setOverride(n,iqe({position:i,dims:s,originalFilename:a}));let l;try{l=(await t.upload(r,o,a)).path}catch(p){const y=p instanceof Error?p.message:String(p);throw t.setOverride(n,cqe({position:i,dims:s,originalFilename:a,message:y})),p}t.setOverride(n,sqe({path:l,dims:s,originalFilename:a,lastUsed:c}));const u=wde({path:l,dims:s,originalFilename:a,lastUsed:c}),d={id:n,type:"imageNode",position:i,data:u},{id:f}=await t.createNode(r,d);t.forgetRetry(n),t.pushUndo&&t.pushUndo({do:async()=>{await t.createNode(r,{...d,id:f})},undo:async()=>{await t.deleteNode(r,f)}})},uqe=new Set(["INPUT","TEXTAREA","SELECT"]),Pr=e=>e?uqe.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1,dqe=(e,t,n)=>{const r=e.indexOf(t);if(r<0)return null;const o=e.length,a=[...e];switch(n.op){case"forward":{if(r>=o-1)return null;const i=a[r],s=a[r+1];return i===void 0||s===void 0?null:(a[r]=s,a[r+1]=i,a)}case"backward":{if(r<=0)return null;const i=a[r],s=a[r-1];return i===void 0||s===void 0?null:(a[r]=s,a[r-1]=i,a)}case"toFront":{if(r===o-1)return null;const[i]=a.splice(r,1);return i===void 0?null:(a.push(i),a)}case"toBack":{if(r===0)return null;const[i]=a.splice(r,1);return i===void 0?null:(a.unshift(i),a)}case"toIndex":{const i=Math.min(Math.max(n.index,0),o-1);if(i===r)return null;const[s]=a.splice(r,1);return s===void 0?null:(a.splice(i,0,s),a)}}};function hqe({slug:e,demos:t,detail:n,loading:r,runs:o,nodeEvents:a,statusByNode:i,onPlayNode:s,onRestartDemo:c}){var Hd,dn;const l=t.find(F=>F.slug===e),[u,d]=g.useState([]),[f,p]=g.useState([]),[y,k]=g.useState(null),w=g.useRef(u),v=g.useRef(f);g.useEffect(()=>{w.current=u},[u]),g.useEffect(()=>{v.current=f},[f]);const M=g.useRef(null),x=g.useRef(null),b=g.useRef(null),S=wte(),C=wte(),L=xte(),P=xte(),[T,_]=g.useState(null),[A,I]=g.useState(null),[V,j]=g.useState(null),H=g.useRef(null);g.useEffect(()=>{H.current=V},[V]);const[O,U]=g.useState(!1),[z,N]=g.useState(0),E=g.useRef(null),W=g.useRef(null),q=g.useCallback(F=>{W.current=F},[]),R=oqe(),{push:G,dropTop:X,markMutation:Y,clear:oe,lastMutationAt:ee}=R,{reset:ae}=S,{reset:ve}=C,{reset:Se}=L,{reset:be}=P;g.useEffect(()=>{d([]),p([]),k(null),ae(),ve(),Se(),be(),_(null),I(null),va.current=null,bi(!1),to.current.clear(),R.clear()},[n==null?void 0:n.id]);const we=g.useCallback((F,B)=>{d(F),p(B)},[]),te=(Hd=n==null?void 0:n.demo)==null?void 0:Hd.nodes,ie=(dn=n==null?void 0:n.demo)==null?void 0:dn.connectors,{pruneAgainst:Te}=S,{pruneAgainst:Ae}=C,{pruneAgainst:at}=L,{pruneAgainst:Qe}=P;g.useEffect(()=>{te&&(Te(te),at(te)),Date.now()-ee()>2e3&&oe()},[te,Te,at,ee,oe]),g.useEffect(()=>{if(!te)return;const F=E.current,B=new Set(te.map(ne=>ne.id));if(E.current=B,F===null)return;const Z=S.overrides,$=L.ids;let D=!1;for(const ne of B)if(!F.has(ne)&&!(ne in Z)){D=!0;break}if(!D){for(const ne of F)if(!B.has(ne)&&!$.has(ne)){D=!0;break}}D&&N(ne=>ne+1)},[te]),g.useEffect(()=>{ie&&(Ae(ie),Qe(ie)),Date.now()-ee()>2e3&&oe()},[ie,Ae,Qe,ee,oe]),g.useEffect(()=>{if(!(!te||!T)&&te.length===T.length){for(let F=0;F<te.length;F++){const B=te[F],Z=T[F];if(!B||B.id!==Z)return}_(null)}},[te,T]);const le=(n==null?void 0:n.id)??null,Q=g.useMemo(()=>le?_Me({baseUrl:"",demoId:le}):null,[le]),[ue,ge]=g.useState(!1),{setOverride:Me,dropOverride:qe}=S,re=g.useRef(S.overrides);g.useEffect(()=>{re.current=S.overrides},[S.overrides]);const he=g.useCallback((F,B)=>{var $;if(!le||!Q)return;const Z=($=te==null?void 0:te.find(D=>D.id===F))==null?void 0:$.position;Me(F,{position:B}),I(null),Y(),Z&&G({do:async()=>{await Q.updateNodePosition(F,B)},undo:async()=>{await Q.updateNodePosition(F,Z)},coalesceKey:`node:${F}:position`}),Q.updateNodePosition(F,B).catch(D=>{qe(F),Z&&X(),I(D instanceof Error?D.message:String(D)),console.error("updateNodePosition failed",D)})},[le,Q,te,Me,qe,G,X,Y]),Ie=g.useCallback(F=>{if(!le||!Q||F.length===0)return;const B=re.current,Z=F.map($=>{var Pe;const D=te==null?void 0:te.find(ke=>ke.id===$.id);if(!D)return null;const ne=((Pe=B[$.id])==null?void 0:Pe.position)??D.position;return{id:$.id,prev:ne,next:$.position}}).filter($=>$!==null);if(Z.length!==0){for(const $ of Z)Me($.id,{position:$.next});I(null),Y(),G({do:async()=>{await Promise.allSettled(Z.map($=>Q.updateNodePosition($.id,$.next)))},undo:async()=>{await Promise.allSettled(Z.map($=>Q.updateNodePosition($.id,$.prev)))}}),Promise.all(Z.map(async $=>{try{return await Q.updateNodePosition($.id,$.next),null}catch(D){return qe($.id),D instanceof Error?D.message:String(D)}})).then($=>{const D=$.find(ne=>ne!==null);D&&I(D)})}},[le,Q,te,Me,qe,G,Y]),He=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=te==null?void 0:te.find(ne=>ne.id===F),$=Z?{width:Z.data.width,height:Z.data.height,position:{x:Z.position.x,y:Z.position.y}}:void 0,D={width:B.width,height:B.height,position:{x:B.x,y:B.y}};Me(F,{position:D.position,data:{width:D.width,height:D.height}}),I(null),Y(),$&&G({do:async()=>{await Q.updateNode(F,D)},undo:async()=>{await Q.updateNode(F,$)},coalesceKey:`node:${F}:resize`}),Q.updateNode(F,D).catch(ne=>{qe(F),$&&X(),I(ne instanceof Error?ne.message:String(ne)),console.error("updateNode resize failed",ne)})},[le,Q,te,Me,qe,G,X,Y]),Ue=g.useCallback(F=>{if(!le||!Q)return;const B=te==null?void 0:te.find(D=>D.id===F);if(!B)return;const Z={autoSize:B.data.autoSize,width:B.data.width,height:B.data.height},$={autoSize:!0};Me(F,{data:{autoSize:!0,width:void 0,height:void 0}}),I(null),Y(),G({do:async()=>{await Q.updateNode(F,$)},undo:async()=>{await Q.updateNode(F,Z)},coalesceKey:`node:${F}:fit-to-content`}),Q.updateNode(F,$).catch(D=>{qe(F),X(),I(D instanceof Error?D.message:String(D)),console.error("updateNode (fit-to-content) failed",D)})},[le,Q,te,Me,qe,G,X,Y]),Rt=g.useCallback(F=>{if(!le||!Q||F.length===0)return;const B=[];for(const $ of F){const D=te==null?void 0:te.find(dt=>dt.id===$.id);if(!D)continue;const ne=D.data,Pe={position:{x:D.position.x,y:D.position.y}};ne.width!==void 0&&(Pe.width=ne.width),ne.height!==void 0&&(Pe.height=ne.height);const ke={position:$.position};$.width!==void 0&&(ke.width=$.width),$.height!==void 0&&(ke.height=$.height),B.push({id:$.id,prev:Pe,next:ke})}if(B.length===0)return;for(const $ of B){const D={};$.next.width!==void 0&&(D.width=$.next.width),$.next.height!==void 0&&(D.height=$.next.height),Me($.id,{position:$.next.position,...Object.keys(D).length>0?{data:D}:{}})}I(null),Y();const Z=B.map($=>$.id).sort();G({do:async()=>{await Promise.allSettled(B.map($=>Q.updateNode($.id,$.next)))},undo:async()=>{await Promise.allSettled(B.map($=>Q.updateNode($.id,$.prev)))},coalesceKey:`multi:resize:${Z.join(",")}`}),Promise.all(B.map(async $=>{try{return await Q.updateNode($.id,$.next),null}catch(D){return qe($.id),D instanceof Error?D.message:String(D)}})).then($=>{const D=$.find(ne=>ne!==null);D&&I(D)})},[le,Q,te,Me,qe,G,Y]),{setOverride:Oe,dropOverride:je}=C,Pt=g.useCallback((F,B)=>{Me(F,{data:B})},[Me]),sr=g.useCallback((F,B)=>{for(const Z of F)Me(Z,{data:B})},[Me]),Dt=g.useCallback((F,B)=>{Oe(F,B)},[Oe]),Dn=g.useCallback((F,B)=>{if(!le||!Q)return;WQ(Ai,B);const Z=te==null?void 0:te.find(D=>D.id===F);let $=null;if(Z){$={};const D=Z.data;for(const ne of Object.keys(B))$[ne]=D[ne]}if(Me(F,{data:B}),I(null),Y(),$){const D=$;G({do:async()=>{await Q.updateNode(F,B)},undo:async()=>{await Q.updateNode(F,D)},coalesceKey:`node:${F}:style`})}Q.updateNode(F,B).catch(D=>{qe(F),$&&X(),I(D instanceof Error?D.message:String(D)),console.error("updateNode style failed",D)})},[le,Q,te,Me,qe,G,X,Y]),en=g.useCallback((F,B)=>{if(!le||!Q||F.length===0)return;WQ(Ai,B);const Z=F.map($=>{const D=te==null?void 0:te.find(ke=>ke.id===$);if(!D)return null;const ne=D.data,Pe={};for(const ke of Object.keys(B))Pe[ke]=ne[ke];return{id:$,prev:Pe}}).filter($=>$!==null);if(Z.length!==0){for(const $ of Z)Me($.id,{data:B});I(null),Y(),G({do:async()=>{await Promise.allSettled(Z.map($=>Q.updateNode($.id,B)))},undo:async()=>{await Promise.allSettled(Z.map($=>Q.updateNode($.id,$.prev)))}}),Promise.all(Z.map(async $=>{try{return await Q.updateNode($.id,B),null}catch(D){return qe($.id),D instanceof Error?D.message:String(D)}})).then($=>{const D=$.find(ne=>ne!==null);D&&I(D)})}},[le,Q,te,Me,qe,G,Y]),$u=g.useCallback(F=>{if(!le||!Q||F.length===0)return;const B=F.map(D=>{const ne=te==null?void 0:te.find(ke=>ke.id===D);if(!ne)return null;const Pe=ne.data;return{id:D,prev:Pe.locked===!0}}).filter(D=>D!==null);if(B.length===0)return;const Z=B.some(D=>!D.prev),$=B.filter(D=>D.prev!==Z);if($.length!==0){for(const D of $)Me(D.id,{data:{locked:Z}});I(null),Y(),G({do:async()=>{await Promise.allSettled($.map(D=>Q.updateNode(D.id,{locked:Z})))},undo:async()=>{await Promise.allSettled($.map(D=>Q.updateNode(D.id,{locked:D.prev})))}}),Promise.all($.map(async D=>{try{return await Q.updateNode(D.id,{locked:Z}),null}catch(ne){return qe(D.id),ne instanceof Error?ne.message:String(ne)}})).then(D=>{const ne=D.find(Pe=>Pe!==null);ne&&I(ne)})}},[le,Q,te,Me,qe,G,Y]),Uu=g.useCallback((F,B)=>{if(!le||!Q)return;SMe(Ai,B);const Z=ie==null?void 0:ie.find(D=>D.id===F);let $=null;if(Z){$={};const D=Z;for(const ne of Object.keys(B))$[ne]=D[ne]}if(Oe(F,B),I(null),Y(),$){const D=$;G({do:async()=>{await Q.updateConnector(F,B)},undo:async()=>{await Q.updateConnector(F,D)},coalesceKey:`connector:${F}:style`})}Q.updateConnector(F,B).catch(D=>{je(F),$&&X(),I(D instanceof Error?D.message:String(D)),console.error("updateConnector failed",D)})},[le,Q,ie,Oe,je,G,X,Y]),{mark:da,markMany:ha,unmark:Xr,unmarkMany:gi}=L,{mark:fa,markMany:xr,unmark:Yr,unmarkMany:wr}=P,Wu=g.useCallback(F=>{if(!le||!Q)return;const B=te==null?void 0:te.find(ke=>ke.id===F);if(!B||B.data.locked===!0)return;const Z=(ie??[]).filter(ke=>ke.source===F||ke.target===F),$=Z.map(ke=>ke.id),D=new Set($);I(null),da(F),$.length>0&&xr($),d(ke=>ke.filter(dt=>dt!==F)),p(ke=>ke.filter(dt=>!D.has(dt))),Y();const ne=B,Pe=Z;G({do:async()=>{da(F),$.length>0&&xr($),await Q.deleteNode(F)},undo:async()=>{Xr(F),$.length>0&&wr($),await Q.createNode({id:ne.id,type:ne.type,position:ne.position,data:ne.data});for(const ke of Pe)await Q.createConnector({...ke,id:ke.id})}}),Q.deleteNode(F).catch(ke=>{Xr(F),$.length>0&&wr($),X(),I(ke instanceof Error?ke.message:String(ke)),console.error("deleteNode failed",ke)})},[le,Q,te,ie,da,xr,Xr,wr,G,X,Y]),Ve=g.useCallback((F,B)=>{if(!le||!Q||!te)return;const Z=T??te.map(ne=>ne.id),$=dqe(Z,F,B);if(!$)return;const D=Z.indexOf(F);_($),I(null),Y(),G({do:async()=>{await Q.reorderNode(F,B)},undo:async()=>{await Q.reorderNode(F,{op:"toIndex",index:D})}}),Q.reorderNode(F,B).catch(ne=>{_(null),X(),I(ne instanceof Error?ne.message:String(ne)),console.error("reorderNode failed",ne)})},[le,Q,te,T,G,X,Y]);g.useCallback(F=>{if(!le||!Q)return;const B=ie==null?void 0:ie.find($=>$.id===F);if(!B)return;I(null),fa(F),p($=>$.filter(D=>D!==F)),Y();const Z=B;G({do:async()=>{fa(F),await Q.deleteConnector(F)},undo:async()=>{Yr(F),await Q.createConnector({...Z,id:Z.id})}}),Q.deleteConnector(F).catch($=>{Yr(F),X(),I($ instanceof Error?$.message:String($)),console.error("deleteConnector failed",$)})},[le,Q,ie,fa,Yr,G,X,Y]);const yt=g.useCallback((F,B)=>{if(!le||!Q||F.length===0&&B.length===0)return;const Z=F,$=new Set((te??[]).filter(_e=>_e.data.locked===!0).map(_e=>_e.id)),D=Z.filter(_e=>!$.has(_e)),ne=new Set(D),Pe=D.map(_e=>te==null?void 0:te.find(nt=>nt.id===_e)).filter(_e=>!!_e),ke=(ie??[]).filter(_e=>ne.has(_e.source)||ne.has(_e.target)),dt=new Set(ke.map(_e=>_e.id)),Tt=B.map(_e=>ie==null?void 0:ie.find(nt=>nt.id===_e)).filter(_e=>!!_e).filter(_e=>!dt.has(_e.id)).filter(_e=>!($.has(_e.source)&&$.has(_e.target)));if(Pe.length===0&&ke.length===0&&Tt.length===0)return;I(null);const Sn=Pe.map(_e=>_e.id),Kt=[...ke.map(_e=>_e.id),...Tt.map(_e=>_e.id)];Sn.length>0&&ha(Sn),Kt.length>0&&xr(Kt);const Lr=Pe;d(_e=>_e.filter(nt=>!ne.has(nt)));const wa=new Set(Tt.map(_e=>_e.id));p(_e=>_e.filter(nt=>!wa.has(nt)&&!dt.has(nt))),Y(),G({do:async()=>{Sn.length>0&&ha(Sn),Kt.length>0&&xr(Kt);for(const _e of Lr)await Q.deleteNode(_e.id).catch(()=>{});await Promise.allSettled(Tt.map(_e=>Q.deleteConnector(_e.id)))},undo:async()=>{Sn.length>0&&gi(Sn),Kt.length>0&&wr(Kt);for(let _e=Lr.length-1;_e>=0;_e--){const nt=Lr[_e];nt&&await Q.createNode({id:nt.id,type:nt.type,position:nt.position,data:nt.data})}for(const _e of[...ke,...Tt])await Q.createConnector({..._e,id:_e.id})}});const Zu=new Map;for(const _e of Pe)Zu.set(_e.id,ke.filter(nt=>nt.source===_e.id||nt.target===_e.id).map(nt=>nt.id));(async()=>{const _e=[];for(const Ne of Lr)try{await Q.deleteNode(Ne.id)}catch(it){Xr(Ne.id);const jt=Zu.get(Ne.id)??[];jt.length>0&&wr(jt),_e.push(it instanceof Error?it.message:String(it))}const nt=await Promise.all(Tt.map(async Ne=>{try{return await Q.deleteConnector(Ne.id),null}catch(it){return Yr(Ne.id),it instanceof Error?it.message:String(it)}}));for(const Ne of nt)Ne!==null&&_e.push(Ne);_e.length>0&&_e[0]!==void 0&&I(_e[0])})()},[le,Q,te,ie,ha,xr,Xr,gi,Yr,wr,G,Y]);g.useEffect(()=>{M.current=yt},[yt]),g.useEffect(()=>{const F=B=>{if(B.key!=="Delete"&&B.key!=="Backspace"||Pr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=w.current,$=v.current;Z.length===0&&$.length===0||(B.preventDefault(),yt(Z,$))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[yt]);const{undo:Qr,redo:Po,canUndo:qn,canRedo:xn}=R;g.useEffect(()=>{const F=async B=>{if((B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="z"&&!Pr(document.activeElement)){if(B.preventDefault(),B.shiftKey){if(!xn)return;try{const Z=await Po();Z!=null&&Z.entry&&await Z.entry.do()}catch(Z){I(Z instanceof Error?Z.message:String(Z)),console.error("redo failed",Z)}return}if(qn)try{const Z=await Qr();Z!=null&&Z.entry&&await Z.entry.undo()}catch(Z){I(Z instanceof Error?Z.message:String(Z)),console.error("undo failed",Z)}}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[Qr,Po,qn,xn]);const _o=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=te==null?void 0:te.find(ne=>ne.id===F),D=(Z&&"name"in Z.data?Z.data.name:void 0)??"";Me(F,{data:{name:B}}),I(null),Y(),Z&&G({do:async()=>{await Q.updateNode(F,{name:B})},undo:async()=>{await Q.updateNode(F,{name:D})},coalesceKey:`node:${F}:name`}),Q.updateNode(F,{name:B}).catch(ne=>{Z&&X(),I(ne instanceof Error?ne.message:String(ne)),console.error("updateNode name failed",ne)})},[le,Q,te,Me,G,X,Y]),On=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=te==null?void 0:te.find(D=>D.id===F);if(!Z)return;const $=Z.data.description??"";Me(F,{data:{description:B}}),I(null),Y(),G({do:async()=>{await Q.updateNode(F,{description:B})},undo:async()=>{await Q.updateNode(F,{description:$})},coalesceKey:`node:${F}:description`}),Q.updateNode(F,{description:B}).catch(D=>{X(),I(D instanceof Error?D.message:String(D)),console.error("updateNode description failed",D)})},[le,Q,te,Me,G,X,Y]),Jr=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=te==null?void 0:te.find(D=>D.id===F);if(!Z)return;const $=Z.data.detail??"";Me(F,{data:{detail:B}}),I(null),Y(),G({do:async()=>{await Q.updateNode(F,{detail:B})},undo:async()=>{await Q.updateNode(F,{detail:$})},coalesceKey:`node:${F}:detail`}),Q.updateNode(F,{detail:B}).catch(D=>{X(),I(D instanceof Error?D.message:String(D)),console.error("updateNode detail failed",D)})},[le,Q,te,Me,G,X,Y]),un=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=te==null?void 0:te.find(D=>D.id===F);if(!Z)return;const $="icon"in Z.data?Z.data.icon??null:null;Me(F,{data:{icon:B??void 0}}),I(null),Y(),G({do:async()=>{await Q.updateNode(F,{icon:B})},undo:async()=>{await Q.updateNode(F,{icon:$})},coalesceKey:`node:${F}:icon`}),Q.updateNode(F,{icon:B}).catch(D=>{X(),I(D instanceof Error?D.message:String(D)),console.error("updateNode icon failed",D)})},[le,Q,te,Me,G,X,Y]),Gt=g.useCallback((F,B,Z)=>{if(!le||!Q)return;I(null);const $=`node-${crypto.randomUUID()}`,D=KQ(F,Z,C0(Ai).node),ne={id:$,type:"shapeNode",position:B,data:D};Me($,{id:$,type:"shapeNode",position:B,data:D}),Y(),Q.createNode(ne).then(({id:ke})=>{G({do:async()=>{await Q.createNode({...ne,id:ke})},undo:async()=>{await Q.deleteNode(ke)}})}).catch(ke=>{qe($),I(ke instanceof Error?ke.message:String(ke)),console.error("createNode failed",ke)})},[le,Q,Me,qe,G,Y]),eo=g.useCallback((F,B)=>{if(!le||!Q)return;I(null);const Z=`node-${crypto.randomUUID()}`,$={icon:F,width:ld.width,height:ld.height},D={id:Z,type:"iconNode",position:B,data:$};Me(Z,{id:Z,type:"iconNode",position:B,data:$}),d([Z]),Y(),Q.createNode(D).then(({id:Pe})=>{G({do:async()=>{await Q.createNode({...D,id:Pe})},undo:async()=>{await Q.deleteNode(Pe)}})}).catch(Pe=>{qe(Z),I(Pe instanceof Error?Pe.message:String(Pe)),console.error("createNode (icon) failed",Pe)})},[le,Q,Me,qe,G,Y]),pa=g.useCallback(F=>{if(!le||!Q)return;I(null);const B=`node-${crypto.randomUUID()}`,Z=`blocks/${B}.html`,$={id:B,type:"htmlNode",position:F.position,data:{}},D={id:B,type:"htmlNode",position:F.position,data:{htmlPath:Z}};Me(B,D),d([B]),Y(),Q.createNode($).then(({id:ne})=>{G({do:async()=>{await Q.createNode({...$,id:ne})},undo:async()=>{await Q.deleteNode(ne)}})}).catch(ne=>{qe(B),I(ne instanceof Error?ne.message:String(ne)),console.error("createNode (htmlNode) failed",ne)})},[le,Q,Me,qe,G,Y]),to=g.useRef(new Map),ki=g.useCallback((F,B)=>{to.current.set(F,B)},[]),vi=g.useCallback(F=>{to.current.delete(F)},[]),mt=g.useCallback(F=>{!le||!Q||(I(null),Y(),lqe({...F,demoId:le,lastUsed:C0(Ai).node},{upload:(B,Z,$)=>Q.uploadImage(Z,$),createNode:async(B,Z)=>{const{id:$}=await Q.createNode(Z);return{id:$}},deleteNode:async(B,Z)=>(await Q.deleteNode(Z),{ok:!0}),setOverride:Me,pushUndo:G,rememberRetry:ki,forgetRetry:vi}).catch(B=>{console.error("image-upload-flow failed",B)}))},[le,Q,Me,G,Y,ki,vi]),xi=g.useCallback(F=>{if(!le||!Q)return;const B=`node-${crypto.randomUUID()}`;mt({nodeId:B,...F})},[le,Q,mt]),ya=g.useCallback(F=>{const B=to.current.get(F);B&&mt({nodeId:F,...B})},[mt]),[Mr,br]=g.useState({open:!1,mode:"insert"}),cr=g.useCallback((F,B)=>{br({open:!0,mode:F,nodeId:B})},[]),ma=g.useCallback(()=>{br(F=>({...F,open:!1}))},[]),wi=g.useCallback(()=>{cr("insert")},[cr]),Mi=g.useCallback(F=>cr("replace",F),[cr]),ga=g.useCallback(F=>{if(yMe(F),Mr.mode==="replace"&&Mr.nodeId){if(le&&Q){const B=Mr.nodeId,Z=te==null?void 0:te.find(D=>D.id===B),$=(Z==null?void 0:Z.type)==="iconNode"?Z.data.icon:void 0;if(Me(B,{data:{icon:F}}),I(null),Y(),$!==void 0){const D=$;G({do:async()=>{await Q.updateNode(B,{icon:F})},undo:async()=>{await Q.updateNode(B,{icon:D})},coalesceKey:`node:${B}:icon`})}Q.updateNode(B,{icon:F}).catch(D=>{qe(B),$!==void 0&&X(),I(D instanceof Error?D.message:String(D)),console.error("updateNode (icon replace) failed",D)})}}else{const B=W.current;if(B&&le){const Z=fMe(B,{width:window.innerWidth,height:window.innerHeight});eo(F,Z)}}ma()},[Mr.mode,Mr.nodeId,le,Q,te,Me,qe,G,X,Y,eo,ma]),wn=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=ie==null?void 0:ie.find(D=>D.id===F),$=Z==null?void 0:Z.label;Oe(F,{label:B}),I(null),Y(),Z&&G({do:async()=>{await Q.updateConnector(F,{label:B})},undo:async()=>{await Q.updateConnector(F,{label:$})},coalesceKey:`connector:${F}:label`}),Q.updateConnector(F,{label:B}).catch(D=>{Z&&X(),I(D instanceof Error?D.message:String(D)),console.error("updateConnector label failed",D)})},[le,Q,ie,Oe,G,X,Y]),Ro=g.useCallback((F,B,Z)=>{if(!le||!Q)return;const $=`conn-${crypto.randomUUID()}`,D=Z==null?void 0:Z.targetPin,ne=C0(Ai).connector,Pe={id:$,source:F,target:B,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...D?{targetPin:D}:{},...ne,kind:"default"},ke={id:$,source:F,target:B,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...D?{targetPin:D}:{},...ne,kind:"default"};Oe($,Pe),I(null),Y(),Q.createConnector(ke).then(({id:dt})=>{G({do:async()=>{await Q.createConnector({...ke,id:dt})},undo:async()=>{await Q.deleteConnector(dt)}})}).catch(dt=>{je($),I(dt instanceof Error?dt.message:String(dt)),console.error("createConnector failed",dt)})},[le,Q,Oe,je,G,Y]),ka=g.useCallback(({sourceNodeId:F,position:B,shape:Z})=>{if(!le||!Q)return;I(null);const $=`node-${crypto.randomUUID()}`,D=`conn-${crypto.randomUUID()}`,ne=uR[Z],Pe=C0(Ai),ke=KQ(Z,ne,Pe.node),dt={id:$,type:"shapeNode",position:B,data:ke},Tt={id:D,source:F,target:$,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...Pe.connector,kind:"default"};Me($,{id:$,type:"shapeNode",position:B,data:ke}),Oe(D,Tt),k($),Y(),(async()=>{try{await Q.createNode(dt),await Q.createConnector(Tt),G({do:async()=>{await Q.createNode(dt),await Q.createConnector(Tt)},undo:async()=>{je(D),qe($),await Q.deleteConnector(D).catch(()=>{}),await Q.deleteNode($).catch(()=>{})}})}catch(Kt){qe($),je(D),I(Kt instanceof Error?Kt.message:String(Kt)),console.error("createAndConnectFromPane failed",Kt)}})()},[le,Q,Me,qe,Oe,je,G,Y]),va=g.useRef(null),[To,bi]=g.useState(!1),Mn=g.useCallback(F=>{if(!te)return;const B=new Set(F),Z=te.filter(D=>B.has(D.id));if(Z.length===0)return;const $=(ie??[]).filter(D=>B.has(D.source)&&B.has(D.target));va.current=JSON.parse(JSON.stringify({nodes:Z,connectors:$})),bi(!0)},[te,ie]),tn=g.useCallback(F=>{if(!le||!Q)return;const B=va.current;if(!B||B.nodes.length===0)return;const{newNodes:Z,newConnectors:$}=aqe({nodes:B.nodes,connectors:B.connectors,flowPos:F,nodeIdGen:()=>`node-${crypto.randomUUID()}`,connectorIdGen:()=>`conn-${crypto.randomUUID()}`});for(const D of Z)Me(D.id,D);for(const D of $)Oe(D.id,D);d(Z.map(D=>D.id)),p($.map(D=>D.id)),I(null),Y(),(async()=>{try{for(const D of Z)await Q.createNode({id:D.id,type:D.type,position:D.position,data:D.data});for(const D of $)await Q.createConnector(D);G({do:async()=>{for(const D of Z)await Q.createNode({id:D.id,type:D.type,position:D.position,data:D.data});for(const D of $)await Q.createConnector(D)},undo:async()=>{await Promise.allSettled($.map(D=>Q.deleteConnector(D.id))),await Promise.allSettled(Z.map(D=>Q.deleteNode(D.id)))}})}catch(D){for(const ne of Z)qe(ne.id);for(const ne of $)je(ne.id);I(D instanceof Error?D.message:String(D)),console.error("paste failed",D)}})()},[le,Q,Me,qe,Oe,je,Y,G]);g.useEffect(()=>{const F=B=>{const Z=bMe({event:B,isEditableActive:Pr(document.activeElement),hasNodes:!!te&&te.length>0,hasConnectors:!!ie&&ie.length>0,selectedIds:w.current,hasClipboard:!!va.current});if(Z.type!=="noop"&&!(Z.type==="copy"||Z.type==="paste")){if(B.preventDefault(),Z.type==="selectAll"){d((te??[]).map($=>$.id)),p((ie??[]).map($=>$.id));return}Mn([...Z.ids]),tn(null)}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[te,ie,Mn,tn]),g.useEffect(()=>{const F=B=>{const Z=xMe(B);if(!Z||Pr(document.activeElement))return;const $=w.current;if($.length===0)return;const D=S.overrides,ne=(te??[]).map(ke=>{var Tt;const dt=((Tt=D[ke.id])==null?void 0:Tt.position)??ke.position;return{id:ke.id,position:dt}}),Pe=MMe(Z,$,ne);if(Pe.length!==0)if(B.preventDefault(),Pe.length===1){const ke=Pe[0];ke&&he(ke.id,ke.position)}else Ie(Pe)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[te,S.overrides,he,Ie]),g.useEffect(()=>{const F=B=>{const Z=wMe(B);if(!Z||Pr(document.activeElement))return;B.preventDefault();const $=W.current;$&&(Z==="fit"?$.fitView({padding:.2,duration:200}):Z==="in"?$.zoomIn({duration:150}):$.zoomOut({duration:150}))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const Fn=g.useCallback(F=>{if(!le||!Q||!te)return;const B=S.overrides,Z=W.current,$=F==="selection"?new Set(w.current):null,D=$?te.filter(Ne=>$.has(Ne.id)):te;if(D.length<2)return;const ne=new Set(D.map(Ne=>Ne.id)),Pe=(ie??[]).filter(Ne=>ne.has(Ne.source)&&ne.has(Ne.target)),ke=D.map(Ne=>{var Si;const it=((Si=B[Ne.id])==null?void 0:Si.position)??Ne.position,jt=Z==null?void 0:Z.getInternalNode(Ne.id),Bn=jt==null?void 0:jt.measured,Vn=Ne.data,QT=(Bn==null?void 0:Bn.width)??Vn.width??200,JT=(Bn==null?void 0:Bn.height)??Vn.height??120;return{id:Ne.id,width:QT,height:JT,position:it}}),dt=Pe.map(Ne=>({source:Ne.source,target:Ne.target})),Tt=eae(ke,dt);let Sn=Number.POSITIVE_INFINITY,Kt=Number.POSITIVE_INFINITY,Lr=Number.POSITIVE_INFINITY,wa=Number.POSITIVE_INFINITY;for(const Ne of ke){Ne.position.x<Sn&&(Sn=Ne.position.x),Ne.position.y<Kt&&(Kt=Ne.position.y);const it=Tt.get(Ne.id);it&&(it.x<Lr&&(Lr=it.x),it.y<wa&&(wa=it.y))}const Zu=Number.isFinite(Sn)&&Number.isFinite(Lr)?Sn-Lr:0,_e=Number.isFinite(Kt)&&Number.isFinite(wa)?Kt-wa:0,nt=[];for(const Ne of ke){const it=Tt.get(Ne.id);if(!it)continue;const jt={x:it.x+Zu,y:it.y+_e},Bn=jt.x-Ne.position.x,Vn=jt.y-Ne.position.y;Math.abs(Bn)<1&&Math.abs(Vn)<1||nt.push({id:Ne.id,prev:Ne.position,next:jt})}if(nt.length!==0){I(null);for(const Ne of nt)Me(Ne.id,{position:Ne.next});Y(),G({do:async()=>{await Promise.allSettled(nt.map(Ne=>Q.updateNodePosition(Ne.id,Ne.next)))},undo:async()=>{await Promise.allSettled(nt.map(Ne=>Q.updateNodePosition(Ne.id,Ne.prev)))}}),Promise.all(nt.map(async Ne=>{try{return await Q.updateNodePosition(Ne.id,Ne.next),null}catch(it){return qe(Ne.id),it instanceof Error?it.message:String(it)}})).then(Ne=>{const it=Ne.filter(Bn=>Bn!==null),jt=it[0];jt&&(I(it.length===1?jt:`${it.length} node updates failed (first: ${jt})`),console.error("Tidy: some updateNodePosition calls failed",it))})}},[le,Q,te,ie,S.overrides,Me,qe,G,Y]);g.useEffect(()=>{const F=B=>{if(!(B.metaKey||B.ctrlKey)||!B.shiftKey||B.altKey||B.key.toLowerCase()!=="l"||Pr(document.activeElement))return;B.preventDefault();const Z=w.current.length>0?"selection":"all";Fn(Z)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[Fn]);const no=g.useCallback(()=>{const F=w.current.length>0?"selection":"all";Fn(F)},[Fn]);g.useEffect(()=>{const F=B=>{if(Pr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=CMe(B);if(Z===null)return;const $=Z==="select"?null:Z;if(H.current===$){j(null);return}j($)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]),g.useEffect(()=>{const F=B=>{B.key==="Escape"&&(Pr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]')||(w.current.length>0&&d([]),v.current.length>0&&p([]),H.current!==null&&j(null)))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]),g.useEffect(()=>{const F=B=>{if(B.key.toLowerCase()!=="f"||B.metaKey||B.ctrlKey||B.shiftKey||B.altKey||Pr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=w.current;if(Z.length===0)return;const $=W.current;$&&$.fitView({nodes:Z.map(D=>({id:D})),padding:.2,duration:200})};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]),g.useEffect(()=>{const F=B=>{if(B.key!=="1"||B.metaKey||B.ctrlKey||B.shiftKey||B.altKey||Pr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=W.current;if(!Z)return;const{x:$,y:D}=Z.getViewport();Z.setViewport({x:$,y:D,zoom:1},{duration:150})};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const jo=g.useCallback(F=>{var B,Z,$;switch(F){case"tool.select":j(null);return;case"tool.rectangle":j("rectangle");return;case"tool.ellipse":j("ellipse");return;case"tool.text":j("text");return;case"tool.sticky":j("sticky");return;case"tool.database":j("database");return;case"edit.undo":{if(!qn)return;(async()=>{try{const D=await Qr();D!=null&&D.entry&&await D.entry.undo()}catch(D){I(D instanceof Error?D.message:String(D)),console.error("undo failed",D)}})();return}case"edit.redo":{if(!xn)return;(async()=>{try{const D=await Po();D!=null&&D.entry&&await D.entry.do()}catch(D){I(D instanceof Error?D.message:String(D)),console.error("redo failed",D)}})();return}case"edit.copy":{const D=w.current;if(D.length===0)return;Mn([...D]);return}case"edit.paste":tn(null);return;case"edit.duplicate":{const D=w.current;if(D.length===0)return;Mn([...D]),tn(null);return}case"edit.delete":{const D=w.current,ne=v.current;if(D.length===0&&ne.length===0)return;yt([...D],[...ne]);return}case"edit.selectAll":d((te??[]).map(D=>D.id)),p((ie??[]).map(D=>D.id));return;case"view.fit":{const D=W.current;if(!D)return;D.fitView({padding:.2,duration:200});return}case"view.zoomIn":{const D=W.current;if(!D)return;D.zoomIn({duration:150});return}case"view.zoomOut":{const D=W.current;if(!D)return;D.zoomOut({duration:150});return}case"view.zoom100":{const D=W.current;if(!D)return;const{x:ne,y:Pe}=D.getViewport();D.setViewport({x:ne,y:Pe,zoom:1},{duration:150});return}case"view.zoomToSelection":{const D=w.current;if(D.length===0)return;const ne=W.current;if(!ne)return;ne.fitView({nodes:D.map(Pe=>({id:Pe})),padding:.2,duration:200});return}case"layout.tidy":{const D=w.current.length>0?"selection":"all";Fn(D);return}case"selection.deselect":w.current.length>0&&d([]),v.current.length>0&&p([]),H.current!==null&&j(null);return;case"help.commandPalette":U(!0);return;case"export.pdf":{(B=b.current)==null||B.exportPdf();return}case"export.png":{(Z=b.current)==null||Z.exportPng();return}case"session.reset":{($=x.current)==null||$.call(x);return}}},[qn,xn,Qr,Po,Mn,tn,yt,te,ie,Fn]);g.useEffect(()=>{const F=B=>{(B.metaKey||B.ctrlKey)&&(B.shiftKey||B.altKey||B.key.toLowerCase()==="p"&&(B.preventDefault(),!Pr(document.activeElement)&&jo("help.commandPalette")))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[jo]),g.useEffect(()=>{x.current=c??null},[c]);const Hn=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=ie==null?void 0:ie.find(ne=>ne.id===F),$=Z?{source:Z.source,target:Z.target,sourceHandle:Z.sourceHandle,targetHandle:Z.targetHandle,sourceHandleAutoPicked:Z.sourceHandleAutoPicked,targetHandleAutoPicked:Z.targetHandleAutoPicked,sourcePin:Z.sourcePin??null,targetPin:Z.targetPin??null}:null,D={...B.source!==void 0?{source:B.source}:{},...B.target!==void 0?{target:B.target}:{},...B.sourceHandle!==void 0?{sourceHandle:B.sourceHandle===null?void 0:B.sourceHandle}:{},...B.targetHandle!==void 0?{targetHandle:B.targetHandle===null?void 0:B.targetHandle}:{},...B.sourceHandleAutoPicked!==void 0?{sourceHandleAutoPicked:B.sourceHandleAutoPicked}:{},...B.targetHandleAutoPicked!==void 0?{targetHandleAutoPicked:B.targetHandleAutoPicked}:{},...B.sourcePin!==void 0?{sourcePin:B.sourcePin===null?void 0:B.sourcePin}:{},...B.targetPin!==void 0?{targetPin:B.targetPin===null?void 0:B.targetPin}:{}};if(Oe(F,D),I(null),Y(),$){const ne=$;G({do:async()=>{await Q.updateConnector(F,B)},undo:async()=>{await Q.updateConnector(F,ne)},coalesceKey:`connector:${F}:reconnect`})}Q.updateConnector(F,B).catch(ne=>{je(F),$&&X(),I(ne instanceof Error?ne.message:String(ne)),console.error("updateConnector reconnect failed",ne)})},[le,Q,ie,Oe,je,G,X,Y]),xa=g.useCallback((F,B,Z)=>{if(!le||!Q)return;const $=ie==null?void 0:ie.find(Pe=>Pe.id===F),D=$?B==="source"?$.sourcePin:$.targetPin:void 0,ne=B==="source"?"sourcePin":"targetPin";if(Oe(F,{[ne]:Z}),I(null),Y(),$){const Pe={[ne]:D??null};G({do:async()=>{await Q.updateConnector(F,{[ne]:Z})},undo:async()=>{await Q.updateConnector(F,Pe)},coalesceKey:`connector:${F}:${ne}`})}Q.updateConnector(F,{[ne]:Z}).catch(Pe=>{je(F),$&&X(),I(Pe instanceof Error?Pe.message:String(Pe)),console.error("updateConnector pin failed",Pe)})},[le,Q,ie,Oe,je,G,X,Y]),Cr=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=ie==null?void 0:ie.find(ne=>ne.id===F),$=Z?B==="source"?Z.sourcePin:Z.targetPin:void 0;if(!$)return;const D=B==="source"?"sourcePin":"targetPin";Oe(F,{[D]:void 0}),I(null),Y(),G({do:async()=>{await Q.updateConnector(F,{[D]:null})},undo:async()=>{await Q.updateConnector(F,{[D]:$})}}),Q.updateConnector(F,{[D]:null}).catch(ne=>{je(F),X(),I(ne instanceof Error?ne.message:String(ne)),console.error("updateConnector unpin failed",ne)})},[le,Q,ie,Oe,je,G,X,Y]),st=n==null?void 0:n.demo,Sr=S.overrides,bn=C.overrides,Cn=L.ids,Ci=P.ids,Gu=g.useMemo(()=>{if(!st||u.length===0)return[];const F=new Map(st.nodes.map(Z=>[Z.id,Z])),B=[];for(const Z of u){const $=F.get(Z);if(!$)continue;const D=Sr[Z];if(!D){B.push($);continue}const ne=D.data?{...$.data,...D.data}:$.data;B.push({...$,...D,data:ne})}return B},[st,u,Sr]),YT=g.useMemo(()=>{if(!st||f.length===0)return[];const F=new Map(st.connectors.map(Z=>[Z.id,Z])),B=[];for(const Z of f){const $=F.get(Z);if(!$)continue;const D=bn[Z];B.push(D?{...$,...D}:$)}return B},[st,f,bn]),ro=g.useMemo(()=>{if(!st)return null;if(!T)return st.nodes;const F=new Map(st.nodes.map($=>[$.id,$])),B=[],Z=new Set;for(const $ of T){const D=F.get($);D&&(B.push(D),Z.add($))}for(const $ of st.nodes)Z.has($.id)||B.push($);return B},[st,T]),Ku=g.useMemo(()=>{const F=ro??(st==null?void 0:st.nodes)??null;return F?Cn.size===0?F:F.filter(B=>!Cn.has(B.id)):null},[ro,st,Cn]),Of=g.useMemo(()=>{const F=(st==null?void 0:st.connectors)??null;return F?Ci.size===0&&Cn.size===0?F:F.filter(B=>!Ci.has(B.id)&&!Cn.has(B.source)&&!Cn.has(B.target)):null},[st,Ci,Cn]);if(!l)return m.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[m.jsxs("p",{className:"text-sm font-medium",children:["Unknown demo: ",e]}),m.jsx("p",{className:"text-xs text-muted-foreground",children:"The slug may have been removed. Re-register from the project repo to bring it back."})]});if(r&&!n)return m.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Loading demo…"});const No=u[0],Ff=No?i[No]:void 0;return m.jsxs("div",{className:"relative h-full w-full",children:[n&&!n.valid?m.jsxs("div",{"data-testid":"demo-error-banner",className:"absolute inset-x-0 top-0 z-10 border-b border-rose-500/40 bg-rose-50 px-4 py-2 text-xs text-rose-900 shadow-xs dark:bg-rose-950/40 dark:text-rose-100",children:[m.jsx("span",{className:"font-medium uppercase tracking-wide",children:"Invalid demo: "}),m.jsx("span",{className:"font-mono",children:n.error})]}):null,st&&Q?m.jsx(Xze,{ref:b,mode:"edit",adapter:Q,projectId:le??void 0,enableEmbed:!1,onExportToCloud:le?()=>ge(!0):void 0,onRestartDemo:c,nodes:Ku??st.nodes,connectors:Of??st.connectors,selectedNodeIds:u,selectedConnectorIds:f,onSelectionChange:we,runtime:{runs:o,statuses:i,pendingOverrides:{nodes:Sr,connectors:bn}},onPlayNode:s,onNodePositionChange:he,onNodePositionsChange:Ie,onNodeResize:He,onHtmlNodeFitToContent:Ue,onMultiResize:Rt,onNodeNameChange:_o,onNodeDescriptionChange:On,onConnectorLabelChange:wn,onCreateShapeNode:Gt,onCreateImageFromFile:le?xi:void 0,onRetryImageUpload:le?ya:void 0,onCreateHtmlNode:le?pa:void 0,iconPickerOpen:Mr.open,onOpenIconPicker:le?wi:void 0,onCloseIconPicker:le?ma:void 0,onPickIcon:le?ga:void 0,onRequestIconReplace:le?Mi:void 0,onCreateConnector:Ro,onReconnectConnector:Hn,onPinEndpoint:le?xa:void 0,onUnpinEndpoint:le?Cr:void 0,onReorderNode:Ve,onDeleteNode:Wu,onCopyNode:F=>Mn([F]),onPasteAt:tn,onCopySelection:le?Mn:void 0,onPasteSelection:le?()=>tn(null):void 0,onToggleNodeLock:le?$u:void 0,hasClipboard:To,selectedNodes:Gu,selectedConnectors:YT,onStyleNode:Dn,onStyleNodePreview:Pt,onStyleNodes:en,onStyleNodesPreview:sr,onStyleConnector:Uu,onStyleConnectorPreview:Dt,onRfInit:q,onTidy:te?no:void 0,onCreateAndConnectFromPane:ka,pendingEditNodeId:y,activeShape:V,onSelectShape:j,statusReport:Ff,onNameChange:_o,onDescriptionChange:On,onDetailChange:Jr,onIconChange:un,autoFitView:!0,autoFitViewSignal:z}):m.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"No demo data yet."}),A?m.jsxs("div",{"data-testid":"edit-error-banner",className:"absolute inset-x-0 bottom-4 z-20 mx-auto w-fit max-w-[80%] rounded-md border border-rose-500/50 bg-rose-50 px-3 py-2 text-xs text-rose-900 shadow-md dark:bg-rose-950/60 dark:text-rose-100",children:[m.jsx("span",{className:"font-medium",children:"Couldn't save change: "}),m.jsx("span",{className:"font-mono",children:A}),m.jsx("button",{type:"button",className:"ml-3 underline underline-offset-2",onClick:()=>I(null),children:"Dismiss"})]}):null,m.jsx(xDe,{open:O,onOpenChange:U,runCommand:jo,ctx:{hasSelection:u.length>0||f.length>0,canUndo:qn,canRedo:xn,hasClipboard:To,canExportDemo:!!le,canResetSession:!!c}}),le?m.jsx(ODe,{open:ue,onOpenChange:ge,projectId:le,onCapturePreview:()=>{var F;return((F=b.current)==null?void 0:F.capturePreview())??Promise.resolve(void 0)}}):null]})}const Mte="npx seeflow register --path .";function fqe(){const[e,t]=g.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(Mte),t(!0),setTimeout(()=>t(!1),1200)}catch(r){console.error("[empty-state] copy failed",r)}};return m.jsx("div",{"data-testid":"seeflow-empty-state",className:"flex h-full w-full items-center justify-center bg-background p-6",children:m.jsxs("div",{className:"flex max-w-lg flex-col items-center gap-6 text-center",children:[m.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:m.jsx(o2,{className:"h-6 w-6 text-muted-foreground"})}),m.jsxs("div",{className:"space-y-2",children:[m.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"No demos registered yet"}),m.jsxs("p",{className:"text-sm text-muted-foreground",children:["Point SeeFlow at any folder containing a"," ",m.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:".seeflow/seeflow.json"})," ","file and it'll appear here."]})]}),m.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md border border-border bg-card px-3 py-2 font-mono text-sm",children:[m.jsx("span",{className:"text-muted-foreground select-none",children:"$"}),m.jsx("code",{className:"flex-1 truncate text-left",children:Mte}),m.jsx(Ft,{type:"button",variant:"ghost",size:"sm",onClick:n,"aria-label":"Copy register command",children:e?m.jsx(Ja,{className:"h-4 w-4"}):m.jsx(T1,{className:"h-4 w-4"})})]})]})})}function pqe({demos:e}){return e.length===0?m.jsx(fqe,{}):m.jsx("div",{className:"flex h-full w-full items-start justify-center overflow-y-auto bg-background p-8",children:m.jsxs("div",{"data-testid":"studio-home-picker",className:"flex w-full max-w-2xl flex-col gap-6 pt-8",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Open a demo"}),m.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.length," demos registered — pick one to load its canvas."]})]}),m.jsx("ul",{className:"flex flex-col gap-2",children:e.map(t=>m.jsx("li",{children:m.jsxs("button",{type:"button",onClick:()=>md(`/d/${t.slug}`),"data-testid":`studio-home-demo-${t.slug}`,className:"flex w-full flex-col items-start gap-0.5 rounded-lg border border-border bg-card px-4 py-3 text-left transition-colors hover:border-input",style:{boxShadow:"var(--shadow-card)"},children:[m.jsx("span",{className:"text-sm font-medium",children:t.name}),m.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t.repoPath})]})},t.id))})]})})}const yqe=e=>{if(!e.startsWith("/d/"))return null;const t=e.slice(3);return t.length>0?decodeURIComponent(t):null};function mqe(){const e=Jze(),{demos:t,refresh:n}=rDe(),r=yqe(e),o=r?(t??[]).find(C=>C.slug===r):void 0,a=(o==null?void 0:o.id)??null,{detail:i,loading:s,refresh:c}=nDe(a),{runs:l,apply:u}=lDe(a),{events:d,apply:f}=sDe(a),{statusByNode:p,apply:y,reset:k}=fDe(a),w=g.useCallback(()=>{k(),c(),n()},[c,n,k]),v=g.useCallback(C=>{u(C),f(C),y(C)},[u,f,y]);pDe(a,{onReload:w,onEvent:v});const M=g.useCallback(async()=>{if(a)try{await Efe(a)}catch(C){console.error("Failed to restart demo:",C)}},[a]),x=g.useCallback(C=>{ste(C.id),n()},[n]),b=g.useCallback(async C=>{await n(),a===C&&md("/")},[n,a]);g.useEffect(()=>{if(e!=="/"||t===null)return;const C=mDe(t,yDe());C&&md(`/d/${C.slug}`)},[e,t]),g.useEffect(()=>{o&&ste(o.id)},[o]);const S=g.useCallback(C=>{a&&Afe(a,C).catch(L=>{u({type:"node:error",nodeId:C,message:L instanceof Error?L.message:String(L),ts:Date.now()})})},[a,u]);return t===null?m.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):m.jsx(d2,{delayDuration:150,children:m.jsxs("div",{className:"flex h-full w-full flex-col bg-background text-foreground",children:[m.jsx(tDe,{demos:t,currentSlug:r??void 0,onProjectCreated:x,onProjectUnregistered:b}),m.jsx("main",{className:"min-h-0 flex-1",children:r?m.jsx(hqe,{slug:r,demos:t,detail:i,loading:s,runs:l,nodeEvents:d,statusByNode:p,onPlayNode:S,onRestartDemo:a?M:void 0}):m.jsx(pqe,{demos:t})})]})})}const Mde=document.getElementById("root");if(!Mde)throw new Error("Root element #root not found");MF.createRoot(Mde).render(m.jsx(ho.StrictMode,{children:m.jsx(mqe,{})}));export{PNe as _,Ba as c,gd as g,vqe as z};
|
|
7838
|
+
`)}async function xze(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await vze(e,t);if(n){const r=document.createElement("style"),o=document.createTextNode(n);r.appendChild(o),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function wze(e,t={}){const{width:n,height:r}=Y1e(e,t),o=await ZT(e,t,!0);return await xze(o,t),await rde(o,t),pze(o,t),await qNe(o,n,r)}async function Mze(e,t={}){const{width:n,height:r}=Y1e(e,t),o=await wze(e,t),a=await xR(o),i=document.createElement("canvas"),s=i.getContext("2d"),c=t.pixelRatio||NNe(),l=t.canvasWidth||n,u=t.canvasHeight||r;return i.width=l*c,i.height=u*c,t.skipAutoScale||zNe(i),i.style.width=`${l}`,i.style.height=`${u}`,t.backgroundColor&&(s.fillStyle=t.backgroundColor,s.fillRect(0,0,i.width,i.height)),s.drawImage(a,0,0,i.width,i.height),i}async function bze(e,t={}){return(await Mze(e,t)).toDataURL()}const Cze=e=>e instanceof Element?!(e.classList.contains("react-flow__minimap")||e.classList.contains("react-flow__controls")||e.classList.contains("react-flow__panel")):!0,Sze=async e=>{const t=await bze(e,{cacheBust:!0,filter:Cze}),n=await new Promise((r,o)=>{const a=new Image;a.onload=()=>r({width:a.naturalWidth,height:a.naturalHeight}),a.onerror=()=>o(new Error("Failed to decode captured image")),a.src=t});return{dataUrl:t,...n}},Lze=(e,t)=>{const n=document.createElement("a");n.href=e,n.download=t,n.rel="noopener",document.body.appendChild(n),n.click(),n.remove()},Ize=e=>{const t=e.replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"");return t.length>0?t.slice(0,80):"canvas"},Qee=(e,t)=>`${Ize(e??"canvas")}.${t}`,Eze=({projectId:e,getReactFlow:t})=>{const[n,r]=g.useState(null),o=g.useCallback(()=>r(null),[]),a=g.useCallback(async()=>{const l=t();if(!l)return null;const u=document.querySelector(".react-flow__viewport");if(!u)return null;const d=l.getViewport();try{return await l.fitView({duration:0,padding:.1}),await new Promise(f=>requestAnimationFrame(()=>f())),await Sze(u)}finally{l.setViewport(d,{duration:0})}},[t]),i=g.useCallback(async()=>{r(null);try{const l=await a();if(!l)return;Lze(l.dataUrl,Qee(e,"png"))}catch(l){r(l instanceof Error?l.message:String(l))}},[a,e]),s=g.useCallback(async()=>{r(null);try{const l=await a();if(!l)return;const{jsPDF:u}=await PNe(async()=>{const{jsPDF:p}=await import("./jspdf.es.min-Dkq0NSxE.js").then(y=>y.j);return{jsPDF:p}},[]),d=l.width>l.height?"landscape":"portrait",f=new u({orientation:d,unit:"px",format:[l.width,l.height],hotfixes:["px_scaling"]});f.addImage(l.dataUrl,"PNG",0,0,l.width,l.height),f.save(Qee(e,"pdf"))}catch(l){r(l instanceof Error?l.message:String(l))}},[a,e]),c=g.useCallback(async()=>{const l=await a();return l==null?void 0:l.dataUrl},[a]);return{exportPdf:s,exportPng:i,capturePreview:c,lastError:n,clearError:o}},Aze={showToolbar:!0,showStyleStrip:!0,showDetailPanel:!0,showStatusBadges:!0,showResizeHandles:!0,showControls:!0,showShareMenu:!0,showRestart:!0,enableKeyboard:!0,enableContextMenu:!0,enableDragDrop:!0,enableImageDrop:!0,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},Pze={showToolbar:!1,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!0,showResizeHandles:!1,showControls:!0,showShareMenu:!0,showRestart:!1,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!0,enablePan:!0,enableSelection:!0,enableNodeMove:!0,enableEmbed:!1},_ze={showToolbar:!1,showStyleStrip:!1,showDetailPanel:!1,showStatusBadges:!1,showResizeHandles:!1,showControls:!1,showShareMenu:!1,showRestart:!1,enableKeyboard:!1,enableContextMenu:!1,enableDragDrop:!1,enableImageDrop:!1,enableZoom:!1,enablePan:!1,enableSelection:!1,enableNodeMove:!1,enableEmbed:!1};function Rze(e){const t=e.mode==="edit"?Aze:e.mode==="mini"?_ze:Pze;return{showToolbar:e.showToolbar??t.showToolbar,showStyleStrip:e.showStyleStrip??t.showStyleStrip,showDetailPanel:e.showDetailPanel??t.showDetailPanel,showStatusBadges:e.showStatusBadges??t.showStatusBadges,showResizeHandles:e.showResizeHandles??t.showResizeHandles,showControls:e.showControls??t.showControls,showShareMenu:e.showShareMenu??t.showShareMenu,showRestart:e.showRestart??t.showRestart,enableKeyboard:e.enableKeyboard??t.enableKeyboard,enableContextMenu:e.enableContextMenu??t.enableContextMenu,enableDragDrop:e.enableDragDrop??t.enableDragDrop,enableImageDrop:e.enableImageDrop??t.enableImageDrop,enableZoom:e.enableZoom??t.enableZoom,enablePan:e.enablePan??t.enablePan,enableSelection:e.enableSelection??t.enableSelection,enableNodeMove:e.enableNodeMove??t.enableNodeMove,enableEmbed:e.enableEmbed??t.enableEmbed}}const Jee=40,ih={padding:.15,duration:300,includeHiddenNodes:!1};function Tze(e){return e===void 0||e===!1?{onMount:!1,onExternalNodeChange:!1}:e===!0?{onMount:!0,onExternalNodeChange:!0}:{onMount:e.onMount??!0,onExternalNodeChange:e.onExternalNodeChange??!0}}const ete=e=>{if("clientX"in e)return{clientX:e.clientX,clientY:e.clientY};const t=e.changedTouches[0]??e.touches[0];return t?{clientX:t.clientX,clientY:t.clientY}:null},jze=(e,t)=>{var r;const n=document.elementsFromPoint(e,t);for(const o of n){const a=(r=o.closest)==null?void 0:r.call(o,".react-flow__node");if(a)return a}return null},ade=15,xF=(e,t,n)=>{const r=jze(t,n);if(r)return r;if(!e)return null;let o=null,a=ade;const i=e.querySelectorAll(".react-flow__node");for(const s of i){const c=s.getBoundingClientRect();if(c.width===0||c.height===0)continue;const l=Math.max(c.left-t,0,t-c.right),u=Math.max(c.top-n,0,n-c.bottom),d=Math.hypot(l,u);d<=a&&(o=s,a=d)}return o};function tte(e,t,n,r,o){if(e==="source"?(r==null?void 0:r.targetPin)!==void 0||(r==null?void 0:r.targetHandleAutoPicked)===!1:(r==null?void 0:r.sourcePin)!==void 0||(r==null?void 0:r.sourceHandleAutoPicked)===!1)return;const i=e==="source"?n:t,s=e==="source"?t:n,c=o(i),l=o(s);if(!c||!l)return;const u=c.measured.width??c.width??0,d=c.measured.height??c.height??0,f=l.measured.width??l.width??0,p=l.measured.height??l.height??0;if(u===0||d===0||f===0||p===0)return;const y={x:c.internals.positionAbsolute.x,y:c.internals.positionAbsolute.y,w:u,h:d},k={x:l.internals.positionAbsolute.x+f/2,y:l.internals.positionAbsolute.y+p/2};return tMe(y,rR(y,k))}function Nze(e,t,n,r){if(r===null)return"no-op";const o=e==="source"?t:n;return r===(e==="source"?n:t)?"self-loop":r===o?"pin-own":"reconnect-and-pin"}const zze=(e,t)=>{if(!t)return e;const n=t.data?{...e.data,...t.data}:e.data;return{...e,...t,data:n}},Dze=(e,t)=>t?{...e,...t}:e,qze={playNode:dCe,stateNode:RCe,shapeNode:CCe,imageNode:tbe,iconNode:hMe,htmlNode:XMe},Oze={editableEdge:jCe},Fze={zIndex:0},Hze=8,nte=(e,t)=>e?typeof e=="string"?`url('#${e}')`:`url('#${`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`}')`:void 0,Bze=e=>function({fromX:n,fromY:r,toX:o,toY:a,fromPosition:i,toPosition:s,connectionLineStyle:c}){const l=Fe(W=>e.current?W.edges.find(q=>q.reconnectable===!0)??null:null),u=l==null?void 0:l.data,d=Fe(W=>{var R;const q=W.connection;return((R=q==null?void 0:q.fromHandle)==null?void 0:R.nodeId)??null}),f=Fe(W=>l!=null&&l.source?W.nodeLookup.get(l.source)??null:null),p=Fe(W=>l!=null&&l.target?W.nodeLookup.get(l.target)??null:null),y=Fe(W=>d?W.nodeLookup.get(d)??null:null),k=(l==null?void 0:l.source)===d,w=l?k?f:p:y,v=k?p:f,M=k?u==null?void 0:u.sourcePin:u==null?void 0:u.targetPin,x=k?u==null?void 0:u.sourceHandleAutoPicked:u==null?void 0:u.targetHandleAutoPicked;let b=n,S=r,C=i;if(w){const W=w.measured.width??w.width??0,q=w.measured.height??w.height??0;if(W>0&&q>0){const R={x:w.internals.positionAbsolute.x,y:w.internals.positionAbsolute.y,w:W,h:q};let G=null;if(M)G=oR(R,M);else if(x!==!1&&v){const X=v.measured.width??v.width??0,Y=v.measured.height??v.height??0;if(X>0&&Y>0){const oe={x:v.internals.positionAbsolute.x+X/2,y:v.internals.positionAbsolute.y+Y/2};G=rR(R,oe)}}G&&(b=G.x,S=G.y,C=rte[G.side])}}const L=Fe(W=>W.transform[2]),P=Fe(W=>W.nodeLookup),T=Fe(W=>{var q;return((q=W.connection.toHandle)==null?void 0:q.nodeId)??null});let _=o,A=a,I=s;if(L>0){const W=ade/L,q=l?k?l.target:l.source:null;let R=null;if(T&&T!==q){const G=P.get(T)??null;G&&(R=G)}if(!R){let G=W;for(const X of P.values()){if(q&&X.id===q||w&&X.id===w.id)continue;const Y=X.measured.width??X.width??0,oe=X.measured.height??X.height??0;if(Y===0||oe===0)continue;const ee=X.internals.positionAbsolute.x,ae=X.internals.positionAbsolute.y,ve=Math.max(ee-o,0,o-(ee+Y)),Se=Math.max(ae-a,0,a-(ae+oe)),be=Math.hypot(ve,Se);be<=G&&(G=be,R=X)}}if(!R&&l&&w){const G=w.measured.width??w.width??0,X=w.measured.height??w.height??0;if(G>0&&X>0){const Y=w.internals.positionAbsolute.x,oe=w.internals.positionAbsolute.y,ee=Math.max(Y-o,0,o-(Y+G)),ae=Math.max(oe-a,0,a-(oe+X));Math.hypot(ee,ae)<=W&&(R=w)}}if(R){const G=R.measured.width??R.width??0,X=R.measured.height??R.height??0;if(G>0&&X>0){const Y=DH({x:R.internals.positionAbsolute.x,y:R.internals.positionAbsolute.y,w:G,h:X},{x:o,y:a}),oe=oR({x:R.internals.positionAbsolute.x,y:R.internals.positionAbsolute.y,w:G,h:X},Y);_=oe.x,A=oe.y,I=rte[oe.side]}}}const V=(u==null?void 0:u.path)==="step",[j]=V?H2({sourceX:b,sourceY:S,sourcePosition:C,targetX:_,targetY:A,targetPosition:I,borderRadius:Hze}):uT({sourceX:b,sourceY:S,sourcePosition:C,targetX:_,targetY:A,targetPosition:I}),H=(l==null?void 0:l.style)??c??void 0,O=Fe(W=>W.rfId),U=k?l==null?void 0:l.markerStart:l==null?void 0:l.markerEnd,z=k?l==null?void 0:l.markerEnd:l==null?void 0:l.markerStart,N=nte(U,O),E=nte(z,O);return m.jsx("path",{d:j,fill:"none",className:"react-flow__connection-path",style:H,markerStart:N,markerEnd:E})},rte={top:me.Top,right:me.Right,bottom:me.Bottom,left:me.Left};function Vze({storeApiRef:e}){const t=vt();return g.useEffect(()=>(e.current=t,()=>{e.current===t&&(e.current=null)}),[t,e]),null}function $ze({wrapperRef:e}){const t=Fe(r=>r.transform[2]),n=e.current;return n&&n.style.setProperty("--rf-zoom",String(t)),null}const Uze=new Set(["INPUT","TEXTAREA","SELECT"]),ide=e=>e?Uze.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1;function Wze(e){const{event:t,selectedNodeIds:n,hasClipboard:r,activeElement:o,onCopySelection:a,onPasteSelection:i}=e;if(!(t.metaKey||t.ctrlKey)||t.shiftKey||t.altKey)return!1;const s=t.key.toLowerCase();return s!=="c"&&s!=="v"||ide(o)?!1:s==="c"?n.length===0||!a?!1:(t.preventDefault(),a([...n]),!0):!r||!i?!1:(t.preventDefault(),i(),!0)}const ote=(e,t)=>{var n;return((n=e==null?void 0:e[t])==null?void 0:n.status)??"idle"},Gze=(e,t)=>{var n;return(n=e==null?void 0:e[t])==null?void 0:n.status},Kze=(e,t)=>{var n,r;return((n=e==null?void 0:e[t])==null?void 0:n.status)==="error"?(r=e[t])==null?void 0:r.error:void 0};function Zze(e,t){var mU,gU;const{mode:n,adapter:r,projectId:o,nodes:a,connectors:i,selectedNodeIds:s,selectedConnectorIds:c,onSelectionChange:l,runtime:u,onPlayNode:d,onNodePositionChange:f,onNodePositionsChange:p,onNodeResize:y,onHtmlNodeFitToContent:k,onMultiResize:w,onNodeNameChange:v,onNodeDescriptionChange:M,onConnectorLabelChange:x,onCreateShapeNode:b,onCreateImageFromFile:S,onRetryImageUpload:C,onCreateHtmlNode:L,onCreateConnector:P,onReconnectConnector:T,onReorderNode:_,onDeleteNode:A,onCopyNode:I,onPasteAt:V,hasClipboard:j,onCopySelection:H,onPasteSelection:O,selectedNodes:U,selectedConnectors:z,onStyleNode:N,onStyleNodePreview:E,onStyleNodes:W,onStyleNodesPreview:q,onStyleConnector:R,onStyleConnectorPreview:G,onRfInit:X,onTidy:Y,onNodeClick:oe,onConnectorClick:ee,onPaneClick:ae,onCreateAndConnectFromPane:ve,pendingEditNodeId:Se,iconPickerOpen:be,onOpenIconPicker:we,onCloseIconPicker:te,onPickIcon:ie,onRequestIconReplace:Te,onPinEndpoint:Ae,onUnpinEndpoint:at,onToggleNodeLock:Qe,activeShape:le,onSelectShape:Q,disableSidebar:ue,statusReport:ge,onNameChange:Me,onDescriptionChange:qe,onDetailChange:re,onIconChange:he,autoFitView:Ie,autoFitViewSignal:He,customIcons:Ue,onExportToCloud:Rt,onRestartDemo:Oe,showToolbar:je,showStyleStrip:Pt,showDetailPanel:sr,showStatusBadges:Dt,showResizeHandles:Dn,showControls:en,showShareMenu:$u,showRestart:Uu,enableKeyboard:da,enableContextMenu:ha,enableDragDrop:Xr,enableImageDrop:gi,enableZoom:fa,enablePan:xr,enableSelection:Yr,enableNodeMove:wr,enableEmbed:Wu}=e,Ve=g.useMemo(()=>Rze({mode:n,showToolbar:je,showStyleStrip:Pt,showDetailPanel:sr,showStatusBadges:Dt,showResizeHandles:Dn,showControls:en,showShareMenu:$u,showRestart:Uu,enableKeyboard:da,enableContextMenu:ha,enableDragDrop:Xr,enableImageDrop:gi,enableZoom:fa,enablePan:xr,enableSelection:Yr,enableNodeMove:wr,enableEmbed:Wu}),[n,je,Pt,sr,Dt,Dn,en,$u,Uu,da,ha,Xr,gi,fa,xr,Yr,wr,Wu]),yt=n==="edit",Qr=g.useRef(Ve);g.useEffect(()=>{Qr.current=Ve},[Ve]);const Po=Ie??(n==="mini"?!0:void 0),qn=g.useMemo(()=>Tze(Po),[Po]),xn=u==null?void 0:u.runs,_o=u==null?void 0:u.statuses,On=(mU=u==null?void 0:u.pendingOverrides)==null?void 0:mU.nodes,Jr=(gU=u==null?void 0:u.pendingOverrides)==null?void 0:gU.connectors,un=g.useRef(null),Gt=g.useRef(null),eo=g.useRef(!1),pa=g.useRef(!1),to=g.useRef(!1),ki=g.useRef(qn);ki.current=qn,g.useEffect(()=>{if(eo.current||!qn.onMount||a.length===0)return;const K=Gt.current;K&&(K.fitView(ih),eo.current=!0)},[a,qn.onMount]);const vi=g.useRef(null),mt=le,xi=Q,ya=g.useRef(new Map),Mr=g.useCallback((K,J)=>(ya.current.set(K,J),()=>{ya.current.get(K)===J&&ya.current.delete(K)}),[]),[br,cr]=g.useState(!1),ma=g.useRef(!1);g.useEffect(()=>{ma.current=br},[br]);const wi=g.useRef(!1),Mi=g.useRef(!1),ga=g.useRef(!1),[wn,Ro]=g.useState(null),ka=g.useRef(null);g.useEffect(()=>{ka.current=wn},[wn]),g.useCallback(()=>{Ro(null)},[]);const va=g.useMemo(()=>Bze(ga),[]),To=g.useRef(null),bi=g.useRef(null),Mn=g.useCallback(K=>{const J=un.current;if(!J){To.current=K;return}const se=To.current;if(se&&se!==K){const de=J.querySelector(`.react-flow__node[data-id="${CSS.escape(se)}"]`);de==null||de.removeAttribute("data-connect-source")}if(K){const de=J.querySelector(`.react-flow__node[data-id="${CSS.escape(K)}"]`);de==null||de.setAttribute("data-connect-source","true")}To.current=K},[]),tn=g.useCallback(K=>{const J=un.current,se=bi.current;if(se!==K){if(J&&se){const de=J.querySelector(`.react-flow__node[data-id="${CSS.escape(se)}"]`);de==null||de.removeAttribute("data-connect-target")}if(J&&K){const de=J.querySelector(`.react-flow__node[data-id="${CSS.escape(K)}"]`);de==null||de.setAttribute("data-connect-target","true")}bi.current=K}},[]),Fn=g.useCallback(()=>{Mn(null),tn(null)},[Mn,tn]);g.useEffect(()=>{if(!br){tn(null);return}const K=J=>{const se=xF(un.current,J.clientX,J.clientY),de=(se==null?void 0:se.getAttribute("data-id"))??null;if(de&&de===To.current){tn(null);return}tn(de)};return document.addEventListener("pointermove",K),()=>{document.removeEventListener("pointermove",K)}},[br,tn]);const[no,jo]=g.useState(null),[Hn,xa]=g.useState(null),Cr=g.useRef(null),st=g.useRef(null),Sr=g.useRef(null),bn=g.useRef(!1);g.useEffect(()=>{Cr.current=mt},[mt]);const Cn=g.useCallback(()=>{xi(null),jo(null),xa(null),Cr.current=null,st.current=null,Sr.current=null,bn.current=!1},[xi]);g.useEffect(()=>{if(!Ve.enableKeyboard)return;const K=J=>{var ye,ze;if(J.key!=="Escape"||ide(document.activeElement))return;if(Cr.current){J.preventDefault(),Cn();return}if(ma.current){J.preventDefault(),wi.current=!0,Mi.current=!0;try{(ye=vi.current)==null||ye.getState().cancelConnection()}catch{}document.dispatchEvent(new MouseEvent("mouseup",{bubbles:!0,cancelable:!0,button:0})),cr(!1);return}if(ka.current){J.preventDefault(),Ro(null);return}const se=Ir.current.size>0,de=zo.current.size>0;(se||de)&&(J.preventDefault(),(ze=oo.current)==null||ze.call(oo,[],[]))};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[Cn,Ve.enableKeyboard]),g.useEffect(()=>{if(!Ve.enableKeyboard)return;const K=J=>{Wze({event:J,selectedNodeIds:s,hasClipboard:!!j,activeElement:document.activeElement,onCopySelection:H,onPasteSelection:O})};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[s,j,H,O,Ve.enableKeyboard]);const Ci=g.useCallback(K=>{var de,ye;if(!Cr.current)return;const J=K.target;if(!(J!=null&&J.classList.contains("react-flow__pane")))return;const se={x:K.clientX,y:K.clientY};bn.current=!0,st.current=se,Sr.current=se,jo(se),xa(se);try{(ye=(de=K.currentTarget).setPointerCapture)==null||ye.call(de,K.pointerId)}catch{}K.preventDefault(),K.stopPropagation()},[]),Gu=g.useCallback(K=>{if(!bn.current)return;const J={x:K.clientX,y:K.clientY};Sr.current=J,xa(J)},[]),YT=g.useCallback(K=>{var Sa,kU;if(!bn.current)return;bn.current=!1;try{(kU=(Sa=K.currentTarget).releasePointerCapture)==null||kU.call(Sa,K.pointerId)}catch{}const J=st.current,se=Sr.current,de=Cr.current,ye=Gt.current;if(Cn(),!J||!se||!de||!ye)return;const ze=Math.min(J.x,se.x),xe=Math.min(J.y,se.y),Ee=Math.max(J.x,se.x),Je=Math.max(J.y,se.y),ht=Ee-ze,qt=Je-xe,Re=ye.screenToFlowPosition({x:ze,y:xe}),rt=ye.screenToFlowPosition({x:Ee,y:Je}),Ze=rt.x-Re.x,Ei=rt.y-Re.y,Ca=ht<Jee||qt<Jee,Do=Ca?uR[de].width:Ze,Zf=Ca?uR[de].height:Ei;b==null||b(de,Re,{width:Do,height:Zf})},[Cn,b]),ro=g.useRef(!1),Ku=g.useRef(!1),Of=g.useRef(new Map),No=g.useCallback(()=>{var K;pa.current&&(Ku.current||ro.current||(pa.current=!1,(K=Gt.current)==null||K.fitView(ih)))},[]),Ff=g.useCallback(K=>{Ku.current=K,K||No()},[No]);g.useEffect(()=>{var K;if(!to.current){to.current=!0;return}if(ki.current.onExternalNodeChange){if(Ku.current||ro.current){pa.current=!0;return}(K=Gt.current)==null||K.fitView(ih)}},[He]);const Hd=!!_||!!A||!!I||!!V||!!at,[dn,F]=g.useState(null),[B,Z]=g.useState(!1),[$,D]=g.useState(null),[ne,Pe]=g.useState(null),ke=g.useRef(null),dt=g.useRef(null);g.useEffect(()=>{if(!dn)return;const K=dt.current;if(!K)return;const J=new MouseEvent("contextmenu",{clientX:dn.x,clientY:dn.y,bubbles:!0,cancelable:!0,button:2,buttons:2});K.dispatchEvent(J)},[dn]);const Tt=g.useCallback(K=>{const J=ke.current;!J||!_||_(J,K)},[_]),Sn=g.useCallback(()=>{const K=ke.current;!K||!A||A(K)},[A]),Kt=g.useCallback(()=>{const K=ke.current;!K||!I||I(K)},[I]),Lr=g.useCallback(()=>{const K=ke.current;!K||!Te||Te(K)},[Te]),wa=g.useCallback(()=>{if(!Qe)return;const K=ke.current,J=K?[K]:[...s];J.length!==0&&Qe(J)},[Qe,s]);g.useCallback((K,J,se,de,ye)=>{Qr.current.enableContextMenu&&(ke.current=null,Z(!1),D(null),Pe({connectorId:K,kind:J,pinned:se}),F({x:de,y:ye}))},[]);const Zu=g.useCallback(()=>{const K=ne;!K||!at||at(K.connectorId,K.kind)},[ne,at]),_e=g.useCallback(()=>{if(!V)return;const K=dn,J=Gt.current;if(!K||!J)return;const se=J.screenToFlowPosition({x:K.x,y:K.y});V(se)},[dn,V]),nt=typeof navigator<"u"&&/Mac|iPhone|iPad|iPod/.test(navigator.platform||navigator.userAgent||""),Ne=nt?"⌘C":"Ctrl+C",it=nt?"⌘V":"Ctrl+V",jt=g.useMemo(()=>new Set(s),[s]),Bn=g.useMemo(()=>{const K=new Set;for(const J of a)J.data.locked===!0&&K.add(J.id);return K},[a]),Vn=g.useMemo(()=>new Set(c),[c]),QT=g.useMemo(()=>{if(s.length<2)return[];const K=On,J=[];for(const se of s){const de=a.find(Ee=>Ee.id===se);if(!de)continue;const ye=K==null?void 0:K[se],ze=(ye==null?void 0:ye.data)??{},xe=de.data;J.push({id:se,position:(ye==null?void 0:ye.position)??de.position,data:{width:ze.width??xe.width,height:ze.height??xe.height,locked:ze.locked??xe.locked}})}return J},[a,On,s]),JT=U??[],Si=g.useMemo(()=>{const K=ye=>{const ze=yt?void 0:Of.current.get(ye.id),xe={id:ye.id,type:ye.type,position:ze??ye.position,data:{...ye.data,projectId:o,onRetryUpload:C,status:Gze(xn,ye.id),errorMessage:Kze(xn,ye.id),statusReport:_o==null?void 0:_o[ye.id],onPlay:d,onResize:y,setResizing:Ff,onFitToContent:ye.type==="htmlNode"?k:void 0,onNameChange:(()=>{if(yt&&!(ye.type==="shapeNode"&&ye.data.shape==="ellipse"))return v})(),onDescriptionChange:(()=>{if(yt){if(ye.type==="shapeNode"){const Ee=ye.data.shape;return Ee==="rectangle"||Ee==="ellipse"||Ee==="sticky"?M:void 0}if(!(ye.type==="imageNode"||ye.type==="iconNode"))return M}})(),onIconChange:(()=>{if(yt&&!(ye.type!=="playNode"&&ye.type!=="stateNode"))return he})(),autoEditOnMount:Se===ye.id?!0:void 0},selected:jt.has(ye.id)};return ye.data.width!==void 0&&(xe.width=ye.data.width),ye.data.height!==void 0&&(xe.height=ye.data.height),jt.has(ye.id)||(xe.connectable=!1),ye.data.locked===!0&&(xe.draggable=!1),xe},J=a.map(ye=>K(zze(ye,On==null?void 0:On[ye.id]))),se=new Set(a.map(ye=>ye.id)),de=[];if(On)for(const[ye,ze]of Object.entries(On)){if(se.has(ye))continue;const xe=ze;typeof xe.type!="string"||!xe.position||!xe.data||de.push(K({...xe,id:ye}))}return[...J,...de]},[o,a,jt,xn,_o,d,y,k,Ff,On,v,M,he,C,Se,yt]),[ej,tj]=g.useState(Si);g.useEffect(()=>{ro.current||Ku.current||tj(Si)},[Si]),g.useEffect(()=>{Bd.current=ej},[ej]);const Ir=g.useRef(jt);g.useEffect(()=>{Ir.current=jt},[jt]);const oo=g.useRef(l);g.useEffect(()=>{oo.current=l},[l]);const zo=g.useRef(Vn);g.useEffect(()=>{zo.current=Vn},[Vn]);const Bd=g.useRef(Si),Li=g.useRef(!1),Hf=g.useRef(new Set),Bf=g.useRef(new Set),nj=g.useRef(new Set),rj=g.useRef(new Set),Ma=g.useRef(null),bde=g.useCallback(K=>{var rt;const J=Li.current?nj.current:(rt=Ma.current)!=null&&rt.shift?Ma.current.nodeIds:null,se=J&&J.size>0?K.filter(Ze=>Ze.type!=="select"?!0:!(Ze.selected===!1&&J.has(Ze.id))):K,de=new Set;for(const Ze of se)Ze.type==="select"&&de.add(Ze.id);const ye=Mie(se,Bd.current),ze=Ir.current,xe=Li.current||ze.size===0?ye:ye.map(Ze=>ze.has(Ze.id)&&!de.has(Ze.id)&&!Ze.selected?{...Ze,selected:!0}:Ze);if(Bd.current=xe,tj(xe),de.size===0)return;if(Li.current){for(const Ze of se)Ze.type==="select"&&(Ze.selected?Hf.current.add(Ze.id):Hf.current.delete(Ze.id));return}const Ee=oo.current;if(!Ee)return;const Je=xe.filter(Ze=>Ze.selected).map(Ze=>Ze.id),ht=Ir.current;ht.size===Je.length&&Je.every(Ze=>ht.has(Ze))||(Ir.current=new Set(Je),Ee(Je,[...zo.current]))},[]),Vf=g.useRef([]),Cde=g.useCallback(K=>{var qt;const J=Li.current?rj.current:(qt=Ma.current)!=null&&qt.shift?Ma.current.edgeIds:null,se=J&&J.size>0?K.filter(Re=>Re.type!=="select"?!0:!(Re.selected===!1&&J.has(Re.id))):K,de=new Set;for(const Re of se)Re.type==="select"&&de.add(Re.id);if(de.size===0)return;if(Li.current){for(const Re of se)Re.type==="select"&&(Re.selected?Bf.current.add(Re.id):Bf.current.delete(Re.id));return}const ye=oo.current;if(!ye)return;const xe=bie(se,Vf.current).filter(Re=>Re.selected).map(Re=>Re.id),Ee=zo.current;Ee.size===xe.length&&xe.every(Re=>Ee.has(Re))||(zo.current=new Set(xe),ye([...Ir.current],xe))},[]),Sde=g.useCallback(K=>{Li.current=!0;const J=Ma.current,se=(J==null?void 0:J.shift)??(K.shiftKey||K.metaKey||K.ctrlKey);nj.current=se?new Set((J==null?void 0:J.nodeIds)??Ir.current):new Set,rj.current=se?new Set((J==null?void 0:J.edgeIds)??zo.current):new Set,Hf.current=new Set(nj.current),Bf.current=new Set(rj.current)},[]),Lde=g.useCallback(()=>{Li.current=!1,Ma.current=null;const K=oo.current;if(!K)return;const J=[...Hf.current],se=new Set(J),de=new Set(Bf.current);for(const Je of Vf.current)se.has(Je.source)&&se.has(Je.target)&&de.add(Je.id);const ye=Ir.current,ze=zo.current,xe=ye.size===se.size&&J.every(Je=>ye.has(Je)),Ee=ze.size===de.size&&[...de].every(Je=>ze.has(Je));xe&&Ee||(Ir.current=new Set(J),zo.current=new Set(de),K(J,[...de]))},[]),Ide=g.useCallback(K=>{if(Ma.current=null,Cr.current||K.button!==0)return;const J=K.target;J!=null&&J.classList.contains("react-flow__pane")&&(Ma.current={shift:K.shiftKey||K.metaKey||K.ctrlKey,nodeIds:new Set(Ir.current),edgeIds:new Set(zo.current)})},[]),Ede=g.useCallback(K=>{if(!Qr.current.enableContextMenu||Ir.current.size<2)return;const se=K.target;se!==dt.current&&(se!=null&&se.closest(".seeflow-connector-endpoint-dot")||(K.preventDefault(),K.stopPropagation(),ke.current=null,Z(!0),D(null),Pe(null),F({x:K.clientX,y:K.clientY})))},[]),Ade=g.useCallback(K=>{const J=K.dataTransfer;if(!J)return;const se=J.types?Array.from(J.types):[],de=se.includes("Files"),ye=se.includes(zJ),ze=de&&!!S&&Ve.enableImageDrop,xe=ye&&!!L&&Ve.enableDragDrop;if(!(!ze&&!xe)){K.preventDefault();try{J.dropEffect="copy"}catch{}}},[S,L,Ve.enableImageDrop,Ve.enableDragDrop]),Pde=g.useCallback(K=>{const J=K.dataTransfer;if((J!=null&&J.types?Array.from(J.types):[]).includes(zJ)&&L&&Ve.enableDragDrop){K.preventDefault();const ze=Gt.current;if(!ze)return;const xe=ze.screenToFlowPosition({x:K.clientX,y:K.clientY});L({position:xe});return}if(!S||!Ve.enableImageDrop)return;const ye={x:K.clientX,y:K.clientY};K.preventDefault(),Vke({dataTransfer:J,clientPos:ye,rfInstance:Gt.current,computeDims:$ke,dispatch:S})},[S,L,Ve.enableImageDrop,Ve.enableDragDrop]),sU=!!T,cU=Vn.size===1?[...Vn][0]:null,oj=g.useMemo(()=>{const K=Ee=>{const Je=ote(xn,Ee.source)==="running"||ote(xn,Ee.target)==="running",ht=Vn.has(Ee.id),qt=X8e(Ee,Je,ht);ht&&(qt.selected=!0);const Re=sU&&Ee.id===cU,rt=Re?{...qt,reconnectable:!0}:qt;return{...rt,data:{...rt.data,onLabelChange:yt?x:void 0,reconnectable:Re,registerEditHandle:Mr}}},J=new Set(i.map(Ee=>Ee.id)),se=i.map(Ee=>K(Dze(Ee,Jr==null?void 0:Jr[Ee.id]))),de=[];if(Jr)for(const[Ee,Je]of Object.entries(Jr)){if(J.has(Ee))continue;const ht=Je;typeof ht.source!="string"||typeof ht.target!="string"||typeof ht.kind!="string"||de.push(K({...ht,id:Ee}))}const ye=[...se,...de],ze=[],xe=[];for(const Ee of ye)Vn.has(Ee.id)?xe.push(Ee):ze.push(Ee);return[...ze,...xe]},[i,xn,Vn,cU,Jr,x,sU,Mr,yt]);g.useEffect(()=>{Vf.current=oj},[oj]);const _de=g.useCallback(()=>{const K=Gt.current,J=Bd.current;if(J.length<2)return;const se=J.map(Re=>{var Do;const rt=(Do=K==null?void 0:K.getInternalNode(Re.id))==null?void 0:Do.measured,Ze=Re.data,Ei=(rt==null?void 0:rt.width)??Ze.width??200,Ca=(rt==null?void 0:rt.height)??Ze.height??120;return{id:Re.id,width:Ei,height:Ca,position:Re.position}}),de=Vf.current.map(Re=>({source:Re.source,target:Re.target})),ye=eae(se,de);let ze=Number.POSITIVE_INFINITY,xe=Number.POSITIVE_INFINITY,Ee=Number.POSITIVE_INFINITY,Je=Number.POSITIVE_INFINITY;for(const Re of se){Re.position.x<ze&&(ze=Re.position.x),Re.position.y<xe&&(xe=Re.position.y);const rt=ye.get(Re.id);rt&&(rt.x<Ee&&(Ee=rt.x),rt.y<Je&&(Je=rt.y))}const ht=Number.isFinite(ze)&&Number.isFinite(Ee)?ze-Ee:0,qt=Number.isFinite(xe)&&Number.isFinite(Je)?xe-Je:0;tj(Re=>Re.map(rt=>{const Ze=ye.get(rt.id);return Ze?{...rt,position:{x:Ze.x+ht,y:Ze.y+qt}}:rt}))},[]),$f=Y??(yt?void 0:_de),Uf=g.useRef(!1),lU=g.useRef(null),Rde=g.useCallback(K=>{var Ee;if(!yt||!P)return;const{source:J,target:se}=K;if(!J||!se||J===se)return;Uf.current=!0;const de=((Ee=lU.current)==null?void 0:Ee.nodeId)??null,ye=de!==null&&de===se&&de!==J;P(ye?se:J,ye?J:se)},[P,yt]),aj=g.useCallback(K=>{const J=se=>{if(!se)return!1;const de=Bd.current.find(ye=>ye.id===se);return de?de.type==="shapeNode"&&de.data.shape==="text":!1};return!J(K.source)&&!J(K.target)},[]),Tde=g.useCallback((K,J)=>{var qt;cr(!1),Fn();const se=Uf.current;if(Uf.current=!1,se||ga.current)return;if(wi.current){wi.current=!1;return}if(!P)return;const de=(qt=J.fromNode)==null?void 0:qt.id,ye=J.fromHandle;if(!de||!ye)return;const ze=ete(K);if(!ze)return;const xe=xF(un.current,ze.clientX,ze.clientY);if(!xe)return;const Ee=xe.getAttribute("data-id");if(!Ee||Ee===de||!aj({source:de,target:Ee,sourceHandle:null,targetHandle:null}))return;let Je;const ht=Gt.current;if(ht){const Re=ht.getInternalNode(Ee);if(Re){const rt=Re.measured.width??Re.width??0,Ze=Re.measured.height??Re.height??0;if(rt>0&&Ze>0){const Ei=ht.screenToFlowPosition({x:ze.clientX,y:ze.clientY});Je=DH({x:Re.internals.positionAbsolute.x,y:Re.internals.positionAbsolute.y,w:rt,h:Ze},Ei)}}}P(de,Ee,Je?{targetPin:Je}:void 0)},[P,Fn,aj]),Wf=g.useRef(!1),jde=g.useCallback((K,J)=>{if(!T)return;const{source:se,target:de,sourceHandle:ye,targetHandle:ze}=J;if(!se||!de||se===de)return;const xe={};if(se!==K.source&&(xe.source=se),de!==K.target&&(xe.target=de),typeof ye=="string"&&ye!==K.sourceHandle&&(xe.sourceHandle=ye),typeof ze=="string"&&ze!==K.targetHandle&&(xe.targetHandle=ze),xe.source===void 0&&xe.target===void 0&&xe.sourceHandle===void 0&&xe.targetHandle===void 0)return;(xe.source!==void 0||xe.sourceHandle!==void 0)&&(xe.sourceHandleAutoPicked=!1),(xe.target!==void 0||xe.targetHandle!==void 0)&&(xe.targetHandleAutoPicked=!1);const Ee=Gt.current;if(!(xe.source===void 0&&xe.target===void 0)&&Ee){const ht=xe.source!==void 0?"source":"target",qt=tte(ht,K.source,K.target,K.data,Re=>Ee.getInternalNode(Re)??null);qt&&(ht==="source"?xe.targetPin=qt:xe.sourcePin=qt)}Wf.current=!0,T(K.id,xe)},[T]),Nde=g.useCallback((K,J,se,de)=>{var Zf;cr(!1),Fn(),ga.current=!1;const ye=Wf.current;if(Wf.current=!1,ye)return;if(Mi.current){Mi.current=!1;return}if(!T)return;const ze=ete(K);let xe=((Zf=de.toNode)==null?void 0:Zf.id)??null;if(!xe&&ze){const Sa=xF(un.current,ze.clientX,ze.clientY);xe=(Sa==null?void 0:Sa.getAttribute("data-id"))??null}const Ee=se==="source"?"target":"source",Je=Nze(Ee,J.source,J.target,xe);if(Je==="no-op"||Je==="self-loop"||!ze)return;const ht=Gt.current;if(!ht)return;const qt=Je==="pin-own"?Ee==="source"?J.source:J.target:xe,Re=ht.getInternalNode(qt);if(!Re)return;const rt=Re.measured.width??Re.width??0,Ze=Re.measured.height??Re.height??0;if(rt===0||Ze===0)return;const Ei=ht.screenToFlowPosition({x:ze.clientX,y:ze.clientY}),Ca=DH({x:Re.internals.positionAbsolute.x,y:Re.internals.positionAbsolute.y,w:rt,h:Ze},Ei);if(Je==="pin-own"){if(!Ae)return;Ae(J.id,Ee,Ca);return}const Do=tte(Ee,J.source,J.target,J.data,Sa=>ht.getInternalNode(Sa)??null);Ee==="source"?T(J.id,{source:xe,sourceHandle:null,sourceHandleAutoPicked:!1,sourcePin:Ca,...Do?{targetPin:Do}:{}}):T(J.id,{target:xe,targetHandle:null,targetHandleAutoPicked:!1,targetPin:Ca,...Do?{sourcePin:Do}:{}})},[T,Fn,Ae]),Ii=g.useMemo(()=>{var Ee;if(!no||!Hn)return null;const K=(Ee=un.current)==null?void 0:Ee.getBoundingClientRect(),J=(K==null?void 0:K.left)??0,se=(K==null?void 0:K.top)??0,de=Math.min(no.x,Hn.x),ye=Math.min(no.y,Hn.y),ze=Math.abs(Hn.x-no.x),xe=Math.abs(Hn.y-no.y);return{left:de-J,top:ye-se,width:ze,height:xe}},[no,Hn]),zde=mt?nce(mt):"",Dde=mt?rce(mt):void 0,qde=mt==="text",[uU,dU]=g.useState(!1),[Ode,Gf]=g.useState(!1),[Fde,hU]=g.useState(!1),ba=Eze({projectId:o,getReactFlow:()=>Gt.current});g.useImperativeHandle(t,()=>({exportPdf:ba.exportPdf,exportPng:ba.exportPng,openEmbedDialog:()=>hU(!0),capturePreview:ba.capturePreview}),[ba.exportPdf,ba.exportPng,ba.capturePreview]),g.useEffect(()=>{if(!Ve.enableKeyboard)return;const K=de=>{if(!de)return!1;const ye=de.tagName;return ye==="INPUT"||ye==="TEXTAREA"||ye==="SELECT"?!0:de instanceof HTMLElement&&de.isContentEditable},J=de=>{de.code==="Space"&&(K(document.activeElement)||(de.preventDefault(),dU(!0)))},se=de=>{de.code==="Space"&&(dU(!1),Gf(!1))};return window.addEventListener("keydown",J),window.addEventListener("keyup",se),()=>{window.removeEventListener("keydown",J),window.removeEventListener("keyup",se)}},[Ve.enableKeyboard]);const Kf=g.useCallback(K=>{if(K.length!==0){if(!yt){const J=Of.current;for(const se of K)J.set(se.id,{x:se.position.x,y:se.position.y});return}if(K.length===1){const J=K[0];J&&f&&f(J.id,{x:J.position.x,y:J.position.y});return}if(p){p(K.map(J=>({id:J.id,position:{x:J.position.x,y:J.position.y}})));return}if(f)for(const J of K)f(J.id,{x:J.position.x,y:J.position.y})}},[f,p,yt]),Hde=g.useCallback((K,J,se)=>{ro.current=!1,Kf(se),No()},[Kf,No]),Bde=g.useCallback(()=>{ro.current=!0},[]),Vde=g.useCallback((K,J)=>{ro.current=!1,Kf(J),No()},[Kf,No]),$de=g.useCallback((K,J)=>{oe==null||oe(J.id)},[oe]),Ude=g.useCallback(K=>{ae==null||ae()},[ae]),Wde=g.useCallback((K,J)=>{ee==null||ee(J.id)},[ee]),fU=mt?"crosshair":uU?Ode?"grabbing":"grab":void 0,pU=s[0],yU=c[0],Gde=pU?a.find(K=>K.id===pU)??null:null,Kde=yU?i.find(K=>K.id===yU)??null:null,Zde=o??null,Xde=Ve.showDetailPanel&&!ue,Yde=g.useMemo(()=>({custom:Ue??{}}),[Ue]);return m.jsx(VMe,{value:Yde,children:m.jsx("div",{"data-testid":"seeflow-canvas","data-mode":n,ref:un,className:"seeflow-canvas-root sf:relative sf:h-full sf:w-full",style:fU?{cursor:fU}:void 0,onPointerDownCapture:Ide,onPointerDown:K=>{uU&&Gf(!0),Ci(K)},onPointerMove:Gu,onPointerUp:K=>{Gf(!1),YT(K)},onPointerCancel:()=>{bn.current=!1,st.current=null,Sr.current=null,jo(null),xa(null),Gf(!1)},onContextMenuCapture:Ede,onDragOver:Ade,onDrop:Pde,children:m.jsxs($9e,{containerRef:un,children:[m.jsxs(h8e,{nodes:ej,edges:oj,onNodesChange:bde,nodeTypes:qze,edgeTypes:Oze,proOptions:{hideAttribution:!0},fitView:!0,minZoom:n==="mini"?.05:.5,nodesDraggable:(yt?!!f:!0)&&!mt&&Ve.enableNodeMove,nodesConnectable:yt&&!!P&&!mt,deleteKeyCode:yt?["Backspace","Delete"]:null,zoomOnScroll:Ve.enableZoom,zoomOnPinch:Ve.enableZoom,className:br?"seeflow-connecting":void 0,onConnect:yt?Rde:void 0,isValidConnection:aj,onConnectStart:(K,J)=>{cr(!0),Uf.current=!1,lU.current={nodeId:J.nodeId??null,handleType:J.handleType??null},Mn(J.nodeId??null)},onConnectEnd:Tde,onReconnect:yt&&T?jde:void 0,onReconnectStart:(K,J,se)=>{cr(!0),Wf.current=!1,ga.current=!0;const de=se==="source"?J.source:J.target;Mn(de)},onReconnectEnd:Nde,connectionLineComponent:va,connectionLineStyle:{strokeWidth:2},connectionRadius:32,reconnectRadius:10,edgesReconnectable:!1,elevateNodesOnSelect:!1,elementsSelectable:!mt&&Ve.enableSelection,selectNodesOnDrag:!1,nodeClickDistance:5,selectionOnDrag:!mt&&Ve.enableSelection,panOnDrag:mt?!1:Ve.enablePan?[1,2]:!1,selectionMode:rd.Partial,selectionKeyCode:null,multiSelectionKeyCode:mt?null:["Meta","Shift"],panActivationKeyCode:mt?null:"Space",onSelectionStart:Sde,onSelectionEnd:Lde,defaultEdgeOptions:Fze,zoomOnDoubleClick:!1,onInit:K=>{Gt.current=K;const J=un.current;J&&J.style.setProperty("--rf-zoom",String(K.getZoom())),!eo.current&&qn.onMount&&a.length>0&&(K.fitView(ih),eo.current=!0),X==null||X(K)},onMove:(K,J)=>{ka.current&&Ro(null);const se=un.current;se&&se.style.setProperty("--rf-zoom",String(J.zoom))},onEdgesChange:Cde,onNodeDragStart:()=>{ro.current=!0},onNodeDragStop:Hde,onSelectionDragStart:Bde,onSelectionDragStop:Vde,onNodeClick:$de,onEdgeClick:Wde,onEdgeDoubleClick:(K,J)=>{var se;(se=ya.current.get(J.id))==null||se()},onPaneClick:Ude,onNodeContextMenu:Ve.enableContextMenu&&Hd?(K,J)=>{K.preventDefault(),ke.current=J.id,Z(!0),D(J.type??null),Pe(null),F({x:K.clientX,y:K.clientY})}:void 0,onPaneContextMenu:Ve.enableContextMenu&&V?K=>{K.preventDefault(),ke.current=null,Z(!1),D(null),Pe(null),F({x:K.clientX,y:K.clientY})}:void 0,children:[m.jsx(Vze,{storeApiRef:vi}),m.jsx($ze,{wrapperRef:un}),m.jsx(M8e,{gap:12,size:.6}),Ve.showControls?m.jsxs(A8e,{showInteractive:!1,showFitView:!1,children:[m.jsx(S1,{"data-testid":"controls-fit-view","aria-label":"Fit view",title:"Fit view",disabled:a.length===0,onClick:()=>{var K;(K=Gt.current)==null||K.fitView(ih)},children:m.jsx(j1,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})}),m.jsx(S1,{"data-testid":"controls-tidy","aria-label":"Tidy layout (⌘⇧L)",title:"Tidy layout (⌘⇧L)",disabled:!$f,onClick:()=>$f==null?void 0:$f(),children:m.jsx(Uh,{className:"sf:h-3 sf:w-3","aria-hidden":"true"})})]}):null,Ve.showResizeHandles?m.jsx(CNe,{selectedNodes:QT,onMultiResize:w}):null,Ve.showToolbar&&b||Ve.showStyleStrip&&N&&R?m.jsx(cd,{position:"top-left",children:m.jsxs("div",{className:"sf:flex sf:flex-col sf:gap-2",children:[Ve.showToolbar&&b?m.jsx(rEe,{activeShape:mt,onSelectShape:xi,iconPickerOpen:be??!1,onOpenIconPicker:we,onCloseIconPicker:te,onPickIcon:ie}):null,Ve.showStyleStrip&&N&&R?m.jsx(LNe,{nodes:JT,connectors:z??[],onStyleNode:N,onStyleNodePreview:E,onStyleNodes:W,onStyleNodesPreview:q,onStyleConnector:R,onStyleConnectorPreview:G,onRequestIconReplace:Te}):null]})}):null,Ve.showShareMenu||Ve.showRestart&&Oe?m.jsx(cd,{position:"top-right",children:m.jsxs("div",{className:"sf:flex sf:items-center sf:gap-1",children:[Ve.showRestart&&Oe?m.jsx(xNe,{onRestartDemo:Oe}):null,Ve.showShareMenu?m.jsx(vNe,{mode:n==="mini"?"view":n,projectId:o,enableEmbed:Ve.enableEmbed,onDownloadPdf:ba.exportPdf,onDownloadPng:ba.exportPng,onExportToCloud:Rt,embedOpen:Fde,onEmbedOpenChange:hU}):null]})}):null]}),Ii?m.jsx("div",{"data-testid":"canvas-draw-ghost","data-ghost-shape":mt??void 0,"aria-hidden":!0,className:ce("sf:pointer-events-none sf:absolute sf:z-10",zde,qde?"sf:rounded-sm sf:border sf:border-dashed sf:border-muted-foreground/40":""),style:{...Dde,left:Ii.left,top:Ii.top,width:Ii.width,height:Ii.height},children:(()=>{const K=mt?v$[mt]:void 0;return K?m.jsx(K,{width:Ii.width,height:Ii.height,borderColor:ct(void 0,"node").borderColor,backgroundColor:ef,borderSize:o$}):null})()}):null,Ve.enableContextMenu&&Hd?m.jsxs(ILe,{onOpenChange:K=>{K||(F(null),ke.current=null,D(null),Pe(null))},children:[m.jsx(ELe,{asChild:!0,children:m.jsx("div",{ref:dt,"data-testid":"node-context-menu-trigger","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(dn==null?void 0:dn.x)??0,top:(dn==null?void 0:dn.y)??0,width:0,height:0}})}),m.jsxs(Dle,{"data-testid":"node-context-menu",children:[ne!=null&&ne.pinned&&at?m.jsx(_r,{"data-testid":"connector-endpoint-context-menu-unpin",onSelect:Zu,children:"Unpin"}):null,B&&I?m.jsxs(_r,{"data-testid":"node-context-menu-copy",onSelect:Kt,children:["Copy",m.jsx(XH,{children:Ne})]}):null,V?m.jsxs(_r,{"data-testid":"node-context-menu-paste",disabled:!j,onSelect:_e,children:["Paste",m.jsx(XH,{children:it})]}):null,B&&(I||V)&&($==="iconNode"&&Te||_||A)?m.jsx(Mh,{}):null,B&&$==="iconNode"&&Te?m.jsx(_r,{"data-testid":"node-context-menu-change-icon",onSelect:Lr,children:"Change icon"}):null,B&&$==="iconNode"&&Te&&(_||A)?m.jsx(Mh,{}):null,B&&_?m.jsxs(m.Fragment,{children:[m.jsx(_r,{"data-testid":"node-context-menu-to-front",onSelect:()=>Tt({op:"toFront"}),children:"Bring to front"}),m.jsx(_r,{"data-testid":"node-context-menu-forward",onSelect:()=>Tt({op:"forward"}),children:"Bring forward"}),m.jsx(_r,{"data-testid":"node-context-menu-backward",onSelect:()=>Tt({op:"backward"}),children:"Send backward"}),m.jsx(_r,{"data-testid":"node-context-menu-to-back",onSelect:()=>Tt({op:"toBack"}),children:"Send to back"})]}):null,B&&_&&(Qe||A)?m.jsx(Mh,{}):null,B&&Qe?(()=>{const K=ke.current,J=K?[K]:s,se=J.length>0&&J.every(de=>Bn.has(de))?"Unlock":"Lock";return m.jsx(_r,{"data-testid":"node-context-menu-toggle-lock",onSelect:wa,disabled:J.length===0,children:se})})():null,B&&Qe&&A?m.jsx(Mh,{}):null,B&&A?m.jsx(_r,{"data-testid":"node-context-menu-delete",onSelect:Sn,disabled:ke.current?Bn.has(ke.current):!1,children:"Delete"}):null]})]}):null,ve?m.jsxs(Nd,{open:!!wn,onOpenChange:K=>{K||Ro(null)},children:[m.jsx(U9e,{asChild:!0,children:m.jsx("div",{"data-testid":"drop-popover-anchor","aria-hidden":!0,className:"sf:pointer-events-none sf:fixed",style:{left:(wn==null?void 0:wn.clientX)??0,top:(wn==null?void 0:wn.clientY)??0,width:0,height:0}})}),m.jsx(Fu,{"data-testid":"drop-popover",align:"start",side:"bottom",sideOffset:4,className:"sf:w-auto sf:p-1",onOpenAutoFocus:K=>{K.preventDefault()},children:m.jsx("div",{role:"menu","aria-label":"Create connected node",className:"sf:flex sf:flex-col sf:gap-0.5",children:nEe.map(({shape:K,label:J,Icon:se})=>m.jsxs("button",{type:"button",role:"menuitem","data-testid":`drop-popover-shape-${K}`,onClick:()=>{const de=wn;de&&(ve({sourceNodeId:de.sourceNodeId,position:{x:de.flowX,y:de.flowY},shape:K}),Ro(null))},className:ce("sf:flex sf:items-center sf:gap-2 sf:rounded-sm sf:px-2 sf:py-1.5 sf:text-left sf:text-sm","sf:hover:bg-accent sf:hover:text-accent-foreground","sf:focus:bg-accent sf:focus:text-accent-foreground sf:focus:outline-hidden"),children:[m.jsx(se,{className:"sf:h-4 sf:w-4 sf:text-muted-foreground","aria-hidden":"true"}),m.jsx("span",{children:J})]},K))})})]}):null,Xde?m.jsx(Xje,{flowId:Zde,node:Gde,connector:Kde,adapter:r??null,statusReport:ge,onNameChange:Me,onDescriptionChange:qe,onDetailChange:re,onIconChange:he,onClose:()=>{var K;(K=oo.current)==null||K.call(oo,[],[])}}):null]})})})}const Xze=g.forwardRef(Zze);function Yze({open:e,onOpenChange:t,onCreated:n}){const[r,o]=g.useState(""),[a,i]=g.useState(null),[s,c]=g.useState(!1);g.useEffect(()=>{e&&(o(""),i(null),c(!1))},[e]);const l=r.trim(),u=l.length>0&&!s,d=async f=>{if(f.preventDefault(),!!u){c(!0),i(null);try{const p=await Ife({name:l});n(p),t(!1)}catch(p){i(p instanceof Error?p.message:String(p)),c(!1)}}};return m.jsx(RT,{open:e,onOpenChange:t,children:m.jsxs(Sf,{className:"sm:max-w-md","data-testid":"create-project-dialog",onOpenAutoFocus:f=>{f.preventDefault();const p=document.querySelector('[data-testid="create-project-name-input"]');p==null||p.focus()},children:[m.jsxs(Lf,{children:[m.jsx(If,{children:"Create new project"}),m.jsxs(Ef,{children:["The project will be created at ",m.jsx("code",{children:"~/.seeflow/<slug>"}),"."]})]}),m.jsxs("form",{onSubmit:d,className:"flex flex-col gap-4",children:[m.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[m.jsx("span",{className:"font-medium",children:"Project name"}),m.jsx("input",{type:"text",required:!0,autoComplete:"off",spellCheck:!1,value:r,onChange:f=>o(f.target.value),"data-testid":"create-project-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"})]}),a?m.jsx("div",{role:"alert","data-testid":"create-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:a}):null,m.jsxs(fd,{children:[m.jsx(Ft,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:s,children:"Cancel"}),m.jsx(Ft,{type:"submit",disabled:!u,"data-testid":"create-project-submit",children:s?"Creating…":"Create project"})]})]})]})})}const gB="seeflow:navigate",Qze=e=>(window.addEventListener("popstate",e),window.addEventListener(gB,e),()=>{window.removeEventListener("popstate",e),window.removeEventListener(gB,e)}),ate=()=>window.location.pathname,Jze=()=>g.useSyncExternalStore(Qze,ate,ate),md=e=>{e!==window.location.pathname&&(window.history.pushState({},"",e),window.dispatchEvent(new Event(gB)))};function eDe({demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:r}){const[o,a]=g.useState(!1),[i,s]=g.useState(!1),[c,l]=g.useState(null),[u,d]=g.useState(!1),[f,p]=g.useState(null);g.useEffect(()=>{const x=b=>{b.key==="k"&&(b.metaKey||b.ctrlKey)&&(b.preventDefault(),a(S=>!S))};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[]);const y=e.find(x=>x.slug===t),k=x=>{n==null||n(x),md(`/d/${x.slug}`)},w=x=>{l(x),p(null)},v=()=>{u||(l(null),p(null))},M=async()=>{if(c){d(!0),p(null);try{await Lfe(c.id);const x=c.id;l(null),r==null||r(x)}catch(x){p(x instanceof Error?x.message:String(x))}finally{d(!1)}}};return m.jsxs(m.Fragment,{children:[m.jsxs(Nd,{open:o,onOpenChange:a,children:[m.jsx(kf,{asChild:!0,children:m.jsxs(Ft,{type:"button",variant:"outline",size:"sm","aria-label":"Switch demo","aria-expanded":o,className:"gap-2","data-testid":"project-switcher-trigger",children:[m.jsx("span",{className:"max-w-[180px] truncate text-sm",children:(y==null?void 0:y.name)??"Select demo"}),m.jsx(jce,{children:"⌘K"}),m.jsx(zh,{className:"h-3.5 w-3.5 opacity-60"})]})}),m.jsx(Fu,{align:"end",sideOffset:6,className:"w-[320px] p-0","data-testid":"project-switcher-popover",children:m.jsxs(Ace,{children:[m.jsx(Pce,{placeholder:"Search demos..."}),m.jsxs(_ce,{children:[m.jsx(Rce,{children:"No demos."}),e.length>0?m.jsx(WH,{heading:"Demos",children:e.map(x=>m.jsxs(GH,{value:`${x.name} ${x.slug}`,onSelect:()=>{a(!1),md(`/d/${x.slug}`)},className:"group flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[m.jsx("span",{className:"font-medium",children:x.name}),m.jsx("span",{className:"w-full truncate text-xs text-muted-foreground",children:x.repoPath})]}),m.jsx("button",{type:"button","aria-label":`Unregister ${x.name}`,className:"shrink-0 rounded p-0.5 opacity-0 transition-opacity hover:text-destructive group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring",onClick:b=>{b.stopPropagation(),a(!1),w(x)},children:m.jsx(a2,{className:"h-3.5 w-3.5"})})]},x.id))}):null,e.length>0?m.jsx(Tce,{}):null,m.jsx(WH,{children:m.jsxs(GH,{value:"+ create new project",onSelect:()=>{a(!1),s(!0)},"data-testid":"project-switcher-create",className:"flex items-center gap-2 text-sm",children:[m.jsx(Yh,{className:"h-4 w-4 opacity-70"}),m.jsx("span",{className:"font-medium",children:"Create new project"})]})})]})]})})]}),m.jsx(Yze,{open:i,onOpenChange:s,onCreated:k}),m.jsx(RT,{open:c!==null,onOpenChange:x=>{x||v()},children:m.jsxs(Sf,{className:"sm:max-w-md","data-testid":"unregister-project-dialog",children:[m.jsxs(Lf,{children:[m.jsx(If,{children:"Unregister project?"}),m.jsxs(Ef,{children:["This removes ",m.jsx("strong",{children:c==null?void 0:c.name})," from SeeFlow. Your files at"," ",m.jsx("code",{className:"text-xs",children:c==null?void 0:c.repoPath})," will not be deleted."]})]}),f?m.jsx("div",{role:"alert","data-testid":"unregister-project-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:f}):null,m.jsxs(fd,{children:[m.jsx(Ft,{type:"button",variant:"ghost",onClick:v,disabled:u,children:"Cancel"}),m.jsx(Ft,{type:"button",variant:"destructive",onClick:M,disabled:u,"data-testid":"unregister-project-confirm",children:u?"Unregistering…":"Unregister"})]})]})})]})}function tDe({demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:r}){return m.jsxs("header",{className:"flex h-12 shrink-0 items-center justify-between border-b border-border bg-background px-4",children:[m.jsxs("button",{type:"button",onClick:()=>md("/"),style:{display:"flex",alignItems:"center",gap:6,fontWeight:700,fontSize:16,letterSpacing:"-0.02em",background:"none",border:"none",cursor:"pointer",padding:0},children:[m.jsx(c2,{size:20,strokeWidth:2,className:"text-emerald-400"}),"SeeFlow"]}),m.jsx("div",{className:"flex items-center gap-3",children:m.jsx(eDe,{demos:e,currentSlug:t,onProjectCreated:n,onProjectUnregistered:r})})]})}const nDe=e=>{const[t,n]=g.useState(null),[r,o]=g.useState(e!==null),[a,i]=g.useState(null),s=g.useCallback(()=>{e&&(o(!0),Nre(e).then(c=>{n(c),i(null)}).catch(c=>{console.error("[useDemoData] failed",c),i(String(c))}).finally(()=>o(!1)))},[e]);return g.useEffect(()=>{if(!e){n(null),o(!1);return}s()},[e,s]),{detail:t,loading:r,error:a,refresh:s}},rDe=()=>{const[e,t]=g.useState(null),[n,r]=g.useState(null),o=g.useCallback(()=>Sfe().then(a=>{t(a),r(null)}).catch(a=>{console.error("[useDemos] failed",a),t([]),r(String(a))}),[]);return g.useEffect(()=>{o()},[o]),{demos:e,error:n,refresh:o}},oDe=5,aDe={"node:running":"running","node:done":"done","node:error":"error"},iDe=(e,t)=>{if(t.type==="reset")return{};const n=e[t.nodeId]??[],r=[t.entry,...n].slice(0,oDe);return{...e,[t.nodeId]:r}},sDe=e=>{const[t,n]=g.useReducer(iDe,{}),r=g.useRef(n);r.current=n,g.useEffect(()=>{r.current({type:"reset"})},[e]);const o=g.useCallback(i=>{const s=aDe[i.type];if(!s)return;const c=typeof i.nodeId=="string"?i.nodeId:null;if(!c)return;const l=typeof i.runId=="string"?i.runId:void 0,u=typeof i.ts=="number"?i.ts:Date.now();r.current({type:"append",nodeId:c,entry:{status:s,ts:u,runId:l}})},[]),a=g.useCallback(()=>{r.current({type:"reset"})},[]);return{events:t,apply:o,reset:a}},cDe=(e,t)=>{var n,r;switch(t.type){case"reset":return{};case"running":return{...e,[t.nodeId]:{status:"running",runId:t.runId,ts:t.ts??Date.now()}};case"done":return{...e,[t.nodeId]:{...e[t.nodeId],status:"done",runId:t.runId??((n=e[t.nodeId])==null?void 0:n.runId),responseStatus:t.responseStatus,body:t.body,ts:t.ts??Date.now()}};case"error":return{...e,[t.nodeId]:{...e[t.nodeId],status:"error",runId:t.runId??((r=e[t.nodeId])==null?void 0:r.runId),error:t.message,ts:t.ts??Date.now()}}}},lDe=e=>{const[t,n]=g.useReducer(cDe,{}),r=g.useRef(n);r.current=n,g.useEffect(()=>{r.current({type:"reset"})},[e]);const o=g.useCallback(i=>{const s=typeof i.nodeId=="string"?i.nodeId:null;if(!s)return;const c=typeof i.runId=="string"?i.runId:void 0;if(i.type==="node:running"){r.current({type:"running",nodeId:s,runId:c,ts:i.ts});return}if(i.type==="node:done"){const l=typeof i.status=="number"?i.status:void 0;r.current({type:"done",nodeId:s,runId:c,responseStatus:l,body:i.body,ts:i.ts});return}if(i.type==="node:error"){const l=typeof i.message=="string"?i.message:void 0;r.current({type:"error",nodeId:s,runId:c,message:l,ts:i.ts})}},[]),a=g.useCallback(()=>{r.current({type:"reset"})},[]);return{runs:t,apply:o,reset:a}},uDe=new Set(["ok","warn","error","pending"]),dDe=(e,t)=>{if(t.type!=="node:status")return e;const n=typeof t.nodeId=="string"?t.nodeId:null;if(!n||typeof t.state!="string"||!uDe.has(t.state))return e;const r=typeof t.summary=="string"?t.summary:void 0,o=typeof t.detail=="string"?t.detail:void 0,a=t.data&&typeof t.data=="object"&&!Array.isArray(t.data)?t.data:void 0,i=typeof t.ts=="number"?t.ts:Date.now();return{...e,[n]:{state:t.state,summary:r,detail:o,data:a,ts:i}}},hDe=(e,t)=>{switch(t.type){case"reset":return{};case"event":return dDe(e,t.event)}},fDe=e=>{const[t,n]=g.useReducer(hDe,{}),r=g.useRef(n);r.current=n,g.useEffect(()=>{r.current({type:"reset"})},[e]);const o=g.useCallback(i=>{r.current({type:"event",event:i})},[]),a=g.useCallback(()=>{r.current({type:"reset"})},[]);return{statusByNode:t,apply:o,reset:a}},pDe=(e,t={})=>{const[n,r]=g.useState(null),[o,a]=g.useState(!1),{onReload:i,onEvent:s}=t;return g.useEffect(()=>{if(!e){r(null),a(!1);return}const c=`/api/events?flowId=${encodeURIComponent(e)}`,l=new EventSource(c);l.addEventListener("open",()=>a(!0)),l.addEventListener("error",()=>a(!1)),l.addEventListener("hello",()=>{i==null||i()}),l.addEventListener("flow:reload",u=>{const d=ite(u,"flow:reload");r(d),s==null||s(d),i==null||i()});for(const u of["node:running","node:done","node:error","node:status"])l.addEventListener(u,d=>{s==null||s(ite(d,u))});return()=>{l.close()}},[e,i,s]),{lastReload:n,connected:o}},ite=(e,t)=>{try{const n=JSON.parse(e.data);return{type:t,ts:Date.now(),...n}}catch{return{type:t,ts:Date.now()}}},sde="seeflow:last-project",yDe=()=>{if(typeof window>"u")return null;try{return window.localStorage.getItem(sde)}catch{return null}},ste=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(sde,e)}catch{}},mDe=(e,t)=>{if(e.length===0)return null;if(e.length===1)return e[0]??null;if(t){const n=e.find(r=>r.id===t);if(n)return n}return null},cte=["File","Edit","View","Tools","Layout","Selection","Help"],cde="seeflow:command-palette:recent",lde=5,ude=new Map(n$.map(e=>[e.id,e])),gDe=e=>typeof e=="string"&&ude.has(e),lte=()=>{if(typeof window>"u")return[];try{const e=window.localStorage.getItem(cde);if(!e)return[];const t=JSON.parse(e);return Array.isArray(t)?t.filter(gDe).slice(0,lde):[]}catch{return[]}},kDe=e=>{if(!(typeof window>"u"))try{window.localStorage.setItem(cde,JSON.stringify(e))}catch{}},ute=(e,t)=>e.enabled?e.enabled(t):!0,vDe=(e,t)=>t.length===0?!0:`${e.label} ${e.description??""}`.toLowerCase().includes(t);function xDe({open:e,onOpenChange:t,runCommand:n,ctx:r}){const[o,a]=g.useState(""),[i,s]=g.useState(0),[c,l]=g.useState(()=>lte()),u=g.useRef(null),d=g.useRef(null);g.useEffect(()=>{e&&(a(""),s(0),l(lte()))},[e]);const{groups:f,flat:p}=g.useMemo(()=>{const b=o.trim().toLowerCase();if(b.length===0){if(c.length===0)return{groups:[],flat:[]};const T=[];for(const A of c){const I=ude.get(A);I&&T.push({cmd:I,enabled:ute(I,r)})}return{groups:[{category:"Recent",rows:T}],flat:T}}const S=new Map;for(const T of n$){if(!vDe(T,b))continue;const _={cmd:T,enabled:ute(T,r)},A=S.get(T.category);A?A.push(_):S.set(T.category,[_])}const L=[...cte.filter(T=>S.has(T)),...Array.from(S.keys()).filter(T=>!cte.includes(T))].map(T=>({category:T,rows:S.get(T)??[]})),P=L.flatMap(T=>T.rows);return{groups:L,flat:P}},[o,r,c]);g.useEffect(()=>{if(p.length===0){s(0);return}s(b=>{var C;let S=b;if(S>=p.length&&(S=0),!((C=p[S])!=null&&C.enabled)){const L=p.findIndex(P=>P.enabled);L!==-1&&(S=L)}return S})},[p]);const y=g.useCallback(b=>{p.length!==0&&s(S=>{var L;let C=S;for(let P=0;P<p.length;P++)if(C=(C+b+p.length)%p.length,(L=p[C])!=null&&L.enabled)return C;return S})},[p]),k=g.useCallback(b=>{l(S=>{const C=[b,...S.filter(L=>L!==b)].slice(0,lde);return kDe(C),C})},[]),w=g.useCallback(b=>{const S=p[b];!S||!S.enabled||(k(S.cmd.id),n(S.cmd.id),t(!1))},[p,t,k,n]),v=g.useCallback(b=>{if(b.key==="ArrowDown"){b.preventDefault(),y(1);return}if(b.key==="ArrowUp"){b.preventDefault(),y(-1);return}b.key==="Enter"&&(b.preventDefault(),w(i))},[w,i,y]);g.useEffect(()=>{if(!e)return;const b=d.current;if(!b)return;const S=b.querySelector(`[data-command-row-index="${i}"]`);S&&typeof S.scrollIntoView=="function"&&S.scrollIntoView({block:"nearest"})},[i,e]);const x=o.trim().length>0;return m.jsx(IT,{open:e,onOpenChange:t,children:m.jsx(ET,{children:m.jsxs(zd,{className:ce("fixed left-0 right-0 top-[20%] z-50 mx-auto w-[480px] max-w-[90vw] border border-border bg-card shadow-lg duration-200","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","sm:rounded-lg"),"data-testid":"command-palette",onOpenAutoFocus:b=>{var S;b.preventDefault(),(S=u.current)==null||S.focus()},children:[m.jsx("div",{className:ce("border-b",p.length===0&&!x&&"border-b-0"),children:m.jsx("input",{ref:u,type:"text",value:o,onChange:b=>a(b.target.value),onKeyDown:v,placeholder:"Type a command…","data-testid":"command-palette-input","aria-label":"Search commands",autoComplete:"off",spellCheck:!1,className:"w-full bg-transparent px-4 py-3 text-sm outline-hidden placeholder:text-muted-foreground"})}),m.jsx("div",{ref:d,"data-testid":"command-palette-list","data-empty":p.length===0?"true":"false",className:ce("max-h-[50vh] overflow-y-auto",p.length>0?"py-1":"","seeflow-no-scrollbar"),children:p.length===0?x?m.jsxs("div",{"data-testid":"command-palette-empty",className:"px-4 py-6 text-center text-sm text-muted-foreground",children:['No commands match "',o,'"']}):null:(()=>{let b=-1;return f.map(S=>m.jsxs("div",{className:"py-1",children:[m.jsx("div",{className:"px-3 pb-1 pt-2 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:S.category}),S.rows.map(C=>{b+=1;const L=b,P=L===i;return m.jsxs("button",{type:"button","data-testid":`command-palette-row-${C.cmd.id}`,"data-command-row-index":L,"data-highlighted":P?"true":"false","aria-disabled":C.enabled?void 0:!0,disabled:!C.enabled,onMouseEnter:()=>{C.enabled&&s(L)},onClick:()=>w(L),className:ce("flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-sm outline-hidden",C.enabled?"cursor-pointer text-foreground hover:bg-muted":"cursor-not-allowed text-muted-foreground/50",P&&C.enabled?"bg-muted":""),children:[m.jsxs("div",{className:"flex min-w-0 flex-col",children:[m.jsx("span",{className:"truncate font-medium",children:C.cmd.label}),C.cmd.description?m.jsx("span",{className:"truncate text-xs text-muted-foreground",children:C.cmd.description}):null]}),C.cmd.shortcut?m.jsx("kbd",{"data-testid":`command-palette-shortcut-${C.cmd.id}`,className:"shrink-0 rounded border bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:C.cmd.shortcut}):null]},C.cmd.id)})]},S.category))})()})]})})})}var cn=Uint8Array,Qn=Uint16Array,oU=Int32Array,aU=new cn([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),iU=new cn([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),dte=new cn([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dde=function(e,t){for(var n=new Qn(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var o=new oU(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)o[a]=a-n[r]<<5|r;return{b:n,r:o}},hde=dde(aU,2),wDe=hde.b,kB=hde.r;wDe[28]=258,kB[258]=28;var MDe=dde(iU,0),hte=MDe.r,vB=new Qn(32768);for(var Mt=0;Mt<32768;++Mt){var Ta=(Mt&43690)>>1|(Mt&21845)<<1;Ta=(Ta&52428)>>2|(Ta&13107)<<2,Ta=(Ta&61680)>>4|(Ta&3855)<<4,vB[Mt]=((Ta&65280)>>8|(Ta&255)<<8)>>1}var y2=function(e,t,n){for(var r=e.length,o=0,a=new Qn(t);o<r;++o)e[o]&&++a[e[o]-1];var i=new Qn(t);for(o=1;o<t;++o)i[o]=i[o-1]+a[o-1]<<1;var s;if(n){s=new Qn(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var l=o<<4|e[o],u=t-e[o],d=i[e[o]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[vB[d]>>c]=l}else for(s=new Qn(r),o=0;o<r;++o)e[o]&&(s[o]=vB[i[e[o]-1]++]>>15-e[o]);return s},_u=new cn(288);for(var Mt=0;Mt<144;++Mt)_u[Mt]=8;for(var Mt=144;Mt<256;++Mt)_u[Mt]=9;for(var Mt=256;Mt<280;++Mt)_u[Mt]=7;for(var Mt=280;Mt<288;++Mt)_u[Mt]=8;var wR=new cn(32);for(var Mt=0;Mt<32;++Mt)wR[Mt]=5;var bDe=y2(_u,9,0),CDe=y2(wR,5,0),fde=function(e){return(e+7)/8|0},pde=function(e,t,n){return(n==null||n>e.length)&&(n=e.length),new cn(e.subarray(t,n))},SDe=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],XT=function(e,t,n){var r=new Error(t||SDe[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,XT),!n)throw r;return r},Bo=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},sh=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},wF=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,a=n.slice();if(!o)return{t:mde,l:0};if(o==1){var i=new cn(n[0].s+1);return i[n[0].s]=1,{t:i,l:1}}n.sort(function(S,C){return S.f-C.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=o-1;)s=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,r=1;r<o;++r)a[r].s>f&&(f=a[r].s);var p=new Qn(f+1),y=xB(n[u-1],p,0);if(y>t){var r=0,k=0,w=y-t,v=1<<w;for(a.sort(function(C,L){return p[L.s]-p[C.s]||C.f-L.f});r<o;++r){var M=a[r].s;if(p[M]>t)k+=v-(1<<y-p[M]),p[M]=t;else break}for(k>>=w;k>0;){var x=a[r].s;p[x]<t?k-=1<<t-p[x]++-1:++r}for(;r>=0&&k;--r){var b=a[r].s;p[b]==t&&(--p[b],++k)}y=t}return{t:new cn(p),l:y}},xB=function(e,t,n){return e.s==-1?Math.max(xB(e.l,t,n+1),xB(e.r,t,n+1)):t[e.s]=n},fte=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Qn(++t),r=0,o=e[0],a=1,i=function(c){n[r++]=c},s=1;s<=t;++s)if(e[s]==o&&s!=t)++a;else{if(!o&&a>2){for(;a>138;a-=138)i(32754);a>2&&(i(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(i(o),--a;a>6;a-=6)i(8304);a>2&&(i(a-3<<5|8208),a=0)}for(;a--;)i(o);a=1,o=e[s]}return{c:n.subarray(0,r),n:t}},ch=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},yde=function(e,t,n){var r=n.length,o=fde(t+2);e[o]=r&255,e[o+1]=r>>8,e[o+2]=e[o]^255,e[o+3]=e[o+1]^255;for(var a=0;a<r;++a)e[o+a+4]=n[a];return(o+4+r)*8},pte=function(e,t,n,r,o,a,i,s,c,l,u){Bo(t,u++,n),++o[256];for(var d=wF(o,15),f=d.t,p=d.l,y=wF(a,15),k=y.t,w=y.l,v=fte(f),M=v.c,x=v.n,b=fte(k),S=b.c,C=b.n,L=new Qn(19),P=0;P<M.length;++P)++L[M[P]&31];for(var P=0;P<S.length;++P)++L[S[P]&31];for(var T=wF(L,7),_=T.t,A=T.l,I=19;I>4&&!_[dte[I-1]];--I);var V=l+5<<3,j=ch(o,_u)+ch(a,wR)+i,H=ch(o,f)+ch(a,k)+i+14+3*I+ch(L,_)+2*L[16]+3*L[17]+7*L[18];if(c>=0&&V<=j&&V<=H)return yde(t,u,e.subarray(c,c+l));var O,U,z,N;if(Bo(t,u,1+(H<j)),u+=2,H<j){O=y2(f,p,0),U=f,z=y2(k,w,0),N=k;var E=y2(_,A,0);Bo(t,u,x-257),Bo(t,u+5,C-1),Bo(t,u+10,I-4),u+=14;for(var P=0;P<I;++P)Bo(t,u+3*P,_[dte[P]]);u+=3*I;for(var W=[M,S],q=0;q<2;++q)for(var R=W[q],P=0;P<R.length;++P){var G=R[P]&31;Bo(t,u,E[G]),u+=_[G],G>15&&(Bo(t,u,R[P]>>5&127),u+=R[P]>>12)}}else O=bDe,U=_u,z=CDe,N=wR;for(var P=0;P<s;++P){var X=r[P];if(X>255){var G=X>>18&31;sh(t,u,O[G+257]),u+=U[G+257],G>7&&(Bo(t,u,X>>23&31),u+=aU[G]);var Y=X&31;sh(t,u,z[Y]),u+=N[Y],Y>3&&(sh(t,u,X>>5&8191),u+=iU[Y])}else sh(t,u,O[X]),u+=U[X]}return sh(t,u,O[256]),u+U[256]},LDe=new oU([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),mde=new cn(0),IDe=function(e,t,n,r,o,a){var i=a.z||e.length,s=new cn(r+i+5*(1+Math.ceil(i/7e3))+o),c=s.subarray(r,s.length-o),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var d=LDe[t-1],f=d>>13,p=d&8191,y=(1<<n)-1,k=a.p||new Qn(32768),w=a.h||new Qn(y+1),v=Math.ceil(n/3),M=2*v,x=function(te){return(e[te]^e[te+1]<<v^e[te+2]<<M)&y},b=new oU(25e3),S=new Qn(288),C=new Qn(32),L=0,P=0,T=a.i||0,_=0,A=a.w||0,I=0;T+2<i;++T){var V=x(T),j=T&32767,H=w[V];if(k[j]=H,w[V]=j,A<=T){var O=i-T;if((L>7e3||_>24576)&&(O>423||!l)){u=pte(e,c,0,b,S,C,P,_,I,T-I,u),_=L=P=0,I=T;for(var U=0;U<286;++U)S[U]=0;for(var U=0;U<30;++U)C[U]=0}var z=2,N=0,E=p,W=j-H&32767;if(O>2&&V==x(T-W))for(var q=Math.min(f,O)-1,R=Math.min(32767,T),G=Math.min(258,O);W<=R&&--E&&j!=H;){if(e[T+z]==e[T+z-W]){for(var X=0;X<G&&e[T+X]==e[T+X-W];++X);if(X>z){if(z=X,N=W,X>q)break;for(var Y=Math.min(W,X-2),oe=0,U=0;U<Y;++U){var ee=T-W+U&32767,ae=k[ee],ve=ee-ae&32767;ve>oe&&(oe=ve,H=ee)}}}j=H,H=k[j],W+=j-H&32767}if(N){b[_++]=268435456|kB[z]<<18|hte[N];var Se=kB[z]&31,be=hte[N]&31;P+=aU[Se]+iU[be],++S[257+Se],++C[be],A=T+z,++L}else b[_++]=e[T],++S[e[T]]}}for(T=Math.max(T,A);T<i;++T)b[_++]=e[T],++S[e[T]];u=pte(e,c,l,b,S,C,P,_,I,T-I,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=w,a.p=k,a.i=T,a.w=A)}else{for(var T=a.w||0;T<i+l;T+=65535){var we=T+65535;we>=i&&(c[u/8|0]=l,we=i),u=yde(c,u+1,e.subarray(T,we))}a.i=i}return pde(s,0,r+fde(u)+o)},EDe=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e}(),ADe=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=EDe[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},gde=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,a=n.length|0,i=0;i!=a;){for(var s=Math.min(i+2655,a);i<s;++i)o+=r+=n[i];r=(r&65535)+15*(r>>16),o=(o&65535)+15*(o>>16)}e=r,t=o},d:function(){return e%=65521,t%=65521,(e&255)<<24|(e&65280)<<8|(t&255)<<8|t>>8}}},kde=function(e,t,n,r,o){if(!o&&(o={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),i=new cn(a.length+e.length);i.set(a),i.set(e,a.length),e=i,o.w=a.length}return IDe(e,t.level==null?6:t.level,t.mem==null?o.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,o)},vde=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},$t=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},PDe=function(e,t){var n=t.level,r=n==0?0:n<6?1:n==9?3:2;if(e[0]=120,e[1]=r<<6|(t.dictionary&&32),e[1]|=31-(e[0]<<8|e[1])%31,t.dictionary){var o=gde();o.p(t.dictionary),$t(e,2,o.d())}};function _De(e,t){return kde(e,t||{},0,0)}function vqe(e,t){t||(t={});var n=gde();n.p(e);var r=kde(e,t,t.dictionary?6:2,4);return PDe(r,t),$t(r,r.length-4,n.d()),r}var xde=function(e,t,n,r){for(var o in e){var a=e[o],i=t+o,s=r;Array.isArray(a)&&(s=vde(r,a[1]),a=a[0]),a instanceof cn?n[i]=[a,s]:(n[i+="/"]=[new cn(0),s],xde(a,i,n,r))}},yte=typeof TextEncoder<"u"&&new TextEncoder,RDe=typeof TextDecoder<"u"&&new TextDecoder,TDe=0;try{RDe.decode(mde,{stream:!0}),TDe=1}catch{}function wB(e,t){var n;if(yte)return yte.encode(e);for(var r=e.length,o=new cn(e.length+(e.length>>1)),a=0,i=function(l){o[a++]=l},n=0;n<r;++n){if(a+5>o.length){var s=new cn(a+8+(r-n<<1));s.set(o),o=s}var c=e.charCodeAt(n);c<128||t?i(c):c<2048?(i(192|c>>6),i(128|c&63)):c>55295&&c<57344?(c=65536+(c&1047552)|e.charCodeAt(++n)&1023,i(240|c>>18),i(128|c>>12&63),i(128|c>>6&63),i(128|c&63)):(i(224|c>>12),i(128|c>>6&63),i(128|c&63))}return pde(o,0,a)}var MB=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&XT(9),t+=r+4}return t},mte=function(e,t,n,r,o,a,i,s){var c=r.length,l=n.extra,u=s&&s.length,d=MB(l);$t(e,t,i!=null?33639248:67324752),t+=4,i!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=o&&8,e[t++]=n.compression&255,e[t++]=n.compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&XT(10),$t(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&($t(e,t,n.crc),$t(e,t+4,a<0?-a-2:a),$t(e,t+8,n.size)),$t(e,t+12,c),$t(e,t+14,d),t+=16,i!=null&&($t(e,t,u),$t(e,t+6,n.attrs),$t(e,t+10,i),t+=14),e.set(r,t),t+=c,d)for(var y in l){var k=l[y],w=k.length;$t(e,t,+y),$t(e,t+2,w),e.set(k,t+4),t+=4+w}return u&&(e.set(s,t),t+=u),t},jDe=function(e,t,n,r,o){$t(e,t,101010256),$t(e,t+8,n),$t(e,t+10,n),$t(e,t+12,r),$t(e,t+16,o)};function NDe(e,t){t||(t={});var n={},r=[];xde(e,"",n,t);var o=0,a=0;for(var i in n){var s=n[i],c=s[0],l=s[1],u=l.level==0?0:8,d=wB(i),f=d.length,p=l.comment,y=p&&wB(p),k=y&&y.length,w=MB(l.extra);f>65535&&XT(11);var v=u?_De(c,l):c,M=v.length,x=ADe();x.p(c),r.push(vde(l,{size:c.length,crc:x.d(),c:v,f:d,m:y,u:f!=i.length||y&&p.length!=k,o,compression:u})),o+=30+f+w+M,a+=76+2*(f+w)+(k||0)+M}for(var b=new cn(a+22),S=o,C=a-o,L=0;L<r.length;++L){var d=r[L];mte(b,d.o,d,d.f,d.u,d.c.length);var P=30+d.f.length+MB(d.extra);b.set(d.c,d.o+P),mte(b,o,d,d.f,d.u,d.c.length,d.o,d.m),o+=16+P+(d.m?d.m.length:0)}return jDe(b,o,r.length,C,S),b}const zDe="https://seeflow.dev/api";async function DDe(e,t,n,r,o){const a=await Nre(e);if(!a.flow)throw new Error("Flow has no data");const i=a.flow,s=new Set,c=[];for(const y of i.nodes)y.type==="imageNode"&&y.data.path&&!s.has(y.data.path)?(s.add(y.data.path),c.push(y.data.path)):y.type==="htmlNode"&&y.data.htmlPath&&!s.has(y.data.htmlPath)&&(s.add(y.data.htmlPath),c.push(y.data.htmlPath));const u={[r==="link"?"seeflow.private.json":"seeflow.json"]:wB(JSON.stringify(i))};if(o){const y=o.split(",")[1];y&&(u["preview.png"]=Uint8Array.from(atob(y),k=>k.charCodeAt(0)))}for(const y of c){const k=await fetch(`/api/projects/${encodeURIComponent(e)}/files/${y}`);k.ok&&(u[`files/${y}`]=new Uint8Array(await k.arrayBuffer()))}const d=NDe(u),f=await fetch(`${zDe}/flows?email=${encodeURIComponent(t)}&name=${encodeURIComponent(n)}`,{method:"POST",headers:{"content-type":"application/zip"},body:d.buffer});if(!f.ok)throw new Error(`Export failed with status ${f.status}`);const p=await f.json();if(typeof p.url!="string")throw new Error("Invalid response from cloud API: missing url");return{shareUrl:p.url}}function qDe(e){return g.useCallback((t,n,r,o)=>DDe(e,t,n,r,o),[e])}const gte="seeflow.export.email",kte="seeflow.export.name",vte="seeflow.export.visibility";function ODe({open:e,onOpenChange:t,projectId:n,onCapturePreview:r}){const[o,a]=g.useState(""),[i,s]=g.useState(""),[c,l]=g.useState("public"),[u,d]=g.useState({kind:"idle"}),[f,p]=g.useState(!1),y=qDe(n);g.useEffect(()=>{e&&(a(localStorage.getItem(gte)??""),s(localStorage.getItem(kte)??""),l(localStorage.getItem(vte)??"public"),d({kind:"idle"}),p(!1))},[e]);const k=g.useCallback(async()=>{d({kind:"loading"});try{const x=await(r==null?void 0:r()),{shareUrl:b}=await y(o.trim(),i.trim(),c,x);localStorage.setItem(gte,o.trim()),localStorage.setItem(kte,i.trim()),localStorage.setItem(vte,c),d({kind:"done",shareUrl:b})}catch(x){d({kind:"error",message:x instanceof Error?x.message:String(x)})}},[y,o,i,c,r]),w=g.useCallback(async()=>{if(u.kind==="done")try{await navigator.clipboard.writeText(u.shareUrl),p(!0),setTimeout(()=>p(!1),2e3)}catch(x){console.error("Failed to copy to clipboard:",x)}},[u]),v=u.kind==="loading",M=o.trim().length>0&&i.trim().length>0;return m.jsx(RT,{open:e,onOpenChange:t,children:m.jsxs(Sf,{className:"sm:max-w-md","data-testid":"export-dialog",onOpenAutoFocus:x=>{x.preventDefault();const b=document.querySelector('[data-testid="export-email-input"]');b==null||b.focus()},children:[m.jsxs(Lf,{children:[m.jsx(If,{children:"Export to seeflow.dev"}),m.jsx(Ef,{children:"Upload this diagram to the cloud and get a shareable link."})]}),u.kind!=="done"?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex flex-col gap-4",children:[m.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[m.jsx("span",{className:"font-medium",children:"Email"}),m.jsx("input",{type:"email",required:!0,autoComplete:"email",value:o,onChange:x=>a(x.target.value),disabled:v,"data-testid":"export-email-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"}),m.jsx("span",{className:"text-xs text-muted-foreground",children:"We'll use this to let you manage your flows in the future."})]}),m.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[m.jsx("span",{className:"font-medium",children:"Flow Name"}),m.jsx("input",{type:"text",required:!0,value:i,onChange:x=>s(x.target.value),disabled:v,"data-testid":"export-name-input",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"})]}),m.jsxs("label",{className:"flex flex-col gap-1.5 text-sm",children:[m.jsx("span",{className:"font-medium",children:"Visibility"}),m.jsxs("select",{value:c,onChange:x=>l(x.target.value),disabled:v,"data-testid":"export-visibility-select",className:"rounded-md border bg-background px-3 py-2 text-sm outline-hidden ring-offset-background focus:border-ring focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",children:[m.jsx("option",{value:"public",children:"Public — anyone can discover it"}),m.jsx("option",{value:"link",children:"Anyone with the link"})]})]}),u.kind==="error"?m.jsx("div",{role:"alert","data-testid":"export-error",className:"rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive",children:u.message}):null]}),m.jsx(fd,{children:u.kind==="error"?m.jsxs(m.Fragment,{children:[m.jsx(Ft,{type:"button",variant:"ghost",onClick:()=>t(!1),"data-testid":"export-cancel",children:"Cancel"}),m.jsx(Ft,{type:"button",onClick:()=>d({kind:"idle"}),"data-testid":"export-retry",children:"Try again"})]}):m.jsxs(m.Fragment,{children:[m.jsx(Ft,{type:"button",variant:"ghost",onClick:()=>t(!1),disabled:v,"data-testid":"export-cancel",children:"Cancel"}),m.jsx(Ft,{type:"button",onClick:k,disabled:v||!M,"data-testid":"export-submit",children:v?m.jsxs(m.Fragment,{children:[m.jsx(dr,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}),m.jsx("span",{children:"Uploading…"})]}):"Export"})]})})]}):m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex flex-col gap-3",children:[m.jsx("p",{className:"text-sm text-muted-foreground",children:"Your diagram is live. Share this link:"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx("input",{type:"text",readOnly:!0,value:u.shareUrl,"data-testid":"export-share-url",className:"min-w-0 flex-1 rounded-md border bg-muted px-3 py-2 text-sm outline-hidden"}),m.jsx(Ft,{type:"button",variant:"outline",size:"icon",onClick:w,"aria-label":"Copy link","data-testid":"export-copy",children:f?m.jsx(Ja,{className:"h-4 w-4","aria-hidden":"true"}):m.jsx(T1,{className:"h-4 w-4","aria-hidden":"true"})}),m.jsx(Ft,{type:"button",variant:"outline",size:"icon",onClick:()=>window.open(u.shareUrl,"_blank"),"aria-label":"View in new tab","data-testid":"export-view",children:m.jsx(Fh,{className:"h-4 w-4","aria-hidden":"true"})})]})]}),m.jsx(fd,{children:m.jsx(Ft,{type:"button",onClick:()=>t(!1),"data-testid":"export-done",children:"Done"})})]})]})})}const FDe=(e,t)=>{if(e.has(t))return e;const n=new Set(e);return n.add(t),n},HDe=(e,t)=>{if(t.length===0)return e;let n=!1;const r=new Set(e);for(const o of t)r.has(o)||(r.add(o),n=!0);return n?r:e},BDe=(e,t)=>{if(!e.has(t))return e;const n=new Set(e);return n.delete(t),n},VDe=(e,t)=>{if(t.length===0)return e;let n=!1;const r=new Set(e);for(const o of t)r.has(o)&&(r.delete(o),n=!0);return n?r:e},$De=(e,t)=>{if(e.size===0)return e;const n=new Set(t.map(a=>a.id));let r=!1;const o=new Set(e);for(const a of o)n.has(a)||(o.delete(a),r=!0);return r?o:e},xte=()=>{const[e,t]=g.useState(()=>new Set),n=g.useCallback(c=>{t(l=>FDe(l,c))},[]),r=g.useCallback(c=>{t(l=>HDe(l,c))},[]),o=g.useCallback(c=>{t(l=>BDe(l,c))},[]),a=g.useCallback(c=>{t(l=>VDe(l,c))},[]),i=g.useCallback(c=>{t(l=>$De(l,c))},[]),s=g.useCallback(()=>t(new Set),[]);return{ids:e,mark:n,markMany:r,unmark:o,unmarkMany:a,pruneAgainst:i,reset:s}},UDe=(e,t)=>e===t?!0:e==null||t==null||typeof e!=typeof t||typeof e!="object"?!1:JSON.stringify(e)===JSON.stringify(t),WDe=(e,t,n)=>({...e,[t]:{...e[t],...n}}),GDe=(e,t)=>{if(!(t in e))return e;const n={...e};return delete n[t],n},KDe=(e,t)=>{const n=Object.entries(e);if(n.length===0)return e;const r=new Map(t.map(i=>[i.id,i]));let o=!1;const a={...e};for(const[i,s]of n){const c=r.get(i);if(!c)continue;const l={};let u=!1;for(const d of Object.keys(s))UDe(s[d],c[d])?o=!0:(l[d]=s[d],u=!0);u?a[i]=l:(o=!0,delete a[i])}return o?a:e},wte=()=>{const[e,t]=g.useState({}),n=g.useCallback((i,s)=>{t(c=>WDe(c,i,s))},[]),r=g.useCallback(i=>{t(s=>GDe(s,i))},[]),o=g.useCallback(i=>{t(s=>KDe(s,i))},[]),a=g.useCallback(()=>t({}),[]);return{overrides:e,setOverride:n,dropOverride:r,pruneAgainst:o,reset:a}},ZDe=500,XDe=500,YDe={stack:[],cursor:0},QDe=(e,t,n)=>{const r=Date.now(),o=ZDe,a=XDe,{stack:i,cursor:s}=e;if(t.coalesceKey&&s>0){const u=i[s-1];if(u&&u.coalesceKey===t.coalesceKey&&r-u.capturedAt<=a){const d=i.slice(0,s);return d[s-1]={...u,do:t.do,capturedAt:r},{stack:d,cursor:s}}}const c=i.slice(0,s);c.push({...t,capturedAt:r});let l=s+1;for(;c.length>o;)c.shift(),l-=1;return l<0&&(l=0),{stack:c,cursor:l}},JDe=e=>e.cursor===0?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor-1},entry:e.stack[e.cursor-1]},eqe=e=>e.cursor===e.stack.length?{state:e,entry:void 0}:{state:{...e,cursor:e.cursor+1},entry:e.stack[e.cursor]},tqe=()=>({stack:[],cursor:0}),nqe=e=>{if(e.cursor===0)return e;const t=e.stack.slice();return t.splice(e.cursor-1,1),{stack:t,cursor:e.cursor-1}},rqe=(e,t)=>t.state,oqe=()=>{const[e,t]=g.useReducer(rqe,YDe),n=g.useRef(e);n.current=e;const r=g.useRef(Promise.resolve()),o=g.useRef(0),a=g.useCallback(p=>{p!==n.current&&(n.current=p,t({type:"replace",state:p}))},[]),i=g.useCallback(p=>{const y={do:p.do,undo:p.undo,coalesceKey:p.coalesceKey,capturedAt:p.capturedAt??Date.now()};a(QDe(n.current,y))},[a]),s=g.useCallback(()=>{o.current=Date.now();const p=r.current.then(()=>{const y=JDe(n.current);if(y.entry)return a(y.state),{entry:y.entry}});return r.current=p.then(()=>{},()=>{}),p},[a]),c=g.useCallback(()=>{o.current=Date.now();const p=r.current.then(()=>{const y=eqe(n.current);if(y.entry)return a(y.state),{entry:y.entry}});return r.current=p.then(()=>{},()=>{}),p},[a]),l=g.useCallback(()=>{a(tqe())},[a]),u=g.useCallback(()=>{a(nqe(n.current))},[a]),d=g.useCallback(()=>{o.current=Date.now()},[]),f=g.useCallback(()=>o.current,[]);return{push:i,undo:s,redo:c,clear:l,dropTop:u,canUndo:e.cursor>0,canRedo:e.cursor<e.stack.length,markMutation:d,lastMutationAt:f}};function aqe({nodes:e,connectors:t,flowPos:n,nodeIdGen:r,connectorIdGen:o,defaultOffset:a={x:24,y:24}}){const i=new Map;for(const p of e)i.set(p.id,r(p.id));let s=Number.POSITIVE_INFINITY,c=Number.POSITIVE_INFINITY;for(const p of e)p.position.x<s&&(s=p.position.x),p.position.y<c&&(c=p.position.y);Number.isFinite(s)||(s=0),Number.isFinite(c)||(c=0);const l=n?n.x-s:a.x,u=n?n.y-c:a.y,d=e.map(p=>{const y=i.get(p.id);if(y===void 0)throw new Error(`paste id missing for ${p.id}`);return{...p,id:y,position:{x:p.position.x+l,y:p.position.y+u}}}),f=t.map(p=>{const y=o(p.id);return{...p,id:y,source:i.get(p.source)??p.source,target:i.get(p.target)??p.target}});return{newNodes:d,newConnectors:f,idMap:i}}const iqe=e=>({type:"imageNode",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploading:!0}}),sqe=e=>({type:"imageNode",data:wde(e)}),cqe=e=>({type:"imageNode",position:e.position,data:{path:"",alt:e.originalFilename,width:e.dims.width,height:e.dims.height,_uploadError:e.message}}),wde=e=>({...PMe(e.path,e.dims,e.lastUsed),alt:e.originalFilename}),lqe=async(e,t)=>{const{nodeId:n,flowId:r,file:o,originalFilename:a,position:i,dims:s,lastUsed:c}=e;t.rememberRetry(n,{file:o,originalFilename:a,position:i,dims:s}),t.setOverride(n,iqe({position:i,dims:s,originalFilename:a}));let l;try{l=(await t.upload(r,o,a)).path}catch(p){const y=p instanceof Error?p.message:String(p);throw t.setOverride(n,cqe({position:i,dims:s,originalFilename:a,message:y})),p}t.setOverride(n,sqe({path:l,dims:s,originalFilename:a,lastUsed:c}));const u=wde({path:l,dims:s,originalFilename:a,lastUsed:c}),d={id:n,type:"imageNode",position:i,data:u},{id:f}=await t.createNode(r,d);t.forgetRetry(n),t.pushUndo&&t.pushUndo({do:async()=>{await t.createNode(r,{...d,id:f})},undo:async()=>{await t.deleteNode(r,f)}})},uqe=new Set(["INPUT","TEXTAREA","SELECT"]),Pr=e=>e?uqe.has(e.tagName)?!0:e instanceof HTMLElement&&e.isContentEditable:!1,dqe=(e,t,n)=>{const r=e.indexOf(t);if(r<0)return null;const o=e.length,a=[...e];switch(n.op){case"forward":{if(r>=o-1)return null;const i=a[r],s=a[r+1];return i===void 0||s===void 0?null:(a[r]=s,a[r+1]=i,a)}case"backward":{if(r<=0)return null;const i=a[r],s=a[r-1];return i===void 0||s===void 0?null:(a[r]=s,a[r-1]=i,a)}case"toFront":{if(r===o-1)return null;const[i]=a.splice(r,1);return i===void 0?null:(a.push(i),a)}case"toBack":{if(r===0)return null;const[i]=a.splice(r,1);return i===void 0?null:(a.unshift(i),a)}case"toIndex":{const i=Math.min(Math.max(n.index,0),o-1);if(i===r)return null;const[s]=a.splice(r,1);return s===void 0?null:(a.splice(i,0,s),a)}}};function hqe({slug:e,demos:t,detail:n,loading:r,runs:o,nodeEvents:a,statusByNode:i,onPlayNode:s,onRestartDemo:c}){var Hd,dn;const l=t.find(F=>F.slug===e),[u,d]=g.useState([]),[f,p]=g.useState([]),[y,k]=g.useState(null),w=g.useRef(u),v=g.useRef(f);g.useEffect(()=>{w.current=u},[u]),g.useEffect(()=>{v.current=f},[f]);const M=g.useRef(null),x=g.useRef(null),b=g.useRef(null),S=wte(),C=wte(),L=xte(),P=xte(),[T,_]=g.useState(null),[A,I]=g.useState(null),[V,j]=g.useState(null),H=g.useRef(null);g.useEffect(()=>{H.current=V},[V]);const[O,U]=g.useState(!1),[z,N]=g.useState(0),E=g.useRef(null),W=g.useRef(null),q=g.useCallback(F=>{W.current=F},[]),R=oqe(),{push:G,dropTop:X,markMutation:Y,clear:oe,lastMutationAt:ee}=R,{reset:ae}=S,{reset:ve}=C,{reset:Se}=L,{reset:be}=P;g.useEffect(()=>{d([]),p([]),k(null),ae(),ve(),Se(),be(),_(null),I(null),va.current=null,bi(!1),to.current.clear(),R.clear()},[n==null?void 0:n.id]);const we=g.useCallback((F,B)=>{d(F),p(B)},[]),te=(Hd=n==null?void 0:n.flow)==null?void 0:Hd.nodes,ie=(dn=n==null?void 0:n.flow)==null?void 0:dn.connectors,{pruneAgainst:Te}=S,{pruneAgainst:Ae}=C,{pruneAgainst:at}=L,{pruneAgainst:Qe}=P;g.useEffect(()=>{te&&(Te(te),at(te)),Date.now()-ee()>2e3&&oe()},[te,Te,at,ee,oe]),g.useEffect(()=>{if(!te)return;const F=E.current,B=new Set(te.map(ne=>ne.id));if(E.current=B,F===null)return;const Z=S.overrides,$=L.ids;let D=!1;for(const ne of B)if(!F.has(ne)&&!(ne in Z)){D=!0;break}if(!D){for(const ne of F)if(!B.has(ne)&&!$.has(ne)){D=!0;break}}D&&N(ne=>ne+1)},[te]),g.useEffect(()=>{ie&&(Ae(ie),Qe(ie)),Date.now()-ee()>2e3&&oe()},[ie,Ae,Qe,ee,oe]),g.useEffect(()=>{if(!(!te||!T)&&te.length===T.length){for(let F=0;F<te.length;F++){const B=te[F],Z=T[F];if(!B||B.id!==Z)return}_(null)}},[te,T]);const le=(n==null?void 0:n.id)??null,Q=g.useMemo(()=>le?_Me({baseUrl:"",flowId:le}):null,[le]),[ue,ge]=g.useState(!1),{setOverride:Me,dropOverride:qe}=S,re=g.useRef(S.overrides);g.useEffect(()=>{re.current=S.overrides},[S.overrides]);const he=g.useCallback((F,B)=>{var $;if(!le||!Q)return;const Z=($=te==null?void 0:te.find(D=>D.id===F))==null?void 0:$.position;Me(F,{position:B}),I(null),Y(),Z&&G({do:async()=>{await Q.updateNodePosition(F,B)},undo:async()=>{await Q.updateNodePosition(F,Z)},coalesceKey:`node:${F}:position`}),Q.updateNodePosition(F,B).catch(D=>{qe(F),Z&&X(),I(D instanceof Error?D.message:String(D)),console.error("updateNodePosition failed",D)})},[le,Q,te,Me,qe,G,X,Y]),Ie=g.useCallback(F=>{if(!le||!Q||F.length===0)return;const B=re.current,Z=F.map($=>{var Pe;const D=te==null?void 0:te.find(ke=>ke.id===$.id);if(!D)return null;const ne=((Pe=B[$.id])==null?void 0:Pe.position)??D.position;return{id:$.id,prev:ne,next:$.position}}).filter($=>$!==null);if(Z.length!==0){for(const $ of Z)Me($.id,{position:$.next});I(null),Y(),G({do:async()=>{await Promise.allSettled(Z.map($=>Q.updateNodePosition($.id,$.next)))},undo:async()=>{await Promise.allSettled(Z.map($=>Q.updateNodePosition($.id,$.prev)))}}),Promise.all(Z.map(async $=>{try{return await Q.updateNodePosition($.id,$.next),null}catch(D){return qe($.id),D instanceof Error?D.message:String(D)}})).then($=>{const D=$.find(ne=>ne!==null);D&&I(D)})}},[le,Q,te,Me,qe,G,Y]),He=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=te==null?void 0:te.find(ne=>ne.id===F),$=Z?{width:Z.data.width,height:Z.data.height,position:{x:Z.position.x,y:Z.position.y}}:void 0,D={width:B.width,height:B.height,position:{x:B.x,y:B.y}};Me(F,{position:D.position,data:{width:D.width,height:D.height}}),I(null),Y(),$&&G({do:async()=>{await Q.updateNode(F,D)},undo:async()=>{await Q.updateNode(F,$)},coalesceKey:`node:${F}:resize`}),Q.updateNode(F,D).catch(ne=>{qe(F),$&&X(),I(ne instanceof Error?ne.message:String(ne)),console.error("updateNode resize failed",ne)})},[le,Q,te,Me,qe,G,X,Y]),Ue=g.useCallback(F=>{if(!le||!Q)return;const B=te==null?void 0:te.find(D=>D.id===F);if(!B)return;const Z={autoSize:B.data.autoSize,width:B.data.width,height:B.data.height},$={autoSize:!0};Me(F,{data:{autoSize:!0,width:void 0,height:void 0}}),I(null),Y(),G({do:async()=>{await Q.updateNode(F,$)},undo:async()=>{await Q.updateNode(F,Z)},coalesceKey:`node:${F}:fit-to-content`}),Q.updateNode(F,$).catch(D=>{qe(F),X(),I(D instanceof Error?D.message:String(D)),console.error("updateNode (fit-to-content) failed",D)})},[le,Q,te,Me,qe,G,X,Y]),Rt=g.useCallback(F=>{if(!le||!Q||F.length===0)return;const B=[];for(const $ of F){const D=te==null?void 0:te.find(dt=>dt.id===$.id);if(!D)continue;const ne=D.data,Pe={position:{x:D.position.x,y:D.position.y}};ne.width!==void 0&&(Pe.width=ne.width),ne.height!==void 0&&(Pe.height=ne.height);const ke={position:$.position};$.width!==void 0&&(ke.width=$.width),$.height!==void 0&&(ke.height=$.height),B.push({id:$.id,prev:Pe,next:ke})}if(B.length===0)return;for(const $ of B){const D={};$.next.width!==void 0&&(D.width=$.next.width),$.next.height!==void 0&&(D.height=$.next.height),Me($.id,{position:$.next.position,...Object.keys(D).length>0?{data:D}:{}})}I(null),Y();const Z=B.map($=>$.id).sort();G({do:async()=>{await Promise.allSettled(B.map($=>Q.updateNode($.id,$.next)))},undo:async()=>{await Promise.allSettled(B.map($=>Q.updateNode($.id,$.prev)))},coalesceKey:`multi:resize:${Z.join(",")}`}),Promise.all(B.map(async $=>{try{return await Q.updateNode($.id,$.next),null}catch(D){return qe($.id),D instanceof Error?D.message:String(D)}})).then($=>{const D=$.find(ne=>ne!==null);D&&I(D)})},[le,Q,te,Me,qe,G,Y]),{setOverride:Oe,dropOverride:je}=C,Pt=g.useCallback((F,B)=>{Me(F,{data:B})},[Me]),sr=g.useCallback((F,B)=>{for(const Z of F)Me(Z,{data:B})},[Me]),Dt=g.useCallback((F,B)=>{Oe(F,B)},[Oe]),Dn=g.useCallback((F,B)=>{if(!le||!Q)return;WQ(Ai,B);const Z=te==null?void 0:te.find(D=>D.id===F);let $=null;if(Z){$={};const D=Z.data;for(const ne of Object.keys(B))$[ne]=D[ne]}if(Me(F,{data:B}),I(null),Y(),$){const D=$;G({do:async()=>{await Q.updateNode(F,B)},undo:async()=>{await Q.updateNode(F,D)},coalesceKey:`node:${F}:style`})}Q.updateNode(F,B).catch(D=>{qe(F),$&&X(),I(D instanceof Error?D.message:String(D)),console.error("updateNode style failed",D)})},[le,Q,te,Me,qe,G,X,Y]),en=g.useCallback((F,B)=>{if(!le||!Q||F.length===0)return;WQ(Ai,B);const Z=F.map($=>{const D=te==null?void 0:te.find(ke=>ke.id===$);if(!D)return null;const ne=D.data,Pe={};for(const ke of Object.keys(B))Pe[ke]=ne[ke];return{id:$,prev:Pe}}).filter($=>$!==null);if(Z.length!==0){for(const $ of Z)Me($.id,{data:B});I(null),Y(),G({do:async()=>{await Promise.allSettled(Z.map($=>Q.updateNode($.id,B)))},undo:async()=>{await Promise.allSettled(Z.map($=>Q.updateNode($.id,$.prev)))}}),Promise.all(Z.map(async $=>{try{return await Q.updateNode($.id,B),null}catch(D){return qe($.id),D instanceof Error?D.message:String(D)}})).then($=>{const D=$.find(ne=>ne!==null);D&&I(D)})}},[le,Q,te,Me,qe,G,Y]),$u=g.useCallback(F=>{if(!le||!Q||F.length===0)return;const B=F.map(D=>{const ne=te==null?void 0:te.find(ke=>ke.id===D);if(!ne)return null;const Pe=ne.data;return{id:D,prev:Pe.locked===!0}}).filter(D=>D!==null);if(B.length===0)return;const Z=B.some(D=>!D.prev),$=B.filter(D=>D.prev!==Z);if($.length!==0){for(const D of $)Me(D.id,{data:{locked:Z}});I(null),Y(),G({do:async()=>{await Promise.allSettled($.map(D=>Q.updateNode(D.id,{locked:Z})))},undo:async()=>{await Promise.allSettled($.map(D=>Q.updateNode(D.id,{locked:D.prev})))}}),Promise.all($.map(async D=>{try{return await Q.updateNode(D.id,{locked:Z}),null}catch(ne){return qe(D.id),ne instanceof Error?ne.message:String(ne)}})).then(D=>{const ne=D.find(Pe=>Pe!==null);ne&&I(ne)})}},[le,Q,te,Me,qe,G,Y]),Uu=g.useCallback((F,B)=>{if(!le||!Q)return;SMe(Ai,B);const Z=ie==null?void 0:ie.find(D=>D.id===F);let $=null;if(Z){$={};const D=Z;for(const ne of Object.keys(B))$[ne]=D[ne]}if(Oe(F,B),I(null),Y(),$){const D=$;G({do:async()=>{await Q.updateConnector(F,B)},undo:async()=>{await Q.updateConnector(F,D)},coalesceKey:`connector:${F}:style`})}Q.updateConnector(F,B).catch(D=>{je(F),$&&X(),I(D instanceof Error?D.message:String(D)),console.error("updateConnector failed",D)})},[le,Q,ie,Oe,je,G,X,Y]),{mark:da,markMany:ha,unmark:Xr,unmarkMany:gi}=L,{mark:fa,markMany:xr,unmark:Yr,unmarkMany:wr}=P,Wu=g.useCallback(F=>{if(!le||!Q)return;const B=te==null?void 0:te.find(ke=>ke.id===F);if(!B||B.data.locked===!0)return;const Z=(ie??[]).filter(ke=>ke.source===F||ke.target===F),$=Z.map(ke=>ke.id),D=new Set($);I(null),da(F),$.length>0&&xr($),d(ke=>ke.filter(dt=>dt!==F)),p(ke=>ke.filter(dt=>!D.has(dt))),Y();const ne=B,Pe=Z;G({do:async()=>{da(F),$.length>0&&xr($),await Q.deleteNode(F)},undo:async()=>{Xr(F),$.length>0&&wr($),await Q.createNode({id:ne.id,type:ne.type,position:ne.position,data:ne.data});for(const ke of Pe)await Q.createConnector({...ke,id:ke.id})}}),Q.deleteNode(F).catch(ke=>{Xr(F),$.length>0&&wr($),X(),I(ke instanceof Error?ke.message:String(ke)),console.error("deleteNode failed",ke)})},[le,Q,te,ie,da,xr,Xr,wr,G,X,Y]),Ve=g.useCallback((F,B)=>{if(!le||!Q||!te)return;const Z=T??te.map(ne=>ne.id),$=dqe(Z,F,B);if(!$)return;const D=Z.indexOf(F);_($),I(null),Y(),G({do:async()=>{await Q.reorderNode(F,B)},undo:async()=>{await Q.reorderNode(F,{op:"toIndex",index:D})}}),Q.reorderNode(F,B).catch(ne=>{_(null),X(),I(ne instanceof Error?ne.message:String(ne)),console.error("reorderNode failed",ne)})},[le,Q,te,T,G,X,Y]);g.useCallback(F=>{if(!le||!Q)return;const B=ie==null?void 0:ie.find($=>$.id===F);if(!B)return;I(null),fa(F),p($=>$.filter(D=>D!==F)),Y();const Z=B;G({do:async()=>{fa(F),await Q.deleteConnector(F)},undo:async()=>{Yr(F),await Q.createConnector({...Z,id:Z.id})}}),Q.deleteConnector(F).catch($=>{Yr(F),X(),I($ instanceof Error?$.message:String($)),console.error("deleteConnector failed",$)})},[le,Q,ie,fa,Yr,G,X,Y]);const yt=g.useCallback((F,B)=>{if(!le||!Q||F.length===0&&B.length===0)return;const Z=F,$=new Set((te??[]).filter(_e=>_e.data.locked===!0).map(_e=>_e.id)),D=Z.filter(_e=>!$.has(_e)),ne=new Set(D),Pe=D.map(_e=>te==null?void 0:te.find(nt=>nt.id===_e)).filter(_e=>!!_e),ke=(ie??[]).filter(_e=>ne.has(_e.source)||ne.has(_e.target)),dt=new Set(ke.map(_e=>_e.id)),Tt=B.map(_e=>ie==null?void 0:ie.find(nt=>nt.id===_e)).filter(_e=>!!_e).filter(_e=>!dt.has(_e.id)).filter(_e=>!($.has(_e.source)&&$.has(_e.target)));if(Pe.length===0&&ke.length===0&&Tt.length===0)return;I(null);const Sn=Pe.map(_e=>_e.id),Kt=[...ke.map(_e=>_e.id),...Tt.map(_e=>_e.id)];Sn.length>0&&ha(Sn),Kt.length>0&&xr(Kt);const Lr=Pe;d(_e=>_e.filter(nt=>!ne.has(nt)));const wa=new Set(Tt.map(_e=>_e.id));p(_e=>_e.filter(nt=>!wa.has(nt)&&!dt.has(nt))),Y(),G({do:async()=>{Sn.length>0&&ha(Sn),Kt.length>0&&xr(Kt);for(const _e of Lr)await Q.deleteNode(_e.id).catch(()=>{});await Promise.allSettled(Tt.map(_e=>Q.deleteConnector(_e.id)))},undo:async()=>{Sn.length>0&&gi(Sn),Kt.length>0&&wr(Kt);for(let _e=Lr.length-1;_e>=0;_e--){const nt=Lr[_e];nt&&await Q.createNode({id:nt.id,type:nt.type,position:nt.position,data:nt.data})}for(const _e of[...ke,...Tt])await Q.createConnector({..._e,id:_e.id})}});const Zu=new Map;for(const _e of Pe)Zu.set(_e.id,ke.filter(nt=>nt.source===_e.id||nt.target===_e.id).map(nt=>nt.id));(async()=>{const _e=[];for(const Ne of Lr)try{await Q.deleteNode(Ne.id)}catch(it){Xr(Ne.id);const jt=Zu.get(Ne.id)??[];jt.length>0&&wr(jt),_e.push(it instanceof Error?it.message:String(it))}const nt=await Promise.all(Tt.map(async Ne=>{try{return await Q.deleteConnector(Ne.id),null}catch(it){return Yr(Ne.id),it instanceof Error?it.message:String(it)}}));for(const Ne of nt)Ne!==null&&_e.push(Ne);_e.length>0&&_e[0]!==void 0&&I(_e[0])})()},[le,Q,te,ie,ha,xr,Xr,gi,Yr,wr,G,Y]);g.useEffect(()=>{M.current=yt},[yt]),g.useEffect(()=>{const F=B=>{if(B.key!=="Delete"&&B.key!=="Backspace"||Pr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=w.current,$=v.current;Z.length===0&&$.length===0||(B.preventDefault(),yt(Z,$))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[yt]);const{undo:Qr,redo:Po,canUndo:qn,canRedo:xn}=R;g.useEffect(()=>{const F=async B=>{if((B.metaKey||B.ctrlKey)&&B.key.toLowerCase()==="z"&&!Pr(document.activeElement)){if(B.preventDefault(),B.shiftKey){if(!xn)return;try{const Z=await Po();Z!=null&&Z.entry&&await Z.entry.do()}catch(Z){I(Z instanceof Error?Z.message:String(Z)),console.error("redo failed",Z)}return}if(qn)try{const Z=await Qr();Z!=null&&Z.entry&&await Z.entry.undo()}catch(Z){I(Z instanceof Error?Z.message:String(Z)),console.error("undo failed",Z)}}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[Qr,Po,qn,xn]);const _o=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=te==null?void 0:te.find(ne=>ne.id===F),D=(Z&&"name"in Z.data?Z.data.name:void 0)??"";Me(F,{data:{name:B}}),I(null),Y(),Z&&G({do:async()=>{await Q.updateNode(F,{name:B})},undo:async()=>{await Q.updateNode(F,{name:D})},coalesceKey:`node:${F}:name`}),Q.updateNode(F,{name:B}).catch(ne=>{Z&&X(),I(ne instanceof Error?ne.message:String(ne)),console.error("updateNode name failed",ne)})},[le,Q,te,Me,G,X,Y]),On=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=te==null?void 0:te.find(D=>D.id===F);if(!Z)return;const $=Z.data.description??"";Me(F,{data:{description:B}}),I(null),Y(),G({do:async()=>{await Q.updateNode(F,{description:B})},undo:async()=>{await Q.updateNode(F,{description:$})},coalesceKey:`node:${F}:description`}),Q.updateNode(F,{description:B}).catch(D=>{X(),I(D instanceof Error?D.message:String(D)),console.error("updateNode description failed",D)})},[le,Q,te,Me,G,X,Y]),Jr=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=te==null?void 0:te.find(D=>D.id===F);if(!Z)return;const $=Z.data.detail??"";Me(F,{data:{detail:B}}),I(null),Y(),G({do:async()=>{await Q.updateNode(F,{detail:B})},undo:async()=>{await Q.updateNode(F,{detail:$})},coalesceKey:`node:${F}:detail`}),Q.updateNode(F,{detail:B}).catch(D=>{X(),I(D instanceof Error?D.message:String(D)),console.error("updateNode detail failed",D)})},[le,Q,te,Me,G,X,Y]),un=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=te==null?void 0:te.find(D=>D.id===F);if(!Z)return;const $="icon"in Z.data?Z.data.icon??null:null;Me(F,{data:{icon:B??void 0}}),I(null),Y(),G({do:async()=>{await Q.updateNode(F,{icon:B})},undo:async()=>{await Q.updateNode(F,{icon:$})},coalesceKey:`node:${F}:icon`}),Q.updateNode(F,{icon:B}).catch(D=>{X(),I(D instanceof Error?D.message:String(D)),console.error("updateNode icon failed",D)})},[le,Q,te,Me,G,X,Y]),Gt=g.useCallback((F,B,Z)=>{if(!le||!Q)return;I(null);const $=`node-${crypto.randomUUID()}`,D=KQ(F,Z,C0(Ai).node),ne={id:$,type:"shapeNode",position:B,data:D};Me($,{id:$,type:"shapeNode",position:B,data:D}),Y(),Q.createNode(ne).then(({id:ke})=>{G({do:async()=>{await Q.createNode({...ne,id:ke})},undo:async()=>{await Q.deleteNode(ke)}})}).catch(ke=>{qe($),I(ke instanceof Error?ke.message:String(ke)),console.error("createNode failed",ke)})},[le,Q,Me,qe,G,Y]),eo=g.useCallback((F,B)=>{if(!le||!Q)return;I(null);const Z=`node-${crypto.randomUUID()}`,$={icon:F,width:ld.width,height:ld.height},D={id:Z,type:"iconNode",position:B,data:$};Me(Z,{id:Z,type:"iconNode",position:B,data:$}),d([Z]),Y(),Q.createNode(D).then(({id:Pe})=>{G({do:async()=>{await Q.createNode({...D,id:Pe})},undo:async()=>{await Q.deleteNode(Pe)}})}).catch(Pe=>{qe(Z),I(Pe instanceof Error?Pe.message:String(Pe)),console.error("createNode (icon) failed",Pe)})},[le,Q,Me,qe,G,Y]),pa=g.useCallback(F=>{if(!le||!Q)return;I(null);const B=`node-${crypto.randomUUID()}`,Z=`blocks/${B}.html`,$={id:B,type:"htmlNode",position:F.position,data:{}},D={id:B,type:"htmlNode",position:F.position,data:{htmlPath:Z}};Me(B,D),d([B]),Y(),Q.createNode($).then(({id:ne})=>{G({do:async()=>{await Q.createNode({...$,id:ne})},undo:async()=>{await Q.deleteNode(ne)}})}).catch(ne=>{qe(B),I(ne instanceof Error?ne.message:String(ne)),console.error("createNode (htmlNode) failed",ne)})},[le,Q,Me,qe,G,Y]),to=g.useRef(new Map),ki=g.useCallback((F,B)=>{to.current.set(F,B)},[]),vi=g.useCallback(F=>{to.current.delete(F)},[]),mt=g.useCallback(F=>{!le||!Q||(I(null),Y(),lqe({...F,flowId:le,lastUsed:C0(Ai).node},{upload:(B,Z,$)=>Q.uploadImage(Z,$),createNode:async(B,Z)=>{const{id:$}=await Q.createNode(Z);return{id:$}},deleteNode:async(B,Z)=>(await Q.deleteNode(Z),{ok:!0}),setOverride:Me,pushUndo:G,rememberRetry:ki,forgetRetry:vi}).catch(B=>{console.error("image-upload-flow failed",B)}))},[le,Q,Me,G,Y,ki,vi]),xi=g.useCallback(F=>{if(!le||!Q)return;const B=`node-${crypto.randomUUID()}`;mt({nodeId:B,...F})},[le,Q,mt]),ya=g.useCallback(F=>{const B=to.current.get(F);B&&mt({nodeId:F,...B})},[mt]),[Mr,br]=g.useState({open:!1,mode:"insert"}),cr=g.useCallback((F,B)=>{br({open:!0,mode:F,nodeId:B})},[]),ma=g.useCallback(()=>{br(F=>({...F,open:!1}))},[]),wi=g.useCallback(()=>{cr("insert")},[cr]),Mi=g.useCallback(F=>cr("replace",F),[cr]),ga=g.useCallback(F=>{if(yMe(F),Mr.mode==="replace"&&Mr.nodeId){if(le&&Q){const B=Mr.nodeId,Z=te==null?void 0:te.find(D=>D.id===B),$=(Z==null?void 0:Z.type)==="iconNode"?Z.data.icon:void 0;if(Me(B,{data:{icon:F}}),I(null),Y(),$!==void 0){const D=$;G({do:async()=>{await Q.updateNode(B,{icon:F})},undo:async()=>{await Q.updateNode(B,{icon:D})},coalesceKey:`node:${B}:icon`})}Q.updateNode(B,{icon:F}).catch(D=>{qe(B),$!==void 0&&X(),I(D instanceof Error?D.message:String(D)),console.error("updateNode (icon replace) failed",D)})}}else{const B=W.current;if(B&&le){const Z=fMe(B,{width:window.innerWidth,height:window.innerHeight});eo(F,Z)}}ma()},[Mr.mode,Mr.nodeId,le,Q,te,Me,qe,G,X,Y,eo,ma]),wn=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=ie==null?void 0:ie.find(D=>D.id===F),$=Z==null?void 0:Z.label;Oe(F,{label:B}),I(null),Y(),Z&&G({do:async()=>{await Q.updateConnector(F,{label:B})},undo:async()=>{await Q.updateConnector(F,{label:$})},coalesceKey:`connector:${F}:label`}),Q.updateConnector(F,{label:B}).catch(D=>{Z&&X(),I(D instanceof Error?D.message:String(D)),console.error("updateConnector label failed",D)})},[le,Q,ie,Oe,G,X,Y]),Ro=g.useCallback((F,B,Z)=>{if(!le||!Q)return;const $=`conn-${crypto.randomUUID()}`,D=Z==null?void 0:Z.targetPin,ne=C0(Ai).connector,Pe={id:$,source:F,target:B,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...D?{targetPin:D}:{},...ne,kind:"default"},ke={id:$,source:F,target:B,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...D?{targetPin:D}:{},...ne,kind:"default"};Oe($,Pe),I(null),Y(),Q.createConnector(ke).then(({id:dt})=>{G({do:async()=>{await Q.createConnector({...ke,id:dt})},undo:async()=>{await Q.deleteConnector(dt)}})}).catch(dt=>{je($),I(dt instanceof Error?dt.message:String(dt)),console.error("createConnector failed",dt)})},[le,Q,Oe,je,G,Y]),ka=g.useCallback(({sourceNodeId:F,position:B,shape:Z})=>{if(!le||!Q)return;I(null);const $=`node-${crypto.randomUUID()}`,D=`conn-${crypto.randomUUID()}`,ne=uR[Z],Pe=C0(Ai),ke=KQ(Z,ne,Pe.node),dt={id:$,type:"shapeNode",position:B,data:ke},Tt={id:D,source:F,target:$,sourceHandleAutoPicked:!0,targetHandleAutoPicked:!0,...Pe.connector,kind:"default"};Me($,{id:$,type:"shapeNode",position:B,data:ke}),Oe(D,Tt),k($),Y(),(async()=>{try{await Q.createNode(dt),await Q.createConnector(Tt),G({do:async()=>{await Q.createNode(dt),await Q.createConnector(Tt)},undo:async()=>{je(D),qe($),await Q.deleteConnector(D).catch(()=>{}),await Q.deleteNode($).catch(()=>{})}})}catch(Kt){qe($),je(D),I(Kt instanceof Error?Kt.message:String(Kt)),console.error("createAndConnectFromPane failed",Kt)}})()},[le,Q,Me,qe,Oe,je,G,Y]),va=g.useRef(null),[To,bi]=g.useState(!1),Mn=g.useCallback(F=>{if(!te)return;const B=new Set(F),Z=te.filter(D=>B.has(D.id));if(Z.length===0)return;const $=(ie??[]).filter(D=>B.has(D.source)&&B.has(D.target));va.current=JSON.parse(JSON.stringify({nodes:Z,connectors:$})),bi(!0)},[te,ie]),tn=g.useCallback(F=>{if(!le||!Q)return;const B=va.current;if(!B||B.nodes.length===0)return;const{newNodes:Z,newConnectors:$}=aqe({nodes:B.nodes,connectors:B.connectors,flowPos:F,nodeIdGen:()=>`node-${crypto.randomUUID()}`,connectorIdGen:()=>`conn-${crypto.randomUUID()}`});for(const D of Z)Me(D.id,D);for(const D of $)Oe(D.id,D);d(Z.map(D=>D.id)),p($.map(D=>D.id)),I(null),Y(),(async()=>{try{for(const D of Z)await Q.createNode({id:D.id,type:D.type,position:D.position,data:D.data});for(const D of $)await Q.createConnector(D);G({do:async()=>{for(const D of Z)await Q.createNode({id:D.id,type:D.type,position:D.position,data:D.data});for(const D of $)await Q.createConnector(D)},undo:async()=>{await Promise.allSettled($.map(D=>Q.deleteConnector(D.id))),await Promise.allSettled(Z.map(D=>Q.deleteNode(D.id)))}})}catch(D){for(const ne of Z)qe(ne.id);for(const ne of $)je(ne.id);I(D instanceof Error?D.message:String(D)),console.error("paste failed",D)}})()},[le,Q,Me,qe,Oe,je,Y,G]);g.useEffect(()=>{const F=B=>{const Z=bMe({event:B,isEditableActive:Pr(document.activeElement),hasNodes:!!te&&te.length>0,hasConnectors:!!ie&&ie.length>0,selectedIds:w.current,hasClipboard:!!va.current});if(Z.type!=="noop"&&!(Z.type==="copy"||Z.type==="paste")){if(B.preventDefault(),Z.type==="selectAll"){d((te??[]).map($=>$.id)),p((ie??[]).map($=>$.id));return}Mn([...Z.ids]),tn(null)}};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[te,ie,Mn,tn]),g.useEffect(()=>{const F=B=>{const Z=xMe(B);if(!Z||Pr(document.activeElement))return;const $=w.current;if($.length===0)return;const D=S.overrides,ne=(te??[]).map(ke=>{var Tt;const dt=((Tt=D[ke.id])==null?void 0:Tt.position)??ke.position;return{id:ke.id,position:dt}}),Pe=MMe(Z,$,ne);if(Pe.length!==0)if(B.preventDefault(),Pe.length===1){const ke=Pe[0];ke&&he(ke.id,ke.position)}else Ie(Pe)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[te,S.overrides,he,Ie]),g.useEffect(()=>{const F=B=>{const Z=wMe(B);if(!Z||Pr(document.activeElement))return;B.preventDefault();const $=W.current;$&&(Z==="fit"?$.fitView({padding:.2,duration:200}):Z==="in"?$.zoomIn({duration:150}):$.zoomOut({duration:150}))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const Fn=g.useCallback(F=>{if(!le||!Q||!te)return;const B=S.overrides,Z=W.current,$=F==="selection"?new Set(w.current):null,D=$?te.filter(Ne=>$.has(Ne.id)):te;if(D.length<2)return;const ne=new Set(D.map(Ne=>Ne.id)),Pe=(ie??[]).filter(Ne=>ne.has(Ne.source)&&ne.has(Ne.target)),ke=D.map(Ne=>{var Si;const it=((Si=B[Ne.id])==null?void 0:Si.position)??Ne.position,jt=Z==null?void 0:Z.getInternalNode(Ne.id),Bn=jt==null?void 0:jt.measured,Vn=Ne.data,QT=(Bn==null?void 0:Bn.width)??Vn.width??200,JT=(Bn==null?void 0:Bn.height)??Vn.height??120;return{id:Ne.id,width:QT,height:JT,position:it}}),dt=Pe.map(Ne=>({source:Ne.source,target:Ne.target})),Tt=eae(ke,dt);let Sn=Number.POSITIVE_INFINITY,Kt=Number.POSITIVE_INFINITY,Lr=Number.POSITIVE_INFINITY,wa=Number.POSITIVE_INFINITY;for(const Ne of ke){Ne.position.x<Sn&&(Sn=Ne.position.x),Ne.position.y<Kt&&(Kt=Ne.position.y);const it=Tt.get(Ne.id);it&&(it.x<Lr&&(Lr=it.x),it.y<wa&&(wa=it.y))}const Zu=Number.isFinite(Sn)&&Number.isFinite(Lr)?Sn-Lr:0,_e=Number.isFinite(Kt)&&Number.isFinite(wa)?Kt-wa:0,nt=[];for(const Ne of ke){const it=Tt.get(Ne.id);if(!it)continue;const jt={x:it.x+Zu,y:it.y+_e},Bn=jt.x-Ne.position.x,Vn=jt.y-Ne.position.y;Math.abs(Bn)<1&&Math.abs(Vn)<1||nt.push({id:Ne.id,prev:Ne.position,next:jt})}if(nt.length!==0){I(null);for(const Ne of nt)Me(Ne.id,{position:Ne.next});Y(),G({do:async()=>{await Promise.allSettled(nt.map(Ne=>Q.updateNodePosition(Ne.id,Ne.next)))},undo:async()=>{await Promise.allSettled(nt.map(Ne=>Q.updateNodePosition(Ne.id,Ne.prev)))}}),Promise.all(nt.map(async Ne=>{try{return await Q.updateNodePosition(Ne.id,Ne.next),null}catch(it){return qe(Ne.id),it instanceof Error?it.message:String(it)}})).then(Ne=>{const it=Ne.filter(Bn=>Bn!==null),jt=it[0];jt&&(I(it.length===1?jt:`${it.length} node updates failed (first: ${jt})`),console.error("Tidy: some updateNodePosition calls failed",it))})}},[le,Q,te,ie,S.overrides,Me,qe,G,Y]);g.useEffect(()=>{const F=B=>{if(!(B.metaKey||B.ctrlKey)||!B.shiftKey||B.altKey||B.key.toLowerCase()!=="l"||Pr(document.activeElement))return;B.preventDefault();const Z=w.current.length>0?"selection":"all";Fn(Z)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[Fn]);const no=g.useCallback(()=>{const F=w.current.length>0?"selection":"all";Fn(F)},[Fn]);g.useEffect(()=>{const F=B=>{if(Pr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=CMe(B);if(Z===null)return;const $=Z==="select"?null:Z;if(H.current===$){j(null);return}j($)};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]),g.useEffect(()=>{const F=B=>{B.key==="Escape"&&(Pr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]')||(w.current.length>0&&d([]),v.current.length>0&&p([]),H.current!==null&&j(null)))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]),g.useEffect(()=>{const F=B=>{if(B.key.toLowerCase()!=="f"||B.metaKey||B.ctrlKey||B.shiftKey||B.altKey||Pr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=w.current;if(Z.length===0)return;const $=W.current;$&&$.fitView({nodes:Z.map(D=>({id:D})),padding:.2,duration:200})};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]),g.useEffect(()=>{const F=B=>{if(B.key!=="1"||B.metaKey||B.ctrlKey||B.shiftKey||B.altKey||Pr(document.activeElement)||document.querySelector('[data-testid="inline-edit-input"]'))return;const Z=W.current;if(!Z)return;const{x:$,y:D}=Z.getViewport();Z.setViewport({x:$,y:D,zoom:1},{duration:150})};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const jo=g.useCallback(F=>{var B,Z,$;switch(F){case"tool.select":j(null);return;case"tool.rectangle":j("rectangle");return;case"tool.ellipse":j("ellipse");return;case"tool.text":j("text");return;case"tool.sticky":j("sticky");return;case"tool.database":j("database");return;case"edit.undo":{if(!qn)return;(async()=>{try{const D=await Qr();D!=null&&D.entry&&await D.entry.undo()}catch(D){I(D instanceof Error?D.message:String(D)),console.error("undo failed",D)}})();return}case"edit.redo":{if(!xn)return;(async()=>{try{const D=await Po();D!=null&&D.entry&&await D.entry.do()}catch(D){I(D instanceof Error?D.message:String(D)),console.error("redo failed",D)}})();return}case"edit.copy":{const D=w.current;if(D.length===0)return;Mn([...D]);return}case"edit.paste":tn(null);return;case"edit.duplicate":{const D=w.current;if(D.length===0)return;Mn([...D]),tn(null);return}case"edit.delete":{const D=w.current,ne=v.current;if(D.length===0&&ne.length===0)return;yt([...D],[...ne]);return}case"edit.selectAll":d((te??[]).map(D=>D.id)),p((ie??[]).map(D=>D.id));return;case"view.fit":{const D=W.current;if(!D)return;D.fitView({padding:.2,duration:200});return}case"view.zoomIn":{const D=W.current;if(!D)return;D.zoomIn({duration:150});return}case"view.zoomOut":{const D=W.current;if(!D)return;D.zoomOut({duration:150});return}case"view.zoom100":{const D=W.current;if(!D)return;const{x:ne,y:Pe}=D.getViewport();D.setViewport({x:ne,y:Pe,zoom:1},{duration:150});return}case"view.zoomToSelection":{const D=w.current;if(D.length===0)return;const ne=W.current;if(!ne)return;ne.fitView({nodes:D.map(Pe=>({id:Pe})),padding:.2,duration:200});return}case"layout.tidy":{const D=w.current.length>0?"selection":"all";Fn(D);return}case"selection.deselect":w.current.length>0&&d([]),v.current.length>0&&p([]),H.current!==null&&j(null);return;case"help.commandPalette":U(!0);return;case"export.pdf":{(B=b.current)==null||B.exportPdf();return}case"export.png":{(Z=b.current)==null||Z.exportPng();return}case"session.reset":{($=x.current)==null||$.call(x);return}}},[qn,xn,Qr,Po,Mn,tn,yt,te,ie,Fn]);g.useEffect(()=>{const F=B=>{(B.metaKey||B.ctrlKey)&&(B.shiftKey||B.altKey||B.key.toLowerCase()==="p"&&(B.preventDefault(),!Pr(document.activeElement)&&jo("help.commandPalette")))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[jo]),g.useEffect(()=>{x.current=c??null},[c]);const Hn=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=ie==null?void 0:ie.find(ne=>ne.id===F),$=Z?{source:Z.source,target:Z.target,sourceHandle:Z.sourceHandle,targetHandle:Z.targetHandle,sourceHandleAutoPicked:Z.sourceHandleAutoPicked,targetHandleAutoPicked:Z.targetHandleAutoPicked,sourcePin:Z.sourcePin??null,targetPin:Z.targetPin??null}:null,D={...B.source!==void 0?{source:B.source}:{},...B.target!==void 0?{target:B.target}:{},...B.sourceHandle!==void 0?{sourceHandle:B.sourceHandle===null?void 0:B.sourceHandle}:{},...B.targetHandle!==void 0?{targetHandle:B.targetHandle===null?void 0:B.targetHandle}:{},...B.sourceHandleAutoPicked!==void 0?{sourceHandleAutoPicked:B.sourceHandleAutoPicked}:{},...B.targetHandleAutoPicked!==void 0?{targetHandleAutoPicked:B.targetHandleAutoPicked}:{},...B.sourcePin!==void 0?{sourcePin:B.sourcePin===null?void 0:B.sourcePin}:{},...B.targetPin!==void 0?{targetPin:B.targetPin===null?void 0:B.targetPin}:{}};if(Oe(F,D),I(null),Y(),$){const ne=$;G({do:async()=>{await Q.updateConnector(F,B)},undo:async()=>{await Q.updateConnector(F,ne)},coalesceKey:`connector:${F}:reconnect`})}Q.updateConnector(F,B).catch(ne=>{je(F),$&&X(),I(ne instanceof Error?ne.message:String(ne)),console.error("updateConnector reconnect failed",ne)})},[le,Q,ie,Oe,je,G,X,Y]),xa=g.useCallback((F,B,Z)=>{if(!le||!Q)return;const $=ie==null?void 0:ie.find(Pe=>Pe.id===F),D=$?B==="source"?$.sourcePin:$.targetPin:void 0,ne=B==="source"?"sourcePin":"targetPin";if(Oe(F,{[ne]:Z}),I(null),Y(),$){const Pe={[ne]:D??null};G({do:async()=>{await Q.updateConnector(F,{[ne]:Z})},undo:async()=>{await Q.updateConnector(F,Pe)},coalesceKey:`connector:${F}:${ne}`})}Q.updateConnector(F,{[ne]:Z}).catch(Pe=>{je(F),$&&X(),I(Pe instanceof Error?Pe.message:String(Pe)),console.error("updateConnector pin failed",Pe)})},[le,Q,ie,Oe,je,G,X,Y]),Cr=g.useCallback((F,B)=>{if(!le||!Q)return;const Z=ie==null?void 0:ie.find(ne=>ne.id===F),$=Z?B==="source"?Z.sourcePin:Z.targetPin:void 0;if(!$)return;const D=B==="source"?"sourcePin":"targetPin";Oe(F,{[D]:void 0}),I(null),Y(),G({do:async()=>{await Q.updateConnector(F,{[D]:null})},undo:async()=>{await Q.updateConnector(F,{[D]:$})}}),Q.updateConnector(F,{[D]:null}).catch(ne=>{je(F),X(),I(ne instanceof Error?ne.message:String(ne)),console.error("updateConnector unpin failed",ne)})},[le,Q,ie,Oe,je,G,X,Y]),st=n==null?void 0:n.flow,Sr=S.overrides,bn=C.overrides,Cn=L.ids,Ci=P.ids,Gu=g.useMemo(()=>{if(!st||u.length===0)return[];const F=new Map(st.nodes.map(Z=>[Z.id,Z])),B=[];for(const Z of u){const $=F.get(Z);if(!$)continue;const D=Sr[Z];if(!D){B.push($);continue}const ne=D.data?{...$.data,...D.data}:$.data;B.push({...$,...D,data:ne})}return B},[st,u,Sr]),YT=g.useMemo(()=>{if(!st||f.length===0)return[];const F=new Map(st.connectors.map(Z=>[Z.id,Z])),B=[];for(const Z of f){const $=F.get(Z);if(!$)continue;const D=bn[Z];B.push(D?{...$,...D}:$)}return B},[st,f,bn]),ro=g.useMemo(()=>{if(!st)return null;if(!T)return st.nodes;const F=new Map(st.nodes.map($=>[$.id,$])),B=[],Z=new Set;for(const $ of T){const D=F.get($);D&&(B.push(D),Z.add($))}for(const $ of st.nodes)Z.has($.id)||B.push($);return B},[st,T]),Ku=g.useMemo(()=>{const F=ro??(st==null?void 0:st.nodes)??null;return F?Cn.size===0?F:F.filter(B=>!Cn.has(B.id)):null},[ro,st,Cn]),Of=g.useMemo(()=>{const F=(st==null?void 0:st.connectors)??null;return F?Ci.size===0&&Cn.size===0?F:F.filter(B=>!Ci.has(B.id)&&!Cn.has(B.source)&&!Cn.has(B.target)):null},[st,Ci,Cn]);if(!l)return m.jsxs("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2 bg-background p-6 text-center",children:[m.jsxs("p",{className:"text-sm font-medium",children:["Unknown demo: ",e]}),m.jsx("p",{className:"text-xs text-muted-foreground",children:"The slug may have been removed. Re-register from the project repo to bring it back."})]});if(r&&!n)return m.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"Loading demo…"});const No=u[0],Ff=No?i[No]:void 0;return m.jsxs("div",{className:"relative h-full w-full",children:[n&&!n.valid?m.jsxs("div",{"data-testid":"demo-error-banner",className:"absolute inset-x-0 top-0 z-10 border-b border-rose-500/40 bg-rose-50 px-4 py-2 text-xs text-rose-900 shadow-xs dark:bg-rose-950/40 dark:text-rose-100",children:[m.jsx("span",{className:"font-medium uppercase tracking-wide",children:"Invalid demo: "}),m.jsx("span",{className:"font-mono",children:n.error})]}):null,st&&Q?m.jsx(Xze,{ref:b,mode:"edit",adapter:Q,projectId:le??void 0,enableEmbed:!1,onExportToCloud:le?()=>ge(!0):void 0,onRestartDemo:c,nodes:Ku??st.nodes,connectors:Of??st.connectors,selectedNodeIds:u,selectedConnectorIds:f,onSelectionChange:we,runtime:{runs:o,statuses:i,pendingOverrides:{nodes:Sr,connectors:bn}},onPlayNode:s,onNodePositionChange:he,onNodePositionsChange:Ie,onNodeResize:He,onHtmlNodeFitToContent:Ue,onMultiResize:Rt,onNodeNameChange:_o,onNodeDescriptionChange:On,onConnectorLabelChange:wn,onCreateShapeNode:Gt,onCreateImageFromFile:le?xi:void 0,onRetryImageUpload:le?ya:void 0,onCreateHtmlNode:le?pa:void 0,iconPickerOpen:Mr.open,onOpenIconPicker:le?wi:void 0,onCloseIconPicker:le?ma:void 0,onPickIcon:le?ga:void 0,onRequestIconReplace:le?Mi:void 0,onCreateConnector:Ro,onReconnectConnector:Hn,onPinEndpoint:le?xa:void 0,onUnpinEndpoint:le?Cr:void 0,onReorderNode:Ve,onDeleteNode:Wu,onCopyNode:F=>Mn([F]),onPasteAt:tn,onCopySelection:le?Mn:void 0,onPasteSelection:le?()=>tn(null):void 0,onToggleNodeLock:le?$u:void 0,hasClipboard:To,selectedNodes:Gu,selectedConnectors:YT,onStyleNode:Dn,onStyleNodePreview:Pt,onStyleNodes:en,onStyleNodesPreview:sr,onStyleConnector:Uu,onStyleConnectorPreview:Dt,onRfInit:q,onTidy:te?no:void 0,onCreateAndConnectFromPane:ka,pendingEditNodeId:y,activeShape:V,onSelectShape:j,statusReport:Ff,onNameChange:_o,onDescriptionChange:On,onDetailChange:Jr,onIconChange:un,autoFitView:!0,autoFitViewSignal:z}):m.jsx("div",{className:"flex h-full w-full items-center justify-center text-sm text-muted-foreground",children:"No demo data yet."}),A?m.jsxs("div",{"data-testid":"edit-error-banner",className:"absolute inset-x-0 bottom-4 z-20 mx-auto w-fit max-w-[80%] rounded-md border border-rose-500/50 bg-rose-50 px-3 py-2 text-xs text-rose-900 shadow-md dark:bg-rose-950/60 dark:text-rose-100",children:[m.jsx("span",{className:"font-medium",children:"Couldn't save change: "}),m.jsx("span",{className:"font-mono",children:A}),m.jsx("button",{type:"button",className:"ml-3 underline underline-offset-2",onClick:()=>I(null),children:"Dismiss"})]}):null,m.jsx(xDe,{open:O,onOpenChange:U,runCommand:jo,ctx:{hasSelection:u.length>0||f.length>0,canUndo:qn,canRedo:xn,hasClipboard:To,canExportDemo:!!le,canResetSession:!!c}}),le?m.jsx(ODe,{open:ue,onOpenChange:ge,projectId:le,onCapturePreview:()=>{var F;return((F=b.current)==null?void 0:F.capturePreview())??Promise.resolve(void 0)}}):null]})}const Mte="npx seeflow register --path .";function fqe(){const[e,t]=g.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(Mte),t(!0),setTimeout(()=>t(!1),1200)}catch(r){console.error("[empty-state] copy failed",r)}};return m.jsx("div",{"data-testid":"seeflow-empty-state",className:"flex h-full w-full items-center justify-center bg-background p-6",children:m.jsxs("div",{className:"flex max-w-lg flex-col items-center gap-6 text-center",children:[m.jsx("div",{className:"flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:m.jsx(o2,{className:"h-6 w-6 text-muted-foreground"})}),m.jsxs("div",{className:"space-y-2",children:[m.jsx("h1",{className:"text-2xl font-semibold tracking-tight text-foreground",children:"No demos registered yet"}),m.jsxs("p",{className:"text-sm text-muted-foreground",children:["Point SeeFlow at any folder containing a"," ",m.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs",children:".seeflow/seeflow.json"})," ","file and it'll appear here."]})]}),m.jsxs("div",{className:"flex w-full items-center gap-2 rounded-md border border-border bg-card px-3 py-2 font-mono text-sm",children:[m.jsx("span",{className:"text-muted-foreground select-none",children:"$"}),m.jsx("code",{className:"flex-1 truncate text-left",children:Mte}),m.jsx(Ft,{type:"button",variant:"ghost",size:"sm",onClick:n,"aria-label":"Copy register command",children:e?m.jsx(Ja,{className:"h-4 w-4"}):m.jsx(T1,{className:"h-4 w-4"})})]})]})})}function pqe({demos:e}){return e.length===0?m.jsx(fqe,{}):m.jsx("div",{className:"flex h-full w-full items-start justify-center overflow-y-auto bg-background p-8",children:m.jsxs("div",{"data-testid":"studio-home-picker",className:"flex w-full max-w-2xl flex-col gap-6 pt-8",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Open a demo"}),m.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.length," demos registered — pick one to load its canvas."]})]}),m.jsx("ul",{className:"flex flex-col gap-2",children:e.map(t=>m.jsx("li",{children:m.jsxs("button",{type:"button",onClick:()=>md(`/d/${t.slug}`),"data-testid":`studio-home-demo-${t.slug}`,className:"flex w-full flex-col items-start gap-0.5 rounded-lg border border-border bg-card px-4 py-3 text-left transition-colors hover:border-input",style:{boxShadow:"var(--shadow-card)"},children:[m.jsx("span",{className:"text-sm font-medium",children:t.name}),m.jsx("span",{className:"truncate text-xs text-muted-foreground",children:t.repoPath})]})},t.id))})]})})}const yqe=e=>{if(!e.startsWith("/d/"))return null;const t=e.slice(3);return t.length>0?decodeURIComponent(t):null};function mqe(){const e=Jze(),{demos:t,refresh:n}=rDe(),r=yqe(e),o=r?(t??[]).find(C=>C.slug===r):void 0,a=(o==null?void 0:o.id)??null,{detail:i,loading:s,refresh:c}=nDe(a),{runs:l,apply:u}=lDe(a),{events:d,apply:f}=sDe(a),{statusByNode:p,apply:y,reset:k}=fDe(a),w=g.useCallback(()=>{k(),c(),n()},[c,n,k]),v=g.useCallback(C=>{u(C),f(C),y(C)},[u,f,y]);pDe(a,{onReload:w,onEvent:v});const M=g.useCallback(async()=>{if(a)try{await Efe(a)}catch(C){console.error("Failed to restart demo:",C)}},[a]),x=g.useCallback(C=>{ste(C.id),n()},[n]),b=g.useCallback(async C=>{await n(),a===C&&md("/")},[n,a]);g.useEffect(()=>{if(e!=="/"||t===null)return;const C=mDe(t,yDe());C&&md(`/d/${C.slug}`)},[e,t]),g.useEffect(()=>{o&&ste(o.id)},[o]);const S=g.useCallback(C=>{a&&Afe(a,C).catch(L=>{u({type:"node:error",nodeId:C,message:L instanceof Error?L.message:String(L),ts:Date.now()})})},[a,u]);return t===null?m.jsx("div",{className:"flex h-full w-full items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):m.jsx(d2,{delayDuration:150,children:m.jsxs("div",{className:"flex h-full w-full flex-col bg-background text-foreground",children:[m.jsx(tDe,{demos:t,currentSlug:r??void 0,onProjectCreated:x,onProjectUnregistered:b}),m.jsx("main",{className:"min-h-0 flex-1",children:r?m.jsx(hqe,{slug:r,demos:t,detail:i,loading:s,runs:l,nodeEvents:d,statusByNode:p,onPlayNode:S,onRestartDemo:a?M:void 0}):m.jsx(pqe,{demos:t})})]})})}const Mde=document.getElementById("root");if(!Mde)throw new Error("Root element #root not found");MF.createRoot(Mde).render(m.jsx(ho.StrictMode,{children:m.jsx(mqe,{})}));export{PNe as _,Ba as c,gd as g,vqe as z};
|