@5minds/processcube_app_sdk 6.2.0-feature-2cf3fc-maf1o23t → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/client/actions-C6ZNF7JX.mjs +1 -0
- package/build/client/components/DropdownMenu.d.ts +2 -2
- package/build/client/components/DynamicUi/DynamicUi.d.ts +1 -1
- package/build/client/components/ProcessInstanceInspector/ProcessInstanceInspector.d.ts +1 -1
- package/build/client/components/SplitterLayout.d.ts +1 -1
- package/build/client/index.cjs +9 -9
- package/build/client/index.mjs +10 -10
- package/build/common/index.cjs +1 -1
- package/build/common/index.mjs +1 -1
- package/build/server/index.cjs +1 -1
- package/build/server/index.mjs +49 -3
- package/package.json +30 -30
- package/build/client/actions-3JRWY3XI.mjs +0 -1
package/build/common/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var C=Object.create;var a=Object.defineProperty;var
|
|
1
|
+
var C=Object.create;var a=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var x=(s,e)=>{for(var r in e)a(s,r,{get:e[r],enumerable:!0})},f=(s,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of S(e))!D.call(s,o)&&o!==r&&a(s,o,{get:()=>e[o],enumerable:!(t=_(e,o))||t.enumerable});return s};var y=(s,e,r)=>(r=s!=null?C(w(s)):{},f(e||!s||!s.__esModule?a(r,"default",{value:s,enumerable:!0}):r,s)),I=s=>f(a({},"__esModule",{value:!0}),s);var b={};x(b,{RemoteUserTask:()=>R,authConfigJwtCallback:()=>g,authConfigSessionCallback:()=>U,hasClaim:()=>F,mapUserTask:()=>h,mapUserTaskList:()=>A});module.exports=I(b);var T=y(require("react"),1);function R(s){return T.default.createElement("div",{style:{width:"100%",height:"100%"}},T.default.createElement("iframe",{width:"100%",height:"100%",src:s.url}))}var u=require("jwt-decode"),d=require("next-auth"),m=require("next-auth/react"),p=require("@5minds/processcube_engine_sdk"),c=new p.Logger("processcube_app_sdk:next-auth_configuration"),k="No refresh token present. Your authority might be configured incorrectly. For more information see https://processcube.io/docs/app-sdk/samples/authority/authentication-with-nextauth";async function F(s){let e;return typeof window>"u"?e=(await(0,d.getServerSession)({callbacks:{jwt:g,session:U}}))?.user:e=(await(0,m.getSession)())?.user,!e||!e.claims?!1:e.claims[s]!=null}async function g(s){let{token:e,account:r,user:t}=s;r&&(e.accessToken=r.access_token,e.idToken=r.id_token,e.refreshToken=r.refresh_token,e.expiresAt=r.expires_at??Math.floor(Date.now()/1e3+r.expires_in)),t&&(e.user=t);let o=process.env.PROCESSCUBE_AUTHORITY_URL!=null&&process.env.NEXTAUTH_CLIENT_ID!=null&&process.env.NEXTAUTH_SECRET!=null;if(o||c.warn("In order for the Access Token to be automatically renewed, PROCESSCUBE_AUTHORITY_URL, NEXTAUTH_CLIENT_ID and NEXTAUTH_SECRET must be set as an environment variable"),e.refreshToken===void 0&&c.warn(k),o&&Date.now()>=e.expiresAt*1e3){if(e.refreshToken===void 0)return c.error("Error refreshing access token.",{err:k}),e.error="RefreshAccessTokenError",e;try{let i=await fetch(`${process.env.PROCESSCUBE_AUTHORITY_URL}/token`,{headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:process.env.NEXTAUTH_CLIENT_ID,client_secret:process.env.NEXTAUTH_SECRET,grant_type:"refresh_token",refresh_token:e.refreshToken}),method:"POST"}),n=await i.json();if(!i.ok)throw n;e.accessToken=n.access_token,e.idToken=n.id_token,e.expiresAt=Math.floor(Date.now()/1e3+n.expires_in),e.refreshToken=n.refresh_token??e.refreshToken}catch(i){c.error("Error refreshing access token",{err:i}),e.error="RefreshAccessTokenError"}}return e}async function U(s){let{session:e,token:r}=s,t=l(r.accessToken),o=l(r.idToken),i=Object.keys(o),n=Object.fromEntries(Object.entries(t).filter(([E,v])=>!i.includes(E)));return delete n.scope,delete n.jti,delete n.client_id,e.user=r.user??{},e.user.claims=n,e.error=r.error,e}function l(s){return(0,u.jwtDecode)(s)}function h(s){let{userTaskConfig:e,userTaskConfigModel:r,...t}=s,o={},i={};return e.formFields.forEach(n=>o[n.id]=n),r.formFields.forEach(n=>i[n.id]=n),{...t,userTaskConfig:{...e,formFieldsDict:o},userTaskConfigModel:{...r,formFieldsDict:i}}}function A(s){return{totalCount:s.totalCount,userTasks:s.userTasks.map(h)}}0&&(module.exports={RemoteUserTask,authConfigJwtCallback,authConfigSessionCallback,hasClaim,mapUserTask,mapUserTaskList});
|
package/build/common/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import c from"react";function C(n){return c.createElement("div",{style:{width:"100%",height:"100%"}},c.createElement("iframe",{width:"100%",height:"100%",src:n.url}))}import{jwtDecode as l}from"jwt-decode";import{getServerSession as u}from"next-auth";import{getSession as d}from"next-auth/react";import{Logger as m}from"@5minds/processcube_engine_sdk";var a=new m("processcube_app_sdk:next-auth_configuration"),T="No refresh token present. Your authority might be configured incorrectly. For more information see https://processcube.io/docs/app-sdk/samples/authority/authentication-with-nextauth";async function A(n){let e;return typeof window>"u"?e=(await u({callbacks:{jwt:p,session:g}}))?.user:e=(await d())?.user,!e||!e.claims?!1:e.claims[n]!=null}async function p(n){let{token:e,account:r,user:i}=n;r&&(e.accessToken=r.access_token,e.idToken=r.id_token,e.refreshToken=r.refresh_token,e.expiresAt=r.expires_at??Math.floor(Date.now()/1e3+r.expires_in)),i&&(e.user=i);let t=process.env.PROCESSCUBE_AUTHORITY_URL!=null&&process.env.NEXTAUTH_CLIENT_ID!=null&&process.env.NEXTAUTH_SECRET!=null;if(t||a.warn("In order for the Access Token to be automatically renewed, PROCESSCUBE_AUTHORITY_URL, NEXTAUTH_CLIENT_ID and NEXTAUTH_SECRET must be set as an environment variable"),e.refreshToken===void 0&&a.warn(T),t&&Date.now()>=e.expiresAt*1e3){if(e.refreshToken===void 0)return a.error("Error refreshing access token.",{err:T}),e.error="RefreshAccessTokenError",e;try{let o=await fetch(`${process.env.PROCESSCUBE_AUTHORITY_URL}/token`,{headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:process.env.NEXTAUTH_CLIENT_ID,client_secret:process.env.NEXTAUTH_SECRET,grant_type:"refresh_token",refresh_token:
|
|
1
|
+
import c from"react";function C(n){return c.createElement("div",{style:{width:"100%",height:"100%"}},c.createElement("iframe",{width:"100%",height:"100%",src:n.url}))}import{jwtDecode as l}from"jwt-decode";import{getServerSession as u}from"next-auth";import{getSession as d}from"next-auth/react";import{Logger as m}from"@5minds/processcube_engine_sdk";var a=new m("processcube_app_sdk:next-auth_configuration"),T="No refresh token present. Your authority might be configured incorrectly. For more information see https://processcube.io/docs/app-sdk/samples/authority/authentication-with-nextauth";async function A(n){let e;return typeof window>"u"?e=(await u({callbacks:{jwt:p,session:g}}))?.user:e=(await d())?.user,!e||!e.claims?!1:e.claims[n]!=null}async function p(n){let{token:e,account:r,user:i}=n;r&&(e.accessToken=r.access_token,e.idToken=r.id_token,e.refreshToken=r.refresh_token,e.expiresAt=r.expires_at??Math.floor(Date.now()/1e3+r.expires_in)),i&&(e.user=i);let t=process.env.PROCESSCUBE_AUTHORITY_URL!=null&&process.env.NEXTAUTH_CLIENT_ID!=null&&process.env.NEXTAUTH_SECRET!=null;if(t||a.warn("In order for the Access Token to be automatically renewed, PROCESSCUBE_AUTHORITY_URL, NEXTAUTH_CLIENT_ID and NEXTAUTH_SECRET must be set as an environment variable"),e.refreshToken===void 0&&a.warn(T),t&&Date.now()>=e.expiresAt*1e3){if(e.refreshToken===void 0)return a.error("Error refreshing access token.",{err:T}),e.error="RefreshAccessTokenError",e;try{let o=await fetch(`${process.env.PROCESSCUBE_AUTHORITY_URL}/token`,{headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({client_id:process.env.NEXTAUTH_CLIENT_ID,client_secret:process.env.NEXTAUTH_SECRET,grant_type:"refresh_token",refresh_token:e.refreshToken}),method:"POST"}),s=await o.json();if(!o.ok)throw s;e.accessToken=s.access_token,e.idToken=s.id_token,e.expiresAt=Math.floor(Date.now()/1e3+s.expires_in),e.refreshToken=s.refresh_token??e.refreshToken}catch(o){a.error("Error refreshing access token",{err:o}),e.error="RefreshAccessTokenError"}}return e}async function g(n){let{session:e,token:r}=n,i=f(r.accessToken),t=f(r.idToken),o=Object.keys(t),s=Object.fromEntries(Object.entries(i).filter(([k,h])=>!o.includes(k)));return delete s.scope,delete s.jti,delete s.client_id,e.user=r.user??{},e.user.claims=s,e.error=r.error,e}function f(n){return l(n)}function U(n){let{userTaskConfig:e,userTaskConfigModel:r,...i}=n,t={},o={};return e.formFields.forEach(s=>t[s.id]=s),r.formFields.forEach(s=>o[s.id]=s),{...i,userTaskConfig:{...e,formFieldsDict:t},userTaskConfigModel:{...r,formFieldsDict:o}}}function v(n){return{totalCount:n.totalCount,userTasks:n.userTasks.map(U)}}export{C as RemoteUserTask,p as authConfigJwtCallback,g as authConfigSessionCallback,A as hasClaim,U as mapUserTask,v as mapUserTaskList};
|
package/build/server/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var N=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var ue=Object.prototype.hasOwnProperty;var pe=(e,t)=>{for(var s in t)N(e,s,{get:t[s],enumerable:!0})},fe=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of le(t))!ue.call(e,o)&&o!==s&&N(e,o,{get:()=>t[o],enumerable:!(n=de(t,o))||n.enumerable});return e};var ye=e=>fe(N({},"__esModule",{value:!0}),e);var Xe={};pe(Xe,{cancelReservedUserTask:()=>Fe,finishManualTask:()=>D,finishTask:()=>Le,finishUntypedTask:()=>M,finishUserTask:()=>L,finishUserTaskAndGetNext:()=>Se,getActiveProcessInstances:()=>Ce,getAssignedUserTasksByIdentity:()=>ve,getEngineClient:()=>Ee,getFlowNodeInstances:()=>Ke,getFlowNodeInstancesByProcessInstanceId:()=>F,getFlowNodeInstancesTriggeredByFlowNodeInstanceIds:()=>v,getIdentity:()=>i,getProcessInstance:()=>qe,getProcessInstanceById:()=>U,getReservedUserTasksByIdentity:()=>Re,getTriggeredFlowNodeInstances:()=>Ge,getUserTasks:()=>te,getWaitingUserTaskByFlowNodeInstanceId:()=>se,getWaitingUserTasks:()=>_e,getWaitingUserTasksByCorrelationId:()=>be,getWaitingUserTasksByFlowNodeId:()=>he,getWaitingUserTasksByProcessInstanceId:()=>Ne,navigateToUrl:()=>Be,reserveUserTask:()=>Ue,retryProcess:()=>We,retryProcessInstance:()=>O,startProcess:()=>Ae,terminateProcess:()=>Me,terminateProcessInstance:()=>B,waitForProcessEnd:()=>Pe,waitForUserTask:()=>xe,withApplicationSdk:()=>Oe});module.exports=ye(Xe);var St=require("only-server"),_t=require("../common/index.cjs");var K=require("node:child_process"),C=require("node:fs"),d=require("node:path"),G=require("chokidar"),X=require("esbuild"),$=require("jwt-decode"),S=require("openid-client"),j=require("@5minds/processcube_engine_sdk");var q=require("@5minds/processcube_engine_client"),h=process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560",r=new q.EngineClient(h);var Ie={token:"ZHVtbXlfdG9rZW4=",userId:"dummy_token"},ke=.85,x=["external_task.ts","external_task.js"],b=process.env.PROCESSCUBE_AUTHORITY_URL!==void 0,T=new j.Logger("processcube_app_sdk:external_task_adapter"),m={},E;async function H(e){if(e&&!(0,C.existsSync)(e))throw new Error(`Invalid customExternalTasksDirPath. The given path '${e}' does not exist`);S.custom.setHttpOptionsDefaults({timeout:1e5});let t=await Q();E=await Z(t),await Te(t);let s=we(e);(0,G.watch)(s).on("add",async n=>{if(x.includes((0,d.basename)(n)))return Y(n,s)}).on("change",async n=>{if(x.includes((0,d.basename)(n)))return me(n,s)}).on("unlink",async n=>{x.includes((0,d.basename)(n))&&V(n)}).on("error",n=>T.error(`Watcher error: ${n}`))}async function Y(e,t){let s=(0,d.dirname)(e);if((await C.promises.readdir(s)).filter(u=>x.includes(u)).length>1){T.error(`Multiple external task files found in directory ${s}. Stopping all external task workers for this directory.`),m[s]&&V(e);return}let a=await J(e),c=(0,d.relative)(t,s),y=z(c),l=(0,d.join)(__dirname,"lib/ExternalTaskWorkerProcess.cjs"),I=(0,K.fork)(l,{env:{...process.env,PROCESSCUBE_ENGINE_URL:h}});m[s]=I,I.once("disconnect",()=>{delete m[s]}),I.send({action:"create",payload:{topic:y,identity:E,moduleString:a,workerPath:e}})}async function me(e,t){let s=(0,d.dirname)(e),n=m[s];if(!n)return Y(e,t);let o=await J(e),a=(0,d.relative)(t,s),c=z(a);n.send({action:"restart",payload:{topic:c,identity:E,moduleString:o,workerPath:e}})}function V(e){let t=(0,d.dirname)(e),s=m[t];s&&s.kill()}async function Q(){if(!b)return null;if(!process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID||!process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET){let n=new Error("Required environment variables PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID and PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET are missing. For help, please refer to our documentation on environment variables at: https://processcube.io/docs/app-sdk/samples/nextjs/external-task-adapter-with-nextjs#authority");throw T.error("Required environment variables PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID and PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET are missing",{err:n}),n}let e=await S.Issuer.discover(process.env.PROCESSCUBE_AUTHORITY_URL);return await new e.Client({client_id:process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID,client_secret:process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET}).grant({grant_type:"client_credentials",scope:"engine_etw"})}function Z(e){if(!b||e===null)return Ie;let t=e.access_token,s=(0,$.jwtDecode)(t);return{token:e.access_token,userId:s.sub}}async function Te(e){let t=5;if(!b||e===null)return;let n=await ge(e)*ke*1e3,o=async()=>{try{let a=await Q();E=Z(a);for(let c of Object.values(m))c.send({action:"updateIdentity",payload:{identity:E}});t=5,setTimeout(o,n)}catch(a){if(t===0){T.error("Could not refresh identity for external task worker processes. Stopping all external task workers.",{error:a});for(let y of Object.values(m))y.kill();return}T.error("Could not refresh identity for external task worker processes.",{error:a,retryCount:t}),t--;let c=2*1e3;setTimeout(o,c)}};setTimeout(o,n)}async function J(e){let t=await(0,X.build)({entryPoints:[e],write:!1,bundle:!0,platform:"node",target:"node18",format:"cjs",external:["@opentelemetry/api"]});if(t.errors.length>0)throw T.error(`Could not transpile file at '${e}'`,{errors:t.errors}),new Error(`Could not transpile file at '${e}'`);return t.warnings.length>0&&T.warn(`Transpiled file at '${e}' with warnings`,{warnings:t.warnings}),t.outputFiles[0].text}async function ge(e){let t=e.expires_in;if(!t&&e.expires_at&&(t=Math.floor(e.expires_at-Date.now()/1e3)),t===void 0)throw new Error("Could not determine the time until the access token for external task workers expires");return t}function z(e){return e.replace(/^\.\/+|\([^)]+\)|^\/*|\/*$/g,"").replace(/[\/]{2,}/g,"/")}function we(e){let t,s=[e,(0,d.join)(process.cwd(),"app"),(0,d.join)(process.cwd(),"src","app")];for(let n of s)if(n&&(0,C.existsSync)(n)){t=n;break}if(!t)throw new Error("Could not find external tasks directory");return t}function Ee(){return r}var R=require("next-auth/jwt"),ee=require("next/dist/compiled/@edge-runtime/cookies"),k=require("next/headers");async function i(){let e=await(0,R.getToken)({req:{cookies:await(0,k.cookies)(),headers:await(0,k.headers)()}});if(e?.expiresAt&&Date.now()>=e.expiresAt*1e3){let s=await fetch(`${process.env.NEXTAUTH_URL}/api/auth/session`,{method:"GET",headers:{"Content-Type":"application/json",cookie:(await(0,k.cookies)()).toString()}}),n=new ee.ResponseCookies(s.headers);if(n.getAll().length){let o=!1;try{for(let a of n.getAll())(await(0,k.cookies)()).set(a.name,a.value,{...a})}catch{o=!0}if(e=await(0,R.getToken)({req:{cookies:o?n:await(0,k.cookies)(),headers:await(0,k.headers)()}}),e?.error)throw e.error}}if(!e?.accessToken||!e?.sub)throw new Error("AccessToken or Sub could not be determined!");return{token:e?.accessToken,userId:e?.sub}}var g=require("@5minds/processcube_engine_client");async function P(){try{return i()}catch{return}}async function U(e){let t=await P();return(await r.processInstances.query({processInstanceId:e},{identity:t})).processInstances[0]}async function F(e,t={sortSettings:{sortBy:g.DataModels.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"ASC"}}){return(await r.flowNodeInstances.query({processInstanceId:e},{...t,identity:t.identity??await P()})).flowNodeInstances}async function v(e){let t=await P();return(await r.flowNodeInstances.query({triggeredByFlowNodeInstance:e},{identity:t})).flowNodeInstances}async function O(e,t,s){let n=await P();await r.processInstances.retryProcessInstance(e,{flowNodeInstanceId:t,newStartToken:s,identity:n})}async function B(e){let t=await P();await r.processInstances.terminateProcessInstance(e,t)}async function Ce(e={options:{identity:!0}}){switch(e.options.identity){case!0:e.options.identity=await i();break;case!1:e.options.identity=void 0;break;case void 0:e.options.identity=await i();break}return await r.processInstances.query({...e?.query,state:g.DataModels.ProcessInstances.ProcessInstanceState.running},e?.options)}async function Pe(e={},t=!0){let{processInstanceId:s}=e,n=typeof t=="boolean"?t==!0?await i():void 0:t;return new Promise(async(o,a)=>{let c=[],y=async l=>{if(s!==void 0&&l.processInstanceId!==s)return;let u=await r.processInstances.query({processInstanceId:l.processInstanceId},{identity:n});for(let _ of c)r.notification.removeSubscription(_,n);return u.totalCount===0?a(new Error(`Process with instance ID "${l.processInstanceId}" does not exist.`)):o(u.processInstances[0])};if(c.push(await r.notification.onProcessEnded(y,{identity:n})),c.push(await r.notification.onProcessError(y,{identity:n})),c.push(await r.notification.onProcessTerminated(y,{identity:n})),s){let l=await r.processInstances.query({processInstanceId:s,state:[g.DataModels.ProcessInstances.ProcessInstanceState.finished,g.DataModels.ProcessInstances.ProcessInstanceState.terminated,g.DataModels.ProcessInstances.ProcessInstanceState.error]},{identity:n});if(l.totalCount>0){for(let I of c)r.notification.removeSubscription(I,n);o(l.processInstances[0])}}})}var f=require("@5minds/processcube_engine_client"),p=require("../common/index.cjs");async function xe(e={},t=!0){let{correlationId:s,processInstanceId:n,flowNodeId:o}=e,a=typeof t=="boolean"?t==!0?await i():void 0:t;return new Promise(async(c,y)=>{let l=await r.userTasks.onUserTaskWaiting(async u=>{let _=s!==void 0&&u.correlationId!==s,ae=u.flowNodeInstanceId===void 0,ie=n!==void 0&&u.processInstanceId!==n,ce=o!==void 0&&u.flowNodeId!==o;if(_||ae||ie||ce)return;let W=await se(u.flowNodeInstanceId,{identity:a});return r.notification.removeSubscription(l,a),W===null?y(new Error(`UserTask with instance ID "${u.flowNodeInstanceId}" does not exist.`)):c(W)},{identity:a}),I=await te({correlationId:s,processInstanceId:n,flowNodeId:o,state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:a});I.userTasks.length>0&&(r.notification.removeSubscription(l,a),c(I.userTasks[0]))})}async function Se(e,t={},s={},n=!0){let o=typeof n=="boolean"?n==!0?await i():void 0:n;await r.userTasks.finishUserTask(e,s,o);let a={state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended,...t},c=await r.userTasks.query(a,{identity:o});return(0,p.mapUserTask)(c.userTasks[0])}async function te(e,t={identity:!0}){switch(t?.identity){case!0:t.identity=await i();break;case!1:t.identity=void 0;break;case void 0:t.identity=await i();break}let s=await r.userTasks.query(e,t);return(0,p.mapUserTaskList)(s)}async function _e(e={identity:!0}){switch(e?.identity){case!0:e.identity=await i();break;case!1:e.identity=void 0;break;case void 0:e.identity=await i();break}let t=await r.userTasks.query({state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},e);return(0,p.mapUserTaskList)(t)}async function Ne(e,t={identity:!0}){switch(t?.identity){case!0:t.identity=await i();break;case!1:t.identity=void 0;break;case void 0:t.identity=await i();break}let s=await r.userTasks.query({processInstanceId:e,state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},t);return(0,p.mapUserTaskList)(s)}async function he(e,t={identity:!0}){switch(t?.identity){case!0:t.identity=await i();break;case!1:t.identity=void 0;break;case void 0:t.identity=await i();break}let s=await r.userTasks.query({flowNodeId:e,state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},t);return(0,p.mapUserTaskList)(s)}async function se(e,t={identity:!0}){switch(t?.identity){case!0:t.identity=await i();break;case!1:t.identity=void 0;break;case void 0:t.identity=await i();break}let s=await r.userTasks.query({flowNodeInstanceId:e,state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{...t,limit:1});return s.userTasks.length===0?null:(0,p.mapUserTask)(s.userTasks[0])}async function be(e,t={identity:!0}){switch(t?.identity){case!0:t.identity=await i();break;case!1:t.identity=void 0;break;case void 0:t.identity=await i();break}let s=await r.userTasks.query({correlationId:e,state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},t);return(0,p.mapUserTaskList)(s)}async function Re(e,t){let s=e||await i(),n=await r.userTasks.query({state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:s,...t}),o=n.userTasks.filter(a=>a.actualOwnerId===s.userId);return n.userTasks=o,(0,p.mapUserTaskList)(n)}async function Ue(e,t,s){await r.userTasks.reserveUserTaskInstance(e,t,s||e.userId)}async function Fe(e,t){await r.userTasks.cancelUserTaskInstanceReservation(e,t)}async function ve(e,t){let s=e||await i(),n=await r.userTasks.query({state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:s,...t}),o=n.userTasks.filter(a=>a.assignedUserIds?.includes(s.userId));return n.userTasks=o,(0,p.mapUserTaskList)(n)}var w=require("next/dist/shared/lib/constants");var ne=!1,A=!1;function Oe(e={}){let{applicationSdk:t,...s}=e;return async(n,o)=>{A=A||n===w.PHASE_PRODUCTION_BUILD;let a=n===w.PHASE_DEVELOPMENT_SERVER||n===w.PHASE_PRODUCTION_SERVER;return t?.useExternalTasks&&a&&!ne&&!A&&(ne=!0,await H(t?.customExternalTasksDirPath)),{...s,experimental:{...s.experimental,serverComponentsExternalPackages:[...s.experimental?.serverComponentsExternalPackages||[],"esbuild"]}}}}var re=require("next/navigation");function Be(e){(0,re.redirect)(e)}async function Ae(...e){return await r.processModels.startProcessInstance(...e)}async function D(...e){await r.manualTasks.finishManualTask(...e)}async function L(...e){await r.userTasks.finishUserTask(...e)}async function M(...e){await r.untypedTasks.finishTask(...e)}var oe=require("@5minds/processcube_engine_client");async function De(){try{return i()}catch{return}}var Le=async(e,t)=>{let s=await De();t==="bpmn:UserTask"?await L(e,{},s):t==="bpmn:ManualTask"?await D(e,s):t==="bpmn:Task"?await M(e,s):console.error(`[@5minds/processcube_app_sdk:handlePlay] Unsupported flow node type: ${t}`)},Me=async e=>{await B(e)},We=async(e,t,s)=>{await O(e,t,s)},qe=async e=>U(e),Ke=async e=>F(e,{sortSettings:{sortBy:oe.DataModels.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"DESC"}}),Ge=async e=>v(e);0&&(module.exports={cancelReservedUserTask,finishManualTask,finishTask,finishUntypedTask,finishUserTask,finishUserTaskAndGetNext,getActiveProcessInstances,getAssignedUserTasksByIdentity,getEngineClient,getFlowNodeInstances,getFlowNodeInstancesByProcessInstanceId,getFlowNodeInstancesTriggeredByFlowNodeInstanceIds,getIdentity,getProcessInstance,getProcessInstanceById,getReservedUserTasksByIdentity,getTriggeredFlowNodeInstances,getUserTasks,getWaitingUserTaskByFlowNodeInstanceId,getWaitingUserTasks,getWaitingUserTasksByCorrelationId,getWaitingUserTasksByFlowNodeId,getWaitingUserTasksByProcessInstanceId,navigateToUrl,reserveUserTask,retryProcess,retryProcessInstance,startProcess,terminateProcess,terminateProcessInstance,waitForProcessEnd,waitForUserTask,withApplicationSdk});
|
|
1
|
+
var N=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var fe=(e,t)=>{for(var s in t)N(e,s,{get:t[s],enumerable:!0})},ye=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ue(t))!pe.call(e,o)&&o!==s&&N(e,o,{get:()=>t[o],enumerable:!(n=le(t,o))||n.enumerable});return e};var Ie=e=>ye(N({},"__esModule",{value:!0}),e);var $e={};fe($e,{cancelReservedUserTask:()=>ve,finishManualTask:()=>D,finishTask:()=>Me,finishUntypedTask:()=>M,finishUserTask:()=>L,finishUserTaskAndGetNext:()=>_e,getActiveProcessInstances:()=>Pe,getAssignedUserTasksByIdentity:()=>Oe,getEngineClient:()=>Ce,getFlowNodeInstances:()=>Ge,getFlowNodeInstancesByProcessInstanceId:()=>F,getFlowNodeInstancesTriggeredByFlowNodeInstanceIds:()=>v,getIdentity:()=>a,getProcessInstance:()=>Ke,getProcessInstanceById:()=>U,getReservedUserTasksByIdentity:()=>Ue,getTriggeredFlowNodeInstances:()=>Xe,getUserTasks:()=>te,getWaitingUserTaskByFlowNodeInstanceId:()=>se,getWaitingUserTasks:()=>Ne,getWaitingUserTasksByCorrelationId:()=>Re,getWaitingUserTasksByFlowNodeId:()=>be,getWaitingUserTasksByProcessInstanceId:()=>he,navigateToUrl:()=>Ae,reserveUserTask:()=>Fe,retryProcess:()=>qe,retryProcessInstance:()=>O,startProcess:()=>De,terminateProcess:()=>We,terminateProcessInstance:()=>B,waitForProcessEnd:()=>xe,waitForUserTask:()=>Se,withApplicationSdk:()=>Be});module.exports=Ie($e);var St=require("only-server"),_t=require("../common/index.cjs");var K=require("node:child_process"),C=require("node:fs"),d=require("node:path"),G=require("chokidar"),X=require("esbuild"),$=require("jwt-decode"),S=require("openid-client"),j=require("@5minds/processcube_engine_sdk");var q=require("@5minds/processcube_engine_client"),h=process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560",r=new q.EngineClient(h);var ke={token:"ZHVtbXlfdG9rZW4=",userId:"dummy_token"},me=.85,x=["external_task.ts","external_task.js"],b=process.env.PROCESSCUBE_AUTHORITY_URL!==void 0,T=new j.Logger("processcube_app_sdk:external_task_adapter"),m={},E;async function H(e){if(e&&!(0,C.existsSync)(e))throw new Error(`Invalid customExternalTasksDirPath. The given path '${e}' does not exist`);S.custom.setHttpOptionsDefaults({timeout:1e5});let t=await Q();E=await Z(t),await ge(t);let s=Ee(e);(0,G.watch)(s).on("add",async n=>{if(x.includes((0,d.basename)(n)))return Y(n,s)}).on("change",async n=>{if(x.includes((0,d.basename)(n)))return Te(n,s)}).on("unlink",async n=>{x.includes((0,d.basename)(n))&&V(n)}).on("error",n=>T.error(`Watcher error: ${n}`))}async function Y(e,t){let s=(0,d.dirname)(e);if((await C.promises.readdir(s)).filter(u=>x.includes(u)).length>1){T.error(`Multiple external task files found in directory ${s}. Stopping all external task workers for this directory.`),m[s]&&V(e);return}let i=await J(e),c=(0,d.relative)(t,s),y=z(c),l=(0,d.join)(__dirname,"lib/ExternalTaskWorkerProcess.cjs"),I=(0,K.fork)(l,{env:{...process.env,PROCESSCUBE_ENGINE_URL:h}});m[s]=I,I.once("disconnect",()=>{delete m[s]}),I.send({action:"create",payload:{topic:y,identity:E,moduleString:i,workerPath:e}})}async function Te(e,t){let s=(0,d.dirname)(e),n=m[s];if(!n)return Y(e,t);let o=await J(e),i=(0,d.relative)(t,s),c=z(i);n.send({action:"restart",payload:{topic:c,identity:E,moduleString:o,workerPath:e}})}function V(e){let t=(0,d.dirname)(e),s=m[t];s&&s.kill()}async function Q(){if(!b)return null;if(!process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID||!process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET){let n=new Error("Required environment variables PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID and PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET are missing. For help, please refer to our documentation on environment variables at: https://processcube.io/docs/app-sdk/samples/nextjs/external-task-adapter-with-nextjs#authority");throw T.error("Required environment variables PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID and PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET are missing",{err:n}),n}let e=await S.Issuer.discover(process.env.PROCESSCUBE_AUTHORITY_URL);return await new e.Client({client_id:process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID,client_secret:process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET}).grant({grant_type:"client_credentials",scope:"engine_etw"})}function Z(e){if(!b||e===null)return ke;let t=e.access_token,s=(0,$.jwtDecode)(t);return{token:e.access_token,userId:s.sub}}async function ge(e){let t=5;if(!b||e===null)return;let n=await we(e)*me*1e3,o=async()=>{try{let i=await Q();E=Z(i);for(let c of Object.values(m))c.send({action:"updateIdentity",payload:{identity:E}});t=5,setTimeout(o,n)}catch(i){if(t===0){T.error("Could not refresh identity for external task worker processes. Stopping all external task workers.",{error:i});for(let y of Object.values(m))y.kill();return}T.error("Could not refresh identity for external task worker processes.",{error:i,retryCount:t}),t--;let c=2*1e3;setTimeout(o,c)}};setTimeout(o,n)}async function J(e){let t=await(0,X.build)({entryPoints:[e],write:!1,bundle:!0,platform:"node",target:"node18",format:"cjs",external:["@opentelemetry/api"]});if(t.errors.length>0)throw T.error(`Could not transpile file at '${e}'`,{errors:t.errors}),new Error(`Could not transpile file at '${e}'`);return t.warnings.length>0&&T.warn(`Transpiled file at '${e}' with warnings`,{warnings:t.warnings}),t.outputFiles[0].text}async function we(e){let t=e.expires_in;if(!t&&e.expires_at&&(t=Math.floor(e.expires_at-Date.now()/1e3)),t===void 0)throw new Error("Could not determine the time until the access token for external task workers expires");return t}function z(e){return e.replace(/^\.\/+|\([^)]+\)|^\/*|\/*$/g,"").replace(/[\/]{2,}/g,"/")}function Ee(e){let t,s=[e,(0,d.join)(process.cwd(),"app"),(0,d.join)(process.cwd(),"src","app")];for(let n of s)if(n&&(0,C.existsSync)(n)){t=n;break}if(!t)throw new Error("Could not find external tasks directory");return t}function Ce(){return r}var R=require("next-auth/jwt"),ee=require("next/dist/compiled/@edge-runtime/cookies"),k=require("next/headers");async function a(){let e=await(0,R.getToken)({req:{cookies:(0,k.cookies)(),headers:(0,k.headers)()}});if(e?.expiresAt&&Date.now()>=e.expiresAt*1e3){let s=await fetch(`${process.env.NEXTAUTH_URL}/api/auth/session`,{method:"GET",headers:{"Content-Type":"application/json",cookie:(0,k.cookies)().toString()}}),n=new ee.ResponseCookies(s.headers);if(n.getAll().length){let o=!1;try{for(let i of n.getAll())(0,k.cookies)().set(i.name,i.value,{...i})}catch{o=!0}if(e=await(0,R.getToken)({req:{cookies:o?n:(0,k.cookies)(),headers:(0,k.headers)()}}),e?.error)throw e.error}}if(!e?.accessToken||!e?.sub)throw new Error("AccessToken or Sub could not be determined!");return{token:e?.accessToken,userId:e?.sub}}var g=require("@5minds/processcube_engine_client");async function P(){try{return a()}catch{return}}async function U(e){let t=await P();return(await r.processInstances.query({processInstanceId:e},{identity:t})).processInstances[0]}async function F(e,t={sortSettings:{sortBy:g.DataModels.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"ASC"}}){return(await r.flowNodeInstances.query({processInstanceId:e},{...t,identity:t.identity??await P()})).flowNodeInstances}async function v(e){let t=await P();return(await r.flowNodeInstances.query({triggeredByFlowNodeInstance:e},{identity:t})).flowNodeInstances}async function O(e,t,s){let n=await P();await r.processInstances.retryProcessInstance(e,{flowNodeInstanceId:t,newStartToken:s,identity:n})}async function B(e){let t=await P();await r.processInstances.terminateProcessInstance(e,t)}async function Pe(e={options:{identity:!0}}){switch(e.options.identity){case!0:e.options.identity=await a();break;case!1:e.options.identity=void 0;break;case void 0:e.options.identity=await a();break}return await r.processInstances.query({...e?.query,state:g.DataModels.ProcessInstances.ProcessInstanceState.running},e?.options)}async function xe(e={},t=!0){let{processInstanceId:s}=e,n=typeof t=="boolean"?t==!0?await a():void 0:t;return new Promise(async(o,i)=>{let c=[],y=async l=>{if(s!==void 0&&l.processInstanceId!==s)return;let u=await r.processInstances.query({processInstanceId:l.processInstanceId},{identity:n});for(let _ of c)r.notification.removeSubscription(_,n);return u.totalCount===0?i(new Error(`Process with instance ID "${l.processInstanceId}" does not exist.`)):o(u.processInstances[0])};if(c.push(await r.notification.onProcessEnded(y,{identity:n})),c.push(await r.notification.onProcessError(y,{identity:n})),c.push(await r.notification.onProcessTerminated(y,{identity:n})),s){let l=await r.processInstances.query({processInstanceId:s,state:[g.DataModels.ProcessInstances.ProcessInstanceState.finished,g.DataModels.ProcessInstances.ProcessInstanceState.terminated,g.DataModels.ProcessInstances.ProcessInstanceState.error]},{identity:n});if(l.totalCount>0){for(let I of c)r.notification.removeSubscription(I,n);o(l.processInstances[0])}}})}var f=require("@5minds/processcube_engine_client"),p=require("../common/index.cjs");async function Se(e={},t=!0){let{correlationId:s,processInstanceId:n,flowNodeId:o}=e,i=typeof t=="boolean"?t==!0?await a():void 0:t;return new Promise(async(c,y)=>{let l=await r.userTasks.onUserTaskWaiting(async u=>{let _=s!==void 0&&u.correlationId!==s,ae=u.flowNodeInstanceId===void 0,ce=n!==void 0&&u.processInstanceId!==n,de=o!==void 0&&u.flowNodeId!==o;if(_||ae||ce||de)return;let W=await se(u.flowNodeInstanceId,{identity:i});return r.notification.removeSubscription(l,i),W===null?y(new Error(`UserTask with instance ID "${u.flowNodeInstanceId}" does not exist.`)):c(W)},{identity:i}),I=await te({correlationId:s,processInstanceId:n,flowNodeId:o,state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:i});I.userTasks.length>0&&(r.notification.removeSubscription(l,i),c(I.userTasks[0]))})}async function _e(e,t={},s={},n=!0){let o=typeof n=="boolean"?n==!0?await a():void 0:n;await r.userTasks.finishUserTask(e,s,o);let i={state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended,...t},c=await r.userTasks.query(i,{identity:o});return(0,p.mapUserTask)(c.userTasks[0])}async function te(e,t={identity:!0}){switch(t?.identity){case!0:t.identity=await a();break;case!1:t.identity=void 0;break;case void 0:t.identity=await a();break}let s=await r.userTasks.query(e,t);return(0,p.mapUserTaskList)(s)}async function Ne(e={identity:!0}){switch(e?.identity){case!0:e.identity=await a();break;case!1:e.identity=void 0;break;case void 0:e.identity=await a();break}let t=await r.userTasks.query({state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},e);return(0,p.mapUserTaskList)(t)}async function he(e,t={identity:!0}){switch(t?.identity){case!0:t.identity=await a();break;case!1:t.identity=void 0;break;case void 0:t.identity=await a();break}let s=await r.userTasks.query({processInstanceId:e,state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},t);return(0,p.mapUserTaskList)(s)}async function be(e,t={identity:!0}){switch(t?.identity){case!0:t.identity=await a();break;case!1:t.identity=void 0;break;case void 0:t.identity=await a();break}let s=await r.userTasks.query({flowNodeId:e,state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},t);return(0,p.mapUserTaskList)(s)}async function se(e,t={identity:!0}){switch(t?.identity){case!0:t.identity=await a();break;case!1:t.identity=void 0;break;case void 0:t.identity=await a();break}let s=await r.userTasks.query({flowNodeInstanceId:e,state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{...t,limit:1});return s.userTasks.length===0?null:(0,p.mapUserTask)(s.userTasks[0])}async function Re(e,t={identity:!0}){switch(t?.identity){case!0:t.identity=await a();break;case!1:t.identity=void 0;break;case void 0:t.identity=await a();break}let s=await r.userTasks.query({correlationId:e,state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},t);return(0,p.mapUserTaskList)(s)}async function Ue(e,t){let s=e||await a(),n=await r.userTasks.query({state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:s,...t}),o=n.userTasks.filter(i=>i.actualOwnerId===s.userId);return n.userTasks=o,(0,p.mapUserTaskList)(n)}async function Fe(e,t,s){await r.userTasks.reserveUserTaskInstance(e,t,s||e.userId)}async function ve(e,t){await r.userTasks.cancelUserTaskInstanceReservation(e,t)}async function Oe(e,t){let s=e||await a(),n=await r.userTasks.query({state:f.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:s,...t}),o=n.userTasks.filter(i=>i.assignedUserIds?.includes(s.userId));return n.userTasks=o,(0,p.mapUserTaskList)(n)}var w=require("next/dist/shared/lib/constants");var ne=!1,A=!1;function Be(e={}){let{applicationSdk:t,...s}=e;return async(n,o)=>{A=A||n===w.PHASE_PRODUCTION_BUILD;let i=n===w.PHASE_DEVELOPMENT_SERVER||n===w.PHASE_PRODUCTION_SERVER;return t?.useExternalTasks&&i&&!ne&&!A&&(ne=!0,await H(t?.customExternalTasksDirPath)),{...s,experimental:{...s.experimental,serverComponentsExternalPackages:[...s.experimental?.serverComponentsExternalPackages||[],"esbuild"]}}}}var re=require("next/cache"),oe=require("next/navigation");function Ae(e){(0,re.revalidatePath)(e),(0,oe.redirect)(e)}async function De(...e){return await r.processModels.startProcessInstance(...e)}async function D(...e){await r.manualTasks.finishManualTask(...e)}async function L(...e){await r.userTasks.finishUserTask(...e)}async function M(...e){await r.untypedTasks.finishTask(...e)}var ie=require("@5minds/processcube_engine_client");async function Le(){try{return a()}catch{return}}var Me=async(e,t)=>{let s=await Le();t==="bpmn:UserTask"?await L(e,{},s):t==="bpmn:ManualTask"?await D(e,s):t==="bpmn:Task"?await M(e,s):console.error(`[@5minds/processcube_app_sdk:handlePlay] Unsupported flow node type: ${t}`)},We=async e=>{await B(e)},qe=async(e,t,s)=>{await O(e,t,s)},Ke=async e=>U(e),Ge=async e=>F(e,{sortSettings:{sortBy:ie.DataModels.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"DESC"}}),Xe=async e=>v(e);0&&(module.exports={cancelReservedUserTask,finishManualTask,finishTask,finishUntypedTask,finishUserTask,finishUserTaskAndGetNext,getActiveProcessInstances,getAssignedUserTasksByIdentity,getEngineClient,getFlowNodeInstances,getFlowNodeInstancesByProcessInstanceId,getFlowNodeInstancesTriggeredByFlowNodeInstanceIds,getIdentity,getProcessInstance,getProcessInstanceById,getReservedUserTasksByIdentity,getTriggeredFlowNodeInstances,getUserTasks,getWaitingUserTaskByFlowNodeInstanceId,getWaitingUserTasks,getWaitingUserTasksByCorrelationId,getWaitingUserTasksByFlowNodeId,getWaitingUserTasksByProcessInstanceId,navigateToUrl,reserveUserTask,retryProcess,retryProcessInstance,startProcess,terminateProcess,terminateProcessInstance,waitForProcessEnd,waitForUserTask,withApplicationSdk});
|
package/build/server/index.mjs
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
|
-
import"only-server";import"../common/index.mjs";import{fork as Yt}from"node:child_process";import{existsSync as Ce,promises as zt}from"node:fs";import{basename as se,dirname as ie,join as ne,relative as Se}from"node:path";import{stat as xt}from"fs";import{stat as bt,readdir as Rt}from"fs/promises";import{EventEmitter as Ct}from"events";import*as p from"path";import{stat as Xe,lstat as ae,readdir as Qe,realpath as Ze}from"node:fs/promises";import{Readable as Je}from"node:stream";import{resolve as ce,relative as et,join as tt,sep as st}from"node:path";var I={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},Y={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:I.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(Y);var he="READDIRP_RECURSIVE_ERROR",nt=new Set(["ENOENT","EPERM","EACCES","ELOOP",he]),de=[I.DIR_TYPE,I.EVERYTHING_TYPE,I.FILE_DIR_TYPE,I.FILE_TYPE],it=new Set([I.DIR_TYPE,I.EVERYTHING_TYPE,I.FILE_DIR_TYPE]),rt=new Set([I.EVERYTHING_TYPE,I.FILE_DIR_TYPE,I.FILE_TYPE]),ot=s=>nt.has(s.code),at=process.platform==="win32",le=s=>!0,fe=s=>{if(s===void 0)return le;if(typeof s=="function")return s;if(typeof s=="string"){let e=s.trim();return t=>t.basename===e}if(Array.isArray(s)){let e=s.map(t=>t.trim());return t=>e.some(n=>t.basename===n)}return le},z=class extends Je{constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark});let t={...Y,...e},{root:n,type:i}=t;this._fileFilter=fe(t.fileFilter),this._directoryFilter=fe(t.directoryFilter);let r=t.lstat?ae:Xe;at?this._stat=a=>r(a,{bigint:!0}):this._stat=r,this._maxDepth=t.depth??Y.depth,this._wantsDir=i?it.has(i):!1,this._wantsFile=i?rt.has(i):!1,this._wantsEverything=i===I.EVERYTHING_TYPE,this._root=ce(n),this._isDirent=!t.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let t=this.parent,n=t&&t.files;if(n&&n.length>0){let{path:i,depth:r}=t,a=n.splice(0,e).map(c=>this._formatEntry(c,i)),o=await Promise.all(a);for(let c of o){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(r<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,r+1)),this._wantsDir&&(this.push(c),e--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),e--)}}else{let i=this.parents.pop();if(!i){this.push(null);break}if(this.parent=await i,this.destroyed)return}}}catch(t){this.destroy(t)}finally{this.reading=!1}}}async _exploreDir(e,t){let n;try{n=await Qe(e,this._rdOptions)}catch(i){this._onError(i)}return{files:n,depth:t,path:e}}async _formatEntry(e,t){let n,i=this._isDirent?e.name:e;try{let r=ce(tt(t,i));n={path:et(this._root,r),fullPath:r,basename:i},n[this._statsProp]=this._isDirent?e:await this._stat(r)}catch(r){this._onError(r);return}return n}_onError(e){ot(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){if(!e&&this._statsProp in e)return"";let t=e[this._statsProp];if(t.isFile())return"file";if(t.isDirectory())return"directory";if(t&&t.isSymbolicLink()){let n=e.fullPath;try{let i=await Ze(n),r=await ae(i);if(r.isFile())return"file";if(r.isDirectory()){let a=i.length;if(n.startsWith(i)&&n.substr(a,1)===st){let o=new Error(`Circular symlink detected: "${n}" points to "${i}"`);return o.code=he,this._onError(o)}return"directory"}}catch(i){return this._onError(i),""}}}_includeAsFile(e){let t=e&&e[this._statsProp];return t&&this._wantsEverything&&!t.isDirectory()}};function ue(s,e={}){let t=e.entryType||e.type;if(t==="both"&&(t=I.FILE_DIR_TYPE),t&&(e.type=t),s){if(typeof s!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(t&&!de.includes(t))throw new Error(`readdirp: Invalid type passed. Use one of ${de.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=s,new z(e)}import{watchFile as ct,unwatchFile as pe,watch as dt}from"fs";import{open as lt,stat as ye,lstat as ft,realpath as K}from"fs/promises";import*as m from"path";import{type as ht}from"os";var ut="data",$="end",we="close",W=()=>{};var M=process.platform,V=M==="win32",pt=M==="darwin",mt=M==="linux",yt=M==="freebsd",_e=ht()==="OS400",w={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},E=w,wt="watch",_t={lstat:ft,stat:ye},k="listeners",A="errHandlers",C="rawEmitters",gt=[k,A,C],It=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),Et=s=>It.has(m.extname(s).slice(1).toLowerCase()),G=(s,e)=>{s instanceof Set?s.forEach(e):e(s)},S=(s,e,t)=>{let n=s[e];n instanceof Set||(s[e]=n=new Set([n])),n.add(t)},Pt=s=>e=>{let t=s[e];t instanceof Set?t.clear():delete s[e]},N=(s,e,t)=>{let n=s[e];n instanceof Set?n.delete(t):n===t&&delete s[e]},ge=s=>s instanceof Set?s.size===0:!s,U=new Map;function me(s,e,t,n,i){let r=(a,o)=>{t(s),i(a,o,{watchedPath:s}),o&&s!==o&&L(m.resolve(s,o),k,m.join(s,o))};try{return dt(s,{persistent:e.persistent},r)}catch(a){n(a);return}}var L=(s,e,t,n,i)=>{let r=U.get(s);r&&G(r[e],a=>{a(t,n,i)})},Tt=(s,e,t,n)=>{let{listener:i,errHandler:r,rawEmitter:a}=n,o=U.get(e),c;if(!t.persistent)return c=me(s,t,i,r,a),c?c.close.bind(c):void 0;if(o)S(o,k,i),S(o,A,r),S(o,C,a);else{if(c=me(s,t,L.bind(null,e,k),r,L.bind(null,e,C)),!c)return;c.on(E.ERROR,async l=>{let d=L.bind(null,e,A);if(o&&(o.watcherUnusable=!0),V&&l.code==="EPERM")try{await(await lt(s,"r")).close(),d(l)}catch{}else d(l)}),o={listeners:i,errHandlers:r,rawEmitters:a,watcher:c},U.set(e,o)}return()=>{N(o,k,i),N(o,A,r),N(o,C,a),ge(o.listeners)&&(o.watcher.close(),U.delete(e),gt.forEach(Pt(o)),o.watcher=void 0,Object.freeze(o))}},q=new Map,kt=(s,e,t,n)=>{let{listener:i,rawEmitter:r}=n,a=q.get(e),o=a&&a.options;return o&&(o.persistent<t.persistent||o.interval>t.interval)&&(pe(e),a=void 0),a?(S(a,k,i),S(a,C,r)):(a={listeners:i,rawEmitters:r,options:t,watcher:ct(e,t,(c,l)=>{G(a.rawEmitters,f=>{f(E.CHANGE,e,{curr:c,prev:l})});let d=c.mtimeMs;(c.size!==l.size||d>l.mtimeMs||d===0)&&G(a.listeners,f=>f(s,c))})},q.set(e,a)),()=>{N(a,k,i),N(a,C,r),ge(a.listeners)&&(q.delete(e),pe(e),a.options=a.watcher=void 0,Object.freeze(a))}},O=class{constructor(e){this.fsw=e,this._boundHandleError=t=>e._handleError(t)}_watchWithNodeFs(e,t){let n=this.fsw.options,i=m.dirname(e),r=m.basename(e);this.fsw._getWatchedDir(i).add(r);let o=m.resolve(e),c={persistent:n.persistent};t||(t=W);let l;if(n.usePolling){let d=n.interval!==n.binaryInterval;c.interval=d&&Et(r)?n.binaryInterval:n.interval,l=kt(e,o,c,{listener:t,rawEmitter:this.fsw._emitRaw})}else l=Tt(e,o,c,{listener:t,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(e,t,n){if(this.fsw.closed)return;let i=m.dirname(e),r=m.basename(e),a=this.fsw._getWatchedDir(i),o=t;if(a.has(r))return;let c=async(d,f)=>{if(this.fsw._throttle(wt,e,5)){if(!f||f.mtimeMs===0)try{let u=await ye(e);if(this.fsw.closed)return;let _=u.atimeMs,g=u.mtimeMs;if((!_||_<=g||g!==o.mtimeMs)&&this.fsw._emit(E.CHANGE,e,u),(pt||mt||yt)&&o.ino!==u.ino){this.fsw._closeFile(d),o=u;let T=this._watchWithNodeFs(e,c);T&&this.fsw._addPathCloser(d,T)}else o=u}catch{this.fsw._remove(i,r)}else if(a.has(r)){let u=f.atimeMs,_=f.mtimeMs;(!u||u<=_||_!==o.mtimeMs)&&this.fsw._emit(E.CHANGE,e,f),o=f}}},l=this._watchWithNodeFs(e,c);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(E.ADD,e,0))return;this.fsw._emit(E.ADD,e,t)}return l}async _handleSymlink(e,t,n,i){if(this.fsw.closed)return;let r=e.fullPath,a=this.fsw._getWatchedDir(t);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await K(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(i)?this.fsw._symlinkPaths.get(r)!==o&&(this.fsw._symlinkPaths.set(r,o),this.fsw._emit(E.CHANGE,n,e.stats)):(a.add(i),this.fsw._symlinkPaths.set(r,o),this.fsw._emit(E.ADD,n,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(r))return!0;this.fsw._symlinkPaths.set(r,!0)}_handleRead(e,t,n,i,r,a,o){if(e=m.join(e,""),o=this.fsw._throttle("readdir",e,1e3),!o)return;let c=this.fsw._getWatchedDir(n.path),l=new Set,d=this.fsw._readdirp(e,{fileFilter:f=>n.filterPath(f),directoryFilter:f=>n.filterDir(f)});if(d)return d.on(ut,async f=>{if(this.fsw.closed){d=void 0;return}let u=f.path,_=m.join(e,u);if(l.add(u),!(f.stats.isSymbolicLink()&&await this._handleSymlink(f,e,_,u))){if(this.fsw.closed){d=void 0;return}(u===i||!i&&!c.has(u))&&(this.fsw._incrReadyCount(),_=m.join(r,m.relative(r,_)),this._addToNodeFs(_,t,n,a+1))}}).on(E.ERROR,this._boundHandleError),new Promise((f,u)=>{if(!d)return u();d.once($,()=>{if(this.fsw.closed){d=void 0;return}let _=o?o.clear():!1;f(void 0),c.getChildren().filter(g=>g!==e&&!l.has(g)).forEach(g=>{this.fsw._remove(e,g)}),d=void 0,_&&this._handleRead(e,!1,n,i,r,a,o)})})}async _handleDir(e,t,n,i,r,a,o){let c=this.fsw._getWatchedDir(m.dirname(e)),l=c.has(m.basename(e));!(n&&this.fsw.options.ignoreInitial)&&!r&&!l&&this.fsw._emit(E.ADD_DIR,e,t),c.add(m.basename(e)),this.fsw._getWatchedDir(e);let d,f,u=this.fsw.options.depth;if((u==null||i<=u)&&!this.fsw._symlinkPaths.has(o)){if(!r&&(await this._handleRead(e,n,a,r,e,i,d),this.fsw.closed))return;f=this._watchWithNodeFs(e,(_,g)=>{g&&g.mtimeMs===0||this._handleRead(_,!1,a,r,e,i,d)})}return f}async _addToNodeFs(e,t,n,i,r){let a=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(e);n&&(o.filterPath=c=>n.filterPath(c),o.filterDir=c=>n.filterDir(c));try{let c=await _t[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,c))return a(),!1;let l=this.fsw.options.followSymlinks,d;if(c.isDirectory()){let f=m.resolve(e),u=l?await K(e):e;if(this.fsw.closed||(d=await this._handleDir(o.watchPath,c,t,i,r,o,u),this.fsw.closed))return;f!==u&&u!==void 0&&this.fsw._symlinkPaths.set(f,u)}else if(c.isSymbolicLink()){let f=l?await K(e):e;if(this.fsw.closed)return;let u=m.dirname(o.watchPath);if(this.fsw._getWatchedDir(u).add(o.watchPath),this.fsw._emit(E.ADD,o.watchPath,c),d=await this._handleDir(u,c,t,i,e,o,f),this.fsw.closed)return;f!==void 0&&this.fsw._symlinkPaths.set(m.resolve(e),f)}else d=this._handleFile(o.watchPath,c,t);return a(),d&&this.fsw._addPathCloser(e,d),!1}catch(c){if(this.fsw._handleError(c))return a(),e}}};var X="/",St="//",xe=".",Nt="..",Dt="string",Ft=/\\/g,Ie=/\/\//,vt=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,At=/^\.[/\\]/;function B(s){return Array.isArray(s)?s:[s]}var Q=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);function Ut(s){return typeof s=="function"?s:typeof s=="string"?e=>s===e:s instanceof RegExp?e=>s.test(e):typeof s=="object"&&s!==null?e=>{if(s.path===e)return!0;if(s.recursive){let t=p.relative(s.path,e);return t?!t.startsWith("..")&&!p.isAbsolute(t):!1}return!1}:()=>!1}function Lt(s){if(typeof s!="string")throw new Error("string expected");s=p.normalize(s),s=s.replace(/\\/g,"/");let e=!1;s.startsWith("//")&&(e=!0);let t=/\/\//;for(;s.match(t);)s=s.replace(t,"/");return e&&(s="/"+s),s}function Ee(s,e,t){let n=Lt(e);for(let i=0;i<s.length;i++){let r=s[i];if(r(n,t))return!0}return!1}function Ot(s,e){if(s==null)throw new TypeError("anymatch: specify first argument");let n=B(s).map(i=>Ut(i));return e==null?(i,r)=>Ee(n,i,r):Ee(n,e)}var Pe=s=>{let e=B(s).flat();if(!e.every(t=>typeof t===Dt))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(be)},Te=s=>{let e=s.replace(Ft,X),t=!1;for(e.startsWith(St)&&(t=!0);e.match(Ie);)e=e.replace(Ie,X);return t&&(e=X+e),e},be=s=>Te(p.normalize(Te(s))),ke=(s="")=>e=>typeof e=="string"?be(p.isAbsolute(e)?e:p.join(s,e)):e,Wt=(s,e)=>p.isAbsolute(s)?s:p.join(e,s),Mt=Object.freeze(new Set),Z=class{constructor(e,t){this.path=e,this._removeWatcher=t,this.items=new Set}add(e){let{items:t}=this;t&&e!==xe&&e!==Nt&&t.add(e)}async remove(e){let{items:t}=this;if(!t||(t.delete(e),t.size>0))return;let n=this.path;try{await Rt(n)}catch{this._removeWatcher&&this._removeWatcher(p.dirname(n),p.basename(n))}}has(e){let{items:t}=this;if(t)return t.has(e)}getChildren(){let{items:e}=this;return e?[...e.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=W,this.items=Mt,Object.freeze(this)}},Bt="stat",Ht="lstat",J=class{constructor(e,t,n){this.fsw=n;let i=e;this.path=e=e.replace(At,""),this.watchPath=i,this.fullWatchPath=p.resolve(i),this.dirParts=[],this.dirParts.forEach(r=>{r.length>1&&r.pop()}),this.followSymlinks=t,this.statMethod=t?Bt:Ht}entryPath(e){return p.join(this.watchPath,p.relative(this.watchPath,e.fullPath))}filterPath(e){let{stats:t}=e;if(t&&t.isSymbolicLink())return this.filterDir(e);let n=this.entryPath(e);return this.fsw._isntIgnored(n,t)&&this.fsw._hasReadPermissions(t)}filterDir(e){return this.fsw._isntIgnored(this.entryPath(e),e.stats)}},ee=class extends Ct{constructor(e={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let t=e.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},i={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...e,ignored:e.ignored?B(e.ignored):B([]),awaitWriteFinish:t===!0?n:typeof t=="object"?{...n,...t}:!1};_e&&(i.usePolling=!0),i.atomic===void 0&&(i.atomic=!i.usePolling);let r=process.env.CHOKIDAR_USEPOLLING;if(r!==void 0){let c=r.toLowerCase();c==="false"||c==="0"?i.usePolling=!1:c==="true"||c==="1"?i.usePolling=!0:i.usePolling=!!c}let a=process.env.CHOKIDAR_INTERVAL;a&&(i.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=W,this._readyEmitted=!0,process.nextTick(()=>this.emit(w.READY)))},this._emitRaw=(...c)=>this.emit(w.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=i,this._nodeFsHandler=new O(this),Object.freeze(i)}_addIgnoredPath(e){if(Q(e)){for(let t of this._ignoredPaths)if(Q(t)&&t.path===e.path&&t.recursive===e.recursive)return}this._ignoredPaths.add(e)}_removeIgnoredPath(e){if(this._ignoredPaths.delete(e),typeof e=="string")for(let t of this._ignoredPaths)Q(t)&&t.path===e&&this._ignoredPaths.delete(t)}add(e,t,n){let{cwd:i}=this.options;this.closed=!1,this._closePromise=void 0;let r=Pe(e);return i&&(r=r.map(a=>Wt(a,i))),r.forEach(a=>{this._removeIgnoredPath(a)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=r.length,Promise.all(r.map(async a=>{let o=await this._nodeFsHandler._addToNodeFs(a,!n,void 0,0,t);return o&&this._emitReady(),o})).then(a=>{this.closed||a.forEach(o=>{o&&this.add(p.dirname(o),p.basename(t||o))})}),this}unwatch(e){if(this.closed)return this;let t=Pe(e),{cwd:n}=this.options;return t.forEach(i=>{!p.isAbsolute(i)&&!this._closers.has(i)&&(n&&(i=p.join(n,i)),i=p.resolve(i)),this._closePath(i),this._addIgnoredPath(i),this._watched.has(i)&&this._addIgnoredPath({path:i,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(t=>t.forEach(n=>{let i=n();i instanceof Promise&&e.push(i)})),this._streams.forEach(t=>t.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(t=>t.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=e.length?Promise.all(e).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((t,n)=>{let r=(this.options.cwd?p.relative(this.options.cwd,n):n)||xe;e[r]=t.getChildren().sort()}),e}emitWithAll(e,t){this.emit(e,...t),e!==w.ERROR&&this.emit(w.ALL,e,...t)}async _emit(e,t,n){if(this.closed)return;let i=this.options;V&&(t=p.normalize(t)),i.cwd&&(t=p.relative(i.cwd,t));let r=[t];n!=null&&r.push(n);let a=i.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(t)))return o.lastChange=new Date,this;if(i.atomic){if(e===w.UNLINK)return this._pendingUnlinks.set(t,[e,...r]),setTimeout(()=>{this._pendingUnlinks.forEach((c,l)=>{this.emit(...c),this.emit(w.ALL,...c),this._pendingUnlinks.delete(l)})},typeof i.atomic=="number"?i.atomic:100),this;e===w.ADD&&this._pendingUnlinks.has(t)&&(e=w.CHANGE,this._pendingUnlinks.delete(t))}if(a&&(e===w.ADD||e===w.CHANGE)&&this._readyEmitted){let c=(l,d)=>{l?(e=w.ERROR,r[0]=l,this.emitWithAll(e,r)):d&&(r.length>1?r[1]=d:r.push(d),this.emitWithAll(e,r))};return this._awaitWriteFinish(t,a.stabilityThreshold,e,c),this}if(e===w.CHANGE&&!this._throttle(w.CHANGE,t,50))return this;if(i.alwaysStat&&n===void 0&&(e===w.ADD||e===w.ADD_DIR||e===w.CHANGE)){let c=i.cwd?p.join(i.cwd,t):t,l;try{l=await bt(c)}catch{}if(!l||this.closed)return;r.push(l)}return this.emitWithAll(e,r),this}_handleError(e){let t=e&&e.code;return e&&t!=="ENOENT"&&t!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||t!=="EPERM"&&t!=="EACCES")&&this.emit(w.ERROR,e),e||this.closed}_throttle(e,t,n){this._throttled.has(e)||this._throttled.set(e,new Map);let i=this._throttled.get(e);if(!i)throw new Error("invalid throttle");let r=i.get(t);if(r)return r.count++,!1;let a,o=()=>{let l=i.get(t),d=l?l.count:0;return i.delete(t),clearTimeout(a),l&&clearTimeout(l.timeoutObject),d};a=setTimeout(o,n);let c={timeoutObject:a,clear:o,count:0};return i.set(t,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,t,n,i){let r=this.options.awaitWriteFinish;if(typeof r!="object")return;let a=r.pollInterval,o,c=e;this.options.cwd&&!p.isAbsolute(e)&&(c=p.join(this.options.cwd,e));let l=new Date,d=this._pendingWrites;function f(u){xt(c,(_,g)=>{if(_||!d.has(e)){_&&_.code!=="ENOENT"&&i(_);return}let T=Number(new Date);u&&g.size!==u.size&&(d.get(e).lastChange=T);let Ve=d.get(e);T-Ve.lastChange>=t?(d.delete(e),i(void 0,g)):o=setTimeout(f,a,g)})}d.has(e)||(d.set(e,{lastChange:l,cancelWait:()=>(d.delete(e),clearTimeout(o),n)}),o=setTimeout(f,a))}_isIgnored(e,t){if(this.options.atomic&&vt.test(e))return!0;if(!this._userIgnored){let{cwd:n}=this.options,r=(this.options.ignored||[]).map(ke(n)),o=[...[...this._ignoredPaths].map(ke(n)),...r];this._userIgnored=Ot(o,void 0)}return this._userIgnored(e,t)}_isntIgnored(e,t){return!this._isIgnored(e,t)}_getWatchHelpers(e){return new J(e,this.options.followSymlinks,this)}_getWatchedDir(e){let t=p.resolve(e);return this._watched.has(t)||this._watched.set(t,new Z(t,this._boundRemove)),this._watched.get(t)}_hasReadPermissions(e){return this.options.ignorePermissionErrors?!0:!!(Number(e.mode)&256)}_remove(e,t,n){let i=p.join(e,t),r=p.resolve(i);if(n=n??(this._watched.has(i)||this._watched.has(r)),!this._throttle("remove",i,100))return;!n&&this._watched.size===1&&this.add(e,t,!0),this._getWatchedDir(i).getChildren().forEach(u=>this._remove(i,u));let c=this._getWatchedDir(e),l=c.has(t);c.remove(t),this._symlinkPaths.has(r)&&this._symlinkPaths.delete(r);let d=i;if(this.options.cwd&&(d=p.relative(this.options.cwd,i)),this.options.awaitWriteFinish&&this._pendingWrites.has(d)&&this._pendingWrites.get(d).cancelWait()===w.ADD)return;this._watched.delete(i),this._watched.delete(r);let f=n?w.UNLINK_DIR:w.UNLINK;l&&!this._isIgnored(i)&&this._emit(f,i),this._closePath(i)}_closePath(e){this._closeFile(e);let t=p.dirname(e);this._getWatchedDir(t).remove(p.basename(e))}_closeFile(e){let t=this._closers.get(e);t&&(t.forEach(n=>n()),this._closers.delete(e))}_addPathCloser(e,t){if(!t)return;let n=this._closers.get(e);n||(n=[],this._closers.set(e,n)),n.push(t)}_readdirp(e,t){if(this.closed)return;let n={type:w.ALL,alwaysStat:!0,lstat:!0,...t,depth:0},i=ue(e,n);return this._streams.add(i),i.once(we,()=>{i=void 0}),i.once($,()=>{i&&(this._streams.delete(i),i=void 0)}),i}};function Re(s,e={}){let t=new ee(e);return t.add(s),t}import{build as Kt}from"esbuild";import{jwtDecode as qt}from"jwt-decode";import{Issuer as Gt,custom as $t}from"openid-client";import{Logger as Vt}from"@5minds/processcube_engine_sdk";import{EngineClient as jt}from"@5minds/processcube_engine_client";var te=process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560",h=new jt(te);var Xt={token:"ZHVtbXlfdG9rZW4=",userId:"dummy_token"},Qt=.85,H=["external_task.ts","external_task.js"],re=process.env.PROCESSCUBE_AUTHORITY_URL!==void 0,b=new Vt("processcube_app_sdk:external_task_adapter"),x={},D;async function Ne(s){if(s&&!Ce(s))throw new Error(`Invalid customExternalTasksDirPath. The given path '${s}' does not exist`);$t.setHttpOptionsDefaults({timeout:1e5});let e=await ve();D=await Ae(e),await Jt(e);let t=ts(s);Re(t).on("add",async n=>{if(H.includes(se(n)))return De(n,t)}).on("change",async n=>{if(H.includes(se(n)))return Zt(n,t)}).on("unlink",async n=>{H.includes(se(n))&&Fe(n)}).on("error",n=>b.error(`Watcher error: ${n}`))}async function De(s,e){let t=ie(s);if((await zt.readdir(t)).filter(d=>H.includes(d)).length>1){b.error(`Multiple external task files found in directory ${t}. Stopping all external task workers for this directory.`),x[t]&&Fe(s);return}let r=await Ue(s),a=Se(e,t),o=Le(a),c=ne(__dirname,"lib/ExternalTaskWorkerProcess.cjs"),l=Yt(c,{env:{...process.env,PROCESSCUBE_ENGINE_URL:te}});x[t]=l,l.once("disconnect",()=>{delete x[t]}),l.send({action:"create",payload:{topic:o,identity:D,moduleString:r,workerPath:s}})}async function Zt(s,e){let t=ie(s),n=x[t];if(!n)return De(s,e);let i=await Ue(s),r=Se(e,t),a=Le(r);n.send({action:"restart",payload:{topic:a,identity:D,moduleString:i,workerPath:s}})}function Fe(s){let e=ie(s),t=x[e];t&&t.kill()}async function ve(){if(!re)return null;if(!process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID||!process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET){let n=new Error("Required environment variables PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID and PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET are missing. For help, please refer to our documentation on environment variables at: https://processcube.io/docs/app-sdk/samples/nextjs/external-task-adapter-with-nextjs#authority");throw b.error("Required environment variables PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID and PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET are missing",{err:n}),n}let s=await Gt.discover(process.env.PROCESSCUBE_AUTHORITY_URL);return await new s.Client({client_id:process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID,client_secret:process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET}).grant({grant_type:"client_credentials",scope:"engine_etw"})}function Ae(s){if(!re||s===null)return Xt;let e=s.access_token,t=qt(e);return{token:s.access_token,userId:t.sub}}async function Jt(s){let e=5;if(!re||s===null)return;let n=await es(s)*Qt*1e3,i=async()=>{try{let r=await ve();D=Ae(r);for(let a of Object.values(x))a.send({action:"updateIdentity",payload:{identity:D}});e=5,setTimeout(i,n)}catch(r){if(e===0){b.error("Could not refresh identity for external task worker processes. Stopping all external task workers.",{error:r});for(let o of Object.values(x))o.kill();return}b.error("Could not refresh identity for external task worker processes.",{error:r,retryCount:e}),e--;let a=2*1e3;setTimeout(i,a)}};setTimeout(i,n)}async function Ue(s){let e=await Kt({entryPoints:[s],write:!1,bundle:!0,platform:"node",target:"node18",format:"cjs",external:["@opentelemetry/api"]});if(e.errors.length>0)throw b.error(`Could not transpile file at '${s}'`,{errors:e.errors}),new Error(`Could not transpile file at '${s}'`);return e.warnings.length>0&&b.warn(`Transpiled file at '${s}' with warnings`,{warnings:e.warnings}),e.outputFiles[0].text}async function es(s){let e=s.expires_in;if(!e&&s.expires_at&&(e=Math.floor(s.expires_at-Date.now()/1e3)),e===void 0)throw new Error("Could not determine the time until the access token for external task workers expires");return e}function Le(s){return s.replace(/^\.\/+|\([^)]+\)|^\/*|\/*$/g,"").replace(/[\/]{2,}/g,"/")}function ts(s){let e,t=[s,ne(process.cwd(),"app"),ne(process.cwd(),"src","app")];for(let n of t)if(n&&Ce(n)){e=n;break}if(!e)throw new Error("Could not find external tasks directory");return e}function js(){return h}import{getToken as Oe}from"next-auth/jwt";import{ResponseCookies as ss}from"next/dist/compiled/@edge-runtime/cookies";import{cookies as j,headers as We}from"next/headers";async function y(){let s=await Oe({req:{cookies:await j(),headers:await We()}});if(s?.expiresAt&&Date.now()>=s.expiresAt*1e3){let t=await fetch(`${process.env.NEXTAUTH_URL}/api/auth/session`,{method:"GET",headers:{"Content-Type":"application/json",cookie:(await j()).toString()}}),n=new ss(t.headers);if(n.getAll().length){let i=!1;try{for(let r of n.getAll())(await j()).set(r.name,r.value,{...r})}catch{i=!0}if(s=await Oe({req:{cookies:i?n:await j(),headers:await We()}}),s?.error)throw s.error}}if(!s?.accessToken||!s?.sub)throw new Error("AccessToken or Sub could not be determined!");return{token:s?.accessToken,userId:s?.sub}}import{DataModels as F}from"@5minds/processcube_engine_client";async function v(){try{return y()}catch{return}}async function Me(s){let e=await v();return(await h.processInstances.query({processInstanceId:s},{identity:e})).processInstances[0]}async function Be(s,e={sortSettings:{sortBy:F.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"ASC"}}){return(await h.flowNodeInstances.query({processInstanceId:s},{...e,identity:e.identity??await v()})).flowNodeInstances}async function He(s){let e=await v();return(await h.flowNodeInstances.query({triggeredByFlowNodeInstance:s},{identity:e})).flowNodeInstances}async function je(s,e,t){let n=await v();await h.processInstances.retryProcessInstance(s,{flowNodeInstanceId:e,newStartToken:t,identity:n})}async function Ye(s){let e=await v();await h.processInstances.terminateProcessInstance(s,e)}async function Qs(s={options:{identity:!0}}){switch(s.options.identity){case!0:s.options.identity=await y();break;case!1:s.options.identity=void 0;break;case void 0:s.options.identity=await y();break}return await h.processInstances.query({...s?.query,state:F.ProcessInstances.ProcessInstanceState.running},s?.options)}async function Zs(s={},e=!0){let{processInstanceId:t}=s,n=typeof e=="boolean"?e==!0?await y():void 0:e;return new Promise(async(i,r)=>{let a=[],o=async c=>{if(t!==void 0&&c.processInstanceId!==t)return;let d=await h.processInstances.query({processInstanceId:c.processInstanceId},{identity:n});for(let f of a)h.notification.removeSubscription(f,n);return d.totalCount===0?r(new Error(`Process with instance ID "${c.processInstanceId}" does not exist.`)):i(d.processInstances[0])};if(a.push(await h.notification.onProcessEnded(o,{identity:n})),a.push(await h.notification.onProcessError(o,{identity:n})),a.push(await h.notification.onProcessTerminated(o,{identity:n})),t){let c=await h.processInstances.query({processInstanceId:t,state:[F.ProcessInstances.ProcessInstanceState.finished,F.ProcessInstances.ProcessInstanceState.terminated,F.ProcessInstances.ProcessInstanceState.error]},{identity:n});if(c.totalCount>0){for(let l of a)h.notification.removeSubscription(l,n);i(c.processInstances[0])}}})}import{DataModels as P}from"@5minds/processcube_engine_client";import{mapUserTask as ze,mapUserTaskList as R}from"../common/index.mjs";async function an(s={},e=!0){let{correlationId:t,processInstanceId:n,flowNodeId:i}=s,r=typeof e=="boolean"?e==!0?await y():void 0:e;return new Promise(async(a,o)=>{let c=await h.userTasks.onUserTaskWaiting(async d=>{let f=t!==void 0&&d.correlationId!==t,u=d.flowNodeInstanceId===void 0,_=n!==void 0&&d.processInstanceId!==n,g=i!==void 0&&d.flowNodeId!==i;if(f||u||_||g)return;let T=await is(d.flowNodeInstanceId,{identity:r});return h.notification.removeSubscription(c,r),T===null?o(new Error(`UserTask with instance ID "${d.flowNodeInstanceId}" does not exist.`)):a(T)},{identity:r}),l=await ns({correlationId:t,processInstanceId:n,flowNodeId:i,state:P.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:r});l.userTasks.length>0&&(h.notification.removeSubscription(c,r),a(l.userTasks[0]))})}async function cn(s,e={},t={},n=!0){let i=typeof n=="boolean"?n==!0?await y():void 0:n;await h.userTasks.finishUserTask(s,t,i);let r={state:P.FlowNodeInstances.FlowNodeInstanceState.suspended,...e},a=await h.userTasks.query(r,{identity:i});return ze(a.userTasks[0])}async function ns(s,e={identity:!0}){switch(e?.identity){case!0:e.identity=await y();break;case!1:e.identity=void 0;break;case void 0:e.identity=await y();break}let t=await h.userTasks.query(s,e);return R(t)}async function dn(s={identity:!0}){switch(s?.identity){case!0:s.identity=await y();break;case!1:s.identity=void 0;break;case void 0:s.identity=await y();break}let e=await h.userTasks.query({state:P.FlowNodeInstances.FlowNodeInstanceState.suspended},s);return R(e)}async function ln(s,e={identity:!0}){switch(e?.identity){case!0:e.identity=await y();break;case!1:e.identity=void 0;break;case void 0:e.identity=await y();break}let t=await h.userTasks.query({processInstanceId:s,state:P.FlowNodeInstances.FlowNodeInstanceState.suspended},e);return R(t)}async function fn(s,e={identity:!0}){switch(e?.identity){case!0:e.identity=await y();break;case!1:e.identity=void 0;break;case void 0:e.identity=await y();break}let t=await h.userTasks.query({flowNodeId:s,state:P.FlowNodeInstances.FlowNodeInstanceState.suspended},e);return R(t)}async function is(s,e={identity:!0}){switch(e?.identity){case!0:e.identity=await y();break;case!1:e.identity=void 0;break;case void 0:e.identity=await y();break}let t=await h.userTasks.query({flowNodeInstanceId:s,state:P.FlowNodeInstances.FlowNodeInstanceState.suspended},{...e,limit:1});return t.userTasks.length===0?null:ze(t.userTasks[0])}async function hn(s,e={identity:!0}){switch(e?.identity){case!0:e.identity=await y();break;case!1:e.identity=void 0;break;case void 0:e.identity=await y();break}let t=await h.userTasks.query({correlationId:s,state:P.FlowNodeInstances.FlowNodeInstanceState.suspended},e);return R(t)}async function un(s,e){let t=s||await y(),n=await h.userTasks.query({state:P.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:t,...e}),i=n.userTasks.filter(r=>r.actualOwnerId===t.userId);return n.userTasks=i,R(n)}async function pn(s,e,t){await h.userTasks.reserveUserTaskInstance(s,e,t||s.userId)}async function mn(s,e){await h.userTasks.cancelUserTaskInstanceReservation(s,e)}async function yn(s,e){let t=s||await y(),n=await h.userTasks.query({state:P.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:t,...e}),i=n.userTasks.filter(r=>r.assignedUserIds?.includes(t.userId));return n.userTasks=i,R(n)}import{PHASE_DEVELOPMENT_SERVER as rs,PHASE_PRODUCTION_BUILD as os,PHASE_PRODUCTION_SERVER as as}from"next/dist/shared/lib/constants";var Ke=!1,oe=!1;function In(s={}){let{applicationSdk:e,...t}=s;return async(n,i)=>{oe=oe||n===os;let r=n===rs||n===as;return e?.useExternalTasks&&r&&!Ke&&!oe&&(Ke=!0,await Ne(e?.customExternalTasksDirPath)),{...t,experimental:{...t.experimental,serverComponentsExternalPackages:[...t.experimental?.serverComponentsExternalPackages||[],"esbuild"]}}}}import{redirect as cs}from"next/navigation";function kn(s){cs(s)}async function Rn(...s){return await h.processModels.startProcessInstance(...s)}async function qe(...s){await h.manualTasks.finishManualTask(...s)}async function Ge(...s){await h.userTasks.finishUserTask(...s)}async function $e(...s){await h.untypedTasks.finishTask(...s)}import{DataModels as ds}from"@5minds/processcube_engine_client";async function ls(){try{return y()}catch{return}}var Mn=async(s,e)=>{let t=await ls();e==="bpmn:UserTask"?await Ge(s,{},t):e==="bpmn:ManualTask"?await qe(s,t):e==="bpmn:Task"?await $e(s,t):console.error(`[@5minds/processcube_app_sdk:handlePlay] Unsupported flow node type: ${e}`)},Bn=async s=>{await Ye(s)},Hn=async(s,e,t)=>{await je(s,e,t)},jn=async s=>Me(s),Yn=async s=>Be(s,{sortSettings:{sortBy:ds.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"DESC"}}),zn=async s=>He(s);export{mn as cancelReservedUserTask,qe as finishManualTask,Mn as finishTask,$e as finishUntypedTask,Ge as finishUserTask,cn as finishUserTaskAndGetNext,Qs as getActiveProcessInstances,yn as getAssignedUserTasksByIdentity,js as getEngineClient,Yn as getFlowNodeInstances,Be as getFlowNodeInstancesByProcessInstanceId,He as getFlowNodeInstancesTriggeredByFlowNodeInstanceIds,y as getIdentity,jn as getProcessInstance,Me as getProcessInstanceById,un as getReservedUserTasksByIdentity,zn as getTriggeredFlowNodeInstances,ns as getUserTasks,is as getWaitingUserTaskByFlowNodeInstanceId,dn as getWaitingUserTasks,hn as getWaitingUserTasksByCorrelationId,fn as getWaitingUserTasksByFlowNodeId,ln as getWaitingUserTasksByProcessInstanceId,kn as navigateToUrl,pn as reserveUserTask,Hn as retryProcess,je as retryProcessInstance,Rn as startProcess,Bn as terminateProcess,Ye as terminateProcessInstance,Zs as waitForProcessEnd,an as waitForUserTask,In as withApplicationSdk};
|
|
1
|
+
var Hn=Object.create;var ds=Object.defineProperty;var Dn=Object.getOwnPropertyDescriptor;var Fn=Object.getOwnPropertyNames;var $n=Object.getPrototypeOf,Mn=Object.prototype.hasOwnProperty;var L=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,s)=>(typeof require<"u"?require:e)[s]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var x=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Un=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Fn(e))!Mn.call(t,n)&&n!==s&&ds(t,n,{get:()=>e[n],enumerable:!(r=Dn(e,n))||r.enumerable});return t};var Bn=(t,e,s)=>(s=t!=null?Hn($n(t)):{},Un(e||!t||!t.__esModule?ds(s,"default",{value:t,enumerable:!0}):s,t));var Ae=x((Tc,Es)=>{"use strict";var Wn=L("path"),ne="\\\\/",hs=`[^${ne}]`,ie="\\.",Gn="\\+",qn="\\?",Ue="\\/",Kn="(?=.)",ps="[^/]",lt=`(?:${Ue}|$)`,_s=`(?:^|${Ue})`,ut=`${ie}{1,2}${lt}`,jn=`(?!${ie})`,Vn=`(?!${_s}${ut})`,Yn=`(?!${ie}{0,1}${lt})`,zn=`(?!${ut})`,Xn=`[^.${Ue}]`,Qn=`${ps}*?`,gs={DOT_LITERAL:ie,PLUS_LITERAL:Gn,QMARK_LITERAL:qn,SLASH_LITERAL:Ue,ONE_CHAR:Kn,QMARK:ps,END_ANCHOR:lt,DOTS_SLASH:ut,NO_DOT:jn,NO_DOTS:Vn,NO_DOT_SLASH:Yn,NO_DOTS_SLASH:zn,QMARK_NO_DOT:Xn,STAR:Qn,START_ANCHOR:_s},Zn={...gs,SLASH_LITERAL:`[${ne}]`,QMARK:hs,STAR:`${hs}*?`,DOTS_SLASH:`${ie}{1,2}(?:[${ne}]|$)`,NO_DOT:`(?!${ie})`,NO_DOTS:`(?!(?:^|[${ne}])${ie}{1,2}(?:[${ne}]|$))`,NO_DOT_SLASH:`(?!${ie}{0,1}(?:[${ne}]|$))`,NO_DOTS_SLASH:`(?!${ie}{1,2}(?:[${ne}]|$))`,QMARK_NO_DOT:`[^.${ne}]`,START_ANCHOR:`(?:^|[${ne}])`,END_ANCHOR:`(?:[${ne}]|$)`},Jn={alnum:"a-zA-Z0-9",alpha:"a-zA-Z",ascii:"\\x00-\\x7F",blank:" \\t",cntrl:"\\x00-\\x1F\\x7F",digit:"0-9",graph:"\\x21-\\x7E",lower:"a-z",print:"\\x20-\\x7E ",punct:"\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",space:" \\t\\r\\n\\v\\f",upper:"A-Z",word:"A-Za-z0-9_",xdigit:"A-Fa-f0-9"};Es.exports={MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:Jn,REGEX_BACKSLASH:/\\(?![*+?^${}(|)[\]])/g,REGEX_NON_SPECIAL_CHARS:/^[^@![\].,$*+?^{}()|\\/]+/,REGEX_SPECIAL_CHARS:/[-*+?.^${}(|)[\]]/,REGEX_SPECIAL_CHARS_BACKREF:/(\\?)((\W)(\3*))/g,REGEX_SPECIAL_CHARS_GLOBAL:/([-*+?.^${}(|)[\]])/g,REGEX_REMOVE_BACKSLASH:/(?:\[.*?[^\\]\]|\\(?=.))/g,REPLACEMENTS:{"***":"*","**/**":"**","**/**/**":"**"},CHAR_0:48,CHAR_9:57,CHAR_UPPERCASE_A:65,CHAR_LOWERCASE_A:97,CHAR_UPPERCASE_Z:90,CHAR_LOWERCASE_Z:122,CHAR_LEFT_PARENTHESES:40,CHAR_RIGHT_PARENTHESES:41,CHAR_ASTERISK:42,CHAR_AMPERSAND:38,CHAR_AT:64,CHAR_BACKWARD_SLASH:92,CHAR_CARRIAGE_RETURN:13,CHAR_CIRCUMFLEX_ACCENT:94,CHAR_COLON:58,CHAR_COMMA:44,CHAR_DOT:46,CHAR_DOUBLE_QUOTE:34,CHAR_EQUAL:61,CHAR_EXCLAMATION_MARK:33,CHAR_FORM_FEED:12,CHAR_FORWARD_SLASH:47,CHAR_GRAVE_ACCENT:96,CHAR_HASH:35,CHAR_HYPHEN_MINUS:45,CHAR_LEFT_ANGLE_BRACKET:60,CHAR_LEFT_CURLY_BRACE:123,CHAR_LEFT_SQUARE_BRACKET:91,CHAR_LINE_FEED:10,CHAR_NO_BREAK_SPACE:160,CHAR_PERCENT:37,CHAR_PLUS:43,CHAR_QUESTION_MARK:63,CHAR_RIGHT_ANGLE_BRACKET:62,CHAR_RIGHT_CURLY_BRACE:125,CHAR_RIGHT_SQUARE_BRACKET:93,CHAR_SEMICOLON:59,CHAR_SINGLE_QUOTE:39,CHAR_SPACE:32,CHAR_TAB:9,CHAR_UNDERSCORE:95,CHAR_VERTICAL_LINE:124,CHAR_ZERO_WIDTH_NOBREAK_SPACE:65279,SEP:Wn.sep,extglobChars(t){return{"!":{type:"negate",open:"(?:(?!(?:",close:`))${t.STAR})`},"?":{type:"qmark",open:"(?:",close:")?"},"+":{type:"plus",open:"(?:",close:")+"},"*":{type:"star",open:"(?:",close:")*"},"@":{type:"at",open:"(?:",close:")"}}},globChars(t){return t===!0?Zn:gs}}});var Be=x(z=>{"use strict";var ei=L("path"),ti=process.platform==="win32",{REGEX_BACKSLASH:si,REGEX_REMOVE_BACKSLASH:ri,REGEX_SPECIAL_CHARS:ni,REGEX_SPECIAL_CHARS_GLOBAL:ii}=Ae();z.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);z.hasRegexChars=t=>ni.test(t);z.isRegexChar=t=>t.length===1&&z.hasRegexChars(t);z.escapeRegex=t=>t.replace(ii,"\\$1");z.toPosixSlashes=t=>t.replace(si,"/");z.removeBackslashes=t=>t.replace(ri,e=>e==="\\"?"":e);z.supportsLookbehinds=()=>{let t=process.version.slice(1).split(".").map(Number);return t.length===3&&t[0]>=9||t[0]===8&&t[1]>=10};z.isWindows=t=>t&&typeof t.windows=="boolean"?t.windows:ti===!0||ei.sep==="\\";z.escapeLast=(t,e,s)=>{let r=t.lastIndexOf(e,s);return r===-1?t:t[r-1]==="\\"?z.escapeLast(t,e,r-1):`${t.slice(0,r)}\\${t.slice(r)}`};z.removePrefix=(t,e={})=>{let s=t;return s.startsWith("./")&&(s=s.slice(2),e.prefix="./"),s};z.wrapOutput=(t,e={},s={})=>{let r=s.contains?"":"^",n=s.contains?"":"$",o=`${r}(?:${t})${n}`;return e.negated===!0&&(o=`(?:^(?!${o}).*$)`),o}});var Is=x((Ic,Ss)=>{"use strict";var ys=Be(),{CHAR_ASTERISK:ft,CHAR_AT:oi,CHAR_BACKWARD_SLASH:Te,CHAR_COMMA:ai,CHAR_DOT:dt,CHAR_EXCLAMATION_MARK:ht,CHAR_FORWARD_SLASH:Ts,CHAR_LEFT_CURLY_BRACE:pt,CHAR_LEFT_PARENTHESES:_t,CHAR_LEFT_SQUARE_BRACKET:ci,CHAR_PLUS:li,CHAR_QUESTION_MARK:ms,CHAR_RIGHT_CURLY_BRACE:ui,CHAR_RIGHT_PARENTHESES:ws,CHAR_RIGHT_SQUARE_BRACKET:fi}=Ae(),Rs=t=>t===Ts||t===Te,As=t=>{t.isPrefix!==!0&&(t.depth=t.isGlobstar?1/0:1)},di=(t,e)=>{let s=e||{},r=t.length-1,n=s.parts===!0||s.scanToEnd===!0,o=[],i=[],a=[],c=t,f=-1,u=0,d=0,l=!1,y=!1,E=!1,w=!1,v=!1,F=!1,Y=!1,$=!1,te=!1,q=!1,ce=0,K,A,b={value:"",depth:0,isGlob:!1},G=()=>f>=r,_=()=>c.charCodeAt(f+1),O=()=>(K=A,c.charCodeAt(++f));for(;f<r;){A=O();let j;if(A===Te){Y=b.backslashes=!0,A=O(),A===pt&&(F=!0);continue}if(F===!0||A===pt){for(ce++;G()!==!0&&(A=O());){if(A===Te){Y=b.backslashes=!0,O();continue}if(A===pt){ce++;continue}if(F!==!0&&A===dt&&(A=O())===dt){if(l=b.isBrace=!0,E=b.isGlob=!0,q=!0,n===!0)continue;break}if(F!==!0&&A===ai){if(l=b.isBrace=!0,E=b.isGlob=!0,q=!0,n===!0)continue;break}if(A===ui&&(ce--,ce===0)){F=!1,l=b.isBrace=!0,q=!0;break}}if(n===!0)continue;break}if(A===Ts){if(o.push(f),i.push(b),b={value:"",depth:0,isGlob:!1},q===!0)continue;if(K===dt&&f===u+1){u+=2;continue}d=f+1;continue}if(s.noext!==!0&&(A===li||A===oi||A===ft||A===ms||A===ht)===!0&&_()===_t){if(E=b.isGlob=!0,w=b.isExtglob=!0,q=!0,A===ht&&f===u&&(te=!0),n===!0){for(;G()!==!0&&(A=O());){if(A===Te){Y=b.backslashes=!0,A=O();continue}if(A===ws){E=b.isGlob=!0,q=!0;break}}continue}break}if(A===ft){if(K===ft&&(v=b.isGlobstar=!0),E=b.isGlob=!0,q=!0,n===!0)continue;break}if(A===ms){if(E=b.isGlob=!0,q=!0,n===!0)continue;break}if(A===ci){for(;G()!==!0&&(j=O());){if(j===Te){Y=b.backslashes=!0,O();continue}if(j===fi){y=b.isBracket=!0,E=b.isGlob=!0,q=!0;break}}if(n===!0)continue;break}if(s.nonegate!==!0&&A===ht&&f===u){$=b.negated=!0,u++;continue}if(s.noparen!==!0&&A===_t){if(E=b.isGlob=!0,n===!0){for(;G()!==!0&&(A=O());){if(A===_t){Y=b.backslashes=!0,A=O();continue}if(A===ws){q=!0;break}}continue}break}if(E===!0){if(q=!0,n===!0)continue;break}}s.noext===!0&&(w=!1,E=!1);let P=c,le="",h="";u>0&&(le=c.slice(0,u),c=c.slice(u),d-=u),P&&E===!0&&d>0?(P=c.slice(0,d),h=c.slice(d)):E===!0?(P="",h=c):P=c,P&&P!==""&&P!=="/"&&P!==c&&Rs(P.charCodeAt(P.length-1))&&(P=P.slice(0,-1)),s.unescape===!0&&(h&&(h=ys.removeBackslashes(h)),P&&Y===!0&&(P=ys.removeBackslashes(P)));let p={prefix:le,input:t,start:u,base:P,glob:h,isBrace:l,isBracket:y,isGlob:E,isExtglob:w,isGlobstar:v,negated:$,negatedExtglob:te};if(s.tokens===!0&&(p.maxDepth=0,Rs(A)||i.push(b),p.tokens=i),s.parts===!0||s.tokens===!0){let j;for(let C=0;C<o.length;C++){let se=j?j+1:u,re=o[C],X=t.slice(se,re);s.tokens&&(C===0&&u!==0?(i[C].isPrefix=!0,i[C].value=le):i[C].value=X,As(i[C]),p.maxDepth+=i[C].depth),(C!==0||X!=="")&&a.push(X),j=re}if(j&&j+1<t.length){let C=t.slice(j+1);a.push(C),s.tokens&&(i[i.length-1].value=C,As(i[i.length-1]),p.maxDepth+=i[i.length-1].depth)}p.slashes=o,p.parts=a}return p};Ss.exports=di});var xs=x((Cc,bs)=>{"use strict";var We=Ae(),Q=Be(),{MAX_LENGTH:Ge,POSIX_REGEX_SOURCE:hi,REGEX_NON_SPECIAL_CHARS:pi,REGEX_SPECIAL_CHARS_BACKREF:_i,REPLACEMENTS:Cs}=We,gi=(t,e)=>{if(typeof e.expandRange=="function")return e.expandRange(...t,e);t.sort();let s=`[${t.join("-")}]`;try{new RegExp(s)}catch{return t.map(n=>Q.escapeRegex(n)).join("..")}return s},Ee=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,gt=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=Cs[t]||t;let s={...e},r=typeof s.maxLength=="number"?Math.min(Ge,s.maxLength):Ge,n=t.length;if(n>r)throw new SyntaxError(`Input length: ${n}, exceeds maximum allowed length: ${r}`);let o={type:"bos",value:"",output:s.prepend||""},i=[o],a=s.capture?"":"?:",c=Q.isWindows(e),f=We.globChars(c),u=We.extglobChars(f),{DOT_LITERAL:d,PLUS_LITERAL:l,SLASH_LITERAL:y,ONE_CHAR:E,DOTS_SLASH:w,NO_DOT:v,NO_DOT_SLASH:F,NO_DOTS_SLASH:Y,QMARK:$,QMARK_NO_DOT:te,STAR:q,START_ANCHOR:ce}=f,K=m=>`(${a}(?:(?!${ce}${m.dot?w:d}).)*?)`,A=s.dot?"":v,b=s.dot?$:te,G=s.bash===!0?K(s):q;s.capture&&(G=`(${G})`),typeof s.noext=="boolean"&&(s.noextglob=s.noext);let _={input:t,index:-1,start:0,dot:s.dot===!0,consumed:"",output:"",prefix:"",backtrack:!1,negated:!1,brackets:0,braces:0,parens:0,quotes:0,globstar:!1,tokens:i};t=Q.removePrefix(t,_),n=t.length;let O=[],P=[],le=[],h=o,p,j=()=>_.index===n-1,C=_.peek=(m=1)=>t[_.index+m],se=_.advance=()=>t[++_.index]||"",re=()=>t.slice(_.index+1),X=(m="",N=0)=>{_.consumed+=m,_.index+=N},De=m=>{_.output+=m.output!=null?m.output:m.value,X(m.value)},On=()=>{let m=1;for(;C()==="!"&&(C(2)!=="("||C(3)==="?");)se(),_.start++,m++;return m%2===0?!1:(_.negated=!0,_.start++,!0)},Fe=m=>{_[m]++,le.push(m)},ue=m=>{_[m]--,le.pop()},I=m=>{if(h.type==="globstar"){let N=_.braces>0&&(m.type==="comma"||m.type==="brace"),g=m.extglob===!0||O.length&&(m.type==="pipe"||m.type==="paren");m.type!=="slash"&&m.type!=="paren"&&!N&&!g&&(_.output=_.output.slice(0,-h.output.length),h.type="star",h.value="*",h.output=G,_.output+=h.output)}if(O.length&&m.type!=="paren"&&(O[O.length-1].inner+=m.value),(m.value||m.output)&&De(m),h&&h.type==="text"&&m.type==="text"){h.value+=m.value,h.output=(h.output||"")+m.value;return}m.prev=h,i.push(m),h=m},$e=(m,N)=>{let g={...u[N],conditions:1,inner:""};g.prev=h,g.parens=_.parens,g.output=_.output;let S=(s.capture?"(":"")+g.open;Fe("parens"),I({type:m,value:N,output:_.output?"":E}),I({type:"paren",extglob:!0,value:se(),output:S}),O.push(g)},Ln=m=>{let N=m.close+(s.capture?")":""),g;if(m.type==="negate"){let S=G;if(m.inner&&m.inner.length>1&&m.inner.includes("/")&&(S=K(s)),(S!==G||j()||/^\)+$/.test(re()))&&(N=m.close=`)$))${S}`),m.inner.includes("*")&&(g=re())&&/^\.[^\\/.]+$/.test(g)){let D=gt(g,{...e,fastpaths:!1}).output;N=m.close=`)${D})${S})`}m.prev.type==="bos"&&(_.negatedExtglob=!0)}I({type:"paren",extglob:!0,value:p,output:N}),ue("parens")};if(s.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(t)){let m=!1,N=t.replace(_i,(g,S,D,V,U,ct)=>V==="\\"?(m=!0,g):V==="?"?S?S+V+(U?$.repeat(U.length):""):ct===0?b+(U?$.repeat(U.length):""):$.repeat(D.length):V==="."?d.repeat(D.length):V==="*"?S?S+V+(U?G:""):G:S?g:`\\${g}`);return m===!0&&(s.unescape===!0?N=N.replace(/\\/g,""):N=N.replace(/\\+/g,g=>g.length%2===0?"\\\\":g?"\\":"")),N===t&&s.contains===!0?(_.output=t,_):(_.output=Q.wrapOutput(N,_,e),_)}for(;!j();){if(p=se(),p==="\0")continue;if(p==="\\"){let g=C();if(g==="/"&&s.bash!==!0||g==="."||g===";")continue;if(!g){p+="\\",I({type:"text",value:p});continue}let S=/^\\+/.exec(re()),D=0;if(S&&S[0].length>2&&(D=S[0].length,_.index+=D,D%2!==0&&(p+="\\")),s.unescape===!0?p=se():p+=se(),_.brackets===0){I({type:"text",value:p});continue}}if(_.brackets>0&&(p!=="]"||h.value==="["||h.value==="[^")){if(s.posix!==!1&&p===":"){let g=h.value.slice(1);if(g.includes("[")&&(h.posix=!0,g.includes(":"))){let S=h.value.lastIndexOf("["),D=h.value.slice(0,S),V=h.value.slice(S+2),U=hi[V];if(U){h.value=D+U,_.backtrack=!0,se(),!o.output&&i.indexOf(h)===1&&(o.output=E);continue}}}(p==="["&&C()!==":"||p==="-"&&C()==="]")&&(p=`\\${p}`),p==="]"&&(h.value==="["||h.value==="[^")&&(p=`\\${p}`),s.posix===!0&&p==="!"&&h.value==="["&&(p="^"),h.value+=p,De({value:p});continue}if(_.quotes===1&&p!=='"'){p=Q.escapeRegex(p),h.value+=p,De({value:p});continue}if(p==='"'){_.quotes=_.quotes===1?0:1,s.keepQuotes===!0&&I({type:"text",value:p});continue}if(p==="("){Fe("parens"),I({type:"paren",value:p});continue}if(p===")"){if(_.parens===0&&s.strictBrackets===!0)throw new SyntaxError(Ee("opening","("));let g=O[O.length-1];if(g&&_.parens===g.parens+1){Ln(O.pop());continue}I({type:"paren",value:p,output:_.parens?")":"\\)"}),ue("parens");continue}if(p==="["){if(s.nobracket===!0||!re().includes("]")){if(s.nobracket!==!0&&s.strictBrackets===!0)throw new SyntaxError(Ee("closing","]"));p=`\\${p}`}else Fe("brackets");I({type:"bracket",value:p});continue}if(p==="]"){if(s.nobracket===!0||h&&h.type==="bracket"&&h.value.length===1){I({type:"text",value:p,output:`\\${p}`});continue}if(_.brackets===0){if(s.strictBrackets===!0)throw new SyntaxError(Ee("opening","["));I({type:"text",value:p,output:`\\${p}`});continue}ue("brackets");let g=h.value.slice(1);if(h.posix!==!0&&g[0]==="^"&&!g.includes("/")&&(p=`/${p}`),h.value+=p,De({value:p}),s.literalBrackets===!1||Q.hasRegexChars(g))continue;let S=Q.escapeRegex(h.value);if(_.output=_.output.slice(0,-h.value.length),s.literalBrackets===!0){_.output+=S,h.value=S;continue}h.value=`(${a}${S}|${h.value})`,_.output+=h.value;continue}if(p==="{"&&s.nobrace!==!0){Fe("braces");let g={type:"brace",value:p,output:"(",outputIndex:_.output.length,tokensIndex:_.tokens.length};P.push(g),I(g);continue}if(p==="}"){let g=P[P.length-1];if(s.nobrace===!0||!g){I({type:"text",value:p,output:p});continue}let S=")";if(g.dots===!0){let D=i.slice(),V=[];for(let U=D.length-1;U>=0&&(i.pop(),D[U].type!=="brace");U--)D[U].type!=="dots"&&V.unshift(D[U].value);S=gi(V,s),_.backtrack=!0}if(g.comma!==!0&&g.dots!==!0){let D=_.output.slice(0,g.outputIndex),V=_.tokens.slice(g.tokensIndex);g.value=g.output="\\{",p=S="\\}",_.output=D;for(let U of V)_.output+=U.output||U.value}I({type:"brace",value:p,output:S}),ue("braces"),P.pop();continue}if(p==="|"){O.length>0&&O[O.length-1].conditions++,I({type:"text",value:p});continue}if(p===","){let g=p,S=P[P.length-1];S&&le[le.length-1]==="braces"&&(S.comma=!0,g="|"),I({type:"comma",value:p,output:g});continue}if(p==="/"){if(h.type==="dot"&&_.index===_.start+1){_.start=_.index+1,_.consumed="",_.output="",i.pop(),h=o;continue}I({type:"slash",value:p,output:y});continue}if(p==="."){if(_.braces>0&&h.type==="dot"){h.value==="."&&(h.output=d);let g=P[P.length-1];h.type="dots",h.output+=p,h.value+=p,g.dots=!0;continue}if(_.braces+_.parens===0&&h.type!=="bos"&&h.type!=="slash"){I({type:"text",value:p,output:d});continue}I({type:"dot",value:p,output:d});continue}if(p==="?"){if(!(h&&h.value==="(")&&s.noextglob!==!0&&C()==="("&&C(2)!=="?"){$e("qmark",p);continue}if(h&&h.type==="paren"){let S=C(),D=p;if(S==="<"&&!Q.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(h.value==="("&&!/[!=<:]/.test(S)||S==="<"&&!/<([!=]|\w+>)/.test(re()))&&(D=`\\${p}`),I({type:"text",value:p,output:D});continue}if(s.dot!==!0&&(h.type==="slash"||h.type==="bos")){I({type:"qmark",value:p,output:te});continue}I({type:"qmark",value:p,output:$});continue}if(p==="!"){if(s.noextglob!==!0&&C()==="("&&(C(2)!=="?"||!/[!=<:]/.test(C(3)))){$e("negate",p);continue}if(s.nonegate!==!0&&_.index===0){On();continue}}if(p==="+"){if(s.noextglob!==!0&&C()==="("&&C(2)!=="?"){$e("plus",p);continue}if(h&&h.value==="("||s.regex===!1){I({type:"plus",value:p,output:l});continue}if(h&&(h.type==="bracket"||h.type==="paren"||h.type==="brace")||_.parens>0){I({type:"plus",value:p});continue}I({type:"plus",value:l});continue}if(p==="@"){if(s.noextglob!==!0&&C()==="("&&C(2)!=="?"){I({type:"at",extglob:!0,value:p,output:""});continue}I({type:"text",value:p});continue}if(p!=="*"){(p==="$"||p==="^")&&(p=`\\${p}`);let g=pi.exec(re());g&&(p+=g[0],_.index+=g[0].length),I({type:"text",value:p});continue}if(h&&(h.type==="globstar"||h.star===!0)){h.type="star",h.star=!0,h.value+=p,h.output=G,_.backtrack=!0,_.globstar=!0,X(p);continue}let m=re();if(s.noextglob!==!0&&/^\([^?]/.test(m)){$e("star",p);continue}if(h.type==="star"){if(s.noglobstar===!0){X(p);continue}let g=h.prev,S=g.prev,D=g.type==="slash"||g.type==="bos",V=S&&(S.type==="star"||S.type==="globstar");if(s.bash===!0&&(!D||m[0]&&m[0]!=="/")){I({type:"star",value:p,output:""});continue}let U=_.braces>0&&(g.type==="comma"||g.type==="brace"),ct=O.length&&(g.type==="pipe"||g.type==="paren");if(!D&&g.type!=="paren"&&!U&&!ct){I({type:"star",value:p,output:""});continue}for(;m.slice(0,3)==="/**";){let Me=t[_.index+4];if(Me&&Me!=="/")break;m=m.slice(3),X("/**",3)}if(g.type==="bos"&&j()){h.type="globstar",h.value+=p,h.output=K(s),_.output=h.output,_.globstar=!0,X(p);continue}if(g.type==="slash"&&g.prev.type!=="bos"&&!V&&j()){_.output=_.output.slice(0,-(g.output+h.output).length),g.output=`(?:${g.output}`,h.type="globstar",h.output=K(s)+(s.strictSlashes?")":"|$)"),h.value+=p,_.globstar=!0,_.output+=g.output+h.output,X(p);continue}if(g.type==="slash"&&g.prev.type!=="bos"&&m[0]==="/"){let Me=m[1]!==void 0?"|$":"";_.output=_.output.slice(0,-(g.output+h.output).length),g.output=`(?:${g.output}`,h.type="globstar",h.output=`${K(s)}${y}|${y}${Me})`,h.value+=p,_.output+=g.output+h.output,_.globstar=!0,X(p+se()),I({type:"slash",value:"/",output:""});continue}if(g.type==="bos"&&m[0]==="/"){h.type="globstar",h.value+=p,h.output=`(?:^|${y}|${K(s)}${y})`,_.output=h.output,_.globstar=!0,X(p+se()),I({type:"slash",value:"/",output:""});continue}_.output=_.output.slice(0,-h.output.length),h.type="globstar",h.output=K(s),h.value+=p,_.output+=h.output,_.globstar=!0,X(p);continue}let N={type:"star",value:p,output:G};if(s.bash===!0){N.output=".*?",(h.type==="bos"||h.type==="slash")&&(N.output=A+N.output),I(N);continue}if(h&&(h.type==="bracket"||h.type==="paren")&&s.regex===!0){N.output=p,I(N);continue}(_.index===_.start||h.type==="slash"||h.type==="dot")&&(h.type==="dot"?(_.output+=F,h.output+=F):s.dot===!0?(_.output+=Y,h.output+=Y):(_.output+=A,h.output+=A),C()!=="*"&&(_.output+=E,h.output+=E)),I(N)}for(;_.brackets>0;){if(s.strictBrackets===!0)throw new SyntaxError(Ee("closing","]"));_.output=Q.escapeLast(_.output,"["),ue("brackets")}for(;_.parens>0;){if(s.strictBrackets===!0)throw new SyntaxError(Ee("closing",")"));_.output=Q.escapeLast(_.output,"("),ue("parens")}for(;_.braces>0;){if(s.strictBrackets===!0)throw new SyntaxError(Ee("closing","}"));_.output=Q.escapeLast(_.output,"{"),ue("braces")}if(s.strictSlashes!==!0&&(h.type==="star"||h.type==="bracket")&&I({type:"maybe_slash",value:"",output:`${y}?`}),_.backtrack===!0){_.output="";for(let m of _.tokens)_.output+=m.output!=null?m.output:m.value,m.suffix&&(_.output+=m.suffix)}return _};gt.fastpaths=(t,e)=>{let s={...e},r=typeof s.maxLength=="number"?Math.min(Ge,s.maxLength):Ge,n=t.length;if(n>r)throw new SyntaxError(`Input length: ${n}, exceeds maximum allowed length: ${r}`);t=Cs[t]||t;let o=Q.isWindows(e),{DOT_LITERAL:i,SLASH_LITERAL:a,ONE_CHAR:c,DOTS_SLASH:f,NO_DOT:u,NO_DOTS:d,NO_DOTS_SLASH:l,STAR:y,START_ANCHOR:E}=We.globChars(o),w=s.dot?d:u,v=s.dot?l:u,F=s.capture?"":"?:",Y={negated:!1,prefix:""},$=s.bash===!0?".*?":y;s.capture&&($=`(${$})`);let te=A=>A.noglobstar===!0?$:`(${F}(?:(?!${E}${A.dot?f:i}).)*?)`,q=A=>{switch(A){case"*":return`${w}${c}${$}`;case".*":return`${i}${c}${$}`;case"*.*":return`${w}${$}${i}${c}${$}`;case"*/*":return`${w}${$}${a}${c}${v}${$}`;case"**":return w+te(s);case"**/*":return`(?:${w}${te(s)}${a})?${v}${c}${$}`;case"**/*.*":return`(?:${w}${te(s)}${a})?${v}${$}${i}${c}${$}`;case"**/.*":return`(?:${w}${te(s)}${a})?${i}${c}${$}`;default:{let b=/^(.*?)\.(\w+)$/.exec(A);if(!b)return;let G=q(b[1]);return G?G+i+b[2]:void 0}}},ce=Q.removePrefix(t,Y),K=q(ce);return K&&s.strictSlashes!==!0&&(K+=`${a}?`),K};bs.exports=gt});var vs=x((bc,ks)=>{"use strict";var Ei=L("path"),yi=Is(),Et=xs(),yt=Be(),mi=Ae(),wi=t=>t&&typeof t=="object"&&!Array.isArray(t),M=(t,e,s=!1)=>{if(Array.isArray(t)){let u=t.map(l=>M(l,e,s));return l=>{for(let y of u){let E=y(l);if(E)return E}return!1}}let r=wi(t)&&t.tokens&&t.input;if(t===""||typeof t!="string"&&!r)throw new TypeError("Expected pattern to be a non-empty string");let n=e||{},o=yt.isWindows(e),i=r?M.compileRe(t,e):M.makeRe(t,e,!1,!0),a=i.state;delete i.state;let c=()=>!1;if(n.ignore){let u={...e,ignore:null,onMatch:null,onResult:null};c=M(n.ignore,u,s)}let f=(u,d=!1)=>{let{isMatch:l,match:y,output:E}=M.test(u,i,e,{glob:t,posix:o}),w={glob:t,state:a,regex:i,posix:o,input:u,output:E,match:y,isMatch:l};return typeof n.onResult=="function"&&n.onResult(w),l===!1?(w.isMatch=!1,d?w:!1):c(u)?(typeof n.onIgnore=="function"&&n.onIgnore(w),w.isMatch=!1,d?w:!1):(typeof n.onMatch=="function"&&n.onMatch(w),d?w:!0)};return s&&(f.state=a),f};M.test=(t,e,s,{glob:r,posix:n}={})=>{if(typeof t!="string")throw new TypeError("Expected input to be a string");if(t==="")return{isMatch:!1,output:""};let o=s||{},i=o.format||(n?yt.toPosixSlashes:null),a=t===r,c=a&&i?i(t):t;return a===!1&&(c=i?i(t):t,a=c===r),(a===!1||o.capture===!0)&&(o.matchBase===!0||o.basename===!0?a=M.matchBase(t,e,s,n):a=e.exec(c)),{isMatch:!!a,match:a,output:c}};M.matchBase=(t,e,s,r=yt.isWindows(s))=>(e instanceof RegExp?e:M.makeRe(e,s)).test(Ei.basename(t));M.isMatch=(t,e,s)=>M(e,s)(t);M.parse=(t,e)=>Array.isArray(t)?t.map(s=>M.parse(s,e)):Et(t,{...e,fastpaths:!1});M.scan=(t,e)=>yi(t,e);M.compileRe=(t,e,s=!1,r=!1)=>{if(s===!0)return t.output;let n=e||{},o=n.contains?"":"^",i=n.contains?"":"$",a=`${o}(?:${t.output})${i}`;t&&t.negated===!0&&(a=`^(?!${a}).*$`);let c=M.toRegex(a,e);return r===!0&&(c.state=t),c};M.makeRe=(t,e={},s=!1,r=!1)=>{if(!t||typeof t!="string")throw new TypeError("Expected a non-empty string");let n={negated:!1,fastpaths:!0};return e.fastpaths!==!1&&(t[0]==="."||t[0]==="*")&&(n.output=Et.fastpaths(t,e)),n.output||(n=Et(t,e)),M.compileRe(n,e,s,r)};M.toRegex=(t,e)=>{try{let s=e||{};return new RegExp(t,s.flags||(s.nocase?"i":""))}catch(s){if(e&&e.debug===!0)throw s;return/$^/}};M.constants=mi;ks.exports=M});var mt=x((xc,Ps)=>{"use strict";Ps.exports=vs()});var Ms=x((kc,$s)=>{"use strict";var Ie=L("fs"),{Readable:Ri}=L("stream"),Se=L("path"),{promisify:Ve}=L("util"),wt=mt(),Ai=Ve(Ie.readdir),Ti=Ve(Ie.stat),Ns=Ve(Ie.lstat),Si=Ve(Ie.realpath),Ii="!",Ds="READDIRP_RECURSIVE_ERROR",Ci=new Set(["ENOENT","EPERM","EACCES","ELOOP",Ds]),Rt="files",Fs="directories",Ke="files_directories",qe="all",Os=[Rt,Fs,Ke,qe],bi=t=>Ci.has(t.code),[Ls,xi]=process.versions.node.split(".").slice(0,2).map(t=>Number.parseInt(t,10)),ki=process.platform==="win32"&&(Ls>10||Ls===10&&xi>=5),Hs=t=>{if(t!==void 0){if(typeof t=="function")return t;if(typeof t=="string"){let e=wt(t.trim());return s=>e(s.basename)}if(Array.isArray(t)){let e=[],s=[];for(let r of t){let n=r.trim();n.charAt(0)===Ii?s.push(wt(n.slice(1))):e.push(wt(n))}return s.length>0?e.length>0?r=>e.some(n=>n(r.basename))&&!s.some(n=>n(r.basename)):r=>!s.some(n=>n(r.basename)):r=>e.some(n=>n(r.basename))}}},je=class t extends Ri{static get defaultOptions(){return{root:".",fileFilter:e=>!0,directoryFilter:e=>!0,type:Rt,lstat:!1,depth:2147483648,alwaysStat:!1}}constructor(e={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:e.highWaterMark||4096});let s={...t.defaultOptions,...e},{root:r,type:n}=s;this._fileFilter=Hs(s.fileFilter),this._directoryFilter=Hs(s.directoryFilter);let o=s.lstat?Ns:Ti;ki?this._stat=i=>o(i,{bigint:!0}):this._stat=o,this._maxDepth=s.depth,this._wantsDir=[Fs,Ke,qe].includes(n),this._wantsFile=[Rt,Ke,qe].includes(n),this._wantsEverything=n===qe,this._root=Se.resolve(r),this._isDirent="Dirent"in Ie&&!s.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(r,1)],this.reading=!1,this.parent=void 0}async _read(e){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&e>0;){let{path:s,depth:r,files:n=[]}=this.parent||{};if(n.length>0){let o=n.splice(0,e).map(i=>this._formatEntry(i,s));for(let i of await Promise.all(o)){if(this.destroyed)return;let a=await this._getEntryType(i);a==="directory"&&this._directoryFilter(i)?(r<=this._maxDepth&&this.parents.push(this._exploreDir(i.fullPath,r+1)),this._wantsDir&&(this.push(i),e--)):(a==="file"||this._includeAsFile(i))&&this._fileFilter(i)&&this._wantsFile&&(this.push(i),e--)}}else{let o=this.parents.pop();if(!o){this.push(null);break}if(this.parent=await o,this.destroyed)return}}}catch(s){this.destroy(s)}finally{this.reading=!1}}}async _exploreDir(e,s){let r;try{r=await Ai(e,this._rdOptions)}catch(n){this._onError(n)}return{files:r,depth:s,path:e}}async _formatEntry(e,s){let r;try{let n=this._isDirent?e.name:e,o=Se.resolve(Se.join(s,n));r={path:Se.relative(this._root,o),fullPath:o,basename:n},r[this._statsProp]=this._isDirent?e:await this._stat(o)}catch(n){this._onError(n)}return r}_onError(e){bi(e)&&!this.destroyed?this.emit("warn",e):this.destroy(e)}async _getEntryType(e){let s=e&&e[this._statsProp];if(s){if(s.isFile())return"file";if(s.isDirectory())return"directory";if(s&&s.isSymbolicLink()){let r=e.fullPath;try{let n=await Si(r),o=await Ns(n);if(o.isFile())return"file";if(o.isDirectory()){let i=n.length;if(r.startsWith(n)&&r.substr(i,1)===Se.sep){let a=new Error(`Circular symlink detected: "${r}" points to "${n}"`);return a.code=Ds,this._onError(a)}return"directory"}}catch(n){this._onError(n)}}}}_includeAsFile(e){let s=e&&e[this._statsProp];return s&&this._wantsEverything&&!s.isDirectory()}},ye=(t,e={})=>{let s=e.entryType||e.type;if(s==="both"&&(s=Ke),s&&(e.type=s),t){if(typeof t!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(s&&!Os.includes(s))throw new Error(`readdirp: Invalid type passed. Use one of ${Os.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new je(e)},vi=(t,e={})=>new Promise((s,r)=>{let n=[];ye(t,e).on("data",o=>n.push(o)).on("end",()=>s(n)).on("error",o=>r(o))});ye.promise=vi;ye.ReaddirpStream=je;ye.default=ye;$s.exports=ye});var At=x((vc,Us)=>{Us.exports=function(t,e){if(typeof t!="string")throw new TypeError("expected path to be a string");if(t==="\\"||t==="/")return"/";var s=t.length;if(s<=1)return t;var r="";if(s>4&&t[3]==="\\"){var n=t[2];(n==="?"||n===".")&&t.slice(0,2)==="\\\\"&&(t=t.slice(2),r="//")}var o=t.split(/[/\\]+/);return e!==!1&&o[o.length-1]===""&&o.pop(),r+o.join("/")}});var js=x((qs,Ks)=>{"use strict";Object.defineProperty(qs,"__esModule",{value:!0});var Gs=mt(),Pi=At(),Bs="!",Ni={returnIndex:!1},Oi=t=>Array.isArray(t)?t:[t],Li=(t,e)=>{if(typeof t=="function")return t;if(typeof t=="string"){let s=Gs(t,e);return r=>t===r||s(r)}return t instanceof RegExp?s=>t.test(s):s=>!1},Ws=(t,e,s,r)=>{let n=Array.isArray(s),o=n?s[0]:s;if(!n&&typeof o!="string")throw new TypeError("anymatch: second argument must be a string: got "+Object.prototype.toString.call(o));let i=Pi(o,!1);for(let c=0;c<e.length;c++){let f=e[c];if(f(i))return r?-1:!1}let a=n&&[i].concat(s.slice(1));for(let c=0;c<t.length;c++){let f=t[c];if(n?f(...a):f(i))return r?c:!0}return r?-1:!1},Tt=(t,e,s=Ni)=>{if(t==null)throw new TypeError("anymatch: specify first argument");let r=typeof s=="boolean"?{returnIndex:s}:s,n=r.returnIndex||!1,o=Oi(t),i=o.filter(c=>typeof c=="string"&&c.charAt(0)===Bs).map(c=>c.slice(1)).map(c=>Gs(c,r)),a=o.filter(c=>typeof c!="string"||typeof c=="string"&&c.charAt(0)!==Bs).map(c=>Li(c,r));return e==null?(c,f=!1)=>Ws(a,i,c,typeof f=="boolean"?f:!1):Ws(a,i,e,n)};Tt.default=Tt;Ks.exports=Tt});var Ys=x((Pc,Vs)=>{Vs.exports=function(e){if(typeof e!="string"||e==="")return!1;for(var s;s=/(\\).|([@?!+*]\(.*\))/g.exec(e);){if(s[2])return!0;e=e.slice(s.index+s[0].length)}return!1}});var St=x((Nc,Xs)=>{var Hi=Ys(),zs={"{":"}","(":")","[":"]"},Di=function(t){if(t[0]==="!")return!0;for(var e=0,s=-2,r=-2,n=-2,o=-2,i=-2;e<t.length;){if(t[e]==="*"||t[e+1]==="?"&&/[\].+)]/.test(t[e])||r!==-1&&t[e]==="["&&t[e+1]!=="]"&&(r<e&&(r=t.indexOf("]",e)),r>e&&(i===-1||i>r||(i=t.indexOf("\\",e),i===-1||i>r)))||n!==-1&&t[e]==="{"&&t[e+1]!=="}"&&(n=t.indexOf("}",e),n>e&&(i=t.indexOf("\\",e),i===-1||i>n))||o!==-1&&t[e]==="("&&t[e+1]==="?"&&/[:!=]/.test(t[e+2])&&t[e+3]!==")"&&(o=t.indexOf(")",e),o>e&&(i=t.indexOf("\\",e),i===-1||i>o))||s!==-1&&t[e]==="("&&t[e+1]!=="|"&&(s<e&&(s=t.indexOf("|",e)),s!==-1&&t[s+1]!==")"&&(o=t.indexOf(")",s),o>s&&(i=t.indexOf("\\",s),i===-1||i>o))))return!0;if(t[e]==="\\"){var a=t[e+1];e+=2;var c=zs[a];if(c){var f=t.indexOf(c,e);f!==-1&&(e=f+1)}if(t[e]==="!")return!0}else e++}return!1},Fi=function(t){if(t[0]==="!")return!0;for(var e=0;e<t.length;){if(/[*?{}()[\]]/.test(t[e]))return!0;if(t[e]==="\\"){var s=t[e+1];e+=2;var r=zs[s];if(r){var n=t.indexOf(r,e);n!==-1&&(e=n+1)}if(t[e]==="!")return!0}else e++}return!1};Xs.exports=function(e,s){if(typeof e!="string"||e==="")return!1;if(Hi(e))return!0;var r=Di;return s&&s.strict===!1&&(r=Fi),r(e)}});var Zs=x((Oc,Qs)=>{"use strict";var $i=St(),Mi=L("path").posix.dirname,Ui=L("os").platform()==="win32",It="/",Bi=/\\/g,Wi=/[\{\[].*[\}\]]$/,Gi=/(^|[^\\])([\{\[]|\([^\)]+$)/,qi=/\\([\!\*\?\|\[\]\(\)\{\}])/g;Qs.exports=function(e,s){var r=Object.assign({flipBackslashes:!0},s);r.flipBackslashes&&Ui&&e.indexOf(It)<0&&(e=e.replace(Bi,It)),Wi.test(e)&&(e+=It),e+="a";do e=Mi(e);while($i(e)||Gi.test(e));return e.replace(qi,"$1")}});var Ye=x(J=>{"use strict";J.isInteger=t=>typeof t=="number"?Number.isInteger(t):typeof t=="string"&&t.trim()!==""?Number.isInteger(Number(t)):!1;J.find=(t,e)=>t.nodes.find(s=>s.type===e);J.exceedsLimit=(t,e,s=1,r)=>r===!1||!J.isInteger(t)||!J.isInteger(e)?!1:(Number(e)-Number(t))/Number(s)>=r;J.escapeNode=(t,e=0,s)=>{let r=t.nodes[e];r&&(s&&r.type===s||r.type==="open"||r.type==="close")&&r.escaped!==!0&&(r.value="\\"+r.value,r.escaped=!0)};J.encloseBrace=t=>t.type!=="brace"?!1:t.commas>>0+t.ranges>>0===0?(t.invalid=!0,!0):!1;J.isInvalidBrace=t=>t.type!=="brace"?!1:t.invalid===!0||t.dollar?!0:t.commas>>0+t.ranges>>0===0||t.open!==!0||t.close!==!0?(t.invalid=!0,!0):!1;J.isOpenOrClose=t=>t.type==="open"||t.type==="close"?!0:t.open===!0||t.close===!0;J.reduce=t=>t.reduce((e,s)=>(s.type==="text"&&e.push(s.value),s.type==="range"&&(s.type="text"),e),[]);J.flatten=(...t)=>{let e=[],s=r=>{for(let n=0;n<r.length;n++){let o=r[n];if(Array.isArray(o)){s(o);continue}o!==void 0&&e.push(o)}return e};return s(t),e}});var ze=x((Hc,er)=>{"use strict";var Js=Ye();er.exports=(t,e={})=>{let s=(r,n={})=>{let o=e.escapeInvalid&&Js.isInvalidBrace(n),i=r.invalid===!0&&e.escapeInvalid===!0,a="";if(r.value)return(o||i)&&Js.isOpenOrClose(r)?"\\"+r.value:r.value;if(r.value)return r.value;if(r.nodes)for(let c of r.nodes)a+=s(c);return a};return s(t)}});var sr=x((Dc,tr)=>{"use strict";tr.exports=function(t){return typeof t=="number"?t-t===0:typeof t=="string"&&t.trim()!==""?Number.isFinite?Number.isFinite(+t):isFinite(+t):!1}});var fr=x((Fc,ur)=>{"use strict";var rr=sr(),fe=(t,e,s)=>{if(rr(t)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(e===void 0||t===e)return String(t);if(rr(e)===!1)throw new TypeError("toRegexRange: expected the second argument to be a number.");let r={relaxZeros:!0,...s};typeof r.strictZeros=="boolean"&&(r.relaxZeros=r.strictZeros===!1);let n=String(r.relaxZeros),o=String(r.shorthand),i=String(r.capture),a=String(r.wrap),c=t+":"+e+"="+n+o+i+a;if(fe.cache.hasOwnProperty(c))return fe.cache[c].result;let f=Math.min(t,e),u=Math.max(t,e);if(Math.abs(f-u)===1){let w=t+"|"+e;return r.capture?`(${w})`:r.wrap===!1?w:`(?:${w})`}let d=lr(t)||lr(e),l={min:t,max:e,a:f,b:u},y=[],E=[];if(d&&(l.isPadded=d,l.maxLen=String(l.max).length),f<0){let w=u<0?Math.abs(u):1;E=nr(w,Math.abs(f),l,r),f=l.a=0}return u>=0&&(y=nr(f,u,l,r)),l.negatives=E,l.positives=y,l.result=Ki(E,y,r),r.capture===!0?l.result=`(${l.result})`:r.wrap!==!1&&y.length+E.length>1&&(l.result=`(?:${l.result})`),fe.cache[c]=l,l.result};function Ki(t,e,s){let r=Ct(t,e,"-",!1,s)||[],n=Ct(e,t,"",!1,s)||[],o=Ct(t,e,"-?",!0,s)||[];return r.concat(o).concat(n).join("|")}function ji(t,e){let s=1,r=1,n=or(t,s),o=new Set([e]);for(;t<=n&&n<=e;)o.add(n),s+=1,n=or(t,s);for(n=ar(e+1,r)-1;t<n&&n<=e;)o.add(n),r+=1,n=ar(e+1,r)-1;return o=[...o],o.sort(zi),o}function Vi(t,e,s){if(t===e)return{pattern:t,count:[],digits:0};let r=Yi(t,e),n=r.length,o="",i=0;for(let a=0;a<n;a++){let[c,f]=r[a];c===f?o+=c:c!=="0"||f!=="9"?o+=Xi(c,f,s):i++}return i&&(o+=s.shorthand===!0?"\\d":"[0-9]"),{pattern:o,count:[i],digits:n}}function nr(t,e,s,r){let n=ji(t,e),o=[],i=t,a;for(let c=0;c<n.length;c++){let f=n[c],u=Vi(String(i),String(f),r),d="";if(!s.isPadded&&a&&a.pattern===u.pattern){a.count.length>1&&a.count.pop(),a.count.push(u.count[0]),a.string=a.pattern+cr(a.count),i=f+1;continue}s.isPadded&&(d=Qi(f,s,r)),u.string=d+u.pattern+cr(u.count),o.push(u),i=f+1,a=u}return o}function Ct(t,e,s,r,n){let o=[];for(let i of t){let{string:a}=i;!r&&!ir(e,"string",a)&&o.push(s+a),r&&ir(e,"string",a)&&o.push(s+a)}return o}function Yi(t,e){let s=[];for(let r=0;r<t.length;r++)s.push([t[r],e[r]]);return s}function zi(t,e){return t>e?1:e>t?-1:0}function ir(t,e,s){return t.some(r=>r[e]===s)}function or(t,e){return Number(String(t).slice(0,-e)+"9".repeat(e))}function ar(t,e){return t-t%Math.pow(10,e)}function cr(t){let[e=0,s=""]=t;return s||e>1?`{${e+(s?","+s:"")}}`:""}function Xi(t,e,s){return`[${t}${e-t===1?"":"-"}${e}]`}function lr(t){return/^-?(0+)\d/.test(t)}function Qi(t,e,s){if(!e.isPadded)return t;let r=Math.abs(e.maxLen-String(t).length),n=s.relaxZeros!==!1;switch(r){case 0:return"";case 1:return n?"0?":"0";case 2:return n?"0{0,2}":"00";default:return n?`0{0,${r}}`:`0{${r}}`}}fe.cache={};fe.clearCache=()=>fe.cache={};ur.exports=fe});var kt=x(($c,yr)=>{"use strict";var Zi=L("util"),hr=fr(),dr=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),Ji=t=>e=>t===!0?Number(e):String(e),bt=t=>typeof t=="number"||typeof t=="string"&&t!=="",Ce=t=>Number.isInteger(+t),xt=t=>{let e=`${t}`,s=-1;if(e[0]==="-"&&(e=e.slice(1)),e==="0")return!1;for(;e[++s]==="0";);return s>0},eo=(t,e,s)=>typeof t=="string"||typeof e=="string"?!0:s.stringify===!0,to=(t,e,s)=>{if(e>0){let r=t[0]==="-"?"-":"";r&&(t=t.slice(1)),t=r+t.padStart(r?e-1:e,"0")}return s===!1?String(t):t},Qe=(t,e)=>{let s=t[0]==="-"?"-":"";for(s&&(t=t.slice(1),e--);t.length<e;)t="0"+t;return s?"-"+t:t},so=(t,e,s)=>{t.negatives.sort((a,c)=>a<c?-1:a>c?1:0),t.positives.sort((a,c)=>a<c?-1:a>c?1:0);let r=e.capture?"":"?:",n="",o="",i;return t.positives.length&&(n=t.positives.map(a=>Qe(String(a),s)).join("|")),t.negatives.length&&(o=`-(${r}${t.negatives.map(a=>Qe(String(a),s)).join("|")})`),n&&o?i=`${n}|${o}`:i=n||o,e.wrap?`(${r}${i})`:i},pr=(t,e,s,r)=>{if(s)return hr(t,e,{wrap:!1,...r});let n=String.fromCharCode(t);if(t===e)return n;let o=String.fromCharCode(e);return`[${n}-${o}]`},_r=(t,e,s)=>{if(Array.isArray(t)){let r=s.wrap===!0,n=s.capture?"":"?:";return r?`(${n}${t.join("|")})`:t.join("|")}return hr(t,e,s)},gr=(...t)=>new RangeError("Invalid range arguments: "+Zi.inspect(...t)),Er=(t,e,s)=>{if(s.strictRanges===!0)throw gr([t,e]);return[]},ro=(t,e)=>{if(e.strictRanges===!0)throw new TypeError(`Expected step "${t}" to be a number`);return[]},no=(t,e,s=1,r={})=>{let n=Number(t),o=Number(e);if(!Number.isInteger(n)||!Number.isInteger(o)){if(r.strictRanges===!0)throw gr([t,e]);return[]}n===0&&(n=0),o===0&&(o=0);let i=n>o,a=String(t),c=String(e),f=String(s);s=Math.max(Math.abs(s),1);let u=xt(a)||xt(c)||xt(f),d=u?Math.max(a.length,c.length,f.length):0,l=u===!1&&eo(t,e,r)===!1,y=r.transform||Ji(l);if(r.toRegex&&s===1)return pr(Qe(t,d),Qe(e,d),!0,r);let E={negatives:[],positives:[]},w=Y=>E[Y<0?"negatives":"positives"].push(Math.abs(Y)),v=[],F=0;for(;i?n>=o:n<=o;)r.toRegex===!0&&s>1?w(n):v.push(to(y(n,F),d,l)),n=i?n-s:n+s,F++;return r.toRegex===!0?s>1?so(E,r,d):_r(v,null,{wrap:!1,...r}):v},io=(t,e,s=1,r={})=>{if(!Ce(t)&&t.length>1||!Ce(e)&&e.length>1)return Er(t,e,r);let n=r.transform||(l=>String.fromCharCode(l)),o=`${t}`.charCodeAt(0),i=`${e}`.charCodeAt(0),a=o>i,c=Math.min(o,i),f=Math.max(o,i);if(r.toRegex&&s===1)return pr(c,f,!1,r);let u=[],d=0;for(;a?o>=i:o<=i;)u.push(n(o,d)),o=a?o-s:o+s,d++;return r.toRegex===!0?_r(u,null,{wrap:!1,options:r}):u},Xe=(t,e,s,r={})=>{if(e==null&&bt(t))return[t];if(!bt(t)||!bt(e))return Er(t,e,r);if(typeof s=="function")return Xe(t,e,1,{transform:s});if(dr(s))return Xe(t,e,0,s);let n={...r};return n.capture===!0&&(n.wrap=!0),s=s||n.step||1,Ce(s)?Ce(t)&&Ce(e)?no(t,e,s,n):io(t,e,Math.max(Math.abs(s),1),n):s!=null&&!dr(s)?ro(s,n):Xe(t,e,1,s)};yr.exports=Xe});var Rr=x((Mc,wr)=>{"use strict";var oo=kt(),mr=Ye(),ao=(t,e={})=>{let s=(r,n={})=>{let o=mr.isInvalidBrace(n),i=r.invalid===!0&&e.escapeInvalid===!0,a=o===!0||i===!0,c=e.escapeInvalid===!0?"\\":"",f="";if(r.isOpen===!0)return c+r.value;if(r.isClose===!0)return console.log("node.isClose",c,r.value),c+r.value;if(r.type==="open")return a?c+r.value:"(";if(r.type==="close")return a?c+r.value:")";if(r.type==="comma")return r.prev.type==="comma"?"":a?r.value:"|";if(r.value)return r.value;if(r.nodes&&r.ranges>0){let u=mr.reduce(r.nodes),d=oo(...u,{...e,wrap:!1,toRegex:!0,strictZeros:!0});if(d.length!==0)return u.length>1&&d.length>1?`(${d})`:d}if(r.nodes)for(let u of r.nodes)f+=s(u,r);return f};return s(t)};wr.exports=ao});var Sr=x((Uc,Tr)=>{"use strict";var co=kt(),Ar=ze(),me=Ye(),de=(t="",e="",s=!1)=>{let r=[];if(t=[].concat(t),e=[].concat(e),!e.length)return t;if(!t.length)return s?me.flatten(e).map(n=>`{${n}}`):e;for(let n of t)if(Array.isArray(n))for(let o of n)r.push(de(o,e,s));else for(let o of e)s===!0&&typeof o=="string"&&(o=`{${o}}`),r.push(Array.isArray(o)?de(n,o,s):n+o);return me.flatten(r)},lo=(t,e={})=>{let s=e.rangeLimit===void 0?1e3:e.rangeLimit,r=(n,o={})=>{n.queue=[];let i=o,a=o.queue;for(;i.type!=="brace"&&i.type!=="root"&&i.parent;)i=i.parent,a=i.queue;if(n.invalid||n.dollar){a.push(de(a.pop(),Ar(n,e)));return}if(n.type==="brace"&&n.invalid!==!0&&n.nodes.length===2){a.push(de(a.pop(),["{}"]));return}if(n.nodes&&n.ranges>0){let d=me.reduce(n.nodes);if(me.exceedsLimit(...d,e.step,s))throw new RangeError("expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.");let l=co(...d,e);l.length===0&&(l=Ar(n,e)),a.push(de(a.pop(),l)),n.nodes=[];return}let c=me.encloseBrace(n),f=n.queue,u=n;for(;u.type!=="brace"&&u.type!=="root"&&u.parent;)u=u.parent,f=u.queue;for(let d=0;d<n.nodes.length;d++){let l=n.nodes[d];if(l.type==="comma"&&n.type==="brace"){d===1&&f.push(""),f.push("");continue}if(l.type==="close"){a.push(de(a.pop(),f,c));continue}if(l.value&&l.type!=="open"){f.push(de(f.pop(),l.value));continue}l.nodes&&r(l,n)}return f};return me.flatten(r(t))};Tr.exports=lo});var Cr=x((Bc,Ir)=>{"use strict";Ir.exports={MAX_LENGTH:1e4,CHAR_0:"0",CHAR_9:"9",CHAR_UPPERCASE_A:"A",CHAR_LOWERCASE_A:"a",CHAR_UPPERCASE_Z:"Z",CHAR_LOWERCASE_Z:"z",CHAR_LEFT_PARENTHESES:"(",CHAR_RIGHT_PARENTHESES:")",CHAR_ASTERISK:"*",CHAR_AMPERSAND:"&",CHAR_AT:"@",CHAR_BACKSLASH:"\\",CHAR_BACKTICK:"`",CHAR_CARRIAGE_RETURN:"\r",CHAR_CIRCUMFLEX_ACCENT:"^",CHAR_COLON:":",CHAR_COMMA:",",CHAR_DOLLAR:"$",CHAR_DOT:".",CHAR_DOUBLE_QUOTE:'"',CHAR_EQUAL:"=",CHAR_EXCLAMATION_MARK:"!",CHAR_FORM_FEED:"\f",CHAR_FORWARD_SLASH:"/",CHAR_HASH:"#",CHAR_HYPHEN_MINUS:"-",CHAR_LEFT_ANGLE_BRACKET:"<",CHAR_LEFT_CURLY_BRACE:"{",CHAR_LEFT_SQUARE_BRACKET:"[",CHAR_LINE_FEED:`
|
|
2
|
+
`,CHAR_NO_BREAK_SPACE:"\xA0",CHAR_PERCENT:"%",CHAR_PLUS:"+",CHAR_QUESTION_MARK:"?",CHAR_RIGHT_ANGLE_BRACKET:">",CHAR_RIGHT_CURLY_BRACE:"}",CHAR_RIGHT_SQUARE_BRACKET:"]",CHAR_SEMICOLON:";",CHAR_SINGLE_QUOTE:"'",CHAR_SPACE:" ",CHAR_TAB:" ",CHAR_UNDERSCORE:"_",CHAR_VERTICAL_LINE:"|",CHAR_ZERO_WIDTH_NOBREAK_SPACE:"\uFEFF"}});var Pr=x((Wc,vr)=>{"use strict";var uo=ze(),{MAX_LENGTH:br,CHAR_BACKSLASH:vt,CHAR_BACKTICK:fo,CHAR_COMMA:ho,CHAR_DOT:po,CHAR_LEFT_PARENTHESES:_o,CHAR_RIGHT_PARENTHESES:go,CHAR_LEFT_CURLY_BRACE:Eo,CHAR_RIGHT_CURLY_BRACE:yo,CHAR_LEFT_SQUARE_BRACKET:xr,CHAR_RIGHT_SQUARE_BRACKET:kr,CHAR_DOUBLE_QUOTE:mo,CHAR_SINGLE_QUOTE:wo,CHAR_NO_BREAK_SPACE:Ro,CHAR_ZERO_WIDTH_NOBREAK_SPACE:Ao}=Cr(),To=(t,e={})=>{if(typeof t!="string")throw new TypeError("Expected a string");let s=e||{},r=typeof s.maxLength=="number"?Math.min(br,s.maxLength):br;if(t.length>r)throw new SyntaxError(`Input length (${t.length}), exceeds max characters (${r})`);let n={type:"root",input:t,nodes:[]},o=[n],i=n,a=n,c=0,f=t.length,u=0,d=0,l,y=()=>t[u++],E=w=>{if(w.type==="text"&&a.type==="dot"&&(a.type="text"),a&&a.type==="text"&&w.type==="text"){a.value+=w.value;return}return i.nodes.push(w),w.parent=i,w.prev=a,a=w,w};for(E({type:"bos"});u<f;)if(i=o[o.length-1],l=y(),!(l===Ao||l===Ro)){if(l===vt){E({type:"text",value:(e.keepEscaping?l:"")+y()});continue}if(l===kr){E({type:"text",value:"\\"+l});continue}if(l===xr){c++;let w;for(;u<f&&(w=y());){if(l+=w,w===xr){c++;continue}if(w===vt){l+=y();continue}if(w===kr&&(c--,c===0))break}E({type:"text",value:l});continue}if(l===_o){i=E({type:"paren",nodes:[]}),o.push(i),E({type:"text",value:l});continue}if(l===go){if(i.type!=="paren"){E({type:"text",value:l});continue}i=o.pop(),E({type:"text",value:l}),i=o[o.length-1];continue}if(l===mo||l===wo||l===fo){let w=l,v;for(e.keepQuotes!==!0&&(l="");u<f&&(v=y());){if(v===vt){l+=v+y();continue}if(v===w){e.keepQuotes===!0&&(l+=v);break}l+=v}E({type:"text",value:l});continue}if(l===Eo){d++;let v={type:"brace",open:!0,close:!1,dollar:a.value&&a.value.slice(-1)==="$"||i.dollar===!0,depth:d,commas:0,ranges:0,nodes:[]};i=E(v),o.push(i),E({type:"open",value:l});continue}if(l===yo){if(i.type!=="brace"){E({type:"text",value:l});continue}let w="close";i=o.pop(),i.close=!0,E({type:w,value:l}),d--,i=o[o.length-1];continue}if(l===ho&&d>0){if(i.ranges>0){i.ranges=0;let w=i.nodes.shift();i.nodes=[w,{type:"text",value:uo(i)}]}E({type:"comma",value:l}),i.commas++;continue}if(l===po&&d>0&&i.commas===0){let w=i.nodes;if(d===0||w.length===0){E({type:"text",value:l});continue}if(a.type==="dot"){if(i.range=[],a.value+=l,a.type="range",i.nodes.length!==3&&i.nodes.length!==5){i.invalid=!0,i.ranges=0,a.type="text";continue}i.ranges++,i.args=[];continue}if(a.type==="range"){w.pop();let v=w[w.length-1];v.value+=a.value+l,a=v,i.ranges--;continue}E({type:"dot",value:l});continue}E({type:"text",value:l})}do if(i=o.pop(),i.type!=="root"){i.nodes.forEach(F=>{F.nodes||(F.type==="open"&&(F.isOpen=!0),F.type==="close"&&(F.isClose=!0),F.nodes||(F.type="text"),F.invalid=!0)});let w=o[o.length-1],v=w.nodes.indexOf(i);w.nodes.splice(v,1,...i.nodes)}while(o.length>0);return E({type:"eos"}),n};vr.exports=To});var Lr=x((Gc,Or)=>{"use strict";var Nr=ze(),So=Rr(),Io=Sr(),Co=Pr(),Z=(t,e={})=>{let s=[];if(Array.isArray(t))for(let r of t){let n=Z.create(r,e);Array.isArray(n)?s.push(...n):s.push(n)}else s=[].concat(Z.create(t,e));return e&&e.expand===!0&&e.nodupes===!0&&(s=[...new Set(s)]),s};Z.parse=(t,e={})=>Co(t,e);Z.stringify=(t,e={})=>Nr(typeof t=="string"?Z.parse(t,e):t,e);Z.compile=(t,e={})=>(typeof t=="string"&&(t=Z.parse(t,e)),So(t,e));Z.expand=(t,e={})=>{typeof t=="string"&&(t=Z.parse(t,e));let s=Io(t,e);return e.noempty===!0&&(s=s.filter(Boolean)),e.nodupes===!0&&(s=[...new Set(s)]),s};Z.create=(t,e={})=>t===""||t.length<3?[t]:e.expand!==!0?Z.compile(t,e):Z.expand(t,e);Or.exports=Z});var Hr=x((qc,bo)=>{bo.exports=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]});var Fr=x((Kc,Dr)=>{Dr.exports=Hr()});var Mr=x((jc,$r)=>{"use strict";var xo=L("path"),ko=Fr(),vo=new Set(ko);$r.exports=t=>vo.has(xo.extname(t).slice(1).toLowerCase())});var Ze=x(R=>{"use strict";var{sep:Po}=L("path"),{platform:Pt}=process,No=L("os");R.EV_ALL="all";R.EV_READY="ready";R.EV_ADD="add";R.EV_CHANGE="change";R.EV_ADD_DIR="addDir";R.EV_UNLINK="unlink";R.EV_UNLINK_DIR="unlinkDir";R.EV_RAW="raw";R.EV_ERROR="error";R.STR_DATA="data";R.STR_END="end";R.STR_CLOSE="close";R.FSEVENT_CREATED="created";R.FSEVENT_MODIFIED="modified";R.FSEVENT_DELETED="deleted";R.FSEVENT_MOVED="moved";R.FSEVENT_CLONED="cloned";R.FSEVENT_UNKNOWN="unknown";R.FSEVENT_FLAG_MUST_SCAN_SUBDIRS=1;R.FSEVENT_TYPE_FILE="file";R.FSEVENT_TYPE_DIRECTORY="directory";R.FSEVENT_TYPE_SYMLINK="symlink";R.KEY_LISTENERS="listeners";R.KEY_ERR="errHandlers";R.KEY_RAW="rawEmitters";R.HANDLER_KEYS=[R.KEY_LISTENERS,R.KEY_ERR,R.KEY_RAW];R.DOT_SLASH=`.${Po}`;R.BACK_SLASH_RE=/\\/g;R.DOUBLE_SLASH_RE=/\/\//;R.SLASH_OR_BACK_SLASH_RE=/[/\\]/;R.DOT_RE=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/;R.REPLACER_RE=/^\.[/\\]/;R.SLASH="/";R.SLASH_SLASH="//";R.BRACE_START="{";R.BANG="!";R.ONE_DOT=".";R.TWO_DOTS="..";R.STAR="*";R.GLOBSTAR="**";R.ROOT_GLOBSTAR="/**/*";R.SLASH_GLOBSTAR="/**";R.DIR_SUFFIX="Dir";R.ANYMATCH_OPTS={dot:!0};R.STRING_TYPE="string";R.FUNCTION_TYPE="function";R.EMPTY_STR="";R.EMPTY_FN=()=>{};R.IDENTITY_FN=t=>t;R.isWindows=Pt==="win32";R.isMacos=Pt==="darwin";R.isLinux=Pt==="linux";R.isIBMi=No.type()==="OS400"});var Kr=x((Yc,qr)=>{"use strict";var oe=L("fs"),B=L("path"),{promisify:ve}=L("util"),Oo=Mr(),{isWindows:Lo,isLinux:Ho,EMPTY_FN:Do,EMPTY_STR:Fo,KEY_LISTENERS:we,KEY_ERR:Nt,KEY_RAW:be,HANDLER_KEYS:$o,EV_CHANGE:et,EV_ADD:Je,EV_ADD_DIR:Mo,EV_ERROR:Br,STR_DATA:Uo,STR_END:Bo,BRACE_START:Wo,STAR:Go}=Ze(),qo="watch",Ko=ve(oe.open),Wr=ve(oe.stat),jo=ve(oe.lstat),Vo=ve(oe.close),Ot=ve(oe.realpath),Yo={lstat:jo,stat:Wr},Ht=(t,e)=>{t instanceof Set?t.forEach(e):e(t)},xe=(t,e,s)=>{let r=t[e];r instanceof Set||(t[e]=r=new Set([r])),r.add(s)},zo=t=>e=>{let s=t[e];s instanceof Set?s.clear():delete t[e]},ke=(t,e,s)=>{let r=t[e];r instanceof Set?r.delete(s):r===s&&delete t[e]},Gr=t=>t instanceof Set?t.size===0:!t,tt=new Map;function Ur(t,e,s,r,n){let o=(i,a)=>{s(t),n(i,a,{watchedPath:t}),a&&t!==a&&st(B.resolve(t,a),we,B.join(t,a))};try{return oe.watch(t,e,o)}catch(i){r(i)}}var st=(t,e,s,r,n)=>{let o=tt.get(t);o&&Ht(o[e],i=>{i(s,r,n)})},Xo=(t,e,s,r)=>{let{listener:n,errHandler:o,rawEmitter:i}=r,a=tt.get(e),c;if(!s.persistent)return c=Ur(t,s,n,o,i),c.close.bind(c);if(a)xe(a,we,n),xe(a,Nt,o),xe(a,be,i);else{if(c=Ur(t,s,st.bind(null,e,we),o,st.bind(null,e,be)),!c)return;c.on(Br,async f=>{let u=st.bind(null,e,Nt);if(a.watcherUnusable=!0,Lo&&f.code==="EPERM")try{let d=await Ko(t,"r");await Vo(d),u(f)}catch{}else u(f)}),a={listeners:n,errHandlers:o,rawEmitters:i,watcher:c},tt.set(e,a)}return()=>{ke(a,we,n),ke(a,Nt,o),ke(a,be,i),Gr(a.listeners)&&(a.watcher.close(),tt.delete(e),$o.forEach(zo(a)),a.watcher=void 0,Object.freeze(a))}},Lt=new Map,Qo=(t,e,s,r)=>{let{listener:n,rawEmitter:o}=r,i=Lt.get(e),a=new Set,c=new Set,f=i&&i.options;return f&&(f.persistent<s.persistent||f.interval>s.interval)&&(a=i.listeners,c=i.rawEmitters,oe.unwatchFile(e),i=void 0),i?(xe(i,we,n),xe(i,be,o)):(i={listeners:n,rawEmitters:o,options:s,watcher:oe.watchFile(e,s,(u,d)=>{Ht(i.rawEmitters,y=>{y(et,e,{curr:u,prev:d})});let l=u.mtimeMs;(u.size!==d.size||l>d.mtimeMs||l===0)&&Ht(i.listeners,y=>y(t,u))})},Lt.set(e,i)),()=>{ke(i,we,n),ke(i,be,o),Gr(i.listeners)&&(Lt.delete(e),oe.unwatchFile(e),i.options=i.watcher=void 0,Object.freeze(i))}},Dt=class{constructor(e){this.fsw=e,this._boundHandleError=s=>e._handleError(s)}_watchWithNodeFs(e,s){let r=this.fsw.options,n=B.dirname(e),o=B.basename(e);this.fsw._getWatchedDir(n).add(o);let a=B.resolve(e),c={persistent:r.persistent};s||(s=Do);let f;return r.usePolling?(c.interval=r.enableBinaryInterval&&Oo(o)?r.binaryInterval:r.interval,f=Qo(e,a,c,{listener:s,rawEmitter:this.fsw._emitRaw})):f=Xo(e,a,c,{listener:s,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw}),f}_handleFile(e,s,r){if(this.fsw.closed)return;let n=B.dirname(e),o=B.basename(e),i=this.fsw._getWatchedDir(n),a=s;if(i.has(o))return;let c=async(u,d)=>{if(this.fsw._throttle(qo,e,5)){if(!d||d.mtimeMs===0)try{let l=await Wr(e);if(this.fsw.closed)return;let y=l.atimeMs,E=l.mtimeMs;(!y||y<=E||E!==a.mtimeMs)&&this.fsw._emit(et,e,l),Ho&&a.ino!==l.ino?(this.fsw._closeFile(u),a=l,this.fsw._addPathCloser(u,this._watchWithNodeFs(e,c))):a=l}catch{this.fsw._remove(n,o)}else if(i.has(o)){let l=d.atimeMs,y=d.mtimeMs;(!l||l<=y||y!==a.mtimeMs)&&this.fsw._emit(et,e,d),a=d}}},f=this._watchWithNodeFs(e,c);if(!(r&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(e)){if(!this.fsw._throttle(Je,e,0))return;this.fsw._emit(Je,e,s)}return f}async _handleSymlink(e,s,r,n){if(this.fsw.closed)return;let o=e.fullPath,i=this.fsw._getWatchedDir(s);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let a;try{a=await Ot(r)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(i.has(n)?this.fsw._symlinkPaths.get(o)!==a&&(this.fsw._symlinkPaths.set(o,a),this.fsw._emit(et,r,e.stats)):(i.add(n),this.fsw._symlinkPaths.set(o,a),this.fsw._emit(Je,r,e.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(o))return!0;this.fsw._symlinkPaths.set(o,!0)}_handleRead(e,s,r,n,o,i,a){if(e=B.join(e,Fo),!r.hasGlob&&(a=this.fsw._throttle("readdir",e,1e3),!a))return;let c=this.fsw._getWatchedDir(r.path),f=new Set,u=this.fsw._readdirp(e,{fileFilter:d=>r.filterPath(d),directoryFilter:d=>r.filterDir(d),depth:0}).on(Uo,async d=>{if(this.fsw.closed){u=void 0;return}let l=d.path,y=B.join(e,l);if(f.add(l),!(d.stats.isSymbolicLink()&&await this._handleSymlink(d,e,y,l))){if(this.fsw.closed){u=void 0;return}(l===n||!n&&!c.has(l))&&(this.fsw._incrReadyCount(),y=B.join(o,B.relative(o,y)),this._addToNodeFs(y,s,r,i+1))}}).on(Br,this._boundHandleError);return new Promise(d=>u.once(Bo,()=>{if(this.fsw.closed){u=void 0;return}let l=a?a.clear():!1;d(),c.getChildren().filter(y=>y!==e&&!f.has(y)&&(!r.hasGlob||r.filterPath({fullPath:B.resolve(e,y)}))).forEach(y=>{this.fsw._remove(e,y)}),u=void 0,l&&this._handleRead(e,!1,r,n,o,i,a)}))}async _handleDir(e,s,r,n,o,i,a){let c=this.fsw._getWatchedDir(B.dirname(e)),f=c.has(B.basename(e));!(r&&this.fsw.options.ignoreInitial)&&!o&&!f&&(!i.hasGlob||i.globFilter(e))&&this.fsw._emit(Mo,e,s),c.add(B.basename(e)),this.fsw._getWatchedDir(e);let u,d,l=this.fsw.options.depth;if((l==null||n<=l)&&!this.fsw._symlinkPaths.has(a)){if(!o&&(await this._handleRead(e,r,i,o,e,n,u),this.fsw.closed))return;d=this._watchWithNodeFs(e,(y,E)=>{E&&E.mtimeMs===0||this._handleRead(y,!1,i,o,e,n,u)})}return d}async _addToNodeFs(e,s,r,n,o){let i=this.fsw._emitReady;if(this.fsw._isIgnored(e)||this.fsw.closed)return i(),!1;let a=this.fsw._getWatchHelpers(e,n);!a.hasGlob&&r&&(a.hasGlob=r.hasGlob,a.globFilter=r.globFilter,a.filterPath=c=>r.filterPath(c),a.filterDir=c=>r.filterDir(c));try{let c=await Yo[a.statMethod](a.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(a.watchPath,c))return i(),!1;let f=this.fsw.options.followSymlinks&&!e.includes(Go)&&!e.includes(Wo),u;if(c.isDirectory()){let d=B.resolve(e),l=f?await Ot(e):e;if(this.fsw.closed||(u=await this._handleDir(a.watchPath,c,s,n,o,a,l),this.fsw.closed))return;d!==l&&l!==void 0&&this.fsw._symlinkPaths.set(d,l)}else if(c.isSymbolicLink()){let d=f?await Ot(e):e;if(this.fsw.closed)return;let l=B.dirname(a.watchPath);if(this.fsw._getWatchedDir(l).add(a.watchPath),this.fsw._emit(Je,a.watchPath,c),u=await this._handleDir(l,c,s,n,e,a,d),this.fsw.closed)return;d!==void 0&&this.fsw._symlinkPaths.set(B.resolve(e),d)}else u=this._handleFile(a.watchPath,c,s);return i(),this.fsw._addPathCloser(e,u),!1}catch(c){if(this.fsw._handleError(c))return i(),e}}};qr.exports=Dt});var Zr=x((zc,qt)=>{"use strict";var Wt=L("fs"),W=L("path"),{promisify:Gt}=L("util"),Re;try{Re=L("fsevents")}catch(t){process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR&&console.error(t)}if(Re){let t=process.version.match(/v(\d+)\.(\d+)/);if(t&&t[1]&&t[2]){let e=Number.parseInt(t[1],10),s=Number.parseInt(t[2],10);e===8&&s<16&&(Re=void 0)}}var{EV_ADD:Ft,EV_CHANGE:Zo,EV_ADD_DIR:jr,EV_UNLINK:rt,EV_ERROR:Jo,STR_DATA:ea,STR_END:ta,FSEVENT_CREATED:sa,FSEVENT_MODIFIED:ra,FSEVENT_DELETED:na,FSEVENT_MOVED:ia,FSEVENT_UNKNOWN:oa,FSEVENT_FLAG_MUST_SCAN_SUBDIRS:aa,FSEVENT_TYPE_FILE:ca,FSEVENT_TYPE_DIRECTORY:Pe,FSEVENT_TYPE_SYMLINK:Qr,ROOT_GLOBSTAR:Vr,DIR_SUFFIX:la,DOT_SLASH:Yr,FUNCTION_TYPE:$t,EMPTY_FN:ua,IDENTITY_FN:fa}=Ze(),da=t=>isNaN(t)?{}:{depth:t},Ut=Gt(Wt.stat),ha=Gt(Wt.lstat),zr=Gt(Wt.realpath),pa={stat:Ut,lstat:ha},he=new Map,_a=10,ga=new Set([69888,70400,71424,72704,73472,131328,131840,262912]),Ea=(t,e)=>({stop:Re.watch(t,e)});function ya(t,e,s,r){let n=W.extname(e)?W.dirname(e):e,o=W.dirname(n),i=he.get(n);ma(o)&&(n=o);let a=W.resolve(t),c=a!==e,f=(d,l,y)=>{c&&(d=d.replace(e,a)),(d===a||!d.indexOf(a+W.sep))&&s(d,l,y)},u=!1;for(let d of he.keys())if(e.indexOf(W.resolve(d)+W.sep)===0){n=d,i=he.get(n),u=!0;break}return i||u?i.listeners.add(f):(i={listeners:new Set([f]),rawEmitter:r,watcher:Ea(n,(d,l)=>{if(!i.listeners.size||l&aa)return;let y=Re.getInfo(d,l);i.listeners.forEach(E=>{E(d,l,y)}),i.rawEmitter(y.event,d,y)})},he.set(n,i)),()=>{let d=i.listeners;if(d.delete(f),!d.size&&(he.delete(n),i.watcher))return i.watcher.stop().then(()=>{i.rawEmitter=i.watcher=void 0,Object.freeze(i)})}}var ma=t=>{let e=0;for(let s of he.keys())if(s.indexOf(t)===0&&(e++,e>=_a))return!0;return!1},wa=()=>Re&&he.size<128,Mt=(t,e)=>{let s=0;for(;!t.indexOf(e)&&(t=W.dirname(t))!==e;)s++;return s},Xr=(t,e)=>t.type===Pe&&e.isDirectory()||t.type===Qr&&e.isSymbolicLink()||t.type===ca&&e.isFile(),Bt=class{constructor(e){this.fsw=e}checkIgnored(e,s){let r=this.fsw._ignoredPaths;if(this.fsw._isIgnored(e,s))return r.add(e),s&&s.isDirectory()&&r.add(e+Vr),!0;r.delete(e),r.delete(e+Vr)}addOrChange(e,s,r,n,o,i,a,c){let f=o.has(i)?Zo:Ft;this.handleEvent(f,e,s,r,n,o,i,a,c)}async checkExists(e,s,r,n,o,i,a,c){try{let f=await Ut(e);if(this.fsw.closed)return;Xr(a,f)?this.addOrChange(e,s,r,n,o,i,a,c):this.handleEvent(rt,e,s,r,n,o,i,a,c)}catch(f){f.code==="EACCES"?this.addOrChange(e,s,r,n,o,i,a,c):this.handleEvent(rt,e,s,r,n,o,i,a,c)}}handleEvent(e,s,r,n,o,i,a,c,f){if(!(this.fsw.closed||this.checkIgnored(s)))if(e===rt){let u=c.type===Pe;(u||i.has(a))&&this.fsw._remove(o,a,u)}else{if(e===Ft){if(c.type===Pe&&this.fsw._getWatchedDir(s),c.type===Qr&&f.followSymlinks){let d=f.depth===void 0?void 0:Mt(r,n)+1;return this._addToFsEvents(s,!1,!0,d)}this.fsw._getWatchedDir(o).add(a)}let u=c.type===Pe?e+la:e;this.fsw._emit(u,s),u===jr&&this._addToFsEvents(s,!1,!0)}}_watchWithFsEvents(e,s,r,n){if(this.fsw.closed||this.fsw._isIgnored(e))return;let o=this.fsw.options,a=ya(e,s,async(c,f,u)=>{if(this.fsw.closed||o.depth!==void 0&&Mt(c,s)>o.depth)return;let d=r(W.join(e,W.relative(e,c)));if(n&&!n(d))return;let l=W.dirname(d),y=W.basename(d),E=this.fsw._getWatchedDir(u.type===Pe?d:l);if(ga.has(f)||u.event===oa)if(typeof o.ignored===$t){let w;try{w=await Ut(d)}catch{}if(this.fsw.closed||this.checkIgnored(d,w))return;Xr(u,w)?this.addOrChange(d,c,s,l,E,y,u,o):this.handleEvent(rt,d,c,s,l,E,y,u,o)}else this.checkExists(d,c,s,l,E,y,u,o);else switch(u.event){case sa:case ra:return this.addOrChange(d,c,s,l,E,y,u,o);case na:case ia:return this.checkExists(d,c,s,l,E,y,u,o)}},this.fsw._emitRaw);return this.fsw._emitReady(),a}async _handleFsEventsSymlink(e,s,r,n){if(!(this.fsw.closed||this.fsw._symlinkPaths.has(s))){this.fsw._symlinkPaths.set(s,!0),this.fsw._incrReadyCount();try{let o=await zr(e);if(this.fsw.closed)return;if(this.fsw._isIgnored(o))return this.fsw._emitReady();this.fsw._incrReadyCount(),this._addToFsEvents(o||e,i=>{let a=e;return o&&o!==Yr?a=i.replace(o,e):i!==Yr&&(a=W.join(e,i)),r(a)},!1,n)}catch(o){if(this.fsw._handleError(o))return this.fsw._emitReady()}}}emitAdd(e,s,r,n,o){let i=r(e),a=s.isDirectory(),c=this.fsw._getWatchedDir(W.dirname(i)),f=W.basename(i);a&&this.fsw._getWatchedDir(i),!c.has(f)&&(c.add(f),(!n.ignoreInitial||o===!0)&&this.fsw._emit(a?jr:Ft,i,s))}initWatch(e,s,r,n){if(this.fsw.closed)return;let o=this._watchWithFsEvents(r.watchPath,W.resolve(e||r.watchPath),n,r.globFilter);this.fsw._addPathCloser(s,o)}async _addToFsEvents(e,s,r,n){if(this.fsw.closed)return;let o=this.fsw.options,i=typeof s===$t?s:fa,a=this.fsw._getWatchHelpers(e);try{let c=await pa[a.statMethod](a.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(a.watchPath,c))throw null;if(c.isDirectory()){if(a.globFilter||this.emitAdd(i(e),c,i,o,r),n&&n>o.depth)return;this.fsw._readdirp(a.watchPath,{fileFilter:f=>a.filterPath(f),directoryFilter:f=>a.filterDir(f),...da(o.depth-(n||0))}).on(ea,f=>{if(this.fsw.closed||f.stats.isDirectory()&&!a.filterPath(f))return;let u=W.join(a.watchPath,f.path),{fullPath:d}=f;if(a.followSymlinks&&f.stats.isSymbolicLink()){let l=o.depth===void 0?void 0:Mt(u,W.resolve(a.watchPath))+1;this._handleFsEventsSymlink(u,d,i,l)}else this.emitAdd(u,f.stats,i,o,r)}).on(Jo,ua).on(ta,()=>{this.fsw._emitReady()})}else this.emitAdd(a.watchPath,c,i,o,r),this.fsw._emitReady()}catch(c){(!c||this.fsw._handleError(c))&&(this.fsw._emitReady(),this.fsw._emitReady())}if(o.persistent&&r!==!0)if(typeof s===$t)this.initWatch(void 0,e,a,i);else{let c;try{c=await zr(a.watchPath)}catch{}this.initWatch(c,e,a,i)}}};qt.exports=Bt;qt.exports.canUse=wa});var un=x(is=>{"use strict";var{EventEmitter:Ra}=L("events"),rs=L("fs"),k=L("path"),{promisify:on}=L("util"),Aa=Ms(),Xt=js().default,Ta=Zs(),Kt=St(),Sa=Lr(),Ia=At(),Ca=Kr(),Jr=Zr(),{EV_ALL:jt,EV_READY:ba,EV_ADD:nt,EV_CHANGE:Ne,EV_UNLINK:en,EV_ADD_DIR:xa,EV_UNLINK_DIR:ka,EV_RAW:va,EV_ERROR:Vt,STR_CLOSE:Pa,STR_END:Na,BACK_SLASH_RE:Oa,DOUBLE_SLASH_RE:tn,SLASH_OR_BACK_SLASH_RE:La,DOT_RE:Ha,REPLACER_RE:Da,SLASH:Yt,SLASH_SLASH:Fa,BRACE_START:$a,BANG:Qt,ONE_DOT:an,TWO_DOTS:Ma,GLOBSTAR:Ua,SLASH_GLOBSTAR:zt,ANYMATCH_OPTS:Zt,STRING_TYPE:ns,FUNCTION_TYPE:Ba,EMPTY_STR:Jt,EMPTY_FN:Wa,isWindows:Ga,isMacos:qa,isIBMi:Ka}=Ze(),ja=on(rs.stat),Va=on(rs.readdir),es=(t=[])=>Array.isArray(t)?t:[t],cn=(t,e=[])=>(t.forEach(s=>{Array.isArray(s)?cn(s,e):e.push(s)}),e),sn=t=>{let e=cn(es(t));if(!e.every(s=>typeof s===ns))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(ln)},rn=t=>{let e=t.replace(Oa,Yt),s=!1;for(e.startsWith(Fa)&&(s=!0);e.match(tn);)e=e.replace(tn,Yt);return s&&(e=Yt+e),e},ln=t=>rn(k.normalize(rn(t))),nn=(t=Jt)=>e=>typeof e!==ns?e:ln(k.isAbsolute(e)?e:k.join(t,e)),Ya=(t,e)=>k.isAbsolute(t)?t:t.startsWith(Qt)?Qt+k.join(e,t.slice(1)):k.join(e,t),ee=(t,e)=>t[e]===void 0,ts=class{constructor(e,s){this.path=e,this._removeWatcher=s,this.items=new Set}add(e){let{items:s}=this;s&&e!==an&&e!==Ma&&s.add(e)}async remove(e){let{items:s}=this;if(!s||(s.delete(e),s.size>0))return;let r=this.path;try{await Va(r)}catch{this._removeWatcher&&this._removeWatcher(k.dirname(r),k.basename(r))}}has(e){let{items:s}=this;if(s)return s.has(e)}getChildren(){let{items:e}=this;if(e)return[...e.values()]}dispose(){this.items.clear(),delete this.path,delete this._removeWatcher,delete this.items,Object.freeze(this)}},za="stat",Xa="lstat",ss=class{constructor(e,s,r,n){this.fsw=n,this.path=e=e.replace(Da,Jt),this.watchPath=s,this.fullWatchPath=k.resolve(s),this.hasGlob=s!==e,e===Jt&&(this.hasGlob=!1),this.globSymlink=this.hasGlob&&r?void 0:!1,this.globFilter=this.hasGlob?Xt(e,void 0,Zt):!1,this.dirParts=this.getDirParts(e),this.dirParts.forEach(o=>{o.length>1&&o.pop()}),this.followSymlinks=r,this.statMethod=r?za:Xa}checkGlobSymlink(e){return this.globSymlink===void 0&&(this.globSymlink=e.fullParentDir===this.fullWatchPath?!1:{realPath:e.fullParentDir,linkPath:this.fullWatchPath}),this.globSymlink?e.fullPath.replace(this.globSymlink.realPath,this.globSymlink.linkPath):e.fullPath}entryPath(e){return k.join(this.watchPath,k.relative(this.watchPath,this.checkGlobSymlink(e)))}filterPath(e){let{stats:s}=e;if(s&&s.isSymbolicLink())return this.filterDir(e);let r=this.entryPath(e);return(this.hasGlob&&typeof this.globFilter===Ba?this.globFilter(r):!0)&&this.fsw._isntIgnored(r,s)&&this.fsw._hasReadPermissions(s)}getDirParts(e){if(!this.hasGlob)return[];let s=[];return(e.includes($a)?Sa.expand(e):[e]).forEach(n=>{s.push(k.relative(this.watchPath,n).split(La))}),s}filterDir(e){if(this.hasGlob){let s=this.getDirParts(this.checkGlobSymlink(e)),r=!1;this.unmatchedGlob=!this.dirParts.some(n=>n.every((o,i)=>(o===Ua&&(r=!0),r||!s[0][i]||Xt(o,s[0][i],Zt))))}return!this.unmatchedGlob&&this.fsw._isntIgnored(this.entryPath(e),e.stats)}},it=class extends Ra{constructor(e){super();let s={};e&&Object.assign(s,e),this._watched=new Map,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._symlinkPaths=new Map,this._streams=new Set,this.closed=!1,ee(s,"persistent")&&(s.persistent=!0),ee(s,"ignoreInitial")&&(s.ignoreInitial=!1),ee(s,"ignorePermissionErrors")&&(s.ignorePermissionErrors=!1),ee(s,"interval")&&(s.interval=100),ee(s,"binaryInterval")&&(s.binaryInterval=300),ee(s,"disableGlobbing")&&(s.disableGlobbing=!1),s.enableBinaryInterval=s.binaryInterval!==s.interval,ee(s,"useFsEvents")&&(s.useFsEvents=!s.usePolling),Jr.canUse()||(s.useFsEvents=!1),ee(s,"usePolling")&&!s.useFsEvents&&(s.usePolling=qa),Ka&&(s.usePolling=!0);let n=process.env.CHOKIDAR_USEPOLLING;if(n!==void 0){let c=n.toLowerCase();c==="false"||c==="0"?s.usePolling=!1:c==="true"||c==="1"?s.usePolling=!0:s.usePolling=!!c}let o=process.env.CHOKIDAR_INTERVAL;o&&(s.interval=Number.parseInt(o,10)),ee(s,"atomic")&&(s.atomic=!s.usePolling&&!s.useFsEvents),s.atomic&&(this._pendingUnlinks=new Map),ee(s,"followSymlinks")&&(s.followSymlinks=!0),ee(s,"awaitWriteFinish")&&(s.awaitWriteFinish=!1),s.awaitWriteFinish===!0&&(s.awaitWriteFinish={});let i=s.awaitWriteFinish;i&&(i.stabilityThreshold||(i.stabilityThreshold=2e3),i.pollInterval||(i.pollInterval=100),this._pendingWrites=new Map),s.ignored&&(s.ignored=es(s.ignored));let a=0;this._emitReady=()=>{a++,a>=this._readyCount&&(this._emitReady=Wa,this._readyEmitted=!0,process.nextTick(()=>this.emit(ba)))},this._emitRaw=(...c)=>this.emit(va,...c),this._readyEmitted=!1,this.options=s,s.useFsEvents?this._fsEventsHandler=new Jr(this):this._nodeFsHandler=new Ca(this),Object.freeze(s)}add(e,s,r){let{cwd:n,disableGlobbing:o}=this.options;this.closed=!1;let i=sn(e);return n&&(i=i.map(a=>{let c=Ya(a,n);return o||!Kt(a)?c:Ia(c)})),i=i.filter(a=>a.startsWith(Qt)?(this._ignoredPaths.add(a.slice(1)),!1):(this._ignoredPaths.delete(a),this._ignoredPaths.delete(a+zt),this._userIgnored=void 0,!0)),this.options.useFsEvents&&this._fsEventsHandler?(this._readyCount||(this._readyCount=i.length),this.options.persistent&&(this._readyCount+=i.length),i.forEach(a=>this._fsEventsHandler._addToFsEvents(a))):(this._readyCount||(this._readyCount=0),this._readyCount+=i.length,Promise.all(i.map(async a=>{let c=await this._nodeFsHandler._addToNodeFs(a,!r,0,0,s);return c&&this._emitReady(),c})).then(a=>{this.closed||a.filter(c=>c).forEach(c=>{this.add(k.dirname(c),k.basename(s||c))})})),this}unwatch(e){if(this.closed)return this;let s=sn(e),{cwd:r}=this.options;return s.forEach(n=>{!k.isAbsolute(n)&&!this._closers.has(n)&&(r&&(n=k.join(r,n)),n=k.resolve(n)),this._closePath(n),this._ignoredPaths.add(n),this._watched.has(n)&&this._ignoredPaths.add(n+zt),this._userIgnored=void 0}),this}close(){if(this.closed)return this._closePromise;this.closed=!0,this.removeAllListeners();let e=[];return this._closers.forEach(s=>s.forEach(r=>{let n=r();n instanceof Promise&&e.push(n)})),this._streams.forEach(s=>s.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(s=>s.dispose()),["closers","watched","streams","symlinkPaths","throttled"].forEach(s=>{this[`_${s}`].clear()}),this._closePromise=e.length?Promise.all(e).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let e={};return this._watched.forEach((s,r)=>{let n=this.options.cwd?k.relative(this.options.cwd,r):r;e[n||an]=s.getChildren().sort()}),e}emitWithAll(e,s){this.emit(...s),e!==Vt&&this.emit(jt,...s)}async _emit(e,s,r,n,o){if(this.closed)return;let i=this.options;Ga&&(s=k.normalize(s)),i.cwd&&(s=k.relative(i.cwd,s));let a=[e,s];o!==void 0?a.push(r,n,o):n!==void 0?a.push(r,n):r!==void 0&&a.push(r);let c=i.awaitWriteFinish,f;if(c&&(f=this._pendingWrites.get(s)))return f.lastChange=new Date,this;if(i.atomic){if(e===en)return this._pendingUnlinks.set(s,a),setTimeout(()=>{this._pendingUnlinks.forEach((u,d)=>{this.emit(...u),this.emit(jt,...u),this._pendingUnlinks.delete(d)})},typeof i.atomic=="number"?i.atomic:100),this;e===nt&&this._pendingUnlinks.has(s)&&(e=a[0]=Ne,this._pendingUnlinks.delete(s))}if(c&&(e===nt||e===Ne)&&this._readyEmitted){let u=(d,l)=>{d?(e=a[0]=Vt,a[1]=d,this.emitWithAll(e,a)):l&&(a.length>2?a[2]=l:a.push(l),this.emitWithAll(e,a))};return this._awaitWriteFinish(s,c.stabilityThreshold,e,u),this}if(e===Ne&&!this._throttle(Ne,s,50))return this;if(i.alwaysStat&&r===void 0&&(e===nt||e===xa||e===Ne)){let u=i.cwd?k.join(i.cwd,s):s,d;try{d=await ja(u)}catch{}if(!d||this.closed)return;a.push(d)}return this.emitWithAll(e,a),this}_handleError(e){let s=e&&e.code;return e&&s!=="ENOENT"&&s!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||s!=="EPERM"&&s!=="EACCES")&&this.emit(Vt,e),e||this.closed}_throttle(e,s,r){this._throttled.has(e)||this._throttled.set(e,new Map);let n=this._throttled.get(e),o=n.get(s);if(o)return o.count++,!1;let i,a=()=>{let f=n.get(s),u=f?f.count:0;return n.delete(s),clearTimeout(i),f&&clearTimeout(f.timeoutObject),u};i=setTimeout(a,r);let c={timeoutObject:i,clear:a,count:0};return n.set(s,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(e,s,r,n){let o,i=e;this.options.cwd&&!k.isAbsolute(e)&&(i=k.join(this.options.cwd,e));let a=new Date,c=f=>{rs.stat(i,(u,d)=>{if(u||!this._pendingWrites.has(e)){u&&u.code!=="ENOENT"&&n(u);return}let l=Number(new Date);f&&d.size!==f.size&&(this._pendingWrites.get(e).lastChange=l);let y=this._pendingWrites.get(e);l-y.lastChange>=s?(this._pendingWrites.delete(e),n(void 0,d)):o=setTimeout(c,this.options.awaitWriteFinish.pollInterval,d)})};this._pendingWrites.has(e)||(this._pendingWrites.set(e,{lastChange:a,cancelWait:()=>(this._pendingWrites.delete(e),clearTimeout(o),r)}),o=setTimeout(c,this.options.awaitWriteFinish.pollInterval))}_getGlobIgnored(){return[...this._ignoredPaths.values()]}_isIgnored(e,s){if(this.options.atomic&&Ha.test(e))return!0;if(!this._userIgnored){let{cwd:r}=this.options,n=this.options.ignored,o=n&&n.map(nn(r)),i=es(o).filter(c=>typeof c===ns&&!Kt(c)).map(c=>c+zt),a=this._getGlobIgnored().map(nn(r)).concat(o,i);this._userIgnored=Xt(a,void 0,Zt)}return this._userIgnored([e,s])}_isntIgnored(e,s){return!this._isIgnored(e,s)}_getWatchHelpers(e,s){let r=s||this.options.disableGlobbing||!Kt(e)?e:Ta(e),n=this.options.followSymlinks;return new ss(e,r,n,this)}_getWatchedDir(e){this._boundRemove||(this._boundRemove=this._remove.bind(this));let s=k.resolve(e);return this._watched.has(s)||this._watched.set(s,new ts(s,this._boundRemove)),this._watched.get(s)}_hasReadPermissions(e){if(this.options.ignorePermissionErrors)return!0;let r=(e&&Number.parseInt(e.mode,10))&511;return!!(4&Number.parseInt(r.toString(8)[0],10))}_remove(e,s,r){let n=k.join(e,s),o=k.resolve(n);if(r=r??(this._watched.has(n)||this._watched.has(o)),!this._throttle("remove",n,100))return;!r&&!this.options.useFsEvents&&this._watched.size===1&&this.add(e,s,!0),this._getWatchedDir(n).getChildren().forEach(l=>this._remove(n,l));let c=this._getWatchedDir(e),f=c.has(s);c.remove(s),this._symlinkPaths.has(o)&&this._symlinkPaths.delete(o);let u=n;if(this.options.cwd&&(u=k.relative(this.options.cwd,n)),this.options.awaitWriteFinish&&this._pendingWrites.has(u)&&this._pendingWrites.get(u).cancelWait()===nt)return;this._watched.delete(n),this._watched.delete(o);let d=r?ka:en;f&&!this._isIgnored(n)&&this._emit(d,n),this.options.useFsEvents||this._closePath(n)}_closePath(e){this._closeFile(e);let s=k.dirname(e);this._getWatchedDir(s).remove(k.basename(e))}_closeFile(e){let s=this._closers.get(e);s&&(s.forEach(r=>r()),this._closers.delete(e))}_addPathCloser(e,s){if(!s)return;let r=this._closers.get(e);r||(r=[],this._closers.set(e,r)),r.push(s)}_readdirp(e,s){if(this.closed)return;let r={type:jt,alwaysStat:!0,lstat:!0,...s},n=Aa(e,r);return this._streams.add(n),n.once(Pa,()=>{n=void 0}),n.once(Na,()=>{n&&(this._streams.delete(n),n=void 0)}),n}};is.FSWatcher=it;var Qa=(t,e)=>{let s=new it(e);return s.add(t),s};is.watch=Qa});import"only-server";import"../common/index.mjs";var hn=Bn(un(),1);import{fork as Ja}from"node:child_process";import{existsSync as fn,promises as ec}from"node:fs";import{basename as as,dirname as ls,join as cs,relative as dn}from"node:path";import{build as tc}from"esbuild";import{jwtDecode as sc}from"jwt-decode";import{Issuer as rc,custom as nc}from"openid-client";import{Logger as ic}from"@5minds/processcube_engine_sdk";import{EngineClient as Za}from"@5minds/processcube_engine_client";var os=process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560",T=new Za(os);var oc={token:"ZHVtbXlfdG9rZW4=",userId:"dummy_token"},ac=.85,ot=["external_task.ts","external_task.js"],us=process.env.PROCESSCUBE_AUTHORITY_URL!==void 0,_e=new ic("processcube_app_sdk:external_task_adapter"),pe={},Oe;async function pn(t){if(t&&!fn(t))throw new Error(`Invalid customExternalTasksDirPath. The given path '${t}' does not exist`);nc.setHttpOptionsDefaults({timeout:1e5});let e=await En();Oe=await yn(e),await lc(e);let s=fc(t);(0,hn.watch)(s).on("add",async r=>{if(ot.includes(as(r)))return _n(r,s)}).on("change",async r=>{if(ot.includes(as(r)))return cc(r,s)}).on("unlink",async r=>{ot.includes(as(r))&&gn(r)}).on("error",r=>_e.error(`Watcher error: ${r}`))}async function _n(t,e){let s=ls(t);if((await ec.readdir(s)).filter(u=>ot.includes(u)).length>1){_e.error(`Multiple external task files found in directory ${s}. Stopping all external task workers for this directory.`),pe[s]&&gn(t);return}let o=await mn(t),i=dn(e,s),a=wn(i),c=cs(__dirname,"lib/ExternalTaskWorkerProcess.cjs"),f=Ja(c,{env:{...process.env,PROCESSCUBE_ENGINE_URL:os}});pe[s]=f,f.once("disconnect",()=>{delete pe[s]}),f.send({action:"create",payload:{topic:a,identity:Oe,moduleString:o,workerPath:t}})}async function cc(t,e){let s=ls(t),r=pe[s];if(!r)return _n(t,e);let n=await mn(t),o=dn(e,s),i=wn(o);r.send({action:"restart",payload:{topic:i,identity:Oe,moduleString:n,workerPath:t}})}function gn(t){let e=ls(t),s=pe[e];s&&s.kill()}async function En(){if(!us)return null;if(!process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID||!process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET){let r=new Error("Required environment variables PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID and PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET are missing. For help, please refer to our documentation on environment variables at: https://processcube.io/docs/app-sdk/samples/nextjs/external-task-adapter-with-nextjs#authority");throw _e.error("Required environment variables PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID and PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET are missing",{err:r}),r}let t=await rc.discover(process.env.PROCESSCUBE_AUTHORITY_URL);return await new t.Client({client_id:process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_ID,client_secret:process.env.PROCESSCUBE_EXTERNAL_TASK_WORKER_CLIENT_SECRET}).grant({grant_type:"client_credentials",scope:"engine_etw"})}function yn(t){if(!us||t===null)return oc;let e=t.access_token,s=sc(e);return{token:t.access_token,userId:s.sub}}async function lc(t){let e=5;if(!us||t===null)return;let r=await uc(t)*ac*1e3,n=async()=>{try{let o=await En();Oe=yn(o);for(let i of Object.values(pe))i.send({action:"updateIdentity",payload:{identity:Oe}});e=5,setTimeout(n,r)}catch(o){if(e===0){_e.error("Could not refresh identity for external task worker processes. Stopping all external task workers.",{error:o});for(let a of Object.values(pe))a.kill();return}_e.error("Could not refresh identity for external task worker processes.",{error:o,retryCount:e}),e--;let i=2*1e3;setTimeout(n,i)}};setTimeout(n,r)}async function mn(t){let e=await tc({entryPoints:[t],write:!1,bundle:!0,platform:"node",target:"node18",format:"cjs",external:["@opentelemetry/api"]});if(e.errors.length>0)throw _e.error(`Could not transpile file at '${t}'`,{errors:e.errors}),new Error(`Could not transpile file at '${t}'`);return e.warnings.length>0&&_e.warn(`Transpiled file at '${t}' with warnings`,{warnings:e.warnings}),e.outputFiles[0].text}async function uc(t){let e=t.expires_in;if(!e&&t.expires_at&&(e=Math.floor(t.expires_at-Date.now()/1e3)),e===void 0)throw new Error("Could not determine the time until the access token for external task workers expires");return e}function wn(t){return t.replace(/^\.\/+|\([^)]+\)|^\/*|\/*$/g,"").replace(/[\/]{2,}/g,"/")}function fc(t){let e,s=[t,cs(process.cwd(),"app"),cs(process.cwd(),"src","app")];for(let r of s)if(r&&fn(r)){e=r;break}if(!e)throw new Error("Could not find external tasks directory");return e}function dl(){return T}import{getToken as Rn}from"next-auth/jwt";import{ResponseCookies as dc}from"next/dist/compiled/@edge-runtime/cookies";import{cookies as at,headers as An}from"next/headers";async function H(){let t=await Rn({req:{cookies:at(),headers:An()}});if(t?.expiresAt&&Date.now()>=t.expiresAt*1e3){let s=await fetch(`${process.env.NEXTAUTH_URL}/api/auth/session`,{method:"GET",headers:{"Content-Type":"application/json",cookie:at().toString()}}),r=new dc(s.headers);if(r.getAll().length){let n=!1;try{for(let o of r.getAll())at().set(o.name,o.value,{...o})}catch{n=!0}if(t=await Rn({req:{cookies:n?r:at(),headers:An()}}),t?.error)throw t.error}}if(!t?.accessToken||!t?.sub)throw new Error("AccessToken or Sub could not be determined!");return{token:t?.accessToken,userId:t?.sub}}import{DataModels as Le}from"@5minds/processcube_engine_client";async function He(){try{return H()}catch{return}}async function Tn(t){let e=await He();return(await T.processInstances.query({processInstanceId:t},{identity:e})).processInstances[0]}async function Sn(t,e={sortSettings:{sortBy:Le.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"ASC"}}){return(await T.flowNodeInstances.query({processInstanceId:t},{...e,identity:e.identity??await He()})).flowNodeInstances}async function In(t){let e=await He();return(await T.flowNodeInstances.query({triggeredByFlowNodeInstance:t},{identity:e})).flowNodeInstances}async function Cn(t,e,s){let r=await He();await T.processInstances.retryProcessInstance(t,{flowNodeInstanceId:e,newStartToken:s,identity:r})}async function bn(t){let e=await He();await T.processInstances.terminateProcessInstance(t,e)}async function Rl(t={options:{identity:!0}}){switch(t.options.identity){case!0:t.options.identity=await H();break;case!1:t.options.identity=void 0;break;case void 0:t.options.identity=await H();break}return await T.processInstances.query({...t?.query,state:Le.ProcessInstances.ProcessInstanceState.running},t?.options)}async function Al(t={},e=!0){let{processInstanceId:s}=t,r=typeof e=="boolean"?e==!0?await H():void 0:e;return new Promise(async(n,o)=>{let i=[],a=async c=>{if(s!==void 0&&c.processInstanceId!==s)return;let u=await T.processInstances.query({processInstanceId:c.processInstanceId},{identity:r});for(let d of i)T.notification.removeSubscription(d,r);return u.totalCount===0?o(new Error(`Process with instance ID "${c.processInstanceId}" does not exist.`)):n(u.processInstances[0])};if(i.push(await T.notification.onProcessEnded(a,{identity:r})),i.push(await T.notification.onProcessError(a,{identity:r})),i.push(await T.notification.onProcessTerminated(a,{identity:r})),s){let c=await T.processInstances.query({processInstanceId:s,state:[Le.ProcessInstances.ProcessInstanceState.finished,Le.ProcessInstances.ProcessInstanceState.terminated,Le.ProcessInstances.ProcessInstanceState.error]},{identity:r});if(c.totalCount>0){for(let f of i)T.notification.removeSubscription(f,r);n(c.processInstances[0])}}})}import{DataModels as ae}from"@5minds/processcube_engine_client";import{mapUserTask as xn,mapUserTaskList as ge}from"../common/index.mjs";async function vl(t={},e=!0){let{correlationId:s,processInstanceId:r,flowNodeId:n}=t,o=typeof e=="boolean"?e==!0?await H():void 0:e;return new Promise(async(i,a)=>{let c=await T.userTasks.onUserTaskWaiting(async u=>{let d=s!==void 0&&u.correlationId!==s,l=u.flowNodeInstanceId===void 0,y=r!==void 0&&u.processInstanceId!==r,E=n!==void 0&&u.flowNodeId!==n;if(d||l||y||E)return;let w=await pc(u.flowNodeInstanceId,{identity:o});return T.notification.removeSubscription(c,o),w===null?a(new Error(`UserTask with instance ID "${u.flowNodeInstanceId}" does not exist.`)):i(w)},{identity:o}),f=await hc({correlationId:s,processInstanceId:r,flowNodeId:n,state:ae.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:o});f.userTasks.length>0&&(T.notification.removeSubscription(c,o),i(f.userTasks[0]))})}async function Pl(t,e={},s={},r=!0){let n=typeof r=="boolean"?r==!0?await H():void 0:r;await T.userTasks.finishUserTask(t,s,n);let o={state:ae.FlowNodeInstances.FlowNodeInstanceState.suspended,...e},i=await T.userTasks.query(o,{identity:n});return xn(i.userTasks[0])}async function hc(t,e={identity:!0}){switch(e?.identity){case!0:e.identity=await H();break;case!1:e.identity=void 0;break;case void 0:e.identity=await H();break}let s=await T.userTasks.query(t,e);return ge(s)}async function Nl(t={identity:!0}){switch(t?.identity){case!0:t.identity=await H();break;case!1:t.identity=void 0;break;case void 0:t.identity=await H();break}let e=await T.userTasks.query({state:ae.FlowNodeInstances.FlowNodeInstanceState.suspended},t);return ge(e)}async function Ol(t,e={identity:!0}){switch(e?.identity){case!0:e.identity=await H();break;case!1:e.identity=void 0;break;case void 0:e.identity=await H();break}let s=await T.userTasks.query({processInstanceId:t,state:ae.FlowNodeInstances.FlowNodeInstanceState.suspended},e);return ge(s)}async function Ll(t,e={identity:!0}){switch(e?.identity){case!0:e.identity=await H();break;case!1:e.identity=void 0;break;case void 0:e.identity=await H();break}let s=await T.userTasks.query({flowNodeId:t,state:ae.FlowNodeInstances.FlowNodeInstanceState.suspended},e);return ge(s)}async function pc(t,e={identity:!0}){switch(e?.identity){case!0:e.identity=await H();break;case!1:e.identity=void 0;break;case void 0:e.identity=await H();break}let s=await T.userTasks.query({flowNodeInstanceId:t,state:ae.FlowNodeInstances.FlowNodeInstanceState.suspended},{...e,limit:1});return s.userTasks.length===0?null:xn(s.userTasks[0])}async function Hl(t,e={identity:!0}){switch(e?.identity){case!0:e.identity=await H();break;case!1:e.identity=void 0;break;case void 0:e.identity=await H();break}let s=await T.userTasks.query({correlationId:t,state:ae.FlowNodeInstances.FlowNodeInstanceState.suspended},e);return ge(s)}async function Dl(t,e){let s=t||await H(),r=await T.userTasks.query({state:ae.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:s,...e}),n=r.userTasks.filter(o=>o.actualOwnerId===s.userId);return r.userTasks=n,ge(r)}async function Fl(t,e,s){await T.userTasks.reserveUserTaskInstance(t,e,s||t.userId)}async function $l(t,e){await T.userTasks.cancelUserTaskInstanceReservation(t,e)}async function Ml(t,e){let s=t||await H(),r=await T.userTasks.query({state:ae.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:s,...e}),n=r.userTasks.filter(o=>o.assignedUserIds?.includes(s.userId));return r.userTasks=n,ge(r)}import{PHASE_DEVELOPMENT_SERVER as _c,PHASE_PRODUCTION_BUILD as gc,PHASE_PRODUCTION_SERVER as Ec}from"next/dist/shared/lib/constants";var kn=!1,fs=!1;function Gl(t={}){let{applicationSdk:e,...s}=t;return async(r,n)=>{fs=fs||r===gc;let o=r===_c||r===Ec;return e?.useExternalTasks&&o&&!kn&&!fs&&(kn=!0,await pn(e?.customExternalTasksDirPath)),{...s,experimental:{...s.experimental,serverComponentsExternalPackages:[...s.experimental?.serverComponentsExternalPackages||[],"esbuild"]}}}}import{revalidatePath as yc}from"next/cache";import{redirect as mc}from"next/navigation";function Vl(t){yc(t),mc(t)}async function Xl(...t){return await T.processModels.startProcessInstance(...t)}async function vn(...t){await T.manualTasks.finishManualTask(...t)}async function Pn(...t){await T.userTasks.finishUserTask(...t)}async function Nn(...t){await T.untypedTasks.finishTask(...t)}import{DataModels as wc}from"@5minds/processcube_engine_client";async function Rc(){try{return H()}catch{return}}var cu=async(t,e)=>{let s=await Rc();e==="bpmn:UserTask"?await Pn(t,{},s):e==="bpmn:ManualTask"?await vn(t,s):e==="bpmn:Task"?await Nn(t,s):console.error(`[@5minds/processcube_app_sdk:handlePlay] Unsupported flow node type: ${e}`)},lu=async t=>{await bn(t)},uu=async(t,e,s)=>{await Cn(t,e,s)},fu=async t=>Tn(t),du=async t=>Sn(t,{sortSettings:{sortBy:wc.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"DESC"}}),hu=async t=>In(t);export{$l as cancelReservedUserTask,vn as finishManualTask,cu as finishTask,Nn as finishUntypedTask,Pn as finishUserTask,Pl as finishUserTaskAndGetNext,Rl as getActiveProcessInstances,Ml as getAssignedUserTasksByIdentity,dl as getEngineClient,du as getFlowNodeInstances,Sn as getFlowNodeInstancesByProcessInstanceId,In as getFlowNodeInstancesTriggeredByFlowNodeInstanceIds,H as getIdentity,fu as getProcessInstance,Tn as getProcessInstanceById,Dl as getReservedUserTasksByIdentity,hu as getTriggeredFlowNodeInstances,hc as getUserTasks,pc as getWaitingUserTaskByFlowNodeInstanceId,Nl as getWaitingUserTasks,Hl as getWaitingUserTasksByCorrelationId,Ll as getWaitingUserTasksByFlowNodeId,Ol as getWaitingUserTasksByProcessInstanceId,Vl as navigateToUrl,Fl as reserveUserTask,uu as retryProcess,Cn as retryProcessInstance,Xl as startProcess,lu as terminateProcess,bn as terminateProcessInstance,Al as waitForProcessEnd,vl as waitForUserTask,Gl as withApplicationSdk};
|
|
2
3
|
/*! Bundled license information:
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
(*!
|
|
5
|
+
normalize-path/index.js:
|
|
6
|
+
(*!
|
|
7
|
+
* normalize-path <https://github.com/jonschlinkert/normalize-path>
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2014-2018, Jon Schlinkert.
|
|
10
|
+
* Released under the MIT License.
|
|
11
|
+
*)
|
|
12
|
+
|
|
13
|
+
is-extglob/index.js:
|
|
14
|
+
(*!
|
|
15
|
+
* is-extglob <https://github.com/jonschlinkert/is-extglob>
|
|
16
|
+
*
|
|
17
|
+
* Copyright (c) 2014-2016, Jon Schlinkert.
|
|
18
|
+
* Licensed under the MIT License.
|
|
19
|
+
*)
|
|
20
|
+
|
|
21
|
+
is-glob/index.js:
|
|
22
|
+
(*!
|
|
23
|
+
* is-glob <https://github.com/jonschlinkert/is-glob>
|
|
24
|
+
*
|
|
25
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
26
|
+
* Released under the MIT License.
|
|
27
|
+
*)
|
|
28
|
+
|
|
29
|
+
is-number/index.js:
|
|
30
|
+
(*!
|
|
31
|
+
* is-number <https://github.com/jonschlinkert/is-number>
|
|
32
|
+
*
|
|
33
|
+
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
34
|
+
* Released under the MIT License.
|
|
35
|
+
*)
|
|
36
|
+
|
|
37
|
+
to-regex-range/index.js:
|
|
38
|
+
(*!
|
|
39
|
+
* to-regex-range <https://github.com/micromatch/to-regex-range>
|
|
40
|
+
*
|
|
41
|
+
* Copyright (c) 2015-present, Jon Schlinkert.
|
|
42
|
+
* Released under the MIT License.
|
|
43
|
+
*)
|
|
44
|
+
|
|
45
|
+
fill-range/index.js:
|
|
46
|
+
(*!
|
|
47
|
+
* fill-range <https://github.com/jonschlinkert/fill-range>
|
|
48
|
+
*
|
|
49
|
+
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
50
|
+
* Licensed under the MIT License.
|
|
51
|
+
*)
|
|
6
52
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@5minds/processcube_app_sdk",
|
|
3
|
-
"version": "6.2.0
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "The SDK for ProcessCube Apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/common/index.cjs",
|
|
@@ -73,53 +73,53 @@
|
|
|
73
73
|
"*.css"
|
|
74
74
|
],
|
|
75
75
|
"devDependencies": {
|
|
76
|
-
"@tailwindcss/forms": "^0.5.
|
|
77
|
-
"@trivago/prettier-plugin-sort-imports": "^5.
|
|
78
|
-
"@types/node": "^22.
|
|
79
|
-
"@types/react": "
|
|
80
|
-
"@types/react-dom": "
|
|
81
|
-
"@types/react-is": "
|
|
82
|
-
"@types/semver": "^7.
|
|
76
|
+
"@tailwindcss/forms": "^0.5.7",
|
|
77
|
+
"@trivago/prettier-plugin-sort-imports": "^5.0.0",
|
|
78
|
+
"@types/node": "^22.0.0",
|
|
79
|
+
"@types/react": "^18.2.22",
|
|
80
|
+
"@types/react-dom": "^18.3.0",
|
|
81
|
+
"@types/react-is": "^18.2.4",
|
|
82
|
+
"@types/semver": "^7.5.8",
|
|
83
83
|
"@types/uuid": "^10.0.0",
|
|
84
|
-
"autoprefixer": "^10.4.
|
|
85
|
-
"concurrently": "^
|
|
84
|
+
"autoprefixer": "^10.4.16",
|
|
85
|
+
"concurrently": "^8.2.0",
|
|
86
86
|
"esbuild-style-plugin": "^1.6.3",
|
|
87
|
+
"postcss-import": "^16.0.1",
|
|
88
|
+
"prettier": "^3.0.0",
|
|
89
|
+
"prettier-plugin-tailwindcss": "^0.6.0",
|
|
87
90
|
"tailwindcss": "^3.4.1",
|
|
88
|
-
"
|
|
89
|
-
"prettier": "^3.5.3",
|
|
90
|
-
"prettier-plugin-tailwindcss": "^0.6.11",
|
|
91
|
-
"typescript": "^5.8.3"
|
|
91
|
+
"typescript": "^5.2.2"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
|
-
"next": ">=
|
|
94
|
+
"next": ">=14",
|
|
95
95
|
"next-auth": "~4.24.6",
|
|
96
|
-
"react": ">=
|
|
96
|
+
"react": ">=18.0.0"
|
|
97
97
|
},
|
|
98
98
|
"dependencies": {
|
|
99
99
|
"@5minds/processcube_engine_client": "6.0.0-beta.5",
|
|
100
100
|
"@5minds/processcube_engine_sdk": "7.0.0-beta.5",
|
|
101
|
-
"@headlessui/react": "^2.
|
|
102
|
-
"@heroicons/react": "^2.
|
|
103
|
-
"@monaco-editor/react": "^4.
|
|
104
|
-
"@heroui/react": "^2.
|
|
105
|
-
"bpmn-js": "^18.
|
|
106
|
-
"chokidar": "^
|
|
101
|
+
"@headlessui/react": "^2.1.1",
|
|
102
|
+
"@heroicons/react": "^2.1.4",
|
|
103
|
+
"@monaco-editor/react": "^4.6.0",
|
|
104
|
+
"@heroui/react": "^2.6.14",
|
|
105
|
+
"bpmn-js": "^18.6.0",
|
|
106
|
+
"chokidar": "^3.5.3",
|
|
107
107
|
"client-only": "^0.0.1",
|
|
108
|
-
"esbuild": "^0.25.
|
|
109
|
-
"isomorphic-dompurify": "^2.
|
|
108
|
+
"esbuild": "^0.25.0",
|
|
109
|
+
"isomorphic-dompurify": "^2.0.0",
|
|
110
110
|
"jwt-decode": "^4.0.0",
|
|
111
111
|
"lodash": "^4.17.21",
|
|
112
|
-
"marked": "^15.0.
|
|
112
|
+
"marked": "^15.0.0",
|
|
113
113
|
"only-server": "^0.0.1",
|
|
114
114
|
"openid-client": "^5.5.0",
|
|
115
|
-
"react-dom": "
|
|
116
|
-
"react-is": "
|
|
115
|
+
"react-dom": "^18.3.1",
|
|
116
|
+
"react-is": "^18.2.0",
|
|
117
117
|
"react-markdown": "^9.0.1",
|
|
118
118
|
"rehype-autolink-headings": "^7.1.0",
|
|
119
119
|
"rehype-raw": "^7.0.0",
|
|
120
120
|
"rehype-slug": "^6.0.0",
|
|
121
|
-
"remark-gfm": "^4.0.
|
|
122
|
-
"semver": "^7.
|
|
123
|
-
"uuid": "^11.
|
|
121
|
+
"remark-gfm": "^4.0.0",
|
|
122
|
+
"semver": "^7.6.0",
|
|
123
|
+
"uuid": "^11.0.0"
|
|
124
124
|
}
|
|
125
125
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use server";import{DataModels as C}from"@5minds/processcube_engine_client";import{DataModels as b}from"@5minds/processcube_engine_client";import{getToken as d}from"next-auth/jwt";import{ResponseCookies as k}from"next/dist/compiled/@edge-runtime/cookies";import{cookies as a,headers as y}from"next/headers";async function i(){let e=await d({req:{cookies:await a(),headers:await y()}});if(e?.expiresAt&&Date.now()>=e.expiresAt*1e3){let s=await fetch(`${process.env.NEXTAUTH_URL}/api/auth/session`,{method:"GET",headers:{"Content-Type":"application/json",cookie:(await a()).toString()}}),o=new k(s.headers);if(o.getAll().length){let p=!1;try{for(let c of o.getAll())(await a()).set(c.name,c.value,{...c})}catch{p=!0}if(e=await d({req:{cookies:p?o:await a(),headers:await y()}}),e?.error)throw e.error}}if(!e?.accessToken||!e?.sub)throw new Error("AccessToken or Sub could not be determined!");return{token:e?.accessToken,userId:e?.sub}}import{EngineClient as T}from"@5minds/processcube_engine_client";var h=process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560",n=new T(h);async function r(){try{return i()}catch{return}}async function u(e){let t=await r();return(await n.processInstances.query({processInstanceId:e},{identity:t})).processInstances[0]}async function I(e,t={sortSettings:{sortBy:b.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"ASC"}}){return(await n.flowNodeInstances.query({processInstanceId:e},{...t,identity:t.identity??await r()})).flowNodeInstances}async function l(e){let t=await r();return(await n.flowNodeInstances.query({triggeredByFlowNodeInstance:e},{identity:t})).flowNodeInstances}async function f(e,t,s){let o=await r();await n.processInstances.retryProcessInstance(e,{flowNodeInstanceId:t,newStartToken:s,identity:o})}async function m(e){let t=await r();await n.processInstances.terminateProcessInstance(e,t)}async function w(...e){await n.manualTasks.finishManualTask(...e)}async function g(...e){await n.userTasks.finishUserTask(...e)}async function P(...e){await n.untypedTasks.finishTask(...e)}async function E(){try{return i()}catch{return}}var X=async(e,t)=>{let s=await E();t==="bpmn:UserTask"?await g(e,{},s):t==="bpmn:ManualTask"?await w(e,s):t==="bpmn:Task"?await P(e,s):console.error(`[@5minds/processcube_app_sdk:handlePlay] Unsupported flow node type: ${t}`)},z=async e=>{await m(e)},J=async(e,t,s)=>{await f(e,t,s)},K=async e=>u(e),V=async e=>I(e,{sortSettings:{sortBy:C.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"DESC"}}),W=async e=>l(e);export{X as finishTask,V as getFlowNodeInstances,K as getProcessInstance,W as getTriggeredFlowNodeInstances,J as retryProcess,z as terminateProcess};
|