diff --git "a/assets/global-b3b5b4db.js" "b/assets/global-b3b5b4db.js" deleted file mode 100644--- "a/assets/global-b3b5b4db.js" +++ /dev/null @@ -1,131 +0,0 @@ -var UT=Object.defineProperty;var GT=(n,e,t)=>e in n?UT(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var P=(n,e,t)=>(GT(n,typeof e!="symbol"?e+"":e,t),t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();function Z(){}const Ic=n=>n;function et(n,e){for(const t in e)n[t]=e[t];return n}function jT(n){return!!n&&(typeof n=="object"||typeof n=="function")&&typeof n.then=="function"}function Iy(n){return n()}function Ig(){return Object.create(null)}function lt(n){n.forEach(Iy)}function Xn(n){return typeof n=="function"}function ae(n,e){return n!=n?e==e:n!==e||n&&typeof n=="object"||typeof n=="function"}let Ea;function Ti(n,e){return Ea||(Ea=document.createElement("a")),Ea.href=e,n===Ea.href}function qT(n){return Object.keys(n).length===0}function ot(n,...e){if(n==null){for(const i of e)i(void 0);return Z}const t=n.subscribe(...e);return t.unsubscribe?()=>t.unsubscribe():t}function ie(n){let e;return ot(n,t=>e=t)(),e}function Si(n,e,t){n.$$.on_destroy.push(ot(e,t))}function De(n,e,t,i){if(n){const s=Ey(n,e,t,i);return n[0](s)}}function Ey(n,e,t,i){return n[1]&&i?et(t.ctx.slice(),n[1](i(e))):t.ctx}function xe(n,e,t,i){if(n[2]&&i){const s=n[2](i(t));if(e.dirty===void 0)return s;if(typeof s=="object"){const r=[],o=Math.max(e.dirty.length,s.length);for(let l=0;l32){const e=[],t=n.ctx.length/32;for(let i=0;iwindow.performance.now():()=>Date.now(),ep=Ay?n=>requestAnimationFrame(n):Z;const No=new Set;function Oy(n){No.forEach(e=>{e.c(n)||(No.delete(e),e.f())}),No.size!==0&&ep(Oy)}function tp(n){let e;return No.size===0&&ep(Oy),{promise:new Promise(t=>{No.add(e={c:n,f:t})}),abort(){No.delete(e)}}}const KT=typeof window<"u"?window:typeof globalThis<"u"?globalThis:global;function F(n,e){n.appendChild(e)}function Ny(n){if(!n)return document;const e=n.getRootNode?n.getRootNode():n.ownerDocument;return e&&e.host?e:n.ownerDocument}function $T(n){const e=z("style");return e.textContent="/* empty */",JT(Ny(n),e),e.sheet}function JT(n,e){return F(n.head||n,e),e.sheet}function A(n,e,t){n.insertBefore(e,t||null)}function E(n){n.parentNode&&n.parentNode.removeChild(n)}function zi(n,e){for(let t=0;tn.removeEventListener(e,t,i)}function Yi(n){return function(e){return e.preventDefault(),n.call(this,e)}}function Hn(n){return function(e){return e.stopPropagation(),n.call(this,e)}}function U9(n){return function(e){e.target===this&&n.call(this,e)}}function v(n,e,t){t==null?n.removeAttribute(e):n.getAttribute(e)!==t&&n.setAttribute(e,t)}const ZT=["width","height"];function Nh(n,e){const t=Object.getOwnPropertyDescriptors(n.__proto__);for(const i in e)e[i]==null?n.removeAttribute(i):i==="style"?n.style.cssText=e[i]:i==="__value"?n.value=n[i]=e[i]:t[i]&&t[i].set&&ZT.indexOf(i)===-1?n[i]=e[i]:v(n,i,e[i])}function Jt(n,e){for(const t in e)v(n,t,e[t])}function QT(n,e){Object.keys(e).forEach(t=>{eC(n,t,e[t])})}function eC(n,e,t){e in n?n[e]=typeof n[e]=="boolean"&&t===""?!0:t:v(n,e,t)}function Ag(n){return/-/.test(n)?QT:Nh}function tC(n){let e;return{p(...t){e=t,e.forEach(i=>n.push(i))},r(){e.forEach(t=>n.splice(n.indexOf(t),1))}}}function br(n){return n===""?null:+n}function iC(n){return Array.from(n.childNodes)}function je(n,e){e=""+e,n.data!==e&&(n.data=e)}function nC(n,e){e=""+e,n.wholeText!==e&&(n.data=e)}function G9(n,e,t){~XT.indexOf(t)?nC(n,e):je(n,e)}function Bt(n,e){n.value=e??""}function ve(n,e,t,i){t==null?n.style.removeProperty(e):n.style.setProperty(e,t,i?"important":"")}function j9(n,e,t){for(let i=0;i{o.source===i.contentWindow&&e()})):(i.src="about:blank",i.onload=()=>{r=ee(i.contentWindow,"resize",e),e()}),F(n,i),()=>{(s||r&&i.contentWindow)&&r(),E(i)}}function B(n,e,t){n.classList.toggle(e,!!t)}function Dy(n,e,{bubbles:t=!1,cancelable:i=!1}={}){return new CustomEvent(n,{detail:e,bubbles:t,cancelable:i})}class oC{constructor(e=!1){P(this,"is_svg",!1);P(this,"e");P(this,"n");P(this,"t");P(this,"a");this.is_svg=e,this.e=this.n=null}c(e){this.h(e)}m(e,t,i=null){this.e||(this.is_svg?this.e=ze(t.nodeName):this.e=z(t.nodeType===11?"TEMPLATE":t.nodeName),this.t=t.tagName!=="TEMPLATE"?t:t.content,this.c(e)),this.i(i)}h(e){this.e.innerHTML=e,this.n=Array.from(this.e.nodeName==="TEMPLATE"?this.e.content.childNodes:this.e.childNodes)}i(e){for(let t=0;t>>0}function aC(n,e){const t={stylesheet:$T(e),rules:{}};return Nu.set(n,t),t}function ip(n,e,t,i,s,r,o,l=0){const a=16.666/i;let u=`{ -`;for(let m=0;m<=1;m+=a){const _=e+(t-e)*r(m);u+=m*100+`%{${o(_,1-_)}} -`}const c=u+`100% {${o(t,1-t)}} -}`,f=`__svelte_${lC(c)}_${l}`,h=Ny(n),{stylesheet:d,rules:p}=Nu.get(h)||aC(h,n);p[f]||(p[f]=!0,d.insertRule(`@keyframes ${f} ${c}`,d.cssRules.length));const g=n.style.animation||"";return n.style.animation=`${g?`${g}, `:""}${f} ${i}ms linear ${s}ms 1 both`,Du+=1,f}function xu(n,e){const t=(n.style.animation||"").split(", "),i=t.filter(e?r=>r.indexOf(e)<0:r=>r.indexOf("__svelte")===-1),s=t.length-i.length;s&&(n.style.animation=i.join(", "),Du-=s,Du||uC())}function uC(){ep(()=>{Du||(Nu.forEach(n=>{const{ownerNode:e}=n.stylesheet;e&&E(e)}),Nu.clear())})}function np(n,e,t,i){if(!e)return Z;const s=n.getBoundingClientRect();if(e.left===s.left&&e.right===s.right&&e.top===s.top&&e.bottom===s.bottom)return Z;const{delay:r=0,duration:o=300,easing:l=Ic,start:a=Qd()+r,end:u=a+o,tick:c=Z,css:f}=t(n,{from:e,to:s},i);let h=!0,d=!1,p;function g(){f&&(p=ip(n,0,1,o,r,l,f)),r||(d=!0)}function m(){f&&xu(n,p),h=!1}return tp(_=>{if(!d&&_>=a&&(d=!0),d&&_>=u&&(c(1,0),m()),!h)return!1;if(d){const b=_-a,y=0+1*l(b/o);c(y,1-y)}return!0}),g(),c(0,1),m}function sp(n){const e=getComputedStyle(n);if(e.position!=="absolute"&&e.position!=="fixed"){const{width:t,height:i}=e,s=n.getBoundingClientRect();n.style.position="absolute",n.style.width=t,n.style.height=i,cC(n,s)}}function cC(n,e){const t=n.getBoundingClientRect();if(e.left!==t.left||e.top!==t.top){const i=getComputedStyle(n),s=i.transform==="none"?"":i.transform;n.style.transform=`${s} translate(${e.left-t.left}px, ${e.top-t.top}px)`}}let Vl;function Bs(n){Vl=n}function Nr(){if(!Vl)throw new Error("Function called outside component initialization");return Vl}function fC(n){Nr().$$.before_update.push(n)}function sl(n){Nr().$$.on_mount.push(n)}function Y9(n){Nr().$$.after_update.push(n)}function rp(n){Nr().$$.on_destroy.push(n)}function mi(){const n=Nr();return(e,t,{cancelable:i=!1}={})=>{const s=n.$$.callbacks[e];if(s){const r=Dy(e,t,{cancelable:i});return s.slice().forEach(o=>{o.call(n,r)}),!r.defaultPrevented}return!0}}function xy(n,e){return Nr().$$.context.set(n,e),e}function op(n){return Nr().$$.context.get(n)}function Ut(n,e){const t=n.$$.callbacks[e.type];t&&t.slice().forEach(i=>i.call(this,e))}const wo=[],Ze=[];let Do=[];const Dh=[],Ly=Promise.resolve();let xh=!1;function My(){xh||(xh=!0,Ly.then(lp))}function yr(){return My(),Ly}function vn(n){Do.push(n)}function Gt(n){Dh.push(n)}const Nf=new Set;let po=0;function lp(){if(po!==0)return;const n=Vl;do{try{for(;pon.indexOf(i)===-1?e.push(i):t.push(i)),t.forEach(i=>i()),Do=e}let dl;function Ry(){return dl||(dl=Promise.resolve(),dl.then(()=>{dl=null})),dl}function Lu(n,e,t){n.dispatchEvent(Dy(`${e?"intro":"outro"}${t}`))}const lu=new Set;let or;function oe(){or={r:0,c:[],p:or}}function le(){or.r||lt(or.c),or=or.p}function S(n,e){n&&n.i&&(lu.delete(n),n.i(e))}function C(n,e,t,i){if(n&&n.o){if(lu.has(n))return;lu.add(n),or.c.push(()=>{lu.delete(n),i&&(t&&n.d(1),i())}),n.o(e)}else i&&i()}const Py={duration:0};function Ec(n,e,t){const i={direction:"in"};let s=e(n,t,i),r=!1,o,l,a=0;function u(){o&&xu(n,o)}function c(){const{delay:h=0,duration:d=300,easing:p=Ic,tick:g=Z,css:m}=s||Py;m&&(o=ip(n,0,1,d,h,p,m,a++)),g(0,1);const _=Qd()+h,b=_+d;l&&l.abort(),r=!0,vn(()=>Lu(n,!0,"start")),l=tp(y=>{if(r){if(y>=b)return g(1,0),Lu(n,!0,"end"),u(),r=!1;if(y>=_){const k=p((y-_)/d);g(k,1-k)}}return r})}let f=!1;return{start(){f||(f=!0,xu(n),Xn(s)?(s=s(i),Ry().then(c)):c())},invalidate(){f=!1},end(){r&&(u(),r=!1)}}}function X9(n,e,t){const i={direction:"out"};let s=e(n,t,i),r=!0,o;const l=or;l.r+=1;let a;function u(){const{delay:c=0,duration:f=300,easing:h=Ic,tick:d=Z,css:p}=s||Py;p&&(o=ip(n,1,0,f,c,h,p));const g=Qd()+c,m=g+f;vn(()=>Lu(n,!1,"start")),"inert"in n&&(a=n.inert,n.inert=!0),tp(_=>{if(r){if(_>=m)return d(0,1),Lu(n,!1,"end"),--l.r||lt(l.c),!1;if(_>=g){const b=h((_-g)/f);d(1-b,b)}}return r})}return Xn(s)?Ry().then(()=>{s=s(i),u()}):u(),{end(c){c&&"inert"in n&&(n.inert=a),c&&s.tick&&s.tick(1,0),r&&(o&&xu(n,o),r=!1)}}}function K9(n,e){const t=e.token={};function i(s,r,o,l){if(e.token!==t)return;e.resolved=l;let a=e.ctx;o!==void 0&&(a=a.slice(),a[o]=l);const u=s&&(e.current=s)(a);let c=!1;e.block&&(e.blocks?e.blocks.forEach((f,h)=>{h!==r&&f&&(oe(),C(f,1,1,()=>{e.blocks[h]===f&&(e.blocks[h]=null)}),le())}):e.block.d(1),u.c(),S(u,1),u.m(e.mount(),e.anchor),c=!0),e.block=u,e.blocks&&(e.blocks[r]=u),c&&lp()}if(jT(n)){const s=Nr();if(n.then(r=>{Bs(s),i(e.then,1,e.value,r),Bs(null)},r=>{if(Bs(s),i(e.catch,2,e.error,r),Bs(null),!e.hasCatch)throw r}),e.current!==e.pending)return i(e.pending,0),!0}else{if(e.current!==e.then)return i(e.then,1,e.value,n),!0;e.resolved=n}}function $9(n,e,t){const i=e.slice(),{resolved:s}=n;n.current===n.then&&(i[n.value]=s),n.current===n.catch&&(i[n.error]=s),n.block.p(i,t)}function Xe(n){return(n==null?void 0:n.length)!==void 0?n:Array.from(n)}function By(n,e){n.d(1),e.delete(n.key)}function Ac(n,e){C(n,1,1,()=>{e.delete(n.key)})}function ap(n,e){n.f(),Ac(n,e)}function Dr(n,e,t,i,s,r,o,l,a,u,c,f){let h=n.length,d=r.length,p=h;const g={};for(;p--;)g[n[p].key]=p;const m=[],_=new Map,b=new Map,y=[];for(p=d;p--;){const x=f(s,r,p),R=t(x);let N=o.get(R);N?i&&y.push(()=>N.p(x,e)):(N=u(R,x),N.c()),_.set(R,m[p]=N),R in g&&b.set(R,Math.abs(p-g[R]))}const k=new Set,T=new Set;function I(x){S(x,1),x.m(l,c),o.set(x.key,x),c=x.first,d--}for(;h&&d;){const x=m[d-1],R=n[h-1],N=x.key,O=R.key;x===R?(c=x.first,h--,d--):_.has(O)?!o.has(N)||k.has(N)?I(x):T.has(O)?h--:b.get(N)>b.get(O)?(T.add(N),I(x)):(k.add(O),h--):(a(R,o),h--)}for(;h--;){const x=n[h];_.has(x.key)||a(x,o)}for(;d;)I(m[d-1]);return lt(y),m}function _i(n,e){const t={},i={},s={$$scope:1};let r=n.length;for(;r--;){const o=n[r],l=e[r];if(l){for(const a in o)a in l||(i[a]=1);for(const a in l)s[a]||(t[a]=l[a],s[a]=1);n[r]=l}else for(const a in o)s[a]=1}for(const o in i)o in t||(t[o]=void 0);return t}function rl(n){return typeof n=="object"&&n!==null?n:{}}function jt(n,e,t){const i=n.$$.props[e];i!==void 0&&(n.$$.bound[i]=t,t(n.$$.ctx[i]))}function Y(n){n&&n.c()}function G(n,e,t){const{fragment:i,after_update:s}=n.$$;i&&i.m(e,t),vn(()=>{const r=n.$$.on_mount.map(Iy).filter(Xn);n.$$.on_destroy?n.$$.on_destroy.push(...r):lt(r),n.$$.on_mount=[]}),s.forEach(vn)}function j(n,e){const t=n.$$;t.fragment!==null&&(dC(t.after_update),lt(t.on_destroy),t.fragment&&t.fragment.d(e),t.on_destroy=t.fragment=null,t.ctx=[])}function pC(n,e){n.$$.dirty[0]===-1&&(wo.push(n),My(),n.$$.dirty.fill(0)),n.$$.dirty[e/31|0]|=1<{const p=d.length?d[0]:h;return u.ctx&&s(u.ctx[f],u.ctx[f]=p)&&(!u.skip_bound&&u.bound[f]&&u.bound[f](p),c&&pC(n,f)),h}):[],u.update(),c=!0,lt(u.before_update),u.fragment=i?i(u.ctx):!1,e.target){if(e.hydrate){const f=iC(e.target);u.fragment&&u.fragment.l(f),f.forEach(E)}else u.fragment&&u.fragment.c();e.intro&&S(n.$$.fragment),G(n,e.target,e.anchor),lp()}Bs(a)}class _e{constructor(){P(this,"$$");P(this,"$$set")}$destroy(){j(this,1),this.$destroy=Z}$on(e,t){if(!Xn(t))return Z;const i=this.$$.callbacks[e]||(this.$$.callbacks[e]=[]);return i.push(t),()=>{const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}$set(e){this.$$set&&!qT(e)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const gC="4",go=[];function Be(n,e=Z){let t;const i=new Set;function s(l){if(ae(n,l)&&(n=l,t)){const a=!go.length;for(const u of i)u[1](),go.push(u,n);if(a){for(let u=0;u{i.delete(u),i.size===0&&t&&(t(),t=null)}}return{set:s,update:r,subscribe:o}}const zy=Be({currentSelection:[],currentSelectionNodes:[],currentHovered:new Set,currentHoveredNodes:new Set});function mC(){zy.set({currentSelection:[],currentSelectionNodes:[],currentHovered:new Set,currentHoveredNodes:new Set})}const Ri={...zy,clear:mC};var Qe=(n=>(n[n.UP=1]="UP",n[n.DOWN=2]="DOWN",n[n.LEFT=3]="LEFT",n[n.RIGHT=4]="RIGHT",n[n.CENTER=5]="CENTER",n))(Qe||{}),ft=(n=>(n[n.ALWAYS=0]="ALWAYS",n[n.ON_EVENT=1]="ON_EVENT",n[n.NEVER=2]="NEVER",n[n.ON_TRIGGER=3]="ON_TRIGGER",n[n.ON_REQUEST=4]="ON_REQUEST",n))(ft||{});const Vr=["Always","On Event","Never","On Trigger"],Og=["#666","#422","#333","#224","#626"];var Re=(n=>(n[n.DEFAULT=0]="DEFAULT",n[n.BOX_SHAPE=1]="BOX_SHAPE",n[n.ROUND_SHAPE=2]="ROUND_SHAPE",n[n.CIRCLE_SHAPE=3]="CIRCLE_SHAPE",n[n.CARD_SHAPE=4]="CARD_SHAPE",n[n.ARROW_SHAPE=5]="ARROW_SHAPE",n[n.GRID_SHAPE=6]="GRID_SHAPE",n))(Re||{});const Ng=["default","box","round","circle","card","arrow","square"];var mt=(n=>(n[n.INPUT=0]="INPUT",n[n.OUTPUT=1]="OUTPUT",n))(mt||{}),Ll=(n=>(n[n.STRAIGHT_LINK=0]="STRAIGHT_LINK",n[n.LINEAR_LINK=1]="LINEAR_LINK",n[n.SPLINE_LINK=2]="SPLINE_LINK",n))(Ll||{}),Ji=(n=>(n[n.NORMAL_TITLE=0]="NORMAL_TITLE",n[n.NO_TITLE=1]="NO_TITLE",n[n.TRANSPARENT_TITLE=2]="TRANSPARENT_TITLE",n[n.AUTOHIDE_TITLE=3]="AUTOHIDE_TITLE",n))(Ji||{}),$=(n=>(n[n.EVENT=-2]="EVENT",n[n.ACTION=-1]="ACTION",n[n.DEFAULT=0]="DEFAULT",n))($||{});const up=["*","array","object","number","string","enum","boolean","table"];var ko=(n=>(n.VERTICAL_LAYOUT="vertical",n.HORIZONTAL_LAYOUT="horizontal",n))(ko||{});function Uo(n,e,t){return e>n?e:t{const s=e(i);return t[s]=i,t},{})}function Dg(n,e){return e in n?n[e]:null}function au(n,e){return e in n.constructor?n.constructor[e]:null}function _C(n,e){if(n.target!==e)return;let t=n.clientX-parseInt(window.getComputedStyle(e).left),i=n.clientY-parseInt(window.getComputedStyle(e).top);const s=o=>{if(o.buttons===0){r();return}e.style.top=o.clientY-i+"px",e.style.left=o.clientX-t+"px"},r=()=>{window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",r)};window.addEventListener("mousemove",s),window.addEventListener("mouseup",r)}function Lh(n){return n.addEventListener("mousedown",e=>_C(e,n)),n.classList.add("draggable"),n}function sn(n){return n===$.EVENT?"Event":n===$.ACTION?"Action":n===$.DEFAULT?"Default":n}function Fy(n){return n===$.EVENT||n===$.ACTION||n===$.DEFAULT||typeof n=="string"}const $e=class{static registerNodeType(n){$e.debug;const e=n.name,t=n.type;if(!t)throw"Config has no type: "+n;if($e.debug,n.category==null||n.category===""){const s=t.lastIndexOf("/");n.category=t.substring(0,s)}n.title||(n.title=e);const i=$e.registered_node_types[t];if(n.supported_extensions)for(let s in n.supported_extensions){const r=n.supported_extensions[s];r&&r.constructor===String&&($e.node_types_by_file_extension[r.toLowerCase()]=n)}n.class.__LITEGRAPH_TYPE__=t,$e.registered_node_types[t]=n,n.class.name&&($e.Nodes[e]=n),$e.onNodeTypeRegistered&&$e.onNodeTypeRegistered(t,n),i&&$e.onNodeTypeReplaced&&$e.onNodeTypeReplaced(t,n,i)}static unregisterNodeType(n){let e;if(typeof n=="string"?e=$e.registered_node_types[n]:e=n,!e)throw"node type not found: "+n;delete $e.registered_node_types[e.type],e.constructor.name&&delete $e.Nodes[e.constructor.name]}static registerNodeAndSlotType(n,e,t=!1){let i;if(typeof n=="string"?i=$e.registered_node_types[n]:"type"in n?i=$e.registered_node_types[n.type]:i=n,!i)throw"Node not registered!"+n;var s=i.class.__litegraph_type__;if(typeof e=="string")var r=e.split(",");else if(e==$.EVENT||e==$.ACTION)var r=["_event_"];else var r=["*"];for(var o=0;o"u"&&(this[a][l]={nodes:[]}),this[a][l].nodes.push(s),l!=="_event_"&&l!=="*"&&(t?$e.slot_types_out.includes(l.toLowerCase())||($e.slot_types_out.push(l.toLowerCase()),$e.slot_types_out.sort()):$e.slot_types_in.includes(l.toLowerCase())||($e.slot_types_in.push(l.toLowerCase()),$e.slot_types_in.sort()))}}static clearRegisteredTypes(){$e.registered_node_types={},$e.node_types_by_file_extension={},$e.Nodes={},$e.searchbox_extras={}}static createNode(n,e,t={}){let i=null,s;if(typeof n=="string")s=n;else if(s=n.__LITEGRAPH_TYPE__,!s)throw"Node was not registered yet!";if(i=$e.registered_node_types[s],!i)return null;e=e||i.title||s;var r=null;const o=t.constructorArgs||[];if($e.catch_exceptions)try{r=new i.class(e,...o)}catch{return null}else r=new i.class(e,...o);if(r.class=i.class,r.type=s,!r.title&&e&&(r.title=e),r.properties||(r.properties={}),r.properties_info||(r.properties_info=[]),r.flags||(r.flags={}),r.size||(r.size=r.computeSize()),r.pos||(r.pos=[$e.DEFAULT_POSITION[0],$e.DEFAULT_POSITION[1]]),r.mode||(r.mode=ft.ALWAYS),t.instanceProps)for(var l in t.instanceProps)r[l]=t.instanceProps[l];const a=Dg(i.class,"propertyLayout");if(a){$e.debug;for(const c of a){const{name:f,defaultValue:h,type:d,options:p}=c;r.addProperty(f,h,d,p)}}const u=Dg(i.class,"slotLayout");if(u){if($e.debug,u.inputs)for(const c of u.inputs){const{name:f,type:h,options:d}=c;r.addInput(f,h,d)}if(u.outputs)for(const c of u.outputs){const{name:f,type:h,options:d}=c;r.addOutput(f,h,d)}}return r.onNodeCreated&&r.onNodeCreated(),r}static getNodeType(n){return $e.registered_node_types[n]}static getNodeTypesInCategory(n,e){var t=[];for(var i in $e.registered_node_types){var s=$e.registered_node_types[i];s.filter==e&&(n==""?s.category==null&&t.push(s):s.category==n&&t.push(s))}return $e.auto_sort_node_types&&t.sort(function(r,o){return r.title.localeCompare(o.title)}),t}static getNodeTypesCategories(n){var e={"":1};for(var t in $e.registered_node_types){var i=$e.registered_node_types[t];if(i.category&&!i.hide_in_node_lists){if(i.filter!=n)continue;e[i.category]=1}}var s=[];for(var t in e)s.push(t);return $e.auto_sort_node_types?s.sort():s}static reloadNodes(n){for(var e=document.getElementsByTagName("script"),t=[],i=0;in&&ie}static growBounding(n,e,t){return en[2]&&(n[2]=e),tn[3]&&(n[3]=t),n}static isInsideBounding(n,e){return!(n[0]e[1][0]||n[1]>e[1][1])}static overlapBounding(n,e){var t=n[0]+n[2],i=n[1]+n[3],s=e[0]+e[2],r=e[1]+e[3];return!(n[0]>s||n[1]>r||t=this.viewport[0]&&r=this.viewport[1]&&othis.max_scale&&(e=this.max_scale),e!=this.scale&&this.element){var i=this.element.getBoundingClientRect();if(i){t=t||[i.width*.5,i.height*.5],t[0]-=i.left,t[1]-=i.top;var s=this.convertCanvasToOffset(t);this.scale=e,Math.abs(this.scale-1)<.01&&(this.scale=1);var r=this.convertCanvasToOffset(t),o=[r[0]-s[0],r[1]-s[1]];this.offset[0]+=o[0],this.offset[1]+=o[1],this.onredraw&&this.onredraw(this)}}}changeDeltaScale(e,t){this.changeScale(this.scale*e,t)}reset(){this.scale=1,this.offset[0]=0,this.offset[1]=0}}class Oa{processMouseDown(e){if(this.set_canvas_dirty_on_mouse_event&&(this.dirty_canvas=!0),!this.graph)return;let t=e;this.adjustMouseEvent(t);var i=this.getCanvasWindow();i.document,re.active_canvas=this;var s=t.clientX,r=t.clientY;this.ds.viewport=this.viewport;var o=!this.viewport||this.viewport&&s>=this.viewport[0]&&s=this.viewport[1]&&rl.size[0]-w.NODE_TITLE_HEIGHT&&k[1]<0&&setTimeout(()=>{this.openSubgraph(l.subgraph)},10),this.live_mode&&(h=!0,y=!0)),y||(this.allow_dragnodes&&(this.graph.beforeChange(),this.node_dragged=l),this.selected_nodes[l.id]||this.processNodeSelected(l,t)),this.dirty_canvas=!0}}else if(!a){let X=!1;if(l&&l.subgraph&&!l.skip_subgraph_button){var k=[t.canvasX-l.pos[0],t.canvasY-l.pos[1]];!l.flags.collapsed&&k[0]>l.size[0]-w.NODE_TITLE_HEIGHT&&k[1]<0&&(X=!0,setTimeout(()=>{this.openSubgraph(l.subgraph)},10))}if(!X){if(this.allow_interaction&&!this.read_only){const q=this.findLinkCenterAtPos(t.canvasX,t.canvasY);q!=null&&(this.showLinkMenu(q,t),this.over_link_center=null)}if(this.selected_group=this.graph.getGroupOnPos(t.canvasX,t.canvasY),this.selected_group_resizing=!1,this.selected_group&&!this.read_only&&this.allow_interaction){t.ctrlKey&&(this.dragging_rectangle=null);var I=w.distance([t.canvasX,t.canvasY],[this.selected_group.pos[0]+this.selected_group.size[0],this.selected_group.pos[1]+this.selected_group.size[1]]);I*this.ds.scale<10?this.selected_group_resizing=!0:this.selected_group.recomputeInsideNodes()}f&&!this.read_only&&this.allow_searchbox&&this.allow_interaction&&(this.showSearchBox(t),t.preventDefault(),t.stopPropagation()),h=!0}}!a&&h&&this.allow_dragcanvas&&(this.dragging_canvas=!0)}else if(t.which==2){if(w.middle_click_slot_add_default_node&&l&&this.allow_interaction&&!a&&!this.read_only&&!this.connecting_node&&!l.flags.collapsed&&!this.live_mode){var x=null,R=null,N=null;if(l.outputs)for(var d=0,p=l.outputs.length;d10&&d>10){for(var m=[],_=0;_=this.viewport[0]&&s=this.viewport[1]&&r0?l*=1.1:i<0&&(l*=1/1.1),this.ds.changeScale(l,[t.clientX,t.clientY]),this.graph.change(),t.preventDefault(),!1}}}}const Ls=class{setZoom(n,e){this.ds.changeScale(n,e),this.maxZoom&&this.ds.scale>this.maxZoom?this.scale=this.maxZoom:this.minZoom&&this.ds.scale> ";e.fillText(a+l.getTitle(),n.width*.5,40),e.restore()}let i=!1;if(this.onRenderBackground&&this.onRenderBackground(n,e)&&(i=!0),this.viewport||(e.restore(),e.setTransform(1,0,0,1,0,0)),this.visible_links.length=0,this.graph){if(e.save(),this.ds.toCanvasContext(e),this.background_image&&this.ds.scale>.5&&!i){this.zoom_modify_alpha?e.globalAlpha=(1-.5/this.ds.scale)*this.editor_alpha:e.globalAlpha=this.editor_alpha,e.imageSmoothingEnabled=e.imageSmoothingEnabled=!1,(!this._bg_img||this._bg_img.name!=this.background_image)&&(this._bg_img=new Image,this._bg_img.name=this.background_image,this._bg_img.src=this.background_image,this._bg_img.onload=()=>{this.draw(!0,!0)});var s=null;this._pattern==null&&this._bg_img.width>0?(s=e.createPattern(this._bg_img,"repeat"),this._pattern_img=this._bg_img,this._pattern=s):s=this._pattern,s&&(e.fillStyle=s,e.fillRect(this.visible_area[0],this.visible_area[1],this.visible_area[2],this.visible_area[3]),e.fillStyle="transparent"),e.globalAlpha=1,e.imageSmoothingEnabled=e.imageSmoothingEnabled=!0}this.graph._groups.length&&!this.live_mode&&this.drawGroups(n,e),this.onDrawBackground&&this.onDrawBackground(e,this.visible_area),w.debug&&(e.fillStyle="red",e.fillRect(this.visible_area[0]+10,this.visible_area[1]+10,this.visible_area[2]-20,this.visible_area[3]-20)),this.render_canvas_border&&(e.strokeStyle="#235",e.strokeRect(0,0,n.width,n.height)),this.render_connections_shadows?(e.shadowColor="#000",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=6):e.shadowColor="rgba(0,0,0,0)",!this.live_mode&&this.render_connections&&this.drawConnections(e),e.shadowColor="rgba(0,0,0,0)",e.restore()}this.dirty_bgcanvas=!1,this.dirty_canvas=!0}drawNode(n,e){this.current_node=n;var t=n.color||n.constructor.color||w.NODE_DEFAULT_COLOR,i=n.bgcolor||n.constructor.bgcolor||w.NODE_DEFAULT_BGCOLOR;n.mouseOver;var s=this.ds.scale<.6;if(this.live_mode){n.flags.collapsed||(e.shadowColor="transparent",n.onDrawForeground&&n.onDrawForeground(e,this,this.canvas));return}var r=this.editor_alpha;if(e.globalAlpha=r,this.render_shadows&&!s?(e.shadowColor=w.DEFAULT_SHADOW_COLOR,e.shadowOffsetX=2*this.ds.scale,e.shadowOffsetY=2*this.ds.scale,e.shadowBlur=3*this.ds.scale):e.shadowColor="transparent",!(n.flags.collapsed&&n.onDrawCollapsed&&n.onDrawCollapsed(e,this)==!0)){var o=n.shape||Re.BOX_SHAPE,l=Ls.temp_vec2;Ls.temp_vec2.set(n.size);var a=n.horizontal;if(n.flags.collapsed){e.font=this.inner_text_font;var u=n.getTitle?n.getTitle():n.title;u!=null&&(n._collapsed_width=Math.min(n.size[0],e.measureText(u).width+w.NODE_TITLE_HEIGHT*2),l[0]=n._collapsed_width,l[1]=0)}n.clip_area&&(e.save(),e.beginPath(),o==Re.BOX_SHAPE?e.rect(0,0,l[0],l[1]):o==Re.ROUND_SHAPE?e.roundRect(0,0,l[0],l[1],[10]):o==Re.CIRCLE_SHAPE&&e.arc(l[0]*.5,l[1]*.5,l[0]*.5,0,Math.PI*2),e.clip()),n.has_errors&&(i="red"),this.drawNodeShape(n,e,[l[0],l[1]],t,i,n.is_selected,n.mouseOver),e.shadowColor="transparent",n.onDrawForeground&&n.onDrawForeground(e,this,this.canvas),e.textAlign=a?"center":"left",e.font=this.inner_text_font;var c=!s,f=this.connecting_output,h=this.connecting_input;e.lineWidth=1;var d=0,p=[0,0];if(n.flags.collapsed){if(this.render_collapsed_slots){var x=null,R=null;if(n.inputs)for(let D=0;D0&&n.execute_triggered--,n.action_triggered>0&&n.action_triggered--}drawConnections(n){var e=w.getTime(),t=this.visible_area;let i=Ls.margin_area;i[0]=t[0]-20,i[1]=t[1]-20,i[2]=t[2]+40,i[3]=t[3]+40,n.lineWidth=this.connections_width,n.fillStyle="#AAA",n.strokeStyle="#AAA",n.globalAlpha=this.editor_alpha;for(var s=this.graph._nodes,r=0,o=s.length;r.6&&(n.lineWidth=this.connections_width+4),n.lineJoin="round",u=u||1,u>1&&(n.lineWidth=.5),n.beginPath();for(var f=0;f.6&&!s&&(n.strokeStyle="rgba(0,0,0,0.5)",n.stroke()),n.lineWidth=this.connections_width,n.fillStyle=n.strokeStyle=o,n.stroke();var I=this.computeConnectionPoint(e,t,.5,l,a);if(i&&i._pos&&(i._pos[0]=I[0],i._pos[1]=I[1]),this.ds.scale>=.6&&this.highquality_render&&a!=Qe.CENTER){if(this.render_connection_arrows){var x=this.computeConnectionPoint(e,t,.25,l,a),R=this.computeConnectionPoint(e,t,.26,l,a),N=this.computeConnectionPoint(e,t,.75,l,a),O=this.computeConnectionPoint(e,t,.76,l,a),D=0,M=0;this.render_curved_connections?(D=-Math.atan2(R[0]-x[0],R[1]-x[1]),M=-Math.atan2(O[0]-N[0],O[1]-N[1])):M=D=t[1]>e[1]?0:Math.PI,n.save(),n.translate(x[0],x[1]),n.rotate(D),n.beginPath(),n.moveTo(-5,-3),n.lineTo(0,7),n.lineTo(5,-3),n.fill(),n.restore(),n.save(),n.translate(N[0],N[1]),n.rotate(M),n.beginPath(),n.moveTo(-5,-3),n.lineTo(0,7),n.lineTo(5,-3),n.fill(),n.restore()}n.beginPath(),n.arc(I[0],I[1],5,0,Math.PI*2),n.fill()}if(r){n.fillStyle=o;for(var f=0;f<5;++f){var L=(w.getTime()*.001+f*.2)%1,I=this.computeConnectionPoint(e,t,L,l,a);n.beginPath(),n.arc(I[0],I[1],5,0,2*Math.PI),n.fill()}}}computeConnectionPoint(n,e,t,i=Qe.RIGHT,s=Qe.LEFT){var r=w.distance(n,e),o=n,l=[n[0],n[1]],a=[e[0],e[1]],u=e;switch(i){case Qe.LEFT:l[0]+=r*-.25;break;case Qe.RIGHT:l[0]+=r*.25;break;case Qe.UP:l[1]+=r*-.25;break;case Qe.DOWN:l[1]+=r*.25;break}switch(s){case Qe.LEFT:a[0]+=r*-.25;break;case Qe.RIGHT:a[0]+=r*.25;break;case Qe.UP:a[1]+=r*-.25;break;case Qe.DOWN:a[1]+=r*.25;break}var c=(1-t)*(1-t)*(1-t),f=3*((1-t)*(1-t))*t,h=3*(1-t)*(t*t),d=t*t*t,p=c*o[0]+f*l[0]+h*a[0]+d*u[0],g=c*o[1]+f*l[1]+h*a[1]+d*u[1];return[p,g]}drawExecutionOrder(n){n.shadowColor="transparent",n.globalAlpha=.25,n.textAlign="center",n.strokeStyle="white",n.globalAlpha=.75;for(var e=this.visible_nodes,t=0;t.5;t.save(),t.globalAlpha=this.editor_alpha;for(var a=w.WIDGET_OUTLINE_COLOR,u=w.WIDGET_BGCOLOR,c=w.WIDGET_TEXT_COLOR,f=w.WIDGET_SECONDARY_TEXT_COLOR,h=15,d=0;de&&this.pos[1]-r-it}setDirtyCanvas(e,t=!1){this.graph&&this.graph.sendActionToCanvas("setDirty",[e,t])}}class Go{constructor(e,t,i,s,r,o){this.data=null,this._pos=[0,0],this._last_time=0,this.id=e,this.type=t,this.origin_id=i,this.origin_slot=s,this.target_id=r,this.target_slot=o}static configure(e){return e instanceof Array?new Go(e[0],e[5],e[1],e[2],e[3],e[4]):new Go(e.id,e.type,e.origin_id,e.origin_slot,e.target_id,e.target_slot)}serialize(){return[this.id,this.origin_id,this.origin_slot,this.target_id,this.target_slot,this.type]}}let Na;const yC=new Uint8Array(16);function vC(){if(!Na&&(Na=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Na))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Na(yC)}const Ni=[];for(let n=0;n<256;++n)Ni.push((n+256).toString(16).slice(1));function wC(n,e=0){return(Ni[n[e+0]]+Ni[n[e+1]]+Ni[n[e+2]]+Ni[n[e+3]]+"-"+Ni[n[e+4]]+Ni[n[e+5]]+"-"+Ni[n[e+6]]+Ni[n[e+7]]+"-"+Ni[n[e+8]]+Ni[n[e+9]]+"-"+Ni[n[e+10]]+Ni[n[e+11]]+Ni[n[e+12]]+Ni[n[e+13]]+Ni[n[e+14]]+Ni[n[e+15]]).toLowerCase()}const kC=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),xg={randomUUID:kC};function fi(n,e,t){if(xg.randomUUID&&!e&&!n)return xg.randomUUID();n=n||{};const i=n.random||(n.rng||vC)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(let s=0;s<16;++s)e[t+s]=i[s];return e}return wC(i)}const Mh=class{constructor(n){this.desc="",this.pos=[0,0],this.subgraph=null,this.skip_subgraph_button=!1,this.priority=0,this.removable=!0,this.clonable=!0,this.collapsable=!0,this.titleMode=Ji.NORMAL_TITLE,this.serialize_widgets=!1,this.hide_in_node_lists=!1,this.block_delete=!1,this.ignore_remove=!1,this.last_serialization=null,this._relative_id=null,this.exec_version=0,this.action_call=null,this.execute_triggered=0,this.action_triggered=0,this.console=[],this.title=n||"Unnamed",this.size=[w.NODE_WIDTH,60],this.graph=null,this.pos=[10,10],w.use_uuids?this.id=fi():this.id=-1,this.type=null,this.inputs=[],this.outputs=[],this.connections=[],this.properties={},this.properties_info=[],this.flags={}}get slotLayout(){return"slotLayout"in this.constructor?this.constructor.slotLayout:null}configure(n){this.graph&&this.graph._version++;for(var e in n){if(e=="properties"){for(var t in n.properties)this.properties[t]=n.properties[t],this.onPropertyChanged&&this.onPropertyChanged(t,n.properties[t]);continue}n[e]!=null&&(typeof n[e]=="object"?this[e]&&this[e].configure?this[e].configure(n[e]):this[e]=w.cloneObject(n[e],this[e]):this[e]=n[e])}n.title||(this.title=au(this,"title")||this.title);const i=n.bgColor;if(i!=null&&(this.bgcolor||(this.bgcolor=i)),this.inputs)for(let o=0;o=this.inputs.length)){var t=this.inputs[n];if(t)return t.properties||(t.properties={}),t.properties[e]}}getOutputSlotProperty(n,e){if(!(!this.outputs||!this.graph)&&!(n==-1||n>=this.outputs.length)){var t=this.outputs[n];if(t)return t.properties||(t.properties={}),t.properties[e]}}setInputSlotProperty(n,e,t){if(!(!this.inputs||!this.graph)&&!(n==-1||n>=this.inputs.length)){var i=this.inputs[n];if(i&&(i.properties||(i.properties={}),t!==i.properties[e])){var s=i.properties[e];i.properties[e]=t,this.graph&&this.graph._version++,this.onSlotPropertyChanged&&this.onSlotPropertyChanged(mt.INPUT,n,i,e,t,s)===!1&&(i.properties[e]=s)}}}setOutputSlotProperty(n,e,t){if(!(!this.outputs||!this.graph)&&!(n==-1||n>=this.outputs.length)){var i=this.outputs[n];if(i&&(i.properties||(i.properties={}),t!==i.properties[e])){var s=i.properties[e];i.properties[e]=t,this.graph&&this.graph._version++,this.onSlotPropertyChanged&&this.onSlotPropertyChanged(mt.OUTPUT,n,i,e,t,s)===!1&&(i.properties[e]=s)}}}setOutputData(n,e){if(!(!this.outputs||!this.graph)&&!(n==-1||n>=this.outputs.length)){var t=this.outputs[n];if(t&&(w.serialize_slot_data?t._data=e:t._data=void 0,this.outputs[n].links))for(var i=0;i=this.outputs.length)){var t=this.outputs[n];if(t&&(t.type=e,this.outputs[n].links))for(let i=this.outputs[n].links.length-1;i>=0;i--){const s=this.outputs[n].links[i],r=this.graph.links[s];if(r){r.type=e;const o=this.graph.getNodeById(r.target_id);if(o){const l=o.getInputInfo(r.target_slot);l&&!w.isValidConnection(e,l.type)&&o.disconnectInput(r.target_slot)}}}}}*iterateInputInfo(){for(let n=0;n=this.inputs.length||this.inputs[n].link==null)){var t=this.inputs[n].link,i=this.graph.links[t];if(!i)return w.debug,null;if(!e)return i.data;var s=this.graph.getNodeById(i.origin_id);return s&&(s.updateOutputData?s.updateOutputData(i.origin_slot):s.onExecute&&s.onExecute(null,{})),i.data}}getInputDataType(n){if(!this.inputs||n>=this.inputs.length||this.inputs[n].link==null)return null;var e=this.inputs[n].link,t=this.graph.links[e];if(!t)return w.debug,null;var i=this.graph.getNodeById(t.origin_id);if(!i)return t.type;var s=i.outputs[t.origin_slot];return s&&s.type!=-1?s.type:null}getInputDataByName(n,e){var t=this.findInputSlotIndexByName(n);return t==-1?null:this.getInputData(t,e)}isInputConnected(n){return this.inputs?n=this.inputs.length)){var t=this.inputs[n];if(t&&(t.type=e,t.link)){const i=t.link,s=this.graph.links[i];s.type=e;const r=this.graph.getNodeById(s.origin_id);if(r){const o=r.getOutputInfo(s.origin_slot);o&&!w.isValidConnection(o.type,e)&&r.disconnectOutput(s.origin_slot)}}}}getOutputSlotConnectedTo(n){if(!this.outputs||!this.graph)return null;if(n>=0&&n=this.outputs.length)return null;var e=this.outputs[n];return e._data}getOutputLinks(n){if(!this.outputs||!this.graph)return[];if(n>=0&&n=0&&n0}isAnyOutputConnected(){if(!this.outputs||!this.graph)return!1;for(var n=0;n=this.outputs.length)return null;var e=this.outputs[n];if(!e.links||e.links.length==0)return null;for(var t=[],i=0;ithis.outputs.length-1)return;const i=this.outputs[e];if(t.links)for(const s of t.links){const r=this.graph.links[s];r.origin_slot=e}if(i.links)for(const s of i.links){const r=this.graph.links[s];r.origin_slot=n}this.outputs[e]=t,this.outputs[n]=i}addInput(n,e=$.DEFAULT,t){var i={name:n,type:e,link:null,properties:{}};if(t)for(var s in t)i[s]=t[s];return(i.shape==null||i.shape==Re.DEFAULT)&&(e=="array"?i.shape=Re.GRID_SHAPE:(e===$.EVENT||e===$.ACTION)&&(i.shape=Re.BOX_SHAPE)),this.inputs||(this.inputs=[]),this.inputs.push(i),this.setSize(this.computeSize()),this.onInputAdded&&this.onInputAdded(i),w.registerNodeAndSlotType(this,e),this.setDirtyCanvas(!0,!0),i}removeInput(n){this.disconnectInput(n);for(var e=this.inputs.splice(n,1),t=n;tthis.inputs.length-1)return;const i=this.inputs[e];if(t.link!=null){const s=this.graph.links[t.link];s.target_slot=e}if(i.link!=null){const s=this.graph.links[i.link];s.target_slot=n}this.inputs[e]=t,this.inputs[n]=i}addConnection(n,e,t,i){let s={name:n,type:e,pos:t,direction:i,links:null};return this.connections.push(s),s}computeSize(n=[0,0]){const e=au(this,"overrideSize");if(e)return e.concat();var t=Math.max(this.inputs?this.inputs.length:1,this.outputs?this.outputs.length:1),i=n;t=Math.max(t,1);var s=w.NODE_TEXT_SIZE,r=g(this.title),o=0,l=0;if(this.inputs)for(var a=0,u=this.inputs.length;an&&this.pos[1]-s-te)return!0;return!1}getSlotInPosition(n,e){var t=[0,0];if(this.inputs)for(var i=0,s=this.inputs.length;i=0&&l!==null)return w.debug,this.connect(n,e,l);if(w.debug,r.createEventInCase&&t==$.EVENT)return w.debug,this.connect(n,e,-1);if(r.generalTypeInCase){let a=e.findInputSlotIndexByType($.DEFAULT,!0,!0);if(w.debug,a>=0)return this.connect(n,e,a)}if(r.firstFreeIfOutputGeneralInCase&&(t==0||t=="*"||t=="")){let a=e.findInputSlotIndexByName(null,!0,[$.EVENT]);if(w.debug,a>=0)return this.connect(n,e,a)}return w.debug,null}connectByTypeOutput(n,e,t,i={}){var s={createEventInCase:!0,firstFreeIfInputGeneralInCase:!0,generalTypeInCase:!0},r=Object.assign(s,i);e&&e.constructor===Number&&(e=this.graph.getNodeById(e));let o=t;if(t===$.EVENT?o=$.ACTION:t===$.ACTION&&(o=$.EVENT),l=e.findOutputSlotIndexByType(o,!0),l>=0&&l!==null)return e.connect(l,this,n);if(r.generalTypeInCase){var l=e.findOutputSlotIndexByType(0,!0,!0);if(l>=0)return e.connect(l,this,n)}if((r.createEventInCase&&t==$.EVENT||t==$.ACTION)&&w.do_add_triggers_slots){var l=e.addOnExecutedOutput();return e.connect(l,this,n)}if(r.firstFreeIfInputGeneralInCase&&(t==0||t=="*"||t=="")){let a=e.findOutputSlotIndexByName(null,!0,[$.EVENT,$.ACTION]);if(a>=0)return e.connect(a,this,n)}return null}connect(n,e,t){if(t=t||0,!this.graph)throw new Error("Connect: Error, node doesn't belong to any graph. Nodes must be added first to a graph before connecting them.");if(typeof n=="string"){if(n=this.findOutputSlotIndexByName(n),n==-1)return w.debug,null}else if(!this.outputs||n>=this.outputs.length)return w.debug,null;if(e&&e.constructor===Number&&(e=this.graph.getNodeById(e)),!e)throw"target node is null";if(e==this)return w.debug,null;if(!e.graph)throw new Error("Connect: Error, target node doesn't belong to any graph. Nodes must be added first to a graph before connecting them.");if(typeof t=="string"){if(t=e.findInputSlotIndexByName(t),t==-1)return w.debug,null}else if(t===$.EVENT)if(w.do_add_triggers_slots)e.changeMode(ft.ON_TRIGGER),t=e.findInputSlotIndexByName("onTrigger");else return w.debug,null;else if(!e.inputs||t>=e.inputs.length)return w.debug,null;var i=!1,s=e.inputs[t],r=null,o=this.outputs[n];if(!this.outputs[n])return w.debug,null;if(e.onBeforeConnectInput&&(t=e.onBeforeConnectInput(t)),t===-1||t===null||!w.isValidConnection(o.type,s.type))return this.setDirtyCanvas(!1,!0),i&&this.graph.connectionChange(this,r),null;if(w.debug,e.onConnectInput&&e.onConnectInput(t,o.type,o,this,n)===!1||this.onConnectOutput&&this.onConnectOutput(n,s.type,s,e,t)===!1)return w.debug,null;if(e.inputs[t]&&e.inputs[t].link!=null&&(this.graph.beforeChange(),e.disconnectInput(t,{doProcessChange:!1}),i=!0),o.links!==null&&o.links.length)switch(o.type){case $.EVENT:w.allow_multi_output_for_events||(this.graph.beforeChange(),this.disconnectOutput(n,null,{doProcessChange:!1}),i=!0);break}let l;return w.use_uuids?l=fi():l=++this.graph.last_link_id,r=new Go(l,s.type||o.type,this.id,n,e.id,t),this.graph.links[r.id],this.graph.links[r.id]=r,o.links==null&&(o.links=[]),o.links.push(r.id),e.inputs[t].link=r.id,this.graph&&this.graph._version++,this.onConnectionsChange&&this.onConnectionsChange(mt.OUTPUT,n,!0,r,o),e.onConnectionsChange&&e.onConnectionsChange(mt.INPUT,t,!0,r,s),this.graph&&this.graph.onNodeConnectionChange&&(this.graph.onNodeConnectionChange(mt.INPUT,e,t,this,n),this.graph.onNodeConnectionChange(mt.OUTPUT,this,n,e,t)),this.setDirtyCanvas(!1,!0),this.graph.afterChange(),this.graph.connectionChange(this,r),r}disconnectOutput(n,e,t){if(typeof n=="string"){if(n=this.findOutputSlotIndexByName(n),n==-1)return w.debug,!1}else if(!this.outputs||n>=this.outputs.length)return w.debug,!1;var i=this.outputs[n];if(!i||!i.links||i.links.length==0)return!1;if(e){if(e.constructor===Number&&(e=this.graph.getNodeById(e)),!e)throw"Target Node not found";for(var s=0,r=i.links.length;s=this.inputs.length)return w.debug,!1;var t=this.inputs[n];if(!t)return!1;var i=this.inputs[n].link;if(i!=null){this.inputs[n].link=null;var s=this.graph.links[i];if(s){var r=this.graph.getNodeById(s.origin_id);if(!r)return!1;var o=r.outputs[s.origin_slot];if(!o||!o.links||o.links.length==0)return!1;for(var l=0,a=o.links.length;le&&this.inputs[e].pos?(t[0]=this.pos[0]+this.inputs[e].pos[0],t[1]=this.pos[1]+this.inputs[e].pos[1],t):!n&&s>e&&this.outputs[e].pos?(t[0]=this.pos[0]+this.outputs[e].pos[0],t[1]=this.pos[1]+this.outputs[e].pos[1],t):this.horizontal?(t[0]=this.pos[0]+(e+.5)*(this.size[0]/s),n?t[1]=this.pos[1]-w.NODE_TITLE_HEIGHT:t[1]=this.pos[1]+this.size[1],t):(n?t[0]=this.pos[0]+r:t[0]=this.pos[0]+this.size[0]+1-r,t[1]=this.pos[1]+(e+.7)*w.NODE_SLOT_HEIGHT+(this.constructor.slot_start_y||0),t)}alignToGrid(){this.pos[0]=w.CANVAS_GRID_SIZE*Math.round(this.pos[0]/w.CANVAS_GRID_SIZE),this.pos[1]=w.CANVAS_GRID_SIZE*Math.round(this.pos[1]/w.CANVAS_GRID_SIZE)}trace(n){this.console||(this.console=[]),this.console.push(n),this.console.length>Mh.MAX_CONSOLE&&this.console.shift(),this.graph.onNodeTrace&&this.graph.onNodeTrace(this,n)}setDirtyCanvas(n,e=!1){this.graph&&this.graph.sendActionToCanvas("setDirty",[n,e])}loadImage(n){var e=new Image;e.src=w.node_images_path+n;var t=this;return e.onload=function(){t.setDirtyCanvas(!0)},e}captureInput(n){if(!(!this.graph||!this.graph.list_of_graphcanvas))for(var e=this.graph.list_of_graphcanvas,t=0;te.toUpperCase())),n}function SC(){return Wy().map(sn)}class qi extends Ke{constructor(e){super(e),this.properties={name:"",type:"number",value:0,subgraphID:null},this.nameInGraph="",this.clonable=!1,this.size=[180,90];let t=this;this.nameWidget=this.addWidget("text","Name",this.properties.name,this.setName.bind(this)),w.graph_inputs_outputs_use_combo_widget?this.typeWidget=this.addWidget("combo","Type",sn(this.properties.type),this.setType.bind(this),{values:SC}):this.typeWidget=this.addWidget("text","Type",sn(this.properties.type),this.setType.bind(this)),this.valueWidget=this.addWidget("number","Value",this.properties.value,function(i){t.setProperty("value",i)}),this.widgets_up=!0}setName(e){if(e==null||e===this.properties.name)return;const t=this.getParentSubgraph();t&&(e=t.getValidGraphInputName(e),this.setProperty("name",e))}setType(e){e||(e="*");let t=e;e==="-1"||e==="Action"?t=$.ACTION:e==="-2"||e==="Event"?t=$.EVENT:e==="0"&&(t="*"),this.setProperty("type",t)}onConfigure(){this.updateType()}getParentSubgraph(){var e,t;return(t=(e=this.graph._subgraph_node)==null?void 0:e.graph)==null?void 0:t.getNodeById(this.properties.subgraphID)}updateType(){var e=this.properties.type;this.typeWidget.value=sn(e);const t=this.outputs[0];t.type!=e&&(w.isValidConnection(t.type,e)||this.disconnectOutput(0),t.type=e),e=="array"?t.shape=Re.GRID_SHAPE:e===$.EVENT||e===$.ACTION?t.shape=Re.BOX_SHAPE:t.shape=Re.DEFAULT,e=="number"?(this.valueWidget.type="number",this.valueWidget.value=0):e=="boolean"?(this.valueWidget.type="toggle",this.valueWidget.value=!0):e=="string"?(this.valueWidget.type="text",this.valueWidget.value=""):(this.valueWidget.type=null,this.valueWidget.value=null),this.properties.value=this.valueWidget.value,this.graph&&this.nameInGraph&&Fy(e)&&(this.graph.changeInputType(this.nameInGraph,e),t.type!==e&&this.setOutputDataType(0,e))}onPropertyChanged(e,t){if(e=="name"){if(t==""||t==this.nameInGraph||t=="enabled")return!1;this.graph&&(this.nameInGraph?this.graph.renameInput(this.nameInGraph,t):this.graph.addInput(t,""+this.properties.type,null)),this.nameWidget.value=t,this.nameInGraph=t}else e=="type"&&this.updateType()}getTitle(){return this.flags.collapsed?this.properties.name:this.title}onAction(e,t){this.properties.type==$.EVENT&&this.triggerSlot(0,t)}onExecute(){var e=this.properties.name,t=this.graph.inputs[e];if(!t){this.setOutputData(0,this.properties.value);return}this.setOutputData(0,t.value!==void 0?t.value:this.properties.value)}onRemoved(){this.nameInGraph&&this.graph.removeInput(this.nameInGraph)}}qi.slotLayout={inputs:[],outputs:[{name:"",type:"number"}]};w.registerNodeType({class:qi,title:"Input",desc:"Input of the graph",type:"graph/input",hide_in_node_lists:!0});function Vy(){let n=[];return n=n.concat(up),n=n.concat([$.EVENT]),n=n.concat(w.slot_types_out),n}function TC(){return Vy().map(sn)}class pn extends Ke{constructor(e){super(e),this.properties={name:"",type:"number",subgraphID:null},this.nameInGraph="",this.clonable=!1,this.size=[180,60],this.nameWidget=this.addWidget("text","Name",this.properties.name,this.setName.bind(this)),w.graph_inputs_outputs_use_combo_widget?this.typeWidget=this.addWidget("combo","Type",sn(this.properties.type),this.setType.bind(this),{values:TC}):this.typeWidget=this.addWidget("text","Type",sn(this.properties.type),this.setType.bind(this)),this.widgets_up=!0}setName(e){if(e==null||e===this.properties.name)return;const t=this.getParentSubgraph();t&&(e=t.getValidGraphOutputName(e),this.setProperty("name",e))}setType(e){e||(e="*");let t=e;e==="-1"||e==="Action"?t=$.ACTION:e==="-2"||e==="Event"?t=$.EVENT:e==="0"&&(t="*"),this.setProperty("type",t)}onConfigure(){this.updateType()}getParentSubgraph(){var e,t;return(t=(e=this.graph._subgraph_node)==null?void 0:e.graph)==null?void 0:t.getNodeById(this.properties.subgraphID)}updateType(){var e=this.properties.type;const t=this.inputs[0];this.typeWidget&&(this.typeWidget.value=sn(e)),e=="array"?t.shape=Re.GRID_SHAPE:e===$.EVENT||e===$.ACTION?t.shape=Re.BOX_SHAPE:t.shape=Re.DEFAULT,t.type!=e&&((e=="action"||e=="event")&&(e=$.EVENT),w.isValidConnection(t.type,e)||this.disconnectInput(0),t.type=e),this.graph&&this.nameInGraph&&Fy(e)&&(this.graph.changeOutputType(this.nameInGraph,e),t.type!==e&&this.setInputDataType(0,e))}onPropertyChanged(e,t){if(e=="name"){if(t==""||t==this.nameInGraph||t=="enabled")return!1;this.graph&&(this.nameInGraph?this.graph.renameOutput(this.nameInGraph,t):this.graph.addOutput(t,""+this.properties.type,null)),this.nameWidget.value=t,this.nameInGraph=t}else e=="type"&&this.updateType()}getTitle(){return this.flags.collapsed?this.properties.name:this.title}onAction(e,t,i){const s=this.getParentSubgraph();if(!s)return;const r=s.findOutputSlotIndexByName(this.properties.name);r==null||s.outputs[r]==null||s.triggerSlot(r,t)}onExecute(){const e=this.getInputData(0);this.graph.setOutputData(this.properties.name,e)}onRemoved(){this.nameInGraph&&this.graph.removeOutput(this.nameInGraph)}}pn.slotLayout={inputs:[{name:"",type:""}],outputs:[]};w.registerNodeType({class:pn,title:"Output",desc:"Output of the graph",type:"graph/output",hide_in_node_lists:!0});const Hy=class{constructor(n){this.supported_types=null,this.vars={},this.extra={},this.inputs={},this.outputs={},this.links={},this.list_of_graphcanvas=[],this._nodes=[],this._groups=[],this._nodes_by_id={},this._nodes_executable=null,this._nodes_in_order=[],this._version=-1,this._last_trigger_time=0,this._is_subgraph=!1,this._subgraph_node=null,this.nodes_executing=[],this.nodes_actioning=[],this.nodes_executedAction=[],this.execution_timer_id=-1,this.execution_time=0,this.errors_in_execution=!1,w.debug,this.list_of_graphcanvas=null,this.clear(),n&&this.configure(n)}getSupportedTypes(){return this.supported_types||Hy.DEFAULT_SUPPORTED_TYPES}getRootGraph(){const n=Array.from(this.iterateParentGraphs()),e=n[n.length-1];return e._is_subgraph?null:e}*iterateParentGraphs(){var e;let n=this;for(;n;)yield n,n=(e=n._subgraph_node)==null?void 0:e.graph}clear(){if(this.stop(),this.status=1,this.last_node_id=0,this.last_link_id=0,this._version=-1,this._nodes)for(var n=0;nl&&(l=c.size[f]);const h=e==ko.VERTICAL_LAYOUT?0:1;a+=c.size[h]+n+w.NODE_TITLE_HEIGHT}s+=l+n}this.setDirtyCanvas(!0,!0)}getTime(){return this.globaltime}getFixedTime(){return this.fixedtime}getElapsedTime(){return this.elapsed_time}*iterateNodesInOrder(){const n=this._nodes_in_order?this._nodes_in_order:this._nodes||[];for(const e of n)yield e}*iterateNodesInOrderRecursive(){const n=this._nodes_in_order?this._nodes_in_order:this._nodes||[];for(const e of n)if(yield e,e.subgraph!=null)for(const t of e.subgraph.iterateNodesInOrderRecursive())yield t}*iterateNodesOfClass(n){const e=n.__LITEGRAPH_TYPE__;if(e!=null)for(const t of this.iterateNodesInOrder())t.type===e&&(yield t)}*iterateNodesOfClassRecursive(n){const e=n.__LITEGRAPH_TYPE__;if(e!=null)for(const t of this.iterateNodesInOrderRecursive())t.type===e&&(yield t)}*iterateNodesOfTypeRecursive(n){for(const e of this.iterateNodesInOrderRecursive())e.type===n&&(yield e)}sendEventToAllNodes(n,e=[],t=ft.ALWAYS){var i=this._nodes_in_order?this._nodes_in_order:this._nodes;if(i)for(const s of this.iterateNodesInOrder()){if(s.type==="basic/subgraph"&&n!="onExecute"){s.mode==t&&s.sendEventToAllNodes(n,e,t);continue}!s[n]||s.mode!=t||(e===void 0?s[n]():e&&e.constructor===Array?s[n].apply(s,e):s[n](e))}}sendActionToCanvas(n,e=[]){if(this.list_of_graphcanvas)for(var t=0;t=w.MAX_NUMBER_OF_NODES)throw"LiteGraph: max number of nodes in a graph reached";return w.use_uuids?n.id||(n.id=fi()):n.id==null||n.id==-1?n.id=++this.last_node_id:this.last_node_id=0;r--){var o=t[r],l=o.titleMode==Ji.NO_TITLE;if(o.isPointInside(n,e,i,l))return o}return s}getGroupOnPos(n,e){for(var t=this._groups.length-1;t>=0;t--){var i=this._groups[t];if(i.isPointInside(n,e,2,!0))return i}return null}checkNodeTypes(){for(var n=!1,e=0;ee.linkIDs[s]))}for(const t of n.nodes)if(t.type==="graph/subgraph"){const i=fp(t.subgraph);e.nodeIDs={...e.nodeIDs,...i.nodeIDs},e.linkIDs={...e.linkIDs,...i.linkIDs}}return e}function CC(n,e){for(const t of n.iterateNodesInOrderRecursive())t.onReassignID&&t.onReassignID(e)}const Uy=class extends Ke{constructor(n,e){super(n),this.properties={enabled:!0},this.size=[140,80],this.enabled=!0,this.subgraph=(e||Uy.default_lgraph_factory)(),this.subgraph._subgraph_node=this,this.subgraph._is_subgraph=!0;const t=(i,s)=>{const r=s.bind(this);return function(...o){i==null||i.apply(this,o),r(...o)}};this.subgraph.onTrigger=t(this.subgraph.onTrigger,this.onSubgraphTrigger),this.subgraph.onNodeAdded=t(this.subgraph.onNodeAdded,this.onSubgraphNodeAdded),this.subgraph.onNodeRemoved=t(this.subgraph.onNodeRemoved,this.onSubgraphNodeRemoved),this.subgraph.onInputAdded=t(this.subgraph.onInputAdded,this.onSubgraphNewInput),this.subgraph.onInputRenamed=t(this.subgraph.onInputRenamed,this.onSubgraphRenamedInput),this.subgraph.onInputTypeChanged=t(this.subgraph.onInputTypeChanged,this.onSubgraphTypeChangeInput),this.subgraph.onInputRemoved=t(this.subgraph.onInputRemoved,this.onSubgraphRemovedInput),this.subgraph.onOutputAdded=t(this.subgraph.onOutputAdded,this.onSubgraphNewOutput),this.subgraph.onOutputRenamed=t(this.subgraph.onOutputRenamed,this.onSubgraphRenamedOutput),this.subgraph.onOutputTypeChanged=t(this.subgraph.onOutputTypeChanged,this.onSubgraphTypeChangeOutput),this.subgraph.onOutputRemoved=t(this.subgraph.onOutputRemoved,this.onSubgraphRemovedOutput)}*iterateParentGraphs(){var e;let n=this.graph;for(;n;)yield n,n=(e=n._subgraph_node)==null?void 0:e.graph}onDblClick(n,e,t){var i=this;setTimeout(function(){t.openSubgraph(i.subgraph)},10)}onAction(n,e,t){const{originNode:i,link:s}=t;if(!i||!s)return;const r=s.target_slot;this.getInnerGraphInputByIndex(r).triggerSlot(0,e)}onExecute(){if(this.enabled=this.getInputOrProperty("enabled"),!!this.enabled){if(this.inputs)for(var n=0;n!b.is(qi)&&!b.is(pn)),n.length===0)return;const e={},t={},i={},s=n.reduce((b,y)=>(b[y.id]=y,b),{});let r=Number.MAX_SAFE_INTEGER,o=0,l=Number.MAX_SAFE_INTEGER,a=0;for(const b of Object.values(n))r=Math.min(b.pos[0],r),o=Math.max(b.pos[0]+b.size[0],o),l=Math.min(b.pos[1],l),a=Math.max(b.pos[1]+b.size[1],a);const u={};for(const b of n){u[b.id]=b;for(let y=0;yb[1][1]-y[1][1]),f.sort((b,y)=>b[1][1]-y[1][1]),w.debug;const h={},d={};for(const b of n){const y=[b.pos[0]-r,b.pos[1]-l],k=b.id;b.graph.remove(b,{removedBy:"moveIntoSubgraph"}),this.subgraph.add(b,{addedBy:"moveIntoSubgraph",prevNodeID:k}),b.pos=y,u[k]=b,u[b.id]=b}let p=0,g=0;for(const[b,y,k]of c){let T=null;if(h[b.origin_id]&&(T=h[b.origin_id][b.origin_slot]),!T&&(T=this.addGraphInput(k,b.type,[-200,p]),p+=T.innerNode.size[1]+w.NODE_SLOT_HEIGHT,!T))continue;const I=u[b.origin_id],x=u[b.target_id];I.connect(b.origin_slot,this,T.outerInputIndex),T.innerNode.connect(0,x,b.target_slot),h[m=b.origin_id]||(h[m]={}),h[b.origin_id][b.origin_slot]=T}for(const[b,y,k]of f){let T=null;if(d[b.target_id]&&(T=d[b.target_id][b.target_slot]),!T&&(T=this.addGraphOutput(k,b.type,[o-r+200,g]),g+=T.innerNode.size[1]+w.NODE_SLOT_HEIGHT,!T))continue;const I=u[b.origin_id],x=u[b.target_id];I.connect(b.origin_slot,T.innerNode,0),this.connect(T.outerOutputIndex,x,b.target_slot),d[_=b.target_id]||(d[_]={}),d[b.target_id][b.origin_slot]=T}for(const[b,y]of Object.values(i)){const k=u[b.origin_id],T=u[b.target_id];k.connect(b.origin_slot,T,b.target_slot)}}addGraphInput(n,e,t){n=this.getValidGraphInputName(n);const i=w.createNode(qi);if(i==null)return null;let s=e;e===$.EVENT?s=$.ACTION:e===$.ACTION&&(e=$.EVENT),i.setProperty("name",n),i.setProperty("type",e),i.properties.subgraphID=this.id,this.subgraph.add(i);const r=i.computeSize();t&&(i.pos=[t[0]-r[0]*.5,t[1]-r[1]*.5]),this.subgraph.addInput(n,s,null);const o=this.inputs.length-1,l=this.inputs[o];return{innerNode:i,outerInput:l,outerInputIndex:o}}addGraphOutput(n,e,t){n=this.getValidGraphOutputName(n);const i=w.createNode(pn);if(i==null)return null;let s=e;e===$.EVENT?e=$.ACTION:e===$.ACTION&&(s=$.EVENT),i.setProperty("name",n),i.setProperty("type",e),i.properties.subgraphID=this.id,this.subgraph.add(i);const r=i.computeSize();t&&(i.pos=[t[0],t[1]-r[1]*.5]),this.subgraph.addOutput(n,s,null);const o=this.outputs.length-1,l=this.outputs[o];return{innerNode:i,outerOutput:l,outerOutputIndex:o}}removeGraphInput(n){if(this.findInputSlotIndexByName(n)==null)return;const t=this.subgraph.findNodesByClass(qi).filter(i=>i.properties.name===n);if(t.length>0)for(const i of t)this.subgraph.remove(i);else{const i=this.findInputSlotIndexByName(n);i!==-1&&this.removeInput(i)}}removeGraphOutput(n){if(this.findOutputSlotIndexByName(n)==null)return;const t=this.subgraph.findNodesByClass(pn).filter(i=>i.properties.name===n);if(t.length>0)for(const i of t)this.subgraph.remove(i);else{const i=this.findOutputSlotIndexByName(n);i!==-1&&this.removeOutput(i)}}getValidGraphInputName(n){n||(n="newInput");let e=n,t=this.getInnerGraphInput(e),i=1;for(;t!=null;)e=`${n}_${i++}`,t=this.getInnerGraphInput(e);return e}getValidGraphOutputName(n){n||(n="newOutput");let e=n,t=this.getInnerGraphOutput(e),i=1;for(;t!=null;)e=`${n}_${i++}`,t=this.getInnerGraphOutput(e);return e}getInnerGraphOutput(n){return this.subgraph._nodes.find(t=>t.is(pn)&&t.properties.name===n)||null}getInnerGraphInput(n){return this.subgraph._nodes.find(t=>t.is(qi)&&t.properties.name===n)||null}getInnerGraphOutputByIndex(n){const e=this.getOutputInfo(n);return e?this.getInnerGraphOutput(e.name):null}getInnerGraphInputByIndex(n){const e=this.getInputInfo(n);return e?this.getInnerGraphInput(e.name):null}moveNodesToParentGraph(n){if(n=n.filter(p=>!p.is(qi)&&!p.is(pn)),n.length===0)return;const e=this,t=e.graph;let i=Number.MAX_SAFE_INTEGER,s=0,r=Number.MAX_SAFE_INTEGER,o=0;for(const p of Object.values(n))i=Math.min(p.pos[0],i),s=Math.max(p.pos[0]+p.size[0],s),r=Math.min(p.pos[1],r),o=Math.max(p.pos[1]+p.size[1],o);const l=s-i,a=o-r,u=e.pos[0]+e.size[0]/2-l/2,c=e.pos[1]+e.size[1]/2-a/2,f={},h={};for(const[p,g]of n.entries())h[g.id]=g;for(const p of n)for(const g of p.iterateAllLinks()){const m=g.target_id===p.id,_=p.getConnectionPos(m,m?g.target_slot:g.origin_slot);h[g.origin_id]!=null&&h[g.target_id]!=null&&(f[g.id]=[g,_])}const d={};for(const[p,g]of n.entries()){const m=[g.pos[0]-i+u,g.pos[1]-r+c],_=g.id;g.graph.remove(g,{removedBy:"moveOutOfSubgraph"}),t.add(g,{addedBy:"moveOutOfSubgraph",prevNodeID:_}),g.pos=m,d[_]=g}for(const[p,g]of Object.values(f)){const m=h[p.origin_id],_=h[p.target_id];m.connect(p.origin_slot,_,p.target_slot)}return d}convertNodesToSubgraphInputs(n){var l;if(n=n.filter(a=>!a.is(qi)&&!a.is(pn)),n.length===0)return;const e=Mu(n,a=>a.id),t=[],i={},s=this.subgraph;for(const a of n)for(const u of a.iterateAllLinks()){if(e[u.origin_id]==null)throw new Error("Can't convert to input with an origin link outward");if(e[u.target_id]==null){t.push(u);const c=[0,0];a.getConnectionPos(!1,u.target_slot,c),i[a.id]=[[a.pos[0],a.pos[1]],c]}}const r=this.moveNodesToParentGraph(n),o={};for(const a of t){const u=s.getNodeById(a.target_id),c=u.getInputInfo(a.target_slot);o[l=a.origin_id]||(o[l]={});let f=o[a.origin_id][a.origin_slot];if(f==null){const d=this.getValidGraphInputName(c.name);f=this.addGraphInput(d,c.type),o[a.origin_id][a.origin_slot]=f;const[p,g]=i[a.origin_id];f.innerNode.pos;const m=f.innerNode.computeSize(),_=f.innerNode.getConnectionPos(!0,0),b=[f.innerNode.pos[0]-_[0],f.innerNode.pos[1]-_[1]],y=[g[0]+b[0]-m[0],g[1]+b[1]];f.innerNode.pos=y}r[a.origin_id].connect(a.origin_slot,this,f.outerInputIndex),f.innerNode.connect(0,u,a.target_slot)}}convertNodesToSubgraphOutputs(n){var l;if(n=n.filter(a=>!a.is(qi)&&!a.is(pn)),n.length===0)return;const e=Mu(n,a=>a.id),t=[],i={},s=this.subgraph;for(const a of n)for(const u of a.iterateAllLinks())if(e[u.origin_id]==null){t.push(u);const c=[0,0];a.getConnectionPos(!0,u.origin_slot,c),i[a.id]=[[a.pos[0],a.pos[1]],c]}else if(e[u.target_id]==null)throw new Error("Can't convert to input with an origin link outward");const r=this.moveNodesToParentGraph(n),o={};for(const a of t){const u=s.getNodeById(a.origin_id),c=u.getOutputInfo(a.origin_slot);o[l=a.target_id]||(o[l]={});let f=o[a.target_id][a.target_slot];if(f==null){f=this.addGraphOutput(name,c.type),o[a.target_id][a.target_slot]=f;const[d,p]=i[a.target_id],g=f.innerNode.getConnectionPos(!0,0),m=[f.innerNode.pos[0]-g[0],f.innerNode.pos[1]-g[1]],_=[p[0]+m[0],p[1]+m[1]];f.innerNode.pos=_}const h=r[a.target_id];u.connect(a.origin_slot,f.innerNode,0),this.connect(f.outerOutputIndex,h,a.target_slot)}}};let an=Uy;an.default_lgraph_factory=()=>new cp;an.slotLayout={inputs:[],outputs:[]};an.propertyLayout=[{name:"enabled",defaultValue:!0}];an.optionalSlots={outputs:[{name:"enabled",type:"boolean"}]};w.registerNodeType({class:an,title:"Subgraph",desc:"Graph inside a node",title_color:"#334",type:"graph/subgraph"});class Ve{static onMenuCollapseAll(){}static onMenuNodeEdit(){}prompt(e="",t,i,s,r=!1,o=null){var l=this,a=document.createElement("div");if(a.is_modified=!1,a.className="graphdialog rounded",r){let T=5;typeof t!="string"&&(t=JSON.stringify(t,null,2));const I=(t.match(/\n/g)||"").length+1;T=Uo(I,5,10),a.innerHTML=` - - - -`}else a.innerHTML=` - - -`;a.close=function(){l.prompt_box=null,a.parentNode&&a.parentNode.removeChild(a)};var u=re.active_canvas,c=u.canvas;c.parentNode.appendChild(a),this.ds.scale>1&&(a.style.transform="scale("+this.ds.scale+")");var f=null,h=0;w.pointerListenerAdd(a,"leave",function(T){h||w.dialog_close_on_mouse_leave&&!a.is_modified&&w.dialog_close_on_mouse_leave&&T.buttons===0&&(f=setTimeout(a.close,w.dialog_close_on_mouse_leave_delay))}),w.pointerListenerAdd(a,"enter",function(T){w.dialog_close_on_mouse_leave&&f&&clearTimeout(f)});var d=a.querySelectorAll("select");d&&d.forEach(function(T){T.addEventListener("click",function(I){h++}),T.addEventListener("blur",function(I){h=0}),T.addEventListener("change",function(I){h=-1})}),l.prompt_box&&l.prompt_box.close(),l.prompt_box=a;var p=a.querySelector(".name");p.innerText=e;let g=a.querySelector(".value");g.value=t;var m=g;if(m.addEventListener("keydown",function(T){if(a.is_modified=!0,T.keyCode==27)a.close();else if(T.keyCode==13&&T.target instanceof Element&&T.target.localName!="textarea")i&&i(this.value),a.close();else return;T.preventDefault(),T.stopPropagation()}),o)for(const[T,I]of Object.entries(o))m.style[T]=I;var _=a.querySelector("button");_.addEventListener("click",function(T){i&&i(m.value),l.setDirty(!0),a.close()});var b=c.getBoundingClientRect(),y=-20,k=-20;return b&&(y-=b.left,k-=b.top),s?(a.style.left=s.clientX+"px",a.style.top=s.clientY+"px"):(a.style.left=c.width*.5+y+"px",a.style.top=c.height*.5+k+"px"),setTimeout(function(){m.focus()},10),Lh(a),a}showSearchBox(e,t={}){var i={slotFrom:null,node_from:null,node_to:null,do_type_filter:w.search_filter_enabled,type_filter_in:null,type_filter_out:null,show_general_if_none_on_typefilter:!0,show_general_after_typefiltered:!0,hide_on_mouse_leave:w.search_hide_on_mouse_leave,show_all_if_empty:!0,show_all_on_open:w.search_show_all_on_open};t=Object.assign(i,t);var s=this,r=re.active_canvas,o=r.canvas,l=o.ownerDocument||document;let a=e;var u=document.createElement("div");u.className="litegraph litesearchbox graphdialog rounded",u.innerHTML="Search ",t.do_type_filter&&(u.innerHTML+="",u.innerHTML+=""),u.innerHTML+="
",l.fullscreenElement?l.fullscreenElement.appendChild(u):(l.body.appendChild(u),l.body.style.overflow="hidden");let c=null,f=null;if(t.do_type_filter&&(c=u.querySelector(".slot_in_type_filter"),f=u.querySelector(".slot_out_type_filter")),u.close=function(){s.search_box=null,this.blur(),o.focus(),l.body.style.overflow="",setTimeout(function(){s.canvas.focus()},20),u.parentNode&&u.parentNode.removeChild(u)},this.ds.scale>1&&(u.style.transform="scale("+this.ds.scale+")"),t.hide_on_mouse_leave){var h=0,d=null;w.pointerListenerAdd(u,"enter",function(V){d&&(clearTimeout(d),d=null)}),w.pointerListenerAdd(u,"leave",function(V){h||(d=setTimeout(function(){u.close()},500))}),t.do_type_filter&&(c.addEventListener("click",function(V){h++}),c.addEventListener("blur",function(V){h=0}),c.addEventListener("change",function(V){h=-1}),f.addEventListener("click",function(V){h++}),f.addEventListener("blur",function(V){h=0}),f.addEventListener("change",function(V){h=-1}))}s.search_box&&s.search_box.close(),s.search_box=u;var p=u.querySelector(".helper"),g=null,m=null,_=null;const b=V=>{if(V)if(s.onSearchBoxSelection)s.onSearchBoxSelection(V,a,r);else{var X=w.searchbox_extras[V.toLowerCase()];X&&(V=X.type),r.graph.beforeChange();var q=w.createNode(V);if(q&&(q.pos=r.convertEventToCanvasOffset(a),r.graph.add(q)),X&&X.data){if(X.data.properties)for(var K in X.data.properties)q.addProperty(""+K,X.data.properties[K]);if(X.data.inputs){q.inputs=[];for(var K in X.data.inputs)q.addInput(X.data.inputs[K][0],X.data.inputs[K][1])}if(X.data.outputs){q.outputs=[];for(var K in X.data.outputs)q.addOutput(X.data.outputs[K][0],X.data.outputs[K][1])}X.data.title&&(q.title=X.data.title),X.data.json&&q.configure(X.data.json)}if(t.node_from){var Q=null;switch(typeof t.slotFrom){case"string":Q=t.node_from.findOutputSlotIndexByName(t.slotFrom);break;case"object":t.slotFrom.name?Q=t.node_from.findOutputSlotIndexByName(t.slotFrom.name):Q=-1,Q==-1&&typeof t.slotFrom.slot_index<"u"&&(Q=t.slotFrom.slot_index);break;case"number":Q=t.slotFrom;break;default:Q=0}Q=Q,typeof t.node_from.outputs[Q]!==void 0&&Q!==null&&Q>-1&&t.node_from.connectByTypeInput(Q,q,t.node_from.outputs[Q].type)}if(t.node_to){var Q=null;switch(typeof t.slotFrom){case"string":Q=t.node_to.findInputSlotIndexByName(t.slotFrom);break;case"number":Q=t.slotFrom;break;default:Q=0}typeof t.node_to.inputs[Q]!==void 0&&Q!==null&&Q>-1&&t.node_to.connectByTypeOutput(Q,q,t.node_to.inputs[Q].type)}r.graph.afterChange()}u.close()},y=V=>{var X=_;_&&_.classList.remove("selected"),_?(_=V?_.nextSibling:_.previousSibling,_||(_=X)):_=V?p.childNodes[0]:p.childNodes[p.childNodes.length],_&&(_.classList.add("selected"),_.scrollIntoView({block:"end",behavior:"smooth"}))},k=(V,X,q,K,Q,J={})=>{const pe=Object.assign({skipFilter:!1,inTypeOverride:null,outTypeOverride:null},J),qe=w.registered_node_types[V];if(qe.hide_in_node_lists||X&&qe.filter!=X||(!t.show_all_if_empty||q)&&V.toLowerCase().indexOf(q)===-1)return!1;if(t.do_type_filter&&!pe.skipFilter){const ue=V;let te=K==null?void 0:K.value;if(pe.inTypeOverride!=null&&(te=pe.inTypeOverride),K&&te&&w.registered_slot_in_types[te]&&w.registered_slot_in_types[te].nodes){var Ae=w.registered_slot_in_types[te].nodes.includes(ue);if(Ae===!1)return!1}if(te=Q==null?void 0:Q.value,pe.outTypeOverride!=null&&(te=pe.outTypeOverride),Q&&te&&w.registered_slot_out_types[te]&&w.registered_slot_out_types[te].nodes){var Ae=w.registered_slot_out_types[te].nodes.includes(ue);if(Ae===!1)return!1}}return!0},T=()=>{m=null;var V=I.value;if(g=null,p.innerHTML="",!V&&!t.show_all_if_empty)return;if(s.onSearchBox){var X=s.onSearchBox(p,V,r);if(X)for(var q=0;qre.search_limit))break}}var pe=null;if(Array.prototype.filter)var qe=Object.keys(w.registered_node_types),pe=qe.filter(ge=>k(ge,Q,V,ue,te));else{pe=[];for(const be in w.registered_node_types)k(be,Q,V,ue,te)&&pe.push(be)}for(var q=0;qre.search_limit));q++);if(t.show_general_after_typefiltered&&(ue!=null&&ue.value||te!=null&&te.value)){let be=[];for(const ge in w.registered_node_types)k(ge,Q,V,ue,te,{inTypeOverride:ue&&ue.value?"*":null,outTypeOverride:te&&te.value?"*":null})&&be.push(ge);for(let ge=0;gere.search_limit));ge++);}if((ue!=null&&ue.value||te!=null&&te.value)&&(p==null?void 0:p.childNodes.length)==0&&t.show_general_if_none_on_typefilter){let be=[];for(const ge in w.registered_node_types)k(ge,Q,V,ue,te,{skipFilter:!0})&&be.push(ge);for(let ge=0;gere.search_limit));ge++);}}function Ae(ue,te){var be=document.createElement("div");g||(g=ue),be.innerText=ue,be.dataset.type=escape(ue),be.className="litegraph lite-search-item",te&&(be.className+=" "+te),be.addEventListener("click",function(ge){b(unescape(this.dataset.type))}),p.appendChild(be)}};var I=u.querySelector("input");if(I&&(I.addEventListener("blur",function(V){this.focus()}),I.addEventListener("keydown",function(V){if(V.keyCode==38)y(!1);else if(V.keyCode==40)y(!0);else if(V.keyCode==27)u.close();else if(V.keyCode==13)_?b(_.innerHTML):g?b(g):u.close();else{m&&clearInterval(m),m=setTimeout(T,w.search_box_refresh_interval_ms);return}return V.preventDefault(),V.stopPropagation(),V.stopImmediatePropagation(),!0})),t.do_type_filter){if(c){var x=w.slot_types_in,R=x.length;(t.type_filter_in==$.EVENT||t.type_filter_in==$.ACTION)&&(t.type_filter_in="_event_");for(var N=0;ND.height-200&&(p.style.maxHeight=D.height-a.layerY-20+"px"),I.focus(),t.show_all_on_open&&T(),u}showShowNodePanel(e){this.closePanels();var t=this.getCanvasWindow(),i=this,s=this.createPanel(e.title||"",{closable:!0,window:t,onOpen:function(){},onClose:function(){i.node_panel=null}});i.node_panel=s,s.id="node-panel",s.node=e,s.classList.add("settings");function r(){s.content.innerHTML="",s.addHTML(""+e.type+""+(e.constructor.desc||"")+""),s.addHTML("

Properties

");var o=function(f,h){switch(i.graph.beforeChange(e),f){case"Title":e.title=h;break;case"Mode":var d=Object.values(Vr).indexOf(h);d>=ft.ALWAYS&&Vr[d]&&e.changeMode(d);break;case"Color":re.node_colors[h]&&(e.color=re.node_colors[h].color,e.bgcolor=re.node_colors[h].bgcolor);break;default:e.setProperty(f,h);break}i.graph.afterChange(),i.dirty_canvas=!0};s.addWidget("string","Title",e.title,{},o),s.addWidget("combo","Mode",Vr[e.mode],{values:Vr},o);var l="";e.color!==void 0&&(l=Object.keys(re.node_colors).filter(function(f){return re.node_colors[f].color==e.color})[0]),s.addWidget("combo","Color",l,{values:Object.keys(re.node_colors)},o);for(var a in e.properties){var u=e.properties[a],c=e.getPropertyInfo(a);c.type,!(e.onAddPropertyToPanel&&e.onAddPropertyToPanel(a,s))&&s.addWidget(c.widget||c.type,a,u,c,o)}s.addSeparator(),e.onShowCustomPanelInfo&&e.onShowCustomPanelInfo(s),s.footer.innerHTML="",s.addButton("Delete",function(){e.block_delete||(e.graph.remove(e),s.close())}).classList.add("delete")}s.inner_showCodePad=function(o){s.classList.remove("settings"),s.classList.add("centered"),s.alt_content.innerHTML="";var l=s.alt_content.querySelector("textarea"),a=function(){s.toggleAltContent(!1),s.toggleFooterVisibility(!0),l.parentNode.removeChild(l),s.classList.add("settings"),s.classList.remove("centered"),r()};l.value=e.properties[o],l.addEventListener("keydown",function(f){f.code=="Enter"&&f.ctrlKey&&(e.setProperty(o,l.value),a())}),s.toggleAltContent(!0),s.toggleFooterVisibility(!1),l.style.height="calc(100% - 40px)";var u=s.addButton("Assign",function(){e.setProperty(o,l.value),a()});s.alt_content.appendChild(u);var c=s.addButton("Close",a);c.style.float="right",s.alt_content.appendChild(c)},r(),this.canvas.parentNode.appendChild(s)}showSubgraphPropertiesDialog(e){var t=this.canvas.parentNode.querySelector(".subgraph_dialog");t&&t.close();var i=this.createPanel("Subgraph Inputs",{closable:!0,width:500});i.node=e,i.classList.add("subgraph_dialog");const s=e;var r=s.subgraph;if(!r)return;function o(){if(i.clear(),e.inputs)for(var g=0;g✕ - - - - -`,b=i.addHTML(_,"subgraph_property");b.dataset.name=m.name,b.dataset.slot=""+g,b.querySelector(".name").innerText=m.name,b.querySelector(".type").innerText=sn(m.type),b.querySelector(".delete").addEventListener("click",function(T){const I=this.parentNode.dataset.name;s.removeGraphInput(I),o()});const y=b.querySelector(".move_up");y.disabled=g<=0,y.addEventListener("click",function(T){const I=+this.parentNode.dataset.slot;I<0||(s.moveInput(I,I-1),o())});const k=b.querySelector(".move_down");k.disabled=g>=e.inputs.length-1,k.addEventListener("click",function(T){const I=+this.parentNode.dataset.slot;I>e.inputs.length-1||(s.moveInput(I,I+1),o())})}}var l=` -+ -Name - -Type - -`,a=i.addHTML(l,"subgraph_property extra",!0);const u=a.querySelector(".name"),c=a.querySelector(".type"),f=a.querySelector("button");for(const g of Wy()){var h=document.createElement("option");h.value=g,h.innerHTML=sn(g),c.appendChild(h),g==="*"&&(h.selected=!0)}const d=()=>{const g=u.value;let m=c.value;m==="-1"?m=$.ACTION:m==="-2"&&(m=$.EVENT),!(!g||e.findInputSlotIndexByName(g)!=-1)&&(this.addGraphInputNode(e,g,m),u.value="",c.value="",o(),u.focus())},p=g=>{g.keyCode==13?(d(),g.preventDefault()):g.keyCode==27&&(i.close(),g.preventDefault())};return f.addEventListener("click",d),u.addEventListener("keydown",p),c.addEventListener("keydown",p),o(),this.canvas.parentNode.appendChild(i),u.focus(),i}showSubgraphPropertiesDialogRight(e){var t=this.canvas.parentNode.querySelector(".subgraph_dialog");t&&t.close();var i=this.createPanel("Subgraph Outputs",{closable:!0,width:500});i.node=e,i.classList.add("subgraph_dialog");const s=e;if(!s.subgraph)return;function o(){if(i.clear(),e.outputs)for(var g=0;g✕ - - - - -`,b=i.addHTML(_,"subgraph_property");b.dataset.name=m.name,b.dataset.slot=""+g,b.querySelector(".name").innerText=m.name,b.querySelector(".type").innerText=sn(m.type),b.querySelector("button").addEventListener("click",function(T){const I=this.parentNode.dataset.name;s.removeGraphOutput(I),o()});const y=b.querySelector(".move_up");y.disabled=g<=0,y.addEventListener("click",function(T){const I=+this.parentNode.dataset.slot;I<0||(s.moveOutput(I,I-1),o())});const k=b.querySelector(".move_down");k.disabled=g>=e.outputs.length-1,k.addEventListener("click",function(T){const I=+this.parentNode.dataset.slot;I>e.outputs.length-1||(s.moveOutput(I,I+1),o())})}}var l=` -+ -Name - -Type - -`,a=i.addHTML(l,"subgraph_property extra",!0);const u=a.querySelector(".name"),c=a.querySelector(".type"),f=a.querySelector("button");for(const g of Vy()){var h=document.createElement("option");h.value=g,h.innerHTML=sn(g),c.appendChild(h),g==="*"&&(h.selected=!0)}const d=()=>{const g=u.value;let m=c.value;m==="-1"?m=$.ACTION:m==="-2"&&(m=$.EVENT),!(!g||e.findOutputSlotIndexByName(g)!=-1)&&(this.addGraphOutputNode(e,g,m),u.value="",c.value="",o(),u.focus())},p=g=>{g.keyCode==13?(d(),g.preventDefault()):g.keyCode==27&&(i.close(),g.preventDefault())};return f.addEventListener("click",d),u.addEventListener("keydown",p),c.addEventListener("keydown",p),o(),this.canvas.parentNode.appendChild(i),u.focus(),i}showConnectionMenu(e={}){var t=e.nodeFrom&&e.slotFrom,i=!t&&e.nodeTo&&e.slotTo;if(!t&&!i)return!1;var s=t?e.nodeFrom:e.nodeTo;const r=t?e.slotFrom:e.slotTo;let o;var l=null;switch(typeof r){case"string":l=t?s.findOutputSlotIndexByName(r):s.findInputSlotIndexByName(r),o=t?s.outputs[r]:s.inputs[r];break;case"object":o=r,l=t?s.findOutputSlotIndexByName(o.name):s.findInputSlotIndexByName(o.name);break;case"number":l=r,o=t?s.outputs[l]:s.inputs[l];break;default:return!1}var a=[{content:"Add Node"},Gi.SEPARATOR];s.graph._is_subgraph&&(t?a.push({content:"Add Subgraph Output"}):a.push({content:"Add Subgraph Input"}),a.push(Gi.SEPARATOR)),this.allow_searchbox&&(a.push({content:"Search"}),a.push(Gi.SEPARATOR));var u=o.type==$.EVENT?"_event_":o.type,c=t?w.slot_types_default_out:w.slot_types_default_in;const f=c[u];if(c&&c[u])if(Array.isArray(f))for(var h of f){const b=typeof h=="string"?h:(h==null?void 0:h.title)||(h==null?void 0:h.node);a.push({content:b,value:h})}else throw new Error(`Invalid default slot specifier, must be an array: ${f}`);const d=b=>{const y=s.graph._subgraph_node,k=[b.canvasX,b.canvasY];y.addGraphInput(o.name,o.type,k).innerNode.connect(0,s,l)},p=b=>{const y=s.graph._subgraph_node,k=[b.canvasX,b.canvasY],T=y.addGraphOutput(o.name,o.type,k);s.connect(l,T.innerNode,0)},g=b=>{const y=Object.assign(e,{position:[e.e.canvasX,e.e.canvasY]});this.createDefaultNodeForSlot(b,y)},m=(b,y,k)=>{switch(b.content){case"Add Node":re.onMenuAdd(b,y,k,_,function(T){t?e.nodeFrom.connectByTypeInput(l,T,u):e.nodeTo.connectByTypeOutput(l,T,u)});break;case"Add Subgraph Input":d(this.adjustMouseEvent(k));break;case"Add Subgraph Output":p(this.adjustMouseEvent(k));break;case"Search":t?this.showSearchBox(k,{node_from:e.nodeFrom,slotFrom:o,type_filter_in:u}):this.showSearchBox(k,{node_to:e.nodeTo,slotFrom:o,type_filter_out:u});break;default:g(b.value);break}};var _=new wi(a,{event:e.e,title:(o&&o.name!=""?o.name+(u?" | ":""):"")+(o&&u?u:""),callback:m});return!1}getLinkMenuOptions(e){const t=this.graph.getNodeById(e.origin_id),i=this.graph.getNodeById(e.target_id);let s=null;t&&t.outputs&&t.outputs[e.origin_slot]&&(s=t.outputs[e.origin_slot].type);let r=null;i&&i.outputs&&i.outputs[e.target_slot]&&(r=i.inputs[e.target_slot].type);const o=c=>{!c.inputs||!c.inputs.length||!c.outputs||!c.outputs.length||t.connectByTypeInput(e.origin_slot,c,s)&&(c.connectByTypeInput(e.target_slot,i,r),c.pos[0]-=c.size[0]*.5)},l=(c,f,h,d,p)=>{re.onMenuAdd(c,f,h,d,o)},a=()=>{this.graph.removeLink(e.id)};let u=[{content:"Add Node",has_submenu:!0,callback:l},Gi.SEPARATOR,{content:"Delete",has_submenu:!0,callback:a},Gi.SEPARATOR];return this.graph.onGetLinkMenuOptions&&(u=this.graph.onGetLinkMenuOptions(u,e)),t.getExtraLinkOptions&&(u=t.getExtraLinkOptions(this,e,mt.OUTPUT,u)),i.getExtraLinkOptions&&(u=i.getExtraLinkOptions(this,e,mt.INPUT,u)),u}showLinkMenu(e,t){const i=this.getLinkMenuOptions(e);return new wi(i,{event:t,title:e.data!=null?e.data.constructor.name:null,extra:e}),!1}showEditPropertyValue(e,t,i={}){if(!e||e.properties[t]===void 0||w.ignore_all_widget_events)return;var s=e.getPropertyInfo(t),r=s.type,o="";if(r=="string"||r=="number"||r=="array"||r=="object")if(s.multiline){let g=e.properties[t],m=5;if(r!=="string"){g=JSON.stringify(g,null,2);const _=(g.match(/\n/g)||"").length+1;m=Uo(_,5,10)}o=""}else o="";else if((r=="enum"||r=="combo")&&s.values){o=""}else if(r=="boolean"||r=="toggle")o="";else return;var u=this.createDialog(""+(s.label?s.label:t)+""+o+"",i),c=null;if((r=="enum"||r=="combo")&&s.values)c=u.querySelector("select"),c.addEventListener("change",function(g){u.modified(),d(g.target.value)});else if(r=="boolean"||r=="toggle")c=u.querySelector("input"),c&&c.addEventListener("click",function(g){u.modified(),d(!!c.checked)});else if(s.multiline?c=u.querySelector("textarea"):c=u.querySelector("input"),c){c.addEventListener("blur",function(m){this.focus()});let g=e.properties[t]!==void 0?e.properties[t]:"";if(r!=="string"){let m=null;s.multiline&&(m=2),g=JSON.stringify(g,null,m)}if(c.value=g,c.addEventListener("keydown",function(m){let _=!1;m.keyCode==27?(u.close(),_=!0):m.keyCode==13&&!s.multiline?(h(),_=!0):m.keyCode!=13&&u.modified(),_&&(m.preventDefault(),m.stopPropagation())}),s.inputStyle)for(const[m,_]of Object.entries(s.inputStyle))c.style[m]=_}c&&c.focus();const f=()=>{i.onclose&&i.onclose(),u.close(),e.setDirtyCanvas(!0,!0)},h=()=>{r!="boolean"&&r!="toggle"?d(c.value):f()},d=g=>{s&&s.values&&s.values.constructor===Object&&s.values[g]!=null&&(g=s.values[g]),typeof e.properties[t]=="number"&&(g=Number(g)),(r=="array"||r=="object")&&(g=JSON.parse(g)),e.setProperty(t,g),f()};var p=u.querySelector("button");return p.addEventListener("click",h),Lh(u),u}createDialog(e,t={checkForInput:!1,closeOnLeave:!0,closeOnLeave_checkModified:!0}){var i=document.createElement("div");i.className="graphdialog",i.innerHTML=e,i.is_modified=!1;var s=this.canvas.getBoundingClientRect(),r=-20,o=-20;if(s&&(r-=s.left,o-=s.top),t.position?(r=t.position[0],o=t.position[1]):t.event?(r=t.event.clientX,o=t.event.clientY):(r+=this.canvas.width*.5,o+=this.canvas.height*.5),i.style.left=r+"px",i.style.top=o+"px",this.canvas.parentNode.appendChild(i),t.checkForInput){var l=i.querySelectorAll("input"),a=!1;l&&l.forEach(function(h){h.addEventListener("keydown",function(d){if(i.modified(),d.keyCode==27)i.close();else if(d.keyCode!=13)return;d.preventDefault(),d.stopPropagation()}),a||h.focus()})}i.modified=function(){i.is_modified=!0},i.close=function(){i.parentNode&&i.parentNode.removeChild(i)};var u=null,c=0;i.addEventListener("mouseleave",function(h){c||(t.closeOnLeave||w.dialog_close_on_mouse_leave)&&!i.is_modified&&w.dialog_close_on_mouse_leave&&h.buttons===0&&(u=setTimeout(i.close,w.dialog_close_on_mouse_leave_delay))}),i.addEventListener("mouseenter",function(h){(t.closeOnLeave||w.dialog_close_on_mouse_leave)&&u&&clearTimeout(u)});var f=i.querySelectorAll("select");return f&&f.forEach(function(h){h.addEventListener("click",function(d){c++}),h.addEventListener("blur",function(d){c=0}),h.addEventListener("change",function(d){c=-1})}),i}getCanvasMenuOptions(){var e=null;if(this.getMenuOptions?e=this.getMenuOptions(this):(e=[{content:"Add Node",has_submenu:!0,callback:re.onMenuAdd},{content:"Add Group",callback:re.onGroupAdd}],this._graph_stack&&this._graph_stack.length>0&&e.push(Gi.SEPARATOR,{content:"Close subgraph",callback:this.closeSubgraph.bind(this)})),this.getExtraMenuOptions){var t=this.getExtraMenuOptions(this,e);t&&(e=e.concat(t))}return e}getNodeMenuOptions(e){let t=[];e.getMenuOptions?t=e.getMenuOptions(this):(t=[{content:"Inputs",has_submenu:!0,disabled:!0,callback:re.showMenuNodeOptionalInputs},{content:"Outputs",has_submenu:!0,disabled:!0,callback:re.showMenuNodeOptionalOutputs},Gi.SEPARATOR,{content:"Properties",has_submenu:!0,disabled:w.ignore_all_widget_events,callback:re.onShowMenuNodeProperties},Gi.SEPARATOR,{content:"Title",value:{name:"title",type:"string"},callback:re.onShowPropertyEditor},{content:"Mode",has_submenu:!0,callback:re.onMenuNodeMode}],e.resizable!==!1&&t.push({content:"Resize",callback:re.onMenuResizeNode}),t.push({content:"Collapse",callback:re.onMenuNodeCollapse},{content:"Pin",callback:re.onMenuNodePin},{content:"Colors",has_submenu:!0,callback:re.onMenuNodeColors},{content:"Shapes",has_submenu:!0,callback:re.onMenuNodeShapes},Gi.SEPARATOR));const i=e.getOptionalSlots();if(i&&(i.inputs&&i.inputs.length>0&&typeof t[0]=="object"&&(t[0].disabled=!1),i.outputs&&i.outputs.length&&typeof t[1]=="object"&&(t[1].disabled=!1)),e.getExtraMenuOptions){var s=e.getExtraMenuOptions(this,t);s&&(s.push(Gi.SEPARATOR),t=s.concat(t))}e.clonable!==!1&&t.push({content:"Clone",callback:re.onMenuNodeClone}),t.push({content:"To Subgraph",callback:re.onMenuNodeToSubgraph});let r=Object.values(this.selected_nodes||{});if(r.length||(r=[e]),r=r.filter(o=>!o.is(qi)&&!o.is(pn)),t.push({content:"To Parent Graph",disabled:!e.graph._is_subgraph||r.length===0,callback:re.onMenuNodeToParentGraph}),e.graph._is_subgraph){const o=c=>{let f=0;const h=Mu(c,d=>d.id);for(const d of c)for(const p of d.iterateAllLinks()){if(h[p.origin_id]==null)return 0;h[p.target_id]==null&&(f+=1)}return f},l=c=>{let f=0;const h=Mu(c,d=>d.id);for(const d of c)for(const p of d.iterateAllLinks())if(h[p.origin_id]==null)f+=1;else if(h[p.target_id]==null)return 0;return f},a=o(r);t.push({content:"To Subgraph Input"+(a>1?"s":""),disabled:a===0,callback:re.onMenuNodeToSubgraphInputs});const u=l(r);t.push({content:"To Subgraph Output"+(u>1?"s":""),disabled:u===0,callback:re.onMenuNodeToSubgraphOutputs})}return t.push(Gi.SEPARATOR,{content:"Remove",disabled:!(e.removable!==!1&&!e.block_delete),callback:re.onMenuNodeRemove}),e.graph&&e.graph.onGetNodeMenuOptions&&(t=e.graph.onGetNodeMenuOptions(t,e)),t}getGroupMenuOptions(e){var t=[{content:"Title",value:{name:"title",type:"string"},callback:re.onShowPropertyEditor},{content:"Color",has_submenu:!0,callback:re.onMenuNodeColors},{content:"Font size",value:{name:"fontSize",type:"number"},callback:re.onShowPropertyEditor},Gi.SEPARATOR,{content:"Remove",callback:re.onMenuNodeRemove}];return t}processContextMenu(e,t){var i=re.active_canvas,s=i.getCanvasWindow();let r=t,o=null,l=null,a=null;e!=null&&(a=e.item,e.type==="node"&&(o=e.item),e.type==="link"&&(l=e.item));let u=null;var c={event:r,extra:a};o!=null&&(c.title=o.type);let f=null;o!=null&&(f=o.getSlotInPosition(r.canvasX,r.canvasY),re.active_node=o);const h=_=>{const b=_.slot;o.graph.beforeChange(),b.input?o.removeInput(b.slot):b.output&&o.removeOutput(b.slot),o.graph.afterChange()},d=_=>{var b=_.slot;o.graph.beforeChange(),b.output?o.disconnectOutput(b.slot):b.input&&o.disconnectInput(b.slot),o.graph.afterChange()},p=_=>{var b=_.slot,y=b.input?o.getInputInfo(b.slot):o.getOutputInfo(b.slot),k=this.createDialog("Name",c),T=k.querySelector("input");T&&y&&(T.value=y.label||"");var I=()=>{o.graph.beforeChange(),T.value&&(y&&(y.label=T.value),this.setDirty(!0)),k.close(),o.graph.afterChange()};k.querySelector("button").addEventListener("click",I),T.addEventListener("keydown",function(x){if(k.is_modified=!0,x.keyCode==27)k.close();else if(x.keyCode==13)I();else if(x.keyCode!=13&&x.target instanceof Element&&x.target.localName!="textarea")return;x.preventDefault(),x.stopPropagation()}),T.focus()};if(f){if(u=[],o.getSlotMenuOptions)u=o.getSlotMenuOptions(f);else{f&&f.output&&f.output.links&&f.output.links.length&&u.push({content:"Disconnect Links",slot:f,callback:d});var g=f.input||f.output;g.removable&&u.push(g.locked?"Cannot remove":{content:"Remove Slot",slot:f,callback:h}),g.nameLocked||u.push({content:"Rename Slot",slot:f,callback:p})}const _=(f.input?f.input.type:f.output.type)||"*";c.title=sn(_)}else if(o)u=this.getNodeMenuOptions(o);else if(l)u=this.getLinkMenuOptions(l);else{u=this.getCanvasMenuOptions();var m=this.graph.getGroupOnPos(r.canvasX,r.canvasY);m&&u.push(Gi.SEPARATOR,{content:"Edit Group",has_submenu:!0,submenu:{title:"Group",extra:m,options:this.getGroupMenuOptions(m)}})}u&&new wi(u,c,s)}createPanel(e,t={}){var i=t.window||window,s=document.createElement("div");if(s.className="litegraph dialog",s.innerHTML=` -
-
- -`,s.header=s.querySelector(".dialog-header"),t.width&&(s.style.width=t.width+(t.width.constructor===Number?"px":"")),t.height&&(s.style.height=t.height+(t.height.constructor===Number?"px":"")),t.closable){var r=document.createElement("span");r.innerHTML="✕",r.classList.add("close"),r.addEventListener("click",function(){s.close()}),s.header.appendChild(r)}return t.onOpen&&(s.onOpen=t.onOpen),t.onClose&&(s.onClose=t.onClose),s.title_element=s.querySelector(".dialog-title"),s.title_element.innerText=e,s.content=s.querySelector(".dialog-content"),s.alt_content=s.querySelector(".dialog-alt-content"),s.footer=s.querySelector(".dialog-footer"),s.close=function(){s.onClose&&typeof s.onClose=="function"&&s.onClose(),s.parentNode&&s.parentNode.removeChild(s),this.parentNode&&this.parentNode.removeChild(this)},s.toggleAltContent=function(o=!1){if(typeof o<"u")var l=o?"block":"none",a=o?"none":"block";else var l=s.alt_content.style.display!="block"?"block":"none",a=s.alt_content.style.display!="block"?"none":"block";s.alt_content.style.display=l,s.content.style.display=a},s.toggleFooterVisibility=function(o=!1){if(typeof o<"u")var l=o?"block":"none";else var l=s.footer.style.display!="block"?"block":"none";s.footer.style.display=l},s.clear=function(){this.content.innerHTML=""},s.addHTML=function(o,l,a){var u=document.createElement("div");return l&&(u.className=l),u.innerHTML=o,a?s.footer.appendChild(u):s.content.appendChild(u),u},s.addButton=function(o,l,a){var u=document.createElement("button");return u.innerText=o,u.options=a,u.classList.add("btn"),u.addEventListener("click",l),s.footer.appendChild(u),u},s.addSeparator=function(){var o=document.createElement("div");return o.className="separator",s.content.appendChild(o),o},s.addWidget=function(o,l,a,u={},c){var f=String(a);o=o.toLowerCase(),o=="number"&&(f=a.toFixed(3));var h=document.createElement("div");h.className="property",h.innerHTML="";let d=h.querySelector(".property_name");d.innerText=u.label||l;var p=h.querySelector(".property_value");if(p.innerText=f,h.dataset.property=l,h.dataset.type=u.type||o,h.options=u,h.value=a,o=="code")h.addEventListener("click",function(m){s.inner_showCodePad(this.dataset.property)});else if(o=="boolean")h.classList.add("boolean"),a&&h.classList.add("bool-on"),h.addEventListener("click",function(){var m=this.dataset.property;this.value=!this.value,this.classList.toggle("bool-on");const _=this.querySelector(".property_value");_.innerText=this.value?"true":"false",g(m,this.value)});else if(o=="string"||o=="number")p.setAttribute("contenteditable","true"),p.addEventListener("keydown",function(m){m.code=="Enter"&&(o!="string"||!m.shiftKey)&&(m.preventDefault(),this.blur())}),p.addEventListener("blur",function(){let m=this.innerText;const _=this.parentNode;var b=_.dataset.property,y=_.dataset.type;y=="number"&&(m=Number(m)),g(b,m)});else if((o=="enum"||o=="combo")&&"values"in u){var f=re.getPropertyPrintableValue(a,u.values);p.innerText=f,p.addEventListener("click",function(_){let b=u.values||[];typeof b=="function"&&(b=[]);var k=this.parentNode.dataset.property,T=this;let I=Array.from(b).map(R=>({content:R}));new wi(I,{event:_,className:"dark",callback:x},i);function x(R,N,O){return T.innerText=R.content,g(k,R.content),!1}})}s.content.appendChild(h);function g(m,_){u.callback&&u.callback(m,_,u),c&&c(m,_,u)}return h},s.onOpen&&typeof s.onOpen=="function"&&s.onOpen(),s}checkPanels(){if(this.canvas)for(var e=this.canvas.parentNode.querySelectorAll(".litegraph.dialog"),t=0;t",a.close=function(){a.parentNode&&a.parentNode.removeChild(a)};var u=a.querySelector(".name");u.innerText=o;var c=a.querySelector(".value");if(c&&(c.value=l,c.addEventListener("blur",function(k){this.focus()}),c.addEventListener("keydown",function(k){if(a.is_modified=!0,k.keyCode==27)a.close();else if(k.keyCode==13)m();else if(k.keyCode!=13&&k.target instanceof Element&&k.target.localName!="textarea")return;k.preventDefault(),k.stopPropagation()}),r.inputStyle))for(const[k,T]of Object.entries(r.inputStyle))c.style[k]=T;var f=re.active_canvas,h=f.canvas,d=h.getBoundingClientRect(),p=-20,g=-20;d&&(p-=d.left,g-=d.top),t?(a.style.left=t.clientX+p+"px",a.style.top=t.clientY+g+"px"):(a.style.left=h.width*.5+p+"px",a.style.top=h.height*.5+g+"px");const m=()=>{c&&_(c.value)},_=k=>{r.type=="number"?k=Number(k):r.type=="boolean"&&(k=!!k);const T=s[o];s[o]=k,s.onJSPropertyChanged&&s.onJSPropertyChanged(o,k,T)===!1&&(s[o]=T),a.parentNode&&a.parentNode.removeChild(a),s.setDirtyCanvas(!0,!0)};var b=a.querySelector("button");b.addEventListener("click",m),h.parentNode.appendChild(a),c&&c.focus();var y=null;a.addEventListener("mouseleave",function(k){w.dialog_close_on_mouse_leave&&!a.is_modified&&w.dialog_close_on_mouse_leave&&k.buttons===0&&(y=setTimeout(a.close,w.dialog_close_on_mouse_leave_delay))}),a.addEventListener("mouseenter",function(k){w.dialog_close_on_mouse_leave&&y&&clearTimeout(y)}),Lh(a)};Ve.onGroupAdd=function(n,e,t,i){var s=re.active_canvas;s.getCanvasWindow();var r=new Ru;r.pos=s.convertEventToCanvasOffset(t),s.graph.addGroup(r)};Ve.onMenuAdd=function(n,e,t,i,s){var r=re.active_canvas,o=r.getCanvasWindow(),l=r.graph;if(!l)return;function a(u,c){var f=w.getNodeTypesCategories(r.filter||l.filter).filter(function(p){return p.startsWith(u)}),h=[];f.map(function(p){if(p){var g=new RegExp("^("+u+")"),m=p.replace(g,"").split("/")[0],_=u===""?m+"/":u+m+"/",b=m;b.indexOf("::")!=-1&&(b=b.split("::")[1]);var y=h.findIndex(function(k){return k.value===_});y===-1&&h.push({value:_,content:b,has_submenu:!0,callback:function(k,T,I,x){a(k.value,x)}})}});var d=w.getNodeTypesInCategory(u.slice(0,-1),r.filter||l.filter);d.map(function(p){if(!p.hide_in_node_lists){var g={value:p.class,content:p.title,has_submenu:!1,callback:function(m,_,b,y){var k=y.getFirstEvent();r.graph.beforeChange();var T=w.createNode(m.value);T&&(T.pos=r.convertEventToCanvasOffset(k),r.graph.add(T)),s&&s(T),r.graph.afterChange()}};h.push(g)}}),new wi(h,{event:t,parentMenu:c},o)}return a("",i),!1};Ve.showMenuNodeOptionalInputs=function(n,e,t,i,s){if(!s)return;var r=this,o=re.active_canvas,l=o.getCanvasWindow();let a=s.getOptionalSlots().inputs,u=[];if(a)for(let d=0;d"+(c.label?c.label:a)+""+u+"",value:a})}if(!l.length)return;new wi(l,{event:t,callback:f,parentMenu:i,allow_html:!0,node:s},o);function f(h,d,p,g){if(s){var m=this.getBoundingClientRect();r.showEditPropertyValue(s,h.value,{position:[m.left,m.top]})}}return!1};Ve.onResizeNode=function(n,e,t,i,s){s&&(s.size=s.computeSize(),s.setDirtyCanvas(!0,!0))};Ve.onMenuNodeCollapse=function(n,e,t,i,s){s.graph.beforeChange();var r=function(a){a.collapse()},o=re.active_canvas;if(!o.selected_nodes||Object.keys(o.selected_nodes).length<=1)r(s);else for(var l in o.selected_nodes)r(o.selected_nodes[l]);s.graph.afterChange()};Ve.onMenuNodePin=function(n,e,t,i,s){s.pin()};Ve.onMenuNodeMode=function(n,e,t,i,s){let r=Array.from(Vr).map(l=>({content:l}));new wi(r,{event:t,callback:o,parentMenu:i,node:s});function o(l){if(s){var a=Object.values(Vr).indexOf(l.content),u=function(h){a>=ft.ALWAYS&&Vr[a]?h.changeMode(a):h.changeMode(ft.ALWAYS)},c=re.active_canvas;if(!c.selected_nodes||Object.keys(c.selected_nodes).length<=1)u(s);else for(var f in c.selected_nodes)u(c.selected_nodes[f])}}return!1};Ve.onMenuNodeColors=function(n,e,t,i,s){if(!s)throw"no node for color";var r=[];r.push({value:null,content:"No color"});for(let a in re.node_colors){var o=re.node_colors[a];let u={value:a,content:""+a+""};r.push(u)}new wi(r,{event:t,callback:l,parentMenu:i,node:s,allow_html:!0});function l(a){if(s){var u=a.value?re.node_colors[a.value]:null,c=function(d){u?d instanceof Ru?d.color=u.groupcolor:(d.color=u.color,d.bgcolor=u.bgcolor):(delete d.color,d instanceof Ke&&delete d.bgcolor)},f=re.active_canvas;if(!f.selected_nodes||Object.keys(f.selected_nodes).length<=1)c(s);else for(var h in f.selected_nodes)c(f.selected_nodes[h]);s.setDirtyCanvas(!0,!0)}}return!1};Ve.onMenuNodeShapes=function(n,e,t,i,s){if(!s)throw"no node passed";const r=Array.from(Ng).map(l=>({content:l}));new wi(r,{event:t,callback:o,parentMenu:i,node:s});function o(l){if(s){s.graph.beforeChange();var a=function(f){f.shape=Ng.indexOf(l.content)},u=re.active_canvas;if(!u.selected_nodes||Object.keys(u.selected_nodes).length<=1)a(s);else for(var c in u.selected_nodes)a(u.selected_nodes[c]);s.graph.afterChange(),s.setDirtyCanvas(!0)}}return!1};Ve.onMenuNodeRemove=function(n,e,t,i,s){if(!s)throw"no node passed";var r=s.graph;r.beforeChange();var o=function(u){u.removable!==!1&&r.remove(u)},l=re.active_canvas;if(!l.selected_nodes||Object.keys(l.selected_nodes).length<=1)o(s);else for(var a in l.selected_nodes)o(l.selected_nodes[a]);r.afterChange(),s.setDirtyCanvas(!0,!0)};Ve.onMenuNodeToSubgraph=function(n,e,t,i,s){var r=s.graph,o=re.active_canvas;if(o){var l=Object.values(o.selected_nodes||{});l.length||(l=[s]);var a=w.createNode("graph/subgraph",null,{constructorArgs:[null]});a.pos=s.pos.concat(),r.add(a),a.buildFromNodes(l),o.deselectAllNodes(),s.setDirtyCanvas(!0,!0)}};Ve.onMenuNodeToSubgraphInputs=function(n,e,t,i,s){var r=re.active_canvas;if(!r)return;const o=s.graph._subgraph_node;if(!s.graph._is_subgraph||!o)return;let l=Object.values(r.selected_nodes||{});l.length||(l=[s]),o.convertNodesToSubgraphInputs(l),r.deselectAllNodes(),s.setDirtyCanvas(!0,!0)};Ve.onMenuNodeToSubgraphOutputs=function(n,e,t,i,s){var r=re.active_canvas;if(!r)return;const o=s.graph._subgraph_node;if(!s.graph._is_subgraph||!o)return;let l=Object.values(r.selected_nodes||{});l.length||(l=[s]),o.convertNodesToSubgraphOutputs(l),r.deselectAllNodes(),s.setDirtyCanvas(!0,!0)};Ve.onMenuNodeToParentGraph=function(n,e,t,i,s){var r=re.active_canvas;if(!r)return;const o=s.graph._subgraph_node;if(!s.graph._is_subgraph||!o)return;let l=Object.values(r.selected_nodes||{});l.length||(l=[s]),o.moveNodesToParentGraph(l),r.deselectAllNodes(),s.setDirtyCanvas(!0,!0)};Ve.onMenuNodeClone=function(n,e,t,i,s){var r=re.active_canvas;(!r.selected_nodes||Object.keys(r.selected_nodes).length<=1)&&r.selectNode(s),r.cloneSelection()};const Al=class{constructor(n,e,t={}){this.link_type_colors={},this.node_panel=null,this.options_panel=null,this.render_time=0,this.allow_dragcanvas=!0,this.allow_dragnodes=!0,this.allow_interaction=!0,this.allow_reconnect_links=!0,this.allow_searchbox=!0,this.always_render_background=!1,this.background_image=Al.DEFAULT_BACKGROUND_IMAGE,this.block_click=!1,this.clear_background=!0,this.connecting_pos=null,this.connecting_slot=null,this.connecting_input=null,this.connecting_output=null,this.connections_width=3,this.current_node=null,this.drag_mode=!1,this.dragging_rectangle=null,this.ds=new bC,this.editor_alpha=1,this.filter=null,this.highquality_render=!0,this.skip_events=!1,this.last_mouse_position=[0,0],this.last_click_position=[0,0],this.last_click_position_offset=[0,0],this.last_mouse_dragging=!1,this.links_render_mode=Ll.SPLINE_LINK,this.live_mode=!1,this.mouse=[0,0],this.offset_mouse=[0,0],this.graph_mouse=[0,0],this.node_widget=null,this.maxZoom=null,this.minZoom=null,this.multi_select=!1,this.over_link_center=null,this.pause_rendering=!1,this.read_only=!1,this.render_canvas_border=!0,this.render_collapsed_slots=!0,this.render_connection_arrows=!1,this.render_connections_border=!0,this.render_connections_shadows=!1,this.render_connections=!0,this.render_curved_connections=!1,this.render_execution_order=!1,this.render_link_tooltip=!0,this.render_only_selected=!0,this.render_shadows=!0,this.render_title_colored=!0,this.render_subgraph_panels=!0,this.render_subgraph_stack_header=!0,this.round_radius=8,this.set_canvas_dirty_on_mouse_event=!0,this.show_info=!0,this.use_gradients=!1,this.visible_links=[],this.zoom_modify_alpha=!0,this.pointer_is_down=!1,this.pointer_is_double=!1,this._highlight_input=null,this._highlight_input_slot=null,this._highlight_output=null,this._graph_stack=[],this._bg_img=null,this._pattern=null,this._pattern_img=null,this.search_box=null,this.prompt_box=null,this._events_binded=!1,this.resizing_node=null,typeof n=="string"&&(n=document.querySelector(n)),this.skip_events=t.skip_events||!1,this.title_text_font=""+w.NODE_TEXT_SIZE+"px Arial",this.inner_text_font="normal "+w.NODE_SUBTEXT_SIZE+"px Arial",this.node_title_color=w.NODE_TITLE_COLOR,this.default_link_color=w.LINK_COLOR,this.link_type_colors=w.cloneObject(Al.DEFAULT_LINK_TYPE_COLORS),this.canvas_mouse=this.graph_mouse,this.visible_area=this.ds.visible_area,this.viewport=t.viewport||null,e&&e.attachCanvas(this),this.setCanvas(n,t.skip_events),this.clear(),t.skip_render||this.startRendering(),this.autoresize=t.autoresize}static getFileExtension(n){var e=n.indexOf("?");e!=-1&&(n=n.substr(0,e));var t=n.lastIndexOf(".");return t==-1?"":n.substr(t+1).toLowerCase()}static decodeHTML(n){var e=document.createElement("div");return e.innerText=n,e.innerHTML}static getPropertyPrintableValue(n,e){if(!e||e.constructor===Array)return String(n);if(e.constructor===Object){var t="";for(var i in e)if(e[i]==n){t=i;break}return String(n)+" ("+t+")"}}get scale(){return this.ds.scale}set scale(n){this.ds.scale=n}clear(){this.frame=0,this.last_draw_time=0,this.render_time=0,this.fps=0,this.dragging_rectangle=null,this.selected_nodes={},this.selected_group=null,this.visible_nodes=[],this.node_dragged=null,this.node_over=null,this.node_capturing_input=null,this.connecting_node=null,this.highlighted_links={},this.dragging_canvas=!1,this.dirty_canvas=!0,this.dirty_bgcanvas=!0,this.dirty_area=null,this.node_in_panel=null,this.node_widget=null,this.last_mouse=[0,0],this.last_mouseclick=0,this.pointer_is_down=!1,this.pointer_is_double=!1,this.onClear&&this.onClear()}setGraph(n,e=!1){if(this.graph!=n){if(e||this.clear(),!n&&this.graph){this.graph.detachCanvas(this);return}n.attachCanvas(this),this._graph_stack&&(this._graph_stack=null),this.setDirty(!0,!0)}}openSubgraph(n){if(!n)throw"graph cannot be null";if(this.graph==n)throw"graph cannot be the same";if(this.clear(),this.graph){this._graph_stack||(this._graph_stack=[]);const t=[this.ds.offset[0],this.ds.offset[1]];this._graph_stack.push({graph:this.graph,offset:t,scale:this.ds.scale})}w.debug,n.attachCanvas(this);const e=[0,0];if(n._nodes.length>0){let t=Number.MAX_SAFE_INTEGER,i=0,s=Number.MAX_SAFE_INTEGER,r=0;for(const o of n.iterateNodesInOrder())t=Math.min(o.pos[0],t),i=Math.max(o.pos[0]+o.size[0],i),s=Math.min(o.pos[1],s),r=Math.max(o.pos[1]+o.size[1],r);e[0]=-(t+(i-t)/2)+this.canvas.width/2,e[1]=-(s+(r-s)/2)+this.canvas.height/2}this.ds.offset=e,this.ds.scale=1,this.checkPanels(),this.setDirty(!0,!0)}closeAllSubgraphs(){for(;this._graph_stack&&this._graph_stack.length>0;)this.closeSubgraph()}closeSubgraph(){if(!(!this._graph_stack||this._graph_stack.length==0)){var n=this.graph._subgraph_node,{graph:e,offset:t,scale:i}=this._graph_stack.pop();this.selected_nodes={},this.highlighted_links={},e.attachCanvas(this),this.setDirty(!0,!0),n&&(this.centerOnNode(n),this.selectNodes([n])),this.ds.offset=t,this.ds.scale=i}}setCanvas(n,e=!1){if(n&&typeof n=="string"&&(n=document.getElementById(n),!n))throw"Error creating LiteGraph canvas: Canvas not found";if(n=n,n!==this.canvas&&(!n&&this.canvas&&(e||this.unbindEvents()),this.canvas=n,this.ds.element=n,!!n)){if(n.className+=" lgraphcanvas",n.data=this,n.tabIndex=1,this.bgcanvas=null,this.bgcanvas||(this.bgcanvas=document.createElement("canvas"),this.bgcanvas.width=this.canvas.width,this.bgcanvas.height=this.canvas.height),n.getContext==null)throw n.localName!="canvas"?"Element supplied for LGraphCanvas must be a element, you passed a "+n.localName:"This browser doesn't support Canvas";e||this.bindEvents(),this.adjustCanvasForHiDPI()}}_doNothing(n){return n.preventDefault(),!1}_doReturnTrue(n){return n.preventDefault(),!0}bindEvents(){if(!this._events_binded){var n=this.canvas,e=this.getCanvasWindow(),t=e.document;this._mousedown_callback=this.processMouseDown.bind(this),this._mousewheel_callback=this.processMouseWheel.bind(this),this._mousemove_callback=this.processMouseMove.bind(this),this._mouseup_callback=this.processMouseUp.bind(this),w.pointerListenerAdd(n,"down",this._mousedown_callback,!0),n.addEventListener("mousewheel",this._mousewheel_callback,!1),w.pointerListenerAdd(n,"up",this._mouseup_callback,!0),w.pointerListenerAdd(n,"move",this._mousemove_callback),n.addEventListener("contextmenu",this._doNothing),n.addEventListener("DOMMouseScroll",this._mousewheel_callback,!1),this._key_callback=this.processKey.bind(this),n.addEventListener("keydown",this._key_callback,!0),t.addEventListener("keyup",this._key_callback,!0),this._ondrop_callback=this.processDrop.bind(this),n.addEventListener("dragover",this._doNothing,!1),n.addEventListener("dragend",this._doNothing,!1),n.addEventListener("drop",this._ondrop_callback,!1),n.addEventListener("dragenter",this._doReturnTrue,!1),this._events_binded=!0}}unbindEvents(){if(this._events_binded){w.debug;var n=this.getCanvasWindow(),e=n.document;w.pointerListenerRemove(this.canvas,"move",this._mousedown_callback),w.pointerListenerRemove(this.canvas,"up",this._mousedown_callback),w.pointerListenerRemove(this.canvas,"down",this._mousedown_callback),this.canvas.removeEventListener("mousewheel",this._mousewheel_callback),this.canvas.removeEventListener("DOMMouseScroll",this._mousewheel_callback),this.canvas.removeEventListener("keydown",this._key_callback),e.removeEventListener("keyup",this._key_callback),this.canvas.removeEventListener("contextmenu",this._doNothing),this.canvas.removeEventListener("drop",this._ondrop_callback),this.canvas.removeEventListener("dragenter",this._doReturnTrue),this._mousedown_callback=null,this._mousewheel_callback=null,this._key_callback=null,this._ondrop_callback=null,this._events_binded=!1}}enableWebGL(){}setDirty(n=!1,e=!1){n&&(this.dirty_canvas=!0),e&&(this.dirty_bgcanvas=!0)}getCanvasWindow(){if(!this.canvas)return window;var n=this.canvas.ownerDocument;return n.defaultView}adjustCanvasForHiDPI(n){if(n||(n=window.devicePixelRatio),n==1||!this.canvas.parentNode)return;const e=this.canvas.parentNode.getBoundingClientRect(),{width:t,height:i}=e;this.canvas.width=t*n,this.canvas.height=i*n,this.canvas.style.width=t+"px",this.canvas.style.height=i+"px",this.canvas.getContext("2d").scale(n,n)}startRendering(){if(this.is_rendering)return;this.is_rendering=!0,n.call(this);function n(){this.pause_rendering||this.draw();var e=this.getCanvasWindow();this.is_rendering&&e.requestAnimationFrame(n.bind(this))}}stopRendering(){this.is_rendering=!1}blockClick(){this.block_click=!0,this.last_mouseclick=0}createDefaultNodeForSlot(n,e={}){var t=this,i=e.nodeFrom&&e.slotFrom!==null,s=!i&&e.nodeTo&&e.slotTo!==null;if(e={...{position:[0,0],posAdd:[0,0],posSizeFix:[0,0]},...e},!i&&!s||!n)return!1;var o=i?e.nodeFrom:e.nodeTo,l=i?e.slotFrom:e.slotTo,a=null;switch(typeof l){case"string":a=i?o.findOutputSlotIndexByName(l):o.findInputSlotIndexByName(l),l=i?o.outputs[l]:o.inputs[l];break;case"object":a=i?o.findOutputSlotIndexByName(l.name):o.findInputSlotIndexByName(l.name);break;case"number":a=l,l=i?o.outputs[l]:o.inputs[l];break;case"undefined":default:return!1}l=l;var u=l.type==$.EVENT?"_event_":l.type,c=i?w.slot_types_default_out:w.slot_types_default_in;const f=c[u];if(c&&f){l.link!==null||l.links&&l.links.length>0;let m=null;if(Array.isArray(f)){for(var h in f)if(n==c[u][h]||n=="AUTO"){m=c[u][h],w.debug;break}}else throw new Error(`Invalid default slot specifier, must be an array: ${f}`);if(m){var d=null;typeof m=="object"&&m.node&&(d=m,m=m.node);var p=w.createNode(m);if(p){if(d){if(d.properties)for(var g in d.properties)p.addProperty(g,d.properties[g]);if(d.inputs){p.inputs=[];for(var g in d.inputs)p.addOutput(d.inputs[g][0],d.inputs[g][1])}if(d.outputs){p.outputs=[];for(var g in d.outputs)p.addOutput(d.outputs[g][0],d.outputs[g][1])}d.title&&(p.title=d.title),d.json&&p.configure(d.json)}const _=e.position[0]+e.posAdd[0]+(e.posSizeFix[0]?e.posSizeFix[0]*p.size[0]:0),b=e.position[1]+e.posAdd[1]+(e.posSizeFix[1]?e.posSizeFix[1]*p.size[1]:0),y=[_,b];return t.graph.add(p,{pos:y}),i?e.nodeFrom.connectByTypeInput(a,p,u):e.nodeTo.connectByTypeOutput(a,p,u),!0}}}return!1}isOverNodeBox(n,e,t){var i=w.NODE_TITLE_HEIGHT;return!!w.isInsideRectangle(e,t,n.pos[0]+2,n.pos[1]+2-i,i-4,i-4)}isOverNodeInput(n,e,t,i){if(n.inputs)for(var s=0,r=n.inputs.length;ss[0]+4||es[1]+4))return i}return null}processKey(n){if(!this.graph)return;var e=!1;if(w.debug,n.target instanceof Element&&n.target.localName=="input")return;const t=this.allow_interaction&&!this.read_only;if(n.type=="keydown"){if(n.keyCode==32&&!(n.metaKey||n.ctrlKey||n.shiftKey)&&(this.dragging_canvas=!0,e=!0),n.keyCode==27&&!(n.metaKey||n.ctrlKey||n.shiftKey)&&(this.node_panel&&this.node_panel.close(),this.options_panel&&this.options_panel.close(),e=!0),t&&(n.keyCode==65&&n.ctrlKey&&(this.selectNodes(),e=!0),n.code=="KeyX"&&(n.metaKey||n.ctrlKey)&&!n.shiftKey&&this.selected_nodes&&(this.cutToClipboard(),e=!0),n.code=="KeyC"&&(n.metaKey||n.ctrlKey)&&!n.shiftKey&&this.selected_nodes&&(this.copyToClipboard(),e=!0),n.code=="KeyV"&&(n.metaKey||n.ctrlKey)&&!n.shiftKey&&this.pasteFromClipboard(),n.code=="KeyD"&&(n.metaKey||n.ctrlKey)&&!n.shiftKey&&(this.cloneSelection(),e=!0),(n.keyCode==46||n.keyCode==8)&&n.target instanceof Element&&n.target.localName!="input"&&n.target.localName!="textarea"&&(this.deleteSelectedNodes(),e=!0),this.selected_nodes))for(var i in this.selected_nodes)this.selected_nodes[i].onKeyDown&&this.selected_nodes[i].onKeyDown(n)}else if(n.type=="keyup"&&(n.keyCode==32&&(this.dragging_canvas=!1),t&&this.selected_nodes))for(var i in this.selected_nodes)this.selected_nodes[i].onKeyUp&&this.selected_nodes[i].onKeyUp(n);if(this.graph.change(),e)return n.preventDefault(),n.stopImmediatePropagation(),!1}cutToClipboard(){this.copyToClipboard(),this.deleteSelectedNodes()}copyToClipboard(){var n={nodes:[],nodeCloneData:{},links:[]},e=0,t=[];for(var i in this.selected_nodes){var s=this.selected_nodes[i];s._relative_id=e,t.push(s),e+=1}for(let u=0;ue.nodes[s].pos[0]&&(t[0]=e.nodes[s].pos[0],i[0]=s),t[1]>e.nodes[s].pos[1]&&(t[1]=e.nodes[s].pos[1],i[1]=s)):(t=[e.nodes[s].pos[0],e.nodes[s].pos[1]],i=[s,s]);for(var r=[],s=0;s=this.viewport[0]&&t=this.viewport[1]&&ih-12||rc.last_y+f||c.last_y===void 0))){var d=c.value;switch(c.type){case"button":t.type===w.pointerevents_method+"down"&&(c.callback&&setTimeout(function(){c.callback(c,l,n,e,t)},20),c.clicked=!0,this.dirty_canvas=!0);break;case"slider":c.options.max-c.options.min;var p=Uo((s-15)/(h-30),0,1);c.value=c.options.min+(c.options.max-c.options.min)*p,c.callback&&setTimeout(function(){k(c,c.value)},20),this.dirty_canvas=!0;break;case"number":case"combo":var d=c.value;if(t.type==w.pointerevents_method+"move"&&c.type=="number")t.deltaX&&(c.value+=t.deltaX*(c.options.step||.1)),c.options.min!=null&&c.valuec.options.max&&(c.value=c.options.max);else if(t.type==w.pointerevents_method+"down"){var g=c.options.values;if(g&&typeof g=="function"){let I=c.options.values;g=I(c,n)}var m=null;c.type!="number"&&(m=Array.isArray(g)?g:Object.keys(g));var _=s<40?-1:s>h-40?1:0;if(c.type=="number")c.value+=_*(c.options.step||.1),c.options.min!=null&&c.valuec.options.max&&(c.value=c.options.max);else if(_){var b=-1;this.last_mouseclick=0,g.constructor===Object?b=m.indexOf(String(c.value))+_:b=m.indexOf(c.value)+_,b>=m.length&&(b=m.length-1),b<0&&(b=0),Array.isArray(g)?c.value=g[b]:c.value=b}else{let I=function(R,N,O){let D=R.content;return g!=m&&(D=y.indexOf(D)),this.value=D,k(this,D),l.dirty_canvas=!0,!1};var y=g!=m?Object.values(g):g;let x=Array.from(y).map(R=>({content:R}));new wi(x,{scale:Math.max(1,this.ds.scale),event:t,className:"dark",callback:I.bind(c)},a)}}else if(t.type==w.pointerevents_method+"up"&&c.type=="number"){var _=s<40?-1:s>h-40?1:0;t.click_time<200&&_==0&&this.prompt("Value",c.value,function(x){this.value=Number(x),k(this,this.value)}.bind(c),t)}d!=c.value&&setTimeout(function(){k(this,this.value)}.bind(c),20),this.dirty_canvas=!0;break;case"toggle":t.type==w.pointerevents_method+"down"&&(c.value=!c.value,setTimeout(function(){k(c,c.value)},20));break;case"string":case"text":t.type==w.pointerevents_method+"down"&&this.prompt("Value",c.value,function(I){this.value=I,k(this,I)}.bind(c),t,c.options?c.options.multiline:!1,c.options.inputStyle);break;default:c.mouse&&(this.dirty_canvas=c.mouse(t,[s,r],n));break}return d!=c.value&&(n.onWidgetChanged&&n.onWidgetChanged(c,d),n.graph._version++),c}}}function k(T,I){T.value=I,T.options&&T.options.property&&n.properties[T.options.property]!==void 0&&n.setProperty(T.options.property,I),T.callback&&T.callback(T.value,l,n,e,t)}return null}adjustNodesSize(){for(var n=this.graph._nodes,e=0;e1&&e.editor_alpha>.99&&(clearInterval(i),e.editor_alpha=1)},1)}onNodeSelectionChange(){}touchHandler(n){}convertOffsetToCanvas(n){return this.ds.convertOffsetToCanvas(n)}convertCanvasToOffset(n,e=[0,0]){return this.ds.convertCanvasToOffset(n,e)}convertEventToCanvasOffset(n){var e=this.canvas.getBoundingClientRect();return this.convertCanvasToOffset([n.clientX-e.left,n.clientY-e.top])}addGraphInputNode(n,e,t){const i=this.graph.findNodesByClass(qi).find(o=>o.properties.name===e);if(i){this.selectNodes([i]);return}(!t||t==="")&&(t="*");const s=[this.canvas.width*.25/this.ds.scale-this.ds.offset[0],this.canvas.height*.5/this.ds.scale-this.ds.offset[1]];this.graph.beforeChange();const r=n.addGraphInput(e,t,s);if(r){const o=r.innerNode;this.selectNodes([o]),this.graph.afterChange()}}addGraphOutputNode(n,e,t){const i=this.graph.findNodesByClass(pn).find(o=>o.properties.name===e);if(i){this.selectNodes([i]);return}(!t||t==="")&&(t="*");const s=[this.canvas.width*.75/this.ds.scale-this.ds.offset[0],this.canvas.height*.5/this.ds.scale-this.ds.offset[1]];this.graph.beforeChange();const r=n.addGraphOutput(e,t,s);if(r){const o=r.innerNode;this.selectNodes([o]),this.graph.afterChange()}}getCanvasMenuOptions(){return Ve.prototype.getCanvasMenuOptions.apply(this,arguments)}getNodeMenuOptions(n){return Ve.prototype.getNodeMenuOptions.apply(this,arguments)}getLinkMenuOptions(n){return Ve.prototype.getLinkMenuOptions.apply(this,arguments)}getGroupMenuOptions(n){return Ve.prototype.getGroupMenuOptions.apply(this,arguments)}checkPanels(){Ve.prototype.checkPanels.apply(this,arguments)}closePanels(){Ve.prototype.closePanels.apply(this,arguments)}createDialog(n,e){return Ve.prototype.createDialog.apply(this,arguments)}createPanel(n,e={}){return Ve.prototype.createPanel.apply(this,arguments)}showSearchBox(n,e={}){return Ve.prototype.showSearchBox.apply(this,arguments)}prompt(n="",e,t,i,s=!1,r=null){return Ve.prototype.prompt.apply(this,arguments)}showConnectionMenu(n={}){return Ve.prototype.showConnectionMenu.apply(this,arguments)}showLinkMenu(n,e){return Ve.prototype.showLinkMenu.apply(this,arguments)}showEditPropertyValue(n,e,t){return Ve.prototype.showEditPropertyValue.apply(this,arguments)}showShowNodePanel(n){Ve.prototype.showShowNodePanel.apply(this,arguments)}showSubgraphPropertiesDialog(n){return Ve.prototype.showSubgraphPropertiesDialog.apply(this,arguments)}showSubgraphPropertiesDialogRight(n){return Ve.prototype.showSubgraphPropertiesDialogRight.apply(this,arguments)}processContextMenu(n,e){Ve.prototype.processContextMenu.apply(this,arguments)}processMouseMove(n){return Oa.prototype.processMouseMove.apply(this,arguments)}processMouseDown(n){return Oa.prototype.processMouseDown.apply(this,arguments)}processMouseUp(n){return Oa.prototype.processMouseUp.apply(this,arguments)}processMouseWheel(n){return Oa.prototype.processMouseWheel.apply(this,arguments)}setZoom(n,e){St.prototype.setZoom.apply(this,arguments)}bringToFront(n){St.prototype.bringToFront.apply(this,arguments)}sendToBack(n){St.prototype.sendToBack.apply(this,arguments)}computeVisibleNodes(n,e=[]){return St.prototype.computeVisibleNodes.apply(this,arguments)}draw(n=!1,e=!1){St.prototype.draw.apply(this,arguments)}drawFrontCanvas(){St.prototype.drawFrontCanvas.apply(this,arguments)}drawSubgraphPanel(n){St.prototype.drawSubgraphPanel.apply(this,arguments)}drawSubgraphPanelLeft(n,e,t){St.prototype.drawSubgraphPanelLeft.apply(this,arguments)}drawSubgraphPanelRight(n,e,t){St.prototype.drawSubgraphPanelRight.apply(this,arguments)}drawButton(n,e,t,i,s,r=w.NODE_DEFAULT_COLOR,o="#555",l=w.NODE_TEXT_COLOR,a=!0){return St.prototype.drawButton.apply(this,arguments)}drawBackCanvas(){St.prototype.drawBackCanvas.apply(this,arguments)}renderInfo(n,e=10,t){St.prototype.renderInfo.apply(this,arguments)}drawNode(n,e){St.prototype.drawNode.apply(this,arguments)}drawLinkTooltip(n,e){St.prototype.drawLinkTooltip.apply(this,arguments)}drawNodeShape(n,e,t,i,s,r,o){St.prototype.drawNodeShape.apply(this,arguments)}drawConnections(n){St.prototype.drawConnections.apply(this,arguments)}renderLink(n,e,t,i,s,r,o,l,a,u){St.prototype.renderLink.apply(this,arguments)}computeConnectionPoint(n,e,t,i=Qe.RIGHT,s=Qe.LEFT){return St.prototype.computeConnectionPoint.apply(this,arguments)}drawExecutionOrder(n){St.prototype.drawExecutionOrder.apply(this,arguments)}drawNodeWidgets(n,e,t,i){St.prototype.drawNodeWidgets.apply(this,arguments)}drawGroups(n,e){St.prototype.drawGroups.apply(this,arguments)}};let re=Al;re.DEFAULT_BACKGROUND_IMAGE="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQBJREFUeNrs1rEKwjAUhlETUkj3vP9rdmr1Ysammk2w5wdxuLgcMHyptfawuZX4pJSWZTnfnu/lnIe/jNNxHHGNn//HNbbv+4dr6V+11uF527arU7+u63qfa/bnmh8sWLBgwYJlqRf8MEptXPBXJXa37BSl3ixYsGDBMliwFLyCV/DeLIMFCxYsWLBMwSt4Be/NggXLYMGCBUvBK3iNruC9WbBgwYJlsGApeAWv4L1ZBgsWLFiwYJmCV/AK3psFC5bBggULloJX8BpdwXuzYMGCBctgwVLwCl7Be7MMFixYsGDBsu8FH1FaSmExVfAxBa/gvVmwYMGCZbBg/W4vAQYA5tRF9QYlv/QAAAAASUVORK5CYII=";re.node_colors={red:{color:"#322",bgcolor:"#533",groupcolor:"#A88"},brown:{color:"#332922",bgcolor:"#593930",groupcolor:"#b06634"},green:{color:"#232",bgcolor:"#353",groupcolor:"#8A8"},blue:{color:"#223",bgcolor:"#335",groupcolor:"#88A"},pale_blue:{color:"#2a363b",bgcolor:"#3f5159",groupcolor:"#3f789e"},cyan:{color:"#233",bgcolor:"#355",groupcolor:"#8AA"},purple:{color:"#323",bgcolor:"#535",groupcolor:"#a1309b"},yellow:{color:"#432",bgcolor:"#653",groupcolor:"#b58b2a"},black:{color:"#222",bgcolor:"#000",groupcolor:"#444"}};re.DEFAULT_LINK_TYPE_COLORS={[$.ACTION]:w.ACTION_LINK_COLOR,[$.EVENT]:w.EVENT_LINK_COLOR,number:"#AAA",node:"#DCA"};re.DEFAULT_CONNECTION_COLORS={input_off:"#778",input_on:"#7F7",output_off:"#778",output_on:"#7F7"};re.DEFAULT_CONNECTION_COLORS_BY_TYPE={number:"#7F7",string:"#77F",boolean:"#F77"};re.DEFAULT_CONNECTION_COLORS_BY_TYPE_OFF={number:"#474",string:"#447",boolean:"#744"};re.active_canvas=null;re.active_node=null;re.onMenuCollapseAll=Ve.onMenuCollapseAll;re.onMenuNodeEdit=Ve.onMenuNodeEdit;re.onShowPropertyEditor=Ve.onShowPropertyEditor;re.onGroupAdd=Ve.onGroupAdd;re.onMenuAdd=Ve.onMenuAdd;re.showMenuNodeOptionalInputs=Ve.showMenuNodeOptionalInputs;re.showMenuNodeOptionalOutputs=Ve.showMenuNodeOptionalOutputs;re.onShowMenuNodeProperties=Ve.onShowMenuNodeProperties;re.onResizeNode=Ve.onResizeNode;re.onMenuResizeNode=Ve.onMenuResizeNode;re.onMenuNodeCollapse=Ve.onMenuNodeCollapse;re.onMenuNodePin=Ve.onMenuNodePin;re.onMenuNodeMode=Ve.onMenuNodeMode;re.onMenuNodeColors=Ve.onMenuNodeColors;re.onMenuNodeShapes=Ve.onMenuNodeShapes;re.onMenuNodeRemove=Ve.onMenuNodeRemove;re.onMenuNodeClone=Ve.onMenuNodeClone;re.onMenuNodeToSubgraph=Ve.onMenuNodeToSubgraph;re.onMenuNodeToSubgraphInputs=Ve.onMenuNodeToSubgraphInputs;re.onMenuNodeToSubgraphOutputs=Ve.onMenuNodeToSubgraphOutputs;re.onMenuNodeToParentGraph=Ve.onMenuNodeToParentGraph;var Gi=(n=>(n[n.SEPARATOR=0]="SEPARATOR",n))(Gi||{});class wi{static trigger(e,t,i,s){var r=document.createEvent("CustomEvent");return r.initCustomEvent(t,!0,!0,i),r.target=s,e.dispatchEvent&&e.dispatchEvent(r),r}static isCursorOverElement(e,t){var i=e.clientX,s=e.clientY,r=t.getBoundingClientRect();return r?s>r.top&&sr.left&&i{o.parentNode.removeChild(o)},w.pointerListenerAdd(o,"down",function(g){if(g.button==2)return s.close(),g.preventDefault(),!0},!0);function l(g){var m=parseInt(o.style.top);return o.style.top=(m+g.deltaY*t.scroll_speed).toFixed()+"px",g.preventDefault(),!0}if(t.scroll_speed||(t.scroll_speed=.1),o.addEventListener("wheel",l,!0),o.addEventListener("mousewheel",l,!0),this.root=o,t.title){var a=document.createElement("div");a.className="litemenu-title",a.innerHTML=t.title,o.appendChild(a)}this.values=[];for(let g=0;gd.width-p.width-10&&(c=d.width-p.width-10),d.height&&f>d.height-p.height-10&&(f=d.height-p.height-10)}o.style.left=c+"px",o.style.top=f+"px",t.scale&&(o.style.transform="scale("+t.scale+")")}addItem(e,t,i={}){var s=this,r=document.createElement("div");r.className="litemenu-entry submenu";var o=!1;typeof t=="string"&&(t={content:t}),t===0?r.classList.add("separator"):(r.innerHTML=t.title?t.title:e,t.disabled&&(o=!0,r.classList.add("disabled")),(t.submenu||t.has_submenu)&&r.classList.add("has_submenu"),typeof t=="function"?r.dataset.value=e:r.dataset.value=""+this.values.length,t.className&&(r.className+=" "+t.className)),this.values.push(t),this.root.appendChild(r),o||r.addEventListener("click",u),i.autoopen&&w.pointerListenerAdd(r,"enter",a);let l=this;function a(c){var f=this.value;!f||!f.has_submenu||u.call(this,c)}function u(c){let f=parseInt(this.dataset.value);var h=l.values[f];w.debug;const d=re.active_canvas;if(!d)return;const p=d.adjustMouseEvent(c);var g=!0;if(s.current_submenu&&s.current_submenu.close(p),i.callback){var m=i.callback.call(this,h,i,p,s,i.node);m===!0&&(g=!1)}if(h&&typeof h=="object"){if(h.callback&&!i.ignore_item_callbacks&&h.disabled!==!0){var m=h.callback.call(this,h,i,p,s,i.extra);m===!0&&(g=!1)}if(h.submenu){if(!h.submenu.options)throw"ContextMenu submenu needs options";new wi(h.submenu.options,{callback:h.submenu.callback,event:p,parentMenu:s,ignore_item_callbacks:h.submenu.ignore_item_callbacks,title:h.submenu.title,extra:h.submenu.extra,autoopen:i.autoopen}),g=!1}}g&&!s.lock&&s.close()}return r}close(e,t){this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.parentMenu&&!t&&(this.parentMenu.lock=!1,this.parentMenu.current_submenu=null,e===void 0?this.parentMenu.close():e&&!wi.isCursorOverElement(e,this.parentMenu.root)&&wi.trigger(this.parentMenu.root,w.pointerevents_method+"leave",e)),this.current_submenu&&this.current_submenu.close(e,!0),this.root.closing_timer&&clearTimeout(this.root.closing_timer)}getTopMenu(){return this.options.parentMenu?this.options.parentMenu.getTopMenu():this}getFirstEvent(){return this.options.parentMenu?this.options.parentMenu.getFirstEvent():this.options.event}}const IC="finalize",EC="consider";function jo(n,e,t){n.dispatchEvent(new CustomEvent(IC,{detail:{items:e,info:t}}))}function vr(n,e,t){n.dispatchEvent(new CustomEvent(EC,{detail:{items:e,info:t}}))}const Oc="draggedEntered",la="draggedLeft",Nc="draggedOverIndex",hp="draggedLeftDocument",Pu={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function AC(n,e,t){n.dispatchEvent(new CustomEvent(Oc,{detail:{indexObj:e,draggedEl:t}}))}function OC(n,e,t){n.dispatchEvent(new CustomEvent(la,{detail:{draggedEl:e,type:Pu.LEFT_FOR_ANOTHER,theOtherDz:t}}))}function NC(n,e){n.dispatchEvent(new CustomEvent(la,{detail:{draggedEl:e,type:Pu.OUTSIDE_OF_ANY}}))}function DC(n,e,t){n.dispatchEvent(new CustomEvent(Nc,{detail:{indexObj:e,draggedEl:t}}))}function xC(n){window.dispatchEvent(new CustomEvent(hp,{detail:{draggedEl:n}}))}const on={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:Oc,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:Nc,DRAGGED_LEFT:la,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},yn={POINTER:"pointer",KEYBOARD:"keyboard"},Is="isDndShadowItem",dp="data-is-dnd-shadow-item",Us="id:dnd-shadow-placeholder-0000",LC="dnd-action-dragged-el";let ki="id",Rh=0;function Gy(){Rh++}function jy(){if(Rh===0)throw new Error("Bug! trying to decrement when there are no dropzones");Rh--}const pp=typeof window>"u";function qy(n){let e;const t=n.getBoundingClientRect(),i=getComputedStyle(n),s=i.transform;if(s){let r,o,l,a;if(s.startsWith("matrix3d("))e=s.slice(9,-1).split(/, /),r=+e[0],o=+e[5],l=+e[12],a=+e[13];else if(s.startsWith("matrix("))e=s.slice(7,-1).split(/, /),r=+e[0],o=+e[3],l=+e[4],a=+e[5];else return t;const u=i.transformOrigin,c=t.x-l-(1-r)*parseFloat(u),f=t.y-a-(1-o)*parseFloat(u.slice(u.indexOf(" ")+1)),h=r?t.width/r:n.offsetWidth,d=o?t.height/o:n.offsetHeight;return{x:c,y:f,width:h,height:d,top:f,right:c+h,bottom:f+d,left:c}}else return t}function Yy(n){const e=qy(n);return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function gp(n){const e=n.getBoundingClientRect();return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function Xy(n){return{x:(n.left+n.right)/2,y:(n.top+n.bottom)/2}}function MC(n,e){return Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2))}function mp(n,e){return n.y<=e.bottom&&n.y>=e.top&&n.x>=e.left&&n.x<=e.right}function Hl(n){return Xy(gp(n))}function Lg(n,e){const t=Hl(n),i=Yy(e);return mp(t,i)}function RC(n,e){const t=Hl(n),i=Hl(e);return MC(t,i)}function PC(n){const e=gp(n);return e.right<0||e.left>document.documentElement.scrollWidth||e.bottom<0||e.top>document.documentElement.scrollHeight}function BC(n,e){const t=gp(e);return mp(n,t)?{top:n.y-t.top,bottom:t.bottom-n.y,left:n.x-t.left,right:Math.min(t.right,document.documentElement.clientWidth)-n.x}:null}let jr;function _p(){jr=new Map}_p();function zC(n){jr.delete(n)}function FC(n){const e=Array.from(n.children).findIndex(t=>t.getAttribute(dp));if(e>=0)return jr.has(n)||jr.set(n,new Map),jr.get(n).set(e,Yy(n.children[e])),e}function WC(n,e){if(!Lg(n,e))return null;const t=e.children;if(t.length===0)return{index:0,isProximityBased:!0};const i=FC(e);for(let o=0;ot(r)))}function i(r){return pl-r}function s(r,o){if(!o)return!1;const l=BC(r,o);if(l===null)return e(),!1;const a=!!n.directionObj;let[u,c]=[!1,!1];return o.scrollHeight>o.clientHeight&&(l.bottomo.clientWidth&&(l.rightMg(c)-Mg(u));function a(){const u=Hl(n),c=GC(u,i);if(!c&&o&&Math.abs(o.x-u.x){i.style.top=`${s}px`,i.style.left=`${r}px`},0)}return i.style.margin="0",i.style.boxSizing="border-box",i.style.height=`${t.height}px`,i.style.width=`${t.width}px`,i.style.transition=`${Lr("top")}, ${Lr("left")}, ${Lr("background-color")}, ${Lr("opacity")}, ${Lr("color")} `,window.setTimeout(()=>i.style.transition+=`, ${Lr("width")}, ${Lr("height")}`,0),i.style.zIndex="9999",i.style.cursor="grabbing",i}function iI(n){n.style.cursor="grab"}function nI(n,e,t,i){Qy(e,n);const s=e.getBoundingClientRect(),r=n.getBoundingClientRect(),o=s.width-r.width,l=s.height-r.height;if(o||l){const a={left:(t-r.left)/r.width,top:(i-r.top)/r.height};n.style.height=`${s.height}px`,n.style.width=`${s.width}px`,n.style.left=`${parseFloat(n.style.left)-a.left*o}px`,n.style.top=`${parseFloat(n.style.top)-a.top*l}px`}}function Qy(n,e){const t=window.getComputedStyle(n);Array.from(t).filter(i=>i.startsWith("background")||i.startsWith("padding")||i.startsWith("font")||i.startsWith("text")||i.startsWith("align")||i.startsWith("justify")||i.startsWith("display")||i.startsWith("flex")||i.startsWith("border")||i==="opacity"||i==="color"||i==="list-style-type").forEach(i=>e.style.setProperty(i,t.getPropertyValue(i),t.getPropertyPriority(i)))}function sI(n,e){n.draggable=!1,n.ondragstart=()=>!1,e?(n.style.userSelect="",n.style.WebkitUserSelect="",n.style.cursor=""):(n.style.userSelect="none",n.style.WebkitUserSelect="none",n.style.cursor="grab")}function ev(n){n.style.display="none",n.style.position="fixed",n.style.zIndex="-5"}function rI(n){n.style.visibility="hidden",n.setAttribute(dp,"true")}function oI(n){n.style.visibility="",n.removeAttribute(dp)}function uu(n,e=()=>{},t=()=>[]){n.forEach(i=>{const s=e(i);Object.keys(s).forEach(r=>{i.style[r]=s[r]}),t(i).forEach(r=>i.classList.add(r))})}function Fu(n,e=()=>{},t=()=>[]){n.forEach(i=>{const s=e(i);Object.keys(s).forEach(r=>{i.style[r]=""}),t(i).forEach(r=>i.classList.contains(r)&&i.classList.remove(r))})}function lI(n){const e=n.style.minHeight;n.style.minHeight=window.getComputedStyle(n).getPropertyValue("height");const t=n.style.minWidth;return n.style.minWidth=window.getComputedStyle(n).getPropertyValue("width"),function(){n.style.minHeight=e,n.style.minWidth=t}}const aI="--any--",uI=100,Pg=3,Bg={outline:"rgba(255, 255, 102, 0.7) solid 2px"};let Ms,Li,xn,Dc,ai,xc,qo,On,sr,Wn,Br=!1,bp=!1,yp,aa=!1,cu=[];const rs=new Map,li=new Map,xf=new WeakMap;function cI(n,e){rs.has(e)||rs.set(e,new Set),rs.get(e).has(n)||(rs.get(e).add(n),Gy())}function zg(n,e){rs.get(e).delete(n),jy(),rs.get(e).size===0&&rs.delete(e)}function fI(){JC();const n=rs.get(Dc);for(const t of n)t.addEventListener(Oc,tv),t.addEventListener(la,iv),t.addEventListener(Nc,nv);window.addEventListener(hp,Yo);const e=Math.max(uI,...Array.from(n.keys()).map(t=>li.get(t).dropAnimationDurationMs));qC(Li,n,e*1.07)}function hI(){ZC();const n=rs.get(Dc);for(const e of n)e.removeEventListener(Oc,tv),e.removeEventListener(la,iv),e.removeEventListener(Nc,nv);window.removeEventListener(hp,Yo),YC()}function dI(n){return n.findIndex(e=>e[ki]===Us)}function Lc(n){return n.findIndex(e=>!!e[Is]&&e[ki]!==Us)}function tv(n){let{items:e,dropFromOthersDisabled:t}=li.get(n.currentTarget);if(t&&n.currentTarget!==ai)return;if(aa=!1,e=e.filter(o=>o[ki]!==qo[ki]),ai!==n.currentTarget){const l=li.get(ai).items.filter(a=>!a[Is]);vr(ai,l,{trigger:on.DRAGGED_ENTERED_ANOTHER,id:xn[ki],source:yn.POINTER})}else{const o=dI(e);o!==-1&&e.splice(o,1)}const{index:i,isProximityBased:s}=n.detail.indexObj,r=s&&i===n.currentTarget.children.length-1?i+1:i;On=n.currentTarget,e.splice(r,0,qo),vr(n.currentTarget,e,{trigger:on.DRAGGED_ENTERED,id:xn[ki],source:yn.POINTER})}function iv(n){if(!Br)return;const{items:e,dropFromOthersDisabled:t}=li.get(n.currentTarget);if(t&&n.currentTarget!==ai&&n.currentTarget!==On)return;const i=Lc(e),s=e.splice(i,1)[0];On=void 0;const{type:r,theOtherDz:o}=n.detail;if(r===Pu.OUTSIDE_OF_ANY||r===Pu.LEFT_FOR_ANOTHER&&o!==ai&&li.get(o).dropFromOthersDisabled){aa=!0,On=ai;const l=li.get(ai).items;l.splice(xc,0,s),vr(ai,l,{trigger:on.DRAGGED_LEFT_ALL,id:xn[ki],source:yn.POINTER})}vr(n.currentTarget,e,{trigger:on.DRAGGED_LEFT,id:xn[ki],source:yn.POINTER})}function nv(n){const{items:e,dropFromOthersDisabled:t}=li.get(n.currentTarget);if(t&&n.currentTarget!==ai)return;aa=!1;const{index:i}=n.detail.indexObj,s=Lc(e);e.splice(s,1),e.splice(i,0,qo),vr(n.currentTarget,e,{trigger:on.DRAGGED_OVER_INDEX,id:xn[ki],source:yn.POINTER})}function Wu(n){n.preventDefault();const e=n.touches?n.touches[0]:n;Wn={x:e.clientX,y:e.clientY},Li.style.transform=`translate3d(${Wn.x-sr.x}px, ${Wn.y-sr.y}px, 0)`}function Yo(){bp=!0,window.removeEventListener("mousemove",Wu),window.removeEventListener("touchmove",Wu),window.removeEventListener("mouseup",Yo),window.removeEventListener("touchend",Yo),hI(),iI(Li),On||(On=ai);let{items:n,type:e}=li.get(On);Fu(rs.get(e),s=>li.get(s).dropTargetStyle,s=>li.get(s).dropTargetClasses);let t=Lc(n);t===-1&&(t=xc),n=n.map(s=>s[Is]?xn:s);function i(){yp(),jo(On,n,{trigger:aa?on.DROPPED_OUTSIDE_OF_ANY:on.DROPPED_INTO_ZONE,id:xn[ki],source:yn.POINTER}),On!==ai&&jo(ai,li.get(ai).items,{trigger:on.DROPPED_INTO_ANOTHER,id:xn[ki],source:yn.POINTER}),oI(On.children[t]),mI()}pI(t,i)}function pI(n,e){const t=qy(On.children[n]),i={x:t.left-parseFloat(Li.style.left),y:t.top-parseFloat(Li.style.top)},{dropAnimationDurationMs:s}=li.get(On),r=`transform ${s}ms ease`;Li.style.transition=Li.style.transition?Li.style.transition+","+r:r,Li.style.transform=`translate3d(${i.x}px, ${i.y}px, 0)`,window.setTimeout(e,s)}function gI(n,e){cu.push({dz:n,destroy:e}),window.requestAnimationFrame(()=>{ev(n),document.body.appendChild(n)})}function mI(){Li.remove(),Ms.remove(),cu.length&&(cu.forEach(({dz:n,destroy:e})=>{e(),n.remove()}),cu=[]),Li=void 0,Ms=void 0,xn=void 0,Dc=void 0,ai=void 0,xc=void 0,qo=void 0,On=void 0,sr=void 0,Wn=void 0,Br=!1,bp=!1,yp=void 0,aa=!1}function _I(n,e){let t=!1;const i={items:void 0,type:void 0,flipDurationMs:0,dragDisabled:!1,morphDisabled:!1,dropFromOthersDisabled:!1,dropTargetStyle:Bg,dropTargetClasses:[],transformDraggedElement:()=>{},centreDraggedOnCursor:!1};let s=new Map;function r(){window.addEventListener("mousemove",a,{passive:!1}),window.addEventListener("touchmove",a,{passive:!1,capture:!1}),window.addEventListener("mouseup",l,{passive:!1}),window.addEventListener("touchend",l,{passive:!1})}function o(){window.removeEventListener("mousemove",a),window.removeEventListener("touchmove",a),window.removeEventListener("mouseup",l),window.removeEventListener("touchend",l)}function l(){o(),Ms=void 0,sr=void 0,Wn=void 0}function a(h){h.preventDefault();const d=h.touches?h.touches[0]:h;Wn={x:d.clientX,y:d.clientY},(Math.abs(Wn.x-sr.x)>=Pg||Math.abs(Wn.y-sr.y)>=Pg)&&(o(),c())}function u(h){if(h.target!==h.currentTarget&&(h.target.value!==void 0||h.target.isContentEditable)||h.button||Br)return;h.stopPropagation();const d=h.touches?h.touches[0]:h;sr={x:d.clientX,y:d.clientY},Wn={...sr},Ms=h.currentTarget,r()}function c(){Br=!0;const h=s.get(Ms);xc=h,ai=Ms.parentElement;const d=ai.getRootNode(),p=d.body||d,{items:g,type:m,centreDraggedOnCursor:_}=i;xn={...g[h]},Dc=m,qo={...xn,[Is]:!0};const b={...qo,[ki]:Us};Li=tI(Ms,_&&Wn);function y(){Li.parentElement?window.requestAnimationFrame(y):(p.appendChild(Li),Li.focus(),fI(),ev(Ms),p.appendChild(Ms))}window.requestAnimationFrame(y),uu(Array.from(rs.get(i.type)).filter(k=>k===ai||!li.get(k).dropFromOthersDisabled),k=>li.get(k).dropTargetStyle,k=>li.get(k).dropTargetClasses),g.splice(h,1,b),yp=lI(ai),vr(ai,g,{trigger:on.DRAG_STARTED,id:xn[ki],source:yn.POINTER}),window.addEventListener("mousemove",Wu,{passive:!1}),window.addEventListener("touchmove",Wu,{passive:!1,capture:!1}),window.addEventListener("mouseup",Yo,{passive:!1}),window.addEventListener("touchend",Yo,{passive:!1})}function f({items:h=void 0,flipDurationMs:d=0,type:p=aI,dragDisabled:g=!1,morphDisabled:m=!1,dropFromOthersDisabled:_=!1,dropTargetStyle:b=Bg,dropTargetClasses:y=[],transformDraggedElement:k=()=>{},centreDraggedOnCursor:T=!1}){i.dropAnimationDurationMs=d,i.type&&p!==i.type&&zg(n,i.type),i.type=p,cI(n,p),i.items=[...h],i.dragDisabled=g,i.morphDisabled=m,i.transformDraggedElement=k,i.centreDraggedOnCursor=T,t&&Br&&!bp&&(!VC(b,i.dropTargetStyle)||!HC(y,i.dropTargetClasses))&&(Fu([n],()=>i.dropTargetStyle,()=>y),uu([n],()=>b,()=>y)),i.dropTargetStyle=b,i.dropTargetClasses=[...y];function I(R,N){return li.get(R)?li.get(R)[N]:i[N]}t&&Br&&i.dropFromOthersDisabled!==_&&(_?Fu([n],R=>I(R,"dropTargetStyle"),R=>I(R,"dropTargetClasses")):uu([n],R=>I(R,"dropTargetStyle"),R=>I(R,"dropTargetClasses"))),i.dropFromOthersDisabled=_,li.set(n,i);const x=Lc(i.items);for(let R=0;R{f(h)},destroy:()=>{function h(){zg(n,li.get(n).type),li.delete(n)}Br?gI(n,h):h()}}}const Bh={DND_ZONE_ACTIVE:"dnd-zone-active",DND_ZONE_DRAG_DISABLED:"dnd-zone-drag-disabled"},sv={[Bh.DND_ZONE_ACTIVE]:"Tab to one the items and press space-bar or enter to start dragging it",[Bh.DND_ZONE_DRAG_DISABLED]:"This is a disabled drag and drop list"},bI="dnd-action-aria-alert";let oi;function zh(){oi||(oi=document.createElement("div"),function(){oi.id=bI,oi.style.position="fixed",oi.style.bottom="0",oi.style.left="0",oi.style.zIndex="-5",oi.style.opacity="0",oi.style.height="0",oi.style.width="0",oi.setAttribute("role","alert")}(),document.body.prepend(oi),Object.entries(sv).forEach(([n,e])=>document.body.prepend(wI(n,e))))}function yI(){return pp?null:(document.readyState==="complete"?zh():window.addEventListener("DOMContentLoaded",zh),{...Bh})}function vI(){pp||!oi||(Object.keys(sv).forEach(n=>{var e;return(e=document.getElementById(n))==null?void 0:e.remove()}),oi.remove(),oi=void 0)}function wI(n,e){const t=document.createElement("div");return t.id=n,t.innerHTML=`

${e}

`,t.style.display="none",t.style.position="fixed",t.style.zIndex="-5",t}function xo(n){if(pp)return;oi||zh(),oi.innerHTML="";const e=document.createTextNode(n);oi.appendChild(e),oi.style.display="none",oi.style.display="inline"}const kI="--any--",Fg={outline:"rgba(255, 255, 102, 0.7) solid 2px"};let Vn=!1,Fh,Ki,qr="",Pr,_s,lr="";const Vu=new WeakSet,Wg=new WeakMap,Vg=new WeakMap,Wh=new Map,Di=new Map,is=new Map;let Hu;function SI(n,e){is.size===0&&(Hu=yI(),window.addEventListener("keydown",rv),window.addEventListener("click",ov)),is.has(e)||is.set(e,new Set),is.get(e).has(n)||(is.get(e).add(n),Gy())}function Hg(n,e){Ki===n&&Ul(),is.get(e).delete(n),jy(),is.get(e).size===0&&is.delete(e),is.size===0&&(window.removeEventListener("keydown",rv),window.removeEventListener("click",ov),Hu=void 0,vI())}function rv(n){if(Vn)switch(n.key){case"Escape":{Ul();break}}}function ov(){Vn&&(Vu.has(document.activeElement)||Ul())}function TI(n){if(!Vn)return;const e=n.currentTarget;if(e===Ki)return;qr=e.getAttribute("aria-label")||"";const{items:t}=Di.get(Ki),i=t.find(u=>u[ki]===_s),s=t.indexOf(i),r=t.splice(s,1)[0],{items:o,autoAriaDisabled:l}=Di.get(e);e.getBoundingClientRect().topn(Di.get(e)))}function Ul(n=!0){Di.get(Ki).autoAriaDisabled||xo(`Stopped dragging item ${lr}`),Vu.has(document.activeElement)&&document.activeElement.blur(),n&&vr(Ki,Di.get(Ki).items,{trigger:on.DRAG_STOPPED,id:_s,source:yn.KEYBOARD}),Fu(is.get(Fh),e=>Di.get(e).dropTargetStyle,e=>Di.get(e).dropTargetClasses),Pr=null,_s=null,lr="",Fh=null,Ki=null,qr="",Vn=!1,lv()}function CI(n,e){const t={items:void 0,type:void 0,dragDisabled:!1,zoneTabIndex:0,dropFromOthersDisabled:!1,dropTargetStyle:Fg,dropTargetClasses:[],autoAriaDisabled:!1};function i(c,f,h){c.length<=1||c.splice(h,1,c.splice(f,1,c[h])[0])}function s(c){switch(c.key){case"Enter":case" ":{if((c.target.disabled!==void 0||c.target.href||c.target.isContentEditable)&&!Vu.has(c.target))return;c.preventDefault(),c.stopPropagation(),Vn?Ul():r(c);break}case"ArrowDown":case"ArrowRight":{if(!Vn)return;c.preventDefault(),c.stopPropagation();const{items:f}=Di.get(n),h=Array.from(n.children),d=h.indexOf(c.currentTarget);d0&&(t.autoAriaDisabled||xo(`Moved item ${lr} to position ${d} in the list ${qr}`),i(f,d,d-1),jo(n,f,{trigger:on.DROPPED_INTO_ZONE,id:_s,source:yn.KEYBOARD}));break}}}function r(c){l(c.currentTarget),Ki=n,Fh=t.type,Vn=!0;const f=Array.from(is.get(t.type)).filter(h=>h===Ki||!Di.get(h).dropFromOthersDisabled);if(uu(f,h=>Di.get(h).dropTargetStyle,h=>Di.get(h).dropTargetClasses),!t.autoAriaDisabled){let h=`Started dragging item ${lr}. Use the arrow keys to move it within its list ${qr}`;f.length>1&&(h+=", or tab to another list in order to move the item into it"),xo(h)}vr(n,Di.get(n).items,{trigger:on.DRAG_STARTED,id:_s,source:yn.KEYBOARD}),lv()}function o(c){Vn&&c.currentTarget!==Pr&&(c.stopPropagation(),Ul(!1),r(c))}function l(c){const{items:f}=Di.get(n),h=Array.from(n.children),d=h.indexOf(c);Pr=c,Pr.tabIndex=0,_s=f[d][ki],lr=h[d].getAttribute("aria-label")||""}function a({items:c=[],type:f=kI,dragDisabled:h=!1,zoneTabIndex:d=0,dropFromOthersDisabled:p=!1,dropTargetStyle:g=Fg,dropTargetClasses:m=[],autoAriaDisabled:_=!1}){t.items=[...c],t.dragDisabled=h,t.dropFromOthersDisabled=p,t.zoneTabIndex=d,t.dropTargetStyle=g,t.dropTargetClasses=m,t.autoAriaDisabled=_,t.type&&f!==t.type&&Hg(n,t.type),t.type=f,SI(n,f),_||(n.setAttribute("aria-disabled",h),n.setAttribute("role","list"),n.setAttribute("aria-describedby",h?Hu.DND_ZONE_DRAG_DISABLED:Hu.DND_ZONE_ACTIVE)),Di.set(n,t),Vn?n.tabIndex=n===Ki||Pr.contains(n)||t.dropFromOthersDisabled||Ki&&t.type!==Di.get(Ki).type?-1:0:n.tabIndex=t.zoneTabIndex,n.addEventListener("focus",TI);for(let b=0;b{a(c)},destroy:()=>{Hg(n,t.type),Di.delete(n),Wh.delete(n)}};return Wh.set(n,u),u}function vp(n,e){Ug(e);const t=_I(n,e),i=CI(n,e);return{update:s=>{Ug(s),t.update(s),i.update(s)},destroy:()=>{t.destroy(),i.destroy()}}}function Ug(n){const{items:e,flipDurationMs:t,type:i,dragDisabled:s,morphDisabled:r,dropFromOthersDisabled:o,zoneTabIndex:l,dropTargetStyle:a,dropTargetClasses:u,transformDraggedElement:c,autoAriaDisabled:f,centreDraggedOnCursor:h,...d}=n;if(Object.keys(d).length>0,!e)throw new Error("no 'items' key provided to dndzone");const p=e.find(g=>!{}.hasOwnProperty.call(g,ki));if(p)throw new Error(`missing '${ki}' property for item ${Df(p)}`);if(u&&!Array.isArray(u))throw new Error(`dropTargetClasses should be an array but instead it is a ${typeof u}, ${Df(u)}`);if(l&&!II(l))throw new Error(`zoneTabIndex should be a number but instead it is a ${typeof l}, ${Df(l)}`)}function II(n){return!isNaN(n)&&function(e){return(e|0)===e}(parseFloat(n))}function Gl(n){return"svelteComponentType"in n}const Lf=n=>(n==null&&(n=[]),n.join(",")),Mf=n=>n===""||n==null?[]:n.split(",").map(e=>e.trim()),av=[{categoryName:"appearance",specs:[{name:"title",type:"string",location:"widget",defaultValue:"",editable:!0},{name:"hidden",type:"boolean",location:"widget",defaultValue:!1,editable:!0},{name:"disabled",type:"boolean",location:"widget",defaultValue:!1,editable:!0},{name:"direction",type:"enum",location:"widget",editable:!0,values:["horizontal","vertical"],defaultValue:"vertical",canShow:n=>n.type==="container"},{name:"classes",type:"string",location:"widget",defaultValue:"",editable:!0},{name:"style",type:"string",location:"widget",defaultValue:"",editable:!0},{name:"nodeDisabledState",type:"enum",location:"widget",editable:!0,values:["visible","disabled","hidden"],defaultValue:"hidden",canShow:n=>n.type==="widget"},{name:"variant",type:"enum",location:"widget",editable:!0,values:["block","accordion","tabs"],defaultValue:"block",canShow:n=>n.type==="container",refreshPanelOnChange:!0},{name:"containerVariant",type:"enum",location:"widget",editable:!0,values:["block","hidden"],defaultValue:"hidden",canShow:n=>n.type==="container"},{name:"openOnStartup",type:"boolean",location:"widget",editable:!0,defaultValue:!1,canShow:n=>n.type==="container"&&n.attrs.variant==="accordion"},{name:"buttonVariant",type:"enum",location:"widget",editable:!0,validNodeTypes:["ui/button"],values:["primary","secondary"],defaultValue:"primary"},{name:"buttonSize",type:"enum",location:"widget",editable:!0,validNodeTypes:["ui/button"],values:["large","small"],defaultValue:"large"},{name:"convertValueToLabelCode",type:"string",location:"nodeProps",editable:!0,multiline:!0,validNodeTypes:["ui/combo"],defaultValue:""},{name:"variant",type:"enum",location:"widget",editable:!0,validNodeTypes:["ui/image_editor"],values:["inlineEditor","fileUpload"],defaultValue:"inlineEditor",refreshPanelOnChange:!0},{name:"variant",type:"enum",location:"widget",editable:!0,validNodeTypes:["ui/gallery"],values:["gallery","image"],defaultValue:"gallery",refreshPanelOnChange:!0},{name:"variant",type:"enum",location:"widget",editable:!0,validNodeTypes:["ui/text"],values:["text","code"],defaultValue:"text",refreshPanelOnChange:!0},{name:"multiline",type:"boolean",location:"nodeProps",editable:!0,validNodeTypes:["ui/text"],defaultValue:!1},{name:"lines",type:"number",location:"nodeProps",editable:!0,validNodeTypes:["ui/text"],defaultValue:5,min:1,max:100,step:1},{name:"maxLines",type:"number",location:"nodeProps",editable:!0,validNodeTypes:["ui/text"],defaultValue:5,min:1,max:100,step:1}]},{categoryName:"behavior",specs:[{name:"saveUserState",type:"boolean",location:"nodeVars",editable:!0,defaultValue:!0},{name:"mode",type:"enum",location:"nodeVars",editable:!0,values:["ALWAYS","NEVER"],defaultValue:"ALWAYS",serialize:n=>n===ft.ALWAYS?"ALWAYS":"NEVER",deserialize:n=>n==="ALWAYS"?ft.ALWAYS:ft.NEVER},{name:"horizontal",type:"boolean",location:"nodeVars",editable:!0,defaultValue:!1},{name:"tags",type:"string",location:"nodeProps",editable:!0,defaultValue:[],serialize:Lf,deserialize:Mf},{name:"tags",type:"string",location:"widget",editable:!0,defaultValue:[],serialize:Lf,deserialize:Mf,canShow:n=>n.type==="container"},{name:"defaultValue",type:"string",location:"nodeProps",editable:!0,defaultValue:"A",validNodeTypes:["ui/combo"]},{name:"defaultValue",type:"boolean",location:"nodeProps",editable:!0,defaultValue:!0,validNodeTypes:["ui/checkbox"]},{name:"defaultValue",type:"number",location:"nodeProps",editable:!0,defaultValue:0,min:-18,max:18,validNodeTypes:["ui/number"]},{name:"min",type:"number",location:"nodeProps",editable:!0,defaultValue:0,min:-18,max:18,validNodeTypes:["ui/number"]},{name:"max",type:"number",location:"nodeProps",editable:!0,defaultValue:10,min:-18,max:18,validNodeTypes:["ui/number"]},{name:"step",type:"number",location:"nodeProps",editable:!0,defaultValue:1,min:-18,max:18,validNodeTypes:["ui/number"]},{name:"param",type:"string",location:"nodeProps",editable:!0,validNodeTypes:["ui/button"],defaultValue:"bang"},{name:"updateMode",type:"enum",location:"nodeProps",editable:!0,validNodeTypes:["ui/gallery"],values:["replace","append"],defaultValue:"replace"},{name:"autoSelectOnUpdate",type:"boolean",location:"nodeProps",editable:!0,validNodeTypes:["ui/gallery"],defaultValue:!0},{name:"showPreviews",type:"boolean",location:"nodeProps",editable:!0,validNodeTypes:["ui/gallery"],defaultValue:!0},{name:"maskCount",type:"number",location:"nodeProps",editable:!0,validNodeTypes:["ui/image_upload"],defaultValue:0,min:0,max:8,step:1},{name:"defaultValue",type:"string",location:"nodeProps",editable:!0,defaultValue:"Choice A",validNodeTypes:["ui/radio"]},{name:"choices",type:"string",location:"nodeProps",editable:!0,validNodeTypes:["ui/radio"],defaultValue:["Choice A","Choice B","Choice C"],serialize:Lf,deserialize:Mf},{name:"defaultValue",type:"string",location:"nodeProps",editable:!0,defaultValue:"",validNodeTypes:["ui/text"]},{name:"title",type:"string",location:"workflow",editable:!0,defaultValue:"New Workflow"},{name:"queuePromptButtonName",type:"string",location:"workflow",editable:!0,defaultValue:"Queue Prompt"},{name:"queuePromptButtonRunWorkflow",type:"boolean",location:"workflow",editable:!0,defaultValue:!0},{name:"queuePromptButtonDefaultWorkflow",type:"string",location:"workflow",editable:!0,defaultValue:""},{name:"showDefaultNotifications",type:"boolean",location:"workflow",editable:!0,defaultValue:!0}]}];let Gg=0;for(const n of Object.values(av))for(const e of Object.values(n.specs))e.id=Gg,Gg+=1;const fu={},Uu={};for(const n of Object.values(av))for(const e of Object.values(n.specs))e.defaultValue!=null&&(e.location==="widget"?fu[e.name]=e.defaultValue:e.location==="workflow"&&(Uu[e.name]=e.defaultValue));function uv(n=null){const e=Be({root:null,allItems:{},allItemsByNode:{},isMenuOpen:!1,isConfiguring:!0});function t(){var N;const R=ie(e);if(R.root===null)throw"Root container was null!";if(R.root.type==="container"){const O=R.root,M=(((N=R.allItems[O.id])==null?void 0:N.children)||[]).find(L=>L.type==="container");return M&&M.type==="container"?M:O}return null}function i(R,N={},O){const D=ie(e),M={type:"container",id:fi(),attrsChanged:Be(0),attrs:{...fu,title:"Container",...N}},L={dragItem:M,children:[],parent:null};if(D.allItemsByNode[M.id]!=null)throw new Error(`Container with ID ${M.id} already registered!!!`);return D.allItems[M.id]=L,R&&c(M,R,O),e.set(D),I(),M}function s(R,N,O={},D){const M=ie(e),L=N.title||"Widget",V={type:"widget",id:fi(),node:N,attrsChanged:Be(0),attrs:{...fu,title:L,...O}},X={dragItem:V,children:[],parent:null};if(M.allItems[V.id]!=null)throw new Error(`Widget with ID ${V.id} already registered!!!`);if(M.allItems[V.id]=X,M.allItemsByNode[N.id]!=null)throw new Error(`Widget's node with ID ${N.id} already registered!!!`);return M.allItemsByNode[N.id]=X,c(V,R,D),I(),V}function r(R,N){const O=ie(e);N&&(O.allItems[R.id].children=N);for(const D of O.allItems[R.id].children)D.id===Us||D.type==="template"||(O.allItems[D.id].parent=R);return e.set(O),O.allItems[R.id].children}function o(R,N){const O=R.allItems[N];if(O.children&&O.children.length>0)throw`Tried removing entry ${N} but it still had children!`;const D=O.parent;if(D){const M=R.allItems[D.id];M.children=M.children.filter(L=>L.id!==N)}if(O.dragItem.type==="widget"){const M=O.dragItem;delete R.allItemsByNode[M.node.id]}delete R.allItems[N],I()}function l(R,N){if(!Gl(R))return;const O=ie(e);if(O.isConfiguring)return;let D={};if(N.addedBy==="template")return;if(N.addedBy==="moveIntoSubgraph"||N.addedBy==="moveOutOfSubgraph"){const L=O.allItemsByNode[N.prevNodeID];delete O.allItemsByNode[N.prevNodeID],O.allItemsByNode[R.id]=L;return}else if((N.addedBy==="cloneSelection"||N.addedBy==="paste")&&N.prevNodeID!=null){let L=O.allItemsByNode[R.id];if(L==null){const V=N.cloneData.forNode[N.prevNodeID];if(V&&V.subgraphNewIDMapping!=null){const q=V.subgraphNewIDMapping.nodeIDs[R.id];q&&(L=O.allItemsByNode[q])}}L&&(D=structuredClone(L.dragItem.attrs))}const M=t();s(M,R,D)}function a(R,N){if(N.removedBy==="moveIntoSubgraph"||N.removedBy==="moveOutOfSubgraph")return;const O=ie(e);let D=Object.entries(O.allItems).filter(M=>M[1].dragItem.type==="widget"&&M[1].dragItem.node.id===R.id);for(const M of D){const[L,V]=M;o(O,L)}e.set(O)}function u(R,N,O,D,M){const L={},V=q=>(L[q]||(L[q]=fi()),L[q]);for(const[q,K]of Object.entries(R.layout.allItems)){const Q=V(q);R.layout.allItems[Q]=K,K.dragItem.id=Q,K.parent&&(K.parent=V(K.parent)),K.children=K.children.map(V),K.dragItem.type==="widget"&&(K.dragItem.nodeId=O[K.dragItem.nodeId].id)}R.layout.root&&(R.layout.root=V(R.layout.root),R.layout.allItems[R.layout.root].parent=null);const X=y(R.layout,N);return e.update(q=>(q.allItems={...q.allItems,...X.allItems},q.allItemsByNode={...q.allItemsByNode,...X.allItemsByNode},q)),c(X.root,D,M),X.root}function c(R,N,O){const D=ie(e),M=D.allItems[R.id];if(!M||M.parent&&M.parent.id===N.id&&M.children.indexOf(R)===O)return;if(M.parent){const V=D.allItems[M.parent.id],X=V.children.findIndex(q=>q.id===R.id);if(X!==-1)V.children.splice(X,1);else throw"Child not found in parent!"}const L=D.allItems[N.id];O!=null&&O>=0?L.children.splice(O,0,R):L.children.push(R),D.allItems[R.id].parent=L.dragItem,I(),e.set(D)}function f(R,N={}){if(R.length===0)return;const O=ie(e),D=O.allItems[R[0]].parent||t();if(D===null||D.type!=="container")return;let M;if(D){const V=O.allItems[D.id].children.findIndex(X=>X.id===R[0]);V!==-1&&(M=V)}const L=i(D,{title:"",containerVariant:"block",...N},M);for(const V of R){const X=O.allItems[V].dragItem;c(X,L)}return I(),e.set(O),L}function h(R){const N=ie(e),O=N.allItems[R.id].parent;if(!O||O.type!=="container")return;let D;const L=N.allItems[O.id].children.findIndex(q=>q.id===R.id);L!==-1&&(D=L);const X=[...N.allItems[R.id].children];for(const q of X)c(q,O,D);o(N,R.id),e.set(N)}function d(R){const N=ie(e),O=Object.entries(N.allItems).find(D=>D[1].dragItem.type==="widget"&&D[1].dragItem.node.id===R);return O?O[1]:null}function p(R){const N=d(R);return N?N.dragItem:null}function*g(R){var D;const N=ie(e);if(R||(R=(D=N.root)==null?void 0:D.id),R==null)return;const O=[N.allItems[R]];for(;O.length>0;){const M=O.shift();if(yield M,M.children)for(const L of M.children)O.push(N.allItems[L.id])}}function m(){e.set({root:null,allItems:{},allItemsByNode:{},isMenuOpen:!1,isConfiguring:!0});const R=i(null,{direction:"horizontal",title:""}),N=i(R,{direction:"vertical",title:""}),O=i(R,{direction:"vertical",title:""});return e.update(D=>(D.root=R,D.isConfiguring=!1,D)),{root:R,left:N,right:O}}function _(R){var M,L;const N=ie(e);if(!N.allItems[R])throw"Root not contained in layout!";const O={},D=[N.allItems[R]];for(;D.length>0;){const V=D.shift();if(V.dragItem.type!=="template"&&(O[V.dragItem.id]={dragItem:{type:V.dragItem.type,id:V.dragItem.id,nodeId:(M=V.dragItem.node)==null?void 0:M.id,attrs:V.dragItem.attrs},children:V.children.map(X=>X.id),parent:(L=V.parent)==null?void 0:L.id},V.children))for(const X of V.children)D.push(N.allItems[X.id])}return{root:R,allItems:O}}function b(){var O,D,M;const R=ie(e),N={};for(const L of Object.entries(R.allItems)){const[V,X]=L;X.dragItem.type!=="template"&&(N[V]={dragItem:{type:X.dragItem.type,id:X.dragItem.id,nodeId:(O=X.dragItem.node)==null?void 0:O.id,attrs:X.dragItem.attrs},children:X.children.map(q=>q.id),parent:(D=X.parent)==null?void 0:D.id})}return{root:(M=R.root)==null?void 0:M.id,allItems:N}}function y(R,N){const O={},D={};for(const V of Object.entries(R.allItems)){const[X,q]=V;if(q.dragItem.type==="template")continue;const K={type:q.dragItem.type,id:q.dragItem.id,attrs:{...fu,...q.dragItem.attrs},attrsChanged:Be(0)},Q={dragItem:K,children:[],parent:null};if(O[X]=Q,K.type==="widget"){const J=K;if(J.node=N.getNodeByIdRecursive(q.dragItem.nodeId),J.node==null)throw`Node in litegraph not found! ${q.dragItem.nodeId}`;D[q.dragItem.nodeId]=Q}}for(const V of Object.entries(R.allItems)){const[X,q]=V;for(const K of q.children)O[X].children.push(O[K].dragItem);q.parent&&(O[X].parent=O[q.parent].dragItem)}let M=null;return R.root&&(M=O[R.root].dragItem),{root:M,allItems:O,allItemsByNode:D,isMenuOpen:!1,isConfiguring:!1}}function k(R,N){const O=y(R,N);e.set(O),Zt.update(D=>(D.refreshPropsPanel+=1,D))}function T(){e.update(R=>(R.isConfiguring=!0,R))}function I(){ie(e).isConfiguring||n==null||n.notifyModified()}return{...e,workflow:n,addContainer:i,addWidget:s,findDefaultContainerForInsertion:t,updateChildren:r,nodeAdded:l,nodeRemoved:a,insertTemplate:u,moveItem:c,groupItems:f,findLayoutEntryForNode:d,findLayoutForNode:p,iterateBreadthFirst:g,ungroup:h,initDefaultLayout:m,onStartConfigure:T,serialize:b,serializeAtRoot:_,deserialize:k,notifyWorkflowModified:I}}function EI(n){if(ie(Zt).all[n.id]!=null)throw new Error(`Layout state already created! ${id}`);const e=uv(n);return Zt.update(t=>(t.all[n.id]=e,t)),e}function AI(n){const e=ie(Zt);if(e.all[n]==null)throw new Error(`No workflow with ID registered! ${n}`);delete e.all[n]}function OI(n){return ie(Zt).all[n]}function cv(n){return"workflowID"in n&&n.workflowID!=null?ie(Zt).all[n.workflowID]:null}function fv(n){const e=n.getRootGraph();return e==null?null:cv(e)}function NI(n){return Object.values(ie(Zt).all).find(e=>ie(e).allItems[n]!=null)}function DI(n){const e=fv(n);return e==null?null:e.findLayoutForNode(n.id)}const xI=Be({all:{},refreshPropsPanel:0}),Zt={...xI,create:EI,createRaw:uv,remove:AI,getLayout:OI,getLayoutByGraph:cv,getLayoutByNode:fv,getLayoutByDragItemID:NI,getDragItemByNode:DI};function hv(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var wp={exports:{}},Lo=typeof Reflect=="object"?Reflect:null,jg=Lo&&typeof Lo.apply=="function"?Lo.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},hu;Lo&&typeof Lo.ownKeys=="function"?hu=Lo.ownKeys:Object.getOwnPropertySymbols?hu=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:hu=function(e){return Object.getOwnPropertyNames(e)};var dv=Number.isNaN||function(e){return e!==e};function Ct(){Ct.init.call(this)}wp.exports=Ct;wp.exports.once=PI;Ct.EventEmitter=Ct;Ct.prototype._events=void 0;Ct.prototype._eventsCount=0;Ct.prototype._maxListeners=void 0;var qg=10;function Mc(n){if(typeof n!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof n)}Object.defineProperty(Ct,"defaultMaxListeners",{enumerable:!0,get:function(){return qg},set:function(n){if(typeof n!="number"||n<0||dv(n))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+n+".");qg=n}});Ct.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ct.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||dv(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function pv(n){return n._maxListeners===void 0?Ct.defaultMaxListeners:n._maxListeners}Ct.prototype.getMaxListeners=function(){return pv(this)};Ct.prototype.emit=function(e){for(var t=[],i=1;i0&&(o=t[0]),o instanceof Error)throw o;var l=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw l.context=o,l}var a=r[e];if(a===void 0)return!1;if(typeof a=="function")jg(a,this,t);else for(var u=a.length,c=yv(a,u),i=0;i0&&o.length>s&&!o.warned){o.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=n,l.type=e,l.count=o.length}return n}Ct.prototype.addListener=function(e,t){return gv(this,e,t,!1)};Ct.prototype.on=Ct.prototype.addListener;Ct.prototype.prependListener=function(e,t){return gv(this,e,t,!0)};function LI(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function mv(n,e,t){var i={fired:!1,wrapFn:void 0,target:n,type:e,listener:t},s=LI.bind(i);return s.listener=t,i.wrapFn=s,s}Ct.prototype.once=function(e,t){return Mc(t),this.on(e,mv(this,e,t)),this};Ct.prototype.prependOnceListener=function(e,t){return Mc(t),this.prependListener(e,mv(this,e,t)),this};Ct.prototype.removeListener=function(e,t){var i,s,r,o,l;if(Mc(t),s=this._events,s===void 0)return this;if(i=s[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete s[e],s.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(r=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){l=i[o].listener,r=o;break}if(r<0)return this;r===0?i.shift():MI(i,r),i.length===1&&(s[e]=i[0]),s.removeListener!==void 0&&this.emit("removeListener",e,l||t)}return this};Ct.prototype.off=Ct.prototype.removeListener;Ct.prototype.removeAllListeners=function(e){var t,i,s;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var r=Object.keys(i),o;for(s=0;s=0;s--)this.removeListener(e,t[s]);return this};function _v(n,e,t){var i=n._events;if(i===void 0)return[];var s=i[e];return s===void 0?[]:typeof s=="function"?t?[s.listener||s]:[s]:t?RI(s):yv(s,s.length)}Ct.prototype.listeners=function(e){return _v(this,e,!0)};Ct.prototype.rawListeners=function(e){return _v(this,e,!1)};Ct.listenerCount=function(n,e){return typeof n.listenerCount=="function"?n.listenerCount(e):bv.call(n,e)};Ct.prototype.listenerCount=bv;function bv(n){var e=this._events;if(e!==void 0){var t=e[n];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Ct.prototype.eventNames=function(){return this._eventsCount>0?hu(this._events):[]};function yv(n,e){for(var t=new Array(e),i=0;i(n.reconnecting=!0,n))}function WI(){kp.update(n=>(n.reconnecting=!1,n))}const bi={...kp,reconnecting:FI,reconnected:WI};class kv extends cp{constructor(t){super();P(this,"eventBus",new wv);P(this,"workflowID",null);this.workflowID=t}get workflow(){var i;const t=(i=this.getRootGraph())==null?void 0:i.workflowID;return t==null?null:ht.getWorkflow(t)}get layout(){var t;return(t=this.workflow)==null?void 0:t.layout}onConfigure(){}onBeforeChange(t,i){this.workflow!=null&&this.workflow.notifyModified()}onAfterChange(t,i){}onAfterExecute(){this.eventBus.emit("afterExecute")}onNodeAdded(t,i){if(t.getRootGraph()!=null&&!this._is_subgraph&&this.workflowID!=null){const s=ie(Zt).all[this.workflowID];if(s===null)throw new Error(`LGraph with workflow missing layout! ${this.workflowID}`);this.doAddNode(t,s,i)}this.workflow!=null&&this.workflow.notifyModified(),this.eventBus.emit("nodeAdded",t)}doAddNode(t,i,s){if(i.nodeAdded(t,s),t.properties.tags==null&&(t.properties.tags=[]),t.canInheritSlotTypes&&t.inputs.length>1&&(t.color||(t.color=re.node_colors.green.color),t.bgColor||(t.bgColor=re.node_colors.green.bgColor)),"outputProperties"in t){const r=t;for(const o of r.outputProperties)r.addPropertyAsOutput(o.name,o.type)}if("defaultWidgets"in t&&!("svelteComponentType"in t)){const r=t,o=r.defaultWidgets;if(o&&o.inputs)for(const l of Object.entries(r.defaultWidgets.inputs)){const[a,u]=l,c=r.inputs[a];c.defaultWidgetNode=u.defaultWidgetNode,u.config&&(c.config=u.config)}}if(ie(bi).autoAddUI&&!("svelteComponentType"in t)&&s.addedBy==null){const r=t,o=[];for(let u=0;u{var c,f;return(f=(c=ie(i).allItemsByNode[u.id])==null?void 0:c.dragItem)==null?void 0:f.id}).filter(Boolean),a=w.registered_node_types[t.type];i.groupItems(l,{title:a.title,variant:"accordion",openOnStartup:!0})}if(t.is(an))for(const r of t.subgraph.iterateNodesInOrder())this.doAddNode(r,i,s);this.workflow!=null&&this.workflow.notifyModified()}onNodeRemoved(t,i){if(Ri.clear(),!this._is_subgraph&&this.workflowID!=null){const s=ie(Zt).all[this.workflowID];if(s===null)throw new Error(`ComfyGraph with workflow missing layout! ${this.workflowID}`);if(s.nodeRemoved(t,i),t.is(an))for(const r of t.subgraph.iterateNodesInOrder())this.onNodeRemoved(r,i)}this.workflow!=null&&this.workflow.notifyModified(),this.eventBus.emit("nodeRemoved",t)}onInputsOutputsChange(){this.workflow!=null&&this.workflow.notifyModified()}onNodeConnectionChange(t,i,s,r,o){this.workflow!=null&&this.workflow.notifyModified(),this.eventBus.emit("nodeConnectionChanged",t,i,s,r,o)}insertTemplate(t,i){const s=[0,0],r={};for(var o=0;ot.draw(!0);this.canvases[e]={canvas:t,canvasHandler:i,state:{offset:[0,0],scale:1}},this.graph.attachCanvas(t),this.graph.eventBus.on("afterExecute",i),Object.keys(this.canvases).length===1&&this.graph.start()}stop(e){const t=this.canvases[e];t!=null&&(t.canvas.closeAllSubgraphs(),this.graph.detachCanvas(t.canvas),this.graph.eventBus.removeListener("afterExecute",t.canvasHandler),delete this.canvases[e],Object.keys(this.canvases).length===0&&this.graph.stop())}stopAll(){for(const e of Object.keys(this.canvases))this.stop(e);this.graph.stop()}serialize(e){const i=this.graph.serialize(),s=e.serialize();return{graph:i,layout:s,attrs:this.attrs}}static create(e="New Workflow"){const t=new ua(e),i=Zt.create(t);return[t,i]}deserialize(e,t){this.missingNodeTypes.clear();for(let i of t.graph.nodes)i.type=="T2IAdapterLoader"&&(i.type="ControlNetLoader"),i.type in w.registered_node_types||this.missingNodeTypes.add(i.type);e.onStartConfigure();for(let i of t.graph.nodes)i.type=="T2IAdapterLoader"&&(i.type="ControlNetLoader");this.graph.configure(t.graph),this.graph.workflowID=this.id;for(const i of this.graph._nodes){const s=i.computeSize();s[0]=Math.max(i.size[0],s[0]),s[1]=Math.max(i.size[1],s[1]),i.size=s}this.attrs={...Uu,...t.attrs},e.deserialize(t.layout,this.graph)}}const Zi=Be({openedWorkflows:[],openedWorkflowsByID:{},activeWorkflowID:null,activeWorkflow:null});function ca(n){return ie(Zi).openedWorkflowsByID[n]}function Sv(n){var t;const e=(t=n.getRootGraph())==null?void 0:t.workflowID;return e==null?null:ca(e)}function VI(n){return Sv(n.graph)}function HI(n){return Object.values(ie(Zi).openedWorkflows).find(e=>e.graph.getNodeByIdRecursive(n)!=null)}function UI(){const n=ie(Zi);return n.activeWorkflowID==null?null:n.openedWorkflowsByID[n.activeWorkflowID]}function GI(n,e="New Workflow",t=!1){const i=new ua(e);Zt.create(i).initDefaultLayout();const r=ie(Zi);return r.openedWorkflows.push(i),r.openedWorkflowsByID[i.id]=i,(t||r.activeWorkflowID==null)&&Rc(n,r.openedWorkflows.length-1),Zi.set(r),i}function jI(n,e,t=!0){const[i,s]=ua.create("Workflow");return i.deserialize(s,{graph:e.workflow,layout:e.layout,attrs:e.attrs}),Tv(n,i,t),i}function Tv(n,e,t=!0){const i=ie(Zi);return i.openedWorkflows.push(e),i.openedWorkflowsByID[e.id]=e,(t||i.activeWorkflowID==null)&&Rc(n,i.openedWorkflows.length-1),Zi.set(i),e}function Cv(n,e){const t=ie(Zi);if(e<0||e>=t.openedWorkflows.length)return;const i=t.openedWorkflows[e];i.stopAll(),Zt.remove(i.id),t.openedWorkflows.splice(e,1),delete t.openedWorkflowsByID[i.id];let s=Uo(e,0,t.openedWorkflows.length-1);Rc(n,s),Zi.set(t)}function qI(n){const e=ie(Zi);for(;e.openedWorkflows.length>0;)Cv(n,0)}function Rc(n,e){const t=ie(Zi);if(t.openedWorkflows.length===0)return t.activeWorkflowID=null,t.activeWorkflow=null,null;if(typeof e=="string"&&(e=t.openedWorkflows.findIndex(s=>s.id===e)),e<0||e>=t.openedWorkflows.length)return t.activeWorkflow;const i=t.openedWorkflows[e];return i.id===t.activeWorkflowID?t.activeWorkflow:(t.activeWorkflow!=null&&t.activeWorkflow.stop("app"),t.activeWorkflowID=i.id,t.activeWorkflow=i,i.start("app",n),n.deserialize(i.canvases.app.state),Zi.set(t),i)}function YI(n){let e=[];const t=ie(Zi);Array.isArray(n)||(n=[n]);const i=new Set(n);for(const s of t.openedWorkflows){const r=s.graph.findNodesByTypeRecursive("events/receive_output").filter(o=>i.has(o.properties.type)&&o.mode===ft.ALWAYS);r.length>0&&e.push({workflow:s,targetNodes:r})}return e}function XI(n,e){const t=ca(n);t!=null&&(t.lastError=null)}function KI(n,e){const t=ca(n);t!=null&&(t.lastError=e)}function $I(n,e){const t=ca(n);t!=null&&(t.lastError=e)}const JI={...Zi,getWorkflow:ca,getWorkflowByGraph:Sv,getWorkflowByNode:VI,getWorkflowByNodeID:HI,getActiveWorkflow:UI,createNewWorkflow:GI,openWorkflow:jI,addWorkflow:Tv,closeWorkflow:Cv,closeAllWorkflows:qI,setActiveWorkflow:Rc,findReceiveOutputTargets:YI,afterQueued:XI,promptError:KI,executionError:$I},ht=JI,En=class{constructor(e){P(this,"root");P(this,"lightboxModal");P(this,"currentImages",[]);P(this,"selectedIndex",-1);P(this,"currentGallery",null);this.root=e,this.lightboxModal=this.root.querySelector("#lightboxModal")}static get instance(){return En._instance||(En._instance=new En(window.app.rootEl)),En._instance}get modalImage(){return this.root.querySelector("#modalImage")}closeModal(){this.lightboxModal.style.display="none",this.currentImages=[],this.selectedIndex=-1,this.currentGallery=null}static all_gallery_buttons(e){var t=e.querySelectorAll(".preview > .thumbnails > .thumbnail-item.thumbnail-small"),i=[];return t.forEach(s=>{s.parentElement.offsetParent&&i.push(s)}),i}static selected_gallery_button(e){var t=e.querySelectorAll(".preview > .thumbnails > .thumbnail-item.thumbnail-small"),i=null;let s=-1;return t.forEach((r,o)=>{r.parentElement.offsetParent&&r.classList.contains("selected")&&(i=r,s=o)}),[i,s]}showModal(e,t,i){this.currentImages=e,this.selectedIndex=t,this.currentGallery=i,this.setModalImageSrc(e[t]),this.lightboxModal.style.display="flex";const s=this.lightboxModal.querySelector(".modalPrev"),r=this.lightboxModal.querySelector(".modalNext");e.length<=1?(s.style.display="none",r.style.display="none"):(s.style.display="block",r.style.display="block"),setTimeout(()=>{this.modalImage.focus()},200)}static get_gallery_urls(e){return En.all_gallery_buttons(e).map(t=>t.children[0].src)}refreshImages(){if(this.currentGallery){this.currentImages=En.get_gallery_urls(this.currentGallery);let[t,i]=En.selected_gallery_button(this.currentGallery);this.selectedIndex=i}const e=this.currentImages[this.selectedIndex];this.setModalImageSrc(e)}setModalImageSrc(e,t=!1){const i=this.modalImage,s=this.lightboxModal;i.src=e,t?(i.style.display="none",s.style.setProperty("background-image",`url(${i.src})`)):(i.style.display="block",s.style.setProperty("background-image","none"))}modalImageSwitch(e){this.selectedIndex=Dv(this.selectedIndex+e,this.currentImages.length);const t=this.currentImages[this.selectedIndex];if(this.setModalImageSrc(t),this.currentGallery){const s=En.all_gallery_buttons(this.currentGallery)[this.selectedIndex];s&&s.click()}setTimeout(()=>{this.lightboxModal.focus()},10)}modalNextImage(e){this.modalImageSwitch(1),e.stopPropagation()}modalPrevImage(e){this.modalImageSwitch(-1),e.stopPropagation()}modalKeyHandler(e){switch(e.key){case"ArrowLeft":this.modalPrevImage(e);break;case"ArrowRight":this.modalNextImage(e);break;case"Escape":this.closeModal();break}}showLightbox(e){this.lightboxModal.style.display!="none"&&this.closeModal();const t=!0;this.modalZoomSet(this.modalImage,t);const i=e.closest("div.block");if(!i||En.all_gallery_buttons(i).length===0)return;let s=En.get_gallery_urls(i);const[r,o]=En.selected_gallery_button(i);this.showModal(s,o,i)}modalZoomSet(e,t){t?e.classList.add("modalImageFullscreen"):e.classList.remove("modalImageFullscreen")}modalZoomToggle(e){const t=this.modalImage;this.modalZoomSet(t,!t.classList.contains("modalImageFullscreen")),e.stopPropagation()}modalTileImageToggle(e){const t=this.modalImage.style.display==="none";this.setModalImageSrc(this.modalImage.src,t),e.stopPropagation()}};let zs=En;P(zs,"_instance");function Iv(n,e){switch(n.type){case"boolean":return typeof e=="boolean";case"number":return typeof e=="number";case"string":return typeof e=="string";case"string[]":return Array.isArray(e)&&e.every(t=>typeof t=="string");case"enum":return!!n.options.values.find(t=>t.value===e)}return!1}const ZI={name:"comfyUIHostname",type:"string",defaultValue:"localhost",category:"backend",description:"Backend domain for ComfyUI",options:{}},QI={name:"comfyUIPort",type:"number",defaultValue:8188,category:"backend",description:"Backend port for ComfyUI",options:{min:1,max:65535,step:1}};var jl=(n=>(n[n.MessageAndSound=0]="MessageAndSound",n[n.MessageOnly=1]="MessageOnly",n[n.SoundOnly=2]="SoundOnly",n[n.None=3]="None",n))(jl||{});const eE={name:"notifications",type:"enum",defaultValue:0,category:"ui",description:"Controls how notifications are shown",options:{values:[{value:0,label:"Message & sound"},{value:1,label:"Message only"},{value:2,label:"Sound only"},{value:3,label:"None"}]}};var du=(n=>(n[n.Auto=0]="Auto",n[n.AlwaysThumbnail=1]="AlwaysThumbnail",n[n.AlwaysFullSize=2]="AlwaysFullSize",n))(du||{});const tE={name:"outputThumbnails",type:"enum",defaultValue:0,category:"ui",description:"If enabled, send back smaller sized output image thumbnails for gallery/queue/history. Enable if you have slow network or are using Colab.",options:{values:[{value:0,label:"Autodetect"},{value:1,label:"Always use thumbnails"},{value:2,label:"Always use full size"}]}},iE={name:"alwaysStripUserState",type:"boolean",defaultValue:!1,category:"behavior",description:"Strip user state even if saving to local storage",options:{}},nE={name:"promptForWorkflowName",type:"boolean",defaultValue:!1,category:"behavior",description:"When saving, always prompt for a name to save the workflow as",options:{}},sE={name:"confirmWhenUnloadingUnsavedChanges",type:"boolean",defaultValue:!0,category:"behavior",description:"When closing the tab, open the confirmation window if there's unsaved changes",options:{}},rE={name:"cacheBuiltInResources",type:"boolean",defaultValue:!0,category:"behavior",description:"Cache loading of built-in resources to save network use",options:{}},oE={name:"pollSystemStatsInterval",type:"number",defaultValue:1e3,category:"behavior",description:"Interval in milliseconds to refresh system stats (total/free VRAM). Set to 0 to disable",options:{min:0,max:6e4,step:100}},lE={name:"builtInTemplates",type:"string[]",defaultValue:["ControlNet","LoRA x5","Model Loader","Positive_Negative","Seed Randomizer"],category:"templates",description:"Basenames of templates that can be loaded from public/templates. Saves LocalStorage space.",options:{}},Pc=[ZI,QI,eE,tE,iE,nE,sE,rE,oE,lE],Ev=Pc.reduce((n,e)=>{if(e.name in n)throw new Error(`Duplicate named config definition: ${e.name}`);return n[e.name]=e,n},{}),J9=Pc.reduce((n,e)=>{var t;return n[t=e.category]||(n[t]=[]),n[e.category].push(e),n},{}),Z9=Pc.reduce((n,e)=>(n.includes(e.category)||n.push(e.category),n),[]),aE=Pc.map(n=>[n.name,structuredClone(n.defaultValue)]),Av=aE.reduce((n,e)=>(n[e[0]]=e[1],n),{}),Jr=Be({...Av}),ar={};let Mo={};function uE(){const n=ie(Jr);let e=n.comfyUIHostname;return e==="localhost"&&(e=location.hostname),`${window.location.protocol}//${e}:${n.comfyUIPort}`}function cE(){const n=ie(Jr).notifications;return n===jl.MessageAndSound||n===jl.MessageOnly}function fE(){const n=ie(Jr).notifications;return n===jl.MessageAndSound||n===jl.SoundOnly}function Ov(n,e,t){let i=!1;return Jr.update(s=>{const r=s[n.name];if(i=Iv(n,e),i?s[n.name]=e:s[n.name]=structuredClone(n.defaultValue),r!=s[n.name])if(t){if(ar[n.name])for(const l of ar[n.name])l(s[n.name],r)}else Mo[n.name]==null?Mo[n.name]=[r,s[n.name]]:Mo[n.name][1]=s[n.name];return s}),i}function Nv(n,e=!1){if(Mo={},Jr.set({...Av}),n!=null&&typeof n=="object")for(const[t,i]of Object.entries(n)){const s=Ev[t];if(s==null){delete n[t];continue}Ov(s,i,e)}return ie(Jr)}function hE(n=!1){return Nv(null,n)}function dE(n,e){ar[n]||(ar[n]=[]),ar[n].push(e)}function pE(){for(const[n,[e,t]]of Object.entries(Mo)){const i=Ev[n];if(ar[n])for(const s of ar[i.name])s(t,e)}Mo={}}const ti={...Jr,getBackendURL:uE,canShowNotificationText:cE,canPlayNotificationSound:fE,validateConfigOption:Iv,setConfigOption:Ov,load:Nv,loadDefault:hE,onChange:dE,runOnChangedEvents:pE};function yi(n,e,t){return t<=e?e:Math.min(Math.max(n,e),t)}function Dv(n,e){return(n%e+e)%e}function Gu(n,e=0){return[...Array(n).keys()].map(t=>t+e)}function gE(n){return n.split(/\r\n|\r|\n/).length}function mE(n){return n.charAt(0).toUpperCase()+n.slice(1)}function xv(n){return n.split("/").pop().split("\\").pop().split(".").slice(0,-1).join(".")}function Q9(n,e){return e<=0?"…":n.length<=e?n:n.slice(0,e)+"…"}async function _E(n,...e){const t=new Date().getTime();return await n.apply(null,e),new Date().getTime()-t}function bE(n,e,t="text/plain"){const i=new Blob([e],{type:t}),s=URL.createObjectURL(i),r=document.createElement("a");r.href=s,r.download=n,document.body.appendChild(r),r.click(),setTimeout(function(){r.remove(),window.URL.revokeObjectURL(s)},0)}const eW=5;function tW(){var n=0;for(const e in localStorage){const t=localStorage[e].length*2/1024/1024;!isNaN(t)&&localStorage.hasOwnProperty(e)&&(n+=t)}return n}function Bc(n,e){const t=n.target.dataset.dragItemId,i=ie(Ri),s=ie(e);if(n.button!==0){i.currentSelection.length<=1&&!s.isMenuOpen&&(i.currentSelection=[t]);return}const r=s.allItems[t].dragItem;if(n.ctrlKey){const o=i.currentSelection.indexOf(r.id);o===-1?i.currentSelection.push(r.id):i.currentSelection.splice(o,1),i.currentSelection=i.currentSelection}else i.currentSelection=[r.id];i.currentSelectionNodes=[];for(const o of i.currentSelection){const l=s.allItems[o].dragItem;if(l.type==="widget"){const a=l.node;a&&i.currentSelectionNodes.push(a)}}e.set(s),Ri.set(i),e.notifyWorkflowModified()}function zc(n,e){e.notifyWorkflowModified()}function iW(n){var s,r;const e=ht.getWorkflowByNodeID(n);if(e==null)return n;const t=(r=(s=e.graph)==null?void 0:s.getNodeByIdRecursive(n))==null?void 0:r.title;if(t==null)return n;const i=n?n.split("-")[0]:String(n);return t+" ("+i+")"}const yE=(n,e=250)=>{let t=null;return(...i)=>{const s=()=>n(...i);t&&clearTimeout(t),t=setTimeout(s,e)}};function vE(n){return n.images.map(wE)}function wE(n){return ti.getBackendURL(),{name:n.filename,orig_name:n.filename,is_file:!1,data:Gs(n)}}function kE(n){const e=[];switch(n.format){case"jpeg":e.push("jpeg");break;case"webp":default:e.push("webp");break}return e.push(String(n.quality)),e.join(";")}function Gs(n,e=!1){if(typeof n=="string")return n;const t={filename:n.filename,subfolder:n.subfolder,type:n.type};if(e){let r;switch(ie(ti).outputThumbnails){case du.AlwaysFullSize:r=!1;break;case du.AlwaysThumbnail:r=!0;break;case du.Auto:default:Bv(navigator.userAgent)?r=!0:r=!1;break}r&&(n.preview={format:"webp",quality:80})}n.preview!=null&&(t.preview=kE(n.preview));const i=new URLSearchParams(t);return ti.getBackendURL()+"/view?"+i}function ql(n){return n&&typeof n=="object"&&n.isComfyBoxImageMetadata}function SE(n){return Array.isArray(n)&&n.every(ql)}function TE(n){return n&&typeof n=="object"&&Array.isArray(n.images)}function Yl(n){return{isComfyBoxImageMetadata:!0,comfyUIFile:n,name:"File",tags:[],children:[]}}function CE(n){let e="";return n.subfolder!=""&&(e=n.subfolder+"/"),e+=`${n.filename} [${n.type}]`,e}function IE(n){return n.images.map(Yl)}function Yg(n){return n!=null&&typeof n=="object"&&typeof n.filename=="string"&&typeof n.type=="string"}function Sp(n){let e=null;return ql(n)?e=[n]:Array.isArray(n)&&n.every(ql)?e=n:TE(n)?e=IE(n):Yg(n)?e=[Yl(n)]:Array.isArray(n)&&n.every(Yg)&&(e=n.map(Yl)),e}function EE(n){const e=Sp(n);return Array.isArray(e)?e.map(t=>t.comfyUIFile):null}function AE(n){return n.comfyUIFile}function ol(n){return Gs(n.comfyUIFile)}function nW(n,e,t){if(t.preventDefault(),!n)return;let i;typeof n[0]=="object"?i=n.map(s=>Gs(s)):i=n,zs.instance.showModal(i,e),t.stopPropagation()}function Lv(n){if(n==null)return null;switch(typeof n){case"string":return"string";case"number":case"bigint":return"number";case"boolean":return"boolean";case"object":return ql(n)?"COMFYBOX_IMAGE":SE(n)?"COMFYBOX_IMAGES":null;case"symbol":case"undefined":case"function":default:return null}}function Mv(n){let e=Number.MAX_SAFE_INTEGER,t=0,i=Number.MAX_SAFE_INTEGER,s=0;for(const r of Object.values(n))e=Math.min(r.pos[0],e),t=Math.max(r.pos[0]+r.size[0],t),i=Math.min(r.pos[1],i),s=Math.max(r.pos[1]+r.size[1],s);return[e,i,t,s]}async function OE(n){return new Promise((e,t)=>{const i=new FileReader;i.onload=async()=>{e(i.result)},i.onerror=async()=>{t(i.error)},i.readAsText(n)})}function ju(n){return n.replace(/([a-zA-Z])[^a-zA-Z]*$/,function(e){var t=e.charCodeAt(0);switch(t){case 90:return"A";case 122:return"a";default:return String.fromCharCode(++t)}})}function Rv(n){if(!ti.canPlayNotificationSound())return;const e=`${location.origin}/sound/${n}`;new Audio(e).play()}async function NE(n){const e=n.map(t=>({blob:t,filename:t.name}));return Pv(e)}async function Pv(n){const e=ti.getBackendURL(),t=n.map(async i=>{const s=new FormData;return s.append("image",i.blob,i.filename),i.overwrite&&s.append("overwrite","true"),fetch(new Request(e+"/upload/image",{body:s,method:"POST"})).then(r=>r.json()).catch(r=>r)});return Promise.all(t).then(i=>{const s=[],r=[];for(const l of i)if(l instanceof Error)s.push(l.toString());else{const a=l;r.push({filename:a.name,subfolder:"",type:"input"})}let o=null;return s&&s.length>0&&(o=`Upload error(s): -`+s.join(` -`)),{error:o,files:r}})}function DE(n){return new Promise(function(e){n.toBlob(e)})}function sW(n,e){let t=0;const i=n.length,s=[];for(t=0;tnew RegExp(n,"i"));function Bv(n){return xE.some(e=>n.match(e))}class Tp extends Ke{constructor(e){super(e),this.properties={value:1},this.nameInGraph="",this.size=[180,30],this.widget=this.addWidget("number","value",1,"value"),this.widgets_up=!0}onExecute(){this.setOutputData(0,this.properties.value)}getTitle(){return this.flags.collapsed?""+this.properties.value:this.title}setValue(e){typeof e!="number"&&(e=parseFloat(e)),this.setProperty("value",e)}onDrawBackground(e){this.outputs[0].label=this.properties.value.toFixed(3)}}Tp.slotLayout={inputs:[],outputs:[{name:"value",type:"number"}]};Tp.propertyLayout=[{name:"value",defaultValue:1}];w.registerNodeType({class:Tp,title:"Const Number",desc:"Constant number",type:"basic/number"});class Cp extends Ke{constructor(e){super(e),this.properties={value:1},this.nameInGraph="",this.size=[180,30],this.widget=this.addWidget("number","value",1,"value",{step:1,precision:0}),this.widgets_up=!0}onExecute(){this.setOutputData(0,this.properties.value)}getTitle(){return this.flags.collapsed?""+this.properties.value:this.title}setValue(e){typeof e!="number"&&(e=parseFloat(e)),this.setProperty("value",Math.floor(e))}onDrawBackground(e){this.outputs[0].label=this.properties.value.toFixed(0)}}Cp.slotLayout={inputs:[],outputs:[{name:"value",type:"number"}]};Cp.propertyLayout=[{name:"value",defaultValue:1}];w.registerNodeType({class:Cp,title:"Const Integer",desc:"Constant integer",type:"basic/integer"});class Fc extends Ke{constructor(e){super(e),this.properties={value:!0},this.size=[140,30],this.widget=this.addWidget("toggle","value",!0,"value"),this.widgets_up=!0}onExecute(){this.setOutputData(0,this.properties.value)}onAction(){this.setValue(!this.properties.value)}getTitle(){return this.flags.collapsed?""+this.properties.value:this.title}setValue(e){this.setProperty("value",!!e)}}Fc.slotLayout={inputs:[],outputs:[{name:"bool",type:"boolean"}]};Fc.propertyLayout=[{name:"value",defaultValue:!0}];Fc.optionalSlots={inputs:[{name:"toggle",type:$.ACTION}]};w.registerNodeType({class:Fc,title:"Const Boolean",desc:"Constant boolean",type:"basic/boolean"});class Wc extends Ke{constructor(e){super(e),this.properties={value:""},this.size=[180,30],this.widget=this.addWidget("text","value","","value"),this.widgets_up=!0}onExecute(){this.setOutputData(0,this.properties.value)}getTitle(){return this.flags.collapsed?""+this.properties.value:this.title}setValue(e){this.setProperty("value",String(e))}onDropFile(e){var t=this,i=new FileReader;i.onload=function(s){t.setProperty("value",i.result)},i.readAsText(e)}}Wc.slotLayout={inputs:[],outputs:[{name:"string",type:"string"}]};Wc.propertyLayout=[{name:"value",defaultValue:""}];Wc.optionalSlots={};w.registerNodeType({class:Wc,title:"Const String",desc:"Constant string",type:"basic/string"});class Vc extends Ke{constructor(e){super(e),this.properties={value:""},this.size=[120,30],this._object={}}onExecute(){this.setOutputData(0,this._object)}}Vc.slotLayout={inputs:[],outputs:[{name:"obj",type:"object"}]};Vc.propertyLayout=[];Vc.optionalSlots={};w.registerNodeType({class:Vc,title:"Const Object",desc:"Constant object",type:"basic/object"});class Hc extends Ke{constructor(e){super(e),this.properties={url:"",type:"text"},this._data=null,this._url=null,this._type=null,this.widget=this.addWidget("text","url","","url"),this._data=null,this.widgets_up=!0}onPropertyChanged(e,t){e=="url"&&(t==null||t==""?this._data=null:this.fetchFile(t))}onExecute(){var e=this.getInputData(0)||this.properties.url;e&&(e!=this._url||this._type!=this.properties.type)&&this.fetchFile(e),this.setOutputData(0,this._data)}setValue(e){this.setProperty("value",e)}async fetchFile(e){var t=this;if(!e||e.constructor!==String){t._data=null,t.boxcolor=null;return}this._url=e,this._type=this.properties.type,e.substr(0,4)=="http"&&w.proxy&&(e=w.proxy+e.substr(e.indexOf(":")+3)),await fetch(e).then(function(i){if(!i.ok)throw new Error("File not found");if(t.properties.type=="arraybuffer")return i.arrayBuffer();if(t.properties.type=="text")return i.text();if(t.properties.type=="json")return i.json();if(t.properties.type=="blob")return i.blob()}).then(function(i){t._data=i,t.boxcolor="#AEA"}).catch(function(i){t._data=null,t.boxcolor="red"})}onDropFile(e){this._url=e.name,this._type=this.properties.type,this.properties.url=e.name;var t=new FileReader;if(t.onload=i=>{this.boxcolor="#AEA";var s=t.result;this.properties.type=="json"&&(s=JSON.parse(s)),this._data=s},this.properties.type=="arraybuffer")t.readAsArrayBuffer(e);else if(this.properties.type=="text"||this.properties.type=="json")t.readAsText(e);else if(this.properties.type=="blob")return t.readAsBinaryString(e)}}Hc.slotLayout={inputs:[{name:"url",type:"string"}],outputs:[{name:"file",type:"string"}]};Hc.propertyLayout=[{name:"url",defaultValue:""},{name:"type",defaultValue:"text"}];Hc.optionalSlots={};w.registerNodeType({class:Hc,title:"Const File",desc:"Fetches a file from an url",type:"basic/file"});const Vh=class extends Ke{constructor(n){super(n),this.properties={value:0},this.nameInGraph="",this.size=[60,30],this.value=0}onExecute(){this.inputs[0]&&(this.value=this.getInputData(0))}getTitle(){return this.flags.collapsed?this.inputs[0].label||"":this.title}static toString(n){if(n==null)return"null";if(n.constructor===Number)return n.toFixed(3);if(n.constructor===Array){for(var e="[",t=0;t=0&&t=0&&i0;return t.push({content:"Splice & Remove",disabled:!i,callback:()=>{const s=this.getInputLink(0),r=this.getOutputLinks(0);if(!s||!r)return;const o=this.graph.getNodeById(s.origin_id);this.graph.removeLink(s.id);for(const l of r){const a=this.graph.getNodeById(l.target_id);this.graph.removeLink(l.id),o.connect(s.origin_slot,a,l.target_slot)}this.graph.remove(this)}}),null}}Yc.slotLayout={inputs:[{name:"",type:"*"}],outputs:[{name:"",type:"*"}]};Yc.overrideSize=[60,30];w.registerNodeType({class:Yc,title:"Reroute",desc:"Simple pass-through for organization",type:"basic/reroute"});class Ip extends Ke{constructor(){super(...arguments),this.properties={enabled:!0}}onExecute(){this.setOutputData(0,this.graph.globaltime*1e3),this.setOutputData(1,this.graph.globaltime)}}Ip.slotLayout={inputs:[],outputs:[{name:"in ms",type:"number"},{name:"in sec",type:"number"}]};Ip.propertyLayout=[{name:"enabled",defaultValue:!0}];w.registerNodeType({class:Ip,title:"Time",desc:"Current time",type:"basic/time"});const zv=class extends Ke{constructor(n){super(n),this.properties={A:1,B:1,OP:"=="},this.opWidget=this.addWidget("combo","Op.",this.properties.OP,null,{property:"OP",values:zv.values})}getTitle(){return"*A "+this.properties.OP+" *B"}onExecute(){var n=this.getInputData(0);n===void 0?n=this.properties.A:this.properties.A=n;var e=this.getInputData(1);e===void 0?e=this.properties.B:this.properties.B=e;var t=!1;if(typeof n==typeof e)switch(this.properties.OP){case"==":case"!=":switch(t=!0,typeof n){case"object":var i=Object.getOwnPropertyNames(n),s=Object.getOwnPropertyNames(e);if(i.length!=s.length){t=!1;break}for(var r=0;r":t=n>e;break;case"<":t=n=":t=n>=e;break;case"||":t=n||e;break;case"&&":t=n&&e;break}this.setOutputData(0,t),this.setOutputData(1,!t)}};let Xc=zv;Xc.slotLayout={inputs:[{name:"A",type:$.DEFAULT},{name:"B",type:$.DEFAULT}],outputs:[{name:"true",type:"boolean"},{name:"false",type:"boolean"}]};Xc.propertyLayout=[{name:"enabled",defaultValue:!0}];Xc.values=["==","!=",">","<",">=","<=","||","&&"];w.registerNodeType({class:Xc,title:"GenericCompare",desc:"Compare *",type:"basic/CompareValues"});class Ep extends Ke{constructor(){super(...arguments),this.properties={strictEquality:!0}}onExecute(){const e=this.getInputData(0),t=this.properties.strictEquality?e===null:e==null;this.setOutputData(0,t)}}Ep.slotLayout={inputs:[{name:"in",type:"*"}],outputs:[{name:"is_null",type:"boolean"}]};Ep.propertyLayout=[];w.registerNodeType({class:Ep,title:"== Null",desc:"Returns true if input is null",type:"basic/is_null"});class Kc extends Ke{constructor(e){super(e),this.properties={},this.size=[60,30],this.actionWidget=this.addWidget("text","Action","",null,{multiline:!0,max_length:100}),this.paramWidget=this.addWidget("text","Param","",null,{multiline:!0,max_length:100}),this.optionsWidget=this.addWidget("text","Opts","",null,{multiline:!0,max_length:100})}onAction(e,t,i){this.actionWidget.value=JSON.stringify(e),this.paramWidget.value=JSON.stringify(t),this.optionsWidget.value=JSON.stringify(i)}}Kc.slotLayout={inputs:[{name:"event",type:$.ACTION}]};Kc.propertyLayout=[];Kc.optionalSlots={};w.registerNodeType({class:Kc,title:"Log Event",desc:"Log event in console",type:"events/log"});class Fv extends Ke{constructor(){super(...arguments),this.properties={onlyOnChange:!0},this.prev=0,this.size=[60,30]}onExecute(e,t){var i=this.getInputData(0),s=i!=this.prev;this.prev===0&&(s=!1);var r=s&&this.properties.onlyOnChange||!s&&!this.properties.onlyOnChange;i&&r&&this.triggerSlot(0,i,null,t),!i&&r&&this.triggerSlot(2,i,null,t),s&&this.triggerSlot(1,i,null,t),this.prev=i}}Fv.slotLayout={inputs:[{name:"if",type:""}],outputs:[{name:"true",type:$.EVENT},{name:"change",type:$.EVENT},{name:"false",type:$.EVENT}]};w.registerNodeType({class:Fv,title:"Trigger Event",desc:"Triggers event if input evaluates to true",type:"events/trigger"});const Wv=class extends Ke{constructor(n){super(n),this.properties={compareValue:null,propertyName:"",mode:"param",operation:"=="},this.size=[60,30],this.modeWidget=this.addWidget("combo","Mode",this.properties.mode,null,{property:"mode",values:["param","property"]}),this.propertyNameWidget=this.addWidget("text","Prop.",this.properties.propertyName,"propertyName"),this.propertyNameWidget.disabled=!0,this.opWidget=this.addWidget("combo","Op.",this.properties.operation,null,{property:"operation",values:Wv.values}),this.compareValueWidget=this.addWidget("text","Value",this.properties.compareValue,"compareValue")}onPropertyChanged(n,e){n==="mode"&&(this.propertyNameWidget.disabled=e==="param")}compare(n,e){if(typeof n!=typeof e)return!1;let t=!1;switch(this.properties.operation){case"==":case"!=":switch(t=!0,typeof n){case"object":var i=Object.getOwnPropertyNames(n),s=Object.getOwnPropertyNames(e);if(i.length!=s.length){t=!1;break}for(var r=0;r":t=n>e;break;case"<":t=n=":t=n>=e;break;case"||":t=n||e;break;case"&&":t=n&&e;break}return t}evaluate(n){if(this.properties.mode==="property"){if(!this.properties.propertyName)return!1;var e=n[this.properties.propertyName];return e==null?!1:this.compare(this.properties.compareValue,e)}else return this.compare(this.properties.compareValue,n)}onExecute(){const n=this.getInputData(1);n!=null&&this.setProperty("compareValue",n),this.compareValueWidget.value=String(this.properties.compareValue)}onAction(n,e,t){this.evaluate(e)?this.triggerSlot(0,e,null,t):this.triggerSlot(1,e,null,t)}};let Ap=Wv;Ap.slotLayout={inputs:[{name:"event",type:$.ACTION},{name:"compare_value",type:"*"}],outputs:[{name:"accept",type:$.EVENT},{name:"reject",type:$.EVENT}]};Ap.values=["==","!=",">","<",">=","<=","||","&&"];w.registerNodeType({class:Ap,title:"Filter Event",desc:"Blocks events that do not match the filter",type:"events/filter"});class Vv extends Ke{constructor(){super(...arguments),this._value=!1,this.size=[120,60]}onExecute(e,t){this._value=this.getInputData(1)}onAction(e,t,i){this._value=this.getInputData(1),this.triggerSlot(this._value?0:1,t,null,i)}}Vv.slotLayout={inputs:[{name:"in",type:$.ACTION},{name:"cond",type:"boolean"}],outputs:[{name:"true",type:$.EVENT},{name:"false",type:$.EVENT}]};w.registerNodeType({class:Vv,title:"Branch",desc:"If condition is true, outputs triggers true, otherwise false",type:"events/branch"});class $c extends Ke{constructor(){super(...arguments),this.properties={timeInMs:1e3},this._pending=[],this.size=[60,30]}onAction(e,t,i){var s=this.properties.timeInMs;s<=0?this.trigger(null,t,i):this._pending.push([s,t])}onExecute(e,t){var i=this.graph.elapsed_time*1e3;this.isInputConnected(1)&&(this.properties.timeInMs=this.getInputData(1));for(var s=0;s0)&&(this._pending.splice(s,1),--s,this.trigger(null,r[1],t))}}}$c.slotLayout={inputs:[{name:"event",type:$.ACTION}],outputs:[{name:"on_time",type:$.EVENT}]};$c.propertyLayout=[];$c.optionalSlots={};w.registerNodeType({class:$c,title:"Delay",desc:"Delays one event",type:"events/delay"});class Jc extends Ke{constructor(){super(...arguments),this.properties={timeInFrames:30},this._pending=[],this.size=[60,30]}onAction(e,t,i){var s=this.properties.timeInFrames;s<=0?this.trigger(null,t,i):this._pending.push([s,t])}onExecute(e,t){var i=1;this.isInputConnected(1)&&(this.properties.timeInFrames=this.getInputData(1));for(var s=0;s0)&&(this._pending.splice(s,1),--s,this.trigger(null,r[1],t))}}}Jc.slotLayout={inputs:[{name:"event",type:$.ACTION}],outputs:[{name:"on_time",type:$.EVENT}]};Jc.propertyLayout=[];Jc.optionalSlots={};w.registerNodeType({class:Jc,title:"Frame Delay",desc:"Delays one event by frame count",type:"events/frame_delay"});class Hv extends Ke{constructor(e){super(e),this.size=[90,70]}getTitle(){return this.horizontal?"":this.title}onAction(e,t,i){if(this.outputs){i=i||{};for(var s=0;so?this.getInputLink(l.length-1)?1:0:this.getOutputLinks(l.length-1).length,u=()=>{o?this.addInput("",$.ACTION):this.addOutput("",$.EVENT)};if(i)s!=null&&t===l.length-1&&u();else{if(a(l.length-1)>0)return;for(let c=l.length-1;c>0&&!(c<=0);c--)if(a()===0)o?this.removeInput(c):this.removeOutput(c);else break;a(l.length-1)>0&&u()}}}Hv.slotLayout={inputs:[{name:"",type:$.ACTION}],outputs:[{name:"",type:$.EVENT}]};w.registerNodeType({class:Hv,title:"Sequence",desc:"Triggers a sequence of events when an event arrives",type:"events/sequence"});class Uv extends Ke{constructor(){super(...arguments),this.properties={}}onAction(e,t,i){var s=this.getInputData(1);this.triggerSlot(0,s,null,i)}}Uv.slotLayout={inputs:[{name:"trigger",type:$.ACTION},{name:"param",type:""}],outputs:[{name:"event",type:$.EVENT}]};w.registerNodeType({class:Uv,title:"Wrap As Event",desc:"Triggers an event setting its parameter to the input value",type:"events/wrap_as_event"});class Op extends Ke{onExecute(){const e=this.getInputData(0);this.setOutputData(0,!!e)}}Op.slotLayout={inputs:[{name:"in",type:"*"}],outputs:[{name:"truthy",type:"boolean"}]};Op.propertyLayout=[];w.registerNodeType({class:Op,title:"~= TRUE",desc:"Returns true if input is truthy",type:"logic/truthy"});class Gv extends Ke{onExecute(){let e=!0;for(let t=0;te+t,this._result=[],this.size=[100,60]}getTitle(){return this.properties.OP=="max"||this.properties.OP=="min"?this.properties.OP+"(A,B)":"A "+this.properties.OP+" B"}setValue(e){typeof e=="string"&&(e=parseFloat(e)),this.properties.value=e}onPropertyChanged(e,t){if(e=="OP")switch(this.properties.OP){case"+":this._func=function(i,s){return i+s};break;case"-":this._func=function(i,s){return i-s};break;case"*":this._func=function(i,s){return i*s};break;case"/":this._func=function(i,s){return i/s};break;case"%":this._func=function(i,s){return i%s};break;case"^":this._func=function(i,s){return Math.pow(i,s)};break;case"max":this._func=function(i,s){return Math.max(i,s)};break;case"min":this._func=function(i,s){return Math.min(i,s)};break;default:this._func=function(i){return i};break}}onExecute(){var e=this.getInputData(0),t=this.getInputData(1);e!=null?e.constructor===Number&&(this.properties.A=e):e=this.properties.A,t!=null?this.properties.B=t:t=this.properties.B;var i;if(e.constructor===Number)i=0,i=this._func(e,t);else if(e.constructor===Array){i=this._result,i.length=e.length;for(var s=0;sthis.formatTemplateValue(t[r-1]));return this.properties.outputJSON&&(i=JSON.parse(i)),i}onPropertyChanged(e,t){if(e==="outputJSON"){const i=t==!0;this.outputs[0].type=i?"*":"string",this.boxcolor=w.NODE_DEFAULT_BOXCOLOR}this._value=null}onExecute(){if(this._value==null){const e=this.properties.template||"";let t;if(this._args!=null)t=this._args,this._args=null;else{const i=this.getInputData(0);if(Array.isArray(i))t=i;else{t=[];for(let s=0;s1&&this.getInputLink(o)==null;o--)this.removeInput(o);this.getInputLink(this.inputs.length-1)!=null&&this.addInput("","*"),this.addInput("update",$.ACTION)}}}Dp.slotLayout={inputs:[{name:"",type:"string,array"},{name:"",type:"string"},{name:"update",type:$.ACTION}],outputs:[{name:"out",type:"string"},{name:"changed",type:$.EVENT}]};Dp.propertyLayout=[{name:"template",defaultValue:"$1, $2, $3",options:{multiline:!0}},{name:"stringQuote",defaultValue:""}];w.registerNodeType({class:Dp,title:"Template",desc:"Substitutes an array of strings in a template like '$1, $2, $3'",type:"string/template"});class sw extends Ke{constructor(){super(...arguments),this.properties={},this._value=null,this._str=null,this._error=null}onExecute(){const e=this.getInputData(0);if(e!=this._str&&typeof e=="string"){this._error=null,this._value=null,this._str=e;try{this._value=JSON.parse(this._str),this.boxcolor="#AEA"}catch(t){this._error=`${t}`,this.boxcolor="red"}}else e==null&&(this._str=null,this._value=null,this._error=null,this.boxcolor=w.NODE_DEFAULT_BOXCOLOR);this.setOutputData(0,this._value),this.setOutputData(1,this._error)}onConnectionsChange(e,t,i,s,r){this._str=null}}sw.slotLayout={inputs:[{name:"in",type:"string"}],outputs:[{name:"out",type:"*"},{name:"error",type:"string"}]};w.registerNodeType({class:sw,title:"JSON Parse",desc:"Parses a string into a JavaScript object",type:"string/json_parse"});class rw extends Ke{constructor(){super(...arguments),this.properties={space:0},this._value=null,this._obj=null,this._error=null,this._changed=!1}onExecute(){const e=this.getInputData(0);if(this._changed||this._obj!==e){this._value=null,this._changed=null,this._obj=e,this._error=null;const t=this.properties.space;try{this._value=JSON.stringify(this._obj,null,t),this.boxcolor="#AEA"}catch(i){this._error=`${i}`,this.boxcolor="red"}}else e==null&&(this._obj=null,this._value=null,this._error=null,this.boxcolor=w.NODE_DEFAULT_BOXCOLOR);this.setOutputData(0,this._value),this.setOutputData(1,this._error)}onConnectionsChange(e,t,i,s,r){this._obj=null,this._changed=!0}}rw.slotLayout={inputs:[{name:"in",type:"*"}],outputs:[{name:"out",type:"string"},{name:"error",type:"string"}]};w.registerNodeType({class:rw,title:"JSON Stringify",desc:"Calls JSON.stringify() on the input value",type:"string/json_stringify"});class Ft extends Ke{constructor(t){super(t);P(this,"properties",{tags:[]});P(this,"isBackendNode");P(this,"defaultWidgets");P(this,"canInheritSlotTypes",!1);P(this,"saveUserState",!0);this.addProperty("tags",[],"array")}stripUserState(t){t.widgets_values=[]}getUpstreamLink(){return null}getUpstreamLinkForInheritedType(){return this.getUpstreamLink()}get layoutState(){return Zt.getLayoutByNode(this)}get dragItem(){return Zt.getDragItemByNode(this)}get workflow(){return ht.getWorkflowByNode(this)}inheritSlotTypes(t,i){var h;if(i&&t===mt.OUTPUT&&new Set(this.outputs.flatMap(p=>p.links.map(g=>this.graph.links[g].type).filter(g=>g!=="*"))).size>1)for(let p=0;pm&&g[m].type==="*"){d.outputs[m].type=o||"*",d.__outputType=c,d.outputs[m].name=d.properties.showOutputText?String(c):"",d.size=d.computeSize(),"applyOrientation"in d&&typeof d.applyOrientation=="function"&&d.applyOrientation();for(const b of d.outputs[m].links||[]){const y=this.graph.links[b];y&&(y.color=f)}}}if(l)for(let d=0;df.class===u);c&&(l.widgetNodeType=c.type),l.defaultWidgetNode=null}}t.saveUserState=this.saveUserState;let i=this.saveUserState||ie(ti).alwaysStripUserState;const s=ie(bi).forceSaveUserState;s!==null&&(i=s),i||this.stripUserState(t)}onConfigure(t){if(!(this.inputs.length!=(t.inputs||[]).length||this.outputs.length!=(t.outputs||[]).length)){for(let i=0;iu.type===l);a&&(o.defaultWidgetNode=a.class)}}this.saveUserState=t.saveUserState,this.saveUserState==null&&(this.saveUserState=!0)}}}const ir=class extends Ft{constructor(t){super(t);P(this,"titleMode",Ji.NO_TITLE);P(this,"collapsable",!1);P(this,"properties",{tags:[],showOutputText:ir.defaultVisibility,horizontal:!1,ignoreTypes:!1});P(this,"canInheritSlotTypes",!0);this.properties||(this.properties={}),this.properties.showOutputText=ir.defaultVisibility,this.properties.horizontal=!1,this.properties.showOutputText&&(this.outputs[0].name="*")}static setDefaultTextVisibility(t){ir.defaultVisibility=t,t?localStorage["Comfy.ComfyReroute.DefaultVisibility"]="true":delete localStorage["Comfy.ComfyReroute.DefaultVisibility"]}onExecute(){this.setOutputData(0,this.getInputData(0))}getUpstreamLink(){const t=this.getInputLink(0),i=this.getInputNode(0);return t&&i&&i.mode===ft.ALWAYS?t:null}onConnectionsChange(t,i,s,r,o){this.applyOrientation(),this.canInheritSlotTypes=!this.properties.ignoreTypes,super.onConnectionsChange(t,i,s,r,o)}clone(){const t=super.clone.apply(this);return t.removeOutput(0),t.addOutput(this.properties.showOutputText?"*":"","*"),t.size=t.computeSize(),t}getExtraMenuOptions(t,i){const s=this.getInputLink(0)!=null&&this.getOutputLinks(0).length>0;return i.push({content:"Splice & Remove",disabled:!s,callback:()=>{const r=this.getInputLink(0),o=this.getOutputLinks(0);if(!r||!o)return;const l=this.graph.getNodeById(r.origin_id);this.graph.removeLink(r.id);for(const a of o){const u=this.graph.getNodeById(a.target_id);this.graph.removeLink(a.id),l.connect(r.origin_slot,u,a.target_slot)}this.graph.remove(this)}}),i.unshift({content:(this.properties.showOutputText?"Hide":"Show")+" Type",callback:()=>{this.properties.showOutputText=!this.properties.showOutputText,this.properties.showOutputText?this.outputs[0].name=this.__outputType||this.outputs[0].type:this.outputs[0].name="",this.size=this.computeSize(),this.applyOrientation(),this.graph.setDirtyCanvas(!0,!0)}},{content:(ir.defaultVisibility?"Hide":"Show")+" Type By Default",callback:()=>{ir.setDefaultTextVisibility(!ir.defaultVisibility)}},{content:"Set "+(this.properties.horizontal?"Horizontal":"Vertical"),callback:()=>{this.properties.horizontal=!this.properties.horizontal,this.applyOrientation()}}),null}applyOrientation(){this.horizontal=this.properties.horizontal,this.horizontal?this.inputs[0].pos=[this.size[0]/2,0]:delete this.inputs[0].pos,this.graph.setDirtyCanvas(!0,!0)}computeSize(){return[this.properties.showOutputText&&this.outputs&&this.outputs.length?Math.max(75,w.NODE_TEXT_SIZE*this.outputs[0].name.length*.6+40):75,26]}};let ks=ir;P(ks,"defaultVisibility",!0),P(ks,"slotLayout",{inputs:[{name:"",type:"*"}],outputs:[{name:"",type:"*"}]});w.registerNodeType({class:ks,title:"Comfy.Reroute",desc:"Reroutes nodes preserving input/output types",type:"utils/reroute"});class ow extends Ft{constructor(t){super(t);P(this,"properties",{tags:[],mode:"anyActiveLink"});P(this,"canInheritSlotTypes",!0);P(this,"selected",-1);P(this,"displayWidget");P(this,"modeWidget");this.displayWidget=this.addWidget("text","Value",""),this.displayWidget.disabled=!0,this.modeWidget=this.addWidget("combo","Mode",this.properties.mode,null,{property:"mode",values:["anyActiveLink","dataTruthy","dataNonNull"]})}onDrawBackground(t){if(!this.flags.collapsed)if(this.selected===-1){const i=w.NODE_SLOT_HEIGHT+6;t.lineWidth=5,t.strokeStyle="red",t.beginPath(),t.moveTo(50-15,i-15),t.lineTo(50+15,i+15),t.stroke(),t.moveTo(50+15,i-15),t.lineTo(50-15,i+15),t.stroke()}else{t.fillStyle="#AFB";const i=this.selected*w.NODE_SLOT_HEIGHT+6;t.beginPath(),t.moveTo(50,i),t.lineTo(50,i+w.NODE_SLOT_HEIGHT),t.lineTo(34,i+w.NODE_SLOT_HEIGHT*.5),t.fill()}}onConnectionsChange(t,i,s,r,o){if(super.onConnectionsChange(t,i,s,r,o),t===mt.INPUT)if(s){if(r!=null&&i===this.inputs.length-1){const l=this.inputs[this.inputs.length-1].name,a=ju(l);this.addInput(a,this.inputs[0].type)}}else{if(this.getInputLink(this.inputs.length-1)!=null)return;for(let a=this.inputs.length-2;a>0&&!(a<=0);a--)if(this.getInputLink(a)==null)this.removeInput(a);else break;let l="A";for(let a=0;a0&&(this._aboutToChange-=1,this._aboutToChange<=0)){const s=this._aboutToChangeValue;this._aboutToChange=0,this._aboutToChangeValue=null,this.triggerChangeEvent(s)}}onAction(t,i,s){if(t===this.storeActionName){let r=!1,o=i;i!=null&&typeof i=="object"&&"__widgetValue__"in i&&(o=i.__widgetValue__,"noChangedEvent"in i&&(r=!!i.noChangedEvent)),this.setValue(o,r)}}onConnectOutput(t,i,s,r,o){const l=Gu(this.outputs.length).some(a=>this.getOutputLinks(a).length>0);return this.autoConfig&&"config"in s&&!l&&s.widgetNodeType===this.type&&this.doAutoConfig(s),!0}doAutoConfig(t,i={setDefaultValue:!0,setWidgetTitle:!0}){const s=t;for(const r in s.config)(i.includeProperties==null||i.includeProperties.has(r))&&this.setProperty(r,s.config[r]);if(i.setDefaultValue&&"defaultValue"in this.properties&&this.setValue(this.properties.defaultValue),i.setWidgetTitle){const r=this.layoutState.findLayoutForNode(this.id);r&&t.name!==""&&(r.attrs.title=t.name)}this.setValue(ie(this.value)),this.onAutoConfig(t),this.notifyPropsChanged()}onAutoConfig(t){}notifyPropsChanged(){if(!this.layoutState)return;const t=this.layoutState.findLayoutEntryForNode(this.id);t&&t.parent&&t.parent.attrsChanged.set(ie(t.parent.attrsChanged)+1),this.propsChanged.set(ie(this.propsChanged)+1)}onConnectionsChange(t,i,s,r,o){super.onConnectionsChange(t,i,s,r,o),this.clampConfig()}clampConfig(){for(const t of this.getOutputLinks(0))if(t){const i=this.graph._nodes_by_id[t.target_id];if(i){const s=i.inputs[t.target_slot];s&&"config"in s&&this.clampOneConfig(s)}}this.notifyPropsChanged()}clampOneConfig(t){}onSerialize(t){t.comfyValue=ie(this.value),t.shownOutputProperties=this.shownOutputProperties,super.onSerialize(t)}onConfigure(t){const i=t.comfyValue||w.cloneObject(this.defaultValue);this.value.set(i),this.shownOutputProperties=t.shownOutputProperties}}typeof window<"u"&&(window.__svelte||(window.__svelte={v:new Set})).v.add(gC);var lw={},aw={},xp={exports:{}},Mt=String,uw=function(){return{isColorSupported:!1,reset:Mt,bold:Mt,dim:Mt,italic:Mt,underline:Mt,inverse:Mt,hidden:Mt,strikethrough:Mt,black:Mt,red:Mt,green:Mt,yellow:Mt,blue:Mt,magenta:Mt,cyan:Mt,white:Mt,gray:Mt,bgBlack:Mt,bgRed:Mt,bgGreen:Mt,bgYellow:Mt,bgBlue:Mt,bgMagenta:Mt,bgCyan:Mt,bgWhite:Mt}};xp.exports=uw();xp.exports.createColors=uw;var LE=xp.exports;(function(n){Object.defineProperty(n,"__esModule",{value:!0});function e(a,u){for(var c in u)Object.defineProperty(a,c,{enumerable:!0,get:u[c]})}e(n,{dim:function(){return o},default:function(){return l}});const t=i(LE);function i(a){return a&&a.__esModule?a:{default:a}}let s=new Set;function r(a,u,c){typeof process<"u"&&{}.JEST_WORKER_ID||c&&s.has(c)||(c&&s.add(c),u.forEach(f=>{}))}function o(a){return t.default.dim(a)}const l={info(a,u){r(t.default.bold(t.default.cyan("info")),...Array.isArray(a)?[a]:[u,a])},warn(a,u){r(t.default.bold(t.default.yellow("warn")),...Array.isArray(a)?[a]:[u,a])},risk(a,u){r(t.default.bold(t.default.magenta("risk")),...Array.isArray(a)?[a]:[u,a])}}})(aw);(function(n){Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return s}});const e=t(aw);function t(r){return r&&r.__esModule?r:{default:r}}function i({version:r,from:o,to:l}){e.default.warn(`${o}-color-renamed`,[`As of Tailwind CSS ${r}, \`${o}\` has been renamed to \`${l}\`.`,"Update your configuration file to silence this warning."])}const s={inherit:"inherit",current:"currentColor",transparent:"transparent",black:"#000",white:"#fff",slate:{50:"#f8fafc",100:"#f1f5f9",200:"#e2e8f0",300:"#cbd5e1",400:"#94a3b8",500:"#64748b",600:"#475569",700:"#334155",800:"#1e293b",900:"#0f172a",950:"#020617"},gray:{50:"#f9fafb",100:"#f3f4f6",200:"#e5e7eb",300:"#d1d5db",400:"#9ca3af",500:"#6b7280",600:"#4b5563",700:"#374151",800:"#1f2937",900:"#111827",950:"#030712"},zinc:{50:"#fafafa",100:"#f4f4f5",200:"#e4e4e7",300:"#d4d4d8",400:"#a1a1aa",500:"#71717a",600:"#52525b",700:"#3f3f46",800:"#27272a",900:"#18181b",950:"#09090b"},neutral:{50:"#fafafa",100:"#f5f5f5",200:"#e5e5e5",300:"#d4d4d4",400:"#a3a3a3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",950:"#0a0a0a"},stone:{50:"#fafaf9",100:"#f5f5f4",200:"#e7e5e4",300:"#d6d3d1",400:"#a8a29e",500:"#78716c",600:"#57534e",700:"#44403c",800:"#292524",900:"#1c1917",950:"#0c0a09"},red:{50:"#fef2f2",100:"#fee2e2",200:"#fecaca",300:"#fca5a5",400:"#f87171",500:"#ef4444",600:"#dc2626",700:"#b91c1c",800:"#991b1b",900:"#7f1d1d",950:"#450a0a"},orange:{50:"#fff7ed",100:"#ffedd5",200:"#fed7aa",300:"#fdba74",400:"#fb923c",500:"#f97316",600:"#ea580c",700:"#c2410c",800:"#9a3412",900:"#7c2d12",950:"#431407"},amber:{50:"#fffbeb",100:"#fef3c7",200:"#fde68a",300:"#fcd34d",400:"#fbbf24",500:"#f59e0b",600:"#d97706",700:"#b45309",800:"#92400e",900:"#78350f",950:"#451a03"},yellow:{50:"#fefce8",100:"#fef9c3",200:"#fef08a",300:"#fde047",400:"#facc15",500:"#eab308",600:"#ca8a04",700:"#a16207",800:"#854d0e",900:"#713f12",950:"#422006"},lime:{50:"#f7fee7",100:"#ecfccb",200:"#d9f99d",300:"#bef264",400:"#a3e635",500:"#84cc16",600:"#65a30d",700:"#4d7c0f",800:"#3f6212",900:"#365314",950:"#1a2e05"},green:{50:"#f0fdf4",100:"#dcfce7",200:"#bbf7d0",300:"#86efac",400:"#4ade80",500:"#22c55e",600:"#16a34a",700:"#15803d",800:"#166534",900:"#14532d",950:"#052e16"},emerald:{50:"#ecfdf5",100:"#d1fae5",200:"#a7f3d0",300:"#6ee7b7",400:"#34d399",500:"#10b981",600:"#059669",700:"#047857",800:"#065f46",900:"#064e3b",950:"#022c22"},teal:{50:"#f0fdfa",100:"#ccfbf1",200:"#99f6e4",300:"#5eead4",400:"#2dd4bf",500:"#14b8a6",600:"#0d9488",700:"#0f766e",800:"#115e59",900:"#134e4a",950:"#042f2e"},cyan:{50:"#ecfeff",100:"#cffafe",200:"#a5f3fc",300:"#67e8f9",400:"#22d3ee",500:"#06b6d4",600:"#0891b2",700:"#0e7490",800:"#155e75",900:"#164e63",950:"#083344"},sky:{50:"#f0f9ff",100:"#e0f2fe",200:"#bae6fd",300:"#7dd3fc",400:"#38bdf8",500:"#0ea5e9",600:"#0284c7",700:"#0369a1",800:"#075985",900:"#0c4a6e",950:"#082f49"},blue:{50:"#eff6ff",100:"#dbeafe",200:"#bfdbfe",300:"#93c5fd",400:"#60a5fa",500:"#3b82f6",600:"#2563eb",700:"#1d4ed8",800:"#1e40af",900:"#1e3a8a",950:"#172554"},indigo:{50:"#eef2ff",100:"#e0e7ff",200:"#c7d2fe",300:"#a5b4fc",400:"#818cf8",500:"#6366f1",600:"#4f46e5",700:"#4338ca",800:"#3730a3",900:"#312e81",950:"#1e1b4b"},violet:{50:"#f5f3ff",100:"#ede9fe",200:"#ddd6fe",300:"#c4b5fd",400:"#a78bfa",500:"#8b5cf6",600:"#7c3aed",700:"#6d28d9",800:"#5b21b6",900:"#4c1d95",950:"#2e1065"},purple:{50:"#faf5ff",100:"#f3e8ff",200:"#e9d5ff",300:"#d8b4fe",400:"#c084fc",500:"#a855f7",600:"#9333ea",700:"#7e22ce",800:"#6b21a8",900:"#581c87",950:"#3b0764"},fuchsia:{50:"#fdf4ff",100:"#fae8ff",200:"#f5d0fe",300:"#f0abfc",400:"#e879f9",500:"#d946ef",600:"#c026d3",700:"#a21caf",800:"#86198f",900:"#701a75",950:"#4a044e"},pink:{50:"#fdf2f8",100:"#fce7f3",200:"#fbcfe8",300:"#f9a8d4",400:"#f472b6",500:"#ec4899",600:"#db2777",700:"#be185d",800:"#9d174d",900:"#831843",950:"#500724"},rose:{50:"#fff1f2",100:"#ffe4e6",200:"#fecdd3",300:"#fda4af",400:"#fb7185",500:"#f43f5e",600:"#e11d48",700:"#be123c",800:"#9f1239",900:"#881337",950:"#4c0519"},get lightBlue(){return i({version:"v2.2",from:"lightBlue",to:"sky"}),this.sky},get warmGray(){return i({version:"v3.0",from:"warmGray",to:"stone"}),this.stone},get trueGray(){return i({version:"v3.0",from:"trueGray",to:"neutral"}),this.neutral},get coolGray(){return i({version:"v3.0",from:"coolGray",to:"gray"}),this.gray},get blueGray(){return i({version:"v3.0",from:"blueGray",to:"slate"}),this.slate}}})(lw);let Rf=lw;var ME=(Rf.__esModule?Rf:{default:Rf}).default;const Xg=hv(ME),RE=[{color:"red",primary:600,secondary:100},{color:"green",primary:600,secondary:100},{color:"blue",primary:600,secondary:100},{color:"yellow",primary:500,secondary:100},{color:"purple",primary:600,secondary:100},{color:"teal",primary:600,secondary:100},{color:"orange",primary:600,secondary:100},{color:"cyan",primary:600,secondary:100},{color:"lime",primary:500,secondary:100},{color:"pink",primary:600,secondary:100}];RE.reduce((n,{color:e,primary:t,secondary:i})=>({...n,[e]:{primary:Xg[e][t],secondary:Xg[e][i]}}),{});const PE=(n,e)=>cw[e](n[e]);function Xo(n,e){const t=e.reduce((i,s)=>(n[s]===void 0||!cw[s]?i[s]=" ":i[s]=` ${PE(n,s)} `,i),{});return t.styles=` ${Object.values(t).join(" ").replace(/\s+/g," ").trim()} `,t}const cw={container(n){return n?"":"padding: 0; margin: 0; border-width: 0; box-shadow: none; overflow: visible; background: transparent;"},label_container(n){return n?"":"border-width: 0; box-shadow: none; overflow: visible; background: transparent;"},grid_cols(n){let e=["","sm-","md-","lg-","xl-","2xl-"],t=Array.isArray(n)?n:[n];return[0,0,0,0,0,0].map((i,s)=>`--${e[s]}grid-cols: var(--grid-${(t==null?void 0:t[s])||(t==null?void 0:t[(t==null?void 0:t.length)-1])});`).join(" ")},grid_rows(n){let e=["","sm-","md-","lg-","xl-","2xl-"],t=Array.isArray(n)?n:[n];return[0,0,0,0,0,0].map((i,s)=>`--${e[s]}grid-rows: var(--grid-${(t==null?void 0:t[s])||(t==null?void 0:t[(t==null?void 0:t.length)-1])});`).join(" ")},height(n){return n==="auto"?"height: auto;":""},full_width(n){return n?"width: var(--size-full); flex-grow: 1;":"flex-grow: 0; width: fit-content;"},equal_height(n){return n?"align-items: stretch;":"align-items: flex-start;"},visible(n){return n?"":"display:hidden;"},item_container(n){return n?"":"border-width:0;"},object_fit(n){return`--object-fit: ${n};`}};function BE(n){let e,t,i,s,r;const o=n[9].default,l=De(o,n,n[8],null);return{c(){e=z("button"),l&&l.c(),v(e,"class",t=n[4]+" "+n[3]+" "+n[1].join(" ")+" svelte-1n8g1go"),v(e,"style",n[6]),v(e,"id",n[0]),e.disabled=n[5],B(e,"hide",!n[2])},m(a,u){A(a,e,u),l&&l.m(e,null),i=!0,s||(r=ee(e,"click",n[10]),s=!0)},p(a,[u]){l&&l.p&&(!i||u&256)&&Le(l,o,a,a[8],i?xe(o,a[8],u,null):Me(a[8]),null),(!i||u&26&&t!==(t=a[4]+" "+a[3]+" "+a[1].join(" ")+" svelte-1n8g1go"))&&v(e,"class",t),(!i||u&64)&&v(e,"style",a[6]),(!i||u&1)&&v(e,"id",a[0]),(!i||u&32)&&(e.disabled=a[5]),(!i||u&30)&&B(e,"hide",!a[2])},i(a){i||(S(l,a),i=!0)},o(a){C(l,a),i=!1},d(a){a&&E(e),l&&l.d(a),s=!1,r()}}}function zE(n,e,t){let i,{$$slots:s={},$$scope:r}=e,{style:o={}}=e,{elem_id:l=""}=e,{elem_classes:a=[]}=e,{visible:u=!0}=e,{variant:c="secondary"}=e,{size:f=o.size||"lg"}=e,{disabled:h=!1}=e;function d(p){Ut.call(this,n,p)}return n.$$set=p=>{"style"in p&&t(7,o=p.style),"elem_id"in p&&t(0,l=p.elem_id),"elem_classes"in p&&t(1,a=p.elem_classes),"visible"in p&&t(2,u=p.visible),"variant"in p&&t(3,c=p.variant),"size"in p&&t(4,f=p.size),"disabled"in p&&t(5,h=p.disabled),"$$scope"in p&&t(8,r=p.$$scope)},n.$$.update=()=>{n.$$.dirty&128&&t(6,{styles:i}=Xo(o,["full_width"]),i)},[l,a,u,c,f,h,i,o,r,s,d]}class Zc extends _e{constructor(e){super(),me(this,e,zE,BE,ae,{style:7,elem_id:0,elem_classes:1,visible:2,variant:3,size:4,disabled:5})}}function fw(n){for(;n!=null;){if(n.mode!==ft.ALWAYS||n.graph==null)return!0;n=n.graph._subgraph_node}return!1}function Kn(n){return n.attrs.disabled?!0:n.type==="widget"?n.attrs.nodeDisabledState==="disabled"&&fw(n.node):!1}function $n(n){return n.attrs.hidden?!0:n.type==="widget"?n.attrs.nodeDisabledState==="hidden"&&fw(n.node):!1}function FE(n,e,t="#fff"){const i=document.createElement("canvas");i.width=n,i.height=e;const s=i.getContext("2d");return s.save(),s.fillStyle=t,s.fillRect(0,0,i.width,i.height),s.restore(),i}async function Lp(n){return new Promise(e=>{const t=new Image;return t.setAttribute("crossorigin","anonymous"),t.addEventListener("load",()=>{e(t)}),t.src=n,t})}function Kg(n){let e,t;return e=new Zc({props:{disabled:Kn(n[0]),variant:n[0].attrs.buttonVariant||"primary",size:n[0].attrs.buttonSize==="small"?"sm":"lg",style:n[5],$$slots:{default:[WE]},$$scope:{ctx:n}}}),e.$on("click",n[4]),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&1&&(r.disabled=Kn(i[0])),s&1&&(r.variant=i[0].attrs.buttonVariant||"primary"),s&1&&(r.size=i[0].attrs.buttonSize==="small"?"sm":"lg"),s&257&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function WE(n){let e=n[0].attrs.title+"",t;return{c(){t=ke(e)},m(i,s){A(i,t,s)},p(i,s){s&1&&e!==(e=i[0].attrs.title+"")&&je(t,e)},d(i){i&&E(t)}}}function $g(n){let e,t,i=n[0]!==null&&n[1]!==null&&Kg(n);return{c(){i&&i.c(),e=we()},m(s,r){i&&i.m(s,r),A(s,e,r),t=!0},p(s,r){s[0]!==null&&s[1]!==null?i?(i.p(s,r),r&3&&S(i,1)):(i=Kg(s),i.c(),S(i,1),i.m(e.parentNode,e)):i&&(oe(),C(i,1,1,()=>{i=null}),le())},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d(s)}}}function VE(n){let e,t=n[3],i,s=$g(n);return{c(){e=z("div"),s.c(),v(e,"class","wrapper gradio-button svelte-b28czd")},m(r,o){A(r,e,o),s.m(e,null),i=!0},p(r,[o]){o&8&&ae(t,t=r[3])?(oe(),C(s,1,1,Z),le(),s=$g(r),s.c(),S(s,1),s.m(e,null)):s.p(r,o)},i(r){i||(S(s),i=!0)},o(r){C(s),i=!1},d(r){r&&E(e),s.d(r)}}}function HE(n,e,t){let i,s=Z,r=()=>(s(),s=ot(u,d=>t(3,i=d)),u);n.$$.on_destroy.push(()=>s());let{widget:o=null}=e,{isMobile:l=!1}=e,a=null,u=Be(0);r();function c(d){d&&(t(1,a=d.node),r(t(2,u=d.attrsChanged)))}function f(d){a.onClick(),navigator.vibrate(20)}const h={full_width:!0};return n.$$set=d=>{"widget"in d&&t(0,o=d.widget),"isMobile"in d&&t(6,l=d.isMobile)},n.$$.update=()=>{n.$$.dirty&1&&o&&c(o)},[o,a,u,i,f,h,l]}class UE extends _e{constructor(e){super(),me(this,e,HE,VE,ae,{widget:0,isMobile:6})}}class hw extends As{constructor(t){super(t,!1);P(this,"properties",{tags:[],defaultValue:!1,param:"bang"});P(this,"svelteComponentType",UE);P(this,"defaultValue",!1);P(this,"outputSlotName",null);P(this,"changedEventName",null)}parseValue(t){return!!t}onClick(){this.setValue(!0),this.triggerSlot(0,this.properties.param),this.setValue(!1)}}P(hw,"slotLayout",{outputs:[{name:"clicked",type:$.EVENT}]});w.registerNodeType({class:hw,title:"UI.Button",desc:"Button that triggers an event when clicked",type:"ui/button"});function GE(n){let e,t,i,s;const r=n[16].default,o=De(r,n,n[15],null);let l=[{"data-testid":n[5]},{id:n[0]},{class:t="block "+n[1].join(" ")+" svelte-1ievav7"},{style:i=n[9]+" "+(n[8]||null)}],a={};for(let u=0;u{"style"in k&&t(11,l=k.style),"elem_id"in k&&t(0,a=k.elem_id),"elem_classes"in k&&t(1,u=k.elem_classes),"variant"in k&&t(2,c=k.variant),"border_mode"in k&&t(3,f=k.border_mode),"padding"in k&&t(4,h=k.padding),"type"in k&&t(12,d=k.type),"test_id"in k&&t(5,p=k.test_id),"disable"in k&&t(13,g=k.disable),"explicit_call"in k&&t(14,m=k.explicit_call),"visible"in k&&t(6,_=k.visible),"allow_overflow"in k&&t(7,b=k.allow_overflow),"$$scope"in k&&t(15,o=k.$$scope)},n.$$.update=()=>{n.$$.dirty&26624&&t(9,{styles:i}=m?Xo(l,[]):g?Xo({container:!1},["container"]):{styles:""},i),n.$$.dirty&2048&&t(8,s=(typeof l.height=="number"?`height: ${l.height}px; `:"")+(typeof l.width=="number"?`width: ${l.width}px;`:""))},[a,u,c,f,h,p,_,b,s,i,y,l,d,g,m,o,r]}class yt extends _e{constructor(e){super(),me(this,e,qE,jE,ae,{style:11,elem_id:0,elem_classes:1,variant:2,border_mode:3,padding:4,type:12,test_id:5,disable:13,explicit_call:14,visible:6,allow_overflow:7})}}function YE(n){let e,t;const i=n[1].default,s=De(i,n,n[0],null);return{c(){e=z("div"),s&&s.c(),v(e,"class","svelte-1hnfib2")},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,[o]){s&&s.p&&(!t||o&1)&&Le(s,i,r,r[0],t?xe(i,r[0],o,null):Me(r[0]),null)},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function XE(n,e,t){let{$$slots:i={},$$scope:s}=e;return n.$$set=r=>{"$$scope"in r&&t(0,s=r.$$scope)},[s,i]}class KE extends _e{constructor(e){super(),me(this,e,XE,YE,ae,{})}}function Jg(n){let e,t;return e=new KE({props:{$$slots:{default:[$E]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&10&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function $E(n){let e;return{c(){e=ke(n[1])},m(t,i){A(t,e,i)},p(t,i){i&2&&je(e,t[1])},d(t){t&&E(e)}}}function JE(n){let e,t,i,s;const r=n[2].default,o=De(r,n,n[3],null);let l=n[1]&&Jg(n);return{c(){e=z("span"),o&&o.c(),t=se(),l&&l.c(),i=we(),v(e,"class","svelte-22c38v"),B(e,"sr-only",!n[0]),B(e,"hide",!n[0]),B(e,"has-info",n[1]!=null)},m(a,u){A(a,e,u),o&&o.m(e,null),A(a,t,u),l&&l.m(a,u),A(a,i,u),s=!0},p(a,[u]){o&&o.p&&(!s||u&8)&&Le(o,r,a,a[3],s?xe(r,a[3],u,null):Me(a[3]),null),(!s||u&1)&&B(e,"sr-only",!a[0]),(!s||u&1)&&B(e,"hide",!a[0]),(!s||u&2)&&B(e,"has-info",a[1]!=null),a[1]?l?(l.p(a,u),u&2&&S(l,1)):(l=Jg(a),l.c(),S(l,1),l.m(i.parentNode,i)):l&&(oe(),C(l,1,1,()=>{l=null}),le())},i(a){s||(S(o,a),S(l),s=!0)},o(a){C(o,a),C(l),s=!1},d(a){a&&(E(e),E(t),E(i)),o&&o.d(a),l&&l.d(a)}}}function ZE(n,e,t){let{$$slots:i={},$$scope:s}=e,{show_label:r=!0}=e,{info:o=void 0}=e;return n.$$set=l=>{"show_label"in l&&t(0,r=l.show_label),"info"in l&&t(1,o=l.info),"$$scope"in l&&t(3,s=l.$$scope)},[r,o,i,s]}class kn extends _e{constructor(e){super(),me(this,e,ZE,JE,ae,{show_label:0,info:1})}}function QE(n){let e,t,i,s,r,o;return i=new n[1]({}),{c(){e=z("div"),t=z("span"),Y(i.$$.fragment),s=se(),r=ke(n[0]),v(t,"class","svelte-1q6ny6"),v(e,"style",n[4]),v(e,"class","svelte-1q6ny6"),B(e,"hide",!n[2]),B(e,"sr-only",!n[2]),B(e,"float",n[3])},m(l,a){A(l,e,a),F(e,t),G(i,t,null),F(e,s),F(e,r),o=!0},p(l,[a]){(!o||a&1)&&je(r,l[0]),(!o||a&16)&&v(e,"style",l[4]),(!o||a&4)&&B(e,"hide",!l[2]),(!o||a&4)&&B(e,"sr-only",!l[2]),(!o||a&8)&&B(e,"float",l[3])},i(l){o||(S(i.$$.fragment,l),o=!0)},o(l){C(i.$$.fragment,l),o=!1},d(l){l&&E(e),j(i)}}}function eA(n,e,t){let i,{label:s=null}=e,{Icon:r}=e,{show_label:o=!0}=e,{disable:l=!1}=e,{float:a=!0}=e;return n.$$set=u=>{"label"in u&&t(0,s=u.label),"Icon"in u&&t(1,r=u.Icon),"show_label"in u&&t(2,o=u.show_label),"disable"in u&&t(5,l=u.disable),"float"in u&&t(3,a=u.float)},n.$$.update=()=>{n.$$.dirty&32&&t(4,{styles:i}=Xo({label_container:!l},["label_container"]),i)},[s,r,o,a,i,l]}class Qc extends _e{constructor(e){super(),me(this,e,eA,QE,ae,{label:0,Icon:1,show_label:2,disable:5,float:3})}}function tA(n){let e,t,i,s,r,o;return i=new n[0]({}),{c(){e=z("button"),t=z("div"),Y(i.$$.fragment),v(t,"class","svelte-uf5pl7"),v(e,"aria-label",n[1]),v(e,"class","svelte-uf5pl7")},m(l,a){A(l,e,a),F(e,t),G(i,t,null),s=!0,r||(o=ee(e,"click",n[2]),r=!0)},p(l,[a]){(!s||a&2)&&v(e,"aria-label",l[1])},i(l){s||(S(i.$$.fragment,l),s=!0)},o(l){C(i.$$.fragment,l),s=!1},d(l){l&&E(e),j(i),r=!1,o()}}}function iA(n,e,t){let{Icon:i}=e,{label:s=""}=e;function r(o){Ut.call(this,n,o)}return n.$$set=o=>{"Icon"in o&&t(0,i=o.Icon),"label"in o&&t(1,s=o.label)},[i,s,r]}class qu extends _e{constructor(e){super(),me(this,e,iA,tA,ae,{Icon:0,label:1})}}function nA(n){let e,t,i;const s=n[3].default,r=De(s,n,n[2],null);return{c(){e=z("div"),t=z("div"),r&&r.c(),v(t,"class","icon svelte-14bvguo"),v(e,"class","empty svelte-14bvguo"),B(e,"small",n[0]==="small"),B(e,"large",n[0]==="large"),B(e,"unpadded_box",n[1])},m(o,l){A(o,e,l),F(e,t),r&&r.m(t,null),i=!0},p(o,[l]){r&&r.p&&(!i||l&4)&&Le(r,s,o,o[2],i?xe(s,o[2],l,null):Me(o[2]),null),(!i||l&1)&&B(e,"small",o[0]==="small"),(!i||l&1)&&B(e,"large",o[0]==="large"),(!i||l&2)&&B(e,"unpadded_box",o[1])},i(o){i||(S(r,o),i=!0)},o(o){C(r,o),i=!1},d(o){o&&E(e),r&&r.d(o)}}}function sA(n,e,t){let{$$slots:i={},$$scope:s}=e,{size:r="small"}=e,{unpadded_box:o=!1}=e;return n.$$set=l=>{"size"in l&&t(0,r=l.size),"unpadded_box"in l&&t(1,o=l.unpadded_box),"$$scope"in l&&t(2,s=l.$$scope)},[r,o,s,i]}class Mp extends _e{constructor(e){super(),me(this,e,sA,nA,ae,{size:0,unpadded_box:1})}}function rA(n){let e,t,i,s,r,o,l;return{c(){e=z("label"),t=z("input"),i=se(),s=z("span"),r=ke(n[2]),t.disabled=n[1],v(t,"type","checkbox"),v(t,"name","test"),v(t,"data-testid","checkbox"),v(t,"class","svelte-8xl2dc"),v(s,"class","ml-2 svelte-8xl2dc"),v(e,"class","svelte-8xl2dc"),B(e,"disabled",n[1])},m(a,u){A(a,e,u),F(e,t),t.checked=n[0],F(e,i),F(e,s),F(s,r),o||(l=[ee(t,"change",n[4]),ee(t,"input",n[5])],o=!0)},p(a,[u]){u&2&&(t.disabled=a[1]),u&1&&(t.checked=a[0]),u&4&&je(r,a[2]),u&2&&B(e,"disabled",a[1])},i:Z,o:Z,d(a){a&&E(e),o=!1,lt(l)}}}function oA(n,e,t){let{value:i}=e,{disabled:s=!1}=e,{label:r}=e;const o=mi();function l(c){o("change",c)}function a(){i=this.checked,t(0,i)}const u=c=>{t(0,i=c.currentTarget.checked),o("select",{index:0,value:r,selected:c.currentTarget.checked})};return n.$$set=c=>{"value"in c&&t(0,i=c.value),"disabled"in c&&t(1,s=c.disabled),"label"in c&&t(2,r=c.label)},n.$$.update=()=>{n.$$.dirty&1&&l(i)},[i,s,r,o,a,u]}class lA extends _e{constructor(e){super(),me(this,e,oA,rA,ae,{value:0,disabled:1,label:2})}}function Rp(n){return n*n*n}function dw(n){const e=n-1;return e*e*e+1}function ef(n,{delay:e=0,duration:t=400,easing:i=Ic}={}){const s=+getComputedStyle(n).opacity;return{delay:e,duration:t,easing:i,css:r=>`opacity: ${r*s}`}}function rW(n,{delay:e=0,duration:t=400,easing:i=dw,x:s=0,y:r=0,opacity:o=0}={}){const l=getComputedStyle(n),a=+l.opacity,u=l.transform==="none"?"":l.transform,c=a*(1-o),[f,h]=Eg(s),[d,p]=Eg(r);return{delay:e,duration:t,easing:i,css:(g,m)=>` - transform: ${u} translate(${(1-g)*f}${h}, ${(1-g)*d}${p}); - opacity: ${a-c*m}`}}function aA(n){let e,t,i;return{c(){e=ze("svg"),t=ze("path"),i=ze("path"),v(t,"d","M28.828 3.172a4.094 4.094 0 0 0-5.656 0L4.05 22.292A6.954 6.954 0 0 0 2 27.242V30h2.756a6.952 6.952 0 0 0 4.95-2.05L28.828 8.829a3.999 3.999 0 0 0 0-5.657zM10.91 18.26l2.829 2.829l-2.122 2.121l-2.828-2.828zm-2.619 8.276A4.966 4.966 0 0 1 4.756 28H4v-.759a4.967 4.967 0 0 1 1.464-3.535l1.91-1.91l2.829 2.828zM27.415 7.414l-12.261 12.26l-2.829-2.828l12.262-12.26a2.047 2.047 0 0 1 2.828 0a2 2 0 0 1 0 2.828z"),v(t,"fill","currentColor"),v(i,"d","M6.5 15a3.5 3.5 0 0 1-2.475-5.974l3.5-3.5a1.502 1.502 0 0 0 0-2.121a1.537 1.537 0 0 0-2.121 0L3.415 5.394L2 3.98l1.99-1.988a3.585 3.585 0 0 1 4.95 0a3.504 3.504 0 0 1 0 4.949L5.439 10.44a1.502 1.502 0 0 0 0 2.121a1.537 1.537 0 0 0 2.122 0l4.024-4.024L13 9.95l-4.025 4.024A3.475 3.475 0 0 1 6.5 15z"),v(i,"fill","currentColor"),v(e,"width","1em"),v(e,"height","1em"),v(e,"viewBox","0 0 32 32")},m(s,r){A(s,e,r),F(e,t),F(e,i)},p:Z,i:Z,o:Z,d(s){s&&E(e)}}}class uA extends _e{constructor(e){super(),me(this,e,null,aA,ae,{})}}function cA(n){let e,t;return{c(){e=ze("svg"),t=ze("polyline"),v(t,"points","20 6 9 17 4 12"),v(e,"xmlns","http://www.w3.org/2000/svg"),v(e,"width","100%"),v(e,"height","100%"),v(e,"viewBox","0 0 24 24"),v(e,"fill","none"),v(e,"stroke","currentColor"),v(e,"stroke-width","3"),v(e,"stroke-linecap","round"),v(e,"stroke-linejoin","round")},m(i,s){A(i,e,s),F(e,t)},p:Z,i:Z,o:Z,d(i){i&&E(e)}}}class fA extends _e{constructor(e){super(),me(this,e,null,cA,ae,{})}}function hA(n){let e,t,i,s;return{c(){e=ze("svg"),t=ze("g"),i=ze("path"),s=ze("path"),v(i,"d","M18,6L6.087,17.913"),ve(i,"fill","none"),ve(i,"fill-rule","nonzero"),ve(i,"stroke-width","2px"),v(t,"transform","matrix(1.14096,-0.140958,-0.140958,1.14096,-0.0559523,0.0559523)"),v(s,"d","M4.364,4.364L19.636,19.636"),ve(s,"fill","none"),ve(s,"fill-rule","nonzero"),ve(s,"stroke-width","2px"),v(e,"width","100%"),v(e,"height","100%"),v(e,"viewBox","0 0 24 24"),v(e,"version","1.1"),v(e,"xmlns","http://www.w3.org/2000/svg"),v(e,"xmlns:xlink","http://www.w3.org/1999/xlink"),v(e,"xml:space","preserve"),v(e,"stroke","currentColor"),ve(e,"fill-rule","evenodd"),ve(e,"clip-rule","evenodd"),ve(e,"stroke-linecap","round"),ve(e,"stroke-linejoin","round")},m(r,o){A(r,e,o),F(e,t),F(t,i),F(e,s)},p:Z,i:Z,o:Z,d(r){r&&E(e)}}}class pw extends _e{constructor(e){super(),me(this,e,null,hA,ae,{})}}function dA(n){let e,t,i;return{c(){e=ze("svg"),t=ze("path"),i=ze("path"),v(t,"fill","currentColor"),v(t,"d","M28 10v18H10V10h18m0-2H10a2 2 0 0 0-2 2v18a2 2 0 0 0 2 2h18a2 2 0 0 0 2-2V10a2 2 0 0 0-2-2Z"),v(i,"fill","currentColor"),v(i,"d","M4 18H2V4a2 2 0 0 1 2-2h14v2H4Z"),v(e,"xmlns","http://www.w3.org/2000/svg"),v(e,"width","100%"),v(e,"height","100%"),v(e,"viewBox","0 0 32 32")},m(s,r){A(s,e,r),F(e,t),F(e,i)},p:Z,i:Z,o:Z,d(s){s&&E(e)}}}class pA extends _e{constructor(e){super(),me(this,e,null,dA,ae,{})}}function gA(n){let e,t;return{c(){e=ze("svg"),t=ze("path"),v(t,"fill","currentColor"),v(t,"d","M26 24v4H6v-4H4v4a2 2 0 0 0 2 2h20a2 2 0 0 0 2-2v-4zm0-10l-1.41-1.41L17 20.17V2h-2v18.17l-7.59-7.58L6 14l10 10l10-10z"),v(e,"xmlns","http://www.w3.org/2000/svg"),v(e,"width","100%"),v(e,"height","100%"),v(e,"viewBox","0 0 32 32")},m(i,s){A(i,e,s),F(e,t)},p:Z,i:Z,o:Z,d(i){i&&E(e)}}}class mA extends _e{constructor(e){super(),me(this,e,null,gA,ae,{})}}function _A(n){let e,t;return{c(){e=ze("svg"),t=ze("path"),v(t,"d","M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"),v(e,"xmlns","http://www.w3.org/2000/svg"),v(e,"width","100%"),v(e,"height","100%"),v(e,"viewBox","0 0 24 24"),v(e,"fill","none"),v(e,"stroke","currentColor"),v(e,"stroke-width","1.5"),v(e,"stroke-linecap","round"),v(e,"stroke-linejoin","round"),v(e,"class","feather feather-edit-2")},m(i,s){A(i,e,s),F(e,t)},p:Z,i:Z,o:Z,d(i){i&&E(e)}}}class bA extends _e{constructor(e){super(),me(this,e,null,_A,ae,{})}}function yA(n){let e,t,i;return{c(){e=ze("svg"),t=ze("path"),i=ze("polyline"),v(t,"d","M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"),v(i,"points","13 2 13 9 20 9"),v(e,"xmlns","http://www.w3.org/2000/svg"),v(e,"width","100%"),v(e,"height","100%"),v(e,"viewBox","0 0 24 24"),v(e,"fill","none"),v(e,"stroke","currentColor"),v(e,"stroke-width","1.5"),v(e,"stroke-linecap","round"),v(e,"stroke-linejoin","round"),v(e,"class","feather feather-file")},m(s,r){A(s,e,r),F(e,t),F(e,i)},p:Z,i:Z,o:Z,d(s){s&&E(e)}}}let vA=class extends _e{constructor(e){super(),me(this,e,null,yA,ae,{})}};function wA(n){let e,t,i,s;return{c(){e=ze("svg"),t=ze("rect"),i=ze("circle"),s=ze("polyline"),v(t,"x","3"),v(t,"y","3"),v(t,"width","18"),v(t,"height","18"),v(t,"rx","2"),v(t,"ry","2"),v(i,"cx","8.5"),v(i,"cy","8.5"),v(i,"r","1.5"),v(s,"points","21 15 16 10 5 21"),v(e,"xmlns","http://www.w3.org/2000/svg"),v(e,"width","100%"),v(e,"height","100%"),v(e,"viewBox","0 0 24 24"),v(e,"fill","none"),v(e,"stroke","currentColor"),v(e,"stroke-width","1.5"),v(e,"stroke-linecap","round"),v(e,"stroke-linejoin","round"),v(e,"class","feather feather-image")},m(r,o){A(r,e,o),F(e,t),F(e,i),F(e,s)},p:Z,i:Z,o:Z,d(r){r&&E(e)}}}let fa=class extends _e{constructor(e){super(),me(this,e,null,wA,ae,{})}};function kA(n){let e,t;return{c(){e=ze("svg"),t=ze("path"),v(t,"fill","currentColor"),v(t,"d","M5 3h2v2H5v5a2 2 0 0 1-2 2a2 2 0 0 1 2 2v5h2v2H5c-1.07-.27-2-.9-2-2v-4a2 2 0 0 0-2-2H0v-2h1a2 2 0 0 0 2-2V5a2 2 0 0 1 2-2m14 0a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2h1v2h-1a2 2 0 0 0-2 2v4a2 2 0 0 1-2 2h-2v-2h2v-5a2 2 0 0 1 2-2a2 2 0 0 1-2-2V5h-2V3h2m-7 12a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1m-4 0a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1m8 0a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1Z"),v(e,"xmlns","http://www.w3.org/2000/svg"),v(e,"xmlns:xlink","http://www.w3.org/1999/xlink"),v(e,"aria-hidden","true"),v(e,"role","img"),v(e,"class","iconify iconify--mdi"),v(e,"width","100%"),v(e,"height","100%"),v(e,"preserveAspectRatio","xMidYMid meet"),v(e,"viewBox","0 0 24 24")},m(i,s){A(i,e,s),F(e,t)},p:Z,i:Z,o:Z,d(i){i&&E(e)}}}let SA=class extends _e{constructor(e){super(),me(this,e,null,kA,ae,{})}};function Zg(n,e,t){const i=n.slice();return i[13]=e[t],i[15]=t,i}function TA(n){let e;return{c(){e=ke(n[3])},m(t,i){A(t,e,i)},p(t,i){i&8&&je(e,t[3])},d(t){t&&E(e)}}}function Qg(n,e){let t,i,s,r,o=!1,l,a,u=e[13]+"",c,f,h,d,p;function g(){return e[12](e[13],e[15])}return h=tC(e[11][0]),{key:n,first:null,c(){t=z("label"),i=z("input"),l=se(),a=z("span"),c=ke(u),f=se(),i.disabled=e[2],v(i,"type","radio"),v(i,"name",s="radio-"+e[6]),i.__value=r=e[13],Bt(i,i.__value),v(i,"class","svelte-1vn8q55"),v(a,"class","ml-2 svelte-1vn8q55"),v(t,"style",e[7]),v(t,"class","svelte-1vn8q55"),B(t,"disabled",e[2]),B(t,"selected",e[0]===e[13]),h.p(i),this.first=t},m(m,_){A(m,t,_),F(t,i),i.checked=i.__value===e[0],F(t,l),F(t,a),F(a,c),F(t,f),d||(p=[ee(i,"change",e[10]),ee(i,"input",g)],d=!0)},p(m,_){e=m,_&4&&(i.disabled=e[2]),_&64&&s!==(s="radio-"+e[6])&&v(i,"name",s),_&2&&r!==(r=e[13])&&(i.__value=r,Bt(i,i.__value),o=!0),(o||_&3)&&(i.checked=i.__value===e[0]),_&2&&u!==(u=e[13]+"")&&je(c,u),_&128&&v(t,"style",e[7]),_&4&&B(t,"disabled",e[2]),_&3&&B(t,"selected",e[0]===e[13])},d(m){m&&E(t),h.r(),d=!1,lt(p)}}}function CA(n){let e,t,i,s=[],r=new Map,o;e=new kn({props:{show_label:n[5],info:n[4],$$slots:{default:[TA]},$$scope:{ctx:n}}});let l=Xe(n[1]);const a=u=>u[15];for(let u=0;uh("select",{value:m,index:_});return n.$$set=m=>{"value"in m&&t(0,s=m.value),"style"in m&&t(9,r=m.style),"choices"in m&&t(1,o=m.choices),"disabled"in m&&t(2,l=m.disabled),"label"in m&&t(3,a=m.label),"info"in m&&t(4,u=m.info),"show_label"in m&&t(5,c=m.show_label),"elem_id"in m&&t(6,f=m.elem_id)},n.$$.update=()=>{n.$$.dirty&1&&h("change",s),n.$$.dirty&512&&t(7,{item_container:i}=Xo(r,["item_container"]),i)},[s,o,l,a,u,c,f,i,h,r,p,d,g]}class EA extends _e{constructor(e){super(),me(this,e,IA,CA,ae,{value:0,style:9,choices:1,disabled:2,label:3,info:4,show_label:5,elem_id:6})}}function AA(n){let e;return{c(){e=ke(n[3])},m(t,i){A(t,e,i)},p(t,i){i&8&&je(e,t[3])},d(t){t&&E(e)}}}function OA(n){let e,t,i,s,r,o,l=n[6]&&n[9].show_copy_button&&em(n);return{c(){l&&l.c(),e=se(),t=z("textarea"),v(t,"data-testid","textbox"),v(t,"class","scroll-hide svelte-13rodre"),v(t,"placeholder",n[2]),v(t,"rows",n[1]),t.disabled=n[5]},m(a,u){l&&l.m(a,u),A(a,e,u),A(a,t,u),Bt(t,n[0]),n[24](t),s=!0,r||(o=[_r(i=n[16].call(null,t,n[0])),ee(t,"input",n[23]),ee(t,"keypress",n[15]),ee(t,"blur",n[12]),ee(t,"select",n[14])],r=!0)},p(a,u){a[6]&&a[9].show_copy_button?l?(l.p(a,u),u&576&&S(l,1)):(l=em(a),l.c(),S(l,1),l.m(e.parentNode,e)):l&&(oe(),C(l,1,1,()=>{l=null}),le()),(!s||u&4)&&v(t,"placeholder",a[2]),(!s||u&2)&&v(t,"rows",a[1]),(!s||u&32)&&(t.disabled=a[5]),i&&Xn(i.update)&&u&1&&i.update.call(null,a[0]),u&1&&Bt(t,a[0])},i(a){s||(S(l),s=!0)},o(a){C(l),s=!1},d(a){a&&(E(e),E(t)),l&&l.d(a),n[24](null),r=!1,lt(o)}}}function NA(n){let e;function t(r,o){if(r[8]==="text")return RA;if(r[8]==="password")return MA;if(r[8]==="email")return LA}let i=t(n),s=i&&i(n);return{c(){s&&s.c(),e=we()},m(r,o){s&&s.m(r,o),A(r,e,o)},p(r,o){i===(i=t(r))&&s?s.p(r,o):(s&&s.d(1),s=i&&i(r),s&&(s.c(),s.m(e.parentNode,e)))},i:Z,o:Z,d(r){r&&E(e),s&&s.d(r)}}}function em(n){let e,t,i,s;const r=[xA,DA],o=[];function l(a,u){return a[11]?0:1}return e=l(n),t=o[e]=r[e](n),{c(){t.c(),i=we()},m(a,u){o[e].m(a,u),A(a,i,u),s=!0},p(a,u){let c=e;e=l(a),e===c?o[e].p(a,u):(oe(),C(o[c],1,1,()=>{o[c]=null}),le(),t=o[e],t?t.p(a,u):(t=o[e]=r[e](a),t.c()),S(t,1),t.m(i.parentNode,i))},i(a){s||(S(t),s=!0)},o(a){C(t),s=!1},d(a){a&&E(i),o[e].d(a)}}}function DA(n){let e,t,i,s,r;return t=new pA({}),{c(){e=z("button"),Y(t.$$.fragment),v(e,"class","copy-text svelte-13rodre")},m(o,l){A(o,e,l),G(t,e,null),i=!0,s||(r=ee(e,"click",n[13]),s=!0)},p:Z,i(o){i||(S(t.$$.fragment,o),i=!0)},o(o){C(t.$$.fragment,o),i=!1},d(o){o&&E(e),j(t),s=!1,r()}}}function xA(n){let e,t,i,s;return t=new fA({}),{c(){e=z("button"),Y(t.$$.fragment),v(e,"class","svelte-13rodre")},m(r,o){A(r,e,o),G(t,e,null),s=!0},p:Z,i(r){s||(S(t.$$.fragment,r),r&&(i||vn(()=>{i=Ec(e,ef,{duration:300}),i.start()})),s=!0)},o(r){C(t.$$.fragment,r),s=!1},d(r){r&&E(e),j(t)}}}function LA(n){let e,t,i;return{c(){e=z("input"),v(e,"data-testid","textbox"),v(e,"type","email"),v(e,"class","scroll-hide svelte-13rodre"),v(e,"placeholder",n[2]),e.disabled=n[5],v(e,"autocomplete","email")},m(s,r){A(s,e,r),Bt(e,n[0]),n[22](e),t||(i=[ee(e,"input",n[21]),ee(e,"keypress",n[15]),ee(e,"blur",n[12]),ee(e,"select",n[14])],t=!0)},p(s,r){r&4&&v(e,"placeholder",s[2]),r&32&&(e.disabled=s[5]),r&1&&e.value!==s[0]&&Bt(e,s[0])},d(s){s&&E(e),n[22](null),t=!1,lt(i)}}}function MA(n){let e,t,i;return{c(){e=z("input"),v(e,"data-testid","password"),v(e,"type","password"),v(e,"class","scroll-hide svelte-13rodre"),v(e,"placeholder",n[2]),e.disabled=n[5],v(e,"autocomplete","")},m(s,r){A(s,e,r),Bt(e,n[0]),n[20](e),t||(i=[ee(e,"input",n[19]),ee(e,"keypress",n[15]),ee(e,"blur",n[12]),ee(e,"select",n[14])],t=!0)},p(s,r){r&4&&v(e,"placeholder",s[2]),r&32&&(e.disabled=s[5]),r&1&&e.value!==s[0]&&Bt(e,s[0])},d(s){s&&E(e),n[20](null),t=!1,lt(i)}}}function RA(n){let e,t,i;return{c(){e=z("input"),v(e,"data-testid","textbox"),v(e,"type","text"),v(e,"class","scroll-hide svelte-13rodre"),v(e,"placeholder",n[2]),e.disabled=n[5]},m(s,r){A(s,e,r),Bt(e,n[0]),n[18](e),t||(i=[ee(e,"input",n[17]),ee(e,"keypress",n[15]),ee(e,"blur",n[12]),ee(e,"select",n[14])],t=!0)},p(s,r){r&4&&v(e,"placeholder",s[2]),r&32&&(e.disabled=s[5]),r&1&&e.value!==s[0]&&Bt(e,s[0])},d(s){s&&E(e),n[18](null),t=!1,lt(i)}}}function PA(n){let e,t,i,s,r,o;t=new kn({props:{show_label:n[6],info:n[4],$$slots:{default:[AA]},$$scope:{ctx:n}}});const l=[NA,OA],a=[];function u(c,f){return c[1]===1&&c[7]===1?0:1}return s=u(n),r=a[s]=l[s](n),{c(){e=z("label"),Y(t.$$.fragment),i=se(),r.c(),v(e,"class","svelte-13rodre")},m(c,f){A(c,e,f),G(t,e,null),F(e,i),a[s].m(e,null),o=!0},p(c,[f]){const h={};f&64&&(h.show_label=c[6]),f&16&&(h.info=c[4]),f&1073741832&&(h.$$scope={dirty:f,ctx:c}),t.$set(h);let d=s;s=u(c),s===d?a[s].p(c,f):(oe(),C(a[d],1,1,()=>{a[d]=null}),le(),r=a[s],r?r.p(c,f):(r=a[s]=l[s](c),r.c()),S(r,1),r.m(e,null))},i(c){o||(S(t.$$.fragment,c),S(r),o=!0)},o(c){C(t.$$.fragment,c),C(r),o=!1},d(c){c&&E(e),j(t),a[s].d()}}}function BA(n,e,t){let{value:i=""}=e,{lines:s=1}=e,{placeholder:r="Type here..."}=e,{label:o}=e,{info:l=void 0}=e,{disabled:a=!1}=e,{show_label:u=!0}=e,{max_lines:c}=e,{type:f="text"}=e,{style:h={}}=e,d,p=!1,g;const m=mi();function _(K){m("change",K)}function b(){m("blur")}async function y(){"clipboard"in navigator&&(await navigator.clipboard.writeText(i),k())}function k(){t(11,p=!0),g&&clearTimeout(g),g=setTimeout(()=>{t(11,p=!1)},1e3)}function T(K){const Q=K.target,J=Q.value,ce=[Q.selectionStart,Q.selectionEnd];m("select",{value:J.substring(...ce),index:ce})}async function I(K){await yr(),(K.key==="Enter"&&K.shiftKey&&s>1||K.key==="Enter"&&!K.shiftKey&&s===1&&c>=1)&&(K.preventDefault(),m("submit"))}async function x(K){if(await yr(),s===c)return;let Q=c===!1?!1:c===void 0?21*11:21*(c+1),J=21*(s+1);const ce=K.target;ce.style.height="1px";let pe;Q&&ce.scrollHeight>Q?pe=Q:ce.scrollHeightK.removeEventListener("input",x)}}function N(){i=this.value,t(0,i)}function O(K){Ze[K?"unshift":"push"](()=>{d=K,t(10,d)})}function D(){i=this.value,t(0,i)}function M(K){Ze[K?"unshift":"push"](()=>{d=K,t(10,d)})}function L(){i=this.value,t(0,i)}function V(K){Ze[K?"unshift":"push"](()=>{d=K,t(10,d)})}function X(){i=this.value,t(0,i)}function q(K){Ze[K?"unshift":"push"](()=>{d=K,t(10,d)})}return n.$$set=K=>{"value"in K&&t(0,i=K.value),"lines"in K&&t(1,s=K.lines),"placeholder"in K&&t(2,r=K.placeholder),"label"in K&&t(3,o=K.label),"info"in K&&t(4,l=K.info),"disabled"in K&&t(5,a=K.disabled),"show_label"in K&&t(6,u=K.show_label),"max_lines"in K&&t(7,c=K.max_lines),"type"in K&&t(8,f=K.type),"style"in K&&t(9,h=K.style)},n.$$.update=()=>{n.$$.dirty&1155&&d&&s!==c&&x({target:d}),n.$$.dirty&1&&_(i)},[i,s,r,o,l,a,u,c,f,h,d,p,b,y,T,I,R,N,O,D,M,L,V,X,q]}class dr extends _e{constructor(e){super(),me(this,e,BA,PA,ae,{value:0,lines:1,placeholder:2,label:3,info:4,disabled:5,show_label:6,max_lines:7,type:8,style:9})}}function zA(n){let e;return{c(){e=ke(n[5])},m(t,i){A(t,e,i)},p(t,i){i&32&&je(e,t[5])},d(t){t&&E(e)}}}function FA(n){let e,t,i,s,r,o,l,a,u,c,f;return s=new kn({props:{show_label:n[7],info:n[6],$$slots:{default:[zA]},$$scope:{ctx:n}}}),{c(){e=z("div"),t=z("div"),i=z("label"),Y(s.$$.fragment),r=se(),o=z("input"),l=se(),a=z("input"),v(i,"for",n[8]),v(o,"data-testid","number-input"),v(o,"type","number"),v(o,"min",n[1]),v(o,"max",n[2]),v(o,"step",n[3]),o.disabled=n[4],v(o,"class","svelte-1jg56fs"),v(t,"class","head svelte-1jg56fs"),v(e,"class","wrap svelte-1jg56fs"),v(a,"type","range"),v(a,"id",n[8]),v(a,"name","cowbell"),v(a,"min",n[1]),v(a,"max",n[2]),v(a,"step",n[3]),a.disabled=n[4],v(a,"class","svelte-1jg56fs")},m(h,d){A(h,e,d),F(e,t),F(t,i),G(s,i,null),F(t,r),F(t,o),Bt(o,n[0]),A(h,l,d),A(h,a,d),Bt(a,n[0]),u=!0,c||(f=[ee(o,"input",n[11]),ee(o,"blur",n[10]),ee(o,"mouseup",n[9]),ee(a,"change",n[12]),ee(a,"input",n[12]),ee(a,"mouseup",n[9])],c=!0)},p(h,[d]){const p={};d&128&&(p.show_label=h[7]),d&64&&(p.info=h[6]),d&16416&&(p.$$scope={dirty:d,ctx:h}),s.$set(p),(!u||d&2)&&v(o,"min",h[1]),(!u||d&4)&&v(o,"max",h[2]),(!u||d&8)&&v(o,"step",h[3]),(!u||d&16)&&(o.disabled=h[4]),d&1&&br(o.value)!==h[0]&&Bt(o,h[0]),(!u||d&2)&&v(a,"min",h[1]),(!u||d&4)&&v(a,"max",h[2]),(!u||d&8)&&v(a,"step",h[3]),(!u||d&16)&&(a.disabled=h[4]),d&1&&Bt(a,h[0])},i(h){u||(S(s.$$.fragment,h),u=!0)},o(h){C(s.$$.fragment,h),u=!1},d(h){h&&(E(e),E(l),E(a)),j(s),c=!1,lt(f)}}}let WA=0;function VA(n,e,t){let{value:i=0}=e,{minimum:s=0}=e,{maximum:r=100}=e,{step:o=1}=e,{disabled:l=!1}=e,{label:a}=e,{info:u=void 0}=e,{show_label:c}=e;const f=`range_id_${WA++}`,h=mi();function d(_){h("release",i)}const p=()=>{h("release",i),t(0,i=Math.min(Math.max(i,s),r))};function g(){i=br(this.value),t(0,i)}function m(){i=br(this.value),t(0,i)}return n.$$set=_=>{"value"in _&&t(0,i=_.value),"minimum"in _&&t(1,s=_.minimum),"maximum"in _&&t(2,r=_.maximum),"step"in _&&t(3,o=_.step),"disabled"in _&&t(4,l=_.disabled),"label"in _&&t(5,a=_.label),"info"in _&&t(6,u=_.info),"show_label"in _&&t(7,c=_.show_label)},n.$$.update=()=>{n.$$.dirty&1&&h("change",i)},[i,s,r,o,l,a,u,c,f,d,p,g,m]}let Ko=class extends _e{constructor(e){super(),me(this,e,VA,FA,ae,{value:0,minimum:1,maximum:2,step:3,disabled:4,label:5,info:6,show_label:7})}};function tm(n){let e,t;return e=new yt({props:{$$slots:{default:[HA]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&529&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function HA(n){let e,t;return e=new lA({props:{disabled:Kn(n[0]),label:n[0].attrs.title,value:n[4]}}),e.$on("select",n[6]),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&1&&(r.disabled=Kn(i[0])),s&1&&(r.label=i[0].attrs.title),s&16&&(r.value=i[4]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function im(n){let e,t,i=n[1]!==null&&tm(n);return{c(){i&&i.c(),e=we()},m(s,r){i&&i.m(s,r),A(s,e,r),t=!0},p(s,r){s[1]!==null?i?(i.p(s,r),r&2&&S(i,1)):(i=tm(s),i.c(),S(i,1),i.m(e.parentNode,e)):i&&(oe(),C(i,1,1,()=>{i=null}),le())},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d(s)}}}function UA(n){let e,t,i=n[5],s,r=im(n);return{c(){e=z("div"),t=z("div"),r.c(),v(t,"class","inner svelte-8q271n"),v(e,"class","wrapper gradio-checkbox svelte-8q271n")},m(o,l){A(o,e,l),F(e,t),r.m(t,null),s=!0},p(o,[l]){l&32&&ae(i,i=o[5])?(oe(),C(r,1,1,Z),le(),r=im(o),r.c(),S(r,1),r.m(t,null)):r.p(o,l)},i(o){s||(S(r),s=!0)},o(o){C(r),s=!1},d(o){o&&E(e),r.d(o)}}}function GA(n,e,t){let i,s=Z,r=()=>(s(),s=ot(h,m=>t(4,i=m)),h),o,l=Z,a=()=>(l(),l=ot(d,m=>t(5,o=m)),d);n.$$.on_destroy.push(()=>s()),n.$$.on_destroy.push(()=>l());let{widget:u=null}=e,{isMobile:c=!1}=e,f=null,h=null;r();let d=null;a();function p(m){m&&(t(1,f=m.node),r(t(2,h=f.value)),a(t(3,d=m.attrsChanged)))}function g(m){pi(h,i=m.detail.selected,i),navigator.vibrate(20)}return n.$$set=m=>{"widget"in m&&t(0,u=m.widget),"isMobile"in m&&t(7,c=m.isMobile)},n.$$.update=()=>{n.$$.dirty&1&&u&&p(u)},[u,f,h,d,i,o,g,c]}class jA extends _e{constructor(e){super(),me(this,e,GA,UA,ae,{widget:0,isMobile:7})}}class gw extends As{constructor(t){super(t,!1);P(this,"properties",{tags:[],defaultValue:!1});P(this,"svelteComponentType",jA);P(this,"defaultValue",!1)}parseValue(t){return!!t}}P(gw,"slotLayout",{inputs:[{name:"store",type:$.ACTION}],outputs:[{name:"value",type:"boolean"},{name:"changed",type:$.EVENT}]});w.registerNodeType({class:gw,title:"UI.Checkbox",desc:"Checkbox that stores a boolean value",type:"ui/checkbox"});function tf(n){return n.split("-")[1]}function mw(n){return n==="y"?"height":"width"}function Yr(n){return n.split("-")[0]}function nf(n){return["top","bottom"].includes(Yr(n))?"x":"y"}function nm(n,e,t){let{reference:i,floating:s}=n;const r=i.x+i.width/2-s.width/2,o=i.y+i.height/2-s.height/2,l=nf(e),a=mw(l),u=i[a]/2-s[a]/2,c=l==="x";let f;switch(Yr(e)){case"top":f={x:r,y:i.y-s.height};break;case"bottom":f={x:r,y:i.y+i.height};break;case"right":f={x:i.x+i.width,y:o};break;case"left":f={x:i.x-s.width,y:o};break;default:f={x:i.x,y:i.y}}switch(tf(e)){case"start":f[l]-=u*(t&&c?-1:1);break;case"end":f[l]+=u*(t&&c?-1:1)}return f}const qA=async(n,e,t)=>{const{placement:i="bottom",strategy:s="absolute",middleware:r=[],platform:o}=t,l=r.filter(Boolean),a=await(o.isRTL==null?void 0:o.isRTL(e));let u=await o.getElementRects({reference:n,floating:e,strategy:s}),{x:c,y:f}=nm(u,i,a),h=i,d={},p=0;for(let g=0;gn.concat(e,e+"-start",e+"-end"),[]);const JA={left:"right",right:"left",bottom:"top",top:"bottom"};function Xu(n){return n.replace(/left|right|bottom|top/g,e=>JA[e])}function ZA(n,e,t){t===void 0&&(t=!1);const i=tf(n),s=nf(n),r=mw(s);let o=s==="x"?i===(t?"end":"start")?"right":"left":i==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(o=Xu(o)),{main:o,cross:Xu(o)}}const QA={start:"end",end:"start"};function Pf(n){return n.replace(/start|end/g,e=>QA[e])}const eO=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t;const{placement:i,middlewareData:s,rects:r,initialPlacement:o,platform:l,elements:a}=e,{mainAxis:u=!0,crossAxis:c=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:d="none",flipAlignment:p=!0,...g}=sf(n,e),m=Yr(i),_=Yr(o)===o,b=await(l.isRTL==null?void 0:l.isRTL(a.floating)),y=f||(_||!p?[Xu(o)]:function(D){const M=Xu(D);return[Pf(D),M,Pf(M)]}(o));f||d==="none"||y.push(...function(D,M,L,V){const X=tf(D);let q=function(K,Q,J){const ce=["left","right"],pe=["right","left"],qe=["top","bottom"],Ae=["bottom","top"];switch(K){case"top":case"bottom":return J?Q?pe:ce:Q?ce:pe;case"left":case"right":return Q?qe:Ae;default:return[]}}(Yr(D),L==="start",V);return X&&(q=q.map(K=>K+"-"+X),M&&(q=q.concat(q.map(Pf)))),q}(o,p,d,b));const k=[o,...y],T=await _w(e,g),I=[];let x=((t=s.flip)==null?void 0:t.overflows)||[];if(u&&I.push(T[m]),c){const{main:D,cross:M}=ZA(i,r,b);I.push(T[D],T[M])}if(x=[...x,{placement:i,overflows:I}],!I.every(D=>D<=0)){var R,N;const D=(((R=s.flip)==null?void 0:R.index)||0)+1,M=k[D];if(M)return{data:{index:D,overflows:x},reset:{placement:M}};let L=(N=x.filter(V=>V.overflows[0]<=0).sort((V,X)=>V.overflows[1]-X.overflows[1])[0])==null?void 0:N.placement;if(!L)switch(h){case"bestFit":{var O;const V=(O=x.map(X=>[X.placement,X.overflows.filter(q=>q>0).reduce((q,K)=>q+K,0)]).sort((X,q)=>X[1]-q[1])[0])==null?void 0:O[0];V&&(L=V);break}case"initialPlacement":L=o}if(i!==L)return{reset:{placement:L}}}return{}}}},tO=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){const{x:t,y:i}=e,s=await async function(r,o){const{placement:l,platform:a,elements:u}=r,c=await(a.isRTL==null?void 0:a.isRTL(u.floating)),f=Yr(l),h=tf(l),d=nf(l)==="x",p=["left","top"].includes(f)?-1:1,g=c&&d?-1:1,m=sf(o,r);let{mainAxis:_,crossAxis:b,alignmentAxis:y}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...m};return h&&typeof y=="number"&&(b=h==="end"?-1*y:y),d?{x:b*g,y:_*p}:{x:_*p,y:b*g}}(e,n);return{x:t+s.x,y:i+s.y,data:s}}}};function iO(n){return n==="x"?"y":"x"}const nO=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:i,placement:s}=e,{mainAxis:r=!0,crossAxis:o=!1,limiter:l={fn:m=>{let{x:_,y:b}=m;return{x:_,y:b}}},...a}=sf(n,e),u={x:t,y:i},c=await _w(e,a),f=nf(Yr(s)),h=iO(f);let d=u[f],p=u[h];if(r){const m=f==="y"?"bottom":"right";d=sm(d+c[f==="y"?"top":"left"],d,d-c[m])}if(o){const m=h==="y"?"bottom":"right";p=sm(p+c[h==="y"?"top":"left"],p,p-c[m])}const g=l.fn({...e,[f]:d,[h]:p});return{...g,data:{x:g.x-t,y:g.y-i}}}}};function qn(n){var e;return((e=n.ownerDocument)==null?void 0:e.defaultView)||window}function ls(n){return qn(n).getComputedStyle(n)}function bw(n){return n instanceof qn(n).Node}function kr(n){return bw(n)?(n.nodeName||"").toLowerCase():"#document"}function as(n){return n instanceof qn(n).HTMLElement}function Ws(n){return n instanceof qn(n).Element}function rm(n){return typeof ShadowRoot<"u"&&(n instanceof qn(n).ShadowRoot||n instanceof ShadowRoot)}function Xl(n){const{overflow:e,overflowX:t,overflowY:i,display:s}=ls(n);return/auto|scroll|overlay|hidden|clip/.test(e+i+t)&&!["inline","contents"].includes(s)}function sO(n){return["table","td","th"].includes(kr(n))}function Hh(n){const e=Pp(),t=ls(n);return t.transform!=="none"||t.perspective!=="none"||!e&&!!t.backdropFilter&&t.backdropFilter!=="none"||!e&&!!t.filter&&t.filter!=="none"||["transform","perspective","filter"].some(i=>(t.willChange||"").includes(i))||["paint","layout","strict","content"].some(i=>(t.contain||"").includes(i))}function Pp(){return!(typeof CSS>"u"||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}function rf(n){return["html","body","#document"].includes(kr(n))}const Uh=Math.min,Ro=Math.max,Ku=Math.round,Da=Math.floor,Zr=n=>({x:n,y:n});function yw(n){const e=ls(n);let t=parseFloat(e.width)||0,i=parseFloat(e.height)||0;const s=as(n),r=s?n.offsetWidth:t,o=s?n.offsetHeight:i,l=Ku(t)!==r||Ku(i)!==o;return l&&(t=r,i=o),{width:t,height:i,$:l}}function Bp(n){return Ws(n)?n:n.contextElement}function Po(n){const e=Bp(n);if(!as(e))return Zr(1);const t=e.getBoundingClientRect(),{width:i,height:s,$:r}=yw(e);let o=(r?Ku(t.width):t.width)/i,l=(r?Ku(t.height):t.height)/s;return o&&Number.isFinite(o)||(o=1),l&&Number.isFinite(l)||(l=1),{x:o,y:l}}const om=Zr(0);function vw(n,e,t){var i,s;if(e===void 0&&(e=!0),!Pp())return om;const r=n?qn(n):window;return!t||e&&t!==r?om:{x:((i=r.visualViewport)==null?void 0:i.offsetLeft)||0,y:((s=r.visualViewport)==null?void 0:s.offsetTop)||0}}function Qr(n,e,t,i){e===void 0&&(e=!1),t===void 0&&(t=!1);const s=n.getBoundingClientRect(),r=Bp(n);let o=Zr(1);e&&(i?Ws(i)&&(o=Po(i)):o=Po(n));const l=vw(r,t,i);let a=(s.left+l.x)/o.x,u=(s.top+l.y)/o.y,c=s.width/o.x,f=s.height/o.y;if(r){const h=qn(r),d=i&&Ws(i)?qn(i):i;let p=h.frameElement;for(;p&&i&&d!==h;){const g=Po(p),m=p.getBoundingClientRect(),_=getComputedStyle(p),b=m.left+(p.clientLeft+parseFloat(_.paddingLeft))*g.x,y=m.top+(p.clientTop+parseFloat(_.paddingTop))*g.y;a*=g.x,u*=g.y,c*=g.x,f*=g.y,a+=b,u+=y,p=qn(p).frameElement}}return Yu({width:c,height:f,x:a,y:u})}function Vs(n){return((bw(n)?n.ownerDocument:n.document)||window.document).documentElement}function of(n){return Ws(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function ww(n){return Qr(Vs(n)).left+of(n).scrollLeft}function $o(n){if(kr(n)==="html")return n;const e=n.assignedSlot||n.parentNode||rm(n)&&n.host||Vs(n);return rm(e)?e.host:e}function kw(n){const e=$o(n);return rf(e)?n.ownerDocument?n.ownerDocument.body:n.body:as(e)&&Xl(e)?e:kw(e)}function $u(n,e){var t;e===void 0&&(e=[]);const i=kw(n),s=i===((t=n.ownerDocument)==null?void 0:t.body),r=qn(i);return s?e.concat(r,r.visualViewport||[],Xl(i)?i:[]):e.concat(i,$u(i))}function lm(n,e,t){let i;if(e==="viewport")i=function(s,r){const o=qn(s),l=Vs(s),a=o.visualViewport;let u=l.clientWidth,c=l.clientHeight,f=0,h=0;if(a){u=a.width,c=a.height;const d=Pp();(!d||d&&r==="fixed")&&(f=a.offsetLeft,h=a.offsetTop)}return{width:u,height:c,x:f,y:h}}(n,t);else if(e==="document")i=function(s){const r=Vs(s),o=of(s),l=s.ownerDocument.body,a=Ro(r.scrollWidth,r.clientWidth,l.scrollWidth,l.clientWidth),u=Ro(r.scrollHeight,r.clientHeight,l.scrollHeight,l.clientHeight);let c=-o.scrollLeft+ww(s);const f=-o.scrollTop;return ls(l).direction==="rtl"&&(c+=Ro(r.clientWidth,l.clientWidth)-a),{width:a,height:u,x:c,y:f}}(Vs(n));else if(Ws(e))i=function(s,r){const o=Qr(s,!0,r==="fixed"),l=o.top+s.clientTop,a=o.left+s.clientLeft,u=as(s)?Po(s):Zr(1);return{width:s.clientWidth*u.x,height:s.clientHeight*u.y,x:a*u.x,y:l*u.y}}(e,t);else{const s=vw(n);i={...e,x:e.x-s.x,y:e.y-s.y}}return Yu(i)}function Sw(n,e){const t=$o(n);return!(t===e||!Ws(t)||rf(t))&&(ls(t).position==="fixed"||Sw(t,e))}function am(n,e){return as(n)&&ls(n).position!=="fixed"?e?e(n):n.offsetParent:null}function um(n,e){const t=qn(n);if(!as(n))return t;let i=am(n,e);for(;i&&sO(i)&&ls(i).position==="static";)i=am(i,e);return i&&(kr(i)==="html"||kr(i)==="body"&&ls(i).position==="static"&&!Hh(i))?t:i||function(s){let r=$o(s);for(;as(r)&&!rf(r);){if(Hh(r))return r;r=$o(r)}return null}(n)||t}function rO(n,e,t){const i=as(e),s=Vs(e),r=t==="fixed",o=Qr(n,!0,r,e);let l={scrollLeft:0,scrollTop:0};const a=Zr(0);if(i||!i&&!r)if((kr(e)!=="body"||Xl(s))&&(l=of(e)),as(e)){const u=Qr(e,!0,r,e);a.x=u.x+e.clientLeft,a.y=u.y+e.clientTop}else s&&(a.x=ww(s));return{x:o.left+l.scrollLeft-a.x,y:o.top+l.scrollTop-a.y,width:o.width,height:o.height}}const oO={getClippingRect:function(n){let{element:e,boundary:t,rootBoundary:i,strategy:s}=n;const r=t==="clippingAncestors"?function(u,c){const f=c.get(u);if(f)return f;let h=$u(u).filter(m=>Ws(m)&&kr(m)!=="body"),d=null;const p=ls(u).position==="fixed";let g=p?$o(u):u;for(;Ws(g)&&!rf(g);){const m=ls(g),_=Hh(g);_||m.position!=="fixed"||(d=null),(p?!_&&!d:!_&&m.position==="static"&&d&&["absolute","fixed"].includes(d.position)||Xl(g)&&!_&&Sw(u,g))?h=h.filter(b=>b!==g):d=m,g=$o(g)}return c.set(u,h),h}(e,this._c):[].concat(t),o=[...r,i],l=o[0],a=o.reduce((u,c)=>{const f=lm(e,c,s);return u.top=Ro(f.top,u.top),u.right=Uh(f.right,u.right),u.bottom=Uh(f.bottom,u.bottom),u.left=Ro(f.left,u.left),u},lm(e,l,s));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}},convertOffsetParentRelativeRectToViewportRelativeRect:function(n){let{rect:e,offsetParent:t,strategy:i}=n;const s=as(t),r=Vs(t);if(t===r)return e;let o={scrollLeft:0,scrollTop:0},l=Zr(1);const a=Zr(0);if((s||!s&&i!=="fixed")&&((kr(t)!=="body"||Xl(r))&&(o=of(t)),as(t))){const u=Qr(t);l=Po(t),a.x=u.x+t.clientLeft,a.y=u.y+t.clientTop}return{width:e.width*l.x,height:e.height*l.y,x:e.x*l.x-o.scrollLeft*l.x+a.x,y:e.y*l.y-o.scrollTop*l.y+a.y}},isElement:Ws,getDimensions:function(n){return yw(n)},getOffsetParent:um,getDocumentElement:Vs,getScale:Po,async getElementRects(n){let{reference:e,floating:t,strategy:i}=n;const s=this.getOffsetParent||um,r=this.getDimensions;return{reference:rO(e,await s(t),i),floating:{x:0,y:0,...await r(t)}}},getClientRects:n=>Array.from(n.getClientRects()),isRTL:n=>ls(n).direction==="rtl"};function lO(n,e,t,i){i===void 0&&(i={});const{ancestorScroll:s=!0,ancestorResize:r=!0,elementResize:o=!0,layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=i,u=Bp(n),c=s||r?[...u?$u(u):[],...$u(e)]:[];c.forEach(g=>{s&&g.addEventListener("scroll",t,{passive:!0}),r&&g.addEventListener("resize",t)});const f=u&&l?function(g,m){let _,b=null;const y=Vs(g);function k(){clearTimeout(_),b&&b.disconnect(),b=null}return function T(I,x){I===void 0&&(I=!1),x===void 0&&(x=1),k();const{left:R,top:N,width:O,height:D}=g.getBoundingClientRect();if(I||m(),!O||!D)return;const M=Da(N),L=Da(y.clientWidth-(R+O)),V=Da(y.clientHeight-(N+D)),X=Da(R);let q=!0;b=new IntersectionObserver(K=>{const Q=K[0].intersectionRatio;if(Q!==x){if(!q)return T();Q?T(!1,Q):_=setTimeout(()=>{T(!1,1e-7)},100)}q=!1},{rootMargin:-M+"px "+-L+"px "+-V+"px "+-X+"px",threshold:Ro(0,Uh(1,x))||1}),b.observe(g)}(!0),k}(u,t):null;let h,d=null;o&&(d=new ResizeObserver(t),u&&!a&&d.observe(u),d.observe(e));let p=a?Qr(n):null;return a&&function g(){const m=Qr(n);!p||m.x===p.x&&m.y===p.y&&m.width===p.width&&m.height===p.height||t(),p=m,h=requestAnimationFrame(g)}(),t(),()=>{c.forEach(g=>{s&&g.removeEventListener("scroll",t),r&&g.removeEventListener("resize",t)}),f&&f(),d&&d.disconnect(),d=null,a&&cancelAnimationFrame(h)}}const aO=(n,e,t)=>{const i=new Map,s={platform:oO,...t},r={...s.platform,_c:i};return qA(n,e,{...s,platform:r})};function uO(n){let e,t;const i={autoUpdate:!0};let s=n;const r=c=>({...i,...n||{},...c||{}}),o=c=>{e&&t&&(s=r(c),aO(e,t,s).then(f=>{Object.assign(t.style,{position:f.strategy,left:`${f.x}px`,top:`${f.y}px`}),s!=null&&s.onComputed&&s.onComputed(f)}))},l=c=>{if("subscribe"in c)return u(c),{};e=c,o()},a=(c,f)=>{let h;t=c,s=r(f),setTimeout(()=>o(f),0),o(f);const d=()=>{h&&(h(),h=void 0)},p=({autoUpdate:g}=s||{})=>{if(d(),g!==!1)return lO(e,t,()=>o(s),g===!0?{}:g)};return h=p(),{update(g){o(g),h=p(g)},destroy(){d()}}},u=c=>{const f=c.subscribe(h=>{e===void 0?(e=h,o()):(Object.assign(e,h),o())});rp(f)};return[l,a,o]}function cO({loadOptions:n,filterText:e,items:t,multiple:i,value:s,itemId:r,groupBy:o,filterSelectedItems:l,itemFilter:a,convertStringItemsToObjects:u,filterGroupedItems:c,label:f}){if(t&&n)return t;if(!t)return[];t&&t.length>0&&typeof t[0]!="object"&&(t=u(t));let h=t.filter(d=>{let p=a(d[f],e,d);return p&&i&&(s!=null&&s.length)&&(p=!s.some(g=>l?g[r]===d[r]:!1)),p});return o&&(h=c(h)),h}async function fO({dispatch:n,loadOptions:e,convertStringItemsToObjects:t,filterText:i}){let s=await e(i).catch(r=>{n("error",{type:"loadOptions",details:r})});if(s&&!s.cancelled)return s?(s&&s.length>0&&typeof s[0]!="object"&&(s=t(s)),n("loaded",{items:s})):s=[],{filteredItems:s,loading:!1,focused:!0,listOpen:!0}}function hO(n){let e,t;return{c(){e=ze("svg"),t=ze("path"),v(t,"fill","currentColor"),v(t,"d",`M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 - 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 - 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 - 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 - 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z`),v(e,"width","100%"),v(e,"height","100%"),v(e,"viewBox","0 0 20 20"),v(e,"focusable","false"),v(e,"aria-hidden","true"),v(e,"class","svelte-qbd276")},m(i,s){A(i,e,s),F(e,t)},p:Z,i:Z,o:Z,d(i){i&&E(e)}}}class dO extends _e{constructor(e){super(),me(this,e,null,hO,ae,{})}}function pO(n){let e,t;return{c(){e=ze("svg"),t=ze("path"),v(t,"fill","currentColor"),v(t,"d",`M34.923,37.251L24,26.328L13.077,37.251L9.436,33.61l10.923-10.923L9.436,11.765l3.641-3.641L24,19.047L34.923,8.124 - l3.641,3.641L27.641,22.688L38.564,33.61L34.923,37.251z`),v(e,"width","100%"),v(e,"height","100%"),v(e,"viewBox","-2 -2 50 50"),v(e,"focusable","false"),v(e,"aria-hidden","true"),v(e,"role","presentation"),v(e,"class","svelte-whdbu1")},m(i,s){A(i,e,s),F(e,t)},p:Z,i:Z,o:Z,d(i){i&&E(e)}}}class Ju extends _e{constructor(e){super(),me(this,e,null,pO,ae,{})}}function gO(n){let e,t;return{c(){e=ze("svg"),t=ze("circle"),v(t,"class","circle_path svelte-1p3nqvd"),v(t,"cx","50"),v(t,"cy","50"),v(t,"r","20"),v(t,"fill","none"),v(t,"stroke","currentColor"),v(t,"stroke-width","5"),v(t,"stroke-miterlimit","10"),v(e,"class","loading svelte-1p3nqvd"),v(e,"viewBox","25 25 50 50")},m(i,s){A(i,e,s),F(e,t)},p:Z,i:Z,o:Z,d(i){i&&E(e)}}}class mO extends _e{constructor(e){super(),me(this,e,null,gO,ae,{})}}const _O=n=>({value:n[0]&8}),cm=n=>({value:n[3]}),bO=n=>({value:n[0]&8}),fm=n=>({value:n[3]}),yO=n=>({listOpen:n[0]&64}),hm=n=>({listOpen:n[6]}),vO=n=>({}),dm=n=>({}),wO=n=>({}),pm=n=>({}),kO=n=>({selection:n[0]&8}),gm=n=>({selection:n[3]});function mm(n,e,t){const i=n.slice();return i[125]=e[t],i[127]=t,i}const SO=n=>({}),_m=n=>({}),TO=n=>({selection:n[0]&8}),bm=n=>({selection:n[125],index:n[127]}),CO=n=>({}),ym=n=>({}),IO=n=>({}),vm=n=>({}),EO=n=>({}),wm=n=>({});function km(n,e,t){const i=n.slice();return i[125]=e[t],i[127]=t,i}const AO=n=>({item:n[0]&16777216}),Sm=n=>({item:n[125],index:n[127]}),OO=n=>({filteredItems:n[0]&16777216}),Tm=n=>({filteredItems:n[24]}),NO=n=>({}),Cm=n=>({});function Im(n){let e,t,i,s,r,o,l,a,u=n[50]["list-prepend"]&&Em(n);const c=[LO,xO,DO],f=[];function h(p,g){return p[50].list?0:p[24].length>0?1:p[19]?-1:2}~(i=h(n))&&(s=f[i]=c[i](n));let d=n[50]["list-append"]&&Om(n);return{c(){e=z("div"),u&&u.c(),t=se(),s&&s.c(),r=se(),d&&d.c(),v(e,"class","svelte-select-list svelte-apvs86"),B(e,"prefloat",n[28])},m(p,g){A(p,e,g),u&&u.m(e,null),F(e,t),~i&&f[i].m(e,null),F(e,r),d&&d.m(e,null),n[90](e),o=!0,l||(a=[_r(n[49].call(null,e)),ee(e,"scroll",n[41]),ee(e,"pointerup",Hn(Yi(n[85])))],l=!0)},p(p,g){p[50]["list-prepend"]?u?(u.p(p,g),g[1]&524288&&S(u,1)):(u=Em(p),u.c(),S(u,1),u.m(e,t)):u&&(oe(),C(u,1,1,()=>{u=null}),le());let m=i;i=h(p),i===m?~i&&f[i].p(p,g):(s&&(oe(),C(f[m],1,1,()=>{f[m]=null}),le()),~i?(s=f[i],s?s.p(p,g):(s=f[i]=c[i](p),s.c()),S(s,1),s.m(e,r)):s=null),p[50]["list-append"]?d?(d.p(p,g),g[1]&524288&&S(d,1)):(d=Om(p),d.c(),S(d,1),d.m(e,null)):d&&(oe(),C(d,1,1,()=>{d=null}),le()),(!o||g[0]&268435456)&&B(e,"prefloat",p[28])},i(p){o||(S(u),S(s),S(d),o=!0)},o(p){C(u),C(s),C(d),o=!1},d(p){p&&E(e),u&&u.d(),~i&&f[i].d(),d&&d.d(),n[90](null),l=!1,lt(a)}}}function Em(n){let e;const t=n[82]["list-prepend"],i=De(t,n,n[81],Cm);return{c(){i&&i.c()},m(s,r){i&&i.m(s,r),e=!0},p(s,r){i&&i.p&&(!e||r[2]&524288)&&Le(i,t,s,s[81],e?xe(t,s[81],r,NO):Me(s[81]),Cm)},i(s){e||(S(i,s),e=!0)},o(s){C(i,s),e=!1},d(s){i&&i.d(s)}}}function DO(n){let e;const t=n[82].empty,i=De(t,n,n[81],wm),s=i||MO();return{c(){s&&s.c()},m(r,o){s&&s.m(r,o),e=!0},p(r,o){i&&i.p&&(!e||o[2]&524288)&&Le(i,t,r,r[81],e?xe(t,r[81],o,EO):Me(r[81]),wm)},i(r){e||(S(s,r),e=!0)},o(r){C(s,r),e=!1},d(r){s&&s.d(r)}}}function xO(n){let e,t,i=Xe(n[24]),s=[];for(let o=0;oC(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o{o[c]=null}),le(),t=o[e],t?t.p(a,u):(t=o[e]=r[e](a),t.c()),S(t,1),t.m(i.parentNode,i))},i(a){s||(S(t),s=!0)},o(a){C(t),s=!1},d(a){a&&E(i),o[e].d(a)}}}function PO(n){let e,t;const i=n[82].selection,s=De(i,n,n[81],gm),r=s||zO(n);return{c(){e=z("div"),r&&r.c(),v(e,"class","selected-item svelte-apvs86"),B(e,"hide-selected-item",n[35])},m(o,l){A(o,e,l),r&&r.m(e,null),t=!0},p(o,l){s?s.p&&(!t||l[0]&8|l[2]&524288)&&Le(s,i,o,o[81],t?xe(i,o[81],l,kO):Me(o[81]),gm):r&&r.p&&(!t||l[0]&4104)&&r.p(o,t?l:[-1,-1,-1,-1,-1]),(!t||l[1]&16)&&B(e,"hide-selected-item",o[35])},i(o){t||(S(r,o),t=!0)},o(o){C(r,o),t=!1},d(o){o&&E(e),r&&r.d(o)}}}function BO(n){let e,t,i=Xe(n[3]),s=[];for(let o=0;oC(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o{f=null}),le()),(!r||p[0]&67108864)&&B(e,"active",n[26]===n[127]),(!r||p[0]&2048)&&B(e,"disabled",n[11])},i(d){r||(S(c,d),S(f),r=!0)},o(d){C(c,d),C(f),r=!1},d(d){d&&E(e),c&&c.d(d),f&&f.d(),o=!1,lt(l)}}}function Mm(n){let e,t;const i=n[82]["loading-icon"],s=De(i,n,n[81],pm),r=s||VO();return{c(){e=z("div"),r&&r.c(),v(e,"class","icon loading svelte-apvs86"),v(e,"aria-hidden","true")},m(o,l){A(o,e,l),r&&r.m(e,null),t=!0},p(o,l){s&&s.p&&(!t||l[2]&524288)&&Le(s,i,o,o[81],t?xe(i,o[81],l,wO):Me(o[81]),pm)},i(o){t||(S(r,o),t=!0)},o(o){C(r,o),t=!1},d(o){o&&E(e),r&&r.d(o)}}}function VO(n){let e,t;return e=new mO({}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function Rm(n){let e,t,i,s;const r=n[82]["clear-icon"],o=De(r,n,n[81],dm),l=o||HO();return{c(){e=z("button"),l&&l.c(),v(e,"type","button"),v(e,"class","icon clear-select svelte-apvs86")},m(a,u){A(a,e,u),l&&l.m(e,null),t=!0,i||(s=ee(e,"click",n[22]),i=!0)},p(a,u){o&&o.p&&(!t||u[2]&524288)&&Le(o,r,a,a[81],t?xe(r,a[81],u,vO):Me(a[81]),dm)},i(a){t||(S(l,a),t=!0)},o(a){C(l,a),t=!1},d(a){a&&E(e),l&&l.d(a),i=!1,s()}}}function HO(n){let e,t;return e=new Ju({}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function Pm(n){let e,t;const i=n[82]["chevron-icon"],s=De(i,n,n[81],hm),r=s||UO();return{c(){e=z("div"),r&&r.c(),v(e,"class","icon chevron svelte-apvs86"),v(e,"aria-hidden","true")},m(o,l){A(o,e,l),r&&r.m(e,null),t=!0},p(o,l){s&&s.p&&(!t||l[0]&64|l[2]&524288)&&Le(s,i,o,o[81],t?xe(i,o[81],l,yO):Me(o[81]),hm)},i(o){t||(S(r,o),t=!0)},o(o){C(r,o),t=!1},d(o){o&&E(e),r&&r.d(o)}}}function UO(n){let e,t;return e=new dO({}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function GO(n){let e,t;return{c(){e=z("input"),v(e,"name",n[8]),v(e,"type","hidden"),e.value=t=n[3]?JSON.stringify(n[3]):null,v(e,"class","svelte-apvs86")},m(i,s){A(i,e,s)},p(i,s){s[0]&256&&v(e,"name",i[8]),s[0]&8&&t!==(t=i[3]?JSON.stringify(i[3]):null)&&(e.value=t)},d(i){i&&E(e)}}}function Bm(n){let e;const t=n[82].required,i=De(t,n,n[81],cm),s=i||jO();return{c(){s&&s.c()},m(r,o){s&&s.m(r,o),e=!0},p(r,o){i&&i.p&&(!e||o[0]&8|o[2]&524288)&&Le(i,t,r,r[81],e?xe(t,r[81],o,_O):Me(r[81]),cm)},i(r){e||(S(s,r),e=!0)},o(r){C(s,r),e=!1},d(r){s&&s.d(r)}}}function jO(n){let e;return{c(){e=z("select"),v(e,"class","required svelte-apvs86"),e.required=!0,v(e,"tabindex","-1"),v(e,"aria-hidden","true")},m(t,i){A(t,e,i)},p:Z,d(t){t&&E(e)}}}function qO(n){let e,t,i,s,r,o,l,a,u,c,f,h,d,p,g,m,_,b,y,k,T=n[6]&&Im(n),I=n[2]&&Nm(n);const x=n[82].prepend,R=De(x,n,n[81],ym);let N=n[25]&&Dm(n),O=[{readOnly:c=!n[17]},n[27],{placeholder:n[33]},{style:n[18]},{disabled:n[11]}],D={};for(let J=0;J{T=null}),le()),J[2]?I?I.p(J,ce):(I=Nm(J),I.c(),I.m(i,null)):I&&(I.d(1),I=null),R&&R.p&&(!b||ce[2]&524288)&&Le(R,x,J,J[81],b?xe(x,J[81],ce,CO):Me(J[81]),ym),J[25]?N?(N.p(J,ce),ce[0]&33554432&&S(N,1)):(N=Dm(J),N.c(),S(N,1),N.m(l,a)):N&&(oe(),C(N,1,1,()=>{N=null}),le()),Nh(u,D=_i(O,[(!b||ce[0]&131072&&c!==(c=!J[17]))&&{readOnly:c},ce[0]&134217728&&J[27],(!b||ce[1]&4)&&{placeholder:J[33]},(!b||ce[0]&262144)&&{style:J[18]},(!b||ce[0]&2048)&&{disabled:J[11]}])),ce[0]&16&&u.value!==J[4]&&Bt(u,J[4]),B(u,"svelte-apvs86",!0),J[5]?M?(M.p(J,ce),ce[0]&32&&S(M,1)):(M=Mm(J),M.c(),S(M,1),M.m(h,d)):M&&(oe(),C(M,1,1,()=>{M=null}),le()),J[34]?L?(L.p(J,ce),ce[1]&8&&S(L,1)):(L=Rm(J),L.c(),S(L,1),L.m(h,p)):L&&(oe(),C(L,1,1,()=>{L=null}),le()),J[20]?V?(V.p(J,ce),ce[0]&1048576&&S(V,1)):(V=Pm(J),V.c(),S(V,1),V.m(h,null)):V&&(oe(),C(V,1,1,()=>{V=null}),le()),q?q.p&&(!b||ce[0]&8|ce[2]&524288)&&Le(q,X,J,J[81],b?xe(X,J[81],ce,bO):Me(J[81]),fm):K&&K.p&&(!b||ce[0]&264)&&K.p(J,b?ce:[-1,-1,-1,-1,-1]),J[16]&&(!J[3]||J[3].length===0)?Q?(Q.p(J,ce),ce[0]&65544&&S(Q,1)):(Q=Bm(J),Q.c(),S(Q,1),Q.m(e,null)):Q&&(oe(),C(Q,1,1,()=>{Q=null}),le()),(!b||ce[0]&2097152&&_!==(_="svelte-select "+J[21]+" svelte-apvs86"))&&v(e,"class",_),(!b||ce[0]&16384)&&v(e,"style",J[14]),(!b||ce[0]&2097664)&&B(e,"multi",J[9]),(!b||ce[0]&2099200)&&B(e,"disabled",J[11]),(!b||ce[0]&2097156)&&B(e,"focused",J[2]),(!b||ce[0]&2097216)&&B(e,"list-open",J[6]),(!b||ce[0]&3145728)&&B(e,"show-chevron",J[20]),(!b||ce[0]&2129920)&&B(e,"error",J[15])},i(J){b||(S(T),S(R,J),S(N),S(M),S(L),S(V),S(K,J),S(Q),b=!0)},o(J){C(T),C(R,J),C(N),C(M),C(L),C(V),C(K,J),C(Q),b=!1},d(J){J&&E(e),T&&T.d(),I&&I.d(),R&&R.d(J),N&&N.d(),n[93](null),M&&M.d(),L&&L.d(),V&&V.d(),K&&K.d(J),Q&&Q.d(),n[95](null),y=!1,lt(k)}}}function zm(n){return n.map((e,t)=>({index:t,value:e,label:`${e}`}))}function YO(n){return n===0}function XO(n){return n.groupHeader&&n.selectable||n.selectable||!n.hasOwnProperty("selectable")}function KO(n,e,t){let i,s,r,o,l,a,u,c,f,{$$slots:h={},$$scope:d}=e;const p=YT(h),g=mi();let{justValue:m=null}=e,{filter:_=cO}=e,{getItems:b=fO}=e,{id:y=null}=e,{name:k=null}=e,{container:T=void 0}=e,{input:I=void 0}=e,{multiple:x=!1}=e,{multiFullItemClearable:R=!1}=e,{disabled:N=!1}=e,{focused:O=!1}=e,{value:D=null}=e,{filterText:M=""}=e,{placeholder:L="Please select"}=e,{placeholderAlwaysShow:V=!1}=e,{items:X=null}=e,{label:q="label"}=e,{itemFilter:K=(W,Ne,Vt)=>`${W}`.toLowerCase().includes(Ne.toLowerCase())}=e,{groupBy:Q=void 0}=e,{groupFilter:J=W=>W}=e,{groupHeaderSelectable:ce=!1}=e,{itemId:pe="value"}=e,{loadOptions:qe=void 0}=e,{containerStyles:Ae=""}=e,{hasError:ue=!1}=e,{filterSelectedItems:te=!0}=e,{required:be=!1}=e,{closeListOnChange:ge=!0}=e,{createGroupHeaderItem:he=(W,Ne)=>({value:W,[q]:W})}=e;const Se=()=>u;let{searchable:Je=!0}=e,{inputStyles:gt=""}=e,{clearable:Ii=!0}=e,{loading:fe=!1}=e,{listOpen:Te=!1}=e,Ge,{debounce:It=(W,Ne=1)=>{clearTimeout(Ge),Ge=setTimeout(W,Ne)}}=e,{debounceWait:Pt=300}=e,{hideEmptyState:ni=!1}=e,{inputAttributes:Xt={}}=e,{listAutoWidth:Fi=!0}=e,{showChevron:Ei=!1}=e,{listOffset:hi=5}=e,{hoverItemIndex:st=0}=e,{floatingConfig:ei={}}=e,{class:Wi=""}=e,ct,si,Tn,tn;function Ce(){if(typeof D=="string"){let W=(X||[]).find(Ne=>Ne[pe]===D);t(3,D=W||{[pe]:D,label:D})}else x&&Array.isArray(D)&&D.length>0&&t(3,D=D.map(W=>typeof W=="string"?{value:W,label:W}:W))}let tt;function vt(){t(27,tt=Object.assign({autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:!1,tabindex:0,type:"text","aria-autocomplete":"list"},Xt)),y&&t(27,tt.id=y,tt),Je||t(27,tt.readonly=!0,tt)}function Kt(W){const Ne=[],Vt={};W.forEach(ho=>{const xs=Q(ho);Ne.includes(xs)||(Ne.push(xs),Vt[xs]=[],xs&&Vt[xs].push(Object.assign(he(xs,ho),{id:xs,groupHeader:!0,selectable:ce}))),Vt[xs].push(Object.assign({groupItem:!!xs},ho))});const Ds=[];return J(Ne).forEach(ho=>{Vt[ho]&&Ds.push(...Vt[ho])}),Ds}function Vi(){if(x){JSON.stringify(D)!==JSON.stringify(si)&&Ai()&&g("input",D);return}(!si||JSON.stringify(D[pe])!==JSON.stringify(si[pe]))&&g("input",D)}function cn(){D&&(Array.isArray(D)?t(3,D=[...D]):t(3,D=[D]))}function Hi(){D&&t(3,D=null)}function Ks(){const W=u.findIndex(Ne=>Ne[pe]===D[pe]);At(W,!0)}function $s(W){g("hoverItem",W)}function At(W=0,Ne){t(7,st=W<0?0:W),!Ne&&Q&&u[st]&&!u[st].selectable&&Wt(1)}function fn(){!qe&&M.length===0||(qe?It(async function(){t(5,fe=!0);let W=await b({dispatch:g,loadOptions:qe,convertStringItemsToObjects:zm,filterText:M});W?(t(5,fe=W.loading),t(6,Te=Te?W.listOpen:M.length>0),t(2,O=Te&&W.focused),t(51,X=Q?Kt(W.filteredItems):W.filteredItems)):(t(5,fe=!1),t(2,O=!0),t(6,Te=!0))},Pt):(t(6,Te=!0),x&&t(26,ct=void 0)))}function Js(W){Te&&g("filter",W)}fC(async()=>{t(77,si=D),t(78,Tn=M),t(79,tn=x)});function Ns(){return x?D?D.map(W=>W[pe]):null:D&&D[pe]}function Ai(){let W=!0;if(D){const Ne=[],Vt=[];D.forEach(Ds=>{Ne.includes(Ds[pe])?W=!1:(Ne.push(Ds[pe]),Vt.push(Ds))}),W||t(3,D=Vt)}return W}function Ui(W){let Ne=W?W[pe]:D[pe];return X.find(Vt=>Vt[pe]===Ne)}function ri(W){!W||W.length===0||W.some(Ne=>typeof Ne!="object")||!D||(x?D.some(Ne=>!Ne||!Ne[pe]):!D[pe])||(Array.isArray(D)?t(3,D=D.map(Ne=>Ui(Ne)||Ne)):t(3,D=Ui()||D))}async function $t(W){const Ne=D[W];D.length===1?t(3,D=void 0):t(3,D=D.filter(Vt=>Vt!==Ne)),g("clear",Ne)}function xt(W){if(O)switch(W.stopPropagation(),W.key){case"Escape":W.preventDefault(),Bn();break;case"Enter":if(W.preventDefault(),Te){if(u.length===0)break;const Ne=u[st];if(D&&!x&&D[pe]===Ne[pe]){Bn();break}else ye(u[st])}break;case"ArrowDown":W.preventDefault(),Te?Wt(1):(t(6,Te=!0),t(26,ct=void 0));break;case"ArrowUp":W.preventDefault(),Te?Wt(-1):(t(6,Te=!0),t(26,ct=void 0));break;case"Tab":if(Te&&O){if(u.length===0||D&&D[pe]===u[st][pe])return Bn();W.preventDefault(),ye(u[st]),Bn()}break;case"Backspace":if(!x||M.length>0)return;if(x&&D&&D.length>0){if($t(ct!==void 0?ct:D.length-1),ct===0||ct===void 0)break;t(26,ct=D.length>ct?ct-1:void 0)}break;case"ArrowLeft":if(!D||!x||M.length>0)return;ct===void 0?t(26,ct=D.length-1):D.length>ct&&ct!==0&&t(26,ct-=1);break;case"ArrowRight":if(!D||!x||M.length>0||ct===void 0)return;ct===D.length-1?t(26,ct=void 0):ct{Te&&t(2,O=!0),O&&I&&I.focus()});function ka(W){if(W){t(4,M="");const Ne=Object.assign({},W);if(Ne.groupHeader&&!Ne.selectable)return;t(3,D=x?D?D.concat([Ne]):[Ne]:t(3,D=Ne)),setTimeout(()=>{ge&&Bn(),t(26,ct=void 0),g("change",D),g("select",W)})}}function Bn(){t(4,M=""),t(6,Te=!1)}let{ariaValues:fl=W=>`Option ${W}, selected.`}=e,{ariaListOpen:Zs=(W,Ne)=>`You are currently focused on option ${W}. There are ${Ne} results available.`}=e,{ariaFocused:Cn=()=>"Select is focused, type to refine list, press down to open the menu."}=e;function Sa(W){let Ne;return W&&D.length>0?Ne=D.map(Vt=>Vt[q]).join(", "):Ne=D[q],fl(Ne)}function Ta(){if(!u||u.length===0)return"";let W=u[st];if(Te&&W){let Ne=u?u.length:0;return Zs(W[q],Ne)}else return Cn()}let Oi=null,hl;function Ca(){clearTimeout(hl),hl=setTimeout(()=>{U=!1},100)}function Fe(W){!Te&&!O&&T&&!T.contains(W.target)&&!(Oi!=null&&Oi.contains(W.target))&&cl()}rp(()=>{Oi==null||Oi.remove()});let U=!1;function ye(W){!W||W.selectable===!1||ka(W)}function Ee(W){U||t(7,st=W)}function _t(W){const{item:Ne,i:Vt}=W;if((Ne==null?void 0:Ne.selectable)!==!1){if(D&&!x&&D[pe]===Ne[pe])return Bn();XO(Ne)&&(t(7,st=Vt),ye(Ne))}}function Wt(W){if(u.filter(Ds=>!Object.hasOwn(Ds,"selectable")||Ds.selectable===!0).length===0)return t(7,st=0);W>0&&st===u.length-1?t(7,st=0):W<0&&st===0?t(7,st=u.length-1):t(7,st=st+W);const Vt=u[st];if(Vt&&Vt.selectable===!1){(W===1||W===-1)&&Wt(W);return}}function dn(W,Ne,Vt){if(!x)return Ne&&Ne[Vt]===W[Vt]}const Lt=co,zn=co;function co(W){return{update(Ne){Ne.scroll&&(Ca(),W.scrollIntoView({behavior:"auto",block:"nearest"}))}}}function Ia(){const{width:W}=T.getBoundingClientRect();t(23,Oi.style.width=Fi?W+"px":"auto",Oi)}let fo={strategy:"absolute",placement:"bottom-start",middleware:[tO(hi),eO(),nO()],autoUpdate:!1};const[IT,ET,AT]=uO(fo);let Of=!0;function OT(W,Ne){if(!W||!Ne)return t(28,Of=!0);setTimeout(()=>{t(28,Of=!1)},0)}function NT(W){Ut.call(this,n,W)}function DT(W){Ut.call(this,n,W)}function xT(W){Ut.call(this,n,W)}function LT(W){Ut.call(this,n,W)}const MT=W=>Ee(W),RT=W=>Ee(W),PT=(W,Ne)=>_t({item:W,i:Ne});function BT(W){Ze[W?"unshift":"push"](()=>{Oi=W,t(23,Oi)})}const zT=W=>$t(W),FT=W=>R?$t(W):{};function WT(W){Ze[W?"unshift":"push"](()=>{I=W,t(1,I)})}function VT(){M=this.value,t(4,M)}function HT(W){Ze[W?"unshift":"push"](()=>{T=W,t(0,T)})}return n.$$set=W=>{"justValue"in W&&t(52,m=W.justValue),"filter"in W&&t(53,_=W.filter),"getItems"in W&&t(54,b=W.getItems),"id"in W&&t(55,y=W.id),"name"in W&&t(8,k=W.name),"container"in W&&t(0,T=W.container),"input"in W&&t(1,I=W.input),"multiple"in W&&t(9,x=W.multiple),"multiFullItemClearable"in W&&t(10,R=W.multiFullItemClearable),"disabled"in W&&t(11,N=W.disabled),"focused"in W&&t(2,O=W.focused),"value"in W&&t(3,D=W.value),"filterText"in W&&t(4,M=W.filterText),"placeholder"in W&&t(56,L=W.placeholder),"placeholderAlwaysShow"in W&&t(57,V=W.placeholderAlwaysShow),"items"in W&&t(51,X=W.items),"label"in W&&t(12,q=W.label),"itemFilter"in W&&t(58,K=W.itemFilter),"groupBy"in W&&t(59,Q=W.groupBy),"groupFilter"in W&&t(60,J=W.groupFilter),"groupHeaderSelectable"in W&&t(61,ce=W.groupHeaderSelectable),"itemId"in W&&t(13,pe=W.itemId),"loadOptions"in W&&t(62,qe=W.loadOptions),"containerStyles"in W&&t(14,Ae=W.containerStyles),"hasError"in W&&t(15,ue=W.hasError),"filterSelectedItems"in W&&t(63,te=W.filterSelectedItems),"required"in W&&t(16,be=W.required),"closeListOnChange"in W&&t(64,ge=W.closeListOnChange),"createGroupHeaderItem"in W&&t(65,he=W.createGroupHeaderItem),"searchable"in W&&t(17,Je=W.searchable),"inputStyles"in W&&t(18,gt=W.inputStyles),"clearable"in W&&t(67,Ii=W.clearable),"loading"in W&&t(5,fe=W.loading),"listOpen"in W&&t(6,Te=W.listOpen),"debounce"in W&&t(68,It=W.debounce),"debounceWait"in W&&t(69,Pt=W.debounceWait),"hideEmptyState"in W&&t(19,ni=W.hideEmptyState),"inputAttributes"in W&&t(70,Xt=W.inputAttributes),"listAutoWidth"in W&&t(71,Fi=W.listAutoWidth),"showChevron"in W&&t(20,Ei=W.showChevron),"listOffset"in W&&t(72,hi=W.listOffset),"hoverItemIndex"in W&&t(7,st=W.hoverItemIndex),"floatingConfig"in W&&t(73,ei=W.floatingConfig),"class"in W&&t(21,Wi=W.class),"ariaValues"in W&&t(74,fl=W.ariaValues),"ariaListOpen"in W&&t(75,Zs=W.ariaListOpen),"ariaFocused"in W&&t(76,Cn=W.ariaFocused),"$$scope"in W&&t(81,d=W.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&8|n.$$.dirty[1]&1048576&&D&&Ce(),n.$$.dirty[0]&131072|n.$$.dirty[2]&256&&(Xt||!Je)&&vt(),n.$$.dirty[0]&512&&x&&cn(),n.$$.dirty[0]&512|n.$$.dirty[2]&131072&&tn&&!x&&Hi(),n.$$.dirty[0]&520&&x&&D&&D.length>1&&Ai(),n.$$.dirty[0]&8&&D&&Vi(),n.$$.dirty[0]&520|n.$$.dirty[2]&32768&&!D&&x&&si&&g("input",D),n.$$.dirty[0]&6&&!O&&I&&Bn(),n.$$.dirty[0]&16|n.$$.dirty[2]&65536&&M!==Tn&&fn(),n.$$.dirty[0]&12824|n.$$.dirty[1]&407896064|n.$$.dirty[2]&3&&t(24,u=_({loadOptions:qe,filterText:M,items:X,multiple:x,value:D,itemId:pe,groupBy:Q,label:q,filterSelectedItems:te,itemFilter:K,convertStringItemsToObjects:zm,filterGroupedItems:Kt})),n.$$.dirty[0]&16777800&&!x&&Te&&D&&u&&Ks(),n.$$.dirty[0]&576&&Te&&x&&t(7,st=0),n.$$.dirty[0]&16&&M&&t(7,st=0),n.$$.dirty[0]&128&&$s(st),n.$$.dirty[0]&520&&t(25,i=x?D&&D.length>0:D),n.$$.dirty[0]&33554448&&t(35,s=i&&M.length>0),n.$$.dirty[0]&33556512|n.$$.dirty[2]&32&&t(34,r=i&&Ii&&!N&&!fe),n.$$.dirty[0]&520|n.$$.dirty[1]&100663296&&t(33,o=V&&x||x&&(D==null?void 0:D.length)===0?L:D?"":L),n.$$.dirty[0]&520&&t(32,l=D?Sa(x):""),n.$$.dirty[0]&16777412&&t(31,a=Ta()),n.$$.dirty[1]&1048576&&ri(X),n.$$.dirty[0]&8712&&t(52,m=Ns()),n.$$.dirty[0]&520|n.$$.dirty[2]&32768&&!x&&si&&!D&&g("input",D),n.$$.dirty[0]&16777800&&Te&&u&&!x&&!D&&At(),n.$$.dirty[0]&16777216&&Js(u),n.$$.dirty[0]&1|n.$$.dirty[2]&2048&&T&&(ei==null?void 0:ei.autoUpdate)===void 0&&t(80,fo.autoUpdate=!0,fo),n.$$.dirty[0]&1|n.$$.dirty[2]&264192&&T&&ei&&AT(Object.assign(fo,ei)),n.$$.dirty[0]&8388608&&t(30,c=!!Oi),n.$$.dirty[0]&8388672&&OT(Oi,Te),n.$$.dirty[0]&8388673&&Te&&T&&Oi&&Ia(),n.$$.dirty[0]&128&&t(29,f=st),n.$$.dirty[0]&70&&I&&Te&&!O&&Ot()},[T,I,O,D,M,fe,Te,st,k,x,R,N,q,pe,Ae,ue,be,Je,gt,ni,Ei,Wi,uo,Oi,u,i,ct,tt,Of,f,c,a,l,o,r,s,$t,xt,Ot,cl,hn,Ca,Fe,Ee,_t,dn,Lt,zn,IT,ET,p,X,m,_,b,y,L,V,K,Q,J,ce,qe,te,ge,he,Se,Ii,It,Pt,Xt,Fi,hi,ei,fl,Zs,Cn,si,Tn,tn,fo,d,h,NT,DT,xT,LT,MT,RT,PT,BT,zT,FT,WT,VT,HT]}class $O extends _e{constructor(e){super(),me(this,e,KO,qO,ae,{justValue:52,filter:53,getItems:54,id:55,name:8,container:0,input:1,multiple:9,multiFullItemClearable:10,disabled:11,focused:2,value:3,filterText:4,placeholder:56,placeholderAlwaysShow:57,items:51,label:12,itemFilter:58,groupBy:59,groupFilter:60,groupHeaderSelectable:61,itemId:13,loadOptions:62,containerStyles:14,hasError:15,filterSelectedItems:63,required:16,closeListOnChange:64,createGroupHeaderItem:65,getFilteredItems:66,searchable:17,inputStyles:18,clearable:67,loading:5,listOpen:6,debounce:68,debounceWait:69,hideEmptyState:19,inputAttributes:70,listAutoWidth:71,showChevron:20,listOffset:72,hoverItemIndex:7,floatingConfig:73,class:21,handleClear:22,ariaValues:74,ariaListOpen:75,ariaFocused:76},null,[-1,-1,-1,-1,-1])}get getFilteredItems(){return this.$$.ctx[66]}get handleClear(){return this.$$.ctx[22]}}const xa={AUTO:"auto",START:"start",CENTER:"center",END:"end"},Ps={HORIZONTAL:"horizontal",VERTICAL:"vertical"},gl={OBSERVED:0,REQUESTED:1},JO={[Ps.VERTICAL]:"top",[Ps.HORIZONTAL]:"left"},Fm={[Ps.VERTICAL]:"scrollTop",[Ps.HORIZONTAL]:"scrollLeft"};class ZO{constructor({itemSize:e,itemCount:t,estimatedItemSize:i}){this.itemSize=e,this.itemCount=t,this.estimatedItemSize=i,this.itemSizeAndPositionData={},this.lastMeasuredIndex=-1,this.checkForMismatchItemSizeAndItemCount(),this.justInTime||this.computeTotalSizeAndPositionData()}get justInTime(){return typeof this.itemSize=="function"}updateConfig({itemSize:e,itemCount:t,estimatedItemSize:i}){t!=null&&(this.itemCount=t),i!=null&&(this.estimatedItemSize=i),e!=null&&(this.itemSize=e),this.checkForMismatchItemSizeAndItemCount(),this.justInTime&&this.totalSize!=null?this.totalSize=void 0:this.computeTotalSizeAndPositionData()}checkForMismatchItemSizeAndItemCount(){if(Array.isArray(this.itemSize)&&this.itemSize.length=this.itemCount)throw Error(`Requested index ${e} is outside of range 0..${this.itemCount}`);return this.justInTime?this.getJustInTimeSizeAndPositionForIndex(e):this.itemSizeAndPositionData[e]}getJustInTimeSizeAndPositionForIndex(e){if(e>this.lastMeasuredIndex){const t=this.getSizeAndPositionOfLastMeasuredItem();let i=t.offset+t.size;for(let s=this.lastMeasuredIndex+1;s<=e;s++){const r=this.getSize(s);if(r==null||isNaN(r))throw Error(`Invalid size returned for index ${s} of value ${r}`);this.itemSizeAndPositionData[s]={offset:i,size:r},i+=r}this.lastMeasuredIndex=e}return this.itemSizeAndPositionData[e]}getSizeAndPositionOfLastMeasuredItem(){return this.lastMeasuredIndex>=0?this.itemSizeAndPositionData[this.lastMeasuredIndex]:{offset:0,size:0}}getTotalSize(){if(this.totalSize)return this.totalSize;const e=this.getSizeAndPositionOfLastMeasuredItem();return e.offset+e.size+(this.itemCount-this.lastMeasuredIndex-1)*this.estimatedItemSize}getUpdatedOffsetForIndex({align:e=xa.START,containerSize:t,currentOffset:i,targetIndex:s}){if(t<=0)return 0;const r=this.getSizeAndPositionForIndex(s),o=r.offset,l=o-t+r.size;let a;switch(e){case xa.END:a=l;break;case xa.CENTER:a=o-(t-r.size)/2;break;case xa.START:a=o;break;default:a=Math.max(l,Math.min(o,i))}const u=this.getTotalSize();return Math.max(0,Math.min(u-t,a))}getVisibleRange({containerSize:e=0,offset:t,overscanCount:i}){if(this.getTotalSize()===0)return{};const r=t+e;let o=this.findNearestItem(t);if(o===void 0)throw Error(`Invalid offset ${t} specified`);const l=this.getSizeAndPositionForIndex(o);t=l.offset+l.size;let a=o;for(;t=e?this.binarySearch({high:i,low:0,offset:e}):this.exponentialSearch({index:i,offset:e})}binarySearch({low:e,high:t,offset:i}){let s=0,r=0;for(;e<=t;){if(s=e+Math.floor((t-e)/2),r=this.getSizeAndPositionForIndex(s).offset,r===i)return s;ri&&(t=s-1)}return e>0?e-1:0}exponentialSearch({index:e,offset:t}){let i=1;for(;e({}),Wm=n=>({});function Vm(n,e,t){const i=n.slice();return i[37]=e[t],i}const eN=n=>({style:n[0]&4,index:n[0]&4}),Hm=n=>({style:n[37].style,index:n[37].index}),tN=n=>({}),Um=n=>({});function Gm(n,e){let t,i;const s=e[21].item,r=De(s,e,e[20],Hm);return{key:n,first:null,c(){t=we(),r&&r.c(),this.first=t},m(o,l){A(o,t,l),r&&r.m(o,l),i=!0},p(o,l){e=o,r&&r.p&&(!i||l[0]&1048580)&&Le(r,s,e,e[20],i?xe(s,e[20],l,eN):Me(e[20]),Hm)},i(o){i||(S(r,o),i=!0)},o(o){C(r,o),i=!1},d(o){o&&E(t),r&&r.d(o)}}}function iN(n){let e,t,i,s=[],r=new Map,o,l;const a=n[21].header,u=De(a,n,n[20],Um);let c=Xe(n[2]);const f=p=>p[0]?p[0](p[37].index):p[37].index;for(let p=0;p{let n=!1;try{const e=Object.defineProperty({},"passive",{get(){return n={passive:!0},!0}});window.addEventListener("testpassive",e,e),window.remove("testpassive",e,e)}catch{}return n})();function sN(n,e,t){let{$$slots:i={},$$scope:s}=e,{height:r}=e,{width:o="100%"}=e,{itemCount:l}=e,{itemSize:a}=e,{estimatedItemSize:u=null}=e,{stickyIndices:c=null}=e,{getKey:f=null}=e,{scrollDirection:h=Ps.VERTICAL}=e,{scrollOffset:d=null}=e,{scrollToIndex:p=null}=e,{scrollToAlignment:g=null}=e,{scrollToBehaviour:m="instant"}=e,{overscanCount:_=3}=e;const b=mi(),y=new ZO({itemCount:l,itemSize:a,estimatedItemSize:pe()});let k=!1,T,I=[],x={offset:d||p!=null&&I.length&&Q(p)||0,scrollChangeReason:gl.REQUESTED},R=x,N={scrollToIndex:p,scrollToAlignment:g,scrollOffset:d,itemCount:l,itemSize:a,estimatedItemSize:u},O={},D="",M="";X(),sl(()=>{t(18,k=!0),T.addEventListener("scroll",J,nN),d!=null?q(d):p!=null&&q(Q(p))}),rp(()=>{k&&T.removeEventListener("scroll",J)});function L(){if(!k)return;const ue=N.scrollToIndex!==p||N.scrollToAlignment!==g,te=N.itemCount!==l||N.itemSize!==a||N.estimatedItemSize!==u;te&&(y.updateConfig({itemSize:a,itemCount:l,estimatedItemSize:pe()}),K()),N.scrollOffset!==d?t(19,x={offset:d||0,scrollChangeReason:gl.REQUESTED}):typeof p=="number"&&(ue||te)&&t(19,x={offset:Q(p,g,l),scrollChangeReason:gl.REQUESTED}),N={scrollToIndex:p,scrollToAlignment:g,scrollOffset:d,itemCount:l,itemSize:a,estimatedItemSize:u}}function V(){if(!k)return;const{offset:ue,scrollChangeReason:te}=x;(R.offset!==ue||R.scrollChangeReason!==te)&&X(),R.offset!==ue&&te===gl.REQUESTED&&q(ue),R=x}function X(){const{offset:ue}=x,{start:te,stop:be}=y.getVisibleRange({containerSize:h===Ps.VERTICAL?r:o,offset:ue,overscanCount:_});let ge=[];const he=y.getTotalSize();h===Ps.VERTICAL?(t(3,D=`height:${r}px;width:${o};`),t(4,M=`flex-direction:column;height:${he}px;`)):(t(3,D=`height:${r};width:${o}px`),t(4,M=`min-height:100%;width:${he}px;`));const Se=c!=null&&c.length!==0;if(Se)for(let Je=0;Je=be)&&(ue=0),y.getUpdatedOffsetForIndex({align:te,containerSize:h===Ps.VERTICAL?r:o,currentOffset:x.offset||0,targetIndex:ue})}function J(ue){const te=ce();te<0||x.offset===te||ue.target!==T||(t(19,x={offset:te,scrollChangeReason:gl.OBSERVED}),b("afterScroll",{offset:te,event:ue}))}function ce(){return T[Fm[h]]}function pe(){return u||typeof a=="number"&&a||50}function qe(ue,te){if(O[ue])return O[ue];const{size:be,offset:ge}=y.getSizeAndPositionForIndex(ue);let he;return h===Ps.VERTICAL?(he=`left:0;width:100%;height:${be}px;`,te?he+=`position:sticky;flex-grow:0;z-index:1;top:0;margin-top:${ge}px;margin-bottom:${-(ge+be)}px;`:he+=`position:absolute;top:${ge}px;`):(he=`top:0;width:${be}px;`,te?he+=`position:sticky;z-index:1;left:0;margin-left:${ge}px;margin-right:${-(ge+be)}px;`:he+=`position:absolute;height:100%;left:${ge}px;`),O[ue]=he}function Ae(ue){Ze[ue?"unshift":"push"](()=>{T=ue,t(1,T)})}return n.$$set=ue=>{"height"in ue&&t(5,r=ue.height),"width"in ue&&t(6,o=ue.width),"itemCount"in ue&&t(7,l=ue.itemCount),"itemSize"in ue&&t(8,a=ue.itemSize),"estimatedItemSize"in ue&&t(9,u=ue.estimatedItemSize),"stickyIndices"in ue&&t(10,c=ue.stickyIndices),"getKey"in ue&&t(0,f=ue.getKey),"scrollDirection"in ue&&t(11,h=ue.scrollDirection),"scrollOffset"in ue&&t(12,d=ue.scrollOffset),"scrollToIndex"in ue&&t(13,p=ue.scrollToIndex),"scrollToAlignment"in ue&&t(14,g=ue.scrollToAlignment),"scrollToBehaviour"in ue&&t(15,m=ue.scrollToBehaviour),"overscanCount"in ue&&t(16,_=ue.overscanCount),"$$scope"in ue&&t(20,s=ue.$$scope)},n.$$.update=()=>{n.$$.dirty[0]&29568&&L(),n.$$.dirty[0]&524288&&V(),n.$$.dirty[0]&263264&&k&&K(0)},[f,T,I,D,M,r,o,l,a,u,c,h,d,p,g,m,_,K,k,x,s,i,Ae]}class rN extends _e{constructor(e){super(),me(this,e,sN,iN,ae,{height:5,width:6,itemCount:7,itemSize:8,estimatedItemSize:9,stickyIndices:10,getKey:0,scrollDirection:11,scrollOffset:12,scrollToIndex:13,scrollToAlignment:14,scrollToBehaviour:15,overscanCount:16,recomputeSizes:17},null,[-1,-1])}get recomputeSizes(){return this.$$.ctx[17]}}function jm(n){const e=n[40][n[44]];n[45]=e}function oN(n){const e=n.slice(),t=e[1]?50:25;e[41]=t;const i=e[1]?10:30;return e[42]=i,e}function qm(n){let e,t;return e=new kn({props:{show_label:!0,$$slots:{default:[lN]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s[0]&33|s[1]&32768&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function lN(n){let e=n[0].attrs.title+"",t,i,s,r,o=n[5].length+"",l,a;return{c(){t=ke(e),i=se(),s=z("span"),r=ke("("),l=ke(o),a=ke(")"),v(s,"class","count-text svelte-1fd1n9i")},m(u,c){A(u,t,c),A(u,i,c),A(u,s,c),F(s,r),F(s,l),F(s,a)},p(u,c){c[0]&1&&e!==(e=u[0].attrs.title+"")&&je(t,e),c[0]&32&&o!==(o=u[5].length+"")&&je(l,o)},d(u){u&&(E(t),E(i),E(s))}}}function aN(n){let e;return{c(){e=z("div"),e.innerHTML="(No items)",v(e,"class","comfy-empty-list svelte-1fd1n9i")},m(t,i){A(t,e,i)},p:Z,i:Z,o:Z,d(t){t&&E(e)}}}function uN(n){let e,t;return e=new rN({props:{items:n[40],width:"100%",height:Math.min(n[40].length,n[42])*n[41],itemCount:n[40].length,itemSize:n[41],overscanCount:5,scrollToIndex:n[11]!=null?yi(n[11]+n[42]-1,0,n[40].length-1):n[12],$$slots:{item:[cN,({style:i,index:s})=>({43:i,44:s}),({style:i,index:s})=>[0,(i?4096:0)|(s?8192:0)]]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s[1]&512&&(r.items=i[40]),s[0]&2|s[1]&512&&(r.height=Math.min(i[40].length,i[42])*i[41]),s[1]&512&&(r.itemCount=i[40].length),s[0]&2&&(r.itemSize=i[41]),s[0]&6146|s[1]&512&&(r.scrollToIndex=i[11]!=null?yi(i[11]+i[42]-1,0,i[40].length-1):i[12]),s[0]&6146|s[1]&45568&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function cN(n){jm(n);let e,t,i=n[45].label+"",s,r,o,l,a;function u(){return n[21](n[40],n[44])}function c(){return n[22](n[44])}function f(){return n[23](n[44])}return{c(){e=z("div"),t=z("span"),s=ke(i),v(t,"class","comfy-select-label"),v(e,"slot","item"),v(e,"class","comfy-select-item svelte-1fd1n9i"),v(e,"title",r=n[19](n[40][n[44]].label)),v(e,"style",o=n[43]),B(e,"mobile",n[1]),B(e,"active",n[11]===n[40][n[44]].index),B(e,"hover",n[12]===n[44])},m(h,d){A(h,e,d),F(e,t),F(t,s),l||(a=[ee(e,"click",u),ee(e,"focus",c),ee(e,"mouseover",f)],l=!0)},p(h,d){n=h,jm(n),d[1]&8704&&i!==(i=n[45].label+"")&&je(s,i),d[1]&8704&&r!==(r=n[19](n[40][n[44]].label))&&v(e,"title",r),d[1]&4096&&o!==(o=n[43])&&v(e,"style",o),d[0]&2&&B(e,"mobile",n[1]),d[0]&2048|d[1]&8704&&B(e,"active",n[11]===n[40][n[44]].index),d[0]&4096|d[1]&8192&&B(e,"hover",n[12]===n[44])},d(h){h&&E(e),l=!1,lt(a)}}}function fN(n){let e,t,i,s;const r=[uN,aN],o=[];function l(u,c){return u[40].length>0?0:1}function a(u,c){return c===0?oN(u):u}return t=l(n),i=o[t]=r[t](a(n,t)),{c(){e=z("div"),i.c(),v(e,"class","comfy-select-list svelte-1fd1n9i"),v(e,"slot","list"),B(e,"mobile",n[1]),ve(e,"--maxLabelWidth",n[2].maxLabelWidthChars||100)},m(u,c){A(u,e,c),o[t].m(e,null),s=!0},p(u,c){let f=t;t=l(u),t===f?o[t].p(a(u,t),c):(oe(),C(o[f],1,1,()=>{o[f]=null}),le(),i=o[t],i?i.p(a(u,t),c):(i=o[t]=r[t](a(u,t)),i.c()),S(i,1),i.m(e,null)),(!s||c[0]&2)&&B(e,"mobile",u[1]),c[0]&4&&ve(e,"--maxLabelWidth",u[2].maxLabelWidthChars||100)},i(u){s||(S(i),s=!0)},o(u){C(i),s=!1},d(u){u&&E(e),o[t].d()}}}function hN(n){let e,t,i,s,r,o,l,a,u,c,f=n[0].attrs.title!==""&&qm(n);function h(b){n[24](b)}function d(b){n[25](b)}function p(b){n[26](b)}function g(b){n[27](b)}function m(b){n[28](b)}let _={value:n[5].length===0?"(Loading...)":n[4],items:n[5],disabled:n[5].length===0||Kn(n[0]),clearable:!1,showChevron:!0,listAutoWidth:!0,inputAttributes:{autocomplete:"off"},$$slots:{list:[fN,({filteredItems:b})=>({40:b}),({filteredItems:b})=>[0,b?512:0]]},$$scope:{ctx:n}};return n[9]!==void 0&&(_.justValue=n[9]),n[12]!==void 0&&(_.hoverItemIndex=n[12]),n[13]!==void 0&&(_.filterText=n[13]),n[14]!==void 0&&(_.listOpen=n[14]),n[10]!==void 0&&(_.input=n[10]),s=new $O({props:_}),Ze.push(()=>jt(s,"justValue",h)),Ze.push(()=>jt(s,"hoverItemIndex",d)),Ze.push(()=>jt(s,"filterText",p)),Ze.push(()=>jt(s,"listOpen",g)),Ze.push(()=>jt(s,"input",m)),s.$on("change",n[29]),s.$on("focus",n[16]),s.$on("hoverItem",n[30]),s.$on("select",n[31]),s.$on("blur",n[32]),s.$on("filter",dN),{c(){e=z("div"),t=z("label"),f&&f.c(),i=se(),Y(s.$$.fragment),v(t,"title",n[15]),v(e,"class","wrapper comfy-combo svelte-1fd1n9i"),B(e,"mobile",n[1]),B(e,"updated",n[6])},m(b,y){A(b,e,y),F(e,t),f&&f.m(t,null),F(t,i),G(s,t,null),c=!0},p(b,y){b[0].attrs.title!==""?f?(f.p(b,y),y[0]&1&&S(f,1)):(f=qm(b),f.c(),S(f,1),f.m(t,i)):f&&(oe(),C(f,1,1,()=>{f=null}),le());const k={};y[0]&48&&(k.value=b[5].length===0?"(Loading...)":b[4]),y[0]&32&&(k.items=b[5]),y[0]&33&&(k.disabled=b[5].length===0||Kn(b[0])),y[0]&6150|y[1]&33280&&(k.$$scope={dirty:y,ctx:b}),!r&&y[0]&512&&(r=!0,k.justValue=b[9],Gt(()=>r=!1)),!o&&y[0]&4096&&(o=!0,k.hoverItemIndex=b[12],Gt(()=>o=!1)),!l&&y[0]&8192&&(l=!0,k.filterText=b[13],Gt(()=>l=!1)),!a&&y[0]&16384&&(a=!0,k.listOpen=b[14],Gt(()=>a=!1)),!u&&y[0]&1024&&(u=!0,k.input=b[10],Gt(()=>u=!1)),s.$set(k),(!c||y[0]&32768)&&v(t,"title",b[15]),(!c||y[0]&2)&&B(e,"mobile",b[1]),(!c||y[0]&64)&&B(e,"updated",b[6])},i(b){c||(S(f),S(s.$$.fragment,b),c=!0)},o(b){C(f),C(s.$$.fragment,b),c=!1},d(b){b&&E(e),f&&f.d(),j(s)}}}function dN(){}function pN(n,e,t){let i,s=Z,r=()=>(s(),s=ot(g,he=>t(4,i=he)),g),o,l=Z,a=()=>(l(),l=ot(_,he=>t(5,o=he)),_),u,c=Z,f=()=>(c(),c=ot(m,he=>t(6,u=he)),m);n.$$.on_destroy.push(()=>s()),n.$$.on_destroy.push(()=>l()),n.$$.on_destroy.push(()=>c());let{widget:h=null}=e,{isMobile:d=!1}=e,p=null,g=Be("");r();let m=Be(!1);f();let _=Be([]);a();let b=null,{debug:y=!1}=e,k=null;function T(he){he&&(t(2,p=he.node),r(t(3,g=p.value)),p.propsChanged,f(t(7,m=p.lightUp)),a(t(8,_=p.valuesForCombo)))}function I(he){const Se=i;t(11,R=he.findIndex(Je=>Je.value===Se))}function x(){D&&navigator.vibrate(20)}let R=null,N=null,O="",D=null;function M(he){t(12,N=he)}function L(he){navigator.vibrate(20);const Se=o[he];t(11,R=he),pi(g,i=Se.value,i),t(14,D=!1),t(13,O=""),setTimeout(()=>{k==null||k.blur()},100)}let V;function X(he){if(he==null){if(!g)return"";he=i}return he&&he.length>80?String(he):""}const q=(he,Se)=>L(he[Se].index),K=he=>M(he),Q=he=>M(he);function J(he){b=he,t(9,b)}function ce(he){N=he,t(12,N)}function pe(he){O=he,t(13,O)}function qe(he){D=he,t(14,D)}function Ae(he){k=he,t(10,k)}function ue(he){Ut.call(this,n,he)}const te=he=>M(he.detail),be=he=>L(he.detail.index);function ge(he){Ut.call(this,n,he)}return n.$$set=he=>{"widget"in he&&t(0,h=he.widget),"isMobile"in he&&t(1,d=he.isMobile),"debug"in he&&t(20,y=he.debug)},n.$$.update=()=>{n.$$.dirty[0]&1&&h&&T(h),n.$$.dirty[0]&13&&g!==null&&(T(h),t(2,p),t(3,g),t(0,h)),n.$$.dirty[0]&32&&o!=null&&I(o),n.$$.dirty[0]&64&&u&&setTimeout(()=>pi(m,u=!1,u),1e3),n.$$.dirty[0]&24&&g&&i&&t(15,V=X(i))},[h,d,p,g,i,o,u,m,_,b,k,R,N,O,D,V,x,M,L,X,y,q,K,Q,J,ce,pe,qe,Ae,ue,te,be,ge]}class gN extends _e{constructor(e){super(),me(this,e,pN,hN,ae,{widget:0,isMobile:1,debug:20},null,[-1,-1])}}class ha extends As{constructor(t){super(t,"A");P(this,"properties",{tags:[],defaultValue:"A",values:["A","B","C","D"],convertValueToLabelCode:""});P(this,"svelteComponentType",gN);P(this,"defaultValue","A");P(this,"saveUserState",!1);P(this,"firstLoad");P(this,"lightUp");P(this,"valuesForCombo");P(this,"maxLabelWidthChars",0);this.firstLoad=Be(!1),this.lightUp=Be(!0),this.valuesForCombo=Be([])}onPropertyChanged(t,i){}formatValues(t,i,s=!1){if(t==null)return;let r=this.properties.values!=t;this.properties.values=t;const o=ie(this.value);this.properties.values.indexOf(o)===-1&&(r=!0,this.value.set(i||this.properties.values[0])),s&&ie(this.firstLoad)&&r&&this.lightUp.set(!0);let l;this.properties.convertValueToLabelCode?l=new Function("value",this.properties.convertValueToLabelCode):l=u=>`${u}`,this.maxLabelWidthChars=0;let a=[];try{a=this.properties.values.map((u,c)=>{const f=l(u);return this.maxLabelWidthChars=Math.max(this.maxLabelWidthChars,f.length),{value:u,label:f,index:c}})}catch{a=this.properties.values.map((c,f)=>{const h=`${c}`;return this.maxLabelWidthChars=Math.max(this.maxLabelWidthChars,h.length),{value:c,label:h,index:f}})}this.firstLoad.set(!0),this.valuesForCombo.set(a)}onConnectOutput(t,i,s,r,o){if(!super.onConnectOutput(t,i,s,r,o))return!1;const l=this.properties;if(!("config"in s))return!0;const u=s.config;if(!(u.values instanceof Array)||u.values.length===0)return!1;l.values=Array.from(u.values);const c=ie(this.value);return l.values.indexOf(c)===-1&&this.setValue(u.defaultValue||l.values[0]),!0}parseValue(t){return typeof t!="string"||this.properties.values.indexOf(t)===-1?this.properties.values[0]:t}clampOneConfig(t){t.config.values?t.config.values.indexOf(this.properties.value)===-1&&(t.config.values.length===0?this.setValue(""):this.setValue(t.config.defaultValue||t.config.values[0])):this.setValue("")}onSerialize(t){super.onSerialize(t),t.properties.values=[]}stripUserState(t){super.stripUserState(t),t.properties.values=[],t.properties.defaultValue=null}}P(ha,"slotLayout",{inputs:[{name:"store",type:$.ACTION}],outputs:[{name:"value",type:"string"},{name:"changed",type:$.EVENT}]});w.registerNodeType({class:ha,title:"UI.Combo",desc:"Combo box outputting a string value",type:"ui/combo"});function Gh(n,e,t){if(n==null)return null;if(typeof n=="string")return{name:"file_data",data:n};if(Array.isArray(n)){const i=[];for(const s of n)s===null?i.push(null):i.push(Gh(s,e,t));return i}else n.is_file&&(t==null?n.data=e+"/file="+n.name:n.data="/proxy="+t+"/file="+n.name);return n}const mN=n=>{const e=new FileReader;return e.readAsDataURL(n),new Promise(t=>{e.onloadend=()=>{t(e.result)}})};function _N(n){let e,t,i,s,r,o,l,a,u;const c=n[15].default,f=De(c,n,n[14],null);return{c(){e=z("div"),f&&f.c(),t=se(),i=z("input"),v(i,"type","file"),v(i,"accept",n[0]),i.multiple=s=n[4]==="multiple"||void 0,v(i,"webkitdirectory",r=n[4]==="directory"||void 0),v(i,"mozdirectory",o=n[4]==="directory"||void 0),v(i,"class","svelte-1h87ywf"),v(e,"class","svelte-1h87ywf"),B(e,"center",n[2]),B(e,"boundedheight",n[1]),B(e,"flex",n[3])},m(h,d){A(h,e,d),f&&f.m(e,null),F(e,t),F(e,i),n[23](i),l=!0,a||(u=[ee(i,"change",n[8]),ee(e,"drag",Hn(Yi(n[16]))),ee(e,"dragstart",Hn(Yi(n[17]))),ee(e,"dragend",Hn(Yi(n[18]))),ee(e,"dragover",Hn(Yi(n[19]))),ee(e,"dragenter",Hn(Yi(n[20]))),ee(e,"dragleave",Hn(Yi(n[21]))),ee(e,"drop",Hn(Yi(n[22]))),ee(e,"click",n[7]),ee(e,"drop",n[9]),ee(e,"dragenter",n[6]),ee(e,"dragleave",n[6])],a=!0)},p(h,[d]){f&&f.p&&(!l||d&16384)&&Le(f,c,h,h[14],l?xe(c,h[14],d,null):Me(h[14]),null),(!l||d&1)&&v(i,"accept",h[0]),(!l||d&16&&s!==(s=h[4]==="multiple"||void 0))&&(i.multiple=s),(!l||d&16&&r!==(r=h[4]==="directory"||void 0))&&v(i,"webkitdirectory",r),(!l||d&16&&o!==(o=h[4]==="directory"||void 0))&&v(i,"mozdirectory",o),(!l||d&4)&&B(e,"center",h[2]),(!l||d&2)&&B(e,"boundedheight",h[1]),(!l||d&8)&&B(e,"flex",h[3])},i(h){l||(S(f,h),l=!0)},o(h){C(f,h),l=!1},d(h){h&&E(e),f&&f.d(h),n[23](null),a=!1,lt(u)}}}function bN(n,e,t){let{$$slots:i={},$$scope:s}=e,{filetype:r=null}=e,{include_file_metadata:o=!0}=e,{dragging:l=!1}=e,{boundedheight:a=!0}=e,{center:u=!0}=e,{flex:c=!0}=e,{file_count:f="single"}=e,{disable_click:h=!1}=e,{parse_to_data_url:d=!0}=e,p;const g=mi(),m=()=>{t(10,l=!l)},_=()=>{h||(t(5,p.value="",p),p.click())},b=async L=>{let V=Array.from(L);if(!(!L.length||!window.FileReader)){if(f==="single"&&(V=[L[0]]),o)var X=V.map(Q=>({name:Q.name,size:Q.size}));var q=[],K=[];d?K=await Promise.all(V.map(Q=>mN(Q))):K=V,o?d?q=K.map((Q,J)=>({data:Q,...X[J]})):q=K.map((Q,J)=>({data:"",blob:Q,...X[J]})):q=K,g("load",f==="single"?q[0]:q)}},y=async L=>{const V=L.target;V.files&&await b(V.files)},k=async L=>{var V;t(10,l=!1),(V=L.dataTransfer)!=null&&V.files&&await b(L.dataTransfer.files)};function T(L){Ut.call(this,n,L)}function I(L){Ut.call(this,n,L)}function x(L){Ut.call(this,n,L)}function R(L){Ut.call(this,n,L)}function N(L){Ut.call(this,n,L)}function O(L){Ut.call(this,n,L)}function D(L){Ut.call(this,n,L)}function M(L){Ze[L?"unshift":"push"](()=>{p=L,t(5,p)})}return n.$$set=L=>{"filetype"in L&&t(0,r=L.filetype),"include_file_metadata"in L&&t(11,o=L.include_file_metadata),"dragging"in L&&t(10,l=L.dragging),"boundedheight"in L&&t(1,a=L.boundedheight),"center"in L&&t(2,u=L.center),"flex"in L&&t(3,c=L.flex),"file_count"in L&&t(4,f=L.file_count),"disable_click"in L&&t(12,h=L.disable_click),"parse_to_data_url"in L&&t(13,d=L.parse_to_data_url),"$$scope"in L&&t(14,s=L.$$scope)},[r,a,u,c,f,p,m,_,y,k,l,o,h,d,s,i,T,I,x,R,N,O,D,M]}class yN extends _e{constructor(e){super(),me(this,e,bN,_N,ae,{filetype:0,include_file_metadata:11,dragging:10,boundedheight:1,center:2,flex:3,file_count:4,disable_click:12,parse_to_data_url:13})}}function Ym(n){let e,t;return e=new qu({props:{Icon:bA,label:"Edit"}}),e.$on("click",n[3]),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p:Z,i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function vN(n){let e,t,i,s,r=n[0]&&Ym(n);return i=new qu({props:{Icon:pw,label:"Clear"}}),i.$on("click",n[4]),{c(){e=z("div"),r&&r.c(),t=se(),Y(i.$$.fragment),v(e,"class","svelte-1wj0ocy"),B(e,"not-absolute",!n[1]),ve(e,"position",n[1]?"absolute":"static")},m(o,l){A(o,e,l),r&&r.m(e,null),F(e,t),G(i,e,null),s=!0},p(o,[l]){o[0]?r?(r.p(o,l),l&1&&S(r,1)):(r=Ym(o),r.c(),S(r,1),r.m(e,t)):r&&(oe(),C(r,1,1,()=>{r=null}),le()),(!s||l&2)&&B(e,"not-absolute",!o[1]),l&2&&ve(e,"position",o[1]?"absolute":"static")},i(o){s||(S(r),S(i.$$.fragment,o),s=!0)},o(o){C(r),C(i.$$.fragment,o),s=!1},d(o){o&&E(e),r&&r.d(),j(i)}}}function wN(n,e,t){let{editable:i=!1}=e,{absolute:s=!0}=e;const r=mi(),o=()=>r("edit"),l=a=>{r("clear"),a.stopPropagation()};return n.$$set=a=>{"editable"in a&&t(0,i=a.editable),"absolute"in a&&t(1,s=a.absolute)},[i,s,r,o,l]}class Tw extends _e{constructor(e){super(),me(this,e,wN,vN,ae,{editable:0,absolute:1})}}function Xm(n,e,t){const i=n.slice();return i[38]=e[t][0],i[39]=e[t][1],i[41]=t,i}function Km(n,e,t){const i=n.slice();return i[38]=e[t],i[42]=e,i[41]=t,i}function $m(n){let e,t;return e=new Qc({props:{show_label:n[3],Icon:fa,label:n[4]||"Gallery",disable:typeof n[6].container=="boolean"&&!n[6].container}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s[0]&8&&(r.show_label=i[3]),s[0]&16&&(r.label=i[4]||"Gallery"),s[0]&64&&(r.disable=typeof i[6].container=="boolean"&&!i[6].container),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function kN(n){let e,t,i,s,r,o=n[0]!==null&&Jm(n),l=Xe(n[9]),a=[];for(let u=0;un[32].call(t)),B(t,"fixed-height",!n[6].height||n[6].height=="auto")},m(u,c){o&&o.m(u,c),A(u,e,c),A(u,t,c),F(t,i);for(let f=0;f{o=null}),le()),c[0]&16897){l=Xe(u[9]);let f;for(f=0;fn[27].call(s)),B(s,"with-caption",!!n[9][n[0]][1]),v(c,"class","thumbnails scroll-hide svelte-1im3pwl"),v(e,"class","preview svelte-1im3pwl"),B(e,"fixed-height",n[6].height!=="auto")},m(_,b){A(_,e,b),G(t,e,null),F(e,i),F(e,s),n[26](s),F(e,a),p&&p.m(e,null),F(e,u),F(e,c);for(let y=0;yn[28](e,l),f=()=>n[28](null,l);function h(){return n[29](n[41])}return{c(){e=z("button"),t=z("img"),o=se(),Ti(t.src,i=n[38][0].data)||v(t,"src",i),v(t,"title",s=n[38][1]||null),v(t,"alt",r=n[38][1]||null),v(t,"class","svelte-1im3pwl"),v(e,"class","thumbnail-item thumbnail-small svelte-1im3pwl"),B(e,"selected",n[0]===n[41])},m(d,p){A(d,e,p),F(e,t),F(e,o),c(),a||(u=ee(e,"click",h),a=!0)},p(d,p){n=d,p[0]&512&&!Ti(t.src,i=n[38][0].data)&&v(t,"src",i),p[0]&512&&s!==(s=n[38][1]||null)&&v(t,"title",s),p[0]&512&&r!==(r=n[38][1]||null)&&v(t,"alt",r),l!==n[41]&&(f(),l=n[41],c()),p[0]&1&&B(e,"selected",n[0]===n[41])},d(d){d&&E(e),f(),a=!1,u()}}}function e0(n){let e,t=n[39]+"",i;return{c(){e=z("div"),i=ke(t),v(e,"class","caption-label svelte-1im3pwl")},m(s,r){A(s,e,r),F(e,i)},p(s,r){r[0]&512&&t!==(t=s[39]+"")&&je(i,t)},d(s){s&&E(e)}}}function t0(n){let e,t,i,s,r,o,l,a,u=n[39]&&e0(n);function c(){return n[31](n[41])}return{c(){e=z("button"),t=z("img"),r=se(),u&&u.c(),o=se(),v(t,"alt",i=n[39]||""),Ti(t.src,s=typeof n[38]=="string"?n[38]:n[38].data)||v(t,"src",s),v(t,"class","svelte-1im3pwl"),v(e,"class","thumbnail-item thumbnail-lg svelte-1im3pwl"),B(e,"selected",n[0]===n[41])},m(f,h){A(f,e,h),F(e,t),F(e,r),u&&u.m(e,null),F(e,o),l||(a=ee(e,"click",c),l=!0)},p(f,h){n=f,h[0]&512&&i!==(i=n[39]||"")&&v(t,"alt",i),h[0]&512&&!Ti(t.src,s=typeof n[38]=="string"?n[38]:n[38].data)&&v(t,"src",s),n[39]?u?u.p(n,h):(u=e0(n),u.c(),u.m(e,o)):u&&(u.d(1),u=null),h[0]&1&&B(e,"selected",n[0]===n[41])},d(f){f&&E(e),u&&u.d(),l=!1,a()}}}function TN(n){let e,t;return e=new fa({}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function CN(n){let e,t,i,s,r,o,l;vn(n[24]);let a=n[3]&&$m(n);const u=[SN,kN],c=[];function f(h,d){return h[5]===null||h[9]===null||h[9].length===0?0:1}return t=f(n),i=c[t]=u[t](n),{c(){a&&a.c(),e=se(),i.c(),s=we()},m(h,d){a&&a.m(h,d),A(h,e,d),c[t].m(h,d),A(h,s,d),r=!0,o||(l=ee(window,"resize",n[24]),o=!0)},p(h,d){h[3]?a?(a.p(h,d),d[0]&8&&S(a,1)):(a=$m(h),a.c(),S(a,1),a.m(e.parentNode,e)):a&&(oe(),C(a,1,1,()=>{a=null}),le());let p=t;t=f(h),t===p?c[t].p(h,d):(oe(),C(c[p],1,1,()=>{c[p]=null}),le(),i=c[t],i?i.p(h,d):(i=c[t]=u[t](h),i.c()),S(i,1),i.m(s.parentNode,s))},i(h){r||(S(a),S(i),r=!0)},o(h){C(a),C(i),r=!1},d(h){h&&(E(e),E(s)),a&&a.d(h),c[t].d(h),o=!1,l()}}}function IN(n,e,t){let i,s,r,o,l,{show_label:a=!0}=e,{label:u}=e,{root:c=""}=e,{root_url:f=null}=e,{focusOnScroll:h=!1}=e,{value:d=null}=e,{style:p={grid_cols:[2],object_fit:"cover",height:"auto"}}=e,{imageWidth:g=0}=e,{imageHeight:m=0}=e;const _=mi();let b=!0,y=d,{selected_image:k=null}=e,T=null,{forceSelectImage:I=null}=e;function x(te){switch(te.code){case"Escape":te.preventDefault(),t(0,k=null);break;case"ArrowLeft":te.preventDefault(),t(0,k=s);break;case"ArrowRight":te.preventDefault(),t(0,k=r);break}}let R=[],N;async function O(te){if(typeof te!="number")return;await yr(),h&&R[te].focus();const{left:be,width:ge}=N.getBoundingClientRect(),{left:he,width:Se}=R[te].getBoundingClientRect(),gt=he-be+Se/2-ge/2+N.scrollLeft;N.scrollTo({left:gt<0?0:gt,behavior:"smooth"})}function D(te){return t(13,l=Xo(te,["grid_cols","grid_rows","object_fit"]).styles),l+` height: ${te.height}`}let M=0,L=0,V=null;function X(){V&&_("clicked",V)}function q(){t(8,L=window.innerHeight)}const K=()=>t(0,k=null);function Q(te){Ze[te?"unshift":"push"](()=>{V=te,t(12,V)})}function J(){g=this.naturalWidth,m=this.naturalHeight,t(1,g),t(0,k),t(21,b),t(22,y),t(5,d),t(6,p),t(17,I),t(2,m),t(0,k),t(21,b),t(22,y),t(5,d),t(6,p),t(17,I)}function ce(te,be){Ze[te?"unshift":"push"](()=>{R[be]=te,t(10,R)})}const pe=te=>t(0,k=te);function qe(te){Ze[te?"unshift":"push"](()=>{N=te,t(11,N)})}const Ae=te=>t(0,k=o?te:k);function ue(){M=this.clientHeight,t(7,M)}return n.$$set=te=>{"show_label"in te&&t(3,a=te.show_label),"label"in te&&t(4,u=te.label),"root"in te&&t(18,c=te.root),"root_url"in te&&t(19,f=te.root_url),"focusOnScroll"in te&&t(20,h=te.focusOnScroll),"value"in te&&t(5,d=te.value),"style"in te&&t(6,p=te.style),"imageWidth"in te&&t(1,g=te.imageWidth),"imageHeight"in te&&t(2,m=te.imageHeight),"selected_image"in te&&t(0,k=te.selected_image),"forceSelectImage"in te&&t(17,I=te.forceSelectImage)},n.$$.update=()=>{if(n.$$.dirty[0]&6422625&&y!==d){if(b){let te=!!(p.preview&&(d!=null&&d.length)),be=0;I!=null&&(te=I,be=k,t(17,I=null)),t(0,k=te?be:null),t(21,b=!1)}else t(0,k=k!==null&&d!==null&&kArray.isArray(te)?[Gh(te[0],c,f),te[1]]:[Gh(te,c,f),null])),n.$$.dirty[0]&513&&(s=((k??0)+((i==null?void 0:i.length)??0)-1)%((i==null?void 0:i.length)??0)),n.$$.dirty[0]&513&&(r=((k??0)+1)%((i==null?void 0:i.length)??0)),n.$$.dirty[0]&8389121&&k!==T&&(t(23,T=k),k!==null&&_("select",{index:k,value:i==null?void 0:i[k][1]})),n.$$.dirty[0]&1&&O(k),n.$$.dirty[0]&384&&t(14,o=L>=M),n.$$.dirty[0]&64&&t(13,l=D(p))},[k,g,m,a,u,d,p,M,L,i,R,N,V,l,o,x,X,I,c,f,h,b,y,T,q,K,Q,J,ce,pe,qe,Ae,ue]}class EN extends _e{constructor(e){super(),me(this,e,IN,CN,ae,{show_label:3,label:4,root:18,root_url:19,focusOnScroll:20,value:5,style:6,imageWidth:1,imageHeight:2,selected_image:0,forceSelectImage:17},null,[-1,-1])}}const AN=n=>{let e=n.currentTarget;const t=e.getBoundingClientRect(),i=e.naturalWidth/t.width,s=e.naturalHeight/t.height;if(i>s){t.width;const l=e.naturalHeight/i,a=(t.height-l)/2;var r=Math.round((n.clientX-t.left)*i),o=Math.round((n.clientY-t.top-a)*i)}else{const l=e.naturalWidth/s;t.height;const a=(t.width-l)/2;var r=Math.round((n.clientX-t.left-a)*s),o=Math.round((n.clientY-t.top)*s)}return r<0||r>=e.naturalWidth||o<0||o>=e.naturalHeight?null:[r,o]};function ON(n){let e,t,i,s,r,o,l,a,u,c,f;return i=new qu({props:{Icon:mA,label:"Download"}}),r=new qu({props:{Icon:pw,label:"Remove"}}),r.$on("click",n[7]),{c(){e=z("div"),t=z("a"),Y(i.$$.fragment),s=se(),Y(r.$$.fragment),o=se(),l=z("img"),v(t,"href",n[0]),v(t,"target",window.__is_colab__?"_blank":null),v(t,"download","image"),v(e,"class","buttons svelte-ce8fvd"),Ti(l.src,a=n[0])||v(l,"src",a),v(l,"alt",""),v(l,"class","svelte-ce8fvd"),(n[1]===void 0||n[2]===void 0)&&vn(()=>n[8].call(l)),B(l,"selectable",n[5])},m(h,d){A(h,e,d),F(e,t),G(i,t,null),F(e,s),G(r,e,null),A(h,o,d),A(h,l,d),u=!0,c||(f=[ee(l,"click",n[6]),ee(l,"load",n[8])],c=!0)},p(h,d){(!u||d&1)&&v(t,"href",h[0]),(!u||d&1&&!Ti(l.src,a=h[0]))&&v(l,"src",a),(!u||d&32)&&B(l,"selectable",h[5])},i(h){u||(S(i.$$.fragment,h),S(r.$$.fragment,h),u=!0)},o(h){C(i.$$.fragment,h),C(r.$$.fragment,h),u=!1},d(h){h&&(E(e),E(o),E(l)),j(i),j(r),c=!1,lt(f)}}}function NN(n){let e,t;return e=new Mp({props:{size:"large",unpadded_box:!0,$$slots:{default:[DN]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&1024&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function DN(n){let e,t;return e=new fa({}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function xN(n){let e,t,i,s,r,o;e=new Qc({props:{show_label:n[4],Icon:fa,label:n[3]||"Image"}});const l=[NN,ON],a=[];function u(c,f){return c[0]===null?0:1}return i=u(n),s=a[i]=l[i](n),{c(){Y(e.$$.fragment),t=se(),s.c(),r=we()},m(c,f){G(e,c,f),A(c,t,f),a[i].m(c,f),A(c,r,f),o=!0},p(c,[f]){const h={};f&16&&(h.show_label=c[4]),f&8&&(h.label=c[3]||"Image"),e.$set(h);let d=i;i=u(c),i===d?a[i].p(c,f):(oe(),C(a[d],1,1,()=>{a[d]=null}),le(),s=a[i],s?s.p(c,f):(s=a[i]=l[i](c),s.c()),S(s,1),s.m(r.parentNode,r))},i(c){o||(S(e.$$.fragment,c),S(s),o=!0)},o(c){C(e.$$.fragment,c),C(s),o=!1},d(c){c&&(E(t),E(r)),j(e,c),a[i].d(c)}}}let LN=null;function MN(n,e,t){let{value:i}=e,{label:s=void 0}=e,{show_label:r}=e,{selectable:o=!1}=e,{imageWidth:l=0}=e,{imageHeight:a=0}=e;const u=mi(),c=d=>{let p=AN(d);p&&u("select",{index:p,value:null})};function f(){t(0,i=null)}function h(){l=this.naturalWidth,a=this.naturalHeight,t(1,l),t(0,i),t(2,a),t(0,i)}return n.$$set=d=>{"value"in d&&t(0,i=d.value),"label"in d&&t(3,s=d.label),"show_label"in d&&t(4,r=d.show_label),"selectable"in d&&t(5,o=d.selectable),"imageWidth"in d&&t(1,l=d.imageWidth),"imageHeight"in d&&t(2,a=d.imageHeight)},n.$$.update=()=>{n.$$.dirty&1&&i&&u("change",i),n.$$.dirty&1&&(i==null||!LN)&&(t(1,l=0),t(2,a=0))},[i,l,a,s,r,o,c,f,h]}class zp extends _e{constructor(e){super(),me(this,e,MN,xN,ae,{value:0,label:3,show_label:4,selectable:5,imageWidth:1,imageHeight:2})}}function cW(n){const e={};return Object.keys(n).forEach(t=>{typeof n[t]<"u"&&(e[t]=n[t])}),e}function fW(n){return typeof n=="string"&&n!==""}function La(n){return typeof n=="object"&&n!==null&&n.constructor&&n.constructor===Object}function Cw(){return Date.now()}function jh(){let n=!0,e,t;for(var i=arguments.length,s=new Array(i),r=0;r{typeof r=="object"&&r.constructor===Object?Object.keys(r).forEach(o=>{r[o]&&n.push(o)}):r&&n.push(r)});const s=[];return n.forEach(r=>{s.indexOf(r)<0&&s.push(r)}),s.join(" ")}function dW(n,e){const t=n();return(s,r)=>{!s||!s.trim().length||typeof s!="string"||s.trim().split(" ").forEach(o=>{const l=(o||"").trim();if(!l)return;const a=`on${l.charAt(0).toUpperCase()+l.slice(1)}`;t(l,r),typeof e[a]=="function"&&(Array.isArray(r)?e[a](...r||[]):e[a](r))})}}let qh=0,Yh=0;function RN(){qh=0,Yh=0}function pW(){return qh+=1,`${Cw()}_${qh}`}function gW(){return Yh+=1,`${Cw()}_${Yh}`}function mW(n){return typeof n>"u"||n===null?"":n}let pr;const at=typeof window<"u"&&window.Framework7ComponentsApp?window.Framework7ComponentsApp:{Framework7:void 0,f7:void 0,f7events:void 0,theme:{},f7routers:{views:[],tabs:[],modals:null}};typeof window<"u"&&(window.Framework7ComponentsApp=at);at.setInstance=n=>{pr=n};const PN=()=>{at.f7&&(at.theme.ios=at.f7.theme==="ios",at.f7.theme,at.theme.md=at.f7.theme==="md",at.f7.theme)},BN=()=>{RN(),delete at.theme.ios,delete at.theme.md,at.f7routers.views=[],at.f7routers.tabs=[],at.f7routers.modals=null},_W=()=>{at.f7events=new at.Framework7.Events},bW=function(n,e,t){e===void 0&&(e={}),t===void 0&&(t=!0);const i=jh({},e,{el:n,init:t});if(typeof e.store<"u"&&(i.store=e.store),i.routes||(i.routes=[]),i.userAgent&&(i.theme==="auto"||!i.theme)){const r=at.Framework7.getDevice({userAgent:i.userAgent},!0);at.theme.ios=!!r.ios,at.theme.md=!at.theme.ios}if(at.f7&&typeof window<"u")return;typeof window>"u"&&BN();const s=new at.Framework7(i);at.f7=s,pr=s,at.setInstance(s),PN(),s.initialized?(at.f7=s,pr=s,at.setInstance(s),at.f7events.emit("ready",at.f7)):s.on("init",()=>{at.f7=s,pr=s,at.setInstance(s),at.f7events.emit("ready",at.f7)})},yW=n=>{n&&(at.f7&&at.f7.initialized?n(at.f7):at.f7events.once("ready",n))},Kl=Be({activeModals:[]});function zN(n){const e=fi(),t={showCloseButton:!0,closeOnClick:!0,buttons:[],svelteProps:{},state:Be({}),...n,id:e,close:()=>Iw(e)};Kl.update(i=>(i.activeModals.push(t),i))}function Iw(n){const e=ie(Kl).activeModals.find(t=>t.id===n);e!=null&&Kl.update(t=>(e.onClose&&e.onClose(e),t.activeModals=t.activeModals.filter(i=>i.id!==n),t))}function FN(){Kl.set({activeModals:[]})}const So={...Kl,pushModal:zN,closeModal:Iw,closeAllModals:FN};function i0(n,e,t){const i=n.slice();return i[4]=e[t].workflow,i[5]=e[t].targetNodes,i}function n0(n,e,t){const i=n.slice();return i[8]=e[t],i}function WN(n){let e;return{c(){e=z("div"),e.textContent="(No receive targets found.)"},m(t,i){A(t,e,i)},p:Z,i:Z,o:Z,d(t){t&&E(e)}}}function VN(n){let e,t,i=Xe(n[0]),s=[];for(let o=0;oC(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;oC(o[a],1,1,()=>{o[a]=null});return{c(){Y(e.$$.fragment),t=se();for(let a=0;a0?0:1}return t=l(n),i=o[t]=r[t](n),{c(){e=z("div"),i.c(),v(e,"class","scroll-container svelte-17e1ti5")},m(a,u){A(a,e,u),o[t].m(e,null),s=!0},p(a,[u]){let c=t;t=l(a),t===c?o[t].p(a,u):(oe(),C(o[c],1,1,()=>{o[c]=null}),le(),i=o[t],i?i.p(a,u):(i=o[t]=r[t](a),i.c()),S(i,1),i.m(e,null))},i(a){s||(S(i),s=!0)},o(a){C(i),s=!1},d(a){a&&E(e),o[t].d()}}}function YN(n,e,t){const i=mi();let{receiveTargets:s=[]}=e;function r(l,a){i("select",{workflow:l,targetNode:a})}const o=(l,a)=>r(l,a);return n.$$set=l=>{"receiveTargets"in l&&t(0,s=l.receiveTargets)},[s,r,o]}class XN extends _e{constructor(e){super(),me(this,e,YN,qN,ae,{receiveTargets:0})}}function KN(n){let e,t,i;return{c(){e=z("span"),t=ke("Type: "),i=ke(n[0])},m(s,r){A(s,e,r),F(e,t),F(e,i)},p(s,r){r&1&&je(i,s[0])},d(s){s&&E(e)}}}function l0(n){let e,t;return e=new zp({props:{show_label:!1,label:"Image",value:n[2][0]}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&4&&(r.value=i[2][0]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function $N(n){let e,t,i=n[0]==="COMFYBOX_IMAGE"&&l0(n);return{c(){i&&i.c(),e=we()},m(s,r){i&&i.m(s,r),A(s,e,r),t=!0},p(s,r){s[0]==="COMFYBOX_IMAGE"?i?(i.p(s,r),r&1&&S(i,1)):(i=l0(s),i.c(),S(i,1),i.m(e.parentNode,e)):i&&(oe(),C(i,1,1,()=>{i=null}),le())},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d(s)}}}function JN(n){let e,t,i,s,r,o,l,a,u;return i=new yt({props:{$$slots:{default:[KN]},$$scope:{ctx:n}}}),r=new XN({props:{receiveTargets:n[1]}}),r.$on("select",n[6]),a=new yt({props:{$$slots:{default:[$N]},$$scope:{ctx:n}}}),{c(){e=z("div"),t=z("div"),Y(i.$$.fragment),s=se(),Y(r.$$.fragment),o=se(),l=z("div"),Y(a.$$.fragment),v(t,"class","targets-container svelte-2jsitd"),v(l,"class","output-display svelte-2jsitd"),v(e,"class","send-output-modal svelte-2jsitd")},m(c,f){A(c,e,f),F(e,t),G(i,t,null),F(t,s),G(r,t,null),F(e,o),F(e,l),G(a,l,null),u=!0},p(c,[f]){const h={};f&129&&(h.$$scope={dirty:f,ctx:c}),i.$set(h);const d={};f&2&&(d.receiveTargets=c[1]),r.$set(d);const p={};f&133&&(p.$$scope={dirty:f,ctx:c}),a.$set(p)},i(c){u||(S(i.$$.fragment,c),S(r.$$.fragment,c),S(a.$$.fragment,c),u=!0)},o(c){C(i.$$.fragment,c),C(r.$$.fragment,c),C(a.$$.fragment,c),u=!1},d(c){c&&E(e),j(i),j(r),j(a)}}}function ZN(n,e,t){let{value:i}=e,{type:s}=e,{receiveTargets:r=[]}=e,{_modal:o}=e,l=[];s==="COMFYBOX_IMAGE"&&(l=[ol(i)]);function a(c,f){const h={workflow:c,targetNode:f};o.state.set(h),o.close()}const u=c=>a(c.detail.workflow,c.detail.targetNode);return n.$$set=c=>{"value"in c&&t(4,i=c.value),"type"in c&&t(0,s=c.type),"receiveTargets"in c&&t(1,r=c.receiveTargets),"_modal"in c&&t(5,o=c._modal)},[s,r,l,a,i,o,u]}class QN extends _e{constructor(e){super(),me(this,e,ZN,JN,ae,{value:4,type:0,receiveTargets:1,_modal:5})}}const $l=Be({pointerNearTop:!1,pointerNearLeft:!1,showIndicator:!1,indicatorValue:null,graphTransitioning:!1,isJumpingToNode:!1,selectedTab:1,showSheet:!1,selectedWorkflowIndex:null,showingWorkflow:!1,isDarkMode:!1}),eD=yE(()=>{$l.update(n=>(n.showIndicator=!1,n))},1e3);function tD(n,e,t){if(!window)return;ie($l);let i=window.innerWidth/2,s=window.innerHeight/2;const r=n({...l,pointerNearTop:o,pointerNearLeft:r,showIndicator:!0,indicatorValue:t})),eD()}function iD(n,e,t,i){if(Bv(navigator.userAgent))$l.update(s=>(s.showSheet=!0,s));else{const s=r=>{i(r);const{workflow:o,targetNode:l}=ie(r.state);if(o==null||l==null)return;const a=window.app;a!=null&&(l.receiveOutput(n),ht.setActiveWorkflow(a.lCanvas,o.id))};So.pushModal({title:"Send Output",closeOnClick:!0,showCloseButton:!0,svelteComponent:QN,svelteProps:{value:n,type:e,receiveTargets:t},onClose:s})}}const Jl={...$l,showIndicator:tD,querySendOutput:iD};function Fp(n,e,t){return n.updateChildren(e,t.detail.items)}function Wp(n,e,t){const i=t.detail,s=i.info,r=i.items.find(l=>l.id===s.id);return(r==null?void 0:r.type)==="template"?sD(n,r,e,i.items):n.updateChildren(e,i.items)}function nD(n){return"insertTemplate"in n}function sD(n,e,t,i){var u;const s=n.workflow,r=i.findIndex(c=>c.id===e.id),o=i.filter(c=>c.id!==e.id),l=(u=s.canvases.app)==null?void 0:u.canvas;if(l==null||!nD(l)||l.graph!==s.graph)return o;n.updateChildren(t,o);const a=[l.visible_area[0]+l.visible_area[2]/2,l.visible_area[1]+l.visible_area[3]/2];return l.insertTemplate(e.template,a,t,r),ie(n).allItems[t.id].children}let ml=null;function a0(n,e,t={}){pr&&(ml&&(ml.destroy(),ml=null),history.pushState({type:"gallery"},""),ml=pr.photoBrowser.create({photos:n,theme:ie(Jl).isDarkMode?"dark":"light",type:"popup",...t}),ml.open(e))}function Vp(n,{from:e,to:t},i={}){const s=getComputedStyle(n),r=s.transform==="none"?"":s.transform,[o,l]=s.transformOrigin.split(" ").map(parseFloat),a=e.left+e.width*o/t.width-(t.left+o),u=e.top+e.height*l/t.height-(t.top+l),{delay:c=0,duration:f=d=>Math.sqrt(d)*120,easing:h=dw}=i;return{delay:c,duration:Xn(f)?f(Math.sqrt(a*a+u*u)):f,easing:h,css:(d,p)=>{const g=p*a,m=p*u,_=d+p*e.width/t.width,b=d+p*e.height/t.height;return`transform: ${r} translate(${g}px, ${m}px) scale(${_}, ${b});`}}}const rD={duration:4e3,initial:1,next:0,pausable:!1,dismissable:!0,reversed:!1,intro:{x:256}};function oD(){const{subscribe:n,update:e}=Be(new Array),t={};let i=0;function s(u){return u instanceof Object}function r(u="default",c={}){return t[u]=c,t}function o(u,c){const f={target:"default",...s(u)?u:{...c,msg:u}},h=t[f.target]||{},d={...rD,...h,...f,theme:{...h.theme,...f.theme},classes:[...h.classes||[],...f.classes||[]],id:++i};return e(p=>d.reversed?[...p,d]:[d,...p]),i}function l(u){e(c=>{if(!c.length||u===0)return[];if(typeof u=="function")return c.filter(h=>u(h));if(s(u))return c.filter(h=>h.target!==u.target);const f=u||Math.max(...c.map(h=>h.id));return c.filter(h=>h.id!==f)})}function a(u,c){const f=s(u)?u:{...c,id:u};e(h=>{const d=h.findIndex(p=>p.id===f.id);return d>-1&&(h[d]={...h[d],...f}),h})}return{subscribe:n,push:o,pop:l,set:a,_init:r}}const Xh=oD();function lD(n){let e,t,i,s;return{c(){e=z("div"),t=ke(n[0]),v(e,"class","svelte-49d8ld")},m(r,o){A(r,e,o),F(e,t),i||(s=ee(e,"click",n[1]),i=!0)},p(r,[o]){o&1&&je(t,r[0])},i:Z,o:Z,d(r){r&&E(e),i=!1,s()}}}function aD(n,e,t){let{message:i=""}=e,{notifyOptions:s}=e,{toastID:r}=e;function o(){s.onClick&&(s.onClick(),Xh.pop(r))}return n.$$set=l=>{"message"in l&&t(0,i=l.message),"notifyOptions"in l&&t(2,s=l.notifyOptions),"toastID"in l&&t(3,r=l.toastID)},[i,o,s,r]}class uD extends _e{constructor(e){super(),me(this,e,aD,lD,ae,{message:0,notifyOptions:2,toastID:3})}}function cD(n,e){if(!pr)return;let t=e.timeout;t===void 0&&(t=3e3);const i={};e.onClick&&(i.click=()=>e.onClick());let s=null;e.imageUrl&&(s=``),pr.notification.create({title:e.title,titleRightText:"now",text:n,closeOnClick:!0,closeTimeout:t,on:i,icon:s}).open()}function fD(n,e){const t={dismissable:e.timeout!==null,duration:e.timeout||5e3,theme:{}};e.showBar&&(t.theme["--toastBarHeight"]="6px"),e.type==="success"?(t.theme["--toastBackground"]="var(--color-green-600)",t.theme["--toastBarBackground"]="var(--color-green-900)"):e.type==="info"?(t.theme["--toastBackground"]="var(--color-blue-500)",t.theme["--toastBarBackground"]="var(--color-blue-800)"):e.type==="warning"?(t.theme["--toastBackground"]="var(--color-yellow-600)",t.theme["--toastBarBackground"]="var(--color-yellow-900)"):e.type==="error"&&(t.theme["--toastBackground"]="var(--color-red-500)",t.theme["--toastBarBackground"]="var(--color-red-800)"),e.onClick?Xh.push({component:{src:uD,props:{message:n,notifyOptions:e},sendIdTo:"toastID"},...t}):Xh.push(n,t)}function hD(n,e){if(window.Notification==null||document.hasFocus())return;const t=e.title||"ComfyBox",i={body:n};e.imageUrl&&(i.icon=e.imageUrl,i.image=e.imageUrl),e.timeout===null&&(i.requireInteraction=!0);const s=new Notification(t,i);s.onclick=()=>{window.focus(),e.onClick&&e.onClick()}}function nt(n,e={}){const t=e.showOn||"web";t!=="none"&&((t==="all"||t==="web")&&(cD(n,e),fD(n,e)),(t==="all"||t==="native")&&hD(n,e))}const Qt=Be({queueRunning:Be([]),queuePending:Be([]),queueCompleted:Be([]),queueRemaining:null,runningNodeID:null,executingNodes:new Set,progress:null,preview:null,isInterrupting:!1});function Kh(n){const[e,t,i,s,r]=n;return{number:e,queuedAt:null,finishedAt:null,promptID:t,prompt:i,extraData:s,goodOutputs:r,outputs:{},nodesRan:new Set,cachedNodes:new Set}}function dD(n){const e=Kh(n.prompt);return e.outputs=n.outputs,{entry:e,status:Object.values(e.outputs).length>0?"success":"all_cached",error:null}}function pD(n){Qt.update(e=>(e.queueRunning.set(n.running.map(Kh)),e.queuePending.set(n.pending.map(Kh)),e.queueRemaining=n.pending.length,e))}function gD(n){Qt.update(e=>{const t=Object.values(n.history);return e.queueCompleted.set(t.map(dD)),e})}function mD(n){Qt.update(e=>(e.progress=n,e))}function _D(n){Qt.update(e=>e.runningNodeID==null?(e.previewURL=null,e):(e.previewURL=URL.createObjectURL(n),e))}function bD(n){Qt.update(e=>(n!==null&&(e.queueRemaining=n.execInfo.queueRemaining),e))}function yD(n){const e=ie(Qt);let t=ie(e.queuePending).find(s=>s.promptID===n);if(t!=null||(t=ie(e.queueRunning).find(s=>s.promptID===n),t!=null))return t;let i=ie(e.queueCompleted).find(s=>s.entry.promptID===n);return i!=null?i.entry:null}function ll(n){const e=ie(Qt);let t=ie(e.queuePending).findIndex(i=>i.promptID===n);return t!==-1?[t,ie(e.queuePending)[t],e.queuePending]:(t=ie(e.queueRunning).findIndex(i=>i.promptID===n),t!==-1?[t,ie(e.queueRunning)[t],e.queueRunning]:[-1,null,null])}function vD(n){const e=ie(Qt);let t=ie(e.queuePending).findIndex(s=>s.promptID===n),i=!1;return t!==-1&&(e.queuePending.update(s=>(s.splice(t,1),s)),i=!0),t=ie(e.queueRunning).findIndex(s=>s.promptID===n),t!==-1&&(e.queueRunning.update(s=>(s.splice(t,1),s)),i=!0),t=ie(e.queueCompleted).findIndex(s=>s.entry.promptID===n),t!==-1&&(e.queueCompleted.update(s=>(s.splice(t,1),s)),i=!0),i}function wD(n,e){const t=ie(Qt),i=ie(e)[n];e.update(s=>(s.splice(n,1),s)),t.queueRunning.update(s=>(s.push(i),s)),t.isInterrupting=!1,Qt.set(t)}function pu(n,e,t,i,s){const r=ie(Qt),o=ie(e)[n];let l=null;s&&(l={type:"execution",error:s},o.nodesRan=new Set(s.executed)),o.finishedAt=new Date,e.update(u=>(u.splice(n,1),u));const a={entry:o,status:t,message:i,error:l};return r.queueCompleted.update(u=>(u.push(a),u)),r.isInterrupting=!1,Qt.set(r),a}function kD(n,e){let t=null;return Qt.update(i=>{var l,a;i.progress=null,i.executingNodes.clear();const[s,r,o]=ll(n);if(e!=null){if(r!=null&&r.nodesRan.add(e),i.runningNodeID=e,i.runningPromptID=n,(l=r==null?void 0:r.extraData)!=null&&l.workflowID){const u=ht.getWorkflow(r.extraData.workflowID);if(u!=null){let c=u.graph.getNodeByIdRecursive(i.runningNodeID);for(;c!=null;)i.executingNodes.add(c.id),c=(a=c.graph)==null?void 0:a._subgraph_node}}}else{if(r!=null){const u=Object.keys(r.prompt).length;if(r.cachedNodes.size>=Object.keys(r.prompt).length)nt("Prompt was cached, nothing to run.",{type:"warning",showOn:"web"}),pu(s,o,"all_cached","(Execution was cached)");else if(r.nodesRan.size>=u){const c=ht.getWorkflow(r.extraData.workflowID);c!=null&&c.attrs.showDefaultNotifications&&(ti.canShowNotificationText()&&nt("Prompt finished!",{type:"success"}),ti.canPlayNotificationSound()&&Rv("notification.mp3")),pu(s,o,"success")}else nt("Interrupted prompt."),pu(s,o,"interrupted",`Interrupted after ${r.nodesRan.size}/${u} nodes`)}i.progress=null,i.previewURL=null,i.runningNodeID=null,i.runningPromptID=null,i.executingNodes.clear()}return t=r,i}),t}function SD(n,e){Qt.update(t=>{const[i,s,r]=ll(n);if(s!=null)for(const o of e)s.nodesRan.add(o),s.cachedNodes.add(o);return t.isInterrupting=!1,t.progress=null,t.previewURL=null,t.runningNodeID=null,t.runningPromptID=null,t.executingNodes.clear(),t})}function TD(n){let e=null;return Qt.update(t=>{const[i,s,r]=ll(n.prompt_id);return s!=null&&(e=pu(i,r,"error","Error executing",n)),t.progress=null,t.previewURL=null,t.runningNodeID=null,t.runningPromptID=null,t.executingNodes.clear(),t}),e}function Ew(n,e=-1,t={},i={}){return{number:e,queuedAt:new Date,finishedAt:void 0,promptID:n,prompt:t,extraData:i,goodOutputs:[],outputs:{},nodesRan:new Set,cachedNodes:new Set}}function CD(n){Qt.update(e=>{const[t,i,s]=ll(n);if(i==null){const r=Ew(n);e.queueRunning.update(o=>(o.push(r),o))}else wD(t,s);return e.isInterrupting=!1,e.runningNodeID=null,e.runningPromptID=n,e.executingNodes.clear(),e})}function ID(n,e,t,i,s){Qt.update(r=>{const[o,l,a]=ll(e);if(l==null){const u=Ew(e,t,i,s);r.queuePending.update(c=>(c.push(u),c))}else l.number=t,l.prompt=i,l.extraData=s,a.set(ie(a));return r.isInterrupting=!1,r})}function ED(n,e,t){let i=null;return Qt.update(s=>{const[r,o,l]=ll(n);return o!=null&&(o.outputs[e]=t,l.set(ie(l))),i=o,s}),i}function AD(n,e){Qt.update(t=>(vD(e),t.isInterrupting=!1,t))}function OD(n){Qt.update(e=>(n==="queue"?(e.queuePending.set([]),e.queueRemaining=0,e.runningNodeID=null,e.runningPromptID=null,e.progress=null,e.previewURL=null,e.executingNodes.clear()):e.queueCompleted.set([]),e.isInterrupting=!1,e))}function ND(n,e,t,i){const s={type:"validation",workflowID:n,error:e,prompt:t,extraData:i},r={number:0,queuedAt:new Date,finishedAt:new Date,promptID:fi(),prompt:t.output,extraData:i,goodOutputs:[],outputs:{},nodesRan:new Set,cachedNodes:new Set},o={entry:r,status:"validation_failed",message:"Validation failed",error:s};return Qt.update(l=>(l.queueCompleted.update(a=>(a.push(o),a)),l)),r.promptID}const bt={...Qt,queueUpdated:pD,historyUpdated:gD,statusUpdated:bD,progressUpdated:mD,previewUpdated:_D,executionStart:CD,executingUpdated:kD,executionCached:SD,executionError:TD,afterQueued:ID,queueItemDeleted:AD,queueCleared:OD,getQueueEntry:yD,onExecuted:ED,promptError:ND};function DD(n){const e=n.slice(),t=e[11][e[11].length-1];e[33]=t;const i=ol(e[33]);return e[34]=i,e}function xD(n){const e=n.slice(),t=e[11].map(ol);return e[35]=t,e}function u0(n){let e,t,i,s;const r=[MD,LD],o=[];function l(u,c){return u[0].attrs.variant==="image"?0:1}function a(u,c){return c===1?xD(u):u}return e=l(n),t=o[e]=r[e](a(n,e)),{c(){t.c(),i=we()},m(u,c){o[e].m(u,c),A(u,i,c),s=!0},p(u,c){let f=e;e=l(u),e===f?o[e].p(a(u,e),c):(oe(),C(o[f],1,1,()=>{o[f]=null}),le(),t=o[e],t?t.p(a(u,e),c):(t=o[e]=r[e](a(u,e)),t.c()),S(t,1),t.m(i.parentNode,i))},i(u){s||(S(t),s=!0)},o(u){C(t),s=!1},d(u){u&&E(i),o[e].d(u)}}}function LD(n){let e,t,i,s;return t=new yt({props:{variant:"solid",padding:!1,$$slots:{default:[RD]},$$scope:{ctx:n}}}),{c(){e=z("div"),Y(t.$$.fragment),v(e,"class","wrapper comfy-gallery-widget gradio-gallery svelte-1vwl2ct"),v(e,"style",i=n[0].attrs.style||"")},m(r,o){A(r,e,o),G(t,e,null),s=!0},p(r,o){const l={};o[0]&32517|o[1]&32&&(l.$$scope={dirty:o,ctx:r}),t.$set(l),(!s||o[0]&1&&i!==(i=r[0].attrs.style||""))&&v(e,"style",i)},i(r){s||(S(t.$$.fragment,r),s=!0)},o(r){C(t.$$.fragment,r),s=!1},d(r){r&&E(e),j(t)}}}function MD(n){let e,t,i,s;return t=new yt({props:{variant:"solid",padding:!1,$$slots:{default:[FD]},$$scope:{ctx:n}}}),{c(){e=z("div"),Y(t.$$.fragment),v(e,"class","wrapper comfy-image-widget svelte-1vwl2ct"),v(e,"style",i=n[0].attrs.style||"")},m(r,o){A(r,e,o),G(t,e,null),s=!0},p(r,o){const l={};o[0]&14337|o[1]&32&&(l.$$scope={dirty:o,ctx:r}),t.$set(l),(!s||o[0]&1&&i!==(i=r[0].attrs.style||""))&&v(e,"style",i)},i(r){s||(S(t.$$.fragment,r),s=!0)},o(r){C(t.$$.fragment,r),s=!1},d(r){r&&E(e),j(t)}}}function c0(n){let e,t,i,s,r;return{c(){e=z("div"),t=z("img"),Ti(t.src,i=n[8].src)||v(t,"src",i),v(t,"class","svelte-1vwl2ct"),v(e,"class","comfy-gallery-preview svelte-1vwl2ct")},m(o,l){A(o,e,l),F(e,t),n[24](t),s||(r=[ee(t,"mouseout",f0),ee(e,"mouseover",VD),ee(e,"mouseout",f0)],s=!0)},p(o,l){l[0]&256&&!Ti(t.src,i=o[8].src)&&v(t,"src",i)},d(o){o&&E(e),n[24](null),s=!1,lt(r)}}}function RD(n){let e,t,i,s,r,o,l,a,u=n[8]&&n[2].runningPromptID!=null&&c0(n);function c(g){n[25](g)}function f(g){n[26](g)}function h(g){n[27](g)}function d(g){n[28](g)}let p={value:n[35],label:n[0].attrs.title,show_label:n[0].attrs.title!=="",style:n[15],root:"",root_url:""};return n[12]!==void 0&&(p.imageWidth=n[12]),n[13]!==void 0&&(p.imageHeight=n[13]),n[10]!==void 0&&(p.selected_image=n[10]),n[14]!==void 0&&(p.forceSelectImage=n[14]),i=new EN({props:p}),Ze.push(()=>jt(i,"imageWidth",c)),Ze.push(()=>jt(i,"imageHeight",f)),Ze.push(()=>jt(i,"selected_image",h)),Ze.push(()=>jt(i,"forceSelectImage",d)),i.$on("select",n[18]),i.$on("clicked",n[17]),{c(){e=z("div"),u&&u.c(),t=se(),Y(i.$$.fragment),v(e,"class","padding svelte-1vwl2ct")},m(g,m){A(g,e,m),u&&u.m(e,null),F(e,t),G(i,e,null),a=!0},p(g,m){g[8]&&g[2].runningPromptID!=null?u?u.p(g,m):(u=c0(g),u.c(),u.m(e,t)):u&&(u.d(1),u=null);const _={};m[0]&2048&&(_.value=g[35]),m[0]&1&&(_.label=g[0].attrs.title),m[0]&1&&(_.show_label=g[0].attrs.title!==""),!s&&m[0]&4096&&(s=!0,_.imageWidth=g[12],Gt(()=>s=!1)),!r&&m[0]&8192&&(r=!0,_.imageHeight=g[13],Gt(()=>r=!1)),!o&&m[0]&1024&&(o=!0,_.selected_image=g[10],Gt(()=>o=!1)),!l&&m[0]&16384&&(l=!0,_.forceSelectImage=g[14],Gt(()=>l=!1)),i.$set(_)},i(g){a||(S(i.$$.fragment,g),a=!0)},o(g){C(i.$$.fragment,g),a=!1},d(g){g&&E(e),u&&u.d(),j(i)}}}function PD(n){let e,t;return e=new Mp({props:{size:"large",unpadded_box:!0,$$slots:{default:[zD]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s[1]&32&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function BD(n){let e,t,i,s;function r(a){n[22](a)}function o(a){n[23](a)}let l={value:n[34],show_label:n[0].attrs.title!="",label:n[0].attrs.title};return n[12]!==void 0&&(l.imageWidth=n[12]),n[13]!==void 0&&(l.imageHeight=n[13]),e=new zp({props:l}),Ze.push(()=>jt(e,"imageWidth",r)),Ze.push(()=>jt(e,"imageHeight",o)),e.$on("select",n[16]),{c(){Y(e.$$.fragment)},m(a,u){G(e,a,u),s=!0},p(a,u){const c={};u[0]&2048&&(c.value=a[34]),u[0]&1&&(c.show_label=a[0].attrs.title!=""),u[0]&1&&(c.label=a[0].attrs.title),!t&&u[0]&4096&&(t=!0,c.imageWidth=a[12],Gt(()=>t=!1)),!i&&u[0]&8192&&(i=!0,c.imageHeight=a[13],Gt(()=>i=!1)),e.$set(c)},i(a){s||(S(e.$$.fragment,a),s=!0)},o(a){C(e.$$.fragment,a),s=!1},d(a){j(e,a)}}}function zD(n){let e,t;return e=new fa({}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function FD(n){let e,t,i,s;const r=[BD,PD],o=[];function l(u,c){return u[11]&&u[11].length>0?0:1}function a(u,c){return c===0?DD(u):u}return e=l(n),t=o[e]=r[e](a(n,e)),{c(){t.c(),i=we()},m(u,c){o[e].m(u,c),A(u,i,c),s=!0},p(u,c){let f=e;e=l(u),e===f?o[e].p(a(u,e),c):(oe(),C(o[f],1,1,()=>{o[f]=null}),le(),t=o[e],t?t.p(a(u,e),c):(t=o[e]=r[e](a(u,e)),t.c()),S(t,1),t.m(i.parentNode,i))},i(u){s||(S(t),s=!0)},o(u){C(t),s=!1},d(u){u&&E(i),o[e].d(u)}}}function WD(n){let e,t,i=n[0]&&n[1]&&n[3]&&n[11]&&u0(n);return{c(){i&&i.c(),e=we()},m(s,r){i&&i.m(s,r),A(s,e,r),t=!0},p(s,r){s[0]&&s[1]&&s[3]&&s[11]?i?(i.p(s,r),r[0]&2059&&S(i,1)):(i=u0(s),i.c(),S(i,1),i.m(e.parentNode,e)):i&&(oe(),C(i,1,1,()=>{i=null}),le())},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d(s)}}}function f0(){}function VD(){}function HD(n,e,t){let i,s=Z,r=()=>(s(),s=ot(O,Se=>t(10,i=Se)),O),o,l=Z,a=()=>(l(),l=ot(x,Se=>t(11,o=Se)),x),u,c,f,h=Z,d=()=>(h(),h=ot(R,Se=>t(12,f=Se)),R),p,g=Z,m=()=>(g(),g=ot(N,Se=>t(13,p=Se)),N),_,b=Z,y=()=>(b(),b=ot(D,Se=>t(14,_=Se)),D);Si(n,bt,Se=>t(2,u=Se)),Si(n,bi,Se=>t(21,c=Se)),n.$$.on_destroy.push(()=>s()),n.$$.on_destroy.push(()=>l()),n.$$.on_destroy.push(()=>h()),n.$$.on_destroy.push(()=>g()),n.$$.on_destroy.push(()=>b());let{widget:k=null}=e,{isMobile:T=!1}=e,I=null,x=null;a();let R=Be(0);d();let N=Be(0);m();let O=Be(null);r();let D=Be(null);y();function M(Se){return Se!=null&&Se.length>0?I.properties.tags.length>0&&I.properties.tags.every(Je=>Se.includes(Je)):I.properties.tags.length===0}let L,V=null,X=null;function q(Se){Se&&(t(1,I=Se.node),a(t(3,x=I.value)),I.propsChanged,d(t(4,R=I.imageWidth)),m(t(5,N=I.imageHeight)),r(t(6,O=I.selectedImage)),y(t(7,D=I.forceSelectImage)),t(20,L=null),t(8,V=null),o!=null&&(I.properties.index<0||I.properties.index>=o.length)&&I.setProperty("index",yi(I.properties.index,0,o.length)))}let K={grid_cols:[T?2:3],object_fit:"cover"};function Q(Se,Je){const gt=Se.closest("div.block");if(!gt||zs.all_gallery_buttons(gt).length===0)return;const fe=zs.all_gallery_buttons(gt).map(Te=>({url:Te.children[0].src}));a0(fe,Je,{thumbs:fe})}function J(Se){const Je=o.map(ol);T?a0(Je,0,{thumbs:Je}):zs.instance.showModal(Je,0)}function ce(Se){T?Q(Se.detail,i):zs.instance.showLightbox(Se.detail)}function pe(Se){I.setProperty("index",Se.detail.index)}function qe(Se){f=Se,R.set(f)}function Ae(Se){p=Se,N.set(p)}function ue(Se){Ze[Se?"unshift":"push"](()=>{X=Se,t(9,X)})}function te(Se){f=Se,R.set(f)}function be(Se){p=Se,N.set(p)}function ge(Se){i=Se,O.set(i)}function he(Se){_=Se,D.set(_)}return n.$$set=Se=>{"widget"in Se&&t(0,k=Se.widget),"isMobile"in Se&&t(19,T=Se.isMobile)},n.$$.update=()=>{var Se,Je,gt;if(n.$$.dirty[0]&1&&k&&q(k),n.$$.dirty[0]&3145734)if(t(20,L=u.previewURL),L&&u.runningPromptID&&!c.hidePreviews&&I.properties.showPreviews){const Ii=bt.getQueueEntry(u.runningPromptID);if(Ii!=null){const fe=(gt=(Je=(Se=Ii.extraData)==null?void 0:Se.extra_pnginfo)==null?void 0:Je.comfyBoxPrompt)==null?void 0:gt.subgraphs;M(fe)&&Lp(L).then(Te=>{t(8,V=Te)})}}else t(8,V=null)},[k,I,u,x,R,N,O,D,V,X,i,o,f,p,_,K,J,ce,pe,T,L,c,qe,Ae,ue,te,be,ge,he]}class UD extends _e{constructor(e){super(),me(this,e,HD,WD,ae,{widget:0,isMobile:19},null,[-1,-1])}}class $h extends As{constructor(t){super(t,[]);P(this,"properties",{tags:[],defaultValue:[],index:0,updateMode:"replace",autoSelectOnUpdate:!0,showPreviews:!0});P(this,"svelteComponentType",UD);P(this,"defaultValue",[]);P(this,"saveUserState",!1);P(this,"outputSlotName",null);P(this,"changedEventName",null);P(this,"selectedFilename",null);P(this,"selectedIndexWidget");P(this,"modeWidget");P(this,"imageWidth",Be(0));P(this,"imageHeight",Be(0));P(this,"selectedImage",Be(null));P(this,"forceSelectImage",Be(null));P(this,"_newSelectedIndex",null);this.selectedIndexWidget=this.addWidget("text","Selected",String(ie(this.selectedImage))),this.selectedIndexWidget.disabled=!0,this.modeWidget=this.addWidget("combo","Mode",this.properties.updateMode,null,{property:"updateMode",values:["replace","append"]}),this.defaultValue=[]}onPropertyChanged(t,i){t==="updateMode"&&(this.modeWidget.value=i)}onExecute(){const t=ie(this.value),i=ie(this.selectedImage);if(this.setOutputData(0,t),this.setOutputData(1,i),this.selectedIndexWidget.value=String(i),i!=null&&t&&t[i]!=null){const s=t[i];s.width=ie(this.imageWidth),s.height=ie(this.imageHeight)}}onAction(t,i,s){super.onAction(t,i,s)}formatValue(t){return`Images: ${(t==null?void 0:t.length)||0}`}setValue(t,i=!1){super.setValue(t,i);const s=this._newSelectedIndex;if(this._newSelectedIndex=null,s!=null){this.selectedImage.set(s),this.forceSelectImage.set(!0);const r=this.getValue()[s];r&&(this.imageWidth.set(r.width||0),this.imageHeight.set(r.height||0))}}stripUserState(t){super.stripUserState(t),t.properties.defaultValue=[],t.comfyValue=[]}parseValue(t){if(t==null)return[];let i=this.properties.updateMode,s=null;typeof t=="object"&&t.galleryImages!=null&&(s=t.selectedIndex,i=t.updateMode||i,t=t.galleryImages);const r=Sp(t)||[];if(i==="append"){const o=ie(this.value);if(r.length>0&&(s!=null||this.properties.autoSelectOnUpdate)){let l=s;l==null&&(l=0),this._newSelectedIndex=Uo(o.length+l,0,o.length+r.length-1)}return o.concat(r)}else{if(this.notifyPropsChanged(),r.length>0&&(s!=null||this.properties.autoSelectOnUpdate)){let o=s;o==null&&(o=ie(this.selectedImage)),o!=null&&(this._newSelectedIndex=Uo(o,0,r.length-1))}return r}}}P($h,"slotLayout",{inputs:[{name:"images",type:"OUTPUT"},{name:"store",type:$.ACTION,options:{color_off:"rebeccapurple",color_on:"rebeccapurple"}}],outputs:[{name:"images",type:"COMFYBOX_IMAGES"},{name:"selected_index",type:"number"}]}),P($h,"propertyLayout",[{name:"updateMode",defaultValue:"replace",type:"enum",options:{values:["replace","append"]}}]);w.registerNodeType({class:$h,title:"UI.Gallery",desc:"Gallery that shows most recent outputs",type:"ui/gallery"});function GD(n){let e,t,i;const s=n[7].default,r=De(s,n,n[6],null);return{c(){e=z("div"),r&&r.c(),v(e,"id",n[1]),v(e,"class",t=mr(n[2].join(" "))+" svelte-1hiax8p"),ve(e,"--row-min-width",n[5]),B(e,"compact",n[4]==="compact"),B(e,"panel",n[4]==="panel"),B(e,"unequal-height",n[0].equal_height===!1),B(e,"stretch",n[0].equal_height),B(e,"hide",!n[3])},m(o,l){A(o,e,l),r&&r.m(e,null),i=!0},p(o,[l]){r&&r.p&&(!i||l&64)&&Le(r,s,o,o[6],i?xe(s,o[6],l,null):Me(o[6]),null),(!i||l&2)&&v(e,"id",o[1]),(!i||l&4&&t!==(t=mr(o[2].join(" "))+" svelte-1hiax8p"))&&v(e,"class",t),(!i||l&32)&&ve(e,"--row-min-width",o[5]),(!i||l&20)&&B(e,"compact",o[4]==="compact"),(!i||l&20)&&B(e,"panel",o[4]==="panel"),(!i||l&5)&&B(e,"unequal-height",o[0].equal_height===!1),(!i||l&5)&&B(e,"stretch",o[0].equal_height),(!i||l&12)&&B(e,"hide",!o[3])},i(o){i||(S(r,o),i=!0)},o(o){C(r,o),i=!1},d(o){o&&E(e),r&&r.d(o)}}}function jD(n,e,t){let{$$slots:i={},$$scope:s}=e,{style:r={}}=e,{elem_id:o}=e,{elem_classes:l=[]}=e,{visible:a=!0}=e,{variant:u="default"}=e,{min_width:c="160px"}=e;return n.$$set=f=>{"style"in f&&t(0,r=f.style),"elem_id"in f&&t(1,o=f.elem_id),"elem_classes"in f&&t(2,l=f.elem_classes),"visible"in f&&t(3,a=f.visible),"variant"in f&&t(4,u=f.variant),"min_width"in f&&t(5,c=f.min_width),"$$scope"in f&&t(6,s=f.$$scope)},[r,o,l,a,u,c,s,i]}class Xr extends _e{constructor(e){super(),me(this,e,jD,GD,ae,{style:0,elem_id:1,elem_classes:2,visible:3,variant:4,min_width:5})}}function qD(n){let e,t="Drop Image here",i,s,r,o,l="Click to Upload",a;return{c(){e=z("div"),i=ke(t),s=se(),r=z("span"),r.textContent="- or -",o=se(),a=ke(l),v(r,"class","or svelte-8ytugg"),v(e,"class","wrap svelte-8ytugg")},m(u,c){A(u,e,c),F(e,i),F(e,s),F(e,r),F(e,o),F(e,a)},p:Z,i:Z,o:Z,d(u){u&&E(e)}}}function YD(n,e,t){let{type:i="file"}=e;return n.$$set=s=>{"type"in s&&t(0,i=s.type)},[i]}class XD extends _e{constructor(e){super(),me(this,e,YD,qD,ae,{type:0})}}function KD(n){const e=n.slice(),t=e[0][0];return e[28]=t,e}function h0(n){let e,t;return e=new yt({props:{visible:!0,variant:n[0]===null||n[0].length===0?"dashed":"solid",border_mode:n[9]?"focus":"base",padding:!0,elem_id:"comfy-image-upload-block",elem_classes:n[5],$$slots:{default:[QD]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&1&&(r.variant=i[0]===null||i[0].length===0?"dashed":"solid"),s&512&&(r.border_mode=i[9]?"focus":"base"),s&32&&(r.elem_classes=i[5]),s&536872863&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function d0(n){let e,t;return e=new Qc({props:{label:n[7],show_label:n[7]!="",Icon:vA,float:n[7]!=""}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&128&&(r.label=i[7]),s&128&&(r.show_label=i[7]!=""),s&128&&(r.float=i[7]!=""),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function $D(n){let e,t,i;function s(o){n[20](o)}let r={file_count:n[4],filetype:"image/*",parse_to_data_url:!1,$$slots:{default:[ZD]},$$scope:{ctx:n}};return n[9]!==void 0&&(r.dragging=n[9]),e=new yN({props:r}),Ze.push(()=>jt(e,"dragging",s)),e.$on("change",n[14]),e.$on("load",n[12]),e.$on("clear",n[21]),e.$on("select",n[22]),{c(){Y(e.$$.fragment)},m(o,l){G(e,o,l),i=!0},p(o,l){const a={};l&16&&(a.file_count=o[4]),l&536870912&&(a.$$scope={dirty:l,ctx:o}),!t&&l&512&&(t=!0,a.dragging=o[9],Gt(()=>t=!1)),e.$set(a)},i(o){i||(S(e.$$.fragment,o),i=!0)},o(o){C(e.$$.fragment,o),i=!1},d(o){j(e,o)}}}function JD(n){let e,t,i,s,r,o,l=n[8],a,u,c,f;e=new Tw({props:{absolute:!0}}),e.$on("clear",n[13]);let h=g0(n);return{c(){Y(e.$$.fragment),t=se(),i=z("img"),o=se(),h.c(),a=we(),Ti(i.src,s=Gs(n[28]))||v(i,"src",s),v(i,"alt",r=n[28].filename),v(i,"class","svelte-7aqtz8"),(n[1]===void 0||n[2]===void 0)&&vn(()=>n[19].call(i))},m(d,p){G(e,d,p),A(d,t,p),A(d,i,p),n[18](i),A(d,o,p),h.m(d,p),A(d,a,p),u=!0,c||(f=[ee(i,"click",n[11]),ee(i,"load",n[19])],c=!0)},p(d,p){(!u||p&1&&!Ti(i.src,s=Gs(d[28])))&&v(i,"src",s),(!u||p&1&&r!==(r=d[28].filename))&&v(i,"alt",r),p&256&&ae(l,l=d[8])?(h.d(1),h=g0(d),h.c(),h.m(a.parentNode,a)):h.p(d,p)},i(d){u||(S(e.$$.fragment,d),u=!0)},o(d){C(e.$$.fragment,d),u=!1},d(d){d&&(E(t),E(i),E(o),E(a)),j(e,d),n[18](null),h.d(d),c=!1,lt(f)}}}function ZD(n){let e,t;return e=new XD({props:{type:"file"}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p:Z,i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function p0(n){let e,t,i,s,r;return{c(){e=z("img"),Ti(e.src,t=Gs(n[8]))||v(e,"src",t),v(e,"alt",i=n[28].filename),v(e,"class","svelte-7aqtz8")},m(o,l){A(o,e,l),s||(r=ee(e,"click",n[11]),s=!0)},p(o,l){l&256&&!Ti(e.src,t=Gs(o[8]))&&v(e,"src",t),l&1&&i!==(i=o[28].filename)&&v(e,"alt",i)},d(o){o&&E(e),s=!1,r()}}}function g0(n){let e,t=n[8]&&p0(n);return{c(){t&&t.c(),e=we()},m(i,s){t&&t.m(i,s),A(i,e,s)},p(i,s){i[8]?t?t.p(i,s):(t=p0(i),t.c(),t.m(e.parentNode,e)):t&&(t.d(1),t=null)},d(i){i&&E(e),t&&t.d(i)}}}function QD(n){let e,t,i,s,r,o=n[7]!=""&&d0(n);const l=[JD,$D],a=[];function u(f,h){return f[0]&&f[0].length>0&&!f[10]?0:1}function c(f,h){return h===0?KD(f):f}return t=u(n),i=a[t]=l[t](c(n,t)),{c(){o&&o.c(),e=se(),i.c(),s=we()},m(f,h){o&&o.m(f,h),A(f,e,h),a[t].m(f,h),A(f,s,h),r=!0},p(f,h){f[7]!=""?o?(o.p(f,h),h&128&&S(o,1)):(o=d0(f),o.c(),S(o,1),o.m(e.parentNode,e)):o&&(oe(),C(o,1,1,()=>{o=null}),le());let d=t;t=u(f),t===d?a[t].p(c(f,t),h):(oe(),C(a[d],1,1,()=>{a[d]=null}),le(),i=a[t],i?i.p(c(f,t),h):(i=a[t]=l[t](c(f,t)),i.c()),S(i,1),i.m(s.parentNode,s))},i(f){r||(S(o),S(i),r=!0)},o(f){C(o),C(i),r=!1},d(f){f&&(E(e),E(s)),o&&o.d(f),a[t].d(f)}}}function e5(n){let e,t,i=n[0]&&h0(n);return{c(){e=z("div"),i&&i.c(),v(e,"class","image-upload svelte-7aqtz8"),v(e,"style",n[6])},m(s,r){A(s,e,r),i&&i.m(e,null),t=!0},p(s,[r]){s[0]?i?(i.p(s,r),r&1&&S(i,1)):(i=h0(s),i.c(),S(i,1),i.m(e,null)):i&&(oe(),C(i,1,1,()=>{i=null}),le()),(!t||r&64)&&v(e,"style",s[6])},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d()}}}function t5(n,e,t){let{value:i=null}=e,{imgWidth:s=0}=e,{imgHeight:r=0}=e,{imgElem:o=null}=e,{fileCount:l="single"}=e,{elem_classes:a=[]}=e,{style:u=""}=e,{label:c=""}=e,{mask:f}=e,h=!1,d=!1,p=null,g=null,m=!1;const _=mi();i&&(g=null,o&&(o.src=Gs(i[0])));function b(){_("change",i)}function y(){_("image_clicked")}async function k(L){return _("uploading"),NE(L)}async function T({detail:L}){t(16,g=Array.isArray(L)?L:[L]),t(17,m=!0)}function I(L){t(16,g=null),t(0,i=[]),t(1,s=0),t(2,r=0),_("change",i),_("clear")}function x(L){t(16,g=L.detail)}function R(L){Ze[L?"unshift":"push"](()=>{o=L,t(3,o)})}function N(){s=this.naturalWidth,r=this.naturalHeight,t(1,s),t(16,g),t(15,p),t(17,m),t(0,i),t(2,r),t(16,g),t(15,p),t(17,m),t(0,i)}function O(L){h=L,t(9,h)}function D(L){Ut.call(this,n,L)}function M(L){Ut.call(this,n,L)}return n.$$set=L=>{"value"in L&&t(0,i=L.value),"imgWidth"in L&&t(1,s=L.imgWidth),"imgHeight"in L&&t(2,r=L.imgHeight),"imgElem"in L&&t(3,o=L.imgElem),"fileCount"in L&&t(4,l=L.fileCount),"elem_classes"in L&&t(5,a=L.elem_classes),"style"in L&&t(6,u=L.style),"label"in L&&t(7,c=L.label),"mask"in L&&t(8,f=L.mask)},n.$$.update=()=>{if(n.$$.dirty&229377&&(JSON.stringify(g)!==JSON.stringify(p)||m)){t(17,m=!1),t(10,d=!0),t(1,s=0),t(2,r=0),t(15,p=g),g==null?t(16,g=[]):Array.isArray(g)||t(16,g=[g]);const L=g.map(V=>V.blob);if(L==null||L.length===0)t(16,g=null),t(0,i=null),b(),t(10,d=!1);else if(!L.every(V=>V!=null))t(16,g=null),t(0,i=null),b(),t(10,d=!1);else{let V=(Array.isArray(g)?g:[g]).map(q=>q.blob),X=g;t(10,d=!0),k(V).then(q=>{JSON.stringify(X)===JSON.stringify(g)&&(t(10,d=!1),q.error&&nt(q.error,{type:"error"}),t(0,i=q.files),_("change",i),_("uploaded",i))}).catch(q=>{_("upload_error",q)})}}},[i,s,r,o,l,a,u,c,f,h,d,y,T,I,x,p,g,m,R,N,O,D,M]}class Aw extends _e{constructor(e){super(),me(this,e,t5,e5,ae,{value:0,imgWidth:1,imgHeight:2,imgElem:3,fileCount:4,elem_classes:5,style:6,label:7,mask:8})}}function i5(n){let e,t,i,s;const r=n[2].default,o=De(r,n,n[1],null);let l=[{xmlns:"http://www.w3.org/2000/svg"},{width:"16"},{height:"16"},{fill:"currentColor"},{viewBox:"0 0 16 16"},n[0]],a={};for(let u=0;u{e=et(et({},e),Zn(l)),t(0,s=zt(e,i)),"$$scope"in l&&t(1,o=l.$$scope)},[s,o,r]}class s5 extends _e{constructor(e){super(),me(this,e,n5,i5,ae,{})}}function r5(n){let e,t,i,s;const r=n[2].default,o=De(r,n,n[1],null);let l=[{xmlns:"http://www.w3.org/2000/svg"},{width:"16"},{height:"16"},{fill:"currentColor"},{viewBox:"0 0 16 16"},n[0]],a={};for(let u=0;u{e=et(et({},e),Zn(l)),t(0,s=zt(e,i)),"$$scope"in l&&t(1,o=l.$$scope)},[s,o,r]}class l5 extends _e{constructor(e){super(),me(this,e,o5,r5,ae,{})}}function a5(n){let e,t,i;const s=n[2].default,r=De(s,n,n[1],null);let o=[{xmlns:"http://www.w3.org/2000/svg"},{width:"16"},{height:"16"},{fill:"currentColor"},{viewBox:"0 0 16 16"},n[0]],l={};for(let a=0;a{e=et(et({},e),Zn(l)),t(0,s=zt(e,i)),"$$scope"in l&&t(1,o=l.$$scope)},[s,o,r]}class c5 extends _e{constructor(e){super(),me(this,e,u5,a5,ae,{})}}function f5(n){let e,t,i;const s=n[2].default,r=De(s,n,n[1],null);let o=[{xmlns:"http://www.w3.org/2000/svg"},{width:"16"},{height:"16"},{fill:"currentColor"},{viewBox:"0 0 16 16"},n[0]],l={};for(let a=0;a{e=et(et({},e),Zn(l)),t(0,s=zt(e,i)),"$$scope"in l&&t(1,o=l.$$scope)},[s,o,r]}class d5 extends _e{constructor(e){super(),me(this,e,h5,f5,ae,{})}}function p5(n){let e,t,i;const s=n[2].default,r=De(s,n,n[1],null);let o=[{xmlns:"http://www.w3.org/2000/svg"},{width:"16"},{height:"16"},{fill:"currentColor"},{viewBox:"0 0 16 16"},n[0]],l={};for(let a=0;a{e=et(et({},e),Zn(l)),t(0,s=zt(e,i)),"$$scope"in l&&t(1,o=l.$$scope)},[s,o,r]}class m5 extends _e{constructor(e){super(),me(this,e,g5,p5,ae,{})}}function _5(n){let e,t,i;const s=n[2].default,r=De(s,n,n[1],null);let o=[{xmlns:"http://www.w3.org/2000/svg"},{width:"16"},{height:"16"},{fill:"currentColor"},{viewBox:"0 0 16 16"},n[0]],l={};for(let a=0;a{e=et(et({},e),Zn(l)),t(0,s=zt(e,i)),"$$scope"in l&&t(1,o=l.$$scope)},[s,o,r]}class y5 extends _e{constructor(e){super(),me(this,e,b5,_5,ae,{})}}function v5(n){let e,t,i;const s=n[2].default,r=De(s,n,n[1],null);let o=[{xmlns:"http://www.w3.org/2000/svg"},{width:"16"},{height:"16"},{fill:"currentColor"},{viewBox:"0 0 16 16"},n[0]],l={};for(let a=0;a{e=et(et({},e),Zn(l)),t(0,s=zt(e,i)),"$$scope"in l&&t(1,o=l.$$scope)},[s,o,r]}class k5 extends _e{constructor(e){super(),me(this,e,w5,v5,ae,{})}}function S5(n){let e,t,i;const s=n[2].default,r=De(s,n,n[1],null);let o=[{xmlns:"http://www.w3.org/2000/svg"},{width:"16"},{height:"16"},{fill:"currentColor"},{viewBox:"0 0 16 16"},n[0]],l={};for(let a=0;a{e=et(et({},e),Zn(l)),t(0,s=zt(e,i)),"$$scope"in l&&t(1,o=l.$$scope)},[s,o,r]}class vW extends _e{constructor(e){super(),me(this,e,T5,S5,ae,{})}}function C5(n){let e,t,i,s;const r=n[2].default,o=De(r,n,n[1],null);let l=[{xmlns:"http://www.w3.org/2000/svg"},{width:"16"},{height:"16"},{fill:"currentColor"},{viewBox:"0 0 16 16"},n[0]],a={};for(let u=0;u{e=et(et({},e),Zn(l)),t(0,s=zt(e,i)),"$$scope"in l&&t(1,o=l.$$scope)},[s,o,r]}let wW=class extends _e{constructor(e){super(),me(this,e,I5,C5,ae,{})}};function E5(n){let e,t,i,s;const r=n[2].default,o=De(r,n,n[1],null);let l=[{xmlns:"http://www.w3.org/2000/svg"},{width:"16"},{height:"16"},{fill:"currentColor"},{viewBox:"0 0 16 16"},n[0]],a={};for(let u=0;u{e=et(et({},e),Zn(l)),t(0,s=zt(e,i)),"$$scope"in l&&t(1,o=l.$$scope)},[s,o,r]}class SW extends _e{constructor(e){super(),me(this,e,A5,E5,ae,{})}}function O5(n){let e,t,i,s;const r=n[2].default,o=De(r,n,n[1],null);let l=[{xmlns:"http://www.w3.org/2000/svg"},{width:"16"},{height:"16"},{fill:"currentColor"},{viewBox:"0 0 16 16"},n[0]],a={};for(let u=0;u{e=et(et({},e),Zn(l)),t(0,s=zt(e,i)),"$$scope"in l&&t(1,o=l.$$scope)},[s,o,r]}class D5 extends _e{constructor(e){super(),me(this,e,N5,O5,ae,{})}}function Bf(n){const e=n.slice(),t=!e[18];return e[65]=t,e}function x5(n){let e,t,i,s=`${n[6]}px`,r=`${n[7]}px`,o,l,a,u,c=n[4]&&m0(Bf(n));return{c(){e=z("div"),t=z("div"),i=z("div"),c&&c.c(),o=se(),l=z("canvas"),v(i,"class","me-original-image-container svelte-1v4o7xm"),ve(i,"width",s),ve(i,"height",r),v(l,"class","me-canvas svelte-1v4o7xm"),ve(l,"cursor",n[13]),v(t,"class","me-canvas-container"),v(e,"class","me-transform svelte-1v4o7xm"),ve(e,"transform",n[19]),ve(e,"--scale",n[8])},m(f,h){A(f,e,h),F(e,t),F(t,i),c&&c.m(i,null),F(t,o),F(t,l),n[39](l),a||(u=[ee(l,"mouseover",n[26]),ee(l,"focus",n[27]),ee(l,"wheel",n[31]),ee(l,"mouseleave",n[28]),ee(l,"mousedown",Yi(n[29])),ee(l,"mouseup",Yi(F5)),ee(l,"mousemove",n[30])],a=!0)},p(f,h){f[4]?c?c.p(Bf(f),h):(c=m0(Bf(f)),c.c(),c.m(i,null)):c&&(c.d(1),c=null),h[0]&64&&s!==(s=`${f[6]}px`)&&ve(i,"width",s),h[0]&128&&r!==(r=`${f[7]}px`)&&ve(i,"height",r),h[0]&8192&&ve(l,"cursor",f[13]),h[0]&524288&&ve(e,"transform",f[19]),h[0]&256&&ve(e,"--scale",f[8])},d(f){f&&E(e),c&&c.d(),n[39](null),a=!1,lt(u)}}}function L5(n){let e;return{c(){e=z("div"),e.textContent="(empty)"},m(t,i){A(t,e,i)},p:Z,d(t){t&&E(e)}}}function m0(n){let e,t;return{c(){e=z("img"),v(e,"class","me-original-image svelte-1v4o7xm"),Ti(e.src,t=n[4].src)||v(e,"src",t),ve(e,"width",n[6]),ve(e,"height",n[7]),ve(e,"display",n[65]?"block":"none")},m(i,s){A(i,e,s)},p(i,s){s[0]&16&&!Ti(e.src,t=i[4].src)&&v(e,"src",t),s[0]&64&&ve(e,"width",i[6]),s[0]&128&&ve(e,"height",i[7]),s[0]&262144&&ve(e,"display",i[65]?"block":"none")},d(i){i&&E(e)}}}function _0(n){let e,t=`${n[16]*n[8]}px`,i=`${n[16]*n[8]}px`,s=`${n[20]+n[11]}px`,r=`${n[21]+n[12]}px`;return{c(){e=z("div"),v(e,"class","me-brush-cursor svelte-1v4o7xm"),ve(e,"width",t),ve(e,"height",i),ve(e,"left",s),ve(e,"top",r),ve(e,"transform","translate(-50%, -50%)")},m(o,l){A(o,e,l)},p(o,l){l[0]&65792&&t!==(t=`${o[16]*o[8]}px`)&&ve(e,"width",t),l[0]&65792&&i!==(i=`${o[16]*o[8]}px`)&&ve(e,"height",i),l[0]&1050624&&s!==(s=`${o[20]+o[11]}px`)&&ve(e,"left",s),l[0]&2101248&&r!==(r=`${o[21]+o[12]}px`)&&ve(e,"top",r)},d(o){o&&E(e)}}}function M5(n){let e,t;return e=new c5({}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function R5(n){let e,t;return e=new y5({}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function P5(n){let e,t,i,s,r,o,l,a,u,c,f,h,d,p,g,m,_,b,y,k,T,I,x,R,N,O,D,M,L,V,X,q,K,Q,J;function ce(ge,he){return ge[5]?x5:L5}let pe=ce(n),qe=pe(n),Ae=n[5]&&n[10]&&!n[9]&&_0(n);o=new l5({}),c=new s5({}),p=new D5({}),b=new d5({}),x=new k5({}),M=new m5({});const ue=[R5,M5],te=[];function be(ge,he){return ge[0]?0:1}return X=be(n),q=te[X]=ue[X](n),{c(){e=z("div"),qe.c(),t=se(),Ae&&Ae.c(),i=se(),s=z("div"),r=z("button"),Y(o.$$.fragment),a=se(),u=z("button"),Y(c.$$.fragment),h=se(),d=z("button"),Y(p.$$.fragment),m=se(),_=z("label"),Y(b.$$.fragment),y=se(),k=z("input"),T=se(),I=z("label"),Y(x.$$.fragment),R=se(),N=z("input"),O=se(),D=z("div"),Y(M.$$.fragment),L=se(),V=z("div"),q.c(),r.disabled=l=n[3].length===0,v(r,"class","svelte-1v4o7xm"),u.disabled=f=n[15].length===0,v(u,"class","svelte-1v4o7xm"),d.disabled=g=n[3].length===0&&n[15].length===0,v(d,"class","svelte-1v4o7xm"),v(k,"type","range"),v(k,"min","1"),v(k,"max","200"),v(k,"step","0.1"),v(k,"class","svelte-1v4o7xm"),v(_,"class","svelte-1v4o7xm"),v(N,"type","range"),v(N,"min","1"),v(N,"max","100"),v(N,"step","0.1"),v(N,"class","svelte-1v4o7xm"),v(I,"class","svelte-1v4o7xm"),v(D,"class","toggle-button svelte-1v4o7xm"),B(D,"toggled",n[18]),v(V,"class","toggle-button svelte-1v4o7xm"),B(V,"toggled",n[0]),v(s,"class","me-toolkit-bar svelte-1v4o7xm"),v(e,"class","me-container svelte-1v4o7xm"),B(e,"fullscreen",n[0])},m(ge,he){A(ge,e,he),qe.m(e,null),F(e,t),Ae&&Ae.m(e,null),F(e,i),F(e,s),F(s,r),G(o,r,null),F(s,a),F(s,u),G(c,u,null),F(s,h),F(s,d),G(p,d,null),F(s,m),F(s,_),G(b,_,null),F(_,y),F(_,k),Bt(k,n[16]),F(s,T),F(s,I),G(x,I,null),F(I,R),F(I,N),Bt(N,n[17]),F(s,O),F(s,D),G(M,D,null),F(s,L),F(s,V),te[X].m(V,null),n[44](e),K=!0,Q||(J=[ee(window,"mouseup",n[33]),ee(r,"click",n[23]),ee(u,"click",n[24]),ee(d,"click",n[1]),ee(k,"change",n[40]),ee(k,"input",n[40]),ee(k,"change",n[22]),ee(k,"pointerup",n[34]),ee(N,"change",n[41]),ee(N,"input",n[41]),ee(N,"change",n[22]),ee(N,"pointerup",n[34]),ee(D,"click",n[42]),ee(V,"click",n[43]),ee(e,"mousemove",n[32])],Q=!0)},p(ge,he){pe===(pe=ce(ge))&&qe?qe.p(ge,he):(qe.d(1),qe=pe(ge),qe&&(qe.c(),qe.m(e,t))),ge[5]&&ge[10]&&!ge[9]?Ae?Ae.p(ge,he):(Ae=_0(ge),Ae.c(),Ae.m(e,i)):Ae&&(Ae.d(1),Ae=null),(!K||he[0]&8&&l!==(l=ge[3].length===0))&&(r.disabled=l),(!K||he[0]&32768&&f!==(f=ge[15].length===0))&&(u.disabled=f),(!K||he[0]&32776&&g!==(g=ge[3].length===0&&ge[15].length===0))&&(d.disabled=g),he[0]&65536&&Bt(k,ge[16]),he[0]&131072&&Bt(N,ge[17]),(!K||he[0]&262144)&&B(D,"toggled",ge[18]);let Se=X;X=be(ge),X!==Se&&(oe(),C(te[Se],1,1,()=>{te[Se]=null}),le(),q=te[X],q||(q=te[X]=ue[X](ge),q.c()),S(q,1),q.m(V,null)),(!K||he[0]&1)&&B(V,"toggled",ge[0]),(!K||he[0]&1)&&B(e,"fullscreen",ge[0])},i(ge){K||(S(o.$$.fragment,ge),S(c.$$.fragment,ge),S(p.$$.fragment,ge),S(b.$$.fragment,ge),S(x.$$.fragment,ge),S(M.$$.fragment,ge),S(q),K=!0)},o(ge){C(o.$$.fragment,ge),C(c.$$.fragment,ge),C(p.$$.fragment,ge),C(b.$$.fragment,ge),C(x.$$.fragment,ge),C(M.$$.fragment,ge),C(q),K=!1},d(ge){ge&&E(e),qe.d(),Ae&&Ae.d(),j(o),j(c),j(p),j(b),j(x),j(M),te[X].d(),n[44](null),Q=!1,lt(J)}}}const B5="#000";function b0(n,e,t){n.strokeStyle=t,n.lineCap="round",n.lineJoin="round",e.forEach(i=>{!(i!=null&&i.points.length)||!i.size||(n.lineWidth=i.size,n.beginPath(),n.moveTo(i.points[0].x,i.points[0].y),i.points.forEach(s=>n.lineTo(s.x,s.y)),n.stroke())})}function z5(n,e){return n&&e?[e.naturalWidth,e.naturalHeight]:[512,512]}function y0(n){return{x:n.offsetX,y:n.offsetY}}function F5(){}function W5(n,e,t){let{fileURL:i=null}=e,{fullscreen:s=!1}=e;const r=mi();let o,l,a,u,c,f,h=[],d=[],p,g=!1,m=512,_=512,b=1,y=1,k=100,T=0,I=!1,x=!1,R=!1,N=!1,O=!1,D="",M=0,L=0,V=0,X=0,q=0,K=0;var Q;(function(Ce){Ce[Ce.Left=0]="Left",Ce[Ce.Middle=1]="Middle",Ce[Ce.Right=2]="Right",Ce[Ce.Back=3]="Back",Ce[Ce.Forward=4]="Forward"})(Q||(Q={}));function J(){x=!1,t(37,u=null),f=null,t(5,g=!1),t(4,p=null),t(6,m=512),t(7,_=512),t(8,b=1),y=.5}let ce=null,pe=!1;function qe(){pe&&(pe=!1,he(),x=h.length>0,r("loaded",{hasMask:x,maskCanvas:u,curLineGroup:h,redoCurLines:d}))}function Ae(){if(!l)return;const Ce=l.getBoundingClientRect();t(11,M=Ce.width/2-m/2*b),t(12,L=Ce.height/2-_/2*b)}function ue(Ce,tt){const vt=Se(Ce,tt);return y=vt/2,vt}function te(Ce){be(Ce),r("change",{hasMask:x,maskCanvas:u,curLineGroup:h,redoCurLines:d})}function be(Ce){if(!c||!f)return;c.clearRect(0,0,c.canvas.width,c.canvas.height),f.clearRect(0,0,f.canvas.width,f.canvas.height);const tt=B5,vt=Kt=>{Kt.save(),Kt.filter=`blur(${T}px)`,b0(Kt,Ce,tt),Kt.restore()};vt(f),I?(c.save(),c.filter=`blur(${T}px)`,b0(c,Ce,tt),c.restore(),c.globalCompositeOperation="source-in",c.drawImage(p,0,0,m,_),c.globalCompositeOperation="source-over"):vt(c)}function ge(){te(h)}function he(){te(h||[])}function Se(Ce,tt){const vt=l==null?void 0:l.getBoundingClientRect();if(!vt)return 1;const Kt=vt.width/Ce,Vi=vt.height/tt;let cn=1;return(Kt<1||Vi<1)&&(cn=Math.min(Kt,Vi)),cn}function Je(){if(h.length===0)return;const Ce=h.pop(),tt=[...d,Ce];t(15,d=tt);const vt=[...h];t(3,h=vt),te(vt)}function gt(){if(d.length===0)return;const Ce=d.pop();t(15,d=[...d]);const tt=[...h,Ce];t(3,h=tt),te(tt)}function Ii(){t(15,d=[]);const Ce=[];t(3,h=Ce),te(Ce)}function fe(){t(8,b=ue(m,_)),Ae()}async function Te(){t(0,s=!s),ge(),await yr(),fe()}function Ge(){t(10,O=!0)}function It(){t(10,O=!0)}function Pt(){t(10,O=!1)}function ni(Ce){if(!(p!=null&&p.src)||N||a==null)return;switch(Ce.button){case Q.Right:return;case Q.Middle:t(9,N=!0),q=Ce.offsetX*b,K=Ce.offsetY*b;return}R=!0,t(15,d=[]);let tt=[...h];tt.push({size:k,points:[y0(Ce)]}),t(3,h=tt),te(h)}function Xt(Ce){N||R&&h.length!==0&&(h[h.length-1].points.push(y0(Ce)),t(3,h),te(h))}function Fi(Ce){if(Ce.preventDefault(),!l||Ce.target!=a)return;const tt=l.getBoundingClientRect(),vt=Ce.clientX-tt.x,Kt=Ce.clientY-tt.y;Ce.preventDefault();var Vi=Ce.deltaY*-.001;Vi=Math.max(-1,Math.min(1,Vi));const cn=(vt-M)/b,Hi=(Kt-L)/b;t(8,b+=Vi*b),t(8,b=Math.max(y,b)),t(11,M=-cn*b+vt),t(12,L=-Hi*b+Kt),t(20,V=Ce.offsetX*b),t(21,X=Ce.offsetY*b)}function Ei(Ce){Ce.target==a&&(t(20,V=Ce.offsetX*b),t(21,X=Ce.offsetY*b),N&&(t(11,M+=V-q),t(12,L+=X-K)))}function hi(Ce){Ce.button===Q.Middle&&(t(9,N=!1),q=0,K=0),!N&&p!=null&&p.src&&a&&R&&(R=!1,r("release",{hasMask:x,maskCanvas:u,curLineGroup:h,redoCurLines:d}))}function st(){ge(),r("release",{hasMask:x,maskCanvas:u,curLineGroup:h,redoCurLines:d})}function ei(Ce){Ze[Ce?"unshift":"push"](()=>{a=Ce,t(2,a),t(4,p),t(6,m),t(7,_),t(37,u),t(35,i),t(38,ce),t(5,g)})}function Wi(){k=br(this.value),t(16,k)}function ct(){T=br(this.value),t(17,T)}const si=()=>{t(18,I=!I),ge()},Tn=()=>{Te()};function tn(Ce){Ze[Ce?"unshift":"push"](()=>{l=Ce,t(14,l)})}return n.$$set=Ce=>{"fileURL"in Ce&&t(35,i=Ce.fileURL),"fullscreen"in Ce&&t(0,s=Ce.fullscreen)},n.$$.update=()=>{n.$$.dirty[1]&144&&i!==ce&&(J(),i?Lp(i).then(Ce=>{t(4,p=Ce),t(5,g=!0),pe=!0}).catch(Ce=>{t(5,g=!1)}):(t(5,g=!1),t(4,p=null)),t(38,ce=i)),n.$$.dirty[0]&240&&(t(6,[m,_]=z5(g,p),m,(t(7,_),t(5,g),t(4,p),t(6,m),t(35,i),t(38,ce))),t(8,b=ue(m,_)),Ae(),yr().then(()=>{qe()})),n.$$.dirty[0]&6400&&t(19,D=`translate(${M}px, ${L}px) scale(${b})`),n.$$.dirty[0]&1568&&(N?t(13,o="grab"):g&&O?t(13,o="none"):t(13,o=void 0)),n.$$.dirty[0]&212|n.$$.dirty[1]&64&&a&&p&&(t(37,u=document.createElement("canvas")),f=u.getContext("2d"),t(37,u.width=m,u),t(37,u.height=_,u),t(2,a.width=m,a),t(2,a.height=_,a),he()),n.$$.dirty[0]&4&&(c=a?a.getContext("2d"):null),n.$$.dirty[0]&8&&(x=h.length>0)},[s,Ii,a,h,p,g,m,_,b,N,O,M,L,o,l,d,k,T,I,D,V,X,ge,Je,gt,Te,Ge,It,Pt,ni,Xt,Fi,Ei,hi,st,i,fe,u,ce,ei,Wi,ct,si,Tn,tn]}class V5 extends _e{constructor(e){super(),me(this,e,W5,P5,ae,{fileURL:35,fullscreen:0,clearStrokes:1,recenterImage:36},null,[-1,-1,-1])}get clearStrokes(){return this.$$.ctx[1]}get recenterImage(){return this.$$.ctx[36]}}function zf(n){const e=n.slice(),t=e[4][0]?e[4][0].children.filter(i=>{var s;return(s=i.tags)==null?void 0:s.includes("mask")}).length:0;return e[36]=t,e}function Ff(n){const e=n.slice(),t=Gs(e[12][0]);return e[37]=t,e}function H5(n){let e,t,i,s,r,o,l,a,u,c=n[12]&&n[12].length>0&&n[2]&&v0(Ff(n));function f(p){n[28](p)}function h(p){n[29](p)}let d={value:n[12],mask:n[10],fileCount:"single",elem_classes:[],style:"",label:n[0].attrs.title};return n[13]!==void 0&&(d.imgWidth=n[13]),n[14]!==void 0&&(d.imgHeight=n[14]),s=new Aw({props:d}),Ze.push(()=>jt(s,"imgWidth",f)),Ze.push(()=>jt(s,"imgHeight",h)),s.$on("uploading",n[19]),s.$on("uploaded",n[20]),s.$on("upload_error",n[22]),s.$on("clear",n[21]),s.$on("change",Ow),s.$on("image_clicked",n[18]),a=new yt({props:{$$slots:{default:[K5]},$$scope:{ctx:n}}}),{c(){e=z("div"),c&&c.c(),t=se(),i=z("div"),Y(s.$$.fragment),l=se(),Y(a.$$.fragment),ve(i,"display",n[2]&&n[9]?"none":"block"),v(e,"class","comfy-image-editor-panel")},m(p,g){A(p,e,g),c&&c.m(e,null),F(e,t),F(e,i),G(s,i,null),F(e,l),G(a,e,null),u=!0},p(p,g){p[12]&&p[12].length>0&&p[2]?c?(c.p(Ff(p),g),g[0]&4100&&S(c,1)):(c=v0(Ff(p)),c.c(),S(c,1),c.m(e,t)):c&&(oe(),C(c,1,1,()=>{c=null}),le());const m={};g[0]&4096&&(m.value=p[12]),g[0]&1024&&(m.mask=p[10]),g[0]&1&&(m.label=p[0].attrs.title),!r&&g[0]&8192&&(r=!0,m.imgWidth=p[13],Gt(()=>r=!1)),!o&&g[0]&16384&&(o=!0,m.imgHeight=p[14],Gt(()=>o=!1)),s.$set(m),g[0]&516&&ve(i,"display",p[2]&&p[9]?"none":"block");const _={};g[0]&6684|g[1]&128&&(_.$$scope={dirty:g,ctx:p}),a.$set(_)},i(p){u||(S(c),S(s.$$.fragment,p),S(a.$$.fragment,p),u=!0)},o(p){C(c),C(s.$$.fragment,p),C(a.$$.fragment,p),u=!1},d(p){p&&E(e),c&&c.d(),j(s),j(a)}}}function U5(n){let e,t,i,s;function r(a){n[25](a)}function o(a){n[26](a)}let l={value:n[12],fileCount:"single",elem_classes:[],style:"",label:n[0].attrs.title};return n[13]!==void 0&&(l.imgWidth=n[13]),n[14]!==void 0&&(l.imgHeight=n[14]),e=new Aw({props:l}),Ze.push(()=>jt(e,"imgWidth",r)),Ze.push(()=>jt(e,"imgHeight",o)),e.$on("uploading",n[19]),e.$on("uploaded",n[20]),e.$on("upload_error",n[22]),e.$on("clear",n[21]),e.$on("change",Ow),e.$on("image_clicked",n[18]),{c(){Y(e.$$.fragment)},m(a,u){G(e,a,u),s=!0},p(a,u){const c={};u[0]&4096&&(c.value=a[12]),u[0]&1&&(c.label=a[0].attrs.title),!t&&u[0]&8192&&(t=!0,c.imgWidth=a[13],Gt(()=>t=!1)),!i&&u[0]&16384&&(i=!0,c.imgHeight=a[14],Gt(()=>i=!1)),e.$set(c)},i(a){s||(S(e.$$.fragment,a),s=!0)},o(a){C(e.$$.fragment,a),s=!1},d(a){j(e,a)}}}function v0(n){let e,t,i,s={fileURL:n[37]};return t=new V5({props:s}),n[27](t),t.$on("release",n[15]),t.$on("loaded",n[15]),{c(){e=z("div"),Y(t.$$.fragment),v(e,"class","mask-canvas-wrapper svelte-xilbl7"),ve(e,"display",n[9]?"block":"none")},m(r,o){A(r,e,o),G(t,e,null),i=!0},p(r,o){const l={};o[0]&4096&&(l.fileURL=r[37]),t.$set(l),o[0]&512&&ve(e,"display",r[9]?"block":"none")},i(r){i||(S(t.$$.fragment,r),i=!0)},o(r){C(t.$$.fragment,r),i=!1},d(r){r&&E(e),n[27](null),j(t)}}}function w0(n){let e,t;return e=new Xr({props:{$$slots:{default:[X5]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s[0]&6676|s[1]&128&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function k0(n){let e,t,i,s,r=n[9]&&S0(n);return i=new Zc({props:{disabled:!n[12],$$slots:{default:[Y5]},$$scope:{ctx:n}}}),i.$on("click",n[17]),{c(){e=z("div"),r&&r.c(),t=se(),Y(i.$$.fragment)},m(o,l){A(o,e,l),r&&r.m(e,null),F(e,t),G(i,e,null),s=!0},p(o,l){o[9]?r?(r.p(o,l),l[0]&512&&S(r,1)):(r=S0(o),r.c(),S(r,1),r.m(e,t)):r&&(oe(),C(r,1,1,()=>{r=null}),le());const a={};l[0]&4096&&(a.disabled=!o[12]),l[0]&512|l[1]&128&&(a.$$scope={dirty:l,ctx:o}),i.$set(a)},i(o){s||(S(r),S(i.$$.fragment,o),s=!0)},o(o){C(r),C(i.$$.fragment,o),s=!1},d(o){o&&E(e),r&&r.d(),j(i)}}}function S0(n){let e,t;return e=new Zc({props:{variant:"secondary",$$slots:{default:[G5]},$$scope:{ctx:n}}}),e.$on("click",n[30]),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s[1]&128&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function G5(n){let e;return{c(){e=ke("Clear Mask")},m(t,i){A(t,e,i)},d(t){t&&E(e)}}}function j5(n){let e;return{c(){e=ke("Edit Mask")},m(t,i){A(t,e,i)},d(t){t&&E(e)}}}function q5(n){let e;return{c(){e=ke("Show Image")},m(t,i){A(t,e,i)},d(t){t&&E(e)}}}function Y5(n){let e;function t(r,o){return r[9]?q5:j5}let i=t(n),s=i(n);return{c(){s.c(),e=we()},m(r,o){s.m(r,o),A(r,e,o)},p(r,o){i!==(i=t(r))&&(s.d(1),s=i(r),s&&(s.c(),s.m(e.parentNode,e)))},d(r){r&&E(e),s.d(r)}}}function T0(n){let e,t,i;return{c(){e=z("div"),t=ke("Upload error: "),i=ke(n[11])},m(s,r){A(s,e,r),F(e,t),F(e,i)},p(s,r){r[0]&2048&&je(i,s[11])},d(s){s&&E(e)}}}function X5(n){let e,t,i,s,r,o,l=n[2]&&k0(n);i=new dr({props:{label:"",show_label:!1,disabled:!0,lines:1,max_lines:1,value:"Images: "+n[4].length+", masks: "+n[36]}});let a=n[11]&&T0(n);return{c(){l&&l.c(),e=se(),t=z("div"),Y(i.$$.fragment),s=se(),a&&a.c(),r=we()},m(u,c){l&&l.m(u,c),A(u,e,c),A(u,t,c),G(i,t,null),A(u,s,c),a&&a.m(u,c),A(u,r,c),o=!0},p(u,c){u[2]?l?(l.p(u,c),c[0]&4&&S(l,1)):(l=k0(u),l.c(),S(l,1),l.m(e.parentNode,e)):l&&(oe(),C(l,1,1,()=>{l=null}),le());const f={};c[0]&16&&(f.value="Images: "+u[4].length+", masks: "+u[36]),i.$set(f),u[11]?a?a.p(u,c):(a=T0(u),a.c(),a.m(r.parentNode,r)):a&&(a.d(1),a=null)},i(u){o||(S(l),S(i.$$.fragment,u),o=!0)},o(u){C(l),C(i.$$.fragment,u),o=!1},d(u){u&&(E(e),E(t),E(s),E(r)),l&&l.d(u),j(i),a&&a.d(u)}}}function K5(n){let e,t,i=n[3]&&w0(zf(n));return{c(){i&&i.c(),e=we()},m(s,r){i&&i.m(s,r),A(s,e,r),t=!0},p(s,r){s[3]?i?(i.p(zf(s),r),r[0]&8&&S(i,1)):(i=w0(zf(s)),i.c(),S(i,1),i.m(e.parentNode,e)):i&&(oe(),C(i,1,1,()=>{i=null}),le())},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d(s)}}}function $5(n){let e,t,i,s;const r=[U5,H5],o=[];function l(a,u){return a[0].attrs.variant==="fileUpload"||a[1]?0:1}return t=l(n),i=o[t]=r[t](n),{c(){e=z("div"),i.c(),v(e,"class","wrapper comfy-image-editor svelte-xilbl7")},m(a,u){A(a,e,u),o[t].m(e,null),s=!0},p(a,u){let c=t;t=l(a),t===c?o[t].p(a,u):(oe(),C(o[c],1,1,()=>{o[c]=null}),le(),i=o[t],i?i.p(a,u):(i=o[t]=r[t](a),i.c()),S(i,1),i.m(e,null))},i(a){s||(S(i),s=!0)},o(a){C(i),s=!1},d(a){a&&E(e),o[t].d()}}}const J5="ComfyBoxMask.png";function Ow(n){}function Z5(n,e,t){let i,s=Z,r=()=>(s(),s=ot(g,be=>t(4,i=be)),g),o,l=Z,a=()=>(l(),l=ot(m,be=>t(13,o=be)),m),u,c=Z,f=()=>(c(),c=ot(_,be=>t(14,u=be)),_);n.$$.on_destroy.push(()=>s()),n.$$.on_destroy.push(()=>l()),n.$$.on_destroy.push(()=>c());let{widget:h=null}=e,{isMobile:d=!1}=e,p=null,g=null;r();let m=Be(0);a();let _=Be(0);f();let b=null,y=!1,k=!1;function T(be){be&&(t(23,p=be.node),r(t(5,g=p.value)),a(t(6,m=p.imgWidth)),f(t(7,_=p.imgHeight)),t(24,L=i&&i.length>0?"uploaded":"empty"))}let I=!1,x;async function R(be){const ge=be.detail;ge.maskCanvas!=null&&ge.hasMask&&await N(ge.maskCanvas)}async function N(be){if(!k){nt("Mask editing is disabled for this widget.",{type:"warning"});return}if(!be){nt("No mask canvas!",{type:"warning"});return}if(!i||i.length===0){nt("No image uploaded to apply mask to.",{type:"warning"});return}const ge=i[0].children.findIndex(Je=>{var gt;return(gt=Je.tags)==null?void 0:gt.includes("mask")})===-1,he=i[0].comfyUIFile.filename,Se=he?`${xv(he)}_mask.png`:J5;await DE(be).then(Je=>Pv([{blob:Je,filename:Se,overwrite:!0}])).then(Je=>{const gt=Je.files.map(Ii=>{const fe=Yl(Ii);return fe.tags=["mask"],fe.width=be.width,fe.height=be.height,fe});if(i.length>0)pi(g,i[0].children=gt,i),ge&&nt("Uploaded mask successfully!",{type:"success"});else throw new Error("No image was uploaded yet.")}).catch(Je=>{nt(`Failed to upload mask to ComfyUI: ${Je}`,{type:"error",timeout:1e4})})}function O(){for(const be of i)be.children=[];t(10,x=null),b&&b.clearStrokes()}async function D(){t(9,y=!y),await yr(),b&&b.recenterImage()}function M(){if(!i||i.length===0)return;const be=i[0],he=[ol(be)];zs.instance.showModal(he,0)}let L="empty",V=null;function X(){t(11,V=null),t(24,L="uploading")}function q(be){t(11,V=null),t(24,L="uploaded"),pi(g,i=be.detail.map(Yl),i)}function K(){t(11,V=null),t(24,L="empty"),pi(g,i=[],i)}function Q(be){t(24,L="error"),t(11,V=be.detail),pi(g,i=[],i),nt(`Failed to upload image to ComfyUI: ${V}`,{type:"error",timeout:1e4})}let J=[];function ce(be){o=be,m.set(o)}function pe(be){u=be,_.set(u)}function qe(be){Ze[be?"unshift":"push"](()=>{b=be,t(8,b)})}function Ae(be){o=be,m.set(o)}function ue(be){u=be,_.set(u)}const te=()=>{O(),nt("Mask cleared.")};return n.$$set=be=>{"widget"in be&&t(0,h=be.widget),"isMobile"in be&&t(1,d=be.isMobile)},n.$$.update=()=>{var be,ge,he;n.$$.dirty[0]&1&&h&&T(h),n.$$.dirty[0]&8388608&&t(2,k=(((be=p==null?void 0:p.properties)==null?void 0:be.maskCount)||0)>0),n.$$.dirty[0]&4&&(k||O()),n.$$.dirty[0]&16&&t(3,I=i&&i.length>0),n.$$.dirty[0]&8&&(I||t(9,y=!1)),n.$$.dirty[0]&28&&(I&&k?t(10,x=(he=(ge=i[0].children)==null?void 0:ge.find(Se=>Se.tags.includes("mask")))==null?void 0:he.comfyUIFile):t(10,x=null)),n.$$.dirty[0]&16&&(i?t(12,J=i.map(AE)):t(12,J=[])),n.$$.dirty[0]&16777216},[h,d,k,I,i,g,m,_,b,y,x,V,J,o,u,R,O,D,M,X,q,K,Q,p,L,ce,pe,qe,Ae,ue,te]}class Q5 extends _e{constructor(e){super(),me(this,e,Z5,$5,ae,{widget:0,isMobile:1},null,[-1,-1])}}class Nw extends As{constructor(t){super(t,[]);P(this,"properties",{defaultValue:[],tags:[],maskCount:0});P(this,"svelteComponentType",Q5);P(this,"defaultValue",[]);P(this,"outputSlotName","images");P(this,"storeActionName","store");P(this,"saveUserState",!1);P(this,"imgWidth",Be(0));P(this,"imgHeight",Be(0))}onExecute(t,i){const s=ie(this.value);if(s&&s.length>0){s[0].width=ie(this.imgWidth),s[0].height=ie(this.imgHeight);for(const r of s[0].children)r.width=ie(this.imgWidth),r.height=ie(this.imgHeight)}super.onExecute(t,i)}parseValue(t){return Sp(t)||[]}formatValue(t){return`Images: ${(t==null?void 0:t.length)||0}`}stripUserState(t){super.stripUserState(t),t.properties.defaultValue=[],t.comfyValue=[]}}P(Nw,"slotLayout",{inputs:[{name:"store",type:$.ACTION}],outputs:[{name:"images",type:"COMFYBOX_IMAGES"},{name:"changed",type:$.EVENT}]});w.registerNodeType({class:Nw,title:"UI.ImageUpload",desc:"Widget that lets you upload and edit a multi-layered image. Can also act like a standalone image uploader.",type:"ui/image_upload"});function C0(n){let e,t;return e=new yt({props:{type:"fieldset",$$slots:{default:[ex]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&2115&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function ex(n){let e,t;return e=new EA({props:{elem_id:"radio",choices:n[1].properties.choices,disabled:Kn(n[0]),label:n[0].attrs.title,show_label:n[0].attrs.title&&n[0].attrs.title!=="",value:n[6]}}),e.$on("select",n[7]),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&2&&(r.choices=i[1].properties.choices),s&1&&(r.disabled=Kn(i[0])),s&1&&(r.label=i[0].attrs.title),s&1&&(r.show_label=i[0].attrs.title&&i[0].attrs.title!==""),s&64&&(r.value=i[6]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function I0(n){let e,t,i=n[1]!==null&&n[1].properties.choices&&C0(n);return{c(){i&&i.c(),e=we()},m(s,r){i&&i.m(s,r),A(s,e,r),t=!0},p(s,r){s[1]!==null&&s[1].properties.choices?i?(i.p(s,r),r&2&&S(i,1)):(i=C0(s),i.c(),S(i,1),i.m(e.parentNode,e)):i&&(oe(),C(i,1,1,()=>{i=null}),le())},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d(s)}}}function E0(n){let e=n[5],t,i,s=I0(n);return{c(){s.c(),t=we()},m(r,o){s.m(r,o),A(r,t,o),i=!0},p(r,o){o&32&&ae(e,e=r[5])?(oe(),C(s,1,1,Z),le(),s=I0(r),s.c(),S(s,1),s.m(t.parentNode,t)):s.p(r,o)},i(r){i||(S(s),i=!0)},o(r){C(s),i=!1},d(r){r&&E(t),s.d(r)}}}function tx(n){let e,t,i=n[2],s,r=E0(n);return{c(){e=z("div"),t=z("div"),r.c(),v(t,"class","inner"),v(e,"class","wrapper gradio-radio")},m(o,l){A(o,e,l),F(e,t),r.m(t,null),s=!0},p(o,[l]){l&4&&ae(i,i=o[2])?(oe(),C(r,1,1,Z),le(),r=E0(o),r.c(),S(r,1),r.m(t,null)):r.p(o,l)},i(o){s||(S(r),s=!0)},o(o){C(r),s=!1},d(o){o&&E(e),r.d(o)}}}let ix=null;function nx(n,e,t){let i,s,r=Z,o=()=>(r(),r=ot(p,b=>t(5,s=b)),p),l,a=Z,u=()=>(a(),a=ot(d,b=>t(6,l=b)),d);Si(n,ix,b=>t(2,i=b)),n.$$.on_destroy.push(()=>r()),n.$$.on_destroy.push(()=>a());let{widget:c=null}=e,{isMobile:f=!1}=e,h=null,d=null;u();let p=null;o();function g(b){b&&(t(1,h=b.node),u(t(3,d=h.value)),o(t(4,p=b.attrsChanged)))}function m(){var b;t(1,h.index=yi(h.index,0,((b=h.properties.choices)==null?void 0:b.length)||0),h)}function _(b){h.setValue(b.detail.value),t(1,h.index=b.detail.index,h),navigator.vibrate(20)}return n.$$set=b=>{"widget"in b&&t(0,c=b.widget),"isMobile"in b&&t(8,f=b.isMobile)},n.$$.update=()=>{n.$$.dirty&1&&c&&g(c),n.$$.dirty&6&&h&&i&&m()},[c,h,i,d,p,s,l,_,f]}class sx extends _e{constructor(e){super(),me(this,e,nx,tx,ae,{widget:0,isMobile:8})}}class Dw extends As{constructor(t){super(t,"Choice A");P(this,"properties",{tags:[],choices:["Choice A","Choice B","Choice C"],defaultValue:"Choice A"});P(this,"svelteComponentType",sx);P(this,"defaultValue","");P(this,"indexWidget");P(this,"index",0);this.indexWidget=this.addWidget("number","Index",this.index),this.indexWidget.disabled=!0}onExecute(t,i){super.onExecute(t,i),this.setOutputData(1,this.index)}setValue(t,i=!1){super.setValue(t,i),t=ie(this.value);const s=this.properties.choices.indexOf(t);s!==-1&&(this.index=s,this.indexWidget.value=s,this.setOutputData(1,this.index))}parseValue(t){if(typeof t=="string")return this.properties.choices.indexOf(t)===-1?this.properties.choices[0]:t;{const i=yi(parseInt(t),0,this.properties.choices.length-1);return this.properties.choices[i]||this.properties.defaultValue}}}P(Dw,"slotLayout",{inputs:[{name:"store",type:$.ACTION}],outputs:[{name:"value",type:"string"},{name:"index",type:"number"},{name:"changed",type:$.EVENT}]});w.registerNodeType({class:Dw,title:"UI.Radio",desc:"Radio that outputs a string and index",type:"ui/radio"});function rx(n){let e;return{c(){e=ke(n[5])},m(t,i){A(t,e,i)},p(t,i){i&32&&je(e,t[5])},d(t){t&&E(e)}}}function ox(n){let e,t,i,s,r,o,l,a,u,c,f;return s=new kn({props:{show_label:n[7],info:n[6],$$slots:{default:[rx]},$$scope:{ctx:n}}}),{c(){e=z("div"),t=z("div"),i=z("label"),Y(s.$$.fragment),r=se(),o=z("input"),l=se(),a=z("input"),v(i,"for",n[9]),v(o,"data-testid","number-input"),v(o,"type","number"),v(o,"min",n[1]),v(o,"max",n[2]),v(o,"step",n[3]),o.disabled=n[4],v(o,"class","svelte-17c17fl"),v(t,"class","head svelte-17c17fl"),v(e,"class","wrap svelte-17c17fl"),v(a,"type","range"),v(a,"id",n[9]),v(a,"name","cowbell"),v(a,"min",n[1]),v(a,"max",n[2]),v(a,"step",n[3]),a.disabled=n[4],v(a,"class","svelte-17c17fl")},m(h,d){A(h,e,d),F(e,t),F(t,i),G(s,i,null),F(t,r),F(t,o),Bt(o,n[8]),A(h,l,d),A(h,a,d),Bt(a,n[0]),u=!0,c||(f=[ee(o,"input",n[15]),ee(o,"input",n[10]),ee(o,"blur",n[12]),ee(o,"pointerup",n[11]),ee(a,"change",n[16]),ee(a,"input",n[16]),ee(a,"pointerup",n[11]),ee(a,"pointerdown",n[13]),ee(a,"pointermove",n[14])],c=!0)},p(h,[d]){const p={};d&128&&(p.show_label=h[7]),d&64&&(p.info=h[6]),d&262176&&(p.$$scope={dirty:d,ctx:h}),s.$set(p),(!u||d&2)&&v(o,"min",h[1]),(!u||d&4)&&v(o,"max",h[2]),(!u||d&8)&&v(o,"step",h[3]),(!u||d&16)&&(o.disabled=h[4]),d&256&&br(o.value)!==h[8]&&Bt(o,h[8]),(!u||d&2)&&v(a,"min",h[1]),(!u||d&4)&&v(a,"max",h[2]),(!u||d&8)&&v(a,"step",h[3]),(!u||d&16)&&(a.disabled=h[4]),d&1&&Bt(a,h[0])},i(h){u||(S(s.$$.fragment,h),u=!0)},o(h){C(s.$$.fragment,h),u=!1},d(h){h&&(E(e),E(l),E(a)),j(s),c=!1,lt(f)}}}let lx=0;function ax(n,e,t){let{value:i=0}=e,{minimum:s=0}=e,{maximum:r=100}=e,{step:o=1}=e,{disabled:l=!1}=e,{label:a}=e,{info:u=void 0}=e,{show_label:c}=e;const f=`range_id_${lx++}`,h=mi();let d=i;function p(T){const I=T.currentTarget;parseFloat(I.value),t(8,d=Math.min(Math.max(d,s),r)),t(0,i=d),h("release",i)}function g(T){h("release",i)}const m=()=>{h("release",i),t(0,i=Math.min(Math.max(i,s),r))};function _(T){Ut.call(this,n,T)}function b(T){Ut.call(this,n,T)}function y(){d=br(this.value),t(8,d),t(0,i)}function k(){i=br(this.value),t(0,i)}return n.$$set=T=>{"value"in T&&t(0,i=T.value),"minimum"in T&&t(1,s=T.minimum),"maximum"in T&&t(2,r=T.maximum),"step"in T&&t(3,o=T.step),"disabled"in T&&t(4,l=T.disabled),"label"in T&&t(5,a=T.label),"info"in T&&t(6,u=T.info),"show_label"in T&&t(7,c=T.show_label)},n.$$.update=()=>{n.$$.dirty&1&&(t(8,d=i),h("change",i))},[i,s,r,o,l,a,u,c,d,f,p,g,m,_,b,y,k]}let ux=class extends _e{constructor(e){super(),me(this,e,ax,ox,ae,{value:0,minimum:1,maximum:2,step:3,disabled:4,label:5,info:6,show_label:7})}};function A0(n){let e,t,i;function s(o){n[13](o)}let r={disabled:Kn(n[0]),minimum:n[2].properties.min,maximum:n[2].properties.max,step:n[2].properties.step,label:n[0].attrs.title,show_label:!0};return n[4]!==void 0&&(r.value=n[4]),e=new ux({props:r}),Ze.push(()=>jt(e,"value",s)),e.$on("release",n[7]),e.$on("change",n[8]),e.$on("pointerdown",n[9]),e.$on("pointermove",n[10]),{c(){Y(e.$$.fragment)},m(o,l){G(e,o,l),i=!0},p(o,l){const a={};l&1&&(a.disabled=Kn(o[0])),l&4&&(a.minimum=o[2].properties.min),l&4&&(a.maximum=o[2].properties.max),l&4&&(a.step=o[2].properties.step),l&1&&(a.label=o[0].attrs.title),!t&&l&16&&(t=!0,a.value=o[4],Gt(()=>t=!1)),e.$set(a)},i(o){i||(S(e.$$.fragment,o),i=!0)},o(o){C(e.$$.fragment,o),i=!1},d(o){j(e,o)}}}function cx(n){let e,t,i=n[2]!==null&&n[4]!==null&&A0(n);return{c(){e=z("div"),i&&i.c(),v(e,"class","wrapper gradio-slider svelte-jib6x3"),B(e,"mobile",n[1])},m(s,r){A(s,e,r),i&&i.m(e,null),n[14](e),t=!0},p(s,[r]){s[2]!==null&&s[4]!==null?i?(i.p(s,r),r&20&&S(i,1)):(i=A0(s),i.c(),S(i,1),i.m(e,null)):i&&(oe(),C(i,1,1,()=>{i=null}),le()),(!t||r&2)&&B(e,"mobile",s[1])},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d(),n[14](null)}}}function fx(n){n.style.setProperty("--background-size",`${hx(n)}%`)}function hx(n){const e=+n.min||0,t=+n.max||100;return(+n.value-e)/(t-e)*100}function dx(n,e,t){let i,s=Z,r=()=>(s(),s=ot(d,O=>t(11,i=O)),d),o,l=Z,a=()=>(l(),l=ot(h,O=>t(12,o=O)),h);n.$$.on_destroy.push(()=>s()),n.$$.on_destroy.push(()=>l());let{widget:u=null}=e,{isMobile:c=!1}=e,f=null,h=null;a();let d=null;r();let p=null;function g(O){O&&(t(2,f=O.node),a(t(3,h=f.value)),r(t(6,d=f.propsChanged)),m(o))}function m(O){t(4,p=O)}function _(O){h&&p!=null&&pi(h,o=p,o)}function b(){const O=y.querySelector("input[type=range]");fx(O)}let y=null;function k(O){c&&Jl.showIndicator(O.clientX,O.clientY,p)}let T=!0,I=null;function x(O){c&&(Jl.showIndicator(O.clientX,O.clientY,p),T&&I!=p&&(I=p,T=!1,setTimeout(()=>{T=!0},30),navigator.vibrate(10)))}function R(O){p=O,t(4,p)}function N(O){Ze[O?"unshift":"push"](()=>{y=O,t(5,y)})}return n.$$set=O=>{"widget"in O&&t(0,u=O.widget),"isMobile"in O&&t(1,c=O.isMobile)},n.$$.update=()=>{if(n.$$.dirty&1&&u&&g(u),n.$$.dirty&6157&&h!==null&&(!i||i)&&(m(o),g(u),t(2,f),t(3,h),t(11,i),t(12,o),t(0,u)),n.$$.dirty&32&&y&&b(),n.$$.dirty&2100&&y&&f!==null&&p!==null&&(!i||i)){const O=y.querySelector("input[type='range']");let D=O.step/(O.max-O.min)*100,M="max(3px, calc("+D+"% - 2px))",L="max(4px, calc("+D+"% + 0px))";y.style.setProperty("--ae-slider-bg-overlay","repeating-linear-gradient( 90deg, transparent, transparent "+M+", var(--ae-input-border-color) "+M+", var(--ae-input-border-color) "+L+" )")}},[u,c,f,h,p,y,d,_,b,k,x,i,o,R,N]}class px extends _e{constructor(e){super(),me(this,e,dx,cx,ae,{widget:0,isMobile:1})}}class lf extends As{constructor(t){super(t,0);P(this,"properties",{tags:[],defaultValue:0,min:0,max:10,step:1,precision:1});P(this,"svelteComponentType",px);P(this,"defaultValue",0);P(this,"outputProperties",[{name:"min",type:"number"},{name:"max",type:"number"},{name:"step",type:"number"},{name:"precision",type:"number"}])}parseValue(t){return typeof t!="number"?this.properties.min:yi(t,this.properties.min,this.properties.max)}clampOneConfig(t){this.setValue(this.properties.defaultValue)}}P(lf,"slotLayout",{inputs:[{name:"store",type:$.ACTION}],outputs:[{name:"value",type:"number"},{name:"changed",type:$.EVENT}]});w.registerNodeType({class:lf,title:"UI.Number",desc:"Displays a number, by default in a slider format.",type:"ui/number"});let kt=class xw{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){let s=[];return this.decompose(0,e,s,2),i.length&&i.decompose(0,i.length,s,3),this.decompose(t,this.length,s,1),bs.from(s,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){let i=[];return this.decompose(e,t,i,0),bs.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),s=new Ml(this),r=new Ml(e);for(let o=t,l=t;;){if(s.next(o),r.next(o),o=0,s.lineBreak!=r.lineBreak||s.done!=r.done||s.value!=r.value)return!1;if(l+=s.value.length,s.done||l>=i)return!0}}iter(e=1){return new Ml(this,e)}iterRange(e,t=this.length){return new Lw(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let s=this.line(e).from;i=this.iterRange(s,Math.max(s,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Mw(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?xw.empty:e.length<=32?new ii(e):bs.from(ii.split(e,[]))}};class ii extends kt{constructor(e,t=gx(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.text[r],l=s+o.length;if((t?i:l)>=e)return new mx(s,l,i,o);s=l+1,i++}}decompose(e,t,i,s){let r=e<=0&&t>=this.length?this:new ii(O0(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(s&1){let o=i.pop(),l=gu(r.text,o.text.slice(),0,r.length);if(l.length<=32)i.push(new ii(l,o.length+r.length));else{let a=l.length>>1;i.push(new ii(l.slice(0,a)),new ii(l.slice(a)))}}else i.push(r)}replace(e,t,i){if(!(i instanceof ii))return super.replace(e,t,i);let s=gu(this.text,gu(i.text,O0(this.text,0,e)),t),r=this.length+i.length-(t-e);return s.length<=32?new ii(s,r):bs.from(ii.split(s,[]),r)}sliceString(e,t=this.length,i=` -`){let s="";for(let r=0,o=0;r<=t&&oe&&o&&(s+=i),er&&(s+=l.slice(Math.max(0,e-r),t-r)),r=a+1}return s}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}static split(e,t){let i=[],s=-1;for(let r of e)i.push(r),s+=r.length+1,i.length==32&&(t.push(new ii(i,s)),i=[],s=-1);return s>-1&&t.push(new ii(i,s)),t}}class bs extends kt{constructor(e,t){super(),this.children=e,this.length=t,this.lines=0;for(let i of e)this.lines+=i.lines}lineInner(e,t,i,s){for(let r=0;;r++){let o=this.children[r],l=s+o.length,a=i+o.lines-1;if((t?a:l)>=e)return o.lineInner(e,t,i,s);s=l+1,i=a+1}}decompose(e,t,i,s){for(let r=0,o=0;o<=t&&r=o){let u=s&((o<=e?1:0)|(a>=t?2:0));o>=e&&a<=t&&!u?i.push(l):l.decompose(e-o,t-o,i,u)}o=a+1}}replace(e,t,i){if(i.lines=r&&t<=l){let a=o.replace(e-r,t-r,i),u=this.lines-o.lines+a.lines;if(a.lines>5-1&&a.lines>u>>5+1){let c=this.children.slice();return c[s]=a,new bs(c,this.length-(t-e)+i.length)}return super.replace(r,l,a)}r=l+1}return super.replace(e,t,i)}sliceString(e,t=this.length,i=` -`){let s="";for(let r=0,o=0;re&&r&&(s+=i),eo&&(s+=l.sliceString(e-o,t-o,i)),o=a+1}return s}flatten(e){for(let t of this.children)t.flatten(e)}scanIdentical(e,t){if(!(e instanceof bs))return 0;let i=0,[s,r,o,l]=t>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=t,r+=t){if(s==o||r==l)return i;let a=this.children[s],u=e.children[r];if(a!=u)return i+a.scanIdentical(u,t);i+=a.length+1}}static from(e,t=e.reduce((i,s)=>i+s.length+1,-1)){let i=0;for(let d of e)i+=d.lines;if(i<32){let d=[];for(let p of e)p.flatten(d);return new ii(d,t)}let s=Math.max(32,i>>5),r=s<<1,o=s>>1,l=[],a=0,u=-1,c=[];function f(d){let p;if(d.lines>r&&d instanceof bs)for(let g of d.children)f(g);else d.lines>o&&(a>o||!a)?(h(),l.push(d)):d instanceof ii&&a&&(p=c[c.length-1])instanceof ii&&d.lines+p.lines<=32?(a+=d.lines,u+=d.length+1,c[c.length-1]=new ii(p.text.concat(d.text),p.length+1+d.length)):(a+d.lines>s&&h(),a+=d.lines,u+=d.length+1,c.push(d))}function h(){a!=0&&(l.push(c.length==1?c[0]:bs.from(c,u)),u=-1,a=c.length=0)}for(let d of e)f(d);return h(),l.length==1?l[0]:new bs(l,t)}}kt.empty=new ii([""],0);function gx(n){let e=-1;for(let t of n)e+=t.length+1;return e}function gu(n,e,t=0,i=1e9){for(let s=0,r=0,o=!0;r=t&&(a>i&&(l=l.slice(0,i-s)),s0?1:(e instanceof ii?e.text.length:e.children.length)<<1]}nextInner(e,t){for(this.done=this.lineBreak=!1;;){let i=this.nodes.length-1,s=this.nodes[i],r=this.offsets[i],o=r>>1,l=s instanceof ii?s.text.length:s.children.length;if(o==(t>0?l:0)){if(i==0)return this.done=!0,this.value="",this;t>0&&this.offsets[i-1]++,this.nodes.pop(),this.offsets.pop()}else if((r&1)==(t>0?0:1)){if(this.offsets[i]+=t,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof ii){let a=s.text[o+(t<0?-1:0)];if(this.offsets[i]+=t,a.length>Math.max(0,e))return this.value=e==0?a:t>0?a.slice(e):a.slice(0,a.length-e),this;e-=a.length}else{let a=s.children[o+(t<0?-1:0)];e>a.length?(e-=a.length,this.offsets[i]+=t):(t<0&&this.offsets[i]--,this.nodes.push(a),this.offsets.push(t>0?1:(a instanceof ii?a.text.length:a.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Lw{constructor(e,t,i){this.value="",this.done=!1,this.cursor=new Ml(e,t>i?-1:1),this.pos=t>i?e.length:0,this.from=Math.min(t,i),this.to=Math.max(t,i)}nextInner(e,t){if(t<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,t<0?this.pos-this.to:this.from-this.pos);let i=t<0?this.pos-this.from:this.to-this.pos;e>i&&(e=i),i-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*t,this.value=s.length<=i?s:t<0?s.slice(s.length-i):s.slice(0,i),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class Mw{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:t,lineBreak:i,value:s}=this.inner.next(e);return t?(this.done=!0,this.value=""):i?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(kt.prototype[Symbol.iterator]=function(){return this.iter()},Ml.prototype[Symbol.iterator]=Lw.prototype[Symbol.iterator]=Mw.prototype[Symbol.iterator]=function(){return this});class mx{constructor(e,t,i,s){this.from=e,this.to=t,this.number=i,this.text=s}get length(){return this.to-this.from}}let Bo="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(n=>n?parseInt(n,36):1);for(let n=1;nn)return Bo[e-1]<=n;return!1}function N0(n){return n>=127462&&n<=127487}const D0=8205;function Ln(n,e,t=!0,i=!0){return(t?Rw:bx)(n,e,i)}function Rw(n,e,t){if(e==n.length)return e;e&&Pw(n.charCodeAt(e))&&Bw(n.charCodeAt(e-1))&&e--;let i=$i(n,e);for(e+=ns(i);e=0&&N0($i(n,o));)r++,o-=2;if(r%2==0)break;e+=2}else break}return e}function bx(n,e,t){for(;e>0;){let i=Rw(n,e-2,t);if(i=56320&&n<57344}function Bw(n){return n>=55296&&n<56320}function $i(n,e){let t=n.charCodeAt(e);if(!Bw(t)||e+1==n.length)return t;let i=n.charCodeAt(e+1);return Pw(i)?(t-55296<<10)+(i-56320)+65536:t}function zw(n){return n<=65535?String.fromCharCode(n):(n-=65536,String.fromCharCode((n>>10)+55296,(n&1023)+56320))}function ns(n){return n<65536?1:2}const Jh=/\r\n?|\n/;var rn=function(n){return n[n.Simple=0]="Simple",n[n.TrackDel=1]="TrackDel",n[n.TrackBefore=2]="TrackBefore",n[n.TrackAfter=3]="TrackAfter",n}(rn||(rn={}));class Ts{constructor(e){this.sections=e}get length(){let e=0;for(let t=0;te)return r+(e-s);r+=l}else{if(i!=rn.Simple&&u>=e&&(i==rn.TrackDel&&se||i==rn.TrackBefore&&se))return null;if(u>e||u==e&&t<0&&!l)return e==s||t<0?r:r+a;r+=a}s=u}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return r}touchesRange(e,t=e){for(let i=0,s=0;i=0&&s<=t&&l>=e)return st?"cover":!0;s=l}return!1}toString(){let e="";for(let t=0;t=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(t=>typeof t!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Ts(e)}static create(e){return new Ts(e)}}class di extends Ts{constructor(e,t){super(e),this.inserted=t}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Zh(this,(t,i,s,r,o)=>e=e.replace(s,s+(i-t),o),!1),e}mapDesc(e,t=!1){return Qh(this,e,t,!0)}invert(e){let t=this.sections.slice(),i=[];for(let s=0,r=0;s=0){t[s]=l,t[s+1]=o;let a=s>>1;for(;i.length0&&ur(i,t,r.text),r.forward(c),l+=c}let u=e[o++];for(;l>1].toJSON()))}return e}static of(e,t,i){let s=[],r=[],o=0,l=null;function a(c=!1){if(!c&&!s.length)return;oh||f<0||h>t)throw new RangeError(`Invalid change range ${f} to ${h} (in doc of length ${t})`);let p=d?typeof d=="string"?kt.of(d.split(i||Jh)):d:kt.empty,g=p.length;if(f==h&&g==0)return;fo&&Xi(s,f-o,-1),Xi(s,h-f,g),ur(r,s,p),o=h}}return u(e),a(!l),l}static empty(e){return new di(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let t=[],i=[];for(let s=0;sl&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(r.length==1)t.push(r[0],0);else{for(;i.length=0&&t<=0&&t==n[s+1]?n[s]+=e:e==0&&n[s]==0?n[s+1]+=t:i?(n[s]+=e,n[s+1]+=t):n.push(e,t)}function ur(n,e,t){if(t.length==0)return;let i=e.length-2>>1;if(i>1])),!(t||o==n.sections.length||n.sections[o+1]<0);)l=n.sections[o++],a=n.sections[o++];e(s,u,r,c,f),s=u,r=c}}}function Qh(n,e,t,i=!1){let s=[],r=i?[]:null,o=new Zl(n),l=new Zl(e);for(let a=-1;;)if(o.ins==-1&&l.ins==-1){let u=Math.min(o.len,l.len);Xi(s,u,-1),o.forward(u),l.forward(u)}else if(l.ins>=0&&(o.ins<0||a==o.i||o.off==0&&(l.len=0&&a=0){let u=0,c=o.len;for(;c;)if(l.ins==-1){let f=Math.min(c,l.len);u+=f,c-=f,l.forward(f)}else if(l.ins==0&&l.lena||o.ins>=0&&o.len>a)&&(l||i.length>u),r.forward2(a),o.forward(a)}}}}class Zl{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return t>=e.length?kt.empty:e[t]}textBit(e){let{inserted:t}=this.set,i=this.i-2>>1;return i>=t.length&&!e?kt.empty:t[i].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Hr{constructor(e,t,i){this.from=e,this.to=t,this.flags=i}get anchor(){return this.flags&16?this.to:this.from}get head(){return this.flags&16?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&4?-1:this.flags&8?1:0}get bidiLevel(){let e=this.flags&3;return e==3?null:e}get goalColumn(){let e=this.flags>>5;return e==33554431?void 0:e}map(e,t=-1){let i,s;return this.empty?i=s=e.mapPos(this.from,t):(i=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),i==this.from&&s==this.to?this:new Hr(i,s,this.flags)}extend(e,t=e){if(e<=this.anchor&&t>=this.anchor)return de.range(e,t);let i=Math.abs(e-this.anchor)>Math.abs(t-this.anchor)?e:t;return de.range(this.anchor,i)}eq(e){return this.anchor==e.anchor&&this.head==e.head}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return de.range(e.anchor,e.head)}static create(e,t,i){return new Hr(e,t,i)}}class de{constructor(e,t){this.ranges=e,this.mainIndex=t}map(e,t=-1){return e.empty?this:de.create(this.ranges.map(i=>i.map(e,t)),this.mainIndex)}eq(e){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let t=0;te.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new de(e.ranges.map(t=>Hr.fromJSON(t)),e.main)}static single(e,t=e){return new de([de.range(e,t)],0)}static create(e,t=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let i=0,s=0;se?4:0)|r)}static normalized(e,t=0){let i=e[t];e.sort((s,r)=>s.from-r.from),t=e.indexOf(i);for(let s=1;sr.head?de.range(a,l):de.range(l,a))}}return new de(e,t)}}function Ww(n,e){for(let t of n.ranges)if(t.to>e)throw new RangeError("Selection points outside of document")}let Hp=0;class We{constructor(e,t,i,s,r){this.combine=e,this.compareInput=t,this.compare=i,this.isStatic=s,this.id=Hp++,this.default=e([]),this.extensions=typeof r=="function"?r(this):r}static define(e={}){return new We(e.combine||(t=>t),e.compareInput||((t,i)=>t===i),e.compare||(e.combine?(t,i)=>t===i:Up),!!e.static,e.enables)}of(e){return new mu([],this,0,e)}compute(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new mu(e,this,1,t)}computeN(e,t){if(this.isStatic)throw new Error("Can't compute a static facet");return new mu(e,this,2,t)}from(e,t){return t||(t=i=>i),this.compute([e],i=>t(i.field(e)))}}function Up(n,e){return n==e||n.length==e.length&&n.every((t,i)=>t===e[i])}class mu{constructor(e,t,i,s){this.dependencies=e,this.facet=t,this.type=i,this.value=s,this.id=Hp++}dynamicSlot(e){var t;let i=this.value,s=this.facet.compareInput,r=this.id,o=e[r]>>1,l=this.type==2,a=!1,u=!1,c=[];for(let f of this.dependencies)f=="doc"?a=!0:f=="selection"?u=!0:((t=e[f.id])!==null&&t!==void 0?t:1)&1||c.push(e[f.id]);return{create(f){return f.values[o]=i(f),1},update(f,h){if(a&&h.docChanged||u&&(h.docChanged||h.selection)||ed(f,c)){let d=i(f);if(l?!x0(d,f.values[o],s):!s(d,f.values[o]))return f.values[o]=d,1}return 0},reconfigure:(f,h)=>{let d,p=h.config.address[r];if(p!=null){let g=Qu(h,p);if(this.dependencies.every(m=>m instanceof We?h.facet(m)===f.facet(m):m instanceof Pn?h.field(m,!1)==f.field(m,!1):!0)||(l?x0(d=i(f),g,s):s(d=i(f),g)))return f.values[o]=g,0}else d=i(f);return f.values[o]=d,1}}}}function x0(n,e,t){if(n.length!=e.length)return!1;for(let i=0;in[a.id]),s=t.map(a=>a.type),r=i.filter(a=>!(a&1)),o=n[e.id]>>1;function l(a){let u=[];for(let c=0;ci===s),e);return e.provide&&(t.provides=e.provide(t)),t}create(e){let t=e.facet(L0).find(i=>i.field==this);return((t==null?void 0:t.create)||this.createF)(e)}slot(e){let t=e[this.id]>>1;return{create:i=>(i.values[t]=this.create(i),1),update:(i,s)=>{let r=i.values[t],o=this.updateF(r,s);return this.compareF(r,o)?0:(i.values[t]=o,1)},reconfigure:(i,s)=>s.config.address[this.id]!=null?(i.values[t]=s.field(this),0):(i.values[t]=this.create(i),1)}}init(e){return[this,L0.of({field:this,create:e})]}get extension(){return this}}const zr={lowest:4,low:3,default:2,high:1,highest:0};function _l(n){return e=>new Vw(e,n)}const da={highest:_l(zr.highest),high:_l(zr.high),default:_l(zr.default),low:_l(zr.low),lowest:_l(zr.lowest)};class Vw{constructor(e,t){this.inner=e,this.prec=t}}class af{of(e){return new td(this,e)}reconfigure(e){return af.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class td{constructor(e,t){this.compartment=e,this.inner=t}}class Zu{constructor(e,t,i,s,r,o){for(this.base=e,this.compartments=t,this.dynamicSlots=i,this.address=s,this.staticValues=r,this.facets=o,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,t,i){let s=[],r=Object.create(null),o=new Map;for(let h of vx(e,t,o))h instanceof Pn?s.push(h):(r[h.facet.id]||(r[h.facet.id]=[])).push(h);let l=Object.create(null),a=[],u=[];for(let h of s)l[h.id]=u.length<<1,u.push(d=>h.slot(d));let c=i==null?void 0:i.config.facets;for(let h in r){let d=r[h],p=d[0].facet,g=c&&c[h]||[];if(d.every(m=>m.type==0))if(l[p.id]=a.length<<1|1,Up(g,d))a.push(i.facet(p));else{let m=p.combine(d.map(_=>_.value));a.push(i&&p.compare(m,i.facet(p))?i.facet(p):m)}else{for(let m of d)m.type==0?(l[m.id]=a.length<<1|1,a.push(m.value)):(l[m.id]=u.length<<1,u.push(_=>m.dynamicSlot(_)));l[p.id]=u.length<<1,u.push(m=>yx(m,p,d))}}let f=u.map(h=>h(l));return new Zu(e,o,f,l,a,r)}}function vx(n,e,t){let i=[[],[],[],[],[]],s=new Map;function r(o,l){let a=s.get(o);if(a!=null){if(a<=l)return;let u=i[a].indexOf(o);u>-1&&i[a].splice(u,1),o instanceof td&&t.delete(o.compartment)}if(s.set(o,l),Array.isArray(o))for(let u of o)r(u,l);else if(o instanceof td){if(t.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let u=e.get(o.compartment)||o.inner;t.set(o.compartment,u),r(u,l)}else if(o instanceof Vw)r(o.inner,o.prec);else if(o instanceof Pn)i[l].push(o),o.provides&&r(o.provides,l);else if(o instanceof mu)i[l].push(o),o.facet.extensions&&r(o.facet.extensions,zr.default);else{let u=o.extension;if(!u)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);r(u,l)}}return r(n,zr.default),i.reduce((o,l)=>o.concat(l))}function Rl(n,e){if(e&1)return 2;let t=e>>1,i=n.status[t];if(i==4)throw new Error("Cyclic dependency between fields and/or facets");if(i&2)return i;n.status[t]=4;let s=n.computeSlot(n,n.config.dynamicSlots[t]);return n.status[t]=2|s}function Qu(n,e){return e&1?n.config.staticValues[e>>1]:n.values[e>>1]}const Hw=We.define(),Uw=We.define({combine:n=>n.some(e=>e),static:!0}),Gw=We.define({combine:n=>n.length?n[0]:void 0,static:!0}),jw=We.define(),qw=We.define(),Yw=We.define(),Xw=We.define({combine:n=>n.length?n[0]:!1});class Ys{constructor(e,t){this.type=e,this.value=t}static define(){return new wx}}class wx{of(e){return new Ys(this,e)}}class kx{constructor(e){this.map=e}of(e){return new dt(this,e)}}class dt{constructor(e,t){this.type=e,this.value=t}map(e){let t=this.type.map(this.value,e);return t===void 0?void 0:t==this.value?this:new dt(this.type,t)}is(e){return this.type==e}static define(e={}){return new kx(e.map||(t=>t))}static mapEffects(e,t){if(!e.length)return e;let i=[];for(let s of e){let r=s.map(t);r&&i.push(r)}return i}}dt.reconfigure=dt.define();dt.appendConfig=dt.define();class gi{constructor(e,t,i,s,r,o){this.startState=e,this.changes=t,this.selection=i,this.effects=s,this.annotations=r,this.scrollIntoView=o,this._doc=null,this._state=null,i&&Ww(i,t.newLength),r.some(l=>l.type==gi.time)||(this.annotations=r.concat(gi.time.of(Date.now())))}static create(e,t,i,s,r,o){return new gi(e,t,i,s,r,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let t of this.annotations)if(t.type==e)return t.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let t=this.annotation(gi.userEvent);return!!(t&&(t==e||t.length>e.length&&t.slice(0,e.length)==e&&t[e.length]=="."))}}gi.time=Ys.define();gi.userEvent=Ys.define();gi.addToHistory=Ys.define();gi.remote=Ys.define();function Sx(n,e){let t=[];for(let i=0,s=0;;){let r,o;if(i=n[i]))r=n[i++],o=n[i++];else if(s=0;s--){let r=i[s](n);r instanceof gi?n=r:Array.isArray(r)&&r.length==1&&r[0]instanceof gi?n=r[0]:n=$w(e,zo(r),!1)}return n}function Cx(n){let e=n.startState,t=e.facet(Yw),i=n;for(let s=t.length-1;s>=0;s--){let r=t[s](n);r&&Object.keys(r).length&&(i=Kw(i,nd(e,r,n.changes.newLength),!0))}return i==n?n:gi.create(e,n.changes,n.selection,i.effects,i.annotations,i.scrollIntoView)}const Ix=[];function zo(n){return n==null?Ix:Array.isArray(n)?n:[n]}var Gn=function(n){return n[n.Word=0]="Word",n[n.Space=1]="Space",n[n.Other=2]="Other",n}(Gn||(Gn={}));const Ex=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let sd;try{sd=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Ax(n){if(sd)return sd.test(n);for(let e=0;e"€"&&(t.toUpperCase()!=t.toLowerCase()||Ex.test(t)))return!0}return!1}function Ox(n){return e=>{if(!/\S/.test(e))return Gn.Space;if(Ax(e))return Gn.Word;for(let t=0;t-1)return Gn.Word;return Gn.Other}}class pt{constructor(e,t,i,s,r,o){this.config=e,this.doc=t,this.selection=i,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=r,o&&(o._state=this);for(let l=0;ls.set(a,l)),t=null),s.set(o.value.compartment,o.value.extension)):o.is(dt.reconfigure)?(t=null,i=o.value):o.is(dt.appendConfig)&&(t=null,i=zo(i).concat(o.value));let r;t?r=e.startState.values.slice():(t=Zu.resolve(i,s,this),r=new pt(t,this.doc,this.selection,t.dynamicSlots.map(()=>null),(l,a)=>a.reconfigure(l,this),null).values),new pt(t,e.newDoc,e.newSelection,r,(o,l)=>l.update(o,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(t=>({changes:{from:t.from,to:t.to,insert:e},range:de.cursor(t.from+e.length)}))}changeByRange(e){let t=this.selection,i=e(t.ranges[0]),s=this.changes(i.changes),r=[i.range],o=zo(i.effects);for(let l=1;lo.spec.fromJSON(l,a)))}}return pt.create({doc:e.doc,selection:de.fromJSON(e.selection),extensions:t.extensions?s.concat([t.extensions]):s})}static create(e={}){let t=Zu.resolve(e.extensions||[],new Map),i=e.doc instanceof kt?e.doc:kt.of((e.doc||"").split(t.staticFacet(pt.lineSeparator)||Jh)),s=e.selection?e.selection instanceof de?e.selection:de.single(e.selection.anchor,e.selection.head):de.single(0);return Ww(s,i.length),t.staticFacet(Uw)||(s=s.asSingle()),new pt(t,i,s,t.dynamicSlots.map(()=>null),(r,o)=>o.create(r),null)}get tabSize(){return this.facet(pt.tabSize)}get lineBreak(){return this.facet(pt.lineSeparator)||` -`}get readOnly(){return this.facet(Xw)}phrase(e,...t){for(let i of this.facet(pt.phrases))if(Object.prototype.hasOwnProperty.call(i,e)){e=i[e];break}return t.length&&(e=e.replace(/\$(\$|\d*)/g,(i,s)=>{if(s=="$")return"$";let r=+(s||1);return!r||r>t.length?i:t[r-1]})),e}languageDataAt(e,t,i=-1){let s=[];for(let r of this.facet(Hw))for(let o of r(this,t,i))Object.prototype.hasOwnProperty.call(o,e)&&s.push(o[e]);return s}charCategorizer(e){return Ox(this.languageDataAt("wordChars",e).join(""))}wordAt(e){let{text:t,from:i,length:s}=this.doc.lineAt(e),r=this.charCategorizer(e),o=e-i,l=e-i;for(;o>0;){let a=Ln(t,o,!1);if(r(t.slice(a,o))!=Gn.Word)break;o=a}for(;ln.length?n[0]:4});pt.lineSeparator=Gw;pt.readOnly=Xw;pt.phrases=We.define({compare(n,e){let t=Object.keys(n),i=Object.keys(e);return t.length==i.length&&t.every(s=>n[s]==e[s])}});pt.languageData=Hw;pt.changeFilter=jw;pt.transactionFilter=qw;pt.transactionExtender=Yw;af.reconfigure=dt.define();function so(n,e,t={}){let i={};for(let s of n)for(let r of Object.keys(s)){let o=s[r],l=i[r];if(l===void 0)i[r]=o;else if(!(l===o||o===void 0))if(Object.hasOwnProperty.call(t,r))i[r]=t[r](l,o);else throw new Error("Config merge conflict for field "+r)}for(let s in e)i[s]===void 0&&(i[s]=e[s]);return i}class eo{eq(e){return this==e}range(e,t=e){return rd.create(e,t,this)}}eo.prototype.startSide=eo.prototype.endSide=0;eo.prototype.point=!1;eo.prototype.mapMode=rn.TrackDel;let rd=class Jw{constructor(e,t,i){this.from=e,this.to=t,this.value=i}static create(e,t,i){return new Jw(e,t,i)}};function od(n,e){return n.from-e.from||n.value.startSide-e.value.startSide}class Gp{constructor(e,t,i,s){this.from=e,this.to=t,this.value=i,this.maxPoint=s}get length(){return this.to[this.to.length-1]}findIndex(e,t,i,s=0){let r=i?this.to:this.from;for(let o=s,l=r.length;;){if(o==l)return o;let a=o+l>>1,u=r[a]-e||(i?this.value[a].endSide:this.value[a].startSide)-t;if(a==o)return u>=0?o:l;u>=0?l=a:o=a+1}}between(e,t,i,s){for(let r=this.findIndex(t,-1e9,!0),o=this.findIndex(i,1e9,!1,r);rd||h==d&&u.startSide>0&&u.endSide<=0)continue;(d-h||u.endSide-u.startSide)<0||(o<0&&(o=h),u.point&&(l=Math.max(l,d-h)),i.push(u),s.push(h-o),r.push(d-o))}return{mapped:i.length?new Gp(s,r,i,l):null,pos:o}}}class Tt{constructor(e,t,i,s){this.chunkPos=e,this.chunk=t,this.nextLayer=i,this.maxPoint=s}static create(e,t,i,s){return new Tt(e,t,i,s)}get length(){let e=this.chunk.length-1;return e<0?0:Math.max(this.chunkEnd(e),this.nextLayer.length)}get size(){if(this.isEmpty)return 0;let e=this.nextLayer.size;for(let t of this.chunk)e+=t.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:t=[],sort:i=!1,filterFrom:s=0,filterTo:r=this.length}=e,o=e.filter;if(t.length==0&&!o)return this;if(i&&(t=t.slice().sort(od)),this.isEmpty)return t.length?Tt.of(t):this;let l=new Zw(this,null,-1).goto(0),a=0,u=[],c=new to;for(;l.value||a=0){let f=t[a++];c.addInner(f.from,f.to,f.value)||u.push(f)}else l.rangeIndex==1&&l.chunkIndexthis.chunkEnd(l.chunkIndex)||rl.to||r=r&&e<=r+o.length&&o.between(r,e-r,t-r,i)===!1)return}this.nextLayer.between(e,t,i)}}iter(e=0){return Ql.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,t=0){return Ql.from(e).goto(t)}static compare(e,t,i,s,r=-1){let o=e.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),l=t.filter(f=>f.maxPoint>0||!f.isEmpty&&f.maxPoint>=r),a=M0(o,l,i),u=new bl(o,a,r),c=new bl(l,a,r);i.iterGaps((f,h,d)=>R0(u,f,c,h,d,s)),i.empty&&i.length==0&&R0(u,0,c,0,0,s)}static eq(e,t,i=0,s){s==null&&(s=1e9-1);let r=e.filter(c=>!c.isEmpty&&t.indexOf(c)<0),o=t.filter(c=>!c.isEmpty&&e.indexOf(c)<0);if(r.length!=o.length)return!1;if(!r.length)return!0;let l=M0(r,o),a=new bl(r,l,0).goto(i),u=new bl(o,l,0).goto(i);for(;;){if(a.to!=u.to||!ld(a.active,u.active)||a.point&&(!u.point||!a.point.eq(u.point)))return!1;if(a.to>s)return!0;a.next(),u.next()}}static spans(e,t,i,s,r=-1){let o=new bl(e,null,r).goto(t),l=t,a=o.openStart;for(;;){let u=Math.min(o.to,i);if(o.point){let c=o.activeForPoint(o.to),f=o.pointFroml&&(s.span(l,u,o.active,a),a=o.openEnd(u));if(o.to>i)return a+(o.point&&o.to>i?1:0);l=o.to,o.next()}}static of(e,t=!1){let i=new to;for(let s of e instanceof rd?[e]:t?Nx(e):e)i.add(s.from,s.to,s.value);return i.finish()}}Tt.empty=new Tt([],[],null,-1);function Nx(n){if(n.length>1)for(let e=n[0],t=1;t0)return n.slice().sort(od);e=i}return n}Tt.empty.nextLayer=Tt.empty;class to{finishChunk(e){this.chunks.push(new Gp(this.from,this.to,this.value,this.maxPoint)),this.chunkPos.push(this.chunkStart),this.chunkStart=-1,this.setMaxPoint=Math.max(this.setMaxPoint,this.maxPoint),this.maxPoint=-1,e&&(this.from=[],this.to=[],this.value=[])}constructor(){this.chunks=[],this.chunkPos=[],this.chunkStart=-1,this.last=null,this.lastFrom=-1e9,this.lastTo=-1e9,this.from=[],this.to=[],this.value=[],this.maxPoint=-1,this.setMaxPoint=-1,this.nextLayer=null}add(e,t,i){this.addInner(e,t,i)||(this.nextLayer||(this.nextLayer=new to)).add(e,t,i)}addInner(e,t,i){let s=e-this.lastTo||i.startSide-this.last.endSide;if(s<=0&&(e-this.lastFrom||i.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return s<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(t-this.chunkStart),this.last=i,this.lastFrom=e,this.lastTo=t,this.value.push(i),i.point&&(this.maxPoint=Math.max(this.maxPoint,t-e)),!0)}addChunk(e,t){if((e-this.lastTo||t.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,t.maxPoint),this.chunks.push(t),this.chunkPos.push(e);let i=t.value.length-1;return this.last=t.value[i],this.lastFrom=t.from[i]+e,this.lastTo=t.to[i]+e,!0}finish(){return this.finishInner(Tt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let t=Tt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,t}}function M0(n,e,t){let i=new Map;for(let r of n)for(let o=0;o=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=i&&s.push(new Zw(o,t,i,r));return s.length==1?s[0]:new Ql(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,t=-1e9){for(let i of this.heap)i.goto(e,t);for(let i=this.heap.length>>1;i>=0;i--)Wf(this.heap,i);return this.next(),this}forward(e,t){for(let i of this.heap)i.forward(e,t);for(let i=this.heap.length>>1;i>=0;i--)Wf(this.heap,i);(this.to-e||this.value.endSide-t)<0&&this.next()}next(){if(this.heap.length==0)this.from=this.to=1e9,this.value=null,this.rank=-1;else{let e=this.heap[0];this.from=e.from,this.to=e.to,this.value=e.value,this.rank=e.rank,e.value&&e.next(),Wf(this.heap,0)}}}function Wf(n,e){for(let t=n[e];;){let i=(e<<1)+1;if(i>=n.length)break;let s=n[i];if(i+1=0&&(s=n[i+1],i++),t.compare(s)<0)break;n[i]=t,n[e]=s,e=i}}class bl{constructor(e,t,i){this.minPoint=i,this.active=[],this.activeTo=[],this.activeRank=[],this.minActive=-1,this.point=null,this.pointFrom=0,this.pointRank=0,this.to=-1e9,this.endSide=0,this.openStart=-1,this.cursor=Ql.from(e,t,i)}goto(e,t=-1e9){return this.cursor.goto(e,t),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=t,this.openStart=-1,this.next(),this}forward(e,t){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-t)<0;)this.removeActive(this.minActive);this.cursor.forward(e,t)}removeActive(e){Ma(this.active,e),Ma(this.activeTo,e),Ma(this.activeRank,e),this.minActive=P0(this.active,this.activeTo)}addActive(e){let t=0,{value:i,to:s,rank:r}=this.cursor;for(;t-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),i&&Ma(i,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let r=this.cursor.value;if(!r.point)this.addActive(i),this.cursor.next();else if(t&&this.cursor.to==this.to&&this.cursor.from=0&&i[s]=0&&!(this.activeRank[i]e||this.activeTo[i]==e&&this.active[i].endSide>=this.point.endSide)&&t.push(this.active[i]);return t.reverse()}openEnd(e){let t=0;for(let i=this.activeTo.length-1;i>=0&&this.activeTo[i]>e;i--)t++;return t}}function R0(n,e,t,i,s,r){n.goto(e),t.goto(i);let o=i+s,l=i,a=i-e;for(;;){let u=n.to+a-t.to||n.endSide-t.endSide,c=u<0?n.to+a:t.to,f=Math.min(c,o);if(n.point||t.point?n.point&&t.point&&(n.point==t.point||n.point.eq(t.point))&&ld(n.activeForPoint(n.to),t.activeForPoint(t.to))||r.comparePoint(l,f,n.point,t.point):f>l&&!ld(n.active,t.active)&&r.compareRange(l,f,n.active,t.active),c>o)break;l=c,u<=0&&n.next(),u>=0&&t.next()}}function ld(n,e){if(n.length!=e.length)return!1;for(let t=0;t=e;i--)n[i+1]=n[i];n[e]=t}function P0(n,e){let t=-1,i=1e9;for(let s=0;s=e)return s;if(s==n.length)break;r+=n.charCodeAt(s)==9?t-r%t:1,s=Ln(n,s)}return i===!0?-1:n.length}const ud="ͼ",B0=typeof Symbol>"u"?"__"+ud:Symbol.for(ud),cd=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),z0=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class Sr{constructor(e,t){this.rules=[];let{finish:i}=t||{};function s(o){return/^@/.test(o)?[o]:o.split(/,\s*/)}function r(o,l,a,u){let c=[],f=/^@(\w+)\b/.exec(o[0]),h=f&&f[1]=="keyframes";if(f&&l==null)return a.push(o[0]+";");for(let d in l){let p=l[d];if(/&/.test(d))r(d.split(/,\s*/).map(g=>o.map(m=>g.replace(/&/,m))).reduce((g,m)=>g.concat(m)),p,a);else if(p&&typeof p=="object"){if(!f)throw new RangeError("The value of a property ("+d+") should be a primitive value.");r(s(d),p,c,h)}else p!=null&&c.push(d.replace(/_.*/,"").replace(/[A-Z]/g,g=>"-"+g.toLowerCase())+": "+p+";")}(c.length||h)&&a.push((i&&!f&&!u?o.map(i):o).join(", ")+" {"+c.join(" ")+"}")}for(let o in e)r(s(o),e[o],this.rules)}getRules(){return this.rules.join(` -`)}static newName(){let e=z0[B0]||1;return z0[B0]=e+1,ud+e.toString(36)}static mount(e,t){(e[cd]||new Dx(e)).mount(Array.isArray(t)?t:[t])}}let F0=new Map;class Dx{constructor(e){let t=e.ownerDocument||e,i=t.defaultView;if(!e.head&&e.adoptedStyleSheets&&i.CSSStyleSheet){let s=F0.get(t);if(s)return e.adoptedStyleSheets=[s.sheet,...e.adoptedStyleSheets],e[cd]=s;this.sheet=new i.CSSStyleSheet,e.adoptedStyleSheets=[this.sheet,...e.adoptedStyleSheets],F0.set(t,this)}else{this.styleTag=t.createElement("style");let s=e.head||e;s.insertBefore(this.styleTag,s.firstChild)}this.modules=[],e[cd]=this}mount(e){let t=this.sheet,i=0,s=0;for(let r=0;r-1&&(this.modules.splice(l,1),s--,l=-1),l==-1){if(this.modules.splice(s++,0,o),t)for(let a=0;a",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},xx=typeof navigator<"u"&&/Mac/.test(navigator.platform),Lx=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Mi=0;Mi<10;Mi++)Tr[48+Mi]=Tr[96+Mi]=String(Mi);for(var Mi=1;Mi<=24;Mi++)Tr[Mi+111]="F"+Mi;for(var Mi=65;Mi<=90;Mi++)Tr[Mi]=String.fromCharCode(Mi+32),ea[Mi]=String.fromCharCode(Mi);for(var Vf in Tr)ea.hasOwnProperty(Vf)||(ea[Vf]=Tr[Vf]);function Mx(n){var e=xx&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Lx&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?ea:Tr)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}function ec(n){let e;return n.nodeType==11?e=n.getSelection?n:n.ownerDocument:e=n,e.getSelection()}function Jo(n,e){return e?n==e||n.contains(e.nodeType!=1?e.parentNode:e):!1}function Rx(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function _u(n,e){if(!e.anchorNode)return!1;try{return Jo(n,e.anchorNode)}catch{return!1}}function Zo(n){return n.nodeType==3?Qo(n,0,n.nodeValue.length).getClientRects():n.nodeType==1?n.getClientRects():[]}function tc(n,e,t,i){return t?W0(n,e,t,i,-1)||W0(n,e,t,i,1):!1}function ic(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e}function W0(n,e,t,i,s){for(;;){if(n==t&&e==i)return!0;if(e==(s<0?0:Cr(n))){if(n.nodeName=="DIV")return!1;let r=n.parentNode;if(!r||r.nodeType!=1)return!1;e=ic(n)+(s<0?0:1),n=r}else if(n.nodeType==1){if(n=n.childNodes[e+(s<0?-1:0)],n.nodeType==1&&n.contentEditable=="false")return!1;e=s<0?Cr(n):0}else return!1}}function Cr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function uf(n,e){let t=e?n.left:n.right;return{left:t,right:t,top:n.top,bottom:n.bottom}}function Px(n){return{left:0,right:n.innerWidth,top:0,bottom:n.innerHeight}}function Bx(n,e,t,i,s,r,o,l){let a=n.ownerDocument,u=a.defaultView||window;for(let c=n;c;)if(c.nodeType==1){let f,h=c==a.body;if(h)f=Px(u);else{if(c.scrollHeight<=c.clientHeight&&c.scrollWidth<=c.clientWidth){c=c.assignedSlot||c.parentNode;continue}let g=c.getBoundingClientRect();f={left:g.left,right:g.left+c.clientWidth,top:g.top,bottom:g.top+c.clientHeight}}let d=0,p=0;if(s=="nearest")e.top0&&e.bottom>f.bottom+p&&(p=e.bottom-f.bottom+p+o)):e.bottom>f.bottom&&(p=e.bottom-f.bottom+o,t<0&&e.top-p0&&e.right>f.right+d&&(d=e.right-f.right+d+r)):e.right>f.right&&(d=e.right-f.right+r,t<0&&e.leftt.clientHeight||t.scrollWidth>t.clientWidth)return t;t=t.assignedSlot||t.parentNode}else if(t.nodeType==11)t=t.host;else break;return null}class Fx{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}eq(e){return this.anchorNode==e.anchorNode&&this.anchorOffset==e.anchorOffset&&this.focusNode==e.focusNode&&this.focusOffset==e.focusOffset}setRange(e){let{anchorNode:t,focusNode:i}=e;this.set(t,Math.min(e.anchorOffset,t?Cr(t):0),i,Math.min(e.focusOffset,i?Cr(i):0))}set(e,t,i,s){this.anchorNode=e,this.anchorOffset=t,this.focusNode=i,this.focusOffset=s}}let mo=null;function Qw(n){if(n.setActive)return n.setActive();if(mo)return n.focus(mo);let e=[];for(let t=n;t&&(e.push(t,t.scrollTop,t.scrollLeft),t!=t.ownerDocument);t=t.parentNode);if(n.focus(mo==null?{get preventScroll(){return mo={preventScroll:!0},!0}}:void 0),!mo){mo=!1;for(let t=0;tt)return f.domBoundsAround(e,t,u);if(h>=e&&s==-1&&(s=a,r=u),u>t&&f.dom.parentNode==this.dom){o=a,l=c;break}c=h,u=h+f.breakAfter}return{from:r,to:l<0?i+this.length:l,startDOM:(s?this.children[s-1].dom.nextSibling:null)||this.dom.firstChild,endDOM:o=0?this.children[o].dom:null}}markDirty(e=!1){this.dirty|=2,this.markParentsDirty(e)}markParentsDirty(e){for(let t=this.parent;t;t=t.parent){if(e&&(t.dirty|=2),t.dirty&1)return;t.dirty|=1,e=!1}}setParent(e){this.parent!=e&&(this.parent=e,this.dirty&&this.markParentsDirty(!0))}setDOM(e){this.dom&&(this.dom.cmView=null),this.dom=e,e.cmView=this}get rootView(){for(let e=this;;){let t=e.parent;if(!t)return e;e=t}}replaceChildren(e,t,i=jp){this.markDirty();for(let s=e;sthis.pos||e==this.pos&&(t>0||this.i==0||this.children[this.i-1].breakAfter))return this.off=e-this.pos,this;let i=this.children[--this.i];this.pos-=i.length+i.breakAfter}}}function ik(n,e,t,i,s,r,o,l,a){let{children:u}=n,c=u.length?u[e]:null,f=r.length?r[r.length-1]:null,h=f?f.breakAfter:o;if(!(e==i&&c&&!o&&!h&&r.length<2&&c.merge(t,s,r.length?f:null,t==0,l,a))){if(i0&&(!o&&r.length&&c.merge(t,c.length,r[0],!1,l,0)?c.breakAfter=r.shift().breakAfter:(t2);var Pe={mac:j0||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:cf,ie_version:sk?fd.documentMode||6:dd?+dd[1]:hd?+hd[1]:0,gecko:U0,gecko_version:U0?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Hf,chrome_version:Hf?+Hf[1]:0,ios:j0,android:/Android\b/.test(Dn.userAgent),webkit:G0,safari:rk,webkit_version:G0?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,tabSize:fd.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};const Hx=256;class io extends Dt{constructor(e){super(),this.text=e}get length(){return this.text.length}createDOM(e){this.setDOM(e||document.createTextNode(this.text))}sync(e,t){this.dom||this.createDOM(),this.dom.nodeValue!=this.text&&(t&&t.node==this.dom&&(t.written=!0),this.dom.nodeValue=this.text)}reuseDOM(e){e.nodeType==3&&this.createDOM(e)}merge(e,t,i){return i&&(!(i instanceof io)||this.length-(t-e)+i.length>Hx)?!1:(this.text=this.text.slice(0,e)+(i?i.text:"")+this.text.slice(t),this.markDirty(),!0)}split(e){let t=new io(this.text.slice(e));return this.text=this.text.slice(0,e),this.markDirty(),t}localPosFromDOM(e,t){return e==this.dom?t:t?this.text.length:0}domAtPos(e){return new Pi(this.dom,e)}domBoundsAround(e,t,i){return{from:i,to:i+this.length,startDOM:this.dom,endDOM:this.dom.nextSibling}}coordsAt(e,t){return pd(this.dom,e,t)}}class js extends Dt{constructor(e,t=[],i=0){super(),this.mark=e,this.children=t,this.length=i;for(let s of t)s.setParent(this)}setAttrs(e){if(ek(e),this.mark.class&&(e.className=this.mark.class),this.mark.attrs)for(let t in this.mark.attrs)e.setAttribute(t,this.mark.attrs[t]);return e}reuseDOM(e){e.nodeName==this.mark.tagName.toUpperCase()&&(this.setDOM(e),this.dirty|=6)}sync(e,t){this.dom?this.dirty&4&&this.setAttrs(this.dom):this.setDOM(this.setAttrs(document.createElement(this.mark.tagName))),super.sync(e,t)}merge(e,t,i,s,r,o){return i&&(!(i instanceof js&&i.mark.eq(this.mark))||e&&r<=0||te&&t.push(i=e&&(s=r),i=a,r++}let o=this.length-e;return this.length=e,s>-1&&(this.children.length=s,this.markDirty()),new js(this.mark,t,o)}domAtPos(e){return ck(this,e)}coordsAt(e,t){return hk(this,e,t)}}function pd(n,e,t){let i=n.nodeValue.length;e>i&&(e=i);let s=e,r=e,o=0;e==0&&t<0||e==i&&t>=0?Pe.chrome||Pe.gecko||(e?(s--,o=1):r=0)?0:l.length-1];return Pe.safari&&!o&&a.width==0&&(a=Array.prototype.find.call(l,u=>u.width)||a),o?uf(a,o<0):a||null}class cr extends Dt{constructor(e,t,i){super(),this.widget=e,this.length=t,this.side=i,this.prevWidget=null}static create(e,t,i){return new(e.customView||cr)(e,t,i)}split(e){let t=cr.create(this.widget,this.length-e,this.side);return this.length-=e,t}sync(e){(!this.dom||!this.widget.updateDOM(this.dom,e))&&(this.dom&&this.prevWidget&&this.prevWidget.destroy(this.dom),this.prevWidget=null,this.setDOM(this.widget.toDOM(e)),this.dom.contentEditable="false")}getSide(){return this.side}merge(e,t,i,s,r,o){return i&&(!(i instanceof cr)||!this.widget.compare(i.widget)||e>0&&r<=0||t0)?Pi.before(this.dom):Pi.after(this.dom,e==this.length)}domBoundsAround(){return null}coordsAt(e,t){let i=this.widget.coordsAt(this.dom,e,t);if(i)return i;let s=this.dom.getClientRects(),r=null;if(!s.length)return null;let o=this.side?this.side<0:e>0;for(let l=o?s.length-1:0;r=s[l],!(e>0?l==0:l==s.length-1||r.tops.domAtPos(r),(s,r)=>new Pi(s,Math.min(r,s.nodeValue.length))):new Pi(i,Math.min(e,i.nodeValue.length))}sync(){this.setDOM(this.widget.toDOM())}localPosFromDOM(e,t){let{topView:i,text:s}=this.widget;return i?ak(e,t,i,s,this.length-i.length):Math.min(t,this.length)}ignoreMutation(){return!1}get overrideDOMText(){return null}coordsAt(e,t){let{topView:i,text:s}=this.widget;return i?gd(e,t,i,s,this.length-i.length,(r,o,l)=>r.coordsAt(o,l),(r,o,l)=>pd(r,o,l)):pd(s,e,t)}destroy(){var e;super.destroy(),(e=this.widget.topView)===null||e===void 0||e.destroy()}get isEditable(){return!0}canReuseDOM(){return!0}}function gd(n,e,t,i,s,r,o){if(t instanceof js){for(let l=t.dom.firstChild;l;l=l.nextSibling){let a=Dt.get(l);if(a){let u=Jo(l,i),c=a.length+(u?s:0);if(n0?Pi.before(this.dom):Pi.after(this.dom)}localPosFromDOM(){return 0}domBoundsAround(){return null}coordsAt(e){return this.dom.getBoundingClientRect()}get overrideDOMText(){return kt.empty}get isHidden(){return!0}}io.prototype.children=cr.prototype.children=el.prototype.children=jp;function ck(n,e){let t=n.dom,{children:i}=n,s=0;for(let r=0;sr&&e0;r--){let o=i[r-1];if(o.dom.parentNode==t)return o.domAtPos(o.length)}for(let r=s;r0&&e instanceof js&&s.length&&(i=s[s.length-1])instanceof js&&i.mark.eq(e.mark)?fk(i,e.children[0],t-1):(s.push(e),e.setParent(n)),n.length+=e.length}function hk(n,e,t){let i=null,s=-1,r=null,o=-1;function l(u,c){for(let f=0,h=0;f=c&&(d.children.length?l(d,c-h):(!r||r.isHidden&&t>0)&&(p>c||h==p&&d.getSide()>0)?(r=d,o=c-h):(h0?3e8:-4e8:t>0?1e8:-1e8,new Ir(e,t,t,i,e.widget||null,!1)}static replace(e){let t=!!e.block,i,s;if(e.isBlockGap)i=-5e8,s=4e8;else{let{start:r,end:o}=dk(e,t);i=(r?t?-3e8:-1:5e8)-1,s=(o?t?2e8:1:-6e8)+1}return new Ir(e,i,s,t,e.widget||null,!0)}static line(e){return new ga(e)}static set(e,t=!1){return Tt.of(e,t)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ut.none=Tt.empty;class ff extends ut{constructor(e){let{start:t,end:i}=dk(e);super(t?-1:5e8,i?1:-6e8,null,e),this.tagName=e.tagName||"span",this.class=e.class||"",this.attrs=e.attributes||null}eq(e){return this==e||e instanceof ff&&this.tagName==e.tagName&&this.class==e.class&&qp(this.attrs,e.attrs)}range(e,t=e){if(e>=t)throw new RangeError("Mark decorations may not be empty");return super.range(e,t)}}ff.prototype.point=!1;class ga extends ut{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ga&&this.spec.class==e.spec.class&&qp(this.spec.attributes,e.spec.attributes)}range(e,t=e){if(t!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,t)}}ga.prototype.mapMode=rn.TrackBefore;ga.prototype.point=!0;class Ir extends ut{constructor(e,t,i,s,r,o){super(t,i,r,e),this.block=s,this.isReplace=o,this.mapMode=s?t<=0?rn.TrackBefore:rn.TrackAfter:rn.TrackDel}get type(){return this.startSide=5||this.widget.lineBreaks>0)}eq(e){return e instanceof Ir&&Gx(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,t=e){if(this.isReplace&&(e>t||e==t&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&t!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,t)}}Ir.prototype.point=!0;function dk(n,e=!1){let{inclusiveStart:t,inclusiveEnd:i}=n;return t==null&&(t=n.inclusive),i==null&&(i=n.inclusive),{start:t??e,end:i??e}}function Gx(n,e){return n==e||!!(n&&e&&n.compare(e))}function bd(n,e,t,i=0){let s=t.length-1;s>=0&&t[s]+i>=n?t[s]=Math.max(t[s],e):t.push(n,e)}class mn extends Dt{constructor(){super(...arguments),this.children=[],this.length=0,this.prevAttrs=void 0,this.attrs=null,this.breakAfter=0}merge(e,t,i,s,r,o){if(i){if(!(i instanceof mn))return!1;this.dom||i.transferDOM(this)}return s&&this.setDeco(i?i.attrs:null),nk(this,e,t,i?i.children:[],r,o),!0}split(e){let t=new mn;if(t.breakAfter=this.breakAfter,this.length==0)return t;let{i,off:s}=this.childPos(e);s&&(t.append(this.children[i].split(s),0),this.children[i].merge(s,this.children[i].length,null,!1,0,0),i++);for(let r=i;r0&&this.children[i-1].length==0;)this.children[--i].destroy();return this.children.length=i,this.markDirty(),this.length=e,t}transferDOM(e){this.dom&&(this.markDirty(),e.setDOM(this.dom),e.prevAttrs=this.prevAttrs===void 0?this.attrs:this.prevAttrs,this.prevAttrs=void 0,this.dom=null)}setDeco(e){qp(this.attrs,e)||(this.dom&&(this.prevAttrs=this.attrs,this.markDirty()),this.attrs=e)}append(e,t){fk(this,e,t)}addLineDeco(e){let t=e.spec.attributes,i=e.spec.class;t&&(this.attrs=md(t,this.attrs||{})),i&&(this.attrs=md({class:i},this.attrs||{}))}domAtPos(e){return ck(this,e)}reuseDOM(e){e.nodeName=="DIV"&&(this.setDOM(e),this.dirty|=6)}sync(e,t){var i;this.dom?this.dirty&4&&(ek(this.dom),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0):(this.setDOM(document.createElement("div")),this.dom.className="cm-line",this.prevAttrs=this.attrs?null:void 0),this.prevAttrs!==void 0&&(_d(this.dom,this.prevAttrs,this.attrs),this.dom.classList.add("cm-line"),this.prevAttrs=void 0),super.sync(e,t);let s=this.dom.lastChild;for(;s&&Dt.get(s)instanceof js;)s=s.lastChild;if(!s||!this.length||s.nodeName!="BR"&&((i=Dt.get(s))===null||i===void 0?void 0:i.isEditable)==!1&&(!Pe.ios||!this.children.some(r=>r instanceof io))){let r=document.createElement("BR");r.cmIgnore=!0,this.dom.appendChild(r)}}measureTextSize(){if(this.children.length==0||this.length>20)return null;let e=0,t;for(let i of this.children){if(!(i instanceof io)||/[^ -~]/.test(i.text))return null;let s=Zo(i.dom);if(s.length!=1)return null;e+=s[0].width,t=s[0].height}return e?{lineHeight:this.dom.getBoundingClientRect().height,charWidth:e/this.length,textHeight:t}:null}coordsAt(e,t){let i=hk(this,e,t);if(!this.children.length&&i&&this.parent){let{heightOracle:s}=this.parent.view.viewState,r=i.bottom-i.top;if(Math.abs(r-s.lineHeight)<2&&s.textHeight=t){if(r instanceof mn)return r;if(o>t)break}s=o+r.breakAfter}return null}}class Kr extends Dt{constructor(e,t,i){super(),this.widget=e,this.length=t,this.type=i,this.breakAfter=0,this.prevWidget=null}merge(e,t,i,s,r,o){return i&&(!(i instanceof Kr)||!this.widget.compare(i.widget)||e>0&&r<=0||t0;){if(this.textOff==this.text.length){let{value:r,lineBreak:o,done:l}=this.cursor.next(this.skip);if(this.skip=0,l)throw new Error("Ran out of text content when drawing inline views");if(o){this.posCovered()||this.getLine(),this.content.length?this.content[this.content.length-1].breakAfter=1:this.breakAtStart=1,this.flushBuffer(),this.curLine=null,this.atCursorPos=!0,e--;continue}else this.text=r,this.textOff=0}let s=Math.min(this.text.length-this.textOff,e,512);this.flushBuffer(t.slice(t.length-i)),this.getLine().append(Pa(new io(this.text.slice(this.textOff,this.textOff+s)),t),i),this.atCursorPos=!0,this.textOff+=s,e-=s,i=0}}span(e,t,i,s){this.buildText(t-e,i,s),this.pos=t,this.openStart<0&&(this.openStart=s)}point(e,t,i,s,r,o){if(this.disallowBlockEffectsFor[o]&&i instanceof Ir){if(i.block)throw new RangeError("Block decorations may not be specified via plugins");if(t>this.doc.lineAt(this.pos).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}let l=t-e;if(i instanceof Ir)if(i.block){let{type:a}=i;a==Yt.WidgetAfter&&!this.posCovered()&&this.getLine(),this.addBlockWidget(new Kr(i.widget||new q0("div"),l,a))}else{let a=cr.create(i.widget||new q0("span"),l,l?0:i.startSide),u=this.atCursorPos&&!a.isEditable&&r<=s.length&&(e0),c=!a.isEditable&&(es.length||i.startSide<=0),f=this.getLine();this.pendingBuffer==2&&!u&&!a.isEditable&&(this.pendingBuffer=0),this.flushBuffer(s),u&&(f.append(Pa(new el(1),s),r),r=s.length+Math.max(0,r-s.length)),f.append(Pa(a,s),r),this.atCursorPos=c,this.pendingBuffer=c?es.length?1:2:0,this.pendingBuffer&&(this.bufferMarks=s.slice())}else this.doc.lineAt(this.pos).from==this.pos&&this.getLine().addLineDeco(i);l&&(this.textOff+l<=this.text.length?this.textOff+=l:(this.skip+=l-(this.text.length-this.textOff),this.text="",this.textOff=0),this.pos=t),this.openStart<0&&(this.openStart=r)}static build(e,t,i,s,r){let o=new Yp(e,t,i,r);return o.openEnd=Tt.spans(s,t,i,o),o.openStart<0&&(o.openStart=o.openEnd),o.finish(o.openEnd),o}}function Pa(n,e){for(let t of e)n=new js(t,[n],n.length);return n}class q0 extends Xs{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}const pk=We.define(),gk=We.define(),mk=We.define(),_k=We.define(),yd=We.define(),bk=We.define(),yk=We.define(),vk=We.define({combine:n=>n.some(e=>e)}),wk=We.define({combine:n=>n.some(e=>e)});class nc{constructor(e,t="nearest",i="nearest",s=5,r=5){this.range=e,this.y=t,this.x=i,this.yMargin=s,this.xMargin=r}map(e){return e.empty?this:new nc(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin)}}const Y0=dt.define({map:(n,e)=>n.map(e)});function Yn(n,e,t){let i=n.facet(_k);i.length?i[0](e):window.onerror&&window.onerror(String(e),t,void 0,void 0,e)}const hf=We.define({combine:n=>n.length?n[0]:!0});let jx=0;const Ol=We.define();class Qi{constructor(e,t,i,s){this.id=e,this.create=t,this.domEventHandlers=i,this.extension=s(this)}static define(e,t){const{eventHandlers:i,provide:s,decorations:r}=t||{};return new Qi(jx++,e,i,o=>{let l=[Ol.of(o)];return r&&l.push(ta.of(a=>{let u=a.plugin(o);return u?r(u):ut.none})),s&&l.push(s(o)),l})}static fromClass(e,t){return Qi.define(i=>new e(i),t)}}class Uf{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}update(e){if(this.value){if(this.mustUpdate){let t=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(t)}catch(i){if(Yn(t.state,i,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.create(e)}catch(t){Yn(e.state,t,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var t;if(!((t=this.value)===null||t===void 0)&&t.destroy)try{this.value.destroy()}catch(i){Yn(e.state,i,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const kk=We.define(),Xp=We.define(),ta=We.define(),Kp=We.define(),Sk=We.define();function Tk(n){let e=0,t=0,i=0,s=0;for(let r of n.state.facet(Sk)){let o=r(n);o&&(o.left!=null&&(e=Math.max(e,o.left)),o.right!=null&&(t=Math.max(t,o.right)),o.top!=null&&(i=Math.max(i,o.top)),o.bottom!=null&&(s=Math.max(s,o.bottom)))}return{left:e,right:t,top:i,bottom:s}}const Nl=We.define();class Cs{constructor(e,t,i,s){this.fromA=e,this.toA=t,this.fromB=i,this.toB=s}join(e){return new Cs(Math.min(this.fromA,e.fromA),Math.max(this.toA,e.toA),Math.min(this.fromB,e.fromB),Math.max(this.toB,e.toB))}addToSet(e){let t=e.length,i=this;for(;t>0;t--){let s=e[t-1];if(!(s.fromA>i.toA)){if(s.toAc)break;r+=2}if(!a)return i;new Cs(a.fromA,a.toA,a.fromB,a.toB).addToSet(i),o=a.toA,l=a.toB}}}class sc{constructor(e,t,i){this.view=e,this.state=t,this.transactions=i,this.flags=0,this.startState=e.state,this.changes=di.empty(this.startState.doc.length);for(let r of i)this.changes=this.changes.compose(r.changes);let s=[];this.changes.iterChangedRanges((r,o,l,a)=>s.push(new Cs(r,o,l,a))),this.changedRanges=s}static create(e,t,i){return new sc(e,t,i)}get viewportChanged(){return(this.flags&4)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&10)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}var qt=function(n){return n[n.LTR=0]="LTR",n[n.RTL=1]="RTL",n}(qt||(qt={}));const vd=qt.LTR,qx=qt.RTL;function Ck(n){let e=[];for(let t=0;t=t){if(l.level==i)return o;(r<0||(s!=0?s<0?l.fromt:e[r].level>l.level))&&(r=o)}}if(r<0)throw new RangeError("Index out of range");return r}}const Ht=[];function Jx(n,e){let t=n.length,i=e==vd?1:2,s=e==vd?2:1;if(!n||i==1&&!$x.test(n))return Ik(t);for(let o=0,l=i,a=i;o=0;h-=3)if(fs[h+1]==-c){let d=fs[h+2],p=d&2?i:d&4?d&1?s:i:0;p&&(Ht[o]=Ht[fs[h]]=p),l=h;break}}else{if(fs.length==189)break;fs[l++]=o,fs[l++]=u,fs[l++]=a}else if((f=Ht[o])==2||f==1){let h=f==i;a=h?0:1;for(let d=l-3;d>=0;d-=3){let p=fs[d+2];if(p&2)break;if(h)fs[d+2]|=2;else{if(p&4)break;fs[d+2]|=4}}}for(let o=0;ol;){let c=u,f=Ht[--u]!=2;for(;u>l&&f==(Ht[u-1]!=2);)u--;r.push(new Wo(u,c,f?2:1))}else r.push(new Wo(l,o,0))}else for(let o=0;or)&&this.lineBreak(),s=o}return this.findPointBefore(i,t),this}readTextNode(e){let t=e.nodeValue;for(let i of this.points)i.node==e&&(i.pos=this.text.length+Math.min(i.offset,t.length));for(let i=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let r=-1,o=1,l;if(this.lineSeparator?(r=t.indexOf(this.lineSeparator,i),o=this.lineSeparator.length):(l=s.exec(t))&&(r=l.index,o=l[0].length),this.append(t.slice(i,r<0?t.length:r)),r<0)break;if(this.lineBreak(),o>1)for(let a of this.points)a.node==e&&a.pos>this.text.length&&(a.pos-=o-1);i=r+o}}readNode(e){if(e.cmIgnore)return;let t=Dt.get(e),i=t&&t.overrideDOMText;if(i!=null){this.findPointInside(e,i.length);for(let s=i.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,t){for(let i of this.points)i.node==e&&e.childNodes[i.offset]==t&&(i.pos=this.text.length)}findPointInside(e,t){for(let i of this.points)(e.nodeType==3?i.node==e:e.contains(i.node))&&(i.pos=this.text.length+Math.min(t,i.offset))}}function X0(n){return n.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(n.nodeName)}class K0{constructor(e,t){this.node=e,this.offset=t,this.pos=-1}}class $0 extends Dt{constructor(e){super(),this.view=e,this.compositionDeco=ut.none,this.decorations=[],this.dynamicDecorationMap=[],this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.setDOM(e.contentDOM),this.children=[new mn],this.children[0].setParent(this),this.updateDeco(),this.updateInner([new Cs(0,0,0,e.state.doc.length)],0)}get length(){return this.view.state.doc.length}update(e){let t=e.changedRanges;this.minWidth>0&&t.length&&(t.every(({fromA:o,toA:l})=>lthis.minWidthTo)?(this.minWidthFrom=e.changes.mapPos(this.minWidthFrom,1),this.minWidthTo=e.changes.mapPos(this.minWidthTo,1)):this.minWidth=this.minWidthFrom=this.minWidthTo=0),this.view.inputState.composing<0?this.compositionDeco=ut.none:(e.transactions.length||this.dirty)&&(this.compositionDeco=eL(this.view,e.changes)),(Pe.ie||Pe.chrome)&&!this.compositionDeco.size&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let i=this.decorations,s=this.updateDeco(),r=sL(i,s,e.changes);return t=Cs.extendWithRanges(t,r),this.dirty==0&&t.length==0?!1:(this.updateInner(t,e.startState.doc.length),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,t){this.view.viewState.mustMeasureContent=!0,this.updateChildren(e,t);let{observer:i}=this.view;i.ignore(()=>{this.dom.style.height=this.view.viewState.contentHeight+"px",this.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let r=Pe.chrome||Pe.ios?{node:i.selectionRange.focusNode,written:!1}:void 0;this.sync(this.view,r),this.dirty=0,r&&(r.written||i.selectionRange.focusNode!=r.node)&&(this.forceSelection=!0),this.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to=0?e[s]:null;if(!r)break;let{fromA:o,toA:l,fromB:a,toB:u}=r,{content:c,breakAtStart:f,openStart:h,openEnd:d}=Yp.build(this.view.state.doc,a,u,this.decorations,this.dynamicDecorationMap),{i:p,off:g}=i.findPos(l,1),{i:m,off:_}=i.findPos(o,-1);ik(this,m,_,p,g,c,f,h,d)}}updateSelection(e=!1,t=!1){(e||!this.view.observer.selectionRange.focusNode)&&this.view.observer.readSelectionRange();let i=this.view.root.activeElement,s=i==this.dom,r=!s&&_u(this.dom,this.view.observer.selectionRange)&&!(i&&this.dom.contains(i));if(!(s||t||r))return;let o=this.forceSelection;this.forceSelection=!1;let l=this.view.state.selection.main,a=this.domAtPos(l.anchor),u=l.empty?a:this.domAtPos(l.head);if(Pe.gecko&&l.empty&&!this.compositionDeco.size&&Qx(a)){let f=document.createTextNode("");this.view.observer.ignore(()=>a.node.insertBefore(f,a.node.childNodes[a.offset]||null)),a=u=new Pi(f,0),o=!0}let c=this.view.observer.selectionRange;(o||!c.focusNode||!tc(a.node,a.offset,c.anchorNode,c.anchorOffset)||!tc(u.node,u.offset,c.focusNode,c.focusOffset))&&(this.view.observer.ignore(()=>{Pe.android&&Pe.chrome&&this.dom.contains(c.focusNode)&&rL(c.focusNode,this.dom)&&(this.dom.blur(),this.dom.focus({preventScroll:!0}));let f=ec(this.view.root);if(f)if(l.empty){if(Pe.gecko){let h=iL(a.node,a.offset);if(h&&h!=3){let d=Nk(a.node,a.offset,h==1?1:-1);d&&(a=new Pi(d,h==1?0:d.nodeValue.length))}}f.collapse(a.node,a.offset),l.bidiLevel!=null&&c.cursorBidiLevel!=null&&(c.cursorBidiLevel=l.bidiLevel)}else if(f.extend){f.collapse(a.node,a.offset);try{f.extend(u.node,u.offset)}catch{}}else{let h=document.createRange();l.anchor>l.head&&([a,u]=[u,a]),h.setEnd(u.node,u.offset),h.setStart(a.node,a.offset),f.removeAllRanges(),f.addRange(h)}r&&this.view.root.activeElement==this.dom&&(this.dom.blur(),i&&i.focus())}),this.view.observer.setSelectionRange(a,u)),this.impreciseAnchor=a.precise?null:new Pi(c.anchorNode,c.anchorOffset),this.impreciseHead=u.precise?null:new Pi(c.focusNode,c.focusOffset)}enforceCursorAssoc(){if(this.compositionDeco.size)return;let{view:e}=this,t=e.state.selection.main,i=ec(e.root),{anchorNode:s,anchorOffset:r}=e.observer.selectionRange;if(!i||!t.empty||!t.assoc||!i.modify)return;let o=mn.find(this,t.head);if(!o)return;let l=o.posAtStart;if(t.head==l||t.head==l+o.length)return;let a=this.coordsAt(t.head,-1),u=this.coordsAt(t.head,1);if(!a||!u||a.bottom>u.top)return;let c=this.domAtPos(t.head+t.assoc);i.collapse(c.node,c.offset),i.modify("move",t.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let f=e.observer.selectionRange;e.docView.posFromDOM(f.anchorNode,f.anchorOffset)!=t.from&&i.collapse(s,r)}nearest(e){for(let t=e;t;){let i=Dt.get(t);if(i&&i.rootView==this)return i;t=t.parentNode}return null}posFromDOM(e,t){let i=this.nearest(e);if(!i)throw new RangeError("Trying to find position for a DOM position outside of the document");return i.localPosFromDOM(e,t)+i.posAtStart}domAtPos(e){let{i:t,off:i}=this.childCursor().findPos(e,-1);for(;to||e==o&&r.type!=Yt.WidgetBefore&&r.type!=Yt.WidgetAfter&&(!s||t==2||this.children[s-1].breakAfter||this.children[s-1].type==Yt.WidgetBefore&&t>-2))return r.coordsAt(e-o,t);i=o}}measureVisibleLineHeights(e){let t=[],{from:i,to:s}=e,r=this.view.contentDOM.clientWidth,o=r>Math.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,l=-1,a=this.view.textDirection==qt.LTR;for(let u=0,c=0;cs)break;if(u>=i){let d=f.dom.getBoundingClientRect();if(t.push(d.height),o){let p=f.dom.lastChild,g=p?Zo(p):[];if(g.length){let m=g[g.length-1],_=a?m.right-d.left:d.right-m.left;_>l&&(l=_,this.minWidth=r,this.minWidthFrom=u,this.minWidthTo=h)}}}u=h+f.breakAfter}return t}textDirectionAt(e){let{i:t}=this.childPos(e,1);return getComputedStyle(this.children[t].dom).direction=="rtl"?qt.RTL:qt.LTR}measureTextSize(){for(let r of this.children)if(r instanceof mn){let o=r.measureTextSize();if(o)return o}let e=document.createElement("div"),t,i,s;return e.className="cm-line",e.style.width="99999px",e.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.dom.appendChild(e);let r=Zo(e.firstChild)[0];t=e.getBoundingClientRect().height,i=r?r.width/27:7,s=r?r.height:t,e.remove()}),{lineHeight:t,charWidth:i,textHeight:s}}childCursor(e=this.length){let t=this.children.length;return t&&(e-=this.children[--t].length),new tk(this.children,e,t)}computeBlockGapDeco(){let e=[],t=this.view.viewState;for(let i=0,s=0;;s++){let r=s==t.viewports.length?null:t.viewports[s],o=r?r.from-1:this.length;if(o>i){let l=t.lineBlockAt(o).bottom-t.lineBlockAt(i).top;e.push(ut.replace({widget:new J0(l),block:!0,inclusive:!0,isBlockGap:!0}).range(i,o))}if(!r)break;i=r.to+1}return ut.set(e)}updateDeco(){let e=this.view.state.facet(ta).map((t,i)=>(this.dynamicDecorationMap[i]=typeof t=="function")?t(this.view):t);for(let t=e.length;tt.anchor?-1:1),s;if(!i)return;!t.empty&&(s=this.coordsAt(t.anchor,t.anchor>t.head?-1:1))&&(i={left:Math.min(i.left,s.left),top:Math.min(i.top,s.top),right:Math.max(i.right,s.right),bottom:Math.max(i.bottom,s.bottom)});let r=Tk(this.view),o={left:i.left-r.left,top:i.top-r.top,right:i.right+r.right,bottom:i.bottom+r.bottom};Bx(this.view.scrollDOM,o,t.head-1)return ut.none;if(a-l0)i=i.childNodes[s-1],s=Cr(i);else break}if(t>=0)for(let i=n,s=e;;){if(i.nodeType==3)return i;if(i.nodeType==1&&s=0)i=i.childNodes[s],s=0;else break}return null}function iL(n,e){return n.nodeType!=1?0:(e&&n.childNodes[e-1].contentEditable=="false"?1:0)|(e0;){let u=Ln(s.text,o,!1);if(i(s.text.slice(u,o))!=a)break;o=u}for(;ln?e.left-n:Math.max(0,n-e.right)}function aL(n,e){return e.top>n?e.top-n:Math.max(0,n-e.bottom)}function Gf(n,e){return n.tope.top+1}function Z0(n,e){return en.bottom?{top:n.top,left:n.left,right:n.right,bottom:e}:n}function kd(n,e,t){let i,s,r,o,l=!1,a,u,c,f;for(let p=n.firstChild;p;p=p.nextSibling){let g=Zo(p);for(let m=0;my||o==y&&r>b){i=p,s=_,r=b,o=y;let k=y?t<_.top?-1:1:b?e<_.left?-1:1:0;l=!k||(k>0?m0)}b==0?t>_.bottom&&(!c||c.bottom<_.bottom)?(a=p,c=_):t<_.top&&(!f||f.top>_.top)&&(u=p,f=_):c&&Gf(c,_)?c=Q0(c,_.bottom):f&&Gf(f,_)&&(f=Z0(f,_.top))}}if(c&&c.bottom>=t?(i=a,s=c):f&&f.top<=t&&(i=u,s=f),!i)return{node:n,offset:0};let h=Math.max(s.left,Math.min(s.right,e));if(i.nodeType==3)return e_(i,h,t);if(l&&i.contentEditable!="false")return kd(i,h,t);let d=Array.prototype.indexOf.call(n.childNodes,i)+(e>=(s.left+s.right)/2?1:0);return{node:n,offset:d}}function e_(n,e,t){let i=n.nodeValue.length,s=-1,r=1e9,o=0;for(let l=0;lt?c.top-t:t-c.bottom)-1;if(c.left-1<=e&&c.right+1>=e&&f=(c.left+c.right)/2,d=h;if((Pe.chrome||Pe.gecko)&&Qo(n,l).getBoundingClientRect().left==c.right&&(d=!h),f<=0)return{node:n,offset:l+(d?1:0)};s=l+(d?1:0),r=f}}}return{node:n,offset:s>-1?s:o>0?n.nodeValue.length:0}}function Dk(n,e,t,i=-1){var s,r;let o=n.contentDOM.getBoundingClientRect(),l=o.top+n.viewState.paddingTop,a,{docHeight:u}=n.viewState,{x:c,y:f}=e,h=f-l;if(h<0)return 0;if(h>u)return n.state.doc.length;for(let k=n.defaultLineHeight/2,T=!1;a=n.elementAtHeight(h),a.type!=Yt.Text;)for(;h=i>0?a.bottom+k:a.top-k,!(h>=0&&h<=u);){if(T)return t?null:0;T=!0,i=-i}f=l+h;let d=a.from;if(dn.viewport.to)return n.viewport.to==n.state.doc.length?n.state.doc.length:t?null:t_(n,o,a,c,f);let p=n.dom.ownerDocument,g=n.root.elementFromPoint?n.root:p,m=g.elementFromPoint(c,f);m&&!n.contentDOM.contains(m)&&(m=null),m||(c=Math.max(o.left+1,Math.min(o.right-1,c)),m=g.elementFromPoint(c,f),m&&!n.contentDOM.contains(m)&&(m=null));let _,b=-1;if(m&&((s=n.docView.nearest(m))===null||s===void 0?void 0:s.isEditable)!=!1){if(p.caretPositionFromPoint){let k=p.caretPositionFromPoint(c,f);k&&({offsetNode:_,offset:b}=k)}else if(p.caretRangeFromPoint){let k=p.caretRangeFromPoint(c,f);k&&({startContainer:_,startOffset:b}=k,(!n.contentDOM.contains(_)||Pe.safari&&uL(_,b,c)||Pe.chrome&&cL(_,b,c))&&(_=void 0))}}if(!_||!n.docView.dom.contains(_)){let k=mn.find(n.docView,d);if(!k)return h>a.top+a.height/2?a.to:a.from;({node:_,offset:b}=kd(k.dom,c,f))}let y=n.docView.nearest(_);if(!y)return null;if(y.isWidget&&((r=y.dom)===null||r===void 0?void 0:r.nodeType)==1){let k=y.dom.getBoundingClientRect();return e.yn.defaultLineHeight*1.5){let l=Math.floor((s-t.top)/n.defaultLineHeight);r+=l*n.viewState.heightOracle.lineLength}let o=n.state.sliceDoc(t.from,t.to);return t.from+ad(o,r,n.state.tabSize)}function uL(n,e,t){let i;if(n.nodeType!=3||e!=(i=n.nodeValue.length))return!1;for(let s=n.nextSibling;s;s=s.nextSibling)if(s.nodeType!=1||s.nodeName!="BR")return!1;return Qo(n,i-1,i).getBoundingClientRect().left>t}function cL(n,e,t){if(e!=0)return!1;for(let s=n;;){let r=s.parentNode;if(!r||r.nodeType!=1||r.firstChild!=s)return!1;if(r.classList.contains("cm-line"))break;s=r}let i=n.nodeType==1?n.getBoundingClientRect():Qo(n,0,Math.max(n.nodeValue.length,1)).getBoundingClientRect();return t-i.left>5}function Sd(n,e){let t=n.lineBlockAt(e);if(Array.isArray(t.type)){for(let i of t.type)if(i.to>e||i.to==e&&(i.to==t.to||i.type==Yt.Text))return i}return t}function fL(n,e,t,i){let s=Sd(n,e.head),r=!i||s.type!=Yt.Text||!(n.lineWrapping||s.widgetLineBreaks)?null:n.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(r){let o=n.dom.getBoundingClientRect(),l=n.textDirectionAt(s.from),a=n.posAtCoords({x:t==(l==qt.LTR)?o.right-1:o.left+1,y:(r.top+r.bottom)/2});if(a!=null)return de.cursor(a,t?-1:1)}return de.cursor(t?s.to:s.from,t?-1:1)}function i_(n,e,t,i){let s=n.state.doc.lineAt(e.head),r=n.bidiSpans(s),o=n.textDirectionAt(s.from);for(let l=e,a=null;;){let u=Zx(s,r,o,l,t),c=Ek;if(!u){if(s.number==(t?n.state.doc.lines:1))return l;c=` -`,s=n.state.doc.line(s.number+(t?1:-1)),r=n.bidiSpans(s),u=de.cursor(t?s.from:s.to)}if(a){if(!a(c))return l}else{if(!i)return u;a=i(c)}l=u}}function hL(n,e,t){let i=n.state.charCategorizer(e),s=i(t);return r=>{let o=i(r);return s==Gn.Space&&(s=o),s==o}}function dL(n,e,t,i){let s=e.head,r=t?1:-1;if(s==(t?n.state.doc.length:0))return de.cursor(s,e.assoc);let o=e.goalColumn,l,a=n.contentDOM.getBoundingClientRect(),u=n.coordsAtPos(s),c=n.documentTop;if(u)o==null&&(o=u.left-a.left),l=r<0?u.top:u.bottom;else{let d=n.viewState.lineBlockAt(s);o==null&&(o=Math.min(a.right-a.left,n.defaultCharacterWidth*(s-d.from))),l=(r<0?d.top:d.bottom)+c}let f=a.left+o,h=i??n.defaultLineHeight>>1;for(let d=0;;d+=10){let p=l+(h+d)*r,g=Dk(n,{x:f,y:p},!1,r);if(pa.bottom||(r<0?gs))return de.cursor(g,e.assoc,void 0,o)}}function bu(n,e,t){for(;;){let i=0;for(let s of n)s.between(e-1,e+1,(r,o,l)=>{if(e>r&&es(n)),t.from,e.head>t.from?-1:1);return i==t.from?t:de.cursor(i,i{this.ignoreDuringComposition(s)||s.type=="keydown"&&this.keydown(e,s)||(this.mustFlushObserver(s)&&e.observer.forceFlush(),this.runCustomHandlers(s.type,e,s)?s.preventDefault():i(e,s))};for(let i in ui){let s=ui[i];e.contentDOM.addEventListener(i,r=>{n_(e,r)&&t(s,r)},Td[i]),this.registeredEvents.push(i)}e.scrollDOM.addEventListener("mousedown",i=>{if(i.target==e.scrollDOM&&i.clientY>e.contentDOM.getBoundingClientRect().bottom&&(t(ui.mousedown,i),!i.defaultPrevented&&i.button==2)){let s=e.contentDOM.style.minHeight;e.contentDOM.style.minHeight="100%",setTimeout(()=>e.contentDOM.style.minHeight=s,200)}}),e.scrollDOM.addEventListener("drop",i=>{i.target==e.scrollDOM&&i.clientY>e.contentDOM.getBoundingClientRect().bottom&&t(ui.drop,i)}),Pe.chrome&&Pe.chrome_version==102&&e.scrollDOM.addEventListener("wheel",()=>{this.chromeScrollHack<0?e.contentDOM.style.pointerEvents="none":window.clearTimeout(this.chromeScrollHack),this.chromeScrollHack=setTimeout(()=>{this.chromeScrollHack=-1,e.contentDOM.style.pointerEvents=""},100)},{passive:!0}),this.notifiedFocused=e.hasFocus,Pe.safari&&e.contentDOM.addEventListener("input",()=>null)}setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}ensureHandlers(e,t){var i;let s;this.customHandlers=[];for(let r of t)if(s=(i=r.update(e).spec)===null||i===void 0?void 0:i.domEventHandlers){this.customHandlers.push({plugin:r.value,handlers:s});for(let o in s)this.registeredEvents.indexOf(o)<0&&o!="scroll"&&(this.registeredEvents.push(o),e.contentDOM.addEventListener(o,l=>{n_(e,l)&&this.runCustomHandlers(o,e,l)&&l.preventDefault()}))}}runCustomHandlers(e,t,i){for(let s of this.customHandlers){let r=s.handlers[e];if(r)try{if(r.call(s.plugin,i,t)||i.defaultPrevented)return!0}catch(o){Yn(t.state,o)}}return!1}runScrollHandlers(e,t){this.lastScrollTop=e.scrollDOM.scrollTop,this.lastScrollLeft=e.scrollDOM.scrollLeft;for(let i of this.customHandlers){let s=i.handlers.scroll;if(s)try{s.call(i.plugin,t,e)}catch(r){Yn(e.state,r)}}}keydown(e,t){if(this.lastKeyCode=t.keyCode,this.lastKeyTime=Date.now(),t.keyCode==9&&Date.now()s.keyCode==t.keyCode))&&!t.ctrlKey||gL.indexOf(t.key)>-1&&t.ctrlKey&&!t.shiftKey)?(this.pendingIOSKey=i||t,setTimeout(()=>this.flushIOSKey(e),250),!0):!1}flushIOSKey(e){let t=this.pendingIOSKey;return t?(this.pendingIOSKey=void 0,Fo(e.contentDOM,t.key,t.keyCode)):!1}ignoreDuringComposition(e){return/^key/.test(e.type)?this.composing>0?!0:Pe.safari&&!Pe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1:!1}mustFlushObserver(e){return e.type=="keydown"&&e.keyCode!=229}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.mouseSelection&&this.mouseSelection.update(e),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}const xk=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],gL="dthko",Lk=[16,17,18,20,91,92,224,225],Ba=6;function za(n){return Math.max(0,n)*.7+8}class mL{constructor(e,t,i,s){this.view=e,this.style=i,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=t,this.scrollParent=zx(e.contentDOM),this.atoms=e.state.facet(Kp).map(o=>o(e));let r=e.contentDOM.ownerDocument;r.addEventListener("mousemove",this.move=this.move.bind(this)),r.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=t.shiftKey,this.multiple=e.state.facet(pt.allowMultipleSelections)&&_L(e,t),this.dragMove=bL(e,t),this.dragging=yL(e,t)&&Bk(t)==1?null:!1}start(e){this.dragging===!1&&(e.preventDefault(),this.select(e))}move(e){var t;if(e.buttons==0)return this.destroy();if(this.dragging!==!1)return;this.select(this.lastEvent=e);let i=0,s=0,r=((t=this.scrollParent)===null||t===void 0?void 0:t.getBoundingClientRect())||{left:0,top:0,right:this.view.win.innerWidth,bottom:this.view.win.innerHeight},o=Tk(this.view);e.clientX-o.left<=r.left+Ba?i=-za(r.left-e.clientX):e.clientX+o.right>=r.right-Ba&&(i=za(e.clientX-r.right)),e.clientY-o.top<=r.top+Ba?s=-za(r.top-e.clientY):e.clientY+o.bottom>=r.bottom-Ba&&(s=za(e.clientY-r.bottom)),this.setScrollSpeed(i,s)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=null}setScrollSpeed(e,t){this.scrollSpeed={x:e,y:t},e||t?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){this.scrollParent?(this.scrollParent.scrollLeft+=this.scrollSpeed.x,this.scrollParent.scrollTop+=this.scrollSpeed.y):this.view.win.scrollBy(this.scrollSpeed.x,this.scrollSpeed.y),this.dragging===!1&&this.select(this.lastEvent)}skipAtoms(e){let t=null;for(let i=0;ithis.select(this.lastEvent),20)}}function _L(n,e){let t=n.state.facet(pk);return t.length?t[0](e):Pe.mac?e.metaKey:e.ctrlKey}function bL(n,e){let t=n.state.facet(gk);return t.length?t[0](e):Pe.mac?!e.altKey:!e.ctrlKey}function yL(n,e){let{main:t}=n.state.selection;if(t.empty)return!1;let i=ec(n.root);if(!i||i.rangeCount==0)return!0;let s=i.getRangeAt(0).getClientRects();for(let r=0;r=e.clientX&&o.top<=e.clientY&&o.bottom>=e.clientY)return!0}return!1}function n_(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target,i;t!=n.contentDOM;t=t.parentNode)if(!t||t.nodeType==11||(i=Dt.get(t))&&i.ignoreEvent(e))return!1;return!0}const ui=Object.create(null),Td=Object.create(null),Mk=Pe.ie&&Pe.ie_version<15||Pe.ios&&Pe.webkit_version<604;function vL(n){let e=n.dom.parentNode;if(!e)return;let t=e.appendChild(document.createElement("textarea"));t.style.cssText="position: fixed; left: -10000px; top: 10px",t.focus(),setTimeout(()=>{n.focus(),t.remove(),Rk(n,t.value)},50)}function Rk(n,e){let{state:t}=n,i,s=1,r=t.toText(e),o=r.lines==t.selection.ranges.length;if(Cd!=null&&t.selection.ranges.every(a=>a.empty)&&Cd==r.toString()){let a=-1;i=t.changeByRange(u=>{let c=t.doc.lineAt(u.from);if(c.from==a)return{range:u};a=c.from;let f=t.toText((o?r.line(s++).text:e)+t.lineBreak);return{changes:{from:c.from,insert:f},range:de.cursor(u.from+f.length)}})}else o?i=t.changeByRange(a=>{let u=r.line(s++);return{changes:{from:a.from,to:a.to,insert:u.text},range:de.cursor(a.from+u.length)}}):i=t.replaceSelection(r);n.dispatch(i,{userEvent:"input.paste",scrollIntoView:!0})}ui.keydown=(n,e)=>{n.inputState.setSelectionOrigin("select"),e.keyCode==27&&(n.inputState.lastEscPress=Date.now())};ui.touchstart=(n,e)=>{n.inputState.lastTouchTime=Date.now(),n.inputState.setSelectionOrigin("select.pointer")};ui.touchmove=n=>{n.inputState.setSelectionOrigin("select.pointer")};Td.touchstart=Td.touchmove={passive:!0};ui.mousedown=(n,e)=>{if(n.observer.flush(),n.inputState.lastTouchTime>Date.now()-2e3)return;let t=null;for(let i of n.state.facet(mk))if(t=i(n,e),t)break;if(!t&&e.button==0&&(t=SL(n,e)),t){let i=n.root.activeElement!=n.contentDOM;n.inputState.startMouseSelection(new mL(n,e,t,i)),i&&n.observer.ignore(()=>Qw(n.contentDOM)),n.inputState.mouseSelection&&n.inputState.mouseSelection.start(e)}};function s_(n,e,t,i){if(i==1)return de.cursor(e,t);if(i==2)return oL(n.state,e,t);{let s=mn.find(n.docView,e),r=n.state.doc.lineAt(s?s.posAtEnd:e),o=s?s.posAtStart:r.from,l=s?s.posAtEnd:r.to;return ln>=e.top&&n<=e.bottom,r_=(n,e,t)=>Pk(e,t)&&n>=t.left&&n<=t.right;function wL(n,e,t,i){let s=mn.find(n.docView,e);if(!s)return 1;let r=e-s.posAtStart;if(r==0)return 1;if(r==s.length)return-1;let o=s.coordsAt(r,-1);if(o&&r_(t,i,o))return-1;let l=s.coordsAt(r,1);return l&&r_(t,i,l)?1:o&&Pk(i,o)?-1:1}function o_(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1);return{pos:t,bias:wL(n,t,e.clientX,e.clientY)}}const kL=Pe.ie&&Pe.ie_version<=11;let l_=null,a_=0,u_=0;function Bk(n){if(!kL)return n.detail;let e=l_,t=u_;return l_=n,u_=Date.now(),a_=!e||t>Date.now()-400&&Math.abs(e.clientX-n.clientX)<2&&Math.abs(e.clientY-n.clientY)<2?(a_+1)%3:1}function SL(n,e){let t=o_(n,e),i=Bk(e),s=n.state.selection;return{update(r){r.docChanged&&(t.pos=r.changes.mapPos(t.pos),s=s.map(r.changes))},get(r,o,l){let a=o_(n,r),u,c=s_(n,a.pos,a.bias,i);if(t.pos!=a.pos&&!o){let f=s_(n,t.pos,t.bias,i),h=Math.min(f.from,c.from),d=Math.max(f.to,c.to);c=h1&&(u=TL(s,a.pos))?u:l?s.addRange(c):de.create([c])}}}function TL(n,e){for(let t=0;t=e)return de.create(n.ranges.slice(0,t).concat(n.ranges.slice(t+1)),n.mainIndex==t?0:n.mainIndex-(n.mainIndex>t?1:0))}return null}ui.dragstart=(n,e)=>{let{selection:{main:t}}=n.state,{mouseSelection:i}=n.inputState;i&&(i.dragging=t),e.dataTransfer&&(e.dataTransfer.setData("Text",n.state.sliceDoc(t.from,t.to)),e.dataTransfer.effectAllowed="copyMove")};function c_(n,e,t,i){if(!t)return;let s=n.posAtCoords({x:e.clientX,y:e.clientY},!1);e.preventDefault();let{mouseSelection:r}=n.inputState,o=i&&r&&r.dragging&&r.dragMove?{from:r.dragging.from,to:r.dragging.to}:null,l={from:s,insert:t},a=n.state.changes(o?[o,l]:l);n.focus(),n.dispatch({changes:a,selection:{anchor:a.mapPos(s,-1),head:a.mapPos(s,1)},userEvent:o?"move.drop":"input.drop"})}ui.drop=(n,e)=>{if(!e.dataTransfer)return;if(n.state.readOnly)return e.preventDefault();let t=e.dataTransfer.files;if(t&&t.length){e.preventDefault();let i=Array(t.length),s=0,r=()=>{++s==t.length&&c_(n,e,i.filter(o=>o!=null).join(n.state.lineBreak),!1)};for(let o=0;o{/[\x00-\x08\x0e-\x1f]{2}/.test(l.result)||(i[o]=l.result),r()},l.readAsText(t[o])}}else c_(n,e,e.dataTransfer.getData("Text"),!0)};ui.paste=(n,e)=>{if(n.state.readOnly)return e.preventDefault();n.observer.flush();let t=Mk?null:e.clipboardData;t?(Rk(n,t.getData("text/plain")||t.getData("text/uri-text")),e.preventDefault()):vL(n)};function CL(n,e){let t=n.dom.parentNode;if(!t)return;let i=t.appendChild(document.createElement("textarea"));i.style.cssText="position: fixed; left: -10000px; top: 10px",i.value=e,i.focus(),i.selectionEnd=e.length,i.selectionStart=0,setTimeout(()=>{i.remove(),n.focus()},50)}function IL(n){let e=[],t=[],i=!1;for(let s of n.selection.ranges)s.empty||(e.push(n.sliceDoc(s.from,s.to)),t.push(s));if(!e.length){let s=-1;for(let{from:r}of n.selection.ranges){let o=n.doc.lineAt(r);o.number>s&&(e.push(o.text),t.push({from:o.from,to:Math.min(n.doc.length,o.to+1)})),s=o.number}i=!0}return{text:e.join(n.lineBreak),ranges:t,linewise:i}}let Cd=null;ui.copy=ui.cut=(n,e)=>{let{text:t,ranges:i,linewise:s}=IL(n.state);if(!t&&!s)return;Cd=s?t:null;let r=Mk?null:e.clipboardData;r?(e.preventDefault(),r.clearData(),r.setData("text/plain",t)):CL(n,t),e.type=="cut"&&!n.state.readOnly&&n.dispatch({changes:i,scrollIntoView:!0,userEvent:"delete.cut"})};const zk=Ys.define();function Fk(n,e){let t=[];for(let i of n.facet(yk)){let s=i(n,e);s&&t.push(s)}return t?n.update({effects:t,annotations:zk.of(!0)}):null}function Wk(n){setTimeout(()=>{let e=n.hasFocus;if(e!=n.inputState.notifiedFocused){let t=Fk(n.state,e);t?n.dispatch(t):n.update([])}},10)}ui.focus=n=>{n.inputState.lastFocusTime=Date.now(),!n.scrollDOM.scrollTop&&(n.inputState.lastScrollTop||n.inputState.lastScrollLeft)&&(n.scrollDOM.scrollTop=n.inputState.lastScrollTop,n.scrollDOM.scrollLeft=n.inputState.lastScrollLeft),Wk(n)};ui.blur=n=>{n.observer.clearSelectionRange(),Wk(n)};ui.compositionstart=ui.compositionupdate=n=>{n.inputState.compositionFirstChange==null&&(n.inputState.compositionFirstChange=!0),n.inputState.composing<0&&(n.inputState.composing=0)};ui.compositionend=n=>{n.inputState.composing=-1,n.inputState.compositionEndedAt=Date.now(),n.inputState.compositionPendingKey=!0,n.inputState.compositionPendingChange=n.observer.pendingRecords().length>0,n.inputState.compositionFirstChange=null,Pe.chrome&&Pe.android?n.observer.flushSoon():n.inputState.compositionPendingChange?Promise.resolve().then(()=>n.observer.flush()):setTimeout(()=>{n.inputState.composing<0&&n.docView.compositionDeco.size&&n.update([])},50)};ui.contextmenu=n=>{n.inputState.lastContextMenu=Date.now()};ui.beforeinput=(n,e)=>{var t;let i;if(Pe.chrome&&Pe.android&&(i=xk.find(s=>s.inputType==e.inputType))&&(n.observer.delayAndroidKey(i.key,i.keyCode),i.key=="Backspace"||i.key=="Delete")){let s=((t=window.visualViewport)===null||t===void 0?void 0:t.height)||0;setTimeout(()=>{var r;(((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0)>s+10&&n.hasFocus&&(n.contentDOM.blur(),n.focus())},100)}};const f_=["pre-wrap","normal","pre-line","break-spaces"];class EL{constructor(e){this.lineWrapping=e,this.doc=kt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30,this.heightChanged=!1}heightForGap(e,t){let i=this.doc.lineAt(t).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(i+=Math.max(0,Math.ceil((t-e-i*this.lineLength*.5)/this.lineLength))),this.lineHeight*i}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/(this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return f_.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let t=!1;for(let i=0;i-1,a=Math.round(t)!=Math.round(this.lineHeight)||this.lineWrapping!=l;if(this.lineWrapping=l,this.lineHeight=t,this.charWidth=i,this.textHeight=s,this.lineLength=r,a){this.heightSamples={};for(let u=0;u0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e,t){this.height!=t&&(Math.abs(this.height-t)>yu&&(e.heightChanged=!0),this.height=t)}replace(e,t,i){return ln.of(i)}decomposeLeft(e,t){t.push(this)}decomposeRight(e,t){t.push(this)}applyChanges(e,t,i,s){let r=this,o=i.doc;for(let l=s.length-1;l>=0;l--){let{fromA:a,toA:u,fromB:c,toB:f}=s[l],h=r.lineAt(a,Rt.ByPosNoHeight,i.setDoc(t),0,0),d=h.to>=u?h:r.lineAt(u,Rt.ByPosNoHeight,i,0,0);for(f+=d.to-u,u=d.to;l>0&&h.from<=s[l-1].toA;)a=s[l-1].fromA,c=s[l-1].fromB,l--,ar*2){let l=e[t-1];l.break?e.splice(--t,1,l.left,null,l.right):e.splice(--t,1,l.left,l.right),i+=1+l.break,s-=l.size}else if(r>s*2){let l=e[i];l.break?e.splice(i,1,l.left,null,l.right):e.splice(i,1,l.left,l.right),i+=2+l.break,r-=l.size}else break;else if(s=r&&o(this.blockAt(0,i,s,r))}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more&&this.setHeight(e,s.heights[s.index++]),this.outdated=!1,this}toString(){return`block(${this.length})`}}class An extends Vk{constructor(e,t){super(e,t,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0}blockAt(e,t,i,s){return new ys(s,this.length,i,this.height,this.breaks)}replace(e,t,i){let s=i[0];return i.length==1&&(s instanceof An||s instanceof xi&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof xi?s=new An(s.length,this.height):s.height=this.height,this.outdated||(s.outdated=!1),s):ln.of(i)}updateHeight(e,t=0,i=!1,s){return s&&s.from<=t&&s.more?this.setHeight(e,s.heights[s.index++]):(i||this.outdated)&&this.setHeight(e,Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class xi extends ln{constructor(e){super(e,0)}heightMetrics(e,t){let i=e.doc.lineAt(t).number,s=e.doc.lineAt(t+this.length).number,r=s-i+1,o,l=0;if(e.lineWrapping){let a=Math.min(this.height,e.lineHeight*r);o=a/r,this.length>r+1&&(l=(this.height-a)/(this.length-r-1))}else o=this.height/r;return{firstLine:i,lastLine:s,perLine:o,perChar:l}}blockAt(e,t,i,s){let{firstLine:r,lastLine:o,perLine:l,perChar:a}=this.heightMetrics(t,s);if(t.lineWrapping){let u=s+Math.round(Math.max(0,Math.min(1,(e-i)/this.height))*this.length),c=t.doc.lineAt(u),f=l+c.length*a,h=Math.max(i,e-f/2);return new ys(c.from,c.length,h,f,0)}else{let u=Math.max(0,Math.min(o-r,Math.floor((e-i)/l))),{from:c,length:f}=t.doc.line(r+u);return new ys(c,f,i+l*u,l,0)}}lineAt(e,t,i,s,r){if(t==Rt.ByHeight)return this.blockAt(e,i,s,r);if(t==Rt.ByPosNoHeight){let{from:d,to:p}=i.doc.lineAt(e);return new ys(d,p-d,0,0,0)}let{firstLine:o,perLine:l,perChar:a}=this.heightMetrics(i,r),u=i.doc.lineAt(e),c=l+u.length*a,f=u.number-o,h=s+l*f+a*(u.from-r-f);return new ys(u.from,u.length,Math.max(s,Math.min(h,s+this.height-c)),c,0)}forEachLine(e,t,i,s,r,o){e=Math.max(e,r),t=Math.min(t,r+this.length);let{firstLine:l,perLine:a,perChar:u}=this.heightMetrics(i,r);for(let c=e,f=s;c<=t;){let h=i.doc.lineAt(c);if(c==e){let p=h.number-l;f+=a*p+u*(e-r-p)}let d=a+u*h.length;o(new ys(h.from,h.length,f,d,0)),f+=d,c=h.to+1}}replace(e,t,i){let s=this.length-t;if(s>0){let r=i[i.length-1];r instanceof xi?i[i.length-1]=new xi(r.length+s):i.push(null,new xi(s-1))}if(e>0){let r=i[0];r instanceof xi?i[0]=new xi(e+r.length):i.unshift(new xi(e-1),null)}return ln.of(i)}decomposeLeft(e,t){t.push(new xi(e-1),null)}decomposeRight(e,t){t.push(null,new xi(this.length-e-1))}updateHeight(e,t=0,i=!1,s){let r=t+this.length;if(s&&s.from<=t+this.length&&s.more){let o=[],l=Math.max(t,s.from),a=-1;for(s.from>t&&o.push(new xi(s.from-t-1).updateHeight(e,t));l<=r&&s.more;){let c=e.doc.lineAt(l).length;o.length&&o.push(null);let f=s.heights[s.index++];a==-1?a=f:Math.abs(f-a)>=yu&&(a=-2);let h=new An(c,f);h.outdated=!1,o.push(h),l+=c+1}l<=r&&o.push(null,new xi(r-l).updateHeight(e,l));let u=ln.of(o);return(a<0||Math.abs(u.height-this.height)>=yu||Math.abs(a-this.heightMetrics(e,t).perLine)>=yu)&&(e.heightChanged=!0),u}else(i||this.outdated)&&(this.setHeight(e,e.heightForGap(t,t+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class OL extends ln{constructor(e,t,i){super(e.length+t+i.length,e.height+i.height,t|(e.outdated||i.outdated?2:0)),this.left=e,this.right=i,this.size=e.size+i.size}get break(){return this.flags&1}blockAt(e,t,i,s){let r=i+this.left.height;return el))return u;let c=t==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return a?u.join(this.right.lineAt(l,c,i,o,l)):this.left.lineAt(l,c,i,s,r).join(u)}forEachLine(e,t,i,s,r,o){let l=s+this.left.height,a=r+this.left.length+this.break;if(this.break)e=a&&this.right.forEachLine(e,t,i,l,a,o);else{let u=this.lineAt(a,Rt.ByPos,i,s,r);e=e&&u.from<=t&&o(u),t>u.to&&this.right.forEachLine(u.to+1,t,i,l,a,o)}}replace(e,t,i){let s=this.left.length+this.break;if(tthis.left.length)return this.balanced(this.left,this.right.replace(e-s,t-s,i));let r=[];e>0&&this.decomposeLeft(e,r);let o=r.length;for(let l of i)r.push(l);if(e>0&&h_(r,o-1),t=i&&t.push(null)),e>i&&this.right.decomposeLeft(e-i,t)}decomposeRight(e,t){let i=this.left.length,s=i+this.break;if(e>=s)return this.right.decomposeRight(e-s,t);e2*t.size||t.size>2*e.size?ln.of(this.break?[e,null,t]:[e,t]):(this.left=e,this.right=t,this.height=e.height+t.height,this.outdated=e.outdated||t.outdated,this.size=e.size+t.size,this.length=e.length+this.break+t.length,this)}updateHeight(e,t=0,i=!1,s){let{left:r,right:o}=this,l=t+r.length+this.break,a=null;return s&&s.from<=t+r.length&&s.more?a=r=r.updateHeight(e,t,i,s):r.updateHeight(e,t,i),s&&s.from<=l+o.length&&s.more?a=o=o.updateHeight(e,l,i,s):o.updateHeight(e,l,i),a?this.balanced(r,o):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function h_(n,e){let t,i;n[e]==null&&(t=n[e-1])instanceof xi&&(i=n[e+1])instanceof xi&&n.splice(e-1,3,new xi(t.length+1+i.length))}const NL=5;class $p{constructor(e,t){this.pos=e,this.oracle=t,this.nodes=[],this.lineStart=-1,this.lineEnd=-1,this.covering=null,this.writtenTo=e}get isCovered(){return this.covering&&this.nodes[this.nodes.length-1]==this.covering}span(e,t){if(this.lineStart>-1){let i=Math.min(t,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof An?s.length+=i-this.pos:(i>this.pos||!this.isCovered)&&this.nodes.push(new An(i-this.pos,-1)),this.writtenTo=i,t>i&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=t}point(e,t,i){if(e=NL)&&this.addLineDeco(s,r,o)}else t>e&&this.span(e,t);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:t}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=t,this.writtenToe&&this.nodes.push(new An(this.pos-e,-1)),this.writtenTo=this.pos}blankContent(e,t){let i=new xi(t-e);return this.oracle.doc.lineAt(e).to==t&&(i.flags|=4),i}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof An)return e;let t=new An(0,-1);return this.nodes.push(t),t}addBlock(e){var t;this.enterLine();let i=(t=e.deco)===null||t===void 0?void 0:t.type;i==Yt.WidgetAfter&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,i!=Yt.WidgetBefore&&(this.covering=e)}addLineDeco(e,t,i){let s=this.ensureLine();s.length+=i,s.collapsed+=i,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=t,this.writtenTo=this.pos=this.pos+i}finish(e){let t=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(t instanceof An)&&!this.isCovered?this.nodes.push(new An(0,-1)):(this.writtenToc.clientHeight||c.scrollWidth>c.clientWidth)&&f.overflow!="visible"){let h=c.getBoundingClientRect();r=Math.max(r,h.left),o=Math.min(o,h.right),l=Math.max(l,h.top),a=u==n.parentNode?h.bottom:Math.min(a,h.bottom)}u=f.position=="absolute"||f.position=="fixed"?c.offsetParent:c.parentNode}else if(u.nodeType==11)u=u.host;else break;return{left:r-t.left,right:Math.max(r,o)-t.left,top:l-(t.top+e),bottom:Math.max(l,a)-(t.top+e)}}function ML(n,e){let t=n.getBoundingClientRect();return{left:0,right:t.right-t.left,top:e,bottom:t.bottom-(t.top+e)}}class qf{constructor(e,t,i){this.from=e,this.to=t,this.size=i}static same(e,t){if(e.length!=t.length)return!1;for(let i=0;itypeof i!="function"&&i.class=="cm-lineWrapping");this.heightOracle=new EL(t),this.stateDeco=e.facet(ta).filter(i=>typeof i!="function"),this.heightMap=ln.empty().applyChanges(this.stateDeco,kt.empty,this.heightOracle.setDoc(e.doc),[new Cs(0,0,0,e.doc.length)]),this.viewport=this.getViewport(0,null),this.updateViewportLines(),this.updateForViewport(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ut.set(this.lineGaps.map(i=>i.draw(!1))),this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:t}=this.state.selection;for(let i=0;i<=1;i++){let s=i?t.head:t.anchor;if(!e.some(({from:r,to:o})=>s>=r&&s<=o)){let{from:r,to:o}=this.lineBlockAt(s);e.push(new Fa(r,o))}}this.viewports=e.sort((i,s)=>i.from-s.from),this.scaler=this.heightMap.height<=7e6?p_:new zL(this.heightOracle,this.heightMap,this.viewports)}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(this.scaler.scale==1?e:Dl(e,this.scaler))})}update(e,t=null){this.state=e.state;let i=this.stateDeco;this.stateDeco=this.state.facet(ta).filter(c=>typeof c!="function");let s=e.changedRanges,r=Cs.extendWithRanges(s,DL(i,this.stateDeco,e?e.changes:di.empty(this.state.doc.length))),o=this.heightMap.height,l=this.scrolledToBottom?null:this.lineBlockAtHeight(this.scrollTop);this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),r),this.heightMap.height!=o&&(e.flags|=2),l?(this.scrollAnchorPos=e.changes.mapPos(l.from,-1),this.scrollAnchorHeight=l.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=this.heightMap.height);let a=r.length?this.mapViewport(this.viewport,e.changes):this.viewport;(t&&(t.range.heada.to)||!this.viewportIsAppropriate(a))&&(a=this.getViewport(0,t));let u=!e.changes.empty||e.flags&2||a.from!=this.viewport.from||a.to!=this.viewport.to;this.viewport=a,this.updateForViewport(),u&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(this.mapLineGaps(this.lineGaps,e.changes))),e.flags|=this.computeVisibleRanges(),t&&(this.scrollTarget=t),!this.mustEnforceCursorAssoc&&e.selectionSet&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(wk)&&(this.mustEnforceCursorAssoc=!0)}measure(e){let t=e.contentDOM,i=window.getComputedStyle(t),s=this.heightOracle,r=i.whiteSpace;this.defaultTextDirection=i.direction=="rtl"?qt.RTL:qt.LTR;let o=this.heightOracle.mustRefreshForWrapping(r),l=t.getBoundingClientRect(),a=o||this.mustMeasureContent||this.contentDOMHeight!=l.height;this.contentDOMHeight=l.height,this.mustMeasureContent=!1;let u=0,c=0,f=parseInt(i.paddingTop)||0,h=parseInt(i.paddingBottom)||0;(this.paddingTop!=f||this.paddingBottom!=h)&&(this.paddingTop=f,this.paddingBottom=h,u|=10),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(a=!0),this.editorWidth=e.scrollDOM.clientWidth,u|=8),this.scrollTop!=e.scrollDOM.scrollTop&&(this.scrollAnchorHeight=-1,this.scrollTop=e.scrollDOM.scrollTop),this.scrolledToBottom=this.scrollTop>e.scrollDOM.scrollHeight-e.scrollDOM.clientHeight-4;let d=(this.printing?ML:LL)(t,this.paddingTop),p=d.top-this.pixelViewport.top,g=d.bottom-this.pixelViewport.bottom;this.pixelViewport=d;let m=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(m!=this.inView&&(this.inView=m,m&&(a=!0)),!this.inView&&!this.scrollTarget)return 0;let _=l.width;if((this.contentDOMWidth!=_||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=l.width,this.editorHeight=e.scrollDOM.clientHeight,u|=8),a){let y=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(y)&&(o=!0),o||s.lineWrapping&&Math.abs(_-this.contentDOMWidth)>s.charWidth){let{lineHeight:k,charWidth:T,textHeight:I}=e.docView.measureTextSize();o=k>0&&s.refresh(r,k,T,I,_/T,y),o&&(e.docView.minWidth=0,u|=8)}p>0&&g>0?c=Math.max(p,g):p<0&&g<0&&(c=Math.min(p,g)),s.heightChanged=!1;for(let k of this.viewports){let T=k.from==this.viewport.from?y:e.docView.measureVisibleLineHeights(k);this.heightMap=(o?ln.empty().applyChanges(this.stateDeco,kt.empty,this.heightOracle,[new Cs(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,o,new AL(k.from,T))}s.heightChanged&&(u|=2)}let b=!this.viewportIsAppropriate(this.viewport,c)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return b&&(this.viewport=this.getViewport(c,this.scrollTarget)),this.updateForViewport(),(u&2||b)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(o?[]:this.lineGaps,e)),u|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),u}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,t){let i=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,r=this.heightOracle,{visibleTop:o,visibleBottom:l}=this,a=new Fa(s.lineAt(o-i*1e3,Rt.ByHeight,r,0,0).from,s.lineAt(l+(1-i)*1e3,Rt.ByHeight,r,0,0).to);if(t){let{head:u}=t.range;if(ua.to){let c=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),f=s.lineAt(u,Rt.ByPos,r,0,0),h;t.y=="center"?h=(f.top+f.bottom)/2-c/2:t.y=="start"||t.y=="nearest"&&u=l+Math.max(10,Math.min(i,250)))&&s>o-2*1e3&&r>1,o=s<<1;if(this.defaultTextDirection!=qt.LTR&&!i)return[];let l=[],a=(u,c,f,h)=>{if(c-uu&&mm.from>=f.from&&m.to<=f.to&&Math.abs(m.from-u)m.from<_&&m.to>_));if(!g){if(cm.from<=c&&m.to>=c)){let m=t.moveToLineBoundary(de.cursor(c),!1,!0).head;m>u&&(c=m)}g=new qf(u,c,this.gapSize(f,u,c,h))}l.push(g)};for(let u of this.viewportLines){if(u.lengthu.from&&a(u.from,h,u,c),dt.draw(this.heightOracle.lineWrapping))))}computeVisibleRanges(){let e=this.stateDeco;this.lineGaps.length&&(e=e.concat(this.lineGapDeco));let t=[];Tt.spans(e,this.viewport.from,this.viewport.to,{span(s,r){t.push({from:s,to:r})},point(){}},20);let i=t.length!=this.visibleRanges.length||this.visibleRanges.some((s,r)=>s.from!=t[r].from||s.to!=t[r].to);return this.visibleRanges=t,i?4:0}lineBlockAt(e){return e>=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(t=>t.from<=e&&t.to>=e)||Dl(this.heightMap.lineAt(e,Rt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return Dl(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}elementAtHeight(e){return Dl(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class Fa{constructor(e,t){this.from=e,this.to=t}}function PL(n,e,t){let i=[],s=n,r=0;return Tt.spans(t,n,e,{span(){},point(o,l){o>s&&(i.push({from:s,to:o}),r+=o-s),s=l}},20),s=1)return e[e.length-1].to;let i=Math.floor(n*t);for(let s=0;;s++){let{from:r,to:o}=e[s],l=o-r;if(i<=l)return r+i;i-=l}}function Va(n,e){let t=0;for(let{from:i,to:s}of n.ranges){if(e<=s){t+=e-i;break}t+=s-i}return t/n.total}function BL(n,e){for(let t of n)if(e(t))return t}const p_={toDOM(n){return n},fromDOM(n){return n},scale:1};class zL{constructor(e,t,i){let s=0,r=0,o=0;this.viewports=i.map(({from:l,to:a})=>{let u=t.lineAt(l,Rt.ByPos,e,0,0).top,c=t.lineAt(a,Rt.ByPos,e,0,0).bottom;return s+=c-u,{from:l,to:a,top:u,bottom:c,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(t.height-s);for(let l of this.viewports)l.domTop=o+(l.top-r)*this.scale,o=l.domBottom=l.domTop+(l.bottom-l.top),r=l.bottom}toDOM(e){for(let t=0,i=0,s=0;;t++){let r=tDl(s,e)):n._content)}const Ha=We.define({combine:n=>n.join(" ")}),Id=We.define({combine:n=>n.indexOf(!0)>-1}),Ed=Sr.newName(),Hk=Sr.newName(),Uk=Sr.newName(),Gk={"&light":"."+Hk,"&dark":"."+Uk};function Ad(n,e,t){return new Sr(e,{finish(i){return/&/.test(i)?i.replace(/&\w*/,s=>{if(s=="&")return n;if(!t||!t[s])throw new RangeError(`Unsupported selector: ${s}`);return t[s]}):n+" "+i}})}const FL=Ad("."+Ed,{"&":{position:"relative !important",boxSizing:"border-box","&.cm-focused":{outline:"1px dotted #212121"},display:"flex !important",flexDirection:"column"},".cm-scroller":{display:"flex !important",alignItems:"flex-start !important",fontFamily:"monospace",lineHeight:1.4,height:"100%",overflowX:"auto",position:"relative",zIndex:0},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",padding:"4px 0",outline:"none","&[contenteditable=true]":{WebkitUserModify:"read-write-plaintext-only"}},".cm-lineWrapping":{whiteSpace_fallback:"pre-wrap",whiteSpace:"break-spaces",wordBreak:"break-word",overflowWrap:"anywhere",flexShrink:1},"&light .cm-content":{caretColor:"black"},"&dark .cm-content":{caretColor:"white"},".cm-line":{display:"block",padding:"0 2px 0 6px"},".cm-layer":{position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .cm-cursorLayer":{animation:"steps(1) cm-blink 1.2s infinite"},"@keyframes cm-blink":{"0%":{},"50%":{opacity:0},"100%":{}},"@keyframes cm-blink2":{"0%":{},"50%":{opacity:0},"100%":{}},".cm-cursor, .cm-dropCursor":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#444"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",left:0,zIndex:200},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",borderRight:"1px solid #ddd"},"&dark .cm-gutters":{backgroundColor:"#333338",color:"#ccc"},".cm-gutter":{display:"flex !important",flexDirection:"column",flexShrink:0,boxSizing:"border-box",minHeight:"100%",overflow:"hidden"},".cm-gutterElement":{boxSizing:"border-box"},".cm-lineNumbers .cm-gutterElement":{padding:"0 3px 0 5px",minWidth:"20px",textAlign:"right",whiteSpace:"nowrap"},"&light .cm-activeLineGutter":{backgroundColor:"#e2f2ff"},"&dark .cm-activeLineGutter":{backgroundColor:"#222227"},".cm-panels":{boxSizing:"border-box",position:"sticky",left:0,right:0},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top"},".cm-highlightSpace:before":{content:"attr(data-display)",position:"absolute",pointerEvents:"none",color:"#888"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".cm-button":{verticalAlign:"middle",color:"inherit",fontSize:"70%",padding:".2em 1em",borderRadius:"1px"},"&light .cm-button":{backgroundImage:"linear-gradient(#eff1f5, #d9d9df)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#b4b4b4, #d0d3d6)"}},"&dark .cm-button":{backgroundImage:"linear-gradient(#393939, #111)",border:"1px solid #888","&:active":{backgroundImage:"linear-gradient(#111, #333)"}},".cm-textfield":{verticalAlign:"middle",color:"inherit",fontSize:"70%",border:"1px solid silver",padding:".2em .5em"},"&light .cm-textfield":{backgroundColor:"white"},"&dark .cm-textfield":{border:"1px solid #555",backgroundColor:"inherit"}},Gk);class WL{constructor(e,t,i,s){this.typeOver=s,this.bounds=null,this.text="";let{impreciseHead:r,impreciseAnchor:o}=e.docView;if(e.state.readOnly&&t>-1)this.newSel=null;else if(t>-1&&(this.bounds=e.docView.domBoundsAround(t,i,0))){let l=r||o?[]:HL(e),a=new Ak(l,e.state);a.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=a.text,this.newSel=UL(l,this.bounds.from)}else{let l=e.observer.selectionRange,a=r&&r.node==l.focusNode&&r.offset==l.focusOffset||!Jo(e.contentDOM,l.focusNode)?e.state.selection.main.head:e.docView.posFromDOM(l.focusNode,l.focusOffset),u=o&&o.node==l.anchorNode&&o.offset==l.anchorOffset||!Jo(e.contentDOM,l.anchorNode)?e.state.selection.main.anchor:e.docView.posFromDOM(l.anchorNode,l.anchorOffset);this.newSel=de.single(u,a)}}}function jk(n,e){let t,{newSel:i}=e,s=n.state.selection.main,r=n.inputState.lastKeyTime>Date.now()-100?n.inputState.lastKeyCode:-1;if(e.bounds){let{from:o,to:l}=e.bounds,a=s.from,u=null;(r===8||Pe.android&&e.text.length=s.from&&t.to<=s.to&&(t.from!=s.from||t.to!=s.to)&&s.to-s.from-(t.to-t.from)<=4?t={from:s.from,to:s.to,insert:n.state.doc.slice(s.from,t.from).append(t.insert).append(n.state.doc.slice(t.to,s.to))}:(Pe.mac||Pe.android)&&t&&t.from==t.to&&t.from==s.head-1&&/^\. ?$/.test(t.insert.toString())&&n.contentDOM.getAttribute("autocorrect")=="off"?(i&&t.insert.length==2&&(i=de.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:kt.of([" "])}):Pe.chrome&&t&&t.from==t.to&&t.from==s.head&&t.insert.toString()==` - `&&n.lineWrapping&&(i&&(i=de.single(i.main.anchor-1,i.main.head-1)),t={from:s.from,to:s.to,insert:kt.of([" "])}),t){let o=n.state;if(Pe.ios&&n.inputState.flushIOSKey(n)||Pe.android&&(t.from==s.from&&t.to==s.to&&t.insert.length==1&&t.insert.lines==2&&Fo(n.contentDOM,"Enter",13)||(t.from==s.from-1&&t.to==s.to&&t.insert.length==0||r==8&&t.insert.lengthc(n,t.from,t.to,l)))return!0;n.inputState.composing>=0&&n.inputState.composing++;let a;if(t.from>=s.from&&t.to<=s.to&&t.to-t.from>=(s.to-s.from)/3&&(!i||i.main.empty&&i.main.from==t.from+t.insert.length)&&n.inputState.composing<0){let c=s.fromt.to?o.sliceDoc(t.to,s.to):"";a=o.replaceSelection(n.state.toText(c+t.insert.sliceString(0,void 0,n.state.lineBreak)+f))}else{let c=o.changes(t),f=i&&i.main.to<=c.newLength?i.main:void 0;if(o.selection.ranges.length>1&&n.inputState.composing>=0&&t.to<=s.to&&t.to>=s.to-10){let h=n.state.sliceDoc(t.from,t.to),d=Ok(n)||n.state.doc.lineAt(s.head),p=s.to-t.to,g=s.to-s.from;a=o.changeByRange(m=>{if(m.from==s.from&&m.to==s.to)return{changes:c,range:f||m.map(c)};let _=m.to-p,b=_-h.length;if(m.to-m.from!=g||n.state.sliceDoc(b,_)!=h||d&&m.to>=d.from&&m.from<=d.to)return{range:m};let y=o.changes({from:b,to:_,insert:t.insert}),k=m.to-s.to;return{changes:y,range:f?de.range(Math.max(0,f.anchor+k),Math.max(0,f.head+k)):m.map(y)}})}else a={changes:c,selection:f&&o.selection.replaceRange(f)}}let u="input.type";return(n.composing||n.inputState.compositionPendingChange&&n.inputState.compositionEndedAt>Date.now()-50)&&(n.inputState.compositionPendingChange=!1,u+=".compose",n.inputState.compositionFirstChange&&(u+=".start",n.inputState.compositionFirstChange=!1)),n.dispatch(a,{scrollIntoView:!0,userEvent:u}),!0}else if(i&&!i.main.eq(s)){let o=!1,l="select";return n.inputState.lastSelectionTime>Date.now()-50&&(n.inputState.lastSelectionOrigin=="select"&&(o=!0),l=n.inputState.lastSelectionOrigin),n.dispatch({selection:i,scrollIntoView:o,userEvent:l}),!0}else return!1}function VL(n,e,t,i){let s=Math.min(n.length,e.length),r=0;for(;r0&&l>0&&n.charCodeAt(o-1)==e.charCodeAt(l-1);)o--,l--;if(i=="end"){let a=Math.max(0,r-Math.min(o,l));t-=o+a-r}if(o=o?r-t:0;r-=a,l=r+(l-o),o=r}else if(l=l?r-t:0;r-=a,o=r+(o-l),l=r}return{from:r,toA:o,toB:l}}function HL(n){let e=[];if(n.root.activeElement!=n.contentDOM)return e;let{anchorNode:t,anchorOffset:i,focusNode:s,focusOffset:r}=n.observer.selectionRange;return t&&(e.push(new K0(t,i)),(s!=t||r!=i)&&e.push(new K0(s,r))),e}function UL(n,e){if(n.length==0)return null;let t=n[0].pos,i=n.length==2?n[1].pos:t;return t>-1&&i>-1?de.single(t+e,i+e):null}const GL={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},Yf=Pe.ie&&Pe.ie_version<=11;class jL{constructor(e){this.view=e,this.active=!1,this.selectionRange=new Fx,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.resizeContent=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(t=>{for(let i of t)this.queue.push(i);(Pe.ie&&Pe.ie_version<=11||Pe.ios&&e.composing)&&t.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Yf&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var t;((t=this.view.docView)===null||t===void 0?void 0:t.lastUpdate)this.view.requestMeasure()),this.resizeContent.observe(e.contentDOM)),this.addWindowListeners(this.win=e.win),this.start(),typeof IntersectionObserver=="function"&&(this.intersection=new IntersectionObserver(t=>{this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),t.length>0&&t[t.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(t=>{t.length>0&&t[t.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runScrollHandlers(this.view,e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(){this.view.viewState.printing=!0,this.view.measure(),setTimeout(()=>{this.view.viewState.printing=!1,this.view.requestMeasure()},500)}updateGaps(e){if(this.gapIntersection&&(e.length!=this.gaps.length||this.gaps.some((t,i)=>t!=e[i]))){this.gapIntersection.disconnect();for(let t of e)this.gapIntersection.observe(t);this.gaps=e}}onSelectionChange(e){let t=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:i}=this,s=this.selectionRange;if(i.state.facet(hf)?i.root.activeElement!=this.dom:!_u(i.dom,s))return;let r=s.anchorNode&&i.docView.nearest(s.anchorNode);if(r&&r.ignoreEvent(e)){t||(this.selectionChanged=!1);return}(Pe.ie&&Pe.ie_version<=11||Pe.android&&Pe.chrome)&&!i.state.selection.main.empty&&s.focusNode&&tc(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,t=Pe.safari&&e.root.nodeType==11&&Rx(this.dom.ownerDocument)==this.dom&&qL(this.view)||ec(e.root);if(!t||this.selectionRange.eq(t))return!1;let i=_u(this.dom,t);return i&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let r=this.delayedAndroidKey;r&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=r.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&r.force&&Fo(this.dom,r.key,r.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:t,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let t=-1,i=-1,s=!1;for(let r of e){let o=this.readMutation(r);o&&(o.typeOver&&(s=!0),t==-1?{from:t,to:i}=o:(t=Math.min(o.from,t),i=Math.max(o.to,i)))}return{from:t,to:i,typeOver:s}}readChange(){let{from:e,to:t,typeOver:i}=this.processRecords(),s=this.selectionChanged&&_u(this.dom,this.selectionRange);return e<0&&!s?null:(e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1,new WL(this.view,e,t,i))}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let t=this.readChange();if(!t)return!1;let i=this.view.state,s=jk(this.view,t);return this.view.state==i&&this.view.update([]),s}readMutation(e){let t=this.view.docView.nearest(e.target);if(!t||t.ignoreMutation(e))return null;if(t.markDirty(e.type=="attributes"),e.type=="attributes"&&(t.dirty|=4),e.type=="childList"){let i=g_(t,e.previousSibling||e.target.previousSibling,-1),s=g_(t,e.nextSibling||e.target.nextSibling,1);return{from:i?t.posAfter(i):t.posAtStart,to:s?t.posBefore(s):t.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:t.posAtStart,to:t.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}destroy(){var e,t,i,s;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(t=this.gapIntersection)===null||t===void 0||t.disconnect(),(i=this.resizeScroll)===null||i===void 0||i.disconnect(),(s=this.resizeContent)===null||s===void 0||s.disconnect();for(let r of this.scrollTargets)r.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey)}}function g_(n,e,t){for(;e;){let i=Dt.get(e);if(i&&i.parent==n)return i;let s=e.parentNode;e=s!=n.dom?s:t>0?e.nextSibling:e.previousSibling}return null}function qL(n){let e=null;function t(a){a.preventDefault(),a.stopImmediatePropagation(),e=a.getTargetRanges()[0]}if(n.contentDOM.addEventListener("beforeinput",t,!0),n.dom.ownerDocument.execCommand("indent"),n.contentDOM.removeEventListener("beforeinput",t,!0),!e)return null;let i=e.startContainer,s=e.startOffset,r=e.endContainer,o=e.endOffset,l=n.docView.domAtPos(n.state.selection.main.anchor);return tc(l.node,l.offset,r,o)&&([i,s,r,o]=[r,o,i,s]),{anchorNode:i,anchorOffset:s,focusNode:r,focusOffset:o}}class He{constructor(e={}){this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.style.cssText="position: fixed; top: -10000px",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),this._dispatch=e.dispatch||(t=>this.update([t])),this.dispatch=this.dispatch.bind(this),this._root=e.root||Wx(e.parent)||document,this.viewState=new d_(e.state||pt.create(e)),this.plugins=this.state.facet(Ol).map(t=>new Uf(t));for(let t of this.plugins)t.update(this);this.observer=new jL(this),this.inputState=new pL(this),this.inputState.ensureHandlers(this,this.plugins),this.docView=new $0(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),e.parent&&e.parent.appendChild(this.dom)}get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return this.inputState.composing>0}get compositionStarted(){return this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}dispatch(...e){let t=e.length==1&&e[0]instanceof gi?e[0]:this.state.update(...e);this._dispatch(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,i=!1,s,r=this.state;for(let h of e){if(h.startState!=r)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");r=h.state}if(this.destroyed){this.viewState.state=r;return}let o=this.hasFocus,l=0,a=null;e.some(h=>h.annotation(zk))?(this.inputState.notifiedFocused=o,l=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,a=Fk(r,o),a||(l=1));let u=this.observer.delayedAndroidKey,c=null;if(u?(this.observer.clearDelayedAndroidKey(),c=this.observer.readChange(),(c&&!this.state.doc.eq(r.doc)||!this.state.selection.eq(r.selection))&&(c=null)):this.observer.clear(),r.facet(pt.phrases)!=this.state.facet(pt.phrases))return this.setState(r);s=sc.create(this,r,e),s.flags|=l;let f=this.viewState.scrollTarget;try{this.updateState=2;for(let h of e){if(f&&(f=f.map(h.changes)),h.scrollIntoView){let{main:d}=h.state.selection;f=new nc(d.empty?d:de.cursor(d.head,d.head>d.anchor?-1:1))}for(let d of h.effects)d.is(Y0)&&(f=d.value)}this.viewState.update(s,f),this.bidiCache=rc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(Nl)!=this.styleModules&&this.mountStyles(),i=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(h=>h.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Ha)!=s.state.facet(Ha)&&(this.viewState.mustMeasureContent=!0),(t||i||f||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),!s.empty)for(let h of this.state.facet(yd))h(s);(a||c)&&Promise.resolve().then(()=>{a&&this.state==a.startState&&this.dispatch(a),c&&!jk(this,c)&&u.force&&Fo(this.contentDOM,u.key,u.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let i of this.plugins)i.destroy(this);this.viewState=new d_(e),this.plugins=e.facet(Ol).map(i=>new Uf(i)),this.pluginMap.clear();for(let i of this.plugins)i.update(this);this.docView=new $0(this),this.inputState.ensureHandlers(this,this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Ol),i=e.state.facet(Ol);if(t!=i){let s=[];for(let r of i){let o=t.indexOf(r);if(o<0)s.push(new Uf(r));else{let l=this.plugins[o];l.mustUpdate=e,s.push(l)}}for(let r of this.plugins)r.mustUpdate!=e&&r.destroy(this);this.plugins=s,this.pluginMap.clear(),this.inputState.ensureHandlers(this,this.plugins)}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,i=this.scrollDOM,{scrollTop:s}=i,{scrollAnchorPos:r,scrollAnchorHeight:o}=this.viewState;if(this.viewState.scrollAnchorHeight=-1,o<0||s!=this.viewState.scrollTop)if(s>i.scrollHeight-i.clientHeight-4)r=-1,o=this.viewState.heightMap.height;else{let l=this.viewState.lineBlockAtHeight(s);r=l.from,o=l.top}try{for(let l=0;;l++){this.updateState=1;let a=this.viewport,u=this.viewState.measure(this);if(!u&&!this.measureRequests.length&&this.viewState.scrollTarget==null||l>5)break;let c=[];u&4||([this.measureRequests,c]=[c,this.measureRequests]);let f=c.map(g=>{try{return g.read(this)}catch(m){return Yn(this.state,m),m_}}),h=sc.create(this,this.state,[]),d=!1,p=!1;h.flags|=u,t?t.flags|=u:t=h,this.updateState=2,h.empty||(this.updatePlugins(h),this.inputState.update(h),this.updateAttrs(),d=this.docView.update(h));for(let g=0;g-1){let m=(r<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(r).top)-o;(m>1||m<-1)&&(i.scrollTop=s+m,p=!0)}}if(d&&this.docView.updateSelection(!0),this.viewport.from==a.from&&this.viewport.to==a.to&&!p&&this.measureRequests.length==0)break;o=-1}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let l of this.state.facet(yd))l(t)}get themeClasses(){return Ed+" "+(this.state.facet(Id)?Uk:Hk)+" "+this.state.facet(Ha)}updateAttrs(){let e=__(this,kk,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",translate:"no",contenteditable:this.state.facet(hf)?"true":"false",class:"cm-content",style:`${Pe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),__(this,Xp,t);let i=this.observer.ignore(()=>{let s=_d(this.contentDOM,this.contentAttrs,t),r=_d(this.dom,this.editorAttrs,e);return s||r});return this.editorAttrs=e,this.contentAttrs=t,i}showAnnouncements(e){let t=!0;for(let i of e)for(let s of i.effects)if(s.is(He.announce)){t&&(this.announceDOM.textContent=""),t=!1;let r=this.announceDOM.appendChild(document.createElement("div"));r.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Nl),Sr.mount(this.root,this.styleModules.concat(FL).reverse())}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;ti.spec==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,i){return jf(this,e,i_(this,e,t,i))}moveByGroup(e,t){return jf(this,e,i_(this,e,t,i=>hL(this,e.head,i)))}moveToLineBoundary(e,t,i=!0){return fL(this,e,t,i)}moveVertically(e,t,i){return jf(this,e,dL(this,e,t,i))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),Dk(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let i=this.docView.coordsAt(e,t);if(!i||i.left==i.right)return i;let s=this.state.doc.lineAt(e),r=this.bidiSpans(s),o=r[Wo.find(r,e-s.from,-1,t)];return uf(i,o.dir==qt.LTR==t>0)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(vk)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>YL)return Ik(e.length);let t=this.textDirectionAt(e.from);for(let s of this.bidiCache)if(s.from==e.from&&s.dir==t)return s.order;let i=Jx(e.text,t);return this.bidiCache.push(new rc(e.from,e.to,t,i)),i}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Pe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{Qw(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Y0.of(new nc(typeof e=="number"?de.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}static domEventHandlers(e){return Qi.define(()=>({}),{eventHandlers:e})}static theme(e,t){let i=Sr.newName(),s=[Ha.of(i),Nl.of(Ad(`.${i}`,e))];return t&&t.dark&&s.push(Id.of(!0)),s}static baseTheme(e){return da.lowest(Nl.of(Ad("."+Ed,e,Gk)))}static findFromDOM(e){var t;let i=e.querySelector(".cm-content"),s=i&&Dt.get(i)||Dt.get(e);return((t=s==null?void 0:s.rootView)===null||t===void 0?void 0:t.view)||null}}He.styleModule=Nl;He.inputHandler=bk;He.focusChangeEffect=yk;He.perLineTextDirection=vk;He.exceptionSink=_k;He.updateListener=yd;He.editable=hf;He.mouseSelectionStyle=mk;He.dragMovesSelection=gk;He.clickAddsSelectionRange=pk;He.decorations=ta;He.atomicRanges=Kp;He.scrollMargins=Sk;He.darkTheme=Id;He.contentAttributes=Xp;He.editorAttributes=kk;He.lineWrapping=He.contentAttributes.of({class:"cm-lineWrapping"});He.announce=dt.define();const YL=4096,m_={};class rc{constructor(e,t,i,s){this.from=e,this.to=t,this.dir=i,this.order=s}static update(e,t){if(t.empty)return e;let i=[],s=e.length?e[e.length-1].dir:qt.LTR;for(let r=Math.max(0,e.length-10);r=0;s--){let r=i[s],o=typeof r=="function"?r(n):r;o&&md(o,t)}return t}const XL=Pe.mac?"mac":Pe.windows?"win":Pe.linux?"linux":"key";function KL(n,e){const t=n.split(/-(?!$)/);let i=t[t.length-1];i=="Space"&&(i=" ");let s,r,o,l;for(let a=0;ai.concat(s),[]))),t}let rr=null;const ZL=4e3;function QL(n,e=XL){let t=Object.create(null),i=Object.create(null),s=(o,l)=>{let a=i[o];if(a==null)i[o]=l;else if(a!=l)throw new Error("Key binding "+o+" is used both as a regular binding and as a multi-stroke prefix")},r=(o,l,a,u)=>{var c,f;let h=t[o]||(t[o]=Object.create(null)),d=l.split(/ (?!$)/).map(m=>KL(m,e));for(let m=1;m{let y=rr={view:b,prefix:_,scope:o};return setTimeout(()=>{rr==y&&(rr=null)},ZL),!0}]})}let p=d.join(" ");s(p,!1);let g=h[p]||(h[p]={preventDefault:!1,run:((f=(c=h._any)===null||c===void 0?void 0:c.run)===null||f===void 0?void 0:f.slice())||[]});a&&g.run.push(a),u&&(g.preventDefault=!0)};for(let o of n){let l=o.scope?o.scope.split(" "):["editor"];if(o.any)for(let u of l){let c=t[u]||(t[u]=Object.create(null));c._any||(c._any={preventDefault:!1,run:[]});for(let f in c)c[f].run.push(o.any)}let a=o[e]||o.key;if(a)for(let u of l)r(u,a,o.run,o.preventDefault),o.shift&&r(u,"Shift-"+a,o.shift,o.preventDefault)}return t}function e3(n,e,t,i){let s=Mx(e),r=$i(s,0),o=ns(r)==s.length&&s!=" ",l="",a=!1;rr&&rr.view==t&&rr.scope==i&&(l=rr.prefix+" ",(a=Lk.indexOf(e.keyCode)<0)&&(rr=null));let u=new Set,c=p=>{if(p){for(let g of p.run)if(!u.has(g)&&(u.add(g),g(t,e)))return!0;p.preventDefault&&(a=!0)}return!1},f=n[i],h,d;if(f){if(c(f[l+Ua(s,e,!o)]))return!0;if(o&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Pe.windows&&e.ctrlKey&&e.altKey)&&(h=Tr[e.keyCode])&&h!=s){if(c(f[l+Ua(h,e,!0)]))return!0;if(e.shiftKey&&(d=ea[e.keyCode])!=s&&d!=h&&c(f[l+Ua(d,e,!1)]))return!0}else if(o&&e.shiftKey&&c(f[l+Ua(s,e,!0)]))return!0;if(c(f._any))return!0}return a}class ma{constructor(e,t,i,s,r){this.className=e,this.left=t,this.top=i,this.width=s,this.height=r}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,i){if(i.empty){let s=e.coordsAtPos(i.head,i.assoc||1);if(!s)return[];let r=qk(e);return[new ma(t,s.left-r.left,s.top-r.top,null,s.bottom-s.top)]}else return t3(e,t,i)}}function qk(n){let e=n.scrollDOM.getBoundingClientRect();return{left:(n.textDirection==qt.LTR?e.left:e.right-n.scrollDOM.clientWidth)-n.scrollDOM.scrollLeft,top:e.top-n.scrollDOM.scrollTop}}function y_(n,e,t){let i=de.cursor(e);return{from:Math.max(t.from,n.moveToLineBoundary(i,!1,!0).from),to:Math.min(t.to,n.moveToLineBoundary(i,!0,!0).from),type:Yt.Text}}function t3(n,e,t){if(t.to<=n.viewport.from||t.from>=n.viewport.to)return[];let i=Math.max(t.from,n.viewport.from),s=Math.min(t.to,n.viewport.to),r=n.textDirection==qt.LTR,o=n.contentDOM,l=o.getBoundingClientRect(),a=qk(n),u=o.querySelector(".cm-line"),c=u&&window.getComputedStyle(u),f=l.left+(c?parseInt(c.paddingLeft)+Math.min(0,parseInt(c.textIndent)):0),h=l.right-(c?parseInt(c.paddingRight):0),d=Sd(n,i),p=Sd(n,s),g=d.type==Yt.Text?d:null,m=p.type==Yt.Text?p:null;if(g&&(n.lineWrapping||d.widgetLineBreaks)&&(g=y_(n,i,g)),m&&(n.lineWrapping||p.widgetLineBreaks)&&(m=y_(n,s,m)),g&&m&&g.from==m.from)return b(y(t.from,t.to,g));{let T=g?y(t.from,null,g):k(d,!1),I=m?y(null,t.to,m):k(p,!0),x=[];return(g||d).to<(m||p).from-(g&&m?1:0)||d.widgetLineBreaks>1&&T.bottom+n.defaultLineHeight/2M&&V.from=q)break;ce>X&&D(Math.max(J,X),T==null&&J<=M,Math.min(ce,q),I==null&&ce>=L,Q.dir)}if(X=K.to+1,X>=q)break}return O.length==0&&D(M,T==null,L,I==null,n.textDirection),{top:R,bottom:N,horizontal:O}}function k(T,I){let x=l.top+(I?T.top:T.bottom);return{top:x,bottom:x,horizontal:[]}}}function i3(n,e){return n.constructor==e.constructor&&n.eq(e)}class n3{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(vu)!=e.state.facet(vu)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&e.view.requestMeasure(this.measureReq)}setOrder(e){let t=0,i=e.facet(vu);for(;t!i3(t,this.drawn[i]))){let t=this.dom.firstChild,i=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[i].constructor&&s.update(t,this.drawn[i])?(t=t.nextSibling,i++):this.dom.insertBefore(s.draw(),t);for(;t;){let s=t.nextSibling;t.remove(),t=s}this.drawn=e}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const vu=We.define();function Yk(n){return[Qi.define(e=>new n3(e,n)),vu.of(n)]}const Xk=!Pe.ios,ia=We.define({combine(n){return so(n,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function s3(n={}){return[ia.of(n),r3,o3,l3,wk.of(!0)]}function Kk(n){return n.startState.facet(ia)!=n.state.facet(ia)}const r3=Yk({above:!0,markers(n){let{state:e}=n,t=e.facet(ia),i=[];for(let s of e.selection.ranges){let r=s==e.selection.main;if(s.empty?!r||Xk:t.drawRangeCursor){let o=r?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",l=s.empty?s:de.cursor(s.head,s.head>s.anchor?-1:1);for(let a of ma.forRange(n,o,l))i.push(a)}}return i},update(n,e){n.transactions.some(i=>i.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=Kk(n);return t&&v_(n.state,e),n.docChanged||n.selectionSet||t},mount(n,e){v_(e.state,n)},class:"cm-cursorLayer"});function v_(n,e){e.style.animationDuration=n.facet(ia).cursorBlinkRate+"ms"}const o3=Yk({above:!1,markers(n){return n.state.selection.ranges.map(e=>e.empty?[]:ma.forRange(n,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(n,e){return n.docChanged||n.selectionSet||n.viewportChanged||Kk(n)},class:"cm-selectionLayer"}),$k={".cm-line":{"& ::selection":{backgroundColor:"transparent !important"},"&::selection":{backgroundColor:"transparent !important"}}};Xk&&($k[".cm-line"].caretColor="transparent !important");const l3=da.highest(He.theme($k));function w_(n,e,t,i,s){e.lastIndex=0;for(let r=n.iterRange(t,i),o=t,l;!r.next().done;o+=r.value.length)if(!r.lineBreak)for(;l=e.exec(r.value);)s(o+l.index,l)}function a3(n,e){let t=n.visibleRanges;if(t.length==1&&t[0].from==n.viewport.from&&t[0].to==n.viewport.to)return t;let i=[];for(let{from:s,to:r}of t)s=Math.max(n.state.doc.lineAt(s).from,s-e),r=Math.min(n.state.doc.lineAt(r).to,r+e),i.length&&i[i.length-1].to>=s?i[i.length-1].to=r:i.push({from:s,to:r});return i}class u3{constructor(e){const{regexp:t,decoration:i,decorate:s,boundary:r,maxLength:o=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(l,a,u,c)=>s(c,u,u+l[0].length,l,a);else if(typeof i=="function")this.addMatch=(l,a,u,c)=>{let f=i(l,a,u);f&&c(u,u+l[0].length,f)};else if(i)this.addMatch=(l,a,u,c)=>c(u,u+l[0].length,i);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=r,this.maxLength=o}createDeco(e){let t=new to,i=t.add.bind(t);for(let{from:s,to:r}of a3(e,this.maxLength))w_(e.state.doc,this.regexp,s,r,(o,l)=>this.addMatch(l,e,o,i));return t.finish()}updateDeco(e,t){let i=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((r,o,l,a)=>{a>e.view.viewport.from&&l1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),i,s):t}updateRange(e,t,i,s){for(let r of e.visibleRanges){let o=Math.max(r.from,i),l=Math.min(r.to,s);if(l>o){let a=e.state.doc.lineAt(o),u=a.toa.from;o--)if(this.boundary.test(a.text[o-1-a.from])){c=o;break}for(;lh.push(_.range(g,m));if(a==u)for(this.regexp.lastIndex=c-a.from;(d=this.regexp.exec(a.text))&&d.indexthis.addMatch(m,e,g,p));t=t.update({filterFrom:c,filterTo:f,filter:(g,m)=>gf,add:h})}}return t}}const Od=/x/.unicode!=null?"gu":"g",c3=new RegExp(`[\0-\b ---Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,Od),f3={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let Xf=null;function h3(){var n;if(Xf==null&&typeof document<"u"&&document.body){let e=document.body.style;Xf=((n=e.tabSize)!==null&&n!==void 0?n:e.MozTabSize)!=null}return Xf||!1}const wu=We.define({combine(n){let e=so(n,{render:null,specialChars:c3,addSpecialChars:null});return(e.replaceTabs=!h3())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,Od)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,Od)),e}});function d3(n={}){return[wu.of(n),p3()]}let k_=null;function p3(){return k_||(k_=Qi.fromClass(class{constructor(n){this.view=n,this.decorations=ut.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(n.state.facet(wu)),this.decorations=this.decorator.createDeco(n)}makeDecorator(n){return new u3({regexp:n.specialChars,decoration:(e,t,i)=>{let{doc:s}=t.state,r=$i(e[0],0);if(r==9){let o=s.lineAt(i),l=t.state.tabSize,a=pa(o.text,l,i-o.from);return ut.replace({widget:new b3((l-a%l)*this.view.defaultCharacterWidth)})}return this.decorationCache[r]||(this.decorationCache[r]=ut.replace({widget:new _3(n,r)}))},boundary:n.replaceTabs?void 0:/[^]/})}update(n){let e=n.state.facet(wu);n.startState.facet(wu)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(n.view)):this.decorations=this.decorator.updateDeco(n,this.decorations)}},{decorations:n=>n.decorations}))}const g3="•";function m3(n){return n>=32?g3:n==10?"␤":String.fromCharCode(9216+n)}class _3 extends Xs{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=m3(this.code),i=e.state.phrase("Control character")+" "+(f3[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,i,t);if(s)return s;let r=document.createElement("span");return r.textContent=t,r.title=i,r.setAttribute("aria-label",i),r.className="cm-specialChar",r}ignoreEvent(){return!1}}class b3 extends Xs{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}class y3 extends Xs{constructor(e){super(),this.content=e}toDOM(){let e=document.createElement("span");return e.className="cm-placeholder",e.style.pointerEvents="none",e.appendChild(typeof this.content=="string"?document.createTextNode(this.content):this.content),typeof this.content=="string"?e.setAttribute("aria-label","placeholder "+this.content):e.setAttribute("aria-hidden","true"),e}coordsAt(e){let t=e.firstChild?Zo(e.firstChild):[];if(!t.length)return null;let i=window.getComputedStyle(e.parentNode),s=uf(t[0],i.direction!="rtl"),r=parseInt(i.lineHeight);return s.bottom-s.top>r*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+r}:s}ignoreEvent(){return!1}}function v3(n){return Qi.fromClass(class{constructor(e){this.view=e,this.placeholder=ut.set([ut.widget({widget:new y3(n),side:1}).range(0)])}get decorations(){return this.view.state.doc.length?ut.none:this.placeholder}},{decorations:e=>e.decorations})}const Nd=2e3;function w3(n,e,t){let i=Math.min(e.line,t.line),s=Math.max(e.line,t.line),r=[];if(e.off>Nd||t.off>Nd||e.col<0||t.col<0){let o=Math.min(e.off,t.off),l=Math.max(e.off,t.off);for(let a=i;a<=s;a++){let u=n.doc.line(a);u.length<=l&&r.push(de.range(u.from+o,u.to+l))}}else{let o=Math.min(e.col,t.col),l=Math.max(e.col,t.col);for(let a=i;a<=s;a++){let u=n.doc.line(a),c=ad(u.text,o,n.tabSize,!0);if(c<0)r.push(de.cursor(u.to));else{let f=ad(u.text,l,n.tabSize);r.push(de.range(u.from+c,u.from+f))}}}return r}function k3(n,e){let t=n.coordsAtPos(n.viewport.from);return t?Math.round(Math.abs((t.left-e)/n.defaultCharacterWidth)):-1}function S_(n,e){let t=n.posAtCoords({x:e.clientX,y:e.clientY},!1),i=n.state.doc.lineAt(t),s=t-i.from,r=s>Nd?-1:s==i.length?k3(n,e.clientX):pa(i.text,n.state.tabSize,t-i.from);return{line:i.number,col:r,off:s}}function S3(n,e){let t=S_(n,e),i=n.state.selection;return t?{update(s){if(s.docChanged){let r=s.changes.mapPos(s.startState.doc.line(t.line).from),o=s.state.doc.lineAt(r);t={line:o.number,col:t.col,off:Math.min(t.off,o.length)},i=i.map(s.changes)}},get(s,r,o){let l=S_(n,s);if(!l)return i;let a=w3(n.state,t,l);return a.length?o?de.create(a.concat(i.ranges)):de.create(a):i}}:null}function T3(n){let e=(n==null?void 0:n.eventFilter)||(t=>t.altKey&&t.button==0);return He.mouseSelectionStyle.of((t,i)=>e(i)?S3(t,i):null)}const C3={Alt:[18,n=>!!n.altKey],Control:[17,n=>!!n.ctrlKey],Shift:[16,n=>!!n.shiftKey],Meta:[91,n=>!!n.metaKey]},I3={style:"cursor: crosshair"};function E3(n={}){let[e,t]=C3[n.key||"Alt"],i=Qi.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventHandlers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[i,He.contentAttributes.of(s=>{var r;return!((r=s.plugin(i))===null||r===void 0)&&r.isDown?I3:null})]}const Ga="-10000px";class Jk{constructor(e,t,i){this.facet=t,this.createTooltipView=i,this.input=e.state.facet(t),this.tooltips=this.input.filter(s=>s),this.tooltipViews=this.tooltips.map(i)}update(e){var t;let i=e.state.facet(this.facet),s=i.filter(o=>o);if(i===this.input){for(let o of this.tooltipViews)o.update&&o.update(e);return!1}let r=[];for(let o=0;o{var e,t,i;return{position:Pe.ios?"absolute":((e=n.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=n.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((i=n.find(s=>s.tooltipSpace))===null||i===void 0?void 0:i.tooltipSpace)||A3}}}),T_=new WeakMap,Zk=Qi.fromClass(class{constructor(n){this.view=n,this.inView=!0,this.lastTransaction=0,this.measureTimeout=-1;let e=n.state.facet(Kf);this.position=e.position,this.parent=e.parent,this.classes=n.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.manager=new Jk(n,Zp,t=>this.createTooltip(t)),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),n.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let n of this.manager.tooltipViews)this.intersectionObserver.observe(n.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(n){n.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(n);e&&this.observeIntersection();let t=e||n.geometryChanged,i=n.state.facet(Kf);if(i.position!=this.position){this.position=i.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(i.parent!=this.parent){this.parent&&this.container.remove(),this.parent=i.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(n){let e=n.create(this.view);if(e.dom.classList.add("cm-tooltip"),n.arrow&&!e.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let t=document.createElement("div");t.className="cm-tooltip-arrow",e.dom.appendChild(t)}return e.dom.style.position=this.position,e.dom.style.top=Ga,this.container.appendChild(e.dom),e.mount&&e.mount(this.view),e}destroy(){var n,e;this.view.win.removeEventListener("resize",this.measureSoon);for(let t of this.manager.tooltipViews)t.dom.remove(),(n=t.destroy)===null||n===void 0||n.call(t);(e=this.intersectionObserver)===null||e===void 0||e.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let n=this.view.dom.getBoundingClientRect();return{editor:n,parent:this.parent?this.container.getBoundingClientRect():n,pos:this.manager.tooltips.map((e,t)=>{let i=this.manager.tooltipViews[t];return i.getCoords?i.getCoords(e.pos):this.view.coordsAtPos(e.pos)}),size:this.manager.tooltipViews.map(({dom:e})=>e.getBoundingClientRect()),space:this.view.state.facet(Kf).tooltipSpace(this.view)}}writeMeasure(n){var e;let{editor:t,space:i}=n,s=[];for(let r=0;r=Math.min(t.bottom,i.bottom)||u.rightMath.min(t.right,i.right)+.1){a.style.top=Ga;continue}let f=o.arrow?l.dom.querySelector(".cm-tooltip-arrow"):null,h=f?7:0,d=c.right-c.left,p=(e=T_.get(l))!==null&&e!==void 0?e:c.bottom-c.top,g=l.offset||N3,m=this.view.textDirection==qt.LTR,_=c.width>i.right-i.left?m?i.left:i.right-c.width:m?Math.min(u.left-(f?14:0)+g.x,i.right-d):Math.max(i.left,u.left-d+(f?14:0)-g.x),b=!!o.above;!o.strictSide&&(b?u.top-(c.bottom-c.top)-g.yi.bottom)&&b==i.bottom-u.bottom>u.top-i.top&&(b=!b);let y=(b?u.top-i.top:i.bottom-u.bottom)-h;if(y_&&I.topk&&(k=b?I.top-p-2-h:I.bottom+h+2);this.position=="absolute"?(a.style.top=k-n.parent.top+"px",a.style.left=_-n.parent.left+"px"):(a.style.top=k+"px",a.style.left=_+"px"),f&&(f.style.left=`${u.left+(m?g.x:-g.x)-(_+14-7)}px`),l.overlap!==!0&&s.push({left:_,top:k,right:T,bottom:k+p}),a.classList.toggle("cm-tooltip-above",b),a.classList.toggle("cm-tooltip-below",!b),l.positioned&&l.positioned(n.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let n of this.manager.tooltipViews)n.dom.style.top=Ga}},{eventHandlers:{scroll(){this.maybeMeasure()}}}),O3=He.baseTheme({".cm-tooltip":{zIndex:100,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:`${7*2}px`,position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),N3={x:0,y:0},Zp=We.define({enables:[Zk,O3]}),oc=We.define();class Qp{constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new Jk(e,oc,t=>this.createHostedView(t))}static create(e){return new Qp(e)}createHostedView(e){let t=e.create(this.view);return t.dom.classList.add("cm-tooltip-section"),this.dom.appendChild(t.dom),this.mounted&&t.mount&&t.mount(this.view),t}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}}const D3=Zp.compute([oc],n=>{let e=n.facet(oc).filter(t=>t);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.filter(t=>t.end!=null).map(t=>t.end)),create:Qp.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class x3{constructor(e,t,i,s,r){this.view=e,this.source=t,this.field=i,this.setHover=s,this.hoverTime=r,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active)return;let e=Date.now()-this.lastMove.time;ei.bottom||e.xi.right+this.view.defaultCharacterWidth)return;let s=this.view.bidiSpans(this.view.state.doc.lineAt(t)).find(l=>l.from<=t&&l.to>=t),r=s&&s.dir==qt.RTL?-1:1,o=this.source(this.view,t,e.x{this.pending==l&&(this.pending=null,a&&this.view.dispatch({effects:this.setHover.of(a)}))},a=>Yn(this.view.state,a,"hover tooltip"))}else o&&this.view.dispatch({effects:this.setHover.of(o)})}mousemove(e){var t;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let i=this.active;if(i&&!C_(this.lastMove.target)||this.pending){let{pos:s}=i||this.pending,r=(t=i==null?void 0:i.end)!==null&&t!==void 0?t:s;(s==r?this.view.posAtCoords(this.lastMove)!=s:!L3(this.view,s,r,e.clientX,e.clientY,6))&&(this.view.dispatch({effects:this.setHover.of(null)}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1,this.active&&!C_(e.relatedTarget)&&this.view.dispatch({effects:this.setHover.of(null)})}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}function C_(n){for(let e=n;e;e=e.parentNode)if(e.nodeType==1&&e.classList.contains("cm-tooltip"))return!0;return!1}function L3(n,e,t,i,s,r){let o=document.createRange(),l=n.domAtPos(e),a=n.domAtPos(t);o.setEnd(a.node,a.offset),o.setStart(l.node,l.offset);let u=o.getClientRects();o.detach();for(let c=0;coc.from(s)});return[i,Qi.define(s=>new x3(s,n,i,t,e.hoverTime||300)),D3]}function Qk(n,e){let t=n.plugin(Zk);if(!t)return null;let i=t.manager.tooltips.indexOf(e);return i<0?null:t.manager.tooltipViews[i]}const R3=dt.define(),I_=We.define({combine(n){let e,t;for(let i of n)e=e||i.topContainer,t=t||i.bottomContainer;return{topContainer:e,bottomContainer:t}}});function P3(n,e){let t=n.plugin(e2),i=t?t.specs.indexOf(e):-1;return i>-1?t.panels[i]:null}const e2=Qi.fromClass(class{constructor(n){this.input=n.state.facet(Dd),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(n));let e=n.state.facet(I_);this.top=new ja(n,!0,e.topContainer),this.bottom=new ja(n,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(n){let e=n.state.facet(I_);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new ja(n.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new ja(n.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=n.state.facet(Dd);if(t!=this.input){let i=t.filter(a=>a),s=[],r=[],o=[],l=[];for(let a of i){let u=this.specs.indexOf(a),c;u<0?(c=a(n.view),l.push(c)):(c=this.panels[u],c.update&&c.update(n)),s.push(c),(c.top?r:o).push(c)}this.specs=i,this.panels=s,this.top.sync(r),this.bottom.sync(o);for(let a of l)a.dom.classList.add("cm-panel"),a.mount&&a.mount()}else for(let i of this.panels)i.update&&i.update(n)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:n=>He.scrollMargins.of(e=>{let t=e.plugin(n);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class ja{constructor(e,t,i){this.view=e,this.top=t,this.container=i,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=E_(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=E_(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function E_(n){let e=n.nextSibling;return n.remove(),e}const Dd=We.define({enables:e2});class Er extends eo{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}Er.prototype.elementClass="";Er.prototype.toDOM=void 0;Er.prototype.mapMode=rn.TrackBefore;Er.prototype.startSide=Er.prototype.endSide=-1;Er.prototype.point=!0;const $f=We.define(),B3={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Tt.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},Pl=We.define();function z3(n){return[t2(),Pl.of(Object.assign(Object.assign({},B3),n))]}const xd=We.define({combine:n=>n.some(e=>e)});function t2(n){let e=[F3];return n&&n.fixed===!1&&e.push(xd.of(!0)),e}const F3=Qi.fromClass(class{constructor(n){this.view=n,this.prevViewport=n.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight+"px",this.gutters=n.state.facet(Pl).map(e=>new O_(n,e));for(let e of this.gutters)this.dom.appendChild(e.dom);this.fixed=!n.state.facet(xd),this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),n.scrollDOM.insertBefore(this.dom,n.contentDOM)}update(n){if(this.updateGutters(n)){let e=this.prevViewport,t=n.view.viewport,i=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(i<(t.to-t.from)*.8)}n.geometryChanged&&(this.dom.style.minHeight=this.view.contentHeight+"px"),this.view.state.facet(xd)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":""),this.prevViewport=n.view.viewport}syncGutters(n){let e=this.dom.nextSibling;n&&this.dom.remove();let t=Tt.iter(this.view.state.facet($f),this.view.viewport.from),i=[],s=this.gutters.map(r=>new W3(r,this.view.viewport,-this.view.documentPadding.top));for(let r of this.view.viewportLineBlocks)if(i.length&&(i=[]),Array.isArray(r.type)){let o=!0;for(let l of r.type)if(l.type==Yt.Text&&o){Ld(t,i,l.from);for(let a of s)a.line(this.view,l,i);o=!1}else if(l.widget)for(let a of s)a.widget(this.view,l)}else if(r.type==Yt.Text){Ld(t,i,r.from);for(let o of s)o.line(this.view,r,i)}for(let r of s)r.finish();n&&this.view.scrollDOM.insertBefore(this.dom,e)}updateGutters(n){let e=n.startState.facet(Pl),t=n.state.facet(Pl),i=n.docChanged||n.heightChanged||n.viewportChanged||!Tt.eq(n.startState.facet($f),n.state.facet($f),n.view.viewport.from,n.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(n)&&(i=!0);else{i=!0;let s=[];for(let r of t){let o=e.indexOf(r);o<0?s.push(new O_(this.view,r)):(this.gutters[o].update(n),s.push(this.gutters[o]))}for(let r of this.gutters)r.dom.remove(),s.indexOf(r)<0&&r.destroy();for(let r of s)this.dom.appendChild(r.dom);this.gutters=s}return i}destroy(){for(let n of this.gutters)n.destroy();this.dom.remove()}},{provide:n=>He.scrollMargins.of(e=>{let t=e.plugin(n);return!t||t.gutters.length==0||!t.fixed?null:e.textDirection==qt.LTR?{left:t.dom.offsetWidth}:{right:t.dom.offsetWidth}})});function A_(n){return Array.isArray(n)?n:[n]}function Ld(n,e,t){for(;n.value&&n.from<=t;)n.from==t&&e.push(n.value),n.next()}class W3{constructor(e,t,i){this.gutter=e,this.height=i,this.i=0,this.cursor=Tt.iter(e.markers,t.from)}addElement(e,t,i){let{gutter:s}=this,r=t.top-this.height;if(this.i==s.elements.length){let o=new i2(e,t.height,r,i);s.elements.push(o),s.dom.appendChild(o.dom)}else s.elements[this.i].update(e,t.height,r,i);this.height=t.bottom,this.i++}line(e,t,i){let s=[];Ld(this.cursor,s,t.from),i.length&&(s=s.concat(i));let r=this.gutter.config.lineMarker(e,t,s);r&&s.unshift(r);let o=this.gutter;s.length==0&&!o.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let i=this.gutter.config.widgetMarker(e,t.widget,t);i&&this.addElement(e,t,[i])}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class O_{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let i in t.domEventHandlers)this.dom.addEventListener(i,s=>{let r=s.target,o;if(r!=this.dom&&this.dom.contains(r)){for(;r.parentNode!=this.dom;)r=r.parentNode;let a=r.getBoundingClientRect();o=(a.top+a.bottom)/2}else o=s.clientY;let l=e.lineBlockAtHeight(o-e.documentTop);t.domEventHandlers[i](e,l,s)&&s.preventDefault()});this.markers=A_(t.markers(e)),t.initialSpacer&&(this.spacer=new i2(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=A_(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let i=e.view.viewport;return!Tt.eq(this.markers,t,i.from,i.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class i2{constructor(e,t,i,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,i,s)}update(e,t,i,s){this.height!=t&&(this.dom.style.height=(this.height=t)+"px"),this.above!=i&&(this.dom.style.marginTop=(this.above=i)?i+"px":""),V3(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let i="cm-gutterElement",s=this.dom.firstChild;for(let r=0,o=0;;){let l=o,a=rr(l,a,u)||o(l,a,u):o}return i}})}});class Jf extends Er{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function Zf(n,e){return n.state.facet(Io).formatNumber(e,n.state)}const U3=Pl.compute([Io],n=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(H3)},lineMarker(e,t,i){return i.some(s=>s.toDOM)?null:new Jf(Zf(e,e.state.doc.lineAt(t.from).number))},widgetMarker:()=>null,lineMarkerChange:e=>e.startState.facet(Io)!=e.state.facet(Io),initialSpacer(e){return new Jf(Zf(e,N_(e.state.doc.lines)))},updateSpacer(e,t){let i=Zf(t.view,N_(t.view.state.doc.lines));return i==e.number?e:new Jf(i)},domEventHandlers:n.facet(Io).domEventHandlers}));function G3(n={}){return[Io.of(n),t2(),U3]}function N_(n){let e=9;for(;e{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=wn.match(e)),t=>{let i=e(t);return i===void 0?null:[this,i]}}}rt.closedBy=new rt({deserialize:n=>n.split(" ")});rt.openedBy=new rt({deserialize:n=>n.split(" ")});rt.group=new rt({deserialize:n=>n.split(" ")});rt.contextHash=new rt({perNode:!0});rt.lookAhead=new rt({perNode:!0});rt.mounted=new rt({perNode:!0});const q3=Object.create(null);class wn{constructor(e,t,i,s=0){this.name=e,this.props=t,this.id=i,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):q3,i=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new wn(e.name||"",t,e.id,i);if(e.props){for(let r of e.props)if(Array.isArray(r)||(r=r(s)),r){if(r[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[r[0].id]=r[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(rt.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let i in e)for(let s of i.split(" "))t[s]=e[i];return i=>{for(let s=i.prop(rt.group),r=-1;r<(s?s.length:0);r++){let o=t[r<0?i.name:s[r]];if(o)return o}}}}wn.none=new wn("",Object.create(null),0,8);class eg{constructor(e){this.types=e;for(let t=0;t0;for(let a=this.cursor(o|vi.IncludeAnonymous);;){let u=!1;if(a.from<=r&&a.to>=s&&(!l&&a.type.isAnonymous||t(a)!==!1)){if(a.firstChild())continue;u=!0}for(;u&&i&&(l||!a.type.isAnonymous)&&i(a),!a.nextSibling();){if(!a.parent())return;u=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:ng(wn.none,this.children,this.positions,0,this.children.length,0,this.length,(t,i,s)=>new ci(this.type,t,i,s,this.propValues),e.makeTree||((t,i,s)=>new ci(wn.none,t,i,s)))}static build(e){return X3(e)}}ci.empty=new ci(wn.none,[],[],0);class tg{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new tg(this.buffer,this.index)}}class ro{constructor(e,t,i){this.buffer=e,this.length=t,this.set=i}get type(){return wn.none}toString(){let e=[];for(let t=0;t0));a=o[a+3]);return l}slice(e,t,i){let s=this.buffer,r=new Uint16Array(t-e),o=0;for(let l=e,a=0;l=e&&te;case 1:return t<=e&&i>e;case 2:return i>e;case 4:return!0}}function r2(n,e){let t=n.childBefore(e);for(;t;){let i=t.lastChild;if(!i||i.to!=t.to)break;i.type.isError&&i.from==i.to?(n=t,t=i.prevSibling):t=i}return n}function tl(n,e,t,i){for(var s;n.from==n.to||(t<1?n.from>=e:n.from>e)||(t>-1?n.to<=e:n.to0?l.length:-1;e!=u;e+=t){let c=l[e],f=a[e]+o.from;if(s2(s,i,f,f+c.length)){if(c instanceof ro){if(r&vi.ExcludeBuffers)continue;let h=c.findChild(0,c.buffer.length,t,i-f,s);if(h>-1)return new fr(new Y3(o,c,e,f),null,h)}else if(r&vi.IncludeAnonymous||!c.type.isAnonymous||ig(c)){let h;if(!(r&vi.IgnoreMounts)&&c.props&&(h=c.prop(rt.mounted))&&!h.overlay)return new Hs(h.tree,f,e,o);let d=new Hs(c,f,e,o);return r&vi.IncludeAnonymous||!d.type.isAnonymous?d:d.nextChild(t<0?c.children.length-1:0,t,i,s)}}}if(r&vi.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+t:e=t<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,t,i=0){let s;if(!(i&vi.IgnoreOverlays)&&(s=this._tree.prop(rt.mounted))&&s.overlay){let r=e-this.from;for(let{from:o,to:l}of s.overlay)if((t>0?o<=r:o=r:l>r))return new Hs(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,i)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}cursor(e=0){return new uc(this,e)}get tree(){return this._tree}toTree(){return this._tree}resolve(e,t=0){return tl(this,e,t,!1)}resolveInner(e,t=0){return tl(this,e,t,!0)}enterUnfinishedNodesBefore(e){return r2(this,e)}getChild(e,t=null,i=null){let s=lc(this,e,t,i);return s.length?s[0]:null}getChildren(e,t=null,i=null){return lc(this,e,t,i)}toString(){return this._tree.toString()}get node(){return this}matchContext(e){return ac(this,e)}}function lc(n,e,t,i){let s=n.cursor(),r=[];if(!s.firstChild())return r;if(t!=null){for(;!s.type.is(t);)if(!s.nextSibling())return r}for(;;){if(i!=null&&s.type.is(i))return r;if(s.type.is(e)&&r.push(s.node),!s.nextSibling())return i==null?r:[]}}function ac(n,e,t=e.length-1){for(let i=n.parent;t>=0;i=i.parent){if(!i)return!1;if(!i.type.isAnonymous){if(e[t]&&e[t]!=i.name)return!1;t--}}return!0}class Y3{constructor(e,t,i,s){this.parent=e,this.buffer=t,this.index=i,this.start=s}}class fr{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,i){this.context=e,this._parent=t,this.index=i,this.type=e.buffer.set.types[e.buffer.buffer[i]]}child(e,t,i){let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,i);return r<0?null:new fr(this.context,this,r)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,t,i=0){if(i&vi.ExcludeBuffers)return null;let{buffer:s}=this.context,r=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return r<0?null:new fr(this.context,this,r)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new fr(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new fr(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}cursor(e=0){return new uc(this,e)}get tree(){return null}toTree(){let e=[],t=[],{buffer:i}=this.context,s=this.index+4,r=i.buffer[this.index+3];if(r>s){let o=i.buffer[this.index+1];e.push(i.slice(s,r,o)),t.push(0)}return new ci(this.type,e,t,this.to-this.from)}resolve(e,t=0){return tl(this,e,t,!1)}resolveInner(e,t=0){return tl(this,e,t,!0)}enterUnfinishedNodesBefore(e){return r2(this,e)}toString(){return this.context.buffer.childString(this.index)}getChild(e,t=null,i=null){let s=lc(this,e,t,i);return s.length?s[0]:null}getChildren(e,t=null,i=null){return lc(this,e,t,i)}get node(){return this}matchContext(e){return ac(this,e)}}class uc{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof Hs)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let i=e._parent;i;i=i._parent)this.stack.unshift(i.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:i,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=i+s.buffer[e+1],this.to=i+s.buffer[e+2],!0}yield(e){return e?e instanceof Hs?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,i){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,i,this.mode));let{buffer:s}=this.buffer,r=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,i);return r<0?!1:(this.stack.push(this.index),this.yieldBuf(r))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,i=this.mode){return this.buffer?i&vi.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,i))}parent(){if(!this.buffer)return this.yieldNode(this.mode&vi.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&vi.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,i=this.stack.length-1;if(e<0){let s=i<0?0:this.stack[i]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(i<0?t.buffer.length:t.buffer[this.stack[i]+3]))return this.yieldBuf(s)}return i<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,i,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let r=t+e,o=e<0?-1:i._tree.children.length;r!=o;r+=e){let l=i._tree.children[r];if(this.mode&vi.IncludeAnonymous||l instanceof ro||!l.type.isAnonymous||ig(l))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let o=e;o;o=o._parent)if(o.index==s){if(s==this.index)return o;t=o,i=r+1;break e}s=this.stack[--r]}for(let s=i;s=0;r--){if(r<0)return ac(this.node,e,s);let o=i[t.buffer[this.stack[r]]];if(!o.isAnonymous){if(e[s]&&e[s]!=o.name)return!1;s--}}return!0}}function ig(n){return n.children.some(e=>e instanceof ro||!e.type.isAnonymous||ig(e))}function X3(n){var e;let{buffer:t,nodeSet:i,maxBufferLength:s=n2,reused:r=[],minRepeatType:o=i.types.length}=n,l=Array.isArray(t)?new tg(t,t.length):t,a=i.types,u=0,c=0;function f(k,T,I,x,R){let{id:N,start:O,end:D,size:M}=l,L=c;for(;M<0;)if(l.next(),M==-1){let Q=r[N];I.push(Q),x.push(O-k);return}else if(M==-3){u=N;return}else if(M==-4){c=N;return}else throw new RangeError(`Unrecognized record size: ${M}`);let V=a[N],X,q,K=O-k;if(D-O<=s&&(q=g(l.pos-T,R))){let Q=new Uint16Array(q.size-q.skip),J=l.pos-q.size,ce=Q.length;for(;l.pos>J;)ce=m(q.start,Q,ce);X=new ro(Q,D-q.start,i),K=q.start-k}else{let Q=l.pos-M;l.next();let J=[],ce=[],pe=N>=o?N:-1,qe=0,Ae=D;for(;l.pos>Q;)pe>=0&&l.id==pe&&l.size>=0?(l.end<=Ae-s&&(d(J,ce,O,qe,l.end,Ae,pe,L),qe=J.length,Ae=l.end),l.next()):f(O,Q,J,ce,pe);if(pe>=0&&qe>0&&qe-1&&qe>0){let ue=h(V);X=ng(V,J,ce,0,J.length,0,D-O,ue,ue)}else X=p(V,J,ce,D-O,L-D)}I.push(X),x.push(K)}function h(k){return(T,I,x)=>{let R=0,N=T.length-1,O,D;if(N>=0&&(O=T[N])instanceof ci){if(!N&&O.type==k&&O.length==x)return O;(D=O.prop(rt.lookAhead))&&(R=I[N]+O.length+D)}return p(k,T,I,x,R)}}function d(k,T,I,x,R,N,O,D){let M=[],L=[];for(;k.length>x;)M.push(k.pop()),L.push(T.pop()+I-R);k.push(p(i.types[O],M,L,N-R,D-N)),T.push(R-I)}function p(k,T,I,x,R=0,N){if(u){let O=[rt.contextHash,u];N=N?[O].concat(N):[O]}if(R>25){let O=[rt.lookAhead,R];N=N?[O].concat(N):[O]}return new ci(k,T,I,x,N)}function g(k,T){let I=l.fork(),x=0,R=0,N=0,O=I.end-s,D={size:0,start:0,skip:0};e:for(let M=I.pos-k;I.pos>M;){let L=I.size;if(I.id==T&&L>=0){D.size=x,D.start=R,D.skip=N,N+=4,x+=4,I.next();continue}let V=I.pos-L;if(L<0||V=o?4:0,q=I.start;for(I.next();I.pos>V;){if(I.size<0)if(I.size==-3)X+=4;else break e;else I.id>=o&&(X+=4);I.next()}R=q,x+=L,N+=X}return(T<0||x==k)&&(D.size=x,D.start=R,D.skip=N),D.size>4?D:void 0}function m(k,T,I){let{id:x,start:R,end:N,size:O}=l;if(l.next(),O>=0&&x4){let M=l.pos-(O-4);for(;l.pos>M;)I=m(k,T,I)}T[--I]=D,T[--I]=N-k,T[--I]=R-k,T[--I]=x}else O==-3?u=x:O==-4&&(c=x);return I}let _=[],b=[];for(;l.pos>0;)f(n.start||0,n.bufferStart||0,_,b,-1);let y=(e=n.length)!==null&&e!==void 0?e:_.length?b[0]+_[0].length:0;return new ci(a[n.topID],_.reverse(),b.reverse(),y)}const x_=new WeakMap;function ku(n,e){if(!n.isAnonymous||e instanceof ro||e.type!=n)return 1;let t=x_.get(e);if(t==null){t=1;for(let i of e.children){if(i.type!=n||!(i instanceof ci)){t=1;break}t+=ku(n,i)}x_.set(e,t)}return t}function ng(n,e,t,i,s,r,o,l,a){let u=0;for(let p=i;p=c)break;I+=x}if(y==k+1){if(I>c){let x=p[k];d(x.children,x.positions,0,x.children.length,g[k]+b);continue}f.push(p[k])}else{let x=g[y-1]+p[y-1].length-T;f.push(ng(n,p,g,k,y,T,x,null,a))}h.push(T+b-r)}}return d(e,t,i,s,0),(l||a)(f,h,o)}class $r{constructor(e,t,i,s,r=!1,o=!1){this.from=e,this.to=t,this.tree=i,this.offset=s,this.open=(r?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],i=!1){let s=[new $r(0,e.length,e,0,!1,i)];for(let r of t)r.to>e.length&&s.push(r);return s}static applyChanges(e,t,i=128){if(!t.length)return e;let s=[],r=1,o=e.length?e[0]:null;for(let l=0,a=0,u=0;;l++){let c=l=i)for(;o&&o.from=h.from||f<=h.to||u){let d=Math.max(h.from,a)-u,p=Math.min(h.to,f)-u;h=d>=p?null:new $r(d,p,h.tree,h.offset+u,l>0,!!c)}if(h&&s.push(h),o.to>f)break;o=rnew Qf(s.from,s.to)):[new Qf(0,0)]:[new Qf(0,e.length)],this.createParse(e,t||[],i)}parse(e,t,i){let s=this.startParse(e,t,i);for(;;){let r=s.advance();if(r)return r}}};class K3{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new rt({perNode:!0});let $3=0;class ms{constructor(e,t,i){this.set=e,this.base=t,this.modified=i,this.id=$3++}static define(e){if(e!=null&&e.base)throw new Error("Can not derive from a modified tag");let t=new ms([],null,[]);if(t.set.push(t),e)for(let i of e.set)t.set.push(i);return t}static defineModifier(){let e=new cc;return t=>t.modified.indexOf(e)>-1?t:cc.get(t.base||t,t.modified.concat(e).sort((i,s)=>i.id-s.id))}}let J3=0;class cc{constructor(){this.instances=[],this.id=J3++}static get(e,t){if(!t.length)return e;let i=t[0].instances.find(l=>l.base==e&&Z3(t,l.modified));if(i)return i;let s=[],r=new ms(s,e,t);for(let l of t)l.instances.push(r);let o=Q3(t);for(let l of e.set)if(!l.modified.length)for(let a of o)s.push(cc.get(l,a));return r}}function Z3(n,e){return n.length==e.length&&n.every((t,i)=>t==e[i])}function Q3(n){let e=[[]];for(let t=0;ti.length-t.length)}function l2(n){let e=Object.create(null);for(let t in n){let i=n[t];Array.isArray(i)||(i=[i]);for(let s of t.split(" "))if(s){let r=[],o=2,l=s;for(let f=0;;){if(l=="..."&&f>0&&f+3==s.length){o=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(l);if(!h)throw new RangeError("Invalid path: "+s);if(r.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),f+=h[0].length,f==s.length)break;let d=s[f++];if(f==s.length&&d=="!"){o=0;break}if(d!="/")throw new RangeError("Invalid path: "+s);l=s.slice(f)}let a=r.length-1,u=r[a];if(!u)throw new RangeError("Invalid path: "+s);let c=new fc(i,o,a>0?r.slice(0,a):null);e[u]=c.sort(e[u])}}return a2.add(e)}const a2=new rt;class fc{constructor(e,t,i,s){this.tags=e,this.mode=t,this.context=i,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let o=s;for(let l of r)for(let a of l.set){let u=t[a.id];if(u){o=o?o+" "+u:u;break}}return o},scope:i}}function eM(n,e){let t=null;for(let i of n){let s=i.style(e);s&&(t=t?t+" "+s:s)}return t}function tM(n,e,t,i=0,s=n.length){let r=new iM(i,Array.isArray(e)?e:[e],t);r.highlightRange(n.cursor(),i,s,"",r.highlighters),r.flush(s)}class iM{constructor(e,t,i){this.at=e,this.highlighters=t,this.span=i,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,i,s,r){let{type:o,from:l,to:a}=e;if(l>=i||a<=t)return;o.isTop&&(r=this.highlighters.filter(d=>!d.scope||d.scope(o)));let u=s,c=nM(e)||fc.empty,f=eM(r,c.tags);if(f&&(u&&(u+=" "),u+=f,c.mode==1&&(s+=(s?" ":"")+f)),this.startSpan(Math.max(t,l),u),c.opaque)return;let h=e.tree&&e.tree.prop(rt.mounted);if(h&&h.overlay){let d=e.node.enter(h.overlay[0].from+l,1),p=this.highlighters.filter(m=>!m.scope||m.scope(h.tree.type)),g=e.firstChild();for(let m=0,_=l;;m++){let b=m=y||!e.nextSibling())););if(!b||y>i)break;_=b.to+l,_>t&&(this.highlightRange(d.cursor(),Math.max(t,b.from+l),Math.min(i,_),"",p),this.startSpan(Math.min(i,_),u))}g&&e.parent()}else if(e.firstChild()){h&&(s="");do if(!(e.to<=t)){if(e.from>=i)break;this.highlightRange(e,t,i,s,r),this.startSpan(Math.min(i,e.to),u)}while(e.nextSibling());e.parent()}}}function nM(n){let e=n.type.prop(a2);for(;e&&e.context&&!n.matchContext(e.context);)e=e.next;return e||null}const Ie=ms.define,Ya=Ie(),er=Ie(),L_=Ie(er),M_=Ie(er),tr=Ie(),Xa=Ie(tr),eh=Ie(tr),ps=Ie(),Mr=Ie(ps),hs=Ie(),ds=Ie(),Md=Ie(),yl=Ie(Md),Ka=Ie(),H={comment:Ya,lineComment:Ie(Ya),blockComment:Ie(Ya),docComment:Ie(Ya),name:er,variableName:Ie(er),typeName:L_,tagName:Ie(L_),propertyName:M_,attributeName:Ie(M_),className:Ie(er),labelName:Ie(er),namespace:Ie(er),macroName:Ie(er),literal:tr,string:Xa,docString:Ie(Xa),character:Ie(Xa),attributeValue:Ie(Xa),number:eh,integer:Ie(eh),float:Ie(eh),bool:Ie(tr),regexp:Ie(tr),escape:Ie(tr),color:Ie(tr),url:Ie(tr),keyword:hs,self:Ie(hs),null:Ie(hs),atom:Ie(hs),unit:Ie(hs),modifier:Ie(hs),operatorKeyword:Ie(hs),controlKeyword:Ie(hs),definitionKeyword:Ie(hs),moduleKeyword:Ie(hs),operator:ds,derefOperator:Ie(ds),arithmeticOperator:Ie(ds),logicOperator:Ie(ds),bitwiseOperator:Ie(ds),compareOperator:Ie(ds),updateOperator:Ie(ds),definitionOperator:Ie(ds),typeOperator:Ie(ds),controlOperator:Ie(ds),punctuation:Md,separator:Ie(Md),bracket:yl,angleBracket:Ie(yl),squareBracket:Ie(yl),paren:Ie(yl),brace:Ie(yl),content:ps,heading:Mr,heading1:Ie(Mr),heading2:Ie(Mr),heading3:Ie(Mr),heading4:Ie(Mr),heading5:Ie(Mr),heading6:Ie(Mr),contentSeparator:Ie(ps),list:Ie(ps),quote:Ie(ps),emphasis:Ie(ps),strong:Ie(ps),link:Ie(ps),monospace:Ie(ps),strikethrough:Ie(ps),inserted:Ie(),deleted:Ie(),changed:Ie(),invalid:Ie(),meta:Ka,documentMeta:Ie(Ka),annotation:Ie(Ka),processingInstruction:Ie(Ka),definition:ms.defineModifier(),constant:ms.defineModifier(),function:ms.defineModifier(),standard:ms.defineModifier(),local:ms.defineModifier(),special:ms.defineModifier()};u2([{tag:H.link,class:"tok-link"},{tag:H.heading,class:"tok-heading"},{tag:H.emphasis,class:"tok-emphasis"},{tag:H.strong,class:"tok-strong"},{tag:H.keyword,class:"tok-keyword"},{tag:H.atom,class:"tok-atom"},{tag:H.bool,class:"tok-bool"},{tag:H.url,class:"tok-url"},{tag:H.labelName,class:"tok-labelName"},{tag:H.inserted,class:"tok-inserted"},{tag:H.deleted,class:"tok-deleted"},{tag:H.literal,class:"tok-literal"},{tag:H.string,class:"tok-string"},{tag:H.number,class:"tok-number"},{tag:[H.regexp,H.escape,H.special(H.string)],class:"tok-string2"},{tag:H.variableName,class:"tok-variableName"},{tag:H.local(H.variableName),class:"tok-variableName tok-local"},{tag:H.definition(H.variableName),class:"tok-variableName tok-definition"},{tag:H.special(H.variableName),class:"tok-variableName2"},{tag:H.definition(H.propertyName),class:"tok-propertyName tok-definition"},{tag:H.typeName,class:"tok-typeName"},{tag:H.namespace,class:"tok-namespace"},{tag:H.className,class:"tok-className"},{tag:H.macroName,class:"tok-macroName"},{tag:H.propertyName,class:"tok-propertyName"},{tag:H.operator,class:"tok-operator"},{tag:H.comment,class:"tok-comment"},{tag:H.meta,class:"tok-meta"},{tag:H.invalid,class:"tok-invalid"},{tag:H.punctuation,class:"tok-punctuation"}]);var th;const Eo=new rt;function sM(n){return We.define({combine:n?e=>e.concat(n):void 0})}const rM=new rt;class os{constructor(e,t,i=[],s=""){this.data=e,this.name=s,pt.prototype.hasOwnProperty("tree")||Object.defineProperty(pt.prototype,"tree",{get(){return Bi(this)}}),this.parser=t,this.extension=[Ar.of(this),pt.languageData.of((r,o,l)=>{let a=R_(r,o,l),u=a.type.prop(Eo);if(!u)return[];let c=r.facet(u),f=a.type.prop(rM);if(f){let h=a.resolve(o-a.from,l);for(let d of f)if(d.test(h,r)){let p=r.facet(d.facet);return d.type=="replace"?p:p.concat(c)}}return c})].concat(i)}isActiveAt(e,t,i=-1){return R_(e,t,i).type.prop(Eo)==this.data}findRegions(e){let t=e.facet(Ar);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let i=[],s=(r,o)=>{if(r.prop(Eo)==this.data){i.push({from:o,to:o+r.length});return}let l=r.prop(rt.mounted);if(l){if(l.tree.prop(Eo)==this.data){if(l.overlay)for(let a of l.overlay)i.push({from:a.from+o,to:a.to+o});else i.push({from:o,to:o+r.length});return}else if(l.overlay){let a=i.length;if(s(l.tree,l.overlay[0].from+o),i.length>a)return}}for(let a=0;ai.isTop?t:void 0)]}),e.name)}configure(e,t){return new hc(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Bi(n){let e=n.field(os.state,!1);return e?e.tree:ci.empty}class oM{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let i=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-i,t-i)}}let vl=null;class dc{constructor(e,t,i=[],s,r,o,l,a){this.parser=e,this.state=t,this.fragments=i,this.tree=s,this.treeLen=r,this.viewport=o,this.skipped=l,this.scheduleOn=a,this.parse=null,this.tempSkipped=[]}static create(e,t,i){return new dc(e,t,[],ci.empty,0,i,[],null)}startParse(){return this.parser.startParse(new oM(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=ci.empty&&this.isDone(t??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var i;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped($r.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=vl;vl=this;try{return e()}finally{vl=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=P_(e,t.from,t.to);return e}changes(e,t){let{fragments:i,tree:s,treeLen:r,viewport:o,skipped:l}=this;if(this.takeTree(),!e.empty){let a=[];if(e.iterChangedRanges((u,c,f,h)=>a.push({fromA:u,toA:c,fromB:f,toB:h})),i=$r.applyChanges(i,a),s=ci.empty,r=0,o={from:e.mapPos(o.from,-1),to:e.mapPos(o.to,1)},this.skipped.length){l=[];for(let u of this.skipped){let c=e.mapPos(u.from,1),f=e.mapPos(u.to,-1);ce.from&&(this.fragments=P_(this.fragments,s,r),this.skipped.splice(i--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends o2{createParse(t,i,s){let r=s[0].from,o=s[s.length-1].to;return{parsedPos:r,advance(){let a=vl;if(a){for(let u of s)a.tempSkipped.push(u);e&&(a.scheduleOn=a.scheduleOn?Promise.all([a.scheduleOn,e]):e)}return this.parsedPos=o,new ci(wn.none,[],[],o-r)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return vl}}function P_(n,e,t){return $r.applyChanges(n,[{fromA:e,toA:t,fromB:e,toB:t}])}class il{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),i=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,i)||t.takeTree(),new il(t)}static init(e){let t=Math.min(3e3,e.doc.length),i=dc.create(e.facet(Ar).parser,e,{from:0,to:t});return i.work(20,t)||i.takeTree(),new il(i)}}os.state=Pn.define({create:il.init,update(n,e){for(let t of e.effects)if(t.is(os.setState))return t.value;return e.startState.facet(Ar)!=e.state.facet(Ar)?il.init(e.state):n.apply(e)}});let c2=n=>{let e=setTimeout(()=>n(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(c2=n=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(n,{timeout:500-100})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const ih=typeof navigator<"u"&&(!((th=navigator.scheduling)===null||th===void 0)&&th.isInputPending)?()=>navigator.scheduling.isInputPending():null,lM=Qi.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(os.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),e.docChanged&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(os.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=c2(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnds+1e3,a=r.context.work(()=>ih&&ih()||Date.now()>o,s+(l?0:1e5));this.chunkBudget-=Date.now()-t,(a||this.chunkBudget<=0)&&(r.context.takeTree(),this.view.dispatch({effects:os.setState.of(new il(r.context))})),this.chunkBudget>0&&!(a&&!l)&&this.scheduleWork(),this.checkAsyncSchedule(r.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>Yn(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),Ar=We.define({combine(n){return n.length?n[0]:null},enables:n=>[os.state,lM,He.contentAttributes.compute([n],e=>{let t=e.facet(n);return t&&t.name?{"data-language":t.name}:{}})]});class aM{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const uM=We.define(),sg=We.define({combine:n=>{if(!n.length)return" ";let e=n[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(n[0]));return e}});function pc(n){let e=n.facet(sg);return e.charCodeAt(0)==9?n.tabSize*e.length:e.length}function na(n,e){let t="",i=n.tabSize,s=n.facet(sg)[0];if(s==" "){for(;e>=i;)t+=" ",e-=i;s=" "}for(let r=0;r=i.from&&s<=i.to?r&&s==e?{text:"",from:e}:(t<0?s-1&&(r+=o-this.countColumn(i,i.search(/\S|$/))),r}countColumn(e,t=e.length){return pa(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:i,from:s}=this.lineAt(e,t),r=this.options.overrideIndentation;if(r){let o=r(s);if(o>-1)return o}return this.countColumn(i,i.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const cM=new rt;function fM(n,e,t){return f2(e.resolveInner(t).enterUnfinishedNodesBefore(t),t,n)}function hM(n){return n.pos==n.options.simulateBreak&&n.options.simulateDoubleBreak}function dM(n){let e=n.type.prop(cM);if(e)return e;let t=n.firstChild,i;if(t&&(i=t.type.prop(rt.closedBy))){let s=n.lastChild,r=s&&i.indexOf(s.name)>-1;return o=>_M(o,!0,1,void 0,r&&!hM(o)?s.from:void 0)}return n.parent==null?pM:null}function f2(n,e,t){for(;n;n=n.parent){let i=dM(n);if(i)return i(og.create(t,e,n))}return null}function pM(){return 0}class og extends df{constructor(e,t,i){super(e.state,e.options),this.base=e,this.pos=t,this.node=i}static create(e,t,i){return new og(e,t,i)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let i=e.resolve(t.from);for(;i.parent&&i.parent.from==i.from;)i=i.parent;if(gM(i,e))break;t=this.state.doc.lineAt(i.from)}return this.lineIndent(t.from)}continue(){let e=this.node.parent;return e?f2(e,this.pos,this.base):0}}function gM(n,e){for(let t=e;t;t=t.parent)if(n==t)return!0;return!1}function mM(n){let e=n.node,t=e.childAfter(e.from),i=e.lastChild;if(!t)return null;let s=n.options.simulateBreak,r=n.state.doc.lineAt(t.from),o=s==null||s<=r.from?r.to:Math.min(r.to,s);for(let l=t.to;;){let a=e.childAfter(l);if(!a||a==i)return null;if(!a.type.isSkipped)return a.from{if(!n.docChanged||!n.isUserEvent("input.type")&&!n.isUserEvent("input.complete"))return n;let e=n.startState.languageDataAt("indentOnInput",n.startState.selection.main.head);if(!e.length)return n;let t=n.newDoc,{head:i}=n.newSelection.main,s=t.lineAt(i);if(i>s.from+bM)return n;let r=t.sliceString(s.from,i);if(!e.some(u=>u.test(r)))return n;let{state:o}=n,l=-1,a=[];for(let{head:u}of o.selection.ranges){let c=o.doc.lineAt(u);if(c.from==l)continue;l=c.from;let f=rg(o,c.from);if(f==null)continue;let h=/^\s*/.exec(c.text)[0],d=na(o,f);h!=d&&a.push({from:c.from,to:c.from+h.length,insert:d})}return a.length?[n,{changes:a,sequential:!0}]:n})}const vM=We.define(),wM=new rt;function kM(n,e,t){let i=Bi(n);if(i.lengtht)continue;if(r&&o.from=e&&a.to>t&&(r=a)}}return r}function SM(n){let e=n.lastChild;return e&&e.to==n.to&&e.type.isError}function gc(n,e,t){for(let i of n.facet(vM)){let s=i(n,e,t);if(s)return s}return kM(n,e,t)}function h2(n,e){let t=e.mapPos(n.from,1),i=e.mapPos(n.to,-1);return t>=i?void 0:{from:t,to:i}}const pf=dt.define({map:h2}),_a=dt.define({map:h2});function d2(n){let e=[];for(let{head:t}of n.state.selection.ranges)e.some(i=>i.from<=t&&i.to>=t)||e.push(n.lineBlockAt(t));return e}const no=Pn.define({create(){return ut.none},update(n,e){n=n.map(e.changes);for(let t of e.effects)t.is(pf)&&!TM(n,t.value.from,t.value.to)?n=n.update({add:[B_.range(t.value.from,t.value.to)]}):t.is(_a)&&(n=n.update({filter:(i,s)=>t.value.from!=i||t.value.to!=s,filterFrom:t.value.from,filterTo:t.value.to}));if(e.selection){let t=!1,{head:i}=e.selection.main;n.between(i,i,(s,r)=>{si&&(t=!0)}),t&&(n=n.update({filterFrom:i,filterTo:i,filter:(s,r)=>r<=i||s>=i}))}return n},provide:n=>He.decorations.from(n),toJSON(n,e){let t=[];return n.between(0,e.doc.length,(i,s)=>{t.push(i,s)}),t},fromJSON(n){if(!Array.isArray(n)||n.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{(!s||s.from>r)&&(s={from:r,to:o})}),s}function TM(n,e,t){let i=!1;return n.between(e,e,(s,r)=>{s==e&&r==t&&(i=!0)}),i}function p2(n,e){return n.field(no,!1)?e:e.concat(dt.appendConfig.of(_2()))}const CM=n=>{for(let e of d2(n)){let t=gc(n.state,e.from,e.to);if(t)return n.dispatch({effects:p2(n.state,[pf.of(t),g2(n,t)])}),!0}return!1},IM=n=>{if(!n.state.field(no,!1))return!1;let e=[];for(let t of d2(n)){let i=mc(n.state,t.from,t.to);i&&e.push(_a.of(i),g2(n,i,!1))}return e.length&&n.dispatch({effects:e}),e.length>0};function g2(n,e,t=!0){let i=n.state.doc.lineAt(e.from).number,s=n.state.doc.lineAt(e.to).number;return He.announce.of(`${n.state.phrase(t?"Folded lines":"Unfolded lines")} ${i} ${n.state.phrase("to")} ${s}.`)}const EM=n=>{let{state:e}=n,t=[];for(let i=0;i{let e=n.state.field(no,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,n.state.doc.length,(i,s)=>{t.push(_a.of({from:i,to:s}))}),n.dispatch({effects:t}),!0},OM=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:CM},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:IM},{key:"Ctrl-Alt-[",run:EM},{key:"Ctrl-Alt-]",run:AM}],NM={placeholderDOM:null,placeholderText:"…"},m2=We.define({combine(n){return so(n,NM)}});function _2(n){let e=[no,LM];return n&&e.push(m2.of(n)),e}const B_=ut.replace({widget:new class extends Xs{toDOM(n){let{state:e}=n,t=e.facet(m2),i=r=>{let o=n.lineBlockAt(n.posAtDOM(r.target)),l=mc(n.state,o.from,o.to);l&&n.dispatch({effects:_a.of(l)}),r.preventDefault()};if(t.placeholderDOM)return t.placeholderDOM(n,i);let s=document.createElement("span");return s.textContent=t.placeholderText,s.setAttribute("aria-label",e.phrase("folded code")),s.title=e.phrase("unfold"),s.className="cm-foldPlaceholder",s.onclick=i,s}}}),DM={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class nh extends Er{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function xM(n={}){let e=Object.assign(Object.assign({},DM),n),t=new nh(e,!0),i=new nh(e,!1),s=Qi.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(Ar)!=o.state.facet(Ar)||o.startState.field(no,!1)!=o.state.field(no,!1)||Bi(o.startState)!=Bi(o.state)||e.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let l=new to;for(let a of o.viewportLineBlocks){let u=mc(o.state,a.from,a.to)?i:gc(o.state,a.from,a.to)?t:null;u&&l.add(a.from,a.from,u)}return l.finish()}}),{domEventHandlers:r}=e;return[s,z3({class:"cm-foldGutter",markers(o){var l;return((l=o.plugin(s))===null||l===void 0?void 0:l.markers)||Tt.empty},initialSpacer(){return new nh(e,!1)},domEventHandlers:Object.assign(Object.assign({},r),{click:(o,l,a)=>{if(r.click&&r.click(o,l,a))return!0;let u=mc(o.state,l.from,l.to);if(u)return o.dispatch({effects:_a.of(u)}),!0;let c=gc(o.state,l.from,l.to);return c?(o.dispatch({effects:pf.of(c)}),!0):!1}})}),_2()]}const LM=He.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class al{constructor(e,t){this.specs=e;let i;function s(l){let a=Sr.newName();return(i||(i=Object.create(null)))["."+a]=l,a}const r=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,o=t.scope;this.scope=o instanceof os?l=>l.prop(Eo)==o.data:o?l=>l==o:void 0,this.style=u2(e.map(l=>({tag:l.tag,class:l.class||s(Object.assign({},l,{tag:null}))})),{all:r}).style,this.module=i?new Sr(i):null,this.themeType=t.themeType}static define(e,t){return new al(e,t||{})}}const Rd=We.define(),b2=We.define({combine(n){return n.length?[n[0]]:null}});function sh(n){let e=n.facet(Rd);return e.length?e:n.facet(b2)}function lg(n,e){let t=[RM],i;return n instanceof al&&(n.module&&t.push(He.styleModule.of(n.module)),i=n.themeType),e!=null&&e.fallback?t.push(b2.of(n)):i?t.push(Rd.computeN([He.darkTheme],s=>s.facet(He.darkTheme)==(i=="dark")?[n]:[])):t.push(Rd.of(n)),t}class MM{constructor(e){this.markCache=Object.create(null),this.tree=Bi(e.state),this.decorations=this.buildDeco(e,sh(e.state))}update(e){let t=Bi(e.state),i=sh(e.state),s=i!=sh(e.startState);t.length{i.add(o,l,this.markCache[a]||(this.markCache[a]=ut.mark({class:a})))},s,r);return i.finish()}}const RM=da.high(Qi.fromClass(MM,{decorations:n=>n.decorations})),PM=al.define([{tag:H.meta,color:"#404740"},{tag:H.link,textDecoration:"underline"},{tag:H.heading,textDecoration:"underline",fontWeight:"bold"},{tag:H.emphasis,fontStyle:"italic"},{tag:H.strong,fontWeight:"bold"},{tag:H.strikethrough,textDecoration:"line-through"},{tag:H.keyword,color:"#708"},{tag:[H.atom,H.bool,H.url,H.contentSeparator,H.labelName],color:"#219"},{tag:[H.literal,H.inserted],color:"#164"},{tag:[H.string,H.deleted],color:"#a11"},{tag:[H.regexp,H.escape,H.special(H.string)],color:"#e40"},{tag:H.definition(H.variableName),color:"#00f"},{tag:H.local(H.variableName),color:"#30a"},{tag:[H.typeName,H.namespace],color:"#085"},{tag:H.className,color:"#167"},{tag:[H.special(H.variableName),H.macroName],color:"#256"},{tag:H.definition(H.propertyName),color:"#00c"},{tag:H.comment,color:"#940"},{tag:H.invalid,color:"#f00"}]),BM=1e4,zM="()[]{}",FM=new rt;function Pd(n,e,t){let i=n.prop(e<0?rt.openedBy:rt.closedBy);if(i)return i;if(n.name.length==1){let s=t.indexOf(n.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function Bd(n){let e=n.type.prop(FM);return e?e(n.node):n}function Ao(n,e,t,i={}){let s=i.maxScanDistance||BM,r=i.brackets||zM,o=Bi(n),l=o.resolveInner(e,t);for(let a=l;a;a=a.parent){let u=Pd(a.type,t,r);if(u&&a.from0?e>=c.from&&ec.from&&e<=c.to))return WM(n,e,t,a,c,u,r)}}return VM(n,e,t,o,l.type,s,r)}function WM(n,e,t,i,s,r,o){let l=i.parent,a={from:s.from,to:s.to},u=0,c=l==null?void 0:l.cursor();if(c&&(t<0?c.childBefore(i.from):c.childAfter(i.to)))do if(t<0?c.to<=i.from:c.from>=i.to){if(u==0&&r.indexOf(c.type.name)>-1&&c.from0)return null;let u={from:t<0?e-1:e,to:t>0?e+1:e},c=n.doc.iterRange(e,t>0?n.doc.length:0),f=0;for(let h=0;!c.next().done&&h<=r;){let d=c.value;t<0&&(h+=d.length);let p=e+h*t;for(let g=t>0?0:d.length-1,m=t>0?d.length:-1;g!=m;g+=t){let _=o.indexOf(d[g]);if(!(_<0||i.resolveInner(p+g,1).type!=s))if(_%2==0==t>0)f++;else{if(f==1)return{start:u,end:{from:p+g,to:p+g+1},matched:_>>1==a>>1};f--}}t>0&&(h+=d.length)}return c.done?{start:u,matched:!1}:null}const HM=Object.create(null),z_=[wn.none],UM=Object.create(null);for(let[n,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])UM[n]=GM(HM,e);function GM(n,e){let t=null;for(let r of e.split(".")){let o=n[r]||H[r];o&&(typeof o=="function"?t&&(t=o(t)):t||(t=o))}if(!t)return 0;let i=e.replace(/ /g,"_"),s=wn.define({id:z_.length,name:i,props:[l2({[i]:t})]});return z_.push(s),s.id}const jM="#2E3235",gs="#DDDDDD",Bl="#B9D2FF",$a="#b0b0b0",qM="#e0e0e0",y2="#808080",rh="#000000",YM="#A54543",v2="#fc6d24",Rr="#fda331",oh="#8abeb7",F_="#b5bd68",wl="#6fb3d2",kl="#cc99cc",XM="#6987AF",W_=v2,V_="#292d30",Ja=Bl+"30",KM=jM,lh=gs,$M="#202325",H_=gs,JM=He.theme({"&":{color:gs,backgroundColor:KM},".cm-content":{caretColor:H_},".cm-cursor, .cm-dropCursor":{borderLeftColor:H_},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:$M},".cm-panels":{backgroundColor:V_,color:$a},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:Bl,outline:`1px solid ${$a}`,color:rh},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:qM,color:rh},".cm-activeLine":{backgroundColor:Ja},".cm-selectionMatch":{backgroundColor:Ja},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${$a}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:Bl,color:rh},".cm-gutters":{borderRight:"1px solid #ffffff10",color:y2,backgroundColor:V_},".cm-activeLineGutter":{backgroundColor:Ja},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:Bl},".cm-tooltip":{border:"none",backgroundColor:lh},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:lh,borderBottomColor:lh},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Ja,color:$a}}},{dark:!0}),ZM=al.define([{tag:H.keyword,color:Rr},{tag:[H.name,H.deleted,H.character,H.propertyName,H.macroName],color:F_},{tag:[H.variableName],color:wl},{tag:[H.function(H.variableName)],color:Rr},{tag:[H.labelName],color:v2},{tag:[H.color,H.constant(H.name),H.standard(H.name)],color:Rr},{tag:[H.definition(H.name),H.separator],color:kl},{tag:[H.brace],color:kl},{tag:[H.annotation],color:W_},{tag:[H.number,H.changed,H.annotation,H.modifier,H.self,H.namespace],color:Rr},{tag:[H.typeName,H.className],color:wl},{tag:[H.operator,H.operatorKeyword],color:kl},{tag:[H.tagName],color:Rr},{tag:[H.squareBracket],color:kl},{tag:[H.angleBracket],color:kl},{tag:[H.attributeName],color:wl},{tag:[H.regexp],color:Rr},{tag:[H.quote],color:gs},{tag:[H.string],color:F_},{tag:H.link,color:XM,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[H.url,H.escape,H.special(H.string)],color:oh},{tag:[H.meta],color:YM},{tag:[H.comment],color:y2,fontStyle:"italic"},{tag:H.monospace,color:gs},{tag:H.strong,fontWeight:"bold",color:Rr},{tag:H.emphasis,fontStyle:"italic",color:wl},{tag:H.strikethrough,textDecoration:"line-through"},{tag:H.heading,fontWeight:"bold",color:gs},{tag:H.special(H.heading1),fontWeight:"bold",color:gs},{tag:H.heading1,fontWeight:"bold",color:gs},{tag:[H.heading2,H.heading3,H.heading4],fontWeight:"bold",color:gs},{tag:[H.heading5,H.heading6],color:gs},{tag:[H.atom,H.bool,H.special(H.variableName)],color:oh},{tag:[H.processingInstruction,H.inserted],color:oh},{tag:[H.contentSeparator],color:wl},{tag:H.invalid,color:Bl,borderBottom:`1px dotted ${W_}`}]),QM=[JM,lg(ZM)],U_="#2e3440",ag="#3b4252",G_="#434c5e",Za="#4c566a",j_="#e5e9f0",zd="#eceff4",ah="#8fbcbb",q_="#88c0d0",e4="#81a1c1",es="#5e81ac",t4="#bf616a",_o="#d08770",uh="#ebcb8b",Y_="#a3be8c",i4="#b48ead",X_="#d30102",ug=zd,ch=ug,n4="#ffffff",fh=ag,s4=ug,K_=ag,r4=He.theme({"&":{color:U_,backgroundColor:n4},".cm-content":{caretColor:K_},".cm-cursor, .cm-dropCursor":{borderLeftColor:K_},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:s4},".cm-panels":{backgroundColor:ug,color:Za},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:`1px solid ${Za}`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:j_},".cm-activeLine":{backgroundColor:ch},".cm-selectionMatch":{backgroundColor:j_},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{outline:`1px solid ${Za}`},"&.cm-focused .cm-matchingBracket":{backgroundColor:zd},".cm-gutters":{backgroundColor:zd,color:U_,border:"none"},".cm-activeLineGutter":{backgroundColor:ch},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:fh},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:fh,borderBottomColor:fh},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:ch,color:Za}}},{dark:!1}),o4=al.define([{tag:H.keyword,color:es},{tag:[H.name,H.deleted,H.character,H.propertyName,H.macroName],color:_o},{tag:[H.variableName],color:_o},{tag:[H.function(H.variableName)],color:es},{tag:[H.labelName],color:e4},{tag:[H.color,H.constant(H.name),H.standard(H.name)],color:es},{tag:[H.definition(H.name),H.separator],color:Y_},{tag:[H.brace],color:ah},{tag:[H.annotation],color:X_},{tag:[H.number,H.changed,H.annotation,H.modifier,H.self,H.namespace],color:q_},{tag:[H.typeName,H.className],color:uh},{tag:[H.operator,H.operatorKeyword],color:Y_},{tag:[H.tagName],color:i4},{tag:[H.squareBracket],color:t4},{tag:[H.angleBracket],color:_o},{tag:[H.attributeName],color:uh},{tag:[H.regexp],color:es},{tag:[H.quote],color:ag},{tag:[H.string],color:_o},{tag:H.link,color:ah,textDecoration:"underline",textUnderlinePosition:"under"},{tag:[H.url,H.escape,H.special(H.string)],color:_o},{tag:[H.meta],color:q_},{tag:[H.comment],color:G_,fontStyle:"italic"},{tag:H.strong,fontWeight:"bold",color:es},{tag:H.emphasis,fontStyle:"italic",color:es},{tag:H.strikethrough,textDecoration:"line-through"},{tag:H.heading,fontWeight:"bold",color:es},{tag:H.special(H.heading1),fontWeight:"bold",color:es},{tag:H.heading1,fontWeight:"bold",color:es},{tag:[H.heading2,H.heading3,H.heading4],fontWeight:"bold",color:es},{tag:[H.heading5,H.heading6],color:es},{tag:[H.atom,H.bool,H.special(H.variableName)],color:_o},{tag:[H.processingInstruction,H.inserted],color:ah},{tag:[H.contentSeparator],color:uh},{tag:H.invalid,color:G_,borderBottom:`1px dotted ${X_}`}]),l4=[r4,lg(o4)],a4=n=>{let{state:e}=n,t=e.doc.lineAt(e.selection.main.from),i=fg(n.state,t.from);return i.line?u4(n):i.block?f4(n):!1};function cg(n,e){return({state:t,dispatch:i})=>{if(t.readOnly)return!1;let s=n(e,t);return s?(i(t.update(s)),!0):!1}}const u4=cg(p4,0),c4=cg(w2,0),f4=cg((n,e)=>w2(n,e,d4(e)),0);function fg(n,e){let t=n.languageDataAt("commentTokens",e);return t.length?t[0]:{}}const Sl=50;function h4(n,{open:e,close:t},i,s){let r=n.sliceDoc(i-Sl,i),o=n.sliceDoc(s,s+Sl),l=/\s*$/.exec(r)[0].length,a=/^\s*/.exec(o)[0].length,u=r.length-l;if(r.slice(u-e.length,u)==e&&o.slice(a,a+t.length)==t)return{open:{pos:i-l,margin:l&&1},close:{pos:s+a,margin:a&&1}};let c,f;s-i<=2*Sl?c=f=n.sliceDoc(i,s):(c=n.sliceDoc(i,i+Sl),f=n.sliceDoc(s-Sl,s));let h=/^\s*/.exec(c)[0].length,d=/\s*$/.exec(f)[0].length,p=f.length-d-t.length;return c.slice(h,h+e.length)==e&&f.slice(p,p+t.length)==t?{open:{pos:i+h+e.length,margin:/\s/.test(c.charAt(h+e.length))?1:0},close:{pos:s-d-t.length,margin:/\s/.test(f.charAt(p-1))?1:0}}:null}function d4(n){let e=[];for(let t of n.selection.ranges){let i=n.doc.lineAt(t.from),s=t.to<=i.to?i:n.doc.lineAt(t.to),r=e.length-1;r>=0&&e[r].to>i.from?e[r].to=s.to:e.push({from:i.from+/^\s*/.exec(i.text)[0].length,to:s.to})}return e}function w2(n,e,t=e.selection.ranges){let i=t.map(r=>fg(e,r.from).block);if(!i.every(r=>r))return null;let s=t.map((r,o)=>h4(e,i[o],r.from,r.to));if(n!=2&&!s.every(r=>r))return{changes:e.changes(t.map((r,o)=>s[o]?[]:[{from:r.from,insert:i[o].open+" "},{from:r.to,insert:" "+i[o].close}]))};if(n!=1&&s.some(r=>r)){let r=[];for(let o=0,l;os&&(r==o||o>f.from)){s=f.from;let h=/^\s*/.exec(f.text)[0].length,d=h==f.length,p=f.text.slice(h,h+u.length)==u?h:-1;hr.comment<0&&(!r.empty||r.single))){let r=[];for(let{line:l,token:a,indent:u,empty:c,single:f}of i)(f||!c)&&r.push({from:l.from+u,insert:a+" "});let o=e.changes(r);return{changes:o,selection:e.selection.map(o,1)}}else if(n!=1&&i.some(r=>r.comment>=0)){let r=[];for(let{line:o,comment:l,token:a}of i)if(l>=0){let u=o.from+l,c=u+a.length;o.text[c-o.from]==" "&&c++,r.push({from:u,to:c})}return{changes:r}}return null}const Fd=Ys.define(),g4=Ys.define(),m4=We.define(),k2=We.define({combine(n){return so(n,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(i,s)=>e(i,s)||t(i,s)})}});function _4(n){let e=0;return n.iterChangedRanges((t,i)=>e=i),e}const S2=Pn.define({create(){return Ss.empty},update(n,e){let t=e.state.facet(k2),i=e.annotation(Fd);if(i){let a=e.docChanged?de.single(_4(e.changes)):void 0,u=_n.fromTransaction(e,a),c=i.side,f=c==0?n.undone:n.done;return u?f=_c(f,f.length,t.minDepth,u):f=I2(f,e.startState.selection),new Ss(c==0?i.rest:f,c==0?f:i.rest)}let s=e.annotation(g4);if((s=="full"||s=="before")&&(n=n.isolate()),e.annotation(gi.addToHistory)===!1)return e.changes.empty?n:n.addMapping(e.changes.desc);let r=_n.fromTransaction(e),o=e.annotation(gi.time),l=e.annotation(gi.userEvent);return r?n=n.addChanges(r,o,l,t,e):e.selection&&(n=n.addSelection(e.startState.selection,o,l,t.newGroupDelay)),(s=="full"||s=="after")&&(n=n.isolate()),n},toJSON(n){return{done:n.done.map(e=>e.toJSON()),undone:n.undone.map(e=>e.toJSON())}},fromJSON(n){return new Ss(n.done.map(_n.fromJSON),n.undone.map(_n.fromJSON))}});function b4(n={}){return[S2,k2.of(n),He.domEventHandlers({beforeinput(e,t){let i=e.inputType=="historyUndo"?T2:e.inputType=="historyRedo"?Wd:null;return i?(e.preventDefault(),i(t)):!1}})]}function gf(n,e){return function({state:t,dispatch:i}){if(!e&&t.readOnly)return!1;let s=t.field(S2,!1);if(!s)return!1;let r=s.pop(n,t,e);return r?(i(r),!0):!1}}const T2=gf(0,!1),Wd=gf(1,!1),y4=gf(0,!0),v4=gf(1,!0);class _n{constructor(e,t,i,s,r){this.changes=e,this.effects=t,this.mapped=i,this.startSelection=s,this.selectionsAfter=r}setSelAfter(e){return new _n(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,i;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(i=this.startSelection)===null||i===void 0?void 0:i.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new _n(e.changes&&di.fromJSON(e.changes),[],e.mapped&&Ts.fromJSON(e.mapped),e.startSelection&&de.fromJSON(e.startSelection),e.selectionsAfter.map(de.fromJSON))}static fromTransaction(e,t){let i=jn;for(let s of e.startState.facet(m4)){let r=s(e);r.length&&(i=i.concat(r))}return!i.length&&e.changes.empty?null:new _n(e.changes.invert(e.startState.doc),i,void 0,t||e.startState.selection,jn)}static selection(e){return new _n(void 0,jn,void 0,void 0,e)}}function _c(n,e,t,i){let s=e+1>t+20?e-t-1:0,r=n.slice(s,e);return r.push(i),r}function w4(n,e){let t=[],i=!1;return n.iterChangedRanges((s,r)=>t.push(s,r)),e.iterChangedRanges((s,r,o,l)=>{for(let a=0;a=u&&o<=c&&(i=!0)}}),i}function k4(n,e){return n.ranges.length==e.ranges.length&&n.ranges.filter((t,i)=>t.empty!=e.ranges[i].empty).length===0}function C2(n,e){return n.length?e.length?n.concat(e):n:e}const jn=[],S4=200;function I2(n,e){if(n.length){let t=n[n.length-1],i=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-S4));return i.length&&i[i.length-1].eq(e)?n:(i.push(e),_c(n,n.length-1,1e9,t.setSelAfter(i)))}else return[_n.selection([e])]}function T4(n){let e=n[n.length-1],t=n.slice();return t[n.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function hh(n,e){if(!n.length)return n;let t=n.length,i=jn;for(;t;){let s=C4(n[t-1],e,i);if(s.changes&&!s.changes.empty||s.effects.length){let r=n.slice(0,t);return r[t-1]=s,r}else e=s.mapped,t--,i=s.selectionsAfter}return i.length?[_n.selection(i)]:jn}function C4(n,e,t){let i=C2(n.selectionsAfter.length?n.selectionsAfter.map(l=>l.map(e)):jn,t);if(!n.changes)return _n.selection(i);let s=n.changes.map(e),r=e.mapDesc(n.changes,!0),o=n.mapped?n.mapped.composeDesc(r):r;return new _n(s,dt.mapEffects(n.effects,e),o,n.startSelection.map(r),i)}const I4=/^(input\.type|delete)($|\.)/;class Ss{constructor(e,t,i=0,s=void 0){this.done=e,this.undone=t,this.prevTime=i,this.prevUserEvent=s}isolate(){return this.prevTime?new Ss(this.done,this.undone):this}addChanges(e,t,i,s,r){let o=this.done,l=o[o.length-1];return l&&l.changes&&!l.changes.empty&&e.changes&&(!i||I4.test(i))&&(!l.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?n.moveByChar(t,e):mf(t,e))}function en(n){return n.textDirectionAt(n.state.selection.main.head)==qt.LTR}const A2=n=>E2(n,!en(n)),O2=n=>E2(n,en(n));function N2(n,e){return cs(n,t=>t.empty?n.moveByGroup(t,e):mf(t,e))}const A4=n=>N2(n,!en(n)),O4=n=>N2(n,en(n));function N4(n,e,t){if(e.type.prop(t))return!0;let i=e.to-e.from;return i&&(i>2||/[^\s,.;:]/.test(n.sliceDoc(e.from,e.to)))||e.firstChild}function _f(n,e,t){let i=Bi(n).resolveInner(e.head),s=t?rt.closedBy:rt.openedBy;for(let a=e.head;;){let u=t?i.childAfter(a):i.childBefore(a);if(!u)break;N4(n,u,s)?i=u:a=t?u.to:u.from}let r=i.type.prop(s),o,l;return r&&(o=t?Ao(n,i.from,1):Ao(n,i.to,-1))&&o.matched?l=t?o.end.to:o.end.from:l=t?i.to:i.from,de.cursor(l,t?-1:1)}const D4=n=>cs(n,e=>_f(n.state,e,!en(n))),x4=n=>cs(n,e=>_f(n.state,e,en(n)));function D2(n,e){return cs(n,t=>{if(!t.empty)return mf(t,e);let i=n.moveVertically(t,e);return i.head!=t.head?i:n.moveToLineBoundary(t,e)})}const x2=n=>D2(n,!1),L2=n=>D2(n,!0);function M2(n){let e=n.scrollDOM.clientHeighto.empty?n.moveVertically(o,e,t.height):mf(o,e));if(s.eq(i.selection))return!1;let r;if(t.selfScroll){let o=n.coordsAtPos(i.selection.main.head),l=n.scrollDOM.getBoundingClientRect(),a=l.top+t.marginTop,u=l.bottom-t.marginBottom;o&&o.top>a&&o.bottomR2(n,!1),Vd=n=>R2(n,!0);function xr(n,e,t){let i=n.lineBlockAt(e.head),s=n.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?i.to:i.from)&&(s=n.moveToLineBoundary(e,t,!1)),!t&&s.head==i.from&&i.length){let r=/^\s*/.exec(n.state.sliceDoc(i.from,Math.min(i.from+100,i.to)))[0].length;r&&e.head!=i.from+r&&(s=de.cursor(i.from+r))}return s}const L4=n=>cs(n,e=>xr(n,e,!0)),M4=n=>cs(n,e=>xr(n,e,!1)),R4=n=>cs(n,e=>xr(n,e,!en(n))),P4=n=>cs(n,e=>xr(n,e,en(n))),B4=n=>cs(n,e=>de.cursor(n.lineBlockAt(e.head).from,1)),z4=n=>cs(n,e=>de.cursor(n.lineBlockAt(e.head).to,-1));function F4(n,e,t){let i=!1,s=ul(n.selection,r=>{let o=Ao(n,r.head,-1)||Ao(n,r.head,1)||r.head>0&&Ao(n,r.head-1,1)||r.headF4(n,e,!1);function Qn(n,e){let t=ul(n.state.selection,i=>{let s=e(i);return de.range(i.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(n.state.selection)?!1:(n.dispatch(Os(n.state,t)),!0)}function P2(n,e){return Qn(n,t=>n.moveByChar(t,e))}const B2=n=>P2(n,!en(n)),z2=n=>P2(n,en(n));function F2(n,e){return Qn(n,t=>n.moveByGroup(t,e))}const V4=n=>F2(n,!en(n)),H4=n=>F2(n,en(n)),U4=n=>Qn(n,e=>_f(n.state,e,!en(n))),G4=n=>Qn(n,e=>_f(n.state,e,en(n)));function W2(n,e){return Qn(n,t=>n.moveVertically(t,e))}const V2=n=>W2(n,!1),H2=n=>W2(n,!0);function U2(n,e){return Qn(n,t=>n.moveVertically(t,e,M2(n).height))}const J_=n=>U2(n,!1),Z_=n=>U2(n,!0),j4=n=>Qn(n,e=>xr(n,e,!0)),q4=n=>Qn(n,e=>xr(n,e,!1)),Y4=n=>Qn(n,e=>xr(n,e,!en(n))),X4=n=>Qn(n,e=>xr(n,e,en(n))),K4=n=>Qn(n,e=>de.cursor(n.lineBlockAt(e.head).from)),$4=n=>Qn(n,e=>de.cursor(n.lineBlockAt(e.head).to)),Q_=({state:n,dispatch:e})=>(e(Os(n,{anchor:0})),!0),e1=({state:n,dispatch:e})=>(e(Os(n,{anchor:n.doc.length})),!0),t1=({state:n,dispatch:e})=>(e(Os(n,{anchor:n.selection.main.anchor,head:0})),!0),i1=({state:n,dispatch:e})=>(e(Os(n,{anchor:n.selection.main.anchor,head:n.doc.length})),!0),J4=({state:n,dispatch:e})=>(e(n.update({selection:{anchor:0,head:n.doc.length},userEvent:"select"})),!0),Z4=({state:n,dispatch:e})=>{let t=yf(n).map(({from:i,to:s})=>de.range(i,Math.min(s+1,n.doc.length)));return e(n.update({selection:de.create(t),userEvent:"select"})),!0},Q4=({state:n,dispatch:e})=>{let t=ul(n.selection,i=>{var s;let r=Bi(n).resolveInner(i.head,1);for(;!(r.from=i.to||r.to>i.to&&r.from<=i.from||!(!((s=r.parent)===null||s===void 0)&&s.parent));)r=r.parent;return de.range(r.to,r.from)});return e(Os(n,t)),!0},eR=({state:n,dispatch:e})=>{let t=n.selection,i=null;return t.ranges.length>1?i=de.create([t.main]):t.main.empty||(i=de.create([de.cursor(t.main.head)])),i?(e(Os(n,i)),!0):!1};function bf(n,e){if(n.state.readOnly)return!1;let t="delete.selection",{state:i}=n,s=i.changeByRange(r=>{let{from:o,to:l}=r;if(o==l){let a=e(o);ao&&(t="delete.forward",a=Qa(n,a,!0)),o=Math.min(o,a),l=Math.max(l,a)}else o=Qa(n,o,!1),l=Qa(n,l,!0);return o==l?{range:r}:{changes:{from:o,to:l},range:de.cursor(o)}});return s.changes.empty?!1:(n.dispatch(i.update(s,{scrollIntoView:!0,userEvent:t,effects:t=="delete.selection"?He.announce.of(i.phrase("Selection deleted")):void 0})),!0)}function Qa(n,e,t){if(n instanceof He)for(let i of n.state.facet(He.atomicRanges).map(s=>s(n)))i.between(e,e,(s,r)=>{se&&(e=t?r:s)});return e}const G2=(n,e)=>bf(n,t=>{let{state:i}=n,s=i.doc.lineAt(t),r,o;if(!e&&t>s.from&&tG2(n,!1),j2=n=>G2(n,!0),q2=(n,e)=>bf(n,t=>{let i=t,{state:s}=n,r=s.doc.lineAt(i),o=s.charCategorizer(i);for(let l=null;;){if(i==(e?r.to:r.from)){i==t&&r.number!=(e?s.doc.lines:1)&&(i+=e?1:-1);break}let a=Ln(r.text,i-r.from,e)+r.from,u=r.text.slice(Math.min(i,a)-r.from,Math.max(i,a)-r.from),c=o(u);if(l!=null&&c!=l)break;(u!=" "||i!=t)&&(l=c),i=a}return i}),Y2=n=>q2(n,!1),tR=n=>q2(n,!0),X2=n=>bf(n,e=>{let t=n.lineBlockAt(e).to;return ebf(n,e=>{let t=n.lineBlockAt(e).from;return e>t?t:Math.max(0,e-1)}),nR=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>({changes:{from:i.from,to:i.to,insert:kt.of(["",""])},range:de.cursor(i.from)}));return e(n.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},sR=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=n.changeByRange(i=>{if(!i.empty||i.from==0||i.from==n.doc.length)return{range:i};let s=i.from,r=n.doc.lineAt(s),o=s==r.from?s-1:Ln(r.text,s-r.from,!1)+r.from,l=s==r.to?s+1:Ln(r.text,s-r.from,!0)+r.from;return{changes:{from:o,to:l,insert:n.doc.slice(s,l).append(n.doc.slice(o,s))},range:de.cursor(l)}});return t.changes.empty?!1:(e(n.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function yf(n){let e=[],t=-1;for(let i of n.selection.ranges){let s=n.doc.lineAt(i.from),r=n.doc.lineAt(i.to);if(!i.empty&&i.to==r.from&&(r=n.doc.lineAt(i.to-1)),t>=s.number){let o=e[e.length-1];o.to=r.to,o.ranges.push(i)}else e.push({from:s.from,to:r.to,ranges:[i]});t=r.number+1}return e}function K2(n,e,t){if(n.readOnly)return!1;let i=[],s=[];for(let r of yf(n)){if(t?r.to==n.doc.length:r.from==0)continue;let o=n.doc.lineAt(t?r.to+1:r.from-1),l=o.length+1;if(t){i.push({from:r.to,to:o.to},{from:r.from,insert:o.text+n.lineBreak});for(let a of r.ranges)s.push(de.range(Math.min(n.doc.length,a.anchor+l),Math.min(n.doc.length,a.head+l)))}else{i.push({from:o.from,to:r.from},{from:r.to,insert:n.lineBreak+o.text});for(let a of r.ranges)s.push(de.range(a.anchor-l,a.head-l))}}return i.length?(e(n.update({changes:i,scrollIntoView:!0,selection:de.create(s,n.selection.mainIndex),userEvent:"move.line"})),!0):!1}const rR=({state:n,dispatch:e})=>K2(n,e,!1),oR=({state:n,dispatch:e})=>K2(n,e,!0);function $2(n,e,t){if(n.readOnly)return!1;let i=[];for(let s of yf(n))t?i.push({from:s.from,insert:n.doc.slice(s.from,s.to)+n.lineBreak}):i.push({from:s.to,insert:n.lineBreak+n.doc.slice(s.from,s.to)});return e(n.update({changes:i,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const lR=({state:n,dispatch:e})=>$2(n,e,!1),aR=({state:n,dispatch:e})=>$2(n,e,!0),uR=n=>{if(n.state.readOnly)return!1;let{state:e}=n,t=e.changes(yf(e).map(({from:s,to:r})=>(s>0?s--:rn.moveVertically(s,!0)).map(t);return n.dispatch({changes:t,selection:i,scrollIntoView:!0,userEvent:"delete.line"}),!0};function cR(n,e){if(/\(\)|\[\]|\{\}/.test(n.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=Bi(n).resolveInner(e),i=t.childBefore(e),s=t.childAfter(e),r;return i&&s&&i.to<=e&&s.from>=e&&(r=i.type.prop(rt.closedBy))&&r.indexOf(s.name)>-1&&n.doc.lineAt(i.to).from==n.doc.lineAt(s.from).from?{from:i.to,to:s.from}:null}const fR=J2(!1),hR=J2(!0);function J2(n){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let i=e.changeByRange(s=>{let{from:r,to:o}=s,l=e.doc.lineAt(r),a=!n&&r==o&&cR(e,r);n&&(r=o=(o<=l.to?l:e.doc.lineAt(o)).to);let u=new df(e,{simulateBreak:r,simulateDoubleBreak:!!a}),c=rg(u,r);for(c==null&&(c=/^\s*/.exec(e.doc.lineAt(r).text)[0].length);ol.from&&r{let s=[];for(let o=i.from;o<=i.to;){let l=n.doc.lineAt(o);l.number>t&&(i.empty||i.to>l.from)&&(e(l,s,i),t=l.number),o=l.to+1}let r=n.changes(s);return{changes:s,range:de.range(r.mapPos(i.anchor,1),r.mapPos(i.head,1))}})}const dR=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let t=Object.create(null),i=new df(n,{overrideIndentation:r=>{let o=t[r];return o??-1}}),s=hg(n,(r,o,l)=>{let a=rg(i,r.from);if(a==null)return;/\S/.test(r.text)||(a=0);let u=/^\s*/.exec(r.text)[0],c=na(n,a);(u!=c||l.fromn.readOnly?!1:(e(n.update(hg(n,(t,i)=>{i.push({from:t.from,insert:n.facet(sg)})}),{userEvent:"input.indent"})),!0),gR=({state:n,dispatch:e})=>n.readOnly?!1:(e(n.update(hg(n,(t,i)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let r=pa(s,n.tabSize),o=0,l=na(n,Math.max(0,r-pc(n)));for(;o({mac:n.key,run:n.run,shift:n.shift}))),bR=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:D4,shift:U4},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:x4,shift:G4},{key:"Alt-ArrowUp",run:rR},{key:"Shift-Alt-ArrowUp",run:lR},{key:"Alt-ArrowDown",run:oR},{key:"Shift-Alt-ArrowDown",run:aR},{key:"Escape",run:eR},{key:"Mod-Enter",run:hR},{key:"Alt-l",mac:"Ctrl-l",run:Z4},{key:"Mod-i",run:Q4,preventDefault:!0},{key:"Mod-[",run:gR},{key:"Mod-]",run:pR},{key:"Mod-Alt-\\",run:dR},{key:"Shift-Mod-k",run:uR},{key:"Shift-Mod-\\",run:W4},{key:"Mod-/",run:a4},{key:"Alt-A",run:c4}].concat(_R);class Z2{constructor(e,t,i){this.state=e,this.pos=t,this.explicit=i,this.abortListeners=[]}tokenBefore(e){let t=Bi(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),i=Math.max(t.from,this.pos-250),s=t.text.slice(i-t.from,this.pos-t.from),r=s.search(Q2(e,!1));return r<0?null:{from:i+r,to:this.pos,text:s.slice(r)}}get aborted(){return this.abortListeners==null}addEventListener(e,t){e=="abort"&&this.abortListeners&&this.abortListeners.push(t)}}function n1(n){let e=Object.keys(n).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function yR(n){let e=Object.create(null),t=Object.create(null);for(let{label:s}of n){e[s[0]]=!0;for(let r=1;rtypeof s=="string"?{label:s}:s),[t,i]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:yR(e);return s=>{let r=s.matchBefore(i);return r||s.explicit?{from:r?r.from:s.pos,options:e,validFor:t}:null}}class s1{constructor(e,t,i,s){this.completion=e,this.source=t,this.match=i,this.score=s}}function gr(n){return n.selection.main.from}function Q2(n,e){var t;let{source:i}=n,s=e&&i[0]!="^",r=i[i.length-1]!="$";return!s&&!r?n:new RegExp(`${s?"^":""}(?:${i})${r?"$":""}`,(t=n.flags)!==null&&t!==void 0?t:n.ignoreCase?"i":"")}const wR=Ys.define();function eS(n,e,t,i){let{main:s}=n.selection,r=t-s.from,o=i-s.from;return Object.assign(Object.assign({},n.changeByRange(l=>l!=s&&t!=i&&n.sliceDoc(l.from+r,l.from+o)!=n.sliceDoc(t,i)?{range:l}:{changes:{from:l.from+r,to:i==s.from?l.to:l.from+o,insert:e},range:de.cursor(l.from+r+e.length)})),{userEvent:"input.complete"})}const r1=new WeakMap;function kR(n){if(!Array.isArray(n))return n;let e=r1.get(n);return e||r1.set(n,e=vR(n)),e}const dg=dt.define(),sa=dt.define();class SR{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[];for(let t=0;t=48&&T<=57||T>=97&&T<=122?2:T>=65&&T<=90?1:0:(I=zw(T))!=I.toLowerCase()?1:I!=I.toUpperCase()?2:0;(!b||x==1&&m||k==0&&x!=0)&&(t[f]==T||i[f]==T&&(h=!0)?o[f++]=b:o.length&&(_=!1)),k=x,b+=ns(T)}return f==a&&o[0]==0&&_?this.result(-100+(h?-200:0),o,e):d==a&&p==0?[-200-e.length+(g==e.length?0:-100),0,g]:l>-1?[-700-e.length,l,l+this.pattern.length]:d==a?[-200+-700-e.length,p,g]:f==a?this.result(-100+(h?-200:0)+-700+(_?0:-1100),o,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,i){let s=[e-i.length],r=1;for(let o of t){let l=o+(this.astral?ns($i(i,o)):1);r>1&&s[r-1]==o?s[r-1]=l:(s[r++]=o,s[r++]=l)}return s}}const bn=We.define({combine(n){return so(n,{activateOnTyping:!0,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:TR,compareCompletions:(e,t)=>e.label.localeCompare(t.label),interactionDelay:75},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>i=>o1(e(i),t(i)),optionClass:(e,t)=>i=>o1(e(i),t(i)),addToOptions:(e,t)=>e.concat(t)})}});function o1(n,e){return n?e?n+" "+e:n:e}function TR(n,e,t,i,s){let r=n.textDirection==qt.RTL,o=r,l=!1,a="top",u,c,f=e.left-s.left,h=s.right-e.right,d=i.right-i.left,p=i.bottom-i.top;if(o&&f=p||g>e.top?u=t.bottom-e.top:(a="bottom",u=e.bottom-t.top)}return{style:`${a}: ${u}px; max-width: ${c}px`,class:"cm-completionInfo-"+(l?r?"left-narrow":"right-narrow":o?"left":"right")}}function CR(n){let e=n.addToOptions.slice();return n.icons&&e.push({render(t){let i=document.createElement("div");return i.classList.add("cm-completionIcon"),t.type&&i.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),i.setAttribute("aria-hidden","true"),i},position:20}),e.push({render(t,i,s){let r=document.createElement("span");r.className="cm-completionLabel";let{label:o}=t,l=0;for(let a=1;al&&r.appendChild(document.createTextNode(o.slice(l,u)));let f=r.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(o.slice(u,c))),f.className="cm-completionMatchedText",l=c}return lt.position-i.position).map(t=>t.render)}function l1(n,e,t){if(n<=t)return{from:0,to:n};if(e<0&&(e=0),e<=n>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let i=Math.floor((n-e)/t);return{from:n-(i+1)*t,to:n-i*t}}class IR{constructor(e,t,i){this.view=e,this.stateField=t,this.applyCompletion=i,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:a=>this.placeInfo(a),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:r,selected:o}=s.open,l=e.state.facet(bn);this.optionContent=CR(l),this.optionClass=l.optionClass,this.tooltipClass=l.tooltipClass,this.range=l1(r.length,o,l.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",a=>{for(let u=a.target,c;u&&u!=this.dom;u=u.parentNode)if(u.nodeName=="LI"&&(c=/-(\d+)$/.exec(u.id))&&+c[1]{let u=e.state.field(this.stateField,!1);u&&u.tooltip&&e.state.facet(bn).closeOnBlur&&a.relatedTarget!=e.contentDOM&&e.dispatch({effects:sa.of(null)})}),this.list=this.dom.appendChild(this.createListBox(r,s.id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}mount(){this.updateSel()}update(e){var t,i,s;let r=e.state.field(this.stateField),o=e.startState.field(this.stateField);this.updateTooltipClass(e.state),r!=o&&(this.updateSel(),((t=r.open)===null||t===void 0?void 0:t.disabled)!=((i=o.open)===null||i===void 0?void 0:i.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!(!((s=r.open)===null||s===void 0)&&s.disabled)))}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let i of this.currentClass.split(" "))i&&this.dom.classList.remove(i);for(let i of t.split(" "))i&&this.dom.classList.add(i);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;if((t.selected>-1&&t.selected=this.range.to)&&(this.range=l1(t.options.length,t.selected,this.view.state.facet(bn).maxRenderedOptions),this.list.remove(),this.list=this.dom.appendChild(this.createListBox(t.options,e.id,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})),this.updateSelectedOption(t.selected)){this.destroyInfo();let{completion:i}=t.options[t.selected],{info:s}=i;if(!s)return;let r=typeof s=="string"?document.createTextNode(s):s(i);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,i)}).catch(o=>Yn(this.view.state,o,"completion info")):this.addInfoPane(r,i)}}addInfoPane(e,t){this.destroyInfo();let i=this.info=document.createElement("div");if(i.className="cm-tooltip cm-completionInfo",e.nodeType!=null)i.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:r}=e;i.appendChild(s),this.infoDestroy=r||null}this.dom.appendChild(i),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let i=this.list.firstChild,s=this.range.from;i;i=i.nextSibling,s++)i.nodeName!="LI"||!i.id?s--:s==e?i.hasAttribute("aria-selected")||(i.setAttribute("aria-selected","true"),t=i):i.hasAttribute("aria-selected")&&i.removeAttribute("aria-selected");return t&&AR(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),i=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),r=this.space;if(!r){let o=this.dom.ownerDocument.defaultView||window;r={left:0,top:0,right:o.innerWidth,bottom:o.innerHeight}}return s.top>Math.min(r.bottom,t.bottom)-10||s.bottomi.from||i.from==0))if(r=h,typeof u!="string"&&u.header)s.appendChild(u.header(u));else{let d=s.appendChild(document.createElement("completion-section"));d.textContent=h}}const c=s.appendChild(document.createElement("li"));c.id=t+"-"+o,c.setAttribute("role","option");let f=this.optionClass(l);f&&(c.className=f);for(let h of this.optionContent){let d=h(l,this.view.state,a);d&&c.appendChild(d)}}return i.from&&s.classList.add("cm-completionListIncompleteTop"),i.tonew IR(t,n,e)}function AR(n,e){let t=n.getBoundingClientRect(),i=e.getBoundingClientRect();i.topt.bottom&&(n.scrollTop+=i.bottom-t.bottom)}function a1(n){return(n.boost||0)*100+(n.apply?10:0)+(n.info?5:0)+(n.type?1:0)}function OR(n,e){let t=[],i=null,s=a=>{t.push(a);let{section:u}=a.completion;if(u){i||(i=[]);let c=typeof u=="string"?u:u.name;i.some(f=>f.name==c)||i.push(typeof u=="string"?{name:c}:u)}};for(let a of n)if(a.hasResult())if(a.result.filter===!1){let u=a.result.getMatch;for(let c of a.result.options){let f=[1e9-t.length];if(u)for(let h of u(c))f.push(h);s(new s1(c,a.source,f,f[0]))}}else{let u=new SR(e.sliceDoc(a.from,a.to)),c;for(let f of a.result.options)(c=u.match(f.label))&&s(new s1(f,a.source,c,c[0]+(f.boost||0)))}if(i){let a=Object.create(null),u=0,c=(f,h)=>{var d,p;return((d=f.rank)!==null&&d!==void 0?d:1e9)-((p=h.rank)!==null&&p!==void 0?p:1e9)||(f.namec.score-u.score||l(u.completion,c.completion)))!o||o.label!=a.completion.label||o.detail!=a.completion.detail||o.type!=null&&a.completion.type!=null&&o.type!=a.completion.type||o.apply!=a.completion.apply?r.push(a):a1(a.completion)>a1(o)&&(r[r.length-1]=a),o=a.completion;return r}class Oo{constructor(e,t,i,s,r,o){this.options=e,this.attrs=t,this.tooltip=i,this.timestamp=s,this.selected=r,this.disabled=o}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Oo(this.options,u1(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,i,s,r){let o=OR(e,t);if(!o.length)return s&&e.some(a=>a.state==1)?new Oo(s.options,s.attrs,s.tooltip,s.timestamp,s.selected,!0):null;let l=t.facet(bn).selectOnOpen?0:-1;if(s&&s.selected!=l&&s.selected!=-1){let a=s.options[s.selected].completion;for(let u=0;uu.hasResult()?Math.min(a,u.from):a,1e8),create:ER(Nn,nS),above:r.aboveCursor},s?s.timestamp:Date.now(),l,!1)}map(e){return new Oo(this.options,this.attrs,Object.assign(Object.assign({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}}class bc{constructor(e,t,i){this.active=e,this.id=t,this.open=i}static start(){return new bc(xR,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,i=t.facet(bn),r=(i.override||t.languageDataAt("autocomplete",gr(t)).map(kR)).map(l=>(this.active.find(u=>u.source==l)||new gn(l,this.active.some(u=>u.state!=0)?1:0)).update(e,i));r.length==this.active.length&&r.every((l,a)=>l==this.active[a])&&(r=this.active);let o=this.open;o&&e.docChanged&&(o=o.map(e.changes)),e.selection||r.some(l=>l.hasResult()&&e.changes.touchesRange(l.from,l.to))||!NR(r,this.active)?o=Oo.build(r,t,this.id,o,i):o&&o.disabled&&!r.some(l=>l.state==1)&&(o=null),!o&&r.every(l=>l.state!=1)&&r.some(l=>l.hasResult())&&(r=r.map(l=>l.hasResult()?new gn(l.source,0):l));for(let l of e.effects)l.is(iS)&&(o=o&&o.setSelected(l.value,this.id));return r==this.active&&o==this.open?this:new bc(r,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:DR}}function NR(n,e){if(n==e)return!0;for(let t=0,i=0;;){for(;t-1&&(t["aria-activedescendant"]=n+"-"+e),t}const xR=[];function Ud(n){return n.isUserEvent("input.type")?"input":n.isUserEvent("delete.backward")?"delete":null}class gn{constructor(e,t,i=-1){this.source=e,this.state=t,this.explicitPos=i}hasResult(){return!1}update(e,t){let i=Ud(e),s=this;i?s=s.handleUserEvent(e,i,t):e.docChanged?s=s.handleChange(e):e.selection&&s.state!=0&&(s=new gn(s.source,0));for(let r of e.effects)if(r.is(dg))s=new gn(s.source,1,r.value?gr(e.state):-1);else if(r.is(sa))s=new gn(s.source,0);else if(r.is(tS))for(let o of r.value)o.source==s.source&&(s=o);return s}handleUserEvent(e,t,i){return t=="delete"||!i.activateOnTyping?this.map(e.changes):new gn(this.source,1)}handleChange(e){return e.changes.touchesRange(gr(e.startState))?new gn(this.source,0):this.map(e.changes)}map(e){return e.empty||this.explicitPos<0?this:new gn(this.source,this.state,e.mapPos(this.explicitPos))}}class Vo extends gn{constructor(e,t,i,s,r){super(e,2,t),this.result=i,this.from=s,this.to=r}hasResult(){return!0}handleUserEvent(e,t,i){var s;let r=e.changes.mapPos(this.from),o=e.changes.mapPos(this.to,1),l=gr(e.state);if((this.explicitPos<0?l<=r:lo||t=="delete"&&gr(e.startState)==this.from)return new gn(this.source,t=="input"&&i.activateOnTyping?1:0);let a=this.explicitPos<0?-1:e.changes.mapPos(this.explicitPos),u;return LR(this.result.validFor,e.state,r,o)?new Vo(this.source,a,this.result,r,o):this.result.update&&(u=this.result.update(this.result,r,o,new Z2(e.state,l,a>=0)))?new Vo(this.source,a,u,u.from,(s=u.to)!==null&&s!==void 0?s:gr(e.state)):new gn(this.source,1,a)}handleChange(e){return e.changes.touchesRange(this.from,this.to)?new gn(this.source,0):this.map(e.changes)}map(e){return e.empty?this:new Vo(this.source,this.explicitPos<0?-1:e.mapPos(this.explicitPos),this.result,e.mapPos(this.from),e.mapPos(this.to,1))}}function LR(n,e,t,i){if(!n)return!1;let s=e.sliceDoc(t,i);return typeof n=="function"?n(s,t,i,e):Q2(n,!0).test(s)}const tS=dt.define({map(n,e){return n.map(t=>t.map(e))}}),iS=dt.define(),Nn=Pn.define({create(){return bc.start()},update(n,e){return n.update(e)},provide:n=>[Zp.from(n,e=>e.tooltip),He.contentAttributes.from(n,e=>e.attrs)]});function nS(n,e){const t=e.completion.apply||e.completion.label;let i=n.state.field(Nn).active.find(s=>s.source==e.source);return i instanceof Vo?(typeof t=="string"?n.dispatch(Object.assign(Object.assign({},eS(n.state,t,i.from,i.to)),{annotations:wR.of(e.completion)})):t(n,e.completion,i.from,i.to),!0):!1}function eu(n,e="option"){return t=>{let i=t.state.field(Nn,!1);if(!i||!i.open||i.open.disabled||Date.now()-i.open.timestamp-1?i.open.selected+s*(n?1:-1):n?0:o-1;return l<0?l=e=="page"?0:o-1:l>=o&&(l=e=="page"?o-1:0),t.dispatch({effects:iS.of(l)}),!0}}const MR=n=>{let e=n.state.field(Nn,!1);return n.state.readOnly||!e||!e.open||e.open.selected<0||Date.now()-e.open.timestampn.state.field(Nn,!1)?(n.dispatch({effects:dg.of(!0)}),!0):!1,PR=n=>{let e=n.state.field(Nn,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(n.dispatch({effects:sa.of(null)}),!0)};class BR{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const c1=50,zR=50,FR=1e3,WR=Qi.fromClass(class{constructor(n){this.view=n,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.composing=0;for(let e of n.state.field(Nn).active)e.state==1&&this.startQuery(e)}update(n){let e=n.state.field(Nn);if(!n.selectionSet&&!n.docChanged&&n.startState.field(Nn)==e)return;let t=n.transactions.some(i=>(i.selection||i.docChanged)&&!Ud(i));for(let i=0;izR&&Date.now()-s.time>FR){for(let r of s.context.abortListeners)try{r()}catch(o){Yn(this.view.state,o)}s.context.abortListeners=null,this.running.splice(i--,1)}else s.updates.push(...n.transactions)}if(this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),this.debounceUpdate=e.active.some(i=>i.state==1&&!this.running.some(s=>s.active.source==i.source))?setTimeout(()=>this.startUpdate(),c1):-1,this.composing!=0)for(let i of n.transactions)Ud(i)=="input"?this.composing=2:this.composing==2&&i.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1;let{state:n}=this.view,e=n.field(Nn);for(let t of e.active)t.state==1&&!this.running.some(i=>i.active.source==t.source)&&this.startQuery(t)}startQuery(n){let{state:e}=this.view,t=gr(e),i=new Z2(e,t,n.explicitPos==t),s=new BR(n,i);this.running.push(s),Promise.resolve(n.source(i)).then(r=>{s.context.aborted||(s.done=r||null,this.scheduleAccept())},r=>{this.view.dispatch({effects:sa.of(null)}),Yn(this.view.state,r)})}scheduleAccept(){this.running.every(n=>n.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),c1))}accept(){var n;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(bn);for(let i=0;io.source==s.active.source);if(r&&r.state==1)if(s.done==null){let o=new gn(s.active.source,0);for(let l of s.updates)o=o.update(l,t);o.state!=1&&e.push(o)}else this.startQuery(r)}e.length&&this.view.dispatch({effects:tS.of(e)})}},{eventHandlers:{blur(n){let e=this.view.state.field(Nn,!1);if(e&&e.tooltip&&this.view.state.facet(bn).closeOnBlur){let t=e.open&&Qk(this.view,e.open.tooltip);(!t||!t.dom.contains(n.relatedTarget))&&this.view.dispatch({effects:sa.of(null)})}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:dg.of(!1)}),20),this.composing=0}}}),VR=He.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),ra={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Ur=dt.define({map(n,e){let t=e.mapPos(n,-1,rn.TrackAfter);return t??void 0}}),pg=new class extends eo{};pg.startSide=1;pg.endSide=-1;const sS=Pn.define({create(){return Tt.empty},update(n,e){if(e.selection){let t=e.state.doc.lineAt(e.selection.main.head).from,i=e.startState.doc.lineAt(e.startState.selection.main.head).from;t!=e.changes.mapPos(i,-1)&&(n=Tt.empty)}n=n.map(e.changes);for(let t of e.effects)t.is(Ur)&&(n=n.update({add:[pg.range(t.value,t.value+1)]}));return n}});function HR(){return[GR,sS]}const dh="()[]{}<>";function rS(n){for(let e=0;e{if((UR?n.composing:n.compositionStarted)||n.state.readOnly)return!1;let s=n.state.selection.main;if(i.length>2||i.length==2&&ns($i(i,0))==1||e!=s.from||t!=s.to)return!1;let r=YR(n.state,i);return r?(n.dispatch(r),!0):!1}),jR=({state:n,dispatch:e})=>{if(n.readOnly)return!1;let i=oS(n,n.selection.main.head).brackets||ra.brackets,s=null,r=n.changeByRange(o=>{if(o.empty){let l=XR(n.doc,o.head);for(let a of i)if(a==l&&vf(n.doc,o.head)==rS($i(a,0)))return{changes:{from:o.head-a.length,to:o.head+a.length},range:de.cursor(o.head-a.length)}}return{range:s=o}});return s||e(n.update(r,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},qR=[{key:"Backspace",run:jR}];function YR(n,e){let t=oS(n,n.selection.main.head),i=t.brackets||ra.brackets;for(let s of i){let r=rS($i(s,0));if(e==s)return r==s?JR(n,s,i.indexOf(s+s+s)>-1,t):KR(n,s,r,t.before||ra.before);if(e==r&&lS(n,n.selection.main.from))return $R(n,s,r)}return null}function lS(n,e){let t=!1;return n.field(sS).between(0,n.doc.length,i=>{i==e&&(t=!0)}),t}function vf(n,e){let t=n.sliceString(e,e+2);return t.slice(0,ns($i(t,0)))}function XR(n,e){let t=n.sliceString(e-2,e);return ns($i(t,0))==t.length?t:t.slice(1)}function KR(n,e,t,i){let s=null,r=n.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:t,from:o.to}],effects:Ur.of(o.to+e.length),range:de.range(o.anchor+e.length,o.head+e.length)};let l=vf(n.doc,o.head);return!l||/\s/.test(l)||i.indexOf(l)>-1?{changes:{insert:e+t,from:o.head},effects:Ur.of(o.head+e.length),range:de.cursor(o.head+e.length)}:{range:s=o}});return s?null:n.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function $R(n,e,t){let i=null,s=n.changeByRange(r=>r.empty&&vf(n.doc,r.head)==t?{changes:{from:r.head,to:r.head+t.length,insert:t},range:de.cursor(r.head+t.length)}:i={range:r});return i?null:n.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function JR(n,e,t,i){let s=i.stringPrefixes||ra.stringPrefixes,r=null,o=n.changeByRange(l=>{if(!l.empty)return{changes:[{insert:e,from:l.from},{insert:e,from:l.to}],effects:Ur.of(l.to+e.length),range:de.range(l.anchor+e.length,l.head+e.length)};let a=l.head,u=vf(n.doc,a),c;if(u==e){if(f1(n,a))return{changes:{insert:e+e,from:a},effects:Ur.of(a+e.length),range:de.cursor(a+e.length)};if(lS(n,a)){let h=t&&n.sliceDoc(a,a+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:a,to:a+h.length,insert:h},range:de.cursor(a+h.length)}}}else{if(t&&n.sliceDoc(a-2*e.length,a)==e+e&&(c=h1(n,a-2*e.length,s))>-1&&f1(n,c))return{changes:{insert:e+e+e+e,from:a},effects:Ur.of(a+e.length),range:de.cursor(a+e.length)};if(n.charCategorizer(a)(u)!=Gn.Word&&h1(n,a,s)>-1&&!ZR(n,a,e,s))return{changes:{insert:e+e,from:a},effects:Ur.of(a+e.length),range:de.cursor(a+e.length)}}return{range:r=l}});return r?null:n.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function f1(n,e){let t=Bi(n).resolveInner(e+1);return t.parent&&t.from==e}function ZR(n,e,t,i){let s=Bi(n).resolveInner(e,-1),r=i.reduce((o,l)=>Math.max(o,l.length),0);for(let o=0;o<5;o++){let l=n.sliceDoc(s.from,Math.min(s.to,s.from+t.length+r)),a=l.indexOf(t);if(!a||a>-1&&i.indexOf(l.slice(0,a))>-1){let c=s.firstChild;for(;c&&c.from==s.from&&c.to-c.from>t.length+a;){if(n.sliceDoc(c.to-t.length,c.to)==t)return!1;c=c.firstChild}return!0}let u=s.to==e&&s.parent;if(!u)break;s=u}return!1}function h1(n,e,t){let i=n.charCategorizer(e);if(i(n.sliceDoc(e-1,e))!=Gn.Word)return e;for(let s of t){let r=e-s.length;if(n.sliceDoc(r,e)==s&&i(n.sliceDoc(r-1,r))!=Gn.Word)return r}return-1}function QR(n={}){return[Nn,bn.of(n),WR,eP,VR]}const aS=[{key:"Ctrl-Space",run:RR},{key:"Escape",run:PR},{key:"ArrowDown",run:eu(!0)},{key:"ArrowUp",run:eu(!1)},{key:"PageDown",run:eu(!0,"page")},{key:"PageUp",run:eu(!1,"page")},{key:"Enter",run:MR}],eP=da.highest(Jp.computeN([bn],n=>n.facet(bn).defaultKeymap?[aS]:[]));function vs(){var n=arguments[0];typeof n=="string"&&(n=document.createElement(n));var e=1,t=arguments[1];if(t&&typeof t=="object"&&t.nodeType==null&&!Array.isArray(t)){for(var i in t)if(Object.prototype.hasOwnProperty.call(t,i)){var s=t[i];typeof s=="string"?n.setAttribute(i,s):s!=null&&(n[i]=s)}e++}for(;el.from==l.to||l.from==l.to-1&&i.doc.lineAt(l.from).to==l.from?ut.widget({widget:new cP(l),diagnostic:l}).range(l.from):ut.mark({attributes:{class:"cm-lintRange cm-lintRange-"+l.severity},diagnostic:l}).range(l.from,l.to)),!0);return new Fr(o,t,nl(o))}}function nl(n,e=null,t=0){let i=null;return n.between(t,1e9,(s,r,{spec:o})=>{if(!(e&&o.diagnostic!=e))return i=new tP(s,r,o.diagnostic),!1}),i}function iP(n,e){let t=n.startState.doc.lineAt(e.pos);return!!(n.effects.some(i=>i.is(cS))||n.changes.touchesRange(t.from,t.to))}function nP(n,e){return n.field(Mn,!1)?e:e.concat(dt.appendConfig.of(dP))}const cS=dt.define(),gg=dt.define(),fS=dt.define(),Mn=Pn.define({create(){return new Fr(ut.none,null,null)},update(n,e){if(e.docChanged){let t=n.diagnostics.map(e.changes),i=null;if(n.selected){let s=e.changes.mapPos(n.selected.from,1);i=nl(t,n.selected.diagnostic,s)||nl(t,null,s)}n=new Fr(t,n.panel,i)}for(let t of e.effects)t.is(cS)?n=Fr.init(t.value,n.panel,e.state):t.is(gg)?n=new Fr(n.diagnostics,t.value?wf.open:null,n.selected):t.is(fS)&&(n=new Fr(n.diagnostics,n.panel,t.value));return n},provide:n=>[Dd.from(n,e=>e.panel),He.decorations.from(n,e=>e.diagnostics)]}),sP=ut.mark({class:"cm-lintRange cm-lintRange-active"});function rP(n,e,t){let{diagnostics:i}=n.state.field(Mn),s=[],r=2e8,o=0;i.between(e-(t<0?1:0),e+(t>0?1:0),(a,u,{spec:c})=>{e>=a&&e<=u&&(a==u||(e>a||t>0)&&(epS(n,t,!1)))}const lP=n=>{let e=n.state.field(Mn,!1);(!e||!e.panel)&&n.dispatch({effects:nP(n.state,[gg.of(!0)])});let t=P3(n,wf.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},d1=n=>{let e=n.state.field(Mn,!1);return!e||!e.panel?!1:(n.dispatch({effects:gg.of(!1)}),!0)},aP=n=>{let e=n.state.field(Mn,!1);if(!e)return!1;let t=n.state.selection.main,i=e.diagnostics.iter(t.to+1);return!i.value&&(i=e.diagnostics.iter(0),!i.value||i.from==t.from&&i.to==t.to)?!1:(n.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0}),!0)},uP=[{key:"Mod-Shift-m",run:lP,preventDefault:!0},{key:"F8",run:aP}],hS=We.define({combine(n){return Object.assign({sources:n.map(e=>e.source)},so(n.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null},{needsRefresh:(e,t)=>e?t?i=>e(i)||t(i):e:t}))}});function dS(n){let e=[];if(n)e:for(let{name:t}of n){for(let i=0;ir.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function pS(n,e,t){var i;let s=t?dS(e.actions):[];return vs("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},vs("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage():e.message),(i=e.actions)===null||i===void 0?void 0:i.map((r,o)=>{let l=!1,a=h=>{if(h.preventDefault(),l)return;l=!0;let d=nl(n.state.field(Mn).diagnostics,e);d&&r.apply(n,d.from,d.to)},{name:u}=r,c=s[o]?u.indexOf(s[o]):-1,f=c<0?u:[u.slice(0,c),vs("u",u.slice(c,c+1)),u.slice(c+1)];return vs("button",{type:"button",class:"cm-diagnosticAction",onclick:a,onmousedown:a,"aria-label":` Action: ${u}${c<0?"":` (access key "${s[o]})"`}.`},f)}),e.source&&vs("div",{class:"cm-diagnosticSource"},e.source))}class cP extends Xs{constructor(e){super(),this.diagnostic=e}eq(e){return e.diagnostic==this.diagnostic}toDOM(){return vs("span",{class:"cm-lintPoint cm-lintPoint-"+this.diagnostic.severity})}}class p1{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=pS(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class wf{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)d1(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:r}=this.items[this.selectedIndex],o=dS(r.actions);for(let l=0;l{for(let r=0;rd1(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(Mn).selected;if(!e)return-1;for(let t=0;t{let u=-1,c;for(let f=i;fi&&(this.items.splice(i,u-i),s=!0)),t&&c.diagnostic==t.diagnostic?c.dom.hasAttribute("aria-selected")||(c.dom.setAttribute("aria-selected","true"),r=c):c.dom.hasAttribute("aria-selected")&&c.dom.removeAttribute("aria-selected"),i++});i({sel:r.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:l})=>{o.topl.bottom&&(this.list.scrollTop+=o.bottom-l.bottom)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let i=e;e=i.nextSibling,i.remove()}for(let i of this.items)if(i.dom.parentNode==this.list){for(;e!=i.dom;)t();e=i.dom.nextSibling}else this.list.insertBefore(i.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(Mn),i=nl(t.diagnostics,this.items[e].diagnostic);i&&this.view.dispatch({selection:{anchor:i.from,head:i.to},scrollIntoView:!0,effects:fS.of(i)})}static open(e){return new wf(e)}}function fP(n,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(n)}')`}function ph(n){return fP(``,'width="6" height="3"')}const hP=He.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:ph("#d11")},".cm-lintRange-warning":{backgroundImage:ph("orange")},".cm-lintRange-info":{backgroundImage:ph("#999")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}}),dP=[Mn,He.decorations.compute([Mn],n=>{let{selected:e,panel:t}=n.field(Mn);return!e||!t||e.from==e.to?ut.none:ut.set([sP.range(e.from,e.to)])}),M3(rP,{hideOn:iP}),hP];var g1=typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{},ws=[],Fn=[],pP=typeof Uint8Array<"u"?Uint8Array:Array,mg=!1;function gS(){mg=!0;for(var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,t=n.length;e0)throw new Error("Invalid string. Length must be a multiple of 4");r=n[l-2]==="="?2:n[l-1]==="="?1:0,o=new pP(l*3/4-r),i=r>0?l-4:l;var a=0;for(e=0,t=0;e>16&255,o[a++]=s>>8&255,o[a++]=s&255;return r===2?(s=Fn[n.charCodeAt(e)]<<2|Fn[n.charCodeAt(e+1)]>>4,o[a++]=s&255):r===1&&(s=Fn[n.charCodeAt(e)]<<10|Fn[n.charCodeAt(e+1)]<<4|Fn[n.charCodeAt(e+2)]>>2,o[a++]=s>>8&255,o[a++]=s&255),o}function mP(n){return ws[n>>18&63]+ws[n>>12&63]+ws[n>>6&63]+ws[n&63]}function _P(n,e,t){for(var i,s=[],r=e;ra?a:l+o));return i===1?(e=n[t-1],s+=ws[e>>2],s+=ws[e<<4&63],s+="=="):i===2&&(e=(n[t-2]<<8)+n[t-1],s+=ws[e>>10],s+=ws[e>>4&63],s+=ws[e<<2&63],s+="="),r.push(s),r.join("")}function kf(n,e,t,i,s){var r,o,l=s*8-i-1,a=(1<>1,c=-7,f=t?s-1:0,h=t?-1:1,d=n[e+f];for(f+=h,r=d&(1<<-c)-1,d>>=-c,c+=l;c>0;r=r*256+n[e+f],f+=h,c-=8);for(o=r&(1<<-c)-1,r>>=-c,c+=i;c>0;o=o*256+n[e+f],f+=h,c-=8);if(r===0)r=1-u;else{if(r===a)return o?NaN:(d?-1:1)*(1/0);o=o+Math.pow(2,i),r=r-u}return(d?-1:1)*o*Math.pow(2,r-i)}function mS(n,e,t,i,s,r){var o,l,a,u=r*8-s-1,c=(1<>1,h=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=i?0:r-1,p=i?1:-1,g=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(l=isNaN(e)?1:0,o=c):(o=Math.floor(Math.log(e)/Math.LN2),e*(a=Math.pow(2,-o))<1&&(o--,a*=2),o+f>=1?e+=h/a:e+=h*Math.pow(2,1-f),e*a>=2&&(o++,a/=2),o+f>=c?(l=0,o=c):o+f>=1?(l=(e*a-1)*Math.pow(2,s),o=o+f):(l=e*Math.pow(2,f-1)*Math.pow(2,s),o=0));s>=8;n[t+d]=l&255,d+=p,l/=256,s-=8);for(o=o<0;n[t+d]=o&255,d+=p,o/=256,u-=8);n[t+d-p]|=g*128}var bP={}.toString,_S=Array.isArray||function(n){return bP.call(n)=="[object Array]"},yP=50;ne.TYPED_ARRAY_SUPPORT=g1.TYPED_ARRAY_SUPPORT!==void 0?g1.TYPED_ARRAY_SUPPORT:!0;yc();function yc(){return ne.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Fs(n,e){if(yc()=yc())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+yc().toString(16)+" bytes");return n|0}ne.isBuffer=Un;function Es(n){return!!(n!=null&&n._isBuffer)}ne.compare=function(e,t){if(!Es(e)||!Es(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var i=e.length,s=t.length,r=0,o=Math.min(i,s);r>>1;case"base64":return ES(n).length;default:if(i)return vc(n).length;e=(""+e).toLowerCase(),i=!0}}ne.byteLength=vS;function TP(n,e,t){var i=!1;if((e===void 0||e<0)&&(e=0),e>this.length||((t===void 0||t>this.length)&&(t=this.length),t<=0)||(t>>>=0,e>>>=0,t<=e))return"";for(n||(n="utf8");;)switch(n){case"hex":return MP(this,e,t);case"utf8":case"utf-8":return SS(this,e,t);case"ascii":return xP(this,e,t);case"latin1":case"binary":return LP(this,e,t);case"base64":return NP(this,e,t);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return RP(this,e,t);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(n+"").toLowerCase(),i=!0}}ne.prototype._isBuffer=!0;function Gr(n,e,t){var i=n[e];n[e]=n[t],n[t]=i}ne.prototype.swap16=function(){var e=this.length;if(e%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""};ne.prototype.compare=function(e,t,i,s,r){if(!Es(e))throw new TypeError("Argument must be a Buffer");if(t===void 0&&(t=0),i===void 0&&(i=e?e.length:0),s===void 0&&(s=0),r===void 0&&(r=this.length),t<0||i>e.length||s<0||r>this.length)throw new RangeError("out of range index");if(s>=r&&t>=i)return 0;if(s>=r)return-1;if(t>=i)return 1;if(t>>>=0,i>>>=0,s>>>=0,r>>>=0,this===e)return 0;for(var o=r-s,l=i-t,a=Math.min(o,l),u=this.slice(s,r),c=e.slice(t,i),f=0;f2147483647?t=2147483647:t<-2147483648&&(t=-2147483648),t=+t,isNaN(t)&&(t=s?0:n.length-1),t<0&&(t=n.length+t),t>=n.length){if(s)return-1;t=n.length-1}else if(t<0)if(s)t=0;else return-1;if(typeof e=="string"&&(e=ne.from(e,i)),Es(e))return e.length===0?-1:_1(n,e,t,i,s);if(typeof e=="number")return e=e&255,ne.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?s?Uint8Array.prototype.indexOf.call(n,e,t):Uint8Array.prototype.lastIndexOf.call(n,e,t):_1(n,[e],t,i,s);throw new TypeError("val must be string, number or Buffer")}function _1(n,e,t,i,s){var r=1,o=n.length,l=e.length;if(i!==void 0&&(i=String(i).toLowerCase(),i==="ucs2"||i==="ucs-2"||i==="utf16le"||i==="utf-16le")){if(n.length<2||e.length<2)return-1;r=2,o/=2,l/=2,t/=2}function a(d,p){return r===1?d[p]:d.readUInt16BE(p*r)}var u;if(s){var c=-1;for(u=t;uo&&(t=o-l),u=t;u>=0;u--){for(var f=!0,h=0;hs&&(i=s)):i=s;var r=e.length;if(r%2!==0)throw new TypeError("Invalid hex string");i>r/2&&(i=r/2);for(var o=0;or)&&(i=r),e.length>0&&(i<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");s||(s="utf8");for(var o=!1;;)switch(s){case"hex":return CP(this,e,t,i);case"utf8":case"utf-8":return IP(this,e,t,i);case"ascii":return kS(this,e,t,i);case"latin1":case"binary":return EP(this,e,t,i);case"base64":return AP(this,e,t,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return OP(this,e,t,i);default:if(o)throw new TypeError("Unknown encoding: "+s);s=(""+s).toLowerCase(),o=!0}};ne.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function NP(n,e,t){return e===0&&t===n.length?m1(n):m1(n.slice(e,t))}function SS(n,e,t){t=Math.min(n.length,t);for(var i=[],s=e;s239?4:r>223?3:r>191?2:1;if(s+l<=t){var a,u,c,f;switch(l){case 1:r<128&&(o=r);break;case 2:a=n[s+1],(a&192)===128&&(f=(r&31)<<6|a&63,f>127&&(o=f));break;case 3:a=n[s+1],u=n[s+2],(a&192)===128&&(u&192)===128&&(f=(r&15)<<12|(a&63)<<6|u&63,f>2047&&(f<55296||f>57343)&&(o=f));break;case 4:a=n[s+1],u=n[s+2],c=n[s+3],(a&192)===128&&(u&192)===128&&(c&192)===128&&(f=(r&15)<<18|(a&63)<<12|(u&63)<<6|c&63,f>65535&&f<1114112&&(o=f))}}o===null?(o=65533,l=1):o>65535&&(o-=65536,i.push(o>>>10&1023|55296),o=56320|o&1023),i.push(o),s+=l}return DP(i)}var b1=4096;function DP(n){var e=n.length;if(e<=b1)return String.fromCharCode.apply(String,n);for(var t="",i=0;ii)&&(t=i);for(var s="",r=e;ri&&(e=i),t<0?(t+=i,t<0&&(t=0)):t>i&&(t=i),tt)throw new RangeError("Trying to access beyond buffer length")}ne.prototype.readUIntLE=function(e,t,i){e=e|0,t=t|0,i||Ci(e,t,this.length);for(var s=this[e],r=1,o=0;++o0&&(r*=256);)s+=this[e+--t]*r;return s};ne.prototype.readUInt8=function(e,t){return t||Ci(e,1,this.length),this[e]};ne.prototype.readUInt16LE=function(e,t){return t||Ci(e,2,this.length),this[e]|this[e+1]<<8};ne.prototype.readUInt16BE=function(e,t){return t||Ci(e,2,this.length),this[e]<<8|this[e+1]};ne.prototype.readUInt32LE=function(e,t){return t||Ci(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+this[e+3]*16777216};ne.prototype.readUInt32BE=function(e,t){return t||Ci(e,4,this.length),this[e]*16777216+(this[e+1]<<16|this[e+2]<<8|this[e+3])};ne.prototype.readIntLE=function(e,t,i){e=e|0,t=t|0,i||Ci(e,t,this.length);for(var s=this[e],r=1,o=0;++o=r&&(s-=Math.pow(2,8*t)),s};ne.prototype.readIntBE=function(e,t,i){e=e|0,t=t|0,i||Ci(e,t,this.length);for(var s=t,r=1,o=this[e+--s];s>0&&(r*=256);)o+=this[e+--s]*r;return r*=128,o>=r&&(o-=Math.pow(2,8*t)),o};ne.prototype.readInt8=function(e,t){return t||Ci(e,1,this.length),this[e]&128?(255-this[e]+1)*-1:this[e]};ne.prototype.readInt16LE=function(e,t){t||Ci(e,2,this.length);var i=this[e]|this[e+1]<<8;return i&32768?i|4294901760:i};ne.prototype.readInt16BE=function(e,t){t||Ci(e,2,this.length);var i=this[e+1]|this[e]<<8;return i&32768?i|4294901760:i};ne.prototype.readInt32LE=function(e,t){return t||Ci(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24};ne.prototype.readInt32BE=function(e,t){return t||Ci(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]};ne.prototype.readFloatLE=function(e,t){return t||Ci(e,4,this.length),kf(this,e,!0,23,4)};ne.prototype.readFloatBE=function(e,t){return t||Ci(e,4,this.length),kf(this,e,!1,23,4)};ne.prototype.readDoubleLE=function(e,t){return t||Ci(e,8,this.length),kf(this,e,!0,52,8)};ne.prototype.readDoubleBE=function(e,t){return t||Ci(e,8,this.length),kf(this,e,!1,52,8)};function Sn(n,e,t,i,s,r){if(!Es(n))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>s||en.length)throw new RangeError("Index out of range")}ne.prototype.writeUIntLE=function(e,t,i,s){if(e=+e,t=t|0,i=i|0,!s){var r=Math.pow(2,8*i)-1;Sn(this,e,t,i,r,0)}var o=1,l=0;for(this[t]=e&255;++l=0&&(l*=256);)this[t+o]=e/l&255;return t+i};ne.prototype.writeUInt8=function(e,t,i){return e=+e,t=t|0,i||Sn(this,e,t,1,255,0),ne.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=e&255,t+1};function Sf(n,e,t,i){e<0&&(e=65535+e+1);for(var s=0,r=Math.min(n.length-t,2);s>>(i?s:1-s)*8}ne.prototype.writeUInt16LE=function(e,t,i){return e=+e,t=t|0,i||Sn(this,e,t,2,65535,0),ne.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Sf(this,e,t,!0),t+2};ne.prototype.writeUInt16BE=function(e,t,i){return e=+e,t=t|0,i||Sn(this,e,t,2,65535,0),ne.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Sf(this,e,t,!1),t+2};function Tf(n,e,t,i){e<0&&(e=4294967295+e+1);for(var s=0,r=Math.min(n.length-t,4);s>>(i?s:3-s)*8&255}ne.prototype.writeUInt32LE=function(e,t,i){return e=+e,t=t|0,i||Sn(this,e,t,4,4294967295,0),ne.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=e&255):Tf(this,e,t,!0),t+4};ne.prototype.writeUInt32BE=function(e,t,i){return e=+e,t=t|0,i||Sn(this,e,t,4,4294967295,0),ne.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):Tf(this,e,t,!1),t+4};ne.prototype.writeIntLE=function(e,t,i,s){if(e=+e,t=t|0,!s){var r=Math.pow(2,8*i-1);Sn(this,e,t,i,r-1,-r)}var o=0,l=1,a=0;for(this[t]=e&255;++o>0)-a&255;return t+i};ne.prototype.writeIntBE=function(e,t,i,s){if(e=+e,t=t|0,!s){var r=Math.pow(2,8*i-1);Sn(this,e,t,i,r-1,-r)}var o=i-1,l=1,a=0;for(this[t+o]=e&255;--o>=0&&(l*=256);)e<0&&a===0&&this[t+o+1]!==0&&(a=1),this[t+o]=(e/l>>0)-a&255;return t+i};ne.prototype.writeInt8=function(e,t,i){return e=+e,t=t|0,i||Sn(this,e,t,1,127,-128),ne.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=e&255,t+1};ne.prototype.writeInt16LE=function(e,t,i){return e=+e,t=t|0,i||Sn(this,e,t,2,32767,-32768),ne.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8):Sf(this,e,t,!0),t+2};ne.prototype.writeInt16BE=function(e,t,i){return e=+e,t=t|0,i||Sn(this,e,t,2,32767,-32768),ne.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=e&255):Sf(this,e,t,!1),t+2};ne.prototype.writeInt32LE=function(e,t,i){return e=+e,t=t|0,i||Sn(this,e,t,4,2147483647,-2147483648),ne.TYPED_ARRAY_SUPPORT?(this[t]=e&255,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Tf(this,e,t,!0),t+4};ne.prototype.writeInt32BE=function(e,t,i){return e=+e,t=t|0,i||Sn(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),ne.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=e&255):Tf(this,e,t,!1),t+4};function TS(n,e,t,i,s,r){if(t+i>n.length)throw new RangeError("Index out of range");if(t<0)throw new RangeError("Index out of range")}function CS(n,e,t,i,s){return s||TS(n,e,t,4),mS(n,e,t,i,23,4),t+4}ne.prototype.writeFloatLE=function(e,t,i){return CS(this,e,t,!0,i)};ne.prototype.writeFloatBE=function(e,t,i){return CS(this,e,t,!1,i)};function IS(n,e,t,i,s){return s||TS(n,e,t,8),mS(n,e,t,i,52,8),t+8}ne.prototype.writeDoubleLE=function(e,t,i){return IS(this,e,t,!0,i)};ne.prototype.writeDoubleBE=function(e,t,i){return IS(this,e,t,!1,i)};ne.prototype.copy=function(e,t,i,s){if(i||(i=0),!s&&s!==0&&(s=this.length),t>=e.length&&(t=e.length),t||(t=0),s>0&&s=this.length)throw new RangeError("sourceStart out of bounds");if(s<0)throw new RangeError("sourceEnd out of bounds");s>this.length&&(s=this.length),e.length-t=0;--o)e[o+t]=this[o+i];else if(r<1e3||!ne.TYPED_ARRAY_SUPPORT)for(o=0;o>>0,i=i===void 0?this.length:i>>>0,e||(e=0);var o;if(typeof e=="number")for(o=t;o55295&&t<57344){if(!s){if(t>56319){(e-=3)>-1&&r.push(239,191,189);continue}else if(o+1===i){(e-=3)>-1&&r.push(239,191,189);continue}s=t;continue}if(t<56320){(e-=3)>-1&&r.push(239,191,189),s=t;continue}t=(s-55296<<10|t-56320)+65536}else s&&(e-=3)>-1&&r.push(239,191,189);if(s=null,t<128){if((e-=1)<0)break;r.push(t)}else if(t<2048){if((e-=2)<0)break;r.push(t>>6|192,t&63|128)}else if(t<65536){if((e-=3)<0)break;r.push(t>>12|224,t>>6&63|128,t&63|128)}else if(t<1114112){if((e-=4)<0)break;r.push(t>>18|240,t>>12&63|128,t>>6&63|128,t&63|128)}else throw new Error("Invalid code point")}return r}function WP(n){for(var e=[],t=0;t>8,s=t%256,r.push(s),r.push(i);return r}function ES(n){return gP(BP(n))}function Cf(n,e,t,i){for(var s=0;s=e.length||s>=n.length);++s)e[s+t]=n[s];return s}function HP(n){return n!==n}function Un(n){return n!=null&&(!!n._isBuffer||AS(n)||UP(n))}function AS(n){return!!n.constructor&&typeof n.constructor.isBuffer=="function"&&n.constructor.isBuffer(n)}function UP(n){return typeof n.readFloatLE=="function"&&typeof n.slice=="function"&&AS(n.slice(0,0))}class wt extends Error{constructor(e,t,i,...s){Array.isArray(t)&&(t=t.join(" ").trim()),super(t),Error.captureStackTrace!==void 0&&Error.captureStackTrace(this,wt),this.code=e;for(const r of s)for(const o in r){const l=r[o];this[o]=Un(l)?l.toString(i.encoding):l==null?l:JSON.parse(JSON.stringify(l))}}}const GP=function(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)},OS=function(n){const e=[];for(let t=0,i=n.length;t=this.size&&(this.resize(),t>=this.size))throw Error("INVALID_BUFFER_STATE");const i=this.buf;this.buf=ne.allocUnsafe(this.size),e.copy(this.buf,0),i.copy(this.buf,e.length),this.length+=e.length}else{const t=this.length++;t===this.size&&this.resize();const i=this.clone();this.buf[0]=e,i.copy(this.buf,1,0,t)}}append(e){const t=this.length++;t===this.size&&this.resize(),this.buf[t]=e}clone(){return ne.from(this.buf.slice(0,this.length))}resize(){const e=this.length;this.size=this.size*2;const t=ne.allocUnsafe(this.size);this.buf.copy(t,0,0,e),this.buf=t}toString(e){return e?this.buf.slice(0,this.length).toString(e):Uint8Array.prototype.slice.call(this.buf.slice(0,this.length))}toJSON(){return this.toString("utf8")}reset(){this.length=0}}const jP=12,qP=13,YP=10,XP=32,KP=9,$P=function(n){return{bomSkipped:!1,bufBytesStart:0,castField:n.cast_function,commenting:!1,error:void 0,enabled:n.from_line===1,escaping:!1,escapeIsQuote:Un(n.escape)&&Un(n.quote)&&ne.compare(n.escape,n.quote)===0,expectedRecordLength:Array.isArray(n.columns)?n.columns.length:void 0,field:new y1(20),firstLineToHeaders:n.cast_first_line_to_header,needMoreDataSize:Math.max(n.comment!==null?n.comment.length:0,...n.delimiter.map(e=>e.length),n.quote!==null?n.quote.length:0),previousBuf:void 0,quoting:!1,stop:!1,rawBuffer:new y1(100),record:[],recordHasError:!1,record_length:0,recordDelimiterMaxLength:n.record_delimiter.length===0?0:Math.max(...n.record_delimiter.map(e=>e.length)),trimChars:[ne.from(" ",n.encoding)[0],ne.from(" ",n.encoding)[0]],wasQuoting:!1,wasRowDelimiter:!1,timchars:[ne.from(ne.from([qP],"utf8").toString(),n.encoding),ne.from(ne.from([YP],"utf8").toString(),n.encoding),ne.from(ne.from([jP],"utf8").toString(),n.encoding),ne.from(ne.from([XP],"utf8").toString(),n.encoding),ne.from(ne.from([KP],"utf8").toString(),n.encoding)]}},JP=function(n){return n.replace(/([A-Z])/g,function(e,t){return"_"+t.toLowerCase()})},v1=function(n){const e={};for(const i in n)e[JP(i)]=n[i];if(e.encoding===void 0||e.encoding===!0)e.encoding="utf8";else if(e.encoding===null||e.encoding===!1)e.encoding=null;else if(typeof e.encoding!="string"&&e.encoding!==null)throw new wt("CSV_INVALID_OPTION_ENCODING",["Invalid option encoding:","encoding must be a string or null to return a buffer,",`got ${JSON.stringify(e.encoding)}`],e);if(e.bom===void 0||e.bom===null||e.bom===!1)e.bom=!1;else if(e.bom!==!0)throw new wt("CSV_INVALID_OPTION_BOM",["Invalid option bom:","bom must be true,",`got ${JSON.stringify(e.bom)}`],e);if(e.cast_function=null,e.cast===void 0||e.cast===null||e.cast===!1||e.cast==="")e.cast=void 0;else if(typeof e.cast=="function")e.cast_function=e.cast,e.cast=!0;else if(e.cast!==!0)throw new wt("CSV_INVALID_OPTION_CAST",["Invalid option cast:","cast must be true or a function,",`got ${JSON.stringify(e.cast)}`],e);if(e.cast_date===void 0||e.cast_date===null||e.cast_date===!1||e.cast_date==="")e.cast_date=!1;else if(e.cast_date===!0)e.cast_date=function(i){const s=Date.parse(i);return isNaN(s)?i:new Date(s)};else if(typeof e.cast_date!="function")throw new wt("CSV_INVALID_OPTION_CAST_DATE",["Invalid option cast_date:","cast_date must be true or a function,",`got ${JSON.stringify(e.cast_date)}`],e);if(e.cast_first_line_to_header=null,e.columns===!0)e.cast_first_line_to_header=void 0;else if(typeof e.columns=="function")e.cast_first_line_to_header=e.columns,e.columns=!0;else if(Array.isArray(e.columns))e.columns=OS(e.columns);else if(e.columns===void 0||e.columns===null||e.columns===!1)e.columns=!1;else throw new wt("CSV_INVALID_OPTION_COLUMNS",["Invalid option columns:","expect an array, a function or true,",`got ${JSON.stringify(e.columns)}`],e);if(e.group_columns_by_name===void 0||e.group_columns_by_name===null||e.group_columns_by_name===!1)e.group_columns_by_name=!1;else{if(e.group_columns_by_name!==!0)throw new wt("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","expect an boolean,",`got ${JSON.stringify(e.group_columns_by_name)}`],e);if(e.columns===!1)throw new wt("CSV_INVALID_OPTION_GROUP_COLUMNS_BY_NAME",["Invalid option group_columns_by_name:","the `columns` mode must be activated."],e)}if(e.comment===void 0||e.comment===null||e.comment===!1||e.comment==="")e.comment=null;else if(typeof e.comment=="string"&&(e.comment=ne.from(e.comment,e.encoding)),!Un(e.comment))throw new wt("CSV_INVALID_OPTION_COMMENT",["Invalid option comment:","comment must be a buffer or a string,",`got ${JSON.stringify(e.comment)}`],e);const t=JSON.stringify(e.delimiter);if(Array.isArray(e.delimiter)||(e.delimiter=[e.delimiter]),e.delimiter.length===0)throw new wt("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${t}`],e);if(e.delimiter=e.delimiter.map(function(i){if(i==null||i===!1)return ne.from(",",e.encoding);if(typeof i=="string"&&(i=ne.from(i,e.encoding)),!Un(i)||i.length===0)throw new wt("CSV_INVALID_OPTION_DELIMITER",["Invalid option delimiter:","delimiter must be a non empty string or buffer or array of string|buffer,",`got ${t}`],e);return i}),e.escape===void 0||e.escape===!0?e.escape=ne.from('"',e.encoding):typeof e.escape=="string"?e.escape=ne.from(e.escape,e.encoding):(e.escape===null||e.escape===!1)&&(e.escape=null),e.escape!==null&&!Un(e.escape))throw new Error(`Invalid Option: escape must be a buffer, a string or a boolean, got ${JSON.stringify(e.escape)}`);if(e.from===void 0||e.from===null)e.from=1;else if(typeof e.from=="string"&&/\d+/.test(e.from)&&(e.from=parseInt(e.from)),Number.isInteger(e.from)){if(e.from<0)throw new Error(`Invalid Option: from must be a positive integer, got ${JSON.stringify(n.from)}`)}else throw new Error(`Invalid Option: from must be an integer, got ${JSON.stringify(e.from)}`);if(e.from_line===void 0||e.from_line===null)e.from_line=1;else if(typeof e.from_line=="string"&&/\d+/.test(e.from_line)&&(e.from_line=parseInt(e.from_line)),Number.isInteger(e.from_line)){if(e.from_line<=0)throw new Error(`Invalid Option: from_line must be a positive integer greater than 0, got ${JSON.stringify(n.from_line)}`)}else throw new Error(`Invalid Option: from_line must be an integer, got ${JSON.stringify(n.from_line)}`);if(e.ignore_last_delimiters===void 0||e.ignore_last_delimiters===null)e.ignore_last_delimiters=!1;else if(typeof e.ignore_last_delimiters=="number")e.ignore_last_delimiters=Math.floor(e.ignore_last_delimiters),e.ignore_last_delimiters===0&&(e.ignore_last_delimiters=!1);else if(typeof e.ignore_last_delimiters!="boolean")throw new wt("CSV_INVALID_OPTION_IGNORE_LAST_DELIMITERS",["Invalid option `ignore_last_delimiters`:","the value must be a boolean value or an integer,",`got ${JSON.stringify(e.ignore_last_delimiters)}`],e);if(e.ignore_last_delimiters===!0&&e.columns===!1)throw new wt("CSV_IGNORE_LAST_DELIMITERS_REQUIRES_COLUMNS",["The option `ignore_last_delimiters`","requires the activation of the `columns` option"],e);if(e.info===void 0||e.info===null||e.info===!1)e.info=!1;else if(e.info!==!0)throw new Error(`Invalid Option: info must be true, got ${JSON.stringify(e.info)}`);if(e.max_record_size===void 0||e.max_record_size===null||e.max_record_size===!1)e.max_record_size=0;else if(!(Number.isInteger(e.max_record_size)&&e.max_record_size>=0))if(typeof e.max_record_size=="string"&&/\d+/.test(e.max_record_size))e.max_record_size=parseInt(e.max_record_size);else throw new Error(`Invalid Option: max_record_size must be a positive integer, got ${JSON.stringify(e.max_record_size)}`);if(e.objname===void 0||e.objname===null||e.objname===!1)e.objname=void 0;else if(Un(e.objname)){if(e.objname.length===0)throw new Error("Invalid Option: objname must be a non empty buffer");e.encoding===null||(e.objname=e.objname.toString(e.encoding))}else if(typeof e.objname=="string"){if(e.objname.length===0)throw new Error("Invalid Option: objname must be a non empty string")}else if(typeof e.objname!="number")throw new Error(`Invalid Option: objname must be a string or a buffer, got ${e.objname}`);if(e.objname!==void 0){if(typeof e.objname=="number"){if(e.columns!==!1)throw Error("Invalid Option: objname index cannot be combined with columns or be defined as a field")}else if(e.columns===!1)throw Error("Invalid Option: objname field must be combined with columns or be defined as an index")}if(e.on_record===void 0||e.on_record===null)e.on_record=void 0;else if(typeof e.on_record!="function")throw new wt("CSV_INVALID_OPTION_ON_RECORD",["Invalid option `on_record`:","expect a function,",`got ${JSON.stringify(e.on_record)}`],e);if(e.quote===null||e.quote===!1||e.quote==="")e.quote=null;else if(e.quote===void 0||e.quote===!0?e.quote=ne.from('"',e.encoding):typeof e.quote=="string"&&(e.quote=ne.from(e.quote,e.encoding)),!Un(e.quote))throw new Error(`Invalid Option: quote must be a buffer or a string, got ${JSON.stringify(e.quote)}`);if(e.raw===void 0||e.raw===null||e.raw===!1)e.raw=!1;else if(e.raw!==!0)throw new Error(`Invalid Option: raw must be true, got ${JSON.stringify(e.raw)}`);if(e.record_delimiter===void 0)e.record_delimiter=[];else if(typeof e.record_delimiter=="string"||Un(e.record_delimiter)){if(e.record_delimiter.length===0)throw new wt("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer,",`got ${JSON.stringify(e.record_delimiter)}`],e);e.record_delimiter=[e.record_delimiter]}else if(!Array.isArray(e.record_delimiter))throw new wt("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer,",`got ${JSON.stringify(e.record_delimiter)}`],e);if(e.record_delimiter=e.record_delimiter.map(function(i,s){if(typeof i!="string"&&!Un(i))throw new wt("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a string, a buffer or array of string|buffer",`at index ${s},`,`got ${JSON.stringify(i)}`],e);if(i.length===0)throw new wt("CSV_INVALID_OPTION_RECORD_DELIMITER",["Invalid option `record_delimiter`:","value must be a non empty string or buffer",`at index ${s},`,`got ${JSON.stringify(i)}`],e);return typeof i=="string"&&(i=ne.from(i,e.encoding)),i}),typeof e.relax_column_count!="boolean")if(e.relax_column_count===void 0||e.relax_column_count===null)e.relax_column_count=!1;else throw new Error(`Invalid Option: relax_column_count must be a boolean, got ${JSON.stringify(e.relax_column_count)}`);if(typeof e.relax_column_count_less!="boolean")if(e.relax_column_count_less===void 0||e.relax_column_count_less===null)e.relax_column_count_less=!1;else throw new Error(`Invalid Option: relax_column_count_less must be a boolean, got ${JSON.stringify(e.relax_column_count_less)}`);if(typeof e.relax_column_count_more!="boolean")if(e.relax_column_count_more===void 0||e.relax_column_count_more===null)e.relax_column_count_more=!1;else throw new Error(`Invalid Option: relax_column_count_more must be a boolean, got ${JSON.stringify(e.relax_column_count_more)}`);if(typeof e.relax_quotes!="boolean")if(e.relax_quotes===void 0||e.relax_quotes===null)e.relax_quotes=!1;else throw new Error(`Invalid Option: relax_quotes must be a boolean, got ${JSON.stringify(e.relax_quotes)}`);if(typeof e.skip_empty_lines!="boolean")if(e.skip_empty_lines===void 0||e.skip_empty_lines===null)e.skip_empty_lines=!1;else throw new Error(`Invalid Option: skip_empty_lines must be a boolean, got ${JSON.stringify(e.skip_empty_lines)}`);if(typeof e.skip_records_with_empty_values!="boolean")if(e.skip_records_with_empty_values===void 0||e.skip_records_with_empty_values===null)e.skip_records_with_empty_values=!1;else throw new Error(`Invalid Option: skip_records_with_empty_values must be a boolean, got ${JSON.stringify(e.skip_records_with_empty_values)}`);if(typeof e.skip_records_with_error!="boolean")if(e.skip_records_with_error===void 0||e.skip_records_with_error===null)e.skip_records_with_error=!1;else throw new Error(`Invalid Option: skip_records_with_error must be a boolean, got ${JSON.stringify(e.skip_records_with_error)}`);if(e.rtrim===void 0||e.rtrim===null||e.rtrim===!1)e.rtrim=!1;else if(e.rtrim!==!0)throw new Error(`Invalid Option: rtrim must be a boolean, got ${JSON.stringify(e.rtrim)}`);if(e.ltrim===void 0||e.ltrim===null||e.ltrim===!1)e.ltrim=!1;else if(e.ltrim!==!0)throw new Error(`Invalid Option: ltrim must be a boolean, got ${JSON.stringify(e.ltrim)}`);if(e.trim===void 0||e.trim===null||e.trim===!1)e.trim=!1;else if(e.trim!==!0)throw new Error(`Invalid Option: trim must be a boolean, got ${JSON.stringify(e.trim)}`);if(e.trim===!0&&n.ltrim!==!1?e.ltrim=!0:e.ltrim!==!0&&(e.ltrim=!1),e.trim===!0&&n.rtrim!==!1?e.rtrim=!0:e.rtrim!==!0&&(e.rtrim=!1),e.to===void 0||e.to===null)e.to=-1;else if(typeof e.to=="string"&&/\d+/.test(e.to)&&(e.to=parseInt(e.to)),Number.isInteger(e.to)){if(e.to<=0)throw new Error(`Invalid Option: to must be a positive integer greater than 0, got ${JSON.stringify(n.to)}`)}else throw new Error(`Invalid Option: to must be an integer, got ${JSON.stringify(n.to)}`);if(e.to_line===void 0||e.to_line===null)e.to_line=-1;else if(typeof e.to_line=="string"&&/\d+/.test(e.to_line)&&(e.to_line=parseInt(e.to_line)),Number.isInteger(e.to_line)){if(e.to_line<=0)throw new Error(`Invalid Option: to_line must be a positive integer greater than 0, got ${JSON.stringify(n.to_line)}`)}else throw new Error(`Invalid Option: to_line must be an integer, got ${JSON.stringify(n.to_line)}`);return e},w1=function(n){return n.every(e=>e==null||e.toString&&e.toString().trim()==="")},ZP=13,QP=10,bo={utf8:ne.from([239,187,191]),utf16le:ne.from([255,254])},e8=function(n={}){const e={bytes:0,comment_lines:0,empty_lines:0,invalid_field_length:0,lines:1,records:0},t=v1(n);return{info:e,original_options:n,options:t,state:$P(t),__needMoreData:function(i,s,r){if(r)return!1;const{encoding:o,escape:l,quote:a}=this.options,{quoting:u,needMoreDataSize:c,recordDelimiterMaxLength:f}=this.state,h=s-i-1,d=Math.max(c,f===0?ne.from(`\r -`,o).length:f,u?(l===null?0:l.length)+a.length:0,u?a.length+f:0);return h_){this.state.stop=!0,o();return}this.state.quoting===!1&&T.length===0&&this.__autoDiscoverRecordDelimiter(O,M)&&(T=this.options.record_delimiter);const L=O[M];if(h===!0&&R.append(L),(L===ZP||L===QP)&&this.state.wasRowDelimiter===!1&&(this.state.wasRowDelimiter=!0),this.state.escaping===!0)this.state.escaping=!1;else{if(y!==null&&this.state.quoting===!0&&this.__isEscape(O,M,L)&&M+y.lengthbo[J].equals(this.state.field.toString())?J:!1).filter(Boolean)[0],Q=this.__error(new wt("INVALID_OPENING_QUOTE",["Invalid Opening Quote:",`a quote is found on field ${JSON.stringify(q.column)} at line ${q.lines}, value is ${JSON.stringify(this.state.field.toString(a))}`,K?`(${K} bom)`:void 0],this.options,q,{field:this.state.field}));if(Q!==void 0)return Q}}else{this.state.quoting=!0,M+=k.length-1;continue}if(this.state.quoting===!1){const q=this.__isRecordDelimiter(L,O,M);if(q!==0){if(this.state.commenting&&this.state.wasQuoting===!1&&this.state.record.length===0&&this.state.field.length===0)this.info.comment_lines++;else{if(this.state.enabled===!1&&this.info.lines+(this.state.wasRowDelimiter===!0?1:0)>=u){this.state.enabled=!0,this.__resetField(),this.__resetRecord(),M+=q-1;continue}if(g===!0&&this.state.wasQuoting===!1&&this.state.record.length===0&&this.state.field.length===0){this.info.empty_lines++,M+=q-1;continue}this.info.bytes=this.state.bufBytesStart+M;const ce=this.__onField();if(ce!==void 0)return ce;this.info.bytes=this.state.bufBytesStart+M+q;const pe=this.__onRecord(r);if(pe!==void 0)return pe;if(m!==-1&&this.info.records>=m){this.state.stop=!0,o();return}}this.state.commenting=!1,M+=q-1;continue}if(this.state.commenting)continue;if((b===null?0:this.__compareBytes(b,O,M,L))!==0){this.state.commenting=!0;continue}const Q=this.__isDelimiter(O,M,L);if(Q!==0){this.info.bytes=this.state.bufBytesStart+M;const J=this.__onField();if(J!==void 0)return J;M+=Q-1;continue}}}if(this.state.commenting===!1&&f!==0&&this.state.record_length+this.state.field.length>f)return this.__error(new wt("CSV_MAX_RECORD_SIZE",["Max Record Size:","record exceed the maximum number of tolerated bytes",`of ${f}`,`at line ${this.info.lines}`],this.options,this.__infoField()));const V=c===!1||this.state.quoting===!0||this.state.field.length!==0||!this.__isCharTrimable(O,M),X=p===!1||this.state.wasQuoting===!1;if(V===!0&&X===!0)this.state.field.append(L);else{if(p===!0&&!this.__isCharTrimable(O,M))return this.__error(new wt("CSV_NON_TRIMABLE_CHAR_AFTER_CLOSING_QUOTE",["Invalid Closing Quote:","found non trimable byte after quote",`at line ${this.info.lines}`],this.options,this.__infoField()));V===!1&&(M+=this.__isCharTrimable(O,M)-1);continue}}if(s===!0)if(this.state.quoting===!0){const L=this.__error(new wt("CSV_QUOTE_NOT_CLOSED",["Quote Not Closed:",`the parsing is finished with an opening quote at line ${this.info.lines}`],this.options,this.__infoField()));if(L!==void 0)return L}else if(this.state.wasQuoting===!0||this.state.record.length!==0||this.state.field.length!==0){this.info.bytes=this.state.bufBytesStart+M;const L=this.__onField();if(L!==void 0)return L;const V=this.__onRecord(r);if(V!==void 0)return V}else this.state.wasRowDelimiter===!0?this.info.empty_lines++:this.state.commenting===!0&&this.info.comment_lines++;else this.state.bufBytesStart+=M,this.state.previousBuf=O.slice(M);this.state.wasRowDelimiter===!0&&(this.info.lines++,this.state.wasRowDelimiter=!1)},__onRecord:function(i){const{columns:s,group_columns_by_name:r,encoding:o,info:l,from:a,relax_column_count:u,relax_column_count_less:c,relax_column_count_more:f,raw:h,skip_records_with_empty_values:d}=this.options,{enabled:p,record:g}=this.state;if(p===!1)return this.__resetRecord();const m=g.length;if(s===!0){if(d===!0&&w1(g)){this.__resetRecord();return}return this.__firstLineToColumns(g)}if(s===!1&&this.info.records===0&&(this.state.expectedRecordLength=m),m!==this.state.expectedRecordLength){const _=s===!1?new wt("CSV_RECORD_INCONSISTENT_FIELDS_LENGTH",["Invalid Record Length:",`expect ${this.state.expectedRecordLength},`,`got ${m} on line ${this.info.lines}`],this.options,this.__infoField(),{record:g}):new wt("CSV_RECORD_INCONSISTENT_COLUMNS",["Invalid Record Length:",`columns length is ${s.length},`,`got ${m} on line ${this.info.lines}`],this.options,this.__infoField(),{record:g});if(u===!0||c===!0&&mthis.state.expectedRecordLength)this.info.invalid_field_length++,this.state.error=_;else{const b=this.__error(_);if(b)return b}}if(d===!0&&w1(g)){this.__resetRecord();return}if(this.state.recordHasError===!0){this.__resetRecord(),this.state.recordHasError=!1;return}if(this.info.records++,a===1||this.info.records>=a){const{objname:_}=this.options;if(s!==!1){const b={};for(let y=0,k=g.length;y{const{timchars:a}=this.state;e:for(let u=0;u=0},__compareBytes:function(i,s,r,o){if(i[0]!==o)return 0;const l=i.length;for(let a=1;athis.state.record.length?i[this.state.record.length].name:null:this.state.record.length,quoting:this.state.wasQuoting}}}},t8=function(n,e={}){typeof n=="string"&&(n=ne.from(n));const t=e&&e.objname?{}:[],i=e8(e),s=a=>{i.options.objname===void 0?t.push(a):t[a[0]]=a[1]},r=()=>{},o=i.parse(n,!1,s,r);if(o!==void 0)throw o;const l=i.parse(void 0,!0,s,r);if(l!==void 0)throw l;return t},NS={[0]:{name:"general",color:"lightblue"},[1]:{name:"artist",color:"red"},[3]:{name:"copyright",color:"lightpurple"},[4]:{name:"character",color:"green"}},i8=Object.values(NS).flatMap(n=>[[`.cm-autocompletion-${n.name}`,{color:n.color+" !important"}]]).reduce((n,e)=>(n[e[0]]=e[1],n),{});function k1(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function n8(n){if(!n||!isNaN(n))return"";let e;return n>=1e6||n>=1e3&&n<1e4?e=Intl.NumberFormat("en",{notation:"compact",minimumFractionDigits:1,maximumFractionDigits:1}):e=Intl.NumberFormat("en",{notation:"compact"}),e.format(n)}const nr=class{constructor(){P(this,"tags",[]);P(this,"tagsByCategory",{});P(this,"aliases",{})}static get instance(){return nr._instance||(nr._instance=new nr),nr._instance}async load(e=!1){if(this.tags.length>0&&!e)return;this.tags=[];const t=i=>({text:i[0],category:parseInt(i[1]),count:parseInt(i[2]),aliases:i[3].split(",")});await _E(async()=>{const s=await(await fetch("/extra/danbooru.csv")).text(),o=t8(s,{delimiter:","}).map(t);this.tags=o})}autocomplete(e){let t=Bi(e.state).resolveInner(e.pos,-1),i=e.state.sliceDoc(t.from,e.pos);if(/:[0-9.]+$/.exec(i))return null;let r=/\b[a-zA-Z0-9_()-]+$/.exec(i);if(!r)return null;let o=r[0],l;o.startsWith("*")?(o=o.slice(1),l=new RegExp(`${k1(o)}`,"i")):l=new RegExp(`(^|[^a-zA-Z])${k1(o)}`,"i");const a=h=>{let d=h.replaceAll("_"," ");return d=d.replaceAll("(","\\(").replaceAll(")","\\)").replaceAll("[","\\[").replaceAll("]","\\]"),d},u=(h,d,p,g)=>{const m=a(d.label);h.dispatch(eS(h.state,m,p,g))},c=h=>h.text.toLowerCase().search(l)>-1,f=this.tags.filter(c).map(h=>{var p;const d=((p=NS[h.category])==null?void 0:p.name)||"unknown";return{label:h.text,apply:u,detail:n8(h.count),type:d,section:"Tags"}});return{from:r?t.from+r.index:e.pos,options:f,validFor:/^\b([\w_()-]+)?$/}}static getCompletionExt(){const e=nr.instance.autocomplete.bind(nr.instance);return QR({override:[e],interactionDelay:250,optionClass:i=>`cm-autocompletion-${i.type}`})}};let zl=nr;P(zl,"_instance");class wc{constructor(e,t,i,s,r,o,l,a,u,c=0,f){this.p=e,this.stack=t,this.state=i,this.reducePos=s,this.pos=r,this.score=o,this.buffer=l,this.bufferBase=a,this.curContext=u,this.lookAhead=c,this.parent=f}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,i=0){let s=e.parser.context;return new wc(e,[],t,i,i,0,[],0,s?new S1(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let i=e>>19,s=e&65535,{parser:r}=this.p,o=r.dynamicPrecedence(s);if(o&&(this.score+=o),i==0){this.pushState(r.getGoto(this.state,s,!0),this.reducePos),s=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(a==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSizel;)this.stack.pop();this.reduceContext(s,a)}storeNode(e,t,i,s=4,r=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&o.buffer[l-4]==0&&o.buffer[l-1]>-1){if(t==i)return;if(o.buffer[l-2]>=t){o.buffer[l-2]=i;return}}}if(!r||this.pos==i)this.buffer.push(e,t,i,s);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0)for(;o>0&&this.buffer[o-2]>i;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,s>4&&(s-=4);this.buffer[o]=e,this.buffer[o+1]=t,this.buffer[o+2]=i,this.buffer[o+3]=s}}shift(e,t,i){let s=this.pos;if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(t,s),t<=this.p.parser.maxNode&&this.buffer.push(t,s,i,4);else{let r=e,{parser:o}=this.p;(i>this.pos||t<=o.maxNode)&&(this.pos=i,o.stateFlag(r,1)||(this.reducePos=i)),this.pushState(r,s),this.shiftContext(t,s),t<=o.maxNode&&this.buffer.push(t,s,i,4)}}apply(e,t,i){e&65536?this.reduce(e):this.shift(e,t,i)}useNode(e,t){let i=this.p.reused.length-1;(i<0||this.p.reused[i]!=e)&&(this.p.reused.push(e),i++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(i,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let i=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new wc(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,i,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let i=e<=this.p.parser.maxNode;i&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,i?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new s8(this);;){let i=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(i==0)return!1;if(!(i&65536))return!0;t.reduce(i)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let s=[];for(let r=0,o;ra&1&&l==o)||s.push(t[r],o)}t=s}let i=[];for(let s=0;s>19,s=t&65535,r=this.stack.length-i*3;if(r<0||e.getGoto(this.stack[r],s,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;t=o}this.storeNode(0,this.reducePos,this.reducePos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],i=(s,r)=>{if(!t.includes(s))return t.push(s),e.allActions(s,o=>{if(!(o&393216))if(o&65536){let l=(o>>19)-r;if(l>1){let a=o&65535,u=this.stack.length-l*3;if(u>=0&&e.getGoto(this.stack[u],a,!1)>=0)return l<<19|65536|a}}else{let l=i(o,r+1);if(l!=null)return l}})};return i(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;tthis.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class S1{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}var T1;(function(n){n[n.Insert=200]="Insert",n[n.Delete=190]="Delete",n[n.Reduce=100]="Reduce",n[n.MaxNext=4]="MaxNext",n[n.MaxInsertStackDepth=300]="MaxInsertStackDepth",n[n.DampenInsertStackDepth=120]="DampenInsertStackDepth",n[n.MinBigReduction=2e3]="MinBigReduction"})(T1||(T1={}));class s8{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,i=e>>19;i==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(i-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}}class kc{constructor(e,t,i){this.stack=e,this.pos=t,this.index=i,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new kc(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new kc(this.stack,this.pos,this.index)}}function xl(n,e=Uint16Array){if(typeof n!="string")return n;let t=null;for(let i=0,s=0;i=92&&o--,o>=34&&o--;let a=o-32;if(a>=46&&(a-=46,l=!0),r+=a,l)break;r*=46}t?t[s++]=r:t=new e(r)}return t}class Su{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const C1=new Su;class r8{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=C1,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let i=this.range,s=this.rangeIndex,r=this.pos+e;for(;ri.to:r>=i.to;){if(s==this.ranges.length-1)return null;let o=this.ranges[++s];r+=o.from-i.to,i=o}return r}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,i,s;if(t>=0&&t=this.chunk2Pos&&il.to&&(this.chunk2=this.chunk2.slice(0,l.to-i)),s=this.chunk2.charCodeAt(0)}}return i>=this.token.lookAhead&&(this.token.lookAhead=i+1),s}acceptToken(e,t=0){let i=t?this.resolveOffset(t,-1):this.pos;if(i==null||i=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=C1,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let i="";for(let s of this.ranges){if(s.from>=t)break;s.to>e&&(i+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return i}}class Ho{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:i}=t.p;xS(this.data,e,t,this.id,i.data,i.tokenPrecTable)}}Ho.prototype.contextual=Ho.prototype.fallback=Ho.prototype.extend=!1;class DS{constructor(e,t,i){this.precTable=t,this.elseToken=i,this.data=typeof e=="string"?xl(e):e}token(e,t){let i=e.pos,s=0;for(;;){let r=e.resolveOffset(1,-1);if(xS(this.data,e,t,0,this.data,this.precTable),e.token.value>-1)break;if(this.elseToken==null)return;if(r==null)break;e.reset(r,e.token),s++}s&&(e.reset(i,e.token),e.acceptToken(this.elseToken,s))}}DS.prototype.contextual=Ho.prototype.fallback=Ho.prototype.extend=!1;function xS(n,e,t,i,s,r){let o=0,l=1<0){let p=n[d];if(a.allows(p)&&(e.token.value==-1||e.token.value==p||o8(p,e.token.value,s,r))){e.acceptToken(p);break}}let c=e.next,f=0,h=n[o+2];if(e.next<0&&h>f&&n[u+h*3-3]==65535&&n[u+h*3-3]==65535){o=n[u+h*3-1];continue e}for(;f>1,p=u+d+(d<<1),g=n[p],m=n[p+1]||65536;if(c=m)f=d+1;else{o=n[p+2],e.advance();continue e}}break}}function I1(n,e,t){for(let i=e,s;(s=n[i])!=65535;i++)if(s==t)return i-e;return-1}function o8(n,e,t,i){let s=I1(t,i,e);return s<0||I1(t,i,n)e)&&!i.type.isError)return t<0?Math.max(0,Math.min(i.to-1,e-25)):Math.min(n.length,Math.max(i.from+1,e+25));if(t<0?i.prevSibling():i.nextSibling())break;if(!i.parent())return t<0?0:n.length}}class l8{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?A1(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?A1(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=o,null;if(r instanceof ci){if(o==e){if(o=Math.max(this.safeFrom,e)&&(this.trees.push(r),this.start.push(o),this.index.push(0))}else this.index[t]++,this.nextStart=o+r.length}}}class a8{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(i=>new Su)}getActions(e){let t=0,i=null,{parser:s}=e.p,{tokenizers:r}=s,o=s.stateSlot(e.state,3),l=e.curContext?e.curContext.hash:0,a=0;for(let u=0;uf.end+25&&(a=Math.max(f.lookAhead,a)),f.value!=0)){let h=t;if(f.extended>-1&&(t=this.addActions(e,f.extended,f.end,t)),t=this.addActions(e,f.value,f.end,t),!c.extend&&(i=f,t>h))break}}for(;this.actions.length>t;)this.actions.pop();return a&&e.setLookAhead(a),!i&&e.pos==this.stream.end&&(i=new Su,i.value=e.p.parser.eofTerm,i.start=i.end=e.pos,t=this.addActions(e,i.value,i.end,t)),this.mainToken=i,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new Su,{pos:i,p:s}=e;return t.start=i,t.end=Math.min(i+1,s.stream.end),t.value=i==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,i){let s=this.stream.clipPos(i.pos);if(t.token(this.stream.reset(s,e),i),e.value>-1){let{parser:r}=i.p;for(let o=0;o=0&&i.p.parser.dialect.allows(l>>1)){l&1?e.extended=l>>1:e.value=l>>1;break}}}else e.value=0,e.end=this.stream.clipPos(s+1)}putAction(e,t,i,s){for(let r=0;re.bufferLength*4?new l8(i,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,i=this.stacks=[],s,r;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;ot)i.push(l);else{if(this.advanceStack(l,i,e))continue;{s||(s=[],r=[]),s.push(l);let a=this.tokens.getMainToken(l);r.push(a.value,a.end)}}break}}if(!i.length){let o=s&&f8(s);if(o)return this.stackToTree(o);if(this.parser.strict)throw new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&s){let o=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,r,i);if(o)return this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(i.length>o)for(i.sort((l,a)=>a.score-l.score);i.length>o;)i.pop();i.some(l=>l.reducePos>t)&&this.recovering--}else if(i.length>1){e:for(let o=0;o500&&u.buffer.length>500)if((l.score-u.score||l.buffer.length-u.buffer.length)>0)i.splice(a--,1);else{i.splice(o--,1);continue e}}}i.length>12&&i.splice(12,i.length-12)}this.minStackPos=i[0].pos;for(let o=1;othis.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let a=e.curContext&&e.curContext.tracker.strict,u=a?e.curContext.hash:0;for(let c=this.fragments.nodeAt(s);c;){let f=this.parser.nodeSet.types[c.type.id]==c.type?r.getGoto(e.state,c.type.id):-1;if(f>-1&&c.length&&(!a||(c.prop(rt.contextHash)||0)==u))return e.useNode(c,f),!0;if(!(c instanceof ci)||c.children.length==0||c.positions[0]>0)break;let h=c.children[0];if(h instanceof ci&&c.positions[0]==0)c=h;else break}}let o=r.stateSlot(e.state,4);if(o>0)return e.reduce(o),!0;if(e.stack.length>=15e3)for(;e.stack.length>9e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let a=0;as?t.push(d):i.push(d)}return!1}advanceFully(e,t){let i=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>i)return N1(e,t),!0}}runRecovery(e,t,i){let s=null,r=!1;for(let o=0;ol.pos?(u==l.pos&&(u++,a=0),l.recoverByDelete(a,u),N1(l,i)):(!s||s.scoree.topRules[l][1]),s=[];for(let l=0;l=0)r(c,a,l[u++]);else{let f=l[u+-c];for(let h=-c;h>0;h--)r(l[u++],a,f);u++}}}this.nodeSet=new eg(t.map((l,a)=>wn.define({name:a>=this.minRepeatTerm?void 0:l,id:a,props:s[a],top:i.indexOf(a)>-1,error:a==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(a)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=n2;let o=xl(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let l=0;ltypeof l=="number"?new Ho(o,l):l),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,i){let s=new u8(this,e,t,i);for(let r of this.wrappers)s=r(s,e,t,i);return s}getGoto(e,t,i=!1){let s=this.goto;if(t>=s[0])return-1;for(let r=s[t+1];;){let o=s[r++],l=o&1,a=s[r++];if(l&&i)return a;for(let u=r+(o>>1);r0}validAction(e,t){return!!this.allActions(e,i=>i==t?!0:null)}allActions(e,t){let i=this.stateSlot(e,4),s=i?t(i):void 0;for(let r=this.stateSlot(e,1);s==null;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Rs(this.data,r+2);else break;s=t(Rs(this.data,r+1))}return s}nextStates(e){let t=[];for(let i=this.stateSlot(e,1);;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Rs(this.data,i+2);else break;if(!(this.data[i+2]&1)){let s=this.data[i+1];t.some((r,o)=>o&1&&r==s)||t.push(this.data[i],s)}}return t}configure(e){let t=Object.assign(Object.create(Sc.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let i=this.topRules[e.top];if(!i)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=i}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(i=>{let s=e.tokenizers.find(r=>r.from==i);return s?s.to:i})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((i,s)=>{let r=e.specializers.find(l=>l.from==i.external);if(!r)return i;let o=Object.assign(Object.assign({},i),{external:r.to});return t.specializers[s]=D1(o),o})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),i=t.map(()=>!1);if(e)for(let r of e.split(" ")){let o=t.indexOf(r);o>=0&&(i[o]=!0)}let s=null;for(let r=0;ri)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scoren.external(t,i)<<1|e}return n.get}const h8=Sc.deserialize({version:14,states:"#YQ]QPOOPkOPOOOpQPO'#CeOOQO'#Co'#CoOOQO'#Cg'#CgQ]QPOOP!ROQO'#C^POOO)C>_)C>_OOQO,59P,59PO!^QPO,59POOQO-E6e-E6ePOOO'#Cf'#CfP!oOQO,58xPOOO,58x,58xOOQO1G.k1G.kPOOO-E6d-E6dPOOO1G.d1G.d",stateData:"!z~O^OSPOS_PQ~OSROTROUROWQO~O_UO~OSROTROUROVWOWQO~O`ZOaZOb]O~OSROTROUROV^OWQO~O`ZOaZOb`O~O",goto:"!UdPPePPPPPPhntPPPPPPP!ORVPXROQTXQ[UR_[QTOQXQTYTXXSOQTX",nodeNames:"⚠ LineComment BlockComment Program Identifier String Boolean ) ( Application",maxTerm:19,nodeProps:[["openedBy",7,"("],["closedBy",8,")"]],skippedNodes:[0,1,2,10],repeatNodeCount:2,tokenData:"%q~R^XY}YZ}]^}pq}rs!`st#|xy$[yz$a}!O$f!P!Q$z!Q![$f!c!}$f#R#S$f#T#o$f~!SS^~XY}YZ}]^}pq}~!cVOr!`rs!xs#O!`#O#P!}#P;'S!`;'S;=`#v<%lO!`~!}OT~~#QRO;'S!`;'S;=`#Z;=`O!`~#^WOr!`rs!xs#O!`#O#P!}#P;'S!`;'S;=`#v;=`<%l!`<%lO!`~#yP;=`<%l!`~$PQ#Y#Z$V#h#i$V~$[OU~~$aOW~~$fOV~~$kTS~}!O$f!Q![$f!c!}$f#R#S$f#T#o$f~$}Qz{%T!P!Q%Y~%YO_~~%_SP~OY%YZ;'S%Y;'S;=`%k<%lO%Y~%nP;=`<%l%Y",tokenizers:[1,new DS("j~RQYZXz{^~^Oa~~aP!P!Qd~iOb~~",25,16)],topRules:{Program:[0,3]},tokenPrec:0}),d8=hc.define({name:"ComfyUI",parser:h8.configure({props:[l2({LineComment:H.lineComment,BlockComment:H.blockComment})]}),languageData:{commentTokens:{line:"//",block:{open:"/*",close:"*/"}}}}),p8=(()=>[G3(),d3(),b4(),xM(),s3(),pt.allowMultipleSelections.of(!0),yM(),lg(PM,{fallback:!0}),HR(),T3(),E3(),He.lineWrapping,zl.getCompletionExt(),new aM(d8),Jp.of([...qR,...bR,...E4,...OM,...aS,...uP])])();function g8(n){let e=n[0].attrs.title+"",t;return{c(){t=ke(e)},m(i,s){A(i,t,s)},p(i,s){s&1&&e!==(e=i[0].attrs.title+"")&&je(t,e)},d(i){i&&E(t)}}}function m8(n){let e,t,i,s,r;return e=new kn({props:{$$slots:{default:[g8]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment),t=se(),i=z("div"),s=z("div"),v(s,"class","codemirror-wrapper "+b8+" svelte-1y013ij"),v(i,"class","wrap svelte-1y013ij")},m(o,l){G(e,o,l),A(o,t,l),A(o,i,l),F(i,s),n[7](s),r=!0},p(o,l){const a={};l&2097153&&(a.$$scope={dirty:l,ctx:o}),e.$set(a)},i(o){r||(S(e.$$.fragment,o),r=!0)},o(o){C(e.$$.fragment,o),r=!1},d(o){o&&(E(t),E(i)),j(e,o),n[7](null)}}}function _8(n){let e,t,i;return t=new yt({props:{$$slots:{default:[m8]},$$scope:{ctx:n}}}),{c(){e=z("div"),Y(t.$$.fragment),v(e,"class","code-editor-wrapper svelte-1y013ij")},m(s,r){A(s,e,r),G(t,e,null),i=!0},p(s,[r]){const o={};r&2097157&&(o.$$scope={dirty:r,ctx:s}),t.$set(o)},i(s){i||(S(t.$$.fragment,s),i=!0)},o(s){C(t.$$.fragment,s),i=!1},d(s){s&&E(e),j(t)}}}let b8="";function y8(n){var i;let e=n.dom.querySelectorAll(".cm-gutterElement");if(e.length===0)return null;for(var t=0;t(s(),s=ot(a,O=>t(6,i=O)),a);n.$$.on_destroy.push(()=>s());let{widget:o}=e,{node:l}=e,{nodeValue:a=Be("")}=e;r();let{extraExtensions:u=[]}=e,c=5,f,h;const d=mi();let p=He.theme({"&":{width:"100%",maxWidth:"100%",height:"12rem",fontSize:"var(--text-sm)",backgroundColor:"var(--input-background-fill)"},".cm-content":{paddingTop:"5px",paddingBottom:"5px",color:"var(--body-text-color)",fontFamily:"var(--font-mono)",minHeight:"100%"},".cm-gutters":{marginRight:"1px",borderRight:"1px solid var(--border-color-primary)",backgroundColor:"transparent",color:"var(--body-text-color-subdued)"},".cm-focused":{outline:"none"},".cm-scroller":{height:"auto"},".cm-cursor":{borderLeftColor:"var(--body-text-color)"},".cm-selectionBackground":{backgroundColor:"var(--secondary-600) !important"},".cm-tooltip":{backgroundColor:"var(--panel-background-fill) !important",border:"1px solid var(--panel-border-color) !important"},".cm-tooltip-autocomplete":{color:"var(--body-text-color) !important"},".cm-tooltip-autocomplete > ul > li[aria-selected]":{color:"unset"},...i8});sl(()=>(h=R(),()=>h==null?void 0:h.destroy()));function g(){h==null||h.dispatch({effects:dt.reconfigure.of(I())})}function m(O){h&&O!==h.state.doc.toString()&&h.dispatch({changes:{from:0,to:h.state.doc.length,insert:O}})}function _(O){h&&h.requestMeasure({read:b})}function b(O){return O.dom.querySelectorAll(".cm-gutter"),y8(O),null}function y(O){if(O.docChanged){const M=O.state.doc.toString();pi(a,i=M,i),d("change",M)}h.requestMeasure({read:b})}function k(O,D){const M=[He.editable.of(!O),pt.readOnly.of(O)];return M.push(p8),D&&M.push(v3(D)),M.push(He.updateListener.of(y)),M}function T(O){const D=[];return O?D.push(QM):D.push(l4),D}function I(){return[...k(!1,""),p,...T(!0),...u]}function x(O){return pt.create({doc:O??void 0,extensions:I()})}function R(){return new He({parent:f,state:x(i)})}function N(O){Ze[O?"unshift":"push"](()=>{f=O,t(2,f)})}return n.$$set=O=>{"widget"in O&&t(0,o=O.widget),"node"in O&&t(3,l=O.node),"nodeValue"in O&&r(t(1,a=O.nodeValue)),"extraExtensions"in O&&t(4,u=O.extraExtensions)},n.$$.update=()=>{var O;n.$$.dirty&8&&t(5,c=((O=l==null?void 0:l.properties)==null?void 0:O.lines)||5),n.$$.dirty&64&&m(i),n.$$.dirty&32&&_()},g(),[o,a,f,l,u,c,i,N]}class w8 extends _e{constructor(e){super(),me(this,e,v8,_8,ae,{widget:0,node:3,nodeValue:1,extraExtensions:4})}}function x1(n){let e,t,i,s;const r=[S8,k8],o=[];function l(a,u){return a[0].attrs.variant==="code"?0:1}return e=l(n),t=o[e]=r[e](n),{c(){t.c(),i=we()},m(a,u){o[e].m(a,u),A(a,i,u),s=!0},p(a,u){let c=e;e=l(a),e===c?o[e].p(a,u):(oe(),C(o[c],1,1,()=>{o[c]=null}),le(),t=o[e],t?t.p(a,u):(t=o[e]=r[e](a),t.c()),S(t,1),t.m(i.parentNode,i))},i(a){s||(S(t),s=!0)},o(a){C(t),s=!1},d(a){a&&E(i),o[e].d(a)}}}function k8(n){let e,t,i;function s(o){n[7](o)}let r={label:n[0].attrs.title,disabled:Kn(n[0]),lines:n[1].properties.multiline?n[1].properties.lines:1,max_lines:n[1].properties.multiline?n[1].properties.maxLines:1,show_label:n[0].attrs.title!==""};return n[4]!==void 0&&(r.value=n[4]),e=new dr({props:r}),Ze.push(()=>jt(e,"value",s)),e.$on("change",n[8]),e.$on("submit",n[9]),e.$on("blur",n[10]),e.$on("select",n[11]),{c(){Y(e.$$.fragment)},m(o,l){G(e,o,l),i=!0},p(o,l){const a={};l&1&&(a.label=o[0].attrs.title),l&1&&(a.disabled=Kn(o[0])),l&2&&(a.lines=o[1].properties.multiline?o[1].properties.lines:1),l&2&&(a.max_lines=o[1].properties.multiline?o[1].properties.maxLines:1),l&1&&(a.show_label=o[0].attrs.title!==""),!t&&l&16&&(t=!0,a.value=o[4],Gt(()=>t=!1)),e.$set(a)},i(o){i||(S(e.$$.fragment,o),i=!0)},o(o){C(e.$$.fragment,o),i=!1},d(o){j(e,o)}}}function S8(n){let e,t;return e=new w8({props:{widget:n[0],node:n[1],nodeValue:n[2]}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&1&&(r.widget=i[0]),s&2&&(r.node=i[1]),s&4&&(r.nodeValue=i[2]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function T8(n){let e,t,i=n[1]!==null&&n[2]!==null&&x1(n);return{c(){e=z("div"),i&&i.c(),v(e,"class","wrapper gradio-textbox svelte-1bwr6zx")},m(s,r){A(s,e,r),i&&i.m(e,null),t=!0},p(s,[r]){s[1]!==null&&s[2]!==null?i?(i.p(s,r),r&6&&S(i,1)):(i=x1(s),i.c(),S(i,1),i.m(e,null)):i&&(oe(),C(i,1,1,()=>{i=null}),le())},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d()}}}function C8(n,e,t){let i,s=Z,r=()=>(s(),s=ot(d,k=>t(6,i=k)),d),o,l=Z,a=()=>(l(),l=ot(h,k=>t(4,o=k)),h);n.$$.on_destroy.push(()=>s()),n.$$.on_destroy.push(()=>l());let{widget:u=null}=e,{isMobile:c=!1}=e,f=null,h=null;a();let d=null;r();function p(k){k&&(t(1,f=k.node),a(t(2,h=f.value)),r(t(3,d=f.propsChanged)))}function g(k){o=k,h.set(o)}function m(k){Ut.call(this,n,k)}function _(k){Ut.call(this,n,k)}function b(k){Ut.call(this,n,k)}function y(k){Ut.call(this,n,k)}return n.$$set=k=>{"widget"in k&&t(0,u=k.widget),"isMobile"in k&&t(5,c=k.isMobile)},n.$$.update=()=>{n.$$.dirty&1&&u&&p(u),n.$$.dirty&71&&h!==null&&(!i||i)&&(p(u),t(1,f),t(2,h),t(6,i),t(0,u))},[u,f,h,d,o,c,i,g,m,_,b,y]}class I8 extends _e{constructor(e){super(),me(this,e,C8,T8,ae,{widget:0,isMobile:5})}}class yg extends As{constructor(t){super(t,"");P(this,"properties",{tags:[],defaultValue:"",multiline:!1,lines:5,maxLines:5});P(this,"inputSlotName","value");P(this,"svelteComponentType",I8);P(this,"defaultValue","")}parseValue(t){return`${t}`}}P(yg,"slotLayout",{inputs:[{name:"value",type:"string"},{name:"store",type:$.ACTION}],outputs:[{name:"value",type:"string"},{name:"changed",type:$.EVENT}]});w.registerNodeType({class:yg,title:"UI.Text",desc:"Textbox outputting a string value",type:"ui/text"});const{window:E8}=KT;function L1(n,e,t){const i=n.slice();i[42]=e[t],i[45]=t;const s=i[8]===i[45];return i[43]=s,i}function A8(n){const e=n.slice(),t=e[2][e[8]];return e[41]=t,e}function _h(n){const e=n.slice(),t=e[0].attrs.title;return e[46]=t,e}function M1(n){let e,t;return e=new Qc({props:{label:n[46],show_label:n[46]!="",Icon:uA,float:n[46]!=""}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s[0]&1&&(r.label=i[46]),s[0]&1&&(r.show_label=i[46]!=""),s[0]&1&&(r.float=i[46]!=""),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function O8(n){let e;return{c(){e=z("div"),e.innerHTML='(No regions)',v(e,"class","regions-empty svelte-4pq7qz")},m(t,i){A(t,e,i)},p:Z,i:Z,o:Z,d(t){t&&E(e)}}}function N8(n){let e,t,i,s=`${n[12]?n[9]*100:100}%`,r,o,l,a,u,c=Xe(n[11]),f=[];for(let d=0;d{h=null}),le())},i(d){u||(S(h),u=!0)},o(d){C(h),u=!1},d(d){d&&(E(e),E(l),E(a)),n[24](null),n[25](null),zi(f,d),h&&h.d(d)}}}function R1(n){let e,t,i,s=`${n[42].xPx}px`,r=`${n[42].yPx}px`,o=`${n[42].widthPx}px`,l=`${n[42].heightPx}px`,a,u;function c(...f){return n[26](n[45],...f)}return{c(){e=z("div"),t=z("span"),t.textContent="Warning: Region very large!",i=se(),v(t,"class","tip svelte-4pq7qz"),ve(t,"display",n[42].warnLargeSize?"block":"none"),v(e,"class","region svelte-4pq7qz"),ve(e,"left",s),ve(e,"top",r),ve(e,"width",o),ve(e,"height",l),ve(e,"background",n[42].bgColor),ve(e,"border-style",n[43]?"solid":"dotted"),ve(e,"border-color",n[42].borderColor),ve(e,"display","block"),ve(e,"opacity",n[43]?"100%":"40%"),ve(e,"z-index",n[43]?"var(--layer-3)":"var(--layer-2)")},m(f,h){A(f,e,h),F(e,t),F(e,i),a||(u=[ee(e,"mousemove",F8),ee(e,"mousedown",c)],a=!0)},p(f,h){n=f,h[0]&2048&&ve(t,"display",n[42].warnLargeSize?"block":"none"),h[0]&2048&&s!==(s=`${n[42].xPx}px`)&&ve(e,"left",s),h[0]&2048&&r!==(r=`${n[42].yPx}px`)&&ve(e,"top",r),h[0]&2048&&o!==(o=`${n[42].widthPx}px`)&&ve(e,"width",o),h[0]&2048&&l!==(l=`${n[42].heightPx}px`)&&ve(e,"height",l),h[0]&2048&&ve(e,"background",n[42].bgColor),h[0]&256&&ve(e,"border-style",n[43]?"solid":"dotted"),h[0]&2048&&ve(e,"border-color",n[42].borderColor),h[0]&256&&ve(e,"opacity",n[43]?"100%":"40%"),h[0]&256&&ve(e,"z-index",n[43]?"var(--layer-3)":"var(--layer-2)")},d(f){f&&E(e),a=!1,lt(u)}}}function P1(n){let e,t;return e=new yt({props:{$$slots:{default:[R8]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s[0]&4868|s[1]&65536&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function D8(n){let e,t;return e=new Ko({props:{label:"Region #",value:n[8]+1,show_label:!0,minimum:1,maximum:n[2].length,step:1}}),e.$on("change",n[27]),e.$on("release",n[20]),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s[0]&256&&(r.value=i[8]+1),s[0]&4&&(r.maximum=i[2].length),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function x8(n){let e,t,i,s;return e=new Ko({props:{label:"X",value:n[41][0],show_label:!0,minimum:0,maximum:1,step:.01}}),e.$on("change",n[28]),e.$on("release",n[20]),i=new Ko({props:{label:"Width",value:n[41][2],show_label:!0,minimum:0,maximum:1,step:.01}}),i.$on("change",n[29]),i.$on("release",n[20]),{c(){Y(e.$$.fragment),t=se(),Y(i.$$.fragment)},m(r,o){G(e,r,o),A(r,t,o),G(i,r,o),s=!0},p(r,o){const l={};o[0]&260&&(l.value=r[41][0]),e.$set(l);const a={};o[0]&260&&(a.value=r[41][2]),i.$set(a)},i(r){s||(S(e.$$.fragment,r),S(i.$$.fragment,r),s=!0)},o(r){C(e.$$.fragment,r),C(i.$$.fragment,r),s=!1},d(r){r&&E(t),j(e,r),j(i,r)}}}function L8(n){let e,t,i,s;return e=new Ko({props:{label:"Y",value:n[41][1],show_label:!0,minimum:0,maximum:1,step:.01}}),e.$on("change",n[30]),e.$on("release",n[20]),i=new Ko({props:{label:"Height",value:n[41][3],show_label:!0,minimum:0,maximum:1,step:.01}}),i.$on("change",n[31]),i.$on("release",n[20]),{c(){Y(e.$$.fragment),t=se(),Y(i.$$.fragment)},m(r,o){G(e,r,o),A(r,t,o),G(i,r,o),s=!0},p(r,o){const l={};o[0]&260&&(l.value=r[41][1]),e.$set(l);const a={};o[0]&260&&(a.value=r[41][3]),i.$set(a)},i(r){s||(S(e.$$.fragment,r),S(i.$$.fragment,r),s=!0)},o(r){C(e.$$.fragment,r),C(i.$$.fragment,r),s=!1},d(r){r&&E(t),j(e,r),j(i,r)}}}function B1(n){let e,t;return e=new Xr({props:{$$slots:{default:[M8]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s[0]&512|s[1]&65536&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function M8(n){let e,t,i;function s(o){n[32](o)}let r={label:"Image Opacity",show_label:!0,minimum:0,maximum:1,step:.01};return n[9]!==void 0&&(r.value=n[9]),e=new Ko({props:r}),Ze.push(()=>jt(e,"value",s)),{c(){Y(e.$$.fragment)},m(o,l){G(e,o,l),i=!0},p(o,l){const a={};!t&&l[0]&512&&(t=!0,a.value=o[9],Gt(()=>t=!1)),e.$set(a)},i(o){i||(S(e.$$.fragment,o),i=!0)},o(o){C(e.$$.fragment,o),i=!1},d(o){j(e,o)}}}function R8(n){let e,t,i,s,r,o,l,a;e=new Xr({props:{$$slots:{default:[D8]},$$scope:{ctx:n}}}),i=new Xr({props:{$$slots:{default:[x8]},$$scope:{ctx:n}}}),r=new Xr({props:{$$slots:{default:[L8]},$$scope:{ctx:n}}});let u=n[12]&&B1(n);return{c(){Y(e.$$.fragment),t=se(),Y(i.$$.fragment),s=se(),Y(r.$$.fragment),o=se(),u&&u.c(),l=we()},m(c,f){G(e,c,f),A(c,t,f),G(i,c,f),A(c,s,f),G(r,c,f),A(c,o,f),u&&u.m(c,f),A(c,l,f),a=!0},p(c,f){const h={};f[0]&260|f[1]&65536&&(h.$$scope={dirty:f,ctx:c}),e.$set(h);const d={};f[0]&260|f[1]&65536&&(d.$$scope={dirty:f,ctx:c}),i.$set(d);const p={};f[0]&260|f[1]&65536&&(p.$$scope={dirty:f,ctx:c}),r.$set(p),c[12]?u?(u.p(c,f),f[0]&4096&&S(u,1)):(u=B1(c),u.c(),S(u,1),u.m(l.parentNode,l)):u&&(oe(),C(u,1,1,()=>{u=null}),le())},i(c){a||(S(e.$$.fragment,c),S(i.$$.fragment,c),S(r.$$.fragment,c),S(u),a=!0)},o(c){C(e.$$.fragment,c),C(i.$$.fragment,c),C(r.$$.fragment,c),C(u),a=!1},d(c){c&&(E(t),E(s),E(o),E(l)),j(e,c),j(i,c),j(r,c),u&&u.d(c)}}}function P8(n){var f;let e,t,i,s,r,o=((f=n[0])==null?void 0:f.attrs.title)&&M1(_h(n));const l=[N8,O8],a=[];function u(h,d){return h[10]?0:1}function c(h,d){return d===0?A8(h):h}return t=u(n),i=a[t]=l[t](c(n,t)),{c(){o&&o.c(),e=se(),i.c(),s=we()},m(h,d){o&&o.m(h,d),A(h,e,d),a[t].m(h,d),A(h,s,d),r=!0},p(h,d){var g;(g=h[0])!=null&&g.attrs.title?o?(o.p(_h(h),d),d[0]&1&&S(o,1)):(o=M1(_h(h)),o.c(),S(o,1),o.m(e.parentNode,e)):o&&(oe(),C(o,1,1,()=>{o=null}),le());let p=t;t=u(h),t===p?a[t].p(c(h,t),d):(oe(),C(a[p],1,1,()=>{a[p]=null}),le(),i=a[t],i?i.p(c(h,t),d):(i=a[t]=l[t](c(h,t)),i.c()),S(i,1),i.m(s.parentNode,s))},i(h){r||(S(o),S(i),r=!0)},o(h){C(o),C(i),r=!1},d(h){h&&(E(e),E(s)),o&&o.d(h),a[t].d(h)}}}function z1(n){let e,t;return e=new yt({props:{$$slots:{default:[P8]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s[0]&7965|s[1]&65536&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function B8(n){var l;let e=(l=n[1])==null?void 0:l.properties.canvasWidth,t,i,s,r,o=z1(n);return{c(){o.c(),t=we()},m(a,u){o.m(a,u),A(a,t,u),i=!0,s||(r=ee(E8,"resize",n[14]),s=!0)},p(a,u){var c;u[0]&2&&ae(e,e=(c=a[1])==null?void 0:c.properties.canvasWidth)?(oe(),C(o,1,1,Z),le(),o=z1(a),o.c(),S(o,1),o.m(t.parentNode,t)):o.p(a,u)},i(a){i||(S(o),i=!0)},o(a){C(o),i=!1},d(a){a&&E(t),o.d(a),s=!1,r()}}}const z8=1280,hr=5,tu=5,Tl=3;function F8(n){const e=n.target,t=e.getBoundingClientRect(),i=n.clientX,s=n.clientY,r=i>=t.left&&i<=t.left+hr,o=i>=t.right-hr&&i<=t.right,l=s>=t.top&&s<=t.top+hr,a=s>=t.bottom-hr&&s<=t.bottom;r&&l||o&&a?e.style.cursor="nwse-resize":r&&a||o&&l?e.style.cursor="nesw-resize":r||o?e.style.cursor="ew-resize":l||a?e.style.cursor="ns-resize":e.style.cursor="move"}function W8(n,e,t){let i,s=Z,r=()=>(s(),s=ot(b,fe=>t(2,i=fe)),b),o,l=Z,a=()=>(l(),l=ot(k,fe=>t(22,o=fe)),k),u,c=Z,f=()=>(c(),c=ot(y,fe=>t(23,u=fe)),y);n.$$.on_destroy.push(()=>s()),n.$$.on_destroy.push(()=>l()),n.$$.on_destroy.push(()=>c());const h=[["#ff0000","rgba(255, 0, 0, 0.3)"],["#ff9900","rgba(255, 153, 0, 0.3)"],["#ffff00","rgba(255, 255, 0, 0.3)"],["#33cc33","rgba(51, 204, 51, 0.3)"],["#33cccc","rgba(51, 204, 204, 0.3)"],["#0066ff","rgba(0, 102, 255, 0.3)"],["#6600ff","rgba(102, 0, 255, 0.3)"],["#cc00cc","rgba(204, 0, 204, 0.3)"],["#ff6666","rgba(255, 102, 102, 0.3)"],["#ffcc66","rgba(255, 204, 102, 0.3)"],["#99cc00","rgba(153, 204, 0, 0.3)"],["#00cc99","rgba(0, 204, 153, 0.3)"],["#0099cc","rgba(0, 153, 204, 0.3)"],["#9933cc","rgba(153, 51, 204, 0.3)"],["#ff3399","rgba(255, 51, 153, 0.3)"],["#996633","rgba(153, 102, 51, 0.3)"]];let{widget:d=null}=e,{isMobile:p=!1}=e,g,m,_=null,b=Be([]);r();let y=Be(!1);f();let k=Be(!1);a();let T=0,I=1;function x(fe){fe&&(t(1,_=fe.node),r(t(5,b=_.value)),_.propsChanged,f(t(6,y=_.sizeChanged)),a(t(7,k=_.regionsChanged)),D())}let R=!1,N=[];async function O(fe,Te){return fe||(fe=_),Te||(Te=i),fe!=null&&m!=null&&g!=null?(t(8,T=yi(T,0,Te.length-1)),await L(fe.properties.canvasWidth,fe.properties.canvasHeight,fe.properties.canvasImageURL),Te.map((Ge,It)=>X(Ge,It,m))):[]}async function D(){if(_!=null)return L(_.properties.canvasWidth,_.properties.canvasHeight,_.properties.canvasImageURL).then(()=>O()).then(fe=>{t(11,N=fe)})}sl(async()=>{await D()});let M=!1;async function L(fe,Te,Ge){t(10,R=fe>0&&Te>0),t(12,M=Ge!=null),Ge==null&&(Ge=FE(fe,Te,"transparent").toDataURL());const It=await Lp(Ge);It.classList.add("regions-image"),g!=null&&g.replaceChildren(It),t(4,m=It),t(4,m.style.border=`${Tl}px solid var(--border-color-primary)`,m),pi(y,u=!1,u)}function V(fe,Te){pi(b,i[fe]=Te,i),t(11,N[fe]=X(Te,fe,m,N[fe]),N)}function X(fe,Te,Ge,It){const[Pt,ni,Xt,Fi]=fe,Ei=Math.min(Ge.clientWidth/Ge.naturalWidth,Ge.clientHeight/Ge.naturalHeight),hi=Ge.clientWidth/2,st=Ge.clientHeight/2,ei=Ge.naturalWidth*Ei,Wi=Ge.naturalHeight*Ei,ct=hi-ei/2+Tl,si=hi+ei/2+Tl,Tn=st-Wi/2+Tl,tn=st+Wi/2+Tl,Ce=ct+ei*Pt,tt=Tn+Wi*ni,vt=Math.min(ei*Xt,si-Ce),Kt=Math.min(Wi*Fi,tn-tt),cn=z8/1*Ei,Hi=cn/ei,Ks=cn/Wi,$s=Xt>Hi||Fi>Ks,[At,fn]=h[Te%h.length];return It||(It={}),It.xPx=Ce,It.yPx=tt,It.widthPx=vt,It.heightPx=Kt,It.warnLargeSize=$s,It.bgColor=fn,It.borderColor=At,It}function q(fe,Te){if(fe.button!==0)return;let Ge=i[Te];if(!m||!Ge)return;t(8,T=Te);const Pt=fe.target.getBoundingClientRect();let ni=fe.clientX,Xt=fe.clientY;const Fi=ni>=Pt.left&&ni<=Pt.left+hr,Ei=ni>=Pt.right-hr&&ni<=Pt.right,hi=Xt>=Pt.top&&Xt<=Pt.top+hr,st=Xt>=Pt.bottom-hr&&Xt<=Pt.bottom,ei=ni>=Pt.left+tu&&ni<=Pt.right-tu,Wi=Xt>=Pt.top+tu&&Xt<=Pt.bottom-tu;if(!Fi&&!Ei&&!hi&&!st&&!ei&&!Wi)return;const ct=Fi?Ge[0]+Ge[2]:Ge[0],si=hi?Ge[1]+Ge[3]:Ge[1];let Tn=Math.min(m.clientWidth/m.naturalWidth,m.clientHeight/m.naturalHeight),tn=m.getBoundingClientRect(),Ce=m.naturalWidth*Tn,tt=m.naturalHeight*Tn,vt=tn.left+window.scrollX+m.clientWidth/2,Kt=tn.top+window.scrollY+m.clientHeight/2,Vi=vt-Ce/2-window.scrollX,cn=vt+Ce/2-window.scrollX,Hi=Kt-tt/2-window.scrollY,Ks=Kt+tt/2-window.scrollY;ni=Math.min(Math.max(ni,Vi),cn),Xt=Math.min(Math.max(Xt,Hi),Ks);function $s(fn){fn.preventDefault();let Js=fn.clientX,Ns=fn.clientY;Js=Math.min(Math.max(Js,Vi),cn),Ns=Math.min(Math.max(Ns,Hi),Ks);const Ai=(Js-ni)/Ce,Ui=(Ns-Xt)/tt;if(ni=Js,Xt=Ns,Ai===0&&Ui===0)return;let[ri,$t,xt,Ot]=Ge;ei&&Wi?(ri=Math.min(Math.max(ri+Ai,0),1-xt),$t=Math.min(Math.max($t+Ui,0),1-Ot)):((Fi||Ei)&&(ri1&&(xt=1-ri)),(hi||st)&&($t1&&(Ot=1-$t)));const[cl,hn,uo]=i[Te];hn[0]===ri&&hn[1]===$t&&hn[2]===xt&&hn[3]===Ot||(Ge[0]=ri,Ge[1]=$t,Ge[2]=xt,Ge[3]=Ot,V(Te,Ge))}const At=()=>{document.removeEventListener("mousemove",$s),document.removeEventListener("mouseup",At),pi(k,o=!0,o),b.set(i)};document.addEventListener("mousemove",$s),document.addEventListener("mouseup",At)}async function K(){t(11,N=await O())}function Q(fe){t(8,T=yi(fe-1,0,i.length-1))}function J(fe){const Te=i[T],Ge=N[T];!Te||!Ge||(Te[0]=fe,t(11,N[T]=X(Te,T,m,Ge),N))}function ce(fe){const Te=i[T],Ge=N[T];!Te||!Ge||(Te[1]=fe,t(11,N[T]=X(Te,T,m,Ge),N))}function pe(fe){const Te=i[T],Ge=N[T];!Te||!Ge||(Te[2]=fe,t(11,N[T]=X(Te,T,m,Ge),N))}function qe(fe){const Te=i[T],Ge=N[T];!Te||!Ge||(Te[3]=fe,t(11,N[T]=X(Te,T,m,Ge),N))}async function Ae(){const fe=i[T],Te=N[T];fe&&Te&&(fe[2]=yi(fe[2],0,1),fe[3]=yi(fe[3],0,1),fe[0]=yi(fe[0],0,1-fe[2]),fe[1]=yi(fe[1],0,1-fe[3]),t(11,N[T]=X(fe,T,m,Te),N)),await D(),b.set(i)}function ue(fe){Ze[fe?"unshift":"push"](()=>{m=fe,t(4,m)})}function te(fe){Ze[fe?"unshift":"push"](()=>{g=fe,t(3,g)})}const be=(fe,Te)=>q(Te,fe),ge=fe=>Q(fe.detail),he=fe=>J(fe.detail),Se=fe=>pe(fe.detail),Je=fe=>ce(fe.detail),gt=fe=>qe(fe.detail);function Ii(fe){I=fe,t(9,I)}return n.$$set=fe=>{"widget"in fe&&t(0,d=fe.widget),"isMobile"in fe&&t(21,p=fe.isMobile)},n.$$.update=()=>{n.$$.dirty[0]&1&&d&&x(d),n.$$.dirty[0]&8388610&&_!=null&&u&&D(),n.$$.dirty[0]&4194310&&o&&(pi(k,o=!1,o),O(_,i).then(fe=>t(11,N=fe)))},[d,_,i,g,m,b,y,k,T,I,R,N,M,q,K,Q,J,ce,pe,qe,Ae,p,o,u,ue,te,be,ge,he,Se,Je,gt,Ii]}class V8 extends _e{constructor(e){super(),me(this,e,W8,B8,ae,{widget:0,isMobile:21},null,[-1,-1])}}function F1(n){return Array.isArray(n)&&n.length===4&&n.every(e=>typeof e=="number")}const bh=[.4,.4,.2,.2];class LS extends As{constructor(t){super(t,[[...bh]]);P(this,"properties",{tags:[],defaultValue:!1,regionCount:1,canvasWidth:512,canvasHeight:512,canvasImageURL:null,inputType:"size"});P(this,"svelteComponentType",V8);P(this,"defaultValue",[[...bh]]);P(this,"outputSlotName",null);P(this,"storeActionName","store");P(this,"changedEventName","changed");P(this,"sizeChanged",Be(!0));P(this,"regionsChanged",Be(!0));P(this,"inputTypeWidget");P(this,"regionCountWidget");P(this,"_prevWidth",null);P(this,"_prevHeight",null);P(this,"_prevImageURL",null);this.inputTypeWidget=this.addWidget("combo","Input Type",this.properties.inputType,"inputType",{values:["size","image"]}),this.regionCountWidget=this.addWidget("number","# of Regions",this.properties.regionCount,i=>{this.setProperty("regionCount",yi(i,1,16))},{min:1,max:16,step:1,precision:0})}onPropertyChanged(t,i){t==="regionCount"?this.updateRegions():t==="width"||t==="height"?this.updateSize():t==="inputType"&&this.updateInputType()}onExecute(){let t=0,i=0,s=null;if(this.updateInputType(),this.properties.inputType==="image"){let o=this.getInputData(1);ql(o)?(s=ol(o),t=o.width,i=o.height):s=null}else this.properties.inputType==="size"&&(t=this.getInputData(1)||0,i=this.getInputData(2)||0);(t!=this.properties.canvasWidth||i!=this.properties.canvasHeight||s!=this.properties.canvasImageURL)&&(this.properties.canvasWidth=t,this.properties.canvasHeight=i,this.properties.canvasImageURL=s,this.updateSize());const r=this.getValue();for(let o=0;othis.properties.regionCount;t--)this.outputs[t].type!==$.EVENT&&this.removeOutput(t);for(let t=this.outputs.length-1;t=1;r--)this.inputs[r].type!==$.ACTION&&this.removeInput(r);t==="image"?this.addInput("image","COMFYBOX_IMAGE"):t==="size"&&(this.addInput("width","number"),this.addInput("height","number"))}}parseValue(t){if(t==null||this.properties.regionCount<=0)return[];let i=[];F1(t)&&(i=this.updateSize([t])),Array.isArray(t)&&t.every(F1)&&(i=this.updateSize(t.splice(0,this.properties.regionCount)));for(let s=i.length;s{o[c]=null}),le(),t=o[e],t?t.p(a,u):(t=o[e]=r[e](a),t.c()),S(t,1),t.m(i.parentNode,i))},i(a){s||(S(t),s=!0)},o(a){C(t),s=!1},d(a){a&&E(i),o[e].d(a)}}}function U8(n){let e,t,i=Xe(n[1]),s=[];for(let o=0;oC(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o{j(c,1)}),le()}r?(e=Nt(r,o(l)),Y(e.$$.fragment),S(e.$$.fragment,1),G(e,t.parentNode,t)):e=null}else r&&e.$set(u)},i(l){i||(e&&S(e.$$.fragment,l),i=!0)},o(l){e&&C(e.$$.fragment,l),i=!1},d(l){l&&E(t),e&&j(e,l)}}}function j8(n){let e,t,i,s;const r=[J8,$8],o=[];function l(a,u){return a[4]?0:1}return e=l(n),t=o[e]=r[e](n),{c(){t.c(),i=we()},m(a,u){o[e].m(a,u),A(a,i,u),s=!0},p(a,u){let c=e;e=l(a),e===c?o[e].p(a,u):(oe(),C(o[c],1,1,()=>{o[c]=null}),le(),t=o[e],t?t.p(a,u):(t=o[e]=r[e](a),t.c()),S(t,1),t.m(i.parentNode,i))},i(a){s||(S(t),s=!0)},o(a){C(t),s=!1},d(a){a&&E(i),o[e].d(a)}}}function q8(n){let e,t,i;var s=n[5].table;function r(o){return{props:{$$slots:{default:[a6]},$$scope:{ctx:o}}}}return s&&(e=Nt(s,r(n))),{c(){e&&Y(e.$$.fragment),t=we()},m(o,l){e&&G(e,o,l),A(o,t,l),i=!0},p(o,l){const a={};if(l&8388716&&(a.$$scope={dirty:l,ctx:o}),l&32&&s!==(s=o[5].table)){if(e){oe();const u=e;C(u.$$.fragment,1,0,()=>{j(u,1)}),le()}s?(e=Nt(s,r(o)),Y(e.$$.fragment),S(e.$$.fragment,1),G(e,t.parentNode,t)):e=null}else s&&e.$set(a)},i(o){i||(e&&S(e.$$.fragment,o),i=!0)},o(o){e&&C(e.$$.fragment,o),i=!1},d(o){o&&E(t),e&&j(e,o)}}}function Y8(n){let e=n[6].raw+"",t;return{c(){t=ke(e)},m(i,s){A(i,t,s)},p(i,s){s&64&&e!==(e=i[6].raw+"")&&je(t,e)},i:Z,o:Z,d(i){i&&E(t)}}}function X8(n){let e,t;return e=new oo({props:{tokens:n[1],renderers:n[5]}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&2&&(r.tokens=i[1]),s&32&&(r.renderers=i[5]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function K8(n){let e,t,i,s;const r=[X8,Y8],o=[];function l(a,u){return a[1]?0:1}return e=l(n),t=o[e]=r[e](n),{c(){t.c(),i=we()},m(a,u){o[e].m(a,u),A(a,i,u),s=!0},p(a,u){let c=e;e=l(a),e===c?o[e].p(a,u):(oe(),C(o[c],1,1,()=>{o[c]=null}),le(),t=o[e],t?t.p(a,u):(t=o[e]=r[e](a),t.c()),S(t,1),t.m(i.parentNode,i))},i(a){s||(S(t),s=!0)},o(a){C(t),s=!1},d(a){a&&E(i),o[e].d(a)}}}function $8(n){let e,t,i;const s=[{ordered:n[4]},n[6]];var r=n[5].list;function o(l){let a={$$slots:{default:[Q8]},$$scope:{ctx:l}};for(let u=0;u{j(c,1)}),le()}r?(e=Nt(r,o(l)),Y(e.$$.fragment),S(e.$$.fragment,1),G(e,t.parentNode,t)):e=null}else r&&e.$set(u)},i(l){i||(e&&S(e.$$.fragment,l),i=!0)},o(l){e&&C(e.$$.fragment,l),i=!1},d(l){l&&E(t),e&&j(e,l)}}}function J8(n){let e,t,i;const s=[{ordered:n[4]},n[6]];var r=n[5].list;function o(l){let a={$$slots:{default:[t6]},$$scope:{ctx:l}};for(let u=0;u{j(c,1)}),le()}r?(e=Nt(r,o(l)),Y(e.$$.fragment),S(e.$$.fragment,1),G(e,t.parentNode,t)):e=null}else r&&e.$set(u)},i(l){i||(e&&S(e.$$.fragment,l),i=!0)},o(l){e&&C(e.$$.fragment,l),i=!1},d(l){l&&E(t),e&&j(e,l)}}}function Z8(n){let e,t,i;return e=new oo({props:{tokens:n[18].tokens,renderers:n[5]}}),{c(){Y(e.$$.fragment),t=se()},m(s,r){G(e,s,r),A(s,t,r),i=!0},p(s,r){const o={};r&64&&(o.tokens=s[18].tokens),r&32&&(o.renderers=s[5]),e.$set(o)},i(s){i||(S(e.$$.fragment,s),i=!0)},o(s){C(e.$$.fragment,s),i=!1},d(s){s&&E(t),j(e,s)}}}function q1(n){let e,t,i;const s=[n[18]];var r=n[5].unorderedlistitem||n[5].listitem;function o(l){let a={$$slots:{default:[Z8]},$$scope:{ctx:l}};for(let u=0;u{j(c,1)}),le()}r?(e=Nt(r,o(l)),Y(e.$$.fragment),S(e.$$.fragment,1),G(e,t.parentNode,t)):e=null}else r&&e.$set(u)},i(l){i||(e&&S(e.$$.fragment,l),i=!0)},o(l){e&&C(e.$$.fragment,l),i=!1},d(l){l&&E(t),e&&j(e,l)}}}function Q8(n){let e,t,i=Xe(n[6].items),s=[];for(let o=0;oC(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o{j(c,1)}),le()}r?(e=Nt(r,o(l)),Y(e.$$.fragment),S(e.$$.fragment,1),G(e,t.parentNode,t)):e=null}else r&&e.$set(u)},i(l){i||(e&&S(e.$$.fragment,l),i=!0)},o(l){e&&C(e.$$.fragment,l),i=!1},d(l){l&&E(t),e&&j(e,l)}}}function t6(n){let e,t,i=Xe(n[6].items),s=[];for(let o=0;oC(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o{j(u,1)}),le()}s?(e=Nt(s,r(o)),Y(e.$$.fragment),S(e.$$.fragment,1),G(e,t.parentNode,t)):e=null}else s&&e.$set(a)},i(o){i||(e&&S(e.$$.fragment,o),i=!0)},o(o){e&&C(e.$$.fragment,o),i=!1},d(o){o&&E(t),e&&j(e,o)}}}function n6(n){let e,t,i=Xe(n[2]),s=[];for(let o=0;oC(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o{j(u,1)}),le()}s?(e=Nt(s,r(o)),Y(e.$$.fragment),S(e.$$.fragment,1),G(e,t.parentNode,t)):e=null}else s&&e.$set(a)},i(o){i||(e&&S(e.$$.fragment,o),i=!0)},o(o){e&&C(e.$$.fragment,o),i=!1},d(o){o&&E(t),e&&j(e,o)}}}function r6(n){let e,t;return e=new oo({props:{tokens:n[13].tokens,renderers:n[5]}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&8&&(r.tokens=i[13].tokens),s&32&&(r.renderers=i[5]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function K1(n){let e,t,i;var s=n[5].tablecell;function r(o){return{props:{header:!1,align:o[6].align[o[15]]||"center",$$slots:{default:[r6]},$$scope:{ctx:o}}}}return s&&(e=Nt(s,r(n))),{c(){e&&Y(e.$$.fragment),t=we()},m(o,l){e&&G(e,o,l),A(o,t,l),i=!0},p(o,l){const a={};if(l&64&&(a.align=o[6].align[o[15]]||"center"),l&8388648&&(a.$$scope={dirty:l,ctx:o}),l&32&&s!==(s=o[5].tablecell)){if(e){oe();const u=e;C(u.$$.fragment,1,0,()=>{j(u,1)}),le()}s?(e=Nt(s,r(o)),Y(e.$$.fragment),S(e.$$.fragment,1),G(e,t.parentNode,t)):e=null}else s&&e.$set(a)},i(o){i||(e&&S(e.$$.fragment,o),i=!0)},o(o){e&&C(e.$$.fragment,o),i=!1},d(o){o&&E(t),e&&j(e,o)}}}function o6(n){let e,t,i=Xe(n[10]),s=[];for(let o=0;oC(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o{j(u,1)}),le()}s?(e=Nt(s,r(o)),Y(e.$$.fragment),S(e.$$.fragment,1),G(e,t.parentNode,t)):e=null}else s&&e.$set(a)},i(o){i||(e&&S(e.$$.fragment,o),i=!0)},o(o){e&&C(e.$$.fragment,o),i=!1},d(o){o&&E(t),e&&j(e,o)}}}function l6(n){let e,t,i=Xe(n[3]),s=[];for(let o=0;oC(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o{j(p,1)}),le()}o?(e=Nt(o,l(c)),Y(e.$$.fragment),S(e.$$.fragment,1),G(e,t.parentNode,t)):e=null}else o&&e.$set(h);const d={};if(f&8388712&&(d.$$scope={dirty:f,ctx:c}),f&32&&a!==(a=c[5].tablebody)){if(i){oe();const p=i;C(p.$$.fragment,1,0,()=>{j(p,1)}),le()}a?(i=Nt(a,u(c)),Y(i.$$.fragment),S(i.$$.fragment,1),G(i,s.parentNode,s)):i=null}else a&&i.$set(d)},i(c){r||(e&&S(e.$$.fragment,c),i&&S(i.$$.fragment,c),r=!0)},o(c){e&&C(e.$$.fragment,c),i&&C(i.$$.fragment,c),r=!1},d(c){c&&(E(t),E(s)),e&&j(e,c),i&&j(i,c)}}}function J1(n){let e,t;const i=[n[7],{renderers:n[5]}];let s={};for(let r=0;r{o[c]=null}),le()),~e?(t=o[e],t?t.p(a,u):(t=o[e]=r[e](a),t.c()),S(t,1),t.m(i.parentNode,i)):t=null)},i(a){s||(S(t),s=!0)},o(a){C(t),s=!1},d(a){a&&E(i),~e&&o[e].d(a)}}}function c6(n,e,t){const i=["type","tokens","header","rows","ordered","renderers"];let s=zt(e,i),{type:r=void 0}=e,{tokens:o=void 0}=e,{header:l=void 0}=e,{rows:a=void 0}=e,{ordered:u=!1}=e,{renderers:c}=e;return n.$$set=f=>{e=et(et({},e),Zn(f)),t(6,s=zt(e,i)),"type"in f&&t(0,r=f.type),"tokens"in f&&t(1,o=f.tokens),"header"in f&&t(2,l=f.header),"rows"in f&&t(3,a=f.rows),"ordered"in f&&t(4,u=f.ordered),"renderers"in f&&t(5,c=f.renderers)},[r,o,l,a,u,c,s]}let oo=class extends _e{constructor(e){super(),me(this,e,c6,u6,ae,{type:0,tokens:1,header:2,rows:3,ordered:4,renderers:5})}};function MS(){return{async:!1,baseUrl:null,breaks:!1,extensions:null,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,hooks:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}let lo=MS();function f6(n){lo=n}const RS=/[&<>"']/,h6=new RegExp(RS.source,"g"),PS=/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,d6=new RegExp(PS.source,"g"),p6={"&":"&","<":"<",">":">",'"':""","'":"'"},Z1=n=>p6[n];function ji(n,e){if(e){if(RS.test(n))return n.replace(h6,Z1)}else if(PS.test(n))return n.replace(d6,Z1);return n}const g6=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;function BS(n){return n.replace(g6,(e,t)=>(t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""))}const m6=/(^|[^\[])\^/g;function Et(n,e){n=typeof n=="string"?n:n.source,e=e||"";const t={replace:(i,s)=>(s=s.source||s,s=s.replace(m6,"$1"),n=n.replace(i,s),t),getRegex:()=>new RegExp(n,e)};return t}const _6=/[^\w:]/g,b6=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;function Q1(n,e,t){if(n){let i;try{i=decodeURIComponent(BS(t)).replace(_6,"").toLowerCase()}catch{return null}if(i.indexOf("javascript:")===0||i.indexOf("vbscript:")===0||i.indexOf("data:")===0)return null}e&&!b6.test(t)&&(t=k6(e,t));try{t=encodeURI(t).replace(/%25/g,"%")}catch{return null}return t}const iu={},y6=/^[^:]+:\/*[^/]*$/,v6=/^([^:]+:)[\s\S]*$/,w6=/^([^:]+:\/*[^/]*)[\s\S]*$/;function k6(n,e){iu[" "+n]||(y6.test(n)?iu[" "+n]=n+"/":iu[" "+n]=Tu(n,"/",!0)),n=iu[" "+n];const t=n.indexOf(":")===-1;return e.substring(0,2)==="//"?t?e:n.replace(v6,"$1")+e:e.charAt(0)==="/"?t?e:n.replace(w6,"$1")+e:n+e}const Tc={exec:function(){}};function eb(n,e){const t=n.replace(/\|/g,(r,o,l)=>{let a=!1,u=o;for(;--u>=0&&l[u]==="\\";)a=!a;return a?"|":" |"}),i=t.split(/ \|/);let s=0;if(i[0].trim()||i.shift(),i.length>0&&!i[i.length-1].trim()&&i.pop(),i.length>e)i.splice(e);else for(;i.length1;)e&1&&(t+=n),e>>=1,n+=n;return t+n}function ib(n,e,t,i){const s=e.href,r=e.title?ji(e.title):null,o=n[1].replace(/\\([\[\]])/g,"$1");if(n[0].charAt(0)!=="!"){i.state.inLink=!0;const l={type:"link",raw:t,href:s,title:r,text:o,tokens:i.inlineTokens(o)};return i.state.inLink=!1,l}return{type:"image",raw:t,href:s,title:r,text:ji(o)}}function C6(n,e){const t=n.match(/^(\s+)(?:```)/);if(t===null)return e;const i=t[1];return e.split(` -`).map(s=>{const r=s.match(/^\s+/);if(r===null)return s;const[o]=r;return o.length>=i.length?s.slice(i.length):s}).join(` -`)}class vg{constructor(e){this.options=e||lo}space(e){const t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){const t=this.rules.block.code.exec(e);if(t){const i=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?i:Tu(i,` -`)}}}fences(e){const t=this.rules.block.fences.exec(e);if(t){const i=t[0],s=C6(i,t[3]||"");return{type:"code",raw:i,lang:t[2]?t[2].trim().replace(this.rules.inline._escapes,"$1"):t[2],text:s}}}heading(e){const t=this.rules.block.heading.exec(e);if(t){let i=t[2].trim();if(/#$/.test(i)){const s=Tu(i,"#");(this.options.pedantic||!s||/ $/.test(s))&&(i=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:i,tokens:this.lexer.inline(i)}}}hr(e){const t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:t[0]}}blockquote(e){const t=this.rules.block.blockquote.exec(e);if(t){const i=t[0].replace(/^ *>[ \t]?/gm,""),s=this.lexer.state.top;this.lexer.state.top=!0;const r=this.lexer.blockTokens(i);return this.lexer.state.top=s,{type:"blockquote",raw:t[0],tokens:r,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let i,s,r,o,l,a,u,c,f,h,d,p,g=t[1].trim();const m=g.length>1,_={type:"list",raw:"",ordered:m,start:m?+g.slice(0,-1):"",loose:!1,items:[]};g=m?`\\d{1,9}\\${g.slice(-1)}`:`\\${g}`,this.options.pedantic&&(g=m?g:"[*+-]");const b=new RegExp(`^( {0,3}${g})((?:[ ][^\\n]*)?(?:\\n|$))`);for(;e&&(p=!1,!(!(t=b.exec(e))||this.rules.block.hr.test(e)));){if(i=t[0],e=e.substring(i.length),c=t[2].split(` -`,1)[0].replace(/^\t+/,k=>" ".repeat(3*k.length)),f=e.split(` -`,1)[0],this.options.pedantic?(o=2,d=c.trimLeft()):(o=t[2].search(/[^ ]/),o=o>4?1:o,d=c.slice(o),o+=t[1].length),a=!1,!c&&/^ *$/.test(f)&&(i+=f+` -`,e=e.substring(f.length+1),p=!0),!p){const k=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),T=new RegExp(`^ {0,${Math.min(3,o-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),I=new RegExp(`^ {0,${Math.min(3,o-1)}}(?:\`\`\`|~~~)`),x=new RegExp(`^ {0,${Math.min(3,o-1)}}#`);for(;e&&(h=e.split(` -`,1)[0],f=h,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),!(I.test(f)||x.test(f)||k.test(f)||T.test(e)));){if(f.search(/[^ ]/)>=o||!f.trim())d+=` -`+f.slice(o);else{if(a||c.search(/[^ ]/)>=4||I.test(c)||x.test(c)||T.test(c))break;d+=` -`+f}!a&&!f.trim()&&(a=!0),i+=h+` -`,e=e.substring(h.length+1),c=f.slice(o)}}_.loose||(u?_.loose=!0:/\n *\n *$/.test(i)&&(u=!0)),this.options.gfm&&(s=/^\[[ xX]\] /.exec(d),s&&(r=s[0]!=="[ ] ",d=d.replace(/^\[[ xX]\] +/,""))),_.items.push({type:"list_item",raw:i,task:!!s,checked:r,loose:!1,text:d}),_.raw+=i}_.items[_.items.length-1].raw=i.trimRight(),_.items[_.items.length-1].text=d.trimRight(),_.raw=_.raw.trimRight();const y=_.items.length;for(l=0;lI.type==="space"),T=k.length>0&&k.some(I=>/\n.*\n/.test(I.raw));_.loose=T}if(_.loose)for(l=0;l$/,"$1").replace(this.rules.inline._escapes,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline._escapes,"$1"):t[3];return{type:"def",tag:i,raw:t[0],href:s,title:r}}}table(e){const t=this.rules.block.table.exec(e);if(t){const i={type:"table",header:eb(t[1]).map(s=>({text:s})),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),rows:t[3]&&t[3].trim()?t[3].replace(/\n[ \t]*$/,"").split(` -`):[]};if(i.header.length===i.align.length){i.raw=t[0];let s=i.align.length,r,o,l,a;for(r=0;r({text:u}));for(s=i.header.length,o=0;o/i.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:this.options.sanitize?"text":"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(t[0]):ji(t[0]):t[0]}}link(e){const t=this.rules.inline.link.exec(e);if(t){const i=t[2].trim();if(!this.options.pedantic&&/^$/.test(i))return;const o=Tu(i.slice(0,-1),"\\");if((i.length-o.length)%2===0)return}else{const o=S6(t[2],"()");if(o>-1){const a=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let s=t[2],r="";if(this.options.pedantic){const o=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(s);o&&(s=o[1],r=o[3])}else r=t[3]?t[3].slice(1,-1):"";return s=s.trim(),/^$/.test(i)?s=s.slice(1):s=s.slice(1,-1)),ib(t,{href:s&&s.replace(this.rules.inline._escapes,"$1"),title:r&&r.replace(this.rules.inline._escapes,"$1")},t[0],this.lexer)}}reflink(e,t){let i;if((i=this.rules.inline.reflink.exec(e))||(i=this.rules.inline.nolink.exec(e))){let s=(i[2]||i[1]).replace(/\s+/g," ");if(s=t[s.toLowerCase()],!s){const r=i[0].charAt(0);return{type:"text",raw:r,text:r}}return ib(i,s,i[0],this.lexer)}}emStrong(e,t,i=""){let s=this.rules.inline.emStrong.lDelim.exec(e);if(!s||s[3]&&i.match(/[\p{L}\p{N}]/u))return;const r=s[1]||s[2]||"";if(!r||r&&(i===""||this.rules.inline.punctuation.exec(i))){const o=s[0].length-1;let l,a,u=o,c=0;const f=s[0][0]==="*"?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(f.lastIndex=0,t=t.slice(-1*e.length+o);(s=f.exec(t))!=null;){if(l=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!l)continue;if(a=l.length,s[3]||s[4]){u+=a;continue}else if((s[5]||s[6])&&o%3&&!((o+a)%3)){c+=a;continue}if(u-=a,u>0)continue;a=Math.min(a,a+u+c);const h=e.slice(0,o+s.index+(s[0].length-l.length)+a);if(Math.min(o,a)%2){const p=h.slice(1,-1);return{type:"em",raw:h,text:p,tokens:this.lexer.inlineTokens(p)}}const d=h.slice(2,-2);return{type:"strong",raw:h,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(e){const t=this.rules.inline.code.exec(e);if(t){let i=t[2].replace(/\n/g," ");const s=/[^ ]/.test(i),r=/^ /.test(i)&&/ $/.test(i);return s&&r&&(i=i.substring(1,i.length-1)),i=ji(i,!0),{type:"codespan",raw:t[0],text:i}}}br(e){const t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){const t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e,t){const i=this.rules.inline.autolink.exec(e);if(i){let s,r;return i[2]==="@"?(s=ji(this.options.mangle?t(i[1]):i[1]),r="mailto:"+s):(s=ji(i[1]),r=s),{type:"link",raw:i[0],text:s,href:r,tokens:[{type:"text",raw:s,text:s}]}}}url(e,t){let i;if(i=this.rules.inline.url.exec(e)){let s,r;if(i[2]==="@")s=ji(this.options.mangle?t(i[0]):i[0]),r="mailto:"+s;else{let o;do o=i[0],i[0]=this.rules.inline._backpedal.exec(i[0])[0];while(o!==i[0]);s=ji(i[0]),i[1]==="www."?r="http://"+i[0]:r=i[0]}return{type:"link",raw:i[0],text:s,href:r,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(e,t){const i=this.rules.inline.text.exec(e);if(i){let s;return this.lexer.state.inRawBlock?s=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):ji(i[0]):i[0]:s=ji(this.options.smartypants?t(i[0]):i[0]),{type:"text",raw:i[0],text:s}}}}const Ue={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,hr:/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,html:"^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))",def:/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/,table:Tc,lheading:/^((?:.|\n(?!\n))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,text:/^[^\n]+/};Ue._label=/(?!\s*\])(?:\\.|[^\[\]\\])+/;Ue._title=/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;Ue.def=Et(Ue.def).replace("label",Ue._label).replace("title",Ue._title).getRegex();Ue.bullet=/(?:[*+-]|\d{1,9}[.)])/;Ue.listItemStart=Et(/^( *)(bull) */).replace("bull",Ue.bullet).getRegex();Ue.list=Et(Ue.list).replace(/bull/g,Ue.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+Ue.def.source+")").getRegex();Ue._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";Ue._comment=/|$)/;Ue.html=Et(Ue.html,"i").replace("comment",Ue._comment).replace("tag",Ue._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();Ue.paragraph=Et(Ue._paragraph).replace("hr",Ue.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ue._tag).getRegex();Ue.blockquote=Et(Ue.blockquote).replace("paragraph",Ue.paragraph).getRegex();Ue.normal={...Ue};Ue.gfm={...Ue.normal,table:"^ *([^\\n ].*\\|.*)\\n {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"};Ue.gfm.table=Et(Ue.gfm.table).replace("hr",Ue.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ue._tag).getRegex();Ue.gfm.paragraph=Et(Ue._paragraph).replace("hr",Ue.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("table",Ue.gfm.table).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",Ue._tag).getRegex();Ue.pedantic={...Ue.normal,html:Et(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Ue._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Tc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Et(Ue.normal._paragraph).replace("hr",Ue.hr).replace("heading",` *#{1,6} *[^ -]`).replace("lheading",Ue.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()};const Oe={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:Tc,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(ref)\]/,nolink:/^!?\[(ref)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/^(?:[^_*\\]|\\.)*?\_\_(?:[^_*\\]|\\.)*?\*(?:[^_*\\]|\\.)*?(?=\_\_)|(?:[^*\\]|\\.)+(?=[^*])|[punct_](\*+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|(?:[^punct*_\s\\]|\\.)(\*+)(?=[^punct*_\s])/,rDelimUnd:/^(?:[^_*\\]|\\.)*?\*\*(?:[^_*\\]|\\.)*?\_(?:[^_*\\]|\\.)*?(?=\*\*)|(?:[^_\\]|\\.)+(?=[^_])|[punct*](\_+)(?=[\s]|$)|(?:[^punct*_\s\\]|\\.)(\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:Tc,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~";Oe.punctuation=Et(Oe.punctuation).replace(/punctuation/g,Oe._punctuation).getRegex();Oe.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g;Oe.escapedEmSt=/(?:^|[^\\])(?:\\\\)*\\[*_]/g;Oe._comment=Et(Ue._comment).replace("(?:-->|$)","-->").getRegex();Oe.emStrong.lDelim=Et(Oe.emStrong.lDelim).replace(/punct/g,Oe._punctuation).getRegex();Oe.emStrong.rDelimAst=Et(Oe.emStrong.rDelimAst,"g").replace(/punct/g,Oe._punctuation).getRegex();Oe.emStrong.rDelimUnd=Et(Oe.emStrong.rDelimUnd,"g").replace(/punct/g,Oe._punctuation).getRegex();Oe._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;Oe._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;Oe._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;Oe.autolink=Et(Oe.autolink).replace("scheme",Oe._scheme).replace("email",Oe._email).getRegex();Oe._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;Oe.tag=Et(Oe.tag).replace("comment",Oe._comment).replace("attribute",Oe._attribute).getRegex();Oe._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;Oe._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/;Oe._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;Oe.link=Et(Oe.link).replace("label",Oe._label).replace("href",Oe._href).replace("title",Oe._title).getRegex();Oe.reflink=Et(Oe.reflink).replace("label",Oe._label).replace("ref",Ue._label).getRegex();Oe.nolink=Et(Oe.nolink).replace("ref",Ue._label).getRegex();Oe.reflinkSearch=Et(Oe.reflinkSearch,"g").replace("reflink",Oe.reflink).replace("nolink",Oe.nolink).getRegex();Oe.normal={...Oe};Oe.pedantic={...Oe.normal,strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:Et(/^!?\[(label)\]\((.*?)\)/).replace("label",Oe._label).getRegex(),reflink:Et(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Oe._label).getRegex()};Oe.gfm={...Oe.normal,escape:Et(Oe.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\.5&&(i="x"+i.toString(16)),e+="&#"+i+";";return e}class qs{constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||lo,this.options.tokenizer=this.options.tokenizer||new vg,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const t={block:Ue.normal,inline:Oe.normal};this.options.pedantic?(t.block=Ue.pedantic,t.inline=Oe.pedantic):this.options.gfm&&(t.block=Ue.gfm,this.options.breaks?t.inline=Oe.breaks:t.inline=Oe.gfm),this.tokenizer.rules=t}static get rules(){return{block:Ue,inline:Oe}}static lex(e,t){return new qs(t).lex(e)}static lexInline(e,t){return new qs(t).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,` -`),this.blockTokens(e,this.tokens);let t;for(;t=this.inlineQueue.shift();)this.inlineTokens(t.src,t.tokens);return this.tokens}blockTokens(e,t=[]){this.options.pedantic?e=e.replace(/\t/g," ").replace(/^ +$/gm,""):e=e.replace(/^( *)(\t+)/gm,(l,a,u)=>a+" ".repeat(u.length));let i,s,r,o;for(;e;)if(!(this.options.extensions&&this.options.extensions.block&&this.options.extensions.block.some(l=>(i=l.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))){if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length),i.raw.length===1&&t.length>0?t[t.length-1].raw+=` -`:t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length),s=t[t.length-1],s&&(s.type==="paragraph"||s.type==="text")?(s.raw+=` -`+i.raw,s.text+=` -`+i.text,this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length),s=t[t.length-1],s&&(s.type==="paragraph"||s.type==="text")?(s.raw+=` -`+i.raw,s.text+=` -`+i.raw,this.inlineQueue[this.inlineQueue.length-1].src=s.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title});continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(r=e,this.options.extensions&&this.options.extensions.startBlock){let l=1/0;const a=e.slice(1);let u;this.options.extensions.startBlock.forEach(function(c){u=c.call({lexer:this},a),typeof u=="number"&&u>=0&&(l=Math.min(l,u))}),l<1/0&&l>=0&&(r=e.substring(0,l+1))}if(this.state.top&&(i=this.tokenizer.paragraph(r))){s=t[t.length-1],o&&s.type==="paragraph"?(s.raw+=` -`+i.raw,s.text+=` -`+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(i),o=r.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length),s=t[t.length-1],s&&s.type==="text"?(s.raw+=` -`+i.raw,s.text+=` -`+i.text,this.inlineQueue.pop(),this.inlineQueue[this.inlineQueue.length-1].src=s.text):t.push(i);continue}if(e){const l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent)break;throw new Error(l)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let i,s,r,o=e,l,a,u;if(this.tokens.links){const c=Object.keys(this.tokens.links);if(c.length>0)for(;(l=this.tokenizer.rules.inline.reflinkSearch.exec(o))!=null;)c.includes(l[0].slice(l[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,l.index)+"["+tb("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(l=this.tokenizer.rules.inline.blockSkip.exec(o))!=null;)o=o.slice(0,l.index)+"["+tb("a",l[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;(l=this.tokenizer.rules.inline.escapedEmSt.exec(o))!=null;)o=o.slice(0,l.index+l[0].length-2)+"++"+o.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex),this.tokenizer.rules.inline.escapedEmSt.lastIndex--;for(;e;)if(a||(u=""),a=!1,!(this.options.extensions&&this.options.extensions.inline&&this.options.extensions.inline.some(c=>(i=c.call({lexer:this},e,t))?(e=e.substring(i.raw.length),t.push(i),!0):!1))){if(i=this.tokenizer.escape(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.tag(e)){e=e.substring(i.raw.length),s=t[t.length-1],s&&i.type==="text"&&s.type==="text"?(s.raw+=i.raw,s.text+=i.text):t.push(i);continue}if(i=this.tokenizer.link(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(i.raw.length),s=t[t.length-1],s&&i.type==="text"&&s.type==="text"?(s.raw+=i.raw,s.text+=i.text):t.push(i);continue}if(i=this.tokenizer.emStrong(e,o,u)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.codespan(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.br(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.del(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.autolink(e,nb)){e=e.substring(i.raw.length),t.push(i);continue}if(!this.state.inLink&&(i=this.tokenizer.url(e,nb))){e=e.substring(i.raw.length),t.push(i);continue}if(r=e,this.options.extensions&&this.options.extensions.startInline){let c=1/0;const f=e.slice(1);let h;this.options.extensions.startInline.forEach(function(d){h=d.call({lexer:this},f),typeof h=="number"&&h>=0&&(c=Math.min(c,h))}),c<1/0&&c>=0&&(r=e.substring(0,c+1))}if(i=this.tokenizer.inlineText(r,I6)){e=e.substring(i.raw.length),i.raw.slice(-1)!=="_"&&(u=i.raw.slice(-1)),a=!0,s=t[t.length-1],s&&s.type==="text"?(s.raw+=i.raw,s.text+=i.text):t.push(i);continue}if(e){const c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent)break;throw new Error(c)}}return t}}class wg{constructor(e){this.options=e||lo}code(e,t,i){const s=(t||"").match(/\S*/)[0];if(this.options.highlight){const r=this.options.highlight(e,s);r!=null&&r!==e&&(i=!0,e=r)}return e=e.replace(/\n$/,"")+` -`,s?'
'+(i?e:ji(e,!0))+`
-`:"
"+(i?e:ji(e,!0))+`
-`}blockquote(e){return`
-${e}
-`}html(e){return e}heading(e,t,i,s){if(this.options.headerIds){const r=this.options.headerPrefix+s.slug(i);return`${e} -`}return`${e} -`}hr(){return this.options.xhtml?`
-`:`
-`}list(e,t,i){const s=t?"ol":"ul",r=t&&i!==1?' start="'+i+'"':"";return"<"+s+r+`> -`+e+" -`}listitem(e){return`
  • ${e}
  • -`}checkbox(e){return" "}paragraph(e){return`

    ${e}

    -`}table(e,t){return t&&(t=`${t}`),` - -`+e+` -`+t+`
    -`}tablerow(e){return` -${e} -`}tablecell(e,t){const i=t.header?"th":"td";return(t.align?`<${i} align="${t.align}">`:`<${i}>`)+e+` -`}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return this.options.xhtml?"
    ":"
    "}del(e){return`${e}`}link(e,t,i){if(e=Q1(this.options.sanitize,this.options.baseUrl,e),e===null)return i;let s='",s}image(e,t,i){if(e=Q1(this.options.sanitize,this.options.baseUrl,e),e===null)return i;let s=`${i}":">",s}text(e){return e}}class zS{strong(e){return e}em(e){return e}codespan(e){return e}del(e){return e}html(e){return e}text(e){return e}link(e,t,i){return""+i}image(e,t,i){return""+i}br(){return""}}class kg{constructor(){this.seen={}}serialize(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/ig,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")}getNextSafeSlug(e,t){let i=e,s=0;if(this.seen.hasOwnProperty(i)){s=this.seen[e];do s++,i=e+"-"+s;while(this.seen.hasOwnProperty(i))}return t||(this.seen[e]=s,this.seen[i]=0),i}slug(e,t={}){const i=this.serialize(e);return this.getNextSafeSlug(i,t.dryrun)}}class Or{constructor(e){this.options=e||lo,this.options.renderer=this.options.renderer||new wg,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new zS,this.slugger=new kg}static parse(e,t){return new Or(t).parse(e)}static parseInline(e,t){return new Or(t).parseInline(e)}parse(e,t=!0){let i="",s,r,o,l,a,u,c,f,h,d,p,g,m,_,b,y,k,T,I;const x=e.length;for(s=0;s0&&b.tokens[0].type==="paragraph"?(b.tokens[0].text=T+" "+b.tokens[0].text,b.tokens[0].tokens&&b.tokens[0].tokens.length>0&&b.tokens[0].tokens[0].type==="text"&&(b.tokens[0].tokens[0].text=T+" "+b.tokens[0].tokens[0].text)):b.tokens.unshift({type:"text",text:T}):_+=T),_+=this.parse(b.tokens,m),h+=this.renderer.listitem(_,k,y);i+=this.renderer.list(h,p,g);continue}case"html":{i+=this.renderer.html(d.text);continue}case"paragraph":{i+=this.renderer.paragraph(this.parseInline(d.tokens));continue}case"text":{for(h=d.tokens?this.parseInline(d.tokens):d.text;s+1{if(i.message+=` -Please report this to https://github.com/markedjs/marked.`,n){const s="

    An error occurred:

    "+ji(i.message+"",!0)+"
    ";if(e)return Promise.resolve(s);if(t){t(null,s);return}return s}if(e)return Promise.reject(i);if(t){t(i);return}throw i}}function FS(n,e){return(t,i,s)=>{typeof i=="function"&&(s=i,i=null);const r={...i};i={...Ye.defaults,...r};const o=E6(i.silent,i.async,s);if(typeof t>"u"||t===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(T6(i),i.hooks&&(i.hooks.options=i),s){const l=i.highlight;let a;try{i.hooks&&(t=i.hooks.preprocess(t)),a=n(t,i)}catch(f){return o(f)}const u=function(f){let h;if(!f)try{i.walkTokens&&Ye.walkTokens(a,i.walkTokens),h=e(a,i),i.hooks&&(h=i.hooks.postprocess(h))}catch(d){f=d}return i.highlight=l,f?o(f):s(null,h)};if(!l||l.length<3||(delete i.highlight,!a.length))return u();let c=0;Ye.walkTokens(a,function(f){f.type==="code"&&(c++,setTimeout(()=>{l(f.text,f.lang,function(h,d){if(h)return u(h);d!=null&&d!==f.text&&(f.text=d,f.escaped=!0),c--,c===0&&u()})},0))}),c===0&&u();return}if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then(l=>n(l,i)).then(l=>i.walkTokens?Promise.all(Ye.walkTokens(l,i.walkTokens)).then(()=>l):l).then(l=>e(l,i)).then(l=>i.hooks?i.hooks.postprocess(l):l).catch(o);try{i.hooks&&(t=i.hooks.preprocess(t));const l=n(t,i);i.walkTokens&&Ye.walkTokens(l,i.walkTokens);let a=e(l,i);return i.hooks&&(a=i.hooks.postprocess(a)),a}catch(l){return o(l)}}}function Ye(n,e,t){return FS(qs.lex,Or.parse)(n,e,t)}Ye.options=Ye.setOptions=function(n){return Ye.defaults={...Ye.defaults,...n},f6(Ye.defaults),Ye};Ye.getDefaults=MS;Ye.defaults=lo;Ye.use=function(...n){const e=Ye.defaults.extensions||{renderers:{},childTokens:{}};n.forEach(t=>{const i={...t};if(i.async=Ye.defaults.async||i.async||!1,t.extensions&&(t.extensions.forEach(s=>{if(!s.name)throw new Error("extension name required");if(s.renderer){const r=e.renderers[s.name];r?e.renderers[s.name]=function(...o){let l=s.renderer.apply(this,o);return l===!1&&(l=r.apply(this,o)),l}:e.renderers[s.name]=s.renderer}if(s.tokenizer){if(!s.level||s.level!=="block"&&s.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");e[s.level]?e[s.level].unshift(s.tokenizer):e[s.level]=[s.tokenizer],s.start&&(s.level==="block"?e.startBlock?e.startBlock.push(s.start):e.startBlock=[s.start]:s.level==="inline"&&(e.startInline?e.startInline.push(s.start):e.startInline=[s.start]))}s.childTokens&&(e.childTokens[s.name]=s.childTokens)}),i.extensions=e),t.renderer){const s=Ye.defaults.renderer||new wg;for(const r in t.renderer){const o=s[r];s[r]=(...l)=>{let a=t.renderer[r].apply(s,l);return a===!1&&(a=o.apply(s,l)),a}}i.renderer=s}if(t.tokenizer){const s=Ye.defaults.tokenizer||new vg;for(const r in t.tokenizer){const o=s[r];s[r]=(...l)=>{let a=t.tokenizer[r].apply(s,l);return a===!1&&(a=o.apply(s,l)),a}}i.tokenizer=s}if(t.hooks){const s=Ye.defaults.hooks||new Cc;for(const r in t.hooks){const o=s[r];Cc.passThroughHooks.has(r)?s[r]=l=>{if(Ye.defaults.async)return Promise.resolve(t.hooks[r].call(s,l)).then(u=>o.call(s,u));const a=t.hooks[r].call(s,l);return o.call(s,a)}:s[r]=(...l)=>{let a=t.hooks[r].apply(s,l);return a===!1&&(a=o.apply(s,l)),a}}i.hooks=s}if(t.walkTokens){const s=Ye.defaults.walkTokens;i.walkTokens=function(r){let o=[];return o.push(t.walkTokens.call(this,r)),s&&(o=o.concat(s.call(this,r))),o}}Ye.setOptions(i)})};Ye.walkTokens=function(n,e){let t=[];for(const i of n)switch(t=t.concat(e.call(Ye,i)),i.type){case"table":{for(const s of i.header)t=t.concat(Ye.walkTokens(s.tokens,e));for(const s of i.rows)for(const r of s)t=t.concat(Ye.walkTokens(r.tokens,e));break}case"list":{t=t.concat(Ye.walkTokens(i.items,e));break}default:Ye.defaults.extensions&&Ye.defaults.extensions.childTokens&&Ye.defaults.extensions.childTokens[i.type]?Ye.defaults.extensions.childTokens[i.type].forEach(function(s){t=t.concat(Ye.walkTokens(i[s],e))}):i.tokens&&(t=t.concat(Ye.walkTokens(i.tokens,e)))}return t};Ye.parseInline=FS(qs.lexInline,Or.parseInline);Ye.Parser=Or;Ye.parser=Or.parse;Ye.Renderer=wg;Ye.TextRenderer=zS;Ye.Lexer=qs;Ye.lexer=qs.lex;Ye.Tokenizer=vg;Ye.Slugger=kg;Ye.Hooks=Cc;Ye.parse=Ye;Ye.options;Ye.setOptions;Ye.use;Ye.walkTokens;Ye.parseInline;Or.parse;qs.lex;const WS={};function A6(n){let e;return{c(){e=ke(n[1])},m(t,i){A(t,e,i)},p(t,i){i&2&&je(e,t[1])},i:Z,o:Z,d(t){t&&E(e)}}}function O6(n){let e,t;const i=n[5].default,s=De(i,n,n[4],null);return{c(){e=z("h6"),s&&s.c(),v(e,"id",n[2])},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,o){s&&s.p&&(!t||o&16)&&Le(s,i,r,r[4],t?xe(i,r[4],o,null):Me(r[4]),null),(!t||o&4)&&v(e,"id",r[2])},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function N6(n){let e,t;const i=n[5].default,s=De(i,n,n[4],null);return{c(){e=z("h5"),s&&s.c(),v(e,"id",n[2])},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,o){s&&s.p&&(!t||o&16)&&Le(s,i,r,r[4],t?xe(i,r[4],o,null):Me(r[4]),null),(!t||o&4)&&v(e,"id",r[2])},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function D6(n){let e,t;const i=n[5].default,s=De(i,n,n[4],null);return{c(){e=z("h4"),s&&s.c(),v(e,"id",n[2])},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,o){s&&s.p&&(!t||o&16)&&Le(s,i,r,r[4],t?xe(i,r[4],o,null):Me(r[4]),null),(!t||o&4)&&v(e,"id",r[2])},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function x6(n){let e,t;const i=n[5].default,s=De(i,n,n[4],null);return{c(){e=z("h3"),s&&s.c(),v(e,"id",n[2])},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,o){s&&s.p&&(!t||o&16)&&Le(s,i,r,r[4],t?xe(i,r[4],o,null):Me(r[4]),null),(!t||o&4)&&v(e,"id",r[2])},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function L6(n){let e,t;const i=n[5].default,s=De(i,n,n[4],null);return{c(){e=z("h2"),s&&s.c(),v(e,"id",n[2])},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,o){s&&s.p&&(!t||o&16)&&Le(s,i,r,r[4],t?xe(i,r[4],o,null):Me(r[4]),null),(!t||o&4)&&v(e,"id",r[2])},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function M6(n){let e,t;const i=n[5].default,s=De(i,n,n[4],null);return{c(){e=z("h1"),s&&s.c(),v(e,"id",n[2])},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,o){s&&s.p&&(!t||o&16)&&Le(s,i,r,r[4],t?xe(i,r[4],o,null):Me(r[4]),null),(!t||o&4)&&v(e,"id",r[2])},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function R6(n){let e,t,i,s;const r=[M6,L6,x6,D6,N6,O6,A6],o=[];function l(a,u){return a[0]===1?0:a[0]===2?1:a[0]===3?2:a[0]===4?3:a[0]===5?4:a[0]===6?5:6}return e=l(n),t=o[e]=r[e](n),{c(){t.c(),i=we()},m(a,u){o[e].m(a,u),A(a,i,u),s=!0},p(a,[u]){let c=e;e=l(a),e===c?o[e].p(a,u):(oe(),C(o[c],1,1,()=>{o[c]=null}),le(),t=o[e],t?t.p(a,u):(t=o[e]=r[e](a),t.c()),S(t,1),t.m(i.parentNode,i))},i(a){s||(S(t),s=!0)},o(a){C(t),s=!1},d(a){a&&E(i),o[e].d(a)}}}function P6(n,e,t){let i,{$$slots:s={},$$scope:r}=e,{depth:o}=e,{raw:l}=e,{text:a}=e;const{slug:u,getOptions:c}=op(WS),f=c();return n.$$set=h=>{"depth"in h&&t(0,o=h.depth),"raw"in h&&t(1,l=h.raw),"text"in h&&t(3,a=h.text),"$$scope"in h&&t(4,r=h.$$scope)},n.$$.update=()=>{n.$$.dirty&8&&t(2,i=f.headerIds?f.headerPrefix+u(a):void 0)},[o,l,i,a,r,s]}class B6 extends _e{constructor(e){super(),me(this,e,P6,R6,ae,{depth:0,raw:1,text:3})}}function z6(n){let e,t;const i=n[1].default,s=De(i,n,n[0],null);return{c(){e=z("p"),s&&s.c()},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,[o]){s&&s.p&&(!t||o&1)&&Le(s,i,r,r[0],t?xe(i,r[0],o,null):Me(r[0]),null)},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function F6(n,e,t){let{$$slots:i={},$$scope:s}=e;return n.$$set=r=>{"$$scope"in r&&t(0,s=r.$$scope)},[s,i]}class W6 extends _e{constructor(e){super(),me(this,e,F6,z6,ae,{})}}function V6(n){let e;const t=n[3].default,i=De(t,n,n[2],null);return{c(){i&&i.c()},m(s,r){i&&i.m(s,r),e=!0},p(s,[r]){i&&i.p&&(!e||r&4)&&Le(i,t,s,s[2],e?xe(t,s[2],r,null):Me(s[2]),null)},i(s){e||(S(i,s),e=!0)},o(s){C(i,s),e=!1},d(s){i&&i.d(s)}}}function H6(n,e,t){let{$$slots:i={},$$scope:s}=e,{text:r}=e,{raw:o}=e;return n.$$set=l=>{"text"in l&&t(0,r=l.text),"raw"in l&&t(1,o=l.raw),"$$scope"in l&&t(2,s=l.$$scope)},[r,o,s,i]}class U6 extends _e{constructor(e){super(),me(this,e,H6,V6,ae,{text:0,raw:1})}}function G6(n){let e,t;return{c(){e=z("img"),Ti(e.src,t=n[0])||v(e,"src",t),v(e,"title",n[1]),v(e,"alt",n[2])},m(i,s){A(i,e,s)},p(i,[s]){s&1&&!Ti(e.src,t=i[0])&&v(e,"src",t),s&2&&v(e,"title",i[1]),s&4&&v(e,"alt",i[2])},i:Z,o:Z,d(i){i&&E(e)}}}function j6(n,e,t){let{href:i=""}=e,{title:s=void 0}=e,{text:r=""}=e;return n.$$set=o=>{"href"in o&&t(0,i=o.href),"title"in o&&t(1,s=o.title),"text"in o&&t(2,r=o.text)},[i,s,r]}let q6=class extends _e{constructor(e){super(),me(this,e,j6,G6,ae,{href:0,title:1,text:2})}};function Y6(n){let e,t;const i=n[3].default,s=De(i,n,n[2],null);return{c(){e=z("a"),s&&s.c(),v(e,"href",n[0]),v(e,"title",n[1])},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,[o]){s&&s.p&&(!t||o&4)&&Le(s,i,r,r[2],t?xe(i,r[2],o,null):Me(r[2]),null),(!t||o&1)&&v(e,"href",r[0]),(!t||o&2)&&v(e,"title",r[1])},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function X6(n,e,t){let{$$slots:i={},$$scope:s}=e,{href:r=""}=e,{title:o=void 0}=e;return n.$$set=l=>{"href"in l&&t(0,r=l.href),"title"in l&&t(1,o=l.title),"$$scope"in l&&t(2,s=l.$$scope)},[r,o,s,i]}class K6 extends _e{constructor(e){super(),me(this,e,X6,Y6,ae,{href:0,title:1})}}function $6(n){let e,t;const i=n[1].default,s=De(i,n,n[0],null);return{c(){e=z("em"),s&&s.c()},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,[o]){s&&s.p&&(!t||o&1)&&Le(s,i,r,r[0],t?xe(i,r[0],o,null):Me(r[0]),null)},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function J6(n,e,t){let{$$slots:i={},$$scope:s}=e;return n.$$set=r=>{"$$scope"in r&&t(0,s=r.$$scope)},[s,i]}class Z6 extends _e{constructor(e){super(),me(this,e,J6,$6,ae,{})}}function Q6(n){let e,t;const i=n[1].default,s=De(i,n,n[0],null);return{c(){e=z("del"),s&&s.c()},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,[o]){s&&s.p&&(!t||o&1)&&Le(s,i,r,r[0],t?xe(i,r[0],o,null):Me(r[0]),null)},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function eB(n,e,t){let{$$slots:i={},$$scope:s}=e;return n.$$set=r=>{"$$scope"in r&&t(0,s=r.$$scope)},[s,i]}class tB extends _e{constructor(e){super(),me(this,e,eB,Q6,ae,{})}}function iB(n){let e,t=n[0].replace(/`/g,"")+"",i;return{c(){e=z("code"),i=ke(t)},m(s,r){A(s,e,r),F(e,i)},p(s,[r]){r&1&&t!==(t=s[0].replace(/`/g,"")+"")&&je(i,t)},i:Z,o:Z,d(s){s&&E(e)}}}function nB(n,e,t){let{raw:i}=e;return n.$$set=s=>{"raw"in s&&t(0,i=s.raw)},[i]}class sB extends _e{constructor(e){super(),me(this,e,nB,iB,ae,{raw:0})}}function rB(n){let e,t;const i=n[1].default,s=De(i,n,n[0],null);return{c(){e=z("strong"),s&&s.c()},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,[o]){s&&s.p&&(!t||o&1)&&Le(s,i,r,r[0],t?xe(i,r[0],o,null):Me(r[0]),null)},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function oB(n,e,t){let{$$slots:i={},$$scope:s}=e;return n.$$set=r=>{"$$scope"in r&&t(0,s=r.$$scope)},[s,i]}class lB extends _e{constructor(e){super(),me(this,e,oB,rB,ae,{})}}function aB(n){let e,t;const i=n[1].default,s=De(i,n,n[0],null);return{c(){e=z("table"),s&&s.c()},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,[o]){s&&s.p&&(!t||o&1)&&Le(s,i,r,r[0],t?xe(i,r[0],o,null):Me(r[0]),null)},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function uB(n,e,t){let{$$slots:i={},$$scope:s}=e;return n.$$set=r=>{"$$scope"in r&&t(0,s=r.$$scope)},[s,i]}class cB extends _e{constructor(e){super(),me(this,e,uB,aB,ae,{})}}function fB(n){let e,t;const i=n[1].default,s=De(i,n,n[0],null);return{c(){e=z("thead"),s&&s.c()},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,[o]){s&&s.p&&(!t||o&1)&&Le(s,i,r,r[0],t?xe(i,r[0],o,null):Me(r[0]),null)},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function hB(n,e,t){let{$$slots:i={},$$scope:s}=e;return n.$$set=r=>{"$$scope"in r&&t(0,s=r.$$scope)},[s,i]}class dB extends _e{constructor(e){super(),me(this,e,hB,fB,ae,{})}}function pB(n){let e,t;const i=n[1].default,s=De(i,n,n[0],null);return{c(){e=z("tbody"),s&&s.c()},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,[o]){s&&s.p&&(!t||o&1)&&Le(s,i,r,r[0],t?xe(i,r[0],o,null):Me(r[0]),null)},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function gB(n,e,t){let{$$slots:i={},$$scope:s}=e;return n.$$set=r=>{"$$scope"in r&&t(0,s=r.$$scope)},[s,i]}class mB extends _e{constructor(e){super(),me(this,e,gB,pB,ae,{})}}function _B(n){let e,t;const i=n[1].default,s=De(i,n,n[0],null);return{c(){e=z("tr"),s&&s.c()},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,[o]){s&&s.p&&(!t||o&1)&&Le(s,i,r,r[0],t?xe(i,r[0],o,null):Me(r[0]),null)},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function bB(n,e,t){let{$$slots:i={},$$scope:s}=e;return n.$$set=r=>{"$$scope"in r&&t(0,s=r.$$scope)},[s,i]}class yB extends _e{constructor(e){super(),me(this,e,bB,_B,ae,{})}}function vB(n){let e,t;const i=n[3].default,s=De(i,n,n[2],null);return{c(){e=z("td"),s&&s.c(),v(e,"align",n[1])},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,o){s&&s.p&&(!t||o&4)&&Le(s,i,r,r[2],t?xe(i,r[2],o,null):Me(r[2]),null),(!t||o&2)&&v(e,"align",r[1])},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function wB(n){let e,t;const i=n[3].default,s=De(i,n,n[2],null);return{c(){e=z("th"),s&&s.c(),v(e,"align",n[1])},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,o){s&&s.p&&(!t||o&4)&&Le(s,i,r,r[2],t?xe(i,r[2],o,null):Me(r[2]),null),(!t||o&2)&&v(e,"align",r[1])},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function kB(n){let e,t,i,s;const r=[wB,vB],o=[];function l(a,u){return a[0]?0:1}return e=l(n),t=o[e]=r[e](n),{c(){t.c(),i=we()},m(a,u){o[e].m(a,u),A(a,i,u),s=!0},p(a,[u]){let c=e;e=l(a),e===c?o[e].p(a,u):(oe(),C(o[c],1,1,()=>{o[c]=null}),le(),t=o[e],t?t.p(a,u):(t=o[e]=r[e](a),t.c()),S(t,1),t.m(i.parentNode,i))},i(a){s||(S(t),s=!0)},o(a){C(t),s=!1},d(a){a&&E(i),o[e].d(a)}}}function SB(n,e,t){let{$$slots:i={},$$scope:s}=e,{header:r}=e,{align:o}=e;return n.$$set=l=>{"header"in l&&t(0,r=l.header),"align"in l&&t(1,o=l.align),"$$scope"in l&&t(2,s=l.$$scope)},[r,o,s,i]}class TB extends _e{constructor(e){super(),me(this,e,SB,kB,ae,{header:0,align:1})}}function CB(n){let e,t;const i=n[3].default,s=De(i,n,n[2],null);return{c(){e=z("ul"),s&&s.c()},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,o){s&&s.p&&(!t||o&4)&&Le(s,i,r,r[2],t?xe(i,r[2],o,null):Me(r[2]),null)},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function IB(n){let e,t;const i=n[3].default,s=De(i,n,n[2],null);return{c(){e=z("ol"),s&&s.c(),v(e,"start",n[1])},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,o){s&&s.p&&(!t||o&4)&&Le(s,i,r,r[2],t?xe(i,r[2],o,null):Me(r[2]),null),(!t||o&2)&&v(e,"start",r[1])},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function EB(n){let e,t,i,s;const r=[IB,CB],o=[];function l(a,u){return a[0]?0:1}return e=l(n),t=o[e]=r[e](n),{c(){t.c(),i=we()},m(a,u){o[e].m(a,u),A(a,i,u),s=!0},p(a,[u]){let c=e;e=l(a),e===c?o[e].p(a,u):(oe(),C(o[c],1,1,()=>{o[c]=null}),le(),t=o[e],t?t.p(a,u):(t=o[e]=r[e](a),t.c()),S(t,1),t.m(i.parentNode,i))},i(a){s||(S(t),s=!0)},o(a){C(t),s=!1},d(a){a&&E(i),o[e].d(a)}}}function AB(n,e,t){let{$$slots:i={},$$scope:s}=e,{ordered:r}=e,{start:o}=e;return n.$$set=l=>{"ordered"in l&&t(0,r=l.ordered),"start"in l&&t(1,o=l.start),"$$scope"in l&&t(2,s=l.$$scope)},[r,o,s,i]}class OB extends _e{constructor(e){super(),me(this,e,AB,EB,ae,{ordered:0,start:1})}}function NB(n){let e,t;const i=n[1].default,s=De(i,n,n[0],null);return{c(){e=z("li"),s&&s.c()},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,[o]){s&&s.p&&(!t||o&1)&&Le(s,i,r,r[0],t?xe(i,r[0],o,null):Me(r[0]),null)},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function DB(n,e,t){let{$$slots:i={},$$scope:s}=e;return n.$$set=r=>{"$$scope"in r&&t(0,s=r.$$scope)},[s,i]}class xB extends _e{constructor(e){super(),me(this,e,DB,NB,ae,{})}}function LB(n){let e;return{c(){e=z("hr")},m(t,i){A(t,e,i)},p:Z,i:Z,o:Z,d(t){t&&E(e)}}}class MB extends _e{constructor(e){super(),me(this,e,null,LB,ae,{})}}function RB(n){let e,t;return{c(){e=new oC(!1),t=we(),e.a=t},m(i,s){e.m(n[0],i,s),A(i,t,s)},p(i,[s]){s&1&&e.p(i[0])},i:Z,o:Z,d(i){i&&(E(t),e.d())}}}function PB(n,e,t){let{text:i}=e;return n.$$set=s=>{"text"in s&&t(0,i=s.text)},[i]}class BB extends _e{constructor(e){super(),me(this,e,PB,RB,ae,{text:0})}}function zB(n){let e,t;const i=n[1].default,s=De(i,n,n[0],null);return{c(){e=z("blockquote"),s&&s.c()},m(r,o){A(r,e,o),s&&s.m(e,null),t=!0},p(r,[o]){s&&s.p&&(!t||o&1)&&Le(s,i,r,r[0],t?xe(i,r[0],o,null):Me(r[0]),null)},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function FB(n,e,t){let{$$slots:i={},$$scope:s}=e;return n.$$set=r=>{"$$scope"in r&&t(0,s=r.$$scope)},[s,i]}class WB extends _e{constructor(e){super(),me(this,e,FB,zB,ae,{})}}function VB(n){let e,t,i;return{c(){e=z("pre"),t=z("code"),i=ke(n[1]),v(e,"class",n[0])},m(s,r){A(s,e,r),F(e,t),F(t,i)},p(s,[r]){r&2&&je(i,s[1]),r&1&&v(e,"class",s[0])},i:Z,o:Z,d(s){s&&E(e)}}}function HB(n,e,t){let{lang:i}=e,{text:s}=e;return n.$$set=r=>{"lang"in r&&t(0,i=r.lang),"text"in r&&t(1,s=r.text)},[i,s]}class UB extends _e{constructor(e){super(),me(this,e,HB,VB,ae,{lang:0,text:1})}}function GB(n){let e,t;const i=n[1].default,s=De(i,n,n[0],null);return{c(){e=z("br"),s&&s.c()},m(r,o){A(r,e,o),s&&s.m(r,o),t=!0},p(r,[o]){s&&s.p&&(!t||o&1)&&Le(s,i,r,r[0],t?xe(i,r[0],o,null):Me(r[0]),null)},i(r){t||(S(s,r),t=!0)},o(r){C(s,r),t=!1},d(r){r&&E(e),s&&s.d(r)}}}function jB(n,e,t){let{$$slots:i={},$$scope:s}=e;return n.$$set=r=>{"$$scope"in r&&t(0,s=r.$$scope)},[s,i]}class qB extends _e{constructor(e){super(),me(this,e,jB,GB,ae,{})}}const YB={heading:B6,paragraph:W6,text:U6,image:q6,link:K6,em:Z6,strong:lB,codespan:sB,del:tB,table:cB,tablehead:dB,tablebody:mB,tablerow:yB,tablecell:TB,list:OB,orderedlistitem:null,unorderedlistitem:null,listitem:xB,hr:MB,html:BB,blockquote:WB,code:UB,br:qB},XB={baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,xhtml:!1};function KB(n){let e,t;return e=new oo({props:{tokens:n[0],renderers:n[1]}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,[s]){const r={};s&1&&(r.tokens=i[0]),s&2&&(r.renderers=i[1]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function $B(n,e,t){let i,s,r,o,{source:l=[]}=e,{renderers:a={}}=e,{options:u={}}=e,{isInline:c=!1}=e;const f=mi();let h,d,p;return xy(WS,{slug:g=>s?s.slug(g):"",getOptions:()=>r}),sl(()=>{t(7,p=!0)}),n.$$set=g=>{"source"in g&&t(2,l=g.source),"renderers"in g&&t(3,a=g.renderers),"options"in g&&t(4,u=g.options),"isInline"in g&&t(5,c=g.isInline)},n.$$.update=()=>{n.$$.dirty&4&&t(8,i=Array.isArray(l)),n.$$.dirty&4&&(s=l?new kg:void 0),n.$$.dirty&16&&t(9,r={...XB,...u}),n.$$.dirty&869&&(i?t(0,h=l):(t(6,d=new qs(r)),t(0,h=c?d.inlineTokens(l):d.lex(l)),f("parsed",{tokens:h}))),n.$$.dirty&8&&t(1,o={...YB,...a}),n.$$.dirty&385&&p&&!i&&f("parsed",{tokens:h})},[h,o,l,a,u,c,d,p,i,r]}class JB extends _e{constructor(e){super(),me(this,e,$B,KB,ae,{source:2,renderers:3,options:4,isInline:5})}}function ZB(n){let e;return{c(){e=z("div")},m(t,i){A(t,e,i)},p:Z,i:Z,o:Z,d(t){t&&E(e)}}}function QB(n,e,t){let{href:i=""}=e,{title:s=void 0}=e,{text:r=""}=e;return n.$$set=o=>{"href"in o&&t(0,i=o.href),"title"in o&&t(1,s=o.title),"text"in o&&t(2,r=o.text)},[i,s,r]}class ez extends _e{constructor(e){super(),me(this,e,QB,ZB,ae,{href:0,title:1,text:2})}}function sb(n){let e,t;return e=new yt({props:{$$slots:{default:[tz]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&544&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function tz(n){let e,t;return e=new JB({props:{source:n[5],renderers:n[6]}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&32&&(r.source=i[5]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function rb(n){let e,t,i=n[0]!==null&&n[1]!==null&&sb(n);return{c(){i&&i.c(),e=we()},m(s,r){i&&i.m(s,r),A(s,e,r),t=!0},p(s,r){s[0]!==null&&s[1]!==null?i?(i.p(s,r),r&3&&S(i,1)):(i=sb(s),i.c(),S(i,1),i.m(e.parentNode,e)):i&&(oe(),C(i,1,1,()=>{i=null}),le())},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d(s)}}}function iz(n){let e,t=n[4],i,s=rb(n);return{c(){e=z("div"),s.c(),v(e,"class","wrapper prose svelte-2ict3b")},m(r,o){A(r,e,o),s.m(e,null),i=!0},p(r,[o]){o&16&&ae(t,t=r[4])?(oe(),C(s,1,1,Z),le(),s=rb(r),s.c(),S(s,1),s.m(e,null)):s.p(r,o)},i(r){i||(S(s),i=!0)},o(r){C(s),i=!1},d(r){r&&E(e),s.d(r)}}}function nz(n,e,t){let i,s=Z,r=()=>(s(),s=ot(d,m=>t(4,i=m)),d),o,l=Z,a=()=>(l(),l=ot(h,m=>t(5,o=m)),h);n.$$.on_destroy.push(()=>s()),n.$$.on_destroy.push(()=>l());let{widget:u=null}=e,{isMobile:c=!1}=e,f=null,h=Be("");a();let d=Be(0);r();let p={html:ez};function g(m){m&&(t(1,f=m.node),a(t(2,h=f.value)),r(t(3,d=m.attrsChanged)))}return n.$$set=m=>{"widget"in m&&t(0,u=m.widget),"isMobile"in m&&t(7,c=m.isMobile)},n.$$.update=()=>{n.$$.dirty&1&&u&&g(u)},[u,f,h,d,i,o,p,c]}class sz extends _e{constructor(e){super(),me(this,e,nz,iz,ae,{widget:0,isMobile:7})}}class VS extends As{constructor(t){super(t,"");P(this,"properties",{tags:[],defaultValue:!1});P(this,"svelteComponentType",sz);P(this,"defaultValue","")}createDisplayWidget(){return this.addWidget("text","Value","",i=>{i==null||i===this.getValue()||this.setValue(i)},{multiline:!0,inputStyle:{fontFamily:"monospace"}})}}P(VS,"slotLayout",{inputs:[{name:"store",type:$.ACTION}],outputs:[{name:"value",type:"string"},{name:"changed",type:$.EVENT}]});w.registerNodeType({class:VS,title:"UI.Markdown",desc:"Displays Markdown in the UI",type:"ui/markdown"});const Qs=0x4000000000000;class HS extends Ft{constructor(t){super(t);P(this,"properties",{tags:[],value:null,action:"randomize",min:-Qs,max:Qs,step:1,ignoreStepWhenRandom:!1});P(this,"defaultWidgets",{inputs:{2:{defaultWidgetNode:ha,config:{defaultValue:"randomize",values:["fixed","increment","decrement","randomize"]}}}});P(this,"delayChangeEvent",!0);P(this,"_aboutToChange",0);P(this,"_aboutToChangeValue",null)}onExecute(){if(this._aboutToChange>0&&(this._aboutToChange-=1,this._aboutToChange<=0)){const t=this._aboutToChangeValue;this._aboutToChange=0,this._aboutToChangeValue=null,this.triggerSlot(1,t)}}onAction(t,i){var s=this.getInputData(0);if(typeof s!="number")return;let r=this.getInputData(2);r==null&&(r="fixed");let o=this.getInputData(3);o==null&&(o=-Qs);let l=this.getInputData(4);l==null&&(l=Qs);let a=this.getInputData(5);a==null&&(a=1),this.setProperty("action",r),this.setProperty("min",o),this.setProperty("max",l),this.setProperty("step",a),o=this.properties.min,l=this.properties.max,o==null&&(o=-Qs),l==null&&(l=Qs),o=Math.max(-Qs,this.properties.min),l=Math.min(Qs,this.properties.max);let u=(l-o)/this.properties.step;switch(this.properties.action){case"fixed":break;case"increment":s+=this.properties.step;break;case"decrement":s-=this.properties.step;break;case"randomize":const c=this.properties.ignoreStepWhenRandom?1:this.properties.step;s=Math.floor(Math.random()*u)*c+o}s=yi(s,o,l),this.setProperty("value",s),this.setOutputData(0,s),this.delayChangeEvent?(this._aboutToChange=2,this._aboutToChangeValue=s):this.triggerSlot(1,s)}}P(HS,"slotLayout",{inputs:[{name:"value",type:"number"},{name:"trigger",type:$.ACTION},{name:"action",type:"string"},{name:"min",type:"number"},{name:"max",type:"number"},{name:"step",type:"number"}],outputs:[{name:"value",type:"*"},{name:"changed",type:$.EVENT}]});w.registerNodeType({class:HS,title:"Comfy.ValueControl",desc:"Adjusts an incoming value based on behavior",type:"utils/value_control"});class US extends Ft{constructor(t){super(t);P(this,"properties",{tags:[],value:null});P(this,"canInheritSlotTypes",!0);P(this,"selected",0)}getUpstreamLink(){var t=this.getInputData(0);(t==null||t.constructor!==Number)&&(t=0),this.selected=t=Math.round(t)%(this.inputs.length-1);var i=this.getInputLink(t+1),s=this.getInputNode(t+1);return i!=null&&s!=null&&s.mode===ft.ALWAYS?i:null}onDrawBackground(t){if(!this.flags.collapsed){t.fillStyle="#AFB";var i=(this.selected+1)*w.NODE_SLOT_HEIGHT+6;t.beginPath(),t.moveTo(50,i),t.lineTo(50,i+w.NODE_SLOT_HEIGHT),t.lineTo(34,i+w.NODE_SLOT_HEIGHT*.5),t.fill()}}onExecute(){var t=this.getInputData(0);(t==null||t.constructor!==Number)&&(t=0),this.selected=t=Math.round(t)%(this.inputs.length-1);var i=this.getInputData(t+1);i!==void 0&&this.setOutputData(0,i)}}P(US,"slotLayout",{inputs:[{name:"select",type:"number"},{name:"A",type:"*"},{name:"B",type:"*"},{name:"C",type:"*"},{name:"D",type:"*"}],outputs:[{name:"out",type:"*"}]});w.registerNodeType({class:US,title:"Comfy.Selector",desc:"Selects an output from two or more inputs",type:"utils/selector"});class GS extends Ft{constructor(t){super(t);P(this,"properties",{tags:[],value:null});P(this,"canInheritSlotTypes",!0);P(this,"selected",0)}getUpstreamLink(){var t=this.getInputData(0);(t==null||t.constructor!==Boolean)&&(t=0),this.selected=t?0:1;var i=this.getInputLink(this.selected+1),s=this.getInputNode(this.selected+1);return i!=null&&s!=null&&s.mode===ft.ALWAYS?i:null}onConnectionsChange(t,i,s,r,o){mt.INPUT}onDrawBackground(t){if(!this.flags.collapsed){t.fillStyle="#AFB";var i=(this.selected+1)*w.NODE_SLOT_HEIGHT+6;t.beginPath(),t.moveTo(65,i),t.lineTo(65,i+w.NODE_SLOT_HEIGHT),t.lineTo(49,i+w.NODE_SLOT_HEIGHT*.5),t.fill()}}onExecute(){var t=this.getInputData(0);(t==null||t.constructor!==Boolean)&&(t=0),this.selected=t?0:1;var i=this.getInputData(this.selected+1);i!==void 0&&(this.getInputLink(this.selected+1),this.getInputNode(this.selected+1),this.setOutputData(0,i))}}P(GS,"slotLayout",{inputs:[{name:"select",type:"boolean"},{name:"true",type:"*"},{name:"false",type:"*"}],outputs:[{name:"out",type:"*"}]});w.registerNodeType({class:GS,title:"Comfy.Selector2",desc:"Selects an output from two inputs with a boolean",type:"utils/selector2"});class jS extends Ft{constructor(t){super(t);P(this,"canInheritSlotTypes",!0);P(this,"_selected",null)}getUpstreamLinkForInheritedType(){for(let t=0;t0&&!(f<=0);f-=1)if(!this.hasActiveSlots(f-1))this.removeInput(f*2),this.removeInput(f*2);else break;let c="A";for(let f=0;f{var r;return(r=s.tags)==null?void 0:r.includes(this.properties.imageTagFilter)}):i==null&&(i=0),this.setValue(t,i),this._image==null?(this.setOutputData(0,null),this.setOutputData(1,null),this.setOutputData(2,0),this.setOutputData(3,0),this.setOutputData(4,null),this.widthWidget.value=0,this.heightWidget.value=0):(this.setOutputData(0,this._image),this.setOutputData(1,this._path),this.setOutputData(2,this._image.width),this.setOutputData(3,this._image.height),this.setOutputData(4,this._image.children),this.widthWidget.value=this._image.width,this.heightWidget.value=this._image.height)}}P(YS,"slotLayout",{inputs:[{name:"images",type:"COMFYBOX_IMAGES,COMFYBOX_IMAGE"},{name:"index",type:"number"}],outputs:[{name:"image",type:"COMFYBOX_IMAGE"},{name:"filename",type:"string"},{name:"width",type:"number"},{name:"height",type:"number"},{name:"children",type:"COMFYBOX_IMAGES"}]});w.registerNodeType({class:YS,title:"Comfy.PickImage",desc:"Selects an image from an array of ComfyBox images and returns its properties.",type:"image/pick_image"});class XS extends Ft{onAction(e,t,i){t&&typeof t=="object"&&"noChangedEvent"in t?t.noChangedEvent=!0:t={__widgetValue__:t,noChangedEvent:!0},this.triggerSlot(0,t,null,i)}}P(XS,"slotLayout",{inputs:[{name:"in",type:$.ACTION}],outputs:[{name:"out",type:$.EVENT}]});w.registerNodeType({class:XS,title:"Comfy.NoChangeEvent",desc:"Wraps an event's parameter such that passing it into a ComfyWidgetNode's 'store' action will not trigger its 'changed' event",type:"events/no_change"});class KS extends Ft{onExecute(){const e=this.getInputData(0);Array.isArray(e)&&(this.setOutputData(0,e[2]),this.setOutputData(1,e[3]),this.setOutputData(2,e[0]),this.setOutputData(3,e[1]))}}P(KS,"slotLayout",{inputs:[{name:"in",type:"COMFYBOX_REGION"}],outputs:[{name:"width",type:"number"},{name:"height",type:"number"},{name:"x",type:"number"},{name:"y",type:"number"}]});w.registerNodeType({class:KS,title:"Comfy.RegionToCoords",desc:"Converts a COMFYBOX_REGION to four outputs of [width, height, x, y]",type:"utils/region_to_coords"});class $S extends Ft{constructor(t){super(t);P(this,"properties",{value:null,tags:[]});P(this,"displayWidget");this.displayWidget=this.addWidget("text","Value","","value"),this.displayWidget.disabled=!0}onExecute(){this.getInputLink(0)&&this.setProperty("value",this.getInputData(0))}onAction(t,i){t==="copy"&&(this.setProperty("value",this.getInputData(0)),this.triggerSlot(0,this.properties.value))}}P($S,"slotLayout",{inputs:[{name:"in",type:"*"},{name:"copy",type:$.ACTION}],outputs:[{name:"out",type:$.EVENT}]});w.registerNodeType({class:$S,title:"Comfy.CopyAction",desc:"Copies its input to its output when an event is received",type:"actions/copy"});class JS extends Ft{constructor(t){super(t);P(this,"properties",{tags:[],targetTag:""});P(this,"displayWidget");this.displayWidget=this.addWidget("text","targetTag",this.properties.targetTag,"targetTag")}onExecute(){const t=this.getInputData(1);t&&this.setProperty("tag",t)}getTitle(){return this.flags.collapsed?"Execute: "+String(this.properties.targetTag):this.title}onAction(t,i){const s=this.getInputData(1)||this.properties.targetTag,r=window==null?void 0:window.app;if(!r)return;const o=r.ctrlDown?-1:0;r.queuePrompt(this.workflow,o,1,s)}}P(JS,"slotLayout",{inputs:[{name:"execute",type:$.ACTION},{name:"targetTag",type:"string"}]});w.registerNodeType({class:JS,title:"Comfy.ExecuteSubgraphAction",desc:"Runs a part of the graph based on a tag",type:"actions/execute_subgraph"});class ZS extends Ft{constructor(){super(...arguments);P(this,"properties",{tags:[],message:"Nya.",type:"info",alwaysShow:!1})}onAction(t,i){if(!ti.canShowNotificationText()&&!this.properties.alwaysShow)return;const s=this.getInputData(0)||this.properties.message;if(!s)return;const r={type:this.properties.type,showOn:"all"};if(i!=null&&typeof i=="object"&&"images"in i){const l=vE(i);l.length>0&&(r.imageUrl=l[0].data)}nt(s,r)}}P(ZS,"slotLayout",{inputs:[{name:"message",type:"string"},{name:"trigger",type:$.ACTION}]});w.registerNodeType({class:ZS,title:"Comfy.NotifyAction",desc:"Displays a message.",type:"actions/notify"});class QS extends Ft{constructor(){super(...arguments);P(this,"properties",{tags:[],sound:"notification.mp3"})}onAction(t,i){if(!ti.canPlayNotificationSound())return;const s=this.getInputData(0)||this.properties.sound;s&&Rv(s)}}P(QS,"slotLayout",{inputs:[{name:"sound",type:"string"},{name:"trigger",type:$.ACTION}]});w.registerNodeType({class:QS,title:"Comfy.PlaySoundAction",desc:"Plays a sound located under the sound/ directory.",type:"actions/play_sound"});class eT extends Ft{getActionParams(e){let t=ie(bt),i=0;return typeof t.queueRemaining=="number"&&(i=t.queueRemaining),{queueRemaining:i,subgraph:e}}beforeQueued(e){this.triggerSlot(0,this.getActionParams(e))}afterQueued(e,t){this.triggerSlot(1,this.getActionParams(t))}onDefaultQueueAction(){let e=ie(bt),t=0;typeof e.queueRemaining=="number"&&(t=e.queueRemaining),this.triggerSlot(2,{queueRemaining:t})}onSerialize(e){super.onSerialize(e)}}P(eT,"slotLayout",{outputs:[{name:"beforeQueued",type:$.EVENT},{name:"afterQueued",type:$.EVENT},{name:"onDefaultQueueAction",type:$.EVENT}]});w.registerNodeType({class:eT,title:"Comfy.QueueEvents",desc:"Triggers a 'bang' event when a prompt is queued.",type:"events/queue_events"});function rz(n){return n.is(Yc)||n.is(ks)}function oz(n){return n.is(qi)||n.is(pn)}function If(n,e,t){var i;for(;n!=null;){if("tags"in n.properties&&n.properties.tags.indexOf(e)!==-1)return!0;if(!t)return!1;n=(i=n.graph)==null?void 0:i._subgraph_node}return!1}function Fl(n,e=null){return!(!n||!rz(n)&&!oz(n)&&e&&!If(n,e,!0)||n.mode!==ft.ALWAYS)}function tT(n,e=null){return!(!n.isBackendNode||!Fl(n,e)||n.graph._is_subgraph&&Array.from(n.iterateParentSubgraphNodes()).some(i=>!Fl(i,e)))}function lz(n,e){if(e.origin_id!=n.id)throw new Error("Invalid link and graph output!");const t=n.getInnerGraphOutputByIndex(e.origin_slot);if(t==null)throw new Error("No inner graph input!");const i=t.getInputLink(0);return[t.graph,i,0,t]}function az(n,e){if(e.origin_id!=n.id)throw new Error("Invalid link and graph input!");const t=n.getParentSubgraph();if(t==null)throw new Error("No outer subgraph!");const i=t.inputs.findIndex(r=>r.name===n.nameInGraph);if(i===-1)throw new Error("No outer input slot!");const s=t.getInputLink(i);return[t.graph,s,i,t]}function uz(n,e){if(n.is(an))return lz(n,e);if(n.is(qi))return az(n,e);if("getUpstreamLink"in n){const t=n.getUpstreamLink();return[n.graph,t,t==null?void 0:t.target_slot,n]}else if(n.inputs.length===1){const t=n.getInputLink(0);if(t)return[n.graph,t,0,n]}return[null,null,null,null]}class iT{constructor(e){this.isTheTargetNode=e}locateUpstream(e,t,i){let s=e.getInputNode(t);if(!s)return[null,null,null,null];const r={};let o=e.getInputLink(t),l=t,a=e;const u=(c,f)=>Fl(c,i)&&!this.isTheTargetNode(c,f);for(;u(s,o);){const[c,f,h,d]=uz(s,o);if(l=h,a=d,f==null)break;if(f&&!r[f.id]){r[f.id]=!0;const p=c.getNodeById(f.origin_id);Fl(s,i)?(o=f,s=p):s=null}else s=null}return!Fl(s,i)||!this.isTheTargetNode(s,o)||o==null?[null,o,l,a]:[s,o,l,a]}}class cz{serializeInputValues(e){var i;if(!e.inputs)return{};const t={};for(let s=0;so.isBackendNode,r=new iT(s);for(let o=0;oa.id===r.id),!tT(r,t))continue;const o=this.serializeInputValues(r),l=this.serializeBackendLinks(r,t);s[String(r.id)]={inputs:{...o,...l},class_type:r.comfyClass}}for(const r in s)for(const o in s[r].inputs)Array.isArray(s[r].inputs[o])&&s[r].inputs[o].length===2&&!s[s[r].inputs[o][0]]&&delete s[r].inputs[o];return{workflow:i,output:s}}}class nT extends Ft{constructor(t){super(t);P(this,"properties",{targetTags:"",enable:!1,tags:[]});P(this,"displayWidget");P(this,"enableWidget");this.displayWidget=this.addWidget("text","Tags",this.properties.targetTags,"targetTags"),this.enableWidget=this.addWidget("toggle","Enable",this.properties.enable,"enable")}onPropertyChanged(t,i){t==="enable"&&(this.enableWidget.value=i)}onAction(t,i){let s=this.getInputData(0);s==null&&(s=this.properties.enable);let r=!!s;typeof i=="object"&&"enabled"in i&&(r=i.enabled);const o=this.properties.targetTags.split(",").map(l=>l.trim());for(const l of this.graph._nodes)if("tags"in l.properties){const a=l;if(o.some(c=>If(a,c,!1))){let c;r?c=ft.ALWAYS:c=ft.NEVER,l.changeMode(c),"notifyPropsChanged"in l&&l.notifyPropsChanged()}}for(const l of Object.values(ie(this.layoutState).allItems))if(l.dragItem.type==="container"){const a=l.dragItem;o.some(c=>a.attrs.tags.indexOf(c)!=-1)&&(a.attrs.hidden=!r),a.attrsChanged.set(ie(a.attrsChanged)+1)}}}P(nT,"slotLayout",{inputs:[{name:"enabled",type:"boolean"},{name:"set",type:$.ACTION}]});w.registerNodeType({class:nT,title:"Comfy.SetNodeModeAction",desc:"Sets a group of nodes/UI containers as enabled/disabled based on their tags (comma-separated)",type:"actions/set_node_mode"});class jd extends Ft{constructor(t){super(t);P(this,"properties",{targetTags:[{tag:"myTag",enable:!0},{tag:"anotherTag",enable:!1}],enable:!0,tags:[]});P(this,"displayWidget");P(this,"enableWidget");this.displayWidget=this.addWidget("text","Tags",this.formatTags(),null),this.displayWidget.disabled=!0,this.enableWidget=this.addWidget("toggle","Enable",this.properties.enable,"enable")}onPropertyChanged(t,i){t==="enable"?this.enableWidget.value=i:t==="targetTags"&&(this.displayWidget.value=this.formatTags())}formatTags(){return!Array.isArray(this.properties.targetTags)||this.properties.targetTags.length===0?"(No tags)":this.properties.targetTags.map(t=>{let i=t.tag;return t.enable?i="+"+i:i="!"+i,i}).join(", ")}getModeChanges(t,i,s,r){for(const o of this.graph.iterateNodesInOrderRecursive())if("tags"in o.properties&&If(o,t.tag,!1)){let u;t.enable?u=i?ft.ALWAYS:ft.NEVER:u=i?ft.NEVER:ft.ALWAYS,s[o.id]=u}for(const o of Object.values(ie(this.layoutState).allItems))if(o.dragItem.type==="container"){const l=o.dragItem;if(l.attrs.tags.indexOf(t.tag)!=-1){let u;t.enable?u=!i:u=i,r[l.id]=u}}}onExecute(){this.boxcolor=w.NODE_DEFAULT_BOXCOLOR;for(const t of this.properties.targetTags)if(typeof t!="object"||!("tag"in t)||!("enable"in t)){this.boxcolor="red";break}}onAction(t,i){let s=this.getInputData(0);s==null&&(s=this.properties.enable);let r=!!s;typeof i=="object"&&"enabled"in i&&(r=i.enabled);const o={},l={};for(const u of this.properties.targetTags)this.getModeChanges(u,r,o,l);for(const[u,c]of Object.entries(o))this.graph.getNodeByIdRecursive(u).changeMode(c);const a=ie(this.layoutState);for(const[u,c]of Object.entries(l)){const f=a.allItems[u].dragItem;f.attrs.hidden=c,f.attrsChanged.set(ie(f.attrsChanged)+1)}}}P(jd,"slotLayout",{inputs:[{name:"enabled",type:"boolean"},{name:"set",type:$.ACTION}]}),P(jd,"propertyLayout",[{name:"enable",defaultValue:!0,type:"boolean"},{name:"targetTags",defaultValue:[{tag:"myTag",enable:!0},{tag:"anotherTag",enable:!1}],type:"array",options:{multiline:!0,inputStyle:{fontFamily:"monospace"}}}]);w.registerNodeType({class:jd,title:"Comfy.SetNodeModeAdvancedAction",desc:"Turns multiple groups of nodes on/off at once based on an array of rules [{ tag: string, enable: boolean }, ...]",type:"actions/set_node_mode_advanced"});class sT extends Ft{constructor(){super(...arguments);P(this,"properties",{tags:[],defaultFolderType:"input"});P(this,"_value",null)}getPromptThumbnails(){const t=this.getInputData(0);return EE(t)}}P(sT,"slotLayout",{inputs:[{name:"filenames",type:"*"}]});w.registerNodeType({class:sT,title:"Comfy.SetPromptThumbnailsAction",desc:"When a subgraph containing this node is executed, sets the thumbnails in the queue sidebar to the input filename(s).",type:"actions/set_prompt_thumbnails"});class rT extends Ft{constructor(){super(...arguments);P(this,"properties",{tags:[],images:null})}onExecute(){this.properties.images!==null&&this.setOutputData(0,this.properties.images)}onAction(t,i){t!=="store"||!i||!("images"in i)||(this.setProperty("images",i),this.setOutputData(0,this.properties.images))}}P(rT,"slotLayout",{inputs:[{name:"output",type:$.ACTION,options:{color_off:"rebeccapurple",color_on:"rebeccapurple"}}],outputs:[{name:"images",type:"OUTPUT"}]});w.registerNodeType({class:rT,title:"Comfy.StoreImagesAction",desc:"Stores images from an onExecuted callback",type:"actions/store_images"});class oT extends Ft{onAction(e,t){const i=this.getInputData(0),s=this.getInputData(1);this.triggerSlot(0,s),this.triggerSlot(1,i)}}P(oT,"slotLayout",{inputs:[{name:"A",type:"*"},{name:"B",type:"*"},{name:"swap",type:$.ACTION}],outputs:[{name:"B",type:$.EVENT},{name:"A",type:$.EVENT}]});w.registerNodeType({class:oT,title:"Comfy.SwapAction",desc:"Swaps two inputs when triggered",type:"actions/swap"});class lT extends Ft{constructor(){super(...arguments);P(this,"properties",{tags:[]});P(this,"isActive",!1)}onAction(t,i){const s=this.getInputData(0);if(s==null){nt("No workflow data to send!",{type:"error"});return}if(this.isActive)return;let r=Lv(s);const o=ht.findReceiveOutputTargets(r);this.isActive=!0,Jl.querySendOutput(s,r,o,()=>{this.isActive=!1})}}P(lT,"slotLayout",{inputs:[{name:"value",type:"*"},{name:"trigger",type:$.ACTION}]});w.registerNodeType({class:lT,title:"Comfy.SendOutputAction",desc:"Sends a workflow output elsewhere",type:"actions/send_output"});function fz(n,e){let t=[];return t=t.concat(Array.from(up)),t.push("COMFYBOX_IMAGE"),t.push("COMFYBOX_IMAGES"),t}class aT extends Ft{constructor(t){super(t);P(this,"properties",{tags:[],name:"Image",description:"Generic image input.",type:"COMFYBOX_IMAGE"});P(this,"size",[180,90]);P(this,"nameWidget");P(this,"descriptionWidget");P(this,"typeWidget");P(this,"isActive",!1);P(this,"_queue",[]);this.nameWidget=this.addWidget("text","Name",this.properties.name,"name"),this.descriptionWidget=this.addWidget("text","Desc.",this.properties.description,"description",{multiline:!0}),this.typeWidget=this.addWidget("combo","Type",""+this.properties.type,"type",{values:fz})}onPropertyChanged(t,i){if(t==="type"){const s=re.DEFAULT_CONNECTION_COLORS_BY_TYPE[i]||re.DEFAULT_CONNECTION_COLORS_BY_TYPE[$.EVENT];this.outputs[0].color_on=s,this.outputs[0].color_off=s}}getTitle(){return this.flags.collapsed?this.properties.name:this.title}onExecute(){for(;this._queue.length>0;)this.triggerSlot(0,this._queue.splice(0,1))}receiveOutput(t){if(Lv(t)!==this.properties.type){nt("Output type mismatch!",{type:"error"});return}this._queue.push(t)}}P(aT,"slotLayout",{outputs:[{name:"received",type:$.EVENT,options:{color_off:"fuchsia",color_on:"fuchsia"}}]});w.registerNodeType({class:aT,title:"Comfy.ReceiveOutput",desc:"Receives a workflow output sent from elsewhere",type:"events/receive_output"});class hz{constructor(){P(this,"eventBus",new wv);P(this,"socket",null);P(this,"clientId",null);P(this,"hostname",null);P(this,"port",8188)}addEventListener(e,t){this.eventBus.addListener(e,t)}pollQueue(){setInterval(async()=>{try{const t=await(await fetch(this.getBackendUrl()+"/prompt")).json();this.eventBus.emit("status",{execInfo:{queueRemaining:t.exec_info.queue_remaining}})}catch(e){this.eventBus.emit("status",{error:e.toString()})}},1e3)}getHostname(){let e=this.hostname||location.hostname;return e==="localhost"&&(e=location.hostname),e}getBackendUrl(){const e=this.getHostname(),t=this.port||location.port;return`${window.location.protocol}//${e}:${t}`}createSocket(e=!1){if(this.socket)return;let t=!1,i=sessionStorage["Comfy.SessionId"]||"";i&&(i="?clientId="+i);const s=this.getHostname(),r=this.port||location.port;this.socket=new WebSocket(`ws${window.location.protocol==="https:"?"s":""}://${s}:${r}/ws${i}`),this.socket.binaryType="arraybuffer",this.socket.addEventListener("open",()=>{t=!0,e&&this.eventBus.emit("reconnected")}),this.socket.addEventListener("error",()=>{this.socket&&this.socket.close(),!e&&!t&&this.pollQueue()}),this.socket.addEventListener("close",()=>{setTimeout(()=>{this.socket=null,this.createSocket(!0)},300),t&&(this.eventBus.emit("status",null),this.eventBus.emit("reconnecting"))}),this.socket.addEventListener("message",o=>{try{if(o.data instanceof ArrayBuffer){const a=new DataView(o.data).getUint32(0),u=o.data.slice(4);switch(a){case 1:const f=new DataView(o.data).getUint32(0);let h;switch(f){case 1:default:h="image/jpeg";break;case 2:h="image/png"}const d=new Blob([u.slice(4)],{type:h});this.eventBus.emit("b_preview",d);break;default:throw new Error(`Unknown binary websocket message of type ${a}`)}}else{const l=JSON.parse(o.data);switch(l.type){case"status":l.data.sid&&(this.clientId=l.data.sid,sessionStorage["Comfy.SessionId"]=this.clientId),this.eventBus.emit("status",{execInfo:{queueRemaining:l.data.status.exec_info.queue_remaining}});break;case"progress":this.eventBus.emit("progress",l.data);break;case"executing":this.eventBus.emit("executing",l.data.prompt_id,l.data.node);break;case"executed":this.eventBus.emit("executed",l.data.prompt_id,l.data.node,l.data.output);break;case"execution_start":this.eventBus.emit("execution_start",l.data.prompt_id);break;case"execution_cached":this.eventBus.emit("execution_cached",l.data.prompt_id,l.data.nodes);break;case"execution_interrupted":this.eventBus.emit("execution_interrupted",l.data);break;case"execution_error":this.eventBus.emit("execution_error",l.data);break;default:}}}catch{}})}init(){this.createSocket()}async getExtensions(){return fetch(this.getBackendUrl()+"/extensions",{cache:"no-store"}).then(e=>e.json())}async getEmbeddings(){return fetch(this.getBackendUrl()+"/embeddings",{cache:"no-store"}).then(e=>e.json())}async getNodeDefs(){return fetch(this.getBackendUrl()+"/object_info",{cache:"no-store"}).then(e=>e.json())}async queuePrompt(e){e.client_id=this.clientId,e.number===-1&&(e.front=!0);let t=null;try{t=JSON.stringify(e)}catch(i){return Promise.reject({error:i.toString()})}return fetch(this.getBackendUrl()+"/prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:t}).then(async i=>{if(i.status!=200)throw await i.json();return i.json()}).then(i=>({promptID:i.prompt_id,number:i.number})).catch(i=>i)}async getQueue(){return fetch(this.getBackendUrl()+"/queue").then(e=>e.json()).then(e=>({running:e.queue_running,pending:e.queue_pending})).catch(e=>({running:[],pending:[],error:e}))}async getHistory(){return fetch(this.getBackendUrl()+"/history").then(e=>e.json()).then(e=>({history:e})).catch(e=>({history:{},error:e}))}async postItem(e,t){try{t=t&&JSON.stringify(t)}catch(i){return Promise.reject(i)}return fetch(this.getBackendUrl()+"/"+e,{method:"POST",headers:{"Content-Type":"application/json"},body:t})}async deleteItem(e,t){return this.postItem(e,{delete:[t]})}async clearItems(e){return this.postItem(e,{clear:!0})}async interrupt(){return fetch(this.getBackendUrl()+"/interrupt",{method:"POST"})}async getSystemStats(){return fetch(this.getBackendUrl()+"/system_stats").then(async e=>await e.json())}}function*dz(n){const e=[137,80,78,71,13,10,26,10],t=4,i=4,s=4;let r=new DataView(n.buffer),o=new TextDecoder("utf-8",{fatal:!0}),l=0;for(let a=0;ai===0);if(t<0)return{kind:1,error:"PNG parse error: no null separator in tEXt chunk"};try{let i=e.decode(n.subarray(0,t)),s=e.decode(n.subarray(t+1,n.byteLength));return{keyword:i,text:s}}catch(i){return{kind:7,error:i}}}async function gz(n){let e=new Uint8Array(n);const t={};let i,s=dz(e);do if(i=s.next(),!i.done){let r=i.value;if("kind"in r||r.type!=="tEXt")continue;let o=pz(r.data);if("kind"in o)continue;let l=o;t[l.keyword]=l.text}while(i.value!=null&&!i.done);return t}function ob(n,e,t){const i=n.slice();return i[12]=e[t],i[14]=t,i}function mz(n){let e,t=n[8][0]+"",i,s,r,o,l,a=n[8][1]+"",u,c,f,h,d,p=Xe(n[7]),g=[];for(let b=0;bC(g[b],1,1,()=>{g[b]=null});let _=!n[5]&&cb();return{c(){e=z("span"),i=ke(t),s=se(),r=z("ul");for(let b=0;b{c[p]=null}),le(),r=c[s],r?r.p(h,d):(r=c[s]=u[s](h),r.c()),S(r,1),r.m(e,o))},i(h){l||(S(r),l=!0)},o(h){C(r),l=!1},d(h){h&&E(e),a&&a.d(),c[s].d()}}}function cb(n){let e;return{c(){e=z("span"),e.textContent=",",v(e,"class","_jsonSep svelte-uhdygg")},m(t,i){A(t,e,i)},d(t){t&&E(e)}}}function fb(n){let e;return{c(){e=z("span"),e.textContent=",",v(e,"class","_jsonSep svelte-uhdygg")},m(t,i){A(t,e,i)},d(t){t&&E(e)}}}function hb(n){let e;return{c(){e=z("span"),e.textContent=",",v(e,"class","_jsonSep svelte-uhdygg")},m(t,i){A(t,e,i)},d(t){t&&E(e)}}}function wz(n){let e,t,i,s;const r=[bz,_z,mz],o=[];function l(a,u){return a[7].length?a[0]?1:2:0}return e=l(n),t=o[e]=r[e](n),{c(){t.c(),i=we()},m(a,u){o[e].m(a,u),A(a,i,u),s=!0},p(a,[u]){let c=e;e=l(a),e===c?o[e].p(a,u):(oe(),C(o[c],1,1,()=>{o[c]=null}),le(),t=o[e],t?t.p(a,u):(t=o[e]=r[e](a),t.c()),S(t,1),t.m(i.parentNode,i))},i(a){s||(S(t),s=!0)},o(a){C(t),s=!1},d(a){a&&E(i),o[e].d(a)}}}function oa(n){return n===null?"null":typeof n}function db(n){const e=oa(n);return e==="string"?`"${n}"`:e==="function"?"f () {...}":e==="symbol"?n.toString():n}function kz(n,e,t){let{json:i}=e,{depth:s=1/0}=e,{collapseByDefault:r=!1}=e,{_cur:o=0}=e,{_last:l=!0}=e,a,u=!1,c=["",""],{collapsed:f=null}=e;function h(){t(0,f=!f)}function d(g){g instanceof KeyboardEvent&&["Enter"," "].includes(g.key)&&h()}function p(g){return typeof r=="function"?r(g):typeof r=="boolean"?r:null}return n.$$set=g=>{"json"in g&&t(1,i=g.json),"depth"in g&&t(2,s=g.depth),"collapseByDefault"in g&&t(3,r=g.collapseByDefault),"_cur"in g&&t(4,o=g._cur),"_last"in g&&t(5,l=g._last),"collapsed"in g&&t(0,f=g.collapsed)},n.$$.update=()=>{n.$$.dirty&66&&(t(7,a=oa(i)==="object"?Object.keys(i):[]),t(6,u=Array.isArray(i)),t(8,c=u?["[","]"]:["{","}"])),n.$$.dirty&21&&f===null&&t(0,f=s{f=null}),le());const g={};d&34&&(g.$$scope={dirty:d,ctx:h}),l.$set(g);const m={};d&48&&(m.$$scope={dirty:d,ctx:h}),u.$set(m)},i(h){c||(S(i.$$.fragment,h),S(f),S(l.$$.fragment,h),S(u.$$.fragment,h),c=!0)},o(h){C(i.$$.fragment,h),C(f),C(l.$$.fragment,h),C(u.$$.fragment,h),c=!1},d(h){h&&E(e),j(i),f&&f.d(),j(l),j(u)}}}function Sz(n){let e,t;return e=new dr({props:{label:"Infotext",show_label:!0,value:n[3],lines:5,max_lines:20}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&8&&(r.value=i[3]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function gb(n){let e=Object.keys(n[2].extraParams).length>0,t,i,s=e&&mb(n);return{c(){s&&s.c(),t=we()},m(r,o){s&&s.m(r,o),A(r,t,o),i=!0},p(r,o){o&4&&(e=Object.keys(r[2].extraParams).length>0),e?s?(s.p(r,o),o&4&&S(s,1)):(s=mb(r),s.c(),S(s,1),s.m(t.parentNode,t)):s&&(oe(),C(s,1,1,()=>{s=null}),le())},i(r){i||(S(s),i=!0)},o(r){C(s),i=!1},d(r){r&&E(t),s&&s.d(r)}}}function mb(n){let e,t;return e=new yt({props:{$$slots:{default:[Cz]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&36&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function Tz(n){let e;return{c(){e=ke("Unused Parameters")},m(t,i){A(t,e,i)},d(t){t&&E(e)}}}function Cz(n){let e,t,i,s,r;return e=new kn({props:{$$slots:{default:[Tz]},$$scope:{ctx:n}}}),s=new Ef({props:{json:n[2].extraParams}}),{c(){Y(e.$$.fragment),t=se(),i=z("div"),Y(s.$$.fragment),v(i,"class","json svelte-a5z4q2")},m(o,l){G(e,o,l),A(o,t,l),A(o,i,l),G(s,i,null),r=!0},p(o,l){const a={};l&32&&(a.$$scope={dirty:l,ctx:o}),e.$set(a);const u={};l&4&&(u.json=o[2].extraParams),s.$set(u)},i(o){r||(S(e.$$.fragment,o),S(s.$$.fragment,o),r=!0)},o(o){C(e.$$.fragment,o),C(s.$$.fragment,o),r=!1},d(o){o&&(E(t),E(i)),j(e,o),j(s)}}}function Iz(n){let e;return{c(){e=ke("Converted Prompt")},m(t,i){A(t,e,i)},d(t){t&&E(e)}}}function Ez(n){let e,t,i,s,r;return e=new kn({props:{$$slots:{default:[Iz]},$$scope:{ctx:n}}}),s=new Ef({props:{json:n[1]}}),{c(){Y(e.$$.fragment),t=se(),i=z("div"),Y(s.$$.fragment),v(i,"class","json svelte-a5z4q2")},m(o,l){G(e,o,l),A(o,t,l),A(o,i,l),G(s,i,null),r=!0},p(o,l){const a={};l&32&&(a.$$scope={dirty:l,ctx:o}),e.$set(a);const u={};l&2&&(u.json=o[1]),s.$set(u)},i(o){r||(S(e.$$.fragment,o),S(s.$$.fragment,o),r=!0)},o(o){C(e.$$.fragment,o),C(s.$$.fragment,o),r=!1},d(o){o&&(E(t),E(i)),j(e,o),j(s)}}}function Az(n){let e,t;return e=new zp({props:{show_label:!1,label:"Image",value:n[4]}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&16&&(r.value=i[4]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function Oz(n){let e,t,i=n[0]!=null&&pb(n);return{c(){i&&i.c(),e=we()},m(s,r){i&&i.m(s,r),A(s,e,r),t=!0},p(s,[r]){s[0]!=null?i?(i.p(s,r),r&1&&S(i,1)):(i=pb(s),i.c(),S(i,1),i.m(e.parentNode,e)):i&&(oe(),C(i,1,1,()=>{i=null}),le())},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d(s)}}}function Nz(n,e,t){let{prompt:i=null}=e,s={},r=null,o="",l=null;return n.$$set=a=>{"prompt"in a&&t(0,i=a.prompt)},n.$$.update=()=>{n.$$.dirty&1&&(i?(t(3,o=i.infotext),t(2,r=i.parsedInfotext),t(1,s=i.stdPrompt),t(4,l=URL.createObjectURL(i.imageFile))):(t(3,o=""),t(2,r=null),t(1,s={}),t(4,l=null)))},[i,s,r,o,l]}class Dz extends _e{constructor(e){super(),me(this,e,Nz,Oz,ae,{prompt:0})}}function _b(n,e,t){const i=n.slice();return i[1]=e[t],i}function bb(n){let e,t=n[1]+"",i;return{c(){e=z("li"),i=ke(t),v(e,"class","svelte-162c7mp")},m(s,r){A(s,e,r),F(e,i)},p(s,r){r&1&&t!==(t=s[1]+"")&&je(i,t)},d(s){s&&E(e)}}}function xz(n){let e,t,i,s,r=Xe(Array.from(n[0])),o=[];for(let l=0;l{"missingNodeTypes"in s&&t(0,i=s.missingNodeTypes)},[i]}class Mz extends _e{constructor(e){super(),me(this,e,Lz,xz,ae,{missingNodeTypes:0})}}function yb(n,e,t){const i=n.slice();return i[1]=e[t],i}function vb(n){let e,t=n[1]+"",i;return{c(){e=z("li"),i=ke(t),v(e,"class","svelte-162c7mp")},m(s,r){A(s,e,r),F(e,i)},p(s,r){r&1&&t!==(t=s[1]+"")&&je(i,t)},d(s){s&&E(e)}}}function Rz(n){let e,t,i,s,r=Xe(Array.from(n[0])),o=[];for(let l=0;l{"missingNodeTypes"in s&&t(0,i=s.missingNodeTypes)},[i]}class Bz extends _e{constructor(e){super(),me(this,e,Pz,Rz,ae,{missingNodeTypes:0})}}function zz(n){var g;let e,t,i,s,r,o=n[0].toString()+"",l,a,u,c,f,h=(((g=n[0])==null?void 0:g.stack)||"(No stacktrace available)")+"",d,p;return{c(){e=z("div"),t=ke(`Loading aborted due to error reloading workflow data: - `),i=z("div"),s=z("pre"),r=ke(" "),l=ke(o),a=ke(` - `),u=se(),c=z("pre"),f=ke(" "),d=ke(h),p=ke(` - `),v(s,"class","error svelte-12ax952"),v(c,"class","stack svelte-12ax952"),v(i,"class","error-block svelte-12ax952"),v(e,"class","svelte-12ax952")},m(m,_){A(m,e,_),F(e,t),F(e,i),F(i,s),F(s,r),F(s,l),F(s,a),F(i,u),F(i,c),F(c,f),F(c,d),F(c,p)},p(m,[_]){var b;_&1&&o!==(o=m[0].toString()+"")&&je(l,o),_&1&&h!==(h=(((b=m[0])==null?void 0:b.stack)||"(No stacktrace available)")+"")&&je(d,h)},i:Z,o:Z,d(m){m&&E(e)}}}function Fz(n,e,t){let{error:i}=e;return n.$$set=s=>{"error"in s&&t(0,i=s.error)},[i]}class Wz extends _e{constructor(e){super(),me(this,e,Fz,zz,ae,{error:0})}}function wb(n,e,t){const i=n.slice();return i[14]=e[t],i[16]=t,i}function Vz(n){let e,t=n[14].name+"",i,s,r,o;function l(){return n[12](n[14],n[16])}return{c(){e=z("button"),i=ke(t),s=se(),v(e,"class","svelte-1tkhcg5")},m(a,u){A(a,e,u),F(e,i),F(e,s),r||(o=ee(e,"click",l),r=!0)},p(a,u){n=a,u&8&&t!==(t=n[14].name+"")&&je(i,t)},d(a){a&&E(e),r=!1,o()}}}function Hz(n){let e,t=n[14].name+"",i,s;return{c(){e=z("button"),i=ke(t),s=se(),v(e,"class","selected svelte-1tkhcg5")},m(r,o){A(r,e,o),F(e,i),F(e,s)},p(r,o){o&8&&t!==(t=r[14].name+"")&&je(i,t)},d(r){r&&E(e)}}}function kb(n,e){let t,i;function s(l,a){return l[14].id===l[4]?Hz:Vz}let r=s(e),o=r(e);return{key:n,first:null,c(){t=we(),o.c(),i=we(),this.first=t},m(l,a){A(l,t,a),o.m(l,a),A(l,i,a)},p(l,a){e=l,r===(r=s(e))&&o?o.p(e,a):(o.d(1),o=r(e),o&&(o.c(),o.m(i.parentNode,i)))},d(l){l&&(E(t),E(i)),o.d(l)}}}function Uz(n){let e,t,i=[],s=new Map,r,o,l,a=Xe(n[3]);const u=h=>h[14].id;for(let h=0;ht(4,s=_));const d=Be(0);Si(n,d,_=>t(13,i=_));const p=mi();xy(uT,{register_tab:_=>(f.push({name:_.name,id:_.id}),h.update(b=>b??_.id),t(3,f),f.length-1),unregister_tab:_=>{const b=f.findIndex(y=>y.id===_.id);f.splice(b,1),h.update(y=>{var k,T;return y===_.id?((k=f[b])==null?void 0:k.id)||((T=f[f.length-1])==null?void 0:T.id):y})},selected_tab:h,selected_tab_index:d});function g(_){t(9,c=_),pi(h,s=_,s),pi(d,i=f.findIndex(b=>b.id===_),i),p("change")}const m=(_,b)=>{g(_.id),p("select",{value:_.name,index:b})};return n.$$set=_=>{"visible"in _&&t(0,l=_.visible),"elem_id"in _&&t(1,a=_.elem_id),"elem_classes"in _&&t(2,u=_.elem_classes),"selected"in _&&t(9,c=_.selected),"$$scope"in _&&t(10,o=_.$$scope)},n.$$.update=()=>{n.$$.dirty&512&&c!==null&&g(c)},[l,a,u,f,s,h,d,p,g,c,o,r,m]}class cT extends _e{constructor(e){super(),me(this,e,Gz,Uz,ae,{visible:0,elem_id:1,elem_classes:2,selected:9})}}function jz(n){let e,t,i,s;const r=n[8].default,o=De(r,n,n[7],null);return{c(){e=z("div"),o&&o.c(),v(e,"id",n[2]),v(e,"class",t=mr(n[3].join(" "))+" svelte-1m1obck"),v(e,"style",i=`min-width: min(${n[1]}px, 100%); flex-grow: ${n[0]}`),B(e,"gap",n[6].gap!==!1),B(e,"compact",n[5]==="compact"),B(e,"panel",n[5]==="panel"),B(e,"hide",!n[4])},m(l,a){A(l,e,a),o&&o.m(e,null),s=!0},p(l,[a]){o&&o.p&&(!s||a&128)&&Le(o,r,l,l[7],s?xe(r,l[7],a,null):Me(l[7]),null),(!s||a&4)&&v(e,"id",l[2]),(!s||a&8&&t!==(t=mr(l[3].join(" "))+" svelte-1m1obck"))&&v(e,"class",t),(!s||a&3&&i!==(i=`min-width: min(${l[1]}px, 100%); flex-grow: ${l[0]}`))&&v(e,"style",i),(!s||a&72)&&B(e,"gap",l[6].gap!==!1),(!s||a&40)&&B(e,"compact",l[5]==="compact"),(!s||a&40)&&B(e,"panel",l[5]==="panel"),(!s||a&24)&&B(e,"hide",!l[4])},i(l){s||(S(o,l),s=!0)},o(l){C(o,l),s=!1},d(l){l&&E(e),o&&o.d(l)}}}function qz(n,e,t){let{$$slots:i={},$$scope:s}=e,{scale:r=1}=e,{min_width:o=0}=e,{elem_id:l=""}=e,{elem_classes:a=[]}=e,{visible:u=!0}=e,{variant:c="default"}=e,{style:f={}}=e;return n.$$set=h=>{"scale"in h&&t(0,r=h.scale),"min_width"in h&&t(1,o=h.min_width),"elem_id"in h&&t(2,l=h.elem_id),"elem_classes"in h&&t(3,a=h.elem_classes),"visible"in h&&t(4,u=h.visible),"variant"in h&&t(5,c=h.variant),"style"in h&&t(6,f=h.style),"$$scope"in h&&t(7,s=h.$$scope)},[r,o,l,a,u,c,f,s,i]}let Yz=class extends _e{constructor(e){super(),me(this,e,qz,jz,ae,{scale:0,min_width:1,elem_id:2,elem_classes:3,visible:4,variant:5,style:6})}};function Xz(n){let e;const t=n[8].default,i=De(t,n,n[9],null);return{c(){i&&i.c()},m(s,r){i&&i.m(s,r),e=!0},p(s,r){i&&i.p&&(!e||r&512)&&Le(i,t,s,s[9],e?xe(t,s[9],r,null):Me(s[9]),null)},i(s){e||(S(i,s),e=!0)},o(s){C(i,s),e=!1},d(s){i&&i.d(s)}}}function Kz(n){let e,t,i,s;return t=new Yz({props:{$$slots:{default:[Xz]},$$scope:{ctx:n}}}),{c(){e=z("div"),Y(t.$$.fragment),v(e,"id",n[0]),v(e,"class",i="tabitem "+n[1].join(" ")+" svelte-ztmw93"),ve(e,"display",n[3]===n[2]?"block":"none")},m(r,o){A(r,e,o),G(t,e,null),s=!0},p(r,[o]){const l={};o&512&&(l.$$scope={dirty:o,ctx:r}),t.$set(l),(!s||o&1)&&v(e,"id",r[0]),(!s||o&2&&i!==(i="tabitem "+r[1].join(" ")+" svelte-ztmw93"))&&v(e,"class",i),o&12&&ve(e,"display",r[3]===r[2]?"block":"none")},i(r){s||(S(t.$$.fragment,r),s=!0)},o(r){C(t.$$.fragment,r),s=!1},d(r){r&&E(e),j(t)}}}function $z(n,e,t){let i,s,{$$slots:r={},$$scope:o}=e,{elem_id:l=""}=e,{elem_classes:a=[]}=e,{name:u}=e,{id:c={}}=e;const f=mi(),{register_tab:h,unregister_tab:d,selected_tab:p,selected_tab_index:g}=op(uT);Si(n,p,_=>t(3,s=_)),Si(n,g,_=>t(7,i=_));let m=h({name:u,id:c});return sl(()=>()=>d({name:u,id:c})),n.$$set=_=>{"elem_id"in _&&t(0,l=_.elem_id),"elem_classes"in _&&t(1,a=_.elem_classes),"name"in _&&t(6,u=_.name),"id"in _&&t(2,c=_.id),"$$scope"in _&&t(9,o=_.$$scope)},n.$$.update=()=>{n.$$.dirty&192&&i===m&&yr().then(()=>f("select",{value:u,index:m}))},[l,a,c,s,p,g,u,i,r,o]}class qd extends _e{constructor(e){super(),me(this,e,$z,Kz,ae,{elem_id:0,elem_classes:1,name:6,id:2})}}function Jz(n){let e,t,i,s,r,o,l,a,u,c;const f=n[4].default,h=De(f,n,n[3],null);return{c(){e=z("div"),t=z("span"),i=ke(n[1]),s=se(),r=z("span"),r.textContent="▼",o=se(),l=z("div"),h&&h.c(),v(t,"class","svelte-xyse2h"),v(r,"class","icon svelte-xyse2h"),ve(r,"transform",n[0]?"rotate(0)":"rotate(90deg)"),v(e,"class","label-wrap svelte-xyse2h"),B(e,"open",n[0]),ve(l,"display",n[0]?"block":"none")},m(d,p){A(d,e,p),F(e,t),F(t,i),F(e,s),F(e,r),A(d,o,p),A(d,l,p),h&&h.m(l,null),a=!0,u||(c=ee(e,"click",n[2]),u=!0)},p(d,[p]){(!a||p&2)&&je(i,d[1]),p&1&&ve(r,"transform",d[0]?"rotate(0)":"rotate(90deg)"),(!a||p&1)&&B(e,"open",d[0]),h&&h.p&&(!a||p&8)&&Le(h,f,d,d[3],a?xe(f,d[3],p,null):Me(d[3]),null),p&1&&ve(l,"display",d[0]?"block":"none")},i(d){a||(S(h,d),a=!0)},o(d){C(h,d),a=!1},d(d){d&&(E(e),E(o),E(l)),h&&h.d(d),u=!1,c()}}}function Zz(n,e,t){let{$$slots:i={},$$scope:s}=e,{label:r=""}=e,{open:o=!0}=e;const l=mi();function a(){t(0,o=!o),l("click",o)}return n.$$set=u=>{"label"in u&&t(1,r=u.label),"open"in u&&t(0,o=u.open),"$$scope"in u&&t(3,s=u.$$scope)},[o,r,a,s,i]}class Af extends _e{constructor(e){super(),me(this,e,Zz,Jz,ae,{label:1,open:0})}}function Sb(n,e,t){const i=n.slice();i[3]=e[t];const s=i[0].allItems[i[3]];return i[4]=s,i}function Qz(n){let e,t;return e=new yt({props:{$$slots:{default:[tF]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&130&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function eF(n){let e,t,i,s;const r=[nF,iF],o=[];function l(a,u){return a[2].dragItem.type==="container"?0:1}return e=l(n),t=o[e]=r[e](n),{c(){t.c(),i=we()},m(a,u){o[e].m(a,u),A(a,i,u),s=!0},p(a,u){let c=e;e=l(a),e===c?o[e].p(a,u):(oe(),C(o[c],1,1,()=>{o[c]=null}),le(),t=o[e],t?t.p(a,u):(t=o[e]=r[e](a),t.c()),S(t,1),t.m(i.parentNode,i))},i(a){s||(S(t),s=!0)},o(a){C(t),s=!1},d(a){a&&E(i),o[e].d(a)}}}function tF(n){let e,t;return{c(){e=ke("Missing drag entry! "),t=ke(n[1])},m(i,s){A(i,e,s),A(i,t,s)},p(i,s){s&2&&je(t,i[1])},d(i){i&&(E(e),E(t))}}}function iF(n){let e,t,i;return t=new yt({props:{$$slots:{default:[rF]},$$scope:{ctx:n}}}),{c(){e=z("div"),Y(t.$$.fragment),v(e,"class","layout-widget svelte-1fp9590")},m(s,r){A(s,e,r),G(t,e,null),i=!0},p(s,r){const o={};r&132&&(o.$$scope={dirty:r,ctx:s}),t.$set(o)},i(s){i||(S(t.$$.fragment,s),i=!0)},o(s){C(t.$$.fragment,s),i=!1},d(s){s&&E(e),j(t)}}}function nF(n){let e,t,i;return t=new yt({props:{$$slots:{default:[lF]},$$scope:{ctx:n}}}),{c(){e=z("div"),Y(t.$$.fragment),v(e,"class","layout-container svelte-1fp9590")},m(s,r){A(s,e,r),G(t,e,null),i=!0},p(s,r){const o={};r&133&&(o.$$scope={dirty:r,ctx:s}),t.$set(o)},i(s){i||(S(t.$$.fragment,s),i=!0)},o(s){C(t.$$.fragment,s),i=!1},d(s){s&&E(e),j(t)}}}function sF(n){let e=n[2].dragItem.attrs.title+"",t;return{c(){t=ke(e)},m(i,s){A(i,t,s)},p(i,s){s&4&&e!==(e=i[2].dragItem.attrs.title+"")&&je(t,e)},d(i){i&&E(t)}}}function rF(n){let e,t;return e=new kn({props:{$$slots:{default:[sF]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&132&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function Tb(n){let e,t;return e=new fT({props:{layout:n[0],entry:n[4],entryID:n[3]}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&1&&(r.layout=i[0]),s&5&&(r.entry=i[4]),s&4&&(r.entryID=i[3]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function oF(n){let e,t,i=Xe(n[2].children),s=[];for(let o=0;oC(s[o],1,1,()=>{s[o]=null});return{c(){for(let o=0;o{o[c]=null}),le(),t=o[e],t?t.p(a,u):(t=o[e]=r[e](a),t.c()),S(t,1),t.m(i.parentNode,i))},i(a){s||(S(t),s=!0)},o(a){C(t),s=!1},d(a){a&&E(i),o[e].d(a)}}}function uF(n,e,t){let{layout:i}=e,{entryID:s}=e,{entry:r}=e;return n.$$set=o=>{"layout"in o&&t(0,i=o.layout),"entryID"in o&&t(1,s=o.entryID),"entry"in o&&t(2,r=o.entry)},[i,s,r]}class fT extends _e{constructor(e){super(),me(this,e,uF,aF,ae,{layout:0,entryID:1,entry:2})}}/*! @license DOMPurify 3.0.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.3/LICENSE */const{entries:hT,setPrototypeOf:Cb,isFrozen:cF,getPrototypeOf:fF,getOwnPropertyDescriptor:hF}=Object;let{freeze:un,seal:us,create:dF}=Object,{apply:Yd,construct:Xd}=typeof Reflect<"u"&&Reflect;Yd||(Yd=function(e,t,i){return e.apply(t,i)});un||(un=function(e){return e});us||(us=function(e){return e});Xd||(Xd=function(e,t){return new e(...t)});const pF=Jn(Array.prototype.forEach),Ib=Jn(Array.prototype.pop),Cl=Jn(Array.prototype.push),Iu=Jn(String.prototype.toLowerCase),yh=Jn(String.prototype.toString),gF=Jn(String.prototype.match),ts=Jn(String.prototype.replace),mF=Jn(String.prototype.indexOf),_F=Jn(String.prototype.trim),In=Jn(RegExp.prototype.test),Il=bF(TypeError);function Jn(n){return function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s/gm),SF=us(/\${[\w\W]*}/gm),TF=us(/^data-[\-\w.\u00B7-\uFFFF]/),CF=us(/^aria-[\-\w]+$/),dT=us(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),IF=us(/^(?:\w+script|data):/i),EF=us(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),pT=us(/^html$/i);var Db=Object.freeze({__proto__:null,MUSTACHE_EXPR:wF,ERB_EXPR:kF,TMPLIT_EXPR:SF,DATA_ATTR:TF,ARIA_ATTR:CF,IS_ALLOWED_URI:dT,IS_SCRIPT_OR_DATA:IF,ATTR_WHITESPACE:EF,DOCTYPE_NAME:pT});const AF=()=>typeof window>"u"?null:window,OF=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";t&&t.hasAttribute(s)&&(i=t.getAttribute(s));const r="dompurify"+(i?"#"+i:"");try{return e.createPolicy(r,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return null}};function gT(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:AF();const e=Fe=>gT(Fe);if(e.version="3.0.3",e.removed=[],!n||!n.document||n.document.nodeType!==9)return e.isSupported=!1,e;const t=n.document,i=t.currentScript;let{document:s}=n;const{DocumentFragment:r,HTMLTemplateElement:o,Node:l,Element:a,NodeFilter:u,NamedNodeMap:c=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:f,DOMParser:h,trustedTypes:d}=n,p=a.prototype,g=nu(p,"cloneNode"),m=nu(p,"nextSibling"),_=nu(p,"childNodes"),b=nu(p,"parentNode");if(typeof o=="function"){const Fe=s.createElement("template");Fe.content&&Fe.content.ownerDocument&&(s=Fe.content.ownerDocument)}let y,k="";const{implementation:T,createNodeIterator:I,createDocumentFragment:x,getElementsByTagName:R}=s,{importNode:N}=t;let O={};e.isSupported=typeof hT=="function"&&typeof b=="function"&&T&&T.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:D,ERB_EXPR:M,TMPLIT_EXPR:L,DATA_ATTR:V,ARIA_ATTR:X,IS_SCRIPT_OR_DATA:q,ATTR_WHITESPACE:K}=Db;let{IS_ALLOWED_URI:Q}=Db,J=null;const ce=it({},[...Eb,...vh,...wh,...kh,...Ab]);let pe=null;const qe=it({},[...Ob,...Sh,...Nb,...su]);let Ae=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ue=null,te=null,be=!0,ge=!0,he=!1,Se=!0,Je=!1,gt=!1,Ii=!1,fe=!1,Te=!1,Ge=!1,It=!1,Pt=!0,ni=!1;const Xt="user-content-";let Fi=!0,Ei=!1,hi={},st=null;const ei=it({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Wi=null;const ct=it({},["audio","video","img","source","image","track"]);let si=null;const Tn=it({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),tn="http://www.w3.org/1998/Math/MathML",Ce="http://www.w3.org/2000/svg",tt="http://www.w3.org/1999/xhtml";let vt=tt,Kt=!1,Vi=null;const cn=it({},[tn,Ce,tt],yh);let Hi;const Ks=["application/xhtml+xml","text/html"],$s="text/html";let At,fn=null;const Js=s.createElement("form"),Ns=function(U){return U instanceof RegExp||U instanceof Function},Ai=function(U){if(!(fn&&fn===U)){if((!U||typeof U!="object")&&(U={}),U=yo(U),Hi=Ks.indexOf(U.PARSER_MEDIA_TYPE)===-1?Hi=$s:Hi=U.PARSER_MEDIA_TYPE,At=Hi==="application/xhtml+xml"?yh:Iu,J="ALLOWED_TAGS"in U?it({},U.ALLOWED_TAGS,At):ce,pe="ALLOWED_ATTR"in U?it({},U.ALLOWED_ATTR,At):qe,Vi="ALLOWED_NAMESPACES"in U?it({},U.ALLOWED_NAMESPACES,yh):cn,si="ADD_URI_SAFE_ATTR"in U?it(yo(Tn),U.ADD_URI_SAFE_ATTR,At):Tn,Wi="ADD_DATA_URI_TAGS"in U?it(yo(ct),U.ADD_DATA_URI_TAGS,At):ct,st="FORBID_CONTENTS"in U?it({},U.FORBID_CONTENTS,At):ei,ue="FORBID_TAGS"in U?it({},U.FORBID_TAGS,At):{},te="FORBID_ATTR"in U?it({},U.FORBID_ATTR,At):{},hi="USE_PROFILES"in U?U.USE_PROFILES:!1,be=U.ALLOW_ARIA_ATTR!==!1,ge=U.ALLOW_DATA_ATTR!==!1,he=U.ALLOW_UNKNOWN_PROTOCOLS||!1,Se=U.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Je=U.SAFE_FOR_TEMPLATES||!1,gt=U.WHOLE_DOCUMENT||!1,Te=U.RETURN_DOM||!1,Ge=U.RETURN_DOM_FRAGMENT||!1,It=U.RETURN_TRUSTED_TYPE||!1,fe=U.FORCE_BODY||!1,Pt=U.SANITIZE_DOM!==!1,ni=U.SANITIZE_NAMED_PROPS||!1,Fi=U.KEEP_CONTENT!==!1,Ei=U.IN_PLACE||!1,Q=U.ALLOWED_URI_REGEXP||dT,vt=U.NAMESPACE||tt,Ae=U.CUSTOM_ELEMENT_HANDLING||{},U.CUSTOM_ELEMENT_HANDLING&&Ns(U.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ae.tagNameCheck=U.CUSTOM_ELEMENT_HANDLING.tagNameCheck),U.CUSTOM_ELEMENT_HANDLING&&Ns(U.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ae.attributeNameCheck=U.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),U.CUSTOM_ELEMENT_HANDLING&&typeof U.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(Ae.allowCustomizedBuiltInElements=U.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Je&&(ge=!1),Ge&&(Te=!0),hi&&(J=it({},[...Ab]),pe=[],hi.html===!0&&(it(J,Eb),it(pe,Ob)),hi.svg===!0&&(it(J,vh),it(pe,Sh),it(pe,su)),hi.svgFilters===!0&&(it(J,wh),it(pe,Sh),it(pe,su)),hi.mathMl===!0&&(it(J,kh),it(pe,Nb),it(pe,su))),U.ADD_TAGS&&(J===ce&&(J=yo(J)),it(J,U.ADD_TAGS,At)),U.ADD_ATTR&&(pe===qe&&(pe=yo(pe)),it(pe,U.ADD_ATTR,At)),U.ADD_URI_SAFE_ATTR&&it(si,U.ADD_URI_SAFE_ATTR,At),U.FORBID_CONTENTS&&(st===ei&&(st=yo(st)),it(st,U.FORBID_CONTENTS,At)),Fi&&(J["#text"]=!0),gt&&it(J,["html","head","body"]),J.table&&(it(J,["tbody"]),delete ue.tbody),U.TRUSTED_TYPES_POLICY){if(typeof U.TRUSTED_TYPES_POLICY.createHTML!="function")throw Il('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof U.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Il('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');y=U.TRUSTED_TYPES_POLICY,k=y.createHTML("")}else y===void 0&&(y=OF(d,i)),y!==null&&typeof k=="string"&&(k=y.createHTML(""));un&&un(U),fn=U}},Ui=it({},["mi","mo","mn","ms","mtext"]),ri=it({},["foreignobject","desc","title","annotation-xml"]),$t=it({},["title","style","font","a","script"]),xt=it({},vh);it(xt,wh),it(xt,yF);const Ot=it({},kh);it(Ot,vF);const cl=function(U){let ye=b(U);(!ye||!ye.tagName)&&(ye={namespaceURI:vt,tagName:"template"});const Ee=Iu(U.tagName),_t=Iu(ye.tagName);return Vi[U.namespaceURI]?U.namespaceURI===Ce?ye.namespaceURI===tt?Ee==="svg":ye.namespaceURI===tn?Ee==="svg"&&(_t==="annotation-xml"||Ui[_t]):!!xt[Ee]:U.namespaceURI===tn?ye.namespaceURI===tt?Ee==="math":ye.namespaceURI===Ce?Ee==="math"&&ri[_t]:!!Ot[Ee]:U.namespaceURI===tt?ye.namespaceURI===Ce&&!ri[_t]||ye.namespaceURI===tn&&!Ui[_t]?!1:!Ot[Ee]&&($t[Ee]||!xt[Ee]):!!(Hi==="application/xhtml+xml"&&Vi[U.namespaceURI]):!1},hn=function(U){Cl(e.removed,{element:U});try{U.parentNode.removeChild(U)}catch{U.remove()}},uo=function(U,ye){try{Cl(e.removed,{attribute:ye.getAttributeNode(U),from:ye})}catch{Cl(e.removed,{attribute:null,from:ye})}if(ye.removeAttribute(U),U==="is"&&!pe[U])if(Te||Ge)try{hn(ye)}catch{}else try{ye.setAttribute(U,"")}catch{}},ka=function(U){let ye,Ee;if(fe)U=""+U;else{const dn=gF(U,/^[\r\n\t ]+/);Ee=dn&&dn[0]}Hi==="application/xhtml+xml"&&vt===tt&&(U=''+U+"");const _t=y?y.createHTML(U):U;if(vt===tt)try{ye=new h().parseFromString(_t,Hi)}catch{}if(!ye||!ye.documentElement){ye=T.createDocument(vt,"template",null);try{ye.documentElement.innerHTML=Kt?k:_t}catch{}}const Wt=ye.body||ye.documentElement;return U&&Ee&&Wt.insertBefore(s.createTextNode(Ee),Wt.childNodes[0]||null),vt===tt?R.call(ye,gt?"html":"body")[0]:gt?ye.documentElement:Wt},Bn=function(U){return I.call(U.ownerDocument||U,U,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,null,!1)},fl=function(U){return U instanceof f&&(typeof U.nodeName!="string"||typeof U.textContent!="string"||typeof U.removeChild!="function"||!(U.attributes instanceof c)||typeof U.removeAttribute!="function"||typeof U.setAttribute!="function"||typeof U.namespaceURI!="string"||typeof U.insertBefore!="function"||typeof U.hasChildNodes!="function")},Zs=function(U){return typeof l=="object"?U instanceof l:U&&typeof U=="object"&&typeof U.nodeType=="number"&&typeof U.nodeName=="string"},Cn=function(U,ye,Ee){O[U]&&pF(O[U],_t=>{_t.call(e,ye,Ee,fn)})},Sa=function(U){let ye;if(Cn("beforeSanitizeElements",U,null),fl(U))return hn(U),!0;const Ee=At(U.nodeName);if(Cn("uponSanitizeElement",U,{tagName:Ee,allowedTags:J}),U.hasChildNodes()&&!Zs(U.firstElementChild)&&(!Zs(U.content)||!Zs(U.content.firstElementChild))&&In(/<[/\w]/g,U.innerHTML)&&In(/<[/\w]/g,U.textContent))return hn(U),!0;if(!J[Ee]||ue[Ee]){if(!ue[Ee]&&Oi(Ee)&&(Ae.tagNameCheck instanceof RegExp&&In(Ae.tagNameCheck,Ee)||Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(Ee)))return!1;if(Fi&&!st[Ee]){const _t=b(U)||U.parentNode,Wt=_(U)||U.childNodes;if(Wt&&_t){const dn=Wt.length;for(let Lt=dn-1;Lt>=0;--Lt)_t.insertBefore(g(Wt[Lt],!0),m(U))}}return hn(U),!0}return U instanceof a&&!cl(U)||(Ee==="noscript"||Ee==="noembed")&&In(/<\/no(script|embed)/i,U.innerHTML)?(hn(U),!0):(Je&&U.nodeType===3&&(ye=U.textContent,ye=ts(ye,D," "),ye=ts(ye,M," "),ye=ts(ye,L," "),U.textContent!==ye&&(Cl(e.removed,{element:U.cloneNode()}),U.textContent=ye)),Cn("afterSanitizeElements",U,null),!1)},Ta=function(U,ye,Ee){if(Pt&&(ye==="id"||ye==="name")&&(Ee in s||Ee in Js))return!1;if(!(ge&&!te[ye]&&In(V,ye))){if(!(be&&In(X,ye))){if(!pe[ye]||te[ye]){if(!(Oi(U)&&(Ae.tagNameCheck instanceof RegExp&&In(Ae.tagNameCheck,U)||Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(U))&&(Ae.attributeNameCheck instanceof RegExp&&In(Ae.attributeNameCheck,ye)||Ae.attributeNameCheck instanceof Function&&Ae.attributeNameCheck(ye))||ye==="is"&&Ae.allowCustomizedBuiltInElements&&(Ae.tagNameCheck instanceof RegExp&&In(Ae.tagNameCheck,Ee)||Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(Ee))))return!1}else if(!si[ye]){if(!In(Q,ts(Ee,K,""))){if(!((ye==="src"||ye==="xlink:href"||ye==="href")&&U!=="script"&&mF(Ee,"data:")===0&&Wi[U])){if(!(he&&!In(q,ts(Ee,K,"")))){if(Ee)return!1}}}}}}return!0},Oi=function(U){return U.indexOf("-")>0},hl=function(U){let ye,Ee,_t,Wt;Cn("beforeSanitizeAttributes",U,null);const{attributes:dn}=U;if(!dn)return;const Lt={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:pe};for(Wt=dn.length;Wt--;){ye=dn[Wt];const{name:zn,namespaceURI:co}=ye;if(Ee=zn==="value"?ye.value:_F(ye.value),_t=At(zn),Lt.attrName=_t,Lt.attrValue=Ee,Lt.keepAttr=!0,Lt.forceKeepAttr=void 0,Cn("uponSanitizeAttribute",U,Lt),Ee=Lt.attrValue,Lt.forceKeepAttr||(uo(zn,U),!Lt.keepAttr))continue;if(!Se&&In(/\/>/i,Ee)){uo(zn,U);continue}Je&&(Ee=ts(Ee,D," "),Ee=ts(Ee,M," "),Ee=ts(Ee,L," "));const Ia=At(U.nodeName);if(Ta(Ia,_t,Ee)){if(ni&&(_t==="id"||_t==="name")&&(uo(zn,U),Ee=Xt+Ee),y&&typeof d=="object"&&typeof d.getAttributeType=="function"&&!co)switch(d.getAttributeType(Ia,_t)){case"TrustedHTML":{Ee=y.createHTML(Ee);break}case"TrustedScriptURL":{Ee=y.createScriptURL(Ee);break}}try{co?U.setAttributeNS(co,zn,Ee):U.setAttribute(zn,Ee),Ib(e.removed)}catch{}}}Cn("afterSanitizeAttributes",U,null)},Ca=function Fe(U){let ye;const Ee=Bn(U);for(Cn("beforeSanitizeShadowDOM",U,null);ye=Ee.nextNode();)Cn("uponSanitizeShadowNode",ye,null),!Sa(ye)&&(ye.content instanceof r&&Fe(ye.content),hl(ye));Cn("afterSanitizeShadowDOM",U,null)};return e.sanitize=function(Fe){let U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},ye,Ee,_t,Wt;if(Kt=!Fe,Kt&&(Fe=""),typeof Fe!="string"&&!Zs(Fe))if(typeof Fe.toString=="function"){if(Fe=Fe.toString(),typeof Fe!="string")throw Il("dirty is not a string, aborting")}else throw Il("toString is not a function");if(!e.isSupported)return Fe;if(Ii||Ai(U),e.removed=[],typeof Fe=="string"&&(Ei=!1),Ei){if(Fe.nodeName){const zn=At(Fe.nodeName);if(!J[zn]||ue[zn])throw Il("root node is forbidden and cannot be sanitized in-place")}}else if(Fe instanceof l)ye=ka(""),Ee=ye.ownerDocument.importNode(Fe,!0),Ee.nodeType===1&&Ee.nodeName==="BODY"||Ee.nodeName==="HTML"?ye=Ee:ye.appendChild(Ee);else{if(!Te&&!Je&&!gt&&Fe.indexOf("<")===-1)return y&&It?y.createHTML(Fe):Fe;if(ye=ka(Fe),!ye)return Te?null:It?k:""}ye&&fe&&hn(ye.firstChild);const dn=Bn(Ei?Fe:ye);for(;_t=dn.nextNode();)Sa(_t)||(_t.content instanceof r&&Ca(_t.content),hl(_t));if(Ei)return Fe;if(Te){if(Ge)for(Wt=x.call(ye.ownerDocument);ye.firstChild;)Wt.appendChild(ye.firstChild);else Wt=ye;return(pe.shadowroot||pe.shadowrootmod)&&(Wt=N.call(t,Wt,!0)),Wt}let Lt=gt?ye.outerHTML:ye.innerHTML;return gt&&J["!doctype"]&&ye.ownerDocument&&ye.ownerDocument.doctype&&ye.ownerDocument.doctype.name&&In(pT,ye.ownerDocument.doctype.name)&&(Lt=" -`+Lt),Je&&(Lt=ts(Lt,D," "),Lt=ts(Lt,M," "),Lt=ts(Lt,L," ")),y&&It?y.createHTML(Lt):Lt},e.setConfig=function(Fe){Ai(Fe),Ii=!0},e.clearConfig=function(){fn=null,Ii=!1},e.isValidAttribute=function(Fe,U,ye){fn||Ai({});const Ee=At(Fe),_t=At(U);return Ta(Ee,_t,ye)},e.addHook=function(Fe,U){typeof U=="function"&&(O[Fe]=O[Fe]||[],Cl(O[Fe],U))},e.removeHook=function(Fe){if(O[Fe])return Ib(O[Fe])},e.removeHooks=function(Fe){O[Fe]&&(O[Fe]=[])},e.removeAllHooks=function(){O={}},e}var NF=gT();function DF(n){let e,t,i,s;const r=n[8].default,o=De(r,n,n[7],null);return{c(){e=z("div"),o&&o.c(),v(e,"id",n[2]),v(e,"class",t=mr(n[3].join(" "))+" svelte-1m1obck"),v(e,"style",i=`min-width: min(${n[1]}px, 100%); flex-grow: ${n[0]}`),B(e,"gap",n[6].gap!==!1),B(e,"compact",n[5]==="compact"),B(e,"panel",n[5]==="panel"),B(e,"hide",!n[4])},m(l,a){A(l,e,a),o&&o.m(e,null),s=!0},p(l,[a]){o&&o.p&&(!s||a&128)&&Le(o,r,l,l[7],s?xe(r,l[7],a,null):Me(l[7]),null),(!s||a&4)&&v(e,"id",l[2]),(!s||a&8&&t!==(t=mr(l[3].join(" "))+" svelte-1m1obck"))&&v(e,"class",t),(!s||a&3&&i!==(i=`min-width: min(${l[1]}px, 100%); flex-grow: ${l[0]}`))&&v(e,"style",i),(!s||a&72)&&B(e,"gap",l[6].gap!==!1),(!s||a&40)&&B(e,"compact",l[5]==="compact"),(!s||a&40)&&B(e,"panel",l[5]==="panel"),(!s||a&24)&&B(e,"hide",!l[4])},i(l){s||(S(o,l),s=!0)},o(l){C(o,l),s=!1},d(l){l&&E(e),o&&o.d(l)}}}function xF(n,e,t){let{$$slots:i={},$$scope:s}=e,{scale:r=1}=e,{min_width:o=0}=e,{elem_id:l=""}=e,{elem_classes:a=[]}=e,{visible:u=!0}=e,{variant:c="default"}=e,{style:f={}}=e;return n.$$set=h=>{"scale"in h&&t(0,r=h.scale),"min_width"in h&&t(1,o=h.min_width),"elem_id"in h&&t(2,l=h.elem_id),"elem_classes"in h&&t(3,a=h.elem_classes),"visible"in h&&t(4,u=h.visible),"variant"in h&&t(5,c=h.variant),"style"in h&&t(6,f=h.style),"$$scope"in h&&t(7,s=h.$$scope)},[r,o,l,a,u,c,f,s,i]}class mT extends _e{constructor(e){super(),me(this,e,xF,DF,ae,{scale:0,min_width:1,elem_id:2,elem_classes:3,visible:4,variant:5,style:6})}}function LF(n){let e;return{c(){e=ke("Metadata")},m(t,i){A(t,e,i)},d(t){t&&E(e)}}}function MF(n){let e,t,i,s,r;function o(a){n[18](a)}let l={label:"Created At",disabled:!0,lines:1,max_lines:1};return n[8]!==void 0&&(l.value=n[8]),e=new dr({props:l}),Ze.push(()=>jt(e,"value",o)),s=new dr({props:{label:"Size",disabled:!0,value:(n[0].svg.length/1024).toFixed(2)+" KB",lines:1,max_lines:1}}),{c(){Y(e.$$.fragment),i=se(),Y(s.$$.fragment)},m(a,u){G(e,a,u),A(a,i,u),G(s,a,u),r=!0},p(a,u){const c={};!t&&u&256&&(t=!0,c.value=a[8],Gt(()=>t=!1)),e.$set(c);const f={};u&1&&(f.value=(a[0].svg.length/1024).toFixed(2)+" KB"),s.$set(f)},i(a){r||(S(e.$$.fragment,a),S(s.$$.fragment,a),r=!0)},o(a){C(e.$$.fragment,a),C(s.$$.fragment,a),r=!1},d(a){a&&E(i),j(e,a),j(s,a)}}}function RF(n){let e,t,i,s,r,o,l,a,u,c,f,h,d,p;e=new kn({props:{$$slots:{default:[LF]},$$scope:{ctx:n}}});function g(T){n[15](T)}let m={label:"Name",disabled:!n[9],lines:1,max_lines:1};n[2].name!==void 0&&(m.value=n[2].name),s=new dr({props:m}),Ze.push(()=>jt(s,"value",g));function _(T){n[16](T)}let b={label:"Author",disabled:!n[9],lines:1,max_lines:1};n[2].author!==void 0&&(b.value=n[2].author),l=new dr({props:b}),Ze.push(()=>jt(l,"value",_));function y(T){n[17](T)}let k={label:"Description",disabled:!n[9],lines:5,max_lines:5};return n[2].description!==void 0&&(k.value=n[2].description),c=new dr({props:k}),Ze.push(()=>jt(c,"value",y)),d=new Xr({props:{$$slots:{default:[MF]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment),t=se(),i=z("div"),Y(s.$$.fragment),o=se(),Y(l.$$.fragment),u=se(),Y(c.$$.fragment),h=se(),Y(d.$$.fragment)},m(T,I){G(e,T,I),A(T,t,I),A(T,i,I),G(s,i,null),F(i,o),G(l,i,null),F(i,u),G(c,i,null),F(i,h),G(d,i,null),p=!0},p(T,I){const x={};I&2097152&&(x.$$scope={dirty:I,ctx:T}),e.$set(x);const R={};I&512&&(R.disabled=!T[9]),!r&&I&4&&(r=!0,R.value=T[2].name,Gt(()=>r=!1)),s.$set(R);const N={};I&512&&(N.disabled=!T[9]),!a&&I&4&&(a=!0,N.value=T[2].author,Gt(()=>a=!1)),l.$set(N);const O={};I&512&&(O.disabled=!T[9]),!f&&I&4&&(f=!0,O.value=T[2].description,Gt(()=>f=!1)),c.$set(O);const D={};I&2097409&&(D.$$scope={dirty:I,ctx:T}),d.$set(D)},i(T){p||(S(e.$$.fragment,T),S(s.$$.fragment,T),S(l.$$.fragment,T),S(c.$$.fragment,T),S(d.$$.fragment,T),p=!0)},o(T){C(e.$$.fragment,T),C(s.$$.fragment,T),C(l.$$.fragment,T),C(c.$$.fragment,T),C(d.$$.fragment,T),p=!1},d(T){T&&(E(t),E(i)),j(e,T),j(s),j(l),j(c),j(d)}}}function PF(n){let e,t,i;return t=new yt({props:{$$slots:{default:[RF]},$$scope:{ctx:n}}}),{c(){e=z("div"),Y(t.$$.fragment),v(e,"class","template-metadata svelte-qwu684")},m(s,r){A(s,e,r),G(t,e,null),i=!0},p(s,r){const o={};r&2097925&&(o.$$scope={dirty:r,ctx:s}),t.$set(o)},i(s){i||(S(t.$$.fragment,s),i=!0)},o(s){C(t.$$.fragment,s),i=!1},d(s){s&&E(e),j(t)}}}function xb(n){let e,t;return e=new mT({props:{$$slots:{default:[FF]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&2097162&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function BF(n){let e;return{c(){e=ke("Layout")},m(t,i){A(t,e,i)},d(t){t&&E(e)}}}function zF(n){let e,t,i,s;return e=new kn({props:{$$slots:{default:[BF]},$$scope:{ctx:n}}}),i=new fT({props:{layout:n[1],entry:n[3],entryID:n[3].dragItem.id}}),{c(){Y(e.$$.fragment),t=se(),Y(i.$$.fragment)},m(r,o){G(e,r,o),A(r,t,o),G(i,r,o),s=!0},p(r,o){const l={};o&2097152&&(l.$$scope={dirty:o,ctx:r}),e.$set(l);const a={};o&2&&(a.layout=r[1]),o&8&&(a.entry=r[3]),o&8&&(a.entryID=r[3].dragItem.id),i.$set(a)},i(r){s||(S(e.$$.fragment,r),S(i.$$.fragment,r),s=!0)},o(r){C(e.$$.fragment,r),C(i.$$.fragment,r),s=!1},d(r){r&&E(t),j(e,r),j(i,r)}}}function FF(n){let e,t,i;return t=new yt({props:{$$slots:{default:[zF]},$$scope:{ctx:n}}}),{c(){e=z("div"),Y(t.$$.fragment),v(e,"class","template-layout-preview svelte-qwu684")},m(s,r){A(s,e,r),G(t,e,null),i=!0},p(s,r){const o={};r&2097162&&(o.$$scope={dirty:r,ctx:s}),t.$set(o)},i(s){i||(S(t.$$.fragment,s),i=!0)},o(s){C(t.$$.fragment,s),i=!1},d(s){s&&E(e),j(t)}}}function WF(n){let e,t,i,s;e=new mT({props:{$$slots:{default:[PF]},$$scope:{ctx:n}}});let r=n[3]&&xb(n);return{c(){Y(e.$$.fragment),t=se(),r&&r.c(),i=we()},m(o,l){G(e,o,l),A(o,t,l),r&&r.m(o,l),A(o,i,l),s=!0},p(o,l){const a={};l&2097925&&(a.$$scope={dirty:l,ctx:o}),e.$set(a),o[3]?r?(r.p(o,l),l&8&&S(r,1)):(r=xb(o),r.c(),S(r,1),r.m(i.parentNode,i)):r&&(oe(),C(r,1,1,()=>{r=null}),le())},i(o){s||(S(e.$$.fragment,o),S(r),s=!0)},o(o){C(e.$$.fragment,o),C(r),s=!1},d(o){o&&(E(t),E(i)),j(e,o),r&&r.d(o)}}}function VF(n){let e;return{c(){e=z("div"),v(e,"class","template-graph-wrapper svelte-qwu684")},m(t,i){A(t,e,i),e.innerHTML=n[10]},p(t,i){i&1024&&(e.innerHTML=t[10])},d(t){t&&E(e)}}}function HF(n){let e,t;return e=new yt({props:{$$slots:{default:[VF]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&2098176&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function UF(n){let e,t;return e=new Af({props:{label:"Graph",$$slots:{default:[HF]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&2098176&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function GF(n){let e,t;return e=new yt({props:{$$slots:{default:[UF]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&2098176&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function Lb(n){let e,t,i,s,r,o,l,a;return t=new SA({}),r=new Ef({props:{json:n[5],collapseByDefault:n[11]}}),{c(){e=z("button"),Y(t.$$.fragment),i=se(),s=z("div"),Y(r.$$.fragment),v(e,"class","json-button svelte-qwu684"),v(s,"class","json svelte-qwu684")},m(u,c){A(u,e,c),G(t,e,null),A(u,i,c),A(u,s,c),G(r,s,null),o=!0,l||(a=ee(e,"click",n[12]),l=!0)},p(u,c){const f={};c&32&&(f.json=u[5]),r.$set(f)},i(u){o||(S(t.$$.fragment,u),S(r.$$.fragment,u),o=!0)},o(u){C(t.$$.fragment,u),C(r.$$.fragment,u),o=!1},d(u){u&&(E(e),E(i),E(s)),j(t),j(r),l=!1,a()}}}function Mb(n){let e,t,i=n[6]&&Lb(n);return{c(){i&&i.c(),e=we()},m(s,r){i&&i.m(s,r),A(s,e,r),t=!0},p(s,r){s[6]?i?(i.p(s,r),r&64&&S(i,1)):(i=Lb(s),i.c(),S(i,1),i.m(e.parentNode,e)):i&&(oe(),C(i,1,1,()=>{i=null}),le())},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d(s)}}}function jF(n){let e=n[7],t,i,s=Mb(n);return{c(){s.c(),t=we()},m(r,o){s.m(r,o),A(r,t,o),i=!0},p(r,o){o&128&&ae(e,e=r[7])?(oe(),C(s,1,1,Z),le(),s=Mb(r),s.c(),S(s,1),s.m(t.parentNode,t)):s.p(r,o)},i(r){i||(S(s),i=!0)},o(r){C(s),i=!1},d(r){r&&E(t),s.d(r)}}}function qF(n){let e,t,i,s;return e=new qd({props:{name:"Graph",id:"graph",$$slots:{default:[GF]},$$scope:{ctx:n}}}),i=new qd({props:{name:"Raw JSON",id:"json",$$slots:{default:[jF]},$$scope:{ctx:n}}}),i.$on("select",n[19]),{c(){Y(e.$$.fragment),t=se(),Y(i.$$.fragment)},m(r,o){G(e,r,o),A(r,t,o),G(i,r,o),s=!0},p(r,o){const l={};o&2098176&&(l.$$scope={dirty:o,ctx:r}),e.$set(l);const a={};o&2097376&&(a.$$scope={dirty:o,ctx:r}),i.$set(a)},i(r){s||(S(e.$$.fragment,r),S(i.$$.fragment,r),s=!0)},o(r){C(e.$$.fragment,r),C(i.$$.fragment,r),s=!1},d(r){r&&E(t),j(e,r),j(i,r)}}}function YF(n){let e,t,i,s,r,o;return t=new Xr({props:{$$slots:{default:[WF]},$$scope:{ctx:n}}}),r=new cT({props:{selected:"graph",$$slots:{default:[qF]},$$scope:{ctx:n}}}),{c(){e=z("div"),Y(t.$$.fragment),i=se(),s=z("div"),Y(r.$$.fragment),v(s,"class","template-graph-preview svelte-qwu684"),v(e,"class","template-preview svelte-qwu684")},m(l,a){A(l,e,a),G(t,e,null),F(e,i),F(e,s),G(r,s,null),o=!0},p(l,[a]){const u={};a&2097935&&(u.$$scope={dirty:a,ctx:l}),t.$set(u);const c={};a&2098400&&(c.$$scope={dirty:a,ctx:l}),r.$set(c)},i(l){o||(S(t.$$.fragment,l),S(r.$$.fragment,l),o=!0)},o(l){C(t.$$.fragment,l),C(r.$$.fragment,l),o=!1},d(l){l&&E(e),j(t),j(r)}}}function XF(n,e,t){let i,s=Z,r=()=>(s(),s=ot(h,O=>t(2,i=O)),h);n.$$.on_destroy.push(()=>s());const o=NF(window);let{templateAndSvg:l}=e,{editable:a=!0}=e,{_modal:u}=e,c,f,h=Be({});r();let d,p=!1,g=0,m="",_=!0;function b(O){switch(g){case 0:return typeof O.id=="string";case 1:return typeof O.nodes=="object";case 2:default:return!1}}function y(){t(7,g=Dv(g+1,3))}let k="";function T(O){n.$$.not_equal(i.name,O)&&(i.name=O,h.set(i))}function I(O){n.$$.not_equal(i.author,O)&&(i.author=O,h.set(i))}function x(O){n.$$.not_equal(i.description,O)&&(i.description=O,h.set(i))}function R(O){m=O,t(8,m),t(0,l)}const N=()=>t(6,p=!0);return n.$$set=O=>{"templateAndSvg"in O&&t(0,l=O.templateAndSvg),"editable"in O&&t(13,a=O.editable),"_modal"in O&&t(14,u=O._modal)},n.$$.update=()=>{if(n.$$.dirty&8193&&t(9,_=a&&l&&!l.isBuiltIn),n.$$.dirty&1&&(t(5,d={...l}),t(5,d.svg=void 0,d)),n.$$.dirty&1){let O={weekday:"short",year:"numeric",month:"short",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"};const D=new Date(l.metadata.createdAt);t(8,m=D.toLocaleString("en-US",O))}n.$$.dirty&16389&&(r(t(4,h=u.state)),"name"in i||(pi(h,i.name=l.metadata.title,i),pi(h,i.author=l.metadata.author,i),pi(h,i.description=l.metadata.description,i))),n.$$.dirty&1&&t(10,k=l?o.sanitize(l.svg,{USE_PROFILES:{svg:!0,svgFilters:!0}}).replace("0){this.__currentElement.nodeName==="path"&&(this.__currentElementsToStyle||(this.__currentElementsToStyle={element:i,children:[]}),this.__currentElementsToStyle.children.push(this.__currentElement),this.__applyCurrentDefaultPath());var s=this.__createElement("g");i.appendChild(s),this.__currentElement=s}if(this.__currentElement){var r=this.__currentElement.getAttribute("transform");r?r+=" ":r="",this.__currentElement.setAttribute("transform",r+=t)}}}},e.scale=function(t,i){i===void 0&&(i=t),this.__addTransform(nn("scale({x},{y})",{x:t,y:i}))},e.rotate=function(t){var i=180*t/Math.PI;this.__addTransform(nn("rotate({angle},{cx},{cy})",{angle:i,cx:0,cy:0}))},e.translate=function(t,i){this.__addTransform(nn("translate({x},{y})",{x:t,y:i}))},e.transform=function(t,i,s,r,o,l){this.__addTransform(nn("matrix({a},{b},{c},{d},{e},{f})",{a:t,b:i,c:s,d:r,e:o,f:l}))},e.beginPath=function(){var t,i;this.__currentDefaultPath="",this.__currentPosition={},t=this.__createElement("path",{},!0),(i=this.__closestGroupOrSvg())&&(i.appendChild(t),this.__currentElement=t)},e.__applyCurrentDefaultPath=function(){var t=this.__currentElement;t&&(t.nodeName==="path"&&t.setAttribute("d",this.__currentDefaultPath))},e.__addPathCommand=function(t){this.__currentDefaultPath+=" ",this.__currentDefaultPath+=t},e.moveTo=function(t,i){this.__currentElement&&(this.__currentElement.nodeName!=="path"&&this.beginPath(),this.__currentPosition={x:t,y:i},this.__addPathCommand(nn("M {x} {y}",{x:t,y:i})))},e.closePath=function(){this.__currentDefaultPath&&this.__addPathCommand("Z")},e.lineTo=function(t,i){this.__currentPosition={x:t,y:i},this.__currentDefaultPath.indexOf("M")>-1?this.__addPathCommand(nn("L {x} {y}",{x:t,y:i})):this.__addPathCommand(nn("M {x} {y}",{x:t,y:i}))},e.bezierCurveTo=function(t,i,s,r,o,l){this.__currentPosition={x:o,y:l},this.__addPathCommand(nn("C {cp1x} {cp1y} {cp2x} {cp2y} {x} {y}",{cp1x:t,cp1y:i,cp2x:s,cp2y:r,x:o,y:l}))},e.quadraticCurveTo=function(t,i,s,r){this.__currentPosition={x:s,y:r},this.__addPathCommand(nn("Q {cpx} {cpy} {x} {y}",{cpx:t,cpy:i,x:s,y:r}))},e.arcTo=function(t,i,s,r,o){var l=this.__currentPosition&&this.__currentPosition.x,a=this.__currentPosition&&this.__currentPosition.y;if(l!==void 0&&a!==void 0){if(o<0)throw new Error("IndexSizeError: The radius provided ("+o+") is negative.");if(l===t&&a===i||t===s&&i===r||o===0)this.lineTo(t,i);else{var u=Th([l-t,a-i]),c=Th([s-t,r-i]);if(u[0]*c[1]!=u[1]*c[0]){var f=Math.acos(Math.abs(u[0]*c[0]+u[1]*c[1])),h=Th([u[0]+c[0],u[1]+c[1]]),d=o/Math.sin(f/2),p=t+d*h[0],g=i+d*h[1],m=[-u[1],u[0]],_=[c[1],-c[0]],b=function(T){var I=T[0];return T[1]>=0?Math.acos(I):-Math.acos(I)},y=b(m),k=b(_);this.lineTo(p+m[0]*o,g+m[1]*o),this.arc(p,g,o,y,k)}else this.lineTo(t,i)}}},e.stroke=function(){this.__currentElement&&(this.__currentElement.nodeName==="path"&&this.__currentElement.setAttribute("paint-order","fill stroke markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("stroke"))},e.fill=function(){this.__currentElement&&(this.__currentElement.nodeName==="path"&&this.__currentElement.setAttribute("paint-order","stroke fill markers"),this.__applyCurrentDefaultPath(),this.__applyStyleToCurrentElement("fill"))},e.rect=function(t,i,s,r){this.__currentElement&&(this.__currentElement.nodeName!=="path"&&this.beginPath(),this.moveTo(t,i),this.lineTo(t+s,i),this.lineTo(t+s,i+r),this.lineTo(t,i+r),this.lineTo(t,i),this.closePath())},e.fillRect=function(t,i,s,r){var o;o=this.__createElement("rect",{x:t,y:i,width:s,height:r},!0),this.__closestGroupOrSvg().appendChild(o),this.__currentElement=o,this.__applyStyleToCurrentElement("fill")},e.strokeRect=function(t,i,s,r){var o;o=this.__createElement("rect",{x:t,y:i,width:s,height:r},!0),this.__closestGroupOrSvg().appendChild(o),this.__currentElement=o,this.__applyStyleToCurrentElement("stroke")},e.__clearCanvas=function(){var t=this.__closestGroupOrSvg();if(t){for(var i=t.getAttribute("transform"),s=this.__root.childNodes[1],r=s.childNodes,o=r.length-1;o>=0;o--)r[o]&&s.removeChild(r[o]);this.__currentElement=s,this.__groupStack=[],i&&this.__addTransform(i)}},e.clearRect=function(t,i,s,r){if(t!==0||i!==0||s!==this.width||r!==this.height){var o,l=this.__closestGroupOrSvg();o=this.__createElement("rect",{x:t,y:i,width:s,height:r,fill:"#FFFFFF"},!0),l.appendChild(o)}else this.__clearCanvas()},e.createLinearGradient=function(t,i,s,r){var o=this.__createElement("linearGradient",{id:ru(this.__ids),x1:t+"px",x2:s+"px",y1:i+"px",y2:r+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(o),new Ch(o,this)},e.createRadialGradient=function(t,i,s,r,o,l){var a=this.__createElement("radialGradient",{id:ru(this.__ids),cx:r+"px",cy:o+"px",r:l+"px",fx:t+"px",fy:i+"px",gradientUnits:"userSpaceOnUse"},!1);return this.__defs.appendChild(a),new Ch(a,this)},e.__parseFont=function(){var t=/^\s*(?=(?:(?:[-a-z]+\s*){0,2}(italic|oblique))?)(?=(?:(?:[-a-z]+\s*){0,2}(small-caps))?)(?=(?:(?:[-a-z]+\s*){0,2}(bold(?:er)?|lighter|[1-9]00))?)(?:(?:normal|\1|\2|\3)\s*){0,3}((?:xx?-)?(?:small|large)|medium|smaller|larger|[.\d]+(?:\%|in|[cem]m|ex|p[ctx]))(?:\s*\/\s*(normal|[.\d]+(?:\%|in|[cem]m|ex|p[ctx])))?\s*([-,\'\"\sa-z0-9]+?)\s*$/i.exec(this.font);if(t){var i={style:t[1]||"normal",size:t[4]||"10px",family:t[6]||"sans-serif",weight:t[3]||"normal",decoration:t[2]||"normal",href:null};return this.__fontUnderline==="underline"&&(i.decoration="underline"),this.__fontHref&&(i.href=this.__fontHref),i}},e.__wrapTextLink=function(t,i){if(t.href){var s=this.__createElement("a");return s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t.href),s.appendChild(i),s}return i},e.__applyText=function(t,i,s,r){var o=this.__parseFont(),l=this.__closestGroupOrSvg();if(o){var a,u,c=this.__createElement("text",{"font-family":o.family,"font-size":o.size,"font-style":o.style,"font-weight":o.weight,"text-decoration":o.decoration,x:i,y:s,"text-anchor":(u=this.textAlign,Rb[u]||Rb.start),"dominant-baseline":(a=this.textBaseline,Pb[a]||Pb.alphabetic)},!0);c.appendChild(this.__document.createTextNode(t)),this.__currentElement=c,this.__applyStyleToCurrentElement(r),l.appendChild(this.__wrapTextLink(o,c))}},e.fillText=function(t,i,s){this.__applyText(t,i,s,"fill")},e.strokeText=function(t,i,s){this.__applyText(t,i,s,"stroke")},e.measureText=function(t){return this.__ctx.font=this.font,this.__ctx.measureText(t)},e.arc=function(t,i,s,r,o,l){if(r!==o){(r%=2*Math.PI)==(o%=2*Math.PI)&&(o=(o+2*Math.PI-.001*(l?-1:1))%(2*Math.PI));var a,u=t+s*Math.cos(o),c=i+s*Math.sin(o),f=t+s*Math.cos(r),h=i+s*Math.sin(r),d=l?0:1,p=o-r;p<0&&(p+=2*Math.PI),a=l?p>Math.PI?0:1:p>Math.PI?1:0,this.lineTo(f,h),this.__addPathCommand(nn("A {rx} {ry} {xAxisRotation} {largeArcFlag} {sweepFlag} {endX} {endY}",{rx:s,ry:s,xAxisRotation:0,largeArcFlag:a,sweepFlag:d,endX:u,endY:c})),this.__currentPosition={x:u,y:c}}},e.clip=function(){var t=this.__closestGroupOrSvg(),i=this.__createElement("clipPath"),s=ru(this.__ids),r=this.__createElement("g");t&&this.__currentElement&&(this.__applyCurrentDefaultPath(),t.removeChild(this.__currentElement),i.setAttribute("id",s),i.appendChild(this.__currentElement),this.__defs.appendChild(i),t.setAttribute("clip-path",nn("url(#{id})",{id:s})),t.appendChild(r),this.__currentElement=r)},e.drawImage=function(){var t,i,s,r,o,l,a,u,c,f,h,d,p,g,m=Array.prototype.slice.call(arguments),_=m[0],b=0,y=0;if(m.length===3)t=m[1],i=m[2],s=o=_.width,r=l=_.height;else if(m.length===5)t=m[1],i=m[2],s=m[3],r=m[4],o=_.width,l=_.height;else{if(m.length!==9)throw new Error("Invalid number of arguments passed to drawImage: "+arguments.length);b=m[1],y=m[2],o=m[3],l=m[4],t=m[5],i=m[6],s=m[7],r=m[8]}a=this.__closestGroupOrSvg();var k="translate("+t+", "+i+")";if(_ instanceof n){if((u=_.getSvg().cloneNode(!0)).childNodes&&u.childNodes.length>1){for(c=u.childNodes[0];c.childNodes.length;)g=c.childNodes[0].getAttribute("id"),this.__ids[g]=g,this.__defs.appendChild(c.childNodes[0]);if(f=u.childNodes[1]){var T=f.getAttribute("transform");f.setAttribute("transform",T?T+" "+k:k),a.appendChild(f)}}}else if(_.nodeName==="CANVAS"||_.nodeName==="IMG"){if((h=this.__createElement("image")).setAttribute("width",s),h.setAttribute("height",r),h.setAttribute("preserveAspectRatio","none"),b||y||o!==_.width||l!==_.height){if((d=this.__document.createElement("canvas")).width=s,d.height=r,!(p=d.getContext("2d")))return;p.drawImage(_,b,y,o,l,0,0,s,r),_=d}h.setAttribute("transform",k),h.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",_.nodeName==="CANVAS"?_.toDataURL():_.getAttribute("src")),a.appendChild(h)}},e.createPattern=function(t,i){var s,r=this.__document.createElementNS("http://www.w3.org/2000/svg","pattern"),o=ru(this.__ids);return r.setAttribute("id",o),r.setAttribute("width",t.width),r.setAttribute("height",t.height),t.nodeName==="CANVAS"||t.nodeName==="IMG"?((s=this.__document.createElementNS("http://www.w3.org/2000/svg","image")).setAttribute("width",t.width),s.setAttribute("height",t.height),s.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t.nodeName==="CANVAS"?t.toDataURL():t.getAttribute("src")),r.appendChild(s),this.__defs.appendChild(r)):t instanceof n&&(r.appendChild(t.__root.childNodes[1]),this.__defs.appendChild(r)),new zb(r,this)},e.setLineDash=function(t){this.lineDash=t&&t.length>0?t.join(","):null},n}();function t7(n){return n&&n.isComfyBoxTemplate}const Fb={title:"New Template",author:"Anonymous",description:"A brand-new ComfyBox template",tags:[],category:"general"};function i7(n,e){const t=new Set(e.map(s=>s.id)),i=s=>{const r=new Set;for(const{dragItem:o}of n.iterateBreadthFirst(s.id))if(o.type==="widget"){if(!t.has(o.id))return!1;r.add(o.id)}return r.size===t.size};for(const s of n.iterateBreadthFirst())if(s.dragItem.type==="container"&&s.children.length>0){const r=s.dragItem;if(i(r))return s}return null}function n7(n){let e=[];for(const t of n)Gl(t)?e.push(t):t.is(an)&&(e=e.concat(Array.from(t.subgraph.iterateNodesInOrderRecursive()).filter(Gl)));return e}function s7(n){const e=new Set(n.map(i=>i.id)),t=[];for(const i of n)for(const s of i.iterateAllLinks())e.has(s.origin_id)&&e.has(s.target_id)&&t.push(s);return t}function r7(n){return n.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}function o7(n){return n.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">")}const l7=50;function a7(n,e,t,i){const s=e._nodes.reduce((b,y)=>{y.pos[0]b[2]&&(b[2]=k),T>b[3]&&(b[3]=T),b},[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY]);s[0]-=t,s[1]-=t,s[2]+=t,s[3]+=t;const r=n.ctx,o=n.ds.scale,l=n.canvas.width,a=n.canvas.height,u=n.ds.offset,c=n.show_info,f=n.background_image,h=n.clear_background,d=n.render_canvas_border,p=n.render_subgraph_panels,g=n.render_subgraph_stack_header;n.openSubgraph(e),n.show_info=!1,n.background_image=null,n.clear_background=!1,n.render_canvas_border=!1,n.render_subgraph_panels=!1,n.render_subgraph_stack_header=!1;const m=new e7(s[2]-s[0],s[3]-s[1]);return m.canvas.getBoundingClientRect=function(){return{width:m.width,height:m.height}},m.getTransform=function(){return r.getTransform()},m.resetTransform=function(){return r.resetTransform()},m.roundRect=m.rect,n.ds.scale=1,n.canvas.width=s[2]-s[0],n.canvas.height=s[3]-s[1],n.ds.offset=[-s[0],-s[1]],n.ctx=m,n.isExportingSVG=!0,n.draw(!0,!0),n.isExportingSVG=!1,n.closeSubgraph(),n.ds.scale=o,n.canvas.width=l,n.canvas.height=a,n.ds.offset=u,n.ctx=r,n.show_info=c,n.clear_background=h,n.background_image=f,n.render_canvas_border=d,n.render_subgraph_panels=p,n.render_subgraph_stack_header=g,n.draw(!0,!0),m.getSerializedSvg(!0)}function NW(n){let e=n.svg;n.svg=void 0;const t=JSON.stringify(n),i=e.replace("",`${r7(t)}`);return n.svg=e,i}function u7(n){let[e,t,i,s]=Mv(n);for(const r of n)r.pos=[r.pos[0]-e,r.pos[1]-t];return n}function c7(n){for(const e of n)Array.isArray(e.properties.tags)&&(e.properties.tags=[]);return n}function f7(n,e){const t=new Set(n.map(i=>i.id));for(const i of n){if(i.inputs)for(const s of i.inputs)s.link&&!t.has(s.link)&&(s.link=null);if(i.outputs)for(const s of i.outputs)s.links&&(s.links=s.links.filter(r=>t.has(r)))}return e=e.filter(i=>t.has(i[0])&&t.has(i[2])),[n,e]}function h7(n){return[n.origin_id,n.origin_slot,n.target_id,n.target_slot]}function d7(n,e){let t;e.nodes.length===1&&e.nodes[0].is(an)?t=e.nodes[0].subgraph:t=n.graph;const i=Zt.getLayoutByDragItemID(e.container.dragItem.id);if(i==null)throw"Couldn't find layout for template being serialized!";bi.update(c=>(c.forceSaveUserState=!1,c));const s=e.metadata;let r=e.nodes.map(c=>c.serialize()),o=e.links.map(h7);const l=i.serializeAtRoot(e.container.dragItem.id);bi.update(c=>(c.forceSaveUserState=null,c)),r=u7(r),r=c7(r),[r,o]=f7(r,o);const a=a7(n,t,l7);return{isComfyBoxTemplate:!0,version:1,commitHash:`6f02912d2e5404946687589e5fd38dd199f45944 -`,id:e.id,metadata:s,nodes:r,links:o,layout:l,svg:a}}function p7(n){const e=n.lastIndexOf("");if(e!==-1){const t=n.lastIndexOf("",e);if(t!==-1){const i=n.substring(t+6,e);return o7(i)}}return null}function Wb(n){let e=null,t=p7(n);return t&&(e=JSON.parse(t)),t7(e)?(e.svg=n,e):null}function g7(n){if(n.length===0)return{error:"No nodes selected."};const e=n7(n),t=s7(n),i=Zt.getLayoutByNode(n[0]);if(i==null)return{error:"Node(s) not contained in a layout!"};let s="New Template";if(n.length===1&&(s=n[0].title||s),e.length>0){const r=e.map(l=>l.dragItem);if(!r.every(Boolean))return{error:"At least one widget node was missing an entry in the UI!"};const o=i7(i,r);return o==null?{error:"Couldn't find a suitable container in the UI for these nodes. Ensure all the widget nodes in the subgraph are kept inside a single container in the UI."}:{version:1,id:fi(),metadata:{...Fb,title:s,createdAt:Date.now()},nodes:n,links:t,container:o}}else return{version:1,id:fi(),metadata:{...Fb,title:s,createdAt:Date.now()},nodes:n,links:t}}const Rn=Be({builtInTemplates:[],userTemplates:[],templatesByID:{}});function Sg(n,e){return n.isBuiltIn?e.builtInTemplates:e.userTemplates}function m7(){const n=ie(Rn);return n.builtInTemplates.concat(n.userTemplates)}function _7(n){return ie(Rn).templatesByID[n.id]?!1:(Rn.update(t=>(Sg(n,t).push(n),t.templatesByID[n.id]=n,t)),ba(),!0)}function b7(n){return ie(Rn).templatesByID[n]?(Rn.update(t=>{const i=Sg(t.templatesByID[n],t),s=i.findIndex(r=>r.id===n);return i.splice(s,1),delete t.templatesByID[n],t}),ba(),!0):!1}function y7(n){return ie(Rn).templatesByID[n.id]?(Rn.update(t=>{const i=n.id,s=Sg(n,t),r=s.findIndex(o=>o.id===i);return s.splice(r,1),delete t.templatesByID[i],n.id=fi(),s.push(n),t.templatesByID[n.id]=n,t}),ba(),!0):!1}function ba(){const n=JSON.stringify(ie(Rn).userTemplates);localStorage.setItem("templates",n),Rn.set(ie(Rn))}function v7(n){Rn.update(i=>{i.userTemplates=[],i.templatesByID={};for(const s of n)s.isBuiltIn=!0,i.templatesByID[s.id]=s;return i.builtInTemplates=n,i});const e=localStorage.getItem("templates");if(!e){ba();return}const t=JSON.parse(e);if(Array.isArray(t)){const i=t.map(s=>(s.isBuiltIn=!1,[s.id,s])).reduce((s,r)=>(s[r[0]]=r[1],s),{});Rn.update(s=>(s.userTemplates=t,s.templatesByID={...s.templatesByID,...i},s))}}const Kd={...Rn,getAllTemplates:m7,addTemplate:_7,removeTemplate:b7,updateTemplate:y7,save:ba,load:v7},Cg=class extends re{constructor(t,i,s,r={}){super(i,s,r);P(this,"app");P(this,"_unsubscribe");P(this,"isExportingSVG",!1);P(this,"activeErrors",null);P(this,"blinkError",null);P(this,"blinkErrorTime",0);P(this,"highlightNodeAndInput",null);P(this,"_selectedNodes",new Set);this.app=t,this._unsubscribe=Ri.subscribe(o=>{for(const l of Object.values(this.selected_nodes))l.is_selected=!1;this.selected_nodes={};for(const l of o.currentSelectionNodes)this.selected_nodes[l.id]=l,l.is_selected=!0;this._selectedNodes=new Set,this.setDirty(!0,!0)})}get comfyGraph(){return this.graph}clearErrors(){this.activeErrors=null,this.blinkError=null,this.blinkErrorTime=0,this.highlightNodeAndInput=null}serialize(){var s;let t=this.ds.offset,i=this.ds.scale;return((s=this._graph_stack)==null?void 0:s.length)>0&&(t=this._graph_stack[0].offset,i=this._graph_stack[0].scale),{offset:t,scale:i}}deserialize(t){this.ds.offset=t.offset,this.ds.scale=t.scale}recenter(){this.ds.reset(),this.setDirty(!0,!0)}drawNodeShape(t,i,s,r,o,l,a){var _;super.drawNodeShape(t,i,s,r,o,l,a);let u=ie(bt),c=ie(Ri);const f=u.executingNodes.has(t.id),h=(_=this.activeErrors)==null?void 0:_.errorsByID[t.id],d=this.highlightNodeAndInput&&this.highlightNodeAndInput[0].id===t.id;this.blinkErrorTime>0&&(this.blinkErrorTime-=this.graph.elapsed_time);let p=null,g=1,m=!1;if(h?(h.find(y=>y.errorType==="execution")?(m=!0,p="#f0f"):p="red",g=2):d?(p="cyan",g=2,this.highlightNodeAndInput[1]==null&&this.blinkErrorTime>0&&Math.floor(this.blinkErrorTime/2)%2===0&&(p=null)):c.currentHoveredNodes.has(t.id)?p="lightblue":f&&(p="#0f0"),m&&h&&h.includes(this.blinkError)&&this.blinkErrorTime>0&&Math.floor(this.blinkErrorTime/2)%2===0&&(p=null),p&&this.drawNodeOutline(t,i,s,a,r,o,p,g),f&&u.progress&&(i.fillStyle="green",i.fillRect(0,0,s[0]*(u.progress.value/u.progress.max),6),i.fillStyle=o),h&&this.drawFailedValidationInputs(t,h,p,i),d){let b=!0;if(this.blinkErrorTime>0&&Math.floor(this.blinkErrorTime/2)%2===0&&(b=!1),b){const[y,k]=this.highlightNodeAndInput;k!=null&&(i.lineWidth=2,i.strokeStyle=p,this.highlightNodeInput(y,k,i))}}}drawFailedValidationInputs(t,i,s,r){r.lineWidth=2,r.strokeStyle=s||"red";for(const o of i)if(o.input!=null){if(o===this.blinkError&&this.blinkErrorTime>0&&Math.floor(this.blinkErrorTime/2)%2===0)continue;this.highlightNodeInput(t,o.input.name,r)}}highlightNodeInput(t,i,s){let r;if(typeof i=="number"?r=i:r=t.findInputSlotIndexByName(i),r!==-1){let o=t.getConnectionPos(!0,r,Cg.CONNECTION_POS);s.beginPath(),s.arc(o[0]-t.pos[0],o[1]-t.pos[1],12,0,2*Math.PI,!1),s.stroke()}}drawNodeOutline(t,i,s,r,o,l,a,u){const c=t.shape||Re.ROUND_SHAPE;var f=!0;t.titleMode==Ji.TRANSPARENT_TITLE||t.titleMode==Ji.NO_TITLE?f=!1:t.titleMode==Ji.AUTOHIDE_TITLE&&r&&(f=!0);const h=f?w.NODE_TITLE_HEIGHT:0;i.lineWidth=u,i.globalAlpha=.8,i.beginPath(),c==Re.BOX_SHAPE?i.rect(-6,-6+h,12+s[0]+1,12+s[1]+h):c==Re.ROUND_SHAPE||c==Re.CARD_SHAPE&&t.flags.collapsed?i.roundRect(-6,-6-h,12+s[0]+1,12+s[1]+h,this.round_radius*2):c==Re.CARD_SHAPE?i.roundRect(-6,-6+h,12+s[0]+1,12+s[1]+h,this.round_radius*2,2):c==Re.CIRCLE_SHAPE&&i.arc(s[0]*.5,s[1]*.5,s[0]*.5+6,0,Math.PI*2),i.strokeStyle=a,i.stroke(),i.strokeStyle=o,i.globalAlpha=1}alignToGrid(t,i){const s=w.CANVAS_GRID_SIZE*Math.round(t.pos[0]/w.CANVAS_GRID_SIZE),r=w.CANVAS_GRID_SIZE*Math.round(t.pos[1]/w.CANVAS_GRID_SIZE),o=s-t.pos[0];let l=r-t.pos[1],a,u;if(t.flags.collapsed)a=t._collapsed_width,u=w.NODE_TITLE_HEIGHT,l-=w.NODE_TITLE_HEIGHT;else{a=t.size[0],u=t.size[1];let f=t.titleMode;f!==Ji.TRANSPARENT_TITLE&&f!==Ji.NO_TITLE&&(u+=w.NODE_TITLE_HEIGHT,l-=w.NODE_TITLE_HEIGHT)}const c=i.fillStyle;i.fillStyle="rgba(100, 100, 100, 0.5)",i.fillRect(o,l,a,u),i.fillStyle=c}drawNode(t,i){var o;(o=window==null?void 0:window.app)!=null&&o.shiftDown&&this.node_dragged&&t.id in this.selected_nodes&&this.alignToGrid(t,i);var s=this.editor_alpha;t.mode===ft.NEVER&&(this.editor_alpha=.4);const r=super.drawNode(t,i);return this.editor_alpha=s,r}drawGroups(t,i){if(!this.graph)return;var s=this.graph._groups;i.save(),i.globalAlpha=.7*this.editor_alpha;for(var r=0;r{i.currentSelectionNodes=Object.values(t),i.currentSelection=[];const s=Zt.getLayoutByGraph(this.graph);if(s){const r=ie(s);for(const o of i.currentSelectionNodes){const l=r.allItemsByNode[o.id];l&&i.currentSelection.push(l.dragItem.id)}}return i})}onHoverChange(t){Ri.update(i=>{i.currentHoveredNodes.clear(),t&&i.currentHoveredNodes.add(t.id),i.currentHovered.clear();const s=Zt.getLayoutByGraph(this.graph);if(s){const r=ie(s);for(const o of i.currentHoveredNodes){const l=r.allItemsByNode[o];l&&i.currentHovered.add(l.dragItem.id)}}return i})}clear(){super.clear(),Ri.update(t=>(t.currentSelectionNodes=[],t.currentHoveredNodes.clear(),t))}onNodeMoved(t){var i;if(super.onNodeMoved&&super.onNodeMoved(t),(i=window==null?void 0:window.app)!=null&&i.shiftDown)for(const s in this.selected_nodes)this.selected_nodes[s].alignToGrid()}reinstantiate(t,i,s,r,o){if(o.isBackendNode)return;const l=w.createNode(o.type),a=(c,f)=>{const h=w.createNode(ks);h.properties.ignoreTypes=!0,o.graph.add(h);const d=o.getConnectionPos(!0,c);return h.pos=[d[0]-140,d[1]+w.NODE_SLOT_HEIGHT/2],o.graph.getNodeById(f.origin_id).connect(f.origin_slot,h,0),h};for(let c=o.inputs.length-1;c>=0;c--){let f=null;f=o.getInputLink(c),o.disconnectInput(c),f&&a(c,f),o.removeInput(c)}for(let c=0;c{const d=w.createNode(ks);d.properties.ignoreTypes=!0,o.graph.add(d);const p=d.computeSize(),g=o.getConnectionPos(!1,c);d.pos=[g[0]+p[0]+20,g[1]+w.NODE_SLOT_HEIGHT/2];for(const m of f)d.connect(0,o.graph.getNodeById(m.target_id),m.target_slot);return d};for(let c=o.outputs.length-1;c>=0;c--){let f=o.getOutputLinks(c);o.disconnectOutput(c),f.length>0&&u(c,f),o.removeOutput(c)}for(let c=0;cu!=null);this.selected_nodes={};const a=w.createNode(an);a.buildFromNodes(l),this.graph.add(a)}insertTemplate(t,i,s,r){const o=this.graph;let[l,a,u,c]=Mv(t.nodes);const f=u-l,h=c-a;i[0]-=f/2,i[1]-=h/2;const d=o.layout;if(d==null)return;const p=w.cloneObject(t),g=o.insertTemplate(p,i),m=d.insertTemplate(p,o,g,s,r);return this.selectNodes(Object.values(g).filter(_=>_.graph===this.graph)),[Object.values(g),m]}saveAsTemplate(t,i,s,r,o){if(!this.selected_nodes||Object.values(this.selected_nodes).length===0)return;const l=g7(Object.values(this.selected_nodes));if("error"in l){nt(`Couldn't create template: ${l.error}`,{type:"error",timeout:5e3});return}const u=d7(this,l);try{Kd.addTemplate(u)?nt("Template saved!",{type:"success"}):nt("Failed to save template: already exists in LocalStorage",{type:"error"})}catch(c){nt(`Failed to save template: ${c}`,{type:"error",timeout:1e4})}}getCanvasMenuOptions(){const t=super.getCanvasMenuOptions();return t.push({content:"Convert to Subgraph",has_submenu:!1,disabled:Object.keys(this.selected_nodes).length===0,callback:this.convertToSubgraph.bind(this)}),t}getNodeMenuOptions(t){const i=super.getNodeMenuOptions(t);return i.push({content:"Reinstantiate",has_submenu:!1,disabled:!1,callback:this.reinstantiate.bind(this)}),i.push({content:"Save as Template",has_submenu:!1,disabled:!1,callback:this.saveAsTemplate.bind(this)}),i}getLinkMenuOptions(t){const i=super.getLinkMenuOptions(t);return i.push({content:"Insert Reroute",has_submenu:!1,disabled:!1,callback:this.insertReroute.bind(this)}),i}onRenderBackground(t,i){return this.isExportingSVG?(i.clearRect(this.visible_area[0],this.visible_area[1],this.visible_area[2],this.visible_area[3]),!0):!1}jumpToFirstError(){this.jumpToError(0)}jumpToError(t){if(this.activeErrors==null)return;let i;if(typeof t=="number"?i=this.activeErrors.errors[t]:i=t,i==null)return;const s=this.graph.getRootGraph();if(s==null)return;const r=s.getNodeByIdRecursive(i.nodeID);if(r==null){nt(`Couldn't find node '${i.comfyNodeType}' (${i.nodeID})`,{type:"warning"});return}this.jumpToNode(r),this.highlightNodeAndInput=null,this.blinkError=i,this.blinkErrorTime=20}jumpToNode(t){Jl.update(s=>(s.isJumpingToNode=!0,s)),this.closeAllSubgraphs();const i=Array.from(t.iterateParentSubgraphNodes()).reverse();for(const s of i)this.openSubgraph(s.subgraph);this.centerOnNode(t),this.selectNode(t)}jumpToNodeAndInput(t,i){this.jumpToNode(t),this.highlightNodeAndInput=[t,i],this.blinkErrorTime=20}};let Eu=Cg;P(Eu,"CONNECTION_POS",[0,0]);function _T(n,e){let t=n[1].default,{min:i,max:s,step:r}=n[1];return t==null&&(t=0),i==null&&(i=0),s==null&&(s=2048),r==null&&(r=e),{min:i,max:s,step:r,precision:0,defaultValue:t}}function ya(n,e,t={}){const i=n.addInput(e);for(const[s,r]of Object.entries(t))i[s]=r;if(i.defaultWidgetNode){const s=Object.values(w.registered_node_types).find(r=>r.class===i.defaultWidgetNode);s&&(i.widgetNodeType=s.type)}return i.serialize=!0,i}const w7={callback:(n,e,t)=>{const i=_T(t,.5);return ya(n,e,{type:"number",config:i,defaultWidgetNode:lf})},inputType:"number",nodeType:"ui/number",addedWidgetCount:1},bT={callback:(n,e,t)=>{const i=_T(t,1);return ya(n,e,{type:"number",config:i,defaultWidgetNode:lf})},nodeType:"ui/number",inputType:"number",addedWidgetCount:1},k7={callback:(n,e,t)=>{const i=t[1].default||"",s=!!t[1].multiline;return ya(n,e,{type:"string",config:{defaultValue:i,multiline:s},defaultWidgetNode:yg})},inputType:"number",nodeType:"ui/text",addedWidgetCount:1},S7={callback:(n,e,t)=>{const i=t[0];let s=i[0];return t[1]&&t[1].default&&(s=t[1].default),ya(n,e,{type:"string",config:{values:i,defaultValue:s},defaultWidgetNode:ha})},inputType:"number",nodeType:"ui/combo",addedWidgetCount:1},T7={callback:(n,e,t)=>ya(n,e,{type:"number",config:{}}),inputType:"COMFY_IMAGES",nodeType:"ui/image_upload",addedWidgetCount:1},Vb={...bT,addedWidgetCount:2},ss={"INT:seed":Vb,"INT:noise_seed":Vb,FLOAT:w7,INT:bT,STRING:k7,COMBO:S7,IMAGEUPLOAD:T7};function C7(n,e){return!Array.isArray(e)&&!(e in ss)&&!(`${e}:${n}`in ss)}function Tg(n){var e=n.input.required||{};return n.input.optional!=null&&(e=Object.assign({},n.input.required,n.input.optional)),Object.entries(e)}function yT(n){const e=n.output?n.output.length:0;return Gu(e).map(t=>({type:n.output[t],name:n.output_name[t]||n.output[t],is_list:n.output_is_list[t]}))}function I7(n){let e=n.toLowerCase().replace("++","pp").replaceAll(" ","_"),t="normal";return e.includes("karras")?(e=e.replace("karras","").replace(/_+$/,""),t="karras"):t="normal",[e,t]}const E7=/^([^(]+)\((.+)\)$/;function A7(n){if(!n)return[void 0,void 0];const e=n.match(E7);return e!=null?[e[1],e[2]]:[void 0,void 0]}const O7=/(.+)\s\[(.+)\]/;function Hb(n){if(!n||n==="None")return[void 0,void 0];const e=n.match(O7);return e!=null?[e[1],e[2]]:[void 0,void 0]}function N7(n){const e=y=>{const k=n.extraParams[y];return delete n.extraParams[y],k},t={};t.conditioning=[{$meta:{types:["positive"]},text:n.positive},{$meta:{types:["negative"]},text:n.negative}];const i=e("hires upscale"),s=e("hires resize");let r=i?parseFloat(i):void 0,o=e("hires upscaler"),l=e("hires steps"),a,u;s&&([a,u]=s.split(s).map(parseInt));const c={width:n.width,height:n.height,batch_count:n.batchSize,batch_pos:n.batchPos},f=e("mask blur");if(f!=null&&(c.mask_blur=parseFloat(f)),t.latent_image=[c],o!=null){let y,k;if(r)y=n.width*r,k=n.height*r;else{if(a==null||u==null)throw new Error("Highres prompt didn't have width/height!");y=+a,k=+u}const T={width:y,height:k,upscale_by:r,upscale_method:o};t.latent_upscale=[T]}const[h,d]=I7(n.sampler),p={steps:n.steps,seed:n.seed,cfg_scale:n.cfgScale,denoise:o!=null?1:n.denoise||1,sampler_name:h,scheduler:d};if(t.k_sampler=[p],o!=null){const y={$meta:{types:["upscale"]},steps:l!=null?parseInt(l):n.steps,seed:n.seed,cfg_scale:n.cfgScale,denoise:n.denoise||1,sampler_name:h,scheduler:d};t.k_sampler.push(y)}if(n.modelHash||n.modelName){const y={model_name:n.modelName,model_hashes:{a1111_shorthash:n.modelHash}};t.checkpoint=[y]}if("clip skip"in n.extraParams){const y=e("clip skip");t.clip=[{clip_skip:parseInt(y)}]}if("sd upscale upscaler"in n.extraParams){const y=e("sd upscale upscaler"),k=e("sd upscale overlap")||"64";t.sd_upscale=[{upscaler:y,overlap:parseInt(k)}]}if("aesthetic embedding"in n.extraParams){const y=e("aesthetic slerp")==="True",k={model_name:e("aesthetic embedding"),lr:parseFloat(e("aesthetic lr")),slerp:y,slerp_angle:parseFloat(e("aesthetic slerp angle")),steps:parseInt(e("aesthetic steps")),text:e("aesthetic text"),text_negative:e("aesthetic text negative")==="True",weight:parseFloat(e("aesthetic weight"))};t.aesthetic_embedding=[k]}if("dynamic thresholding enabled"in n.extraParams&&e("dynamic thresholding enabled")==="True"){const k={mimic_scale:parseInt(e("mimic scale")),threshold_percentile:parseFloat(e("threshold percentile")),mimic_mode:e("mimic mode"),mimic_scale_minimum:parseFloat(e("mimic scale minimum")),cfg_mode:e("cfg mode"),cfg_scale_minimum:parseFloat(e("cfg scale minimum"))};t.dynamic_thresholding=[k]}if("sag guidance scale"in n.extraParams){const y={guidance_scale:parseFloat(e("sag guidance scale")),mask_threshold:parseFloat(e("sag mask threshold"))};t.self_attention_guidance=[y]}if("ddetailer prompt"in n.extraParams){const y=e("ddetailer prompt"),k=e("ddetailer neg prompt"),T=e("ddetailer bitwise"),I=parseFloat(e("ddetailer denoising")),x=e("ddetailer inpaint full")==="True",R=parseInt(e("ddetailer inpaint padding")),N=parseFloat(e("ddetailer mask blur")),O=parseFloat(e("ddetailer cfg")),D=e("ddetailer preprocess b")==="True",[M,L]=Hb(e("ddetailer model a")),[V,X]=Hb(e("ddetailer model b")),q={positive_prompt:y,negative_prompt:k,bitwise:T,denoise:I,inpaint_full:x,inpaint_padding:R,mask_blur:N,cfg:O,model:M,model_hashes:L?{a1111_shorthash:L}:void 0,preprocess:!D,conf:parseFloat(e("ddetailer conf a")),dilation:parseFloat(e("ddetailer dilation a")),offset_x:parseFloat(e("ddetailer offset x a")),offset_y:parseFloat(e("ddetailer offset y a"))},K={positive_prompt:y,negative_prompt:k,bitwise:T,denoise:I,inpaint_full:x,inpaint_padding:R,mask_blur:N,cfg:O,model:V,model_hashes:X?{a1111_shorthash:X}:void 0,preprocess:D,conf:parseFloat(e("ddetailer conf b")),dilation:parseFloat(e("ddetailer dilation b")),offset_x:parseFloat(e("ddetailer offset x b")),offset_y:parseFloat(e("ddetailer offset y b"))};t.ddetailer=[q,K]}for(const[y,k]of Object.entries(n.extraNetworks)){for(const T of k){let I;switch(y.toLowerCase()){case"lora":case"locon":case"lyco":I=parseFloat(T.items[1]);const x={module_name:y.toLowerCase(),model_name:T.items[0],strength_unet:I,strength_tenc:I};t.lora?t.lora.push(x):t.lora=[x];break;case"hypernet":I=parseFloat(T.items[1]);const R={model_name:T.items[0],strength:I};t.hypernetwork?t.hypernetwork.push(R):t.hypernetwork=[R];break}}delete n.extraNetworks[y]}let g=1;for(n.extraParams[`addnet module ${g}`];`addnet module ${g}`in n.extraParams;){e("addnet enabled");const y=e(`addnet module ${g}`),k=e(`addnet model ${g}`),T=e(`addnet weight ${g}`);let I=e(`addnet weight a ${g}`),x=e(`addnet weight b ${g}`);if((I==null||x==null)&&(I=T,x=T),y==null||k==null||I==null||x==null)throw new Error(`Error parsing addnet model params: ${y} ${k} ${I} ${x}`);if(y!=="LoRA")throw new Error("Unknown AddNet model type "+y);const[R,N]=A7(k);if(R==null||N==null)throw new Error("Error parsing addnet model name: "+JSON.stringify(k));let O,D;N.length>8?O=N:D=N;const M={model_name:R,module_name:y,model_hashes:{addnet_shorthash:O,addnet_shorthash_legacy:D},strength_unet:parseFloat(I),strength_tenc:parseFloat(x)};t.lora?t.lora.push(M):t.lora=[M],g+=1,n.extraParams[`addnet model ${g}`]}let m=e("version");const _={};return Object.keys(n.extraParams).length>0&&(_.a1111={params:n.extraParams}),{version:1,metadata:{created_with:"stable-diffusion-webui",app_version:m,extra_data:_},parameters:t}}const D7={Reroute:"utils/reroute"};function x7(n,e,t,i=[0,0]){var s=w.NODE_SLOT_HEIGHT*.5;return e?i[0]=n.pos[0]+s:i[0]=n.pos[0]+n.size[0]+1-s,i[1]=n.pos[1]+(t+.7)*w.NODE_SLOT_HEIGHT+(n.constructor.slot_start_y||0),i}function Au(n,e,t,i,s,r){const o=w.createNode(e);o.flags.collapsed=!0;const l=[0,0],a=w.NODE_TEXT_SIZE;l[0]=Math.min(o.size[0],o.title.length*a+w.NODE_TITLE_HEIGHT*2);const u=o.serialize();if(u.comfyValue=t,u.shownOutputProperties={},i!=null&&(x7(i,r,s,u.pos),r?u.pos[0]-=l[0]-20:u.pos[0]+=20,u.pos[1]+=w.NODE_TITLE_HEIGHT/2),e==="ui/text"&&typeof t=="string"&&t.indexOf(` -`)!=-1){const c=gE(t);u.properties.multiline=!0,u.properties.lines=c+2,u.properties.maxLines=c+2}return n.nodes.push(u),[o,u]}function Ub(n,e,t,i,s){const r=i.inputs[s],o=e.outputs[t],l=fi();r.link=l,o.links||(o.links=[]),o.links.push(l),n.links||(n.links=[]),n.links.push([l,e.id,t,i.id,s,r.type])}function vT(n){const e={},t={},i=r=>typeof r=="string"?r:(e[r]||(e[r]=fi()),e[r]),s=r=>typeof r=="string"?r:(t[r]||(t[r]=fi()),t[r]);for(const r of n.nodes){if(r.id=i(r.id),r.inputs!=null)for(const o of r.inputs)o.link!=null&&(o.link=s(o.link));if(r.outputs!=null)for(const o of r.outputs)o.links!=null&&(o.links=o.links.map(s))}for(const r of n.links)r[0]=s(r[0]),r[1]=i(r[1]),r[3]=i(r[3]);for(const r of n.nodes)r.type==="graph/subgraph"&&vT(r.subgraph)}function wT(n,e){let t=null,i=null,s=1;if(Array.isArray(e))t="ui/combo",i="string",s=1;else if(`${e}:${n}`in ss){const r=ss[`${e}:${n}`];t=r.nodeType,i=r.inputType,s=r.addedWidgetCount}else if(e in ss){const r=ss[e];t=r.nodeType,i=r.inputType,s=r.addedWidgetCount}else return null;return[t,i,s]}function kT(n,e){switch(e||(e={}),n.type){case"ui/number":n.properties.min=e.min||0,n.properties.max=e.max||100,n.properties.step=e.step||1;break;case"ui/text":n.properties.multiline=e.multiline||!1;break}}function L7(n,e,t,i){const s=(e.outputs||[])[0];if(!s||!s.links)return!1;const r=s.widget;if(r===null)return!1;const[o,l]=r.config;if(!e.widgets_values)return!1;let a=wT(r.name,o);if(a==null)return!1;let[u,c,f]=a;const h=e.widgets_values[0],[d,p]=Au(n,u,h,e,0,!1);kT(p,l);let g=null;const m=t.addWidget(i,d);m.attrs.title=s.name;const _=p.outputs.findIndex(b=>b.name===d.outputSlotName);if(_!==-1){const b=p.outputs[_];for(const y of s.links){const k=n.links.find(T=>T[0]===y);if(k){k[1]=p.id,k[2]=_,b.links||(b.links=[]),b.links.push(y);const T=n.nodes.find(x=>x.id===k[3]),I=T!=null?T.inputs[k[4]]:null;k[5]=c,I!=null&&(I.type=c,I.serialize=!0),g==null&&I!=null&&I.name&&(g=I.name,m.attrs.title=g)}}s.links=[]}return!0}function Gb(n,e){if(e.outputs)for(const t of e.outputs)t.links&&(n.links=n.links.filter(i=>t.links.indexOf(i[0])===-1),t.links=[]);if(e.inputs)for(const t of e.inputs)t.link&&(n.links=n.links.filter(i=>t.link!==i[0]),t.link=null);n.nodes=n.nodes.filter(t=>t.id!==e.id)}function M7(n,e){var a,u,c;const[t,i]=ua.create(),{root:s,left:r,right:o}=i.initDefaultLayout();vT(n);for(const[f,h]of Object.entries(n.nodes)){const d=D7[h.type];d!=null&&(h.type=d);const p=h.bgcolor;if(p!=null&&(h.bgColor||(h.bgColor=p)),h.color||(h.color=w.NODE_DEFAULT_COLOR),h.bgColor||(h.bgColor=w.NODE_DEFAULT_BGCOLOR),h.type==="PrimitiveNode"){L7(n,h,i,r),Gb(n,h);continue}else if(h.type==="Note"){const[b,y]=Au(n,"ui/markdown",h.widgets_values[0]);y.pos=[h.pos[0],h.pos[1]];const k=i.addContainer(r,{title:""});i.addWidget(k,b),Gb(n,h);continue}const g=To.knownBackendNodes[h.type];if(g==null)continue;let m=null,_=g.nodeDef.output_node;for(const[b,[y,k]]of Tg(g.nodeDef)){const T=(a=h.inputs)==null?void 0:a.find(O=>{var D;return((D=O.widget)==null?void 0:D.name)===b});let I=wT(b,y);if(I==null)continue;let[x,R,N]=I;if(T!=null)h.widgets_values.splice(0,N)[0];else{const O={name:b,link:null,type:R,config:k,defaultWidgetNode:null,widgetNodeType:x,serialize:!0,properties:{}};h.inputs||(h.inputs=[]),h.inputs.push(O);const D=h.inputs.length-1,L=h.widgets_values.splice(0,N)[0],[V,X]=Au(n,x,L,h,D,!0);kT(X,k),m==null&&(m=i.addContainer(_?o:r,{title:h.title||h.type}));const q=i.addWidget(m,V);q.attrs.title=b;const K=(u=X.outputs)==null?void 0:u.findIndex(Q=>Q.name===V.outputSlotName);K!=null&&Ub(n,X,K,h,D)}}if(_){const b={name:"OUTPUT",type:$.EVENT,color_off:"rebeccapurple",color_on:"rebeccapurple",shape:Re.BOX_SHAPE,links:[],properties:{}};h.outputs||(h.outputs=[]),h.outputs.push(b);const y=h.outputs.length-1,[k,T]=Au(n,"ui/gallery",[],h,y,!1);m==null&&(m=i.addContainer(_?o:r,{title:h.title||h.type}));const I=i.addWidget(m,k);I.attrs.title="Output";const x=(c=T.inputs)==null?void 0:c.findIndex(R=>R.name===k.storeActionName);x!=null&&Ub(n,h,y,T,x)}}const l=i.serialize();return t.deserialize(i,{graph:n,attrs:e,layout:l}),[t,i]}const R7={createdBy:"ComfyBox",version:1,attrs:{title:"New Workflow",queuePromptButtonName:"Queue Prompt",queuePromptButtonRunWorkflow:!0},workflow:{last_node_id:0,last_link_id:0,nodes:[],links:[],groups:[],config:{},extra:{},version:0},layout:{root:null,allItems:{}},canvas:{offset:[0,0],scale:1}},Wl=class extends Ft{constructor(t,i,s){super(t);P(this,"properties",{tags:[],noOutputDisplay:!1});P(this,"comfyClass");P(this,"comfyNodeDef");P(this,"displayName");this.type=i,this.displayName=s.display_name,this.comfyNodeDef=s,this.comfyClass=i,this.isBackendNode=!0;const r=re.node_colors.yellow;this.color==null&&(this.color=r.color),this.bgColor==null&&(this.bgColor=r.bgColor),this.setup(s),s.output_node&&this.addOutput("OUTPUT",$.EVENT,{color_off:"rebeccapurple",color_on:"rebeccapurple"})}get isOutputNode(){return this.comfyNodeDef.output_node}setup(t){Wl.defaultInputConfigs[this.type]={};for(const[i,s]of Tg(t)){const r={},[o,l]=s;if(l!=null&&l.forceInput){if(Array.isArray(o))throw new Error(`Can't have forceInput set to true for an enum type! ${o}`);this.addInput(i,o)}else Array.isArray(o)?Object.assign(r,ss.COMBO.callback(this,i,s)||{}):`${o}:${i}`in ss?Object.assign(r,ss[`${o}:${i}`].callback(this,i,s)||{}):o in ss?Object.assign(r,ss[o].callback(this,i,s)||{}):this.addInput(i,o);"widgetNodeType"in r&&(Wl.defaultInputConfigs[this.type][i]=r.config)}for(const i of yT(t)){const s=i.is_list?Re.GRID_SHAPE:Re.CIRCLE_SHAPE;this.addOutput(i.name,i.type,{shape:s})}this.serialize_widgets=!1}onSerialize(t){super.onSerialize(t);for(const i of t.inputs)i.config!=null&&(i.config={})}onConfigure(t){super.onConfigure(t);const i=Wl.defaultInputConfigs[t.type];for(let s=0;s=0&&s]+)>/g,B7=/\s*([\w ]+):\s*("(?:\\"[^,]|\\"|\\|[^\"])+"|[^,]*)(?:,|$)/g;function z7(n){const e={};function t(i,s,r){return e[s]||(e[s]=[]),e[s].push({items:r.split(":")}),""}return n=n.replace(P7,t),[n,e]}const jb=n=>(e,t)=>{e[n]=parseFloat(t)},ou=n=>(e,t)=>{e[n]=parseInt(t)},F7={steps:ou("steps"),"cfg scale":jb("cfgScale"),size:(n,e)=>{const[t,i]=e.split("x");n.width=parseInt(t),n.height=parseInt(i)},"model hash":"modelHash",model:"modelName","batch size":ou("batchSize"),"batch pos":ou("batchPos"),sampler:"sampler",seed:ou("seed"),"denoising strength":jb("denoise")};function W7(n){let e=!1,t="",i="";const s=n.trim().split(` -`);let r=s.findIndex(c=>c.trim().indexOf("Steps: ")!==-1);if(r===-1)return{error:"Steps: line not found"};for(let c=0;c(n.RequiredInputMissing="required_input_missing",n.BadLinkedInput="bad_linked_input",n.ReturnTypeMismatch="return_type_mismatch",n.InvalidInputType="invalid_input_type",n.ValueSmallerThanMin="value_smaller_than_min",n.ValueBiggerThanMax="value_bigger_than_max",n.CustomValidationFailed="custom_validation_failed",n.ValueNotInList="value_not_in_list",n.ExceptionDuringValidation="exception_during_validation",n.ExceptionDuringInnerValidation="exception_during_inner_validation",n))(V7||{});function H7(n){return n&&"input_name"in n}function U7(n){return n&&"exception_type"in n&&"traceback"in n}function G7(n){return`${n.error.message}: ${n.error.details}`}function j7(n){return n.exception_message}function q7(n,e,t){const i={};for(const[s,r]of Object.entries(e.node_errors))i[s]=r.errors.map(o=>{const l={workflowID:n,nodeID:s,comfyNodeType:r.class_type,errorType:o.type,message:o.message,dependentOutputs:r.dependent_outputs,queueEntry:t};return H7(o.extra_info)&&(l.input={name:o.extra_info.input_name,config:o.extra_info.input_config,receivedValue:o.extra_info.received_value},"received_type"in o.extra_info&&(l.input.receivedType=o.extra_info.received_type),"linked_node"in o.extra_info&&(l.input.linkedNode=o.extra_info.linked_node)),"exception_message"in o.extra_info&&(l.exceptionMessage=o.extra_info.exception_message),U7(o.extra_info)&&(l.exceptionType=o.extra_info.exception_type,l.traceback=o.extra_info.traceback),l});return{message:e.error.message,errors:Object.values(i).flatMap(s=>s),errorsByID:i}}function Y7(n,e,t){const i={};return i[e.node_id]=[{workflowID:n,nodeID:e.node_id,comfyNodeType:e.node_type,errorType:"execution",message:e.exception_message,dependentOutputs:[],queueEntry:t,exceptionMessage:e.exception_message,exceptionType:e.exception_type,traceback:e.traceback,inputValues:e.current_inputs,outputValues:e.current_outputs}],{message:e.exception_message,errors:Object.values(i).flatMap(s=>s),errorsByID:i}}function DW(n,e,t){return e.type==="validation"?q7(n,e.error,t):Y7(n,e.error,t)}const ST=Be({devices:[]});function X7(n){ST.set({devices:n.devices})}const qb={...ST,updateState:X7},Yb=1;typeof window<"u"&&ks.setDefaultTextVisibility(!!localStorage["Comfy.ComfyReroute.DefaultVisibility"]);function K7(n){return n!=null&&typeof n=="object"&&n.comfyBoxWorkflow}function $7(n){return n!=null&&typeof n=="object"&&n.last_node_id!=null}const Wr=class{constructor(){P(this,"api");P(this,"rootEl",null);P(this,"canvasEl",null);P(this,"canvasCtx",null);P(this,"lCanvas",null);P(this,"shiftDown",!1);P(this,"ctrlDown",!1);P(this,"selectedGroupMoving",!1);P(this,"alreadySetup",Be(!1));P(this,"queueItems",[]);P(this,"processingQueue",!1);P(this,"promptSerializer");P(this,"stdPromptSerializer");this.api=new hz,this.promptSerializer=new cz,this.stdPromptSerializer=new QF}async setup(){if(ie(this.alreadySetup))return;await this.loadConfig(),this.api.hostname=ie(ti).comfyUIHostname,this.api.port=ie(ti).comfyUIPort,this.setupColorScheme(),this.rootEl=document.getElementById("app-root"),this.canvasEl=document.getElementById("graph-canvas"),this.lCanvas=new Eu(this,this.canvasEl),this.canvasCtx=this.canvasEl.getContext("2d");const e=ie(bi).uiUnlocked;this.lCanvas.allow_dragnodes=e,this.lCanvas.allow_interaction=e;let t;try{t=await this.api.getNodeDefs()}catch{throw new Error(`Could not reach ComfyUI at ${this.api.getBackendUrl()}`)}await this.registerNodes(t);let i=!1;try{i=await this.loadStateFromLocalStorage(t)}catch(r){nt(`Error loading previous workflow: -${r}`,{type:"error",timeout:null})}if(!i){const r={refreshCombos:t,setActive:!1};await this.initDefaultWorkflow("defaultWorkflow",r),await this.initDefaultWorkflow("upscaleByModel",r),await this.initDefaultWorkflow("conditioningRegions",r)}this.addApiUpdateHandlers(),this.addPasteHandler(),this.addKeyboardHandler(),await this.updateHistoryAndQueue();const s=await this.loadBuiltInTemplates();return Kd.load(s),await this.initFrontendFeatures(),this.resizeCanvas(),window.addEventListener("resize",this.resizeCanvas.bind(this)),this.requestPermissions(),this.alreadySetup.set(!0),Promise.resolve()}async loadConfig(){try{const e=localStorage.getItem("config");e==null?ti.loadDefault():ti.load(JSON.parse(e))}catch{ti.loadDefault()}ti.runOnChangedEvents()}async loadBuiltInTemplates(){const e=ie(ti).builtInTemplates,t=ie(ti).cacheBuiltInResources?{}:{cache:"no-store"},i=e.map(o=>fetch(`/templates/${o}.svg`,t).then(l=>l.text()).catch(l=>l)),[s,r]=await Promise.all(i).then(o=>{const l=[],a=[];for(const c of o)if(c instanceof Error)a.push(c.toString());else{const h=Wb(c);h==null?a.push("Invalid SVG template format"):l.push(h)}let u=null;return a&&a.length>0&&(u=`Error(s) loading builtin templates: -`+a.join(` -`)),[l,u]});return r&&nt(r,{type:"error"}),s}resizeCanvas(){this.canvasEl&&(this.canvasEl.width=this.canvasEl.parentElement.offsetWidth,this.canvasEl.height=this.canvasEl.parentElement.offsetHeight,this.canvasEl.style.width="",this.canvasEl.style.height="",this.lCanvas.draw(!0,!0))}serialize(e,t){const i=Zt.getLayout(e.id);if(i==null)throw new Error("Workflow has no layout!");const{graph:s,layout:r,attrs:o}=e.serialize(i);return t||(t=this.lCanvas.serialize()),{comfyBoxWorkflow:!0,createdBy:"ComfyBox",version:Yb,commitHash:`6f02912d2e5404946687589e5fd38dd199f45944 -`,workflow:s,attrs:o,layout:r,canvas:t}}saveStateToLocalStorage(e=!0){try{bi.update(l=>(l.forceSaveUserState=!0,l));const t=ie(ht),i=t.openedWorkflows,s=i.map(l=>this.serialize(l)),r=i.findIndex(l=>t.activeWorkflowID===l.id),o=JSON.stringify({workflows:s,activeWorkflowIndex:r});localStorage.setItem("workflows",o);for(const l of i)l.isModified=!1;ht.set(ie(ht)),e&&nt("Saved to local storage.")}catch(t){e&&nt(`Failed saving to local storage: -${t}`,{type:"error"})}finally{bi.update(t=>(t.forceSaveUserState=null,t))}}async loadStateFromLocalStorage(e){const t=localStorage.getItem("workflows");if(!t)return!1;const i=JSON.parse(t);if(!("workflows"in i))return!1;const s=i.workflows;return s.length===0?!1:(await Promise.all(s.map(r=>this.openWorkflow(r,{refreshCombos:e,warnMissingNodeTypes:!1,setActive:!1}).catch(o=>{nt(`Failed restoring previous workflow: ${o}`,{type:"error"})}))),typeof i.activeWorkflowIndex=="number"&&(ht.setActiveWorkflow(this.lCanvas,i.activeWorkflowIndex),Ri.clear()),!0)}async registerNodes(e){Wr.knownBackendNodes={};for(const[t,i]of Object.entries(e)){const r=Wr.node_type_overrides[t]||Ou,l={class:class extends r{constructor(a){super(a,t,i)}},title:i.display_name||i.name,type:t,desc:`ComfyNode: ${t}`};w.registerNodeType(l),l.category=i.category,Wr.knownBackendNodes[t]={nodeDef:i},Wr.registerDefaultSlotHandlers(t,i)}Wr.registerComfyBoxSlotTypes()}static registerComfyBoxSlotTypes(){const e=t=>{const i=t.toLowerCase();w.slot_types_in.includes(i)||w.slot_types_in.push(i),w.slot_types_out.includes(t)||w.slot_types_out.push(t)};e("COMFYBOX_IMAGE"),e("COMFYBOX_IMAGES"),e("COMFYBOX_REGION"),w.registered_node_types["basic/reroute"].hide_in_node_lists=!0}static registerDefaultSlotHandlers(e,t){var r,o,l;const i={node:e,title:t.display_name||t.name,properties:null,inputs:null,outputs:null};for(const[a,[u,c]]of Tg(t))if(C7(a,u)){(r=w.slot_types_default_out)[u]||(r[u]=["utils/reroute"]),w.slot_types_default_out[u].push(i);const f=u.toLocaleLowerCase();f in w.registered_slot_in_types||(w.registered_slot_in_types[f]={nodes:[]}),w.registered_slot_in_types[f].nodes.push(e),w.slot_types_in.includes(f)||w.slot_types_in.push(f)}for(const a of yT(t))(o=w.slot_types_default_in)[l=a.type]||(o[l]=["utils/reroute"]),w.slot_types_default_in[a.type].push(i),a.type in w.registered_slot_out_types||(w.registered_slot_out_types[a.type]={nodes:[]}),w.registered_slot_out_types[a.type].nodes.push(e),w.slot_types_out.includes(a.type)||w.slot_types_out.push(a.type);const s=5;for(const a of Object.keys(w.slot_types_default_in))w.slot_types_default_in[a]=w.slot_types_default_in[a].slice(0,s);for(const a of Object.keys(w.slot_types_default_out))w.slot_types_default_out[a]=w.slot_types_default_out[a].slice(0,s)}addPasteHandler(){document.addEventListener("paste",e=>{let t=(e.clipboardData||window.clipboardData).getData("text/plain"),i;try{t=t.slice(t.indexOf("{")),i=JSON.parse(t)}catch{try{t=t.slice(t.indexOf(`workflow -`)),t=t.slice(t.indexOf("{")),i=JSON.parse(t)}catch{}}if(i!=null&&typeof i=="object")if(typeof i.createdBy=="string")this.openWorkflow(i);else throw new Error("Workflow was not in ComfyBox format!")})}addApiUpdateHandlers(){this.api.addEventListener("status",t=>{bt.statusUpdated(t)}),this.api.addEventListener("reconnecting",()=>{bi.reconnecting()}),this.api.addEventListener("reconnected",()=>{bi.reconnected()}),this.api.addEventListener("progress",t=>{var i,s;bt.progressUpdated(t),(s=(i=ht.getActiveWorkflow())==null?void 0:i.graph)==null||s.setDirtyCanvas(!0,!1)}),this.api.addEventListener("executing",(t,i)=>{var r,o;const s=bt.executingUpdated(t,i);if(s!=null&&((r=s.extraData)==null?void 0:r.workflowID)!=null){const l=ht.getWorkflow(s.extraData.workflowID);(o=l==null?void 0:l.graph)==null||o.setDirtyCanvas(!0,!1)}}),this.api.addEventListener("executed",(t,i,s)=>{const r=bt.onExecuted(t,i,s);if(r!=null){const o=ht.getWorkflow(r.extraData.workflowID);if(o!=null){o.graph.setDirtyCanvas(!0,!1);const l=o.graph.getNodeByIdRecursive(i);l!=null&&l.onExecuted&&l.onExecuted(s)}}}),this.api.addEventListener("execution_start",t=>{bt.executionStart(t)}),this.api.addEventListener("execution_cached",(t,i)=>{bt.executionCached(t,i)}),this.api.addEventListener("execution_error",t=>{const i=bt.executionError(t);let s;if(i){const r=i.entry.extraData.workflowID;r&&(s=ht.getWorkflow(r))}if(s)ht.executionError(s.id,t.prompt_id),nt(`Execution error in workflow "${s.attrs.title}". -Click for details.`,{type:"error",showBar:!0,timeout:15*1e3,onClick:()=>{bi.update(r=>(r.activeError=t.prompt_id,r))}});else{const r=j7(t);nt(`Execution error: ${r}`,{type:"error",timeout:1e4})}}),this.api.addEventListener("b_preview",t=>{bt.previewUpdated(t)});const e=ie(ti);if(e.pollSystemStatsInterval>0){const t=Math.max(e.pollSystemStatsInterval,250),i=async()=>{try{const s=await this.api.getSystemStats();qb.updateState(s)}catch{qb.updateState({devices:[]})}setTimeout(i,t)};setTimeout(i,t)}this.api.init()}async interrupt(){ie(bt).isInterrupting||(bt.update(e=>(e.isInterrupting=!0,e)),await this.api.interrupt().finally(()=>{bt.update(e=>(e.isInterrupting=!0,e))}))}async deleteQueueItem(e,t){ie(bt).isInterrupting||(bt.update(i=>(i.isInterrupting=!0,i)),await this.api.deleteItem(e,t).then(()=>{bt.queueItemDeleted(e,t)}).finally(()=>{bt.update(i=>(i.isInterrupting=!1,i))}))}async clearQueue(e){ie(bt).isInterrupting||(bt.update(t=>(t.isInterrupting=!0,t)),await this.api.clearItems(e).then(()=>{bt.queueCleared(e),nt(`${mE(e)} cleared.`)}).finally(()=>{bt.update(t=>(t.isInterrupting=!1,t))}))}addKeyboardHandler(){window.addEventListener("keydown",e=>{this.shiftDown=e.shiftKey,this.ctrlDown=e.ctrlKey,(e.ctrlKey||e.metaKey)&&(e.key==="Enter"||e.code==="Enter"||e.keyCode===10)?(e.preventDefault(),e.stopImmediatePropagation(),this.runDefaultQueueAction()):e.ctrlKey&&(e.key==="s"||e.code==="KeyS")&&(e.preventDefault(),e.stopImmediatePropagation(),this.saveStateToLocalStorage())}),window.addEventListener("keyup",e=>{this.shiftDown=e.shiftKey,this.ctrlDown=e.ctrlKey})}async initFrontendFeatures(){await zl.instance.load()}async updateHistoryAndQueue(){const e=await this.api.getQueue(),t=await this.api.getHistory();bt.queueUpdated(e),bt.historyUpdated(t)}requestPermissions(){window.Notification!=null&&window.Notification.permission==="default"&&window.Notification.requestPermission().then(e=>{})}setupColorScheme(){const e=(i,s)=>{re.DEFAULT_LINK_TYPE_COLORS[i]=s,re.DEFAULT_CONNECTION_COLORS_BY_TYPE[i]=s},t=["CLIP","CLIP_VISION","CLIP_VISION_OUTPUT","CONDITIONING","CONTROL_NET","IMAGE","LATENT","MASK","MODEL","STYLE_MODEL","VAE","UPSCALE_MODEL"];for(const i of t)e(i,"orange");e("COMFYBOX_IMAGES","rebeccapurple"),e("COMFYBOX_IMAGE","fuchsia"),e("COMFYBOX_REGION","salmon"),e($.EVENT,"lightseagreen"),e($.ACTION,"lightseagreen")}async openWorkflow(e,t={setActive:!0,refreshCombos:!0,warnMissingNodeTypes:!0}){if(e.version!==Yb){const s=`Invalid ComfyBox saved data format: ${e.version} `;return nt(s,{type:"error"}),Promise.reject(s)}this.clean();let i;try{i=ht.openWorkflow(this.lCanvas,e,t.setActive)}catch(s){return So.pushModal({svelteComponent:Wz,svelteProps:{error:s}}),Promise.reject(s)}if(i.missingNodeTypes.size>0&&t.warnMissingNodeTypes&&So.pushModal({svelteComponent:Bz,svelteProps:{missingNodeTypes:i.missingNodeTypes}}),this.lCanvas.deserialize(e.canvas),t.refreshCombos){let s=null;typeof t.refreshCombos=="object"&&(s=t.refreshCombos),await this.refreshComboInNodes(i,s)}return i}async openVanillaWorkflow(e,t){const i=xv(t),s={...Uu,title:i},r={offset:[0,0],scale:1},[o,l]=M7(e,s),a=()=>{nt("Converted ComfyUI workflow to ComfyBox format.",{type:"info"}),ht.addWorkflow(this.lCanvas,o),this.lCanvas.deserialize(r)};o.missingNodeTypes.size>0?So.pushModal({svelteComponent:Mz,svelteProps:{missingNodeTypes:o.missingNodeTypes},closeOnClick:!1,showCloseButton:!1,buttons:[{name:"Cancel",variant:"secondary",onClick:()=>{Zt.remove(o.id)}},{name:"Convert",variant:"primary",onClick:a}]}):a()}setActiveWorkflow(e){const t=ie(ht).openedWorkflows.findIndex(i=>i.id===e);t!==-1&&(ht.setActiveWorkflow(this.lCanvas,t),Ri.clear())}createNewWorkflow(){ht.createNewWorkflow(this.lCanvas,void 0,!0),Ri.clear()}closeWorkflow(e){const t=ie(ht).openedWorkflows.findIndex(i=>i.id===e);t!==-1&&(ht.closeWorkflow(this.lCanvas,t),Ri.clear())}async initDefaultWorkflow(e="defaultWorkflow",t){let i=null;try{const s=ie(ti).cacheBuiltInResources?{}:{cache:"no-store"};i=await(await fetch(`/workflows/${e}.json`,s)).json()}catch(s){nt(`Failed to load default graph ${e}: ${s} `,{type:"error"}),i=structuredClone(R7)}await this.openWorkflow(i,t)}saveWorkflowStateAsDefault(e){if(e||(e=ht.getActiveWorkflow()),e!=null)for(const t of e.graph.iterateNodesInOrderRecursive())Gl(t)&&(t.properties.defaultValue=t.getValue())}resetCurrentWorkflow(){const e=ht.getActiveWorkflow();if(e!=null)for(const t of e.graph.iterateNodesInOrderRecursive())Gl(t)&&t.setValue(t.properties.defaultValue)}clear(){this.clean(),this.lCanvas.closeAllSubgraphs(),ht.closeAllWorkflows(this.lCanvas),bi.update(e=>(e.uiUnlocked=!0,e.uiEditMode="widgets",e))}runDefaultQueueAction(){const e=ht.getActiveWorkflow();if(e!=null){for(const t of e.graph.iterateNodesInOrderRecursive())"onDefaultQueueAction"in t&&t.onDefaultQueueAction();if(e.attrs.queuePromptButtonRunWorkflow){const t=this.ctrlDown?-1:0;let i=null;e.attrs.queuePromptButtonDefaultWorkflow&&(i=e.attrs.queuePromptButtonDefaultWorkflow),this.queuePrompt(e,t,1,i)}}}querySave(){const e=ht.getActiveWorkflow();if(e==null){nt("No active workflow!",{type:"error"});return}this.saveWorkflowStateAsDefault(e);const t=ie(ti).promptForWorkflowName,i=e.attrs.title.trim()||"workflow";let s=`${i}.json`;if(t){if(s=prompt("Save workflow as:",s),!s)return;s.toLowerCase().endsWith(".json")||(s+=".json")}else{const a=new Date().toISOString().replace(/:/g,"-").replace(/\.\d{3}/g,"").replace("T","_").replace("Z","");s=`${i} - ${a}.json`}const r=2,o=JSON.stringify(this.serialize(e),null,r);bE(s,o,"application/json"),e.isModified=!1,ht.set(ie(ht))}graphToPrompt(e,t=null){return this.promptSerializer.serialize(e.graph,t)}async queuePrompt(e,t,i=1,s=null){if(this.queueItems.push({num:t,batchCount:i,workflow:e}),this.processingQueue)return;s===""&&(s=null),e.attrs.showDefaultNotifications&&nt("Prompt queued.",{type:"info",showOn:"web"}),this.processingQueue=!0;let r;try{for(;this.queueItems.length;){({num:t,batchCount:i,workflow:r}=this.queueItems.pop());const o=[];for(const l of r.graph.iterateNodesInOrderRecursive())if(!(l.mode!==ft.ALWAYS||s!=null&&!If(l,s,!0))&&"getPromptThumbnails"in l){const a=l.getPromptThumbnails();a&&o.push(...a)}for(let l=0;l{bi.update(m=>(m.activeError=p,m))}});else if(d!=null)break;for(const m of r.graph.iterateNodesInOrderRecursive())"afterQueued"in m&&m.afterQueued(a,s);this.lCanvas.draw(!0,!0)}}}finally{this.processingQueue=!1}}async handleFile(e){if(e.type==="image/png"){const t=await e.arrayBuffer(),i=await gz(t);if(i)if(i.comfyBoxWorkflow)await this.openWorkflow(JSON.parse(i.comfyBoxWorkflow));else if(i.workflow){const s=JSON.parse(i.workflow);await this.openVanillaWorkflow(s,e.name)}else if(i.parameters){const s=W7(i.parameters);if("error"in s){nt(`Couldn't parse webui prompt: ${s.error}`,{type:"error"});return}const r=N7(s),o={infotext:i.parameters,parsedInfotext:s,stdPrompt:r,imageFile:e};So.pushModal({title:"A1111 Prompt Details",svelteComponent:Dz,svelteProps:{prompt:o}})}else nt("No metadata found in image file.",{type:"error"})}else if(e.type==="application/json"||e.name.endsWith(".json")){const t=new FileReader;t.onload=async()=>{const i=JSON.parse(t.result);K7(i)?await this.openWorkflow(i):$7(i)&&await this.openVanillaWorkflow(i,e.name)},t.readAsText(e)}else if(e.type==="image/svg+xml"||e.name.endsWith(".svg")){const t=await OE(e),i=Wb(t);if(i==null){nt("Invalid SVG template format!",{type:"error"});return}const s=()=>{try{Kd.addTemplate(i)?nt("Template imported successfully!",{type:"success"}):nt("Template already exists in saved list.",{type:"warning"})}catch(r){nt(`Error importing template: ${r}`,{type:"error",timeout:1e4})}};So.pushModal({title:"ComfyBox Template Preview",svelteComponent:KF,closeOnClick:!1,showCloseButton:!1,svelteProps:{templateAndSvg:i,editable:!1},buttons:[{name:"Import",variant:"primary",onClick:s},{name:"Close",variant:"secondary",onClick:()=>{}}]})}}async refreshComboInNodes(e,t,i=!1){if(e||(e=ht.getActiveWorkflow()),e==null){nt("No active workflow!",{type:"error"});return}t==null&&(t=await this.api.getNodeDefs());const s=u=>u&&u.type==="ui/combo"&&"doAutoConfig"in u,r=u=>"config"in u&&"widgetNodeType"in u&&u.widgetNodeType==="ui/combo",o={},l=new iT(s),a=(u,c)=>{const f=u.inputs[c];if(!r(f))return null;const[d,p]=l.locateUpstream(u,c,null);return d==null?null:[f,d]};for(const u of e.graph.iterateNodesInOrderRecursive()){if(!tT(u))continue;const c=Gu(u.inputs.length).map(f=>a(u,f)).filter(Boolean);for(const[f,h]of c)t[u.type].input.required[f.name]!==void 0&&(o[h.id]={comboNode:h,comfyInput:f,backendNode:u})}for(const u of e.graph.iterateNodesOfClassRecursive(ha)){if(o[u.id]!=null)continue;const c=u;let f=c.properties.values;const h=Gu(u.outputs.length).flatMap(p=>u.getInputSlotsConnectedTo(p)).find(p=>"config"in p&&Array.isArray(p.config.values));let d=null;if(h!=null){const p=h;f=p.config.values,d=p.config.defaultValue}c.formatValues(f,d)}await yr();for(const{comboNode:u,comfyInput:c,backendNode:f}of Object.values(o)){const h=t[f.type],[d,p]=h.input.required[c.name];u.doAutoConfig(c,{includeProperties:new Set(["values"]),setWidgetTitle:!1});const g=d,m=d[0];u.formatValues(g,m,!0),d!=null&&d.includes(ie(u.value))||u.setValue(d[0],c.config.defaultValue)}}clean(){}};let To=Wr;P(To,"node_type_overrides",{}),P(To,"widget_type_overrides",{}),P(To,"knownBackendNodes",{});function J7(n=!1){w.catch_exceptions=!1,w.use_uuids=!0,w.search_filter_enabled=!0,w.release_link_on_empty_shows_menu=!0,w.alt_drag_do_clone_nodes=!0,w.middle_click_slot_add_default_node=!0,w.dialog_close_on_mouse_leave=!1,w.search_hide_on_mouse_leave=!1,w.graph_inputs_outputs_use_combo_widget=!0,w.search_box_refresh_interval_ms=150,w.CANVAS_GRID_SIZE=32,n&&(w.pointerevents_method="pointer"),an.default_lgraph_factory=()=>new kv}function Z7(){const n=window;n.LiteGraph=w,n.LGraphCanvas=re,n.layoutStates=Zt,n.workflowState=ht,n.svelteGet=ie}function xW(n=!1){J7(n),Z7()}const ao=Be({mode:"queue",queuedEntries:[],runningEntries:[],completedEntries:[],queueUIEntries:[],historyUIEntries:[]});function Q7(n){const e=n.toLocaleString("en-US",{hour:"numeric",minute:"numeric",hour12:!0}),t=n.toLocaleString("en-US",{month:"2-digit",day:"2-digit",year:"numeric"}).replace(",","");return[e,t].join(", ")}function TT(n,e){var l,a,u,c;let t=n.finishedAt||n.queuedAt,i=null;t&&(i=Q7(t));const s=(u=(a=(l=n.extraData)==null?void 0:l.extra_pnginfo)==null?void 0:a.comfyBoxPrompt)==null?void 0:u.subgraphs;let r="Prompt";if(((c=n.extraData)==null?void 0:c.workflowTitle)!=null&&(r=`${n.extraData.workflowTitle}`),s&&s.length>0){const f=s.join(", ");r+=` (${f})`}let o=`#: ${n.number}, Nodes: ${Object.keys(n.prompt).length}`;return Object.keys(n.outputs).length>0&&(o=`Images: ${Object.values(n.outputs).filter(h=>h.images).flatMap(h=>h.images).length}`),{entry:n,message:r,submessage:o,date:i,status:e,images:[]}}function Xb(n,e){var r;const t=TT(n,e),i=(r=n.extraData)==null?void 0:r.thumbnails;i&&(t.images=[...i]);const s=Object.values(n.outputs).filter(o=>o.images).flatMap(o=>o.images);return s&&(t.images=t.images.concat(s)),t}function e9(n){const e=TT(n.entry,n.status),t=Object.values(n.entry.outputs).filter(i=>i.images).flatMap(i=>i.images);return e.images=t,n.message?e.submessage=n.message:(n.status==="interrupted"||n.status==="all_cached")&&(e.submessage="Prompt was interrupted."),n.error&&(e.error=n.error),e}function t9(n,e){ao.update(t=>(t.queuedEntries=n.map(i=>Xb(i,"pending")).reverse(),t.runningEntries=e.map(i=>Xb(i,"running")).reverse(),t.queuedEntries.sort((i,s)=>i.entry.number-s.entry.number),t.runningEntries.sort((i,s)=>i.entry.number-s.entry.number),t.queueUIEntries=t.queuedEntries.concat(t.runningEntries),t))}function i9(n){ao.update(e=>(e.historyUIEntries=n.map(e9).reverse(),e))}function va(n=!1){const e=ie(ao),t=ie(bt),i=t.queuePending,s=t.queueRunning,r=t.queueCompleted,o=ie(i).length!=e.queuedEntries.length||ie(s).length!=e.runningEntries.length,l=ie(r).length!=e.historyUIEntries.length;(o||n)&&t9(ie(i),ie(s)),(l||n)&&i9(ie(r))}function n9(){ao.update(n=>(n.queuedEntries=[],n.runningEntries=[],n.historyUIEntries=[],n)),va(!0)}function s9(){ao.update(n=>(n.queuedEntries=[],n.runningEntries=[],n)),va(!0)}function r9(){ao.update(n=>(n.historyUIEntries=[],n)),va(!0)}bt.subscribe(n=>{va()});const LW={...ao,updateEntries:va,clearAll:n9,clearQueue:s9,clearHistory:r9};function Kb(n,e,t){const i=n.slice();i[19]=e[t];const s=$n(i[19])&&!i[5];return i[20]=s,i}function Ih(n){const e=n.slice(),t=e[9].uiUnlocked&&e[10].currentSelection.includes(e[0].id);return e[18]=t,e}function $b(n){let e,t,i,s;return t=new yt({props:{$$slots:{default:[l9]},$$scope:{ctx:n}}}),{c(){e=z("div"),Y(t.$$.fragment),v(e,"class",i="container "+n[0].attrs.direction+" "+n[0].attrs.classes+" "+n[3].join(" ")+" z-index"+n[2]+" svelte-ihejkv"),B(e,"hide-block",n[0].attrs.containerVariant==="hidden"),B(e,"selected",n[18]),B(e,"root-container",n[2]===0),B(e,"is-executing",n[0].isNodeExecuting),B(e,"mobile",n[7]),B(e,"edit",n[5])},m(r,o){A(r,e,o),G(t,e,null),s=!0},p(r,o){const l={};o&8389623&&(l.$$scope={dirty:o,ctx:r}),t.$set(l),(!s||o&13&&i!==(i="container "+r[0].attrs.direction+" "+r[0].attrs.classes+" "+r[3].join(" ")+" z-index"+r[2]+" svelte-ihejkv"))&&v(e,"class",i),(!s||o&13)&&B(e,"hide-block",r[0].attrs.containerVariant==="hidden"),(!s||o&1549)&&B(e,"selected",r[18]),(!s||o&13)&&B(e,"root-container",r[2]===0),(!s||o&13)&&B(e,"is-executing",r[0].isNodeExecuting),(!s||o&141)&&B(e,"mobile",r[7]),(!s||o&45)&&B(e,"edit",r[5])},i(r){s||(S(t.$$.fragment,r),s=!0)},o(r){C(t.$$.fragment,r),s=!1},d(r){r&&E(e),j(t)}}}function Jb(n){let e,t,i,s,r;return t=new kn({props:{$$slots:{default:[o9]},$$scope:{ctx:n}}}),{c(){e=z("label"),Y(t.$$.fragment),v(e,"for",i=String(n[0].id)),v(e,"class",s=mr(n[9].uiUnlocked&&n[9].uiEditMode==="widgets"?"edit-title-label":"")+" svelte-ihejkv")},m(o,l){A(o,e,l),G(t,e,null),r=!0},p(o,l){const a={};l&8388609&&(a.$$scope={dirty:l,ctx:o}),t.$set(a),(!r||l&1&&i!==(i=String(o[0].id)))&&v(e,"for",i),(!r||l&512&&s!==(s=mr(o[9].uiUnlocked&&o[9].uiEditMode==="widgets"?"edit-title-label":"")+" svelte-ihejkv"))&&v(e,"class",s)},i(o){r||(S(t.$$.fragment,o),r=!0)},o(o){C(t.$$.fragment,o),r=!1},d(o){o&&E(e),j(t)}}}function o9(n){let e=n[0].attrs.title+"",t;return{c(){t=ke(e)},m(i,s){A(i,t,s)},p(i,s){s&1&&e!==(e=i[0].attrs.title+"")&&je(t,e)},d(i){i&&E(t)}}}function Zb(n){let e,t;return{c(){e=z("div"),v(e,"class","drag-item-shadow svelte-ihejkv")},m(i,s){A(i,e,s)},p(i,s){},i(i){t||vn(()=>{t=Ec(e,ef,{duration:200,easing:Rp}),t.start()})},o:Z,d(i){i&&E(e)}}}function Qb(n,e){let t,i,s,r,o,l,a=Z,u;i=new wa({props:{layoutState:e[1],dragItem:e[19],zIndex:e[2]+1,isMobile:e[7]}});let c=e[19][Is]&&Zb();return{key:n,first:null,c(){var f,h;t=z("div"),Y(i.$$.fragment),s=se(),c&&c.c(),r=se(),v(t,"class","animation-wrapper svelte-ihejkv"),v(t,"style",o=((h=(f=e[19])==null?void 0:f.attrs)==null?void 0:h.style)||""),B(t,"edit",e[5]),B(t,"hidden",e[20]),this.first=t},m(f,h){A(f,t,h),G(i,t,null),F(t,s),c&&c.m(t,null),F(t,r),u=!0},p(f,h){var p,g;e=f;const d={};h&2&&(d.layoutState=e[1]),h&256&&(d.dragItem=e[19]),h&4&&(d.zIndex=e[2]+1),h&128&&(d.isMobile=e[7]),i.$set(d),e[19][Is]?c?h&256&&S(c,1):(c=Zb(),c.c(),S(c,1),c.m(t,r)):c&&(c.d(1),c=null),(!u||h&256&&o!==(o=((g=(p=e[19])==null?void 0:p.attrs)==null?void 0:g.style)||""))&&v(t,"style",o),(!u||h&32)&&B(t,"edit",e[5]),(!u||h&288)&&B(t,"hidden",e[20])},r(){l=t.getBoundingClientRect()},f(){sp(t),a()},a(){a(),a=np(t,l,Vp,{duration:$d})},i(f){u||(S(i.$$.fragment,f),S(c),u=!0)},o(f){C(i.$$.fragment,f),u=!1},d(f){f&&E(t),j(i),c&&c.d()}}}function ey(n){let e;return{c(){e=z("div"),v(e,"class","handle handle-hidden svelte-ihejkv"),B(e,"hidden",!n[5]),ve(e,"z-index",n[2]+100)},m(t,i){A(t,e,i)},p(t,i){i&32&&B(e,"hidden",!t[5]),i&4&&ve(e,"z-index",t[2]+100)},d(t){t&&E(e)}}}function ty(n){let e,t,i,s;return{c(){e=z("div"),v(e,"class","handle handle-container svelte-ihejkv"),v(e,"data-drag-item-id",t=n[0].id),ve(e,"z-index",n[2]+100)},m(r,o){A(r,e,o),i||(s=[ee(e,"mousedown",n[13]),ee(e,"touchstart",n[13]),ee(e,"mouseup",n[14]),ee(e,"touchend",n[14])],i=!0)},p(r,o){o&1&&t!==(t=r[0].id)&&v(e,"data-drag-item-id",t),o&4&&ve(e,"z-index",r[2]+100)},d(r){r&&E(e),i=!1,lt(s)}}}function l9(n){let e,t,i=[],s=new Map,r,o,l=$n(n[0])&&n[5],a,u,c,f,h,d=n[0].attrs.title&&n[0].attrs.title!==""&&Jb(n),p=Xe(n[8].filter(n[16]));const g=b=>b[19].id;for(let b=0;b{d=null}),le()),y&422){p=Xe(b[8].filter(b[16])),oe();for(let k=0;k{i=null}),le())},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d(s)}}}const $d=100;function u9(n,e,t){let i,s=Z,r=()=>(s(),s=ot(a,I=>t(15,i=I)),a),o,l;Si(n,bi,I=>t(9,o=I)),Si(n,Ri,I=>t(10,l=I)),n.$$.on_destroy.push(()=>s());let{layoutState:a}=e;r();let{container:u=null}=e,{zIndex:c=0}=e,{classes:f=[]}=e,{showHandles:h=!1}=e,{edit:d=!1}=e,{dragDisabled:p=!1}=e,{isMobile:g=!1}=e,m=[];function _(I){t(8,m=Fp(a,u,I))}function b(I){t(8,m=Wp(a,u,I))}function y(I){Bc(I,a)}function k(I){zc(I,a)}const T=I=>I.id!==Us;return n.$$set=I=>{"layoutState"in I&&r(t(1,a=I.layoutState)),"container"in I&&t(0,u=I.container),"zIndex"in I&&t(2,c=I.zIndex),"classes"in I&&t(3,f=I.classes),"showHandles"in I&&t(4,h=I.showHandles),"edit"in I&&t(5,d=I.edit),"dragDisabled"in I&&t(6,p=I.dragDisabled),"isMobile"in I&&t(7,g=I.isMobile)},n.$$.update=()=>{n.$$.dirty&32769&&(u?i.allItems[u.id]?(t(8,m=i.allItems[u.id].children),u.attrsChanged):(t(0,u=null),t(8,m=[])):t(8,m=[]))},[u,a,c,f,h,d,p,g,m,o,l,_,b,y,k,i,T]}class c9 extends _e{constructor(e){super(),me(this,e,u9,a9,ae,{layoutState:1,container:0,zIndex:2,classes:3,showHandles:4,edit:5,dragDisabled:6,isMobile:7})}}function iy(n,e,t){const i=n.slice();return i[23]=e[t],i}function ny(n,e,t){const i=n.slice();i[23]=e[t];const s=$n(i[23]);return i[24]=s,i}function Eh(n){const e=n.slice(),t=e[11].uiUnlocked&&e[12].currentSelection.includes(e[0].id);return e[22]=t,e}function sy(n){let e,t,i,s,r;const o=[h9,f9],l=[];function a(u,c){return u[5]?0:1}return t=a(n),i=l[t]=o[t](n),{c(){e=z("div"),i.c(),v(e,"class",s="container "+n[0].attrs.direction+" "+n[0].attrs.classes+" "+n[3].join(" ")+" z-index"+n[2]+" svelte-gk4lmp"),B(e,"hide-block",n[0].attrs.containerVariant==="hidden"),B(e,"selected",n[22]),B(e,"root-container",n[2]===0),B(e,"is-executing",n[0].isNodeExecuting),B(e,"edit",n[5])},m(u,c){A(u,e,c),l[t].m(e,null),r=!0},p(u,c){let f=t;t=a(u),t===f?l[t].p(u,c):(oe(),C(l[f],1,1,()=>{l[f]=null}),le(),i=l[t],i?i.p(u,c):(i=l[t]=o[t](u),i.c()),S(i,1),i.m(e,null)),(!r||c&13&&s!==(s="container "+u[0].attrs.direction+" "+u[0].attrs.classes+" "+u[3].join(" ")+" z-index"+u[2]+" svelte-gk4lmp"))&&v(e,"class",s),(!r||c&13)&&B(e,"hide-block",u[0].attrs.containerVariant==="hidden"),(!r||c&6157)&&B(e,"selected",u[22]),(!r||c&13)&&B(e,"root-container",u[2]===0),(!r||c&13)&&B(e,"is-executing",u[0].isNodeExecuting),(!r||c&45)&&B(e,"edit",u[5])},i(u){r||(S(i),r=!0)},o(u){C(i),r=!1},d(u){u&&E(e),l[t].d()}}}function f9(n){let e,t;return e=new yt({props:{elem_classes:["gradio-accordion"],$$slots:{default:[p9]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&536872583&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function h9(n){let e,t;return e=new yt({props:{elem_classes:["gradio-accordion"],$$slots:{default:[m9]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&536871671&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function ry(n,e){let t,i,s;return i=new wa({props:{layoutState:e[1],dragItem:e[23],zIndex:e[2]+1,isMobile:e[7]}}),{key:n,first:null,c(){t=we(),Y(i.$$.fragment),this.first=t},m(r,o){A(r,t,o),G(i,r,o),s=!0},p(r,o){e=r;const l={};o&2&&(l.layoutState=e[1]),o&512&&(l.dragItem=e[23]),o&4&&(l.zIndex=e[2]+1),o&128&&(l.isMobile=e[7]),i.$set(l)},i(r){s||(S(i.$$.fragment,r),s=!0)},o(r){C(i.$$.fragment,r),s=!1},d(r){r&&E(t),j(i,r)}}}function d9(n){let e=[],t=new Map,i,s,r=Xe(n[9].filter(n[19]));const o=l=>l[23].id;for(let l=0;l{t=Ec(e,ef,{duration:200,easing:Rp}),t.start()})},o:Z,d(i){i&&E(e)}}}function ly(n,e){let t,i,s,r,o,l,a=Z,u;i=new wa({props:{layoutState:e[1],dragItem:e[23],zIndex:e[2]+1,isMobile:e[7]}});let c=e[23][Is]&&oy();return{key:n,first:null,c(){var f,h;t=z("div"),Y(i.$$.fragment),s=se(),c&&c.c(),r=se(),v(t,"class","animation-wrapper svelte-gk4lmp"),v(t,"style",o=((h=(f=e[23])==null?void 0:f.attrs)==null?void 0:h.style)||""),B(t,"hidden",e[24]),this.first=t},m(f,h){A(f,t,h),G(i,t,null),F(t,s),c&&c.m(t,null),F(t,r),u=!0},p(f,h){var p,g;e=f;const d={};h&2&&(d.layoutState=e[1]),h&512&&(d.dragItem=e[23]),h&4&&(d.zIndex=e[2]+1),h&128&&(d.isMobile=e[7]),i.$set(d),e[23][Is]?c?h&512&&S(c,1):(c=oy(),c.c(),S(c,1),c.m(t,r)):c&&(c.d(1),c=null),(!u||h&512&&o!==(o=((g=(p=e[23])==null?void 0:p.attrs)==null?void 0:g.style)||""))&&v(t,"style",o),(!u||h&512)&&B(t,"hidden",e[24])},r(){l=t.getBoundingClientRect()},f(){sp(t),a()},a(){a(),a=np(t,l,Vp,{duration:Jd})},i(f){u||(S(i.$$.fragment,f),S(c),u=!0)},o(f){C(i.$$.fragment,f),u=!1},d(f){f&&E(t),j(i),c&&c.d()}}}function ay(n){let e;return{c(){e=z("div"),v(e,"class","handle handle-hidden svelte-gk4lmp"),B(e,"hidden",!n[5]),ve(e,"z-index",n[2]+100)},m(t,i){A(t,e,i)},p(t,i){i&32&&B(e,"hidden",!t[5]),i&4&&ve(e,"z-index",t[2]+100)},d(t){t&&E(e)}}}function uy(n){let e,t,i,s;return{c(){e=z("div"),v(e,"class","handle handle-container svelte-gk4lmp"),v(e,"data-drag-item-id",t=n[0].id),ve(e,"z-index",n[2]+100)},m(r,o){A(r,e,o),i||(s=[ee(e,"mousedown",n[16]),ee(e,"touchstart",n[16]),ee(e,"mouseup",n[17]),ee(e,"touchend",n[17])],i=!0)},p(r,o){o&1&&t!==(t=r[0].id)&&v(e,"data-drag-item-id",t),o&4&&ve(e,"z-index",r[2]+100)},d(r){r&&E(e),i=!1,lt(s)}}}function g9(n){let e,t=[],i=new Map,s,r,o=$n(n[0])&&n[5],l,a,u,c,f,h=Xe(n[9].filter(n[18]));const d=m=>m[23].id;for(let m=0;m{i=null}),le())},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d(s)}}}const Jd=100;function b9(n,e,t){let i,s=Z,r=()=>(s(),s=ot(y,L=>t(10,i=L)),y),o,l=Z,a=()=>(l(),l=ot(f,L=>t(20,o=L)),f),u,c;Si(n,bi,L=>t(11,u=L)),Si(n,Ri,L=>t(12,c=L)),n.$$.on_destroy.push(()=>s()),n.$$.on_destroy.push(()=>l());let{layoutState:f}=e;a();let{container:h=null}=e,{zIndex:d=0}=e,{classes:p=[]}=e,{showHandles:g=!1}=e,{edit:m=!1}=e,{dragDisabled:_=!1}=e,{isMobile:b=!1}=e,y=null;r();let k=[];function T(){t(9,k=o.allItems[h.id].children),h.isOpen==null&&t(0,h.isOpen=Be(h.attrs.openOnStartup),h),r(t(8,y=h.isOpen))}function I(L){t(9,k=Fp(f,h,L))}function x(L){t(9,k=Wp(f,h,L))}function R(L){navigator.vibrate(20),pi(y,i=L.detail,i)}function N(L){Bc(L,f)}function O(L){zc(L,f)}const D=L=>L.id!==Us,M=L=>L.id!==Us;return n.$$set=L=>{"layoutState"in L&&a(t(1,f=L.layoutState)),"container"in L&&t(0,h=L.container),"zIndex"in L&&t(2,d=L.zIndex),"classes"in L&&t(3,p=L.classes),"showHandles"in L&&t(4,g=L.showHandles),"edit"in L&&t(5,m=L.edit),"dragDisabled"in L&&t(6,_=L.dragDisabled),"isMobile"in L&&t(7,b=L.isMobile)},n.$$.update=()=>{n.$$.dirty&1&&(h?T():t(9,k=null))},[h,f,d,p,g,m,_,b,y,k,i,u,c,I,x,R,N,O,D,M]}class y9 extends _e{constructor(e){super(),me(this,e,b9,_9,ae,{layoutState:1,container:0,zIndex:2,classes:3,showHandles:4,edit:5,dragDisabled:6,isMobile:7})}}function cy(n,e,t){const i=n.slice();i[19]=e[t],i[23]=t;const s=CT(i[1],i[23]);return i[21]=s,i}function fy(n,e,t){const i=n.slice();i[19]=e[t],i[23]=t;const s=$n(i[19]);i[20]=s;const r=CT(i[1],i[23]);return i[21]=r,i}function Ah(n){const e=n.slice(),t=e[9].uiUnlocked&&e[10].currentSelection.includes(e[1].id);return e[18]=t,e}function hy(n){let e,t,i,s,r;const o=[w9,v9],l=[];function a(u,c){return u[5]?0:1}return t=a(n),i=l[t]=o[t](n),{c(){e=z("div"),i.c(),v(e,"class",s="container "+n[1].attrs.direction+" "+n[1].attrs.classes+" "+n[3].join(" ")+" z-index"+n[2]+" svelte-1gex4qr"),B(e,"hide-block",n[1].attrs.containerVariant==="hidden"),B(e,"selected",n[18]),B(e,"root-container",n[2]===0),B(e,"is-executing",n[1].isNodeExecuting),B(e,"edit",n[5])},m(u,c){A(u,e,c),l[t].m(e,null),r=!0},p(u,c){let f=t;t=a(u),t===f?l[t].p(u,c):(oe(),C(l[f],1,1,()=>{l[f]=null}),le(),i=l[t],i?i.p(u,c):(i=l[t]=o[t](u),i.c()),S(i,1),i.m(e,null)),(!r||c&14&&s!==(s="container "+u[1].attrs.direction+" "+u[1].attrs.classes+" "+u[3].join(" ")+" z-index"+u[2]+" svelte-1gex4qr"))&&v(e,"class",s),(!r||c&14)&&B(e,"hide-block",u[1].attrs.containerVariant==="hidden"),(!r||c&1550)&&B(e,"selected",u[18]),(!r||c&14)&&B(e,"root-container",u[2]===0),(!r||c&14)&&B(e,"is-executing",u[1].isNodeExecuting),(!r||c&46)&&B(e,"edit",u[5])},i(u){r||(S(i),r=!0)},o(u){C(i),r=!1},d(u){u&&E(e),l[t].d()}}}function v9(n){let e,t;return e=new cT({props:{elem_classes:["gradio-tabs"],$$slots:{default:[S9]},$$scope:{ctx:n}}}),e.$on("select",A9),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&33554823&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function w9(n){let e,t;return e=new yt({props:{$$slots:{default:[I9]},$$scope:{ctx:n}}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&33554935&&(r.$$scope={dirty:s,ctx:i}),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function k9(n){let e,t,i;return e=new wa({props:{layoutState:n[0],dragItem:n[19],zIndex:n[2]+1,isMobile:n[7]}}),{c(){Y(e.$$.fragment),t=se()},m(s,r){G(e,s,r),A(s,t,r),i=!0},p(s,r){const o={};r&1&&(o.layoutState=s[0]),r&256&&(o.dragItem=s[19]),r&4&&(o.zIndex=s[2]+1),r&128&&(o.isMobile=s[7]),e.$set(o)},i(s){i||(S(e.$$.fragment,s),i=!0)},o(s){C(e.$$.fragment,s),i=!1},d(s){s&&E(t),j(e,s)}}}function dy(n,e){let t,i,s;return i=new qd({props:{id:e[21],name:e[21],$$slots:{default:[k9]},$$scope:{ctx:e}}}),{key:n,first:null,c(){t=we(),Y(i.$$.fragment),this.first=t},m(r,o){A(r,t,o),G(i,r,o),s=!0},p(r,o){e=r;const l={};o&258&&(l.id=e[21]),o&258&&(l.name=e[21]),o&33554821&&(l.$$scope={dirty:o,ctx:e}),i.$set(l)},i(r){s||(S(i.$$.fragment,r),s=!0)},o(r){C(i.$$.fragment,r),s=!1},d(r){r&&E(t),j(i,r)}}}function S9(n){let e=[],t=new Map,i,s,r=Xe(n[8].filter(n[17]));const o=l=>l[19].id;for(let l=0;l{t=Ec(e,ef,{duration:200,easing:Rp}),t.start()})},o:Z,d(i){i&&E(e)}}}function C9(n){let e,t,i,s,r,o,l,a;t=new kn({props:{$$slots:{default:[T9]},$$scope:{ctx:n}}}),r=new wa({props:{layoutState:n[0],dragItem:n[19],zIndex:n[2]+1,isMobile:n[7]}});let u=n[19][Is]&&py();return{c(){e=z("label"),Y(t.$$.fragment),s=se(),Y(r.$$.fragment),o=se(),u&&u.c(),l=we(),v(e,"for",i=String(n[19].id))},m(c,f){A(c,e,f),G(t,e,null),A(c,s,f),G(r,c,f),A(c,o,f),u&&u.m(c,f),A(c,l,f),a=!0},p(c,f){const h={};f&33554690&&(h.$$scope={dirty:f,ctx:c}),t.$set(h),(!a||f&256&&i!==(i=String(c[19].id)))&&v(e,"for",i);const d={};f&1&&(d.layoutState=c[0]),f&256&&(d.dragItem=c[19]),f&4&&(d.zIndex=c[2]+1),f&128&&(d.isMobile=c[7]),r.$set(d),c[19][Is]?u?f&256&&S(u,1):(u=py(),u.c(),S(u,1),u.m(l.parentNode,l)):u&&(u.d(1),u=null)},i(c){a||(S(t.$$.fragment,c),S(r.$$.fragment,c),S(u),a=!0)},o(c){C(t.$$.fragment,c),C(r.$$.fragment,c),a=!1},d(c){c&&(E(e),E(s),E(o),E(l)),j(t),j(r,c),u&&u.d(c)}}}function gy(n,e){let t,i,s,r,o,l=Z,a;return i=new yt({props:{$$slots:{default:[C9]},$$scope:{ctx:e}}}),{key:n,first:null,c(){var u,c;t=z("div"),Y(i.$$.fragment),s=se(),v(t,"class","animation-wrapper svelte-1gex4qr"),v(t,"style",r=((c=(u=e[19])==null?void 0:u.attrs)==null?void 0:c.style)||""),B(t,"hidden",e[20]),this.first=t},m(u,c){A(u,t,c),G(i,t,null),F(t,s),a=!0},p(u,c){var h,d;e=u;const f={};c&33554823&&(f.$$scope={dirty:c,ctx:e}),i.$set(f),(!a||c&256&&r!==(r=((d=(h=e[19])==null?void 0:h.attrs)==null?void 0:d.style)||""))&&v(t,"style",r),(!a||c&256)&&B(t,"hidden",e[20])},r(){o=t.getBoundingClientRect()},f(){sp(t),l()},a(){l(),l=np(t,o,Vp,{duration:Zd})},i(u){a||(S(i.$$.fragment,u),a=!0)},o(u){C(i.$$.fragment,u),a=!1},d(u){u&&E(t),j(i)}}}function my(n){let e;return{c(){e=z("div"),v(e,"class","handle handle-hidden svelte-1gex4qr"),B(e,"hidden",!n[5]),ve(e,"z-index",n[2]+100)},m(t,i){A(t,e,i)},p(t,i){i&32&&B(e,"hidden",!t[5]),i&4&&ve(e,"z-index",t[2]+100)},d(t){t&&E(e)}}}function _y(n){let e,t,i,s;return{c(){e=z("div"),v(e,"class","handle handle-container svelte-1gex4qr"),v(e,"data-drag-item-id",t=n[1].id),ve(e,"z-index",n[2]+100)},m(r,o){A(r,e,o),i||(s=[ee(e,"mousedown",n[13]),ee(e,"touchstart",n[13]),ee(e,"mouseup",n[14]),ee(e,"touchend",n[14])],i=!0)},p(r,o){o&2&&t!==(t=r[1].id)&&v(e,"data-drag-item-id",t),o&4&&ve(e,"z-index",r[2]+100)},d(r){r&&E(e),i=!1,lt(s)}}}function I9(n){let e,t=[],i=new Map,s,r,o=$n(n[1])&&n[5],l,a,u,c,f,h=Xe(n[8].filter(n[16]));const d=m=>m[19].id;for(let m=0;m{i=null}),le())},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d(s)}}}const Zd=100;function CT(n,e){const t=n.attrs.title;if(!t)return`Tab ${e+1}`;const s=t.split(",").map(r=>r.trim())[e];return s==null||s===""?`Tab ${e+1}`:s}function A9(){navigator.vibrate(20)}function O9(n,e,t){let i,s=Z,r=()=>(s(),s=ot(a,x=>t(15,i=x)),a),o,l;Si(n,bi,x=>t(9,o=x)),Si(n,Ri,x=>t(10,l=x)),n.$$.on_destroy.push(()=>s());let{layoutState:a}=e;r();let{container:u=null}=e,{zIndex:c=0}=e,{classes:f=[]}=e,{showHandles:h=!1}=e,{edit:d=!1}=e,{dragDisabled:p=!1}=e,{isMobile:g=!1}=e,m=[];function _(x){t(8,m=Fp(a,u,x))}function b(x){t(8,m=Wp(a,u,x))}function y(x){Bc(x,a)}function k(x){zc(x,a)}const T=x=>x.id!==Us,I=x=>x.id!==Us;return n.$$set=x=>{"layoutState"in x&&r(t(0,a=x.layoutState)),"container"in x&&t(1,u=x.container),"zIndex"in x&&t(2,c=x.zIndex),"classes"in x&&t(3,f=x.classes),"showHandles"in x&&t(4,h=x.showHandles),"edit"in x&&t(5,d=x.edit),"dragDisabled"in x&&t(6,p=x.dragDisabled),"isMobile"in x&&t(7,g=x.isMobile)},n.$$.update=()=>{n.$$.dirty&32770&&(u?t(8,m=i.allItems[u.id].children):t(8,m=[]))},[a,u,c,f,h,d,p,g,m,o,l,_,b,y,k,i,T,I]}class N9 extends _e{constructor(e){super(),me(this,e,O9,E9,ae,{layoutState:0,container:1,zIndex:2,classes:3,showHandles:4,edit:5,dragDisabled:6,isMobile:7})}}function Oh(n){const e=n.slice(),t=e[7].uiUnlocked&&e[7].uiEditMode==="widgets";e[10]=t;const i=e[2]===0||e[8].currentSelection.length>2||!e[7].uiUnlocked;return e[11]=i,e}function by(n){let e=n[9],t,i,s=vy(n);return{c(){s.c(),t=we()},m(r,o){s.m(r,o),A(r,t,o),i=!0},p(r,o){o&512&&ae(e,e=r[9])?(oe(),C(s,1,1,Z),le(),s=vy(r),s.c(),S(s,1),s.m(t.parentNode,t)):s.p(r,o)},i(r){i||(S(s),i=!0)},o(r){C(s),i=!1},d(r){r&&E(t),s.d(r)}}}function yy(n){let e,t,i,s;const r=[L9,x9,D9],o=[];function l(a,u){return a[1].attrs.variant==="tabs"?0:a[1].attrs.variant==="accordion"?1:2}return e=l(n),t=o[e]=r[e](n),{c(){t.c(),i=we()},m(a,u){o[e].m(a,u),A(a,i,u),s=!0},p(a,u){let c=e;e=l(a),e===c?o[e].p(a,u):(oe(),C(o[c],1,1,()=>{o[c]=null}),le(),t=o[e],t?t.p(a,u):(t=o[e]=r[e](a),t.c()),S(t,1),t.m(i.parentNode,i))},i(a){s||(S(t),s=!0)},o(a){C(t),s=!1},d(a){a&&E(i),o[e].d(a)}}}function D9(n){let e,t;return e=new c9({props:{layoutState:n[0],container:n[1],zIndex:n[2],classes:n[3],showHandles:n[4],edit:n[10],dragDisabled:n[11],isMobile:n[5]}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&1&&(r.layoutState=i[0]),s&2&&(r.container=i[1]),s&4&&(r.zIndex=i[2]),s&8&&(r.classes=i[3]),s&16&&(r.showHandles=i[4]),s&128&&(r.edit=i[10]),s&388&&(r.dragDisabled=i[11]),s&32&&(r.isMobile=i[5]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function x9(n){let e,t;return e=new y9({props:{layoutState:n[0],container:n[1],zIndex:n[2],classes:n[3],showHandles:n[4],edit:n[10],dragDisabled:n[11],isMobile:n[5]}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&1&&(r.layoutState=i[0]),s&2&&(r.container=i[1]),s&4&&(r.zIndex=i[2]),s&8&&(r.classes=i[3]),s&16&&(r.showHandles=i[4]),s&128&&(r.edit=i[10]),s&388&&(r.dragDisabled=i[11]),s&32&&(r.isMobile=i[5]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function L9(n){let e,t;return e=new N9({props:{layoutState:n[0],container:n[1],zIndex:n[2],classes:n[3],showHandles:n[4],edit:n[10],dragDisabled:n[11],isMobile:n[5]}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&1&&(r.layoutState=i[0]),s&2&&(r.container=i[1]),s&4&&(r.zIndex=i[2]),s&8&&(r.classes=i[3]),s&16&&(r.showHandles=i[4]),s&128&&(r.edit=i[10]),s&388&&(r.dragDisabled=i[11]),s&32&&(r.isMobile=i[5]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function vy(n){let e=n[10]||!$n(n[1]),t,i,s=e&&yy(n);return{c(){s&&s.c(),t=we()},m(r,o){s&&s.m(r,o),A(r,t,o),i=!0},p(r,o){o&130&&(e=r[10]||!$n(r[1])),e?s?(s.p(r,o),o&130&&S(s,1)):(s=yy(r),s.c(),S(s,1),s.m(t.parentNode,t)):s&&(oe(),C(s,1,1,()=>{s=null}),le())},i(r){i||(S(s),i=!0)},o(r){C(s),i=!1},d(r){r&&E(t),s&&s.d(r)}}}function M9(n){let e,t,i=n[1]&&by(Oh(n));return{c(){i&&i.c(),e=we()},m(s,r){i&&i.m(s,r),A(s,e,r),t=!0},p(s,[r]){s[1]?i?(i.p(Oh(s),r),r&2&&S(i,1)):(i=by(Oh(s)),i.c(),S(i,1),i.m(e.parentNode,e)):i&&(oe(),C(i,1,1,()=>{i=null}),le())},i(s){t||(S(i),t=!0)},o(s){C(i),t=!1},d(s){s&&E(e),i&&i.d(s)}}}function R9(n,e,t){let i,s,r,o=Z,l=()=>(o(),o=ot(p,g=>t(9,r=g)),p);Si(n,bi,g=>t(7,i=g)),Si(n,Ri,g=>t(8,s=g)),n.$$.on_destroy.push(()=>o());let{layoutState:a}=e,{container:u=null}=e,{zIndex:c=0}=e,{classes:f=[]}=e,{showHandles:h=!1}=e,{isMobile:d=!1}=e,p=null;return l(),n.$$set=g=>{"layoutState"in g&&t(0,a=g.layoutState),"container"in g&&t(1,u=g.container),"zIndex"in g&&t(2,c=g.zIndex),"classes"in g&&t(3,f=g.classes),"showHandles"in g&&t(4,h=g.showHandles),"isMobile"in g&&t(5,d=g.isMobile)},n.$$.update=()=>{n.$$.dirty&2&&l(u?t(6,p=u.attrsChanged):t(6,p=null))},[a,u,c,f,h,d,p,i,s,r]}class P9 extends _e{constructor(e){super(),me(this,e,R9,M9,ae,{layoutState:0,container:1,zIndex:2,classes:3,showHandles:4,isMobile:5})}}function B9(n){const e=n.slice(),t=e[7].uiUnlocked&&e[7].uiEditMode==="widgets";e[19]=t;const i=$n(e[5]);e[20]=i;const s=e[7].uiUnlocked&&e[12].currentHovered.has(e[5].id);e[21]=s;const r=e[7].uiUnlocked&&e[12].currentSelection.includes(e[5].id);return e[22]=r,e}function z9(n){let e=n[11],t,i,s=Ty(n);return{c(){s.c(),t=we()},m(r,o){s.m(r,o),A(r,t,o),i=!0},p(r,o){o&2048&&ae(e,e=r[11])?(oe(),C(s,1,1,Z),le(),s=Ty(r),s.c(),S(s,1),s.m(t.parentNode,t)):s.p(r,o)},i(r){i||(S(s),i=!0)},o(r){C(s),i=!1},d(r){r&&E(t),s.d(r)}}}function F9(n){let e=n[11],t,i,s=Cy(n);return{c(){s.c(),t=we()},m(r,o){s.m(r,o),A(r,t,o),i=!0},p(r,o){o&2048&&ae(e,e=r[11])?(oe(),C(s,1,1,Z),le(),s=Cy(r),s.c(),S(s,1),s.m(t.parentNode,t)):s.p(r,o)},i(r){i||(S(s),i=!0)},o(r){C(s),i=!1},d(r){r&&E(t),s.d(r)}}}function wy(n){let e;return{c(){e=z("div"),v(e,"class","handle handle-hidden svelte-1nqgbfy"),B(e,"hidden",!n[19])},m(t,i){A(t,e,i)},p(t,i){i&128&&B(e,"hidden",!t[19])},d(t){t&&E(e)}}}function ky(n){let e,t,i,s;return{c(){e=z("div"),v(e,"class","handle handle-widget svelte-1nqgbfy"),v(e,"data-drag-item-id",t=n[5].id),B(e,"hovered",n[21])},m(r,o){A(r,e,o),i||(s=[ee(e,"mousedown",n[15]),ee(e,"touchstart",n[15]),ee(e,"mouseup",n[16]),ee(e,"touchend",n[16])],i=!0)},p(r,o){o&32&&t!==(t=r[5].id)&&v(e,"data-drag-item-id",t),o&4256&&B(e,"hovered",r[21])},d(r){r&&E(e),i=!1,lt(s)}}}function Sy(n){let e,t,i,s,r,o,l;var a=n[5].node.svelteComponentType;function u(h){return{props:{widget:h[5],isMobile:h[3]}}}a&&(t=Nt(a,u(n)));let c=n[20]&&n[19]&&wy(n),f=(n[10]||n[21])&&ky(n);return{c(){e=z("div"),t&&Y(t.$$.fragment),s=se(),c&&c.c(),r=se(),f&&f.c(),o=we(),v(e,"class",i="widget "+n[5].attrs.classes+" "+n[14]()+" svelte-1nqgbfy"),B(e,"edit",n[19]),B(e,"hovered",n[21]),B(e,"selected",n[22]),B(e,"is-executing",n[6].runningNodeID&&n[6].runningNodeID==n[5].node.id),B(e,"hidden",n[20])},m(h,d){A(h,e,d),t&&G(t,e,null),A(h,s,d),c&&c.m(h,d),A(h,r,d),f&&f.m(h,d),A(h,o,d),l=!0},p(h,d){const p={};if(d&32&&(p.widget=h[5]),d&8&&(p.isMobile=h[3]),d&32&&a!==(a=h[5].node.svelteComponentType)){if(t){oe();const g=t;C(g.$$.fragment,1,0,()=>{j(g,1)}),le()}a?(t=Nt(a,u(h)),Y(t.$$.fragment),S(t.$$.fragment,1),G(t,e,null)):t=null}else a&&t.$set(p);(!l||d&32&&i!==(i="widget "+h[5].attrs.classes+" "+h[14]()+" svelte-1nqgbfy"))&&v(e,"class",i),(!l||d&160)&&B(e,"edit",h[19]),(!l||d&4256)&&B(e,"hovered",h[21]),(!l||d&4256)&&B(e,"selected",h[22]),(!l||d&96)&&B(e,"is-executing",h[6].runningNodeID&&h[6].runningNodeID==h[5].node.id),(!l||d&32)&&B(e,"hidden",h[20]),h[20]&&h[19]?c?c.p(h,d):(c=wy(h),c.c(),c.m(r.parentNode,r)):c&&(c.d(1),c=null),h[10]||h[21]?f?f.p(h,d):(f=ky(h),f.c(),f.m(o.parentNode,o)):f&&(f.d(1),f=null)},i(h){l||(t&&S(t.$$.fragment,h),l=!0)},o(h){t&&C(t.$$.fragment,h),l=!1},d(h){h&&(E(e),E(s),E(r),E(o)),t&&j(t),c&&c.d(h),f&&f.d(h)}}}function Ty(n){let e=n[13],t,i,s=Sy(n);return{c(){s.c(),t=we()},m(r,o){s.m(r,o),A(r,t,o),i=!0},p(r,o){o&8192&&ae(e,e=r[13])?(oe(),C(s,1,1,Z),le(),s=Sy(r),s.c(),S(s,1),s.m(t.parentNode,t)):s.p(r,o)},i(r){i||(S(s),i=!0)},o(r){C(s),i=!1},d(r){r&&E(t),s.d(r)}}}function Cy(n){let e,t;return e=new P9({props:{layoutState:n[0],container:n[4],classes:n[2],zIndex:n[1],showHandles:n[10],isMobile:n[3]}}),{c(){Y(e.$$.fragment)},m(i,s){G(e,i,s),t=!0},p(i,s){const r={};s&1&&(r.layoutState=i[0]),s&16&&(r.container=i[4]),s&4&&(r.classes=i[2]),s&2&&(r.zIndex=i[1]),s&1024&&(r.showHandles=i[10]),s&8&&(r.isMobile=i[3]),e.$set(r)},i(i){t||(S(e.$$.fragment,i),t=!0)},o(i){C(e.$$.fragment,i),t=!1},d(i){j(e,i)}}}function W9(n){let e,t,i,s;const r=[F9,z9],o=[];function l(u,c){return u[4]?0:u[5]&&u[5].node?1:-1}function a(u,c){return c===1?B9(u):u}return~(e=l(n))&&(t=o[e]=r[e](a(n,e))),{c(){t&&t.c(),i=we()},m(u,c){~e&&o[e].m(u,c),A(u,i,c),s=!0},p(u,[c]){let f=e;e=l(u),e===f?~e&&o[e].p(a(u,e),c):(t&&(oe(),C(o[f],1,1,()=>{o[f]=null}),le()),~e?(t=o[e],t?t.p(a(u,e),c):(t=o[e]=r[e](a(u,e)),t.c()),S(t,1),t.m(i.parentNode,i)):t=null)},i(u){s||(S(t),s=!0)},o(u){C(t),s=!1},d(u){u&&E(i),~e&&o[e].d(u)}}}function V9(n,e,t){let i,s,r=Z,o=()=>(r(),r=ot(g,M=>t(18,s=M)),g),l,a,u=Z,c=()=>(u(),u=ot(T,M=>t(11,a=M)),T),f,h,d=Z,p=()=>(d(),d=ot(I,M=>t(13,h=M)),I);Si(n,bt,M=>t(6,i=M)),Si(n,bi,M=>t(7,l=M)),Si(n,Ri,M=>t(12,f=M)),n.$$.on_destroy.push(()=>r()),n.$$.on_destroy.push(()=>u()),n.$$.on_destroy.push(()=>d());let{layoutState:g}=e;o();let{dragItem:m=null}=e,{zIndex:_=0}=e,{classes:b=[]}=e,{isMobile:y=!1}=e,k=null,T=Be(0);c();let I=Be(0);p();let x=null,R=!1;function N(){return`widget--${x.node.type.replace("/","-").replace(".","-")}`}function O(M){Bc(M,g)}function D(M){zc(M,g)}return n.$$set=M=>{"layoutState"in M&&o(t(0,g=M.layoutState)),"dragItem"in M&&t(17,m=M.dragItem),"zIndex"in M&&t(1,_=M.zIndex),"classes"in M&&t(2,b=M.classes),"isMobile"in M&&t(3,y=M.isMobile)},n.$$.update=()=>{n.$$.dirty&393264&&(!m||!s.allItems[m.id]?(t(17,m=null),t(4,k=null),t(5,x=null),c(t(8,T=Be(0))),p(t(9,I=Be(0)))):m.type==="container"?(t(4,k=m),c(t(8,T=k.attrsChanged)),t(5,x=null),p(t(9,I=null))):m.type==="widget"&&(t(5,x=m),c(t(8,T=x.attrsChanged)),t(4,k=null),x.node&&"propsChanged"in x.node?p(t(9,I=x.node.propsChanged)):p(t(9,I=Be(0))))),n.$$.dirty&262274&&t(10,R=l.uiUnlocked&&l.uiEditMode==="widgets"&&_>1&&!s.isMenuOpen),n.$$.dirty&96&&i&&x&&x.node&&t(17,m.isNodeExecuting=i.runningNodeID===x.node.id,m)},[g,_,b,y,k,x,i,l,T,I,R,a,f,h,N,O,D,m,s]}class wa extends _e{constructor(e){super(),me(this,e,V9,W9,ae,{layoutState:0,dragItem:17,zIndex:1,classes:2,isMobile:3})}}export{Le as $,Nt as A,Y as B,G as C,_i as D,rl as E,j as F,Xe as G,oC as H,Dr as I,ap as J,mr as K,sp as L,cC as M,np as N,vn as O,Ec as P,rW as Q,X9 as R,_e as S,Vp as T,ef as U,Nh as V,zt as W,Zn as X,De as Y,ze as Z,Jt as _,et as a,Jl as a$,Me as a0,xe as a1,zs as a2,Ac as a3,mi as a4,xy as a5,pi as a6,ke as a7,je as a8,ve as a9,Ut as aA,bt as aB,Bt as aC,Xn as aD,Q9 as aE,br as aF,nW as aG,Ti as aH,LW as aI,vW as aJ,iW as aK,ot as aL,aO as aM,lO as aN,_r as aO,tO as aP,eO as aQ,nO as aR,bi as aS,Ri as aT,wa as aU,So as aV,V7 as aW,If as aX,Ef as aY,iT as aZ,uz as a_,op as aa,yr as ab,Y9 as ac,Ze as ad,qb as ae,zi as af,Mp as ag,SA as ah,pA as ai,fA as aj,yt as ak,Yl as al,ht as am,Af as an,Gs as ao,EN as ap,jt as aq,Gt as ar,gE as as,kn as at,XN as au,dr as av,Qc as aw,Hn as ax,U9 as ay,Zc as az,me as b,j9 as b0,q9 as b1,Zt as b2,av as b3,ie as b4,lA as b5,Kd as b6,tW as b7,eW as b8,fi as b9,dW as bA,yW as bB,at as bC,hW as bD,gW as bE,pr as bF,cW as bG,pW as bH,jh as bI,_W as bJ,PN as bK,YT as bL,bW as bM,G9 as bN,mW as bO,fC as bP,sW as bQ,a0 as bR,fu as ba,on as bb,Is as bc,KF as bd,Us as be,vp as bf,By as bg,nt as bh,NW as bi,bE as bj,Rp as bk,mE as bl,SW as bm,K9 as bn,$9 as bo,DW as bp,Z9 as bq,ti as br,Ev as bs,J9 as bt,KT as bu,wW as bv,Bv as bw,xW as bx,To as by,fW as bz,se as c,v as d,z as e,A as f,F as g,ee as h,Ic as i,oe as j,C as k,tp as l,le as m,Qd as n,S as o,E as p,Si as q,lt as r,ae as s,B as t,sl as u,rp as v,Be as w,Z as x,Xh as y,we as z}; -//# sourceMappingURL=global-b3b5b4db.js.map