@processfocus/cli 0.1.0-next.1 → 0.1.0-next.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +82 -699
  2. package/dist/bundle-organisation.mjs +2 -0
  3. package/dist/bundled-db-import.mjs +103 -120
  4. package/dist/bundled-graphql-schema.mjs +17 -15
  5. package/dist/command-reference.md +571 -0
  6. package/dist/main.mjs +325 -313
  7. package/dist/pfcli.usage.kdl +377 -0
  8. package/dist/prepare-deployment-artifact.mjs +2 -2
  9. package/dist/resources/cedar/policies.cedar +80 -38
  10. package/dist/resources/cedar/schema.cedarschema +39 -21
  11. package/dist/resources/system-migrations/20260925020504_panoramic_klaw/migration.sql +1 -0
  12. package/dist/resources/system-migrations/20260925020504_panoramic_klaw/snapshot.json +7708 -0
  13. package/dist/resources/system-migrations/20261013060336_pretty_mulholland_black/migration.sql +14 -0
  14. package/dist/resources/system-migrations/20261013060336_pretty_mulholland_black/snapshot.json +7852 -0
  15. package/dist/resources/system-migrations/20261019050118_aberrant_jetstream/migration.sql +4 -0
  16. package/dist/resources/system-migrations/20261019050118_aberrant_jetstream/snapshot.json +7908 -0
  17. package/dist/resources/system-migrations/20261023074259_previous_falcon/migration.sql +1 -0
  18. package/dist/resources/system-migrations/20261023074259_previous_falcon/snapshot.json +7918 -0
  19. package/dist/resources/system-migrations/20261023211931_black_vision/migration.sql +1 -0
  20. package/dist/resources/system-migrations/20261023211931_black_vision/snapshot.json +7928 -0
  21. package/dist/resources/system-migrations/20261024022040_magenta_dreaming_celestial/migration.sql +4 -0
  22. package/dist/resources/system-migrations/20261024022040_magenta_dreaming_celestial/snapshot.json +7968 -0
  23. package/dist/resources/system-migrations/20261025201326_confused_mordo/migration.sql +25 -0
  24. package/dist/resources/system-migrations/20261025201326_confused_mordo/snapshot.json +8141 -0
  25. package/dist/resources/system-migrations/20261025225809_pink_mysterio/migration.sql +20 -0
  26. package/dist/resources/system-migrations/20261025225809_pink_mysterio/snapshot.json +8350 -0
  27. package/dist/resources/system-migrations/20261030073445_fuzzy_patriot/migration.sql +1 -0
  28. package/dist/resources/system-migrations/20261030073445_fuzzy_patriot/snapshot.json +8360 -0
  29. package/dist/resources/system-migrations/20261101232313_curved_siren/migration.sql +3 -0
  30. package/dist/resources/system-migrations/20261101232313_curved_siren/snapshot.json +8390 -0
  31. package/dist/resources/system-migrations/20261111225459_real_overlord/migration.sql +13 -0
  32. package/dist/resources/system-migrations/20261111225459_real_overlord/snapshot.json +8511 -0
  33. package/dist/resources/system-migrations/20261112002154_fresh_mikhail_rasputin/migration.sql +1 -0
  34. package/dist/resources/system-migrations/20261112002154_fresh_mikhail_rasputin/snapshot.json +8501 -0
  35. package/dist/resources/system-migrations/20261116032801_numerous_taskmaster/migration.sql +1 -0
  36. package/dist/resources/system-migrations/20261116032801_numerous_taskmaster/snapshot.json +8511 -0
  37. package/dist/resources/system-migrations/20261119201444_settings-login-audit-index/migration.sql +3 -0
  38. package/dist/resources/system-migrations/20261119201444_settings-login-audit-index/snapshot.json +8511 -0
  39. package/dist/resources/system-migrations/20261119223342_lucky_lester/migration.sql +3 -0
  40. package/dist/resources/system-migrations/20261119223342_lucky_lester/snapshot.json +8367 -0
  41. package/dist/resources/system-migrations/20261123050259_sad_dagger/migration.sql +1 -0
  42. package/dist/resources/system-migrations/20261123050259_sad_dagger/snapshot.json +8377 -0
  43. package/package.json +11 -9
@@ -1,8 +1,8 @@
1
1
  // @bun
