UNPKG

@finda-co/novu-framework

Version:

The Code-First Notifications Workflow SDK.

13 lines 218 kB
"use strict";var vo=Object.create;var Jt=Object.defineProperty;var _o=Object.getOwnPropertyDescriptor;var Ro=Object.getOwnPropertyNames;var Po=Object.getPrototypeOf,Io=Object.prototype.hasOwnProperty;var No=(w,r)=>{for(var o in r)Jt(w,o,{get:r[o],enumerable:!0})},br=(w,r,o,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(let E of Ro(r))!Io.call(w,E)&&E!==o&&Jt(w,E,{get:()=>r[E],enumerable:!(u=_o(r,E))||u.enumerable});return w};var at=(w,r,o)=>(o=w!=null?vo(Po(w)):{},br(r||!w||!w.__esModule?Jt(o,"default",{value:w,enumerable:!0}):o,w)),xo=w=>br(Jt({},"__esModule",{value:!0}),w);var ba={};No(ba,{Client:()=>wt,CronExpression:()=>si,NovuRequestHandler:()=>kn,workflow:()=>hs});module.exports=xo(ba);var Ur=require("liquidjs");var Rt=(u=>(u.TRIGGER="trigger",u.EXECUTE="execute",u.PREVIEW="preview",u))(Rt||{}),Gt=(u=>(u.DISCOVER="discover",u.HEALTH_CHECK="health-check",u.CODE="code",u))(Gt||{});var si=(U=>(U.EVERY_SECOND="* * * * * *",U.EVERY_5_SECONDS="*/5 * * * * *",U.EVERY_10_SECONDS="*/10 * * * * *",U.EVERY_30_SECONDS="*/30 * * * * *",U.EVERY_MINUTE="*/1 * * * *",U.EVERY_5_MINUTES="0 */5 * * * *",U.EVERY_10_MINUTES="0 */10 * * * *",U.EVERY_30_MINUTES="0 */30 * * * *",U.EVERY_HOUR="0 0-23/1 * * *",U.EVERY_2_HOURS="0 0-23/2 * * *",U.EVERY_3_HOURS="0 0-23/3 * * *",U.EVERY_4_HOURS="0 0-23/4 * * *",U.EVERY_5_HOURS="0 0-23/5 * * *",U.EVERY_6_HOURS="0 0-23/6 * * *",U.EVERY_7_HOURS="0 0-23/7 * * *",U.EVERY_8_HOURS="0 0-23/8 * * *",U.EVERY_9_HOURS="0 0-23/9 * * *",U.EVERY_10_HOURS="0 0-23/10 * * *",U.EVERY_11_HOURS="0 0-23/11 * * *",U.EVERY_12_HOURS="0 0-23/12 * * *",U.EVERY_DAY_AT_1AM="0 01 * * *",U.EVERY_DAY_AT_2AM="0 02 * * *",U.EVERY_DAY_AT_3AM="0 03 * * *",U.EVERY_DAY_AT_4AM="0 04 * * *",U.EVERY_DAY_AT_5AM="0 05 * * *",U.EVERY_DAY_AT_6AM="0 06 * * *",U.EVERY_DAY_AT_7AM="0 07 * * *",U.EVERY_DAY_AT_8AM="0 08 * * *",U.EVERY_DAY_AT_9AM="0 09 * * *",U.EVERY_DAY_AT_10AM="0 10 * * *",U.EVERY_DAY_AT_11AM="0 11 * * *",U.EVERY_DAY_AT_NOON="0 12 * * *",U.EVERY_DAY_AT_1PM="0 13 * * *",U.EVERY_DAY_AT_2PM="0 14 * * *",U.EVERY_DAY_AT_3PM="0 15 * * *",U.EVERY_DAY_AT_4PM="0 16 * * *",U.EVERY_DAY_AT_5PM="0 17 * * *",U.EVERY_DAY_AT_6PM="0 18 * * *",U.EVERY_DAY_AT_7PM="0 19 * * *",U.EVERY_DAY_AT_8PM="0 20 * * *",U.EVERY_DAY_AT_9PM="0 21 * * *",U.EVERY_DAY_AT_10PM="0 22 * * *",U.EVERY_DAY_AT_11PM="0 23 * * *",U.EVERY_DAY_AT_MIDNIGHT="0 0 * * *",U.EVERY_WEEK="0 0 * * 0",U.EVERY_WEEKDAY="0 0 * * 1-5",U.EVERY_WEEKEND="0 0 * * 6,0",U.EVERY_1ST_DAY_OF_MONTH_AT_MIDNIGHT="0 0 1 * *",U.EVERY_1ST_DAY_OF_MONTH_AT_NOON="0 12 1 * *",U.EVERY_2ND_HOUR="0 */2 * * *",U.EVERY_2ND_HOUR_FROM_1AM_THROUGH_11PM="0 1-23/2 * * *",U.EVERY_2ND_MONTH="0 0 1 */2 *",U.EVERY_QUARTER="0 0 1 */3 *",U.EVERY_6_MONTHS="0 0 1 */6 *",U.EVERY_YEAR="0 0 1 0 *",U.EVERY_30_MINUTES_BETWEEN_9AM_AND_5PM="0 */30 9-17 * * *",U.EVERY_30_MINUTES_BETWEEN_9AM_AND_6PM="0 */30 9-18 * * *",U.EVERY_30_MINUTES_BETWEEN_10AM_AND_7PM="0 */30 10-19 * * *",U.MONDAY_TO_FRIDAY_AT_1AM="0 0 01 * * 1-5",U.MONDAY_TO_FRIDAY_AT_2AM="0 0 02 * * 1-5",U.MONDAY_TO_FRIDAY_AT_3AM="0 0 03 * * 1-5",U.MONDAY_TO_FRIDAY_AT_4AM="0 0 04 * * 1-5",U.MONDAY_TO_FRIDAY_AT_5AM="0 0 05 * * 1-5",U.MONDAY_TO_FRIDAY_AT_6AM="0 0 06 * * 1-5",U.MONDAY_TO_FRIDAY_AT_7AM="0 0 07 * * 1-5",U.MONDAY_TO_FRIDAY_AT_8AM="0 0 08 * * 1-5",U.MONDAY_TO_FRIDAY_AT_9AM="0 0 09 * * 1-5",U.MONDAY_TO_FRIDAY_AT_09_30AM="0 30 09 * * 1-5",U.MONDAY_TO_FRIDAY_AT_10AM="0 0 10 * * 1-5",U.MONDAY_TO_FRIDAY_AT_11AM="0 0 11 * * 1-5",U.MONDAY_TO_FRIDAY_AT_11_30AM="0 30 11 * * 1-5",U.MONDAY_TO_FRIDAY_AT_12PM="0 0 12 * * 1-5",U.MONDAY_TO_FRIDAY_AT_1PM="0 0 13 * * 1-5",U.MONDAY_TO_FRIDAY_AT_2PM="0 0 14 * * 1-5",U.MONDAY_TO_FRIDAY_AT_3PM="0 0 15 * * 1-5",U.MONDAY_TO_FRIDAY_AT_4PM="0 0 16 * * 1-5",U.MONDAY_TO_FRIDAY_AT_5PM="0 0 17 * * 1-5",U.MONDAY_TO_FRIDAY_AT_6PM="0 0 18 * * 1-5",U.MONDAY_TO_FRIDAY_AT_7PM="0 0 19 * * 1-5",U.MONDAY_TO_FRIDAY_AT_8PM="0 0 20 * * 1-5",U.MONDAY_TO_FRIDAY_AT_9PM="0 0 21 * * 1-5",U.MONDAY_TO_FRIDAY_AT_10PM="0 0 22 * * 1-5",U.MONDAY_TO_FRIDAY_AT_11PM="0 0 23 * * 1-5",U))(si||{});var We=(ce=>(ce.BRIDGE_ERROR="BridgeError",ce.EXECUTION_EVENT_CONTROL_INVALID_ERROR="ExecutionEventControlInvalidError",ce.EXECUTION_EVENT_PAYLOAD_INVALID_ERROR="ExecutionEventPayloadInvalidError",ce.EXECUTION_PROVIDER_OUTPUT_INVALID_ERROR="ExecutionProviderOutputInvalidError",ce.EXECUTION_STATE_CONTROL_INVALID_ERROR="ExecutionStateControlInvalidError",ce.EXECUTION_STATE_CORRUPT_ERROR="ExecutionStateCorruptError",ce.EXECUTION_STATE_OUTPUT_INVALID_ERROR="ExecutionStateOutputInvalidError",ce.EXECUTION_STATE_RESULT_INVALID_ERROR="ExecutionStateResultInvalidError",ce.INVALID_ACTION_ERROR="InvalidActionError",ce.METHOD_NOT_ALLOWED_ERROR="MethodNotAllowedError",ce.MISSING_DEPENDENCY_ERROR="MissingDependencyError",ce.MISSING_SECRET_KEY_ERROR="MissingSecretKeyError",ce.PROVIDER_EXECUTION_FAILED_ERROR="ProviderExecutionFailedError",ce.PROVIDER_NOT_FOUND_ERROR="ProviderNotFoundError",ce.SIGNATURE_EXPIRED_ERROR="SignatureExpiredError",ce.SIGNATURE_INVALID_ERROR="SignatureInvalidError",ce.SIGNATURE_MISMATCH_ERROR="SignatureMismatchError",ce.SIGNATURE_NOT_FOUND_ERROR="SignatureNotFoundError",ce.SIGNATURE_VERSION_INVALID_ERROR="SignatureVersionInvalidError",ce.SIGNING_KEY_NOT_FOUND_ERROR="SigningKeyNotFoundError",ce.STEP_ALREADY_EXISTS_ERROR="StepAlreadyExistsError",ce.STEP_CONTROL_COMPILATION_FAILED_ERROR="StepControlCompilationFailedError",ce.STEP_EXECUTION_FAILED_ERROR="StepExecutionFailedError",ce.STEP_NOT_FOUND_ERROR="StepNotFoundError",ce.WORKFLOW_ALREADY_EXISTS_ERROR="WorkflowAlreadyExistsError",ce.WORKFLOW_NOT_FOUND_ERROR="WorkflowNotFoundError",ce.WORKFLOW_PAYLOAD_INVALID_ERROR="WorkflowPayloadInvalidError",ce))(We||{});var Kt=(u=>(u.POST="POST",u.GET="GET",u.OPTIONS="OPTIONS",u))(Kt||{});var Ht=(Y=>(Y.EMAIL="email",Y.SMS="sms",Y.PUSH="push",Y.CHAT="chat",Y.IN_APP="in_app",Y))(Ht||{});var ko=w=>{var o,u;if(typeof w!="object"||w===null)return!1;let r=Object.getPrototypeOf(w);return(u=(o=r==null?void 0:r.constructor)==null?void 0:o.name.endsWith("Error"))!=null?u:!1},et=class extends Error{},zt=class extends et{constructor(){super(...arguments);this.statusCode=404}},Ce=class extends et{constructor(){super(...arguments);this.statusCode=400}},it=class extends et{constructor(){super(...arguments);this.statusCode=401}},rt=class extends et{constructor(r,{cause:o}={}){var u;ko(o)?(super(`${r}: ${o.message}`),this.data={stack:(u=o.stack)!=null?u:r}):(super(`${r}${o?`: ${JSON.stringify(o,null,2)}`:""}`),this.data={stack:r})}},Xt=class extends et{constructor(){super(...arguments);this.statusCode=409}};var mt=class extends rt{constructor(o){super("Unknown BridgeError",{cause:o});this.statusCode=500;this.code="BridgeError"}};var Qt=class extends Ce{constructor(o,u){super(`Workflow with id: \`${o}\` has a corrupt state. Step with id: \`${u}\` does not exist. Please provide the missing state.`);this.code="ExecutionStateCorruptError";this.data={workflowId:o,stepId:u}}},It=class extends Ce{constructor(o,u){super(`Workflow with id: \`${o}\` has invalid \`payload\`. Please provide the correct event payload.`);this.code="ExecutionEventPayloadInvalidError";this.data=u}},Zt=class extends Ce{constructor(o,u){super(`Workflow with id: \`${o}\` has invalid \`controls\`. Please provide the correct event controls.`);this.code="ExecutionEventControlInvalidError";this.data=u}},en=class extends Ce{constructor(o,u,E){super(`Workflow with id: \`${o}\` has an invalid state. Step with id: \`${u}\` has invalid \`controls\`. Please provide the correct step controls.`);this.code="ExecutionStateControlInvalidError";this.data=E}},tn=class extends Ce{constructor(o,u,E){super(`Workflow with id: \`${o}\` has an invalid state. Step with id: \`${u}\` has invalid output. Please provide the correct step output.`);this.code="ExecutionStateOutputInvalidError";this.data=E}},nn=class extends Ce{constructor(o,u,E){super(`Workflow with id: \`${o}\` has an invalid state. Step with id: \`${u}\` has invalid result. Please provide the correct step result.`);this.code="ExecutionStateResultInvalidError";this.data=E}},rn=class extends Ce{constructor(o,u,E){super(`Workflow with id: \`${o}\` has invalid controls syntax in step with id: \`${u}\`. Please correct step control syntax.`);this.code="StepControlCompilationFailedError";this.data=E}},sn=class extends Ce{constructor(o,u,E,Y){super(`Workflow with id: \`${o}\` has an invalid state. Step with id: \`${u}\` and provider with id: \`${E}\` has invalid output. Please provide the correct provider output.`);this.code="ExecutionProviderOutputInvalidError";this.data=Y}},on=class extends Ce{constructor(o,u){super(`Workflow with id: \`${o}\` has invalid \`payload\`. Please provide the correct payload.`);this.code="WorkflowPayloadInvalidError";this.data=u}};var oi=w=>Object.values(w).map(r=>`\`${r}\``).join(", "),an=w=>w.replaceAll(/(\w)(\w*)/g,(r,o,u)=>o.toUpperCase()+u.toLowerCase()).replaceAll(/[\s-]+/g,""),ai=(w,r=0)=>Array.isArray(w)||typeof w=="object"&&w!==null?JSON.stringify(w,null,r).replace(/"/g,"'").replace(/\n/g,"\\n"):String(w);var ln=class extends et{constructor(){super(...arguments);this.code="MethodNotAllowedError";this.statusCode=405;this.message=`Method not allowed. Please use one of ${oi(Kt)}`}},Nt=class extends Ce{constructor(o,u){super(`Invalid query string: \`action\`=\`${o}\`. Please use one of ${oi(u)}`);this.code="InvalidActionError"}},cn=class extends Ce{constructor(){super("Missing secret key. Set the `NOVU_SECRET_KEY` environment variable or pass `secretKey` to the client options.");this.code="MissingSecretKeyError"}};var pn=class extends Error{constructor(r,o,u){super(),this.data={message:u},this.statusCode=r,this.code=o}};var xt=class extends Xt{constructor(r,o){super(`${an(r)} with id: \`${o}\` already exists. Please use a different id.`)}},st=class extends zt{constructor(r,o){super(`${an(r)} with id: \`${o}\` does not exist. Please provide a valid id.`)}},yt=class extends rt{constructor(o,u,E,Y){super(`Failed to ${E} ${an(o)} with id: \`${u}\``,{cause:Y});this.statusCode=502}};var un=class extends st{constructor(o){super("provider",o);this.code="ProviderNotFoundError"}},dn=class extends yt{constructor(o,u,E){super("provider",o,u,E);this.code="ProviderExecutionFailedError"}};var fn=class extends it{constructor(){super("Signature does not match the expected signature. Please ensure the signature provided in the `novu-signature` header is correct and try again.");this.code="SignatureMismatchError"}},hn=class extends it{constructor(){super("Signature not found. Please provide a signature in the `novu-signature` header");this.code="SignatureNotFoundError"}},mn=class extends it{constructor(){super("Signature is invalid. Please provide a valid signature in the `novu-signature` header");this.code="SignatureInvalidError"}},yn=class extends it{constructor(){super(`Signature expired. Please provide a signature with a timestamp no older than ${5} minutes in the \`novu-signature\` header`);this.code="SignatureExpiredError"}},gn=class extends it{constructor(){super("Signature key not found. Please provide a valid key in the Client constructor `config.secretKey`");this.code="SigningKeyNotFoundError"}};var wn=class extends st{constructor(o){super("step",o);this.code="StepNotFoundError"}},bn=class extends xt{constructor(o){super("step",o);this.code="StepAlreadyExistsError"}},kt=class extends yt{constructor(o,u,E){super("step",o,u,E);this.code="StepExecutionFailedError"}};var Mt=class extends st{constructor(o){super("workflow",o);this.code="WorkflowNotFoundError"}};var lt=w=>Object.values(We).includes(w==null?void 0:w.code),Tr=w=>!lt(w)&&typeof w.statusCode=="number"&&w.statusCode>=400&&w.statusCode<500;var Or=async(w,r)=>{let o=new TextEncoder,u=o.encode(w),E=o.encode(r),Y=await crypto.subtle.importKey("raw",u,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),D=await crypto.subtle.sign("HMAC",Y,E);return Array.from(new Uint8Array(D)).map(ne=>ne.toString(16).padStart(2,"0")).join("")};var Lo=require("cross-fetch");var Ar=async()=>{if(process.env.NOVU_BRIDGE_ORIGIN)return`${process.env.NOVU_BRIDGE_ORIGIN}/api/novu`;if(process.env.NEXT_PUBLIC_VERCEL_ENV==="preview"&&process.env.NEXT_PUBLIC_VERCEL_URL)return`https://${process.env.NEXT_PUBLIC_VERCEL_URL}/api/novu`;try{if(process.env.NODE_ENV==="development"){let r=await(await fetch("http://localhost:2022/.well-known/novu")).json();return`${r.tunnelOrigin}${r.route}`}}catch(w){console.error(w)}return""};function Er(w){return!!w&&typeof w=="object"&&"error"in w&&"message"in w&&"statusCode"in w}var Sn=(w,r,o)=>{let{headers:u,...E}=o||{};if(!w)throw new cn;return{post:async(Y,D)=>{let ne=await fetch(`${r}/v1${Y}`,{...E,method:"POST",headers:{...u,"Content-Type":"application/json",Authorization:`ApiKey ${w}`},body:JSON.stringify(D)}),re=await ne.json();if(ne.ok)return re;throw Er(re)?new pn(re.statusCode,re.error,re.message):new mt(re)},delete:async Y=>(await fetch(`${r}/v1${Y}`,{...E,method:"DELETE",headers:{...u,"Content-Type":"application/json",Authorization:`ApiKey ${w}`}})).json()}};var ct=at(require("chalk"),1),we={info:w=>ct.default.blue(w),warning:w=>ct.default.yellow(w),error:w=>ct.default.red(w),success:w=>ct.default.green(w),underline:w=>ct.default.underline(w),bold:w=>ct.default.bold(w)},_e={SUCCESS:we.success("\u2714"),ERROR:we.error("\u2717"),WARNING:we.warning("\u26A0"),INFO:we.info("\u2139"),ARROW:we.bold("\u2192"),MOCK:we.info("\u25CB"),HYDRATED:we.bold(we.info("\u2192")),STEP:we.info("\u03C3"),ACTION:we.info("\u03B1"),DURATION:we.info("\u0394"),PROVIDER:we.info("\u2699"),OUTPUT:we.info("\u21E2"),INPUT:we.info("\u21E0"),WORKFLOW:we.info("\u03C9"),STATE:we.info("\u03C3"),EXECUTE:we.info("\u03B5"),PREVIEW:we.info("\u03C1")};function Tn(w){return w||process.env.NOVU_API_URL||"https://api.novu.co"}function On(w){return w||process.env.NOVU_SECRET_KEY||process.env.NOVU_API_KEY||""}var li=at(require("sanitize-html"),1),Do={allowedTags:li.default.defaults.allowedTags.concat(["style","img","html","head","body","link","meta","title"]),allowedAttributes:!1,allowVulnerableTags:!0,parseStyleAttributes:!1,parser:{lowerCaseAttributeNames:!0}},vr=w=>{if(!w)return w;let r=/^<!DOCTYPE .*?>/,o=w.match(r),u=(0,li.default)(w,Do);return o?o[0]+u:u},An=w=>Object.keys(w).reduce((r,o)=>{let u=w[o];return typeof u=="string"?r[o]=vr(u):Array.isArray(u)?r[o]=u.map(E=>typeof E=="string"?vr(E):typeof E=="object"?An(E):E):typeof u=="object"&&u!==null?r[o]=An(u):r[o]=u,r},{});var Rr=at(require("ajv"),1),Pr=at(require("ajv-formats"),1);var _r=w=>typeof structuredClone=="function"?structuredClone(w):JSON.parse(JSON.stringify(w));var En=class extends rt{constructor(o,u){let E=u.length===1?"it":"them";super(`Tried to use a ${o} in @novu/framework without ${u.join(", ")} installed. Please install ${E} by running \`npm install ${u.join(" ")}\`.`);this.statusCode=500;this.code="MissingDependencyError"}};var vn=async(w,r)=>{let o=new Set;if((await Promise.allSettled(w.map(E=>E.import))).forEach((E,Y)=>{let D=w[Y];E.status==="fulfilled"&&D.exports.every(re=>E.value[re]!==void 0)||o.add(D.name)}),o.size>0)throw new En(r,Array.from(o))};var _n=class{constructor(){this.requiredImports=[];this.ajv=new Rr.default({useDefaults:!0,removeAdditional:"failing"}),(0,Pr.default)(this.ajv),this.compiledSchemas=new Map}async canHandle(r){let o=r.type==="object"||!!r.anyOf||!!r.allOf||!!r.oneOf;return o&&await vn(this.requiredImports,"JSON schema"),o}async validate(r,o){let u=this.compiledSchemas.get(o);u||(u=this.ajv.compile(o),this.compiledSchemas.set(o,u));let E=_r(r);return u(E)?{success:!0,data:E}:{success:!1,errors:u.errors.map(D=>({path:D.instancePath,message:D.message}))}}async transformToJsonSchema(r){return r}};var Rn=class{constructor(){this.requiredImports=[{name:"zod",import:import("zod"),exports:["ZodType"]},{name:"zod-to-json-schema",import:import("zod-to-json-schema"),exports:["zodToJsonSchema"]}]}async canHandle(r){let o=r.safeParseAsync!==void 0;return o&&await vn(this.requiredImports,"Zod schema"),o}async validate(r,o){let u=await o.safeParseAsync(r);return u.success?{success:!0,data:u.data}:{success:!1,errors:u.error.errors.map(E=>({path:`/${E.path.join("/")}`,message:E.message}))}}async transformToJsonSchema(r){let{zodToJsonSchema:o}=await import("zod-to-json-schema");return o(r)}};var Pn=new Rn,In=new _n,Nn=async(w,r)=>{if(await Pn.canHandle(w))return Pn.validate(r,w);if(await In.canHandle(w))return In.validate(r,w);throw new Error("Invalid schema")},Ne=async w=>{if(await Pn.canHandle(w))return Pn.transformToJsonSchema(w);if(await In.canHandle(w))return In.transformToJsonSchema(w);throw new Error("Invalid schema")};var xn=(()=>{var w=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,u=Object.prototype.hasOwnProperty,E=(e,t)=>function(){return e&&(t=(0,e[o(e)[0]])(e=0)),t},Y=(e,t)=>function(){return t||(0,e[o(e)[0]])((t={exports:{}}).exports,t),t.exports},D=(e,t)=>{for(var n in t)w(e,n,{get:t[n],enumerable:!0})},ne=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of o(t))!u.call(e,c)&&c!==n&&w(e,c,{get:()=>t[c],enumerable:!(l=r(t,c))||l.enumerable});return e},re=e=>ne(w({},"__esModule",{value:!0}),e),Ee={};D(Ee,{JSONSchemaFaker:()=>gr,default:()=>wr,setDependencies:()=>ki});function Le(e,t){return typeof e=="string"?typeof t!="undefined"?Ot.register(e,t):Ot.get(e):Ot.registerMany(e)}function Ue(e,t){return e=typeof e=="undefined"?He.MIN_INTEGER:e,t=typeof t=="undefined"?He.MAX_INTEGER:t,Math.floor(ee("random")()*(t-e+1))+e}function Re(e){return Ft.default.prototype.max=ee("defaultRandExpMax"),Ft.default.prototype.randInt=(n,l)=>n+Math.floor(ee("random")()*(1+(l-n))),new Ft.default(e).gen()}function De(e){return e[Math.floor(ee("random")()*e.length)]}function Fe(e){let t,n,l=e.length,c=e.slice();for(;l>0;)n=Math.floor(ee("random")()*l),l-=1,t=c[l],c[l]=c[n],c[n]=t;return c}function ot(e,t){return ee("random")()*(t-e)+e}function Je(e,t,n,l,c=!1){return n=typeof n=="undefined"?He.MIN_NUMBER:n,l=typeof l=="undefined"?He.MAX_NUMBER:l,e=typeof e=="undefined"?n:e,t=typeof t=="undefined"?l:t,t<e&&(t+=e),c?ot(e,t):Ue(e,t)}function Dt(e){switch(e){case"seconds":return Je(0,60)*60;case"minutes":return Je(15,50)*612;case"hours":return Je(12,72)*36123;case"days":return Je(7,30)*86412345;case"weeks":return Je(4,52)*604812345;case"months":return Je(2,13)*2592012345;case"years":return Je(1,20)*31104012345;default:break}}function Dn(e){if(e)return Dt(e);let t=ee("minDateTime"),n=ee("maxDateTime");typeof t=="string"&&(t=new Date(t)),typeof n=="string"&&(n=new Date(n));let l=new Date().getTime();return typeof t=="number"&&(t=new Date(l+t)),typeof n=="number"&&(n=new Date(l+n)),new Date(ot(t.getTime(),n.getTime()))}function di(e,t,n){if(t=decodeURIComponent(t),n&&n[t])return ce(n[t]);let l=t.replace("#/","/").split("/"),c=e.$ref&&n&&n[e.$ref]||e;for(!c&&!l[0]&&(l[0]=e.$ref.split("#/")[0]),n&&t.includes("#/")&&n[l[0]]&&(c=n[l.shift()]),l[0]||l.shift();c&&l.length>0;){let f=l.shift();if(!c[f])throw new Error(`Prop not found: ${f} (${t})`);c=c[f]}return c}function Ut(e){return typeof e=="string"&&Wi.test(e)}function Ge(e){return["number","boolean"].includes(typeof e)}function Ke(e,...t){return t.filter(n=>typeof e[n]!="undefined").length>0}function fi(e){if(e.includes(" "))return new Date(e).toISOString().substr(0,10);let[t,n,l]=e.split("T")[0].split("-");return n=`0${Math.max(1,Math.min(12,n))}`.slice(-2),l=`0${Math.max(1,Math.min(31,l))}`.slice(-2),`${t}-${n}-${l}`}function ms(e){if(e.includes(" "))return new Date(e).toISOString().substr(0,10);let[t,n]=e.split("T"),[l,c,f]=t.split("-"),[d,T,L]=n.substr(0,8).split(":");return c=`0${Math.max(1,Math.min(12,c))}`.slice(-2),f=`0${Math.max(1,Math.min(31,f))}`.slice(-2),d=`0${Math.max(1,Math.min(23,d))}`.slice(-2),T=`0${Math.max(1,Math.min(59,T))}`.slice(-2),L=`0${Math.max(1,Math.min(59,L))}`.slice(-2),`${l}-${c}-${f}T${d}:${T}:${L}.000Z`}function ys(e,t,n){let l={};switch(e||t.type){case"integer":case"number":if(typeof t.minimum!="undefined"&&(l.minimum=t.minimum),typeof t.maximum!="undefined"&&(l.maximum=t.maximum),t.enum){let f=Math.max(l.minimum||0,0),d=Math.min(l.maximum||1/0,1/0);t.exclusiveMinimum&&f===t.minimum&&(f+=t.multipleOf||1),t.exclusiveMaximum&&d===t.maximum&&(d-=t.multipleOf||1),(f||d!==1/0)&&(t.enum=t.enum.filter(T=>T>=f&&T<=d))}break;case"string":{l.minLength=ee("minLength")||0,l.maxLength=ee("maxLength")||Number.MAX_SAFE_INTEGER,typeof t.minLength!="undefined"&&(l.minLength=Math.max(l.minLength,t.minLength)),typeof t.maxLength!="undefined"&&(l.maxLength=Math.min(l.maxLength,t.maxLength));break}default:break}let c=n(l);if(c==null)return null;switch(e||t.type){case"number":c=Ut(c)?parseFloat(c):c;break;case"integer":c=Ut(c)?parseInt(c,10):c;break;case"boolean":c=!!c;break;case"string":{if(Ge(c))return c;c=String(c);let f=Math.max(l.minLength||0,0),d=Math.min(l.maxLength||1/0,1/0),T,L=0;for(;c.length<f;)if(T=c,t.pattern?c+=Q.randexp(t.pattern):c+=`${Q.pick([" ","/","_","-","+","=","@","^"])}${c}`,c===T){if(L+=1,L===3)break}else L=0;switch(c.length>d&&(c=c.substr(0,d)),t.format){case"date-time":case"datetime":c=new Date(ms(c)).toISOString().replace(/([0-9])0+Z$/,"$1Z");break;case"full-date":case"date":c=new Date(fi(c)).toISOString().substr(0,10);break;case"time":c=new Date(`1969-01-01 ${c}`).toISOString().substr(11);break;default:break}break}default:break}return c}function dt(e,t){return Object.keys(t).forEach(n=>{typeof t[n]!="object"||t[n]===null?e[n]=t[n]:Array.isArray(t[n])?(e[n]=e[n]||[],t[n].forEach((l,c)=>{e.type==="array"&&t.type==="array"?e[n][c]=dt(e[n][c]||{},l,!0):Array.isArray(e[n])&&e[n].indexOf(l)===-1&&e[n].push(l)})):typeof e[n]!="object"||e[n]===null||Array.isArray(e[n])?e[n]=dt({},t[n]):e[n]=dt(e[n],t[n])}),e}function ce(e,t=new Map){if(!e||typeof e!="object")return e;if(t.has(e))return t.get(e);if(Array.isArray(e)){let l=[];return t.set(e,l),l.push(...e.map(c=>ce(c,t))),l}let n={};return t.set(e,n),Object.keys(e).reduce((l,c)=>(l[c]=ce(e[c],t),l),n)}function gs(e){let t=JSON.stringify(e),n=JSON.stringify(e,null,2);return t.length>400?`${n.substr(0,400)}...`:n}function hi(){return Q.pick([!1,!0,null,-1,NaN,Math.PI,1/0,void 0,[],{},Math.random(),Math.random().toString(36).substr(2)])}function ws(e,t){if(e.enum)return e.enum.includes(t);if(e.const)return e.const===t}function bs(e,t){let n=dt({},t);if(typeof e.minimum!="undefined"&&(n.maximum=e.minimum,n.exclusiveMaximum=!0),typeof e.maximum!="undefined"&&(n.minimum=e.maximum>n.maximum?0:e.maximum,n.exclusiveMinimum=!0),typeof e.minLength!="undefined"&&(n.maxLength=e.minLength),typeof e.maxLength!="undefined"&&(n.minLength=e.maxLength>n.maxLength?0:e.maxLength),e.type)n.type=Q.pick(He.SCALAR_TYPES.filter(l=>(Array.isArray(e.type)?e.type:[e.type]).every(f=>l==="number"||l==="integer"?f!=="number"&&f!=="integer":l!==f)));else if(e.enum){let l;do l=hi();while(e.enum.indexOf(l)!==-1);n.enum=[l]}return e.required&&n.properties&&e.required.forEach(l=>{delete n.properties[l]}),n}function Un(e,t){let n=t.minimum!==void 0,l=t.maximum!==void 0;return(n||l)&&(!n||e>=t.minimum)&&(!l||e<=t.maximum)}function Ss(e,t){return!t.every(n=>Un(e,n))}function Ts(e,t){return t.reduce((l,c)=>l+(Un(e,c)?1:0),0)===1}function Os(e){return["enum","const","default","examples","required","definitions","items","properties"].includes(e)}function As(e,t){return Object.keys(e).filter(n=>!t.includes(n)).reduce((n,l)=>(Array.isArray(e[l])?n[l]=e[l].slice():n[l]=e[l]instanceof Object?dt({},e[l]):e[l],n),{})}function mi(e,t){return Array.isArray(e)?e.map(n=>mi(n,t)):(typeof e=="string"&&(e=e.replace(/#\{([\w.-]+)\}/g,(n,l)=>t[l])),e)}function $n(e){return Object.prototype.toString.call(e)==="[object Object]"&&!Object.keys(e).length}function yi(e,t){t=t.items||t;let n=ee("alwaysFakeOptionals"),l=Array.isArray(t.required)&&t.required.includes(e)||n,c=typeof t.thunk=="function"||t.additionalProperties&&typeof t.additionalProperties.thunk=="function";return!l&&!c}function Fn(e,t,n=!1){if(!e||typeof e!="object")return e;if(Array.isArray(e))return e.map(l=>Fn(l,t,!0)).filter(l=>typeof l!="undefined");if(Object.keys(e).forEach(l=>{if($n(e[l]))yi(l,t)&&delete e[l];else{let c=t;t&&t.properties&&t.properties[l]&&(c=t.properties[l]);let f=Fn(e[l],c);$n(f)||(e[l]=f)}typeof e[l]=="undefined"&&delete e[l]}),!(!Object.keys(e).length&&n))return e}function Es(e){return(t,n,l,c)=>{let f=t,d=[];typeof t=="object"&&(f=Object.keys(t)[0],Array.isArray(t[f])?d=t[f]:d.push(t[f]));let T=f.split("."),L=e();for(;T.length>1;)L=L[T.shift()];return t=typeof L=="object"?L[T[0]]:L,typeof t=="function"&&(t=t.apply(L,d.map(S=>de.template(S,c)))),Object.prototype.toString.call(t)==="[object Object]"&&Object.keys(t).forEach(S=>{if(typeof t[S]=="function")throw new Error(`Cannot resolve value for '${l}: ${f}', given: ${t}`)}),t}}function vs(e,t){if(typeof e=="undefined")return ht.list();if(typeof e=="string")if(typeof t=="function")ht.register(e,t);else if(t===null||t===!1)ht.unregister(e);else return ht.get(e);else ht.registerMany(e)}function _s(e,t,n){return Object.keys(e).filter(l=>{let c=Ji.indexOf(t)>-1;return n.indexOf(l)>-1&&!c}).length>0}function Rs(e,t){let n=Object.keys(At);for(let l=0;l<n.length;l+=1){let c=n[l],f=t[t.length-1];if(_s(e,f,At[c]))return c}}function Ps(){return ee("random")()>.5}function Is(){return null}function Ns(e,t,n,l,c,f){let d=[],T=[];function L($){let v=JSON.stringify($.value);return T.indexOf(v)===-1?(T.push(v),d.push($),!0):!1}t.forEach(L);let S=100;for(;d.length!==t.length&&(L(f(n.items||l,e,c))||(S-=1),!!S););return d}function xs(e,t,n,l){let c=[];if(!(e.items||e.additionalItems)){if(de.hasProperties(e,"minItems","maxItems","uniqueItems")&&(e.minItems!==0||e.maxItems!==0))throw new jt(`missing items for ${de.short(e)}`,t);return c}if(Array.isArray(e.items))return e.items.map((W,ae)=>{let X=t.concat(["items",ae]);return l(W,X,n)});let f=e.minItems,d=e.maxItems,T=ee("minItems"),L=ee("maxItems");T&&(f=typeof f=="undefined"?T:Math.min(T,f)),L&&(d=typeof d=="undefined"?L:Math.min(L,d),d&&d>L&&(d=L),f&&f>L&&(f=d));let S=ee("alwaysFakeOptionals")===!0?1:ee("optionalsProbability"),$=ee("alwaysFakeOptionals")||ee("fixedProbabilities")||!1,v=Q.number(f,d,1,5);S!==null&&(v=Math.max($?Math.round((d||v)*S):Math.abs(Q.number(f,d)*S),f||0));let q=typeof e.additionalItems=="object"?e.additionalItems:{};for(let W=c.length;W<v;W+=1){let ae=t.concat(["items",W]),X=l(e.items||q,ae,n);c.push(X)}if(e.contains&&v>0){let W=Q.number(0,v-1);c[W]=l(e.contains,t.concat(["items",W]),n)}return e.uniqueItems?Ns(t.concat(["items"]),c,e,q,n,l):c}function ks(e){let t=typeof e.minimum=="undefined"||e.minimum===-Number.MAX_VALUE?He.MIN_INTEGER:e.minimum,n=typeof e.maximum=="undefined"||e.maximum===Number.MAX_VALUE?He.MAX_INTEGER:e.maximum,l=e.multipleOf,c=l&&String(l).match(/e-(\d)|\.(\d+)$/);if(c){let f=(Math.random()*Q.number(0,10)+1)*l,d=c[1]||c[2].length,T=parseFloat(f.toFixed(d)),L=Q.number(t,n-1);return String(T).includes(".")?L+T:(L+T).toExponential()}if(l&&(n=Math.floor(n/l)*l,t=Math.ceil(t/l)*l),e.exclusiveMinimum&&t===e.minimum&&(t+=l||1),e.exclusiveMaximum&&n===e.maximum&&(n-=l||1),t>n)return NaN;if(l){let f=Q.number(Math.floor(t/l),Math.floor(n/l))*l;for(;f<t;)f+=l;return f}return Q.number(t,n,void 0,void 0,e.type!=="integer")}function Ms(e){return Math.floor(ei({...e}))}function Cs(e){return Q.shuffle(nr).slice(0,e)}function Ls(e,t,n,l){let c={},f=e.properties||{},d=e.patternProperties||{},T=typeof e.required=="boolean"?[]:(e.required||[]).slice(),L=e.additionalProperties!==!1,S=Object.keys(f),$=Object.keys(d),v=S.concat($).reduce((j,h)=>(T.indexOf(h)===-1&&j.push(h),j),[]),q=T.concat(v),W=L&&e.additionalProperties===!0?Wt:e.additionalProperties;if(!L&&S.length===0&&$.length===0&&de.hasProperties(e,"minProperties","maxProperties","dependencies","required"))return null;if(ee("requiredOnly")===!0)return T.forEach(j=>{f[j]&&(c[j]=f[j])}),l(c,t.concat(["properties"]),n,e);let ae=ee("alwaysFakeOptionals")===!0?1:ee("optionalsProbability"),X=ee("alwaysFakeOptionals")||ee("fixedProbabilities")||!1,te=ee("ignoreProperties")||[],he=ee("reuseProperties"),ye=ee("fillProperties"),F=e.maxProperties||q.length+(L?Q.number(1,5):0),g=Math.max(e.minProperties||0,T.length),b=Math.max(0,q.length-g);q.length===1&&!T.length&&(g=Math.max(Q.number(ye?1:0,F),g)),ae!==null&&(X===!0?b=Math.round(g-T.length+ae*(q.length-g)):b=Q.number(g-T.length,ae*(q.length-g)));let R=Q.shuffle(v).slice(0,b),I=v.filter(j=>R.indexOf(j)!==-1),M=ae!==null||T.length===F?F:Q.number(0,F),_=T.concat(Q.shuffle(I).slice(0,M)).slice(0,F),N=[],k=[];if(e.dependencies&&(Object.keys(e.dependencies).forEach(j=>{let h=e.dependencies[j];if(_.indexOf(j)!==-1)if(Array.isArray(h))h.forEach(x=>{_.indexOf(x)===-1&&_.push(x)});else if(Array.isArray(h.oneOf||h.anyOf)){let x=h.oneOf||h.anyOf;k.push({prop:j,values:x})}else N.push(h)}),N.length))return delete e.dependencies,l({allOf:N.concat(e)},t.concat(["properties"]),n,e);let V=[],J=[];_.forEach(j=>{if(f[j]&&["{}","true"].includes(JSON.stringify(f[j].not)))return;for(let x=0;x<te.length;x+=1)if(te[x]instanceof RegExp&&te[x].test(j)||typeof te[x]=="string"&&te[x]===j||typeof te[x]=="function"&&te[x](f[j],j)){V.push(j);return}W===!1&&T.indexOf(j)!==-1&&(c[j]=f[j]),f[j]&&(c[j]=f[j]);let h;if($.forEach(x=>{j.match(new RegExp(x))&&(h=!0,c[j]?de.merge(c[j],d[x]):c[Q.randexp(j)]=d[x])}),!h){let x=d[j]||W;x&&W!==!1?c[d[j]?Q.randexp(j):j]=f[j]||x:J.push(j)}});let Z=Object.keys(c).length+(ye?0:V.length),Te=j=>Q.randexp(`_?[_a-f\\d]{1,3}${j?"\\$?":""}`);function Oe(j){let h;do{if(!j.length)break;h=j.shift()}while(c[h]);return h}let ve=g;if(L&&!T.length&&(ve=Math.max(ae===null||W?Q.number(ye?1:0,F):0,g)),!I.length&&!b&&L&&X===!0&&ye){let j=Q.number(0,F);for(let h=0;h<j;h+=1)c[Yt(1)+Te(j[h])]=W||Wt}for(;ye&&!(!($.length||L)||Z>=ve);){if(L)if(he&&S.length-Z>ve){let j=0,h;do{if(j+=1,j>1e3)break;h=Oe(T)||Q.pick(S)}while(typeof c[h]!="undefined");typeof c[h]=="undefined"&&(c[h]=f[h],Z+=1)}else if($.length&&!W){let j=Q.pick($),h=Q.randexp(j);c[h]||(c[h]=d[j],Z+=1)}else{let j=Oe(T)||Yt(1)+Te();c[j]||(c[j]=W||Wt,Z+=1)}for(let j=0;Z<g&&j<$.length;j+=1){let h=$[j],x=Q.randexp(h);c[x]||(c[x]=d[h],Z+=1)}}if(T.length===0&&(!L||ae===!1)){let j=Q.number(g,F);for(;Z<j;){let h=Oe(S);h&&(c[h]=f[h]),Z+=1}}let Pe=c;if(ee("sortProperties")!==null){let j=Object.keys(f);Pe=Object.keys(c).sort((x,G)=>ee("sortProperties")?x.localeCompare(G):j.indexOf(x)-j.indexOf(G)).reduce((x,G)=>(x[G]=c[G],x),{})}let xe=l(Pe,t.concat(["properties"]),n,e);return k.forEach(j=>{for(let h of j.values)if(de.hasValue(h.properties[j.prop],xe.value[j.prop])){Object.keys(h.properties).forEach(x=>{x!==j.prop&&de.merge(xe.value,l(h.properties,t.concat(["properties"]),n,e).value)});break}}),xe}function gi(){let e=Q.number(1,5);return Yt(e).join(" ")}function Ds(e=0,t=140){let n=Math.max(0,e),l=Q.number(n,t),c=gi();for(;c.length<n;)c+=gi();return c.length>l&&(c=c.substr(0,l)),c}function Us(){return[0,0,0,0].map(()=>Q.number(0,255)).join(".")}function $s(){return Q.date().toISOString()}function Fs(){return Vt().slice(0,10)}function js(){return Vt().slice(11)}function Ys(e){return Q.randexp(je[e]).replace(lr,(t,n)=>Q.randexp(je[n]))}function Ws(e,t){let n=Zn(e.format);if(typeof n=="function")return n(e);switch(e.format){case"date-time":case"datetime":return Vt();case"date":return sr();case"time":return or();case"ipv4":return rr();case"regex":return".+?";case"email":case"hostname":case"ipv6":case"uri":case"uri-reference":case"iri":case"iri-reference":case"idn-email":case"idn-hostname":case"json-pointer":case"slug":case"uri-template":case"uuid":case"duration":return cr(e.format);default:if(typeof n=="undefined"){if(ee("failOnInvalidFormat"))throw new Error(`unknown registry key ${de.short(e.format)}`);return t()}throw new Error(`unsupported format '${e.format}'`)}}function Vs(e){return de.typecast("string",e,n=>e.format?Ws(e,()=>ti(n.minLength,n.maxLength)):e.pattern?Q.randexp(e.pattern):ti(n.minLength,n.maxLength))}function Bs({$comment:e,title:t,description:n}){return Object.entries({comment:e,title:t,description:n}).filter(([,l])=>l).reduce((l,[c,f])=>(l[c]=f,l),{})}function ft(e,t,n,l){if(e=n(e,null,t),e&&(e.oneOf||e.anyOf||e.allOf)&&(e=n(e,null,t)),!e)throw new Error(`Cannot traverse at '${t.join(".")}', given '${JSON.stringify(l)}'`);let c={...Bs(e),schemaPath:t};if(t[t.length-1]!=="properties"){if(ee("useExamplesValue")&&Array.isArray(e.examples)){let S=e.examples.concat("default"in e?[e.default]:[]);return{value:de.typecast(null,e,()=>Q.pick(S)),context:c}}if(ee("useExamplesValue")&&typeof e.example!="undefined")return{value:de.typecast(null,e,()=>e.example),context:c};if(ee("useDefaultValue")&&"default"in e&&(e.default!==""||!ee("replaceEmptyByRandomValue")))return{value:e.default,context:c};if("template"in e)return{value:de.template(e.template,l),context:c};if("const"in e)return{value:e.const,context:c}}if(e.not&&typeof e.not=="object"&&(e=de.notValue(e.not,de.omitProps(e,["not"])),e.type&&e.type==="object")){let{value:S,context:$}=ft(e,t.concat(["not"]),n,l);return{value:de.clean(S,e,!1),context:{...c,items:$}}}if(typeof e.thunk=="function"){let{value:S,context:$}=ft(e.thunk(l),t,n);return{value:S,context:{...c,items:$}}}if(e.jsonPath)return{value:e,context:c};let f=e.type;if(Array.isArray(f)?f=Q.pick(f):typeof f=="undefined"&&(f=Gi(e,t)||f,f&&(e.type=f)),typeof e.generate=="function"){let S=de.typecast(null,e,()=>e.generate(l,t)),$=S===null?"null":typeof S;if($===f||$==="number"&&f==="integer"||Array.isArray(S)&&f==="array")return{value:S,context:c}}if(typeof e.pattern=="string")return{value:de.typecast("string",e,()=>Q.randexp(e.pattern)),context:c};if(Array.isArray(e.enum))return{value:de.typecast(null,e,()=>Q.pick(e.enum)),context:c};if(typeof f=="string")if(Et[f])try{let S=Et[f](e,t,n,ft);return f==="array"?{value:S.map(({value:$})=>$),context:{...c,items:S.map(Array.isArray(e.items)?({context:$})=>$:({context:$})=>({...$,schemaPath:$.schemaPath.slice(0,-1)}))}}:f==="object"?S!==null?{value:S.value,context:{...c,items:S.context}}:{value:{},context:c}:{value:S,context:c}}catch(S){throw typeof S.path=="undefined"?new jt(S.stack,t):S}else{if(ee("failOnInvalidTypes"))throw new jt(`unknown primitive ${de.short(f)}`,t.concat(["type"]));{let S=ee("defaultInvalidTypeProduct");return typeof S=="string"&&Et[S]?{value:Et[S](e,t,n,ft),context:c}:{value:S,context:c}}}let d={},T={...c};Array.isArray(e)&&(d=[]);let L=ee("pruneProperties")||[];return Object.keys(e).forEach(S=>{if(!L.includes(S)&&e[S]!==null)if(typeof e[S]=="object"&&S!=="definitions"){let{value:$,context:v}=ft(e[S],t.concat([S]),n,d);d[S]=de.clean($,e[S],!1),T[S]=v,d[S]===null&&ee("omitNulls")&&(delete d[S],delete T[S])}else d[S]=e[S]}),{value:d,context:T}}function qs(e){return Array.isArray(e)?Q.pick(e):e}function Js(e,t){if(!Array.isArray(e))return e;let n=t?e.pop():e.shift();return t?e.unshift(n):e.push(n),n}function jn(e,t,n,l){if(!e||typeof e!="object")return e;if(n||(n={}),t||(t=e),Array.isArray(e))return e.map(c=>jn(c,t,n,l));if(e.jsonPath){let{JSONPath:c}=Kn(),f=typeof e.jsonPath!="object"?{path:e.jsonPath}:e.jsonPath;f.group=e.group||f.group||l,f.cycle=e.cycle||f.cycle||!1,f.reverse=e.reverse||f.reverse||!1,f.count=e.count||f.count||1;let d=`${f.group}__${f.path}`;return n[d]||(f.count>1?n[d]=c(f.path,t).slice(0,f.count):n[d]=c(f.path,t)),f.cycle||f.reverse?Js(n[d],f.reverse):qs(n[d])}return Object.keys(e).forEach(c=>{e[c]=jn(e[c],t,n,c)}),e}function Gs(e,t,n,l){if(Object.prototype.toString.call(t)!=="[object Object]")throw new Error(`Invalid input, expecting object but given ${typeof t}`);let c=ee("refDepthMin")||0,f=ee("refDepthMax")||3;try{let{resolveSchema:d}=hr({refs:e,schema:t,container:n,synchronous:l,refDepthMin:c,refDepthMax:f}),T=dr(de.clone(t),[],d);return ee("resolveJsonPath")?{value:jn(T.value),context:T.context}:T}catch(d){throw d.path?new Error(`${d.message} in /${d.path.join("/")}`):d}}function Ks(e){return e.value}function Hs(e,t){return t.reduce((n,l)=>l in n?n[l]:{},e)}function Yn(e,t,n,l=n){let{title:c,description:f,comment:d}=Hs(e,t),T=[];ee("renderTitle")&&c&&T.push(` ${c}`,""),ee("renderDescription")&&f&&T.push(` ${f}`),ee("renderComment")&&d&&T.push(` ${d}`),n.commentBefore=T.join(` `),l instanceof mr?l.items.forEach(L=>{Yn(e,[...t,"items",L.key.value],L.key,L.value)}):l instanceof yr&&l.items.forEach((L,S)=>{Yn(e,[...t,"items",S],L)})}function zs({value:e,context:t}){let n=vt.createNode(e);Yn(t,[],n);let l=new vt.Document;return l.contents=n,l.toString()}function wi(){Xe.define("autoIncrement",function(t,n){if(!this.offset){let l=n.minimum||1,c=l+He.MAX_NUMBER,f=t.initialOffset||n.initialOffset;this.offset=f||Q.number(l,c)}return t?this.offset++:n}),Xe.define("sequentialDate",function(t,n){if(this.now||(this.now=Q.date()),t){if(n=this.now.toISOString(),t=t===!0?"days":t,["seconds","minutes","hours","days","weeks","months","years"].indexOf(t)===-1)throw new Error(`Unsupported increment by ${de.short(t)}`);this.now.setTime(this.now.getTime()+Q.date(t))}return n})}function bi(e,t){let n={};Array.isArray(e)?e.forEach(c=>{n[c.$id||c.id]=c}):n=e||{};function l(c){if(!c||typeof c!="object")return;if(Array.isArray(c))return c.forEach(l);let f=c.$id||c.id;typeof f=="string"&&!n[f]&&(n[f]=c),Object.keys(c).forEach(d=>{l(c[d])})}return l(e),l(t),n}var Si,Wn,Ti,Vn,Oi,Ai,$e,Ei,Bn,U,qn,vi,_i,Ri,Pi,Ii,Tt,$t,Jn,Ni,xi,Gn,Kn,ki,Mi,Hn,ue,zn,Ci,Li,Ot,ee,Xn,Qn,Di,Ui,$i,Fi,ji,Yi,He,Ft,Q,Wi,de,Vi,Bi,ht,Zn,qi,jt,At,Ji,Gi,Ki,Hi,zi,Xi,Qi,Zi,er,ei,tr,nr,Yt,Wt,ir,ti,rr,Vt,sr,or,ni,Bt,ar,je,lr,cr,pr,ur,Et,dr,fr,hr,ii,ri,ke,Xs,Qs,Zs,eo,to,no,io,ro,so,oo,ao,lo,mr,yr,vt,Xe,Se,gr,wr,co=E({"src/shared.js"(){Si=Object.create,Wn=Object.defineProperty,Ti=Object.getOwnPropertyDescriptor,Vn=Object.getOwnPropertyNames,Oi=Object.getPrototypeOf,Ai=Object.prototype.hasOwnProperty,$e=(e,t)=>function(){return t||(0,e[Vn(e)[0]])((t={exports:{}}).exports,t),t.exports},Ei=(e,t,n,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of Vn(t))!Ai.call(e,c)&&c!==n&&Wn(e,c,{get:()=>t[c],enumerable:!(l=Ti(t,c))||l.enumerable});return e},Bn=(e,t,n)=>(n=e!=null?Si(Oi(e)):{},Ei(t||!e||!e.__esModule?Wn(n,"default",{value:e,enumerable:!0}):n,e)),U=$e({"node_modules/ret/lib/types.js"(e,t){t.exports={ROOT:0,GROUP:1,POSITION:2,SET:3,RANGE:4,REPETITION:5,REFERENCE:6,CHAR:7}}}),qn=$e({"node_modules/ret/lib/sets.js"(e){var t=U(),n=()=>[{type:t.RANGE,from:48,to:57}],l=()=>[{type:t.CHAR,value:95},{type:t.RANGE,from:97,to:122},{type:t.RANGE,from:65,to:90}].concat(n()),c=()=>[{type:t.CHAR,value:9},{type:t.CHAR,value:10},{type:t.CHAR,value:11},{type:t.CHAR,value:12},{type:t.CHAR,value:13},{type:t.CHAR,value:32},{type:t.CHAR,value:160},{type:t.CHAR,value:5760},{type:t.RANGE,from:8192,to:8202},{type:t.CHAR,value:8232},{type:t.CHAR,value:8233},{type:t.CHAR,value:8239},{type:t.CHAR,value:8287},{type:t.CHAR,value:12288},{type:t.CHAR,value:65279}],f=()=>[{type:t.CHAR,value:10},{type:t.CHAR,value:13},{type:t.CHAR,value:8232},{type:t.CHAR,value:8233}];e.words=()=>({type:t.SET,set:l(),not:!1}),e.notWords=()=>({type:t.SET,set:l(),not:!0}),e.ints=()=>({type:t.SET,set:n(),not:!1}),e.notInts=()=>({type:t.SET,set:n(),not:!0}),e.whitespace=()=>({type:t.SET,set:c(),not:!1}),e.notWhitespace=()=>({type:t.SET,set:c(),not:!0}),e.anyChar=()=>({type:t.SET,set:f(),not:!0})}}),vi=$e({"node_modules/ret/lib/util.js"(e){var t=U(),n=qn(),l="@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?",c={0:0,t:9,n:10,v:11,f:12,r:13};e.strToChars=function(f){var d=/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|(0?[0-7]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g;return f=f.replace(d,function(T,L,S,$,v,q,W,ae){if(S)return T;var X=L?8:$?parseInt($,16):v?parseInt(v,16):q?parseInt(q,8):W?l.indexOf(W):c[ae],te=String.fromCharCode(X);return/[[\]{}^$.|?*+()]/.test(te)&&(te="\\"+te),te}),f},e.tokenizeClass=(f,d)=>{for(var T=[],L=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(?:\\)?([^\]]))|(\])|(?:\\)?([^])/g,S,$;(S=L.exec(f))!=null;)if(S[1])T.push(n.words());else if(S[2])T.push(n.ints());else if(S[3])T.push(n.whitespace());else if(S[4])T.push(n.notWords());else if(S[5])T.push(n.notInts());else if(S[6])T.push(n.notWhitespace());else if(S[7])T.push({type:t.RANGE,from:(S[8]||S[9]).charCodeAt(0),to:S[10].charCodeAt(0)});else if($=S[12])T.push({type:t.CHAR,value:$.charCodeAt(0)});else return[T,L.lastIndex];e.error(d,"Unterminated character class")},e.error=(f,d)=>{throw new SyntaxError("Invalid regular expression: /"+f+"/: "+d)}}}),_i=$e({"node_modules/ret/lib/positions.js"(e){var t=U();e.wordBoundary=()=>({type:t.POSITION,value:"b"}),e.nonWordBoundary=()=>({type:t.POSITION,value:"B"}),e.begin=()=>({type:t.POSITION,value:"^"}),e.end=()=>({type:t.POSITION,value:"$"})}}),Ri=$e({"node_modules/ret/lib/index.js"(e,t){var n=vi(),l=U(),c=qn(),f=_i();t.exports=d=>{var T=0,L,S,$={type:l.ROOT,stack:[]},v=$,q=$.stack,W=[],ae=I=>{n.error(d,`Nothing to repeat at column ${I-1}`)},X=n.strToChars(d);for(L=X.length;T<L;)switch(S=X[T++],S){case"\\":switch(S=X[T++],S){case"b":q.push(f.wordBoundary());break;case"B":q.push(f.nonWordBoundary());break;case"w":q.push(c.words());break;case"W":q.push(c.notWords());break;case"d":q.push(c.ints());break;case"D":q.push(c.notInts());break;case"s":q.push(c.whitespace());break;case"S":q.push(c.notWhitespace());break;default:/\d/.test(S)?q.push({type:l.REFERENCE,value:parseInt(S,10)}):q.push({type:l.CHAR,value:S.charCodeAt(0)})}break;case"^":q.push(f.begin());break;case"$":q.push(f.end());break;case"[":var te;X[T]==="^"?(te=!0,T++):te=!1;var he=n.tokenizeClass(X.slice(T),d);T+=he[1],q.push({type:l.SET,set:he[0],not:te});break;case".":q.push(c.anyChar());break;case"(":var ye={type:l.GROUP,stack:[],remember:!0};S=X[T],S==="?"&&(S=X[T+1],T+=2,S==="="?ye.followedBy=!0:S==="!"?ye.notFollowedBy=!0:S!==":"&&n.error(d,`Invalid group, character '${S}' after '?' at column ${T-1}`),ye.remember=!1),q.push(ye),W.push(v),v=ye,q=ye.stack;break;case")":W.length===0&&n.error(d,`Unmatched ) at column ${T-1}`),v=W.pop(),q=v.options?v.options[v.options.length-1]:v.stack;break;case"|":v.options||(v.options=[v.stack],delete v.stack);var F=[];v.options.push(F),q=F;break;case"{":var g=/^(\d+)(,(\d+)?)?\}/.exec(X.slice(T)),b,R;g!==null?(q.length===0&&ae(T),b=parseInt(g[1],10),R=g[2]?g[3]?parseInt(g[3],10):1/0:b,T+=g[0].length,q.push({type:l.REPETITION,min:b,max:R,value:q.pop()})):q.push({type:l.CHAR,value:123});break;case"?":q.length===0&&ae(T),q.push({type:l.REPETITION,min:0,max:1,value:q.pop()});break;case"+":q.length===0&&ae(T),q.push({type:l.REPETITION,min:1,max:1/0,value:q.pop()});break;case"*":q.length===0&&ae(T),q.push({type:l.REPETITION,min:0,max:1/0,value:q.pop()});break;default:q.push({type:l.CHAR,value:S.charCodeAt(0)})}return W.length!==0&&n.error(d,"Unterminated group"),$},t.exports.types=l}}),Pi=$e({"node_modules/drange/lib/index.js"(e,t){"use strict";var n=class gt{constructor(f,d){this.low=f,this.high=d,this.length=1+d-f}overlaps(f){return!(this.high<f.low||this.low>f.high)}touches(f){return!(this.high+1<f.low||this.low-1>f.high)}add(f){return new gt(Math.min(this.low,f.low),Math.max(this.high,f.high))}subtract(f){return f.low<=this.low&&f.high>=this.high?[]:f.low>this.low&&f.high<this.high?[new gt(this.low,f.low-1),new gt(f.high+1,this.high)]:f.low<=this.low?[new gt(f.high+1,this.high)]:[new gt(this.low,f.low-1)]}toString(){return this.low==this.high?this.low.toString():this.low+"-"+this.high}},l=class Ct{constructor(f,d){this.ranges=[],this.length=0,f!=null&&this.add(f,d)}_update_length(){this.length=this.ranges.reduce((f,d)=>f+d.length,0)}add(f,d){var T=L=>{for(var S=0;S<this.ranges.length&&!L.touches(this.ranges[S]);)S++;for(var $=this.ranges.slice(0,S);S<this.ranges.length&&L.touches(this.ranges[S]);)L=L.add(this.ranges[S]),S++;$.push(L),this.ranges=$.concat(this.ranges.slice(S)),this._update_length()};return f instanceof Ct?f.ranges.forEach(T):(d==null&&(d=f),T(new n(f,d))),this}subtract(f,d){var T=L=>{for(var S=0;S<this.ranges.length&&!L.overlaps(this.ranges[S]);)S++;for(var $=this.ranges.slice(0,S);S<this.ranges.length&&L.overlaps(this.ranges[S]);)$=$.concat(this.ranges[S].subtract(L)),S++;this.ranges=$.concat(this.ranges.slice(S)),this._update_length()};return f instanceof Ct?f.ranges.forEach(T):(d==null&&(d=f),T(new n(f,d))),this}intersect(f,d){var T=[],L=S=>{for(var $=0;$<this.ranges.length&&!S.overlaps(this.ranges[$]);)$++;for(;$<this.ranges.length&&S.overlaps(this.ranges[$]);){var v=Math.max(this.ranges[$].low,S.low),q=Math.min(this.ranges[$].high,S.high);T.push(new n(v,q)),$++}};return f instanceof Ct?f.ranges.forEach(L):(d==null&&(d=f),L(new n(f,d))),this.ranges=T,this._update_length(),this}index(f){for(var d=0;d<this.ranges.length&&this.ranges[d].length<=f;)f-=this.ranges[d].length,d++;return this.ranges[d].low+f}toString(){return"[ "+this.ranges.join(", ")+" ]"}clone(){return new Ct(this)}numbers(){return this.ranges.reduce((f,d)=>{for(var T=d.low;T<=d.high;)f.push(T),T++;return f},[])}subranges(){return this.ranges.map(f=>({low:f.low,high:f.high,length:1+f.high-f.low}))}};t.exports=l}}),Ii=$e({"node_modules/randexp/lib/randexp.js"(e,t){var n=Ri(),l=Pi(),c=n.types;t.exports=class Lt{constructor(d,T){if(this._setDefaults(d),d instanceof RegExp)this.ignoreCase=d.ignoreCase,this.multiline=d.multiline,d=d.source;else if(typeof d=="string")this.ignoreCase=T&&T.indexOf("i")!==-1,this.multiline=T&&T.indexOf("m")!==-1;else throw new Error("Expected a regexp or string");this.tokens=n(d)}_setDefaults(d){this.max=d.max!=null?d.max:Lt.prototype.max!=null?Lt.prototype.max:100,this.defaultRange=d.defaultRange?d.defaultRange:this.defaultRange.clone(),d.randInt&&(this.randInt=d.randInt)}gen(){return this._gen(this.tokens,[])}_gen(d,T){var L,S,$,v,q;switch(d.type){case c.ROOT:case c.GROUP:if(d.followedBy||d.notFollowedBy)return"";for(d.remember&&d.groupNumber===void 0&&(d.groupNumber=T.push(null)-1),L=d.options?this._randSelect(d.options):d.stack,S="",v=0,q=L.length;v<q;v++)S+=this._gen(L[v],T);return d.remember&&(T[d.groupNumber]=S),S;case c.POSITION:return"";case c.SET:var W=this._expand(d);return W.length?String.fromCharCode(this._randSelect(W)):"";case c.REPETITION:for($=this.randInt(d.min,d.max===1/0?d.min+this.max:d.max),S="",v=0;v<$;v++)S+=this._gen(d.value,T);return S;case c.REFERENCE:return T[d.value-1]||"";case c.CHAR:var ae=this.ignoreCase&&this._randBool()?this._toOtherCase(d.value):d.value;return String.fromCharCode(ae)}}_toOtherCase(d){return d+(97<=d&&d<=122?-32:65<=d&&d<=90?32:0)}_randBool(){return!this.randInt(0,1)}_randSelect(d){return d instanceof l?d.index(this.randInt(0,d.length-1)):d[this.randInt(0,d.length-1)]}_expand(d){if(d.type===n.types.CHAR)return new l(d.value);if(d.type===n.types.RANGE)return new l(d.from,d.to);{let T=new l;for(let L=0;L<d.set.length;L++){let S=this._expand(d.set[L]);if(T.add(S),this.ignoreCase)for(let $=0;$<S.length;$++){let v=S.index($),q=this._toOtherCase(v);v!==q&&T.add(q)}}return d.not?this.defaultRange.clone().subtract(T):this.defaultRange.clone().intersect(T)}}randInt(d,T){return d+Math.floor(Math.random()*(1+T-d))}get defaultRange(){return this._range=this._range||new l(32,126)}set defaultRange(d){this._range=d}static randexp(d,T){var L;return typeof d=="string"&&(d=new RegExp(d,T)),d._randexp===void 0?(L=new Lt(d,T),d._randexp=L):(L=d._randexp,L._setDefaults(d)),L.gen()}static sugar(){RegExp.prototype.gen=function(){return Lt.randexp(this)}}}}}),Tt=$e({"node_modules/yaml/dist/PlainValue-ec8e588e.js"(e){"use strict";var t={ANCHOR:"&",COMMENT:"#",TAG:"!",DIRECTIVES_END:"-",DOCUMENT_END:"."},n={ALIAS:"ALIAS",BLANK_LINE:"BLANK_LINE",BLOCK_FOLDED:"BLOCK_FOLDED",BLOCK_LITERAL:"BLOCK_LITERAL",COMMENT:"COMMENT",DIRECTIVE:"DIRECTIVE",DOCUMENT:"DOCUMENT",FLOW_MAP:"FLOW_MAP",FLOW_SEQ:"FLOW_SEQ",MAP:"MAP",MAP_KEY:"MAP_KEY",MAP_VALUE:"MAP_VALUE",PLAIN:"PLAIN",QUOTE_DOUBLE:"QUOTE_DOUBLE",QUOTE_SINGLE:"QUOTE_SINGLE",SEQ:"SEQ",SEQ_ITEM:"SEQ_ITEM"},l="tag:yaml.org,2002:",c={MAP:"tag:yaml.org,2002:map",SEQ:"tag:yaml.org,2002:seq",STR:"tag:yaml.org,2002:str"};function f(F){let g=[0],b=F.indexOf(` `);for(;b!==-1;)b+=1,g.push(b),b=F.indexOf(` `,b);return g}function d(F){let g,b;return typeof F=="string"?(g=f(F),b=F):(Array.isArray(F)&&(F=F[0]),F&&F.context&&(F.lineStarts||(F.lineStarts=f(F.context.src)),g=F.lineStarts,b=F.context.src)),{lineStarts:g,src:b}}function T(F,g){if(typeof F!="number"||F<0)return null;let{lineStarts:b,src:R}=d(g);if(!b||!R||F>R.length)return null;for(let M=0;M<b.length;++M){let _=b[M];if(F<_)return{line:M,col:F-b[M-1]+1};if(F===_)return{line:M+1,col:1}}let I=b.length;return{line:I,col:F-b[I-1]+1}}function L(F,g){let{lineStarts:b,src:R}=d(g);if(!b||!(F>=1)||F>b.length)return null;let I=b[F-1],M=b[F];for(;M&&M>I&&R[M-1]===` `;)--M;return R.slice(I,M)}function S({start:F,end:g},b,R=80){let I=L(F.line,b);if(!I)return null;let{col:M}=F;if(I.length>R)if(M<=R-10)I=I.substr(0,R-1)+"\u2026";else{let J=Math.round(R/2);I.length>M+J&&(I=I.substr(0,M+J-1)+"\u2026"),M-=I.length-R,I="\u2026"+I.substr(1-R)}let _=1,N="";g&&(g.line===F.line&&M+(g.col-F.col)<=R+1?_=g.col-F.col:(_=Math.min(I.length+1,R)-M,N="\u2026"));let k=M>1?" ".repeat(M-1):"",V="^".repeat(_);return`${I} ${k}${V}${N}`}var $=class Ir{static copy(g){return new Ir(g.start,g.end)}constructor(g,b){this.start=g,this.end=b||g}isEmpty(){return typeof this.start!="number"||!this.end||this.end<=this.start}setOrigRange(g,b){let{start:R,end:I}=this;if(g.length===0||I<=g[0])return this.origStart=R,this.origEnd=I,b;let M=b;for(;M<g.length&&!(g[M]>R);)++M;this.origStart=R+M;let _=M;for(;M<g.length&&!(g[M]>=I);)++M;return this.origEnd=I+M,_}},v=class tt{static addStringTerminator(g,b,R){if(R[R.length-1]===` `)return R;let I=tt.endOfWhiteSpace(g,b);return I>=g.length||g[I]===` `?R+` `:R}static atDocumentBoundary(g,b,R){let I=g[b];if(!I)return!0;let M=g[b-1];if(M&&M!==` `)return!1;if(R){if(I!==R)return!1}else if(I!==t.DIRECTIVES_END&&I!==t.DOCUMENT_END)return!1;let _=g[b+1],N=g[b+2];if(_!==I||N!==I)return!1;let k=g[b+3];return!k||k===` `||k===" "||k===" "}static endOfIdentifier(g,b){let R=g[b],I=R==="<",M=I?[` `," "," ",">"]:[` `," "," ","[","]","{","}",","];for(;R&