funcnodes-react-flow 1.0.1__py3-none-any.whl → 1.0.2__py3-none-any.whl

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.
@@ -779,12 +779,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
779
779
  `+t.error),n=t.id&&this.messagePromises.get(t.id),n)return n.reject(t.error);break;case"progress":if(!this.context.worker._zustand)return;this.context.worker._zustand.set_progress(t);break;case"workerevent":return await this.context.worker.getEventManager().receive_workerevent(t);case"large_message":return await this.context.worker.handle_large_message_hint(t);default:console.warn("Unhandled message",t);break}}async recieve_bytes(t,n){const{type:r}=t;if(r==="io_value"){if(!this.context.worker._zustand)return;const{node:o,io:a,preview:s,mime:u}=t,c=s?"value":"fullvalue";(!o||!a)&&console.error("Invalid io_value message",t);const f=CA({data:n,mime:u||"application/octet-stream"});this.context.worker._zustand.on_node_action({type:"update",node:{id:o,io:{[a]:{[c]:f}}},id:o,from_remote:!0})}else if(r=="result"){const o=t.id&&this.messagePromises.get(t.id);o&&o.resolve({bytes:n,header:t})}else console.warn("Unhandled bytes message",t)}async onbytes(t){try{const n=new TextDecoder("utf-8").decode(t),r=n.indexOf(`\r
780
780
  \r
781
781
  `);if(r===-1){console.error(`Header terminator not found for:
782
- `,n);return}const o=n.substring(0,r+4),a=t.slice(r+4),s=o.split(";"),u={};if(s.forEach(p=>{const[g,y]=p.split("=");u[g.trim()]=y.trim()}),!u.chunk||!u.msgid){console.error("Header missing required fields chunk or msgid",u);return}const[c,f]=u.chunk.split("/"),h=u.msgid;if(c==="1"&&f==="1")return this.recieve_bytes(u,a);if(this.blobChunks[h]||(this.blobChunks[h]={chunks:Array.from({length:parseInt(f)},()=>null),timestamp:Date.now()}),this.blobChunks[h].chunks.length!==parseInt(f)){console.error("Total chunks mismatch");return}if(this.blobChunks[h].chunks[parseInt(c)-1]=t,this.blobChunks[h].chunks.every(p=>p!==null)){const p=new Uint8Array(this.blobChunks[h].chunks.reduce((g,y)=>g.concat(Array.from(y)),[]));this.recieve_bytes(u,p),delete this.blobChunks[h]}}catch(n){console.error("Websocketworker: onbytes error",n,t);return}}}class RY extends Uo{constructor(){super(...arguments),this._ns_event_intercepts=new Map}start(){}stop(){}async _receive_edge_added(t,n,r,o){this.context.worker._zustand&&this.context.worker._zustand.on_edge_action({type:"add",from_remote:!0,src_nid:t,src_ioid:n,trg_nid:r,trg_ioid:o})}async _receive_groups(t){this.context.worker._zustand&&this.context.worker._zustand.on_group_action({type:"set",groups:t})}async _receive_node_added(t){if(this.context.worker._zustand)return this.context.worker._zustand.on_node_action({type:"add",node:t,id:t.id,from_remote:!0})}async receive_workerevent({event:t,data:n}){switch(t){case"worker_error":return this.context.worker._zustand?this.context.worker._zustand.logger.error(n.error):void 0;case"update_worker_dependencies":return this.context.worker._zustand?this.context.worker._zustand.lib.libstate.getState().set({external_worker:n.worker_dependencies}):void 0;case"lib_update":await this.context.worker.getSyncManager().sync_lib();return;case"fullsync":await this.context.worker.getSyncManager().stepwise_fullsync();return;case"external_worker_update":await this.context.worker.getSyncManager().sync_lib(),await this.context.worker.getSyncManager().sync_external_worker();return;case"starting":this.hookManager.call_hooks("starting");return;case"stopping":this.hookManager.call_hooks("stopping");return;default:console.warn("Unhandled worker event",t,n);break}}async intercept_ns_event(t){let n=t;for(const r of this._ns_event_intercepts.get(t.event)||[])n=await r(n);return n}async receive_nodespace_event(t){const{event:n,data:r}=await this.intercept_ns_event(t);switch(n){case"after_set_value":return this.context.worker._zustand?this.context.worker._zustand.on_node_action({type:"update",node:{id:r.node,io:{[r.io]:{value:r.result}}},id:r.node,from_remote:!0}):void 0;case"after_update_value_options":return this.context.worker._zustand?this.context.worker._zustand.on_node_action({type:"update",node:{id:r.node,io:{[r.io]:{value_options:r.result}}},id:r.node,from_remote:!0}):void 0;case"triggerstart":return this.context.worker._zustand?this.context.worker._zustand.on_node_action({type:"update",node:{id:r.node,in_trigger:!0},id:r.node,from_remote:!0}):void 0;case"triggerdone":return this.context.worker._zustand?this.context.worker._zustand.on_node_action({type:"update",node:{id:r.node,in_trigger:!1},id:r.node,from_remote:!0}):void 0;case"triggerfast":if(!this.context.worker._zustand)return;this.context.worker._zustand.on_node_action({type:"update",node:{id:r.node,in_trigger:!0},id:r.node,from_remote:!0}),setTimeout(()=>{this.context.worker._zustand&&this.context.worker._zustand.on_node_action({type:"update",node:{id:r.node,in_trigger:!1},id:r.node,from_remote:!0})},50);return;case"node_trigger_error":return this.context.worker._zustand?this.context.worker._zustand.on_node_action({type:"error",errortype:"trigger",error:r.error,id:r.node,tb:r.tb,from_remote:!0}):void 0;case"node_removed":if(!this.context.worker._zustand)return;this.context.worker._zustand.on_node_action({type:"delete",id:r.node,from_remote:!0}),this.hookManager.call_hooks("node_removed",{node:r.node});return;case"node_added":this._receive_node_added(r.node);return;case"after_disconnect":return!r.result||!Array.isArray(r.result)||r.result.length!==4||!this.context.worker._zustand?void 0:this.context.worker._zustand.on_edge_action({type:"delete",from_remote:!0,src_nid:r.result[0],src_ioid:r.result[1],trg_nid:r.result[2],trg_ioid:r.result[3]});case"after_unforward":return!r.result||!Array.isArray(r.result)||r.result.length!==4||!this.context.worker._zustand?void 0:this.context.worker._zustand.on_edge_action({type:"delete",from_remote:!0,src_nid:r.result[0],src_ioid:r.result[1],trg_nid:r.result[2],trg_ioid:r.result[3]});case"after_connect":return!r.result||!Array.isArray(r.result)||r.result.length!==4?void 0:this._receive_edge_added(...r.result);case"after_forward":return!r.result||!Array.isArray(r.result)||r.result.length!==4?void 0:this._receive_edge_added(...r.result);case"after_add_shelf":return!r.result||!this.context.worker._zustand?void 0:this.context.worker._zustand.lib.libstate.getState().set({lib:r.result});case"after_remove_shelf":return!r.result||!this.context.worker._zustand?void 0:this.context.worker._zustand.lib.libstate.getState().set({lib:r.result});case"progress":if(!this.context.worker._zustand)return;if(r.node)return this.context.worker._zustand.on_node_action({type:"update",node:{id:r.node,progress:r.info},id:r.node,from_remote:!0});console.warn("Unhandled nodepsace event",n,r);break;default:if(["after_set_nodespace"].includes(n))return;console.warn("Unhandled nodepsace event",n,r);break}}add_ns_event_intercept(t,n){const r=this._ns_event_intercepts.get(t)||[];return r.push(n),this._ns_event_intercepts.set(t,r),()=>{const a=this._ns_event_intercepts.get(t)||[],s=a.indexOf(n);s>=0&&a.splice(s,1)}}}class MY extends Uo{constructor(){super(...arguments),this._hooks=new Map}start(){}stop(){}add_hook(t,n){const r=this._hooks.get(t)||[];return r.push(n),this._hooks.set(t,r),()=>{const a=this._hooks.get(t)||[],s=a.indexOf(n);s>=0&&a.splice(s,1)}}async call_hooks(t,n){const r=[];for(const o of this._hooks.get(t)||[]){const a=o({worker:this.context.worker,data:n});a instanceof Promise&&r.push(a)}await Promise.all(r)}}class OY extends Uo{start(){}stop(){}async trigger_node(t){await this.communicationManager._send_cmd({cmd:"trigger_node",kwargs:{nid:t},wait_for_response:!1})}async add_node(t){const n=await this.communicationManager._send_cmd({cmd:"add_node",kwargs:{id:t}});return this.eventManager._receive_node_added(n)}async remove_node(t){await this.communicationManager._send_cmd({cmd:"remove_node",kwargs:{id:t}})}locally_update_node(t){this.syncManager.locally_update_node(t)}set_io_value({nid:t,ioid:n,value:r,set_default:o=!1}){return this.communicationManager._send_cmd({cmd:"set_io_value",kwargs:{nid:t,ioid:n,value:r,set_default:o},wait_for_response:!0})}set_io_value_options({nid:t,ioid:n,values:r,keys:o,nullable:a}){return this.communicationManager._send_cmd({cmd:"update_io_value_options",kwargs:{nid:t,ioid:n,options:{options:{type:"enum",values:r,keys:o,nullable:a}}}})}async get_io_value({nid:t,ioid:n}){const r=await this.communicationManager._send_cmd({cmd:"get_io_value",kwargs:{nid:t,ioid:n},wait_for_response:!0});return this.context.worker._zustand&&this.context.worker._zustand.on_node_action({type:"update",node:{io:{[n]:{value:r}}},id:t,from_remote:!0}),r}async get_ios_values({nid:t}){const n=await this.communicationManager._send_cmd({cmd:"get_ios_values",kwargs:{nid:t},wait_for_response:!0});if(!this.context.worker._zustand)return n;const r={};for(const o in n)r[o]={value:n[o]};return this.context.worker._zustand.on_node_action({type:"update",node:{io:r},id:t,from_remote:!0}),n}async get_io_full_value({nid:t,ioid:n}){const r=await this.communicationManager._send_cmd({cmd:"get_io_full_value",kwargs:{nid:t,ioid:n},wait_for_response:!0,as_bytes:!0}),{header:o,bytes:a}=r,{mime:s}=o,u=CA({data:a,mime:s||"application/octet-stream"});return this.context.worker._zustand?.on_node_action?.({type:"update",node:{id:t,io:{[n]:{fullvalue:u}}},id:t,from_remote:!0}),u}async update_io_options({nid:t,ioid:n,options:r}){const o=await this.communicationManager._send_cmd({cmd:"update_io_options",kwargs:{nid:t,ioid:n,...r},wait_for_response:!0});if(!this.context.worker._zustand)return o;this.context.worker._zustand.on_node_action({type:"update",node:{io:{[n]:{...r}}},id:t,from_remote:!0})}async get_node_status(t){return await this.communicationManager._send_cmd({cmd:"get_node_state",kwargs:{nid:t},wait_for_response:!0})}async get_remote_node_state(t){const n=await this.communicationManager._send_cmd({cmd:"get_node_state",kwargs:{nid:t},wait_for_response:!0});this.context.worker._zustand&&this.context.worker._zustand.on_node_action({type:"update",node:n,id:n.id,from_remote:!0})}}class NY extends Uo{start(){}stop(){}add_edge({src_nid:t,src_ioid:n,trg_nid:r,trg_ioid:o,replace:a=!1}){return this.communicationManager._send_cmd({cmd:"add_edge",kwargs:{src_nid:t,src_ioid:n,trg_nid:r,trg_ioid:o,replace:a}})}remove_edge({src_nid:t,src_ioid:n,trg_nid:r,trg_ioid:o}){return this.communicationManager._send_cmd({cmd:"remove_edge",kwargs:{src_nid:t,src_ioid:n,trg_nid:r,trg_ioid:o}})}}class DY extends Uo{start(){}stop(){}async group_nodes(t,n){const r=await this.communicationManager._send_cmd({cmd:"group_nodes",kwargs:{node_ids:t,group_ids:n},wait_for_response:!0});return this.eventManager._receive_groups(r),r}async remove_group(t){await this.communicationManager._send_cmd({cmd:"remove_group",kwargs:{gid:t},wait_for_response:!0}),await this.syncManager.sync_nodespace()}locally_update_group(t){this.syncManager.locally_update_group(t)}}class PY extends Uo{start(){}stop(){}async add_external_worker({module:t,cls_module:n,cls_name:r}){return await this.communicationManager._send_cmd({cmd:"add_external_worker",kwargs:{module:t,cls_module:n,cls_name:r}})}async add_lib(t,n){return await this.communicationManager._send_cmd({cmd:"add_package_dependency",kwargs:{name:t,version:n},wait_for_response:!1})}async remove_lib(t){return await this.communicationManager._send_cmd({cmd:"remove_package_dependency",kwargs:{name:t},wait_for_response:!1})}async get_available_modules(){return await this.communicationManager._send_cmd({cmd:"get_available_modules",wait_for_response:!0,unique:!0})}async remove_external_worker(t,n){return await this.communicationManager._send_cmd({cmd:"remove_external_worker",kwargs:{worker_id:t,class_id:n},wait_for_response:!0})}}class jY{getEventManager(){return this._eventManager}getSyncManager(){return this._syncManager}getCommunicationManager(){return this._communicationManager}getConnectionHealthManager(){return this._connectionhealthManager}getHookManager(){return this._hookManager}getNodeManager(){return this._nodeManager}getEdgeManager(){return this._edgeManager}getGroupManager(){return this._groupManager}getLibraryManager(){return this._libraryManager}constructor(t){this.uuid=t.uuid,this.on_error=t.on_error||(r=>{this._zustand?.logger.error(r)}),this.state=gr((r,o)=>({is_open:!1}));const n={worker:this};this._connectionhealthManager=new CY(n),this._communicationManager=new AY(n),this._eventManager=new RY({...n}),this._syncManager=new kY({...n,on_sync_complete:t.on_sync_complete}),this._hookManager=new MY(n),this._nodeManager=new OY(n),this._edgeManager=new NY(n),this._groupManager=new DY(n),this._libraryManager=new PY(n),this._communicationManager.start(),this._connectionhealthManager.start(),this._syncManager.start(),this._eventManager.start(),this._hookManager.start(),this._nodeManager.start(),this._edgeManager.start(),this._groupManager.start(),this._libraryManager.start(),t.zustand&&this.set_zustand(t.zustand),this.api={node:this._nodeManager,group:this._groupManager,edge:this._edgeManager,hooks:this._hookManager,lib:this._libraryManager}}set_zustand(t){t!==this._zustand&&(this._zustand=t,t.set_worker(this),this._zustand.auto_progress(),this._syncManager.stepwise_fullsync())}get is_open(){return this.state.getState().is_open}set is_open(t){this.state.setState({is_open:t})}get is_responsive(){return this._connectionhealthManager.isResponsive()}clear(){return this._communicationManager._send_cmd({cmd:"clear",unique:!0})}save(){return this._communicationManager._send_cmd({cmd:"save",wait_for_response:!0,unique:!0})}load(t){return this._communicationManager._send_cmd({cmd:"load_data",kwargs:{data:t},wait_for_response:!0}).then(()=>{this._syncManager.stepwise_fullsync()})}async get_runstate(){return await this._communicationManager._send_cmd({cmd:"get_runstate",wait_for_response:!0,unique:!0})}async send(t){throw new Error("async send(data: any) not implemented")}async upload_file(t){throw new Error("upload_file not implemented ")}async handle_large_message_hint({}){throw new Error("async handle_large_message_hint({}: LargeMessageHint) not implemented ")}disconnect(){}onclose(){this.is_open=!1,this._zustand&&this._zustand.auto_progress()}async reconnect(){}async stop(){await this._communicationManager._send_cmd({cmd:"stop_worker",wait_for_response:!1});const t=this.onclose.bind(this);this.onclose=()=>{t(),this._zustand&&(this._zustand.worker===this&&this._zustand.clear_all(),this.onclose=t)}}async update_external_worker(t,n,r){return await this._communicationManager._send_cmd({cmd:"update_external_worker",kwargs:{worker_id:t,class_id:n,...r},wait_for_response:!0})}async export({withFiles:t=!1}){return await this._communicationManager._send_cmd({cmd:"export_worker",wait_for_response:!0,kwargs:{with_files:t}})}async update_from_export(t){const n=this._hookManager.add_hook("node_added",async({})=>{this._zustand?.center_all()});try{const r=await this._communicationManager._send_cmd({cmd:"update_from_export",kwargs:{data:t},wait_for_response:!0,response_timeout:6e5,unique:!0});return await new Promise(o=>{setTimeout(()=>{o()},1e3)}),await this._syncManager.stepwise_fullsync(),r}finally{n()}}_send_cmd(t){return this._communicationManager._send_cmd(t)}set_io_value(t){return this._nodeManager.set_io_value(t)}get_io_value(t){return this._nodeManager.get_io_value(t)}}function kA(e,t){return function(){return e.apply(t,arguments)}}const{toString:IY}=Object.prototype,{getPrototypeOf:Gy}=Object,{iterator:mh,toStringTag:TA}=Symbol,gh=(e=>t=>{const n=IY.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),jr=e=>(e=e.toLowerCase(),t=>gh(t)===e),yh=e=>t=>typeof t===e,{isArray:Bs}=Array,Ru=yh("undefined");function Mu(e){return e!==null&&!Ru(e)&&e.constructor!==null&&!Ru(e.constructor)&&On(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const AA=jr("ArrayBuffer");function zY(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&AA(e.buffer),t}const LY=yh("string"),On=yh("function"),RA=yh("number"),Ou=e=>e!==null&&typeof e=="object",FY=e=>e===!0||e===!1,vh=e=>{if(gh(e)!=="object")return!1;const t=Gy(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(TA in e)&&!(mh in e)},$Y=e=>{if(!Ou(e)||Mu(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},BY=jr("Date"),HY=jr("File"),VY=jr("Blob"),UY=jr("FileList"),qY=e=>Ou(e)&&On(e.pipe),GY=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||On(e.append)&&((t=gh(e))==="formdata"||t==="object"&&On(e.toString)&&e.toString()==="[object FormData]"))},YY=jr("URLSearchParams"),[WY,XY,KY,ZY]=["ReadableStream","Request","Response","Headers"].map(jr),QY=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Nu(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Bs(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Mu(e))return;const a=n?Object.getOwnPropertyNames(e):Object.keys(e),s=a.length;let u;for(r=0;r<s;r++)u=a[r],t.call(null,e[u],u,e)}}function MA(e,t){if(Mu(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Ca=typeof globalThis<"u"?globalThis:typeof self<"u"?self:window,OA=e=>!Ru(e)&&e!==Ca;function Yy(){const{caseless:e}=OA(this)&&this||{},t={},n=(r,o)=>{const a=e&&MA(t,o)||o;vh(t[a])&&vh(r)?t[a]=Yy(t[a],r):vh(r)?t[a]=Yy({},r):Bs(r)?t[a]=r.slice():t[a]=r};for(let r=0,o=arguments.length;r<o;r++)arguments[r]&&Nu(arguments[r],n);return t}const JY=(e,t,n,{allOwnKeys:r}={})=>(Nu(t,(o,a)=>{n&&On(o)?e[a]=kA(o,n):e[a]=o},{allOwnKeys:r}),e),eW=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),tW=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},nW=(e,t,n,r)=>{let o,a,s;const u={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),a=o.length;a-- >0;)s=o[a],(!r||r(s,e,t))&&!u[s]&&(t[s]=e[s],u[s]=!0);e=n!==!1&&Gy(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},rW=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},oW=e=>{if(!e)return null;if(Bs(e))return e;let t=e.length;if(!RA(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},iW=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Gy(Uint8Array)),aW=(e,t)=>{const r=(e&&e[mh]).call(e);let o;for(;(o=r.next())&&!o.done;){const a=o.value;t.call(e,a[0],a[1])}},sW=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},lW=jr("HTMLFormElement"),uW=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),NA=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),cW=jr("RegExp"),DA=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Nu(n,(o,a)=>{let s;(s=t(o,a,e))!==!1&&(r[a]=s||o)}),Object.defineProperties(e,r)},fW=e=>{DA(e,(t,n)=>{if(On(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(On(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},dW=(e,t)=>{const n={},r=o=>{o.forEach(a=>{n[a]=!0})};return Bs(e)?r(e):r(String(e).split(t)),n},hW=()=>{},pW=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function mW(e){return!!(e&&On(e.append)&&e[TA]==="FormData"&&e[mh])}const gW=e=>{const t=new Array(10),n=(r,o)=>{if(Ou(r)){if(t.indexOf(r)>=0)return;if(Mu(r))return r;if(!("toJSON"in r)){t[o]=r;const a=Bs(r)?[]:{};return Nu(r,(s,u)=>{const c=n(s,o+1);!Ru(c)&&(a[u]=c)}),t[o]=void 0,a}}return r};return n(e,0)},yW=jr("AsyncFunction"),vW=e=>e&&(Ou(e)||On(e))&&On(e.then)&&On(e.catch),PA=((e,t)=>e?setImmediate:t?((n,r)=>(Ca.addEventListener("message",({source:o,data:a})=>{o===Ca&&a===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Ca.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",On(Ca.postMessage)),bW=typeof queueMicrotask<"u"?queueMicrotask.bind(Ca):typeof process<"u"&&process.nextTick||PA,ie={isArray:Bs,isArrayBuffer:AA,isBuffer:Mu,isFormData:GY,isArrayBufferView:zY,isString:LY,isNumber:RA,isBoolean:FY,isObject:Ou,isPlainObject:vh,isEmptyObject:$Y,isReadableStream:WY,isRequest:XY,isResponse:KY,isHeaders:ZY,isUndefined:Ru,isDate:BY,isFile:HY,isBlob:VY,isRegExp:cW,isFunction:On,isStream:qY,isURLSearchParams:YY,isTypedArray:iW,isFileList:UY,forEach:Nu,merge:Yy,extend:JY,trim:QY,stripBOM:eW,inherits:tW,toFlatObject:nW,kindOf:gh,kindOfTest:jr,endsWith:rW,toArray:oW,forEachEntry:aW,matchAll:sW,isHTMLForm:lW,hasOwnProperty:NA,hasOwnProp:NA,reduceDescriptors:DA,freezeMethods:fW,toObjectSet:dW,toCamelCase:uW,noop:hW,toFiniteNumber:pW,findKey:MA,global:Ca,isContextDefined:OA,isSpecCompliantForm:mW,toJSONObject:gW,isAsyncFn:yW,isThenable:vW,setImmediate:PA,asap:bW,isIterable:e=>e!=null&&On(e[mh])};function Fe(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}ie.inherits(Fe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ie.toJSONObject(this.config),code:this.code,status:this.status}}});const jA=Fe.prototype,IA={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{IA[e]={value:e}}),Object.defineProperties(Fe,IA),Object.defineProperty(jA,"isAxiosError",{value:!0}),Fe.from=(e,t,n,r,o,a)=>{const s=Object.create(jA);return ie.toFlatObject(e,s,function(c){return c!==Error.prototype},u=>u!=="isAxiosError"),Fe.call(s,e.message,t,n,r,o),s.cause=e,s.name=e.name,a&&Object.assign(s,a),s};const xW=null;function Wy(e){return ie.isPlainObject(e)||ie.isArray(e)}function zA(e){return ie.endsWith(e,"[]")?e.slice(0,-2):e}function LA(e,t,n){return e?e.concat(t).map(function(o,a){return o=zA(o),!n&&a?"["+o+"]":o}).join(n?".":""):t}function wW(e){return ie.isArray(e)&&!e.some(Wy)}const _W=ie.toFlatObject(ie,{},null,function(t){return/^is[A-Z]/.test(t)});function bh(e,t,n){if(!ie.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=ie.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,S){return!ie.isUndefined(S[v])});const r=n.metaTokens,o=n.visitor||h,a=n.dots,s=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&ie.isSpecCompliantForm(t);if(!ie.isFunction(o))throw new TypeError("visitor must be a function");function f(w){if(w===null)return"";if(ie.isDate(w))return w.toISOString();if(ie.isBoolean(w))return w.toString();if(!c&&ie.isBlob(w))throw new Fe("Blob is not supported. Use a Buffer instead.");return ie.isArrayBuffer(w)||ie.isTypedArray(w)?c&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function h(w,v,S){let E=w;if(w&&!S&&typeof w=="object"){if(ie.endsWith(v,"{}"))v=r?v:v.slice(0,-2),w=JSON.stringify(w);else if(ie.isArray(w)&&wW(w)||(ie.isFileList(w)||ie.endsWith(v,"[]"))&&(E=ie.toArray(w)))return v=zA(v),E.forEach(function(k,A){!(ie.isUndefined(k)||k===null)&&t.append(s===!0?LA([v],A,a):s===null?v:v+"[]",f(k))}),!1}return Wy(w)?!0:(t.append(LA(S,v,a),f(w)),!1)}const p=[],g=Object.assign(_W,{defaultVisitor:h,convertValue:f,isVisitable:Wy});function y(w,v){if(!ie.isUndefined(w)){if(p.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));p.push(w),ie.forEach(w,function(E,T){(!(ie.isUndefined(E)||E===null)&&o.call(t,E,ie.isString(T)?T.trim():T,v,g))===!0&&y(E,v?v.concat(T):[T])}),p.pop()}}if(!ie.isObject(e))throw new TypeError("data must be an object");return y(e),t}function FA(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Xy(e,t){this._pairs=[],e&&bh(e,this,t)}const $A=Xy.prototype;$A.append=function(t,n){this._pairs.push([t,n])},$A.toString=function(t){const n=t?function(r){return t.call(this,r,FA)}:FA;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function SW(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function BA(e,t,n){if(!t)return e;const r=n&&n.encode||SW;ie.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let a;if(o?a=o(t,n):a=ie.isURLSearchParams(t)?t.toString():new Xy(t,n).toString(r),a){const s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}class HA{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){ie.forEach(this.handlers,function(r){r!==null&&t(r)})}}const VA={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},EW={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Xy,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ky=typeof window<"u"&&typeof document<"u",Zy=typeof navigator=="object"&&navigator||void 0,CW=Ky&&(!Zy||["ReactNative","NativeScript","NS"].indexOf(Zy.product)<0),kW=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",TW=Ky&&window.location.href||"http://localhost",pn={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ky,hasStandardBrowserEnv:CW,hasStandardBrowserWebWorkerEnv:kW,navigator:Zy,origin:TW},Symbol.toStringTag,{value:"Module"})),...EW};function AW(e,t){return bh(e,new pn.classes.URLSearchParams,{visitor:function(n,r,o,a){return pn.isNode&&ie.isBuffer(n)?(this.append(r,n.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function RW(e){return ie.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function MW(e){const t={},n=Object.keys(e);let r;const o=n.length;let a;for(r=0;r<o;r++)a=n[r],t[a]=e[a];return t}function UA(e){function t(n,r,o,a){let s=n[a++];if(s==="__proto__")return!0;const u=Number.isFinite(+s),c=a>=n.length;return s=!s&&ie.isArray(o)?o.length:s,c?(ie.hasOwnProp(o,s)?o[s]=[o[s],r]:o[s]=r,!u):((!o[s]||!ie.isObject(o[s]))&&(o[s]=[]),t(n,r,o[s],a)&&ie.isArray(o[s])&&(o[s]=MW(o[s])),!u)}if(ie.isFormData(e)&&ie.isFunction(e.entries)){const n={};return ie.forEachEntry(e,(r,o)=>{t(RW(r),o,n,0)}),n}return null}function OW(e,t,n){if(ie.isString(e))try{return(t||JSON.parse)(e),ie.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Du={transitional:VA,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,a=ie.isObject(t);if(a&&ie.isHTMLForm(t)&&(t=new FormData(t)),ie.isFormData(t))return o?JSON.stringify(UA(t)):t;if(ie.isArrayBuffer(t)||ie.isBuffer(t)||ie.isStream(t)||ie.isFile(t)||ie.isBlob(t)||ie.isReadableStream(t))return t;if(ie.isArrayBufferView(t))return t.buffer;if(ie.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(a){if(r.indexOf("application/x-www-form-urlencoded")>-1)return AW(t,this.formSerializer).toString();if((u=ie.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return bh(u?{"files[]":t}:t,c&&new c,this.formSerializer)}}return a||o?(n.setContentType("application/json",!1),OW(t)):t}],transformResponse:[function(t){const n=this.transitional||Du.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(ie.isResponse(t)||ie.isReadableStream(t))return t;if(t&&ie.isString(t)&&(r&&!this.responseType||o)){const s=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(u){if(s)throw u.name==="SyntaxError"?Fe.from(u,Fe.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:pn.classes.FormData,Blob:pn.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ie.forEach(["delete","get","head","post","put","patch"],e=>{Du.headers[e]={}});const NW=ie.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),DW=e=>{const t={};let n,r,o;return e&&e.split(`
782
+ `,n);return}const o=n.substring(0,r+4),a=t.slice(r+4),s=o.split(";"),u={};if(s.forEach(p=>{const[g,y]=p.split("=");u[g.trim()]=y.trim()}),!u.chunk||!u.msgid){console.error("Header missing required fields chunk or msgid",u);return}const[c,f]=u.chunk.split("/"),h=u.msgid;if(c==="1"&&f==="1")return this.recieve_bytes(u,a);if(this.blobChunks[h]||(this.blobChunks[h]={chunks:Array.from({length:parseInt(f)},()=>null),timestamp:Date.now()}),this.blobChunks[h].chunks.length!==parseInt(f)){console.error("Total chunks mismatch");return}if(this.blobChunks[h].chunks[parseInt(c)-1]=t,this.blobChunks[h].chunks.every(p=>p!==null)){const p=new Uint8Array(this.blobChunks[h].chunks.reduce((g,y)=>g.concat(Array.from(y)),[]));this.recieve_bytes(u,p),delete this.blobChunks[h]}}catch(n){console.error("Websocketworker: onbytes error",n,t);return}}}class RY extends Uo{constructor(){super(...arguments),this._ns_event_intercepts=new Map}start(){}stop(){}async _receive_edge_added(t,n,r,o){this.context.worker._zustand&&this.context.worker._zustand.on_edge_action({type:"add",from_remote:!0,src_nid:t,src_ioid:n,trg_nid:r,trg_ioid:o})}async _receive_groups(t){this.context.worker._zustand&&this.context.worker._zustand.on_group_action({type:"set",groups:t})}async _receive_node_added(t){if(this.context.worker._zustand)return this.context.worker._zustand.on_node_action({type:"add",node:t,id:t.id,from_remote:!0})}async receive_workerevent({event:t,data:n}){switch(t){case"worker_error":return this.context.worker._zustand?this.context.worker._zustand.logger.error(n.error):void 0;case"update_worker_dependencies":return this.context.worker._zustand?this.context.worker._zustand.lib.libstate.getState().set({external_worker:n.worker_dependencies}):void 0;case"lib_update":await this.context.worker.getSyncManager().sync_lib();return;case"fullsync":await this.context.worker.getSyncManager().stepwise_fullsync();return;case"external_worker_update":await this.context.worker.getSyncManager().sync_lib(),await this.context.worker.getSyncManager().sync_external_worker();return;case"starting":this.hookManager.call_hooks("starting");return;case"stopping":this.hookManager.call_hooks("stopping");return;default:console.warn("Unhandled worker event",t,n);break}}async intercept_ns_event(t){let n=t;for(const r of this._ns_event_intercepts.get(t.event)||[])n=await r(n);return n}async receive_nodespace_event(t){const{event:n,data:r}=await this.intercept_ns_event(t);switch(n){case"after_set_value":return this.context.worker._zustand?this.context.worker._zustand.on_node_action({type:"update",node:{id:r.node,io:{[r.io]:{value:r.result}}},id:r.node,from_remote:!0}):void 0;case"after_update_value_options":return this.context.worker._zustand?this.context.worker._zustand.on_node_action({type:"update",node:{id:r.node,io:{[r.io]:{value_options:r.result}}},id:r.node,from_remote:!0}):void 0;case"triggerstart":return this.context.worker._zustand?this.context.worker._zustand.on_node_action({type:"update",node:{id:r.node,in_trigger:!0},id:r.node,from_remote:!0}):void 0;case"triggerdone":return this.context.worker._zustand?this.context.worker._zustand.on_node_action({type:"update",node:{id:r.node,in_trigger:!1},id:r.node,from_remote:!0}):void 0;case"triggerfast":if(!this.context.worker._zustand)return;this.context.worker._zustand.on_node_action({type:"update",node:{id:r.node,in_trigger:!0},id:r.node,from_remote:!0}),setTimeout(()=>{this.context.worker._zustand&&this.context.worker._zustand.on_node_action({type:"update",node:{id:r.node,in_trigger:!1},id:r.node,from_remote:!0})},50);return;case"node_trigger_error":return this.context.worker._zustand?this.context.worker._zustand.on_node_action({type:"error",errortype:"trigger",error:r.error,id:r.node,tb:r.tb,from_remote:!0}):void 0;case"node_removed":if(!this.context.worker._zustand)return;this.context.worker._zustand.on_node_action({type:"delete",id:r.node,from_remote:!0}),this.hookManager.call_hooks("node_removed",{node:r.node});return;case"node_added":this._receive_node_added(r.node);return;case"after_disconnect":return!r.result||!Array.isArray(r.result)||r.result.length!==4||!this.context.worker._zustand?void 0:this.context.worker._zustand.on_edge_action({type:"delete",from_remote:!0,src_nid:r.result[0],src_ioid:r.result[1],trg_nid:r.result[2],trg_ioid:r.result[3]});case"after_unforward":return!r.result||!Array.isArray(r.result)||r.result.length!==4||!this.context.worker._zustand?void 0:this.context.worker._zustand.on_edge_action({type:"delete",from_remote:!0,src_nid:r.result[0],src_ioid:r.result[1],trg_nid:r.result[2],trg_ioid:r.result[3]});case"after_connect":return!r.result||!Array.isArray(r.result)||r.result.length!==4?void 0:this._receive_edge_added(...r.result);case"after_forward":return!r.result||!Array.isArray(r.result)||r.result.length!==4?void 0:this._receive_edge_added(...r.result);case"after_add_shelf":return!r.result||!this.context.worker._zustand?void 0:this.context.worker._zustand.lib.libstate.getState().set({lib:r.result});case"after_remove_shelf":return!r.result||!this.context.worker._zustand?void 0:this.context.worker._zustand.lib.libstate.getState().set({lib:r.result});case"progress":if(!this.context.worker._zustand)return;if(r.node)return this.context.worker._zustand.on_node_action({type:"update",node:{id:r.node,progress:r.info},id:r.node,from_remote:!0});console.warn("Unhandled nodepsace event",n,r);break;default:if(["after_set_nodespace"].includes(n))return;console.warn("Unhandled nodepsace event",n,r);break}}add_ns_event_intercept(t,n){const r=this._ns_event_intercepts.get(t)||[];return r.push(n),this._ns_event_intercepts.set(t,r),()=>{const a=this._ns_event_intercepts.get(t)||[],s=a.indexOf(n);s>=0&&a.splice(s,1)}}}class MY extends Uo{constructor(){super(...arguments),this._hooks=new Map}start(){}stop(){}add_hook(t,n){const r=this._hooks.get(t)||[];return r.push(n),this._hooks.set(t,r),()=>{const a=this._hooks.get(t)||[],s=a.indexOf(n);s>=0&&a.splice(s,1)}}async call_hooks(t,n){const r=[];for(const o of this._hooks.get(t)||[]){const a=o({worker:this.context.worker,data:n});a instanceof Promise&&r.push(a)}await Promise.all(r)}}class OY extends Uo{start(){}stop(){}async trigger_node(t){await this.communicationManager._send_cmd({cmd:"trigger_node",kwargs:{nid:t},wait_for_response:!1})}async add_node(t){const n=await this.communicationManager._send_cmd({cmd:"add_node",kwargs:{id:t}});return this.eventManager._receive_node_added(n)}async remove_node(t){await this.communicationManager._send_cmd({cmd:"remove_node",kwargs:{id:t}})}locally_update_node(t){this.syncManager.locally_update_node(t)}set_io_value({nid:t,ioid:n,value:r,set_default:o=!1}){return this.communicationManager._send_cmd({cmd:"set_io_value",kwargs:{nid:t,ioid:n,value:r,set_default:o},wait_for_response:!0})}set_io_value_options({nid:t,ioid:n,values:r,keys:o,nullable:a}){return this.communicationManager._send_cmd({cmd:"update_io_value_options",kwargs:{nid:t,ioid:n,options:{options:{type:"enum",values:r,keys:o,nullable:a}}}})}async get_io_value({nid:t,ioid:n}){const r=await this.communicationManager._send_cmd({cmd:"get_io_value",kwargs:{nid:t,ioid:n},wait_for_response:!0});return this.context.worker._zustand&&this.context.worker._zustand.on_node_action({type:"update",node:{io:{[n]:{value:r}}},id:t,from_remote:!0}),r}async get_ios_values({nid:t}){const n=await this.communicationManager._send_cmd({cmd:"get_ios_values",kwargs:{nid:t},wait_for_response:!0});if(!this.context.worker._zustand)return n;const r={};for(const o in n)r[o]={value:n[o]};return this.context.worker._zustand.on_node_action({type:"update",node:{io:r},id:t,from_remote:!0}),n}async get_io_full_value({nid:t,ioid:n}){const r=await this.communicationManager._send_cmd({cmd:"get_io_full_value",kwargs:{nid:t,ioid:n},wait_for_response:!0,as_bytes:!0}),{header:o,bytes:a}=r,{mime:s}=o,u=CA({data:a,mime:s||"application/octet-stream"});return this.context.worker._zustand?.on_node_action?.({type:"update",node:{id:t,io:{[n]:{fullvalue:u}}},id:t,from_remote:!0}),u}async update_io_options({nid:t,ioid:n,options:r}){const o=await this.communicationManager._send_cmd({cmd:"update_io_options",kwargs:{nid:t,ioid:n,...r},wait_for_response:!0});if(!this.context.worker._zustand)return o;this.context.worker._zustand.on_node_action({type:"update",node:{io:{[n]:{...r}}},id:t,from_remote:!0})}async get_node_status(t){return await this.communicationManager._send_cmd({cmd:"get_node_state",kwargs:{nid:t},wait_for_response:!0})}async get_remote_node_state(t){const n=await this.communicationManager._send_cmd({cmd:"get_node_state",kwargs:{nid:t},wait_for_response:!0});this.context.worker._zustand&&this.context.worker._zustand.on_node_action({type:"update",node:n,id:n.id,from_remote:!0})}}class NY extends Uo{start(){}stop(){}add_edge({src_nid:t,src_ioid:n,trg_nid:r,trg_ioid:o,replace:a=!1}){return this.communicationManager._send_cmd({cmd:"add_edge",kwargs:{src_nid:t,src_ioid:n,trg_nid:r,trg_ioid:o,replace:a}})}remove_edge({src_nid:t,src_ioid:n,trg_nid:r,trg_ioid:o}){return this.communicationManager._send_cmd({cmd:"remove_edge",kwargs:{src_nid:t,src_ioid:n,trg_nid:r,trg_ioid:o}})}}class DY extends Uo{start(){}stop(){}async group_nodes(t,n){const r=await this.communicationManager._send_cmd({cmd:"group_nodes",kwargs:{node_ids:t,group_ids:n},wait_for_response:!0});return this.eventManager._receive_groups(r),r}async remove_group(t){await this.communicationManager._send_cmd({cmd:"remove_group",kwargs:{gid:t},wait_for_response:!0}),await this.syncManager.sync_nodespace()}locally_update_group(t){this.syncManager.locally_update_group(t)}}class PY extends Uo{start(){}stop(){}async add_external_worker({module:t,cls_module:n,cls_name:r}){return await this.communicationManager._send_cmd({cmd:"add_external_worker",kwargs:{module:t,cls_module:n,cls_name:r}})}async add_lib(t,n){return await this.communicationManager._send_cmd({cmd:"add_package_dependency",kwargs:{name:t,version:n},wait_for_response:!1})}async remove_lib(t){return await this.communicationManager._send_cmd({cmd:"remove_package_dependency",kwargs:{name:t},wait_for_response:!1})}async get_available_modules(){return await this.communicationManager._send_cmd({cmd:"get_available_modules",wait_for_response:!0,unique:!0})}async remove_external_worker(t,n){return await this.communicationManager._send_cmd({cmd:"remove_external_worker",kwargs:{worker_id:t,class_id:n},wait_for_response:!0})}}class jY{getEventManager(){return this._eventManager}getSyncManager(){return this._syncManager}getCommunicationManager(){return this._communicationManager}getConnectionHealthManager(){return this._connectionhealthManager}getHookManager(){return this._hookManager}getNodeManager(){return this._nodeManager}getEdgeManager(){return this._edgeManager}getGroupManager(){return this._groupManager}getLibraryManager(){return this._libraryManager}constructor(t){this.uuid=t.uuid,this.on_error=t.on_error||(r=>{this._zustand?.logger.error(r)}),this.state=gr((r,o)=>({is_open:!1}));const n={worker:this};this._connectionhealthManager=new CY(n),this._communicationManager=new AY(n),this._eventManager=new RY({...n}),this._syncManager=new kY({...n,on_sync_complete:t.on_sync_complete}),this._hookManager=new MY(n),this._nodeManager=new OY(n),this._edgeManager=new NY(n),this._groupManager=new DY(n),this._libraryManager=new PY(n),this._communicationManager.start(),this._connectionhealthManager.start(),this._syncManager.start(),this._eventManager.start(),this._hookManager.start(),this._nodeManager.start(),this._edgeManager.start(),this._groupManager.start(),this._libraryManager.start(),t.zustand&&this.set_zustand(t.zustand),this.api={node:this._nodeManager,group:this._groupManager,edge:this._edgeManager,hooks:this._hookManager,lib:this._libraryManager}}set_zustand(t){t!==this._zustand&&(t.logger.debug("Setting zustand for worker"),this._zustand=t,t.set_worker(this),this._zustand.auto_progress(),this._syncManager.stepwise_fullsync())}get is_open(){return this.state.getState().is_open}set is_open(t){this.state.setState({is_open:t})}get is_responsive(){return this._connectionhealthManager.isResponsive()}clear(){return this._communicationManager._send_cmd({cmd:"clear",unique:!0})}save(){return this._communicationManager._send_cmd({cmd:"save",wait_for_response:!0,unique:!0})}load(t){return this._communicationManager._send_cmd({cmd:"load_data",kwargs:{data:t},wait_for_response:!0}).then(()=>{this._syncManager.stepwise_fullsync()})}async get_runstate(){return await this._communicationManager._send_cmd({cmd:"get_runstate",wait_for_response:!0,unique:!0})}async send(t){throw new Error("async send(data: any) not implemented")}async upload_file(t){throw new Error("upload_file not implemented ")}async handle_large_message_hint({}){throw new Error("async handle_large_message_hint({}: LargeMessageHint) not implemented ")}disconnect(){}onclose(){this.is_open=!1,this._zustand&&this._zustand.auto_progress()}async reconnect(){}async stop(){await this._communicationManager._send_cmd({cmd:"stop_worker",wait_for_response:!1});const t=this.onclose.bind(this);this.onclose=()=>{t(),this._zustand&&(this._zustand.worker===this&&this._zustand.clear_all(),this.onclose=t)}}async update_external_worker(t,n,r){return await this._communicationManager._send_cmd({cmd:"update_external_worker",kwargs:{worker_id:t,class_id:n,...r},wait_for_response:!0})}async export({withFiles:t=!1}){return await this._communicationManager._send_cmd({cmd:"export_worker",wait_for_response:!0,kwargs:{with_files:t}})}async update_from_export(t){const n=this._hookManager.add_hook("node_added",async({})=>{this._zustand?.center_all()});try{const r=await this._communicationManager._send_cmd({cmd:"update_from_export",kwargs:{data:t},wait_for_response:!0,response_timeout:6e5,unique:!0});return await new Promise(o=>{setTimeout(()=>{o()},1e3)}),await this._syncManager.stepwise_fullsync(),r}finally{n()}}_send_cmd(t){return this._communicationManager._send_cmd(t)}set_io_value(t){return this._nodeManager.set_io_value(t)}get_io_value(t){return this._nodeManager.get_io_value(t)}}function kA(e,t){return function(){return e.apply(t,arguments)}}const{toString:IY}=Object.prototype,{getPrototypeOf:Gy}=Object,{iterator:mh,toStringTag:TA}=Symbol,gh=(e=>t=>{const n=IY.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),jr=e=>(e=e.toLowerCase(),t=>gh(t)===e),yh=e=>t=>typeof t===e,{isArray:Bs}=Array,Ru=yh("undefined");function Mu(e){return e!==null&&!Ru(e)&&e.constructor!==null&&!Ru(e.constructor)&&On(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const AA=jr("ArrayBuffer");function zY(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&AA(e.buffer),t}const LY=yh("string"),On=yh("function"),RA=yh("number"),Ou=e=>e!==null&&typeof e=="object",FY=e=>e===!0||e===!1,vh=e=>{if(gh(e)!=="object")return!1;const t=Gy(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(TA in e)&&!(mh in e)},$Y=e=>{if(!Ou(e)||Mu(e))return!1;try{return Object.keys(e).length===0&&Object.getPrototypeOf(e)===Object.prototype}catch{return!1}},BY=jr("Date"),HY=jr("File"),VY=jr("Blob"),UY=jr("FileList"),qY=e=>Ou(e)&&On(e.pipe),GY=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||On(e.append)&&((t=gh(e))==="formdata"||t==="object"&&On(e.toString)&&e.toString()==="[object FormData]"))},YY=jr("URLSearchParams"),[WY,XY,KY,ZY]=["ReadableStream","Request","Response","Headers"].map(jr),QY=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Nu(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,o;if(typeof e!="object"&&(e=[e]),Bs(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{if(Mu(e))return;const a=n?Object.getOwnPropertyNames(e):Object.keys(e),s=a.length;let u;for(r=0;r<s;r++)u=a[r],t.call(null,e[u],u,e)}}function MA(e,t){if(Mu(e))return null;t=t.toLowerCase();const n=Object.keys(e);let r=n.length,o;for(;r-- >0;)if(o=n[r],t===o.toLowerCase())return o;return null}const Ca=typeof globalThis<"u"?globalThis:typeof self<"u"?self:window,OA=e=>!Ru(e)&&e!==Ca;function Yy(){const{caseless:e}=OA(this)&&this||{},t={},n=(r,o)=>{const a=e&&MA(t,o)||o;vh(t[a])&&vh(r)?t[a]=Yy(t[a],r):vh(r)?t[a]=Yy({},r):Bs(r)?t[a]=r.slice():t[a]=r};for(let r=0,o=arguments.length;r<o;r++)arguments[r]&&Nu(arguments[r],n);return t}const JY=(e,t,n,{allOwnKeys:r}={})=>(Nu(t,(o,a)=>{n&&On(o)?e[a]=kA(o,n):e[a]=o},{allOwnKeys:r}),e),eW=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),tW=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},nW=(e,t,n,r)=>{let o,a,s;const u={};if(t=t||{},e==null)return t;do{for(o=Object.getOwnPropertyNames(e),a=o.length;a-- >0;)s=o[a],(!r||r(s,e,t))&&!u[s]&&(t[s]=e[s],u[s]=!0);e=n!==!1&&Gy(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},rW=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},oW=e=>{if(!e)return null;if(Bs(e))return e;let t=e.length;if(!RA(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},iW=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Gy(Uint8Array)),aW=(e,t)=>{const r=(e&&e[mh]).call(e);let o;for(;(o=r.next())&&!o.done;){const a=o.value;t.call(e,a[0],a[1])}},sW=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},lW=jr("HTMLFormElement"),uW=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,o){return r.toUpperCase()+o}),NA=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),cW=jr("RegExp"),DA=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Nu(n,(o,a)=>{let s;(s=t(o,a,e))!==!1&&(r[a]=s||o)}),Object.defineProperties(e,r)},fW=e=>{DA(e,(t,n)=>{if(On(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(On(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},dW=(e,t)=>{const n={},r=o=>{o.forEach(a=>{n[a]=!0})};return Bs(e)?r(e):r(String(e).split(t)),n},hW=()=>{},pW=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t;function mW(e){return!!(e&&On(e.append)&&e[TA]==="FormData"&&e[mh])}const gW=e=>{const t=new Array(10),n=(r,o)=>{if(Ou(r)){if(t.indexOf(r)>=0)return;if(Mu(r))return r;if(!("toJSON"in r)){t[o]=r;const a=Bs(r)?[]:{};return Nu(r,(s,u)=>{const c=n(s,o+1);!Ru(c)&&(a[u]=c)}),t[o]=void 0,a}}return r};return n(e,0)},yW=jr("AsyncFunction"),vW=e=>e&&(Ou(e)||On(e))&&On(e.then)&&On(e.catch),PA=((e,t)=>e?setImmediate:t?((n,r)=>(Ca.addEventListener("message",({source:o,data:a})=>{o===Ca&&a===n&&r.length&&r.shift()()},!1),o=>{r.push(o),Ca.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",On(Ca.postMessage)),bW=typeof queueMicrotask<"u"?queueMicrotask.bind(Ca):typeof process<"u"&&process.nextTick||PA,ie={isArray:Bs,isArrayBuffer:AA,isBuffer:Mu,isFormData:GY,isArrayBufferView:zY,isString:LY,isNumber:RA,isBoolean:FY,isObject:Ou,isPlainObject:vh,isEmptyObject:$Y,isReadableStream:WY,isRequest:XY,isResponse:KY,isHeaders:ZY,isUndefined:Ru,isDate:BY,isFile:HY,isBlob:VY,isRegExp:cW,isFunction:On,isStream:qY,isURLSearchParams:YY,isTypedArray:iW,isFileList:UY,forEach:Nu,merge:Yy,extend:JY,trim:QY,stripBOM:eW,inherits:tW,toFlatObject:nW,kindOf:gh,kindOfTest:jr,endsWith:rW,toArray:oW,forEachEntry:aW,matchAll:sW,isHTMLForm:lW,hasOwnProperty:NA,hasOwnProp:NA,reduceDescriptors:DA,freezeMethods:fW,toObjectSet:dW,toCamelCase:uW,noop:hW,toFiniteNumber:pW,findKey:MA,global:Ca,isContextDefined:OA,isSpecCompliantForm:mW,toJSONObject:gW,isAsyncFn:yW,isThenable:vW,setImmediate:PA,asap:bW,isIterable:e=>e!=null&&On(e[mh])};function Fe(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o,this.status=o.status?o.status:null)}ie.inherits(Fe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ie.toJSONObject(this.config),code:this.code,status:this.status}}});const jA=Fe.prototype,IA={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{IA[e]={value:e}}),Object.defineProperties(Fe,IA),Object.defineProperty(jA,"isAxiosError",{value:!0}),Fe.from=(e,t,n,r,o,a)=>{const s=Object.create(jA);return ie.toFlatObject(e,s,function(c){return c!==Error.prototype},u=>u!=="isAxiosError"),Fe.call(s,e.message,t,n,r,o),s.cause=e,s.name=e.name,a&&Object.assign(s,a),s};const xW=null;function Wy(e){return ie.isPlainObject(e)||ie.isArray(e)}function zA(e){return ie.endsWith(e,"[]")?e.slice(0,-2):e}function LA(e,t,n){return e?e.concat(t).map(function(o,a){return o=zA(o),!n&&a?"["+o+"]":o}).join(n?".":""):t}function wW(e){return ie.isArray(e)&&!e.some(Wy)}const _W=ie.toFlatObject(ie,{},null,function(t){return/^is[A-Z]/.test(t)});function bh(e,t,n){if(!ie.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=ie.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(v,S){return!ie.isUndefined(S[v])});const r=n.metaTokens,o=n.visitor||h,a=n.dots,s=n.indexes,c=(n.Blob||typeof Blob<"u"&&Blob)&&ie.isSpecCompliantForm(t);if(!ie.isFunction(o))throw new TypeError("visitor must be a function");function f(w){if(w===null)return"";if(ie.isDate(w))return w.toISOString();if(ie.isBoolean(w))return w.toString();if(!c&&ie.isBlob(w))throw new Fe("Blob is not supported. Use a Buffer instead.");return ie.isArrayBuffer(w)||ie.isTypedArray(w)?c&&typeof Blob=="function"?new Blob([w]):Buffer.from(w):w}function h(w,v,S){let E=w;if(w&&!S&&typeof w=="object"){if(ie.endsWith(v,"{}"))v=r?v:v.slice(0,-2),w=JSON.stringify(w);else if(ie.isArray(w)&&wW(w)||(ie.isFileList(w)||ie.endsWith(v,"[]"))&&(E=ie.toArray(w)))return v=zA(v),E.forEach(function(k,A){!(ie.isUndefined(k)||k===null)&&t.append(s===!0?LA([v],A,a):s===null?v:v+"[]",f(k))}),!1}return Wy(w)?!0:(t.append(LA(S,v,a),f(w)),!1)}const p=[],g=Object.assign(_W,{defaultVisitor:h,convertValue:f,isVisitable:Wy});function y(w,v){if(!ie.isUndefined(w)){if(p.indexOf(w)!==-1)throw Error("Circular reference detected in "+v.join("."));p.push(w),ie.forEach(w,function(E,T){(!(ie.isUndefined(E)||E===null)&&o.call(t,E,ie.isString(T)?T.trim():T,v,g))===!0&&y(E,v?v.concat(T):[T])}),p.pop()}}if(!ie.isObject(e))throw new TypeError("data must be an object");return y(e),t}function FA(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function Xy(e,t){this._pairs=[],e&&bh(e,this,t)}const $A=Xy.prototype;$A.append=function(t,n){this._pairs.push([t,n])},$A.toString=function(t){const n=t?function(r){return t.call(this,r,FA)}:FA;return this._pairs.map(function(o){return n(o[0])+"="+n(o[1])},"").join("&")};function SW(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function BA(e,t,n){if(!t)return e;const r=n&&n.encode||SW;ie.isFunction(n)&&(n={serialize:n});const o=n&&n.serialize;let a;if(o?a=o(t,n):a=ie.isURLSearchParams(t)?t.toString():new Xy(t,n).toString(r),a){const s=e.indexOf("#");s!==-1&&(e=e.slice(0,s)),e+=(e.indexOf("?")===-1?"?":"&")+a}return e}class HA{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){ie.forEach(this.handlers,function(r){r!==null&&t(r)})}}const VA={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},EW={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Xy,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ky=typeof window<"u"&&typeof document<"u",Zy=typeof navigator=="object"&&navigator||void 0,CW=Ky&&(!Zy||["ReactNative","NativeScript","NS"].indexOf(Zy.product)<0),kW=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",TW=Ky&&window.location.href||"http://localhost",pn={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ky,hasStandardBrowserEnv:CW,hasStandardBrowserWebWorkerEnv:kW,navigator:Zy,origin:TW},Symbol.toStringTag,{value:"Module"})),...EW};function AW(e,t){return bh(e,new pn.classes.URLSearchParams,{visitor:function(n,r,o,a){return pn.isNode&&ie.isBuffer(n)?(this.append(r,n.toString("base64")),!1):a.defaultVisitor.apply(this,arguments)},...t})}function RW(e){return ie.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function MW(e){const t={},n=Object.keys(e);let r;const o=n.length;let a;for(r=0;r<o;r++)a=n[r],t[a]=e[a];return t}function UA(e){function t(n,r,o,a){let s=n[a++];if(s==="__proto__")return!0;const u=Number.isFinite(+s),c=a>=n.length;return s=!s&&ie.isArray(o)?o.length:s,c?(ie.hasOwnProp(o,s)?o[s]=[o[s],r]:o[s]=r,!u):((!o[s]||!ie.isObject(o[s]))&&(o[s]=[]),t(n,r,o[s],a)&&ie.isArray(o[s])&&(o[s]=MW(o[s])),!u)}if(ie.isFormData(e)&&ie.isFunction(e.entries)){const n={};return ie.forEachEntry(e,(r,o)=>{t(RW(r),o,n,0)}),n}return null}function OW(e,t,n){if(ie.isString(e))try{return(t||JSON.parse)(e),ie.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const Du={transitional:VA,adapter:["xhr","http","fetch"],transformRequest:[function(t,n){const r=n.getContentType()||"",o=r.indexOf("application/json")>-1,a=ie.isObject(t);if(a&&ie.isHTMLForm(t)&&(t=new FormData(t)),ie.isFormData(t))return o?JSON.stringify(UA(t)):t;if(ie.isArrayBuffer(t)||ie.isBuffer(t)||ie.isStream(t)||ie.isFile(t)||ie.isBlob(t)||ie.isReadableStream(t))return t;if(ie.isArrayBufferView(t))return t.buffer;if(ie.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let u;if(a){if(r.indexOf("application/x-www-form-urlencoded")>-1)return AW(t,this.formSerializer).toString();if((u=ie.isFileList(t))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return bh(u?{"files[]":t}:t,c&&new c,this.formSerializer)}}return a||o?(n.setContentType("application/json",!1),OW(t)):t}],transformResponse:[function(t){const n=this.transitional||Du.transitional,r=n&&n.forcedJSONParsing,o=this.responseType==="json";if(ie.isResponse(t)||ie.isReadableStream(t))return t;if(t&&ie.isString(t)&&(r&&!this.responseType||o)){const s=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(t)}catch(u){if(s)throw u.name==="SyntaxError"?Fe.from(u,Fe.ERR_BAD_RESPONSE,this,null,this.response):u}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:pn.classes.FormData,Blob:pn.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ie.forEach(["delete","get","head","post","put","patch"],e=>{Du.headers[e]={}});const NW=ie.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),DW=e=>{const t={};let n,r,o;return e&&e.split(`
783
783
  `).forEach(function(s){o=s.indexOf(":"),n=s.substring(0,o).trim().toLowerCase(),r=s.substring(o+1).trim(),!(!n||t[n]&&NW[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},qA=Symbol("internals");function Pu(e){return e&&String(e).trim().toLowerCase()}function xh(e){return e===!1||e==null?e:ie.isArray(e)?e.map(xh):String(e)}function PW(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}const jW=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Qy(e,t,n,r,o){if(ie.isFunction(r))return r.call(this,t,n);if(o&&(t=n),!!ie.isString(t)){if(ie.isString(r))return t.indexOf(r)!==-1;if(ie.isRegExp(r))return r.test(t)}}function IW(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function zW(e,t){const n=ie.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(o,a,s){return this[r].call(this,t,o,a,s)},configurable:!0})})}let Nn=class{constructor(t){t&&this.set(t)}set(t,n,r){const o=this;function a(u,c,f){const h=Pu(c);if(!h)throw new Error("header name must be a non-empty string");const p=ie.findKey(o,h);(!p||o[p]===void 0||f===!0||f===void 0&&o[p]!==!1)&&(o[p||c]=xh(u))}const s=(u,c)=>ie.forEach(u,(f,h)=>a(f,h,c));if(ie.isPlainObject(t)||t instanceof this.constructor)s(t,n);else if(ie.isString(t)&&(t=t.trim())&&!jW(t))s(DW(t),n);else if(ie.isObject(t)&&ie.isIterable(t)){let u={},c,f;for(const h of t){if(!ie.isArray(h))throw TypeError("Object iterator must return a key-value pair");u[f=h[0]]=(c=u[f])?ie.isArray(c)?[...c,h[1]]:[c,h[1]]:h[1]}s(u,n)}else t!=null&&a(n,t,r);return this}get(t,n){if(t=Pu(t),t){const r=ie.findKey(this,t);if(r){const o=this[r];if(!n)return o;if(n===!0)return PW(o);if(ie.isFunction(n))return n.call(this,o,r);if(ie.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=Pu(t),t){const r=ie.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||Qy(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let o=!1;function a(s){if(s=Pu(s),s){const u=ie.findKey(r,s);u&&(!n||Qy(r,r[u],u,n))&&(delete r[u],o=!0)}}return ie.isArray(t)?t.forEach(a):a(t),o}clear(t){const n=Object.keys(this);let r=n.length,o=!1;for(;r--;){const a=n[r];(!t||Qy(this,this[a],a,t,!0))&&(delete this[a],o=!0)}return o}normalize(t){const n=this,r={};return ie.forEach(this,(o,a)=>{const s=ie.findKey(r,a);if(s){n[s]=xh(o),delete n[a];return}const u=t?IW(a):String(a).trim();u!==a&&delete n[a],n[u]=xh(o),r[u]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return ie.forEach(this,(r,o)=>{r!=null&&r!==!1&&(n[o]=t&&ie.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
784
784
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[qA]=this[qA]={accessors:{}}).accessors,o=this.prototype;function a(s){const u=Pu(s);r[u]||(zW(o,s),r[u]=!0)}return ie.isArray(t)?t.forEach(a):a(t),this}};Nn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ie.reduceDescriptors(Nn.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),ie.freezeMethods(Nn);function Jy(e,t){const n=this||Du,r=t||n,o=Nn.from(r.headers);let a=r.data;return ie.forEach(e,function(u){a=u.call(n,a,o.normalize(),t?t.status:void 0)}),o.normalize(),a}function GA(e){return!!(e&&e.__CANCEL__)}function Hs(e,t,n){Fe.call(this,e??"canceled",Fe.ERR_CANCELED,t,n),this.name="CanceledError"}ie.inherits(Hs,Fe,{__CANCEL__:!0});function YA(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new Fe("Request failed with status code "+n.status,[Fe.ERR_BAD_REQUEST,Fe.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function LW(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function FW(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,a=0,s;return t=t!==void 0?t:1e3,function(c){const f=Date.now(),h=r[a];s||(s=f),n[o]=c,r[o]=f;let p=a,g=0;for(;p!==o;)g+=n[p++],p=p%e;if(o=(o+1)%e,o===a&&(a=(a+1)%e),f-s<t)return;const y=h&&f-h;return y?Math.round(g*1e3/y):void 0}}function $W(e,t){let n=0,r=1e3/t,o,a;const s=(f,h=Date.now())=>{n=h,o=null,a&&(clearTimeout(a),a=null),e(...f)};return[(...f)=>{const h=Date.now(),p=h-n;p>=r?s(f,h):(o=f,a||(a=setTimeout(()=>{a=null,s(o)},r-p)))},()=>o&&s(o)]}const wh=(e,t,n=3)=>{let r=0;const o=FW(50,250);return $W(a=>{const s=a.loaded,u=a.lengthComputable?a.total:void 0,c=s-r,f=o(c),h=s<=u;r=s;const p={loaded:s,total:u,progress:u?s/u:void 0,bytes:c,rate:f||void 0,estimated:f&&u&&h?(u-s)/f:void 0,event:a,lengthComputable:u!=null,[t?"download":"upload"]:!0};e(p)},n)},WA=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},XA=e=>(...t)=>ie.asap(()=>e(...t)),BW=pn.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,pn.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(pn.origin),pn.navigator&&/(msie|trident)/i.test(pn.navigator.userAgent)):()=>!0,HW=pn.hasStandardBrowserEnv?{write(e,t,n,r,o,a){const s=[e+"="+encodeURIComponent(t)];ie.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),ie.isString(r)&&s.push("path="+r),ie.isString(o)&&s.push("domain="+o),a===!0&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function VW(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function UW(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function KA(e,t,n){let r=!VW(t);return e&&(r||n==!1)?UW(e,t):t}const ZA=e=>e instanceof Nn?{...e}:e;function ka(e,t){t=t||{};const n={};function r(f,h,p,g){return ie.isPlainObject(f)&&ie.isPlainObject(h)?ie.merge.call({caseless:g},f,h):ie.isPlainObject(h)?ie.merge({},h):ie.isArray(h)?h.slice():h}function o(f,h,p,g){if(ie.isUndefined(h)){if(!ie.isUndefined(f))return r(void 0,f,p,g)}else return r(f,h,p,g)}function a(f,h){if(!ie.isUndefined(h))return r(void 0,h)}function s(f,h){if(ie.isUndefined(h)){if(!ie.isUndefined(f))return r(void 0,f)}else return r(void 0,h)}function u(f,h,p){if(p in t)return r(f,h);if(p in e)return r(void 0,f)}const c={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:u,headers:(f,h,p)=>o(ZA(f),ZA(h),p,!0)};return ie.forEach(Object.keys({...e,...t}),function(h){const p=c[h]||o,g=p(e[h],t[h],h);ie.isUndefined(g)&&p!==u||(n[h]=g)}),n}const QA=e=>{const t=ka({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:a,headers:s,auth:u}=t;t.headers=s=Nn.from(s),t.url=BA(KA(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),u&&s.set("Authorization","Basic "+btoa((u.username||"")+":"+(u.password?unescape(encodeURIComponent(u.password)):"")));let c;if(ie.isFormData(n)){if(pn.hasStandardBrowserEnv||pn.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((c=s.getContentType())!==!1){const[f,...h]=c?c.split(";").map(p=>p.trim()).filter(Boolean):[];s.setContentType([f||"multipart/form-data",...h].join("; "))}}if(pn.hasStandardBrowserEnv&&(r&&ie.isFunction(r)&&(r=r(t)),r||r!==!1&&BW(t.url))){const f=o&&a&&HW.read(a);f&&s.set(o,f)}return t},qW=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){const o=QA(e);let a=o.data;const s=Nn.from(o.headers).normalize();let{responseType:u,onUploadProgress:c,onDownloadProgress:f}=o,h,p,g,y,w;function v(){y&&y(),w&&w(),o.cancelToken&&o.cancelToken.unsubscribe(h),o.signal&&o.signal.removeEventListener("abort",h)}let S=new XMLHttpRequest;S.open(o.method.toUpperCase(),o.url,!0),S.timeout=o.timeout;function E(){if(!S)return;const k=Nn.from("getAllResponseHeaders"in S&&S.getAllResponseHeaders()),M={data:!u||u==="text"||u==="json"?S.responseText:S.response,status:S.status,statusText:S.statusText,headers:k,config:e,request:S};YA(function(P){n(P),v()},function(P){r(P),v()},M),S=null}"onloadend"in S?S.onloadend=E:S.onreadystatechange=function(){!S||S.readyState!==4||S.status===0&&!(S.responseURL&&S.responseURL.indexOf("file:")===0)||setTimeout(E)},S.onabort=function(){S&&(r(new Fe("Request aborted",Fe.ECONNABORTED,e,S)),S=null)},S.onerror=function(){r(new Fe("Network Error",Fe.ERR_NETWORK,e,S)),S=null},S.ontimeout=function(){let A=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const M=o.transitional||VA;o.timeoutErrorMessage&&(A=o.timeoutErrorMessage),r(new Fe(A,M.clarifyTimeoutError?Fe.ETIMEDOUT:Fe.ECONNABORTED,e,S)),S=null},a===void 0&&s.setContentType(null),"setRequestHeader"in S&&ie.forEach(s.toJSON(),function(A,M){S.setRequestHeader(M,A)}),ie.isUndefined(o.withCredentials)||(S.withCredentials=!!o.withCredentials),u&&u!=="json"&&(S.responseType=o.responseType),f&&([g,w]=wh(f,!0),S.addEventListener("progress",g)),c&&S.upload&&([p,y]=wh(c),S.upload.addEventListener("progress",p),S.upload.addEventListener("loadend",y)),(o.cancelToken||o.signal)&&(h=k=>{S&&(r(!k||k.type?new Hs(null,e,S):k),S.abort(),S=null)},o.cancelToken&&o.cancelToken.subscribe(h),o.signal&&(o.signal.aborted?h():o.signal.addEventListener("abort",h)));const T=LW(o.url);if(T&&pn.protocols.indexOf(T)===-1){r(new Fe("Unsupported protocol "+T+":",Fe.ERR_BAD_REQUEST,e));return}S.send(a||null)})},GW=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const a=function(f){if(!o){o=!0,u();const h=f instanceof Error?f:this.reason;r.abort(h instanceof Fe?h:new Hs(h instanceof Error?h.message:h))}};let s=t&&setTimeout(()=>{s=null,a(new Fe(`timeout ${t} of ms exceeded`,Fe.ETIMEDOUT))},t);const u=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(f=>{f.unsubscribe?f.unsubscribe(a):f.removeEventListener("abort",a)}),e=null)};e.forEach(f=>f.addEventListener("abort",a));const{signal:c}=r;return c.unsubscribe=()=>ie.asap(u),c}},YW=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},WW=async function*(e,t){for await(const n of XW(e))yield*YW(n,t)},XW=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},JA=(e,t,n,r)=>{const o=WW(e,t);let a=0,s,u=c=>{s||(s=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:f,value:h}=await o.next();if(f){u(),c.close();return}let p=h.byteLength;if(n){let g=a+=p;n(g)}c.enqueue(new Uint8Array(h))}catch(f){throw u(f),f}},cancel(c){return u(c),o.return()}},{highWaterMark:2})},_h=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",eR=_h&&typeof ReadableStream=="function",KW=_h&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),tR=(e,...t)=>{try{return!!e(...t)}catch{return!1}},ZW=eR&&tR(()=>{let e=!1;const t=new Request(pn.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),nR=64*1024,ev=eR&&tR(()=>ie.isReadableStream(new Response("").body)),Sh={stream:ev&&(e=>e.body)};_h&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Sh[t]&&(Sh[t]=ie.isFunction(e[t])?n=>n[t]():(n,r)=>{throw new Fe(`Response type '${t}' is not supported`,Fe.ERR_NOT_SUPPORT,r)})})})(new Response);const QW=async e=>{if(e==null)return 0;if(ie.isBlob(e))return e.size;if(ie.isSpecCompliantForm(e))return(await new Request(pn.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(ie.isArrayBufferView(e)||ie.isArrayBuffer(e))return e.byteLength;if(ie.isURLSearchParams(e)&&(e=e+""),ie.isString(e))return(await KW(e)).byteLength},JW=async(e,t)=>{const n=ie.toFiniteNumber(e.getContentLength());return n??QW(t)},tv={http:xW,xhr:qW,fetch:_h&&(async e=>{let{url:t,method:n,data:r,signal:o,cancelToken:a,timeout:s,onDownloadProgress:u,onUploadProgress:c,responseType:f,headers:h,withCredentials:p="same-origin",fetchOptions:g}=QA(e);f=f?(f+"").toLowerCase():"text";let y=GW([o,a&&a.toAbortSignal()],s),w;const v=y&&y.unsubscribe&&(()=>{y.unsubscribe()});let S;try{if(c&&ZW&&n!=="get"&&n!=="head"&&(S=await JW(h,r))!==0){let M=new Request(t,{method:"POST",body:r,duplex:"half"}),N;if(ie.isFormData(r)&&(N=M.headers.get("content-type"))&&h.setContentType(N),M.body){const[P,z]=WA(S,wh(XA(c)));r=JA(M.body,nR,P,z)}}ie.isString(p)||(p=p?"include":"omit");const E="credentials"in Request.prototype;w=new Request(t,{...g,signal:y,method:n.toUpperCase(),headers:h.normalize().toJSON(),body:r,duplex:"half",credentials:E?p:void 0});let T=await fetch(w,g);const k=ev&&(f==="stream"||f==="response");if(ev&&(u||k&&v)){const M={};["status","statusText","headers"].forEach(B=>{M[B]=T[B]});const N=ie.toFiniteNumber(T.headers.get("content-length")),[P,z]=u&&WA(N,wh(XA(u),!0))||[];T=new Response(JA(T.body,nR,P,()=>{z&&z(),v&&v()}),M)}f=f||"text";let A=await Sh[ie.findKey(Sh,f)||"text"](T,e);return!k&&v&&v(),await new Promise((M,N)=>{YA(M,N,{data:A,headers:Nn.from(T.headers),status:T.status,statusText:T.statusText,config:e,request:w})})}catch(E){throw v&&v(),E&&E.name==="TypeError"&&/Load failed|fetch/i.test(E.message)?Object.assign(new Fe("Network Error",Fe.ERR_NETWORK,e,w),{cause:E.cause||E}):Fe.from(E,E&&E.code,e,w)}})};ie.forEach(tv,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const rR=e=>`- ${e}`,eX=e=>ie.isFunction(e)||e===null||e===!1,oR={getAdapter:e=>{e=ie.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let a=0;a<t;a++){n=e[a];let s;if(r=n,!eX(n)&&(r=tv[(s=String(n)).toLowerCase()],r===void 0))throw new Fe(`Unknown adapter '${s}'`);if(r)break;o[s||"#"+a]=r}if(!r){const a=Object.entries(o).map(([u,c])=>`adapter ${u} `+(c===!1?"is not supported by the environment":"is not available in the build"));let s=t?a.length>1?`since :
785
785
  `+a.map(rR).join(`
786
786
  `):" "+rR(a[0]):"as no adapter specified";throw new Fe("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return r},adapters:tv};function nv(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Hs(null,e)}function iR(e){return nv(e),e.headers=Nn.from(e.headers),e.data=Jy.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),oR.getAdapter(e.adapter||Du.adapter)(e).then(function(r){return nv(e),r.data=Jy.call(e,e.transformResponse,r),r.headers=Nn.from(r.headers),r},function(r){return GA(r)||(nv(e),r&&r.response&&(r.response.data=Jy.call(e,e.transformResponse,r.response),r.response.headers=Nn.from(r.response.headers))),Promise.reject(r)})}const aR="1.11.0",Eh={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Eh[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const sR={};Eh.transitional=function(t,n,r){function o(a,s){return"[Axios v"+aR+"] Transitional option '"+a+"'"+s+(r?". "+r:"")}return(a,s,u)=>{if(t===!1)throw new Fe(o(s," has been removed"+(n?" in "+n:"")),Fe.ERR_DEPRECATED);return n&&!sR[s]&&(sR[s]=!0,console.warn(o(s," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(a,s,u):!0}},Eh.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function tX(e,t,n){if(typeof e!="object")throw new Fe("options must be an object",Fe.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const a=r[o],s=t[a];if(s){const u=e[a],c=u===void 0||s(u,a,e);if(c!==!0)throw new Fe("option "+a+" must be "+c,Fe.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new Fe("Unknown option "+a,Fe.ERR_BAD_OPTION)}}const Ch={assertOptions:tX,validators:Eh},co=Ch.validators;let Ta=class{constructor(t){this.defaults=t||{},this.interceptors={request:new HA,response:new HA}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const a=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?a&&!String(r.stack).endsWith(a.replace(/^.+\n.+\n/,""))&&(r.stack+=`
787
- `+a):r.stack=a}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=ka(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:a}=n;r!==void 0&&Ch.assertOptions(r,{silentJSONParsing:co.transitional(co.boolean),forcedJSONParsing:co.transitional(co.boolean),clarifyTimeoutError:co.transitional(co.boolean)},!1),o!=null&&(ie.isFunction(o)?n.paramsSerializer={serialize:o}:Ch.assertOptions(o,{encode:co.function,serialize:co.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ch.assertOptions(n,{baseUrl:co.spelling("baseURL"),withXsrfToken:co.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let s=a&&ie.merge(a.common,a[n.method]);a&&ie.forEach(["delete","get","head","post","put","patch","common"],w=>{delete a[w]}),n.headers=Nn.concat(s,a);const u=[];let c=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(c=c&&v.synchronous,u.unshift(v.fulfilled,v.rejected))});const f=[];this.interceptors.response.forEach(function(v){f.push(v.fulfilled,v.rejected)});let h,p=0,g;if(!c){const w=[iR.bind(this),void 0];for(w.unshift(...u),w.push(...f),g=w.length,h=Promise.resolve(n);p<g;)h=h.then(w[p++],w[p++]);return h}g=u.length;let y=n;for(p=0;p<g;){const w=u[p++],v=u[p++];try{y=w(y)}catch(S){v.call(this,S);break}}try{h=iR.call(this,y)}catch(w){return Promise.reject(w)}for(p=0,g=f.length;p<g;)h=h.then(f[p++],f[p++]);return h}getUri(t){t=ka(this.defaults,t);const n=KA(t.baseURL,t.url,t.allowAbsoluteUrls);return BA(n,t.params,t.paramsSerializer)}};ie.forEach(["delete","get","head","options"],function(t){Ta.prototype[t]=function(n,r){return this.request(ka(r||{},{method:t,url:n,data:(r||{}).data}))}}),ie.forEach(["post","put","patch"],function(t){function n(r){return function(a,s,u){return this.request(ka(u||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:s}))}}Ta.prototype[t]=n(),Ta.prototype[t+"Form"]=n(!0)});let nX=class ij{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const r=this;this.promise.then(o=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](o);r._listeners=null}),this.promise.then=o=>{let a;const s=new Promise(u=>{r.subscribe(u),a=u}).then(o);return s.cancel=function(){r.unsubscribe(a)},s},t(function(a,s,u){r.reason||(r.reason=new Hs(a,s,u),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new ij(function(o){t=o}),cancel:t}}};function rX(e){return function(n){return e.apply(null,n)}}function oX(e){return ie.isObject(e)&&e.isAxiosError===!0}const rv={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(rv).forEach(([e,t])=>{rv[t]=e});function lR(e){const t=new Ta(e),n=kA(Ta.prototype.request,t);return ie.extend(n,Ta.prototype,t,{allOwnKeys:!0}),ie.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return lR(ka(e,o))},n}const zt=lR(Du);zt.Axios=Ta,zt.CanceledError=Hs,zt.CancelToken=nX,zt.isCancel=GA,zt.VERSION=aR,zt.toFormData=bh,zt.AxiosError=Fe,zt.Cancel=zt.CanceledError,zt.all=function(t){return Promise.all(t)},zt.spread=rX,zt.isAxiosError=oX,zt.mergeConfig=ka,zt.AxiosHeaders=Nn,zt.formToJSON=e=>UA(ie.isHTMLForm(e)?new FormData(e):e),zt.getAdapter=oR.getAdapter,zt.HttpStatusCode=rv,zt.default=zt;const{Axios:Npe,AxiosError:Dpe,CanceledError:Ppe,isCancel:jpe,CancelToken:Ipe,VERSION:zpe,all:Lpe,Cancel:Fpe,isAxiosError:$pe,spread:Bpe,toFormData:Hpe,AxiosHeaders:Vpe,HttpStatusCode:Upe,formToJSON:qpe,getAdapter:Gpe,mergeConfig:Ype}=zt;class uR extends jY{constructor(t){super(t),this._websocket=null,this.reconnectAttempts=0,this.maxReconnectAttempts=999,this.initialTimeout=200,this.maxTimeout=5e3,this._reconnect=!0,this._reconnect_timeout=void 0,this._url=t.url,this._reconnect_timeout=setTimeout(()=>{this.connect()},200),this._zustand&&this._zustand.auto_progress()}connect(){this._zustand?.logger.info("Connecting to websocket"),this.is_open=!1,this._websocket=new WebSocket(this._url),this._websocket.onopen=()=>{this.onopen()},this._websocket.onclose=()=>{this.onclose()},this._websocket.onerror=()=>{this.on_ws_error()},this._websocket.onmessage=t=>{typeof t.data=="string"?this.onmessage(t.data):t.data instanceof Blob&&t.data.arrayBuffer().then(n=>{const r=new Uint8Array(n);this.getCommunicationManager().onbytes(r)})}}calculateReconnectTimeout(){return Math.min(this.initialTimeout*Math.pow(2,this.reconnectAttempts),this.maxTimeout)}auto_reconnect(){if(this.reconnectAttempts<this.maxReconnectAttempts){let t=this.calculateReconnectTimeout();this._zustand?.logger.info(`Attempting to reconnect in ${t} ms`),this._reconnect_timeout=setTimeout(()=>{this._websocket&&this._websocket.readyState===WebSocket.OPEN||(this.reconnectAttempts++,this.connect())},t)}else this._zustand?.logger.warn("Maximum reconnect attempts reached. Giving up.")}async onmessage(t){try{const n=JSON.parse(t);this._zustand?.logger.debug(`Recieved data of length: ${t.length} and data"`,n),await this.getCommunicationManager().receive(n)}catch(n){console.error("Websocketworker: onmessage JSON.parse error",n,t);return}}get http_protocol(){return this.secure_url?"https":"http"}get secure_url(){return this._url.startsWith("wss")}get url_wo_protocol(){return this._url.substring(this.secure_url?6:5)}get http_url(){var t=this.http_protocol+"://"+this.url_wo_protocol;return t[t.length-1]!=="/"&&(t+="/"),t}get_io_subscription_url({node_id:t,io_id:n,stream:r}){let o=this.http_url+`node/${t}/io/${n}/value`;return r&&(o+="/stream"),o}async upload_file({files:t,onProgressCallback:n,root:r}){const o=`${this.http_url}upload/`,a=new FormData,s=Array.isArray(t)?t:Array.from(t);for(const u of s){const c=u.webkitRelativePath||u.name,f=r?`${r}/${c}`:c;a.append("file",u,f)}try{return(await zt.post(o,a,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:c=>{n&&n(c.loaded,c.total)}})).data.file}catch{throw new Error("Failed to upload file")}}async handle_large_message_hint({msg_id:t}){const n=this.http_url+"message/"+t,o=await(await fetch(n,{method:"GET",headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}})).json();this.getCommunicationManager().receive(o)}onopen(){this._zustand?.logger.info("Websocket opened"),this.is_open=!0,this._zustand&&this._zustand.auto_progress(),this.reconnectAttempts=0,this.getSyncManager().stepwise_fullsync()}onclose(){this._zustand?.logger.info("Websocket closed"),super.onclose(),this._reconnect&&(this._zustand?.logger.info("Websocket closed,reconnecting"),this.auto_reconnect())}on_ws_error(){this._zustand?.logger.warn("Websocket error"),this._websocket?this._websocket.close():this.auto_reconnect()}async send_large_message(t){const n=`${this.http_url}message/`;await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:t})}async send(t){if(!this._websocket||this._websocket.readyState!==WebSocket.OPEN){this._zustand?.logger.warn("Websocket not connected");return}const n=JSON.stringify(t);if(new Blob([n]).size>1e6)return this._zustand?.logger.info("Data too large, sending via http"),await this.send_large_message(n);this._zustand?.logger.debug("Sending data",t),this._websocket.send(n)}async stop(){await super.stop(),this._reconnect=!1}close(){this._websocket&&this._websocket.close()}disconnect(){super.disconnect(),this._reconnect=!1,this._reconnect_timeout&&(clearTimeout(this._reconnect_timeout),this._reconnect_timeout=void 0),this.close()}async reconnect(){if(await super.reconnect(),this._reconnect=!0,this._websocket&&(this._zustand?.logger.info("Reconnecting"),(this._websocket.readyState===WebSocket.OPEN||this._websocket.readyState===WebSocket.CONNECTING)&&(this._websocket.readyState===WebSocket.CONNECTING&&await new Promise((t,n)=>{if(this._websocket===null)return;let r=setTimeout(()=>{n("Timeout@reconnect")},2e3);this._websocket.addEventListener("open",()=>{clearTimeout(r),t(null)},{once:!0}),this._websocket.readyState===WebSocket.OPEN&&(clearTimeout(r),t(null))}),this._websocket.readyState===WebSocket.OPEN))){this.getSyncManager().stepwise_fullsync();return}this.connect()}}class iX{constructor(t,n){this.ws=null,this.reconnectAttempts=0,this.maxReconnectAttempts=999,this.initialTimeout=200,this.maxTimeout=2e3,this._wsuri=t,this.zustand=n,this.workers={},this.on_setWorker=r=>{this.zustand.set_worker(r)},this.connectionTimeout=setTimeout(()=>{this.connect()},200)}get wsuri(){return this._wsuri}get open(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.zustand.set_progress({progress:0,message:"connecting to worker manager",status:"info",blocking:!0}),this.zustand.logger.info("Connecting to websocket:",this._wsuri),this.ws=new WebSocket(this._wsuri),this.ws.onopen=()=>{this.onopen()},this.ws.onclose=()=>{this.onclose()},this.ws.onerror=()=>{this.on_ws_error()},this.ws.onmessage=t=>{typeof t.data=="string"?this.onmessage(t.data):console.error("WorkerManager: onmessage event.data is not a string",typeof t.data)},this.connectionTimeout=setTimeout(()=>{this.ws?.readyState!==WebSocket.OPEN&&this.on_ws_error()},5e3)}on_ws_error(){console.warn("Websocket error"),this.ws?this.ws.close():this.reconnect()}onopen(){this.connectionTimeout&&(clearTimeout(this.connectionTimeout),this.connectionTimeout=void 0),this.zustand.auto_progress(),this.ws&&this.ws.send("worker_status");const t=window.localStorage.getItem("funcnodes__active_worker");t&&this.set_active(t)}onmessage(t){try{let n=JSON.parse(t);if(n.type==="worker_status"){const r={};for(let o of n.active)o.active=!0,r[o.uuid]=o;for(let o of n.inactive)o.active=!1,r[o.uuid]=o;this.zustand.workers.setState(r);return}else if(n.type==="set_worker"){if(n.data.type==="WSWorker"){let r="ws"+(n.data.ssl?"s":"")+"://"+n.data.host+":"+n.data.port;this.setWorker(this.workers[n.data.uuid]||new uR({url:r,zustand:this.zustand,uuid:n.data.uuid,on_sync_complete:this.zustand.options.on_sync_complete}))}else this.zustand.logger.error("WorkerManager: unknown worker type",n);return}else if(n.type==="progress"){this.zustand.set_progress(n);return}this.zustand.logger.error("WorkerManager: unknown message",n)}catch(n){console.error("WorkerManager: onmessage JSON.parse error",n,t);return}}setWorker(t){for(let n in this.workers)n!==t?.uuid&&this.workers[n].disconnect();t!==void 0&&(this.workers[t.uuid]=t,t.reconnect()),t?.uuid&&window.localStorage.setItem("funcnodes__active_worker",t?.uuid),this.zustand.worker!==void 0&&this.zustand.clear_all(),this.zustand.set_worker(t),this.on_setWorker(t)}async restart_worker(t){this.ws?.send(JSON.stringify({type:"restart_worker",workerid:t}))}calculateReconnectTimeout(){return Math.min(this.initialTimeout*Math.pow(2,this.reconnectAttempts),this.maxTimeout)}reconnect(){if(this.reconnectAttempts<this.maxReconnectAttempts){let t=this.calculateReconnectTimeout();this.zustand.logger.info(`Attempting to reconnect in ${t} ms`),setTimeout(()=>{this.ws&&this.ws.readyState===WebSocket.OPEN||(this.reconnectAttempts++,this.connect())},t)}else this.zustand.logger.warn("Maximum reconnect attempts reached. Giving up.")}onclose(){this.zustand.logger.warn("WorkerManager: onclose"),this.reconnect()}set_active(t){this.ws&&this.ws.send(JSON.stringify({type:"set_active",workerid:t}))}new_worker({name:t,reference:n,copyLib:r,copyNS:o,in_venv:a}){t||(t=void 0),r||(r=!1),o||(o=!1),n||(n=void 0,r=!1,o=!1),this.ws&&this.ws.send(JSON.stringify({type:"new_worker",kwargs:{name:t,reference:n,copyLib:r,copyNS:o,in_venv:a}}))}remove(){for(let t in this.workers)this.workers[t].disconnect();this.connectionTimeout&&(clearTimeout(this.connectionTimeout),this.connectionTimeout=void 0),this.ws&&(this.ws.onclose=()=>{},this.ws.onerror=()=>{},this.ws.onmessage=()=>{},this.ws.onopen=()=>{},this.ws.close())}}const _n=()=>{const e=tt();return e.worker?{...e.worker.api,worker:e.worker}:{node:void 0,group:void 0,edge:void 0,hooks:void 0,lib:void 0,worker:e.worker}},aX={id:"",debug:!1,useWorkerManager:!0,show_library:!0,header:{show:!0,showmenu:!0},flow:{minimap:!0,static:!1,minZoom:.1,maxZoom:5,allowFullScreen:!0,allowExpand:!0,showNodeSettings:!0},library:{show:!0}},cR=["classic","metal","light","solarized","midnight","forest","scientific","neon","ocean","sunset"];function Vt(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Vt(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var sX={value:()=>{}};function kh(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Th(n)}function Th(e){this._=e}function lX(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Th.prototype=kh.prototype={constructor:Th,on:function(e,t){var n=this._,r=lX(e+"",n),o,a=-1,s=r.length;if(arguments.length<2){for(;++a<s;)if((o=(e=r[a]).type)&&(o=uX(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<s;)if(o=(e=r[a]).type)n[o]=fR(n[o],e.name,t);else if(t==null)for(o in n)n[o]=fR(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Th(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,a;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],r=0,o=a.length;r<o;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,a=r.length;o<a;++o)r[o].value.apply(t,n)}};function uX(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function fR(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=sX,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var ov="http://www.w3.org/1999/xhtml";const dR={svg:"http://www.w3.org/2000/svg",xhtml:ov,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ah(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),dR.hasOwnProperty(t)?{space:dR[t],local:e}:e}function cX(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ov&&t.documentElement.namespaceURI===ov?t.createElement(e):t.createElementNS(n,e)}}function fX(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function hR(e){var t=Ah(e);return(t.local?fX:cX)(t)}function dX(){}function iv(e){return e==null?dX:function(){return this.querySelector(e)}}function hX(e){typeof e!="function"&&(e=iv(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var a=t[o],s=a.length,u=r[o]=new Array(s),c,f,h=0;h<s;++h)(c=a[h])&&(f=e.call(c,c.__data__,h,a))&&("__data__"in c&&(f.__data__=c.__data__),u[h]=f);return new Kn(r,this._parents)}function pX(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function mX(){return[]}function pR(e){return e==null?mX:function(){return this.querySelectorAll(e)}}function gX(e){return function(){return pX(e.apply(this,arguments))}}function yX(e){typeof e=="function"?e=gX(e):e=pR(e);for(var t=this._groups,n=t.length,r=[],o=[],a=0;a<n;++a)for(var s=t[a],u=s.length,c,f=0;f<u;++f)(c=s[f])&&(r.push(e.call(c,c.__data__,f,s)),o.push(c));return new Kn(r,o)}function mR(e){return function(){return this.matches(e)}}function gR(e){return function(t){return t.matches(e)}}var vX=Array.prototype.find;function bX(e){return function(){return vX.call(this.children,e)}}function xX(){return this.firstElementChild}function wX(e){return this.select(e==null?xX:bX(typeof e=="function"?e:gR(e)))}var _X=Array.prototype.filter;function SX(){return Array.from(this.children)}function EX(e){return function(){return _X.call(this.children,e)}}function CX(e){return this.selectAll(e==null?SX:EX(typeof e=="function"?e:gR(e)))}function kX(e){typeof e!="function"&&(e=mR(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var a=t[o],s=a.length,u=r[o]=[],c,f=0;f<s;++f)(c=a[f])&&e.call(c,c.__data__,f,a)&&u.push(c);return new Kn(r,this._parents)}function yR(e){return new Array(e.length)}function TX(){return new Kn(this._enter||this._groups.map(yR),this._parents)}function Rh(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Rh.prototype={constructor:Rh,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function AX(e){return function(){return e}}function RX(e,t,n,r,o,a){for(var s=0,u,c=t.length,f=a.length;s<f;++s)(u=t[s])?(u.__data__=a[s],r[s]=u):n[s]=new Rh(e,a[s]);for(;s<c;++s)(u=t[s])&&(o[s]=u)}function MX(e,t,n,r,o,a,s){var u,c,f=new Map,h=t.length,p=a.length,g=new Array(h),y;for(u=0;u<h;++u)(c=t[u])&&(g[u]=y=s.call(c,c.__data__,u,t)+"",f.has(y)?o[u]=c:f.set(y,c));for(u=0;u<p;++u)y=s.call(e,a[u],u,a)+"",(c=f.get(y))?(r[u]=c,c.__data__=a[u],f.delete(y)):n[u]=new Rh(e,a[u]);for(u=0;u<h;++u)(c=t[u])&&f.get(g[u])===c&&(o[u]=c)}function OX(e){return e.__data__}function NX(e,t){if(!arguments.length)return Array.from(this,OX);var n=t?MX:RX,r=this._parents,o=this._groups;typeof e!="function"&&(e=AX(e));for(var a=o.length,s=new Array(a),u=new Array(a),c=new Array(a),f=0;f<a;++f){var h=r[f],p=o[f],g=p.length,y=DX(e.call(h,h&&h.__data__,f,r)),w=y.length,v=u[f]=new Array(w),S=s[f]=new Array(w),E=c[f]=new Array(g);n(h,p,v,S,E,y,t);for(var T=0,k=0,A,M;T<w;++T)if(A=v[T]){for(T>=k&&(k=T+1);!(M=S[k])&&++k<w;);A._next=M||null}}return s=new Kn(s,r),s._enter=u,s._exit=c,s}function DX(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function PX(){return new Kn(this._exit||this._groups.map(yR),this._parents)}function jX(e,t,n){var r=this.enter(),o=this,a=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?a.remove():n(a),r&&o?r.merge(o).order():o}function IX(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,a=r.length,s=Math.min(o,a),u=new Array(o),c=0;c<s;++c)for(var f=n[c],h=r[c],p=f.length,g=u[c]=new Array(p),y,w=0;w<p;++w)(y=f[w]||h[w])&&(g[w]=y);for(;c<o;++c)u[c]=n[c];return new Kn(u,this._parents)}function zX(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,a=r[o],s;--o>=0;)(s=r[o])&&(a&&s.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(s,a),a=s);return this}function LX(e){e||(e=FX);function t(p,g){return p&&g?e(p.__data__,g.__data__):!p-!g}for(var n=this._groups,r=n.length,o=new Array(r),a=0;a<r;++a){for(var s=n[a],u=s.length,c=o[a]=new Array(u),f,h=0;h<u;++h)(f=s[h])&&(c[h]=f);c.sort(t)}return new Kn(o,this._parents).order()}function FX(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function $X(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function BX(){return Array.from(this)}function HX(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,a=r.length;o<a;++o){var s=r[o];if(s)return s}return null}function VX(){let e=0;for(const t of this)++e;return e}function UX(){return!this.node()}function qX(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],a=0,s=o.length,u;a<s;++a)(u=o[a])&&e.call(u,u.__data__,a,o);return this}function GX(e){return function(){this.removeAttribute(e)}}function YX(e){return function(){this.removeAttributeNS(e.space,e.local)}}function WX(e,t){return function(){this.setAttribute(e,t)}}function XX(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function KX(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function ZX(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function QX(e,t){var n=Ah(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?YX:GX:typeof t=="function"?n.local?ZX:KX:n.local?XX:WX)(n,t))}function vR(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function JX(e){return function(){this.style.removeProperty(e)}}function eK(e,t,n){return function(){this.style.setProperty(e,t,n)}}function tK(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function nK(e,t,n){return arguments.length>1?this.each((t==null?JX:typeof t=="function"?tK:eK)(e,t,n??"")):Vs(this.node(),e)}function Vs(e,t){return e.style.getPropertyValue(t)||vR(e).getComputedStyle(e,null).getPropertyValue(t)}function rK(e){return function(){delete this[e]}}function oK(e,t){return function(){this[e]=t}}function iK(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function aK(e,t){return arguments.length>1?this.each((t==null?rK:typeof t=="function"?iK:oK)(e,t)):this.node()[e]}function bR(e){return e.trim().split(/^|\s+/)}function av(e){return e.classList||new xR(e)}function xR(e){this._node=e,this._names=bR(e.getAttribute("class")||"")}xR.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function wR(e,t){for(var n=av(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function _R(e,t){for(var n=av(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function sK(e){return function(){wR(this,e)}}function lK(e){return function(){_R(this,e)}}function uK(e,t){return function(){(t.apply(this,arguments)?wR:_R)(this,e)}}function cK(e,t){var n=bR(e+"");if(arguments.length<2){for(var r=av(this.node()),o=-1,a=n.length;++o<a;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?uK:t?sK:lK)(n,t))}function fK(){this.textContent=""}function dK(e){return function(){this.textContent=e}}function hK(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function pK(e){return arguments.length?this.each(e==null?fK:(typeof e=="function"?hK:dK)(e)):this.node().textContent}function mK(){this.innerHTML=""}function gK(e){return function(){this.innerHTML=e}}function yK(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function vK(e){return arguments.length?this.each(e==null?mK:(typeof e=="function"?yK:gK)(e)):this.node().innerHTML}function bK(){this.nextSibling&&this.parentNode.appendChild(this)}function xK(){return this.each(bK)}function wK(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function _K(){return this.each(wK)}function SK(e){var t=typeof e=="function"?e:hR(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function EK(){return null}function CK(e,t){var n=typeof e=="function"?e:hR(e),r=t==null?EK:typeof t=="function"?t:iv(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function kK(){var e=this.parentNode;e&&e.removeChild(this)}function TK(){return this.each(kK)}function AK(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function RK(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function MK(e){return this.select(e?RK:AK)}function OK(e){return arguments.length?this.property("__data__",e):this.node().__data__}function NK(e){return function(t){e.call(this,t,this.__data__)}}function DK(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function PK(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,a;n<o;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function jK(e,t,n){return function(){var r=this.__on,o,a=NK(t);if(r){for(var s=0,u=r.length;s<u;++s)if((o=r[s]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=a,o.options=n),o.value=t;return}}this.addEventListener(e.type,a,n),o={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(o):this.__on=[o]}}function IK(e,t,n){var r=DK(e+""),o,a=r.length,s;if(arguments.length<2){var u=this.node().__on;if(u){for(var c=0,f=u.length,h;c<f;++c)for(o=0,h=u[c];o<a;++o)if((s=r[o]).type===h.type&&s.name===h.name)return h.value}return}for(u=t?jK:PK,o=0;o<a;++o)this.each(u(r[o],t,n));return this}function SR(e,t,n){var r=vR(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function zK(e,t){return function(){return SR(this,e,t)}}function LK(e,t){return function(){return SR(this,e,t.apply(this,arguments))}}function FK(e,t){return this.each((typeof t=="function"?LK:zK)(e,t))}function*$K(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,a=r.length,s;o<a;++o)(s=r[o])&&(yield s)}var ER=[null];function Kn(e,t){this._groups=e,this._parents=t}function ju(){return new Kn([[document.documentElement]],ER)}function BK(){return this}Kn.prototype=ju.prototype={constructor:Kn,select:hX,selectAll:yX,selectChild:wX,selectChildren:CX,filter:kX,data:NX,enter:TX,exit:PX,join:jX,merge:IX,selection:BK,order:zX,sort:LX,call:$X,nodes:BX,node:HX,size:VX,empty:UX,each:qX,attr:QX,style:nK,property:aK,classed:cK,text:pK,html:vK,raise:xK,lower:_K,append:SK,insert:CK,remove:TK,clone:MK,datum:OK,on:IK,dispatch:FK,[Symbol.iterator]:$K};function Zn(e){return typeof e=="string"?new Kn([[document.querySelector(e)]],[document.documentElement]):new Kn([[e]],ER)}function HK(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ir(e,t){if(e=HK(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const VK={passive:!1},Iu={capture:!0,passive:!1};function sv(e){e.stopImmediatePropagation()}function Us(e){e.preventDefault(),e.stopImmediatePropagation()}function CR(e){var t=e.document.documentElement,n=Zn(e).on("dragstart.drag",Us,Iu);"onselectstart"in t?n.on("selectstart.drag",Us,Iu):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function kR(e,t){var n=e.document.documentElement,r=Zn(e).on("dragstart.drag",null);t&&(r.on("click.drag",Us,Iu),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Mh=e=>()=>e;function lv(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:a,x:s,y:u,dx:c,dy:f,dispatch:h}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:h}})}lv.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function UK(e){return!e.ctrlKey&&!e.button}function qK(){return this.parentNode}function GK(e,t){return t??{x:e.x,y:e.y}}function YK(){return navigator.maxTouchPoints||"ontouchstart"in this}function TR(){var e=UK,t=qK,n=GK,r=YK,o={},a=kh("start","drag","end"),s=0,u,c,f,h,p=0;function g(A){A.on("mousedown.drag",y).filter(r).on("touchstart.drag",S).on("touchmove.drag",E,VK).on("touchend.drag touchcancel.drag",T).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(A,M){if(!(h||!e.call(this,A,M))){var N=k(this,t.call(this,A,M),A,M,"mouse");N&&(Zn(A.view).on("mousemove.drag",w,Iu).on("mouseup.drag",v,Iu),CR(A.view),sv(A),f=!1,u=A.clientX,c=A.clientY,N("start",A))}}function w(A){if(Us(A),!f){var M=A.clientX-u,N=A.clientY-c;f=M*M+N*N>p}o.mouse("drag",A)}function v(A){Zn(A.view).on("mousemove.drag mouseup.drag",null),kR(A.view,f),Us(A),o.mouse("end",A)}function S(A,M){if(e.call(this,A,M)){var N=A.changedTouches,P=t.call(this,A,M),z=N.length,B,R;for(B=0;B<z;++B)(R=k(this,P,A,M,N[B].identifier,N[B]))&&(sv(A),R("start",A,N[B]))}}function E(A){var M=A.changedTouches,N=M.length,P,z;for(P=0;P<N;++P)(z=o[M[P].identifier])&&(Us(A),z("drag",A,M[P]))}function T(A){var M=A.changedTouches,N=M.length,P,z;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),P=0;P<N;++P)(z=o[M[P].identifier])&&(sv(A),z("end",A,M[P]))}function k(A,M,N,P,z,B){var R=a.copy(),F=Ir(B||N,M),U,W,j;if((j=n.call(A,new lv("beforestart",{sourceEvent:N,target:g,identifier:z,active:s,x:F[0],y:F[1],dx:0,dy:0,dispatch:R}),P))!=null)return U=j.x-F[0]||0,W=j.y-F[1]||0,function V(I,H,q){var G=F,O;switch(I){case"start":o[z]=V,O=s++;break;case"end":delete o[z],--s;case"drag":F=Ir(q||H,M),O=s;break}R.call(I,A,new lv(I,{sourceEvent:H,subject:j,target:g,identifier:z,active:O,x:F[0]+U,y:F[1]+W,dx:F[0]-G[0],dy:F[1]-G[1],dispatch:R}),P)}}return g.filter=function(A){return arguments.length?(e=typeof A=="function"?A:Mh(!!A),g):e},g.container=function(A){return arguments.length?(t=typeof A=="function"?A:Mh(A),g):t},g.subject=function(A){return arguments.length?(n=typeof A=="function"?A:Mh(A),g):n},g.touchable=function(A){return arguments.length?(r=typeof A=="function"?A:Mh(!!A),g):r},g.on=function(){var A=a.on.apply(a,arguments);return A===a?g:A},g.clickDistance=function(A){return arguments.length?(p=(A=+A)*A,g):Math.sqrt(p)},g}function uv(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function AR(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function zu(){}var Lu=.7,Oh=1/Lu,qs="\\s*([+-]?\\d+)\\s*",Fu="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",fo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",WK=/^#([0-9a-f]{3,8})$/,XK=new RegExp(`^rgb\\(${qs},${qs},${qs}\\)$`),KK=new RegExp(`^rgb\\(${fo},${fo},${fo}\\)$`),ZK=new RegExp(`^rgba\\(${qs},${qs},${qs},${Fu}\\)$`),QK=new RegExp(`^rgba\\(${fo},${fo},${fo},${Fu}\\)$`),JK=new RegExp(`^hsl\\(${Fu},${fo},${fo}\\)$`),eZ=new RegExp(`^hsla\\(${Fu},${fo},${fo},${Fu}\\)$`),RR={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};uv(zu,Aa,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:MR,formatHex:MR,formatHex8:tZ,formatHsl:nZ,formatRgb:OR,toString:OR});function MR(){return this.rgb().formatHex()}function tZ(){return this.rgb().formatHex8()}function nZ(){return IR(this).formatHsl()}function OR(){return this.rgb().formatRgb()}function Aa(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=WK.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?NR(t):n===3?new Dn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Nh(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Nh(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=XK.exec(e))?new Dn(t[1],t[2],t[3],1):(t=KK.exec(e))?new Dn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ZK.exec(e))?Nh(t[1],t[2],t[3],t[4]):(t=QK.exec(e))?Nh(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=JK.exec(e))?jR(t[1],t[2]/100,t[3]/100,1):(t=eZ.exec(e))?jR(t[1],t[2]/100,t[3]/100,t[4]):RR.hasOwnProperty(e)?NR(RR[e]):e==="transparent"?new Dn(NaN,NaN,NaN,0):null}function NR(e){return new Dn(e>>16&255,e>>8&255,e&255,1)}function Nh(e,t,n,r){return r<=0&&(e=t=n=NaN),new Dn(e,t,n,r)}function rZ(e){return e instanceof zu||(e=Aa(e)),e?(e=e.rgb(),new Dn(e.r,e.g,e.b,e.opacity)):new Dn}function cv(e,t,n,r){return arguments.length===1?rZ(e):new Dn(e,t,n,r??1)}function Dn(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}uv(Dn,cv,AR(zu,{brighter(e){return e=e==null?Oh:Math.pow(Oh,e),new Dn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Lu:Math.pow(Lu,e),new Dn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Dn(Ra(this.r),Ra(this.g),Ra(this.b),Dh(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:DR,formatHex:DR,formatHex8:oZ,formatRgb:PR,toString:PR}));function DR(){return`#${Ma(this.r)}${Ma(this.g)}${Ma(this.b)}`}function oZ(){return`#${Ma(this.r)}${Ma(this.g)}${Ma(this.b)}${Ma((isNaN(this.opacity)?1:this.opacity)*255)}`}function PR(){const e=Dh(this.opacity);return`${e===1?"rgb(":"rgba("}${Ra(this.r)}, ${Ra(this.g)}, ${Ra(this.b)}${e===1?")":`, ${e})`}`}function Dh(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ra(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ma(e){return e=Ra(e),(e<16?"0":"")+e.toString(16)}function jR(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new zr(e,t,n,r)}function IR(e){if(e instanceof zr)return new zr(e.h,e.s,e.l,e.opacity);if(e instanceof zu||(e=Aa(e)),!e)return new zr;if(e instanceof zr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),a=Math.max(t,n,r),s=NaN,u=a-o,c=(a+o)/2;return u?(t===a?s=(n-r)/u+(n<r)*6:n===a?s=(r-t)/u+2:s=(t-n)/u+4,u/=c<.5?a+o:2-a-o,s*=60):u=c>0&&c<1?0:s,new zr(s,u,c,e.opacity)}function iZ(e,t,n,r){return arguments.length===1?IR(e):new zr(e,t,n,r??1)}function zr(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}uv(zr,iZ,AR(zu,{brighter(e){return e=e==null?Oh:Math.pow(Oh,e),new zr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Lu:Math.pow(Lu,e),new zr(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new Dn(fv(e>=240?e-240:e+120,o,r),fv(e,o,r),fv(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new zr(zR(this.h),Ph(this.s),Ph(this.l),Dh(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Dh(this.opacity);return`${e===1?"hsl(":"hsla("}${zR(this.h)}, ${Ph(this.s)*100}%, ${Ph(this.l)*100}%${e===1?")":`, ${e})`}`}}));function zR(e){return e=(e||0)%360,e<0?e+360:e}function Ph(e){return Math.max(0,Math.min(1,e||0))}function fv(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const dv=e=>()=>e;function aZ(e,t){return function(n){return e+n*t}}function sZ(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function lZ(e){return(e=+e)==1?LR:function(t,n){return n-t?sZ(t,n,e):dv(isNaN(t)?n:t)}}function LR(e,t){var n=t-e;return n?aZ(e,n):dv(isNaN(e)?t:e)}const jh=function e(t){var n=lZ(t);function r(o,a){var s=n((o=cv(o)).r,(a=cv(a)).r),u=n(o.g,a.g),c=n(o.b,a.b),f=LR(o.opacity,a.opacity);return function(h){return o.r=s(h),o.g=u(h),o.b=c(h),o.opacity=f(h),o+""}}return r.gamma=e,r}(1);function uZ(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(a){for(o=0;o<n;++o)r[o]=e[o]*(1-a)+t[o]*a;return r}}function cZ(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function fZ(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),a=new Array(n),s;for(s=0;s<r;++s)o[s]=$u(e[s],t[s]);for(;s<n;++s)a[s]=t[s];return function(u){for(s=0;s<r;++s)a[s]=o[s](u);return a}}function dZ(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function ho(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function hZ(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=$u(e[o],t[o]):r[o]=t[o];return function(a){for(o in n)r[o]=n[o](a);return r}}var hv=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,pv=new RegExp(hv.source,"g");function pZ(e){return function(){return e}}function mZ(e){return function(t){return e(t)+""}}function FR(e,t){var n=hv.lastIndex=pv.lastIndex=0,r,o,a,s=-1,u=[],c=[];for(e=e+"",t=t+"";(r=hv.exec(e))&&(o=pv.exec(t));)(a=o.index)>n&&(a=t.slice(n,a),u[s]?u[s]+=a:u[++s]=a),(r=r[0])===(o=o[0])?u[s]?u[s]+=o:u[++s]=o:(u[++s]=null,c.push({i:s,x:ho(r,o)})),n=pv.lastIndex;return n<t.length&&(a=t.slice(n),u[s]?u[s]+=a:u[++s]=a),u.length<2?c[0]?mZ(c[0].x):pZ(t):(t=c.length,function(f){for(var h=0,p;h<t;++h)u[(p=c[h]).i]=p.x(f);return u.join("")})}function $u(e,t){var n=typeof t,r;return t==null||n==="boolean"?dv(t):(n==="number"?ho:n==="string"?(r=Aa(t))?(t=r,jh):FR:t instanceof Aa?jh:t instanceof Date?dZ:cZ(t)?uZ:Array.isArray(t)?fZ:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?hZ:ho)(e,t)}var $R=180/Math.PI,mv={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function BR(e,t,n,r,o,a){var s,u,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(u=Math.sqrt(n*n+r*r))&&(n/=u,r/=u,c/=u),e*r<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:o,translateY:a,rotate:Math.atan2(t,e)*$R,skewX:Math.atan(c)*$R,scaleX:s,scaleY:u}}var Ih;function gZ(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?mv:BR(t.a,t.b,t.c,t.d,t.e,t.f)}function yZ(e){return e==null||(Ih||(Ih=document.createElementNS("http://www.w3.org/2000/svg","g")),Ih.setAttribute("transform",e),!(e=Ih.transform.baseVal.consolidate()))?mv:(e=e.matrix,BR(e.a,e.b,e.c,e.d,e.e,e.f))}function HR(e,t,n,r){function o(f){return f.length?f.pop()+" ":""}function a(f,h,p,g,y,w){if(f!==p||h!==g){var v=y.push("translate(",null,t,null,n);w.push({i:v-4,x:ho(f,p)},{i:v-2,x:ho(h,g)})}else(p||g)&&y.push("translate("+p+t+g+n)}function s(f,h,p,g){f!==h?(f-h>180?h+=360:h-f>180&&(f+=360),g.push({i:p.push(o(p)+"rotate(",null,r)-2,x:ho(f,h)})):h&&p.push(o(p)+"rotate("+h+r)}function u(f,h,p,g){f!==h?g.push({i:p.push(o(p)+"skewX(",null,r)-2,x:ho(f,h)}):h&&p.push(o(p)+"skewX("+h+r)}function c(f,h,p,g,y,w){if(f!==p||h!==g){var v=y.push(o(y)+"scale(",null,",",null,")");w.push({i:v-4,x:ho(f,p)},{i:v-2,x:ho(h,g)})}else(p!==1||g!==1)&&y.push(o(y)+"scale("+p+","+g+")")}return function(f,h){var p=[],g=[];return f=e(f),h=e(h),a(f.translateX,f.translateY,h.translateX,h.translateY,p,g),s(f.rotate,h.rotate,p,g),u(f.skewX,h.skewX,p,g),c(f.scaleX,f.scaleY,h.scaleX,h.scaleY,p,g),f=h=null,function(y){for(var w=-1,v=g.length,S;++w<v;)p[(S=g[w]).i]=S.x(y);return p.join("")}}}var vZ=HR(gZ,"px, ","px)","deg)"),bZ=HR(yZ,", ",")",")"),xZ=1e-12;function VR(e){return((e=Math.exp(e))+1/e)/2}function wZ(e){return((e=Math.exp(e))-1/e)/2}function _Z(e){return((e=Math.exp(2*e))-1)/(e+1)}const zh=function e(t,n,r){function o(a,s){var u=a[0],c=a[1],f=a[2],h=s[0],p=s[1],g=s[2],y=h-u,w=p-c,v=y*y+w*w,S,E;if(v<xZ)E=Math.log(g/f)/t,S=function(P){return[u+P*y,c+P*w,f*Math.exp(t*P*E)]};else{var T=Math.sqrt(v),k=(g*g-f*f+r*v)/(2*f*n*T),A=(g*g-f*f-r*v)/(2*g*n*T),M=Math.log(Math.sqrt(k*k+1)-k),N=Math.log(Math.sqrt(A*A+1)-A);E=(N-M)/t,S=function(P){var z=P*E,B=VR(M),R=f/(n*T)*(B*_Z(t*z+M)-wZ(M));return[u+R*y,c+R*w,f*B/VR(t*z+M)]}}return S.duration=E*1e3*t/Math.SQRT2,S}return o.rho=function(a){var s=Math.max(.001,+a),u=s*s,c=u*u;return e(s,u,c)},o}(Math.SQRT2,2,4);var Gs=0,Bu=0,Hu=0,UR=1e3,Lh,Vu,Fh=0,Oa=0,$h=0,Uu=typeof performance=="object"&&performance.now?performance:Date,qR=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function gv(){return Oa||(qR(SZ),Oa=Uu.now()+$h)}function SZ(){Oa=0}function Bh(){this._call=this._time=this._next=null}Bh.prototype=GR.prototype={constructor:Bh,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?gv():+n)+(t==null?0:+t),!this._next&&Vu!==this&&(Vu?Vu._next=this:Lh=this,Vu=this),this._call=e,this._time=n,yv()},stop:function(){this._call&&(this._call=null,this._time=1/0,yv())}};function GR(e,t,n){var r=new Bh;return r.restart(e,t,n),r}function EZ(){gv(),++Gs;for(var e=Lh,t;e;)(t=Oa-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Gs}function YR(){Oa=(Fh=Uu.now())+$h,Gs=Bu=0;try{EZ()}finally{Gs=0,kZ(),Oa=0}}function CZ(){var e=Uu.now(),t=e-Fh;t>UR&&($h-=t,Fh=e)}function kZ(){for(var e,t=Lh,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Lh=n);Vu=e,yv(r)}function yv(e){if(!Gs){Bu&&(Bu=clearTimeout(Bu));var t=e-Oa;t>24?(e<1/0&&(Bu=setTimeout(YR,e-Uu.now()-$h)),Hu&&(Hu=clearInterval(Hu))):(Hu||(Fh=Uu.now(),Hu=setInterval(CZ,UR)),Gs=1,qR(YR))}}function WR(e,t,n){var r=new Bh;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var TZ=kh("start","end","cancel","interrupt"),AZ=[],XR=0,KR=1,vv=2,Hh=3,ZR=4,bv=5,Vh=6;function Uh(e,t,n,r,o,a){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;RZ(e,n,{name:t,index:r,group:o,on:TZ,tween:AZ,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:XR})}function xv(e,t){var n=Lr(e,t);if(n.state>XR)throw new Error("too late; already scheduled");return n}function po(e,t){var n=Lr(e,t);if(n.state>Hh)throw new Error("too late; already running");return n}function Lr(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function RZ(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=GR(a,0,n.time);function a(f){n.state=KR,n.timer.restart(s,n.delay,n.time),n.delay<=f&&s(f-n.delay)}function s(f){var h,p,g,y;if(n.state!==KR)return c();for(h in r)if(y=r[h],y.name===n.name){if(y.state===Hh)return WR(s);y.state===ZR?(y.state=Vh,y.timer.stop(),y.on.call("interrupt",e,e.__data__,y.index,y.group),delete r[h]):+h<t&&(y.state=Vh,y.timer.stop(),y.on.call("cancel",e,e.__data__,y.index,y.group),delete r[h])}if(WR(function(){n.state===Hh&&(n.state=ZR,n.timer.restart(u,n.delay,n.time),u(f))}),n.state=vv,n.on.call("start",e,e.__data__,n.index,n.group),n.state===vv){for(n.state=Hh,o=new Array(g=n.tween.length),h=0,p=-1;h<g;++h)(y=n.tween[h].value.call(e,e.__data__,n.index,n.group))&&(o[++p]=y);o.length=p+1}}function u(f){for(var h=f<n.duration?n.ease.call(null,f/n.duration):(n.timer.restart(c),n.state=bv,1),p=-1,g=o.length;++p<g;)o[p].call(e,h);n.state===bv&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Vh,n.timer.stop(),delete r[t];for(var f in r)return;delete e.__transition}}function qh(e,t){var n=e.__transition,r,o,a=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((r=n[s]).name!==t){a=!1;continue}o=r.state>vv&&r.state<bv,r.state=Vh,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}a&&delete e.__transition}}function MZ(e){return this.each(function(){qh(this,e)})}function OZ(e,t){var n,r;return function(){var o=po(this,e),a=o.tween;if(a!==n){r=n=a;for(var s=0,u=r.length;s<u;++s)if(r[s].name===t){r=r.slice(),r.splice(s,1);break}}o.tween=r}}function NZ(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var a=po(this,e),s=a.tween;if(s!==r){o=(r=s).slice();for(var u={name:t,value:n},c=0,f=o.length;c<f;++c)if(o[c].name===t){o[c]=u;break}c===f&&o.push(u)}a.tween=o}}function DZ(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Lr(this.node(),n).tween,o=0,a=r.length,s;o<a;++o)if((s=r[o]).name===e)return s.value;return null}return this.each((t==null?OZ:NZ)(n,e,t))}function wv(e,t,n){var r=e._id;return e.each(function(){var o=po(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return Lr(o,r).value[t]}}function QR(e,t){var n;return(typeof t=="number"?ho:t instanceof Aa?jh:(n=Aa(t))?(t=n,jh):FR)(e,t)}function PZ(e){return function(){this.removeAttribute(e)}}function jZ(e){return function(){this.removeAttributeNS(e.space,e.local)}}function IZ(e,t,n){var r,o=n+"",a;return function(){var s=this.getAttribute(e);return s===o?null:s===r?a:a=t(r=s,n)}}function zZ(e,t,n){var r,o=n+"",a;return function(){var s=this.getAttributeNS(e.space,e.local);return s===o?null:s===r?a:a=t(r=s,n)}}function LZ(e,t,n){var r,o,a;return function(){var s,u=n(this),c;return u==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=u+"",s===c?null:s===r&&c===o?a:(o=c,a=t(r=s,u)))}}function FZ(e,t,n){var r,o,a;return function(){var s,u=n(this),c;return u==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=u+"",s===c?null:s===r&&c===o?a:(o=c,a=t(r=s,u)))}}function $Z(e,t){var n=Ah(e),r=n==="transform"?bZ:QR;return this.attrTween(e,typeof t=="function"?(n.local?FZ:LZ)(n,r,wv(this,"attr."+e,t)):t==null?(n.local?jZ:PZ)(n):(n.local?zZ:IZ)(n,r,t))}function BZ(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function HZ(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function VZ(e,t){var n,r;function o(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&HZ(e,a)),n}return o._value=t,o}function UZ(e,t){var n,r;function o(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&BZ(e,a)),n}return o._value=t,o}function qZ(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=Ah(e);return this.tween(n,(r.local?VZ:UZ)(r,t))}function GZ(e,t){return function(){xv(this,e).delay=+t.apply(this,arguments)}}function YZ(e,t){return t=+t,function(){xv(this,e).delay=t}}function WZ(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?GZ:YZ)(t,e)):Lr(this.node(),t).delay}function XZ(e,t){return function(){po(this,e).duration=+t.apply(this,arguments)}}function KZ(e,t){return t=+t,function(){po(this,e).duration=t}}function ZZ(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?XZ:KZ)(t,e)):Lr(this.node(),t).duration}function QZ(e,t){if(typeof t!="function")throw new Error;return function(){po(this,e).ease=t}}function JZ(e){var t=this._id;return arguments.length?this.each(QZ(t,e)):Lr(this.node(),t).ease}function eQ(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;po(this,e).ease=n}}function tQ(e){if(typeof e!="function")throw new Error;return this.each(eQ(this._id,e))}function nQ(e){typeof e!="function"&&(e=mR(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var a=t[o],s=a.length,u=r[o]=[],c,f=0;f<s;++f)(c=a[f])&&e.call(c,c.__data__,f,a)&&u.push(c);return new qo(r,this._parents,this._name,this._id)}function rQ(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,a=Math.min(r,o),s=new Array(r),u=0;u<a;++u)for(var c=t[u],f=n[u],h=c.length,p=s[u]=new Array(h),g,y=0;y<h;++y)(g=c[y]||f[y])&&(p[y]=g);for(;u<r;++u)s[u]=t[u];return new qo(s,this._parents,this._name,this._id)}function oQ(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function iQ(e,t,n){var r,o,a=oQ(t)?xv:po;return function(){var s=a(this,e),u=s.on;u!==r&&(o=(r=u).copy()).on(t,n),s.on=o}}function aQ(e,t){var n=this._id;return arguments.length<2?Lr(this.node(),n).on.on(e):this.each(iQ(n,e,t))}function sQ(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function lQ(){return this.on("end.remove",sQ(this._id))}function uQ(e){var t=this._name,n=this._id;typeof e!="function"&&(e=iv(e));for(var r=this._groups,o=r.length,a=new Array(o),s=0;s<o;++s)for(var u=r[s],c=u.length,f=a[s]=new Array(c),h,p,g=0;g<c;++g)(h=u[g])&&(p=e.call(h,h.__data__,g,u))&&("__data__"in h&&(p.__data__=h.__data__),f[g]=p,Uh(f[g],t,n,g,f,Lr(h,n)));return new qo(a,this._parents,t,n)}function cQ(e){var t=this._name,n=this._id;typeof e!="function"&&(e=pR(e));for(var r=this._groups,o=r.length,a=[],s=[],u=0;u<o;++u)for(var c=r[u],f=c.length,h,p=0;p<f;++p)if(h=c[p]){for(var g=e.call(h,h.__data__,p,c),y,w=Lr(h,n),v=0,S=g.length;v<S;++v)(y=g[v])&&Uh(y,t,n,v,g,w);a.push(g),s.push(h)}return new qo(a,s,t,n)}var fQ=ju.prototype.constructor;function dQ(){return new fQ(this._groups,this._parents)}function hQ(e,t){var n,r,o;return function(){var a=Vs(this,e),s=(this.style.removeProperty(e),Vs(this,e));return a===s?null:a===n&&s===r?o:o=t(n=a,r=s)}}function JR(e){return function(){this.style.removeProperty(e)}}function pQ(e,t,n){var r,o=n+"",a;return function(){var s=Vs(this,e);return s===o?null:s===r?a:a=t(r=s,n)}}function mQ(e,t,n){var r,o,a;return function(){var s=Vs(this,e),u=n(this),c=u+"";return u==null&&(c=u=(this.style.removeProperty(e),Vs(this,e))),s===c?null:s===r&&c===o?a:(o=c,a=t(r=s,u))}}function gQ(e,t){var n,r,o,a="style."+t,s="end."+a,u;return function(){var c=po(this,e),f=c.on,h=c.value[a]==null?u||(u=JR(t)):void 0;(f!==n||o!==h)&&(r=(n=f).copy()).on(s,o=h),c.on=r}}function yQ(e,t,n){var r=(e+="")=="transform"?vZ:QR;return t==null?this.styleTween(e,hQ(e,r)).on("end.style."+e,JR(e)):typeof t=="function"?this.styleTween(e,mQ(e,r,wv(this,"style."+e,t))).each(gQ(this._id,e)):this.styleTween(e,pQ(e,r,t),n).on("end.style."+e,null)}function vQ(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function bQ(e,t,n){var r,o;function a(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&vQ(e,s,n)),r}return a._value=t,a}function xQ(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,bQ(e,t,n??""))}function wQ(e){return function(){this.textContent=e}}function _Q(e){return function(){var t=e(this);this.textContent=t??""}}function SQ(e){return this.tween("text",typeof e=="function"?_Q(wv(this,"text",e)):wQ(e==null?"":e+""))}function EQ(e){return function(t){this.textContent=e.call(this,t)}}function CQ(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&EQ(o)),t}return r._value=e,r}function kQ(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,CQ(e))}function TQ(){for(var e=this._name,t=this._id,n=eM(),r=this._groups,o=r.length,a=0;a<o;++a)for(var s=r[a],u=s.length,c,f=0;f<u;++f)if(c=s[f]){var h=Lr(c,t);Uh(c,e,n,f,s,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new qo(r,this._parents,e,n)}function AQ(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(a,s){var u={value:s},c={value:function(){--o===0&&a()}};n.each(function(){var f=po(this,r),h=f.on;h!==e&&(t=(e=h).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(c)),f.on=t}),o===0&&a()})}var RQ=0;function qo(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function eM(){return++RQ}var Go=ju.prototype;qo.prototype={constructor:qo,select:uQ,selectAll:cQ,selectChild:Go.selectChild,selectChildren:Go.selectChildren,filter:nQ,merge:rQ,selection:dQ,transition:TQ,call:Go.call,nodes:Go.nodes,node:Go.node,size:Go.size,empty:Go.empty,each:Go.each,on:aQ,attr:$Z,attrTween:qZ,style:yQ,styleTween:xQ,text:SQ,textTween:kQ,remove:lQ,tween:DZ,delay:WZ,duration:ZZ,ease:JZ,easeVarying:tQ,end:AQ,[Symbol.iterator]:Go[Symbol.iterator]};function MQ(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var OQ={time:null,delay:0,duration:250,ease:MQ};function NQ(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function DQ(e){var t,n;e instanceof qo?(t=e._id,e=e._name):(t=eM(),(n=OQ).time=gv(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,a=0;a<o;++a)for(var s=r[a],u=s.length,c,f=0;f<u;++f)(c=s[f])&&Uh(c,e,t,f,s,n||NQ(c,t));return new qo(r,this._parents,e,t)}ju.prototype.interrupt=MZ,ju.prototype.transition=DQ;const Gh=e=>()=>e;function PQ(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Yo(e,t,n){this.k=e,this.x=t,this.y=n}Yo.prototype={constructor:Yo,scale:function(e){return e===1?this:new Yo(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Yo(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Yh=new Yo(1,0,0);tM.prototype=Yo.prototype;function tM(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Yh;return e.__zoom}function _v(e){e.stopImmediatePropagation()}function qu(e){e.preventDefault(),e.stopImmediatePropagation()}function jQ(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function IQ(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function nM(){return this.__zoom||Yh}function zQ(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function LQ(){return navigator.maxTouchPoints||"ontouchstart"in this}function FQ(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),s>a?(a+s)/2:Math.min(0,a)||Math.max(0,s))}function rM(){var e=jQ,t=IQ,n=FQ,r=zQ,o=LQ,a=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],u=250,c=zh,f=kh("start","zoom","end"),h,p,g,y=500,w=150,v=0,S=10;function E(j){j.property("__zoom",nM).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",R).filter(o).on("touchstart.zoom",F).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",W).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(j,V,I,H){var q=j.selection?j.selection():j;q.property("__zoom",nM),j!==q?M(j,V,I,H):q.interrupt().each(function(){N(this,arguments).event(H).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(j,V,I,H){E.scaleTo(j,function(){var q=this.__zoom.k,G=typeof V=="function"?V.apply(this,arguments):V;return q*G},I,H)},E.scaleTo=function(j,V,I,H){E.transform(j,function(){var q=t.apply(this,arguments),G=this.__zoom,O=I==null?A(q):typeof I=="function"?I.apply(this,arguments):I,Y=G.invert(O),Z=typeof V=="function"?V.apply(this,arguments):V;return n(k(T(G,Z),O,Y),q,s)},I,H)},E.translateBy=function(j,V,I,H){E.transform(j,function(){return n(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof I=="function"?I.apply(this,arguments):I),t.apply(this,arguments),s)},null,H)},E.translateTo=function(j,V,I,H,q){E.transform(j,function(){var G=t.apply(this,arguments),O=this.__zoom,Y=H==null?A(G):typeof H=="function"?H.apply(this,arguments):H;return n(Yh.translate(Y[0],Y[1]).scale(O.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof I=="function"?-I.apply(this,arguments):-I),G,s)},H,q)};function T(j,V){return V=Math.max(a[0],Math.min(a[1],V)),V===j.k?j:new Yo(V,j.x,j.y)}function k(j,V,I){var H=V[0]-I[0]*j.k,q=V[1]-I[1]*j.k;return H===j.x&&q===j.y?j:new Yo(j.k,H,q)}function A(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function M(j,V,I,H){j.on("start.zoom",function(){N(this,arguments).event(H).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(H).end()}).tween("zoom",function(){var q=this,G=arguments,O=N(q,G).event(H),Y=t.apply(q,G),Z=I==null?A(Y):typeof I=="function"?I.apply(q,G):I,L=Math.max(Y[1][0]-Y[0][0],Y[1][1]-Y[0][1]),te=q.__zoom,he=typeof V=="function"?V.apply(q,G):V,oe=c(te.invert(Z).concat(L/te.k),he.invert(Z).concat(L/he.k));return function(de){if(de===1)de=he;else{var le=oe(de),ye=L/le[2];de=new Yo(ye,Z[0]-le[0]*ye,Z[1]-le[1]*ye)}O.zoom(null,de)}})}function N(j,V,I){return!I&&j.__zooming||new P(j,V)}function P(j,V){this.that=j,this.args=V,this.active=0,this.sourceEvent=null,this.extent=t.apply(j,V),this.taps=0}P.prototype={event:function(j){return j&&(this.sourceEvent=j),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(j,V){return this.mouse&&j!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var V=Zn(this.that).datum();f.call(j,this.that,new PQ(j,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:f}),V)}};function z(j,...V){if(!e.apply(this,arguments))return;var I=N(this,V).event(j),H=this.__zoom,q=Math.max(a[0],Math.min(a[1],H.k*Math.pow(2,r.apply(this,arguments)))),G=Ir(j);if(I.wheel)(I.mouse[0][0]!==G[0]||I.mouse[0][1]!==G[1])&&(I.mouse[1]=H.invert(I.mouse[0]=G)),clearTimeout(I.wheel);else{if(H.k===q)return;I.mouse=[G,H.invert(G)],qh(this),I.start()}qu(j),I.wheel=setTimeout(O,w),I.zoom("mouse",n(k(T(H,q),I.mouse[0],I.mouse[1]),I.extent,s));function O(){I.wheel=null,I.end()}}function B(j,...V){if(g||!e.apply(this,arguments))return;var I=j.currentTarget,H=N(this,V,!0).event(j),q=Zn(j.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",L,!0),G=Ir(j,I),O=j.clientX,Y=j.clientY;CR(j.view),_v(j),H.mouse=[G,this.__zoom.invert(G)],qh(this),H.start();function Z(te){if(qu(te),!H.moved){var he=te.clientX-O,oe=te.clientY-Y;H.moved=he*he+oe*oe>v}H.event(te).zoom("mouse",n(k(H.that.__zoom,H.mouse[0]=Ir(te,I),H.mouse[1]),H.extent,s))}function L(te){q.on("mousemove.zoom mouseup.zoom",null),kR(te.view,H.moved),qu(te),H.event(te).end()}}function R(j,...V){if(e.apply(this,arguments)){var I=this.__zoom,H=Ir(j.changedTouches?j.changedTouches[0]:j,this),q=I.invert(H),G=I.k*(j.shiftKey?.5:2),O=n(k(T(I,G),H,q),t.apply(this,V),s);qu(j),u>0?Zn(this).transition().duration(u).call(M,O,H,j):Zn(this).call(E.transform,O,H,j)}}function F(j,...V){if(e.apply(this,arguments)){var I=j.touches,H=I.length,q=N(this,V,j.changedTouches.length===H).event(j),G,O,Y,Z;for(_v(j),O=0;O<H;++O)Y=I[O],Z=Ir(Y,this),Z=[Z,this.__zoom.invert(Z),Y.identifier],q.touch0?!q.touch1&&q.touch0[2]!==Z[2]&&(q.touch1=Z,q.taps=0):(q.touch0=Z,G=!0,q.taps=1+!!h);h&&(h=clearTimeout(h)),G&&(q.taps<2&&(p=Z[0],h=setTimeout(function(){h=null},y)),qh(this),q.start())}}function U(j,...V){if(this.__zooming){var I=N(this,V).event(j),H=j.changedTouches,q=H.length,G,O,Y,Z;for(qu(j),G=0;G<q;++G)O=H[G],Y=Ir(O,this),I.touch0&&I.touch0[2]===O.identifier?I.touch0[0]=Y:I.touch1&&I.touch1[2]===O.identifier&&(I.touch1[0]=Y);if(O=I.that.__zoom,I.touch1){var L=I.touch0[0],te=I.touch0[1],he=I.touch1[0],oe=I.touch1[1],de=(de=he[0]-L[0])*de+(de=he[1]-L[1])*de,le=(le=oe[0]-te[0])*le+(le=oe[1]-te[1])*le;O=T(O,Math.sqrt(de/le)),Y=[(L[0]+he[0])/2,(L[1]+he[1])/2],Z=[(te[0]+oe[0])/2,(te[1]+oe[1])/2]}else if(I.touch0)Y=I.touch0[0],Z=I.touch0[1];else return;I.zoom("touch",n(k(O,Y,Z),I.extent,s))}}function W(j,...V){if(this.__zooming){var I=N(this,V).event(j),H=j.changedTouches,q=H.length,G,O;for(_v(j),g&&clearTimeout(g),g=setTimeout(function(){g=null},y),G=0;G<q;++G)O=H[G],I.touch0&&I.touch0[2]===O.identifier?delete I.touch0:I.touch1&&I.touch1[2]===O.identifier&&delete I.touch1;if(I.touch1&&!I.touch0&&(I.touch0=I.touch1,delete I.touch1),I.touch0)I.touch0[1]=this.__zoom.invert(I.touch0[0]);else if(I.end(),I.taps===2&&(O=Ir(O,this),Math.hypot(p[0]-O[0],p[1]-O[1])<S)){var Y=Zn(this).on("dblclick.zoom");Y&&Y.apply(this,arguments)}}}return E.wheelDelta=function(j){return arguments.length?(r=typeof j=="function"?j:Gh(+j),E):r},E.filter=function(j){return arguments.length?(e=typeof j=="function"?j:Gh(!!j),E):e},E.touchable=function(j){return arguments.length?(o=typeof j=="function"?j:Gh(!!j),E):o},E.extent=function(j){return arguments.length?(t=typeof j=="function"?j:Gh([[+j[0][0],+j[0][1]],[+j[1][0],+j[1][1]]]),E):t},E.scaleExtent=function(j){return arguments.length?(a[0]=+j[0],a[1]=+j[1],E):[a[0],a[1]]},E.translateExtent=function(j){return arguments.length?(s[0][0]=+j[0][0],s[1][0]=+j[1][0],s[0][1]=+j[0][1],s[1][1]=+j[1][1],E):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},E.constrain=function(j){return arguments.length?(n=j,E):n},E.duration=function(j){return arguments.length?(u=+j,E):u},E.interpolate=function(j){return arguments.length?(c=j,E):c},E.on=function(){var j=f.on.apply(f,arguments);return j===f?E:j},E.clickDistance=function(j){return arguments.length?(v=(j=+j)*j,E):Math.sqrt(v)},E.tapDistance=function(j){return arguments.length?(S=+j,E):S},E}const mo={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Gu=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],oM=["Enter"," ","Escape"],iM={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Ys;(function(e){e.Strict="strict",e.Loose="loose"})(Ys||(Ys={}));var Na;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Na||(Na={}));var Yu;(function(e){e.Partial="partial",e.Full="full"})(Yu||(Yu={}));const aM={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var Ni;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ni||(Ni={}));var Wh;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Wh||(Wh={}));var ke;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ke||(ke={}));const sM={[ke.Left]:ke.Right,[ke.Right]:ke.Left,[ke.Top]:ke.Bottom,[ke.Bottom]:ke.Top};function lM(e){return e===null?null:e?"valid":"invalid"}const uM=e=>"id"in e&&"source"in e&&"target"in e,$Q=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Sv=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Wu=(e,t=[0,0])=>{const{width:n,height:r}=Wo(e),o=e.origin??t,a=n*o[0],s=r*o[1];return{x:e.position.x-a,y:e.position.y-s}},BQ=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const a=typeof o=="string";let s=!t.nodeLookup&&!a?o:void 0;t.nodeLookup&&(s=a?t.nodeLookup.get(o):Sv(o)?o:t.nodeLookup.get(o.id));const u=s?Zh(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Xh(r,u)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Kh(n)},Xu=(e,t={})=>{if(e.size===0)return{x:0,y:0,width:0,height:0};let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return e.forEach(r=>{if(t.filter===void 0||t.filter(r)){const o=Zh(r);n=Xh(n,o)}}),Kh(n)},Ev=(e,t,[n,r,o]=[0,0,1],a=!1,s=!1)=>{const u={...Zu(t,[n,r,o]),width:t.width/o,height:t.height/o},c=[];for(const f of e.values()){const{measured:h,selectable:p=!0,hidden:g=!1}=f;if(s&&!p||g)continue;const y=h.width??f.width??f.initialWidth??null,w=h.height??f.height??f.initialHeight??null,v=Ku(u,Xs(f)),S=(y??0)*(w??0),E=a&&v>0;(!f.internals.handleBounds||E||v>=S||f.dragging)&&c.push(f)}return c},HQ=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function VQ(e,t){const n=new Map,r=t?.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&(t?.includeHiddenNodes||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function UQ({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:a},s){if(e.size===0)return Promise.resolve(!0);const u=VQ(e,s),c=Xu(u),f=kv(c,t,n,s?.minZoom??o,s?.maxZoom??a,s?.padding??.1);return await r.setViewport(f,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)}function cM({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:a}){const s=n.get(e),u=s.parentId?n.get(s.parentId):void 0,{x:c,y:f}=u?u.internals.positionAbsolute:{x:0,y:0},h=s.origin??r;let p=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!u)a?.("005",mo.error005());else{const y=u.measured.width,w=u.measured.height;y&&w&&(p=[[c,f],[c+y,f+w]])}else u&&Zs(s.extent)&&(p=[[s.extent[0][0]+c,s.extent[0][1]+f],[s.extent[1][0]+c,s.extent[1][1]+f]]);const g=Zs(p)?Da(t,p,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&a?.("015",mo.error015()),{position:{x:g.x-c+(s.measured.width??0)*h[0],y:g.y-f+(s.measured.height??0)*h[1]},positionAbsolute:g}}async function qQ({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const a=new Set(e.map(g=>g.id)),s=[];for(const g of n){if(g.deletable===!1)continue;const y=a.has(g.id),w=!y&&g.parentId&&s.find(v=>v.id===g.parentId);(y||w)&&s.push(g)}const u=new Set(t.map(g=>g.id)),c=r.filter(g=>g.deletable!==!1),h=HQ(s,c);for(const g of c)u.has(g.id)&&!h.find(w=>w.id===g.id)&&h.push(g);if(!o)return{edges:h,nodes:s};const p=await o({nodes:s,edges:h});return typeof p=="boolean"?p?{edges:h,nodes:s}:{edges:[],nodes:[]}:p}const Ws=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Da=(e={x:0,y:0},t,n)=>({x:Ws(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ws(e.y,t[0][1],t[1][1]-(n?.height??0))});function fM(e,t,n){const{width:r,height:o}=Wo(n),{x:a,y:s}=n.internals.positionAbsolute;return Da(e,[[a,s],[a+r,s+o]],t)}const dM=(e,t,n)=>e<t?Ws(Math.abs(e-t),1,t)/t:e>n?-Ws(Math.abs(e-n),1,t)/t:0,hM=(e,t,n=15,r=40)=>{const o=dM(e.x,r,t.width-r)*n,a=dM(e.y,r,t.height-r)*n;return[o,a]},Xh=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Cv=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Kh=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Xs=(e,t=[0,0])=>{const{x:n,y:r}=Sv(e)?e.internals.positionAbsolute:Wu(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Zh=(e,t=[0,0])=>{const{x:n,y:r}=Sv(e)?e.internals.positionAbsolute:Wu(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},pM=(e,t)=>Kh(Xh(Cv(e),Cv(t))),Ku=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},mM=e=>Fr(e.width)&&Fr(e.height)&&Fr(e.x)&&Fr(e.y),Fr=e=>!isNaN(e)&&isFinite(e),GQ=(e,t)=>{},Qh=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Zu=({x:e,y:t},[n,r,o],a=!1,s=[1,1])=>{const u={x:(e-n)/o,y:(t-r)/o};return a?Qh(u,s):u},Jh=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function Ks(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function YQ(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Ks(e,n),o=Ks(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=Ks(e.top??e.y??0,n),o=Ks(e.bottom??e.y??0,n),a=Ks(e.left??e.x??0,t),s=Ks(e.right??e.x??0,t);return{top:r,right:s,bottom:o,left:a,x:a+s,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function WQ(e,t,n,r,o,a){const{x:s,y:u}=Jh(e,[t,n,r]),{x:c,y:f}=Jh({x:e.x+e.width,y:e.y+e.height},[t,n,r]),h=o-c,p=a-f;return{left:Math.floor(s),top:Math.floor(u),right:Math.floor(h),bottom:Math.floor(p)}}const kv=(e,t,n,r,o,a)=>{const s=YQ(a,t,n),u=(t-s.x)/e.width,c=(n-s.y)/e.height,f=Math.min(u,c),h=Ws(f,r,o),p=e.x+e.width/2,g=e.y+e.height/2,y=t/2-p*h,w=n/2-g*h,v=WQ(e,y,w,h,t,n),S={left:Math.min(v.left-s.left,0),top:Math.min(v.top-s.top,0),right:Math.min(v.right-s.right,0),bottom:Math.min(v.bottom-s.bottom,0)};return{x:y-S.left+S.right,y:w-S.top+S.bottom,zoom:h}},ep=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Zs(e){return e!==void 0&&e!=="parent"}function Wo(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function gM(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function yM(e,t={width:0,height:0},n,r,o){const a={...e},s=r.get(n);if(s){const u=s.origin||o;a.x+=s.internals.positionAbsolute.x-(t.width??0)*u[0],a.y+=s.internals.positionAbsolute.y-(t.height??0)*u[1]}return a}function vM(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function XQ(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function KQ(e){return{...iM,...e||{}}}function Qu(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:a,y:s}=go(e),u=Zu({x:a-(o?.left??0),y:s-(o?.top??0)},r),{x:c,y:f}=n?Qh(u,t):u;return{xSnapped:c,ySnapped:f,...u}}const Tv=e=>({width:e.offsetWidth,height:e.offsetHeight}),bM=e=>e?.getRootNode?.()||window?.document,ZQ=["INPUT","SELECT","TEXTAREA"];function xM(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:ZQ.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const wM=e=>"clientX"in e,go=(e,t)=>{const n=wM(e),r=n?e.clientX:e.touches?.[0].clientX,o=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:o-(t?.top??0)}},_M=(e,t,n,r,o)=>{const a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(s=>{const u=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:o,position:s.getAttribute("data-handlepos"),x:(u.left-n.left)/r,y:(u.top-n.top)/r,...Tv(s)}})};function SM({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:a,targetControlX:s,targetControlY:u}){const c=e*.125+o*.375+s*.375+n*.125,f=t*.125+a*.375+u*.375+r*.125,h=Math.abs(c-e),p=Math.abs(f-t);return[c,f,h,p]}function tp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function EM({pos:e,x1:t,y1:n,x2:r,y2:o,c:a}){switch(e){case ke.Left:return[t-tp(t-r,a),n];case ke.Right:return[t+tp(r-t,a),n];case ke.Top:return[t,n-tp(n-o,a)];case ke.Bottom:return[t,n+tp(o-n,a)]}}function Av({sourceX:e,sourceY:t,sourcePosition:n=ke.Bottom,targetX:r,targetY:o,targetPosition:a=ke.Top,curvature:s=.25}){const[u,c]=EM({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[f,h]=EM({pos:a,x1:r,y1:o,x2:e,y2:t,c:s}),[p,g,y,w]=SM({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:u,sourceControlY:c,targetControlX:f,targetControlY:h});return[`M${e},${t} C${u},${c} ${f},${h} ${r},${o}`,p,g,y,w]}function CM({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,a=n<e?n+o:n-o,s=Math.abs(r-t)/2,u=r<t?r+s:r-s;return[a,u,o,s]}function QQ({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r,elevateOnSelect:o=!1}){if(r!==void 0)return r;const a=o&&n?1e3:0,s=Math.max(e.parentId?e.internals.z:0,t.parentId?t.internals.z:0);return a+s}function JQ({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const a=Xh(Zh(e),Zh(t));a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1);const s={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return Ku(s,Kh(a))>0}const eJ=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,tJ=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),nJ=(e,t)=>{if(!e.source||!e.target)return t;let n;return uM(e)?n={...e}:n={...e,id:eJ(e)},tJ(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))};function kM({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,a,s,u]=CM({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,a,s,u]}const TM={[ke.Left]:{x:-1,y:0},[ke.Right]:{x:1,y:0},[ke.Top]:{x:0,y:-1},[ke.Bottom]:{x:0,y:1}},rJ=({source:e,sourcePosition:t=ke.Bottom,target:n})=>t===ke.Left||t===ke.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},AM=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function oJ({source:e,sourcePosition:t=ke.Bottom,target:n,targetPosition:r=ke.Top,center:o,offset:a,stepPosition:s}){const u=TM[t],c=TM[r],f={x:e.x+u.x*a,y:e.y+u.y*a},h={x:n.x+c.x*a,y:n.y+c.y*a},p=rJ({source:f,sourcePosition:t,target:h}),g=p.x!==0?"x":"y",y=p[g];let w=[],v,S;const E={x:0,y:0},T={x:0,y:0},[,,k,A]=CM({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(u[g]*c[g]===-1){g==="x"?(v=o.x??f.x+(h.x-f.x)*s,S=o.y??(f.y+h.y)/2):(v=o.x??(f.x+h.x)/2,S=o.y??f.y+(h.y-f.y)*s);const N=[{x:v,y:f.y},{x:v,y:h.y}],P=[{x:f.x,y:S},{x:h.x,y:S}];u[g]===y?w=g==="x"?N:P:w=g==="x"?P:N}else{const N=[{x:f.x,y:h.y}],P=[{x:h.x,y:f.y}];if(g==="x"?w=u.x===y?P:N:w=u.y===y?N:P,t===r){const U=Math.abs(e[g]-n[g]);if(U<=a){const W=Math.min(a-1,a-U);u[g]===y?E[g]=(f[g]>e[g]?-1:1)*W:T[g]=(h[g]>n[g]?-1:1)*W}}if(t!==r){const U=g==="x"?"y":"x",W=u[g]===c[U],j=f[U]>h[U],V=f[U]<h[U];(u[g]===1&&(!W&&j||W&&V)||u[g]!==1&&(!W&&V||W&&j))&&(w=g==="x"?N:P)}const z={x:f.x+E.x,y:f.y+E.y},B={x:h.x+T.x,y:h.y+T.y},R=Math.max(Math.abs(z.x-w[0].x),Math.abs(B.x-w[0].x)),F=Math.max(Math.abs(z.y-w[0].y),Math.abs(B.y-w[0].y));R>=F?(v=(z.x+B.x)/2,S=w[0].y):(v=w[0].x,S=(z.y+B.y)/2)}return[[e,{x:f.x+E.x,y:f.y+E.y},...w,{x:h.x+T.x,y:h.y+T.y},n],v,S,k,A]}function iJ(e,t,n,r){const o=Math.min(AM(e,t)/2,AM(t,n)/2,r),{x:a,y:s}=t;if(e.x===a&&a===n.x||e.y===s&&s===n.y)return`L${a} ${s}`;if(e.y===s){const f=e.x<n.x?-1:1,h=e.y<n.y?1:-1;return`L ${a+o*f},${s}Q ${a},${s} ${a},${s+o*h}`}const u=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${a},${s+o*c}Q ${a},${s} ${a+o*u},${s}`}function Rv({sourceX:e,sourceY:t,sourcePosition:n=ke.Bottom,targetX:r,targetY:o,targetPosition:a=ke.Top,borderRadius:s=5,centerX:u,centerY:c,offset:f=20,stepPosition:h=.5}){const[p,g,y,w,v]=oJ({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:a,center:{x:u,y:c},offset:f,stepPosition:h});return[p.reduce((E,T,k)=>{let A="";return k>0&&k<p.length-1?A=iJ(p[k-1],T,p[k+1],s):A=`${k===0?"M":"L"}${T.x} ${T.y}`,E+=A,E},""),g,y,w,v]}function RM(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function aJ(e){const{sourceNode:t,targetNode:n}=e;if(!RM(t)||!RM(n))return null;const r=t.internals.handleBounds||MM(t.handles),o=n.internals.handleBounds||MM(n.handles),a=OM(r?.source??[],e.sourceHandle),s=OM(e.connectionMode===Ys.Strict?o?.target??[]:(o?.target??[]).concat(o?.source??[]),e.targetHandle);if(!a||!s)return e.onError?.("008",mo.error008(a?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const u=a?.position||ke.Bottom,c=s?.position||ke.Top,f=Ju(t,a,u),h=Ju(n,s,c);return{sourceX:f.x,sourceY:f.y,targetX:h.x,targetY:h.y,sourcePosition:u,targetPosition:c}}function MM(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function Ju(e,t,n=ke.Left,r=!1){const o=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:u}=t??Wo(e);if(r)return{x:o+s/2,y:a+u/2};switch(t?.position??n){case ke.Top:return{x:o+s/2,y:a};case ke.Right:return{x:o+s,y:a+u/2};case ke.Bottom:return{x:o+s/2,y:a+u};case ke.Left:return{x:o,y:a+u/2}}}function OM(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Mv(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function sJ(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const a=new Set;return e.reduce((s,u)=>([u.markerStart||r,u.markerEnd||o].forEach(c=>{if(c&&typeof c=="object"){const f=Mv(c,t);a.has(f)||(s.push({id:f,color:c.color||n,...c}),a.add(f))}}),s),[]).sort((s,u)=>s.id.localeCompare(u.id))}const Ov={nodeOrigin:[0,0],nodeExtent:Gu,elevateNodesOnSelect:!0,defaults:{}},lJ={...Ov,checkEquality:!0};function Nv(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function uJ(e,t,n){const r=Nv(Ov,n);for(const o of e.values())if(o.parentId)Pv(o,e,t,r);else{const a=Wu(o,r.nodeOrigin),s=Zs(o.extent)?o.extent:r.nodeExtent,u=Da(a,s,Wo(o));o.internals.positionAbsolute=u}}function Dv(e,t,n,r){const o=Nv(lJ,r);let a=e.length>0;const s=new Map(t),u=o?.elevateNodesOnSelect?1e3:0;t.clear(),n.clear();for(const c of e){let f=s.get(c.id);if(o.checkEquality&&c===f?.internals.userNode)t.set(c.id,f);else{const h=Wu(c,o.nodeOrigin),p=Zs(c.extent)?c.extent:o.nodeExtent,g=Da(h,p,Wo(c));f={...o.defaults,...c,measured:{width:c.measured?.width,height:c.measured?.height},internals:{positionAbsolute:g,handleBounds:c.measured?f?.internals.handleBounds:void 0,z:NM(c,u),userNode:c}},t.set(c.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(a=!1),c.parentId&&Pv(f,t,n,r)}return a}function cJ(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Pv(e,t,n,r){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:s}=Nv(Ov,r),u=e.parentId,c=t.get(u);if(!c){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}cJ(e,n);const f=o?1e3:0,{x:h,y:p,z:g}=fJ(e,c,a,s,f),{positionAbsolute:y}=e.internals,w=h!==y.x||p!==y.y;(w||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:h,y:p}:y,z:g}})}function NM(e,t){return(Fr(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function fJ(e,t,n,r,o){const{x:a,y:s}=t.internals.positionAbsolute,u=Wo(e),c=Wu(e,n),f=Zs(e.extent)?Da(c,e.extent,u):c;let h=Da({x:a+f.x,y:s+f.y},r,u);e.extent==="parent"&&(h=fM(h,u,t));const p=NM(e,o),g=t.internals.z??0;return{x:h.x,y:h.y,z:g>=p?g+1:p}}function jv(e,t,n,r=[0,0]){const o=[],a=new Map;for(const s of e){const u=t.get(s.parentId);if(!u)continue;const c=a.get(s.parentId)?.expandedRect??Xs(u),f=pM(c,s.rect);a.set(s.parentId,{expandedRect:f,parent:u})}return a.size>0&&a.forEach(({expandedRect:s,parent:u},c)=>{const f=u.internals.positionAbsolute,h=Wo(u),p=u.origin??r,g=s.x<f.x?Math.round(Math.abs(f.x-s.x)):0,y=s.y<f.y?Math.round(Math.abs(f.y-s.y)):0,w=Math.max(h.width,Math.round(s.width)),v=Math.max(h.height,Math.round(s.height)),S=(w-h.width)*p[0],E=(v-h.height)*p[1];(g>0||y>0||S||E)&&(o.push({id:c,type:"position",position:{x:u.position.x-g+S,y:u.position.y-y+E}}),n.get(c)?.forEach(T=>{e.some(k=>k.id===T.id)||o.push({id:T.id,type:"position",position:{x:T.position.x+g,y:T.position.y+y}})})),(h.width<s.width||h.height<s.height||g||y)&&o.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:w+(g?p[0]*g-S:0),height:v+(y?p[1]*y-E:0)}})}),o}function dJ(e,t,n,r,o,a){const s=r?.querySelector(".xyflow__viewport");let u=!1;if(!s)return{changes:[],updatedInternals:u};const c=[],f=window.getComputedStyle(s),{m22:h}=new window.DOMMatrixReadOnly(f.transform),p=[];for(const g of e.values()){const y=t.get(g.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),u=!0;continue}const w=Tv(g.nodeElement),v=y.measured.width!==w.width||y.measured.height!==w.height;if(!!(w.width&&w.height&&(v||!y.internals.handleBounds||g.force))){const E=g.nodeElement.getBoundingClientRect(),T=Zs(y.extent)?y.extent:a;let{positionAbsolute:k}=y.internals;y.parentId&&y.extent==="parent"?k=fM(k,w,t.get(y.parentId)):T&&(k=Da(k,T,w));const A={...y,measured:w,internals:{...y.internals,positionAbsolute:k,handleBounds:{source:_M("source",g.nodeElement,E,h,y.id),target:_M("target",g.nodeElement,E,h,y.id)}}};t.set(y.id,A),y.parentId&&Pv(A,t,n,{nodeOrigin:o}),u=!0,v&&(c.push({id:y.id,type:"dimensions",dimensions:w}),y.expandParent&&y.parentId&&p.push({id:y.id,parentId:y.parentId,rect:Xs(A,o)}))}}if(p.length>0){const g=jv(p,t,n,o);c.push(...g)}return{changes:c,updatedInternals:u}}async function hJ({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,a]],r),u=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(u)}function DM(e,t,n,r,o,a){let s=o;const u=r.get(s)||new Map;r.set(s,u.set(n,t)),s=`${o}-${e}`;const c=r.get(s)||new Map;if(r.set(s,c.set(n,t)),a){s=`${o}-${e}-${a}`;const f=r.get(s)||new Map;r.set(s,f.set(n,t))}}function PM(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:a,sourceHandle:s=null,targetHandle:u=null}=r,c={edgeId:r.id,source:o,target:a,sourceHandle:s,targetHandle:u},f=`${o}-${s}--${a}-${u}`,h=`${a}-${u}--${o}-${s}`;DM("source",c,h,e,o,s),DM("target",c,f,e,a,u),t.set(r.id,r)}}function jM(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:jM(n,t):!1}function IM(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function pJ(e,t,n,r){const o=new Map;for(const[a,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!jM(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const u=e.get(a);u&&o.set(a,{id:a,position:u.position||{x:0,y:0},distance:{x:n.x-u.internals.positionAbsolute.x,y:n.y-u.internals.positionAbsolute.y},extent:u.extent,parentId:u.parentId,origin:u.origin,expandParent:u.expandParent,internals:{positionAbsolute:u.internals.positionAbsolute||{x:0,y:0}},measured:{width:u.measured.width??0,height:u.measured.height??0}})}return o}function Iv({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){const o=[];for(const[s,u]of t){const c=n.get(s)?.internals.userNode;c&&o.push({...c,position:u.position,dragging:r})}if(!e)return[o[0],o];const a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:o[0],o]}function mJ({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let a={x:null,y:null},s=0,u=new Map,c=!1,f={x:0,y:0},h=null,p=!1,g=null,y=!1,w=!1;function v({noDragClassName:E,handleSelector:T,domNode:k,isSelectable:A,nodeId:M,nodeClickDistance:N=0}){g=Zn(k);function P({x:F,y:U},W){const{nodeLookup:j,nodeExtent:V,snapGrid:I,snapToGrid:H,nodeOrigin:q,onNodeDrag:G,onSelectionDrag:O,onError:Y,updateNodePositions:Z}=t();a={x:F,y:U};let L=!1,te={x:0,y:0,x2:0,y2:0};if(u.size>1&&V){const he=Xu(u);te=Cv(he)}for(const[he,oe]of u){if(!j.has(he))continue;let de={x:F-oe.distance.x,y:U-oe.distance.y};H&&(de=Qh(de,I));let le=[[V[0][0],V[0][1]],[V[1][0],V[1][1]]];if(u.size>1&&V&&!oe.extent){const{positionAbsolute:Ne}=oe.internals,we=Ne.x-te.x+V[0][0],Te=Ne.x+oe.measured.width-te.x2+V[1][0],_e=Ne.y-te.y+V[0][1],Xe=Ne.y+oe.measured.height-te.y2+V[1][1];le=[[we,_e],[Te,Xe]]}const{position:ye,positionAbsolute:je}=cM({nodeId:he,nextPosition:de,nodeLookup:j,nodeExtent:le,nodeOrigin:q,onError:Y});L=L||oe.position.x!==ye.x||oe.position.y!==ye.y,oe.position=ye,oe.internals.positionAbsolute=je}if(w=w||L,!!L&&(Z(u,!0),W&&(r||G||!M&&O))){const[he,oe]=Iv({nodeId:M,dragItems:u,nodeLookup:j});r?.(W,u,he,oe),G?.(W,he,oe),M||O?.(W,oe)}}async function z(){if(!h)return;const{transform:F,panBy:U,autoPanSpeed:W,autoPanOnNodeDrag:j}=t();if(!j){c=!1,cancelAnimationFrame(s);return}const[V,I]=hM(f,h,W);(V!==0||I!==0)&&(a.x=(a.x??0)-V/F[2],a.y=(a.y??0)-I/F[2],await U({x:V,y:I})&&P(a,null)),s=requestAnimationFrame(z)}function B(F){const{nodeLookup:U,multiSelectionActive:W,nodesDraggable:j,transform:V,snapGrid:I,snapToGrid:H,selectNodesOnDrag:q,onNodeDragStart:G,onSelectionDragStart:O,unselectNodesAndEdges:Y}=t();p=!0,(!q||!A)&&!W&&M&&(U.get(M)?.selected||Y()),A&&q&&M&&e?.(M);const Z=Qu(F.sourceEvent,{transform:V,snapGrid:I,snapToGrid:H,containerBounds:h});if(a=Z,u=pJ(U,j,Z,M),u.size>0&&(n||G||!M&&O)){const[L,te]=Iv({nodeId:M,dragItems:u,nodeLookup:U});n?.(F.sourceEvent,u,L,te),G?.(F.sourceEvent,L,te),M||O?.(F.sourceEvent,te)}}const R=TR().clickDistance(N).on("start",F=>{const{domNode:U,nodeDragThreshold:W,transform:j,snapGrid:V,snapToGrid:I}=t();h=U?.getBoundingClientRect()||null,y=!1,w=!1,W===0&&B(F),a=Qu(F.sourceEvent,{transform:j,snapGrid:V,snapToGrid:I,containerBounds:h}),f=go(F.sourceEvent,h)}).on("drag",F=>{const{autoPanOnNodeDrag:U,transform:W,snapGrid:j,snapToGrid:V,nodeDragThreshold:I,nodeLookup:H}=t(),q=Qu(F.sourceEvent,{transform:W,snapGrid:j,snapToGrid:V,containerBounds:h});if((F.sourceEvent.type==="touchmove"&&F.sourceEvent.touches.length>1||M&&!H.has(M))&&(y=!0),!y){if(!c&&U&&p&&(c=!0,z()),!p){const G=q.xSnapped-(a.x??0),O=q.ySnapped-(a.y??0);Math.sqrt(G*G+O*O)>I&&B(F)}(a.x!==q.xSnapped||a.y!==q.ySnapped)&&u&&p&&(f=go(F.sourceEvent,h),P(q,F.sourceEvent))}}).on("end",F=>{if(!(!p||y)&&(c=!1,p=!1,cancelAnimationFrame(s),u.size>0)){const{nodeLookup:U,updateNodePositions:W,onNodeDragStop:j,onSelectionDragStop:V}=t();if(w&&(W(u,!1),w=!1),o||j||!M&&V){const[I,H]=Iv({nodeId:M,dragItems:u,nodeLookup:U,dragging:!1});o?.(F.sourceEvent,u,I,H),j?.(F.sourceEvent,I,H),M||V?.(F.sourceEvent,H)}}}).filter(F=>{const U=F.target;return!F.button&&(!E||!IM(U,`.${E}`,k))&&(!T||IM(U,T,k))});g.call(R)}function S(){g?.on(".drag",null)}return{update:v,destroy:S}}function gJ(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const a of t.values())Ku(o,Xs(a))>0&&r.push(a);return r}const yJ=250;function vJ(e,t,n,r){let o=[],a=1/0;const s=gJ(e,n,t+yJ);for(const u of s){const c=[...u.internals.handleBounds?.source??[],...u.internals.handleBounds?.target??[]];for(const f of c){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:h,y:p}=Ju(u,f,f.position,!0),g=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(p-e.y,2));g>t||(g<a?(o=[{...f,x:h,y:p}],a=g):g===a&&o.push({...f,x:h,y:p}))}}if(!o.length)return null;if(o.length>1){const u=r.type==="source"?"target":"source";return o.find(c=>c.type===u)??o[0]}return o[0]}function zM(e,t,n,r,o,a=!1){const s=r.get(e);if(!s)return null;const u=o==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],c=(n?u?.find(f=>f.id===n):u?.[0])??null;return c&&a?{...c,...Ju(s,c,c.position,!0)}:c}function LM(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function bJ(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const FM=()=>!0;function xJ(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:a,isTarget:s,domNode:u,nodeLookup:c,lib:f,autoPanOnConnect:h,flowId:p,panBy:g,cancelConnection:y,onConnectStart:w,onConnect:v,onConnectEnd:S,isValidConnection:E=FM,onReconnectEnd:T,updateConnection:k,getTransform:A,getFromHandle:M,autoPanSpeed:N,dragThreshold:P=1}){const z=bM(e.target);let B=0,R;const{x:F,y:U}=go(e),W=z?.elementFromPoint(F,U),j=LM(a,W),V=u?.getBoundingClientRect();let I=!1;if(!V||!j)return;const H=zM(o,j,r,c,t);if(!H)return;let q=go(e,V),G=!1,O=null,Y=!1,Z=null;function L(){if(!h||!V)return;const[Ne,we]=hM(q,V,N);g({x:Ne,y:we}),B=requestAnimationFrame(L)}const te={...H,nodeId:o,type:j,position:H.position},he=c.get(o);let de={inProgress:!0,isValid:null,from:Ju(he,te,ke.Left,!0),fromHandle:te,fromPosition:te.position,fromNode:he,to:q,toHandle:null,toPosition:sM[te.position],toNode:null};function le(){I=!0,k(de),w?.(e,{nodeId:o,handleId:r,handleType:j})}P===0&&le();function ye(Ne){if(!I){const{x:Xe,y:Ct}=go(Ne),ft=Xe-F,yn=Ct-U;if(!(ft*ft+yn*yn>P*P))return;le()}if(!M()||!te){je(Ne);return}const we=A();q=go(Ne,V),R=vJ(Zu(q,we,!1,[1,1]),n,c,te),G||(L(),G=!0);const Te=$M(Ne,{handle:R,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:E,doc:z,lib:f,flowId:p,nodeLookup:c});Z=Te.handleDomNode,O=Te.connection,Y=bJ(!!R,Te.isValid);const _e={...de,isValid:Y,to:Te.toHandle&&Y?Jh({x:Te.toHandle.x,y:Te.toHandle.y},we):q,toHandle:Te.toHandle,toPosition:Y&&Te.toHandle?Te.toHandle.position:sM[te.position],toNode:Te.toHandle?c.get(Te.toHandle.nodeId):null};Y&&R&&de.toHandle&&_e.toHandle&&de.toHandle.type===_e.toHandle.type&&de.toHandle.nodeId===_e.toHandle.nodeId&&de.toHandle.id===_e.toHandle.id&&de.to.x===_e.to.x&&de.to.y===_e.to.y||(k(_e),de=_e)}function je(Ne){if(I){(R||Z)&&O&&Y&&v?.(O);const{inProgress:we,...Te}=de,_e={...Te,toPosition:de.toHandle?de.toPosition:null};S?.(Ne,_e),a&&T?.(Ne,_e)}y(),cancelAnimationFrame(B),G=!1,Y=!1,O=null,Z=null,z.removeEventListener("mousemove",ye),z.removeEventListener("mouseup",je),z.removeEventListener("touchmove",ye),z.removeEventListener("touchend",je)}z.addEventListener("mousemove",ye),z.addEventListener("mouseup",je),z.addEventListener("touchmove",ye),z.addEventListener("touchend",je)}function $M(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:a,doc:s,lib:u,flowId:c,isValidConnection:f=FM,nodeLookup:h}){const p=a==="target",g=t?s.querySelector(`.${u}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:y,y:w}=go(e),v=s.elementFromPoint(y,w),S=v?.classList.contains(`${u}-flow__handle`)?v:g,E={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const T=LM(void 0,S),k=S.getAttribute("data-nodeid"),A=S.getAttribute("data-handleid"),M=S.classList.contains("connectable"),N=S.classList.contains("connectableend");if(!k||!T)return E;const P={source:p?k:r,sourceHandle:p?A:o,target:p?r:k,targetHandle:p?o:A};E.connection=P;const B=M&&N&&(n===Ys.Strict?p&&T==="source"||!p&&T==="target":k!==r||A!==o);E.isValid=B&&f(P),E.toHandle=zM(k,T,A,h,n,!0)}return E}const zv={onPointerDown:xJ,isValid:$M};function wJ({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=Zn(e);function a({translateExtent:u,width:c,height:f,zoomStep:h=10,pannable:p=!0,zoomable:g=!0,inversePan:y=!1}){const w=k=>{const A=n();if(k.sourceEvent.type!=="wheel"||!t)return;const M=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*h,N=A[2]*Math.pow(2,M);t.scaleTo(N)};let v=[0,0];const S=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(v=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},E=k=>{const A=n();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!t)return;const M=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],N=[M[0]-v[0],M[1]-v[1]];v=M;const P=r()*Math.max(A[2],Math.log(A[2]))*(y?-1:1),z={x:A[0]-N[0]*P,y:A[1]-N[1]*P},B=[[0,0],[c,f]];t.setViewportConstrained({x:z.x,y:z.y,zoom:A[2]},B,u)},T=rM().on("start",S).on("zoom",p?E:null).on("zoom.wheel",g?w:null);o.call(T,{})}function s(){o.on("zoom",null)}return{update:a,destroy:s,pointer:Ir}}const _J=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,np=e=>({x:e.x,y:e.y,zoom:e.k}),Lv=({x:e,y:t,zoom:n})=>Yh.translate(e,t).scale(n),Qs=(e,t)=>e.target.closest(`.${t}`),BM=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),SJ=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Fv=(e,t=0,n=SJ,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},HM=e=>{const t=e.ctrlKey&&ep()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function EJ({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:a,zoomOnPinch:s,onPanZoomStart:u,onPanZoom:c,onPanZoomEnd:f}){return h=>{if(Qs(h,t))return!1;h.preventDefault(),h.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(h.ctrlKey&&s){const S=Ir(h),E=HM(h),T=p*Math.pow(2,E);r.scaleTo(n,T,S,h);return}const g=h.deltaMode===1?20:1;let y=o===Na.Vertical?0:h.deltaX*g,w=o===Na.Horizontal?0:h.deltaY*g;!ep()&&h.shiftKey&&o!==Na.Vertical&&(y=h.deltaY*g,w=0),r.translateBy(n,-(y/p)*a,-(w/p)*a,{internal:!0});const v=np(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling||(e.isPanScrolling=!0,u?.(h,v)),e.isPanScrolling&&(c?.(h,v),e.panScrollTimeout=setTimeout(()=>{f?.(h,v),e.isPanScrolling=!1},150))}}function CJ({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const a=r.type==="wheel",s=!t&&a&&!r.ctrlKey,u=Qs(r,e);if(r.ctrlKey&&a&&u&&r.preventDefault(),s||u)return null;r.preventDefault(),n.call(this,r,o)}}function kJ({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;const o=np(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=o,r.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(r.sourceEvent,o)}}function TJ({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return a=>{e.usedRightMouseButton=!!(n&&BM(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),o&&!a.sourceEvent?.internal&&o?.(a.sourceEvent,np(a.transform))}}function AJ({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:a}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&BM(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&a(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o&&_J(e.prevViewport,s.transform))){const u=np(s.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o?.(s.sourceEvent,u)},n?150:0)}}}function RJ({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:a,userSelectionActive:s,noWheelClassName:u,noPanClassName:c,lib:f}){return h=>{const p=e||t,g=n&&h.ctrlKey;if(h.button===1&&h.type==="mousedown"&&(Qs(h,`${f}-flow__node`)||Qs(h,`${f}-flow__edge`)))return!0;if(!r&&!p&&!o&&!a&&!n||s||Qs(h,u)&&h.type==="wheel"||Qs(h,c)&&(h.type!=="wheel"||o&&h.type==="wheel"&&!e)||!n&&h.ctrlKey&&h.type==="wheel")return!1;if(!n&&h.type==="touchstart"&&h.touches?.length>1)return h.preventDefault(),!1;if(!p&&!o&&!g&&h.type==="wheel"||!r&&(h.type==="mousedown"||h.type==="touchstart")||Array.isArray(r)&&!r.includes(h.button)&&h.type==="mousedown")return!1;const y=Array.isArray(r)&&r.includes(h.button)||!h.button||h.button<=1;return(!h.ctrlKey||h.type==="wheel")&&y}}function MJ({domNode:e,minZoom:t,maxZoom:n,paneClickDistance:r,translateExtent:o,viewport:a,onPanZoom:s,onPanZoomStart:u,onPanZoomEnd:c,onDraggingChange:f}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),g=rM().clickDistance(!Fr(r)||r<0?0:r).scaleExtent([t,n]).translateExtent(o),y=Zn(e).call(g);k({x:a.x,y:a.y,zoom:Ws(a.zoom,t,n)},[[0,0],[p.width,p.height]],o);const w=y.on("wheel.zoom"),v=y.on("dblclick.zoom");g.wheelDelta(HM);function S(U,W){return y?new Promise(j=>{g?.interpolate(W?.interpolate==="linear"?$u:zh).transform(Fv(y,W?.duration,W?.ease,()=>j(!0)),U)}):Promise.resolve(!1)}function E({noWheelClassName:U,noPanClassName:W,onPaneContextMenu:j,userSelectionActive:V,panOnScroll:I,panOnDrag:H,panOnScrollMode:q,panOnScrollSpeed:G,preventScrolling:O,zoomOnPinch:Y,zoomOnScroll:Z,zoomOnDoubleClick:L,zoomActivationKeyPressed:te,lib:he,onTransformChange:oe}){V&&!h.isZoomingOrPanning&&T();const le=I&&!te&&!V?EJ({zoomPanValues:h,noWheelClassName:U,d3Selection:y,d3Zoom:g,panOnScrollMode:q,panOnScrollSpeed:G,zoomOnPinch:Y,onPanZoomStart:u,onPanZoom:s,onPanZoomEnd:c}):CJ({noWheelClassName:U,preventScrolling:O,d3ZoomHandler:w});if(y.on("wheel.zoom",le,{passive:!1}),!V){const je=kJ({zoomPanValues:h,onDraggingChange:f,onPanZoomStart:u});g.on("start",je);const Ne=TJ({zoomPanValues:h,panOnDrag:H,onPaneContextMenu:!!j,onPanZoom:s,onTransformChange:oe});g.on("zoom",Ne);const we=AJ({zoomPanValues:h,panOnDrag:H,panOnScroll:I,onPaneContextMenu:j,onPanZoomEnd:c,onDraggingChange:f});g.on("end",we)}const ye=RJ({zoomActivationKeyPressed:te,panOnDrag:H,zoomOnScroll:Z,panOnScroll:I,zoomOnDoubleClick:L,zoomOnPinch:Y,userSelectionActive:V,noPanClassName:W,noWheelClassName:U,lib:he});g.filter(ye),L?y.on("dblclick.zoom",v):y.on("dblclick.zoom",null)}function T(){g.on("zoom",null)}async function k(U,W,j){const V=Lv(U),I=g?.constrain()(V,W,j);return I&&await S(I),new Promise(H=>H(I))}async function A(U,W){const j=Lv(U);return await S(j,W),new Promise(V=>V(j))}function M(U){if(y){const W=Lv(U),j=y.property("__zoom");(j.k!==U.zoom||j.x!==U.x||j.y!==U.y)&&g?.transform(y,W,null,{sync:!0})}}function N(){const U=y?tM(y.node()):{x:0,y:0,k:1};return{x:U.x,y:U.y,zoom:U.k}}function P(U,W){return y?new Promise(j=>{g?.interpolate(W?.interpolate==="linear"?$u:zh).scaleTo(Fv(y,W?.duration,W?.ease,()=>j(!0)),U)}):Promise.resolve(!1)}function z(U,W){return y?new Promise(j=>{g?.interpolate(W?.interpolate==="linear"?$u:zh).scaleBy(Fv(y,W?.duration,W?.ease,()=>j(!0)),U)}):Promise.resolve(!1)}function B(U){g?.scaleExtent(U)}function R(U){g?.translateExtent(U)}function F(U){const W=!Fr(U)||U<0?0:U;g?.clickDistance(W)}return{update:E,destroy:T,setViewport:A,setViewportConstrained:k,getViewport:N,scaleTo:P,scaleBy:z,setScaleExtent:B,setTranslateExtent:R,syncViewport:M,setClickDistance:F}}var Js;(function(e){e.Line="line",e.Handle="handle"})(Js||(Js={}));function OJ({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:a}){const s=e-t,u=n-r,c=[s>0?1:s<0?-1:0,u>0?1:u<0?-1:0];return s&&o&&(c[0]=c[0]*-1),u&&a&&(c[1]=c[1]*-1),c}function NJ(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function Di(e,t){return Math.max(0,t-e)}function Pi(e,t){return Math.max(0,e-t)}function rp(e,t,n){return Math.max(0,t-e,e-n)}function VM(e,t){return e?!t:t}function DJ(e,t,n,r,o,a,s,u){let{affectsX:c,affectsY:f}=t;const{isHorizontal:h,isVertical:p}=t,g=h&&p,{xSnapped:y,ySnapped:w}=n,{minWidth:v,maxWidth:S,minHeight:E,maxHeight:T}=r,{x:k,y:A,width:M,height:N,aspectRatio:P}=e;let z=Math.floor(h?y-e.pointerX:0),B=Math.floor(p?w-e.pointerY:0);const R=M+(c?-z:z),F=N+(f?-B:B),U=-a[0]*M,W=-a[1]*N;let j=rp(R,v,S),V=rp(F,E,T);if(s){let q=0,G=0;c&&z<0?q=Di(k+z+U,s[0][0]):!c&&z>0&&(q=Pi(k+R+U,s[1][0])),f&&B<0?G=Di(A+B+W,s[0][1]):!f&&B>0&&(G=Pi(A+F+W,s[1][1])),j=Math.max(j,q),V=Math.max(V,G)}if(u){let q=0,G=0;c&&z>0?q=Pi(k+z,u[0][0]):!c&&z<0&&(q=Di(k+R,u[1][0])),f&&B>0?G=Pi(A+B,u[0][1]):!f&&B<0&&(G=Di(A+F,u[1][1])),j=Math.max(j,q),V=Math.max(V,G)}if(o){if(h){const q=rp(R/P,E,T)*P;if(j=Math.max(j,q),s){let G=0;!c&&!f||c&&!f&&g?G=Pi(A+W+R/P,s[1][1])*P:G=Di(A+W+(c?z:-z)/P,s[0][1])*P,j=Math.max(j,G)}if(u){let G=0;!c&&!f||c&&!f&&g?G=Di(A+R/P,u[1][1])*P:G=Pi(A+(c?z:-z)/P,u[0][1])*P,j=Math.max(j,G)}}if(p){const q=rp(F*P,v,S)/P;if(V=Math.max(V,q),s){let G=0;!c&&!f||f&&!c&&g?G=Pi(k+F*P+U,s[1][0])/P:G=Di(k+(f?B:-B)*P+U,s[0][0])/P,V=Math.max(V,G)}if(u){let G=0;!c&&!f||f&&!c&&g?G=Di(k+F*P,u[1][0])/P:G=Pi(k+(f?B:-B)*P,u[0][0])/P,V=Math.max(V,G)}}}B=B+(B<0?V:-V),z=z+(z<0?j:-j),o&&(g?R>F*P?B=(VM(c,f)?-z:z)/P:z=(VM(c,f)?-B:B)*P:h?(B=z/P,f=c):(z=B*P,c=f));const I=c?k+z:k,H=f?A+B:A;return{width:M+(c?-z:z),height:N+(f?-B:B),x:a[0]*z*(c?-1:1)+I,y:a[1]*B*(f?-1:1)+H}}const UM={width:0,height:0,x:0,y:0},PJ={...UM,pointerX:0,pointerY:0,aspectRatio:1};function jJ(e){return[[0,0],[e.measured.width,e.measured.height]]}function IJ(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,a=e.measured.width??0,s=e.measured.height??0,u=n[0]*a,c=n[1]*s;return[[r-u,o-c],[r+a-u,o+s-c]]}function zJ({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const a=Zn(e);function s({controlPosition:c,boundaries:f,keepAspectRatio:h,resizeDirection:p,onResizeStart:g,onResize:y,onResizeEnd:w,shouldResize:v}){let S={...UM},E={...PJ};const T=NJ(c);let k,A=null,M=[],N,P,z;const B=TR().on("start",R=>{const{nodeLookup:F,transform:U,snapGrid:W,snapToGrid:j,nodeOrigin:V,paneDomNode:I}=n();if(k=F.get(t),!k)return;A=I?.getBoundingClientRect()??null;const{xSnapped:H,ySnapped:q}=Qu(R.sourceEvent,{transform:U,snapGrid:W,snapToGrid:j,containerBounds:A});S={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},E={...S,pointerX:H,pointerY:q,aspectRatio:S.width/S.height},N=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(N=F.get(k.parentId),P=N&&k.extent==="parent"?jJ(N):void 0),M=[],z=void 0;for(const[G,O]of F)if(O.parentId===t&&(M.push({id:G,position:{...O.position},extent:O.extent}),O.extent==="parent"||O.expandParent)){const Y=IJ(O,k,O.origin??V);z?z=[[Math.min(Y[0][0],z[0][0]),Math.min(Y[0][1],z[0][1])],[Math.max(Y[1][0],z[1][0]),Math.max(Y[1][1],z[1][1])]]:z=Y}g?.(R,{...S})}).on("drag",R=>{const{transform:F,snapGrid:U,snapToGrid:W,nodeOrigin:j}=n(),V=Qu(R.sourceEvent,{transform:F,snapGrid:U,snapToGrid:W,containerBounds:A}),I=[];if(!k)return;const{x:H,y:q,width:G,height:O}=S,Y={},Z=k.origin??j,{width:L,height:te,x:he,y:oe}=DJ(E,T,V,f,h,Z,P,z),de=L!==G,le=te!==O,ye=he!==H&&de,je=oe!==q&&le;if(!ye&&!je&&!de&&!le)return;if((ye||je||Z[0]===1||Z[1]===1)&&(Y.x=ye?he:S.x,Y.y=je?oe:S.y,S.x=Y.x,S.y=Y.y,M.length>0)){const _e=he-H,Xe=oe-q;for(const Ct of M)Ct.position={x:Ct.position.x-_e+Z[0]*(L-G),y:Ct.position.y-Xe+Z[1]*(te-O)},I.push(Ct)}if((de||le)&&(Y.width=de&&(!p||p==="horizontal")?L:S.width,Y.height=le&&(!p||p==="vertical")?te:S.height,S.width=Y.width,S.height=Y.height),N&&k.expandParent){const _e=Z[0]*(Y.width??0);Y.x&&Y.x<_e&&(S.x=_e,E.x=E.x-(Y.x-_e));const Xe=Z[1]*(Y.height??0);Y.y&&Y.y<Xe&&(S.y=Xe,E.y=E.y-(Y.y-Xe))}const Ne=OJ({width:S.width,prevWidth:G,height:S.height,prevHeight:O,affectsX:T.affectsX,affectsY:T.affectsY}),we={...S,direction:Ne};v?.(R,we)!==!1&&(y?.(R,we),r(Y,I))}).on("end",R=>{w?.(R,{...S}),o?.({...S})});a.call(B)}function u(){a.on(".drag",null)}return{update:s,destroy:u}}const{useDebugValue:LJ}=Qt,{useSyncExternalStoreWithSelector:FJ}=mA,$J=e=>e;function qM(e,t=$J,n){const r=FJ(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return LJ(r),r}const GM=(e,t)=>{const n=cA(e),r=(o,a=t)=>qM(n,o,a);return Object.assign(r,n),r},BJ=(e,t)=>e?GM(e,t):GM;function Tt(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,o]of e)if(!Object.is(o,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const op=_.createContext(null),HJ=op.Provider,YM=mo.error001();function Ze(e,t){const n=_.useContext(op);if(n===null)throw new Error(YM);return qM(n,e,t)}function Et(){const e=_.useContext(op);if(e===null)throw new Error(YM);return _.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const WM={display:"none"},VJ={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},XM="react-flow__node-desc",KM="react-flow__edge-desc",UJ="react-flow__aria-live",qJ=e=>e.ariaLiveMessage,GJ=e=>e.ariaLabelConfig;function YJ({rfId:e}){const t=Ze(qJ);return x.jsx("div",{id:`${UJ}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:VJ,children:t})}function WJ({rfId:e,disableKeyboardA11y:t}){const n=Ze(GJ);return x.jsxs(x.Fragment,{children:[x.jsx("div",{id:`${XM}-${e}`,style:WM,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),x.jsx("div",{id:`${KM}-${e}`,style:WM,children:n["edge.a11yDescription.default"]}),!t&&x.jsx(YJ,{rfId:e})]})}const ip=_.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},a)=>{const s=`${e}`.split("-");return x.jsx("div",{className:Vt(["react-flow__panel",n,...s]),style:r,ref:a,...o,children:t})});ip.displayName="Panel";function XJ({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:x.jsx(ip,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:x.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const KJ=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},ap=e=>e.id;function ZJ(e,t){return Tt(e.selectedNodes.map(ap),t.selectedNodes.map(ap))&&Tt(e.selectedEdges.map(ap),t.selectedEdges.map(ap))}function QJ({onSelectionChange:e}){const t=Et(),{selectedNodes:n,selectedEdges:r}=Ze(KJ,ZJ);return _.useEffect(()=>{const o={nodes:n,edges:r};e?.(o),t.getState().onSelectionChangeHandlers.forEach(a=>a(o))},[n,r,e]),null}const JJ=e=>!!e.onSelectionChangeHandlers;function eee({onSelectionChange:e}){const t=Ze(JJ);return e||t?x.jsx(QJ,{onSelectionChange:e}):null}const ZM=[0,0],tee={x:0,y:0,zoom:1},QM=[...["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","paneClickDistance","ariaLabelConfig"],"rfId"],nee=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setPaneClickDistance:e.setPaneClickDistance}),JM={translateExtent:Gu,nodeOrigin:ZM,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1",paneClickDistance:0};function ree(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:a,setNodeExtent:s,reset:u,setDefaultNodesAndEdges:c,setPaneClickDistance:f}=Ze(nee,Tt),h=Et();_.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{p.current=JM,u()}),[]);const p=_.useRef(JM);return _.useEffect(()=>{for(const g of QM){const y=e[g],w=p.current[g];y!==w&&(typeof e[g]>"u"||(g==="nodes"?t(y):g==="edges"?n(y):g==="minZoom"?r(y):g==="maxZoom"?o(y):g==="translateExtent"?a(y):g==="nodeExtent"?s(y):g==="paneClickDistance"?f(y):g==="ariaLabelConfig"?h.setState({ariaLabelConfig:KQ(y)}):g==="fitView"?h.setState({fitViewQueued:y}):g==="fitViewOptions"?h.setState({fitViewOptions:y}):h.setState({[g]:y})))}p.current=e},QM.map(g=>e[g])),null}function eO(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function oee(e){const[t,n]=_.useState(e==="system"?null:e);return _.useEffect(()=>{if(e!=="system"){n(e);return}const r=eO(),o=()=>n(r?.matches?"dark":"light");return o(),r?.addEventListener("change",o),()=>{r?.removeEventListener("change",o)}},[e]),t!==null?t:eO()?.matches?"dark":"light"}const tO=typeof document<"u"?document:null;function Xo(e=null,t={target:tO,actInsideInputWithModifier:!0}){const[n,r]=_.useState(!1),o=_.useRef(!1),a=_.useRef(new Set([])),[s,u]=_.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",`
787
+ `+a):r.stack=a}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=ka(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:a}=n;r!==void 0&&Ch.assertOptions(r,{silentJSONParsing:co.transitional(co.boolean),forcedJSONParsing:co.transitional(co.boolean),clarifyTimeoutError:co.transitional(co.boolean)},!1),o!=null&&(ie.isFunction(o)?n.paramsSerializer={serialize:o}:Ch.assertOptions(o,{encode:co.function,serialize:co.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ch.assertOptions(n,{baseUrl:co.spelling("baseURL"),withXsrfToken:co.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let s=a&&ie.merge(a.common,a[n.method]);a&&ie.forEach(["delete","get","head","post","put","patch","common"],w=>{delete a[w]}),n.headers=Nn.concat(s,a);const u=[];let c=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(n)===!1||(c=c&&v.synchronous,u.unshift(v.fulfilled,v.rejected))});const f=[];this.interceptors.response.forEach(function(v){f.push(v.fulfilled,v.rejected)});let h,p=0,g;if(!c){const w=[iR.bind(this),void 0];for(w.unshift(...u),w.push(...f),g=w.length,h=Promise.resolve(n);p<g;)h=h.then(w[p++],w[p++]);return h}g=u.length;let y=n;for(p=0;p<g;){const w=u[p++],v=u[p++];try{y=w(y)}catch(S){v.call(this,S);break}}try{h=iR.call(this,y)}catch(w){return Promise.reject(w)}for(p=0,g=f.length;p<g;)h=h.then(f[p++],f[p++]);return h}getUri(t){t=ka(this.defaults,t);const n=KA(t.baseURL,t.url,t.allowAbsoluteUrls);return BA(n,t.params,t.paramsSerializer)}};ie.forEach(["delete","get","head","options"],function(t){Ta.prototype[t]=function(n,r){return this.request(ka(r||{},{method:t,url:n,data:(r||{}).data}))}}),ie.forEach(["post","put","patch"],function(t){function n(r){return function(a,s,u){return this.request(ka(u||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:a,data:s}))}}Ta.prototype[t]=n(),Ta.prototype[t+"Form"]=n(!0)});let nX=class ij{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(a){n=a});const r=this;this.promise.then(o=>{if(!r._listeners)return;let a=r._listeners.length;for(;a-- >0;)r._listeners[a](o);r._listeners=null}),this.promise.then=o=>{let a;const s=new Promise(u=>{r.subscribe(u),a=u}).then(o);return s.cancel=function(){r.unsubscribe(a)},s},t(function(a,s,u){r.reason||(r.reason=new Hs(a,s,u),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new ij(function(o){t=o}),cancel:t}}};function rX(e){return function(n){return e.apply(null,n)}}function oX(e){return ie.isObject(e)&&e.isAxiosError===!0}const rv={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(rv).forEach(([e,t])=>{rv[t]=e});function lR(e){const t=new Ta(e),n=kA(Ta.prototype.request,t);return ie.extend(n,Ta.prototype,t,{allOwnKeys:!0}),ie.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return lR(ka(e,o))},n}const zt=lR(Du);zt.Axios=Ta,zt.CanceledError=Hs,zt.CancelToken=nX,zt.isCancel=GA,zt.VERSION=aR,zt.toFormData=bh,zt.AxiosError=Fe,zt.Cancel=zt.CanceledError,zt.all=function(t){return Promise.all(t)},zt.spread=rX,zt.isAxiosError=oX,zt.mergeConfig=ka,zt.AxiosHeaders=Nn,zt.formToJSON=e=>UA(ie.isHTMLForm(e)?new FormData(e):e),zt.getAdapter=oR.getAdapter,zt.HttpStatusCode=rv,zt.default=zt;const{Axios:Npe,AxiosError:Dpe,CanceledError:Ppe,isCancel:jpe,CancelToken:Ipe,VERSION:zpe,all:Lpe,Cancel:Fpe,isAxiosError:$pe,spread:Bpe,toFormData:Hpe,AxiosHeaders:Vpe,HttpStatusCode:Upe,formToJSON:qpe,getAdapter:Gpe,mergeConfig:Ype}=zt;class uR extends jY{constructor(t){super(t),this._websocket=null,this.reconnectAttempts=0,this.maxReconnectAttempts=999,this.initialTimeout=200,this.maxTimeout=5e3,this._reconnect=!0,this._reconnect_timeout=void 0,this._url=t.url,this._reconnect_timeout=setTimeout(()=>{this.connect()},200),this._zustand&&this._zustand.auto_progress()}connect(){this._zustand?.logger.info("Connecting to websocket"),this.is_open=!1,this._websocket=new WebSocket(this._url),this._websocket.onopen=()=>{this.onopen()},this._websocket.onclose=()=>{this.onclose()},this._websocket.onerror=()=>{this.on_ws_error()},this._websocket.onmessage=t=>{typeof t.data=="string"?this.onmessage(t.data):t.data instanceof Blob&&t.data.arrayBuffer().then(n=>{const r=new Uint8Array(n);this.getCommunicationManager().onbytes(r)})}}calculateReconnectTimeout(){return Math.min(this.initialTimeout*Math.pow(2,this.reconnectAttempts),this.maxTimeout)}auto_reconnect(){if(this.reconnectAttempts<this.maxReconnectAttempts){let t=this.calculateReconnectTimeout();this._zustand?.logger.info(`Attempting to reconnect in ${t} ms`),this._reconnect_timeout=setTimeout(()=>{this._websocket&&this._websocket.readyState===WebSocket.OPEN||(this.reconnectAttempts++,this.connect())},t)}else this._zustand?.logger.warn("Maximum reconnect attempts reached. Giving up.")}async onmessage(t){try{const n=JSON.parse(t);this._zustand?.logger.debug(`Recieved data of length: ${t.length} and data"`,n),await this.getCommunicationManager().receive(n)}catch(n){console.error("Websocketworker: onmessage JSON.parse error",n,t);return}}get http_protocol(){return this.secure_url?"https":"http"}get secure_url(){return this._url.startsWith("wss")}get url_wo_protocol(){return this._url.substring(this.secure_url?6:5)}get http_url(){var t=this.http_protocol+"://"+this.url_wo_protocol;return t[t.length-1]!=="/"&&(t+="/"),t}get_io_subscription_url({node_id:t,io_id:n,stream:r}){let o=this.http_url+`node/${t}/io/${n}/value`;return r&&(o+="/stream"),o}async upload_file({files:t,onProgressCallback:n,root:r}){const o=`${this.http_url}upload/`,a=new FormData,s=Array.isArray(t)?t:Array.from(t);for(const u of s){const c=u.webkitRelativePath||u.name,f=r?`${r}/${c}`:c;a.append("file",u,f)}try{return(await zt.post(o,a,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:c=>{n&&n(c.loaded,c.total)}})).data.file}catch{throw new Error("Failed to upload file")}}async handle_large_message_hint({msg_id:t}){const n=this.http_url+"message/"+t,o=await(await fetch(n,{method:"GET",headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*"}})).json();this.getCommunicationManager().receive(o)}onopen(){this._zustand?.logger.info("Websocket opened"),this.is_open=!0,this._zustand&&this._zustand.auto_progress(),this.reconnectAttempts=0,this.getSyncManager().stepwise_fullsync()}onclose(){this._zustand?.logger.info("Websocket closed"),super.onclose(),this._reconnect&&(this._zustand?.logger.info("Websocket closed,reconnecting"),this.auto_reconnect())}on_ws_error(){this._zustand?.logger.warn("Websocket error"),this._websocket?this._websocket.close():this.auto_reconnect()}async send_large_message(t){const n=`${this.http_url}message/`;await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:t})}async send(t){if(!this._websocket||this._websocket.readyState!==WebSocket.OPEN){this._zustand?.logger.warn("Websocket not connected");return}const n=JSON.stringify(t);if(new Blob([n]).size>1e6)return this._zustand?.logger.info("Data too large, sending via http"),await this.send_large_message(n);this._zustand?.logger.debug("Sending data",t),this._websocket.send(n)}async stop(){await super.stop(),this._reconnect=!1}close(){this._websocket&&this._websocket.close()}disconnect(){super.disconnect(),this._reconnect=!1,this._reconnect_timeout&&(clearTimeout(this._reconnect_timeout),this._reconnect_timeout=void 0),this.close()}async reconnect(){if(await super.reconnect(),this._reconnect=!0,this._websocket&&(this._zustand?.logger.info("Reconnecting"),(this._websocket.readyState===WebSocket.OPEN||this._websocket.readyState===WebSocket.CONNECTING)&&(this._websocket.readyState===WebSocket.CONNECTING&&await new Promise((t,n)=>{if(this._websocket===null)return;let r=setTimeout(()=>{n("Timeout@reconnect")},2e3);this._websocket.addEventListener("open",()=>{clearTimeout(r),t(null)},{once:!0}),this._websocket.readyState===WebSocket.OPEN&&(clearTimeout(r),t(null))}),this._websocket.readyState===WebSocket.OPEN))){this.getSyncManager().stepwise_fullsync();return}this.connect()}}class iX{constructor(t,n){this.ws=null,this.reconnectAttempts=0,this.maxReconnectAttempts=999,this.initialTimeout=200,this.maxTimeout=2e3,n.logger.debug("Initializing worker manager"),this._wsuri=t,this.zustand=n,this.workers={},this.on_setWorker=r=>{this.zustand.set_worker(r)},this.connectionTimeout=setTimeout(()=>{this.connect()},200)}get wsuri(){return this._wsuri}get open(){return this.ws?.readyState===WebSocket.OPEN}connect(){this.zustand.set_progress({progress:0,message:"connecting to worker manager",status:"info",blocking:!0}),this.zustand.logger.info("Connecting to websocket:",this._wsuri),this.ws=new WebSocket(this._wsuri),this.ws.onopen=()=>{this.onopen()},this.ws.onclose=()=>{this.onclose()},this.ws.onerror=()=>{this.on_ws_error()},this.ws.onmessage=t=>{typeof t.data=="string"?this.onmessage(t.data):console.error("WorkerManager: onmessage event.data is not a string",typeof t.data)},this.connectionTimeout=setTimeout(()=>{this.ws?.readyState!==WebSocket.OPEN&&this.on_ws_error()},5e3)}on_ws_error(){console.warn("Websocket error"),this.ws?this.ws.close():this.reconnect()}onopen(){this.connectionTimeout&&(clearTimeout(this.connectionTimeout),this.connectionTimeout=void 0),this.zustand.auto_progress(),this.ws&&this.ws.send("worker_status");const t=window.localStorage.getItem("funcnodes__active_worker");t&&this.set_active(t)}onmessage(t){try{let n=JSON.parse(t);if(n.type==="worker_status"){const r={};for(let o of n.active)o.active=!0,r[o.uuid]=o;for(let o of n.inactive)o.active=!1,r[o.uuid]=o;this.zustand.workers.setState(r);return}else if(n.type==="set_worker"){if(n.data.type==="WSWorker"){let r="ws"+(n.data.ssl?"s":"")+"://"+n.data.host+":"+n.data.port;this.setWorker(this.workers[n.data.uuid]||new uR({url:r,zustand:this.zustand,uuid:n.data.uuid,on_sync_complete:this.zustand.options.on_sync_complete}))}else this.zustand.logger.error("WorkerManager: unknown worker type",n);return}else if(n.type==="progress"){this.zustand.set_progress(n);return}this.zustand.logger.error("WorkerManager: unknown message",n)}catch(n){console.error("WorkerManager: onmessage JSON.parse error",n,t);return}}setWorker(t){for(let n in this.workers)n!==t?.uuid&&this.workers[n].disconnect();t!==void 0&&(this.workers[t.uuid]=t,t.reconnect()),t?.uuid&&window.localStorage.setItem("funcnodes__active_worker",t?.uuid),this.zustand.worker!==void 0&&this.zustand.clear_all(),this.zustand.set_worker(t),this.on_setWorker(t)}async restart_worker(t){this.ws?.send(JSON.stringify({type:"restart_worker",workerid:t}))}calculateReconnectTimeout(){return Math.min(this.initialTimeout*Math.pow(2,this.reconnectAttempts),this.maxTimeout)}reconnect(){if(this.reconnectAttempts<this.maxReconnectAttempts){let t=this.calculateReconnectTimeout();this.zustand.logger.info(`Attempting to reconnect in ${t} ms`),setTimeout(()=>{this.ws&&this.ws.readyState===WebSocket.OPEN||(this.reconnectAttempts++,this.connect())},t)}else this.zustand.logger.warn("Maximum reconnect attempts reached. Giving up.")}onclose(){this.zustand.logger.warn("WorkerManager: onclose"),this.reconnect()}set_active(t){this.ws&&this.ws.send(JSON.stringify({type:"set_active",workerid:t}))}new_worker({name:t,reference:n,copyLib:r,copyNS:o,in_venv:a}){t||(t=void 0),r||(r=!1),o||(o=!1),n||(n=void 0,r=!1,o=!1),this.ws&&this.ws.send(JSON.stringify({type:"new_worker",kwargs:{name:t,reference:n,copyLib:r,copyNS:o,in_venv:a}}))}remove(){for(let t in this.workers)this.workers[t].disconnect();this.connectionTimeout&&(clearTimeout(this.connectionTimeout),this.connectionTimeout=void 0),this.ws&&(this.ws.onclose=()=>{},this.ws.onerror=()=>{},this.ws.onmessage=()=>{},this.ws.onopen=()=>{},this.ws.close())}}const _n=()=>{const e=tt();return e.worker?{...e.worker.api,worker:e.worker}:{node:void 0,group:void 0,edge:void 0,hooks:void 0,lib:void 0,worker:e.worker}},aX={id:"",debug:!1,useWorkerManager:!0,show_library:!0,header:{show:!0,showmenu:!0},flow:{minimap:!0,static:!1,minZoom:.1,maxZoom:5,allowFullScreen:!0,allowExpand:!0,showNodeSettings:!0},library:{show:!0}},cR=["classic","metal","light","solarized","midnight","forest","scientific","neon","ocean","sunset"];function Vt(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Vt(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var sX={value:()=>{}};function kh(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Th(n)}function Th(e){this._=e}function lX(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Th.prototype=kh.prototype={constructor:Th,on:function(e,t){var n=this._,r=lX(e+"",n),o,a=-1,s=r.length;if(arguments.length<2){for(;++a<s;)if((o=(e=r[a]).type)&&(o=uX(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<s;)if(o=(e=r[a]).type)n[o]=fR(n[o],e.name,t);else if(t==null)for(o in n)n[o]=fR(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Th(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,a;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],r=0,o=a.length;r<o;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,a=r.length;o<a;++o)r[o].value.apply(t,n)}};function uX(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function fR(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=sX,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var ov="http://www.w3.org/1999/xhtml";const dR={svg:"http://www.w3.org/2000/svg",xhtml:ov,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ah(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),dR.hasOwnProperty(t)?{space:dR[t],local:e}:e}function cX(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ov&&t.documentElement.namespaceURI===ov?t.createElement(e):t.createElementNS(n,e)}}function fX(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function hR(e){var t=Ah(e);return(t.local?fX:cX)(t)}function dX(){}function iv(e){return e==null?dX:function(){return this.querySelector(e)}}function hX(e){typeof e!="function"&&(e=iv(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var a=t[o],s=a.length,u=r[o]=new Array(s),c,f,h=0;h<s;++h)(c=a[h])&&(f=e.call(c,c.__data__,h,a))&&("__data__"in c&&(f.__data__=c.__data__),u[h]=f);return new Kn(r,this._parents)}function pX(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function mX(){return[]}function pR(e){return e==null?mX:function(){return this.querySelectorAll(e)}}function gX(e){return function(){return pX(e.apply(this,arguments))}}function yX(e){typeof e=="function"?e=gX(e):e=pR(e);for(var t=this._groups,n=t.length,r=[],o=[],a=0;a<n;++a)for(var s=t[a],u=s.length,c,f=0;f<u;++f)(c=s[f])&&(r.push(e.call(c,c.__data__,f,s)),o.push(c));return new Kn(r,o)}function mR(e){return function(){return this.matches(e)}}function gR(e){return function(t){return t.matches(e)}}var vX=Array.prototype.find;function bX(e){return function(){return vX.call(this.children,e)}}function xX(){return this.firstElementChild}function wX(e){return this.select(e==null?xX:bX(typeof e=="function"?e:gR(e)))}var _X=Array.prototype.filter;function SX(){return Array.from(this.children)}function EX(e){return function(){return _X.call(this.children,e)}}function CX(e){return this.selectAll(e==null?SX:EX(typeof e=="function"?e:gR(e)))}function kX(e){typeof e!="function"&&(e=mR(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var a=t[o],s=a.length,u=r[o]=[],c,f=0;f<s;++f)(c=a[f])&&e.call(c,c.__data__,f,a)&&u.push(c);return new Kn(r,this._parents)}function yR(e){return new Array(e.length)}function TX(){return new Kn(this._enter||this._groups.map(yR),this._parents)}function Rh(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Rh.prototype={constructor:Rh,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function AX(e){return function(){return e}}function RX(e,t,n,r,o,a){for(var s=0,u,c=t.length,f=a.length;s<f;++s)(u=t[s])?(u.__data__=a[s],r[s]=u):n[s]=new Rh(e,a[s]);for(;s<c;++s)(u=t[s])&&(o[s]=u)}function MX(e,t,n,r,o,a,s){var u,c,f=new Map,h=t.length,p=a.length,g=new Array(h),y;for(u=0;u<h;++u)(c=t[u])&&(g[u]=y=s.call(c,c.__data__,u,t)+"",f.has(y)?o[u]=c:f.set(y,c));for(u=0;u<p;++u)y=s.call(e,a[u],u,a)+"",(c=f.get(y))?(r[u]=c,c.__data__=a[u],f.delete(y)):n[u]=new Rh(e,a[u]);for(u=0;u<h;++u)(c=t[u])&&f.get(g[u])===c&&(o[u]=c)}function OX(e){return e.__data__}function NX(e,t){if(!arguments.length)return Array.from(this,OX);var n=t?MX:RX,r=this._parents,o=this._groups;typeof e!="function"&&(e=AX(e));for(var a=o.length,s=new Array(a),u=new Array(a),c=new Array(a),f=0;f<a;++f){var h=r[f],p=o[f],g=p.length,y=DX(e.call(h,h&&h.__data__,f,r)),w=y.length,v=u[f]=new Array(w),S=s[f]=new Array(w),E=c[f]=new Array(g);n(h,p,v,S,E,y,t);for(var T=0,k=0,A,M;T<w;++T)if(A=v[T]){for(T>=k&&(k=T+1);!(M=S[k])&&++k<w;);A._next=M||null}}return s=new Kn(s,r),s._enter=u,s._exit=c,s}function DX(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function PX(){return new Kn(this._exit||this._groups.map(yR),this._parents)}function jX(e,t,n){var r=this.enter(),o=this,a=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?a.remove():n(a),r&&o?r.merge(o).order():o}function IX(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,a=r.length,s=Math.min(o,a),u=new Array(o),c=0;c<s;++c)for(var f=n[c],h=r[c],p=f.length,g=u[c]=new Array(p),y,w=0;w<p;++w)(y=f[w]||h[w])&&(g[w]=y);for(;c<o;++c)u[c]=n[c];return new Kn(u,this._parents)}function zX(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,a=r[o],s;--o>=0;)(s=r[o])&&(a&&s.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(s,a),a=s);return this}function LX(e){e||(e=FX);function t(p,g){return p&&g?e(p.__data__,g.__data__):!p-!g}for(var n=this._groups,r=n.length,o=new Array(r),a=0;a<r;++a){for(var s=n[a],u=s.length,c=o[a]=new Array(u),f,h=0;h<u;++h)(f=s[h])&&(c[h]=f);c.sort(t)}return new Kn(o,this._parents).order()}function FX(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function $X(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function BX(){return Array.from(this)}function HX(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,a=r.length;o<a;++o){var s=r[o];if(s)return s}return null}function VX(){let e=0;for(const t of this)++e;return e}function UX(){return!this.node()}function qX(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],a=0,s=o.length,u;a<s;++a)(u=o[a])&&e.call(u,u.__data__,a,o);return this}function GX(e){return function(){this.removeAttribute(e)}}function YX(e){return function(){this.removeAttributeNS(e.space,e.local)}}function WX(e,t){return function(){this.setAttribute(e,t)}}function XX(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function KX(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function ZX(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function QX(e,t){var n=Ah(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?YX:GX:typeof t=="function"?n.local?ZX:KX:n.local?XX:WX)(n,t))}function vR(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function JX(e){return function(){this.style.removeProperty(e)}}function eK(e,t,n){return function(){this.style.setProperty(e,t,n)}}function tK(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function nK(e,t,n){return arguments.length>1?this.each((t==null?JX:typeof t=="function"?tK:eK)(e,t,n??"")):Vs(this.node(),e)}function Vs(e,t){return e.style.getPropertyValue(t)||vR(e).getComputedStyle(e,null).getPropertyValue(t)}function rK(e){return function(){delete this[e]}}function oK(e,t){return function(){this[e]=t}}function iK(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function aK(e,t){return arguments.length>1?this.each((t==null?rK:typeof t=="function"?iK:oK)(e,t)):this.node()[e]}function bR(e){return e.trim().split(/^|\s+/)}function av(e){return e.classList||new xR(e)}function xR(e){this._node=e,this._names=bR(e.getAttribute("class")||"")}xR.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function wR(e,t){for(var n=av(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function _R(e,t){for(var n=av(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function sK(e){return function(){wR(this,e)}}function lK(e){return function(){_R(this,e)}}function uK(e,t){return function(){(t.apply(this,arguments)?wR:_R)(this,e)}}function cK(e,t){var n=bR(e+"");if(arguments.length<2){for(var r=av(this.node()),o=-1,a=n.length;++o<a;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?uK:t?sK:lK)(n,t))}function fK(){this.textContent=""}function dK(e){return function(){this.textContent=e}}function hK(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function pK(e){return arguments.length?this.each(e==null?fK:(typeof e=="function"?hK:dK)(e)):this.node().textContent}function mK(){this.innerHTML=""}function gK(e){return function(){this.innerHTML=e}}function yK(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function vK(e){return arguments.length?this.each(e==null?mK:(typeof e=="function"?yK:gK)(e)):this.node().innerHTML}function bK(){this.nextSibling&&this.parentNode.appendChild(this)}function xK(){return this.each(bK)}function wK(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function _K(){return this.each(wK)}function SK(e){var t=typeof e=="function"?e:hR(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function EK(){return null}function CK(e,t){var n=typeof e=="function"?e:hR(e),r=t==null?EK:typeof t=="function"?t:iv(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function kK(){var e=this.parentNode;e&&e.removeChild(this)}function TK(){return this.each(kK)}function AK(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function RK(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function MK(e){return this.select(e?RK:AK)}function OK(e){return arguments.length?this.property("__data__",e):this.node().__data__}function NK(e){return function(t){e.call(this,t,this.__data__)}}function DK(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function PK(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,a;n<o;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function jK(e,t,n){return function(){var r=this.__on,o,a=NK(t);if(r){for(var s=0,u=r.length;s<u;++s)if((o=r[s]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=a,o.options=n),o.value=t;return}}this.addEventListener(e.type,a,n),o={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(o):this.__on=[o]}}function IK(e,t,n){var r=DK(e+""),o,a=r.length,s;if(arguments.length<2){var u=this.node().__on;if(u){for(var c=0,f=u.length,h;c<f;++c)for(o=0,h=u[c];o<a;++o)if((s=r[o]).type===h.type&&s.name===h.name)return h.value}return}for(u=t?jK:PK,o=0;o<a;++o)this.each(u(r[o],t,n));return this}function SR(e,t,n){var r=vR(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function zK(e,t){return function(){return SR(this,e,t)}}function LK(e,t){return function(){return SR(this,e,t.apply(this,arguments))}}function FK(e,t){return this.each((typeof t=="function"?LK:zK)(e,t))}function*$K(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,a=r.length,s;o<a;++o)(s=r[o])&&(yield s)}var ER=[null];function Kn(e,t){this._groups=e,this._parents=t}function ju(){return new Kn([[document.documentElement]],ER)}function BK(){return this}Kn.prototype=ju.prototype={constructor:Kn,select:hX,selectAll:yX,selectChild:wX,selectChildren:CX,filter:kX,data:NX,enter:TX,exit:PX,join:jX,merge:IX,selection:BK,order:zX,sort:LX,call:$X,nodes:BX,node:HX,size:VX,empty:UX,each:qX,attr:QX,style:nK,property:aK,classed:cK,text:pK,html:vK,raise:xK,lower:_K,append:SK,insert:CK,remove:TK,clone:MK,datum:OK,on:IK,dispatch:FK,[Symbol.iterator]:$K};function Zn(e){return typeof e=="string"?new Kn([[document.querySelector(e)]],[document.documentElement]):new Kn([[e]],ER)}function HK(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ir(e,t){if(e=HK(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const VK={passive:!1},Iu={capture:!0,passive:!1};function sv(e){e.stopImmediatePropagation()}function Us(e){e.preventDefault(),e.stopImmediatePropagation()}function CR(e){var t=e.document.documentElement,n=Zn(e).on("dragstart.drag",Us,Iu);"onselectstart"in t?n.on("selectstart.drag",Us,Iu):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function kR(e,t){var n=e.document.documentElement,r=Zn(e).on("dragstart.drag",null);t&&(r.on("click.drag",Us,Iu),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Mh=e=>()=>e;function lv(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:a,x:s,y:u,dx:c,dy:f,dispatch:h}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:h}})}lv.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function UK(e){return!e.ctrlKey&&!e.button}function qK(){return this.parentNode}function GK(e,t){return t??{x:e.x,y:e.y}}function YK(){return navigator.maxTouchPoints||"ontouchstart"in this}function TR(){var e=UK,t=qK,n=GK,r=YK,o={},a=kh("start","drag","end"),s=0,u,c,f,h,p=0;function g(A){A.on("mousedown.drag",y).filter(r).on("touchstart.drag",S).on("touchmove.drag",E,VK).on("touchend.drag touchcancel.drag",T).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function y(A,M){if(!(h||!e.call(this,A,M))){var N=k(this,t.call(this,A,M),A,M,"mouse");N&&(Zn(A.view).on("mousemove.drag",w,Iu).on("mouseup.drag",v,Iu),CR(A.view),sv(A),f=!1,u=A.clientX,c=A.clientY,N("start",A))}}function w(A){if(Us(A),!f){var M=A.clientX-u,N=A.clientY-c;f=M*M+N*N>p}o.mouse("drag",A)}function v(A){Zn(A.view).on("mousemove.drag mouseup.drag",null),kR(A.view,f),Us(A),o.mouse("end",A)}function S(A,M){if(e.call(this,A,M)){var N=A.changedTouches,P=t.call(this,A,M),z=N.length,B,R;for(B=0;B<z;++B)(R=k(this,P,A,M,N[B].identifier,N[B]))&&(sv(A),R("start",A,N[B]))}}function E(A){var M=A.changedTouches,N=M.length,P,z;for(P=0;P<N;++P)(z=o[M[P].identifier])&&(Us(A),z("drag",A,M[P]))}function T(A){var M=A.changedTouches,N=M.length,P,z;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),P=0;P<N;++P)(z=o[M[P].identifier])&&(sv(A),z("end",A,M[P]))}function k(A,M,N,P,z,B){var R=a.copy(),F=Ir(B||N,M),U,W,j;if((j=n.call(A,new lv("beforestart",{sourceEvent:N,target:g,identifier:z,active:s,x:F[0],y:F[1],dx:0,dy:0,dispatch:R}),P))!=null)return U=j.x-F[0]||0,W=j.y-F[1]||0,function V(I,H,q){var G=F,O;switch(I){case"start":o[z]=V,O=s++;break;case"end":delete o[z],--s;case"drag":F=Ir(q||H,M),O=s;break}R.call(I,A,new lv(I,{sourceEvent:H,subject:j,target:g,identifier:z,active:O,x:F[0]+U,y:F[1]+W,dx:F[0]-G[0],dy:F[1]-G[1],dispatch:R}),P)}}return g.filter=function(A){return arguments.length?(e=typeof A=="function"?A:Mh(!!A),g):e},g.container=function(A){return arguments.length?(t=typeof A=="function"?A:Mh(A),g):t},g.subject=function(A){return arguments.length?(n=typeof A=="function"?A:Mh(A),g):n},g.touchable=function(A){return arguments.length?(r=typeof A=="function"?A:Mh(!!A),g):r},g.on=function(){var A=a.on.apply(a,arguments);return A===a?g:A},g.clickDistance=function(A){return arguments.length?(p=(A=+A)*A,g):Math.sqrt(p)},g}function uv(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function AR(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function zu(){}var Lu=.7,Oh=1/Lu,qs="\\s*([+-]?\\d+)\\s*",Fu="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",fo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",WK=/^#([0-9a-f]{3,8})$/,XK=new RegExp(`^rgb\\(${qs},${qs},${qs}\\)$`),KK=new RegExp(`^rgb\\(${fo},${fo},${fo}\\)$`),ZK=new RegExp(`^rgba\\(${qs},${qs},${qs},${Fu}\\)$`),QK=new RegExp(`^rgba\\(${fo},${fo},${fo},${Fu}\\)$`),JK=new RegExp(`^hsl\\(${Fu},${fo},${fo}\\)$`),eZ=new RegExp(`^hsla\\(${Fu},${fo},${fo},${Fu}\\)$`),RR={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};uv(zu,Aa,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:MR,formatHex:MR,formatHex8:tZ,formatHsl:nZ,formatRgb:OR,toString:OR});function MR(){return this.rgb().formatHex()}function tZ(){return this.rgb().formatHex8()}function nZ(){return IR(this).formatHsl()}function OR(){return this.rgb().formatRgb()}function Aa(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=WK.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?NR(t):n===3?new Dn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Nh(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Nh(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=XK.exec(e))?new Dn(t[1],t[2],t[3],1):(t=KK.exec(e))?new Dn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=ZK.exec(e))?Nh(t[1],t[2],t[3],t[4]):(t=QK.exec(e))?Nh(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=JK.exec(e))?jR(t[1],t[2]/100,t[3]/100,1):(t=eZ.exec(e))?jR(t[1],t[2]/100,t[3]/100,t[4]):RR.hasOwnProperty(e)?NR(RR[e]):e==="transparent"?new Dn(NaN,NaN,NaN,0):null}function NR(e){return new Dn(e>>16&255,e>>8&255,e&255,1)}function Nh(e,t,n,r){return r<=0&&(e=t=n=NaN),new Dn(e,t,n,r)}function rZ(e){return e instanceof zu||(e=Aa(e)),e?(e=e.rgb(),new Dn(e.r,e.g,e.b,e.opacity)):new Dn}function cv(e,t,n,r){return arguments.length===1?rZ(e):new Dn(e,t,n,r??1)}function Dn(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}uv(Dn,cv,AR(zu,{brighter(e){return e=e==null?Oh:Math.pow(Oh,e),new Dn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Lu:Math.pow(Lu,e),new Dn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Dn(Ra(this.r),Ra(this.g),Ra(this.b),Dh(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:DR,formatHex:DR,formatHex8:oZ,formatRgb:PR,toString:PR}));function DR(){return`#${Ma(this.r)}${Ma(this.g)}${Ma(this.b)}`}function oZ(){return`#${Ma(this.r)}${Ma(this.g)}${Ma(this.b)}${Ma((isNaN(this.opacity)?1:this.opacity)*255)}`}function PR(){const e=Dh(this.opacity);return`${e===1?"rgb(":"rgba("}${Ra(this.r)}, ${Ra(this.g)}, ${Ra(this.b)}${e===1?")":`, ${e})`}`}function Dh(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ra(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ma(e){return e=Ra(e),(e<16?"0":"")+e.toString(16)}function jR(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new zr(e,t,n,r)}function IR(e){if(e instanceof zr)return new zr(e.h,e.s,e.l,e.opacity);if(e instanceof zu||(e=Aa(e)),!e)return new zr;if(e instanceof zr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),a=Math.max(t,n,r),s=NaN,u=a-o,c=(a+o)/2;return u?(t===a?s=(n-r)/u+(n<r)*6:n===a?s=(r-t)/u+2:s=(t-n)/u+4,u/=c<.5?a+o:2-a-o,s*=60):u=c>0&&c<1?0:s,new zr(s,u,c,e.opacity)}function iZ(e,t,n,r){return arguments.length===1?IR(e):new zr(e,t,n,r??1)}function zr(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}uv(zr,iZ,AR(zu,{brighter(e){return e=e==null?Oh:Math.pow(Oh,e),new zr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Lu:Math.pow(Lu,e),new zr(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new Dn(fv(e>=240?e-240:e+120,o,r),fv(e,o,r),fv(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new zr(zR(this.h),Ph(this.s),Ph(this.l),Dh(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Dh(this.opacity);return`${e===1?"hsl(":"hsla("}${zR(this.h)}, ${Ph(this.s)*100}%, ${Ph(this.l)*100}%${e===1?")":`, ${e})`}`}}));function zR(e){return e=(e||0)%360,e<0?e+360:e}function Ph(e){return Math.max(0,Math.min(1,e||0))}function fv(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const dv=e=>()=>e;function aZ(e,t){return function(n){return e+n*t}}function sZ(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function lZ(e){return(e=+e)==1?LR:function(t,n){return n-t?sZ(t,n,e):dv(isNaN(t)?n:t)}}function LR(e,t){var n=t-e;return n?aZ(e,n):dv(isNaN(e)?t:e)}const jh=function e(t){var n=lZ(t);function r(o,a){var s=n((o=cv(o)).r,(a=cv(a)).r),u=n(o.g,a.g),c=n(o.b,a.b),f=LR(o.opacity,a.opacity);return function(h){return o.r=s(h),o.g=u(h),o.b=c(h),o.opacity=f(h),o+""}}return r.gamma=e,r}(1);function uZ(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(a){for(o=0;o<n;++o)r[o]=e[o]*(1-a)+t[o]*a;return r}}function cZ(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function fZ(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),a=new Array(n),s;for(s=0;s<r;++s)o[s]=$u(e[s],t[s]);for(;s<n;++s)a[s]=t[s];return function(u){for(s=0;s<r;++s)a[s]=o[s](u);return a}}function dZ(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function ho(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function hZ(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=$u(e[o],t[o]):r[o]=t[o];return function(a){for(o in n)r[o]=n[o](a);return r}}var hv=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,pv=new RegExp(hv.source,"g");function pZ(e){return function(){return e}}function mZ(e){return function(t){return e(t)+""}}function FR(e,t){var n=hv.lastIndex=pv.lastIndex=0,r,o,a,s=-1,u=[],c=[];for(e=e+"",t=t+"";(r=hv.exec(e))&&(o=pv.exec(t));)(a=o.index)>n&&(a=t.slice(n,a),u[s]?u[s]+=a:u[++s]=a),(r=r[0])===(o=o[0])?u[s]?u[s]+=o:u[++s]=o:(u[++s]=null,c.push({i:s,x:ho(r,o)})),n=pv.lastIndex;return n<t.length&&(a=t.slice(n),u[s]?u[s]+=a:u[++s]=a),u.length<2?c[0]?mZ(c[0].x):pZ(t):(t=c.length,function(f){for(var h=0,p;h<t;++h)u[(p=c[h]).i]=p.x(f);return u.join("")})}function $u(e,t){var n=typeof t,r;return t==null||n==="boolean"?dv(t):(n==="number"?ho:n==="string"?(r=Aa(t))?(t=r,jh):FR:t instanceof Aa?jh:t instanceof Date?dZ:cZ(t)?uZ:Array.isArray(t)?fZ:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?hZ:ho)(e,t)}var $R=180/Math.PI,mv={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function BR(e,t,n,r,o,a){var s,u,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(u=Math.sqrt(n*n+r*r))&&(n/=u,r/=u,c/=u),e*r<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:o,translateY:a,rotate:Math.atan2(t,e)*$R,skewX:Math.atan(c)*$R,scaleX:s,scaleY:u}}var Ih;function gZ(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?mv:BR(t.a,t.b,t.c,t.d,t.e,t.f)}function yZ(e){return e==null||(Ih||(Ih=document.createElementNS("http://www.w3.org/2000/svg","g")),Ih.setAttribute("transform",e),!(e=Ih.transform.baseVal.consolidate()))?mv:(e=e.matrix,BR(e.a,e.b,e.c,e.d,e.e,e.f))}function HR(e,t,n,r){function o(f){return f.length?f.pop()+" ":""}function a(f,h,p,g,y,w){if(f!==p||h!==g){var v=y.push("translate(",null,t,null,n);w.push({i:v-4,x:ho(f,p)},{i:v-2,x:ho(h,g)})}else(p||g)&&y.push("translate("+p+t+g+n)}function s(f,h,p,g){f!==h?(f-h>180?h+=360:h-f>180&&(f+=360),g.push({i:p.push(o(p)+"rotate(",null,r)-2,x:ho(f,h)})):h&&p.push(o(p)+"rotate("+h+r)}function u(f,h,p,g){f!==h?g.push({i:p.push(o(p)+"skewX(",null,r)-2,x:ho(f,h)}):h&&p.push(o(p)+"skewX("+h+r)}function c(f,h,p,g,y,w){if(f!==p||h!==g){var v=y.push(o(y)+"scale(",null,",",null,")");w.push({i:v-4,x:ho(f,p)},{i:v-2,x:ho(h,g)})}else(p!==1||g!==1)&&y.push(o(y)+"scale("+p+","+g+")")}return function(f,h){var p=[],g=[];return f=e(f),h=e(h),a(f.translateX,f.translateY,h.translateX,h.translateY,p,g),s(f.rotate,h.rotate,p,g),u(f.skewX,h.skewX,p,g),c(f.scaleX,f.scaleY,h.scaleX,h.scaleY,p,g),f=h=null,function(y){for(var w=-1,v=g.length,S;++w<v;)p[(S=g[w]).i]=S.x(y);return p.join("")}}}var vZ=HR(gZ,"px, ","px)","deg)"),bZ=HR(yZ,", ",")",")"),xZ=1e-12;function VR(e){return((e=Math.exp(e))+1/e)/2}function wZ(e){return((e=Math.exp(e))-1/e)/2}function _Z(e){return((e=Math.exp(2*e))-1)/(e+1)}const zh=function e(t,n,r){function o(a,s){var u=a[0],c=a[1],f=a[2],h=s[0],p=s[1],g=s[2],y=h-u,w=p-c,v=y*y+w*w,S,E;if(v<xZ)E=Math.log(g/f)/t,S=function(P){return[u+P*y,c+P*w,f*Math.exp(t*P*E)]};else{var T=Math.sqrt(v),k=(g*g-f*f+r*v)/(2*f*n*T),A=(g*g-f*f-r*v)/(2*g*n*T),M=Math.log(Math.sqrt(k*k+1)-k),N=Math.log(Math.sqrt(A*A+1)-A);E=(N-M)/t,S=function(P){var z=P*E,B=VR(M),R=f/(n*T)*(B*_Z(t*z+M)-wZ(M));return[u+R*y,c+R*w,f*B/VR(t*z+M)]}}return S.duration=E*1e3*t/Math.SQRT2,S}return o.rho=function(a){var s=Math.max(.001,+a),u=s*s,c=u*u;return e(s,u,c)},o}(Math.SQRT2,2,4);var Gs=0,Bu=0,Hu=0,UR=1e3,Lh,Vu,Fh=0,Oa=0,$h=0,Uu=typeof performance=="object"&&performance.now?performance:Date,qR=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function gv(){return Oa||(qR(SZ),Oa=Uu.now()+$h)}function SZ(){Oa=0}function Bh(){this._call=this._time=this._next=null}Bh.prototype=GR.prototype={constructor:Bh,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?gv():+n)+(t==null?0:+t),!this._next&&Vu!==this&&(Vu?Vu._next=this:Lh=this,Vu=this),this._call=e,this._time=n,yv()},stop:function(){this._call&&(this._call=null,this._time=1/0,yv())}};function GR(e,t,n){var r=new Bh;return r.restart(e,t,n),r}function EZ(){gv(),++Gs;for(var e=Lh,t;e;)(t=Oa-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Gs}function YR(){Oa=(Fh=Uu.now())+$h,Gs=Bu=0;try{EZ()}finally{Gs=0,kZ(),Oa=0}}function CZ(){var e=Uu.now(),t=e-Fh;t>UR&&($h-=t,Fh=e)}function kZ(){for(var e,t=Lh,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Lh=n);Vu=e,yv(r)}function yv(e){if(!Gs){Bu&&(Bu=clearTimeout(Bu));var t=e-Oa;t>24?(e<1/0&&(Bu=setTimeout(YR,e-Uu.now()-$h)),Hu&&(Hu=clearInterval(Hu))):(Hu||(Fh=Uu.now(),Hu=setInterval(CZ,UR)),Gs=1,qR(YR))}}function WR(e,t,n){var r=new Bh;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var TZ=kh("start","end","cancel","interrupt"),AZ=[],XR=0,KR=1,vv=2,Hh=3,ZR=4,bv=5,Vh=6;function Uh(e,t,n,r,o,a){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;RZ(e,n,{name:t,index:r,group:o,on:TZ,tween:AZ,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:XR})}function xv(e,t){var n=Lr(e,t);if(n.state>XR)throw new Error("too late; already scheduled");return n}function po(e,t){var n=Lr(e,t);if(n.state>Hh)throw new Error("too late; already running");return n}function Lr(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function RZ(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=GR(a,0,n.time);function a(f){n.state=KR,n.timer.restart(s,n.delay,n.time),n.delay<=f&&s(f-n.delay)}function s(f){var h,p,g,y;if(n.state!==KR)return c();for(h in r)if(y=r[h],y.name===n.name){if(y.state===Hh)return WR(s);y.state===ZR?(y.state=Vh,y.timer.stop(),y.on.call("interrupt",e,e.__data__,y.index,y.group),delete r[h]):+h<t&&(y.state=Vh,y.timer.stop(),y.on.call("cancel",e,e.__data__,y.index,y.group),delete r[h])}if(WR(function(){n.state===Hh&&(n.state=ZR,n.timer.restart(u,n.delay,n.time),u(f))}),n.state=vv,n.on.call("start",e,e.__data__,n.index,n.group),n.state===vv){for(n.state=Hh,o=new Array(g=n.tween.length),h=0,p=-1;h<g;++h)(y=n.tween[h].value.call(e,e.__data__,n.index,n.group))&&(o[++p]=y);o.length=p+1}}function u(f){for(var h=f<n.duration?n.ease.call(null,f/n.duration):(n.timer.restart(c),n.state=bv,1),p=-1,g=o.length;++p<g;)o[p].call(e,h);n.state===bv&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Vh,n.timer.stop(),delete r[t];for(var f in r)return;delete e.__transition}}function qh(e,t){var n=e.__transition,r,o,a=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((r=n[s]).name!==t){a=!1;continue}o=r.state>vv&&r.state<bv,r.state=Vh,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[s]}a&&delete e.__transition}}function MZ(e){return this.each(function(){qh(this,e)})}function OZ(e,t){var n,r;return function(){var o=po(this,e),a=o.tween;if(a!==n){r=n=a;for(var s=0,u=r.length;s<u;++s)if(r[s].name===t){r=r.slice(),r.splice(s,1);break}}o.tween=r}}function NZ(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var a=po(this,e),s=a.tween;if(s!==r){o=(r=s).slice();for(var u={name:t,value:n},c=0,f=o.length;c<f;++c)if(o[c].name===t){o[c]=u;break}c===f&&o.push(u)}a.tween=o}}function DZ(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Lr(this.node(),n).tween,o=0,a=r.length,s;o<a;++o)if((s=r[o]).name===e)return s.value;return null}return this.each((t==null?OZ:NZ)(n,e,t))}function wv(e,t,n){var r=e._id;return e.each(function(){var o=po(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return Lr(o,r).value[t]}}function QR(e,t){var n;return(typeof t=="number"?ho:t instanceof Aa?jh:(n=Aa(t))?(t=n,jh):FR)(e,t)}function PZ(e){return function(){this.removeAttribute(e)}}function jZ(e){return function(){this.removeAttributeNS(e.space,e.local)}}function IZ(e,t,n){var r,o=n+"",a;return function(){var s=this.getAttribute(e);return s===o?null:s===r?a:a=t(r=s,n)}}function zZ(e,t,n){var r,o=n+"",a;return function(){var s=this.getAttributeNS(e.space,e.local);return s===o?null:s===r?a:a=t(r=s,n)}}function LZ(e,t,n){var r,o,a;return function(){var s,u=n(this),c;return u==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=u+"",s===c?null:s===r&&c===o?a:(o=c,a=t(r=s,u)))}}function FZ(e,t,n){var r,o,a;return function(){var s,u=n(this),c;return u==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=u+"",s===c?null:s===r&&c===o?a:(o=c,a=t(r=s,u)))}}function $Z(e,t){var n=Ah(e),r=n==="transform"?bZ:QR;return this.attrTween(e,typeof t=="function"?(n.local?FZ:LZ)(n,r,wv(this,"attr."+e,t)):t==null?(n.local?jZ:PZ)(n):(n.local?zZ:IZ)(n,r,t))}function BZ(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function HZ(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function VZ(e,t){var n,r;function o(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&HZ(e,a)),n}return o._value=t,o}function UZ(e,t){var n,r;function o(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&BZ(e,a)),n}return o._value=t,o}function qZ(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=Ah(e);return this.tween(n,(r.local?VZ:UZ)(r,t))}function GZ(e,t){return function(){xv(this,e).delay=+t.apply(this,arguments)}}function YZ(e,t){return t=+t,function(){xv(this,e).delay=t}}function WZ(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?GZ:YZ)(t,e)):Lr(this.node(),t).delay}function XZ(e,t){return function(){po(this,e).duration=+t.apply(this,arguments)}}function KZ(e,t){return t=+t,function(){po(this,e).duration=t}}function ZZ(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?XZ:KZ)(t,e)):Lr(this.node(),t).duration}function QZ(e,t){if(typeof t!="function")throw new Error;return function(){po(this,e).ease=t}}function JZ(e){var t=this._id;return arguments.length?this.each(QZ(t,e)):Lr(this.node(),t).ease}function eQ(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;po(this,e).ease=n}}function tQ(e){if(typeof e!="function")throw new Error;return this.each(eQ(this._id,e))}function nQ(e){typeof e!="function"&&(e=mR(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var a=t[o],s=a.length,u=r[o]=[],c,f=0;f<s;++f)(c=a[f])&&e.call(c,c.__data__,f,a)&&u.push(c);return new qo(r,this._parents,this._name,this._id)}function rQ(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,a=Math.min(r,o),s=new Array(r),u=0;u<a;++u)for(var c=t[u],f=n[u],h=c.length,p=s[u]=new Array(h),g,y=0;y<h;++y)(g=c[y]||f[y])&&(p[y]=g);for(;u<r;++u)s[u]=t[u];return new qo(s,this._parents,this._name,this._id)}function oQ(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function iQ(e,t,n){var r,o,a=oQ(t)?xv:po;return function(){var s=a(this,e),u=s.on;u!==r&&(o=(r=u).copy()).on(t,n),s.on=o}}function aQ(e,t){var n=this._id;return arguments.length<2?Lr(this.node(),n).on.on(e):this.each(iQ(n,e,t))}function sQ(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function lQ(){return this.on("end.remove",sQ(this._id))}function uQ(e){var t=this._name,n=this._id;typeof e!="function"&&(e=iv(e));for(var r=this._groups,o=r.length,a=new Array(o),s=0;s<o;++s)for(var u=r[s],c=u.length,f=a[s]=new Array(c),h,p,g=0;g<c;++g)(h=u[g])&&(p=e.call(h,h.__data__,g,u))&&("__data__"in h&&(p.__data__=h.__data__),f[g]=p,Uh(f[g],t,n,g,f,Lr(h,n)));return new qo(a,this._parents,t,n)}function cQ(e){var t=this._name,n=this._id;typeof e!="function"&&(e=pR(e));for(var r=this._groups,o=r.length,a=[],s=[],u=0;u<o;++u)for(var c=r[u],f=c.length,h,p=0;p<f;++p)if(h=c[p]){for(var g=e.call(h,h.__data__,p,c),y,w=Lr(h,n),v=0,S=g.length;v<S;++v)(y=g[v])&&Uh(y,t,n,v,g,w);a.push(g),s.push(h)}return new qo(a,s,t,n)}var fQ=ju.prototype.constructor;function dQ(){return new fQ(this._groups,this._parents)}function hQ(e,t){var n,r,o;return function(){var a=Vs(this,e),s=(this.style.removeProperty(e),Vs(this,e));return a===s?null:a===n&&s===r?o:o=t(n=a,r=s)}}function JR(e){return function(){this.style.removeProperty(e)}}function pQ(e,t,n){var r,o=n+"",a;return function(){var s=Vs(this,e);return s===o?null:s===r?a:a=t(r=s,n)}}function mQ(e,t,n){var r,o,a;return function(){var s=Vs(this,e),u=n(this),c=u+"";return u==null&&(c=u=(this.style.removeProperty(e),Vs(this,e))),s===c?null:s===r&&c===o?a:(o=c,a=t(r=s,u))}}function gQ(e,t){var n,r,o,a="style."+t,s="end."+a,u;return function(){var c=po(this,e),f=c.on,h=c.value[a]==null?u||(u=JR(t)):void 0;(f!==n||o!==h)&&(r=(n=f).copy()).on(s,o=h),c.on=r}}function yQ(e,t,n){var r=(e+="")=="transform"?vZ:QR;return t==null?this.styleTween(e,hQ(e,r)).on("end.style."+e,JR(e)):typeof t=="function"?this.styleTween(e,mQ(e,r,wv(this,"style."+e,t))).each(gQ(this._id,e)):this.styleTween(e,pQ(e,r,t),n).on("end.style."+e,null)}function vQ(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function bQ(e,t,n){var r,o;function a(){var s=t.apply(this,arguments);return s!==o&&(r=(o=s)&&vQ(e,s,n)),r}return a._value=t,a}function xQ(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,bQ(e,t,n??""))}function wQ(e){return function(){this.textContent=e}}function _Q(e){return function(){var t=e(this);this.textContent=t??""}}function SQ(e){return this.tween("text",typeof e=="function"?_Q(wv(this,"text",e)):wQ(e==null?"":e+""))}function EQ(e){return function(t){this.textContent=e.call(this,t)}}function CQ(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&EQ(o)),t}return r._value=e,r}function kQ(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,CQ(e))}function TQ(){for(var e=this._name,t=this._id,n=eM(),r=this._groups,o=r.length,a=0;a<o;++a)for(var s=r[a],u=s.length,c,f=0;f<u;++f)if(c=s[f]){var h=Lr(c,t);Uh(c,e,n,f,s,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new qo(r,this._parents,e,n)}function AQ(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(a,s){var u={value:s},c={value:function(){--o===0&&a()}};n.each(function(){var f=po(this,r),h=f.on;h!==e&&(t=(e=h).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(c)),f.on=t}),o===0&&a()})}var RQ=0;function qo(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function eM(){return++RQ}var Go=ju.prototype;qo.prototype={constructor:qo,select:uQ,selectAll:cQ,selectChild:Go.selectChild,selectChildren:Go.selectChildren,filter:nQ,merge:rQ,selection:dQ,transition:TQ,call:Go.call,nodes:Go.nodes,node:Go.node,size:Go.size,empty:Go.empty,each:Go.each,on:aQ,attr:$Z,attrTween:qZ,style:yQ,styleTween:xQ,text:SQ,textTween:kQ,remove:lQ,tween:DZ,delay:WZ,duration:ZZ,ease:JZ,easeVarying:tQ,end:AQ,[Symbol.iterator]:Go[Symbol.iterator]};function MQ(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var OQ={time:null,delay:0,duration:250,ease:MQ};function NQ(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function DQ(e){var t,n;e instanceof qo?(t=e._id,e=e._name):(t=eM(),(n=OQ).time=gv(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,a=0;a<o;++a)for(var s=r[a],u=s.length,c,f=0;f<u;++f)(c=s[f])&&Uh(c,e,t,f,s,n||NQ(c,t));return new qo(r,this._parents,e,t)}ju.prototype.interrupt=MZ,ju.prototype.transition=DQ;const Gh=e=>()=>e;function PQ(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Yo(e,t,n){this.k=e,this.x=t,this.y=n}Yo.prototype={constructor:Yo,scale:function(e){return e===1?this:new Yo(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Yo(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Yh=new Yo(1,0,0);tM.prototype=Yo.prototype;function tM(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Yh;return e.__zoom}function _v(e){e.stopImmediatePropagation()}function qu(e){e.preventDefault(),e.stopImmediatePropagation()}function jQ(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function IQ(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function nM(){return this.__zoom||Yh}function zQ(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function LQ(){return navigator.maxTouchPoints||"ontouchstart"in this}function FQ(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),s>a?(a+s)/2:Math.min(0,a)||Math.max(0,s))}function rM(){var e=jQ,t=IQ,n=FQ,r=zQ,o=LQ,a=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],u=250,c=zh,f=kh("start","zoom","end"),h,p,g,y=500,w=150,v=0,S=10;function E(j){j.property("__zoom",nM).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",R).filter(o).on("touchstart.zoom",F).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",W).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}E.transform=function(j,V,I,H){var q=j.selection?j.selection():j;q.property("__zoom",nM),j!==q?M(j,V,I,H):q.interrupt().each(function(){N(this,arguments).event(H).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},E.scaleBy=function(j,V,I,H){E.scaleTo(j,function(){var q=this.__zoom.k,G=typeof V=="function"?V.apply(this,arguments):V;return q*G},I,H)},E.scaleTo=function(j,V,I,H){E.transform(j,function(){var q=t.apply(this,arguments),G=this.__zoom,O=I==null?A(q):typeof I=="function"?I.apply(this,arguments):I,Y=G.invert(O),Z=typeof V=="function"?V.apply(this,arguments):V;return n(k(T(G,Z),O,Y),q,s)},I,H)},E.translateBy=function(j,V,I,H){E.transform(j,function(){return n(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof I=="function"?I.apply(this,arguments):I),t.apply(this,arguments),s)},null,H)},E.translateTo=function(j,V,I,H,q){E.transform(j,function(){var G=t.apply(this,arguments),O=this.__zoom,Y=H==null?A(G):typeof H=="function"?H.apply(this,arguments):H;return n(Yh.translate(Y[0],Y[1]).scale(O.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof I=="function"?-I.apply(this,arguments):-I),G,s)},H,q)};function T(j,V){return V=Math.max(a[0],Math.min(a[1],V)),V===j.k?j:new Yo(V,j.x,j.y)}function k(j,V,I){var H=V[0]-I[0]*j.k,q=V[1]-I[1]*j.k;return H===j.x&&q===j.y?j:new Yo(j.k,H,q)}function A(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function M(j,V,I,H){j.on("start.zoom",function(){N(this,arguments).event(H).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(H).end()}).tween("zoom",function(){var q=this,G=arguments,O=N(q,G).event(H),Y=t.apply(q,G),Z=I==null?A(Y):typeof I=="function"?I.apply(q,G):I,L=Math.max(Y[1][0]-Y[0][0],Y[1][1]-Y[0][1]),te=q.__zoom,he=typeof V=="function"?V.apply(q,G):V,oe=c(te.invert(Z).concat(L/te.k),he.invert(Z).concat(L/he.k));return function(de){if(de===1)de=he;else{var le=oe(de),ye=L/le[2];de=new Yo(ye,Z[0]-le[0]*ye,Z[1]-le[1]*ye)}O.zoom(null,de)}})}function N(j,V,I){return!I&&j.__zooming||new P(j,V)}function P(j,V){this.that=j,this.args=V,this.active=0,this.sourceEvent=null,this.extent=t.apply(j,V),this.taps=0}P.prototype={event:function(j){return j&&(this.sourceEvent=j),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(j,V){return this.mouse&&j!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var V=Zn(this.that).datum();f.call(j,this.that,new PQ(j,{sourceEvent:this.sourceEvent,target:E,transform:this.that.__zoom,dispatch:f}),V)}};function z(j,...V){if(!e.apply(this,arguments))return;var I=N(this,V).event(j),H=this.__zoom,q=Math.max(a[0],Math.min(a[1],H.k*Math.pow(2,r.apply(this,arguments)))),G=Ir(j);if(I.wheel)(I.mouse[0][0]!==G[0]||I.mouse[0][1]!==G[1])&&(I.mouse[1]=H.invert(I.mouse[0]=G)),clearTimeout(I.wheel);else{if(H.k===q)return;I.mouse=[G,H.invert(G)],qh(this),I.start()}qu(j),I.wheel=setTimeout(O,w),I.zoom("mouse",n(k(T(H,q),I.mouse[0],I.mouse[1]),I.extent,s));function O(){I.wheel=null,I.end()}}function B(j,...V){if(g||!e.apply(this,arguments))return;var I=j.currentTarget,H=N(this,V,!0).event(j),q=Zn(j.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",L,!0),G=Ir(j,I),O=j.clientX,Y=j.clientY;CR(j.view),_v(j),H.mouse=[G,this.__zoom.invert(G)],qh(this),H.start();function Z(te){if(qu(te),!H.moved){var he=te.clientX-O,oe=te.clientY-Y;H.moved=he*he+oe*oe>v}H.event(te).zoom("mouse",n(k(H.that.__zoom,H.mouse[0]=Ir(te,I),H.mouse[1]),H.extent,s))}function L(te){q.on("mousemove.zoom mouseup.zoom",null),kR(te.view,H.moved),qu(te),H.event(te).end()}}function R(j,...V){if(e.apply(this,arguments)){var I=this.__zoom,H=Ir(j.changedTouches?j.changedTouches[0]:j,this),q=I.invert(H),G=I.k*(j.shiftKey?.5:2),O=n(k(T(I,G),H,q),t.apply(this,V),s);qu(j),u>0?Zn(this).transition().duration(u).call(M,O,H,j):Zn(this).call(E.transform,O,H,j)}}function F(j,...V){if(e.apply(this,arguments)){var I=j.touches,H=I.length,q=N(this,V,j.changedTouches.length===H).event(j),G,O,Y,Z;for(_v(j),O=0;O<H;++O)Y=I[O],Z=Ir(Y,this),Z=[Z,this.__zoom.invert(Z),Y.identifier],q.touch0?!q.touch1&&q.touch0[2]!==Z[2]&&(q.touch1=Z,q.taps=0):(q.touch0=Z,G=!0,q.taps=1+!!h);h&&(h=clearTimeout(h)),G&&(q.taps<2&&(p=Z[0],h=setTimeout(function(){h=null},y)),qh(this),q.start())}}function U(j,...V){if(this.__zooming){var I=N(this,V).event(j),H=j.changedTouches,q=H.length,G,O,Y,Z;for(qu(j),G=0;G<q;++G)O=H[G],Y=Ir(O,this),I.touch0&&I.touch0[2]===O.identifier?I.touch0[0]=Y:I.touch1&&I.touch1[2]===O.identifier&&(I.touch1[0]=Y);if(O=I.that.__zoom,I.touch1){var L=I.touch0[0],te=I.touch0[1],he=I.touch1[0],oe=I.touch1[1],de=(de=he[0]-L[0])*de+(de=he[1]-L[1])*de,le=(le=oe[0]-te[0])*le+(le=oe[1]-te[1])*le;O=T(O,Math.sqrt(de/le)),Y=[(L[0]+he[0])/2,(L[1]+he[1])/2],Z=[(te[0]+oe[0])/2,(te[1]+oe[1])/2]}else if(I.touch0)Y=I.touch0[0],Z=I.touch0[1];else return;I.zoom("touch",n(k(O,Y,Z),I.extent,s))}}function W(j,...V){if(this.__zooming){var I=N(this,V).event(j),H=j.changedTouches,q=H.length,G,O;for(_v(j),g&&clearTimeout(g),g=setTimeout(function(){g=null},y),G=0;G<q;++G)O=H[G],I.touch0&&I.touch0[2]===O.identifier?delete I.touch0:I.touch1&&I.touch1[2]===O.identifier&&delete I.touch1;if(I.touch1&&!I.touch0&&(I.touch0=I.touch1,delete I.touch1),I.touch0)I.touch0[1]=this.__zoom.invert(I.touch0[0]);else if(I.end(),I.taps===2&&(O=Ir(O,this),Math.hypot(p[0]-O[0],p[1]-O[1])<S)){var Y=Zn(this).on("dblclick.zoom");Y&&Y.apply(this,arguments)}}}return E.wheelDelta=function(j){return arguments.length?(r=typeof j=="function"?j:Gh(+j),E):r},E.filter=function(j){return arguments.length?(e=typeof j=="function"?j:Gh(!!j),E):e},E.touchable=function(j){return arguments.length?(o=typeof j=="function"?j:Gh(!!j),E):o},E.extent=function(j){return arguments.length?(t=typeof j=="function"?j:Gh([[+j[0][0],+j[0][1]],[+j[1][0],+j[1][1]]]),E):t},E.scaleExtent=function(j){return arguments.length?(a[0]=+j[0],a[1]=+j[1],E):[a[0],a[1]]},E.translateExtent=function(j){return arguments.length?(s[0][0]=+j[0][0],s[1][0]=+j[1][0],s[0][1]=+j[0][1],s[1][1]=+j[1][1],E):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},E.constrain=function(j){return arguments.length?(n=j,E):n},E.duration=function(j){return arguments.length?(u=+j,E):u},E.interpolate=function(j){return arguments.length?(c=j,E):c},E.on=function(){var j=f.on.apply(f,arguments);return j===f?E:j},E.clickDistance=function(j){return arguments.length?(v=(j=+j)*j,E):Math.sqrt(v)},E.tapDistance=function(j){return arguments.length?(S=+j,E):S},E}const mo={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},Gu=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],oM=["Enter"," ","Escape"],iM={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Ys;(function(e){e.Strict="strict",e.Loose="loose"})(Ys||(Ys={}));var Na;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Na||(Na={}));var Yu;(function(e){e.Partial="partial",e.Full="full"})(Yu||(Yu={}));const aM={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var Ni;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ni||(Ni={}));var Wh;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Wh||(Wh={}));var ke;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ke||(ke={}));const sM={[ke.Left]:ke.Right,[ke.Right]:ke.Left,[ke.Top]:ke.Bottom,[ke.Bottom]:ke.Top};function lM(e){return e===null?null:e?"valid":"invalid"}const uM=e=>"id"in e&&"source"in e&&"target"in e,$Q=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Sv=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Wu=(e,t=[0,0])=>{const{width:n,height:r}=Wo(e),o=e.origin??t,a=n*o[0],s=r*o[1];return{x:e.position.x-a,y:e.position.y-s}},BQ=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const a=typeof o=="string";let s=!t.nodeLookup&&!a?o:void 0;t.nodeLookup&&(s=a?t.nodeLookup.get(o):Sv(o)?o:t.nodeLookup.get(o.id));const u=s?Zh(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Xh(r,u)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Kh(n)},Xu=(e,t={})=>{if(e.size===0)return{x:0,y:0,width:0,height:0};let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0};return e.forEach(r=>{if(t.filter===void 0||t.filter(r)){const o=Zh(r);n=Xh(n,o)}}),Kh(n)},Ev=(e,t,[n,r,o]=[0,0,1],a=!1,s=!1)=>{const u={...Zu(t,[n,r,o]),width:t.width/o,height:t.height/o},c=[];for(const f of e.values()){const{measured:h,selectable:p=!0,hidden:g=!1}=f;if(s&&!p||g)continue;const y=h.width??f.width??f.initialWidth??null,w=h.height??f.height??f.initialHeight??null,v=Ku(u,Xs(f)),S=(y??0)*(w??0),E=a&&v>0;(!f.internals.handleBounds||E||v>=S||f.dragging)&&c.push(f)}return c},HQ=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function VQ(e,t){const n=new Map,r=t?.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&(t?.includeHiddenNodes||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function UQ({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:a},s){if(e.size===0)return Promise.resolve(!0);const u=VQ(e,s),c=Xu(u),f=kv(c,t,n,s?.minZoom??o,s?.maxZoom??a,s?.padding??.1);return await r.setViewport(f,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)}function cM({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:a}){const s=n.get(e),u=s.parentId?n.get(s.parentId):void 0,{x:c,y:f}=u?u.internals.positionAbsolute:{x:0,y:0},h=s.origin??r;let p=s.extent||o;if(s.extent==="parent"&&!s.expandParent)if(!u)a?.("005",mo.error005());else{const y=u.measured.width,w=u.measured.height;y&&w&&(p=[[c,f],[c+y,f+w]])}else u&&Zs(s.extent)&&(p=[[s.extent[0][0]+c,s.extent[0][1]+f],[s.extent[1][0]+c,s.extent[1][1]+f]]);const g=Zs(p)?Da(t,p,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&a?.("015",mo.error015()),{position:{x:g.x-c+(s.measured.width??0)*h[0],y:g.y-f+(s.measured.height??0)*h[1]},positionAbsolute:g}}async function qQ({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const a=new Set(e.map(g=>g.id)),s=[];for(const g of n){if(g.deletable===!1)continue;const y=a.has(g.id),w=!y&&g.parentId&&s.find(v=>v.id===g.parentId);(y||w)&&s.push(g)}const u=new Set(t.map(g=>g.id)),c=r.filter(g=>g.deletable!==!1),h=HQ(s,c);for(const g of c)u.has(g.id)&&!h.find(w=>w.id===g.id)&&h.push(g);if(!o)return{edges:h,nodes:s};const p=await o({nodes:s,edges:h});return typeof p=="boolean"?p?{edges:h,nodes:s}:{edges:[],nodes:[]}:p}const Ws=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Da=(e={x:0,y:0},t,n)=>({x:Ws(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ws(e.y,t[0][1],t[1][1]-(n?.height??0))});function fM(e,t,n){const{width:r,height:o}=Wo(n),{x:a,y:s}=n.internals.positionAbsolute;return Da(e,[[a,s],[a+r,s+o]],t)}const dM=(e,t,n)=>e<t?Ws(Math.abs(e-t),1,t)/t:e>n?-Ws(Math.abs(e-n),1,t)/t:0,hM=(e,t,n=15,r=40)=>{const o=dM(e.x,r,t.width-r)*n,a=dM(e.y,r,t.height-r)*n;return[o,a]},Xh=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Cv=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Kh=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Xs=(e,t=[0,0])=>{const{x:n,y:r}=Sv(e)?e.internals.positionAbsolute:Wu(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},Zh=(e,t=[0,0])=>{const{x:n,y:r}=Sv(e)?e.internals.positionAbsolute:Wu(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},pM=(e,t)=>Kh(Xh(Cv(e),Cv(t))),Ku=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},mM=e=>Fr(e.width)&&Fr(e.height)&&Fr(e.x)&&Fr(e.y),Fr=e=>!isNaN(e)&&isFinite(e),GQ=(e,t)=>{},Qh=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Zu=({x:e,y:t},[n,r,o],a=!1,s=[1,1])=>{const u={x:(e-n)/o,y:(t-r)/o};return a?Qh(u,s):u},Jh=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function Ks(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function YQ(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Ks(e,n),o=Ks(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=Ks(e.top??e.y??0,n),o=Ks(e.bottom??e.y??0,n),a=Ks(e.left??e.x??0,t),s=Ks(e.right??e.x??0,t);return{top:r,right:s,bottom:o,left:a,x:a+s,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function WQ(e,t,n,r,o,a){const{x:s,y:u}=Jh(e,[t,n,r]),{x:c,y:f}=Jh({x:e.x+e.width,y:e.y+e.height},[t,n,r]),h=o-c,p=a-f;return{left:Math.floor(s),top:Math.floor(u),right:Math.floor(h),bottom:Math.floor(p)}}const kv=(e,t,n,r,o,a)=>{const s=YQ(a,t,n),u=(t-s.x)/e.width,c=(n-s.y)/e.height,f=Math.min(u,c),h=Ws(f,r,o),p=e.x+e.width/2,g=e.y+e.height/2,y=t/2-p*h,w=n/2-g*h,v=WQ(e,y,w,h,t,n),S={left:Math.min(v.left-s.left,0),top:Math.min(v.top-s.top,0),right:Math.min(v.right-s.right,0),bottom:Math.min(v.bottom-s.bottom,0)};return{x:y-S.left+S.right,y:w-S.top+S.bottom,zoom:h}},ep=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Zs(e){return e!==void 0&&e!=="parent"}function Wo(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function gM(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function yM(e,t={width:0,height:0},n,r,o){const a={...e},s=r.get(n);if(s){const u=s.origin||o;a.x+=s.internals.positionAbsolute.x-(t.width??0)*u[0],a.y+=s.internals.positionAbsolute.y-(t.height??0)*u[1]}return a}function vM(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function XQ(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function KQ(e){return{...iM,...e||{}}}function Qu(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:a,y:s}=go(e),u=Zu({x:a-(o?.left??0),y:s-(o?.top??0)},r),{x:c,y:f}=n?Qh(u,t):u;return{xSnapped:c,ySnapped:f,...u}}const Tv=e=>({width:e.offsetWidth,height:e.offsetHeight}),bM=e=>e?.getRootNode?.()||window?.document,ZQ=["INPUT","SELECT","TEXTAREA"];function xM(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:ZQ.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const wM=e=>"clientX"in e,go=(e,t)=>{const n=wM(e),r=n?e.clientX:e.touches?.[0].clientX,o=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:o-(t?.top??0)}},_M=(e,t,n,r,o)=>{const a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(s=>{const u=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:o,position:s.getAttribute("data-handlepos"),x:(u.left-n.left)/r,y:(u.top-n.top)/r,...Tv(s)}})};function SM({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:a,targetControlX:s,targetControlY:u}){const c=e*.125+o*.375+s*.375+n*.125,f=t*.125+a*.375+u*.375+r*.125,h=Math.abs(c-e),p=Math.abs(f-t);return[c,f,h,p]}function tp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function EM({pos:e,x1:t,y1:n,x2:r,y2:o,c:a}){switch(e){case ke.Left:return[t-tp(t-r,a),n];case ke.Right:return[t+tp(r-t,a),n];case ke.Top:return[t,n-tp(n-o,a)];case ke.Bottom:return[t,n+tp(o-n,a)]}}function Av({sourceX:e,sourceY:t,sourcePosition:n=ke.Bottom,targetX:r,targetY:o,targetPosition:a=ke.Top,curvature:s=.25}){const[u,c]=EM({pos:n,x1:e,y1:t,x2:r,y2:o,c:s}),[f,h]=EM({pos:a,x1:r,y1:o,x2:e,y2:t,c:s}),[p,g,y,w]=SM({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:u,sourceControlY:c,targetControlX:f,targetControlY:h});return[`M${e},${t} C${u},${c} ${f},${h} ${r},${o}`,p,g,y,w]}function CM({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,a=n<e?n+o:n-o,s=Math.abs(r-t)/2,u=r<t?r+s:r-s;return[a,u,o,s]}function QQ({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r,elevateOnSelect:o=!1}){if(r!==void 0)return r;const a=o&&n?1e3:0,s=Math.max(e.parentId?e.internals.z:0,t.parentId?t.internals.z:0);return a+s}function JQ({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const a=Xh(Zh(e),Zh(t));a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1);const s={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return Ku(s,Kh(a))>0}const eJ=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,tJ=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),nJ=(e,t)=>{if(!e.source||!e.target)return t;let n;return uM(e)?n={...e}:n={...e,id:eJ(e)},tJ(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))};function kM({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,a,s,u]=CM({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,a,s,u]}const TM={[ke.Left]:{x:-1,y:0},[ke.Right]:{x:1,y:0},[ke.Top]:{x:0,y:-1},[ke.Bottom]:{x:0,y:1}},rJ=({source:e,sourcePosition:t=ke.Bottom,target:n})=>t===ke.Left||t===ke.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},AM=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function oJ({source:e,sourcePosition:t=ke.Bottom,target:n,targetPosition:r=ke.Top,center:o,offset:a,stepPosition:s}){const u=TM[t],c=TM[r],f={x:e.x+u.x*a,y:e.y+u.y*a},h={x:n.x+c.x*a,y:n.y+c.y*a},p=rJ({source:f,sourcePosition:t,target:h}),g=p.x!==0?"x":"y",y=p[g];let w=[],v,S;const E={x:0,y:0},T={x:0,y:0},[,,k,A]=CM({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(u[g]*c[g]===-1){g==="x"?(v=o.x??f.x+(h.x-f.x)*s,S=o.y??(f.y+h.y)/2):(v=o.x??(f.x+h.x)/2,S=o.y??f.y+(h.y-f.y)*s);const N=[{x:v,y:f.y},{x:v,y:h.y}],P=[{x:f.x,y:S},{x:h.x,y:S}];u[g]===y?w=g==="x"?N:P:w=g==="x"?P:N}else{const N=[{x:f.x,y:h.y}],P=[{x:h.x,y:f.y}];if(g==="x"?w=u.x===y?P:N:w=u.y===y?N:P,t===r){const U=Math.abs(e[g]-n[g]);if(U<=a){const W=Math.min(a-1,a-U);u[g]===y?E[g]=(f[g]>e[g]?-1:1)*W:T[g]=(h[g]>n[g]?-1:1)*W}}if(t!==r){const U=g==="x"?"y":"x",W=u[g]===c[U],j=f[U]>h[U],V=f[U]<h[U];(u[g]===1&&(!W&&j||W&&V)||u[g]!==1&&(!W&&V||W&&j))&&(w=g==="x"?N:P)}const z={x:f.x+E.x,y:f.y+E.y},B={x:h.x+T.x,y:h.y+T.y},R=Math.max(Math.abs(z.x-w[0].x),Math.abs(B.x-w[0].x)),F=Math.max(Math.abs(z.y-w[0].y),Math.abs(B.y-w[0].y));R>=F?(v=(z.x+B.x)/2,S=w[0].y):(v=w[0].x,S=(z.y+B.y)/2)}return[[e,{x:f.x+E.x,y:f.y+E.y},...w,{x:h.x+T.x,y:h.y+T.y},n],v,S,k,A]}function iJ(e,t,n,r){const o=Math.min(AM(e,t)/2,AM(t,n)/2,r),{x:a,y:s}=t;if(e.x===a&&a===n.x||e.y===s&&s===n.y)return`L${a} ${s}`;if(e.y===s){const f=e.x<n.x?-1:1,h=e.y<n.y?1:-1;return`L ${a+o*f},${s}Q ${a},${s} ${a},${s+o*h}`}const u=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${a},${s+o*c}Q ${a},${s} ${a+o*u},${s}`}function Rv({sourceX:e,sourceY:t,sourcePosition:n=ke.Bottom,targetX:r,targetY:o,targetPosition:a=ke.Top,borderRadius:s=5,centerX:u,centerY:c,offset:f=20,stepPosition:h=.5}){const[p,g,y,w,v]=oJ({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:a,center:{x:u,y:c},offset:f,stepPosition:h});return[p.reduce((E,T,k)=>{let A="";return k>0&&k<p.length-1?A=iJ(p[k-1],T,p[k+1],s):A=`${k===0?"M":"L"}${T.x} ${T.y}`,E+=A,E},""),g,y,w,v]}function RM(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function aJ(e){const{sourceNode:t,targetNode:n}=e;if(!RM(t)||!RM(n))return null;const r=t.internals.handleBounds||MM(t.handles),o=n.internals.handleBounds||MM(n.handles),a=OM(r?.source??[],e.sourceHandle),s=OM(e.connectionMode===Ys.Strict?o?.target??[]:(o?.target??[]).concat(o?.source??[]),e.targetHandle);if(!a||!s)return e.onError?.("008",mo.error008(a?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const u=a?.position||ke.Bottom,c=s?.position||ke.Top,f=Ju(t,a,u),h=Ju(n,s,c);return{sourceX:f.x,sourceY:f.y,targetX:h.x,targetY:h.y,sourcePosition:u,targetPosition:c}}function MM(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function Ju(e,t,n=ke.Left,r=!1){const o=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:u}=t??Wo(e);if(r)return{x:o+s/2,y:a+u/2};switch(t?.position??n){case ke.Top:return{x:o+s/2,y:a};case ke.Right:return{x:o+s,y:a+u/2};case ke.Bottom:return{x:o+s/2,y:a+u};case ke.Left:return{x:o,y:a+u/2}}}function OM(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Mv(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function sJ(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const a=new Set;return e.reduce((s,u)=>([u.markerStart||r,u.markerEnd||o].forEach(c=>{if(c&&typeof c=="object"){const f=Mv(c,t);a.has(f)||(s.push({id:f,color:c.color||n,...c}),a.add(f))}}),s),[]).sort((s,u)=>s.id.localeCompare(u.id))}const Ov={nodeOrigin:[0,0],nodeExtent:Gu,elevateNodesOnSelect:!0,defaults:{}},lJ={...Ov,checkEquality:!0};function Nv(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function uJ(e,t,n){const r=Nv(Ov,n);for(const o of e.values())if(o.parentId)Pv(o,e,t,r);else{const a=Wu(o,r.nodeOrigin),s=Zs(o.extent)?o.extent:r.nodeExtent,u=Da(a,s,Wo(o));o.internals.positionAbsolute=u}}function Dv(e,t,n,r){const o=Nv(lJ,r);let a=e.length>0;const s=new Map(t),u=o?.elevateNodesOnSelect?1e3:0;t.clear(),n.clear();for(const c of e){let f=s.get(c.id);if(o.checkEquality&&c===f?.internals.userNode)t.set(c.id,f);else{const h=Wu(c,o.nodeOrigin),p=Zs(c.extent)?c.extent:o.nodeExtent,g=Da(h,p,Wo(c));f={...o.defaults,...c,measured:{width:c.measured?.width,height:c.measured?.height},internals:{positionAbsolute:g,handleBounds:c.measured?f?.internals.handleBounds:void 0,z:NM(c,u),userNode:c}},t.set(c.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(a=!1),c.parentId&&Pv(f,t,n,r)}return a}function cJ(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Pv(e,t,n,r){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:s}=Nv(Ov,r),u=e.parentId,c=t.get(u);if(!c){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}cJ(e,n);const f=o?1e3:0,{x:h,y:p,z:g}=fJ(e,c,a,s,f),{positionAbsolute:y}=e.internals,w=h!==y.x||p!==y.y;(w||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:h,y:p}:y,z:g}})}function NM(e,t){return(Fr(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function fJ(e,t,n,r,o){const{x:a,y:s}=t.internals.positionAbsolute,u=Wo(e),c=Wu(e,n),f=Zs(e.extent)?Da(c,e.extent,u):c;let h=Da({x:a+f.x,y:s+f.y},r,u);e.extent==="parent"&&(h=fM(h,u,t));const p=NM(e,o),g=t.internals.z??0;return{x:h.x,y:h.y,z:g>=p?g+1:p}}function jv(e,t,n,r=[0,0]){const o=[],a=new Map;for(const s of e){const u=t.get(s.parentId);if(!u)continue;const c=a.get(s.parentId)?.expandedRect??Xs(u),f=pM(c,s.rect);a.set(s.parentId,{expandedRect:f,parent:u})}return a.size>0&&a.forEach(({expandedRect:s,parent:u},c)=>{const f=u.internals.positionAbsolute,h=Wo(u),p=u.origin??r,g=s.x<f.x?Math.round(Math.abs(f.x-s.x)):0,y=s.y<f.y?Math.round(Math.abs(f.y-s.y)):0,w=Math.max(h.width,Math.round(s.width)),v=Math.max(h.height,Math.round(s.height)),S=(w-h.width)*p[0],E=(v-h.height)*p[1];(g>0||y>0||S||E)&&(o.push({id:c,type:"position",position:{x:u.position.x-g+S,y:u.position.y-y+E}}),n.get(c)?.forEach(T=>{e.some(k=>k.id===T.id)||o.push({id:T.id,type:"position",position:{x:T.position.x+g,y:T.position.y+y}})})),(h.width<s.width||h.height<s.height||g||y)&&o.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:w+(g?p[0]*g-S:0),height:v+(y?p[1]*y-E:0)}})}),o}function dJ(e,t,n,r,o,a){const s=r?.querySelector(".xyflow__viewport");let u=!1;if(!s)return{changes:[],updatedInternals:u};const c=[],f=window.getComputedStyle(s),{m22:h}=new window.DOMMatrixReadOnly(f.transform),p=[];for(const g of e.values()){const y=t.get(g.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),u=!0;continue}const w=Tv(g.nodeElement),v=y.measured.width!==w.width||y.measured.height!==w.height;if(!!(w.width&&w.height&&(v||!y.internals.handleBounds||g.force))){const E=g.nodeElement.getBoundingClientRect(),T=Zs(y.extent)?y.extent:a;let{positionAbsolute:k}=y.internals;y.parentId&&y.extent==="parent"?k=fM(k,w,t.get(y.parentId)):T&&(k=Da(k,T,w));const A={...y,measured:w,internals:{...y.internals,positionAbsolute:k,handleBounds:{source:_M("source",g.nodeElement,E,h,y.id),target:_M("target",g.nodeElement,E,h,y.id)}}};t.set(y.id,A),y.parentId&&Pv(A,t,n,{nodeOrigin:o}),u=!0,v&&(c.push({id:y.id,type:"dimensions",dimensions:w}),y.expandParent&&y.parentId&&p.push({id:y.id,parentId:y.parentId,rect:Xs(A,o)}))}}if(p.length>0){const g=jv(p,t,n,o);c.push(...g)}return{changes:c,updatedInternals:u}}async function hJ({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:a}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,a]],r),u=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(u)}function DM(e,t,n,r,o,a){let s=o;const u=r.get(s)||new Map;r.set(s,u.set(n,t)),s=`${o}-${e}`;const c=r.get(s)||new Map;if(r.set(s,c.set(n,t)),a){s=`${o}-${e}-${a}`;const f=r.get(s)||new Map;r.set(s,f.set(n,t))}}function PM(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:a,sourceHandle:s=null,targetHandle:u=null}=r,c={edgeId:r.id,source:o,target:a,sourceHandle:s,targetHandle:u},f=`${o}-${s}--${a}-${u}`,h=`${a}-${u}--${o}-${s}`;DM("source",c,h,e,o,s),DM("target",c,f,e,a,u),t.set(r.id,r)}}function jM(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:jM(n,t):!1}function IM(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function pJ(e,t,n,r){const o=new Map;for(const[a,s]of e)if((s.selected||s.id===r)&&(!s.parentId||!jM(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const u=e.get(a);u&&o.set(a,{id:a,position:u.position||{x:0,y:0},distance:{x:n.x-u.internals.positionAbsolute.x,y:n.y-u.internals.positionAbsolute.y},extent:u.extent,parentId:u.parentId,origin:u.origin,expandParent:u.expandParent,internals:{positionAbsolute:u.internals.positionAbsolute||{x:0,y:0}},measured:{width:u.measured.width??0,height:u.measured.height??0}})}return o}function Iv({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){const o=[];for(const[s,u]of t){const c=n.get(s)?.internals.userNode;c&&o.push({...c,position:u.position,dragging:r})}if(!e)return[o[0],o];const a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:o[0],o]}function mJ({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let a={x:null,y:null},s=0,u=new Map,c=!1,f={x:0,y:0},h=null,p=!1,g=null,y=!1,w=!1;function v({noDragClassName:E,handleSelector:T,domNode:k,isSelectable:A,nodeId:M,nodeClickDistance:N=0}){g=Zn(k);function P({x:F,y:U},W){const{nodeLookup:j,nodeExtent:V,snapGrid:I,snapToGrid:H,nodeOrigin:q,onNodeDrag:G,onSelectionDrag:O,onError:Y,updateNodePositions:Z}=t();a={x:F,y:U};let L=!1,te={x:0,y:0,x2:0,y2:0};if(u.size>1&&V){const he=Xu(u);te=Cv(he)}for(const[he,oe]of u){if(!j.has(he))continue;let de={x:F-oe.distance.x,y:U-oe.distance.y};H&&(de=Qh(de,I));let le=[[V[0][0],V[0][1]],[V[1][0],V[1][1]]];if(u.size>1&&V&&!oe.extent){const{positionAbsolute:Ne}=oe.internals,we=Ne.x-te.x+V[0][0],Te=Ne.x+oe.measured.width-te.x2+V[1][0],_e=Ne.y-te.y+V[0][1],Xe=Ne.y+oe.measured.height-te.y2+V[1][1];le=[[we,_e],[Te,Xe]]}const{position:ye,positionAbsolute:je}=cM({nodeId:he,nextPosition:de,nodeLookup:j,nodeExtent:le,nodeOrigin:q,onError:Y});L=L||oe.position.x!==ye.x||oe.position.y!==ye.y,oe.position=ye,oe.internals.positionAbsolute=je}if(w=w||L,!!L&&(Z(u,!0),W&&(r||G||!M&&O))){const[he,oe]=Iv({nodeId:M,dragItems:u,nodeLookup:j});r?.(W,u,he,oe),G?.(W,he,oe),M||O?.(W,oe)}}async function z(){if(!h)return;const{transform:F,panBy:U,autoPanSpeed:W,autoPanOnNodeDrag:j}=t();if(!j){c=!1,cancelAnimationFrame(s);return}const[V,I]=hM(f,h,W);(V!==0||I!==0)&&(a.x=(a.x??0)-V/F[2],a.y=(a.y??0)-I/F[2],await U({x:V,y:I})&&P(a,null)),s=requestAnimationFrame(z)}function B(F){const{nodeLookup:U,multiSelectionActive:W,nodesDraggable:j,transform:V,snapGrid:I,snapToGrid:H,selectNodesOnDrag:q,onNodeDragStart:G,onSelectionDragStart:O,unselectNodesAndEdges:Y}=t();p=!0,(!q||!A)&&!W&&M&&(U.get(M)?.selected||Y()),A&&q&&M&&e?.(M);const Z=Qu(F.sourceEvent,{transform:V,snapGrid:I,snapToGrid:H,containerBounds:h});if(a=Z,u=pJ(U,j,Z,M),u.size>0&&(n||G||!M&&O)){const[L,te]=Iv({nodeId:M,dragItems:u,nodeLookup:U});n?.(F.sourceEvent,u,L,te),G?.(F.sourceEvent,L,te),M||O?.(F.sourceEvent,te)}}const R=TR().clickDistance(N).on("start",F=>{const{domNode:U,nodeDragThreshold:W,transform:j,snapGrid:V,snapToGrid:I}=t();h=U?.getBoundingClientRect()||null,y=!1,w=!1,W===0&&B(F),a=Qu(F.sourceEvent,{transform:j,snapGrid:V,snapToGrid:I,containerBounds:h}),f=go(F.sourceEvent,h)}).on("drag",F=>{const{autoPanOnNodeDrag:U,transform:W,snapGrid:j,snapToGrid:V,nodeDragThreshold:I,nodeLookup:H}=t(),q=Qu(F.sourceEvent,{transform:W,snapGrid:j,snapToGrid:V,containerBounds:h});if((F.sourceEvent.type==="touchmove"&&F.sourceEvent.touches.length>1||M&&!H.has(M))&&(y=!0),!y){if(!c&&U&&p&&(c=!0,z()),!p){const G=q.xSnapped-(a.x??0),O=q.ySnapped-(a.y??0);Math.sqrt(G*G+O*O)>I&&B(F)}(a.x!==q.xSnapped||a.y!==q.ySnapped)&&u&&p&&(f=go(F.sourceEvent,h),P(q,F.sourceEvent))}}).on("end",F=>{if(!(!p||y)&&(c=!1,p=!1,cancelAnimationFrame(s),u.size>0)){const{nodeLookup:U,updateNodePositions:W,onNodeDragStop:j,onSelectionDragStop:V}=t();if(w&&(W(u,!1),w=!1),o||j||!M&&V){const[I,H]=Iv({nodeId:M,dragItems:u,nodeLookup:U,dragging:!1});o?.(F.sourceEvent,u,I,H),j?.(F.sourceEvent,I,H),M||V?.(F.sourceEvent,H)}}}).filter(F=>{const U=F.target;return!F.button&&(!E||!IM(U,`.${E}`,k))&&(!T||IM(U,T,k))});g.call(R)}function S(){g?.on(".drag",null)}return{update:v,destroy:S}}function gJ(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const a of t.values())Ku(o,Xs(a))>0&&r.push(a);return r}const yJ=250;function vJ(e,t,n,r){let o=[],a=1/0;const s=gJ(e,n,t+yJ);for(const u of s){const c=[...u.internals.handleBounds?.source??[],...u.internals.handleBounds?.target??[]];for(const f of c){if(r.nodeId===f.nodeId&&r.type===f.type&&r.id===f.id)continue;const{x:h,y:p}=Ju(u,f,f.position,!0),g=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(p-e.y,2));g>t||(g<a?(o=[{...f,x:h,y:p}],a=g):g===a&&o.push({...f,x:h,y:p}))}}if(!o.length)return null;if(o.length>1){const u=r.type==="source"?"target":"source";return o.find(c=>c.type===u)??o[0]}return o[0]}function zM(e,t,n,r,o,a=!1){const s=r.get(e);if(!s)return null;const u=o==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],c=(n?u?.find(f=>f.id===n):u?.[0])??null;return c&&a?{...c,...Ju(s,c,c.position,!0)}:c}function LM(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function bJ(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const FM=()=>!0;function xJ(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:a,isTarget:s,domNode:u,nodeLookup:c,lib:f,autoPanOnConnect:h,flowId:p,panBy:g,cancelConnection:y,onConnectStart:w,onConnect:v,onConnectEnd:S,isValidConnection:E=FM,onReconnectEnd:T,updateConnection:k,getTransform:A,getFromHandle:M,autoPanSpeed:N,dragThreshold:P=1}){const z=bM(e.target);let B=0,R;const{x:F,y:U}=go(e),W=z?.elementFromPoint(F,U),j=LM(a,W),V=u?.getBoundingClientRect();let I=!1;if(!V||!j)return;const H=zM(o,j,r,c,t);if(!H)return;let q=go(e,V),G=!1,O=null,Y=!1,Z=null;function L(){if(!h||!V)return;const[Ne,we]=hM(q,V,N);g({x:Ne,y:we}),B=requestAnimationFrame(L)}const te={...H,nodeId:o,type:j,position:H.position},he=c.get(o);let de={inProgress:!0,isValid:null,from:Ju(he,te,ke.Left,!0),fromHandle:te,fromPosition:te.position,fromNode:he,to:q,toHandle:null,toPosition:sM[te.position],toNode:null};function le(){I=!0,k(de),w?.(e,{nodeId:o,handleId:r,handleType:j})}P===0&&le();function ye(Ne){if(!I){const{x:Xe,y:Ct}=go(Ne),ft=Xe-F,yn=Ct-U;if(!(ft*ft+yn*yn>P*P))return;le()}if(!M()||!te){je(Ne);return}const we=A();q=go(Ne,V),R=vJ(Zu(q,we,!1,[1,1]),n,c,te),G||(L(),G=!0);const Te=$M(Ne,{handle:R,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:s?"target":"source",isValidConnection:E,doc:z,lib:f,flowId:p,nodeLookup:c});Z=Te.handleDomNode,O=Te.connection,Y=bJ(!!R,Te.isValid);const _e={...de,isValid:Y,to:Te.toHandle&&Y?Jh({x:Te.toHandle.x,y:Te.toHandle.y},we):q,toHandle:Te.toHandle,toPosition:Y&&Te.toHandle?Te.toHandle.position:sM[te.position],toNode:Te.toHandle?c.get(Te.toHandle.nodeId):null};Y&&R&&de.toHandle&&_e.toHandle&&de.toHandle.type===_e.toHandle.type&&de.toHandle.nodeId===_e.toHandle.nodeId&&de.toHandle.id===_e.toHandle.id&&de.to.x===_e.to.x&&de.to.y===_e.to.y||(k(_e),de=_e)}function je(Ne){if(I){(R||Z)&&O&&Y&&v?.(O);const{inProgress:we,...Te}=de,_e={...Te,toPosition:de.toHandle?de.toPosition:null};S?.(Ne,_e),a&&T?.(Ne,_e)}y(),cancelAnimationFrame(B),G=!1,Y=!1,O=null,Z=null,z.removeEventListener("mousemove",ye),z.removeEventListener("mouseup",je),z.removeEventListener("touchmove",ye),z.removeEventListener("touchend",je)}z.addEventListener("mousemove",ye),z.addEventListener("mouseup",je),z.addEventListener("touchmove",ye),z.addEventListener("touchend",je)}function $M(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:a,doc:s,lib:u,flowId:c,isValidConnection:f=FM,nodeLookup:h}){const p=a==="target",g=t?s.querySelector(`.${u}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:y,y:w}=go(e),v=s.elementFromPoint(y,w),S=v?.classList.contains(`${u}-flow__handle`)?v:g,E={handleDomNode:S,isValid:!1,connection:null,toHandle:null};if(S){const T=LM(void 0,S),k=S.getAttribute("data-nodeid"),A=S.getAttribute("data-handleid"),M=S.classList.contains("connectable"),N=S.classList.contains("connectableend");if(!k||!T)return E;const P={source:p?k:r,sourceHandle:p?A:o,target:p?r:k,targetHandle:p?o:A};E.connection=P;const B=M&&N&&(n===Ys.Strict?p&&T==="source"||!p&&T==="target":k!==r||A!==o);E.isValid=B&&f(P),E.toHandle=zM(k,T,A,h,n,!0)}return E}const zv={onPointerDown:xJ,isValid:$M};function wJ({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=Zn(e);function a({translateExtent:u,width:c,height:f,zoomStep:h=10,pannable:p=!0,zoomable:g=!0,inversePan:y=!1}){const w=k=>{const A=n();if(k.sourceEvent.type!=="wheel"||!t)return;const M=-k.sourceEvent.deltaY*(k.sourceEvent.deltaMode===1?.05:k.sourceEvent.deltaMode?1:.002)*h,N=A[2]*Math.pow(2,M);t.scaleTo(N)};let v=[0,0];const S=k=>{(k.sourceEvent.type==="mousedown"||k.sourceEvent.type==="touchstart")&&(v=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY])},E=k=>{const A=n();if(k.sourceEvent.type!=="mousemove"&&k.sourceEvent.type!=="touchmove"||!t)return;const M=[k.sourceEvent.clientX??k.sourceEvent.touches[0].clientX,k.sourceEvent.clientY??k.sourceEvent.touches[0].clientY],N=[M[0]-v[0],M[1]-v[1]];v=M;const P=r()*Math.max(A[2],Math.log(A[2]))*(y?-1:1),z={x:A[0]-N[0]*P,y:A[1]-N[1]*P},B=[[0,0],[c,f]];t.setViewportConstrained({x:z.x,y:z.y,zoom:A[2]},B,u)},T=rM().on("start",S).on("zoom",p?E:null).on("zoom.wheel",g?w:null);o.call(T,{})}function s(){o.on("zoom",null)}return{update:a,destroy:s,pointer:Ir}}const _J=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,np=e=>({x:e.x,y:e.y,zoom:e.k}),Lv=({x:e,y:t,zoom:n})=>Yh.translate(e,t).scale(n),Qs=(e,t)=>e.target.closest(`.${t}`),BM=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),SJ=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Fv=(e,t=0,n=SJ,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},HM=e=>{const t=e.ctrlKey&&ep()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function EJ({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:a,zoomOnPinch:s,onPanZoomStart:u,onPanZoom:c,onPanZoomEnd:f}){return h=>{if(Qs(h,t))return!1;h.preventDefault(),h.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(h.ctrlKey&&s){const S=Ir(h),E=HM(h),T=p*Math.pow(2,E);r.scaleTo(n,T,S,h);return}const g=h.deltaMode===1?20:1;let y=o===Na.Vertical?0:h.deltaX*g,w=o===Na.Horizontal?0:h.deltaY*g;!ep()&&h.shiftKey&&o!==Na.Vertical&&(y=h.deltaY*g,w=0),r.translateBy(n,-(y/p)*a,-(w/p)*a,{internal:!0});const v=np(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling||(e.isPanScrolling=!0,u?.(h,v)),e.isPanScrolling&&(c?.(h,v),e.panScrollTimeout=setTimeout(()=>{f?.(h,v),e.isPanScrolling=!1},150))}}function CJ({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const a=r.type==="wheel",s=!t&&a&&!r.ctrlKey,u=Qs(r,e);if(r.ctrlKey&&a&&u&&r.preventDefault(),s||u)return null;r.preventDefault(),n.call(this,r,o)}}function kJ({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;const o=np(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=o,r.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(r.sourceEvent,o)}}function TJ({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return a=>{e.usedRightMouseButton=!!(n&&BM(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),o&&!a.sourceEvent?.internal&&o?.(a.sourceEvent,np(a.transform))}}function AJ({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:a}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&BM(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&a(s.sourceEvent),e.usedRightMouseButton=!1,r(!1),o&&_J(e.prevViewport,s.transform))){const u=np(s.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o?.(s.sourceEvent,u)},n?150:0)}}}function RJ({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:a,userSelectionActive:s,noWheelClassName:u,noPanClassName:c,lib:f}){return h=>{const p=e||t,g=n&&h.ctrlKey;if(h.button===1&&h.type==="mousedown"&&(Qs(h,`${f}-flow__node`)||Qs(h,`${f}-flow__edge`)))return!0;if(!r&&!p&&!o&&!a&&!n||s||Qs(h,u)&&h.type==="wheel"||Qs(h,c)&&(h.type!=="wheel"||o&&h.type==="wheel"&&!e)||!n&&h.ctrlKey&&h.type==="wheel")return!1;if(!n&&h.type==="touchstart"&&h.touches?.length>1)return h.preventDefault(),!1;if(!p&&!o&&!g&&h.type==="wheel"||!r&&(h.type==="mousedown"||h.type==="touchstart")||Array.isArray(r)&&!r.includes(h.button)&&h.type==="mousedown")return!1;const y=Array.isArray(r)&&r.includes(h.button)||!h.button||h.button<=1;return(!h.ctrlKey||h.type==="wheel")&&y}}function MJ({domNode:e,minZoom:t,maxZoom:n,paneClickDistance:r,translateExtent:o,viewport:a,onPanZoom:s,onPanZoomStart:u,onPanZoomEnd:c,onDraggingChange:f}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{x:0,y:0,zoom:0},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},p=e.getBoundingClientRect(),g=rM().clickDistance(!Fr(r)||r<0?0:r).scaleExtent([t,n]).translateExtent(o),y=Zn(e).call(g);k({x:a.x,y:a.y,zoom:Ws(a.zoom,t,n)},[[0,0],[p.width,p.height]],o);const w=y.on("wheel.zoom"),v=y.on("dblclick.zoom");g.wheelDelta(HM);function S(U,W){return y?new Promise(j=>{g?.interpolate(W?.interpolate==="linear"?$u:zh).transform(Fv(y,W?.duration,W?.ease,()=>j(!0)),U)}):Promise.resolve(!1)}function E({noWheelClassName:U,noPanClassName:W,onPaneContextMenu:j,userSelectionActive:V,panOnScroll:I,panOnDrag:H,panOnScrollMode:q,panOnScrollSpeed:G,preventScrolling:O,zoomOnPinch:Y,zoomOnScroll:Z,zoomOnDoubleClick:L,zoomActivationKeyPressed:te,lib:he,onTransformChange:oe}){V&&!h.isZoomingOrPanning&&T();const le=I&&!te&&!V?EJ({zoomPanValues:h,noWheelClassName:U,d3Selection:y,d3Zoom:g,panOnScrollMode:q,panOnScrollSpeed:G,zoomOnPinch:Y,onPanZoomStart:u,onPanZoom:s,onPanZoomEnd:c}):CJ({noWheelClassName:U,preventScrolling:O,d3ZoomHandler:w});if(y.on("wheel.zoom",le,{passive:!1}),!V){const je=kJ({zoomPanValues:h,onDraggingChange:f,onPanZoomStart:u});g.on("start",je);const Ne=TJ({zoomPanValues:h,panOnDrag:H,onPaneContextMenu:!!j,onPanZoom:s,onTransformChange:oe});g.on("zoom",Ne);const we=AJ({zoomPanValues:h,panOnDrag:H,panOnScroll:I,onPaneContextMenu:j,onPanZoomEnd:c,onDraggingChange:f});g.on("end",we)}const ye=RJ({zoomActivationKeyPressed:te,panOnDrag:H,zoomOnScroll:Z,panOnScroll:I,zoomOnDoubleClick:L,zoomOnPinch:Y,userSelectionActive:V,noPanClassName:W,noWheelClassName:U,lib:he});g.filter(ye),L?y.on("dblclick.zoom",v):y.on("dblclick.zoom",null)}function T(){g.on("zoom",null)}async function k(U,W,j){const V=Lv(U),I=g?.constrain()(V,W,j);return I&&await S(I),new Promise(H=>H(I))}async function A(U,W){const j=Lv(U);return await S(j,W),new Promise(V=>V(j))}function M(U){if(y){const W=Lv(U),j=y.property("__zoom");(j.k!==U.zoom||j.x!==U.x||j.y!==U.y)&&g?.transform(y,W,null,{sync:!0})}}function N(){const U=y?tM(y.node()):{x:0,y:0,k:1};return{x:U.x,y:U.y,zoom:U.k}}function P(U,W){return y?new Promise(j=>{g?.interpolate(W?.interpolate==="linear"?$u:zh).scaleTo(Fv(y,W?.duration,W?.ease,()=>j(!0)),U)}):Promise.resolve(!1)}function z(U,W){return y?new Promise(j=>{g?.interpolate(W?.interpolate==="linear"?$u:zh).scaleBy(Fv(y,W?.duration,W?.ease,()=>j(!0)),U)}):Promise.resolve(!1)}function B(U){g?.scaleExtent(U)}function R(U){g?.translateExtent(U)}function F(U){const W=!Fr(U)||U<0?0:U;g?.clickDistance(W)}return{update:E,destroy:T,setViewport:A,setViewportConstrained:k,getViewport:N,scaleTo:P,scaleBy:z,setScaleExtent:B,setTranslateExtent:R,syncViewport:M,setClickDistance:F}}var Js;(function(e){e.Line="line",e.Handle="handle"})(Js||(Js={}));function OJ({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:a}){const s=e-t,u=n-r,c=[s>0?1:s<0?-1:0,u>0?1:u<0?-1:0];return s&&o&&(c[0]=c[0]*-1),u&&a&&(c[1]=c[1]*-1),c}function NJ(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function Di(e,t){return Math.max(0,t-e)}function Pi(e,t){return Math.max(0,e-t)}function rp(e,t,n){return Math.max(0,t-e,e-n)}function VM(e,t){return e?!t:t}function DJ(e,t,n,r,o,a,s,u){let{affectsX:c,affectsY:f}=t;const{isHorizontal:h,isVertical:p}=t,g=h&&p,{xSnapped:y,ySnapped:w}=n,{minWidth:v,maxWidth:S,minHeight:E,maxHeight:T}=r,{x:k,y:A,width:M,height:N,aspectRatio:P}=e;let z=Math.floor(h?y-e.pointerX:0),B=Math.floor(p?w-e.pointerY:0);const R=M+(c?-z:z),F=N+(f?-B:B),U=-a[0]*M,W=-a[1]*N;let j=rp(R,v,S),V=rp(F,E,T);if(s){let q=0,G=0;c&&z<0?q=Di(k+z+U,s[0][0]):!c&&z>0&&(q=Pi(k+R+U,s[1][0])),f&&B<0?G=Di(A+B+W,s[0][1]):!f&&B>0&&(G=Pi(A+F+W,s[1][1])),j=Math.max(j,q),V=Math.max(V,G)}if(u){let q=0,G=0;c&&z>0?q=Pi(k+z,u[0][0]):!c&&z<0&&(q=Di(k+R,u[1][0])),f&&B>0?G=Pi(A+B,u[0][1]):!f&&B<0&&(G=Di(A+F,u[1][1])),j=Math.max(j,q),V=Math.max(V,G)}if(o){if(h){const q=rp(R/P,E,T)*P;if(j=Math.max(j,q),s){let G=0;!c&&!f||c&&!f&&g?G=Pi(A+W+R/P,s[1][1])*P:G=Di(A+W+(c?z:-z)/P,s[0][1])*P,j=Math.max(j,G)}if(u){let G=0;!c&&!f||c&&!f&&g?G=Di(A+R/P,u[1][1])*P:G=Pi(A+(c?z:-z)/P,u[0][1])*P,j=Math.max(j,G)}}if(p){const q=rp(F*P,v,S)/P;if(V=Math.max(V,q),s){let G=0;!c&&!f||f&&!c&&g?G=Pi(k+F*P+U,s[1][0])/P:G=Di(k+(f?B:-B)*P+U,s[0][0])/P,V=Math.max(V,G)}if(u){let G=0;!c&&!f||f&&!c&&g?G=Di(k+F*P,u[1][0])/P:G=Pi(k+(f?B:-B)*P,u[0][0])/P,V=Math.max(V,G)}}}B=B+(B<0?V:-V),z=z+(z<0?j:-j),o&&(g?R>F*P?B=(VM(c,f)?-z:z)/P:z=(VM(c,f)?-B:B)*P:h?(B=z/P,f=c):(z=B*P,c=f));const I=c?k+z:k,H=f?A+B:A;return{width:M+(c?-z:z),height:N+(f?-B:B),x:a[0]*z*(c?-1:1)+I,y:a[1]*B*(f?-1:1)+H}}const UM={width:0,height:0,x:0,y:0},PJ={...UM,pointerX:0,pointerY:0,aspectRatio:1};function jJ(e){return[[0,0],[e.measured.width,e.measured.height]]}function IJ(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,a=e.measured.width??0,s=e.measured.height??0,u=n[0]*a,c=n[1]*s;return[[r-u,o-c],[r+a-u,o+s-c]]}function zJ({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const a=Zn(e);function s({controlPosition:c,boundaries:f,keepAspectRatio:h,resizeDirection:p,onResizeStart:g,onResize:y,onResizeEnd:w,shouldResize:v}){let S={...UM},E={...PJ};const T=NJ(c);let k,A=null,M=[],N,P,z;const B=TR().on("start",R=>{const{nodeLookup:F,transform:U,snapGrid:W,snapToGrid:j,nodeOrigin:V,paneDomNode:I}=n();if(k=F.get(t),!k)return;A=I?.getBoundingClientRect()??null;const{xSnapped:H,ySnapped:q}=Qu(R.sourceEvent,{transform:U,snapGrid:W,snapToGrid:j,containerBounds:A});S={width:k.measured.width??0,height:k.measured.height??0,x:k.position.x??0,y:k.position.y??0},E={...S,pointerX:H,pointerY:q,aspectRatio:S.width/S.height},N=void 0,k.parentId&&(k.extent==="parent"||k.expandParent)&&(N=F.get(k.parentId),P=N&&k.extent==="parent"?jJ(N):void 0),M=[],z=void 0;for(const[G,O]of F)if(O.parentId===t&&(M.push({id:G,position:{...O.position},extent:O.extent}),O.extent==="parent"||O.expandParent)){const Y=IJ(O,k,O.origin??V);z?z=[[Math.min(Y[0][0],z[0][0]),Math.min(Y[0][1],z[0][1])],[Math.max(Y[1][0],z[1][0]),Math.max(Y[1][1],z[1][1])]]:z=Y}g?.(R,{...S})}).on("drag",R=>{const{transform:F,snapGrid:U,snapToGrid:W,nodeOrigin:j}=n(),V=Qu(R.sourceEvent,{transform:F,snapGrid:U,snapToGrid:W,containerBounds:A}),I=[];if(!k)return;const{x:H,y:q,width:G,height:O}=S,Y={},Z=k.origin??j,{width:L,height:te,x:he,y:oe}=DJ(E,T,V,f,h,Z,P,z),de=L!==G,le=te!==O,ye=he!==H&&de,je=oe!==q&&le;if(!ye&&!je&&!de&&!le)return;if((ye||je||Z[0]===1||Z[1]===1)&&(Y.x=ye?he:S.x,Y.y=je?oe:S.y,S.x=Y.x,S.y=Y.y,M.length>0)){const _e=he-H,Xe=oe-q;for(const Ct of M)Ct.position={x:Ct.position.x-_e+Z[0]*(L-G),y:Ct.position.y-Xe+Z[1]*(te-O)},I.push(Ct)}if((de||le)&&(Y.width=de&&(!p||p==="horizontal")?L:S.width,Y.height=le&&(!p||p==="vertical")?te:S.height,S.width=Y.width,S.height=Y.height),N&&k.expandParent){const _e=Z[0]*(Y.width??0);Y.x&&Y.x<_e&&(S.x=_e,E.x=E.x-(Y.x-_e));const Xe=Z[1]*(Y.height??0);Y.y&&Y.y<Xe&&(S.y=Xe,E.y=E.y-(Y.y-Xe))}const Ne=OJ({width:S.width,prevWidth:G,height:S.height,prevHeight:O,affectsX:T.affectsX,affectsY:T.affectsY}),we={...S,direction:Ne};v?.(R,we)!==!1&&(y?.(R,we),r(Y,I))}).on("end",R=>{w?.(R,{...S}),o?.({...S})});a.call(B)}function u(){a.on(".drag",null)}return{update:s,destroy:u}}const{useDebugValue:LJ}=Qt,{useSyncExternalStoreWithSelector:FJ}=mA,$J=e=>e;function qM(e,t=$J,n){const r=FJ(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return LJ(r),r}const GM=(e,t)=>{const n=cA(e),r=(o,a=t)=>qM(n,o,a);return Object.assign(r,n),r},BJ=(e,t)=>e?GM(e,t):GM;function Tt(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,o]of e)if(!Object.is(o,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const op=_.createContext(null),HJ=op.Provider,YM=mo.error001();function Ze(e,t){const n=_.useContext(op);if(n===null)throw new Error(YM);return qM(n,e,t)}function Et(){const e=_.useContext(op);if(e===null)throw new Error(YM);return _.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const WM={display:"none"},VJ={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},XM="react-flow__node-desc",KM="react-flow__edge-desc",UJ="react-flow__aria-live",qJ=e=>e.ariaLiveMessage,GJ=e=>e.ariaLabelConfig;function YJ({rfId:e}){const t=Ze(qJ);return x.jsx("div",{id:`${UJ}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:VJ,children:t})}function WJ({rfId:e,disableKeyboardA11y:t}){const n=Ze(GJ);return x.jsxs(x.Fragment,{children:[x.jsx("div",{id:`${XM}-${e}`,style:WM,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),x.jsx("div",{id:`${KM}-${e}`,style:WM,children:n["edge.a11yDescription.default"]}),!t&&x.jsx(YJ,{rfId:e})]})}const ip=_.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},a)=>{const s=`${e}`.split("-");return x.jsx("div",{className:Vt(["react-flow__panel",n,...s]),style:r,ref:a,...o,children:t})});ip.displayName="Panel";function XJ({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:x.jsx(ip,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:x.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const KJ=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},ap=e=>e.id;function ZJ(e,t){return Tt(e.selectedNodes.map(ap),t.selectedNodes.map(ap))&&Tt(e.selectedEdges.map(ap),t.selectedEdges.map(ap))}function QJ({onSelectionChange:e}){const t=Et(),{selectedNodes:n,selectedEdges:r}=Ze(KJ,ZJ);return _.useEffect(()=>{const o={nodes:n,edges:r};e?.(o),t.getState().onSelectionChangeHandlers.forEach(a=>a(o))},[n,r,e]),null}const JJ=e=>!!e.onSelectionChangeHandlers;function eee({onSelectionChange:e}){const t=Ze(JJ);return e||t?x.jsx(QJ,{onSelectionChange:e}):null}const ZM=[0,0],tee={x:0,y:0,zoom:1},QM=[...["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","paneClickDistance","ariaLabelConfig"],"rfId"],nee=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setPaneClickDistance:e.setPaneClickDistance}),JM={translateExtent:Gu,nodeOrigin:ZM,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1",paneClickDistance:0};function ree(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:a,setNodeExtent:s,reset:u,setDefaultNodesAndEdges:c,setPaneClickDistance:f}=Ze(nee,Tt),h=Et();_.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{p.current=JM,u()}),[]);const p=_.useRef(JM);return _.useEffect(()=>{for(const g of QM){const y=e[g],w=p.current[g];y!==w&&(typeof e[g]>"u"||(g==="nodes"?t(y):g==="edges"?n(y):g==="minZoom"?r(y):g==="maxZoom"?o(y):g==="translateExtent"?a(y):g==="nodeExtent"?s(y):g==="paneClickDistance"?f(y):g==="ariaLabelConfig"?h.setState({ariaLabelConfig:KQ(y)}):g==="fitView"?h.setState({fitViewQueued:y}):g==="fitViewOptions"?h.setState({fitViewOptions:y}):h.setState({[g]:y})))}p.current=e},QM.map(g=>e[g])),null}function eO(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function oee(e){const[t,n]=_.useState(e==="system"?null:e);return _.useEffect(()=>{if(e!=="system"){n(e);return}const r=eO(),o=()=>n(r?.matches?"dark":"light");return o(),r?.addEventListener("change",o),()=>{r?.removeEventListener("change",o)}},[e]),t!==null?t:eO()?.matches?"dark":"light"}const tO=typeof document<"u"?document:null;function Xo(e=null,t={target:tO,actInsideInputWithModifier:!0}){const[n,r]=_.useState(!1),o=_.useRef(!1),a=_.useRef(new Set([])),[s,u]=_.useMemo(()=>{if(e!==null){const f=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",`
788
788
  `).replace(`
789
789
 
790
790
  `,`
@@ -822,9 +822,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
822
822
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:s,tableCell:c,tableRow:u}};function s(y,w,v,S){return f(h(y,v,S),y.align)}function u(y,w,v,S){const E=p(y,v,S),T=f([E]);return T.slice(0,T.indexOf(`
823
823
  `))}function c(y,w,v,S){const E=v.enter("tableCell"),T=v.enter("phrasing"),k=v.containerPhrasing(y,{...S,before:a,after:a});return T(),E(),k}function f(y,w){return mce(y,{align:w,alignDelimiters:r,padding:n,stringLength:o})}function h(y,w,v){const S=y.children;let E=-1;const T=[],k=w.enter("table");for(;++E<S.length;)T[E]=p(S[E],w,v);return k(),T}function p(y,w,v){const S=y.children;let E=-1;const T=[],k=w.enter("tableRow");for(;++E<S.length;)T[E]=c(S[E],y,w,v);return k(),T}function g(y,w,v){let S=m5.inlineCode(y,w,v);return v.stack.includes("tableCell")&&(S=S.replace(/\|/g,"\\$&")),S}}function nfe(){return{exit:{taskListCheckValueChecked:y5,taskListCheckValueUnchecked:y5,paragraph:ofe}}}function rfe(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:ife}}}function y5(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function ofe(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,s;for(;++a<o.length;){const u=o[a];if(u.type==="paragraph"){s=u;break}}s===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 ife(e,t,n,r){const o=e.children[0],a=typeof e.checked=="boolean"&&o&&o.type==="paragraph",s="["+(e.checked?"x":" ")+"] ",u=n.createTracker(r);a&&u.move(s);let c=m5.listItem(e,t,n,{...r,...u.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),c;function f(h){return h+s}}function afe(){return[Lue(),ice(),uce(),Xce(),nfe()]}function sfe(e){return{extensions:[Fue(),ace(e),cce(),tfe(e),rfe()]}}const lfe={tokenize:pfe,partial:!0},v5={tokenize:mfe,partial:!0},b5={tokenize:gfe,partial:!0},x5={tokenize:yfe,partial:!0},ufe={tokenize:vfe,partial:!0},w5={name:"wwwAutolink",tokenize:dfe,previous:S5},_5={name:"protocolAutolink",tokenize:hfe,previous:E5},Qo={name:"emailAutolink",tokenize:ffe,previous:C5},bo={};function cfe(){return{text:bo}}let Ba=48;for(;Ba<123;)bo[Ba]=Qo,Ba++,Ba===58?Ba=65:Ba===91&&(Ba=97);bo[43]=Qo,bo[45]=Qo,bo[46]=Qo,bo[95]=Qo,bo[72]=[Qo,_5],bo[104]=[Qo,_5],bo[87]=[Qo,w5],bo[119]=[Qo,w5];function ffe(e,t,n){const r=this;let o,a;return s;function s(p){return!p1(p)||!C5.call(r,r.previous)||m1(r.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),u(p))}function u(p){return p1(p)?(e.consume(p),u):p===64?(e.consume(p),c):n(p)}function c(p){return p===46?e.check(ufe,h,f)(p):p===45||p===95||gn(p)?(a=!0,e.consume(p),c):h(p)}function f(p){return e.consume(p),o=!0,c}function h(p){return a&&o&&Cn(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function dfe(e,t,n){const r=this;return o;function o(s){return s!==87&&s!==119||!S5.call(r,r.previous)||m1(r.events)?n(s):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(lfe,e.attempt(v5,e.attempt(b5,a),n),n)(s))}function a(s){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(s)}}function hfe(e,t,n){const r=this;let o="",a=!1;return s;function s(p){return(p===72||p===104)&&E5.call(r,r.previous)&&!m1(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),o+=String.fromCodePoint(p),e.consume(p),u):n(p)}function u(p){if(Cn(p)&&o.length<5)return o+=String.fromCodePoint(p),e.consume(p),u;if(p===58){const g=o.toLowerCase();if(g==="http"||g==="https")return e.consume(p),c}return n(p)}function c(p){return p===47?(e.consume(p),a?f:(a=!0,c)):n(p)}function f(p){return p===null||Cp(p)||vt(p)||$a(p)||kp(p)?n(p):e.attempt(v5,e.attempt(b5,h),n)(p)}function h(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function pfe(e,t,n){let r=0;return o;function o(s){return(s===87||s===119)&&r<3?(r++,e.consume(s),o):s===46&&r===3?(e.consume(s),a):n(s)}function a(s){return s===null?n(s):t(s)}}function mfe(e,t,n){let r,o,a;return s;function s(f){return f===46||f===95?e.check(x5,c,u)(f):f===null||vt(f)||$a(f)||f!==45&&kp(f)?c(f):(a=!0,e.consume(f),s)}function u(f){return f===95?r=!0:(o=r,r=void 0),e.consume(f),s}function c(f){return o||r||!a?n(f):t(f)}}function gfe(e,t){let n=0,r=0;return o;function o(s){return s===40?(n++,e.consume(s),o):s===41&&r<n?a(s):s===33||s===34||s===38||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===60||s===63||s===93||s===95||s===126?e.check(x5,t,a)(s):s===null||vt(s)||$a(s)?t(s):(e.consume(s),o)}function a(s){return s===41&&r++,e.consume(s),o}}function yfe(e,t,n){return r;function r(u){return u===33||u===34||u===39||u===41||u===42||u===44||u===46||u===58||u===59||u===63||u===95||u===126?(e.consume(u),r):u===38?(e.consume(u),a):u===93?(e.consume(u),o):u===60||u===null||vt(u)||$a(u)?t(u):n(u)}function o(u){return u===null||u===40||u===91||vt(u)||$a(u)?t(u):r(u)}function a(u){return Cn(u)?s(u):n(u)}function s(u){return u===59?(e.consume(u),r):Cn(u)?(e.consume(u),s):n(u)}}function vfe(e,t,n){return r;function r(a){return e.consume(a),o}function o(a){return gn(a)?n(a):t(a)}}function S5(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||vt(e)}function E5(e){return!Cn(e)}function C5(e){return!(e===47||p1(e))}function p1(e){return e===43||e===45||e===46||e===95||gn(e)}function m1(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 bfe={tokenize:Tfe,partial:!0};function xfe(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Efe,continuation:{tokenize:Cfe},exit:kfe}},text:{91:{name:"gfmFootnoteCall",tokenize:Sfe},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:wfe,resolveTo:_fe}}}}function wfe(e,t,n){const r=this;let o=r.events.length;const a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s;for(;o--;){const c=r.events[o][1];if(c.type==="labelImage"){s=c;break}if(c.type==="gfmFootnoteCall"||c.type==="labelLink"||c.type==="label"||c.type==="image"||c.type==="link")break}return u;function u(c){if(!s||!s._balanced)return n(c);const f=$r(r.sliceSerialize({start:s.end,end:r.now()}));return f.codePointAt(0)!==94||!a.includes(f.slice(1))?n(c):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(c),e.exit("gfmFootnoteCallLabelMarker"),t(c))}}function _fe(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)},s={type:"chunkString",contentType:"string",start:Object.assign({},a.start),end:Object.assign({},a.end)},u=[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",s,t],["exit",s,t],["exit",a,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...u),e}function Sfe(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a=0,s;return u;function u(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),c}function c(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(p){if(a>999||p===93&&!s||p===null||p===91||vt(p))return n(p);if(p===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return o.includes($r(r.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return vt(p)||(s=!0),a++,e.consume(p),p===92?h:f}function h(p){return p===91||p===92||p===93?(e.consume(p),a++,f):f(p)}}function Efe(e,t,n){const r=this,o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let a,s=0,u;return c;function c(w){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),f}function f(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",h):n(w)}function h(w){if(s>999||w===93&&!u||w===null||w===91||vt(w))return n(w);if(w===93){e.exit("chunkString");const v=e.exit("gfmFootnoteDefinitionLabelString");return a=$r(r.sliceSerialize(v)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return vt(w)||(u=!0),s++,e.consume(w),w===92?p:h}function p(w){return w===91||w===92||w===93?(e.consume(w),s++,h):h(w)}function g(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),o.includes(a)||o.push(a),Qe(e,y,"gfmFootnoteDefinitionWhitespace")):n(w)}function y(w){return t(w)}}function Cfe(e,t,n){return e.check(yc,t,e.attempt(bfe,t,n))}function kfe(e){e.exit("gfmFootnoteDefinition")}function Tfe(e,t,n){const r=this;return Qe(e,o,"gfmFootnoteDefinitionIndent",5);function o(a){const s=r.events[r.events.length-1];return s&&s[1].type==="gfmFootnoteDefinitionIndent"&&s[2].sliceSerialize(s[1],!0).length===4?t(a):n(a)}}function Afe(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(s,u){let c=-1;for(;++c<s.length;)if(s[c][0]==="enter"&&s[c][1].type==="strikethroughSequenceTemporary"&&s[c][1]._close){let f=c;for(;f--;)if(s[f][0]==="exit"&&s[f][1].type==="strikethroughSequenceTemporary"&&s[f][1]._open&&s[c][1].end.offset-s[c][1].start.offset===s[f][1].end.offset-s[f][1].start.offset){s[c][1].type="strikethroughSequence",s[f][1].type="strikethroughSequence";const h={type:"strikethrough",start:Object.assign({},s[f][1].start),end:Object.assign({},s[c][1].end)},p={type:"strikethroughText",start:Object.assign({},s[f][1].end),end:Object.assign({},s[c][1].start)},g=[["enter",h,u],["enter",s[f][1],u],["exit",s[f][1],u],["enter",p,u]],y=u.parser.constructs.insideSpan.null;y&&er(g,g.length,0,Tp(y,s.slice(f+1,c),u)),er(g,g.length,0,[["exit",p,u],["enter",s[c][1],u],["exit",s[c][1],u],["exit",h,u]]),er(s,f-1,c-f+3,g),c=f+g.length-2;break}}for(c=-1;++c<s.length;)s[c][1].type==="strikethroughSequenceTemporary"&&(s[c][1].type="data");return s}function a(s,u,c){const f=this.previous,h=this.events;let p=0;return g;function g(w){return f===126&&h[h.length-1][1].type!=="characterEscape"?c(w):(s.enter("strikethroughSequenceTemporary"),y(w))}function y(w){const v=ll(f);if(w===126)return p>1?c(w):(s.consume(w),p++,y);if(p<2&&!n)return c(w);const S=s.exit("strikethroughSequenceTemporary"),E=ll(w);return S._open=!E||E===2&&!!v,S._close=!v||v===2&&!!E,u(w)}}}class Rfe{constructor(){this.map=[]}add(t,n,r){Mfe(this,t,n,r)}consume(t){if(this.map.sort(function(a,s){return a[0]-s[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 Mfe(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 Ofe(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 Nfe(){return{flow:{null:{name:"table",tokenize:Dfe,resolveAll:Pfe}}}}function Dfe(e,t,n){const r=this;let o=0,a=0,s;return u;function u(R){let F=r.events.length-1;for(;F>-1;){const j=r.events[F][1].type;if(j==="lineEnding"||j==="linePrefix")F--;else break}const U=F>-1?r.events[F][1].type:null,W=U==="tableHead"||U==="tableRow"?N:c;return W===N&&r.parser.lazy[r.now().line]?n(R):W(R)}function c(R){return e.enter("tableHead"),e.enter("tableRow"),f(R)}function f(R){return R===124||(s=!0,a+=1),h(R)}function h(R){return R===null?n(R):Oe(R)?a>1?(a=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),y):n(R):Ge(R)?Qe(e,h,"whitespace")(R):(a+=1,s&&(s=!1,o+=1),R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),s=!0,h):(e.enter("data"),p(R)))}function p(R){return R===null||R===124||vt(R)?(e.exit("data"),h(R)):(e.consume(R),R===92?g:p)}function g(R){return R===92||R===124?(e.consume(R),p):p(R)}function y(R){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(R):(e.enter("tableDelimiterRow"),s=!1,Ge(R)?Qe(e,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):w(R))}function w(R){return R===45||R===58?S(R):R===124?(s=!0,e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),v):M(R)}function v(R){return Ge(R)?Qe(e,S,"whitespace")(R):S(R)}function S(R){return R===58?(a+=1,s=!0,e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),E):R===45?(a+=1,E(R)):R===null||Oe(R)?A(R):M(R)}function E(R){return R===45?(e.enter("tableDelimiterFiller"),T(R)):M(R)}function T(R){return R===45?(e.consume(R),T):R===58?(s=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),k):(e.exit("tableDelimiterFiller"),k(R))}function k(R){return Ge(R)?Qe(e,A,"whitespace")(R):A(R)}function A(R){return R===124?w(R):R===null||Oe(R)?!s||o!==a?M(R):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(R)):M(R)}function M(R){return n(R)}function N(R){return e.enter("tableRow"),P(R)}function P(R){return R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),P):R===null||Oe(R)?(e.exit("tableRow"),t(R)):Ge(R)?Qe(e,P,"whitespace")(R):(e.enter("data"),z(R))}function z(R){return R===null||R===124||vt(R)?(e.exit("data"),P(R)):(e.consume(R),R===92?B:z)}function B(R){return R===92||R===124?(e.consume(R),z):z(R)}}function Pfe(e,t){let n=-1,r=!0,o=0,a=[0,0,0,0],s=[0,0,0,0],u=!1,c=0,f,h,p;const g=new Rfe;for(;++n<e.length;){const y=e[n],w=y[1];y[0]==="enter"?w.type==="tableHead"?(u=!1,c!==0&&(k5(g,t,c,f,h),h=void 0,c=0),f={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(n,0,[["enter",f,t]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(r=!0,p=void 0,a=[0,0,0,0],s=[0,n+1,0,0],u&&(u=!1,h={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(n,0,[["enter",h,t]])),o=w.type==="tableDelimiterRow"?2:h?3:1):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(r=!1,s[2]===0&&(a[1]!==0&&(s[0]=s[1],p=Lp(g,t,a,o,void 0,p),a=[0,0,0,0]),s[2]=n)):w.type==="tableCellDivider"&&(r?r=!1:(a[1]!==0&&(s[0]=s[1],p=Lp(g,t,a,o,void 0,p)),a=s,s=[a[1],n,0,0])):w.type==="tableHead"?(u=!0,c=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(c=n,a[1]!==0?(s[0]=s[1],p=Lp(g,t,a,o,n,p)):s[1]!==0&&(p=Lp(g,t,s,o,n,p)),o=0):o&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(s[3]=n)}for(c!==0&&k5(g,t,c,f,h),g.consume(t.events),n=-1;++n<t.events.length;){const y=t.events[n];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=Ofe(t.events,n))}return e}function Lp(e,t,n,r,o,a){const s=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",u="tableContent";n[0]!==0&&(a.end=Object.assign({},cl(t.events,n[0])),e.add(n[0],0,[["exit",a,t]]));const c=cl(t.events,n[1]);if(a={type:s,start:Object.assign({},c),end:Object.assign({},c)},e.add(n[1],0,[["enter",a,t]]),n[2]!==0){const f=cl(t.events,n[2]),h=cl(t.events,n[3]),p={type:u,start:Object.assign({},f),end:Object.assign({},h)};if(e.add(n[2],0,[["enter",p,t]]),r!==2){const g=t.events[n[2]],y=t.events[n[3]];if(g[1].end=Object.assign({},y[1].end),g[1].type="chunkText",g[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,v=n[3]-n[2]-1;e.add(w,v,[])}}e.add(n[3]+1,0,[["exit",p,t]])}return o!==void 0&&(a.end=Object.assign({},cl(t.events,o)),e.add(o,0,[["exit",a,t]]),a=void 0),a}function k5(e,t,n,r,o){const a=[],s=cl(t.events,n);o&&(o.end=Object.assign({},s),a.push(["exit",o,t])),r.end=Object.assign({},s),a.push(["exit",r,t]),e.add(n+1,0,a)}function cl(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const jfe={name:"tasklistCheck",tokenize:zfe};function Ife(){return{text:{91:jfe}}}function zfe(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 vt(c)?(e.enter("taskListCheckValueUnchecked"),e.consume(c),e.exit("taskListCheckValueUnchecked"),s):c===88||c===120?(e.enter("taskListCheckValueChecked"),e.consume(c),e.exit("taskListCheckValueChecked"),s):n(c)}function s(c){return c===93?(e.enter("taskListCheckMarker"),e.consume(c),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),u):n(c)}function u(c){return Oe(c)?t(c):Ge(c)?e.check({tokenize:Lfe},t,n)(c):n(c)}}function Lfe(e,t,n){return Qe(e,r,"whitespace");function r(o){return o===null?n(o):t(o)}}function Ffe(e){return s3([cfe(),xfe(),Afe(e),Nfe(),Ife()])}const $fe={};function Bfe(e){const t=this,n=e||$fe,r=t.data(),o=r.micromarkExtensions||(r.micromarkExtensions=[]),a=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),s=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);o.push(Ffe(n)),a.push(afe()),s.push(sfe(n))}const g1=({availableModule:e})=>{const[t,n]=_.useState(!1),r=()=>n(!t),o=150,a=e.description.length>o?e.description.substring(0,o)+"...":e.description;return x.jsxs("div",{className:"module-description",children:[x.jsx(Aue,{remarkPlugins:[Bfe],children:t?e.description.replace(/\\n/g,`
824
824
  `):a.replace(/\\n/g,`
825
- `)}),e.description.length>o&&x.jsx("button",{onClick:r,className:"toggle-description",children:t?"Show less":"Show more"})]})},T5=[">=","==","<=","<",">"],Fp=">=",y1=({availableModule:e,on_change:t})=>{const[n,r]=_.useState(e.version||"latest"),[o,a]=_.useState(Fp),s=c=>{const f=c.target.value;r(f),t(f!=="latest"?o+f:f)},u=c=>{c.target.value!==o&&T5.includes(c.target.value)&&(a(c.target.value),n!=="latest"&&t(c.target.value+n))};return e.releases&&!e.releases.includes(n)&&e.releases.unshift(n),x.jsxs(x.Fragment,{children:[x.jsx("select",{value:o,onChange:u,children:T5.map(c=>x.jsx("option",{value:c,children:c},c))}),x.jsx("select",{onChange:s,value:n,children:e.releases&&e.releases.map(c=>x.jsx("option",{value:c,children:c},c))})]})},Hfe=({availableModule:e,on_remove:t,on_update:n})=>{const[r,o]=_.useState(Fp+e.version||"latest");return x.jsxs("div",{className:"addable-module",children:[x.jsx("div",{className:"module-name",children:e.name+(e.version?` (${e.version})`:"")}),x.jsx(Sb,{availableModule:e}),x.jsx(g1,{availableModule:e}),x.jsxs("div",{children:[x.jsx(y1,{availableModule:e,on_change:o}),x.jsx("button",{className:"update-button",disabled:r===e.version,onClick:()=>{n(e,r)},children:"Update"}),x.jsx("button",{className:"remove-button",onClick:()=>{t(e)},children:"Remove"})]})]})},Vfe=({availableModule:e,on_add:t})=>{const[n,r]=_.useState(Fp+e.version||"latest");return x.jsxs("div",{className:"addable-module",children:[x.jsx("div",{className:"module-name",children:e.name+(e.version?` (${e.version})`:"")}),x.jsx(Sb,{availableModule:e}),x.jsx(g1,{availableModule:e}),x.jsxs("div",{children:[x.jsx(y1,{availableModule:e,on_change:r}),x.jsx("button",{className:"add-button",onClick:()=>{t(e,n)},children:"Add"})]})]})},Ufe=({availableModule:e,on_add:t})=>{const[n,r]=_.useState(Fp+e.version||"latest");return x.jsxs("div",{className:"addable-module",children:[x.jsx("div",{className:"module-name",children:e.name}),x.jsx(Sb,{availableModule:e}),x.jsx(g1,{availableModule:e}),x.jsxs("div",{children:[x.jsx(y1,{availableModule:e,on_change:r}),x.jsx("button",{className:"add-button",onClick:()=>{t(e,n)},children:"Add"})]})]})},qfe=({ins:e})=>{const[t,n]=_.useState(e.name),r=tt(),{lib:o}=_n(),a=()=>{r.worker&&o?.remove_external_worker(e.uuid,e.nodeclassid)},s=()=>{r.worker&&(r.worker.update_external_worker(e.uuid,e.nodeclassid,{name:t}),e.name=t)};return x.jsx(x.Fragment,{children:x.jsx(Lo,{title:e.name,description:"Settings for"+e.name,trigger:x.jsx("div",{children:"Settings"}),buttons:[{text:"Save",onClick:s,close:!0},{text:"Delete",onClick:a,close:!0}],children:x.jsx("div",{children:x.jsxs("div",{children:[x.jsx("label",{htmlFor:"name",children:"Name: "}),x.jsx("input",{type:"text",name:"name",value:t,onChange:u=>n(u.target.value),className:"styledinput"})]})})})})},Gfe=({ins:e,lib:t,filter:n="",parentkey:r})=>{const[o,a]=_.useState(!1),s=()=>a(!o),u=t?.nodes?.filter(c=>c.node_id.toLowerCase().includes(n.toLowerCase()));return x.jsxs("div",{className:"shelfcontainer",children:[x.jsxs("div",{className:"shelftitle",onClick:s,style:{cursor:"pointer"},title:e.name,children:[x.jsx("div",{className:"shelftitle_text",children:e.name}),x.jsx("div",{className:"expandicon "+(o?"open":"close"),children:x.jsx(xu,{})})]}),x.jsx("div",{className:"libnodecontainer "+(o?"open":"close"),children:x.jsx("div",{className:"libnodecontainer_inner",children:o&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"libnodeentry",title:e.uuid,children:x.jsx(qfe,{ins:e})}),t&&x.jsxs(x.Fragment,{children:[u&&x.jsx(x.Fragment,{children:u.map(c=>x.jsx(N2,{item:c},r+c.node_id))}),t.subshelves.map(c=>x.jsx(_b,{item:c,filter:n,parentkey:r+c.name},r+c.name))]})]})})})]})},Yfe=({item:e,mod:t,lib:n})=>{const{lib:r}=_n(),[o,a]=_.useState(!1),s=()=>a(!o),u=_.useCallback(()=>{r?.add_external_worker({module:t,cls_module:e.module,cls_name:e.class_name})},[r,t,e]),c=h=>{h.detail===2&&u()},f=e.name||e.module+"."+e.class_name;return x.jsxs("div",{className:"shelfcontainer",children:[x.jsxs("div",{className:"shelftitle",onClick:s,style:{cursor:"pointer"},title:f,children:[x.jsx("div",{className:"shelftitle_text",children:f}),x.jsx("div",{className:"expandicon "+(o?"open":"close"),children:x.jsx(xu,{})})]}),x.jsx("div",{className:"libnodecontainer "+(o?"open":"close"),children:x.jsx("div",{className:"libnodecontainer_inner",children:o&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"libnodeentry",onClick:c,title:e.name,children:"New Instance"}),e.instances.map(h=>x.jsx(Gfe,{ins:h,lib:n?.subshelves.find(p=>p.name===h.uuid),parentkey:h.uuid},h.uuid))]})})})]})},Wfe=({externalworkermod:e,lib:t})=>{const[n,r]=_.useState(!1),o=()=>r(!n),a=n;return x.jsxs("div",{className:"shelfcontainer",children:[x.jsxs("div",{className:"shelftitle",onClick:o,style:{cursor:"pointer"},title:e.module,children:[x.jsx("div",{className:"shelftitle_text",children:e.module}),x.jsx("div",{className:"expandicon "+(a?"open":"close"),children:x.jsx(xu,{})})]}),x.jsx("div",{className:"libnodecontainer "+(a?"open":"close"),children:x.jsx("div",{className:"libnodecontainer_inner",children:e.worker_classes.map(s=>x.jsx(Yfe,{item:s,mod:e.module,lib:t},s.module+s.class_name))})}),x.jsx("hr",{})]})},Xfe=()=>{const e=tt(),t=e.lib.libstate(),n=tt(),r=n.local_settings(f=>f.view_settings.expand_lib),o=f=>{n.update_view_settings({expand_lib:f})},a=rre("m"),[s,u]=_.useState(""),c=e.worker?.state(f=>f.is_open)??!1;return x.jsx(tb,{maxSize:a?"100%":"18.75rem",direction:a?"down":"right",containerClassName:"pos-left pos-top bg1 h-12",onExpandChange:o,expanded:r===void 0?!0:r,collapseIcons:{up:Fd,down:bu,left:vu,right:Ld},expandIcons:{up:bu,down:Fd,left:Ld,right:vu},children:x.jsxs("div",{className:"libcontainer",children:[x.jsxs("div",{className:"library",children:[x.jsx("div",{className:"libtitle",children:"Lib"}),x.jsx("hr",{className:"hr_prominent"}),x.jsx(Cie,{filter:s,setFilter:u}),x.jsx("div",{className:"vscrollcontainer",children:t.lib.shelves.filter(f=>f.name!=="_external_worker").map(f=>x.jsx(_b,{item:f,filter:s,parentkey:f.name},f.name))}),x.jsx("hr",{}),x.jsx("div",{className:"libtitle",children:"External Worker"}),x.jsx("hr",{className:"hr_prominent"}),x.jsx("div",{className:"vscrollcontainer",children:t.external_worker?.map(f=>x.jsx(Wfe,{externalworkermod:f,lib:t.lib.shelves.find(h=>h.name==="_external_worker")},f.module))}),x.jsx("hr",{})]}),c&&x.jsx("div",{className:"addlib",children:x.jsx(kie,{children:x.jsx("button",{children:"Manage Libraries"})})})]})})},Kfe=({fnrf_zst:e,header:t,flow:n,library:r})=>{const[o,a]=_.useState(e.options.worker),s=_.useRef(null);e.workermanager&&(e.workermanager.on_setWorker=a),e.set_worker(o),_.useEffect(()=>{e.auto_progress()},[]),_.useEffect(()=>{e.local_state.setState({funcnodescontainerRef:s.current})},[s]);const u=e.plugins();return x.jsx(Hne,{plugins:u,fnrf_zst:e,children:x.jsx(NB,{children:x.jsx(FC.Provider,{value:e,children:x.jsx(bi,{asChild:!0,children:x.jsx(Ao,{asChild:!0,children:x.jsx(EN,{style:{height:"100%",width:"100%",display:"flex",flexDirection:"column",flex:1},children:x.jsxs("div",{ref:s,className:"funcnodesreactflowcontainer funcnodescontainer",children:[t.show&&x.jsx(Eie,{...t}),x.jsxs("div",{className:"funcnodesreactflowbody",children:[x.jsx(noe,{...n}),o&&r.show&&x.jsx(Xfe,{}),o&&n.showNodeSettings&&x.jsx(lre,{})]}),x.jsxs("div",{className:"funcnodesflaotingmenu",children:[x.jsx(Ao.OutFullScreen,{children:n.allowExpand&&x.jsxs(bi.Trigger,{children:[x.jsx(bi.Expanded,{children:x.jsx(_B,{size:"xl",style:{padding:"4px"}})}),x.jsx(bi.Collapsed,{children:x.jsx(SB,{size:"xl",style:{padding:"4px"}})})]})}),n.allowFullScreen&&x.jsxs(Ao.Trigger,{children:[x.jsx(Ao.OutFullScreen,{children:x.jsx(LC,{size:"xl",style:{padding:"4px"}})}),x.jsx(Ao.InFullScreen,{children:x.jsx(wB,{size:"xl",style:{padding:"4px"}})})]})]})]})})})})})})})};class fl{constructor(t){this.context=t}get nodespaceManager(){return this.context.rf.getNodespaceManager()}get libManager(){return this.context.rf.getLibManager()}get workerManager(){return this.context.rf.getWorkerManager()}get stateManager(){return this.context.rf.getStateManager()}get pluginManager(){return this.context.rf.getPluginManager()}get reactFlowManager(){return this.context.rf.getReactFlowManager()}}const A5=({src_nid:e,src_ioid:t,trg_nid:n,trg_ioid:r})=>[`${e}:${t}`,`${n}:${r}`].sort().join("--"),Zfe=({})=>{const e=new Map;return{nodesstates:e,get_node:(t,n=!0)=>{const r=e.get(t);if(!r&&n){const o=e.keys();throw new Error(`Node ${t} not found, available nodes: ${Array.from(o)}`)}return r}}};class Qfe extends fl{constructor(t){super(t),this.on_node_action=n=>{switch(n.type){case"add":return this._add_node(n);case"update":return this._update_node(n);case"delete":return this._delete_node(n);case"error":return this._error_action(n);case"trigger":return this._trigger_action(n);default:this.context.rf.logger.error("Unknown node action",n);return}},this.on_edge_action=n=>{const r=this.reactFlowManager.useReactFlowStore.getState();switch(n.type){case"add":if(n.from_remote){const o=r.getEdges(),a=A5(n);if(o.some(u=>u.id===a))return;const s={id:a,source:n.src_nid,target:n.trg_nid,sourceHandle:n.src_ioid,targetHandle:n.trg_ioid,className:"funcnodes-edge animated",zIndex:1003};this.context.rf.logger.info("Adding edge",s),r.update_edges([...o,s]),this.workerManager.worker?.api.node.get_remote_node_state(n.src_nid),this.workerManager.worker?.api.node.get_remote_node_state(n.trg_nid)}break;case"delete":if(n.from_remote){const o=r.getEdges(),a=A5(n);this.context.rf.logger.info("Deleting edge",a);const s=o.filter(u=>u.id!==a);r.update_edges(s),this.workerManager.worker?.api.node.get_remote_node_state(n.src_nid),this.workerManager.worker?.api.node.get_remote_node_state(n.trg_nid)}break;default:this.context.rf.logger.error("Unknown edge action",n)}},this.on_group_action=n=>{switch(n.type){case"set":return this._set_groups(n.groups);case"update":return this._update_group(n);default:this.context.rf.logger.error("Unknown group action",n)}},this.clear_all=()=>{this.workerManager.worker?.disconnect(),this.workerManager.set_worker(void 0),this.workerManager.workermanager?.setWorker(void 0),this.libManager.lib.libstate.getState().set({lib:{shelves:[]},external_worker:[]}),this.nodespace.nodesstates.clear(),this.reactFlowManager.useReactFlowStore.getState().update_nodes([]),this.reactFlowManager.useReactFlowStore.getState().update_edges([]),this.stateManager.auto_progress()},this.center_node=n=>{if(!this.reactFlowManager.rf_instance)return;n=Array.isArray(n)?n:[n];const r=this.reactFlowManager.useReactFlowStore.getState().getNodes().filter(o=>n.includes(o.id));r.length>0&&this.reactFlowManager.rf_instance?.fitView({padding:.2,nodes:r})},this.auto_resize_group=n=>{const r=this.reactFlowManager.useReactFlowStore.getState(),o=r.getNode(n);if(o===void 0||o.type!=="group")return;const a=o.data.group.node_ids.map(h=>r.getNode(h)).filter(h=>h!==void 0),s=o.data.group.child_groups.map(h=>r.getNode(h)).filter(h=>h!==void 0),u=[...a,...s],c=this.reactFlowManager.rf_instance?.getNodesBounds(u);if(c===void 0)return;const f={...o,position:{x:c.x,y:c.y},height:c.height,width:c.width};f.data.group.position=[c.x,c.y],r.partial_update_nodes([f])},this.change_group_position=n=>{if(n.position===void 0)return;const r=this.reactFlowManager.useReactFlowStore.getState(),o=r.getNode(n.id);if(o===void 0||o.type!=="group")return;const a=[...o.data.group.node_ids,...o.data.group.child_groups],s=this.reactFlowManager.rf_instance?.getNodesBounds(a);if(s===void 0)return;const u=n.position.x-s?.x,c=n.position.y-s?.y,f=[];for(const h of a){const p=r.getNode(h);p!==void 0&&f.push({id:h,type:"position",position:{x:p.position.x+u,y:p.position.y+c}})}r.onNodesChange(f)},this.change_fn_node_position=n=>{n.position!==void 0&&this.on_node_action({type:"update",id:n.id,node:{properties:{"frontend:pos":[n.position.x,n.position.y]}},from_remote:!1})},this.change_group_dimensions=n=>{if(n.dimensions===void 0)return;const o=this.reactFlowManager.useReactFlowStore.getState().getNode(n.id);o!==void 0&&this.reactFlowManager.useReactFlowStore.getState().partial_update_nodes($v([n],[o]))},this.change_fn_node_dimensions=n=>{n.dimensions!==void 0&&this.on_node_action({type:"update",id:n.id,node:{properties:{"frontend:size":[n.dimensions.width,n.dimensions.height]}},from_remote:!1})},this._update_group=n=>{if(n.from_remote){const r=this.reactFlowManager.useReactFlowStore.getState(),o=r.getNode(n.id);if(o===void 0||o.type!=="group")return;const{new_obj:a,change:s}=ha(o.data.group,n.group);s&&(o.data.group=a),r.partial_update_nodes([o])}else this.workerManager.worker&&this.workerManager.worker.api.group.locally_update_group(n)},this._set_groups=n=>{const r=this.reactFlowManager.useReactFlowStore.getState(),{default_nodes:o}=lb(r.getNodes()),a=[...o],s={};for(const c in n){const f=n[c];for(const p of f.node_ids)s[p]=c;for(const p of f.child_groups)s[p]=c;f.position===void 0&&(f.position=[0,0]);const h={id:c,type:"group",data:{group:n[c],id:c},position:{x:f.position[0],y:f.position[1]},zIndex:2};f.parent_group&&(h.data.groupID=f.parent_group),a.push(h)}for(const c of a)c.id in s?c.data.groupID=s[c.id]:c.data.groupID=void 0;const u=ub(a);r.update_nodes(u);for(const c of u.reverse())c.type==="group"&&this.auto_resize_group(c.id)},this._add_node=n=>{this.context.rf.logger.info("add node",n);const r=this.reactFlowManager.useReactFlowStore.getState();if(n.from_remote){let o=this.nodespace.get_node(n.node.id,!1);if(o)return;if(!o)try{o=Wre(n.node),this.nodespace.nodesstates.set(n.node.id,o)}catch(c){this.context.rf.logger.error(`Failed to create node store ${c}`);return}const a=o.getState();this.context.rf.logger.info("Add node",a.id,a.name);const s=toe(o,this.context.rf),u=[...r.getNodes(),s];this.reactFlowManager.useReactFlowStore.getState().update_nodes(u);for(const c of s.io_order)this.workerManager.worker?.api.node.get_io_value({nid:s.id,ioid:c});return setTimeout(()=>{this.workerManager.worker?.api.hooks.call_hooks("node_added",{node:a.id})},0),a}},this._update_node=n=>{if(Object.keys(n.node).length===0){this.context.rf.logger.error("Node update is empty",new Error(JSON.stringify(n)));return}if(n.node.in_trigger&&(n.node.error=void 0),n.from_remote){const r=this.nodespace.get_node(n.id,!1);if(!r){console.error("Node not found to update",n.id);return}return r.update(n.node),r.getState()}else this.workerManager.worker&&this.workerManager.worker.api.node.locally_update_node(n)},this._delete_node=n=>{this.context.rf.logger.info("Deleting node",n.id),n.from_remote?this.reactFlowManager.useReactFlowStore.getState().onNodesChange([{type:"remove",id:n.id}]):this.workerManager.worker?.api.node.remove_node(n.id)},this._error_action=n=>(this.context.rf.logger.error("Error",new Error(JSON.stringify(n))),this.on_node_action({type:"update",id:n.id,node:{in_trigger:!1,error:n.error},from_remote:!0})),this._trigger_action=n=>{if(n.from_remote)return this.on_node_action({type:"update",id:n.id,node:{in_trigger:!0,error:void 0},from_remote:!0});this.workerManager.worker?.api.node.trigger_node(n.id)},this.nodespace=Zfe({})}center_all(){this.reactFlowManager.rf_instance?.fitView({padding:.2})}}const Jfe=()=>({libstate:gr((e,t)=>({lib:{shelves:[]},external_worker:[],set:n=>e(r=>({...r,...n})),get_lib:()=>t().lib,get_external_worker:()=>t().external_worker}))});class ede extends fl{constructor(t){super(t),this.lib=Jfe()}}class tde extends fl{constructor(t){super(t),this.workers=gr((n,r)=>({})),this.workerstate=gr((n,r)=>({is_open:!1}))}set_worker(t){t!==this.worker&&(this._unsubscribeFromWorker&&(this._unsubscribeFromWorker(),this._unsubscribeFromWorker=void 0),t&&(this._unsubscribeFromWorker=t.state.subscribe(n=>{this.workerstate.setState(n)}),this.workerstate.setState(t.state.getState())),this.worker=t,t?.set_zustand(this.context.rf))}}class nde extends fl{constructor(t){super(t),this.progress_state=gr((n,r)=>({message:"please select worker",status:"info",progress:0,blocking:!1})),this.local_settings=gr((n,r)=>({view_settings:{expand_node_props:!1,expand_lib:!1}})),this.local_state=gr((n,r)=>({selected_nodes:[],selected_edges:[],selected_groups:[],funcnodescontainerRef:null}))}set_progress(t){if(t.message==="")return this.auto_progress();const n=this.progress_state.getState(),{new_obj:r,change:o}=ha(n,t);o&&this.progress_state.setState(r)}auto_progress(){const t=this.workerManager.workermanager,n=this.workerManager.worker;if(t!==void 0&&!t.open)return this.set_progress({progress:0,message:"connecting to worker manager",status:"error",blocking:!1});if(n===void 0)return this.set_progress({progress:0,message:"please select worker",status:"error",blocking:!1});if(!n.is_open)return this.set_progress({progress:0,message:"connecting to worker",status:"info",blocking:!0});this.set_progress({progress:1,message:"running",status:"info",blocking:!1})}update_view_settings(t){UN(this.local_settings,{view_settings:t})}}const R5="1.0.0",rde=["1"],ode=e=>{if(!e.v.toString().includes(".")||!rde.includes(e.v.toString().split(".")[0]))throw new Error(`Unsupported version: ${e.v}`);return{...e,v:R5}};class ide extends fl{constructor(t){super(t),this.plugins=gr((n,r)=>({})),this.render_options=gr((n,r)=>({}))}add_plugin(t,n){if(n!==void 0)try{const r=ode(n);this.plugins.setState(o=>({...o,[t]:r}))}catch(r){r instanceof Error?this.context.rf.logger.error(`Error loading plugin ${t}`,r):this.context.rf.logger.error(`Error loading plugin ${t}`,new Error(String(r))),this.stateManager.toaster?.error({title:"Error",description:`Error loading plugin ${t}: ${r instanceof Error?r.message:String(r)}`,duration:5e3})}}update_render_options(t){UN(this.render_options,t)}async add_packed_plugin(t,n){if(n.js)for(const r of n.js){const o=document.createElement("script");o.text=atob(r),document.body.appendChild(o)}if(n.css)for(const r of n.css){const o=document.createElement("style");o.innerHTML=atob(r),document.head.appendChild(o)}if(n.module!==void 0){const r=atob(n.module);try{const a=await new Function("React","FuncNodesReactFlow",`
825
+ `)}),e.description.length>o&&x.jsx("button",{onClick:r,className:"toggle-description",children:t?"Show less":"Show more"})]})},T5=[">=","==","<=","<",">"],Fp=">=",y1=({availableModule:e,on_change:t})=>{const[n,r]=_.useState(e.version||"latest"),[o,a]=_.useState(Fp),s=c=>{const f=c.target.value;r(f),t(f!=="latest"?o+f:f)},u=c=>{c.target.value!==o&&T5.includes(c.target.value)&&(a(c.target.value),n!=="latest"&&t(c.target.value+n))};return e.releases&&!e.releases.includes(n)&&e.releases.unshift(n),x.jsxs(x.Fragment,{children:[x.jsx("select",{value:o,onChange:u,children:T5.map(c=>x.jsx("option",{value:c,children:c},c))}),x.jsx("select",{onChange:s,value:n,children:e.releases&&e.releases.map(c=>x.jsx("option",{value:c,children:c},c))})]})},Hfe=({availableModule:e,on_remove:t,on_update:n})=>{const[r,o]=_.useState(Fp+e.version||"latest");return x.jsxs("div",{className:"addable-module",children:[x.jsx("div",{className:"module-name",children:e.name+(e.version?` (${e.version})`:"")}),x.jsx(Sb,{availableModule:e}),x.jsx(g1,{availableModule:e}),x.jsxs("div",{children:[x.jsx(y1,{availableModule:e,on_change:o}),x.jsx("button",{className:"update-button",disabled:r===e.version,onClick:()=>{n(e,r)},children:"Update"}),x.jsx("button",{className:"remove-button",onClick:()=>{t(e)},children:"Remove"})]})]})},Vfe=({availableModule:e,on_add:t})=>{const[n,r]=_.useState(Fp+e.version||"latest");return x.jsxs("div",{className:"addable-module",children:[x.jsx("div",{className:"module-name",children:e.name+(e.version?` (${e.version})`:"")}),x.jsx(Sb,{availableModule:e}),x.jsx(g1,{availableModule:e}),x.jsxs("div",{children:[x.jsx(y1,{availableModule:e,on_change:r}),x.jsx("button",{className:"add-button",onClick:()=>{t(e,n)},children:"Add"})]})]})},Ufe=({availableModule:e,on_add:t})=>{const[n,r]=_.useState(Fp+e.version||"latest");return x.jsxs("div",{className:"addable-module",children:[x.jsx("div",{className:"module-name",children:e.name}),x.jsx(Sb,{availableModule:e}),x.jsx(g1,{availableModule:e}),x.jsxs("div",{children:[x.jsx(y1,{availableModule:e,on_change:r}),x.jsx("button",{className:"add-button",onClick:()=>{t(e,n)},children:"Add"})]})]})},qfe=({ins:e})=>{const[t,n]=_.useState(e.name),r=tt(),{lib:o}=_n(),a=()=>{r.worker&&o?.remove_external_worker(e.uuid,e.nodeclassid)},s=()=>{r.worker&&(r.worker.update_external_worker(e.uuid,e.nodeclassid,{name:t}),e.name=t)};return x.jsx(x.Fragment,{children:x.jsx(Lo,{title:e.name,description:"Settings for"+e.name,trigger:x.jsx("div",{children:"Settings"}),buttons:[{text:"Save",onClick:s,close:!0},{text:"Delete",onClick:a,close:!0}],children:x.jsx("div",{children:x.jsxs("div",{children:[x.jsx("label",{htmlFor:"name",children:"Name: "}),x.jsx("input",{type:"text",name:"name",value:t,onChange:u=>n(u.target.value),className:"styledinput"})]})})})})},Gfe=({ins:e,lib:t,filter:n="",parentkey:r})=>{const[o,a]=_.useState(!1),s=()=>a(!o),u=t?.nodes?.filter(c=>c.node_id.toLowerCase().includes(n.toLowerCase()));return x.jsxs("div",{className:"shelfcontainer",children:[x.jsxs("div",{className:"shelftitle",onClick:s,style:{cursor:"pointer"},title:e.name,children:[x.jsx("div",{className:"shelftitle_text",children:e.name}),x.jsx("div",{className:"expandicon "+(o?"open":"close"),children:x.jsx(xu,{})})]}),x.jsx("div",{className:"libnodecontainer "+(o?"open":"close"),children:x.jsx("div",{className:"libnodecontainer_inner",children:o&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"libnodeentry",title:e.uuid,children:x.jsx(qfe,{ins:e})}),t&&x.jsxs(x.Fragment,{children:[u&&x.jsx(x.Fragment,{children:u.map(c=>x.jsx(N2,{item:c},r+c.node_id))}),t.subshelves.map(c=>x.jsx(_b,{item:c,filter:n,parentkey:r+c.name},r+c.name))]})]})})})]})},Yfe=({item:e,mod:t,lib:n})=>{const{lib:r}=_n(),[o,a]=_.useState(!1),s=()=>a(!o),u=_.useCallback(()=>{r?.add_external_worker({module:t,cls_module:e.module,cls_name:e.class_name})},[r,t,e]),c=h=>{h.detail===2&&u()},f=e.name||e.module+"."+e.class_name;return x.jsxs("div",{className:"shelfcontainer",children:[x.jsxs("div",{className:"shelftitle",onClick:s,style:{cursor:"pointer"},title:f,children:[x.jsx("div",{className:"shelftitle_text",children:f}),x.jsx("div",{className:"expandicon "+(o?"open":"close"),children:x.jsx(xu,{})})]}),x.jsx("div",{className:"libnodecontainer "+(o?"open":"close"),children:x.jsx("div",{className:"libnodecontainer_inner",children:o&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"libnodeentry",onClick:c,title:e.name,children:"New Instance"}),e.instances.map(h=>x.jsx(Gfe,{ins:h,lib:n?.subshelves.find(p=>p.name===h.uuid),parentkey:h.uuid},h.uuid))]})})})]})},Wfe=({externalworkermod:e,lib:t})=>{const[n,r]=_.useState(!1),o=()=>r(!n),a=n;return x.jsxs("div",{className:"shelfcontainer",children:[x.jsxs("div",{className:"shelftitle",onClick:o,style:{cursor:"pointer"},title:e.module,children:[x.jsx("div",{className:"shelftitle_text",children:e.module}),x.jsx("div",{className:"expandicon "+(a?"open":"close"),children:x.jsx(xu,{})})]}),x.jsx("div",{className:"libnodecontainer "+(a?"open":"close"),children:x.jsx("div",{className:"libnodecontainer_inner",children:e.worker_classes.map(s=>x.jsx(Yfe,{item:s,mod:e.module,lib:t},s.module+s.class_name))})}),x.jsx("hr",{})]})},Xfe=()=>{const e=tt(),t=e.lib.libstate(),n=tt(),r=n.local_settings(f=>f.view_settings.expand_lib),o=f=>{n.update_view_settings({expand_lib:f})},a=rre("m"),[s,u]=_.useState(""),c=e.worker?.state(f=>f.is_open)??!1;return x.jsx(tb,{maxSize:a?"100%":"18.75rem",direction:a?"down":"right",containerClassName:"pos-left pos-top bg1 h-12",onExpandChange:o,expanded:r===void 0?!0:r,collapseIcons:{up:Fd,down:bu,left:vu,right:Ld},expandIcons:{up:bu,down:Fd,left:Ld,right:vu},children:x.jsxs("div",{className:"libcontainer",children:[x.jsxs("div",{className:"library",children:[x.jsx("div",{className:"libtitle",children:"Lib"}),x.jsx("hr",{className:"hr_prominent"}),x.jsx(Cie,{filter:s,setFilter:u}),x.jsx("div",{className:"vscrollcontainer",children:t.lib.shelves.filter(f=>f.name!=="_external_worker").map(f=>x.jsx(_b,{item:f,filter:s,parentkey:f.name},f.name))}),x.jsx("hr",{}),x.jsx("div",{className:"libtitle",children:"External Worker"}),x.jsx("hr",{className:"hr_prominent"}),x.jsx("div",{className:"vscrollcontainer",children:t.external_worker?.map(f=>x.jsx(Wfe,{externalworkermod:f,lib:t.lib.shelves.find(h=>h.name==="_external_worker")},f.module))}),x.jsx("hr",{})]}),c&&x.jsx("div",{className:"addlib",children:x.jsx(kie,{children:x.jsx("button",{children:"Manage Libraries"})})})]})})},Kfe=({fnrf_zst:e,header:t,flow:n,library:r})=>{const[o,a]=_.useState(e.options.worker||e.getWorkerManager().worker),s=_.useRef(null);e.workermanager&&(e.workermanager.on_setWorker=a),_.useEffect(()=>{e.auto_progress()},[]),_.useEffect(()=>{e.local_state.setState({funcnodescontainerRef:s.current})},[s]);const u=e.plugins();return x.jsx(Hne,{plugins:u,fnrf_zst:e,children:x.jsx(NB,{children:x.jsx(FC.Provider,{value:e,children:x.jsx(bi,{asChild:!0,children:x.jsx(Ao,{asChild:!0,children:x.jsx(EN,{style:{height:"100%",width:"100%",display:"flex",flexDirection:"column",flex:1},children:x.jsxs("div",{ref:s,className:"funcnodesreactflowcontainer funcnodescontainer",children:[t.show&&x.jsx(Eie,{...t}),x.jsxs("div",{className:"funcnodesreactflowbody",children:[x.jsx(noe,{...n}),o&&r.show&&x.jsx(Xfe,{}),o&&n.showNodeSettings&&x.jsx(lre,{})]}),x.jsxs("div",{className:"funcnodesflaotingmenu",children:[x.jsx(Ao.OutFullScreen,{children:n.allowExpand&&x.jsxs(bi.Trigger,{children:[x.jsx(bi.Expanded,{children:x.jsx(_B,{size:"xl",style:{padding:"4px"}})}),x.jsx(bi.Collapsed,{children:x.jsx(SB,{size:"xl",style:{padding:"4px"}})})]})}),n.allowFullScreen&&x.jsxs(Ao.Trigger,{children:[x.jsx(Ao.OutFullScreen,{children:x.jsx(LC,{size:"xl",style:{padding:"4px"}})}),x.jsx(Ao.InFullScreen,{children:x.jsx(wB,{size:"xl",style:{padding:"4px"}})})]})]})]})})})})})})})};class fl{constructor(t){this.context=t}get nodespaceManager(){return this.context.rf.getNodespaceManager()}get libManager(){return this.context.rf.getLibManager()}get workerManager(){return this.context.rf.getWorkerManager()}get stateManager(){return this.context.rf.getStateManager()}get pluginManager(){return this.context.rf.getPluginManager()}get reactFlowManager(){return this.context.rf.getReactFlowManager()}}const A5=({src_nid:e,src_ioid:t,trg_nid:n,trg_ioid:r})=>[`${e}:${t}`,`${n}:${r}`].sort().join("--"),Zfe=({})=>{const e=new Map;return{nodesstates:e,get_node:(t,n=!0)=>{const r=e.get(t);if(!r&&n){const o=e.keys();throw new Error(`Node ${t} not found, available nodes: ${Array.from(o)}`)}return r}}};class Qfe extends fl{constructor(t){super(t),this.on_node_action=n=>{switch(n.type){case"add":return this._add_node(n);case"update":return this._update_node(n);case"delete":return this._delete_node(n);case"error":return this._error_action(n);case"trigger":return this._trigger_action(n);default:this.context.rf.logger.error("Unknown node action",n);return}},this.on_edge_action=n=>{const r=this.reactFlowManager.useReactFlowStore.getState();switch(n.type){case"add":if(n.from_remote){const o=r.getEdges(),a=A5(n);if(o.some(u=>u.id===a))return;const s={id:a,source:n.src_nid,target:n.trg_nid,sourceHandle:n.src_ioid,targetHandle:n.trg_ioid,className:"funcnodes-edge animated",zIndex:1003};this.context.rf.logger.info("Adding edge",s),r.update_edges([...o,s]),this.workerManager.worker?.api.node.get_remote_node_state(n.src_nid),this.workerManager.worker?.api.node.get_remote_node_state(n.trg_nid)}break;case"delete":if(n.from_remote){const o=r.getEdges(),a=A5(n);this.context.rf.logger.info("Deleting edge",a);const s=o.filter(u=>u.id!==a);r.update_edges(s),this.workerManager.worker?.api.node.get_remote_node_state(n.src_nid),this.workerManager.worker?.api.node.get_remote_node_state(n.trg_nid)}break;default:this.context.rf.logger.error("Unknown edge action",n)}},this.on_group_action=n=>{switch(n.type){case"set":return this._set_groups(n.groups);case"update":return this._update_group(n);default:this.context.rf.logger.error("Unknown group action",n)}},this.clear_all=()=>{this.context.rf.logger.debug("Clearing all nodespace"),this.workerManager.worker?.disconnect(),this.workerManager.set_worker(void 0),this.workerManager.workermanager?.setWorker(void 0),this.libManager.lib.libstate.getState().set({lib:{shelves:[]},external_worker:[]}),this.nodespace.nodesstates.clear(),this.reactFlowManager.useReactFlowStore.getState().update_nodes([]),this.reactFlowManager.useReactFlowStore.getState().update_edges([]),this.stateManager.auto_progress()},this.center_node=n=>{if(!this.reactFlowManager.rf_instance)return;n=Array.isArray(n)?n:[n];const r=this.reactFlowManager.useReactFlowStore.getState().getNodes().filter(o=>n.includes(o.id));r.length>0&&this.reactFlowManager.rf_instance?.fitView({padding:.2,nodes:r})},this.auto_resize_group=n=>{const r=this.reactFlowManager.useReactFlowStore.getState(),o=r.getNode(n);if(o===void 0||o.type!=="group")return;const a=o.data.group.node_ids.map(h=>r.getNode(h)).filter(h=>h!==void 0),s=o.data.group.child_groups.map(h=>r.getNode(h)).filter(h=>h!==void 0),u=[...a,...s],c=this.reactFlowManager.rf_instance?.getNodesBounds(u);if(c===void 0)return;const f={...o,position:{x:c.x,y:c.y},height:c.height,width:c.width};f.data.group.position=[c.x,c.y],r.partial_update_nodes([f])},this.change_group_position=n=>{if(n.position===void 0)return;const r=this.reactFlowManager.useReactFlowStore.getState(),o=r.getNode(n.id);if(o===void 0||o.type!=="group")return;const a=[...o.data.group.node_ids,...o.data.group.child_groups],s=this.reactFlowManager.rf_instance?.getNodesBounds(a);if(s===void 0)return;const u=n.position.x-s?.x,c=n.position.y-s?.y,f=[];for(const h of a){const p=r.getNode(h);p!==void 0&&f.push({id:h,type:"position",position:{x:p.position.x+u,y:p.position.y+c}})}r.onNodesChange(f)},this.change_fn_node_position=n=>{n.position!==void 0&&this.on_node_action({type:"update",id:n.id,node:{properties:{"frontend:pos":[n.position.x,n.position.y]}},from_remote:!1})},this.change_group_dimensions=n=>{if(n.dimensions===void 0)return;const o=this.reactFlowManager.useReactFlowStore.getState().getNode(n.id);o!==void 0&&this.reactFlowManager.useReactFlowStore.getState().partial_update_nodes($v([n],[o]))},this.change_fn_node_dimensions=n=>{n.dimensions!==void 0&&this.on_node_action({type:"update",id:n.id,node:{properties:{"frontend:size":[n.dimensions.width,n.dimensions.height]}},from_remote:!1})},this._update_group=n=>{if(n.from_remote){const r=this.reactFlowManager.useReactFlowStore.getState(),o=r.getNode(n.id);if(o===void 0||o.type!=="group")return;const{new_obj:a,change:s}=ha(o.data.group,n.group);s&&(o.data.group=a),r.partial_update_nodes([o])}else this.workerManager.worker&&this.workerManager.worker.api.group.locally_update_group(n)},this._set_groups=n=>{const r=this.reactFlowManager.useReactFlowStore.getState(),{default_nodes:o}=lb(r.getNodes()),a=[...o],s={};for(const c in n){const f=n[c];for(const p of f.node_ids)s[p]=c;for(const p of f.child_groups)s[p]=c;f.position===void 0&&(f.position=[0,0]);const h={id:c,type:"group",data:{group:n[c],id:c},position:{x:f.position[0],y:f.position[1]},zIndex:2};f.parent_group&&(h.data.groupID=f.parent_group),a.push(h)}for(const c of a)c.id in s?c.data.groupID=s[c.id]:c.data.groupID=void 0;const u=ub(a);r.update_nodes(u);for(const c of u.reverse())c.type==="group"&&this.auto_resize_group(c.id)},this._add_node=n=>{this.context.rf.logger.info("add node",n);const r=this.reactFlowManager.useReactFlowStore.getState();if(n.from_remote){let o=this.nodespace.get_node(n.node.id,!1);if(o)return;if(!o)try{o=Wre(n.node),this.nodespace.nodesstates.set(n.node.id,o)}catch(c){this.context.rf.logger.error(`Failed to create node store ${c}`);return}const a=o.getState();this.context.rf.logger.info("Add node",a.id,a.name);const s=toe(o,this.context.rf),u=[...r.getNodes(),s];this.reactFlowManager.useReactFlowStore.getState().update_nodes(u);for(const c of s.io_order)this.workerManager.worker?.api.node.get_io_value({nid:s.id,ioid:c});return setTimeout(()=>{this.workerManager.worker?.api.hooks.call_hooks("node_added",{node:a.id})},0),a}},this._update_node=n=>{if(Object.keys(n.node).length===0){this.context.rf.logger.error("Node update is empty",new Error(JSON.stringify(n)));return}if(n.node.in_trigger&&(n.node.error=void 0),n.from_remote){const r=this.nodespace.get_node(n.id,!1);if(!r){console.error("Node not found to update",n.id);return}return r.update(n.node),r.getState()}else this.workerManager.worker&&this.workerManager.worker.api.node.locally_update_node(n)},this._delete_node=n=>{this.context.rf.logger.info("Deleting node",n.id),n.from_remote?this.reactFlowManager.useReactFlowStore.getState().onNodesChange([{type:"remove",id:n.id}]):this.workerManager.worker?.api.node.remove_node(n.id)},this._error_action=n=>(this.context.rf.logger.error("Error",new Error(JSON.stringify(n))),this.on_node_action({type:"update",id:n.id,node:{in_trigger:!1,error:n.error},from_remote:!0})),this._trigger_action=n=>{if(n.from_remote)return this.on_node_action({type:"update",id:n.id,node:{in_trigger:!0,error:void 0},from_remote:!0});this.workerManager.worker?.api.node.trigger_node(n.id)},this.nodespace=Zfe({})}center_all(){this.reactFlowManager.rf_instance?.fitView({padding:.2})}}const Jfe=()=>({libstate:gr((e,t)=>({lib:{shelves:[]},external_worker:[],set:n=>e(r=>({...r,...n})),get_lib:()=>t().lib,get_external_worker:()=>t().external_worker}))});class ede extends fl{constructor(t){super(t),this.lib=Jfe()}}class tde extends fl{constructor(t){super(t),t.rf.logger.debug("Initializing worker manager handler"),this.workers=gr((n,r)=>({})),this.workerstate=gr((n,r)=>({is_open:!1}))}set_worker(t){t!==this.worker&&(this._unsubscribeFromWorker&&(this._unsubscribeFromWorker(),this._unsubscribeFromWorker=void 0),t?(this.context.rf.logger.debug("Setting worker in worker manager"),this._unsubscribeFromWorker=t.state.subscribe(n=>{this.workerstate.setState(n)}),this.workerstate.setState(t.state.getState())):this.context.rf.logger.debug("Removing worker in worker manager"),this.worker=t,t?.set_zustand(this.context.rf))}}class nde extends fl{constructor(t){super(t),this.progress_state=gr((n,r)=>({message:"please select worker",status:"info",progress:0,blocking:!1})),this.local_settings=gr((n,r)=>({view_settings:{expand_node_props:!1,expand_lib:!1}})),this.local_state=gr((n,r)=>({selected_nodes:[],selected_edges:[],selected_groups:[],funcnodescontainerRef:null}))}set_progress(t){if(t.message==="")return this.auto_progress();const n=this.progress_state.getState(),{new_obj:r,change:o}=ha(n,t);o&&this.progress_state.setState(r)}auto_progress(){const t=this.workerManager.workermanager,n=this.workerManager.worker;if(t!==void 0&&!t.open)return this.set_progress({progress:0,message:"connecting to worker manager",status:"error",blocking:!1});if(n===void 0)return this.set_progress({progress:0,message:"please select worker",status:"error",blocking:!1});if(!n.is_open)return this.set_progress({progress:0,message:"connecting to worker",status:"info",blocking:!0});this.set_progress({progress:1,message:"running",status:"info",blocking:!1})}update_view_settings(t){UN(this.local_settings,{view_settings:t})}}const R5="1.0.0",rde=["1"],ode=e=>{if(!e.v.toString().includes(".")||!rde.includes(e.v.toString().split(".")[0]))throw new Error(`Unsupported version: ${e.v}`);return{...e,v:R5}};class ide extends fl{constructor(t){super(t),this.plugins=gr((n,r)=>({})),this.render_options=gr((n,r)=>({}))}add_plugin(t,n){if(n!==void 0)try{const r=ode(n);this.plugins.setState(o=>({...o,[t]:r}))}catch(r){r instanceof Error?this.context.rf.logger.error(`Error loading plugin ${t}`,r):this.context.rf.logger.error(`Error loading plugin ${t}`,new Error(String(r))),this.stateManager.toaster?.error({title:"Error",description:`Error loading plugin ${t}: ${r instanceof Error?r.message:String(r)}`,duration:5e3})}}update_render_options(t){UN(this.render_options,t)}async add_packed_plugin(t,n){if(n.js)for(const r of n.js){const o=document.createElement("script");o.text=atob(r),document.body.appendChild(o)}if(n.css)for(const r of n.css){const o=document.createElement("style");o.innerHTML=atob(r),document.head.appendChild(o)}if(n.module!==void 0){const r=atob(n.module);try{const a=await new Function("React","FuncNodesReactFlow",`
826
826
  return (async () => {
827
827
  ${r}
828
828
  return FuncNodesPlugin;
829
829
  })();
830
- `)(ls,To);this.add_plugin(t,a)}catch(o){o instanceof Error?this.context.rf.logger.error(`Error building plugin ${t}`,o):this.context.rf.logger.error(`Error building plugin ${t}`,new Error(String(o))),this.stateManager.toaster?.error({title:"Error",description:`Error building plugin ${t}: ${o}`,duration:5e3})}}}}class ade extends fl{constructor(t){super(t),this.on_rf_node_change=n=>{const r=this.useReactFlowStore.getState();for(const o of n)switch(o.type){case"position":if(o.position){const a=r.getNode(o.id);if(a===void 0)continue;a.type==="group"?this.nodespaceManager.change_group_position(o):this.nodespaceManager.change_fn_node_position(o),a.data.groupID&&this.nodespaceManager.auto_resize_group(a.data.groupID)}break;case"dimensions":if(o.dimensions){const a=r.getNode(o.id);if(a===void 0)continue;a.type==="group"?this.nodespaceManager.change_group_dimensions(o):this.nodespaceManager.change_fn_node_dimensions(o),a.data.groupID&&this.nodespaceManager.auto_resize_group(a.data.groupID)}break}},this.on_rf_edge_change=n=>{},this.on_connect=n=>{n.source===null||n.target===null||n.sourceHandle===null||n.targetHandle===null||!this.workerManager.worker||this.workerManager.worker.api.edge.add_edge({src_nid:n.source,src_ioid:n.sourceHandle,trg_nid:n.target,trg_ioid:n.targetHandle,replace:!0})},this.useReactFlowStore=roe({on_node_change:this.on_rf_node_change.bind(this),on_edge_change:this.on_rf_edge_change.bind(this),on_connect:this.on_connect.bind(this)})}}let sde=class{constructor(t){this.reactflowRef=null,this.dev_settings={debug:xp},this.options=t,this.logger=t.logger??new fg("fn",$w);const n={rf:this};this._nodespaceManager=new Qfe(n),this._libManager=new ede(n),this._workerManager=new tde(n),this._stateManager=new nde(n),this._pluginManager=new ide(n),this._reactFlowManager=new ade(n)}getNodespaceManager(){return this._nodespaceManager}getLibManager(){return this._libManager}getWorkerManager(){return this._workerManager}getStateManager(){return this._stateManager}getPluginManager(){return this._pluginManager}getReactFlowManager(){return this._reactFlowManager}get nodespace(){return this._nodespaceManager.nodespace}get on_node_action(){return this._nodespaceManager.on_node_action.bind(this._nodespaceManager)}get on_edge_action(){return this._nodespaceManager.on_edge_action.bind(this._nodespaceManager)}get on_group_action(){return this._nodespaceManager.on_group_action.bind(this._nodespaceManager)}get clear_all(){return this._nodespaceManager.clear_all.bind(this._nodespaceManager)}get center_node(){return this._nodespaceManager.center_node.bind(this._nodespaceManager)}get center_all(){return this._nodespaceManager.center_all.bind(this._nodespaceManager)}get lib(){return this._libManager.lib}get set_worker(){return this._workerManager.set_worker.bind(this._workerManager)}get workermanager(){return this._workerManager.workermanager}set workermanager(t){this._workerManager.workermanager=t}get worker(){return this._workerManager.worker}get workers(){return this._workerManager.workers}get workerstate(){return this._workerManager.workerstate}get _unsubscribeFromWorker(){return this._workerManager._unsubscribeFromWorker?.bind(this._workerManager)}get set_progress(){return this._stateManager.set_progress.bind(this._stateManager)}get auto_progress(){return this._stateManager.auto_progress.bind(this._stateManager)}get progress_state(){return this._stateManager.progress_state}get local_settings(){return this._stateManager.local_settings}get local_state(){return this._stateManager.local_state}update_view_settings(t){this._stateManager.update_view_settings(t)}get plugins(){return this._pluginManager.plugins.bind(this._pluginManager)}get add_plugin(){return this._pluginManager.add_plugin.bind(this._pluginManager)}get add_packed_plugin(){return this._pluginManager.add_packed_plugin.bind(this._pluginManager)}get render_options(){return this._pluginManager.render_options.bind(this._pluginManager)}get update_render_options(){return this._pluginManager.update_render_options.bind(this._pluginManager)}get useReactFlowStore(){return this._reactFlowManager.useReactFlowStore.bind(this._reactFlowManager)}get rf_instance(){return this._reactFlowManager.rf_instance}set rf_instance(t){this._reactFlowManager.rf_instance=t}};const lde=pg(aX,e=>(e.id=By(),e)),ude=e=>{if(!e.useWorkerManager&&e.worker===void 0)throw new Error("If you don't use a worker manager, you must provide a default worker.");if(e.useWorkerManager&&e.workermanager_url===void 0)throw new Error("Error: If you use a worker manager, you must provide a worker managerurl.")},v1={};window.fnrf_zst===void 0&&(window.fnrf_zst=v1);const cde=e=>{const[t,n]=_.useState(void 0),[r,o]=_.useState(void 0),[a,s]=_.useState(!1);if(_.useEffect(()=>{const u=lde(e);u.logger=u.logger||new fg("FuncNodes",u.debug?"debug":"info"),u.logger.debug("Initializing FuncNodes with props:",u),n(u),s(!1)},[e]),_.useEffect(()=>{if(!t)return;t.logger?.debug("Initializing/Getting Zustand store");const u=v1[t.id];if(u===void 0){const c=new sde(t);v1[t.id]=c,o(c)}else o(u),u.options.debug=t.debug},[t?.id,t?.debug]),_.useEffect(()=>{if(!(!t||!r)&&!(t.useWorkerManager||!t.worker_url))if(t.logger?.debug("Worker effect running"),t.worker){t.worker.set_zustand(r);return}else{t.logger?.debug("Creating WebSocket worker");const u=new uR({url:t.worker_url,uuid:t.id,on_sync_complete:t.on_sync_complete});return u.set_zustand(r),n(c=>c&&{...c,worker:u,useWorkerManager:!1}),()=>{t.logger?.debug("Disconnecting worker"),u.disconnect(),n(c=>c&&{...c,worker:void 0})}}},[t?.worker_url,t?.id,t?.useWorkerManager,r,t?.on_sync_complete]),_.useEffect(()=>{if(!t?.fnw_url||!t.worker)return;t.logger?.debug("Loading fnw_url data");let u=!1;const c=t.worker.getSyncManager().on_sync_complete;return(async()=>{try{const h=await Tj(t.fnw_url);!u&&t.worker&&(t.worker.getSyncManager().on_sync_complete=async p=>{await p.update_from_export(h),t.worker.getSyncManager().on_sync_complete=c,c&&c(p)})}catch(h){h instanceof Error?t.logger?.error("Failed to load fnw_url:",h):t.logger?.error("Failed to load fnw_url:",new Error(String(h)))}})(),()=>{u=!0,t.worker&&(t.worker.getSyncManager().on_sync_complete=c)}},[t?.fnw_url,t?.worker]),_.useEffect(()=>{if(!t||!r||!t.useWorkerManager)return;if(!t.workermanager_url)throw new Error("Error: If you use a worker manager, you must provide a worker manager url.");r.logger.info("Worker manager effect running");const u=!r.workermanager,c=r.workermanager&&r.workermanager.wsuri!==t.workermanager_url;if(u||c){r.workermanager&&(r.logger.info("Removing existing worker manager"),r.workermanager.remove(),r.workermanager=void 0),r.logger.info("Creating new worker manager");const f=new iX(t.workermanager_url,r);return r.workermanager=f,n(h=>h&&{...h,workermanager:f}),()=>{r.logger.info("Worker manager cleanup running"),r.workermanager===f?(r.logger.info("Removing worker manager instance"),f.remove(),r.workermanager=void 0):r.logger.info("Worker manager instance mismatch, skipping cleanup")}}else{r.logger.info("Worker manager already initialized with correct URL");return}},[t?.useWorkerManager,t?.workermanager_url,t?.id,r]),_.useEffect(()=>{if(!t||!r||a)return;(t.useWorkerManager?r.workermanager!==void 0:t.worker!==void 0)&&t.on_ready&&typeof t.on_ready=="function"&&(t.logger?.debug("Firing on_ready callback"),t.on_ready({fnrf_zst:r}),s(!0))},[t,r,a,t?.useWorkerManager,r?.workermanager,t?.worker]),t===void 0||r===void 0)return x.jsx("div",{children:"Loading..."});try{ude(t)}catch(u){return x.jsx(Aj,{error:u})}return x.jsx("div",{className:"FuncnodesApp",children:x.jsx(DB,{available_themes:cR,children:x.jsx(cY,{duration:5e3,children:x.jsx(Kfe,{fnrf_zst:r,header:t.header,library:t.library,flow:t.flow})})})})},M5=(e,t)=>{t===void 0&&(t={});const{element:n,eleid:r}=typeof e=="string"?{element:document.getElementById(e),eleid:e}:{element:e,eleid:e.id};pj.createRoot(n).render(x.jsx(_.StrictMode,{children:x.jsx(cde,{...t,id:t.id||r})}))};window.FuncNodes=M5,window.FuncNodes.version="1.0.0",window.FuncNodes.utils={logger:{ConsoleLogger:fg,DivLogger:bj,BaseLogger:cg,DEBUG:mj,INFO:$w,WARN:gj,ERROR:yj}}})();
830
+ `)(ls,To);this.add_plugin(t,a)}catch(o){o instanceof Error?this.context.rf.logger.error(`Error building plugin ${t}`,o):this.context.rf.logger.error(`Error building plugin ${t}`,new Error(String(o))),this.stateManager.toaster?.error({title:"Error",description:`Error building plugin ${t}: ${o}`,duration:5e3})}}}}class ade extends fl{constructor(t){super(t),this.on_rf_node_change=n=>{const r=this.useReactFlowStore.getState();for(const o of n)switch(o.type){case"position":if(o.position){const a=r.getNode(o.id);if(a===void 0)continue;a.type==="group"?this.nodespaceManager.change_group_position(o):this.nodespaceManager.change_fn_node_position(o),a.data.groupID&&this.nodespaceManager.auto_resize_group(a.data.groupID)}break;case"dimensions":if(o.dimensions){const a=r.getNode(o.id);if(a===void 0)continue;a.type==="group"?this.nodespaceManager.change_group_dimensions(o):this.nodespaceManager.change_fn_node_dimensions(o),a.data.groupID&&this.nodespaceManager.auto_resize_group(a.data.groupID)}break}},this.on_rf_edge_change=n=>{},this.on_connect=n=>{n.source===null||n.target===null||n.sourceHandle===null||n.targetHandle===null||!this.workerManager.worker||this.workerManager.worker.api.edge.add_edge({src_nid:n.source,src_ioid:n.sourceHandle,trg_nid:n.target,trg_ioid:n.targetHandle,replace:!0})},this.useReactFlowStore=roe({on_node_change:this.on_rf_node_change.bind(this),on_edge_change:this.on_rf_edge_change.bind(this),on_connect:this.on_connect.bind(this)})}}let sde=class{constructor(t){this.reactflowRef=null,this.dev_settings={debug:xp},this.options=t,this.logger=t.logger??new fg("fn",$w);const n={rf:this};this._nodespaceManager=new Qfe(n),this._libManager=new ede(n),this._workerManager=new tde(n),this._stateManager=new nde(n),this._pluginManager=new ide(n),this._reactFlowManager=new ade(n)}getNodespaceManager(){return this._nodespaceManager}getLibManager(){return this._libManager}getWorkerManager(){return this._workerManager}getStateManager(){return this._stateManager}getPluginManager(){return this._pluginManager}getReactFlowManager(){return this._reactFlowManager}get nodespace(){return this._nodespaceManager.nodespace}get on_node_action(){return this._nodespaceManager.on_node_action.bind(this._nodespaceManager)}get on_edge_action(){return this._nodespaceManager.on_edge_action.bind(this._nodespaceManager)}get on_group_action(){return this._nodespaceManager.on_group_action.bind(this._nodespaceManager)}get clear_all(){return this._nodespaceManager.clear_all.bind(this._nodespaceManager)}get center_node(){return this._nodespaceManager.center_node.bind(this._nodespaceManager)}get center_all(){return this._nodespaceManager.center_all.bind(this._nodespaceManager)}get lib(){return this._libManager.lib}get set_worker(){return this._workerManager.set_worker.bind(this._workerManager)}get workermanager(){return this._workerManager.workermanager}set workermanager(t){this._workerManager.workermanager=t}get worker(){return this._workerManager.worker}get workers(){return this._workerManager.workers}get workerstate(){return this._workerManager.workerstate}get _unsubscribeFromWorker(){return this._workerManager._unsubscribeFromWorker?.bind(this._workerManager)}get set_progress(){return this._stateManager.set_progress.bind(this._stateManager)}get auto_progress(){return this._stateManager.auto_progress.bind(this._stateManager)}get progress_state(){return this._stateManager.progress_state}get local_settings(){return this._stateManager.local_settings}get local_state(){return this._stateManager.local_state}update_view_settings(t){this._stateManager.update_view_settings(t)}get plugins(){return this._pluginManager.plugins.bind(this._pluginManager)}get add_plugin(){return this._pluginManager.add_plugin.bind(this._pluginManager)}get add_packed_plugin(){return this._pluginManager.add_packed_plugin.bind(this._pluginManager)}get render_options(){return this._pluginManager.render_options.bind(this._pluginManager)}get update_render_options(){return this._pluginManager.update_render_options.bind(this._pluginManager)}get useReactFlowStore(){return this._reactFlowManager.useReactFlowStore.bind(this._reactFlowManager)}get rf_instance(){return this._reactFlowManager.rf_instance}set rf_instance(t){this._reactFlowManager.rf_instance=t}};const lde=pg(aX,e=>(e.id=By(),e)),ude=e=>{if(!e.useWorkerManager&&e.worker===void 0)throw new Error("If you don't use a worker manager, you must provide a default worker.");if(e.useWorkerManager&&e.workermanager_url===void 0)throw new Error("Error: If you use a worker manager, you must provide a worker managerurl.")},v1={};window.fnrf_zst===void 0&&(window.fnrf_zst=v1);const cde=e=>{const[t,n]=_.useState(void 0),[r,o]=_.useState(void 0),[a,s]=_.useState(!1);if(_.useEffect(()=>{const u=lde(e);u.logger=u.logger||new fg("FuncNodes",u.debug?"debug":"info"),u.logger.debug("Initializing FuncNodes with props:",u),n(u),s(!1)},[e]),_.useEffect(()=>{if(!t)return;t.logger?.debug("Initializing/Getting Zustand store");const u=v1[t.id];if(u===void 0){const c=new sde(t);v1[t.id]=c,o(c)}else o(u),u.options.debug=t.debug},[t?.id,t?.debug]),_.useEffect(()=>{if(!(!t||!r)&&!(t.useWorkerManager||!t.worker_url))if(t.logger?.debug("Worker effect running"),t.worker){t.worker.set_zustand(r);return}else{t.logger?.debug("Creating WebSocket worker");const u=new uR({url:t.worker_url,uuid:t.id,on_sync_complete:t.on_sync_complete});return u.set_zustand(r),n(c=>c&&{...c,worker:u,useWorkerManager:!1}),()=>{t.logger?.debug("Disconnecting worker"),u.disconnect(),n(c=>c&&{...c,worker:void 0})}}},[t?.worker_url,t?.id,t?.useWorkerManager,r,t?.on_sync_complete]),_.useEffect(()=>{if(!t?.fnw_url||!t.worker)return;t.logger?.debug("Loading fnw_url data");let u=!1;const c=t.worker.getSyncManager().on_sync_complete;return(async()=>{try{const h=await Tj(t.fnw_url);!u&&t.worker&&(t.worker.getSyncManager().on_sync_complete=async p=>{await p.update_from_export(h),t.worker.getSyncManager().on_sync_complete=c,c&&c(p)})}catch(h){h instanceof Error?t.logger?.error("Failed to load fnw_url:",h):t.logger?.error("Failed to load fnw_url:",new Error(String(h)))}})(),()=>{u=!0,t.worker&&(t.worker.getSyncManager().on_sync_complete=c)}},[t?.fnw_url,t?.worker]),_.useEffect(()=>{if(!t||!r||!t.useWorkerManager)return;if(!t.workermanager_url)throw new Error("Error: If you use a worker manager, you must provide a worker manager url.");r.logger.info("Worker manager effect running");const u=!r.workermanager,c=r.workermanager&&r.workermanager.wsuri!==t.workermanager_url;if(u||c){r.workermanager&&(r.logger.info("Removing existing worker manager"),r.workermanager.remove(),r.workermanager=void 0),r.logger.info("Creating new worker manager");const f=new iX(t.workermanager_url,r);return r.workermanager=f,n(h=>h&&{...h,workermanager:f}),()=>{r.logger.info("Worker manager cleanup running"),r.workermanager===f?(r.logger.info("Removing worker manager instance"),f.remove(),r.workermanager=void 0):r.logger.info("Worker manager instance mismatch, skipping cleanup")}}else{r.logger.info("Worker manager already initialized with correct URL");return}},[t?.useWorkerManager,t?.workermanager_url,t?.id,r]),_.useEffect(()=>{if(!t||!r||a)return;(t.useWorkerManager?r.workermanager!==void 0:t.worker!==void 0)&&t.on_ready&&typeof t.on_ready=="function"&&(t.logger?.debug("Firing on_ready callback"),t.on_ready({fnrf_zst:r}),s(!0))},[t,r,a,t?.useWorkerManager,r?.workermanager,t?.worker]),t===void 0||r===void 0)return x.jsx("div",{children:"Loading..."});try{ude(t)}catch(u){return x.jsx(Aj,{error:u})}return x.jsx("div",{className:"FuncnodesApp",children:x.jsx(DB,{available_themes:cR,children:x.jsx(cY,{duration:5e3,children:x.jsx(Kfe,{fnrf_zst:r,header:t.header,library:t.library,flow:t.flow})})})})},M5=(e,t)=>{t===void 0&&(t={});const{element:n,eleid:r}=typeof e=="string"?{element:document.getElementById(e),eleid:e}:{element:e,eleid:e.id};pj.createRoot(n).render(x.jsx(_.StrictMode,{children:x.jsx(cde,{...t,id:t.id||r})}))};window.FuncNodes=M5,window.FuncNodes.version="1.0.2",window.FuncNodes.utils={logger:{ConsoleLogger:fg,DivLogger:bj,BaseLogger:cg,DEBUG:mj,INFO:$w,WARN:gj,ERROR:yj}}})();