@dbt-tools/web 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,112 @@
1
+ (function(){var e=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),t=(/* @__PURE__ */ e(((e,t)=>{var n=typeof Reflect==`object`?Reflect:null,r=n&&typeof n.apply==`function`?n.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},i=n&&typeof n.ownKeys==`function`?n.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function a(e){console&&console.warn&&console.warn(e)}var o=Number.isNaN||function(e){return e!==e};function s(){s.init.call(this)}t.exports=s,t.exports.once=y,s.EventEmitter=s,s.prototype._events=void 0,s.prototype._eventsCount=0,s.prototype._maxListeners=void 0;var c=10;function l(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(s,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);c=e}}),s.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},s.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||o(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function u(e){return e._maxListeners===void 0?s.defaultMaxListeners:e._maxListeners}s.prototype.getMaxListeners=function(){return u(this)},s.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=/* @__PURE__ */ Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)r(c,this,t);else for(var l=c.length,u=g(c,l),n=0;n<l;++n)r(u[n],this,t);return!0};function d(e,t,n,r){var i,o,s;if(l(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),s=o[t]),s===void 0)s=o[t]=n,++e._eventsCount;else if(typeof s==`function`?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),i=u(e),i>0&&s.length>i&&!s.warned){s.warned=!0;var c=/* @__PURE__ */ Error(`Possible EventEmitter memory leak detected. `+s.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);c.name=`MaxListenersExceededWarning`,c.emitter=e,c.type=t,c.count=s.length,a(c)}return e}s.prototype.addListener=function(e,t){return d(this,e,t,!1)},s.prototype.on=s.prototype.addListener,s.prototype.prependListener=function(e,t){return d(this,e,t,!0)};function f(){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 p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=f.bind(r);return i.listener=n,r.wrapFn=i,i}s.prototype.once=function(e,t){return l(t),this.on(e,p(this,e,t)),this},s.prototype.prependOnceListener=function(e,t){return l(t),this.prependListener(e,p(this,e,t)),this},s.prototype.removeListener=function(e,t){var n,r,i,a,o;if(l(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():_(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},s.prototype.off=s.prototype.removeListener,s.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function m(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?v(i):g(i,i.length)}s.prototype.listeners=function(e){return m(this,e,!0)},s.prototype.rawListeners=function(e){return m(this,e,!1)},s.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):h.call(e,t)},s.prototype.listenerCount=h;function h(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}s.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]};function g(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function _(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function v(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function y(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}x(e,t,a,{once:!0}),t!==`error`&&b(e,i,{once:!0})})}function b(e,t,n){typeof e.on==`function`&&x(e,`error`,t,n)}function x(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}})))();function n(){let e=arguments[0];for(let t=1,n=arguments.length;t<n;t++)if(arguments[t])for(let n in arguments[t])e[n]=arguments[t][n];return e}let r=n;typeof Object.assign==`function`&&(r=Object.assign);function i(e,t,n,r){let i=e._nodes.get(t),a=null;return i&&(a=r===`mixed`?i.out&&i.out[n]||i.undirected&&i.undirected[n]:r===`directed`?i.out&&i.out[n]:i.undirected&&i.undirected[n]),a}function a(e){return typeof e==`object`&&!!e}function o(e){let t;for(t in e)return!1;return!0}function s(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function c(e,t,n){let r={enumerable:!0,configurable:!0};typeof n==`function`?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(e,t,r)}function l(e){return!(!a(e)||e.attributes&&!Array.isArray(e.attributes))}function u(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function d(){let e=arguments,t=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(r=t.next(),r.done)t=null;else break}while(1);return r}}}function f(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}var p=class extends Error{constructor(e){super(),this.name=`GraphError`,this.message=e}},m=class e extends p{constructor(t){super(t),this.name=`InvalidArgumentsGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}},h=class e extends p{constructor(t){super(t),this.name=`NotFoundGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}},g=class e extends p{constructor(t){super(t),this.name=`UsageGraphError`,typeof Error.captureStackTrace==`function`&&Error.captureStackTrace(this,e.prototype.constructor)}};function _(e,t){this.key=e,this.attributes=t,this.clear()}_.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function v(e,t){this.key=e,this.attributes=t,this.clear()}v.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function y(e,t){this.key=e,this.attributes=t,this.clear()}y.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function b(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}b.prototype.attach=function(){let e=`out`,t=`in`;this.undirected&&(e=t=`undirected`);let n=this.source.key,r=this.target.key;this.source[e][r]=this,this.undirected&&n===r||(this.target[t][n]=this)},b.prototype.attachMulti=function(){let e=`out`,t=`in`,n=this.source.key,r=this.target.key;this.undirected&&(e=t=`undirected`);let i=this.source[e],a=i[r];a===void 0?(i[r]=this,this.undirected&&n===r||(this.target[t][n]=this)):(a.previous=this,this.next=a,i[r]=this,this.target[t][n]=this)},b.prototype.detach=function(){let e=this.source.key,t=this.target.key,n=`out`,r=`in`;this.undirected&&(n=r=`undirected`),delete this.source[n][t],delete this.target[r][e]},b.prototype.detachMulti=function(){let e=this.source.key,t=this.target.key,n=`out`,r=`in`;this.undirected&&(n=r=`undirected`),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};function x(e,t,n,r,i,a,o){let s,c,l,u;if(r=``+r,n===0){if(s=e._nodes.get(r),!s)throw new h(`Graph.${t}: could not find the "${r}" node in the graph.`);l=i,u=a}else if(n===3){if(i=``+i,c=e._edges.get(i),!c)throw new h(`Graph.${t}: could not find the "${i}" edge in the graph.`);let n=c.source.key,d=c.target.key;if(r===n)s=c.target;else if(r===d)s=c.source;else throw new h(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${n}, ${d}).`);l=a,u=o}else{if(c=e._edges.get(r),!c)throw new h(`Graph.${t}: could not find the "${r}" edge in the graph.`);s=n===1?c.source:c.target,l=i,u=a}return[s,l,u]}function ee(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=x(this,t,n,e,r,i);return a.attributes[o]}}function S(e,t,n){e.prototype[t]=function(e,r){let[i]=x(this,t,n,e,r);return i.attributes}}function te(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=x(this,t,n,e,r,i);return a.attributes.hasOwnProperty(o)}}function ne(e,t,n){e.prototype[t]=function(e,r,i,a){let[o,s,c]=x(this,t,n,e,r,i,a);return o.attributes[s]=c,this.emit(`nodeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:s}),this}}function re(e,t,n){e.prototype[t]=function(e,r,i,a){let[o,s,c]=x(this,t,n,e,r,i,a);if(typeof c!=`function`)throw new m(`Graph.${t}: updater should be a function.`);let l=o.attributes;return l[s]=c(l[s]),this.emit(`nodeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:s}),this}}function ie(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=x(this,t,n,e,r,i);return delete a.attributes[o],this.emit(`nodeAttributesUpdated`,{key:a.key,type:`remove`,attributes:a.attributes,name:o}),this}}function ae(e,t,n){e.prototype[t]=function(e,r,i){let[o,s]=x(this,t,n,e,r,i);if(!a(s))throw new m(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=s,this.emit(`nodeAttributesUpdated`,{key:o.key,type:`replace`,attributes:o.attributes}),this}}function oe(e,t,n){e.prototype[t]=function(e,i,o){let[s,c]=x(this,t,n,e,i,o);if(!a(c))throw new m(`Graph.${t}: provided attributes are not a plain object.`);return r(s.attributes,c),this.emit(`nodeAttributesUpdated`,{key:s.key,type:`merge`,attributes:s.attributes,data:c}),this}}function se(e,t,n){e.prototype[t]=function(e,r,i){let[a,o]=x(this,t,n,e,r,i);if(typeof o!=`function`)throw new m(`Graph.${t}: provided updater is not a function.`);return a.attributes=o(a.attributes),this.emit(`nodeAttributesUpdated`,{key:a.key,type:`update`,attributes:a.attributes}),this}}let ce=[{name:e=>`get${e}Attribute`,attacher:ee},{name:e=>`get${e}Attributes`,attacher:S},{name:e=>`has${e}Attribute`,attacher:te},{name:e=>`set${e}Attribute`,attacher:ne},{name:e=>`update${e}Attribute`,attacher:re},{name:e=>`remove${e}Attribute`,attacher:ie},{name:e=>`replace${e}Attributes`,attacher:ae},{name:e=>`merge${e}Attributes`,attacher:oe},{name:e=>`update${e}Attributes`,attacher:se}];function le(e){ce.forEach(function({name:t,attacher:n}){n(e,t(`Node`),0),n(e,t(`Source`),1),n(e,t(`Target`),2),n(e,t(`Opposite`),3)})}function ue(e,t,n){e.prototype[t]=function(e,r){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=``+e,s=``+r;if(r=arguments[2],a=i(this,o,s,n),!a)throw new h(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,a=this._edges.get(e),!a)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return a.attributes[r]}}function de(e,t,n){e.prototype[t]=function(e){let r;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new g(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=``+e,o=``+arguments[1];if(r=i(this,a,o,n),!r)throw new h(`Graph.${t}: could not find an edge for the given path ("${a}" - "${o}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,r=this._edges.get(e),!r)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return r.attributes}}function fe(e,t,n){e.prototype[t]=function(e,r){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=``+e,s=``+r;if(r=arguments[2],a=i(this,o,s,n),!a)throw new h(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,a=this._edges.get(e),!a)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return a.attributes.hasOwnProperty(r)}}function pe(e,t,n){e.prototype[t]=function(e,r,a){let o;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new g(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=``+e,c=``+r;if(r=arguments[2],a=arguments[3],o=i(this,s,c,n),!o)throw new h(`Graph.${t}: could not find an edge for the given path ("${s}" - "${c}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,o=this._edges.get(e),!o)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return o.attributes[r]=a,this.emit(`edgeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:r}),this}}function me(e,t,n){e.prototype[t]=function(e,r,a){let o;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new g(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let s=``+e,c=``+r;if(r=arguments[2],a=arguments[3],o=i(this,s,c,n),!o)throw new h(`Graph.${t}: could not find an edge for the given path ("${s}" - "${c}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,o=this._edges.get(e),!o)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(typeof a!=`function`)throw new m(`Graph.${t}: updater should be a function.`);return o.attributes[r]=a(o.attributes[r]),this.emit(`edgeAttributesUpdated`,{key:o.key,type:`set`,attributes:o.attributes,name:r}),this}}function he(e,t,n){e.prototype[t]=function(e,r){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=``+e,s=``+r;if(r=arguments[2],a=i(this,o,s,n),!a)throw new h(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,a=this._edges.get(e),!a)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}return delete a.attributes[r],this.emit(`edgeAttributesUpdated`,{key:a.key,type:`remove`,attributes:a.attributes,name:r}),this}}function ge(e,t,n){e.prototype[t]=function(e,r){let o;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let a=``+e,s=``+r;if(r=arguments[2],o=i(this,a,s,n),!o)throw new h(`Graph.${t}: could not find an edge for the given path ("${a}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,o=this._edges.get(e),!o)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(!a(r))throw new m(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=r,this.emit(`edgeAttributesUpdated`,{key:o.key,type:`replace`,attributes:o.attributes}),this}}function _e(e,t,n){e.prototype[t]=function(e,o){let s;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let r=``+e,a=``+o;if(o=arguments[2],s=i(this,r,a,n),!s)throw new h(`Graph.${t}: could not find an edge for the given path ("${r}" - "${a}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,s=this._edges.get(e),!s)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(!a(o))throw new m(`Graph.${t}: provided attributes are not a plain object.`);return r(s.attributes,o),this.emit(`edgeAttributesUpdated`,{key:s.key,type:`merge`,attributes:s.attributes,data:o}),this}}function ve(e,t,n){e.prototype[t]=function(e,r){let a;if(this.type!==`mixed`&&n!==`mixed`&&n!==this.type)throw new g(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new g(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);let o=``+e,s=``+r;if(r=arguments[2],a=i(this,o,s,n),!a)throw new h(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!==`mixed`)throw new g(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(e=``+e,a=this._edges.get(e),!a)throw new h(`Graph.${t}: could not find the "${e}" edge in the graph.`)}if(typeof r!=`function`)throw new m(`Graph.${t}: provided updater is not a function.`);return a.attributes=r(a.attributes),this.emit(`edgeAttributesUpdated`,{key:a.key,type:`update`,attributes:a.attributes}),this}}let ye=[{name:e=>`get${e}Attribute`,attacher:ue},{name:e=>`get${e}Attributes`,attacher:de},{name:e=>`has${e}Attribute`,attacher:fe},{name:e=>`set${e}Attribute`,attacher:pe},{name:e=>`update${e}Attribute`,attacher:me},{name:e=>`remove${e}Attribute`,attacher:he},{name:e=>`replace${e}Attributes`,attacher:ge},{name:e=>`merge${e}Attributes`,attacher:_e},{name:e=>`update${e}Attributes`,attacher:ve}];function be(e){ye.forEach(function({name:t,attacher:n}){n(e,t(`Edge`),`mixed`),n(e,t(`DirectedEdge`),`directed`),n(e,t(`UndirectedEdge`),`undirected`)})}let xe=[{name:`edges`,type:`mixed`},{name:`inEdges`,type:`directed`,direction:`in`},{name:`outEdges`,type:`directed`,direction:`out`},{name:`inboundEdges`,type:`mixed`,direction:`in`},{name:`outboundEdges`,type:`mixed`,direction:`out`},{name:`directedEdges`,type:`directed`},{name:`undirectedEdges`,type:`undirected`}];function Se(e,t,n,r){let i=!1;for(let a in t){if(a===r)continue;let o=t[a];if(i=n(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),e&&i)return o.key}}function Ce(e,t,n,r){let i,a,o,s=!1;for(let c in t)if(c!==r){i=t[c];do{if(a=i.source,o=i.target,s=n(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected),e&&s)return i.key;i=i.next}while(i!==void 0)}}function we(e,t){let n=Object.keys(e),r=n.length,i,a=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(a>=r)return{done:!0};let o=n[a++];if(o===t){i=void 0;continue}i=e[o]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function Te(e,t,n,r){let i=t[n];if(!i)return;let a=i.source,o=i.target;if(r(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected)&&e)return i.key}function Ee(e,t,n,r){let i=t[n];if(!i)return;let a=!1;do{if(a=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),e&&a)return i.key;i=i.next}while(i!==void 0)}function De(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let e={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:e}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function Oe(e,t){if(e.size===0)return[];if(t===`mixed`||t===e.type)return Array.from(e._edges.keys());let n=t===`undirected`?e.undirectedSize:e.directedSize,r=Array(n),i=t===`undirected`,a=e._edges.values(),o=0,s,c;for(;s=a.next(),s.done!==!0;)c=s.value,c.undirected===i&&(r[o++]=c.key);return r}function ke(e,t,n,r){if(t.size===0)return;let i=n!==`mixed`&&n!==t.type,a=n===`undirected`,o,s,c=!1,l=t._edges.values();for(;o=l.next(),o.done!==!0;){if(s=o.value,i&&s.undirected!==a)continue;let{key:t,attributes:n,source:l,target:u}=s;if(c=r(t,n,l.key,u.key,l.attributes,u.attributes,s.undirected),e&&c)return t}}function Ae(e,t){if(e.size===0)return f();let n=t!==`mixed`&&t!==e.type,r=t===`undirected`,i=e._edges.values();return{[Symbol.iterator](){return this},next(){let e,t;for(;;){if(e=i.next(),e.done)return e;if(t=e.value,!(n&&t.undirected!==r))break}return{value:{edge:t.key,attributes:t.attributes,source:t.source.key,target:t.target.key,sourceAttributes:t.source.attributes,targetAttributes:t.target.attributes,undirected:t.undirected},done:!1}}}}function je(e,t,n,r,i,a){let o=t?Ce:Se,s;if(n!==`undirected`&&(r!==`out`&&(s=o(e,i.in,a),e&&s)||r!==`in`&&(s=o(e,i.out,a,r?void 0:i.key),e&&s))||n!==`directed`&&(s=o(e,i.undirected,a),e&&s))return s}function Me(e,t,n,r){let i=[];return je(!1,e,t,n,r,function(e){i.push(e)}),i}function Ne(e,t,n){let r=f();return e!==`undirected`&&(t!==`out`&&n.in!==void 0&&(r=d(r,we(n.in))),t!==`in`&&n.out!==void 0&&(r=d(r,we(n.out,t?void 0:n.key)))),e!==`directed`&&n.undirected!==void 0&&(r=d(r,we(n.undirected))),r}function Pe(e,t,n,r,i,a,o){let s=n?Ee:Te,c;if(t!==`undirected`&&(i.in!==void 0&&r!==`out`&&(c=s(e,i.in,a,o),e&&c)||i.out!==void 0&&r!==`in`&&(r||i.key!==a)&&(c=s(e,i.out,a,o),e&&c))||t!==`directed`&&i.undirected!==void 0&&(c=s(e,i.undirected,a,o),e&&c))return c}function Fe(e,t,n,r,i){let a=[];return Pe(!1,e,t,n,r,i,function(e){a.push(e)}),a}function Ie(e,t,n,r){let i=f();return e!==`undirected`&&(n.in!==void 0&&t!==`out`&&r in n.in&&(i=d(i,De(n.in,r))),n.out!==void 0&&t!==`in`&&r in n.out&&(t||n.key!==r)&&(i=d(i,De(n.out,r)))),e!==`directed`&&n.undirected!==void 0&&r in n.undirected&&(i=d(i,De(n.undirected,r))),i}function Le(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return[];if(!arguments.length)return Oe(this,r);if(arguments.length===1){e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new h(`Graph.${n}: could not find the "${e}" node in the graph.`);return Me(this.multi,r===`mixed`?this.type:r,i,t)}if(arguments.length===2){e=``+e,t=``+t;let a=this._nodes.get(e);if(!a)throw new h(`Graph.${n}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.${n}: could not find the "${t}" target node in the graph.`);return Fe(r,this.multi,i,a,t)}throw new m(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Re(e,t){let{name:n,type:r,direction:i}=t,a=`forEach`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t,n){if(r===`mixed`||this.type===`mixed`||r===this.type){if(arguments.length===1)return n=e,ke(!1,this,r,n);if(arguments.length===2){e=``+e,n=t;let o=this._nodes.get(e);if(o===void 0)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);return je(!1,this.multi,r===`mixed`?this.type:r,i,o,n)}if(arguments.length===3){e=``+e,t=``+t;let o=this._nodes.get(e);if(!o)throw new h(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.${a}: could not find the "${t}" target node in the graph.`);return Pe(!1,r,this.multi,i,o,t,n)}throw new m(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};let o=`map`+n[0].toUpperCase()+n.slice(1);e.prototype[o]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop(),n;if(e.length===0){let i=0;r!==`directed`&&(i+=this.undirectedSize),r!==`undirected`&&(i+=this.directedSize),n=Array(i);let a=0;e.push((e,r,i,o,s,c,l)=>{n[a++]=t(e,r,i,o,s,c,l)})}else n=[],e.push((e,r,i,a,o,s,c)=>{n.push(t(e,r,i,a,o,s,c))});return this[a].apply(this,e),n};let s=`filter`+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop(),n=[];return e.push((e,r,i,a,o,s,c)=>{t(e,r,i,a,o,s,c)&&n.push(e)}),this[a].apply(this,e),n};let c=`reduce`+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(){let e=Array.prototype.slice.call(arguments);if(e.length<2||e.length>4)throw new m(`Graph.${c}: invalid number of arguments (expecting 2, 3 or 4 and got ${e.length}).`);if(typeof e[e.length-1]==`function`&&typeof e[e.length-2]!=`function`)throw new m(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let t,n;e.length===2?(t=e[0],n=e[1],e=[]):e.length===3?(t=e[1],n=e[2],e=[e[0]]):e.length===4&&(t=e[2],n=e[3],e=[e[0],e[1]]);let r=n;return e.push((e,n,i,a,o,s,c)=>{r=t(r,e,n,i,a,o,s,c)}),this[a].apply(this,e),r}}function ze(e,t){let{name:n,type:r,direction:i}=t,a=`find`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t,n){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return!1;if(arguments.length===1)return n=e,ke(!0,this,r,n);if(arguments.length===2){e=``+e,n=t;let o=this._nodes.get(e);if(o===void 0)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);return je(!0,this.multi,r===`mixed`?this.type:r,i,o,n)}if(arguments.length===3){e=``+e,t=``+t;let o=this._nodes.get(e);if(!o)throw new h(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.${a}: could not find the "${t}" target node in the graph.`);return Pe(!0,r,this.multi,i,o,t,n)}throw new m(`Graph.${a}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let o=`some`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((e,n,r,i,a,o,s)=>t(e,n,r,i,a,o,s)),!!this[a].apply(this,e)};let s=`every`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){let e=Array.prototype.slice.call(arguments),t=e.pop();return e.push((e,n,r,i,a,o,s)=>!t(e,n,r,i,a,o,s)),!this[a].apply(this,e)}}function Be(e,t){let{name:n,type:r,direction:i}=t,a=n.slice(0,-1)+`Entries`;e.prototype[a]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return f();if(!arguments.length)return Ae(this,r);if(arguments.length===1){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);return Ne(r,i,t)}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.${a}: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.${a}: could not find the "${t}" target node in the graph.`);return Ie(r,i,n,t)}throw new m(`Graph.${a}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Ve(e){xe.forEach(t=>{Le(e,t),Re(e,t),ze(e,t),Be(e,t)})}let He=[{name:`neighbors`,type:`mixed`},{name:`inNeighbors`,type:`directed`,direction:`in`},{name:`outNeighbors`,type:`directed`,direction:`out`},{name:`inboundNeighbors`,type:`mixed`,direction:`in`},{name:`outboundNeighbors`,type:`mixed`,direction:`out`},{name:`directedNeighbors`,type:`directed`},{name:`undirectedNeighbors`,type:`undirected`}];function Ue(){this.A=null,this.B=null}Ue.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)},Ue.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function We(e,t,n,r,i){for(let a in r){let o=r[a],s=o.source,c=o.target,l=s===n?c:s;if(t&&t.has(l.key))continue;let u=i(l.key,l.attributes);if(e&&u)return l.key}}function Ge(e,t,n,r,i){if(t!==`mixed`){if(t===`undirected`)return We(e,null,r,r.undirected,i);if(typeof n==`string`)return We(e,null,r,r[n],i)}let a=new Ue,o;if(t!==`undirected`){if(n!==`out`){if(o=We(e,null,r,r.in,i),e&&o)return o;a.wrap(r.in)}if(n!==`in`){if(o=We(e,a,r,r.out,i),e&&o)return o;a.wrap(r.out)}}if(t!==`directed`&&(o=We(e,a,r,r.undirected,i),e&&o))return o}function Ke(e,t,n){if(e!==`mixed`){if(e===`undirected`)return Object.keys(n.undirected);if(typeof t==`string`)return Object.keys(n[t])}let r=[];return Ge(!1,e,t,n,function(e){r.push(e)}),r}function qe(e,t,n){let r=Object.keys(n),i=r.length,a=0;return{[Symbol.iterator](){return this},next(){let o=null;do{if(a>=i)return e&&e.wrap(n),{done:!0};let s=n[r[a++]],c=s.source,l=s.target;o=c===t?l:c,e&&e.has(o.key)&&(o=null)}while(o===null);return{done:!1,value:{neighbor:o.key,attributes:o.attributes}}}}}function Je(e,t,n){if(e!==`mixed`){if(e===`undirected`)return qe(null,n,n.undirected);if(typeof t==`string`)return qe(null,n,n[t])}let r=f(),i=new Ue;return e!==`undirected`&&(t!==`out`&&(r=d(r,qe(i,n,n.in))),t!==`in`&&(r=d(r,qe(i,n,n.out)))),e!==`directed`&&(r=d(r,qe(i,n,n.undirected))),r}function Ye(e,t){let{name:n,type:r,direction:i}=t;e.prototype[n]=function(e){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return[];e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new h(`Graph.${n}: could not find the "${e}" node in the graph.`);return Ke(r===`mixed`?this.type:r,i,t)}}function Xe(e,t){let{name:n,type:r,direction:i}=t,a=`forEach`+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return;e=``+e;let n=this._nodes.get(e);if(n===void 0)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);Ge(!1,r===`mixed`?this.type:r,i,n,t)};let o=`map`+n[0].toUpperCase()+n.slice(1);e.prototype[o]=function(e,t){let n=[];return this[a](e,(e,r)=>{n.push(t(e,r))}),n};let s=`filter`+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(e,t){let n=[];return this[a](e,(e,r)=>{t(e,r)&&n.push(e)}),n};let c=`reduce`+n[0].toUpperCase()+n.slice(1);e.prototype[c]=function(e,t,n){if(arguments.length<3)throw new m(`Graph.${c}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let r=n;return this[a](e,(e,n)=>{r=t(r,e,n)}),r}}function Ze(e,t){let{name:n,type:r,direction:i}=t,a=n[0].toUpperCase()+n.slice(1,-1),o=`find`+a;e.prototype[o]=function(e,t){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return;e=``+e;let n=this._nodes.get(e);if(n===void 0)throw new h(`Graph.${o}: could not find the "${e}" node in the graph.`);return Ge(!0,r===`mixed`?this.type:r,i,n,t)};let s=`some`+a;e.prototype[s]=function(e,t){return!!this[o](e,t)};let c=`every`+a;e.prototype[c]=function(e,t){return!this[o](e,(e,n)=>!t(e,n))}}function Qe(e,t){let{name:n,type:r,direction:i}=t,a=n.slice(0,-1)+`Entries`;e.prototype[a]=function(e){if(r!==`mixed`&&this.type!==`mixed`&&r!==this.type)return f();e=``+e;let t=this._nodes.get(e);if(t===void 0)throw new h(`Graph.${a}: could not find the "${e}" node in the graph.`);return Je(r===`mixed`?this.type:r,i,t)}}function $e(e){He.forEach(t=>{Ye(e,t),Xe(e,t),Ze(e,t),Qe(e,t)})}function et(e,t,n,r,i){let a=r._nodes.values(),o=r.type,s,c,l,u,d,f,p;for(;s=a.next(),s.done!==!0;){let r=!1;if(c=s.value,o!==`undirected`)for(l in u=c.out,u){d=u[l];do{if(f=d.target,r=!0,p=i(c.key,f.key,c.attributes,f.attributes,d.key,d.attributes,d.undirected),e&&p)return d;d=d.next}while(d)}if(o!==`directed`){for(l in u=c.undirected,u)if(!(t&&c.key>l)){d=u[l];do{if(f=d.target,f.key!==l&&(f=d.source),r=!0,p=i(c.key,f.key,c.attributes,f.attributes,d.key,d.attributes,d.undirected),e&&p)return d;d=d.next}while(d)}}if(n&&!r&&(p=i(c.key,null,c.attributes,null,null,null,null),e&&p))return null}}function tt(e,t){let n={key:e};return o(t.attributes)||(n.attributes=r({},t.attributes)),n}function nt(e,t,n){let i={key:t,source:n.source.key,target:n.target.key};return o(n.attributes)||(i.attributes=r({},n.attributes)),e===`mixed`&&n.undirected&&(i.undirected=!0),i}function rt(e){if(!a(e))throw new m(`Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.`);if(!(`key`in e))throw new m(`Graph.import: serialized node is missing its key.`);if(`attributes`in e&&(!a(e.attributes)||e.attributes===null))throw new m(`Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.`)}function it(e){if(!a(e))throw new m(`Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.`);if(!(`source`in e))throw new m(`Graph.import: serialized edge is missing its source.`);if(!(`target`in e))throw new m(`Graph.import: serialized edge is missing its target.`);if(`attributes`in e&&(!a(e.attributes)||e.attributes===null))throw new m(`Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.`);if(`undirected`in e&&typeof e.undirected!=`boolean`)throw new m(`Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.`)}let at=u(),ot=/* @__PURE__ */ new Set([`directed`,`undirected`,`mixed`]),st=/* @__PURE__ */ new Set([`domain`,`_events`,`_eventsCount`,`_maxListeners`]),ct=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:`directed`},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:`undirected`},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:`directed`},{name:e=>`${e}UndirectedEdgeWithKey`,type:`undirected`}],lt={allowSelfLoops:!0,multi:!1,type:`mixed`};function ut(e,t,n){if(n&&!a(n))throw new m(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=``+t,n||={},e._nodes.has(t))throw new g(`Graph.addNode: the "${t}" node already exist in the graph.`);let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit(`nodeAdded`,{key:t,attributes:n}),r}function dt(e,t,n){let r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit(`nodeAdded`,{key:t,attributes:n}),r}function ft(e,t,n,r,i,o,s,c){if(!r&&e.type===`undirected`)throw new g(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&e.type===`directed`)throw new g(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(c&&!a(c))throw new m(`Graph.${t}: invalid attributes. Expecting an object but got "${c}"`);if(o=``+o,s=``+s,c||={},!e.allowSelfLoops&&o===s)throw new g(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(o),u=e._nodes.get(s);if(!l)throw new h(`Graph.${t}: source node "${o}" not found.`);if(!u)throw new h(`Graph.${t}: target node "${s}" not found.`);let d={key:null,undirected:r,source:o,target:s,attributes:c};if(n)i=e._edgeKeyGenerator();else if(i=``+i,e._edges.has(i))throw new g(`Graph.${t}: the "${i}" edge already exists in the graph.`);if(!e.multi&&(r?l.undirected[s]!==void 0:l.out[s]!==void 0))throw new g(`Graph.${t}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);let f=new b(r,i,l,u,c);e._edges.set(i,f);let p=o===s;return r?(l.undirectedDegree++,u.undirectedDegree++,p&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,u.inDegree++,p&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?f.attachMulti():f.attach(),r?e._undirectedSize++:e._directedSize++,d.key=i,e.emit(`edgeAdded`,d),i}function pt(e,t,n,i,o,s,c,l,u){if(!i&&e.type===`undirected`)throw new g(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(i&&e.type===`directed`)throw new g(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(l){if(u){if(typeof l!=`function`)throw new m(`Graph.${t}: invalid updater function. Expecting a function but got "${l}"`)}else if(!a(l))throw new m(`Graph.${t}: invalid attributes. Expecting an object but got "${l}"`)}s=``+s,c=``+c;let d;if(u&&(d=l,l=void 0),!e.allowSelfLoops&&s===c)throw new g(`Graph.${t}: source & target are the same ("${s}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let f=e._nodes.get(s),p=e._nodes.get(c),h,_;if(!n&&(h=e._edges.get(o),h)){if((h.source.key!==s||h.target.key!==c)&&(!i||h.source.key!==c||h.target.key!==s))throw new g(`Graph.${t}: inconsistency detected when attempting to merge the "${o}" edge with "${s}" source & "${c}" target vs. ("${h.source.key}", "${h.target.key}").`);_=h}if(!_&&!e.multi&&f&&(_=i?f.undirected[c]:f.out[c]),_){let t=[_.key,!1,!1,!1];if(u?!d:!l)return t;if(u){let t=_.attributes;_.attributes=d(t),e.emit(`edgeAttributesUpdated`,{type:`replace`,key:_.key,attributes:_.attributes})}else r(_.attributes,l),e.emit(`edgeAttributesUpdated`,{type:`merge`,key:_.key,attributes:_.attributes,data:l});return t}l||={},u&&d&&(l=d(l));let v={key:null,undirected:i,source:s,target:c,attributes:l};if(n)o=e._edgeKeyGenerator();else if(o=``+o,e._edges.has(o))throw new g(`Graph.${t}: the "${o}" edge already exists in the graph.`);let y=!1,x=!1;f||(f=dt(e,s,{}),y=!0,s===c&&(p=f,x=!0)),p||(p=dt(e,c,{}),x=!0),h=new b(i,o,f,p,l),e._edges.set(o,h);let ee=s===c;return i?(f.undirectedDegree++,p.undirectedDegree++,ee&&(f.undirectedLoops++,e._undirectedSelfLoopCount++)):(f.outDegree++,p.inDegree++,ee&&(f.directedLoops++,e._directedSelfLoopCount++)),e.multi?h.attachMulti():h.attach(),i?e._undirectedSize++:e._directedSize++,v.key=o,e.emit(`edgeAdded`,v),[o,!0,y,x]}function mt(e,t){e._edges.delete(t.key);let{source:n,target:r,attributes:i}=t,a=t.undirected,o=n===r;a?(n.undirectedDegree--,r.undirectedDegree--,o&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,o&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),a?e._undirectedSize--:e._directedSize--,e.emit(`edgeDropped`,{key:t.key,attributes:i,source:n.key,target:r.key,undirected:a})}var C=class e extends t.EventEmitter{constructor(e){if(super(),e=r({},lt,e),typeof e.multi!=`boolean`)throw new m(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!ot.has(e.type))throw new m(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!=`boolean`)throw new m(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let t=e.type===`mixed`?_:e.type===`directed`?v:y;s(this,`NodeDataClass`,t);let n=`geid_`+at()+`_`,i=0;s(this,`_attributes`,{}),s(this,`_nodes`,/* @__PURE__ */ new Map),s(this,`_edges`,/* @__PURE__ */ new Map),s(this,`_directedSize`,0),s(this,`_undirectedSize`,0),s(this,`_directedSelfLoopCount`,0),s(this,`_undirectedSelfLoopCount`,0),s(this,`_edgeKeyGenerator`,()=>{let e;do e=n+i++;while(this._edges.has(e));return e}),s(this,`_options`,e),st.forEach(e=>s(this,e,this[e])),c(this,`order`,()=>this._nodes.size),c(this,`size`,()=>this._edges.size),c(this,`directedSize`,()=>this._directedSize),c(this,`undirectedSize`,()=>this._undirectedSize),c(this,`selfLoopCount`,()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),c(this,`directedSelfLoopCount`,()=>this._directedSelfLoopCount),c(this,`undirectedSelfLoopCount`,()=>this._undirectedSelfLoopCount),c(this,`multi`,this._options.multi),c(this,`type`,this._options.type),c(this,`allowSelfLoops`,this._options.allowSelfLoops),c(this,`implementation`,()=>`graphology`)}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(e){return this._nodes.has(``+e)}hasDirectedEdge(e,t){if(this.type===`undirected`)return!1;if(arguments.length===1){let t=``+e,n=this._edges.get(t);return!!n&&!n.undirected}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.out.hasOwnProperty(t):!1}throw new m(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(e,t){if(this.type===`directed`)return!1;if(arguments.length===1){let t=``+e,n=this._edges.get(t);return!!n&&n.undirected}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.undirected.hasOwnProperty(t):!1}throw new m(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(e,t){if(arguments.length===1){let t=``+e;return this._edges.has(t)}if(arguments.length===2){e=``+e,t=``+t;let n=this._nodes.get(e);return n?n.out!==void 0&&n.out.hasOwnProperty(t)||n.undirected!==void 0&&n.undirected.hasOwnProperty(t):!1}throw new m(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(e,t){if(this.type===`undirected`)return;if(e=``+e,t=``+t,this.multi)throw new g(`Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.`);let n=this._nodes.get(e);if(!n)throw new h(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.directedEdge: could not find the "${t}" target node in the graph.`);let r=n.out&&n.out[t]||void 0;if(r)return r.key}undirectedEdge(e,t){if(this.type===`directed`)return;if(e=``+e,t=``+t,this.multi)throw new g(`Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.`);let n=this._nodes.get(e);if(!n)throw new h(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.undirectedEdge: could not find the "${t}" target node in the graph.`);let r=n.undirected&&n.undirected[t]||void 0;if(r)return r.key}edge(e,t){if(this.multi)throw new g(`Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.`);e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new h(`Graph.edge: could not find the "${t}" target node in the graph.`);let r=n.out&&n.out[t]||n.undirected&&n.undirected[t]||void 0;if(r)return r.key}areDirectedNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type===`undirected`?!1:t in n.in||t in n.out}areOutNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.out}areInNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.in}areUndirectedNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`directed`&&t in n.undirected}areNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&(t in n.in||t in n.out)||this.type!==`directed`&&t in n.undirected}areInboundNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.in||this.type!==`directed`&&t in n.undirected}areOutboundNeighbors(e,t){e=``+e,t=``+t;let n=this._nodes.get(e);if(!n)throw new h(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);return this.type!==`undirected`&&t in n.out||this.type!==`directed`&&t in n.undirected}inDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.inDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree}outDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.outDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.outDegree}directedDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.directedDegree: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree+t.outDegree}undirectedDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);return this.type===`directed`?0:t.undirectedDegree}inboundDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.inDegree),n}outboundDegree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.outDegree),n}degree(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;return this.type!==`directed`&&(n+=t.undirectedDegree),this.type!==`undirected`&&(n+=t.inDegree+t.outDegree),n}inDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`undirected`?0:t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);return this.type===`directed`?0:t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.inDegree,r+=t.directedLoops),n-r}outboundDegreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.outDegree,r+=t.directedLoops),n-r}degreeWithoutSelfLoops(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;return this.type!==`directed`&&(n+=t.undirectedDegree,r+=t.undirectedLoops*2),this.type!==`undirected`&&(n+=t.inDegree+t.outDegree,r+=t.directedLoops*2),n-r}source(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.source: could not find the "${e}" edge in the graph.`);return t.source.key}target(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.target: could not find the "${e}" edge in the graph.`);return t.target.key}extremities(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.extremities: could not find the "${e}" edge in the graph.`);return[t.source.key,t.target.key]}opposite(e,t){e=``+e,t=``+t;let n=this._edges.get(t);if(!n)throw new h(`Graph.opposite: could not find the "${t}" edge in the graph.`);let r=n.source.key,i=n.target.key;if(e===r)return i;if(e===i)return r;throw new h(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${r}, ${i}).`)}hasExtremity(e,t){e=``+e,t=``+t;let n=this._edges.get(e);if(!n)throw new h(`Graph.hasExtremity: could not find the "${e}" edge in the graph.`);return n.source.key===t||n.target.key===t}isUndirected(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.isUndirected: could not find the "${e}" edge in the graph.`);return t.undirected}isDirected(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.isDirected: could not find the "${e}" edge in the graph.`);return!t.undirected}isSelfLoop(e){e=``+e;let t=this._edges.get(e);if(!t)throw new h(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return ut(this,e,t).key}mergeNode(e,t){if(t&&!a(t))throw new m(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=``+e,t||={};let n=this._nodes.get(e);return n?(t&&(r(n.attributes,t),this.emit(`nodeAttributesUpdated`,{type:`merge`,key:e,attributes:n.attributes,data:t})),[e,!1]):(n=new this.NodeDataClass(e,t),this._nodes.set(e,n),this.emit(`nodeAdded`,{key:e,attributes:t}),[e,!0])}updateNode(e,t){if(t&&typeof t!=`function`)throw new m(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=``+e;let n=this._nodes.get(e);if(n){if(t){let r=n.attributes;n.attributes=t(r),this.emit(`nodeAttributesUpdated`,{type:`replace`,key:e,attributes:n.attributes})}return[e,!1]}let r=t?t({}):{};return n=new this.NodeDataClass(e,r),this._nodes.set(e,n),this.emit(`nodeAdded`,{key:e,attributes:r}),[e,!0]}dropNode(e){e=``+e;let t=this._nodes.get(e);if(!t)throw new h(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!==`undirected`){for(let e in t.out){n=t.out[e];do mt(this,n),n=n.next;while(n)}for(let e in t.in){n=t.in[e];do mt(this,n),n=n.next;while(n)}}if(this.type!==`directed`)for(let e in t.undirected){n=t.undirected[e];do mt(this,n),n=n.next;while(n)}this._nodes.delete(e),this.emit(`nodeDropped`,{key:e,attributes:t.attributes})}dropEdge(e){let t;if(arguments.length>1){let e=``+arguments[0],n=``+arguments[1];if(t=i(this,e,n,this.type),!t)throw new h(`Graph.dropEdge: could not find the "${e}" -> "${n}" edge in the graph.`)}else if(e=``+e,t=this._edges.get(e),!t)throw new h(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return mt(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new g(`Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.`);if(this.multi)throw new g(`Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.`);e=``+e,t=``+t;let n=i(this,e,t,`directed`);if(!n)throw new h(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return mt(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new g(`Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.`);if(this.multi)throw new g(`Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.`);let n=i(this,e,t,`undirected`);if(!n)throw new h(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return mt(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit(`cleared`)}clearEdges(){let e=this._nodes.values(),t;for(;t=e.next(),t.done!==!0;)t.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit(`edgesCleared`)}getAttribute(e){return this._attributes[e]}getAttributes(){return this._attributes}hasAttribute(e){return this._attributes.hasOwnProperty(e)}setAttribute(e,t){return this._attributes[e]=t,this.emit(`attributesUpdated`,{type:`set`,attributes:this._attributes,name:e}),this}updateAttribute(e,t){if(typeof t!=`function`)throw new m(`Graph.updateAttribute: updater should be a function.`);let n=this._attributes[e];return this._attributes[e]=t(n),this.emit(`attributesUpdated`,{type:`set`,attributes:this._attributes,name:e}),this}removeAttribute(e){return delete this._attributes[e],this.emit(`attributesUpdated`,{type:`remove`,attributes:this._attributes,name:e}),this}replaceAttributes(e){if(!a(e))throw new m(`Graph.replaceAttributes: provided attributes are not a plain object.`);return this._attributes=e,this.emit(`attributesUpdated`,{type:`replace`,attributes:this._attributes}),this}mergeAttributes(e){if(!a(e))throw new m(`Graph.mergeAttributes: provided attributes are not a plain object.`);return r(this._attributes,e),this.emit(`attributesUpdated`,{type:`merge`,attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!=`function`)throw new m(`Graph.updateAttributes: provided updater is not a function.`);return this._attributes=e(this._attributes),this.emit(`attributesUpdated`,{type:`update`,attributes:this._attributes}),this}updateEachNodeAttributes(e,t){if(typeof e!=`function`)throw new m(`Graph.updateEachNodeAttributes: expecting an updater function.`);if(t&&!l(t))throw new m(`Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}`);let n=this._nodes.values(),r,i;for(;r=n.next(),r.done!==!0;)i=r.value,i.attributes=e(i.key,i.attributes);this.emit(`eachNodeAttributesUpdated`,{hints:t||null})}updateEachEdgeAttributes(e,t){if(typeof e!=`function`)throw new m(`Graph.updateEachEdgeAttributes: expecting an updater function.`);if(t&&!l(t))throw new m(`Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}`);let n=this._edges.values(),r,i,a,o;for(;r=n.next(),r.done!==!0;)i=r.value,a=i.source,o=i.target,i.attributes=e(i.key,i.attributes,a.key,o.key,a.attributes,o.attributes,i.undirected);this.emit(`eachEdgeAttributesUpdated`,{hints:t||null})}forEachAdjacencyEntry(e){if(typeof e!=`function`)throw new m(`Graph.forEachAdjacencyEntry: expecting a callback.`);et(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!=`function`)throw new m(`Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.`);et(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!=`function`)throw new m(`Graph.forEachAssymetricAdjacencyEntry: expecting a callback.`);et(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!=`function`)throw new m(`Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.`);et(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!=`function`)throw new m(`Graph.forEachNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)r=n.value,e(r.key,r.attributes)}findNode(e){if(typeof e!=`function`)throw new m(`Graph.findNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,e(r.key,r.attributes))return r.key}mapNodes(e){if(typeof e!=`function`)throw new m(`Graph.mapNode: expecting a callback.`);let t=this._nodes.values(),n,r,i=Array(this.order),a=0;for(;n=t.next(),n.done!==!0;)r=n.value,i[a++]=e(r.key,r.attributes);return i}someNode(e){if(typeof e!=`function`)throw new m(`Graph.someNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,e(r.key,r.attributes))return!0;return!1}everyNode(e){if(typeof e!=`function`)throw new m(`Graph.everyNode: expecting a callback.`);let t=this._nodes.values(),n,r;for(;n=t.next(),n.done!==!0;)if(r=n.value,!e(r.key,r.attributes))return!1;return!0}filterNodes(e){if(typeof e!=`function`)throw new m(`Graph.filterNodes: expecting a callback.`);let t=this._nodes.values(),n,r,i=[];for(;n=t.next(),n.done!==!0;)r=n.value,e(r.key,r.attributes)&&i.push(r.key);return i}reduceNodes(e,t){if(typeof e!=`function`)throw new m(`Graph.reduceNodes: expecting a callback.`);if(arguments.length<2)throw new m(`Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let n=t,r=this._nodes.values(),i,a;for(;i=r.next(),i.done!==!0;)a=i.value,n=e(n,a.key,a.attributes);return n}nodeEntries(){let e=this._nodes.values();return{[Symbol.iterator](){return this},next(){let t=e.next();if(t.done)return t;let n=t.value;return{value:{node:n.key,attributes:n.attributes},done:!1}}}}export(){let e=Array(this._nodes.size),t=0;this._nodes.forEach((n,r)=>{e[t++]=tt(r,n)});let n=Array(this._edges.size);return t=0,this._edges.forEach((e,r)=>{n[t++]=nt(this.type,r,e)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(t,n=!1){if(t instanceof e)return t.forEachNode((e,t)=>{n?this.mergeNode(e,t):this.addNode(e,t)}),t.forEachEdge((e,t,r,i,a,o,s)=>{n?s?this.mergeUndirectedEdgeWithKey(e,r,i,t):this.mergeDirectedEdgeWithKey(e,r,i,t):s?this.addUndirectedEdgeWithKey(e,r,i,t):this.addDirectedEdgeWithKey(e,r,i,t)}),this;if(!a(t))throw new m(`Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.`);if(t.attributes){if(!a(t.attributes))throw new m(`Graph.import: invalid attributes. Expecting a plain object.`);n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,i,o,s,c;if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new m(`Graph.import: invalid nodes. Expecting an array.`);for(r=0,i=o.length;r<i;r++){s=o[r],rt(s);let{key:e,attributes:t}=s;n?this.mergeNode(e,t):this.addNode(e,t)}}if(t.edges){let e=!1;if(this.type===`undirected`&&(e=!0),o=t.edges,!Array.isArray(o))throw new m(`Graph.import: invalid edges. Expecting an array.`);for(r=0,i=o.length;r<i;r++){c=o[r],it(c);let{source:t,target:i,attributes:a,undirected:s=e}=c,l;`key`in c?(l=n?s?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:s?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,l.call(this,c.key,t,i,a)):(l=n?s?this.mergeUndirectedEdge:this.mergeDirectedEdge:s?this.addUndirectedEdge:this.addDirectedEdge,l.call(this,t,i,a))}}return this}nullCopy(t){let n=new e(r({},this._options,t));return n.replaceAttributes(r({},this.getAttributes())),n}emptyCopy(e){let t=this.nullCopy(e);return this._nodes.forEach((e,n)=>{let i=r({},e.attributes);e=new t.NodeDataClass(n,i),t._nodes.set(n,e)}),t}copy(e){if(e||={},typeof e.type==`string`&&e.type!==this.type&&e.type!==`mixed`)throw new g(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${e.type}" because this would mean losing information about the current graph.`);if(typeof e.multi==`boolean`&&e.multi!==this.multi&&e.multi!==!0)throw new g(`Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.`);if(typeof e.allowSelfLoops==`boolean`&&e.allowSelfLoops!==this.allowSelfLoops&&e.allowSelfLoops!==!0)throw new g(`Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.`);let t=this.emptyCopy(e),n=this._edges.values(),i,a;for(;i=n.next(),i.done!==!0;)a=i.value,ft(t,`copy`,!1,a.undirected,a.key,a.source.key,a.target.key,r({},a.attributes));return t}toJSON(){return this.export()}toString(){return`[object Graph]`}inspect(){let e={};this._nodes.forEach((t,n)=>{e[n]=t.attributes});let t={},n={};this._edges.forEach((e,r)=>{let i=e.undirected?`--`:`->`,a=``,o=e.source.key,s=e.target.key,c;e.undirected&&o>s&&(c=o,o=s,s=c);let l=`(${o})${i}(${s})`;r.startsWith(`geid_`)?this.multi&&(n[l]===void 0?n[l]=0:n[l]++,a+=`${n[l]}. `):a+=`[${r}]: `,a+=l,t[a]=e.attributes});let r={};for(let e in this)this.hasOwnProperty(e)&&!st.has(e)&&typeof this[e]!=`function`&&typeof e!=`symbol`&&(r[e]=this[e]);return r.attributes=this._attributes,r.nodes=e,r.edges=t,s(r,`constructor`,this.constructor),r}};typeof Symbol<`u`&&(C.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=C.prototype.inspect),ct.forEach(e=>{[`add`,`merge`,`update`].forEach(t=>{let n=e.name(t),r=t===`add`?ft:pt;e.generateKey?C.prototype[n]=function(i,a,o){return r(this,n,!0,(e.type||this.type)===`undirected`,null,i,a,o,t===`update`)}:C.prototype[n]=function(i,a,o,s){return r(this,n,!1,(e.type||this.type)===`undirected`,i,a,o,s,t===`update`)}})}),le(C),be(C),Ve(C),$e(C);var ht=class extends C{constructor(e){let t=r({type:`directed`},e);if(`multi`in t&&t.multi!==!1)throw new m(`DirectedGraph.from: inconsistent indication that the graph should be multi in given options!`);if(t.type!==`directed`)throw new m(`DirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},gt=class extends C{constructor(e){let t=r({type:`undirected`},e);if(`multi`in t&&t.multi!==!1)throw new m(`UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!`);if(t.type!==`undirected`)throw new m(`UndirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},_t=class extends C{constructor(e){let t=r({multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new m(`MultiGraph.from: inconsistent indication that the graph should be simple in given options!`);super(t)}},vt=class extends C{constructor(e){let t=r({type:`directed`,multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new m(`MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!`);if(t.type!==`directed`)throw new m(`MultiDirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}},yt=class extends C{constructor(e){let t=r({type:`undirected`,multi:!0},e);if(`multi`in t&&t.multi!==!0)throw new m(`MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!`);if(t.type!==`undirected`)throw new m(`MultiUndirectedGraph.from: inconsistent "`+t.type+`" type in given options!`);super(t)}};function bt(e){e.from=function(t,n){let i=new e(r({},t.options,n));return i.import(t),i}}bt(C),bt(ht),bt(gt),bt(_t),bt(vt),bt(yt),C.Graph=C,C.DirectedGraph=ht,C.UndirectedGraph=gt,C.MultiGraph=_t,C.MultiDirectedGraph=vt,C.MultiUndirectedGraph=yt,C.InvalidArgumentsGraphError=m,C.NotFoundGraphError=h,C.UsageGraphError=g;var xt=/* @__PURE__ */ e(((e,t)=>{t.exports=function(e){return typeof e==`object`&&!!e&&typeof e.addUndirectedEdgeWithKey==`function`&&typeof e.dropNode==`function`&&typeof e.multi==`boolean`}})),St=/* @__PURE__ */ e(((e,t)=>{let n=xt();t.exports=function(e){if(!n(e))throw Error(`graphology-dag/has-cycle: the given graph is not a valid graphology instance.`);if(e.size===0)return!1;if(e.selfLoopCount!==0)return!0;let t={},r=[];function i(e){let n=t[e];if(n===void 0)r.push(e);else if(n===0)return!0;return!1}return e.someNode(n=>{if(t[n]===1)return!1;for(r.push(n);r.length!==0;){let n=r[r.length-1],a=t[n];if(a!==0){if(t[n]=0,e.someOutboundNeighbor(n,i))return!0}else a===0&&(r.pop(),t[n]=1)}return!1})}})),Ct=/* @__PURE__ */ e(((e,t)=>{let n=xt();t.exports=function(e,t,r){if(!n(e))throw Error(`graphology-dag/will-create-cycle: the given graph is not a valid graphology instance.`);if(t=``+t,r=``+r,t===r)return!0;if(!e.hasNode(t)||!e.hasNode(r)||e.hasDirectedEdge(t,r))return!1;if(e.hasDirectedEdge(r,t))return!0;let i=e.outNeighbors(r);function a(e){i.push(e)}for(;i.length!==0;){let n=i.pop();if(n===t)return!0;e.forEachOutNeighbor(n,a)}return!1}})),wt=/* @__PURE__ */ e((e=>{e.ARRAY_BUFFER_SUPPORT=typeof ArrayBuffer<`u`,e.SYMBOL_SUPPORT=typeof Symbol<`u`})),Tt=/* @__PURE__ */ e(((e,t)=>{var n=wt(),r=n.ARRAY_BUFFER_SUPPORT,i=n.SYMBOL_SUPPORT;t.exports=function(e,t){var n,a,o,s,c;if(!e)throw Error(`obliterator/forEach: invalid iterable.`);if(typeof t!=`function`)throw Error(`obliterator/forEach: expecting a callback.`);if(Array.isArray(e)||r&&ArrayBuffer.isView(e)||typeof e==`string`||e.toString()===`[object Arguments]`)for(o=0,s=e.length;o<s;o++)t(e[o],o);else if(typeof e.forEach==`function`)e.forEach(t);else if(i&&Symbol.iterator in e&&typeof e.next!=`function`&&(e=e[Symbol.iterator]()),typeof e.next==`function`)for(n=e,o=0;c=n.next(),c.done!==!0;)t(c.value,o),o++;else for(a in e)e.hasOwnProperty(a)&&t(e[a],a)}})),Et=/* @__PURE__ */ e((e=>{var t=2**16-1,n=2**32-1,r=127,i=2**15-1,a=2**31-1;e.getPointerArray=function(e){var r=e-1;if(r<=255)return Uint8Array;if(r<=t)return Uint16Array;if(r<=n)return Uint32Array;throw Error(`mnemonist: Pointer Array of size > 4294967295 is not supported.`)},e.getSignedPointerArray=function(e){var t=e-1;return t<=r?Int8Array:t<=i?Int16Array:t<=a?Int32Array:Float64Array},e.getNumberType=function(e){return e===(e|0)?Math.sign(e)===-1?e<=127&&e>=-128?Int8Array:e<=32767&&e>=-32768?Int16Array:Int32Array:e<=255?Uint8Array:e<=65535?Uint16Array:Uint32Array:Float64Array};var o={Uint8Array:1,Int8Array:2,Uint16Array:3,Int16Array:4,Uint32Array:5,Int32Array:6,Float32Array:7,Float64Array:8};e.getMinimalRepresentation=function(t,n){for(var r=null,i=0,a,s,c,l=0,u=t.length;l<u;l++)c=n?n(t[l]):t[l],s=e.getNumberType(c),a=o[s.name],a>i&&(i=a,r=s);return r},e.isTypedArray=function(e){return typeof ArrayBuffer<`u`&&ArrayBuffer.isView(e)},e.concat=function(){for(var e=0,t=0,n,r=arguments.length;t<r;t++)e+=arguments[t].length;var i=new arguments[0].constructor(e);for(t=0,n=0;t<r;t++)i.set(arguments[t],n),n+=arguments[t].length;return i},e.indices=function(t){for(var n=new(e.getPointerArray(t))(t),r=0;r<t;r++)n[r]=r;return n}})),Dt=/* @__PURE__ */ e((e=>{var t=Tt(),n=Et();function r(e){return Array.isArray(e)||n.isTypedArray(e)}function i(e){if(typeof e.length==`number`)return e.length;if(typeof e.size==`number`)return e.size}function a(e){var n=i(e),r=typeof n==`number`?Array(n):[],a=0;return t(e,function(e){r[a++]=e}),r}function o(e){var r=i(e),a=typeof r==`number`?n.getPointerArray(r):Array,o=typeof r==`number`?Array(r):[],s=typeof r==`number`?new a(r):[],c=0;return t(e,function(e){o[c]=e,s[c]=c++}),[o,s]}e.isArrayLike=r,e.guessLength=i,e.toArray=a,e.toArrayWithIndices=o})),Ot=/* @__PURE__ */ e(((e,t)=>{function n(e){if(typeof e!=`function`)throw Error(`obliterator/iterator: expecting a function!`);this.next=e}typeof Symbol<`u`&&(n.prototype[Symbol.iterator]=function(){return this}),n.of=function(){var e=arguments,t=e.length,r=0;return new n(function(){return r>=t?{done:!0}:{done:!1,value:e[r++]}})},n.empty=function(){return new n(function(){return{done:!0}})},n.fromSequence=function(e){var t=0,r=e.length;return new n(function(){return t>=r?{done:!0}:{done:!1,value:e[t++]}})},n.is=function(e){return e instanceof n||typeof e==`object`&&!!e&&typeof e.next==`function`},t.exports=n})),kt=/* @__PURE__ */ e(((e,t)=>{var n=Dt(),r=Ot();function i(e,t){if(arguments.length<2)throw Error(`mnemonist/fixed-deque: expecting an Array class and a capacity.`);if(typeof t!=`number`||t<=0)throw Error("mnemonist/fixed-deque: `capacity` should be a positive number.");this.ArrayClass=e,this.capacity=t,this.items=new e(this.capacity),this.clear()}i.prototype.clear=function(){this.start=0,this.size=0},i.prototype.push=function(e){if(this.size===this.capacity)throw Error(`mnemonist/fixed-deque.push: deque capacity (`+this.capacity+`) exceeded!`);var t=this.start+this.size;return t>=this.capacity&&(t-=this.capacity),this.items[t]=e,++this.size},i.prototype.unshift=function(e){if(this.size===this.capacity)throw Error(`mnemonist/fixed-deque.unshift: deque capacity (`+this.capacity+`) exceeded!`);var t=this.start-1;return this.start===0&&(t=this.capacity-1),this.items[t]=e,this.start=t,++this.size},i.prototype.pop=function(){if(this.size!==0){this.size--;var e=this.start+this.size;return e>=this.capacity&&(e-=this.capacity),this.items[e]}},i.prototype.shift=function(){if(this.size!==0){var e=this.start;return this.size--,this.start++,this.start===this.capacity&&(this.start=0),this.items[e]}},i.prototype.peekFirst=function(){if(this.size!==0)return this.items[this.start]},i.prototype.peekLast=function(){if(this.size!==0){var e=this.start+this.size-1;return e>=this.capacity&&(e-=this.capacity),this.items[e]}},i.prototype.get=function(e){if(!(this.size===0||e>=this.capacity))return e=this.start+e,e>=this.capacity&&(e-=this.capacity),this.items[e]},i.prototype.forEach=function(e,t){t=arguments.length>1?t:this;for(var n=this.capacity,r=this.size,i=this.start,a=0;a<r;)e.call(t,this.items[i],a,this),i++,a++,i===n&&(i=0)},i.prototype.toArray=function(){var e=this.start+this.size;if(e<this.capacity)return this.items.slice(this.start,e);for(var t=new this.ArrayClass(this.size),n=this.capacity,r=this.size,i=this.start,a=0;a<r;)t[a]=this.items[i],i++,a++,i===n&&(i=0);return t},i.prototype.values=function(){var e=this.items,t=this.capacity,n=this.size,i=this.start,a=0;return new r(function(){if(a>=n)return{done:!0};var r=e[i];return i++,a++,i===t&&(i=0),{value:r,done:!1}})},i.prototype.entries=function(){var e=this.items,t=this.capacity,n=this.size,i=this.start,a=0;return new r(function(){if(a>=n)return{done:!0};var r=e[i];return i++,i===t&&(i=0),{value:[a++,r],done:!1}})},typeof Symbol<`u`&&(i.prototype[Symbol.iterator]=i.prototype.values),i.prototype.inspect=function(){var e=this.toArray();return e.type=this.ArrayClass.name,e.capacity=this.capacity,Object.defineProperty(e,"constructor",{value:i,enumerable:!1}),e},typeof Symbol<`u`&&(i.prototype[Symbol.for(`nodejs.util.inspect.custom`)]=i.prototype.inspect),i.from=function(e,t,r){if(arguments.length<3&&(r=n.guessLength(e),typeof r!=`number`))throw Error(`mnemonist/fixed-deque.from: could not guess iterable length. Please provide desired capacity as last argument.`);var a=new i(t,r);if(n.isArrayLike(e)){for(var o=0,s=e.length;o<s;o++)a.items[o]=e[o];return a.size=s,a}return n.forEach(e,function(e){a.push(e)}),a},t.exports=i})),At=/* @__PURE__ */ e((e=>{let t=xt(),n=kt();function r(e,t){let n=0;return e.forEachInNeighbor(t,()=>{n++}),n}function i(e,i){if(!t(e))throw Error(`graphology-dag/topological-sort: the given graph is not a valid graphology instance.`);if(e.type===`undirected`||e.undirectedSize!==0)throw Error(`graphology-dag/topological-sort: cannot work if graph is not directed.`);if(e.order===0)return;let a=new n(Array,e.order),o={},s=0;e.forEachNode((t,n)=>{let i=e.multi?r(e,t):e.inDegree(t);i===0?a.push([t,n,0]):(o[t]=i,s+=i)});let c=0;function l(e,t){let n=--o[e];s--,n===0&&a.push([e,t,c+1]),o[e]=n}for(;a.size!==0;){let[t,n,r]=a.shift();c=r,i(t,n,r),e.forEachOutNeighbor(t,l)}if(s!==0)throw Error(`graphology-dag/topological-sort: given graph is not acyclic.`)}function a(e){if(!t(e))throw Error(`graphology-dag/topological-sort: the given graph is not a valid graphology instance.`);let n=Array(e.order),r=0;return i(e,e=>{n[r++]=e}),n}function o(e,n){if(!t(e))throw Error(`graphology-dag/topological-generations: the given graph is not a valid graphology instance.`);if(e.order===0)return;let r=0,a=[];i(e,(e,t,i)=>{i>r&&(n(a),r=i,a=[]),a.push(e)}),n(a)}function s(e){if(!t(e))throw Error(`graphology-dag/topological-generations: the given graph is not a valid graphology instance.`);let n=[];return o(e,e=>{n.push(e)}),n}e.topologicalSort=a,e.forEachNodeInTopologicalOrder=i,e.topologicalGenerations=s,e.forEachTopologicalGeneration=o})),jt=(/* @__PURE__ */ e((e=>{e.hasCycle=St(),e.willCreateCycle=Ct();let t=At();e.forEachNodeInTopologicalOrder=t.forEachNodeInTopologicalOrder,e.topologicalSort=t.topologicalSort,e.topologicalGenerations=t.topologicalGenerations,e.forEachTopologicalGeneration=t.forEachTopologicalGeneration})))();function w(e,t){if(Object.prototype.hasOwnProperty.call(e,t))return Object.getOwnPropertyDescriptor(e,t)?.value}function Mt(e,t,n){Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})}function Nt(e){return Object.fromEntries(e)}function Pt(e,t,n=1){let r=e.get(t)??0;e.set(t,r+n)}function Ft(e){let t=e.metadata;if(!t||!t.dbt_schema_version)return null;let n=t.dbt_schema_version.match(/\/manifest\/v(\d+)\.json$/);return n?parseInt(n[1],10):null}function It(e){return e.metadata?.dbt_version||null}function Lt(e){let t=Ft(e);return t!==null&&t>=10}function Rt(e){return{schema_version:Ft(e),dbt_version:It(e),is_supported:Lt(e)}}function zt(e){return e.metrics}function Bt(e){return e.semantic_models}function Vt(e){return e.unit_tests}var Ht=class{constructor(e){if(this.relationMap=/* @__PURE__ */ new Map,!Lt(e)){let t=Rt(e);throw Error(`Unsupported dbt version. Schema version: ${t.schema_version||`unknown`}, dbt version: ${t.dbt_version||`unknown`}. Requires dbt 1.10+ (manifest schema v10+)`)}this.graph=new ht,this.buildGraph(e)}buildGraph(e){this.addNodes(e),this.addEdges(e)}registerRelationName(e,t){t&&this.relationMap.set(t.toLowerCase(),e)}optionalString(e){return typeof e==`string`&&e!==``?e:void 0}optionalStringArray(e){return Array.isArray(e)?e:void 0}baseNodeAttributes(e,t){return{unique_id:e,name:this.optionalString(t.name)??e,package_name:this.optionalString(t.package_name)??``,path:this.optionalString(t.path),original_file_path:this.optionalString(t.original_file_path),tags:this.optionalStringArray(t.tags),description:this.optionalString(t.description)}}addManifestEntries(e,t,n){if(e)for(let[r,i]of Object.entries(e)){let e=i;this.graph.addNode(r,t(r,e)),n!=null&&this.registerRelationName(r,w(e,n))}}readMaterialized(e){let t=e?.materialized;return typeof t==`string`&&t.trim()!==``?t:void 0}metricArrayStrings(e,t){if(Array.isArray(e))return e.map(e=>w(e,t)).filter(e=>typeof e==`string`)}buildNodeEntryAttributes(e,t){let n=this.extractResourceType(this.optionalString(t.resource_type)??`model`),r=t.config,i=this.readMaterialized(r);return{...this.baseNodeAttributes(e,t),resource_type:n,patch_path:this.optionalString(t.patch_path),database:this.optionalString(t.database),schema:this.optionalString(t.schema),alias:this.optionalString(t.alias),compiled_code:this.optionalString(t.compiled_code),raw_code:this.optionalString(t.raw_code)??this.optionalString(t.raw_sql),...i==null?{}:{materialized:i}}}buildSourceEntryAttributes(e,t){return{...this.baseNodeAttributes(e,t),resource_type:`source`,database:this.optionalString(t.database),schema:this.optionalString(t.schema),alias:this.optionalString(t.identifier),relation_name:this.optionalString(t.relation_name)}}buildMacroEntryAttributes(e,t){return{...this.baseNodeAttributes(e,t),resource_type:`macro`,raw_code:this.optionalString(t.macro_sql)}}buildExposureEntryAttributes(e,t){return{...this.baseNodeAttributes(e,t),resource_type:`exposure`}}buildMetricEntryAttributes(e,t){let n=t.type_params,r=t.filter,i=t.depends_on,a=t.tags,o=typeof a==`string`?[a]:this.optionalStringArray(a);return{...this.baseNodeAttributes(e,t),resource_type:`metric`,label:this.optionalString(t.label),metric_type:this.optionalString(t.type),metric_expression:this.optionalString(n?.expr),metric_measure:this.optionalString(n?.measure?.name),metric_input_measures:this.metricArrayStrings(n?.input_measures,`name`),metric_input_metrics:this.metricArrayStrings(n?.metrics,`name`),metric_time_granularity:this.optionalString(t.time_granularity),metric_filters:this.metricArrayStrings(r?.where_filters,`where_sql_template`),metric_source_reference:i?.nodes?.[0]??void 0,tags:o}}traverseNeighbors(e,t){if(!this.graph.hasNode(e))return[];let n=[],r=/* @__PURE__ */ new Set,i=[],a=0,o=(e,a)=>{for(let o of t.getNeighbors(e))r.has(o)||(r.add(o),n.push(t.includeParents?{nodeId:o,depth:a,parentId:e}:{nodeId:o,depth:a}),(t.maxDepth===void 0||a<t.maxDepth)&&i.push({id:o,depth:a}))};for(o(e,1);a<i.length;){let{id:e,depth:t}=i[a++];o(e,t+1)}return n}addNodes(e){this.addNodeEntries(e.nodes),this.addSourceEntries(e.sources),this.addMacroEntries(e.macros),this.addExposureEntries(e.exposures),this.addMetricEntries(zt(e)),this.addSemanticModelEntries(Bt(e)),this.addUnitTestEntries(Vt(e))}addNodeEntries(e){this.addManifestEntries(e,(e,t)=>this.buildNodeEntryAttributes(e,t),`relation_name`)}addSourceEntries(e){this.addManifestEntries(e,(e,t)=>this.buildSourceEntryAttributes(e,t),`relation_name`)}addMacroEntries(e){this.addManifestEntries(e,(e,t)=>this.buildMacroEntryAttributes(e,t))}addExposureEntries(e){this.addManifestEntries(e,(e,t)=>this.buildExposureEntryAttributes(e,t))}addMetricEntries(e){this.addManifestEntries(e,(e,t)=>this.buildMetricEntryAttributes(e,t))}addSemanticModelEntries(e){if(e)for(let[t,n]of Object.entries(e)){let e=n;this.graph.addNode(t,{unique_id:t,resource_type:`semantic_model`,name:e.name||t,package_name:e.package_name||``,path:e.path||void 0,original_file_path:e.original_file_path||void 0,description:e.description||void 0,label:e.label||void 0,semantic_model_reference:e.model||void 0,semantic_model_default_time_dimension:e.defaults?.agg_time_dimension||void 0,semantic_model_entities:Array.isArray(e.entities)?e.entities.map(e=>e.name).filter(e=>typeof e==`string`):void 0,semantic_model_measures:Array.isArray(e.measures)?e.measures.map(e=>e.name).filter(e=>typeof e==`string`):void 0,semantic_model_dimensions:Array.isArray(e.dimensions)?e.dimensions.map(e=>e.name).filter(e=>typeof e==`string`):void 0})}}addUnitTestEntries(e){if(e)for(let[t,n]of Object.entries(e)){let e=n;this.graph.addNode(t,{unique_id:t,resource_type:`unit_test`,name:e.name||t,package_name:e.package_name||``})}}addEdges(e){e.parent_map&&this.addEdgesFromParentMap(e.parent_map),this.addEdgesFromNodeDependsOn(e.nodes),this.addEdgesFromExposureDependsOn(e.exposures),this.addEdgesFromMetricDependsOn(zt(e))}addEdgesFromParentMap(e){for(let[t,n]of Object.entries(e))if(this.graph.hasNode(t))for(let e of n)this.graph.hasNode(e)&&!this.graph.hasEdge(e,t)&&this.graph.addEdge(e,t,{dependency_type:this.inferDependencyType(e)})}addEdgesFromDependsOn(e,t){if(t.nodes)for(let n of t.nodes)this.graph.hasNode(n)&&!this.graph.hasEdge(n,e)&&this.graph.addEdge(n,e,{dependency_type:`node`});if(t.macros)for(let n of t.macros)this.graph.hasNode(n)&&!this.graph.hasEdge(n,e)&&this.graph.addEdge(n,e,{dependency_type:`macro`})}addEdgesFromNodeDependsOn(e){if(e)for(let[t,n]of Object.entries(e)){let e=n.depends_on;e&&this.addEdgesFromDependsOn(t,e)}}addEdgesFromExposureDependsOn(e){if(e)for(let[t,n]of Object.entries(e)){let e=n.depends_on;e?.nodes&&this.addEdgesFromDependsOn(t,e)}}addEdgesFromMetricDependsOn(e){if(e)for(let[t,n]of Object.entries(e)){let e=n.depends_on;e?.nodes&&this.addEdgesFromDependsOn(t,e)}}extractResourceType(e){let t=e.toLowerCase();return[`model`,`source`,`seed`,`snapshot`,`test`,`analysis`,`macro`,`exposure`,`metric`,`semantic_model`,`unit_test`,`function`].includes(t)?t:`model`}inferDependencyType(e){return e.startsWith(`macro.`)?`macro`:e.startsWith(`source.`)?`source`:`node`}getGraph(){return this.graph}getSummary(){let e=/* @__PURE__ */ new Map,t=0;this.graph.forEachNode((n,r)=>{t++;let i=r.resource_type||`unknown`;Pt(e,i)});let n=(0,jt.hasCycle)(this.graph);return{total_nodes:t,nodes_by_type:Nt(e),total_edges:this.graph.size,has_cycles:n}}getUpstream(e,t){return this.traverseNeighbors(e,{maxDepth:t,getNeighbors:e=>this.graph.inboundNeighbors(e),includeParents:!1}).map(({nodeId:e,depth:t})=>({nodeId:e,depth:t}))}getDownstream(e,t){return this.traverseNeighbors(e,{maxDepth:t,getNeighbors:e=>this.graph.outboundNeighbors(e),includeParents:!1}).map(({nodeId:e,depth:t})=>({nodeId:e,depth:t}))}getUpstreamWithParents(e,t){return this.traverseNeighbors(e,{maxDepth:t,getNeighbors:e=>this.graph.inboundNeighbors(e),includeParents:!0}).map(({nodeId:t,depth:n,parentId:r})=>({nodeId:t,depth:n,parentId:r??e}))}getUpstreamBuildOrder(e,t){let n=this.getUpstream(e,t);if(n.length===0)return[];let r=new Set(n.map(e=>e.nodeId)),i=new Map(n.map(e=>[e.nodeId,e.depth])),a=new ht;for(let e of r)a.addNode(e,this.graph.getNodeAttributes(e));return this.graph.forEachEdge((e,t,n,i)=>{r.has(n)&&r.has(i)&&(a.hasEdge(n,i)||a.addEdge(n,i,t))}),(0,jt.topologicalSort)(a).map(e=>({nodeId:e,depth:i.get(e)??0}))}getDownstreamWithParents(e,t){return this.traverseNeighbors(e,{maxDepth:t,getNeighbors:e=>this.graph.outboundNeighbors(e),includeParents:!0}).map(({nodeId:t,depth:n,parentId:r})=>({nodeId:t,depth:n,parentId:r??e}))}addFieldNodes(e){if(e.nodes){for(let[t,n]of Object.entries(e.nodes))if(this.graph.hasNode(t)){let e=n.columns;this.processCatalogColumns(t,e)}}if(e.sources){for(let[t,n]of Object.entries(e.sources))if(this.graph.hasNode(t)){let e=n.columns;this.processCatalogColumns(t,e)}}}processCatalogColumns(e,t){if(!t)return;let n=this.graph.getNodeAttributes(e);for(let[r,i]of Object.entries(t)){let t=`${e}#${r}`,a=i,o=a?.comment??a?.description;this.graph.hasNode(t)||(this.graph.addNode(t,{unique_id:t,resource_type:`field`,name:r,package_name:n.package_name,parent_id:e,description:o}),this.graph.addEdge(e,t,{dependency_type:`internal`}))}}addFieldEdges(e,t){if(this.graph.hasNode(e))for(let[n,r]of Object.entries(t)){let t=`${e}#${n}`;this.ensureFieldNode(e,n);for(let e of r){let n=this.resolveRelationToUniqueId(e.sourceTable);if(!n)continue;let r=`${n}#${e.sourceColumn}`;this.ensureFieldNode(n,e.sourceColumn),this.graph.hasEdge(r,t)||this.graph.addEdge(r,t,{dependency_type:`field`})}}}ensureFieldNode(e,t){let n=`${e}#${t}`;if(!this.graph.hasNode(n)){let r=this.graph.getNodeAttributes(e);this.graph.addNode(n,{unique_id:n,resource_type:`field`,name:t,package_name:r.package_name,parent_id:e}),this.graph.addEdge(e,n,{dependency_type:`internal`})}return n}tryResolveRelationName(e){return this.resolveRelationToUniqueId(e)}resolveRelationToUniqueId(e){let t=e.toLowerCase();if(this.relationMap.has(t))return this.relationMap.get(t);let n=t.replace(/["`]/g,``);if(this.relationMap.has(n))return this.relationMap.get(n);for(let[e,t]of this.relationMap.entries()){let r=e.replace(/["`]/g,``);if(r.endsWith(`.${n}`)||r===n)return t}}buildSubgraph(e,t,n,r){if(!this.graph.hasNode(e))throw Error(`Focus node not found in manifest: ${e}`);let i=/* @__PURE__ */ new Set([e]);if(t===`upstream`||t===`both`)for(let{nodeId:t}of this.getUpstream(e,n))i.add(t);if(t===`downstream`||t===`both`)for(let{nodeId:t}of this.getDownstream(e,n))i.add(t);let a=new ht;for(let t of i){if(!this.graph.hasNode(t))continue;let n=this.graph.getNodeAttributes(t);(t===e||!r||r.has(n.resource_type.toLowerCase()))&&a.addNode(t,n)}return this.graph.forEachEdge((e,t,n,r)=>{a.hasNode(n)&&a.hasNode(r)&&(a.hasEdge(n,r)||a.addEdge(n,r,t))}),a}};function T(e,t){let n=w(e,t);if(typeof n==`number`&&Number.isFinite(n))return n;if(typeof n==`string`&&n.trim()!==``){let e=Number(n);if(Number.isFinite(e))return e}}function E(e,t){let n=w(e,t);if(typeof n==`string`&&n.trim()!==``)return n}function D(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ut(e){return e===null?`null`:typeof e==`string`?e===``?`""`:e:typeof e==`number`||typeof e==`boolean`?String(e):Array.isArray(e)?`[${e.map(e=>Ut(e)).join(`, `)}]`:D(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${Ut(w(e,t))}`).join(`,`)}}`:String(e)}function Wt(e,t){return typeof t==`number`&&Number.isFinite(t)?{key:e,label:e,kind:`number`,displayValue:t.toLocaleString(),isScalar:!0,sortValue:t}:typeof t==`string`?{key:e,label:e,kind:`string`,displayValue:t===``?`""`:t,isScalar:!0,sortValue:t}:typeof t==`boolean`?{key:e,label:e,kind:`boolean`,displayValue:t?`true`:`false`,isScalar:!0,sortValue:+!!t}:t===null?{key:e,label:e,kind:`null`,displayValue:`null`,isScalar:!1}:Array.isArray(t)?{key:e,label:e,kind:`array`,displayValue:Ut(t),isScalar:!1}:{key:e,label:e,kind:`object`,displayValue:Ut(t),isScalar:!1}}function Gt(e,t){if(!D(t))return[Wt(e,t)];let n=Object.keys(t).sort();return n.length===0?[Wt(e,t)]:n.map(n=>Wt(`${e}.${n}`,w(t,n)))}function Kt(e){return e.bytesProcessed!==void 0||e.bytesBilled!==void 0||e.slotMs!==void 0||e.rowsAffected!==void 0||e.adapterCode!==void 0||e.adapterMessage!==void 0||e.queryId!==void 0||e.projectId!==void 0||e.location!==void 0||e.rowsInserted!==void 0||e.rowsDeleted!==void 0||e.rowsUpdated!==void 0||e.rowsDuplicated!==void 0}function qt(e){return D(e)}function Jt(e){if(typeof e!=`string`)return e;let t=e.trim();if(t===``||t===`null`)return null;let n=t[0];if(n!==`{`&&n!==`[`)return e;try{return JSON.parse(t)}catch{return e}}function Yt(e){return D(e)?Object.keys(e).sort().flatMap(t=>Gt(t,w(e,t))):[]}function Xt(e,t,n,r){for(let{metricKey:i,totalKey:a}of t){let t=w(e,i);typeof t==`number`&&(Pt(n,a,t),r.set(a,!0))}}function Zt(e,t,n,r){let i={nodesWithAdapterData:e};for(let{totalKey:e}of t){if(!r.get(e))continue;let t=n.get(e);t!==void 0&&Mt(i,e,t)}return i}function Qt(e){let t=[{metricKey:`bytesProcessed`,totalKey:`totalBytesProcessed`},{metricKey:`bytesBilled`,totalKey:`totalBytesBilled`},{metricKey:`slotMs`,totalKey:`totalSlotMs`},{metricKey:`rowsAffected`,totalKey:`totalRowsAffected`},{metricKey:`rowsInserted`,totalKey:`totalRowsInserted`},{metricKey:`rowsUpdated`,totalKey:`totalRowsUpdated`},{metricKey:`rowsDeleted`,totalKey:`totalRowsDeleted`},{metricKey:`rowsDuplicated`,totalKey:`totalRowsDuplicated`}],n=0,r=/* @__PURE__ */ new Map,i=/* @__PURE__ */ new Map;for(let{totalKey:e}of t)r.set(e,0),i.set(e,!1);for(let a of e)a!=null&&Kt(a)&&(n+=1,Xt(a,t,r,i));if(n!==0)return Zt(n,t,r,i)}function $t(e){if(!D(e))return{};let t=T(e,`bytes_processed`),n=T(e,`bytes_billed`),r=T(e,`slot_ms`),i=T(e,`rows_affected`),a=E(e,`code`),o=E(e,`_message`),s=E(e,`query_id`)??E(e,`job_id`),c=E(e,`project_id`),l=E(e,`location`);return{...t===void 0?{}:{bytesProcessed:t},...n===void 0?{}:{bytesBilled:n},...r===void 0?{}:{slotMs:r},...i===void 0?{}:{rowsAffected:i},...a===void 0?{}:{adapterCode:a},...o===void 0?{}:{adapterMessage:o},...s===void 0?{}:{queryId:s},...c===void 0?{}:{projectId:c},...l===void 0?{}:{location:l}}}function O(e,t){if(!D(e))return{rawKeys:[]};let n=Object.keys(e).filter(e=>typeof e==`string`);return{...$t(e),...t,rawKeys:n}}let en={name:`generic`,parse(e){return O(e,{})}},tn={name:`athena`,parse(e){if(!D(e))return{rawKeys:[]};let t=T(e,`data_scanned_in_bytes`);return O(e,{...t===void 0?{}:{bytesProcessed:t}})},canParse(e){return D(e)?`data_scanned_in_bytes`in e:!1}},nn={name:`bigquery`,parse(e){if(!D(e))return{rawKeys:[]};let t=T(e,`bytes_processed`),n=T(e,`bytes_billed`),r=T(e,`slot_ms`),i=E(e,`project_id`),a=E(e,`location`),o=E(e,`query_id`)??E(e,`job_id`);return O(e,{...t===void 0?{}:{bytesProcessed:t},...n===void 0?{}:{bytesBilled:n},...r===void 0?{}:{slotMs:r},...o===void 0?{}:{queryId:o},...i===void 0?{}:{projectId:i},...a===void 0?{}:{location:a}})},canParse(e){return D(e)?`bytes_processed`in e||`bytes_billed`in e||`slot_ms`in e||`job_id`in e||`location`in e:!1}},rn={name:`postgres`,parse(e){return O(e,{})}},an={name:`redshift`,parse(e){return O(e,{})}},on={name:`snowflake`,parse(e){if(!D(e))return{rawKeys:[]};let t=T(e,`rows_inserted`),n=T(e,`rows_deleted`),r=T(e,`rows_updated`),i=T(e,`rows_duplicates`);return O(e,{...t===void 0?{}:{rowsInserted:t},...n===void 0?{}:{rowsDeleted:n},...r===void 0?{}:{rowsUpdated:r},...i===void 0?{}:{rowsDuplicated:i}})},canParse(e){return D(e)?`rows_inserted`in e||`rows_deleted`in e||`rows_updated`in e||`rows_duplicates`in e:!1}},sn=/* @__PURE__ */ new Map([[`athena`,tn],[`bigquery`,nn],[`postgres`,rn],[`redshift`,an],[`snowflake`,on],[`spark`,{name:`spark`,parse(e){return O(e,{})}}]]),cn=[nn,on,tn],ln=new class{selectParser(e,t){if(e&&typeof e==`string`){let n=e.toLowerCase().trim(),r=sn.get(n);if(r&&(!r.canParse||r.canParse(t)))return r}for(let e of cn)if(e.canParse&&e.canParse(t))return e;return en}};function un(e,t){let n=Jt(e),r=t?.adapterType;return ln.selectParser(r,n).parse(n)}function dn(e,t){if(!e.results||!Array.isArray(e.results))return[];let n=e.results,r=e=>{let t=e.timing||[];return t.find(e=>e.name===`execute`)||t.find(e=>e.name===`compile`)||t[0]},i=e=>typeof e==`string`&&e.trim()!==``?e.trim():void 0,a=e=>{let n=un(e,{adapterType:t});return{adapterMetrics:n,includeAdapter:n.rawKeys.length>0||Kt(n),adapterResponseFields:Yt(e),includeAdapterFields:qt(e)}};return n.map(e=>{let t=r(e),n=Jt(e.adapter_response),{adapterMetrics:o,includeAdapter:s,adapterResponseFields:c,includeAdapterFields:l}=a(n),u=i(e.message);return{unique_id:e.unique_id||``,status:e.status||`unknown`,execution_time:e.execution_time||0,started_at:t?.started_at??void 0,completed_at:t?.completed_at??void 0,thread_id:e.thread_id??void 0,...u==null?{}:{message:u},...s?{adapterMetrics:o}:{},...l?{adapterResponseFields:c}:{}}})}var fn=class{constructor(e,t,n){this.runResults=e,this.graph=t,this.adapterType=n}getSummary(){let e=this.getNodeExecutions(),t=/* @__PURE__ */ new Map,n=0;for(let r of e)Pt(t,r.status||`unknown`),n+=r.execution_time||0;let r=this.calculateCriticalPath(e);return{total_execution_time:n,total_nodes:e.length,nodes_by_status:Nt(t),critical_path:r,node_executions:e}}getNodeExecutions(){return dn(this.runResults,this.adapterType)}calculateCriticalPath(e){let t=/* @__PURE__ */ new Map;for(let n of e)t.set(n.unique_id,n);let n=[],r=this.graph.getGraph();if(r.forEachNode(e=>{r.outboundNeighbors(e).length===0&&t.has(e)&&n.push(e)}),n.length===0)return;let i=[],a=0;for(let e of n){let n=this.findLongestPathToRoot(e,t),r=this.calculatePathTime(n,t);r>a&&(a=r,i=n)}if(i.length!==0)return{path:i,total_time:a}}findLongestPathToRoot(e,t){let n=this.graph.getGraph(),r=/* @__PURE__ */ new Set,i=[],a=(e,o)=>{if(r.has(e))return;r.add(e);let s=[...o,e];s.length>i.length&&(i=s);let c=n.inboundNeighbors(e);for(let e of c)t.has(e)&&a(e,s);r.delete(e)};return a(e,[]),i.reverse()}calculatePathTime(e,t){let n=0;for(let r of e){let e=t.get(r);e&&(n+=e.execution_time||0)}return n}getRunStartedAt(){let e=this.getNodeExecutions().map(e=>e.started_at?new Date(e.started_at).getTime():null).filter(e=>e!==null);return e.length===0?null:Math.min(...e)}parseTimingInterval(e){if(!e)return null;let t=e.started_at,n=e.completed_at;if(!t||!n)return null;let r=new Date(t).getTime(),i=new Date(n).getTime();return Number.isNaN(r)||Number.isNaN(i)?null:{start:r,end:i}}wallClockFromResult(e){let t=e.timing||[],n=t.find(e=>e.name===`execute`),r=t.find(e=>e.name===`compile`),i=this.parseTimingInterval(r),a=this.parseTimingInterval(n),o=[],s=[];return i&&(o.push(i.start),s.push(i.end)),a&&(o.push(a.start),s.push(a.end)),o.length===0?null:{wallStart:Math.min(...o),wallEnd:Math.max(...s),compile:i,execute:a}}getGanttData(){if(!this.runResults.results||!Array.isArray(this.runResults.results))return[];let e=this.graph.getGraph(),t=[];for(let n of this.runResults.results){let r=n.unique_id||``;if(!r)continue;let i=this.wallClockFromResult(n);if(!i)continue;let a=(e.hasNode(r)?e.getNodeAttributes(r):void 0)?.name||r,o=n.status||`unknown`;t.push({unique_id:r,name:a,status:o,wall:i})}if(t.length===0)return[];let n=Math.min(...t.map(e=>e.wall.wallStart));return t.map(e=>{let{wall:t}=e,r=e=>e-n;return{unique_id:e.unique_id,name:e.name,start:r(t.wallStart),end:r(t.wallEnd),duration:t.wallEnd-t.wallStart,status:e.status,compileStart:t.compile?r(t.compile.start):null,compileEnd:t.compile?r(t.compile.end):null,executeStart:t.execute?r(t.execute.start):null,executeEnd:t.execute?r(t.execute.end):null}})}};function pn(e,t){let n=t.split(`*`);if(n.length===1)return e===t;let r=0,i=!0;for(let t of n){let n=e.indexOf(t,r);if(n===-1||i&&n!==0)return!1;i=!1,r=n+t.length}let a=n[n.length-1];return a===``||e.endsWith(a)}function mn(e,t){return t instanceof RegExp?t.test(e):pn(e,t)}new Map([`bytes_processed`,`bytes_billed`,`slot_ms`,`rows_affected`,`rows_inserted`,`rows_updated`,`rows_deleted`,`rows_duplicated`].map(e=>[`${e}_desc`,e]));function hn(e,t){let n=e.adapterMetrics;return n!=null&&[n.queryId,n.adapterCode,n.adapterMessage,n.projectId,n.location].some(e=>e?.toLowerCase().includes(t)===!0)}function gn(e,t){let n=[...e];if(t.status!==void 0){let e=typeof t.status==`string`?[t.status]:t.status,r=new Set(e.map(e=>e.toLowerCase()));n=n.filter(e=>r.has((e.status||`unknown`).toLowerCase()))}if(t.min_execution_time!==void 0&&(n=n.filter(e=>(e.execution_time??0)>=t.min_execution_time)),t.max_execution_time!==void 0&&(n=n.filter(e=>(e.execution_time??0)<=t.max_execution_time)),t.unique_id_pattern!==void 0&&(n=n.filter(e=>mn(e.unique_id,t.unique_id_pattern))),t.has_adapter_key!==void 0&&(n=n.filter(e=>e.adapterMetrics?.rawKeys.includes(t.has_adapter_key)===!0)),t.adapter_text!==void 0&&t.adapter_text.trim()!==``){let e=t.adapter_text.toLowerCase();n=n.filter(t=>hn(t,e))}return n}function _n(e,t){return[...e].sort((e,n)=>{switch(t){case`execution_time_asc`:return(e.execution_time??0)-(n.execution_time??0);case`execution_time_desc`:return(n.execution_time??0)-(e.execution_time??0);case`unique_id`:return e.unique_id.localeCompare(n.unique_id);default:return 0}})}function vn(e,t){let n=gn(e,t);return t.sort&&(n=_n(n,t.sort)),t.limit!==void 0&&t.limit>=0&&(n=n.slice(0,t.limit)),n}function yn(e,t){if(!t)return;let n=t.getGraph();if(n.hasNode(e))return n.getNodeAttributes(e)?.name||void 0}function bn(e,t){let n=e.reduce((e,t)=>e+(t.execution_time??0),0),r;return r=t.mode===`top_n`?vn(e,{sort:`execution_time_desc`,limit:t.top}):vn(e,{min_execution_time:t.min_seconds,sort:`execution_time_desc`}),{nodes:r.map((e,r)=>{let i=e.execution_time??0,a=n>0?i/n*100:0;return{unique_id:e.unique_id,name:yn(e.unique_id,t.graph),execution_time:i,rank:r+1,pct_of_total:Math.round(a*10)/10,status:e.status||`unknown`}}),total_execution_time:n,criteria_used:t.mode===`top_n`?`top_n`:`threshold`}}function xn(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r+=1)n|=e.charCodeAt(r)^t.charCodeAt(r);return n===0}let Sn=/* @__PURE__ */ new Map([[`seed`,`seed`],[`snapshot`,`snapshot`],[`test`,`test`],[`unit_test`,`test`],[`operation`,`operation`]]);function Cn(e){switch(e){case`table`:return`table`;case`view`:return`view`;case`incremental`:return`incremental`;case`ephemeral`:return`ephemeral`;case`materialized_view`:case`materializedview`:return`materialized_view`;default:return}}function wn(e){return e.trim().toLowerCase()||`unknown`}function Tn(e){if(e==null||typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t===``?null:t.replace(/[\s-]+/g,`_`)}function En(e,t){let n=wn(e),r=Tn(t),i=Sn.get(n);if(i!==void 0)return{kind:i};if(n.length===0||xn(n,`model`))return typeof r==`string`?Dn(r,t):{kind:`unknown`};if(typeof r==`string`){let e=Cn(r);return e===void 0?{kind:`unknown`,raw:t.trim()}:{kind:e,raw:void 0}}return{kind:`unknown`}}function Dn(e,t){let n=Cn(e);return n===void 0?{kind:`unknown`,raw:t.trim()}:{kind:n}}function On(e,t){if(wn(t)===`source`)return{persisted:!0,createsRelation:!1,compiledIntoParent:!1};switch(e){case`ephemeral`:return{persisted:!1,createsRelation:!1,compiledIntoParent:!0};case`table`:case`view`:case`incremental`:case`materialized_view`:return{persisted:!0,createsRelation:!0,compiledIntoParent:!1};case`seed`:case`snapshot`:return{persisted:!0,createsRelation:!0,compiledIntoParent:!1};case`test`:case`operation`:return{persisted:!1,createsRelation:!1,compiledIntoParent:!1};default:return{persisted:!1,createsRelation:!1,compiledIntoParent:!1}}}function kn(e){if(e==null)return;let t=e.config;return typeof t==`object`&&t?t:void 0}function An(e,t,n){return e==null?`derived`:t||n||typeof e.relation_name==`string`&&e.relation_name.length>0?`manifest`:`derived`}function jn(e){let t=e?.unique_key;return t==null?{uniqueKey:void 0,hasUniqueKeyField:!1}:typeof t==`string`||Array.isArray(t)&&t.every(e=>typeof e==`string`)?{uniqueKey:t,hasUniqueKeyField:!0}:{uniqueKey:void 0,hasUniqueKeyField:!0}}function Mn(e,t){if(e==null)return{hasAnyIncrementalHint:t};let n=typeof e.incremental_strategy==`string`?e.incremental_strategy:void 0,r=typeof e.on_schema_change==`string`?e.on_schema_change:void 0,i=typeof e.full_refresh==`boolean`?e.full_refresh:void 0;return{incrementalStrategy:n,onSchemaChange:r,fullRefreshCapable:i,hasAnyIncrementalHint:n!=null||r!=null||i!=null||t}}function Nn(e){let t=e=>typeof e==`string`&&e.trim()!==``?e:void 0,n=(e,n,r,i,a)=>({...e==null?{}:{relationName:e},...t(n)==null?{}:{adapterType:t(n)},...a.incrementalStrategy==null?{}:{incrementalStrategy:a.incrementalStrategy},...r==null?{}:{uniqueKey:r},...a.onSchemaChange==null?{}:{onSchemaChange:a.onSchemaChange},...a.fullRefreshCapable==null?{}:{fullRefreshCapable:a.fullRefreshCapable},...t(i)==null?{}:{rawMaterialization:t(i)}}),{resourceType:r,adapterType:i}=e,a=e.manifestEntry??null,o=kn(a),s=typeof o?.materialized==`string`?o.materialized:null,c=typeof e.materialized==`string`&&e.materialized.trim()!==``?e.materialized:null,{kind:l,raw:u}=En(r,c??s),{uniqueKey:d,hasUniqueKeyField:f}=jn(o),p=Mn(o,f),m=t(a?.relation_name),h=s!=null&&String(s).trim()!==``,g=c!=null&&c.trim()!==``;return{resourceType:r,materialization:l,...On(l,r),...n(m,i,d,u,p),materializationSource:An(a,h||g,p.hasAnyIncrementalHint)}}let Pn=[{kind:`database`,label:`Database`,field:`database`},{kind:`schema`,label:`Schema`,field:`schema`}],Fn=[{kind:`catalog`,label:`Catalog`,field:`database`},{kind:`schema`,label:`Schema`,field:`schema`}],In=/* @__PURE__ */ new Map([[`bigquery`,[{kind:`project`,label:`Project`,field:`database`},{kind:`dataset`,label:`Dataset`,field:`schema`}]],[`snowflake`,Pn],[`redshift`,Pn],[`postgres`,Pn],[`duckdb`,Fn],[`databricks`,Fn],[`trino`,Fn],[`athena`,[{kind:`catalog`,label:`Data catalog`,field:`database`},{kind:`database`,label:`Glue database`,field:`schema`}]],[`spark`,[{kind:`schema`,label:`Schema`,field:`schema`}]]]),Ln=/* @__PURE__ */ new Set([`exposure`,`macro`,`metric`,`semantic_model`,`test`,`unit_test`]);function Rn(e){return typeof e==`string`&&e.trim()!==``?e:null}function zn(e,t){return Rn(t===`database`?e.database:e.schema)}function Bn(e){let t=(e??``).trim().toLowerCase();return In.get(t)??Pn}function Vn(e){if(Ln.has(e.resourceType)||e.createsRelation===!1)return null;let t=[];for(let n of Bn(e.adapterType)){let r=zn(e,n.field);if(r==null)return null;t.push({kind:n.kind,label:n.label,name:r})}return{levels:t,relation:Rn(e.alias)??Rn(e.name)}}let Hn=[`model`,`source`,`test`,`metric`,`semantic_model`,`exposure`,`seed`,`snapshot`,`unit_test`,`analysis`,`macro`];function Un(){return performance.now()}function Wn(e){let t=e?.trim().toLowerCase();return t?[`success`,`pass`,`passed`].includes(t)?`positive`:[`warn`,`warning`].includes(t)?`warning`:[`error`,`errors`,`fail`,`failed`,`failure`,`failures`,`errored`,`run error`,`runtime error`,`compile error`,`database error`].includes(t)?`danger`:[`skipped`,`no op`].includes(t)?`skipped`:`neutral`:`neutral`}function Gn(e){return typeof e==`string`&&e.trim()!==``?e.trim():null}function Kn(e){return e?e.split(/[\s_-]+/).filter(Boolean).map(e=>e[0].toUpperCase()+e.slice(1).toLowerCase()).join(` `):`Unknown`}function qn(e){let t=e.split(`.`);return t.length<2?``:t[1]??``}function Jn(e){let t=e.split(`.`)[0]??``;return(/* @__PURE__ */ new Set([`model`,`test`,`unit_test`,`seed`,`snapshot`,`source`,`source_freshness`,`exposure`,`metric`,`semantic_model`,`analysis`,`macro`])).has(t)?t:`operation`}function Yn(e){return e.split(`_`).map(e=>e[0].toUpperCase()+e.slice(1)).join(` `)}function Xn(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Zn(e){let t=typeof e.metric_measure==`string`?e.metric_measure:null,n=Xn(e.metric_input_measures);return{kind:`metric`,label:typeof e.label==`string`?e.label:null,description:typeof e.description==`string`?e.description:null,metricType:typeof e.metric_type==`string`?e.metric_type:null,expression:typeof e.metric_expression==`string`?e.metric_expression:null,sourceReference:typeof e.metric_source_reference==`string`?e.metric_source_reference:typeof e.metric_measure==`string`?e.metric_measure:null,filters:Xn(e.metric_filters),timeGranularity:typeof e.metric_time_granularity==`string`?e.metric_time_granularity:null,measures:n.length>0?n:t==null?[]:[t],metrics:Xn(e.metric_input_metrics)}}function Qn(e){return{kind:`semantic_model`,label:typeof e.label==`string`?e.label:null,description:typeof e.description==`string`?e.description:null,sourceReference:typeof e.semantic_model_reference==`string`?e.semantic_model_reference:null,defaultTimeDimension:typeof e.semantic_model_default_time_dimension==`string`?e.semantic_model_default_time_dimension:null,entities:Xn(e.semantic_model_entities),measures:Xn(e.semantic_model_measures),dimensions:Xn(e.semantic_model_dimensions)}}function $n(e,t){return e===`metric`?Zn(t):e===`semantic_model`?Qn(t):null}function er(e,t){let n=Hn.indexOf(e),r=Hn.indexOf(t);return n===-1&&r===-1?e.localeCompare(t):n===-1?1:r===-1?-1:n-r}function tr(e,t){let n=er(e.resourceType,t.resourceType);return n===0?e.name.localeCompare(t.name):n}function nr(e){let t=e.metadata;return typeof t==`object`&&t&&`project_name`in t&&typeof t.project_name==`string`&&t.project_name!==``?t.project_name:null}let rr=/* @__PURE__ */ new Set([`test`,`unit_test`,`macro`,`operation`,`sql_operation`]),ir=/* @__PURE__ */ new Set([`elementary`]);function ar(e,t){let n=(t.hasNode(e.unique_id)?t.getNodeAttributes(e.unique_id):void 0)?.package_name;return typeof n==`string`&&n.length>0?n:qn(e.unique_id)}function or(e,t){let n=(t.hasNode(e.unique_id)?t.getNodeAttributes(e.unique_id):void 0)?.resource_type;return typeof n==`string`&&n.length>0?n:Jn(e.unique_id)}function sr(e,t){if(e.length===0)return null;let n=/* @__PURE__ */ new Map;for(let r of e){let e=or(r,t);if(rr.has(e))continue;let i=ar(r,t);i.length>0&&!ir.has(i)&&Pt(n,i)}return[...n.entries()].sort((e,t)=>{let n=t[1]-e[1];return n===0?e[0].localeCompare(t[0]):n})[0]?.[0]??null}function cr(e,t,n){let r=0;for(let i of e){let e=or(i,t);rr.has(e)||ar(i,t)===n&&r++}return r}function lr(e,t,n){let r=nr(e),i=sr(t,n);return r==null||cr(t,n,r)===0&&i!=null?i:r}function ur(e){let t=e.metadata!=null&&typeof e.metadata==`object`?e.metadata:null;return typeof t?.invocation_id==`string`?t.invocation_id:null}function dr(e){let t=e.metadata;return typeof t==`object`&&t&&`adapter_type`in t&&typeof t.adapter_type==`string`&&t.adapter_type!==``?t.adapter_type:null}function fr(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=t.get(n.resourceType)??[];e.push(n),t.set(n.resourceType,e)}return[...t.entries()].sort(([e],[t])=>er(e,t)).map(([e,t])=>({resourceType:e,label:Yn(e),count:t.length,attentionCount:t.filter(e=>e.statusTone===`danger`||e.statusTone===`warning`).length,resources:t}))}function pr(e,t){let n=/* @__PURE__ */ new Map;for(let e of t){let t=Kn(e.status);n.set(t,(n.get(t)??0)+(e.execution_time??0))}return Object.entries(e.nodes_by_status).map(([t,r])=>({status:Kn(t),count:r,duration:n.get(Kn(t))??0,share:e.total_nodes>0?r/e.total_nodes:0,tone:Wn(t)})).sort((e,t)=>t.count-e.count)}function mr(e,t){let n={};for(let r of t)Mt(n,r,e.hasNode(r)?{inbound:[...e.inboundNeighbors(r)],outbound:[...e.outboundNeighbors(r)]}:{inbound:[],outbound:[]});return n}function hr(e){let t=/* @__PURE__ */ new Map;for(let n of e){let e=n.threadId??`unknown`,r=t.get(e)??{count:0,totalExecutionTime:0};r.count+=1,r.totalExecutionTime+=n.executionTime,t.set(e,r)}return[...t.entries()].map(([e,t])=>({threadId:e,count:t.count,totalExecutionTime:t.totalExecutionTime})).sort((e,t)=>t.totalExecutionTime-e.totalExecutionTime)}let gr=/* @__PURE__ */ new Set([`test`,`unit_test`]);function _r(e){let t=/* @__PURE__ */ new Map,n=e=>{if(typeof e==`object`&&e)for(let[n,r]of Object.entries(e))typeof r==`object`&&r&&t.set(n,r)};if(n(e.nodes),n(e.sources),n(e.unit_tests),e.disabled!=null&&typeof e.disabled==`object`){for(let[n,r]of Object.entries(e.disabled))if(Array.isArray(r))for(let e of r)typeof e==`object`&&e&&t.set(n,e)}return t}function vr(e,t,n){return t.hasNode(e)?t.getNodeAttributes(e):n.get(e)}function yr(e,t,n){for(let r of e){let e=vr(r,t,n),i=String(e?.resource_type??Jn(r));if(i!==`test`&&i!==`unit_test`&&i!==``)return r}return null}function br(e,t,n,r){let i=e.getUpstream(r),a=i.filter(e=>e.depth===1),o=yr((a.length>0?a:i).map(e=>e.nodeId),t,n);if(o!=null)return o;let s=n.get(r),c=typeof s?.attached_node==`string`?s.attached_node:null;if(c!=null)return c;let l=s?.depends_on;if(Array.isArray(l?.nodes)){let e=yr(l.nodes.filter(e=>typeof e==`string`),t,n);if(e!=null)return e}return null}function xr(e){return typeof e?.original_file_path==`string`?e.original_file_path:typeof e?.path==`string`?e.path:null}function Sr(e,t,n,r){let i=n.get(e)??null;return Nn({resourceType:typeof t?.resource_type==`string`&&t.resource_type!==``?t.resource_type:Jn(e),materialized:typeof t?.materialized==`string`&&t.materialized.trim()!==``?t.materialized:null,manifestEntry:i,adapterType:r??null})}function Cr(e,t,n,r,i){let a=vr(e.unique_id,n,r),o=typeof a?.resource_type==`string`&&a.resource_type!==``?a.resource_type:Jn(e.unique_id),s=o===`test`||o===`unit_test`?br(t,n,r,e.unique_id):null,c=typeof a?.package_name==`string`&&a.package_name.length>0?a.package_name:qn(e.unique_id),l=typeof a?.materialized==`string`&&a.materialized.trim()!==``?a.materialized:null,u=Sr(e.unique_id,a,r,i);return{...e,resourceType:o,packageName:c,path:xr(a),parentId:s,materialized:l,semantics:u}}function wr(e){let t=e?.trim().toLowerCase();return t?[`error`,`fail`,`failed`,`run error`].includes(t)?3:[`warn`,`warning`].includes(t)?2:+!![`success`,`pass`,`passed`].includes(t):0}function Tr(e){let t=e[0]?.status??`unknown`,n=wr(t);for(let r of e.slice(1)){let e=wr(r.status);e>n&&(n=e,t=r.status)}return t}function Er(e,t){let n=e.start-t.start;if(n!==0)return n;let r=t.duration-e.duration;return r===0?e.name.localeCompare(t.name):r}function Dr(e,t,n,r){let i=(e,n)=>{if(n.resourceType!==`test`&&n.resourceType!==`unit_test`||n.parentId==null||!t.hasNode(n.parentId))return;let r=t.getNodeAttributes(n.parentId);if(String(r?.resource_type??``)!==`source`)return;let i=e.get(n.parentId)??[];i.push(n),e.set(n.parentId,i)},a=(e,i)=>{let a=t.getNodeAttributes(e),o=[...i].sort(Er),s=Math.min(...o.map(e=>e.start)),c=Math.max(...o.map(e=>e.end)),l=Sr(e,a,n,r);return{unique_id:e,name:typeof a?.name==`string`&&a.name.length>0?a.name:e,start:s,end:c,duration:Math.max(0,c-s),status:Tr(o),resourceType:`source`,packageName:typeof a?.package_name==`string`&&a.package_name.length>0?a.package_name:qn(e),path:xr(a),parentId:null,compileStart:null,compileEnd:null,executeStart:null,executeEnd:null,materialized:null,semantics:l}},o=new Set(e.map(e=>e.unique_id)),s=/* @__PURE__ */ new Map;for(let t of e)i(s,t);let c=[];for(let[e,t]of s.entries())o.has(e)||t.length===0||c.push(a(e,t));return c.sort(Er)}function Or(e,t,n,r,i){let a=new Set(e.map(e=>e.unique_id)),o=new Map(e.map(e=>[e.unique_id,e])),s=[];return t.forEachNode((e,c)=>{if(String(c.resource_type??``)!==`source`||a.has(e))return;let l=typeof c.package_name==`string`&&c.package_name.length>0?c.package_name:qn(e);if(n!=null&&l!==n)return;let u=[];for(let n of t.outboundNeighbors(e)){let e=o.get(n);e!=null&&(gr.has(e.resourceType)||u.push(e))}if(u.length===0)return;let d=[...u].sort(Er),f=Math.min(...d.map(e=>e.start)),p=Math.max(...d.map(e=>e.end)),m=Sr(e,c,r,i);s.push({unique_id:e,name:typeof c.name==`string`&&c.name.length>0?c.name:e,start:f,end:p,duration:Math.max(0,p-f),status:Tr(d),resourceType:`source`,packageName:l,path:xr(c),parentId:null,compileStart:null,compileEnd:null,executeStart:null,executeEnd:null,materialized:null,semantics:m})}),s.sort(Er)}function kr(e){let t=e.column_name;return typeof t!=`string`||t.trim()===``?null:t.trim()}function Ar(e,t){let n=e.attached_node;if(typeof n!=`string`)return null;let r=t.getGraph();if(!r.hasNode(n))return null;let i=r.getNodeAttributes(n);return i==null||typeof i.name!=`string`||i.name===``?null:i.name}function jr(e,t){let n=e.depends_on;if(!Array.isArray(n?.nodes))return null;let r=t.getGraph();for(let e of n.nodes){if(typeof e!=`string`||!r.hasNode(e))continue;let t=r.getNodeAttributes(e),n=String(t?.resource_type??Jn(e));if(n!==`test`&&n!==`unit_test`&&t!=null&&typeof t.name==`string`&&t.name!==``)return t.name}return null}function Mr(e,t){if(e==null)return null;let n=kr(e),r=Ar(e,t)??jr(e,t);return r!=null&&n!=null?`${r}.${n}`:r??n??null}function k(e,t){let n=w(e,t);return typeof n==`string`?n:null}function Nr(e,t){let n=Array.isArray(t.tags)?t.tags.filter(e=>typeof e==`string`):void 0;return{uniqueId:e,name:String(t.name||e),resourceType:String(t.resource_type||`unknown`),packageName:String(t.package_name||``),...n===void 0?{}:{tags:n},path:k(t,`path`),originalFilePath:k(t,`original_file_path`),patchPath:k(t,`patch_path`),database:k(t,`database`),schema:k(t,`schema`),description:k(t,`description`)}}function A(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function Pr(e){let t=/* @__PURE__ */ new Map;if(e==null)return t;for(let n of[`nodes`,`sources`]){let r=n===`nodes`?e.nodes:n===`sources`?e.sources:void 0;if(typeof r==`object`&&r)for(let[e,n]of Object.entries(r))typeof n==`object`&&n&&t.set(e,n)}return t}function Fr(e){if(e==null)return null;let t=e.columns!=null&&typeof e.columns==`object`?e.columns:void 0,n=e.metadata!=null&&typeof e.metadata==`object`?e.metadata:void 0,r=e.stats!=null&&typeof e.stats==`object`?e.stats:void 0;return{columnCount:t==null?0:Object.keys(t).length,tableType:typeof n?.type==`string`?n.type:typeof n?.table_type==`string`?n.table_type:null,bytes:A(r?.bytes)??A(r?.num_bytes)??A(r?.size),rowCount:A(r?.row_count)??A(r?.num_rows)??A(r?.rows)}}function Ir(e){let t=/* @__PURE__ */ new Map,n=e?.results;if(!Array.isArray(n))return t;for(let e of n){if(typeof e!=`object`||!e)continue;let n=e,r=n.unique_id;typeof r==`string`&&r.length>0&&t.set(r,n)}return t}function Lr(e){if(typeof e!=`object`||!e)return null;let t=typeof e.count==`number`?e.count:null,n=typeof e.period==`string`?e.period:null;return t==null||n==null?null:`${t} ${n}`}function Rr(e,t){if(e!==`source`||t==null)return null;let n=t.criteria!=null&&typeof t.criteria==`object`?t.criteria:void 0,r=typeof t.status==`string`&&t.status.trim()!==``?t.status:void 0;return{status:r==null?`Unknown`:Kn(r),statusTone:Wn(r),maxLoadedAt:typeof t.max_loaded_at==`string`?t.max_loaded_at:null,snapshottedAt:typeof t.snapshotted_at==`string`?t.snapshotted_at:null,ageSeconds:A(t.max_loaded_at_time_ago_in_s),criteria:n==null?null:{warnAfter:Lr(n.warn_after),errorAfter:Lr(n.error_after),filter:typeof n.filter==`string`?n.filter:null},error:typeof t.error==`string`?t.error:typeof t.message==`string`?t.message:null}}function zr(e,t,n){let r=e=>{let n=t.getNodeAttributes(e.nodeId);return{uniqueId:e.nodeId,name:String(n?.name||e.nodeId),resourceType:String(n?.resource_type||`unknown`),depth:e.depth}},i=e.getUpstream(n,1),a=e.getDownstream(n,1);return{upstreamCount:i.length,downstreamCount:a.length,upstream:i.map(r),downstream:a.map(r)}}function Br(e,t,n,r,i,a,o,s){let c=(e,t,n)=>e?{[t]:n}:{},l=Nr(e,t),{resourceType:u}=l,d=k(t,`materialized`),f=Nn({resourceType:u,materialized:d!=null&&d.trim()!==``?d:null,manifestEntry:a.get(e)??null,adapterType:o??null}),p=u===`test`||u===`unit_test`?Mr(r,i):null,m=Gn(n?.message),h=typeof n?.execution_time==`number`?n.execution_time:null,g=typeof n?.thread_id==`string`?n.thread_id:null,_=Fr(s.catalogEntry),v=Rr(u,s.sourcesEntry),y=k(t,`alias`),b=Vn({adapterType:o,resourceType:u,database:l.database,schema:l.schema,alias:y,name:l.name,createsRelation:u===`source`||f.createsRelation});return{...l,compiledCode:null,rawCode:null,definition:$n(u,t),status:n?.status?Kn(n.status):null,statusTone:Wn(n?.status),executionTime:h,threadId:g,semantics:f,...c(p!=null,`testAttachedTarget`,p),...c(m!=null,`runResultMessage`,m),...c(n?.adapterMetrics!=null,`adapterMetrics`,n?.adapterMetrics),...c(n?.adapterResponseFields!=null,`adapterResponseFields`,n?.adapterResponseFields),...c(_!=null,`catalogStats`,_),...c(v!=null,`sourceFreshness`,v),...c(y!=null,`alias`,y),...c(b!=null,`warehouseLocation`,b)}}function Vr(e,t,n,r,i){let a=[],o={},s=e.getGraph(),c=Pr(i.catalogJson),l=Ir(i.sourcesJson);return s.forEachNode((i,u)=>{let d=t.get(i),f=n.get(i);a.push(Br(i,u,d,f,e,n,r,{catalogEntry:c.get(i),sourcesEntry:l.get(i)})),Mt(o,i,zr(e,s,i))}),a.sort(tr),{resources:a,dependencyIndex:o}}var Hr=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0})})),Ur=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tryFallbackToLatest=n;function t(e,t){console.warn(`Unsupported artifact schema version '${e}'; falling back to latest supported schema '${t}'. This is best-effort; prefer refreshing parsers for full support.`)}function n(e,n,r,i,a){if(!(!e?.fallbackToLatest||n<=r))return t(i,`v${r}`),a}})),Wr=/* @__PURE__ */ e(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__exportStar||function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&r(t,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.parseManifestV1=c,e.parseManifestV2=l,e.parseManifestV3=u,e.parseManifestV4=d,e.parseManifestV5=f,e.parseManifestV6=p,e.parseManifestV7=m,e.parseManifestV8=h,e.parseManifestV9=g,e.parseManifestV10=_,e.parseManifestV11=v,e.parseManifestV12=y,e.parseManifest=x,i(Hr(),e);let a=Ur(),o=`Not a manifest.json`;function s(e){if(!e)return null;let t=e.match(/\/manifest\/v(\d+)\.json$/);return t?parseInt(t[1],10):null}function c(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v1`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v1.json`))throw Error(`Not a manifest.json v1`);return e}function l(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v2`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v2.json`))throw Error(`Not a manifest.json v2`);return e}function u(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v3`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v3.json`))throw Error(`Not a manifest.json v3`);return e}function d(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v4`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v4.json`))throw Error(`Not a manifest.json v4`);return e}function f(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v5`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v5.json`))throw Error(`Not a manifest.json v5`);return e}function p(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v6`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v6.json`))throw Error(`Not a manifest.json v6`);return e}function m(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v7`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v7.json`))throw Error(`Not a manifest.json v7`);return e}function h(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v8`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v8.json`))throw Error(`Not a manifest.json v8`);return e}function g(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v9`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v9.json`))throw Error(`Not a manifest.json v9`);return e}function _(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v10`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v10.json`))throw Error(`Not a manifest.json v10`);return e}function v(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v11`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v11.json`))throw Error(`Not a manifest.json v11`);return e}function y(e){let t=e.metadata;if(!t)throw Error(`Not a manifest.json v12`);let n=t.dbt_schema_version;if(!n||!n.includes(`/manifest/v12.json`))throw Error(`Not a manifest.json v12`);return e}let b=[c,l,u,d,f,p,m,h,g,_,v,y];function x(e,t){let n=e.metadata;if(!n)throw Error(o);let r=n.dbt_schema_version;if(!r||!r.includes(`/manifest/v`))throw Error(o);let i=s(r);if(i===null)throw Error(o);let c=b[i-1];if(c)return c(e);let l=(0,a.tryFallbackToLatest)(t,i,b.length,r,e);if(l!==void 0)return l;throw Error(`Unsupported manifest version: ${i}`)}})),Gr=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0})})),Kr=/* @__PURE__ */ e(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__exportStar||function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&r(t,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.parseRunResultsV1=c,e.parseRunResultsV2=l,e.parseRunResultsV3=u,e.parseRunResultsV4=d,e.parseRunResultsV5=f,e.parseRunResultsV6=p,e.parseRunResults=h,i(Gr(),e);let a=Ur(),o=`Not a run-results.json`;function s(e){if(!e)return null;let t=e.match(/\/run-results\/v(\d+)\.json$/);return t?parseInt(t[1],10):null}function c(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v1`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v1.json`))throw Error(`Not a run-results.json v1`);return e}function l(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v2`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v2.json`))throw Error(`Not a run-results.json v2`);return e}function u(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v3`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v3.json`))throw Error(`Not a run-results.json v3`);return e}function d(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v4`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v4.json`))throw Error(`Not a run-results.json v4`);return e}function f(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v5`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v5.json`))throw Error(`Not a run-results.json v5`);return e}function p(e){let t=e.metadata;if(!t)throw Error(`Not a run-results.json v6`);let n=t.dbt_schema_version;if(!n||!n.includes(`/run-results/v6.json`))throw Error(`Not a run-results.json v6`);return e}let m=[c,l,u,d,f,p];function h(e,t){let n=e.metadata;if(!n)throw Error(o);let r=n.dbt_schema_version;if(!r||!r.includes(`/run-results/v`))throw Error(o);let i=s(r);if(i===null)throw Error(o);let c=m[i-1];if(c)return c(e);let l=(0,a.tryFallbackToLatest)(t,i,m.length,r,e);if(l!==void 0)return l;throw Error(`Unsupported run-results version: ${i}`)}})),qr=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0})})),Jr=/* @__PURE__ */ e(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__exportStar||function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&r(t,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.parseCatalogV1=c,e.parseCatalog=u,i(qr(),e);let a=Ur(),o=`Not a catalog.json`;function s(e){if(!e)return null;let t=e.match(/\/catalog\/v(\d+)\.json$/);return t?parseInt(t[1],10):null}function c(e){let t=e.metadata;if(!t)throw Error(`Not a catalog.json v1`);let n=t.dbt_schema_version;if(!n||!n.includes(`/catalog/v1.json`))throw Error(`Not a catalog.json v1`);return e}let l=[c];function u(e,t){let n=e.metadata;if(!n)throw Error(o);let r=n.dbt_schema_version;if(!r||!r.includes(`/catalog/v`))throw Error(o);let i=s(r);if(i===null)throw Error(o);let c=l[i-1];if(c)return c(e);let u=(0,a.tryFallbackToLatest)(t,i,l.length,r,e);if(u!==void 0)return u;throw Error(`Unsupported catalog version: ${i}`)}})),Yr=/* @__PURE__ */ e((e=>{Object.defineProperty(e,"__esModule",{value:!0})})),Xr=/* @__PURE__ */ e(((e,t,n)=>{var r=n&&n.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),i=n&&n.__exportStar||function(e,t){for(var n in e)n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n)&&r(t,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.parseSourcesV1=c,e.parseSourcesV2=l,e.parseSourcesV3=u,e.parseSources=f,i(Yr(),e);let a=Ur(),o=`Not a sources.json`;function s(e){if(!e)return null;let t=e.match(/\/sources\/v(\d+)\.json$/);return t?parseInt(t[1],10):null}function c(e){let t=e.metadata;if(!t)throw Error(`Not a sources.json v1`);let n=t.dbt_schema_version;if(!n||!n.includes(`/sources/v1.json`))throw Error(`Not a sources.json v1`);return e}function l(e){let t=e.metadata;if(!t)throw Error(`Not a sources.json v2`);let n=t.dbt_schema_version;if(!n||!n.includes(`/sources/v2.json`))throw Error(`Not a sources.json v2`);return e}function u(e){let t=e.metadata;if(!t)throw Error(`Not a sources.json v3`);let n=t.dbt_schema_version;if(!n||!n.includes(`/sources/v3.json`))throw Error(`Not a sources.json v3`);return e}let d=[c,l,u];function f(e,t){let n=e.metadata;if(!n)throw Error(o);let r=n.dbt_schema_version;if(!r||!r.includes(`/sources/v`))throw Error(o);let i=s(r);if(i===null)throw Error(o);let c=d[i-1];if(c)return c(e);let l=(0,a.tryFallbackToLatest)(t,i,d.length,r,e);if(l!==void 0)return l;throw Error(`Unsupported sources version: ${i}`)}}));function Zr(){return{total_execution_time:0,total_nodes:0,nodes_by_status:{},node_executions:[]}}function Qr(e){let{manifestJson:t,runResultsJson:n,catalogJson:r,sourcesJson:i,manifest:a,runResults:o}=e,s=Un(),c=new Ht(a),l=dr(t),u=o==null?null:new fn(o,c,l),d=Un()-s,f=Un(),p=u?.getSummary()??Zr(),m=_r(t),h=u?.getGanttData()??[],g=u?.getNodeExecutions()??[],_=g.map(e=>e.started_at?new Date(e.started_at).getTime():null).filter(e=>e!==null),v=_.length>0?Math.min(..._):null,y=p.node_executions.length===0?void 0:bn(p.node_executions,{mode:`top_n`,top:5,graph:c}),b=c.getSummary(),x=new Map(h.map(e=>[e.unique_id,e])),ee=new Map(g.map(e=>[e.unique_id,e])),S=c.getGraph(),{resources:te,dependencyIndex:ne}=Vr(c,ee,m,l,{catalogJson:r,sourcesJson:i}),re=lr(t,g,S),ie=h.map(e=>Cr(e,c,S,m,l)),ae=Dr(ie,S,m,l),oe=Or([...ie,...ae],S,re,m,l),se=[...ie,...ae,...oe].sort(Er),ce=mr(S,se.map(e=>e.unique_id)),le=new Map(te.map(e=>[e.uniqueId,e.semantics])),ue=g.map(e=>{let t=S.hasNode(e.unique_id)?S.getNodeAttributes(e.unique_id):void 0,n=x.get(e.unique_id),r=le.get(e.unique_id),i=Gn(e.message);return{uniqueId:e.unique_id,name:String(t?.name||e.unique_id),resourceType:String(t?.resource_type||Jn(e.unique_id)),packageName:(()=>{let n=t?.package_name;return typeof n==`string`&&n.length>0?n:qn(e.unique_id)})(),path:typeof t?.original_file_path==`string`?t.original_file_path:typeof t?.path==`string`?t.path:null,status:Kn(e.status),statusTone:Wn(e.status),executionTime:e.execution_time??0,threadId:typeof e.thread_id==`string`?e.thread_id:null,start:n?.start??null,end:n?.end??null,...e.adapterMetrics==null?{}:{adapterMetrics:e.adapterMetrics},...e.adapterResponseFields==null?{}:{adapterResponseFields:e.adapterResponseFields},...r==null?{}:{semantics:r},...i==null?{}:{runResultMessage:i}}}).sort((e,t)=>t.executionTime-e.executionTime),de=Qt(g.map(e=>e.adapterMetrics)),fe=fr(te),pe=pr(p,g),me=hr(ue),he=te.find(e=>e.resourceType===`model`)?.uniqueId??te[0]?.uniqueId??null;return{analysis:{summary:p,projectName:re,warehouseType:l,runStartedAt:v,ganttData:se,bottlenecks:y,graphSummary:{totalNodes:b.total_nodes,totalEdges:b.total_edges,hasCycles:b.has_cycles,nodesByType:b.nodes_by_type},resources:te,resourceGroups:fe,executions:ue,statusBreakdown:pe,threadStats:me,dependencyIndex:ne,timelineAdjacency:ce,selectedResourceId:he,invocationId:n==null?null:ur(n),...de==null?{}:{adapterTotals:de}},timings:{graphBuildMs:d,snapshotBuildMs:Un()-f},graph:c}}function $r(e){let t=e.split(/\s+/).filter(Boolean),n=[],r,i,a,o;for(let e of t)e.startsWith(`type:`)?r=e.slice(5):e.startsWith(`package:`)?i=e.slice(8):e.startsWith(`tag:`)?a=e.slice(4):e.startsWith(`path:`)?o=e.slice(5):e.startsWith(`owner:`)||e.startsWith(`source:`)?n.push(e.slice(e.indexOf(`:`)+1)):n.push(e);return{terms:n,type:r,package:i,tag:a,path:o}}function ei(e,t,n,r,i){if(e.resource_type===`field`||t&&!t.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean).includes(e.resource_type.toLowerCase())||n&&(e.package_name||``)!==n)return!1;if(r){let t=r.split(`,`).map(e=>e.trim().toLowerCase()).filter(Boolean),n=(e.tags||[]).map(e=>e.toLowerCase());if(!t.some(e=>n.includes(e)))return!1}return!(i&&!(e.path||``).includes(i))}function ti(e,t){if(t.length===0)return 1;let n=0,r=(e.name||``).toLowerCase(),i=(e.unique_id||``).toLowerCase(),a=(e.package_name||``).toLowerCase(),o=(e.path||``).toLowerCase(),s=(e.tags||[]).map(e=>e.toLowerCase());for(let e of t){let t=e.toLowerCase();if(r===t||i===t)n+=10;else if(r.includes(t)||i.includes(t))n+=5;else if(a.includes(t)||o.includes(t))n+=2;else if(s.some(e=>e.includes(t)))n+=3;else return 0}return n}function ni(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function ri(e,t=`|`){return e.map(e=>Ci(e)).join(t)}function ii(e,t){return typeof t==`bigint`?t.toString():t}var ai=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function oi(e){return new ai(e)}function si(e){return e==null}function ci(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function li(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function j(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ui(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function M(e){return ui(e._zod.def)??e._zod.def.shape}function di(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return j(this,t,e),e},enumerable:!0,configurable:!0})}function fi(e,t,n){t in e?j(e,t,n):e[t]=n}function N(e,t,n,r){let i=M(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?di(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):fi(e,a,r?r(n.value,a):n.value))}}function pi(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?di(e,n,()=>t[n]):fi(e,n,r.value))}}function P(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function mi(e){return JSON.stringify(e)}function hi(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}let gi=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function _i(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}let vi=/* @__PURE__*/ oi(()=>{if(H.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function yi(e){if(_i(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return _i(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function bi(e){return yi(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let xi=/* @__PURE__*/ new Set([`string`,`number`,`symbol`]);function Si(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function F(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function I(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Ci(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function wi(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}let Ti={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ei={int64:[/* @__PURE__*/ BigInt(`-9223372036854775808`),/* @__PURE__*/ BigInt(`9223372036854775807`)],uint64:[/* @__PURE__*/ BigInt(0),/* @__PURE__*/ BigInt(`18446744073709551615`)]};function Di(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return N(i,e,Oi(e,t)),F(e,P(n,{shape:i,checks:[]}))}function Oi(e,t){let n=M(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function ki(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(Oi(e,t)),a={};return N(a,e,Reflect.ownKeys(M(e)).filter(e=>!i.has(e))),F(e,P(n,{shape:a,checks:[]}))}function Ai(e,t){if(!yi(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=M(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return F(e,P(e._zod.def,{shape:ji(e,t)}))}function ji(e,t){let n={};return N(n,e,Reflect.ownKeys(M(e))),pi(n,t),n}function Mi(e,t){if(!yi(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return F(e,P(e._zod.def,{shape:ji(e,t)}))}function Ni(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return N(n,e,Reflect.ownKeys(M(e))),N(n,t,Reflect.ownKeys(M(t))),F(e,P(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Pi(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(Oi(t,n)):void 0,o={};return N(o,t,Reflect.ownKeys(M(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),F(t,P(t._zod.def,{shape:o,checks:[]}))}function Fi(e,t,n){let r=n?new Set(Oi(t,n)):void 0,i={};return N(i,t,Reflect.ownKeys(M(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),F(t,P(t._zod.def,{shape:i}))}function L(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ii(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Li(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Ri(e){return typeof e==`string`?e:e?.message}function zi(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function Bi(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Vi(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Ri(e.inst?._zod.def?.error?.(e))??Ri(a?.(e))??Ri(t?.error?.(e))??Ri(n.customError?.(e))??Ri(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}let Hi=/[\uD800-\uDBFF]/;function Ui(e){let t=e.length;if(!Hi.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Wi(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Gi(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Ki(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function qi(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Xi(e,n,r.value)}}function R(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Ji(e,t,n){return R(e,t,n,!1)}/* @__NO_SIDE_EFFECTS__ */
2
+ function Yi(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return R(this,n,r(this))},set(e){R(this,n,e)}})}return t}function Xi(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:R(this,t,n.bind(this))},set(e){R(this,t,e)}})}function Zi(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}let Qi,$i=!1,ea={configurable:!0,get(){$i=!0}};function z(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&Qi!==e._zod?Qi=void 0:(Qi=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,ea);let e=$i;$i=!1;try{let r=n(this);return $i?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),$i||=e,r}catch(n){throw delete this[t],$i||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function ta(e,t,n,r){let i=Zi(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}function na(e){let t=()=>e;return t[`~constantCatch`]=!0,t}var ra;let ia={value:void 0,enumerable:!1},aa=`captureStackTrace`in Error?Error:null;function oa(e){let t=aa;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return aa=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}/* @__NO_SIDE_EFFECTS__ */
3
+ function B(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=/* @__PURE__ */ new Set}a.prototype=i;let o=n,s=o&&/* @__PURE__ */ new WeakSet;function c(n,r){if(!n._zod){ia.value=new a(r);try{Object.defineProperty(n,"_zod",ia)}finally{ia.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),qi(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?oa(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var V=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},sa=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(ra=globalThis).__zod_globalConfig??(ra.__zod_globalConfig={});let H=globalThis.__zod_globalConfig;function U(e){return e&&Object.assign(H,e),H}function ca(){let e=this._zod;return e.message??=JSON.stringify(e.def,ii,2),e.message}function la(e){this._zod.message=e}let ua={get:ca,set:la,enumerable:!0,configurable:!0},da={value:void 0,enumerable:!1},fa=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]),pa=/* @__PURE__ */ B(`$ZodError`,(e,t)=>{e.name=`$ZodError`,da.value=t,Object.defineProperty(e,"issues",da),da.value=void 0,Object.defineProperty(e,"message",ua);let n=Object.getPrototypeOf(e);fa.has(n)||(fa.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function ma(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function ha(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?ma(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function ga(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function _a(e,t){return{callee:t?.callee??e,Err:t?.Err}}let va=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new V;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Vi(e,o,U())));throw gi(n,a?.callee??t),n}return s.value};return t},ya=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Vi(e,o,U())));throw gi(n,a?.callee??t),n}return s.value};return t},ba=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new V;return a.issues.length?xa(e,a.issues,i):{success:!0,data:a.value}};function xa(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Vi(e,n,U()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}let Sa=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?xa(e,a.issues,i):{success:!0,data:a.value}},Ca=/* @__PURE__ */ Symbol.for(`zod.compile.invalid`),wa=/* @__PURE__ */ Symbol.for(`zod.compile.fallback`),Ta=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Ca)return!0;if(r.definite===!0&&n===void 0)return!1}return Ea(e,t,n)});function Ea(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[wa]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new V;return a.issues.length===0}let Da=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Oa=e=>{let t=va(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,_a(n,a))};return n},ka=e=>{let t=va(e),n=(e,r,i,a)=>t(e,r,i,_a(n,a));return n},Aa=e=>{let t=ya(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,_a(n,a))};return n},ja=e=>{let t=ya(e),n=async(e,r,i,a)=>await t(e,r,i,_a(n,a));return n},Ma=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ba(e)(t,n,i)},Na=e=>(t,n,r)=>ba(e)(t,n,r),Pa=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Sa(e)(t,n,i)},Fa=e=>async(t,n,r)=>Sa(e)(t,n,r),Ia=/^[cC][0-9a-z]{6,}$/,La=/^[0-9a-z]+$/,Ra=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,za=/^[0-9a-vA-V]{20}$/,Ba=/^[A-Za-z0-9]{27}$/,Va=/^[a-zA-Z0-9_-]{21}$/;function Ha(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}let Ua=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Wa=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ga=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ka=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function qa(){return/* @__PURE__ */ RegExp(`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`,`u`)}let Ja=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Ya=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Xa=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Za=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Qa=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$a=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,eo=/^https?$/,to=/^\+[1-9]\d{6,14}$/,no=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function ro(e){return RegExp(`^${e}$`)}let io=/*@__PURE__*/ ro(no);function ao(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function oo(e){return RegExp(`^${ao(e)}$`)}function so(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${ao({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${ao({precision:e.precision})}`:n;return RegExp(`^${no}T(?:${r})$`)}let co=/^[\s\S]{0,}$/,lo=/^-?\d+(?:\.\d+)?$/,uo=/^[^A-Z]*$/,fo=/^[^a-z]*$/,W=/*@__PURE__*/ B(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),po=e=>{let t=e.value;return!si(t)&&t.length!==void 0},mo={number:`number`,bigint:`bigint`,object:`date`},ho=/*@__PURE__*/ B(`$ZodCheckLessThan`,(e,t)=>{W.init(e,t);let n=mo[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:mo[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),go=/*@__PURE__*/ B(`$ZodCheckGreaterThan`,(e,t)=>{W.init(e,t);let n=mo[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:mo[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_o=/*@__PURE__*/ B(`$ZodCheckMultipleOf`,(e,t)=>{W.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):li(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),vo=/*@__PURE__*/ B(`$ZodCheckNumberFormat`,(e,t)=>{W.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Ti[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),yo=/*@__PURE__*/ B(`$ZodCheckMaxLength`,(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=po),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Ui(r):i)<=t.maximum)return;let a=Wi(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),bo=/*@__PURE__*/ B(`$ZodCheckMinLength`,(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=po),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Ui(r):i)>=t.minimum)return;let a=Wi(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),xo=/*@__PURE__*/ B(`$ZodCheckLengthEquals`,(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=po),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Ui(r):i;if(a===t.length)return;let o=Wi(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),So=/*@__PURE__*/ B(`$ZodCheckStringFormat`,(e,t)=>{var n,r;W.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Co=/*@__PURE__*/ B(`$ZodCheckRegex`,(e,t)=>{So.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),wo=/*@__PURE__*/ B(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=uo,So.init(e,t)}),To=/*@__PURE__*/ B(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=fo,So.init(e,t)}),Eo=/*@__PURE__*/ B(`$ZodCheckIncludes`,(e,t)=>{W.init(e,t);let n=Si(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Do=/*@__PURE__*/ B(`$ZodCheckStartsWith`,(e,t)=>{W.init(e,t);let n=RegExp(`^${Si(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Oo=/*@__PURE__*/ B(`$ZodCheckEndsWith`,(e,t)=>{W.init(e,t);let n=RegExp(`.*${Si(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),ko=/*@__PURE__*/ B(`$ZodCheckOverwrite`,(e,t)=>{W.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Ao=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
4
+ `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
5
+ `)}\n};`)(...Object.values(this.closed))}};let jo={major:4,minor:6,patch:7},G=/*@__PURE__*/ B(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=jo;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=L(t),a;for(let o of n){if(o._zod.def.when){if(Ii(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new V;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Bi(t.issues,n,e),i||=L(t,n))});else{if(t.issues.length===n)continue;Bi(t.issues,n,e),i||=L(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(L(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new V;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new V;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return Ji(this,`~standard`,Po(this))},set"~standard"(e){R(this,`~standard`,e)}}),Mo=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Vi(e,t,U()))}:{value:e.value};async function No(e,t){let n={async:!0};return Mo(await e._zod.run({value:t,issues:[]},n),n)}function Po(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Mo(r,n)}catch{}return No(e,t)},vendor:`zod`,version:1}}let Fo=/*@__PURE__*/ B(`$ZodString`,(e,t)=>{G.init(e,t),e._zod.pattern=t.pattern??co,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),K=/*@__PURE__*/ B(`$ZodStringFormat`,(e,t)=>{So.init(e,t),Fo.init(e,t)}),Io=/*@__PURE__*/ B(`$ZodGUID`,(e,t)=>{t.pattern??=Wa,K.init(e,t)}),Lo=/*@__PURE__*/ B(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Ga(e)}else t.pattern??=Ga();K.init(e,t)}),Ro=/*@__PURE__*/ B(`$ZodEmail`,(e,t)=>{t.pattern??=Ka,K.init(e,t)});function zo(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Bo(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?zo(e)||2:Vo(e,t)}function Vo(e,t){if(!t.normalize&&t.protocol?.source===eo.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}let Ho=/[\t\n\r]/g;function Uo(e){return e.replace(Ho,``)}function Wo(e,t){return t.lastIndex=0,t.test(e.hostname)}function Go(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}let Ko=/*@__PURE__*/ B(`$ZodURL`,(e,t)=>{K.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Bo(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Uo(r);return}t.hostname&&!Wo(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Go(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Uo(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),qo=/*@__PURE__*/ B(`$ZodEmoji`,(e,t)=>{t.pattern??=qa(),K.init(e,t)}),Jo=/*@__PURE__*/ B(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Va:Ha(t.length),K.init(e,t)}),Yo=/*@__PURE__*/ B(`$ZodCUID`,(e,t)=>{t.pattern??=Ia,K.init(e,t)}),Xo=/*@__PURE__*/ B(`$ZodCUID2`,(e,t)=>{t.pattern??=La,K.init(e,t)}),Zo=/*@__PURE__*/ B(`$ZodULID`,(e,t)=>{t.pattern??=Ra,K.init(e,t)}),Qo=/*@__PURE__*/ B(`$ZodXID`,(e,t)=>{t.pattern??=za,K.init(e,t)}),$o=/*@__PURE__*/ B(`$ZodKSUID`,(e,t)=>{t.pattern??=Ba,K.init(e,t)}),es=/*@__PURE__*/ B(`$ZodISODateTime`,(e,t)=>{t.pattern??=so(t),K.init(e,t)}),ts=/*@__PURE__*/ B(`$ZodISODate`,(e,t)=>{t.pattern??=io,K.init(e,t)}),ns=/*@__PURE__*/ B(`$ZodISOTime`,(e,t)=>{t.pattern??=oo(t),K.init(e,t)}),rs=/*@__PURE__*/ B(`$ZodISODuration`,(e,t)=>{t.pattern??=Ua,K.init(e,t)}),is=/*@__PURE__*/ B(`$ZodIPv4`,(e,t)=>{t.pattern??=Ja,K.init(e,t)}),as=/^[0-9a-fA-F:.]+$/;function os(e){return as.test(e)?zo(`http://[${e}]`):!1}let ss=/*@__PURE__*/ B(`$ZodIPv6`,(e,t)=>{t.pattern??=Ya,K.init(e,t),e._zod.check=n=>{os(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),cs=/*@__PURE__*/ B(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Xa,K.init(e,t)});function ls(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:os(n)}let us=/*@__PURE__*/ B(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Za,K.init(e,t),e._zod.check=n=>{ls(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function ds(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let fs=/^[0-9a-zA-Z+/]*={0,2}$/,ps=/*@__PURE__*/ B(`$ZodBase64`,(e,t)=>{t.pattern??=fs,K.init(e,t),e._zod.check=n=>{ds(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),ms=/^[A-Za-z0-9_-]*$/;function hs(e){if(!ms.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return ds(t.padEnd(Math.ceil(t.length/4)*4,`=`))}let gs=/*@__PURE__*/ B(`$ZodBase64URL`,(e,t)=>{t.pattern??=ms,K.init(e,t),e._zod.check=n=>{hs(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),_s=/*@__PURE__*/ B(`$ZodE164`,(e,t)=>{t.pattern??=to,K.init(e,t)});function vs(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}let ys=/*@__PURE__*/ B(`$ZodJWT`,(e,t)=>{K.init(e,t),e._zod.check=n=>{vs(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),bs=/*@__PURE__*/ B(`$ZodNumber`,(e,t)=>{G.init(e,t),e._zod.pattern=lo,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),xs=/*@__PURE__*/ B(`$ZodNumberFormat`,(e,t)=>{vo.init(e,t),bs.init(e,t)}),Ss=/*@__PURE__*/ B(`$ZodUnknown`,(e,t)=>{G.init(e,t),e._zod.parse=e=>e}),Cs=/*@__PURE__*/ B(`$ZodNever`,(e,t)=>{G.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function ws(e,t){let n=zi(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of zi(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,Bi(n.issues,t,e),n}}return i(n,a)}}let Ts=e=>Array.isArray(e)?e.length:-1;function Es(e,t,n){e.issues.length&&t.issues.push(...Li(n,e.issues)),t.value[n]=e.value}let Ds=/*@__PURE__*/ B(`$ZodArray`,(e,t)=>{G.init(e,t);let n=H.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Es(t,r,e)));else if(Es(c,r,e),s&&c.issues.length!==0&&L(c))break}return o.length?Promise.all(o).then(()=>r):r},ws(e,Ts)});function Os(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Li(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}let ks=[];function As(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ks,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=wi(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function js(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(L(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Os(e,n,i,t,d,f))):Os(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}let Ms=/*@__PURE__*/ B(`$ZodObject`,(e,t)=>{G.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=oi(()=>As(t));z(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||j(n,e,/* @__PURE__ */ new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=_i,o=t.catchall,s,c=H.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(L(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>Os(n,t,e,r,a,o))):Os(s,t,e,r,a,o)}return o?js(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Ns=/*@__PURE__*/ B(`$ZodObjectJIT`,(e,t)=>{Ms.init(e,t);let n=e._zod.parse,r=oi(()=>As(t)),i=H.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Ao([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
6
+ let ${e}_ab = false;
7
+ for (let i = 0; i < ${e}.issues.length; i++) {
8
+ const iss = ${e}.issues[i];
9
+ iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
10
+ payload.issues.push(iss);
11
+ if (iss.continue !== true) ${e}_ab = true;
12
+ }
13
+ if (${e}_ab && ctx && ctx.abortEarly) {
14
+ payload.value = newResult;
15
+ return payload;
16
+ }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:mi(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
17
+ const ${n}_present = ${i};
18
+ if (!${n}.issues.length || ${n}_present) {
19
+ if (${n}.issues.length) {${c(n,r)}
20
+ }
21
+
22
+ if (${e}) {
23
+ newResult[${r}] = ${n}.value;
24
+ }
25
+ }
26
+
27
+ `)}else f?(o.write(`
28
+ if (${n}.issues.length) {${c(n,r)}
29
+ }
30
+ `),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
31
+ if (${n}.value !== undefined || ${i}) {
32
+ newResult[${r}] = ${n}.value;
33
+ }
34
+ `)):o.write(`
35
+ const ${n}_present = ${i};
36
+ if (${n}.issues.length) {${c(n,r)}
37
+ }
38
+ if (!${n}_present && !${n}.issues.length) {
39
+ payload.issues.push({
40
+ code: "invalid_type",
41
+ expected: "nonoptional",
42
+ input: undefined,
43
+ path: [${r}]
44
+ });
45
+ if (ctx && ctx.abortEarly) {
46
+ payload.value = newResult;
47
+ return payload;
48
+ }
49
+ }
50
+
51
+ if (${n}_present) {
52
+ newResult[${r}] = ${n}.value;
53
+ }
54
+
55
+ `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=_i,c=!H.jitless,l=c&&vi.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?js([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Ps(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!L(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Vi(e,r,U())))}),t)}let Fs=/*@__PURE__*/ B(`$ZodUnion`,(e,t)=>{G.init(e,t),z(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),z(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),z(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),z(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>ci(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Ps(t,r,e,i)):Ps(o,r,e,i)}}),Is=/*@__PURE__*/ B(`$ZodIntersection`,(e,t)=>{G.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Rs(e,t,n)):Rs(e,i,a)}});function Ls(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(yi(e)&&yi(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Ls(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ls(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Rs(e,t,n){let r=/* @__PURE__ */ new Map,i,a=/* @__PURE__ */ new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Ls(t.value,n.value);if(!c.valid){if(L(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}let zs=/*@__PURE__*/ B(`$ZodEnum`,(e,t)=>{G.init(e,t);let n=ni(t.entries),r=new Set(n);e._zod.values=r,z(e,`pattern`,e=>{let t=ni(e.def.entries).filter(e=>xi.has(typeof e));return RegExp(t.length?`^(${t.map(e=>Si(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Bs=/*@__PURE__*/ B(`$ZodTransform`,(e,t)=>{G.init(e,t),e._zod.optin=`optional`,H.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new sa(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new V;return n.value=i,n}});function Vs(e,t){return e.value=t.issues.length?void 0:t.value,e}let Hs=/*@__PURE__*/ B(`$ZodOptional`,(e,t)=>{G.init(e,t),z(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,z(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?/* @__PURE__ */ new Set([...t,void 0]):void 0}),z(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ci(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Vs(e,t)):Vs(e,r)}return t.innerType._zod.run(e,n)}}),Us=/*@__PURE__*/ B(`$ZodExactOptional`,(e,t)=>{Hs.init(e,t),z(e,`values`,e=>e.def.innerType._zod.values),z(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ws=/*@__PURE__*/ B(`$ZodNullable`,(e,t)=>{G.init(e,t),z(e,`optin`,e=>e.def.innerType._zod.optin),z(e,`optout`,e=>e.def.innerType._zod.optout),z(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${ci(t.source)}|null)$`):void 0}),z(e,`values`,e=>e.def.innerType._zod.values?/* @__PURE__ */ new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Gs=/*@__PURE__*/ B(`$ZodDefault`,(e,t)=>{G.init(e,t),e._zod.optin=`defaulted`,z(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ks(e,t)):Ks(r,t)}});function Ks(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}let qs=/*@__PURE__*/ B(`$ZodPrefault`,(e,t)=>{G.init(e,t),e._zod.optin=`defaulted`,z(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Js=/*@__PURE__*/ B(`$ZodNonOptional`,(e,t)=>{G.init(e,t),z(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ys(t,e)):Ys(i,e)}});function Ys(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Xs(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Vi(e,r,U()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}let Zs=/*@__PURE__*/ B(`$ZodCatch`,(e,t)=>{G.init(e,t),z(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),z(e,`optout`,e=>e.def.innerType._zod.optout),z(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Xs(e,r,t,n)):Xs(e,r,t,n)}}),Qs=/*@__PURE__*/ B(`$ZodPipe`,(e,t)=>{G.init(e,t),z(e,`values`,e=>e.def.in._zod.values),z(e,`optin`,e=>e.def.in._zod.optin),z(e,`optout`,e=>e.def.out._zod.optout),z(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>$s(e,t.in,n)):$s(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>$s(e,t.out,n)):$s(r,t.out,n)}});function $s(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}let ec=/*@__PURE__*/ B(`$ZodReadonly`,(e,t)=>{G.init(e,t),z(e,`propValues`,e=>e.def.innerType._zod.propValues),z(e,`values`,e=>e.def.innerType._zod.values),z(e,`optin`,e=>e.def.innerType?._zod?.optin),z(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(tc):tc(r)}});function tc(e){return e.memo||(e.value=Object.freeze(e.value)),e}let nc=/*@__PURE__*/ B(`$ZodCustom`,(e,t)=>{W.init(e,t),G.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>rc(t,n,r,e));rc(i,n,r,e)}});function rc(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Ki(e))}}var ic=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}};let ac=`~memo`,oc=[];function sc(e){return typeof e==`object`&&!!e}function cc(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}let lc=/*@__PURE__*/ new WeakMap;function uc(e,t,n){let r=lc.get(e);if(r!==void 0)return r?2:0;if(t.has(e))return 2;t.add(e);let i=0,a=e=>{if(i!==2&&e?._zod){let r=uc(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=0;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?1:o.value?._zod?uc(o.value,t,n):0;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=ui(c);s(e?o(e,!0):1),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?uc(r,t,!1):1);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),dc(e,i)}function dc(e,t){return t!==1&&lc.set(e,t===2),t}function fc(e,t){let n=e.buckets.get(t);return n||(n=/* @__PURE__ */ new WeakMap,e.buckets.set(t,n)),n}let pc,mc=[],hc={alloc(e,t,n){let r=pc;if(!r)return n;pc=void 0;let i={value:n,issues:null};return r.set(t.value,i),mc.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&_c(n,e.value))throw new ic;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=uc(e,/* @__PURE__ */ new Set,!1);if(i===0)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===2||r?n=!0:r=!0}let l=s.value;if(!sc(l))return t(s,c);let u=c[ac];u||(u={buckets:/* @__PURE__ */ new WeakMap,backEdges:void 0},c[ac]=u);let d;i===c?d=a:(d=fc(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...cc(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=/* @__PURE__ */ new WeakSet),u.backEdges.add(f.value)),s;pc=d;let p=mc.length,m=t(s,c);pc=void 0;let h=mc.length>p?mc.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?cc(e.issues):oc),e)):(h&&(h.issues=m.issues.length?cc(m.issues):oc),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function gc(){return hc}function _c(e,t){let n=e[ac]?.backEdges;return n!==void 0&&sc(t)&&n.has(t)}let vc=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Gi(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Ci(e.values[0])}`:`Invalid option: expected one of ${ri(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${ri(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function yc(){return{localeError:vc()}}var bc,xc=class{constructor(){this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=/* @__PURE__ */ new WeakMap,this._idmap=/* @__PURE__ */ new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Sc(){return new xc}(bc=globalThis).__zod_globalRegistry??(bc.__zod_globalRegistry=Sc());let Cc=globalThis.__zod_globalRegistry;function wc(e){return e.checks&&=[...e.checks],e}// @__NO_SIDE_EFFECTS__
56
+ function Tc(e,t){return new e(wc({type:`string`,...I(t)}))}// @__NO_SIDE_EFFECTS__
57
+ function Ec(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
58
+ function Dc(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
59
+ function Oc(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
60
+ function kc(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...I(t)})}// @__NO_SIDE_EFFECTS__
61
+ function Ac(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...I(t)})}// @__NO_SIDE_EFFECTS__
62
+ function jc(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...I(t)})}// @__NO_SIDE_EFFECTS__
63
+ function Mc(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
64
+ function Nc(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
65
+ function Pc(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
66
+ function Fc(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
67
+ function Ic(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
68
+ function Lc(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
69
+ function Rc(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
70
+ function zc(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
71
+ function Bc(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
72
+ function Vc(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
73
+ function Hc(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
74
+ function Uc(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
75
+ function Wc(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
76
+ function Gc(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
77
+ function Kc(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
78
+ function qc(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...I(t)})}// @__NO_SIDE_EFFECTS__
79
+ function Jc(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...I(t)})}// @__NO_SIDE_EFFECTS__
80
+ function Yc(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...I(t)})}// @__NO_SIDE_EFFECTS__
81
+ function Xc(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...I(t)})}// @__NO_SIDE_EFFECTS__
82
+ function Zc(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...I(t)})}// @__NO_SIDE_EFFECTS__
83
+ function Qc(e,t){return new e(wc({type:`number`,checks:[],...I(t)}))}// @__NO_SIDE_EFFECTS__
84
+ function $c(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...I(t)})}// @__NO_SIDE_EFFECTS__
85
+ function el(e){return new e({type:`unknown`})}// @__NO_SIDE_EFFECTS__
86
+ function tl(e,t){return new e({type:`never`,...I(t)})}// @__NO_SIDE_EFFECTS__
87
+ function nl(e,t){return new ho({check:`less_than`,...I(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
88
+ function rl(e,t){return new ho({check:`less_than`,...I(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
89
+ function il(e,t){return new go({check:`greater_than`,...I(t),value:e,inclusive:!1})}// @__NO_SIDE_EFFECTS__
90
+ function al(e,t){return new go({check:`greater_than`,...I(t),value:e,inclusive:!0})}// @__NO_SIDE_EFFECTS__
91
+ function ol(e,t){return new _o({check:`multiple_of`,...I(t),value:e})}// @__NO_SIDE_EFFECTS__
92
+ function sl(e,t){return new yo({check:`max_length`,...I(t),maximum:e})}// @__NO_SIDE_EFFECTS__
93
+ function cl(e,t){return new bo({check:`min_length`,...I(t),minimum:e})}// @__NO_SIDE_EFFECTS__
94
+ function ll(e,t){return new xo({check:`length_equals`,...I(t),length:e})}// @__NO_SIDE_EFFECTS__
95
+ function ul(e,t){return new Co({check:`string_format`,format:`regex`,...I(t),pattern:e})}// @__NO_SIDE_EFFECTS__
96
+ function dl(e){return new wo({check:`string_format`,format:`lowercase`,...I(e)})}// @__NO_SIDE_EFFECTS__
97
+ function fl(e){return new To({check:`string_format`,format:`uppercase`,...I(e)})}// @__NO_SIDE_EFFECTS__
98
+ function pl(e,t){return new Eo({check:`string_format`,format:`includes`,...I(t),includes:e})}// @__NO_SIDE_EFFECTS__
99
+ function ml(e,t){return new Do({check:`string_format`,format:`starts_with`,...I(t),prefix:e})}// @__NO_SIDE_EFFECTS__
100
+ function hl(e,t){return new Oo({check:`string_format`,format:`ends_with`,...I(t),suffix:e})}// @__NO_SIDE_EFFECTS__
101
+ function q(e){return new ko({check:`overwrite`,tx:e})}// @__NO_SIDE_EFFECTS__
102
+ function gl(e){return/* @__PURE__ */ q(t=>t.normalize(e))}// @__NO_SIDE_EFFECTS__
103
+ function _l(){return/* @__PURE__ */ q(e=>e.trim())}// @__NO_SIDE_EFFECTS__
104
+ function vl(){return/* @__PURE__ */ q(e=>e.toLowerCase())}// @__NO_SIDE_EFFECTS__
105
+ function yl(){return/* @__PURE__ */ q(e=>e.toUpperCase())}// @__NO_SIDE_EFFECTS__
106
+ function bl(){return/* @__PURE__ */ q(e=>hi(e))}// @__NO_SIDE_EFFECTS__
107
+ function xl(e,t,n){return new e({type:`array`,element:t,...I(n)})}// @__NO_SIDE_EFFECTS__
108
+ function Sl(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...I(n)})}// @__NO_SIDE_EFFECTS__
109
+ function Cl(e,t){let n=/* @__PURE__ */ wl(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Ki(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Ki(r))}},e(t.value,t)),t);return n}// @__NO_SIDE_EFFECTS__
110
+ function wl(e,t){let n=new W({check:`custom`,...I(t)});return n._zod.check=e,n}function Tl(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&j(e,t,n[t]);return e}function El(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Cc,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:/* @__PURE__ */ new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Dl(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function J(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,J(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Tl(o.schema,c),t.io===`input`&&Y(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Ol(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function kl(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=/* @__PURE__ */ new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Ol(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Ol(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
111
+
112
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Al(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Al(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}let jl=/* @__PURE__ */ new Set([`type`,`properties`,`required`,`additionalProperties`]),Ml=[`oneOf`,`anyOf`];function Nl(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Pl(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!jl.has(e))return null;t.push(n)}let n={},r=/* @__PURE__ */ new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Nl(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}j(n,r,e.length===1?e[0]:Pl(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Nl(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Fl(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of jl)if(t in e)return;let n=t.filter(e=>Ml.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Pl(t);else{let e=n[0],i=Ml.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Pl([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Tl(e,r))}function Il(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Tl(i,s),Tl(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Al(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=/* @__PURE__ */ new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Fl(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Tl(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,j(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:Rl(t,`input`,e.processors),output:Rl(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Y(e,t){let n=t??{seen:/* @__PURE__ */ new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Y(r.element,n);if(r.type===`set`)return Y(r.valueType,n);if(r.type===`lazy`)return Y(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Y(r.innerType,n);if(r.type===`intersection`)return Y(r.left,n)||Y(r.right,n);if(r.type===`record`||r.type===`map`)return Y(r.keyType,n)||Y(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Y(r.in,n)||Y(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Y(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Y(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Y(e,n))return!0;return!!(r.rest&&Y(r.rest,n))}return!1}let Ll=(e,t={})=>n=>{let r=El({...n,processors:t});return J(e,r),kl(r,e),Il(r,e)},Rl=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=El({...i??{},target:a,io:t,processors:n});return J(e,o),kl(o,e),Il(o,e)},zl=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Bl=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Vl=(e,t)=>{zl(e,`minimum`,t),Bl(e,`maximum`,t)},Hl=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Ul=(e,t)=>{e.patterns??=/* @__PURE__ */ new Set,e.patterns.add(t)},Wl=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Gl=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},Kl=(e,t)=>zl(e,`minimum`,t.minimum),ql=(e,t)=>Bl(e,`maximum`,t.maximum),Jl=e=>(t,n)=>{Gl(t,n.format);let[r,i]=e[n.format];zl(t,`minimum`,r),Bl(t,`maximum`,i)},Yl={greater_than:(e,t)=>zl(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Bl(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Hl(e,t.value),number_format:Jl(Ti),bigint_format:Jl(Ei),min_length:Kl,max_length:ql,length_equals:(e,t)=>Vl(e,t.length),min_size:Kl,max_size:ql,size_equals:(e,t)=>Vl(e,t.size),string_format:(e,t)=>{Gl(e,t.format),t.pattern&&Ul(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Wl(e,t.mime)};function X(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Yl[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&zl(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&zl(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Bl(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Bl(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Hl(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Wl(t,i.mime);for(let e of i.patterns??[])Ul(t,e);return t}let Xl={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},Zl=/* @__PURE__ */ new Map([[fs,Qa],[ms,$a]]),Ql=e=>Zl.get(e)??e,$l=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=X(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Xl[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(Ql);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},eu=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=X(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=/* @__PURE__ */ new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Dl(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},tu=(e,t,n,r)=>{n.not={}},nu=(e,t,n,r)=>{let i=e._zod.def,a=ni(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},ru=(e,t,n,r)=>{Dl(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},iu=(e,t,n,r)=>{Dl(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},au=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=X(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=J(a.element,t,{...r,path:[...r.path,`items`]})};function ou(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?ou(t.out):t.type===`catch`?ou(t.innerType):e._zod.optin}let su=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Dl(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)j(i.properties,e,J(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?ou(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=J(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},cu=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>J(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},lu=(e,t,n,r)=>{let i=e._zod.def,a=J(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=J(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},uu=(e,t,n,r)=>{let i=e._zod.def,a=J(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},du=(e,t,n,r)=>{let i=e._zod.def;J(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},fu=Symbol();function pu(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Dl(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),fu):JSON.parse(o)}let mu=(e,t,n,r)=>{let i=e._zod.def;J(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=pu(i.defaultValue,e,t,n,r);o!==fu&&(n.default=o)},hu=(e,t,n,r)=>{let i=e._zod.def;J(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=pu(i.defaultValue,e,t,n,r);o!==fu&&(n._prefault=o)},gu=(e,t,n,r)=>{let i=e._zod.def;J(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Dl(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},_u=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;J(o,t,r);let s=t.seen.get(e);s.ref=o},vu=(e,t,n,r)=>{let i=e._zod.def;J(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},yu=(e,t,n,r)=>{let i=e._zod.def;J(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},bu=/* @__PURE__ */ new WeakSet([Object.prototype,Error.prototype]);function xu(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}let Z=/*@__PURE__*/ B(`ZodError`,(e,t)=>{pa.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);bu.has(n)||(bu.add(n),xu(n,`format`,e=>t=>ga(e,t)),xu(n,`flatten`,e=>t=>ha(e,t)),xu(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,ii,2)}),xu(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,ii,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Su=/* @__PURE__ */ va(Z),Cu=/* @__PURE__ */ ya(Z),wu=/* @__PURE__ */ ba(Z),Tu=/* @__PURE__ */ Sa(Z),Eu=/* @__PURE__ */ Oa(Z),Du=/* @__PURE__ */ ka(Z),Ou=/* @__PURE__ */ Aa(Z),ku=/* @__PURE__ */ ja(Z),Au=/* @__PURE__ */ Ma(Z),ju=/* @__PURE__ */ Na(Z),Mu=/* @__PURE__ */ Pa(Z),Nu=/* @__PURE__ */ Fa(Z);function Pu(){H.localeError||U(yc())}function Fu(){H.memoizer||U({memoizer:gc()})}let Q=/*@__PURE__*/ B(`ZodType`,(e,t)=>(Pu(),G.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(P(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return F(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(qd(e,t))},superRefine(e,t){return this.check(Jd(e,t))},overwrite(e){return this.check(/* @__PURE__ */ q(e))},optional(){return kd(this)},exactOptional(){return jd(this)},nullable(){return Nd(this)},nullish(){return kd(Nd(this))},nonoptional(e){return zd(this,e)},array(){return _d(this)},or(e){return xd([this,e])},and(e){return Cd(this,e)},transform(e){return Ud(this,Dd(e))},default(e){return Fd(this,e)},prefault(e){return Ld(this,e)},catch(e){return Vd(this,e)},pipe(e){return Ud(this,e)},readonly(){return Gd(this)},describe(e){let t=this.clone();return Cc.add(t,{description:e}),t},meta(...e){if(e.length===0)return Cc.get(this);let t=this.clone();return Cc.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Ji(this,`~standard`,{...Po(this),jsonSchema:{input:Rl(this,`input`),output:Rl(this,`output`)}})},set"~standard"(e){R(this,`~standard`,e)},parse:function e(t,n){return Su(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await Cu(this,t,n,{callee:e})},safeParse(e,t){return wu(this,e,t)},async safeParseAsync(e,t){return Tu(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){R(this,`spa`,e)},validate(e,t){return Ta(this,e,t)},validateAsync(e,t){return Da(this,e,t)},encode:function e(t,n){return Eu(this,t,n,{callee:e})},decode:function e(t,n){return Du(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Ou(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await ku(this,t,n,{callee:e})},safeEncode(e,t){return Au(this,e,t)},safeDecode(e,t){return ju(this,e,t)},async safeEncodeAsync(e,t){return Mu(this,e,t)},async safeDecodeAsync(e,t){return Nu(this,e,t)},toJSONSchema(e){return Ll(this,{})(e)},get description(){return Cc.get(this)?.description},get _def(){return this._zod.def}}),Iu=/*@__PURE__*/ B(`_ZodString`,(e,t)=>{Fo.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>$l(e,t,n,r)},/*@__PURE__*/ Yi({format:e=>X(e).format??null,minLength:e=>X(e).minimum??null,maxLength:e=>X(e).maximum??null},{regex(...e){return this.check(/* @__PURE__ */ ul(...e))},includes(...e){return this.check(/* @__PURE__ */ pl(...e))},startsWith(...e){return this.check(/* @__PURE__ */ ml(...e))},endsWith(...e){return this.check(/* @__PURE__ */ hl(...e))},min(...e){return this.check(/* @__PURE__ */ cl(...e))},max(...e){return this.check(/* @__PURE__ */ sl(...e))},length(...e){return this.check(/* @__PURE__ */ ll(...e))},nonempty(...e){return this.check(/* @__PURE__ */ cl(1,...e))},lowercase(e){return this.check(/* @__PURE__ */ dl(e))},uppercase(e){return this.check(/* @__PURE__ */ fl(e))},trim(){return this.check(/* @__PURE__ */ _l())},normalize(...e){return this.check(/* @__PURE__ */ gl(...e))},toLowerCase(){return this.check(/* @__PURE__ */ vl())},toUpperCase(){return this.check(/* @__PURE__ */ yl())},slugify(){return this.check(/* @__PURE__ */ bl())}})),Lu=/*@__PURE__*/ B(`ZodString`,(e,t)=>{Fo.init(e,t),Iu.init(e,t)},{email(e){return this.check(/* @__PURE__ */ Ec(Uu,e))},url(e){return this.check(/* @__PURE__ */ Mc(Ku,e))},jwt(e){return this.check(/* @__PURE__ */ qc(sd,e))},emoji(e){return this.check(/* @__PURE__ */ Nc(qu,e))},guid(e){return this.check(/* @__PURE__ */ Dc(Wu,e))},uuid(e){return this.check(/* @__PURE__ */ Oc(Gu,e))},uuidv4(e){return this.check(/* @__PURE__ */ kc(Gu,e))},uuidv6(e){return this.check(/* @__PURE__ */ Ac(Gu,e))},uuidv7(e){return this.check(/* @__PURE__ */ jc(Gu,e))},nanoid(e){return this.check(/* @__PURE__ */ Pc(Ju,e))},cuid(e){return this.check(/* @__PURE__ */ Fc(Yu,e))},cuid2(e){return this.check(/* @__PURE__ */ Ic(Xu,e))},ulid(e){return this.check(/* @__PURE__ */ Lc(Zu,e))},base64(e){return this.check(/* @__PURE__ */ Wc(id,e))},base64url(e){return this.check(/* @__PURE__ */ Gc(ad,e))},xid(e){return this.check(/* @__PURE__ */ Rc(Qu,e))},ksuid(e){return this.check(/* @__PURE__ */ zc($u,e))},ipv4(e){return this.check(/* @__PURE__ */ Bc(ed,e))},ipv6(e){return this.check(/* @__PURE__ */ Vc(td,e))},cidrv4(e){return this.check(/* @__PURE__ */ Hc(nd,e))},cidrv6(e){return this.check(/* @__PURE__ */ Uc(rd,e))},e164(e){return this.check(/* @__PURE__ */ Kc(od,e))},datetime(e){return this.check(/* @__PURE__ */ Jc(zu,e))},date(e){return this.check(/* @__PURE__ */ Yc(Bu,e))},time(e){return this.check(/* @__PURE__ */ Xc(Vu,e))},duration(e){return this.check(/* @__PURE__ */ Zc(Hu,e))}});function Ru(e){return/* @__PURE__ */ Tc(Lu,e)}let $=/*@__PURE__*/ B(`ZodStringFormat`,(e,t)=>{K.init(e,t),Iu.init(e,t)}),zu=/*@__PURE__*/ B(`ZodISODateTime`,(e,t)=>{es.init(e,t),$.init(e,t)}),Bu=/*@__PURE__*/ B(`ZodISODate`,(e,t)=>{ts.init(e,t),$.init(e,t)}),Vu=/*@__PURE__*/ B(`ZodISOTime`,(e,t)=>{ns.init(e,t),$.init(e,t)}),Hu=/*@__PURE__*/ B(`ZodISODuration`,(e,t)=>{rs.init(e,t),$.init(e,t)}),Uu=/*@__PURE__*/ B(`ZodEmail`,(e,t)=>{Ro.init(e,t),$.init(e,t)}),Wu=/*@__PURE__*/ B(`ZodGUID`,(e,t)=>{Io.init(e,t),$.init(e,t)}),Gu=/*@__PURE__*/ B(`ZodUUID`,(e,t)=>{Lo.init(e,t),$.init(e,t)}),Ku=/*@__PURE__*/ B(`ZodURL`,(e,t)=>{Ko.init(e,t),$.init(e,t)}),qu=/*@__PURE__*/ B(`ZodEmoji`,(e,t)=>{qo.init(e,t),$.init(e,t)}),Ju=/*@__PURE__*/ B(`ZodNanoID`,(e,t)=>{Jo.init(e,t),$.init(e,t)}),Yu=/*@__PURE__*/ B(`ZodCUID`,(e,t)=>{Yo.init(e,t),$.init(e,t)}),Xu=/*@__PURE__*/ B(`ZodCUID2`,(e,t)=>{Xo.init(e,t),$.init(e,t)}),Zu=/*@__PURE__*/ B(`ZodULID`,(e,t)=>{Zo.init(e,t),$.init(e,t)}),Qu=/*@__PURE__*/ B(`ZodXID`,(e,t)=>{Qo.init(e,t),$.init(e,t)}),$u=/*@__PURE__*/ B(`ZodKSUID`,(e,t)=>{$o.init(e,t),$.init(e,t)}),ed=/*@__PURE__*/ B(`ZodIPv4`,(e,t)=>{is.init(e,t),$.init(e,t)}),td=/*@__PURE__*/ B(`ZodIPv6`,(e,t)=>{ss.init(e,t),$.init(e,t)}),nd=/*@__PURE__*/ B(`ZodCIDRv4`,(e,t)=>{cs.init(e,t),$.init(e,t)}),rd=/*@__PURE__*/ B(`ZodCIDRv6`,(e,t)=>{us.init(e,t),$.init(e,t)}),id=/*@__PURE__*/ B(`ZodBase64`,(e,t)=>{ps.init(e,t),$.init(e,t)}),ad=/*@__PURE__*/ B(`ZodBase64URL`,(e,t)=>{gs.init(e,t),$.init(e,t)}),od=/*@__PURE__*/ B(`ZodE164`,(e,t)=>{_s.init(e,t),$.init(e,t)}),sd=/*@__PURE__*/ B(`ZodJWT`,(e,t)=>{ys.init(e,t),$.init(e,t)}),cd=/*@__PURE__*/ B(`ZodNumber`,(e,t)=>{bs.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>eu(e,t,n,r),e.isFinite=!0},/*@__PURE__*/ Yi({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=X(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=X(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=X(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>X(e).format??null},{gt(e,t){return this.check(/* @__PURE__ */ il(e,t))},gte(e,t){return this.check(/* @__PURE__ */ al(e,t))},min(e,t){return this.check(/* @__PURE__ */ al(e,t))},lt(e,t){return this.check(/* @__PURE__ */ nl(e,t))},lte(e,t){return this.check(/* @__PURE__ */ rl(e,t))},max(e,t){return this.check(/* @__PURE__ */ rl(e,t))},int(e){return this.check(dd(e))},safe(e){return this.check(dd(e))},positive(e){return this.check(/* @__PURE__ */ il(0,e))},nonnegative(e){return this.check(/* @__PURE__ */ al(0,e))},negative(e){return this.check(/* @__PURE__ */ nl(0,e))},nonpositive(e){return this.check(/* @__PURE__ */ rl(0,e))},multipleOf(e,t){return this.check(/* @__PURE__ */ ol(e,t))},step(e,t){return this.check(/* @__PURE__ */ ol(e,t))},finite(){return this}}));function ld(e){return/* @__PURE__ */ Qc(cd,e)}let ud=/*@__PURE__*/ B(`ZodNumberFormat`,(e,t)=>{xs.init(e,t),cd.init(e,t)});function dd(e){return/* @__PURE__ */ $c(ud,e)}let fd=/*@__PURE__*/ B(`ZodUnknown`,(e,t)=>{Ss.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function pd(){return/* @__PURE__ */ el(fd)}let md=/*@__PURE__*/ B(`ZodNever`,(e,t)=>{Cs.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tu(e,t,n,r)});function hd(e){return/* @__PURE__ */ tl(md,e)}let gd=/*@__PURE__*/ B(`ZodArray`,(e,t)=>{Fu(),Ds.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>au(e,t,n,r),e.element=t.element},{min(e,t){return this.check(/* @__PURE__ */ cl(e,t))},nonempty(e){return this.check(/* @__PURE__ */ cl(1,e))},max(e,t){return this.check(/* @__PURE__ */ sl(e,t))},length(e,t){return this.check(/* @__PURE__ */ ll(e,t))},unwrap(){return this.element}});function _d(e,t){return/* @__PURE__ */ xl(gd,e,t)}let vd=/*@__PURE__*/ B(`ZodObject`,(e,t)=>{Fu(),Ns.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>su(e,t,n,r),ta(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Td(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(P(this._zod.def,{catchall:e}))},passthrough(){return this.clone(P(this._zod.def,{catchall:pd()}))},loose(){return this.clone(P(this._zod.def,{catchall:pd()}))},strict(){return this.clone(P(this._zod.def,{catchall:hd()}))},strip(){return this.clone(P(this._zod.def,{catchall:void 0}))},extend(e){return Ai(this,e)},safeExtend(e){return Mi(this,e)},merge(e){return Ni(this,e)},pick(e){return Di(this,e)},omit(e){return ki(this,e)},partial(...e){return Pi(Od,this,e[0])},exactPartial(...e){return Pi(Ad,this,e[0],`exactPartial`)},required(...e){return Fi(Rd,this,e[0])}});function yd(e,t){let n={type:`object`,shape:e??{},...I(t)};return new vd(n)}let bd=/*@__PURE__*/ B(`ZodUnion`,(e,t)=>{Fs.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cu(e,t,n,r),e.options=t.options});function xd(e,t){return new bd({type:`union`,options:e,...I(t)})}let Sd=/*@__PURE__*/ B(`ZodIntersection`,(e,t)=>{Is.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lu(e,t,n,r)});function Cd(e,t){return new Sd({type:`intersection`,left:e,right:t})}let wd=/*@__PURE__*/ B(`ZodEnum`,(e,t)=>{zs.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nu(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new wd({...t,checks:[],...I(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new wd({...t,checks:[],...I(r),entries:i})}});function Td(e,t){let n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new wd({type:`enum`,entries:n,...I(t)})}let Ed=/*@__PURE__*/ B(`ZodTransform`,(e,t)=>{Fu(),Bs.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>iu(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new sa(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ki(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Ki(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Dd(e){return new Ed({type:`transform`,transform:e})}let Od=/*@__PURE__*/ B(`ZodOptional`,(e,t)=>{Hs.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yu(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function kd(e){return new Od({type:`optional`,innerType:e})}let Ad=/*@__PURE__*/ B(`ZodExactOptional`,(e,t)=>{Us.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yu(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function jd(e){return new Ad({type:`optional`,innerType:e})}let Md=/*@__PURE__*/ B(`ZodNullable`,(e,t)=>{Ws.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>uu(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Nd(e){return new Md({type:`nullable`,innerType:e})}let Pd=/*@__PURE__*/ B(`ZodDefault`,(e,t)=>{Gs.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mu(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Fd(e,t){return new Pd({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():bi(t)}})}let Id=/*@__PURE__*/ B(`ZodPrefault`,(e,t)=>{qs.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hu(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ld(e,t){return new Id({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():bi(t)}})}let Rd=/*@__PURE__*/ B(`ZodNonOptional`,(e,t)=>{Js.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>du(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function zd(e,t){return new Rd({type:`nonoptional`,innerType:e,...I(t)})}let Bd=/*@__PURE__*/ B(`ZodCatch`,(e,t)=>{Zs.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gu(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Vd(e,t){return new Bd({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:na(t)})}let Hd=/*@__PURE__*/ B(`ZodPipe`,(e,t)=>{Qs.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_u(e,t,n,r),e.in=t.in,e.out=t.out});function Ud(e,t){return new Hd({type:`pipe`,in:e,out:t})}let Wd=/*@__PURE__*/ B(`ZodReadonly`,(e,t)=>{ec.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vu(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Gd(e){return new Wd({type:`readonly`,innerType:e})}let Kd=/*@__PURE__*/ B(`ZodCustom`,(e,t)=>{nc.init(e,t),Q.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ru(e,t,n,r)});function qd(e,t={}){return/* @__PURE__ */ Sl(Kd,e,t)}function Jd(e,t){return/* @__PURE__ */ Cl(e,t)}yd({query:Ru().optional(),type:Ru().optional(),package:Ru().optional(),tag:Ru().optional(),path:Ru().optional(),limit:ld().int().min(1).max(200).optional(),offset:ld().int().min(0).optional()});function Yd(e,t,n){return e==null||!Number.isFinite(e)?t:Math.min(Math.max(1,Math.floor(e)),n)}function Xd(e){return e==null||!Number.isFinite(e)?0:Math.max(0,Math.floor(e))}function Zd(e){if(e!=null)return Yd(e,20,200)}function Qd(e,t){return{unique_id:e,resource_type:t.resource_type,name:t.name,package_name:t.package_name,path:t.path,tags:t.tags,description:t.description}}function $d(e,t){let n=t.query?$r(t.query):{terms:[]},r=t.type??n.type,i=t.package??n.package,a=t.tag??n.tag,o=t.path??n.path,s=[];e.getGraph().forEachNode((e,t)=>{if(!ei(t,r,i,a,o))return;let c=ti(t,n.terms);c!==0&&s.push({score:c,result:Qd(e,t)})}),s.sort((e,t)=>t.score===e.score?e.result.unique_id.localeCompare(t.result.unique_id):t.score-e.score);let c=Zd(t.limit),l=Xd(t.offset);if(l>0&&c==null)throw Error(`offset requires limit`);let u=s.map(e=>e.result),d=c==null?u:u.slice(l,l+c);return{query:t.query||void 0,total:u.length,results:d,offset:l,...c==null?{}:{limit:c,has_more:l+d.length<u.length}}}var ef=Wr(),tf=Kr(),nf=Jr(),rf=Xr();function af(e){let t=e.origin;if(t===``||t===`null`)return!0;try{return t===globalThis.location.origin}catch{return!1}}function of(){return performance.now()}let sf=null,cf=null,lf=0,uf=`No analysis loaded`;function df(e,t){return{type:`analysis-error`,protocolVersion:4,requestId:e,message:t}}function ff(e,t){return{type:`resource-code-error`,protocolVersion:4,requestId:e,message:t}}function pf(e,t){return{type:`search-resources-error`,protocolVersion:4,requestId:e,message:t}}function mf(e){let t=new TextDecoder().decode(e);return JSON.parse(t)}function hf(e){return e==null?void 0:mf(e)}function gf(e,t){let n=e.getGraph();if(!n.hasNode(t))return{compiledCode:null,rawCode:null};let r=n.getNodeAttributes(t);return{compiledCode:typeof r.compiled_code==`string`?r.compiled_code:null,rawCode:typeof r.raw_code==`string`?r.raw_code:typeof r.raw_sql==`string`?r.raw_sql:null}}function _f(e){if(e.protocolVersion!==4)return pf(e.requestId,`Unsupported protocol version: ${e.protocolVersion}`);if(!cf||!sf)return pf(e.requestId,uf);let t=e.query.trim(),n;if(t){let e=new Map(cf.map(e=>[e.uniqueId,e]));n=$d(sf,{query:t,limit:8}).results.map(t=>e.get(t.unique_id)??null).filter(e=>e!=null)}else n=cf.slice(0,8);return{type:`search-resources-ready`,protocolVersion:4,requestId:e.requestId,resources:n}}function vf(e){if(e.protocolVersion!==4)return ff(e.requestId,`Unsupported protocol version: ${e.protocolVersion}`);if(!sf)return ff(e.requestId,uf);let{compiledCode:t,rawCode:n}=gf(sf,e.uniqueId);return{type:`resource-code-ready`,protocolVersion:4,requestId:e.requestId,compiledCode:t,rawCode:n}}async function yf(e){if(e.protocolVersion!==4)return df(e.requestId,`Unsupported protocol version: ${e.protocolVersion}`);let t=++lf;try{let n=of(),r=of(),i=mf(e.artifactBuffers.manifestBytes),a=hf(e.artifactBuffers.runResultsBytes),o=hf(e.artifactBuffers.catalogBytes),s=hf(e.artifactBuffers.sourcesBytes),c=of()-r,l=of(),u=(0,ef.parseManifest)(i),d=a==null?void 0:(0,tf.parseRunResults)(a),f=o==null?void 0:(0,nf.parseCatalog)(o),p=s==null?void 0:(0,rf.parseSources)(s),m=of()-l,{analysis:h,timings:g,graph:_}=Qr({manifestJson:i,runResultsJson:a,catalogJson:o,sourcesJson:s,manifest:u,runResults:d,catalog:f,sources:p});t===lf&&(sf=_,cf=h.resources);let v={decodeMs:c,parseMs:m,graphBuildMs:g.graphBuildMs,snapshotBuildMs:g.snapshotBuildMs,totalWorkerMs:of()-n};return{type:`analysis-ready`,protocolVersion:4,requestId:e.requestId,analysis:h,timings:v}}catch(t){return df(e.requestId,t instanceof Error?t.message:`Failed to analyze artifacts`)}}function bf(e){return e.type===`get-resource-code`?Promise.resolve(vf(e)):e.type===`search-resources`?Promise.resolve(_f(e)):yf(e)}function xf(e){return typeof e==`object`&&!!e&&e.type===`invalidate-pending-loads`}typeof self<`u`&&(self.onmessage=e=>{af(e)&&(xf(e.data)?lf+=1:bf(e.data).then(e=>{self.postMessage(e)}))})})();