import{createRequireasjM0}from"node:module";varOM0=Object.create;var{getPrototypeOf:FM0,defineProperty:NF,getOwnPropertyNames:NM0}=Object;varMM0=Object.prototype.hasOwnProperty;functionAM0($){returnthis[$]}varPM0,TM0,I3=($,I,z)=>{varq=$!=null&&typeof$==="object";if(q){varU=I?PM0??=newWeakMap:TM0??=newWeakMap,Y=U.get($);if(Y)returnY}z=$!=null?OM0(FM0($)):{};letJ=I||!$||!$.__esModule?NF(z,"default",{value:$,enumerable:!0}):z;for(letQofNM0($))if(!MM0.call(J,Q))NF(J,Q,{get:AM0.bind($,Q),enumerable:!0});if(q)U.set($,J);returnJ};varF=($,I)=>()=>(I||$((I={exports:{}}).exports,I),I.exports);varEM0=($)=>$;functionBM0($,I){this[$]=EM0.bind(null,I)}varA$=($,I)=>{for(varzinI)NF($,z,{get:I[z],enumerable:!0,configurable:!0,set:BM0.bind(I,z)})};varK0=($,I)=>()=>($&&(I=$($=0)),I);vart=jM0(import.meta.url);functionr($,I,z){functionq(Q,K){if(!Q._zod)Object.defineProperty(Q,"_zod",{value:{def:K,constr:J,traits:newSet},enumerable:!1});if(Q._zod.traits.has($))return;Q._zod.traits.add($),I(Q,K);letw=J.prototype,G=Object.keys(w);for(letH=0;H<G.length;H++){letW=G[H];if(!(WinQ))Q[W]=w[W].bind(Q)}}letU=z?.Parent??Object;classYextendsU{}Object.defineProperty(Y,"name",{value:$});functionJ(Q){varK;letw=z?.Parent?newY:this;q(w,Q),(K=w._zod).deferred??(K.deferred=[]);for(letGofw._zod.deferred)G();returnw}returnObject.defineProperty(J,"init",{value:q}),Object.defineProperty(J,Symbol.hasInstance,{value:(Q)=>{if(z?.Parent&&Qinstanceofz.Parent)return!0;returnQ?._zod?.traits?.has($)}}),Object.defineProperty(J,"name",{value:$}),J}functionE4($){if($)Object.assign(z3,$);returnz3}varIb,MF,AF,S8,q3,z3;varU3=K0(()=>{MF=Object.freeze({status:"aborted"});AF=Symbol("zod_brand");S8=classS8extendsError{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};q3=classq3extendsError{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}};(Ib=globalThis).__zod_globalConfig??(Ib.__zod_globalConfig={});z3=globalThis.__zod_globalConfig});varF0={};A$(F0,{unwrapMessage:()=>TY,uint8ArrayToHex:()=>sM0,uint8ArrayToBase64url:()=>tM0,uint8ArrayToBase64:()=>Ub,stringifyPrimitive:()=>X0,slugify:()=>EF,shallowClone:()=>jF,safeExtend:()=>cM0,required:()=>lM0,randomString:()=>xM0,propertyKeyTypes:()=>jY,promiseAllObject:()=>uM0,primitiveTypes:()=>vF,prefixIssues:()=>I$,pick:()=>nM0,partial:()=>mM0,parsedType:()=>D0,optionalKeys:()=>RF,omit:()=>iM0,objectClone:()=>hM0,numKeys:()=>kM0,nullish:()=>A9,normalizeParams:()=>P0,mergeDefs:()=>M5,merge:()=>dM0,jsonStringifyReplacer:()=>rI,joinValues:()=>z0,issue:()=>aI,isPlainObject:()=>T9,isObject:()=>Y3,hexToUint8Array:()=>aM0,getSizableOrigin:()=>vY,getParsedType:()=>fM0,getLengthableOrigin:()=>RY,getEnumValues:()=>EY,getElementAtPath:()=>yM0,floatSafeRemainder:()=>TF,finalizeIssue:()=>b6,extend:()=>pM0,explicitlyAborted:()=>CF,escapeRegex:()=>c$,esc:()=>nw,defineLazy:()=>U1,createTransparentProxy:()=>bM0,cloneDef:()=>SM0,clone:()=>f6,cleanRegex:()=>BY,cleanEnum:()=>oM0,captureStackTrace:()=>iw,cached:()=>tI,base64urlToUint8Array:()=>rM0,base64ToUint8Array:()=>qb,assignProp:()=>P9,assertNotEqual:()=>RM0,assertNever:()=>_M0,assertIs:()=>gM0,assertEqual:()=>vM0,assert:()=>CM0,allowsEval:()=>BF,aborted:()=>E9,NUMBER_FORMAT_RANGES:()=>gF,Class:()=>Yb,BIGINT_FORMAT_RANGES:()=>_F});functionvM0($){return$}functionRM0($){return$}functiongM0($){}function_M0($){throwError("Unexpected value in exhaustive check")}functionCM0($){}functionEY($){letI=Object.values($).filter((q)=>typeofq==="number");returnObject.entries($).filter(([q,U])=>I.indexOf(+q)===-1).map(([q,U])=>U)}functionz0($,I="|"){return$.map((z)=>X0(z)).join(I)}functionrI($,I){if(typeofI==="bigint")returnI.toString();returnI}functiontI($){return{getvalue(){{letz=$();returnObject.defineProperty(this,"value",{value:z}),z}throwError("cached value already set")}}}functionA9($){return$===null||$===void0}functionBY($){letI=$.startsWith("^")?1:0,z=$.endsWith("$")?$.length-1:$.length;return$.slice(I,z)}functionTF($,I){letz=$/I,q=Math.round(z),U=Number.EPSILON*Math.max(Math.abs(z),1);if(Math.abs(z-q)<U)return0;returnz-q}functionU1($,I,z){letq=void0;Object.defineProperty($,I,{get(){if(q===zb)return;if(q===void0)q=zb,q=z();returnq},set(U){Object.defineProperty($,I,{value:U})},configurable:!0})}functionhM0($){returnObject.create(Object.getPrototypeOf($),Object.getOwnPropertyDescriptors($))}functionP9($,I,z){Object.defineProperty($,I,{value:z,writable:!0,enumerable:!0,configurable:!0})}functionM5(...$){letI={};for(letzof$){letq=Object.getOwnPropertyDescriptors(z);Object.assign(I,q)}returnObject.defineProperties({},I)}functionSM0($){returnM5($._zod.def)}functionyM0($,I){if(!I)return$;returnI.reduce((z,q)=>z?.[q],$)}functionuM0($){letI=Object.keys($),z=I.map((q)=>$[q]);returnPromise.all(z).then((q)=>{letU={};for(letY=0;Y<I.length;Y++)U[I[Y]]=q[Y];returnU})}functionxM0($=10){letz=Line truncated
`)}var Jb=($,I)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:I,enumerable:!1}),$.message=JSON.stringify(I,rI,2),Object.defineProperty($,"toString",{value:()=>$.message,enumerable:!1})},gY,z$;var yF=K0(()=>{U3();h0();gY=r("$ZodError",Jb),z$=r("$ZodError",Jb,{Parent:Error})});var sI=($)=>(I,z,q,U)=>{let Y=q?{...q,async:!1}:{async:!1},J=I._zod.run({value:z,issues:[]},Y);if(J instanceof Promise)throw new S8;if(J.issues.length){let Q=new(U?.Err??$)(J.issues.map((K)=>b6(K,Y,E4())));throw iw(Q,U?.callee),Q}return J.value},hY,eI=($)=>async(I,z,q,U)=>{let Y=q?{...q,async:!0}:{async:!0},J=I._zod.run({value:z,issues:[]},Y);if(J instanceof Promise)J=await J;if(J.issues.length){let Q=new(U?.Err??$)(J.issues.map((K)=>b6(K,Y,E4())));throw iw(Q,U?.callee),Q}return J.value},SY,$z=($)=>(I,z,q)=>{let U=q?{...q,async:!1}:{async:!1},Y=I._zod.run({value:z,issues:[]},U);if(Y instanceof Promise)throw new S8;return Y.issues.length?{success:!1,error:new($??gY)(Y.issues.map((J)=>b6(J,U,E4())))}:{success:!0,data:Y.value}},Iz,zz=($)=>async(I,z,q)=>{let U=q?{...q,async:!0}:{async:!0},Y=I._zod.run({value:z,issues:[]},U);if(Y instanceof Promise)Y=await Y;return Y.issues.length?{success:!1,error:new $(Y.issues.map((J)=>b6(J,U,E4())))}:{success:!0,data:Y.value}},yY,pw=($)=>(I,z,q)=>{let U=q?{...q,direction:"backward"}:{direction:"backward"};return sI($)(I,z,U)},Kb,cw=($)=>(I,z,q)=>{return sI($)(I,z,q)},wb,dw=($)=>async(I,z,q)=>{let U=q?{...q,direction:"backward"}:{direction:"backward"};return eI($)(I,z,U)},Gb,mw=($)=>async(I,z,q)=>{return eI($)(I,z,q)},Hb,lw=($)=>(I,z,q)=>{let U=q?{...q,direction:"backward"}:{direction:"backward"};return $z($)(I,z,U)},Wb,ow=($)=>(I,z,q)=>{return $z($)(I,z,q)},Vb,rw=($)=>async(I,z,q)=>{let U=q?{...q,direction:"backward"}:{direction:"backward"};return zz($)(I,z,U)},Zb,tw=($)=>async(I,z,q)=>{return zz($)(I,z,q)},Xb;var uF=K0(()=>{U3();yF();h0();hY=sI(z$),SY=eI(z$),Iz=$z(z$),yY=zz(z$),Kb=pw(z$),wb=cw(z$),Gb=dw(z$),Hb=mw(z$),Wb=lw(z$),Vb=ow(z$),Zb=rw(z$),Xb=tw(z$)});var P$={};A$(P$,{xid:()=>bF,uuid7:()=>qA0,uuid6:()=>zA0,uuid4:()=>IA0,uuid:()=>J3,uppercase:()=>HN,unicodeEmail:()=>Lb,undefined:()=>wN,ulid:()=>fF,time:()=>zN,string:()=>UN,sha512_hex:()=>TA0,sha512_base64url:()=>BA0,sha512_base64:()=>EA0,sha384_hex:()=>MA0,sha384_base64url:()=>PA0,sha384_base64:()=>AA0,sha256_hex:()=>OA0,sha256_base64url:()=>NA0,sha256_base64:()=>FA0,sha1_hex:()=>XA0,sha1_base64url:()=>DA0,sha1_base64:()=>LA0,rfc5322Email:()=>YA0,number:()=>uY,null:()=>KN,nanoid:()=>iF,md5_hex:()=>WA0,md5_base64url:()=>ZA0,md5_base64:()=>VA0,mac:()=>rF,lowercase:()=>GN,ksuid:()=>nF,ipv6:()=>oF,ipv4:()=>lF,integer:()=>JN,idnEmail:()=>JA0,httpProtocol:()=>eF,html5Email:()=>UA0,hostname:()=>wA0,hex:()=>HA0,guid:()=>cF,extendedDuration:()=>$A0,emoji:()=>mF,email:()=>dF,e164:()=>$N,duration:()=>pF,domain:()=>GA0,datetime:()=>qN,date:()=>IN,cuid2:()=>kF,cuid:()=>xF,cidrv6:()=>aF,cidrv4:()=>tF,browserEmail:()=>QA0,boolean:()=>QN,bigint:()=>YN,base64url:()=>aw,base64:()=>sF});function mF(){return new RegExp(KA0,"u")}function Ob($){return typeof $.precision==="number"?$.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":$.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${$.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function zN($){return new RegExp(`^${Ob($)}$`)}function qN($){let I=Ob({precision:$.precision}),z=["Z"];if($.local)z.push("");if($.offset)z.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let q=`${I}(?:${z.join("|")})`;return new RegExp(`^${Db}T(?:${q})$`)}function xY($,I){return new RegExp(`^[A-Za-z0-9+/]{${$}}${I}$`)}function kY($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var xF,kF,fF,bF,nF,iF,pF,$A0,cF,J3=($)=>{if(!$)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;returnnewRegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${$}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},IA0,zA0,qA0,dF,UA0,YA0,Lb,JA0,QA0,KA0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",lF,oF,rF=($)=>{letI=c$($??":");returnnewRegExp(`^(?:[0-9A-F]{2}${I}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${I}){5}[0-9a-f]{2}$`)},tF,aF,sF,aw,wA0,GA0,eF,$N,Db="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",IN,UN=($)=>{letI=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";returnnewRegExp(`^${I}$`)},YN,JN,uY,QN,KN,wN,GN,HN,HA0,WA0,VA0,ZA0,XA0,LA0,DA0,OA0,FA0,NA0,MA0,AA0,PA0,TA0,EA0,BA0;varsw=K0(()=>{h0();xF=/^[cC][0-9a-z]{6,}$/,kF=/^[0-9a-z]+$/,fF=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,bF=/^[0-9a-vA-V]{20}$/,nF=/^[A-Za-z0-9]{27}$/,iF=/^[a-zA-Z0-9_-]{21}$/,pF=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\dLine truncated
import{createRequireasjM0}from"node:module";varDM0=Object.create;var{getPrototypeOf:FM0,defineProperty:NF,getOwnPropertyNames:NM0}=Object;varMM0=Object.prototype.hasOwnProperty;functionAM0($){returnthis[$]}varPM0,TM0,I3=($,I,z)=>{varq=$!=null&&typeof$==="object";if(q){varU=I?PM0??=newWeakMap:TM0??=newWeakMap,Y=U.get($);if(Y)returnY}z=$!=null?DM0(FM0($)):{};letJ=I||!$||!$.__esModule?NF(z,"default",{value:$,enumerable:!0}):z;for(letQofNM0($))if(!MM0.call(J,Q))NF(J,Q,{get:AM0.bind($,Q),enumerable:!0});if(q)U.set($,J);returnJ};varF=($,I)=>()=>(I||$((I={exports:{}}).exports,I),I.exports);varEM0=($)=>$;functionBM0($,I){this[$]=EM0.bind(null,I)}varA$=($,I)=>{for(varzinI)NF($,z,{get:I[z],enumerable:!0,configurable:!0,set:BM0.bind(I,z)})};varK0=($,I)=>()=>($&&(I=$($=0)),I);vara=jM0(import.meta.url);functiont($,I,z){functionq(Q,K){if(!Q._zod)Object.defineProperty(Q,"_zod",{value:{def:K,constr:J,traits:newSet},enumerable:!1});if(Q._zod.traits.has($))return;Q._zod.traits.add($),I(Q,K);letw=J.prototype,G=Object.keys(w);for(letH=0;H<G.length;H++){letW=G[H];if(!(WinQ))Q[W]=w[W].bind(Q)}}letU=z?.Parent??Object;classYextendsU{}Object.defineProperty(Y,"name",{value:$});functionJ(Q){varK;letw=z?.Parent?newY:this;q(w,Q),(K=w._zod).deferred??(K.deferred=[]);for(letGofw._zod.deferred)G();returnw}returnObject.defineProperty(J,"init",{value:q}),Object.defineProperty(J,Symbol.hasInstance,{value:(Q)=>{if(z?.Parent&&Qinstanceofz.Parent)return!0;returnQ?._zod?.traits?.has($)}}),Object.defineProperty(J,"name",{value:$}),J}functionE4($){if($)Object.assign(z3,$);returnz3}varzb,MF,AF,S8,q3,z3;varU3=K0(()=>{MF=Object.freeze({status:"aborted"});AF=Symbol("zod_brand");S8=classS8extendsError{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};q3=classq3extendsError{constructor($){super(`Encountered unidirectional transform during encode: ${$}`);this.name="ZodEncodeError"}};(zb=globalThis).__zod_globalConfig??(zb.__zod_globalConfig={});z3=globalThis.__zod_globalConfig});varF0={};A$(F0,{unwrapMessage:()=>TY,uint8ArrayToHex:()=>sM0,uint8ArrayToBase64url:()=>tM0,uint8ArrayToBase64:()=>Yb,stringifyPrimitive:()=>X0,slugify:()=>EF,shallowClone:()=>jF,safeExtend:()=>cM0,required:()=>lM0,randomString:()=>xM0,propertyKeyTypes:()=>jY,promiseAllObject:()=>uM0,primitiveTypes:()=>vF,prefixIssues:()=>I$,pick:()=>nM0,partial:()=>mM0,parsedType:()=>O0,optionalKeys:()=>RF,omit:()=>iM0,objectClone:()=>hM0,numKeys:()=>kM0,nullish:()=>A9,normalizeParams:()=>A0,mergeDefs:()=>M5,merge:()=>dM0,jsonStringifyReplacer:()=>rI,joinValues:()=>U0,issue:()=>aI,isPlainObject:()=>T9,isObject:()=>Y3,hexToUint8Array:()=>aM0,getSizableOrigin:()=>vY,getParsedType:()=>fM0,getLengthableOrigin:()=>RY,getEnumValues:()=>EY,getElementAtPath:()=>yM0,floatSafeRemainder:()=>TF,finalizeIssue:()=>b6,extend:()=>pM0,explicitlyAborted:()=>CF,escapeRegex:()=>c$,esc:()=>nw,defineLazy:()=>Y1,createTransparentProxy:()=>bM0,cloneDef:()=>SM0,clone:()=>f6,cleanRegex:()=>BY,cleanEnum:()=>oM0,captureStackTrace:()=>iw,cached:()=>tI,base64urlToUint8Array:()=>rM0,base64ToUint8Array:()=>Ub,assignProp:()=>P9,assertNotEqual:()=>RM0,assertNever:()=>_M0,assertIs:()=>gM0,assertEqual:()=>vM0,assert:()=>CM0,allowsEval:()=>BF,aborted:()=>E9,NUMBER_FORMAT_RANGES:()=>gF,Class:()=>Jb,BIGINT_FORMAT_RANGES:()=>_F});functionvM0($){return$}functionRM0($){return$}functiongM0($){}function_M0($){throwError("Unexpected value in exhaustive check")}functionCM0($){}functionEY($){letI=Object.values($).filter((q)=>typeofq==="number");returnObject.entries($).filter(([q,U])=>I.indexOf(+q)===-1).map(([q,U])=>U)}functionU0($,I="|"){return$.map((z)=>X0(z)).join(I)}functionrI($,I){if(typeofI==="bigint")returnI.toString();returnI}functiontI($){return{getvalue(){{letz=$();returnObject.defineProperty(this,"value",{value:z}),z}throwError("cached value already set")}}}functionA9($){return$===null||$===void0}functionBY($){letI=$.startsWith("^")?1:0,z=$.endsWith("$")?$.length-1:$.length;return$.slice(I,z)}functionTF($,I){letz=$/I,q=Math.round(z),U=Number.EPSILON*Math.max(Math.abs(z),1);if(Math.abs(z-q)<U)return0;returnz-q}functionY1($,I,z){letq=void0;Object.defineProperty($,I,{get(){if(q===qb)return;if(q===void0)q=qb,q=z();returnq},set(U){Object.defineProperty($,I,{value:U})},configurable:!0})}functionhM0($){returnObject.create(Object.getPrototypeOf($),Object.getOwnPropertyDescriptors($))}functionP9($,I,z){Object.defineProperty($,I,{value:z,writable:!0,enumerable:!0,configurable:!0})}functionM5(...$){letI={};for(letzof$){letq=Object.getOwnPropertyDescriptors(z);Object.assign(I,q)}returnObject.defineProperties({},I)}functionSM0($){returnM5($._zod.def)}functionyM0($,I){if(!I)return$;returnI.reduce((z,q)=>z?.[q],$)}functionuM0($){letI=Object.keys($),z=I.map((q)=>$[q]);returnPromise.all(z).then((q)=>{letU={};for(letY=0;Y<I.length;Y++)U[I[Y]]=q[Y];returnU})}functionxM0($=10){letz=Line truncated
`)}var Qb=($,I)=>{$.name="$ZodError",Object.defineProperty($,"_zod",{value:$._zod,enumerable:!1}),Object.defineProperty($,"issues",{value:I,enumerable:!1}),$.message=JSON.stringify(I,rI,2),Object.defineProperty($,"toString",{value:()=>$.message,enumerable:!1})},gY,z$;var yF=K0(()=>{U3();C0();gY=t("$ZodError",Qb),z$=t("$ZodError",Qb,{Parent:Error})});var sI=($)=>(I,z,q,U)=>{let Y=q?{...q,async:!1}:{async:!1},J=I._zod.run({value:z,issues:[]},Y);if(J instanceof Promise)throw new S8;if(J.issues.length){let Q=new(U?.Err??$)(J.issues.map((K)=>b6(K,Y,E4())));throw iw(Q,U?.callee),Q}return J.value},hY,eI=($)=>async(I,z,q,U)=>{let Y=q?{...q,async:!0}:{async:!0},J=I._zod.run({value:z,issues:[]},Y);if(J instanceof Promise)J=await J;if(J.issues.length){let Q=new(U?.Err??$)(J.issues.map((K)=>b6(K,Y,E4())));throw iw(Q,U?.callee),Q}return J.value},SY,$z=($)=>(I,z,q)=>{let U=q?{...q,async:!1}:{async:!1},Y=I._zod.run({value:z,issues:[]},U);if(Y instanceof Promise)throw new S8;return Y.issues.length?{success:!1,error:new($??gY)(Y.issues.map((J)=>b6(J,U,E4())))}:{success:!0,data:Y.value}},Iz,zz=($)=>async(I,z,q)=>{let U=q?{...q,async:!0}:{async:!0},Y=I._zod.run({value:z,issues:[]},U);if(Y instanceof Promise)Y=await Y;return Y.issues.length?{success:!1,error:new $(Y.issues.map((J)=>b6(J,U,E4())))}:{success:!0,data:Y.value}},yY,pw=($)=>(I,z,q)=>{let U=q?{...q,direction:"backward"}:{direction:"backward"};return sI($)(I,z,U)},wb,cw=($)=>(I,z,q)=>{return sI($)(I,z,q)},Gb,dw=($)=>async(I,z,q)=>{let U=q?{...q,direction:"backward"}:{direction:"backward"};return eI($)(I,z,U)},Hb,mw=($)=>async(I,z,q)=>{return eI($)(I,z,q)},Wb,lw=($)=>(I,z,q)=>{let U=q?{...q,direction:"backward"}:{direction:"backward"};return $z($)(I,z,U)},Vb,ow=($)=>(I,z,q)=>{return $z($)(I,z,q)},Zb,rw=($)=>async(I,z,q)=>{let U=q?{...q,direction:"backward"}:{direction:"backward"};return zz($)(I,z,U)},Xb,tw=($)=>async(I,z,q)=>{return zz($)(I,z,q)},Lb;var uF=K0(()=>{U3();yF();C0();hY=sI(z$),SY=eI(z$),Iz=$z(z$),yY=zz(z$),wb=pw(z$),Gb=cw(z$),Hb=dw(z$),Wb=mw(z$),Vb=lw(z$),Zb=ow(z$),Xb=rw(z$),Lb=tw(z$)});var P$={};A$(P$,{xid:()=>bF,uuid7:()=>qA0,uuid6:()=>zA0,uuid4:()=>IA0,uuid:()=>J3,uppercase:()=>HN,unicodeEmail:()=>Ob,undefined:()=>wN,ulid:()=>fF,time:()=>zN,string:()=>UN,sha512_hex:()=>TA0,sha512_base64url:()=>BA0,sha512_base64:()=>EA0,sha384_hex:()=>MA0,sha384_base64url:()=>PA0,sha384_base64:()=>AA0,sha256_hex:()=>DA0,sha256_base64url:()=>NA0,sha256_base64:()=>FA0,sha1_hex:()=>XA0,sha1_base64url:()=>OA0,sha1_base64:()=>LA0,rfc5322Email:()=>YA0,number:()=>uY,null:()=>KN,nanoid:()=>iF,md5_hex:()=>WA0,md5_base64url:()=>ZA0,md5_base64:()=>VA0,mac:()=>rF,lowercase:()=>GN,ksuid:()=>nF,ipv6:()=>oF,ipv4:()=>lF,integer:()=>JN,idnEmail:()=>JA0,httpProtocol:()=>eF,html5Email:()=>UA0,hostname:()=>wA0,hex:()=>HA0,guid:()=>cF,extendedDuration:()=>$A0,emoji:()=>mF,email:()=>dF,e164:()=>$N,duration:()=>pF,domain:()=>GA0,datetime:()=>qN,date:()=>IN,cuid2:()=>kF,cuid:()=>xF,cidrv6:()=>aF,cidrv4:()=>tF,browserEmail:()=>QA0,boolean:()=>QN,bigint:()=>YN,base64url:()=>aw,base64:()=>sF});function mF(){return new RegExp(KA0,"u")}function Fb($){return typeof $.precision==="number"?$.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":$.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${$.precision}}`:"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function zN($){return new RegExp(`^${Fb($)}$`)}function qN($){let I=Fb({precision:$.precision}),z=["Z"];if($.local)z.push("");if($.offset)z.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let q=`${I}(?:${z.join("|")})`;return new RegExp(`^${Db}T(?:${q})$`)}function xY($,I){return new RegExp(`^[A-Za-z0-9+/]{${$}}${I}$`)}function kY($){return new RegExp(`^[A-Za-z0-9_-]{${$}}$`)}var xF,kF,fF,bF,nF,iF,pF,$A0,cF,J3=($)=>{if(!$)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;returnnewRegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${$}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},IA0,zA0,qA0,dF,UA0,YA0,Ob,JA0,QA0,KA0="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",lF,oF,rF=($)=>{letI=c$($??":");returnnewRegExp(`^(?:[0-9A-F]{2}${I}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${I}){5}[0-9a-f]{2}$`)},tF,aF,sF,aw,wA0,GA0,eF,$N,Db="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",IN,UN=($)=>{letI=$?`[\\s\\S]{${$?.minimum??0},${$?.maximum??""}}`:"[\\s\\S]*";returnnewRegExp(`^${I}$`)},YN,JN,uY,QN,KN,wN,GN,HN,HA0,WA0,VA0,ZA0,XA0,LA0,OA0,DA0,FA0,NA0,MA0,AA0,PA0,TA0,EA0,BA0;varsw=K0(()=>{C0();xF=/^[cC][0-9a-z]{6,}$/,kF=/^[0-9a-z]+$/,fF=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,bF=/^[0-9a-vA-V]{20}$/,nF=/^[A-Za-z0-9]{27}$/,iF=/^[a-zA-Z0-9_-]{21}$/,pF=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\dLine truncated
`).filter((Y)=>Y),q=Math.min(...z.map((Y)=>Y.length-Y.trimStart().length)),U=z.map((Y)=>Y.slice(q)).map((Y)=>" ".repeat(this.indent*2)+Y);for(let Y of U)this.content.push(Y)}compile(){let $=Function,I=this?.args,q=[...(this?.content??[""]).map((U)=>`${U}`)];return new $(...I,q.join(`
`))}}var gN;var _N=K0(()=>{gN={major:4,minor:4,patch:3}});function eN($){if($==="")return!0;if(/\s/.test($))return!1;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}function ub($){if(!aw.test($))return!1;let I=$.replace(/[-_]/g,(q)=>q==="-"?"+":"/"),z=I.padEnd(Math.ceil(I.length/4)*4,"=");return eN(z)}function xb($,I=null){try{let z=$.split(".");if(z.length!==3)return!1;let[q]=z;if(!q)return!1;let U=JSON.parse(atob(q));if("typ"in U&&U?.typ!=="JWT")return!1;if(!U.alg)return!1;if(I&&(!("alg"in U)||U.alg!==I))return!1;return!0}catch{return!1}}function Ab($,I,z){if($.issues.length)I.issues.push(...I$(z,$.issues));I.value[z]=$.value}function JG($,I,z,q,U,Y){let J=z in q;if($.issues.length){if(U&&Y&&!J)return;I.issues.push(...I$(z,$.issues))}if(!J&&!U){if(!$.issues.length)I.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[z]});return}if($.value===void 0){if(J)I.value[z]=void 0}else I.value[z]=$.value}function kb($){let I=Object.keys($.shape);for(let q of I)if(!$.shape?.[q]?._zod?.traits?.has("$ZodType"))throw Error(`Invalidelementatkey"${q}":expectedaZodschema`);let z=RF($.shape);return{...$,keys:I,keySet:new Set(I),numKeys:I.length,optionalKeys:new Set(z)}}function fb($,I,z,q,U,Y){let J=[],Q=U.keySet,K=U.catchall._zod,w=K.def.type,G=K.optin==="optional",H=K.optout==="optional";for(let W in I){if(W==="__proto__")continue;if(Q.has(W))continue;if(w==="never"){J.push(W);continue}let V=K.run({value:I[W],issues:[]},q);if(V instanceof Promise)$.push(V.then((X)=>JG(X,z,W,I,G,H)));else JG(V,z,W,I,G,H)}if(J.length)z.issues.push({code:"unrecognized_keys",keys:J,input:I,inst:Y});if(!$.length)return z;return Promise.all($).then(()=>{return z})}function Pb($,I,z,q){for(let Y of $)if(Y.issues.length===0)return I.value=Y.value,I;let U=$.filter((Y)=>!E9(Y));if(U.length===1)return I.value=U[0].value,U[0];return I.issues.push({code:"invalid_union",input:I.value,inst:z,errors:$.map((Y)=>Y.issues.map((J)=>b6(J,q,E4())))}),I}function Tb($,I,z,q){let U=$.filter((Y)=>Y.issues.length===0);if(U.length===1)return I.value=U[0].value,I;if(U.length===0)I.issues.push({code:"invalid_union",input:I.value,inst:z,errors:$.map((Y)=>Y.issues.map((J)=>b6(J,q,E4())))});else I.issues.push({code:"invalid_union",input:I.value,inst:z,errors:[],inclusive:!1});return I}function CN($,I){if($===I)return{valid:!0,data:$};if($ instanceof Date&&I instanceof Date&&+$===+I)return{valid:!0,data:$};if(T9($)&&T9(I)){let z=Object.keys(I),q=Object.keys($).filter((Y)=>z.indexOf(Y)!==-1),U={...$,...I};for(let Y of q){let J=CN($[Y],I[Y]);if(!J.valid)return{valid:!1,mergeErrorPath:[Y,...J.mergeErrorPath]};U[Y]=J.data}return{valid:!0,data:U}}if(Array.isArray($)&&Array.isArray(I)){if($.length!==I.length)return{valid:!1,mergeErrorPath:[]};let z=[];for(let q=0;q<$.length;q++){let U=$[q],Y=I[q],J=CN(U,Y);if(!J.valid)return{valid:!1,mergeErrorPath:[q,...J.mergeErrorPath]};z.push(J.data)}return{valid:!0,data:z}}return{valid:!1,mergeErrorPath:[]}}function Eb($,I,z){let q=new Map,U;for(let Q of I.issues)if(Q.code==="unrecognized_keys"){U??(U=Q);for(let K of Q.keys){if(!q.has(K))q.set(K,{});q.get(K).l=!0}}else $.issues.push(Q);for(let Q of z.issues)if(Q.code==="unrecognized_keys")for(let K of Q.keys){if(!q.has(K))q.set(K,{});q.get(K).r=!0}else $.issues.push(Q);let Y=[...q].filter(([,Q])=>Q.l&&Q.r).map(([Q])=>Q);if(Y.length&&U)$.issues.push({...U,keys:Y});if(E9($))return $;let J=CN(I.value,z.value);if(!J.valid)throw Error(`Unmergableintersection.Errorpath:${JSON.stringify(J.mergeErrorPath)}`);return $.value=J.data,$}function Bb($,I){for(let z=$.length-1;z>=0;z--)if($[z]._zod[I]!=="optional")return z+1;return 0}function jb($,I,z){if($.issues.length)I.issues.push(...I$(z,$.issues));I.value[z]=$.value}function vb($,I,z,q,U){for(let Y=0;Y<z.length;Y++){let J=$[Y],Q=Y<q.length;if(J.issues.length){if(!Q&&Y>=U){I.value.length=Y;break}I.issues.push(...I$(Y,J.issues))}I.value[Y]=J.value}for(let Y=I.value.length-1;Y>=q.length;Y--)if(z[Y]._zod.optout==="optional"&&I.value[Y]===void 0)I.value.length=Y;else break;return I}function Rb($,I,z,q,U,Y,J){if($.issues.length)if(jY.has(typeof q))z.issues.push(...I$(q,$.issues));else z.issues.push({code:"invalid_key",origin:"map",input:U,inst:Y,issues:$.issues.map((Q)=>b6(Q,J,E4()))});if(I.issues.length)if(jY.has(typeof q))z.issues.push(...I$(q,I.issues));else z.issues.push({origin:"map",code:"invalid_element",input:U,inst:Y,key:q,issues:I.issues.map((Q)=>b6(Q,J,E4()))});z.value.set($.value,I.value)}function gb($,I){if($.issues.length)I.issues.push(...$.issues);I.value.add($.value)}function _b($,I){if(I===void 0&&($.issues.length||$.fallback))return{issues:[],value:void 0};return $}function Cb($,I){if($.value===void 0)$.value=I.defaultValue;return $}function hb($,I){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:I});return $}function qG($,I,z){if($.issues.length)return $.aborted=!0,$;return I._zod.run({value:$.value,issues:$.issues,f
Line truncated
`))}}var gN;var _N=K0(()=>{gN={major:4,minor:4,patch:3}});function eN($){if($==="")return!0;if(/\s/.test($))return!1;if($.length%4!==0)return!1;try{return atob($),!0}catch{return!1}}function xb($){if(!aw.test($))return!1;let I=$.replace(/[-_]/g,(q)=>q==="-"?"+":"/"),z=I.padEnd(Math.ceil(I.length/4)*4,"=");return eN(z)}function kb($,I=null){try{let z=$.split(".");if(z.length!==3)return!1;let[q]=z;if(!q)return!1;let U=JSON.parse(atob(q));if("typ"in U&&U?.typ!=="JWT")return!1;if(!U.alg)return!1;if(I&&(!("alg"in U)||U.alg!==I))return!1;return!0}catch{return!1}}function Pb($,I,z){if($.issues.length)I.issues.push(...I$(z,$.issues));I.value[z]=$.value}function JG($,I,z,q,U,Y){let J=z in q;if($.issues.length){if(U&&Y&&!J)return;I.issues.push(...I$(z,$.issues))}if(!J&&!U){if(!$.issues.length)I.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[z]});return}if($.value===void 0){if(J)I.value[z]=void 0}else I.value[z]=$.value}function fb($){let I=Object.keys($.shape);for(let q of I)if(!$.shape?.[q]?._zod?.traits?.has("$ZodType"))throw Error(`Invalidelementatkey"${q}":expectedaZodschema`);let z=RF($.shape);return{...$,keys:I,keySet:new Set(I),numKeys:I.length,optionalKeys:new Set(z)}}function bb($,I,z,q,U,Y){let J=[],Q=U.keySet,K=U.catchall._zod,w=K.def.type,G=K.optin==="optional",H=K.optout==="optional";for(let W in I){if(W==="__proto__")continue;if(Q.has(W))continue;if(w==="never"){J.push(W);continue}let V=K.run({value:I[W],issues:[]},q);if(V instanceof Promise)$.push(V.then((X)=>JG(X,z,W,I,G,H)));else JG(V,z,W,I,G,H)}if(J.length)z.issues.push({code:"unrecognized_keys",keys:J,input:I,inst:Y});if(!$.length)return z;return Promise.all($).then(()=>{return z})}function Tb($,I,z,q){for(let Y of $)if(Y.issues.length===0)return I.value=Y.value,I;let U=$.filter((Y)=>!E9(Y));if(U.length===1)return I.value=U[0].value,U[0];return I.issues.push({code:"invalid_union",input:I.value,inst:z,errors:$.map((Y)=>Y.issues.map((J)=>b6(J,q,E4())))}),I}function Eb($,I,z,q){let U=$.filter((Y)=>Y.issues.length===0);if(U.length===1)return I.value=U[0].value,I;if(U.length===0)I.issues.push({code:"invalid_union",input:I.value,inst:z,errors:$.map((Y)=>Y.issues.map((J)=>b6(J,q,E4())))});else I.issues.push({code:"invalid_union",input:I.value,inst:z,errors:[],inclusive:!1});return I}function CN($,I){if($===I)return{valid:!0,data:$};if($ instanceof Date&&I instanceof Date&&+$===+I)return{valid:!0,data:$};if(T9($)&&T9(I)){let z=Object.keys(I),q=Object.keys($).filter((Y)=>z.indexOf(Y)!==-1),U={...$,...I};for(let Y of q){let J=CN($[Y],I[Y]);if(!J.valid)return{valid:!1,mergeErrorPath:[Y,...J.mergeErrorPath]};U[Y]=J.data}return{valid:!0,data:U}}if(Array.isArray($)&&Array.isArray(I)){if($.length!==I.length)return{valid:!1,mergeErrorPath:[]};let z=[];for(let q=0;q<$.length;q++){let U=$[q],Y=I[q],J=CN(U,Y);if(!J.valid)return{valid:!1,mergeErrorPath:[q,...J.mergeErrorPath]};z.push(J.data)}return{valid:!0,data:z}}return{valid:!1,mergeErrorPath:[]}}function Bb($,I,z){let q=new Map,U;for(let Q of I.issues)if(Q.code==="unrecognized_keys"){U??(U=Q);for(let K of Q.keys){if(!q.has(K))q.set(K,{});q.get(K).l=!0}}else $.issues.push(Q);for(let Q of z.issues)if(Q.code==="unrecognized_keys")for(let K of Q.keys){if(!q.has(K))q.set(K,{});q.get(K).r=!0}else $.issues.push(Q);let Y=[...q].filter(([,Q])=>Q.l&&Q.r).map(([Q])=>Q);if(Y.length&&U)$.issues.push({...U,keys:Y});if(E9($))return $;let J=CN(I.value,z.value);if(!J.valid)throw Error(`Unmergableintersection.Errorpath:${JSON.stringify(J.mergeErrorPath)}`);return $.value=J.data,$}function jb($,I){for(let z=$.length-1;z>=0;z--)if($[z]._zod[I]!=="optional")return z+1;return 0}function vb($,I,z){if($.issues.length)I.issues.push(...I$(z,$.issues));I.value[z]=$.value}function Rb($,I,z,q,U){for(let Y=0;Y<z.length;Y++){let J=$[Y],Q=Y<q.length;if(J.issues.length){if(!Q&&Y>=U){I.value.length=Y;break}I.issues.push(...I$(Y,J.issues))}I.value[Y]=J.value}for(let Y=I.value.length-1;Y>=q.length;Y--)if(z[Y]._zod.optout==="optional"&&I.value[Y]===void 0)I.value.length=Y;else break;return I}function gb($,I,z,q,U,Y,J){if($.issues.length)if(jY.has(typeof q))z.issues.push(...I$(q,$.issues));else z.issues.push({code:"invalid_key",origin:"map",input:U,inst:Y,issues:$.issues.map((Q)=>b6(Q,J,E4()))});if(I.issues.length)if(jY.has(typeof q))z.issues.push(...I$(q,I.issues));else z.issues.push({origin:"map",code:"invalid_element",input:U,inst:Y,key:q,issues:I.issues.map((Q)=>b6(Q,J,E4()))});z.value.set($.value,I.value)}function _b($,I){if($.issues.length)I.issues.push(...$.issues);I.value.add($.value)}function Cb($,I){if(I===void 0&&($.issues.length||$.fallback))return{issues:[],value:void 0};return $}function hb($,I){if($.value===void 0)$.value=I.defaultValue;return $}function Sb($,I){if(!$.issues.length&&$.value===void 0)$.issues.push({code:"invalid_type",expected:"nonoptional",input:$.value,inst:I});return $}function qG($,I,z){if($.issues.length)return $.aborted=!0,$;return I._zod.run({value:$.value,issues:$.issues,f
Line truncated
`)}V.write("payload.value = newResult;"),V.write("return payload;");let A=V.compile();return(T,M)=>A(W,T,M)},Y,J=Y3,Q=!z3.jitless,w=Q&&BF.value,G=I.catchall,H;$._zod.parse=(W,V)=>{H??(H=q.value);let X=W.value;if(!J(X))return W.issues.push({expected:"object",code:"invalid_type",input:X,inst:$}),W;if(Q&&w&&V?.async===!1&&V.jitless!==!0){if(!Y)Y=U(I.shape);if(W=Y(W,V),!G)return W;return fb([],X,W,V,H,$)}return z(W,V)}});bY=r("$ZodUnion",($,I)=>{d0.init($,I),U1($._zod,"optin",()=>I.options.some((q)=>q._zod.optin==="optional")?"optional":void 0),U1($._zod,"optout",()=>I.options.some((q)=>q._zod.optout==="optional")?"optional":void 0),U1($._zod,"values",()=>{if(I.options.every((q)=>q._zod.values))return new Set(I.options.flatMap((q)=>Array.from(q._zod.values)));return}),U1($._zod,"pattern",()=>{if(I.options.every((q)=>q._zod.pattern)){let q=I.options.map((U)=>U._zod.pattern);return new RegExp(`^(${q.map((U)=>BY(U.source)).join("|")})$`)}return});let z=I.options.length===1?I.options[0]._zod.run:null;$._zod.parse=(q,U)=>{if(z)return z(q,U);let Y=!1,J=[];for(let Q of I.options){let K=Q._zod.run({value:q.value,issues:[]},U);if(K instanceof Promise)J.push(K),Y=!0;else{if(K.issues.length===0)return K;J.push(K)}}if(!Y)return Pb(J,q,$,U);return Promise.all(J).then((Q)=>{return Pb(Q,q,$,U)})}});DM=r("$ZodXor",($,I)=>{bY.init($,I),I.inclusive=!1;let z=I.options.length===1?I.options[0]._zod.run:null;$._zod.parse=(q,U)=>{if(z)return z(q,U);let Y=!1,J=[];for(let Q of I.options){let K=Q._zod.run({value:q.value,issues:[]},U);if(K instanceof Promise)J.push(K),Y=!0;else J.push(K)}if(!Y)return Tb(J,q,$,U);return Promise.all(J).then((Q)=>{return Tb(Q,q,$,U)})}}),OM=r("$ZodDiscriminatedUnion",($,I)=>{I.inclusive=!1,bY.init($,I);let z=$._zod.parse;U1($._zod,"propValues",()=>{let U={};for(let Y of I.options){let J=Y._zod.propValues;if(!J||Object.keys(J).length===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${I.options.indexOf(Y)}"`);for(let[Q,K]of Object.entries(J)){if(!U[Q])U[Q]=new Set;for(let w of K)U[Q].add(w)}}return U});let q=tI(()=>{let U=I.options,Y=new Map;for(let J of U){let Q=J._zod.propValues?.[I.discriminator];if(!Q||Q.size===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${I.options.indexOf(J)}"`);for(let K of Q){if(Y.has(K))throw Error(`Duplicatediscriminatorvalue"${String(K)}"`);Y.set(K,J)}}return Y});$._zod.parse=(U,Y)=>{let J=U.value;if(!Y3(J))return U.issues.push({code:"invalid_type",expected:"object",input:J,inst:$}),U;let Q=q.value.get(J?.[I.discriminator]);if(Q)return Q._zod.run(U,Y);if(I.unionFallback||Y.direction==="backward")return z(U,Y);return U.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:I.discriminator,options:Array.from(q.value.keys()),input:J,path:[I.discriminator],inst:$}),U}}),FM=r("$ZodIntersection",($,I)=>{d0.init($,I),$._zod.parse=(z,q)=>{let U=z.value,Y=I.left._zod.run({value:U,issues:[]},q),J=I.right._zod.run({value:U,issues:[]},q);if(Y instanceof Promise||J instanceof Promise)return Promise.all([Y,J]).then(([K,w])=>{return Eb(z,K,w)});return Eb(z,Y,J)}});wG=r("$ZodTuple",($,I)=>{d0.init($,I);let z=I.items;$._zod.parse=(q,U)=>{let Y=q.value;if(!Array.isArray(Y))return q.issues.push({input:Y,inst:$,expected:"tuple",code:"invalid_type"}),q;q.value=[];let J=[],Q=Bb(z,"optin"),K=Bb(z,"optout");if(!I.rest){if(Y.length<Q)return q.issues.push({code:"too_small",minimum:Q,inclusive:!0,input:Y,inst:$,origin:"array"}),q;if(Y.length>z.length)q.issues.push({code:"too_big",maximum:z.length,inclusive:!0,input:Y,inst:$,origin:"array"})}let w=Array(z.length);for(let G=0;G<z.length;G++){let H=z[G]._zod.run({value:Y[G],issues:[]},U);if(H instanceof Promise)J.push(H.then((W)=>{w[G]=W}));else w[G]=H}if(I.rest){let G=z.length-1,H=Y.slice(z.length);for(let W of H){G++;let V=I.rest._zod.run({value:W,issues:[]},U);if(V instanceof Promise)J.push(V.then((X)=>jb(X,q,G)));else jb(V,q,G)}}if(J.length)return Promise.all(J).then(()=>vb(w,q,z,Y,K));return vb(w,q,z,Y,K)}});NM=r("$ZodRecord",($,I)=>{d0.init($,I),$._zod.parse=(z,q)=>{let U=z.value;if(!T9(U))return z.issues.push({expected:"record",code:"invalid_type",input:U,inst:$}),z;let Y=[],J=I.keyType._zod.values;if(J){z.value={};let Q=new Set;for(let w of J)if(typeof w==="string"||typeof w==="number"||typeof w==="symbol"){Q.add(typeof w==="number"?w.toString():w);let G=I.keyType._zod.run({value:w,issues:[]},q);if(G instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(G.issues.length){z.issues.push({code:"invalid_key",origin:"record",issues:G.issues.map((V)=>b6(V,q,E4())),input:w,path:[w],inst:$});continue}let H=G.value,W=I.valueType._zod.run({value:U[w],issues:[]},q);if(W instanceof Promise)Y.push(W.then((V)=>{if(V.issues.length)z.issues.push(...I$(w,V.issues));z.value[H]=V.value}));else{if(W.issues.length)z.issues.push(...I$(w,W.issues));z.value[H]=W.value}}let K;for(let w in U)if(!Q.has(w))K=K??[],K.push(w);if(K&&K.length>0)z.issues.push({code:"unrecognize
Line truncated
`)}V.write("payload.value = newResult;"),V.write("return payload;");let A=V.compile();return(T,M)=>A(W,T,M)},Y,J=Y3,Q=!z3.jitless,w=Q&&BF.value,G=I.catchall,H;$._zod.parse=(W,V)=>{H??(H=q.value);let X=W.value;if(!J(X))return W.issues.push({expected:"object",code:"invalid_type",input:X,inst:$}),W;if(Q&&w&&V?.async===!1&&V.jitless!==!0){if(!Y)Y=U(I.shape);if(W=Y(W,V),!G)return W;return bb([],X,W,V,H,$)}return z(W,V)}});bY=t("$ZodUnion",($,I)=>{d0.init($,I),Y1($._zod,"optin",()=>I.options.some((q)=>q._zod.optin==="optional")?"optional":void 0),Y1($._zod,"optout",()=>I.options.some((q)=>q._zod.optout==="optional")?"optional":void 0),Y1($._zod,"values",()=>{if(I.options.every((q)=>q._zod.values))return new Set(I.options.flatMap((q)=>Array.from(q._zod.values)));return}),Y1($._zod,"pattern",()=>{if(I.options.every((q)=>q._zod.pattern)){let q=I.options.map((U)=>U._zod.pattern);return new RegExp(`^(${q.map((U)=>BY(U.source)).join("|")})$`)}return});let z=I.options.length===1?I.options[0]._zod.run:null;$._zod.parse=(q,U)=>{if(z)return z(q,U);let Y=!1,J=[];for(let Q of I.options){let K=Q._zod.run({value:q.value,issues:[]},U);if(K instanceof Promise)J.push(K),Y=!0;else{if(K.issues.length===0)return K;J.push(K)}}if(!Y)return Tb(J,q,$,U);return Promise.all(J).then((Q)=>{return Tb(Q,q,$,U)})}});OM=t("$ZodXor",($,I)=>{bY.init($,I),I.inclusive=!1;let z=I.options.length===1?I.options[0]._zod.run:null;$._zod.parse=(q,U)=>{if(z)return z(q,U);let Y=!1,J=[];for(let Q of I.options){let K=Q._zod.run({value:q.value,issues:[]},U);if(K instanceof Promise)J.push(K),Y=!0;else J.push(K)}if(!Y)return Eb(J,q,$,U);return Promise.all(J).then((Q)=>{return Eb(Q,q,$,U)})}}),DM=t("$ZodDiscriminatedUnion",($,I)=>{I.inclusive=!1,bY.init($,I);let z=$._zod.parse;Y1($._zod,"propValues",()=>{let U={};for(let Y of I.options){let J=Y._zod.propValues;if(!J||Object.keys(J).length===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${I.options.indexOf(Y)}"`);for(let[Q,K]of Object.entries(J)){if(!U[Q])U[Q]=new Set;for(let w of K)U[Q].add(w)}}return U});let q=tI(()=>{let U=I.options,Y=new Map;for(let J of U){let Q=J._zod.propValues?.[I.discriminator];if(!Q||Q.size===0)throw Error(`Invaliddiscriminatedunionoptionatindex"${I.options.indexOf(J)}"`);for(let K of Q){if(Y.has(K))throw Error(`Duplicatediscriminatorvalue"${String(K)}"`);Y.set(K,J)}}return Y});$._zod.parse=(U,Y)=>{let J=U.value;if(!Y3(J))return U.issues.push({code:"invalid_type",expected:"object",input:J,inst:$}),U;let Q=q.value.get(J?.[I.discriminator]);if(Q)return Q._zod.run(U,Y);if(I.unionFallback||Y.direction==="backward")return z(U,Y);return U.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:I.discriminator,options:Array.from(q.value.keys()),input:J,path:[I.discriminator],inst:$}),U}}),FM=t("$ZodIntersection",($,I)=>{d0.init($,I),$._zod.parse=(z,q)=>{let U=z.value,Y=I.left._zod.run({value:U,issues:[]},q),J=I.right._zod.run({value:U,issues:[]},q);if(Y instanceof Promise||J instanceof Promise)return Promise.all([Y,J]).then(([K,w])=>{return Bb(z,K,w)});return Bb(z,Y,J)}});wG=t("$ZodTuple",($,I)=>{d0.init($,I);let z=I.items;$._zod.parse=(q,U)=>{let Y=q.value;if(!Array.isArray(Y))return q.issues.push({input:Y,inst:$,expected:"tuple",code:"invalid_type"}),q;q.value=[];let J=[],Q=jb(z,"optin"),K=jb(z,"optout");if(!I.rest){if(Y.length<Q)return q.issues.push({code:"too_small",minimum:Q,inclusive:!0,input:Y,inst:$,origin:"array"}),q;if(Y.length>z.length)q.issues.push({code:"too_big",maximum:z.length,inclusive:!0,input:Y,inst:$,origin:"array"})}let w=Array(z.length);for(let G=0;G<z.length;G++){let H=z[G]._zod.run({value:Y[G],issues:[]},U);if(H instanceof Promise)J.push(H.then((W)=>{w[G]=W}));else w[G]=H}if(I.rest){let G=z.length-1,H=Y.slice(z.length);for(let W of H){G++;let V=I.rest._zod.run({value:W,issues:[]},U);if(V instanceof Promise)J.push(V.then((X)=>vb(X,q,G)));else vb(V,q,G)}}if(J.length)return Promise.all(J).then(()=>Rb(w,q,z,Y,K));return Rb(w,q,z,Y,K)}});NM=t("$ZodRecord",($,I)=>{d0.init($,I),$._zod.parse=(z,q)=>{let U=z.value;if(!T9(U))return z.issues.push({expected:"record",code:"invalid_type",input:U,inst:$}),z;let Y=[],J=I.keyType._zod.values;if(J){z.value={};let Q=new Set;for(let w of J)if(typeof w==="string"||typeof w==="number"||typeof w==="symbol"){Q.add(typeof w==="number"?w.toString():w);let G=I.keyType._zod.run({value:w,issues:[]},q);if(G instanceof Promise)throw Error("Async schemas not supported in object keys currently");if(G.issues.length){z.issues.push({code:"invalid_key",origin:"record",issues:G.issues.map((V)=>b6(V,q,E4())),input:w,path:[w],inst:$});continue}let H=G.value,W=I.valueType._zod.run({value:U[w],issues:[]},q);if(W instanceof Promise)Y.push(W.then((V)=>{if(V.issues.length)z.issues.push(...I$(w,V.issues));z.value[H]=V.value}));else{if(W.issues.length)z.issues.push(...I$(w,W.issues));z.value[H]=W.value}}let K;for(let w in U)if(!Q.has(w))K=K??[],K.push(w);if(K&&K.length>0)z.issues.push({code:"unrecognize
Line truncated
Setthe\`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(letJof$.seen.entries()){letQ=J[1];if(I===J[0]){Y(J);continue}if($.external){letw=$.external.registry.get(J[0])?.id;if(I!==J[0]&&w){Y(J);continue}}if($.metadataRegistry.get(J[0])?.id){Y(J);continue}if(Q.cycle){Y(J);continue}if(Q.count>1){if($.reused==="ref"){Y(J);continue}}}}functiong9($,I){letz=$.seen.get(I);if(!z)throwError("Unprocessed schema. This is a bug in Zod.");letq=(Q)=>{letK=$.seen.get(Q);if(K.ref===null)return;letw=K.def??K.schema,G={...w},H=K.ref;if(K.ref=null,H){q(H);letV=$.seen.get(H),X=V.schema;if(X.$ref&&($.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"))w.allOf=w.allOf??[],w.allOf.push(X);elseObject.assign(w,X);if(Object.assign(w,G),Q._zod.parent===H)for(letDinw){if(D==="$ref"||D==="allOf")continue;if(!(DinG))deletew[D]}if(X.$ref&&V.def)for(letDinw){if(D==="$ref"||D==="allOf")continue;if(DinV.def&&JSON.stringify(w[D])===JSON.stringify(V.def[D]))deletew[D]}}letW=Q._zod.parent;if(W&&W!==H){q(W);letV=$.seen.get(W);if(V?.schema.$ref){if(w.$ref=V.schema.$ref,V.def)for(letXinw){if(X==="$ref"||X==="allOf")continue;if(XinV.def&&JSON.stringify(w[X])===JSON.stringify(V.def[X]))deletew[X]}}}$.override({zodSchema:Q,jsonSchema:w,path:K.path??[]})};for(letQof[...$.seen.entries()].reverse())q(Q[0]);letU={};if($.target==="draft-2020-12")U.$schema="https://json-schema.org/draft/2020-12/schema";elseif($.target==="draft-07")U.$schema="http://json-schema.org/draft-07/schema#";elseif($.target==="draft-04")U.$schema="http://json-schema.org/draft-04/schema#";elseif($.target==="openapi-3.0");if($.external?.uri){letQ=$.external.registry.get(I)?.id;if(!Q)throwError("Schema is missing an `id` property");U.$id=$.external.uri(Q)}Object.assign(U,z.def??z.schema);letY=$.metadataRegistry.get(I)?.id;if(Y!==void0&&U.id===Y)deleteU.id;letJ=$.external?.defs??{};for(letQof$.seen.entries()){letK=Q[1];if(K.def&&K.defId){if(K.def.id===K.defId)deleteK.def.id;J[K.defId]=K.def}}if($.external);elseif(Object.keys(J).length>0)if($.target==="draft-2020-12")U.$defs=J;elseU.definitions=J;try{letQ=JSON.parse(JSON.stringify(U));returnObject.defineProperty(Q,"~standard",{value:{...I["~standard"],jsonSchema:{input:Oz(I,"input",$.processors),output:Oz(I,"output",$.processors)}},enumerable:!1,writable:!1}),Q}catch(Q){throwError("Error converting schema to JSON.")}}functioni6($,I){letz=I??{seen:newSet};if(z.seen.has($))return!1;z.seen.add($);letq=$._zod.def;if(q.type==="transform")return!0;if(q.type==="array")returni6(q.element,z);if(q.type==="set")returni6(q.valueType,z);if(q.type==="lazy")returni6(q.getter(),z);if(q.type==="promise"||q.type==="optional"||q.type==="nonoptional"||q.type==="nullable"||q.type==="readonly"||q.type==="default"||q.type==="prefault")returni6(q.innerType,z);if(q.type==="intersection")returni6(q.left,z)||i6(q.right,z);if(q.type==="record"||q.type==="map")returni6(q.keyType,z)||i6(q.valueType,z);if(q.type==="pipe"){if($._zod.traits.has("$ZodCodec"))return!0;returni6(q.in,z)||i6(q.out,z)}if(q.type==="object"){for(letUinq.shape)if(i6(q.shape[U],z))return!0;return!1}if(q.type==="union"){for(letUofq.options)if(i6(U,z))return!0;return!1}if(q.type==="tuple"){for(letUofq.items)if(i6(U,z))return!0;if(q.rest&&i6(q.rest,z))return!0;return!1}return!1}vargP=($,I={})=>(z)=>{letq=v9({...z,processors:I});returnx1($,q),R9(q,$),g9(q,$)},Oz=($,I,z={})=>(q)=>{let{libraryOptions:U,target:Y}=q??{},J=v9({...U??{},target:Y,io:I,processors:z});returnx1($,J),R9(J,$),g9(J,$)};vartY=K0(()=>{lY()});functionnG($,I){if("_idmap"in$){letq=$,U=v9({...I,processors:kG}),Y={};for(letKofq._idmap.entries()){let[w,G]=K;x1(G,U)}letJ={},Q={registry:q,uri:I?.uri,defs:Y};U.external=Q;for(letKofq._idmap.entries()){let[w,G]=K;R9(U,G),J[w]=g9(U,G)}if(Object.keys(Y).length>0){letK=U.target==="draft-2020-12"?"$defs":"definitions";J.__shared={[K]:Y}}return{schemas:J}}letz=v9({...I,processors:kG});returnx1($,z),R9(z,$),g9(z,$)}varoP0,_P=($,I,z,q)=>{letU=z;U.type="string";let{minimum:Y,maximum:J,format:Q,patterns:K,contentEncoding:w}=$._zod.bag;if(typeofY==="number")U.minLength=Y;if(typeofJ==="number")U.maxLength=J;if(Q){if(U.format=oP0[Q]??Q,U.format==="")deleteU.format;if(Q==="time")deleteU.format}if(w)U.contentEncoding=w;if(K&&K.size>0){letG=[...K];if(G.length===1)U.pattern=G[0].source;elseif(G.length>1)U.allOf=[...G.map((H)=>({...I.target==="draft-07"||I.target==="draft-04"||I.target==="openapi-3.0"?{type:"string"}:{},pattern:H.source}))]}},CP=($,I,z,q)=>{letU=z,{minimum:Y,maximum:J,format:Q,multipleOf:K,exclusiveMaximum:w,exclusiveMinimum:G}=$._zod.bag;if(typeofQ==="string"&&Q.includes("int"))U.type="integer";elseU.type="number";letH=typeofG==="number"&&G>=(Y??Number.NEGATIVE_INFINITY),W=typeofw==="number"&&w<=(J??Number.POSITIVE_INFINITY),V=I.target==="draft-04"||I.target==="openapi-3.0";if(H)if(V)U.minimum=G,U.exclusiveMinimum=!0;elseU.exclusiveMinimLine truncated
Setthe\`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(letJof$.seen.entries()){letQ=J[1];if(I===J[0]){Y(J);continue}if($.external){letw=$.external.registry.get(J[0])?.id;if(I!==J[0]&&w){Y(J);continue}}if($.metadataRegistry.get(J[0])?.id){Y(J);continue}if(Q.cycle){Y(J);continue}if(Q.count>1){if($.reused==="ref"){Y(J);continue}}}}functiong9($,I){letz=$.seen.get(I);if(!z)throwError("Unprocessed schema. This is a bug in Zod.");letq=(Q)=>{letK=$.seen.get(Q);if(K.ref===null)return;letw=K.def??K.schema,G={...w},H=K.ref;if(K.ref=null,H){q(H);letV=$.seen.get(H),X=V.schema;if(X.$ref&&($.target==="draft-07"||$.target==="draft-04"||$.target==="openapi-3.0"))w.allOf=w.allOf??[],w.allOf.push(X);elseObject.assign(w,X);if(Object.assign(w,G),Q._zod.parent===H)for(letOinw){if(O==="$ref"||O==="allOf")continue;if(!(OinG))deletew[O]}if(X.$ref&&V.def)for(letOinw){if(O==="$ref"||O==="allOf")continue;if(OinV.def&&JSON.stringify(w[O])===JSON.stringify(V.def[O]))deletew[O]}}letW=Q._zod.parent;if(W&&W!==H){q(W);letV=$.seen.get(W);if(V?.schema.$ref){if(w.$ref=V.schema.$ref,V.def)for(letXinw){if(X==="$ref"||X==="allOf")continue;if(XinV.def&&JSON.stringify(w[X])===JSON.stringify(V.def[X]))deletew[X]}}}$.override({zodSchema:Q,jsonSchema:w,path:K.path??[]})};for(letQof[...$.seen.entries()].reverse())q(Q[0]);letU={};if($.target==="draft-2020-12")U.$schema="https://json-schema.org/draft/2020-12/schema";elseif($.target==="draft-07")U.$schema="http://json-schema.org/draft-07/schema#";elseif($.target==="draft-04")U.$schema="http://json-schema.org/draft-04/schema#";elseif($.target==="openapi-3.0");if($.external?.uri){letQ=$.external.registry.get(I)?.id;if(!Q)throwError("Schema is missing an `id` property");U.$id=$.external.uri(Q)}Object.assign(U,z.def??z.schema);letY=$.metadataRegistry.get(I)?.id;if(Y!==void0&&U.id===Y)deleteU.id;letJ=$.external?.defs??{};for(letQof$.seen.entries()){letK=Q[1];if(K.def&&K.defId){if(K.def.id===K.defId)deleteK.def.id;J[K.defId]=K.def}}if($.external);elseif(Object.keys(J).length>0)if($.target==="draft-2020-12")U.$defs=J;elseU.definitions=J;try{letQ=JSON.parse(JSON.stringify(U));returnObject.defineProperty(Q,"~standard",{value:{...I["~standard"],jsonSchema:{input:Dz(I,"input",$.processors),output:Dz(I,"output",$.processors)}},enumerable:!1,writable:!1}),Q}catch(Q){throwError("Error converting schema to JSON.")}}functioni6($,I){letz=I??{seen:newSet};if(z.seen.has($))return!1;z.seen.add($);letq=$._zod.def;if(q.type==="transform")return!0;if(q.type==="array")returni6(q.element,z);if(q.type==="set")returni6(q.valueType,z);if(q.type==="lazy")returni6(q.getter(),z);if(q.type==="promise"||q.type==="optional"||q.type==="nonoptional"||q.type==="nullable"||q.type==="readonly"||q.type==="default"||q.type==="prefault")returni6(q.innerType,z);if(q.type==="intersection")returni6(q.left,z)||i6(q.right,z);if(q.type==="record"||q.type==="map")returni6(q.keyType,z)||i6(q.valueType,z);if(q.type==="pipe"){if($._zod.traits.has("$ZodCodec"))return!0;returni6(q.in,z)||i6(q.out,z)}if(q.type==="object"){for(letUinq.shape)if(i6(q.shape[U],z))return!0;return!1}if(q.type==="union"){for(letUofq.options)if(i6(U,z))return!0;return!1}if(q.type==="tuple"){for(letUofq.items)if(i6(U,z))return!0;if(q.rest&&i6(q.rest,z))return!0;return!1}return!1}vargP=($,I={})=>(z)=>{letq=v9({...z,processors:I});returnx1($,q),R9(q,$),g9(q,$)},Dz=($,I,z={})=>(q)=>{let{libraryOptions:U,target:Y}=q??{},J=v9({...U??{},target:Y,io:I,processors:z});returnx1($,J),R9(J,$),g9(J,$)};vartY=K0(()=>{lY()});functionnG($,I){if("_idmap"in$){letq=$,U=v9({...I,processors:kG}),Y={};for(letKofq._idmap.entries()){let[w,G]=K;x1(G,U)}letJ={},Q={registry:q,uri:I?.uri,defs:Y};U.external=Q;for(letKofq._idmap.entries()){let[w,G]=K;R9(U,G),J[w]=g9(U,G)}if(Object.keys(Y).length>0){letK=U.target==="draft-2020-12"?"$defs":"definitions";J.__shared={[K]:Y}}return{schemas:J}}letz=v9({...I,processors:kG});returnx1($,z),R9(z,$),g9(z,$)}varoP0,_P=($,I,z,q)=>{letU=z;U.type="string";let{minimum:Y,maximum:J,format:Q,patterns:K,contentEncoding:w}=$._zod.bag;if(typeofY==="number")U.minLength=Y;if(typeofJ==="number")U.maxLength=J;if(Q){if(U.format=oP0[Q]??Q,U.format==="")deleteU.format;if(Q==="time")deleteU.format}if(w)U.contentEncoding=w;if(K&&K.size>0){letG=[...K];if(G.length===1)U.pattern=G[0].source;elseif(G.length>1)U.allOf=[...G.map((H)=>({...I.target==="draft-07"||I.target==="draft-04"||I.target==="openapi-3.0"?{type:"string"}:{},pattern:H.source}))]}},CP=($,I,z,q)=>{letU=z,{minimum:Y,maximum:J,format:Q,multipleOf:K,exclusiveMaximum:w,exclusiveMinimum:G}=$._zod.bag;if(typeofQ==="string"&&Q.includes("int"))U.type="integer";elseU.type="number";letH=typeofG==="number"&&G>=(Y??Number.NEGATIVE_INFINITY),W=typeofw==="number"&&w<=(J??Number.POSITIVE_INFINITY),V=I.target==="draft-04"||I.target==="openapi-3.0";if(H)if(V)U.minimum=G,U.exclusiveMinimum=!0;elseU.exclusiveMinimLine truncated
`)}openNode($,I){let z=this.tos,q=this._xml;if(z&&this.open)q.push(">");this._stack.push($),q.push("<"),q.push($),Ug(q,I),this.leaf=!0,this.open=!0}addAttribute($,I){if(!this.open)throw Error("Cannot write attributes to node if it is not open");if(I!==void 0)N60(this._xml,$,I)}addAttributes($){if(!this.open)throw Error("Cannot write attributes to node if it is not open");Ug(this._xml,$)}writeText($){let I=this._xml;if(this.open)I.push(">"),this.open=!1;this.leaf=!1,I.push(F60.xmlEncode($.toString()))}writeXml($){if(this.open)this._xml.push(">"),this.open=!1;this.leaf=!1,this._xml.push($)}closeNode(){let $=this._stack.pop(),I=this._xml;if(this.leaf)I.push("/>");else I.push("</"),I.push($),I.push(">");this.open=!1,this.leaf=!1}leafNode($,I,z){if(this.openNode($,I),z!==void 0)this.writeText(z);this.closeNode()}closeAll(){while(this._stack.length)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf,open:this.open}),this.cursor}commit(){this._rollbacks.pop()}rollback(){let $=this._rollbacks.pop();if(this._xml.length>$.xml)this._xml.splice($.xml,this._xml.length-$.xml);if(this._stack.length>$.stack)this._stack.splice($.stack,this._stack.length-$.stack);this.leaf=$.leaf,this.open=$.open}get xml(){return this.closeAll(),this._xml.join("")}}Yg.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"};M60.exports=Yg});var Jg=F((Xd0)=>{var A60=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function Zd0($){if(typeof $==="string")return $;if(A60)return A60.decode($);return $.toString()}Xd0.bufferToString=Zd0});var j60=F((T60)=>{Object.defineProperty(T60,"__esModule",{value:!0});T60.CHAR=`
`)}openNode($,I){let z=this.tos,q=this._xml;if(z&&this.open)q.push(">");this._stack.push($),q.push("<"),q.push($),Ug(q,I),this.leaf=!0,this.open=!0}addAttribute($,I){if(!this.open)throw Error("Cannot write attributes to node if it is not open");if(I!==void 0)M60(this._xml,$,I)}addAttributes($){if(!this.open)throw Error("Cannot write attributes to node if it is not open");Ug(this._xml,$)}writeText($){let I=this._xml;if(this.open)I.push(">"),this.open=!1;this.leaf=!1,I.push(N60.xmlEncode($.toString()))}writeXml($){if(this.open)this._xml.push(">"),this.open=!1;this.leaf=!1,this._xml.push($)}closeNode(){let $=this._stack.pop(),I=this._xml;if(this.leaf)I.push("/>");else I.push("</"),I.push($),I.push(">");this.open=!1,this.leaf=!1}leafNode($,I,z){if(this.openNode($,I),z!==void 0)this.writeText(z);this.closeNode()}closeAll(){while(this._stack.length)this.closeNode()}addRollback(){return this._rollbacks.push({xml:this._xml.length,stack:this._stack.length,leaf:this.leaf,open:this.open}),this.cursor}commit(){this._rollbacks.pop()}rollback(){let $=this._rollbacks.pop();if(this._xml.length>$.xml)this._xml.splice($.xml,this._xml.length-$.xml);if(this._stack.length>$.stack)this._stack.splice($.stack,this._stack.length-$.stack);this.leaf=$.leaf,this.open=$.open}get xml(){return this.closeAll(),this._xml.join("")}}Yg.StdDocAttributes={version:"1.0",encoding:"UTF-8",standalone:"yes"};A60.exports=Yg});var Jg=F((Xd0)=>{var P60=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");function Zd0($){if(typeof $==="string")return $;if(P60)return P60.decode($);return $.toString()}Xd0.bufferToString=Zd0});var v60=F((E60)=>{Object.defineProperty(E60,"__esModule",{value:!0});E60.CHAR=`
`,$=this.i;break;case ym0:{let{entityReturnState:z}=this,q=this.entity+I.slice($,this.prevI);this.state=z;let U;if(q==="")this.fail("empty entity name."),U="&;";else U=this.parseEntity(q),this.entity="";if(z!==l6||this.textHandler!==void 0)this.text+=U;break $}case V4:this.entity+=I.slice($);break $;default:}}sOpenWaka(){let $=this.getCode();if(w2($))this.state=gm0,this.unget(),this.xmlDeclPossible=!1;else switch($){case BZ:this.state=hm0,this.xmlDeclPossible=!1;break;case t60:this.state=Nm0,this.openWakaBang="",this.xmlDeclPossible=!1;break;case L6:this.state=Em0;break;default:this.fail("disallowed character in tag name"),this.state=l6,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case"[CDATA[":if(!this.sawRoot&&!this.reportedTextBeforeRoot)this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0;if(this.closedRoot&&!this.reportedTextAfterRoot)this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0;this.state=Lg,this.openWakaBang="";break;case"--":this.state=Xg,this.openWakaBang="";break;case"DOCTYPE":if(this.state=Wg,this.doctype||this.sawRoot)this.fail("inappropriately located doctype declaration.");this.openWakaBang="";break;default:if(this.openWakaBang.length>=7)this.fail("incorrect syntax.")}}sComment(){if(this.captureToChar(EZ))this.state=Mm0}sCommentEnding(){var $;let I=this.getCodeNorm();if(I===EZ)this.state=Am0,($=this.commentHandler)===null||$===void 0||$.call(this,this.text),this.text="";else this.text+=`-${String.fromCodePoint(I)}`,this.state=Xg}sCommentEnded(){let $=this.getCodeNorm();if($!==m4)this.fail("malformed comment."),this.text+=`--${String.fromCodePoint($)}`,this.state=Xg;else this.state=l6}sCData(){if(this.captureToChar(hq))this.state=Pm0}sCDataEnding(){let $=this.getCodeNorm();if($===hq)this.state=Tm0;else this.text+=`]${String.fromCodePoint($)}`,this.state=Lg}sCDataEnding2(){var $;let I=this.getCodeNorm();switch(I){case m4:{($=this.cdataHandler)===null||$===void 0||$.call(this,this.text),this.text="",this.state=l6;break}case hq:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(I)}`,this.state=Lg}}sPIFirstChar(){let $=this.getCodeNorm();if(this.nameStartCheck($))this.piTarget+=String.fromCodePoint($),this.state=p60;else if($===L6||W$($))this.fail("processing instruction without a target."),this.state=$===L6?TZ:Dg;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint($),this.state=p60}sPIRest(){let{chunk:$,i:I}=this;while(!0){let z=this.getCodeNorm();if(z===V4){this.piTarget+=$.slice(I);return}if(!this.nameCheck(z)){this.piTarget+=$.slice(I,this.prevI);let q=z===L6;if(q||W$(z))if(this.piTarget==="xml"){if(!this.xmlDeclPossible)this.fail("an XML declaration must be at the start of the document.");this.state=q?i3:c60}else this.state=q?TZ:Dg;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(z);break}}}sPIBody(){if(this.text.length===0){let $=this.getCodeNorm();if($===L6)this.state=TZ;else if(!W$($))this.text=String.fromCodePoint($)}else if(this.captureToChar(L6))this.state=TZ}sPIEnding(){var $;let I=this.getCodeNorm();if(I===m4){let{piTarget:z}=this;if(z.toLowerCase()==="xml")this.fail("the XML declaration must appear at the start of the document.");($=this.piHandler)===null||$===void 0||$.call(this,{target:z,body:this.text}),this.piTarget=this.text="",this.state=l6}else if(I===L6)this.text+="?";else this.text+=`?${String.fromCodePoint(I)}`,this.state=Dg;this.xmlDeclPossible=!1}sXMLDeclNameStart(){let $=this.skipSpaces();if($===L6){this.state=i3;return}if($!==V4)this.state=Bm0,this.name=String.fromCodePoint($)}sXMLDeclName(){let $=this.captureTo(km0);if($===L6){this.state=i3,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(!(W$($)||$===Cq))return;if(this.name+=this.text,this.text="",!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail("did not expect any more name/value pairs.");break;case 1:this.fail(`expectedthename${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expectedoneof${this.xmlDeclExpects.join(", ")}`)}this.state=$===Cq?d60:jm0}sXMLDeclEq(){let $=this.getCodeNorm();if($===L6){this.state=i3,this.fail("XML declaration is incomplete.");return}if(W$($))return;if($!==Cq)this.fail("value required.");this.state=d60}sXMLDeclValueStart(){let $=this.getCodeNorm();if($===L6){this.state=i3,this.fail("XML declaration is incomplete.");return}if(W$($))return;if(!jZ($))this.fail("value must be quoted."),this.q=r60;else this.q=$;this.state=vm0}sXMLDeclValue(){let $=this.captureTo([this.q,L6]);if($===L6){this.state=i3,this.text="",this.fail("XML declaration is incomplete.");return}if($===V4)return;let I=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let z=I;if(this.xmlDecl.version=z,!/^1\.[0-9]+$/.test(z))this.fail("ver
Line truncated
`,$=this.i;break;case ym0:{let{entityReturnState:z}=this,q=this.entity+I.slice($,this.prevI);this.state=z;let U;if(q==="")this.fail("empty entity name."),U="&;";else U=this.parseEntity(q),this.entity="";if(z!==l6||this.textHandler!==void 0)this.text+=U;break $}case V4:this.entity+=I.slice($);break $;default:}}sOpenWaka(){let $=this.getCode();if(w2($))this.state=gm0,this.unget(),this.xmlDeclPossible=!1;else switch($){case BZ:this.state=hm0,this.xmlDeclPossible=!1;break;case a60:this.state=Nm0,this.openWakaBang="",this.xmlDeclPossible=!1;break;case L6:this.state=Em0;break;default:this.fail("disallowed character in tag name"),this.state=l6,this.xmlDeclPossible=!1}}sOpenWakaBang(){switch(this.openWakaBang+=String.fromCodePoint(this.getCodeNorm()),this.openWakaBang){case"[CDATA[":if(!this.sawRoot&&!this.reportedTextBeforeRoot)this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0;if(this.closedRoot&&!this.reportedTextAfterRoot)this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0;this.state=Lg,this.openWakaBang="";break;case"--":this.state=Xg,this.openWakaBang="";break;case"DOCTYPE":if(this.state=Wg,this.doctype||this.sawRoot)this.fail("inappropriately located doctype declaration.");this.openWakaBang="";break;default:if(this.openWakaBang.length>=7)this.fail("incorrect syntax.")}}sComment(){if(this.captureToChar(EZ))this.state=Mm0}sCommentEnding(){var $;let I=this.getCodeNorm();if(I===EZ)this.state=Am0,($=this.commentHandler)===null||$===void 0||$.call(this,this.text),this.text="";else this.text+=`-${String.fromCodePoint(I)}`,this.state=Xg}sCommentEnded(){let $=this.getCodeNorm();if($!==m4)this.fail("malformed comment."),this.text+=`--${String.fromCodePoint($)}`,this.state=Xg;else this.state=l6}sCData(){if(this.captureToChar(hq))this.state=Pm0}sCDataEnding(){let $=this.getCodeNorm();if($===hq)this.state=Tm0;else this.text+=`]${String.fromCodePoint($)}`,this.state=Lg}sCDataEnding2(){var $;let I=this.getCodeNorm();switch(I){case m4:{($=this.cdataHandler)===null||$===void 0||$.call(this,this.text),this.text="",this.state=l6;break}case hq:this.text+="]";break;default:this.text+=`]]${String.fromCodePoint(I)}`,this.state=Lg}}sPIFirstChar(){let $=this.getCodeNorm();if(this.nameStartCheck($))this.piTarget+=String.fromCodePoint($),this.state=c60;else if($===L6||W$($))this.fail("processing instruction without a target."),this.state=$===L6?TZ:Og;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint($),this.state=c60}sPIRest(){let{chunk:$,i:I}=this;while(!0){let z=this.getCodeNorm();if(z===V4){this.piTarget+=$.slice(I);return}if(!this.nameCheck(z)){this.piTarget+=$.slice(I,this.prevI);let q=z===L6;if(q||W$(z))if(this.piTarget==="xml"){if(!this.xmlDeclPossible)this.fail("an XML declaration must be at the start of the document.");this.state=q?i3:d60}else this.state=q?TZ:Og;else this.fail("disallowed character in processing instruction name."),this.piTarget+=String.fromCodePoint(z);break}}}sPIBody(){if(this.text.length===0){let $=this.getCodeNorm();if($===L6)this.state=TZ;else if(!W$($))this.text=String.fromCodePoint($)}else if(this.captureToChar(L6))this.state=TZ}sPIEnding(){var $;let I=this.getCodeNorm();if(I===m4){let{piTarget:z}=this;if(z.toLowerCase()==="xml")this.fail("the XML declaration must appear at the start of the document.");($=this.piHandler)===null||$===void 0||$.call(this,{target:z,body:this.text}),this.piTarget=this.text="",this.state=l6}else if(I===L6)this.text+="?";else this.text+=`?${String.fromCodePoint(I)}`,this.state=Og;this.xmlDeclPossible=!1}sXMLDeclNameStart(){let $=this.skipSpaces();if($===L6){this.state=i3;return}if($!==V4)this.state=Bm0,this.name=String.fromCodePoint($)}sXMLDeclName(){let $=this.captureTo(km0);if($===L6){this.state=i3,this.name+=this.text,this.text="",this.fail("XML declaration is incomplete.");return}if(!(W$($)||$===Cq))return;if(this.name+=this.text,this.text="",!this.xmlDeclExpects.includes(this.name))switch(this.name.length){case 0:this.fail("did not expect any more name/value pairs.");break;case 1:this.fail(`expectedthename${this.xmlDeclExpects[0]}.`);break;default:this.fail(`expectedoneof${this.xmlDeclExpects.join(", ")}`)}this.state=$===Cq?m60:jm0}sXMLDeclEq(){let $=this.getCodeNorm();if($===L6){this.state=i3,this.fail("XML declaration is incomplete.");return}if(W$($))return;if($!==Cq)this.fail("value required.");this.state=m60}sXMLDeclValueStart(){let $=this.getCodeNorm();if($===L6){this.state=i3,this.fail("XML declaration is incomplete.");return}if(W$($))return;if(!jZ($))this.fail("value must be quoted."),this.q=t60;else this.q=$;this.state=vm0}sXMLDeclValue(){let $=this.captureTo([this.q,L6]);if($===L6){this.state=i3,this.text="",this.fail("XML declaration is incomplete.");return}if($===V4)return;let I=this.text;switch(this.text="",this.name){case"version":{this.xmlDeclExpects=["encoding","standalone"];let z=I;if(this.xmlDecl.version=z,!/^1\.[0-9]+$/.test(z))this.fail("ver
Line truncated
`;$=this.i;break;case V4:if(z!==void 0)this.text+=I.slice($);break $;default:if(!W$(U))q=!0}}if(!q)return;if(!this.sawRoot&&!this.reportedTextBeforeRoot)this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0;if(this.closedRoot&&!this.reportedTextAfterRoot)this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0}pushAttribNS($,I){var z;let{prefix:q,local:U}=this.qname($),Y={name:$,prefix:q,local:U,value:I};if(this.attribList.push(Y),(z=this.attributeHandler)===null||z===void 0||z.call(this,Y),q==="xmlns"){let J=I.trim();if(this.currentXMLVersion==="1.0"&&J==="")this.fail("invalid attempt to undefine prefix in XML 1.0");this.topNS[U]=J,Pg(this,U,J)}else if($==="xmlns"){let J=I.trim();this.topNS[""]=J,Pg(this,"",J)}}pushAttribPlain($,I){var z;let q={name:$,value:I};this.attribList.push(q),(z=this.attributeHandler)===null||z===void 0||z.call(this,q)}end(){var $,I;if(!this.sawRoot)this.fail("document must contain a root element.");let{tags:z}=this;while(z.length>0){let U=z.pop();this.fail(`unclosedtag:${U.name}`)}if(this.state!==i60&&this.state!==l6)this.fail("unexpected end.");let{text:q}=this;if(q.length!==0)($=this.textHandler)===null||$===void 0||$.call(this,q),this.text="";return this._closed=!0,(I=this.endHandler)===null||I===void 0||I.call(this),this._init(),this}resolve($){var I,z;let q=this.topNS[$];if(q!==void 0)return q;let{tags:U}=this;for(let Y=U.length-1;Y>=0;Y--)if(q=U[Y].ns[$],q!==void 0)return q;if(q=this.ns[$],q!==void 0)return q;return(z=(I=this.opt).resolvePrefix)===null||z===void 0?void 0:z.call(I,$)}qname($){let I=$.indexOf(":");if(I===-1)return{prefix:"",local:$};let z=$.slice(I+1),q=$.slice(0,I);if(q===""||z===""||z.includes(":"))this.fail(`malformedname:${$}.`);return{prefix:q,local:z}}processAttribsNS(){var $;let{attribList:I}=this,z=this.tag;{let{prefix:Y,local:J}=this.qname(z.name);z.prefix=Y,z.local=J;let Q=z.uri=($=this.resolve(Y))!==null&&$!==void 0?$:"";if(Y!==""){if(Y==="xmlns")this.fail('tags may not have "xmlns" as prefix.');if(Q==="")this.fail(`unboundnamespaceprefix:${JSON.stringify(Y)}.`),z.uri=Y}}if(I.length===0)return;let{attributes:q}=z,U=new Set;for(let Y of I){let{name:J,prefix:Q,local:K}=Y,w,G;if(Q==="")w=J==="xmlns"?Sq:"",G=J;else{if(w=this.resolve(Q),w===void 0)this.fail(`unboundnamespaceprefix:${JSON.stringify(Q)}.`),w=Q;G=`{${w}}${K}`}if(U.has(G))this.fail(`duplicateattribute:${G}.`);U.add(G),Y.uri=w,q[J]=Y}this.attribList=[]}processAttribsPlain(){let{attribList:$}=this,I=this.tag.attributes;for(let{name:z,value:q}of $){if(I[z]!==void 0)this.fail(`duplicateattribute:${z}.`);I[z]=q}this.attribList=[]}openTag(){var $;this.processAttribs();let{tags:I}=this,z=this.tag;z.isSelfClosing=!1,($=this.openTagHandler)===null||$===void 0||$.call(this,z),I.push(z),this.state=l6,this.name=""}openSelfClosingTag(){var $,I,z;this.processAttribs();let{tags:q}=this,U=this.tag;if(U.isSelfClosing=!0,($=this.openTagHandler)===null||$===void 0||$.call(this,U),(I=this.closeTagHandler)===null||I===void 0||I.call(this,U),(this.tag=(z=q[q.length-1])!==null&&z!==void 0?z:null)===null)this.closedRoot=!0;this.state=l6,this.name=""}closeTag(){let{tags:$,name:I}=this;if(this.state=l6,this.name="",I===""){this.fail("weird empty close tag."),this.text+="</>";return}let z=this.closeTagHandler,q=$.length;while(q-- >0){let U=this.tag=$.pop();if(this.topNS=U.ns,z===null||z===void 0||z(U),U.name===I)break;this.fail("unexpected close tag.")}if(q===0)this.closedRoot=!0;else if(q<0)this.fail(`unmatchedclosingtag:${I}.`),this.text+=`</${I}>`}parseEntity($){if($[0]!=="#"){let z=this.ENTITIES[$];if(z!==void 0)return z;return this.fail(this.isName($)?"undefined entity.":"disallowed character in entity name."),`&${$};`}let I=NaN;if($[1]==="x"&&/^#x[0-9a-f]+$/i.test($))I=parseInt($.slice(2),16);elseif(/^#[0-9]+$/.test($))I=parseInt($.slice(1),10);if(!this.isChar(I))returnthis.fail("malformed character entity."),`&${$};`;returnString.fromCodePoint(I)}}Q$0.SaxesParser=J$0});varW2=F((Ng1,w$0)=>{var{SaxesParser:dm0}=K$0(),{PassThrough:mm0}=g6(),{bufferToString:lm0}=Jg();w$0.exports=asyncfunction*($){if($.pipe&&!$[Symbol.asyncIterator])$=$.pipe(newmm0);letI=newdm0,z;I.on("error",(U)=>{z=U});letq=[];I.on("opentag",(U)=>q.push({eventType:"opentag",value:U})),I.on("text",(U)=>q.push({eventType:"text",value:U})),I.on("closetag",(U)=>q.push({eventType:"closetag",value:U}));forawait(letUof$){if(I.write(lm0(U)),z)throwz;yieldq,q=[]}}});varO0=F((Mg1,G$0)=>{varom0=W2(),rm0=X6();classuq{prepare(){}render(){}parseOpen($){}parseText($){}parseClose($){}reconcile($,I){}reset(){if(this.model=null,this.map)Object.values(this.map).forEach(($)=>{if($instanceofuq)$.reset();elseif($.xform)$.xform.reset()})}mergeModel($){this.model=Object.assign(this.model||{},$)}asyncparse($){forawait(letIof$)for(let{eventType:z,value:q}ofI)if(z==="opentag")this.parseOpen(q);elseif(z==="text")this.parseText(q);elseif(z==="closetag"){if(!this.parseClose(q.name))returnthLine truncated
]`;this.ESCAPE_REGEXP=new RegExp(I)}set headers($){this._headers=$}shouldQuote($,I){let z=I?this.formatterOptions.quoteHeaders:this.formatterOptions.quoteColumns;if(X11.default(z))return z;if(Array.isArray(z))return z[$];if(this._headers!==null)return z[this._headers[$]];return!1}format($,I,z){let q=`${L11.default($)?"":$}`.replace(/\0/g,""),{formatterOptions:U}=this;if(U.quote!==""){if(q.indexOf(U.quote)!==-1)return this.quoteField(q.replace(this.REPLACE_REGEXP,U.escapedQuote))}if(q.search(this.ESCAPE_REGEXP)!==-1||this.shouldQuote(I,z))return this.quoteField(q);return q}quoteField($){let{quote:I}=this.formatterOptions;return`${I}${$}${I}`}}oq.FieldFormatter=yz0});var s_=F((uz0)=>{Object.defineProperty(uz0,"__esModule",{value:!0});uz0.isSyncTransform=void 0;uz0.isSyncTransform=($)=>$.length===1});var fz0=F((rq)=>{var kz0=rq&&rq.__importDefault||function($){return $&&$.__esModule?$:{default:$}};Object.defineProperty(rq,"__esModule",{value:!0});rq.RowFormatter=void 0;var O11=kz0(QX()),F11=kz0(Bz0()),N11=a_(),M11=s_();class II{constructor($){if(this.rowCount=0,this.formatterOptions=$,this.fieldFormatter=new N11.FieldFormatter($),this.headers=$.headers,this.shouldWriteHeaders=$.shouldWriteHeaders,this.hasWrittenHeaders=!1,this.headers!==null)this.fieldFormatter.headers=this.headers;if($.transform)this.rowTransform=$.transform}static isRowHashArray($){if(Array.isArray($))return Array.isArray($[0])&&$[0].length===2;return!1}static isRowArray($){return Array.isArray($)&&!this.isRowHashArray($)}static gatherHeaders($){if(II.isRowHashArray($))return $.map((I)=>I[0]);if(Array.isArray($))return $;return Object.keys($)}static createTransform($){if(M11.isSyncTransform($))return(I,z)=>{let q=null;try{q=$(I)}catch(U){return z(U)}return z(null,q)};return(I,z)=>{$(I,z)}}set rowTransform($){if(!O11.default($))throw TypeError("The transform should be a function");this._rowTransform=II.createTransform($)}format($,I){this.callTransformer($,(z,q)=>{if(z)return I(z);if(!$)return I(null);let U=[];if(q){let{shouldFormatColumns:Y,headers:J}=this.checkHeaders(q);if(this.shouldWriteHeaders&&J&&!this.hasWrittenHeaders)U.push(this.formatColumns(J,!0)),this.hasWrittenHeaders=!0;if(Y){let Q=this.gatherColumns(q);U.push(this.formatColumns(Q,!1))}}return I(null,U)})}finish($){let I=[];if(this.formatterOptions.alwaysWriteHeaders&&this.rowCount===0){if(!this.headers)return $(Error("`alwaysWriteHeaders` option is set to true but `headers` option not provided."));I.push(this.formatColumns(this.headers,!0))}if(this.formatterOptions.includeEndRowDelimiter)I.push(this.formatterOptions.rowDelimiter);return $(null,I)}checkHeaders($){if(this.headers)return{shouldFormatColumns:!0,headers:this.headers};let I=II.gatherHeaders($);if(this.headers=I,this.fieldFormatter.headers=I,!this.shouldWriteHeaders)return{shouldFormatColumns:!0,headers:null};return{shouldFormatColumns:!F11.default(I,$),headers:I}}gatherColumns($){if(this.headers===null)throw Error("Headers is currently null");if(!Array.isArray($))return this.headers.map((I)=>$[I]);if(II.isRowHashArray($))return this.headers.map((I,z)=>{let q=$[z];if(q)return q[1];return""});if(II.isRowArray($)&&!this.shouldWriteHeaders)return $;return this.headers.map((I,z)=>$[z])}callTransformer($,I){if(!this._rowTransform)return I(null,$);return this._rowTransform($,I)}formatColumns($,I){let z=$.map((U,Y)=>this.fieldFormatter.format(U,Y,I)).join(this.formatterOptions.delimiter),{rowCount:q}=this;if(this.rowCount+=1,q)return[this.formatterOptions.rowDelimiter,z].join("");return z}}rq.RowFormatter=II});var bz0=F((NX)=>{Object.defineProperty(NX,"__esModule",{value:!0});NX.FieldFormatter=NX.RowFormatter=void 0;var A11=fz0();Object.defineProperty(NX,"RowFormatter",{enumerable:!0,get:function(){return A11.RowFormatter}});var P11=a_();Object.defineProperty(NX,"FieldFormatter",{enumerable:!0,get:function(){return P11.FieldFormatter}})});var e_=F((iz0)=>{Object.defineProperty(iz0,"__esModule",{value:!0});iz0.CsvFormatterStream=void 0;var E11=t("stream"),B11=bz0();class nz0 extends E11.Transform{constructor($){super({writableObjectMode:$.objectMode});this.hasWrittenBOM=!1,this.formatterOptions=$,this.rowFormatter=new B11.RowFormatter($),this.hasWrittenBOM=!$.writeBOM}transform($){return this.rowFormatter.rowTransform=$,this}_transform($,I,z){let q=!1;try{if(!this.hasWrittenBOM)this.push(this.formatterOptions.BOM),this.hasWrittenBOM=!0;this.rowFormatter.format($,(U,Y)=>{if(U)return q=!0,z(U);if(Y)Y.forEach((J)=>{this.push(Buffer.from(J,"utf8"))});return q=!0,z()})}catch(U){if(q)throw U;z(U)}}_flush($){this.rowFormatter.finish((I,z)=>{if(I)return $(I);if(z)z.forEach((q)=>{this.push(Buffer.from(q,"utf8"))});return $()})}}iz0.CsvFormatterStream=nz0});var dz0=F((j1)=>{var cz0=j1&&j1.__createBinding||(Object.create?function($,I,z,q){if(q===void 0)q=z;Object.defineProperty($,q,{enumerable:!0,get:function(){return I[z]}})}:function($,I,z,q){if(q===void 0)q=z;$[q]=I[z]}),j11=j1&&j1.__setModuleDefault||(Object.create?function($,I){Ob
Line truncated
`;$=this.i;break;case V4:if(z!==void 0)this.text+=I.slice($);break $;default:if(!W$(U))q=!0}}if(!q)return;if(!this.sawRoot&&!this.reportedTextBeforeRoot)this.fail("text data outside of root node."),this.reportedTextBeforeRoot=!0;if(this.closedRoot&&!this.reportedTextAfterRoot)this.fail("text data outside of root node."),this.reportedTextAfterRoot=!0}pushAttribNS($,I){var z;let{prefix:q,local:U}=this.qname($),Y={name:$,prefix:q,local:U,value:I};if(this.attribList.push(Y),(z=this.attributeHandler)===null||z===void 0||z.call(this,Y),q==="xmlns"){let J=I.trim();if(this.currentXMLVersion==="1.0"&&J==="")this.fail("invalid attempt to undefine prefix in XML 1.0");this.topNS[U]=J,Pg(this,U,J)}else if($==="xmlns"){let J=I.trim();this.topNS[""]=J,Pg(this,"",J)}}pushAttribPlain($,I){var z;let q={name:$,value:I};this.attribList.push(q),(z=this.attributeHandler)===null||z===void 0||z.call(this,q)}end(){var $,I;if(!this.sawRoot)this.fail("document must contain a root element.");let{tags:z}=this;while(z.length>0){let U=z.pop();this.fail(`unclosedtag:${U.name}`)}if(this.state!==p60&&this.state!==l6)this.fail("unexpected end.");let{text:q}=this;if(q.length!==0)($=this.textHandler)===null||$===void 0||$.call(this,q),this.text="";return this._closed=!0,(I=this.endHandler)===null||I===void 0||I.call(this),this._init(),this}resolve($){var I,z;let q=this.topNS[$];if(q!==void 0)return q;let{tags:U}=this;for(let Y=U.length-1;Y>=0;Y--)if(q=U[Y].ns[$],q!==void 0)return q;if(q=this.ns[$],q!==void 0)return q;return(z=(I=this.opt).resolvePrefix)===null||z===void 0?void 0:z.call(I,$)}qname($){let I=$.indexOf(":");if(I===-1)return{prefix:"",local:$};let z=$.slice(I+1),q=$.slice(0,I);if(q===""||z===""||z.includes(":"))this.fail(`malformedname:${$}.`);return{prefix:q,local:z}}processAttribsNS(){var $;let{attribList:I}=this,z=this.tag;{let{prefix:Y,local:J}=this.qname(z.name);z.prefix=Y,z.local=J;let Q=z.uri=($=this.resolve(Y))!==null&&$!==void 0?$:"";if(Y!==""){if(Y==="xmlns")this.fail('tags may not have "xmlns" as prefix.');if(Q==="")this.fail(`unboundnamespaceprefix:${JSON.stringify(Y)}.`),z.uri=Y}}if(I.length===0)return;let{attributes:q}=z,U=new Set;for(let Y of I){let{name:J,prefix:Q,local:K}=Y,w,G;if(Q==="")w=J==="xmlns"?Sq:"",G=J;else{if(w=this.resolve(Q),w===void 0)this.fail(`unboundnamespaceprefix:${JSON.stringify(Q)}.`),w=Q;G=`{${w}}${K}`}if(U.has(G))this.fail(`duplicateattribute:${G}.`);U.add(G),Y.uri=w,q[J]=Y}this.attribList=[]}processAttribsPlain(){let{attribList:$}=this,I=this.tag.attributes;for(let{name:z,value:q}of $){if(I[z]!==void 0)this.fail(`duplicateattribute:${z}.`);I[z]=q}this.attribList=[]}openTag(){var $;this.processAttribs();let{tags:I}=this,z=this.tag;z.isSelfClosing=!1,($=this.openTagHandler)===null||$===void 0||$.call(this,z),I.push(z),this.state=l6,this.name=""}openSelfClosingTag(){var $,I,z;this.processAttribs();let{tags:q}=this,U=this.tag;if(U.isSelfClosing=!0,($=this.openTagHandler)===null||$===void 0||$.call(this,U),(I=this.closeTagHandler)===null||I===void 0||I.call(this,U),(this.tag=(z=q[q.length-1])!==null&&z!==void 0?z:null)===null)this.closedRoot=!0;this.state=l6,this.name=""}closeTag(){let{tags:$,name:I}=this;if(this.state=l6,this.name="",I===""){this.fail("weird empty close tag."),this.text+="</>";return}let z=this.closeTagHandler,q=$.length;while(q-- >0){let U=this.tag=$.pop();if(this.topNS=U.ns,z===null||z===void 0||z(U),U.name===I)break;this.fail("unexpected close tag.")}if(q===0)this.closedRoot=!0;else if(q<0)this.fail(`unmatchedclosingtag:${I}.`),this.text+=`</${I}>`}parseEntity($){if($[0]!=="#"){let z=this.ENTITIES[$];if(z!==void 0)return z;return this.fail(this.isName($)?"undefined entity.":"disallowed character in entity name."),`&${$};`}let I=NaN;if($[1]==="x"&&/^#x[0-9a-f]+$/i.test($))I=parseInt($.slice(2),16);elseif(/^#[0-9]+$/.test($))I=parseInt($.slice(1),10);if(!this.isChar(I))returnthis.fail("malformed character entity."),`&${$};`;returnString.fromCodePoint(I)}}K$0.SaxesParser=Q$0});varW2=F((Ag1,G$0)=>{var{SaxesParser:dm0}=w$0(),{PassThrough:mm0}=g6(),{bufferToString:lm0}=Jg();G$0.exports=asyncfunction*($){if($.pipe&&!$[Symbol.asyncIterator])$=$.pipe(newmm0);letI=newdm0,z;I.on("error",(U)=>{z=U});letq=[];I.on("opentag",(U)=>q.push({eventType:"opentag",value:U})),I.on("text",(U)=>q.push({eventType:"text",value:U})),I.on("closetag",(U)=>q.push({eventType:"closetag",value:U}));forawait(letUof$){if(I.write(lm0(U)),z)throwz;yieldq,q=[]}}});varD0=F((Pg1,H$0)=>{varom0=W2(),rm0=X6();classuq{prepare(){}render(){}parseOpen($){}parseText($){}parseClose($){}reconcile($,I){}reset(){if(this.model=null,this.map)Object.values(this.map).forEach(($)=>{if($instanceofuq)$.reset();elseif($.xform)$.xform.reset()})}mergeModel($){this.model=Object.assign(this.model||{},$)}asyncparse($){forawait(letIof$)for(let{eventType:z,value:q}ofI)if(z==="opentag")this.parseOpen(q);elseif(z==="text")this.parseText(q);elseif(z==="closetag"){if(!this.parseClose(q.name))returnthLine truncated
See:https://github.com/isaacs/node-glob/issues/167`);return new l4($,I).found}function l4($,I){if(!$)throw Error("must provide pattern");if(typeof I==="function"||arguments.length===3)throw TypeError(`callback provided to sync glob
`+$0[W0-1];break}}}var V1="a promise was created in a "+P+"handler "+s+"but was not returned from it, see http://goo.gl/rRqMUw"+o;S._warn(V1,!0,N)}}function g0(a,N){var P=a+" is deprecated and will be removed in a future version.";if(N)P+=" Use "+N+" instead.";return G1(P)}function G1(a,N,P){if(!R0.warnings)return;var S=new U(a),i;if(N)P._attachExtraTrace(S);else if(R0.longStackTraces&&(i=$._peekContext()))i.attachExtraTrace(S);else{var s=I1(S);S.stack=s.message+`
`+$0[W0-1];break}}}var V1="a promise was created in a "+P+"handler "+e+"but was not returned from it, see http://goo.gl/rRqMUw"+o;S._warn(V1,!0,N)}}function R0(s,N){var P=s+" is deprecated and will be removed in a future version.";if(N)P+=" Use "+N+" instead.";return U1(P)}function U1(s,N,P){if(!v0.warnings)return;var S=new U(s),i;if(N)P._attachExtraTrace(S);else if(v0.longStackTraces&&(i=$._peekContext()))i.attachExtraTrace(S);else{var e=k0(S);S.stack=e.message+`
`)));return}}O=O._target();var A=O._bitField;if((A&50397184)===0)this._yieldedPromise=O,O._proxy(this,null);else if((A&33554432)!==0)$._async.invoke(this._promiseFulfilled,this,O._value());else if((A&16777216)!==0)$._async.invoke(this._promiseRejected,this,O._reason());else this._promiseCancelled()}},$.coroutine=function(X,L){if(typeof X!=="function")throw new Q(`generatorFunctionmustbeafunction
`)));return}}D=D._target();var A=D._bitField;if((A&50397184)===0)this._yieldedPromise=D,D._proxy(this,null);else if((A&33554432)!==0)$._async.invoke(this._promiseFulfilled,this,D._value());else if((A&16777216)!==0)$._async.invoke(this._promiseRejected,this,D._reason());else this._promiseCancelled()}},$.coroutine=function(X,L){if(typeof X!=="function")throw new Q(`generatorFunctionmustbeafunction
Seehttp://goo.gl/MqrFmX
`);var D=Object(L).yieldHandler,O=V,A=Error().stack;return function(){var T=X.apply(this,arguments),M=new O(void 0,void 0,D,A),v=M.promise();return M._generator=T,M._promiseFulfilled(void 0),v}},$.coroutine.addYieldHandler=function(X){if(typeof X!=="function")throw new Q("expecting a function but got "+K.classString(X));H.push(X)},$.spawn=function(X){if(Y.deprecated("Promise.spawn()","Promise.coroutine()"),typeof X!=="function")return I(`generatorFunctionmustbeafunction
`);var O=Object(L).yieldHandler,D=V,A=Error().stack;return function(){var T=X.apply(this,arguments),M=new D(void 0,void 0,O,A),j=M.promise();return M._generator=T,M._promiseFulfilled(void 0),j}},$.coroutine.addYieldHandler=function(X){if(typeof X!=="function")throw new Q("expecting a function but got "+K.classString(X));H.push(X)},$.spawn=function(X){if(Y.deprecated("Promise.spawn()","Promise.coroutine()"),typeof X!=="function")return I(`generatorFunctionmustbeafunction
`)},I=function(){return new g.PromiseInspection(this._target())},z=function(R){return g.reject(new H(R))};function q(){}var U={},Y=r1(),J;if(Y.isNode)J=function(){var R=process.domain;if(R===void 0)R=null;return R};else J=function(){return null};Y.notEnumerableProp(g,"_getDomain",J);var Q=MI(),K=wG0(),w=new K;Q.defineProperty(g,"_async",{value:w});var G=z9(),H=g.TypeError=G.TypeError;g.RangeError=G.RangeError;var W=g.CancellationError=G.CancellationError;g.TimeoutError=G.TimeoutError,g.OperationalError=G.OperationalError,g.RejectionError=G.OperationalError,g.AggregateError=G.AggregateError;var V=function(){},X={},L={},D=ZG0()(g,V),O=LG0()(g,V,D,z,q),A=OG0()(g),T=A.create,M=NG0()(g,A),v=M.CapturedTrace,x=AG0()(g,D),h=TG0()(L),k=Py(),j=Y.errorObj,n=Y.tryCatch;function b(R,u){if(typeof u!=="function")throw new H("expecting a function but got "+Y.classString(u));if(R.constructor!==g)throw new H(`thepromiseconstructorcannotbeinvokeddirectly
`)},I=function(){return new C.PromiseInspection(this._target())},z=function(v){return C.reject(new H(v))};function q(){}var U={},Y=r1(),J;if(Y.isNode)J=function(){var v=process.domain;if(v===void 0)v=null;return v};else J=function(){return null};Y.notEnumerableProp(C,"_getDomain",J);var Q=MI(),K=GG0(),w=new K;Q.defineProperty(C,"_async",{value:w});var G=z9(),H=C.TypeError=G.TypeError;C.RangeError=G.RangeError;var W=C.CancellationError=G.CancellationError;C.TimeoutError=G.TimeoutError,C.OperationalError=G.OperationalError,C.RejectionError=G.OperationalError,C.AggregateError=G.AggregateError;var V=function(){},X={},L={},O=XG0()(C,V),D=OG0()(C,V,O,z,q),A=FG0()(C),T=A.create,M=MG0()(C,A),j=M.CapturedTrace,x=PG0()(C,O),h=EG0()(L),b=Py(),R=Y.errorObj,f=Y.tryCatch;function n(v,u){if(typeof u!=="function")throw new H("expecting a function but got "+Y.classString(u));if(v.constructor!==C)throw new H(`thepromiseconstructorcannotbeinvokeddirectly
Seehttp://goo.gl/MqrFmX
`)}function g(R){if(this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,R!==V)b(this,R),this._resolveFromExecutor(R);this._promiseCreated(),this._fireEvent("promiseCreated",this)}g.prototype.toString=function(){return"[object Promise]"},g.prototype.caught=g.prototype.catch=function(R){var u=arguments.length;if(u>1){var c=Array(u-1),m=0,e;for(e=0;e<u-1;++e){var G0=arguments[e];if(Y.isObject(G0))c[m++]=G0;else return z("expecting an object but got A catch statement predicate "+Y.classString(G0))}return c.length=m,R=arguments[e],this.then(void 0,h(c,R,this))}return this.then(void 0,R)},g.prototype.reflect=function(){return this._then(I,I,void 0,this,void 0)},g.prototype.then=function(R,u){if(M.warnings()&&arguments.length>0&&typeof R!=="function"&&typeof u!=="function"){var c=".then() only accepts functions but was passed: "+Y.classString(R);if(arguments.length>1)c+=", "+Y.classString(u);this._warn(c)}return this._then(R,u,void 0,void 0,void 0)},g.prototype.done=function(R,u){var c=this._then(R,u,void 0,void 0,void 0);c._setIsFinal()},g.prototype.spread=function(R){if(typeof R!=="function")return z("expecting a function but got "+Y.classString(R));return this.all()._then(R,void 0,void 0,X,void 0)},g.prototype.toJSON=function(){var R={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};if(this.isFulfilled())R.fulfillmentValue=this.value(),R.isFulfilled=!0;else if(this.isRejected())R.rejectionReason=this.reason(),R.isRejected=!0;return R},g.prototype.all=function(){if(arguments.length>0)this._warn(".all() was passed arguments but it does not take any");return new O(this).promise()},g.prototype.error=function(R){return this.caught(Y.originatesFromRejection,R)},g.getNewLibraryCopy=Ey.exports,g.is=function(R){return R instanceof g},g.fromNode=g.fromCallback=function(R){var u=new g(V);u._captureStackTrace();var c=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,m=n(R)(k(u,c));if(m===j)u._rejectCallback(m.e,!0);if(!u._isFateSealed())u._setAsyncGuaranteed();return u},g.all=function(R){return new O(R).promise()},g.cast=function(R){var u=D(R);if(!(u instanceof g))u=new g(V),u._captureStackTrace(),u._setFulfilled(),u._rejectionHandler0=R;return u},g.resolve=g.fulfilled=g.cast,g.reject=g.rejected=function(R){var u=new g(V);return u._captureStackTrace(),u._rejectCallback(R,!0),u},g.setScheduler=function(R){if(typeof R!=="function")throw new H("expecting a function but got "+Y.classString(R));return w.setScheduler(R)},g.prototype._then=function(R,u,c,m,e){var G0=e!==void 0,M0=G0?e:new g(V),g0=this._target(),G1=g0._bitField;if(!G0){if(M0._propagateFrom(this,3),M0._captureStackTrace(),m===void 0&&(this._bitField&2097152)!==0)if((G1&50397184)!==0)m=this._boundValue();else m=g0===this?void 0:this._boundTo;this._fireEvent("promiseChained",this,M0)}var S0=J();if((G1&50397184)!==0){var $1,A0,U0=g0._settlePromiseCtx;if((G1&33554432)!==0)A0=g0._rejectionHandler0,$1=R;else if((G1&16777216)!==0)A0=g0._fulfillmentHandler0,$1=u,g0._unsetRejectionIsUnhandled();else U0=g0._settlePromiseLateCancellationObserver,A0=new W("late cancellation observer"),g0._attachExtraTrace(A0),$1=u;w.invoke(U0,g0,{handler:S0===null?$1:typeof $1==="function"&&Y.domainBind(S0,$1),promise:M0,receiver:m,value:A0})}else g0._addCallbacks(R,u,M0,m,S0);return M0},g.prototype._length=function(){return this._bitField&65535},g.prototype._isFateSealed=function(){return(this._bitField&117506048)!==0},g.prototype._isFollowing=function(){return(this._bitField&67108864)===67108864},g.prototype._setLength=function(R){this._bitField=this._bitField&-65536|R&65535},g.prototype._setFulfilled=function(){this._bitField=this._bitField|33554432,this._fireEvent("promiseFulfilled",this)},g.prototype._setRejected=function(){this._bitField=this._bitField|16777216,this._fireEvent("promiseRejected",this)},g.prototype._setFollowing=function(){this._bitField=this._bitField|67108864,this._fireEvent("promiseResolved",this)},g.prototype._setIsFinal=function(){this._bitField=this._bitField|4194304},g.prototype._isFinal=function(){return(this._bitField&4194304)>0},g.prototype._unsetCancelled=function(){this._bitField=this._bitField&-65537},g.prototype._setCancelled=function(){this._bitField=this._bitField|65536,this._fireEvent("promiseCancelled",this)},g.prototype._setWillBeCancelled=function(){this._bitField=this._bitField|8388608},g.prototype._setAsyncGuaranteed=function(){if(w.hasCustomScheduler())return;this._bitField=this._bitField|134217728},g.prototype._receiverAt=function(R){var u=R===0?this._receiver0:this[R*4-4+3];if(u===U)return;else if(u===void 0&&this._isBound())return this._boundValue();return u},g.prototype._promiseAt=function(R){return this[R*4-4+2]},g.prototype._fulfillmentHandlerAt=function(R){return this[R*4-4+0]},g.prototype._rejectionHandlerAt=function(R){return this[R*4-4+1]},g.prototype._boundValue=function(){},g.prototype._migrateCallback0=function(R){var{_bitField:u,_
Line truncated
`)}function C(v){if(this._bitField=0,this._fulfillmentHandler0=void 0,this._rejectionHandler0=void 0,this._promise0=void 0,this._receiver0=void 0,v!==V)n(this,v),this._resolveFromExecutor(v);this._promiseCreated(),this._fireEvent("promiseCreated",this)}C.prototype.toString=function(){return"[object Promise]"},C.prototype.caught=C.prototype.catch=function(v){var u=arguments.length;if(u>1){var c=Array(u-1),r=0,q0;for(q0=0;q0<u-1;++q0){var w0=arguments[q0];if(Y.isObject(w0))c[r++]=w0;else return z("expecting an object but got A catch statement predicate "+Y.classString(w0))}return c.length=r,v=arguments[q0],this.then(void 0,h(c,v,this))}return this.then(void 0,v)},C.prototype.reflect=function(){return this._then(I,I,void 0,this,void 0)},C.prototype.then=function(v,u){if(M.warnings()&&arguments.length>0&&typeof v!=="function"&&typeof u!=="function"){var c=".then() only accepts functions but was passed: "+Y.classString(v);if(arguments.length>1)c+=", "+Y.classString(u);this._warn(c)}return this._then(v,u,void 0,void 0,void 0)},C.prototype.done=function(v,u){var c=this._then(v,u,void 0,void 0,void 0);c._setIsFinal()},C.prototype.spread=function(v){if(typeof v!=="function")return z("expecting a function but got "+Y.classString(v));return this.all()._then(v,void 0,void 0,X,void 0)},C.prototype.toJSON=function(){var v={isFulfilled:!1,isRejected:!1,fulfillmentValue:void 0,rejectionReason:void 0};if(this.isFulfilled())v.fulfillmentValue=this.value(),v.isFulfilled=!0;else if(this.isRejected())v.rejectionReason=this.reason(),v.isRejected=!0;return v},C.prototype.all=function(){if(arguments.length>0)this._warn(".all() was passed arguments but it does not take any");return new D(this).promise()},C.prototype.error=function(v){return this.caught(Y.originatesFromRejection,v)},C.getNewLibraryCopy=Ey.exports,C.is=function(v){return v instanceof C},C.fromNode=C.fromCallback=function(v){var u=new C(V);u._captureStackTrace();var c=arguments.length>1?!!Object(arguments[1]).multiArgs:!1,r=f(v)(b(u,c));if(r===R)u._rejectCallback(r.e,!0);if(!u._isFateSealed())u._setAsyncGuaranteed();return u},C.all=function(v){return new D(v).promise()},C.cast=function(v){var u=O(v);if(!(u instanceof C))u=new C(V),u._captureStackTrace(),u._setFulfilled(),u._rejectionHandler0=v;return u},C.resolve=C.fulfilled=C.cast,C.reject=C.rejected=function(v){var u=new C(V);return u._captureStackTrace(),u._rejectCallback(v,!0),u},C.setScheduler=function(v){if(typeof v!=="function")throw new H("expecting a function but got "+Y.classString(v));return w.setScheduler(v)},C.prototype._then=function(v,u,c,r,q0){var w0=q0!==void 0,M0=w0?q0:new C(V),R0=this._target(),U1=R0._bitField;if(!w0){if(M0._propagateFrom(this,3),M0._captureStackTrace(),r===void 0&&(this._bitField&2097152)!==0)if((U1&50397184)!==0)r=this._boundValue();else r=R0===this?void 0:this._boundTo;this._fireEvent("promiseChained",this,M0)}var x0=J();if((U1&50397184)!==0){var r0,I1,m=R0._settlePromiseCtx;if((U1&33554432)!==0)I1=R0._rejectionHandler0,r0=v;else if((U1&16777216)!==0)I1=R0._fulfillmentHandler0,r0=u,R0._unsetRejectionIsUnhandled();else m=R0._settlePromiseLateCancellationObserver,I1=new W("late cancellation observer"),R0._attachExtraTrace(I1),r0=u;w.invoke(m,R0,{handler:x0===null?r0:typeof r0==="function"&&Y.domainBind(x0,r0),promise:M0,receiver:r,value:I1})}else R0._addCallbacks(v,u,M0,r,x0);return M0},C.prototype._length=function(){return this._bitField&65535},C.prototype._isFateSealed=function(){return(this._bitField&117506048)!==0},C.prototype._isFollowing=function(){return(this._bitField&67108864)===67108864},C.prototype._setLength=function(v){this._bitField=this._bitField&-65536|v&65535},C.prototype._setFulfilled=function(){this._bitField=this._bitField|33554432,this._fireEvent("promiseFulfilled",this)},C.prototype._setRejected=function(){this._bitField=this._bitField|16777216,this._fireEvent("promiseRejected",this)},C.prototype._setFollowing=function(){this._bitField=this._bitField|67108864,this._fireEvent("promiseResolved",this)},C.prototype._setIsFinal=function(){this._bitField=this._bitField|4194304},C.prototype._isFinal=function(){return(this._bitField&4194304)>0},C.prototype._unsetCancelled=function(){this._bitField=this._bitField&-65537},C.prototype._setCancelled=function(){this._bitField=this._bitField|65536,this._fireEvent("promiseCancelled",this)},C.prototype._setWillBeCancelled=function(){this._bitField=this._bitField|8388608},C.prototype._setAsyncGuaranteed=function(){if(w.hasCustomScheduler())return;this._bitField=this._bitField|134217728},C.prototype._receiverAt=function(v){var u=v===0?this._receiver0:this[v*4-4+3];if(u===U)return;else if(u===void 0&&this._isBound())return this._boundValue();return u},C.prototype._promiseAt=function(v){return this[v*4-4+2]},C.prototype._fulfillmentHandlerAt=function(v){return this[v*4-4+0]},C.prototype._rejectionHandlerAt=function(v){return this[v*4-4+1]},C.prototype._boundValue=function(){},C.prototype._migrateCallback0=function(v){var{_bitFie
Line truncated
@@ -626,43 +626,43 @@ export function lintRule(rule: RuleLintTarget): RuleLintResult {
}
exportdefaultlintRule;
`}});import{existsSync as xI,mkdirSync as tH1,readFileSync as aH1,readdirSync as oX0,rmSync as sH1,unlinkSync as eH1,writeFileSync as $W1}from"node:fs";import{homedir as IW1}from"node:os";import{isAbsolute as zW1,join as u6,resolve as qW1}from"node:path";import{pathToFileURL as mX0}from"node:url";function rX0($=L5){let I=[],z=[];try{if(!xI($))tH1($,{recursive:!0});let q=Object.keys(Xx);for(let[Y,J]of Object.entries(Xx)){let Q=u6($,Y),K=!0;if(xI(Q))try{if(aH1(Q,"utf8")===J)K=!1}catch{K=!0}if(K)$W1(Q,J,"utf8");I.push(Y)}let U=oX0($,{withFileTypes:!0});for(let Y of U)if(!q.includes(Y.name)){let J=u6($,Y.name);try{if(Y.isDirectory())sH1(J,{recursive:!0,force:!0});else eH1(J);z.push(Y.name)}catch{}}}catch{}return{synced:I,pruned:z}}function tX0($={syncOfficial:!0}){if($.syncOfficial!==!1)rX0();let I=[{name:"builtin",type:"builtin",path:u6(L5,"builtin.ts"),description:"Seal 官方标准校验器 (拦截过短描述、主观模糊词与悬空例外条款)"},{name:"strict",type:"official",path:u6(L5,"strict.ts"),description:"Seal 官方严格风控校验器 (强校验字数、刚性定量约束、凭证依据与具体审批人角色)"}],z=[Q8,KO];for(let q of z)if(xI(q))try{let U=oX0(q,{withFileTypes:!0});for(let Y of U){if(Y.isDirectory())continue;let J=Y.name;if(J.endsWith(".ts")||J.endsWith(".js")||J.endsWith(".mjs")){let Q=J.replace(/\.(ts|js|mjs)$/,"");if(!I.some((K)=>K.name===Q))I.push({name:Q,type:"custom",path:u6(q,J),description:`用户自定义规则校验器(${J})`})}}}catch{}return I}function YW1($){let I=($||"").trim();if(!I||I==="builtin"||I==="default"||I==="official/builtin"||I==="official/builtin.ts")return{path:u6(L5,"builtin.ts"),isOfficial:!0,officialKind:"builtin"};if(I==="strict"||I==="official/strict"||I==="official/strict.ts")return{path:u6(L5,"strict.ts"),isOfficial:!0,officialKind:"strict"};if(zW1(I)||I.startsWith("./")||I.startsWith("../")){let q=qW1(I);if(xI(q))return{path:q};for(let U of[".ts",".js",".mjs"])if(xI(`${q}${U}`))return{path:`${q}${U}`}}let z=[u6(Q8,`${I}.ts`),u6(Q8,`${I}.js`),u6(Q8,`${I}.mjs`),u6(KO,`${I}.ts`),u6(KO,`${I}.js`),u6(KO,`${I}.mjs`)];for(let q of z)if(xI(q))return{path:q};return{}}async function Dx($){rX0();let I=YW1($??"builtin");if(I.isOfficial){let q=I.officialKind==="strict"?dX0:sU,U=I.officialKind==="strict"?"official":"builtin",Y=I.path;if(Y&&xI(Y))try{let Q=await import(mX0(Y).href),K=Q.default??Q.lintRule??Q.linter??Q.lint;if(typeof K==="function")return{name:I.officialKind??"builtin",type:U,filePath:Y,linter:lX0(K,q)}}catch{}return{name:I.officialKind??"builtin",type:U,filePath:Y,linter:q}}let z=I.path;if(!z)return console.error(`⚠️[linter]未找到自定义校验器"${$}",已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:sU};try{let U=await import(mX0(z).href),Y=U.default??U.lintRule??U.linter??U.lint;if(typeof Y!=="function")return console.error(`⚠️[linter]自定义校验器"${z}"未导出标准函数(default/lintRule),已安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:sU};return{name:$??"custom",type:"custom",filePath:z,linter:lX0(Y,sU)}}catch(q){returnconsole.error(`⚠️[linter]加载自定义校验器脚本"${z}"失败(语法错误或依赖缺失:${q?.message??q}),已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:sU}}}functionlX0($,I){returnasync(z,q)=>{try{letU=await$(z,q);if(U&&typeofU==="object"&&typeofU.score==="number"&&Array.isArray(U.issues))returnU;returnconsole.error("⚠️[linter]自定义校验器返回值格式不符合RuleLintResult契约,已回退至内置结果。"),I(z,q)}catch(U){returnconsole.error("⚠️[linter]自定义校验器执行异常:",U),I(z,q)}}}varQ8,UW1="official",L5,KO;varOx=K0(()=>{Vx();Lx();Zx();Q8=u6(IW1(),".config","seal-use","linters"),L5=u6(Q8,UW1),KO=u6(process.cwd(),"linters")});asyncfunctionFx($,I,z){letq=awaitI.linter($,z);return{ruleId:$.id,ruleCode:$.code,ruleName:$.name,score:q.score,passed:q.passed,issues:q.issues,description:$.description}}asyncfunctionaX0($,I,z,q){letU=q?.minScore??0,Y=q?.level??"all",J=[],Q=0;for(letVof$){letX=awaitFx(V,I,z);Q+=X.score;letL=X.issues;if(Y==="error")L=X.issues.filter((O)=>O.level==="error");elseif(Y==="warning")L=X.issues.filter((O)=>O.level==="warning"||O.level==="error");letD=L.every((O)=>O.level!=="error");if(q?.summary){if(L.length>0)J.push({...X,passed:D,issues:L})}elseJ.push({...X,passed:D,issues:L})}letK=$.length,w=K===0?100:Math.round(Q/K),G=J.filter((V)=>V.issues.length>0).length,H=K-G,W=w>=U&&J.every((V)=>V.passed);return{linter:I.name,linterType:I.type,totalRules:K,healthyCount:H,issueCount:G,overallScore:w,passed:W,issues:J}}varNx=K0(()=>{cX0();Vx();Zx();Lx();Ox()});import{existsSyncasJW1,readFileSyncasQW1,writeFileSyncasKW1,mkdirSyncaswW1}from"node:fs";import{dirnameasGW1,resolveaseX0}from"node:path";functionHW1($){letI;try{I=JSON.parse($)}catch(z){throwErroLine truncated
`}});import{existsSync as xI,mkdirSync as aH1,readFileSync as sH1,readdirSync as rX0,rmSync as eH1,unlinkSync as $W1,writeFileSync as IW1}from"node:fs";import{homedir as zW1}from"node:os";import{isAbsolute as qW1,join as u6,resolve as UW1}from"node:path";import{pathToFileURL as lX0}from"node:url";function tX0($=L5){let I=[],z=[];try{if(!xI($))aH1($,{recursive:!0});let q=Object.keys(Lx);for(let[Y,J]of Object.entries(Lx)){let Q=u6($,Y),K=!0;if(xI(Q))try{if(sH1(Q,"utf8")===J)K=!1}catch{K=!0}if(K)IW1(Q,J,"utf8");I.push(Y)}let U=rX0($,{withFileTypes:!0});for(let Y of U)if(!q.includes(Y.name)){let J=u6($,Y.name);try{if(Y.isDirectory())eH1(J,{recursive:!0,force:!0});else $W1(J);z.push(Y.name)}catch{}}}catch{}return{synced:I,pruned:z}}function aX0($={syncOfficial:!0}){if($.syncOfficial!==!1)tX0();let I=[{name:"builtin",type:"builtin",path:u6(L5,"builtin.ts"),description:"Seal 官方标准校验器 (拦截过短描述、主观模糊词与悬空例外条款)"},{name:"strict",type:"official",path:u6(L5,"strict.ts"),description:"Seal 官方严格风控校验器 (强校验字数、刚性定量约束、凭证依据与具体审批人角色)"}],z=[Q8,KD];for(let q of z)if(xI(q))try{let U=rX0(q,{withFileTypes:!0});for(let Y of U){if(Y.isDirectory())continue;let J=Y.name;if(J.endsWith(".ts")||J.endsWith(".js")||J.endsWith(".mjs")){let Q=J.replace(/\.(ts|js|mjs)$/,"");if(!I.some((K)=>K.name===Q))I.push({name:Q,type:"custom",path:u6(q,J),description:`用户自定义规则校验器(${J})`})}}}catch{}return I}function JW1($){let I=($||"").trim();if(!I||I==="builtin"||I==="default"||I==="official/builtin"||I==="official/builtin.ts")return{path:u6(L5,"builtin.ts"),isOfficial:!0,officialKind:"builtin"};if(I==="strict"||I==="official/strict"||I==="official/strict.ts")return{path:u6(L5,"strict.ts"),isOfficial:!0,officialKind:"strict"};if(qW1(I)||I.startsWith("./")||I.startsWith("../")){let q=UW1(I);if(xI(q))return{path:q};for(let U of[".ts",".js",".mjs"])if(xI(`${q}${U}`))return{path:`${q}${U}`}}let z=[u6(Q8,`${I}.ts`),u6(Q8,`${I}.js`),u6(Q8,`${I}.mjs`),u6(KD,`${I}.ts`),u6(KD,`${I}.js`),u6(KD,`${I}.mjs`)];for(let q of z)if(xI(q))return{path:q};return{}}async function Dx($){tX0();let I=JW1($??"builtin");if(I.isOfficial){let q=I.officialKind==="strict"?mX0:sU,U=I.officialKind==="strict"?"official":"builtin",Y=I.path;if(Y&&xI(Y))try{let Q=await import(lX0(Y).href),K=Q.default??Q.lintRule??Q.linter??Q.lint;if(typeof K==="function")return{name:I.officialKind??"builtin",type:U,filePath:Y,linter:oX0(K,q)}}catch{}return{name:I.officialKind??"builtin",type:U,filePath:Y,linter:q}}let z=I.path;if(!z)return console.error(`⚠️[linter]未找到自定义校验器"${$}",已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:sU};try{let U=await import(lX0(z).href),Y=U.default??U.lintRule??U.linter??U.lint;if(typeof Y!=="function")return console.error(`⚠️[linter]自定义校验器"${z}"未导出标准函数(default/lintRule),已安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:sU};return{name:$??"custom",type:"custom",filePath:z,linter:oX0(Y,sU)}}catch(q){returnconsole.error(`⚠️[linter]加载自定义校验器脚本"${z}"失败(语法错误或依赖缺失:${q?.message??q}),已自动安全降级至内置标准校验器。`),{name:"builtin",type:"builtin",linter:sU}}}functionoX0($,I){returnasync(z,q)=>{try{letU=await$(z,q);if(U&&typeofU==="object"&&typeofU.score==="number"&&Array.isArray(U.issues))returnU;returnconsole.error("⚠️[linter]自定义校验器返回值格式不符合RuleLintResult契约,已回退至内置结果。"),I(z,q)}catch(U){returnconsole.error("⚠️[linter]自定义校验器执行异常:",U),I(z,q)}}}varQ8,YW1="official",L5,KD;varFx=K0(()=>{Zx();Ox();Xx();Q8=u6(zW1(),".config","seal-use","linters"),L5=u6(Q8,YW1),KD=u6(process.cwd(),"linters")});asyncfunctionNx($,I,z){letq=awaitI.linter($,z);return{ruleId:$.id,ruleCode:$.code,ruleName:$.name,score:q.score,passed:q.passed,issues:q.issues,description:$.description}}asyncfunctionsX0($,I,z,q){letU=q?.minScore??0,Y=q?.level??"all",J=[],Q=0;for(letVof$){letX=awaitNx(V,I,z);Q+=X.score;letL=X.issues;if(Y==="error")L=X.issues.filter((D)=>D.level==="error");elseif(Y==="warning")L=X.issues.filter((D)=>D.level==="warning"||D.level==="error");letO=L.every((D)=>D.level!=="error");if(q?.summary){if(L.length>0)J.push({...X,passed:O,issues:L})}elseJ.push({...X,passed:O,issues:L})}letK=$.length,w=K===0?100:Math.round(Q/K),G=J.filter((V)=>V.issues.length>0).length,H=K-G,W=w>=U&&J.every((V)=>V.passed);return{linter:I.name,linterType:I.type,totalRules:K,healthyCount:H,issueCount:G,overallScore:w,passed:W,issues:J}}varMx=K0(()=>{dX0();Zx();Xx();Ox();Fx()});import{existsSyncasQW1,readFileSyncasKW1,writeFileSyncaswW1,mkdirSyncasGW1}from"node:fs";import{dirnameasHW1,resolveas$L0}from"node:path";functionWW1($){letI;try{I=JSON.parse($)}catch(z){throwErroLine truncated
`+"• 安全边界:该凭证绝不包含且无法访问合思 (Hose) 主系统;仅限内部排查,严禁在外部公开分享!")}return{url:I.sso?G:w,sealResultUrl:w,ssoUrl:G,type:I.sso?"sso_link":"deep_link",expiresIn:I.sso?V:void 0,identity:H,warning:W,enterpriseAssistUrl:J,enterpriseUrl:J,hoseDomain:Y.type==="hose"?jZ1(Y.domain):void 0,documentUrl:Q,recordId:U?.id,sourceDocumentSN:U?.sourceDocumentSN,sourceDocumentId:U?.sourceDocumentId,sourceSystem:U?.sourceSystem,missing:{enterpriseAssistUrl:J?void 0:"Current enterprise source is not Hose, so no Hose enterprise assist URL is configured.",documentUrl:q&&!Q?"sourceExtendData.hosecloudViewUrl is absent from the approval run detail.":void 0}}}},{name:"seal_approval_run_pick",description:"按合思单号或关键字查询运行记录,返回候选记录及其当时使用的规则版本,便于再取详情或查版本规则",parameters:Z.object({query:Z.string().optional().describe("合思单号、源单据 ID、运行记录 ID 或 trace 关键字"),sn:Z.string().optional().describe("合思/易快报单号;优先作为精确 sourceDocumentSN 查询"),batchId:Z.string().optional().describe("模拟批次 ID"),latest:Z.boolean().optional().describe("只返回最新一条匹配记录"),fields:Z.union([Z.string(),Z.array(Z.string())]).optional().describe("限制返回字段"),limit:Z.number().int().positive().max(100).optional(),maxScan:Z.number().int().positive().max(5000).optional().describe("最多扫描多少条运行记录用于本地匹配,默认 1000"),includeBridge:Z.boolean().optional()}),handler:async($,I)=>{let z=I.sn??I.query;if(!z)throw Error("query or sn is required");let q=await vZ1($,{query:z,sn:I.sn,batchId:I.batchId,latest:I.latest,limit:I.latest?1:I.limit??20,maxScan:I.maxScan??1000}),U=await Promise.all(q.records.map((Q)=>X4($,Q.id))),Y=gD0(I.fields),J=U.map((Q)=>TZ1(Q,Y));return{query:z,sourceDocumentSN:I.sn,simulationBatchId:I.batchId,latest:I.latest??!1,total:q.total,scanned:q.scanned,matched:J.length,records:J,next:{getSummary:"seal-home approval-runs get <recordId> --summary",getRuleVersion:"seal-home rules version <ruleSetVersionNumber>",searchRuleVersion:`seal-hometoolseal_approval_search--json'{"keywords":["关键词"],"areas":["rules"],"ruleVersionScope":"version","ruleVersionNumber":14}'`,getVersionContext:`seal-hometoolseal_approval_context_get--json'{"ruleVersionNumber":14}'`},...I.includeBridge?{bridge:yO(U)}:{}}}},{name:"seal_simulation_batch_records_get",description:"获取某一次 Seal 模拟批次的运行记录,并整理对应 Langfuse trace/session 桥接字段",parameters:Z.object({batchId:Z.string().describe("simulation batch ID"),query:Z.string().optional().describe("在 id、sourceDocumentSN、sourceDocumentId、documentId、Langfuse traceId 中做本地包含匹配")}),handler:async($,I)=>{let z=gk(await hj($,I.batchId),I.query);return{batchId:I.batchId,count:z.length,records:z.map(iI),bridge:yO(z)}}},{name:"seal_simulation_batch_create",description:"创建 Seal 模拟测试批次。支持合思指定单号(hosecloud)与材料包导入(material_pack)两种模式;其他取数模式通过 rawParams 预留透传。",parameters:Z.object({mode:Z.enum(["hosecloud","material_pack"]).default("hosecloud").describe("来源模式: hosecloud=合思指定单号; material_pack=材料包导入"),flowIds:Z.array(Z.string()).max(100).optional().describe("合思模式: 单据流水号列表"),rejectNodeName:Z.string().nullable().optional().describe("仅关注特定节点: 节点名称, 不设为 null 表示不限制"),thinkingDepthOverride:Z.enum(["default","medium","high"]).optional().describe("思考深度: default=按偏好设置, medium=标准, high=深度推理"),skipInvoiceGeneration:Z.boolean().optional().describe("跳过发票生成, 默认 true"),skipExpenseExtraction:Z.boolean().optional().describe("跳过费用提取, 默认 true"),disableAttachmentCache:Z.boolean().optional().describe("不使用附件缓存, 默认 false"),signKey:Z.string().optional().describe("合思集成标识; 缺省时自动取第一个合思集成"),packageIds:Z.array(Z.string()).optional().describe("材料包模式: 材料包 id 列表(来自 material-packages upload 响应)"),templateId:Z.string().optional().describe("材料包模板 id, 例如 conference_reimbursement_v1; 缺省取 schemaConfig.id"),schemaConfig:Z.record(Z.string(),Z.unknown()).optional().describe("材料包字段映射(确认参数), 建议使用 material-packages upload 返回的 schemaConfig"),noWait:Z.boolean().optional().describe("创建后立即返回异步票据,不等待批次完成"),rawParams:Z.record(Z.string(),Z.unknown()).optional().describe("预留: 其他取数模式(如时间范围 startTime/endTime)透传参数, 覆盖上述构建结果")}),handler:async($,I)=>{let z=I.mode??"hosecloud",q=I.signKey;if(z==="hosecloud"&&!q){if(q=(await yj($)).find((Q)=>Q.signKey)?.signKey,!q)throw Error("未找到合思集成 signKey, 请通过 signKey
Line truncated
`)}function kZ1($){let I=[];if(I.push(`seal-use${$.area}-${$.title}`),$.description)I.push($.description);I.push(""),I.push("Usage:");for(let z of $.commands)for(let q of z.usage)I.push(`${q}`);if($.commands.some((z)=>z.name))I.push(""),I.push(`Run'seal-use ${$.area} <command> --help'fordetailsonaspecificcommand.`);return I.join(`
`)}function rD0(){let $=[];$.push("seal-use CLI"),$.push(""),$.push("Usage:"),$.push(" seal-use version");for(let I of tD0)for(let z of I.commands)for(let q of z.usage)$.push(`${q}`);return $.push(""),$.push("Run 'seal-use <command> --help' for details on a specific command."),$.join(`
`)}var tD0;var xk=K0(()=>{k$();tD0=[{area:"corps",title:"Enterprise and tenant management",description:"Manage enterprise configurations, environment modes, test bindings, and syncing.",commands:[{name:"list",summary:"List configured enterprises sorted by 7-day usage frequency",usage:["seal-use corps list [query] [--all] [--limit <n>] [--env <production|test>] [--strict] [--corp <corpId>]"],options:[{flag:"--all",description:"Display all configured enterprises without the default 10-item limit"},{flag:"--limit <n>",description:"Maximum number of enterprises to display (defaults to 10)"},{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}]},{name:"search",aliases:["find"],summary:"Search configured enterprises with intelligent soft fuzzy matching",usage:["seal-use corps search <query> [--env <production|test>] [--strict]"],options:[{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}],description:"Searches enterprise ID, name, staff ID, domain, tenant slug, environment, or bindings. Uses soft search by default (case-insensitive, Chinese homophones, front/back nasal vowels, initials, typo/missing letter tolerance)."},{name:"get",aliases:["show"],summary:"Get rich details and configuration of an enterprise",usage:["seal-use corps get <corpId>"],description:"Retrieves complete enterprise details (URLs, tenant slugs, custom headers/cookies, staff IDs, relations, config file path) with sensitive secrets safely redacted."},{name:"current",summary:"Show active enterprise in stateful mode",usage:["seal-use corps current [--corp <corpId>]"]},{name:"switch",summary:"Switch default active enterprise",usage:["seal-use corps switch <corpId>"]},{name:"mark",summary:"Mark enterprise environment as production or test",usage:["seal-use corps mark <corpId> --env <production|test> [--confirm]"],options:[{flag:"--env <production|test>",description:"Target environment: 'production' or 'test' (required)"},{flag:"--confirm",description:"Confirm the environment update (required)"}],description:"Explicitly updates an enterprise's environment tag. Requires --confirm to prevent accidental changes."},{name:"bind-test",summary:"Bind a production enterprise to a test enterprise (1-to-1 association)",usage:["seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]","seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]"],options:[{flag:"--confirm",description:"Explicitly confirm binding and tag test environment (required)"},{flag:"--force",description:"Force re-binding if the production enterprise is already bound"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Establishes a strict 1-to-1 association between a production enterprise and a test enterprise. Automatically marks the test enterprise with environment 'test'."},{name:"unbind-test",summary:"Unbind a production and test enterprise association",usage:["seal-use corps unbind-test [<corpId>] [--confirm]"],options:[{flag:"--confirm",description:"Explicitly confirm unbinding both sides (required)"},{flag:"--corp <corpId>",description:"Specify enterprise ID or name"}],description:"Removes the 1-to-1 test association from both the production enterprise and the test enterprise."},{name:"sync-test",summary:"Synchronize rules and preferences from production to test enterprise",usage:["seal-use corps sync-test [<prodCorpId>] [--dry-run] [--yes] [--version-name <name>]"],options:[{flag:"--dry-run",description:"Preview sync diff without making network mutations (default)"},{flag:"--yes",description:"Execute synchronization and publish new rule version on test enterprise"},{flag:"--version-name <name>",description:"Custom version name for published test rule version"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Overwrites test enterprise decision preferences with production preferences, syncs production draft rules to test enterprise, and immediately publishes a new version on the test enterprise. Production rules remain safe in draft state."},{name:"replay-test",summary:"Replay approval records from production enterprise to bound test enterprise via Webhook",usage:["seal-use corps replay-test [<prodCorpId>] [--record-id <id>] [--sn <sn>] [--limit <n>] [--webhook <idOrName>] [--dry-run]"],options:[{flag:"<prodCorpId>",description:"Production enterprise ID (default: active enterprise)"},{flag:"--record-id <id>",description:"Replay a specific approval run ID"},{flag:"--sn <sn>",description:"Replay a specific document SN"},{flag:"--limit <n>",description:"Batch replay latest N records from production (default: 1)"},{flag:"--status <status>",descript
Line truncated
`+"• 安全边界:该凭证绝不包含且无法访问合思 (Hose) 主系统;仅限内部排查,严禁在外部公开分享!")}return{url:I.sso?G:w,sealResultUrl:w,ssoUrl:G,type:I.sso?"sso_link":"deep_link",expiresIn:I.sso?V:void 0,identity:H,warning:W,enterpriseAssistUrl:J,enterpriseUrl:J,hoseDomain:Y.type==="hose"?RZ1(Y.domain):void 0,documentUrl:Q,recordId:U?.id,sourceDocumentSN:U?.sourceDocumentSN,sourceDocumentId:U?.sourceDocumentId,sourceSystem:U?.sourceSystem,missing:{enterpriseAssistUrl:J?void 0:"Current enterprise source is not Hose, so no Hose enterprise assist URL is configured.",documentUrl:q&&!Q?"sourceExtendData.hosecloudViewUrl is absent from the approval run detail.":void 0}}}},{name:"seal_approval_run_pick",description:"按合思单号或关键字查询运行记录,返回候选记录及其当时使用的规则版本,便于再取详情或查版本规则",parameters:Z.object({query:Z.string().optional().describe("合思单号、源单据 ID、运行记录 ID 或 trace 关键字"),sn:Z.string().optional().describe("合思/易快报单号;优先作为精确 sourceDocumentSN 查询"),batchId:Z.string().optional().describe("模拟批次 ID"),latest:Z.boolean().optional().describe("只返回最新一条匹配记录"),fields:Z.union([Z.string(),Z.array(Z.string())]).optional().describe("限制返回字段"),limit:Z.number().int().positive().max(100).optional(),maxScan:Z.number().int().positive().max(5000).optional().describe("最多扫描多少条运行记录用于本地匹配,默认 1000"),includeBridge:Z.boolean().optional()}),handler:async($,I)=>{let z=I.sn??I.query;if(!z)throw Error("query or sn is required");let q=await gZ1($,{query:z,sn:I.sn,batchId:I.batchId,latest:I.latest,limit:I.latest?1:I.limit??20,maxScan:I.maxScan??1000}),U=await Promise.all(q.records.map((Q)=>X4($,Q.id))),Y=gO0(I.fields),J=U.map((Q)=>BZ1(Q,Y));return{query:z,sourceDocumentSN:I.sn,simulationBatchId:I.batchId,latest:I.latest??!1,total:q.total,scanned:q.scanned,matched:J.length,records:J,next:{getSummary:"seal-home approval-runs get <recordId> --summary",getRuleVersion:"seal-home rules version <ruleSetVersionNumber>",searchRuleVersion:`seal-hometoolseal_approval_search--json'{"keywords":["关键词"],"areas":["rules"],"ruleVersionScope":"version","ruleVersionNumber":14}'`,getVersionContext:`seal-hometoolseal_approval_context_get--json'{"ruleVersionNumber":14}'`},...I.includeBridge?{bridge:yD(U)}:{}}}},{name:"seal_simulation_batch_records_get",description:"获取某一次 Seal 模拟批次的运行记录,并整理对应 Langfuse trace/session 桥接字段",parameters:Z.object({batchId:Z.string().describe("simulation batch ID"),query:Z.string().optional().describe("在 id、sourceDocumentSN、sourceDocumentId、documentId、Langfuse traceId 中做本地包含匹配")}),handler:async($,I)=>{let z=_k(await hj($,I.batchId),I.query);return{batchId:I.batchId,count:z.length,records:z.map(iI),bridge:yD(z)}}},{name:"seal_simulation_batch_create",description:"创建 Seal 模拟测试批次。支持合思指定单号(hosecloud)与材料包导入(material_pack)两种模式;其他取数模式通过 rawParams 预留透传。",parameters:Z.object({mode:Z.enum(["hosecloud","material_pack"]).default("hosecloud").describe("来源模式: hosecloud=合思指定单号; material_pack=材料包导入"),flowIds:Z.array(Z.string()).max(100).optional().describe("合思模式: 单据流水号列表"),rejectNodeName:Z.string().nullable().optional().describe("仅关注特定节点: 节点名称, 不设为 null 表示不限制"),thinkingDepthOverride:Z.enum(["default","medium","high"]).optional().describe("思考深度: default=按偏好设置, medium=标准, high=深度推理"),skipInvoiceGeneration:Z.boolean().optional().describe("跳过发票生成, 默认 true"),skipExpenseExtraction:Z.boolean().optional().describe("跳过费用提取, 默认 true"),disableAttachmentCache:Z.boolean().optional().describe("不使用附件缓存, 默认 false"),signKey:Z.string().optional().describe("合思集成标识; 缺省时自动取第一个合思集成"),packageIds:Z.array(Z.string()).optional().describe("材料包模式: 材料包 id 列表(来自 material-packages upload 响应)"),templateId:Z.string().optional().describe("材料包模板 id, 例如 conference_reimbursement_v1; 缺省取 schemaConfig.id"),schemaConfig:Z.record(Z.string(),Z.unknown()).optional().describe("材料包字段映射(确认参数), 建议使用 material-packages upload 返回的 schemaConfig"),noWait:Z.boolean().optional().describe("创建后立即返回异步票据,不等待批次完成"),rawParams:Z.record(Z.string(),Z.unknown()).optional().describe("预留: 其他取数模式(如时间范围 startTime/endTime)透传参数, 覆盖上述构建结果")}),handler:async($,I)=>{let z=I.mode??"hosecloud",q=I.signKey;if(z==="hosecloud"&&!q){if(q=(await yj($)).find((Q)=>Q.signKey)?.signKey,!q)throw Error("未找到合思集成 signKey, 请通过 signKey
Line truncated
`)}function bZ1($){let I=[];if(I.push(`seal-use${$.area}-${$.title}`),$.description)I.push($.description);I.push(""),I.push("Usage:");for(let z of $.commands)for(let q of z.usage)I.push(`${q}`);if($.commands.some((z)=>z.name))I.push(""),I.push(`Run'seal-use ${$.area} <command> --help'fordetailsonaspecificcommand.`);return I.join(`
`)}function rO0(){let $=[];$.push("seal-use CLI"),$.push(""),$.push("Usage:"),$.push(" seal-use version");for(let I of tO0)for(let z of I.commands)for(let q of z.usage)$.push(`${q}`);return $.push(""),$.push("Run 'seal-use <command> --help' for details on a specific command."),$.join(`
`)}var tO0;var kk=K0(()=>{k$();tO0=[{area:"corps",title:"Enterprise and tenant management",description:"Manage enterprise configurations, environment modes, test bindings, and syncing.",commands:[{name:"list",summary:"List configured enterprises sorted by 7-day usage frequency",usage:["seal-use corps list [query] [--all] [--limit <n>] [--env <production|test>] [--strict] [--corp <corpId>]"],options:[{flag:"--all",description:"Display all configured enterprises without the default 10-item limit"},{flag:"--limit <n>",description:"Maximum number of enterprises to display (defaults to 10)"},{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}]},{name:"search",aliases:["find"],summary:"Search configured enterprises with intelligent soft fuzzy matching",usage:["seal-use corps search <query> [--env <production|test>] [--strict]"],options:[{flag:"--env <production|test>",description:"Filter enterprises by environment ('production' or 'test')"},{flag:"--strict",description:"Use strict exact substring matching instead of default soft fuzzy search"}],description:"Searches enterprise ID, name, staff ID, domain, tenant slug, environment, or bindings. Uses soft search by default (case-insensitive, Chinese homophones, front/back nasal vowels, initials, typo/missing letter tolerance)."},{name:"get",aliases:["show"],summary:"Get rich details and configuration of an enterprise",usage:["seal-use corps get <corpId>"],description:"Retrieves complete enterprise details (URLs, tenant slugs, custom headers/cookies, staff IDs, relations, config file path) with sensitive secrets safely redacted."},{name:"current",summary:"Show active enterprise in stateful mode",usage:["seal-use corps current [--corp <corpId>]"]},{name:"switch",summary:"Switch default active enterprise",usage:["seal-use corps switch <corpId>"]},{name:"mark",summary:"Mark enterprise environment as production or test",usage:["seal-use corps mark <corpId> --env <production|test> [--confirm]"],options:[{flag:"--env <production|test>",description:"Target environment: 'production' or 'test' (required)"},{flag:"--confirm",description:"Confirm the environment update (required)"}],description:"Explicitly updates an enterprise's environment tag. Requires --confirm to prevent accidental changes."},{name:"bind-test",summary:"Bind a production enterprise to a test enterprise (1-to-1 association)",usage:["seal-use corps bind-test <prodCorpId> <testCorpId> [--confirm] [--force]","seal-use corps bind-test <testCorpId> --corp <prodCorpId> [--confirm] [--force]"],options:[{flag:"--confirm",description:"Explicitly confirm binding and tag test environment (required)"},{flag:"--force",description:"Force re-binding if the production enterprise is already bound"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Establishes a strict 1-to-1 association between a production enterprise and a test enterprise. Automatically marks the test enterprise with environment 'test'."},{name:"unbind-test",summary:"Unbind a production and test enterprise association",usage:["seal-use corps unbind-test [<corpId>] [--confirm]"],options:[{flag:"--confirm",description:"Explicitly confirm unbinding both sides (required)"},{flag:"--corp <corpId>",description:"Specify enterprise ID or name"}],description:"Removes the 1-to-1 test association from both the production enterprise and the test enterprise."},{name:"sync-test",summary:"Synchronize rules and preferences from production to test enterprise",usage:["seal-use corps sync-test [<prodCorpId>] [--dry-run] [--yes] [--version-name <name>]"],options:[{flag:"--dry-run",description:"Preview sync diff without making network mutations (default)"},{flag:"--yes",description:"Execute synchronization and publish new rule version on test enterprise"},{flag:"--version-name <name>",description:"Custom version name for published test rule version"},{flag:"--corp <corpId>",description:"Specify production enterprise ID or name"}],description:"Overwrites test enterprise decision preferences with production preferences, syncs production draft rules to test enterprise, and immediately publishes a new version on the test enterprise. Production rules remain safe in draft state."},{name:"replay-test",summary:"Replay approval records from production enterprise to bound test enterprise via Webhook",usage:["seal-use corps replay-test [<prodCorpId>] [--record-id <id>] [--sn <sn>] [--limit <n>] [--webhook <idOrName>] [--dry-run]"],options:[{flag:"<prodCorpId>",description:"Production enterprise ID (default: active enterprise)"},{flag:"--record-id <id>",description:"Replay a specific approval run ID"},{flag:"--sn <sn>",description:"Replay a specific document SN"},{flag:"--limit <n>",description:"Batch replay latest N records from production (default: 1)"},{flag:"--status <status>",descript
Line truncated
`}class aB{constructor($=Xo.stdin,I=Xo.stdout){this._stdin=$,this._stdout=I,this._readBuffer=new tB,this._started=!1,this._ondata=(z)=>{this._readBuffer.append(z),this.processReadBuffer()},this._onerror=(z)=>{this.onerror?.(z)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let $=this._readBuffer.readMessage();if($===null)break;this.onmessage?.($)}catch($){this.onerror?.($)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send($){return new Promise((I)=>{let z=Zo($);if(this._stdout.write(z))I();else this._stdout.once("drain",I)})}}w$();import{dirname as Df,join as PL1}from"node:path";import{fileURLToPath as TL1}from"node:url";import{spawnSync as Lr}from"node:child_process";var UQ={name:"seal-use",version:"0.10.20",type:"module",module:"src/server.ts",bin:{"seal-use":"src/cli.ts","seal-home":"src/cli.ts"},scripts:{dev:"bun run --watch src/server.ts",start:"bun run src/server.ts",probe:"bun run src/probe.ts",cli:"bun run src/cli.ts",check:"tsc --noEmit","build:binary":"node scripts/build-binary.mjs","build:plugin":"node scripts/build-plugin.mjs",bump:"bun run scripts/bump-version.ts","dev:override":"bun run scripts/dev-override.ts","dev:link":"bun run scripts/dev-override.ts","openapi:bundle":"bun run scripts/bundle-openapi.ts","openapi:raw":"bun run scripts/generate-raw-openapi.ts",test:"bun test"},dependencies:{"@modelcontextprotocol/sdk":"^1.29.0",exceljs:"^4.4.0","iconv-lite":"^0.7.3",ky:"^2.0.2","pinyin-pro":"^3.29.3",yauzl:"^3.4.0",zod:"^4.4.3"},devDependencies:{"@types/bun":"^1.3.14","@types/yauzl":"^3.4.0","bun-types":"^1.3.14",typescript:"^5.9.3",yaml:"^2.9.0"}};function Yy0($,I=UQ.version){let z=$.trim();if(!z)return null;let q=z.endsWith("-dirty"),U=q?z.slice(0,-6):z,Y=U.match(/^v?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)-(\d+)-g([0-9a-f]+)$/);if(Y&&Y[1]&&Y[2]&&Y[3])return{baseVersion:Y[1],commitsAhead:Number.parseInt(Y[2],10),commit:Y[3],dirty:q,describe:z};let J=U.match(/^v?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)$/);if(J&&J[1])return{baseVersion:J[1],commitsAhead:0,commit:"",dirty:q,describe:z};let Q=U.match(/^([0-9a-f]{7,40})$/);if(Q&&Q[1])return{baseVersion:I,commitsAhead:0,commit:Q[1],dirty:q,describe:z};return null}function Jy0($,I,z,q){let Y=z?`+g${z}${q?".dirty":""}`:q?"+dirty":"";return`${$}-dev.${I}${Y}`}function Qy0($){let I=$?.env,z=I?.SEAL_BUILD_VERSION??process.env.SEAL_BUILD_VERSION,q=I?.SEAL_BUILD_IS_RELEASE??process.env.SEAL_BUILD_IS_RELEASE,U=I?.SEAL_BUILD_CHANNEL??process.env.SEAL_BUILD_CHANNEL,Y=I?.SEAL_BUILD_GIT_BASE??process.env.SEAL_BUILD_GIT_BASE,J=I?.SEAL_BUILD_GIT_COMMITS_AHEAD??process.env.SEAL_BUILD_GIT_COMMITS_AHEAD,Q=I?.SEAL_BUILD_GIT_COMMIT??process.env.SEAL_BUILD_GIT_COMMIT,K=I?.SEAL_BUILD_GIT_DIRTY??process.env.SEAL_BUILD_GIT_DIRTY,w=I?.SEAL_BUILD_GIT_DESCRIBE??process.env.SEAL_BUILD_GIT_DESCRIBE,G=I?.SEAL_FORCE_RELEASE??process.env.SEAL_FORCE_RELEASE,H=$?.cwd;if(z){let W=q==="true",X={name:"seal-use",version:z,channel:U||(W?"release":"dev"),isRelease:W};if(Y)X.git={baseVersion:Y,commitsAhead:Number.parseInt(J||"0",10),commit:Q||"",dirty:K==="true",describe:w||z};return X}if(q==="true"||G==="1")return{name:"seal-use",version:UQ.version,channel:"release",isRelease:!0};try{let W=Lr("git",["describe","--tags","--long","--dirty","--always"],{cwd:H,encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(W.status===0&&W.stdout){let V=Yy0(W.stdout.trim(),UQ.version);if(V){if(!V.commit){let L=Lr("git",["rev-parse","--short","HEAD"],{cwd:H,encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(L.status===0&&L.stdout)V.commit=L.stdout.trim()}return{name:"seal-use",version:Jy0(V.baseVersion,V.commitsAhead,V.commit,V.dirty),channel:"dev",isRelease:!1,git:V}}}}catch{}return{name:"seal-use",version:`${UQ.version}-dev.0+local`,channel:"dev",isRelease:!1}}var YQ=Qy0(),q1=YQ.version,Fj=YQ.isRelease,Jj1=YQ.channel;c4();rD();su();A4();G4();u1();w$();A4();c4();c4();aK();Nk();G4();u1();k$();import{existsSync as qO0}from"node:fs";async function UO0($,I){if(!qO0($))throw Error(`Filenotfound:${$}`);let z=nI($);console.log(JSON.stringify(await bI(z.fileBuffer,z.fileName,I),null,2))}async function mO($,I,z,q,U){if($==="ready"||$==="status"){let Y=I??E(U.options.file)??E(U.options.input),J=await gO(z,q,{filePath:Y,webhook:E(U.options.webhook)??E(U.options.selector)});if(console.error(`[webhook-ready]企业环境:${J.corp.name}(${J.corp.id})[${J.stateMode}]`),J.corp.tenant?.name)console.error(`[webhook-ready]租户信息:${J.corp.tenant.name}(${J.corp.tenant.id})`);console.error(`[webhook-ready]凭证状态:${J.authStatus==="ok"?"OK":`异常 (${J.authError})`}`),console.error(`[webhook-ready]Webhook通道:${J.activeWebhooLine truncated
`}class aB{constructor($=Lo.stdin,I=Lo.stdout){this._stdin=$,this._stdout=I,this._readBuffer=new tB,this._started=!1,this._ondata=(z)=>{this._readBuffer.append(z),this.processReadBuffer()},this._onerror=(z)=>{this.onerror?.(z)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let $=this._readBuffer.readMessage();if($===null)break;this.onmessage?.($)}catch($){this.onerror?.($)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send($){return new Promise((I)=>{let z=Xo($);if(this._stdout.write(z))I();else this._stdout.once("drain",I)})}}w$();import{dirname as Df,join as EL1}from"node:path";import{fileURLToPath as BL1}from"node:url";import{spawnSync as Or}from"node:child_process";var UQ={name:"seal-use",version:"0.10.20",type:"module",module:"src/server.ts",bin:{"seal-use":"src/cli.ts","seal-home":"src/cli.ts"},scripts:{dev:"bun run --watch src/server.ts",start:"bun run src/server.ts",probe:"bun run src/probe.ts",cli:"bun run src/cli.ts",check:"tsc --noEmit","build:binary":"node scripts/build-binary.mjs","build:plugin":"node scripts/build-plugin.mjs",bump:"bun run scripts/bump-version.ts","dev:override":"bun run scripts/dev-override.ts","dev:link":"bun run scripts/dev-override.ts","openapi:bundle":"bun run scripts/bundle-openapi.ts","openapi:raw":"bun run scripts/generate-raw-openapi.ts",test:"bun test"},dependencies:{"@modelcontextprotocol/sdk":"^1.29.0",exceljs:"^4.4.0","iconv-lite":"^0.7.3",ky:"^2.0.2","pinyin-pro":"^3.29.3",yauzl:"^3.4.0",zod:"^4.4.3"},devDependencies:{"@types/bun":"^1.3.14","@types/yauzl":"^3.4.0","bun-types":"^1.3.14",typescript:"^5.9.3",yaml:"^2.9.0"}};function Yy0($,I=UQ.version){let z=$.trim();if(!z)return null;let q=z.endsWith("-dirty"),U=q?z.slice(0,-6):z,Y=U.match(/^v?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)-(\d+)-g([0-9a-f]+)$/);if(Y&&Y[1]&&Y[2]&&Y[3])return{baseVersion:Y[1],commitsAhead:Number.parseInt(Y[2],10),commit:Y[3],dirty:q,describe:z};let J=U.match(/^v?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.]+)?)$/);if(J&&J[1])return{baseVersion:J[1],commitsAhead:0,commit:"",dirty:q,describe:z};let Q=U.match(/^([0-9a-f]{7,40})$/);if(Q&&Q[1])return{baseVersion:I,commitsAhead:0,commit:Q[1],dirty:q,describe:z};return null}function Jy0($,I,z,q){let Y=z?`+g${z}${q?".dirty":""}`:q?"+dirty":"";return`${$}-dev.${I}${Y}`}function Qy0($){let I=$?.env,z=I?.SEAL_BUILD_VERSION??process.env.SEAL_BUILD_VERSION,q=I?.SEAL_BUILD_IS_RELEASE??process.env.SEAL_BUILD_IS_RELEASE,U=I?.SEAL_BUILD_CHANNEL??process.env.SEAL_BUILD_CHANNEL,Y=I?.SEAL_BUILD_GIT_BASE??process.env.SEAL_BUILD_GIT_BASE,J=I?.SEAL_BUILD_GIT_COMMITS_AHEAD??process.env.SEAL_BUILD_GIT_COMMITS_AHEAD,Q=I?.SEAL_BUILD_GIT_COMMIT??process.env.SEAL_BUILD_GIT_COMMIT,K=I?.SEAL_BUILD_GIT_DIRTY??process.env.SEAL_BUILD_GIT_DIRTY,w=I?.SEAL_BUILD_GIT_DESCRIBE??process.env.SEAL_BUILD_GIT_DESCRIBE,G=I?.SEAL_FORCE_RELEASE??process.env.SEAL_FORCE_RELEASE,H=$?.cwd;if(z){let W=q==="true",X={name:"seal-use",version:z,channel:U||(W?"release":"dev"),isRelease:W};if(Y)X.git={baseVersion:Y,commitsAhead:Number.parseInt(J||"0",10),commit:Q||"",dirty:K==="true",describe:w||z};return X}if(q==="true"||G==="1")return{name:"seal-use",version:UQ.version,channel:"release",isRelease:!0};try{let W=Or("git",["describe","--tags","--long","--dirty","--always"],{cwd:H,encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(W.status===0&&W.stdout){let V=Yy0(W.stdout.trim(),UQ.version);if(V){if(!V.commit){let L=Or("git",["rev-parse","--short","HEAD"],{cwd:H,encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(L.status===0&&L.stdout)V.commit=L.stdout.trim()}return{name:"seal-use",version:Jy0(V.baseVersion,V.commitsAhead,V.commit,V.dirty),channel:"dev",isRelease:!1,git:V}}}}catch{}return{name:"seal-use",version:`${UQ.version}-dev.0+local`,channel:"dev",isRelease:!1}}var YQ=Qy0(),q1=YQ.version,Fj=YQ.isRelease,Kj1=YQ.channel;c4();rO();eu();A4();G4();u1();w$();A4();c4();c4();aK();Mk();G4();u1();k$();import{existsSync as qD0}from"node:fs";async function UD0($,I){if(!qD0($))throw Error(`Filenotfound:${$}`);let z=nI($);console.log(JSON.stringify(await bI(z.fileBuffer,z.fileName,I),null,2))}async function mD($,I,z,q,U){if($==="ready"||$==="status"){let Y=I??E(U.options.file)??E(U.options.input),J=await gD(z,q,{filePath:Y,webhook:E(U.options.webhook)??E(U.options.selector)});if(console.error(`[webhook-ready]企业环境:${J.corp.name}(${J.corp.id})[${J.stateMode}]`),J.corp.tenant?.name)console.error(`[webhook-ready]租户信息:${J.corp.tenant.name}(${J.corp.tenant.id})`);console.error(`[webhook-ready]凭证状态:${J.authStatus==="ok"?"OK":`异常 (${J.authError})`}`),console.error(`[webhook-ready]Webhook通道:${J.activeWebhooLine truncated
`+`\uD83D\uDC49查看全部请添加:seal-usecorpslist--all
`+"\uD83D\uDC49 检索指定企业请使用: seal-use corps search <keyword>")}T0(O.map((A)=>({id:A.id,name:A.name,environment:A.environment??"production",sourceType:A.source.type,provider:A.source.provider??A.source.type,staffId:A.source.staffId,testCorpId:A.testCorpId,prodCorpId:A.prodCorpId,current:A.id===w})));return}if($==="get"||$==="show"){let q=I??E(z.options.corp);if(!q)throw M4("Usage: seal-use corps get <corpId>");let U=w1(q),Y=Yx(U.id),J=MX1(U);T0({id:U.id,name:U.name,environment:U.environment??"production",configFile:Y,seal:{url:J,tenantSlug:U.seal.tenantSlug??U.source.tenantSlug,customHeaderNames:U.seal.headers?Object.keys(U.seal.headers):[],customCookieNames:U.seal.cookies?Object.keys(U.seal.cookies):[],endpoints:U.seal.endpoints},source:AX1(U.source),relations:{testCorpId:U.testCorpId,prodCorpId:U.prodCorpId},auth:{refreshTtl:U.auth.refreshTtl}});return}if($==="current"){let q=w1(E(z.options.corp));T0({id:q.id,name:q.name,environment:q.environment??"production",sourceType:q.source.type,provider:q.source.provider??q.source.type,staffId:q.source.staffId,testCorpId:q.testCorpId,prodCorpId:q.prodCorpId});return}if($==="mark"||$==="mark-test"||$==="mark-prod"){let q=I??E(z.options.corp);if(!q)throw M4("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");let U=w1(q),Y=$==="mark-test"?"test":$==="mark-prod"?"production":E(z.options.env)??E(z.options.environment);if(Y!=="production"&&Y!=="test")throw M4("Usage: seal-use corps mark <corpId> --env <production|test> [--confirm]");if(!(V0(z.options.confirm)===!0||V0(z.options.yes)===!0))throw X5(`Refusingtochangeenvironmenttagofenterprise'${U.name}'(${U.id})to'${Y}'without--confirm.Markingalterssynchronizationsafetyguards.`,`seal-usecorpsmark${U.id}--env${Y}--confirm`);let Q=d7(U.id,{environment:Y});T0({id:Q.id,name:Q.name,environment:Q.environment,testCorpId:Q.testCorpId,prodCorpId:Q.prodCorpId});return}if($==="bind-test"){let q,U;if(I&&z.command[3])q=I,U=z.command[3];else if(I){let H=E(z.options.corp),W=E(z.options["test-corp"])??E(z.options.testCorp);if(H)q=H,U=I;else if(W)q=I,U=W}if(!q||!U)throw M4(`Usage:seal-usecorpsbind-test<prodCorpId><testCorpId>[--confirm][--force]
Run'seal-use corps bind-test ${U.id} <testCorpId> --confirm'firsttoestablishaverified1-to-1association.`);let Y=G1(U.testCorpId);if(Y.environment!=="test")throw Error(`Targetenterprise'${Y.name}'(${Y.id})ismarkedas'${Y.environment}',NOT'test'.Abortingsynctoprotectnon-testenvironments.`);let J=await Q1(U),Q=await Q1(Y),[K,w,G,H,W,V,X,L]=await Promise.all([E1(J,U.seal.endpoints.approvalStylePreferences).catch(()=>({})),E1(Q,Y.seal.endpoints.approvalStylePreferences).catch(()=>({})),W6(J),W6(Q),r$(J).catch(()=>[]),r$(Q).catch(()=>[]),d9(J,{limit:100}).catch(()=>({articles:[]})),d9(Q,{limit:100}).catch(()=>({articles:[]}))]),O=(X.articles||[]).filter((m)=>!m.isDeleted),D=(L.articles||[]).filter((m)=>!m.isDeleted),A=new Map(D.map((m)=>[m.title.trim(),m])),T=[],M=[],j=new Set(O.map((m)=>m.title.trim()));for(let m of O){let B0=m.title.trim(),k0=A.get(B0);if(!k0)T.push(m);else{let W1=k0.content!==m.content,T4=(k0.purpose??"")!==(m.purpose??""),S4=k0.enabled!==m.enabled,b$=k0.contentType!==m.contentType,$$=(k0.status??"")!==(m.status??""),k6=JSON.stringify([...k0.scenarios??[]].sort())!==JSON.stringify([...m.scenarios??[]].sort()),n$=JSON.stringify([...k0.tags??[]].sort())!==JSON.stringify([...m.tags??[]].sort());if(W1||T4||S4||b$||$$||k6||n$)M.push({testId:k0.id,prodDoc:m,reasons:[...W1?["content"]:[],...T4?["purpose"]:[],...S4?["enabled"]:[],...b$?["contentType"]:[],...$$?["status"]:[],...k6?["scenarios"]:[],...n$?["tags"]:[]]})}}let x=D.filter((m)=>!j.has(m.title.trim())),b=[...W].sort((m,B0)=>B0.versionNumber-m.versionNumber)[0],R=b?.versionNumber,n=([...V].sort((m,B0)=>B0.versionNumber-m.versionNumber)[0]?.versionNumber??0)+1,C=NF0(U.name,R,V),p=E(z.options["version-name"])??E(z.options.versionName)??MF0(U.name,R,C,n),z0={...w,tone:K.tone,language:K.language,detailLevel:K.detailLevel,outputFormat:K.outputFormat,examples:K.examples??[],prohibitedPhrases:K.prohibitedPhrases??[],customInstructions:K.customInstructions,decisionPreferences:K.decisionPreferences,thinkingDepthPreference:K.thinkingDepthPreference};if(V0(z.options["dry-run"])===!0||V0(z.options.dryRun)===!0){P0({dryRun:!0,source:{id:U.id,name:U.name,environment:U.environment,latestPublishedVersion:b?{versionNumber:b.versionNumber,versionName:b.versionName}:null,documentsCount:O.length},target:{id:Y.id,name:Y.name,environment:Y.environment},versionMappingPlan:{sourceProdVersionNumber:R??null,sourceProdVersionName:b?.versionName??null,targetTestExpectedVersionNumber:n,targetTestPublishVersionName:p,iteration:C},preferencesDiff:{decisionPreferences:{before:w.decisionPreferences,after:K.decisionPreferences},thinkingDepthPreference:{before:w.thinkingDepthPreference,after:K.thinkingDepthPreference}},rulesPlan:{sourceDraftRuleCount:G.rules.length,targetExistingDraftRuleCount:H.rules.length,toDeleteCount:H.rules.length,toCreateCount:G.rules.length,rulesToSync:G.rules.map((m,B0)=>({index:B0+1,sourceRuleId:m.id,sourceRuleCode:m.code??B0+1,expectedTargetCode:`rule-${B0+1}`,description:m.description,scope:m.scope,strictness:m.strictness}))},documentsPlan:{sourceDocumentCount:O.length,targetExistingDocumentCount:D.length,toCreateCount:T.length,toCreate:T.map((m)=>({title:m.title,purpose:m.purpose,contentType:m.contentType,scenarios:m.scenarios})),toUpdateCount:M.length,toUpdate:M.map((m)=>({targetDocumentId:m.testId,title:m.prodDoc.title,reasons:m.reasons})),toDeleteCount:x.length,toDelete:x.map((m)=>({targetDocumentId:m.id,title:m.title}))},publishingPlan:{targetCorpId:Y.id,publishVersionName:p,publishTarget:"test"},hosecloudSyncPlan:(()=>{if(U.source.type!=="hose")return{sourceType:U.source.type,skipped:!0,reason:"prod source is not hose; no hosecloud credentials available"};let m=(K.integrations??[]).filter((W1)=>W1.type==="hosecloud"),B0=new Set,k0=m.filter((W1)=>{let T4=W1.corporationId??U.id;if(B0.has(T4))return!1;return B0.add(T4),!0});return{sourceType:"hose",outboundName:jF0(U.name),targetMode:"assisted",integrationsCount:k0.length,integrations:k0.map((W1)=>({corporationId:W1.corporationId,apiOrigin:W1.apiOrigin,customApiUrl:W1.customApiUrl}))}})(),productionGuarantees:{prodRulesStayDraft:!0,prodVersionPublished:!1}});return}if(!(V0(z.options.yes)===!0||V0(z.options.confirm)===!0))throw X5(`Refusingtooverwritetestenterprise'${Y.name}'(${Y.id})withpreferences,${G.rules.length}draftrules,and${O.length}knowledgedocumentsfromproductionenterprise'${U.name}'(${U.id})without--yes.Thiswillreplacetestdraftrules,synchronizeknowledgedocuments,andpublishanewversiononthetestenterprise.`,`seal-usecorpssync-test${U.id}--yes`);await i8(Q,z0,Y.seal.endpoints.approvalStylePreferences);let c=[];for(let m of x)await oW(Q,m.id),c.push({id:m.id,title:m.title});let r=[];for(let m of M)await lW(Q,m.testId,{title:m.prodDoc.title,purpose:m.prodDoc.purpose,content:m.prodDoc.content,contentType:m.prodDoc.contentType,status:m.prodDoc.status,enabled:m.prodDoc.enabled,scenarios:m.prodDoc.scenarios&&m.prodDoc.scenarios.le
Line truncated
Run'seal-use corps bind-test ${U.id} <testCorpId> --confirm'firsttoestablishaverified1-to-1association,
oradd'--force'(oruse'seal-use webhook replay <recordId> --force')ifyouexplicitlyintendtoreplaydirectlywithinproduction.`);J=U}else if(J=w1(U.testCorpId),J.environment!=="test"&&!Y)throw Error(`Targetenterprise'${J.name}'(${J.id})ismarkedas'${J.environment}',NOT'test'.Abortingreplaytoprotectnon-testenvironments(use--forcetooverride).`);let Q=E(z.options.recordId)??E(z.options["record-id"])??E(z.options.id),K=E(z.options.recordIds)??E(z.options["record-ids"]),w=K?K.split(",").map((b)=>b.trim()).filter(Boolean):void 0,G=E(z.options.sn)??E(z.options.documentSn)??E(z.options["document-sn"]),H=E(z.options.sns)??E(z.options["document-sns"]),W=H?H.split(",").map((b)=>b.trim()).filter(Boolean):void 0,V=_0(z.options.limit)??(!Q&&!w&&!G&&!W?1:void 0),X=E(z.options.status),L=E(z.options.startDate)??E(z.options["start-date"]),D=E(z.options.endDate)??E(z.options["end-date"]),O=await J1(U),A=U.id===J.id?O:await J1(J),T=E(z.options.webhook)??E(z.options.selector),M=E(z.options.snSuffix)??E(z.options["sn-suffix"]),v=E(z.options.snPrefix)??E(z.options["sn-prefix"]),x=E(z.options.docIdSuffix)??E(z.options["doc-id-suffix"]),h=E(z.options.docIdPrefix)??E(z.options["doc-id-prefix"]),k=V0(z.options.dryRun)??V0(z.options["dry-run"]),j={recordId:Q,recordIds:w,sn:G,sns:W,limit:V,status:X,startDate:L,endDate:D};console.error(`[corps-replay-test]正式企业「${U.name}」(${U.id})->测试企业「${J.name}」(${J.id})`);let n=await aU({query:j,sourceClient:O,targetClient:A,sourceCorp:U,targetCorp:J,webhookSelector:T,snPrefix:v,snSuffix:M,docIdPrefix:h,docIdSuffix:x,dryRun:k});if(k){console.error(`[corps-replay-test]预览模式:已成功从${U.name}提取单据并转换为WebhookPayload(未实际推送)。`),console.log(JSON.stringify(n,null,2));return}if(n.success)if(n.totalCount===1&&n.replayedDocument)console.error(`\uD83D\uDFE2成功重放单据「${n.replayedDocument.documentSN}」至${J.name}(${n.targetWebhook?.name??"Webhook 通道"})`);else console.error(`\uD83D\uDFE2成功重放${n.successCount}条单据(来自「${U.name}」)至「${J.name}」(${n.targetWebhook?.name??"Webhook 通道"})`);else console.error(`\uD83D\uDD34单据重放部分或全部失败(成功${n.successCount}条,失败${n.failureCount}条)至「${J.name}」`);if(console.error(`\uD83D\uDC49Nextaction:seal-useapproval-runslist--corp${J.id}--limit${n.totalCount}`),console.log(JSON.stringify(n,null,2)),!n.success)process.exitCode=1;return}if($==="switch"){let q=I;if(!q)throw Error("Usage: seal-use corps switch <corpId>");let U=K4();if(!U.stateful)throw Error("Cannot switch the default enterprise while stateless mode is enabled. Use `seal-useconfigmodestateful` first.");let Y=w1(q);uI({...U,stateful:!0,defaultCorpId:Y.id}),T0({current:!0,id:Y.id,name:Y.name});return}if($==="probe-hose"){await TX1(s6(z.json));return}if($==="hose-staffs"){await EX1(s6(z.json));return}if($==="add-hose"){await BX1(s6(z.json));return}if($==="add-seal"){await jX1(s6(z.json));return}if($==="add-link"){let q=I??E(z.options.link)??E(z.options.url);if(!q)throw Error("Usage: seal-use corps add-link <https://.../web/thirdparty.html?...> [--name <customName>] [--overwrite]");await vX1(q,E(z.options.name),V0(z.options.overwrite)===!0);return}throw Error(`Unknowncorpscommand:${$??""}.Run'seal-use help'foravailablecommands.`)}function jF0($){return[...$].slice(0,6).join("")+"(Seal测)"}async function PX1($,I,z,q){if($.source.type!=="hose")return{skipped:!0,reason:"prod source is not hose; no hosecloud credentials available"};let U=($.source.appKey??$.source.key)?.trim(),Y=($.source.appSecurity??$.source.password)?.trim();if(!U||!Y)return{skipped:!0,reason:"prod hose source missing appKey/appSecurity (or key/password)"};let[J,Q]=await Promise.all([E1(z,$.seal.endpoints.approvalStylePreferences).catch(()=>({})),E1(q,I.seal.endpoints.approvalStylePreferences).catch(()=>({}))]),K=(J.integrations??[]).filter((A)=>A.type==="hosecloud");if(K.length===0)return{skipped:!0,reason:"prod Seal enterprise has no hosecloud integrations configured"};let w=new Set,G=[];for(let A of K){let T=A.corporationId??$.id;if(!w.has(T))w.add(T),G.push(A)}let H=Q.integrations??[],W=new Map(H.filter((A)=>A.type==="hosecloud").map((A)=>[A.corporationId,A])),V=jF0($.name),X=[],L=G.map((A)=>{let T=W.get(A.corporationId),M=T?.signKey??NX1(6).toString("hex");return X.push({signKey:M,outboundName:V,corporationId:A.corporationId,action:T?"updated":"created"}),{type:"hosecloud",signKey:M,outboundName:V,mode:"assisted",apiKey:U,apiSecret:Y,apiOrigin:A.apiOrigin,...A.customApiUrl?{customApiUrl:A.customApiUrl}:{},corporationId:A.corporationId}}),D=H.filter((A)=>A.type!=="hosecloud"),O={...Q,integrations:[...D,...L]};return await i8(q,O,I.seal.endpoints.approvalStylePreferences),{skipped:!1,synced:X}}async function TX1($){let I=L9($,"appKey"),z=L9($,"appSecurity"),q=b1($,"domain"),U=await az(I,z,q),Y=await yW(U.domain,U.openapiToken).catch(()=>[])
Line truncated
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let W of H){let V=W.outboundName??"SealAI 审批",X=W.signKey,L=W.apiOrigin??"production";console.error(`•"${V}"(signKey:${X},环境:${L})`),console.error(`\uD83D\uDC49查看命令:seal-usedeployhosecloudget${X}--corp${U.id}
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let X of W){let L=X.outboundName??"SealAI 审批",D=X.signKey,O=X.apiOrigin??"production";console.error(`•"${L}"(signKey:${D},环境:${O})`),console.error(`\uD83D\uDC49同步命令:seal-usedeployhosecloudsync${D}--corp${U.id}
`),console.error("ℹ️ 当前企业发现以下可用的合思配置卡片:");for(let X of W){let L=X.outboundName??"SealAI 审批",O=X.signKey,D=X.apiOrigin??"production";console.error(`•"${L}"(signKey:${O},环境:${D})`),console.error(`\uD83D\uDC49同步命令:seal-usedeployhosecloudsync${O}--corp${U.id}
`);throw new N4("缺少必需参数 <sign-key>。请从上述候选列表中选择并指定 signKey 执行同步。",2,W.length===1?`seal-usedeployhosecloudsync${W[0].signKey}--corp${U.id}`:void 0)}await N0("seal_deploy_hosecloud_sync",q,U,{signKey:w},Z0(Y.options));return}throw Error(`Unknowndeployhosecloudaction:${Q??""}.Available:requirements,list,get,status,configure,sync.`)}Ox();import{accessSync as dX1,constants as mX1,existsSync as x6,readdirSync as lX1}from"node:fs";import{homedir as oX1}from"node:os";import{join as O9}from"node:path";G9();import{existsSync as rk,mkdirSync as cF0,rmSync as iX1,writeFileSync as pX1}from"node:fs";import{homedir as dF0}from"node:os";import{dirname as cX1,join as tk}from"node:path";var hF0=`---
`);throw new N4("缺少必需参数 <sign-key>。请从上述候选列表中选择并指定 signKey 执行同步。",2,W.length===1?`seal-usedeployhosecloudsync${W[0].signKey}--corp${U.id}`:void 0)}await N0("seal_deploy_hosecloud_sync",q,U,{signKey:w},Z0(Y.options));return}throw Error(`Unknowndeployhosecloudaction:${Q??""}.Available:requirements,list,get,status,configure,sync.`)}Fx();import{accessSync as lX1,constants as oX1,existsSync as x6,readdirSync as rX1}from"node:fs";import{homedir as tX1}from"node:os";import{join as D9}from"node:path";G9();import{existsSync as tk,mkdirSync as cF0,rmSync as cX1,writeFileSync as dX1}from"node:fs";import{homedir as dF0}from"node:os";import{dirname as mX1,join as ak}from"node:path";var hF0=`---
name:seal-use
description:"v0.10.20: Use for Seal Use first-time enterprise onboarding, Hose/合思 or Seal-native authentication, assistance links and browser cURL intake, plus tenant approval operations, diagnosis, simulation, rules, users, configuration, and search."
`;var xF0="# Seal Use CLI Reference\n\nRun from any directory after installing the global CLI:\n\n```bash\nseal-use<command>\n```\n\nEnterprise config lookup:\n\n- If `SEAL_USE_ENTERPRISES_DIR` is set, only that directory is loaded.\n- Otherwise the user-level `~/.config/seal-use/enterprises`directoryisloaded.Aconfigured\n`testEnterprisesDir`isloadedfirstfortest-tenantworkflows.Thecurrentworkingdirectory's\n`./enterprises`directoryisnotloadedimplicitly.\n-Set`SEAL_USE_ENTERPRISES_DIR`touseoneexplicitdirectoryinstead.Legacy\n`~/.config/seal-home/enterprises`filesaremigratedtotheprimarydirectorywhenpossible.\n\nEnterpriseselectionisstatelessbydefault.Commandsthataccessanenterpriserequire\n`--corp<corpId>`unlessstatefulmodeisexplicitlyenabled:\n\n```bash\nseal-useconfigmodestateful--corp<corpId>\nseal-usecorpsswitch<corpId>\nseal-useconfigmodestateless\n```\n\nTheglobalmodeisstoredin`~/.config/seal-use/config.json`;set`SEAL_USE_CONFIG_FILE`to\noverridethatpath.Thelegacy`current-corp`fileisnotread.\n\n##Stream&ExitCodeContract\n\n-**`stdout`**:Pure,deterministicJSONformachine/Agentparsing.\n-**`stderr`**:Diagnostics,probinglogs,and**Next-StepCommandSuggestions**withthestableprefix`👉Nextaction:seal-use...`.\n-**`ExitCode`**:`0`onsuccess;`1`runtime/upstreamfailure,`2`usage/argumenterror,`10`explicitdestructive-operationconfirmationrequired,`11`missing/invalidauthentication,and`12`outputprotectionrequiringacompact/file/queryalternative.\n\n##Top-LevelCommands\n\n```bash\nseal-useversion\nseal-useconfigpaths\nseal-useconfigget\nseal-useconfigmode<stateful|stateless>[--corp<corpId>]\nseal-useconfigtest-dir[<path>|--clear]\nseal-useconfiglint<enable|disable|status>[--linter<name>][--min-score<score>]\nseal-userulescount[--corp<corpId>]\nseal-useruleslist[--summary][--count][--limit20][--offset0][--corp<corpId>]\nseal-userulesclear[--corp<corpId>][--dry-run|--yes]\nseal-userulesversions[--corp<corpId>]\nseal-userulesversion<versionId|versionNumber|latest>[--corp<corpId>]\nseal-userulesget--corp<corpId>--version<number|latest>--code'#0038'\nseal-userulesget--corp<corpId>--record-id<recordId>--runtime-idrule-205\nseal-userulessearch<keyword>[--version<versionId|versionNumber|latest>][--maxResults20][--corp<corpId>]\nseal-userulespull[--corp<corpId>][--version<id|num|latest>][--out<file>]\nseal-useruleslint[--file<path>][--corp<corpId>][--linter<name|path>][--version<num>][--code<code>][--min-score<score>][--summary]\nseal-useruleslinters[--corp<corpId>]\nseal-userulespush[--file<path>][--corp<corpId>][--publish][--version-name<name>][--dry-run|--yes]\nseal-userulesmap[--corp<corpId>][--version<id|num|latest>][--code<code>]\nseal-useservice<start|stop|restart|status|logs>[--port8787][--host127.0.0.1][--lines50]\nseal-usehttp[--port8787][--host127.0.0.1]\nseal-useserve[--port8787]\nseal-useupdate[--check][--force][--version<v>]\nseal-useupdatecheck\nseal-useupdatechangelog[--limit<n>]\nseal-usechangelog[--limit<n>]\nseal-usemcp\nseal-usemcpconfig\nseal-usemcp-config\nseal-useskilldump\nseal-useskillinstall[--dir<path>|--local]\nseal-useskillstatus\nseal-usedoctor[--quiet]\nseal-usedoctortenant[--corp<corpId>][--quiet]\nseal-usedoctorguide\nseal-usedoctorpaths\nseal-usetestregression[--corp<corpId>][--samples<N>][--dry-run][--fail-on-flips]\nseal-useprobe[<corpId>]\nseal-usetoolslist\nseal-usecorpslist[query][--env<production|test>][--limit<n>][--all][--sort<usage|name|id>][--strict][--corp<corpId>]\nseal-usecorpssearch<query>[--env<production|test>][--strict]\nseal-usecorpsget<corpId>\nseal-usecorpscurrent[--corp<corpId>]\nseal-usecorpsswitch<corpId>\nseal-usecorpsmark<corpId>--env<production|test>[--confirm]\nseal-usecorpsbind-test<prodCorpId><testCorpId>[--confirm][--force]\nseal-usecorpsunbind-test[<corpId>][--confirm]\nseal-usecorpssync-test[<prodCorpId>][--dry-run][--yes][--version-name<name>]\nseal-usecorpsreplay-test[<prodCorpId>][--record-id<id>][--sn<sn>][--limit<n>][--status<status>][--webhook<idOrName>][--sn-suffix<str>][--dry-run][--force]\nseal-usecorpsregression[--corp<corpId>][--samples<N>][--dry-run][--fail-on-flips]\nseal-usecorpsadd-hose--json'{\"name\":\"企业名称\",\"domain\":\"https://app.ekuaibao.com\",\"appKey\":\"...\",\"appSecurity\":\"...\",\"proxyStaffBizId\":\"corpId:staffId\"}'\nseal-usecorpsadd-seal--json'{\"sealUrl\":\"https://tenant.sealai.cc\",\"token\":\"seal-bearer-token\"}'\nseal-usecorpsadd-link<https://.../web/thirdparty.html?...>[--name<customName>][--overwrite]\nseal-useauthdiagnose[--corp<corpId>]\nseal-useauthhose-link[--corp<corpId>][--expire7200]Line truncated
`;var xF0="# Seal Use CLI Reference\n\nRun from any directory after installing the global CLI:\n\n```bash\nseal-use<command>\n```\n\nEnterprise config lookup:\n\n- If `SEAL_USE_ENTERPRISES_DIR` is set, only that directory is loaded.\n- Otherwise the user-level `~/.config/seal-use/enterprises`directoryisloaded.Aconfigured\n`testEnterprisesDir`isloadedfirstfortest-tenantworkflows.Thecurrentworkingdirectory's\n`./enterprises`directoryisnotloadedimplicitly.\n-Set`SEAL_USE_ENTERPRISES_DIR`touseoneexplicitdirectoryinstead.Legacy\n`~/.config/seal-home/enterprises`filesaremigratedtotheprimarydirectorywhenpossible.\n\nEnterpriseselectionisstatelessbydefault.Commandsthataccessanenterpriserequire\n`--corp<corpId>`unlessstatefulmodeisexplicitlyenabled:\n\n```bash\nseal-useconfigmodestateful--corp<corpId>\nseal-usecorpsswitch<corpId>\nseal-useconfigmodestateless\n```\n\nTheglobalmodeisstoredin`~/.config/seal-use/config.json`;set`SEAL_USE_CONFIG_FILE`to\noverridethatpath.Thelegacy`current-corp`fileisnotread.\n\n##Stream&ExitCodeContract\n\n-**`stdout`**:Pure,deterministicJSONformachine/Agentparsing.\n-**`stderr`**:Diagnostics,probinglogs,and**Next-StepCommandSuggestions**withthestableprefix`👉Nextaction:seal-use...`.\n-**`ExitCode`**:`0`onsuccess;`1`runtime/upstreamfailure,`2`usage/argumenterror,`10`explicitdestructive-operationconfirmationrequired,`11`missing/invalidauthentication,and`12`outputprotectionrequiringacompact/file/queryalternative.\n\n##Top-LevelCommands\n\n```bash\nseal-useversion\nseal-useconfigpaths\nseal-useconfigget\nseal-useconfigmode<stateful|stateless>[--corp<corpId>]\nseal-useconfigtest-dir[<path>|--clear]\nseal-useconfiglint<enable|disable|status>[--linter<name>][--min-score<score>]\nseal-userulescount[--corp<corpId>]\nseal-useruleslist[--summary][--count][--limit20][--offset0][--corp<corpId>]\nseal-userulesclear[--corp<corpId>][--dry-run|--yes]\nseal-userulesversions[--corp<corpId>]\nseal-userulesversion<versionId|versionNumber|latest>[--corp<corpId>]\nseal-userulesget--corp<corpId>--version<number|latest>--code'#0038'\nseal-userulesget--corp<corpId>--record-id<recordId>--runtime-idrule-205\nseal-userulessearch<keyword>[--version<versionId|versionNumber|latest>][--maxResults20][--corp<corpId>]\nseal-userulespull[--corp<corpId>][--version<id|num|latest>][--out<file>]\nseal-useruleslint[--file<path>][--corp<corpId>][--linter<name|path>][--version<num>][--code<code>][--min-score<score>][--summary]\nseal-useruleslinters[--corp<corpId>]\nseal-userulespush[--file<path>][--corp<corpId>][--publish][--version-name<name>][--dry-run|--yes]\nseal-userulesmap[--corp<corpId>][--version<id|num|latest>][--code<code>]\nseal-useservice<start|stop|restart|status|logs>[--port8787][--host127.0.0.1][--lines50]\nseal-usehttp[--port8787][--host127.0.0.1]\nseal-useserve[--port8787]\nseal-useupdate[--check][--force][--version<v>]\nseal-useupdatecheck\nseal-useupdatechangelog[--limit<n>]\nseal-usechangelog[--limit<n>]\nseal-usemcp\nseal-usemcpconfig\nseal-usemcp-config\nseal-useskilldump\nseal-useskillinstall[--dir<path>|--local]\nseal-useskillstatus\nseal-usedoctor[--quiet]\nseal-usedoctortenant[--corp<corpId>][--quiet]\nseal-usedoctorguide\nseal-usedoctorpaths\nseal-usetestregression[--corp<corpId>][--samples<N>][--dry-run][--fail-on-flips]\nseal-useprobe[<corpId>]\nseal-usetoolslist\nseal-usecorpslist[query][--env<production|test>][--limit<n>][--all][--sort<usage|name|id>][--strict][--corp<corpId>]\nseal-usecorpssearch<query>[--env<production|test>][--strict]\nseal-usecorpsget<corpId>\nseal-usecorpscurrent[--corp<corpId>]\nseal-usecorpsswitch<corpId>\nseal-usecorpsmark<corpId>--env<production|test>[--confirm]\nseal-usecorpsbind-test<prodCorpId><testCorpId>[--confirm][--force]\nseal-usecorpsunbind-test[<corpId>][--confirm]\nseal-usecorpssync-test[<prodCorpId>][--dry-run][--yes][--version-name<name>]\nseal-usecorpsreplay-test[<prodCorpId>][--record-id<id>][--sn<sn>][--limit<n>][--status<status>][--webhook<idOrName>][--sn-suffix<str>][--dry-run][--force]\nseal-usecorpsregression[--corp<corpId>][--samples<N>][--dry-run][--fail-on-flips]\nseal-usecorpsadd-hose--json'{\"name\":\"企业名称\",\"domain\":\"https://app.ekuaibao.com\",\"appKey\":\"...\",\"appSecurity\":\"...\",\"proxyStaffBizId\":\"corpId:staffId\"}'\nseal-usecorpsadd-seal--json'{\"sealUrl\":\"https://tenant.sealai.cc\",\"token\":\"seal-bearer-token\"}'\nseal-usecorpsadd-link<https://.../web/thirdparty.html?...>[--name<customName>][--overwrite]\nseal-useauthdiagnose[--corp<corpId>]\nseal-useauthhose-link[--corp<corpId>][--expire7200]Line truncated
`)}G4();u1();async function IN0($,I,z){let q=($??I??"").toLowerCase();if(q==="guide"||q==="doc"||q==="knowledge"||q==="book"){console.error(`\uD83D\uDCD6[SealUseDoctor]正在读取内嵌系统规范白皮书(纯内存只读)...
`},servers:[{url:"http://localhost:8787",description:"Reserved for a future local HTTP adapter; the current service uses MCP stdio."}],security:[{localSession:[]}],tags:[{name:"Corps",description:"Local enterprise configuration selection."},{name:"Source",description:"Source-derived Seal enterprise configuration."},{name:"Auth",description:"Wrapped authentication diagnostics and current identity."},{name:"Approval Runs",description:"Wrapped approval run history, summaries, document URLs, and trace bridge helpers."},{name:"Approval Knowledge",description:"Wrapped approval rules, documents, preferences, and search."},{name:"Simulation",description:"Wrapped simulation batch record access."}],paths:{"/v1/corps":{get:{tags:["Corps"],operationId:"listCorps",summary:"List configured enterprises",responses:{"200":{description:"Configured enterprises.",content:{"application/json":{schema:{type:"array",items:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}}}}}}}}},"/v1/corps/current":{get:{tags:["Corps"],operationId:"getCurrentCorp",summary:"Get current enterprise",description:"Returns the configured default enterprise in stateful mode. Stateless mode has no current enterprise and requires an explicit corpId for enterprise operations.",responses:{"200":{description:"Current enterprise.",content:{"application/json":{schema:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}}}}}}}},"/v1/corps/current/switch":{post:{tags:["Corps"],operationId:"switchCurrentCorp",summary:"Switch current enterprise",requestBody:{required:!0,content:{"application/json":{schema:{type:"object",required:["corpId"],properties:{corpId:{type:"string"}}}}}},responses:{"200":{description:"Switched enterprise.",content:{"application/json":{schema:{type:"object",required:["current","id","name"],properties:{current:{type:"boolean"},id:{type:"string"},name:{type:"string"}}}}}},"404":{description:"Requested resource was not found.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}}}},"/v1/source/config":{get:{tags:["Source"],operationId:"getSourceConfig",summary:"Resolve source-derived Seal enterprise config",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."}],responses:{"200":{description:"Redacted Seal enterprise config.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,description:"Redacted Seal enterprise config resolved from the configured source."}}}},"401":{description:"Local service authentication failed or downstream Seal auth failed.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}}}},"/v1/auth/diagnose":{get:{tags:["Auth"],operationId:"diagnoseAuth",summary:"Diagnose wrapped source-to-Seal authentication",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."}],responses:{"200":{description:"Authentication stage diagnosis.",content:{"application/json":{schema:{type:"object",required:["stages"],properties:{stages:{type:"array",items:{$ref:"#/components/schemas/AuthStage"}}}}}}}}}},"/v1/whoami":{get:{tags:["Auth"],operationId:"whoami",summary:"Get current wrapped Seal identity",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."}],responses:{"200":{description:"Current Seal user and tenant.",content:{"application/json":{schema:{type:"object",required:["user","tenant"],properties:{user:{$ref:"#/components/schemas/SealUser"},tenant:{$ref:"#/components/schemas/SealTenant"}}}}}},"401":{description:"Local service authentication failed or downstream Seal auth failed.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}}}},"/v1/session":{get:{tags:["Auth"],operationId:"getSession",summary:"Get current wrapped Seal session metadata",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."}],responses:{"2
Line truncated
`},servers:[{url:"http://localhost:8787",description:"Reserved for a future local HTTP adapter; the current service uses MCP stdio."}],security:[{localSession:[]}],tags:[{name:"Corps",description:"Local enterprise configuration selection."},{name:"Source",description:"Source-derived Seal enterprise configuration."},{name:"Auth",description:"Wrapped authentication diagnostics and current identity."},{name:"Approval Runs",description:"Wrapped approval run history, summaries, document URLs, and trace bridge helpers."},{name:"Approval Knowledge",description:"Wrapped approval rules, documents, preferences, and search."},{name:"Simulation",description:"Wrapped simulation batch record access."}],paths:{"/v1/corps":{get:{tags:["Corps"],operationId:"listCorps",summary:"List configured enterprises",responses:{"200":{description:"Configured enterprises.",content:{"application/json":{schema:{type:"array",items:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}}}}}}}}},"/v1/corps/current":{get:{tags:["Corps"],operationId:"getCurrentCorp",summary:"Get current enterprise",description:"Returns the configured default enterprise in stateful mode. Stateless mode has no current enterprise and requires an explicit corpId for enterprise operations.",responses:{"200":{description:"Current enterprise.",content:{"application/json":{schema:{type:"object",required:["id","name","sourceType","current"],properties:{id:{type:"string"},name:{type:"string"},sourceType:{type:"string",enum:["hose","direct","seal"]},current:{type:"boolean"}}}}}}}}},"/v1/corps/current/switch":{post:{tags:["Corps"],operationId:"switchCurrentCorp",summary:"Switch current enterprise",requestBody:{required:!0,content:{"application/json":{schema:{type:"object",required:["corpId"],properties:{corpId:{type:"string"}}}}}},responses:{"200":{description:"Switched enterprise.",content:{"application/json":{schema:{type:"object",required:["current","id","name"],properties:{current:{type:"boolean"},id:{type:"string"},name:{type:"string"}}}}}},"404":{description:"Requested resource was not found.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}}}},"/v1/source/config":{get:{tags:["Source"],operationId:"getSourceConfig",summary:"Resolve source-derived Seal enterprise config",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."}],responses:{"200":{description:"Redacted Seal enterprise config.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,description:"Redacted Seal enterprise config resolved from the configured source."}}}},"401":{description:"Local service authentication failed or downstream Seal auth failed.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}}}},"/v1/auth/diagnose":{get:{tags:["Auth"],operationId:"diagnoseAuth",summary:"Diagnose wrapped source-to-Seal authentication",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."}],responses:{"200":{description:"Authentication stage diagnosis.",content:{"application/json":{schema:{type:"object",required:["stages"],properties:{stages:{type:"array",items:{$ref:"#/components/schemas/AuthStage"}}}}}}}}}},"/v1/whoami":{get:{tags:["Auth"],operationId:"whoami",summary:"Get current wrapped Seal identity",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."}],responses:{"200":{description:"Current Seal user and tenant.",content:{"application/json":{schema:{type:"object",required:["user","tenant"],properties:{user:{$ref:"#/components/schemas/SealUser"},tenant:{$ref:"#/components/schemas/SealTenant"}}}}}},"401":{description:"Local service authentication failed or downstream Seal auth failed.",content:{"application/json":{schema:{type:"object",additionalProperties:!0,required:["error"],properties:{error:{type:"string"},message:{type:"string"},details:{}}}}}}}}},"/v1/session":{get:{tags:["Auth"],operationId:"getSession",summary:"Get current wrapped Seal session metadata",parameters:[{name:"corpId",in:"query",schema:{type:"string"},description:"Local enterprise config ID. Required when global selection mode is stateless; optional in stateful mode, where the configured default enterprise is used."}],responses:{"2
Line truncated
`);U(q)})})}async function YN0($){let I=_0($.options.port)??_0($.options.p),z=E($.options.host)??E($.options.h),q=await JF({port:I,host:z}),U=()=>{q.close(()=>{process.exit(0)})};process.on("SIGINT",U),process.on("SIGTERM",U),await new Promise(()=>{})}A4();u1();async function JN0($,I,z,q){if($==="config"||$==="get"){await N0("seal_llm_config_get",I,z,{},Z0(q.options));return}if($==="providers"||$==="list"){await N0("seal_llm_providers_list",I,z,{},Z0(q.options));return}throw Error(`Unknownllmcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}u1();async function QN0($,I){if($==="config"||$==="json"){Uf();return}await Yf()}function Uf(){T0({mcpServers:{"seal-use":{type:"stdio",command:"seal-use",args:["mcp"],env:{SEAL_USE_MCP_ENABLED:"true"}}}})}u1();function KN0($){let I=IF();T0(I,{...Z0($.options),allowFull:!0})}A4();u1();async function wN0($,I,z,q){if($==="available"){await N0("seal_permissions_available_list",I,z,{},Z0(q.options));return}if($==="configs"||$==="list"){await N0("seal_permissions_configs_list",I,z,{},Z0(q.options));return}throw Error(`Unknownpermissionscommand:${$??""}.Run'seal-use help'foravailablecommands.`)}A4();G4();u1();import{readFileSync as GN0}from"node:fs";async function HN0($,I,z,q,U,Y,J){if(!$||$==="get"){await N0("seal_preference_get",U,Y,{},Z0(J.options));return}if($==="decision"){if(I==="update"||!I){let Q=E(J.options.input),K=Q?JSON.parse(GN0(Q,"utf8")):s6(J.json);if(!K||Object.keys(K).length===0)throw Error(`Usage:seal-usepreferencedecisionupdate--json'{"explicitApprove":"..."}'`);await N0("seal_preference_decision_update",U,Y,{...K,dryRun:V0(J.options.dryRun)??V0(J.options["dry-run"])},Z0(J.options));return}}if($==="thinking-depth"||$==="thinkingDepth"){if(I==="set"){let Q=E(J.options.default)??E(J.options.level)??q;if(Q!=="medium"&&Q!=="high")throw Error("Usage: seal-use preference thinking-depth set --default <medium|high>");await N0("seal_preference_thinking_depth_set",U,Y,{defaultLevel:Q,dryRun:V0(J.options.dryRun)??V0(J.options["dry-run"])},Z0(J.options));return}if(I==="policies"){if(z==="list"||!z){await N0("seal_preference_thinking_depth_policies_list",U,Y,{},Z0(J.options));return}if(z==="upsert"){let Q=E(J.options.input),K=Q?JSON.parse(GN0(Q,"utf8")):s6(J.json);if(!K||!K.id||!K.name)throw Error(`Usage:seal-usepreferencethinking-depthpoliciesupsert--json'{"id":"...","name":"...","level":"high"}'`);await N0("seal_preference_thinking_depth_policies_upsert",U,Y,{...K,dryRun:V0(J.options.dryRun)??V0(J.options["dry-run"])},Z0(J.options));return}if(z==="remove"||z==="delete"){let Q=q??E(J.options.id)??E(J.options.policyId);if(!Q)throw Error("Usage: seal-use preference thinking-depth policies remove <policyId>");await N0("seal_preference_thinking_depth_policies_remove",U,Y,{policyId:Q,dryRun:V0(J.options.dryRun)??V0(J.options["dry-run"])},Z0(J.options));return}}}throw Error(`Unknownpreferenceaction:${$??""}.Available:get,decisionupdate,thinking-depthset,thinking-depthpolicieslist/upsert/remove.`)}G9();w$();c4();async function WN0($={}){let I=O$(),z=K4(),q=m7(I,{stateful:z.stateful,defaultCorpId:z.defaultCorpId,corpId:$.corpId},w9());console.log(`[probe]corp=${q.id}source=${q.source.type}`);let U=await ZY(q);console.log("[probe] seal enterprise"),console.log(JSON.stringify(U,null,2));let Y=await J1(q),J=await sW(Y,{documentLimit:20,stylePreferencesEndpoint:q.seal.endpoints.approvalStylePreferences});console.log("[probe] approval context summary"),console.log(JSON.stringify({rules:J.rules.rules.length,hasPendingRuleDeletes:J.rules.hasPendingDeletes,documents:J.documents.articles.length,documentsTotal:J.documents.total,stylePreferences:J.stylePreferences.ok?"ok":`error:${J.stylePreferences.error}`},null,2))}G4();async function VN0($,I,z){let q=I??E(z.options.corp)??($&&$!=="--corp"?$:void 0);await WN0({corpId:q})}Nx();A4();k$();G4();u1();async function Jf($,I,z,q,U){if($==="count"){await N0("seal_approval_rules_list",z,q,{countOnly:!0},Z0(U.options));return}if($==="list"){if(V0(U.options.count)){await N0("seal_approval_rules_list",z,q,{countOnly:!0},Z0(U.options));return}let Y=_0(U.options.limit),J=_0(U.options.offset);if(V0(U.options.summary)){await N0("seal_approval_rules_list",z,q,{fields:eD0,limit:Y,offset:J},Z0(U.options));return}let Q=await r7("seal_approval_rules_list",z,q,{limit:Y,offset:J});$O0(Q,V0(U.options.full)===!0),T0(Q);return}if($==="clear"){let Y=V0(U.options.yes)===!0,J=V0(U.options.dryRun)??V0(U.options["dry-run"])??!Y;if(!Y&&!J)throw X5("Refusing to clear rules without --yes. Use --dry-run to preview.",`seal-userulesclear--corp${q.id}--dry-run`);let Q=await r7("seal_approval_rules_clear",z,q,{dryRun:J,recode:V0(U.options.recode)});if(!Y&&J&&Q&&typeof Q==="object"){T0({...Q,nextCommand:`seal-userulesclear--corp${q.id}--yes`},Z0(U.options));return}T0(Q,Z0(U.options));return}if($==="versions"){await N0("seal_approval_rule_versions_list",z,q,{},Z0(U.options));return}if($==="version"){let Y=I??E(U.op
Line truncated
`).filter(Boolean),Y=U.slice(-I);return{logFile:z,lines:Y,totalLines:U.length}}async function JL1($){let I=GF($),z=wf($),q=Dw($);DN0($.stateDir);let U=$.port??(process.env.PORT?Number.parseInt(process.env.PORT,10):UF),Y=$.host??(process.env.HOST?process.env.HOST:YF);KF(I,`${process.pid}
`,{mode:384}),KF(z,JSON.stringify({pid:process.pid,port:U,host:Y,version:$.version,startedAt:new Date().toISOString()},null,2),{mode:384}),XY(q,`servicestartingonhttp://${Y}:${U} pid=${process.pid}`);let J=null;try{J=await JF({port:U,host:Y,silent:!0}),XY(q,`service listening pid=${process.pid}`)}catch(K){if(XY(q,`service failed to bind port ${U}: ${K instanceof Error?K.message:String(K)}`),wF(I)===process.pid)N5(I,{force:!0}),N5(z,{force:!0});throw K}let Q=()=>{if(J)J.close(),J=null;if(wF(I)===process.pid)N5(I,{force:!0}),N5(z,{force:!0});XY(q,`stopped pid=${process.pid}`)};await new Promise((K)=>{let w=!1,G=()=>{if(w)return;w=!0,Q(),process.off("SIGTERM",G),process.off("SIGINT",G),K()};process.once("SIGTERM",G),process.once("SIGINT",G)})}function ZN0($){DN0($.stateDir);let I=LY($);if(I.running)return I;let z=$.launcher??{command:process.execPath,args:[$.entryFile]},q=[...z.args??[],"service","run"];if($.port)q.push("--port",String($.port));if($.host)q.push("--host",String($.host));let U=zL1(z.command,q,{cwd:$.appRoot,detached:!0,stdio:["ignore","ignore","ignore"],env:process.env});U.unref();let Y=GF($);return KF(Y,`${U.pid}
`,{flag:"a",mode:384})}u1();G4();var Gf=wL1(KL1(),".config","seal-use");async function Hf($,I,z){let q=z?_0(z.options.port)??_0(z.options.p):void 0,U=z?E(z.options.host)??E(z.options.h):void 0,Y=z?_0(z.options.lines)??_0(z.options.n):void 0,J=await dI($,{appRoot:I.appRoot,entryFile:I.entryFile,stateDir:Gf,version:q1,launcher:I.launcher,port:q,host:U},{maxLines:Y});if(J!==void 0)T0(J)}A4();G4();u1();import{existsSync as GL1,readFileSync as ON0}from"node:fs";async function FN0($,I,z,q,U){if($==="batch-records"||$==="records"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation batch-records <batchId>");await N0("seal_simulation_batch_records_get",z,q,{batchId:Y,query:E(U.options.query)},Z0(U.options));return}if($==="create"||$==="run"){let Y=E(U.options.mode)??E(U.options.sourceSystem)??E(U.options["source-system"])??"hosecloud",J=Y==="material-pack"?"material_pack":Y,Q=E(U.options.schemaConfig)??E(U.options["schema-config"]),K=Q?JSON.parse(ON0(Q,"utf8")):void 0,w=E(U.options.input),G=w?JSON.parse(ON0(w,"utf8")):s6(U.json),H=E(U.options.packageId)??E(U.options["package-id"]),W=q6(U.options.packageIds)??q6(U.options["package-ids"])??(H?[H]:void 0),V=q6(U.options.flowIds)??q6(U.options["flow-ids"])??q6(U.options.documentSn)??q6(U.options["document-sn"]),X=E(U.options.signKey)??E(U.options["sign-key"])??E(U.options.integration),L=V0(U.options.noWait)??V0(U.options["no-wait"]);await N0("seal_simulation_batch_create",z,q,{mode:J,sourceSystem:J,flowIds:V,documentSn:V,rejectNodeName:E(U.options.rejectNode)??E(U.options["reject-node"])??null,thinkingDepthOverride:E(U.options.thinkingDepth)??E(U.options["thinking-depth"]),skipInvoiceGeneration:V0(U.options.skipInvoiceGeneration)??V0(U.options["skip-invoice-generation"]),skipExpenseExtraction:V0(U.options.skipExpenseExtraction)??V0(U.options["skip-expense-extraction"]),disableAttachmentCache:V0(U.options.disableAttachmentCache)??V0(U.options["disable-attachment-cache"]),signKey:X,packageIds:W,packageId:H,templateId:E(U.options.templateId)??E(U.options["template-id"]),schemaConfig:K,requestIds:q6(U.options.requestIds)??q6(U.options["request-ids"]),workflowTypeId:E(U.options.workflowTypeId)??E(U.options["workflow-type-id"]),flowStatusList:q6(U.options.flowStatusList)?.map(Number)??q6(U.options["flow-status-list"])?.map(Number),businessCodes:q6(U.options.businessCodes)??q6(U.options["business-codes"]),documentType:E(U.options.documentType)??E(U.options["document-type"]),startTime:_0(U.options.startTime)??_0(U.options["start-time"]),endTime:_0(U.options.endTime)??_0(U.options["end-time"]),status:q6(U.options.status),limit:_0(U.options.limit),noWait:L,rawParams:G},Z0(U.options));return}if($==="wait"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");await N0("seal_simulation_batch_wait",z,q,{batchId:Y,timeout:E(U.options.timeout),pollInterval:E(U.options.pollInterval)??E(U.options["poll-interval"])},Z0(U.options));return}if($==="status"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation status <batchId>");await N0("seal_simulation_batch_status",z,q,{batchId:Y},Z0(U.options));return}if($==="clean"||$==="delete"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation clean <batchId>");await N0("seal_simulation_batch_clean",z,q,{batchId:Y},Z0(U.options));return}if($==="specifications"){let Y=I??E(U.options.integration)??E(U.options.signKey)??E(U.options["sign-key"]);await N0("seal_simulation_specifications_list",z,q,{signKey:Y},Z0(U.options));return}if($==="approval-definitions"||$==="definitions"){await N0("seal_simulation_feishu_approval_definitions_list",z,q,{},Z0(U.options));return}if($==="list"){await N0("seal_simulation_batches_list",z,q,{limit:_0(U.options.limit)},Z0(U.options));return}if($==="get"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation get <batchId>");await N0("seal_simulation_batch_get",z,q,{batchId:Y},Z0(U.options));return}if($==="templates"){await N0("seal_simulation_templates_get",z,q,{},Z0(U.options));return}if($==="integrations"){await N0("seal_simulation_integrations_get",z,q,{},Z0(U.options));return}if($==="package-upload"){let Y=I??E(U.options.file);if(!Y)throw Error("Usage: seal-use simulation package-upload <材料包.zip>");if(!GL1(Y))throw Error(`Filenotfound:${Y}`);await N0("seal_simulation_material_package_upload",z,q,{filePath:Y},Z0(U.options));return}throw Error(`Unknownsimulationcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}import{existsSync as NN0}from"node:fs";import{join as HF}from"node:path";G4();u1();function MN0($,I,z){if($==="dump"||$==="cat"||$==="show"){process.stdout.write(`${lF0()}
`);return}if($==="install"||$==="init"||$==="sync"){let q=V0(z.options.local)||V0(z.options.workspace),U=E(z.options.dir)??E(z.options.target)??I,Y=U?U:q?HF(process.cwd(),".agents","skills","seal-use"):cI(),J=ak(Y);T0({installed:!0,targetDir:J.targetDir,fileCount:J.files.length,files:J.files});return}if($==="status"||$==="get"||!$){let q=cI(),U=HF(process.cwd(),".agents","skills","seal-use");T0({global:{dir:q,installed:NN0(HF(q,"SKILL.md"))},local:{dir:U,installed:NN0(HF(U,"SKILL.md"))}});return}throw Error(`Unknownskillcommand:${$}.Run'seal-use help'foravailablecommands.`)}u1();async function AN0($,I){if($==="config"){T0(await ZY(I));return}throw Error(`Unknownsourcecommand:${$??""}.Run'seal-use help'foravailablecommands.`)}k$();A4();G4();u1();w$();k$();c4();aK();function Wf($){if(typeof $!=="string"||!$.trim())return"UNKNOWN";let I=$.toUpperCase().trim();if(I==="APPROVE"||I==="PASS")return"APPROVE";if(I==="REJECT"||I==="DENIED")return"REJECT";if(I==="MANUAL"||I==="ASSISTED")return"MANUAL";if(I==="ERROR"||I==="FAILED")return"ERROR";return I}async function PN0($){let{sourceCorp:I,targetCorp:z,sourceClient:q,targetClient:U,samples:Y=10,dryRun:J=!1,pollIntervalMs:Q=2000,timeoutMs:K=45000,snPrefix:w="REG_",fetchFn:G=fetch}=$;if(z.environment!=="test")throw new N4(`重放目标企业「${z.name}」(${z.id})的环境为「${z.environment}」,非测试环境!
`+"硬性安全规定:自动化回归测试矩阵严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${I.id}<testCorpId>`);let H=await M3(U),V=(Array.isArray(H.features)?H.features:[]).find((u)=>u?.code==="ai-approval"),X=typeof V?.balance==="number"?V.balance:0,L=typeof V?.deductionAmount==="number"&&V.deductionAmount>0?V.deductionAmount:120,D=Y*L;if(X<D)throw new N4(`测试企业「${z.name}」AI审批额度不足:当前剩余${X}点,本次回归抽样${Y}笔需要约${D}点。
`+"为防止测试环境额度耗尽中断业务,已硬性拦截并拒绝发起测试单据注入。",2,`请为测试企业「${z.id}」充值AI审批额度,或降低抽样笔数(--samples${Math.max(1,Math.floor(X/L))})`);let O=await s4(q,{limit:Y,status:"completed"}),A=Array.isArray(O.records)?O.records:[];if(A.length===0){let u=await s4(q,{limit:Y});A=Array.isArray(u.records)?u.records:[]}if(A.length===0)throw new N4(`在母企业「${I.name}」(${I.id})中未检索到任何历史审批单据,无法抽取回归样本。`,2);if(A=A.slice(0,Y),J){let u=A.map((c)=>{let m=c.sourceDocumentSN??c.id,e=c?.result?.decision??c.aiDecision??c?.decision,G0=Wf(e),M0=c?.result?.summary??c.aiSummary;return{sn:m,sourceRecordId:c.id,prodDecision:G0,prodSummary:M0,status:"DRY_RUN"}});return{ok:!0,verdict:"DRY_RUN",safeToPublish:!0,timestamp:new Date().toISOString(),sourceCorp:{id:I.id,name:I.name,environment:I.environment??"production"},targetCorp:{id:z.id,name:z.name,environment:z.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:X,deductionAmount:L,estimatedRequired:D},metrics:{sampleCount:u.length,successCount:u.length,failureCount:0,matchCount:u.length,flipCount:0,concordanceRate:1},flips:[],records:u}}let T=await Wx(U,z),M=[];for(let u of A){let c=Date.now(),m=u.sourceDocumentSN??u.id,e=Wf(u?.result?.decision??u.aiDecision??u?.decision),G0=u?.result?.summary??u.aiSummary;try{let M0=await X4(q,u.id),g0=`${w}${m}`,G1=Gx(M0,{snPrefix:w,docIdPrefix:w});await Hx(T.incomingDocumentWebhook.url,T.secret,G1,G,p4(z.seal));let S0=null,$1=Date.now();while(Date.now()-$1<K){await new Promise((S4)=>setTimeout(S4,Q));let T4=await s4(U,{sourceDocumentSN:g0,limit:1});if(T4.records&&T4.records.length>0){let S4=T4.records[0];if(S4.status==="completed"||S4.status==="failed"){S0=S4;break}}}if(!S0){M.push({sn:m,sourceRecordId:u.id,prodDecision:e,prodSummary:G0,status:"FAILED",error:`测试租户单据审核超时(${Math.round(K/1000)}s未完成)`,durationMs:Date.now()-c});continue}let A0=Wf(S0?.result?.decision??S0.aiDecision??S0?.decision??(S0.status==="completed"?"APPROVE":"ERROR")),U0=S0?.result?.summary??S0.aiSummary,v0=e===A0,I1=v0?"MATCHED":"FLIPPED",W1={sn:m,sourceRecordId:u.id,prodDecision:e,prodSummary:G0,testRecordId:S0.id,testDecision:A0,testSummary:U0,status:I1,durationMs:Date.now()-c};if(!v0)W1.diff={from:e,to:A0,reasonDiff:U0&&G0&&U0!==G0?`生产:${G0.slice(0,60)}...->测试:${U0.slice(0,60)}...`:void 0};M.push(W1)}catch(M0){M.push({sn:m,sourceRecordId:u.id,prodDecision:e,prodSummary:G0,status:"FAILED",error:M0 instanceof Error?M0.message:String(M0),durationMs:Date.now()-c})}}let v=M.filter((u)=>u.status==="MATCHED"||u.status==="FLIPPED"),x=M.filter((u)=>u.status==="MATCHED"),h=M.filter((u)=>u.status==="FLIPPED"),k=M.filter((u)=>u.status==="FAILED").length,j=x.length,n=h.length,b=j+n,g=b>0?j/b:0,f=n>0,p=f?"REGRESSIONS_DETECTED":"CLEAN",q0=!f&&k===0,R;try{let u=await M3(U),m=(Array.isArray(u.features)?u.features:[]).find((e)=>e?.code==="ai-approval");if(typeof m?.balance==="number")R=m.balance}catch{}return{ok:!f&&k===0,verdict:p,safeToPublish:q0,timestamp:new Date().toISOString(),sourceCorp:{id:I.id,name:I.name,environment:I.environment??"production"},targetCorp:{id:z.id,name:z.name,environment:z.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:X,deductionAmount:L,estimatedRequired:D,balanceAfter:R},metrics:{sampleCount:M.length,successCount:v.length,failureCount:k,matchCount:j,flipCount:n,concordanceRate:Number(g.toFixed(4))},flips:h,records:M}}function TN0($){let{sourceCorp:I,targetCorp:z,verdict:q,safeToPublish:U,metrics:Y,quota:J,flips:Q,records:K}=$,w=q==="CLEAN"?"\uD83D\uDFE2 决策完全一致 (CLEAN - 无回归)":q==="DRY_RUN"?"⚪ 预演模式 (DRY-RUN)":"\uD83D\uDD34 发现决策翻转 (REGRESSIONS_DETECTED)",G=["",`\uD83E\uDDEA[SealUseTest]规则回归测试矩阵:生产「${I.name}」->测试靶场「${z.name}」`,`判定:${w}·准许发布:${U?"YES (可安全上线)":"NO (存在行为偏离/待复核)"}`," "+"─".repeat(65),`样本总数:${Y.sampleCount}|一致通过:${Y.matchCount}|决策翻转:${Y.flipCount}|异常失败:${Y.failureCount}`,`一致率:${(Y.concordanceRate*100).toFixed(1)}%|消耗预估:${J.estimatedRequired}点(余量:${J.balanceBefore}${J.balanceAfter!==void0?` -> ${J.balanceAfter}`:""})`," "+"─".repeat(65)];if(Q.length>0){G.push(`⚠️决策翻转清单(${Q.length}笔单据在新规则下结果改变):`);for(let H of Q)if(G.push(`•单据[${H.sn}]:原生产判定「${H.prodDecision}」➔测试新判定「${H.testDecision}」`),H.diff?.reasonDiff)G.push(`理由差异:${H.diff.reasonDiff}`);G.push(" "+"─".repeat(65)),G.push(" \uD83D\uDC49 建议: 请检查上述翻转单据是否符合预期修正。若为意外误杀,请调整测试环境规则后再次回归。")}else if(q==="CLEAN")G.push(" ✓ 全部样本在新规则下的审核决策与生产历史 100%
Line truncated
`)}async function Vf($,I,z){let q=($??I??"regression").toLowerCase();if(q==="regression"||q==="regress"||q==="matrix"){let U=E(z.options.corp)??(I&&I!==q?I:void 0),Y=w1(U),J=Y,Q=Y;if(Y.environment==="test"){Q=Y;let A=E(z.options["prod-corp"])??E(z.options.prod)??Y.prodCorpId;if(!A)throw new N4(`测试企业「${Y.name}」(${Y.id})未绑定生产母企业,无法拉取历史样本。
`+"请建立绑定或通过 --prod-corp 参数指定生产企业来源。",2,`seal-usecorpsbind-test<prodCorpId>${Y.id}`);J=w1(A)}else{J=Y;let A=E(z.options["test-corp"])??E(z.options.test)??Y.testCorpId;if(!A)throw new N4(`生产企业「${Y.name}」(${Y.id})未绑定测试靶场企业。
`+"硬性规定:回归测试严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${Y.id}<testCorpId>`);Q=w1(A)}let K=await J1(J),w=await J1(Q),G=_0(z.options.samples)??_0(z.options.limit)??_0(z.options.n)??10,H=V0(z.options["dry-run"]),W=V0(z.options["fail-on-flips"]),V=_0(z.options["poll-interval"])??2000,X=_0(z.options.timeout)??45000,L=E(z.options["sn-prefix"])??"REG_",D=await PN0({sourceCorp:J,targetCorp:Q,sourceClient:K,targetClient:w,samples:G,dryRun:H,pollIntervalMs:V,timeoutMs:X,snPrefix:L,failOnFlips:W});if(!(V0(z.options.quiet)||V0(z.options.silent)))console.error(TN0(D));if(T0(D),W&&!D.ok)throw new N4(`回归测试发现${D.metrics.flipCount}笔单据决策翻转,已按--fail-on-flips策略非零终止。`,1);return}throw new N4(`未知的test子命令:"${q}"。
可用子命令:seal-usetestregression[--corp<id>][--samples<N>][--dry-run]`,2,"seal-use test regression --help")}A4();G4();u1();async function EN0($,I,z,q){if(!$)throw Error("Usage: seal-use tool <toolName> [--json '{...}']");await N0($,I,z,s6(q.json),Z0(q.options))}nO();u1();function BN0(){T0(Qw.map(($)=>({name:$.name,description:$.description})))}import{chmodSync as HL1,mkdirSync as WL1,renameSync as Zf,rmSync as VL1,unlinkSync as _N0,writeFileSync as jN0}from"node:fs";import{dirname as ZL1,join as vN0}from"node:path";import{spawnSync as mI}from"node:child_process";function WF($=process.execPath,I=import.meta.url){if(I.includes("/$bunfs/")||I.includes("\\$bunfs\\"))return!0;let z=$.toLowerCase().replace(/\\/g,"/");return!z.endsWith("/bun")&&!z.endsWith("/bun.exe")&&!z.endsWith("/node")&&!z.endsWith("/node.exe")}u1();var CN0="yunyingk/seal-use",Fw="yunyingk/seal-home";var XL1="SEAL_USE_GITHUB_REPO",LL1="SEAL_HOME_GITHUB_REPO";async function hN0($,I={}){let z={appRoot:$.appRoot,entryFile:$.entryFile,stateDir:Gf,version:q1,launcher:$.launcher},q=I.repo||process.env[XL1]?.trim()||process.env[LL1]?.trim()||CN0,U=I.targetVersion?.trim(),Y=U&&U.toLowerCase()!=="latest"?U:void 0;if(Y){let M=Y.replace(/^v/,""),v=SN0(M,q1);if(v<0)if(!Fj&&I.force);else{T0({updated:!1,currentVersion:q1,targetVersion:M,mode:WF()?"binary":"source",message:!Fj?`Cannotdowngradeseal-usefromdevbuildv${q1}toreleasev${M}.Use--forcetooverwrite.`:`Cannotdowngradeseal-usefromv${q1}toolderversionv${M}.Updatesmustbeforward-only.`});return}if(v===0&&!I.force){T0({updated:!1,currentVersion:q1,targetVersion:M,mode:WF()?"binary":"source",message:`seal-useisalreadyatversionv${q1}.Use--forcetoreinstall.`});return}}if(I.changelogOnly){let M=await Xf(q,I.limit??10);T0({currentVersion:q1,totalQueried:M.length,releases:M.map((v)=>({version:v.version,tagName:v.tagName,publishedAt:v.publishedAt,author:v.author,releaseNotes:v.notes,releaseUrl:v.htmlUrl,isCurrent:v.version===q1,isNewer:Ow(v.version,q1)}))});return}if(!WF()){if(I.checkOnly){let v=await Xf(q,30),x=v[0],h=x?.version??q1,k=v.find((b)=>b.version===q1),j=Ow(h,q1),n=v.filter((b)=>Ow(b.version,q1));T0({updated:!1,updateAvailable:j,currentVersion:q1,currentVersionPublishedAt:k?.publishedAt,latestVersion:h,latestVersionPublishedAt:x?.publishedAt,behindCount:n.length,pendingReleases:n.map((b)=>({version:b.version,tagName:b.tagName,publishedAt:b.publishedAt,author:b.author,releaseNotes:b.notes,releaseUrl:b.htmlUrl})),releaseNotes:x?.notes??"",releaseUrl:x?.htmlUrl??"",mode:"source",message:"Running in source development mode. Run 'seal-use update' to git pull & bun install."});return}let M=LY(z).running;if(M)await dI("stop",z);try{gN0("git",["-C",$.appRoot,"pull","--ff-only"])}catch(v){console.error(`gitpullskipped:${vinstanceofError?v.message:String(v)}`)}if(gN0("bun",["install"],{cwd:$.appRoot}),M)await dI("start",z);T0({updated:!0,serviceRestarted:M,version:q1,mode:"source"});return}let J=DL1(),Q=OL1(),K=await Xf(q,30),w=Y?K.find((M)=>M.version===Y||M.tagName===Y||M.tagName===`v${Y}`)??await RN0(q,Y):K[0]??await RN0(q);if(!w){T0({updated:!1,currentVersion:q1,mode:"binary",message:`Failedtoqueryreleasesfromrepository'${q}'`});return}let G=w.version,H=K.find((M)=>M.version===q1),W=Ow(G,q1),V=W||Boolean(I.force),X=K.filter((M)=>Ow(M.version,q1));if(I.checkOnly){T0({updated:!1,updateAvailable:W,currentVersion:q1,currentVersionPublishedAt:H?.publishedAt,latestVersion:G,latestVersionPublishedAt:w.publishedAt,behindCount:X.length,pendingReleases:X.map((M)=>({version:M.version,tagName:M.tagName,publishedAt:M.publishedAt,author:M.author,releaseNotes:M.notes,releaseUrl:M.htmlUrl})),releaseNotes:w.notes,releaseUrl:w.htmlUrl,mode:"binary"});return}if(!V){T0({updated:!1,currentVersion:q1,currentVersionPublishedAt:H?.publishedAt,latestVersion:G,latestVersionPublishedAt:w.publishedAt,mode:"binary",message:`seal-useisalreadyuptodate(v${q1})`});return}let L=FL1(w.assets,J,Q);if(!L)throw Error(`Nocompatiblebinaryfoundfor${J}-${Q}inreleasev${G}.Availableassets:${w.assets.map((M)=>M.name).join(", ")}`);let D=LY(z).running;if(D)await dI("stop",z);let O=process.execPath,A=ZL1(O),T=vN0(A,`.tmp-update-${Date.now()}`);WL1(T,{recursive:!0});try{let M=vN0(T,L.name);await NL1(L.downloadUrl,M,w.tagName,L.name);let v=M;if(L.name.endsWith(".tar.gz")||L.name.endsWith(".tgz"))v=ML1(M,T,J);else if(L.name.endsWith(".zip"))v=AL1(M,T,J);if(HL1(v,493),process.platform==="darwin")try{mI("/usr/bin/codesign",["--remove-signature",v],{stdio:"ignore"}),mI("/usr/bin/codesign",["--force","--sign","-",v],{stdio:"ignore"})}catch{}if(process.platform==="win32"){let h=`${O}.old.${Date.now()}`;try{Zf(O,h)}catch{}Zf(v,O)}else Zf(v,O);if(D)await dI("start",z);let x=sk();T0({updated:!0,fromVersion:q1,toVersion:G,serviceRestarted:D,skillSynced:x.synced?x.targetDir:!1,mode:"binary"})}finally{try{VL1(T,{recursive:!0,force:!0})}catch{}}}function DL1(){if(process.platform==="darwin")retur
Line truncated
`)}catch{}}async function NL1($,I,z,q){let U=Lf(),Y=[],J=z?z.startsWith("v")?z:`v${z}`:void 0,Q=q||$.split("/").pop()||"";if(U!=="github"){if(J&&Q)Y.push(`https://git.ying-qing.cn/gitea/seal-use/releases/download/${J}/${Q}`,`https://git.ying-qing.cn/gitea/seal-home/releases/download/${J}/${Q}`);if($.startsWith("https://git.ying-qing.cn"))Y.push($)}if(U!=="gitea")if(J&&Q){let L=`https://github.com/${CN0}/releases/download/${J}/${Q}`;if(!process.env.CI)Y.push(`https://ghfast.top/${L}`,`https://gh.ddlc.top/${L}`);Y.push(L)}else if($.includes("github.com")){if(!process.env.CI)Y.push(`https://ghfast.top/${$}`,`https://gh.ddlc.top/${$}`);Y.push($)}else Y.push($);let K=Array.from(new Set(Y)),w,G=6000,H=6000,W=307200,V=1e4,X=180000;for(let L=0;L<K.length;L++){let D=K[L],O=new AbortController,A="",T=(h)=>{A=h;try{O.abort()}catch{}},M=setTimeout(()=>{T("Connection timed out (no response headers within 6s)")},G),v,x;try{VF(`==> [${L+1}/${K.length}] Downloading via: ${D}`);let h=await fetch(D,{signal:O.signal});if(M)clearTimeout(M),M=void 0;if(!h.ok)throw Error(`HTTP ${h.status} ${h.statusText}`);v=setTimeout(()=>{T("Overall download time exceeded 3 minutes")},X);let k=Number(h.headers.get("content-length"))||0,j=h.body?.getReader();if(!j){let p=Buffer.from(await h.arrayBuffer());if(p.length<1000)throw Error(`Downloaded content is suspiciously small (${p.length} bytes)`);jN0(I,p),VF(`✓ Download succeeded (${(p.length/1024/1024).toFixed(1)} MB)`);return}let n=[],b=0,g=0;x=setTimeout(()=>{if(b<W){let p=(b/1024).toFixed(1);T(`Initial transfer too slow (${p} KB < 300 KB in 6s), switching mirror...`)}},H);while(!0){let p=j.read(),q0,R=new Promise((e,G0)=>{q0=setTimeout(()=>{G0(Error("Data transfer stalled (no chunk received for 10s)"))},V)}),u;try{u=await Promise.race([p,R])}finally{if(q0)clearTimeout(q0)}let{done:c,value:m}=u;if(c)break;if(m){if(n.push(m),b+=m.length,x&&b>=W)clearTimeout(x),x=void 0;let e=Date.now();if(e-g>200){g=e;let G0=k?Math.round(b/k*100):0,M0=(b/1048576).toFixed(1),g0=k?(k/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${G0}% (${M0} / ${g0} MB)...`)}catch{}}}}try{process.stderr.write(`
`);U(q)})})}async function YN0($){let I=g0($.options.port)??g0($.options.p),z=E($.options.host)??E($.options.h),q=await JF({port:I,host:z}),U=()=>{q.close(()=>{process.exit(0)})};process.on("SIGINT",U),process.on("SIGTERM",U),await new Promise(()=>{})}A4();u1();async function JN0($,I,z,q){if($==="config"||$==="get"){await N0("seal_llm_config_get",I,z,{},Z0(q.options));return}if($==="providers"||$==="list"){await N0("seal_llm_providers_list",I,z,{},Z0(q.options));return}throw Error(`Unknownllmcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}u1();async function QN0($,I){if($==="config"||$==="json"){Yf();return}await Jf()}function Yf(){P0({mcpServers:{"seal-use":{type:"stdio",command:"seal-use",args:["mcp"],env:{SEAL_USE_MCP_ENABLED:"true"}}}})}u1();function KN0($){let I=IF();P0(I,{...Z0($.options),allowFull:!0})}A4();u1();async function wN0($,I,z,q){if($==="available"){await N0("seal_permissions_available_list",I,z,{},Z0(q.options));return}if($==="configs"||$==="list"){await N0("seal_permissions_configs_list",I,z,{},Z0(q.options));return}throw Error(`Unknownpermissionscommand:${$??""}.Run'seal-use help'foravailablecommands.`)}A4();G4();u1();import{readFileSync as GN0}from"node:fs";async function HN0($,I,z,q,U,Y,J){if(!$||$==="get"){await N0("seal_preference_get",U,Y,{},Z0(J.options));return}if($==="decision"){if(I==="update"||!I){let Q=E(J.options.input),K=Q?JSON.parse(GN0(Q,"utf8")):s6(J.json);if(!K||Object.keys(K).length===0)throw Error(`Usage:seal-usepreferencedecisionupdate--json'{"explicitApprove":"..."}'`);await N0("seal_preference_decision_update",U,Y,{...K,dryRun:V0(J.options.dryRun)??V0(J.options["dry-run"])},Z0(J.options));return}}if($==="thinking-depth"||$==="thinkingDepth"){if(I==="set"){let Q=E(J.options.default)??E(J.options.level)??q;if(Q!=="medium"&&Q!=="high")throw Error("Usage: seal-use preference thinking-depth set --default <medium|high>");await N0("seal_preference_thinking_depth_set",U,Y,{defaultLevel:Q,dryRun:V0(J.options.dryRun)??V0(J.options["dry-run"])},Z0(J.options));return}if(I==="policies"){if(z==="list"||!z){await N0("seal_preference_thinking_depth_policies_list",U,Y,{},Z0(J.options));return}if(z==="upsert"){let Q=E(J.options.input),K=Q?JSON.parse(GN0(Q,"utf8")):s6(J.json);if(!K||!K.id||!K.name)throw Error(`Usage:seal-usepreferencethinking-depthpoliciesupsert--json'{"id":"...","name":"...","level":"high"}'`);await N0("seal_preference_thinking_depth_policies_upsert",U,Y,{...K,dryRun:V0(J.options.dryRun)??V0(J.options["dry-run"])},Z0(J.options));return}if(z==="remove"||z==="delete"){let Q=q??E(J.options.id)??E(J.options.policyId);if(!Q)throw Error("Usage: seal-use preference thinking-depth policies remove <policyId>");await N0("seal_preference_thinking_depth_policies_remove",U,Y,{policyId:Q,dryRun:V0(J.options.dryRun)??V0(J.options["dry-run"])},Z0(J.options));return}}}throw Error(`Unknownpreferenceaction:${$??""}.Available:get,decisionupdate,thinking-depthset,thinking-depthpolicieslist/upsert/remove.`)}G9();w$();c4();async function WN0($={}){let I=D$(),z=K4(),q=m7(I,{stateful:z.stateful,defaultCorpId:z.defaultCorpId,corpId:$.corpId},w9());console.log(`[probe]corp=${q.id}source=${q.source.type}`);let U=await ZY(q);console.log("[probe] seal enterprise"),console.log(JSON.stringify(U,null,2));let Y=await Q1(q),J=await sW(Y,{documentLimit:20,stylePreferencesEndpoint:q.seal.endpoints.approvalStylePreferences});console.log("[probe] approval context summary"),console.log(JSON.stringify({rules:J.rules.rules.length,hasPendingRuleDeletes:J.rules.hasPendingDeletes,documents:J.documents.articles.length,documentsTotal:J.documents.total,stylePreferences:J.stylePreferences.ok?"ok":`error:${J.stylePreferences.error}`},null,2))}G4();async function VN0($,I,z){let q=I??E(z.options.corp)??($&&$!=="--corp"?$:void 0);await WN0({corpId:q})}Mx();A4();k$();G4();u1();async function Qf($,I,z,q,U){if($==="count"){await N0("seal_approval_rules_list",z,q,{countOnly:!0},Z0(U.options));return}if($==="list"){if(V0(U.options.count)){await N0("seal_approval_rules_list",z,q,{countOnly:!0},Z0(U.options));return}let Y=g0(U.options.limit),J=g0(U.options.offset);if(V0(U.options.summary)){await N0("seal_approval_rules_list",z,q,{fields:eO0,limit:Y,offset:J},Z0(U.options));return}let Q=await r7("seal_approval_rules_list",z,q,{limit:Y,offset:J});$D0(Q,V0(U.options.full)===!0),P0(Q);return}if($==="clear"){let Y=V0(U.options.yes)===!0,J=V0(U.options.dryRun)??V0(U.options["dry-run"])??!Y;if(!Y&&!J)throw X5("Refusing to clear rules without --yes. Use --dry-run to preview.",`seal-userulesclear--corp${q.id}--dry-run`);let Q=await r7("seal_approval_rules_clear",z,q,{dryRun:J,recode:V0(U.options.recode)});if(!Y&&J&&Q&&typeof Q==="object"){P0({...Q,nextCommand:`seal-userulesclear--corp${q.id}--yes`},Z0(U.options));return}P0(Q,Z0(U.options));return}if($==="versions"){await N0("seal_approval_rule_versions_list",z,q,{},Z0(U.options));return}if($==="version"){let Y=I??E(U.op
Line truncated
`).filter(Boolean),Y=U.slice(-I);return{logFile:z,lines:Y,totalLines:U.length}}async function KL1($){let I=GF($),z=Gf($),q=Ow($);ON0($.stateDir);let U=$.port??(process.env.PORT?Number.parseInt(process.env.PORT,10):UF),Y=$.host??(process.env.HOST?process.env.HOST:YF);KF(I,`${process.pid}
`,{mode:384}),KF(z,JSON.stringify({pid:process.pid,port:U,host:Y,version:$.version,startedAt:new Date().toISOString()},null,2),{mode:384}),XY(q,`servicestartingonhttp://${Y}:${U} pid=${process.pid}`);let J=null;try{J=await JF({port:U,host:Y,silent:!0}),XY(q,`service listening pid=${process.pid}`)}catch(K){if(XY(q,`service failed to bind port ${U}: ${K instanceof Error?K.message:String(K)}`),wF(I)===process.pid)N5(I,{force:!0}),N5(z,{force:!0});throw K}let Q=()=>{if(J)J.close(),J=null;if(wF(I)===process.pid)N5(I,{force:!0}),N5(z,{force:!0});XY(q,`stopped pid=${process.pid}`)};await new Promise((K)=>{let w=!1,G=()=>{if(w)return;w=!0,Q(),process.off("SIGTERM",G),process.off("SIGINT",G),K()};process.once("SIGTERM",G),process.once("SIGINT",G)})}function ZN0($){ON0($.stateDir);let I=LY($);if(I.running)return I;let z=$.launcher??{command:process.execPath,args:[$.entryFile]},q=[...z.args??[],"service","run"];if($.port)q.push("--port",String($.port));if($.host)q.push("--host",String($.host));let U=UL1(z.command,q,{cwd:$.appRoot,detached:!0,stdio:["ignore","ignore","ignore"],env:process.env});U.unref();let Y=GF($);return KF(Y,`${U.pid}
`,{flag:"a",mode:384})}u1();G4();var Hf=HL1(GL1(),".config","seal-use");async function Wf($,I,z){let q=z?g0(z.options.port)??g0(z.options.p):void 0,U=z?E(z.options.host)??E(z.options.h):void 0,Y=z?g0(z.options.lines)??g0(z.options.n):void 0,J=await dI($,{appRoot:I.appRoot,entryFile:I.entryFile,stateDir:Hf,version:q1,launcher:I.launcher,port:q,host:U},{maxLines:Y});if(J!==void 0)P0(J)}A4();G4();u1();import{existsSync as WL1,readFileSync as DN0}from"node:fs";async function FN0($,I,z,q,U){if($==="batch-records"||$==="records"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation batch-records <batchId>");await N0("seal_simulation_batch_records_get",z,q,{batchId:Y,query:E(U.options.query)},Z0(U.options));return}if($==="create"||$==="run"){let Y=E(U.options.mode)??E(U.options.sourceSystem)??E(U.options["source-system"])??"hosecloud",J=Y==="material-pack"?"material_pack":Y,Q=E(U.options.schemaConfig)??E(U.options["schema-config"]),K=Q?JSON.parse(DN0(Q,"utf8")):void 0,w=E(U.options.input),G=w?JSON.parse(DN0(w,"utf8")):s6(U.json),H=E(U.options.packageId)??E(U.options["package-id"]),W=q6(U.options.packageIds)??q6(U.options["package-ids"])??(H?[H]:void 0),V=q6(U.options.flowIds)??q6(U.options["flow-ids"])??q6(U.options.documentSn)??q6(U.options["document-sn"]),X=E(U.options.signKey)??E(U.options["sign-key"])??E(U.options.integration),L=V0(U.options.noWait)??V0(U.options["no-wait"]);await N0("seal_simulation_batch_create",z,q,{mode:J,sourceSystem:J,flowIds:V,documentSn:V,rejectNodeName:E(U.options.rejectNode)??E(U.options["reject-node"])??null,thinkingDepthOverride:E(U.options.thinkingDepth)??E(U.options["thinking-depth"]),skipInvoiceGeneration:V0(U.options.skipInvoiceGeneration)??V0(U.options["skip-invoice-generation"]),skipExpenseExtraction:V0(U.options.skipExpenseExtraction)??V0(U.options["skip-expense-extraction"]),disableAttachmentCache:V0(U.options.disableAttachmentCache)??V0(U.options["disable-attachment-cache"]),signKey:X,packageIds:W,packageId:H,templateId:E(U.options.templateId)??E(U.options["template-id"]),schemaConfig:K,requestIds:q6(U.options.requestIds)??q6(U.options["request-ids"]),workflowTypeId:E(U.options.workflowTypeId)??E(U.options["workflow-type-id"]),flowStatusList:q6(U.options.flowStatusList)?.map(Number)??q6(U.options["flow-status-list"])?.map(Number),businessCodes:q6(U.options.businessCodes)??q6(U.options["business-codes"]),documentType:E(U.options.documentType)??E(U.options["document-type"]),startTime:g0(U.options.startTime)??g0(U.options["start-time"]),endTime:g0(U.options.endTime)??g0(U.options["end-time"]),status:q6(U.options.status),limit:g0(U.options.limit),noWait:L,rawParams:G},Z0(U.options));return}if($==="wait"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation wait <batchId> [--timeout 10m] [--poll-interval 2s]");await N0("seal_simulation_batch_wait",z,q,{batchId:Y,timeout:E(U.options.timeout),pollInterval:E(U.options.pollInterval)??E(U.options["poll-interval"])},Z0(U.options));return}if($==="status"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation status <batchId>");await N0("seal_simulation_batch_status",z,q,{batchId:Y},Z0(U.options));return}if($==="clean"||$==="delete"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation clean <batchId>");await N0("seal_simulation_batch_clean",z,q,{batchId:Y},Z0(U.options));return}if($==="specifications"){let Y=I??E(U.options.integration)??E(U.options.signKey)??E(U.options["sign-key"]);await N0("seal_simulation_specifications_list",z,q,{signKey:Y},Z0(U.options));return}if($==="approval-definitions"||$==="definitions"){await N0("seal_simulation_feishu_approval_definitions_list",z,q,{},Z0(U.options));return}if($==="list"){await N0("seal_simulation_batches_list",z,q,{limit:g0(U.options.limit)},Z0(U.options));return}if($==="get"){let Y=I??E(U.options.batchId)??E(U.options["batch-id"]);if(!Y)throw Error("Usage: seal-use simulation get <batchId>");await N0("seal_simulation_batch_get",z,q,{batchId:Y},Z0(U.options));return}if($==="templates"){await N0("seal_simulation_templates_get",z,q,{},Z0(U.options));return}if($==="integrations"){await N0("seal_simulation_integrations_get",z,q,{},Z0(U.options));return}if($==="package-upload"){let Y=I??E(U.options.file);if(!Y)throw Error("Usage: seal-use simulation package-upload <材料包.zip>");if(!WL1(Y))throw Error(`Filenotfound:${Y}`);await N0("seal_simulation_material_package_upload",z,q,{filePath:Y},Z0(U.options));return}throw Error(`Unknownsimulationcommand:${$??""}.Run'seal-use help'foravailablecommands.`)}import{existsSync as NN0}from"node:fs";import{join as HF}from"node:path";G4();u1();function MN0($,I,z){if($==="dump"||$==="cat"||$==="show"){process.stdout.write(`${lF0()}
`);return}if($==="install"||$==="init"||$==="sync"){let q=V0(z.options.local)||V0(z.options.workspace),U=E(z.options.dir)??E(z.options.target)??I,Y=U?U:q?HF(process.cwd(),".agents","skills","seal-use"):cI(),J=sk(Y);P0({installed:!0,targetDir:J.targetDir,fileCount:J.files.length,files:J.files});return}if($==="status"||$==="get"||!$){let q=cI(),U=HF(process.cwd(),".agents","skills","seal-use");P0({global:{dir:q,installed:NN0(HF(q,"SKILL.md"))},local:{dir:U,installed:NN0(HF(U,"SKILL.md"))}});return}throw Error(`Unknownskillcommand:${$}.Run'seal-use help'foravailablecommands.`)}u1();async function AN0($,I){if($==="config"){P0(await ZY(I));return}throw Error(`Unknownsourcecommand:${$??""}.Run'seal-use help'foravailablecommands.`)}k$();A4();G4();u1();w$();k$();c4();aK();function Vf($){if(typeof $!=="string"||!$.trim())return"UNKNOWN";let I=$.toUpperCase().trim();if(I==="APPROVE"||I==="PASS")return"APPROVE";if(I==="REJECT"||I==="DENIED")return"REJECT";if(I==="MANUAL"||I==="ASSISTED")return"MANUAL";if(I==="ERROR"||I==="FAILED")return"ERROR";return I}async function PN0($){let{sourceCorp:I,targetCorp:z,sourceClient:q,targetClient:U,samples:Y=10,dryRun:J=!1,pollIntervalMs:Q=2000,timeoutMs:K=45000,snPrefix:w="REG_",fetchFn:G=fetch}=$;if(z.environment!=="test")throw new N4(`重放目标企业「${z.name}」(${z.id})的环境为「${z.environment}」,非测试环境!
`+"硬性安全规定:自动化回归测试矩阵严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${I.id}<testCorpId>`);let H=await M3(U),V=(Array.isArray(H.features)?H.features:[]).find((u)=>u?.code==="ai-approval"),X=typeof V?.balance==="number"?V.balance:0,L=typeof V?.deductionAmount==="number"&&V.deductionAmount>0?V.deductionAmount:120,O=Y*L;if(X<O)throw new N4(`测试企业「${z.name}」AI审批额度不足:当前剩余${X}点,本次回归抽样${Y}笔需要约${O}点。
`+"为防止测试环境额度耗尽中断业务,已硬性拦截并拒绝发起测试单据注入。",2,`请为测试企业「${z.id}」充值AI审批额度,或降低抽样笔数(--samples${Math.max(1,Math.floor(X/L))})`);let D=await s4(q,{limit:Y,status:"completed"}),A=Array.isArray(D.records)?D.records:[];if(A.length===0){let u=await s4(q,{limit:Y});A=Array.isArray(u.records)?u.records:[]}if(A.length===0)throw new N4(`在母企业「${I.name}」(${I.id})中未检索到任何历史审批单据,无法抽取回归样本。`,2);if(A=A.slice(0,Y),J){let u=A.map((c)=>{let r=c.sourceDocumentSN??c.id,q0=c?.result?.decision??c.aiDecision??c?.decision,w0=Vf(q0),M0=c?.result?.summary??c.aiSummary;return{sn:r,sourceRecordId:c.id,prodDecision:w0,prodSummary:M0,status:"DRY_RUN"}});return{ok:!0,verdict:"DRY_RUN",safeToPublish:!0,timestamp:new Date().toISOString(),sourceCorp:{id:I.id,name:I.name,environment:I.environment??"production"},targetCorp:{id:z.id,name:z.name,environment:z.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:X,deductionAmount:L,estimatedRequired:O},metrics:{sampleCount:u.length,successCount:u.length,failureCount:0,matchCount:u.length,flipCount:0,concordanceRate:1},flips:[],records:u}}let T=await Vx(U,z),M=[];for(let u of A){let c=Date.now(),r=u.sourceDocumentSN??u.id,q0=Vf(u?.result?.decision??u.aiDecision??u?.decision),w0=u?.result?.summary??u.aiSummary;try{let M0=await X4(q,u.id),R0=`${w}${r}`,U1=Hx(M0,{snPrefix:w,docIdPrefix:w});await Wx(T.incomingDocumentWebhook.url,T.secret,U1,G,p4(z.seal));let x0=null,r0=Date.now();while(Date.now()-r0<K){await new Promise((S4)=>setTimeout(S4,Q));let T4=await s4(U,{sourceDocumentSN:R0,limit:1});if(T4.records&&T4.records.length>0){let S4=T4.records[0];if(S4.status==="completed"||S4.status==="failed"){x0=S4;break}}}if(!x0){M.push({sn:r,sourceRecordId:u.id,prodDecision:q0,prodSummary:w0,status:"FAILED",error:`测试租户单据审核超时(${Math.round(K/1000)}s未完成)`,durationMs:Date.now()-c});continue}let I1=Vf(x0?.result?.decision??x0.aiDecision??x0?.decision??(x0.status==="completed"?"APPROVE":"ERROR")),m=x0?.result?.summary??x0.aiSummary,B0=q0===I1,k0=B0?"MATCHED":"FLIPPED",W1={sn:r,sourceRecordId:u.id,prodDecision:q0,prodSummary:w0,testRecordId:x0.id,testDecision:I1,testSummary:m,status:k0,durationMs:Date.now()-c};if(!B0)W1.diff={from:q0,to:I1,reasonDiff:m&&w0&&m!==w0?`生产:${w0.slice(0,60)}...->测试:${m.slice(0,60)}...`:void 0};M.push(W1)}catch(M0){M.push({sn:r,sourceRecordId:u.id,prodDecision:q0,prodSummary:w0,status:"FAILED",error:M0 instanceof Error?M0.message:String(M0),durationMs:Date.now()-c})}}let j=M.filter((u)=>u.status==="MATCHED"||u.status==="FLIPPED"),x=M.filter((u)=>u.status==="MATCHED"),h=M.filter((u)=>u.status==="FLIPPED"),b=M.filter((u)=>u.status==="FAILED").length,R=x.length,f=h.length,n=R+f,C=n>0?R/n:0,k=f>0,p=k?"REGRESSIONS_DETECTED":"CLEAN",z0=!k&&b===0,v;try{let u=await M3(U),r=(Array.isArray(u.features)?u.features:[]).find((q0)=>q0?.code==="ai-approval");if(typeof r?.balance==="number")v=r.balance}catch{}return{ok:!k&&b===0,verdict:p,safeToPublish:z0,timestamp:new Date().toISOString(),sourceCorp:{id:I.id,name:I.name,environment:I.environment??"production"},targetCorp:{id:z.id,name:z.name,environment:z.environment??"test"},quota:{featureCode:"ai-approval",balanceBefore:X,deductionAmount:L,estimatedRequired:O,balanceAfter:v},metrics:{sampleCount:M.length,successCount:j.length,failureCount:b,matchCount:R,flipCount:f,concordanceRate:Number(C.toFixed(4))},flips:h,records:M}}function TN0($){let{sourceCorp:I,targetCorp:z,verdict:q,safeToPublish:U,metrics:Y,quota:J,flips:Q,records:K}=$,w=q==="CLEAN"?"\uD83D\uDFE2 决策完全一致 (CLEAN - 无回归)":q==="DRY_RUN"?"⚪ 预演模式 (DRY-RUN)":"\uD83D\uDD34 发现决策翻转 (REGRESSIONS_DETECTED)",G=["",`\uD83E\uDDEA[SealUseTest]规则回归测试矩阵:生产「${I.name}」->测试靶场「${z.name}」`,`判定:${w}·准许发布:${U?"YES (可安全上线)":"NO (存在行为偏离/待复核)"}`," "+"─".repeat(65),`样本总数:${Y.sampleCount}|一致通过:${Y.matchCount}|决策翻转:${Y.flipCount}|异常失败:${Y.failureCount}`,`一致率:${(Y.concordanceRate*100).toFixed(1)}%|消耗预估:${J.estimatedRequired}点(余量:${J.balanceBefore}${J.balanceAfter!==void0?` -> ${J.balanceAfter}`:""})`," "+"─".repeat(65)];if(Q.length>0){G.push(`⚠️决策翻转清单(${Q.length}笔单据在新规则下结果改变):`);for(let H of Q)if(G.push(`•单据[${H.sn}]:原生产判定「${H.prodDecision}」➔测试新判定「${H.testDecision}」`),H.diff?.reasonDiff)G.push(`理由差异:${H.diff.reasonDiff}`);G.push(" "+"─".repeat(65)),G.push(" \uD83D\uDC49 建议: 请检查上述翻转单据是否符合预期修正。若为意外误杀,请调整测试环境规则后再次回归。")}else if(q==="CLEAN")G.push(" ✓ 全部样本在新规则下的审核决策与生产历史 1
Line truncated
`)}async function Zf($,I,z){let q=($??I??"regression").toLowerCase();if(q==="regression"||q==="regress"||q==="matrix"){let U=E(z.options.corp)??(I&&I!==q?I:void 0),Y=G1(U),J=Y,Q=Y;if(Y.environment==="test"){Q=Y;let A=E(z.options["prod-corp"])??E(z.options.prod)??Y.prodCorpId;if(!A)throw new N4(`测试企业「${Y.name}」(${Y.id})未绑定生产母企业,无法拉取历史样本。
`+"请建立绑定或通过 --prod-corp 参数指定生产企业来源。",2,`seal-usecorpsbind-test<prodCorpId>${Y.id}`);J=G1(A)}else{J=Y;let A=E(z.options["test-corp"])??E(z.options.test)??Y.testCorpId;if(!A)throw new N4(`生产企业「${Y.name}」(${Y.id})未绑定测试靶场企业。
`+"硬性规定:回归测试严禁在生产环境直接运行。必须绑定并指定测试环境(testCorp)。",2,`seal-usecorpsbind-test${Y.id}<testCorpId>`);Q=G1(A)}let K=await Q1(J),w=await Q1(Q),G=g0(z.options.samples)??g0(z.options.limit)??g0(z.options.n)??10,H=V0(z.options["dry-run"]),W=V0(z.options["fail-on-flips"]),V=g0(z.options["poll-interval"])??2000,X=g0(z.options.timeout)??45000,L=E(z.options["sn-prefix"])??"REG_",O=await PN0({sourceCorp:J,targetCorp:Q,sourceClient:K,targetClient:w,samples:G,dryRun:H,pollIntervalMs:V,timeoutMs:X,snPrefix:L,failOnFlips:W});if(!(V0(z.options.quiet)||V0(z.options.silent)))console.error(TN0(O));if(P0(O),W&&!O.ok)throw new N4(`回归测试发现${O.metrics.flipCount}笔单据决策翻转,已按--fail-on-flips策略非零终止。`,1);return}throw new N4(`未知的test子命令:"${q}"。
可用子命令:seal-usetestregression[--corp<id>][--samples<N>][--dry-run]`,2,"seal-use test regression --help")}A4();G4();u1();async function EN0($,I,z,q){if(!$)throw Error("Usage: seal-use tool <toolName> [--json '{...}']");await N0($,I,z,s6(q.json),Z0(q.options))}nD();u1();function BN0(){P0(Qw.map(($)=>({name:$.name,description:$.description})))}import{chmodSync as VL1,mkdirSync as ZL1,renameSync as Xf,rmSync as XL1,unlinkSync as _N0,writeFileSync as jN0}from"node:fs";import{dirname as LL1,join as vN0}from"node:path";import{spawnSync as mI}from"node:child_process";function WF($=process.execPath,I=import.meta.url){if(I.includes("/$bunfs/")||I.includes("\\$bunfs\\"))return!0;let z=$.toLowerCase().replace(/\\/g,"/");return!z.endsWith("/bun")&&!z.endsWith("/bun.exe")&&!z.endsWith("/node")&&!z.endsWith("/node.exe")}u1();var CN0="yunyingk/seal-use",Fw="yunyingk/seal-home";var OL1="SEAL_USE_GITHUB_REPO",DL1="SEAL_HOME_GITHUB_REPO";async function hN0($,I={}){let z={appRoot:$.appRoot,entryFile:$.entryFile,stateDir:Hf,version:q1,launcher:$.launcher},q=I.repo||process.env[OL1]?.trim()||process.env[DL1]?.trim()||CN0,U=I.targetVersion?.trim(),Y=U&&U.toLowerCase()!=="latest"?U:void 0;if(Y){let M=Y.replace(/^v/,""),j=SN0(M,q1);if(j<0)if(!Fj&&I.force);else{P0({updated:!1,currentVersion:q1,targetVersion:M,mode:WF()?"binary":"source",message:!Fj?`Cannotdowngradeseal-usefromdevbuildv${q1}toreleasev${M}.Use--forcetooverwrite.`:`Cannotdowngradeseal-usefromv${q1}toolderversionv${M}.Updatesmustbeforward-only.`});return}if(j===0&&!I.force){P0({updated:!1,currentVersion:q1,targetVersion:M,mode:WF()?"binary":"source",message:`seal-useisalreadyatversionv${q1}.Use--forcetoreinstall.`});return}}if(I.changelogOnly){let M=await Lf(q,I.limit??10);P0({currentVersion:q1,totalQueried:M.length,releases:M.map((j)=>({version:j.version,tagName:j.tagName,publishedAt:j.publishedAt,author:j.author,releaseNotes:j.notes,releaseUrl:j.htmlUrl,isCurrent:j.version===q1,isNewer:Dw(j.version,q1)}))});return}if(!WF()){if(I.checkOnly){let j=await Lf(q,30),x=j[0],h=x?.version??q1,b=j.find((n)=>n.version===q1),R=Dw(h,q1),f=j.filter((n)=>Dw(n.version,q1));P0({updated:!1,updateAvailable:R,currentVersion:q1,currentVersionPublishedAt:b?.publishedAt,latestVersion:h,latestVersionPublishedAt:x?.publishedAt,behindCount:f.length,pendingReleases:f.map((n)=>({version:n.version,tagName:n.tagName,publishedAt:n.publishedAt,author:n.author,releaseNotes:n.notes,releaseUrl:n.htmlUrl})),releaseNotes:x?.notes??"",releaseUrl:x?.htmlUrl??"",mode:"source",message:"Running in source development mode. Run 'seal-use update' to git pull & bun install."});return}let M=LY(z).running;if(M)await dI("stop",z);try{gN0("git",["-C",$.appRoot,"pull","--ff-only"])}catch(j){console.error(`gitpullskipped:${jinstanceofError?j.message:String(j)}`)}if(gN0("bun",["install"],{cwd:$.appRoot}),M)await dI("start",z);P0({updated:!0,serviceRestarted:M,version:q1,mode:"source"});return}let J=FL1(),Q=NL1(),K=await Lf(q,30),w=Y?K.find((M)=>M.version===Y||M.tagName===Y||M.tagName===`v${Y}`)??await RN0(q,Y):K[0]??await RN0(q);if(!w){P0({updated:!1,currentVersion:q1,mode:"binary",message:`Failedtoqueryreleasesfromrepository'${q}'`});return}let G=w.version,H=K.find((M)=>M.version===q1),W=Dw(G,q1),V=W||Boolean(I.force),X=K.filter((M)=>Dw(M.version,q1));if(I.checkOnly){P0({updated:!1,updateAvailable:W,currentVersion:q1,currentVersionPublishedAt:H?.publishedAt,latestVersion:G,latestVersionPublishedAt:w.publishedAt,behindCount:X.length,pendingReleases:X.map((M)=>({version:M.version,tagName:M.tagName,publishedAt:M.publishedAt,author:M.author,releaseNotes:M.notes,releaseUrl:M.htmlUrl})),releaseNotes:w.notes,releaseUrl:w.htmlUrl,mode:"binary"});return}if(!V){P0({updated:!1,currentVersion:q1,currentVersionPublishedAt:H?.publishedAt,latestVersion:G,latestVersionPublishedAt:w.publishedAt,mode:"binary",message:`seal-useisalreadyuptodate(v${q1})`});return}let L=ML1(w.assets,J,Q);if(!L)throw Error(`Nocompatiblebinaryfoundfor${J}-${Q}inreleasev${G}.Availableassets:${w.assets.map((M)=>M.name).join(", ")}`);let O=LY(z).running;if(O)await dI("stop",z);let D=process.execPath,A=LL1(D),T=vN0(A,`.tmp-update-${Date.now()}`);ZL1(T,{recursive:!0});try{let M=vN0(T,L.name);await AL1(L.downloadUrl,M,w.tagName,L.name);let j=M;if(L.name.endsWith(".tar.gz")||L.name.endsWith(".tgz"))j=PL1(M,T,J);else if(L.name.endsWith(".zip"))j=TL1(M,T,J);if(VL1(j,493),process.platform==="darwin")try{mI("/usr/bin/codesign",["--remove-signature",j],{stdio:"ignore"}),mI("/usr/bin/codesign",["--force","--sign","-",j],{stdio:"ignore"})}catch{}if(process.platform==="win32"){let h=`${D}.old.${Date.now()}`;try{Xf(D,h)}catch{}Xf(j,D)}else Xf(j,D);if(O)await dI("start",z);let x=ek();P0({updated:!0,fromVersion:q1,toVersion:G,serviceRestarted:O,skillSynced:x.synced?x.targetDir:!1,mode:"binary"})}finally{try{XL1(T,{recursive:!0,force:!0})}catch{}}}function FL1(){if(process.platform==="darwin")retur
Line truncated
`)}catch{}}async function AL1($,I,z,q){let U=Of(),Y=[],J=z?z.startsWith("v")?z:`v${z}`:void 0,Q=q||$.split("/").pop()||"";if(U!=="github"){if(J&&Q)Y.push(`https://git.ying-qing.cn/gitea/seal-use/releases/download/${J}/${Q}`,`https://git.ying-qing.cn/gitea/seal-home/releases/download/${J}/${Q}`);if($.startsWith("https://git.ying-qing.cn"))Y.push($)}if(U!=="gitea")if(J&&Q){let L=`https://github.com/${CN0}/releases/download/${J}/${Q}`;if(!process.env.CI)Y.push(`https://ghfast.top/${L}`,`https://gh.ddlc.top/${L}`);Y.push(L)}else if($.includes("github.com")){if(!process.env.CI)Y.push(`https://ghfast.top/${$}`,`https://gh.ddlc.top/${$}`);Y.push($)}else Y.push($);let K=Array.from(new Set(Y)),w,G=6000,H=6000,W=307200,V=1e4,X=180000;for(let L=0;L<K.length;L++){let O=K[L],D=new AbortController,A="",T=(h)=>{A=h;try{D.abort()}catch{}},M=setTimeout(()=>{T("Connection timed out (no response headers within 6s)")},G),j,x;try{VF(`==> [${L+1}/${K.length}] Downloading via: ${O}`);let h=await fetch(O,{signal:D.signal});if(M)clearTimeout(M),M=void 0;if(!h.ok)throw Error(`HTTP ${h.status} ${h.statusText}`);j=setTimeout(()=>{T("Overall download time exceeded 3 minutes")},X);let b=Number(h.headers.get("content-length"))||0,R=h.body?.getReader();if(!R){let p=Buffer.from(await h.arrayBuffer());if(p.length<1000)throw Error(`Downloaded content is suspiciously small (${p.length} bytes)`);jN0(I,p),VF(`✓ Download succeeded (${(p.length/1024/1024).toFixed(1)} MB)`);return}let f=[],n=0,C=0;x=setTimeout(()=>{if(n<W){let p=(n/1024).toFixed(1);T(`Initial transfer too slow (${p} KB < 300 KB in 6s), switching mirror...`)}},H);while(!0){let p=R.read(),z0,v=new Promise((q0,w0)=>{z0=setTimeout(()=>{w0(Error("Data transfer stalled (no chunk received for 10s)"))},V)}),u;try{u=await Promise.race([p,v])}finally{if(z0)clearTimeout(z0)}let{done:c,value:r}=u;if(c)break;if(r){if(f.push(r),n+=r.length,x&&n>=W)clearTimeout(x),x=void 0;let q0=Date.now();if(q0-C>200){C=q0;let w0=b?Math.round(n/b*100):0,M0=(n/1048576).toFixed(1),R0=b?(b/1048576).toFixed(1):"?";try{process.stderr.write(`\r ↳ Progress: ${w0}% (${M0} / ${R0} MB)...`)}catch{}}}}try{process.stderr.write(`
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.