app-v3-scripts-editor 1.14.2 → 1.14.3
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.
|
@@ -89925,7 +89925,7 @@ var HGe = "scripts_editor_3c0va90", WGe = "scripts_editor_3c0va91", QGe = "scrip
|
|
|
89925
89925
|
function TJ(e) {
|
|
89926
89926
|
return gr({ attr: { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, child: [{ tag: "path", attr: { d: "M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20" }, child: [] }, { tag: "path", attr: { d: "M8 11h8" }, child: [] }, { tag: "path", attr: { d: "M8 7h6" }, child: [] }] })(e);
|
|
89927
89927
|
}
|
|
89928
|
-
const XGe = "1.14.
|
|
89928
|
+
const XGe = "1.14.3", ZGe = {
|
|
89929
89929
|
version: XGe
|
|
89930
89930
|
};
|
|
89931
89931
|
var df = /* @__PURE__ */ ((e) => (e.BOT = "bot", e.CLONE = "clone", e))(df || {});
|
|
@@ -693,7 +693,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Cb]+=1);const mi=({showArrowO
|
|
|
693
693
|
***************************************************************************** */function Xq(e,t){const[n,r]=I.useState(null),o=I.useMemo(()=>Object.entries(t).flat(),[t]);return I.useEffect(()=>{if(!(e!=null&&e.current))return;const i=$I.create(Object.assign(Object.assign({},t),{container:e.current}));return r(i),()=>{i.destroy()}},[e,...o]),n}const Zq=/^on([A-Z])/,Pze=e=>Zq.test(e);function Tze(e,t){const n=I.useMemo(()=>Object.entries(t).flat(),[t]);I.useEffect(()=>{if(!e)return;const r=Object.entries(t);if(!r.length)return;const o=r.map(([i,a])=>{const s=i.replace(Zq,(l,c)=>c.toLowerCase());return e.on(s,(...l)=>a(e,...l))});return()=>{o.forEach(i=>i())}},[e,...n])}I.memo(e=>{const t=I.useRef(null),[n,r]=function(o){return I.useMemo(()=>{const i=Object.assign({},o),a=Object.assign({},o);for(const s in i)Pze(s)?delete i[s]:delete a[s];return[i,a]},[o])}(e);return Tze(Xq(t,n),r),C.jsx("div",{ref:t})});function Jq(e){var{container:t}=e;const n=Xq(t,function(o,i){var a={};for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&i.indexOf(s)<0&&(a[s]=o[s]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function"){var l=0;for(s=Object.getOwnPropertySymbols(o);l<s.length;l++)i.indexOf(s[l])<0&&Object.prototype.propertyIsEnumerable.call(o,s[l])&&(a[s[l]]=o[s[l]])}return a}(e,["container"])),r=function(o){const[i,a]=I.useState(!1),[s,l]=I.useState(!1),[c,u]=I.useState(!1),[d,h]=I.useState(0);return I.useEffect(()=>{if(!o)return;const p=[o.on("load",()=>{a(!1),l(!1),h(0)}),o.on("ready",()=>{a(!0),l(!1),u(!1),h(0)}),o.on("finish",()=>{u(!0)}),o.on("play",()=>{l(!0)}),o.on("pause",()=>{l(!1)}),o.on("timeupdate",()=>{h(o.getCurrentTime())}),o.on("destroy",()=>{a(!1),l(!1)})];return()=>{p.forEach(m=>m())}},[o]),I.useMemo(()=>({isReady:i,isPlaying:s,hasFinished:c,currentTime:d}),[s,c,d,i])}(n);return I.useMemo(()=>Object.assign(Object.assign({},r),{wavesurfer:n}),[r,n])}function MI(e,t,n,r){return new(n||(n=Promise))(function(o,i){function a(c){try{l(r.next(c))}catch(u){i(u)}}function s(c){try{l(r.throw(c))}catch(u){i(u)}}function l(c){var u;c.done?o(c.value):(u=c.value,u instanceof n?u:new n(function(d){d(u)})).then(a,s)}l((r=r.apply(e,[])).next())})}typeof SuppressedError=="function"&&SuppressedError;let eG=class{constructor(){this.listeners={}}on(t,n,r){if(this.listeners[t]||(this.listeners[t]=new Set),r==null?void 0:r.once){const o=(...i)=>{this.un(t,o),n(...i)};return this.listeners[t].add(o),()=>this.un(t,o)}return this.listeners[t].add(n),()=>this.un(t,n)}un(t,n){var r;(r=this.listeners[t])===null||r===void 0||r.delete(n)}once(t,n){return this.on(t,n,{once:!0})}unAll(){this.listeners={}}emit(t,...n){this.listeners[t]&&this.listeners[t].forEach(r=>r(...n))}},_ze=class extends eG{constructor(t){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=t}onInit(){}_init(t){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}},Dze=class extends eG{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;const t=()=>{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(t))};t()}stop(){this.isRunning=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}};const kze=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];let Bze=class HJ extends _ze{constructor(t){var n,r,o,i,a,s;super(Object.assign(Object.assign({},t),{audioBitsPerSecond:(n=t.audioBitsPerSecond)!==null&&n!==void 0?n:128e3,scrollingWaveform:(r=t.scrollingWaveform)!==null&&r!==void 0&&r,scrollingWaveformWindow:(o=t.scrollingWaveformWindow)!==null&&o!==void 0?o:5,continuousWaveform:(i=t.continuousWaveform)!==null&&i!==void 0&&i,renderRecordedAudio:(a=t.renderRecordedAudio)===null||a===void 0||a,mediaRecorderTimeslice:(s=t.mediaRecorderTimeslice)!==null&&s!==void 0?s:void 0})),this.stream=null,this.mediaRecorder=null,this.dataWindow=null,this.isWaveformPaused=!1,this.lastStartTime=0,this.lastDuration=0,this.duration=0,this.micStream=null,this.recordedBlobUrl=null,this.timer=new Dze,this.subscriptions.push(this.timer.on("tick",()=>{const l=performance.now()-this.lastStartTime;this.duration=this.isPaused()?this.duration:this.lastDuration+l,this.emit("record-progress",this.duration)}))}static create(t){return new HJ(t||{})}renderMicStream(t){var n;const r=new AudioContext,o=r.createMediaStreamSource(t),i=r.createAnalyser();o.connect(i),this.options.continuousWaveform&&(i.fftSize=32);const a=i.frequencyBinCount,s=new Float32Array(a);let l=0;this.wavesurfer&&((n=this.originalOptions)!==null&&n!==void 0||(this.originalOptions=Object.assign({},this.wavesurfer.options)),this.wavesurfer.options.interact=!1,this.options.scrollingWaveform&&(this.wavesurfer.options.cursorWidth=0));const c=setInterval(()=>{var u,d,h,p;if(!this.isWaveformPaused){if(i.getFloatTimeDomainData(s),this.options.scrollingWaveform){const m=Math.floor((this.options.scrollingWaveformWindow||0)*r.sampleRate),v=Math.min(m,this.dataWindow?this.dataWindow.length+a:a),g=new Float32Array(m);if(this.dataWindow){const y=Math.max(0,m-this.dataWindow.length);g.set(this.dataWindow.slice(-v+a),y)}g.set(s,m-a),this.dataWindow=g}else if(this.options.continuousWaveform){if(!this.dataWindow){const v=this.options.continuousWaveformDuration?Math.round(100*this.options.continuousWaveformDuration):((d=(u=this.wavesurfer)===null||u===void 0?void 0:u.getWidth())!==null&&d!==void 0?d:0)*window.devicePixelRatio;this.dataWindow=new Float32Array(v)}let m=0;for(let v=0;v<a;v++){const g=Math.abs(s[v]);g>m&&(m=g)}if(l+1>this.dataWindow.length){const v=new Float32Array(2*this.dataWindow.length);v.set(this.dataWindow,0),this.dataWindow=v}this.dataWindow[l]=m,l++}else this.dataWindow=s;if(this.wavesurfer){const m=((p=(h=this.dataWindow)===null||h===void 0?void 0:h.length)!==null&&p!==void 0?p:0)/100;this.wavesurfer.load("",[this.dataWindow],this.options.scrollingWaveform?this.options.scrollingWaveformWindow:m).then(()=>{this.wavesurfer&&this.options.continuousWaveform&&(this.wavesurfer.setTime(this.getDuration()/1e3),this.wavesurfer.options.minPxPerSec||this.wavesurfer.setOptions({minPxPerSec:this.wavesurfer.getWidth()/this.wavesurfer.getDuration()}))}).catch(v=>{console.error("Error rendering real-time recording data:",v)})}}},10);return{onDestroy:()=>{clearInterval(c),o==null||o.disconnect(),r==null||r.close()},onEnd:()=>{this.isWaveformPaused=!0,this.stopMic()}}}startMic(t){return MI(this,void 0,void 0,function*(){let n;this.micStream&&this.stopMic();try{n=yield navigator.mediaDevices.getUserMedia({audio:t==null||t})}catch(o){throw new Error("Error accessing the microphone: "+o.message)}const r=this.renderMicStream(n);return this.micStream=r,this.unsubscribeDestroy=this.once("destroy",r.onDestroy),this.unsubscribeRecordEnd=this.once("record-end",r.onEnd),this.stream=n,n})}stopMic(){var t,n,r;(t=this.micStream)===null||t===void 0||t.onDestroy(),(n=this.unsubscribeDestroy)===null||n===void 0||n.call(this),(r=this.unsubscribeRecordEnd)===null||r===void 0||r.call(this),this.micStream=null,this.unsubscribeDestroy=void 0,this.unsubscribeRecordEnd=void 0,this.stream&&(this.stream.getTracks().forEach(o=>o.stop()),this.stream=null,this.mediaRecorder=null)}startRecording(t){return MI(this,void 0,void 0,function*(){const n=this.stream||(yield this.startMic(t));this.dataWindow=null;const r=this.mediaRecorder||new MediaRecorder(n,{mimeType:this.options.mimeType||kze.find(a=>MediaRecorder.isTypeSupported(a)),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=r,this.stopRecording();const o=[];r.ondataavailable=a=>{a.data.size>0&&o.push(a.data),this.emit("record-data-available",a.data)};const i=a=>{var s;const l=new Blob(o,{type:r.mimeType});this.emit(a,l),this.options.renderRecordedAudio&&(this.applyOriginalOptionsIfNeeded(),this.recordedBlobUrl&&URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=URL.createObjectURL(l),(s=this.wavesurfer)===null||s===void 0||s.load(this.recordedBlobUrl))};r.onpause=()=>i("record-pause"),r.onstop=()=>i("record-end"),r.start(this.options.mediaRecorderTimeslice),this.lastStartTime=performance.now(),this.lastDuration=0,this.duration=0,this.isWaveformPaused=!1,this.timer.start(),this.emit("record-start")})}getDuration(){return this.duration}isRecording(){var t;return((t=this.mediaRecorder)===null||t===void 0?void 0:t.state)==="recording"}isPaused(){var t;return((t=this.mediaRecorder)===null||t===void 0?void 0:t.state)==="paused"}isActive(){var t;return((t=this.mediaRecorder)===null||t===void 0?void 0:t.state)!=="inactive"}stopRecording(){var t;this.isActive()&&((t=this.mediaRecorder)===null||t===void 0||t.stop(),this.timer.stop())}pauseRecording(){var t,n;this.isRecording()&&(this.isWaveformPaused=!0,(t=this.mediaRecorder)===null||t===void 0||t.requestData(),(n=this.mediaRecorder)===null||n===void 0||n.pause(),this.timer.stop(),this.lastDuration=this.duration)}resumeRecording(){var t;this.isPaused()&&(this.isWaveformPaused=!1,(t=this.mediaRecorder)===null||t===void 0||t.resume(),this.timer.start(),this.lastStartTime=performance.now(),this.emit("record-resume"))}static getAvailableAudioDevices(){return MI(this,void 0,void 0,function*(){return navigator.mediaDevices.enumerateDevices().then(t=>t.filter(n=>n.kind==="audioinput"))})}destroy(){this.applyOriginalOptionsIfNeeded(),super.destroy(),this.stopRecording(),this.stopMic(),this.recordedBlobUrl&&(URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=null)}applyOriginalOptionsIfNeeded(){this.wavesurfer&&this.originalOptions&&(this.wavesurfer.setOptions(this.originalOptions),delete this.originalOptions)}};const tG=()=>{const{axiosInstance:e,context:{COMPANY_ID:t,CALLBOTSCENARIO_ID:n}}=Ho(),{error:r}=Bb();return kte({mutationFn:async({audio:o})=>{var a,s,l;if(!t||!n)throw new Error("COMPANY_ID and CALLBOTSCENARIO_ID are required");const i=new FormData;i.append("raw_file",o);try{return(await e.postForm(`/company/${t}/callbotscenario/${n}/file`,i)).data}catch(c){const u=c;throw r((l=(s=(a=u.response)==null?void 0:a.data)==null?void 0:s.raw_file)==null?void 0:l[0]),u}},onError:o=>{console.error("Upload audio error:",o)}})},nG=60*10,Fb=({onStartRecord:e,onFinishRecord:t})=>{const n=I.useRef(null),r=I.useRef(null),o=I.useRef(null),[i,a]=I.useState(!1),[s,l]=I.useState(0),{mutateAsync:c,isPending:u}=tG(),d=m=>{const v=Math.floor(m/60).toString().padStart(2,"0"),g=(m%60).toString().padStart(2,"0");return`${v}:${g}`};Jq({container:n,waveColor:"#b0dfff",progressColor:"#30b4ff",height:50,plugins:I.useMemo(()=>{const m=Bze.create({renderRecordedAudio:!1,continuousWaveform:!1,scrollingWaveform:!0,continuousWaveformDuration:30});return m.on("record-progress",v=>{const g=Math.floor(v/1e3);l(g),g>=nG&&h()}),m.on("record-start",()=>console.log("🎤 Recording started")),m.on("record-end",()=>console.log("✅ Recording finished")),m.on("record-data-available",async v=>{const g=`${RNe("recording")}.webm`,y=new File([v],g,{type:v.type}),A=await c({audio:y});t==null||t(A)}),r.current=m,[m]},[])});const h=()=>{r.current&&(r.current.stopRecording(),a(!1),o.current&&(clearTimeout(o.current),o.current=null))},p=()=>{r.current&&r.current.startRecording().then(()=>{a(!0),e==null||e(),l(0),o.current=setTimeout(()=>{h()},nG*1e3)}).catch(m=>console.error("Start recording failed:",m))};return C.jsxs(Ze,{gap:12,align:"center",style:{flex:1},children:[i?C.jsx(dt,{type:"text",onClick:h,disabled:u,style:{width:"40px",height:"32px",borderRadius:"8px",backgroundColor:$n.speakBlock.background,border:`1px solid ${$n.speakBlock.border}`,display:"flex",alignItems:"center",justifyContent:"center",padding:0},children:C.jsx("div",{style:{width:"12px",height:"12px",backgroundColor:$n.common.red,borderRadius:"2px"}})}):C.jsx(dt,{icon:u?C.jsx(ua,{}):C.jsx(zE,{}),onClick:p,disabled:u,loading:u,children:u?"Đang tải lên...":"Ghi âm"}),C.jsx("div",{ref:n,style:{width:"100%",height:50,overflow:"hidden",opacity:i?1:0,pointerEvents:i?"auto":"none",transition:"opacity 0.2s"}}),i&&C.jsx("div",{style:{fontSize:14,fontWeight:500,minWidth:40,textAlign:"right"},children:d(s)})]})};var Lze="scripts_editor_14vtnyz0",Fze="scripts_editor_14vtnyz1",zze="scripts_editor_14vtnyz2";const PI=({url:e,className:t,formPath:n,onDelete:r})=>{const o=ye.useFormInstance();if(!e||e==="")return C.jsx(ru,{message:"Không có file âm thanh",description:"Vui lòng tải lên file âm thanh hoặc ghi âm",type:"info",showIcon:!0,icon:C.jsx(zE,{})});const i=()=>{n&&(r==null||r(),n.forEach(a=>{o.setFieldValue(a,void 0)}))};return C.jsx("div",{className:t,children:C.jsxs("div",{className:Fze,children:[C.jsxs("audio",{controls:!0,preload:"auto","aria-label":"Audio playback",src:e,style:{height:32,maxWidth:"260px"},children:[C.jsx("track",{kind:"captions",src:"",label:"Captions"}),"Trình duyệt của bạn không hỗ trợ phát âm thanh."]}),n&&C.jsx(dt,{className:zze,danger:!0,icon:C.jsx(va,{}),"aria-label":"Delete audio",style:{marginLeft:"8px"},onClick:i})]})})};var Vze="scripts_editor_1v7rh6r0";const rG=({content:e})=>C.jsx("div",{className:Vze,children:e}),jze=({prefixPaths:e=[]})=>C.jsxs(C.Fragment,{children:[C.jsx(rG,{content:"Cắt file audio tự động có thể không chính xác bằng cắt file audio thủ công."}),C.jsx(ye.Item,{name:[...e,"record","trim"],valuePropName:"checked",children:C.jsx(Wr,{children:C.jsxs(Ze,{align:"center",gap:8,children:["Tự động cắt file ghi âm",C.jsx(tr,{title:"Hệ thống tự động cắt phần đầu và phần cuối không có âm thanh",children:C.jsx(tc,{})})]})})}),C.jsx(ye.Item,{name:[...e,"record","autoGender"],valuePropName:"checked",children:C.jsx(Wr,{children:C.jsxs(Ze,{align:"center",gap:8,children:["Tự động tạo file ghi âm nam/nữ",C.jsx(tr,{title:`Hệ thống tự động tạo file ghi âm nam/nữ từ file ghi âm gốc,
|
|
694
694
|
sử dụng trong tính năng nhận diện giới tính`,children:C.jsx(tc,{})})]})})}),C.jsx(Ze,{justify:"center",children:C.jsx(dt,{type:"primary",children:"Áp dụng"})})]});let oG=class{constructor(){this.listeners={}}on(t,n,r){if(this.listeners[t]||(this.listeners[t]=new Set),r==null?void 0:r.once){const o=(...i)=>{this.un(t,o),n(...i)};return this.listeners[t].add(o),()=>this.un(t,o)}return this.listeners[t].add(n),()=>this.un(t,n)}un(t,n){var r;(r=this.listeners[t])===null||r===void 0||r.delete(n)}once(t,n){return this.on(t,n,{once:!0})}unAll(){this.listeners={}}emit(t,...n){this.listeners[t]&&this.listeners[t].forEach(r=>r(...n))}},Hze=class extends oG{constructor(t){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=t}onInit(){}_init(t){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}};function zb(e,t,n,r,o=3,i=0,a=100){if(!e)return()=>{};const s=matchMedia("(pointer: coarse)").matches;let l=()=>{};const c=u=>{if(u.button!==i)return;u.preventDefault(),u.stopPropagation();let d=u.clientX,h=u.clientY,p=!1;const m=Date.now(),v=S=>{if(S.preventDefault(),S.stopPropagation(),s&&Date.now()-m<a)return;const E=S.clientX,N=S.clientY,O=E-d,$=N-h;if(p||Math.abs(O)>o||Math.abs($)>o){const M=e.getBoundingClientRect(),{left:P,top:_}=M;p||(n==null||n(d-P,h-_),p=!0),t(O,$,E-P,N-_),d=E,h=N}},g=S=>{if(p){const E=S.clientX,N=S.clientY,O=e.getBoundingClientRect(),{left:$,top:M}=O;r==null||r(E-$,N-M)}l()},y=S=>{S.relatedTarget&&S.relatedTarget!==document.documentElement||g(S)},A=S=>{p&&(S.stopPropagation(),S.preventDefault())},w=S=>{p&&S.preventDefault()};document.addEventListener("pointermove",v),document.addEventListener("pointerup",g),document.addEventListener("pointerout",y),document.addEventListener("pointercancel",y),document.addEventListener("touchmove",w,{passive:!1}),document.addEventListener("click",A,{capture:!0}),l=()=>{document.removeEventListener("pointermove",v),document.removeEventListener("pointerup",g),document.removeEventListener("pointerout",y),document.removeEventListener("pointercancel",y),document.removeEventListener("touchmove",w),setTimeout(()=>{document.removeEventListener("click",A,{capture:!0})},10)}};return e.addEventListener("pointerdown",c),()=>{l(),e.removeEventListener("pointerdown",c)}}function iG(e,t){const n=t.xmlns?document.createElementNS(t.xmlns,e):document.createElement(e);for(const[r,o]of Object.entries(t))if(r==="children"&&o)for(const[i,a]of Object.entries(o))a instanceof Node?n.appendChild(a):typeof a=="string"?n.appendChild(document.createTextNode(a)):n.appendChild(iG(i,a));else r==="style"?Object.assign(n.style,o):r==="textContent"?n.textContent=o:n.setAttribute(r,o.toString());return n}function fm(e,t,n){const r=iG(e,t||{});return n==null||n.appendChild(r),r}let aG=class extends oG{constructor(t,n,r=0){var o,i,a,s,l,c,u,d,h,p;super(),this.totalDuration=n,this.numberOfChannels=r,this.element=null,this.minLength=0,this.maxLength=1/0,this.contentEditable=!1,this.subscriptions=[],this.updatingSide=void 0,this.isRemoved=!1,this.subscriptions=[],this.id=t.id||`region-${Math.random().toString(32).slice(2)}`,this.start=this.clampPosition(t.start),this.end=this.clampPosition((o=t.end)!==null&&o!==void 0?o:t.start),this.drag=(i=t.drag)===null||i===void 0||i,this.resize=(a=t.resize)===null||a===void 0||a,this.resizeStart=(s=t.resizeStart)===null||s===void 0||s,this.resizeEnd=(l=t.resizeEnd)===null||l===void 0||l,this.color=(c=t.color)!==null&&c!==void 0?c:"rgba(0, 0, 0, 0.1)",this.minLength=(u=t.minLength)!==null&&u!==void 0?u:this.minLength,this.maxLength=(d=t.maxLength)!==null&&d!==void 0?d:this.maxLength,this.channelIdx=(h=t.channelIdx)!==null&&h!==void 0?h:-1,this.contentEditable=(p=t.contentEditable)!==null&&p!==void 0?p:this.contentEditable,this.element=this.initElement(),this.setContent(t.content),this.setPart(),this.renderPosition(),this.initMouseEvents()}clampPosition(t){return Math.max(0,Math.min(this.totalDuration,t))}setPart(){var t;const n=this.start===this.end;(t=this.element)===null||t===void 0||t.setAttribute("part",`${n?"marker":"region"} ${this.id}`)}addResizeHandles(t){const n={position:"absolute",zIndex:"2",width:"6px",height:"100%",top:"0",cursor:"ew-resize",wordBreak:"keep-all"},r=fm("div",{part:"region-handle region-handle-left",style:Object.assign(Object.assign({},n),{left:"0",borderLeft:"2px solid rgba(0, 0, 0, 0.5)",borderRadius:"2px 0 0 2px"})},t),o=fm("div",{part:"region-handle region-handle-right",style:Object.assign(Object.assign({},n),{right:"0",borderRight:"2px solid rgba(0, 0, 0, 0.5)",borderRadius:"0 2px 2px 0"})},t);this.subscriptions.push(zb(r,i=>this.onResize(i,"start"),()=>null,()=>this.onEndResizing("start"),1),zb(o,i=>this.onResize(i,"end"),()=>null,()=>this.onEndResizing("end"),1))}removeResizeHandles(t){const n=t.querySelector('[part*="region-handle-left"]'),r=t.querySelector('[part*="region-handle-right"]');n&&t.removeChild(n),r&&t.removeChild(r)}initElement(){if(this.isRemoved)return null;const t=this.start===this.end;let n=0,r=100;this.channelIdx>=0&&this.numberOfChannels>0&&this.channelIdx<this.numberOfChannels&&(r=100/this.numberOfChannels,n=r*this.channelIdx);const o=fm("div",{style:{position:"absolute",top:`${n}%`,height:`${r}%`,backgroundColor:t?"none":this.color,borderLeft:t?"2px solid "+this.color:"none",borderRadius:"2px",boxSizing:"border-box",transition:"background-color 0.2s ease",cursor:this.drag?"grab":"default",pointerEvents:"all"}});return!t&&this.resize&&this.addResizeHandles(o),o}renderPosition(){if(!this.element)return;const t=this.start/this.totalDuration,n=(this.totalDuration-this.end)/this.totalDuration;this.element.style.left=100*t+"%",this.element.style.right=100*n+"%"}toggleCursor(t){var n;this.drag&&(!((n=this.element)===null||n===void 0)&&n.style)&&(this.element.style.cursor=t?"grabbing":"grab")}initMouseEvents(){const{element:t}=this;t&&(t.addEventListener("click",n=>this.emit("click",n)),t.addEventListener("mouseenter",n=>this.emit("over",n)),t.addEventListener("mouseleave",n=>this.emit("leave",n)),t.addEventListener("dblclick",n=>this.emit("dblclick",n)),t.addEventListener("pointerdown",()=>this.toggleCursor(!0)),t.addEventListener("pointerup",()=>this.toggleCursor(!1)),this.subscriptions.push(zb(t,n=>this.onMove(n),()=>this.toggleCursor(!0),()=>{this.toggleCursor(!1),this.drag&&this.emit("update-end")})),this.contentEditable&&this.content&&(this.contentClickListener=n=>this.onContentClick(n),this.contentBlurListener=()=>this.onContentBlur(),this.content.addEventListener("click",this.contentClickListener),this.content.addEventListener("blur",this.contentBlurListener)))}_onUpdate(t,n,r){var o;if(!(!((o=this.element)===null||o===void 0)&&o.parentElement))return;const{width:i}=this.element.parentElement.getBoundingClientRect(),a=t/i*this.totalDuration;let s=n&&n!=="start"?this.start:this.start+a,l=n&&n!=="end"?this.end:this.end+a;const c=r!==void 0;c&&this.updatingSide&&this.updatingSide!==n&&(this.updatingSide==="start"?s=r:l=r),s=Math.max(0,s),l=Math.min(this.totalDuration,l);const u=l-s;this.updatingSide=n;const d=u>=this.minLength&&u<=this.maxLength;s<=l&&(d||c)&&(this.start=s,this.end=l,this.renderPosition(),this.emit("update",n))}onMove(t){this.drag&&this._onUpdate(t)}onResize(t,n){this.resize&&(this.resizeStart||n!=="start")&&(this.resizeEnd||n!=="end")&&this._onUpdate(t,n)}onEndResizing(t){this.resize&&(this.emit("update-end",t),this.updatingSide=void 0)}onContentClick(t){t.stopPropagation(),t.target.focus(),this.emit("click",t)}onContentBlur(){this.emit("update-end")}_setTotalDuration(t){this.totalDuration=t,this.renderPosition()}play(t){this.emit("play",t&&this.end!==this.start?this.end:void 0)}getContent(t=!1){var n;return t?this.content||void 0:this.element instanceof HTMLElement?((n=this.content)===null||n===void 0?void 0:n.innerHTML)||void 0:""}setContent(t){var n;if(this.element)if(this.content&&this.contentEditable&&(this.contentClickListener&&this.content.removeEventListener("click",this.contentClickListener),this.contentBlurListener&&this.content.removeEventListener("blur",this.contentBlurListener)),(n=this.content)===null||n===void 0||n.remove(),t){if(typeof t=="string"){const r=this.start===this.end;this.content=fm("div",{style:{padding:`0.2em ${r?.2:.4}em`,display:"inline-block"},textContent:t})}else this.content=t;this.contentEditable&&(this.content.contentEditable="true",this.contentClickListener=r=>this.onContentClick(r),this.contentBlurListener=()=>this.onContentBlur(),this.content.addEventListener("click",this.contentClickListener),this.content.addEventListener("blur",this.contentBlurListener)),this.content.setAttribute("part","region-content"),this.element.appendChild(this.content),this.emit("content-changed")}else this.content=void 0}setOptions(t){var n,r;if(this.element){if(t.color&&(this.color=t.color,this.element.style.backgroundColor=this.color),t.drag!==void 0&&(this.drag=t.drag,this.element.style.cursor=this.drag?"grab":"default"),t.start!==void 0||t.end!==void 0){const o=this.start===this.end;this.start=this.clampPosition((n=t.start)!==null&&n!==void 0?n:this.start),this.end=this.clampPosition((r=t.end)!==null&&r!==void 0?r:o?this.start:this.end),this.renderPosition(),this.setPart()}if(t.content&&this.setContent(t.content),t.id&&(this.id=t.id,this.setPart()),t.resize!==void 0&&t.resize!==this.resize){const o=this.start===this.end;this.resize=t.resize,this.resize&&!o?this.addResizeHandles(this.element):this.removeResizeHandles(this.element)}t.resizeStart!==void 0&&(this.resizeStart=t.resizeStart),t.resizeEnd!==void 0&&(this.resizeEnd=t.resizeEnd)}}remove(){this.isRemoved=!0,this.emit("remove"),this.subscriptions.forEach(t=>t()),this.element&&(this.element.remove(),this.element=null)}};class TI extends Hze{constructor(t){super(t),this.regions=[],this.regionsContainer=this.initRegionsContainer()}static create(t){return new TI(t)}onInit(){if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");this.wavesurfer.getWrapper().appendChild(this.regionsContainer),this.subscriptions.push(this.wavesurfer.on("ready",n=>{this.regions.forEach(r=>r._setTotalDuration(n))}));let t=[];this.subscriptions.push(this.wavesurfer.on("timeupdate",n=>{const r=this.regions.filter(o=>o.start<=n&&(o.end===o.start?o.start+.05:o.end)>=n);r.forEach(o=>{t.includes(o)||this.emit("region-in",o)}),t.forEach(o=>{r.includes(o)||this.emit("region-out",o)}),t=r}))}initRegionsContainer(){return fm("div",{part:"regions-container",style:{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",zIndex:"5",pointerEvents:"none"}})}getRegions(){return this.regions}avoidOverlapping(t){t.content&&setTimeout(()=>{const n=t.content,r=n.getBoundingClientRect(),o=this.regions.map(i=>{if(i===t||!i.content)return 0;const a=i.content.getBoundingClientRect();return r.left<a.left+a.width&&a.left<r.left+r.width?a.height:0}).reduce((i,a)=>i+a,0);n.style.marginTop=`${o}px`},10)}adjustScroll(t){var n,r;if(!t.element)return;const o=(r=(n=this.wavesurfer)===null||n===void 0?void 0:n.getWrapper())===null||r===void 0?void 0:r.parentElement;if(!o)return;const{clientWidth:i,scrollWidth:a}=o;if(a<=i)return;const s=o.getBoundingClientRect(),l=t.element.getBoundingClientRect(),c=l.left-s.left,u=l.right-s.left;c<0?o.scrollLeft+=c:u>i&&(o.scrollLeft+=u-i)}virtualAppend(t,n,r){const o=()=>{if(!this.wavesurfer)return;const i=this.wavesurfer.getWidth(),a=this.wavesurfer.getScroll(),s=n.clientWidth,l=this.wavesurfer.getDuration(),c=Math.round(t.start/l*s),u=c+(Math.round((t.end-t.start)/l*s)||1)>a&&c<a+i;u&&!r.parentElement?n.appendChild(r):!u&&r.parentElement&&r.remove()};setTimeout(()=>{if(!this.wavesurfer||!t.element)return;o();const i=this.wavesurfer.on("scroll",o),a=this.wavesurfer.on("zoom",o);this.subscriptions.push(i,a),t.once("remove",()=>{i(),a()})},0)}saveRegion(t){if(!t.element)return;this.virtualAppend(t,this.regionsContainer,t.element),this.avoidOverlapping(t),this.regions.push(t);const n=[t.on("update",r=>{r||this.adjustScroll(t),this.emit("region-update",t,r)}),t.on("update-end",r=>{this.avoidOverlapping(t),this.emit("region-updated",t,r)}),t.on("play",r=>{var o;(o=this.wavesurfer)===null||o===void 0||o.play(t.start,r)}),t.on("click",r=>{this.emit("region-clicked",t,r)}),t.on("dblclick",r=>{this.emit("region-double-clicked",t,r)}),t.on("content-changed",()=>{this.emit("region-content-changed",t)}),t.once("remove",()=>{n.forEach(r=>r()),this.regions=this.regions.filter(r=>r!==t),this.emit("region-removed",t)})];this.subscriptions.push(...n),this.emit("region-created",t)}addRegion(t){var n,r;if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");const o=this.wavesurfer.getDuration(),i=(r=(n=this.wavesurfer)===null||n===void 0?void 0:n.getDecodedData())===null||r===void 0?void 0:r.numberOfChannels,a=new aG(t,o,i);return this.emit("region-initialized",a),o?this.saveRegion(a):this.subscriptions.push(this.wavesurfer.once("ready",s=>{a._setTotalDuration(s),this.saveRegion(a)})),a}enableDragSelection(t,n=3){var r;const o=(r=this.wavesurfer)===null||r===void 0?void 0:r.getWrapper();if(!(o&&o instanceof HTMLElement))return()=>{};let i=null,a=0,s=0;return zb(o,(l,c,u)=>{i&&i._onUpdate(l,u>a?"end":"start",s)},l=>{var c,u;if(a=l,!this.wavesurfer)return;const d=this.wavesurfer.getDuration(),h=(u=(c=this.wavesurfer)===null||c===void 0?void 0:c.getDecodedData())===null||u===void 0?void 0:u.numberOfChannels,{width:p}=this.wavesurfer.getWrapper().getBoundingClientRect();s=a/p*d;const m=l/p*d,v=(l+5)/p*d;i=new aG(Object.assign(Object.assign({},t),{start:m,end:v}),d,h),this.emit("region-initialized",i),i.element&&this.regionsContainer.appendChild(i.element)},()=>{i&&(this.saveRegion(i),i.updatingSide=void 0,i=null)},n)}clearRegions(){this.regions.slice().forEach(t=>t.remove()),this.regions=[]}destroy(){this.clearRegions(),super.destroy(),this.regionsContainer.remove()}}let Rze=class{constructor(){this.listeners={}}on(t,n,r){if(this.listeners[t]||(this.listeners[t]=new Set),r==null?void 0:r.once){const o=(...i)=>{this.un(t,o),n(...i)};return this.listeners[t].add(o),()=>this.un(t,o)}return this.listeners[t].add(n),()=>this.un(t,n)}un(t,n){var r;(r=this.listeners[t])===null||r===void 0||r.delete(n)}once(t,n){return this.on(t,n,{once:!0})}unAll(){this.listeners={}}emit(t,...n){this.listeners[t]&&this.listeners[t].forEach(r=>r(...n))}},Wze=class extends Rze{constructor(t){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=t}onInit(){}_init(t){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}};function sG(e,t){const n=t.xmlns?document.createElementNS(t.xmlns,e):document.createElement(e);for(const[r,o]of Object.entries(t))if(r==="children"&&o)for(const[i,a]of Object.entries(o))a instanceof Node?n.appendChild(a):typeof a=="string"?n.appendChild(document.createTextNode(a)):n.appendChild(sG(i,a));else r==="style"?Object.assign(n.style,o):r==="textContent"?n.textContent=o:n.setAttribute(r,o.toString());return n}function _I(e,t,n){return sG(e,t||{})}const Qze={height:20,timeOffset:0,formatTimeCallback:e=>e/60>1?`${Math.floor(e/60)}:${`${(e=Math.round(e%60))<10?"0":""}${e}`}`:`${Math.round(1e3*e)/1e3}`};class DI extends Wze{constructor(t){super(t||{}),this.unsubscribeNotches=[],this.notchElements=new Map,this.options=Object.assign({},Qze,t),this.timelineWrapper=this.initTimelineWrapper()}static create(t){return new DI(t)}onInit(){var t;if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");let n=this.wavesurfer.getWrapper();if(this.options.container instanceof HTMLElement)n=this.options.container;else if(typeof this.options.container=="string"){const r=document.querySelector(this.options.container);if(!r)throw Error(`No Timeline container found matching ${this.options.container}`);n=r}this.options.insertPosition?(n.firstElementChild||n).insertAdjacentElement(this.options.insertPosition,this.timelineWrapper):n.appendChild(this.timelineWrapper),this.subscriptions.push(this.wavesurfer.on("redraw",()=>this.initTimeline())),(!((t=this.wavesurfer)===null||t===void 0)&&t.getDuration()||this.options.duration)&&this.initTimeline()}destroy(){this.unsubscribeNotches.forEach(t=>t()),this.unsubscribeNotches=[],this.timelineWrapper.remove(),super.destroy()}initTimelineWrapper(){return _I("div",{part:"timeline-wrapper",style:{pointerEvents:"none"}})}defaultTimeInterval(t){return t>=25?1:5*t>=25?5:15*t>=25?15:60*Math.ceil(.5/t)}defaultPrimaryLabelInterval(t){return t>=25?10:5*t>=25?6:4}defaultSecondaryLabelInterval(t){return t>=25?5:2}virtualAppend(t,n,r){if(this.notchElements.set(r,{start:t,width:r.clientWidth,wasVisible:!1}),!this.wavesurfer)return;const o=this.wavesurfer.getScroll(),i=o+this.wavesurfer.getWidth(),a=this.notchElements.get(r),s=t>=o&&t+a.width<i;a.wasVisible=s,s&&n.appendChild(r)}updateVisibleNotches(t,n,r){this.notchElements.forEach((o,i)=>{const a=o.start>=t&&o.start+o.width<n;a!==o.wasVisible&&(o.wasVisible=a,a?r.appendChild(i):i.remove())})}initTimeline(){var t,n,r,o,i,a,s,l;this.unsubscribeNotches.forEach(w=>w()),this.unsubscribeNotches=[],this.notchElements.clear();const c=(r=(n=(t=this.wavesurfer)===null||t===void 0?void 0:t.getDuration())!==null&&n!==void 0?n:this.options.duration)!==null&&r!==void 0?r:0,u=(((o=this.wavesurfer)===null||o===void 0?void 0:o.getWrapper().scrollWidth)||this.timelineWrapper.scrollWidth)/c,d=(i=this.options.timeInterval)!==null&&i!==void 0?i:this.defaultTimeInterval(u),h=(a=this.options.primaryLabelInterval)!==null&&a!==void 0?a:this.defaultPrimaryLabelInterval(u),p=this.options.primaryLabelSpacing,m=(s=this.options.secondaryLabelInterval)!==null&&s!==void 0?s:this.defaultSecondaryLabelInterval(u),v=this.options.secondaryLabelSpacing,g=this.options.insertPosition==="beforebegin",y=_I("div",{style:Object.assign({height:`${this.options.height}px`,overflow:"hidden",fontSize:this.options.height/2+"px",whiteSpace:"nowrap"},g?{position:"absolute",top:"0",left:"0",right:"0",zIndex:"2"}:{position:"relative"})});y.setAttribute("part","timeline"),typeof this.options.style=="string"?y.setAttribute("style",y.getAttribute("style")+this.options.style):typeof this.options.style=="object"&&Object.assign(y.style,this.options.style);const A=_I("div",{style:{width:"0",height:"50%",display:"flex",flexDirection:"column",justifyContent:g?"flex-start":"flex-end",top:g?"0":"auto",bottom:g?"auto":"0",overflow:"visible",borderLeft:"1px solid currentColor",opacity:`${(l=this.options.secondaryLabelOpacity)!==null&&l!==void 0?l:.25}`,position:"absolute",zIndex:"1"}});for(let w=0,S=0;w<c;w+=d,S++){const E=A.cloneNode(),N=Math.round(100*w)%Math.round(100*h)==0||p&&S%p==0,O=Math.round(100*w)%Math.round(100*m)==0||v&&S%v==0;(N||O)&&(E.style.height="100%",E.style.textIndent="3px",E.textContent=this.options.formatTimeCallback(w),N&&(E.style.opacity="1"));const $=N?"primary":O?"secondary":"tick";E.setAttribute("part",`timeline-notch timeline-notch-${$}`);const M=Math.round(100*(w+this.options.timeOffset))/100*u;E.style.left=`${M}px`,this.virtualAppend(M,y,E)}this.timelineWrapper.innerHTML="",this.timelineWrapper.appendChild(y),this.wavesurfer&&this.unsubscribeNotches.push(this.wavesurfer.on("scroll",(w,S,E,N)=>{this.updateVisibleNotches(E,N,y)})),this.emit("ready")}}class Kze{constructor(){this.listeners={}}on(t,n,r){if(this.listeners[t]||(this.listeners[t]=new Set),r==null?void 0:r.once){const o=(...i)=>{this.un(t,o),n(...i)};return this.listeners[t].add(o),()=>this.un(t,o)}return this.listeners[t].add(n),()=>this.un(t,n)}un(t,n){var r;(r=this.listeners[t])===null||r===void 0||r.delete(n)}once(t,n){return this.on(t,n,{once:!0})}unAll(){this.listeners={}}emit(t,...n){this.listeners[t]&&this.listeners[t].forEach(r=>r(...n))}}class qze extends Kze{constructor(t){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=t}onInit(){}_init(t){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}}const Gze={scale:.5,deltaThreshold:5,exponentialZooming:!1,iterations:20};class kI extends qze{constructor(t){super(t||{}),this.wrapper=void 0,this.container=null,this.accumulatedDelta=0,this.pointerTime=0,this.oldX=0,this.endZoom=0,this.startZoom=0,this.onWheel=n=>{if(this.wavesurfer&&this.container&&!(Math.abs(n.deltaX)>=Math.abs(n.deltaY))&&(n.preventDefault(),this.accumulatedDelta+=-n.deltaY,this.startZoom===0&&this.options.exponentialZooming&&(this.startZoom=this.wavesurfer.getWrapper().clientWidth/this.wavesurfer.getDuration()),this.options.deltaThreshold===0||Math.abs(this.accumulatedDelta)>=this.options.deltaThreshold)){const r=this.wavesurfer.getDuration(),o=this.wavesurfer.options.minPxPerSec===0?this.wavesurfer.getWrapper().scrollWidth/r:this.wavesurfer.options.minPxPerSec,i=n.clientX-this.container.getBoundingClientRect().left,a=this.container.clientWidth,s=this.wavesurfer.getScroll();i===this.oldX&&this.oldX!==0||(this.pointerTime=(s+i)/o),this.oldX=i;const l=this.calculateNewZoom(o,this.accumulatedDelta),c=a/l*(i/a);l*r<a?(this.wavesurfer.zoom(a/r),this.container.scrollLeft=0):(this.wavesurfer.zoom(l),this.container.scrollLeft=(this.pointerTime-c)*l),this.accumulatedDelta=0}},this.calculateNewZoom=(n,r)=>{let o;if(this.options.exponentialZooming){const i=r>0?Math.pow(this.endZoom/this.startZoom,1/(this.options.iterations-1)):Math.pow(this.startZoom/this.endZoom,1/(this.options.iterations-1));o=Math.max(0,n*i)}else o=Math.max(0,n+r*this.options.scale);return Math.min(o,this.options.maxZoom)},this.options=Object.assign({},Gze,t)}static create(t){return new kI(t)}onInit(){var t;this.wrapper=(t=this.wavesurfer)===null||t===void 0?void 0:t.getWrapper(),this.wrapper&&(this.container=this.wrapper.parentElement,this.container.addEventListener("wheel",this.onWheel),this.options.maxZoom===void 0&&(this.options.maxZoom=this.container.clientWidth),this.endZoom=this.options.maxZoom)}destroy(){this.container&&this.container.removeEventListener("wheel",this.onWheel),super.destroy()}}const lG=e=>[e/60,e%60].map(t=>`0${Math.floor(t)}`.slice(-2)).join(":"),Uze=({prefixPaths:e=[]})=>{const t=I.useRef(null),n=I.useRef(null),r=I.useRef(null),[o,i]=I.useState(0),[a,s]=I.useState(0),[l,c]=I.useState(!1),[u,d]=I.useState(null),h=ye.useFormInstance(),p=h.getFieldValue([...e,"title"]),m=h.getFieldValue([...e,"record","transcript_original"]),{wavesurfer:v}=Jq({container:t,height:60,waveColor:"#b0dfff",progressColor:"#30b4ff",interact:!0,dragToSeek:!1,url:h.getFieldValue([...e,"record","default_record"]),plugins:I.useMemo(()=>{const y=kI.create({scale:.5,maxZoom:100,deltaThreshold:5,exponentialZooming:!0}),A=DI.create({insertPosition:"afterend",height:15,timeInterval:1,primaryLabelInterval:5,secondaryLabelInterval:1,style:{fontSize:"10px"}}),w=TI.create({dragSelection:!1});return r.current=A,n.current=w,[y,A,w]},[])});I.useEffect(()=>{if(!v)return;const y=n.current;if(y)return y.enableDragSelection({slop:5}),y.on("region-created",A=>{console.log("🟢 Created region:",A.start,A.end),Object.assign(A.element.style,{border:"2px solid rgba(255,165,0,0.8)",borderRadius:"6px",backgroundColor:"transparent",boxSizing:"border-box"}),A.element.querySelectorAll('[part~="region-handle"]').forEach(w=>{Object.assign(w.style,{border:"none",background:"transparent",borderRadius:"0"})})}),y.on("region-updated",A=>{console.log("✏️ Updated region:",A.start,A.end)}),y.on("region-clicked",(A,w)=>{w.stopPropagation(),y.getRegions().forEach(S=>{Object.assign(S.element.style,{border:"2px solid rgba(255,165,0,0.8)",backgroundColor:"transparent"}),S.element.classList.remove("wavesurfer-region-active")}),Object.assign(A.element.style,{border:"2px solid rgba(255,165,0,0.8)",backgroundColor:"rgba(255,165,0,0.25)"}),A.element.classList.add("wavesurfer-region-active"),d(A)}),v.on("audioprocess",A=>s(A)),v.on("ready",()=>i(v.getDuration())),v.on("play",()=>c(!0)),v.on("pause",()=>c(!1)),()=>{y.unAll()}},[v]);const g=I.useCallback(()=>{v==null||v.playPause()},[v]);return I.useEffect(()=>{const y=A=>{u&&(A.key==="Delete"||A.key==="Backspace")&&(A.preventDefault(),u.remove(),d(null))};return window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y)}},[u]),C.jsxs(C.Fragment,{children:[C.jsx(rG,{content:C.jsxs("ul",{style:{margin:0,paddingLeft:10},children:[C.jsx("li",{children:"Cắt thủ công áp dụng cho từng file audio."}),C.jsx("li",{children:"Kéo vị trí khung anh/chị để cắt từ anh/chị từ audio gốc."}),C.jsx("li",{children:"Kéo nút || trên thanh công cụ để cắt bỏ phần đầu và phần cuối không mong muốn."})]})}),C.jsx(hi,{children:C.jsxs(Ze,{vertical:!0,gap:20,align:"center",children:[C.jsxs(Ur,{style:{width:"100%"},children:[C.jsx(dn,{span:4,children:C.jsx(Ke.Text,{strong:!0,children:p})}),C.jsx(dn,{span:20,children:C.jsx(Ke.Text,{italic:!0,type:"secondary",children:m})})]}),C.jsxs(Ur,{style:{width:"100%"},children:[C.jsx(dn,{span:5,style:{display:"flex",alignItems:"center"},children:C.jsxs(Ze,{align:"center",gap:12,children:[C.jsx(dt,{size:"large",icon:l?C.jsx(tz,{}):C.jsx(oz,{}),type:"primary",onClick:g}),C.jsxs(Ke.Text,{strong:!0,children:[lG(a),"/",lG(o)]})]})}),C.jsx(dn,{span:19,children:C.jsx("div",{ref:t})})]}),C.jsx(dt,{icon:C.jsx(Nu,{}),style:{color:"white",backgroundColor:$n.button.volcano},children:"Tạo file nam/nữ"})]})})]})},Yze=({onConfirm:e})=>{const{isOpen:t,onToggle:n}=Xr(),r=()=>{e(),n()};return C.jsx(Jl,{open:t,title:"Khôi phục tất cả audio gốc",description:"Bạn có chắc chắn muốn khôi phục audio gốc",onConfirm:r,onCancel:n,okText:"Có",cancelText:"Không",children:C.jsx(dt,{onClick:n,className:"float-right",type:"link",icon:C.jsx(sz,{}),children:"Khôi phục tất cả audio gốc"})})},Xze=({prefixPaths:e=[]})=>{const t=ye.useFormInstance();return ye.useWatch([...e,"record","volume"],t),ye.useWatch([...e,"record","speed"],t),C.jsxs(C.Fragment,{children:[C.jsxs(Ur,{gutter:8,align:"middle",children:[C.jsx(dn,{xs:20,sm:18,md:20,children:C.jsx(ye.Item,{name:[...e,"record","volume"],label:"Âm lượng",labelCol:{span:4},labelAlign:"left",children:C.jsx(bE,{min:.1,max:2,step:.1,tooltip:{open:!1}})})}),C.jsx(dn,{xs:4,sm:6,md:4,children:C.jsx(ye.Item,{name:[...e,"record","volume"],labelAlign:"left",children:C.jsx($s,{min:.1,max:2,step:.1,style:{width:"100%"}})})})]}),C.jsxs(Ur,{gutter:8,align:"middle",children:[C.jsx(dn,{xs:20,sm:18,md:20,children:C.jsx(ye.Item,{name:[...e,"record","speed"],label:"Tốc độ",labelCol:{span:4},labelAlign:"left",children:C.jsx(bE,{min:.1,max:2,step:.1,tooltip:{open:!1}})})}),C.jsx(dn,{xs:4,sm:6,md:4,children:C.jsx(ye.Item,{name:[...e,"record","speed"],labelAlign:"left",children:C.jsx($s,{min:.1,max:2,step:.1,style:{width:"100%"}})})})]}),C.jsx(Ze,{justify:"center",children:C.jsx(dt,{type:"primary",children:"Áp dụng"})})]})},Zze=({prefixPaths:e=[]})=>{const[t,n]=I.useState(!0),{isOpen:r,onOpen:o,onToggle:i}=Xr(),s=ye.useFormInstance().getFieldValue([...e,"title"]);return C.jsxs(C.Fragment,{children:[C.jsx(dt,{type:"text",onClick:o,icon:C.jsx(bf,{})}),C.jsx(Ir,{title:"Chỉnh sửa file ghi âm",open:r,onCancel:i,onOk:i,destroyOnHidden:!0,width:900,footer:[C.jsx(dt,{type:"primary",onClick:i,children:"Hoàn thành"},"submit")],children:C.jsxs(Ze,{vertical:!0,gap:12,children:[C.jsxs(Ze,{justify:"space-between",children:[C.jsx(Ke.Paragraph,{strong:!0,children:`File ghi âm ${s}`}),C.jsx(Yze,{onConfirm:()=>{}})]}),C.jsxs(Qi,{theme:{components:{Collapse:{headerBg:$n.collapseHeaderBg.background}}},children:[C.jsx($0,{size:"small",defaultActiveKey:["1"],items:[{key:"1",label:"Âm lượng & Tốc độ",children:C.jsx(Xze,{})}]}),C.jsx($0,{size:"small",defaultActiveKey:["1"],items:[{key:"1",label:C.jsxs(Kn,{children:[C.jsx(Ke.Text,{children:"Trim audio & cắt file nam/nữ"}),C.jsx(ya,{icon:C.jsx(H1,{}),color:"volcano",onClick:l=>{l.stopPropagation(),l.preventDefault(),n(!t)},children:t?"Cắt file thủ công":"Cắt file tự động"})]}),children:t?C.jsx(jze,{}):C.jsx(Uze,{})}]})]})]})})]})},{TextArea:Jze}=jt,eVe=({placeholder:e="Vui lòng tải lên ghi âm để cá nhân hoá",rows:t=4})=>{const n=mf(),r=I.useRef(null),{isOpen:o,onOpen:i,onClose:a}=Xr(),[s,l]=I.useState(""),[c,u]=I.useState("confirm"),d=w=>{},h=w=>{var O;const S=r.current;if(!S)return;const E=(O=S.resizableTextArea)==null?void 0:O.textArea;if(!E)return;const N=E.value.substring(E.selectionStart,E.selectionEnd);N.trim()?(l(N),u("confirm"),i()):a()},p=()=>{u("configure")},m=()=>{a(),l(""),u("confirm")},v=()=>{var P;const w=r.current;if(!w)return;const S=(P=w.resizableTextArea)==null?void 0:P.textArea;if(!S)return;const E=S.value,N=E.substring(0,S.selectionStart),O=E.substring(S.selectionEnd),$=prompt("Nhập tên biến"),M=N+`{{${$}}}`+O;n.setFieldValue(["record","transcript_personalize"],M),n.submit(),a(),l(""),u("confirm")},g=()=>{a(),l(""),u("confirm")},y=()=>C.jsxs("div",{style:{minWidth:"300px"},children:[C.jsx("div",{style:{marginBottom:"16px"},children:C.jsxs(Ke.Text,{children:["Bạn muốn thay thế cụm từ ",C.jsx("strong",{children:s})," bằng biến?"]})}),C.jsx(oo,{isOpen:c==="configure",children:C.jsx("div",{children:C.jsx("div",{style:{padding:"16px",backgroundColor:"#f5f5f5",borderRadius:"8px"},children:C.jsx("p",{children:"TODO: Component tìm kiếm tên trường"})})})})]}),A=()=>c==="confirm"?{onConfirm:p,onCancel:m,okText:"Thêm biến",cancelText:"Hủy"}:{onConfirm:v,onCancel:g,okText:"Thêm biến",cancelText:"Hủy"};return C.jsxs(C.Fragment,{children:[C.jsx(Jl,{title:y(),...A(),open:o,icon:!1,children:C.jsx(Ke.Text,{type:"secondary",children:"Xoá cụm từ trong kịch bản, sau đó điền biến vào chỗ vừa xoá bằng cách nhập {{ten_bien}}."})}),C.jsx(Jze,{ref:r,placeholder:e,rows:t,value:n.getFieldValue(["record","transcript_personalize"]),onChange:d,onMouseUp:h,style:{width:"100%",border:"none",borderRadius:sj.block.rounded.borderRadius,backgroundColor:$n.common.gray,padding:"12px",marginTop:"12px",fontSize:"14px",lineHeight:"1.5",resize:"none"}})]})},Vb=({onUploadSuccess:e,fieldName:t="audio",disabled:n=!1,beforeUpload:r})=>{const{mutateAsync:o,isPending:i}=tG(),a=Bb(),s=async c=>await o({audio:c}),l={name:t,accept:".mp3,.wav,.m4a",showUploadList:!1,beforeUpload:async c=>{if(r==null||r(),!["audio/mp3","audio/mpeg","audio/wav","audio/x-wav","audio/m4a","audio/x-m4a"].includes(c.type))return a.error("Chỉ chấp nhận file audio (mp3, wav, m4a)"),!1;if(!(c.size/1024/1024<50))return a.error("File phải nhỏ hơn 50MB!"),!1;try{const h=await s(c);e==null||e(h)}catch(h){a.error("Tải lên audio thất bại!"),console.error("Upload error:",h)}return!1}};return C.jsx(vg,{...l,children:C.jsx(dt,{icon:i?C.jsx(ua,{}):C.jsx(hz,{}),disabled:n||i,loading:i,children:i?"Đang tải lên...":"Tải lên"})})},{TextArea:BI}=jt,{Text:hm}=Ke,tVe=({prefixPaths:e=[]})=>{const[t,n]=I.useState(),r=ye.useWatch([...e,"record","detect_gender"]),o=ye.useWatch([...e,"record","personalize"]),i=mf(),a=ye.useWatch([...e,"record","default_record"],i),s=ye.useWatch([...e,"record","male_record"],i),l=ye.useWatch([...e,"record","female_record"],i);return C.jsxs(C.Fragment,{children:[C.jsx(ye.Item,{name:[...e,"record","default_record"],valuePropName:"checked",style:{marginBottom:"8px",paddingTop:8},className:Lze,label:C.jsxs(Ze,{justify:"space-between",align:"center",style:{width:"100%"},children:[C.jsx(tr,{placement:"right",title:C.jsxs(C.Fragment,{children:["Nếu bạn ghi âm, node này sẽ sử dụng file ghi âm khi gọi",C.jsx("br",{}),"Nếu bạn bỏ trống, node này sử dụng giọng bot"]}),children:C.jsx(hm,{strong:!0,children:"Ghi âm"})}),C.jsx(tr,{title:"Cập nhật nội dung văn bản theo file ghi âm",children:C.jsx(dt,{size:"small",icon:C.jsx(LF,{}),type:"primary",onClick:()=>{const c=i.getFieldValue([...e,"record","transcript_original"]);i.setFieldValue([...e,"machine","content"],c)}})})]}),children:C.jsxs("div",{children:[C.jsx(oo,{isOpen:!a,children:C.jsxs(Ze,{align:"center",gap:12,children:[t?null:C.jsx(Vb,{beforeUpload:()=>{n(!1)},onUploadSuccess:({file:c,transcript_text:u,transcript:d})=>{i.setFieldValue([...e,"record","default_record"],c),i.setFieldValue([...e,"record","transcript_original"],u),i.setFieldValue([...e,"record","transcript_with_timestamp"],d),i.submit()}}),t||Ht.isUndefined(t)?C.jsx(Fb,{onStartRecord:()=>{n(!0)},onFinishRecord:({file:c,transcript_text:u,transcript:d})=>{i.setFieldValue([...e,"record","default_record"],c),i.setFieldValue([...e,"record","transcript_original"],u),i.setFieldValue([...e,"record","transcript_with_timestamp"],d),i.submit(),n(void 0)}}):null]})}),C.jsx(oo,{isOpen:!!a,children:C.jsx(PI,{onDelete:()=>n(void 0),url:a,formPath:[[...e,"record","default_record"],[...e,"record","transcript_original"]]})})]})}),a?C.jsxs(C.Fragment,{children:[C.jsxs(Ze,{justify:"space-between",align:"center",children:[C.jsx(ye.Item,{name:[...e,"record","detect_gender"],valuePropName:"checked",style:{marginBottom:"0px"},children:C.jsx(Wr,{disabled:!!o,children:C.jsx(tr,{title:o?"Tắt cá nhân hoá nội dung để dùng tính năng này":null,children:C.jsx(hm,{strong:!0,children:"Cá nhân hoá giới tính"})})})}),o||!r?null:C.jsx(Zze,{})]}),C.jsx(oo,{isOpen:r,children:C.jsxs(Ur,{gutter:[0,16],children:[C.jsx(ye.Item,{name:[...e,"record","male_record"],noStyle:!0,children:C.jsxs(Kn,{direction:"vertical",size:0,wrap:!0,children:[C.jsx(hm,{children:"Khách hàng nam"}),C.jsx(oo,{isOpen:!s,children:C.jsxs(Ze,{align:"center",gap:12,children:[t?null:C.jsx(Vb,{onUploadSuccess:({file:c})=>{i.setFieldValue([...e,"record","male_record"],c),i.submit()}}),t||Ht.isUndefined(t)?C.jsx(Fb,{onStartRecord:()=>{n(!0)},onFinishRecord:({file:c})=>{i.setFieldValue([...e,"record","male_record"],c),i.submit(),n(void 0)}}):null]})}),C.jsx(oo,{isOpen:!!s,children:C.jsx(PI,{url:s,formPath:[[...e,"record","male_record"]]})})]})}),C.jsx(ye.Item,{name:[...e,"record","female_record"],noStyle:!0,children:C.jsx(Kn,{direction:"horizontal",size:0,wrap:!0,children:C.jsxs(Kn,{direction:"vertical",size:0,wrap:!0,children:[C.jsx(hm,{children:"Khách hàng nữ"}),C.jsx(oo,{isOpen:!l,children:C.jsxs(Ze,{align:"center",gap:12,children:[t?null:C.jsx(Vb,{onUploadSuccess:({file:c})=>{i.setFieldValue([...e,"record","female_record"],c),i.submit()}}),t||Ht.isUndefined(t)?C.jsx(Fb,{onStartRecord:()=>{n(!0)},onFinishRecord:({file:c})=>{i.setFieldValue([...e,"record","female_record"],c),i.submit(),n(void 0)}}):null]})}),C.jsx(oo,{isOpen:!!l,children:C.jsx(PI,{url:l,formPath:[[...e,"record","female_record"]]})})]})})})]})}),C.jsx(ga,{style:{margin:"8px 0"}}),C.jsx(ye.Item,{name:[...e,"record","personalize"],valuePropName:"checked",style:{marginBottom:"8px"},children:C.jsx(Wr,{disabled:!!r,onChange:c=>{console.log("e",c.target.checked),c.target.checked?i.setFieldValue([...e,"record","transcript_personalize"],i.getFieldValue([...e,"record","transcript_original"])):i.setFieldValue([...e,"record","transcript_personalize"],void 0)},children:C.jsx(tr,{title:r?"Tắt cá nhân hoá giới tính để dùng tính năng này":null,children:C.jsx(hm,{strong:!0,children:"Cá nhân hoá nội dung"})})})}),C.jsx(oo,{isOpen:o,children:C.jsx(eVe,{})})]}):null,C.jsx(ye.Item,{name:[...e,"record","transcript_with_timestamp"],label:"Transcript với timestamp",hidden:!0,children:C.jsx(BI,{placeholder:"<span start='0.0' end='0.3'>em</span> ...",rows:2})}),C.jsx(ye.Item,{name:[...e,"record","transcript_original"],label:"Transcript gốc",hidden:!0,children:C.jsx(BI,{placeholder:"Em chào anh chị ạ",rows:2})}),C.jsx(ye.Item,{name:[...e,"record","transcript_personalize"],label:"Transcript cá nhân hóa",hidden:!0,children:C.jsx(BI,{placeholder:"Em chào {{name}} ạ",rows:2})})]})},{TextArea:nVe}=jt,rVe=({prefixPaths:e=[]})=>{const t=ye.useFormInstance();return ye.useWatch([...e,"machine","content"],t),C.jsxs(C.Fragment,{children:[C.jsxs("div",{className:Eze,children:[C.jsx(ye.Item,{name:[...e,"machine","content"],style:{marginBottom:"8px"},children:C.jsx(nVe,{placeholder:"Nhập kịch bản",rows:4,className:NI})}),C.jsx(tr,{className:xze,placement:"left",title:`Khi đã tải lên file ghi âm, bot sẽ ưu tiên sử dụng nội dung
|
|
695
695
|
của file ghi âm, mà không dùng nội dung văn bản này.`,children:C.jsx(tc,{})})]}),C.jsx(tVe,{})]})},{TextArea:oVe}=jt,iVe=({prefixPaths:e=[]})=>C.jsx(ye.Item,{name:[...e,"prompt","content"],noStyle:!0,children:C.jsx(oVe,{placeholder:"Nhập prompt",rows:4,className:NI})}),aVe=({id:e})=>{const{getNode:t,setNodes:n}=Fn(),r=bo(),{infos:o,errors:i}=ni(e),a=o.length!==0||i.length!==0,{data:s}=t(e),l=s,[c]=ye.useForm(),u=ye.useWatch(["type"],c)||yo.MACHINE_AND_RECORD,d=p=>{r(e,p)},h=Ht.debounce(()=>{c.submit()},500);return C.jsx("div",{className:Sze,children:C.jsxs(ye,{form:c,layout:"vertical",initialValues:{...l},onFinish:d,onValuesChange:h,children:[C.jsx(ye.Item,{name:["title"],noStyle:!0,children:C.jsx(jt,{type:"hidden"})}),C.jsxs(Kn,{direction:"vertical",size:"small",style:{width:"100%"},children:[C.jsx(ye.Item,{name:["type"],noStyle:!0,children:C.jsx(pf,{size:"middle",block:!0,options:[{label:C.jsxs(Ze,{align:"center",gap:12,justify:"center",children:[C.jsx(ac,{}),"Câu cố định"]}),value:yo.MACHINE_AND_RECORD},{label:C.jsxs(Ze,{align:"center",gap:12,justify:"center",children:[C.jsx(Nu,{}),"Prompt"]}),value:yo.PROMPT}]})}),C.jsx(oo,{isOpen:u===yo.MACHINE_AND_RECORD,children:C.jsx(rVe,{})}),C.jsx(oo,{isOpen:u===yo.PROMPT,children:C.jsx(iVe,{})}),C.jsxs(Bs,{visible:a,children:[C.jsx(ga,{style:{margin:"4px 0"}}),!Ht.isEmpty(o)&&C.jsx("div",{className:Gq,children:o.map(p=>C.jsx(ru,{message:p.title,description:p.description,type:"info",showIcon:!0,closable:!0,style:{padding:"12px",margin:"12px 0"}},p.title))}),!Ht.isEmpty(i)&&C.jsx("div",{className:Gq,children:i.map(p=>C.jsx(ru,{style:{padding:"12px"},message:p.title,description:p.description,type:"error",showIcon:!0,closable:!0},p.title))})]})]})]})})},LI=({id:e,data:t,mini:n})=>{const{displayComponent:r,nodeId:o,closeModal:i}=zo(),a=bo(),{errors:s}=ni(e),l=t.title||"Node nói",c=t.type||yo.MACHINE_AND_RECORD,u=I.useMemo(()=>{var v,g;return c===yo.MACHINE_AND_RECORD?((v=t==null?void 0:t.machine)==null?void 0:v.content)??"":((g=t==null?void 0:t.prompt)==null?void 0:g.content)??""},[c,t]),[d,h]=I.useState(u);I.useEffect(()=>{h(u)},[u]);const p=I.useMemo(()=>Ht.debounce(v=>{c===yo.MACHINE_AND_RECORD?a(e,{...t,machine:{...t.machine,content:v}}):a(e,{...t,prompt:{...t.prompt,content:v}})},300),[c,e,t]),m=v=>{v.target.closest(`button, [role="button"], input, textarea, .${Ds}-modal-wrap`)||(v.stopPropagation(),v.preventDefault(),r(C.jsx(aVe,{id:e}),"Cài đặt node nói",()=>{},e))};return n?C.jsx("div",{className:Cze,children:C.jsx("div",{className:Wq,children:C.jsx("div",{className:Kq,children:C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[C.jsx("span",{className:qq,children:C.jsx(J1,{})}),C.jsx("span",{className:Aze,children:l})]})})})}):C.jsx("div",{className:bze,onClick:m,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&m(v)},children:C.jsxs("div",{className:`${Wq} ${o===e?Qq.active:Qq.default}`,children:[C.jsxs("div",{className:Kq,children:[C.jsxs(Kn,{size:4,children:[C.jsx("span",{className:qq,children:C.jsx(J1,{})}),C.jsx(Eg,{id:e,color:$n.common.red})]}),C.jsx(ts,{id:e,deleteBtnColor:$n.common.red})]}),C.jsxs(Ze,{gap:6,vertical:!0,style:{width:"100%"},children:[C.jsx(pf,{block:!0,size:"small",style:{width:"100%",fontSize:12},value:c,options:[{label:C.jsxs(Ze,{align:"center",gap:12,justify:"center",children:[C.jsx(ac,{size:12}),"Câu cố định"]}),value:yo.MACHINE_AND_RECORD,disabled:c===yo.PROMPT},{label:C.jsxs(Ze,{align:"center",gap:12,justify:"center",children:[C.jsx(Nu,{size:12}),"Prompt"]}),value:yo.PROMPT,disabled:c===yo.MACHINE_AND_RECORD}]}),C.jsx(oo,{isOpen:!Ht.isEmpty(s),children:C.jsx("div",{className:wze,children:s.map(v=>C.jsx(ru,{message:v.title,type:"error",showIcon:!0,closable:!0,style:{width:"100%"}},`alert-${e}-${v.title}`))})})]}),C.jsx(jt.TextArea,{rows:4,autoSize:{minRows:4,maxRows:4},placeholder:"Vui lòng nhập nội dung",className:NI,onFocus:()=>i(),value:d,onChange:v=>{const g=v.target.value;h(g),p(g)}})]})})};var sVe="scripts_editor_1b2l0x40",lVe="scripts_editor_1b2l0x41",cG="scripts_editor_1b2l0x42",uG="scripts_editor_1b2l0x43",dG="scripts_editor_1b2l0x44",fG="scripts_editor_1b2l0x45",cVe="scripts_editor_1b2l0x46",uVe="scripts_editor_1b2l0x49",hG="scripts_editor_1b2l0x4a",pG="scripts_editor_1b2l0x4d",dVe="scripts_editor_flqrya0",fVe="scripts_editor_flqrya1",hVe="scripts_editor_flqrya2 scripts_editor_flqrya1",gG="scripts_editor_flqrya3",pVe="scripts_editor_flqrya4",gVe="scripts_editor_flqrya5 scripts_editor_flqrya4";const mG=({mini:e})=>e?C.jsxs("div",{className:hVe,children:[C.jsx("span",{className:gG,children:C.jsx(nj,{style:{fontSize:"20px"}})}),C.jsx("span",{className:gVe,children:"Bắt đầu"})]}):C.jsx("div",{className:dVe,children:C.jsxs("div",{className:fVe,children:[C.jsx("span",{className:gG,children:C.jsx(nj,{})}),C.jsx("span",{className:pVe,children:"Bắt đầu"})]})}),mVe=({id:e,data:t})=>C.jsxs(Ea,{nodeId:e,children:[C.jsx(yr,{type:"source",position:Rt.Right}),C.jsx(mG,{id:e,data:t})]}),vVe=({id:e})=>{const t=dle(),n=hle(),{fitView:r}=Fn(),o=vie({id:e},t,n),i=mie({id:e},t,n),a=I.useCallback(c=>{r({nodes:[{id:c}],padding:.2,duration:700})},[r]),s=I.useCallback(c=>c.length===0?C.jsx(Ke.Text,{type:"secondary",children:"Không có node nào"}):C.jsx(Bs,{wrapperTag:u=>C.jsx(Kn,{...u,direction:"vertical",wrap:!0,size:0,style:{width:"100%"}}),children:c.map(u=>{const d={id:u.id,data:u.data,mini:!0};let h=C.jsx(Ke.Text,{children:"NODE_NOT_IMPLEMENTED"},u.id);return u.type===st.START&&(h=C.jsx(mG,{...d})),u.type===st.SPEAK&&(h=C.jsx(LI,{...d})),u.type===st.LISTEN&&(h=C.jsx(II,{...d})),u.type===st.TRANSFER&&(h=C.jsx(FI,{...d})),C.jsx("div",{onMouseDown:p=>(p.stopPropagation(),a(u.id)),style:{width:"100%",border:"none",background:"transparent",padding:0,margin:0,cursor:"pointer",outline:"none",textAlign:"left"},children:h},u.id)})}),[a]),l=[{key:"1",label:C.jsx("b",{children:"Mối quan hệ"}),children:C.jsxs(Kn,{wrap:!0,direction:"vertical",size:8,style:{width:"100%"},children:[C.jsx(Ke.Text,{strong:!0,type:"secondary",children:"Node trước"}),s(o),C.jsx(Ke.Text,{strong:!0,type:"secondary",children:"Node sau"}),s(i),C.jsx(Ke.Text,{strong:!0,type:"secondary",children:"Node cha"}),s([])]}),styles:{header:{padding:"0px 0px 12px 0px"},body:{padding:0}}}];return C.jsx($0,{ghost:!0,items:l})},yVe=()=>C.jsxs(C.Fragment,{children:[C.jsx(Ke.Text,{strong:!0,children:"Cài đặt tổng đài"}),C.jsx(ye.Item,{label:"Chọn nhánh nội bộ",name:["external","value"],style:{marginBottom:12},children:C.jsx(jt,{placeholder:"Nhập số điện thoại"})}),C.jsx(ye.Item,{noStyle:!0,name:["external","maximum_try"],children:C.jsx($s,{addonBefore:"Chờ tối đa",addonAfter:"giây",min:1,max:300,placeholder:"30",style:{width:"100%"}})})]}),bVe=()=>C.jsxs(C.Fragment,{children:[C.jsx(Ke.Text,{strong:!0,children:"Cài đặt tổng đài"}),C.jsx(ye.Item,{label:"Chọn nhánh nội bộ",name:["internal","value"],style:{marginBottom:12},children:C.jsx(jt,{placeholder:"Chọn nhánh nội bộ hoặc nhập số điện thoại"})}),C.jsx(ye.Item,{noStyle:!0,name:["internal","maximum_try"],children:C.jsx($s,{addonBefore:"Chờ tối đa",addonAfter:"giây",min:1,max:300,placeholder:"30",style:{width:"100%"}})})]}),CVe=({id:e})=>{const{getNode:t}=Fn(),{data:n}=t(e),r=n,[o]=ye.useForm(),[i,a]=I.useState(r.type),{infos:s}=ni(e),l=bo(),c=d=>{l(e,d)},u=Ht.debounce(()=>{o.submit()},500);return I.useEffect(()=>{o.setFieldsValue({...r}),a(r.type)},[r,o]),C.jsxs(ye,{form:o,layout:"vertical",onFinish:c,onBlur:()=>{o.submit()},onChange:()=>{u()},children:[C.jsx(ye.Item,{name:"type",noStyle:!0,children:C.jsx(pf,{value:i,onChange:d=>{a(d)},options:[{label:"Tổng đài",value:es.INTERNAL},{label:"Điện thoại",value:es.EXTERNAL}],block:!0})}),C.jsxs(Kn,{direction:"vertical",size:8,style:{width:"100%",marginTop:16},children:[C.jsx(oo,{isOpen:i===es.INTERNAL,children:C.jsx(bVe,{})}),C.jsx(oo,{isOpen:i===es.EXTERNAL,children:C.jsx(yVe,{})}),!Ht.isEmpty(s)&&C.jsx(Bs,{children:s.map(d=>C.jsx(ru,{message:d.title,description:d.description,type:"info",showIcon:!0,closable:!0,style:{padding:"12px",margin:"12px 0"}},d.title))})]}),C.jsx(ga,{}),C.jsx(vVe,{id:e}),C.jsx("div",{style:{height:"200px"}})]})},FI=({id:e,data:t,mini:n,group:r})=>{const{displayComponent:o}=zo(),i=t.title||"Chuyển máy",a=t.type||es.INTERNAL,s=c2(),l=u=>{var d;(d=u.target)!=null&&d.closest("button")||(u.stopPropagation(),u.preventDefault(),o(C.jsx(CVe,{id:e}),"Cài đặt chuyển máy"),s(e))},c=I.useMemo(()=>a===es.INTERNAL?"Tổng đài":a===es.EXTERNAL?"Điện thoại":"UNKNOWN",[a]);return n?C.jsx("div",{className:lVe,children:C.jsx("div",{className:cG,children:C.jsxs("div",{className:uG,children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[C.jsx("span",{className:dG,children:C.jsx(nz,{})}),C.jsx("span",{className:fG,children:i})]}),C.jsx("div",{className:cVe,children:c})]})})}):C.jsx("div",{className:sVe,onClick:l,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&l(u)},children:C.jsxs("div",{className:cG,children:[C.jsxs("div",{className:uG,children:[C.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[C.jsx("span",{className:dG,children:C.jsx(eOe,{})}),C.jsx("span",{className:fG,children:i}),C.jsx(Eg,{id:e,color:$n.icon.transferCall})]}),C.jsx(ts,{id:e,deleteBtnColor:$n.icon.transferCall})]}),!r&&C.jsx("div",{className:uVe,children:C.jsxs(Bs,{children:[C.jsxs("div",{className:hG,children:["Chuyển máy thành công",C.jsx(yr,{type:"target",id:`${e}_success`,position:Rt.Right,className:pG,style:{top:"50%",right:"8%"}})]}),C.jsxs("div",{className:hG,children:["Chuyển máy thất bại",C.jsx(yr,{type:"target",id:`${e}_failed`,position:Rt.Right,className:pG,style:{top:"75%",right:"8%"}})]})]})})]})})},AVe=({data:e,id:t})=>C.jsxs(Ea,{nodeId:t,children:[C.jsx(yr,{type:"target",position:Rt.Left}),C.jsx(FI,{id:t,data:e})]}),wVe=[st.SPEAK,st.TRANSFER],SVe=e=>{const t=Pq(e);return{verifyAddable:I.useCallback(r=>{const o=wVe.includes(r);let i=!0;const a=[];return o||(i=!1,a.push("Block này không hỗ trợ thêm vào nhóm")),t.filter(s=>s.type===st.SPEAK).length>0&&r===st.SPEAK&&(i=!1,a.push("Nhóm chỉ có thể chứa tối đa 1 block nói")),t.filter(s=>s.type===st.TRANSFER).length>0&&r===st.TRANSFER&&(i=!1,a.push("Nhóm chỉ có thể chứa tối đa 1 block chuyển máy")),{allowed:i,errors:a}},[t])}};var EVe="scripts_editor_dxvfua1",xVe="scripts_editor_dxvfua2",IVe="scripts_editor_dxvfua3",NVe="scripts_editor_dxvfua4",OVe="scripts_editor_dxvfua5 scripts_editor_dxvfua4";const{Text:vG}=Ke,$Ve=({id:e,data:t})=>{const[n]=kb(),{setNodes:r}=Fn(),{screenToFlowPosition:o}=Fn(),i=Pq(e),{verifyAddable:a}=SVe(e),{error:s}=Bb(),l=i.length>0,c=p=>{p.preventDefault(),p.dataTransfer.dropEffect="move"},u=p=>`${e}_${p.toLowerCase()}_${xu()}`,d=p=>{if(p.preventDefault(),!n)return;const m=a(n);if(!m.allowed){m.errors.forEach(y=>{s({content:y,key:y})});return}const v=o({x:p.clientX,y:p.clientY}),g={id:u(n),type:n,position:v,data:{title:_f[n],...Cg[n]},deletable:!0,...Ag[n],parentId:e,extent:"parent",hidden:!0};r(y=>y.concat(g))},h=I.useMemo(()=>i.map(p=>p.type===st.SPEAK?C.jsx(LI,{...p,data:p.data,group:!0},p.id):p.type===st.LISTEN?C.jsx(II,{...p,data:p.data,group:!0},p.id):p.type===st.TRANSFER?C.jsx(FI,{...p,data:p.data,group:!0},p.id):C.jsx(C.Fragment,{})),[i]);return C.jsx("div",{children:C.jsxs(hi,{className:EVe,styles:{body:{padding:"8px",display:"flex",flex:1,flexDirection:"column",height:"100%",minHeight:"100%"}},children:[C.jsxs("div",{className:`${xVe} drag-handle__custom`,children:[C.jsxs("div",{className:IVe,children:[C.jsx(QFe,{size:16,color:$n.common.black}),C.jsx(vG,{strong:!0,children:t.title}),C.jsx(Eg,{id:e,color:$n.common.black})]}),C.jsx(ts,{id:e,deleteBtnColor:$n.common.black})]}),C.jsx(Kn,{direction:"vertical",size:8,children:h}),C.jsx("button",{className:l?NVe:OVe,onDragOver:c,onDrop:d,type:"button","data-group-drop-zone":"true",children:C.jsx(vG,{children:"Thả block vào đây"})}),C.jsxs(Kn,{direction:"vertical",size:8,style:{marginTop:8},children:[C.jsxs(hi,{styles:{body:{padding:"12px"}},children:["Thực hiện thành công",C.jsx(yr,{type:"source",position:Rt.Right})]}),C.jsxs(hi,{styles:{body:{padding:"12px"}},children:["Thực hiện thất bại",C.jsx(yr,{type:"source",position:Rt.Right})]})]})]})})},MVe=({data:e,id:t})=>C.jsxs(Ea,{nodeId:t,children:[C.jsx(yr,{type:"target",position:Rt.Left}),C.jsx($Ve,{id:t,data:e})]}),PVe=({data:e,id:t})=>C.jsxs(Ea,{nodeId:t,children:[C.jsx(yr,{type:"target",position:Rt.Left}),C.jsx(LI,{id:t,data:e}),C.jsx(yr,{type:"source",position:Rt.Right})]}),yG={[st.AGENT]:ZTe,[st.SPEAK]:PVe,[st.START]:mVe,[st.LISTEN]:yze,[st.TRANSFER]:AVe,[st.GROUP]:MVe,[st.TRIGGER_CONTACT]:yBe,[st.CONTACT_ACTION]:dBe,[st.EMAIL]:RFe,[st.DELAY]:FBe,[st.BRANCH]:D9e,[st.AI_AGENT]:rDe},jb=e=>{switch(e.type){case st.AGENT:return $n.agentBlock.background;case st.START:return $n.startBlock.background;case st.SPEAK:return $n.speakBlock.background;case st.LISTEN:return $n.listenBlock.background;case st.TRANSFER:return $n.icon.transferCall;case st.CRM:return $n.icon.getData;case st.HTTP_REQUEST:return $n.icon.httpRequest;case st.CONDITION:return $n.icon.condition;case st.GROUP:return $n.groupBlock.background;case st.TRIGGER_CONTACT:return $n.contactBlock.backgroundNoGradient;case st.CONTACT_ACTION:return $n.contactBlock.backgroundNoGradient;case st.EMAIL:return $n.contactBlock.backgroundNoGradient;case st.DELAY:return $n.delayBlock.backgroundNoGradient;default:return $n.common.gray}},bG=[st.AGENT,st.SPEAK,st.LISTEN,st.TRANSFER,st.CRM,st.HTTP_REQUEST,st.CONDITION,st.GROUP],Hb=[{key:st.AGENT,label:"Agent",icon:WE,group:1},{key:st.SPEAK,label:"Node nói",icon:fz,group:1},{key:st.LISTEN,label:"Node nghe",icon:FF,group:1},{key:st.TRANSFER,label:"Chuyển máy",icon:nOe,group:1},{key:st.CRM,label:"CRM",icon:RF,group:2},{key:st.HTTP_REQUEST,label:`HTTP
|
|
696
|
-
Request`,icon:FE,group:2},{key:st.CONDITION,label:"Điều kiện",icon:BF,group:2},{key:st.GROUP,label:"Nhóm",icon:XF,group:2}],Rb=[{label:"Trigger",key:"trigger",icon:E3,iconProps:{variant:"Bold"},group:1,color:"#FAAD14",items:[{key:st.TRIGGER_CONTACT,label:"Liên hệ",description:"Liên hệ thay đổi",icon:Hx,group:"CRM",color:"#096DD9"},{key:st.CALLBOT_TRIGGER,label:"Callbot",description:"Chiến dịch được tạo",icon:WE,group:"Đa kênh",color:"#096DD9"}]},{label:"CRM",key:"crm",icon:w3,iconProps:{variant:"Bold"},group:2,color:"#1D39C4",items:[{key:st.CONTACT_ACTION,label:"Liên hệ",description:"Thực hiện hành động với liên hệ",icon:Hx,color:"#096DD9"},{key:st.ORDER_ACTION,label:"Đơn hàng",description:"Thực hiện hành động với đơn hàng",icon:dz,color:"#096DD9"}]},{label:"Đa kênh",key:"chat",icon:ZW,iconProps:{variant:"Bold"},group:2,color:"#08979C",items:[{key:st.EMAIL,label:"Email",description:"Gửi email",icon:S3,iconProps:{variant:"Bold"},color:"#096DD9"}]},{label:"Logic",key:"logic",icon:Y1,group:2,color:"#D46B08",items:[{key:st.DELAY,label:"Hẹn giờ",description:"Hẹn giờ",icon:oj,color:"#D4380D"},{key:st.BRANCH,label:"Rẽ nhánh",description:"Rẽ nhánh",icon:Y1,color:"#D4380D"},{key:st.AI_AGENT,label:"AI Agent",description:"AI Agent",icon:x3,iconProps:{variant:"Bold"},color:"#D4380D"}]},{label:"Tích hợp",key:"integration",icon:FE,group:2,color:"#08979C",items:[]}],Cl={[st.AGENT]:"#FAAD14",[st.START]:"none",[st.SPEAK]:"#d7268a",[st.LISTEN]:"#d2691e",[st.TRANSFER]:"#20b2aa",[st.CRM]:"#1890ff",[st.HTTP_REQUEST]:"#20b2aa",[st.CONDITION]:"#1890ff",[st.GROUP]:"#8c8c8c",[st.TRIGGER_CONTACT]:"#1890FF",[st.CALLBOT_TRIGGER]:"#1890FF",[st.ORDER_TRIGGER]:"#1890FF",[st.CONTACT_ACTION]:"#1890FF",[st.CALLBOT_ACTION]:"#1890FF",[st.ORDER_ACTION]:"#1890FF",[st.EMAIL]:"#1890FF",[st.DELAY]:"#D4380D",[st.BRANCH]:"#D4380D",[st.AI_AGENT]:"#D4380D"};var CG="scripts_editor_223f7c0",AG="scripts_editor_223f7c2";const TVe={autoCallButton:({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:i,targetPosition:a,style:s,target:l,markerEnd:c})=>{const{isOpen:u,onOpen:d,onClose:h}=Xr(),{setEdges:p,setNodes:m}=Fn(),[v,g,y]=Bv({sourceX:t,sourceY:n,sourcePosition:i,targetX:r,targetY:o,targetPosition:a}),A=[...Hb.map(E=>({label:C.jsxs(Kn,{align:"center",size:8,children:[I.createElement(E.icon,{style:{color:Cl[E.key]}}),E.label]}),key:E.key}))],w=E=>{E.preventDefault(),d()},S=({key:E})=>{const N=E,O={id:`${N.toLowerCase()}_${xu()}`,type:N,position:{x:g,y},data:{title:_f[N],...Cg[N]},deletable:!0,...Ag[N]};m($=>$.concat(O)),p($=>{const M=$.find(B=>B.id===e);if(!M)return $;const{source:P,target:_}=M,D=$.filter(B=>B.id!==e);return D.push({id:`${P}_${O.id}_${xu()}`,source:P,target:O.id,type:"autoCallButton"}),wG.includes(N)&&D.push({id:`${O.id}_${_}_${xu()}`,source:O.id,target:_,type:"autoCallButton"}),D}),h()};return C.jsxs(C.Fragment,{children:[C.jsx(Nd,{path:v,markerEnd:c,style:s??{}}),C.jsx($M,{children:C.jsx(tr,{title:"Thêm nút",children:C.jsx("div",{className:`${CG} nodrag nopan ${u?AG:""}`,style:{transform:`translate(-50%, -50%) translate(${g}px,${y}px)`},children:C.jsx(Ms,{onOpenChange:E=>{E?d():h()},menu:{items:A,onClick:S},open:u,trigger:["click"],children:C.jsx(dt,{onClick:w,type:"text",size:"large",style:{padding:4},children:C.jsx(dg,{style:{fontSize:24}})})})})})})]})},autoFlowButton:e=>{const{id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:a,targetPosition:s,style:l,markerEnd:c}=e,{isOpen:u,onOpen:d,onClose:h}=Xr(),{setEdges:p,setNodes:m}=Fn(),[v,g,y]=I.useMemo(()=>Bv({sourceX:n,sourceY:r,sourcePosition:a,targetX:o,targetY:i,targetPosition:s}),[n,r,o,i,a,s]),A=I.useMemo(()=>Rb.map(O=>({key:O.key,label:C.jsxs(Kn,{align:"center",size:8,children:[C.jsx("span",{style:{color:O.color||Cl[O.key]},children:C.jsx(O.icon,{...O.iconProps,size:20})}),C.jsx("span",{children:O.label})]}),children:O.items.map($=>({key:$.key,label:C.jsxs(Kn,{align:"center",size:8,children:[C.jsx("span",{style:{color:$.color||Cl[$.key]},children:C.jsx($.icon,{...$.iconProps,size:14})}),C.jsx("span",{children:$.label})]})}))})),[]),w=I.useCallback(O=>({id:`${O.toLowerCase()}_${xu()}`,type:O,position:{x:g,y},data:{title:_f[O],...Cg[O]},deletable:!0,...Ag[O]}),[g,y]),S=I.useCallback(({key:O})=>{const M=w(O);m(P=>[...P,M]),p(P=>{const _=P.find(k=>k.id===t);if(!_)return P;const{source:D,target:B}=_,T=xu();return[...P.filter(k=>k.id!==t),{id:`${D}_${M.id}_${T}`,source:D,target:M.id,type:"autoFlowButton"},{id:`${M.id}_${B}_${T}`,source:M.id,target:B,type:"autoFlowButton"}]}),h()},[t,w,m,p,h]),E=I.useCallback(O=>{O.preventDefault(),d()},[d]),N=I.useMemo(()=>({transform:`translate(-50%, -50%) translate(${g}px,${y}px)`}),[g,y]);return C.jsxs(C.Fragment,{children:[C.jsx(Nd,{path:v,markerEnd:c,style:l}),C.jsx($M,{children:C.jsx(tr,{title:"Thêm nút",children:C.jsx("div",{className:`${CG} nodrag nopan ${u?AG:""}`,style:N,children:C.jsx(Ms,{open:u,trigger:["click"],menu:{items:A,onClick:S},onOpenChange:O=>O?d():h(),children:C.jsx(dt,{onClick:E,type:"text",size:"large",style:{padding:4},children:C.jsx(dg,{style:{fontSize:24}})})})})})})]})}},wG=[st.SPEAK];function _Ve(){const{getNodes:e,getEdges:t}=Fn(),n=Bb();return{isValidConnection:I.useCallback(o=>{const i=e();t();const a=i.find(s=>s.id===o.target);return(a==null?void 0:a.id)===o.source?(n.error({key:"self-loop",content:"Không thể kết nối node vào chính nó"}),!1):!0},[t,e,n])}}var DVe="scripts_editor_3c0va90",kVe="scripts_editor_3c0va91",BVe="scripts_editor_3c0va93",LVe="scripts_editor_3c0va94",FVe="scripts_editor_3c0va95",zVe="scripts_editor_3c0va96",mc="scripts_editor_3c0va97",VVe="scripts_editor_3c0va98",jVe="scripts_editor_3c0va99",SG="scripts_editor_3c0va9a";function EG(e){return ar({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20"},child:[]},{tag:"path",attr:{d:"M8 11h8"},child:[]},{tag:"path",attr:{d:"M8 7h6"},child:[]}]})(e)}const HVe={version:"1.14.2"};var gh=(e=>(e.BOT="bot",e.CLONE="clone",e))(gh||{});function zI(e){const t=e.getState(),{nodes:n,edges:r,transform:o}=t;return{nodes:n,edges:r,viewport:{x:o[0],y:o[1],zoom:o[2]}}}function RVe({cb:e,delay:t=1e3,enabled:n=!0}){const r=mr(),o=I.useRef(e),i=I.useRef(zI(r)),a=I.useRef(i.current.viewport.zoom);I.useEffect(()=>{o.current=n?e:void 0},[e,n]);const s=I.useCallback(()=>{var v;if(!n)return;const u=zI(r),d=i.current,h=Ht.isEqual(u.nodes,d.nodes),p=Ht.isEqual(u.edges,d.edges),m=Ht.isEqual(u.viewport,d.viewport);h&&p&&m||(i.current=u,a.current=u.viewport.zoom,(v=o.current)==null||v.call(o,u))},[r,n]),l=I.useMemo(()=>Ht.debounce(s,t),[s,t]);I.useEffect(()=>{const u=r.subscribe(()=>l());return()=>{l.cancel(),u()}},[r,l]),MM({onChange:({zoom:u})=>{n&&u!==a.current&&(a.current=u,l())}});const c=I.useCallback(()=>{const u=zI(r);i.current=u,a.current=u.viewport.zoom},[r]);return{commit:l,resetCommitState:c}}const xG=e=>{let t;const n=new Set,r=(c,u)=>{const d=typeof c=="function"?c(t):c;if(!Object.is(d,t)){const h=t;t=u??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(p=>p(t,h))}},o=()=>t,s={setState:r,getState:o,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=t=e(r,o,s);return s},WVe=e=>e?xG(e):xG,QVe=e=>e;function KVe(e,t=QVe){const n=I.useSyncExternalStore(e.subscribe,I.useCallback(()=>t(e.getState()),[e,t]),I.useCallback(()=>t(e.getInitialState()),[e,t]));return I.useDebugValue(n),n}const IG=e=>{const t=WVe(e),n=r=>KVe(t,r);return Object.assign(n,t),n},NG=e=>e?IG(e):IG,OG=NG(e=>({mode:"trackpad",toggleMode:()=>e(t=>({mode:t.mode==="trackpad"?"mouse":"trackpad"}))}));function $G(){const e=OG(r=>r.mode),t=OG(r=>r.toggleMode),n=I.useMemo(()=>e==="trackpad"?{panOnScroll:!0,panOnDrag:!1,zoomOnScroll:!1,zoomOnPinch:!0,zoomOnDoubleClick:!1}:{panOnScroll:!1,panOnDrag:!0,zoomOnScroll:!0,zoomOnPinch:!1,zoomOnDoubleClick:!1},[e]);return{mode:e,toggleMode:t,flowProps:n}}var VI,MG;function qVe(){if(MG)return VI;MG=1;function e(){this.__data__=[],this.size=0}return VI=e,VI}var jI,PG;function TG(){if(PG)return jI;PG=1;function e(t,n){return t===n||t!==t&&n!==n}return jI=e,jI}var HI,_G;function Wb(){if(_G)return HI;_G=1;var e=TG();function t(n,r){for(var o=n.length;o--;)if(e(n[o][0],r))return o;return-1}return HI=t,HI}var RI,DG;function GVe(){if(DG)return RI;DG=1;var e=Wb(),t=Array.prototype,n=t.splice;function r(o){var i=this.__data__,a=e(i,o);if(a<0)return!1;var s=i.length-1;return a==s?i.pop():n.call(i,a,1),--this.size,!0}return RI=r,RI}var WI,kG;function UVe(){if(kG)return WI;kG=1;var e=Wb();function t(n){var r=this.__data__,o=e(r,n);return o<0?void 0:r[o][1]}return WI=t,WI}var QI,BG;function YVe(){if(BG)return QI;BG=1;var e=Wb();function t(n){return e(this.__data__,n)>-1}return QI=t,QI}var KI,LG;function XVe(){if(LG)return KI;LG=1;var e=Wb();function t(n,r){var o=this.__data__,i=e(o,n);return i<0?(++this.size,o.push([n,r])):o[i][1]=r,this}return KI=t,KI}var qI,FG;function Qb(){if(FG)return qI;FG=1;var e=qVe(),t=GVe(),n=UVe(),r=YVe(),o=XVe();function i(a){var s=-1,l=a==null?0:a.length;for(this.clear();++s<l;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=n,i.prototype.has=r,i.prototype.set=o,qI=i,qI}var GI,zG;function ZVe(){if(zG)return GI;zG=1;var e=Qb();function t(){this.__data__=new e,this.size=0}return GI=t,GI}var UI,VG;function JVe(){if(VG)return UI;VG=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return UI=e,UI}var YI,jG;function eje(){if(jG)return YI;jG=1;function e(t){return this.__data__.get(t)}return YI=e,YI}var XI,HG;function tje(){if(HG)return XI;HG=1;function e(t){return this.__data__.has(t)}return XI=e,XI}var ZI,RG;function WG(){if(RG)return ZI;RG=1;var e=tm(),t=Ab(),n="[object AsyncFunction]",r="[object Function]",o="[object GeneratorFunction]",i="[object Proxy]";function a(s){if(!t(s))return!1;var l=e(s);return l==r||l==o||l==n||l==i}return ZI=a,ZI}var JI,QG;function nje(){if(QG)return JI;QG=1;var e=js(),t=e["__core-js_shared__"];return JI=t,JI}var e5,KG;function rje(){if(KG)return e5;KG=1;var e=nje(),t=function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function n(r){return!!t&&t in r}return e5=n,e5}var t5,qG;function GG(){if(qG)return t5;qG=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return t5=n,t5}var n5,UG;function oje(){if(UG)return n5;UG=1;var e=WG(),t=rje(),n=Ab(),r=GG(),o=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,a=Function.prototype,s=Object.prototype,l=a.toString,c=s.hasOwnProperty,u=RegExp("^"+l.call(c).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(h){if(!n(h)||t(h))return!1;var p=e(h)?u:i;return p.test(r(h))}return n5=d,n5}var r5,YG;function ije(){if(YG)return r5;YG=1;function e(t,n){return t==null?void 0:t[n]}return r5=e,r5}var o5,XG;function mh(){if(XG)return o5;XG=1;var e=oje(),t=ije();function n(r,o){var i=t(r,o);return e(i)?i:void 0}return o5=n,o5}var i5,ZG;function a5(){if(ZG)return i5;ZG=1;var e=mh(),t=js(),n=e(t,"Map");return i5=n,i5}var s5,JG;function Kb(){if(JG)return s5;JG=1;var e=mh(),t=e(Object,"create");return s5=t,s5}var l5,eU;function aje(){if(eU)return l5;eU=1;var e=Kb();function t(){this.__data__=e?e(null):{},this.size=0}return l5=t,l5}var c5,tU;function sje(){if(tU)return c5;tU=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return c5=e,c5}var u5,nU;function lje(){if(nU)return u5;nU=1;var e=Kb(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function o(i){var a=this.__data__;if(e){var s=a[i];return s===t?void 0:s}return r.call(a,i)?a[i]:void 0}return u5=o,u5}var d5,rU;function cje(){if(rU)return d5;rU=1;var e=Kb(),t=Object.prototype,n=t.hasOwnProperty;function r(o){var i=this.__data__;return e?i[o]!==void 0:n.call(i,o)}return d5=r,d5}var f5,oU;function uje(){if(oU)return f5;oU=1;var e=Kb(),t="__lodash_hash_undefined__";function n(r,o){var i=this.__data__;return this.size+=this.has(r)?0:1,i[r]=e&&o===void 0?t:o,this}return f5=n,f5}var h5,iU;function dje(){if(iU)return h5;iU=1;var e=aje(),t=sje(),n=lje(),r=cje(),o=uje();function i(a){var s=-1,l=a==null?0:a.length;for(this.clear();++s<l;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=n,i.prototype.has=r,i.prototype.set=o,h5=i,h5}var p5,aU;function fje(){if(aU)return p5;aU=1;var e=dje(),t=Qb(),n=a5();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return p5=r,p5}var g5,sU;function hje(){if(sU)return g5;sU=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return g5=e,g5}var m5,lU;function qb(){if(lU)return m5;lU=1;var e=hje();function t(n,r){var o=n.__data__;return e(r)?o[typeof r=="string"?"string":"hash"]:o.map}return m5=t,m5}var v5,cU;function pje(){if(cU)return v5;cU=1;var e=qb();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return v5=t,v5}var y5,uU;function gje(){if(uU)return y5;uU=1;var e=qb();function t(n){return e(this,n).get(n)}return y5=t,y5}var b5,dU;function mje(){if(dU)return b5;dU=1;var e=qb();function t(n){return e(this,n).has(n)}return b5=t,b5}var C5,fU;function vje(){if(fU)return C5;fU=1;var e=qb();function t(n,r){var o=e(this,n),i=o.size;return o.set(n,r),this.size+=o.size==i?0:1,this}return C5=t,C5}var A5,hU;function pU(){if(hU)return A5;hU=1;var e=fje(),t=pje(),n=gje(),r=mje(),o=vje();function i(a){var s=-1,l=a==null?0:a.length;for(this.clear();++s<l;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=n,i.prototype.has=r,i.prototype.set=o,A5=i,A5}var w5,gU;function yje(){if(gU)return w5;gU=1;var e=Qb(),t=a5(),n=pU(),r=200;function o(i,a){var s=this.__data__;if(s instanceof e){var l=s.__data__;if(!t||l.length<r-1)return l.push([i,a]),this.size=++s.size,this;s=this.__data__=new n(l)}return s.set(i,a),this.size=s.size,this}return w5=o,w5}var S5,mU;function bje(){if(mU)return S5;mU=1;var e=Qb(),t=ZVe(),n=JVe(),r=eje(),o=tje(),i=yje();function a(s){var l=this.__data__=new e(s);this.size=l.size}return a.prototype.clear=t,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=o,a.prototype.set=i,S5=a,S5}var E5,vU;function Cje(){if(vU)return E5;vU=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return E5=t,E5}var x5,yU;function Aje(){if(yU)return x5;yU=1;function e(t){return this.__data__.has(t)}return x5=e,x5}var I5,bU;function wje(){if(bU)return I5;bU=1;var e=pU(),t=Cje(),n=Aje();function r(o){var i=-1,a=o==null?0:o.length;for(this.__data__=new e;++i<a;)this.add(o[i])}return r.prototype.add=r.prototype.push=t,r.prototype.has=n,I5=r,I5}var N5,CU;function Sje(){if(CU)return N5;CU=1;function e(t,n){for(var r=-1,o=t==null?0:t.length;++r<o;)if(n(t[r],r,t))return!0;return!1}return N5=e,N5}var O5,AU;function Eje(){if(AU)return O5;AU=1;function e(t,n){return t.has(n)}return O5=e,O5}var $5,wU;function SU(){if(wU)return $5;wU=1;var e=wje(),t=Sje(),n=Eje(),r=1,o=2;function i(a,s,l,c,u,d){var h=l&r,p=a.length,m=s.length;if(p!=m&&!(h&&m>p))return!1;var v=d.get(a),g=d.get(s);if(v&&g)return v==s&&g==a;var y=-1,A=!0,w=l&o?new e:void 0;for(d.set(a,s),d.set(s,a);++y<p;){var S=a[y],E=s[y];if(c)var N=h?c(E,S,y,s,a,d):c(S,E,y,a,s,d);if(N!==void 0){if(N)continue;A=!1;break}if(w){if(!t(s,function(O,$){if(!n(w,$)&&(S===O||u(S,O,l,c,d)))return w.push($)})){A=!1;break}}else if(!(S===E||u(S,E,l,c,d))){A=!1;break}}return d.delete(a),d.delete(s),A}return $5=i,$5}var M5,EU;function xje(){if(EU)return M5;EU=1;var e=js(),t=e.Uint8Array;return M5=t,M5}var P5,xU;function Ije(){if(xU)return P5;xU=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(o,i){r[++n]=[i,o]}),r}return P5=e,P5}var T5,IU;function Nje(){if(IU)return T5;IU=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(o){r[++n]=o}),r}return T5=e,T5}var _5,NU;function Oje(){if(NU)return _5;NU=1;var e=eI(),t=xje(),n=TG(),r=SU(),o=Ije(),i=Nje(),a=1,s=2,l="[object Boolean]",c="[object Date]",u="[object Error]",d="[object Map]",h="[object Number]",p="[object RegExp]",m="[object Set]",v="[object String]",g="[object Symbol]",y="[object ArrayBuffer]",A="[object DataView]",w=e?e.prototype:void 0,S=w?w.valueOf:void 0;function E(N,O,$,M,P,_,D){switch($){case A:if(N.byteLength!=O.byteLength||N.byteOffset!=O.byteOffset)return!1;N=N.buffer,O=O.buffer;case y:return!(N.byteLength!=O.byteLength||!_(new t(N),new t(O)));case l:case c:case h:return n(+N,+O);case u:return N.name==O.name&&N.message==O.message;case p:case v:return N==O+"";case d:var B=o;case m:var T=M&a;if(B||(B=i),N.size!=O.size&&!T)return!1;var k=D.get(N);if(k)return k==O;M|=s,D.set(N,O);var F=r(B(N),B(O),M,P,_,D);return D.delete(N),F;case g:if(S)return S.call(N)==S.call(O)}return!1}return _5=E,_5}var D5,OU;function $je(){if(OU)return D5;OU=1;function e(t,n){for(var r=-1,o=n.length,i=t.length;++r<o;)t[i+r]=n[r];return t}return D5=e,D5}var k5,$U;function Gb(){if($U)return k5;$U=1;var e=Array.isArray;return k5=e,k5}var B5,MU;function Mje(){if(MU)return B5;MU=1;var e=$je(),t=Gb();function n(r,o,i){var a=o(r);return t(r)?a:e(a,i(r))}return B5=n,B5}var L5,PU;function Pje(){if(PU)return L5;PU=1;function e(t,n){for(var r=-1,o=t==null?0:t.length,i=0,a=[];++r<o;){var s=t[r];n(s,r,t)&&(a[i++]=s)}return a}return L5=e,L5}var F5,TU;function Tje(){if(TU)return F5;TU=1;function e(){return[]}return F5=e,F5}var z5,_U;function _je(){if(_U)return z5;_U=1;var e=Pje(),t=Tje(),n=Object.prototype,r=n.propertyIsEnumerable,o=Object.getOwnPropertySymbols,i=o?function(a){return a==null?[]:(a=Object(a),e(o(a),function(s){return r.call(a,s)}))}:t;return z5=i,z5}var V5,DU;function Dje(){if(DU)return V5;DU=1;function e(t,n){for(var r=-1,o=Array(t);++r<t;)o[r]=n(r);return o}return V5=e,V5}var j5,kU;function kje(){if(kU)return j5;kU=1;var e=tm(),t=nm(),n="[object Arguments]";function r(o){return t(o)&&e(o)==n}return j5=r,j5}var H5,BU;function LU(){if(BU)return H5;BU=1;var e=kje(),t=nm(),n=Object.prototype,r=n.hasOwnProperty,o=n.propertyIsEnumerable,i=e(function(){return arguments}())?e:function(a){return t(a)&&r.call(a,"callee")&&!o.call(a,"callee")};return H5=i,H5}var pm={exports:{}},R5,FU;function Bje(){if(FU)return R5;FU=1;function e(){return!1}return R5=e,R5}pm.exports;var zU;function W5(){return zU||(zU=1,function(e,t){var n=js(),r=Bje(),o=t&&!t.nodeType&&t,i=o&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===o,s=a?n.Buffer:void 0,l=s?s.isBuffer:void 0,c=l||r;e.exports=c}(pm,pm.exports)),pm.exports}var Q5,VU;function Lje(){if(VU)return Q5;VU=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(r,o){var i=typeof r;return o=o??e,!!o&&(i=="number"||i!="symbol"&&t.test(r))&&r>-1&&r%1==0&&r<o}return Q5=n,Q5}var K5,jU;function HU(){if(jU)return K5;jU=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return K5=t,K5}var q5,RU;function Fje(){if(RU)return q5;RU=1;var e=tm(),t=HU(),n=nm(),r="[object Arguments]",o="[object Array]",i="[object Boolean]",a="[object Date]",s="[object Error]",l="[object Function]",c="[object Map]",u="[object Number]",d="[object Object]",h="[object RegExp]",p="[object Set]",m="[object String]",v="[object WeakMap]",g="[object ArrayBuffer]",y="[object DataView]",A="[object Float32Array]",w="[object Float64Array]",S="[object Int8Array]",E="[object Int16Array]",N="[object Int32Array]",O="[object Uint8Array]",$="[object Uint8ClampedArray]",M="[object Uint16Array]",P="[object Uint32Array]",_={};_[A]=_[w]=_[S]=_[E]=_[N]=_[O]=_[$]=_[M]=_[P]=!0,_[r]=_[o]=_[g]=_[i]=_[y]=_[a]=_[s]=_[l]=_[c]=_[u]=_[d]=_[h]=_[p]=_[m]=_[v]=!1;function D(B){return n(B)&&t(B.length)&&!!_[e(B)]}return q5=D,q5}var G5,WU;function zje(){if(WU)return G5;WU=1;function e(t){return function(n){return t(n)}}return G5=e,G5}var gm={exports:{}};gm.exports;var QU;function Vje(){return QU||(QU=1,function(e,t){var n=tK(),r=t&&!t.nodeType&&t,o=r&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===r,a=i&&n.process,s=function(){try{var l=o&&o.require&&o.require("util").types;return l||a&&a.binding&&a.binding("util")}catch{}}();e.exports=s}(gm,gm.exports)),gm.exports}var U5,KU;function Y5(){if(KU)return U5;KU=1;var e=Fje(),t=zje(),n=Vje(),r=n&&n.isTypedArray,o=r?t(r):e;return U5=o,U5}var X5,qU;function jje(){if(qU)return X5;qU=1;var e=Dje(),t=LU(),n=Gb(),r=W5(),o=Lje(),i=Y5(),a=Object.prototype,s=a.hasOwnProperty;function l(c,u){var d=n(c),h=!d&&t(c),p=!d&&!h&&r(c),m=!d&&!h&&!p&&i(c),v=d||h||p||m,g=v?e(c.length,String):[],y=g.length;for(var A in c)(u||s.call(c,A))&&!(v&&(A=="length"||p&&(A=="offset"||A=="parent")||m&&(A=="buffer"||A=="byteLength"||A=="byteOffset")||o(A,y)))&&g.push(A);return g}return X5=l,X5}var Z5,GU;function UU(){if(GU)return Z5;GU=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,o=typeof r=="function"&&r.prototype||e;return n===o}return Z5=t,Z5}var J5,YU;function Hje(){if(YU)return J5;YU=1;function e(t,n){return function(r){return t(n(r))}}return J5=e,J5}var e6,XU;function Rje(){if(XU)return e6;XU=1;var e=Hje(),t=e(Object.keys,Object);return e6=t,e6}var t6,ZU;function JU(){if(ZU)return t6;ZU=1;var e=UU(),t=Rje(),n=Object.prototype,r=n.hasOwnProperty;function o(i){if(!e(i))return t(i);var a=[];for(var s in Object(i))r.call(i,s)&&s!="constructor"&&a.push(s);return a}return t6=o,t6}var n6,eY;function tY(){if(eY)return n6;eY=1;var e=WG(),t=HU();function n(r){return r!=null&&t(r.length)&&!e(r)}return n6=n,n6}var r6,nY;function Wje(){if(nY)return r6;nY=1;var e=jje(),t=JU(),n=tY();function r(o){return n(o)?e(o):t(o)}return r6=r,r6}var o6,rY;function Qje(){if(rY)return o6;rY=1;var e=Mje(),t=_je(),n=Wje();function r(o){return e(o,n,t)}return o6=r,o6}var i6,oY;function Kje(){if(oY)return i6;oY=1;var e=Qje(),t=1,n=Object.prototype,r=n.hasOwnProperty;function o(i,a,s,l,c,u){var d=s&t,h=e(i),p=h.length,m=e(a),v=m.length;if(p!=v&&!d)return!1;for(var g=p;g--;){var y=h[g];if(!(d?y in a:r.call(a,y)))return!1}var A=u.get(i),w=u.get(a);if(A&&w)return A==a&&w==i;var S=!0;u.set(i,a),u.set(a,i);for(var E=d;++g<p;){y=h[g];var N=i[y],O=a[y];if(l)var $=d?l(O,N,y,a,i,u):l(N,O,y,i,a,u);if(!($===void 0?N===O||c(N,O,s,l,u):$)){S=!1;break}E||(E=y=="constructor")}if(S&&!E){var M=i.constructor,P=a.constructor;M!=P&&"constructor"in i&&"constructor"in a&&!(typeof M=="function"&&M instanceof M&&typeof P=="function"&&P instanceof P)&&(S=!1)}return u.delete(i),u.delete(a),S}return i6=o,i6}var a6,iY;function qje(){if(iY)return a6;iY=1;var e=mh(),t=js(),n=e(t,"DataView");return a6=n,a6}var s6,aY;function Gje(){if(aY)return s6;aY=1;var e=mh(),t=js(),n=e(t,"Promise");return s6=n,s6}var l6,sY;function Uje(){if(sY)return l6;sY=1;var e=mh(),t=js(),n=e(t,"Set");return l6=n,l6}var c6,lY;function Yje(){if(lY)return c6;lY=1;var e=mh(),t=js(),n=e(t,"WeakMap");return c6=n,c6}var u6,cY;function uY(){if(cY)return u6;cY=1;var e=qje(),t=a5(),n=Gje(),r=Uje(),o=Yje(),i=tm(),a=GG(),s="[object Map]",l="[object Object]",c="[object Promise]",u="[object Set]",d="[object WeakMap]",h="[object DataView]",p=a(e),m=a(t),v=a(n),g=a(r),y=a(o),A=i;return(e&&A(new e(new ArrayBuffer(1)))!=h||t&&A(new t)!=s||n&&A(n.resolve())!=c||r&&A(new r)!=u||o&&A(new o)!=d)&&(A=function(w){var S=i(w),E=S==l?w.constructor:void 0,N=E?a(E):"";if(N)switch(N){case p:return h;case m:return s;case v:return c;case g:return u;case y:return d}return S}),u6=A,u6}var d6,dY;function Xje(){if(dY)return d6;dY=1;var e=bje(),t=SU(),n=Oje(),r=Kje(),o=uY(),i=Gb(),a=W5(),s=Y5(),l=1,c="[object Arguments]",u="[object Array]",d="[object Object]",h=Object.prototype,p=h.hasOwnProperty;function m(v,g,y,A,w,S){var E=i(v),N=i(g),O=E?u:o(v),$=N?u:o(g);O=O==c?d:O,$=$==c?d:$;var M=O==d,P=$==d,_=O==$;if(_&&a(v)){if(!a(g))return!1;E=!0,M=!1}if(_&&!M)return S||(S=new e),E||s(v)?t(v,g,y,A,w,S):n(v,g,O,y,A,w,S);if(!(y&l)){var D=M&&p.call(v,"__wrapped__"),B=P&&p.call(g,"__wrapped__");if(D||B){var T=D?v.value():v,k=B?g.value():g;return S||(S=new e),w(T,k,y,A,S)}}return _?(S||(S=new e),r(v,g,y,A,w,S)):!1}return d6=m,d6}var f6,fY;function Zje(){if(fY)return f6;fY=1;var e=Xje(),t=nm();function n(r,o,i,a,s){return r===o?!0:r==null||o==null||!t(r)&&!t(o)?r!==r&&o!==o:e(r,o,i,a,n,s)}return f6=n,f6}var h6,hY;function Jje(){if(hY)return h6;hY=1;var e=Zje();function t(n,r){return e(n,r)}return h6=t,h6}var eHe=Jje();const p6=li(eHe);function g6(e){const t=e.getState(),{nodes:n,edges:r,transform:o}=t;return{nodes:n,edges:r,viewport:{x:o[0],y:o[1],zoom:o[2]}}}const tHe=()=>{const e=mr(),{setNodes:t,setEdges:n,setViewport:r}=Fn(),[o,i]=I.useState([g6(e)]),[a,s]=I.useState(0),l=I.useRef(!1),c=I.useRef(!1),u=I.useRef(g6(e)),d=I.useRef(u.current.viewport.zoom),h=A=>{c.current=A},p=I.useCallback(()=>{if(l.current||c.current)return;const A=g6(e),w=u.current,S=p6(A.nodes,w.nodes),E=p6(A.edges,w.edges),N=p6(A.viewport,w.viewport);if(S&&E&&N)return;const O=o.slice(0,a+1);O.push(A),i(O),s(O.length-1),u.current=A,d.current=A.viewport.zoom},[e,o,a]),m=I.useMemo(()=>pK(p,300),[p]),v=I.useCallback(A=>{if(A<0||A>=o.length)return;l.current=!0,m.cancel();const w=o[A];t(w.nodes),n(w.edges),r(w.viewport),s(A),u.current=w,d.current=w.viewport.zoom,requestAnimationFrame(()=>{l.current=!1})},[o,t,n,r,m]),g=I.useCallback(()=>{a>0&&v(a-1)},[a,v]),y=I.useCallback(()=>{a<o.length-1&&v(a+1)},[a,o.length,v]);return I.useEffect(()=>{const A=e.subscribe(()=>{m()});return()=>{m.cancel(),A()}},[e,m]),MM({onChange:({zoom:A})=>{A!==d.current&&(d.current=A,m())}}),{undo:g,redo:y,canUndo:a>0,canRedo:a<o.length-1,commit:m,setIsDragging:h}},m6=e=>{try{const t=e.nodes.map(o=>({id:o.id,position:o.position})),n=e.edges.map(o=>({id:o.id,source:o.source,target:o.target})),r=e.viewport;return JSON.stringify({nodes:t,edges:n,viewport:r})}catch{return JSON.stringify(e)}},mm=NG((e,t)=>({history:[],currentStep:-1,pushSnapshot:n=>e(r=>{const o=m6(n),i=r.history[r.currentStep];if(i&&m6(i)===o)return{};const a=r.history.slice(0,r.currentStep+1);a.push(n);const s={history:a,currentStep:a.length-1};return{...s,canUndo:(s.currentStep??0)>0,canRedo:(s.currentStep??0)<a.length-1}}),applySnapshot:n=>{const r=t();if(n<0||n>=r.history.length)return null;const o=r.history[n];return e(()=>({currentStep:n,canUndo:n>0,canRedo:n<r.history.length-1})),o},reset:n=>e(()=>({history:n?[n]:[],currentStep:n?0:-1,canUndo:!1,canRedo:!1})),canUndo:!1,canRedo:!1})),nHe=()=>{const e=mm(c=>c.currentStep),t=mm(c=>c.history.length),n=e>0,r=e<t-1,{setNodes:o,setEdges:i,setViewport:a}=Fn(),s=I.useCallback(()=>{const c=mm.getState(),u=c.currentStep;if(u>0){const d=c.applySnapshot(u-1);d&&(o==null||o(d.nodes??[]),i==null||i(d.edges??[]),d.viewport&&(a==null||a(d.viewport)))}},[o,i,a]),l=I.useCallback(()=>{const c=mm.getState(),u=c.currentStep;if(u<c.history.length-1){const d=c.applySnapshot(u+1);d&&(o==null||o(d.nodes??[]),i==null||i(d.edges??[]),d.viewport&&(a==null||a(d.viewport)))}},[o,i,a]);return{canUndo:n,canRedo:r,undo:s,redo:l}},rHe=e=>{const{getNodes:t,getEdges:n,getViewport:r}=Fn(),o=I.useRef(null),i=I.useRef(null),a=e==null?void 0:e.snapshotDebounceMs,s=I.useCallback(()=>{const c={nodes:t()??[],edges:n()??[],viewport:r?r():null},u=m6(c);i.current!==u&&(i.current=u,mm.getState().pushSnapshot(c))},[t,n,r]),l=I.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{s(),o.current=null},a)},[a,s]);return I.useEffect(()=>(s(),()=>{o.current&&window.clearTimeout(o.current)}),[s,e==null?void 0:e.takeInitialSnapshot]),{takeSnapshotNow:s,takeSnapshotDebounced:l}};function oHe(e){return ar({attr:{t:"1569683610100",viewBox:"0 0 1024 1024",version:"1.1"},child:[{tag:"path",attr:{d:"M841 370c3-3.3 2.7-8.3-0.6-11.3-1.5-1.3-3.4-2.1-5.3-2.1h-72.6c-2.4 0-4.6 1-6.1 2.8L633.5 504.6c-2.9 3.4-7.9 3.8-11.3 0.9-0.9-0.8-1.6-1.7-2.1-2.8l-63.5-141.3c-1.3-2.9-4.1-4.7-7.3-4.7H380.7l0.9-4.7 8-42.3c10.5-55.4 38-81.4 85.8-81.4 18.6 0 35.5 1.7 48.8 4.7l14.1-66.8c-22.6-4.7-35.2-6.1-54.9-6.1-103.3 0-156.4 44.3-175.9 147.3l-9.4 49.4h-97.6c-3.8 0-7.1 2.7-7.8 6.4L181.9 415c-0.9 4.3 1.9 8.6 6.2 9.5 0.5 0.1 1.1 0.2 1.6 0.2H284l-89 429.9c-0.9 4.3 1.9 8.6 6.2 9.5 0.5 0.1 1.1 0.2 1.6 0.2H269c3.8 0 7.1-2.7 7.8-6.4l89.7-433.1h135.8l68.2 139.1c1.4 2.9 1 6.4-1.2 8.8l-180.6 203c-2.9 3.3-2.6 8.4 0.7 11.3 1.5 1.3 3.4 2 5.3 2h72.7c2.4 0 4.6-1 6.1-2.8l123.7-146.7c2.8-3.4 7.9-3.8 11.3-1 0.9 0.8 1.6 1.7 2.1 2.8L676.4 784c1.3 2.8 4.1 4.7 7.3 4.7h64.6c4.4 0 8-3.6 8-8 0-1.2-0.3-2.4-0.8-3.5l-95.2-198.9c-1.4-2.9-0.9-6.4 1.3-8.8L841 370z"},child:[]}]})(e)}function iHe(e){return ar({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"},child:[]},{tag:"path",attr:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"},child:[]}]})(e)}function aHe(e){return ar({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M952 792H72c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h880c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0-632H72c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h880c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM848 660c8.8 0 16-7.2 16-16V380c0-8.8-7.2-16-16-16H176c-8.8 0-16 7.2-16 16v264c0 8.8 7.2 16 16 16h672zM232 436h560v152H232V436z"},child:[]}]})(e)}function sHe(e){return ar({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"},child:[]},{tag:"path",attr:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"},child:[]}]})(e)}function lHe(e){return ar({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M9 18h3v-2H9c-1.654 0-3-1.346-3-3s1.346-3 3-3h6v3l5-4-5-4v3H9c-2.757 0-5 2.243-5 5s2.243 5 5 5z"},child:[]}]})(e)}function cHe(e){return ar({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M9 10h6c1.654 0 3 1.346 3 3s-1.346 3-3 3h-3v2h3c2.757 0 5-2.243 5-5s-2.243-5-5-5H9V5L4 9l5 4v-3z"},child:[]}]})(e)}function uHe(e){return ar({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M20 3H4c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2zm0 2 .001 4H4V5h16zM4 19v-8h16.001l.001 8H4z"},child:[]},{tag:"path",attr:{d:"M14 6h2v2h-2zm3 0h2v2h-2z"},child:[]}]})(e)}function dHe(e){return ar({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 76c48.1 0 93.3 18.7 127.3 52.7S436 207.9 436 256s-18.7 93.3-52.7 127.3S304.1 436 256 436c-48.1 0-93.3-18.7-127.3-52.7S76 304.1 76 256s18.7-93.3 52.7-127.3S207.9 76 256 76m0-28C141.1 48 48 141.1 48 256s93.1 208 208 208 208-93.1 208-208S370.9 48 256 48z"},child:[]},{tag:"path",attr:{d:"M256.7 160c37.5 0 63.3 20.8 63.3 50.7 0 19.8-9.6 33.5-28.1 44.4-17.4 10.1-23.3 17.5-23.3 30.3v7.9h-34.7l-.3-8.6c-1.7-20.6 5.5-33.4 23.6-44 16.9-10.1 24-16.5 24-28.9s-12-21.5-26.9-21.5c-15.1 0-26 9.8-26.8 24.6H192c.7-32.2 24.5-54.9 64.7-54.9zm-26.3 171.4c0-11.5 9.6-20.6 21.4-20.6 11.9 0 21.5 9 21.5 20.6s-9.6 20.6-21.5 20.6-21.4-9-21.4-20.6z"},child:[]}]})(e)}var v6,pY;function y6(){if(pY)return v6;pY=1;var e="\0",t="\0",n="";class r{constructor(u){uo(this,"_isDirected",!0);uo(this,"_isMultigraph",!1);uo(this,"_isCompound",!1);uo(this,"_label");uo(this,"_defaultNodeLabelFn",()=>{});uo(this,"_defaultEdgeLabelFn",()=>{});uo(this,"_nodes",{});uo(this,"_in",{});uo(this,"_preds",{});uo(this,"_out",{});uo(this,"_sucs",{});uo(this,"_edgeObjs",{});uo(this,"_edgeLabels",{});uo(this,"_nodeCount",0);uo(this,"_edgeCount",0);uo(this,"_parent");uo(this,"_children");u&&(this._isDirected=Object.hasOwn(u,"directed")?u.directed:!0,this._isMultigraph=Object.hasOwn(u,"multigraph")?u.multigraph:!1,this._isCompound=Object.hasOwn(u,"compound")?u.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(u){return this._label=u,this}graph(){return this._label}setDefaultNodeLabel(u){return this._defaultNodeLabelFn=u,typeof u!="function"&&(this._defaultNodeLabelFn=()=>u),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var u=this;return this.nodes().filter(d=>Object.keys(u._in[d]).length===0)}sinks(){var u=this;return this.nodes().filter(d=>Object.keys(u._out[d]).length===0)}setNodes(u,d){var h=arguments,p=this;return u.forEach(function(m){h.length>1?p.setNode(m,d):p.setNode(m)}),this}setNode(u,d){return Object.hasOwn(this._nodes,u)?(arguments.length>1&&(this._nodes[u]=d),this):(this._nodes[u]=arguments.length>1?d:this._defaultNodeLabelFn(u),this._isCompound&&(this._parent[u]=t,this._children[u]={},this._children[t][u]=!0),this._in[u]={},this._preds[u]={},this._out[u]={},this._sucs[u]={},++this._nodeCount,this)}node(u){return this._nodes[u]}hasNode(u){return Object.hasOwn(this._nodes,u)}removeNode(u){var d=this;if(Object.hasOwn(this._nodes,u)){var h=p=>d.removeEdge(d._edgeObjs[p]);delete this._nodes[u],this._isCompound&&(this._removeFromParentsChildList(u),delete this._parent[u],this.children(u).forEach(function(p){d.setParent(p)}),delete this._children[u]),Object.keys(this._in[u]).forEach(h),delete this._in[u],delete this._preds[u],Object.keys(this._out[u]).forEach(h),delete this._out[u],delete this._sucs[u],--this._nodeCount}return this}setParent(u,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(d===void 0)d=t;else{d+="";for(var h=d;h!==void 0;h=this.parent(h))if(h===u)throw new Error("Setting "+d+" as parent of "+u+" would create a cycle");this.setNode(d)}return this.setNode(u),this._removeFromParentsChildList(u),this._parent[u]=d,this._children[d][u]=!0,this}_removeFromParentsChildList(u){delete this._children[this._parent[u]][u]}parent(u){if(this._isCompound){var d=this._parent[u];if(d!==t)return d}}children(u=t){if(this._isCompound){var d=this._children[u];if(d)return Object.keys(d)}else{if(u===t)return this.nodes();if(this.hasNode(u))return[]}}predecessors(u){var d=this._preds[u];if(d)return Object.keys(d)}successors(u){var d=this._sucs[u];if(d)return Object.keys(d)}neighbors(u){var d=this.predecessors(u);if(d){const p=new Set(d);for(var h of this.successors(u))p.add(h);return Array.from(p.values())}}isLeaf(u){var d;return this.isDirected()?d=this.successors(u):d=this.neighbors(u),d.length===0}filterNodes(u){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var h=this;Object.entries(this._nodes).forEach(function([v,g]){u(v)&&d.setNode(v,g)}),Object.values(this._edgeObjs).forEach(function(v){d.hasNode(v.v)&&d.hasNode(v.w)&&d.setEdge(v,h.edge(v))});var p={};function m(v){var g=h.parent(v);return g===void 0||d.hasNode(g)?(p[v]=g,g):g in p?p[g]:m(g)}return this._isCompound&&d.nodes().forEach(v=>d.setParent(v,m(v))),d}setDefaultEdgeLabel(u){return this._defaultEdgeLabelFn=u,typeof u!="function"&&(this._defaultEdgeLabelFn=()=>u),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(u,d){var h=this,p=arguments;return u.reduce(function(m,v){return p.length>1?h.setEdge(m,v,d):h.setEdge(m,v),v}),this}setEdge(){var u,d,h,p,m=!1,v=arguments[0];typeof v=="object"&&v!==null&&"v"in v?(u=v.v,d=v.w,h=v.name,arguments.length===2&&(p=arguments[1],m=!0)):(u=v,d=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),u=""+u,d=""+d,h!==void 0&&(h=""+h);var g=a(this._isDirected,u,d,h);if(Object.hasOwn(this._edgeLabels,g))return m&&(this._edgeLabels[g]=p),this;if(h!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(u),this.setNode(d),this._edgeLabels[g]=m?p:this._defaultEdgeLabelFn(u,d,h);var y=s(this._isDirected,u,d,h);return u=y.v,d=y.w,Object.freeze(y),this._edgeObjs[g]=y,o(this._preds[d],u),o(this._sucs[u],d),this._in[d][g]=y,this._out[u][g]=y,this._edgeCount++,this}edge(u,d,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,u,d,h);return this._edgeLabels[p]}edgeAsObj(){const u=this.edge(...arguments);return typeof u!="object"?{label:u}:u}hasEdge(u,d,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,u,d,h);return Object.hasOwn(this._edgeLabels,p)}removeEdge(u,d,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,u,d,h),m=this._edgeObjs[p];return m&&(u=m.v,d=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],i(this._preds[d],u),i(this._sucs[u],d),delete this._in[d][p],delete this._out[u][p],this._edgeCount--),this}inEdges(u,d){var h=this._in[u];if(h){var p=Object.values(h);return d?p.filter(m=>m.v===d):p}}outEdges(u,d){var h=this._out[u];if(h){var p=Object.values(h);return d?p.filter(m=>m.w===d):p}}nodeEdges(u,d){var h=this.inEdges(u,d);if(h)return h.concat(this.outEdges(u,d))}}function o(c,u){c[u]?c[u]++:c[u]=1}function i(c,u){--c[u]||delete c[u]}function a(c,u,d,h){var p=""+u,m=""+d;if(!c&&p>m){var v=p;p=m,m=v}return p+n+m+n+(h===void 0?e:h)}function s(c,u,d,h){var p=""+u,m=""+d;if(!c&&p>m){var v=p;p=m,m=v}var g={v:p,w:m};return h&&(g.name=h),g}function l(c,u){return a(c,u.v,u.w,u.name)}return v6=r,v6}var b6,gY;function fHe(){return gY||(gY=1,b6="2.2.4"),b6}var C6,mY;function hHe(){return mY||(mY=1,C6={Graph:y6(),version:fHe()}),C6}var A6,vY;function pHe(){if(vY)return A6;vY=1;var e=y6();A6={write:t,read:o};function t(i){var a={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:n(i),edges:r(i)};return i.graph()!==void 0&&(a.value=structuredClone(i.graph())),a}function n(i){return i.nodes().map(function(a){var s=i.node(a),l=i.parent(a),c={v:a};return s!==void 0&&(c.value=s),l!==void 0&&(c.parent=l),c})}function r(i){return i.edges().map(function(a){var s=i.edge(a),l={v:a.v,w:a.w};return a.name!==void 0&&(l.name=a.name),s!==void 0&&(l.value=s),l})}function o(i){var a=new e(i.options).setGraph(i.value);return i.nodes.forEach(function(s){a.setNode(s.v,s.value),s.parent&&a.setParent(s.v,s.parent)}),i.edges.forEach(function(s){a.setEdge({v:s.v,w:s.w,name:s.name},s.value)}),a}return A6}var w6,yY;function gHe(){if(yY)return w6;yY=1,w6=e;function e(t){var n={},r=[],o;function i(a){Object.hasOwn(n,a)||(n[a]=!0,o.push(a),t.successors(a).forEach(i),t.predecessors(a).forEach(i))}return t.nodes().forEach(function(a){o=[],i(a),o.length&&r.push(o)}),r}return w6}var S6,bY;function CY(){if(bY)return S6;bY=1;class e{constructor(){uo(this,"_arr",[]);uo(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,r){var o=this._keyIndices;if(n=String(n),!Object.hasOwn(o,n)){var i=this._arr,a=i.length;return o[n]=a,i.push({key:n,priority:r}),this._decrease(a),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,r){var o=this._keyIndices[n];if(r>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[o].priority+" New: "+r);this._arr[o].priority=r,this._decrease(o)}_heapify(n){var r=this._arr,o=2*n,i=o+1,a=n;o<r.length&&(a=r[o].priority<r[a].priority?o:a,i<r.length&&(a=r[i].priority<r[a].priority?i:a),a!==n&&(this._swap(n,a),this._heapify(a)))}_decrease(n){for(var r=this._arr,o=r[n].priority,i;n!==0&&(i=n>>1,!(r[i].priority<o));)this._swap(n,i),n=i}_swap(n,r){var o=this._arr,i=this._keyIndices,a=o[n],s=o[r];o[n]=s,o[r]=a,i[s.key]=n,i[a.key]=r}}return S6=e,S6}var E6,AY;function wY(){if(AY)return E6;AY=1;var e=CY();E6=n;var t=()=>1;function n(o,i,a,s){return r(o,String(i),a||t,s||function(l){return o.outEdges(l)})}function r(o,i,a,s){var l={},c=new e,u,d,h=function(p){var m=p.v!==u?p.v:p.w,v=l[m],g=a(p),y=d.distance+g;if(g<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+p+" Weight: "+g);y<v.distance&&(v.distance=y,v.predecessor=u,c.decrease(m,y))};for(o.nodes().forEach(function(p){var m=p===i?0:Number.POSITIVE_INFINITY;l[p]={distance:m},c.add(p,m)});c.size()>0&&(u=c.removeMin(),d=l[u],d.distance!==Number.POSITIVE_INFINITY);)s(u).forEach(h);return l}return E6}var x6,SY;function mHe(){if(SY)return x6;SY=1;var e=wY();x6=t;function t(n,r,o){return n.nodes().reduce(function(i,a){return i[a]=e(n,a,r,o),i},{})}return x6}var I6,EY;function xY(){if(EY)return I6;EY=1,I6=e;function e(t){var n=0,r=[],o={},i=[];function a(s){var l=o[s]={onStack:!0,lowlink:n,index:n++};if(r.push(s),t.successors(s).forEach(function(d){Object.hasOwn(o,d)?o[d].onStack&&(l.lowlink=Math.min(l.lowlink,o[d].index)):(a(d),l.lowlink=Math.min(l.lowlink,o[d].lowlink))}),l.lowlink===l.index){var c=[],u;do u=r.pop(),o[u].onStack=!1,c.push(u);while(s!==u);i.push(c)}}return t.nodes().forEach(function(s){Object.hasOwn(o,s)||a(s)}),i}return I6}var N6,IY;function vHe(){if(IY)return N6;IY=1;var e=xY();N6=t;function t(n){return e(n).filter(function(r){return r.length>1||r.length===1&&n.hasEdge(r[0],r[0])})}return N6}var O6,NY;function yHe(){if(NY)return O6;NY=1,O6=t;var e=()=>1;function t(r,o,i){return n(r,o||e,i||function(a){return r.outEdges(a)})}function n(r,o,i){var a={},s=r.nodes();return s.forEach(function(l){a[l]={},a[l][l]={distance:0},s.forEach(function(c){l!==c&&(a[l][c]={distance:Number.POSITIVE_INFINITY})}),i(l).forEach(function(c){var u=c.v===l?c.w:c.v,d=o(c);a[l][u]={distance:d,predecessor:l}})}),s.forEach(function(l){var c=a[l];s.forEach(function(u){var d=a[u];s.forEach(function(h){var p=d[l],m=c[h],v=d[h],g=p.distance+m.distance;g<v.distance&&(v.distance=g,v.predecessor=m.predecessor)})})}),a}return O6}var $6,OY;function $Y(){if(OY)return $6;OY=1;function e(n){var r={},o={},i=[];function a(s){if(Object.hasOwn(o,s))throw new t;Object.hasOwn(r,s)||(o[s]=!0,r[s]=!0,n.predecessors(s).forEach(a),delete o[s],i.push(s))}if(n.sinks().forEach(a),Object.keys(r).length!==n.nodeCount())throw new t;return i}class t extends Error{constructor(){super(...arguments)}}return $6=e,e.CycleException=t,$6}var M6,MY;function bHe(){if(MY)return M6;MY=1;var e=$Y();M6=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return M6}var P6,PY;function TY(){if(PY)return P6;PY=1,P6=e;function e(o,i,a){Array.isArray(i)||(i=[i]);var s=o.isDirected()?d=>o.successors(d):d=>o.neighbors(d),l=a==="post"?t:n,c=[],u={};return i.forEach(d=>{if(!o.hasNode(d))throw new Error("Graph does not have node: "+d);l(d,s,u,c)}),c}function t(o,i,a,s){for(var l=[[o,!1]];l.length>0;){var c=l.pop();c[1]?s.push(c[0]):Object.hasOwn(a,c[0])||(a[c[0]]=!0,l.push([c[0],!0]),r(i(c[0]),u=>l.push([u,!1])))}}function n(o,i,a,s){for(var l=[o];l.length>0;){var c=l.pop();Object.hasOwn(a,c)||(a[c]=!0,s.push(c),r(i(c),u=>l.push(u)))}}function r(o,i){for(var a=o.length;a--;)i(o[a],a,o);return o}return P6}var T6,_Y;function CHe(){if(_Y)return T6;_Y=1;var e=TY();T6=t;function t(n,r){return e(n,r,"post")}return T6}var _6,DY;function AHe(){if(DY)return _6;DY=1;var e=TY();_6=t;function t(n,r){return e(n,r,"pre")}return _6}var D6,kY;function wHe(){if(kY)return D6;kY=1;var e=y6(),t=CY();D6=n;function n(r,o){var i=new e,a={},s=new t,l;function c(d){var h=d.v===l?d.w:d.v,p=s.priority(h);if(p!==void 0){var m=o(d);m<p&&(a[h]=l,s.decrease(h,m))}}if(r.nodeCount()===0)return i;r.nodes().forEach(function(d){s.add(d,Number.POSITIVE_INFINITY),i.setNode(d)}),s.decrease(r.nodes()[0],0);for(var u=!1;s.size()>0;){if(l=s.removeMin(),Object.hasOwn(a,l))i.setEdge(l,a[l]);else{if(u)throw new Error("Input graph is not connected: "+r);u=!0}r.nodeEdges(l).forEach(c)}return i}return D6}var k6,BY;function SHe(){return BY||(BY=1,k6={components:gHe(),dijkstra:wY(),dijkstraAll:mHe(),findCycles:vHe(),floydWarshall:yHe(),isAcyclic:bHe(),postorder:CHe(),preorder:AHe(),prim:wHe(),tarjan:xY(),topsort:$Y()}),k6}var B6,LY;function ss(){if(LY)return B6;LY=1;var e=hHe();return B6={Graph:e.Graph,json:pHe(),alg:SHe(),version:e.version},B6}var L6,FY;function EHe(){if(FY)return L6;FY=1;class e{constructor(){let o={};o._next=o._prev=o,this._sentinel=o}dequeue(){let o=this._sentinel,i=o._prev;if(i!==o)return t(i),i}enqueue(o){let i=this._sentinel;o._prev&&o._next&&t(o),o._next=i._next,i._next._prev=o,i._next=o,o._prev=i}toString(){let o=[],i=this._sentinel,a=i._prev;for(;a!==i;)o.push(JSON.stringify(a,n)),a=a._prev;return"["+o.join(", ")+"]"}}function t(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,o){if(r!=="_next"&&r!=="_prev")return o}return L6=e,L6}var F6,zY;function xHe(){if(zY)return F6;zY=1;let e=ss().Graph,t=EHe();F6=r;let n=()=>1;function r(c,u){if(c.nodeCount()<=1)return[];let d=a(c,u||n);return o(d.graph,d.buckets,d.zeroIdx).flatMap(p=>c.outEdges(p.v,p.w))}function o(c,u,d){let h=[],p=u[u.length-1],m=u[0],v;for(;c.nodeCount();){for(;v=m.dequeue();)i(c,u,d,v);for(;v=p.dequeue();)i(c,u,d,v);if(c.nodeCount()){for(let g=u.length-2;g>0;--g)if(v=u[g].dequeue(),v){h=h.concat(i(c,u,d,v,!0));break}}}return h}function i(c,u,d,h,p){let m=p?[]:void 0;return c.inEdges(h.v).forEach(v=>{let g=c.edge(v),y=c.node(v.v);p&&m.push({v:v.v,w:v.w}),y.out-=g,s(u,d,y)}),c.outEdges(h.v).forEach(v=>{let g=c.edge(v),y=v.w,A=c.node(y);A.in-=g,s(u,d,A)}),c.removeNode(h.v),m}function a(c,u){let d=new e,h=0,p=0;c.nodes().forEach(g=>{d.setNode(g,{v:g,in:0,out:0})}),c.edges().forEach(g=>{let y=d.edge(g.v,g.w)||0,A=u(g),w=y+A;d.setEdge(g.v,g.w,w),p=Math.max(p,d.node(g.v).out+=A),h=Math.max(h,d.node(g.w).in+=A)});let m=l(p+h+3).map(()=>new t),v=h+1;return d.nodes().forEach(g=>{s(m,v,d.node(g))}),{graph:d,buckets:m,zeroIdx:v}}function s(c,u,d){d.out?d.in?c[d.out-d.in+u].enqueue(d):c[c.length-1].enqueue(d):c[0].enqueue(d)}function l(c){const u=[];for(let d=0;d<c;d++)u.push(d);return u}return F6}var z6,VY;function wo(){if(VY)return z6;VY=1;let e=ss().Graph;z6={addBorderNode:u,addDummyNode:t,applyWithChunking:p,asNonCompoundGraph:r,buildLayerMatrix:s,intersectRect:a,mapValues:N,maxRank:m,normalizeRanks:l,notime:y,partition:v,pick:E,predecessorWeights:i,range:S,removeEmptyRanks:c,simplify:n,successorWeights:o,time:g,uniqueId:w,zipObject:O};function t($,M,P,_){for(var D=_;$.hasNode(D);)D=w(_);return P.dummy=M,$.setNode(D,P),D}function n($){let M=new e().setGraph($.graph());return $.nodes().forEach(P=>M.setNode(P,$.node(P))),$.edges().forEach(P=>{let _=M.edge(P.v,P.w)||{weight:0,minlen:1},D=$.edge(P);M.setEdge(P.v,P.w,{weight:_.weight+D.weight,minlen:Math.max(_.minlen,D.minlen)})}),M}function r($){let M=new e({multigraph:$.isMultigraph()}).setGraph($.graph());return $.nodes().forEach(P=>{$.children(P).length||M.setNode(P,$.node(P))}),$.edges().forEach(P=>{M.setEdge(P,$.edge(P))}),M}function o($){let M=$.nodes().map(P=>{let _={};return $.outEdges(P).forEach(D=>{_[D.w]=(_[D.w]||0)+$.edge(D).weight}),_});return O($.nodes(),M)}function i($){let M=$.nodes().map(P=>{let _={};return $.inEdges(P).forEach(D=>{_[D.v]=(_[D.v]||0)+$.edge(D).weight}),_});return O($.nodes(),M)}function a($,M){let P=$.x,_=$.y,D=M.x-P,B=M.y-_,T=$.width/2,k=$.height/2;if(!D&&!B)throw new Error("Not possible to find intersection inside of the rectangle");let F,z;return Math.abs(B)*T>Math.abs(D)*k?(B<0&&(k=-k),F=k*D/B,z=k):(D<0&&(T=-T),F=T,z=T*B/D),{x:P+F,y:_+z}}function s($){let M=S(m($)+1).map(()=>[]);return $.nodes().forEach(P=>{let _=$.node(P),D=_.rank;D!==void 0&&(M[D][_.order]=P)}),M}function l($){let M=$.nodes().map(_=>{let D=$.node(_).rank;return D===void 0?Number.MAX_VALUE:D}),P=p(Math.min,M);$.nodes().forEach(_=>{let D=$.node(_);Object.hasOwn(D,"rank")&&(D.rank-=P)})}function c($){let M=$.nodes().map(T=>$.node(T).rank),P=p(Math.min,M),_=[];$.nodes().forEach(T=>{let k=$.node(T).rank-P;_[k]||(_[k]=[]),_[k].push(T)});let D=0,B=$.graph().nodeRankFactor;Array.from(_).forEach((T,k)=>{T===void 0&&k%B!==0?--D:T!==void 0&&D&&T.forEach(F=>$.node(F).rank+=D)})}function u($,M,P,_){let D={width:0,height:0};return arguments.length>=4&&(D.rank=P,D.order=_),t($,"border",D,M)}function d($,M=h){const P=[];for(let _=0;_<$.length;_+=M){const D=$.slice(_,_+M);P.push(D)}return P}const h=65535;function p($,M){if(M.length>h){const P=d(M);return $.apply(null,P.map(_=>$.apply(null,_)))}else return $.apply(null,M)}function m($){const P=$.nodes().map(_=>{let D=$.node(_).rank;return D===void 0?Number.MIN_VALUE:D});return p(Math.max,P)}function v($,M){let P={lhs:[],rhs:[]};return $.forEach(_=>{M(_)?P.lhs.push(_):P.rhs.push(_)}),P}function g($,M){let P=Date.now();try{return M()}finally{console.log($+" time: "+(Date.now()-P)+"ms")}}function y($,M){return M()}let A=0;function w($){var M=++A;return $+(""+M)}function S($,M,P=1){M==null&&(M=$,$=0);let _=B=>B<M;P<0&&(_=B=>M<B);const D=[];for(let B=$;_(B);B+=P)D.push(B);return D}function E($,M){const P={};for(const _ of M)$[_]!==void 0&&(P[_]=$[_]);return P}function N($,M){let P=M;return typeof M=="string"&&(P=_=>_[M]),Object.entries($).reduce((_,[D,B])=>(_[D]=P(B,D),_),{})}function O($,M){return $.reduce((P,_,D)=>(P[_]=M[D],P),{})}return z6}var V6,jY;function IHe(){if(jY)return V6;jY=1;let e=xHe(),t=wo().uniqueId;V6={run:n,undo:o};function n(i){(i.graph().acyclicer==="greedy"?e(i,s(i)):r(i)).forEach(l=>{let c=i.edge(l);i.removeEdge(l),c.forwardName=l.name,c.reversed=!0,i.setEdge(l.w,l.v,c,t("rev"))});function s(l){return c=>l.edge(c).weight}}function r(i){let a=[],s={},l={};function c(u){Object.hasOwn(l,u)||(l[u]=!0,s[u]=!0,i.outEdges(u).forEach(d=>{Object.hasOwn(s,d.w)?a.push(d):c(d.w)}),delete s[u])}return i.nodes().forEach(c),a}function o(i){i.edges().forEach(a=>{let s=i.edge(a);if(s.reversed){i.removeEdge(a);let l=s.forwardName;delete s.reversed,delete s.forwardName,i.setEdge(a.w,a.v,s,l)}})}return V6}var j6,HY;function NHe(){if(HY)return j6;HY=1;let e=wo();j6={run:t,undo:r};function t(o){o.graph().dummyChains=[],o.edges().forEach(i=>n(o,i))}function n(o,i){let a=i.v,s=o.node(a).rank,l=i.w,c=o.node(l).rank,u=i.name,d=o.edge(i),h=d.labelRank;if(c===s+1)return;o.removeEdge(i);let p,m,v;for(v=0,++s;s<c;++v,++s)d.points=[],m={width:0,height:0,edgeLabel:d,edgeObj:i,rank:s},p=e.addDummyNode(o,"edge",m,"_d"),s===h&&(m.width=d.width,m.height=d.height,m.dummy="edge-label",m.labelpos=d.labelpos),o.setEdge(a,p,{weight:d.weight},u),v===0&&o.graph().dummyChains.push(p),a=p;o.setEdge(a,l,{weight:d.weight},u)}function r(o){o.graph().dummyChains.forEach(i=>{let a=o.node(i),s=a.edgeLabel,l;for(o.setEdge(a.edgeObj,s);a.dummy;)l=o.successors(i)[0],o.removeNode(i),s.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(s.x=a.x,s.y=a.y,s.width=a.width,s.height=a.height),i=l,a=o.node(i)})}return j6}var H6,RY;function Ub(){if(RY)return H6;RY=1;const{applyWithChunking:e}=wo();H6={longestPath:t,slack:n};function t(r){var o={};function i(a){var s=r.node(a);if(Object.hasOwn(o,a))return s.rank;o[a]=!0;let l=r.outEdges(a).map(u=>u==null?Number.POSITIVE_INFINITY:i(u.w)-r.edge(u).minlen);var c=e(Math.min,l);return c===Number.POSITIVE_INFINITY&&(c=0),s.rank=c}r.sources().forEach(i)}function n(r,o){return r.node(o.w).rank-r.node(o.v).rank-r.edge(o).minlen}return H6}var R6,WY;function QY(){if(WY)return R6;WY=1;var e=ss().Graph,t=Ub().slack;R6=n;function n(a){var s=new e({directed:!1}),l=a.nodes()[0],c=a.nodeCount();s.setNode(l,{});for(var u,d;r(s,a)<c;)u=o(s,a),d=s.hasNode(u.v)?t(a,u):-t(a,u),i(s,a,d);return s}function r(a,s){function l(c){s.nodeEdges(c).forEach(u=>{var d=u.v,h=c===d?u.w:d;!a.hasNode(h)&&!t(s,u)&&(a.setNode(h,{}),a.setEdge(c,h,{}),l(h))})}return a.nodes().forEach(l),a.nodeCount()}function o(a,s){return s.edges().reduce((c,u)=>{let d=Number.POSITIVE_INFINITY;return a.hasNode(u.v)!==a.hasNode(u.w)&&(d=t(s,u)),d<c[0]?[d,u]:c},[Number.POSITIVE_INFINITY,null])[1]}function i(a,s,l){a.nodes().forEach(c=>s.node(c).rank+=l)}return R6}var W6,KY;function OHe(){if(KY)return W6;KY=1;var e=QY(),t=Ub().slack,n=Ub().longestPath,r=ss().alg.preorder,o=ss().alg.postorder,i=wo().simplify;W6=a,a.initLowLimValues=u,a.initCutValues=s,a.calcCutValue=c,a.leaveEdge=h,a.enterEdge=p,a.exchangeEdges=m;function a(A){A=i(A),n(A);var w=e(A);u(w),s(w,A);for(var S,E;S=h(w);)E=p(w,A,S),m(w,A,S,E)}function s(A,w){var S=o(A,A.nodes());S=S.slice(0,S.length-1),S.forEach(E=>l(A,w,E))}function l(A,w,S){var E=A.node(S),N=E.parent;A.edge(S,N).cutvalue=c(A,w,S)}function c(A,w,S){var E=A.node(S),N=E.parent,O=!0,$=w.edge(S,N),M=0;return $||(O=!1,$=w.edge(N,S)),M=$.weight,w.nodeEdges(S).forEach(P=>{var _=P.v===S,D=_?P.w:P.v;if(D!==N){var B=_===O,T=w.edge(P).weight;if(M+=B?T:-T,g(A,S,D)){var k=A.edge(S,D).cutvalue;M+=B?-k:k}}}),M}function u(A,w){arguments.length<2&&(w=A.nodes()[0]),d(A,{},1,w)}function d(A,w,S,E,N){var O=S,$=A.node(E);return w[E]=!0,A.neighbors(E).forEach(M=>{Object.hasOwn(w,M)||(S=d(A,w,S,M,E))}),$.low=O,$.lim=S++,N?$.parent=N:delete $.parent,S}function h(A){return A.edges().find(w=>A.edge(w).cutvalue<0)}function p(A,w,S){var E=S.v,N=S.w;w.hasEdge(E,N)||(E=S.w,N=S.v);var O=A.node(E),$=A.node(N),M=O,P=!1;O.lim>$.lim&&(M=$,P=!0);var _=w.edges().filter(D=>P===y(A,A.node(D.v),M)&&P!==y(A,A.node(D.w),M));return _.reduce((D,B)=>t(w,B)<t(w,D)?B:D)}function m(A,w,S,E){var N=S.v,O=S.w;A.removeEdge(N,O),A.setEdge(E.v,E.w,{}),u(A),s(A,w),v(A,w)}function v(A,w){var S=A.nodes().find(N=>!w.node(N).parent),E=r(A,S);E=E.slice(1),E.forEach(N=>{var O=A.node(N).parent,$=w.edge(N,O),M=!1;$||($=w.edge(O,N),M=!0),w.node(N).rank=w.node(O).rank+(M?$.minlen:-$.minlen)})}function g(A,w,S){return A.hasEdge(w,S)}function y(A,w,S){return S.low<=w.lim&&w.lim<=S.lim}return W6}var Q6,qY;function $He(){if(qY)return Q6;qY=1;var e=Ub(),t=e.longestPath,n=QY(),r=OHe();Q6=o;function o(l){var c=l.graph().ranker;if(c instanceof Function)return c(l);switch(l.graph().ranker){case"network-simplex":s(l);break;case"tight-tree":a(l);break;case"longest-path":i(l);break;case"none":break;default:s(l)}}var i=t;function a(l){t(l),n(l)}function s(l){r(l)}return Q6}var K6,GY;function MHe(){if(GY)return K6;GY=1,K6=e;function e(r){let o=n(r);r.graph().dummyChains.forEach(i=>{let a=r.node(i),s=a.edgeObj,l=t(r,o,s.v,s.w),c=l.path,u=l.lca,d=0,h=c[d],p=!0;for(;i!==s.w;){if(a=r.node(i),p){for(;(h=c[d])!==u&&r.node(h).maxRank<a.rank;)d++;h===u&&(p=!1)}if(!p){for(;d<c.length-1&&r.node(h=c[d+1]).minRank<=a.rank;)d++;h=c[d]}r.setParent(i,h),i=r.successors(i)[0]}})}function t(r,o,i,a){let s=[],l=[],c=Math.min(o[i].low,o[a].low),u=Math.max(o[i].lim,o[a].lim),d,h;d=i;do d=r.parent(d),s.push(d);while(d&&(o[d].low>c||u>o[d].lim));for(h=d,d=a;(d=r.parent(d))!==h;)l.push(d);return{path:s.concat(l.reverse()),lca:h}}function n(r){let o={},i=0;function a(s){let l=i;r.children(s).forEach(a),o[s]={low:l,lim:i++}}return r.children().forEach(a),o}return K6}var q6,UY;function PHe(){if(UY)return q6;UY=1;let e=wo();q6={run:t,cleanup:i};function t(a){let s=e.addDummyNode(a,"root",{},"_root"),l=r(a),c=Object.values(l),u=e.applyWithChunking(Math.max,c)-1,d=2*u+1;a.graph().nestingRoot=s,a.edges().forEach(p=>a.edge(p).minlen*=d);let h=o(a)+1;a.children().forEach(p=>n(a,s,d,h,u,l,p)),a.graph().nodeRankFactor=d}function n(a,s,l,c,u,d,h){let p=a.children(h);if(!p.length){h!==s&&a.setEdge(s,h,{weight:0,minlen:l});return}let m=e.addBorderNode(a,"_bt"),v=e.addBorderNode(a,"_bb"),g=a.node(h);a.setParent(m,h),g.borderTop=m,a.setParent(v,h),g.borderBottom=v,p.forEach(y=>{n(a,s,l,c,u,d,y);let A=a.node(y),w=A.borderTop?A.borderTop:y,S=A.borderBottom?A.borderBottom:y,E=A.borderTop?c:2*c,N=w!==S?1:u-d[h]+1;a.setEdge(m,w,{weight:E,minlen:N,nestingEdge:!0}),a.setEdge(S,v,{weight:E,minlen:N,nestingEdge:!0})}),a.parent(h)||a.setEdge(s,m,{weight:0,minlen:u+d[h]})}function r(a){var s={};function l(c,u){var d=a.children(c);d&&d.length&&d.forEach(h=>l(h,u+1)),s[c]=u}return a.children().forEach(c=>l(c,1)),s}function o(a){return a.edges().reduce((s,l)=>s+a.edge(l).weight,0)}function i(a){var s=a.graph();a.removeNode(s.nestingRoot),delete s.nestingRoot,a.edges().forEach(l=>{var c=a.edge(l);c.nestingEdge&&a.removeEdge(l)})}return q6}var G6,YY;function THe(){if(YY)return G6;YY=1;let e=wo();G6=t;function t(r){function o(i){let a=r.children(i),s=r.node(i);if(a.length&&a.forEach(o),Object.hasOwn(s,"minRank")){s.borderLeft=[],s.borderRight=[];for(let l=s.minRank,c=s.maxRank+1;l<c;++l)n(r,"borderLeft","_bl",i,s,l),n(r,"borderRight","_br",i,s,l)}}r.children().forEach(o)}function n(r,o,i,a,s,l){let c={width:0,height:0,rank:l,borderType:o},u=s[o][l-1],d=e.addDummyNode(r,"border",c,i);s[o][l]=d,r.setParent(d,a),u&&r.setEdge(u,d,{weight:1})}return G6}var U6,XY;function _He(){if(XY)return U6;XY=1,U6={adjust:e,undo:t};function e(l){let c=l.graph().rankdir.toLowerCase();(c==="lr"||c==="rl")&&n(l)}function t(l){let c=l.graph().rankdir.toLowerCase();(c==="bt"||c==="rl")&&o(l),(c==="lr"||c==="rl")&&(a(l),n(l))}function n(l){l.nodes().forEach(c=>r(l.node(c))),l.edges().forEach(c=>r(l.edge(c)))}function r(l){let c=l.width;l.width=l.height,l.height=c}function o(l){l.nodes().forEach(c=>i(l.node(c))),l.edges().forEach(c=>{let u=l.edge(c);u.points.forEach(i),Object.hasOwn(u,"y")&&i(u)})}function i(l){l.y=-l.y}function a(l){l.nodes().forEach(c=>s(l.node(c))),l.edges().forEach(c=>{let u=l.edge(c);u.points.forEach(s),Object.hasOwn(u,"x")&&s(u)})}function s(l){let c=l.x;l.x=l.y,l.y=c}return U6}var Y6,ZY;function DHe(){if(ZY)return Y6;ZY=1;let e=wo();Y6=t;function t(n){let r={},o=n.nodes().filter(u=>!n.children(u).length),i=o.map(u=>n.node(u).rank),a=e.applyWithChunking(Math.max,i),s=e.range(a+1).map(()=>[]);function l(u){if(r[u])return;r[u]=!0;let d=n.node(u);s[d.rank].push(u),n.successors(u).forEach(l)}return o.sort((u,d)=>n.node(u).rank-n.node(d).rank).forEach(l),s}return Y6}var X6,JY;function kHe(){if(JY)return X6;JY=1;let e=wo().zipObject;X6=t;function t(r,o){let i=0;for(let a=1;a<o.length;++a)i+=n(r,o[a-1],o[a]);return i}function n(r,o,i){let a=e(i,i.map((h,p)=>p)),s=o.flatMap(h=>r.outEdges(h).map(p=>({pos:a[p.w],weight:r.edge(p).weight})).sort((p,m)=>p.pos-m.pos)),l=1;for(;l<i.length;)l<<=1;let c=2*l-1;l-=1;let u=new Array(c).fill(0),d=0;return s.forEach(h=>{let p=h.pos+l;u[p]+=h.weight;let m=0;for(;p>0;)p%2&&(m+=u[p+1]),p=p-1>>1,u[p]+=h.weight;d+=h.weight*m}),d}return X6}var Z6,eX;function BHe(){if(eX)return Z6;eX=1,Z6=e;function e(t,n=[]){return n.map(r=>{let o=t.inEdges(r);if(o.length){let i=o.reduce((a,s)=>{let l=t.edge(s),c=t.node(s.v);return{sum:a.sum+l.weight*c.order,weight:a.weight+l.weight}},{sum:0,weight:0});return{v:r,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:r}})}return Z6}var J6,tX;function LHe(){if(tX)return J6;tX=1;let e=wo();J6=t;function t(o,i){let a={};o.forEach((l,c)=>{let u=a[l.v]={indegree:0,in:[],out:[],vs:[l.v],i:c};l.barycenter!==void 0&&(u.barycenter=l.barycenter,u.weight=l.weight)}),i.edges().forEach(l=>{let c=a[l.v],u=a[l.w];c!==void 0&&u!==void 0&&(u.indegree++,c.out.push(a[l.w]))});let s=Object.values(a).filter(l=>!l.indegree);return n(s)}function n(o){let i=[];function a(l){return c=>{c.merged||(c.barycenter===void 0||l.barycenter===void 0||c.barycenter>=l.barycenter)&&r(l,c)}}function s(l){return c=>{c.in.push(l),--c.indegree===0&&o.push(c)}}for(;o.length;){let l=o.pop();i.push(l),l.in.reverse().forEach(a(l)),l.out.forEach(s(l))}return i.filter(l=>!l.merged).map(l=>e.pick(l,["vs","i","barycenter","weight"]))}function r(o,i){let a=0,s=0;o.weight&&(a+=o.barycenter*o.weight,s+=o.weight),i.weight&&(a+=i.barycenter*i.weight,s+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=a/s,o.weight=s,o.i=Math.min(i.i,o.i),i.merged=!0}return J6}var eN,nX;function FHe(){if(nX)return eN;nX=1;let e=wo();eN=t;function t(o,i){let a=e.partition(o,m=>Object.hasOwn(m,"barycenter")),s=a.lhs,l=a.rhs.sort((m,v)=>v.i-m.i),c=[],u=0,d=0,h=0;s.sort(r(!!i)),h=n(c,l,h),s.forEach(m=>{h+=m.vs.length,c.push(m.vs),u+=m.barycenter*m.weight,d+=m.weight,h=n(c,l,h)});let p={vs:c.flat(!0)};return d&&(p.barycenter=u/d,p.weight=d),p}function n(o,i,a){let s;for(;i.length&&(s=i[i.length-1]).i<=a;)i.pop(),o.push(s.vs),a++;return a}function r(o){return(i,a)=>i.barycenter<a.barycenter?-1:i.barycenter>a.barycenter?1:o?a.i-i.i:i.i-a.i}return eN}var tN,rX;function zHe(){if(rX)return tN;rX=1;let e=BHe(),t=LHe(),n=FHe();tN=r;function r(a,s,l,c){let u=a.children(s),d=a.node(s),h=d?d.borderLeft:void 0,p=d?d.borderRight:void 0,m={};h&&(u=u.filter(A=>A!==h&&A!==p));let v=e(a,u);v.forEach(A=>{if(a.children(A.v).length){let w=r(a,A.v,l,c);m[A.v]=w,Object.hasOwn(w,"barycenter")&&i(A,w)}});let g=t(v,l);o(g,m);let y=n(g,c);if(h&&(y.vs=[h,y.vs,p].flat(!0),a.predecessors(h).length)){let A=a.node(a.predecessors(h)[0]),w=a.node(a.predecessors(p)[0]);Object.hasOwn(y,"barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+A.order+w.order)/(y.weight+2),y.weight+=2}return y}function o(a,s){a.forEach(l=>{l.vs=l.vs.flatMap(c=>s[c]?s[c].vs:c)})}function i(a,s){a.barycenter!==void 0?(a.barycenter=(a.barycenter*a.weight+s.barycenter*s.weight)/(a.weight+s.weight),a.weight+=s.weight):(a.barycenter=s.barycenter,a.weight=s.weight)}return tN}var nN,oX;function VHe(){if(oX)return nN;oX=1;let e=ss().Graph,t=wo();nN=n;function n(o,i,a){let s=r(o),l=new e({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(c=>o.node(c));return o.nodes().forEach(c=>{let u=o.node(c),d=o.parent(c);(u.rank===i||u.minRank<=i&&i<=u.maxRank)&&(l.setNode(c),l.setParent(c,d||s),o[a](c).forEach(h=>{let p=h.v===c?h.w:h.v,m=l.edge(p,c),v=m!==void 0?m.weight:0;l.setEdge(p,c,{weight:o.edge(h).weight+v})}),Object.hasOwn(u,"minRank")&&l.setNode(c,{borderLeft:u.borderLeft[i],borderRight:u.borderRight[i]}))}),l}function r(o){for(var i;o.hasNode(i=t.uniqueId("_root")););return i}return nN}var rN,iX;function jHe(){if(iX)return rN;iX=1,rN=e;function e(t,n,r){let o={},i;r.forEach(a=>{let s=t.parent(a),l,c;for(;s;){if(l=t.parent(s),l?(c=o[l],o[l]=s):(c=i,i=s),c&&c!==s){n.setEdge(c,s);return}s=l}})}return rN}var oN,aX;function HHe(){if(aX)return oN;aX=1;let e=DHe(),t=kHe(),n=zHe(),r=VHe(),o=jHe(),i=ss().Graph,a=wo();oN=s;function s(d,h){if(h&&typeof h.customOrder=="function"){h.customOrder(d,s);return}let p=a.maxRank(d),m=l(d,a.range(1,p+1),"inEdges"),v=l(d,a.range(p-1,-1,-1),"outEdges"),g=e(d);if(u(d,g),h&&h.disableOptimalOrderHeuristic)return;let y=Number.POSITIVE_INFINITY,A;for(let w=0,S=0;S<4;++w,++S){c(w%2?m:v,w%4>=2),g=a.buildLayerMatrix(d);let E=t(d,g);E<y&&(S=0,A=Object.assign({},g),y=E)}u(d,A)}function l(d,h,p){return h.map(function(m){return r(d,m,p)})}function c(d,h){let p=new i;d.forEach(function(m){let v=m.graph().root,g=n(m,v,p,h);g.vs.forEach((y,A)=>m.node(y).order=A),o(m,p,g.vs)})}function u(d,h){Object.values(h).forEach(p=>p.forEach((m,v)=>d.node(m).order=v))}return oN}var iN,sX;function RHe(){if(sX)return iN;sX=1;let e=ss().Graph,t=wo();iN={positionX:p,findType1Conflicts:n,findType2Conflicts:r,addConflict:i,hasConflict:a,verticalAlignment:s,horizontalCompaction:l,alignCoordinates:d,findSmallestWidthAlignment:u,balance:h};function n(g,y){let A={};function w(S,E){let N=0,O=0,$=S.length,M=E[E.length-1];return E.forEach((P,_)=>{let D=o(g,P),B=D?g.node(D).order:$;(D||P===M)&&(E.slice(O,_+1).forEach(T=>{g.predecessors(T).forEach(k=>{let F=g.node(k),z=F.order;(z<N||B<z)&&!(F.dummy&&g.node(T).dummy)&&i(A,k,T)})}),O=_+1,N=B)}),E}return y.length&&y.reduce(w),A}function r(g,y){let A={};function w(E,N,O,$,M){let P;t.range(N,O).forEach(_=>{P=E[_],g.node(P).dummy&&g.predecessors(P).forEach(D=>{let B=g.node(D);B.dummy&&(B.order<$||B.order>M)&&i(A,D,P)})})}function S(E,N){let O=-1,$,M=0;return N.forEach((P,_)=>{if(g.node(P).dummy==="border"){let D=g.predecessors(P);D.length&&($=g.node(D[0]).order,w(N,M,_,O,$),M=_,O=$)}w(N,M,N.length,$,E.length)}),N}return y.length&&y.reduce(S),A}function o(g,y){if(g.node(y).dummy)return g.predecessors(y).find(A=>g.node(A).dummy)}function i(g,y,A){if(y>A){let S=y;y=A,A=S}let w=g[y];w||(g[y]=w={}),w[A]=!0}function a(g,y,A){if(y>A){let w=y;y=A,A=w}return!!g[y]&&Object.hasOwn(g[y],A)}function s(g,y,A,w){let S={},E={},N={};return y.forEach(O=>{O.forEach(($,M)=>{S[$]=$,E[$]=$,N[$]=M})}),y.forEach(O=>{let $=-1;O.forEach(M=>{let P=w(M);if(P.length){P=P.sort((D,B)=>N[D]-N[B]);let _=(P.length-1)/2;for(let D=Math.floor(_),B=Math.ceil(_);D<=B;++D){let T=P[D];E[M]===M&&$<N[T]&&!a(A,M,T)&&(E[T]=M,E[M]=S[M]=S[T],$=N[T])}}})}),{root:S,align:E}}function l(g,y,A,w,S){let E={},N=c(g,y,A,S),O=S?"borderLeft":"borderRight";function $(_,D){let B=N.nodes(),T=B.pop(),k={};for(;T;)k[T]?_(T):(k[T]=!0,B.push(T),B=B.concat(D(T))),T=B.pop()}function M(_){E[_]=N.inEdges(_).reduce((D,B)=>Math.max(D,E[B.v]+N.edge(B)),0)}function P(_){let D=N.outEdges(_).reduce((T,k)=>Math.min(T,E[k.w]-N.edge(k)),Number.POSITIVE_INFINITY),B=g.node(_);D!==Number.POSITIVE_INFINITY&&B.borderType!==O&&(E[_]=Math.max(E[_],D))}return $(M,N.predecessors.bind(N)),$(P,N.successors.bind(N)),Object.keys(w).forEach(_=>E[_]=E[A[_]]),E}function c(g,y,A,w){let S=new e,E=g.graph(),N=m(E.nodesep,E.edgesep,w);return y.forEach(O=>{let $;O.forEach(M=>{let P=A[M];if(S.setNode(P),$){var _=A[$],D=S.edge(_,P);S.setEdge(_,P,Math.max(N(g,M,$),D||0))}$=M})}),S}function u(g,y){return Object.values(y).reduce((A,w)=>{let S=Number.NEGATIVE_INFINITY,E=Number.POSITIVE_INFINITY;Object.entries(w).forEach(([O,$])=>{let M=v(g,O)/2;S=Math.max($+M,S),E=Math.min($-M,E)});const N=S-E;return N<A[0]&&(A=[N,w]),A},[Number.POSITIVE_INFINITY,null])[1]}function d(g,y){let A=Object.values(y),w=t.applyWithChunking(Math.min,A),S=t.applyWithChunking(Math.max,A);["u","d"].forEach(E=>{["l","r"].forEach(N=>{let O=E+N,$=g[O];if($===y)return;let M=Object.values($),P=w-t.applyWithChunking(Math.min,M);N!=="l"&&(P=S-t.applyWithChunking(Math.max,M)),P&&(g[O]=t.mapValues($,_=>_+P))})})}function h(g,y){return t.mapValues(g.ul,(A,w)=>{if(y)return g[y.toLowerCase()][w];{let S=Object.values(g).map(E=>E[w]).sort((E,N)=>E-N);return(S[1]+S[2])/2}})}function p(g){let y=t.buildLayerMatrix(g),A=Object.assign(n(g,y),r(g,y)),w={},S;["u","d"].forEach(N=>{S=N==="u"?y:Object.values(y).reverse(),["l","r"].forEach(O=>{O==="r"&&(S=S.map(_=>Object.values(_).reverse()));let $=(N==="u"?g.predecessors:g.successors).bind(g),M=s(g,S,A,$),P=l(g,S,M.root,M.align,O==="r");O==="r"&&(P=t.mapValues(P,_=>-_)),w[N+O]=P})});let E=u(g,w);return d(w,E),h(w,g.graph().align)}function m(g,y,A){return(w,S,E)=>{let N=w.node(S),O=w.node(E),$=0,M;if($+=N.width/2,Object.hasOwn(N,"labelpos"))switch(N.labelpos.toLowerCase()){case"l":M=-N.width/2;break;case"r":M=N.width/2;break}if(M&&($+=A?M:-M),M=0,$+=(N.dummy?y:g)/2,$+=(O.dummy?y:g)/2,$+=O.width/2,Object.hasOwn(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":M=O.width/2;break;case"r":M=-O.width/2;break}return M&&($+=A?M:-M),M=0,$}}function v(g,y){return g.node(y).width}return iN}var aN,lX;function WHe(){if(lX)return aN;lX=1;let e=wo(),t=RHe().positionX;aN=n;function n(o){o=e.asNonCompoundGraph(o),r(o),Object.entries(t(o)).forEach(([i,a])=>o.node(i).x=a)}function r(o){let i=e.buildLayerMatrix(o),a=o.graph().ranksep,s=0;i.forEach(l=>{const c=l.reduce((u,d)=>{const h=o.node(d).height;return u>h?u:h},0);l.forEach(u=>o.node(u).y=s+c/2),s+=c+a})}return aN}var sN,cX;function QHe(){if(cX)return sN;cX=1;let e=IHe(),t=NHe(),n=$He(),r=wo().normalizeRanks,o=MHe(),i=wo().removeEmptyRanks,a=PHe(),s=THe(),l=_He(),c=HHe(),u=WHe(),d=wo(),h=ss().Graph;sN=p;function p(H,W){let R=W&&W.debugTiming?d.time:d.notime;R("layout",()=>{let U=R(" buildLayoutGraph",()=>$(H));R(" runLayout",()=>m(U,R,W)),R(" updateInputGraph",()=>v(H,U))})}function m(H,W,R){W(" makeSpaceForEdgeLabels",()=>M(H)),W(" removeSelfEdges",()=>j(H)),W(" acyclic",()=>e.run(H)),W(" nestingGraph.run",()=>a.run(H)),W(" rank",()=>n(d.asNonCompoundGraph(H))),W(" injectEdgeLabelProxies",()=>P(H)),W(" removeEmptyRanks",()=>i(H)),W(" nestingGraph.cleanup",()=>a.cleanup(H)),W(" normalizeRanks",()=>r(H)),W(" assignRankMinMax",()=>_(H)),W(" removeEdgeLabelProxies",()=>D(H)),W(" normalize.run",()=>t.run(H)),W(" parentDummyChains",()=>o(H)),W(" addBorderSegments",()=>s(H)),W(" order",()=>c(H,R)),W(" insertSelfEdges",()=>V(H)),W(" adjustCoordinateSystem",()=>l.adjust(H)),W(" position",()=>u(H)),W(" positionSelfEdges",()=>Q(H)),W(" removeBorderNodes",()=>z(H)),W(" normalize.undo",()=>t.undo(H)),W(" fixupEdgeLabelCoords",()=>k(H)),W(" undoCoordinateSystem",()=>l.undo(H)),W(" translateGraph",()=>B(H)),W(" assignNodeIntersects",()=>T(H)),W(" reversePoints",()=>F(H)),W(" acyclic.undo",()=>e.undo(H))}function v(H,W){H.nodes().forEach(R=>{let U=H.node(R),ee=W.node(R);U&&(U.x=ee.x,U.y=ee.y,U.rank=ee.rank,W.children(R).length&&(U.width=ee.width,U.height=ee.height))}),H.edges().forEach(R=>{let U=H.edge(R),ee=W.edge(R);U.points=ee.points,Object.hasOwn(ee,"x")&&(U.x=ee.x,U.y=ee.y)}),H.graph().width=W.graph().width,H.graph().height=W.graph().height}let g=["nodesep","edgesep","ranksep","marginx","marginy"],y={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},A=["acyclicer","ranker","rankdir","align"],w=["width","height","rank"],S={width:0,height:0},E=["minlen","weight","width","height","labeloffset"],N={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},O=["labelpos"];function $(H){let W=new h({multigraph:!0,compound:!0}),R=G(H.graph());return W.setGraph(Object.assign({},y,K(R,g),d.pick(R,A))),H.nodes().forEach(U=>{let ee=G(H.node(U));const Y=K(ee,w);Object.keys(S).forEach(ne=>{Y[ne]===void 0&&(Y[ne]=S[ne])}),W.setNode(U,Y),W.setParent(U,H.parent(U))}),H.edges().forEach(U=>{let ee=G(H.edge(U));W.setEdge(U,Object.assign({},N,K(ee,E),d.pick(ee,O)))}),W}function M(H){let W=H.graph();W.ranksep/=2,H.edges().forEach(R=>{let U=H.edge(R);U.minlen*=2,U.labelpos.toLowerCase()!=="c"&&(W.rankdir==="TB"||W.rankdir==="BT"?U.width+=U.labeloffset:U.height+=U.labeloffset)})}function P(H){H.edges().forEach(W=>{let R=H.edge(W);if(R.width&&R.height){let U=H.node(W.v),Y={rank:(H.node(W.w).rank-U.rank)/2+U.rank,e:W};d.addDummyNode(H,"edge-proxy",Y,"_ep")}})}function _(H){let W=0;H.nodes().forEach(R=>{let U=H.node(R);U.borderTop&&(U.minRank=H.node(U.borderTop).rank,U.maxRank=H.node(U.borderBottom).rank,W=Math.max(W,U.maxRank))}),H.graph().maxRank=W}function D(H){H.nodes().forEach(W=>{let R=H.node(W);R.dummy==="edge-proxy"&&(H.edge(R.e).labelRank=R.rank,H.removeNode(W))})}function B(H){let W=Number.POSITIVE_INFINITY,R=0,U=Number.POSITIVE_INFINITY,ee=0,Y=H.graph(),ne=Y.marginx||0,oe=Y.marginy||0;function X(Z){let ie=Z.x,te=Z.y,de=Z.width,ce=Z.height;W=Math.min(W,ie-de/2),R=Math.max(R,ie+de/2),U=Math.min(U,te-ce/2),ee=Math.max(ee,te+ce/2)}H.nodes().forEach(Z=>X(H.node(Z))),H.edges().forEach(Z=>{let ie=H.edge(Z);Object.hasOwn(ie,"x")&&X(ie)}),W-=ne,U-=oe,H.nodes().forEach(Z=>{let ie=H.node(Z);ie.x-=W,ie.y-=U}),H.edges().forEach(Z=>{let ie=H.edge(Z);ie.points.forEach(te=>{te.x-=W,te.y-=U}),Object.hasOwn(ie,"x")&&(ie.x-=W),Object.hasOwn(ie,"y")&&(ie.y-=U)}),Y.width=R-W+ne,Y.height=ee-U+oe}function T(H){H.edges().forEach(W=>{let R=H.edge(W),U=H.node(W.v),ee=H.node(W.w),Y,ne;R.points?(Y=R.points[0],ne=R.points[R.points.length-1]):(R.points=[],Y=ee,ne=U),R.points.unshift(d.intersectRect(U,Y)),R.points.push(d.intersectRect(ee,ne))})}function k(H){H.edges().forEach(W=>{let R=H.edge(W);if(Object.hasOwn(R,"x"))switch((R.labelpos==="l"||R.labelpos==="r")&&(R.width-=R.labeloffset),R.labelpos){case"l":R.x-=R.width/2+R.labeloffset;break;case"r":R.x+=R.width/2+R.labeloffset;break}})}function F(H){H.edges().forEach(W=>{let R=H.edge(W);R.reversed&&R.points.reverse()})}function z(H){H.nodes().forEach(W=>{if(H.children(W).length){let R=H.node(W),U=H.node(R.borderTop),ee=H.node(R.borderBottom),Y=H.node(R.borderLeft[R.borderLeft.length-1]),ne=H.node(R.borderRight[R.borderRight.length-1]);R.width=Math.abs(ne.x-Y.x),R.height=Math.abs(ee.y-U.y),R.x=Y.x+R.width/2,R.y=U.y+R.height/2}}),H.nodes().forEach(W=>{H.node(W).dummy==="border"&&H.removeNode(W)})}function j(H){H.edges().forEach(W=>{if(W.v===W.w){var R=H.node(W.v);R.selfEdges||(R.selfEdges=[]),R.selfEdges.push({e:W,label:H.edge(W)}),H.removeEdge(W)}})}function V(H){var W=d.buildLayerMatrix(H);W.forEach(R=>{var U=0;R.forEach((ee,Y)=>{var ne=H.node(ee);ne.order=Y+U,(ne.selfEdges||[]).forEach(oe=>{d.addDummyNode(H,"selfedge",{width:oe.label.width,height:oe.label.height,rank:ne.rank,order:Y+ ++U,e:oe.e,label:oe.label},"_se")}),delete ne.selfEdges})})}function Q(H){H.nodes().forEach(W=>{var R=H.node(W);if(R.dummy==="selfedge"){var U=H.node(R.e.v),ee=U.x+U.width/2,Y=U.y,ne=R.x-ee,oe=U.height/2;H.setEdge(R.e,R.label),H.removeNode(W),R.label.points=[{x:ee+2*ne/3,y:Y-oe},{x:ee+5*ne/6,y:Y-oe},{x:ee+ne,y:Y},{x:ee+5*ne/6,y:Y+oe},{x:ee+2*ne/3,y:Y+oe}],R.label.x=R.x,R.label.y=R.y}})}function K(H,W){return d.mapValues(d.pick(H,W),Number)}function G(H){var W={};return H&&Object.entries(H).forEach(([R,U])=>{typeof R=="string"&&(R=R.toLowerCase()),W[R]=U}),W}return sN}var lN,uX;function KHe(){if(uX)return lN;uX=1;let e=wo(),t=ss().Graph;lN={debugOrdering:n};function n(r){let o=e.buildLayerMatrix(r),i=new t({compound:!0,multigraph:!0}).setGraph({});return r.nodes().forEach(a=>{i.setNode(a,{label:a}),i.setParent(a,"layer"+r.node(a).rank)}),r.edges().forEach(a=>i.setEdge(a.v,a.w,{},a.name)),o.forEach((a,s)=>{let l="layer"+s;i.setNode(l,{rank:"same"}),a.reduce((c,u)=>(i.setEdge(c,u,{style:"invis"}),u))}),i}return lN}var cN,dX;function qHe(){return dX||(dX=1,cN="1.1.5"),cN}var uN,fX;function GHe(){return fX||(fX=1,uN={graphlib:ss(),layout:QHe(),debug:KHe(),util:{time:wo().time,notime:wo().notime},version:qHe()}),uN}var UHe=GHe();const hX=li(UHe),YHe=()=>{const{getNodes:e,getEdges:t,setNodes:n,setEdges:r,fitView:o}=Fn(),i=s=>{const l=document.querySelector(`[data-id="${s}"]`);if(!l)return{width:180,height:60};const c=l.getBoundingClientRect();return{width:Math.max(60,c.width),height:Math.max(30,c.height)}};return{layout:(s="LR")=>{const l=e(),c=t();l.length&&requestAnimationFrame(()=>{const u=s==="LR",d=new hX.graphlib.Graph;d.setDefaultEdgeLabel(()=>({})),d.setGraph({rankdir:s,ranksep:120,nodesep:80}),l.forEach(p=>{const{width:m,height:v}=i(p.id);d.setNode(p.id,{width:m,height:v})}),c.forEach(p=>d.setEdge(p.source,p.target)),hX.layout(d);const h=l.map(p=>{const m=d.node(p.id),{width:v,height:g}=i(p.id);return{...p,position:{x:m.x-v/2,y:m.y-g/2},targetPosition:u?"left":"top",sourcePosition:u?"right":"bottom"}});n(h),r(c),requestAnimationFrame(()=>o({duration:400,padding:.3}))})}}};var XHe="scripts_editor_k7c3wx0",vc="scripts_editor_k7c3wx1",ZHe="scripts_editor_k7c3wx2",dN="scripts_editor_k7c3wx3",JHe="scripts_editor_k7c3wx4";const eRe=()=>{const e=mr(),[t,n]=I.useState(()=>e.getState().transform[2]);return I.useEffect(()=>{let r=e.getState().transform[2];return e.subscribe(i=>{const a=i.transform[2];a!==r&&(r=a,n(a))})},[e]),C.jsxs("span",{className:JHe,children:[Math.round(t*100)/2,"%"]})},tRe=I.memo(()=>{const{zoomIn:e,zoomOut:t,fitView:n}=Fn(),{layout:r}=YHe(),{undo:o,redo:i,canUndo:a,canRedo:s}=nHe(),{mode:l,toggleMode:c}=$G();return C.jsxs("div",{className:XHe,children:[C.jsx("button",{type:"button",disabled:!a,className:vc,onClick:o,children:C.jsx(cHe,{size:18})}),C.jsx("button",{type:"button",disabled:!s,className:vc,onClick:i,children:C.jsx(lHe,{size:18})}),C.jsx("div",{className:dN}),C.jsx("button",{type:"button",className:vc,onClick:()=>r(),children:C.jsx(tOe,{})}),C.jsx("button",{type:"button",className:vc,onClick:()=>n({padding:.2}),children:C.jsx(aHe,{size:18})}),C.jsx("div",{className:dN}),C.jsx("button",{type:"button",className:vc,onClick:()=>e(),children:C.jsx(sHe,{size:18})}),C.jsx(eRe,{}),C.jsx("button",{type:"button",className:vc,onClick:()=>t(),children:C.jsx(iHe,{size:18})}),C.jsx("div",{className:dN}),C.jsx("button",{type:"button",className:`${vc} ${l==="trackpad"?ZHe:""}`,onClick:c,children:C.jsx(uHe,{size:18})}),C.jsx("button",{type:"button",className:vc,children:C.jsx(dHe,{size:18})})]})});var fN,pX;function nRe(){if(pX)return fN;pX=1;var e=JU(),t=uY(),n=LU(),r=Gb(),o=tY(),i=W5(),a=UU(),s=Y5(),l="[object Map]",c="[object Set]",u=Object.prototype,d=u.hasOwnProperty;function h(p){if(p==null)return!0;if(o(p)&&(r(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||s(p)||n(p)))return!p.length;var m=t(p);if(m==l||m==c)return!p.size;if(a(p))return!e(p).length;for(var v in p)if(d.call(p,v))return!1;return!0}return fN=h,fN}var rRe=nRe();const oRe=li(rRe);var gX="scripts_editor_ohkkdt0",Yb="scripts_editor_ohkkdt1",Xb="scripts_editor_ohkkdt2",iRe="scripts_editor_ohkkdt3",hN="scripts_editor_ohkkdt4",pN="scripts_editor_ohkkdt5",aRe="scripts_editor_ohkkdt6",sRe="scripts_editor_ohkkdt7",lRe="scripts_editor_ohkkdt8";const mX=e=>C.jsx(Kn,{...e,direction:"vertical",size:10}),vX=I.memo(({keyId:e,Icon:t,label:n,active:r,color:o,isLongLabel:i,onDragStart:a})=>{const s=I.useCallback(l=>a(l,e),[a,e]);return C.jsxs(dt,{draggable:!0,type:"text",style:{minHeight:i?62:52},className:r?`${Xb} ${iRe} `:`${Xb}`,onDragStart:s,children:[C.jsx("span",{className:hN,style:{color:o},children:C.jsx(t,{})}),C.jsx("span",{className:pN,children:n})]},e)},(e,t)=>e.keyId===t.keyId&&e.label===t.label&&e.active===t.active&&e.color===t.color&&e.isLongLabel===t.isLongLabel&&e.onDragStart===t.onDragStart),cRe=()=>{const[e,t]=kb(),{BLOCKS_ENABLED:n}=Ho(),r=I.useCallback((a,s)=>{a.dataTransfer.effectAllowed="move",requestAnimationFrame(()=>t(s))},[t]);if(oRe(n))return null;const o=I.useMemo(()=>Hb.filter(a=>(n==null?void 0:n.includes(a.key))&&a.group===1),[n]),i=I.useMemo(()=>Hb.filter(a=>(n==null?void 0:n.includes(a.key))&&a.group===2),[n]);return C.jsxs("div",{className:gX,children:[C.jsx(Bs,{className:Yb,wrapperTag:mX,children:o.map(a=>{const s=a.icon,l=a.active,c=a.label.includes(`
|
|
696
|
+
Request`,icon:FE,group:2},{key:st.CONDITION,label:"Điều kiện",icon:BF,group:2},{key:st.GROUP,label:"Nhóm",icon:XF,group:2}],Rb=[{label:"Trigger",key:"trigger",icon:E3,iconProps:{variant:"Bold"},group:1,color:"#FAAD14",items:[{key:st.TRIGGER_CONTACT,label:"Liên hệ",description:"Liên hệ thay đổi",icon:Hx,group:"CRM",color:"#096DD9"},{key:st.CALLBOT_TRIGGER,label:"Callbot",description:"Chiến dịch được tạo",icon:WE,group:"Đa kênh",color:"#096DD9"}]},{label:"CRM",key:"crm",icon:w3,iconProps:{variant:"Bold"},group:2,color:"#1D39C4",items:[{key:st.CONTACT_ACTION,label:"Liên hệ",description:"Thực hiện hành động với liên hệ",icon:Hx,color:"#096DD9"},{key:st.ORDER_ACTION,label:"Đơn hàng",description:"Thực hiện hành động với đơn hàng",icon:dz,color:"#096DD9"}]},{label:"Đa kênh",key:"chat",icon:ZW,iconProps:{variant:"Bold"},group:2,color:"#08979C",items:[{key:st.EMAIL,label:"Email",description:"Gửi email",icon:S3,iconProps:{variant:"Bold"},color:"#096DD9"}]},{label:"Logic",key:"logic",icon:Y1,group:2,color:"#D46B08",items:[{key:st.DELAY,label:"Hẹn giờ",description:"Hẹn giờ",icon:oj,color:"#D4380D"},{key:st.BRANCH,label:"Rẽ nhánh",description:"Rẽ nhánh",icon:Y1,color:"#D4380D"},{key:st.AI_AGENT,label:"AI Agent",description:"AI Agent",icon:x3,iconProps:{variant:"Bold"},color:"#D4380D"}]},{label:"Tích hợp",key:"integration",icon:FE,group:2,color:"#08979C",items:[]}],Cl={[st.AGENT]:"#FAAD14",[st.START]:"none",[st.SPEAK]:"#d7268a",[st.LISTEN]:"#d2691e",[st.TRANSFER]:"#20b2aa",[st.CRM]:"#1890ff",[st.HTTP_REQUEST]:"#20b2aa",[st.CONDITION]:"#1890ff",[st.GROUP]:"#8c8c8c",[st.TRIGGER_CONTACT]:"#1890FF",[st.CALLBOT_TRIGGER]:"#1890FF",[st.ORDER_TRIGGER]:"#1890FF",[st.CONTACT_ACTION]:"#1890FF",[st.CALLBOT_ACTION]:"#1890FF",[st.ORDER_ACTION]:"#1890FF",[st.EMAIL]:"#1890FF",[st.DELAY]:"#D4380D",[st.BRANCH]:"#D4380D",[st.AI_AGENT]:"#D4380D"};var CG="scripts_editor_223f7c0",AG="scripts_editor_223f7c2";const TVe={autoCallButton:({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:i,targetPosition:a,style:s,target:l,markerEnd:c})=>{const{isOpen:u,onOpen:d,onClose:h}=Xr(),{setEdges:p,setNodes:m}=Fn(),[v,g,y]=Bv({sourceX:t,sourceY:n,sourcePosition:i,targetX:r,targetY:o,targetPosition:a}),A=[...Hb.map(E=>({label:C.jsxs(Kn,{align:"center",size:8,children:[I.createElement(E.icon,{style:{color:Cl[E.key]}}),E.label]}),key:E.key}))],w=E=>{E.preventDefault(),d()},S=({key:E})=>{const N=E,O={id:`${N.toLowerCase()}_${xu()}`,type:N,position:{x:g,y},data:{title:_f[N],...Cg[N]},deletable:!0,...Ag[N]};m($=>$.concat(O)),p($=>{const M=$.find(B=>B.id===e);if(!M)return $;const{source:P,target:_}=M,D=$.filter(B=>B.id!==e);return D.push({id:`${P}_${O.id}_${xu()}`,source:P,target:O.id,type:"autoCallButton"}),wG.includes(N)&&D.push({id:`${O.id}_${_}_${xu()}`,source:O.id,target:_,type:"autoCallButton"}),D}),h()};return C.jsxs(C.Fragment,{children:[C.jsx(Nd,{path:v,markerEnd:c,style:s??{}}),C.jsx($M,{children:C.jsx(tr,{title:"Thêm nút",children:C.jsx("div",{className:`${CG} nodrag nopan ${u?AG:""}`,style:{transform:`translate(-50%, -50%) translate(${g}px,${y}px)`},children:C.jsx(Ms,{onOpenChange:E=>{E?d():h()},menu:{items:A,onClick:S},open:u,trigger:["click"],children:C.jsx(dt,{onClick:w,type:"text",size:"large",style:{padding:4},children:C.jsx(dg,{style:{fontSize:24}})})})})})})]})},autoFlowButton:e=>{const{id:t,sourceX:n,sourceY:r,targetX:o,targetY:i,sourcePosition:a,targetPosition:s,style:l,markerEnd:c}=e,{isOpen:u,onOpen:d,onClose:h}=Xr(),{setEdges:p,setNodes:m}=Fn(),[v,g,y]=I.useMemo(()=>Bv({sourceX:n,sourceY:r,sourcePosition:a,targetX:o,targetY:i,targetPosition:s}),[n,r,o,i,a,s]),A=I.useMemo(()=>Rb.map(O=>({key:O.key,label:C.jsxs(Kn,{align:"center",size:8,children:[C.jsx("span",{style:{color:O.color||Cl[O.key]},children:C.jsx(O.icon,{...O.iconProps,size:20})}),C.jsx("span",{children:O.label})]}),children:O.items.map($=>({key:$.key,label:C.jsxs(Kn,{align:"center",size:8,children:[C.jsx("span",{style:{color:$.color||Cl[$.key]},children:C.jsx($.icon,{...$.iconProps,size:14})}),C.jsx("span",{children:$.label})]})}))})),[]),w=I.useCallback(O=>({id:`${O.toLowerCase()}_${xu()}`,type:O,position:{x:g,y},data:{title:_f[O],...Cg[O]},deletable:!0,...Ag[O]}),[g,y]),S=I.useCallback(({key:O})=>{const M=w(O);m(P=>[...P,M]),p(P=>{const _=P.find(k=>k.id===t);if(!_)return P;const{source:D,target:B}=_,T=xu();return[...P.filter(k=>k.id!==t),{id:`${D}_${M.id}_${T}`,source:D,target:M.id,type:"autoFlowButton"},{id:`${M.id}_${B}_${T}`,source:M.id,target:B,type:"autoFlowButton"}]}),h()},[t,w,m,p,h]),E=I.useCallback(O=>{O.preventDefault(),d()},[d]),N=I.useMemo(()=>({transform:`translate(-50%, -50%) translate(${g}px,${y}px)`}),[g,y]);return C.jsxs(C.Fragment,{children:[C.jsx(Nd,{path:v,markerEnd:c,style:l}),C.jsx($M,{children:C.jsx(tr,{title:"Thêm nút",children:C.jsx("div",{className:`${CG} nodrag nopan ${u?AG:""}`,style:N,children:C.jsx(Ms,{open:u,trigger:["click"],menu:{items:A,onClick:S},onOpenChange:O=>O?d():h(),children:C.jsx(dt,{onClick:E,type:"text",size:"large",style:{padding:4},children:C.jsx(dg,{style:{fontSize:24}})})})})})})]})}},wG=[st.SPEAK];function _Ve(){const{getNodes:e,getEdges:t}=Fn(),n=Bb();return{isValidConnection:I.useCallback(o=>{const i=e();t();const a=i.find(s=>s.id===o.target);return(a==null?void 0:a.id)===o.source?(n.error({key:"self-loop",content:"Không thể kết nối node vào chính nó"}),!1):!0},[t,e,n])}}var DVe="scripts_editor_3c0va90",kVe="scripts_editor_3c0va91",BVe="scripts_editor_3c0va93",LVe="scripts_editor_3c0va94",FVe="scripts_editor_3c0va95",zVe="scripts_editor_3c0va96",mc="scripts_editor_3c0va97",VVe="scripts_editor_3c0va98",jVe="scripts_editor_3c0va99",SG="scripts_editor_3c0va9a";function EG(e){return ar({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20"},child:[]},{tag:"path",attr:{d:"M8 11h8"},child:[]},{tag:"path",attr:{d:"M8 7h6"},child:[]}]})(e)}const HVe={version:"1.14.3"};var gh=(e=>(e.BOT="bot",e.CLONE="clone",e))(gh||{});function zI(e){const t=e.getState(),{nodes:n,edges:r,transform:o}=t;return{nodes:n,edges:r,viewport:{x:o[0],y:o[1],zoom:o[2]}}}function RVe({cb:e,delay:t=1e3,enabled:n=!0}){const r=mr(),o=I.useRef(e),i=I.useRef(zI(r)),a=I.useRef(i.current.viewport.zoom);I.useEffect(()=>{o.current=n?e:void 0},[e,n]);const s=I.useCallback(()=>{var v;if(!n)return;const u=zI(r),d=i.current,h=Ht.isEqual(u.nodes,d.nodes),p=Ht.isEqual(u.edges,d.edges),m=Ht.isEqual(u.viewport,d.viewport);h&&p&&m||(i.current=u,a.current=u.viewport.zoom,(v=o.current)==null||v.call(o,u))},[r,n]),l=I.useMemo(()=>Ht.debounce(s,t),[s,t]);I.useEffect(()=>{const u=r.subscribe(()=>l());return()=>{l.cancel(),u()}},[r,l]),MM({onChange:({zoom:u})=>{n&&u!==a.current&&(a.current=u,l())}});const c=I.useCallback(()=>{const u=zI(r);i.current=u,a.current=u.viewport.zoom},[r]);return{commit:l,resetCommitState:c}}const xG=e=>{let t;const n=new Set,r=(c,u)=>{const d=typeof c=="function"?c(t):c;if(!Object.is(d,t)){const h=t;t=u??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(p=>p(t,h))}},o=()=>t,s={setState:r,getState:o,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=t=e(r,o,s);return s},WVe=e=>e?xG(e):xG,QVe=e=>e;function KVe(e,t=QVe){const n=I.useSyncExternalStore(e.subscribe,I.useCallback(()=>t(e.getState()),[e,t]),I.useCallback(()=>t(e.getInitialState()),[e,t]));return I.useDebugValue(n),n}const IG=e=>{const t=WVe(e),n=r=>KVe(t,r);return Object.assign(n,t),n},NG=e=>e?IG(e):IG,OG=NG(e=>({mode:"trackpad",toggleMode:()=>e(t=>({mode:t.mode==="trackpad"?"mouse":"trackpad"}))}));function $G(){const e=OG(r=>r.mode),t=OG(r=>r.toggleMode),n=I.useMemo(()=>e==="trackpad"?{panOnScroll:!0,panOnDrag:!1,zoomOnScroll:!1,zoomOnPinch:!0,zoomOnDoubleClick:!1}:{panOnScroll:!1,panOnDrag:!0,zoomOnScroll:!0,zoomOnPinch:!1,zoomOnDoubleClick:!1},[e]);return{mode:e,toggleMode:t,flowProps:n}}var VI,MG;function qVe(){if(MG)return VI;MG=1;function e(){this.__data__=[],this.size=0}return VI=e,VI}var jI,PG;function TG(){if(PG)return jI;PG=1;function e(t,n){return t===n||t!==t&&n!==n}return jI=e,jI}var HI,_G;function Wb(){if(_G)return HI;_G=1;var e=TG();function t(n,r){for(var o=n.length;o--;)if(e(n[o][0],r))return o;return-1}return HI=t,HI}var RI,DG;function GVe(){if(DG)return RI;DG=1;var e=Wb(),t=Array.prototype,n=t.splice;function r(o){var i=this.__data__,a=e(i,o);if(a<0)return!1;var s=i.length-1;return a==s?i.pop():n.call(i,a,1),--this.size,!0}return RI=r,RI}var WI,kG;function UVe(){if(kG)return WI;kG=1;var e=Wb();function t(n){var r=this.__data__,o=e(r,n);return o<0?void 0:r[o][1]}return WI=t,WI}var QI,BG;function YVe(){if(BG)return QI;BG=1;var e=Wb();function t(n){return e(this.__data__,n)>-1}return QI=t,QI}var KI,LG;function XVe(){if(LG)return KI;LG=1;var e=Wb();function t(n,r){var o=this.__data__,i=e(o,n);return i<0?(++this.size,o.push([n,r])):o[i][1]=r,this}return KI=t,KI}var qI,FG;function Qb(){if(FG)return qI;FG=1;var e=qVe(),t=GVe(),n=UVe(),r=YVe(),o=XVe();function i(a){var s=-1,l=a==null?0:a.length;for(this.clear();++s<l;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=n,i.prototype.has=r,i.prototype.set=o,qI=i,qI}var GI,zG;function ZVe(){if(zG)return GI;zG=1;var e=Qb();function t(){this.__data__=new e,this.size=0}return GI=t,GI}var UI,VG;function JVe(){if(VG)return UI;VG=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return UI=e,UI}var YI,jG;function eje(){if(jG)return YI;jG=1;function e(t){return this.__data__.get(t)}return YI=e,YI}var XI,HG;function tje(){if(HG)return XI;HG=1;function e(t){return this.__data__.has(t)}return XI=e,XI}var ZI,RG;function WG(){if(RG)return ZI;RG=1;var e=tm(),t=Ab(),n="[object AsyncFunction]",r="[object Function]",o="[object GeneratorFunction]",i="[object Proxy]";function a(s){if(!t(s))return!1;var l=e(s);return l==r||l==o||l==n||l==i}return ZI=a,ZI}var JI,QG;function nje(){if(QG)return JI;QG=1;var e=js(),t=e["__core-js_shared__"];return JI=t,JI}var e5,KG;function rje(){if(KG)return e5;KG=1;var e=nje(),t=function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function n(r){return!!t&&t in r}return e5=n,e5}var t5,qG;function GG(){if(qG)return t5;qG=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return t5=n,t5}var n5,UG;function oje(){if(UG)return n5;UG=1;var e=WG(),t=rje(),n=Ab(),r=GG(),o=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,a=Function.prototype,s=Object.prototype,l=a.toString,c=s.hasOwnProperty,u=RegExp("^"+l.call(c).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(h){if(!n(h)||t(h))return!1;var p=e(h)?u:i;return p.test(r(h))}return n5=d,n5}var r5,YG;function ije(){if(YG)return r5;YG=1;function e(t,n){return t==null?void 0:t[n]}return r5=e,r5}var o5,XG;function mh(){if(XG)return o5;XG=1;var e=oje(),t=ije();function n(r,o){var i=t(r,o);return e(i)?i:void 0}return o5=n,o5}var i5,ZG;function a5(){if(ZG)return i5;ZG=1;var e=mh(),t=js(),n=e(t,"Map");return i5=n,i5}var s5,JG;function Kb(){if(JG)return s5;JG=1;var e=mh(),t=e(Object,"create");return s5=t,s5}var l5,eU;function aje(){if(eU)return l5;eU=1;var e=Kb();function t(){this.__data__=e?e(null):{},this.size=0}return l5=t,l5}var c5,tU;function sje(){if(tU)return c5;tU=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return c5=e,c5}var u5,nU;function lje(){if(nU)return u5;nU=1;var e=Kb(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function o(i){var a=this.__data__;if(e){var s=a[i];return s===t?void 0:s}return r.call(a,i)?a[i]:void 0}return u5=o,u5}var d5,rU;function cje(){if(rU)return d5;rU=1;var e=Kb(),t=Object.prototype,n=t.hasOwnProperty;function r(o){var i=this.__data__;return e?i[o]!==void 0:n.call(i,o)}return d5=r,d5}var f5,oU;function uje(){if(oU)return f5;oU=1;var e=Kb(),t="__lodash_hash_undefined__";function n(r,o){var i=this.__data__;return this.size+=this.has(r)?0:1,i[r]=e&&o===void 0?t:o,this}return f5=n,f5}var h5,iU;function dje(){if(iU)return h5;iU=1;var e=aje(),t=sje(),n=lje(),r=cje(),o=uje();function i(a){var s=-1,l=a==null?0:a.length;for(this.clear();++s<l;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=n,i.prototype.has=r,i.prototype.set=o,h5=i,h5}var p5,aU;function fje(){if(aU)return p5;aU=1;var e=dje(),t=Qb(),n=a5();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return p5=r,p5}var g5,sU;function hje(){if(sU)return g5;sU=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return g5=e,g5}var m5,lU;function qb(){if(lU)return m5;lU=1;var e=hje();function t(n,r){var o=n.__data__;return e(r)?o[typeof r=="string"?"string":"hash"]:o.map}return m5=t,m5}var v5,cU;function pje(){if(cU)return v5;cU=1;var e=qb();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return v5=t,v5}var y5,uU;function gje(){if(uU)return y5;uU=1;var e=qb();function t(n){return e(this,n).get(n)}return y5=t,y5}var b5,dU;function mje(){if(dU)return b5;dU=1;var e=qb();function t(n){return e(this,n).has(n)}return b5=t,b5}var C5,fU;function vje(){if(fU)return C5;fU=1;var e=qb();function t(n,r){var o=e(this,n),i=o.size;return o.set(n,r),this.size+=o.size==i?0:1,this}return C5=t,C5}var A5,hU;function pU(){if(hU)return A5;hU=1;var e=fje(),t=pje(),n=gje(),r=mje(),o=vje();function i(a){var s=-1,l=a==null?0:a.length;for(this.clear();++s<l;){var c=a[s];this.set(c[0],c[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=n,i.prototype.has=r,i.prototype.set=o,A5=i,A5}var w5,gU;function yje(){if(gU)return w5;gU=1;var e=Qb(),t=a5(),n=pU(),r=200;function o(i,a){var s=this.__data__;if(s instanceof e){var l=s.__data__;if(!t||l.length<r-1)return l.push([i,a]),this.size=++s.size,this;s=this.__data__=new n(l)}return s.set(i,a),this.size=s.size,this}return w5=o,w5}var S5,mU;function bje(){if(mU)return S5;mU=1;var e=Qb(),t=ZVe(),n=JVe(),r=eje(),o=tje(),i=yje();function a(s){var l=this.__data__=new e(s);this.size=l.size}return a.prototype.clear=t,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=o,a.prototype.set=i,S5=a,S5}var E5,vU;function Cje(){if(vU)return E5;vU=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return E5=t,E5}var x5,yU;function Aje(){if(yU)return x5;yU=1;function e(t){return this.__data__.has(t)}return x5=e,x5}var I5,bU;function wje(){if(bU)return I5;bU=1;var e=pU(),t=Cje(),n=Aje();function r(o){var i=-1,a=o==null?0:o.length;for(this.__data__=new e;++i<a;)this.add(o[i])}return r.prototype.add=r.prototype.push=t,r.prototype.has=n,I5=r,I5}var N5,CU;function Sje(){if(CU)return N5;CU=1;function e(t,n){for(var r=-1,o=t==null?0:t.length;++r<o;)if(n(t[r],r,t))return!0;return!1}return N5=e,N5}var O5,AU;function Eje(){if(AU)return O5;AU=1;function e(t,n){return t.has(n)}return O5=e,O5}var $5,wU;function SU(){if(wU)return $5;wU=1;var e=wje(),t=Sje(),n=Eje(),r=1,o=2;function i(a,s,l,c,u,d){var h=l&r,p=a.length,m=s.length;if(p!=m&&!(h&&m>p))return!1;var v=d.get(a),g=d.get(s);if(v&&g)return v==s&&g==a;var y=-1,A=!0,w=l&o?new e:void 0;for(d.set(a,s),d.set(s,a);++y<p;){var S=a[y],E=s[y];if(c)var N=h?c(E,S,y,s,a,d):c(S,E,y,a,s,d);if(N!==void 0){if(N)continue;A=!1;break}if(w){if(!t(s,function(O,$){if(!n(w,$)&&(S===O||u(S,O,l,c,d)))return w.push($)})){A=!1;break}}else if(!(S===E||u(S,E,l,c,d))){A=!1;break}}return d.delete(a),d.delete(s),A}return $5=i,$5}var M5,EU;function xje(){if(EU)return M5;EU=1;var e=js(),t=e.Uint8Array;return M5=t,M5}var P5,xU;function Ije(){if(xU)return P5;xU=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(o,i){r[++n]=[i,o]}),r}return P5=e,P5}var T5,IU;function Nje(){if(IU)return T5;IU=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(o){r[++n]=o}),r}return T5=e,T5}var _5,NU;function Oje(){if(NU)return _5;NU=1;var e=eI(),t=xje(),n=TG(),r=SU(),o=Ije(),i=Nje(),a=1,s=2,l="[object Boolean]",c="[object Date]",u="[object Error]",d="[object Map]",h="[object Number]",p="[object RegExp]",m="[object Set]",v="[object String]",g="[object Symbol]",y="[object ArrayBuffer]",A="[object DataView]",w=e?e.prototype:void 0,S=w?w.valueOf:void 0;function E(N,O,$,M,P,_,D){switch($){case A:if(N.byteLength!=O.byteLength||N.byteOffset!=O.byteOffset)return!1;N=N.buffer,O=O.buffer;case y:return!(N.byteLength!=O.byteLength||!_(new t(N),new t(O)));case l:case c:case h:return n(+N,+O);case u:return N.name==O.name&&N.message==O.message;case p:case v:return N==O+"";case d:var B=o;case m:var T=M&a;if(B||(B=i),N.size!=O.size&&!T)return!1;var k=D.get(N);if(k)return k==O;M|=s,D.set(N,O);var F=r(B(N),B(O),M,P,_,D);return D.delete(N),F;case g:if(S)return S.call(N)==S.call(O)}return!1}return _5=E,_5}var D5,OU;function $je(){if(OU)return D5;OU=1;function e(t,n){for(var r=-1,o=n.length,i=t.length;++r<o;)t[i+r]=n[r];return t}return D5=e,D5}var k5,$U;function Gb(){if($U)return k5;$U=1;var e=Array.isArray;return k5=e,k5}var B5,MU;function Mje(){if(MU)return B5;MU=1;var e=$je(),t=Gb();function n(r,o,i){var a=o(r);return t(r)?a:e(a,i(r))}return B5=n,B5}var L5,PU;function Pje(){if(PU)return L5;PU=1;function e(t,n){for(var r=-1,o=t==null?0:t.length,i=0,a=[];++r<o;){var s=t[r];n(s,r,t)&&(a[i++]=s)}return a}return L5=e,L5}var F5,TU;function Tje(){if(TU)return F5;TU=1;function e(){return[]}return F5=e,F5}var z5,_U;function _je(){if(_U)return z5;_U=1;var e=Pje(),t=Tje(),n=Object.prototype,r=n.propertyIsEnumerable,o=Object.getOwnPropertySymbols,i=o?function(a){return a==null?[]:(a=Object(a),e(o(a),function(s){return r.call(a,s)}))}:t;return z5=i,z5}var V5,DU;function Dje(){if(DU)return V5;DU=1;function e(t,n){for(var r=-1,o=Array(t);++r<t;)o[r]=n(r);return o}return V5=e,V5}var j5,kU;function kje(){if(kU)return j5;kU=1;var e=tm(),t=nm(),n="[object Arguments]";function r(o){return t(o)&&e(o)==n}return j5=r,j5}var H5,BU;function LU(){if(BU)return H5;BU=1;var e=kje(),t=nm(),n=Object.prototype,r=n.hasOwnProperty,o=n.propertyIsEnumerable,i=e(function(){return arguments}())?e:function(a){return t(a)&&r.call(a,"callee")&&!o.call(a,"callee")};return H5=i,H5}var pm={exports:{}},R5,FU;function Bje(){if(FU)return R5;FU=1;function e(){return!1}return R5=e,R5}pm.exports;var zU;function W5(){return zU||(zU=1,function(e,t){var n=js(),r=Bje(),o=t&&!t.nodeType&&t,i=o&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===o,s=a?n.Buffer:void 0,l=s?s.isBuffer:void 0,c=l||r;e.exports=c}(pm,pm.exports)),pm.exports}var Q5,VU;function Lje(){if(VU)return Q5;VU=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(r,o){var i=typeof r;return o=o??e,!!o&&(i=="number"||i!="symbol"&&t.test(r))&&r>-1&&r%1==0&&r<o}return Q5=n,Q5}var K5,jU;function HU(){if(jU)return K5;jU=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return K5=t,K5}var q5,RU;function Fje(){if(RU)return q5;RU=1;var e=tm(),t=HU(),n=nm(),r="[object Arguments]",o="[object Array]",i="[object Boolean]",a="[object Date]",s="[object Error]",l="[object Function]",c="[object Map]",u="[object Number]",d="[object Object]",h="[object RegExp]",p="[object Set]",m="[object String]",v="[object WeakMap]",g="[object ArrayBuffer]",y="[object DataView]",A="[object Float32Array]",w="[object Float64Array]",S="[object Int8Array]",E="[object Int16Array]",N="[object Int32Array]",O="[object Uint8Array]",$="[object Uint8ClampedArray]",M="[object Uint16Array]",P="[object Uint32Array]",_={};_[A]=_[w]=_[S]=_[E]=_[N]=_[O]=_[$]=_[M]=_[P]=!0,_[r]=_[o]=_[g]=_[i]=_[y]=_[a]=_[s]=_[l]=_[c]=_[u]=_[d]=_[h]=_[p]=_[m]=_[v]=!1;function D(B){return n(B)&&t(B.length)&&!!_[e(B)]}return q5=D,q5}var G5,WU;function zje(){if(WU)return G5;WU=1;function e(t){return function(n){return t(n)}}return G5=e,G5}var gm={exports:{}};gm.exports;var QU;function Vje(){return QU||(QU=1,function(e,t){var n=tK(),r=t&&!t.nodeType&&t,o=r&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===r,a=i&&n.process,s=function(){try{var l=o&&o.require&&o.require("util").types;return l||a&&a.binding&&a.binding("util")}catch{}}();e.exports=s}(gm,gm.exports)),gm.exports}var U5,KU;function Y5(){if(KU)return U5;KU=1;var e=Fje(),t=zje(),n=Vje(),r=n&&n.isTypedArray,o=r?t(r):e;return U5=o,U5}var X5,qU;function jje(){if(qU)return X5;qU=1;var e=Dje(),t=LU(),n=Gb(),r=W5(),o=Lje(),i=Y5(),a=Object.prototype,s=a.hasOwnProperty;function l(c,u){var d=n(c),h=!d&&t(c),p=!d&&!h&&r(c),m=!d&&!h&&!p&&i(c),v=d||h||p||m,g=v?e(c.length,String):[],y=g.length;for(var A in c)(u||s.call(c,A))&&!(v&&(A=="length"||p&&(A=="offset"||A=="parent")||m&&(A=="buffer"||A=="byteLength"||A=="byteOffset")||o(A,y)))&&g.push(A);return g}return X5=l,X5}var Z5,GU;function UU(){if(GU)return Z5;GU=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,o=typeof r=="function"&&r.prototype||e;return n===o}return Z5=t,Z5}var J5,YU;function Hje(){if(YU)return J5;YU=1;function e(t,n){return function(r){return t(n(r))}}return J5=e,J5}var e6,XU;function Rje(){if(XU)return e6;XU=1;var e=Hje(),t=e(Object.keys,Object);return e6=t,e6}var t6,ZU;function JU(){if(ZU)return t6;ZU=1;var e=UU(),t=Rje(),n=Object.prototype,r=n.hasOwnProperty;function o(i){if(!e(i))return t(i);var a=[];for(var s in Object(i))r.call(i,s)&&s!="constructor"&&a.push(s);return a}return t6=o,t6}var n6,eY;function tY(){if(eY)return n6;eY=1;var e=WG(),t=HU();function n(r){return r!=null&&t(r.length)&&!e(r)}return n6=n,n6}var r6,nY;function Wje(){if(nY)return r6;nY=1;var e=jje(),t=JU(),n=tY();function r(o){return n(o)?e(o):t(o)}return r6=r,r6}var o6,rY;function Qje(){if(rY)return o6;rY=1;var e=Mje(),t=_je(),n=Wje();function r(o){return e(o,n,t)}return o6=r,o6}var i6,oY;function Kje(){if(oY)return i6;oY=1;var e=Qje(),t=1,n=Object.prototype,r=n.hasOwnProperty;function o(i,a,s,l,c,u){var d=s&t,h=e(i),p=h.length,m=e(a),v=m.length;if(p!=v&&!d)return!1;for(var g=p;g--;){var y=h[g];if(!(d?y in a:r.call(a,y)))return!1}var A=u.get(i),w=u.get(a);if(A&&w)return A==a&&w==i;var S=!0;u.set(i,a),u.set(a,i);for(var E=d;++g<p;){y=h[g];var N=i[y],O=a[y];if(l)var $=d?l(O,N,y,a,i,u):l(N,O,y,i,a,u);if(!($===void 0?N===O||c(N,O,s,l,u):$)){S=!1;break}E||(E=y=="constructor")}if(S&&!E){var M=i.constructor,P=a.constructor;M!=P&&"constructor"in i&&"constructor"in a&&!(typeof M=="function"&&M instanceof M&&typeof P=="function"&&P instanceof P)&&(S=!1)}return u.delete(i),u.delete(a),S}return i6=o,i6}var a6,iY;function qje(){if(iY)return a6;iY=1;var e=mh(),t=js(),n=e(t,"DataView");return a6=n,a6}var s6,aY;function Gje(){if(aY)return s6;aY=1;var e=mh(),t=js(),n=e(t,"Promise");return s6=n,s6}var l6,sY;function Uje(){if(sY)return l6;sY=1;var e=mh(),t=js(),n=e(t,"Set");return l6=n,l6}var c6,lY;function Yje(){if(lY)return c6;lY=1;var e=mh(),t=js(),n=e(t,"WeakMap");return c6=n,c6}var u6,cY;function uY(){if(cY)return u6;cY=1;var e=qje(),t=a5(),n=Gje(),r=Uje(),o=Yje(),i=tm(),a=GG(),s="[object Map]",l="[object Object]",c="[object Promise]",u="[object Set]",d="[object WeakMap]",h="[object DataView]",p=a(e),m=a(t),v=a(n),g=a(r),y=a(o),A=i;return(e&&A(new e(new ArrayBuffer(1)))!=h||t&&A(new t)!=s||n&&A(n.resolve())!=c||r&&A(new r)!=u||o&&A(new o)!=d)&&(A=function(w){var S=i(w),E=S==l?w.constructor:void 0,N=E?a(E):"";if(N)switch(N){case p:return h;case m:return s;case v:return c;case g:return u;case y:return d}return S}),u6=A,u6}var d6,dY;function Xje(){if(dY)return d6;dY=1;var e=bje(),t=SU(),n=Oje(),r=Kje(),o=uY(),i=Gb(),a=W5(),s=Y5(),l=1,c="[object Arguments]",u="[object Array]",d="[object Object]",h=Object.prototype,p=h.hasOwnProperty;function m(v,g,y,A,w,S){var E=i(v),N=i(g),O=E?u:o(v),$=N?u:o(g);O=O==c?d:O,$=$==c?d:$;var M=O==d,P=$==d,_=O==$;if(_&&a(v)){if(!a(g))return!1;E=!0,M=!1}if(_&&!M)return S||(S=new e),E||s(v)?t(v,g,y,A,w,S):n(v,g,O,y,A,w,S);if(!(y&l)){var D=M&&p.call(v,"__wrapped__"),B=P&&p.call(g,"__wrapped__");if(D||B){var T=D?v.value():v,k=B?g.value():g;return S||(S=new e),w(T,k,y,A,S)}}return _?(S||(S=new e),r(v,g,y,A,w,S)):!1}return d6=m,d6}var f6,fY;function Zje(){if(fY)return f6;fY=1;var e=Xje(),t=nm();function n(r,o,i,a,s){return r===o?!0:r==null||o==null||!t(r)&&!t(o)?r!==r&&o!==o:e(r,o,i,a,n,s)}return f6=n,f6}var h6,hY;function Jje(){if(hY)return h6;hY=1;var e=Zje();function t(n,r){return e(n,r)}return h6=t,h6}var eHe=Jje();const p6=li(eHe);function g6(e){const t=e.getState(),{nodes:n,edges:r,transform:o}=t;return{nodes:n,edges:r,viewport:{x:o[0],y:o[1],zoom:o[2]}}}const tHe=()=>{const e=mr(),{setNodes:t,setEdges:n,setViewport:r}=Fn(),[o,i]=I.useState([g6(e)]),[a,s]=I.useState(0),l=I.useRef(!1),c=I.useRef(!1),u=I.useRef(g6(e)),d=I.useRef(u.current.viewport.zoom),h=A=>{c.current=A},p=I.useCallback(()=>{if(l.current||c.current)return;const A=g6(e),w=u.current,S=p6(A.nodes,w.nodes),E=p6(A.edges,w.edges),N=p6(A.viewport,w.viewport);if(S&&E&&N)return;const O=o.slice(0,a+1);O.push(A),i(O),s(O.length-1),u.current=A,d.current=A.viewport.zoom},[e,o,a]),m=I.useMemo(()=>pK(p,300),[p]),v=I.useCallback(A=>{if(A<0||A>=o.length)return;l.current=!0,m.cancel();const w=o[A];t(w.nodes),n(w.edges),r(w.viewport),s(A),u.current=w,d.current=w.viewport.zoom,requestAnimationFrame(()=>{l.current=!1})},[o,t,n,r,m]),g=I.useCallback(()=>{a>0&&v(a-1)},[a,v]),y=I.useCallback(()=>{a<o.length-1&&v(a+1)},[a,o.length,v]);return I.useEffect(()=>{const A=e.subscribe(()=>{m()});return()=>{m.cancel(),A()}},[e,m]),MM({onChange:({zoom:A})=>{A!==d.current&&(d.current=A,m())}}),{undo:g,redo:y,canUndo:a>0,canRedo:a<o.length-1,commit:m,setIsDragging:h}},m6=e=>{try{const t=e.nodes.map(o=>({id:o.id,position:o.position})),n=e.edges.map(o=>({id:o.id,source:o.source,target:o.target})),r=e.viewport;return JSON.stringify({nodes:t,edges:n,viewport:r})}catch{return JSON.stringify(e)}},mm=NG((e,t)=>({history:[],currentStep:-1,pushSnapshot:n=>e(r=>{const o=m6(n),i=r.history[r.currentStep];if(i&&m6(i)===o)return{};const a=r.history.slice(0,r.currentStep+1);a.push(n);const s={history:a,currentStep:a.length-1};return{...s,canUndo:(s.currentStep??0)>0,canRedo:(s.currentStep??0)<a.length-1}}),applySnapshot:n=>{const r=t();if(n<0||n>=r.history.length)return null;const o=r.history[n];return e(()=>({currentStep:n,canUndo:n>0,canRedo:n<r.history.length-1})),o},reset:n=>e(()=>({history:n?[n]:[],currentStep:n?0:-1,canUndo:!1,canRedo:!1})),canUndo:!1,canRedo:!1})),nHe=()=>{const e=mm(c=>c.currentStep),t=mm(c=>c.history.length),n=e>0,r=e<t-1,{setNodes:o,setEdges:i,setViewport:a}=Fn(),s=I.useCallback(()=>{const c=mm.getState(),u=c.currentStep;if(u>0){const d=c.applySnapshot(u-1);d&&(o==null||o(d.nodes??[]),i==null||i(d.edges??[]),d.viewport&&(a==null||a(d.viewport)))}},[o,i,a]),l=I.useCallback(()=>{const c=mm.getState(),u=c.currentStep;if(u<c.history.length-1){const d=c.applySnapshot(u+1);d&&(o==null||o(d.nodes??[]),i==null||i(d.edges??[]),d.viewport&&(a==null||a(d.viewport)))}},[o,i,a]);return{canUndo:n,canRedo:r,undo:s,redo:l}},rHe=e=>{const{getNodes:t,getEdges:n,getViewport:r}=Fn(),o=I.useRef(null),i=I.useRef(null),a=e==null?void 0:e.snapshotDebounceMs,s=I.useCallback(()=>{const c={nodes:t()??[],edges:n()??[],viewport:r?r():null},u=m6(c);i.current!==u&&(i.current=u,mm.getState().pushSnapshot(c))},[t,n,r]),l=I.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>{s(),o.current=null},a)},[a,s]);return I.useEffect(()=>(s(),()=>{o.current&&window.clearTimeout(o.current)}),[s,e==null?void 0:e.takeInitialSnapshot]),{takeSnapshotNow:s,takeSnapshotDebounced:l}};function oHe(e){return ar({attr:{t:"1569683610100",viewBox:"0 0 1024 1024",version:"1.1"},child:[{tag:"path",attr:{d:"M841 370c3-3.3 2.7-8.3-0.6-11.3-1.5-1.3-3.4-2.1-5.3-2.1h-72.6c-2.4 0-4.6 1-6.1 2.8L633.5 504.6c-2.9 3.4-7.9 3.8-11.3 0.9-0.9-0.8-1.6-1.7-2.1-2.8l-63.5-141.3c-1.3-2.9-4.1-4.7-7.3-4.7H380.7l0.9-4.7 8-42.3c10.5-55.4 38-81.4 85.8-81.4 18.6 0 35.5 1.7 48.8 4.7l14.1-66.8c-22.6-4.7-35.2-6.1-54.9-6.1-103.3 0-156.4 44.3-175.9 147.3l-9.4 49.4h-97.6c-3.8 0-7.1 2.7-7.8 6.4L181.9 415c-0.9 4.3 1.9 8.6 6.2 9.5 0.5 0.1 1.1 0.2 1.6 0.2H284l-89 429.9c-0.9 4.3 1.9 8.6 6.2 9.5 0.5 0.1 1.1 0.2 1.6 0.2H269c3.8 0 7.1-2.7 7.8-6.4l89.7-433.1h135.8l68.2 139.1c1.4 2.9 1 6.4-1.2 8.8l-180.6 203c-2.9 3.3-2.6 8.4 0.7 11.3 1.5 1.3 3.4 2 5.3 2h72.7c2.4 0 4.6-1 6.1-2.8l123.7-146.7c2.8-3.4 7.9-3.8 11.3-1 0.9 0.8 1.6 1.7 2.1 2.8L676.4 784c1.3 2.8 4.1 4.7 7.3 4.7h64.6c4.4 0 8-3.6 8-8 0-1.2-0.3-2.4-0.8-3.5l-95.2-198.9c-1.4-2.9-0.9-6.4 1.3-8.8L841 370z"},child:[]}]})(e)}function iHe(e){return ar({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"},child:[]},{tag:"path",attr:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"},child:[]}]})(e)}function aHe(e){return ar({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M952 792H72c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h880c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zm0-632H72c-4.4 0-8 3.6-8 8v56c0 4.4 3.6 8 8 8h880c4.4 0 8-3.6 8-8v-56c0-4.4-3.6-8-8-8zM848 660c8.8 0 16-7.2 16-16V380c0-8.8-7.2-16-16-16H176c-8.8 0-16 7.2-16 16v264c0 8.8 7.2 16 16 16h672zM232 436h560v152H232V436z"},child:[]}]})(e)}function sHe(e){return ar({attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"},child:[]},{tag:"path",attr:{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"},child:[]}]})(e)}function lHe(e){return ar({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M9 18h3v-2H9c-1.654 0-3-1.346-3-3s1.346-3 3-3h6v3l5-4-5-4v3H9c-2.757 0-5 2.243-5 5s2.243 5 5 5z"},child:[]}]})(e)}function cHe(e){return ar({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M9 10h6c1.654 0 3 1.346 3 3s-1.346 3-3 3h-3v2h3c2.757 0 5-2.243 5-5s-2.243-5-5-5H9V5L4 9l5 4v-3z"},child:[]}]})(e)}function uHe(e){return ar({attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{d:"M20 3H4c-1.103 0-2 .897-2 2v14c0 1.103.897 2 2 2h16c1.103 0 2-.897 2-2V5c0-1.103-.897-2-2-2zm0 2 .001 4H4V5h16zM4 19v-8h16.001l.001 8H4z"},child:[]},{tag:"path",attr:{d:"M14 6h2v2h-2zm3 0h2v2h-2z"},child:[]}]})(e)}function dHe(e){return ar({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M256 76c48.1 0 93.3 18.7 127.3 52.7S436 207.9 436 256s-18.7 93.3-52.7 127.3S304.1 436 256 436c-48.1 0-93.3-18.7-127.3-52.7S76 304.1 76 256s18.7-93.3 52.7-127.3S207.9 76 256 76m0-28C141.1 48 48 141.1 48 256s93.1 208 208 208 208-93.1 208-208S370.9 48 256 48z"},child:[]},{tag:"path",attr:{d:"M256.7 160c37.5 0 63.3 20.8 63.3 50.7 0 19.8-9.6 33.5-28.1 44.4-17.4 10.1-23.3 17.5-23.3 30.3v7.9h-34.7l-.3-8.6c-1.7-20.6 5.5-33.4 23.6-44 16.9-10.1 24-16.5 24-28.9s-12-21.5-26.9-21.5c-15.1 0-26 9.8-26.8 24.6H192c.7-32.2 24.5-54.9 64.7-54.9zm-26.3 171.4c0-11.5 9.6-20.6 21.4-20.6 11.9 0 21.5 9 21.5 20.6s-9.6 20.6-21.5 20.6-21.4-9-21.4-20.6z"},child:[]}]})(e)}var v6,pY;function y6(){if(pY)return v6;pY=1;var e="\0",t="\0",n="";class r{constructor(u){uo(this,"_isDirected",!0);uo(this,"_isMultigraph",!1);uo(this,"_isCompound",!1);uo(this,"_label");uo(this,"_defaultNodeLabelFn",()=>{});uo(this,"_defaultEdgeLabelFn",()=>{});uo(this,"_nodes",{});uo(this,"_in",{});uo(this,"_preds",{});uo(this,"_out",{});uo(this,"_sucs",{});uo(this,"_edgeObjs",{});uo(this,"_edgeLabels",{});uo(this,"_nodeCount",0);uo(this,"_edgeCount",0);uo(this,"_parent");uo(this,"_children");u&&(this._isDirected=Object.hasOwn(u,"directed")?u.directed:!0,this._isMultigraph=Object.hasOwn(u,"multigraph")?u.multigraph:!1,this._isCompound=Object.hasOwn(u,"compound")?u.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(u){return this._label=u,this}graph(){return this._label}setDefaultNodeLabel(u){return this._defaultNodeLabelFn=u,typeof u!="function"&&(this._defaultNodeLabelFn=()=>u),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var u=this;return this.nodes().filter(d=>Object.keys(u._in[d]).length===0)}sinks(){var u=this;return this.nodes().filter(d=>Object.keys(u._out[d]).length===0)}setNodes(u,d){var h=arguments,p=this;return u.forEach(function(m){h.length>1?p.setNode(m,d):p.setNode(m)}),this}setNode(u,d){return Object.hasOwn(this._nodes,u)?(arguments.length>1&&(this._nodes[u]=d),this):(this._nodes[u]=arguments.length>1?d:this._defaultNodeLabelFn(u),this._isCompound&&(this._parent[u]=t,this._children[u]={},this._children[t][u]=!0),this._in[u]={},this._preds[u]={},this._out[u]={},this._sucs[u]={},++this._nodeCount,this)}node(u){return this._nodes[u]}hasNode(u){return Object.hasOwn(this._nodes,u)}removeNode(u){var d=this;if(Object.hasOwn(this._nodes,u)){var h=p=>d.removeEdge(d._edgeObjs[p]);delete this._nodes[u],this._isCompound&&(this._removeFromParentsChildList(u),delete this._parent[u],this.children(u).forEach(function(p){d.setParent(p)}),delete this._children[u]),Object.keys(this._in[u]).forEach(h),delete this._in[u],delete this._preds[u],Object.keys(this._out[u]).forEach(h),delete this._out[u],delete this._sucs[u],--this._nodeCount}return this}setParent(u,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(d===void 0)d=t;else{d+="";for(var h=d;h!==void 0;h=this.parent(h))if(h===u)throw new Error("Setting "+d+" as parent of "+u+" would create a cycle");this.setNode(d)}return this.setNode(u),this._removeFromParentsChildList(u),this._parent[u]=d,this._children[d][u]=!0,this}_removeFromParentsChildList(u){delete this._children[this._parent[u]][u]}parent(u){if(this._isCompound){var d=this._parent[u];if(d!==t)return d}}children(u=t){if(this._isCompound){var d=this._children[u];if(d)return Object.keys(d)}else{if(u===t)return this.nodes();if(this.hasNode(u))return[]}}predecessors(u){var d=this._preds[u];if(d)return Object.keys(d)}successors(u){var d=this._sucs[u];if(d)return Object.keys(d)}neighbors(u){var d=this.predecessors(u);if(d){const p=new Set(d);for(var h of this.successors(u))p.add(h);return Array.from(p.values())}}isLeaf(u){var d;return this.isDirected()?d=this.successors(u):d=this.neighbors(u),d.length===0}filterNodes(u){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var h=this;Object.entries(this._nodes).forEach(function([v,g]){u(v)&&d.setNode(v,g)}),Object.values(this._edgeObjs).forEach(function(v){d.hasNode(v.v)&&d.hasNode(v.w)&&d.setEdge(v,h.edge(v))});var p={};function m(v){var g=h.parent(v);return g===void 0||d.hasNode(g)?(p[v]=g,g):g in p?p[g]:m(g)}return this._isCompound&&d.nodes().forEach(v=>d.setParent(v,m(v))),d}setDefaultEdgeLabel(u){return this._defaultEdgeLabelFn=u,typeof u!="function"&&(this._defaultEdgeLabelFn=()=>u),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(u,d){var h=this,p=arguments;return u.reduce(function(m,v){return p.length>1?h.setEdge(m,v,d):h.setEdge(m,v),v}),this}setEdge(){var u,d,h,p,m=!1,v=arguments[0];typeof v=="object"&&v!==null&&"v"in v?(u=v.v,d=v.w,h=v.name,arguments.length===2&&(p=arguments[1],m=!0)):(u=v,d=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),u=""+u,d=""+d,h!==void 0&&(h=""+h);var g=a(this._isDirected,u,d,h);if(Object.hasOwn(this._edgeLabels,g))return m&&(this._edgeLabels[g]=p),this;if(h!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(u),this.setNode(d),this._edgeLabels[g]=m?p:this._defaultEdgeLabelFn(u,d,h);var y=s(this._isDirected,u,d,h);return u=y.v,d=y.w,Object.freeze(y),this._edgeObjs[g]=y,o(this._preds[d],u),o(this._sucs[u],d),this._in[d][g]=y,this._out[u][g]=y,this._edgeCount++,this}edge(u,d,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,u,d,h);return this._edgeLabels[p]}edgeAsObj(){const u=this.edge(...arguments);return typeof u!="object"?{label:u}:u}hasEdge(u,d,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,u,d,h);return Object.hasOwn(this._edgeLabels,p)}removeEdge(u,d,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):a(this._isDirected,u,d,h),m=this._edgeObjs[p];return m&&(u=m.v,d=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],i(this._preds[d],u),i(this._sucs[u],d),delete this._in[d][p],delete this._out[u][p],this._edgeCount--),this}inEdges(u,d){var h=this._in[u];if(h){var p=Object.values(h);return d?p.filter(m=>m.v===d):p}}outEdges(u,d){var h=this._out[u];if(h){var p=Object.values(h);return d?p.filter(m=>m.w===d):p}}nodeEdges(u,d){var h=this.inEdges(u,d);if(h)return h.concat(this.outEdges(u,d))}}function o(c,u){c[u]?c[u]++:c[u]=1}function i(c,u){--c[u]||delete c[u]}function a(c,u,d,h){var p=""+u,m=""+d;if(!c&&p>m){var v=p;p=m,m=v}return p+n+m+n+(h===void 0?e:h)}function s(c,u,d,h){var p=""+u,m=""+d;if(!c&&p>m){var v=p;p=m,m=v}var g={v:p,w:m};return h&&(g.name=h),g}function l(c,u){return a(c,u.v,u.w,u.name)}return v6=r,v6}var b6,gY;function fHe(){return gY||(gY=1,b6="2.2.4"),b6}var C6,mY;function hHe(){return mY||(mY=1,C6={Graph:y6(),version:fHe()}),C6}var A6,vY;function pHe(){if(vY)return A6;vY=1;var e=y6();A6={write:t,read:o};function t(i){var a={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:n(i),edges:r(i)};return i.graph()!==void 0&&(a.value=structuredClone(i.graph())),a}function n(i){return i.nodes().map(function(a){var s=i.node(a),l=i.parent(a),c={v:a};return s!==void 0&&(c.value=s),l!==void 0&&(c.parent=l),c})}function r(i){return i.edges().map(function(a){var s=i.edge(a),l={v:a.v,w:a.w};return a.name!==void 0&&(l.name=a.name),s!==void 0&&(l.value=s),l})}function o(i){var a=new e(i.options).setGraph(i.value);return i.nodes.forEach(function(s){a.setNode(s.v,s.value),s.parent&&a.setParent(s.v,s.parent)}),i.edges.forEach(function(s){a.setEdge({v:s.v,w:s.w,name:s.name},s.value)}),a}return A6}var w6,yY;function gHe(){if(yY)return w6;yY=1,w6=e;function e(t){var n={},r=[],o;function i(a){Object.hasOwn(n,a)||(n[a]=!0,o.push(a),t.successors(a).forEach(i),t.predecessors(a).forEach(i))}return t.nodes().forEach(function(a){o=[],i(a),o.length&&r.push(o)}),r}return w6}var S6,bY;function CY(){if(bY)return S6;bY=1;class e{constructor(){uo(this,"_arr",[]);uo(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,r){var o=this._keyIndices;if(n=String(n),!Object.hasOwn(o,n)){var i=this._arr,a=i.length;return o[n]=a,i.push({key:n,priority:r}),this._decrease(a),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,r){var o=this._keyIndices[n];if(r>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[o].priority+" New: "+r);this._arr[o].priority=r,this._decrease(o)}_heapify(n){var r=this._arr,o=2*n,i=o+1,a=n;o<r.length&&(a=r[o].priority<r[a].priority?o:a,i<r.length&&(a=r[i].priority<r[a].priority?i:a),a!==n&&(this._swap(n,a),this._heapify(a)))}_decrease(n){for(var r=this._arr,o=r[n].priority,i;n!==0&&(i=n>>1,!(r[i].priority<o));)this._swap(n,i),n=i}_swap(n,r){var o=this._arr,i=this._keyIndices,a=o[n],s=o[r];o[n]=s,o[r]=a,i[s.key]=n,i[a.key]=r}}return S6=e,S6}var E6,AY;function wY(){if(AY)return E6;AY=1;var e=CY();E6=n;var t=()=>1;function n(o,i,a,s){return r(o,String(i),a||t,s||function(l){return o.outEdges(l)})}function r(o,i,a,s){var l={},c=new e,u,d,h=function(p){var m=p.v!==u?p.v:p.w,v=l[m],g=a(p),y=d.distance+g;if(g<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+p+" Weight: "+g);y<v.distance&&(v.distance=y,v.predecessor=u,c.decrease(m,y))};for(o.nodes().forEach(function(p){var m=p===i?0:Number.POSITIVE_INFINITY;l[p]={distance:m},c.add(p,m)});c.size()>0&&(u=c.removeMin(),d=l[u],d.distance!==Number.POSITIVE_INFINITY);)s(u).forEach(h);return l}return E6}var x6,SY;function mHe(){if(SY)return x6;SY=1;var e=wY();x6=t;function t(n,r,o){return n.nodes().reduce(function(i,a){return i[a]=e(n,a,r,o),i},{})}return x6}var I6,EY;function xY(){if(EY)return I6;EY=1,I6=e;function e(t){var n=0,r=[],o={},i=[];function a(s){var l=o[s]={onStack:!0,lowlink:n,index:n++};if(r.push(s),t.successors(s).forEach(function(d){Object.hasOwn(o,d)?o[d].onStack&&(l.lowlink=Math.min(l.lowlink,o[d].index)):(a(d),l.lowlink=Math.min(l.lowlink,o[d].lowlink))}),l.lowlink===l.index){var c=[],u;do u=r.pop(),o[u].onStack=!1,c.push(u);while(s!==u);i.push(c)}}return t.nodes().forEach(function(s){Object.hasOwn(o,s)||a(s)}),i}return I6}var N6,IY;function vHe(){if(IY)return N6;IY=1;var e=xY();N6=t;function t(n){return e(n).filter(function(r){return r.length>1||r.length===1&&n.hasEdge(r[0],r[0])})}return N6}var O6,NY;function yHe(){if(NY)return O6;NY=1,O6=t;var e=()=>1;function t(r,o,i){return n(r,o||e,i||function(a){return r.outEdges(a)})}function n(r,o,i){var a={},s=r.nodes();return s.forEach(function(l){a[l]={},a[l][l]={distance:0},s.forEach(function(c){l!==c&&(a[l][c]={distance:Number.POSITIVE_INFINITY})}),i(l).forEach(function(c){var u=c.v===l?c.w:c.v,d=o(c);a[l][u]={distance:d,predecessor:l}})}),s.forEach(function(l){var c=a[l];s.forEach(function(u){var d=a[u];s.forEach(function(h){var p=d[l],m=c[h],v=d[h],g=p.distance+m.distance;g<v.distance&&(v.distance=g,v.predecessor=m.predecessor)})})}),a}return O6}var $6,OY;function $Y(){if(OY)return $6;OY=1;function e(n){var r={},o={},i=[];function a(s){if(Object.hasOwn(o,s))throw new t;Object.hasOwn(r,s)||(o[s]=!0,r[s]=!0,n.predecessors(s).forEach(a),delete o[s],i.push(s))}if(n.sinks().forEach(a),Object.keys(r).length!==n.nodeCount())throw new t;return i}class t extends Error{constructor(){super(...arguments)}}return $6=e,e.CycleException=t,$6}var M6,MY;function bHe(){if(MY)return M6;MY=1;var e=$Y();M6=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return M6}var P6,PY;function TY(){if(PY)return P6;PY=1,P6=e;function e(o,i,a){Array.isArray(i)||(i=[i]);var s=o.isDirected()?d=>o.successors(d):d=>o.neighbors(d),l=a==="post"?t:n,c=[],u={};return i.forEach(d=>{if(!o.hasNode(d))throw new Error("Graph does not have node: "+d);l(d,s,u,c)}),c}function t(o,i,a,s){for(var l=[[o,!1]];l.length>0;){var c=l.pop();c[1]?s.push(c[0]):Object.hasOwn(a,c[0])||(a[c[0]]=!0,l.push([c[0],!0]),r(i(c[0]),u=>l.push([u,!1])))}}function n(o,i,a,s){for(var l=[o];l.length>0;){var c=l.pop();Object.hasOwn(a,c)||(a[c]=!0,s.push(c),r(i(c),u=>l.push(u)))}}function r(o,i){for(var a=o.length;a--;)i(o[a],a,o);return o}return P6}var T6,_Y;function CHe(){if(_Y)return T6;_Y=1;var e=TY();T6=t;function t(n,r){return e(n,r,"post")}return T6}var _6,DY;function AHe(){if(DY)return _6;DY=1;var e=TY();_6=t;function t(n,r){return e(n,r,"pre")}return _6}var D6,kY;function wHe(){if(kY)return D6;kY=1;var e=y6(),t=CY();D6=n;function n(r,o){var i=new e,a={},s=new t,l;function c(d){var h=d.v===l?d.w:d.v,p=s.priority(h);if(p!==void 0){var m=o(d);m<p&&(a[h]=l,s.decrease(h,m))}}if(r.nodeCount()===0)return i;r.nodes().forEach(function(d){s.add(d,Number.POSITIVE_INFINITY),i.setNode(d)}),s.decrease(r.nodes()[0],0);for(var u=!1;s.size()>0;){if(l=s.removeMin(),Object.hasOwn(a,l))i.setEdge(l,a[l]);else{if(u)throw new Error("Input graph is not connected: "+r);u=!0}r.nodeEdges(l).forEach(c)}return i}return D6}var k6,BY;function SHe(){return BY||(BY=1,k6={components:gHe(),dijkstra:wY(),dijkstraAll:mHe(),findCycles:vHe(),floydWarshall:yHe(),isAcyclic:bHe(),postorder:CHe(),preorder:AHe(),prim:wHe(),tarjan:xY(),topsort:$Y()}),k6}var B6,LY;function ss(){if(LY)return B6;LY=1;var e=hHe();return B6={Graph:e.Graph,json:pHe(),alg:SHe(),version:e.version},B6}var L6,FY;function EHe(){if(FY)return L6;FY=1;class e{constructor(){let o={};o._next=o._prev=o,this._sentinel=o}dequeue(){let o=this._sentinel,i=o._prev;if(i!==o)return t(i),i}enqueue(o){let i=this._sentinel;o._prev&&o._next&&t(o),o._next=i._next,i._next._prev=o,i._next=o,o._prev=i}toString(){let o=[],i=this._sentinel,a=i._prev;for(;a!==i;)o.push(JSON.stringify(a,n)),a=a._prev;return"["+o.join(", ")+"]"}}function t(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,o){if(r!=="_next"&&r!=="_prev")return o}return L6=e,L6}var F6,zY;function xHe(){if(zY)return F6;zY=1;let e=ss().Graph,t=EHe();F6=r;let n=()=>1;function r(c,u){if(c.nodeCount()<=1)return[];let d=a(c,u||n);return o(d.graph,d.buckets,d.zeroIdx).flatMap(p=>c.outEdges(p.v,p.w))}function o(c,u,d){let h=[],p=u[u.length-1],m=u[0],v;for(;c.nodeCount();){for(;v=m.dequeue();)i(c,u,d,v);for(;v=p.dequeue();)i(c,u,d,v);if(c.nodeCount()){for(let g=u.length-2;g>0;--g)if(v=u[g].dequeue(),v){h=h.concat(i(c,u,d,v,!0));break}}}return h}function i(c,u,d,h,p){let m=p?[]:void 0;return c.inEdges(h.v).forEach(v=>{let g=c.edge(v),y=c.node(v.v);p&&m.push({v:v.v,w:v.w}),y.out-=g,s(u,d,y)}),c.outEdges(h.v).forEach(v=>{let g=c.edge(v),y=v.w,A=c.node(y);A.in-=g,s(u,d,A)}),c.removeNode(h.v),m}function a(c,u){let d=new e,h=0,p=0;c.nodes().forEach(g=>{d.setNode(g,{v:g,in:0,out:0})}),c.edges().forEach(g=>{let y=d.edge(g.v,g.w)||0,A=u(g),w=y+A;d.setEdge(g.v,g.w,w),p=Math.max(p,d.node(g.v).out+=A),h=Math.max(h,d.node(g.w).in+=A)});let m=l(p+h+3).map(()=>new t),v=h+1;return d.nodes().forEach(g=>{s(m,v,d.node(g))}),{graph:d,buckets:m,zeroIdx:v}}function s(c,u,d){d.out?d.in?c[d.out-d.in+u].enqueue(d):c[c.length-1].enqueue(d):c[0].enqueue(d)}function l(c){const u=[];for(let d=0;d<c;d++)u.push(d);return u}return F6}var z6,VY;function wo(){if(VY)return z6;VY=1;let e=ss().Graph;z6={addBorderNode:u,addDummyNode:t,applyWithChunking:p,asNonCompoundGraph:r,buildLayerMatrix:s,intersectRect:a,mapValues:N,maxRank:m,normalizeRanks:l,notime:y,partition:v,pick:E,predecessorWeights:i,range:S,removeEmptyRanks:c,simplify:n,successorWeights:o,time:g,uniqueId:w,zipObject:O};function t($,M,P,_){for(var D=_;$.hasNode(D);)D=w(_);return P.dummy=M,$.setNode(D,P),D}function n($){let M=new e().setGraph($.graph());return $.nodes().forEach(P=>M.setNode(P,$.node(P))),$.edges().forEach(P=>{let _=M.edge(P.v,P.w)||{weight:0,minlen:1},D=$.edge(P);M.setEdge(P.v,P.w,{weight:_.weight+D.weight,minlen:Math.max(_.minlen,D.minlen)})}),M}function r($){let M=new e({multigraph:$.isMultigraph()}).setGraph($.graph());return $.nodes().forEach(P=>{$.children(P).length||M.setNode(P,$.node(P))}),$.edges().forEach(P=>{M.setEdge(P,$.edge(P))}),M}function o($){let M=$.nodes().map(P=>{let _={};return $.outEdges(P).forEach(D=>{_[D.w]=(_[D.w]||0)+$.edge(D).weight}),_});return O($.nodes(),M)}function i($){let M=$.nodes().map(P=>{let _={};return $.inEdges(P).forEach(D=>{_[D.v]=(_[D.v]||0)+$.edge(D).weight}),_});return O($.nodes(),M)}function a($,M){let P=$.x,_=$.y,D=M.x-P,B=M.y-_,T=$.width/2,k=$.height/2;if(!D&&!B)throw new Error("Not possible to find intersection inside of the rectangle");let F,z;return Math.abs(B)*T>Math.abs(D)*k?(B<0&&(k=-k),F=k*D/B,z=k):(D<0&&(T=-T),F=T,z=T*B/D),{x:P+F,y:_+z}}function s($){let M=S(m($)+1).map(()=>[]);return $.nodes().forEach(P=>{let _=$.node(P),D=_.rank;D!==void 0&&(M[D][_.order]=P)}),M}function l($){let M=$.nodes().map(_=>{let D=$.node(_).rank;return D===void 0?Number.MAX_VALUE:D}),P=p(Math.min,M);$.nodes().forEach(_=>{let D=$.node(_);Object.hasOwn(D,"rank")&&(D.rank-=P)})}function c($){let M=$.nodes().map(T=>$.node(T).rank),P=p(Math.min,M),_=[];$.nodes().forEach(T=>{let k=$.node(T).rank-P;_[k]||(_[k]=[]),_[k].push(T)});let D=0,B=$.graph().nodeRankFactor;Array.from(_).forEach((T,k)=>{T===void 0&&k%B!==0?--D:T!==void 0&&D&&T.forEach(F=>$.node(F).rank+=D)})}function u($,M,P,_){let D={width:0,height:0};return arguments.length>=4&&(D.rank=P,D.order=_),t($,"border",D,M)}function d($,M=h){const P=[];for(let _=0;_<$.length;_+=M){const D=$.slice(_,_+M);P.push(D)}return P}const h=65535;function p($,M){if(M.length>h){const P=d(M);return $.apply(null,P.map(_=>$.apply(null,_)))}else return $.apply(null,M)}function m($){const P=$.nodes().map(_=>{let D=$.node(_).rank;return D===void 0?Number.MIN_VALUE:D});return p(Math.max,P)}function v($,M){let P={lhs:[],rhs:[]};return $.forEach(_=>{M(_)?P.lhs.push(_):P.rhs.push(_)}),P}function g($,M){let P=Date.now();try{return M()}finally{console.log($+" time: "+(Date.now()-P)+"ms")}}function y($,M){return M()}let A=0;function w($){var M=++A;return $+(""+M)}function S($,M,P=1){M==null&&(M=$,$=0);let _=B=>B<M;P<0&&(_=B=>M<B);const D=[];for(let B=$;_(B);B+=P)D.push(B);return D}function E($,M){const P={};for(const _ of M)$[_]!==void 0&&(P[_]=$[_]);return P}function N($,M){let P=M;return typeof M=="string"&&(P=_=>_[M]),Object.entries($).reduce((_,[D,B])=>(_[D]=P(B,D),_),{})}function O($,M){return $.reduce((P,_,D)=>(P[_]=M[D],P),{})}return z6}var V6,jY;function IHe(){if(jY)return V6;jY=1;let e=xHe(),t=wo().uniqueId;V6={run:n,undo:o};function n(i){(i.graph().acyclicer==="greedy"?e(i,s(i)):r(i)).forEach(l=>{let c=i.edge(l);i.removeEdge(l),c.forwardName=l.name,c.reversed=!0,i.setEdge(l.w,l.v,c,t("rev"))});function s(l){return c=>l.edge(c).weight}}function r(i){let a=[],s={},l={};function c(u){Object.hasOwn(l,u)||(l[u]=!0,s[u]=!0,i.outEdges(u).forEach(d=>{Object.hasOwn(s,d.w)?a.push(d):c(d.w)}),delete s[u])}return i.nodes().forEach(c),a}function o(i){i.edges().forEach(a=>{let s=i.edge(a);if(s.reversed){i.removeEdge(a);let l=s.forwardName;delete s.reversed,delete s.forwardName,i.setEdge(a.w,a.v,s,l)}})}return V6}var j6,HY;function NHe(){if(HY)return j6;HY=1;let e=wo();j6={run:t,undo:r};function t(o){o.graph().dummyChains=[],o.edges().forEach(i=>n(o,i))}function n(o,i){let a=i.v,s=o.node(a).rank,l=i.w,c=o.node(l).rank,u=i.name,d=o.edge(i),h=d.labelRank;if(c===s+1)return;o.removeEdge(i);let p,m,v;for(v=0,++s;s<c;++v,++s)d.points=[],m={width:0,height:0,edgeLabel:d,edgeObj:i,rank:s},p=e.addDummyNode(o,"edge",m,"_d"),s===h&&(m.width=d.width,m.height=d.height,m.dummy="edge-label",m.labelpos=d.labelpos),o.setEdge(a,p,{weight:d.weight},u),v===0&&o.graph().dummyChains.push(p),a=p;o.setEdge(a,l,{weight:d.weight},u)}function r(o){o.graph().dummyChains.forEach(i=>{let a=o.node(i),s=a.edgeLabel,l;for(o.setEdge(a.edgeObj,s);a.dummy;)l=o.successors(i)[0],o.removeNode(i),s.points.push({x:a.x,y:a.y}),a.dummy==="edge-label"&&(s.x=a.x,s.y=a.y,s.width=a.width,s.height=a.height),i=l,a=o.node(i)})}return j6}var H6,RY;function Ub(){if(RY)return H6;RY=1;const{applyWithChunking:e}=wo();H6={longestPath:t,slack:n};function t(r){var o={};function i(a){var s=r.node(a);if(Object.hasOwn(o,a))return s.rank;o[a]=!0;let l=r.outEdges(a).map(u=>u==null?Number.POSITIVE_INFINITY:i(u.w)-r.edge(u).minlen);var c=e(Math.min,l);return c===Number.POSITIVE_INFINITY&&(c=0),s.rank=c}r.sources().forEach(i)}function n(r,o){return r.node(o.w).rank-r.node(o.v).rank-r.edge(o).minlen}return H6}var R6,WY;function QY(){if(WY)return R6;WY=1;var e=ss().Graph,t=Ub().slack;R6=n;function n(a){var s=new e({directed:!1}),l=a.nodes()[0],c=a.nodeCount();s.setNode(l,{});for(var u,d;r(s,a)<c;)u=o(s,a),d=s.hasNode(u.v)?t(a,u):-t(a,u),i(s,a,d);return s}function r(a,s){function l(c){s.nodeEdges(c).forEach(u=>{var d=u.v,h=c===d?u.w:d;!a.hasNode(h)&&!t(s,u)&&(a.setNode(h,{}),a.setEdge(c,h,{}),l(h))})}return a.nodes().forEach(l),a.nodeCount()}function o(a,s){return s.edges().reduce((c,u)=>{let d=Number.POSITIVE_INFINITY;return a.hasNode(u.v)!==a.hasNode(u.w)&&(d=t(s,u)),d<c[0]?[d,u]:c},[Number.POSITIVE_INFINITY,null])[1]}function i(a,s,l){a.nodes().forEach(c=>s.node(c).rank+=l)}return R6}var W6,KY;function OHe(){if(KY)return W6;KY=1;var e=QY(),t=Ub().slack,n=Ub().longestPath,r=ss().alg.preorder,o=ss().alg.postorder,i=wo().simplify;W6=a,a.initLowLimValues=u,a.initCutValues=s,a.calcCutValue=c,a.leaveEdge=h,a.enterEdge=p,a.exchangeEdges=m;function a(A){A=i(A),n(A);var w=e(A);u(w),s(w,A);for(var S,E;S=h(w);)E=p(w,A,S),m(w,A,S,E)}function s(A,w){var S=o(A,A.nodes());S=S.slice(0,S.length-1),S.forEach(E=>l(A,w,E))}function l(A,w,S){var E=A.node(S),N=E.parent;A.edge(S,N).cutvalue=c(A,w,S)}function c(A,w,S){var E=A.node(S),N=E.parent,O=!0,$=w.edge(S,N),M=0;return $||(O=!1,$=w.edge(N,S)),M=$.weight,w.nodeEdges(S).forEach(P=>{var _=P.v===S,D=_?P.w:P.v;if(D!==N){var B=_===O,T=w.edge(P).weight;if(M+=B?T:-T,g(A,S,D)){var k=A.edge(S,D).cutvalue;M+=B?-k:k}}}),M}function u(A,w){arguments.length<2&&(w=A.nodes()[0]),d(A,{},1,w)}function d(A,w,S,E,N){var O=S,$=A.node(E);return w[E]=!0,A.neighbors(E).forEach(M=>{Object.hasOwn(w,M)||(S=d(A,w,S,M,E))}),$.low=O,$.lim=S++,N?$.parent=N:delete $.parent,S}function h(A){return A.edges().find(w=>A.edge(w).cutvalue<0)}function p(A,w,S){var E=S.v,N=S.w;w.hasEdge(E,N)||(E=S.w,N=S.v);var O=A.node(E),$=A.node(N),M=O,P=!1;O.lim>$.lim&&(M=$,P=!0);var _=w.edges().filter(D=>P===y(A,A.node(D.v),M)&&P!==y(A,A.node(D.w),M));return _.reduce((D,B)=>t(w,B)<t(w,D)?B:D)}function m(A,w,S,E){var N=S.v,O=S.w;A.removeEdge(N,O),A.setEdge(E.v,E.w,{}),u(A),s(A,w),v(A,w)}function v(A,w){var S=A.nodes().find(N=>!w.node(N).parent),E=r(A,S);E=E.slice(1),E.forEach(N=>{var O=A.node(N).parent,$=w.edge(N,O),M=!1;$||($=w.edge(O,N),M=!0),w.node(N).rank=w.node(O).rank+(M?$.minlen:-$.minlen)})}function g(A,w,S){return A.hasEdge(w,S)}function y(A,w,S){return S.low<=w.lim&&w.lim<=S.lim}return W6}var Q6,qY;function $He(){if(qY)return Q6;qY=1;var e=Ub(),t=e.longestPath,n=QY(),r=OHe();Q6=o;function o(l){var c=l.graph().ranker;if(c instanceof Function)return c(l);switch(l.graph().ranker){case"network-simplex":s(l);break;case"tight-tree":a(l);break;case"longest-path":i(l);break;case"none":break;default:s(l)}}var i=t;function a(l){t(l),n(l)}function s(l){r(l)}return Q6}var K6,GY;function MHe(){if(GY)return K6;GY=1,K6=e;function e(r){let o=n(r);r.graph().dummyChains.forEach(i=>{let a=r.node(i),s=a.edgeObj,l=t(r,o,s.v,s.w),c=l.path,u=l.lca,d=0,h=c[d],p=!0;for(;i!==s.w;){if(a=r.node(i),p){for(;(h=c[d])!==u&&r.node(h).maxRank<a.rank;)d++;h===u&&(p=!1)}if(!p){for(;d<c.length-1&&r.node(h=c[d+1]).minRank<=a.rank;)d++;h=c[d]}r.setParent(i,h),i=r.successors(i)[0]}})}function t(r,o,i,a){let s=[],l=[],c=Math.min(o[i].low,o[a].low),u=Math.max(o[i].lim,o[a].lim),d,h;d=i;do d=r.parent(d),s.push(d);while(d&&(o[d].low>c||u>o[d].lim));for(h=d,d=a;(d=r.parent(d))!==h;)l.push(d);return{path:s.concat(l.reverse()),lca:h}}function n(r){let o={},i=0;function a(s){let l=i;r.children(s).forEach(a),o[s]={low:l,lim:i++}}return r.children().forEach(a),o}return K6}var q6,UY;function PHe(){if(UY)return q6;UY=1;let e=wo();q6={run:t,cleanup:i};function t(a){let s=e.addDummyNode(a,"root",{},"_root"),l=r(a),c=Object.values(l),u=e.applyWithChunking(Math.max,c)-1,d=2*u+1;a.graph().nestingRoot=s,a.edges().forEach(p=>a.edge(p).minlen*=d);let h=o(a)+1;a.children().forEach(p=>n(a,s,d,h,u,l,p)),a.graph().nodeRankFactor=d}function n(a,s,l,c,u,d,h){let p=a.children(h);if(!p.length){h!==s&&a.setEdge(s,h,{weight:0,minlen:l});return}let m=e.addBorderNode(a,"_bt"),v=e.addBorderNode(a,"_bb"),g=a.node(h);a.setParent(m,h),g.borderTop=m,a.setParent(v,h),g.borderBottom=v,p.forEach(y=>{n(a,s,l,c,u,d,y);let A=a.node(y),w=A.borderTop?A.borderTop:y,S=A.borderBottom?A.borderBottom:y,E=A.borderTop?c:2*c,N=w!==S?1:u-d[h]+1;a.setEdge(m,w,{weight:E,minlen:N,nestingEdge:!0}),a.setEdge(S,v,{weight:E,minlen:N,nestingEdge:!0})}),a.parent(h)||a.setEdge(s,m,{weight:0,minlen:u+d[h]})}function r(a){var s={};function l(c,u){var d=a.children(c);d&&d.length&&d.forEach(h=>l(h,u+1)),s[c]=u}return a.children().forEach(c=>l(c,1)),s}function o(a){return a.edges().reduce((s,l)=>s+a.edge(l).weight,0)}function i(a){var s=a.graph();a.removeNode(s.nestingRoot),delete s.nestingRoot,a.edges().forEach(l=>{var c=a.edge(l);c.nestingEdge&&a.removeEdge(l)})}return q6}var G6,YY;function THe(){if(YY)return G6;YY=1;let e=wo();G6=t;function t(r){function o(i){let a=r.children(i),s=r.node(i);if(a.length&&a.forEach(o),Object.hasOwn(s,"minRank")){s.borderLeft=[],s.borderRight=[];for(let l=s.minRank,c=s.maxRank+1;l<c;++l)n(r,"borderLeft","_bl",i,s,l),n(r,"borderRight","_br",i,s,l)}}r.children().forEach(o)}function n(r,o,i,a,s,l){let c={width:0,height:0,rank:l,borderType:o},u=s[o][l-1],d=e.addDummyNode(r,"border",c,i);s[o][l]=d,r.setParent(d,a),u&&r.setEdge(u,d,{weight:1})}return G6}var U6,XY;function _He(){if(XY)return U6;XY=1,U6={adjust:e,undo:t};function e(l){let c=l.graph().rankdir.toLowerCase();(c==="lr"||c==="rl")&&n(l)}function t(l){let c=l.graph().rankdir.toLowerCase();(c==="bt"||c==="rl")&&o(l),(c==="lr"||c==="rl")&&(a(l),n(l))}function n(l){l.nodes().forEach(c=>r(l.node(c))),l.edges().forEach(c=>r(l.edge(c)))}function r(l){let c=l.width;l.width=l.height,l.height=c}function o(l){l.nodes().forEach(c=>i(l.node(c))),l.edges().forEach(c=>{let u=l.edge(c);u.points.forEach(i),Object.hasOwn(u,"y")&&i(u)})}function i(l){l.y=-l.y}function a(l){l.nodes().forEach(c=>s(l.node(c))),l.edges().forEach(c=>{let u=l.edge(c);u.points.forEach(s),Object.hasOwn(u,"x")&&s(u)})}function s(l){let c=l.x;l.x=l.y,l.y=c}return U6}var Y6,ZY;function DHe(){if(ZY)return Y6;ZY=1;let e=wo();Y6=t;function t(n){let r={},o=n.nodes().filter(u=>!n.children(u).length),i=o.map(u=>n.node(u).rank),a=e.applyWithChunking(Math.max,i),s=e.range(a+1).map(()=>[]);function l(u){if(r[u])return;r[u]=!0;let d=n.node(u);s[d.rank].push(u),n.successors(u).forEach(l)}return o.sort((u,d)=>n.node(u).rank-n.node(d).rank).forEach(l),s}return Y6}var X6,JY;function kHe(){if(JY)return X6;JY=1;let e=wo().zipObject;X6=t;function t(r,o){let i=0;for(let a=1;a<o.length;++a)i+=n(r,o[a-1],o[a]);return i}function n(r,o,i){let a=e(i,i.map((h,p)=>p)),s=o.flatMap(h=>r.outEdges(h).map(p=>({pos:a[p.w],weight:r.edge(p).weight})).sort((p,m)=>p.pos-m.pos)),l=1;for(;l<i.length;)l<<=1;let c=2*l-1;l-=1;let u=new Array(c).fill(0),d=0;return s.forEach(h=>{let p=h.pos+l;u[p]+=h.weight;let m=0;for(;p>0;)p%2&&(m+=u[p+1]),p=p-1>>1,u[p]+=h.weight;d+=h.weight*m}),d}return X6}var Z6,eX;function BHe(){if(eX)return Z6;eX=1,Z6=e;function e(t,n=[]){return n.map(r=>{let o=t.inEdges(r);if(o.length){let i=o.reduce((a,s)=>{let l=t.edge(s),c=t.node(s.v);return{sum:a.sum+l.weight*c.order,weight:a.weight+l.weight}},{sum:0,weight:0});return{v:r,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:r}})}return Z6}var J6,tX;function LHe(){if(tX)return J6;tX=1;let e=wo();J6=t;function t(o,i){let a={};o.forEach((l,c)=>{let u=a[l.v]={indegree:0,in:[],out:[],vs:[l.v],i:c};l.barycenter!==void 0&&(u.barycenter=l.barycenter,u.weight=l.weight)}),i.edges().forEach(l=>{let c=a[l.v],u=a[l.w];c!==void 0&&u!==void 0&&(u.indegree++,c.out.push(a[l.w]))});let s=Object.values(a).filter(l=>!l.indegree);return n(s)}function n(o){let i=[];function a(l){return c=>{c.merged||(c.barycenter===void 0||l.barycenter===void 0||c.barycenter>=l.barycenter)&&r(l,c)}}function s(l){return c=>{c.in.push(l),--c.indegree===0&&o.push(c)}}for(;o.length;){let l=o.pop();i.push(l),l.in.reverse().forEach(a(l)),l.out.forEach(s(l))}return i.filter(l=>!l.merged).map(l=>e.pick(l,["vs","i","barycenter","weight"]))}function r(o,i){let a=0,s=0;o.weight&&(a+=o.barycenter*o.weight,s+=o.weight),i.weight&&(a+=i.barycenter*i.weight,s+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=a/s,o.weight=s,o.i=Math.min(i.i,o.i),i.merged=!0}return J6}var eN,nX;function FHe(){if(nX)return eN;nX=1;let e=wo();eN=t;function t(o,i){let a=e.partition(o,m=>Object.hasOwn(m,"barycenter")),s=a.lhs,l=a.rhs.sort((m,v)=>v.i-m.i),c=[],u=0,d=0,h=0;s.sort(r(!!i)),h=n(c,l,h),s.forEach(m=>{h+=m.vs.length,c.push(m.vs),u+=m.barycenter*m.weight,d+=m.weight,h=n(c,l,h)});let p={vs:c.flat(!0)};return d&&(p.barycenter=u/d,p.weight=d),p}function n(o,i,a){let s;for(;i.length&&(s=i[i.length-1]).i<=a;)i.pop(),o.push(s.vs),a++;return a}function r(o){return(i,a)=>i.barycenter<a.barycenter?-1:i.barycenter>a.barycenter?1:o?a.i-i.i:i.i-a.i}return eN}var tN,rX;function zHe(){if(rX)return tN;rX=1;let e=BHe(),t=LHe(),n=FHe();tN=r;function r(a,s,l,c){let u=a.children(s),d=a.node(s),h=d?d.borderLeft:void 0,p=d?d.borderRight:void 0,m={};h&&(u=u.filter(A=>A!==h&&A!==p));let v=e(a,u);v.forEach(A=>{if(a.children(A.v).length){let w=r(a,A.v,l,c);m[A.v]=w,Object.hasOwn(w,"barycenter")&&i(A,w)}});let g=t(v,l);o(g,m);let y=n(g,c);if(h&&(y.vs=[h,y.vs,p].flat(!0),a.predecessors(h).length)){let A=a.node(a.predecessors(h)[0]),w=a.node(a.predecessors(p)[0]);Object.hasOwn(y,"barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+A.order+w.order)/(y.weight+2),y.weight+=2}return y}function o(a,s){a.forEach(l=>{l.vs=l.vs.flatMap(c=>s[c]?s[c].vs:c)})}function i(a,s){a.barycenter!==void 0?(a.barycenter=(a.barycenter*a.weight+s.barycenter*s.weight)/(a.weight+s.weight),a.weight+=s.weight):(a.barycenter=s.barycenter,a.weight=s.weight)}return tN}var nN,oX;function VHe(){if(oX)return nN;oX=1;let e=ss().Graph,t=wo();nN=n;function n(o,i,a){let s=r(o),l=new e({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(c=>o.node(c));return o.nodes().forEach(c=>{let u=o.node(c),d=o.parent(c);(u.rank===i||u.minRank<=i&&i<=u.maxRank)&&(l.setNode(c),l.setParent(c,d||s),o[a](c).forEach(h=>{let p=h.v===c?h.w:h.v,m=l.edge(p,c),v=m!==void 0?m.weight:0;l.setEdge(p,c,{weight:o.edge(h).weight+v})}),Object.hasOwn(u,"minRank")&&l.setNode(c,{borderLeft:u.borderLeft[i],borderRight:u.borderRight[i]}))}),l}function r(o){for(var i;o.hasNode(i=t.uniqueId("_root")););return i}return nN}var rN,iX;function jHe(){if(iX)return rN;iX=1,rN=e;function e(t,n,r){let o={},i;r.forEach(a=>{let s=t.parent(a),l,c;for(;s;){if(l=t.parent(s),l?(c=o[l],o[l]=s):(c=i,i=s),c&&c!==s){n.setEdge(c,s);return}s=l}})}return rN}var oN,aX;function HHe(){if(aX)return oN;aX=1;let e=DHe(),t=kHe(),n=zHe(),r=VHe(),o=jHe(),i=ss().Graph,a=wo();oN=s;function s(d,h){if(h&&typeof h.customOrder=="function"){h.customOrder(d,s);return}let p=a.maxRank(d),m=l(d,a.range(1,p+1),"inEdges"),v=l(d,a.range(p-1,-1,-1),"outEdges"),g=e(d);if(u(d,g),h&&h.disableOptimalOrderHeuristic)return;let y=Number.POSITIVE_INFINITY,A;for(let w=0,S=0;S<4;++w,++S){c(w%2?m:v,w%4>=2),g=a.buildLayerMatrix(d);let E=t(d,g);E<y&&(S=0,A=Object.assign({},g),y=E)}u(d,A)}function l(d,h,p){return h.map(function(m){return r(d,m,p)})}function c(d,h){let p=new i;d.forEach(function(m){let v=m.graph().root,g=n(m,v,p,h);g.vs.forEach((y,A)=>m.node(y).order=A),o(m,p,g.vs)})}function u(d,h){Object.values(h).forEach(p=>p.forEach((m,v)=>d.node(m).order=v))}return oN}var iN,sX;function RHe(){if(sX)return iN;sX=1;let e=ss().Graph,t=wo();iN={positionX:p,findType1Conflicts:n,findType2Conflicts:r,addConflict:i,hasConflict:a,verticalAlignment:s,horizontalCompaction:l,alignCoordinates:d,findSmallestWidthAlignment:u,balance:h};function n(g,y){let A={};function w(S,E){let N=0,O=0,$=S.length,M=E[E.length-1];return E.forEach((P,_)=>{let D=o(g,P),B=D?g.node(D).order:$;(D||P===M)&&(E.slice(O,_+1).forEach(T=>{g.predecessors(T).forEach(k=>{let F=g.node(k),z=F.order;(z<N||B<z)&&!(F.dummy&&g.node(T).dummy)&&i(A,k,T)})}),O=_+1,N=B)}),E}return y.length&&y.reduce(w),A}function r(g,y){let A={};function w(E,N,O,$,M){let P;t.range(N,O).forEach(_=>{P=E[_],g.node(P).dummy&&g.predecessors(P).forEach(D=>{let B=g.node(D);B.dummy&&(B.order<$||B.order>M)&&i(A,D,P)})})}function S(E,N){let O=-1,$,M=0;return N.forEach((P,_)=>{if(g.node(P).dummy==="border"){let D=g.predecessors(P);D.length&&($=g.node(D[0]).order,w(N,M,_,O,$),M=_,O=$)}w(N,M,N.length,$,E.length)}),N}return y.length&&y.reduce(S),A}function o(g,y){if(g.node(y).dummy)return g.predecessors(y).find(A=>g.node(A).dummy)}function i(g,y,A){if(y>A){let S=y;y=A,A=S}let w=g[y];w||(g[y]=w={}),w[A]=!0}function a(g,y,A){if(y>A){let w=y;y=A,A=w}return!!g[y]&&Object.hasOwn(g[y],A)}function s(g,y,A,w){let S={},E={},N={};return y.forEach(O=>{O.forEach(($,M)=>{S[$]=$,E[$]=$,N[$]=M})}),y.forEach(O=>{let $=-1;O.forEach(M=>{let P=w(M);if(P.length){P=P.sort((D,B)=>N[D]-N[B]);let _=(P.length-1)/2;for(let D=Math.floor(_),B=Math.ceil(_);D<=B;++D){let T=P[D];E[M]===M&&$<N[T]&&!a(A,M,T)&&(E[T]=M,E[M]=S[M]=S[T],$=N[T])}}})}),{root:S,align:E}}function l(g,y,A,w,S){let E={},N=c(g,y,A,S),O=S?"borderLeft":"borderRight";function $(_,D){let B=N.nodes(),T=B.pop(),k={};for(;T;)k[T]?_(T):(k[T]=!0,B.push(T),B=B.concat(D(T))),T=B.pop()}function M(_){E[_]=N.inEdges(_).reduce((D,B)=>Math.max(D,E[B.v]+N.edge(B)),0)}function P(_){let D=N.outEdges(_).reduce((T,k)=>Math.min(T,E[k.w]-N.edge(k)),Number.POSITIVE_INFINITY),B=g.node(_);D!==Number.POSITIVE_INFINITY&&B.borderType!==O&&(E[_]=Math.max(E[_],D))}return $(M,N.predecessors.bind(N)),$(P,N.successors.bind(N)),Object.keys(w).forEach(_=>E[_]=E[A[_]]),E}function c(g,y,A,w){let S=new e,E=g.graph(),N=m(E.nodesep,E.edgesep,w);return y.forEach(O=>{let $;O.forEach(M=>{let P=A[M];if(S.setNode(P),$){var _=A[$],D=S.edge(_,P);S.setEdge(_,P,Math.max(N(g,M,$),D||0))}$=M})}),S}function u(g,y){return Object.values(y).reduce((A,w)=>{let S=Number.NEGATIVE_INFINITY,E=Number.POSITIVE_INFINITY;Object.entries(w).forEach(([O,$])=>{let M=v(g,O)/2;S=Math.max($+M,S),E=Math.min($-M,E)});const N=S-E;return N<A[0]&&(A=[N,w]),A},[Number.POSITIVE_INFINITY,null])[1]}function d(g,y){let A=Object.values(y),w=t.applyWithChunking(Math.min,A),S=t.applyWithChunking(Math.max,A);["u","d"].forEach(E=>{["l","r"].forEach(N=>{let O=E+N,$=g[O];if($===y)return;let M=Object.values($),P=w-t.applyWithChunking(Math.min,M);N!=="l"&&(P=S-t.applyWithChunking(Math.max,M)),P&&(g[O]=t.mapValues($,_=>_+P))})})}function h(g,y){return t.mapValues(g.ul,(A,w)=>{if(y)return g[y.toLowerCase()][w];{let S=Object.values(g).map(E=>E[w]).sort((E,N)=>E-N);return(S[1]+S[2])/2}})}function p(g){let y=t.buildLayerMatrix(g),A=Object.assign(n(g,y),r(g,y)),w={},S;["u","d"].forEach(N=>{S=N==="u"?y:Object.values(y).reverse(),["l","r"].forEach(O=>{O==="r"&&(S=S.map(_=>Object.values(_).reverse()));let $=(N==="u"?g.predecessors:g.successors).bind(g),M=s(g,S,A,$),P=l(g,S,M.root,M.align,O==="r");O==="r"&&(P=t.mapValues(P,_=>-_)),w[N+O]=P})});let E=u(g,w);return d(w,E),h(w,g.graph().align)}function m(g,y,A){return(w,S,E)=>{let N=w.node(S),O=w.node(E),$=0,M;if($+=N.width/2,Object.hasOwn(N,"labelpos"))switch(N.labelpos.toLowerCase()){case"l":M=-N.width/2;break;case"r":M=N.width/2;break}if(M&&($+=A?M:-M),M=0,$+=(N.dummy?y:g)/2,$+=(O.dummy?y:g)/2,$+=O.width/2,Object.hasOwn(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":M=O.width/2;break;case"r":M=-O.width/2;break}return M&&($+=A?M:-M),M=0,$}}function v(g,y){return g.node(y).width}return iN}var aN,lX;function WHe(){if(lX)return aN;lX=1;let e=wo(),t=RHe().positionX;aN=n;function n(o){o=e.asNonCompoundGraph(o),r(o),Object.entries(t(o)).forEach(([i,a])=>o.node(i).x=a)}function r(o){let i=e.buildLayerMatrix(o),a=o.graph().ranksep,s=0;i.forEach(l=>{const c=l.reduce((u,d)=>{const h=o.node(d).height;return u>h?u:h},0);l.forEach(u=>o.node(u).y=s+c/2),s+=c+a})}return aN}var sN,cX;function QHe(){if(cX)return sN;cX=1;let e=IHe(),t=NHe(),n=$He(),r=wo().normalizeRanks,o=MHe(),i=wo().removeEmptyRanks,a=PHe(),s=THe(),l=_He(),c=HHe(),u=WHe(),d=wo(),h=ss().Graph;sN=p;function p(H,W){let R=W&&W.debugTiming?d.time:d.notime;R("layout",()=>{let U=R(" buildLayoutGraph",()=>$(H));R(" runLayout",()=>m(U,R,W)),R(" updateInputGraph",()=>v(H,U))})}function m(H,W,R){W(" makeSpaceForEdgeLabels",()=>M(H)),W(" removeSelfEdges",()=>j(H)),W(" acyclic",()=>e.run(H)),W(" nestingGraph.run",()=>a.run(H)),W(" rank",()=>n(d.asNonCompoundGraph(H))),W(" injectEdgeLabelProxies",()=>P(H)),W(" removeEmptyRanks",()=>i(H)),W(" nestingGraph.cleanup",()=>a.cleanup(H)),W(" normalizeRanks",()=>r(H)),W(" assignRankMinMax",()=>_(H)),W(" removeEdgeLabelProxies",()=>D(H)),W(" normalize.run",()=>t.run(H)),W(" parentDummyChains",()=>o(H)),W(" addBorderSegments",()=>s(H)),W(" order",()=>c(H,R)),W(" insertSelfEdges",()=>V(H)),W(" adjustCoordinateSystem",()=>l.adjust(H)),W(" position",()=>u(H)),W(" positionSelfEdges",()=>Q(H)),W(" removeBorderNodes",()=>z(H)),W(" normalize.undo",()=>t.undo(H)),W(" fixupEdgeLabelCoords",()=>k(H)),W(" undoCoordinateSystem",()=>l.undo(H)),W(" translateGraph",()=>B(H)),W(" assignNodeIntersects",()=>T(H)),W(" reversePoints",()=>F(H)),W(" acyclic.undo",()=>e.undo(H))}function v(H,W){H.nodes().forEach(R=>{let U=H.node(R),ee=W.node(R);U&&(U.x=ee.x,U.y=ee.y,U.rank=ee.rank,W.children(R).length&&(U.width=ee.width,U.height=ee.height))}),H.edges().forEach(R=>{let U=H.edge(R),ee=W.edge(R);U.points=ee.points,Object.hasOwn(ee,"x")&&(U.x=ee.x,U.y=ee.y)}),H.graph().width=W.graph().width,H.graph().height=W.graph().height}let g=["nodesep","edgesep","ranksep","marginx","marginy"],y={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},A=["acyclicer","ranker","rankdir","align"],w=["width","height","rank"],S={width:0,height:0},E=["minlen","weight","width","height","labeloffset"],N={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},O=["labelpos"];function $(H){let W=new h({multigraph:!0,compound:!0}),R=G(H.graph());return W.setGraph(Object.assign({},y,K(R,g),d.pick(R,A))),H.nodes().forEach(U=>{let ee=G(H.node(U));const Y=K(ee,w);Object.keys(S).forEach(ne=>{Y[ne]===void 0&&(Y[ne]=S[ne])}),W.setNode(U,Y),W.setParent(U,H.parent(U))}),H.edges().forEach(U=>{let ee=G(H.edge(U));W.setEdge(U,Object.assign({},N,K(ee,E),d.pick(ee,O)))}),W}function M(H){let W=H.graph();W.ranksep/=2,H.edges().forEach(R=>{let U=H.edge(R);U.minlen*=2,U.labelpos.toLowerCase()!=="c"&&(W.rankdir==="TB"||W.rankdir==="BT"?U.width+=U.labeloffset:U.height+=U.labeloffset)})}function P(H){H.edges().forEach(W=>{let R=H.edge(W);if(R.width&&R.height){let U=H.node(W.v),Y={rank:(H.node(W.w).rank-U.rank)/2+U.rank,e:W};d.addDummyNode(H,"edge-proxy",Y,"_ep")}})}function _(H){let W=0;H.nodes().forEach(R=>{let U=H.node(R);U.borderTop&&(U.minRank=H.node(U.borderTop).rank,U.maxRank=H.node(U.borderBottom).rank,W=Math.max(W,U.maxRank))}),H.graph().maxRank=W}function D(H){H.nodes().forEach(W=>{let R=H.node(W);R.dummy==="edge-proxy"&&(H.edge(R.e).labelRank=R.rank,H.removeNode(W))})}function B(H){let W=Number.POSITIVE_INFINITY,R=0,U=Number.POSITIVE_INFINITY,ee=0,Y=H.graph(),ne=Y.marginx||0,oe=Y.marginy||0;function X(Z){let ie=Z.x,te=Z.y,de=Z.width,ce=Z.height;W=Math.min(W,ie-de/2),R=Math.max(R,ie+de/2),U=Math.min(U,te-ce/2),ee=Math.max(ee,te+ce/2)}H.nodes().forEach(Z=>X(H.node(Z))),H.edges().forEach(Z=>{let ie=H.edge(Z);Object.hasOwn(ie,"x")&&X(ie)}),W-=ne,U-=oe,H.nodes().forEach(Z=>{let ie=H.node(Z);ie.x-=W,ie.y-=U}),H.edges().forEach(Z=>{let ie=H.edge(Z);ie.points.forEach(te=>{te.x-=W,te.y-=U}),Object.hasOwn(ie,"x")&&(ie.x-=W),Object.hasOwn(ie,"y")&&(ie.y-=U)}),Y.width=R-W+ne,Y.height=ee-U+oe}function T(H){H.edges().forEach(W=>{let R=H.edge(W),U=H.node(W.v),ee=H.node(W.w),Y,ne;R.points?(Y=R.points[0],ne=R.points[R.points.length-1]):(R.points=[],Y=ee,ne=U),R.points.unshift(d.intersectRect(U,Y)),R.points.push(d.intersectRect(ee,ne))})}function k(H){H.edges().forEach(W=>{let R=H.edge(W);if(Object.hasOwn(R,"x"))switch((R.labelpos==="l"||R.labelpos==="r")&&(R.width-=R.labeloffset),R.labelpos){case"l":R.x-=R.width/2+R.labeloffset;break;case"r":R.x+=R.width/2+R.labeloffset;break}})}function F(H){H.edges().forEach(W=>{let R=H.edge(W);R.reversed&&R.points.reverse()})}function z(H){H.nodes().forEach(W=>{if(H.children(W).length){let R=H.node(W),U=H.node(R.borderTop),ee=H.node(R.borderBottom),Y=H.node(R.borderLeft[R.borderLeft.length-1]),ne=H.node(R.borderRight[R.borderRight.length-1]);R.width=Math.abs(ne.x-Y.x),R.height=Math.abs(ee.y-U.y),R.x=Y.x+R.width/2,R.y=U.y+R.height/2}}),H.nodes().forEach(W=>{H.node(W).dummy==="border"&&H.removeNode(W)})}function j(H){H.edges().forEach(W=>{if(W.v===W.w){var R=H.node(W.v);R.selfEdges||(R.selfEdges=[]),R.selfEdges.push({e:W,label:H.edge(W)}),H.removeEdge(W)}})}function V(H){var W=d.buildLayerMatrix(H);W.forEach(R=>{var U=0;R.forEach((ee,Y)=>{var ne=H.node(ee);ne.order=Y+U,(ne.selfEdges||[]).forEach(oe=>{d.addDummyNode(H,"selfedge",{width:oe.label.width,height:oe.label.height,rank:ne.rank,order:Y+ ++U,e:oe.e,label:oe.label},"_se")}),delete ne.selfEdges})})}function Q(H){H.nodes().forEach(W=>{var R=H.node(W);if(R.dummy==="selfedge"){var U=H.node(R.e.v),ee=U.x+U.width/2,Y=U.y,ne=R.x-ee,oe=U.height/2;H.setEdge(R.e,R.label),H.removeNode(W),R.label.points=[{x:ee+2*ne/3,y:Y-oe},{x:ee+5*ne/6,y:Y-oe},{x:ee+ne,y:Y},{x:ee+5*ne/6,y:Y+oe},{x:ee+2*ne/3,y:Y+oe}],R.label.x=R.x,R.label.y=R.y}})}function K(H,W){return d.mapValues(d.pick(H,W),Number)}function G(H){var W={};return H&&Object.entries(H).forEach(([R,U])=>{typeof R=="string"&&(R=R.toLowerCase()),W[R]=U}),W}return sN}var lN,uX;function KHe(){if(uX)return lN;uX=1;let e=wo(),t=ss().Graph;lN={debugOrdering:n};function n(r){let o=e.buildLayerMatrix(r),i=new t({compound:!0,multigraph:!0}).setGraph({});return r.nodes().forEach(a=>{i.setNode(a,{label:a}),i.setParent(a,"layer"+r.node(a).rank)}),r.edges().forEach(a=>i.setEdge(a.v,a.w,{},a.name)),o.forEach((a,s)=>{let l="layer"+s;i.setNode(l,{rank:"same"}),a.reduce((c,u)=>(i.setEdge(c,u,{style:"invis"}),u))}),i}return lN}var cN,dX;function qHe(){return dX||(dX=1,cN="1.1.5"),cN}var uN,fX;function GHe(){return fX||(fX=1,uN={graphlib:ss(),layout:QHe(),debug:KHe(),util:{time:wo().time,notime:wo().notime},version:qHe()}),uN}var UHe=GHe();const hX=li(UHe),YHe=()=>{const{getNodes:e,getEdges:t,setNodes:n,setEdges:r,fitView:o}=Fn(),i=s=>{const l=document.querySelector(`[data-id="${s}"]`);if(!l)return{width:180,height:60};const c=l.getBoundingClientRect();return{width:Math.max(60,c.width),height:Math.max(30,c.height)}};return{layout:(s="LR")=>{const l=e(),c=t();l.length&&requestAnimationFrame(()=>{const u=s==="LR",d=new hX.graphlib.Graph;d.setDefaultEdgeLabel(()=>({})),d.setGraph({rankdir:s,ranksep:120,nodesep:80}),l.forEach(p=>{const{width:m,height:v}=i(p.id);d.setNode(p.id,{width:m,height:v})}),c.forEach(p=>d.setEdge(p.source,p.target)),hX.layout(d);const h=l.map(p=>{const m=d.node(p.id),{width:v,height:g}=i(p.id);return{...p,position:{x:m.x-v/2,y:m.y-g/2},targetPosition:u?"left":"top",sourcePosition:u?"right":"bottom"}});n(h),r(c),requestAnimationFrame(()=>o({duration:400,padding:.3}))})}}};var XHe="scripts_editor_k7c3wx0",vc="scripts_editor_k7c3wx1",ZHe="scripts_editor_k7c3wx2",dN="scripts_editor_k7c3wx3",JHe="scripts_editor_k7c3wx4";const eRe=()=>{const e=mr(),[t,n]=I.useState(()=>e.getState().transform[2]);return I.useEffect(()=>{let r=e.getState().transform[2];return e.subscribe(i=>{const a=i.transform[2];a!==r&&(r=a,n(a))})},[e]),C.jsxs("span",{className:JHe,children:[Math.round(t*100)/2,"%"]})},tRe=I.memo(()=>{const{zoomIn:e,zoomOut:t,fitView:n}=Fn(),{layout:r}=YHe(),{undo:o,redo:i,canUndo:a,canRedo:s}=nHe(),{mode:l,toggleMode:c}=$G();return C.jsxs("div",{className:XHe,children:[C.jsx("button",{type:"button",disabled:!a,className:vc,onClick:o,children:C.jsx(cHe,{size:18})}),C.jsx("button",{type:"button",disabled:!s,className:vc,onClick:i,children:C.jsx(lHe,{size:18})}),C.jsx("div",{className:dN}),C.jsx("button",{type:"button",className:vc,onClick:()=>r(),children:C.jsx(tOe,{})}),C.jsx("button",{type:"button",className:vc,onClick:()=>n({padding:.2}),children:C.jsx(aHe,{size:18})}),C.jsx("div",{className:dN}),C.jsx("button",{type:"button",className:vc,onClick:()=>e(),children:C.jsx(sHe,{size:18})}),C.jsx(eRe,{}),C.jsx("button",{type:"button",className:vc,onClick:()=>t(),children:C.jsx(iHe,{size:18})}),C.jsx("div",{className:dN}),C.jsx("button",{type:"button",className:`${vc} ${l==="trackpad"?ZHe:""}`,onClick:c,children:C.jsx(uHe,{size:18})}),C.jsx("button",{type:"button",className:vc,children:C.jsx(dHe,{size:18})})]})});var fN,pX;function nRe(){if(pX)return fN;pX=1;var e=JU(),t=uY(),n=LU(),r=Gb(),o=tY(),i=W5(),a=UU(),s=Y5(),l="[object Map]",c="[object Set]",u=Object.prototype,d=u.hasOwnProperty;function h(p){if(p==null)return!0;if(o(p)&&(r(p)||typeof p=="string"||typeof p.splice=="function"||i(p)||s(p)||n(p)))return!p.length;var m=t(p);if(m==l||m==c)return!p.size;if(a(p))return!e(p).length;for(var v in p)if(d.call(p,v))return!1;return!0}return fN=h,fN}var rRe=nRe();const oRe=li(rRe);var gX="scripts_editor_ohkkdt0",Yb="scripts_editor_ohkkdt1",Xb="scripts_editor_ohkkdt2",iRe="scripts_editor_ohkkdt3",hN="scripts_editor_ohkkdt4",pN="scripts_editor_ohkkdt5",aRe="scripts_editor_ohkkdt6",sRe="scripts_editor_ohkkdt7",lRe="scripts_editor_ohkkdt8";const mX=e=>C.jsx(Kn,{...e,direction:"vertical",size:10}),vX=I.memo(({keyId:e,Icon:t,label:n,active:r,color:o,isLongLabel:i,onDragStart:a})=>{const s=I.useCallback(l=>a(l,e),[a,e]);return C.jsxs(dt,{draggable:!0,type:"text",style:{minHeight:i?62:52},className:r?`${Xb} ${iRe} `:`${Xb}`,onDragStart:s,children:[C.jsx("span",{className:hN,style:{color:o},children:C.jsx(t,{})}),C.jsx("span",{className:pN,children:n})]},e)},(e,t)=>e.keyId===t.keyId&&e.label===t.label&&e.active===t.active&&e.color===t.color&&e.isLongLabel===t.isLongLabel&&e.onDragStart===t.onDragStart),cRe=()=>{const[e,t]=kb(),{BLOCKS_ENABLED:n}=Ho(),r=I.useCallback((a,s)=>{a.dataTransfer.effectAllowed="move",requestAnimationFrame(()=>t(s))},[t]);if(oRe(n))return null;const o=I.useMemo(()=>Hb.filter(a=>(n==null?void 0:n.includes(a.key))&&a.group===1),[n]),i=I.useMemo(()=>Hb.filter(a=>(n==null?void 0:n.includes(a.key))&&a.group===2),[n]);return C.jsxs("div",{className:gX,children:[C.jsx(Bs,{className:Yb,wrapperTag:mX,children:o.map(a=>{const s=a.icon,l=a.active,c=a.label.includes(`
|
|
697
697
|
`)||a.label.length>9;return C.jsx(vX,{keyId:a.key,Icon:s,label:a.label,active:l,color:Cl[a.key],isLongLabel:c,onDragStart:r})})}),C.jsx(Bs,{className:Yb,wrapperTag:mX,children:i.map(a=>{const s=a.icon,l=a.active,c=a.label.includes(`
|
|
698
698
|
`)||a.label.length>9;return C.jsx(vX,{keyId:a.key,Icon:s,label:a.label,active:l,color:Cl[a.key],isLongLabel:c,onDragStart:r})})})]})},uRe=I.memo(cRe),yX=e=>{const[t,n]=kb(),r=(s,l)=>{s.dataTransfer.effectAllowed="move",requestAnimationFrame(()=>n(l))},o={},i=[];e.forEach(s=>{s.group?(o[s.group]||(o[s.group]=[]),o[s.group].push(s)):i.push(s)});const a=s=>{const l=s.icon,c=s.iconProps||{},u=[st.BRANCH,st.DELAY,st.AI_AGENT].includes(s.key);return C.jsx(dt,{className:aRe,draggable:!0,onDragStart:d=>r(d,s.key),icon:C.jsx("div",{className:`${sRe} ${u?lRe:""}`,style:{color:s.color??Cl[s.key]},children:C.jsx(l,{...c})}),children:C.jsxs(Ze,{vertical:!0,align:"flex-start",justify:"center",style:{minWidth:0},children:[C.jsx(Ke.Text,{strong:!0,ellipsis:{tooltip:s.label,expanded:!1},children:s.label}),C.jsx(Ke.Text,{ellipsis:{tooltip:s.description,expanded:!1},type:"secondary",style:{fontSize:12},children:s.description})]})},s.key)};return C.jsxs(C.Fragment,{children:[i.map(a),Object.entries(o).map(([s,l])=>C.jsxs("div",{children:[C.jsx(Ke.Text,{type:"secondary",strong:!0,style:{fontSize:13,marginLeft:8},children:s}),l.map(a)]},s))]})},dRe=()=>{const{BLOCKS_ENABLED:e}=Ho();return Ht.isEmpty(e)?C.jsx(C.Fragment,{}):C.jsxs("div",{className:gX,children:[C.jsx(Bs,{className:Yb,wrapperTag:t=>C.jsx(Kn,{...t,direction:"vertical",size:10,style:{}}),children:Rb.filter(t=>t.group===1).map(t=>{var i;const n=t.icon,r=t.iconProps||{},o=t.label.includes(`
|
|
699
699
|
`)||t.label.length>9;return C.jsx(Ns,{content:(i=t.items)!=null&&i.length?yX(t.items):null,overlayInnerStyle:{padding:8},trigger:"hover",placement:"rightTop",children:C.jsxs(dt,{type:"text",className:Xb,style:{minHeight:o?64:58,minWidth:o?64:58},children:[C.jsx("span",{className:hN,style:{color:t.color||Cl[t.key]},children:C.jsx(n,{...r})}),C.jsx("span",{className:pN,children:t.label})]},t.key)})})}),C.jsx(Bs,{className:Yb,wrapperTag:t=>C.jsx(Kn,{...t,direction:"vertical",size:10}),children:Rb.filter(t=>t.group===2).map(t=>{var i;const n=t.icon,r=t.iconProps||{},o=t.label.includes(`
|