2
- var ti=Object.create;var{getPrototypeOf:ni,defineProperty:yr,getOwnPropertyNames:ri}=Object;var gr=Object.prototype.hasOwnProperty;function oi(e){return this[e]}var ii,si,Q=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var o=t?ii??=new WeakMap:si??=new WeakMap,i=o.get(e);if(i)return i}n=e!=null?ti(ni(e)):{};let s=t||!e||!e.__esModule||!gr.call(e,"default")?yr(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of ri(e))if(!gr.call(s,a))yr(s,a,{get:oi.bind(e,a),enumerable:!0})}if(r)o.set(e,s);return s};var te=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ai=import.meta.require;var $e=te(function(wt,hn){Object.defineProperty(wt,"__esModule",{value:!0});wt.default=di;function di(e){if(e===void 0||e===null)throw TypeError("Expected a string but received a ".concat(e));if(e.constructor.name!=="String")throw TypeError("Expected a string but received a ".concat(e.constructor.name))}hn.exports=wt.default;hn.exports.default=wt.default});var Tn=te(function(Et,Sn){Object.defineProperty(Et,"__esModule",{value:!0});Et.default=li;function ci(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function li(e,t){for(var n=0;n<t.length;n++){var r=t[n];if(e===r||ci(r)&&r.test(e))return!0}return!1}Sn.exports=Et.default;Sn.exports.default=Et.default});var Sr=te(function(kt,xn){Object.defineProperty(kt,"__esModule",{value:!0});kt.default=void 0;var fi=function(t,n){return t.indexOf(n)!==-1},Dc=kt.default=fi;xn.exports=kt.default;xn.exports.default=kt.default});var Rt=te(function(Ot,bn){Object.defineProperty(Ot,"__esModule",{value:!0});Ot.default=mi;function Fn(e){return Fn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fn(e)}function mi(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;if(Fn(e)!=="object"||e===null)e={};for(var n in t)if(typeof e[n]>"u")e[n]=t[n];return e}bn.exports=Ot.default;bn.exports.default=Ot.default});var En=te(function(At,wn){Object.defineProperty(At,"__esModule",{value:!0});At.default=Ti;var gi=Tr($e()),hi=Tr(Rt());function Tr(e){return e&&e.__esModule?e:{default:e}}var Si={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};function Ti(e,t){if((0,gi.default)(e),t=(0,hi.default)(t,Si),t.allow_trailing_dot&&e[e.length-1]===".")e=e.substring(0,e.length-1);if(t.allow_wildcard===!0&&e.indexOf("*.")===0)e=e.substring(2);var n=e.split("."),r=n[n.length-1];if(t.require_tld){if(n.length<2)return!1;if(!t.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(r))return!1;if(/\s/.test(r))return!1}if(!t.allow_numeric_tld&&/^\d+$/.test(r))return!1;return n.every(function(o){if(o.length>63&&!t.ignore_max_length)return!1;if(!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(o))return!1;if(/[\uff01-\uff5e]/.test(o))return!1;if(/^-|-$/.test(o))return!1;if(!t.allow_underscores&&/_/.test(o))return!1;return!0})}wn.exports=At.default;wn.exports.default=At.default});var An=te(function(_t,Rn){Object.defineProperty(_t,"__esModule",{value:!0});_t.default=On;var Fi=bi($e());function bi(e){return e&&e.__esModule?e:{default:e}}function kn(e){return kn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},kn(e)}var xr="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",Ee="(".concat(xr,"[.]){3}").concat(xr),wi=new RegExp("^".concat(Ee,"$")),j="(?:[0-9a-fA-F]{1,4})",Ei=new RegExp("^("+"(?:".concat(j,":){7}(?:").concat(j,"|:)|")+"(?:".concat(j,":){6}(?:").concat(Ee,"|:").concat(j,"|:)|")+"(?:".concat(j,":){5}(?::").concat(Ee,"|(:").concat(j,"){1,2}|:)|")+"(?:".concat(j,":){4}(?:(:").concat(j,"){0,1}:").concat(Ee,"|(:").concat(j,"){1,3}|:)|")+"(?:".concat(j,":){3}(?:(:").concat(j,"){0,2}:").concat(Ee,"|(:").concat(j,"){1,4}|:)|")+"(?:".concat(j,":){2}(?:(:").concat(j,"){0,3}:").concat(Ee,"|(:").concat(j,"){1,5}|:)|")+"(?:".concat(j,":){1}(?:(:").concat(j,"){0,4}:").concat(Ee,"|(:").concat(j,"){1,6}|:)|")+"(?::((?::".concat(j,"){0,5}:").concat(Ee,"|(?::").concat(j,"){1,7}|:))")+")(%[0-9a-zA-Z.]{1,})?$");function On(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};(0,Fi.default)(e);var n=(kn(t)==="object"?t.version:arguments[1])||"";if(!n)return On(e,{version:4})||On(e,{version:6});if(n.toString()==="4")return wi.test(e);if(n.toString()==="6")return Ei.test(e);return!1}Rn.exports=_t.default;Rn.exports.default=_t.default});var Er=te(function(Dt,Dn){Object.defineProperty(Dt,"__esModule",{value:!0});Dt.default=$i;var Oi=Ne($e()),Fr=Ne(Tn()),_n=Ne(Sr()),Ri=Ne(En()),br=Ne(An()),Ai=Ne(Rt());function Ne(e){return e&&e.__esModule?e:{default:e}}function _i(e,t){return Ii(e)||Ci(e,t)||Pi(e,t)||Di()}function Di(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
3
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Pi(e,t){if(e){if(typeof e=="string")return wr(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?wr(e,t):void 0}}function wr(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ci(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,s,a=[],d=!0,u=!1;try{if(i=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;d=!1}else for(;!(d=(r=i.call(n)).done)&&(a.push(r.value),a.length!==t);d=!0);}catch(l){u=!0,o=l}finally{try{if(!d&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw o}}return a}}function Ii(e){if(Array.isArray(e))return e}var vi={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_port:!1,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1,allow_fragments:!0,allow_query_components:!0,validate_length:!0,max_allowed_length:2084},Mi=/^\[([^\]]+)\](?::([0-9]+))?$/;function $i(e,t){if((0,Oi.default)(e),!e||/[\s<>]/.test(e))return!1;if(e.indexOf("mailto:")===0)return!1;if(t=(0,Ai.default)(t,vi),t.validate_length&&e.length>t.max_allowed_length)return!1;if(!t.allow_fragments&&(0,_n.default)(e,"#"))return!1;if(!t.allow_query_components&&((0,_n.default)(e,"?")||(0,_n.default)(e,"&")))return!1;var n,r,o,i,s,a,d,u;d=e.split("#"),e=d.shift(),d=e.split("?"),e=d.shift();var l=e.match(/^([a-z][a-z0-9+\-.]*):/i),c=!1,g=function(L){if(c=!0,n=L.toLowerCase(),t.require_valid_protocol&&t.protocols.indexOf(n)===-1)return!1;return e.substring(l[0].length)};if(l){var x=l[1],F=e.substring(l[0].length),N=F.slice(0,2)==="//";if(!N){var D=F.indexOf("/"),B=D===-1?F:F.substring(0,D),b=B.indexOf("@");if(b!==-1){var A=B.substring(0,b),p=/^[a-zA-Z0-9\-_.%:]*$/,m=p.test(A),f=/%[0-9a-fA-F]{2}/.test(A);if(m&&!f){if(t.require_protocol)return!1}else if(e=g(x),e===!1)return!1}else{var y=/^[0-9]/.test(F);if(y){if(t.require_protocol)return!1}else if(e=g(x),e===!1)return!1}}else if(e=g(x),e===!1)return!1}else if(t.require_protocol)return!1;if(e.slice(0,2)==="//"){if(!c&&!t.allow_protocol_relative_urls)return!1;e=e.slice(2)}if(e==="")return!1;if(d=e.split("/"),e=d.shift(),e===""&&!t.require_host)return!0;if(d=e.split("@"),d.length>1){if(t.disallow_auth)return!1;if(d[0]==="")return!1;if(r=d.shift(),r.indexOf(":")>=0&&r.split(":").length>2)return!1;var T=r.split(":"),E=_i(T,2),k=E[0],I=E[1];if(k===""&&I==="")return!1}i=d.join("@"),a=null,u=null;var _=i.match(Mi);if(_)o="",u=_[1],a=_[2]||null;else if(d=i.split(":"),o=d.shift(),d.length)a=d.join(":");if(a!==null&&a.length>0){if(s=parseInt(a,10),!/^[0-9]+$/.test(a)||s<=0||s>65535)return!1}else if(t.require_port)return!1;if(t.host_whitelist)return(0,Fr.default)(o,t.host_whitelist);if(o===""&&!t.require_host)return!0;if(!(0,br.default)(o)&&!(0,Ri.default)(o,t)&&(!u||!(0,br.default)(u,6)))return!1;if(o=o||u,t.host_blacklist&&(0,Fr.default)(o,t.host_blacklist))return!1;return!0}Dn.exports=Dt.default;Dn.exports.default=Dt.default});var Pr=te(function(Lt,Mn){Object.defineProperty(Lt,"__esModule",{value:!0});Lt.default=Xi;var Ji=Zi($e());function Zi(e){return e&&e.__esModule?e:{default:e}}function vn(e){return vn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vn(e)}function Xi(e,t){(0,Ji.default)(e);var n,r;if(vn(t)==="object")n=t.min||0,r=t.max;else n=arguments[1],r=arguments[2];var o=encodeURI(e).split(/%..|./).length-1;return o>=n&&(typeof r>"u"||o<=r)}Mn.exports=Lt.default;Mn.exports.default=Lt.default});var vr=te(function(Bt,Nn){Object.defineProperty(Bt,"__esModule",{value:!0});Bt.default=fs;var ts=Ue($e()),Cr=Ue(Tn()),$n=Ue(Pr()),ns=Ue(En()),Ir=Ue(An()),rs=Ue(Rt());function Ue(e){return e&&e.__esModule?e:{default:e}}var os={allow_display_name:!1,allow_underscores:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0,blacklisted_chars:"",ignore_max_length:!1,host_blacklist:[],host_whitelist:[]},is=/^([^\x00-\x1F\x7F-\x9F\cX]+)</i,ss=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,as=/^[a-z\d]+$/,ds=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,us=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,cs=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i,ls=254;function ps(e){var t=e.replace(/^"(.+)"$/,"$1");if(!t.trim())return!1;var n=/[\.";<>]/.test(t);if(n){if(t===e)return!1;var r=t.split('"').length===t.split("\\\"").length;if(!r)return!1}return!0}function fs(e,t){if((0,ts.default)(e),t=(0,rs.default)(t,os),t.require_display_name||t.allow_display_name){var n=e.match(is);if(n){var r=n[1];if(e=e.replace(r,"").replace(/(^<|>$)/g,""),r.endsWith(" "))r=r.slice(0,-1);if(!ps(r))return!1}else if(t.require_display_name)return!1}if(!t.ignore_max_length&&e.length>ls)return!1;var o=e.split("@"),i=o.pop(),s=i.toLowerCase();if(t.host_blacklist.length>0&&(0,Cr.default)(s,t.host_blacklist))return!1;if(t.host_whitelist.length>0&&!(0,Cr.default)(s,t.host_whitelist))return!1;var a=o.join("@");if(t.domain_specific_validation&&(s==="gmail.com"||s==="googlemail.com")){a=a.toLowerCase();var d=a.split("+")[0];if(!(0,$n.default)(d.replace(/\./g,""),{min:6,max:30}))return!1;var u=d.split(".");for(var l=0;l<u.length;l++)if(!as.test(u[l]))return!1}if(t.ignore_max_length===!1&&(!(0,$n.default)(a,{max:64})||!(0,$n.default)(i,{max:254})))return!1;if(!(0,ns.default)(i,{require_tld:t.require_tld,ignore_max_length:t.ignore_max_length,allow_underscores:t.allow_underscores})){if(!t.allow_ip_domain)return!1;if(!(0,Ir.default)(i)){if(!i.startsWith("[")||!i.endsWith("]"))return!1;var c=i.slice(1,-1);if(c.length===0||!(0,Ir.default)(c))return!1}}if(t.blacklisted_chars){if(a.search(new RegExp("[".concat(t.blacklisted_chars,"]+"),"g"))!==-1)return!1}if(a[0]==='"'&&a[a.length-1]==='"')return a=a.slice(1,a.length-1),t.allow_utf8_local_part?cs.test(a):ds.test(a);var g=t.allow_utf8_local_part?us:ss,x=a.split(".");for(var F=0;F<x.length;F++)if(!g.test(x[F]))return!1;return!0}Nn.exports=Bt.default;Nn.exports.default=Bt.default});var jn=te(function(Hr){Object.defineProperty(Hr,"__esModule",{value:!0});Hr.Dependable=Hr.DependencyGroup=void 0;var jr=Symbol.for("jsii.rtti");class Wr{static[jr]={fqn:"constructs.DependencyGroup",version:"10.8.1"};_deps=[];constructor(...e){let t=this;Wt.implement(this,{get dependencyRoots(){let n=[];for(let r of t._deps)n.push(...Wt.of(r).dependencyRoots);return n}}),this.add(...e)}add(...e){this._deps.push(...e)}}Hr.DependencyGroup=Wr;var Ur=Symbol.for("@aws-cdk/core.DependableTrait");class Wt{static[jr]={fqn:"constructs.Dependable",version:"10.8.1"};static implement(e,t){e[Ur]=t}static of(e){let t=e[Ur];if(!t)throw Error(`${e} does not implement IDependable. Use "Dependable.implement()" to implement`);return t}static get(e){return this.of(e)}}Hr.Dependable=Wt});var Kr=te(function(ae){var Ms=ae&&ae.__createBinding||(Object.create?function(e,t,n,r){if(r===void 0)r=n;var o=Object.getOwnPropertyDescriptor(t,n);if(!o||("get"in o?!t.__esModule:o.writable||o.configurable))o={enumerable:!0,get:function(){return t[n]}};Object.defineProperty(e,r,o)}:function(e,t,n,r){if(r===void 0)r=n;e[r]=t[n]}),$s=ae&&ae.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Ns=ae&&ae.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(n){var r=[];for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o))r[r.length]=o;return r},e(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(t!=null){for(var r=e(t),o=0;o<r.length;o++)if(r[o]!=="default")Ms(n,t,r[o])}return $s(n,t),n}}();Object.defineProperty(ae,"__esModule",{value:!0});ae.ADDR_SEP=void 0;ae.addressOf=Us;var Ls=Ns(ai("crypto")),Bs="Default";ae.ADDR_SEP=`
4
- `;function Us(e){let t=Ls.createHash("sha1");for(let n of e){if(n===Bs)continue;t.update(n),t.update(ae.ADDR_SEP)}return"c8"+t.digest("hex")}});var Yr=te(function(zr){Object.defineProperty(zr,"__esModule",{value:!0});zr.captureStackTrace=Vr;function Vr(e){e=e||Vr;let t={stack:""},n=Error.stackTraceLimit;try{Error.stackTraceLimit=Number.MAX_SAFE_INTEGER,Error.captureStackTrace(t,e)}finally{Error.stackTraceLimit=n}if(!t.stack)return[];return t.stack.split(`
5
- `).slice(1).map((r)=>r.replace(/^\s*at\s+/,""))}});var no=te(function(eo){Object.defineProperty(eo,"__esModule",{value:!0});eo.RootConstruct=eo.ConstructOrder=eo.Construct=eo.Node=void 0;var Wn=Symbol.for("jsii.rtti"),Qr=jn(),Jr=Kr(),Ws=Yr(),Zr=Symbol.for("constructs.Construct");class ot{host;static[Wn]={fqn:"constructs.Node",version:"10.8.1"};static PATH_SEP="/";static of(e){return e.node}scope;id;path;_locked=!1;_children;_context;_metadata;_dependencies;_defaultChild;_validations;_addr;_scopes;constructor(e,t,n){if(this.host=e,n=n??"",this.id=Gr(n),this.scope=t,t&&!this.id)throw Error("Only root constructs may have an empty ID");if(t)t.node.addChild(e,this.id),this.path=t.node.path?`${t.node.path}${ot.PATH_SEP}${this.id}`:this.id,this._scopes=[...t.node._scopes,this.host];else this.path=this.id,this._scopes=[this.host]}get scopes(){return[...this._scopes]}get addr(){if(!this._addr)this._addr=Jr.addressOf(this._scopes.map((e)=>e.node.id));return this._addr}tryFindChild(e){return this._children?.[Gr(e)]}findChild(e){let t=this.tryFindChild(e);if(!t)throw Error(`No child with id: '${e}'`);return t}get defaultChild(){if(this._defaultChild!==void 0)return this._defaultChild;let e=this.tryFindChild("Resource"),t=this.tryFindChild("Default");if(e&&t)throw Error(`Cannot determine default child for ${this.path}. There is both a child with id "Resource" and id "Default"`);return t||e}set defaultChild(e){this._defaultChild=e}get children(){return Object.values(this._children??{})}findAll(e=rt.PREORDER){let t=[];return n(this.host),t;function n(r){if(e===rt.PREORDER)t.push(r);for(let o of r.node.children)n(o);if(e===rt.POSTORDER)t.push(r)}}setContext(e,t){if(this.children.length>0){let n=this.children.map((r)=>r.node.id);throw Error("Cannot set context after children have been added: "+n.join(","))}if(!this._context)this._context={};this._context[e]=t}getContext(e){let t=this._context?.[e];if(t!==void 0)return t;if(t===void 0&&!this.scope?.node)throw Error(`No context value present for ${e} key`);return this.scope&&this.scope.node.getContext(e)}getAllContext(e){let t={...e};for(let n of this._scopes)Object.assign(t,n.node._context);return t}tryGetContext(e){let t=this._context?.[e];if(t!==void 0)return t;return this.scope&&this.scope.node.tryGetContext(e)}get metadata(){return[...this._metadata??[]]}addMetadata(e,t,n={}){if(t==null)return;let r=this;function o(){if(n.stackTraceOverride&&n.stackTraceOverride.length>0)return n.stackTraceOverride;return n.stackTrace??!1?Ws.captureStackTrace(n.traceFromFunction??r.addMetadata):void 0}if(!this._metadata)this._metadata=[];this._metadata.push({type:e,data:t,trace:o()})}get root(){return this._scopes[0]}get locked(){if(this._locked)return!0;if(this.scope&&this.scope.node.locked)return!0;return!1}addDependency(...e){if(!this._dependencies)this._dependencies=new Set;for(let t of e)this._dependencies.add(t)}removeDependency(...e){if(!this._dependencies)this._dependencies=new Set;for(let t of e)this._dependencies.delete(t)}get dependencies(){let e=[];if(this._dependencies)for(let t of this._dependencies)for(let n of Qr.Dependable.of(t).dependencyRoots)e.push(n);return e}tryRemoveChild(e){if(!this._children||!(e in this._children))return!1;return delete this._children[e],!0}addValidation(e){if(!this._validations)this._validations=[];this._validations.push(e)}validate(){return(this._validations??[]).flatMap((e)=>e.validate())}lock(){this._locked=!0}with(...e){let t=this.findAll();for(let n of e)for(let r of t)if(n.supports(r))n.applyTo(r);return this.host}addChild(e,t){if(this.locked){if(!this.path)throw Error("Cannot add children during synthesis");throw Error(`Cannot add children to "${this.path}" during synthesis`)}if(!this._children)this._children={};if(this._children[t]){let n=this.id??"",r=this.host.constructor.name;throw Error(`There is already a Construct with name '${t}' in ${r}${n.length>0?" ["+n+"]":""}`)}this._children[t]=e}}eo.Node=ot;class Ht{static[Wn]={fqn:"constructs.Construct",version:"10.8.1"};static isConstruct(e){return e&&typeof e==="object"&&e[Zr]}node;constructor(e,t){this.node=new ot(this,e,t),Qr.Dependable.implement(this,{dependencyRoots:[this]})}with(...e){return this.node.with(...e)}toString(){return this.node.path||"<root>"}}eo.Construct=Ht;var rt;(function(e){e[e.PREORDER=0]="PREORDER",e[e.POSTORDER=1]="POSTORDER"})(rt||(eo.ConstructOrder=rt={}));var Hs=new RegExp(`[${ot.PATH_SEP}${Jr.ADDR_SEP}]`,"g");function Gr(e){return e.replace(Hs,"--")}Object.defineProperty(Ht.prototype,Zr,{value:!0,enumerable:!1,writable:!1});class Xr extends Ht{static[Wn]={fqn:"constructs.RootConstruct",version:"10.8.1"};constructor(e){super(void 0,e??"")}}eo.RootConstruct=Xr});var ne=te(function(Oe){var zs=Oe&&Oe.__createBinding||(Object.create?function(e,t,n,r){if(r===void 0)r=n;var o=Object.getOwnPropertyDescriptor(t,n);if(!o||("get"in o?!t.__esModule:o.writable||o.configurable))o={enumerable:!0,get:function(){return t[n]}};Object.defineProperty(e,r,o)}:function(e,t,n,r){if(r===void 0)r=n;e[r]=t[n]}),ro=Oe&&Oe.__exportStar||function(e,t){for(var n in e)if(n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n))zs(t,e,n)};Object.defineProperty(Oe,"__esModule",{value:!0});ro(no(),Oe);ro(jn(),Oe)});import{Effect as Xo}from"effect";import{Data as mr,Effect as C,Schema as xt}from"effect";import{Data as Nr,Effect as Y,Either as hl,Schema as ke,SchemaAST as me}from"effect";import{Schema as Qi,SchemaAST as Dr}from"effect";var et=Symbol.for("pf/form/annotation/ReadOnly");var mn=Symbol.for("pf/form/annotation/Required");var yn=Symbol.for("pf/form/annotation/EmailInput"),gn=Symbol.for("pf/form/annotation/PhoneInput");var Rr=Q(Er(),1);import{Schema as Le}from"effect";var vt=Symbol.for("processfocus:internal-tag/form-schema/flatten"),Te=Symbol.for("processfocus:internal-tag/form-schema/structural-only"),Ar=Symbol.for("processfocus:internal-tag/form-schema/structural-type");var Mt=Symbol.for("processfocus:internal-tag/form-schema/metric-breakdown");var _r=(e,t)=>Le.Undefined.annotations({[Te]:!0,[Ar]:e,...t}),Ic=_r("structural"),vc=_r("divider");var Vi=(e)=>{if(typeof e!=="object"||e===null||Array.isArray(e))return!1;return typeof e.label==="string"},zi=(e)=>{if(typeof e!=="object"||e===null||Array.isArray(e))return!1;let t=e;return typeof t.label==="string"&&typeof t.value==="string"},Yi=(e)=>{if(typeof e!=="object"||e===null||Array.isArray(e))return!1;let t=e;return t.type==="selector"&&typeof t.name==="string"&&(t.urlParameter===void 0||typeof t.urlParameter==="string")&&typeof t.label==="string"&&(t.value===void 0||typeof t.value==="string")&&Array.isArray(t.options)&&t.options.length>0&&t.options.every(zi)},$t=(e)=>{if(typeof e!=="object"||e===null||Array.isArray(e))return!1;let t=e,{dataSource:n,controls:r,rendererPluginType:o,rendererPluginData:i}=t;return typeof t.title==="string"&&Array.isArray(t.buckets)&&t.buckets.every(Vi)&&(r===void 0||Array.isArray(r)&&r.every(Yi))&&(n===void 0||n==="item")&&(o===void 0||typeof o==="string")&&(i===void 0||typeof i==="object"&&i!==null&&!Array.isArray(i))};var Gi=(e)=>Rr.default(e,{protocols:["https"],require_protocol:!0,require_tld:!0}),Mc=Le.String.pipe(Le.filter(Gi,{message:()=>"Must be a valid HTTPS URL (e.g. https://example.com/path)"}),Le.annotations({arbitrary:()=>(e)=>e.webUrl({validSchemes:["https"]})}));var $c=Le.Boolean.pipe(Le.filter((e)=>e===!0,{message:()=>"This field is required",jsonSchema:{type:"boolean",enum:[!0]},[mn]:!0}));var Pe=(e,t)=>{let n=e.annotations[t];if(n!==void 0)return n;if(e._tag==="Transformation"||e._tag==="Refinement")return Pe(e.from,t);if(e._tag==="Union")for(let r of e.types){let o=Pe(r,t);if(o!==void 0)return o}return},tt=(e)=>Qi.isPropertySignature(e)?e.ast._tag==="PropertySignatureDeclaration"?Dr.annotations(e.ast.type,e.ast.annotations):Dr.annotations(e.ast.from.type,{...e.ast.from.annotations,...e.ast.to.annotations}):e.ast,Be=(e)=>Pe(tt(e),Te)!==void 0,Nt=(e)=>Pe(tt(e),vt)!==void 0,Ce=(e)=>Pe(tt(e),et)===!0;var Mr=Q(vr(),1);import{Schema as Ln}from"effect";var Vc=Ln.Trim.pipe(Ln.filter((e)=>Mr.default(e,{require_tld:!1,allow_utf8_local_part:!0,allow_ip_domain:!0}),{message:()=>"must be a valid email address"}),Ln.annotations({identifier:"Email",title:"Email address",description:"A valid email address",jsonSchema:{format:"email"},[yn]:!0}));import{Either as Gc,Schema as Qc}from"effect";import{ArrayFormatter as Zc}from"effect/ParseResult";import{Schema as Bn}from"effect";var gs=/^\+?[\d\s\-()]+$/,hs=(e)=>(e.match(/\d/g)||[]).length,Ss=(e)=>{if(!gs.test(e))return!1;let t=hs(e);return t>=7&&t<=15},rl=Bn.Trim.pipe(Bn.filter((e)=>Ss(e),{message:()=>"must be a valid phone number (7-15 digits)"}),Bn.annotations({identifier:"Phone",title:"Phone number",description:"A valid phone number",jsonSchema:{format:"phone"},[gn]:!0}));import{Schema as je}from"effect";var Un=(e,t,n=(r)=>r)=>{let r=e.ast;if(r._tag==="PropertySignatureDeclaration")return je.makePropertySignature(new je.PropertySignatureDeclaration(t(r.type,"input"),r.isOptional,r.isReadonly,n(r.annotations,r.type,"input"),r.defaultValue));let{from:o,to:i}=r;return je.makePropertySignature(new je.PropertySignatureTransformation(new je.FromPropertySignature(t(o.type,"input"),o.isOptional,o.isReadonly,n(o.annotations,o.type,"input"),o.fromKey),new je.ToPropertySignature(t(i.type,"output"),i.isOptional,i.isReadonly,n(i.annotations,o.type,"output"),i.defaultValue),r.decode,r.encode))};class Ut extends Nr.TaggedError("FieldNameCollisionError"){get message(){return`Field name collision: "${this.wrapperField}" is already present as "${this.fieldName}" in its parent struct`}}class Lr extends Nr.TaggedError("InvalidFlattenAnnotationError"){get message(){return`Invalid schema: field "${this.fieldName}" has flatten annotation but is not a struct (AST tag: ${this.astTag}). Only use Wrapper() with Schema.Struct().`}}var Br=(e,t)=>Y.gen(function*(){let n=Nt(e),r=e.ast._tag==="TypeLiteral";if(n&&!r)return yield*new Lr({fieldName:t,astTag:e.ast._tag});return n&&r}),nt=(e)=>Y.gen(function*(){let t={};for(let[n,r]of Object.entries(e.fields)){let o=r;if(Be(o))continue;if(Ce(o))continue;if(yield*Br(o,String(n))){let i=yield*nt(o);for(let[s,a]of Object.entries(i.fields)){if(s in t)return yield*new Ut({fieldName:s,wrapperField:`${n}...${s}`});t[s]=a}}else{if(n in t)return yield*new Ut({fieldName:n,wrapperField:n});t[n]=yield*Ts(r)}}return yield*xs(e.ast),ke.Struct(t)}),Ts=(e)=>Y.gen(function*(){if(!ke.isPropertySignature(e))return ke.make(yield*ye(e.ast));let t=e.ast,n=yield*ye(t._tag==="PropertySignatureDeclaration"?t.type:t.from.type),r=t._tag==="PropertySignatureDeclaration"?n:yield*ye(t.to.type);return Un(e,(o,i)=>i==="input"?n:r)}),ye=(e)=>Y.gen(function*(){if(e._tag==="TypeLiteral"){let t=[],n=new Set;for(let r of e.propertySignatures){let o=ke.make(me.annotations(r.type,r.annotations));if(Be(o)||Ce(o))continue;let i=yield*Br(o,String(r.name)),s=yield*ye(r.type),a=i&&s._tag==="TypeLiteral"?s.propertySignatures:[new me.PropertySignature(r.name,s,r.isOptional,r.isReadonly,r.annotations)];for(let d of a){if(n.has(d.name))return yield*new Ut({fieldName:String(d.name),wrapperField:`${String(r.name)}...${String(d.name)}`});n.add(d.name),t.push(d)}}return new me.TypeLiteral(t,e.indexSignatures,e.annotations)}if(e._tag==="Union")return me.Union.make(yield*Y.forEach(e.types,ye),e.annotations);if(e._tag==="Refinement")return new me.Refinement(yield*ye(e.from),e.filter,e.annotations);if(e._tag==="Transformation"){let t=yield*ye(e.from),n=yield*ye(e.to),r=e.transformation._tag==="TypeLiteralTransformation"&&t._tag==="TypeLiteral"&&n._tag==="TypeLiteral"?new me.TypeLiteralTransformation(e.transformation.propertySignatureTransformations.filter((o)=>t.propertySignatures.some((i)=>i.name===o.from)&&n.propertySignatures.some((i)=>i.name===o.to))):e.transformation;return new me.Transformation(t,n,r,e.annotations)}if(e._tag==="TupleType"){let t=yield*Y.forEach(e.elements,(r)=>ye(r.type).pipe(Y.map((o)=>new me.OptionalType(o,r.isOptional,r.annotations)))),n=yield*Y.forEach(e.rest,(r)=>ye(r.type).pipe(Y.map((o)=>new me.Type(o,r.annotations))));return new me.TupleType(t,n,e.isReadonly,e.annotations)}return e});var $r=new WeakMap,xs=(e)=>Y.gen(function*(){let t=$r.get(e);if(t)return t;let n=e,r=new Map,o=(s)=>Y.gen(function*(){if(s._tag==="Union")r.set(s,yield*Y.forEach(s.types,(a)=>Y.gen(function*(){let d=yield*ye(a);return yield*o(a),{ast:a,matches:ke.is(ke.encodedSchema(ke.make(d)))}})));else if(s._tag==="TypeLiteral")yield*Y.forEach(s.propertySignatures,(a)=>{let d=ke.make(me.annotations(a.type,a.annotations));return Be(d)||Ce(d)?Y.void:o(a.type)});else if(s._tag==="TupleType")yield*Y.forEach([...s.elements,...s.rest],(a)=>o(a.type));else if(s._tag==="Refinement"||s._tag==="Transformation")yield*o(s.from)});yield*o(n);let i={ast:n,members:r};return $r.set(e,i),i});import{Match as Fl}from"effect";import{Data as We,Effect as Kl,Match as Vl,Option as zl}from"effect";import*as Es from"effect/SchemaAST";import{TitleAnnotationId as Al}from"effect/SchemaAST";import{cleanupAllPlugins as Il,getMatchingPlugin as ws,registerWalkerPlugin as vl,unregisterWalkerPlugin as Ml}from"@processfocus/runtime";class ks extends We.TaggedError("UnknownSchemaFieldTypeError"){get message(){return`Cannot create form field "${this.fieldName}": schema type "${this.schemaType}" is not supported`}}class Os extends We.TaggedError("IndexSignaturesNotSupportedError"){get message(){return"Index signatures are not supported in schemas"}}class Rs extends We.TaggedError("UnrecognizedASTNodeError"){get message(){return`AST node type "${this.nodeTag}" is not recognized`}}class As extends We.TaggedError("InvalidPropertyKeyError"){get message(){return`Property keys must be strings or numbers, got: ${String(this.propertyKey)}`}}class _s extends We.TaggedError("InvalidFieldPermissionError"){get message(){return`Cannot apply field permission to "${this.fieldName}": ${this.reason}`}}class Ds extends We.TaggedError("InvalidStaticLinkError"){get message(){return`Cannot create link field "${this.fieldName}": url must use http, https, or mailto and text must be a string`}}var Ys=Q(ne(),1);var qt=(e,t)=>typeof e==="object"&&e!==null&&(t in e)&&e[t]===!0;var it=(e)=>qt(e,"isForm");var Hn=(e)=>qt(e,"isList"),st=(e)=>qt(e,"isOrgUnit");var Ie=(e)=>qt(e,"isProcess");import{Context as Qs,Data as Kt,Effect as Op}from"effect";var de=(e)=>e.split("/").filter((r)=>r.length>0).map((r)=>r.replace(/-/g," ").split(/\s+/).filter((i)=>i.length>0).map((i)=>i.charAt(0).toUpperCase()+i.slice(1).toLowerCase()).join("")).join("");class Js extends Kt.TaggedError("SourceStepNotFoundError"){}class Zs extends Kt.TaggedError("EdgeNotFoundError"){}class Xs extends Kt.TaggedError("ConditionFunctionMissingError"){}class ea extends Kt.TaggedError("ConditionEvaluationError"){}class ta extends Qs.Tag("processfocus:internal-tag/process/ConditionEvaluator")(){}var na=Q(ne(),1);var ra=Q(ne(),1);var oa=Q(ne(),1);import{DateTime as Ip}from"effect";import{Context as ua,Data as so,Effect as Zp}from"effect";import{Context as aa,Data as oo,Effect as zp}from"effect";var ia=Q(ne(),1);import{Schema as Up}from"effect";class da extends oo.TaggedError("ForEachStepRequiresItemsError"){}class qn extends oo.TaggedError("NotAForEachStepError"){}class io extends aa.Tag("processfocus:internal-tag/process/CurrentStepJobContext")(){}class ca extends so.TaggedError("ForEachStepNotFoundError"){}class la extends so.TaggedError("ForEachItemsError"){}class pa extends ua.Tag("processfocus:internal-tag/process/ForEachItemsResolver")(){}import{Data as Sa,Effect as Mf,JSONSchema as $f,Option as Nf,Schema as Lf,SchemaAST as Bf}from"effect";import{Schema as gf,SchemaAST as hf}from"effect";import{Data as ma,Effect as nf,Schema as ge,SchemaAST as rf}from"effect";class Kn extends ma.TaggedError("FormDecorationError"){}var sf=ge.Array(ge.Struct({value:ge.String,label:ge.String})),af=ge.Array(ge.Struct({value:ge.String,startsAt:ge.String,endsAt:ge.String,label:ge.optional(ge.String)}));import{Effect as bf,Option as wf,Schema as Ef,SchemaAST as kf}from"effect";class Ta extends Sa.TaggedError("LookupFieldNotFoundError"){}var xa=Q(ne(),1);var Fa=Q(ne(),1);import{Data as He,Effect as tm,String as nm,JSONSchema as rm,Option as om,SchemaAST as im,Schema as sm}from"effect";class ba extends He.TaggedError("ListItemQueryNotDefinedError"){get message(){return`List ${this.listPath} has no itemQuery defined`}}class wa extends He.TaggedError("ListItemUpdateNotDefinedError"){get message(){return`List ${this.listPath} has no update function defined`}}class Ea extends He.TaggedError("ListItemDeleteNotDefinedError"){get message(){return`List ${this.listPath} has no delete function defined`}}class ka extends He.TaggedError("ListCreateError"){}class Oa extends He.TaggedError("ListCreateNotDefinedError"){}class Ra extends He.TaggedError("ListUpdateValidationError"){}var Aa=Q(ne(),1);var Md=Q(ne(),1);import{EventEmitter as _a}from"events";function Da(){let e=arguments[0];for(let t=1,n=arguments.length;t<n;t++){if(!arguments[t])continue;for(let r in arguments[t])e[r]=arguments[t][r]}return e}var W=Da;if(typeof Object.assign==="function")W=Object.assign;function ce(e,t,n,r){let o=e._nodes.get(t),i=null;if(!o)return i;if(r==="mixed")i=o.out&&o.out[n]||o.undirected&&o.undirected[n];else if(r==="directed")i=o.out&&o.out[n];else i=o.undirected&&o.undirected[n];return i}function V(e){return typeof e==="object"&&e!==null}function fo(e){let t;for(t in e)return!1;return!0}function ue(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function he(e,t,n){let r={enumerable:!0,configurable:!0};if(typeof n==="function")r.get=n;else r.value=n,r.writable=!1;Object.defineProperty(e,t,r)}function co(e){if(!V(e))return!1;if(e.attributes&&!Array.isArray(e.attributes))return!1;return!0}function Pa(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function xe(){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;continue}break}while(!0);return r}}}function Ke(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Yt extends Error{constructor(e){super();this.name="GraphError",this.message=e}}class S extends Yt{constructor(e){super(e);if(this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,S.prototype.constructor)}}class h extends Yt{constructor(e){super(e);if(this.name="NotFoundGraphError",typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,h.prototype.constructor)}}class w extends Yt{constructor(e){super(e);if(this.name="UsageGraphError",typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,w.prototype.constructor)}}function mo(e,t){this.key=e,this.attributes=t,this.clear()}mo.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 yo(e,t){this.key=e,this.attributes=t,this.clear()}yo.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function go(e,t){this.key=e,this.attributes=t,this.clear()}go.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Ve(e,t,n,r,o){this.key=t,this.attributes=o,this.undirected=e,this.source=n,this.target=r}Ve.prototype.attach=function(){let e="out",t="in";if(this.undirected)e=t="undirected";let n=this.source.key,r=this.target.key;if(this.source[e][r]=this,this.undirected&&n===r)return;this.target[t][n]=this};Ve.prototype.attachMulti=function(){let e="out",t="in",n=this.source.key,r=this.target.key;if(this.undirected)e=t="undirected";let o=this.source[e],i=o[r];if(typeof i>"u"){if(o[r]=this,!(this.undirected&&n===r))this.target[t][n]=this;return}i.previous=this,this.next=i,o[r]=this,this.target[t][n]=this};Ve.prototype.detach=function(){let e=this.source.key,t=this.target.key,n="out",r="in";if(this.undirected)n=r="undirected";delete this.source[n][t],delete this.target[r][e]};Ve.prototype.detachMulti=function(){let e=this.source.key,t=this.target.key,n="out",r="in";if(this.undirected)n=r="undirected";if(this.previous===void 0)if(this.next===void 0)delete this.source[n][t],delete this.target[r][e];else this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next;else if(this.previous.next=this.next,this.next!==void 0)this.next.previous=this.previous};var ho=0,So=1,Ca=2,To=3;function Fe(e,t,n,r,o,i,s){let a,d,u,l;if(r=""+r,n===ho){if(a=e._nodes.get(r),!a)throw new h(`Graph.${t}: could not find the "${r}" node in the graph.`);u=o,l=i}else if(n===To){if(o=""+o,d=e._edges.get(o),!d)throw new h(`Graph.${t}: could not find the "${o}" edge in the graph.`);let c=d.source.key,g=d.target.key;if(r===c)a=d.target;else if(r===g)a=d.source;else throw new h(`Graph.${t}: the "${r}" node is not attached to the "${o}" edge (${c}, ${g}).`);u=i,l=s}else{if(d=e._edges.get(r),!d)throw new h(`Graph.${t}: could not find the "${r}" edge in the graph.`);if(n===So)a=d.source;else a=d.target;u=o,l=i}return[a,u,l]}function Ia(e,t,n){e.prototype[t]=function(r,o,i){let[s,a]=Fe(this,t,n,r,o,i);return s.attributes[a]}}function va(e,t,n){e.prototype[t]=function(r,o){let[i]=Fe(this,t,n,r,o);return i.attributes}}function Ma(e,t,n){e.prototype[t]=function(r,o,i){let[s,a]=Fe(this,t,n,r,o,i);return s.attributes.hasOwnProperty(a)}}function $a(e,t,n){e.prototype[t]=function(r,o,i,s){let[a,d,u]=Fe(this,t,n,r,o,i,s);return a.attributes[d]=u,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:d}),this}}function Na(e,t,n){e.prototype[t]=function(r,o,i,s){let[a,d,u]=Fe(this,t,n,r,o,i,s);if(typeof u!=="function")throw new S(`Graph.${t}: updater should be a function.`);let l=a.attributes,c=u(l[d]);return l[d]=c,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:d}),this}}function La(e,t,n){e.prototype[t]=function(r,o,i){let[s,a]=Fe(this,t,n,r,o,i);return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}function Ba(e,t,n){e.prototype[t]=function(r,o,i){let[s,a]=Fe(this,t,n,r,o,i);if(!V(a))throw new S(`Graph.${t}: provided attributes are not a plain object.`);return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function Ua(e,t,n){e.prototype[t]=function(r,o,i){let[s,a]=Fe(this,t,n,r,o,i);if(!V(a))throw new S(`Graph.${t}: provided attributes are not a plain object.`);return W(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function ja(e,t,n){e.prototype[t]=function(r,o,i){let[s,a]=Fe(this,t,n,r,o,i);if(typeof a!=="function")throw new S(`Graph.${t}: provided updater is not a function.`);return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}var Wa=[{name:(e)=>`get${e}Attribute`,attacher:Ia},{name:(e)=>`get${e}Attributes`,attacher:va},{name:(e)=>`has${e}Attribute`,attacher:Ma},{name:(e)=>`set${e}Attribute`,attacher:$a},{name:(e)=>`update${e}Attribute`,attacher:Na},{name:(e)=>`remove${e}Attribute`,attacher:La},{name:(e)=>`replace${e}Attributes`,attacher:Ba},{name:(e)=>`merge${e}Attributes`,attacher:Ua},{name:(e)=>`update${e}Attributes`,attacher:ja}];function Ha(e){Wa.forEach(function({name:t,attacher:n}){n(e,t("Node"),ho),n(e,t("Source"),So),n(e,t("Target"),Ca),n(e,t("Opposite"),To)})}function qa(e,t,n){e.prototype[t]=function(r,o){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new w(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new w(`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=""+r,a=""+o;if(o=arguments[2],i=ce(this,s,a,n),!i)throw new h(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new w(`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(r=""+r,i=this._edges.get(r),!i)throw new h(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes[o]}}function Ka(e,t,n){e.prototype[t]=function(r){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new w(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new w(`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 i=""+r,s=""+arguments[1];if(o=ce(this,i,s,n),!o)throw new h(`Graph.${t}: could not find an edge for the given path ("${i}" - "${s}").`)}else{if(n!=="mixed")throw new w(`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(r=""+r,o=this._edges.get(r),!o)throw new h(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes}}function Va(e,t,n){e.prototype[t]=function(r,o){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new w(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new w(`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=""+r,a=""+o;if(o=arguments[2],i=ce(this,s,a,n),!i)throw new h(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new w(`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(r=""+r,i=this._edges.get(r),!i)throw new h(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes.hasOwnProperty(o)}}function za(e,t,n){e.prototype[t]=function(r,o,i){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new w(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new w(`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=""+r,d=""+o;if(o=arguments[2],i=arguments[3],s=ce(this,a,d,n),!s)throw new h(`Graph.${t}: could not find an edge for the given path ("${a}" - "${d}").`)}else{if(n!=="mixed")throw new w(`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(r=""+r,s=this._edges.get(r),!s)throw new h(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return s.attributes[o]=i,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:o}),this}}function Ya(e,t,n){e.prototype[t]=function(r,o,i){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new w(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new w(`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=""+r,d=""+o;if(o=arguments[2],i=arguments[3],s=ce(this,a,d,n),!s)throw new h(`Graph.${t}: could not find an edge for the given path ("${a}" - "${d}").`)}else{if(n!=="mixed")throw new w(`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(r=""+r,s=this._edges.get(r),!s)throw new h(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!=="function")throw new S(`Graph.${t}: updater should be a function.`);return s.attributes[o]=i(s.attributes[o]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:o}),this}}function Ga(e,t,n){e.prototype[t]=function(r,o){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new w(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new w(`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=""+r,a=""+o;if(o=arguments[2],i=ce(this,s,a,n),!i)throw new h(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new w(`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(r=""+r,i=this._edges.get(r),!i)throw new h(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return delete i.attributes[o],this.emit("edgeAttributesUpdated",{key:i.key,type:"remove",attributes:i.attributes,name:o}),this}}function Qa(e,t,n){e.prototype[t]=function(r,o){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new w(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new w(`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=""+r,a=""+o;if(o=arguments[2],i=ce(this,s,a,n),!i)throw new h(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new w(`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(r=""+r,i=this._edges.get(r),!i)throw new h(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!V(o))throw new S(`Graph.${t}: provided attributes are not a plain object.`);return i.attributes=o,this.emit("edgeAttributesUpdated",{key:i.key,type:"replace",attributes:i.attributes}),this}}function Ja(e,t,n){e.prototype[t]=function(r,o){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new w(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new w(`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=""+r,a=""+o;if(o=arguments[2],i=ce(this,s,a,n),!i)throw new h(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new w(`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(r=""+r,i=this._edges.get(r),!i)throw new h(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!V(o))throw new S(`Graph.${t}: provided attributes are not a plain object.`);return W(i.attributes,o),this.emit("edgeAttributesUpdated",{key:i.key,type:"merge",attributes:i.attributes,data:o}),this}}function Za(e,t,n){e.prototype[t]=function(r,o){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new w(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new w(`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=""+r,a=""+o;if(o=arguments[2],i=ce(this,s,a,n),!i)throw new h(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new w(`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(r=""+r,i=this._edges.get(r),!i)throw new h(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!=="function")throw new S(`Graph.${t}: provided updater is not a function.`);return i.attributes=o(i.attributes),this.emit("edgeAttributesUpdated",{key:i.key,type:"update",attributes:i.attributes}),this}}var Xa=[{name:(e)=>`get${e}Attribute`,attacher:qa},{name:(e)=>`get${e}Attributes`,attacher:Ka},{name:(e)=>`has${e}Attribute`,attacher:Va},{name:(e)=>`set${e}Attribute`,attacher:za},{name:(e)=>`update${e}Attribute`,attacher:Ya},{name:(e)=>`remove${e}Attribute`,attacher:Ga},{name:(e)=>`replace${e}Attributes`,attacher:Qa},{name:(e)=>`merge${e}Attributes`,attacher:Ja},{name:(e)=>`update${e}Attributes`,attacher:Za}];function ed(e){Xa.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}var td=[{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 nd(e,t,n,r){let o=!1;for(let i in t){if(i===r)continue;let s=t[i];if(o=n(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),e&&o)return s.key}return}function rd(e,t,n,r){let o,i,s,a=!1;for(let d in t){if(d===r)continue;o=t[d];do{if(i=o.source,s=o.target,a=n(o.key,o.attributes,i.key,s.key,i.attributes,s.attributes,o.undirected),e&&a)return o.key;o=o.next}while(o!==void 0)}return}function Vn(e,t){let n=Object.keys(e),r=n.length,o,i=0;return{[Symbol.iterator](){return this},next(){do if(!o){if(i>=r)return{done:!0};let s=n[i++];if(s===t){o=void 0;continue}o=e[s]}else o=o.next;while(!o);return{done:!1,value:{edge:o.key,attributes:o.attributes,source:o.source.key,target:o.target.key,sourceAttributes:o.source.attributes,targetAttributes:o.target.attributes,undirected:o.undirected}}}}}function od(e,t,n,r){let o=t[n];if(!o)return;let{source:i,target:s}=o;if(r(o.key,o.attributes,i.key,s.key,i.attributes,s.attributes,o.undirected)&&e)return o.key}function id(e,t,n,r){let o=t[n];if(!o)return;let i=!1;do{if(i=r(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),e&&i)return o.key;o=o.next}while(o!==void 0);return}function zn(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let o={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:o}}};let r=!1;return{[Symbol.iterator](){return this},next(){if(r===!0)return{done:!0};return 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 sd(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),o=t==="undirected",i=e._edges.values(),s=0,a,d;while(a=i.next(),a.done!==!0)if(d=a.value,d.undirected===o)r[s++]=d.key;return r}function xo(e,t,n,r){if(t.size===0)return;let o=n!=="mixed"&&n!==t.type,i=n==="undirected",s,a,d=!1,u=t._edges.values();while(s=u.next(),s.done!==!0){if(a=s.value,o&&a.undirected!==i)continue;let{key:l,attributes:c,source:g,target:x}=a;if(d=r(l,c,g.key,x.key,g.attributes,x.attributes,a.undirected),e&&d)return l}return}function ad(e,t){if(e.size===0)return Ke();let n=t!=="mixed"&&t!==e.type,r=t==="undirected",o=e._edges.values();return{[Symbol.iterator](){return this},next(){let i,s;while(!0){if(i=o.next(),i.done)return i;if(s=i.value,n&&s.undirected!==r)continue;break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function Yn(e,t,n,r,o,i){let s=t?rd:nd,a;if(n!=="undirected"){if(r!=="out"){if(a=s(e,o.in,i),e&&a)return a}if(r!=="in"){if(a=s(e,o.out,i,!r?o.key:void 0),e&&a)return a}}if(n!=="directed"){if(a=s(e,o.undirected,i),e&&a)return a}return}function dd(e,t,n,r){let o=[];return Yn(!1,e,t,n,r,function(i){o.push(i)}),o}function ud(e,t,n){let r=Ke();if(e!=="undirected"){if(t!=="out"&&typeof n.in<"u")r=xe(r,Vn(n.in));if(t!=="in"&&typeof n.out<"u")r=xe(r,Vn(n.out,!t?n.key:void 0))}if(e!=="directed"&&typeof n.undirected<"u")r=xe(r,Vn(n.undirected));return r}function Gn(e,t,n,r,o,i,s){let a=n?id:od,d;if(t!=="undirected"){if(typeof o.in<"u"&&r!=="out"){if(d=a(e,o.in,i,s),e&&d)return d}if(typeof o.out<"u"&&r!=="in"&&(r||o.key!==i)){if(d=a(e,o.out,i,s),e&&d)return d}}if(t!=="directed"){if(typeof o.undirected<"u"){if(d=a(e,o.undirected,i,s),e&&d)return d}}return}function cd(e,t,n,r,o){let i=[];return Gn(!1,e,t,n,r,o,function(s){i.push(s)}),i}function ld(e,t,n,r){let o=Ke();if(e!=="undirected"){if(typeof n.in<"u"&&t!=="out"&&r in n.in)o=xe(o,zn(n.in,r));if(typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r))o=xe(o,zn(n.out,r))}if(e!=="directed"){if(typeof n.undirected<"u"&&r in n.undirected)o=xe(o,zn(n.undirected,r))}return o}function pd(e,t){let{name:n,type:r,direction:o}=t;e.prototype[n]=function(i,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return sd(this,r);if(arguments.length===1){i=""+i;let a=this._nodes.get(i);if(typeof a>"u")throw new h(`Graph.${n}: could not find the "${i}" node in the graph.`);return dd(this.multi,r==="mixed"?this.type:r,o,a)}if(arguments.length===2){i=""+i,s=""+s;let a=this._nodes.get(i);if(!a)throw new h(`Graph.${n}: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(s))throw new h(`Graph.${n}: could not find the "${s}" target node in the graph.`);return cd(r,this.multi,o,a,s)}throw new S(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function fd(e,t){let{name:n,type:r,direction:o}=t,i="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[i]=function(u,l,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;if(arguments.length===1)return c=u,xo(!1,this,r,c);if(arguments.length===2){u=""+u,c=l;let g=this._nodes.get(u);if(typeof g>"u")throw new h(`Graph.${i}: could not find the "${u}" node in the graph.`);return Yn(!1,this.multi,r==="mixed"?this.type:r,o,g,c)}if(arguments.length===3){u=""+u,l=""+l;let g=this._nodes.get(u);if(!g)throw new h(`Graph.${i}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(l))throw new h(`Graph.${i}: could not find the "${l}" target node in the graph.`);return Gn(!1,r,this.multi,o,g,l,c)}throw new S(`Graph.${i}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){let u=Array.prototype.slice.call(arguments),l=u.pop(),c;if(u.length===0){let g=0;if(r!=="directed")g+=this.undirectedSize;if(r!=="undirected")g+=this.directedSize;c=Array(g);let x=0;u.push((F,N,D,B,b,A,p)=>{c[x++]=l(F,N,D,B,b,A,p)})}else c=[],u.push((g,x,F,N,D,B,b)=>{c.push(l(g,x,F,N,D,B,b))});return this[i].apply(this,u),c};let a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(){let u=Array.prototype.slice.call(arguments),l=u.pop(),c=[];return u.push((g,x,F,N,D,B,b)=>{if(l(g,x,F,N,D,B,b))c.push(g)}),this[i].apply(this,u),c};let d="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[d]=function(){let u=Array.prototype.slice.call(arguments);if(u.length<2||u.length>4)throw new S(`Graph.${d}: invalid number of arguments (expecting 2, 3 or 4 and got ${u.length}).`);if(typeof u[u.length-1]==="function"&&typeof u[u.length-2]!=="function")throw new S(`Graph.${d}: 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 l,c;if(u.length===2)l=u[0],c=u[1],u=[];else if(u.length===3)l=u[1],c=u[2],u=[u[0]];else if(u.length===4)l=u[2],c=u[3],u=[u[0],u[1]];let g=c;return u.push((x,F,N,D,B,b,A)=>{g=l(g,x,F,N,D,B,b,A)}),this[i].apply(this,u),g}}function md(e,t){let{name:n,type:r,direction:o}=t,i="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[i]=function(d,u,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return l=d,xo(!0,this,r,l);if(arguments.length===2){d=""+d,l=u;let c=this._nodes.get(d);if(typeof c>"u")throw new h(`Graph.${i}: could not find the "${d}" node in the graph.`);return Yn(!0,this.multi,r==="mixed"?this.type:r,o,c,l)}if(arguments.length===3){d=""+d,u=""+u;let c=this._nodes.get(d);if(!c)throw new h(`Graph.${i}: could not find the "${d}" source node in the graph.`);if(!this._nodes.has(u))throw new h(`Graph.${i}: could not find the "${u}" target node in the graph.`);return Gn(!0,r,this.multi,o,c,u,l)}throw new S(`Graph.${i}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let s="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){let d=Array.prototype.slice.call(arguments),u=d.pop();if(d.push((c,g,x,F,N,D,B)=>u(c,g,x,F,N,D,B)),this[i].apply(this,d))return!0;return!1};let a="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(){let d=Array.prototype.slice.call(arguments),u=d.pop();if(d.push((c,g,x,F,N,D,B)=>!u(c,g,x,F,N,D,B)),this[i].apply(this,d))return!1;return!0}}function yd(e,t){let{name:n,type:r,direction:o}=t,i=n.slice(0,-1)+"Entries";e.prototype[i]=function(s,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Ke();if(!arguments.length)return ad(this,r);if(arguments.length===1){s=""+s;let d=this._nodes.get(s);if(!d)throw new h(`Graph.${i}: could not find the "${s}" node in the graph.`);return ud(r,o,d)}if(arguments.length===2){s=""+s,a=""+a;let d=this._nodes.get(s);if(!d)throw new h(`Graph.${i}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new h(`Graph.${i}: could not find the "${a}" target node in the graph.`);return ld(r,o,d,a)}throw new S(`Graph.${i}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function gd(e){td.forEach((t)=>{pd(e,t),fd(e,t),md(e,t),yd(e,t)})}var hd=[{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 Gt(){this.A=null,this.B=null}Gt.prototype.wrap=function(e){if(this.A===null)this.A=e;else if(this.B===null)this.B=e};Gt.prototype.has=function(e){if(this.A!==null&&e in this.A)return!0;if(this.B!==null&&e in this.B)return!0;return!1};function at(e,t,n,r,o){for(let i in r){let s=r[i],{source:a,target:d}=s,u=a===n?d:a;if(t&&t.has(u.key))continue;let l=o(u.key,u.attributes);if(e&&l)return u.key}return}function Qn(e,t,n,r,o){if(t!=="mixed"){if(t==="undirected")return at(e,null,r,r.undirected,o);if(typeof n==="string")return at(e,null,r,r[n],o)}let i=new Gt,s;if(t!=="undirected"){if(n!=="out"){if(s=at(e,null,r,r.in,o),e&&s)return s;i.wrap(r.in)}if(n!=="in"){if(s=at(e,i,r,r.out,o),e&&s)return s;i.wrap(r.out)}}if(t!=="directed"){if(s=at(e,i,r,r.undirected,o),e&&s)return s}return}function Sd(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 Qn(!1,e,t,n,function(o){r.push(o)}),r}function dt(e,t,n){let r=Object.keys(n),o=r.length,i=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(i>=o){if(e)e.wrap(n);return{done:!0}}let a=n[r[i++]],{source:d,target:u}=a;if(s=d===t?u:d,e&&e.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function Td(e,t,n){if(e!=="mixed"){if(e==="undirected")return dt(null,n,n.undirected);if(typeof t==="string")return dt(null,n,n[t])}let r=Ke(),o=new Gt;if(e!=="undirected"){if(t!=="out")r=xe(r,dt(o,n,n.in));if(t!=="in")r=xe(r,dt(o,n,n.out))}if(e!=="directed")r=xe(r,dt(o,n,n.undirected));return r}function xd(e,t){let{name:n,type:r,direction:o}=t;e.prototype[n]=function(i){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];i=""+i;let s=this._nodes.get(i);if(typeof s>"u")throw new h(`Graph.${n}: could not find the "${i}" node in the graph.`);return Sd(r==="mixed"?this.type:r,o,s)}}function Fd(e,t){let{name:n,type:r,direction:o}=t,i="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[i]=function(u,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let c=this._nodes.get(u);if(typeof c>"u")throw new h(`Graph.${i}: could not find the "${u}" node in the graph.`);Qn(!1,r==="mixed"?this.type:r,o,c,l)};let s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(u,l){let c=[];return this[i](u,(g,x)=>{c.push(l(g,x))}),c};let a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(u,l){let c=[];return this[i](u,(g,x)=>{if(l(g,x))c.push(g)}),c};let d="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[d]=function(u,l,c){if(arguments.length<3)throw new S(`Graph.${d}: 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 g=c;return this[i](u,(x,F)=>{g=l(g,x,F)}),g}}function bd(e,t){let{name:n,type:r,direction:o}=t,i=n[0].toUpperCase()+n.slice(1,-1),s="find"+i;e.prototype[s]=function(u,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let c=this._nodes.get(u);if(typeof c>"u")throw new h(`Graph.${s}: could not find the "${u}" node in the graph.`);return Qn(!0,r==="mixed"?this.type:r,o,c,l)};let a="some"+i;e.prototype[a]=function(u,l){if(this[s](u,l))return!0;return!1};let d="every"+i;e.prototype[d]=function(u,l){if(this[s](u,(g,x)=>!l(g,x)))return!1;return!0}}function wd(e,t){let{name:n,type:r,direction:o}=t,i=n.slice(0,-1)+"Entries";e.prototype[i]=function(s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Ke();s=""+s;let a=this._nodes.get(s);if(typeof a>"u")throw new h(`Graph.${i}: could not find the "${s}" node in the graph.`);return Td(r==="mixed"?this.type:r,o,a)}}function Ed(e){hd.forEach((t)=>{xd(e,t),Fd(e,t),bd(e,t),wd(e,t)})}function zt(e,t,n,r,o){let i=r._nodes.values(),s=r.type,a,d,u,l,c,g,x;while(a=i.next(),a.done!==!0){let F=!1;if(d=a.value,s!=="undirected"){l=d.out;for(u in l){c=l[u];do{if(g=c.target,F=!0,x=o(d.key,g.key,d.attributes,g.attributes,c.key,c.attributes,c.undirected),e&&x)return c;c=c.next}while(c)}}if(s!=="directed"){l=d.undirected;for(u in l){if(t&&d.key>u)continue;c=l[u];do{if(g=c.target,g.key!==u)g=c.source;if(F=!0,x=o(d.key,g.key,d.attributes,g.attributes,c.key,c.attributes,c.undirected),e&&x)return c;c=c.next}while(c)}}if(n&&!F){if(x=o(d.key,null,d.attributes,null,null,null,null),e&&x)return null}}return}function kd(e,t){let n={key:e};if(!fo(t.attributes))n.attributes=W({},t.attributes);return n}function Od(e,t,n){let r={key:t,source:n.source.key,target:n.target.key};if(!fo(n.attributes))r.attributes=W({},n.attributes);if(e==="mixed"&&n.undirected)r.undirected=!0;return r}function Rd(e){if(!V(e))throw new S('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 S("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!V(e.attributes)||e.attributes===null))throw new S("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function Ad(e){if(!V(e))throw new S('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 S("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new S("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!V(e.attributes)||e.attributes===null))throw new S("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!=="boolean")throw new S("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var _d=Pa(),Dd=new Set(["directed","undirected","mixed"]),lo=new Set(["domain","_events","_eventsCount","_maxListeners"]),Pd=[{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"}],Cd={allowSelfLoops:!0,multi:!1,type:"mixed"};function Id(e,t,n){if(n&&!V(n))throw new S(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new w(`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 po(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 Fo(e,t,n,r,o,i,s,a){if(!r&&e.type==="undirected")throw new w(`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 w(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!V(a))throw new S(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`);if(i=""+i,s=""+s,a=a||{},!e.allowSelfLoops&&i===s)throw new w(`Graph.${t}: source & target are the same ("${i}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let d=e._nodes.get(i),u=e._nodes.get(s);if(!d)throw new h(`Graph.${t}: source node "${i}" not found.`);if(!u)throw new h(`Graph.${t}: target node "${s}" not found.`);let l={key:null,undirected:r,source:i,target:s,attributes:a};if(n)o=e._edgeKeyGenerator();else if(o=""+o,e._edges.has(o))throw new w(`Graph.${t}: the "${o}" edge already exists in the graph.`);if(!e.multi&&(r?typeof d.undirected[s]<"u":typeof d.out[s]<"u"))throw new w(`Graph.${t}: an edge linking "${i}" 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 c=new Ve(r,o,d,u,a);e._edges.set(o,c);let g=i===s;if(r){if(d.undirectedDegree++,u.undirectedDegree++,g)d.undirectedLoops++,e._undirectedSelfLoopCount++}else if(d.outDegree++,u.inDegree++,g)d.directedLoops++,e._directedSelfLoopCount++;if(e.multi)c.attachMulti();else c.attach();if(r)e._undirectedSize++;else e._directedSize++;return l.key=o,e.emit("edgeAdded",l),o}function vd(e,t,n,r,o,i,s,a,d){if(!r&&e.type==="undirected")throw new w(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new w(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(a){if(d){if(typeof a!=="function")throw new S(`Graph.${t}: invalid updater function. Expecting a function but got "${a}"`)}else if(!V(a))throw new S(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`)}i=""+i,s=""+s;let u;if(d)u=a,a=void 0;if(!e.allowSelfLoops&&i===s)throw new w(`Graph.${t}: source & target are the same ("${i}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(i),c=e._nodes.get(s),g,x;if(!n){if(g=e._edges.get(o),g){if(g.source.key!==i||g.target.key!==s){if(!r||g.source.key!==s||g.target.key!==i)throw new w(`Graph.${t}: inconsistency detected when attempting to merge the "${o}" edge with "${i}" source & "${s}" target vs. ("${g.source.key}", "${g.target.key}").`)}x=g}}if(!x&&!e.multi&&l)x=r?l.undirected[s]:l.out[s];if(x){let b=[x.key,!1,!1,!1];if(d?!u:!a)return b;if(d){let A=x.attributes;x.attributes=u(A),e.emit("edgeAttributesUpdated",{type:"replace",key:x.key,attributes:x.attributes})}else W(x.attributes,a),e.emit("edgeAttributesUpdated",{type:"merge",key:x.key,attributes:x.attributes,data:a});return b}if(a=a||{},d&&u)a=u(a);let F={key:null,undirected:r,source:i,target:s,attributes:a};if(n)o=e._edgeKeyGenerator();else if(o=""+o,e._edges.has(o))throw new w(`Graph.${t}: the "${o}" edge already exists in the graph.`);let N=!1,D=!1;if(!l){if(l=po(e,i,{}),N=!0,i===s)c=l,D=!0}if(!c)c=po(e,s,{}),D=!0;g=new Ve(r,o,l,c,a),e._edges.set(o,g);let B=i===s;if(r){if(l.undirectedDegree++,c.undirectedDegree++,B)l.undirectedLoops++,e._undirectedSelfLoopCount++}else if(l.outDegree++,c.inDegree++,B)l.directedLoops++,e._directedSelfLoopCount++;if(e.multi)g.attachMulti();else g.attach();if(r)e._undirectedSize++;else e._directedSize++;return F.key=o,e.emit("edgeAdded",F),[o,!0,N,D]}function qe(e,t){e._edges.delete(t.key);let{source:n,target:r,attributes:o}=t,i=t.undirected,s=n===r;if(i){if(n.undirectedDegree--,r.undirectedDegree--,s)n.undirectedLoops--,e._undirectedSelfLoopCount--}else if(n.outDegree--,r.inDegree--,s)n.directedLoops--,e._directedSelfLoopCount--;if(e.multi)t.detachMulti();else t.detach();if(i)e._undirectedSize--;else e._directedSize--;e.emit("edgeDropped",{key:t.key,attributes:o,source:n.key,target:r.key,undirected:i})}class P extends _a{constructor(e){super();if(e=W({},Cd,e),typeof e.multi!=="boolean")throw new S(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!Dd.has(e.type))throw new S(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!=="boolean")throw new S(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let t=e.type==="mixed"?mo:e.type==="directed"?yo:go;ue(this,"NodeDataClass",t);let n="geid_"+_d()+"_",r=0,o=()=>{let i;do i=n+r++;while(this._edges.has(i));return i};ue(this,"_attributes",{}),ue(this,"_nodes",new Map),ue(this,"_edges",new Map),ue(this,"_directedSize",0),ue(this,"_undirectedSize",0),ue(this,"_directedSelfLoopCount",0),ue(this,"_undirectedSelfLoopCount",0),ue(this,"_edgeKeyGenerator",o),ue(this,"_options",e),lo.forEach((i)=>ue(this,i,this[i])),he(this,"order",()=>this._nodes.size),he(this,"size",()=>this._edges.size),he(this,"directedSize",()=>this._directedSize),he(this,"undirectedSize",()=>this._undirectedSize),he(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),he(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),he(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),he(this,"multi",this._options.multi),he(this,"type",this._options.type),he(this,"allowSelfLoops",this._options.allowSelfLoops),he(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 n=""+e,r=this._edges.get(n);return!!r&&!r.undirected}else if(arguments.length===2){e=""+e,t=""+t;let n=this._nodes.get(e);if(!n)return!1;return n.out.hasOwnProperty(t)}throw new S(`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 n=""+e,r=this._edges.get(n);return!!r&&r.undirected}else if(arguments.length===2){e=""+e,t=""+t;let n=this._nodes.get(e);if(!n)return!1;return n.undirected.hasOwnProperty(t)}throw new S(`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 n=""+e;return this._edges.has(n)}else if(arguments.length===2){e=""+e,t=""+t;let n=this._nodes.get(e);if(!n)return!1;return typeof n.out<"u"&&n.out.hasOwnProperty(t)||typeof n.undirected<"u"&&n.undirected.hasOwnProperty(t)}throw new S(`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 w("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 w("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 w("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.`);if(this.type==="undirected")return!1;return 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.`);if(this.type==="undirected")return!1;return 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.`);if(this.type==="undirected")return!1;return 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.`);if(this.type==="directed")return!1;return 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.`);if(this.type!=="undirected"){if(t in n.in||t in n.out)return!0}if(this.type!=="directed"){if(t in n.undirected)return!0}return!1}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.`);if(this.type!=="undirected"){if(t in n.in)return!0}if(this.type!=="directed"){if(t in n.undirected)return!0}return!1}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.`);if(this.type!=="undirected"){if(t in n.out)return!0}if(this.type!=="directed"){if(t in n.undirected)return!0}return!1}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.`);if(this.type==="undirected")return 0;return 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.`);if(this.type==="undirected")return 0;return 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.`);if(this.type==="undirected")return 0;return 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.`);if(this.type==="directed")return 0;return 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;if(this.type!=="directed")n+=t.undirectedDegree;if(this.type!=="undirected")n+=t.inDegree;return 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;if(this.type!=="directed")n+=t.undirectedDegree;if(this.type!=="undirected")n+=t.outDegree;return 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;if(this.type!=="directed")n+=t.undirectedDegree;if(this.type!=="undirected")n+=t.inDegree+t.outDegree;return 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.`);if(this.type==="undirected")return 0;return 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.`);if(this.type==="undirected")return 0;return 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.`);if(this.type==="undirected")return 0;return 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.`);if(this.type==="directed")return 0;return 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;if(this.type!=="directed")n+=t.undirectedDegree,r+=t.undirectedLoops*2;if(this.type!=="undirected")n+=t.inDegree,r+=t.directedLoops;return 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;if(this.type!=="directed")n+=t.undirectedDegree,r+=t.undirectedLoops*2;if(this.type!=="undirected")n+=t.outDegree,r+=t.directedLoops;return 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;if(this.type!=="directed")n+=t.undirectedDegree,r+=t.undirectedLoops*2;if(this.type!=="undirected")n+=t.inDegree+t.outDegree,r+=t.directedLoops*2;return 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,o=n.target.key;if(e===r)return o;if(e===o)return r;throw new h(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${r}, ${o}).`)}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 Id(this,e,t).key}mergeNode(e,t){if(t&&!V(t))throw new S(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=""+e,t=t||{};let n=this._nodes.get(e);if(n){if(t)W(n.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:t});return[e,!1]}return 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 S(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=""+e;let n=this._nodes.get(e);if(n){if(t){let o=n.attributes;n.attributes=t(o),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 r in t.out){n=t.out[r];do qe(this,n),n=n.next;while(n)}for(let r in t.in){n=t.in[r];do qe(this,n),n=n.next;while(n)}}if(this.type!=="directed")for(let r in t.undirected){n=t.undirected[r];do qe(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 n=""+arguments[0],r=""+arguments[1];if(t=ce(this,n,r,this.type),!t)throw new h(`Graph.dropEdge: could not find the "${n}" -> "${r}" 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 qe(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new w("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 w("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=ce(this,e,t,"directed");if(!n)throw new h(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return qe(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new w("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 w("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=ce(this,e,t,"undirected");if(!n)throw new h(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return qe(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let e=this._nodes.values(),t;while(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 S("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(!V(e))throw new S("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(!V(e))throw new S("Graph.mergeAttributes: provided attributes are not a plain object.");return W(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!=="function")throw new S("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 S("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!co(t))throw new S("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let n=this._nodes.values(),r,o;while(r=n.next(),r.done!==!0)o=r.value,o.attributes=e(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:t?t:null})}updateEachEdgeAttributes(e,t){if(typeof e!=="function")throw new S("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!co(t))throw new S("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let n=this._edges.values(),r,o,i,s;while(r=n.next(),r.done!==!0)o=r.value,i=o.source,s=o.target,o.attributes=e(o.key,o.attributes,i.key,s.key,i.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t?t:null})}forEachAdjacencyEntry(e){if(typeof e!=="function")throw new S("Graph.forEachAdjacencyEntry: expecting a callback.");zt(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!=="function")throw new S("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");zt(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!=="function")throw new S("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");zt(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!=="function")throw new S("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");zt(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!=="function")throw new S("Graph.forEachNode: expecting a callback.");let t=this._nodes.values(),n,r;while(n=t.next(),n.done!==!0)r=n.value,e(r.key,r.attributes)}findNode(e){if(typeof e!=="function")throw new S("Graph.findNode: expecting a callback.");let t=this._nodes.values(),n,r;while(n=t.next(),n.done!==!0)if(r=n.value,e(r.key,r.attributes))return r.key;return}mapNodes(e){if(typeof e!=="function")throw new S("Graph.mapNode: expecting a callback.");let t=this._nodes.values(),n,r,o=Array(this.order),i=0;while(n=t.next(),n.done!==!0)r=n.value,o[i++]=e(r.key,r.attributes);return o}someNode(e){if(typeof e!=="function")throw new S("Graph.someNode: expecting a callback.");let t=this._nodes.values(),n,r;while(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 S("Graph.everyNode: expecting a callback.");let t=this._nodes.values(),n,r;while(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 S("Graph.filterNodes: expecting a callback.");let t=this._nodes.values(),n,r,o=[];while(n=t.next(),n.done!==!0)if(r=n.value,e(r.key,r.attributes))o.push(r.key);return o}reduceNodes(e,t){if(typeof e!=="function")throw new S("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new S("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(),o,i;while(o=r.next(),o.done!==!0)i=o.value,n=e(n,i.key,i.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((r,o)=>{e[t++]=kd(o,r)});let n=Array(this._edges.size);return t=0,this._edges.forEach((r,o)=>{n[t++]=Od(this.type,o,r)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(e,t=!1){if(e instanceof P)return e.forEachNode((a,d)=>{if(t)this.mergeNode(a,d);else this.addNode(a,d)}),e.forEachEdge((a,d,u,l,c,g,x)=>{if(t)if(x)this.mergeUndirectedEdgeWithKey(a,u,l,d);else this.mergeDirectedEdgeWithKey(a,u,l,d);else if(x)this.addUndirectedEdgeWithKey(a,u,l,d);else this.addDirectedEdgeWithKey(a,u,l,d)}),this;if(!V(e))throw new S("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!V(e.attributes))throw new S("Graph.import: invalid attributes. Expecting a plain object.");if(t)this.mergeAttributes(e.attributes);else this.replaceAttributes(e.attributes)}let n,r,o,i,s;if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new S("Graph.import: invalid nodes. Expecting an array.");for(n=0,r=o.length;n<r;n++){i=o[n],Rd(i);let{key:a,attributes:d}=i;if(t)this.mergeNode(a,d);else this.addNode(a,d)}}if(e.edges){let a=!1;if(this.type==="undirected")a=!0;if(o=e.edges,!Array.isArray(o))throw new S("Graph.import: invalid edges. Expecting an array.");for(n=0,r=o.length;n<r;n++){s=o[n],Ad(s);let{source:d,target:u,attributes:l,undirected:c=a}=s,g;if("key"in s)g=t?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,g.call(this,s.key,d,u,l);else g=t?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,g.call(this,d,u,l)}}return this}nullCopy(e){let t=new P(W({},this._options,e));return t.replaceAttributes(W({},this.getAttributes())),t}emptyCopy(e){let t=this.nullCopy(e);return this._nodes.forEach((n,r)=>{let o=W({},n.attributes);n=new t.NodeDataClass(r,o),t._nodes.set(r,n)}),t}copy(e){if(e=e||{},typeof e.type==="string"&&e.type!==this.type&&e.type!=="mixed")throw new w(`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 w("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 w("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(),r,o;while(r=n.next(),r.done!==!0)o=r.value,Fo(t,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,W({},o.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let e={};this._nodes.forEach((o,i)=>{e[i]=o.attributes});let t={},n={};this._edges.forEach((o,i)=>{let s=o.undirected?"--":"->",a="",d=o.source.key,u=o.target.key,l;if(o.undirected&&d>u)l=d,d=u,u=l;let c=`(${d})${s}(${u})`;if(!i.startsWith("geid_"))a+=`[${i}]: `;else if(this.multi){if(typeof n[c]>"u")n[c]=0;else n[c]++;a+=`${n[c]}. `}a+=c,t[a]=o.attributes});let r={};for(let o in this)if(this.hasOwnProperty(o)&&!lo.has(o)&&typeof this[o]!=="function"&&typeof o!=="symbol")r[o]=this[o];return r.attributes=this._attributes,r.nodes=e,r.edges=t,ue(r,"constructor",this.constructor),r}}if(typeof Symbol<"u")P.prototype[Symbol.for("nodejs.util.inspect.custom")]=P.prototype.inspect;Pd.forEach((e)=>{["add","merge","update"].forEach((t)=>{let n=e.name(t),r=t==="add"?Fo:vd;if(e.generateKey)P.prototype[n]=function(o,i,s){return r(this,n,!0,(e.type||this.type)==="undirected",null,o,i,s,t==="update")};else P.prototype[n]=function(o,i,s,a){return r(this,n,!1,(e.type||this.type)==="undirected",o,i,s,a,t==="update")}})});Ha(P);ed(P);gd(P);Ed(P);class Jn extends P{constructor(e){let t=W({type:"directed"},e);if("multi"in t&&t.multi!==!1)throw new S("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new S('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Zn extends P{constructor(e){let t=W({type:"undirected"},e);if("multi"in t&&t.multi!==!1)throw new S("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new S('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Xn extends P{constructor(e){let t=W({multi:!0},e);if("multi"in t&&t.multi!==!0)throw new S("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class er extends P{constructor(e){let t=W({type:"directed",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new S("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new S('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class tr extends P{constructor(e){let t=W({type:"undirected",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new S("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new S('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function ze(e){e.from=function(t,n){let r=W({},t.options,n),o=new e(r);return o.import(t),o}}ze(P);ze(Jn);ze(Zn);ze(Xn);ze(er);ze(tr);P.Graph=P;P.DirectedGraph=Jn;P.UndirectedGraph=Zn;P.MultiGraph=Xn;P.MultiDirectedGraph=er;P.MultiUndirectedGraph=tr;P.InvalidArgumentsGraphError=S;P.NotFoundGraphError=h;P.UsageGraphError=w;var Im=new Set([...Intl.supportedValuesOf("timeZone"),"UTC"]);import{Schema as uu}from"effect";import{Schema as M}from"effect";import{Schema as H}from"effect";import{Schema as U}from"effect";var Re=U.Int.pipe(U.between(0,6),U.brand("DayOfWeek"));var bo=U.Struct({hour:U.Int.pipe(U.between(0,23)),minute:U.Int.pipe(U.between(0,59))}),Qt=U.Struct({open:bo,close:bo}),Ye=U.Struct({day:Re,ranges:U.Array(Qt)}),$m=U.Array(Ye),ut=U.Int.pipe(U.between(1,12),U.brand("Month")),ct=U.Int.pipe(U.between(1,31),U.brand("DayOfMonth")),nr=U.Int.pipe(U.between(1,5),U.brand("NthOccurrence")),v=(e)=>e.hour*60+e.minute,be=(e)=>v(e.close)<v(e.open);var wo=H.Struct({id:H.String,type:H.String,name:H.String,startDate:H.DateTimeUtcFromSelf,endDate:H.DateTimeUtcFromSelf,isActive:H.Boolean,weeklySchedule:H.optional(H.Array(Ye))}),Um=H.Struct({id:H.String,type:H.String,name:H.String,startDate:H.DateTimeUtc,endDate:H.DateTimeUtc,isActive:H.Boolean,weeklySchedule:H.optional(H.Array(Ye))});import{Schema as q}from"effect";var $d=q.TaggedStruct("FixedHoliday",{name:q.String,month:ut,day:ct}),Nd=q.TaggedStruct("NthWeekdayHoliday",{name:q.String,month:ut,weekday:Re,nth:nr}),Ld=q.TaggedStruct("LastWeekdayHoliday",{name:q.String,month:ut,weekday:Re}),Bd=q.TaggedStruct("EasterRelativeHoliday",{name:q.String,daysOffset:q.Int}),rr=q.Union($d,Nd,Ld,Bd),qm=q.Struct({date:q.DateTimeUtcFromSelf,name:q.String,rule:q.optional(rr)}),or=q.decodeSync(ut),Ud=q.decodeSync(ct),Eo=q.decodeSync(Re),jd=q.decodeSync(nr),J=(e,t,n)=>({_tag:"FixedHoliday",name:e,month:or(t),day:Ud(n)}),ve=(e,t,n,r)=>({_tag:"NthWeekdayHoliday",name:e,month:or(t),weekday:Eo(n),nth:jd(r)}),Wd=(e,t,n)=>({_tag:"LastWeekdayHoliday",name:e,month:or(t),weekday:Eo(n)}),Ae=(e,t)=>({_tag:"EasterRelativeHoliday",name:e,daysOffset:t});var Km=[J("New Year's Day",1,1),ve("Martin Luther King Jr. Day",1,1,3),ve("Presidents' Day",2,1,3),Wd("Memorial Day",5,1),J("Independence Day",7,4),ve("Labor Day",9,1,1),ve("Columbus Day",10,1,2),J("Veterans Day",11,11),ve("Thanksgiving",11,4,4),J("Christmas Day",12,25)],Vm=[J("Nieuwjaarsdag",1,1),J("Koningsdag",4,27),J("Bevrijdingsdag",5,5),J("Eerste Kerstdag",12,25),J("Tweede Kerstdag",12,26),Ae("Goede Vrijdag",-2),Ae("Eerste Paasdag",0),Ae("Tweede Paasdag",1),Ae("Hemelvaartsdag",39),Ae("Eerste Pinksterdag",49),Ae("Tweede Pinksterdag",50)],zm=[J("New Year's Day",1,1),J("Day after New Year's Day",1,2),J("Waitangi Day",2,6),Ae("Good Friday",-2),Ae("Easter Monday",1),J("Anzac Day",4,25),ve("Queen's Birthday",6,1,1),ve("Labour Day",10,1,4),J("Christmas Day",12,25),J("Boxing Day",12,26)];var Hd=M.Struct({date:M.DateTimeUtcFromSelf,slots:M.Union(M.Array(Qt),M.Literal("closed")),note:M.optional(M.String)}),sy=M.Struct({date:M.DateTimeUtc,slots:M.Union(M.Array(Qt),M.Literal("closed")),note:M.optional(M.String)}),ay=M.Struct({weeklySchedule:M.Array(Ye),holidays:M.Array(rr),exceptions:M.Array(Hd),nonWorkingDays:M.Array(Re),periods:M.Array(wo),requireActivePeriod:M.optional(M.String),startDayOfWeek:M.optional(Re),timezone:M.optional(M.String)});import{Context as ko,Data as qd}from"effect";class Jt extends qd.TaggedError("BusinessCalendarError"){}class ir extends ko.Tag("processfocus:internal-tag/business-calendar/BusinessCalendarService")(){}class sr extends ko.Tag("processfocus:internal-tag/business-calendar/BusinessCalendarConfigService")(){}import{Cause as _o,DateTime as O,Deferred as tn,Duration as pt,Effect as R,Exit as iu,Layer as su,Option as le,SynchronizedRef as nn}from"effect";import{DateTime as ie,Effect as Z}from"effect";import{Data as Ge}from"effect";class Kd extends Ge.TaggedError("DateOutOfRangeError"){}class Vd extends Ge.TaggedError("NoBusinessHoursError"){}class zd extends Ge.TaggedError("InvalidCalendarConfigError"){}class Zt extends Ge.TaggedError("InvalidDateError"){}class lt extends Ge.TaggedError("InvalidYearError"){}class Yd extends Ge.TaggedError("ValidationError"){}var Oo=1583,Ro=9999,Xt=(e)=>{if(!Number.isInteger(e))return Z.fail(new lt({year:e,message:`Year must be an integer, got ${e}`}));if(e<Oo)return Z.fail(new lt({year:e,message:`Year must be >= ${Oo} for Gregorian calendar, got ${e}`}));if(e>Ro)return Z.fail(new lt({year:e,message:`Year must be <= ${Ro}, got ${e}`}));return Z.succeed(e)},Gd=(e,t)=>new Date(e,t,0).getDate(),Qd=(e,t,n)=>{let r=Gd(e,t);if(n>r)return Z.fail(new Zt({year:e,month:t,day:n,message:`Invalid date: ${e}-${t}-${n}. Month ${t} has only ${r} days in year ${e}`}));return Z.void},en=(e,t,n)=>Z.try({try:()=>ie.unsafeMake({year:e,month:t,day:n,hour:0,minute:0,second:0,millis:0}),catch:(r)=>new Zt({year:e,month:t,day:n,message:`Failed to create date: ${r}`})}),Jd=(e)=>Z.gen(function*(){yield*Xt(e);let t=e%19,n=Math.floor(e/100),r=e%100,o=Math.floor(n/4),i=n%4,s=Math.floor((n+8)/25),a=Math.floor((n-s+1)/3),d=(19*t+n-o-a+15)%30,u=Math.floor(r/4),l=r%4,c=(32+2*i+2*u-d-l)%7,g=Math.floor((t+11*d+22*c)/451),x=Math.floor((d+c-7*g+114)/31),F=(d+c-7*g+114)%31+1;return yield*en(e,x,F)}),Zd=(e,t,n,r)=>Z.gen(function*(){yield*Xt(e);let o=yield*en(e,t,1),s=ie.toParts(o).weekDay,a=n-s;if(a<0)a+=7;if(o=ie.add(o,{days:a}),o=ie.add(o,{days:(r-1)*7}),ie.toParts(o).month!==t)return;return o}),Xd=(e,t,n)=>Z.gen(function*(){yield*Xt(e);let r=t===12?1:t+1,o=t===12?e+1:e,i=yield*en(o,r,1);i=ie.add(i,{days:-1});let d=ie.toParts(i).weekDay-n;if(d<0)d+=7;return ie.add(i,{days:-d})}),eu=(e,t)=>Z.gen(function*(){return yield*Xt(t),yield*Qd(t,e.month,e.day),{date:yield*en(t,e.month,e.day),name:e.name,rule:e}}),tu=(e,t)=>Z.gen(function*(){let n=yield*Zd(t,e.month,e.weekday,e.nth);if(!n)return;return{date:n,name:e.name,rule:e}}),nu=(e,t)=>Z.gen(function*(){return{date:yield*Xd(t,e.month,e.weekday),name:e.name,rule:e}}),ru=(e,t)=>Z.gen(function*(){let n=yield*Jd(t);return{date:ie.add(n,{days:e.daysOffset}),name:e.name,rule:e}}),ou=(e,t)=>{switch(e._tag){case"FixedHoliday":return eu(e,t);case"NthWeekdayHoliday":return tu(e,t);case"LastWeekdayHoliday":return nu(e,t);case"EasterRelativeHoliday":return ru(e,t)}},Ao=(e,t)=>Z.gen(function*(){let n=[];for(let r of e){let o=yield*ou(r,t);if(o)n.push(o)}return n.sort((r,o)=>{let i=ie.toEpochMillis(r.date),s=ie.toEpochMillis(o.date);return i-s})}),ar=(e,t)=>{let n=ie.toParts(e);for(let r of t){let o=ie.toParts(r.date);if(n.year===o.year&&n.month===o.month&&n.day===o.day)return r}return};var dr=1e4,au=1e5,ft=365,du=(e)=>R.gen(function*(){let t=e.timezone?O.zoneUnsafeMakeNamed(e.timezone):O.zoneUnsafeMakeNamed("UTC"),n=(p)=>{let m=O.setZone(p,t);return O.toParts(m)},r=(p,m,f,y,T)=>{let E=O.unsafeMakeZoned({year:p,month:m,day:f,hours:y,minutes:T,seconds:0,millis:0},{timeZone:t,adjustForTimeZone:!0});return O.toUtc(E)},o=yield*nn.make(new Map),i=(p)=>Ao(e.holidays,p).pipe(R.catchAllCause((m)=>{if(_o.isInterrupted(m)||_o.isDie(m))return R.failCause(m);return R.logWarning("Failed to compute holidays for year",m).pipe(R.annotateLogs({year:p}),R.as([]))})),s=(p)=>R.uninterruptibleMask((m)=>R.gen(function*(){let f=yield*nn.modifyEffect(o,(y)=>{let T=y.get(p);if(T!==void 0){if(T._tag==="Done")return R.succeed([{_tag:"hit",holidays:T.holidays},y]);return R.succeed([{_tag:"join",deferred:T.deferred},y])}return tn.make().pipe(R.map((E)=>{let k=new Map(y);return k.set(p,{_tag:"InFlight",deferred:E}),[{_tag:"owner",deferred:E},k]}))});switch(f._tag){case"hit":return f.holidays;case"join":return yield*m(tn.await(f.deferred).pipe(R.catchAll(()=>s(p))));case"owner":{let y=yield*R.exit(m(R.gen(function*(){return yield*R.yieldNow(),yield*i(p)})));if(iu.isSuccess(y))return yield*tn.succeed(f.deferred,y.value),yield*nn.update(o,(T)=>{let E=T.get(p);if(E?._tag==="InFlight"&&E.deferred===f.deferred){let k=new Map(T);return k.set(p,{_tag:"Done",holidays:y.value}),k}return T}),y.value;return yield*nn.update(o,(T)=>{let E=T.get(p);if(E?._tag==="InFlight"&&E.deferred===f.deferred){let k=new Map(T);return k.delete(p),k}return T}),yield*tn.fail(f.deferred,"abandoned"),yield*R.failCause(y.cause)}}})),a=(p)=>{let m=n(p);for(let f of e.exceptions){let y=n(f.date);if(m.year===y.year&&m.month===y.month&&m.day===y.day)return f}return},d=(p)=>{let m=O.toEpochMillis(p);return[...e.periods].filter((f)=>{let y=O.toEpochMillis(f.startDate),T=O.toEpochMillis(f.endDate);return f.isActive&&m>=y&&m<=T})},u=(p)=>{if(!e.requireActivePeriod)return!0;let m=O.toEpochMillis(p);for(let f of e.periods){if(f.type!==e.requireActivePeriod||!f.isActive)continue;let y=O.toEpochMillis(f.startDate),T=O.toEpochMillis(f.endDate);if(m>=y&&m<=T)return!0}return!1},l=(p)=>{let m=d(p);for(let f of m)if(f.weeklySchedule)return f.weeklySchedule;return e.weeklySchedule},c=(p,m)=>p.find((f)=>f.day===m),g=(p,m)=>{let f=v(p),y=v(m.open),T=v(m.close);if(be(m))return f>=y||f<T;return f>=y&&f<T},x=(p,m)=>{let f=v(p),y=v(m.close);if(be(m)){if(f>=v(m.open))return 1440-f+y;return y-f}return y-f},F=1440,N=(p,m,f,y)=>Math.max(0,Math.min(m,y)-Math.max(p,f)),D=(p,m,f)=>{if(f<=m)return 0;let y=v(p.open),T=v(p.close);if(be(p))return N(y,1440,m,f)+N(0,T,m,f);return N(y,T,m,f)},B=(p)=>{let m=a(p);if(m){if(m.slots==="closed")return[];return m.slots}let f=n(p),y=l(p);return c(y,f.weekDay)?.ranges??[]},b=(p,m)=>{let f=n(p),y=n(m);return f.year===y.year&&f.month===y.month&&f.day===y.day},A={isBusinessDay:(p)=>R.gen(function*(){let m=n(p),f=a(p);if(f?.slots==="closed")return!1;if(e.nonWorkingDays.includes(m.weekDay))return!1;let y=yield*s(m.year),T=O.unsafeMake({year:m.year,month:m.month,day:m.day});if(ar(T,y))return!1;if(!u(p))return!1;let E=l(p),k=c(E,m.weekDay);if(f&&typeof f.slots!=="string")return!0;if(!k||k.ranges.length===0)return!1;return!0}),isBusinessHours:(p)=>R.gen(function*(){if(!(yield*A.isBusinessDay(p)))return!1;let f=n(p),y={hour:f.hours,minute:f.minutes},T=a(p);if(T&&typeof T.slots!=="string"){for(let I of T.slots)if(g(y,I))return!0;return!1}let E=l(p),k=c(E,f.weekDay);if(!k)return!1;for(let I of k.ranges)if(g(y,I))return!0;return!1}),addBusinessDays:(p,m)=>R.gen(function*(){if(m===0||!Number.isFinite(m))return p;let f=Math.max(-dr,Math.min(dr,Math.round(m))),y=p,T=Math.abs(f),E=f>0?1:-1,k=0;while(T>0&&k<dr*2)if(k++,y=O.add(y,{days:E}),yield*A.isBusinessDay(y))T--;return y}),addBusinessHours:(p,m)=>R.gen(function*(){if(m<=0||!Number.isFinite(m))return p;let f=Math.min(au,m),y=p,T=Math.round(f*60),E=0,k=T+ft*24*60;while(T>0&&E<k){if(E++,!(yield*A.isBusinessHours(y))){let G=yield*A.nextBusinessDay(y),se=yield*A.businessDayStart(G);if(le.isNone(se)){y=O.add(G,{days:1});continue}y=se.value;continue}let _=n(y),z={hour:_.hours,minute:_.minutes},L=a(y),ee;if(L&&typeof L.slots!=="string")ee=L.slots;else{let G=l(y);ee=c(G,_.weekDay)?.ranges??[]}let oe=0;for(let G of ee)if(g(z,G)){oe=x(z,G);break}if(oe>=T)return O.add(y,{minutes:T});T-=oe,y=O.add(y,{minutes:oe});let Ft=n(y),pn={hour:Ft.hours,minute:Ft.minutes},fn=!1;for(let G of ee){let se=v(G.open),bt=v(pn);if(se>bt&&!be(G)){let ei=se-bt;y=O.add(y,{minutes:ei}),fn=!0;break}}if(!fn){let G=yield*A.nextBusinessDay(y),se=yield*A.businessDayStart(G);if(le.isNone(se)){y=O.add(G,{days:1});continue}y=se.value}}return y}),nextBusinessDay:(p)=>R.gen(function*(){let m=O.add(p,{days:1}),f=n(m);m=r(f.year,f.month,f.day,0,0);let y=0;while(y<ft){if(y++,yield*A.isBusinessDay(m))return m;m=O.add(m,{days:1})}return yield*new Jt({message:`No business day found within ${ft} days of ${O.toUtc(p)}, possible misconfigured calendar`})}),previousBusinessDay:(p)=>R.gen(function*(){let m=n(p),f=r(m.year,m.month,m.day,0,0);f=O.add(f,{days:-1});let y=0;while(y<ft){if(y++,yield*A.isBusinessDay(f))return f;f=O.add(f,{days:-1})}return yield*new Jt({message:`No business day found within ${ft} days of ${O.toUtc(p)}, possible misconfigured calendar`})}),businessDayStart:(p)=>R.gen(function*(){if(!(yield*A.isBusinessDay(p)))return le.none();let f=n(p),y=a(p);if(y&&typeof y.slots!=="string"){let _=y.slots,z=_[0];if(!z)return le.none();let L=z.open;for(let ee of _)if(v(ee.open)<v(L))L=ee.open;return le.some(r(f.year,f.month,f.day,L.hour,L.minute))}let T=l(p),E=c(T,f.weekDay),k=E?.ranges[0];if(!E||!k)return le.none();let I=k.open;for(let _ of E.ranges)if(v(_.open)<v(I))I=_.open;return le.some(r(f.year,f.month,f.day,I.hour,I.minute))}),businessDayEnd:(p)=>R.gen(function*(){if(!(yield*A.isBusinessDay(p)))return le.none();let f=n(p),y=a(p);if(y&&typeof y.slots!=="string"){let _=y.slots,z=_[0];if(!z)return le.none();let L=z.close;for(let ee of _)if(be(ee))L=ee.close;else if(v(ee.close)>v(L)&&!be({open:z.open,close:L}))L=ee.close;return le.some(r(f.year,f.month,f.day,L.hour,L.minute))}let T=l(p),E=c(T,f.weekDay),k=E?.ranges[0];if(!E||!k)return le.none();let I=k.close;for(let _ of E.ranges)if(be(_))I=_.close;else if(v(_.close)>v(I)&&!be({open:k.open,close:I}))I=_.close;return le.some(r(f.year,f.month,f.day,I.hour,I.minute))}),businessHoursRemaining:(p)=>R.gen(function*(){if(!(yield*A.isBusinessHours(p)))return pt.zero;let f=n(p),y={hour:f.hours,minute:f.minutes},T=a(p),E;if(T&&typeof T.slots!=="string")E=T.slots;else{let _=l(p);E=c(_,f.weekDay)?.ranges??[]}let k=0,I=!1;for(let _ of E)if(g(y,_))k+=x(y,_),I=!0;else if(I&&v(_.open)>v(y))k+=v(_.close)-v(_.open);return pt.minutes(k)}),businessDaysBetween:(p,m)=>R.gen(function*(){let f=O.toEpochMillis(p),y=O.toEpochMillis(m);if(f>=y)return 0;let T=0,E=p;while(O.toEpochMillis(E)<y){if(yield*A.isBusinessDay(E))T++;E=O.add(E,{days:1})}return T}),businessHoursBetween:(p,m)=>R.gen(function*(){let f=O.toEpochMillis(p),y=O.toEpochMillis(m);if(f>=y)return pt.zero;let T=(oe,Ft,pn)=>R.gen(function*(){if(!(yield*A.isBusinessDay(oe)))return 0;let G=B(oe),se=0;for(let bt of G)se+=D(bt,Ft,pn);return se}),E=n(p),k=n(m),I=E.hours*60+E.minutes,_=k.hours*60+k.minutes;if(b(p,m)){let oe=yield*T(p,I,_);return pt.minutes(oe)}let z=0;z+=yield*T(p,I,1440);let L=r(E.year,E.month,E.day,12,0);L=O.add(L,{days:1});let ee=r(k.year,k.month,k.day,12,0);while(O.toEpochMillis(L)<O.toEpochMillis(ee)){z+=yield*T(L,0,1440);let oe=n(L);L=O.add(r(oe.year,oe.month,oe.day,12,0),{days:1})}return z+=yield*T(m,0,_),pt.minutes(z)}),isHoliday:(p)=>R.gen(function*(){let m=n(p),f=yield*s(m.year),y=O.unsafeMake({year:m.year,month:m.month,day:m.day});return ar(y,f)!==void 0}),getHolidaysForYear:(p)=>s(p),getActivePeriods:(p)=>R.succeed(d(p)),getActivePeriodsByType:(p,m)=>R.succeed(d(p).filter((f)=>f.type===m)),isWithinPeriodType:(p,m)=>R.succeed(d(p).some((f)=>f.type===m)),getPeriodsForDateRange:(p,m,f)=>R.succeed([...e.periods].filter((y)=>{if(f&&y.type!==f)return!1;let T=O.toEpochMillis(y.startDate),E=O.toEpochMillis(y.endDate),k=O.toEpochMillis(p),I=O.toEpochMillis(m);return T<=I&&E>=k})),getEffectiveSchedule:(p)=>R.sync(()=>{let m=a(p);if(m){if(m.slots==="closed")return[];return[{day:n(p).weekDay,ranges:[...m.slots]}]}return[...l(p)]})};return A}),xy=su.effect(ir,R.flatMap(sr,du));import{DateTime as wy}from"effect";import{DateTime as Oy,Duration as Ry,Effect as Ay}from"effect";var Vy=uu.decodeSync(ct);import{Data as rn,Effect as Qy}from"effect";class cu extends rn.TaggedError("EmbeddedFormNotStartStepError"){}class lu extends rn.TaggedError("UnsupportedEmbeddedFormFieldError"){}class pu extends rn.TaggedError("EmbeddedFormMetadataBuildError"){}class fu extends rn.TaggedError("EmbeddedProcessHasMultipleStartStepsError"){}import{Data as Su,Effect as Og}from"effect";var gu=Q(ne(),1);class Tu extends Su.TaggedError("OrganisationFrontendManifestBuildError"){}import*as _e from"path";import*as ku from"effect/Brand";import*as Ou from"effect/Context";import*as Ru from"effect/Data";import*as ur from"effect/Channel";import*as xu from"effect/Chunk";import{GenericTag as Fu}from"effect/Context";import*as Se from"effect/Effect";import{identity as Bg,pipe as Ug}from"effect/Function";import*as bu from"effect/Layer";import*as wu from"effect/Option";import*as cr from"effect/Sink";import*as on from"effect/Stream";var Do=Fu("@effect/platform/FileSystem");var mt=BigInt(1024),jg=mt*mt*mt*mt*mt;var Po=Do;import{RUNTIME_ARTIFACT_FORMAT as Au,RUNTIME_ARTIFACT_VERSION as _u,Runtime as Io,parseServerPluginRegistrations as Du}from"@processfocus/runtime";import{Config as Pu,Context as Cu,Data as Iu,Effect as re,Either as aS,Layer as vo}from"effect";class Qe extends Iu.TaggedError("processfocus:internal-tag/OrganisationLoadError"){}class yt extends Cu.Tag("processfocus:internal-tag/process/OrganisationProvider")(){}var vu=(e)=>re.gen(function*(){let t=yield*Po,n=_e.resolve(process.cwd(),e),r=_e.join(n,"org.js"),o=_e.join(n,"src/index.ts"),s=(yield*t.exists(r))?r:o;if(!(yield*t.exists(s)))return yield*new Qe({message:`Failed to load organisation from ${e}: Organisation file not found: ${s}`,orgPath:e});let d=yield*re.tryPromise({try:async()=>await import(s),catch:(F)=>new Qe({message:`Failed to load organisation from ${e}: ${F instanceof Error?F.message:String(F)}`,orgPath:e,cause:F})}),u=yield*Io.loadArtifact(re.succeed({format:Au,version:_u,organisation:d.org})).pipe(re.mapError((F)=>new Qe({message:`Failed to load organisation from ${e}: ${F.message}`,orgPath:e}))),{CustomDbLayer:l,CustomGraphqlSchema:c,CustomJobLayer:g}=d,x=yield*Du(d.ServerPlugins).pipe(re.mapError((F)=>new Qe({message:`Failed to load organisation from ${e}: ${F.message}`,orgPath:e,cause:F})));return{org:u.organisation,resolvedPath:n,...l?{customDbLayer:l}:{},...c?{customGraphqlSchema:c}:{},...g?{customJobLayer:g}:{},serverPlugins:x}}),Mu=(e)=>Io.loadOrganisation({load:vu},e),$u=({org:e,orgPath:t,customDbLayer:n,customGraphqlSchema:r,customJobLayer:o,serverPlugins:i=[]})=>re.gen(function*(){let s=yield*Po,a=_e.join(t,"dist/graphql/org.graphql"),d=_e.join(t,"graphql/org.graphql"),l=(yield*s.exists(a))?a:d;return{organisation:e,orgPath:t,schemaPath:l,...n?{customDbLayer:n}:{},...r?{customGraphqlSchema:r}:{},...o?{customJobLayer:o}:{},serverPlugins:i}}),Nu=({org:e,orgPath:t,schemaPath:n,customGraphqlSchema:r,customJobLayer:o,serverPlugins:i=[]})=>{let s=n??_e.join(t,"dist/graphql/org.graphql");return{organisation:e,orgPath:t,schemaPath:s,...r?{customGraphqlSchema:r}:{},...o?{customJobLayer:o}:{},serverPlugins:i}},Lu=({name:e,customDbLayer:t,customJobLayer:n,serverPlugins:r=[]})=>re.gen(function*(){if(yield*re.log(`Loaded organisation: ${e}`),t)yield*re.log("Loaded custom database layer from organisation");if(n)yield*re.log("Loaded custom job layer from organisation");if(r.length>0)yield*re.log(`Loaded ${r.length} server plugin registration(s) from organisation`)}),uS=vo.effect(yt,re.gen(function*(){let e=yield*Pu.string("PF_ORG").pipe(re.mapError(()=>new Qe({message:"PF_ORG environment variable is not set",orgPath:"<env>"})));yield*re.log(`Loading organisation from: ${e}`);let{org:t,resolvedPath:n,customDbLayer:r,customGraphqlSchema:o,customJobLayer:i,serverPlugins:s}=yield*Mu(e);return yield*Lu({name:t.name,customDbLayer:r,customJobLayer:i,serverPlugins:s}),yield*$u({org:t,orgPath:n,customDbLayer:r,customGraphqlSchema:o,customJobLayer:i,serverPlugins:s})}));var Mo=(e,t,n,r,o,i=[])=>vo.succeed(yt,Nu({org:e,orgPath:t??process.cwd(),schemaPath:n,customGraphqlSchema:r,customJobLayer:o,serverPlugins:i}));var Bu=Q(ne(),1);var Uu=Q(ne(),1);import{Duration as mS}from"effect";import{Context as ju,Data as sn,DateTime as SS,Effect as TS,Option as xS,Schema as FS,SchemaAST as bS}from"effect";class Wu extends sn.TaggedError("SourceStepNotFoundForScheduleError"){}class Hu extends sn.TaggedError("EdgeNotFoundForScheduleError"){}class qu extends sn.TaggedError("ScheduleFunctionMissingError"){}class Ku extends sn.TaggedError("ScheduleEvaluationError"){}class Vu extends ju.Tag("processfocus:internal-tag/process/ScheduleEvaluator")(){}var zu=Q(ne(),1);import{Context as lr,Data as gt,Effect as DS,Option as PS,Schema as CS}from"effect";class Yu extends gt.TaggedError("StepNotFoundError"){}class Gu extends gt.TaggedError("NotASystemStepError"){}class Qu extends gt.TaggedError("SystemStepExecutionError"){}class Ju extends gt.TaggedError("OutputValidationError"){}class Zu extends gt.TaggedError("LongDurationDispatchError"){}class Xu extends lr.Tag("processfocus:internal-tag/process/LongDurationDispatcher")(){}class ec extends lr.Tag("processfocus:internal-tag/process/StepProcessStateReader")(){}class tc extends lr.Tag("processfocus:internal-tag/process/SystemStepExecutor")(){}import{Context as nc,Data as rc}from"effect";class oc extends rc.TaggedError("UsageCostError"){}class ic extends nc.Tag("processfocus:internal-tag/process/UsageCostService")(){}import{Data as an,Effect as X,Match as pe,Option as No}from"effect";import*as pr from"effect/SchemaAST";var ht=(e)=>!(e._tag==="Literal"&&e.literal===null),Je=(e)=>{switch(typeof e){case"string":return"String";case"number":return"Float";case"boolean":return"Boolean";default:return}},St=(e)=>{let t=e.map((r)=>r._tag==="Literal"?Je(r.literal):void 0),n=t[0];return n!==void 0&&t.every((r)=>r===n)?n:void 0};class we extends an.TaggedError("UnsupportedOutputSchemaTypeError"){get message(){return`Cannot generate GraphQL output type for field "${this.fieldName}": schema type "${this.schemaType}" is not supported`}}class Lo extends an.TaggedError("OutputIndexSignaturesNotSupportedError"){get message(){return"Index signatures are not supported in GraphQL output types"}}class Bo extends an.TaggedError("UnrecognizedOutputASTNodeError"){get message(){return`AST node type "${this.nodeTag}" is not recognized`}}class Uo extends an.TaggedError("OutputInvalidPropertyKeyError"){get message(){return`Property keys must be strings, got: ${String(this.propertyKey)}`}}var jo=(e)=>{if(typeof e==="symbol"||typeof e==="number")return X.fail(new Uo({propertyKey:e}));return X.succeed(e)},Wo=(e,t)=>{let n=t.charAt(0).toUpperCase()+t.slice(1);return`${e}${n}`},sc=(e)=>{let t=pr.getAnnotation(e,Mt),n=No.getOrUndefined(t);return $t(n)?n:void 0},ac=(e,t,n)=>{let r=Wo(t,e),o=`${r}Field`,i=`${r}Bucket`;return{fieldDefinition:`${e}: ${r}${n?"":"!"}`,auxiliary:[`type ${o} {
2
+ var Xo=Object.create;var{getPrototypeOf:ei,defineProperty:fr,getOwnPropertyNames:ti}=Object;var pr=Object.prototype.hasOwnProperty;function ni(e){return this[e]}var ri,oi,J=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var o=t?ri??=new WeakMap:oi??=new WeakMap,i=o.get(e);if(i)return i}n=e!=null?Xo(ei(e)):{};let s=t||!e||!e.__esModule||!pr.call(e,"default")?fr(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let a of ti(e))if(!pr.call(s,a))fr(s,a,{get:ni.bind(e,a),enumerable:!0})}if(r)o.set(e,s);return s};var ne=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ii=import.meta.require;var Ue=ne(function(At,hn){Object.defineProperty(At,"__esModule",{value:!0});At.default=si;function si(e){if(e===void 0||e===null)throw TypeError("Expected a string but received a ".concat(e));if(e.constructor.name!=="String")throw TypeError("Expected a string but received a ".concat(e.constructor.name))}hn.exports=At.default;hn.exports.default=At.default});var Sn=ne(function(Pt,gn){Object.defineProperty(Pt,"__esModule",{value:!0});Pt.default=ui;function di(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function ui(e,t){for(var n=0;n<t.length;n++){var r=t[n];if(e===r||di(r)&&r.test(e))return!0}return!1}gn.exports=Pt.default;gn.exports.default=Pt.default});var Sr=ne(function(_t,xn){Object.defineProperty(_t,"__esModule",{value:!0});_t.default=void 0;var li=function(t,n){return t.indexOf(n)!==-1},sc=_t.default=li;xn.exports=_t.default;xn.exports.default=_t.default});var Dt=ne(function(It,Tn){Object.defineProperty(It,"__esModule",{value:!0});It.default=fi;function wn(e){return wn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wn(e)}function fi(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;if(wn(e)!=="object"||e===null)e={};for(var n in t)if(typeof e[n]>"u")e[n]=t[n];return e}Tn.exports=It.default;Tn.exports.default=It.default});var Fn=ne(function(Rt,bn){Object.defineProperty(Rt,"__esModule",{value:!0});Rt.default=gi;var mi=xr(Ue()),yi=xr(Dt());function xr(e){return e&&e.__esModule?e:{default:e}}var hi={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_numeric_tld:!1,allow_wildcard:!1,ignore_max_length:!1};function gi(e,t){if((0,mi.default)(e),t=(0,yi.default)(t,hi),t.allow_trailing_dot&&e[e.length-1]===".")e=e.substring(0,e.length-1);if(t.allow_wildcard===!0&&e.indexOf("*.")===0)e=e.substring(2);var n=e.split("."),r=n[n.length-1];if(t.require_tld){if(n.length<2)return!1;if(!t.allow_numeric_tld&&!/^([a-z\u00A1-\u00A8\u00AA-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{2,}|xn[a-z0-9-]{2,})$/i.test(r))return!1;if(/\s/.test(r))return!1}if(!t.allow_numeric_tld&&/^\d+$/.test(r))return!1;return n.every(function(o){if(o.length>63&&!t.ignore_max_length)return!1;if(!/^[a-z_\u00a1-\uffff0-9-]+$/i.test(o))return!1;if(/[\uff01-\uff5e]/.test(o))return!1;if(/^-|-$/.test(o))return!1;if(!t.allow_underscores&&/_/.test(o))return!1;return!0})}bn.exports=Rt.default;bn.exports.default=Rt.default});var An=ne(function(vt,On){Object.defineProperty(vt,"__esModule",{value:!0});vt.default=kn;var xi=wi(Ue());function wi(e){return e&&e.__esModule?e:{default:e}}function En(e){return En=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},En(e)}var wr="(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])",Ee="(".concat(wr,"[.]){3}").concat(wr),Ti=new RegExp("^".concat(Ee,"$")),W="(?:[0-9a-fA-F]{1,4})",bi=new RegExp("^("+"(?:".concat(W,":){7}(?:").concat(W,"|:)|")+"(?:".concat(W,":){6}(?:").concat(Ee,"|:").concat(W,"|:)|")+"(?:".concat(W,":){5}(?::").concat(Ee,"|(:").concat(W,"){1,2}|:)|")+"(?:".concat(W,":){4}(?:(:").concat(W,"){0,1}:").concat(Ee,"|(:").concat(W,"){1,3}|:)|")+"(?:".concat(W,":){3}(?:(:").concat(W,"){0,2}:").concat(Ee,"|(:").concat(W,"){1,4}|:)|")+"(?:".concat(W,":){2}(?:(:").concat(W,"){0,3}:").concat(Ee,"|(:").concat(W,"){1,5}|:)|")+"(?:".concat(W,":){1}(?:(:").concat(W,"){0,4}:").concat(Ee,"|(:").concat(W,"){1,6}|:)|")+"(?::((?::".concat(W,"){0,5}:").concat(Ee,"|(?::").concat(W,"){1,7}|:))")+")(%[0-9a-zA-Z.]{1,})?$");function kn(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};(0,xi.default)(e);var n=(En(t)==="object"?t.version:arguments[1])||"";if(!n)return kn(e,{version:4})||kn(e,{version:6});if(n.toString()==="4")return Ti.test(e);if(n.toString()==="6")return bi.test(e);return!1}On.exports=vt.default;On.exports.default=vt.default});var Er=ne(function(Ct,_n){Object.defineProperty(Ct,"__esModule",{value:!0});Ct.default=Ci;var Ei=je(Ue()),Tr=je(Sn()),Pn=je(Sr()),ki=je(Fn()),br=je(An()),Oi=je(Dt());function je(e){return e&&e.__esModule?e:{default:e}}function Ai(e,t){return Di(e)||Ii(e,t)||_i(e,t)||Pi()}function Pi(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _i(e,t){if(e){if(typeof e=="string")return Fr(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Fr(e,t):void 0}}function Fr(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Ii(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,i,s,a=[],d=!0,u=!1;try{if(i=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;d=!1}else for(;!(d=(r=i.call(n)).done)&&(a.push(r.value),a.length!==t);d=!0);}catch(l){u=!0,o=l}finally{try{if(!d&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw o}}return a}}function Di(e){if(Array.isArray(e))return e}var Ri={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_host:!0,require_port:!1,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1,allow_fragments:!0,allow_query_components:!0,validate_length:!0,max_allowed_length:2084},vi=/^\[([^\]]+)\](?::([0-9]+))?$/;function Ci(e,t){if((0,Ei.default)(e),!e||/[\s<>]/.test(e))return!1;if(e.indexOf("mailto:")===0)return!1;if(t=(0,Oi.default)(t,Ri),t.validate_length&&e.length>t.max_allowed_length)return!1;if(!t.allow_fragments&&(0,Pn.default)(e,"#"))return!1;if(!t.allow_query_components&&((0,Pn.default)(e,"?")||(0,Pn.default)(e,"&")))return!1;var n,r,o,i,s,a,d,u;d=e.split("#"),e=d.shift(),d=e.split("?"),e=d.shift();var l=e.match(/^([a-z][a-z0-9+\-.]*):/i),c=!1,h=function(U){if(c=!0,n=U.toLowerCase(),t.require_valid_protocol&&t.protocols.indexOf(n)===-1)return!1;return e.substring(l[0].length)};if(l){var w=l[1],T=e.substring(l[0].length),B=T.slice(0,2)==="//";if(!B){var D=T.indexOf("/"),j=D===-1?T:T.substring(0,D),b=j.indexOf("@");if(b!==-1){var P=j.substring(0,b),f=/^[a-zA-Z0-9\-_.%:]*$/,m=f.test(P),p=/%[0-9a-fA-F]{2}/.test(P);if(m&&!p){if(t.require_protocol)return!1}else if(e=h(w),e===!1)return!1}else{var y=/^[0-9]/.test(T);if(y){if(t.require_protocol)return!1}else if(e=h(w),e===!1)return!1}}else if(e=h(w),e===!1)return!1}else if(t.require_protocol)return!1;if(e.slice(0,2)==="//"){if(!c&&!t.allow_protocol_relative_urls)return!1;e=e.slice(2)}if(e==="")return!1;if(d=e.split("/"),e=d.shift(),e===""&&!t.require_host)return!0;if(d=e.split("@"),d.length>1){if(t.disallow_auth)return!1;if(d[0]==="")return!1;if(r=d.shift(),r.indexOf(":")>=0&&r.split(":").length>2)return!1;var x=r.split(":"),E=Ai(x,2),k=E[0],C=E[1];if(k===""&&C==="")return!1}i=d.join("@"),a=null,u=null;var _=i.match(vi);if(_)o="",u=_[1],a=_[2]||null;else if(d=i.split(":"),o=d.shift(),d.length)a=d.join(":");if(a!==null&&a.length>0){if(s=parseInt(a,10),!/^[0-9]+$/.test(a)||s<=0||s>65535)return!1}else if(t.require_port)return!1;if(t.host_whitelist)return(0,Tr.default)(o,t.host_whitelist);if(o===""&&!t.require_host)return!0;if(!(0,br.default)(o)&&!(0,ki.default)(o,t)&&(!u||!(0,br.default)(u,6)))return!1;if(o=o||u,t.host_blacklist&&(0,Tr.default)(o,t.host_blacklist))return!1;return!0}_n.exports=Ct.default;_n.exports.default=Ct.default});var Ar=ne(function(Nt,Cn){Object.defineProperty(Nt,"__esModule",{value:!0});Nt.default=zi;var qi=Ki(Ue());function Ki(e){return e&&e.__esModule?e:{default:e}}function vn(e){return vn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vn(e)}function zi(e,t){(0,qi.default)(e);var n,r;if(vn(t)==="object")n=t.min||0,r=t.max;else n=arguments[1],r=arguments[2];var o=encodeURI(e).split(/%..|./).length-1;return o>=n&&(typeof r>"u"||o<=r)}Cn.exports=Nt.default;Cn.exports.default=Nt.default});var Ir=ne(function(Lt,$n){Object.defineProperty(Lt,"__esModule",{value:!0});Lt.default=ss;var Gi=He(Ue()),Pr=He(Sn()),Mn=He(Ar()),Yi=He(Fn()),_r=He(An()),Qi=He(Dt());function He(e){return e&&e.__esModule?e:{default:e}}var Ji={allow_display_name:!1,allow_underscores:!1,require_display_name:!1,allow_utf8_local_part:!0,require_tld:!0,blacklisted_chars:"",ignore_max_length:!1,host_blacklist:[],host_whitelist:[]},Zi=/^([^\x00-\x1F\x7F-\x9F\cX]+)</i,Xi=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,es=/^[a-z\d]+$/,ts=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,ns=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A1-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,rs=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i,os=254;function is(e){var t=e.replace(/^"(.+)"$/,"$1");if(!t.trim())return!1;var n=/[\.";<>]/.test(t);if(n){if(t===e)return!1;var r=t.split('"').length===t.split("\\\"").length;if(!r)return!1}return!0}function ss(e,t){if((0,Gi.default)(e),t=(0,Qi.default)(t,Ji),t.require_display_name||t.allow_display_name){var n=e.match(Zi);if(n){var r=n[1];if(e=e.replace(r,"").replace(/(^<|>$)/g,""),r.endsWith(" "))r=r.slice(0,-1);if(!is(r))return!1}else if(t.require_display_name)return!1}if(!t.ignore_max_length&&e.length>os)return!1;var o=e.split("@"),i=o.pop(),s=i.toLowerCase();if(t.host_blacklist.length>0&&(0,Pr.default)(s,t.host_blacklist))return!1;if(t.host_whitelist.length>0&&!(0,Pr.default)(s,t.host_whitelist))return!1;var a=o.join("@");if(t.domain_specific_validation&&(s==="gmail.com"||s==="googlemail.com")){a=a.toLowerCase();var d=a.split("+")[0];if(!(0,Mn.default)(d.replace(/\./g,""),{min:6,max:30}))return!1;var u=d.split(".");for(var l=0;l<u.length;l++)if(!es.test(u[l]))return!1}if(t.ignore_max_length===!1&&(!(0,Mn.default)(a,{max:64})||!(0,Mn.default)(i,{max:254})))return!1;if(!(0,Yi.default)(i,{require_tld:t.require_tld,ignore_max_length:t.ignore_max_length,allow_underscores:t.allow_underscores})){if(!t.allow_ip_domain)return!1;if(!(0,_r.default)(i)){if(!i.startsWith("[")||!i.endsWith("]"))return!1;var c=i.slice(1,-1);if(c.length===0||!(0,_r.default)(c))return!1}}if(t.blacklisted_chars){if(a.search(new RegExp("[".concat(t.blacklisted_chars,"]+"),"g"))!==-1)return!1}if(a[0]==='"'&&a[a.length-1]==='"')return a=a.slice(1,a.length-1),t.allow_utf8_local_part?rs.test(a):ts.test(a);var h=t.allow_utf8_local_part?ns:Xi,w=a.split(".");for(var T=0;T<w.length;T++)if(!h.test(w[T]))return!1;return!0}$n.exports=Lt.default;$n.exports.default=Lt.default});var Bn=ne(function(Wr){Object.defineProperty(Wr,"__esModule",{value:!0});Wr.Dependable=Wr.DependencyGroup=void 0;var Ur=Symbol.for("jsii.rtti");class jr{static[Ur]={fqn:"constructs.DependencyGroup",version:"10.8.1"};_deps=[];constructor(...e){let t=this;Wt.implement(this,{get dependencyRoots(){let n=[];for(let r of t._deps)n.push(...Wt.of(r).dependencyRoots);return n}}),this.add(...e)}add(...e){this._deps.push(...e)}}Wr.DependencyGroup=jr;var Br=Symbol.for("@aws-cdk/core.DependableTrait");class Wt{static[Ur]={fqn:"constructs.Dependable",version:"10.8.1"};static implement(e,t){e[Br]=t}static of(e){let t=e[Br];if(!t)throw Error(`${e} does not implement IDependable. Use "Dependable.implement()" to implement`);return t}static get(e){return this.of(e)}}Wr.Dependable=Wt});var qr=ne(function(ue){var Ts=ue&&ue.__createBinding||(Object.create?function(e,t,n,r){if(r===void 0)r=n;var o=Object.getOwnPropertyDescriptor(t,n);if(!o||("get"in o?!t.__esModule:o.writable||o.configurable))o={enumerable:!0,get:function(){return t[n]}};Object.defineProperty(e,r,o)}:function(e,t,n,r){if(r===void 0)r=n;e[r]=t[n]}),bs=ue&&ue.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),Fs=ue&&ue.__importStar||function(){var e=function(t){return e=Object.getOwnPropertyNames||function(n){var r=[];for(var o in n)if(Object.prototype.hasOwnProperty.call(n,o))r[r.length]=o;return r},e(t)};return function(t){if(t&&t.__esModule)return t;var n={};if(t!=null){for(var r=e(t),o=0;o<r.length;o++)if(r[o]!=="default")Ts(n,t,r[o])}return bs(n,t),n}}();Object.defineProperty(ue,"__esModule",{value:!0});ue.ADDR_SEP=void 0;ue.addressOf=Os;var Es=Fs(ii("crypto")),ks="Default";ue.ADDR_SEP=`
4
+ `;function Os(e){let t=Es.createHash("sha1");for(let n of e){if(n===ks)continue;t.update(n),t.update(ue.ADDR_SEP)}return"c8"+t.digest("hex")}});var Vr=ne(function(zr){Object.defineProperty(zr,"__esModule",{value:!0});zr.captureStackTrace=Kr;function Kr(e){e=e||Kr;let t={stack:""},n=Error.stackTraceLimit;try{Error.stackTraceLimit=Number.MAX_SAFE_INTEGER,Error.captureStackTrace(t,e)}finally{Error.stackTraceLimit=n}if(!t.stack)return[];return t.stack.split(`
5
+ `).slice(1).map((r)=>r.replace(/^\s*at\s+/,""))}});var eo=ne(function(Zr){Object.defineProperty(Zr,"__esModule",{value:!0});Zr.RootConstruct=Zr.ConstructOrder=Zr.Construct=Zr.Node=void 0;var Un=Symbol.for("jsii.rtti"),Ht=Bn(),qt=qr(),Yr=Vr(),Qr=Symbol.for("constructs.Construct");class ut{host;static[Un]={fqn:"constructs.Node",version:"10.8.1"};static PATH_SEP="/";static of(e){return e.node}scope;id;path;_locked=!1;_children;_context;_metadata;_dependencies;_defaultChild;_validations;_addr;_scopes;constructor(e,t,n){if(this.host=e,n=n??"",this.id=Gr(n),this.scope=t,t&&!this.id)throw Error("Only root constructs may have an empty ID");if(t)t.node.addChild(e,this.id),this.path=t.node.path?`${t.node.path}${ut.PATH_SEP}${this.id}`:this.id,this._scopes=[...t.node._scopes,this.host];else this.path=this.id,this._scopes=[this.host]}get scopes(){return[...this._scopes]}get addr(){if(!this._addr)this._addr=qt.addressOf(this._scopes.map((e)=>e.node.id));return this._addr}tryFindChild(e){return this._children?.[Gr(e)]}findChild(e){let t=this.tryFindChild(e);if(!t)throw Error(`No child with id: '${e}'`);return t}get defaultChild(){if(this._defaultChild!==void 0)return this._defaultChild;let e=this.tryFindChild("Resource"),t=this.tryFindChild("Default");if(e&&t)throw Error(`Cannot determine default child for ${this.path}. There is both a child with id "Resource" and id "Default"`);return t||e}set defaultChild(e){this._defaultChild=e}get children(){return Object.values(this._children??{})}findAll(e=dt.PREORDER){let t=[];return n(this.host),t;function n(r){if(e===dt.PREORDER)t.push(r);for(let o of r.node.children)n(o);if(e===dt.POSTORDER)t.push(r)}}setContext(e,t){if(this.children.length>0){let n=this.children.map((r)=>r.node.id);throw Error("Cannot set context after children have been added: "+n.join(","))}if(!this._context)this._context={};this._context[e]=t}getContext(e){let t=this._context?.[e];if(t!==void 0)return t;if(t===void 0&&!this.scope?.node)throw Error(`No context value present for ${e} key`);return this.scope&&this.scope.node.getContext(e)}getAllContext(e){let t={...e};for(let n of this._scopes)Object.assign(t,n.node._context);return t}tryGetContext(e){let t=this._context?.[e];if(t!==void 0)return t;return this.scope&&this.scope.node.tryGetContext(e)}get metadata(){return[...this._metadata??[]]}addMetadata(e,t,n={}){if(t==null)return;let r=this;function o(){if(n.stackTraceOverride&&n.stackTraceOverride.length>0)return n.stackTraceOverride;return n.stackTrace??!1?Yr.captureStackTrace(n.traceFromFunction??r.addMetadata):void 0}if(!this._metadata)this._metadata=[];this._metadata.push({type:e,data:t,trace:o()})}get root(){return this._scopes[0]}get locked(){if(this._locked)return!0;if(this.scope&&this.scope.node.locked)return!0;return!1}addDependency(...e){if(!this._dependencies)this._dependencies=new Set;for(let t of e)this._dependencies.add(t)}removeDependency(...e){if(!this._dependencies)this._dependencies=new Set;for(let t of e)this._dependencies.delete(t)}get dependencies(){let e=[];if(this._dependencies)for(let t of this._dependencies)for(let n of Ht.Dependable.of(t).dependencyRoots)e.push(n);return e}tryRemoveChild(e){if(!this._children||!(e in this._children))return!1;return delete this._children[e],!0}addValidation(e){if(!this._validations)this._validations=[];this._validations.push(e)}validate(){return(this._validations??[]).flatMap((e)=>e.validate())}lock(){this._locked=!0}with(...e){let t=this.findAll();for(let n of e)for(let r of t)if(n.supports(r))n.applyTo(r);return this.host}addChild(e,t){if(this.locked){if(!this.path)throw Error("Cannot add children during synthesis");throw Error(`Cannot add children to "${this.path}" during synthesis`)}if(!this._children)this._children={};if(this._children[t]){let n=this.id??"",r=this.host.constructor.name;throw Error(`There is already a Construct with name '${t}' in ${r}${n.length>0?" ["+n+"]":""}`)}this._children[t]=e}}Zr.Node=ut;class Kt{static[Un]={fqn:"constructs.Construct",version:"10.8.1"};static isConstruct(e){return e&&typeof e==="object"&&e[Qr]}node;constructor(e,t){this.node=new ut(this,e,t),Ht.Dependable.implement(this,{dependencyRoots:[this]})}with(...e){return this.node.with(...e)}toString(){return this.node.path||"<root>"}}Zr.Construct=Kt;var dt;(function(e){e[e.PREORDER=0]="PREORDER",e[e.POSTORDER=1]="POSTORDER"})(dt||(Zr.ConstructOrder=dt={}));var Ps=new RegExp(`[${ut.PATH_SEP}${qt.ADDR_SEP}]`,"g");function Gr(e){return e.replace(Ps,"--")}Object.defineProperty(Kt.prototype,Qr,{value:!0,enumerable:!1,writable:!1});class Jr extends Kt{static[Un]={fqn:"constructs.RootConstruct",version:"10.8.1"};constructor(e){super(void 0,e??"")}}Zr.RootConstruct=Jr});var oe=ne(function(Oe){var Rs=Oe&&Oe.__createBinding||(Object.create?function(e,t,n,r){if(r===void 0)r=n;var o=Object.getOwnPropertyDescriptor(t,n);if(!o||("get"in o?!t.__esModule:o.writable||o.configurable))o={enumerable:!0,get:function(){return t[n]}};Object.defineProperty(e,r,o)}:function(e,t,n,r){if(r===void 0)r=n;e[r]=t[n]}),to=Oe&&Oe.__exportStar||function(e,t){for(var n in e)if(n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n))Rs(t,e,n)};Object.defineProperty(Oe,"__esModule",{value:!0});to(eo(),Oe);to(Bn(),Oe)});import{Effect as Jo}from"effect";import{Data as lr,Effect as v,Schema as bt}from"effect";import{Result as hl,Schema as gl,SchemaAST as Sl}from"effect";var rt=Symbol.for("pf/form/annotation/Label"),ot=Symbol.for("pf/form/annotation/Description"),kt=Symbol.for("pf/form/annotation/ReadOnly"),Be=Symbol.for("pf/form/annotation/Default"),mr=Symbol.for("pf/form/annotation/Permission"),yn=Symbol.for("pf/form/annotation/Required");var Ot=Symbol.for("pf/form/annotation/AutoComplete");var yr=Symbol.for("pf/form/annotation/EmailInput"),hr=Symbol.for("pf/form/annotation/PhoneInput");var kr=J(Er(),1);import{Schema as xe}from"effect";var st=Symbol.for("processfocus:internal-tag/form-schema/flatten"),ke=Symbol.for("processfocus:internal-tag/form-schema/structural-only"),Li=Symbol.for("processfocus:internal-tag/form-schema/structural-type");var In=Symbol.for("processfocus:internal-tag/form-schema/metric-breakdown");var Or=(e,t)=>xe.make(xe.optionalKey(xe.Undefined).ast).annotate({[ke]:!0,[Li]:e,...t}),Sc=Or("structural"),xc=Or("divider");var Bi=(e)=>{if(typeof e!=="object"||e===null||Array.isArray(e))return!1;return typeof e.label==="string"},Ui=(e)=>{if(typeof e!=="object"||e===null||Array.isArray(e))return!1;let t=e;return typeof t.label==="string"&&typeof t.value==="string"},ji=(e)=>{if(typeof e!=="object"||e===null||Array.isArray(e))return!1;let t=e;return t.type==="selector"&&typeof t.name==="string"&&(t.urlParameter===void 0||typeof t.urlParameter==="string")&&typeof t.label==="string"&&(t.value===void 0||typeof t.value==="string")&&Array.isArray(t.options)&&t.options.length>0&&t.options.every(Ui)},Dn=(e)=>{if(typeof e!=="object"||e===null||Array.isArray(e))return!1;let t=e,{dataSource:n,controls:r,rendererPluginType:o,rendererPluginData:i}=t;return typeof t.title==="string"&&Array.isArray(t.buckets)&&t.buckets.every(Bi)&&(r===void 0||Array.isArray(r)&&r.every(ji))&&(n===void 0||n==="item")&&(o===void 0||typeof o==="string")&&(i===void 0||typeof i==="object"&&i!==null&&!Array.isArray(i))};var Wi=(e)=>typeof e==="object"&&e!==null&&("modify"in e)&&typeof e.modify==="object"&&e.modify!==null&&("node"in e.modify)&&typeof e.modify.node==="object"&&e.modify.node!==null&&("path"in e.modify.node)&&typeof e.modify.node.path==="string",Rn=(e,t)=>{if(!t)return e;let n={};if(t.label!==void 0)n[rt]=t.label;if(t.description!==void 0)n[ot]=t.description;if(t.autoComplete!==void 0)n[Ot]=t.autoComplete;if(t.readOnly!==void 0)n[kt]=t.readOnly;if(Wi(t.permission))n[mr]=t.permission;if(t.default!==void 0)n[Be]=t.default;return Object.getOwnPropertySymbols(n).length>0?e.annotate(n):e};var Hi=(e)=>kr.default(e,{protocols:["https"],require_protocol:!0,require_tld:!0}),wc=xe.String.pipe(xe.check(xe.makeFilter(Hi,{message:"Must be a valid HTTPS URL (e.g. https://example.com/path)",arbitraryConstraint:{patterns:[{source:"^https://[a-z]{3,12}\\.example\\.com$",flags:""}]}})));var Tc=xe.Boolean.pipe(xe.check(xe.makeFilter((e)=>e===!0,{message:"This field is required",toJsonSchema:()=>({type:"boolean",enum:[!0]}),[yn]:!0})));var re=(e,t)=>{let n=Reflect.get(e.context?.annotations??{},t)??e.checks?.toReversed().map((r)=>Reflect.get(r.annotations??{},t)).find((r)=>r!==void 0)??Reflect.get(e.annotations??{},t);if(n!==void 0)return n;if(e.encoding)for(let r of e.encoding){let o=re(r.to,t);if(o!==void 0)return o}if(e._tag==="Union")for(let r of e.types){let o=re(r,t);if(o!==void 0)return o}return},$t=(e)=>e.ast,Re=(e)=>re($t(e),ke)!==void 0,We=(e)=>re($t(e),st)!==void 0,ve=(e)=>re($t(e),kt)===!0;var Dr=J(Ir(),1);import{Schema as Bt}from"effect";var ds=Bt.Trim.pipe(Bt.check(Bt.makeFilter((e)=>Dr.default(e,{require_tld:!1,allow_utf8_local_part:!0,allow_ip_domain:!0}),{message:"must be a valid email address"})),Bt.annotate({identifier:"Email",title:"Email address",description:"A valid email address",format:"email",[yr]:!0})),Rr=(e)=>Rn(ds,{autoComplete:e?.autoComplete??"email",...e});import{Result as Rc,Schema as vc,SchemaIssue as Cc}from"effect";import{Schema as I}from"effect";var us=I.Struct({label:I.optional(I.String),description:I.optional(I.String),text:I.optional(I.String),href:I.optional(I.String)}),Nc=I.Struct({presentation:I.Record(I.String,us),inaccessible:I.Array(I.String),originalValues:I.Record(I.String,I.Unknown),lookups:I.optional(I.Record(I.String,I.Struct({dependencies:I.Array(I.String),queryName:I.String}))),prefill:I.optional(I.Struct({dependency:I.String,fields:I.Array(I.String),concealed:I.Array(I.String),queryName:I.String}))});import{Effect as vr,Number as cs,Option as ls,Schema as Nn,SchemaGetter as Cr,SchemaIssue as fs}from"effect";var Uc=Nn.String.pipe(Nn.decodeTo(Nn.Number,{decode:Cr.transformEffect((e)=>{let t=cs.parse(e);return ls.isSome(t)?vr.succeed(t.value):vr.fail(new fs.InvalidValue({message:"Must be a numeric string"},e))}),encode:Cr.transform(String)}));import{Schema as Ut}from"effect";var ps=/^\+?[\d\s\-()]+$/,ms=(e)=>(e.match(/\d/g)||[]).length,ys=(e)=>{if(!ps.test(e))return!1;let t=ms(e);return t>=7&&t<=15},Kc=Ut.Trim.pipe(Ut.check(Ut.makeFilter((e)=>ys(e),{message:"must be a valid phone number (7-15 digits)"})),Ut.annotate({identifier:"Phone",title:"Phone number",description:"A valid phone number",format:"phone",[hr]:!0}));import{Schema as hs}from"effect";var Yc=hs.Struct({correctedEmail:Rr({label:"Corrected email"})});import{Data as $r,Effect as Y,Result as fl,Schema as Me,SchemaAST as qe}from"effect";class jt extends $r.TaggedError("FieldNameCollisionError"){get message(){return`Field name collision: "${this.wrapperField}" is already present as "${this.fieldName}" in its parent struct`}}class Nr extends $r.TaggedError("InvalidFlattenAnnotationError"){get message(){return`Invalid schema: field "${this.fieldName}" has flatten annotation but is not a struct (AST tag: ${this.astTag}). Only use Wrapper() with Schema.Struct().`}}var Lr=(e,t)=>Y.gen(function*(){let n=We(e),r=e.ast._tag==="Objects";if(n&&!r)return yield*new Nr({fieldName:t,astTag:e.ast._tag});return n&&r}),at=(e)=>Y.gen(function*(){let t={};for(let[n,r]of Object.entries(e.fields)){let o=r;if(Re(o))continue;if(ve(o))continue;if(yield*Lr(o,String(n))){let i=yield*at(o);for(let[s,a]of Object.entries(i.fields)){if(s in t)return yield*new jt({fieldName:s,wrapperField:`${n}...${s}`});t[s]=a}}else{if(n in t)return yield*new jt({fieldName:n,wrapperField:n});t[n]=yield*gs(r)}}return yield*Ss(e.ast),Me.Struct(t)}),gs=(e)=>Y.map(Ce(e.ast),(t)=>Me.make(t)),Ce=(e)=>Y.gen(function*(){let t=e.encoding?yield*Y.forEach(e.encoding,(n)=>Y.map(Ce(n.to),(r)=>new qe.Link(r,n.transformation))):void 0;if(e._tag==="Objects"){let n=[],r=new Set;for(let o of e.propertySignatures){let i=Me.make(o.type);if(Re(i)||ve(i))continue;let s=yield*Lr(i,String(o.name)),a=yield*Ce(o.type),d=s&&a._tag==="Objects"?a.propertySignatures:[new qe.PropertySignature(o.name,a)];for(let u of d){if(r.has(u.name))return yield*new jt({fieldName:String(u.name),wrapperField:`${String(o.name)}...${String(u.name)}`});r.add(u.name),n.push(u)}}return new qe.Objects(n,e.indexSignatures,e.annotations,e.checks,t,e.context,e.encodingChecks)}if(e._tag==="Union")return new qe.Union(yield*Y.forEach(e.types,Ce),e.options,e.annotations,e.checks,t,e.context,e.encodingChecks);if(e._tag==="Arrays")return new qe.Arrays(e.isMutable,yield*Y.forEach(e.elements,Ce),yield*Y.forEach(e.rest,Ce),e.annotations,e.checks,t,e.context,e.encodingChecks);return t?Object.assign(Object.create(Object.getPrototypeOf(e)),e,{encoding:t}):e});var Mr=new WeakMap,Ss=(e)=>Y.gen(function*(){let t=Mr.get(e);if(t)return t;let n=qe.toEncoded(e),r=new Map,o=(s)=>Y.gen(function*(){if(s._tag==="Union")r.set(s,yield*Y.forEach(s.types,(a)=>Y.gen(function*(){let d=yield*Ce(a);return yield*o(a),{ast:a,matches:Me.is(Me.toEncoded(Me.make(d)))}})));else if(s._tag==="Objects")yield*Y.forEach(s.propertySignatures,(a)=>{let d=Me.make(a.type);return Re(d)||ve(d)?Y.void:o(a.type)});else if(s._tag==="Arrays")yield*Y.forEach([...s.elements,...s.rest],(a)=>o(a))});yield*o(n);let i={ast:n,members:r};return Mr.set(e,i),i});import{JsonSchema as Fl,Schema as El,SchemaRepresentation as kl}from"effect";import{Match as Pl}from"effect";import*as xs from"effect/SchemaAST";import{Option as Rl,Schema as vl,SchemaIssue as Cl}from"effect";var vs=J(oe(),1);var zt=(e,t)=>typeof e==="object"&&e!==null&&(t in e)&&e[t]===!0;var Ke=(e)=>zt(e,"isForm");var jn=(e)=>zt(e,"isList"),ct=(e)=>zt(e,"isOrgUnit");var $e=(e)=>zt(e,"isProcess");import{Context as Ms,Data as Vt,Effect as Xl}from"effect";var Ae=(e)=>e.startsWith("/")?e:`/${e}`;var ce=(e)=>e.split("/").filter((r)=>r.length>0).map((r)=>r.replace(/-/g," ").split(/\s+/).filter((i)=>i.length>0).map((i)=>i.charAt(0).toUpperCase()+i.slice(1).toLowerCase()).join("")).join("");class $s extends Vt.TaggedError("SourceStepNotFoundError"){}class Ns extends Vt.TaggedError("EdgeNotFoundError"){}class Ls extends Vt.TaggedError("ConditionFunctionMissingError"){}class Bs extends Vt.TaggedError("ConditionEvaluationError"){}class Us extends Ms.Service()("processfocus:internal-tag/process/ConditionEvaluator"){}var js=J(oe(),1);var Ws=J(oe(),1);var Hs=J(oe(),1);import{DateTime as af}from"effect";import{Context as Ys,Data as oo,Effect as kf}from"effect";import{Context as Vs,Data as no,Effect as wf}from"effect";var Ks=J(oe(),1);import{Schema as pf}from"effect";class Gs extends no.TaggedError("ForEachStepRequiresItemsError"){}class Wn extends no.TaggedError("NotAForEachStepError"){}class ro extends Vs.Service()("processfocus:internal-tag/process/CurrentStepJobContext"){}class Qs extends oo.TaggedError("ForEachStepNotFoundError"){}class Js extends oo.TaggedError("ForEachItemsError"){}class Zs extends Ys.Service()("processfocus:internal-tag/process/ForEachItemsResolver"){}import{Data as ao,Effect as up,Option as cp,Schema as lp,SchemaAST as fp,SchemaGetter as pp}from"effect";import{Array as Uf,Schema as jf,SchemaAST as Wf}from"effect";import{Data as ea,Effect as _f,Schema as me}from"effect";class Gt extends ea.TaggedError("FormDecorationError"){}var Df=me.Array(me.Struct({value:me.String,label:me.String})),Rf=me.Array(me.Struct({value:me.String,startsAt:me.String,endsAt:me.String,label:me.optional(me.String)}));import{Effect as Vf,Option as Gf,Schema as Yf,SchemaAST as Qf}from"effect";class oa extends ao.TaggedError("FormSubmissionError"){}class ia extends ao.TaggedError("LookupFieldNotFoundError"){}var sa=J(oe(),1);var aa=J(oe(),1);import{Data as ze,Effect as _p,String as Ip,Option as Dp,SchemaAST as Rp,Schema as vp}from"effect";class da extends ze.TaggedError("ListItemQueryNotDefinedError"){get message(){return`List ${this.listPath} has no itemQuery defined`}}class ua extends ze.TaggedError("ListItemUpdateNotDefinedError"){get message(){return`List ${this.listPath} has no update function defined`}}class ca extends ze.TaggedError("ListItemDeleteNotDefinedError"){get message(){return`List ${this.listPath} has no delete function defined`}}class la extends ze.TaggedError("ListCreateError"){}class fa extends ze.TaggedError("ListCreateNotDefinedError"){}class pa extends ze.TaggedError("ListUpdateValidationError"){}var ma=J(oe(),1);var Td=J(oe(),1);import{Data as bd}from"effect";import{EventEmitter as ya}from"events";function ha(){let e=arguments[0];for(let t=1,n=arguments.length;t<n;t++){if(!arguments[t])continue;for(let r in arguments[t])e[r]=arguments[t][r]}return e}var H=ha;if(typeof Object.assign==="function")H=Object.assign;function fe(e,t,n,r){let o=e._nodes.get(t),i=null;if(!o)return i;if(r==="mixed")i=o.out&&o.out[n]||o.undirected&&o.undirected[n];else if(r==="directed")i=o.out&&o.out[n];else i=o.undirected&&o.undirected[n];return i}function V(e){return typeof e==="object"&&e!==null}function fo(e){let t;for(t in e)return!1;return!0}function le(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function ye(e,t,n){let r={enumerable:!0,configurable:!0};if(typeof n==="function")r.get=n;else r.value=n,r.writable=!1;Object.defineProperty(e,t,r)}function uo(e){if(!V(e))return!1;if(e.attributes&&!Array.isArray(e.attributes))return!1;return!0}function ga(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function we(){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;continue}break}while(!0);return r}}}function Ge(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class Qt extends Error{constructor(e){super();this.name="GraphError",this.message=e}}class S extends Qt{constructor(e){super(e);if(this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,S.prototype.constructor)}}class g extends Qt{constructor(e){super(e);if(this.name="NotFoundGraphError",typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,g.prototype.constructor)}}class F extends Qt{constructor(e){super(e);if(this.name="UsageGraphError",typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,F.prototype.constructor)}}function po(e,t){this.key=e,this.attributes=t,this.clear()}po.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 mo(e,t){this.key=e,this.attributes=t,this.clear()}mo.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function yo(e,t){this.key=e,this.attributes=t,this.clear()}yo.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Ye(e,t,n,r,o){this.key=t,this.attributes=o,this.undirected=e,this.source=n,this.target=r}Ye.prototype.attach=function(){let e="out",t="in";if(this.undirected)e=t="undirected";let n=this.source.key,r=this.target.key;if(this.source[e][r]=this,this.undirected&&n===r)return;this.target[t][n]=this};Ye.prototype.attachMulti=function(){let e="out",t="in",n=this.source.key,r=this.target.key;if(this.undirected)e=t="undirected";let o=this.source[e],i=o[r];if(typeof i>"u"){if(o[r]=this,!(this.undirected&&n===r))this.target[t][n]=this;return}i.previous=this,this.next=i,o[r]=this,this.target[t][n]=this};Ye.prototype.detach=function(){let e=this.source.key,t=this.target.key,n="out",r="in";if(this.undirected)n=r="undirected";delete this.source[n][t],delete this.target[r][e]};Ye.prototype.detachMulti=function(){let e=this.source.key,t=this.target.key,n="out",r="in";if(this.undirected)n=r="undirected";if(this.previous===void 0)if(this.next===void 0)delete this.source[n][t],delete this.target[r][e];else this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next;else if(this.previous.next=this.next,this.next!==void 0)this.next.previous=this.previous};var ho=0,go=1,Sa=2,So=3;function Te(e,t,n,r,o,i,s){let a,d,u,l;if(r=""+r,n===ho){if(a=e._nodes.get(r),!a)throw new g(`Graph.${t}: could not find the "${r}" node in the graph.`);u=o,l=i}else if(n===So){if(o=""+o,d=e._edges.get(o),!d)throw new g(`Graph.${t}: could not find the "${o}" edge in the graph.`);let c=d.source.key,h=d.target.key;if(r===c)a=d.target;else if(r===h)a=d.source;else throw new g(`Graph.${t}: the "${r}" node is not attached to the "${o}" edge (${c}, ${h}).`);u=i,l=s}else{if(d=e._edges.get(r),!d)throw new g(`Graph.${t}: could not find the "${r}" edge in the graph.`);if(n===go)a=d.source;else a=d.target;u=o,l=i}return[a,u,l]}function xa(e,t,n){e.prototype[t]=function(r,o,i){let[s,a]=Te(this,t,n,r,o,i);return s.attributes[a]}}function wa(e,t,n){e.prototype[t]=function(r,o){let[i]=Te(this,t,n,r,o);return i.attributes}}function Ta(e,t,n){e.prototype[t]=function(r,o,i){let[s,a]=Te(this,t,n,r,o,i);return s.attributes.hasOwnProperty(a)}}function ba(e,t,n){e.prototype[t]=function(r,o,i,s){let[a,d,u]=Te(this,t,n,r,o,i,s);return a.attributes[d]=u,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:d}),this}}function Fa(e,t,n){e.prototype[t]=function(r,o,i,s){let[a,d,u]=Te(this,t,n,r,o,i,s);if(typeof u!=="function")throw new S(`Graph.${t}: updater should be a function.`);let l=a.attributes,c=u(l[d]);return l[d]=c,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:d}),this}}function Ea(e,t,n){e.prototype[t]=function(r,o,i){let[s,a]=Te(this,t,n,r,o,i);return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}function ka(e,t,n){e.prototype[t]=function(r,o,i){let[s,a]=Te(this,t,n,r,o,i);if(!V(a))throw new S(`Graph.${t}: provided attributes are not a plain object.`);return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function Oa(e,t,n){e.prototype[t]=function(r,o,i){let[s,a]=Te(this,t,n,r,o,i);if(!V(a))throw new S(`Graph.${t}: provided attributes are not a plain object.`);return H(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function Aa(e,t,n){e.prototype[t]=function(r,o,i){let[s,a]=Te(this,t,n,r,o,i);if(typeof a!=="function")throw new S(`Graph.${t}: provided updater is not a function.`);return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}var Pa=[{name:(e)=>`get${e}Attribute`,attacher:xa},{name:(e)=>`get${e}Attributes`,attacher:wa},{name:(e)=>`has${e}Attribute`,attacher:Ta},{name:(e)=>`set${e}Attribute`,attacher:ba},{name:(e)=>`update${e}Attribute`,attacher:Fa},{name:(e)=>`remove${e}Attribute`,attacher:Ea},{name:(e)=>`replace${e}Attributes`,attacher:ka},{name:(e)=>`merge${e}Attributes`,attacher:Oa},{name:(e)=>`update${e}Attributes`,attacher:Aa}];function _a(e){Pa.forEach(function({name:t,attacher:n}){n(e,t("Node"),ho),n(e,t("Source"),go),n(e,t("Target"),Sa),n(e,t("Opposite"),So)})}function Ia(e,t,n){e.prototype[t]=function(r,o){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new F(`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=""+r,a=""+o;if(o=arguments[2],i=fe(this,s,a,n),!i)throw new g(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new F(`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(r=""+r,i=this._edges.get(r),!i)throw new g(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes[o]}}function Da(e,t,n){e.prototype[t]=function(r){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new F(`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 i=""+r,s=""+arguments[1];if(o=fe(this,i,s,n),!o)throw new g(`Graph.${t}: could not find an edge for the given path ("${i}" - "${s}").`)}else{if(n!=="mixed")throw new F(`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(r=""+r,o=this._edges.get(r),!o)throw new g(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes}}function Ra(e,t,n){e.prototype[t]=function(r,o){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new F(`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=""+r,a=""+o;if(o=arguments[2],i=fe(this,s,a,n),!i)throw new g(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new F(`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(r=""+r,i=this._edges.get(r),!i)throw new g(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes.hasOwnProperty(o)}}function va(e,t,n){e.prototype[t]=function(r,o,i){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new F(`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=""+r,d=""+o;if(o=arguments[2],i=arguments[3],s=fe(this,a,d,n),!s)throw new g(`Graph.${t}: could not find an edge for the given path ("${a}" - "${d}").`)}else{if(n!=="mixed")throw new F(`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(r=""+r,s=this._edges.get(r),!s)throw new g(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return s.attributes[o]=i,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:o}),this}}function Ca(e,t,n){e.prototype[t]=function(r,o,i){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new F(`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=""+r,d=""+o;if(o=arguments[2],i=arguments[3],s=fe(this,a,d,n),!s)throw new g(`Graph.${t}: could not find an edge for the given path ("${a}" - "${d}").`)}else{if(n!=="mixed")throw new F(`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(r=""+r,s=this._edges.get(r),!s)throw new g(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!=="function")throw new S(`Graph.${t}: updater should be a function.`);return s.attributes[o]=i(s.attributes[o]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:o}),this}}function Ma(e,t,n){e.prototype[t]=function(r,o){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new F(`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=""+r,a=""+o;if(o=arguments[2],i=fe(this,s,a,n),!i)throw new g(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new F(`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(r=""+r,i=this._edges.get(r),!i)throw new g(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return delete i.attributes[o],this.emit("edgeAttributesUpdated",{key:i.key,type:"remove",attributes:i.attributes,name:o}),this}}function $a(e,t,n){e.prototype[t]=function(r,o){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new F(`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=""+r,a=""+o;if(o=arguments[2],i=fe(this,s,a,n),!i)throw new g(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new F(`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(r=""+r,i=this._edges.get(r),!i)throw new g(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!V(o))throw new S(`Graph.${t}: provided attributes are not a plain object.`);return i.attributes=o,this.emit("edgeAttributesUpdated",{key:i.key,type:"replace",attributes:i.attributes}),this}}function Na(e,t,n){e.prototype[t]=function(r,o){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new F(`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=""+r,a=""+o;if(o=arguments[2],i=fe(this,s,a,n),!i)throw new g(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new F(`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(r=""+r,i=this._edges.get(r),!i)throw new g(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!V(o))throw new S(`Graph.${t}: provided attributes are not a plain object.`);return H(i.attributes,o),this.emit("edgeAttributesUpdated",{key:i.key,type:"merge",attributes:i.attributes,data:o}),this}}function La(e,t,n){e.prototype[t]=function(r,o){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new F(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new F(`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=""+r,a=""+o;if(o=arguments[2],i=fe(this,s,a,n),!i)throw new g(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new F(`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(r=""+r,i=this._edges.get(r),!i)throw new g(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!=="function")throw new S(`Graph.${t}: provided updater is not a function.`);return i.attributes=o(i.attributes),this.emit("edgeAttributesUpdated",{key:i.key,type:"update",attributes:i.attributes}),this}}var Ba=[{name:(e)=>`get${e}Attribute`,attacher:Ia},{name:(e)=>`get${e}Attributes`,attacher:Da},{name:(e)=>`has${e}Attribute`,attacher:Ra},{name:(e)=>`set${e}Attribute`,attacher:va},{name:(e)=>`update${e}Attribute`,attacher:Ca},{name:(e)=>`remove${e}Attribute`,attacher:Ma},{name:(e)=>`replace${e}Attributes`,attacher:$a},{name:(e)=>`merge${e}Attributes`,attacher:Na},{name:(e)=>`update${e}Attributes`,attacher:La}];function Ua(e){Ba.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}var ja=[{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 Wa(e,t,n,r){let o=!1;for(let i in t){if(i===r)continue;let s=t[i];if(o=n(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),e&&o)return s.key}return}function Ha(e,t,n,r){let o,i,s,a=!1;for(let d in t){if(d===r)continue;o=t[d];do{if(i=o.source,s=o.target,a=n(o.key,o.attributes,i.key,s.key,i.attributes,s.attributes,o.undirected),e&&a)return o.key;o=o.next}while(o!==void 0)}return}function Hn(e,t){let n=Object.keys(e),r=n.length,o,i=0;return{[Symbol.iterator](){return this},next(){do if(!o){if(i>=r)return{done:!0};let s=n[i++];if(s===t){o=void 0;continue}o=e[s]}else o=o.next;while(!o);return{done:!1,value:{edge:o.key,attributes:o.attributes,source:o.source.key,target:o.target.key,sourceAttributes:o.source.attributes,targetAttributes:o.target.attributes,undirected:o.undirected}}}}}function qa(e,t,n,r){let o=t[n];if(!o)return;let{source:i,target:s}=o;if(r(o.key,o.attributes,i.key,s.key,i.attributes,s.attributes,o.undirected)&&e)return o.key}function Ka(e,t,n,r){let o=t[n];if(!o)return;let i=!1;do{if(i=r(o.key,o.attributes,o.source.key,o.target.key,o.source.attributes,o.target.attributes,o.undirected),e&&i)return o.key;o=o.next}while(o!==void 0);return}function qn(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};let o={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:o}}};let r=!1;return{[Symbol.iterator](){return this},next(){if(r===!0)return{done:!0};return 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 za(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),o=t==="undirected",i=e._edges.values(),s=0,a,d;while(a=i.next(),a.done!==!0)if(d=a.value,d.undirected===o)r[s++]=d.key;return r}function xo(e,t,n,r){if(t.size===0)return;let o=n!=="mixed"&&n!==t.type,i=n==="undirected",s,a,d=!1,u=t._edges.values();while(s=u.next(),s.done!==!0){if(a=s.value,o&&a.undirected!==i)continue;let{key:l,attributes:c,source:h,target:w}=a;if(d=r(l,c,h.key,w.key,h.attributes,w.attributes,a.undirected),e&&d)return l}return}function Va(e,t){if(e.size===0)return Ge();let n=t!=="mixed"&&t!==e.type,r=t==="undirected",o=e._edges.values();return{[Symbol.iterator](){return this},next(){let i,s;while(!0){if(i=o.next(),i.done)return i;if(s=i.value,n&&s.undirected!==r)continue;break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function Kn(e,t,n,r,o,i){let s=t?Ha:Wa,a;if(n!=="undirected"){if(r!=="out"){if(a=s(e,o.in,i),e&&a)return a}if(r!=="in"){if(a=s(e,o.out,i,!r?o.key:void 0),e&&a)return a}}if(n!=="directed"){if(a=s(e,o.undirected,i),e&&a)return a}return}function Ga(e,t,n,r){let o=[];return Kn(!1,e,t,n,r,function(i){o.push(i)}),o}function Ya(e,t,n){let r=Ge();if(e!=="undirected"){if(t!=="out"&&typeof n.in<"u")r=we(r,Hn(n.in));if(t!=="in"&&typeof n.out<"u")r=we(r,Hn(n.out,!t?n.key:void 0))}if(e!=="directed"&&typeof n.undirected<"u")r=we(r,Hn(n.undirected));return r}function zn(e,t,n,r,o,i,s){let a=n?Ka:qa,d;if(t!=="undirected"){if(typeof o.in<"u"&&r!=="out"){if(d=a(e,o.in,i,s),e&&d)return d}if(typeof o.out<"u"&&r!=="in"&&(r||o.key!==i)){if(d=a(e,o.out,i,s),e&&d)return d}}if(t!=="directed"){if(typeof o.undirected<"u"){if(d=a(e,o.undirected,i,s),e&&d)return d}}return}function Qa(e,t,n,r,o){let i=[];return zn(!1,e,t,n,r,o,function(s){i.push(s)}),i}function Ja(e,t,n,r){let o=Ge();if(e!=="undirected"){if(typeof n.in<"u"&&t!=="out"&&r in n.in)o=we(o,qn(n.in,r));if(typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r))o=we(o,qn(n.out,r))}if(e!=="directed"){if(typeof n.undirected<"u"&&r in n.undirected)o=we(o,qn(n.undirected,r))}return o}function Za(e,t){let{name:n,type:r,direction:o}=t;e.prototype[n]=function(i,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return za(this,r);if(arguments.length===1){i=""+i;let a=this._nodes.get(i);if(typeof a>"u")throw new g(`Graph.${n}: could not find the "${i}" node in the graph.`);return Ga(this.multi,r==="mixed"?this.type:r,o,a)}if(arguments.length===2){i=""+i,s=""+s;let a=this._nodes.get(i);if(!a)throw new g(`Graph.${n}: could not find the "${i}" source node in the graph.`);if(!this._nodes.has(s))throw new g(`Graph.${n}: could not find the "${s}" target node in the graph.`);return Qa(r,this.multi,o,a,s)}throw new S(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function Xa(e,t){let{name:n,type:r,direction:o}=t,i="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[i]=function(u,l,c){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;if(arguments.length===1)return c=u,xo(!1,this,r,c);if(arguments.length===2){u=""+u,c=l;let h=this._nodes.get(u);if(typeof h>"u")throw new g(`Graph.${i}: could not find the "${u}" node in the graph.`);return Kn(!1,this.multi,r==="mixed"?this.type:r,o,h,c)}if(arguments.length===3){u=""+u,l=""+l;let h=this._nodes.get(u);if(!h)throw new g(`Graph.${i}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(l))throw new g(`Graph.${i}: could not find the "${l}" target node in the graph.`);return zn(!1,r,this.multi,o,h,l,c)}throw new S(`Graph.${i}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){let u=Array.prototype.slice.call(arguments),l=u.pop(),c;if(u.length===0){let h=0;if(r!=="directed")h+=this.undirectedSize;if(r!=="undirected")h+=this.directedSize;c=Array(h);let w=0;u.push((T,B,D,j,b,P,f)=>{c[w++]=l(T,B,D,j,b,P,f)})}else c=[],u.push((h,w,T,B,D,j,b)=>{c.push(l(h,w,T,B,D,j,b))});return this[i].apply(this,u),c};let a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(){let u=Array.prototype.slice.call(arguments),l=u.pop(),c=[];return u.push((h,w,T,B,D,j,b)=>{if(l(h,w,T,B,D,j,b))c.push(h)}),this[i].apply(this,u),c};let d="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[d]=function(){let u=Array.prototype.slice.call(arguments);if(u.length<2||u.length>4)throw new S(`Graph.${d}: invalid number of arguments (expecting 2, 3 or 4 and got ${u.length}).`);if(typeof u[u.length-1]==="function"&&typeof u[u.length-2]!=="function")throw new S(`Graph.${d}: 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 l,c;if(u.length===2)l=u[0],c=u[1],u=[];else if(u.length===3)l=u[1],c=u[2],u=[u[0]];else if(u.length===4)l=u[2],c=u[3],u=[u[0],u[1]];let h=c;return u.push((w,T,B,D,j,b,P)=>{h=l(h,w,T,B,D,j,b,P)}),this[i].apply(this,u),h}}function ed(e,t){let{name:n,type:r,direction:o}=t,i="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[i]=function(d,u,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return l=d,xo(!0,this,r,l);if(arguments.length===2){d=""+d,l=u;let c=this._nodes.get(d);if(typeof c>"u")throw new g(`Graph.${i}: could not find the "${d}" node in the graph.`);return Kn(!0,this.multi,r==="mixed"?this.type:r,o,c,l)}if(arguments.length===3){d=""+d,u=""+u;let c=this._nodes.get(d);if(!c)throw new g(`Graph.${i}: could not find the "${d}" source node in the graph.`);if(!this._nodes.has(u))throw new g(`Graph.${i}: could not find the "${u}" target node in the graph.`);return zn(!0,r,this.multi,o,c,u,l)}throw new S(`Graph.${i}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};let s="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){let d=Array.prototype.slice.call(arguments),u=d.pop();if(d.push((c,h,w,T,B,D,j)=>u(c,h,w,T,B,D,j)),this[i].apply(this,d))return!0;return!1};let a="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(){let d=Array.prototype.slice.call(arguments),u=d.pop();if(d.push((c,h,w,T,B,D,j)=>!u(c,h,w,T,B,D,j)),this[i].apply(this,d))return!1;return!0}}function td(e,t){let{name:n,type:r,direction:o}=t,i=n.slice(0,-1)+"Entries";e.prototype[i]=function(s,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Ge();if(!arguments.length)return Va(this,r);if(arguments.length===1){s=""+s;let d=this._nodes.get(s);if(!d)throw new g(`Graph.${i}: could not find the "${s}" node in the graph.`);return Ya(r,o,d)}if(arguments.length===2){s=""+s,a=""+a;let d=this._nodes.get(s);if(!d)throw new g(`Graph.${i}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new g(`Graph.${i}: could not find the "${a}" target node in the graph.`);return Ja(r,o,d,a)}throw new S(`Graph.${i}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function nd(e){ja.forEach((t)=>{Za(e,t),Xa(e,t),ed(e,t),td(e,t)})}var rd=[{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 Jt(){this.A=null,this.B=null}Jt.prototype.wrap=function(e){if(this.A===null)this.A=e;else if(this.B===null)this.B=e};Jt.prototype.has=function(e){if(this.A!==null&&e in this.A)return!0;if(this.B!==null&&e in this.B)return!0;return!1};function lt(e,t,n,r,o){for(let i in r){let s=r[i],{source:a,target:d}=s,u=a===n?d:a;if(t&&t.has(u.key))continue;let l=o(u.key,u.attributes);if(e&&l)return u.key}return}function Vn(e,t,n,r,o){if(t!=="mixed"){if(t==="undirected")return lt(e,null,r,r.undirected,o);if(typeof n==="string")return lt(e,null,r,r[n],o)}let i=new Jt,s;if(t!=="undirected"){if(n!=="out"){if(s=lt(e,null,r,r.in,o),e&&s)return s;i.wrap(r.in)}if(n!=="in"){if(s=lt(e,i,r,r.out,o),e&&s)return s;i.wrap(r.out)}}if(t!=="directed"){if(s=lt(e,i,r,r.undirected,o),e&&s)return s}return}function od(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 Vn(!1,e,t,n,function(o){r.push(o)}),r}function ft(e,t,n){let r=Object.keys(n),o=r.length,i=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(i>=o){if(e)e.wrap(n);return{done:!0}}let a=n[r[i++]],{source:d,target:u}=a;if(s=d===t?u:d,e&&e.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function id(e,t,n){if(e!=="mixed"){if(e==="undirected")return ft(null,n,n.undirected);if(typeof t==="string")return ft(null,n,n[t])}let r=Ge(),o=new Jt;if(e!=="undirected"){if(t!=="out")r=we(r,ft(o,n,n.in));if(t!=="in")r=we(r,ft(o,n,n.out))}if(e!=="directed")r=we(r,ft(o,n,n.undirected));return r}function sd(e,t){let{name:n,type:r,direction:o}=t;e.prototype[n]=function(i){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];i=""+i;let s=this._nodes.get(i);if(typeof s>"u")throw new g(`Graph.${n}: could not find the "${i}" node in the graph.`);return od(r==="mixed"?this.type:r,o,s)}}function ad(e,t){let{name:n,type:r,direction:o}=t,i="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[i]=function(u,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let c=this._nodes.get(u);if(typeof c>"u")throw new g(`Graph.${i}: could not find the "${u}" node in the graph.`);Vn(!1,r==="mixed"?this.type:r,o,c,l)};let s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(u,l){let c=[];return this[i](u,(h,w)=>{c.push(l(h,w))}),c};let a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(u,l){let c=[];return this[i](u,(h,w)=>{if(l(h,w))c.push(h)}),c};let d="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[d]=function(u,l,c){if(arguments.length<3)throw new S(`Graph.${d}: 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 h=c;return this[i](u,(w,T)=>{h=l(h,w,T)}),h}}function dd(e,t){let{name:n,type:r,direction:o}=t,i=n[0].toUpperCase()+n.slice(1,-1),s="find"+i;e.prototype[s]=function(u,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;u=""+u;let c=this._nodes.get(u);if(typeof c>"u")throw new g(`Graph.${s}: could not find the "${u}" node in the graph.`);return Vn(!0,r==="mixed"?this.type:r,o,c,l)};let a="some"+i;e.prototype[a]=function(u,l){if(this[s](u,l))return!0;return!1};let d="every"+i;e.prototype[d]=function(u,l){if(this[s](u,(h,w)=>!l(h,w)))return!1;return!0}}function ud(e,t){let{name:n,type:r,direction:o}=t,i=n.slice(0,-1)+"Entries";e.prototype[i]=function(s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Ge();s=""+s;let a=this._nodes.get(s);if(typeof a>"u")throw new g(`Graph.${i}: could not find the "${s}" node in the graph.`);return id(r==="mixed"?this.type:r,o,a)}}function cd(e){rd.forEach((t)=>{sd(e,t),ad(e,t),dd(e,t),ud(e,t)})}function Yt(e,t,n,r,o){let i=r._nodes.values(),s=r.type,a,d,u,l,c,h,w;while(a=i.next(),a.done!==!0){let T=!1;if(d=a.value,s!=="undirected"){l=d.out;for(u in l){c=l[u];do{if(h=c.target,T=!0,w=o(d.key,h.key,d.attributes,h.attributes,c.key,c.attributes,c.undirected),e&&w)return c;c=c.next}while(c)}}if(s!=="directed"){l=d.undirected;for(u in l){if(t&&d.key>u)continue;c=l[u];do{if(h=c.target,h.key!==u)h=c.source;if(T=!0,w=o(d.key,h.key,d.attributes,h.attributes,c.key,c.attributes,c.undirected),e&&w)return c;c=c.next}while(c)}}if(n&&!T){if(w=o(d.key,null,d.attributes,null,null,null,null),e&&w)return null}}return}function ld(e,t){let n={key:e};if(!fo(t.attributes))n.attributes=H({},t.attributes);return n}function fd(e,t,n){let r={key:t,source:n.source.key,target:n.target.key};if(!fo(n.attributes))r.attributes=H({},n.attributes);if(e==="mixed"&&n.undirected)r.undirected=!0;return r}function pd(e){if(!V(e))throw new S('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 S("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!V(e.attributes)||e.attributes===null))throw new S("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function md(e){if(!V(e))throw new S('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 S("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new S("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!V(e.attributes)||e.attributes===null))throw new S("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!=="boolean")throw new S("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}var yd=ga(),hd=new Set(["directed","undirected","mixed"]),co=new Set(["domain","_events","_eventsCount","_maxListeners"]),gd=[{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"}],Sd={allowSelfLoops:!0,multi:!1,type:"mixed"};function xd(e,t,n){if(n&&!V(n))throw new S(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new F(`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 lo(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 wo(e,t,n,r,o,i,s,a){if(!r&&e.type==="undirected")throw new F(`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 F(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!V(a))throw new S(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`);if(i=""+i,s=""+s,a=a||{},!e.allowSelfLoops&&i===s)throw new F(`Graph.${t}: source & target are the same ("${i}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let d=e._nodes.get(i),u=e._nodes.get(s);if(!d)throw new g(`Graph.${t}: source node "${i}" not found.`);if(!u)throw new g(`Graph.${t}: target node "${s}" not found.`);let l={key:null,undirected:r,source:i,target:s,attributes:a};if(n)o=e._edgeKeyGenerator();else if(o=""+o,e._edges.has(o))throw new F(`Graph.${t}: the "${o}" edge already exists in the graph.`);if(!e.multi&&(r?typeof d.undirected[s]<"u":typeof d.out[s]<"u"))throw new F(`Graph.${t}: an edge linking "${i}" 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 c=new Ye(r,o,d,u,a);e._edges.set(o,c);let h=i===s;if(r){if(d.undirectedDegree++,u.undirectedDegree++,h)d.undirectedLoops++,e._undirectedSelfLoopCount++}else if(d.outDegree++,u.inDegree++,h)d.directedLoops++,e._directedSelfLoopCount++;if(e.multi)c.attachMulti();else c.attach();if(r)e._undirectedSize++;else e._directedSize++;return l.key=o,e.emit("edgeAdded",l),o}function wd(e,t,n,r,o,i,s,a,d){if(!r&&e.type==="undirected")throw new F(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new F(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(a){if(d){if(typeof a!=="function")throw new S(`Graph.${t}: invalid updater function. Expecting a function but got "${a}"`)}else if(!V(a))throw new S(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`)}i=""+i,s=""+s;let u;if(d)u=a,a=void 0;if(!e.allowSelfLoops&&i===s)throw new F(`Graph.${t}: source & target are the same ("${i}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(i),c=e._nodes.get(s),h,w;if(!n){if(h=e._edges.get(o),h){if(h.source.key!==i||h.target.key!==s){if(!r||h.source.key!==s||h.target.key!==i)throw new F(`Graph.${t}: inconsistency detected when attempting to merge the "${o}" edge with "${i}" source & "${s}" target vs. ("${h.source.key}", "${h.target.key}").`)}w=h}}if(!w&&!e.multi&&l)w=r?l.undirected[s]:l.out[s];if(w){let b=[w.key,!1,!1,!1];if(d?!u:!a)return b;if(d){let P=w.attributes;w.attributes=u(P),e.emit("edgeAttributesUpdated",{type:"replace",key:w.key,attributes:w.attributes})}else H(w.attributes,a),e.emit("edgeAttributesUpdated",{type:"merge",key:w.key,attributes:w.attributes,data:a});return b}if(a=a||{},d&&u)a=u(a);let T={key:null,undirected:r,source:i,target:s,attributes:a};if(n)o=e._edgeKeyGenerator();else if(o=""+o,e._edges.has(o))throw new F(`Graph.${t}: the "${o}" edge already exists in the graph.`);let B=!1,D=!1;if(!l){if(l=lo(e,i,{}),B=!0,i===s)c=l,D=!0}if(!c)c=lo(e,s,{}),D=!0;h=new Ye(r,o,l,c,a),e._edges.set(o,h);let j=i===s;if(r){if(l.undirectedDegree++,c.undirectedDegree++,j)l.undirectedLoops++,e._undirectedSelfLoopCount++}else if(l.outDegree++,c.inDegree++,j)l.directedLoops++,e._directedSelfLoopCount++;if(e.multi)h.attachMulti();else h.attach();if(r)e._undirectedSize++;else e._directedSize++;return T.key=o,e.emit("edgeAdded",T),[o,!0,B,D]}function Ve(e,t){e._edges.delete(t.key);let{source:n,target:r,attributes:o}=t,i=t.undirected,s=n===r;if(i){if(n.undirectedDegree--,r.undirectedDegree--,s)n.undirectedLoops--,e._undirectedSelfLoopCount--}else if(n.outDegree--,r.inDegree--,s)n.directedLoops--,e._directedSelfLoopCount--;if(e.multi)t.detachMulti();else t.detach();if(i)e._undirectedSize--;else e._directedSize--;e.emit("edgeDropped",{key:t.key,attributes:o,source:n.key,target:r.key,undirected:i})}class R extends ya{constructor(e){super();if(e=H({},Sd,e),typeof e.multi!=="boolean")throw new S(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${e.multi}".`);if(!hd.has(e.type))throw new S(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${e.type}".`);if(typeof e.allowSelfLoops!=="boolean")throw new S(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${e.allowSelfLoops}".`);let t=e.type==="mixed"?po:e.type==="directed"?mo:yo;le(this,"NodeDataClass",t);let n="geid_"+yd()+"_",r=0,o=()=>{let i;do i=n+r++;while(this._edges.has(i));return i};le(this,"_attributes",{}),le(this,"_nodes",new Map),le(this,"_edges",new Map),le(this,"_directedSize",0),le(this,"_undirectedSize",0),le(this,"_directedSelfLoopCount",0),le(this,"_undirectedSelfLoopCount",0),le(this,"_edgeKeyGenerator",o),le(this,"_options",e),co.forEach((i)=>le(this,i,this[i])),ye(this,"order",()=>this._nodes.size),ye(this,"size",()=>this._edges.size),ye(this,"directedSize",()=>this._directedSize),ye(this,"undirectedSize",()=>this._undirectedSize),ye(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),ye(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),ye(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),ye(this,"multi",this._options.multi),ye(this,"type",this._options.type),ye(this,"allowSelfLoops",this._options.allowSelfLoops),ye(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 n=""+e,r=this._edges.get(n);return!!r&&!r.undirected}else if(arguments.length===2){e=""+e,t=""+t;let n=this._nodes.get(e);if(!n)return!1;return n.out.hasOwnProperty(t)}throw new S(`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 n=""+e,r=this._edges.get(n);return!!r&&r.undirected}else if(arguments.length===2){e=""+e,t=""+t;let n=this._nodes.get(e);if(!n)return!1;return n.undirected.hasOwnProperty(t)}throw new S(`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 n=""+e;return this._edges.has(n)}else if(arguments.length===2){e=""+e,t=""+t;let n=this._nodes.get(e);if(!n)return!1;return typeof n.out<"u"&&n.out.hasOwnProperty(t)||typeof n.undirected<"u"&&n.undirected.hasOwnProperty(t)}throw new S(`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 F("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 g(`Graph.directedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new g(`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 F("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 g(`Graph.undirectedEdge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new g(`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 F("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 g(`Graph.edge: could not find the "${e}" source node in the graph.`);if(!this._nodes.has(t))throw new g(`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 g(`Graph.areDirectedNeighbors: could not find the "${e}" node in the graph.`);if(this.type==="undirected")return!1;return 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 g(`Graph.areOutNeighbors: could not find the "${e}" node in the graph.`);if(this.type==="undirected")return!1;return t in n.out}areInNeighbors(e,t){e=""+e,t=""+t;let n=this._nodes.get(e);if(!n)throw new g(`Graph.areInNeighbors: could not find the "${e}" node in the graph.`);if(this.type==="undirected")return!1;return t in n.in}areUndirectedNeighbors(e,t){e=""+e,t=""+t;let n=this._nodes.get(e);if(!n)throw new g(`Graph.areUndirectedNeighbors: could not find the "${e}" node in the graph.`);if(this.type==="directed")return!1;return t in n.undirected}areNeighbors(e,t){e=""+e,t=""+t;let n=this._nodes.get(e);if(!n)throw new g(`Graph.areNeighbors: could not find the "${e}" node in the graph.`);if(this.type!=="undirected"){if(t in n.in||t in n.out)return!0}if(this.type!=="directed"){if(t in n.undirected)return!0}return!1}areInboundNeighbors(e,t){e=""+e,t=""+t;let n=this._nodes.get(e);if(!n)throw new g(`Graph.areInboundNeighbors: could not find the "${e}" node in the graph.`);if(this.type!=="undirected"){if(t in n.in)return!0}if(this.type!=="directed"){if(t in n.undirected)return!0}return!1}areOutboundNeighbors(e,t){e=""+e,t=""+t;let n=this._nodes.get(e);if(!n)throw new g(`Graph.areOutboundNeighbors: could not find the "${e}" node in the graph.`);if(this.type!=="undirected"){if(t in n.out)return!0}if(this.type!=="directed"){if(t in n.undirected)return!0}return!1}inDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new g(`Graph.inDegree: could not find the "${e}" node in the graph.`);if(this.type==="undirected")return 0;return t.inDegree}outDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new g(`Graph.outDegree: could not find the "${e}" node in the graph.`);if(this.type==="undirected")return 0;return t.outDegree}directedDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new g(`Graph.directedDegree: could not find the "${e}" node in the graph.`);if(this.type==="undirected")return 0;return t.inDegree+t.outDegree}undirectedDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new g(`Graph.undirectedDegree: could not find the "${e}" node in the graph.`);if(this.type==="directed")return 0;return t.undirectedDegree}inboundDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new g(`Graph.inboundDegree: could not find the "${e}" node in the graph.`);let n=0;if(this.type!=="directed")n+=t.undirectedDegree;if(this.type!=="undirected")n+=t.inDegree;return n}outboundDegree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new g(`Graph.outboundDegree: could not find the "${e}" node in the graph.`);let n=0;if(this.type!=="directed")n+=t.undirectedDegree;if(this.type!=="undirected")n+=t.outDegree;return n}degree(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new g(`Graph.degree: could not find the "${e}" node in the graph.`);let n=0;if(this.type!=="directed")n+=t.undirectedDegree;if(this.type!=="undirected")n+=t.inDegree+t.outDegree;return n}inDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new g(`Graph.inDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);if(this.type==="undirected")return 0;return t.inDegree-t.directedLoops}outDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new g(`Graph.outDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);if(this.type==="undirected")return 0;return t.outDegree-t.directedLoops}directedDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new g(`Graph.directedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);if(this.type==="undirected")return 0;return t.inDegree+t.outDegree-t.directedLoops*2}undirectedDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new g(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);if(this.type==="directed")return 0;return t.undirectedDegree-t.undirectedLoops*2}inboundDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new g(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;if(this.type!=="directed")n+=t.undirectedDegree,r+=t.undirectedLoops*2;if(this.type!=="undirected")n+=t.inDegree,r+=t.directedLoops;return n-r}outboundDegreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new g(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;if(this.type!=="directed")n+=t.undirectedDegree,r+=t.undirectedLoops*2;if(this.type!=="undirected")n+=t.outDegree,r+=t.directedLoops;return n-r}degreeWithoutSelfLoops(e){e=""+e;let t=this._nodes.get(e);if(!t)throw new g(`Graph.degreeWithoutSelfLoops: could not find the "${e}" node in the graph.`);let n=0,r=0;if(this.type!=="directed")n+=t.undirectedDegree,r+=t.undirectedLoops*2;if(this.type!=="undirected")n+=t.inDegree+t.outDegree,r+=t.directedLoops*2;return n-r}source(e){e=""+e;let t=this._edges.get(e);if(!t)throw new g(`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 g(`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 g(`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 g(`Graph.opposite: could not find the "${t}" edge in the graph.`);let r=n.source.key,o=n.target.key;if(e===r)return o;if(e===o)return r;throw new g(`Graph.opposite: the "${e}" node is not attached to the "${t}" edge (${r}, ${o}).`)}hasExtremity(e,t){e=""+e,t=""+t;let n=this._edges.get(e);if(!n)throw new g(`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 g(`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 g(`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 g(`Graph.isSelfLoop: could not find the "${e}" edge in the graph.`);return t.source===t.target}addNode(e,t){return xd(this,e,t).key}mergeNode(e,t){if(t&&!V(t))throw new S(`Graph.mergeNode: invalid attributes. Expecting an object but got "${t}"`);e=""+e,t=t||{};let n=this._nodes.get(e);if(n){if(t)H(n.attributes,t),this.emit("nodeAttributesUpdated",{type:"merge",key:e,attributes:n.attributes,data:t});return[e,!1]}return 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 S(`Graph.updateNode: invalid updater function. Expecting a function but got "${t}"`);e=""+e;let n=this._nodes.get(e);if(n){if(t){let o=n.attributes;n.attributes=t(o),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 g(`Graph.dropNode: could not find the "${e}" node in the graph.`);let n;if(this.type!=="undirected"){for(let r in t.out){n=t.out[r];do Ve(this,n),n=n.next;while(n)}for(let r in t.in){n=t.in[r];do Ve(this,n),n=n.next;while(n)}}if(this.type!=="directed")for(let r in t.undirected){n=t.undirected[r];do Ve(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 n=""+arguments[0],r=""+arguments[1];if(t=fe(this,n,r,this.type),!t)throw new g(`Graph.dropEdge: could not find the "${n}" -> "${r}" edge in the graph.`)}else if(e=""+e,t=this._edges.get(e),!t)throw new g(`Graph.dropEdge: could not find the "${e}" edge in the graph.`);return Ve(this,t),this}dropDirectedEdge(e,t){if(arguments.length<2)throw new F("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 F("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=fe(this,e,t,"directed");if(!n)throw new g(`Graph.dropDirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return Ve(this,n),this}dropUndirectedEdge(e,t){if(arguments.length<2)throw new F("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 F("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=fe(this,e,t,"undirected");if(!n)throw new g(`Graph.dropUndirectedEdge: could not find a "${e}" -> "${t}" edge in the graph.`);return Ve(this,n),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){let e=this._nodes.values(),t;while(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 S("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(!V(e))throw new S("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(!V(e))throw new S("Graph.mergeAttributes: provided attributes are not a plain object.");return H(this._attributes,e),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:e}),this}updateAttributes(e){if(typeof e!=="function")throw new S("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 S("Graph.updateEachNodeAttributes: expecting an updater function.");if(t&&!uo(t))throw new S("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let n=this._nodes.values(),r,o;while(r=n.next(),r.done!==!0)o=r.value,o.attributes=e(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:t?t:null})}updateEachEdgeAttributes(e,t){if(typeof e!=="function")throw new S("Graph.updateEachEdgeAttributes: expecting an updater function.");if(t&&!uo(t))throw new S("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");let n=this._edges.values(),r,o,i,s;while(r=n.next(),r.done!==!0)o=r.value,i=o.source,s=o.target,o.attributes=e(o.key,o.attributes,i.key,s.key,i.attributes,s.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:t?t:null})}forEachAdjacencyEntry(e){if(typeof e!=="function")throw new S("Graph.forEachAdjacencyEntry: expecting a callback.");Yt(!1,!1,!1,this,e)}forEachAdjacencyEntryWithOrphans(e){if(typeof e!=="function")throw new S("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Yt(!1,!1,!0,this,e)}forEachAssymetricAdjacencyEntry(e){if(typeof e!=="function")throw new S("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Yt(!1,!0,!1,this,e)}forEachAssymetricAdjacencyEntryWithOrphans(e){if(typeof e!=="function")throw new S("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Yt(!1,!0,!0,this,e)}nodes(){return Array.from(this._nodes.keys())}forEachNode(e){if(typeof e!=="function")throw new S("Graph.forEachNode: expecting a callback.");let t=this._nodes.values(),n,r;while(n=t.next(),n.done!==!0)r=n.value,e(r.key,r.attributes)}findNode(e){if(typeof e!=="function")throw new S("Graph.findNode: expecting a callback.");let t=this._nodes.values(),n,r;while(n=t.next(),n.done!==!0)if(r=n.value,e(r.key,r.attributes))return r.key;return}mapNodes(e){if(typeof e!=="function")throw new S("Graph.mapNode: expecting a callback.");let t=this._nodes.values(),n,r,o=Array(this.order),i=0;while(n=t.next(),n.done!==!0)r=n.value,o[i++]=e(r.key,r.attributes);return o}someNode(e){if(typeof e!=="function")throw new S("Graph.someNode: expecting a callback.");let t=this._nodes.values(),n,r;while(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 S("Graph.everyNode: expecting a callback.");let t=this._nodes.values(),n,r;while(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 S("Graph.filterNodes: expecting a callback.");let t=this._nodes.values(),n,r,o=[];while(n=t.next(),n.done!==!0)if(r=n.value,e(r.key,r.attributes))o.push(r.key);return o}reduceNodes(e,t){if(typeof e!=="function")throw new S("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new S("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(),o,i;while(o=r.next(),o.done!==!0)i=o.value,n=e(n,i.key,i.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((r,o)=>{e[t++]=ld(o,r)});let n=Array(this._edges.size);return t=0,this._edges.forEach((r,o)=>{n[t++]=fd(this.type,o,r)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:e,edges:n}}import(e,t=!1){if(e instanceof R)return e.forEachNode((a,d)=>{if(t)this.mergeNode(a,d);else this.addNode(a,d)}),e.forEachEdge((a,d,u,l,c,h,w)=>{if(t)if(w)this.mergeUndirectedEdgeWithKey(a,u,l,d);else this.mergeDirectedEdgeWithKey(a,u,l,d);else if(w)this.addUndirectedEdgeWithKey(a,u,l,d);else this.addDirectedEdgeWithKey(a,u,l,d)}),this;if(!V(e))throw new S("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(e.attributes){if(!V(e.attributes))throw new S("Graph.import: invalid attributes. Expecting a plain object.");if(t)this.mergeAttributes(e.attributes);else this.replaceAttributes(e.attributes)}let n,r,o,i,s;if(e.nodes){if(o=e.nodes,!Array.isArray(o))throw new S("Graph.import: invalid nodes. Expecting an array.");for(n=0,r=o.length;n<r;n++){i=o[n],pd(i);let{key:a,attributes:d}=i;if(t)this.mergeNode(a,d);else this.addNode(a,d)}}if(e.edges){let a=!1;if(this.type==="undirected")a=!0;if(o=e.edges,!Array.isArray(o))throw new S("Graph.import: invalid edges. Expecting an array.");for(n=0,r=o.length;n<r;n++){s=o[n],md(s);let{source:d,target:u,attributes:l,undirected:c=a}=s,h;if("key"in s)h=t?c?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:c?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,h.call(this,s.key,d,u,l);else h=t?c?this.mergeUndirectedEdge:this.mergeDirectedEdge:c?this.addUndirectedEdge:this.addDirectedEdge,h.call(this,d,u,l)}}return this}nullCopy(e){let t=new R(H({},this._options,e));return t.replaceAttributes(H({},this.getAttributes())),t}emptyCopy(e){let t=this.nullCopy(e);return this._nodes.forEach((n,r)=>{let o=H({},n.attributes);n=new t.NodeDataClass(r,o),t._nodes.set(r,n)}),t}copy(e){if(e=e||{},typeof e.type==="string"&&e.type!==this.type&&e.type!=="mixed")throw new F(`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 F("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 F("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(),r,o;while(r=n.next(),r.done!==!0)o=r.value,wo(t,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,H({},o.attributes));return t}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){let e={};this._nodes.forEach((o,i)=>{e[i]=o.attributes});let t={},n={};this._edges.forEach((o,i)=>{let s=o.undirected?"--":"->",a="",d=o.source.key,u=o.target.key,l;if(o.undirected&&d>u)l=d,d=u,u=l;let c=`(${d})${s}(${u})`;if(!i.startsWith("geid_"))a+=`[${i}]: `;else if(this.multi){if(typeof n[c]>"u")n[c]=0;else n[c]++;a+=`${n[c]}. `}a+=c,t[a]=o.attributes});let r={};for(let o in this)if(this.hasOwnProperty(o)&&!co.has(o)&&typeof this[o]!=="function"&&typeof o!=="symbol")r[o]=this[o];return r.attributes=this._attributes,r.nodes=e,r.edges=t,le(r,"constructor",this.constructor),r}}if(typeof Symbol<"u")R.prototype[Symbol.for("nodejs.util.inspect.custom")]=R.prototype.inspect;gd.forEach((e)=>{["add","merge","update"].forEach((t)=>{let n=e.name(t),r=t==="add"?wo:wd;if(e.generateKey)R.prototype[n]=function(o,i,s){return r(this,n,!0,(e.type||this.type)==="undirected",null,o,i,s,t==="update")};else R.prototype[n]=function(o,i,s,a){return r(this,n,!1,(e.type||this.type)==="undirected",o,i,s,a,t==="update")}})});_a(R);Ua(R);nd(R);cd(R);class Gn extends R{constructor(e){let t=H({type:"directed"},e);if("multi"in t&&t.multi!==!1)throw new S("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="directed")throw new S('DirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Yn extends R{constructor(e){let t=H({type:"undirected"},e);if("multi"in t&&t.multi!==!1)throw new S("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(t.type!=="undirected")throw new S('UndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Qn extends R{constructor(e){let t=H({multi:!0},e);if("multi"in t&&t.multi!==!0)throw new S("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(t)}}class Jn extends R{constructor(e){let t=H({type:"directed",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new S("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="directed")throw new S('MultiDirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}class Zn extends R{constructor(e){let t=H({type:"undirected",multi:!0},e);if("multi"in t&&t.multi!==!0)throw new S("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(t.type!=="undirected")throw new S('MultiUndirectedGraph.from: inconsistent "'+t.type+'" type in given options!');super(t)}}function Qe(e){e.from=function(t,n){let r=H({},t.options,n),o=new e(r);return o.import(t),o}}Qe(R);Qe(Gn);Qe(Yn);Qe(Qn);Qe(Jn);Qe(Zn);R.Graph=R;R.DirectedGraph=Gn;R.UndirectedGraph=Yn;R.MultiGraph=Qn;R.MultiDirectedGraph=Jn;R.MultiUndirectedGraph=Zn;R.InvalidArgumentsGraphError=S;R.NotFoundGraphError=g;R.UsageGraphError=F;class Fd extends bd.TaggedError("ProcessActivationConflict"){}var sm=new Set([...Intl.supportedValuesOf("timeZone"),"UTC"]);import{Schema as Jd}from"effect";import{Schema as L}from"effect";import{Schema as q}from"effect";import{Schema as M}from"effect";var Pe=M.Int.pipe(M.check(M.isBetween({minimum:0,maximum:6})),M.brand("DayOfWeek"));var To=M.Struct({hour:M.Int.pipe(M.check(M.isBetween({minimum:0,maximum:23}))),minute:M.Int.pipe(M.check(M.isBetween({minimum:0,maximum:59})))}),Zt=M.Struct({open:To,close:To}),Je=M.Struct({day:Pe,ranges:M.Array(Zt)}),um=M.Array(Je),pt=M.Int.pipe(M.check(M.isBetween({minimum:1,maximum:12})),M.brand("Month")),mt=M.Int.pipe(M.check(M.isBetween({minimum:1,maximum:31})),M.brand("DayOfMonth")),Xn=M.Int.pipe(M.check(M.isBetween({minimum:1,maximum:5})),M.brand("NthOccurrence")),N=(e)=>e.hour*60+e.minute,be=(e)=>N(e.close)<N(e.open);var bo=q.Struct({id:q.String,type:q.String,name:q.String,startDate:q.DateTimeUtc,endDate:q.DateTimeUtc,isActive:q.Boolean,weeklySchedule:q.optional(q.Array(Je))}),pm=q.Struct({id:q.String,type:q.String,name:q.String,startDate:q.DateTimeUtcFromString,endDate:q.DateTimeUtcFromString,isActive:q.Boolean,weeklySchedule:q.optional(q.Array(Je))});import{Schema as K}from"effect";var Ed=K.TaggedStruct("FixedHoliday",{name:K.String,month:pt,day:mt}),kd=K.TaggedStruct("NthWeekdayHoliday",{name:K.String,month:pt,weekday:Pe,nth:Xn}),Od=K.TaggedStruct("LastWeekdayHoliday",{name:K.String,month:pt,weekday:Pe}),Ad=K.TaggedStruct("EasterRelativeHoliday",{name:K.String,daysOffset:K.Int}),er=K.Union([Ed,kd,Od,Ad]),gm=K.Struct({date:K.DateTimeUtc,name:K.String,rule:K.optional(er)}),tr=K.decodeSync(pt),Pd=K.decodeSync(mt),Fo=K.decodeSync(Pe),_d=K.decodeSync(Xn),Z=(e,t,n)=>({_tag:"FixedHoliday",name:e,month:tr(t),day:Pd(n)}),Ne=(e,t,n,r)=>({_tag:"NthWeekdayHoliday",name:e,month:tr(t),weekday:Fo(n),nth:_d(r)}),Id=(e,t,n)=>({_tag:"LastWeekdayHoliday",name:e,month:tr(t),weekday:Fo(n)}),_e=(e,t)=>({_tag:"EasterRelativeHoliday",name:e,daysOffset:t});var Sm=[Z("New Year's Day",1,1),Ne("Martin Luther King Jr. Day",1,1,3),Ne("Presidents' Day",2,1,3),Id("Memorial Day",5,1),Z("Independence Day",7,4),Ne("Labor Day",9,1,1),Ne("Columbus Day",10,1,2),Z("Veterans Day",11,11),Ne("Thanksgiving",11,4,4),Z("Christmas Day",12,25)],xm=[Z("Nieuwjaarsdag",1,1),Z("Koningsdag",4,27),Z("Bevrijdingsdag",5,5),Z("Eerste Kerstdag",12,25),Z("Tweede Kerstdag",12,26),_e("Goede Vrijdag",-2),_e("Eerste Paasdag",0),_e("Tweede Paasdag",1),_e("Hemelvaartsdag",39),_e("Eerste Pinksterdag",49),_e("Tweede Pinksterdag",50)],wm=[Z("New Year's Day",1,1),Z("Day after New Year's Day",1,2),Z("Waitangi Day",2,6),_e("Good Friday",-2),_e("Easter Monday",1),Z("Anzac Day",4,25),Ne("Queen's Birthday",6,1,1),Ne("Labour Day",10,1,4),Z("Christmas Day",12,25),Z("Boxing Day",12,26)];var Dd=L.Struct({date:L.DateTimeUtc,slots:L.Union([L.Array(Zt),L.Literal("closed")]),note:L.optional(L.String)}),vm=L.Struct({date:L.DateTimeUtcFromString,slots:L.Union([L.Array(Zt),L.Literal("closed")]),note:L.optional(L.String)}),Cm=L.Struct({weeklySchedule:L.Array(Je),holidays:L.Array(er),exceptions:L.Array(Dd),nonWorkingDays:L.Array(Pe),periods:L.Array(bo),requireActivePeriod:L.optional(L.String),startDayOfWeek:L.optional(Pe),timezone:L.optional(L.String)});import{Context as Eo,Data as Rd}from"effect";class Xt extends Rd.TaggedError("BusinessCalendarError"){}class nr extends Eo.Service()("processfocus:internal-tag/business-calendar/BusinessCalendarService"){}class rr extends Eo.Service()("processfocus:internal-tag/business-calendar/BusinessCalendarConfigService"){}import{Cause as Po,DateTime as O,Deferred as rn,Duration as ht,Effect as A,Exit as Vd,Layer as Gd,Option as pe,SynchronizedRef as on}from"effect";import{DateTime as ae,Effect as X}from"effect";import{Data as Ze}from"effect";class vd extends Ze.TaggedError("DateOutOfRangeError"){}class Cd extends Ze.TaggedError("NoBusinessHoursError"){}class Md extends Ze.TaggedError("InvalidCalendarConfigError"){}class en extends Ze.TaggedError("InvalidDateError"){}class yt extends Ze.TaggedError("InvalidYearError"){}class $d extends Ze.TaggedError("ValidationError"){}var ko=1583,Oo=9999,tn=(e)=>{if(!Number.isInteger(e))return X.fail(new yt({year:e,message:`Year must be an integer, got ${e}`}));if(e<ko)return X.fail(new yt({year:e,message:`Year must be >= ${ko} for Gregorian calendar, got ${e}`}));if(e>Oo)return X.fail(new yt({year:e,message:`Year must be <= ${Oo}, got ${e}`}));return X.succeed(e)},Nd=(e,t)=>new Date(e,t,0).getDate(),Ld=(e,t,n)=>{let r=Nd(e,t);if(n>r)return X.fail(new en({year:e,month:t,day:n,message:`Invalid date: ${e}-${t}-${n}. Month ${t} has only ${r} days in year ${e}`}));return X.void},nn=(e,t,n)=>X.try({try:()=>ae.makeUnsafe({year:e,month:t,day:n,hour:0,minute:0,second:0,millisecond:0}),catch:(r)=>new en({year:e,month:t,day:n,message:`Failed to create date: ${r}`})}),Bd=(e)=>X.gen(function*(){yield*tn(e);let t=e%19,n=Math.floor(e/100),r=e%100,o=Math.floor(n/4),i=n%4,s=Math.floor((n+8)/25),a=Math.floor((n-s+1)/3),d=(19*t+n-o-a+15)%30,u=Math.floor(r/4),l=r%4,c=(32+2*i+2*u-d-l)%7,h=Math.floor((t+11*d+22*c)/451),w=Math.floor((d+c-7*h+114)/31),T=(d+c-7*h+114)%31+1;return yield*nn(e,w,T)}),Ud=(e,t,n,r)=>X.gen(function*(){yield*tn(e);let o=yield*nn(e,t,1),s=ae.toParts(o).weekDay,a=n-s;if(a<0)a+=7;if(o=ae.add(o,{days:a}),o=ae.add(o,{days:(r-1)*7}),ae.toParts(o).month!==t)return;return o}),jd=(e,t,n)=>X.gen(function*(){yield*tn(e);let r=t===12?1:t+1,o=t===12?e+1:e,i=yield*nn(o,r,1);i=ae.add(i,{days:-1});let d=ae.toParts(i).weekDay-n;if(d<0)d+=7;return ae.add(i,{days:-d})}),Wd=(e,t)=>X.gen(function*(){return yield*tn(t),yield*Ld(t,e.month,e.day),{date:yield*nn(t,e.month,e.day),name:e.name,rule:e}}),Hd=(e,t)=>X.gen(function*(){let n=yield*Ud(t,e.month,e.weekday,e.nth);if(!n)return;return{date:n,name:e.name,rule:e}}),qd=(e,t)=>X.gen(function*(){return{date:yield*jd(t,e.month,e.weekday),name:e.name,rule:e}}),Kd=(e,t)=>X.gen(function*(){let n=yield*Bd(t);return{date:ae.add(n,{days:e.daysOffset}),name:e.name,rule:e}}),zd=(e,t)=>{switch(e._tag){case"FixedHoliday":return Wd(e,t);case"NthWeekdayHoliday":return Hd(e,t);case"LastWeekdayHoliday":return qd(e,t);case"EasterRelativeHoliday":return Kd(e,t)}},Ao=(e,t)=>X.gen(function*(){let n=[];for(let r of e){let o=yield*zd(r,t);if(o)n.push(o)}return n.sort((r,o)=>{let i=ae.toEpochMillis(r.date),s=ae.toEpochMillis(o.date);return i-s})}),or=(e,t)=>{let n=ae.toParts(e);for(let r of t){let o=ae.toParts(r.date);if(n.year===o.year&&n.month===o.month&&n.day===o.day)return r}return};var ir=1e4,Yd=1e5,gt=365,Qd=(e)=>A.gen(function*(){let t=e.timezone?O.zoneMakeNamedUnsafe(e.timezone):O.zoneMakeNamedUnsafe("UTC"),n=(f)=>{let m=O.setZone(f,t);return O.toParts(m)},r=(f,m,p,y,x)=>{let E=O.makeZonedUnsafe({year:f,month:m,day:p,hour:y,minute:x,second:0,millisecond:0},{timeZone:t,adjustForTimeZone:!0});return O.toUtc(E)},o=yield*on.make(new Map),i=(f)=>Ao(e.holidays,f).pipe(A.catchCause((m)=>{if(Po.hasInterrupts(m)||Po.hasDies(m))return A.failCause(m);return A.logWarning("Failed to compute holidays for year",m).pipe(A.annotateLogs({year:f}),A.as([]))})),s=(f)=>A.uninterruptibleMask((m)=>A.gen(function*(){let p=yield*on.modifyEffect(o,(y)=>{let x=y.get(f);if(x!==void 0){if(x._tag==="Done")return A.succeed([{_tag:"hit",holidays:x.holidays},y]);return A.succeed([{_tag:"join",deferred:x.deferred},y])}return rn.make().pipe(A.map((E)=>{let k=new Map(y);return k.set(f,{_tag:"InFlight",deferred:E}),[{_tag:"owner",deferred:E},k]}))});switch(p._tag){case"hit":return p.holidays;case"join":return yield*m(rn.await(p.deferred).pipe(A.catch(()=>s(f))));case"owner":{let y=yield*A.exit(m(A.gen(function*(){return yield*A.yieldNow,yield*i(f)})));if(Vd.isSuccess(y))return yield*rn.succeed(p.deferred,y.value),yield*on.update(o,(x)=>{let E=x.get(f);if(E?._tag==="InFlight"&&E.deferred===p.deferred){let k=new Map(x);return k.set(f,{_tag:"Done",holidays:y.value}),k}return x}),y.value;return yield*on.update(o,(x)=>{let E=x.get(f);if(E?._tag==="InFlight"&&E.deferred===p.deferred){let k=new Map(x);return k.delete(f),k}return x}),yield*rn.fail(p.deferred,"abandoned"),yield*A.failCause(y.cause)}}})),a=(f)=>{let m=n(f);for(let p of e.exceptions){let y=n(p.date);if(m.year===y.year&&m.month===y.month&&m.day===y.day)return p}return},d=(f)=>{let m=O.toEpochMillis(f);return[...e.periods].filter((p)=>{let y=O.toEpochMillis(p.startDate),x=O.toEpochMillis(p.endDate);return p.isActive&&m>=y&&m<=x})},u=(f)=>{if(!e.requireActivePeriod)return!0;let m=O.toEpochMillis(f);for(let p of e.periods){if(p.type!==e.requireActivePeriod||!p.isActive)continue;let y=O.toEpochMillis(p.startDate),x=O.toEpochMillis(p.endDate);if(m>=y&&m<=x)return!0}return!1},l=(f)=>{let m=d(f);for(let p of m)if(p.weeklySchedule)return p.weeklySchedule;return e.weeklySchedule},c=(f,m)=>f.find((p)=>p.day===m),h=(f,m)=>{let p=N(f),y=N(m.open),x=N(m.close);if(be(m))return p>=y||p<x;return p>=y&&p<x},w=(f,m)=>{let p=N(f),y=N(m.close);if(be(m)){if(p>=N(m.open))return 1440-p+y;return y-p}return y-p},T=1440,B=(f,m,p,y)=>Math.max(0,Math.min(m,y)-Math.max(f,p)),D=(f,m,p)=>{if(p<=m)return 0;let y=N(f.open),x=N(f.close);if(be(f))return B(y,1440,m,p)+B(0,x,m,p);return B(y,x,m,p)},j=(f)=>{let m=a(f);if(m){if(m.slots==="closed")return[];return m.slots}let p=n(f),y=l(f);return c(y,p.weekDay)?.ranges??[]},b=(f,m)=>{let p=n(f),y=n(m);return p.year===y.year&&p.month===y.month&&p.day===y.day},P={isBusinessDay:(f)=>A.gen(function*(){let m=n(f),p=a(f);if(p?.slots==="closed")return!1;if(e.nonWorkingDays.includes(m.weekDay))return!1;let y=yield*s(m.year),x=O.makeUnsafe({year:m.year,month:m.month,day:m.day});if(or(x,y))return!1;if(!u(f))return!1;let E=l(f),k=c(E,m.weekDay);if(p&&typeof p.slots!=="string")return!0;if(!k||k.ranges.length===0)return!1;return!0}),isBusinessHours:(f)=>A.gen(function*(){if(!(yield*P.isBusinessDay(f)))return!1;let p=n(f),y={hour:p.hour,minute:p.minute},x=a(f);if(x&&typeof x.slots!=="string"){for(let C of x.slots)if(h(y,C))return!0;return!1}let E=l(f),k=c(E,p.weekDay);if(!k)return!1;for(let C of k.ranges)if(h(y,C))return!0;return!1}),addBusinessDays:(f,m)=>A.gen(function*(){if(m===0||!Number.isFinite(m))return f;let p=Math.max(-ir,Math.min(ir,Math.round(m))),y=f,x=Math.abs(p),E=p>0?1:-1,k=0;while(x>0&&k<ir*2)if(k++,y=O.add(y,{days:E}),yield*P.isBusinessDay(y))x--;return y}),addBusinessHours:(f,m)=>A.gen(function*(){if(m<=0||!Number.isFinite(m))return f;let p=Math.min(Yd,m),y=f,x=Math.round(p*60),E=0,k=x+gt*24*60;while(x>0&&E<k){if(E++,!(yield*P.isBusinessHours(y))){let Q=yield*P.nextBusinessDay(y),de=yield*P.businessDayStart(Q);if(pe.isNone(de)){y=O.add(Q,{days:1});continue}y=de.value;continue}let _=n(y),G={hour:_.hour,minute:_.minute},U=a(y),te;if(U&&typeof U.slots!=="string")te=U.slots;else{let Q=l(y);te=c(Q,_.weekDay)?.ranges??[]}let se=0;for(let Q of te)if(h(G,Q)){se=w(G,Q);break}if(se>=x)return O.add(y,{minutes:x});x-=se,y=O.add(y,{minutes:se});let Ft=n(y),pn={hour:Ft.hour,minute:Ft.minute},mn=!1;for(let Q of te){let de=N(Q.open),Et=N(pn);if(de>Et&&!be(Q)){let Zo=de-Et;y=O.add(y,{minutes:Zo}),mn=!0;break}}if(!mn){let Q=yield*P.nextBusinessDay(y),de=yield*P.businessDayStart(Q);if(pe.isNone(de)){y=O.add(Q,{days:1});continue}y=de.value}}return y}),nextBusinessDay:(f)=>A.gen(function*(){let m=O.add(f,{days:1}),p=n(m);m=r(p.year,p.month,p.day,0,0);let y=0;while(y<gt){if(y++,yield*P.isBusinessDay(m))return m;m=O.add(m,{days:1})}return yield*new Xt({message:`No business day found within ${gt} days of ${O.toUtc(f)}, possible misconfigured calendar`})}),previousBusinessDay:(f)=>A.gen(function*(){let m=n(f),p=r(m.year,m.month,m.day,0,0);p=O.add(p,{days:-1});let y=0;while(y<gt){if(y++,yield*P.isBusinessDay(p))return p;p=O.add(p,{days:-1})}return yield*new Xt({message:`No business day found within ${gt} days of ${O.toUtc(f)}, possible misconfigured calendar`})}),businessDayStart:(f)=>A.gen(function*(){if(!(yield*P.isBusinessDay(f)))return pe.none();let p=n(f),y=a(f);if(y&&typeof y.slots!=="string"){let _=y.slots,G=_[0];if(!G)return pe.none();let U=G.open;for(let te of _)if(N(te.open)<N(U))U=te.open;return pe.some(r(p.year,p.month,p.day,U.hour,U.minute))}let x=l(f),E=c(x,p.weekDay),k=E?.ranges[0];if(!E||!k)return pe.none();let C=k.open;for(let _ of E.ranges)if(N(_.open)<N(C))C=_.open;return pe.some(r(p.year,p.month,p.day,C.hour,C.minute))}),businessDayEnd:(f)=>A.gen(function*(){if(!(yield*P.isBusinessDay(f)))return pe.none();let p=n(f),y=a(f);if(y&&typeof y.slots!=="string"){let _=y.slots,G=_[0];if(!G)return pe.none();let U=G.close;for(let te of _)if(be(te))U=te.close;else if(N(te.close)>N(U)&&!be({open:G.open,close:U}))U=te.close;return pe.some(r(p.year,p.month,p.day,U.hour,U.minute))}let x=l(f),E=c(x,p.weekDay),k=E?.ranges[0];if(!E||!k)return pe.none();let C=k.close;for(let _ of E.ranges)if(be(_))C=_.close;else if(N(_.close)>N(C)&&!be({open:k.open,close:C}))C=_.close;return pe.some(r(p.year,p.month,p.day,C.hour,C.minute))}),businessHoursRemaining:(f)=>A.gen(function*(){if(!(yield*P.isBusinessHours(f)))return ht.zero;let p=n(f),y={hour:p.hour,minute:p.minute},x=a(f),E;if(x&&typeof x.slots!=="string")E=x.slots;else{let _=l(f);E=c(_,p.weekDay)?.ranges??[]}let k=0,C=!1;for(let _ of E)if(h(y,_))k+=w(y,_),C=!0;else if(C&&N(_.open)>N(y))k+=N(_.close)-N(_.open);return ht.minutes(k)}),businessDaysBetween:(f,m)=>A.gen(function*(){let p=O.toEpochMillis(f),y=O.toEpochMillis(m);if(p>=y)return 0;let x=0,E=f;while(O.toEpochMillis(E)<y){if(yield*P.isBusinessDay(E))x++;E=O.add(E,{days:1})}return x}),businessHoursBetween:(f,m)=>A.gen(function*(){let p=O.toEpochMillis(f),y=O.toEpochMillis(m);if(p>=y)return ht.zero;let x=(se,Ft,pn)=>A.gen(function*(){if(!(yield*P.isBusinessDay(se)))return 0;let Q=j(se),de=0;for(let Et of Q)de+=D(Et,Ft,pn);return de}),E=n(f),k=n(m),C=E.hour*60+E.minute,_=k.hour*60+k.minute;if(b(f,m)){let se=yield*x(f,C,_);return ht.minutes(se)}let G=0;G+=yield*x(f,C,1440);let U=r(E.year,E.month,E.day,12,0);U=O.add(U,{days:1});let te=r(k.year,k.month,k.day,12,0);while(O.toEpochMillis(U)<O.toEpochMillis(te)){G+=yield*x(U,0,1440);let se=n(U);U=O.add(r(se.year,se.month,se.day,12,0),{days:1})}return G+=yield*x(m,0,_),ht.minutes(G)}),isHoliday:(f)=>A.gen(function*(){let m=n(f),p=yield*s(m.year),y=O.makeUnsafe({year:m.year,month:m.month,day:m.day});return or(y,p)!==void 0}),getHolidaysForYear:(f)=>s(f),getActivePeriods:(f)=>A.succeed(d(f)),getActivePeriodsByType:(f,m)=>A.succeed(d(f).filter((p)=>p.type===m)),isWithinPeriodType:(f,m)=>A.succeed(d(f).some((p)=>p.type===m)),getPeriodsForDateRange:(f,m,p)=>A.succeed([...e.periods].filter((y)=>{if(p&&y.type!==p)return!1;let x=O.toEpochMillis(y.startDate),E=O.toEpochMillis(y.endDate),k=O.toEpochMillis(f),C=O.toEpochMillis(m);return x<=C&&E>=k})),getEffectiveSchedule:(f)=>A.sync(()=>{let m=a(f);if(m){if(m.slots==="closed")return[];return[{day:n(f).weekDay,ranges:[...m.slots]}]}return[...l(f)]})};return P}),Vm=Gd.effect(nr,A.flatMap(rr,Qd));import{DateTime as Qm}from"effect";import{DateTime as Xm,Duration as ey,Effect as ty}from"effect";var xy=Jd.decodeSync(mt);import{Data as sn,Effect as by,Schema as Fy}from"effect";class Zd extends sn.TaggedError("EmbeddedFormNotStartStepError"){}class Xd extends sn.TaggedError("UnsupportedEmbeddedFormFieldError"){}class eu extends sn.TaggedError("EmbeddedFormMetadataBuildError"){}class tu extends sn.TaggedError("EmbeddedProcessHasMultipleStartStepsError"){}import{Data as su,Effect as Xy}from"effect";import*as au from"effect/SchemaAST";var ou=J(oe(),1);class du extends su.TaggedError("OrganisationFrontendManifestBuildError"){}import*as Ie from"path";import{RUNTIME_ARTIFACT_FORMAT as uu,RUNTIME_ARTIFACT_VERSION as cu,Runtime as _o,parseServerPluginRegistrations as lu}from"@processfocus/runtime";import{Config as fu,Context as pu,Data as mu,Effect as ie,FileSystem as Io,Layer as Do,Result as ph}from"effect";class Xe extends mu.TaggedError("processfocus:internal-tag/OrganisationLoadError"){}class St extends pu.Service()("processfocus:internal-tag/process/OrganisationProvider"){}var yu=(e)=>ie.gen(function*(){let t=yield*Io.FileSystem,n=Ie.resolve(process.cwd(),e),r=Ie.join(n,"org.js"),o=Ie.join(n,"src/index.ts"),s=(yield*t.exists(r))?r:o;if(!(yield*t.exists(s)))return yield*new Xe({message:`Failed to load organisation from ${e}: Organisation file not found: ${s}`,orgPath:e});let d=yield*ie.tryPromise({try:async()=>await import(s),catch:(T)=>new Xe({message:`Failed to load organisation from ${e}: ${T instanceof Error?T.message:String(T)}`,orgPath:e,cause:T})}),u=yield*_o.loadArtifact(ie.succeed({format:uu,version:cu,organisation:d.org,configuration:d.Configuration})).pipe(ie.mapError((T)=>new Xe({message:`Failed to load organisation from ${e}: ${T.message}`,orgPath:e}))),{CustomDbLayer:l,CustomGraphqlSchema:c,CustomJobLayer:h}=d,w=yield*lu(d.ServerPlugins).pipe(ie.mapError((T)=>new Xe({message:`Failed to load organisation from ${e}: ${T.message}`,orgPath:e,cause:T})));return{org:u.organisation,resolvedPath:n,...l?{customDbLayer:l}:{},...c?{customGraphqlSchema:c}:{},...h?{customJobLayer:h}:{},serverPlugins:w}}),hu=(e)=>_o.loadOrganisation({load:yu},e),gu=({org:e,orgPath:t,customDbLayer:n,customGraphqlSchema:r,customJobLayer:o,serverPlugins:i=[]})=>ie.gen(function*(){let s=yield*Io.FileSystem,a=Ie.join(t,"dist/graphql/org.graphql"),d=Ie.join(t,"graphql/org.graphql"),l=(yield*s.exists(a))?a:d;return{organisation:e,orgPath:t,schemaPath:l,...n?{customDbLayer:n}:{},...r?{customGraphqlSchema:r}:{},...o?{customJobLayer:o}:{},serverPlugins:i}}),Su=({org:e,orgPath:t,schemaPath:n,customGraphqlSchema:r,customJobLayer:o,serverPlugins:i=[]})=>{let s=n??Ie.join(t,"dist/graphql/org.graphql");return{organisation:e,orgPath:t,schemaPath:s,...r?{customGraphqlSchema:r}:{},...o?{customJobLayer:o}:{},serverPlugins:i}},xu=({name:e,customDbLayer:t,customJobLayer:n,serverPlugins:r=[]})=>ie.gen(function*(){if(yield*ie.log(`Loaded organisation: ${e}`),t)yield*ie.log("Loaded custom database layer from organisation");if(n)yield*ie.log("Loaded custom job layer from organisation");if(r.length>0)yield*ie.log(`Loaded ${r.length} server plugin registration(s) from organisation`)}),yh=Do.effect(St,ie.gen(function*(){let e=yield*fu.String("PF_ORG").pipe(ie.mapError(()=>new Xe({message:"PF_ORG environment variable is not set",orgPath:"<env>"})));yield*ie.log(`Loading organisation from: ${e}`);let{org:t,resolvedPath:n,customDbLayer:r,customGraphqlSchema:o,customJobLayer:i,serverPlugins:s}=yield*hu(e);return yield*xu({name:t.name,customDbLayer:r,customJobLayer:i,serverPlugins:s}),yield*gu({org:t,orgPath:n,customDbLayer:r,customGraphqlSchema:o,customJobLayer:i,serverPlugins:s})}));var Ro=(e,t,n,r,o,i=[])=>Do.succeed(St,Su({org:e,orgPath:t??process.cwd(),schemaPath:n,customGraphqlSchema:r,customJobLayer:o,serverPlugins:i}));var wu=J(oe(),1);var Tu=J(oe(),1);import{Duration as wh}from"effect";import{Context as bu,Data as an,DateTime as Eh,Effect as kh,Schema as Oh,SchemaAST as Ah}from"effect";class Fu extends an.TaggedError("SourceStepNotFoundForScheduleError"){}class Eu extends an.TaggedError("EdgeNotFoundForScheduleError"){}class ku extends an.TaggedError("ScheduleFunctionMissingError"){}class Ou extends an.TaggedError("ScheduleEvaluationError"){}class Au extends bu.Service()("processfocus:internal-tag/process/ScheduleEvaluator"){}var Pu=J(oe(),1);import{Context as sr,Data as xt,Effect as Mh,Option as $h,Schema as Nh}from"effect";class _u extends xt.TaggedError("StepNotFoundError"){}class Iu extends xt.TaggedError("NotASystemStepError"){}class Du extends xt.TaggedError("SystemStepExecutionError"){}class Ru extends xt.TaggedError("OutputValidationError"){}class vu extends xt.TaggedError("LongDurationDispatchError"){}class Cu extends sr.Service()("processfocus:internal-tag/process/LongDurationDispatcher"){}class Mu extends sr.Service()("processfocus:internal-tag/process/StepProcessStateReader"){}class $u extends sr.Service()("processfocus:internal-tag/process/SystemStepExecutor"){}import{Data as un,Effect as ee,Match as ge,Option as dn}from"effect";var wt=(e)=>e._tag!=="Null",et=(e)=>{switch(typeof e){case"string":return"String";case"number":return"Float";case"boolean":return"Boolean";default:return}},Tt=(e)=>{let t=e.map((r)=>r._tag==="Literal"?et(r.literal):void 0),n=t[0];return n!==void 0&&t.every((r)=>r===n)?n:void 0},he=(e)=>e._tag==="Union"?e.types.flatMap(he):[e];class Fe extends un.TaggedError("UnsupportedOutputSchemaTypeError"){get message(){return`Cannot generate GraphQL output type for field "${this.fieldName}": schema type "${this.schemaType}" is not supported`}}class Co extends un.TaggedError("OutputIndexSignaturesNotSupportedError"){get message(){return"Index signatures are not supported in GraphQL output types"}}class Mo extends un.TaggedError("UnrecognizedOutputASTNodeError"){get message(){return`AST node type "${this.nodeTag}" is not recognized`}}class $o extends un.TaggedError("OutputInvalidPropertyKeyError"){get message(){return`Property keys must be strings, got: ${String(this.propertyKey)}`}}var No=(e)=>{if(typeof e==="symbol"||typeof e==="number")return ee.fail(new $o({propertyKey:e}));return ee.succeed(e)},Lo=(e,t)=>{let n=t.charAt(0).toUpperCase()+t.slice(1);return`${e}${n}`},Nu=(e)=>{let t=dr(e,In),n=dn.getOrUndefined(t);return Dn(n)?n:void 0},Lu=(e,t,n)=>{let r=Lo(t,e),o=`${r}Field`,i=`${r}Bucket`;return{fieldDefinition:`${e}: ${r}${n?"":"!"}`,auxiliary:[`type ${o} {
6
6
  label: String!
7
7
  value: String!
8
8
  }`,`type ${i} {
@@ -16,40 +16,42 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
16
16
  badge: String
17
17
  fields: [${o}!]!
18
18
  buckets: [${i}!]!
19
- }`]}},$o=(e)=>{switch(e){case"StringKeyword":return"String";case"NumberKeyword":return"Float";case"BooleanKeyword":return"Boolean";default:return}},dn=(e,t)=>pe.type().pipe(pe.tag("TypeLiteral",(n)=>X.gen(function*(){let r=[],o=[];for(let s of n.propertySignatures){yield*jo(s.name);let a=yield*dc(s,t);if(a)r.push(a.fieldDefinition),o.push(...a.auxiliary)}if(n.indexSignatures.length>0)return yield*new Lo;return{main:`type ${t} {
19
+ }`]}},vo=(e)=>{switch(e){case"String":return"String";case"Number":return"Float";case"Boolean":return"Boolean";default:return}},cn=(e,t)=>ge.type().pipe(ge.tag("Objects",(n)=>ee.gen(function*(){let r=[],o=[];for(let s of n.propertySignatures){yield*No(s.name);let a=yield*Bo(s,t);for(let d of a)r.push(d.fieldDefinition),o.push(...d.auxiliary)}if(n.indexSignatures.length>0)return yield*new Co;return{main:`type ${t} {
20
20
  ${r.map((s)=>` ${s}`).join(`
21
21
  `)}
22
- }`,auxiliary:o}})),pe.orElse((n)=>X.fail(new Bo({nodeTag:n._tag}))))(e),dc=(e,t)=>X.gen(function*(){let n=yield*jo(e.name),r=e.isOptional;if(sc(e.type)?.dataSource==="item")return ac(n,t,r);if(No.isSome(pr.getAnnotation(e.type,Te)))return null;return yield*Tt(e.type,n,t,r)}),Tt=(e,t,n,r)=>pe.type().pipe(pe.when((o)=>$o(o._tag)!==void 0,(o)=>{let i=$o(o._tag);if(!i)return X.fail(new we({fieldName:t,schemaType:o._tag}));let s=r?"":"!";return X.succeed({fieldDefinition:`${t}: ${i}${s}`,auxiliary:[]})}),pe.tag("Literal",(o)=>{let i=Je(o.literal);if(!i)return X.fail(new we({fieldName:t,schemaType:e._tag}));let s=r?"":"!";return X.succeed({fieldDefinition:`${t}: ${i}${s}`,auxiliary:[]})}),pe.tag("TypeLiteral",(o)=>X.gen(function*(){let i=Wo(n,t),s=yield*dn(o,i);return{fieldDefinition:`${t}: ${i}${r?"":"!"}`,auxiliary:[s.main,...s.auxiliary]}})),pe.tag("Refinement",(o)=>Tt(o.from,t,n,r)),pe.tag("Transformation",(o)=>Tt(o.to,t,n,r)),pe.tag("Union",(o)=>{let i=o.types.filter((d)=>d._tag!=="UndefinedKeyword"&&d._tag!=="VoidKeyword"&&ht(d)),s=St(i);if(s){let d=r||i.length!==o.types.length;return X.succeed({fieldDefinition:`${t}: ${s}${d?"":"!"}`,auxiliary:[]})}if(i.length>1)return X.fail(new we({fieldName:t,schemaType:e._tag}));let a=i[0];if(!a)return X.fail(new we({fieldName:t,schemaType:"Union (all undefined)"}));return Tt(a,t,n,r||i.length!==o.types.length)}),pe.tag("TupleType",(o)=>X.gen(function*(){if(o.rest.length===0)return yield*new we({fieldName:t,schemaType:"TupleType (no rest elements)"});let i=o.rest[0];if(!i)return yield*new we({fieldName:t,schemaType:"TupleType (no element type)"});let s=yield*Tt(i.type,`${t}Item`,n,!1),a=s.fieldDefinition.match(/:\s*(.+?)!?\s*$/);if(!a)return yield*new we({fieldName:t,schemaType:"TupleType (could not extract element type)"});let d=a[1]?.replace("!","")??"Unknown";return{fieldDefinition:`${t}: [${d}!]${r?"":"!"}`,auxiliary:s.auxiliary}})),pe.orElse(()=>X.fail(new we({fieldName:t,schemaType:e._tag}))))(e);import{Data as cn,Effect as K,Match as fe}from"effect";class De extends cn.TaggedError("UnsupportedSchemaTypeError"){get message(){return`Cannot generate GraphQL input type for field "${this.fieldName}": schema type "${this.schemaType}" is not supported`}}class qo extends cn.TaggedError("IndexSignaturesNotSupportedError"){get message(){return"Index signatures are not supported in GraphQL input types"}}class Ko extends cn.TaggedError("UnrecognizedASTNodeError"){get message(){return`AST node type "${this.nodeTag}" is not recognized`}}class Vo extends cn.TaggedError("InvalidPropertyKeyError"){get message(){return`Property keys must be strings, got: ${String(this.propertyKey)}`}}var zo=(e)=>{if(typeof e==="symbol"||typeof e==="number")return K.fail(new Vo({propertyKey:e}));return K.succeed(e)},Ho=(e,t)=>{let n=t.charAt(0).toUpperCase()+t.slice(1);return`${e}${n}Input`},fr=(e)=>{switch(e){case"StringKeyword":return"String";case"NumberKeyword":return"Float";case"BooleanKeyword":return"Boolean";default:return}},uc=(e)=>{if(e._tag==="Literal")return Je(e.literal);if(e._tag==="Union")return St(e.types.filter((t)=>t._tag!=="UndefinedKeyword"&&t._tag!=="VoidKeyword"&&ht(t)));return fr(e._tag)},Ze=(e,t)=>fe.type().pipe(fe.tag("TypeLiteral",(n)=>K.gen(function*(){let r=[],o=[];for(let s of n.propertySignatures){if(s.type._tag==="UndefinedKeyword"||s.type._tag==="VoidKeyword")continue;yield*zo(s.name);let a=yield*cc(s,t);r.push(a.fieldDefinition),o.push(...a.auxiliary)}if(n.indexSignatures.length>0)return yield*new qo;return{main:`input ${t} {
22
+ }`,auxiliary:o}})),ge.orElse((n)=>ee.fail(new Mo({nodeTag:n._tag}))))(e),Bo=(e,t)=>ee.gen(function*(){let n=yield*No(e.name),r=e.type.context?.isOptional??!1;if(Nu(e.type)?.dataSource==="item")return[Lu(n,t,!1)];if(dn.isSome(dr(e.type,ke)))return[];if(e.type._tag==="Objects"&&dn.isSome(dr(e.type,st))){let i=[];for(let s of e.type.propertySignatures)i.push(...yield*Bo(s,t));return i}return[yield*ar(e.type,n,t,r)]}),ar=(e,t,n,r)=>ge.type().pipe(ge.when((o)=>vo(o._tag)!==void 0,(o)=>{let i=vo(o._tag);if(!i)return ee.fail(new Fe({fieldName:t,schemaType:o._tag}));let s=r?"":"!";return ee.succeed({fieldDefinition:`${t}: ${i}${s}`,auxiliary:[]})}),ge.tag("Literal",(o)=>{let i=et(o.literal);if(!i)return ee.fail(new Fe({fieldName:t,schemaType:e._tag}));let s=r?"":"!";return ee.succeed({fieldDefinition:`${t}: ${i}${s}`,auxiliary:[]})}),ge.tag("Objects",(o)=>ee.gen(function*(){let i=Lo(n,t),s=yield*cn(o,i);return{fieldDefinition:`${t}: ${i}${r?"":"!"}`,auxiliary:[s.main,...s.auxiliary]}})),ge.tag("Union",(o)=>{let i=he(o).filter((d)=>d._tag!=="Undefined"&&d._tag!=="Void"&&wt(d)),s=Tt(i);if(s){let d=r||i.length!==he(o).length;return ee.succeed({fieldDefinition:`${t}: ${s}${d?"":"!"}`,auxiliary:[]})}if(i.length>1)return ee.fail(new Fe({fieldName:t,schemaType:e._tag}));let a=i[0];if(!a)return ee.fail(new Fe({fieldName:t,schemaType:"Union (all undefined)"}));return ar(a,t,n,r||i.length!==he(o).length)}),ge.tag("Arrays",(o)=>ee.gen(function*(){if(o.rest.length===0)return yield*new Fe({fieldName:t,schemaType:"Arrays (no rest elements)"});let i=o.rest[0];if(!i)return yield*new Fe({fieldName:t,schemaType:"Arrays (no element type)"});let s=yield*ar(i,`${t}Item`,n,!1),a=s.fieldDefinition.match(/:\s*(.+?)!?\s*$/);if(!a)return yield*new Fe({fieldName:t,schemaType:"Arrays (could not extract element type)"});let d=a[1]?.replace("!","")??"Unknown";return{fieldDefinition:`${t}: [${d}!]${r?"":"!"}`,auxiliary:s.auxiliary}})),ge.orElse(()=>ee.fail(new Fe({fieldName:t,schemaType:e._tag}))))(e),dr=(e,t)=>dn.fromNullishOr(re(e,t));import{Data as ln,Effect as z,Match as Se}from"effect";import*as cr from"effect/SchemaAST";class De extends ln.TaggedError("UnsupportedSchemaTypeError"){get message(){return`Cannot generate GraphQL input type for field "${this.fieldName}": schema type "${this.schemaType}" is not supported`}}class jo extends ln.TaggedError("IndexSignaturesNotSupportedError"){get message(){return"Index signatures are not supported in GraphQL input types"}}class Wo extends ln.TaggedError("UnrecognizedASTNodeError"){get message(){return`AST node type "${this.nodeTag}" is not recognized`}}class Ho extends ln.TaggedError("InvalidPropertyKeyError"){get message(){return`Property keys must be strings, got: ${String(this.propertyKey)}`}}var qo=(e)=>{if(typeof e==="symbol"||typeof e==="number")return z.fail(new Ho({propertyKey:e}));return z.succeed(e)},Uo=(e,t)=>{let n=t.charAt(0).toUpperCase()+t.slice(1);return`${e}${n}Input`},ur=(e)=>{switch(e){case"String":return"String";case"Number":return"Float";case"Boolean":return"Boolean";default:return}},Bu=(e)=>{if(e._tag==="Literal")return et(e.literal);if(e._tag==="Union")return Tt(he(e).filter((t)=>t._tag!=="Undefined"&&t._tag!=="Void"&&wt(t)));return ur(e._tag)},tt=(e,t)=>Se.type().pipe(Se.tag("Objects",(n)=>z.gen(function*(){let r=[],o=[];for(let s of n.propertySignatures){if(s.type._tag==="Undefined"||s.type._tag==="Void")continue;yield*qo(s.name);let a=yield*Uu(s,t);r.push(a.fieldDefinition),o.push(...a.auxiliary)}if(n.indexSignatures.length>0)return yield*new jo;return{main:`input ${t} {
23
23
  ${r.map((s)=>` ${s}`).join(`
24
24
  `)}
25
- }`,auxiliary:o}})),fe.orElse((n)=>K.fail(new Ko({nodeTag:n._tag}))))(e),cc=(e,t)=>K.gen(function*(){let n=yield*zo(e.name),r=e.isOptional;return yield*un(e.type,n,t,r)}),un=(e,t,n,r)=>fe.type().pipe(fe.when((o)=>fr(o._tag)!==void 0,(o)=>{let i=fr(o._tag);if(!i)return K.fail(new De({fieldName:t,schemaType:o._tag}));let s=r?"":"!";return K.succeed({fieldDefinition:`${t}: ${i}${s}`,auxiliary:[]})}),fe.tag("Literal",(o)=>{let i=Je(o.literal);if(!i)return K.fail(new De({fieldName:t,schemaType:e._tag}));let s=r?"":"!";return K.succeed({fieldDefinition:`${t}: ${i}${s}`,auxiliary:[]})}),fe.tag("TypeLiteral",(o)=>K.gen(function*(){let i=Ho(n,t),s=yield*Ze(o,i);return{fieldDefinition:`${t}: ${i}${r?"":"!"}`,auxiliary:[s.main,...s.auxiliary]}})),fe.tag("TupleType",(o)=>{let i=o.rest[0];if(!i)return K.fail(new De({fieldName:t,schemaType:"TupleType (empty)"}));let s=i.type,a=r?"":"!";if(s._tag==="TypeLiteral"){let u=Ho(n,`${t}Item`);return Ze(s,u).pipe(K.map((l)=>({fieldDefinition:`${t}: [${u}!]${a}`,auxiliary:[l.main,...l.auxiliary]})))}let d=uc(s);if(d)return K.succeed({fieldDefinition:`${t}: [${d}!]${a}`,auxiliary:[]});return K.fail(new De({fieldName:t,schemaType:`TupleType (item: ${s._tag})`}))}),fe.tag("Refinement",(o)=>un(o.from,t,n,r)),fe.tag("Transformation",(o)=>un(o.from,t,n,r)),fe.tag("Union",(o)=>{let i=o.types.filter((d)=>d._tag!=="UndefinedKeyword"&&d._tag!=="VoidKeyword"&&ht(d)),s=St(i);if(s){let d=r||i.length!==o.types.length;return K.succeed({fieldDefinition:`${t}: ${s}${d?"":"!"}`,auxiliary:[]})}if(i.length>1)return K.fail(new De({fieldName:t,schemaType:e._tag}));let a=i[0];if(!a)return K.fail(new De({fieldName:t,schemaType:"Union (all undefined)"}));return un(a,t,n,r||i.length!==o.types.length)}),fe.orElse(()=>K.fail(new De({fieldName:t,schemaType:e._tag}))))(e);class Xe extends mr.TaggedError("InvalidProcessGraph"){}class Yo extends mr.TaggedError("NoStartNodeError"){get message(){return`Process "${this.processPath}" has no start nodes`}}var ln=de,lc=/^[_A-Za-z][_0-9A-Za-z]*$/,pc=(e)=>C.gen(function*(){let t=e.startNodes();if(t.length===0)return yield*new Yo({processPath:e.node.path});return t[0]}),Go=(e)=>C.gen(function*(){let t=[];for(let n of e.node.children)if(st(n)){let r=yield*Go(n);t.push(...r)}else if(Ie(n)){let r=yield*C.try({try:()=>n.getGraph(),catch:(i)=>new Xe({processPath:n.node.path,cause:i})}),o=r.nodes();for(let i of o){let s=r.getNodeAttributes(i);if(it(s))t.push(s)}}return t}),Qo=(e)=>C.gen(function*(){let t=[];for(let n of e.node.children)if(st(n)){let r=yield*Qo(n);t.push(...r)}else if(Ie(n))t.push(n);return t}),Jo=(e)=>C.gen(function*(){let t=[];for(let n of e.node.children)if(st(n)){let r=yield*Jo(n);t.push(...r)}else if(Hn(n))t.push(n);return t});class Me extends mr.TaggedError("InvalidListSchema"){get message(){let e=this.cause instanceof Error?`: ${this.cause.message}`:"";return`Invalid list schema for ${this.listPath}${e}`}}var fc=(e)=>C.gen(function*(){let t=`${de(e.node.path)}Item`,n=xt.Struct(e.output);return yield*dn(n.ast,t).pipe(C.mapError((o)=>new Me({listPath:e.node.path,cause:o})))}),mc=(e)=>C.gen(function*(){if(!e.hasForm||!e.formFields)return null;let t=`${de(e.node.path)}Detail`,n=xt.Struct(e.formFields);return yield*dn(n.ast,t).pipe(C.mapError((o)=>new Me({listPath:e.node.path,cause:o})))}),yc=(e)=>C.gen(function*(){if(!e.hasForm)return null;let t=de(e.node.path),n=e.itemQueryName(),r=`${t}Detail`,o=[];for(let s of e.itemQueryControls()){if(!lc.test(s.name)||s.name==="id")return yield*C.fail(new Me({listPath:e.node.path,cause:Error(`MetricBreakdown control name "${s.name}" is not a safe GraphQL item query argument name`)}));o.push(`${s.name}: String`)}let i=["id: String!",...o];return` ${n}(${i.join(", ")}): ${r}`}),gc=(e)=>{let t=de(e.node.path),n=`${t}Item`;return`type ${`${t}Page`} {
25
+ }`,auxiliary:o}})),Se.orElse((n)=>z.fail(new Wo({nodeTag:n._tag}))))(cr.toEncoded(e)),Uu=(e,t)=>z.gen(function*(){let n=yield*qo(e.name),r=e.type.context?.isOptional??!1;return yield*Ko(e.type,n,t,r)}),Ko=(e,t,n,r)=>Se.type().pipe(Se.when((o)=>ur(o._tag)!==void 0,(o)=>{let i=ur(o._tag);if(!i)return z.fail(new De({fieldName:t,schemaType:o._tag}));let s=r?"":"!";return z.succeed({fieldDefinition:`${t}: ${i}${s}`,auxiliary:[]})}),Se.tag("Literal",(o)=>{let i=et(o.literal);if(!i)return z.fail(new De({fieldName:t,schemaType:e._tag}));let s=r?"":"!";return z.succeed({fieldDefinition:`${t}: ${i}${s}`,auxiliary:[]})}),Se.tag("Objects",(o)=>z.gen(function*(){let i=Uo(n,t),s=yield*tt(o,i);return{fieldDefinition:`${t}: ${i}${r?"":"!"}`,auxiliary:[s.main,...s.auxiliary]}})),Se.tag("Arrays",(o)=>{let i=o.rest[0];if(!i)return z.fail(new De({fieldName:t,schemaType:"Arrays (empty)"}));let s=i,a=r?"":"!";if(s._tag==="Objects"){let u=Uo(n,`${t}Item`);return tt(s,u).pipe(z.map((l)=>({fieldDefinition:`${t}: [${u}!]${a}`,auxiliary:[l.main,...l.auxiliary]})))}let d=Bu(s);if(d)return z.succeed({fieldDefinition:`${t}: [${d}!]${a}`,auxiliary:[]});return z.fail(new De({fieldName:t,schemaType:`Arrays (item: ${s._tag})`}))}),Se.tag("Union",(o)=>{let i=he(o).filter((d)=>d._tag!=="Undefined"&&d._tag!=="Void"&&wt(d)),s=Tt(i);if(s){let d=r||i.length!==he(o).length;return z.succeed({fieldDefinition:`${t}: ${s}${d?"":"!"}`,auxiliary:[]})}if(i.length>1)return z.fail(new De({fieldName:t,schemaType:e._tag}));let a=i[0];if(!a)return z.fail(new De({fieldName:t,schemaType:"Union (all undefined)"}));return Ko(a,t,n,r||i.length!==he(o).length)}),Se.orElse(()=>z.fail(new De({fieldName:t,schemaType:e._tag}))))(cr.toEncoded(e));class nt extends lr.TaggedError("InvalidProcessGraph"){}class zo extends lr.TaggedError("NoStartNodeError"){get message(){return`Process "${this.processPath}" has no start nodes`}}var fn=ce,ju=/^[_A-Za-z][_0-9A-Za-z]*$/,Wu=(e)=>v.gen(function*(){let t=e.startNodes();if(t.length===0)return yield*new zo({processPath:e.node.path});return t[0]}),Vo=(e)=>v.gen(function*(){let t=[];for(let n of e.node.children)if(ct(n)){let r=yield*Vo(n);t.push(...r)}else if($e(n)){let r=yield*v.try({try:()=>n.getGraph(),catch:(i)=>new nt({processPath:n.node.path,cause:i})}),o=r.nodes();for(let i of o){let s=r.getNodeAttributes(i);if(Ke(s))t.push(s)}}return t}),Go=(e)=>v.gen(function*(){let t=[];for(let n of e.node.children)if(ct(n)){let r=yield*Go(n);t.push(...r)}else if($e(n))t.push(n);return t}),Yo=(e)=>v.gen(function*(){let t=[];for(let n of e.node.children)if(ct(n)){let r=yield*Yo(n);t.push(...r)}else if(jn(n))t.push(n);return t});class Le extends lr.TaggedError("InvalidListSchema"){get message(){let e=this.cause instanceof Error?`: ${this.cause.message}`:"";return`Invalid list schema for ${this.listPath}${e}`}}var Hu=(e)=>v.gen(function*(){let t=`${ce(e.node.path)}Item`,n=bt.Struct(e.output);return yield*cn(n.ast,t).pipe(v.mapError((o)=>new Le({listPath:e.node.path,cause:o})))}),qu=(e)=>v.gen(function*(){if(!e.hasForm||!e.formFields)return null;let t=`${ce(e.node.path)}Detail`,n=bt.Struct(e.formFields);return yield*cn(n.ast,t).pipe(v.mapError((o)=>new Le({listPath:e.node.path,cause:o})))}),Ku=(e)=>v.gen(function*(){if(!e.hasForm)return null;let t=ce(e.node.path),n=e.itemQueryName(),r=`${t}Detail`,o=[];for(let s of e.itemQueryControls()){if(!ju.test(s.name)||s.name==="id")return yield*v.fail(new Le({listPath:e.node.path,cause:Error(`MetricBreakdown control name "${s.name}" is not a safe GraphQL item query argument name`)}));o.push(`${s.name}: String`)}let i=["id: String!",...o];return` ${n}(${i.join(", ")}): ${r}`}),zu=(e)=>{let t=ce(e.node.path),n=`${t}Item`;return`type ${`${t}Page`} {
26
26
  items: [${n}!]!
27
27
  totalCount: Int!
28
28
  page: Int!
29
29
  limit: Int!
30
30
  hasNextPage: Boolean!
31
- }`},hc=(e)=>{let t=de(e.node.path),n=e.queryName(),r=`${t}Page`,i=["page: Int! = 1",`limit: Int! = ${e.defaultPageSize}`,"filter: String","sort: ListSortInput"];return` ${n}(${i.join(", ")}): ${r}!`},Sc=(e)=>C.gen(function*(){if(!e.hasUpdate||!e.hasForm||!e.formFields)return null;let t=e.updateInputTypeName(),n=xt.Struct(e.editableFormFields()),r=yield*nt(n).pipe(C.mapError((i)=>new Me({listPath:e.node.path,cause:i})));return yield*Ze(r.ast,t).pipe(C.mapError((i)=>new Me({listPath:e.node.path,cause:i})))}),Tc=(e)=>{if(!e.hasUpdate||!e.hasForm)return null;let t=de(e.node.path),n=e.updateMutationName(),r=e.updateInputTypeName(),o=`${t}Detail`;return` ${n}(id: String!, input: ${r}!): ${o}`},xc=(e)=>{if(!e.hasDelete)return null;return` ${e.deleteMutationName()}(id: String!): Boolean!`},Fc=(e)=>C.gen(function*(){let t=e.createSubmissionSchema(),n=t?yield*Ze(t.ast,e.createInputTypeName()).pipe(C.mapError((g)=>new Me({listPath:e.node.path,cause:g}))):null,r=e.hasCreate?` ${e.createMutationName()}(input: ${e.createInputTypeName()}!): String!`:null,o=yield*fc(e),i=gc(e),s=hc(e),a=yield*mc(e),d=yield*yc(e),u=yield*Sc(e),l=Tc(e),c=xc(e);return{itemTypes:o,pageType:i,query:s,detailType:a,itemQuery:d,createInputType:n,createMutation:r,updateInputType:u,updateMutation:l,deleteMutation:c}}),bc=(e)=>C.gen(function*(){let t=ln(e.node.path),n=xt.Struct(e.output),r=yield*nt(n).pipe(C.mapError((i)=>new Xe({processPath:e.node.path,cause:i})));if(Object.keys(r.fields).length===0)return{main:`input ${t} {
31
+ }`},Vu=(e)=>{let t=ce(e.node.path),n=e.queryName(),r=`${t}Page`,i=["page: Int! = 1",`limit: Int! = ${e.defaultPageSize}`,"filter: String","sort: ListSortInput"];return` ${n}(${i.join(", ")}): ${r}!`},Gu=(e)=>v.gen(function*(){if(!e.hasUpdate||!e.hasForm||!e.formFields)return null;let t=e.updateInputTypeName(),n=bt.Struct(e.editableFormFields()),r=yield*at(n).pipe(v.mapError((i)=>new Le({listPath:e.node.path,cause:i})));return yield*tt(r.ast,t).pipe(v.mapError((i)=>new Le({listPath:e.node.path,cause:i})))}),Yu=(e)=>{if(!e.hasUpdate||!e.hasForm)return null;let t=ce(e.node.path),n=e.updateMutationName(),r=e.updateInputTypeName(),o=`${t}Detail`;return` ${n}(id: String!, input: ${r}!): ${o}`},Qu=(e)=>{if(!e.hasDelete)return null;return` ${e.deleteMutationName()}(id: String!): Boolean!`},Ju=(e)=>v.gen(function*(){let t=e.createSubmissionSchema(),n=t?yield*tt(t.ast,e.createInputTypeName()).pipe(v.mapError((h)=>new Le({listPath:e.node.path,cause:h}))):null,r=e.hasCreate?` ${e.createMutationName()}(input: ${e.createInputTypeName()}!): String!`:null,o=yield*Hu(e),i=zu(e),s=Vu(e),a=yield*qu(e),d=yield*Ku(e),u=yield*Gu(e),l=Yu(e),c=Qu(e);return{itemTypes:o,pageType:i,query:s,detailType:a,itemQuery:d,createInputType:n,createMutation:r,updateInputType:u,updateMutation:l,deleteMutation:c}}),Zu=(e)=>v.gen(function*(){let t=fn(e.node.path),n=bt.Struct(e.output),r=yield*at(n).pipe(v.mapError((i)=>new nt({processPath:e.node.path,cause:i})));if(Object.keys(r.fields).length===0)return{main:`input ${t} {
32
32
  _dummy: String
33
- }`,auxiliary:[]};return yield*Ze(r.ast,t).pipe(C.mapError((i)=>new Xe({processPath:e.node.path,cause:i})))}),wc=(e)=>C.gen(function*(){let t=yield*pc(e),n=e.startMutationName(),o=(t.isForm?t:null)?.embed?' @auth(tag: "embed")':e.props.cron&&t.isSystemStep?' @auth(tag: "cron")':"";if(!(t.isForm&&t.output&&Object.keys(t.output).length>0))return[` ${n}(executionId: ID, withoutWaiting: Boolean = false): StartProcessPayload!${o}`];let s=ln(t.node.path);return[` ${n}(input: ${s}!, executionId: ID, withoutWaiting: Boolean = false): StartProcessPayload!${o}`]}),Ec=(e)=>C.gen(function*(){let t=yield*C.try({try:()=>e.getGraph(),catch:(o)=>new Xe({processPath:e.node.path,cause:o})}),n=[],r=t.nodes();for(let o of r){let i=t.getNodeAttributes(o);if(it(i)){let a=`complete${ln(i.node.path)}`,d=xt.Struct(i.output),u=yield*nt(d).pipe(C.mapError((c)=>new Xe({processPath:e.node.path,cause:c})));if(Object.keys(u.fields).length===0)n.push(` ${a}(todoId: ID!): CompleteStepPayload!`);else{let c=ln(i.node.path);n.push(` ${a}(todoId: ID!, input: ${c}!): CompleteStepPayload!`)}}}return n}),kc=(e)=>{let t=[],n=[];for(let{form:r}of e.forms()){let o=r.lookupOverrides();for(let[i,s]of o){if(!s.dependencies||s.dependencies.length===0)continue;let a=r.lookupQueryName(i),d=`${a.charAt(0).toUpperCase()+a.slice(1)}Input`,u=s.dependencies.map((c)=>` ${c}: String!`).join(`
33
+ }`,auxiliary:[]};return yield*tt(r.ast,t).pipe(v.mapError((i)=>new nt({processPath:e.node.path,cause:i})))}),Xu=(e)=>v.gen(function*(){let t=yield*Wu(e),n=e.startMutationName(),r=e.props.cron&&t.isSystemStep?' @auth(tag: "cron")':` @step(path: ${JSON.stringify(Ae(t.node.path))}) @processPermission`;if(!(t.isForm&&t.output&&Object.keys(t.output).length>0))return[` ${n}(executionId: ID, withoutWaiting: Boolean = false): StartProcessPayload!${r}`];let i=fn(t.node.path);return[` ${n}(input: ${i}!, executionId: ID, withoutWaiting: Boolean = false): StartProcessPayload!${r}`]}),ec=(e)=>v.gen(function*(){let t=yield*v.try({try:()=>e.getGraph(),catch:(o)=>new nt({processPath:e.node.path,cause:o})}),n=[],r=t.nodes();for(let o of r){let i=t.getNodeAttributes(o);if(Ke(i)){let a=`complete${fn(i.node.path)}`,d=bt.Struct(i.output),u=yield*at(d).pipe(v.mapError((c)=>new nt({processPath:e.node.path,cause:c})));if(Object.keys(u.fields).length===0)n.push(` ${a}(todoId: ID!): CompleteStepPayload! @processPermission`);else{let c=fn(i.node.path);n.push(` ${a}(todoId: ID!, input: ${c}!): CompleteStepPayload! @processPermission`)}}}return n}),tc=(e)=>{let t=[],n=[];for(let{form:r}of e.forms()){if(r.prefillQuery())n.push(` ${r.prefillQueryName()}(value: String!): JSON!`);let o=r.lookupOverrides();for(let[i,s]of o){if(!s.dependencies||s.dependencies.length===0)continue;let a=r.lookupQueryName(i),d=`${a.charAt(0).toUpperCase()+a.slice(1)}Input`,u=s.dependencies.map((l)=>` ${l}: String!`).join(`
34
34
  `);t.push(`input ${d} {
35
35
  filter: String
36
36
  ${u}
37
- }`);let l=r.embed?' @auth(tag: "embed")':"";n.push(` ${a}(input: ${d}!, limit: Int): [LookupItem!]!${l}`)}}return{inputTypes:t,queryFields:n}},Oc=`type StartProcessPayload {
37
+ }`),n.push(` ${a}(input: ${d}!, limit: Int): [LookupItem!]! @step(path: ${JSON.stringify(Ae(r.node.path))})`)}}return{inputTypes:t,queryFields:n}},nc=`type StartProcessPayload {
38
38
  deduplicated: Boolean!
39
39
  executionId: ID!
40
40
  processId: ID!
41
41
  processPath: String!
42
42
  timestamp: DateTimeISO!
43
- }`,Rc=`type CompleteStepPayload {
43
+ }`,rc=`type CompleteStepPayload {
44
44
  executionId: ID!
45
45
  stepPath: String!
46
46
  timestamp: DateTimeISO!
47
- }`,Zo=()=>C.gen(function*(){let{organisation:e,customGraphqlSchema:t}=yield*yt,n=yield*Go(e),r=yield*C.forEach(n,(b)=>bc(b)),o=new Set,i=[];for(let b of r){i.push(b.main);for(let A of b.auxiliary)o.add(A)}let s=yield*Qo(e),a=yield*C.forEach(s,(b)=>wc(b)),d=yield*C.forEach(s,(b)=>Ec(b)),u=[...a.flat(),...d.flat()],l=[],c=[];for(let b of s){let{inputTypes:A,queryFields:p}=kc(b);l.push(...A),c.push(...p)}let g=yield*Jo(e),x=yield*C.forEach(g,(b)=>Fc(b)),F=[],N=[];for(let b of x){F.push(b.itemTypes.main);for(let A of b.itemTypes.auxiliary)F.push(A);if(F.push(b.pageType),b.detailType){F.push(b.detailType.main);for(let A of b.detailType.auxiliary)F.push(A)}if(b.createInputType)F.push(b.createInputType.main,...b.createInputType.auxiliary);if(b.createMutation)u.push(b.createMutation);if(b.updateInputType){F.push(b.updateInputType.main);for(let A of b.updateInputType.auxiliary)F.push(A)}if(N.push(b.query),b.itemQuery)N.push(b.itemQuery);if(b.updateMutation)u.push(b.updateMutation);if(b.deleteMutation)u.push(b.deleteMutation)}let D=[];if(D.push(Oc),D.push(Rc),o.size>0)D.push(...o);if(i.length>0)D.push(...i);if(l.length>0)D.push(...l);if(F.length>0)D.push(...F);if(u.length>0){let b=`type Mutation {
47
+ }`,Qo=()=>v.gen(function*(){let{organisation:e,customGraphqlSchema:t}=yield*St,n=yield*Vo(e),r=yield*v.forEach(n,(b)=>Zu(b)),o=new Set,i=[];for(let b of r){i.push(b.main);for(let P of b.auxiliary)o.add(P)}let s=yield*Go(e),a=yield*v.forEach(s,(b)=>Xu(b)),d=yield*v.forEach(s,(b)=>ec(b)),u=[...a.flat(),...d.flat()],l=[],c=[];for(let b of s){let{inputTypes:P,queryFields:f}=tc(b);l.push(...P),c.push(...f)}let h=yield*Yo(e),w=yield*v.forEach(h,(b)=>Ju(b)),T=[],B=[];for(let b of w){T.push(b.itemTypes.main);for(let P of b.itemTypes.auxiliary)T.push(P);if(T.push(b.pageType),b.detailType){T.push(b.detailType.main);for(let P of b.detailType.auxiliary)T.push(P)}if(b.createInputType)T.push(b.createInputType.main,...b.createInputType.auxiliary);if(b.createMutation)u.push(b.createMutation);if(b.updateInputType){T.push(b.updateInputType.main);for(let P of b.updateInputType.auxiliary)T.push(P)}if(B.push(b.query),b.itemQuery)B.push(b.itemQuery);if(b.updateMutation)u.push(b.updateMutation);if(b.deleteMutation)u.push(b.deleteMutation)}let D=[`"Binds a generated operation to its domain Step for Cedar authorization."
48
+ directive @step(path: String!) on FIELD_DEFINITION`,`"Authorizes an eligible generated mutation through its process command."
49
+ directive @processPermission on FIELD_DEFINITION`];if(D.push(nc),D.push(rc),o.size>0)D.push(...o);if(i.length>0)D.push(...i);if(l.length>0)D.push(...l);if(T.length>0)D.push(...T);if(u.length>0){let b=`type Mutation {
48
50
  ${u.join(`
49
51
  `)}
50
- }`;D.push(b)}let B=[...N,...c];if(B.length>0){let b=`type Query {
51
- ${B.join(`
52
+ }`;D.push(b)}let j=[...B,...c];if(j.length>0){let b=`type Query {
53
+ ${j.join(`
52
54
  `)}
53
55
  }`;D.push(b)}if(t?.typeDefs)D.push(t.typeDefs);return D.join(`
54
56
 
55
- `)});var jT=(e,t,n)=>Xo.runPromise(Zo().pipe(Xo.provide(Mo(e,t,void 0,n))));export{jT as buildBundledGraphqlSchema};
57
+ `)});var Wg=(e,t,n)=>Jo.runPromise(Qo().pipe(Jo.provide(Ro(e,t,void 0,n))));export{Wg as buildBundledGraphqlSchema};