@5minds/processcube_app_sdk 6.2.0-feature-afd7db-m9jner2j → 6.2.0-feature-b0f0cb-m9jnmlua

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use server";import{DataModels as D}from"@5minds/processcube_engine_client";import{DataModels as S}from"@5minds/processcube_engine_client";import{getToken as y}from"next-auth/jwt";import{ResponseCookies as E}from"next/dist/compiled/@edge-runtime/cookies";import{cookies as d,headers as f}from"next/headers";async function l(){let e=await y({req:{cookies:d(),headers:f()}});if(e?.expiresAt&&Date.now()>=e.expiresAt*1e3){let n=await fetch(`${process.env.NEXTAUTH_URL}/api/auth/session`,{method:"GET",headers:{"Content-Type":"application/json",cookie:d().toString()}}),t=new E(n.headers);if(t.getAll().length){let a=!1;try{for(let r of t.getAll())d().set(r.name,r.value,{...r})}catch{a=!0}if(e=await y({req:{cookies:a?t:d(),headers:f()}}),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 M}from"@5minds/processcube_engine_client";var x=process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560",o=new M(x);var p=300,I=1e3;async function i(){try{return l()}catch{return}}async function m(e){let s=await i();return(await o.processInstances.query({processInstanceId:e},{identity:s})).processInstances[0]}async function g(e,s){let{processInstanceId:n,flowNodeInstanceId:t}=e,a=t;if(!n&&!a)return[];let r=[];return a&&a.length>p?await Promise.all(new Array(Math.ceil(a.length/p)).fill(null).map(async(u,c)=>{let b=await w({flowNodeInstanceId:a.slice(c*p,(c+1)*p)},{...s,identity:s?.identity??await i()});r.push(...b)})):r.push(...await w({processInstanceId:n,flowNodeInstanceId:a},{...s,identity:s?.identity??await i()})),r}async function P(e,s={sortSettings:{sortBy:S.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"ASC"}}){return await g({processInstanceId:e},s)}async function k(e){return await g({triggeredByFlowNodeInstance:e})}async function N(e,s,n){let t=await i();await o.processInstances.retryProcessInstance(e,{flowNodeInstanceId:s,newStartToken:n,identity:t})}async function h(e){let s=await i();await o.processInstances.terminateProcessInstance(e,s)}async function w(e,s){let n=[],t=await o.flowNodeInstances.query(e,{...s,limit:I});if(n.push(...t.flowNodeInstances),t.flowNodeInstances.length!==t.totalCount){let a=Math.floor(t.totalCount/t.flowNodeInstances.length);await Promise.all(new Array(a).fill(null).map(async(r,u)=>{let c=await o.flowNodeInstances.query(e,{...s,limit:I,offset:I*(u+1)});n.push(...c.flowNodeInstances)}))}return n}async function T(...e){await o.manualTasks.finishManualTask(...e)}async function F(...e){await o.userTasks.finishUserTask(...e)}async function C(...e){await o.untypedTasks.finishTask(...e)}async function _(){try{return l()}catch{return}}var Z=async(e,s)=>{let n=await _();s==="bpmn:UserTask"?await F(e,{},n):s==="bpmn:ManualTask"?await T(e,n):s==="bpmn:Task"?await C(e,n):console.error(`[@5minds/processcube_app_sdk:handlePlay] Unsupported flow node type: ${s}`)},ee=async e=>{await h(e)},se=async(e,s,n)=>{await N(e,s,n)},ne=async e=>m(e),te=async e=>P(e,{sortSettings:{sortBy:D.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"DESC"}}),oe=async e=>k(e);export{Z as finishTask,te as getFlowNodeInstances,ne as getProcessInstance,oe as getTriggeredFlowNodeInstances,se as retryProcess,ee as terminateProcess};
@@ -1,4 +1,4 @@
1
- "use client";var ua=Object.create;var eo=Object.defineProperty;var ka=Object.getOwnPropertyDescriptor;var fa=Object.getOwnPropertyNames;var ha=Object.getPrototypeOf,ga=Object.prototype.hasOwnProperty;var ee=(e,o)=>()=>(e&&(o=e(e=0)),o);var Ft=(e,o)=>{for(var t in o)eo(e,t,{get:o[t],enumerable:!0})},Ct=(e,o,t,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of fa(o))!ga.call(e,a)&&a!==t&&eo(e,a,{get:()=>o[a],enumerable:!(s=ka(o,a))||s.enumerable});return e};var d=(e,o,t)=>(t=e!=null?ua(ha(e)):{},Ct(o||!e||!e.__esModule?eo(t,"default",{value:e,enumerable:!0}):t,e)),wa=e=>Ct(eo({},"__esModule",{value:!0}),e);async function zo(){let e=await(0,yt.getToken)({req:{cookies:(0,ge.cookies)(),headers:(0,ge.headers)()}});if(e?.expiresAt&&Date.now()>=e.expiresAt*1e3){let t=await fetch(`${process.env.NEXTAUTH_URL}/api/auth/session`,{method:"GET",headers:{"Content-Type":"application/json",cookie:(0,ge.cookies)().toString()}}),s=new vs.ResponseCookies(t.headers);if(s.getAll().length){let a=!1;try{for(let r of s.getAll())(0,ge.cookies)().set(r.name,r.value,{...r})}catch{a=!0}if(e=await(0,yt.getToken)({req:{cookies:a?s:(0,ge.cookies)(),headers:(0,ge.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 yt,vs,ge,vt=ee(()=>{yt=require("next-auth/jwt"),vs=require("next/dist/compiled/@edge-runtime/cookies"),ge=require("next/headers")});var bs,Za,Z,qe=ee(()=>{bs=require("@5minds/processcube_engine_client"),Za=process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560",Z=new bs.EngineClient(Za)});async function Xe(){try{return zo()}catch{return}}async function Ns(e){let o=await Xe();return(await Z.processInstances.query({processInstanceId:e},{identity:o})).processInstances[0]}async function Fs(e,o){let{processInstanceId:t,flowNodeInstanceId:s}=e,a=s;if(!t&&!a)return[];let r=[];return a&&a.length>$o?await Promise.all(new Array(Math.ceil(a.length/$o)).fill(null).map(async(n,i)=>{let p=await Is({flowNodeInstanceId:a.slice(i*$o,(i+1)*$o)},{...o,identity:o?.identity??await Xe()});r.push(...p)})):r.push(...await Is({processInstanceId:t,flowNodeInstanceId:a},{...o,identity:o?.identity??await Xe()})),r}async function Cs(e,o={sortSettings:{sortBy:xs.DataModels.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"ASC"}}){return await Fs({processInstanceId:e},o)}async function Ps(e){return await Fs({triggeredByFlowNodeInstance:e})}async function Ss(e,o,t){let s=await Xe();await Z.processInstances.retryProcessInstance(e,{flowNodeInstanceId:o,newStartToken:t,identity:s})}async function Ds(e){let o=await Xe();await Z.processInstances.terminateProcessInstance(e,o)}async function Is(e,o){let t=[],s=await Z.flowNodeInstances.query(e,{...o,limit:bt});if(t.push(...s.flowNodeInstances),s.flowNodeInstances.length!==s.totalCount){let a=Math.floor(s.totalCount/s.flowNodeInstances.length);await Promise.all(new Array(a).fill(null).map(async(r,n)=>{let i=await Z.flowNodeInstances.query(e,{...o,limit:bt,offset:bt*(n+1)});t.push(...i.flowNodeInstances)}))}return t}var xs,$o,bt,Ts=ee(()=>{xs=require("@5minds/processcube_engine_client");vt();qe();$o=300,bt=1e3});var Qa,Ka,Ms=ee(()=>{Qa=require("next/cache"),Ka=require("next/navigation")});var Es=ee(()=>{});async function Bs(...e){await Z.manualTasks.finishManualTask(...e)}var Us=ee(()=>{qe()});async function Os(...e){await Z.userTasks.finishUserTask(...e)}var Ls=ee(()=>{qe()});async function _s(...e){await Z.untypedTasks.finishTask(...e)}var Vs=ee(()=>{qe()});var As=ee(()=>{Ms();Es();Us();Ls();Vs()});var _e={};Ft(_e,{finishTask:()=>or,getFlowNodeInstances:()=>rr,getProcessInstance:()=>ar,getTriggeredFlowNodeInstances:()=>nr,retryProcess:()=>sr,terminateProcess:()=>tr});async function er(){try{return zo()}catch{return}}var zs,or,tr,sr,ar,rr,nr,Ve=ee(()=>{"use server";zs=require("@5minds/processcube_engine_sdk");Ts();vt();As();or=async(e,o)=>{let t=await er();o==="bpmn:UserTask"?await Os(e,{},t):o==="bpmn:ManualTask"?await Bs(e,t):o==="bpmn:Task"?await _s(e,t):console.error(`[@5minds/processcube_app_sdk:handlePlay] Unsupported flow node type: ${o}`)},tr=async e=>{await Ds(e)},sr=async(e,o,t)=>{await Ss(e,o,t)},ar=async e=>Ns(e),rr=async e=>Cs(e,{sortSettings:{sortBy:zs.DataModels.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"DESC"}}),nr=async e=>Ps(e)});var cr={};Ft(cr,{BPMNViewer:()=>oo,BPMNViewerNextJS:()=>Ia,BooleanFormField:()=>io,BpmnViewerComponent:()=>ut,CheckboxFormField:()=>po,ColorFormField:()=>lo,ConfirmFormField:()=>mo,CustomFormField:()=>uo,DateFormField:()=>ko,DatetimeLocalFormField:()=>fo,DecimalFormField:()=>go,DiagramDocumentationInspector:()=>ao,DiagramDocumentationInspectorNextJS:()=>Da,DocumentationViewer:()=>to,DropdownMenu:()=>Ta,DropdownMenuItem:()=>Ma,DynamicLink:()=>Ea,DynamicUi:()=>ja,DynamicUiComponent:()=>gt,EmailFormField:()=>wo,EnumFormField:()=>yo,FileFormField:()=>vo,FlowNode:()=>ro,FormFieldComponentMap:()=>ht,HeaderFormField:()=>bo,HiddenFormField:()=>Io,IntegerFormField:()=>xo,MonthFormField:()=>No,ParagraphFormField:()=>So,PasswordFormField:()=>Do,ProcessInstanceInspector:()=>na,ProcessInstanceInspectorNextJS:()=>lr,RadioFormField:()=>To,RangeFormField:()=>Mo,SelectFormField:()=>Eo,SplitterLayout:()=>$e,StringFormField:()=>Bo,TelFormField:()=>Uo,TextareaFormField:()=>Ee,TimeFormField:()=>Oo,UrlFormField:()=>Lo,WeekFormField:()=>_o});module.exports=wa(cr);var Gp=require("client-only");var Pt=d(require("bpmn-js/lib/Viewer"),1),St=d(require("bpmn-js/lib/features/outline"),1),Dt=d(require("clsx"),1),Tt=d(require("diagram-js/lib/features/selection"),1),Mt=d(require("diagram-js/lib/navigation/movecanvas"),1),Et=d(require("diagram-js/lib/navigation/zoomscroll"),1),Bt=d(require("next/dynamic"),1),de=require("react"),et=d(require("react"),1),ya={canvas:{autoFocus:!0}};function va(e,o){let t=(0,de.useRef)(null),s=(0,de.useRef)(new Pt.default({bpmnRenderer:{defaultFillColor:"var(--asdk-bv-background-color)",defaultStrokeColor:"var(--asdk-bv-foreground-color)"},additionalModules:[Et.default,Mt.default,Tt.default,St.default],...ya}));return(0,de.useImperativeHandle)(o,()=>({getOverlays(){return s.current.get("overlays")},getElementRegistry(){return s.current.get("elementRegistry")},addMarker(a,r){s.current.get("canvas")?.addMarker(a,r)},removeMarker(a,r){s.current.get("canvas")?.removeMarker(a,r)},hasMarker(a,r){return s.current.get("canvas")?.hasMarker(a,r)}}),[s.current,t.current]),(0,de.useEffect)(()=>{if(!t.current)return;let a=s.current;a.attachTo(t.current);let r=a.get("canvas"),n=i=>{e.onSelectionChanged?.(i.newSelection)};return a.importXML(e.xml).then(()=>{let i=r.viewbox(),p={x:i.outer.width/2,y:i.outer.height/2};r.zoom("fit-viewport",p),e.onImportDone?.(),a.on("selection.changed",n);let{preselectedElementIds:g}=e;if(!g||g.length===0)return;let f=a.get("elementRegistry").filter(D=>g.includes(D.id)).sort((D,j)=>g.indexOf(D.id)-g.indexOf(j.id));a.get("selection").select(f??[])}).catch(i=>{console.error(`[@5minds/processcube_app_sdk:BPMNViewer] Error while importing BPMN XML: "${i.message}`)}),()=>{a.off("selection.changed",n),a.detach()}},[e.xml,e.preselectedElementIds]),et.default.createElement("div",{ref:t,className:(0,Dt.default)("app-sdk-bpmn-viewer","app-sdk-h-full",e.className)})}var oo=(0,de.forwardRef)(va);function ba(e){return et.default.createElement(oo,{...e,ref:e.viewerRef})}var Ia=(0,Bt.default)(()=>Promise.resolve(ba),{ssr:!1});var so=require("bpmn-js/lib/util/ModelUtil"),zt=d(require("next/dynamic"),1),B=d(require("react"),1),H=require("react"),Ne=require("react-dom/server");var ot=d(require("react"),1),Ut=d(require("react-markdown"),1),Ot=d(require("rehype-autolink-headings"),1),Lt=d(require("rehype-raw"),1),_t=d(require("rehype-slug"),1),Vt=d(require("remark-gfm"),1);function to(e){return ot.default.createElement("div",{className:"app-sdk-absolute app-sdk-w-full app-sdk-h-full app-sdk-overflow-y-auto app-sdk-scroll-p-4 app-sdk-scroll-smooth app-sdk-scroll-shadow"},ot.default.createElement(Ut.default,{remarkPlugins:[Vt.default],rehypePlugins:[Lt.default,_t.default,[Ot.default,{behavior:"wrap"}]],className:"app-sdk-markdown lg:app-sdk-mx-40 md:app-sdk-mx-20 app-sdk-mx-10"},e.documentation??""))}var ie=d(require("react"),1),At=4,$e=class extends ie.default.Component{static defaultProps={customClassName:"",vertical:!1,percentage:!1,primaryIndex:0,primaryMinSize:0,secondaryDefaultSize:null,secondaryInitialSize:null,secondaryMinSize:0,onDragStart:null,onDragEnd:null,onSizeChanged:null,children:[]};container;splitter;constructor(o){super(o),this.handleResize=this.handleResize.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleTouchMove=this.handleTouchMove.bind(this),this.handleSplitterMouseDown=this.handleSplitterMouseDown.bind(this),this.handleSplitterDoubleClick=this.handleSplitterDoubleClick.bind(this),this.state={lastMouseDown:0,secondaryPaneSize:o.secondaryInitialSize||0,resizing:!1}}componentDidMount(){window.addEventListener("resize",this.handleResize),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchend",this.handleMouseUp),document.addEventListener("touchmove",this.handleTouchMove);let o;if(this.props.secondaryInitialSize!=null)o=this.props.secondaryInitialSize;else{let t=this.container.getBoundingClientRect(),s;this.splitter?s=this.splitter.getBoundingClientRect():s={width:At,height:At},o=this.getSecondaryPaneSize(t,s,{left:t.left+(t.width-s.width)/2,top:t.top+(t.height-s.height)/2},!1)}this.setSecondaryPaneSize(o)}componentDidUpdate(o,t){t.secondaryPaneSize!==this.state.secondaryPaneSize&&this.props.onSizeChanged&&this.props.onSizeChanged(this.state.secondaryPaneSize),t.resizing!==this.state.resizing&&(this.state.resizing?this.props.onDragStart&&this.props.onDragStart(t.secondaryPaneSize):this.props.onDragEnd&&this.props.onDragEnd(t.secondaryPaneSize,this.state.secondaryPaneSize))}componentWillUnmount(){window.removeEventListener("resize",this.handleResize),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("touchend",this.handleMouseUp),document.removeEventListener("touchmove",this.handleTouchMove)}clearSelection(){if(document.body.createTextRange){let o=document.body.createTextRange();o.collapse(),o.select()}else if(window.getSelection){let o=window.getSelection();if(o==null)return;o.empty?o.empty():o.removeAllRanges&&o.removeAllRanges()}else document.selection&&document.selection.empty()}getSecondaryPaneSize(o,t,s,a){let r=0,n=0,i=0;this.props.vertical?(r=o.height,n=t.height,i=s.top-o.top):(r=o.width,n=t.width,i=s.left-o.left),a&&(i-=n/2),i<0?i=0:i>r-n&&(i=r-n);let p;this.props.primaryIndex===1?p=i:p=r-n-i;let g=r-n-p;return this.props.percentage&&(p=p*100/r,g=g*100/r,n=n*100/r,r=100),g<this.props.primaryMinSize?p=Math.max(p-(this.props.primaryMinSize-g),0):p<this.props.secondaryMinSize&&(p=Math.min(r-n-this.props.primaryMinSize,this.props.secondaryMinSize)),p}setSecondaryPaneSize(o){this.setState({secondaryPaneSize:o})}maximizeSecondaryPane(){if(this.props.percentage)this.setSecondaryPaneSize(100-this.props.primaryMinSize);else throw new Error("maximizeSecondaryPane() is only supported in SplitterLayout with prop `percentage`")}isReset(){let o=this.props.secondaryDefaultSize||this.props.secondaryMinSize;return this.state.secondaryPaneSize===o}reset(){let o=this.props.secondaryDefaultSize||this.props.secondaryMinSize;this.setSecondaryPaneSize(o)}handleResize(){if(this.splitter&&!this.props.percentage){let o=this.container.getBoundingClientRect(),t=this.splitter.getBoundingClientRect(),s=this.getSecondaryPaneSize(o,t,{left:t.left,top:t.top},!1);this.setState({secondaryPaneSize:s})}}handleMouseMove(o){if(this.state.resizing){let t=this.container.getBoundingClientRect(),s=this.splitter.getBoundingClientRect(),a=this.getSecondaryPaneSize(t,s,{left:o.clientX,top:o.clientY},!0);this.clearSelection(),this.setState({secondaryPaneSize:a})}}handleTouchMove(o){this.handleMouseMove(o.changedTouches[0])}handleSplitterMouseDown(o){o.preventDefault(),this.clearSelection(),this.setState({resizing:!0})}handleSplitterDoubleClick(){let o=this.props.secondaryDefaultSize||this.props.secondaryMinSize;this.state.secondaryPaneSize===o?this.setSecondaryPaneSize(Math.floor(o*1.5)):this.setSecondaryPaneSize(o)}handleMouseUp(){this.setState(o=>o.resizing?{resizing:!1}:null)}render(){let o="app-sdk-splitter-layout";this.props.customClassName&&(o+=` ${this.props.customClassName}`),this.props.vertical&&(o+=" app-sdk-splitter-layout-vertical"),this.state.resizing&&(o+=" layout-changing");let t=ie.default.Children.toArray(this.props.children).slice(0,2);t.length===0&&t.push(ie.default.createElement("div",null));let s=[],a=this.props.primaryIndex!==0&&this.props.primaryIndex!==1?0:this.props.primaryIndex;for(let r=0;r<t.length;++r){let n=!0,i;t.length>1&&r!==a&&(n=!1,i=this.state.secondaryPaneSize),s.push(ie.default.createElement(xa,{vertical:this.props.vertical,percentage:this.props.percentage,primary:n,size:i},t[r]))}return ie.default.createElement("div",{className:o,ref:r=>{this.container=r}},s[0],s.length>1&&ie.default.createElement("div",{role:"separator",className:"app-sdk-layout-splitter"},ie.default.createElement("div",{className:"app-sdk-layout-splitter__inner",ref:r=>{this.splitter=r},onMouseDown:this.handleSplitterMouseDown,onTouchStart:this.handleSplitterMouseDown,onDoubleClick:this.handleSplitterDoubleClick})),s.length>1&&s[1])}};function xa(e={vertical:!1,primary:!1,size:0,percentage:!1,children:[]}){let o=e.size||0,t=e.percentage?"%":"px",s="app-sdk-layout-pane",a={};return e.primary?s+=" app-sdk-layout-pane-primary":e.vertical?a.height=`${o}${t}`:a.width=`${o}${t}`,ie.default.createElement("div",{className:s,style:a},e.children)}var He=30;function Na(e,o){let[t,s]=(0,H.useState)([]),a=(0,H.useRef)(null),r=(0,H.useRef)(null),[n,i]=(0,H.useState)([]),[p,g]=(0,H.useState)(!1),[c,f]=(0,H.useState)([]),[D,j]=(0,H.useState)(He);return(0,H.useEffect)(()=>{if(!window)return;let l=new URLSearchParams(window.location.search),k=l.getAll("selected");if(f(k),!l.has("splitterSize"))return;let P=parseFloat(l.get("splitterSize"));isNaN(P)||P===He||(j(P),r.current?.setSecondaryPaneSize(P))},[]),(0,H.useEffect)(()=>{if(!p)return;let l=new URLSearchParams(window.location.search);D!==He?l.set("splitterSize",D.toString()):l.delete("splitterSize"),l.delete("selected"),n.length>0&&n.forEach(Y=>l.append("selected",Y.id));let k=decodeURIComponent(window.location.hash.slice(1)),P=k.length>0?document.getElementById(k):null;window.history.replaceState(null,"",`?${l.toString()}${P?window.location.hash:""}`),window.location.hash&&(window.location.hash=window.location.hash),P?.scrollIntoView()},[n,D]),(0,H.useEffect)(()=>{if(!p)return;t.forEach(Y=>Y());let l=a.current?.getOverlays();a.current?.getElementRegistry()?.filter($t)?.forEach(Y=>{l?.add(Y.id,Pa(Y))})},[p]),(0,H.useEffect)(()=>{e.setSelectedElementIds?.(n.map(l=>l.id))},[n]),(0,H.useImperativeHandle)(o,()=>({bpmnViewerRef:{getElementRegistry(){return a.current?.getElementRegistry()},getOverlays(){return a.current?.getOverlays()},addMarker(l,k){a.current?.addMarker(l,k)},removeMarker(l,k){a.current?.removeMarker(l,k)},hasMarker(l,k){return a.current?.hasMarker(l,k)},onImportDone(l){p?l():s(k=>[...k,l])}}}),[a.current]),B.default.createElement($e,{ref:r,vertical:!0,percentage:!0,secondaryInitialSize:He,secondaryDefaultSize:He,onDragEnd:(l,k)=>j(Math.round(k))},B.default.createElement(oo,{ref:a,xml:e.xml,preselectedElementIds:c,onSelectionChanged:l=>i([...l]),onImportDone:()=>g(!0)}),B.default.createElement("div",{className:"app-sdk-flex app-sdk-justify-center app-sdk-h-full app-sdk-bg-[color:var(--asdk-ddi-background-color)]"},B.default.createElement(Fa,{elements:n})))}function Fa({elements:e}){if(e.length===0)return B.default.createElement("p",{className:"app-sdk-m-0 app-sdk-p-6"},"Please select an element");let o=e.filter($t);if(o.length===0)return B.default.createElement("p",{className:"app-sdk-m-0 app-sdk-p-6"},"No documentation available");if(o.length===1){let t=(0,so.getBusinessObject)(o[0])?.documentation?.[0]?.text;return B.default.createElement(to,{documentation:t})}return B.default.createElement(to,{documentation:o.map(t=>(0,so.getBusinessObject)(t)?.documentation?.[0]?.text).join(`
1
+ "use client";var ua=Object.create;var eo=Object.defineProperty;var ka=Object.getOwnPropertyDescriptor;var fa=Object.getOwnPropertyNames;var ha=Object.getPrototypeOf,ga=Object.prototype.hasOwnProperty;var ee=(e,o)=>()=>(e&&(o=e(e=0)),o);var Ft=(e,o)=>{for(var t in o)eo(e,t,{get:o[t],enumerable:!0})},Ct=(e,o,t,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let a of fa(o))!ga.call(e,a)&&a!==t&&eo(e,a,{get:()=>o[a],enumerable:!(s=ka(o,a))||s.enumerable});return e};var d=(e,o,t)=>(t=e!=null?ua(ha(e)):{},Ct(o||!e||!e.__esModule?eo(t,"default",{value:e,enumerable:!0}):t,e)),wa=e=>Ct(eo({},"__esModule",{value:!0}),e);async function zo(){let e=await(0,yt.getToken)({req:{cookies:(0,ge.cookies)(),headers:(0,ge.headers)()}});if(e?.expiresAt&&Date.now()>=e.expiresAt*1e3){let t=await fetch(`${process.env.NEXTAUTH_URL}/api/auth/session`,{method:"GET",headers:{"Content-Type":"application/json",cookie:(0,ge.cookies)().toString()}}),s=new vs.ResponseCookies(t.headers);if(s.getAll().length){let a=!1;try{for(let r of s.getAll())(0,ge.cookies)().set(r.name,r.value,{...r})}catch{a=!0}if(e=await(0,yt.getToken)({req:{cookies:a?s:(0,ge.cookies)(),headers:(0,ge.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 yt,vs,ge,vt=ee(()=>{yt=require("next-auth/jwt"),vs=require("next/dist/compiled/@edge-runtime/cookies"),ge=require("next/headers")});var bs,Za,Z,qe=ee(()=>{bs=require("@5minds/processcube_engine_client"),Za=process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560",Z=new bs.EngineClient(Za)});async function Xe(){try{return zo()}catch{return}}async function Ns(e){let o=await Xe();return(await Z.processInstances.query({processInstanceId:e},{identity:o})).processInstances[0]}async function Fs(e,o){let{processInstanceId:t,flowNodeInstanceId:s}=e,a=s;if(!t&&!a)return[];let r=[];return a&&a.length>$o?await Promise.all(new Array(Math.ceil(a.length/$o)).fill(null).map(async(n,i)=>{let p=await Is({flowNodeInstanceId:a.slice(i*$o,(i+1)*$o)},{...o,identity:o?.identity??await Xe()});r.push(...p)})):r.push(...await Is({processInstanceId:t,flowNodeInstanceId:a},{...o,identity:o?.identity??await Xe()})),r}async function Cs(e,o={sortSettings:{sortBy:xs.DataModels.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"ASC"}}){return await Fs({processInstanceId:e},o)}async function Ps(e){return await Fs({triggeredByFlowNodeInstance:e})}async function Ss(e,o,t){let s=await Xe();await Z.processInstances.retryProcessInstance(e,{flowNodeInstanceId:o,newStartToken:t,identity:s})}async function Ds(e){let o=await Xe();await Z.processInstances.terminateProcessInstance(e,o)}async function Is(e,o){let t=[],s=await Z.flowNodeInstances.query(e,{...o,limit:bt});if(t.push(...s.flowNodeInstances),s.flowNodeInstances.length!==s.totalCount){let a=Math.floor(s.totalCount/s.flowNodeInstances.length);await Promise.all(new Array(a).fill(null).map(async(r,n)=>{let i=await Z.flowNodeInstances.query(e,{...o,limit:bt,offset:bt*(n+1)});t.push(...i.flowNodeInstances)}))}return t}var xs,$o,bt,Ts=ee(()=>{xs=require("@5minds/processcube_engine_client");vt();qe();$o=300,bt=1e3});var Qa,Ka,Ms=ee(()=>{Qa=require("next/cache"),Ka=require("next/navigation")});var Es=ee(()=>{});async function Bs(...e){await Z.manualTasks.finishManualTask(...e)}var Us=ee(()=>{qe()});async function Os(...e){await Z.userTasks.finishUserTask(...e)}var Ls=ee(()=>{qe()});async function _s(...e){await Z.untypedTasks.finishTask(...e)}var Vs=ee(()=>{qe()});var As=ee(()=>{Ms();Es();Us();Ls();Vs()});var _e={};Ft(_e,{finishTask:()=>or,getFlowNodeInstances:()=>rr,getProcessInstance:()=>ar,getTriggeredFlowNodeInstances:()=>nr,retryProcess:()=>sr,terminateProcess:()=>tr});async function er(){try{return zo()}catch{return}}var zs,or,tr,sr,ar,rr,nr,Ve=ee(()=>{"use server";zs=require("@5minds/processcube_engine_client");Ts();vt();As();or=async(e,o)=>{let t=await er();o==="bpmn:UserTask"?await Os(e,{},t):o==="bpmn:ManualTask"?await Bs(e,t):o==="bpmn:Task"?await _s(e,t):console.error(`[@5minds/processcube_app_sdk:handlePlay] Unsupported flow node type: ${o}`)},tr=async e=>{await Ds(e)},sr=async(e,o,t)=>{await Ss(e,o,t)},ar=async e=>Ns(e),rr=async e=>Cs(e,{sortSettings:{sortBy:zs.DataModels.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"DESC"}}),nr=async e=>Ps(e)});var cr={};Ft(cr,{BPMNViewer:()=>oo,BPMNViewerNextJS:()=>Ia,BooleanFormField:()=>io,BpmnViewerComponent:()=>ut,CheckboxFormField:()=>po,ColorFormField:()=>lo,ConfirmFormField:()=>mo,CustomFormField:()=>uo,DateFormField:()=>ko,DatetimeLocalFormField:()=>fo,DecimalFormField:()=>go,DiagramDocumentationInspector:()=>ao,DiagramDocumentationInspectorNextJS:()=>Da,DocumentationViewer:()=>to,DropdownMenu:()=>Ta,DropdownMenuItem:()=>Ma,DynamicLink:()=>Ea,DynamicUi:()=>ja,DynamicUiComponent:()=>gt,EmailFormField:()=>wo,EnumFormField:()=>yo,FileFormField:()=>vo,FlowNode:()=>ro,FormFieldComponentMap:()=>ht,HeaderFormField:()=>bo,HiddenFormField:()=>Io,IntegerFormField:()=>xo,MonthFormField:()=>No,ParagraphFormField:()=>So,PasswordFormField:()=>Do,ProcessInstanceInspector:()=>na,ProcessInstanceInspectorNextJS:()=>lr,RadioFormField:()=>To,RangeFormField:()=>Mo,SelectFormField:()=>Eo,SplitterLayout:()=>$e,StringFormField:()=>Bo,TelFormField:()=>Uo,TextareaFormField:()=>Ee,TimeFormField:()=>Oo,UrlFormField:()=>Lo,WeekFormField:()=>_o});module.exports=wa(cr);var jp=require("client-only");var Pt=d(require("bpmn-js/lib/Viewer"),1),St=d(require("bpmn-js/lib/features/outline"),1),Dt=d(require("clsx"),1),Tt=d(require("diagram-js/lib/features/selection"),1),Mt=d(require("diagram-js/lib/navigation/movecanvas"),1),Et=d(require("diagram-js/lib/navigation/zoomscroll"),1),Bt=d(require("next/dynamic"),1),de=require("react"),et=d(require("react"),1),ya={canvas:{autoFocus:!0}};function va(e,o){let t=(0,de.useRef)(null),s=(0,de.useRef)(new Pt.default({bpmnRenderer:{defaultFillColor:"var(--asdk-bv-background-color)",defaultStrokeColor:"var(--asdk-bv-foreground-color)"},additionalModules:[Et.default,Mt.default,Tt.default,St.default],...ya}));return(0,de.useImperativeHandle)(o,()=>({getOverlays(){return s.current.get("overlays")},getElementRegistry(){return s.current.get("elementRegistry")},addMarker(a,r){s.current.get("canvas")?.addMarker(a,r)},removeMarker(a,r){s.current.get("canvas")?.removeMarker(a,r)},hasMarker(a,r){return s.current.get("canvas")?.hasMarker(a,r)}}),[s.current,t.current]),(0,de.useEffect)(()=>{if(!t.current)return;let a=s.current;a.attachTo(t.current);let r=a.get("canvas"),n=i=>{e.onSelectionChanged?.(i.newSelection)};return a.importXML(e.xml).then(()=>{let i=r.viewbox(),p={x:i.outer.width/2,y:i.outer.height/2};r.zoom("fit-viewport",p),e.onImportDone?.(),a.on("selection.changed",n);let{preselectedElementIds:g}=e;if(!g||g.length===0)return;let f=a.get("elementRegistry").filter(D=>g.includes(D.id)).sort((D,j)=>g.indexOf(D.id)-g.indexOf(j.id));a.get("selection").select(f??[])}).catch(i=>{console.error(`[@5minds/processcube_app_sdk:BPMNViewer] Error while importing BPMN XML: "${i.message}`)}),()=>{a.off("selection.changed",n),a.detach()}},[e.xml,e.preselectedElementIds]),et.default.createElement("div",{ref:t,className:(0,Dt.default)("app-sdk-bpmn-viewer","app-sdk-h-full",e.className)})}var oo=(0,de.forwardRef)(va);function ba(e){return et.default.createElement(oo,{...e,ref:e.viewerRef})}var Ia=(0,Bt.default)(()=>Promise.resolve(ba),{ssr:!1});var so=require("bpmn-js/lib/util/ModelUtil"),zt=d(require("next/dynamic"),1),B=d(require("react"),1),H=require("react"),Ne=require("react-dom/server");var ot=d(require("react"),1),Ut=d(require("react-markdown"),1),Ot=d(require("rehype-autolink-headings"),1),Lt=d(require("rehype-raw"),1),_t=d(require("rehype-slug"),1),Vt=d(require("remark-gfm"),1);function to(e){return ot.default.createElement("div",{className:"app-sdk-absolute app-sdk-w-full app-sdk-h-full app-sdk-overflow-y-auto app-sdk-scroll-p-4 app-sdk-scroll-smooth app-sdk-scroll-shadow"},ot.default.createElement(Ut.default,{remarkPlugins:[Vt.default],rehypePlugins:[Lt.default,_t.default,[Ot.default,{behavior:"wrap"}]],className:"app-sdk-markdown lg:app-sdk-mx-40 md:app-sdk-mx-20 app-sdk-mx-10"},e.documentation??""))}var ie=d(require("react"),1),At=4,$e=class extends ie.default.Component{static defaultProps={customClassName:"",vertical:!1,percentage:!1,primaryIndex:0,primaryMinSize:0,secondaryDefaultSize:null,secondaryInitialSize:null,secondaryMinSize:0,onDragStart:null,onDragEnd:null,onSizeChanged:null,children:[]};container;splitter;constructor(o){super(o),this.handleResize=this.handleResize.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleTouchMove=this.handleTouchMove.bind(this),this.handleSplitterMouseDown=this.handleSplitterMouseDown.bind(this),this.handleSplitterDoubleClick=this.handleSplitterDoubleClick.bind(this),this.state={lastMouseDown:0,secondaryPaneSize:o.secondaryInitialSize||0,resizing:!1}}componentDidMount(){window.addEventListener("resize",this.handleResize),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchend",this.handleMouseUp),document.addEventListener("touchmove",this.handleTouchMove);let o;if(this.props.secondaryInitialSize!=null)o=this.props.secondaryInitialSize;else{let t=this.container.getBoundingClientRect(),s;this.splitter?s=this.splitter.getBoundingClientRect():s={width:At,height:At},o=this.getSecondaryPaneSize(t,s,{left:t.left+(t.width-s.width)/2,top:t.top+(t.height-s.height)/2},!1)}this.setSecondaryPaneSize(o)}componentDidUpdate(o,t){t.secondaryPaneSize!==this.state.secondaryPaneSize&&this.props.onSizeChanged&&this.props.onSizeChanged(this.state.secondaryPaneSize),t.resizing!==this.state.resizing&&(this.state.resizing?this.props.onDragStart&&this.props.onDragStart(t.secondaryPaneSize):this.props.onDragEnd&&this.props.onDragEnd(t.secondaryPaneSize,this.state.secondaryPaneSize))}componentWillUnmount(){window.removeEventListener("resize",this.handleResize),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("touchend",this.handleMouseUp),document.removeEventListener("touchmove",this.handleTouchMove)}clearSelection(){if(document.body.createTextRange){let o=document.body.createTextRange();o.collapse(),o.select()}else if(window.getSelection){let o=window.getSelection();if(o==null)return;o.empty?o.empty():o.removeAllRanges&&o.removeAllRanges()}else document.selection&&document.selection.empty()}getSecondaryPaneSize(o,t,s,a){let r=0,n=0,i=0;this.props.vertical?(r=o.height,n=t.height,i=s.top-o.top):(r=o.width,n=t.width,i=s.left-o.left),a&&(i-=n/2),i<0?i=0:i>r-n&&(i=r-n);let p;this.props.primaryIndex===1?p=i:p=r-n-i;let g=r-n-p;return this.props.percentage&&(p=p*100/r,g=g*100/r,n=n*100/r,r=100),g<this.props.primaryMinSize?p=Math.max(p-(this.props.primaryMinSize-g),0):p<this.props.secondaryMinSize&&(p=Math.min(r-n-this.props.primaryMinSize,this.props.secondaryMinSize)),p}setSecondaryPaneSize(o){this.setState({secondaryPaneSize:o})}maximizeSecondaryPane(){if(this.props.percentage)this.setSecondaryPaneSize(100-this.props.primaryMinSize);else throw new Error("maximizeSecondaryPane() is only supported in SplitterLayout with prop `percentage`")}isReset(){let o=this.props.secondaryDefaultSize||this.props.secondaryMinSize;return this.state.secondaryPaneSize===o}reset(){let o=this.props.secondaryDefaultSize||this.props.secondaryMinSize;this.setSecondaryPaneSize(o)}handleResize(){if(this.splitter&&!this.props.percentage){let o=this.container.getBoundingClientRect(),t=this.splitter.getBoundingClientRect(),s=this.getSecondaryPaneSize(o,t,{left:t.left,top:t.top},!1);this.setState({secondaryPaneSize:s})}}handleMouseMove(o){if(this.state.resizing){let t=this.container.getBoundingClientRect(),s=this.splitter.getBoundingClientRect(),a=this.getSecondaryPaneSize(t,s,{left:o.clientX,top:o.clientY},!0);this.clearSelection(),this.setState({secondaryPaneSize:a})}}handleTouchMove(o){this.handleMouseMove(o.changedTouches[0])}handleSplitterMouseDown(o){o.preventDefault(),this.clearSelection(),this.setState({resizing:!0})}handleSplitterDoubleClick(){let o=this.props.secondaryDefaultSize||this.props.secondaryMinSize;this.state.secondaryPaneSize===o?this.setSecondaryPaneSize(Math.floor(o*1.5)):this.setSecondaryPaneSize(o)}handleMouseUp(){this.setState(o=>o.resizing?{resizing:!1}:null)}render(){let o="app-sdk-splitter-layout";this.props.customClassName&&(o+=` ${this.props.customClassName}`),this.props.vertical&&(o+=" app-sdk-splitter-layout-vertical"),this.state.resizing&&(o+=" layout-changing");let t=ie.default.Children.toArray(this.props.children).slice(0,2);t.length===0&&t.push(ie.default.createElement("div",null));let s=[],a=this.props.primaryIndex!==0&&this.props.primaryIndex!==1?0:this.props.primaryIndex;for(let r=0;r<t.length;++r){let n=!0,i;t.length>1&&r!==a&&(n=!1,i=this.state.secondaryPaneSize),s.push(ie.default.createElement(xa,{vertical:this.props.vertical,percentage:this.props.percentage,primary:n,size:i},t[r]))}return ie.default.createElement("div",{className:o,ref:r=>{this.container=r}},s[0],s.length>1&&ie.default.createElement("div",{role:"separator",className:"app-sdk-layout-splitter"},ie.default.createElement("div",{className:"app-sdk-layout-splitter__inner",ref:r=>{this.splitter=r},onMouseDown:this.handleSplitterMouseDown,onTouchStart:this.handleSplitterMouseDown,onDoubleClick:this.handleSplitterDoubleClick})),s.length>1&&s[1])}};function xa(e={vertical:!1,primary:!1,size:0,percentage:!1,children:[]}){let o=e.size||0,t=e.percentage?"%":"px",s="app-sdk-layout-pane",a={};return e.primary?s+=" app-sdk-layout-pane-primary":e.vertical?a.height=`${o}${t}`:a.width=`${o}${t}`,ie.default.createElement("div",{className:s,style:a},e.children)}var He=30;function Na(e,o){let[t,s]=(0,H.useState)([]),a=(0,H.useRef)(null),r=(0,H.useRef)(null),[n,i]=(0,H.useState)([]),[p,g]=(0,H.useState)(!1),[c,f]=(0,H.useState)([]),[D,j]=(0,H.useState)(He);return(0,H.useEffect)(()=>{if(!window)return;let l=new URLSearchParams(window.location.search),k=l.getAll("selected");if(f(k),!l.has("splitterSize"))return;let P=parseFloat(l.get("splitterSize"));isNaN(P)||P===He||(j(P),r.current?.setSecondaryPaneSize(P))},[]),(0,H.useEffect)(()=>{if(!p)return;let l=new URLSearchParams(window.location.search);D!==He?l.set("splitterSize",D.toString()):l.delete("splitterSize"),l.delete("selected"),n.length>0&&n.forEach(Y=>l.append("selected",Y.id));let k=decodeURIComponent(window.location.hash.slice(1)),P=k.length>0?document.getElementById(k):null;window.history.replaceState(null,"",`?${l.toString()}${P?window.location.hash:""}`),window.location.hash&&(window.location.hash=window.location.hash),P?.scrollIntoView()},[n,D]),(0,H.useEffect)(()=>{if(!p)return;t.forEach(Y=>Y());let l=a.current?.getOverlays();a.current?.getElementRegistry()?.filter($t)?.forEach(Y=>{l?.add(Y.id,Pa(Y))})},[p]),(0,H.useEffect)(()=>{e.setSelectedElementIds?.(n.map(l=>l.id))},[n]),(0,H.useImperativeHandle)(o,()=>({bpmnViewerRef:{getElementRegistry(){return a.current?.getElementRegistry()},getOverlays(){return a.current?.getOverlays()},addMarker(l,k){a.current?.addMarker(l,k)},removeMarker(l,k){a.current?.removeMarker(l,k)},hasMarker(l,k){return a.current?.hasMarker(l,k)},onImportDone(l){p?l():s(k=>[...k,l])}}}),[a.current]),B.default.createElement($e,{ref:r,vertical:!0,percentage:!0,secondaryInitialSize:He,secondaryDefaultSize:He,onDragEnd:(l,k)=>j(Math.round(k))},B.default.createElement(oo,{ref:a,xml:e.xml,preselectedElementIds:c,onSelectionChanged:l=>i([...l]),onImportDone:()=>g(!0)}),B.default.createElement("div",{className:"app-sdk-flex app-sdk-justify-center app-sdk-h-full app-sdk-bg-[color:var(--asdk-ddi-background-color)]"},B.default.createElement(Fa,{elements:n})))}function Fa({elements:e}){if(e.length===0)return B.default.createElement("p",{className:"app-sdk-m-0 app-sdk-p-6"},"Please select an element");let o=e.filter($t);if(o.length===0)return B.default.createElement("p",{className:"app-sdk-m-0 app-sdk-p-6"},"No documentation available");if(o.length===1){let t=(0,so.getBusinessObject)(o[0])?.documentation?.[0]?.text;return B.default.createElement(to,{documentation:t})}return B.default.createElement(to,{documentation:o.map(t=>(0,so.getBusinessObject)(t)?.documentation?.[0]?.text).join(`
2
2
 
3
3
  <hr />
4
4
 
@@ -21,6 +21,6 @@ Component Name: ${k.name} ${k.displayName??""}`),Ps(k),I=k);let j=r.get(p.id)?.r
21
21
 
22
22
  FormField: ${s} with ${a} `);return}t[s]?t[s]=Array.isArray(t[s])?[...t[s],a]:[t[s],a]:t[s]=a}),o.forEach((a,s)=>{if(typeof a.ref.current?.getState=="function"){let r=a.ref.current.getState();(typeof r=="boolean"||typeof r=="number"||typeof r=="string"||Array.isArray(r)||r==null||r?.toString()==="[object Object]")&&(t[s]=r)}}),t}function Ds(e,o,t){let a={};for(let r of e.keys()){let n=e.getAll(r);if(n[0]instanceof File){console.warn(`[@5minds/processcube_app_sdk:DynamicUi] Only plain objects can be passed to Server Components from Client Components. File objects are not supported. Use the raw FormData instance to process files instead.
23
23
 
24
- FormField: ${r} with ${n} `);continue}if(n.length===1?a[r]=n[0]:a[r]=n,a[r]==""&&delete a[r],a[r]){let d=o.find(i=>i.id===r)?.type;if(d==="boolean"){a[r]=a[r]==="on";continue}if(d==="confirm"){a[r]=JSON.parse(a[r]);continue}if(d==="number"){a[r]=parseFloat(a[r]);continue}if(d==="long"){a[r]=parseInt(a[r]);continue}}}let s=o.filter(r=>r.type==="boolean");return s.length&&s.forEach(r=>{a[r.id]||(a[r.id]=!1)}),t.forEach((r,n)=>{if(typeof r.ref.current?.getValue=="function"){let d=r.ref.current.getValue();(typeof d=="boolean"||typeof d=="number"||typeof d=="string"||Array.isArray(d)||d==null||d?.toString()==="[object Object]")&&(a[n]=d)}}),a}import{Transition as Qs}from"@headlessui/react";import{getBusinessObject as er}from"bpmn-js/lib/util/ModelUtil";import{isEqual as et}from"lodash";import or from"next/dynamic";import S,{useCallback as Ge,useEffect as Je,useRef as tr,useState as Q}from"react";import{createRoot as ar}from"react-dom/client";import{BpmnType as R,FlowNodeInstanceState as Wt,ProcessInstanceState as Re}from"@5minds/processcube_engine_sdk";import{Combobox as Ts,ComboboxInput as Ms,ComboboxOption as Es,ComboboxOptions as Bs,Dialog as Os,DialogBackdrop as Us,DialogPanel as Ls}from"@headlessui/react";import{UsersIcon as Vs}from"@heroicons/react/24/outline";import J,{useState as _s}from"react";function Ct(e){let[o,t]=_s(""),a=o===""?e.entries:e.entries.filter(s=>s.name.toLowerCase().includes(o.toLowerCase()));return J.createElement(Os,{className:"app-sdk-relative app-sdk-z-50",open:e.isOpen,onClose:()=>{e.onClose(),t("")}},J.createElement(Us,{transition:!0,className:"app-sdk-fixed app-sdk-inset-0 app-sdk-bg-gray-500 app-sdk-bg-opacity-25 app-sdk-transition-opacity data-[closed]:app-sdk-opacity-0 data-[enter]:app-sdk-duration-300 data-[leave]:app-sdk-duration-150 data-[enter]:app-sdk-ease-out data-[leave]:app-sdk-ease-in"}),J.createElement("div",{className:"app-sdk-fixed app-sdk-inset-0 app-sdk-z-10 app-sdk-w-screen app-sdk-overflow-y-auto app-sdk-p-4 sm:app-sdk-p-6 md:app-sdk-p-20"},J.createElement(Ls,{transition:!0,className:"app-sdk-mx-auto app-sdk-max-w-xl app-sdk-transform app-sdk-rounded-xl app-sdk-bg-[color:var(--asdk-cmdp-background-color)] app-sdk-p-2 app-sdk-shadow-2xl app-sdk-ring-1 app-sdk-ring-black app-sdk-ring-opacity-5 app-sdk-transition-all data-[closed]:app-sdk-scale-95 data-[closed]:app-sdk-opacity-0 data-[enter]:app-sdk-duration-300 data-[leave]:app-sdk-duration-150 data-[enter]:app-sdk-ease-out data-[leave]:app-sdk-ease-in"},J.createElement(Ts,{onChange:s=>{s&&e.onConfirm(s)}},J.createElement(Ms,{autoFocus:!0,className:"app-sdk-w-full app-sdk-ring-offset-2 app-sdk-rounded-md app-sdk-border-0 app-sdk-bg-[color:var(--asdk-cmdp-input-color)] app-sdk-px-4 app-sdk-py-2.5 app-sdk-text-[color:var(--asdk-cmdp-text-color)] sm:app-sdk-text-sm",placeholder:e.placeholder,onChange:s=>t(s.target.value),onBlur:()=>t("")}),a.length>0&&J.createElement(Bs,{static:!0,className:"app-sdk-mb-2 app-sdk-max-h-72 app-sdk-scroll-py-2 app-sdk-overflow-y-auto app-sdk-py-2 app-sdk-text-sm app-sdk-text-[color:var(--asdk-cmdp-text-color)]"},a.map(s=>J.createElement(Es,{key:s.id,value:s,className:({focus:r})=>P("app-sdk-cursor-default app-sdk-select-none app-sdk-rounded-md app-sdk-px-4 app-sdk-py-2",r&&"app-sdk-bg-[color:var(--asdk-cmdp-focus-color)] app-sdk-text-white")},s.name))),o!==""&&a.length===0&&J.createElement("div",{className:"app-sdk-px-4 app-sdk-py-14 app-sdk-text-center sm:app-sdk-px-14"},J.createElement(Vs,{className:"app-sdk-mx-auto app-sdk-h-6 app-sdk-w-6 app-sdk-text-gray-400","aria-hidden":"true"}),J.createElement("p",{className:"app-sdk-mt-4 app-sdk-text-sm app-sdk-text-[color:var(--asdk-cmdp-text-color)]"},e.noResultsText||"No entries found using that search term."))))))}import zs from"react";function X({title:e,children:o,className:t,onClick:a}){return zs.createElement("button",{title:e,className:P(t,"app-sdk-appearance-none app-sdk-border-none app-sdk-pointer-events-auto app-sdk-cursor-pointer app-sdk-flex app-sdk-w-6 app-sdk-min-w-6 app-sdk-max-w-6 app-sdk-h-4 app-sdk-text-white app-sdk-bg-cyan-800 app-sdk-rounded app-sdk-text-xs app-sdk-items-center app-sdk-justify-center"),onClick:a},o)}import As from"react";function Pt({width:e,children:o}){return As.createElement("div",{className:"app-sdk-flex app-sdk-gap-1 app-sdk-justify-center app-sdk-flex-wrap",style:{width:`${e}px`}},o)}import Jo from"react";function St({isSender:e,onClick:o}){return Jo.createElement(X,{title:`Go to ${e?"Target":"Source"}`,onClick:o},Jo.createElement("svg",{className:"!app-sdk-fill-white",width:"10px",height:"10px",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},Jo.createElement("path",{d:"M320 0c-17.7 0-32 14.3-32 32s14.3 32 32 32h82.7L201.4 265.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L448 109.3V192c0 17.7 14.3 32 32 32s32-14.3 32-32V32c0-17.7-14.3-32-32-32H320zM80 32C35.8 32 0 67.8 0 112V432c0 44.2 35.8 80 80 80H400c44.2 0 80-35.8 80-80V320c0-17.7-14.3-32-32-32s-32 14.3-32 32V432c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16V112c0-8.8 7.2-16 16-16H192c17.7 0 32-14.3 32-32s-14.3-32-32-32H80z"})))}import Wo from"react";function Dt({onClick:e}){return Wo.createElement(X,{onClick:e,title:"List Instances"},Wo.createElement("svg",{className:"!app-sdk-fill-white",width:"10px",height:"10px",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},Wo.createElement("path",{d:"M24 56c0-13.3 10.7-24 24-24H80c13.3 0 24 10.7 24 24V176h16c13.3 0 24 10.7 24 24s-10.7 24-24 24H40c-13.3 0-24-10.7-24-24s10.7-24 24-24H56V80H48C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432H120c13.3 0 24 10.7 24 24s-10.7 24-24 24H32c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32s14.3-32 32-32z"})))}import Xo from"react";function Tt({flowNodeId:e,flowNodeInstanceId:o,flowNodeType:t,processInstanceId:a,onPlay:s}){return Xo.createElement(X,{title:"Run Task",className:"asdk-pii-play-button",onClick:()=>{typeof s=="function"?new Promise(async(r,n)=>{try{await s({flowNodeId:e,processInstanceId:a,flowNodeInstanceId:o,taskType:t}),r(!0)}catch(d){n(d)}}):import("./actions-OE3ZZPBR.mjs").then(({finishTask:r})=>r(o,t))}},Xo.createElement("svg",{className:"!app-sdk-fill-none !app-sdk-stroke-white !app-sdk-stroke-[2px]",width:"14px",height:"14px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},Xo.createElement("path",{d:"M5 17.3336V6.66698C5 5.78742 5 5.34715 5.18509 5.08691C5.34664 4.85977 5.59564 4.71064 5.87207 4.67499C6.18868 4.63415 6.57701 4.84126 7.35254 5.25487L17.3525 10.5882L17.3562 10.5898C18.2132 11.0469 18.642 11.2756 18.7826 11.5803C18.9053 11.8462 18.9053 12.1531 18.7826 12.4189C18.6418 12.7241 18.212 12.9537 17.3525 13.4121L7.35254 18.7454C6.57645 19.1593 6.1888 19.3657 5.87207 19.3248C5.59564 19.2891 5.34664 19.1401 5.18509 18.9129C5 18.6527 5 18.2132 5 17.3336Z"})))}import $s from"react";function Mt(){return $s.createElement("div",{className:"app-sdk-h-6 app-sdk-w-[1px] app-sdk-my-auto app-sdk-border-l app-sdk-border-r-0 app-sdk-border-t-0 app-sdk-border-b-0 app-sdk-border-collapse app-sdk-border-solid app-sdk-border-gray-900 dark:app-sdk-border-gray-300"})}import Et from"react";function Bt({children:e}){return Et.createElement("div",{className:"app-sdk-w-full app-sdk-absolute app-sdk-top-0 app-sdk-left-0 app-sdk-z-40 app-sdk-pt-2 app-sdk-pointer-events-none"},Et.createElement("div",{className:"app-sdk-flex app-sdk-w-fit app-sdk-mx-auto app-sdk-rounded-full app-sdk-px-3 app-sdk-py-2 app-sdk-gap-1 app-sdk-border app-sdk-border-solid app-sdk-bg-white/95 dark:app-sdk-bg-black/85 dark:app-sdk-border-none app-sdk-pointer-events-auto"},e))}import Ro from"react";import Hs from"react";function oe({title:e,disabled:o,children:t,onClick:a}){return Hs.createElement("button",{title:`${e??""}${o?" (disabled)":""}`,className:P("app-sdk-appearance-none app-sdk-border-none app-sdk-bg-transparent app-sdk-flex app-sdk-h-full app-sdk-my-auto app-sdk-rounded-full app-sdk-p-1",o?"app-sdk-cursor-not-allowed":"app-sdk-cursor-pointer hover:app-sdk-bg-app-sdk-gray-100/40"),onClick:a,disabled:o},t)}function Ot({onClick:e}){return Ro.createElement(oe,{title:"Refresh Process Instance Data",onClick:e},Ro.createElement("svg",{className:"dark:!app-sdk-stroke-app-sdk-gray-50 dark:!app-sdk-fill-app-sdk-gray-50",width:"1.25rem",height:"1.25rem",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},Ro.createElement("path",{d:"M105.1 202.6c7.7-21.8 20.2-42.3 37.8-59.8c62.5-62.5 163.8-62.5 226.3 0L386.3 160H352c-17.7 0-32 14.3-32 32s14.3 32 32 32H463.5c0 0 0 0 0 0h.4c17.7 0 32-14.3 32-32V80c0-17.7-14.3-32-32-32s-32 14.3-32 32v35.2L414.4 97.6c-87.5-87.5-229.3-87.5-316.8 0C73.2 122 55.6 150.7 44.8 181.4c-5.9 16.7 2.9 34.9 19.5 40.8s34.9-2.9 40.8-19.5zM39 289.3c-5 1.5-9.8 4.2-13.7 8.2c-4 4-6.7 8.8-8.1 14c-.3 1.2-.6 2.5-.8 3.8c-.3 1.7-.4 3.4-.4 5.1V432c0 17.7 14.3 32 32 32s32-14.3 32-32V396.9l17.6 17.5 0 0c87.5 87.4 229.3 87.4 316.7 0c24.4-24.4 42.1-53.1 52.9-83.7c5.9-16.7-2.9-34.9-19.5-40.8s-34.9 2.9-40.8 19.5c-7.7 21.8-20.2 42.3-37.8 59.8c-62.5 62.5-163.8 62.5-226.3 0l-.1-.1L125.6 352H160c17.7 0 32-14.3 32-32s-14.3-32-32-32H48.4c-1.6 0-3.2 .1-4.8 .3s-3.1 .5-4.6 1z"})))}import Yo from"react";function Ut({onClick:e}){return Yo.createElement(X,{title:"Retry Process Here",onClick:e},Yo.createElement("svg",{className:"!app-sdk-fill-white !app-sdk-stroke-white",width:"10px",height:"10px",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},Yo.createElement("path",{d:"M463.5 224H472c13.3 0 24-10.7 24-24V72c0-9.7-5.8-18.5-14.8-22.2s-19.3-1.7-26.2 5.2L413.4 96.6c-87.6-86.5-228.7-86.2-315.8 1c-87.5 87.5-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3c62.2-62.2 162.7-62.5 225.3-1L327 183c-6.9 6.9-8.9 17.2-5.2 26.2s12.5 14.8 22.2 14.8H463.5z"})))}import{Description as Lt,Dialog as js,DialogBackdrop as Gs,DialogPanel as Js,DialogTitle as Ws}from"@headlessui/react";import Xs from"@monaco-editor/react";import H,{useEffect as Rs,useState as Ys}from"react";function Vt(e){let[o,t]=Ys("");return Rs(()=>{t(JSON.stringify(e.flowNodeInstance?.startToken??e.processInstance.startToken??{},null,2))},[e.flowNodeInstance,e.processInstance]),H.createElement(js,{open:e.isOpen,onClose:e.onClose,className:"app-sdk-relative app-sdk-z-50"},H.createElement(Gs,{transition:!0,className:"app-sdk-fixed app-sdk-inset-0 app-sdk-bg-gray-500 app-sdk-bg-opacity-25 app-sdk-transition-opacity data-[closed]:app-sdk-opacity-0 data-[enter]:app-sdk-duration-300 data-[leave]:app-sdk-duration-150 data-[enter]:app-sdk-ease-out data-[leave]:app-sdk-ease-in"},H.createElement("div",{className:"app-sdk-fixed app-sdk-inset-0 app-sdk-flex app-sdk-w-screen app-sdk-items-center app-sdk-justify-center app-sdk-p-4"},H.createElement(Js,{className:"app-sdk-max-w-lg app-sdk-space-y-4 app-sdk-shadow-2xl app-sdk-bg-[color:var(--asdk-rd-background-color)] app-sdk-p-8 app-sdk-rounded-xl app-sdk-text-[color:var(--asdk-rd-text-color)]"},H.createElement(Ws,{className:"app-sdk-font-bold"},"Retry Process Instance"),H.createElement(Lt,{className:"app-sdk-break-words"},"Are you sure you want to retry the Process Instance",e.flowNodeInstance&&` at this Flow Node (${e.flowNodeInstance.flowNodeId})`,"?"),H.createElement(Lt,null,"You can provide a new start token:"),H.createElement("div",{className:"app-sdk-flex app-sdk-flex-col app-sdk-gap-1"},H.createElement("label",null,"Start Token"),H.createElement(Xs,{height:"7rem",defaultLanguage:"json",defaultValue:o,onChange:a=>t(a??""),options:{lineNumbersMinChars:2,readOnly:!1,minimap:{enabled:!1},formatOnPaste:!0,formatOnType:!0}})),H.createElement("div",{className:"app-sdk-flex app-sdk-justify-end app-sdk-gap-2"},H.createElement("button",{className:"app-sdk-bg-[color:var(--asdk-rd-secondary-button-color)] app-sdk-text-[color:var(--asdk-rd-secondary-button-text-color)] app-sdk-rounded-md app-sdk-p-2 app-sdk-border hover:app-sdk-cursor-pointer hover:app-sdk-bg-[color:var(--asdk-rd-secondary-button-hover-color)]",onClick:e.onClose},"Cancel"),H.createElement("button",{className:"app-sdk-bg-[color:var(--asdk-rd-primary-button-color)] app-sdk-text-[color:var(--asdk-rd-primary-button-text-color)] app-sdk-rounded-md app-sdk-p-2 app-sdk-border-0 hover:app-sdk-cursor-pointer hover:app-sdk-bg-[color:var(--asdk-rd-primary-button-hover-color)]",onClick:async()=>{let a=JSON.parse(o);await(await import("./actions-OE3ZZPBR.mjs")).retryProcess(e.processInstance.processInstanceId,e.flowNodeInstance?.flowNodeInstanceId,a),e.onClose()}},"Retry"))))))}import qo from"react";function _t({disabled:e,onClick:o}){return qo.createElement(oe,{title:"Retry Process",disabled:e,onClick:o},qo.createElement("svg",{className:e?"!app-sdk-stroke-app-sdk-gray-200 dark:!app-sdk-stroke-app-sdk-gray-400 !app-sdk-fill-app-sdk-gray-200 dark:!app-sdk-fill-app-sdk-gray-400":"dark:!app-sdk-stroke-app-sdk-gray-50 dark:!app-sdk-fill-app-sdk-gray-50",width:"1.25rem",height:"1.25rem",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},qo.createElement("path",{d:"M463.5 224H472c13.3 0 24-10.7 24-24V72c0-9.7-5.8-18.5-14.8-22.2s-19.3-1.7-26.2 5.2L413.4 96.6c-87.6-86.5-228.7-86.2-315.8 1c-87.5 87.5-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3c62.2-62.2 162.7-62.5 225.3-1L327 183c-6.9 6.9-8.9 17.2-5.2 26.2s12.5 14.8 22.2 14.8H463.5z"})))}import Zo from"react";function zt({processInstanceId:e,disabled:o}){return Zo.createElement(oe,{title:"Terminate Process",disabled:o,onClick:()=>import("./actions-OE3ZZPBR.mjs").then(({terminateProcess:t})=>t(e))},Zo.createElement("svg",{className:o?"!app-sdk-stroke-app-sdk-gray-200 dark:!app-sdk-stroke-app-sdk-gray-400 !app-sdk-fill-app-sdk-gray-200 dark:!app-sdk-fill-app-sdk-gray-400":"!app-sdk-stroke-red-600 !app-sdk-fill-red-600",width:"1.25rem",height:"1.25rem",viewBox:"0 0 516 516",xmlns:"http://www.w3.org/2000/svg"},Zo.createElement("path",{d:"M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm192-96l128 0c17.7 0 32 14.3 32 32l0 128c0 17.7-14.3 32-32 32l-128 0c-17.7 0-32-14.3-32-32l0-128c0-17.7 14.3-32 32-32z"})))}import{ArrowsPointingInIcon as At,ArrowsPointingOutIcon as $t,XMarkIcon as qs}from"@heroicons/react/24/outline";import{Editor as Ht}from"@monaco-editor/react";import b,{useEffect as Ko,useMemo as jt,useState as Qo}from"react";function Gt(e){let[o,t]=Qo(),[a,s]=Qo(!0),[r,n]=Qo(null),d=l=>{n(r===l?null:l)};Ko(()=>(a&&e.flowNodeInstances.length>1&&s(!1),()=>{if(a)return;let l=new URLSearchParams(window.location.search);l.delete("tokenInspectorFocus"),window.history.replaceState(null,"",`${window.location.pathname}?${l.toString()}${window.location.hash}`)}),[a,e.flowNodeInstances]),Ko(()=>{if(e.flowNodeInstances.length<2){t(void 0);return}let u=new URLSearchParams(window.location.search).get("tokenInspectorFocus");u||t(e.flowNodeInstances[0]);let C=e.flowNodeInstances.find(V=>V.flowNodeId===u);C&&t(C)},[e.flowNodeInstances]),Ko(()=>{if(a)return;let l=new URLSearchParams(window.location.search);o?l.set("tokenInspectorFocus",o.flowNodeId):l.delete("tokenInspectorFocus"),window.history.replaceState(null,"",`${window.location.pathname}?${l.toString()}${window.location.hash}`)},[o,a]);let i=jt(()=>e.flowNodeInstances.length===1?JSON.stringify(e.flowNodeInstances[0].startToken,null,2):JSON.stringify(o?o.startToken:e.processInstance?.startToken??{},null,2),[o,e.flowNodeInstances,e.processInstance]),f=jt(()=>e.flowNodeInstances.length===1?JSON.stringify(e.flowNodeInstances[0].endToken,null,2):JSON.stringify(o?o.endToken:e.processInstance?.endToken??{},null,2),[o,e.flowNodeInstances,e.processInstance]);return b.createElement("div",{className:"app-sdk-flex app-sdk-flex-col app-sdk-h-full app-sdk-rounded-3xl app-sdk-p-4 app-sdk-gap-1 app-sdk-bg-white/95 dark:app-sdk-bg-black/85 dark:app-sdk-text-white app-sdk-border app-sdk-border-solid dark:app-sdk-border-none"},b.createElement("button",{onClick:()=>{e.close()},className:"app-sdk-text-white hover:app-sdk-text-gray-300",title:"Close Token Inspector"},b.createElement(qs,{className:"app-sdk-w-6 app-sdk-h-6"})),b.createElement("div",{className:"app-sdk-flex app-sdk-flex-col app-sdk-gap-4"},e.flowNodeInstances.length===0?b.createElement("label",{className:"app-sdk-break-all"},"Process: ",e.processInstance.processModelId,e.processInstance.processModelName&&` (${e.processInstance.processModelName})`):e.flowNodeInstances.length===1?b.createElement("label",{className:"app-sdk-break-all"},"Flow Node: ",e.flowNodeInstances[0].flowNodeId,e.flowNodeInstances[0].flowNodeName&&` (${e.flowNodeInstances[0].flowNodeName})`):b.createElement("div",{className:"app-sdk-flex app-sdk-flex-col app-sdk-gap-1 app-sdk-w-full"},b.createElement("label",null,"Select Flow Node:"),b.createElement("select",{className:"app-sdk-max-w-full app-sdk-bg-transparent app-sdk-border app-sdk-rounded-md app-sdk-py-2 app-sdk-px-1 app-sdk-text-ellipsis",onChange:l=>t(e.flowNodeInstances.find(u=>u.flowNodeId===l.target.value)),value:o?.flowNodeId??e.flowNodeInstances[0].flowNodeId},e.flowNodeInstances.map(l=>b.createElement("option",{key:`token-inspector-option-${l.flowNodeId}`,value:l.flowNodeId},`${l.flowNodeName?`${l.flowNodeName} (${l.flowNodeId})`:l.flowNodeId}`)))),b.createElement("div",{className:"app-sdk-flex app-sdk-flex-col app-sdk-gap-3"},r&&b.createElement("div",{className:"app-sdk-fixed app-sdk-inset-0 app-sdk-bg-black/30 app-sdk-backdrop-blur-md app-sdk-z-40"}),b.createElement("div",{className:`app-sdk-flex app-sdk-flex-col app-sdk-gap-1
24
+ FormField: ${r} with ${n} `);continue}if(n.length===1?a[r]=n[0]:a[r]=n,a[r]==""&&delete a[r],a[r]){let d=o.find(i=>i.id===r)?.type;if(d==="boolean"){a[r]=a[r]==="on";continue}if(d==="confirm"){a[r]=JSON.parse(a[r]);continue}if(d==="number"){a[r]=parseFloat(a[r]);continue}if(d==="long"){a[r]=parseInt(a[r]);continue}}}let s=o.filter(r=>r.type==="boolean");return s.length&&s.forEach(r=>{a[r.id]||(a[r.id]=!1)}),t.forEach((r,n)=>{if(typeof r.ref.current?.getValue=="function"){let d=r.ref.current.getValue();(typeof d=="boolean"||typeof d=="number"||typeof d=="string"||Array.isArray(d)||d==null||d?.toString()==="[object Object]")&&(a[n]=d)}}),a}import{Transition as Qs}from"@headlessui/react";import{getBusinessObject as er}from"bpmn-js/lib/util/ModelUtil";import{isEqual as et}from"lodash";import or from"next/dynamic";import S,{useCallback as Ge,useEffect as Je,useRef as tr,useState as Q}from"react";import{createRoot as ar}from"react-dom/client";import{BpmnType as R,FlowNodeInstanceState as Wt,ProcessInstanceState as Re}from"@5minds/processcube_engine_sdk";import{Combobox as Ts,ComboboxInput as Ms,ComboboxOption as Es,ComboboxOptions as Bs,Dialog as Os,DialogBackdrop as Us,DialogPanel as Ls}from"@headlessui/react";import{UsersIcon as Vs}from"@heroicons/react/24/outline";import J,{useState as _s}from"react";function Ct(e){let[o,t]=_s(""),a=o===""?e.entries:e.entries.filter(s=>s.name.toLowerCase().includes(o.toLowerCase()));return J.createElement(Os,{className:"app-sdk-relative app-sdk-z-50",open:e.isOpen,onClose:()=>{e.onClose(),t("")}},J.createElement(Us,{transition:!0,className:"app-sdk-fixed app-sdk-inset-0 app-sdk-bg-gray-500 app-sdk-bg-opacity-25 app-sdk-transition-opacity data-[closed]:app-sdk-opacity-0 data-[enter]:app-sdk-duration-300 data-[leave]:app-sdk-duration-150 data-[enter]:app-sdk-ease-out data-[leave]:app-sdk-ease-in"}),J.createElement("div",{className:"app-sdk-fixed app-sdk-inset-0 app-sdk-z-10 app-sdk-w-screen app-sdk-overflow-y-auto app-sdk-p-4 sm:app-sdk-p-6 md:app-sdk-p-20"},J.createElement(Ls,{transition:!0,className:"app-sdk-mx-auto app-sdk-max-w-xl app-sdk-transform app-sdk-rounded-xl app-sdk-bg-[color:var(--asdk-cmdp-background-color)] app-sdk-p-2 app-sdk-shadow-2xl app-sdk-ring-1 app-sdk-ring-black app-sdk-ring-opacity-5 app-sdk-transition-all data-[closed]:app-sdk-scale-95 data-[closed]:app-sdk-opacity-0 data-[enter]:app-sdk-duration-300 data-[leave]:app-sdk-duration-150 data-[enter]:app-sdk-ease-out data-[leave]:app-sdk-ease-in"},J.createElement(Ts,{onChange:s=>{s&&e.onConfirm(s)}},J.createElement(Ms,{autoFocus:!0,className:"app-sdk-w-full app-sdk-ring-offset-2 app-sdk-rounded-md app-sdk-border-0 app-sdk-bg-[color:var(--asdk-cmdp-input-color)] app-sdk-px-4 app-sdk-py-2.5 app-sdk-text-[color:var(--asdk-cmdp-text-color)] sm:app-sdk-text-sm",placeholder:e.placeholder,onChange:s=>t(s.target.value),onBlur:()=>t("")}),a.length>0&&J.createElement(Bs,{static:!0,className:"app-sdk-mb-2 app-sdk-max-h-72 app-sdk-scroll-py-2 app-sdk-overflow-y-auto app-sdk-py-2 app-sdk-text-sm app-sdk-text-[color:var(--asdk-cmdp-text-color)]"},a.map(s=>J.createElement(Es,{key:s.id,value:s,className:({focus:r})=>P("app-sdk-cursor-default app-sdk-select-none app-sdk-rounded-md app-sdk-px-4 app-sdk-py-2",r&&"app-sdk-bg-[color:var(--asdk-cmdp-focus-color)] app-sdk-text-white")},s.name))),o!==""&&a.length===0&&J.createElement("div",{className:"app-sdk-px-4 app-sdk-py-14 app-sdk-text-center sm:app-sdk-px-14"},J.createElement(Vs,{className:"app-sdk-mx-auto app-sdk-h-6 app-sdk-w-6 app-sdk-text-gray-400","aria-hidden":"true"}),J.createElement("p",{className:"app-sdk-mt-4 app-sdk-text-sm app-sdk-text-[color:var(--asdk-cmdp-text-color)]"},e.noResultsText||"No entries found using that search term."))))))}import zs from"react";function X({title:e,children:o,className:t,onClick:a}){return zs.createElement("button",{title:e,className:P(t,"app-sdk-appearance-none app-sdk-border-none app-sdk-pointer-events-auto app-sdk-cursor-pointer app-sdk-flex app-sdk-w-6 app-sdk-min-w-6 app-sdk-max-w-6 app-sdk-h-4 app-sdk-text-white app-sdk-bg-cyan-800 app-sdk-rounded app-sdk-text-xs app-sdk-items-center app-sdk-justify-center"),onClick:a},o)}import As from"react";function Pt({width:e,children:o}){return As.createElement("div",{className:"app-sdk-flex app-sdk-gap-1 app-sdk-justify-center app-sdk-flex-wrap",style:{width:`${e}px`}},o)}import Jo from"react";function St({isSender:e,onClick:o}){return Jo.createElement(X,{title:`Go to ${e?"Target":"Source"}`,onClick:o},Jo.createElement("svg",{className:"!app-sdk-fill-white",width:"10px",height:"10px",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},Jo.createElement("path",{d:"M320 0c-17.7 0-32 14.3-32 32s14.3 32 32 32h82.7L201.4 265.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L448 109.3V192c0 17.7 14.3 32 32 32s32-14.3 32-32V32c0-17.7-14.3-32-32-32H320zM80 32C35.8 32 0 67.8 0 112V432c0 44.2 35.8 80 80 80H400c44.2 0 80-35.8 80-80V320c0-17.7-14.3-32-32-32s-32 14.3-32 32V432c0 8.8-7.2 16-16 16H80c-8.8 0-16-7.2-16-16V112c0-8.8 7.2-16 16-16H192c17.7 0 32-14.3 32-32s-14.3-32-32-32H80z"})))}import Wo from"react";function Dt({onClick:e}){return Wo.createElement(X,{onClick:e,title:"List Instances"},Wo.createElement("svg",{className:"!app-sdk-fill-white",width:"10px",height:"10px",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},Wo.createElement("path",{d:"M24 56c0-13.3 10.7-24 24-24H80c13.3 0 24 10.7 24 24V176h16c13.3 0 24 10.7 24 24s-10.7 24-24 24H40c-13.3 0-24-10.7-24-24s10.7-24 24-24H56V80H48C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432H120c13.3 0 24 10.7 24 24s-10.7 24-24 24H32c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160H480c17.7 0 32 14.3 32 32s-14.3 32-32 32H224c-17.7 0-32-14.3-32-32s14.3-32 32-32z"})))}import Xo from"react";function Tt({flowNodeId:e,flowNodeInstanceId:o,flowNodeType:t,processInstanceId:a,onPlay:s}){return Xo.createElement(X,{title:"Run Task",className:"asdk-pii-play-button",onClick:()=>{typeof s=="function"?new Promise(async(r,n)=>{try{await s({flowNodeId:e,processInstanceId:a,flowNodeInstanceId:o,taskType:t}),r(!0)}catch(d){n(d)}}):import("./actions-BW4Q6NQT.mjs").then(({finishTask:r})=>r(o,t))}},Xo.createElement("svg",{className:"!app-sdk-fill-none !app-sdk-stroke-white !app-sdk-stroke-[2px]",width:"14px",height:"14px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},Xo.createElement("path",{d:"M5 17.3336V6.66698C5 5.78742 5 5.34715 5.18509 5.08691C5.34664 4.85977 5.59564 4.71064 5.87207 4.67499C6.18868 4.63415 6.57701 4.84126 7.35254 5.25487L17.3525 10.5882L17.3562 10.5898C18.2132 11.0469 18.642 11.2756 18.7826 11.5803C18.9053 11.8462 18.9053 12.1531 18.7826 12.4189C18.6418 12.7241 18.212 12.9537 17.3525 13.4121L7.35254 18.7454C6.57645 19.1593 6.1888 19.3657 5.87207 19.3248C5.59564 19.2891 5.34664 19.1401 5.18509 18.9129C5 18.6527 5 18.2132 5 17.3336Z"})))}import $s from"react";function Mt(){return $s.createElement("div",{className:"app-sdk-h-6 app-sdk-w-[1px] app-sdk-my-auto app-sdk-border-l app-sdk-border-r-0 app-sdk-border-t-0 app-sdk-border-b-0 app-sdk-border-collapse app-sdk-border-solid app-sdk-border-gray-900 dark:app-sdk-border-gray-300"})}import Et from"react";function Bt({children:e}){return Et.createElement("div",{className:"app-sdk-w-full app-sdk-absolute app-sdk-top-0 app-sdk-left-0 app-sdk-z-40 app-sdk-pt-2 app-sdk-pointer-events-none"},Et.createElement("div",{className:"app-sdk-flex app-sdk-w-fit app-sdk-mx-auto app-sdk-rounded-full app-sdk-px-3 app-sdk-py-2 app-sdk-gap-1 app-sdk-border app-sdk-border-solid app-sdk-bg-white/95 dark:app-sdk-bg-black/85 dark:app-sdk-border-none app-sdk-pointer-events-auto"},e))}import Ro from"react";import Hs from"react";function oe({title:e,disabled:o,children:t,onClick:a}){return Hs.createElement("button",{title:`${e??""}${o?" (disabled)":""}`,className:P("app-sdk-appearance-none app-sdk-border-none app-sdk-bg-transparent app-sdk-flex app-sdk-h-full app-sdk-my-auto app-sdk-rounded-full app-sdk-p-1",o?"app-sdk-cursor-not-allowed":"app-sdk-cursor-pointer hover:app-sdk-bg-app-sdk-gray-100/40"),onClick:a,disabled:o},t)}function Ot({onClick:e}){return Ro.createElement(oe,{title:"Refresh Process Instance Data",onClick:e},Ro.createElement("svg",{className:"dark:!app-sdk-stroke-app-sdk-gray-50 dark:!app-sdk-fill-app-sdk-gray-50",width:"1.25rem",height:"1.25rem",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},Ro.createElement("path",{d:"M105.1 202.6c7.7-21.8 20.2-42.3 37.8-59.8c62.5-62.5 163.8-62.5 226.3 0L386.3 160H352c-17.7 0-32 14.3-32 32s14.3 32 32 32H463.5c0 0 0 0 0 0h.4c17.7 0 32-14.3 32-32V80c0-17.7-14.3-32-32-32s-32 14.3-32 32v35.2L414.4 97.6c-87.5-87.5-229.3-87.5-316.8 0C73.2 122 55.6 150.7 44.8 181.4c-5.9 16.7 2.9 34.9 19.5 40.8s34.9-2.9 40.8-19.5zM39 289.3c-5 1.5-9.8 4.2-13.7 8.2c-4 4-6.7 8.8-8.1 14c-.3 1.2-.6 2.5-.8 3.8c-.3 1.7-.4 3.4-.4 5.1V432c0 17.7 14.3 32 32 32s32-14.3 32-32V396.9l17.6 17.5 0 0c87.5 87.4 229.3 87.4 316.7 0c24.4-24.4 42.1-53.1 52.9-83.7c5.9-16.7-2.9-34.9-19.5-40.8s-34.9 2.9-40.8 19.5c-7.7 21.8-20.2 42.3-37.8 59.8c-62.5 62.5-163.8 62.5-226.3 0l-.1-.1L125.6 352H160c17.7 0 32-14.3 32-32s-14.3-32-32-32H48.4c-1.6 0-3.2 .1-4.8 .3s-3.1 .5-4.6 1z"})))}import Yo from"react";function Ut({onClick:e}){return Yo.createElement(X,{title:"Retry Process Here",onClick:e},Yo.createElement("svg",{className:"!app-sdk-fill-white !app-sdk-stroke-white",width:"10px",height:"10px",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},Yo.createElement("path",{d:"M463.5 224H472c13.3 0 24-10.7 24-24V72c0-9.7-5.8-18.5-14.8-22.2s-19.3-1.7-26.2 5.2L413.4 96.6c-87.6-86.5-228.7-86.2-315.8 1c-87.5 87.5-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3c62.2-62.2 162.7-62.5 225.3-1L327 183c-6.9 6.9-8.9 17.2-5.2 26.2s12.5 14.8 22.2 14.8H463.5z"})))}import{Description as Lt,Dialog as js,DialogBackdrop as Gs,DialogPanel as Js,DialogTitle as Ws}from"@headlessui/react";import Xs from"@monaco-editor/react";import H,{useEffect as Rs,useState as Ys}from"react";function Vt(e){let[o,t]=Ys("");return Rs(()=>{t(JSON.stringify(e.flowNodeInstance?.startToken??e.processInstance.startToken??{},null,2))},[e.flowNodeInstance,e.processInstance]),H.createElement(js,{open:e.isOpen,onClose:e.onClose,className:"app-sdk-relative app-sdk-z-50"},H.createElement(Gs,{transition:!0,className:"app-sdk-fixed app-sdk-inset-0 app-sdk-bg-gray-500 app-sdk-bg-opacity-25 app-sdk-transition-opacity data-[closed]:app-sdk-opacity-0 data-[enter]:app-sdk-duration-300 data-[leave]:app-sdk-duration-150 data-[enter]:app-sdk-ease-out data-[leave]:app-sdk-ease-in"},H.createElement("div",{className:"app-sdk-fixed app-sdk-inset-0 app-sdk-flex app-sdk-w-screen app-sdk-items-center app-sdk-justify-center app-sdk-p-4"},H.createElement(Js,{className:"app-sdk-max-w-lg app-sdk-space-y-4 app-sdk-shadow-2xl app-sdk-bg-[color:var(--asdk-rd-background-color)] app-sdk-p-8 app-sdk-rounded-xl app-sdk-text-[color:var(--asdk-rd-text-color)]"},H.createElement(Ws,{className:"app-sdk-font-bold"},"Retry Process Instance"),H.createElement(Lt,{className:"app-sdk-break-words"},"Are you sure you want to retry the Process Instance",e.flowNodeInstance&&` at this Flow Node (${e.flowNodeInstance.flowNodeId})`,"?"),H.createElement(Lt,null,"You can provide a new start token:"),H.createElement("div",{className:"app-sdk-flex app-sdk-flex-col app-sdk-gap-1"},H.createElement("label",null,"Start Token"),H.createElement(Xs,{height:"7rem",defaultLanguage:"json",defaultValue:o,onChange:a=>t(a??""),options:{lineNumbersMinChars:2,readOnly:!1,minimap:{enabled:!1},formatOnPaste:!0,formatOnType:!0}})),H.createElement("div",{className:"app-sdk-flex app-sdk-justify-end app-sdk-gap-2"},H.createElement("button",{className:"app-sdk-bg-[color:var(--asdk-rd-secondary-button-color)] app-sdk-text-[color:var(--asdk-rd-secondary-button-text-color)] app-sdk-rounded-md app-sdk-p-2 app-sdk-border hover:app-sdk-cursor-pointer hover:app-sdk-bg-[color:var(--asdk-rd-secondary-button-hover-color)]",onClick:e.onClose},"Cancel"),H.createElement("button",{className:"app-sdk-bg-[color:var(--asdk-rd-primary-button-color)] app-sdk-text-[color:var(--asdk-rd-primary-button-text-color)] app-sdk-rounded-md app-sdk-p-2 app-sdk-border-0 hover:app-sdk-cursor-pointer hover:app-sdk-bg-[color:var(--asdk-rd-primary-button-hover-color)]",onClick:async()=>{let a=JSON.parse(o);await(await import("./actions-BW4Q6NQT.mjs")).retryProcess(e.processInstance.processInstanceId,e.flowNodeInstance?.flowNodeInstanceId,a),e.onClose()}},"Retry"))))))}import qo from"react";function _t({disabled:e,onClick:o}){return qo.createElement(oe,{title:"Retry Process",disabled:e,onClick:o},qo.createElement("svg",{className:e?"!app-sdk-stroke-app-sdk-gray-200 dark:!app-sdk-stroke-app-sdk-gray-400 !app-sdk-fill-app-sdk-gray-200 dark:!app-sdk-fill-app-sdk-gray-400":"dark:!app-sdk-stroke-app-sdk-gray-50 dark:!app-sdk-fill-app-sdk-gray-50",width:"1.25rem",height:"1.25rem",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},qo.createElement("path",{d:"M463.5 224H472c13.3 0 24-10.7 24-24V72c0-9.7-5.8-18.5-14.8-22.2s-19.3-1.7-26.2 5.2L413.4 96.6c-87.6-86.5-228.7-86.2-315.8 1c-87.5 87.5-87.5 229.3 0 316.8s229.3 87.5 316.8 0c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0c-62.5 62.5-163.8 62.5-226.3 0s-62.5-163.8 0-226.3c62.2-62.2 162.7-62.5 225.3-1L327 183c-6.9 6.9-8.9 17.2-5.2 26.2s12.5 14.8 22.2 14.8H463.5z"})))}import Zo from"react";function zt({processInstanceId:e,disabled:o}){return Zo.createElement(oe,{title:"Terminate Process",disabled:o,onClick:()=>import("./actions-BW4Q6NQT.mjs").then(({terminateProcess:t})=>t(e))},Zo.createElement("svg",{className:o?"!app-sdk-stroke-app-sdk-gray-200 dark:!app-sdk-stroke-app-sdk-gray-400 !app-sdk-fill-app-sdk-gray-200 dark:!app-sdk-fill-app-sdk-gray-400":"!app-sdk-stroke-red-600 !app-sdk-fill-red-600",width:"1.25rem",height:"1.25rem",viewBox:"0 0 516 516",xmlns:"http://www.w3.org/2000/svg"},Zo.createElement("path",{d:"M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm192-96l128 0c17.7 0 32 14.3 32 32l0 128c0 17.7-14.3 32-32 32l-128 0c-17.7 0-32-14.3-32-32l0-128c0-17.7 14.3-32 32-32z"})))}import{ArrowsPointingInIcon as At,ArrowsPointingOutIcon as $t,XMarkIcon as qs}from"@heroicons/react/24/outline";import{Editor as Ht}from"@monaco-editor/react";import b,{useEffect as Ko,useMemo as jt,useState as Qo}from"react";function Gt(e){let[o,t]=Qo(),[a,s]=Qo(!0),[r,n]=Qo(null),d=l=>{n(r===l?null:l)};Ko(()=>(a&&e.flowNodeInstances.length>1&&s(!1),()=>{if(a)return;let l=new URLSearchParams(window.location.search);l.delete("tokenInspectorFocus"),window.history.replaceState(null,"",`${window.location.pathname}?${l.toString()}${window.location.hash}`)}),[a,e.flowNodeInstances]),Ko(()=>{if(e.flowNodeInstances.length<2){t(void 0);return}let u=new URLSearchParams(window.location.search).get("tokenInspectorFocus");u||t(e.flowNodeInstances[0]);let C=e.flowNodeInstances.find(V=>V.flowNodeId===u);C&&t(C)},[e.flowNodeInstances]),Ko(()=>{if(a)return;let l=new URLSearchParams(window.location.search);o?l.set("tokenInspectorFocus",o.flowNodeId):l.delete("tokenInspectorFocus"),window.history.replaceState(null,"",`${window.location.pathname}?${l.toString()}${window.location.hash}`)},[o,a]);let i=jt(()=>e.flowNodeInstances.length===1?JSON.stringify(e.flowNodeInstances[0].startToken,null,2):JSON.stringify(o?o.startToken:e.processInstance?.startToken??{},null,2),[o,e.flowNodeInstances,e.processInstance]),f=jt(()=>e.flowNodeInstances.length===1?JSON.stringify(e.flowNodeInstances[0].endToken,null,2):JSON.stringify(o?o.endToken:e.processInstance?.endToken??{},null,2),[o,e.flowNodeInstances,e.processInstance]);return b.createElement("div",{className:"app-sdk-flex app-sdk-flex-col app-sdk-h-full app-sdk-rounded-3xl app-sdk-p-4 app-sdk-gap-1 app-sdk-bg-white/95 dark:app-sdk-bg-black/85 dark:app-sdk-text-white app-sdk-border app-sdk-border-solid dark:app-sdk-border-none"},b.createElement("button",{onClick:()=>{e.close()},className:"app-sdk-text-white hover:app-sdk-text-gray-300",title:"Close Token Inspector"},b.createElement(qs,{className:"app-sdk-w-6 app-sdk-h-6"})),b.createElement("div",{className:"app-sdk-flex app-sdk-flex-col app-sdk-gap-4"},e.flowNodeInstances.length===0?b.createElement("label",{className:"app-sdk-break-all"},"Process: ",e.processInstance.processModelId,e.processInstance.processModelName&&` (${e.processInstance.processModelName})`):e.flowNodeInstances.length===1?b.createElement("label",{className:"app-sdk-break-all"},"Flow Node: ",e.flowNodeInstances[0].flowNodeId,e.flowNodeInstances[0].flowNodeName&&` (${e.flowNodeInstances[0].flowNodeName})`):b.createElement("div",{className:"app-sdk-flex app-sdk-flex-col app-sdk-gap-1 app-sdk-w-full"},b.createElement("label",null,"Select Flow Node:"),b.createElement("select",{className:"app-sdk-max-w-full app-sdk-bg-transparent app-sdk-border app-sdk-rounded-md app-sdk-py-2 app-sdk-px-1 app-sdk-text-ellipsis",onChange:l=>t(e.flowNodeInstances.find(u=>u.flowNodeId===l.target.value)),value:o?.flowNodeId??e.flowNodeInstances[0].flowNodeId},e.flowNodeInstances.map(l=>b.createElement("option",{key:`token-inspector-option-${l.flowNodeId}`,value:l.flowNodeId},`${l.flowNodeName?`${l.flowNodeName} (${l.flowNodeId})`:l.flowNodeId}`)))),b.createElement("div",{className:"app-sdk-flex app-sdk-flex-col app-sdk-gap-3"},r&&b.createElement("div",{className:"app-sdk-fixed app-sdk-inset-0 app-sdk-bg-black/30 app-sdk-backdrop-blur-md app-sdk-z-40"}),b.createElement("div",{className:`app-sdk-flex app-sdk-flex-col app-sdk-gap-1
25
25
  ${r==="start"?"app-sdk-fixed app-sdk-top-1/2 app-sdk-left-1/2 app-sdk--translate-x-1/2 app-sdk--translate-y-1/2 app-sdk-w-4/5 app-sdk-h-[70vh] app-sdk-bg-white/10 app-sdk-backdrop-blur-xl app-sdk-rounded-xl app-sdk-shadow-2xl app-sdk-z-50 app-sdk-p-6":""}`},b.createElement("div",{className:"app-sdk-flex app-sdk-items-center app-sdk-justify-between"},b.createElement("label",{className:"app-sdk-text-white app-sdk-font-medium"},"Start Token"),b.createElement("button",{className:"app-sdk-text-white hover:app-sdk-text-gray-300 app-sdk-w-6 app-sdk-h-6",onClick:()=>d("start"),title:r==="start"?"Minimize":"Maximize"},r==="start"?b.createElement(At,{className:"app-sdk-w-6 app-sdk-h-6"}):b.createElement($t,{className:"app-sdk-w-6 app-sdk-h-6"}))),b.createElement(Ht,{height:r==="start"?"60vh":"7rem",defaultLanguage:"json",value:i,options:{lineNumbersMinChars:2,readOnly:!0,minimap:{enabled:!1}}})),b.createElement("div",{className:`app-sdk-flex app-sdk-flex-col app-sdk-gap-1
26
- ${r==="end"?"app-sdk-fixed app-sdk-top-1/2 app-sdk-left-1/2 app-sdk--translate-x-1/2 app-sdk--translate-y-1/2 app-sdk-w-4/5 app-sdk-h-[70vh] app-sdk-bg-white/10 app-sdk-backdrop-blur-xl app-sdk-rounded-xl app-sdk-shadow-2xl app-sdk-z-50 app-sdk-p-6":""}`},b.createElement("div",{className:"app-sdk-flex app-sdk-items-center app-sdk-justify-between"},b.createElement("label",{className:"app-sdk-text-white app-sdk-font-medium"},"End Token"),b.createElement("button",{className:"app-sdk-text-white hover:app-sdk-text-gray-300 app-sdk-w-6 app-sdk-h-6",onClick:()=>d("end"),title:r==="end"?"Minimize":"Maximize"},r==="end"?b.createElement(At,{className:"app-sdk-w-6 app-sdk-h-6"}):b.createElement($t,{className:"app-sdk-w-6 app-sdk-h-6"}))),b.createElement(Ht,{height:r==="end"?"60vh":"7rem",defaultLanguage:"json",value:f,options:{lineNumbersMinChars:2,readOnly:!0,minimap:{enabled:!1}}})))))}import Oe,{useEffect as Zs,useState as Ks}from"react";function Jt(e){let[o,t]=Ks(e.isOpen??!1);return Zs(()=>{t(e.isOpen??!1)},[e.isOpen]),Oe.createElement(oe,{disabled:e.disabled,title:"View Process Tokens",onClick:()=>{o?e.close():e.open(),t(a=>!a)}},o?Oe.createElement("svg",{className:"dark:!app-sdk-stroke-app-sdk-gray-50 dark:!app-sdk-fill-app-sdk-gray-50",xmlns:"http://www.w3.org/2000/svg",width:"1.25rem",height:"1.25rem",viewBox:"0 0 384 512"},Oe.createElement("path",{d:"M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"})):Oe.createElement("svg",{className:"dark:!app-sdk-stroke-app-sdk-gray-50 dark:!app-sdk-fill-app-sdk-gray-50",xmlns:"http://www.w3.org/2000/svg",width:"1.25rem",height:"1.25rem",viewBox:"0 0 448 512"},Oe.createElement("path",{d:"M0 96C0 78.3 14.3 64 32 64l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 128C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 288c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32L32 448c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"})))}var Xt=[Re.error,Re.terminated],sr=[R.manualTask,R.userTask,R.untypedTask],Rt=[R.endEvent,R.intermediateThrowEvent,R.sendTask],rr=[R.startEvent,R.intermediateCatchEvent,R.boundaryEvent,R.receiveTask],We={isOpen:!1,placeholder:"",entries:[],onConfirm:()=>{},onClose:()=>{}},nr={isOpen:!1},Xe="asdk-buttons";function dr(e){let{processInstanceId:o}=e,[t,a]=Q(We),[s,r]=Q(nr),[n,d]=Q(!1),[i,f]=Q(),[l,u]=Q([]),[C,V]=Q([]),[p,k]=Q(new Map),[I,j]=Q([]),[Yt,ot]=Q([]),g=tr(null),qt=Ge(async()=>{let c=await import("./actions-OE3ZZPBR.mjs"),h=c.getProcessInstance(o),_=c.getFlowNodeInstances(o),[w,B]=await Promise.all([h,_]),x=await c.getTriggeredFlowNodeInstances(B.map(N=>N.flowNodeInstanceId));f(w),u(B),V(x);let D=new URLSearchParams(window.location.search);D.get("tokenInspector")==="true"&&d(!0);let W=D.getAll("instance"),Y=B.filter(N=>W.includes(N.flowNodeInstanceId));Y.length!==W.length&&(D.delete("instance"),Y.forEach(N=>D.append("instance",N.flowNodeInstanceId)),window.history.replaceState({},"",`${window.location.pathname}?${D.toString()}`));let A=new Map;B.forEach(N=>{A.has(N.flowNodeId)||A.set(N.flowNodeId,N.flowNodeInstanceId)}),Y.forEach(N=>A.set(N.flowNodeId,N.flowNodeInstanceId)),k(A)},[o]),Zt=Ge(c=>{let h=er(c),_=l.some(B=>B.flowNodeId===h.targetRef.id),w=l.some(B=>B.flowNodeId===h.sourceRef.id&&B.state===Wt.finished);return _&&w},[l]),Ue=Ge(async()=>{let c=g.current?.bpmnViewerRef,h=c?.getOverlays();if(!c||!h)return;let _=await import("./actions-OE3ZZPBR.mjs"),w=_.getProcessInstance(o),B=_.getFlowNodeInstances(o),[x,D]=await Promise.all([w,B]),pe=await _.getTriggeredFlowNodeInstances(D.map(T=>T.flowNodeInstanceId));if(et(x,i)&&et(D,l)&&et(pe,C))return;x.state!==i?.state&&h.clear();for(let[T,Le]of p.entries()){let le=l.find(O=>O.flowNodeInstanceId===Le);if(!le)continue;let Ve=D.find(O=>O.flowNodeId===T);Ve?.flowNodeInstanceId===Le&&le.state===Ve.state||(c.removeMarker(T,`asdk-pii-flow-node-instance-state--${le.state}`),h.remove({element:T,type:Xe}))}f(x),u(D),V(pe);let W=new URLSearchParams(window.location.search),Y=W.getAll("instance"),A=D.filter(T=>Y.includes(T.flowNodeInstanceId));A.length!==Y.length&&(W.delete("instance"),A.forEach(T=>W.append("instance",T.flowNodeInstanceId)),window.history.replaceState({},"",`${window.location.pathname}?${W.toString()}`));let N=new Map;D.forEach(T=>{N.has(T.flowNodeId)||N.set(T.flowNodeId,T.flowNodeInstanceId)}),A.forEach(T=>N.set(T.flowNodeId,T.flowNodeInstanceId)),k(N)},[g.current,i,p,l,o]),Kt=Ge((c,h)=>{let _=g.current?.bpmnViewerRef,w=_?.getOverlays();if(!_||!w)return;let B=w.get({element:c.id,type:Xe});if(Array.isArray(B)&&B.length>0)return;let x=h.find(O=>O.flowNodeInstanceId===p.get(O.flowNodeId));if(!x)return;let D=e.showFlowNodeExecutionCount&&h.length>1,pe=e.showFlowNodeInstancesListButton&&h.length>1,W=e.showFinishTaskButton&&sr.includes(c.type)&&x.state===Wt.suspended,Y=e.showRetryFlowNodeInstanceButton&&i&&Xt.includes(i.state),A=!1,N=[];if(e.showGoToFlowNodeButton&&rr.includes(c.type)){let O=x.triggeredByFlowNodeInstance;A=O!==void 0,N=O?[O]:[]}else if(e.showGoToFlowNodeButton&&Rt.includes(c.type)){let O=C.filter(U=>U.triggeredByFlowNodeInstance?.flowNodeInstanceId===x.flowNodeInstanceId);A=O.length>0,N=O}if(!D&&!W&&!Y&&!A)return;let T=c.width<52,Le=w.add(c.id,Xe,{position:{bottom:-7,left:T?-c.width/2:0},html:"<div></div>"}),le=w.get(Le),Ve=ar(le.htmlContainer),Ye=h.indexOf(x)===0,qe=h.length-h.indexOf(x);Ve.render(S.createElement(Pt,{width:T?c.width*2:c.width},D&&S.createElement(X,{className:"app-sdk-select-none !app-sdk-cursor-default !app-sdk-bg-slate-500",title:`Flow Node was executed ${h.length} times.${Ye?"":` You are viewing instance #${qe}.`}`},`${Ye?"":`${qe}/`}${h.length}`),pe&&S.createElement(Dt,{onClick:()=>{let O=h.map($=>({id:$.flowNodeInstanceId,name:`${$.startedAt?.toLocaleString("en-GB")} - ${$.flowNodeInstanceId} - ${$.state}${$.flowNodeInstanceId===x.flowNodeInstanceId?" (selected)":""}`,...$}));a({isOpen:!0,placeholder:"Select instance to display:",entries:O,onConfirm:async $=>{let Ze=h.find(Ke=>Ke.flowNodeInstanceId===$.flowNodeInstanceId);if(!Ze)return;_.removeMarker(x.flowNodeId,`asdk-pii-flow-node-instance-state--${x.state}`),w.remove({element:c.id,type:Xe});let _e=new URLSearchParams(window.location.search);_e.getAll("instance").includes(x.flowNodeInstanceId)&&_e.delete("instance",x.flowNodeInstanceId),h.indexOf(Ze)!==0&&_e.append("instance",Ze.flowNodeInstanceId),window.history.replaceState({},"",`${window.location.pathname}?${_e.toString()}${window.location.hash}`),k(Ke=>new Map(Ke).set(c.id,$.flowNodeInstanceId)),a(We)},onClose:()=>a(We)})}}),A&&S.createElement(St,{isSender:Rt.includes(c.type),onClick:()=>{if(N.length===1){let U=new URLSearchParams;U.append("selected",N[0].flowNodeId),U.append("instance",N[0].flowNodeInstanceId),window.location.href=`${N[0].processInstanceId}?${U.toString()}`;return}let O=N.map(U=>({id:U.flowNodeInstanceId,name:`${U.startedAt?.toLocaleString("en-GB")} - ${U.flowNodeId}${U.flowNodeName?` - ${U.flowNodeName}`:""}`,...U}));a({isOpen:!0,placeholder:"Select target to go to:",entries:O,onConfirm:U=>{let $=new URLSearchParams;$.append("selected",U.flowNodeId),$.append("instance",U.flowNodeInstanceId),window.location.href=`${U.processInstanceId}?${$.toString()}`},onClose:()=>a(We)})}}),W&&S.createElement(Tt,{flowNodeId:x.flowNodeId,flowNodeInstanceId:x.flowNodeInstanceId,flowNodeType:c.type,processInstanceId:x.processInstanceId,onPlay:e.onFinish}),Y&&S.createElement(Ut,{onClick:()=>{r({isOpen:!0,flowNodeInstance:x})}})))},[g.current,i,l,C,p]);if(Je(()=>{qt()},[o]),Je(()=>{if(i?.state===Re.finished){Ue();return}let c=setInterval(Ue,1e3);return()=>clearInterval(c)},[Ue,i?.state]),Je(()=>{if(I.length===0||l.length===0){ot([]);return}let c=l.filter(h=>{let _=I.includes(h.flowNodeId),w=p.get(h.flowNodeId)===h.flowNodeInstanceId;return _&&w});if(c.length===0){let h=new URLSearchParams(window.location.search);h.delete("tokenInspectorFocus"),window.history.replaceState({},"",`${window.location.pathname}?${h.toString()}${window.location.hash}`)}ot(c)},[l,I,p]),Je(()=>{if(!i?.xml)return;let c=g.current?.bpmnViewerRef,h=c?.getElementRegistry();!c||!h||c.onImportDone(()=>{let _=new Set(l.map(w=>w.flowNodeId));h.forEach(w=>{if(w.type==="bpmn:SequenceFlow"){Zt(w)?c.addMarker(w.id,"asdk-pii-sequence-flow-finished"):c.hasMarker(w.id,"asdk-pii-sequence-flow-finished")&&c.removeMarker(w.id,"asdk-pii-sequence-flow-finished");return}if(!_.has(w.id))return;let B=l.filter(D=>D.flowNodeId===w.id),x=B.find(D=>D.flowNodeInstanceId===p.get(D.flowNodeId));x&&(c.hasMarker(w.id,"asdk-pii-flow-node-instance-state")||c.addMarker(w.id,"asdk-pii-flow-node-instance-state"),c.hasMarker(w.id,`asdk-pii-flow-node-instance-state--${x.state}`)||c.addMarker(w.id,`asdk-pii-flow-node-instance-state--${x.state}`),Kt(w,B))})})},[g.current,i,l,C,p]),!i?.xml)return e.loadingComponent?e.loadingComponent:S.createElement("div",{className:"app-sdk-absolute app-sdk-w-screen app-sdk-h-screen app-sdk-flex"},S.createElement("div",{className:"app-sdk-m-auto"},"Fetching diagram..."));let Qt=e.showProcessRefreshButton||e.showProcessRetryButton||e.showProcessTerminateButton||e.showTokenInspectorButton,ea=e.showTokenInspectorButton&&(e.showProcessRefreshButton||e.showProcessRetryButton||e.showProcessTerminateButton);return S.createElement("div",{className:"app-sdk-relative app-sdk-w-full app-sdk-h-full"},S.createElement(Ct,{...t}),(e.showRetryFlowNodeInstanceButton||e.showProcessRetryButton)&&S.createElement(Vt,{...s,processInstance:i,onClose:()=>r(c=>({...c,isOpen:!1}))}),Qt&&S.createElement(Bt,null,e.showProcessRefreshButton&&S.createElement(Ot,{onClick:Ue}),e.showProcessRetryButton&&S.createElement(_t,{onClick:()=>r({isOpen:!0}),disabled:!Xt.includes(i.state)}),e.showProcessTerminateButton&&S.createElement(zt,{processInstanceId:o,disabled:i.state!==Re.running}),ea&&S.createElement(Mt,null),e.showTokenInspectorButton&&S.createElement(Jt,{isOpen:n,open:()=>{let c=new URLSearchParams(window.location.search);c.set("tokenInspector","true"),window.history.replaceState({},"",`${window.location.pathname}?${c.toString()}${window.location.hash}`),d(!0)},close:()=>{let c=new URLSearchParams(window.location.search);c.delete("tokenInspector"),window.history.replaceState({},"",`${window.location.pathname}?${c.toString()}${window.location.hash}`),d(!1)}})),S.createElement(Qs,{show:n},S.createElement("div",{className:"app-sdk-transition app-sdk-duration-200 data-[closed]:app-sdk-opacity-0 app-sdk-w-1/4 app-sdk-min-w-64 app-sdk-absolute app-sdk-top-0 app-sdk-right-0 app-sdk-z-40 app-sdk-pt-2 app-sdk-pr-2"},S.createElement(Gt,{processInstance:i,flowNodeInstances:Yt,close:()=>{let c=new URLSearchParams(window.location.search);c.delete("tokenInspector"),window.history.replaceState({},"",`${window.location.pathname}?${c.toString()}${window.location.hash}`),d(!1)}}))),S.createElement(to,{xml:i.xml,ref:g,setSelectedElementIds:j}))}var Fc=or(()=>Promise.resolve(dr),{ssr:!1});export{Qe as BPMNViewer,yr as BPMNViewerNextJS,fo as BooleanFormField,vt as BpmnViewerComponent,ho as CheckboxFormField,go as ColorFormField,wo as ConfirmFormField,vo as CustomFormField,yo as DateFormField,bo as DatetimeLocalFormField,xo as DecimalFormField,to as DiagramDocumentationInspector,Hr as DiagramDocumentationInspectorNextJS,eo as DocumentationViewer,Rr as DropdownMenu,Yr as DropdownMenuItem,on as DynamicLink,qp as DynamicUi,It as DynamicUiComponent,No as EmailFormField,Io as EnumFormField,Fo as FileFormField,ko as FlowNode,bt as FormFieldComponentMap,Co as HeaderFormField,Po as HiddenFormField,So as IntegerFormField,Do as MonthFormField,Bo as ParagraphFormField,Oo as PasswordFormField,dr as ProcessInstanceInspector,Fc as ProcessInstanceInspectorNextJS,Uo as RadioFormField,Lo as RangeFormField,Vo as SelectFormField,ze as SplitterLayout,_o as StringFormField,zo as TelFormField,Se as TextareaFormField,Ao as TimeFormField,$o as UrlFormField,Ho as WeekFormField};
26
+ ${r==="end"?"app-sdk-fixed app-sdk-top-1/2 app-sdk-left-1/2 app-sdk--translate-x-1/2 app-sdk--translate-y-1/2 app-sdk-w-4/5 app-sdk-h-[70vh] app-sdk-bg-white/10 app-sdk-backdrop-blur-xl app-sdk-rounded-xl app-sdk-shadow-2xl app-sdk-z-50 app-sdk-p-6":""}`},b.createElement("div",{className:"app-sdk-flex app-sdk-items-center app-sdk-justify-between"},b.createElement("label",{className:"app-sdk-text-white app-sdk-font-medium"},"End Token"),b.createElement("button",{className:"app-sdk-text-white hover:app-sdk-text-gray-300 app-sdk-w-6 app-sdk-h-6",onClick:()=>d("end"),title:r==="end"?"Minimize":"Maximize"},r==="end"?b.createElement(At,{className:"app-sdk-w-6 app-sdk-h-6"}):b.createElement($t,{className:"app-sdk-w-6 app-sdk-h-6"}))),b.createElement(Ht,{height:r==="end"?"60vh":"7rem",defaultLanguage:"json",value:f,options:{lineNumbersMinChars:2,readOnly:!0,minimap:{enabled:!1}}})))))}import Oe,{useEffect as Zs,useState as Ks}from"react";function Jt(e){let[o,t]=Ks(e.isOpen??!1);return Zs(()=>{t(e.isOpen??!1)},[e.isOpen]),Oe.createElement(oe,{disabled:e.disabled,title:"View Process Tokens",onClick:()=>{o?e.close():e.open(),t(a=>!a)}},o?Oe.createElement("svg",{className:"dark:!app-sdk-stroke-app-sdk-gray-50 dark:!app-sdk-fill-app-sdk-gray-50",xmlns:"http://www.w3.org/2000/svg",width:"1.25rem",height:"1.25rem",viewBox:"0 0 384 512"},Oe.createElement("path",{d:"M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"})):Oe.createElement("svg",{className:"dark:!app-sdk-stroke-app-sdk-gray-50 dark:!app-sdk-fill-app-sdk-gray-50",xmlns:"http://www.w3.org/2000/svg",width:"1.25rem",height:"1.25rem",viewBox:"0 0 448 512"},Oe.createElement("path",{d:"M0 96C0 78.3 14.3 64 32 64l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 128C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 288c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32L32 448c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z"})))}var Xt=[Re.error,Re.terminated],sr=[R.manualTask,R.userTask,R.untypedTask],Rt=[R.endEvent,R.intermediateThrowEvent,R.sendTask],rr=[R.startEvent,R.intermediateCatchEvent,R.boundaryEvent,R.receiveTask],We={isOpen:!1,placeholder:"",entries:[],onConfirm:()=>{},onClose:()=>{}},nr={isOpen:!1},Xe="asdk-buttons";function dr(e){let{processInstanceId:o}=e,[t,a]=Q(We),[s,r]=Q(nr),[n,d]=Q(!1),[i,f]=Q(),[l,u]=Q([]),[C,V]=Q([]),[p,k]=Q(new Map),[I,j]=Q([]),[Yt,ot]=Q([]),g=tr(null),qt=Ge(async()=>{let c=await import("./actions-BW4Q6NQT.mjs"),h=c.getProcessInstance(o),_=c.getFlowNodeInstances(o),[w,B]=await Promise.all([h,_]),x=await c.getTriggeredFlowNodeInstances(B.map(N=>N.flowNodeInstanceId));f(w),u(B),V(x);let D=new URLSearchParams(window.location.search);D.get("tokenInspector")==="true"&&d(!0);let W=D.getAll("instance"),Y=B.filter(N=>W.includes(N.flowNodeInstanceId));Y.length!==W.length&&(D.delete("instance"),Y.forEach(N=>D.append("instance",N.flowNodeInstanceId)),window.history.replaceState({},"",`${window.location.pathname}?${D.toString()}`));let A=new Map;B.forEach(N=>{A.has(N.flowNodeId)||A.set(N.flowNodeId,N.flowNodeInstanceId)}),Y.forEach(N=>A.set(N.flowNodeId,N.flowNodeInstanceId)),k(A)},[o]),Zt=Ge(c=>{let h=er(c),_=l.some(B=>B.flowNodeId===h.targetRef.id),w=l.some(B=>B.flowNodeId===h.sourceRef.id&&B.state===Wt.finished);return _&&w},[l]),Ue=Ge(async()=>{let c=g.current?.bpmnViewerRef,h=c?.getOverlays();if(!c||!h)return;let _=await import("./actions-BW4Q6NQT.mjs"),w=_.getProcessInstance(o),B=_.getFlowNodeInstances(o),[x,D]=await Promise.all([w,B]),pe=await _.getTriggeredFlowNodeInstances(D.map(T=>T.flowNodeInstanceId));if(et(x,i)&&et(D,l)&&et(pe,C))return;x.state!==i?.state&&h.clear();for(let[T,Le]of p.entries()){let le=l.find(O=>O.flowNodeInstanceId===Le);if(!le)continue;let Ve=D.find(O=>O.flowNodeId===T);Ve?.flowNodeInstanceId===Le&&le.state===Ve.state||(c.removeMarker(T,`asdk-pii-flow-node-instance-state--${le.state}`),h.remove({element:T,type:Xe}))}f(x),u(D),V(pe);let W=new URLSearchParams(window.location.search),Y=W.getAll("instance"),A=D.filter(T=>Y.includes(T.flowNodeInstanceId));A.length!==Y.length&&(W.delete("instance"),A.forEach(T=>W.append("instance",T.flowNodeInstanceId)),window.history.replaceState({},"",`${window.location.pathname}?${W.toString()}`));let N=new Map;D.forEach(T=>{N.has(T.flowNodeId)||N.set(T.flowNodeId,T.flowNodeInstanceId)}),A.forEach(T=>N.set(T.flowNodeId,T.flowNodeInstanceId)),k(N)},[g.current,i,p,l,o]),Kt=Ge((c,h)=>{let _=g.current?.bpmnViewerRef,w=_?.getOverlays();if(!_||!w)return;let B=w.get({element:c.id,type:Xe});if(Array.isArray(B)&&B.length>0)return;let x=h.find(O=>O.flowNodeInstanceId===p.get(O.flowNodeId));if(!x)return;let D=e.showFlowNodeExecutionCount&&h.length>1,pe=e.showFlowNodeInstancesListButton&&h.length>1,W=e.showFinishTaskButton&&sr.includes(c.type)&&x.state===Wt.suspended,Y=e.showRetryFlowNodeInstanceButton&&i&&Xt.includes(i.state),A=!1,N=[];if(e.showGoToFlowNodeButton&&rr.includes(c.type)){let O=x.triggeredByFlowNodeInstance;A=O!==void 0,N=O?[O]:[]}else if(e.showGoToFlowNodeButton&&Rt.includes(c.type)){let O=C.filter(U=>U.triggeredByFlowNodeInstance?.flowNodeInstanceId===x.flowNodeInstanceId);A=O.length>0,N=O}if(!D&&!W&&!Y&&!A)return;let T=c.width<52,Le=w.add(c.id,Xe,{position:{bottom:-7,left:T?-c.width/2:0},html:"<div></div>"}),le=w.get(Le),Ve=ar(le.htmlContainer),Ye=h.indexOf(x)===0,qe=h.length-h.indexOf(x);Ve.render(S.createElement(Pt,{width:T?c.width*2:c.width},D&&S.createElement(X,{className:"app-sdk-select-none !app-sdk-cursor-default !app-sdk-bg-slate-500",title:`Flow Node was executed ${h.length} times.${Ye?"":` You are viewing instance #${qe}.`}`},`${Ye?"":`${qe}/`}${h.length}`),pe&&S.createElement(Dt,{onClick:()=>{let O=h.map($=>({id:$.flowNodeInstanceId,name:`${$.startedAt?.toLocaleString("en-GB")} - ${$.flowNodeInstanceId} - ${$.state}${$.flowNodeInstanceId===x.flowNodeInstanceId?" (selected)":""}`,...$}));a({isOpen:!0,placeholder:"Select instance to display:",entries:O,onConfirm:async $=>{let Ze=h.find(Ke=>Ke.flowNodeInstanceId===$.flowNodeInstanceId);if(!Ze)return;_.removeMarker(x.flowNodeId,`asdk-pii-flow-node-instance-state--${x.state}`),w.remove({element:c.id,type:Xe});let _e=new URLSearchParams(window.location.search);_e.getAll("instance").includes(x.flowNodeInstanceId)&&_e.delete("instance",x.flowNodeInstanceId),h.indexOf(Ze)!==0&&_e.append("instance",Ze.flowNodeInstanceId),window.history.replaceState({},"",`${window.location.pathname}?${_e.toString()}${window.location.hash}`),k(Ke=>new Map(Ke).set(c.id,$.flowNodeInstanceId)),a(We)},onClose:()=>a(We)})}}),A&&S.createElement(St,{isSender:Rt.includes(c.type),onClick:()=>{if(N.length===1){let U=new URLSearchParams;U.append("selected",N[0].flowNodeId),U.append("instance",N[0].flowNodeInstanceId),window.location.href=`${N[0].processInstanceId}?${U.toString()}`;return}let O=N.map(U=>({id:U.flowNodeInstanceId,name:`${U.startedAt?.toLocaleString("en-GB")} - ${U.flowNodeId}${U.flowNodeName?` - ${U.flowNodeName}`:""}`,...U}));a({isOpen:!0,placeholder:"Select target to go to:",entries:O,onConfirm:U=>{let $=new URLSearchParams;$.append("selected",U.flowNodeId),$.append("instance",U.flowNodeInstanceId),window.location.href=`${U.processInstanceId}?${$.toString()}`},onClose:()=>a(We)})}}),W&&S.createElement(Tt,{flowNodeId:x.flowNodeId,flowNodeInstanceId:x.flowNodeInstanceId,flowNodeType:c.type,processInstanceId:x.processInstanceId,onPlay:e.onFinish}),Y&&S.createElement(Ut,{onClick:()=>{r({isOpen:!0,flowNodeInstance:x})}})))},[g.current,i,l,C,p]);if(Je(()=>{qt()},[o]),Je(()=>{if(i?.state===Re.finished){Ue();return}let c=setInterval(Ue,1e3);return()=>clearInterval(c)},[Ue,i?.state]),Je(()=>{if(I.length===0||l.length===0){ot([]);return}let c=l.filter(h=>{let _=I.includes(h.flowNodeId),w=p.get(h.flowNodeId)===h.flowNodeInstanceId;return _&&w});if(c.length===0){let h=new URLSearchParams(window.location.search);h.delete("tokenInspectorFocus"),window.history.replaceState({},"",`${window.location.pathname}?${h.toString()}${window.location.hash}`)}ot(c)},[l,I,p]),Je(()=>{if(!i?.xml)return;let c=g.current?.bpmnViewerRef,h=c?.getElementRegistry();!c||!h||c.onImportDone(()=>{let _=new Set(l.map(w=>w.flowNodeId));h.forEach(w=>{if(w.type==="bpmn:SequenceFlow"){Zt(w)?c.addMarker(w.id,"asdk-pii-sequence-flow-finished"):c.hasMarker(w.id,"asdk-pii-sequence-flow-finished")&&c.removeMarker(w.id,"asdk-pii-sequence-flow-finished");return}if(!_.has(w.id))return;let B=l.filter(D=>D.flowNodeId===w.id),x=B.find(D=>D.flowNodeInstanceId===p.get(D.flowNodeId));x&&(c.hasMarker(w.id,"asdk-pii-flow-node-instance-state")||c.addMarker(w.id,"asdk-pii-flow-node-instance-state"),c.hasMarker(w.id,`asdk-pii-flow-node-instance-state--${x.state}`)||c.addMarker(w.id,`asdk-pii-flow-node-instance-state--${x.state}`),Kt(w,B))})})},[g.current,i,l,C,p]),!i?.xml)return e.loadingComponent?e.loadingComponent:S.createElement("div",{className:"app-sdk-absolute app-sdk-w-screen app-sdk-h-screen app-sdk-flex"},S.createElement("div",{className:"app-sdk-m-auto"},"Fetching diagram..."));let Qt=e.showProcessRefreshButton||e.showProcessRetryButton||e.showProcessTerminateButton||e.showTokenInspectorButton,ea=e.showTokenInspectorButton&&(e.showProcessRefreshButton||e.showProcessRetryButton||e.showProcessTerminateButton);return S.createElement("div",{className:"app-sdk-relative app-sdk-w-full app-sdk-h-full"},S.createElement(Ct,{...t}),(e.showRetryFlowNodeInstanceButton||e.showProcessRetryButton)&&S.createElement(Vt,{...s,processInstance:i,onClose:()=>r(c=>({...c,isOpen:!1}))}),Qt&&S.createElement(Bt,null,e.showProcessRefreshButton&&S.createElement(Ot,{onClick:Ue}),e.showProcessRetryButton&&S.createElement(_t,{onClick:()=>r({isOpen:!0}),disabled:!Xt.includes(i.state)}),e.showProcessTerminateButton&&S.createElement(zt,{processInstanceId:o,disabled:i.state!==Re.running}),ea&&S.createElement(Mt,null),e.showTokenInspectorButton&&S.createElement(Jt,{isOpen:n,open:()=>{let c=new URLSearchParams(window.location.search);c.set("tokenInspector","true"),window.history.replaceState({},"",`${window.location.pathname}?${c.toString()}${window.location.hash}`),d(!0)},close:()=>{let c=new URLSearchParams(window.location.search);c.delete("tokenInspector"),window.history.replaceState({},"",`${window.location.pathname}?${c.toString()}${window.location.hash}`),d(!1)}})),S.createElement(Qs,{show:n},S.createElement("div",{className:"app-sdk-transition app-sdk-duration-200 data-[closed]:app-sdk-opacity-0 app-sdk-w-1/4 app-sdk-min-w-64 app-sdk-absolute app-sdk-top-0 app-sdk-right-0 app-sdk-z-40 app-sdk-pt-2 app-sdk-pr-2"},S.createElement(Gt,{processInstance:i,flowNodeInstances:Yt,close:()=>{let c=new URLSearchParams(window.location.search);c.delete("tokenInspector"),window.history.replaceState({},"",`${window.location.pathname}?${c.toString()}${window.location.hash}`),d(!1)}}))),S.createElement(to,{xml:i.xml,ref:g,setSelectedElementIds:j}))}var Fc=or(()=>Promise.resolve(dr),{ssr:!1});export{Qe as BPMNViewer,yr as BPMNViewerNextJS,fo as BooleanFormField,vt as BpmnViewerComponent,ho as CheckboxFormField,go as ColorFormField,wo as ConfirmFormField,vo as CustomFormField,yo as DateFormField,bo as DatetimeLocalFormField,xo as DecimalFormField,to as DiagramDocumentationInspector,Hr as DiagramDocumentationInspectorNextJS,eo as DocumentationViewer,Rr as DropdownMenu,Yr as DropdownMenuItem,on as DynamicLink,qp as DynamicUi,It as DynamicUiComponent,No as EmailFormField,Io as EnumFormField,Fo as FileFormField,ko as FlowNode,bt as FormFieldComponentMap,Co as HeaderFormField,Po as HiddenFormField,So as IntegerFormField,Do as MonthFormField,Bo as ParagraphFormField,Oo as PasswordFormField,dr as ProcessInstanceInspector,Fc as ProcessInstanceInspectorNextJS,Uo as RadioFormField,Lo as RangeFormField,Vo as SelectFormField,ze as SplitterLayout,_o as StringFormField,zo as TelFormField,Se as TextareaFormField,Ao as TimeFormField,$o as UrlFormField,Ho as WeekFormField};
@@ -1,7 +1,7 @@
1
- import { DataModels, FlowNodeInstance } from '@5minds/processcube_engine_sdk';
1
+ import { DataModels } from '@5minds/processcube_engine_client';
2
2
  export declare const finishTask: (flowNodeInstanceId: string, flowNodeType: "bpmn:UserTask" | "bpmn:ManualTask" | "bpmn:Task") => Promise<void>;
3
3
  export declare const terminateProcess: (processInstanceId: string) => Promise<void>;
4
4
  export declare const retryProcess: (processInstanceId: string, flowNodeInstanceId?: string, newStartToken?: any) => Promise<void>;
5
5
  export declare const getProcessInstance: (processInstanceId: string) => Promise<DataModels.ProcessInstances.ProcessInstance>;
6
- export declare const getFlowNodeInstances: (processInstanceId: string) => Promise<FlowNodeInstance[]>;
7
- export declare const getTriggeredFlowNodeInstances: (flowNodeInstanceIds: string[]) => Promise<FlowNodeInstance[]>;
6
+ export declare const getFlowNodeInstances: (processInstanceId: string) => Promise<DataModels.FlowNodeInstances.FlowNodeInstance[]>;
7
+ export declare const getTriggeredFlowNodeInstances: (flowNodeInstanceIds: string[]) => Promise<DataModels.FlowNodeInstances.FlowNodeInstance[]>;
@@ -1 +1 @@
1
- var h=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var me=Object.prototype.hasOwnProperty;var ke=(e,t)=>{for(var s in t)h(e,s,{get:t[s],enumerable:!0})},we=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ye(t))!me.call(e,o)&&o!==s&&h(e,o,{get:()=>t[o],enumerable:!(n=Ie(t,o))||n.enumerable});return e};var Te=e=>we(h({},"__esModule",{value:!0}),e);var Ye={};ke(Ye,{cancelReservedUserTask:()=>Me,finishManualTask:()=>W,finishTask:()=>Ge,finishUntypedTask:()=>K,finishUserTask:()=>q,finishUserTaskAndGetNext:()=>Re,getActiveProcessInstances:()=>Se,getAssignedUserTasksByIdentity:()=>De,getEngineClient:()=>_e,getFlowNodeInstances:()=>He,getFlowNodeInstancesByProcessInstanceId:()=>O,getFlowNodeInstancesTriggeredByFlowNodeInstanceIds:()=>B,getIdentity:()=>i,getProcessInstance:()=>je,getProcessInstanceById:()=>A,getReservedUserTasksByIdentity:()=>Oe,getTriggeredFlowNodeInstances:()=>Qe,getUserTasks:()=>oe,getWaitingUserTaskByFlowNodeInstanceId:()=>ae,getWaitingUserTasks:()=>Ue,getWaitingUserTasksByCorrelationId:()=>ve,getWaitingUserTasksByFlowNodeId:()=>Ae,getWaitingUserTasksByProcessInstanceId:()=>Fe,navigateToUrl:()=>We,queryFlowNodeInstances:()=>v,reserveUserTask:()=>Be,retryProcess:()=>$e,retryProcessInstance:()=>M,startProcess:()=>qe,terminateProcess:()=>Xe,terminateProcessInstance:()=>D,waitForProcessEnd:()=>he,waitForUserTask:()=>be,withApplicationSdk:()=>Le});module.exports=Te(Ye);var Rt=require("only-server"),Ut=require("../common/index.cjs");var $=require("node:child_process"),P=require("node:fs"),d=require("node:path"),j=require("chokidar"),H=require("esbuild"),Q=require("jwt-decode"),x=require("openid-client"),Y=require("@5minds/processcube_engine_sdk");var X=require("@5minds/processcube_engine_client"),b=process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560",r=new X.EngineClient(b);var ge={token:"ZHVtbXlfdG9rZW4=",userId:"dummy_token"},Ee=.85,N=["external_task.ts","external_task.js"],R=process.env.PROCESSCUBE_AUTHORITY_URL!==void 0,w=new Y.Logger("processcube_app_sdk:external_task_adapter"),k={},E;async function V(e){if(e&&!(0,P.existsSync)(e))throw new Error(`Invalid customExternalTasksDirPath. The given path '${e}' does not exist`);x.custom.setHttpOptionsDefaults({timeout:1e5});let t=await z();E=await ee(t),await Ce(t);let s=xe(e);(0,j.watch)(s).on("add",async n=>{if(N.includes((0,d.basename)(n)))return Z(n,s)}).on("change",async n=>{if(N.includes((0,d.basename)(n)))return Pe(n,s)}).on("unlink",async n=>{N.includes((0,d.basename)(n))&&J(n)}).on("error",n=>w.error(`Watcher error: ${n}`))}async function Z(e,t){let s=(0,d.dirname)(e);if((await P.promises.readdir(s)).filter(p=>N.includes(p)).length>1){w.error(`Multiple external task files found in directory ${s}. Stopping all external task workers for this directory.`),k[s]&&J(e);return}let a=await te(e),c=(0,d.relative)(t,s),l=se(c),u=(0,d.join)(__dirname,"lib/ExternalTaskWorkerProcess.cjs"),y=(0,$.fork)(u,{env:{...process.env,PROCESSCUBE_ENGINE_URL:b}});k[s]=y,y.once("disconnect",()=>{delete k[s]}),y.send({action:"create",payload:{topic:l,identity:E,moduleString:a,workerPath:e}})}async function Pe(e,t){let s=(0,d.dirname)(e),n=k[s];if(!n)return Z(e,t);let o=await te(e),a=(0,d.relative)(t,s),c=se(a);n.send({action:"restart",payload:{topic:c,identity:E,moduleString:o,workerPath:e}})}function J(e){let t=(0,d.dirname)(e),s=k[t];s&&s.kill()}async function z(){if(!R)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 w.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 x.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 ee(e){if(!R||e===null)return ge;let t=e.access_token,s=(0,Q.jwtDecode)(t);return{token:e.access_token,userId:s.sub}}async function Ce(e){let t=5;if(!R||e===null)return;let n=await Ne(e)*Ee*1e3,o=async()=>{try{let a=await z();E=ee(a);for(let c of Object.values(k))c.send({action:"updateIdentity",payload:{identity:E}});t=5,setTimeout(o,n)}catch(a){if(t===0){w.error("Could not refresh identity for external task worker processes. Stopping all external task workers.",{error:a});for(let l of Object.values(k))l.kill();return}w.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 te(e){let t=await(0,H.build)({entryPoints:[e],write:!1,bundle:!0,platform:"node",target:"node18",format:"cjs",external:["@opentelemetry/api"]});if(t.errors.length>0)throw w.error(`Could not transpile file at '${e}'`,{errors:t.errors}),new Error(`Could not transpile file at '${e}'`);return t.warnings.length>0&&w.warn(`Transpiled file at '${e}' with warnings`,{warnings:t.warnings}),t.outputFiles[0].text}async function Ne(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 se(e){return e.replace(/^\.\/+|\([^)]+\)|^\/*|\/*$/g,"").replace(/[\/]{2,}/g,"/")}function xe(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,P.existsSync)(n)){t=n;break}if(!t)throw new Error("Could not find external tasks directory");return t}function _e(){return r}var U=require("next-auth/jwt"),ne=require("next/dist/compiled/@edge-runtime/cookies"),m=require("next/headers");async function i(){let e=await(0,U.getToken)({req:{cookies:(0,m.cookies)(),headers:(0,m.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,m.cookies)().toString()}}),n=new ne.ResponseCookies(s.headers);if(n.getAll().length){let o=!1;try{for(let a of n.getAll())(0,m.cookies)().set(a.name,a.value,{...a})}catch{o=!0}if(e=await(0,U.getToken)({req:{cookies:o?n:(0,m.cookies)(),headers:(0,m.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 T=require("@5minds/processcube_engine_client");var _=300,F=1e3;async function C(){try{return i()}catch{return}}async function A(e){let t=await C();return(await r.processInstances.query({processInstanceId:e},{identity:t})).processInstances[0]}async function v(e,t){let{processInstanceId:s,flowNodeInstanceId:n}=e,o=n;if(!s&&!o)return[];let a=[];return o&&o.length>_?await Promise.all(new Array(Math.ceil(o.length/_)).fill(null).map(async(c,l)=>{let u=await re({flowNodeInstanceId:o.slice(l*_,(l+1)*_)},{...t,identity:t?.identity??await C()});a.push(...u)})):a.push(...await re({processInstanceId:s,flowNodeInstanceId:o},{...t,identity:t?.identity??await C()})),a}async function O(e,t={sortSettings:{sortBy:T.DataModels.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"ASC"}}){return await v({processInstanceId:e},t)}async function B(e){return await v({triggeredByFlowNodeInstance:e})}async function M(e,t,s){let n=await C();await r.processInstances.retryProcessInstance(e,{flowNodeInstanceId:t,newStartToken:s,identity:n})}async function D(e){let t=await C();await r.processInstances.terminateProcessInstance(e,t)}async function Se(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:T.DataModels.ProcessInstances.ProcessInstanceState.running},e?.options)}async function he(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=[],l=async u=>{if(s!==void 0&&u.processInstanceId!==s)return;let p=await r.processInstances.query({processInstanceId:u.processInstanceId},{identity:n});for(let S of c)r.notification.removeSubscription(S,n);return p.totalCount===0?a(new Error(`Process with instance ID "${u.processInstanceId}" does not exist.`)):o(p.processInstances[0])};if(c.push(await r.notification.onProcessEnded(l,{identity:n})),c.push(await r.notification.onProcessError(l,{identity:n})),c.push(await r.notification.onProcessTerminated(l,{identity:n})),s){let u=await r.processInstances.query({processInstanceId:s,state:[T.DataModels.ProcessInstances.ProcessInstanceState.finished,T.DataModels.ProcessInstances.ProcessInstanceState.terminated,T.DataModels.ProcessInstances.ProcessInstanceState.error]},{identity:n});if(u.totalCount>0){for(let y of c)r.notification.removeSubscription(y,n);o(u.processInstances[0])}}})}async function re(e,t){let s=[],n=await r.flowNodeInstances.query(e,{...t,limit:F});if(s.push(...n.flowNodeInstances),n.flowNodeInstances.length!==n.totalCount){let o=Math.floor(n.totalCount/n.flowNodeInstances.length);await Promise.all(new Array(o).fill(null).map(async(a,c)=>{let l=await r.flowNodeInstances.query(e,{...t,limit:F,offset:F*(c+1)});s.push(...l.flowNodeInstances)}))}return s}var I=require("@5minds/processcube_engine_client"),f=require("../common/index.cjs");async function be(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,l)=>{let u=await r.userTasks.onUserTaskWaiting(async p=>{let S=s!==void 0&&p.correlationId!==s,ue=p.flowNodeInstanceId===void 0,pe=n!==void 0&&p.processInstanceId!==n,fe=o!==void 0&&p.flowNodeId!==o;if(S||ue||pe||fe)return;let G=await ae(p.flowNodeInstanceId,{identity:a});return r.notification.removeSubscription(u,a),G===null?l(new Error(`UserTask with instance ID "${p.flowNodeInstanceId}" does not exist.`)):c(G)},{identity:a}),y=await oe({correlationId:s,processInstanceId:n,flowNodeId:o,state:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:a});y.userTasks.length>0&&(r.notification.removeSubscription(u,a),c(y.userTasks[0]))})}async function Re(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:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended,...t},c=await r.userTasks.query(a,{identity:o});return(0,f.mapUserTask)(c.userTasks[0])}async function oe(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,f.mapUserTaskList)(s)}async function Ue(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:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},e);return(0,f.mapUserTaskList)(t)}async function Fe(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:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},t);return(0,f.mapUserTaskList)(s)}async function Ae(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:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},t);return(0,f.mapUserTaskList)(s)}async function ae(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:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{...t,limit:1});return s.userTasks.length===0?null:(0,f.mapUserTask)(s.userTasks[0])}async function ve(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:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},t);return(0,f.mapUserTaskList)(s)}async function Oe(e,t){let s=e||await i(),n=await r.userTasks.query({state:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:s,...t}),o=n.userTasks.filter(a=>a.actualOwnerId===s.userId);return n.userTasks=o,(0,f.mapUserTaskList)(n)}async function Be(e,t,s){await r.userTasks.reserveUserTaskInstance(e,t,s||e.userId)}async function Me(e,t){await r.userTasks.cancelUserTaskInstanceReservation(e,t)}async function De(e,t){let s=e||await i(),n=await r.userTasks.query({state:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:s,...t}),o=n.userTasks.filter(a=>a.assignedUserIds?.includes(s.userId));return n.userTasks=o,(0,f.mapUserTaskList)(n)}var g=require("next/dist/shared/lib/constants");var ie=!1,L=!1;function Le(e={}){let{applicationSdk:t,...s}=e;return async(n,o)=>{L=L||n===g.PHASE_PRODUCTION_BUILD;let a=n===g.PHASE_DEVELOPMENT_SERVER||n===g.PHASE_PRODUCTION_SERVER;return t?.useExternalTasks&&a&&!ie&&!L&&(ie=!0,await V(t?.customExternalTasksDirPath)),{...s,experimental:{...s.experimental,serverComponentsExternalPackages:[...s.experimental?.serverComponentsExternalPackages||[],"esbuild"]}}}}var ce=require("next/cache"),de=require("next/navigation");function We(e){(0,ce.revalidatePath)(e),(0,de.redirect)(e)}async function qe(...e){return await r.processModels.startProcessInstance(...e)}async function W(...e){await r.manualTasks.finishManualTask(...e)}async function q(...e){await r.userTasks.finishUserTask(...e)}async function K(...e){await r.untypedTasks.finishTask(...e)}var le=require("@5minds/processcube_engine_sdk");async function Ke(){try{return i()}catch{return}}var Ge=async(e,t)=>{let s=await Ke();t==="bpmn:UserTask"?await q(e,{},s):t==="bpmn:ManualTask"?await W(e,s):t==="bpmn:Task"?await K(e,s):console.error(`[@5minds/processcube_app_sdk:handlePlay] Unsupported flow node type: ${t}`)},Xe=async e=>{await D(e)},$e=async(e,t,s)=>{await M(e,t,s)},je=async e=>A(e),He=async e=>O(e,{sortSettings:{sortBy:le.DataModels.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"DESC"}}),Qe=async e=>B(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,queryFlowNodeInstances,reserveUserTask,retryProcess,retryProcessInstance,startProcess,terminateProcess,terminateProcessInstance,waitForProcessEnd,waitForUserTask,withApplicationSdk});
1
+ var h=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var me=Object.prototype.hasOwnProperty;var we=(e,t)=>{for(var s in t)h(e,s,{get:t[s],enumerable:!0})},ke=(e,t,s,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ye(t))!me.call(e,o)&&o!==s&&h(e,o,{get:()=>t[o],enumerable:!(n=Ie(t,o))||n.enumerable});return e};var Te=e=>ke(h({},"__esModule",{value:!0}),e);var Ye={};we(Ye,{cancelReservedUserTask:()=>Oe,finishManualTask:()=>W,finishTask:()=>Ge,finishUntypedTask:()=>K,finishUserTask:()=>q,finishUserTaskAndGetNext:()=>Re,getActiveProcessInstances:()=>Se,getAssignedUserTasksByIdentity:()=>Be,getEngineClient:()=>_e,getFlowNodeInstances:()=>He,getFlowNodeInstancesByProcessInstanceId:()=>v,getFlowNodeInstancesTriggeredByFlowNodeInstanceIds:()=>D,getIdentity:()=>i,getProcessInstance:()=>je,getProcessInstanceById:()=>A,getReservedUserTasksByIdentity:()=>ve,getTriggeredFlowNodeInstances:()=>Qe,getUserTasks:()=>oe,getWaitingUserTaskByFlowNodeInstanceId:()=>ae,getWaitingUserTasks:()=>Ue,getWaitingUserTasksByCorrelationId:()=>Me,getWaitingUserTasksByFlowNodeId:()=>Ae,getWaitingUserTasksByProcessInstanceId:()=>Fe,navigateToUrl:()=>We,queryFlowNodeInstances:()=>M,reserveUserTask:()=>De,retryProcess:()=>$e,retryProcessInstance:()=>O,startProcess:()=>qe,terminateProcess:()=>Xe,terminateProcessInstance:()=>B,waitForProcessEnd:()=>he,waitForUserTask:()=>be,withApplicationSdk:()=>Le});module.exports=Te(Ye);var bt=require("only-server"),Rt=require("../common/index.cjs");var $=require("node:child_process"),P=require("node:fs"),d=require("node:path"),j=require("chokidar"),H=require("esbuild"),Q=require("jwt-decode"),x=require("openid-client"),Y=require("@5minds/processcube_engine_sdk");var X=require("@5minds/processcube_engine_client"),b=process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560",r=new X.EngineClient(b);var ge={token:"ZHVtbXlfdG9rZW4=",userId:"dummy_token"},Ee=.85,C=["external_task.ts","external_task.js"],R=process.env.PROCESSCUBE_AUTHORITY_URL!==void 0,k=new Y.Logger("processcube_app_sdk:external_task_adapter"),w={},E;async function V(e){if(e&&!(0,P.existsSync)(e))throw new Error(`Invalid customExternalTasksDirPath. The given path '${e}' does not exist`);x.custom.setHttpOptionsDefaults({timeout:1e5});let t=await z();E=await ee(t),await Ne(t);let s=xe(e);(0,j.watch)(s).on("add",async n=>{if(C.includes((0,d.basename)(n)))return Z(n,s)}).on("change",async n=>{if(C.includes((0,d.basename)(n)))return Pe(n,s)}).on("unlink",async n=>{C.includes((0,d.basename)(n))&&J(n)}).on("error",n=>k.error(`Watcher error: ${n}`))}async function Z(e,t){let s=(0,d.dirname)(e);if((await P.promises.readdir(s)).filter(p=>C.includes(p)).length>1){k.error(`Multiple external task files found in directory ${s}. Stopping all external task workers for this directory.`),w[s]&&J(e);return}let a=await te(e),c=(0,d.relative)(t,s),l=se(c),u=(0,d.join)(__dirname,"lib/ExternalTaskWorkerProcess.cjs"),y=(0,$.fork)(u,{env:{...process.env,PROCESSCUBE_ENGINE_URL:b}});w[s]=y,y.once("disconnect",()=>{delete w[s]}),y.send({action:"create",payload:{topic:l,identity:E,moduleString:a,workerPath:e}})}async function Pe(e,t){let s=(0,d.dirname)(e),n=w[s];if(!n)return Z(e,t);let o=await te(e),a=(0,d.relative)(t,s),c=se(a);n.send({action:"restart",payload:{topic:c,identity:E,moduleString:o,workerPath:e}})}function J(e){let t=(0,d.dirname)(e),s=w[t];s&&s.kill()}async function z(){if(!R)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 k.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 x.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 ee(e){if(!R||e===null)return ge;let t=e.access_token,s=(0,Q.jwtDecode)(t);return{token:e.access_token,userId:s.sub}}async function Ne(e){let t=5;if(!R||e===null)return;let n=await Ce(e)*Ee*1e3,o=async()=>{try{let a=await z();E=ee(a);for(let c of Object.values(w))c.send({action:"updateIdentity",payload:{identity:E}});t=5,setTimeout(o,n)}catch(a){if(t===0){k.error("Could not refresh identity for external task worker processes. Stopping all external task workers.",{error:a});for(let l of Object.values(w))l.kill();return}k.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 te(e){let t=await(0,H.build)({entryPoints:[e],write:!1,bundle:!0,platform:"node",target:"node18",format:"cjs",external:["@opentelemetry/api"]});if(t.errors.length>0)throw k.error(`Could not transpile file at '${e}'`,{errors:t.errors}),new Error(`Could not transpile file at '${e}'`);return t.warnings.length>0&&k.warn(`Transpiled file at '${e}' with warnings`,{warnings:t.warnings}),t.outputFiles[0].text}async function Ce(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 se(e){return e.replace(/^\.\/+|\([^)]+\)|^\/*|\/*$/g,"").replace(/[\/]{2,}/g,"/")}function xe(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,P.existsSync)(n)){t=n;break}if(!t)throw new Error("Could not find external tasks directory");return t}function _e(){return r}var U=require("next-auth/jwt"),ne=require("next/dist/compiled/@edge-runtime/cookies"),m=require("next/headers");async function i(){let e=await(0,U.getToken)({req:{cookies:(0,m.cookies)(),headers:(0,m.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,m.cookies)().toString()}}),n=new ne.ResponseCookies(s.headers);if(n.getAll().length){let o=!1;try{for(let a of n.getAll())(0,m.cookies)().set(a.name,a.value,{...a})}catch{o=!0}if(e=await(0,U.getToken)({req:{cookies:o?n:(0,m.cookies)(),headers:(0,m.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 T=require("@5minds/processcube_engine_client");var _=300,F=1e3;async function N(){try{return i()}catch{return}}async function A(e){let t=await N();return(await r.processInstances.query({processInstanceId:e},{identity:t})).processInstances[0]}async function M(e,t){let{processInstanceId:s,flowNodeInstanceId:n}=e,o=n;if(!s&&!o)return[];let a=[];return o&&o.length>_?await Promise.all(new Array(Math.ceil(o.length/_)).fill(null).map(async(c,l)=>{let u=await re({flowNodeInstanceId:o.slice(l*_,(l+1)*_)},{...t,identity:t?.identity??await N()});a.push(...u)})):a.push(...await re({processInstanceId:s,flowNodeInstanceId:o},{...t,identity:t?.identity??await N()})),a}async function v(e,t={sortSettings:{sortBy:T.DataModels.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"ASC"}}){return await M({processInstanceId:e},t)}async function D(e){return await M({triggeredByFlowNodeInstance:e})}async function O(e,t,s){let n=await N();await r.processInstances.retryProcessInstance(e,{flowNodeInstanceId:t,newStartToken:s,identity:n})}async function B(e){let t=await N();await r.processInstances.terminateProcessInstance(e,t)}async function Se(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:T.DataModels.ProcessInstances.ProcessInstanceState.running},e?.options)}async function he(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=[],l=async u=>{if(s!==void 0&&u.processInstanceId!==s)return;let p=await r.processInstances.query({processInstanceId:u.processInstanceId},{identity:n});for(let S of c)r.notification.removeSubscription(S,n);return p.totalCount===0?a(new Error(`Process with instance ID "${u.processInstanceId}" does not exist.`)):o(p.processInstances[0])};if(c.push(await r.notification.onProcessEnded(l,{identity:n})),c.push(await r.notification.onProcessError(l,{identity:n})),c.push(await r.notification.onProcessTerminated(l,{identity:n})),s){let u=await r.processInstances.query({processInstanceId:s,state:[T.DataModels.ProcessInstances.ProcessInstanceState.finished,T.DataModels.ProcessInstances.ProcessInstanceState.terminated,T.DataModels.ProcessInstances.ProcessInstanceState.error]},{identity:n});if(u.totalCount>0){for(let y of c)r.notification.removeSubscription(y,n);o(u.processInstances[0])}}})}async function re(e,t){let s=[],n=await r.flowNodeInstances.query(e,{...t,limit:F});if(s.push(...n.flowNodeInstances),n.flowNodeInstances.length!==n.totalCount){let o=Math.floor(n.totalCount/n.flowNodeInstances.length);await Promise.all(new Array(o).fill(null).map(async(a,c)=>{let l=await r.flowNodeInstances.query(e,{...t,limit:F,offset:F*(c+1)});s.push(...l.flowNodeInstances)}))}return s}var I=require("@5minds/processcube_engine_client"),f=require("../common/index.cjs");async function be(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,l)=>{let u=await r.userTasks.onUserTaskWaiting(async p=>{let S=s!==void 0&&p.correlationId!==s,ue=p.flowNodeInstanceId===void 0,pe=n!==void 0&&p.processInstanceId!==n,fe=o!==void 0&&p.flowNodeId!==o;if(S||ue||pe||fe)return;let G=await ae(p.flowNodeInstanceId,{identity:a});return r.notification.removeSubscription(u,a),G===null?l(new Error(`UserTask with instance ID "${p.flowNodeInstanceId}" does not exist.`)):c(G)},{identity:a}),y=await oe({correlationId:s,processInstanceId:n,flowNodeId:o,state:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:a});y.userTasks.length>0&&(r.notification.removeSubscription(u,a),c(y.userTasks[0]))})}async function Re(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:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended,...t},c=await r.userTasks.query(a,{identity:o});return(0,f.mapUserTask)(c.userTasks[0])}async function oe(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,f.mapUserTaskList)(s)}async function Ue(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:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},e);return(0,f.mapUserTaskList)(t)}async function Fe(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:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},t);return(0,f.mapUserTaskList)(s)}async function Ae(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:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},t);return(0,f.mapUserTaskList)(s)}async function ae(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:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{...t,limit:1});return s.userTasks.length===0?null:(0,f.mapUserTask)(s.userTasks[0])}async function Me(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:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},t);return(0,f.mapUserTaskList)(s)}async function ve(e,t){let s=e||await i(),n=await r.userTasks.query({state:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:s,...t}),o=n.userTasks.filter(a=>a.actualOwnerId===s.userId);return n.userTasks=o,(0,f.mapUserTaskList)(n)}async function De(e,t,s){await r.userTasks.reserveUserTaskInstance(e,t,s||e.userId)}async function Oe(e,t){await r.userTasks.cancelUserTaskInstanceReservation(e,t)}async function Be(e,t){let s=e||await i(),n=await r.userTasks.query({state:I.DataModels.FlowNodeInstances.FlowNodeInstanceState.suspended},{identity:s,...t}),o=n.userTasks.filter(a=>a.assignedUserIds?.includes(s.userId));return n.userTasks=o,(0,f.mapUserTaskList)(n)}var g=require("next/dist/shared/lib/constants");var ie=!1,L=!1;function Le(e={}){let{applicationSdk:t,...s}=e;return async(n,o)=>{L=L||n===g.PHASE_PRODUCTION_BUILD;let a=n===g.PHASE_DEVELOPMENT_SERVER||n===g.PHASE_PRODUCTION_SERVER;return t?.useExternalTasks&&a&&!ie&&!L&&(ie=!0,await V(t?.customExternalTasksDirPath)),{...s,experimental:{...s.experimental,serverComponentsExternalPackages:[...s.experimental?.serverComponentsExternalPackages||[],"esbuild"]}}}}var ce=require("next/cache"),de=require("next/navigation");function We(e){(0,ce.revalidatePath)(e),(0,de.redirect)(e)}async function qe(...e){return await r.processModels.startProcessInstance(...e)}async function W(...e){await r.manualTasks.finishManualTask(...e)}async function q(...e){await r.userTasks.finishUserTask(...e)}async function K(...e){await r.untypedTasks.finishTask(...e)}var le=require("@5minds/processcube_engine_client");async function Ke(){try{return i()}catch{return}}var Ge=async(e,t)=>{let s=await Ke();t==="bpmn:UserTask"?await q(e,{},s):t==="bpmn:ManualTask"?await W(e,s):t==="bpmn:Task"?await K(e,s):console.error(`[@5minds/processcube_app_sdk:handlePlay] Unsupported flow node type: ${t}`)},Xe=async e=>{await B(e)},$e=async(e,t,s)=>{await O(e,t,s)},je=async e=>A(e),He=async e=>v(e,{sortSettings:{sortBy:le.DataModels.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"DESC"}}),Qe=async e=>D(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,queryFlowNodeInstances,reserveUserTask,retryProcess,retryProcessInstance,startProcess,terminateProcess,terminateProcessInstance,waitForProcessEnd,waitForUserTask,withApplicationSdk});
@@ -1,5 +1,5 @@
1
1
  var Mn=Object.create;var ps=Object.defineProperty;var Un=Object.getOwnPropertyDescriptor;var Bn=Object.getOwnPropertyNames;var Wn=Object.getPrototypeOf,Gn=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 qn=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Bn(e))!Gn.call(t,n)&&n!==s&&ps(t,n,{get:()=>e[n],enumerable:!(r=Un(e,n))||r.enumerable});return t};var Kn=(t,e,s)=>(s=t!=null?Mn(Wn(t)):{},qn(e||!t||!t.__esModule?ps(s,"default",{value:t,enumerable:!0}):s,t));var Ae=x((bc,ms)=>{"use strict";var jn=L("path"),ne="\\\\/",_s=`[^${ne}]`,ie="\\.",Vn="\\+",Yn="\\?",Ue="\\/",zn="(?=.)",gs="[^/]",ut=`(?:${Ue}|$)`,ys=`(?:^|${Ue})`,ft=`${ie}{1,2}${ut}`,Xn=`(?!${ie})`,Qn=`(?!${ys}${ft})`,Zn=`(?!${ie}{0,1}${ut})`,Jn=`(?!${ft})`,ei=`[^.${Ue}]`,ti=`${gs}*?`,Es={DOT_LITERAL:ie,PLUS_LITERAL:Vn,QMARK_LITERAL:Yn,SLASH_LITERAL:Ue,ONE_CHAR:zn,QMARK:gs,END_ANCHOR:ut,DOTS_SLASH:ft,NO_DOT:Xn,NO_DOTS:Qn,NO_DOT_SLASH:Zn,NO_DOTS_SLASH:Jn,QMARK_NO_DOT:ei,STAR:ti,START_ANCHOR:ys},si={...Es,SLASH_LITERAL:`[${ne}]`,QMARK:_s,STAR:`${_s}*?`,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}]|$)`},ri={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"};ms.exports={MAX_LENGTH:1024*64,POSIX_REGEX_SOURCE:ri,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:jn.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?si:Es}}});var Be=x(z=>{"use strict";var ni=L("path"),ii=process.platform==="win32",{REGEX_BACKSLASH:oi,REGEX_REMOVE_BACKSLASH:ai,REGEX_SPECIAL_CHARS:ci,REGEX_SPECIAL_CHARS_GLOBAL:li}=Ae();z.isObject=t=>t!==null&&typeof t=="object"&&!Array.isArray(t);z.hasRegexChars=t=>ci.test(t);z.isRegexChar=t=>t.length===1&&z.hasRegexChars(t);z.escapeRegex=t=>t.replace(li,"\\$1");z.toPosixSlashes=t=>t.replace(oi,"/");z.removeBackslashes=t=>t.replace(ai,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:ii===!0||ni.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 bs=x((kc,Cs)=>{"use strict";var ws=Be(),{CHAR_ASTERISK:dt,CHAR_AT:ui,CHAR_BACKWARD_SLASH:Te,CHAR_COMMA:fi,CHAR_DOT:ht,CHAR_EXCLAMATION_MARK:pt,CHAR_FORWARD_SLASH:Ss,CHAR_LEFT_CURLY_BRACE:_t,CHAR_LEFT_PARENTHESES:gt,CHAR_LEFT_SQUARE_BRACKET:di,CHAR_PLUS:hi,CHAR_QUESTION_MARK:Rs,CHAR_RIGHT_CURLY_BRACE:pi,CHAR_RIGHT_PARENTHESES:As,CHAR_RIGHT_SQUARE_BRACKET:_i}=Ae(),Ts=t=>t===Ss||t===Te,Is=t=>{t.isPrefix!==!0&&(t.depth=t.isGlobstar?1/0:1)},gi=(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,E=!1,y=!1,w=!1,N=!1,D=!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===_t&&(D=!0);continue}if(D===!0||A===_t){for(ce++;G()!==!0&&(A=O());){if(A===Te){Y=b.backslashes=!0,O();continue}if(A===_t){ce++;continue}if(D!==!0&&A===ht&&(A=O())===ht){if(l=b.isBrace=!0,y=b.isGlob=!0,q=!0,n===!0)continue;break}if(D!==!0&&A===fi){if(l=b.isBrace=!0,y=b.isGlob=!0,q=!0,n===!0)continue;break}if(A===pi&&(ce--,ce===0)){D=!1,l=b.isBrace=!0,q=!0;break}}if(n===!0)continue;break}if(A===Ss){if(o.push(f),i.push(b),b={value:"",depth:0,isGlob:!1},q===!0)continue;if(K===ht&&f===u+1){u+=2;continue}d=f+1;continue}if(s.noext!==!0&&(A===hi||A===ui||A===dt||A===Rs||A===pt)===!0&&_()===gt){if(y=b.isGlob=!0,w=b.isExtglob=!0,q=!0,A===pt&&f===u&&(te=!0),n===!0){for(;G()!==!0&&(A=O());){if(A===Te){Y=b.backslashes=!0,A=O();continue}if(A===As){y=b.isGlob=!0,q=!0;break}}continue}break}if(A===dt){if(K===dt&&(N=b.isGlobstar=!0),y=b.isGlob=!0,q=!0,n===!0)continue;break}if(A===Rs){if(y=b.isGlob=!0,q=!0,n===!0)continue;break}if(A===di){for(;G()!==!0&&(j=O());){if(j===Te){Y=b.backslashes=!0,O();continue}if(j===_i){E=b.isBracket=!0,y=b.isGlob=!0,q=!0;break}}if(n===!0)continue;break}if(s.nonegate!==!0&&A===pt&&f===u){$=b.negated=!0,u++;continue}if(s.noparen!==!0&&A===gt){if(y=b.isGlob=!0,n===!0){for(;G()!==!0&&(A=O());){if(A===gt){Y=b.backslashes=!0,A=O();continue}if(A===As){q=!0;break}}continue}break}if(y===!0){if(q=!0,n===!0)continue;break}}s.noext===!0&&(w=!1,y=!1);let v=c,le="",h="";u>0&&(le=c.slice(0,u),c=c.slice(u),d-=u),v&&y===!0&&d>0?(v=c.slice(0,d),h=c.slice(d)):y===!0?(v="",h=c):v=c,v&&v!==""&&v!=="/"&&v!==c&&Ts(v.charCodeAt(v.length-1))&&(v=v.slice(0,-1)),s.unescape===!0&&(h&&(h=ws.removeBackslashes(h)),v&&Y===!0&&(v=ws.removeBackslashes(v)));let p={prefix:le,input:t,start:u,base:v,glob:h,isBrace:l,isBracket:E,isGlob:y,isExtglob:w,isGlobstar:N,negated:$,negatedExtglob:te};if(s.tokens===!0&&(p.maxDepth=0,Ts(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,Is(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,Is(i[i.length-1]),p.maxDepth+=i[i.length-1].depth)}p.slashes=o,p.parts=a}return p};Cs.exports=gi});var Ns=x((Nc,ks)=>{"use strict";var We=Ae(),Q=Be(),{MAX_LENGTH:Ge,POSIX_REGEX_SOURCE:yi,REGEX_NON_SPECIAL_CHARS:Ei,REGEX_SPECIAL_CHARS_BACKREF:mi,REPLACEMENTS:xs}=We,wi=(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},ye=(t,e)=>`Missing ${t}: "${e}" - use "\\\\${e}" to match literal characters`,yt=(t,e)=>{if(typeof t!="string")throw new TypeError("Expected a string");t=xs[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:E,ONE_CHAR:y,DOTS_SLASH:w,NO_DOT:N,NO_DOT_SLASH:D,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?"":N,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=[],v=[],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="",P=0)=>{_.consumed+=m,_.index+=P},Fe=m=>{_.output+=m.output!=null?m.output:m.value,X(m.value)},Dn=()=>{let m=1;for(;C()==="!"&&(C(2)!=="("||C(3)==="?");)se(),_.start++,m++;return m%2===0?!1:(_.negated=!0,_.start++,!0)},De=m=>{_[m]++,le.push(m)},ue=m=>{_[m]--,le.pop()},S=m=>{if(h.type==="globstar"){let P=_.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"&&!P&&!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)&&Fe(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,P)=>{let g={...u[P],conditions:1,inner:""};g.prev=h,g.parens=_.parens,g.output=_.output;let I=(s.capture?"(":"")+g.open;De("parens"),S({type:m,value:P,output:_.output?"":y}),S({type:"paren",extglob:!0,value:se(),output:I}),O.push(g)},$n=m=>{let P=m.close+(s.capture?")":""),g;if(m.type==="negate"){let I=G;if(m.inner&&m.inner.length>1&&m.inner.includes("/")&&(I=K(s)),(I!==G||j()||/^\)+$/.test(re()))&&(P=m.close=`)$))${I}`),m.inner.includes("*")&&(g=re())&&/^\.[^\\/.]+$/.test(g)){let F=yt(g,{...e,fastpaths:!1}).output;P=m.close=`)${F})${I})`}m.prev.type==="bos"&&(_.negatedExtglob=!0)}S({type:"paren",extglob:!0,value:p,output:P}),ue("parens")};if(s.fastpaths!==!1&&!/(^[*!]|[/()[\]{}"])/.test(t)){let m=!1,P=t.replace(mi,(g,I,F,V,U,lt)=>V==="\\"?(m=!0,g):V==="?"?I?I+V+(U?$.repeat(U.length):""):lt===0?b+(U?$.repeat(U.length):""):$.repeat(F.length):V==="."?d.repeat(F.length):V==="*"?I?I+V+(U?G:""):G:I?g:`\\${g}`);return m===!0&&(s.unescape===!0?P=P.replace(/\\/g,""):P=P.replace(/\\+/g,g=>g.length%2===0?"\\\\":g?"\\":"")),P===t&&s.contains===!0?(_.output=t,_):(_.output=Q.wrapOutput(P,_,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+="\\",S({type:"text",value:p});continue}let I=/^\\+/.exec(re()),F=0;if(I&&I[0].length>2&&(F=I[0].length,_.index+=F,F%2!==0&&(p+="\\")),s.unescape===!0?p=se():p+=se(),_.brackets===0){S({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 I=h.value.lastIndexOf("["),F=h.value.slice(0,I),V=h.value.slice(I+2),U=yi[V];if(U){h.value=F+U,_.backtrack=!0,se(),!o.output&&i.indexOf(h)===1&&(o.output=y);continue}}}(p==="["&&C()!==":"||p==="-"&&C()==="]")&&(p=`\\${p}`),p==="]"&&(h.value==="["||h.value==="[^")&&(p=`\\${p}`),s.posix===!0&&p==="!"&&h.value==="["&&(p="^"),h.value+=p,Fe({value:p});continue}if(_.quotes===1&&p!=='"'){p=Q.escapeRegex(p),h.value+=p,Fe({value:p});continue}if(p==='"'){_.quotes=_.quotes===1?0:1,s.keepQuotes===!0&&S({type:"text",value:p});continue}if(p==="("){De("parens"),S({type:"paren",value:p});continue}if(p===")"){if(_.parens===0&&s.strictBrackets===!0)throw new SyntaxError(ye("opening","("));let g=O[O.length-1];if(g&&_.parens===g.parens+1){$n(O.pop());continue}S({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(ye("closing","]"));p=`\\${p}`}else De("brackets");S({type:"bracket",value:p});continue}if(p==="]"){if(s.nobracket===!0||h&&h.type==="bracket"&&h.value.length===1){S({type:"text",value:p,output:`\\${p}`});continue}if(_.brackets===0){if(s.strictBrackets===!0)throw new SyntaxError(ye("opening","["));S({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,Fe({value:p}),s.literalBrackets===!1||Q.hasRegexChars(g))continue;let I=Q.escapeRegex(h.value);if(_.output=_.output.slice(0,-h.value.length),s.literalBrackets===!0){_.output+=I,h.value=I;continue}h.value=`(${a}${I}|${h.value})`,_.output+=h.value;continue}if(p==="{"&&s.nobrace!==!0){De("braces");let g={type:"brace",value:p,output:"(",outputIndex:_.output.length,tokensIndex:_.tokens.length};v.push(g),S(g);continue}if(p==="}"){let g=v[v.length-1];if(s.nobrace===!0||!g){S({type:"text",value:p,output:p});continue}let I=")";if(g.dots===!0){let F=i.slice(),V=[];for(let U=F.length-1;U>=0&&(i.pop(),F[U].type!=="brace");U--)F[U].type!=="dots"&&V.unshift(F[U].value);I=wi(V,s),_.backtrack=!0}if(g.comma!==!0&&g.dots!==!0){let F=_.output.slice(0,g.outputIndex),V=_.tokens.slice(g.tokensIndex);g.value=g.output="\\{",p=I="\\}",_.output=F;for(let U of V)_.output+=U.output||U.value}S({type:"brace",value:p,output:I}),ue("braces"),v.pop();continue}if(p==="|"){O.length>0&&O[O.length-1].conditions++,S({type:"text",value:p});continue}if(p===","){let g=p,I=v[v.length-1];I&&le[le.length-1]==="braces"&&(I.comma=!0,g="|"),S({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}S({type:"slash",value:p,output:E});continue}if(p==="."){if(_.braces>0&&h.type==="dot"){h.value==="."&&(h.output=d);let g=v[v.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"){S({type:"text",value:p,output:d});continue}S({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 I=C(),F=p;if(I==="<"&&!Q.supportsLookbehinds())throw new Error("Node.js v10 or higher is required for regex lookbehinds");(h.value==="("&&!/[!=<:]/.test(I)||I==="<"&&!/<([!=]|\w+>)/.test(re()))&&(F=`\\${p}`),S({type:"text",value:p,output:F});continue}if(s.dot!==!0&&(h.type==="slash"||h.type==="bos")){S({type:"qmark",value:p,output:te});continue}S({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){Dn();continue}}if(p==="+"){if(s.noextglob!==!0&&C()==="("&&C(2)!=="?"){$e("plus",p);continue}if(h&&h.value==="("||s.regex===!1){S({type:"plus",value:p,output:l});continue}if(h&&(h.type==="bracket"||h.type==="paren"||h.type==="brace")||_.parens>0){S({type:"plus",value:p});continue}S({type:"plus",value:l});continue}if(p==="@"){if(s.noextglob!==!0&&C()==="("&&C(2)!=="?"){S({type:"at",extglob:!0,value:p,output:""});continue}S({type:"text",value:p});continue}if(p!=="*"){(p==="$"||p==="^")&&(p=`\\${p}`);let g=Ei.exec(re());g&&(p+=g[0],_.index+=g[0].length),S({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,I=g.prev,F=g.type==="slash"||g.type==="bos",V=I&&(I.type==="star"||I.type==="globstar");if(s.bash===!0&&(!F||m[0]&&m[0]!=="/")){S({type:"star",value:p,output:""});continue}let U=_.braces>0&&(g.type==="comma"||g.type==="brace"),lt=O.length&&(g.type==="pipe"||g.type==="paren");if(!F&&g.type!=="paren"&&!U&&!lt){S({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)}${E}|${E}${Me})`,h.value+=p,_.output+=g.output+h.output,_.globstar=!0,X(p+se()),S({type:"slash",value:"/",output:""});continue}if(g.type==="bos"&&m[0]==="/"){h.type="globstar",h.value+=p,h.output=`(?:^|${E}|${K(s)}${E})`,_.output=h.output,_.globstar=!0,X(p+se()),S({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 P={type:"star",value:p,output:G};if(s.bash===!0){P.output=".*?",(h.type==="bos"||h.type==="slash")&&(P.output=A+P.output),S(P);continue}if(h&&(h.type==="bracket"||h.type==="paren")&&s.regex===!0){P.output=p,S(P);continue}(_.index===_.start||h.type==="slash"||h.type==="dot")&&(h.type==="dot"?(_.output+=D,h.output+=D):s.dot===!0?(_.output+=Y,h.output+=Y):(_.output+=A,h.output+=A),C()!=="*"&&(_.output+=y,h.output+=y)),S(P)}for(;_.brackets>0;){if(s.strictBrackets===!0)throw new SyntaxError(ye("closing","]"));_.output=Q.escapeLast(_.output,"["),ue("brackets")}for(;_.parens>0;){if(s.strictBrackets===!0)throw new SyntaxError(ye("closing",")"));_.output=Q.escapeLast(_.output,"("),ue("parens")}for(;_.braces>0;){if(s.strictBrackets===!0)throw new SyntaxError(ye("closing","}"));_.output=Q.escapeLast(_.output,"{"),ue("braces")}if(s.strictSlashes!==!0&&(h.type==="star"||h.type==="bracket")&&S({type:"maybe_slash",value:"",output:`${E}?`}),_.backtrack===!0){_.output="";for(let m of _.tokens)_.output+=m.output!=null?m.output:m.value,m.suffix&&(_.output+=m.suffix)}return _};yt.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=xs[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:E,START_ANCHOR:y}=We.globChars(o),w=s.dot?d:u,N=s.dot?l:u,D=s.capture?"":"?:",Y={negated:!1,prefix:""},$=s.bash===!0?".*?":E;s.capture&&($=`(${$})`);let te=A=>A.noglobstar===!0?$:`(${D}(?:(?!${y}${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}${N}${$}`;case"**":return w+te(s);case"**/*":return`(?:${w}${te(s)}${a})?${N}${c}${$}`;case"**/*.*":return`(?:${w}${te(s)}${a})?${N}${$}${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};ks.exports=yt});var Ps=x((vc,vs)=>{"use strict";var Ri=L("path"),Ai=bs(),Et=Ns(),mt=Be(),Ti=Ae(),Ii=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 E of u){let y=E(l);if(y)return y}return!1}}let r=Ii(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=mt.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:E,output:y}=M.test(u,i,e,{glob:t,posix:o}),w={glob:t,state:a,regex:i,posix:o,input:u,output:y,match:E,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?mt.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=mt.isWindows(s))=>(e instanceof RegExp?e:M.makeRe(e,s)).test(Ri.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)=>Ai(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=Ti;vs.exports=M});var wt=x((Pc,Os)=>{"use strict";Os.exports=Ps()});var Bs=x((Oc,Us)=>{"use strict";var Se=L("fs"),{Readable:Si}=L("stream"),Ie=L("path"),{promisify:Ve}=L("util"),Rt=wt(),Ci=Ve(Se.readdir),bi=Ve(Se.stat),Ls=Ve(Se.lstat),xi=Ve(Se.realpath),ki="!",$s="READDIRP_RECURSIVE_ERROR",Ni=new Set(["ENOENT","EPERM","EACCES","ELOOP",$s]),At="files",Ms="directories",Ke="files_directories",qe="all",Hs=[At,Ms,Ke,qe],vi=t=>Ni.has(t.code),[Fs,Pi]=process.versions.node.split(".").slice(0,2).map(t=>Number.parseInt(t,10)),Oi=process.platform==="win32"&&(Fs>10||Fs===10&&Pi>=5),Ds=t=>{if(t!==void 0){if(typeof t=="function")return t;if(typeof t=="string"){let e=Rt(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)===ki?s.push(Rt(n.slice(1))):e.push(Rt(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 Si{static get defaultOptions(){return{root:".",fileFilter:e=>!0,directoryFilter:e=>!0,type:At,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=Ds(s.fileFilter),this._directoryFilter=Ds(s.directoryFilter);let o=s.lstat?Ls:bi;Oi?this._stat=i=>o(i,{bigint:!0}):this._stat=o,this._maxDepth=s.depth,this._wantsDir=[Ms,Ke,qe].includes(n),this._wantsFile=[At,Ke,qe].includes(n),this._wantsEverything=n===qe,this._root=Ie.resolve(r),this._isDirent="Dirent"in Se&&!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 Ci(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=Ie.resolve(Ie.join(s,n));r={path:Ie.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){vi(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 xi(r),o=await Ls(n);if(o.isFile())return"file";if(o.isDirectory()){let i=n.length;if(r.startsWith(n)&&r.substr(i,1)===Ie.sep){let a=new Error(`Circular symlink detected: "${r}" points to "${n}"`);return a.code=$s,this._onError(a)}return"directory"}}catch(n){this._onError(n)}}}}_includeAsFile(e){let s=e&&e[this._statsProp];return s&&this._wantsEverything&&!s.isDirectory()}},Ee=(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&&!Hs.includes(s))throw new Error(`readdirp: Invalid type passed. Use one of ${Hs.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return e.root=t,new je(e)},Li=(t,e={})=>new Promise((s,r)=>{let n=[];Ee(t,e).on("data",o=>n.push(o)).on("end",()=>s(n)).on("error",o=>r(o))});Ee.promise=Li;Ee.ReaddirpStream=je;Ee.default=Ee;Us.exports=Ee});var Tt=x((Lc,Ws)=>{Ws.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 Ys=x((js,Vs)=>{"use strict";Object.defineProperty(js,"__esModule",{value:!0});var Ks=wt(),Hi=Tt(),Gs="!",Fi={returnIndex:!1},Di=t=>Array.isArray(t)?t:[t],$i=(t,e)=>{if(typeof t=="function")return t;if(typeof t=="string"){let s=Ks(t,e);return r=>t===r||s(r)}return t instanceof RegExp?s=>t.test(s):s=>!1},qs=(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=Hi(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},It=(t,e,s=Fi)=>{if(t==null)throw new TypeError("anymatch: specify first argument");let r=typeof s=="boolean"?{returnIndex:s}:s,n=r.returnIndex||!1,o=Di(t),i=o.filter(c=>typeof c=="string"&&c.charAt(0)===Gs).map(c=>c.slice(1)).map(c=>Ks(c,r)),a=o.filter(c=>typeof c!="string"||typeof c=="string"&&c.charAt(0)!==Gs).map(c=>$i(c,r));return e==null?(c,f=!1)=>qs(a,i,c,typeof f=="boolean"?f:!1):qs(a,i,e,n)};It.default=It;Vs.exports=It});var Xs=x((Hc,zs)=>{zs.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((Fc,Zs)=>{var Mi=Xs(),Qs={"{":"}","(":")","[":"]"},Ui=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=Qs[a];if(c){var f=t.indexOf(c,e);f!==-1&&(e=f+1)}if(t[e]==="!")return!0}else e++}return!1},Bi=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=Qs[s];if(r){var n=t.indexOf(r,e);n!==-1&&(e=n+1)}if(t[e]==="!")return!0}else e++}return!1};Zs.exports=function(e,s){if(typeof e!="string"||e==="")return!1;if(Mi(e))return!0;var r=Ui;return s&&s.strict===!1&&(r=Bi),r(e)}});var er=x((Dc,Js)=>{"use strict";var Wi=St(),Gi=L("path").posix.dirname,qi=L("os").platform()==="win32",Ct="/",Ki=/\\/g,ji=/[\{\[].*[\}\]]$/,Vi=/(^|[^\\])([\{\[]|\([^\)]+$)/,Yi=/\\([\!\*\?\|\[\]\(\)\{\}])/g;Js.exports=function(e,s){var r=Object.assign({flipBackslashes:!0},s);r.flipBackslashes&&qi&&e.indexOf(Ct)<0&&(e=e.replace(Ki,Ct)),ji.test(e)&&(e+=Ct),e+="a";do e=Gi(e);while(Wi(e)||Vi.test(e));return e.replace(Yi,"$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((Mc,sr)=>{"use strict";var tr=Ye();sr.exports=(t,e={})=>{let s=(r,n={})=>{let o=e.escapeInvalid&&tr.isInvalidBrace(n),i=r.invalid===!0&&e.escapeInvalid===!0,a="";if(r.value)return(o||i)&&tr.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 nr=x((Uc,rr)=>{"use strict";rr.exports=function(t){return typeof t=="number"?t-t===0:typeof t=="string"&&t.trim()!==""?Number.isFinite?Number.isFinite(+t):isFinite(+t):!1}});var hr=x((Bc,dr)=>{"use strict";var ir=nr(),fe=(t,e,s)=>{if(ir(t)===!1)throw new TypeError("toRegexRange: expected the first argument to be a number");if(e===void 0||t===e)return String(t);if(ir(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=fr(t)||fr(e),l={min:t,max:e,a:f,b:u},E=[],y=[];if(d&&(l.isPadded=d,l.maxLen=String(l.max).length),f<0){let w=u<0?Math.abs(u):1;y=or(w,Math.abs(f),l,r),f=l.a=0}return u>=0&&(E=or(f,u,l,r)),l.negatives=y,l.positives=E,l.result=zi(y,E,r),r.capture===!0?l.result=`(${l.result})`:r.wrap!==!1&&E.length+y.length>1&&(l.result=`(?:${l.result})`),fe.cache[c]=l,l.result};function zi(t,e,s){let r=bt(t,e,"-",!1,s)||[],n=bt(e,t,"",!1,s)||[],o=bt(t,e,"-?",!0,s)||[];return r.concat(o).concat(n).join("|")}function Xi(t,e){let s=1,r=1,n=cr(t,s),o=new Set([e]);for(;t<=n&&n<=e;)o.add(n),s+=1,n=cr(t,s);for(n=lr(e+1,r)-1;t<n&&n<=e;)o.add(n),r+=1,n=lr(e+1,r)-1;return o=[...o],o.sort(Ji),o}function Qi(t,e,s){if(t===e)return{pattern:t,count:[],digits:0};let r=Zi(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+=eo(c,f,s):i++}return i&&(o+=s.shorthand===!0?"\\d":"[0-9]"),{pattern:o,count:[i],digits:n}}function or(t,e,s,r){let n=Xi(t,e),o=[],i=t,a;for(let c=0;c<n.length;c++){let f=n[c],u=Qi(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+ur(a.count),i=f+1;continue}s.isPadded&&(d=to(f,s,r)),u.string=d+u.pattern+ur(u.count),o.push(u),i=f+1,a=u}return o}function bt(t,e,s,r,n){let o=[];for(let i of t){let{string:a}=i;!r&&!ar(e,"string",a)&&o.push(s+a),r&&ar(e,"string",a)&&o.push(s+a)}return o}function Zi(t,e){let s=[];for(let r=0;r<t.length;r++)s.push([t[r],e[r]]);return s}function Ji(t,e){return t>e?1:e>t?-1:0}function ar(t,e,s){return t.some(r=>r[e]===s)}function cr(t,e){return Number(String(t).slice(0,-e)+"9".repeat(e))}function lr(t,e){return t-t%Math.pow(10,e)}function ur(t){let[e=0,s=""]=t;return s||e>1?`{${e+(s?","+s:"")}}`:""}function eo(t,e,s){return`[${t}${e-t===1?"":"-"}${e}]`}function fr(t){return/^-?(0+)\d/.test(t)}function to(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={};dr.exports=fe});var Nt=x((Wc,wr)=>{"use strict";var so=L("util"),_r=hr(),pr=t=>t!==null&&typeof t=="object"&&!Array.isArray(t),ro=t=>e=>t===!0?Number(e):String(e),xt=t=>typeof t=="number"||typeof t=="string"&&t!=="",Ce=t=>Number.isInteger(+t),kt=t=>{let e=`${t}`,s=-1;if(e[0]==="-"&&(e=e.slice(1)),e==="0")return!1;for(;e[++s]==="0";);return s>0},no=(t,e,s)=>typeof t=="string"||typeof e=="string"?!0:s.stringify===!0,io=(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},oo=(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},gr=(t,e,s,r)=>{if(s)return _r(t,e,{wrap:!1,...r});let n=String.fromCharCode(t);if(t===e)return n;let o=String.fromCharCode(e);return`[${n}-${o}]`},yr=(t,e,s)=>{if(Array.isArray(t)){let r=s.wrap===!0,n=s.capture?"":"?:";return r?`(${n}${t.join("|")})`:t.join("|")}return _r(t,e,s)},Er=(...t)=>new RangeError("Invalid range arguments: "+so.inspect(...t)),mr=(t,e,s)=>{if(s.strictRanges===!0)throw Er([t,e]);return[]},ao=(t,e)=>{if(e.strictRanges===!0)throw new TypeError(`Expected step "${t}" to be a number`);return[]},co=(t,e,s=1,r={})=>{let n=Number(t),o=Number(e);if(!Number.isInteger(n)||!Number.isInteger(o)){if(r.strictRanges===!0)throw Er([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=kt(a)||kt(c)||kt(f),d=u?Math.max(a.length,c.length,f.length):0,l=u===!1&&no(t,e,r)===!1,E=r.transform||ro(l);if(r.toRegex&&s===1)return gr(Qe(t,d),Qe(e,d),!0,r);let y={negatives:[],positives:[]},w=Y=>y[Y<0?"negatives":"positives"].push(Math.abs(Y)),N=[],D=0;for(;i?n>=o:n<=o;)r.toRegex===!0&&s>1?w(n):N.push(io(E(n,D),d,l)),n=i?n-s:n+s,D++;return r.toRegex===!0?s>1?oo(y,r,d):yr(N,null,{wrap:!1,...r}):N},lo=(t,e,s=1,r={})=>{if(!Ce(t)&&t.length>1||!Ce(e)&&e.length>1)return mr(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 gr(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?yr(u,null,{wrap:!1,options:r}):u},Xe=(t,e,s,r={})=>{if(e==null&&xt(t))return[t];if(!xt(t)||!xt(e))return mr(t,e,r);if(typeof s=="function")return Xe(t,e,1,{transform:s});if(pr(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)?co(t,e,s,n):lo(t,e,Math.max(Math.abs(s),1),n):s!=null&&!pr(s)?ao(s,n):Xe(t,e,1,s)};wr.exports=Xe});var Tr=x((Gc,Ar)=>{"use strict";var uo=Nt(),Rr=Ye(),fo=(t,e={})=>{let s=(r,n={})=>{let o=Rr.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=Rr.reduce(r.nodes),d=uo(...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)};Ar.exports=fo});var Cr=x((qc,Sr)=>{"use strict";var ho=Nt(),Ir=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)},po=(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(),Ir(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=ho(...d,e);l.length===0&&(l=Ir(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))};Sr.exports=po});var xr=x((Kc,br)=>{"use strict";br.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 Or=x((jc,Pr)=>{"use strict";var _o=ze(),{MAX_LENGTH:kr,CHAR_BACKSLASH:vt,CHAR_BACKTICK:go,CHAR_COMMA:yo,CHAR_DOT:Eo,CHAR_LEFT_PARENTHESES:mo,CHAR_RIGHT_PARENTHESES:wo,CHAR_LEFT_CURLY_BRACE:Ro,CHAR_RIGHT_CURLY_BRACE:Ao,CHAR_LEFT_SQUARE_BRACKET:Nr,CHAR_RIGHT_SQUARE_BRACKET:vr,CHAR_DOUBLE_QUOTE:To,CHAR_SINGLE_QUOTE:Io,CHAR_NO_BREAK_SPACE:So,CHAR_ZERO_WIDTH_NOBREAK_SPACE:Co}=xr(),bo=(t,e={})=>{if(typeof t!="string")throw new TypeError("Expected a string");let s=e||{},r=typeof s.maxLength=="number"?Math.min(kr,s.maxLength):kr;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,E=()=>t[u++],y=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(y({type:"bos"});u<f;)if(i=o[o.length-1],l=E(),!(l===Co||l===So)){if(l===vt){y({type:"text",value:(e.keepEscaping?l:"")+E()});continue}if(l===vr){y({type:"text",value:"\\"+l});continue}if(l===Nr){c++;let w;for(;u<f&&(w=E());){if(l+=w,w===Nr){c++;continue}if(w===vt){l+=E();continue}if(w===vr&&(c--,c===0))break}y({type:"text",value:l});continue}if(l===mo){i=y({type:"paren",nodes:[]}),o.push(i),y({type:"text",value:l});continue}if(l===wo){if(i.type!=="paren"){y({type:"text",value:l});continue}i=o.pop(),y({type:"text",value:l}),i=o[o.length-1];continue}if(l===To||l===Io||l===go){let w=l,N;for(e.keepQuotes!==!0&&(l="");u<f&&(N=E());){if(N===vt){l+=N+E();continue}if(N===w){e.keepQuotes===!0&&(l+=N);break}l+=N}y({type:"text",value:l});continue}if(l===Ro){d++;let N={type:"brace",open:!0,close:!1,dollar:a.value&&a.value.slice(-1)==="$"||i.dollar===!0,depth:d,commas:0,ranges:0,nodes:[]};i=y(N),o.push(i),y({type:"open",value:l});continue}if(l===Ao){if(i.type!=="brace"){y({type:"text",value:l});continue}let w="close";i=o.pop(),i.close=!0,y({type:w,value:l}),d--,i=o[o.length-1];continue}if(l===yo&&d>0){if(i.ranges>0){i.ranges=0;let w=i.nodes.shift();i.nodes=[w,{type:"text",value:_o(i)}]}y({type:"comma",value:l}),i.commas++;continue}if(l===Eo&&d>0&&i.commas===0){let w=i.nodes;if(d===0||w.length===0){y({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 N=w[w.length-1];N.value+=a.value+l,a=N,i.ranges--;continue}y({type:"dot",value:l});continue}y({type:"text",value:l})}do if(i=o.pop(),i.type!=="root"){i.nodes.forEach(D=>{D.nodes||(D.type==="open"&&(D.isOpen=!0),D.type==="close"&&(D.isClose=!0),D.nodes||(D.type="text"),D.invalid=!0)});let w=o[o.length-1],N=w.nodes.indexOf(i);w.nodes.splice(N,1,...i.nodes)}while(o.length>0);return y({type:"eos"}),n};Pr.exports=bo});var Fr=x((Vc,Hr)=>{"use strict";var Lr=ze(),xo=Tr(),ko=Cr(),No=Or(),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={})=>No(t,e);Z.stringify=(t,e={})=>Lr(typeof t=="string"?Z.parse(t,e):t,e);Z.compile=(t,e={})=>(typeof t=="string"&&(t=Z.parse(t,e)),xo(t,e));Z.expand=(t,e={})=>{typeof t=="string"&&(t=Z.parse(t,e));let s=ko(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);Hr.exports=Z});var Dr=x((Yc,vo)=>{vo.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 Mr=x((zc,$r)=>{$r.exports=Dr()});var Br=x((Xc,Ur)=>{"use strict";var Po=L("path"),Oo=Mr(),Lo=new Set(Oo);Ur.exports=t=>Lo.has(Po.extname(t).slice(1).toLowerCase())});var Ze=x(R=>{"use strict";var{sep:Ho}=L("path"),{platform:Pt}=process,Fo=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=`.${Ho}`;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=Fo.type()==="OS400"});var Vr=x((Zc,jr)=>{"use strict";var oe=L("fs"),B=L("path"),{promisify:Ne}=L("util"),Do=Br(),{isWindows:$o,isLinux:Mo,EMPTY_FN:Uo,EMPTY_STR:Bo,KEY_LISTENERS:we,KEY_ERR:Ot,KEY_RAW:be,HANDLER_KEYS:Wo,EV_CHANGE:et,EV_ADD:Je,EV_ADD_DIR:Go,EV_ERROR:Gr,STR_DATA:qo,STR_END:Ko,BRACE_START:jo,STAR:Vo}=Ze(),Yo="watch",zo=Ne(oe.open),qr=Ne(oe.stat),Xo=Ne(oe.lstat),Qo=Ne(oe.close),Lt=Ne(oe.realpath),Zo={lstat:Xo,stat:qr},Ft=(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)},Jo=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]},Kr=t=>t instanceof Set?t.size===0:!t,tt=new Map;function Wr(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&&Ft(o[e],i=>{i(s,r,n)})},ea=(t,e,s,r)=>{let{listener:n,errHandler:o,rawEmitter:i}=r,a=tt.get(e),c;if(!s.persistent)return c=Wr(t,s,n,o,i),c.close.bind(c);if(a)xe(a,we,n),xe(a,Ot,o),xe(a,be,i);else{if(c=Wr(t,s,st.bind(null,e,we),o,st.bind(null,e,be)),!c)return;c.on(Gr,async f=>{let u=st.bind(null,e,Ot);if(a.watcherUnusable=!0,$o&&f.code==="EPERM")try{let d=await zo(t,"r");await Qo(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,Ot,o),ke(a,be,i),Kr(a.listeners)&&(a.watcher.close(),tt.delete(e),Wo.forEach(Jo(a)),a.watcher=void 0,Object.freeze(a))}},Ht=new Map,ta=(t,e,s,r)=>{let{listener:n,rawEmitter:o}=r,i=Ht.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)=>{Ft(i.rawEmitters,E=>{E(et,e,{curr:u,prev:d})});let l=u.mtimeMs;(u.size!==d.size||l>d.mtimeMs||l===0)&&Ft(i.listeners,E=>E(t,u))})},Ht.set(e,i)),()=>{ke(i,we,n),ke(i,be,o),Kr(i.listeners)&&(Ht.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=Uo);let f;return r.usePolling?(c.interval=r.enableBinaryInterval&&Do(o)?r.binaryInterval:r.interval,f=ta(e,a,c,{listener:s,rawEmitter:this.fsw._emitRaw})):f=ea(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(Yo,e,5)){if(!d||d.mtimeMs===0)try{let l=await qr(e);if(this.fsw.closed)return;let E=l.atimeMs,y=l.mtimeMs;(!E||E<=y||y!==a.mtimeMs)&&this.fsw._emit(et,e,l),Mo&&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,E=d.mtimeMs;(!l||l<=E||E!==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 Lt(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,Bo),!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(qo,async d=>{if(this.fsw.closed){u=void 0;return}let l=d.path,E=B.join(e,l);if(f.add(l),!(d.stats.isSymbolicLink()&&await this._handleSymlink(d,e,E,l))){if(this.fsw.closed){u=void 0;return}(l===n||!n&&!c.has(l))&&(this.fsw._incrReadyCount(),E=B.join(o,B.relative(o,E)),this._addToNodeFs(E,s,r,i+1))}}).on(Gr,this._boundHandleError);return new Promise(d=>u.once(Ko,()=>{if(this.fsw.closed){u=void 0;return}let l=a?a.clear():!1;d(),c.getChildren().filter(E=>E!==e&&!f.has(E)&&(!r.hasGlob||r.filterPath({fullPath:B.resolve(e,E)}))).forEach(E=>{this.fsw._remove(e,E)}),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(Go,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,(E,y)=>{y&&y.mtimeMs===0||this._handleRead(E,!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 Zo[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(Vo)&&!e.includes(jo),u;if(c.isDirectory()){let d=B.resolve(e),l=f?await Lt(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 Lt(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}}};jr.exports=Dt});var en=x((Jc,Kt)=>{"use strict";var Gt=L("fs"),W=L("path"),{promisify:qt}=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:$t,EV_CHANGE:sa,EV_ADD_DIR:Yr,EV_UNLINK:rt,EV_ERROR:ra,STR_DATA:na,STR_END:ia,FSEVENT_CREATED:oa,FSEVENT_MODIFIED:aa,FSEVENT_DELETED:ca,FSEVENT_MOVED:la,FSEVENT_UNKNOWN:ua,FSEVENT_FLAG_MUST_SCAN_SUBDIRS:fa,FSEVENT_TYPE_FILE:da,FSEVENT_TYPE_DIRECTORY:ve,FSEVENT_TYPE_SYMLINK:Jr,ROOT_GLOBSTAR:zr,DIR_SUFFIX:ha,DOT_SLASH:Xr,FUNCTION_TYPE:Mt,EMPTY_FN:pa,IDENTITY_FN:_a}=Ze(),ga=t=>isNaN(t)?{}:{depth:t},Bt=qt(Gt.stat),ya=qt(Gt.lstat),Qr=qt(Gt.realpath),Ea={stat:Bt,lstat:ya},he=new Map,ma=10,wa=new Set([69888,70400,71424,72704,73472,131328,131840,262912]),Ra=(t,e)=>({stop:Re.watch(t,e)});function Aa(t,e,s,r){let n=W.extname(e)?W.dirname(e):e,o=W.dirname(n),i=he.get(n);Ta(o)&&(n=o);let a=W.resolve(t),c=a!==e,f=(d,l,E)=>{c&&(d=d.replace(e,a)),(d===a||!d.indexOf(a+W.sep))&&s(d,l,E)},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:Ra(n,(d,l)=>{if(!i.listeners.size||l&fa)return;let E=Re.getInfo(d,l);i.listeners.forEach(y=>{y(d,l,E)}),i.rawEmitter(E.event,d,E)})},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 Ta=t=>{let e=0;for(let s of he.keys())if(s.indexOf(t)===0&&(e++,e>=ma))return!0;return!1},Ia=()=>Re&&he.size<128,Ut=(t,e)=>{let s=0;for(;!t.indexOf(e)&&(t=W.dirname(t))!==e;)s++;return s},Zr=(t,e)=>t.type===ve&&e.isDirectory()||t.type===Jr&&e.isSymbolicLink()||t.type===da&&e.isFile(),Wt=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+zr),!0;r.delete(e),r.delete(e+zr)}addOrChange(e,s,r,n,o,i,a,c){let f=o.has(i)?sa:$t;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 Bt(e);if(this.fsw.closed)return;Zr(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===ve;(u||i.has(a))&&this.fsw._remove(o,a,u)}else{if(e===$t){if(c.type===ve&&this.fsw._getWatchedDir(s),c.type===Jr&&f.followSymlinks){let d=f.depth===void 0?void 0:Ut(r,n)+1;return this._addToFsEvents(s,!1,!0,d)}this.fsw._getWatchedDir(o).add(a)}let u=c.type===ve?e+ha:e;this.fsw._emit(u,s),u===Yr&&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=Aa(e,s,async(c,f,u)=>{if(this.fsw.closed||o.depth!==void 0&&Ut(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),E=W.basename(d),y=this.fsw._getWatchedDir(u.type===ve?d:l);if(wa.has(f)||u.event===ua)if(typeof o.ignored===Mt){let w;try{w=await Bt(d)}catch{}if(this.fsw.closed||this.checkIgnored(d,w))return;Zr(u,w)?this.addOrChange(d,c,s,l,y,E,u,o):this.handleEvent(rt,d,c,s,l,y,E,u,o)}else this.checkExists(d,c,s,l,y,E,u,o);else switch(u.event){case oa:case aa:return this.addOrChange(d,c,s,l,y,E,u,o);case ca:case la:return this.checkExists(d,c,s,l,y,E,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 Qr(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!==Xr?a=i.replace(o,e):i!==Xr&&(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?Yr:$t,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===Mt?s:_a,a=this.fsw._getWatchHelpers(e);try{let c=await Ea[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),...ga(o.depth-(n||0))}).on(na,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:Ut(u,W.resolve(a.watchPath))+1;this._handleFsEventsSymlink(u,d,i,l)}else this.emitAdd(u,f.stats,i,o,r)}).on(ra,pa).on(ia,()=>{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===Mt)this.initWatch(void 0,e,a,i);else{let c;try{c=await Qr(a.watchPath)}catch{}this.initWatch(c,e,a,i)}}};Kt.exports=Wt;Kt.exports.canUse=Ia});var dn=x(os=>{"use strict";var{EventEmitter:Sa}=L("events"),ns=L("fs"),k=L("path"),{promisify:cn}=L("util"),Ca=Bs(),Qt=Ys().default,ba=er(),jt=St(),xa=Fr(),ka=Tt(),Na=Vr(),tn=en(),{EV_ALL:Vt,EV_READY:va,EV_ADD:nt,EV_CHANGE:Pe,EV_UNLINK:sn,EV_ADD_DIR:Pa,EV_UNLINK_DIR:Oa,EV_RAW:La,EV_ERROR:Yt,STR_CLOSE:Ha,STR_END:Fa,BACK_SLASH_RE:Da,DOUBLE_SLASH_RE:rn,SLASH_OR_BACK_SLASH_RE:$a,DOT_RE:Ma,REPLACER_RE:Ua,SLASH:zt,SLASH_SLASH:Ba,BRACE_START:Wa,BANG:Zt,ONE_DOT:ln,TWO_DOTS:Ga,GLOBSTAR:qa,SLASH_GLOBSTAR:Xt,ANYMATCH_OPTS:Jt,STRING_TYPE:is,FUNCTION_TYPE:Ka,EMPTY_STR:es,EMPTY_FN:ja,isWindows:Va,isMacos:Ya,isIBMi:za}=Ze(),Xa=cn(ns.stat),Qa=cn(ns.readdir),ts=(t=[])=>Array.isArray(t)?t:[t],un=(t,e=[])=>(t.forEach(s=>{Array.isArray(s)?un(s,e):e.push(s)}),e),nn=t=>{let e=un(ts(t));if(!e.every(s=>typeof s===is))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(fn)},on=t=>{let e=t.replace(Da,zt),s=!1;for(e.startsWith(Ba)&&(s=!0);e.match(rn);)e=e.replace(rn,zt);return s&&(e=zt+e),e},fn=t=>on(k.normalize(on(t))),an=(t=es)=>e=>typeof e!==is?e:fn(k.isAbsolute(e)?e:k.join(t,e)),Za=(t,e)=>k.isAbsolute(t)?t:t.startsWith(Zt)?Zt+k.join(e,t.slice(1)):k.join(e,t),ee=(t,e)=>t[e]===void 0,ss=class{constructor(e,s){this.path=e,this._removeWatcher=s,this.items=new Set}add(e){let{items:s}=this;s&&e!==ln&&e!==Ga&&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 Qa(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)}},Ja="stat",ec="lstat",rs=class{constructor(e,s,r,n){this.fsw=n,this.path=e=e.replace(Ua,es),this.watchPath=s,this.fullWatchPath=k.resolve(s),this.hasGlob=s!==e,e===es&&(this.hasGlob=!1),this.globSymlink=this.hasGlob&&r?void 0:!1,this.globFilter=this.hasGlob?Qt(e,void 0,Jt):!1,this.dirParts=this.getDirParts(e),this.dirParts.forEach(o=>{o.length>1&&o.pop()}),this.followSymlinks=r,this.statMethod=r?Ja:ec}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===Ka?this.globFilter(r):!0)&&this.fsw._isntIgnored(r,s)&&this.fsw._hasReadPermissions(s)}getDirParts(e){if(!this.hasGlob)return[];let s=[];return(e.includes(Wa)?xa.expand(e):[e]).forEach(n=>{s.push(k.relative(this.watchPath,n).split($a))}),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===qa&&(r=!0),r||!s[0][i]||Qt(o,s[0][i],Jt))))}return!this.unmatchedGlob&&this.fsw._isntIgnored(this.entryPath(e),e.stats)}},it=class extends Sa{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),tn.canUse()||(s.useFsEvents=!1),ee(s,"usePolling")&&!s.useFsEvents&&(s.usePolling=Ya),za&&(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=ts(s.ignored));let a=0;this._emitReady=()=>{a++,a>=this._readyCount&&(this._emitReady=ja,this._readyEmitted=!0,process.nextTick(()=>this.emit(va)))},this._emitRaw=(...c)=>this.emit(La,...c),this._readyEmitted=!1,this.options=s,s.useFsEvents?this._fsEventsHandler=new tn(this):this._nodeFsHandler=new Na(this),Object.freeze(s)}add(e,s,r){let{cwd:n,disableGlobbing:o}=this.options;this.closed=!1;let i=nn(e);return n&&(i=i.map(a=>{let c=Za(a,n);return o||!jt(a)?c:ka(c)})),i=i.filter(a=>a.startsWith(Zt)?(this._ignoredPaths.add(a.slice(1)),!1):(this._ignoredPaths.delete(a),this._ignoredPaths.delete(a+Xt),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=nn(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+Xt),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||ln]=s.getChildren().sort()}),e}emitWithAll(e,s){this.emit(...s),e!==Yt&&this.emit(Vt,...s)}async _emit(e,s,r,n,o){if(this.closed)return;let i=this.options;Va&&(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===sn)return this._pendingUnlinks.set(s,a),setTimeout(()=>{this._pendingUnlinks.forEach((u,d)=>{this.emit(...u),this.emit(Vt,...u),this._pendingUnlinks.delete(d)})},typeof i.atomic=="number"?i.atomic:100),this;e===nt&&this._pendingUnlinks.has(s)&&(e=a[0]=Pe,this._pendingUnlinks.delete(s))}if(c&&(e===nt||e===Pe)&&this._readyEmitted){let u=(d,l)=>{d?(e=a[0]=Yt,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===Pe&&!this._throttle(Pe,s,50))return this;if(i.alwaysStat&&r===void 0&&(e===nt||e===Pa||e===Pe)){let u=i.cwd?k.join(i.cwd,s):s,d;try{d=await Xa(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(Yt,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=>{ns.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 E=this._pendingWrites.get(e);l-E.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&&Ma.test(e))return!0;if(!this._userIgnored){let{cwd:r}=this.options,n=this.options.ignored,o=n&&n.map(an(r)),i=ts(o).filter(c=>typeof c===is&&!jt(c)).map(c=>c+Xt),a=this._getGlobIgnored().map(an(r)).concat(o,i);this._userIgnored=Qt(a,void 0,Jt)}return this._userIgnored([e,s])}_isntIgnored(e,s){return!this._isIgnored(e,s)}_getWatchHelpers(e,s){let r=s||this.options.disableGlobbing||!jt(e)?e:ba(e),n=this.options.followSymlinks;return new rs(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 ss(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?Oa:sn;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:Vt,alwaysStat:!0,lstat:!0,...s},n=Ca(e,r);return this._streams.add(n),n.once(Ha,()=>{n=void 0}),n.once(Fa,()=>{n&&(this._streams.delete(n),n=void 0)}),n}};os.FSWatcher=it;var tc=(t,e)=>{let s=new it(e);return s.add(t),s};os.watch=tc});import"only-server";import"../common/index.mjs";var _n=Kn(dn(),1);import{fork as rc}from"node:child_process";import{existsSync as hn,promises as nc}from"node:fs";import{basename as cs,dirname as us,join as ls,relative as pn}from"node:path";import{build as ic}from"esbuild";import{jwtDecode as oc}from"jwt-decode";import{Issuer as ac,custom as cc}from"openid-client";import{Logger as lc}from"@5minds/processcube_engine_sdk";import{EngineClient as sc}from"@5minds/processcube_engine_client";var as=process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560",T=new sc(as);var uc={token:"ZHVtbXlfdG9rZW4=",userId:"dummy_token"},fc=.85,ot=["external_task.ts","external_task.js"],fs=process.env.PROCESSCUBE_AUTHORITY_URL!==void 0,_e=new lc("processcube_app_sdk:external_task_adapter"),pe={},Oe;async function gn(t){if(t&&!hn(t))throw new Error(`Invalid customExternalTasksDirPath. The given path '${t}' does not exist`);cc.setHttpOptionsDefaults({timeout:1e5});let e=await mn();Oe=await wn(e),await hc(e);let s=_c(t);(0,_n.watch)(s).on("add",async r=>{if(ot.includes(cs(r)))return yn(r,s)}).on("change",async r=>{if(ot.includes(cs(r)))return dc(r,s)}).on("unlink",async r=>{ot.includes(cs(r))&&En(r)}).on("error",r=>_e.error(`Watcher error: ${r}`))}async function yn(t,e){let s=us(t);if((await nc.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]&&En(t);return}let o=await Rn(t),i=pn(e,s),a=An(i),c=ls(__dirname,"lib/ExternalTaskWorkerProcess.cjs"),f=rc(c,{env:{...process.env,PROCESSCUBE_ENGINE_URL:as}});pe[s]=f,f.once("disconnect",()=>{delete pe[s]}),f.send({action:"create",payload:{topic:a,identity:Oe,moduleString:o,workerPath:t}})}async function dc(t,e){let s=us(t),r=pe[s];if(!r)return yn(t,e);let n=await Rn(t),o=pn(e,s),i=An(o);r.send({action:"restart",payload:{topic:i,identity:Oe,moduleString:n,workerPath:t}})}function En(t){let e=us(t),s=pe[e];s&&s.kill()}async function mn(){if(!fs)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 ac.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 wn(t){if(!fs||t===null)return uc;let e=t.access_token,s=oc(e);return{token:t.access_token,userId:s.sub}}async function hc(t){let e=5;if(!fs||t===null)return;let r=await pc(t)*fc*1e3,n=async()=>{try{let o=await mn();Oe=wn(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 Rn(t){let e=await ic({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 pc(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 An(t){return t.replace(/^\.\/+|\([^)]+\)|^\/*|\/*$/g,"").replace(/[\/]{2,}/g,"/")}function _c(t){let e,s=[t,ls(process.cwd(),"app"),ls(process.cwd(),"src","app")];for(let r of s)if(r&&hn(r)){e=r;break}if(!e)throw new Error("Could not find external tasks directory");return e}function gl(){return T}import{getToken as Tn}from"next-auth/jwt";import{ResponseCookies as gc}from"next/dist/compiled/@edge-runtime/cookies";import{cookies as at,headers as In}from"next/headers";async function H(){let t=await Tn({req:{cookies:at(),headers:In()}});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 gc(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 Tn({req:{cookies:n?r:at(),headers:In()}}),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";var ct=300,ds=1e3;async function He(){try{return H()}catch{return}}async function Cn(t){let e=await He();return(await T.processInstances.query({processInstanceId:t},{identity:e})).processInstances[0]}async function bn(t,e){let{processInstanceId:s,flowNodeInstanceId:r}=t,n=r;if(!s&&!n)return[];let o=[];return n&&n.length>ct?await Promise.all(new Array(Math.ceil(n.length/ct)).fill(null).map(async(i,a)=>{let c=await Sn({flowNodeInstanceId:n.slice(a*ct,(a+1)*ct)},{...e,identity:e?.identity??await He()});o.push(...c)})):o.push(...await Sn({processInstanceId:s,flowNodeInstanceId:n},{...e,identity:e?.identity??await He()})),o}async function xn(t,e={sortSettings:{sortBy:Le.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"ASC"}}){return await bn({processInstanceId:t},e)}async function kn(t){return await bn({triggeredByFlowNodeInstance:t})}async function Nn(t,e,s){let r=await He();await T.processInstances.retryProcessInstance(t,{flowNodeInstanceId:e,newStartToken:s,identity:r})}async function vn(t){let e=await He();await T.processInstances.terminateProcessInstance(t,e)}async function Sl(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 Cl(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])}}})}async function Sn(t,e){let s=[],r=await T.flowNodeInstances.query(t,{...e,limit:ds});if(s.push(...r.flowNodeInstances),r.flowNodeInstances.length!==r.totalCount){let n=Math.floor(r.totalCount/r.flowNodeInstances.length);await Promise.all(new Array(n).fill(null).map(async(o,i)=>{let a=await T.flowNodeInstances.query(t,{...e,limit:ds,offset:ds*(i+1)});s.push(...a.flowNodeInstances)}))}return s}import{DataModels as ae}from"@5minds/processcube_engine_client";import{mapUserTask as Pn,mapUserTaskList as ge}from"../common/index.mjs";async function Ll(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,E=r!==void 0&&u.processInstanceId!==r,y=n!==void 0&&u.flowNodeId!==n;if(d||l||E||y)return;let w=await Ec(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 yc({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 Hl(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 Pn(i.userTasks[0])}async function yc(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 Fl(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 Dl(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 $l(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 Ec(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:Pn(s.userTasks[0])}async function Ml(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 Ul(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 Bl(t,e,s){await T.userTasks.reserveUserTaskInstance(t,e,s||t.userId)}async function Wl(t,e){await T.userTasks.cancelUserTaskInstanceReservation(t,e)}async function Gl(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 mc,PHASE_PRODUCTION_BUILD as wc,PHASE_PRODUCTION_SERVER as Rc}from"next/dist/shared/lib/constants";var On=!1,hs=!1;function Vl(t={}){let{applicationSdk:e,...s}=t;return async(r,n)=>{hs=hs||r===wc;let o=r===mc||r===Rc;return e?.useExternalTasks&&o&&!On&&!hs&&(On=!0,await gn(e?.customExternalTasksDirPath)),{...s,experimental:{...s.experimental,serverComponentsExternalPackages:[...s.experimental?.serverComponentsExternalPackages||[],"esbuild"]}}}}import{revalidatePath as Ac}from"next/cache";import{redirect as Tc}from"next/navigation";function Ql(t){Ac(t),Tc(t)}async function eu(...t){return await T.processModels.startProcessInstance(...t)}async function Ln(...t){await T.manualTasks.finishManualTask(...t)}async function Hn(...t){await T.userTasks.finishUserTask(...t)}async function Fn(...t){await T.untypedTasks.finishTask(...t)}import{DataModels as Ic}from"@5minds/processcube_engine_sdk";async function Sc(){try{return H()}catch{return}}var hu=async(t,e)=>{let s=await Sc();e==="bpmn:UserTask"?await Hn(t,{},s):e==="bpmn:ManualTask"?await Ln(t,s):e==="bpmn:Task"?await Fn(t,s):console.error(`[@5minds/processcube_app_sdk:handlePlay] Unsupported flow node type: ${e}`)},pu=async t=>{await vn(t)},_u=async(t,e,s)=>{await Nn(t,e,s)},gu=async t=>Cn(t),yu=async t=>xn(t,{sortSettings:{sortBy:Ic.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"DESC"}}),Eu=async t=>kn(t);export{Wl as cancelReservedUserTask,Ln as finishManualTask,hu as finishTask,Fn as finishUntypedTask,Hn as finishUserTask,Hl as finishUserTaskAndGetNext,Sl as getActiveProcessInstances,Gl as getAssignedUserTasksByIdentity,gl as getEngineClient,yu as getFlowNodeInstances,xn as getFlowNodeInstancesByProcessInstanceId,kn as getFlowNodeInstancesTriggeredByFlowNodeInstanceIds,H as getIdentity,gu as getProcessInstance,Cn as getProcessInstanceById,Ul as getReservedUserTasksByIdentity,Eu as getTriggeredFlowNodeInstances,yc as getUserTasks,Ec as getWaitingUserTaskByFlowNodeInstanceId,Fl as getWaitingUserTasks,Ml as getWaitingUserTasksByCorrelationId,$l as getWaitingUserTasksByFlowNodeId,Dl as getWaitingUserTasksByProcessInstanceId,Ql as navigateToUrl,bn as queryFlowNodeInstances,Bl as reserveUserTask,_u as retryProcess,Nn as retryProcessInstance,eu as startProcess,pu as terminateProcess,vn as terminateProcessInstance,Cl as waitForProcessEnd,Ll as waitForUserTask,Vl as withApplicationSdk};
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 Or=x((jc,Pr)=>{"use strict";var _o=ze(),{MAX_LENGTH:kr,CHAR_BACKSLASH:vt,CHAR_BACKTICK:go,CHAR_COMMA:yo,CHAR_DOT:Eo,CHAR_LEFT_PARENTHESES:mo,CHAR_RIGHT_PARENTHESES:wo,CHAR_LEFT_CURLY_BRACE:Ro,CHAR_RIGHT_CURLY_BRACE:Ao,CHAR_LEFT_SQUARE_BRACKET:Nr,CHAR_RIGHT_SQUARE_BRACKET:vr,CHAR_DOUBLE_QUOTE:To,CHAR_SINGLE_QUOTE:Io,CHAR_NO_BREAK_SPACE:So,CHAR_ZERO_WIDTH_NOBREAK_SPACE:Co}=xr(),bo=(t,e={})=>{if(typeof t!="string")throw new TypeError("Expected a string");let s=e||{},r=typeof s.maxLength=="number"?Math.min(kr,s.maxLength):kr;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,E=()=>t[u++],y=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(y({type:"bos"});u<f;)if(i=o[o.length-1],l=E(),!(l===Co||l===So)){if(l===vt){y({type:"text",value:(e.keepEscaping?l:"")+E()});continue}if(l===vr){y({type:"text",value:"\\"+l});continue}if(l===Nr){c++;let w;for(;u<f&&(w=E());){if(l+=w,w===Nr){c++;continue}if(w===vt){l+=E();continue}if(w===vr&&(c--,c===0))break}y({type:"text",value:l});continue}if(l===mo){i=y({type:"paren",nodes:[]}),o.push(i),y({type:"text",value:l});continue}if(l===wo){if(i.type!=="paren"){y({type:"text",value:l});continue}i=o.pop(),y({type:"text",value:l}),i=o[o.length-1];continue}if(l===To||l===Io||l===go){let w=l,N;for(e.keepQuotes!==!0&&(l="");u<f&&(N=E());){if(N===vt){l+=N+E();continue}if(N===w){e.keepQuotes===!0&&(l+=N);break}l+=N}y({type:"text",value:l});continue}if(l===Ro){d++;let N={type:"brace",open:!0,close:!1,dollar:a.value&&a.value.slice(-1)==="$"||i.dollar===!0,depth:d,commas:0,ranges:0,nodes:[]};i=y(N),o.push(i),y({type:"open",value:l});continue}if(l===Ao){if(i.type!=="brace"){y({type:"text",value:l});continue}let w="close";i=o.pop(),i.close=!0,y({type:w,value:l}),d--,i=o[o.length-1];continue}if(l===yo&&d>0){if(i.ranges>0){i.ranges=0;let w=i.nodes.shift();i.nodes=[w,{type:"text",value:_o(i)}]}y({type:"comma",value:l}),i.commas++;continue}if(l===Eo&&d>0&&i.commas===0){let w=i.nodes;if(d===0||w.length===0){y({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 N=w[w.length-1];N.value+=a.value+l,a=N,i.ranges--;continue}y({type:"dot",value:l});continue}y({type:"text",value:l})}do if(i=o.pop(),i.type!=="root"){i.nodes.forEach(D=>{D.nodes||(D.type==="open"&&(D.isOpen=!0),D.type==="close"&&(D.isClose=!0),D.nodes||(D.type="text"),D.invalid=!0)});let w=o[o.length-1],N=w.nodes.indexOf(i);w.nodes.splice(N,1,...i.nodes)}while(o.length>0);return y({type:"eos"}),n};Pr.exports=bo});var Fr=x((Vc,Hr)=>{"use strict";var Lr=ze(),xo=Tr(),ko=Cr(),No=Or(),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={})=>No(t,e);Z.stringify=(t,e={})=>Lr(typeof t=="string"?Z.parse(t,e):t,e);Z.compile=(t,e={})=>(typeof t=="string"&&(t=Z.parse(t,e)),xo(t,e));Z.expand=(t,e={})=>{typeof t=="string"&&(t=Z.parse(t,e));let s=ko(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);Hr.exports=Z});var Dr=x((Yc,vo)=>{vo.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 Mr=x((zc,$r)=>{$r.exports=Dr()});var Br=x((Xc,Ur)=>{"use strict";var Po=L("path"),Oo=Mr(),Lo=new Set(Oo);Ur.exports=t=>Lo.has(Po.extname(t).slice(1).toLowerCase())});var Ze=x(R=>{"use strict";var{sep:Ho}=L("path"),{platform:Pt}=process,Fo=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=`.${Ho}`;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=Fo.type()==="OS400"});var Vr=x((Zc,jr)=>{"use strict";var oe=L("fs"),B=L("path"),{promisify:Ne}=L("util"),Do=Br(),{isWindows:$o,isLinux:Mo,EMPTY_FN:Uo,EMPTY_STR:Bo,KEY_LISTENERS:we,KEY_ERR:Ot,KEY_RAW:be,HANDLER_KEYS:Wo,EV_CHANGE:et,EV_ADD:Je,EV_ADD_DIR:Go,EV_ERROR:Gr,STR_DATA:qo,STR_END:Ko,BRACE_START:jo,STAR:Vo}=Ze(),Yo="watch",zo=Ne(oe.open),qr=Ne(oe.stat),Xo=Ne(oe.lstat),Qo=Ne(oe.close),Lt=Ne(oe.realpath),Zo={lstat:Xo,stat:qr},Ft=(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)},Jo=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]},Kr=t=>t instanceof Set?t.size===0:!t,tt=new Map;function Wr(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&&Ft(o[e],i=>{i(s,r,n)})},ea=(t,e,s,r)=>{let{listener:n,errHandler:o,rawEmitter:i}=r,a=tt.get(e),c;if(!s.persistent)return c=Wr(t,s,n,o,i),c.close.bind(c);if(a)xe(a,we,n),xe(a,Ot,o),xe(a,be,i);else{if(c=Wr(t,s,st.bind(null,e,we),o,st.bind(null,e,be)),!c)return;c.on(Gr,async f=>{let u=st.bind(null,e,Ot);if(a.watcherUnusable=!0,$o&&f.code==="EPERM")try{let d=await zo(t,"r");await Qo(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,Ot,o),ke(a,be,i),Kr(a.listeners)&&(a.watcher.close(),tt.delete(e),Wo.forEach(Jo(a)),a.watcher=void 0,Object.freeze(a))}},Ht=new Map,ta=(t,e,s,r)=>{let{listener:n,rawEmitter:o}=r,i=Ht.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)=>{Ft(i.rawEmitters,E=>{E(et,e,{curr:u,prev:d})});let l=u.mtimeMs;(u.size!==d.size||l>d.mtimeMs||l===0)&&Ft(i.listeners,E=>E(t,u))})},Ht.set(e,i)),()=>{ke(i,we,n),ke(i,be,o),Kr(i.listeners)&&(Ht.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=Uo);let f;return r.usePolling?(c.interval=r.enableBinaryInterval&&Do(o)?r.binaryInterval:r.interval,f=ta(e,a,c,{listener:s,rawEmitter:this.fsw._emitRaw})):f=ea(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(Yo,e,5)){if(!d||d.mtimeMs===0)try{let l=await qr(e);if(this.fsw.closed)return;let E=l.atimeMs,y=l.mtimeMs;(!E||E<=y||y!==a.mtimeMs)&&this.fsw._emit(et,e,l),Mo&&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,E=d.mtimeMs;(!l||l<=E||E!==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 Lt(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,Bo),!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(qo,async d=>{if(this.fsw.closed){u=void 0;return}let l=d.path,E=B.join(e,l);if(f.add(l),!(d.stats.isSymbolicLink()&&await this._handleSymlink(d,e,E,l))){if(this.fsw.closed){u=void 0;return}(l===n||!n&&!c.has(l))&&(this.fsw._incrReadyCount(),E=B.join(o,B.relative(o,E)),this._addToNodeFs(E,s,r,i+1))}}).on(Gr,this._boundHandleError);return new Promise(d=>u.once(Ko,()=>{if(this.fsw.closed){u=void 0;return}let l=a?a.clear():!1;d(),c.getChildren().filter(E=>E!==e&&!f.has(E)&&(!r.hasGlob||r.filterPath({fullPath:B.resolve(e,E)}))).forEach(E=>{this.fsw._remove(e,E)}),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(Go,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,(E,y)=>{y&&y.mtimeMs===0||this._handleRead(E,!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 Zo[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(Vo)&&!e.includes(jo),u;if(c.isDirectory()){let d=B.resolve(e),l=f?await Lt(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 Lt(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}}};jr.exports=Dt});var en=x((Jc,Kt)=>{"use strict";var Gt=L("fs"),W=L("path"),{promisify:qt}=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:$t,EV_CHANGE:sa,EV_ADD_DIR:Yr,EV_UNLINK:rt,EV_ERROR:ra,STR_DATA:na,STR_END:ia,FSEVENT_CREATED:oa,FSEVENT_MODIFIED:aa,FSEVENT_DELETED:ca,FSEVENT_MOVED:la,FSEVENT_UNKNOWN:ua,FSEVENT_FLAG_MUST_SCAN_SUBDIRS:fa,FSEVENT_TYPE_FILE:da,FSEVENT_TYPE_DIRECTORY:ve,FSEVENT_TYPE_SYMLINK:Jr,ROOT_GLOBSTAR:zr,DIR_SUFFIX:ha,DOT_SLASH:Xr,FUNCTION_TYPE:Mt,EMPTY_FN:pa,IDENTITY_FN:_a}=Ze(),ga=t=>isNaN(t)?{}:{depth:t},Bt=qt(Gt.stat),ya=qt(Gt.lstat),Qr=qt(Gt.realpath),Ea={stat:Bt,lstat:ya},he=new Map,ma=10,wa=new Set([69888,70400,71424,72704,73472,131328,131840,262912]),Ra=(t,e)=>({stop:Re.watch(t,e)});function Aa(t,e,s,r){let n=W.extname(e)?W.dirname(e):e,o=W.dirname(n),i=he.get(n);Ta(o)&&(n=o);let a=W.resolve(t),c=a!==e,f=(d,l,E)=>{c&&(d=d.replace(e,a)),(d===a||!d.indexOf(a+W.sep))&&s(d,l,E)},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:Ra(n,(d,l)=>{if(!i.listeners.size||l&fa)return;let E=Re.getInfo(d,l);i.listeners.forEach(y=>{y(d,l,E)}),i.rawEmitter(E.event,d,E)})},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 Ta=t=>{let e=0;for(let s of he.keys())if(s.indexOf(t)===0&&(e++,e>=ma))return!0;return!1},Ia=()=>Re&&he.size<128,Ut=(t,e)=>{let s=0;for(;!t.indexOf(e)&&(t=W.dirname(t))!==e;)s++;return s},Zr=(t,e)=>t.type===ve&&e.isDirectory()||t.type===Jr&&e.isSymbolicLink()||t.type===da&&e.isFile(),Wt=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+zr),!0;r.delete(e),r.delete(e+zr)}addOrChange(e,s,r,n,o,i,a,c){let f=o.has(i)?sa:$t;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 Bt(e);if(this.fsw.closed)return;Zr(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===ve;(u||i.has(a))&&this.fsw._remove(o,a,u)}else{if(e===$t){if(c.type===ve&&this.fsw._getWatchedDir(s),c.type===Jr&&f.followSymlinks){let d=f.depth===void 0?void 0:Ut(r,n)+1;return this._addToFsEvents(s,!1,!0,d)}this.fsw._getWatchedDir(o).add(a)}let u=c.type===ve?e+ha:e;this.fsw._emit(u,s),u===Yr&&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=Aa(e,s,async(c,f,u)=>{if(this.fsw.closed||o.depth!==void 0&&Ut(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),E=W.basename(d),y=this.fsw._getWatchedDir(u.type===ve?d:l);if(wa.has(f)||u.event===ua)if(typeof o.ignored===Mt){let w;try{w=await Bt(d)}catch{}if(this.fsw.closed||this.checkIgnored(d,w))return;Zr(u,w)?this.addOrChange(d,c,s,l,y,E,u,o):this.handleEvent(rt,d,c,s,l,y,E,u,o)}else this.checkExists(d,c,s,l,y,E,u,o);else switch(u.event){case oa:case aa:return this.addOrChange(d,c,s,l,y,E,u,o);case ca:case la:return this.checkExists(d,c,s,l,y,E,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 Qr(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!==Xr?a=i.replace(o,e):i!==Xr&&(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?Yr:$t,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===Mt?s:_a,a=this.fsw._getWatchHelpers(e);try{let c=await Ea[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),...ga(o.depth-(n||0))}).on(na,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:Ut(u,W.resolve(a.watchPath))+1;this._handleFsEventsSymlink(u,d,i,l)}else this.emitAdd(u,f.stats,i,o,r)}).on(ra,pa).on(ia,()=>{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===Mt)this.initWatch(void 0,e,a,i);else{let c;try{c=await Qr(a.watchPath)}catch{}this.initWatch(c,e,a,i)}}};Kt.exports=Wt;Kt.exports.canUse=Ia});var dn=x(os=>{"use strict";var{EventEmitter:Sa}=L("events"),ns=L("fs"),k=L("path"),{promisify:cn}=L("util"),Ca=Bs(),Qt=Ys().default,ba=er(),jt=St(),xa=Fr(),ka=Tt(),Na=Vr(),tn=en(),{EV_ALL:Vt,EV_READY:va,EV_ADD:nt,EV_CHANGE:Pe,EV_UNLINK:sn,EV_ADD_DIR:Pa,EV_UNLINK_DIR:Oa,EV_RAW:La,EV_ERROR:Yt,STR_CLOSE:Ha,STR_END:Fa,BACK_SLASH_RE:Da,DOUBLE_SLASH_RE:rn,SLASH_OR_BACK_SLASH_RE:$a,DOT_RE:Ma,REPLACER_RE:Ua,SLASH:zt,SLASH_SLASH:Ba,BRACE_START:Wa,BANG:Zt,ONE_DOT:ln,TWO_DOTS:Ga,GLOBSTAR:qa,SLASH_GLOBSTAR:Xt,ANYMATCH_OPTS:Jt,STRING_TYPE:is,FUNCTION_TYPE:Ka,EMPTY_STR:es,EMPTY_FN:ja,isWindows:Va,isMacos:Ya,isIBMi:za}=Ze(),Xa=cn(ns.stat),Qa=cn(ns.readdir),ts=(t=[])=>Array.isArray(t)?t:[t],un=(t,e=[])=>(t.forEach(s=>{Array.isArray(s)?un(s,e):e.push(s)}),e),nn=t=>{let e=un(ts(t));if(!e.every(s=>typeof s===is))throw new TypeError(`Non-string provided as watch path: ${e}`);return e.map(fn)},on=t=>{let e=t.replace(Da,zt),s=!1;for(e.startsWith(Ba)&&(s=!0);e.match(rn);)e=e.replace(rn,zt);return s&&(e=zt+e),e},fn=t=>on(k.normalize(on(t))),an=(t=es)=>e=>typeof e!==is?e:fn(k.isAbsolute(e)?e:k.join(t,e)),Za=(t,e)=>k.isAbsolute(t)?t:t.startsWith(Zt)?Zt+k.join(e,t.slice(1)):k.join(e,t),ee=(t,e)=>t[e]===void 0,ss=class{constructor(e,s){this.path=e,this._removeWatcher=s,this.items=new Set}add(e){let{items:s}=this;s&&e!==ln&&e!==Ga&&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 Qa(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)}},Ja="stat",ec="lstat",rs=class{constructor(e,s,r,n){this.fsw=n,this.path=e=e.replace(Ua,es),this.watchPath=s,this.fullWatchPath=k.resolve(s),this.hasGlob=s!==e,e===es&&(this.hasGlob=!1),this.globSymlink=this.hasGlob&&r?void 0:!1,this.globFilter=this.hasGlob?Qt(e,void 0,Jt):!1,this.dirParts=this.getDirParts(e),this.dirParts.forEach(o=>{o.length>1&&o.pop()}),this.followSymlinks=r,this.statMethod=r?Ja:ec}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===Ka?this.globFilter(r):!0)&&this.fsw._isntIgnored(r,s)&&this.fsw._hasReadPermissions(s)}getDirParts(e){if(!this.hasGlob)return[];let s=[];return(e.includes(Wa)?xa.expand(e):[e]).forEach(n=>{s.push(k.relative(this.watchPath,n).split($a))}),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===qa&&(r=!0),r||!s[0][i]||Qt(o,s[0][i],Jt))))}return!this.unmatchedGlob&&this.fsw._isntIgnored(this.entryPath(e),e.stats)}},it=class extends Sa{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),tn.canUse()||(s.useFsEvents=!1),ee(s,"usePolling")&&!s.useFsEvents&&(s.usePolling=Ya),za&&(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=ts(s.ignored));let a=0;this._emitReady=()=>{a++,a>=this._readyCount&&(this._emitReady=ja,this._readyEmitted=!0,process.nextTick(()=>this.emit(va)))},this._emitRaw=(...c)=>this.emit(La,...c),this._readyEmitted=!1,this.options=s,s.useFsEvents?this._fsEventsHandler=new tn(this):this._nodeFsHandler=new Na(this),Object.freeze(s)}add(e,s,r){let{cwd:n,disableGlobbing:o}=this.options;this.closed=!1;let i=nn(e);return n&&(i=i.map(a=>{let c=Za(a,n);return o||!jt(a)?c:ka(c)})),i=i.filter(a=>a.startsWith(Zt)?(this._ignoredPaths.add(a.slice(1)),!1):(this._ignoredPaths.delete(a),this._ignoredPaths.delete(a+Xt),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=nn(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+Xt),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||ln]=s.getChildren().sort()}),e}emitWithAll(e,s){this.emit(...s),e!==Yt&&this.emit(Vt,...s)}async _emit(e,s,r,n,o){if(this.closed)return;let i=this.options;Va&&(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===sn)return this._pendingUnlinks.set(s,a),setTimeout(()=>{this._pendingUnlinks.forEach((u,d)=>{this.emit(...u),this.emit(Vt,...u),this._pendingUnlinks.delete(d)})},typeof i.atomic=="number"?i.atomic:100),this;e===nt&&this._pendingUnlinks.has(s)&&(e=a[0]=Pe,this._pendingUnlinks.delete(s))}if(c&&(e===nt||e===Pe)&&this._readyEmitted){let u=(d,l)=>{d?(e=a[0]=Yt,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===Pe&&!this._throttle(Pe,s,50))return this;if(i.alwaysStat&&r===void 0&&(e===nt||e===Pa||e===Pe)){let u=i.cwd?k.join(i.cwd,s):s,d;try{d=await Xa(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(Yt,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=>{ns.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 E=this._pendingWrites.get(e);l-E.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&&Ma.test(e))return!0;if(!this._userIgnored){let{cwd:r}=this.options,n=this.options.ignored,o=n&&n.map(an(r)),i=ts(o).filter(c=>typeof c===is&&!jt(c)).map(c=>c+Xt),a=this._getGlobIgnored().map(an(r)).concat(o,i);this._userIgnored=Qt(a,void 0,Jt)}return this._userIgnored([e,s])}_isntIgnored(e,s){return!this._isIgnored(e,s)}_getWatchHelpers(e,s){let r=s||this.options.disableGlobbing||!jt(e)?e:ba(e),n=this.options.followSymlinks;return new rs(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 ss(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?Oa:sn;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:Vt,alwaysStat:!0,lstat:!0,...s},n=Ca(e,r);return this._streams.add(n),n.once(Ha,()=>{n=void 0}),n.once(Fa,()=>{n&&(this._streams.delete(n),n=void 0)}),n}};os.FSWatcher=it;var tc=(t,e)=>{let s=new it(e);return s.add(t),s};os.watch=tc});import"only-server";import"../common/index.mjs";var _n=Kn(dn(),1);import{fork as rc}from"node:child_process";import{existsSync as hn,promises as nc}from"node:fs";import{basename as cs,dirname as us,join as ls,relative as pn}from"node:path";import{build as ic}from"esbuild";import{jwtDecode as oc}from"jwt-decode";import{Issuer as ac,custom as cc}from"openid-client";import{Logger as lc}from"@5minds/processcube_engine_sdk";import{EngineClient as sc}from"@5minds/processcube_engine_client";var as=process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560",T=new sc(as);var uc={token:"ZHVtbXlfdG9rZW4=",userId:"dummy_token"},fc=.85,ot=["external_task.ts","external_task.js"],fs=process.env.PROCESSCUBE_AUTHORITY_URL!==void 0,_e=new lc("processcube_app_sdk:external_task_adapter"),pe={},Oe;async function gn(t){if(t&&!hn(t))throw new Error(`Invalid customExternalTasksDirPath. The given path '${t}' does not exist`);cc.setHttpOptionsDefaults({timeout:1e5});let e=await mn();Oe=await wn(e),await hc(e);let s=_c(t);(0,_n.watch)(s).on("add",async r=>{if(ot.includes(cs(r)))return yn(r,s)}).on("change",async r=>{if(ot.includes(cs(r)))return dc(r,s)}).on("unlink",async r=>{ot.includes(cs(r))&&En(r)}).on("error",r=>_e.error(`Watcher error: ${r}`))}async function yn(t,e){let s=us(t);if((await nc.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]&&En(t);return}let o=await Rn(t),i=pn(e,s),a=An(i),c=ls(__dirname,"lib/ExternalTaskWorkerProcess.cjs"),f=rc(c,{env:{...process.env,PROCESSCUBE_ENGINE_URL:as}});pe[s]=f,f.once("disconnect",()=>{delete pe[s]}),f.send({action:"create",payload:{topic:a,identity:Oe,moduleString:o,workerPath:t}})}async function dc(t,e){let s=us(t),r=pe[s];if(!r)return yn(t,e);let n=await Rn(t),o=pn(e,s),i=An(o);r.send({action:"restart",payload:{topic:i,identity:Oe,moduleString:n,workerPath:t}})}function En(t){let e=us(t),s=pe[e];s&&s.kill()}async function mn(){if(!fs)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 ac.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 wn(t){if(!fs||t===null)return uc;let e=t.access_token,s=oc(e);return{token:t.access_token,userId:s.sub}}async function hc(t){let e=5;if(!fs||t===null)return;let r=await pc(t)*fc*1e3,n=async()=>{try{let o=await mn();Oe=wn(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 Rn(t){let e=await ic({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 pc(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 An(t){return t.replace(/^\.\/+|\([^)]+\)|^\/*|\/*$/g,"").replace(/[\/]{2,}/g,"/")}function _c(t){let e,s=[t,ls(process.cwd(),"app"),ls(process.cwd(),"src","app")];for(let r of s)if(r&&hn(r)){e=r;break}if(!e)throw new Error("Could not find external tasks directory");return e}function gl(){return T}import{getToken as Tn}from"next-auth/jwt";import{ResponseCookies as gc}from"next/dist/compiled/@edge-runtime/cookies";import{cookies as at,headers as In}from"next/headers";async function H(){let t=await Tn({req:{cookies:at(),headers:In()}});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 gc(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 Tn({req:{cookies:n?r:at(),headers:In()}}),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";var ct=300,ds=1e3;async function He(){try{return H()}catch{return}}async function Cn(t){let e=await He();return(await T.processInstances.query({processInstanceId:t},{identity:e})).processInstances[0]}async function bn(t,e){let{processInstanceId:s,flowNodeInstanceId:r}=t,n=r;if(!s&&!n)return[];let o=[];return n&&n.length>ct?await Promise.all(new Array(Math.ceil(n.length/ct)).fill(null).map(async(i,a)=>{let c=await Sn({flowNodeInstanceId:n.slice(a*ct,(a+1)*ct)},{...e,identity:e?.identity??await He()});o.push(...c)})):o.push(...await Sn({processInstanceId:s,flowNodeInstanceId:n},{...e,identity:e?.identity??await He()})),o}async function xn(t,e={sortSettings:{sortBy:Le.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"ASC"}}){return await bn({processInstanceId:t},e)}async function kn(t){return await bn({triggeredByFlowNodeInstance:t})}async function Nn(t,e,s){let r=await He();await T.processInstances.retryProcessInstance(t,{flowNodeInstanceId:e,newStartToken:s,identity:r})}async function vn(t){let e=await He();await T.processInstances.terminateProcessInstance(t,e)}async function Sl(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 Cl(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])}}})}async function Sn(t,e){let s=[],r=await T.flowNodeInstances.query(t,{...e,limit:ds});if(s.push(...r.flowNodeInstances),r.flowNodeInstances.length!==r.totalCount){let n=Math.floor(r.totalCount/r.flowNodeInstances.length);await Promise.all(new Array(n).fill(null).map(async(o,i)=>{let a=await T.flowNodeInstances.query(t,{...e,limit:ds,offset:ds*(i+1)});s.push(...a.flowNodeInstances)}))}return s}import{DataModels as ae}from"@5minds/processcube_engine_client";import{mapUserTask as Pn,mapUserTaskList as ge}from"../common/index.mjs";async function Ll(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,E=r!==void 0&&u.processInstanceId!==r,y=n!==void 0&&u.flowNodeId!==n;if(d||l||E||y)return;let w=await Ec(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 yc({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 Hl(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 Pn(i.userTasks[0])}async function yc(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 Fl(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 Dl(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 $l(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 Ec(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:Pn(s.userTasks[0])}async function Ml(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 Ul(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 Bl(t,e,s){await T.userTasks.reserveUserTaskInstance(t,e,s||t.userId)}async function Wl(t,e){await T.userTasks.cancelUserTaskInstanceReservation(t,e)}async function Gl(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 mc,PHASE_PRODUCTION_BUILD as wc,PHASE_PRODUCTION_SERVER as Rc}from"next/dist/shared/lib/constants";var On=!1,hs=!1;function Vl(t={}){let{applicationSdk:e,...s}=t;return async(r,n)=>{hs=hs||r===wc;let o=r===mc||r===Rc;return e?.useExternalTasks&&o&&!On&&!hs&&(On=!0,await gn(e?.customExternalTasksDirPath)),{...s,experimental:{...s.experimental,serverComponentsExternalPackages:[...s.experimental?.serverComponentsExternalPackages||[],"esbuild"]}}}}import{revalidatePath as Ac}from"next/cache";import{redirect as Tc}from"next/navigation";function Ql(t){Ac(t),Tc(t)}async function eu(...t){return await T.processModels.startProcessInstance(...t)}async function Ln(...t){await T.manualTasks.finishManualTask(...t)}async function Hn(...t){await T.userTasks.finishUserTask(...t)}async function Fn(...t){await T.untypedTasks.finishTask(...t)}import{DataModels as Ic}from"@5minds/processcube_engine_client";async function Sc(){try{return H()}catch{return}}var du=async(t,e)=>{let s=await Sc();e==="bpmn:UserTask"?await Hn(t,{},s):e==="bpmn:ManualTask"?await Ln(t,s):e==="bpmn:Task"?await Fn(t,s):console.error(`[@5minds/processcube_app_sdk:handlePlay] Unsupported flow node type: ${e}`)},hu=async t=>{await vn(t)},pu=async(t,e,s)=>{await Nn(t,e,s)},_u=async t=>Cn(t),gu=async t=>xn(t,{sortSettings:{sortBy:Ic.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"DESC"}}),yu=async t=>kn(t);export{Wl as cancelReservedUserTask,Ln as finishManualTask,du as finishTask,Fn as finishUntypedTask,Hn as finishUserTask,Hl as finishUserTaskAndGetNext,Sl as getActiveProcessInstances,Gl as getAssignedUserTasksByIdentity,gl as getEngineClient,gu as getFlowNodeInstances,xn as getFlowNodeInstancesByProcessInstanceId,kn as getFlowNodeInstancesTriggeredByFlowNodeInstanceIds,H as getIdentity,_u as getProcessInstance,Cn as getProcessInstanceById,Ul as getReservedUserTasksByIdentity,yu as getTriggeredFlowNodeInstances,yc as getUserTasks,Ec as getWaitingUserTaskByFlowNodeInstanceId,Fl as getWaitingUserTasks,Ml as getWaitingUserTasksByCorrelationId,$l as getWaitingUserTasksByFlowNodeId,Dl as getWaitingUserTasksByProcessInstanceId,Ql as navigateToUrl,bn as queryFlowNodeInstances,Bl as reserveUserTask,pu as retryProcess,Nn as retryProcessInstance,eu as startProcess,hu as terminateProcess,vn as terminateProcessInstance,Cl as waitForProcessEnd,Ll as waitForUserTask,Vl as withApplicationSdk};
3
3
  /*! Bundled license information:
4
4
 
5
5
  normalize-path/index.js:
@@ -1,5 +1,5 @@
1
1
  import { DataModels } from '@5minds/processcube_engine_client';
2
- import type { FlowNodeInstance, GenericFlowNodeInstanceQuery, Identity } from '@5minds/processcube_engine_sdk';
2
+ import type { GenericFlowNodeInstanceQuery, Identity } from '@5minds/processcube_engine_sdk';
3
3
  import { Client } from './internal/EngineClient';
4
4
  /**
5
5
  * This function will return the ProcessInstance with the given ID.
@@ -8,7 +8,7 @@ import { Client } from './internal/EngineClient';
8
8
  * @returns {Promise<DataModels.ProcessInstances.ProcessInstance>} The {@link DataModels.ProcessInstances.ProcessInstance}
9
9
  */
10
10
  export declare function getProcessInstanceById(processInstanceId: string): Promise<DataModels.ProcessInstances.ProcessInstance>;
11
- export declare function queryFlowNodeInstances(query: GenericFlowNodeInstanceQuery, options?: Parameters<typeof Client.flowNodeInstances.query>[1]): Promise<FlowNodeInstance[]>;
11
+ export declare function queryFlowNodeInstances(query: GenericFlowNodeInstanceQuery, options?: Parameters<typeof Client.flowNodeInstances.query>[1]): Promise<DataModels.FlowNodeInstances.FlowNodeInstance[]>;
12
12
  /**
13
13
  * This function will return the FlowNodeInstances of the ProcessInstance with the given ID.
14
14
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@5minds/processcube_app_sdk",
3
- "version": "6.2.0-feature-afd7db-m9jner2j",
3
+ "version": "6.2.0-feature-b0f0cb-m9jnmlua",
4
4
  "description": "The SDK for ProcessCube Apps",
5
5
  "type": "module",
6
6
  "main": "build/common/index.cjs",
@@ -1 +0,0 @@
1
- "use server";import{DataModels as _}from"@5minds/processcube_engine_sdk";import{DataModels as S}from"@5minds/processcube_engine_client";import{getToken as y}from"next-auth/jwt";import{ResponseCookies as F}from"next/dist/compiled/@edge-runtime/cookies";import{cookies as d,headers as f}from"next/headers";async function l(){let e=await y({req:{cookies:d(),headers:f()}});if(e?.expiresAt&&Date.now()>=e.expiresAt*1e3){let t=await fetch(`${process.env.NEXTAUTH_URL}/api/auth/session`,{method:"GET",headers:{"Content-Type":"application/json",cookie:d().toString()}}),s=new F(t.headers);if(s.getAll().length){let a=!1;try{for(let r of s.getAll())d().set(r.name,r.value,{...r})}catch{a=!0}if(e=await y({req:{cookies:a?s:d(),headers:f()}}),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 M}from"@5minds/processcube_engine_client";var x=process.env.PROCESSCUBE_ENGINE_URL??"http://localhost:10560",o=new M(x);var p=300,I=1e3;async function i(){try{return l()}catch{return}}async function w(e){let n=await i();return(await o.processInstances.query({processInstanceId:e},{identity:n})).processInstances[0]}async function g(e,n){let{processInstanceId:t,flowNodeInstanceId:s}=e,a=s;if(!t&&!a)return[];let r=[];return a&&a.length>p?await Promise.all(new Array(Math.ceil(a.length/p)).fill(null).map(async(u,c)=>{let E=await m({flowNodeInstanceId:a.slice(c*p,(c+1)*p)},{...n,identity:n?.identity??await i()});r.push(...E)})):r.push(...await m({processInstanceId:t,flowNodeInstanceId:a},{...n,identity:n?.identity??await i()})),r}async function P(e,n={sortSettings:{sortBy:S.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"ASC"}}){return await g({processInstanceId:e},n)}async function k(e){return await g({triggeredByFlowNodeInstance:e})}async function h(e,n,t){let s=await i();await o.processInstances.retryProcessInstance(e,{flowNodeInstanceId:n,newStartToken:t,identity:s})}async function N(e){let n=await i();await o.processInstances.terminateProcessInstance(e,n)}async function m(e,n){let t=[],s=await o.flowNodeInstances.query(e,{...n,limit:I});if(t.push(...s.flowNodeInstances),s.flowNodeInstances.length!==s.totalCount){let a=Math.floor(s.totalCount/s.flowNodeInstances.length);await Promise.all(new Array(a).fill(null).map(async(r,u)=>{let c=await o.flowNodeInstances.query(e,{...n,limit:I,offset:I*(u+1)});t.push(...c.flowNodeInstances)}))}return t}async function T(...e){await o.manualTasks.finishManualTask(...e)}async function C(...e){await o.userTasks.finishUserTask(...e)}async function b(...e){await o.untypedTasks.finishTask(...e)}async function U(){try{return l()}catch{return}}var ee=async(e,n)=>{let t=await U();n==="bpmn:UserTask"?await C(e,{},t):n==="bpmn:ManualTask"?await T(e,t):n==="bpmn:Task"?await b(e,t):console.error(`[@5minds/processcube_app_sdk:handlePlay] Unsupported flow node type: ${n}`)},ne=async e=>{await N(e)},te=async(e,n,t)=>{await h(e,n,t)},se=async e=>w(e),oe=async e=>P(e,{sortSettings:{sortBy:_.FlowNodeInstances.FlowNodeInstanceSortableColumns.createdAt,sortDir:"DESC"}}),ae=async e=>k(e);export{ee as finishTask,oe as getFlowNodeInstances,se as getProcessInstance,ae as getTriggeredFlowNodeInstances,te as retryProcess,ne as terminateProcess};