archik 0.12.45 → 0.12.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -501,7 +501,7 @@ ${d}
501
501
  Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let v of o.seen.entries()){let k=v[1];if(c===v[0]){b(v);continue}if(o.external){let N=o.external.registry.get(v[0])?.id;if(c!==v[0]&&N){b(v);continue}}if(o.metadataRegistry.get(v[0])?.id){b(v);continue}if(k.cycle){b(v);continue}if(k.count>1&&o.reused==="ref"){b(v);continue}}}function hL(o,c){let d=o.seen.get(c);if(!d)throw new Error("Unprocessed schema. This is a bug in Zod.");let g=v=>{let k=o.seen.get(v);if(k.ref===null)return;let T=k.def??k.schema,N={...T},j=k.ref;if(k.ref=null,j){g(j);let G=o.seen.get(j),K=G.schema;if(K.$ref&&(o.target==="draft-07"||o.target==="draft-04"||o.target==="openapi-3.0")?(T.allOf=T.allOf??[],T.allOf.push(K)):Object.assign(T,K),Object.assign(T,N),v._zod.parent===j)for(let ce in T)ce==="$ref"||ce==="allOf"||ce in N||delete T[ce];if(K.$ref&&G.def)for(let ce in T)ce==="$ref"||ce==="allOf"||ce in G.def&&JSON.stringify(T[ce])===JSON.stringify(G.def[ce])&&delete T[ce]}let B=v._zod.parent;if(B&&B!==j){g(B);let G=o.seen.get(B);if(G?.schema.$ref&&(T.$ref=G.schema.$ref,G.def))for(let K in T)K==="$ref"||K==="allOf"||K in G.def&&JSON.stringify(T[K])===JSON.stringify(G.def[K])&&delete T[K]}o.override({zodSchema:v,jsonSchema:T,path:k.path??[]})};for(let v of[...o.seen.entries()].reverse())g(v[0]);let f={};if(o.target==="draft-2020-12"?f.$schema="https://json-schema.org/draft/2020-12/schema":o.target==="draft-07"?f.$schema="http://json-schema.org/draft-07/schema#":o.target==="draft-04"?f.$schema="http://json-schema.org/draft-04/schema#":o.target,o.external?.uri){let v=o.external.registry.get(c)?.id;if(!v)throw new Error("Schema is missing an `id` property");f.$id=o.external.uri(v)}Object.assign(f,d.def??d.schema);let b=o.external?.defs??{};for(let v of o.seen.entries()){let k=v[1];k.def&&k.defId&&(b[k.defId]=k.def)}o.external||Object.keys(b).length>0&&(o.target==="draft-2020-12"?f.$defs=b:f.definitions=b);try{let v=JSON.parse(JSON.stringify(f));return Object.defineProperty(v,"~standard",{value:{...c["~standard"],jsonSchema:{input:wq(c,"input",o.processors),output:wq(c,"output",o.processors)}},enumerable:!1,writable:!1}),v}catch{throw new Error("Error converting schema to JSON.")}}function Jy(o,c){let d=c??{seen:new Set};if(d.seen.has(o))return!1;d.seen.add(o);let g=o._zod.def;if(g.type==="transform")return!0;if(g.type==="array")return Jy(g.element,d);if(g.type==="set")return Jy(g.valueType,d);if(g.type==="lazy")return Jy(g.getter(),d);if(g.type==="promise"||g.type==="optional"||g.type==="nonoptional"||g.type==="nullable"||g.type==="readonly"||g.type==="default"||g.type==="prefault")return Jy(g.innerType,d);if(g.type==="intersection")return Jy(g.left,d)||Jy(g.right,d);if(g.type==="record"||g.type==="map")return Jy(g.keyType,d)||Jy(g.valueType,d);if(g.type==="pipe")return Jy(g.in,d)||Jy(g.out,d);if(g.type==="object"){for(let f in g.shape)if(Jy(g.shape[f],d))return!0;return!1}if(g.type==="union"){for(let f of g.options)if(Jy(f,d))return!0;return!1}if(g.type==="tuple"){for(let f of g.items)if(Jy(f,d))return!0;return!!(g.rest&&Jy(g.rest,d))}return!1}var e1t=(o,c={})=>d=>{let g=uL({...d,processors:c});return nu(o,g),lL(g,o),hL(g,o)},wq=(o,c,d={})=>g=>{let{libraryOptions:f,target:b}=g??{},v=uL({...f??{},target:b,io:c,processors:d});return nu(o,v),lL(v,o),hL(v,o)};var BHn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},t1t=(o,c,d,g)=>{let f=d;f.type="string";let{minimum:b,maximum:v,format:k,patterns:T,contentEncoding:N}=o._zod.bag;if(typeof b=="number"&&(f.minLength=b),typeof v=="number"&&(f.maxLength=v),k&&(f.format=BHn[k]??k,f.format===""&&delete f.format,k==="time"&&delete f.format),N&&(f.contentEncoding=N),T&&T.size>0){let j=[...T];j.length===1?f.pattern=j[0].source:j.length>1&&(f.allOf=[...j.map(B=>({...c.target==="draft-07"||c.target==="draft-04"||c.target==="openapi-3.0"?{type:"string"}:{},pattern:B.source}))])}},n1t=(o,c,d,g)=>{let f=d,{minimum:b,maximum:v,format:k,multipleOf:T,exclusiveMaximum:N,exclusiveMinimum:j}=o._zod.bag;typeof k=="string"&&k.includes("int")?f.type="integer":f.type="number",typeof j=="number"&&(c.target==="draft-04"||c.target==="openapi-3.0"?(f.minimum=j,f.exclusiveMinimum=!0):f.exclusiveMinimum=j),typeof b=="number"&&(f.minimum=b,typeof j=="number"&&c.target!=="draft-04"&&(j>=b?delete f.minimum:delete f.exclusiveMinimum)),typeof N=="number"&&(c.target==="draft-04"||c.target==="openapi-3.0"?(f.maximum=N,f.exclusiveMaximum=!0):f.exclusiveMaximum=N),typeof v=="number"&&(f.maximum=v,typeof N=="number"&&c.target!=="draft-04"&&(N<=v?delete f.maximum:delete f.exclusiveMaximum)),typeof T=="number"&&(f.multipleOf=T)},r1t=(o,c,d,g)=>{d.type="boolean"},i1t=(o,c,d,g)=>{if(c.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},o1t=(o,c,d,g)=>{if(c.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},c1t=(o,c,d,g)=>{c.target==="openapi-3.0"?(d.type="string",d.nullable=!0,d.enum=[null]):d.type="null"},a1t=(o,c,d,g)=>{if(c.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},s1t=(o,c,d,g)=>{if(c.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},u1t=(o,c,d,g)=>{d.not={}},l1t=(o,c,d,g)=>{},h1t=(o,c,d,g)=>{},d1t=(o,c,d,g)=>{if(c.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},f1t=(o,c,d,g)=>{let f=o._zod.def,b=qQ(f.entries);b.every(v=>typeof v=="number")&&(d.type="number"),b.every(v=>typeof v=="string")&&(d.type="string"),d.enum=b},p1t=(o,c,d,g)=>{let f=o._zod.def,b=[];for(let v of f.values)if(v===void 0){if(c.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof v=="bigint"){if(c.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");b.push(Number(v))}else b.push(v);if(b.length!==0)if(b.length===1){let v=b[0];d.type=v===null?"null":typeof v,c.target==="draft-04"||c.target==="openapi-3.0"?d.enum=[v]:d.const=v}else b.every(v=>typeof v=="number")&&(d.type="number"),b.every(v=>typeof v=="string")&&(d.type="string"),b.every(v=>typeof v=="boolean")&&(d.type="boolean"),b.every(v=>v===null)&&(d.type="null"),d.enum=b},g1t=(o,c,d,g)=>{if(c.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},y1t=(o,c,d,g)=>{let f=d,b=o._zod.pattern;if(!b)throw new Error("Pattern not found in template literal");f.type="string",f.pattern=b.source},b1t=(o,c,d,g)=>{let f=d,b={type:"string",format:"binary",contentEncoding:"binary"},{minimum:v,maximum:k,mime:T}=o._zod.bag;v!==void 0&&(b.minLength=v),k!==void 0&&(b.maxLength=k),T?T.length===1?(b.contentMediaType=T[0],Object.assign(f,b)):(Object.assign(f,b),f.anyOf=T.map(N=>({contentMediaType:N}))):Object.assign(f,b)},w1t=(o,c,d,g)=>{d.type="boolean"},m1t=(o,c,d,g)=>{if(c.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},v1t=(o,c,d,g)=>{if(c.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},k1t=(o,c,d,g)=>{if(c.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},M1t=(o,c,d,g)=>{if(c.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},x1t=(o,c,d,g)=>{if(c.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},S1t=(o,c,d,g)=>{let f=d,b=o._zod.def,{minimum:v,maximum:k}=o._zod.bag;typeof v=="number"&&(f.minItems=v),typeof k=="number"&&(f.maxItems=k),f.type="array",f.items=nu(b.element,c,{...g,path:[...g.path,"items"]})},_1t=(o,c,d,g)=>{let f=d,b=o._zod.def;f.type="object",f.properties={};let v=b.shape;for(let N in v)f.properties[N]=nu(v[N],c,{...g,path:[...g.path,"properties",N]});let k=new Set(Object.keys(v)),T=new Set([...k].filter(N=>{let j=b.shape[N]._zod;return c.io==="input"?j.optin===void 0:j.optout===void 0}));T.size>0&&(f.required=Array.from(T)),b.catchall?._zod.def.type==="never"?f.additionalProperties=!1:b.catchall?b.catchall&&(f.additionalProperties=nu(b.catchall,c,{...g,path:[...g.path,"additionalProperties"]})):c.io==="output"&&(f.additionalProperties=!1)},x2e=(o,c,d,g)=>{let f=o._zod.def,b=f.inclusive===!1,v=f.options.map((k,T)=>nu(k,c,{...g,path:[...g.path,b?"oneOf":"anyOf",T]}));b?d.oneOf=v:d.anyOf=v},C1t=(o,c,d,g)=>{let f=o._zod.def,b=nu(f.left,c,{...g,path:[...g.path,"allOf",0]}),v=nu(f.right,c,{...g,path:[...g.path,"allOf",1]}),k=N=>"allOf"in N&&Object.keys(N).length===1,T=[...k(b)?b.allOf:[b],...k(v)?v.allOf:[v]];d.allOf=T},I1t=(o,c,d,g)=>{let f=d,b=o._zod.def;f.type="array";let v=c.target==="draft-2020-12"?"prefixItems":"items",k=c.target==="draft-2020-12"||c.target==="openapi-3.0"?"items":"additionalItems",T=b.items.map((G,K)=>nu(G,c,{...g,path:[...g.path,v,K]})),N=b.rest?nu(b.rest,c,{...g,path:[...g.path,k,...c.target==="openapi-3.0"?[b.items.length]:[]]}):null;c.target==="draft-2020-12"?(f.prefixItems=T,N&&(f.items=N)):c.target==="openapi-3.0"?(f.items={anyOf:T},N&&f.items.anyOf.push(N),f.minItems=T.length,N||(f.maxItems=T.length)):(f.items=T,N&&(f.additionalItems=N));let{minimum:j,maximum:B}=o._zod.bag;typeof j=="number"&&(f.minItems=j),typeof B=="number"&&(f.maxItems=B)},L1t=(o,c,d,g)=>{let f=d,b=o._zod.def;f.type="object";let v=b.keyType,T=v._zod.bag?.patterns;if(b.mode==="loose"&&T&&T.size>0){let j=nu(b.valueType,c,{...g,path:[...g.path,"patternProperties","*"]});f.patternProperties={};for(let B of T)f.patternProperties[B.source]=j}else(c.target==="draft-07"||c.target==="draft-2020-12")&&(f.propertyNames=nu(b.keyType,c,{...g,path:[...g.path,"propertyNames"]})),f.additionalProperties=nu(b.valueType,c,{...g,path:[...g.path,"additionalProperties"]});let N=v._zod.values;if(N){let j=[...N].filter(B=>typeof B=="string"||typeof B=="number");j.length>0&&(f.required=j)}},E1t=(o,c,d,g)=>{let f=o._zod.def,b=nu(f.innerType,c,g),v=c.seen.get(o);c.target==="openapi-3.0"?(v.ref=f.innerType,d.nullable=!0):d.anyOf=[b,{type:"null"}]},T1t=(o,c,d,g)=>{let f=o._zod.def;nu(f.innerType,c,g);let b=c.seen.get(o);b.ref=f.innerType},A1t=(o,c,d,g)=>{let f=o._zod.def;nu(f.innerType,c,g);let b=c.seen.get(o);b.ref=f.innerType,d.default=JSON.parse(JSON.stringify(f.defaultValue))},P1t=(o,c,d,g)=>{let f=o._zod.def;nu(f.innerType,c,g);let b=c.seen.get(o);b.ref=f.innerType,c.io==="input"&&(d._prefault=JSON.parse(JSON.stringify(f.defaultValue)))},N1t=(o,c,d,g)=>{let f=o._zod.def;nu(f.innerType,c,g);let b=c.seen.get(o);b.ref=f.innerType;let v;try{v=f.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}d.default=v},R1t=(o,c,d,g)=>{let f=o._zod.def,b=c.io==="input"?f.in._zod.def.type==="transform"?f.out:f.in:f.out;nu(b,c,g);let v=c.seen.get(o);v.ref=b},D1t=(o,c,d,g)=>{let f=o._zod.def;nu(f.innerType,c,g);let b=c.seen.get(o);b.ref=f.innerType,d.readOnly=!0},O1t=(o,c,d,g)=>{let f=o._zod.def;nu(f.innerType,c,g);let b=c.seen.get(o);b.ref=f.innerType},S2e=(o,c,d,g)=>{let f=o._zod.def;nu(f.innerType,c,g);let b=c.seen.get(o);b.ref=f.innerType},F1t=(o,c,d,g)=>{let f=o._zod.innerType;nu(f,c,g);let b=c.seen.get(o);b.ref=f},M2e={string:t1t,number:n1t,boolean:r1t,bigint:i1t,symbol:o1t,null:c1t,undefined:a1t,void:s1t,never:u1t,any:l1t,unknown:h1t,date:d1t,enum:f1t,literal:p1t,nan:g1t,template_literal:y1t,file:b1t,success:w1t,custom:m1t,function:v1t,transform:k1t,map:M1t,set:x1t,array:S1t,object:_1t,union:x2e,intersection:C1t,tuple:I1t,record:L1t,nullable:E1t,nonoptional:T1t,default:A1t,prefault:P1t,catch:N1t,pipe:R1t,readonly:D1t,promise:O1t,optional:S2e,lazy:F1t};function _2e(o,c){if("_idmap"in o){let g=o,f=uL({...c,processors:M2e}),b={};for(let T of g._idmap.entries()){let[N,j]=T;nu(j,f)}let v={},k={registry:g,uri:c?.uri,defs:b};f.external=k;for(let T of g._idmap.entries()){let[N,j]=T;lL(f,j),v[N]=hL(f,j)}if(Object.keys(b).length>0){let T=f.target==="draft-2020-12"?"$defs":"definitions";v.__shared={[T]:b}}return{schemas:v}}let d=uL({...c,processors:M2e});return nu(o,d),lL(d,o),hL(d,o)}var C2e=class{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(c){this.ctx.counter=c}get seen(){return this.ctx.seen}constructor(c){let d=c?.target??"draft-2020-12";d==="draft-4"&&(d="draft-04"),d==="draft-7"&&(d="draft-07"),this.ctx=uL({processors:M2e,target:d,...c?.metadata&&{metadata:c.metadata},...c?.unrepresentable&&{unrepresentable:c.unrepresentable},...c?.override&&{override:c.override},...c?.io&&{io:c.io}})}process(c,d={path:[],schemaPath:[]}){return nu(c,this.ctx,d)}emit(c,d){d&&(d.cycles&&(this.ctx.cycles=d.cycles),d.reused&&(this.ctx.reused=d.reused),d.external&&(this.ctx.external=d.external)),lL(this.ctx,c);let g=hL(this.ctx,c),{"~standard":f,...b}=g;return b}};var Gtn={};var see={};Bx(see,{ZodAny:()=>aht,ZodArray:()=>hht,ZodBase64:()=>W2e,ZodBase64URL:()=>J2e,ZodBigInt:()=>_q,ZodBigIntFormat:()=>K2e,ZodBoolean:()=>Sq,ZodCIDRv4:()=>G2e,ZodCIDRv6:()=>V2e,ZodCUID:()=>z2e,ZodCUID2:()=>j2e,ZodCatch:()=>Nht,ZodCodec:()=>ope,ZodCustom:()=>mee,ZodCustomStringFormat:()=>Mq,ZodDate:()=>pee,ZodDefault:()=>Iht,ZodDiscriminatedUnion:()=>fht,ZodE164:()=>Z2e,ZodEmail:()=>D2e,ZodEmoji:()=>O2e,ZodEnum:()=>vq,ZodExactOptional:()=>Sht,ZodFile:()=>Mht,ZodFunction:()=>$ht,ZodGUID:()=>uee,ZodIPv4:()=>U2e,ZodIPv6:()=>q2e,ZodIntersection:()=>pht,ZodJWT:()=>X2e,ZodKSUID:()=>$2e,ZodLazy:()=>jht,ZodLiteral:()=>kht,ZodMAC:()=>eht,ZodMap:()=>mht,ZodNaN:()=>Dht,ZodNanoID:()=>F2e,ZodNever:()=>uht,ZodNonOptional:()=>rpe,ZodNull:()=>oht,ZodNullable:()=>Cht,ZodNumber:()=>xq,ZodNumberFormat:()=>hR,ZodObject:()=>yee,ZodOptional:()=>npe,ZodPipe:()=>ipe,ZodPrefault:()=>Eht,ZodPromise:()=>Hht,ZodReadonly:()=>Oht,ZodRecord:()=>wee,ZodSet:()=>vht,ZodString:()=>kq,ZodStringFormat:()=>Ku,ZodSuccess:()=>Pht,ZodSymbol:()=>rht,ZodTemplateLiteral:()=>zht,ZodTransform:()=>xht,ZodTuple:()=>yht,ZodType:()=>bc,ZodULID:()=>B2e,ZodURL:()=>fee,ZodUUID:()=>I9,ZodUndefined:()=>iht,ZodUnion:()=>bee,ZodUnknown:()=>sht,ZodVoid:()=>lht,ZodXID:()=>H2e,ZodXor:()=>dht,_ZodString:()=>R2e,_default:()=>Lht,_function:()=>Ynn,any:()=>Tnn,array:()=>gee,base64:()=>fnn,base64url:()=>pnn,bigint:()=>_nn,boolean:()=>nht,catch:()=>Rht,check:()=>Qnn,cidrv4:()=>hnn,cidrv6:()=>dnn,codec:()=>Znn,cuid:()=>rnn,cuid2:()=>inn,custom:()=>ern,date:()=>Pnn,describe:()=>trn,discriminatedUnion:()=>znn,e164:()=>gnn,email:()=>Wtn,emoji:()=>tnn,enum:()=>epe,exactOptional:()=>_ht,file:()=>Gnn,float32:()=>knn,float64:()=>Mnn,function:()=>Ynn,guid:()=>Jtn,hash:()=>vnn,hex:()=>mnn,hostname:()=>wnn,httpUrl:()=>enn,instanceof:()=>rrn,int:()=>N2e,int32:()=>xnn,int64:()=>Cnn,intersection:()=>ght,ipv4:()=>snn,ipv6:()=>lnn,json:()=>orn,jwt:()=>ynn,keyof:()=>Nnn,ksuid:()=>ann,lazy:()=>Bht,literal:()=>qnn,looseObject:()=>Onn,looseRecord:()=>Bnn,mac:()=>unn,map:()=>Hnn,meta:()=>nrn,nan:()=>Jnn,nanoid:()=>nnn,nativeEnum:()=>Unn,never:()=>Y2e,nonoptional:()=>Aht,null:()=>cht,nullable:()=>hee,nullish:()=>Vnn,number:()=>tht,object:()=>Rnn,optional:()=>lee,partialRecord:()=>jnn,pipe:()=>dee,prefault:()=>Tht,preprocess:()=>crn,promise:()=>Knn,readonly:()=>Fht,record:()=>wht,refine:()=>Uht,set:()=>$nn,strictObject:()=>Dnn,string:()=>P2e,stringFormat:()=>bnn,stringbool:()=>irn,success:()=>Wnn,superRefine:()=>qht,symbol:()=>Lnn,templateLiteral:()=>Xnn,transform:()=>tpe,tuple:()=>bht,uint32:()=>Snn,uint64:()=>Inn,ulid:()=>onn,undefined:()=>Enn,union:()=>Q2e,unknown:()=>lR,url:()=>Qtn,uuid:()=>Ztn,uuidv4:()=>Xtn,uuidv6:()=>Ktn,uuidv7:()=>Ytn,void:()=>Ann,xid:()=>cnn,xor:()=>Fnn});var I2e={};Bx(I2e,{endsWith:()=>lq,gt:()=>_9,gte:()=>Wy,includes:()=>sq,length:()=>uR,lowercase:()=>cq,lt:()=>S9,lte:()=>yv,maxLength:()=>sR,maxSize:()=>sL,mime:()=>hq,minLength:()=>Wx,minSize:()=>C9,multipleOf:()=>aL,negative:()=>w2e,nonnegative:()=>v2e,nonpositive:()=>m2e,normalize:()=>dq,overwrite:()=>W5,positive:()=>b2e,property:()=>k2e,regex:()=>oq,size:()=>aR,slugify:()=>yq,startsWith:()=>uq,toLowerCase:()=>pq,toUpperCase:()=>gq,trim:()=>fq,uppercase:()=>aq});var mq={};Bx(mq,{ZodISODate:()=>E2e,ZodISODateTime:()=>L2e,ZodISODuration:()=>A2e,ZodISOTime:()=>T2e,date:()=>j1t,datetime:()=>z1t,duration:()=>H1t,time:()=>B1t});var L2e=kt("ZodISODateTime",(o,c)=>{gut.init(o,c),Ku.init(o,c)});function z1t(o){return mlt(L2e,o)}var E2e=kt("ZodISODate",(o,c)=>{yut.init(o,c),Ku.init(o,c)});function j1t(o){return vlt(E2e,o)}var T2e=kt("ZodISOTime",(o,c)=>{but.init(o,c),Ku.init(o,c)});function B1t(o){return klt(T2e,o)}var A2e=kt("ZodISODuration",(o,c)=>{wut.init(o,c),Ku.init(o,c)});function H1t(o){return Mlt(A2e,o)}var Vtn=(o,c)=>{ZQ.init(o,c),o.name="ZodError",Object.defineProperties(o,{format:{value:d=>KQ(o,d)},flatten:{value:d=>XQ(o,d)},addIssue:{value:d=>{o.issues.push(d),o.message=JSON.stringify(o.issues,XU,2)}},addIssues:{value:d=>{o.issues.push(...d),o.message=JSON.stringify(o.issues,XU,2)}},isEmpty:{get(){return o.issues.length===0}}})},$Hn=kt("ZodError",Vtn),Dw=kt("ZodError",Vtn,{Parent:Error});var $1t=QU(Dw),U1t=eq(Dw),q1t=tq(Dw),G1t=nq(Dw),V1t=_0e(Dw),W1t=C0e(Dw),J1t=I0e(Dw),Z1t=L0e(Dw),X1t=E0e(Dw),K1t=T0e(Dw),Y1t=A0e(Dw),Q1t=P0e(Dw);var bc=kt("ZodType",(o,c)=>(Bo.init(o,c),Object.assign(o["~standard"],{jsonSchema:{input:wq(o,"input"),output:wq(o,"output")}}),o.toJSONSchema=e1t(o,{}),o.def=c,o.type=c.type,Object.defineProperty(o,"_def",{value:c}),o.check=(...d)=>o.clone(ur.mergeDefs(c,{checks:[...c.checks??[],...d.map(g=>typeof g=="function"?{_zod:{check:g,def:{check:"custom"},onattach:[]}}:g)]}),{parent:!0}),o.with=o.check,o.clone=(d,g)=>Vy(o,d,g),o.brand=()=>o,o.register=((d,g)=>(d.add(o,g),o)),o.parse=(d,g)=>$1t(o,d,g,{callee:o.parse}),o.safeParse=(d,g)=>q1t(o,d,g),o.parseAsync=async(d,g)=>U1t(o,d,g,{callee:o.parseAsync}),o.safeParseAsync=async(d,g)=>G1t(o,d,g),o.spa=o.safeParseAsync,o.encode=(d,g)=>V1t(o,d,g),o.decode=(d,g)=>W1t(o,d,g),o.encodeAsync=async(d,g)=>J1t(o,d,g),o.decodeAsync=async(d,g)=>Z1t(o,d,g),o.safeEncode=(d,g)=>X1t(o,d,g),o.safeDecode=(d,g)=>K1t(o,d,g),o.safeEncodeAsync=async(d,g)=>Y1t(o,d,g),o.safeDecodeAsync=async(d,g)=>Q1t(o,d,g),o.refine=(d,g)=>o.check(Uht(d,g)),o.superRefine=d=>o.check(qht(d)),o.overwrite=d=>o.check(W5(d)),o.optional=()=>lee(o),o.exactOptional=()=>_ht(o),o.nullable=()=>hee(o),o.nullish=()=>lee(hee(o)),o.nonoptional=d=>Aht(o,d),o.array=()=>gee(o),o.or=d=>Q2e([o,d]),o.and=d=>ght(o,d),o.transform=d=>dee(o,tpe(d)),o.default=d=>Lht(o,d),o.prefault=d=>Tht(o,d),o.catch=d=>Rht(o,d),o.pipe=d=>dee(o,d),o.readonly=()=>Fht(o),o.describe=d=>{let g=o.clone();return Ip.add(g,{description:d}),g},Object.defineProperty(o,"description",{get(){return Ip.get(o)?.description},configurable:!0}),o.meta=(...d)=>{if(d.length===0)return Ip.get(o);let g=o.clone();return Ip.add(g,d[0]),g},o.isOptional=()=>o.safeParse(void 0).success,o.isNullable=()=>o.safeParse(null).success,o.apply=d=>d(o),o)),R2e=kt("_ZodString",(o,c)=>{cR.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(g,f,b)=>t1t(o,g,f,b);let d=o._zod.bag;o.format=d.format??null,o.minLength=d.minimum??null,o.maxLength=d.maximum??null,o.regex=(...g)=>o.check(oq(...g)),o.includes=(...g)=>o.check(sq(...g)),o.startsWith=(...g)=>o.check(uq(...g)),o.endsWith=(...g)=>o.check(lq(...g)),o.min=(...g)=>o.check(Wx(...g)),o.max=(...g)=>o.check(sR(...g)),o.length=(...g)=>o.check(uR(...g)),o.nonempty=(...g)=>o.check(Wx(1,...g)),o.lowercase=g=>o.check(cq(g)),o.uppercase=g=>o.check(aq(g)),o.trim=()=>o.check(fq()),o.normalize=(...g)=>o.check(dq(...g)),o.toLowerCase=()=>o.check(pq()),o.toUpperCase=()=>o.check(gq()),o.slugify=()=>o.check(yq())}),kq=kt("ZodString",(o,c)=>{cR.init(o,c),R2e.init(o,c),o.email=d=>o.check(K0e(D2e,d)),o.url=d=>o.check(aee(fee,d)),o.jwt=d=>o.check(y2e(X2e,d)),o.emoji=d=>o.check(n2e(O2e,d)),o.guid=d=>o.check(cee(uee,d)),o.uuid=d=>o.check(Y0e(I9,d)),o.uuidv4=d=>o.check(Q0e(I9,d)),o.uuidv6=d=>o.check(e2e(I9,d)),o.uuidv7=d=>o.check(t2e(I9,d)),o.nanoid=d=>o.check(r2e(F2e,d)),o.guid=d=>o.check(cee(uee,d)),o.cuid=d=>o.check(i2e(z2e,d)),o.cuid2=d=>o.check(o2e(j2e,d)),o.ulid=d=>o.check(c2e(B2e,d)),o.base64=d=>o.check(f2e(W2e,d)),o.base64url=d=>o.check(p2e(J2e,d)),o.xid=d=>o.check(a2e(H2e,d)),o.ksuid=d=>o.check(s2e($2e,d)),o.ipv4=d=>o.check(u2e(U2e,d)),o.ipv6=d=>o.check(l2e(q2e,d)),o.cidrv4=d=>o.check(h2e(G2e,d)),o.cidrv6=d=>o.check(d2e(V2e,d)),o.e164=d=>o.check(g2e(Z2e,d)),o.datetime=d=>o.check(z1t(d)),o.date=d=>o.check(j1t(d)),o.time=d=>o.check(B1t(d)),o.duration=d=>o.check(H1t(d))});function P2e(o){return glt(kq,o)}var Ku=kt("ZodStringFormat",(o,c)=>{Xu.init(o,c),R2e.init(o,c)}),D2e=kt("ZodEmail",(o,c)=>{cut.init(o,c),Ku.init(o,c)});function Wtn(o){return K0e(D2e,o)}var uee=kt("ZodGUID",(o,c)=>{iut.init(o,c),Ku.init(o,c)});function Jtn(o){return cee(uee,o)}var I9=kt("ZodUUID",(o,c)=>{out.init(o,c),Ku.init(o,c)});function Ztn(o){return Y0e(I9,o)}function Xtn(o){return Q0e(I9,o)}function Ktn(o){return e2e(I9,o)}function Ytn(o){return t2e(I9,o)}var fee=kt("ZodURL",(o,c)=>{aut.init(o,c),Ku.init(o,c)});function Qtn(o){return aee(fee,o)}function enn(o){return aee(fee,{protocol:/^https?$/,hostname:p3.domain,...ur.normalizeParams(o)})}var O2e=kt("ZodEmoji",(o,c)=>{sut.init(o,c),Ku.init(o,c)});function tnn(o){return n2e(O2e,o)}var F2e=kt("ZodNanoID",(o,c)=>{uut.init(o,c),Ku.init(o,c)});function nnn(o){return r2e(F2e,o)}var z2e=kt("ZodCUID",(o,c)=>{lut.init(o,c),Ku.init(o,c)});function rnn(o){return i2e(z2e,o)}var j2e=kt("ZodCUID2",(o,c)=>{hut.init(o,c),Ku.init(o,c)});function inn(o){return o2e(j2e,o)}var B2e=kt("ZodULID",(o,c)=>{dut.init(o,c),Ku.init(o,c)});function onn(o){return c2e(B2e,o)}var H2e=kt("ZodXID",(o,c)=>{fut.init(o,c),Ku.init(o,c)});function cnn(o){return a2e(H2e,o)}var $2e=kt("ZodKSUID",(o,c)=>{put.init(o,c),Ku.init(o,c)});function ann(o){return s2e($2e,o)}var U2e=kt("ZodIPv4",(o,c)=>{mut.init(o,c),Ku.init(o,c)});function snn(o){return u2e(U2e,o)}var eht=kt("ZodMAC",(o,c)=>{kut.init(o,c),Ku.init(o,c)});function unn(o){return blt(eht,o)}var q2e=kt("ZodIPv6",(o,c)=>{vut.init(o,c),Ku.init(o,c)});function lnn(o){return l2e(q2e,o)}var G2e=kt("ZodCIDRv4",(o,c)=>{Mut.init(o,c),Ku.init(o,c)});function hnn(o){return h2e(G2e,o)}var V2e=kt("ZodCIDRv6",(o,c)=>{xut.init(o,c),Ku.init(o,c)});function dnn(o){return d2e(V2e,o)}var W2e=kt("ZodBase64",(o,c)=>{_ut.init(o,c),Ku.init(o,c)});function fnn(o){return f2e(W2e,o)}var J2e=kt("ZodBase64URL",(o,c)=>{Cut.init(o,c),Ku.init(o,c)});function pnn(o){return p2e(J2e,o)}var Z2e=kt("ZodE164",(o,c)=>{Iut.init(o,c),Ku.init(o,c)});function gnn(o){return g2e(Z2e,o)}var X2e=kt("ZodJWT",(o,c)=>{Lut.init(o,c),Ku.init(o,c)});function ynn(o){return y2e(X2e,o)}var Mq=kt("ZodCustomStringFormat",(o,c)=>{Eut.init(o,c),Ku.init(o,c)});function bnn(o,c,d={}){return bq(Mq,o,c,d)}function wnn(o){return bq(Mq,"hostname",p3.hostname,o)}function mnn(o){return bq(Mq,"hex",p3.hex,o)}function vnn(o,c){let d=c?.enc??"hex",g=`${o}_${d}`,f=p3[g];if(!f)throw new Error(`Unrecognized hash format: ${g}`);return bq(Mq,g,f,c)}var xq=kt("ZodNumber",(o,c)=>{$0e.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(g,f,b)=>n1t(o,g,f,b),o.gt=(g,f)=>o.check(_9(g,f)),o.gte=(g,f)=>o.check(Wy(g,f)),o.min=(g,f)=>o.check(Wy(g,f)),o.lt=(g,f)=>o.check(S9(g,f)),o.lte=(g,f)=>o.check(yv(g,f)),o.max=(g,f)=>o.check(yv(g,f)),o.int=g=>o.check(N2e(g)),o.safe=g=>o.check(N2e(g)),o.positive=g=>o.check(_9(0,g)),o.nonnegative=g=>o.check(Wy(0,g)),o.negative=g=>o.check(S9(0,g)),o.nonpositive=g=>o.check(yv(0,g)),o.multipleOf=(g,f)=>o.check(aL(g,f)),o.step=(g,f)=>o.check(aL(g,f)),o.finite=()=>o;let d=o._zod.bag;o.minValue=Math.max(d.minimum??Number.NEGATIVE_INFINITY,d.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,o.maxValue=Math.min(d.maximum??Number.POSITIVE_INFINITY,d.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,o.isInt=(d.format??"").includes("int")||Number.isSafeInteger(d.multipleOf??.5),o.isFinite=!0,o.format=d.format??null});function tht(o){return xlt(xq,o)}var hR=kt("ZodNumberFormat",(o,c)=>{Tut.init(o,c),xq.init(o,c)});function N2e(o){return _lt(hR,o)}function knn(o){return Clt(hR,o)}function Mnn(o){return Ilt(hR,o)}function xnn(o){return Llt(hR,o)}function Snn(o){return Elt(hR,o)}var Sq=kt("ZodBoolean",(o,c)=>{tee.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>r1t(o,d,g,f)});function nht(o){return Tlt(Sq,o)}var _q=kt("ZodBigInt",(o,c)=>{U0e.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(g,f,b)=>i1t(o,g,f,b),o.gte=(g,f)=>o.check(Wy(g,f)),o.min=(g,f)=>o.check(Wy(g,f)),o.gt=(g,f)=>o.check(_9(g,f)),o.gte=(g,f)=>o.check(Wy(g,f)),o.min=(g,f)=>o.check(Wy(g,f)),o.lt=(g,f)=>o.check(S9(g,f)),o.lte=(g,f)=>o.check(yv(g,f)),o.max=(g,f)=>o.check(yv(g,f)),o.positive=g=>o.check(_9(BigInt(0),g)),o.negative=g=>o.check(S9(BigInt(0),g)),o.nonpositive=g=>o.check(yv(BigInt(0),g)),o.nonnegative=g=>o.check(Wy(BigInt(0),g)),o.multipleOf=(g,f)=>o.check(aL(g,f));let d=o._zod.bag;o.minValue=d.minimum??null,o.maxValue=d.maximum??null,o.format=d.format??null});function _nn(o){return Plt(_q,o)}var K2e=kt("ZodBigIntFormat",(o,c)=>{Aut.init(o,c),_q.init(o,c)});function Cnn(o){return Rlt(K2e,o)}function Inn(o){return Dlt(K2e,o)}var rht=kt("ZodSymbol",(o,c)=>{Put.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>o1t(o,d,g,f)});function Lnn(o){return Olt(rht,o)}var iht=kt("ZodUndefined",(o,c)=>{Nut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>a1t(o,d,g,f)});function Enn(o){return Flt(iht,o)}var oht=kt("ZodNull",(o,c)=>{Rut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>c1t(o,d,g,f)});function cht(o){return zlt(oht,o)}var aht=kt("ZodAny",(o,c)=>{Dut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>l1t(o,d,g,f)});function Tnn(){return jlt(aht)}var sht=kt("ZodUnknown",(o,c)=>{Out.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>h1t(o,d,g,f)});function lR(){return Blt(sht)}var uht=kt("ZodNever",(o,c)=>{Fut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>u1t(o,d,g,f)});function Y2e(o){return Hlt(uht,o)}var lht=kt("ZodVoid",(o,c)=>{zut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>s1t(o,d,g,f)});function Ann(o){return $lt(lht,o)}var pee=kt("ZodDate",(o,c)=>{jut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(g,f,b)=>d1t(o,g,f,b),o.min=(g,f)=>o.check(Wy(g,f)),o.max=(g,f)=>o.check(yv(g,f));let d=o._zod.bag;o.minDate=d.minimum?new Date(d.minimum):null,o.maxDate=d.maximum?new Date(d.maximum):null});function Pnn(o){return Ult(pee,o)}var hht=kt("ZodArray",(o,c)=>{But.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>S1t(o,d,g,f),o.element=c.element,o.min=(d,g)=>o.check(Wx(d,g)),o.nonempty=d=>o.check(Wx(1,d)),o.max=(d,g)=>o.check(sR(d,g)),o.length=(d,g)=>o.check(uR(d,g)),o.unwrap=()=>o.element});function gee(o,c){return Vlt(hht,o,c)}function Nnn(o){let c=o._zod.def.shape;return epe(Object.keys(c))}var yee=kt("ZodObject",(o,c)=>{Hut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>_1t(o,d,g,f),ur.defineLazy(o,"shape",()=>c.shape),o.keyof=()=>epe(Object.keys(o._zod.def.shape)),o.catchall=d=>o.clone({...o._zod.def,catchall:d}),o.passthrough=()=>o.clone({...o._zod.def,catchall:lR()}),o.loose=()=>o.clone({...o._zod.def,catchall:lR()}),o.strict=()=>o.clone({...o._zod.def,catchall:Y2e()}),o.strip=()=>o.clone({...o._zod.def,catchall:void 0}),o.extend=d=>ur.extend(o,d),o.safeExtend=d=>ur.safeExtend(o,d),o.merge=d=>ur.merge(o,d),o.pick=d=>ur.pick(o,d),o.omit=d=>ur.omit(o,d),o.partial=(...d)=>ur.partial(npe,o,d[0]),o.required=(...d)=>ur.required(rpe,o,d[0])});function Rnn(o,c){let d={type:"object",shape:o??{},...ur.normalizeParams(c)};return new yee(d)}function Dnn(o,c){return new yee({type:"object",shape:o,catchall:Y2e(),...ur.normalizeParams(c)})}function Onn(o,c){return new yee({type:"object",shape:o,catchall:lR(),...ur.normalizeParams(c)})}var bee=kt("ZodUnion",(o,c)=>{nee.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>x2e(o,d,g,f),o.options=c.options});function Q2e(o,c){return new bee({type:"union",options:o,...ur.normalizeParams(c)})}var dht=kt("ZodXor",(o,c)=>{bee.init(o,c),$ut.init(o,c),o._zod.processJSONSchema=(d,g,f)=>x2e(o,d,g,f),o.options=c.options});function Fnn(o,c){return new dht({type:"union",options:o,inclusive:!1,...ur.normalizeParams(c)})}var fht=kt("ZodDiscriminatedUnion",(o,c)=>{bee.init(o,c),Uut.init(o,c)});function znn(o,c,d){return new fht({type:"union",options:c,discriminator:o,...ur.normalizeParams(d)})}var pht=kt("ZodIntersection",(o,c)=>{qut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>C1t(o,d,g,f)});function ght(o,c){return new pht({type:"intersection",left:o,right:c})}var yht=kt("ZodTuple",(o,c)=>{q0e.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>I1t(o,d,g,f),o.rest=d=>o.clone({...o._zod.def,rest:d})});function bht(o,c,d){let g=c instanceof Bo,f=g?d:c,b=g?c:null;return new yht({type:"tuple",items:o,rest:b,...ur.normalizeParams(f)})}var wee=kt("ZodRecord",(o,c)=>{Gut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>L1t(o,d,g,f),o.keyType=c.keyType,o.valueType=c.valueType});function wht(o,c,d){return new wee({type:"record",keyType:o,valueType:c,...ur.normalizeParams(d)})}function jnn(o,c,d){let g=Vy(o);return g._zod.values=void 0,new wee({type:"record",keyType:g,valueType:c,...ur.normalizeParams(d)})}function Bnn(o,c,d){return new wee({type:"record",keyType:o,valueType:c,mode:"loose",...ur.normalizeParams(d)})}var mht=kt("ZodMap",(o,c)=>{Vut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>M1t(o,d,g,f),o.keyType=c.keyType,o.valueType=c.valueType,o.min=(...d)=>o.check(C9(...d)),o.nonempty=d=>o.check(C9(1,d)),o.max=(...d)=>o.check(sL(...d)),o.size=(...d)=>o.check(aR(...d))});function Hnn(o,c,d){return new mht({type:"map",keyType:o,valueType:c,...ur.normalizeParams(d)})}var vht=kt("ZodSet",(o,c)=>{Wut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>x1t(o,d,g,f),o.min=(...d)=>o.check(C9(...d)),o.nonempty=d=>o.check(C9(1,d)),o.max=(...d)=>o.check(sL(...d)),o.size=(...d)=>o.check(aR(...d))});function $nn(o,c){return new vht({type:"set",valueType:o,...ur.normalizeParams(c)})}var vq=kt("ZodEnum",(o,c)=>{Jut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(g,f,b)=>f1t(o,g,f,b),o.enum=c.entries,o.options=Object.values(c.entries);let d=new Set(Object.keys(c.entries));o.extract=(g,f)=>{let b={};for(let v of g)if(d.has(v))b[v]=c.entries[v];else throw new Error(`Key ${v} not found in enum`);return new vq({...c,checks:[],...ur.normalizeParams(f),entries:b})},o.exclude=(g,f)=>{let b={...c.entries};for(let v of g)if(d.has(v))delete b[v];else throw new Error(`Key ${v} not found in enum`);return new vq({...c,checks:[],...ur.normalizeParams(f),entries:b})}});function epe(o,c){let d=Array.isArray(o)?Object.fromEntries(o.map(g=>[g,g])):o;return new vq({type:"enum",entries:d,...ur.normalizeParams(c)})}function Unn(o,c){return new vq({type:"enum",entries:o,...ur.normalizeParams(c)})}var kht=kt("ZodLiteral",(o,c)=>{Zut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>p1t(o,d,g,f),o.values=new Set(c.values),Object.defineProperty(o,"value",{get(){if(c.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return c.values[0]}})});function qnn(o,c){return new kht({type:"literal",values:Array.isArray(o)?o:[o],...ur.normalizeParams(c)})}var Mht=kt("ZodFile",(o,c)=>{Xut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>b1t(o,d,g,f),o.min=(d,g)=>o.check(C9(d,g)),o.max=(d,g)=>o.check(sL(d,g)),o.mime=(d,g)=>o.check(hq(Array.isArray(d)?d:[d],g))});function Gnn(o){return Wlt(Mht,o)}var xht=kt("ZodTransform",(o,c)=>{Kut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>k1t(o,d,g,f),o._zod.parse=(d,g)=>{if(g.direction==="backward")throw new nL(o.constructor.name);d.addIssue=b=>{if(typeof b=="string")d.issues.push(ur.issue(b,d.value,c));else{let v=b;v.fatal&&(v.continue=!1),v.code??(v.code="custom"),v.input??(v.input=d.value),v.inst??(v.inst=o),d.issues.push(ur.issue(v))}};let f=c.transform(d.value,d);return f instanceof Promise?f.then(b=>(d.value=b,d)):(d.value=f,d)}});function tpe(o){return new xht({type:"transform",transform:o})}var npe=kt("ZodOptional",(o,c)=>{G0e.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>S2e(o,d,g,f),o.unwrap=()=>o._zod.def.innerType});function lee(o){return new npe({type:"optional",innerType:o})}var Sht=kt("ZodExactOptional",(o,c)=>{Yut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>S2e(o,d,g,f),o.unwrap=()=>o._zod.def.innerType});function _ht(o){return new Sht({type:"optional",innerType:o})}var Cht=kt("ZodNullable",(o,c)=>{Qut.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>E1t(o,d,g,f),o.unwrap=()=>o._zod.def.innerType});function hee(o){return new Cht({type:"nullable",innerType:o})}function Vnn(o){return lee(hee(o))}var Iht=kt("ZodDefault",(o,c)=>{elt.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>A1t(o,d,g,f),o.unwrap=()=>o._zod.def.innerType,o.removeDefault=o.unwrap});function Lht(o,c){return new Iht({type:"default",innerType:o,get defaultValue(){return typeof c=="function"?c():ur.shallowClone(c)}})}var Eht=kt("ZodPrefault",(o,c)=>{tlt.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>P1t(o,d,g,f),o.unwrap=()=>o._zod.def.innerType});function Tht(o,c){return new Eht({type:"prefault",innerType:o,get defaultValue(){return typeof c=="function"?c():ur.shallowClone(c)}})}var rpe=kt("ZodNonOptional",(o,c)=>{nlt.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>T1t(o,d,g,f),o.unwrap=()=>o._zod.def.innerType});function Aht(o,c){return new rpe({type:"nonoptional",innerType:o,...ur.normalizeParams(c)})}var Pht=kt("ZodSuccess",(o,c)=>{rlt.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>w1t(o,d,g,f),o.unwrap=()=>o._zod.def.innerType});function Wnn(o){return new Pht({type:"success",innerType:o})}var Nht=kt("ZodCatch",(o,c)=>{ilt.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>N1t(o,d,g,f),o.unwrap=()=>o._zod.def.innerType,o.removeCatch=o.unwrap});function Rht(o,c){return new Nht({type:"catch",innerType:o,catchValue:typeof c=="function"?c:()=>c})}var Dht=kt("ZodNaN",(o,c)=>{olt.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>g1t(o,d,g,f)});function Jnn(o){return Glt(Dht,o)}var ipe=kt("ZodPipe",(o,c)=>{clt.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>R1t(o,d,g,f),o.in=c.in,o.out=c.out});function dee(o,c){return new ipe({type:"pipe",in:o,out:c})}var ope=kt("ZodCodec",(o,c)=>{ipe.init(o,c),ree.init(o,c)});function Znn(o,c,d){return new ope({type:"pipe",in:o,out:c,transform:d.decode,reverseTransform:d.encode})}var Oht=kt("ZodReadonly",(o,c)=>{alt.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>D1t(o,d,g,f),o.unwrap=()=>o._zod.def.innerType});function Fht(o){return new Oht({type:"readonly",innerType:o})}var zht=kt("ZodTemplateLiteral",(o,c)=>{slt.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>y1t(o,d,g,f)});function Xnn(o,c){return new zht({type:"template_literal",parts:o,...ur.normalizeParams(c)})}var jht=kt("ZodLazy",(o,c)=>{hlt.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>F1t(o,d,g,f),o.unwrap=()=>o._zod.def.getter()});function Bht(o){return new jht({type:"lazy",getter:o})}var Hht=kt("ZodPromise",(o,c)=>{llt.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>O1t(o,d,g,f),o.unwrap=()=>o._zod.def.innerType});function Knn(o){return new Hht({type:"promise",innerType:o})}var $ht=kt("ZodFunction",(o,c)=>{ult.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>v1t(o,d,g,f)});function Ynn(o){return new $ht({type:"function",input:Array.isArray(o?.input)?bht(o?.input):o?.input??gee(lR()),output:o?.output??lR()})}var mee=kt("ZodCustom",(o,c)=>{dlt.init(o,c),bc.init(o,c),o._zod.processJSONSchema=(d,g,f)=>m1t(o,d,g,f)});function Qnn(o){let c=new pl({check:"custom"});return c._zod.check=o,c}function ern(o,c){return Jlt(mee,o??(()=>!0),c)}function Uht(o,c={}){return Zlt(mee,o,c)}function qht(o){return Xlt(o)}var trn=Klt,nrn=Ylt;function rrn(o,c={}){let d=new mee({type:"custom",check:"custom",fn:g=>g instanceof o,abort:!0,...ur.normalizeParams(c)});return d._zod.bag.Class=o,d._zod.check=g=>{g.value instanceof o||g.issues.push({code:"invalid_type",expected:o.name,input:g.value,inst:d,path:[...d._zod.def.path??[]]})},d}var irn=(...o)=>Qlt({Codec:ope,Boolean:Sq,String:kq},...o);function orn(o){let c=Bht(()=>Q2e([P2e(o),tht(),nht(),cht(),gee(c),wht(P2e(),c)]));return c}function crn(o,c){return dee(tpe(o),c)}var qHn={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function GHn(o){fd({customError:o})}function VHn(){return fd().customError}var Ght;Ght||(Ght={});var jr={...see,...I2e,iso:mq},WHn=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function JHn(o,c){let d=o.$schema;return d==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":d==="http://json-schema.org/draft-07/schema#"?"draft-7":d==="http://json-schema.org/draft-04/schema#"?"draft-4":c??"draft-2020-12"}function ZHn(o,c){if(!o.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let d=o.slice(1).split("/").filter(Boolean);if(d.length===0)return c.rootSchema;let g=c.version==="draft-2020-12"?"$defs":"definitions";if(d[0]===g){let f=d[1];if(!f||!c.defs[f])throw new Error(`Reference not found: ${o}`);return c.defs[f]}throw new Error(`Reference not found: ${o}`)}function arn(o,c){if(o.not!==void 0){if(typeof o.not=="object"&&Object.keys(o.not).length===0)return jr.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(o.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(o.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(o.if!==void 0||o.then!==void 0||o.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(o.dependentSchemas!==void 0||o.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(o.$ref){let f=o.$ref;if(c.refs.has(f))return c.refs.get(f);if(c.processing.has(f))return jr.lazy(()=>{if(!c.refs.has(f))throw new Error(`Circular reference not resolved: ${f}`);return c.refs.get(f)});c.processing.add(f);let b=ZHn(f,c),v=Tg(b,c);return c.refs.set(f,v),c.processing.delete(f),v}if(o.enum!==void 0){let f=o.enum;if(c.version==="openapi-3.0"&&o.nullable===!0&&f.length===1&&f[0]===null)return jr.null();if(f.length===0)return jr.never();if(f.length===1)return jr.literal(f[0]);if(f.every(v=>typeof v=="string"))return jr.enum(f);let b=f.map(v=>jr.literal(v));return b.length<2?b[0]:jr.union([b[0],b[1],...b.slice(2)])}if(o.const!==void 0)return jr.literal(o.const);let d=o.type;if(Array.isArray(d)){let f=d.map(b=>{let v={...o,type:b};return arn(v,c)});return f.length===0?jr.never():f.length===1?f[0]:jr.union(f)}if(!d)return jr.any();let g;switch(d){case"string":{let f=jr.string();if(o.format){let b=o.format;b==="email"?f=f.check(jr.email()):b==="uri"||b==="uri-reference"?f=f.check(jr.url()):b==="uuid"||b==="guid"?f=f.check(jr.uuid()):b==="date-time"?f=f.check(jr.iso.datetime()):b==="date"?f=f.check(jr.iso.date()):b==="time"?f=f.check(jr.iso.time()):b==="duration"?f=f.check(jr.iso.duration()):b==="ipv4"?f=f.check(jr.ipv4()):b==="ipv6"?f=f.check(jr.ipv6()):b==="mac"?f=f.check(jr.mac()):b==="cidr"?f=f.check(jr.cidrv4()):b==="cidr-v6"?f=f.check(jr.cidrv6()):b==="base64"?f=f.check(jr.base64()):b==="base64url"?f=f.check(jr.base64url()):b==="e164"?f=f.check(jr.e164()):b==="jwt"?f=f.check(jr.jwt()):b==="emoji"?f=f.check(jr.emoji()):b==="nanoid"?f=f.check(jr.nanoid()):b==="cuid"?f=f.check(jr.cuid()):b==="cuid2"?f=f.check(jr.cuid2()):b==="ulid"?f=f.check(jr.ulid()):b==="xid"?f=f.check(jr.xid()):b==="ksuid"&&(f=f.check(jr.ksuid()))}typeof o.minLength=="number"&&(f=f.min(o.minLength)),typeof o.maxLength=="number"&&(f=f.max(o.maxLength)),o.pattern&&(f=f.regex(new RegExp(o.pattern))),g=f;break}case"number":case"integer":{let f=d==="integer"?jr.number().int():jr.number();typeof o.minimum=="number"&&(f=f.min(o.minimum)),typeof o.maximum=="number"&&(f=f.max(o.maximum)),typeof o.exclusiveMinimum=="number"?f=f.gt(o.exclusiveMinimum):o.exclusiveMinimum===!0&&typeof o.minimum=="number"&&(f=f.gt(o.minimum)),typeof o.exclusiveMaximum=="number"?f=f.lt(o.exclusiveMaximum):o.exclusiveMaximum===!0&&typeof o.maximum=="number"&&(f=f.lt(o.maximum)),typeof o.multipleOf=="number"&&(f=f.multipleOf(o.multipleOf)),g=f;break}case"boolean":{g=jr.boolean();break}case"null":{g=jr.null();break}case"object":{let f={},b=o.properties||{},v=new Set(o.required||[]);for(let[T,N]of Object.entries(b)){let j=Tg(N,c);f[T]=v.has(T)?j:j.optional()}if(o.propertyNames){let T=Tg(o.propertyNames,c),N=o.additionalProperties&&typeof o.additionalProperties=="object"?Tg(o.additionalProperties,c):jr.any();if(Object.keys(f).length===0){g=jr.record(T,N);break}let j=jr.object(f).passthrough(),B=jr.looseRecord(T,N);g=jr.intersection(j,B);break}if(o.patternProperties){let T=o.patternProperties,N=Object.keys(T),j=[];for(let G of N){let K=Tg(T[G],c),de=jr.string().regex(new RegExp(G));j.push(jr.looseRecord(de,K))}let B=[];if(Object.keys(f).length>0&&B.push(jr.object(f).passthrough()),B.push(...j),B.length===0)g=jr.object({}).passthrough();else if(B.length===1)g=B[0];else{let G=jr.intersection(B[0],B[1]);for(let K=2;K<B.length;K++)G=jr.intersection(G,B[K]);g=G}break}let k=jr.object(f);o.additionalProperties===!1?g=k.strict():typeof o.additionalProperties=="object"?g=k.catchall(Tg(o.additionalProperties,c)):g=k.passthrough();break}case"array":{let f=o.prefixItems,b=o.items;if(f&&Array.isArray(f)){let v=f.map(T=>Tg(T,c)),k=b&&typeof b=="object"&&!Array.isArray(b)?Tg(b,c):void 0;k?g=jr.tuple(v).rest(k):g=jr.tuple(v),typeof o.minItems=="number"&&(g=g.check(jr.minLength(o.minItems))),typeof o.maxItems=="number"&&(g=g.check(jr.maxLength(o.maxItems)))}else if(Array.isArray(b)){let v=b.map(T=>Tg(T,c)),k=o.additionalItems&&typeof o.additionalItems=="object"?Tg(o.additionalItems,c):void 0;k?g=jr.tuple(v).rest(k):g=jr.tuple(v),typeof o.minItems=="number"&&(g=g.check(jr.minLength(o.minItems))),typeof o.maxItems=="number"&&(g=g.check(jr.maxLength(o.maxItems)))}else if(b!==void 0){let v=Tg(b,c),k=jr.array(v);typeof o.minItems=="number"&&(k=k.min(o.minItems)),typeof o.maxItems=="number"&&(k=k.max(o.maxItems)),g=k}else g=jr.array(jr.any());break}default:throw new Error(`Unsupported type: ${d}`)}return o.description&&(g=g.describe(o.description)),o.default!==void 0&&(g=g.default(o.default)),g}function Tg(o,c){if(typeof o=="boolean")return o?jr.any():jr.never();let d=arn(o,c),g=o.type||o.enum!==void 0||o.const!==void 0;if(o.anyOf&&Array.isArray(o.anyOf)){let k=o.anyOf.map(N=>Tg(N,c)),T=jr.union(k);d=g?jr.intersection(d,T):T}if(o.oneOf&&Array.isArray(o.oneOf)){let k=o.oneOf.map(N=>Tg(N,c)),T=jr.xor(k);d=g?jr.intersection(d,T):T}if(o.allOf&&Array.isArray(o.allOf))if(o.allOf.length===0)d=g?d:jr.any();else{let k=g?d:Tg(o.allOf[0],c),T=g?0:1;for(let N=T;N<o.allOf.length;N++)k=jr.intersection(k,Tg(o.allOf[N],c));d=k}o.nullable===!0&&c.version==="openapi-3.0"&&(d=jr.nullable(d)),o.readOnly===!0&&(d=jr.readonly(d));let f={},b=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let k of b)k in o&&(f[k]=o[k]);let v=["contentEncoding","contentMediaType","contentSchema"];for(let k of v)k in o&&(f[k]=o[k]);for(let k of Object.keys(o))WHn.has(k)||(f[k]=o[k]);return Object.keys(f).length>0&&c.registry.add(d,f),d}function srn(o,c){if(typeof o=="boolean")return o?jr.any():jr.never();let d=JHn(o,c?.defaultTarget),g=o.$defs||o.definitions||{},f={version:d,defs:g,refs:new Map,processing:new Set,rootSchema:o,registry:c?.registry??Ip};return Tg(o,f)}var Vht={};Bx(Vht,{bigint:()=>QHn,boolean:()=>YHn,date:()=>e$n,number:()=>KHn,string:()=>XHn});function XHn(o){return ylt(kq,o)}function KHn(o){return Slt(xq,o)}function YHn(o){return Alt(Sq,o)}function QHn(o){return Nlt(_q,o)}function e$n(o){return qlt(pee,o)}fd(V0e());var Wht=["service","function","worker","agent","database","cache","vectordb","storage","queue","topic","stream","gateway","cdn","route","interface","adapter","port","llm","prompt","tool","auth","observability","cloud","frontend","external","human","page","component","store","hook","module","custom"],urn=jt.enum(Wht),t$n=new Set(["service","function","worker","module","page","component","store","hook"]);function cpe(o){return t$n.has(o)}var Jht=["http_call","grpc","invokes","routes_to","websocket","webhook","reads","writes","publishes","subscribes","streams_to","implements","extends","depends_on","has_a","uses"],lrn=jt.enum(Jht);var g3=jt.enum(["proposed","active","deprecated"]),n$n=jt.enum(["boundary","control","entity"]),r$n=jt.string().min(1).refine(o=>!o.startsWith("/"),{message:"sourcePath must be a relative path (no leading /)"}).refine(o=>!o.includes("\\"),{message:"sourcePath must use forward slashes"}).refine(o=>!o.split("/").some(c=>c===".."),{message:"sourcePath must not contain `..` segments"}),i$n=/^[a-z][a-z0-9-]*$/,$l=jt.string().regex(i$n,"id must match /^[a-z][a-z0-9-]*$/"),Zht=jt.string().min(1).refine(o=>!o.startsWith("/")&&!/^[a-zA-Z]:[\\/]/.test(o),{message:"archikFile must be a relative path"}).refine(o=>!o.includes("\\"),{message:"archikFile must use forward slashes"}).refine(o=>!o.split("/").some(c=>c==="..")&&!o.includes("./../"),{message:"archikFile must not contain `..` segments"}).refine(o=>o.endsWith(".archik.yaml"),{message:"archikFile must end in `.archik.yaml`"}),vee=jt.string().min(1).refine(o=>!o.startsWith("/")&&!/^[a-zA-Z]:[\\/]/.test(o),{message:"seqFile must be a relative path"}).refine(o=>!o.includes("\\"),{message:"seqFile must use forward slashes"}).refine(o=>!o.split("/").some(c=>c===".."),{message:"seqFile must not contain `..` segments"}).refine(o=>o.endsWith(".archik.seq.yaml"),{message:"seqFile must end in `.archik.seq.yaml`"}),o$n=jt.strictObject({name:jt.string().min(1),protocol:jt.string().min(1),description:jt.string().optional()}),c$n=jt.strictObject({id:$l,kind:urn,name:jt.string().min(1),description:jt.string().min(1).optional(),stack:jt.string().optional(),responsibilities:jt.array(jt.string().min(1)).optional(),interfaces:jt.array(o$n).optional(),notes:jt.array(jt.string()).optional(),parentId:$l.optional(),archikFile:Zht.optional(),seqFiles:jt.array(vee).min(1).optional(),sourcePath:r$n.optional(),status:g3.optional(),stereotype:n$n.optional(),metadata:jt.record(jt.string(),jt.unknown()).optional()}),a$n=jt.strictObject({id:$l,from:$l,to:$l,relationship:lrn,label:jt.string().optional(),description:jt.string().optional(),protocol:jt.string().optional(),color:jt.string().optional(),status:g3.optional(),fromFile:Zht.optional(),toFile:Zht.optional()}),s$n=jt.strictObject({from:jt.string().min(1),at:jt.string().min(1),note:jt.string().optional()}),u$n=jt.strictObject({createdAt:jt.string().min(1).optional(),updatedAt:jt.string().min(1).optional(),suggestion:s$n.optional()}),hrn=jt.strictObject({version:jt.literal("1.0"),name:jt.string().min(1),description:jt.string().optional(),nodes:jt.array(c$n),edges:jt.array(a$n),metadata:u$n.optional()}).superRefine((o,c)=>{let d=new Set;for(let k=0;k<o.nodes.length;k++){let T=o.nodes[k];d.has(T.id)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["nodes",k,"id"],message:`duplicate node id "${T.id}"`}),d.add(T.id),(T.description===void 0||T.description.length===0)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["nodes",k,"description"],message:`node "${T.id}" is missing required \`description\`. Every node must explain what it does (its responsibility / behaviour) \u2014 not just restate its kind or name.`})}let g=new Set;for(let k=0;k<o.edges.length;k++){let T=o.edges[k];g.has(T.id)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["edges",k,"id"],message:`duplicate edge id "${T.id}"`}),g.add(T.id),T.fromFile===void 0&&!d.has(T.from)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["edges",k,"from"],message:`edge "${T.id}" references unknown node "${T.from}"`}),T.toFile===void 0&&!d.has(T.to)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["edges",k,"to"],message:`edge "${T.id}" references unknown node "${T.to}"`}),T.fromFile!==void 0&&T.toFile!==void 0&&c.addIssue({code:jt.ZodIssueCode.custom,path:["edges",k],message:`edge "${T.id}" has both fromFile and toFile \u2014 at least one endpoint must be local to this file`}),T.from===T.to&&T.fromFile===void 0&&T.toFile===void 0&&c.addIssue({code:jt.ZodIssueCode.custom,path:["edges",k],message:`edge "${T.id}" is a self-loop (from === to). Self-loops aren't meaningful in an architecture diagram.`})}let f=new Map;for(let k of o.nodes)f.set(k.id,k.parentId);for(let k=0;k<o.nodes.length;k++){let T=o.nodes[k];if(T.parentId===void 0)continue;if(T.parentId===T.id){c.addIssue({code:jt.ZodIssueCode.custom,path:["nodes",k,"parentId"],message:`node "${T.id}" lists itself as parentId`});continue}if(!d.has(T.parentId)){c.addIssue({code:jt.ZodIssueCode.custom,path:["nodes",k,"parentId"],message:`node "${T.id}" parentId "${T.parentId}" doesn't match any node`});continue}let N=new Set([T.id]),j=T.parentId,B=0;for(;j!==void 0&&B<=o.nodes.length;){if(N.has(j)){c.addIssue({code:jt.ZodIssueCode.custom,path:["nodes",k,"parentId"],message:`node "${T.id}" is part of a parentId cycle (via "${j}")`});break}N.add(j),j=f.get(j),B++}}function b(k,T){let N=f.get(T),j=0;for(;N!==void 0&&j<=o.nodes.length;){if(N===k)return!0;N=f.get(N),j++}return!1}for(let k=0;k<o.edges.length;k++){let T=o.edges[k];T.fromFile!==void 0||T.toFile!==void 0||!d.has(T.from)||!d.has(T.to)||(b(T.from,T.to)||b(T.to,T.from))&&c.addIssue({code:jt.ZodIssueCode.custom,path:["edges",k],message:`edge "${T.id}" connects "${T.from}" and "${T.to}" but one is an ancestor of the other \u2014 the parent already contains the child, so an edge between them is a duplicate. Either remove the edge or change the parentId.`})}let v=new Map;for(let k=0;k<o.edges.length;k++){let T=o.edges[k];if(T.fromFile!==void 0||T.toFile!==void 0)continue;let N=`${T.from}\0${T.to}\0${T.relationship}`,j=v.get(N);if(j!==void 0){c.addIssue({code:jt.ZodIssueCode.custom,path:["edges",k],message:`edge "${T.id}" duplicates "${j}" \u2014 same from/to/relationship (${T.from} \u2192 ${T.to} via ${T.relationship}). The diagram already expresses this connection; remove one of them.`});continue}v.set(N,T.id)}});function Cq(o,c,d){let g=[],f=new Map;for(let b of o.nodes)b.sourcePath!==void 0&&b.sourcePath.length>0&&f.set(b.id,b.sourcePath);return o.nodes.forEach((b,v)=>{if(!cpe(b.kind))return;let k=b.status==="proposed"||b.status==="deprecated";if(b.sourcePath===void 0||b.sourcePath.length===0){if(k)return;g.push({path:`nodes.${v}.sourcePath`,message:`node "${b.id}" (kind: ${b.kind}) is missing required \`sourcePath\`. Code-bearing kinds must declare where their source lives. Either add a sourcePath, or mark the node \`status: proposed\` if the code isn't built yet (proposed/deprecated nodes are exempt).`});return}if(!d(b.sourcePath)){g.push({path:`nodes.${v}.sourcePath`,message:`node "${b.id}" sourcePath "${b.sourcePath}" does not exist on disk (resolved relative to the project root). Either fix the path, drop it (if status is proposed/deprecated, sourcePath is optional), or change the node's status to proposed.`});return}if(b.parentId!==void 0){let T=f.get(b.parentId);T!==void 0&&h$n(T)&&!l$n(b.sourcePath,T)&&g.push({path:`nodes.${v}.sourcePath`,message:`node "${b.id}" sourcePath "${b.sourcePath}" is not inside its parent's sourcePath "${T}". The diagram says "${b.id}" lives inside "${b.parentId}", but the source tree disagrees. Either fix the path, change the parentId, or drop one of the sourcePaths.`})}}),g}function l$n(o,c){let d=o.replace(/\/+$/,""),g=c.replace(/\/+$/,"");return d===g?!0:d.startsWith(g+"/")}function h$n(o){let c=o.split("/").pop()??"";return!/\.[^./]+$/.test(c)}function Iq(o,c){let d=[];return o.nodes.forEach((g,f)=>{g.archikFile!==void 0&&(c(g.archikFile)||d.push({path:`nodes.${f}.archikFile`,message:`archikFile "${g.archikFile}" does not exist (resolved relative to the project root)`}))}),o.edges.forEach((g,f)=>{g.fromFile!==void 0&&!c(g.fromFile)&&d.push({path:`edges.${f}.fromFile`,message:`fromFile "${g.fromFile}" does not exist (resolved relative to the project root)`}),g.toFile!==void 0&&!c(g.toFile)&&d.push({path:`edges.${f}.toFile`,message:`toFile "${g.toFile}" does not exist (resolved relative to the project root)`})}),d}function frn(o,c){let d=[];return o.nodes.forEach((g,f)=>{g.seqFiles&&g.seqFiles.forEach((b,v)=>{c(b)||d.push({path:`nodes.${f}.seqFiles.${v}`,message:`seqFile "${b}" does not exist on disk (resolved relative to the project root)`})})}),d}function drn(o){return o.length===0?"<root>":o.map(String).join(".")}function d$n(o,c){let d=o[o.length-1],g=/expected array/i.test(c)&&/received\s+string/i.test(c),f=/received\s+undefined/i.test(c)||/required/i.test(c);return g&&(d==="notes"||d==="responsibilities"||d==="interfaces")?`${String(d)} is an array \u2014 wrap your value, e.g. ${String(d)}: ['first', 'second']. Run \`npx archik schema\` for the full shape.`:f&&d==="id"&&o.length>=2&&o[o.length-3]==="edges"?"every edge requires an `id` (kebab-case, unique within the document), e.g. id: api-writes-db. Run `npx archik schema` for the full Edge shape.":null}function f$n(o){return o.issues.flatMap(c=>{if(c.code==="unrecognized_keys")return c.keys.map(f=>({path:drn([...c.path,f]),message:"unrecognized key"}));let d=d$n(c.path,c.message),g=d===null?c.message:`${c.message}
502
502
  hint: ${d}`;return[{path:drn(c.path),message:g}]})}function dL(o){let c=hrn.safeParse(o);return c.success?{ok:!0,value:c.data}:{ok:!1,errors:f$n(c.error)}}function Ag(o){return o.map(c=>` \u2022 ${c.path}: ${c.message}`).join(`
503
503
  `)}import{readFile as p$n,readdir as g$n}from"node:fs/promises";import Mee from"node:path";var Xht=Ai(Gx(),1);function P2(o){let c;try{c=Xht.default.parse(o)}catch(g){let f=g instanceof Error?g.message:String(g);throw new Error(`Invalid YAML: ${f}`)}let d=dL(c);if(!d.ok)throw new Error(`Invalid Archik document:
504
- ${Ag(d.errors)}`);return d.value}function kee(o){return Xht.default.stringify(o,{indent:2,lineWidth:0})}var y$n=6;function Kht(o,c){return Mee.relative(o,c).split(Mee.sep).join("/")||Mee.basename(c)}function b$n(o){return o.endsWith(".archik.yaml")&&!o.endsWith(".archik.suggested.yaml")}async function z0(o,c){let d=[],g=[],f=new Set,b=async k=>{if(f.has(k))return;f.add(k);let T;try{T=await p$n(k,"utf-8")}catch(N){g.push({abs:k,relPath:Kht(c,k),message:N instanceof Error?N.message:String(N)});return}try{let N=P2(T);d.push({abs:k,relPath:Kht(c,k),doc:N})}catch(N){g.push({abs:k,relPath:Kht(c,k),message:N instanceof Error?N.message:String(N)})}};await b(o);let v=async(k,T)=>{if(T>y$n)return;let N;try{N=await g$n(k,{withFileTypes:!0})}catch{return}for(let j of N){let B=Mee.join(k,j.name);if(j.isDirectory()){await v(B,T+1);continue}j.isFile()&&b$n(j.name)&&await b(B)}};return await v(Mee.join(c,".archik"),0),{docs:d,errors:g}}var yrn=Ai(Gx(),1);import{readFile as I$n,readdir as L$n}from"node:fs/promises";import See from"node:path";var w$n=jt.enum(["sync","async","return","create","destroy"]),m$n=jt.enum(["over","left_of","right_of"]),v$n=jt.enum(["alt","opt","loop","par","break","ref"]),k$n=jt.strictObject({id:$l,nodeId:$l,label:jt.string().min(1).optional(),status:g3.optional()}),M$n=jt.strictObject({type:jt.literal("message"),id:$l,from:$l,to:$l,label:jt.string().min(1),arrow:w$n,activate:jt.boolean().optional(),status:g3.optional()}),x$n=jt.strictObject({type:jt.literal("note"),id:$l,position:m$n,participants:jt.array($l).min(1),text:jt.string().min(1),status:g3.optional()}),S$n=jt.lazy(()=>jt.strictObject({label:jt.string().optional(),steps:jt.array(prn)})),_$n=jt.lazy(()=>jt.strictObject({type:jt.literal("group"),id:$l,kind:v$n,condition:jt.string().optional(),label:jt.string().optional(),branches:jt.array(S$n).optional(),seqFile:vee.optional(),participants:jt.array($l).optional(),status:g3.optional()})),prn=jt.lazy(()=>jt.union([M$n,x$n,_$n]));function grn(o,c){let d=[];for(let g of o)if(c.has(g.id)?d.push(g.id):c.add(g.id),g.type==="group"&&g.branches)for(let f of g.branches)d.push(...grn(f.steps,c));return d}var C$n=jt.strictObject({useCase:$l,slice:$l}),xee=jt.strictObject({version:jt.literal("1.0"),name:jt.string().min(1),description:jt.string().optional(),realizes:C$n.optional(),participants:jt.array(k$n).min(1),steps:jt.array(prn)}).superRefine((o,c)=>{let d=new Set;for(let b=0;b<o.participants.length;b++){let v=o.participants[b];d.has(v.id)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["participants",b,"id"],message:`duplicate participant id "${v.id}"`}),d.add(v.id)}let g=new Set,f=grn(o.steps,g);for(let b of f)c.addIssue({code:jt.ZodIssueCode.custom,path:["steps"],message:`duplicate step id "${b}"`})});var E$n=6;function T$n(o,c){return See.relative(o,c).split(See.sep).join("/")||See.basename(c)}async function J5(o){let c=[],d=[],g=async b=>{let v=T$n(o,b),k;try{k=await I$n(b,"utf-8")}catch(T){d.push({abs:b,relPath:v,message:T instanceof Error?T.message:String(T)});return}try{let T=yrn.default.parse(k),N=xee.safeParse(T);if(!N.success){d.push({abs:b,relPath:v,message:N.error.issues.map(j=>j.message).join("; ")});return}c.push({abs:b,relPath:v,doc:N.data})}catch(T){d.push({abs:b,relPath:v,message:T instanceof Error?T.message:String(T)})}},f=async(b,v)=>{if(v>E$n)return;let k;try{k=await L$n(b,{withFileTypes:!0})}catch{return}for(let T of k){let N=See.join(b,T.name);if(T.isDirectory()){await f(N,v+1);continue}T.isFile()&&T.name.endsWith(".archik.seq.yaml")&&await g(N)}};return await f(See.join(o,".archik"),0),{docs:c,errors:d}}var wrn=Ai(Gx(),1);import{readFile as j$n,readdir as B$n}from"node:fs/promises";import _ee from"node:path";var A$n=jt.string().min(1).refine(o=>!o.startsWith("/")&&!/^[a-zA-Z]:[\\/]/.test(o),{message:"test path must be relative (no leading / or drive letter)"}).refine(o=>!o.includes("\\"),{message:"test path must use forward slashes"}).refine(o=>!o.split("/").some(c=>c===".."),{message:"test path must not contain `..` segments"}),P$n=/^[a-z][a-z0-9-]*\.\d+$/,N$n=jt.string().regex(P$n,"branchFrom must be `<flowId>.<stepNumber>` (e.g. basic.3)"),R$n=jt.strictObject({steps:jt.array(jt.string().min(1)).min(1)}),D$n=jt.strictObject({id:$l,branchFrom:N$n,steps:jt.array(jt.string().min(1)).min(1)}),O$n=jt.strictObject({basic:R$n,alternates:jt.array(D$n).optional()}),F$n=jt.strictObject({seqFile:vee}),z$n=jt.strictObject({id:$l,description:jt.string().min(1),flows:jt.array($l).min(1),tests:jt.array(A$n).optional(),realization:F$n.optional(),status:g3.optional()}),brn=jt.strictObject({version:jt.literal("1.0"),id:$l,name:jt.string().min(1),description:jt.string().optional(),status:g3.optional(),primaryActor:$l,secondaryActors:jt.array($l).optional(),goal:jt.string().min(1),preconditions:jt.array(jt.string().min(1)).optional(),postconditions:jt.array(jt.string().min(1)).optional(),flows:O$n,slices:jt.array(z$n).min(1)}).superRefine((o,c)=>{let d=new Map;d.set("basic",o.flows.basic.steps.length);let g=new Set;o.flows.alternates&&(o.flows.alternates.forEach((b,v)=>{b.id==="basic"&&c.addIssue({code:jt.ZodIssueCode.custom,path:["flows","alternates",v,"id"],message:'alternate id "basic" collides with the basic flow'}),g.has(b.id)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["flows","alternates",v,"id"],message:`duplicate alternate flow id "${b.id}"`}),g.add(b.id),d.set(b.id,b.steps.length)}),o.flows.alternates.forEach((b,v)=>{let[k,T]=b.branchFrom.split("."),N=Number(T),j=d.get(k);if(j===void 0){c.addIssue({code:jt.ZodIssueCode.custom,path:["flows","alternates",v,"branchFrom"],message:`branchFrom "${b.branchFrom}" references unknown flow "${k}"`});return}(N<1||N>j)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["flows","alternates",v,"branchFrom"],message:`branchFrom "${b.branchFrom}" step ${N} is out of range (flow "${k}" has ${j} step(s))`})}));let f=new Set;o.slices.forEach((b,v)=>{f.has(b.id)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["slices",v,"id"],message:`duplicate slice id "${b.id}"`}),f.add(b.id),b.flows.forEach((T,N)=>{d.has(T)||c.addIssue({code:jt.ZodIssueCode.custom,path:["slices",v,"flows",N],message:`slice "${b.id}" references unknown flow "${T}". Available: ${Array.from(d.keys()).join(", ")}.`})}),b.flows.includes("basic")||c.addIssue({code:jt.ZodIssueCode.custom,path:["slices",v,"flows"],message:`slice "${b.id}" does not include the basic flow. Slices must include "basic" plus zero or more alternates that branch off it; otherwise the alternate has no prefix to branch from.`}),!(b.status==="proposed"||b.status==="deprecated")&&(b.tests===void 0||b.tests.length===0)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["slices",v,"tests"],message:`slice "${b.id}" has no tests. Active slices must declare at least one test path (each must exist on disk). Mark the slice \`status: proposed\` if the test isn't written yet.`})})});var H$n=6;function $$n(o,c){return _ee.relative(o,c).split(_ee.sep).join("/")||_ee.basename(c)}function U$n(o){return o.endsWith(".archik.uc.yaml")}async function Zy(o){let c=[],d=[],g=async b=>{let v=$$n(o,b),k;try{k=await j$n(b,"utf-8")}catch(j){d.push({abs:b,relPath:v,message:j instanceof Error?j.message:String(j)});return}let T;try{T=wrn.default.parse(k)}catch(j){d.push({abs:b,relPath:v,message:j instanceof Error?j.message:String(j)});return}let N=brn.safeParse(T);if(!N.success){d.push({abs:b,relPath:v,message:N.error.issues.map(j=>j.message).join("; ")});return}c.push({abs:b,relPath:v,doc:N.data})},f=async(b,v)=>{if(v>H$n)return;let k;try{k=await B$n(b,{withFileTypes:!0})}catch{return}for(let T of k){let N=_ee.join(b,T.name);if(T.isDirectory()){await f(N,v+1);continue}T.isFile()&&U$n(T.name)&&await g(N)}};return await f(_ee.join(o,".archik","usecases"),0),{docs:c,errors:d}}var vrn=Ai(Gx(),1);import{readFile as V$n,readdir as W$n}from"node:fs/promises";import Cee from"node:path";var q$n=jt.enum(["human","external-system","time","device"]),G$n=jt.strictObject({id:$l,kind:q$n,description:jt.string().min(1),goals:jt.array(jt.string().min(1)).optional(),status:g3.optional()}),mrn=jt.strictObject({version:jt.literal("1.0"),description:jt.string().optional(),actors:jt.array(G$n).min(1)}).superRefine((o,c)=>{let d=new Set;o.actors.forEach((g,f)=>{d.has(g.id)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["actors",f,"id"],message:`duplicate actor id "${g.id}"`}),d.add(g.id)})});var J$n=6;function Z$n(o,c){return Cee.relative(o,c).split(Cee.sep).join("/")||Cee.basename(c)}function X$n(o){return o.endsWith(".archik.actors.yaml")}async function Zx(o){let c=[],d=[],g=async b=>{let v=Z$n(o,b),k;try{k=await V$n(b,"utf-8")}catch(j){d.push({abs:b,relPath:v,message:j instanceof Error?j.message:String(j)});return}let T;try{T=vrn.default.parse(k)}catch(j){d.push({abs:b,relPath:v,message:j instanceof Error?j.message:String(j)});return}let N=mrn.safeParse(T);if(!N.success){d.push({abs:b,relPath:v,message:N.error.issues.map(j=>j.message).join("; ")});return}c.push({abs:b,relPath:v,doc:N.data})},f=async(b,v)=>{if(v>J$n)return;let k;try{k=await W$n(b,{withFileTypes:!0})}catch{return}for(let T of k){let N=Cee.join(b,T.name);if(T.isDirectory()){await f(N,v+1);continue}T.isFile()&&X$n(T.name)&&await g(N)}};return await f(Cee.join(o,".archik"),0),{docs:c,errors:d}}function krn(o,c,d,g){o.forEach((f,b)=>{let v=`${g}.${b}`;f.type==="message"?(c.has(f.from)||d.push({path:`${v}.from`,message:`participant "${f.from}" is not declared in participants`}),c.has(f.to)||d.push({path:`${v}.to`,message:`participant "${f.to}" is not declared in participants`})):f.type==="note"?f.participants.forEach((k,T)=>{c.has(k)||d.push({path:`${v}.participants.${T}`,message:`participant "${k}" is not declared in participants`})}):f.type==="group"&&f.branches&&f.branches.forEach((k,T)=>{krn(k.steps,c,d,`${v}.branches.${T}.steps`)})})}function Mrn(o,c){let d=[],g=new Set;return o.participants.forEach((f,b)=>{g.add(f.id),c.has(f.nodeId)||d.push({path:`participants.${b}.nodeId`,message:`nodeId "${f.nodeId}" does not match any architecture node. Run \`npx archik q list\` to see available node ids.`})}),krn(o.steps,g,d,"steps"),d}var K$n={boundary:new Set(["control"]),control:new Set(["boundary","control","entity"]),entity:new Set(["control","entity"])};function xrn(o,c,d,g,f,b){o.forEach((v,k)=>{let T=`${f}.${k}`;if(v.type==="message"){let N=c.get(v.from),j=c.get(v.to);if(N===void 0||j===void 0)return;let B=K$n[N];B&&!B.has(j)&&b.push({path:`${d}:${T}`,message:`ECB violation in seq "${g}" message "${v.id}": ${N} \u2192 ${j} is forbidden by the robustness rules (boundaries don't talk to boundaries or entities; entities don't talk to boundaries). Insert a control between them, or revisit the stereotype assignment.`})}else v.type==="group"&&v.branches&&v.branches.forEach((N,j)=>{xrn(N.steps,c,d,g,`${T}.branches.${j}.steps`,b)})})}function Srn(o,c){let d=[],g=new Map;for(let{doc:f}of c)for(let b of f.nodes)b.stereotype!==void 0&&g.set(b.id,b.stereotype);for(let f of o){if(f.doc.realizes===void 0)continue;let b=new Map;for(let v of f.doc.participants){let k=g.get(v.nodeId);k!==void 0&&b.set(v.id,k)}xrn(f.doc.steps,b,f.relPath,f.doc.name,"steps",d)}return d}function _rn(o,c){let d=[],g=new Map;for(let{doc:f}of c)for(let b of f.nodes){let v=g.get(b.id)??new Set;for(let k of b.seqFiles??[])v.add(k);g.set(b.id,v)}for(let f of o){if(f.doc.realizes===void 0)continue;let b=new Set;for(let v of f.doc.participants){if(b.has(v.nodeId))continue;let k=g.get(v.nodeId);k!==void 0&&(k.has(f.relPath)||(b.add(v.nodeId),d.push({path:`${f.relPath}:participants.${v.id}`,message:`seq "${f.doc.name}" lists node "${v.nodeId}" as a participant, but that node's \`seqFiles\` array does not reference this diagram. Add "${f.relPath}" to node "${v.nodeId}"'s \`seqFiles\` array via \`npx archik suggest set\` so the canvas can surface the flow on that node.`})))}}return d}function Crn(o,c){let d=[],g=new Map(c.map(f=>[f.doc.id,f]));for(let f of o){if(f.doc.realizes===void 0)continue;let{useCase:b,slice:v}=f.doc.realizes,k=g.get(b);if(k===void 0){d.push({path:`${f.relPath}:realizes.useCase`,message:`seq diagram "${f.doc.name}" claims to realize use case "${b}" but no such use case file was found.`});continue}let T=k.doc.slices.find(N=>N.id===v);if(T===void 0){d.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" claims to realize slice "${v}" of use case "${b}", but that use case has no slice with that id. Available slices: ${k.doc.slices.map(N=>N.id).join(", ")}.`});continue}if(T.realization===void 0){d.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" realizes slice "${v}" of "${b}", but the slice does not declare \`realization.seqFile\`. Add \`realization: { seqFile: "${f.relPath}" }\` to slice "${v}" in ${k.relPath}.`});continue}T.realization.seqFile!==f.relPath&&d.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" realizes slice "${v}" of "${b}", but that slice's realization.seqFile points at "${T.realization.seqFile}", not at this file ("${f.relPath}"). Pick one canonical seq file and update both sides.`})}return d}function Irn(o){let c=new Map,d=[];for(let{relPath:g,doc:f}of o)for(let b of f.actors){let v=c.get(b.id);if(v!==void 0){d.push({path:g,message:`actor id "${b.id}" is duplicated across actor files (also defined in ${v.relPath})`});continue}c.set(b.id,{relPath:g})}return{index:c,errors:d}}function Lrn(o){let c=new Map,d=[];for(let{relPath:g,doc:f}of o){let b=c.get(f.id);if(b!==void 0){d.push({path:g,message:`use case id "${f.id}" is duplicated across files (also defined in ${b.relPath})`});continue}c.set(f.id,{relPath:g})}return{index:c,errors:d}}function Ern(o,c){let d=[];for(let{relPath:g,doc:f}of o)c.has(f.primaryActor)||d.push({path:`${g}:primaryActor`,message:`use case "${f.id}" references unknown primaryActor "${f.primaryActor}". Define it in a *.archik.actors.yaml file.`}),f.secondaryActors&&f.secondaryActors.forEach((b,v)=>{c.has(b)||d.push({path:`${g}:secondaryActors.${v}`,message:`use case "${f.id}" references unknown secondary actor "${b}". Define it in a *.archik.actors.yaml file.`})});return d}function Trn(o,c){let d=[];for(let{relPath:g,doc:f}of o)f.slices.forEach((b,v)=>{b.status==="proposed"||b.status==="deprecated"||b.tests!==void 0&&b.tests.forEach((T,N)=>{c(T)||d.push({path:`${g}:slices.${v}.tests.${N}`,message:`slice "${b.id}" test "${T}" does not exist on disk (resolved relative to project root). Either fix the path or mark the slice \`status: proposed\`.`})})});return d}function Arn(o,c){let d=[],g=new Map(c.map(f=>[f.relPath,f]));for(let{relPath:f,doc:b}of o)b.slices.forEach((v,k)=>{if(v.realization===void 0)return;let T=g.get(v.realization.seqFile);if(T===void 0){d.push({path:`${f}:slices.${k}.realization.seqFile`,message:`slice "${v.id}" realization seqFile "${v.realization.seqFile}" does not exist or did not parse. Run \`npx archik q sequences\` to see available seq files.`});return}if(T.doc.realizes===void 0){d.push({path:`${f}:slices.${k}.realization.seqFile`,message:`slice "${v.id}" claims realization "${v.realization.seqFile}", but that seq diagram has no \`realizes\` block. Add \`realizes: { useCase: "${b.id}", slice: "${v.id}" }\` to ${T.relPath}, or remove the realization claim.`});return}(T.doc.realizes.useCase!==b.id||T.doc.realizes.slice!==v.id)&&d.push({path:`${f}:slices.${k}.realization.seqFile`,message:`slice "${v.id}" claims realization "${v.realization.seqFile}", but that seq diagram's \`realizes\` points at "${T.doc.realizes.useCase}/${T.doc.realizes.slice}", not at "${b.id}/${v.id}". Pick one canonical link.`})});return d}import Iee from"node:path";function Xx(o){let c=Iee.dirname(o),d=Iee.basename(o),g=Iee.extname(d),f=g.length>0?d.slice(0,-g.length):d;return Iee.join(c,`${f}.suggested${g}`)}function Lq(o){return Iee.basename(o).endsWith(".archik.suggested.yaml")?"suggested":"normal"}function Prn(o){return o.metadata?.suggestion!==void 0}function ape(o){if(o.metadata?.suggestion===void 0)return o;let{suggestion:c,...d}=o.metadata,g={...o};return Object.keys(d).length===0?delete g.metadata:g.metadata=d,g}var eUn=o=>{let c=Xr(o,"json");return c!==void 0&&c!=="false"&&c!=="0"};function Z5(o){console.log(JSON.stringify(o,null,2))}async function Drn(o){let c=eUn(o),d;try{d=await Eu(o._[0])}catch(Le){let tn=Le instanceof Error?Le.message:String(Le);return c?Z5({ok:!1,errors:[{path:"<root>",message:tn}]}):console.error(`\u2717 ${tn}`),1}let g=Nrn.relative(process.cwd(),d)||d,f;try{f=await Q$n(d,"utf-8")}catch(Le){let tn=Le instanceof Error?Le.message:String(Le);return c?Z5({ok:!1,file:g,errors:[{path:"<root>",message:tn}]}):(console.error(`\u2717 Cannot read ${g}`),console.error(tn)),1}let b;try{b=Rrn.default.parse(f)}catch(Le){let Jt=[{path:"<root>",message:`Invalid YAML: ${Le instanceof Error?Le.message:String(Le)}`}];return c?Z5({ok:!1,file:g,errors:Jt}):(console.error(`\u2717 ${g}`),console.error(Ag(Jt))),1}let v=dL(b);if(!v.ok)return c?Z5({ok:!1,file:g,errors:v.errors}):(console.error(`\u2717 ${g}`),console.error(Ag(v.errors))),1;let k=W1(d),T=Le=>Y$n(Nrn.resolve(k,Le)),N=Iq(v.value,T);if(N.length>0)return c?Z5({ok:!1,file:g,errors:N}):(console.error(`\u2717 ${g}`),console.error(Ag(N))),1;let j=Lq(d),B=Cq(v.value,j,T);if(B.length>0)return c?Z5({ok:!1,file:g,errors:B}):(console.error(`\u2717 ${g}`),console.error(Ag(B))),1;let G=await z0(d,k);if(G.errors.length>0){if(c)Z5({ok:!1,file:g,errors:G.errors.map(Le=>({path:Le.relPath,message:Le.message}))});else for(let Le of G.errors)console.error(`\u2717 ${Le.relPath}: ${Le.message}`);return 1}let K=new Set(G.docs.flatMap(Le=>Le.doc.nodes.map(tn=>tn.id))),de=[];for(let{doc:Le}of G.docs)de.push(...frn(Le,T));if(de.length>0){if(c)Z5({ok:!1,file:g,errors:de});else{console.error("\u2717 seqFiles path errors:");for(let Le of de)console.error(` \u2717 ${Le.path}: ${Le.message}`)}return 1}let ce=await J5(k),be=0;for(let Le of ce.errors)c||console.error(`\u2717 ${Le.relPath}: ${Le.message}`),be++;for(let{relPath:Le,doc:tn}of ce.docs){let Jt=Mrn(tn,K);if(Jt.length>0){if(!c){console.error(`\u2717 ${Le}`);for(let or of Jt)console.error(` \u2717 ${or.path}: ${or.message}`)}be+=Jt.length}}if(be>0)return c&&Z5({ok:!1,file:g,errors:[{path:"<seq>",message:`${be} sequence diagram error(s)`}]}),1;let Re=await Zy(k),at=await Zx(k),Mt=[];for(let Le of Re.errors)Mt.push({path:Le.relPath,message:Le.message});for(let Le of at.errors)Mt.push({path:Le.relPath,message:Le.message});if(Mt.length===0){let Le=Irn(at.docs);Mt.push(...Le.errors);let tn=Lrn(Re.docs);Mt.push(...tn.errors),Mt.length===0&&(Mt.push(...Ern(Re.docs,Le.index)),Mt.push(...Trn(Re.docs,T)),Mt.push(...Arn(Re.docs,ce.docs)),Mt.push(...Crn(ce.docs,Re.docs)),Mt.push(...Srn(ce.docs,G.docs)),Mt.push(..._rn(ce.docs,G.docs)))}if(Mt.length>0)return c?Z5({ok:!1,file:g,errors:Mt}):(console.error(`\u2717 ${g}`),console.error(Ag(Mt))),1;let Ce=at.docs.reduce((Le,tn)=>Le+tn.doc.actors.length,0),st=Re.docs.length;if(c)Z5({ok:!0,file:g,nodes:v.value.nodes.length,edges:v.value.edges.length,useCases:st,actors:Ce});else{let Le=G.docs.reduce((gn,Hr)=>gn+Hr.doc.nodes.length,0),tn=G.docs.reduce((gn,Hr)=>gn+Hr.doc.edges.length,0),Jt=G.docs.length,or=Jt>1?` (${Jt} files)`:"",Xn=st>0?`, ${st} use case${st===1?"":"s"}`:"",br=Ce>0?`, ${Ce} actor${Ce===1?"":"s"}`:"";console.log(`\u2713 ${g}${or} \u2014 ${Le} nodes, ${tn} edges${Xn}${br}`)}return 0}var Wft=Ai(y3(),1),Jft=Ai(Mge(),1),Xan=Ai(Gx(),1);import{mkdir as Wan,readFile as Jan,writeFile as Zan}from"node:fs/promises";import eG from"node:path";var Gcn=Ai(Hcn(),1);function gte(o,c){return o.length*c}function Gf(o,c,d){if(c<=0)return"";let g=Math.floor(c/d);return o.length<=g?o:g<=1?"\u2026":o.slice(0,g-1)+"\u2026"}var yte={nodeSpacing:60,layerSpacing:100,padding:40,viewMode:"detailed"};function nWn(o){let c=o.nodeSpacing??yte.nodeSpacing,d=o.layerSpacing??yte.layerSpacing,g=o.padding??yte.padding;return{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.layered.spacing.nodeNodeBetweenLayers":String(d),"elk.spacing.nodeNode":String(c),"elk.padding":`[top=${g}, left=${g}, bottom=${g}, right=${g}]`,"elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.edgeLabels.placement":"CENTER","elk.spacing.edgeLabel":"8","elk.spacing.labelLabel":"6","elk.spacing.edgeNode":"20","elk.spacing.edgeEdge":"12","elk.layered.spacing.edgeEdgeBetweenLayers":"12"}}var Th={width:172,height:82},$cn={width:172,height:90},rWn={service:Th,function:Th,worker:Th,agent:Th,database:{width:184,height:100},cache:$cn,vectordb:Th,storage:Th,queue:{width:188,height:80},topic:Th,stream:Th,gateway:Th,cdn:Th,route:Th,interface:Th,adapter:Th,port:Th,llm:Th,prompt:Th,tool:Th,auth:Th,observability:Th,cloud:{width:200,height:120},frontend:$cn,page:Th,component:Th,store:Th,hook:Th,external:{width:184,height:100},human:{width:184,height:100},module:{width:240,height:130},custom:{width:240,height:130}},yl={width:152,height:36},Ucn={width:200,height:80},iWn={service:yl,function:yl,worker:yl,agent:yl,database:yl,cache:yl,vectordb:yl,storage:yl,queue:{width:168,height:36},topic:yl,stream:yl,gateway:yl,cdn:yl,route:yl,interface:yl,adapter:yl,port:yl,llm:yl,prompt:yl,tool:yl,auth:yl,observability:yl,cloud:yl,frontend:yl,page:yl,component:yl,store:yl,hook:yl,external:{width:168,height:40},human:{width:168,height:40},module:Ucn,custom:Ucn},oWn=24,qcn=320;function cWn(o,c,d){if(o.kind==="module"||o.kind==="custom")return c;if(d==="compact"){let k=36+gte(o.name,5.9)+12;return Math.max(c,Math.min(qcn,Math.ceil(k)))}let g=gte(o.name,7.4),f=o.stack!==void 0?gte(o.stack,5.9):0,b=Math.max(g,f)+oWn;return Math.max(c,Math.min(qcn,Math.ceil(b)))}var aWn={top:48,left:18,bottom:18,right:18};function sWn(o,c,d,g){let f=d[o.kind],b={id:o.id,width:cWn(o,f.width,g),height:f.height};if(c.length>0){b.children=c;let v=g==="compact"?{top:30,left:12,bottom:12,right:12}:aWn;b.layoutOptions={"elk.padding":`[top=${v.top}, left=${v.left}, bottom=${v.bottom}, right=${v.right}]`}}return b}function uWn(o,c,d){let g=new Map;for(let k of o.nodes)g.set(k.id,k);let f=new Map;for(let k of o.nodes){let T=f.get(k.parentId)??[];T.push(k),f.set(k.parentId,T)}function b(k){let T=(f.get(k.id)??[]).map(b);return sWn(k,T,c,d)}return{roots:(f.get(void 0)??[]).map(b),byId:g}}function lWn(o){return o.fromFile===void 0&&o.toFile===void 0}function hWn(o){return o.edges.filter(lWn).map(c=>{let d={id:c.id,sources:[c.from],targets:[c.to]};return c.label!==void 0&&c.label.length>0&&(d.labels=[{text:c.label,width:Math.ceil(gte(c.label,5.9)),height:14}]),d})}function zw(o){return o??0}function Vcn(o,c){let d=c.get(o.id);if(!d)throw new Error(`ELK returned unknown node id "${o.id}"`);let g=(o.children??[]).map(f=>Vcn(f,c));return{...d,x:zw(o.x),y:zw(o.y),width:zw(o.width),height:zw(o.height),children:g}}function dWn(o,c){let d=new Map,g=new Map,f=(N,j,B,G)=>{let K=j+zw(N.x),de=B+zw(N.y);d.set(N.id,{x:K,y:de}),g.set(N.id,G);let ce=[...G,N.id];for(let be of N.children??[])f(be,K,de,ce)};f(o,0,0,[]);let b=(N,j)=>{let B=g.get(N)??[],G=g.get(j)??[],K=0;for(;K<B.length&&K<G.length&&B[K]===G[K];)K++;let de=K===0?o.id:B[K-1];return d.get(de)??{x:0,y:0}},v=new Map,k=new Map,T=N=>{for(let j of N.edges??[]){let B=j.sources?.[0]??"",G=j.targets?.[0]??"",K=b(B,G),de=Re=>({x:zw(Re.x)+K.x,y:zw(Re.y)+K.y}),ce=(j.sections??[]).map(Re=>({startPoint:de(Re.startPoint),endPoint:de(Re.endPoint),bendPoints:(Re.bendPoints??[]).map(de)}));v.set(j.id,ce);let be=(j.labels??[]).map(Re=>({text:typeof Re.text=="string"?Re.text:"",x:zw(Re.x)+K.x,y:zw(Re.y)+K.y,width:zw(Re.width),height:zw(Re.height)}));k.set(j.id,be)}for(let j of N.children??[])T(j)};return T(o),c.edges.map(N=>({...N,sections:v.get(N.id)??[],labels:k.get(N.id)??[]}))}var fWn=new Gcn.default;async function pWn(o,c={}){if(o.nodes.length===0)return{document:o,width:0,height:0,roots:[],edges:[]};let d=c.viewMode==="compact"?"compact":"detailed",g=d==="compact"?iWn:rWn,{roots:f,byId:b}=uWn(o,g,d),v={id:"__root__",layoutOptions:nWn(c),children:f,edges:hWn(o)},k=await fWn.layout(v),T=(k.children??[]).map(N=>Vcn(N,b));return{document:o,width:zw(k.width),height:zw(k.height),roots:T,edges:dWn(k,o)}}var xge={name:"elk",layout:pWn};var nri={[xge.name]:xge},gWn=xge;function Xq(o,c){return gWn.layout(o,c)}var Sge="seq-arrow-filled",_ge="seq-arrow-open";function yWn(o){return Math.max(160,o.length*8+80)}function Wcn(o,c,d,g,f,b=0){let v=d,k=[],T=Number.POSITIVE_INFINITY,N=Number.NEGATIVE_INFINITY;for(let j of o)if(j.type==="message"){let B=c.get(j.from),G=c.get(j.to),K=B?.cx??g,de=G?.cx??g;k.push({type:"message",id:j.id,fromCx:K,toCx:de,y:v,label:j.label,arrow:j.arrow,activate:j.activate??!1,isSelf:j.from===j.to,...j.status!==void 0?{status:j.status}:{}}),v+=j.from===j.to?56*1.5:56}else if(j.type==="note"){let B=j.participants.map(be=>c.get(be)?.cx).filter(be=>be!==void 0).sort((be,Re)=>be-Re),G=B[0]??g,K=B[B.length-1]??f,de=Math.min(Math.max(j.text.length*7.5+24,K-G+16,80),400),ce;j.position==="left_of"?ce=G-de-8:j.position==="right_of"?ce=K+8:ce=(G+K)/2-de/2,T=Math.min(T,ce),N=Math.max(N,ce+de),k.push({type:"note",id:j.id,x:ce,y:v,width:de,height:64,text:j.text,...j.status!==void 0?{status:j.status}:{}}),v+=72}else if(j.type==="group"){let B=Math.min(b*6,12),G=g-12+B,K=f-g+24-B*2,de=v;v+=24;let ce=[];if(j.branches)for(let be=0;be<j.branches.length;be++){let Re=j.branches[be],at=v,{items:Mt,endY:Ce,contentMinX:st,contentMaxX:Le}=Wcn(Re.steps,c,v,g,f,b+1);v=Ce,T=Math.min(T,st),N=Math.max(N,Le),ce.push({...Re.label!==void 0?{label:Re.label}:{},startY:at,...be<j.branches.length-1?{dividerY:v}:{},steps:Mt}),be<j.branches.length-1&&(v+=4)}v+=12,k.push({type:"group",id:j.id,kind:j.kind,...j.condition!==void 0?{condition:j.condition}:{},...j.label!==void 0?{label:j.label}:{},...j.seqFile!==void 0?{seqFile:j.seqFile}:{},x:G,y:de,width:K,height:v-de,branches:ce,...j.status!==void 0?{status:j.status}:{}}),T=Math.min(T,G),N=Math.max(N,G+K),v+=8}return{items:k,endY:v,contentMinX:T,contentMaxX:N}}function Jcn(o){let c=new Map;for(let d of o)if(d.type==="message"&&d.arrow==="destroy"&&c.set(d.toCx,d.y+56+20),d.type==="group")for(let g of d.branches)for(let[f,b]of Jcn(g.steps))c.set(f,b);return c}function bWn(o){let c=[],d=new Map;function g(f){for(let b of f)if(b.type==="message"){if(b.activate&&b.arrow==="sync"&&!b.isSelf){let v=d.get(b.toCx)??[];v.push(b.y),d.set(b.toCx,v)}if(b.arrow==="return"&&!b.isSelf){let v=d.get(b.fromCx);if(v&&v.length>0){let k=v.pop();c.push({cx:b.fromCx,startY:k,endY:b.y}),v.length===0&&d.delete(b.fromCx)}}}else if(b.type==="group")for(let v of b.branches)g(v.steps)}g(o);for(let[f,b]of d)for(let v of b)c.push({cx:f,startY:v,endY:v+56/2});return c}function Zcn(o,c){let d=o.participants.map(tn=>yWn(tn.label??tn.nodeId)),g=32,f=o.participants.map((tn,Jt)=>{let or=d[Jt],Xn=g+or/2;g+=or;let br=c?.get(tn.nodeId);return{id:tn.id,nodeId:tn.nodeId,label:tn.label??tn.nodeId,cx:Xn,colWidth:or,...br!==void 0?{kind:br}:{},...tn.status!==void 0?{status:tn.status}:{},lifelineEndY:0}}),b=g+32,v=new Map(f.map(tn=>[tn.id,tn])),k=f[0]?.cx??32,T=f[f.length-1]?.cx??b-32,N=24,{items:j,endY:B,contentMinX:G,contentMaxX:K}=Wcn(o.steps,v,N,k,T),de=G<32&&Number.isFinite(G)?32-G:0,ce=Number.isFinite(K)?K+de+32:0,be=Math.max(b+de,ce),Re=de>0?j.map(tn=>Xcn(tn,de)):j,at=de>0?f.map(tn=>({...tn,cx:tn.cx+de})):f,Mt=Jcn(Re),Ce=at.map(tn=>({...tn,lifelineEndY:Mt.get(tn.cx)??56+B+24})),st=56+B+24,Le=bWn(Re);return{participants:Ce,steps:Re,activations:Le,totalWidth:be,totalHeight:st}}function Xcn(o,c){return o.type==="message"?{...o,fromCx:o.fromCx+c,toCx:o.toCx+c}:o.type==="note"?{...o,x:o.x+c}:{...o,x:o.x+c,branches:o.branches.map(d=>({...d,steps:d.steps.map(g=>Xcn(g,c))}))}}var Ci=Ai(Rft(),1);var M3=Ai(sc(),1),oan=(o,c,d)=>({width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:c,strokeWidth:d,strokeLinecap:"round",strokeLinejoin:"round"});function can({size:o=16,color:c="currentColor",strokeWidth:d=1.8}){return(0,M3.jsxs)("svg",{...oan(o,c,d),"aria-hidden":"true",children:[(0,M3.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3.5",ry:"3.5"}),(0,M3.jsx)("line",{x1:"9",y1:"9",x2:"9",y2:"13"}),(0,M3.jsx)("line",{x1:"15",y1:"9",x2:"15",y2:"13"}),(0,M3.jsx)("circle",{cx:"12",cy:"16.5",r:"1",fill:c,stroke:"none"})]})}function aan({size:o=16,color:c="currentColor",strokeWidth:d=1.8}){return(0,M3.jsxs)("svg",{...oan(o,c,d),"aria-hidden":"true",children:[(0,M3.jsx)("path",{d:"M 7.5 6 L 3.5 12 L 7.5 18"}),(0,M3.jsx)("path",{d:"M 16.5 6 L 20.5 12 L 16.5 18"}),(0,M3.jsx)("circle",{cx:"13",cy:"8.6",r:"0.9",fill:c,stroke:"none"}),(0,M3.jsx)("line",{x1:"13",y1:"11",x2:"11",y2:"16.5"})]})}var jw={service:{color:"#38bdf8",icon:Ci.Server,description:"Long-running compute that owns business logic."},function:{color:"#22d3ee",icon:Ci.FunctionSquare,description:"Stateless function-as-a-service / lambda."},worker:{color:"#06b6d4",icon:Ci.Cog,description:"Background job processor or consumer loop."},agent:{color:"#14b8a6",icon:Ci.Bot,description:"Autonomous AI agent driving tools and actions."},database:{color:"#34d399",icon:Ci.Database,description:"Persistent state \u2014 relational, document, key-value."},cache:{color:"#a78bfa",icon:Ci.Layers,description:"In-memory store for fast reads."},vectordb:{color:"#c084fc",icon:Ci.Sparkles,description:"Vector store for embeddings / similarity search."},storage:{color:"#84cc16",icon:Ci.HardDrive,description:"Object / blob storage (S3, GCS, etc.)."},queue:{color:"#fbbf24",icon:Ci.SendHorizontal,description:"Asynchronous work queue with at-least-once delivery."},topic:{color:"#f97316",icon:Ci.Radio,description:"Pub/sub topic with multiple consumers."},stream:{color:"#fb923c",icon:Ci.Waves,description:"Append-only event log (Kafka, Kinesis)."},gateway:{color:"#6366f1",icon:Ci.DoorOpen,description:"API gateway, ingress, edge router."},cdn:{color:"#0ea5e9",icon:Ci.Globe,description:"Content delivery network / static edge."},route:{color:"#f59e0b",icon:Ci.Route,description:"HTTP / URL route \u2014 path + method mapped to a handler."},interface:{color:"#d946ef",icon:aan,description:"Abstract contract \u2014 the <i> a system commits to."},adapter:{color:"#c026d3",icon:Ci.Cable,description:"Concrete implementation of an interface."},port:{color:"#a21caf",icon:can,description:"Hexagonal-architecture port \u2014 the socket an adapter plugs into."},llm:{color:"#a855f7",icon:Ci.Brain,description:"Large language model service."},prompt:{color:"#c4b5fd",icon:Ci.MessageSquare,description:"Prompt template / instruction set."},tool:{color:"#fde047",icon:Ci.Wrench,description:"Tool callable by an agent or LLM."},auth:{color:"#ef4444",icon:Ci.Lock,description:"Identity provider, auth service."},observability:{color:"#10b981",icon:Ci.Eye,description:"Metrics, logs, traces \u2014 operational telemetry."},cloud:{color:"#0284c7",icon:Ci.Cloud,description:"Managed cloud service (compute, hosted, etc.)."},frontend:{color:"#f472b6",icon:Ci.Monitor,description:"User-facing surface \u2014 browser, mobile, CLI."},page:{color:"#fb7185",icon:Ci.LayoutTemplate,description:"Route-level UI screen mapped to a URL."},component:{color:"#8b5cf6",icon:Ci.Component,description:"Reusable UI component / view fragment."},store:{color:"#facc15",icon:Ci.Boxes,description:"Client-side state container \u2014 Redux, Zustand, Pinia."},hook:{color:"#0d9488",icon:Ci.Anchor,description:"Reusable client logic \u2014 React hook, Vue composable."},external:{color:"#94a3b8",icon:Ci.ExternalLink,description:"Third-party system you don't own."},human:{color:"#60a5fa",icon:Ci.UserRound,description:"Human actor \u2014 end user, operator, or customer."},module:{color:"#7dd3fc",icon:Ci.Package,description:"Module / component grouping (logical container)."},custom:{color:"#64748b",icon:Ci.Box,description:"Container or anything not in the taxonomy."}};var Tz=Ai(sc(),1),ODe=36,Ykr=128,Qkr=7,san=20,uan=24;function lan({participant:o,nodeKind:c}){let d=c?jw[c]:void 0,g=d?.color??"var(--archik-fg-muted)",f=(56-ODe)/2,b=d?.icon,v=Math.max(Ykr,o.label.length*Qkr+uan+(b?san:0)),k=v/2,T=b?k+san/2:k,N=o.status,j=N==="proposed"?.55:N==="deprecated"?.35:1,B=N==="proposed"||N==="deprecated"?"4 3":void 0;return(0,Tz.jsxs)("g",{transform:`translate(${o.cx-k}, ${f})`,opacity:j,children:[(0,Tz.jsx)("rect",{width:v,height:ODe,rx:8,fill:"var(--archik-node-fill)",stroke:g,strokeWidth:1.4,...B!==void 0?{strokeDasharray:B}:{}}),b&&(0,Tz.jsx)("g",{transform:`translate(${uan/2}, ${(ODe-14)/2})`,children:(0,Tz.jsx)(b,{size:14,color:g,strokeWidth:1.5})}),(0,Tz.jsx)("text",{x:T,y:ODe/2+4,textAnchor:"middle",fontSize:12,fontWeight:500,fill:"var(--archik-fg)",fontFamily:"inherit",children:o.label})]})}var dan=Ai(sc(),1);function han({participant:o}){let c=o.status,d=c==="proposed"?.3:c==="deprecated"?.2:.5;return(0,dan.jsx)("line",{x1:o.cx,y1:56,x2:o.cx,y2:o.lifelineEndY,stroke:"var(--archik-node-stroke)",strokeWidth:1,strokeDasharray:"4 4",opacity:d})}var Q5=Ai(sc(),1),Oft=32,Fft=20,e3r=-6;function fan({msg:o}){let c=o.arrow==="return",d=o.arrow==="async",g=o.arrow==="create",f=c||g,b=o.arrow==="destroy",v=c||d?_ge:Sge,k=o.status==="proposed"?.5:o.status==="deprecated"?.35:1;if(o.isSelf){let B=o.fromCx,G=o.y,K=`M ${B} ${G} L ${B+Oft} ${G} L ${B+Oft} ${G+Fft} L ${B} ${G+Fft}`;return(0,Q5.jsxs)("g",{opacity:k,children:[(0,Q5.jsx)("path",{d:K,fill:"none",stroke:"var(--archik-edge-filled)",strokeWidth:1.4,markerEnd:`url(#${v})`}),(0,Q5.jsx)("text",{x:B+Oft+6,y:G+Fft/2+4,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:o.label})]})}let N=o.fromCx<o.toCx?o.toCx-6:o.toCx+6,j=(o.fromCx+o.toCx)/2;return(0,Q5.jsxs)("g",{opacity:k,children:[(0,Q5.jsx)("line",{x1:o.fromCx,y1:o.y,x2:N,y2:o.y,stroke:"var(--archik-edge-filled)",strokeWidth:1.4,strokeDasharray:f?"4 4":void 0,markerEnd:b?void 0:`url(#${v})`}),(0,Q5.jsxs)("text",{x:j,y:o.y+e3r,textAnchor:"middle",fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:[g&&"\xABcreate\xBB ",o.label]}),o.arrow==="destroy"&&(0,Q5.jsxs)("g",{transform:`translate(${o.toCx-6}, ${o.y-6})`,children:[(0,Q5.jsx)("line",{x1:0,y1:0,x2:12,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5}),(0,Q5.jsx)("line",{x1:12,y1:0,x2:0,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5})]})]})}var j9=Ai(sc(),1),t3r={alt:"#6366f1",opt:"#0ea5e9",loop:"#10b981",par:"#f59e0b",break:"#ef4444",ref:"#8b5cf6"},pan=36,zft=18;function gan({group:o,renderStep:c,onRefClick:d}){let g=t3r[o.kind]??"var(--archik-fg-muted)",f=o.status==="proposed"?.55:o.status==="deprecated"?.35:1,b=o.kind==="ref"&&o.seqFile!==void 0&&d!==void 0;return(0,j9.jsxs)("g",{opacity:f,onClick:b?()=>d(o.seqFile):void 0,style:b?{cursor:"pointer"}:void 0,children:[(0,j9.jsx)("rect",{x:o.x,y:o.y,width:o.width,height:o.height,rx:4,fill:"none",stroke:g,strokeWidth:1.2,opacity:.6}),(0,j9.jsx)("rect",{x:o.x,y:o.y,width:pan,height:zft,rx:4,fill:g,opacity:.8}),(0,j9.jsx)("text",{x:o.x+6,y:o.y+zft-5,fontSize:10,fontWeight:600,fill:"#fff",fontFamily:"inherit",children:o.kind}),(o.condition??o.label)&&(0,j9.jsx)("text",{x:o.x+pan+6,y:o.y+zft-5,fontSize:10,fill:g,fontFamily:"inherit",children:o.condition??o.label}),o.branches.map((v,k)=>(0,j9.jsxs)("g",{children:[v.label&&(0,j9.jsx)("text",{x:o.x+6,y:v.startY+12,fontSize:10,fill:g,fontFamily:"inherit",children:v.label}),v.steps.map(T=>c(T)),v.dividerY!==void 0&&(0,j9.jsx)("line",{x1:o.x,y1:v.dividerY,x2:o.x+o.width,y2:v.dividerY,stroke:g,strokeWidth:1,strokeDasharray:"4 2",opacity:.5})]},k))]})}var Kq=Ai(sc(),1);function n3r(o,c){let d=Math.max(10,Math.floor(c/6.5));if(o.length<=d)return[o];let g=o.split(" "),f=[],b="";for(let v of g)(b+(b?" ":"")+v).length>d&&b?(f.push(b),b=v):b=b?b+" "+v:v;return b&&f.push(b),f.slice(0,3)}function yan({note:o}){let{x:c,y:d,width:g,height:f,text:b}=o,v=o.status==="proposed"?.55:o.status==="deprecated"?.35:1;return(0,Kq.jsxs)("g",{opacity:v,children:[(0,Kq.jsx)("path",{d:`M ${c} ${d} L ${c+g-10} ${d} L ${c+g} ${d+10} L ${c+g} ${d+f} L ${c} ${d+f} Z`,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),(0,Kq.jsx)("path",{d:`M ${c+g-10} ${d} L ${c+g-10} ${d+10} L ${c+g} ${d+10}`,fill:"none",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),n3r(b,g-16).map((k,T)=>(0,Kq.jsx)("text",{x:c+8,y:d+8+11+T*13,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:k},T))]})}var $0=Ai(sc(),1);function r3r({id:o}){return(0,$0.jsx)("marker",{id:o,viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:(0,$0.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"context-stroke"})})}function i3r({id:o}){return(0,$0.jsx)("marker",{id:o,viewBox:"0 0 12 12",refX:"11",refY:"6",markerWidth:"7",markerHeight:"7",orient:"auto-start-reverse",children:(0,$0.jsx)("path",{d:"M 1 1 L 11 6 L 1 11",fill:"none",stroke:"context-stroke",strokeWidth:"1.5",strokeLinejoin:"round"})})}function wan({step:o,onRefClick:c}){return o.type==="message"?(0,$0.jsx)(fan,{msg:o}):o.type==="note"?(0,$0.jsx)(yan,{note:o}):o.type==="group"?(0,$0.jsx)(gan,{group:o,...c!==void 0?{onRefClick:c}:{},renderStep:d=>(0,$0.jsx)(wan,{step:d,...c!==void 0?{onRefClick:c}:{}},d.id)}):null}function man({laid:o,svgRef:c,onRefClick:d}){let{participants:g,steps:f,activations:b,totalWidth:v,totalHeight:k}=o;return(0,$0.jsxs)("svg",{ref:c,width:v,height:k,viewBox:`0 0 ${v} ${k}`,xmlns:"http://www.w3.org/2000/svg",style:{fontFamily:"var(--archik-font, system-ui)"},children:[(0,$0.jsxs)("defs",{children:[(0,$0.jsx)(r3r,{id:Sge}),(0,$0.jsx)(i3r,{id:_ge})]}),g.map(T=>(0,$0.jsx)(han,{participant:T},T.id)),g.map(T=>(0,$0.jsx)(lan,{participant:T,...T.kind!==void 0?{nodeKind:T.kind}:{}},T.id)),(0,$0.jsxs)("g",{transform:`translate(0, ${56})`,children:[b.map(T=>(0,$0.jsx)("rect",{x:T.cx-8/2,y:T.startY,width:8,height:T.endY-T.startY,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1,rx:2},`${T.cx}-${T.startY}`)),f.map(T=>(0,$0.jsx)(wan,{step:T,...d!==void 0?{onRefClick:d}:{}},T.id))]})]})}var LL=Ai(sc(),1),Vf=28;function Yq({kind:o,iconAt:c,labelAt:d}){let g=jw[o],f=g.icon,b=14;return(0,LL.jsxs)(LL.Fragment,{children:[(0,LL.jsx)("g",{transform:`translate(${c.cx-b/2}, ${c.cy-b/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,LL.jsx)(f,{size:b,color:g.color,strokeWidth:1.8})}),(0,LL.jsx)("text",{x:d.cx,y:d.cy,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.toUpperCase()})]})}var EL=Ai(sc(),1),o3r=24;function van({node:o,selected:c}){let d=o.width,g=o.height,f=o.stack!==void 0,b=Vf+(g-Vf)/2,v=f?b-4:b+4,k=b+14,T=Math.max(0,d-o3r),N=Gf(o.name,T,7.4),j=f?Gf(o.stack,T,5.9):"";return(0,EL.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,EL.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:d,height:g,rx:10,ry:10,fill:"var(--archik-node-fill)",stroke:c?"var(--archik-selected)":"var(--archik-node-stroke)",strokeWidth:c?1.8:1.4}),(0,EL.jsx)("line",{x1:0,y1:Vf,x2:d,y2:Vf,stroke:"var(--archik-node-stroke)",strokeOpacity:.25,strokeWidth:1}),(0,EL.jsx)(Yq,{kind:o.kind,iconAt:{cx:18,cy:Vf/2},labelAt:{cx:d/2,cy:Vf/2+3}}),(0,EL.jsx)("text",{x:d/2,y:v,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:N}),f&&(0,EL.jsx)("text",{x:d/2,y:k,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:j})]})}var TL=Ai(sc(),1);function kan({node:o,selected:c}){let d=o.width,g=o.height,f=Math.min(g/2,28),b=o.stack!==void 0,v=Vf+(g-Vf)/2,k=b?v-4:v+4,T=v+14,N=Math.max(0,d-2*f-8),j=Gf(o.name,N,7.4),B=b?Gf(o.stack,N,5.9):"",G=c?"var(--archik-selected)":"var(--archik-node-stroke)";return(0,TL.jsxs)("g",{className:"archik-node archik-node--queue",children:[(0,TL.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:d,height:g,rx:f,ry:f,fill:"var(--archik-node-fill)",stroke:G,strokeWidth:c?1.8:1.4}),(0,TL.jsx)("line",{x1:f,y1:Vf,x2:d-f,y2:Vf,stroke:G,strokeOpacity:.25,strokeWidth:1}),(0,TL.jsx)(Yq,{kind:"queue",iconAt:{cx:f+8,cy:Vf/2},labelAt:{cx:d/2,cy:Vf/2+3}}),(0,TL.jsx)("text",{x:d/2,y:k,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:j}),b&&(0,TL.jsx)("text",{x:d/2,y:T,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:B})]})}var AL=Ai(sc(),1),c3r=24;function Man({node:o,selected:c}){let d=o.width,g=o.height,f=o.description!==void 0,b=Vf,v=b+(g-b)/2,k=f?v-2:v+4,T=g-12,N=Math.max(0,d-c3r),j=Gf(o.name,N,7.4),B=f?Gf(o.description,N,5.9):"",G=c?"var(--archik-selected)":"var(--archik-node-stroke-soft)";return(0,AL.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,AL.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:d,height:g,rx:8,ry:8,fill:"var(--archik-node-fill-tinted)",stroke:G,strokeWidth:c?1.8:1.2,strokeDasharray:c?void 0:"6 4"}),(0,AL.jsx)("line",{x1:6,y1:Vf,x2:d-6,y2:Vf,stroke:G,strokeOpacity:.25,strokeWidth:1}),(0,AL.jsx)(Yq,{kind:o.kind,iconAt:{cx:18,cy:Vf/2},labelAt:{cx:d/2,cy:Vf/2+3}}),(0,AL.jsx)("text",{x:d/2,y:k,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:j}),f&&(0,AL.jsx)("text",{x:d/2,y:T,textAnchor:"middle",fontSize:10,fill:"var(--archik-node-text-dim)",children:B})]})}var e6=Ai(sc(),1),a3r=28,jft=10,s3r=22;function xan({node:o,selected:c}){let d=o.width,g=o.height,f=d/2,b=jft,v=jw[o.kind],k=v.icon,T=c?"var(--archik-selected)":"var(--archik-node-stroke)",N=c?1.8:1.4,j=o.stack!==void 0,B=Math.max(0,d-a3r),G=Gf(o.name,B,7.4),K=j?Gf(o.stack,B,5.9):"",de=g,ce=de-s3r,be=(ce+de)/2,Mt=(b+8+ce)/2,Ce=j?Mt-4:Mt+4,st=Mt+14;return(0,e6.jsxs)("g",{className:"archik-node archik-node--database",children:[(0,e6.jsx)("path",{className:c?"archik-selected-glow":void 0,d:Bft(d,g,b),fill:"var(--archik-node-fill)",stroke:T,strokeWidth:N,strokeLinejoin:"round"}),(0,e6.jsx)("ellipse",{cx:f,cy:b,rx:d/2,ry:b,fill:"var(--archik-node-fill)",stroke:T,strokeWidth:N}),(0,e6.jsx)("text",{x:f,y:Ce,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"var(--archik-node-text)",children:G}),j&&(0,e6.jsx)("text",{x:f,y:st,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:K}),(0,e6.jsx)("line",{x1:4,y1:ce,x2:d-4,y2:ce,stroke:T,strokeOpacity:.45,strokeWidth:1}),(0,e6.jsx)("g",{transform:`translate(14, ${be-7})`,pointerEvents:"none","aria-hidden":"true",children:(0,e6.jsx)(k,{size:14,color:v.color,strokeWidth:1.9})}),(0,e6.jsx)("text",{x:f,y:be+4,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()})]})}var u3r=10;function Bft(o,c,d){let g=u3r;return[`M 0 ${d}`,`L 0 ${c-g}`,`A ${g} ${g} 0 0 0 ${g} ${c}`,`L ${o-g} ${c}`,`A ${g} ${g} 0 0 0 ${o} ${c-g}`,`L ${o} ${d}`,`A ${o/2} ${d} 0 0 0 0 ${d}`,"Z"].join(" ")}var cS=Ai(sc(),1),l3r=36,San=18;function _an({node:o,selected:c}){let d=o.width,g=o.height,f=jw[o.kind],b=f.icon,v=c?"var(--archik-selected)":"var(--archik-node-stroke)",k=c?1.8:1.4,T=o.stack!==void 0,N=Math.max(0,d-l3r),j=Gf(o.name,N,7.4),B=T?Gf(o.stack,N,5.9):"",G=d/2,K=g*.55,de=T?K-4:K+4,ce=K+14;return(0,cS.jsxs)("g",{className:"archik-node archik-node--cloud",children:[(0,cS.jsx)("path",{className:c?"archik-selected-glow":void 0,d:h3r(d,g),fill:"var(--archik-node-fill)",stroke:v,strokeWidth:k,strokeLinejoin:"round"}),(0,cS.jsx)("g",{transform:`translate(18, ${San-6})`,pointerEvents:"none","aria-hidden":"true",children:(0,cS.jsx)(b,{size:14,color:f.color,strokeWidth:1.9})}),(0,cS.jsx)("text",{x:G,y:San+4,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()}),(0,cS.jsx)("text",{x:G,y:de,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:j}),T&&(0,cS.jsx)("text",{x:G,y:ce,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:B})]})}function h3r(o,c){let g=c-2,f=c*.62,b=Math.min(c*.18,14),v=o-4,k=c*.5,T=Math.min(v*.15,k*.85),N=Math.min(v*.18,k),j=Math.min(v*.15,k*.85),B=2*(T+N+j),G=Math.max(0,v-B)/4,K=2,de=o-2,ce=K+G,be=ce+2*T,Re=be+G,at=Re+2*N,Mt=at+G,Ce=Mt+2*j;return[`M ${K} ${g-b}`,`Q ${K} ${g} ${K+b} ${g}`,`L ${de-b} ${g}`,`Q ${de} ${g} ${de} ${g-b}`,`L ${de} ${f}`,`L ${Ce} ${f}`,`A ${j} ${j} 0 0 0 ${Mt} ${f}`,`L ${at} ${f}`,`A ${N} ${N} 0 0 0 ${Re} ${f}`,`L ${be} ${f}`,`A ${T} ${T} 0 0 0 ${ce} ${f}`,`L ${K} ${f}`,"Z"].join(" ")}var rb=Ai(sc(),1),Qq=32,FDe=14,Hft=14;function Can({node:o,selected:c,depth:d=0}){let g=o.width,f=o.height;if(!(o.children.length>0))return(0,rb.jsx)(f3r,{node:o,selected:!!c});let v=jw[o.kind],k=v.icon,T=Math.min(.04+d*.06,.22),N=Math.min(.55+d*.12,.95),j=c?"var(--archik-selected)":"var(--archik-container-border)",B=c?1.8:1.2,G=Math.max(0,g-FDe*2-60),K=Gf(o.name,G,7.4);return(0,rb.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--container`,children:[(0,rb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:g,height:f,rx:8,ry:8,fill:v.color,fillOpacity:T,stroke:j,strokeWidth:B,pointerEvents:"none"}),d>=1&&g>8&&f>8&&(0,rb.jsx)("rect",{x:3,y:3,width:g-6,height:f-6,rx:6,ry:6,fill:"none",stroke:v.color,strokeOpacity:Math.min(.18+(d-1)*.06,.32),strokeWidth:1,pointerEvents:"none"}),(0,rb.jsx)("path",{d:d3r(g,Qq,8),fill:v.color,fillOpacity:N*.18}),(0,rb.jsx)("line",{x1:0,y1:Qq,x2:g,y2:Qq,stroke:j,strokeOpacity:.45,strokeWidth:1}),(0,rb.jsx)("g",{transform:`translate(${FDe}, ${Qq/2-Hft/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,rb.jsx)(k,{size:Hft,color:v.color,strokeWidth:1.9})}),(0,rb.jsx)("text",{x:FDe+Hft+8,y:Qq/2+4,fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:K}),(0,rb.jsx)("text",{x:g-FDe,y:Qq/2+3,textAnchor:"end",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()})]})}function d3r(o,c,d){return`M ${d} 0 H ${o-d} A ${d} ${d} 0 0 1 ${o} ${d} V ${c} H 0 V ${d} A ${d} ${d} 0 0 1 ${d} 0 Z`}function f3r({node:o,selected:c}){let d=o.width,g=o.height,f=jw[o.kind],b=c?"var(--archik-selected)":"var(--archik-node-stroke-soft)";return(0,rb.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,rb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:d,height:g,rx:8,ry:8,fill:"var(--archik-node-fill-tinted)",stroke:b,strokeWidth:c?1.8:1.2,strokeDasharray:c?void 0:"5 4"}),(0,rb.jsx)("text",{x:d/2,y:g/2+4,textAnchor:"middle",fontSize:12,fontWeight:600,fill:f.color,children:o.name})]})}var ib=Ai(sc(),1),wte=24,Ian=10,$ft=28;function Lan({node:o,selected:c,depth:d=0}){let g=o.width,f=o.height,b=jw[o.kind],v=b.icon,k=o.kind==="external";if(o.children.length>0)return(0,ib.jsx)(p3r,{node:o,selected:!!c,depth:d});let T=c?"var(--archik-selected)":k?"var(--archik-node-stroke-soft)":"var(--archik-node-stroke)",N=k?"var(--archik-node-fill-tinted)":"var(--archik-node-fill)",j=o.kind==="queue"?Math.min(f/2,18):8;return(0,ib.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--compact`,children:[(0,ib.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:g,height:f,rx:j,ry:j,fill:N,stroke:T,strokeWidth:c?1.8:1.4,strokeDasharray:k&&!c?"5 4":void 0}),(0,ib.jsx)("g",{transform:`translate(${Ian}, ${f/2-7})`,pointerEvents:"none","aria-hidden":"true",children:(0,ib.jsx)(v,{size:13,color:b.color,strokeWidth:1.9})}),(0,ib.jsx)("text",{x:$ft,y:f/2+4,fontSize:12,fontWeight:600,fill:"var(--archik-node-text)",children:Gf(o.name,Math.max(0,g-$ft-8),5.9)})]})}function p3r({node:o,selected:c,depth:d}){let g=o.width,f=o.height,b=jw[o.kind],v=b.icon,k=Math.min(.04+d*.035,.14),T=Math.min(.55+d*.08,.85),N=c?"var(--archik-selected)":"var(--archik-container-border)",j=Math.max(0,g-12-22),B=Gf(o.name,j,5.9);return(0,ib.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--compact archik-node--container`,children:[(0,ib.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:g,height:f,rx:6,ry:6,fill:b.color,fillOpacity:k,stroke:N,strokeWidth:c?1.8:1.2}),(0,ib.jsx)("path",{d:g3r(g,wte,6),fill:b.color,fillOpacity:T*.18}),(0,ib.jsx)("line",{x1:0,y1:wte,x2:g,y2:wte,stroke:N,strokeOpacity:.45,strokeWidth:1}),(0,ib.jsx)("g",{transform:`translate(${Ian}, ${wte/2-6})`,pointerEvents:"none","aria-hidden":"true",children:(0,ib.jsx)(v,{size:12,color:b.color,strokeWidth:1.9})}),(0,ib.jsx)("text",{x:$ft,y:wte/2+4,fontSize:12,fontWeight:600,fill:"var(--archik-node-text)",children:B})]})}function g3r(o,c,d){return`M ${d} 0 H ${o-d} A ${d} ${d} 0 0 1 ${o} ${d} V ${c} H 0 V ${d} A ${d} ${d} 0 0 1 ${d} 0 Z`}var B9=Ai(Rft(),1),g1=Ai(sc(),1),y3r=12,b3r=18;function Ean({Icon:o,cx:c,cy:d,size:g=y3r,color:f,strokeWidth:b=1.8}){return(0,g1.jsx)("g",{transform:`translate(${c-g/2}, ${d-g/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,g1.jsx)(o,{size:g,color:f??"var(--archik-fg-dim)",strokeWidth:b})})}function Tan(o){return(0,g1.jsx)(Ean,{Icon:B9.Info,...o})}function Aan(o){return(0,g1.jsx)(Ean,{Icon:B9.StickyNote,...o})}function Pan({cx:o,cy:c,filePath:d,fileLabel:g,onClick:f,size:b=13}){return(0,g1.jsxs)("g",{transform:`translate(${o-b/2}, ${c-b/2})`,style:{cursor:f?"pointer":"default"},onClick:f,children:[(0,g1.jsx)("title",{children:`Cross-file edge \u2192 ${g} (${d})`}),(0,g1.jsx)("circle",{cx:b/2,cy:b/2,r:b/2+.5,fill:"var(--archik-fg-dim)",fillOpacity:.12,stroke:"var(--archik-fg-dim)",strokeOpacity:.4,strokeWidth:1}),(0,g1.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,g1.jsx)(B9.ArrowUpRight,{size:b-2,color:"var(--archik-fg-muted)",strokeWidth:2.2})})]})}function Nan({cx:o,cy:c,onClick:d,size:g=14}){return(0,g1.jsxs)("g",{transform:`translate(${o-g/2}, ${c-g/2})`,style:{cursor:d?"pointer":"default"},onClick:d,children:[(0,g1.jsx)("title",{children:"Open sub-architecture"}),(0,g1.jsx)("circle",{cx:g/2,cy:g/2,r:g/2+.5,fill:"var(--archik-accent)",fillOpacity:.16,stroke:"var(--archik-accent)",strokeOpacity:.45,strokeWidth:1}),(0,g1.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,g1.jsx)(B9.ChevronDown,{size:g-2,color:"var(--archik-accent)",strokeWidth:2.2})})]})}function Ran({cx:o,cy:c,files:d,count:g,size:f=14}){let b=d.length===1?`Open sequence diagram \u2192 ${d[0].label} (${d[0].path})`:`${d.length} sequence diagrams on this node:
504
+ ${Ag(d.errors)}`);return d.value}function kee(o){return Xht.default.stringify(o,{indent:2,lineWidth:0})}var y$n=6;function Kht(o,c){return Mee.relative(o,c).split(Mee.sep).join("/")||Mee.basename(c)}function b$n(o){return o.endsWith(".archik.yaml")&&!o.endsWith(".archik.suggested.yaml")}async function z0(o,c){let d=[],g=[],f=new Set,b=async k=>{if(f.has(k))return;f.add(k);let T;try{T=await p$n(k,"utf-8")}catch(N){g.push({abs:k,relPath:Kht(c,k),message:N instanceof Error?N.message:String(N)});return}try{let N=P2(T);d.push({abs:k,relPath:Kht(c,k),doc:N})}catch(N){g.push({abs:k,relPath:Kht(c,k),message:N instanceof Error?N.message:String(N)})}};await b(o);let v=async(k,T)=>{if(T>y$n)return;let N;try{N=await g$n(k,{withFileTypes:!0})}catch{return}for(let j of N){let B=Mee.join(k,j.name);if(j.isDirectory()){await v(B,T+1);continue}j.isFile()&&b$n(j.name)&&await b(B)}};return await v(Mee.join(c,".archik"),0),{docs:d,errors:g}}var yrn=Ai(Gx(),1);import{readFile as I$n,readdir as L$n}from"node:fs/promises";import See from"node:path";var w$n=jt.enum(["sync","async","return","create","destroy"]),m$n=jt.enum(["over","left_of","right_of"]),v$n=jt.enum(["alt","opt","loop","par","break","ref"]),k$n=jt.strictObject({id:$l,nodeId:$l,label:jt.string().min(1).optional(),status:g3.optional()}),M$n=jt.strictObject({type:jt.literal("message"),id:$l,from:$l,to:$l,label:jt.string().min(1),arrow:w$n,activate:jt.boolean().optional(),status:g3.optional()}),x$n=jt.strictObject({type:jt.literal("note"),id:$l,position:m$n,participants:jt.array($l).min(1),text:jt.string().min(1),status:g3.optional()}),S$n=jt.lazy(()=>jt.strictObject({label:jt.string().optional(),steps:jt.array(prn)})),_$n=jt.lazy(()=>jt.strictObject({type:jt.literal("group"),id:$l,kind:v$n,condition:jt.string().optional(),label:jt.string().optional(),branches:jt.array(S$n).optional(),seqFile:vee.optional(),participants:jt.array($l).optional(),status:g3.optional()})),prn=jt.lazy(()=>jt.union([M$n,x$n,_$n]));function grn(o,c){let d=[];for(let g of o)if(c.has(g.id)?d.push(g.id):c.add(g.id),g.type==="group"&&g.branches)for(let f of g.branches)d.push(...grn(f.steps,c));return d}var C$n=jt.strictObject({useCase:$l,slice:$l}),xee=jt.strictObject({version:jt.literal("1.0"),name:jt.string().min(1),description:jt.string().optional(),realizes:C$n.optional(),participants:jt.array(k$n).min(1),steps:jt.array(prn)}).superRefine((o,c)=>{let d=new Set;for(let b=0;b<o.participants.length;b++){let v=o.participants[b];d.has(v.id)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["participants",b,"id"],message:`duplicate participant id "${v.id}"`}),d.add(v.id)}let g=new Set,f=grn(o.steps,g);for(let b of f)c.addIssue({code:jt.ZodIssueCode.custom,path:["steps"],message:`duplicate step id "${b}"`})});var E$n=6;function T$n(o,c){return See.relative(o,c).split(See.sep).join("/")||See.basename(c)}async function J5(o){let c=[],d=[],g=async b=>{let v=T$n(o,b),k;try{k=await I$n(b,"utf-8")}catch(T){d.push({abs:b,relPath:v,message:T instanceof Error?T.message:String(T)});return}try{let T=yrn.default.parse(k),N=xee.safeParse(T);if(!N.success){d.push({abs:b,relPath:v,message:N.error.issues.map(j=>j.message).join("; ")});return}c.push({abs:b,relPath:v,doc:N.data})}catch(T){d.push({abs:b,relPath:v,message:T instanceof Error?T.message:String(T)})}},f=async(b,v)=>{if(v>E$n)return;let k;try{k=await L$n(b,{withFileTypes:!0})}catch{return}for(let T of k){let N=See.join(b,T.name);if(T.isDirectory()){await f(N,v+1);continue}T.isFile()&&T.name.endsWith(".archik.seq.yaml")&&await g(N)}};return await f(See.join(o,".archik"),0),{docs:c,errors:d}}var wrn=Ai(Gx(),1);import{readFile as j$n,readdir as B$n}from"node:fs/promises";import _ee from"node:path";var A$n=jt.string().min(1).refine(o=>!o.startsWith("/")&&!/^[a-zA-Z]:[\\/]/.test(o),{message:"test path must be relative (no leading / or drive letter)"}).refine(o=>!o.includes("\\"),{message:"test path must use forward slashes"}).refine(o=>!o.split("/").some(c=>c===".."),{message:"test path must not contain `..` segments"}),P$n=/^[a-z][a-z0-9-]*\.\d+$/,N$n=jt.string().regex(P$n,"branchFrom must be `<flowId>.<stepNumber>` (e.g. basic.3)"),R$n=jt.strictObject({steps:jt.array(jt.string().min(1)).min(1)}),D$n=jt.strictObject({id:$l,branchFrom:N$n,steps:jt.array(jt.string().min(1)).min(1)}),O$n=jt.strictObject({basic:R$n,alternates:jt.array(D$n).optional()}),F$n=jt.strictObject({seqFile:vee}),z$n=jt.strictObject({id:$l,description:jt.string().min(1),flows:jt.array($l).min(1),tests:jt.array(A$n).optional(),realization:F$n.optional(),status:g3.optional()}),brn=jt.strictObject({version:jt.literal("1.0"),id:$l,name:jt.string().min(1),description:jt.string().optional(),status:g3.optional(),primaryActor:$l,secondaryActors:jt.array($l).optional(),goal:jt.string().min(1),preconditions:jt.array(jt.string().min(1)).optional(),postconditions:jt.array(jt.string().min(1)).optional(),flows:O$n,slices:jt.array(z$n).min(1)}).superRefine((o,c)=>{let d=new Map;d.set("basic",o.flows.basic.steps.length);let g=new Set;o.flows.alternates&&(o.flows.alternates.forEach((b,v)=>{b.id==="basic"&&c.addIssue({code:jt.ZodIssueCode.custom,path:["flows","alternates",v,"id"],message:'alternate id "basic" collides with the basic flow'}),g.has(b.id)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["flows","alternates",v,"id"],message:`duplicate alternate flow id "${b.id}"`}),g.add(b.id),d.set(b.id,b.steps.length)}),o.flows.alternates.forEach((b,v)=>{let[k,T]=b.branchFrom.split("."),N=Number(T),j=d.get(k);if(j===void 0){c.addIssue({code:jt.ZodIssueCode.custom,path:["flows","alternates",v,"branchFrom"],message:`branchFrom "${b.branchFrom}" references unknown flow "${k}"`});return}(N<1||N>j)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["flows","alternates",v,"branchFrom"],message:`branchFrom "${b.branchFrom}" step ${N} is out of range (flow "${k}" has ${j} step(s))`})}));let f=new Set;o.slices.forEach((b,v)=>{f.has(b.id)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["slices",v,"id"],message:`duplicate slice id "${b.id}"`}),f.add(b.id),b.flows.forEach((T,N)=>{d.has(T)||c.addIssue({code:jt.ZodIssueCode.custom,path:["slices",v,"flows",N],message:`slice "${b.id}" references unknown flow "${T}". Available: ${Array.from(d.keys()).join(", ")}.`})}),b.flows.includes("basic")||c.addIssue({code:jt.ZodIssueCode.custom,path:["slices",v,"flows"],message:`slice "${b.id}" does not include the basic flow. Slices must include "basic" plus zero or more alternates that branch off it; otherwise the alternate has no prefix to branch from.`}),!(b.status==="proposed"||b.status==="deprecated")&&(b.tests===void 0||b.tests.length===0)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["slices",v,"tests"],message:`slice "${b.id}" has no tests. Active slices must declare at least one test path (each must exist on disk). Mark the slice \`status: proposed\` if the test isn't written yet.`})})});var H$n=6;function $$n(o,c){return _ee.relative(o,c).split(_ee.sep).join("/")||_ee.basename(c)}function U$n(o){return o.endsWith(".archik.uc.yaml")}async function Zy(o){let c=[],d=[],g=async b=>{let v=$$n(o,b),k;try{k=await j$n(b,"utf-8")}catch(j){d.push({abs:b,relPath:v,message:j instanceof Error?j.message:String(j)});return}let T;try{T=wrn.default.parse(k)}catch(j){d.push({abs:b,relPath:v,message:j instanceof Error?j.message:String(j)});return}let N=brn.safeParse(T);if(!N.success){d.push({abs:b,relPath:v,message:N.error.issues.map(j=>j.message).join("; ")});return}c.push({abs:b,relPath:v,doc:N.data})},f=async(b,v)=>{if(v>H$n)return;let k;try{k=await B$n(b,{withFileTypes:!0})}catch{return}for(let T of k){let N=_ee.join(b,T.name);if(T.isDirectory()){await f(N,v+1);continue}T.isFile()&&U$n(T.name)&&await g(N)}};return await f(_ee.join(o,".archik","usecases"),0),{docs:c,errors:d}}var vrn=Ai(Gx(),1);import{readFile as V$n,readdir as W$n}from"node:fs/promises";import Cee from"node:path";var q$n=jt.enum(["human","external-system","time","device"]),G$n=jt.strictObject({id:$l,kind:q$n,description:jt.string().min(1),goals:jt.array(jt.string().min(1)).optional(),status:g3.optional()}),mrn=jt.strictObject({version:jt.literal("1.0"),description:jt.string().optional(),actors:jt.array(G$n).min(1)}).superRefine((o,c)=>{let d=new Set;o.actors.forEach((g,f)=>{d.has(g.id)&&c.addIssue({code:jt.ZodIssueCode.custom,path:["actors",f,"id"],message:`duplicate actor id "${g.id}"`}),d.add(g.id)})});var J$n=6;function Z$n(o,c){return Cee.relative(o,c).split(Cee.sep).join("/")||Cee.basename(c)}function X$n(o){return o.endsWith(".archik.actors.yaml")}async function Zx(o){let c=[],d=[],g=async b=>{let v=Z$n(o,b),k;try{k=await V$n(b,"utf-8")}catch(j){d.push({abs:b,relPath:v,message:j instanceof Error?j.message:String(j)});return}let T;try{T=vrn.default.parse(k)}catch(j){d.push({abs:b,relPath:v,message:j instanceof Error?j.message:String(j)});return}let N=mrn.safeParse(T);if(!N.success){d.push({abs:b,relPath:v,message:N.error.issues.map(j=>j.message).join("; ")});return}c.push({abs:b,relPath:v,doc:N.data})},f=async(b,v)=>{if(v>J$n)return;let k;try{k=await W$n(b,{withFileTypes:!0})}catch{return}for(let T of k){let N=Cee.join(b,T.name);if(T.isDirectory()){await f(N,v+1);continue}T.isFile()&&X$n(T.name)&&await g(N)}};return await f(Cee.join(o,".archik"),0),{docs:c,errors:d}}function krn(o,c,d,g){o.forEach((f,b)=>{let v=`${g}.${b}`;f.type==="message"?(c.has(f.from)||d.push({path:`${v}.from`,message:`participant "${f.from}" is not declared in participants`}),c.has(f.to)||d.push({path:`${v}.to`,message:`participant "${f.to}" is not declared in participants`})):f.type==="note"?f.participants.forEach((k,T)=>{c.has(k)||d.push({path:`${v}.participants.${T}`,message:`participant "${k}" is not declared in participants`})}):f.type==="group"&&f.branches&&f.branches.forEach((k,T)=>{krn(k.steps,c,d,`${v}.branches.${T}.steps`)})})}function Mrn(o,c){let d=[],g=new Set;return o.participants.forEach((f,b)=>{g.add(f.id),c.has(f.nodeId)||d.push({path:`participants.${b}.nodeId`,message:`nodeId "${f.nodeId}" does not match any architecture node. Run \`npx archik q list\` to see available node ids.`})}),krn(o.steps,g,d,"steps"),d}var K$n={boundary:new Set(["control"]),control:new Set(["boundary","control","entity"]),entity:new Set(["control","entity"])};function xrn(o,c,d,g,f,b){o.forEach((v,k)=>{let T=`${f}.${k}`;if(v.type==="message"){let N=c.get(v.from),j=c.get(v.to);if(N===void 0||j===void 0)return;let B=K$n[N];B&&!B.has(j)&&b.push({path:`${d}:${T}`,message:`ECB violation in seq "${g}" message "${v.id}": ${N} \u2192 ${j} is forbidden by the robustness rules (boundaries don't talk to boundaries or entities; entities don't talk to boundaries). Insert a control between them, or revisit the stereotype assignment.`})}else v.type==="group"&&v.branches&&v.branches.forEach((N,j)=>{xrn(N.steps,c,d,g,`${T}.branches.${j}.steps`,b)})})}function Srn(o,c){let d=[],g=new Map;for(let{doc:f}of c)for(let b of f.nodes)b.stereotype!==void 0&&g.set(b.id,b.stereotype);for(let f of o){if(f.doc.realizes===void 0)continue;let b=new Map;for(let v of f.doc.participants){let k=g.get(v.nodeId);k!==void 0&&b.set(v.id,k)}xrn(f.doc.steps,b,f.relPath,f.doc.name,"steps",d)}return d}function _rn(o,c){let d=[],g=new Map;for(let{doc:f}of c)for(let b of f.nodes){let v=g.get(b.id)??new Set;for(let k of b.seqFiles??[])v.add(k);g.set(b.id,v)}for(let f of o){if(f.doc.realizes===void 0)continue;let b=new Set;for(let v of f.doc.participants){if(b.has(v.nodeId))continue;let k=g.get(v.nodeId);k!==void 0&&(k.has(f.relPath)||(b.add(v.nodeId),d.push({path:`${f.relPath}:participants.${v.id}`,message:`seq "${f.doc.name}" lists node "${v.nodeId}" as a participant, but that node's \`seqFiles\` array does not reference this diagram. Add "${f.relPath}" to node "${v.nodeId}"'s \`seqFiles\` array via \`npx archik suggest set\` so the canvas can surface the flow on that node.`})))}}return d}function Crn(o,c){let d=[],g=new Map(c.map(f=>[f.doc.id,f]));for(let f of o){if(f.doc.realizes===void 0)continue;let{useCase:b,slice:v}=f.doc.realizes,k=g.get(b);if(k===void 0){d.push({path:`${f.relPath}:realizes.useCase`,message:`seq diagram "${f.doc.name}" claims to realize use case "${b}" but no such use case file was found.`});continue}let T=k.doc.slices.find(N=>N.id===v);if(T===void 0){d.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" claims to realize slice "${v}" of use case "${b}", but that use case has no slice with that id. Available slices: ${k.doc.slices.map(N=>N.id).join(", ")}.`});continue}if(T.realization===void 0){d.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" realizes slice "${v}" of "${b}", but the slice does not declare \`realization.seqFile\`. Add \`realization: { seqFile: "${f.relPath}" }\` to slice "${v}" in ${k.relPath}.`});continue}T.realization.seqFile!==f.relPath&&d.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" realizes slice "${v}" of "${b}", but that slice's realization.seqFile points at "${T.realization.seqFile}", not at this file ("${f.relPath}"). Pick one canonical seq file and update both sides.`})}return d}function Irn(o){let c=new Map,d=[];for(let{relPath:g,doc:f}of o)for(let b of f.actors){let v=c.get(b.id);if(v!==void 0){d.push({path:g,message:`actor id "${b.id}" is duplicated across actor files (also defined in ${v.relPath})`});continue}c.set(b.id,{relPath:g})}return{index:c,errors:d}}function Lrn(o){let c=new Map,d=[];for(let{relPath:g,doc:f}of o){let b=c.get(f.id);if(b!==void 0){d.push({path:g,message:`use case id "${f.id}" is duplicated across files (also defined in ${b.relPath})`});continue}c.set(f.id,{relPath:g})}return{index:c,errors:d}}function Ern(o,c){let d=[];for(let{relPath:g,doc:f}of o)c.has(f.primaryActor)||d.push({path:`${g}:primaryActor`,message:`use case "${f.id}" references unknown primaryActor "${f.primaryActor}". Define it in a *.archik.actors.yaml file.`}),f.secondaryActors&&f.secondaryActors.forEach((b,v)=>{c.has(b)||d.push({path:`${g}:secondaryActors.${v}`,message:`use case "${f.id}" references unknown secondary actor "${b}". Define it in a *.archik.actors.yaml file.`})});return d}function Trn(o,c){let d=[];for(let{relPath:g,doc:f}of o)f.slices.forEach((b,v)=>{b.status==="proposed"||b.status==="deprecated"||b.tests!==void 0&&b.tests.forEach((T,N)=>{c(T)||d.push({path:`${g}:slices.${v}.tests.${N}`,message:`slice "${b.id}" test "${T}" does not exist on disk (resolved relative to project root). Either fix the path or mark the slice \`status: proposed\`.`})})});return d}function Arn(o,c){let d=[],g=new Map(c.map(f=>[f.relPath,f]));for(let{relPath:f,doc:b}of o)b.slices.forEach((v,k)=>{if(v.realization===void 0)return;let T=g.get(v.realization.seqFile);if(T===void 0){d.push({path:`${f}:slices.${k}.realization.seqFile`,message:`slice "${v.id}" realization seqFile "${v.realization.seqFile}" does not exist or did not parse. Run \`npx archik q sequences\` to see available seq files.`});return}if(T.doc.realizes===void 0){d.push({path:`${f}:slices.${k}.realization.seqFile`,message:`slice "${v.id}" claims realization "${v.realization.seqFile}", but that seq diagram has no \`realizes\` block. Add \`realizes: { useCase: "${b.id}", slice: "${v.id}" }\` to ${T.relPath}, or remove the realization claim.`});return}(T.doc.realizes.useCase!==b.id||T.doc.realizes.slice!==v.id)&&d.push({path:`${f}:slices.${k}.realization.seqFile`,message:`slice "${v.id}" claims realization "${v.realization.seqFile}", but that seq diagram's \`realizes\` points at "${T.doc.realizes.useCase}/${T.doc.realizes.slice}", not at "${b.id}/${v.id}". Pick one canonical link.`})});return d}import Iee from"node:path";function Xx(o){let c=Iee.dirname(o),d=Iee.basename(o),g=Iee.extname(d),f=g.length>0?d.slice(0,-g.length):d;return Iee.join(c,`${f}.suggested${g}`)}function Lq(o){return Iee.basename(o).endsWith(".archik.suggested.yaml")?"suggested":"normal"}function Prn(o){return o.metadata?.suggestion!==void 0}function ape(o){if(o.metadata?.suggestion===void 0)return o;let{suggestion:c,...d}=o.metadata,g={...o};return Object.keys(d).length===0?delete g.metadata:g.metadata=d,g}var eUn=o=>{let c=Xr(o,"json");return c!==void 0&&c!=="false"&&c!=="0"};function Z5(o){console.log(JSON.stringify(o,null,2))}async function Drn(o){let c=eUn(o),d;try{d=await Eu(o._[0])}catch(Le){let tn=Le instanceof Error?Le.message:String(Le);return c?Z5({ok:!1,errors:[{path:"<root>",message:tn}]}):console.error(`\u2717 ${tn}`),1}let g=Nrn.relative(process.cwd(),d)||d,f;try{f=await Q$n(d,"utf-8")}catch(Le){let tn=Le instanceof Error?Le.message:String(Le);return c?Z5({ok:!1,file:g,errors:[{path:"<root>",message:tn}]}):(console.error(`\u2717 Cannot read ${g}`),console.error(tn)),1}let b;try{b=Rrn.default.parse(f)}catch(Le){let Jt=[{path:"<root>",message:`Invalid YAML: ${Le instanceof Error?Le.message:String(Le)}`}];return c?Z5({ok:!1,file:g,errors:Jt}):(console.error(`\u2717 ${g}`),console.error(Ag(Jt))),1}let v=dL(b);if(!v.ok)return c?Z5({ok:!1,file:g,errors:v.errors}):(console.error(`\u2717 ${g}`),console.error(Ag(v.errors))),1;let k=W1(d),T=Le=>Y$n(Nrn.resolve(k,Le)),N=Iq(v.value,T);if(N.length>0)return c?Z5({ok:!1,file:g,errors:N}):(console.error(`\u2717 ${g}`),console.error(Ag(N))),1;let j=Lq(d),B=Cq(v.value,j,T);if(B.length>0)return c?Z5({ok:!1,file:g,errors:B}):(console.error(`\u2717 ${g}`),console.error(Ag(B))),1;let G=await z0(d,k);if(G.errors.length>0){if(c)Z5({ok:!1,file:g,errors:G.errors.map(Le=>({path:Le.relPath,message:Le.message}))});else for(let Le of G.errors)console.error(`\u2717 ${Le.relPath}: ${Le.message}`);return 1}let K=new Set(G.docs.flatMap(Le=>Le.doc.nodes.map(tn=>tn.id))),de=[];for(let{doc:Le}of G.docs)de.push(...frn(Le,T));if(de.length>0){if(c)Z5({ok:!1,file:g,errors:de});else{console.error("\u2717 seqFiles path errors:");for(let Le of de)console.error(` \u2717 ${Le.path}: ${Le.message}`)}return 1}let ce=await J5(k),be=0;for(let Le of ce.errors)c||console.error(`\u2717 ${Le.relPath}: ${Le.message}`),be++;for(let{relPath:Le,doc:tn}of ce.docs){let Jt=Mrn(tn,K);if(Jt.length>0){if(!c){console.error(`\u2717 ${Le}`);for(let or of Jt)console.error(` \u2717 ${or.path}: ${or.message}`)}be+=Jt.length}}if(be>0)return c&&Z5({ok:!1,file:g,errors:[{path:"<seq>",message:`${be} sequence diagram error(s)`}]}),1;let Re=await Zy(k),at=await Zx(k),Mt=[];for(let Le of Re.errors)Mt.push({path:Le.relPath,message:Le.message});for(let Le of at.errors)Mt.push({path:Le.relPath,message:Le.message});if(Mt.length===0){let Le=Irn(at.docs);Mt.push(...Le.errors);let tn=Lrn(Re.docs);Mt.push(...tn.errors),Mt.length===0&&(Mt.push(...Ern(Re.docs,Le.index)),Mt.push(...Trn(Re.docs,T)),Mt.push(...Arn(Re.docs,ce.docs)),Mt.push(...Crn(ce.docs,Re.docs)),Mt.push(...Srn(ce.docs,G.docs)),Mt.push(..._rn(ce.docs,G.docs)))}if(Mt.length>0)return c?Z5({ok:!1,file:g,errors:Mt}):(console.error(`\u2717 ${g}`),console.error(Ag(Mt))),1;let Ce=at.docs.reduce((Le,tn)=>Le+tn.doc.actors.length,0),st=Re.docs.length;if(c)Z5({ok:!0,file:g,nodes:v.value.nodes.length,edges:v.value.edges.length,useCases:st,actors:Ce});else{let Le=G.docs.reduce((gn,Hr)=>gn+Hr.doc.nodes.length,0),tn=G.docs.reduce((gn,Hr)=>gn+Hr.doc.edges.length,0),Jt=G.docs.length,or=Jt>1?` (${Jt} files)`:"",Xn=st>0?`, ${st} use case${st===1?"":"s"}`:"",br=Ce>0?`, ${Ce} actor${Ce===1?"":"s"}`:"";console.log(`\u2713 ${g}${or} \u2014 ${Le} nodes, ${tn} edges${Xn}${br}`)}return 0}var Wft=Ai(y3(),1),Jft=Ai(Mge(),1),Xan=Ai(Gx(),1);import{mkdir as Wan,readFile as Jan,writeFile as Zan}from"node:fs/promises";import eG from"node:path";var Gcn=Ai(Hcn(),1);function gte(o,c){return o.length*c}function Gf(o,c,d){if(c<=0)return"";let g=Math.floor(c/d);return o.length<=g?o:g<=1?"\u2026":o.slice(0,g-1)+"\u2026"}var yte={nodeSpacing:60,layerSpacing:100,padding:40,viewMode:"detailed"};function nWn(o){let c=o.nodeSpacing??yte.nodeSpacing,d=o.layerSpacing??yte.layerSpacing,g=o.padding??yte.padding;return{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.layered.spacing.nodeNodeBetweenLayers":String(d),"elk.spacing.nodeNode":String(c),"elk.padding":`[top=${g}, left=${g}, bottom=${g}, right=${g}]`,"elk.hierarchyHandling":"INCLUDE_CHILDREN","elk.edgeLabels.placement":"CENTER","elk.spacing.edgeLabel":"8","elk.spacing.labelLabel":"6","elk.spacing.edgeNode":"20","elk.spacing.edgeEdge":"12","elk.layered.spacing.edgeEdgeBetweenLayers":"12"}}var Th={width:172,height:82},$cn={width:172,height:90},rWn={service:Th,function:Th,worker:Th,agent:Th,database:{width:184,height:100},cache:$cn,vectordb:Th,storage:Th,queue:{width:188,height:80},topic:Th,stream:Th,gateway:Th,cdn:Th,route:Th,interface:Th,adapter:Th,port:Th,llm:Th,prompt:Th,tool:Th,auth:Th,observability:Th,cloud:{width:200,height:120},frontend:$cn,page:Th,component:Th,store:Th,hook:Th,external:{width:184,height:100},human:{width:184,height:100},module:{width:240,height:130},custom:{width:240,height:130}},yl={width:152,height:36},Ucn={width:200,height:80},iWn={service:yl,function:yl,worker:yl,agent:yl,database:yl,cache:yl,vectordb:yl,storage:yl,queue:{width:168,height:36},topic:yl,stream:yl,gateway:yl,cdn:yl,route:yl,interface:yl,adapter:yl,port:yl,llm:yl,prompt:yl,tool:yl,auth:yl,observability:yl,cloud:yl,frontend:yl,page:yl,component:yl,store:yl,hook:yl,external:{width:168,height:40},human:{width:168,height:40},module:Ucn,custom:Ucn},oWn=24,qcn=320;function cWn(o,c,d){if(o.kind==="module"||o.kind==="custom")return c;if(d==="compact"){let k=36+gte(o.name,5.9)+12;return Math.max(c,Math.min(qcn,Math.ceil(k)))}let g=gte(o.name,7.4),f=o.stack!==void 0?gte(o.stack,5.9):0,b=Math.max(g,f)+oWn;return Math.max(c,Math.min(qcn,Math.ceil(b)))}var aWn={top:48,left:18,bottom:18,right:18};function sWn(o,c,d,g){let f=d[o.kind],b={id:o.id,width:cWn(o,f.width,g),height:f.height};if(c.length>0){b.children=c;let v=g==="compact"?{top:30,left:12,bottom:12,right:12}:aWn;b.layoutOptions={"elk.padding":`[top=${v.top}, left=${v.left}, bottom=${v.bottom}, right=${v.right}]`}}return b}function uWn(o,c,d){let g=new Map;for(let k of o.nodes)g.set(k.id,k);let f=new Map;for(let k of o.nodes){let T=f.get(k.parentId)??[];T.push(k),f.set(k.parentId,T)}function b(k){let T=(f.get(k.id)??[]).map(b);return sWn(k,T,c,d)}return{roots:(f.get(void 0)??[]).map(b),byId:g}}function lWn(o){return o.fromFile===void 0&&o.toFile===void 0}function hWn(o){return o.edges.filter(lWn).map(c=>{let d={id:c.id,sources:[c.from],targets:[c.to]};return c.label!==void 0&&c.label.length>0&&(d.labels=[{text:c.label,width:Math.ceil(gte(c.label,5.9)),height:14}]),d})}function zw(o){return o??0}function Vcn(o,c){let d=c.get(o.id);if(!d)throw new Error(`ELK returned unknown node id "${o.id}"`);let g=(o.children??[]).map(f=>Vcn(f,c));return{...d,x:zw(o.x),y:zw(o.y),width:zw(o.width),height:zw(o.height),children:g}}function dWn(o,c){let d=new Map,g=new Map,f=(N,j,B,G)=>{let K=j+zw(N.x),de=B+zw(N.y);d.set(N.id,{x:K,y:de}),g.set(N.id,G);let ce=[...G,N.id];for(let be of N.children??[])f(be,K,de,ce)};f(o,0,0,[]);let b=(N,j)=>{let B=g.get(N)??[],G=g.get(j)??[],K=0;for(;K<B.length&&K<G.length&&B[K]===G[K];)K++;let de=K===0?o.id:B[K-1];return d.get(de)??{x:0,y:0}},v=new Map,k=new Map,T=N=>{for(let j of N.edges??[]){let B=j.sources?.[0]??"",G=j.targets?.[0]??"",K=b(B,G),de=Re=>({x:zw(Re.x)+K.x,y:zw(Re.y)+K.y}),ce=(j.sections??[]).map(Re=>({startPoint:de(Re.startPoint),endPoint:de(Re.endPoint),bendPoints:(Re.bendPoints??[]).map(de)}));v.set(j.id,ce);let be=(j.labels??[]).map(Re=>({text:typeof Re.text=="string"?Re.text:"",x:zw(Re.x)+K.x,y:zw(Re.y)+K.y,width:zw(Re.width),height:zw(Re.height)}));k.set(j.id,be)}for(let j of N.children??[])T(j)};return T(o),c.edges.map(N=>({...N,sections:v.get(N.id)??[],labels:k.get(N.id)??[]}))}var fWn=new Gcn.default;async function pWn(o,c={}){if(o.nodes.length===0)return{document:o,width:0,height:0,roots:[],edges:[]};let d=c.viewMode==="compact"?"compact":"detailed",g=d==="compact"?iWn:rWn,{roots:f,byId:b}=uWn(o,g,d),v={id:"__root__",layoutOptions:nWn(c),children:f,edges:hWn(o)},k=await fWn.layout(v),T=(k.children??[]).map(N=>Vcn(N,b));return{document:o,width:zw(k.width),height:zw(k.height),roots:T,edges:dWn(k,o)}}var xge={name:"elk",layout:pWn};var nri={[xge.name]:xge},gWn=xge;function Xq(o,c){return gWn.layout(o,c)}var Sge="seq-arrow-filled",_ge="seq-arrow-open";function yWn(o){return Math.max(160,o.length*8+80)}function Wcn(o,c,d,g,f,b=0){let v=d,k=[],T=Number.POSITIVE_INFINITY,N=Number.NEGATIVE_INFINITY;for(let j of o)if(j.type==="message"){let B=c.get(j.from),G=c.get(j.to),K=B?.cx??g,de=G?.cx??g;k.push({type:"message",id:j.id,fromCx:K,toCx:de,y:v,label:j.label,arrow:j.arrow,activate:j.activate??!1,isSelf:j.from===j.to,...j.status!==void 0?{status:j.status}:{}}),v+=j.from===j.to?56*1.5:56}else if(j.type==="note"){let B=j.participants.map(be=>c.get(be)?.cx).filter(be=>be!==void 0).sort((be,Re)=>be-Re),G=B[0]??g,K=B[B.length-1]??f,de=Math.min(Math.max(j.text.length*7.5+24,K-G+16,80),400),ce;j.position==="left_of"?ce=G-de-8:j.position==="right_of"?ce=K+8:ce=(G+K)/2-de/2,T=Math.min(T,ce),N=Math.max(N,ce+de),k.push({type:"note",id:j.id,x:ce,y:v,width:de,height:64,text:j.text,...j.status!==void 0?{status:j.status}:{}}),v+=72}else if(j.type==="group"){let B=Math.min(b*6,12),G=g-12+B,K=f-g+24-B*2,de=v;v+=24;let ce=[];if(j.branches)for(let be=0;be<j.branches.length;be++){let Re=j.branches[be],at=v,{items:Mt,endY:Ce,contentMinX:st,contentMaxX:Le}=Wcn(Re.steps,c,v,g,f,b+1);v=Ce,T=Math.min(T,st),N=Math.max(N,Le),ce.push({...Re.label!==void 0?{label:Re.label}:{},startY:at,...be<j.branches.length-1?{dividerY:v}:{},steps:Mt}),be<j.branches.length-1&&(v+=4)}v+=12,k.push({type:"group",id:j.id,kind:j.kind,...j.condition!==void 0?{condition:j.condition}:{},...j.label!==void 0?{label:j.label}:{},...j.seqFile!==void 0?{seqFile:j.seqFile}:{},x:G,y:de,width:K,height:v-de,branches:ce,...j.status!==void 0?{status:j.status}:{}}),T=Math.min(T,G),N=Math.max(N,G+K),v+=20}return{items:k,endY:v,contentMinX:T,contentMaxX:N}}function Jcn(o){let c=new Map;for(let d of o)if(d.type==="message"&&d.arrow==="destroy"&&c.set(d.toCx,d.y+56+20),d.type==="group")for(let g of d.branches)for(let[f,b]of Jcn(g.steps))c.set(f,b);return c}function bWn(o){let c=[],d=new Map;function g(f){for(let b of f)if(b.type==="message"){if(b.activate&&b.arrow==="sync"&&!b.isSelf){let v=d.get(b.toCx)??[];v.push(b.y),d.set(b.toCx,v)}if(b.arrow==="return"&&!b.isSelf){let v=d.get(b.fromCx);if(v&&v.length>0){let k=v.pop();c.push({cx:b.fromCx,startY:k,endY:b.y}),v.length===0&&d.delete(b.fromCx)}}}else if(b.type==="group")for(let v of b.branches)g(v.steps)}g(o);for(let[f,b]of d)for(let v of b)c.push({cx:f,startY:v,endY:v+56/2});return c}function Zcn(o,c){let d=o.participants.map(tn=>yWn(tn.label??tn.nodeId)),g=32,f=o.participants.map((tn,Jt)=>{let or=d[Jt],Xn=g+or/2;g+=or;let br=c?.get(tn.nodeId);return{id:tn.id,nodeId:tn.nodeId,label:tn.label??tn.nodeId,cx:Xn,colWidth:or,...br!==void 0?{kind:br}:{},...tn.status!==void 0?{status:tn.status}:{},lifelineEndY:0}}),b=g+32,v=new Map(f.map(tn=>[tn.id,tn])),k=f[0]?.cx??32,T=f[f.length-1]?.cx??b-32,N=24,{items:j,endY:B,contentMinX:G,contentMaxX:K}=Wcn(o.steps,v,N,k,T),de=G<32&&Number.isFinite(G)?32-G:0,ce=Number.isFinite(K)?K+de+32:0,be=Math.max(b+de,ce),Re=de>0?j.map(tn=>Xcn(tn,de)):j,at=de>0?f.map(tn=>({...tn,cx:tn.cx+de})):f,Mt=Jcn(Re),Ce=at.map(tn=>({...tn,lifelineEndY:Mt.get(tn.cx)??56+B+24})),st=56+B+24,Le=bWn(Re);return{participants:Ce,steps:Re,activations:Le,totalWidth:be,totalHeight:st}}function Xcn(o,c){return o.type==="message"?{...o,fromCx:o.fromCx+c,toCx:o.toCx+c}:o.type==="note"?{...o,x:o.x+c}:{...o,x:o.x+c,branches:o.branches.map(d=>({...d,steps:d.steps.map(g=>Xcn(g,c))}))}}var Ci=Ai(Rft(),1);var M3=Ai(sc(),1),oan=(o,c,d)=>({width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:c,strokeWidth:d,strokeLinecap:"round",strokeLinejoin:"round"});function can({size:o=16,color:c="currentColor",strokeWidth:d=1.8}){return(0,M3.jsxs)("svg",{...oan(o,c,d),"aria-hidden":"true",children:[(0,M3.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3.5",ry:"3.5"}),(0,M3.jsx)("line",{x1:"9",y1:"9",x2:"9",y2:"13"}),(0,M3.jsx)("line",{x1:"15",y1:"9",x2:"15",y2:"13"}),(0,M3.jsx)("circle",{cx:"12",cy:"16.5",r:"1",fill:c,stroke:"none"})]})}function aan({size:o=16,color:c="currentColor",strokeWidth:d=1.8}){return(0,M3.jsxs)("svg",{...oan(o,c,d),"aria-hidden":"true",children:[(0,M3.jsx)("path",{d:"M 7.5 6 L 3.5 12 L 7.5 18"}),(0,M3.jsx)("path",{d:"M 16.5 6 L 20.5 12 L 16.5 18"}),(0,M3.jsx)("circle",{cx:"13",cy:"8.6",r:"0.9",fill:c,stroke:"none"}),(0,M3.jsx)("line",{x1:"13",y1:"11",x2:"11",y2:"16.5"})]})}var jw={service:{color:"#38bdf8",icon:Ci.Server,description:"Long-running compute that owns business logic."},function:{color:"#22d3ee",icon:Ci.FunctionSquare,description:"Stateless function-as-a-service / lambda."},worker:{color:"#06b6d4",icon:Ci.Cog,description:"Background job processor or consumer loop."},agent:{color:"#14b8a6",icon:Ci.Bot,description:"Autonomous AI agent driving tools and actions."},database:{color:"#34d399",icon:Ci.Database,description:"Persistent state \u2014 relational, document, key-value."},cache:{color:"#a78bfa",icon:Ci.Layers,description:"In-memory store for fast reads."},vectordb:{color:"#c084fc",icon:Ci.Sparkles,description:"Vector store for embeddings / similarity search."},storage:{color:"#84cc16",icon:Ci.HardDrive,description:"Object / blob storage (S3, GCS, etc.)."},queue:{color:"#fbbf24",icon:Ci.SendHorizontal,description:"Asynchronous work queue with at-least-once delivery."},topic:{color:"#f97316",icon:Ci.Radio,description:"Pub/sub topic with multiple consumers."},stream:{color:"#fb923c",icon:Ci.Waves,description:"Append-only event log (Kafka, Kinesis)."},gateway:{color:"#6366f1",icon:Ci.DoorOpen,description:"API gateway, ingress, edge router."},cdn:{color:"#0ea5e9",icon:Ci.Globe,description:"Content delivery network / static edge."},route:{color:"#f59e0b",icon:Ci.Route,description:"HTTP / URL route \u2014 path + method mapped to a handler."},interface:{color:"#d946ef",icon:aan,description:"Abstract contract \u2014 the <i> a system commits to."},adapter:{color:"#c026d3",icon:Ci.Cable,description:"Concrete implementation of an interface."},port:{color:"#a21caf",icon:can,description:"Hexagonal-architecture port \u2014 the socket an adapter plugs into."},llm:{color:"#a855f7",icon:Ci.Brain,description:"Large language model service."},prompt:{color:"#c4b5fd",icon:Ci.MessageSquare,description:"Prompt template / instruction set."},tool:{color:"#fde047",icon:Ci.Wrench,description:"Tool callable by an agent or LLM."},auth:{color:"#ef4444",icon:Ci.Lock,description:"Identity provider, auth service."},observability:{color:"#10b981",icon:Ci.Eye,description:"Metrics, logs, traces \u2014 operational telemetry."},cloud:{color:"#0284c7",icon:Ci.Cloud,description:"Managed cloud service (compute, hosted, etc.)."},frontend:{color:"#f472b6",icon:Ci.Monitor,description:"User-facing surface \u2014 browser, mobile, CLI."},page:{color:"#fb7185",icon:Ci.LayoutTemplate,description:"Route-level UI screen mapped to a URL."},component:{color:"#8b5cf6",icon:Ci.Component,description:"Reusable UI component / view fragment."},store:{color:"#facc15",icon:Ci.Boxes,description:"Client-side state container \u2014 Redux, Zustand, Pinia."},hook:{color:"#0d9488",icon:Ci.Anchor,description:"Reusable client logic \u2014 React hook, Vue composable."},external:{color:"#94a3b8",icon:Ci.ExternalLink,description:"Third-party system you don't own."},human:{color:"#60a5fa",icon:Ci.UserRound,description:"Human actor \u2014 end user, operator, or customer."},module:{color:"#7dd3fc",icon:Ci.Package,description:"Module / component grouping (logical container)."},custom:{color:"#64748b",icon:Ci.Box,description:"Container or anything not in the taxonomy."}};var Tz=Ai(sc(),1),ODe=36,Ykr=128,Qkr=7,san=20,uan=24;function lan({participant:o,nodeKind:c}){let d=c?jw[c]:void 0,g=d?.color??"var(--archik-fg-muted)",f=(56-ODe)/2,b=d?.icon,v=Math.max(Ykr,o.label.length*Qkr+uan+(b?san:0)),k=v/2,T=b?k+san/2:k,N=o.status,j=N==="proposed"?.55:N==="deprecated"?.35:1,B=N==="proposed"||N==="deprecated"?"4 3":void 0;return(0,Tz.jsxs)("g",{transform:`translate(${o.cx-k}, ${f})`,opacity:j,children:[(0,Tz.jsx)("rect",{width:v,height:ODe,rx:8,fill:"var(--archik-node-fill)",stroke:g,strokeWidth:1.4,...B!==void 0?{strokeDasharray:B}:{}}),b&&(0,Tz.jsx)("g",{transform:`translate(${uan/2}, ${(ODe-14)/2})`,children:(0,Tz.jsx)(b,{size:14,color:g,strokeWidth:1.5})}),(0,Tz.jsx)("text",{x:T,y:ODe/2+4,textAnchor:"middle",fontSize:12,fontWeight:500,fill:"var(--archik-fg)",fontFamily:"inherit",children:o.label})]})}var dan=Ai(sc(),1);function han({participant:o}){let c=o.status,d=c==="proposed"?.3:c==="deprecated"?.2:.5;return(0,dan.jsx)("line",{x1:o.cx,y1:56,x2:o.cx,y2:o.lifelineEndY,stroke:"var(--archik-node-stroke)",strokeWidth:1,strokeDasharray:"4 4",opacity:d})}var Q5=Ai(sc(),1),Oft=32,Fft=20,e3r=-6;function fan({msg:o}){let c=o.arrow==="return",d=o.arrow==="async",g=o.arrow==="create",f=c||g,b=o.arrow==="destroy",v=c||d?_ge:Sge,k=o.status==="proposed"?.5:o.status==="deprecated"?.35:1;if(o.isSelf){let B=o.fromCx,G=o.y,K=`M ${B} ${G} L ${B+Oft} ${G} L ${B+Oft} ${G+Fft} L ${B} ${G+Fft}`;return(0,Q5.jsxs)("g",{opacity:k,children:[(0,Q5.jsx)("path",{d:K,fill:"none",stroke:"var(--archik-edge-filled)",strokeWidth:1.4,markerEnd:`url(#${v})`}),(0,Q5.jsx)("text",{x:B+Oft+6,y:G+Fft/2+4,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:o.label})]})}let N=o.fromCx<o.toCx?o.toCx-6:o.toCx+6,j=(o.fromCx+o.toCx)/2;return(0,Q5.jsxs)("g",{opacity:k,children:[(0,Q5.jsx)("line",{x1:o.fromCx,y1:o.y,x2:N,y2:o.y,stroke:"var(--archik-edge-filled)",strokeWidth:1.4,strokeDasharray:f?"4 4":void 0,markerEnd:b?void 0:`url(#${v})`}),(0,Q5.jsxs)("text",{x:j,y:o.y+e3r,textAnchor:"middle",fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:[g&&"\xABcreate\xBB ",o.label]}),o.arrow==="destroy"&&(0,Q5.jsxs)("g",{transform:`translate(${o.toCx-6}, ${o.y-6})`,children:[(0,Q5.jsx)("line",{x1:0,y1:0,x2:12,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5}),(0,Q5.jsx)("line",{x1:12,y1:0,x2:0,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5})]})]})}var j9=Ai(sc(),1),t3r={alt:"#6366f1",opt:"#0ea5e9",loop:"#10b981",par:"#f59e0b",break:"#ef4444",ref:"#8b5cf6"},pan=36,zft=18;function gan({group:o,renderStep:c,onRefClick:d}){let g=t3r[o.kind]??"var(--archik-fg-muted)",f=o.status==="proposed"?.55:o.status==="deprecated"?.35:1,b=o.kind==="ref"&&o.seqFile!==void 0&&d!==void 0;return(0,j9.jsxs)("g",{opacity:f,onClick:b?()=>d(o.seqFile):void 0,style:b?{cursor:"pointer"}:void 0,children:[(0,j9.jsx)("rect",{x:o.x,y:o.y,width:o.width,height:o.height,rx:4,fill:"none",stroke:g,strokeWidth:1.2,opacity:.6}),(0,j9.jsx)("rect",{x:o.x,y:o.y,width:pan,height:zft,rx:4,fill:g,opacity:.8}),(0,j9.jsx)("text",{x:o.x+6,y:o.y+zft-5,fontSize:10,fontWeight:600,fill:"#fff",fontFamily:"inherit",children:o.kind}),(o.condition??o.label)&&(0,j9.jsx)("text",{x:o.x+pan+6,y:o.y+zft-5,fontSize:10,fill:g,fontFamily:"inherit",children:o.condition??o.label}),o.branches.map((v,k)=>(0,j9.jsxs)("g",{children:[v.label&&(0,j9.jsx)("text",{x:o.x+6,y:v.startY+12,fontSize:10,fill:g,fontFamily:"inherit",children:v.label}),v.steps.map(T=>c(T)),v.dividerY!==void 0&&(0,j9.jsx)("line",{x1:o.x,y1:v.dividerY,x2:o.x+o.width,y2:v.dividerY,stroke:g,strokeWidth:1,strokeDasharray:"4 2",opacity:.5})]},k))]})}var Kq=Ai(sc(),1);function n3r(o,c){let d=Math.max(10,Math.floor(c/6.5));if(o.length<=d)return[o];let g=o.split(" "),f=[],b="";for(let v of g)(b+(b?" ":"")+v).length>d&&b?(f.push(b),b=v):b=b?b+" "+v:v;return b&&f.push(b),f.slice(0,3)}function yan({note:o}){let{x:c,y:d,width:g,height:f,text:b}=o,v=o.status==="proposed"?.55:o.status==="deprecated"?.35:1;return(0,Kq.jsxs)("g",{opacity:v,children:[(0,Kq.jsx)("path",{d:`M ${c} ${d} L ${c+g-10} ${d} L ${c+g} ${d+10} L ${c+g} ${d+f} L ${c} ${d+f} Z`,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),(0,Kq.jsx)("path",{d:`M ${c+g-10} ${d} L ${c+g-10} ${d+10} L ${c+g} ${d+10}`,fill:"none",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),n3r(b,g-16).map((k,T)=>(0,Kq.jsx)("text",{x:c+8,y:d+8+11+T*13,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:k},T))]})}var $0=Ai(sc(),1);function r3r({id:o}){return(0,$0.jsx)("marker",{id:o,viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:(0,$0.jsx)("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"context-stroke"})})}function i3r({id:o}){return(0,$0.jsx)("marker",{id:o,viewBox:"0 0 12 12",refX:"11",refY:"6",markerWidth:"7",markerHeight:"7",orient:"auto-start-reverse",children:(0,$0.jsx)("path",{d:"M 1 1 L 11 6 L 1 11",fill:"none",stroke:"context-stroke",strokeWidth:"1.5",strokeLinejoin:"round"})})}function wan({step:o,onRefClick:c}){return o.type==="message"?(0,$0.jsx)(fan,{msg:o}):o.type==="note"?(0,$0.jsx)(yan,{note:o}):o.type==="group"?(0,$0.jsx)(gan,{group:o,...c!==void 0?{onRefClick:c}:{},renderStep:d=>(0,$0.jsx)(wan,{step:d,...c!==void 0?{onRefClick:c}:{}},d.id)}):null}function man({laid:o,svgRef:c,onRefClick:d}){let{participants:g,steps:f,activations:b,totalWidth:v,totalHeight:k}=o;return(0,$0.jsxs)("svg",{ref:c,width:v,height:k,viewBox:`0 0 ${v} ${k}`,xmlns:"http://www.w3.org/2000/svg",style:{fontFamily:"var(--archik-font, system-ui)"},children:[(0,$0.jsxs)("defs",{children:[(0,$0.jsx)(r3r,{id:Sge}),(0,$0.jsx)(i3r,{id:_ge})]}),g.map(T=>(0,$0.jsx)(han,{participant:T},T.id)),g.map(T=>(0,$0.jsx)(lan,{participant:T,...T.kind!==void 0?{nodeKind:T.kind}:{}},T.id)),(0,$0.jsxs)("g",{transform:`translate(0, ${56})`,children:[b.map(T=>(0,$0.jsx)("rect",{x:T.cx-8/2,y:T.startY,width:8,height:T.endY-T.startY,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1,rx:2},`${T.cx}-${T.startY}`)),f.map(T=>(0,$0.jsx)(wan,{step:T,...d!==void 0?{onRefClick:d}:{}},T.id))]})]})}var LL=Ai(sc(),1),Vf=28;function Yq({kind:o,iconAt:c,labelAt:d}){let g=jw[o],f=g.icon,b=14;return(0,LL.jsxs)(LL.Fragment,{children:[(0,LL.jsx)("g",{transform:`translate(${c.cx-b/2}, ${c.cy-b/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,LL.jsx)(f,{size:b,color:g.color,strokeWidth:1.8})}),(0,LL.jsx)("text",{x:d.cx,y:d.cy,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.toUpperCase()})]})}var EL=Ai(sc(),1),o3r=24;function van({node:o,selected:c}){let d=o.width,g=o.height,f=o.stack!==void 0,b=Vf+(g-Vf)/2,v=f?b-4:b+4,k=b+14,T=Math.max(0,d-o3r),N=Gf(o.name,T,7.4),j=f?Gf(o.stack,T,5.9):"";return(0,EL.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,EL.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:d,height:g,rx:10,ry:10,fill:"var(--archik-node-fill)",stroke:c?"var(--archik-selected)":"var(--archik-node-stroke)",strokeWidth:c?1.8:1.4}),(0,EL.jsx)("line",{x1:0,y1:Vf,x2:d,y2:Vf,stroke:"var(--archik-node-stroke)",strokeOpacity:.25,strokeWidth:1}),(0,EL.jsx)(Yq,{kind:o.kind,iconAt:{cx:18,cy:Vf/2},labelAt:{cx:d/2,cy:Vf/2+3}}),(0,EL.jsx)("text",{x:d/2,y:v,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:N}),f&&(0,EL.jsx)("text",{x:d/2,y:k,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:j})]})}var TL=Ai(sc(),1);function kan({node:o,selected:c}){let d=o.width,g=o.height,f=Math.min(g/2,28),b=o.stack!==void 0,v=Vf+(g-Vf)/2,k=b?v-4:v+4,T=v+14,N=Math.max(0,d-2*f-8),j=Gf(o.name,N,7.4),B=b?Gf(o.stack,N,5.9):"",G=c?"var(--archik-selected)":"var(--archik-node-stroke)";return(0,TL.jsxs)("g",{className:"archik-node archik-node--queue",children:[(0,TL.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:d,height:g,rx:f,ry:f,fill:"var(--archik-node-fill)",stroke:G,strokeWidth:c?1.8:1.4}),(0,TL.jsx)("line",{x1:f,y1:Vf,x2:d-f,y2:Vf,stroke:G,strokeOpacity:.25,strokeWidth:1}),(0,TL.jsx)(Yq,{kind:"queue",iconAt:{cx:f+8,cy:Vf/2},labelAt:{cx:d/2,cy:Vf/2+3}}),(0,TL.jsx)("text",{x:d/2,y:k,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:j}),b&&(0,TL.jsx)("text",{x:d/2,y:T,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:B})]})}var AL=Ai(sc(),1),c3r=24;function Man({node:o,selected:c}){let d=o.width,g=o.height,f=o.description!==void 0,b=Vf,v=b+(g-b)/2,k=f?v-2:v+4,T=g-12,N=Math.max(0,d-c3r),j=Gf(o.name,N,7.4),B=f?Gf(o.description,N,5.9):"",G=c?"var(--archik-selected)":"var(--archik-node-stroke-soft)";return(0,AL.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,AL.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:d,height:g,rx:8,ry:8,fill:"var(--archik-node-fill-tinted)",stroke:G,strokeWidth:c?1.8:1.2,strokeDasharray:c?void 0:"6 4"}),(0,AL.jsx)("line",{x1:6,y1:Vf,x2:d-6,y2:Vf,stroke:G,strokeOpacity:.25,strokeWidth:1}),(0,AL.jsx)(Yq,{kind:o.kind,iconAt:{cx:18,cy:Vf/2},labelAt:{cx:d/2,cy:Vf/2+3}}),(0,AL.jsx)("text",{x:d/2,y:k,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:j}),f&&(0,AL.jsx)("text",{x:d/2,y:T,textAnchor:"middle",fontSize:10,fill:"var(--archik-node-text-dim)",children:B})]})}var e6=Ai(sc(),1),a3r=28,jft=10,s3r=22;function xan({node:o,selected:c}){let d=o.width,g=o.height,f=d/2,b=jft,v=jw[o.kind],k=v.icon,T=c?"var(--archik-selected)":"var(--archik-node-stroke)",N=c?1.8:1.4,j=o.stack!==void 0,B=Math.max(0,d-a3r),G=Gf(o.name,B,7.4),K=j?Gf(o.stack,B,5.9):"",de=g,ce=de-s3r,be=(ce+de)/2,Mt=(b+8+ce)/2,Ce=j?Mt-4:Mt+4,st=Mt+14;return(0,e6.jsxs)("g",{className:"archik-node archik-node--database",children:[(0,e6.jsx)("path",{className:c?"archik-selected-glow":void 0,d:Bft(d,g,b),fill:"var(--archik-node-fill)",stroke:T,strokeWidth:N,strokeLinejoin:"round"}),(0,e6.jsx)("ellipse",{cx:f,cy:b,rx:d/2,ry:b,fill:"var(--archik-node-fill)",stroke:T,strokeWidth:N}),(0,e6.jsx)("text",{x:f,y:Ce,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"var(--archik-node-text)",children:G}),j&&(0,e6.jsx)("text",{x:f,y:st,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:K}),(0,e6.jsx)("line",{x1:4,y1:ce,x2:d-4,y2:ce,stroke:T,strokeOpacity:.45,strokeWidth:1}),(0,e6.jsx)("g",{transform:`translate(14, ${be-7})`,pointerEvents:"none","aria-hidden":"true",children:(0,e6.jsx)(k,{size:14,color:v.color,strokeWidth:1.9})}),(0,e6.jsx)("text",{x:f,y:be+4,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()})]})}var u3r=10;function Bft(o,c,d){let g=u3r;return[`M 0 ${d}`,`L 0 ${c-g}`,`A ${g} ${g} 0 0 0 ${g} ${c}`,`L ${o-g} ${c}`,`A ${g} ${g} 0 0 0 ${o} ${c-g}`,`L ${o} ${d}`,`A ${o/2} ${d} 0 0 0 0 ${d}`,"Z"].join(" ")}var cS=Ai(sc(),1),l3r=36,San=18;function _an({node:o,selected:c}){let d=o.width,g=o.height,f=jw[o.kind],b=f.icon,v=c?"var(--archik-selected)":"var(--archik-node-stroke)",k=c?1.8:1.4,T=o.stack!==void 0,N=Math.max(0,d-l3r),j=Gf(o.name,N,7.4),B=T?Gf(o.stack,N,5.9):"",G=d/2,K=g*.55,de=T?K-4:K+4,ce=K+14;return(0,cS.jsxs)("g",{className:"archik-node archik-node--cloud",children:[(0,cS.jsx)("path",{className:c?"archik-selected-glow":void 0,d:h3r(d,g),fill:"var(--archik-node-fill)",stroke:v,strokeWidth:k,strokeLinejoin:"round"}),(0,cS.jsx)("g",{transform:`translate(18, ${San-6})`,pointerEvents:"none","aria-hidden":"true",children:(0,cS.jsx)(b,{size:14,color:f.color,strokeWidth:1.9})}),(0,cS.jsx)("text",{x:G,y:San+4,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()}),(0,cS.jsx)("text",{x:G,y:de,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:j}),T&&(0,cS.jsx)("text",{x:G,y:ce,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:B})]})}function h3r(o,c){let g=c-2,f=c*.62,b=Math.min(c*.18,14),v=o-4,k=c*.5,T=Math.min(v*.15,k*.85),N=Math.min(v*.18,k),j=Math.min(v*.15,k*.85),B=2*(T+N+j),G=Math.max(0,v-B)/4,K=2,de=o-2,ce=K+G,be=ce+2*T,Re=be+G,at=Re+2*N,Mt=at+G,Ce=Mt+2*j;return[`M ${K} ${g-b}`,`Q ${K} ${g} ${K+b} ${g}`,`L ${de-b} ${g}`,`Q ${de} ${g} ${de} ${g-b}`,`L ${de} ${f}`,`L ${Ce} ${f}`,`A ${j} ${j} 0 0 0 ${Mt} ${f}`,`L ${at} ${f}`,`A ${N} ${N} 0 0 0 ${Re} ${f}`,`L ${be} ${f}`,`A ${T} ${T} 0 0 0 ${ce} ${f}`,`L ${K} ${f}`,"Z"].join(" ")}var rb=Ai(sc(),1),Qq=32,FDe=14,Hft=14;function Can({node:o,selected:c,depth:d=0}){let g=o.width,f=o.height;if(!(o.children.length>0))return(0,rb.jsx)(f3r,{node:o,selected:!!c});let v=jw[o.kind],k=v.icon,T=Math.min(.04+d*.06,.22),N=Math.min(.55+d*.12,.95),j=c?"var(--archik-selected)":"var(--archik-container-border)",B=c?1.8:1.2,G=Math.max(0,g-FDe*2-60),K=Gf(o.name,G,7.4);return(0,rb.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--container`,children:[(0,rb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:g,height:f,rx:8,ry:8,fill:v.color,fillOpacity:T,stroke:j,strokeWidth:B,pointerEvents:"none"}),d>=1&&g>8&&f>8&&(0,rb.jsx)("rect",{x:3,y:3,width:g-6,height:f-6,rx:6,ry:6,fill:"none",stroke:v.color,strokeOpacity:Math.min(.18+(d-1)*.06,.32),strokeWidth:1,pointerEvents:"none"}),(0,rb.jsx)("path",{d:d3r(g,Qq,8),fill:v.color,fillOpacity:N*.18}),(0,rb.jsx)("line",{x1:0,y1:Qq,x2:g,y2:Qq,stroke:j,strokeOpacity:.45,strokeWidth:1}),(0,rb.jsx)("g",{transform:`translate(${FDe}, ${Qq/2-Hft/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,rb.jsx)(k,{size:Hft,color:v.color,strokeWidth:1.9})}),(0,rb.jsx)("text",{x:FDe+Hft+8,y:Qq/2+4,fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:K}),(0,rb.jsx)("text",{x:g-FDe,y:Qq/2+3,textAnchor:"end",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()})]})}function d3r(o,c,d){return`M ${d} 0 H ${o-d} A ${d} ${d} 0 0 1 ${o} ${d} V ${c} H 0 V ${d} A ${d} ${d} 0 0 1 ${d} 0 Z`}function f3r({node:o,selected:c}){let d=o.width,g=o.height,f=jw[o.kind],b=c?"var(--archik-selected)":"var(--archik-node-stroke-soft)";return(0,rb.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,rb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:d,height:g,rx:8,ry:8,fill:"var(--archik-node-fill-tinted)",stroke:b,strokeWidth:c?1.8:1.2,strokeDasharray:c?void 0:"5 4"}),(0,rb.jsx)("text",{x:d/2,y:g/2+4,textAnchor:"middle",fontSize:12,fontWeight:600,fill:f.color,children:o.name})]})}var ib=Ai(sc(),1),wte=24,Ian=10,$ft=28;function Lan({node:o,selected:c,depth:d=0}){let g=o.width,f=o.height,b=jw[o.kind],v=b.icon,k=o.kind==="external";if(o.children.length>0)return(0,ib.jsx)(p3r,{node:o,selected:!!c,depth:d});let T=c?"var(--archik-selected)":k?"var(--archik-node-stroke-soft)":"var(--archik-node-stroke)",N=k?"var(--archik-node-fill-tinted)":"var(--archik-node-fill)",j=o.kind==="queue"?Math.min(f/2,18):8;return(0,ib.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--compact`,children:[(0,ib.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:g,height:f,rx:j,ry:j,fill:N,stroke:T,strokeWidth:c?1.8:1.4,strokeDasharray:k&&!c?"5 4":void 0}),(0,ib.jsx)("g",{transform:`translate(${Ian}, ${f/2-7})`,pointerEvents:"none","aria-hidden":"true",children:(0,ib.jsx)(v,{size:13,color:b.color,strokeWidth:1.9})}),(0,ib.jsx)("text",{x:$ft,y:f/2+4,fontSize:12,fontWeight:600,fill:"var(--archik-node-text)",children:Gf(o.name,Math.max(0,g-$ft-8),5.9)})]})}function p3r({node:o,selected:c,depth:d}){let g=o.width,f=o.height,b=jw[o.kind],v=b.icon,k=Math.min(.04+d*.035,.14),T=Math.min(.55+d*.08,.85),N=c?"var(--archik-selected)":"var(--archik-container-border)",j=Math.max(0,g-12-22),B=Gf(o.name,j,5.9);return(0,ib.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--compact archik-node--container`,children:[(0,ib.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:g,height:f,rx:6,ry:6,fill:b.color,fillOpacity:k,stroke:N,strokeWidth:c?1.8:1.2}),(0,ib.jsx)("path",{d:g3r(g,wte,6),fill:b.color,fillOpacity:T*.18}),(0,ib.jsx)("line",{x1:0,y1:wte,x2:g,y2:wte,stroke:N,strokeOpacity:.45,strokeWidth:1}),(0,ib.jsx)("g",{transform:`translate(${Ian}, ${wte/2-6})`,pointerEvents:"none","aria-hidden":"true",children:(0,ib.jsx)(v,{size:12,color:b.color,strokeWidth:1.9})}),(0,ib.jsx)("text",{x:$ft,y:wte/2+4,fontSize:12,fontWeight:600,fill:"var(--archik-node-text)",children:B})]})}function g3r(o,c,d){return`M ${d} 0 H ${o-d} A ${d} ${d} 0 0 1 ${o} ${d} V ${c} H 0 V ${d} A ${d} ${d} 0 0 1 ${d} 0 Z`}var B9=Ai(Rft(),1),g1=Ai(sc(),1),y3r=12,b3r=18;function Ean({Icon:o,cx:c,cy:d,size:g=y3r,color:f,strokeWidth:b=1.8}){return(0,g1.jsx)("g",{transform:`translate(${c-g/2}, ${d-g/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,g1.jsx)(o,{size:g,color:f??"var(--archik-fg-dim)",strokeWidth:b})})}function Tan(o){return(0,g1.jsx)(Ean,{Icon:B9.Info,...o})}function Aan(o){return(0,g1.jsx)(Ean,{Icon:B9.StickyNote,...o})}function Pan({cx:o,cy:c,filePath:d,fileLabel:g,onClick:f,size:b=13}){return(0,g1.jsxs)("g",{transform:`translate(${o-b/2}, ${c-b/2})`,style:{cursor:f?"pointer":"default"},onClick:f,children:[(0,g1.jsx)("title",{children:`Cross-file edge \u2192 ${g} (${d})`}),(0,g1.jsx)("circle",{cx:b/2,cy:b/2,r:b/2+.5,fill:"var(--archik-fg-dim)",fillOpacity:.12,stroke:"var(--archik-fg-dim)",strokeOpacity:.4,strokeWidth:1}),(0,g1.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,g1.jsx)(B9.ArrowUpRight,{size:b-2,color:"var(--archik-fg-muted)",strokeWidth:2.2})})]})}function Nan({cx:o,cy:c,onClick:d,size:g=14}){return(0,g1.jsxs)("g",{transform:`translate(${o-g/2}, ${c-g/2})`,style:{cursor:d?"pointer":"default"},onClick:d,children:[(0,g1.jsx)("title",{children:"Open sub-architecture"}),(0,g1.jsx)("circle",{cx:g/2,cy:g/2,r:g/2+.5,fill:"var(--archik-accent)",fillOpacity:.16,stroke:"var(--archik-accent)",strokeOpacity:.45,strokeWidth:1}),(0,g1.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,g1.jsx)(B9.ChevronDown,{size:g-2,color:"var(--archik-accent)",strokeWidth:2.2})})]})}function Ran({cx:o,cy:c,files:d,count:g,size:f=14}){let b=d.length===1?`Open sequence diagram \u2192 ${d[0].label} (${d[0].path})`:`${d.length} sequence diagrams on this node:
505
505
  `+d.map(v=>` \u2022 ${v.label}`).join(`
506
506
  `)+`
507
507
  Click to open the first; the rest live in the inspector.`;return(0,g1.jsxs)("g",{transform:`translate(${o-f/2}, ${c-f/2})`,style:{cursor:"pointer"},children:[(0,g1.jsx)("title",{children:b}),(0,g1.jsx)("circle",{cx:f/2,cy:f/2,r:f/2+.5,fill:"var(--archik-status-proposed)",fillOpacity:.16,stroke:"var(--archik-status-proposed)",strokeOpacity:.5,strokeWidth:1}),(0,g1.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,g1.jsx)(B9.GitBranch,{size:f-2,color:"var(--archik-status-proposed)",strokeWidth:2.2})}),g!==void 0&&g>1&&(0,g1.jsxs)("g",{pointerEvents:"none",children:[(0,g1.jsx)("circle",{cx:f/2,cy:-3,r:5.5,fill:"var(--archik-canvas)"}),(0,g1.jsx)("circle",{cx:f/2,cy:-3,r:4.5,fill:"var(--archik-status-proposed)"}),(0,g1.jsx)("text",{x:f/2,y:-.5,fontSize:7.5,fontWeight:700,fill:"#ffffff",textAnchor:"middle",children:g})]})]})}function Dan(o,c,d,g=!1){if(g)return{right:{x:c-14,y:42}};switch(o){case"queue":{let b=Math.min(d/2,28);return{right:{x:c-b-4,y:14}}}case"database":return{right:{x:c-14,y:d-11}};case"module":case"custom":return{right:{x:c-14,y:42}};default:return{right:{x:c-14,y:14}}}}function Oan(o,c){return Array.from({length:c},(d,g)=>({x:o.x-g*b3r,y:o.y}))}var ru=Ai(sc(),1);function w3r({node:o,selected:c,viewMode:d,depth:g}){if(d==="compact")return(0,ru.jsx)(Lan,{node:o,selected:c,depth:g});if(o.children.length>0)return(0,ru.jsx)(Can,{node:o,selected:c,depth:g});switch(o.kind){case"queue":return(0,ru.jsx)(kan,{node:o,selected:c});case"external":case"human":return(0,ru.jsx)(Man,{node:o,selected:c});case"database":return(0,ru.jsx)(xan,{node:o,selected:c});case"cloud":return(0,ru.jsx)(_an,{node:o,selected:c});case"module":case"custom":case"service":case"function":case"worker":case"agent":case"cache":case"vectordb":case"storage":case"topic":case"stream":case"gateway":case"cdn":case"route":case"interface":case"adapter":case"port":case"llm":case"prompt":case"tool":case"auth":case"observability":case"frontend":case"page":case"component":case"store":case"hook":return(0,ru.jsx)(van,{node:o,selected:c});default:{let f=o.kind;throw new Error("unreachable node kind")}}}function Uft({node:o,selectedNodeIds:c,glowNodeIds:d,onSelectNode:g,onOpenSubFile:f,onCrossFileNavigate:b,crossFileByNode:v,viewMode:k="detailed",depth:T=0,showStereotypeBands:N=!0}){let j=c?.has(o.id)??!1,B=d?.has(o.id)??!1,G=o.children.length>0,K=G?T+1:T,de=g?be=>{be.stopPropagation(),g(o.id,be)}:void 0,ce=o.description!==void 0&&o.description.length>0;return(0,ru.jsxs)("g",{"data-archik-node-id":o.id,...j?{"data-archik-selected":"true"}:{},...o.status!==void 0&&o.status!=="active"?{"data-archik-status":o.status}:{},...o.stereotype!==void 0?{"data-archik-stereotype":o.stereotype}:{},transform:`translate(${o.x}, ${o.y})`,...de!==void 0?{onClick:de}:{},style:g?{cursor:"pointer"}:void 0,children:[B&&(0,ru.jsx)("rect",{x:-4,y:-4,width:o.width+8,height:o.height+8,rx:10,fill:"none",stroke:"var(--archik-status-proposed)",strokeWidth:2,opacity:.85,style:{pointerEvents:"none"}}),(0,ru.jsx)(w3r,{node:o,selected:j,viewMode:k,depth:T}),o.stereotype!==void 0&&N&&(0,ru.jsxs)(ru.Fragment,{children:[(0,ru.jsx)("clipPath",{id:`archik-nclip-${o.id}`,children:o.kind==="database"?(0,ru.jsx)("path",{d:Bft(o.width,o.height,jft)}):(0,ru.jsx)("rect",{width:o.width,height:o.height,rx:8,ry:8})}),(0,ru.jsx)("rect",{className:"archik-stereotype-band",x:0,y:0,width:o.width,height:4,clipPath:`url(#archik-nclip-${o.id})`,style:{pointerEvents:"none"}})]}),k==="detailed"&&(()=>{let be=o.notes!==void 0&&o.notes.length>0,Re=o.archikFile!==void 0&&o.archikFile.length>0,at=v?.get(o.id),Mt=at?Array.from(at).sort():[],Ce=o.seqFiles??[],st=[];Re&&st.push("subarch"),Ce.length>0&&st.push({type:"seq",paths:Ce});for(let Jt of Mt)st.push({type:"crossfile",path:Jt});if(ce&&st.push("info"),be&&st.push("notes"),st.length===0)return null;let Le=Dan(o.kind,o.width,o.height,G),tn=Oan(Le.right,st.length);return(0,ru.jsx)(ru.Fragment,{children:st.map((Jt,or)=>{let Xn=tn[or];if(typeof Jt=="object"&&Jt.type==="seq"){let br=Jt.paths.map(Hr=>({path:Hr,label:Hr.split("/").pop().replace(/\.archik\.seq\.yaml$/,"")})),gn=`/__archik/seq?path=${encodeURIComponent(br[0].path)}`;return(0,ru.jsx)("a",{href:gn,onClick:Hr=>Hr.stopPropagation(),children:(0,ru.jsx)(Ran,{cx:Xn.x,cy:Xn.y,files:br,count:br.length})},"seq")}if(typeof Jt=="object"&&Jt.type==="crossfile"){let br=Jt.path,gn=br.split("/").pop().replace(/\.archik\.yaml$/,""),Hr=b??f,vi=Hr?xo=>{xo.stopPropagation(),Hr(br,gn)}:void 0;return(0,ru.jsx)(Pan,{cx:Xn.x,cy:Xn.y,filePath:br,fileLabel:gn,...vi?{onClick:vi}:{}},`xf-${br}`)}if(Jt==="subarch"){let br=o.archikFile,gn=f?Hr=>{Hr.stopPropagation(),f(br,o.name)}:void 0;return(0,ru.jsx)(Nan,{cx:Xn.x,cy:Xn.y,...gn?{onClick:gn}:{}},"subarch")}return Jt==="info"?(0,ru.jsx)(Tan,{cx:Xn.x,cy:Xn.y,color:"var(--archik-node-caption)"},"info"):(0,ru.jsxs)("g",{children:[(0,ru.jsx)(Aan,{cx:Xn.x,cy:Xn.y,color:"var(--archik-node-caption)"}),o.notes&&o.notes.length>1&&(0,ru.jsx)("text",{x:Xn.x+7,y:Xn.y-5,fontSize:8,fontWeight:700,fill:"var(--archik-accent)",textAnchor:"middle",pointerEvents:"none",children:o.notes.length})]},"notes")})})})(),o.children.map(be=>(0,ru.jsx)(Uft,{node:be,viewMode:k,depth:K,showStereotypeBands:N,...c!==void 0?{selectedNodeIds:c}:{},...d!==void 0?{glowNodeIds:d}:{},...g!==void 0?{onSelectNode:g}:{},...f!==void 0?{onOpenSubFile:f}:{},...b!==void 0?{onCrossFileNavigate:b}:{},...v!==void 0?{crossFileByNode:v}:{}},be.id))]})}var Pz=Ai(sc(),1),Bw="archik-arrow-filled",Az="archik-arrow-open",qft="archik-arrow-selected",t6="var(--archik-edge-filled)",mte="var(--archik-edge-dim)",m3r={http_call:{stroke:t6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,markerId:Bw},grpc:{stroke:t6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,markerId:Bw},invokes:{stroke:t6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,markerId:Bw},routes_to:{stroke:t6,strokeWidth:1.4,markerId:Bw},websocket:{stroke:t6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,markerId:Bw,markerStartId:Bw},webhook:{stroke:t6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,markerId:Bw},reads:{stroke:t6,strokeWidth:1.4,markerId:Az},writes:{stroke:t6,strokeWidth:1.4,markerId:Bw},publishes:{stroke:t6,strokeWidth:1.4,markerId:Bw},subscribes:{stroke:t6,strokeWidth:1.4,markerId:Bw},streams_to:{stroke:t6,strokeWidth:1.4,markerId:Bw},implements:{stroke:mte,strokeWidth:1.2,markerId:Az},extends:{stroke:mte,strokeWidth:1.2,markerId:Az},depends_on:{stroke:mte,strokeWidth:1.2,markerId:Az},has_a:{stroke:mte,strokeWidth:1.2,markerId:Bw},uses:{stroke:mte,strokeWidth:1.2,markerId:Az}};function Fan(o){return o.map(c=>`${c.x},${c.y}`).join(" ")}function v3r(o){if(o.length===0)return;let c=Math.floor(o.length/2);if(o.length%2===1)return o[c];let d=o[c-1],g=o[c];return{x:(d.x+g.x)/2,y:(d.y+g.y)/2}}function zan({edge:o,selectedEdgeIds:c,onSelectEdge:d}){let g=o.sections[0];if(!g)return null;let f=[g.startPoint,...g.bendPoints,g.endPoint],b=m3r[o.relationship],v=o.labels[0],k=v?{x:v.x+v.width/2,y:v.y+v.height/2}:v3r(f),T=c?.has(o.id)??!1,N=o.status==="proposed"?"var(--archik-status-proposed)":o.status==="deprecated"?"var(--archik-status-deprecated)":void 0,j=T?"var(--archik-selected)":N??o.color??b.stroke,B=T?b.strokeWidth+.5:b.strokeWidth,G=T?qft:b.markerId,K=!T&&b.markerStartId!==void 0?b.markerStartId:void 0,de=!T&&b.animated?"archik-edge-flowing":void 0,ce=b.strokeDasharray!==void 0?b.strokeDasharray.trim().split(/\s+/).reduce((at,Mt)=>at+Number(Mt),0):0,be=de!==void 0&&ce>0?{"--archik-dash-period":String(ce)}:void 0,Re=d?at=>{at.stopPropagation(),d(o.id,at)}:void 0;return(0,Pz.jsxs)("g",{"data-archik-edge-id":o.id,"data-archik-edge-relationship":o.relationship,...T?{"data-archik-selected":"true"}:{},...o.status!==void 0&&o.status!=="active"?{"data-archik-status":o.status}:{},className:`archik-edge archik-edge--${o.relationship}`,...Re!==void 0?{onClick:Re}:{},style:d?{cursor:"pointer"}:void 0,children:[d&&(0,Pz.jsx)("polyline",{"data-archik-edge-hitarea":"",points:Fan(f),fill:"none",stroke:"transparent",strokeWidth:14,strokeLinecap:"round",strokeLinejoin:"round"}),(0,Pz.jsx)("polyline",{className:de,points:Fan(f),fill:"none",stroke:j,strokeWidth:B,strokeLinecap:"round",strokeLinejoin:"round",markerEnd:`url(#${G})`,...K!==void 0?{markerStart:`url(#${K})`}:{},...b.strokeDasharray!==void 0?{strokeDasharray:b.strokeDasharray}:{},...be!==void 0?{style:be}:{}}),o.label!==void 0&&k!==void 0&&(0,Pz.jsx)("g",{transform:`translate(${k.x}, ${v?k.y+4:k.y-6})`,children:(0,Pz.jsx)("text",{textAnchor:"middle",fontSize:11,fontWeight:T?700:500,fill:T?"var(--archik-selected)":"var(--archik-fg-dim)",stroke:"var(--archik-panel)",strokeWidth:T?4:3,paintOrder:"stroke",children:o.label})})]})}var ob=Ai(sc(),1);var Gft={added:"var(--archik-success)",removed:"var(--archik-danger)",changed:"var(--archik-warning)"};function k3r(o){let c=[],d=(g,f,b)=>{for(let v of g){let k=f+v.x,T=b+v.y;c.push({...v,absX:k,absY:T}),v.children.length>0&&d(v.children,k,T)}};return d(o,0,0),c}function M3r(o){return o.replace(/[^a-z0-9-]/g,c=>`\\${c}`)}function Han({statuses:o,scopeClass:c}){let d=[];for(let[f,b]of o.nodes)b==="removed"&&d.push(f);if(d.length===0)return null;let g=d.map(f=>`.${c} [data-archik-node-id="${M3r(f)}"] { opacity: 0.35; }`).join(`
@@ -223,4 +223,4 @@ ${MXn(p)}
223
223
  `)}function NXn(h,b){const p=b.get(h.from)?.name??h.from,v=b.get(h.to)?.name??h.to,T=h.label!==void 0?`: ${h.label}`:"",M=h.status&&h.status!=="active"?` _(${h.status})_`:"";return`- ${p} **${h.relationship}** ${v}${T}${M}`}function IXn(h){const b=new Map;for(const v of h.nodes)b.set(v.id,v);const p=[];if(p.push(`# ${h.name}`),h.description!==void 0&&p.push("",h.description),p.push("","## Components"),h.nodes.length===0)p.push("","_No components yet._");else for(const v of h.nodes)p.push("",_Xn(v));if(p.push("","## Connections"),h.edges.length===0)p.push("","_No connections yet._");else{p.push("");for(const v of h.edges)p.push(NXn(v,b))}return`${p.join(`
224
224
  `)}
225
225
  `}const DXn={name:"yaml",label:"YAML",extension:".yaml",mime:"application/yaml",export:G7e},$Xn={name:"json",label:"JSON",extension:".json",mime:"application/json",export:p0n},LXn={name:"markdown",label:"Markdown",extension:".md",mime:"text/markdown",export:IXn},RXn=[DXn,$Xn,LXn];function S0n({document:h,filename:b,getSvg:p}){const v=async j=>{try{await navigator.clipboard.writeText(j)}catch{}},T=()=>{const j=p?.();j&&g1n(w1n(b,"svg"),CXn(j))},M=async()=>{const j=p?.();if(j)try{const P=await OXn(j);g1n(w1n(b,"png"),P)}catch(P){console.error("PNG export failed:",P)}};return R.jsx(TT,{trigger:j=>R.jsxs("button",{type:"button",className:"archik-btn",children:["Export",R.jsx("span",{style:{opacity:.6},children:j?"▴":"▾"})]}),children:j=>R.jsxs(R.Fragment,{children:[h&&RXn.map(P=>R.jsxs("button",{type:"button",className:"archik-menu-item",onClick:()=>{v(P.export(h)),j()},children:[R.jsx("span",{style:{minWidth:60,color:"var(--archik-fg-dim)"},children:"Copy"}),R.jsx("span",{children:P.label})]},P.name)),h&&R.jsxs(R.Fragment,{children:[R.jsx("hr",{style:{border:0,borderTop:"1px solid var(--archik-border)",margin:"4px 0"}}),R.jsxs("button",{type:"button",className:"archik-menu-item",onClick:()=>{qZn(b,h),j()},children:[R.jsx("span",{style:{minWidth:60,color:"var(--archik-fg-dim)"},children:"Download"}),R.jsx("span",{children:"YAML"})]})]}),p&&R.jsxs(R.Fragment,{children:[R.jsxs("button",{type:"button",className:"archik-menu-item",onClick:()=>{T(),j()},children:[R.jsx("span",{style:{minWidth:60,color:"var(--archik-fg-dim)"},children:"Download"}),R.jsx("span",{children:"SVG"})]}),R.jsxs("button",{type:"button",className:"archik-menu-item",onClick:()=>{M(),j()},children:[R.jsx("span",{style:{minWidth:60,color:"var(--archik-fg-dim)"},children:"Download"}),R.jsx("span",{children:"PNG"})]})]})]})})}const E0n="archik-density",A0n="archik-view-mode",T0n="archik-show-stereotype-bands",dI=1,R8e="detailed",P8e=!1;function PXn(){if(typeof localStorage>"u")return P8e;try{const h=localStorage.getItem(T0n);return h==="true"?!0:h==="false"?!1:P8e}catch{return P8e}}function zXn(h){if(!(typeof localStorage>"u"))try{localStorage.setItem(T0n,h?"true":"false")}catch{}}function BXn(){if(typeof localStorage>"u")return R8e;try{return localStorage.getItem(A0n)==="compact"?"compact":R8e}catch{return R8e}}function FXn(h){if(!(typeof localStorage>"u"))try{localStorage.setItem(A0n,h)}catch{}}function qXn(){if(typeof localStorage>"u")return dI;try{const h=localStorage.getItem(E0n);if(!h)return dI;const b=Number.parseFloat(h);return Number.isFinite(b)?J7e(b):dI}catch{return dI}}function GXn(h){if(!(typeof localStorage>"u"))try{localStorage.setItem(E0n,String(J7e(h)))}catch{}}function J7e(h){return Math.max(.3,Math.min(4,h))}function UXn(h){const b=J7e(h);return{nodeSpacing:Math.round(60*b),layerSpacing:Math.round(100*b),padding:Math.round(40*b)}}function JXn({density:h,onChange:b}){const p=Math.round(h*100);return R.jsx(TT,{align:"end",trigger:v=>R.jsxs("button",{type:"button",className:"archik-btn","aria-expanded":v,title:"Layout density",children:["Spacing",R.jsxs("span",{style:{opacity:.6},children:[p,"%"]})]}),children:()=>R.jsxs("div",{style:{minWidth:240,padding:8},children:[R.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:6},children:[R.jsx("span",{className:"archik-label",style:{margin:0},children:"Node spacing"}),R.jsxs("span",{className:"archik-mono",style:{fontSize:11,color:"var(--archik-fg-dim)"},children:[p,"%"]})]}),R.jsx("input",{type:"range",min:.3,max:4,step:.1,value:h,onChange:v=>b(Number.parseFloat(v.target.value)),style:{width:"100%",accentColor:"var(--archik-accent)"}}),R.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:10,color:"var(--archik-fg-muted)",marginTop:4},children:[R.jsx("span",{children:"tight"}),R.jsx("span",{children:"roomy"})]}),R.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:10},children:R.jsx("button",{type:"button",className:"archik-btn",onClick:()=>b(dI),disabled:h===dI,children:"Reset"})})]})})}function HXn(){return R.jsx(TT,{align:"end",trigger:h=>R.jsxs("button",{type:"button",className:"archik-btn","aria-expanded":h,children:["Legend",R.jsx("span",{style:{opacity:.6},children:h?"▴":"▾"})]}),children:()=>R.jsxs("div",{style:{minWidth:320,maxHeight:"min(70vh, 520px)",overflowY:"auto",padding:6},children:[R.jsx("div",{style:{position:"sticky",top:0,background:"var(--archik-panel)",fontSize:10,letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--archik-fg-muted)",padding:"4px 6px 8px",zIndex:1},children:"Node kinds"}),q7e.map(h=>{const b=Np[h],p=b.icon;return R.jsxs("div",{style:{display:"grid",gridTemplateColumns:"20px 80px 1fr",alignItems:"center",gap:8,padding:"5px 6px",fontSize:12},children:[R.jsx("span",{"aria-hidden":"true",style:{display:"flex",alignItems:"center",justifyContent:"center",color:b.color},children:R.jsx(p,{size:14,strokeWidth:1.8})}),R.jsx("code",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--archik-fg)",fontSize:11},children:h}),R.jsx("span",{style:{color:"var(--archik-fg-dim)"},children:b.description})]},h)}),R.jsx(ZXn,{})]})})}const KXn=[{id:"boundary",varName:"--archik-stereotype-boundary",description:"talks to actors / external systems (UIs, adapters)"},{id:"control",varName:"--archik-stereotype-control",description:"orchestration logic between boundaries and entities"},{id:"entity",varName:"--archik-stereotype-entity",description:"long-lived domain state (modules, databases)"}];function ZXn(){return R.jsxs(R.Fragment,{children:[R.jsx("div",{style:{position:"sticky",top:0,background:"var(--archik-panel)",fontSize:10,letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--archik-fg-muted)",padding:"12px 6px 8px",marginTop:6,borderTop:"1px solid var(--archik-border)"},children:"Stereotype (ECB)"}),KXn.map(h=>R.jsxs("div",{style:{display:"grid",gridTemplateColumns:"20px 80px 1fr",alignItems:"center",gap:8,padding:"5px 6px",fontSize:12},children:[R.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:12,height:12,borderRadius:3,background:`var(${h.varName})`}}),R.jsx("code",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--archik-fg)",fontSize:11},children:h.id}),R.jsx("span",{style:{color:"var(--archik-fg-dim)"},children:h.description})]},h.id))]})}function XXn({size:h=22}){return R.jsxs("svg",{width:h,height:h,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Archik",style:{display:"block"},children:[R.jsx("path",{d:"M 12 5 L 5 18",stroke:"var(--archik-accent)",strokeWidth:"1.4",strokeLinecap:"round"}),R.jsx("path",{d:"M 12 5 L 19 18",stroke:"var(--archik-accent-bright)",strokeWidth:"1.4",strokeLinecap:"round"}),R.jsx("path",{d:"M 5 18 L 19 18",stroke:"var(--archik-magenta)",strokeWidth:"1.2",strokeLinecap:"round",strokeDasharray:"2.5 2.5"}),R.jsx("circle",{cx:"12",cy:"5",r:"2.6",fill:"var(--archik-accent)"}),R.jsx("circle",{cx:"5",cy:"18",r:"2.6",fill:"var(--archik-accent-bright)"}),R.jsx("circle",{cx:"19",cy:"18",r:"2.6",fill:"var(--archik-magenta)"})]})}const VXn="archik-theme";function a7e(){return typeof document>"u"?"dark":document.documentElement.getAttribute("data-theme")==="light"?"light":"dark"}function WXn(h){if(!(typeof document>"u")){document.documentElement.setAttribute("data-theme",h);try{localStorage.setItem(VXn,h)}catch{}}}function YXn(){const h=a7e()==="dark"?"light":"dark";return WXn(h),h}function QXn(){const[h,b]=lt.useState(()=>a7e());lt.useEffect(()=>{b(a7e())},[]);const p=()=>{b(YXn())},v=h==="dark"?"Light theme":"Dark theme",T=h==="dark"?"☀":"☾";return R.jsx("button",{type:"button",onClick:p,title:v,"aria-label":v,className:"archik-btn",style:{minWidth:30,justifyContent:"center"},children:R.jsx("span",{"aria-hidden":"true",children:T})})}const eVn="/__archik/usecases",nVn="/__archik/trace";async function p1n(h,b){const p=await fetch(h,{cache:"no-store",signal:b});if(!p.ok)throw new Error(`HTTP ${p.status} ${p.statusText}`);return await p.json()}function tVn(){const[h,b]=lt.useState({status:"loading"}),[p,v]=lt.useState(0);return lt.useEffect(()=>{let T=!1;const M=new AbortController;return Promise.all([p1n(eVn,M.signal),p1n(nVn,M.signal)]).then(([j,P])=>{T||b({status:"ready",useCases:j.useCases??[],trace:P.rows??[]})}).catch(j=>{T||M.signal.aborted||b({status:"error",message:j instanceof Error?j.message:String(j)})}),()=>{T=!0,M.abort()}},[p]),R.jsx(TT,{align:"end",trigger:T=>R.jsxs("button",{type:"button",className:"archik-btn","aria-expanded":T,onClick:()=>{T||v(M=>M+1)},children:[R.jsx(iVn,{state:h}),R.jsx("span",{style:{opacity:.6,marginLeft:6},children:T?"▴":"▾"})]}),children:()=>R.jsx(rVn,{state:h})})}function iVn({state:h}){if(h.status!=="ready"||h.trace.length===0)return R.jsx(R.Fragment,{children:"Use cases"});const b=x0n(h.trace);return b.none>0?R.jsxs("span",{title:`${b.none} untraced — needs tests + seq`,children:["Use cases"," ",R.jsxs("span",{style:{color:"var(--archik-danger)"},children:["○ ",b.none," untraced"]})]}):b.partial>0?R.jsxs("span",{title:`${b.partial} partial — missing test or realisation`,children:["Use cases"," ",R.jsxs("span",{style:{color:"var(--archik-warning)"},children:["◐ ",b.partial," to finish"]})]}):R.jsxs("span",{title:`All ${b.full} slices traced — ready to ship`,children:["Use cases"," ",R.jsx("span",{style:{color:"var(--archik-success)",fontWeight:600},children:"✓ all traced"})]})}function x0n(h){let b=0,p=0,v=0;for(const T of h)T.level==="full"?b++:T.level==="partial"?p++:v++;return{full:b,partial:p,none:v}}function rVn({state:h}){return R.jsxs("div",{style:{minWidth:360,maxHeight:"min(70vh, 560px)",overflowY:"auto",padding:6},children:[R.jsx(aVn,{label:"Use cases",children:R.jsx("a",{href:"/__archik/usecases",style:{fontSize:10,letterSpacing:"0.04em",textTransform:"none",color:"var(--archik-accent)",textDecoration:"none",fontWeight:500},title:"Open the full use cases page (clickable test paths + seq links)",children:"Open page →"})}),h.status==="loading"&&R.jsx(z8e,{children:"Loading…"}),h.status==="error"&&R.jsxs(z8e,{tone:"error",children:["Couldn't load: ",h.message]}),h.status==="ready"&&h.useCases.length===0&&R.jsxs(z8e,{children:["No use cases defined. Add a ",R.jsx("code",{children:"*.archik.uc.yaml"})," file under"," ",R.jsx("code",{children:".archik/usecases/"}),"."]}),h.status==="ready"&&h.useCases.length>0&&R.jsxs(R.Fragment,{children:[R.jsx(cVn,{trace:h.trace}),R.jsx(uVn,{useCases:h.useCases,trace:h.trace})]})]})}function cVn({trace:h}){const b=lt.useMemo(()=>x0n(h),[h]),p=h.length;return p===0?R.jsx(R.Fragment,{}):R.jsxs("div",{title:"Coverage matrix — same as `npx archik trace`. ● fully traced (test + seq), ◐ partial, ○ untraced.",style:{display:"flex",alignItems:"center",gap:12,padding:"6px 10px",margin:"2px 2px 6px",borderRadius:6,background:"var(--archik-surface)",fontSize:11,color:"var(--archik-fg-dim)"},children:[R.jsx("span",{style:{fontWeight:600,color:"var(--archik-fg)"},children:"Trace"}),R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-success)"},children:"●"})," ",b.full," full"]}),R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-warning)"},children:"◐"})," ",b.partial," partial"]}),R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"○"})," ",b.none," untraced"]}),R.jsxs("span",{style:{marginLeft:"auto",color:"var(--archik-fg-muted)"},children:[p," ",p===1?"slice":"slices"]})]})}function uVn({useCases:h,trace:b}){const p=lt.useMemo(()=>{const v=new Map;for(const T of b)v.set(`${T.useCase}/${T.slice}`,T.level);return v},[b]);return R.jsx("div",{children:h.map(v=>R.jsx(sVn,{uc:v,traceByKey:p},v.id))})}function sVn({uc:h,traceByKey:b}){return R.jsxs("div",{style:{padding:"8px 8px 6px",borderTop:"1px solid var(--archik-border)"},children:[R.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,marginBottom:2},children:[R.jsx("code",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,color:"var(--archik-fg)"},children:h.id}),R.jsx("span",{style:{color:"var(--archik-fg-dim)",fontSize:11},children:h.name}),h.status&&h.status!=="active"&&R.jsx("span",{className:"archik-pill",style:{fontSize:9,marginLeft:"auto"},children:h.status})]}),R.jsxs("div",{style:{color:"var(--archik-fg-muted)",fontSize:11},children:["primary ",R.jsx("code",{children:h.primaryActor}),h.secondaryActors&&h.secondaryActors.length>0&&R.jsxs(R.Fragment,{children:[" ","· secondary"," ",h.secondaryActors.map((p,v)=>R.jsxs("span",{children:[v>0&&", ",R.jsx("code",{children:p})]},p))]})]}),R.jsx("ul",{style:{marginTop:6,listStyle:"none",padding:0},children:h.slices.map(p=>{const v=b.get(`${h.id}/${p.id}`);return R.jsx(oVn,{slice:p,level:v},p.id)})})]})}function oVn({slice:h,level:b}){const[p,v]=lt.useState(!1);return R.jsxs("li",{style:{padding:"3px 0"},children:[R.jsxs("button",{type:"button",onClick:()=>v(T=>!T),className:"archik-btn",style:{display:"grid",gridTemplateColumns:"16px 1fr",alignItems:"center",gap:8,width:"100%",padding:"4px 6px",background:"transparent",border:"none",textAlign:"left",cursor:"pointer"},"aria-expanded":p,children:[R.jsx(fVn,{level:b}),R.jsxs("span",{style:{fontSize:12,color:"var(--archik-fg)",display:"flex",alignItems:"baseline",gap:6},children:[R.jsx("code",{children:h.id}),h.status&&h.status!=="active"&&R.jsxs("span",{style:{color:"var(--archik-fg-dim)",fontSize:10},children:["[",h.status,"]"]}),R.jsx("span",{style:{color:"var(--archik-fg-dim)",fontSize:11,marginLeft:"auto"},children:(()=>{const T=h.tests?.length??0,M=`${T} ${T===1?"test":"tests"}`,j=h.realization?"realized":"no seq";return`${M} • ${j}`})()})]})]}),p&&R.jsxs("div",{style:{paddingLeft:24,color:"var(--archik-fg-dim)",fontSize:11,paddingBottom:4},children:[R.jsx("div",{style:{color:"var(--archik-fg)",marginBottom:4,lineHeight:1.4},children:h.description}),h.tests&&h.tests.length>0&&R.jsxs("div",{children:["tests:"," ",h.tests.map((T,M)=>R.jsxs("code",{children:[M>0&&", ",T]},T))]}),h.realization&&R.jsxs("div",{children:["realises: ",R.jsx("code",{children:h.realization.seqFile})]}),!h.tests?.length&&!h.realization&&R.jsx("div",{children:"(no tests, no realisation)"})]})]})}const lVn={full:{glyph:"✓",tone:"var(--archik-status-active, #4ade80)",title:"fully traced"},partial:{glyph:"~",tone:"var(--archik-status-proposed, #fbbf24)",title:"partially traced"},none:{glyph:"✗",tone:"var(--archik-status-deprecated, #f87171)",title:"untraced"},missing:{glyph:"·",tone:"var(--archik-fg-dim)",title:"no trace data"}};function fVn({level:h}){const b=lVn[h??"missing"];return R.jsx("span",{title:b.title,"aria-label":b.title,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,fontSize:11,fontWeight:600,color:b.tone},children:b.glyph})}function aVn({label:h,children:b}){return R.jsxs("div",{style:{position:"sticky",top:0,background:"var(--archik-panel)",fontSize:10,letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--archik-fg-muted)",padding:"4px 6px 8px",zIndex:1,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[R.jsx("span",{children:h}),b]})}function z8e({children:h,tone:b}){return R.jsx("div",{style:{padding:"8px 8px 12px",fontSize:12,color:b==="error"?"var(--archik-status-deprecated, #f87171)":"var(--archik-fg-dim)"},children:h})}const hVn={idle:"",saving:"archik-pill archik-pill--info",saved:"archik-pill archik-pill--success",error:"archik-pill archik-pill--danger"},dVn={idle:null,saving:"Saving…",saved:"Saved",error:"Save failed"};function bVn({document:h,filename:b="architecture.archik.yaml",commandError:p,reloadError:v,saveStatus:T="idle",saveError:M,isDirty:j=!1,onSave:P,onAddNode:G,connectingFromName:J,onCancelConnect:se,density:re,onDensityChange:fe,viewMode:Ae,onViewModeChange:Ze,showStereotypeBands:ie,onToggleStereotypeBands:tn,canUndo:bn=!1,canRedo:_n=!1,onUndo:hn,onRedo:Rn,getSvg:rt,seqHighlight:dt,onToggleSeqHighlight:Wn,seqNodeCount:pt}){const wr=dVn[T],Wr=typeof navigator<"u"&&/Mac/i.test(navigator.platform)?"⌘S":"Ctrl+S";return R.jsxs("header",{className:"flex items-center gap-3 px-4 py-2.5",style:{background:"var(--archik-panel)",borderBottom:"1px solid var(--archik-border)"},children:[R.jsxs("div",{className:"flex items-center gap-2",children:[R.jsx(XXn,{}),R.jsx("span",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--archik-fg)",letterSpacing:"0.02em"},children:"Archik"})]}),R.jsx("span",{className:"archik-mono",style:{color:"var(--archik-fg-dim)",fontSize:11,opacity:.85},children:h.name}),J!==void 0&&R.jsxs("span",{className:"archik-pill archik-pill--info",children:["Connecting from ",R.jsx("strong",{children:J}),R.jsx("button",{type:"button",onClick:se,className:"underline hover:no-underline",style:{color:"var(--archik-accent)"},children:"cancel (Esc)"})]}),p!==void 0&&R.jsx("span",{className:"archik-pill archik-pill--danger",children:p}),v!==void 0&&R.jsx("span",{className:"archik-pill archik-pill--warning",title:v,children:"File reload error"}),wr!==null&&R.jsx("span",{className:hVn[T],...T==="error"&&M!==void 0?{title:M}:{},children:wr}),T==="error"&&M!==void 0&&R.jsx("span",{className:"archik-pill archik-pill--danger",style:{maxWidth:480,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",fontFamily:"ui-monospace, monospace",fontSize:11},title:M,children:gVn(M)}),R.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[hn!==void 0&&R.jsx("button",{type:"button",onClick:hn,disabled:!bn,title:`Undo (${Wr.replace("S","Z")})`,"aria-label":"Undo",className:"archik-btn",style:{padding:"5px 8px"},children:R.jsx(DFn,{size:14,strokeWidth:1.8})}),Rn!==void 0&&R.jsx("button",{type:"button",onClick:Rn,disabled:!_n,title:`Redo (${Wr.replace("S","⇧Z").replace("Ctrl+","Ctrl+Shift+")})`,"aria-label":"Redo",className:"archik-btn",style:{padding:"5px 8px"},children:R.jsx(wFn,{size:14,strokeWidth:1.8})}),G!==void 0&&R.jsx(wXn,{onAdd:G}),Ae!==void 0&&Ze!==void 0&&R.jsx("button",{type:"button",onClick:()=>Ze(Ae==="compact"?"detailed":"compact"),title:Ae==="compact"?"Switch to detailed view":"Switch to compact view","aria-label":"Toggle view mode",className:"archik-btn",style:{padding:"5px 8px"},children:Ae==="compact"?R.jsx(YBn,{size:14,strokeWidth:1.8}):R.jsx(yFn,{size:14,strokeWidth:1.8})}),ie!==void 0&&tn!==void 0&&R.jsx("button",{type:"button",onClick:tn,title:ie?"Hide ECB stereotype bands":"Show ECB stereotype bands (boundary / control / entity)","aria-label":"Toggle ECB stereotype bands","aria-pressed":ie,className:"archik-btn",style:{padding:"5px 8px",...ie?{background:"var(--archik-stereotype-control)",borderColor:"var(--archik-stereotype-control)",color:"white"}:{}},children:R.jsx(OFn,{size:14,strokeWidth:1.8})}),re!==void 0&&fe!==void 0&&R.jsx(JXn,{density:re,onChange:fe}),Wn!==void 0&&(pt??0)>0&&R.jsx("button",{type:"button",onClick:Wn,title:dt?"Hide sequence diagram highlights":`Show ${pt} node${pt===1?"":"s"} with sequence diagrams`,"aria-label":"Toggle sequence diagram highlights","aria-pressed":dt,className:"archik-btn",style:{padding:"5px 8px",...dt?{background:"var(--archik-status-proposed)",borderColor:"var(--archik-status-proposed)",color:"white"}:{}},children:R.jsx(R1n,{size:14,strokeWidth:1.8})}),R.jsx(tVn,{}),R.jsx(yXn,{}),R.jsx(HXn,{}),R.jsx(S0n,{document:h,filename:b,...rt!==void 0?{getSvg:rt}:{}}),R.jsx("button",{type:"button",onClick:P,disabled:!j||T==="saving",title:`Save to ${b} (${Wr})`,className:"archik-btn archik-btn-primary",children:j?"Save •":"Save"}),R.jsx(QXn,{})]})]})}function gVn(h){const b=h.indexOf(`
226
- `);return b===-1?h:h.slice(0,b)}function wVn({files:h,currentPath:b,onSwitchFile:p}){const v=h.some(M=>M.hasSuggestion||M.isOrphanSuggestion);if(h.length<=1&&!v)return null;const T=h.find(M=>M.path===b)??h[0];return R.jsx(TT,{align:"start",trigger:M=>R.jsxs("button",{type:"button","aria-label":"Switch architecture file","aria-expanded":M,className:"archik-btn",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",fontSize:12,background:"transparent",color:"var(--archik-fg)"},children:[R.jsx(FBn,{size:13,strokeWidth:1.8}),R.jsx("span",{style:{fontWeight:600},children:T.name}),T.hasSuggestion&&R.jsx(pue,{}),R.jsx($1n,{size:12,strokeWidth:2,style:{opacity:.6}})]}),children:M=>R.jsxs("div",{style:{minWidth:220,padding:4},children:[R.jsx("div",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--archik-fg-muted)",padding:"6px 10px 4px"},children:"Architecture files"}),h.map(j=>{const P=j.path===T.path,G=j.isOrphanSuggestion===!0;return R.jsxs("button",{type:"button",title:G?`Pending sub-architecture (sidecar only — no main file yet). Click to view; accept via \`npx archik suggest accept ${j.path.replace(/\.archik\.suggested\.yaml$/,".archik.yaml")}\` to promote it, or /archik:accept.`:void 0,onClick:()=>{M(),!P&&p(j)},className:"archik-menu-item",style:{display:"flex",alignItems:"center",gap:8,width:"100%",textAlign:"left",padding:"6px 10px",fontSize:12,background:P?"var(--archik-surface-hover)":void 0,borderLeft:G?"2px dashed var(--archik-accent)":void 0,paddingLeft:G?8:void 0},children:[R.jsxs("span",{style:{fontWeight:P?600:400,color:"var(--archik-fg)"},children:[j.name,G&&R.jsx("span",{style:{marginLeft:6,fontSize:10,fontWeight:500,color:"var(--archik-accent)",letterSpacing:"0.04em"},children:"(pending)"})]}),j.hasSuggestion&&!G&&R.jsx(pue,{}),R.jsx("span",{style:{flex:1,fontSize:10,fontFamily:"ui-monospace, monospace",color:"var(--archik-fg-muted)",textAlign:"right"},children:j.path})]},j.path)})]})})}function pue(){return R.jsx("span",{"aria-label":"pending suggestion",title:"Pending suggestion",style:{width:6,height:6,borderRadius:3,background:"var(--archik-accent)",flexShrink:0}})}function pVn({stack:h,onGoToFrame:b,suggestionsByPath:p}){return h.length<=1?null:R.jsx("nav",{"aria-label":"Architecture file navigation",style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--archik-fg-muted)"},children:h.map((v,T)=>{const M=T===h.length-1,j=v.archikFile!==null&&p!==void 0&&p.has(v.archikFile);return R.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[M?R.jsxs("span",{style:{color:"var(--archik-fg)",fontWeight:600,display:"inline-flex",alignItems:"center",gap:6},"aria-current":"page",children:[v.label,j&&R.jsx(pue,{})]}):R.jsxs("button",{type:"button",onClick:()=>b(T),className:"archik-btn",style:{padding:"2px 6px",fontSize:12,color:"var(--archik-fg-muted)",background:"transparent",display:"inline-flex",alignItems:"center",gap:6},title:`Back to ${v.label}`,children:[v.label,j&&R.jsx(pue,{})]}),!M&&R.jsx("span",{"aria-hidden":"true",style:{opacity:.5},children:"›"})]},`${T}-${v.archikFile??"root"}`)})})}const mVn="/architecture.archik.yaml",vVn="/architecture.archik.suggested.yaml",yVn="/__archik/accept-suggestion",kVn=1500,h7e={label:"main",docUrl:mVn,sidecarUrl:vVn,acceptUrl:yVn,archikFile:null};function M0n(h,b){const p=h.replace(/\.archik\.yaml$/,".archik.suggested.yaml"),v=encodeURIComponent(h),T=encodeURIComponent(p);return{label:b,docUrl:`/__archik/file?path=${v}`,sidecarUrl:`/__archik/file?path=${T}`,acceptUrl:`/__archik/file-accept?path=${v}`,archikFile:h}}function jVn(){if(typeof window>"u")return null;const h=new URLSearchParams(window.location.search).get("file");return h!==null&&h.length>0?h:null}function SVn(h){if(typeof window>"u")return;const b=new URL(window.location.href);h===null||h.length===0?b.searchParams.delete("file"):b.searchParams.set("file",h),window.history.replaceState(null,"",b.toString())}function m1n(){const h=jVn();if(h===null)return[h7e];const p=(h.split("/").pop()??h).replace(/\.archik\.yaml$/i,"")||"main";return[M0n(h,p)]}function EVn(){const[h,b]=lt.useState({status:"loading"}),[p,v]=lt.useState(m1n),T=p[p.length-1],[M,j]=lt.useState([]),P=lt.useMemo(()=>new Set(M.filter(xn=>xn.hasSuggestion).map(xn=>xn.path)),[M]),G=lt.useMemo(()=>M.find(xn=>xn.isRoot)??null,[M]),J=T.archikFile===null?G?.path??null:T.archikFile,[se,re]=lt.useState(void 0),[fe,Ae]=lt.useState(void 0),[Ze,ie]=lt.useState("idle"),[tn,bn]=lt.useState(null),[_n,hn]=lt.useState(!1),[Rn,rt]=lt.useState(!1),[dt,Wn]=lt.useState({status:"none"}),[pt,wr]=lt.useState(!1),[Wr,Yr]=lt.useState([]),[Ui,Q]=lt.useState([]),Yo=100,[Ao,Jn]=lt.useState(()=>qXn()),ct=xn=>{Jn(xn),GXn(xn)},[ki,Br]=lt.useState(()=>BXn()),Xc=xn=>{Br(xn),FXn(xn)},[He,Yn]=lt.useState(()=>PXn()),ti=xn=>{Yn(xn),zXn(xn)},ji=lt.useMemo(()=>({...UXn(Ao),viewMode:ki}),[Ao,ki]),ar=lt.useMemo(()=>h.status==="ready"?new Set(h.document.nodes.filter(xn=>(xn.seqFiles?.length??0)>0).map(xn=>xn.id)):new Set,[h]),Jr=lt.useRef(!1),Oc=lt.useRef(null),Rs=lt.useRef(null),Wu=lt.useCallback(()=>Rs.current,[]),sh=lt.useRef(null),ds=oy(xn=>xn.selection),oa=oy(xn=>xn.connectFrom),r5=oy(xn=>xn.selectNode),Na=oy(xn=>xn.selectEdge),hy=oy(xn=>xn.toggleNode),iv=oy(xn=>xn.toggleEdge),Ab=oy(xn=>xn.clearSelection),t7=oy(xn=>xn.startConnect),su=oy(xn=>xn.cancelConnect),Vc=ds.length>0?ds.at(-1)??null:null,c5=lt.useMemo(()=>new Set(ds.filter(xn=>xn.type==="node").map(xn=>xn.id)),[ds]),Ps=lt.useMemo(()=>new Set(ds.filter(xn=>xn.type==="edge").map(xn=>xn.id)),[ds]);lt.useEffect(()=>{const xn=p[p.length-1];SVn(xn.archikFile)},[p]),lt.useEffect(()=>{if(typeof window>"u")return;const xn=()=>v(m1n());return window.addEventListener("popstate",xn),()=>window.removeEventListener("popstate",xn)},[]),lt.useEffect(()=>{let xn=!1;Oc.current="",Jr.current=!1;const Pt=()=>{BZn(T.docUrl).then(({document:xi,text:Dr})=>{if(xn||Dr===Oc.current)return;Oc.current=Dr,Jr.current=!0,b({status:"ready",document:xi}),hn(!1),typeof window<"u"&&xi.name&&(window.document.title=`${xi.name} — Archik`),Ae(void 0),Yr([]),Q([]);const Al=new Set(xi.nodes.map(ou=>ou.id)),To=new Set(xi.edges.map(ou=>ou.id));oy.setState(ou=>({selection:ou.selection.filter(Rc=>Rc.type==="node"?Al.has(Rc.id):To.has(Rc.id)),connectFrom:ou.connectFrom!==null&&Al.has(ou.connectFrom)?ou.connectFrom:null}))},xi=>{if(xn)return;const Dr=xi instanceof Error?xi.message:String(xi);Jr.current?Ae(Dr):b({status:"error",error:Dr})})};b({status:"loading"}),Pt();const Ji=s1n(Pt);return()=>{xn=!0,Ji()}},[T.docUrl]),lt.useEffect(()=>()=>{sh.current&&clearTimeout(sh.current)},[]),lt.useEffect(()=>{let xn=!1;const Pt=async()=>{try{const Dr=await fetch("/__archik/files",{cache:"no-store"});if(xn||!Dr.ok)return;const Al=await Dr.json();if(xn)return;Array.isArray(Al.files)&&j(Al.files)}catch{}};Pt();const Ji=s1n(()=>{Pt()}),xi=o1n(()=>{Pt()});return()=>{xn=!0,Ji(),xi()}},[]),lt.useEffect(()=>{if(h.status!=="ready")return;const xn=h.document;let Pt=!1;const Ji=async()=>{if(J!==null&&M.length>0&&M.some(Dr=>Dr.path===J)&&!P.has(J)){Wn({status:"none"});return}try{const Dr=await fetch(T.sidecarUrl,{cache:"no-store"});if(Pt)return;if(Dr.status===404){Wn({status:"none"});return}if(!Dr.ok){Wn({status:"error",message:`Sidecar fetch failed: HTTP ${Dr.status}`});return}const Al=await Dr.text();let To;try{To=w0n(Al)}catch(Rc){Wn({status:"error",message:Rc instanceof Error?Rc.message:String(Rc)});return}const ou=l7e(xn,To);Wn({status:"pending",added:ou.nodes.added.length+ou.edges.added.length,removed:ou.nodes.removed.length+ou.edges.removed.length,changed:ou.nodes.changed.length+ou.edges.changed.length,doc:To,...To.metadata?.suggestion?.note!==void 0?{note:To.metadata.suggestion.note}:{}})}catch(Dr){if(Pt)return;Wn({status:"error",message:Dr instanceof Error?Dr.message:String(Dr)})}};Ji();const xi=o1n(Ji);return()=>{Pt=!0,xi()}},[h,T.sidecarUrl,J,M,P]);const xT=lt.useCallback(async()=>{try{const xn=await fetch(T.acceptUrl,{method:"POST"});if(!xn.ok){const Pt=await xn.text();Wn({status:"error",message:`Accept failed: ${Pt||`HTTP ${xn.status}`}`});return}Wn({status:"none"}),wr(!1)}catch(xn){Wn({status:"error",message:xn instanceof Error?xn.message:String(xn)})}},[T.acceptUrl]),oh=lt.useCallback(async()=>{try{const xn=await fetch(T.sidecarUrl,{method:"DELETE"});if(!xn.ok&&xn.status!==404){const Pt=await xn.text();Wn({status:"error",message:`Reject failed: ${Pt||`HTTP ${xn.status}`}`});return}Wn({status:"none"}),wr(!1)}catch(xn){Wn({status:"error",message:xn instanceof Error?xn.message:String(xn)})}},[T.sidecarUrl]),MT=lt.useCallback(()=>{wr(xn=>!xn)},[]),dy=lt.useCallback(async()=>{let xn=null;if(b(Ji=>(Ji.status==="ready"&&(xn=Ji.document),Ji)),!xn)return;const Pt=G7e(xn);Oc.current=Pt,ie("saving"),bn(null);try{await FZn(T.docUrl,xn),ie("saved");let Ji=!1;b(xi=>(xi.status==="ready"&&xi.document===xn&&(Ji=!0),xi)),Ji&&hn(!1),sh.current&&clearTimeout(sh.current),sh.current=setTimeout(()=>ie("idle"),kVn)}catch(Ji){ie("error"),bn(Ji instanceof Error?Ji.message:String(Ji))}},[T.docUrl]),rv=G?.path??null,Zg=lt.useCallback((xn,Pt)=>rv===xn?h7e:M0n(xn,Pt),[rv]),by=lt.useCallback((xn,Pt)=>xn.archikFile===Pt?!0:xn.archikFile===null&&rv===Pt,[rv]),i7=lt.useCallback((xn,Pt)=>{v(Ji=>{const xi=Ji.findIndex(Dr=>by(Dr,xn));return xi>=0?xi===Ji.length-1?Ji:Ji.slice(0,xi+1):[...Ji,Zg(xn,Pt)]})},[Zg,by]),u5=lt.useCallback((xn,Pt)=>{v(Ji=>{const xi=Ji[Ji.length-1];return by(xi,xn)?Ji:[Zg(xn,Pt)]})},[Zg,by]),CT=lt.useCallback(xn=>{v(Pt=>xn<0||xn>=Pt.length-1?Pt:Pt.slice(0,xn+1))},[]),cv=lt.useCallback(xn=>{xn.isRoot?v([h7e]):u5(xn.path,xn.name)},[u5]),lh=lt.useCallback((xn,Pt)=>{if(oa===null){Pt&&(Pt.metaKey||Pt.ctrlKey||Pt.shiftKey)?hy(xn):r5(xn);return}if(xn===oa){su();return}let Ji=null;b(xi=>{if(xi.status!=="ready"||!xi.document.nodes.find(Rc=>Rc.id===oa))return xi;const Al=new Set(xi.document.edges.map(Rc=>Rc.id)),To=$8e(D8e(`${oa}-${xn}`),Al,"edge"),ou={id:To,from:oa,to:xn,relationship:"http_call"};try{const Rc=tI(xi.document,{type:"connect",edge:ou});return re(void 0),hn(!0),Yr(Bu=>[...Bu.slice(-(Yo-1)),xi.document]),Q([]),Ji=To,{status:"ready",document:Rc}}catch(Rc){const Bu=Rc instanceof Error?Rc.message:String(Rc);return re(Bu),xi}}),su(),Ji&&Na(Ji)},[oa,su,r5,hy,Na]),Tb=lt.useCallback((xn,Pt)=>{Pt&&(Pt.metaKey||Pt.ctrlKey||Pt.shiftKey)?iv(xn):Na(xn)},[Na,iv]),fh=lt.useCallback((xn,Pt)=>{let Ji=null;b(xi=>{if(xi.status!=="ready")return xi;const Dr=xi.document.nodes.find(Bu=>Bu.id===xn),Al=xi.document.nodes.find(Bu=>Bu.id===Pt);if(!Dr||!Al)return xi;const To=new Set(xi.document.edges.map(Bu=>Bu.id)),ou=$8e(D8e(`${xn}-${Pt}`),To,"edge"),Rc={id:ou,from:xn,to:Pt,relationship:"http_call"};try{const Bu=tI(xi.document,{type:"connect",edge:Rc});return re(void 0),hn(!0),Yr(Mb=>[...Mb.slice(-(Yo-1)),xi.document]),Q([]),Ji=ou,{status:"ready",document:Bu}}catch(Bu){const Mb=Bu instanceof Error?Bu.message:String(Bu);return re(Mb),xi}}),Ji&&Na(Ji)},[Na]),OT=lt.useCallback((xn,Pt,Ji)=>{b(xi=>{if(xi.status!=="ready")return xi;const Dr=new Set(xi.document.nodes.map(To=>To.id)),Al=$8e(D8e(Pt),Dr,xn);try{const To=tI(xi.document,{type:"add_node",node:{id:Al,kind:xn,name:Pt,description:Ji}});return re(void 0),hn(!0),Yr(ou=>[...ou.slice(-(Yo-1)),xi.document]),Q([]),{status:"ready",document:To}}catch(To){const ou=To instanceof Error?To.message:String(To);return re(ou),xi}})},[]),r7=lt.useCallback(xn=>{b(Pt=>{if(Pt.status!=="ready")return Pt;try{const Ji=tI(Pt.document,xn);return re(void 0),hn(!0),Yr(xi=>[...xi.slice(-(Yo-1)),Pt.document]),Q([]),{status:"ready",document:Ji}}catch(Ji){const xi=Ji instanceof Error?Ji.message:String(Ji);return re(xi),Pt}})},[]),s5=lt.useCallback(()=>{ds.length!==0&&(b(xn=>{if(xn.status!=="ready")return xn;let Pt=xn.document;try{const Ji=ds.filter(Dr=>Dr.type==="edge").map(Dr=>Dr.id);for(const Dr of Ji)Pt.edges.some(Al=>Al.id===Dr)&&(Pt=tI(Pt,{type:"disconnect",id:Dr}));const xi=ds.filter(Dr=>Dr.type==="node").map(Dr=>Dr.id);for(const Dr of xi)Pt.nodes.some(Al=>Al.id===Dr)&&(Pt=tI(Pt,{type:"remove_node",id:Dr}));return Pt===xn.document?xn:(re(void 0),hn(!0),Yr(Dr=>[...Dr.slice(-(Yo-1)),xn.document]),Q([]),{status:"ready",document:Pt})}catch(Ji){const xi=Ji instanceof Error?Ji.message:String(Ji);return re(xi),xn}}),Ab())},[ds,Ab]),$p=lt.useCallback(()=>{if(h.status!=="ready"||Wr.length===0)return;const xn=Wr[Wr.length-1];Yr(Pt=>Pt.slice(0,-1)),Q(Pt=>[...Pt,h.document]),b({status:"ready",document:xn}),hn(!0),re(void 0),Ab()},[h,Wr,Ab]),Xg=lt.useCallback(()=>{if(h.status!=="ready"||Ui.length===0)return;const xn=Ui[Ui.length-1];Q(Pt=>Pt.slice(0,-1)),Yr(Pt=>[...Pt,h.document]),b({status:"ready",document:xn}),hn(!0),re(void 0),Ab()},[h,Ui,Ab]);if(lt.useEffect(()=>{const xn=Pt=>{if((Pt.metaKey||Pt.ctrlKey)&&Pt.key==="s"){Pt.preventDefault(),_n&&dy();return}if((Pt.metaKey||Pt.ctrlKey)&&(Pt.key==="z"||Pt.key==="Z")){Pt.preventDefault(),Pt.shiftKey?Xg():$p();return}if((Pt.metaKey||Pt.ctrlKey)&&Pt.key==="y"){Pt.preventDefault(),Xg();return}if(Pt.key==="Escape"){oa&&su();return}if(Pt.key==="Delete"||Pt.key==="Backspace"){const Ji=Pt.target;if(Ji instanceof HTMLInputElement||Ji instanceof HTMLTextAreaElement||Ji instanceof HTMLSelectElement||Ji instanceof HTMLElement&&Ji.isContentEditable||ds.length===0)return;Pt.preventDefault(),s5()}};return window.addEventListener("keydown",xn),()=>window.removeEventListener("keydown",xn)},[_n,dy,oa,su,ds,s5,$p,Xg]),h.status==="loading")return R.jsxs(v1n,{children:["Loading ",T.docUrl,"…"]});if(h.status==="error")return R.jsx(v1n,{children:R.jsx("pre",{className:"max-w-3xl whitespace-pre-wrap text-xs text-rose-700",children:h.error})});const xb=h.document,E1=pt&&dt.status==="pending",gy=E1&&dt.status==="pending"?XZn(xb,dt.doc):null,Lp=E1&&dt.status==="pending"?y0n(l7e(xb,dt.doc)):null,wy=gy??xb,c7=Vc?.type==="node"?wy.nodes.find(xn=>xn.id===Vc.id):void 0,o5=Vc?.type==="edge"?wy.edges.find(xn=>xn.id===Vc.id):void 0,Rp=oa!==null?xb.nodes.find(xn=>xn.id===oa):void 0,u7=ds.length>1;return R.jsxs("div",{className:"flex h-full flex-col",style:{background:"var(--archik-canvas)",color:"var(--archik-fg)"},children:[R.jsx(bVn,{document:xb,commandError:se,saveStatus:Ze,...tn!==null?{saveError:tn}:{},isDirty:_n,onSave:()=>{dy()},onAddNode:OT,density:Ao,onDensityChange:ct,viewMode:ki,onViewModeChange:Xc,showStereotypeBands:He,onToggleStereotypeBands:()=>ti(!He),canUndo:Wr.length>0,canRedo:Ui.length>0,onUndo:$p,onRedo:Xg,getSvg:Wu,seqHighlight:Rn,onToggleSeqHighlight:()=>rt(xn=>!xn),seqNodeCount:ar.size,...fe!==void 0?{reloadError:fe}:{},...Rp!==void 0?{connectingFromName:Rp.name,onCancelConnect:su}:{}}),dt.status==="pending"&&R.jsx(TVn,{added:dt.added,removed:dt.removed,changed:dt.changed,note:dt.note,reviewing:E1,onReview:MT,onAccept:()=>{xT()},onReject:()=>{oh()}}),dt.status==="error"&&R.jsxs("div",{role:"alert",style:{background:"rgba(217, 119, 6, 0.12)",borderBottom:"1px solid rgba(217, 119, 6, 0.45)",color:"var(--archik-warning)",padding:"8px 16px",fontSize:12,display:"flex",alignItems:"center",gap:12},children:[R.jsx("span",{style:{fontWeight:700},children:"SUGGESTION ERROR —"}),R.jsx("span",{style:{flex:1,color:"var(--archik-fg)"},children:dt.message}),R.jsx("button",{type:"button",onClick:()=>Wn({status:"none"}),"aria-label":"Dismiss",style:{background:"transparent",border:"none",color:"var(--archik-fg-dim)",cursor:"pointer",fontSize:16,lineHeight:1},children:"×"})]}),fe!==void 0&&R.jsxs("div",{role:"alert",style:{background:"rgba(225, 29, 72, 0.12)",borderBottom:"1px solid rgba(225, 29, 72, 0.45)",color:"var(--archik-danger)",padding:"10px 16px",display:"flex",alignItems:"flex-start",gap:12,fontSize:12,lineHeight:1.5},children:[R.jsx("span",{style:{fontWeight:700,letterSpacing:"0.04em"},children:"FILE INVALID —"}),R.jsx("pre",{style:{margin:0,flex:1,whiteSpace:"pre-wrap",fontFamily:"inherit",color:"var(--archik-fg)"},children:fe}),R.jsx("button",{type:"button",onClick:()=>Ae(void 0),"aria-label":"Dismiss error",style:{background:"transparent",border:"none",color:"var(--archik-fg-dim)",cursor:"pointer",padding:"0 4px",fontSize:16,lineHeight:1},children:"×"})]}),R.jsxs("main",{className:"flex min-h-0 flex-1 p-4",style:{gap:0},children:[R.jsx("div",{className:"archik-panel",style:{flex:1,minWidth:0,overflow:"hidden"},children:R.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%"},children:[(M.length>1||p.length>1)&&R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",background:"var(--archik-surface)",borderBottom:"1px solid var(--archik-border)"},children:[R.jsx(wVn,{files:M,currentPath:J,onSwitchFile:cv}),R.jsx(pVn,{stack:p,onGoToFrame:CT,suggestionsByPath:P})]}),R.jsx(Bqn,{document:wy,className:"flex-1 archik-grid",layoutOptions:ji,viewMode:ki,showStereotypeBands:He,selectedNodeIds:c5,selectedEdgeIds:Ps,onSelectNode:lh,onSelectEdge:Tb,onSelectNothing:oa===null?Ab:su,onConnectDrag:fh,onOpenSubFile:i7,onCrossFileNavigate:u5,viewKey:T.docUrl,svgRef:Rs,...Lp?{diffStatuses:Lp}:{},...Rn&&ar.size>0?{glowNodeIds:ar}:{}})]})}),R.jsx("aside",{"aria-hidden":ds.length===0,className:`archik-drawer-shell ${ds.length>0?"archik-drawer-shell--open":"archik-drawer-shell--closed"}`,children:R.jsx("div",{className:"archik-panel archik-drawer-content archik-drawer-fade",style:{overflow:"hidden"},children:u7?R.jsx(AVn,{count:ds.length,onDelete:s5,onClear:Ab}):Vc?.type==="edge"?R.jsx(bXn,{edge:o5,dispatch:r7,readOnly:E1}):Vc?.type==="node"?R.jsx(oXn,{node:c7,dispatch:r7,onStartConnect:t7,allNodes:wy.nodes,readOnly:E1,viewKey:T.archikFile??void 0}):null},u7?`multi:${ds.length}`:Vc?`${Vc.type}:${Vc.id}`:"empty")})]})]})}function AVn({count:h,onDelete:b,onClear:p}){return R.jsxs("div",{className:"flex h-full flex-col gap-4 overflow-y-auto p-4 text-sm",children:[R.jsxs("div",{children:[R.jsx("div",{className:"archik-label",children:"Selection"}),R.jsxs("div",{style:{fontSize:18,fontWeight:600,color:"var(--archik-fg)",letterSpacing:"0.01em"},children:[h," items"]}),R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-dim)",marginTop:4},children:"Hold ⌘ / Ctrl while clicking to add or remove items."})]}),R.jsx("div",{className:"archik-divider"}),R.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-4",children:[R.jsx("button",{type:"button",onClick:p,className:"archik-btn",style:{justifyContent:"center",padding:"8px 12px"},children:"Clear selection"}),R.jsxs("button",{type:"button",onClick:b,className:"archik-btn archik-btn-danger",style:{justifyContent:"center",padding:"8px 12px"},children:["Delete ",h," items"]})]})]})}function v1n({children:h}){return R.jsx("div",{className:"flex h-full items-center justify-center p-6 text-sm",style:{background:"var(--archik-canvas)",color:"var(--archik-fg-dim)"},children:h})}function TVn({added:h,removed:b,changed:p,note:v,reviewing:T,onReview:M,onAccept:j,onReject:P}){const G=h+b+p;return R.jsxs("div",{role:"region","aria-label":"Pending suggestion",style:{background:"rgba(168, 85, 247, 0.12)",borderBottom:"1px solid rgba(168, 85, 247, 0.45)",padding:"10px 16px",display:"flex",alignItems:"center",gap:14,fontSize:12,lineHeight:1.4},children:[R.jsx("span",{style:{fontWeight:700,letterSpacing:"0.04em",color:"#c4b5fd"},children:"📝 SUGGESTION PENDING"}),R.jsxs("span",{style:{color:"var(--archik-fg)"},children:[G===0?"(identical to current — nothing to apply)":R.jsxs(R.Fragment,{children:[R.jsxs("span",{style:{color:"var(--archik-success)"},children:["+",h]})," ",R.jsxs("span",{style:{color:"var(--archik-danger)"},children:["−",b]})," ",R.jsxs("span",{style:{color:"var(--archik-warning)"},children:["~",p]})]}),v?R.jsxs("span",{style:{marginLeft:10,color:"var(--archik-fg-dim)",fontStyle:"italic"},children:['"',v,'"']}):null]}),R.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8},children:[R.jsx("button",{type:"button",onClick:M,className:"archik-btn",style:{padding:"5px 12px",fontSize:12,...T?{background:"#a855f7",color:"white",borderColor:"#a855f7"}:{}},children:T?"Hide diff":"Review"}),R.jsx("button",{type:"button",onClick:j,className:"archik-btn",title:G===0?"Suggestion already matches the current file — Accept just clears the sidecar.":"Apply the suggestion to the main file.",style:{padding:"5px 12px",fontSize:12,background:"var(--archik-success)",color:"white",borderColor:"var(--archik-success)"},children:"Accept"}),R.jsx("button",{type:"button",onClick:P,className:"archik-btn",style:{padding:"5px 12px",fontSize:12,color:"var(--archik-danger)",borderColor:"var(--archik-danger)"},children:"Reject"})]})]})}const xVn=n7(["sync","async","return","create","destroy"]),MVn=n7(["over","left_of","right_of"]),CVn=n7(["alt","opt","loop","par","break","ref"]),OVn=Kg({id:dd,nodeId:dd,label:hs().min(1).optional(),status:CI.optional()}),_Vn=Kg({type:oJ("message"),id:dd,from:dd,to:dd,label:hs().min(1),arrow:xVn,activate:VKn().optional(),status:CI.optional()}),NVn=Kg({type:oJ("note"),id:dd,position:MVn,participants:Jg(dd).min(1),text:hs().min(1),status:CI.optional()}),IVn=F7e(()=>Kg({label:hs().optional(),steps:Jg(C0n)})),DVn=F7e(()=>Kg({type:oJ("group"),id:dd,kind:CVn,condition:hs().optional(),label:hs().optional(),branches:Jg(IVn).optional(),seqFile:h0n.optional(),participants:Jg(dd).optional(),status:CI.optional()})),C0n=F7e(()=>o0n([_Vn,NVn,DVn]));function O0n(h,b){const p=[];for(const v of h)if(b.has(v.id)?p.push(v.id):b.add(v.id),v.type==="group"&&v.branches)for(const T of v.branches)p.push(...O0n(T.steps,b));return p}const $Vn=Kg({useCase:dd,slice:dd}),LVn=Kg({version:oJ("1.0"),name:hs().min(1),description:hs().optional(),realizes:$Vn.optional(),participants:Jg(OVn).min(1),steps:Jg(C0n)}).superRefine((h,b)=>{const p=new Set;for(let M=0;M<h.participants.length;M++){const j=h.participants[M];p.has(j.id)&&b.addIssue({code:jb.custom,path:["participants",M,"id"],message:`duplicate participant id "${j.id}"`}),p.add(j.id)}const v=new Set,T=O0n(h.steps,v);for(const M of T)b.addIssue({code:jb.custom,path:["steps"],message:`duplicate step id "${M}"`})}),kI=56,RVn=160,PVn=40,d7e=56,zVn=24,eue=12,BVn=8,FVn=6,y1n=64,pT=32,B8e=24,k1n=8,_0n="seq-arrow-filled",N0n="seq-arrow-open";function qVn(h){return Math.max(RVn,h.length*8+PVn*2)}function I0n(h,b,p,v,T,M=0){let j=p;const P=[];let G=Number.POSITIVE_INFINITY,J=Number.NEGATIVE_INFINITY;for(const se of h)if(se.type==="message"){const re=b.get(se.from),fe=b.get(se.to),Ae=re?.cx??v,Ze=fe?.cx??v;P.push({type:"message",id:se.id,fromCx:Ae,toCx:Ze,y:j,label:se.label,arrow:se.arrow,activate:se.activate??!1,isSelf:se.from===se.to,...se.status!==void 0?{status:se.status}:{}}),j+=se.from===se.to?d7e*1.5:d7e}else if(se.type==="note"){const re=se.participants.map(tn=>b.get(tn)?.cx).filter(tn=>tn!==void 0).sort((tn,bn)=>tn-bn),fe=re[0]??v,Ae=re[re.length-1]??T,Ze=Math.min(Math.max(se.text.length*7.5+24,Ae-fe+16,80),400);let ie;se.position==="left_of"?ie=fe-Ze-8:se.position==="right_of"?ie=Ae+8:ie=(fe+Ae)/2-Ze/2,G=Math.min(G,ie),J=Math.max(J,ie+Ze),P.push({type:"note",id:se.id,x:ie,y:j,width:Ze,height:y1n,text:se.text,...se.status!==void 0?{status:se.status}:{}}),j+=y1n+8}else if(se.type==="group"){const re=Math.min(M*FVn,eue),fe=v-eue+re,Ae=T-v+eue*2-re*2,Ze=j;j+=zVn;const ie=[];if(se.branches)for(let tn=0;tn<se.branches.length;tn++){const bn=se.branches[tn],_n=j,{items:hn,endY:Rn,contentMinX:rt,contentMaxX:dt}=I0n(bn.steps,b,j,v,T,M+1);j=Rn,G=Math.min(G,rt),J=Math.max(J,dt),ie.push({...bn.label!==void 0?{label:bn.label}:{},startY:_n,...tn<se.branches.length-1?{dividerY:j}:{},steps:hn}),tn<se.branches.length-1&&(j+=4)}j+=eue,P.push({type:"group",id:se.id,kind:se.kind,...se.condition!==void 0?{condition:se.condition}:{},...se.label!==void 0?{label:se.label}:{},...se.seqFile!==void 0?{seqFile:se.seqFile}:{},x:fe,y:Ze,width:Ae,height:j-Ze,branches:ie,...se.status!==void 0?{status:se.status}:{}}),G=Math.min(G,fe),J=Math.max(J,fe+Ae),j+=BVn}return{items:P,endY:j,contentMinX:G,contentMaxX:J}}function D0n(h){const b=new Map;for(const p of h)if(p.type==="message"&&p.arrow==="destroy"&&b.set(p.toCx,p.y+kI+20),p.type==="group")for(const v of p.branches)for(const[T,M]of D0n(v.steps))b.set(T,M);return b}function GVn(h){const b=[],p=new Map;function v(T){for(const M of T)if(M.type==="message"){if(M.activate&&M.arrow==="sync"&&!M.isSelf){const j=p.get(M.toCx)??[];j.push(M.y),p.set(M.toCx,j)}if(M.arrow==="return"&&!M.isSelf){const j=p.get(M.fromCx);if(j&&j.length>0){const P=j.pop();b.push({cx:M.fromCx,startY:P,endY:M.y}),j.length===0&&p.delete(M.fromCx)}}}else if(M.type==="group")for(const j of M.branches)v(j.steps)}v(h);for(const[T,M]of p)for(const j of M)b.push({cx:T,startY:j,endY:j+d7e/2});return b}function UVn(h,b){const p=h.participants.map(Wn=>qVn(Wn.label??Wn.nodeId));let v=pT;const T=h.participants.map((Wn,pt)=>{const wr=p[pt],Wr=v+wr/2;v+=wr;const Yr=b?.get(Wn.nodeId);return{id:Wn.id,nodeId:Wn.nodeId,label:Wn.label??Wn.nodeId,cx:Wr,colWidth:wr,...Yr!==void 0?{kind:Yr}:{},...Wn.status!==void 0?{status:Wn.status}:{},lifelineEndY:0}}),M=v+pT,j=new Map(T.map(Wn=>[Wn.id,Wn])),P=T[0]?.cx??pT,G=T[T.length-1]?.cx??M-pT,J=B8e,{items:se,endY:re,contentMinX:fe,contentMaxX:Ae}=I0n(h.steps,j,J,P,G),Ze=fe<pT&&Number.isFinite(fe)?pT-fe:0,ie=Number.isFinite(Ae)?Ae+Ze+pT:0,tn=Math.max(M+Ze,ie),bn=Ze>0?se.map(Wn=>$0n(Wn,Ze)):se,_n=Ze>0?T.map(Wn=>({...Wn,cx:Wn.cx+Ze})):T,hn=D0n(bn),Rn=_n.map(Wn=>({...Wn,lifelineEndY:hn.get(Wn.cx)??kI+re+B8e})),rt=kI+re+B8e,dt=GVn(bn);return{participants:Rn,steps:bn,activations:dt,totalWidth:tn,totalHeight:rt}}function $0n(h,b){return h.type==="message"?{...h,fromCx:h.fromCx+b,toCx:h.toCx+b}:h.type==="note"?{...h,x:h.x+b}:{...h,x:h.x+b,branches:h.branches.map(p=>({...p,steps:p.steps.map(v=>$0n(v,b))}))}}const nue=36,JVn=128,HVn=7,j1n=20,S1n=24;function KVn({participant:h,nodeKind:b}){const p=b?Np[b]:void 0,v=p?.color??"var(--archik-fg-muted)",T=(kI-nue)/2,M=p?.icon,j=Math.max(JVn,h.label.length*HVn+S1n+(M?j1n:0)),P=j/2,G=M?P+j1n/2:P,J=h.status,se=J==="proposed"?.55:J==="deprecated"?.35:1,re=J==="proposed"||J==="deprecated"?"4 3":void 0;return R.jsxs("g",{transform:`translate(${h.cx-P}, ${T})`,opacity:se,children:[R.jsx("rect",{width:j,height:nue,rx:8,fill:"var(--archik-node-fill)",stroke:v,strokeWidth:1.4,...re!==void 0?{strokeDasharray:re}:{}}),M&&R.jsx("g",{transform:`translate(${S1n/2}, ${(nue-14)/2})`,children:R.jsx(M,{size:14,color:v,strokeWidth:1.5})}),R.jsx("text",{x:G,y:nue/2+4,textAnchor:"middle",fontSize:12,fontWeight:500,fill:"var(--archik-fg)",fontFamily:"inherit",children:h.label})]})}function ZVn({participant:h}){const b=h.status,p=b==="proposed"?.3:b==="deprecated"?.2:.5;return R.jsx("line",{x1:h.cx,y1:kI,x2:h.cx,y2:h.lifelineEndY,stroke:"var(--archik-node-stroke)",strokeWidth:1,strokeDasharray:"4 4",opacity:p})}const F8e=32,q8e=20,XVn=-6;function VVn({msg:h}){const b=h.arrow==="return",p=h.arrow==="async",v=h.arrow==="create",T=b||v,M=h.arrow==="destroy",j=b||p?N0n:_0n,P=h.status==="proposed"?.5:h.status==="deprecated"?.35:1;if(h.isSelf){const re=h.fromCx,fe=h.y,Ae=`M ${re} ${fe} L ${re+F8e} ${fe} L ${re+F8e} ${fe+q8e} L ${re} ${fe+q8e}`;return R.jsxs("g",{opacity:P,children:[R.jsx("path",{d:Ae,fill:"none",stroke:"var(--archik-edge-filled)",strokeWidth:1.4,markerEnd:`url(#${j})`}),R.jsx("text",{x:re+F8e+6,y:fe+q8e/2+4,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:h.label})]})}const J=h.fromCx<h.toCx?h.toCx-6:h.toCx+6,se=(h.fromCx+h.toCx)/2;return R.jsxs("g",{opacity:P,children:[R.jsx("line",{x1:h.fromCx,y1:h.y,x2:J,y2:h.y,stroke:"var(--archik-edge-filled)",strokeWidth:1.4,strokeDasharray:T?"4 4":void 0,markerEnd:M?void 0:`url(#${j})`}),R.jsxs("text",{x:se,y:h.y+XVn,textAnchor:"middle",fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:[v&&"«create» ",h.label]}),h.arrow==="destroy"&&R.jsxs("g",{transform:`translate(${h.toCx-6}, ${h.y-6})`,children:[R.jsx("line",{x1:0,y1:0,x2:12,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5}),R.jsx("line",{x1:12,y1:0,x2:0,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5})]})]})}const WVn={alt:"#6366f1",opt:"#0ea5e9",loop:"#10b981",par:"#f59e0b",break:"#ef4444",ref:"#8b5cf6"},E1n=36,G8e=18;function YVn({group:h,renderStep:b,onRefClick:p}){const v=WVn[h.kind]??"var(--archik-fg-muted)",T=h.status==="proposed"?.55:h.status==="deprecated"?.35:1,M=h.kind==="ref"&&h.seqFile!==void 0&&p!==void 0;return R.jsxs("g",{opacity:T,onClick:M?()=>p(h.seqFile):void 0,style:M?{cursor:"pointer"}:void 0,children:[R.jsx("rect",{x:h.x,y:h.y,width:h.width,height:h.height,rx:4,fill:"none",stroke:v,strokeWidth:1.2,opacity:.6}),R.jsx("rect",{x:h.x,y:h.y,width:E1n,height:G8e,rx:4,fill:v,opacity:.8}),R.jsx("text",{x:h.x+6,y:h.y+G8e-5,fontSize:10,fontWeight:600,fill:"#fff",fontFamily:"inherit",children:h.kind}),(h.condition??h.label)&&R.jsx("text",{x:h.x+E1n+6,y:h.y+G8e-5,fontSize:10,fill:v,fontFamily:"inherit",children:h.condition??h.label}),h.branches.map((j,P)=>R.jsxs("g",{children:[j.label&&R.jsx("text",{x:h.x+6,y:j.startY+12,fontSize:10,fill:v,fontFamily:"inherit",children:j.label}),j.steps.map(G=>b(G)),j.dividerY!==void 0&&R.jsx("line",{x1:h.x,y1:j.dividerY,x2:h.x+h.width,y2:j.dividerY,stroke:v,strokeWidth:1,strokeDasharray:"4 2",opacity:.5})]},P))]})}const rI=10;function QVn(h,b){const p=Math.max(10,Math.floor(b/6.5));if(h.length<=p)return[h];const v=h.split(" "),T=[];let M="";for(const j of v)(M+(M?" ":"")+j).length>p&&M?(T.push(M),M=j):M=M?M+" "+j:j;return M&&T.push(M),T.slice(0,3)}function eWn({note:h}){const{x:b,y:p,width:v,height:T,text:M}=h,j=h.status==="proposed"?.55:h.status==="deprecated"?.35:1;return R.jsxs("g",{opacity:j,children:[R.jsx("path",{d:`M ${b} ${p} L ${b+v-rI} ${p} L ${b+v} ${p+rI} L ${b+v} ${p+T} L ${b} ${p+T} Z`,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),R.jsx("path",{d:`M ${b+v-rI} ${p} L ${b+v-rI} ${p+rI} L ${b+v} ${p+rI}`,fill:"none",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),QVn(M,v-16).map((P,G)=>R.jsx("text",{x:b+8,y:p+8+11+G*13,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:P},G))]})}function nWn({id:h}){return R.jsx("marker",{id:h,viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:R.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"context-stroke"})})}function tWn({id:h}){return R.jsx("marker",{id:h,viewBox:"0 0 12 12",refX:"11",refY:"6",markerWidth:"7",markerHeight:"7",orient:"auto-start-reverse",children:R.jsx("path",{d:"M 1 1 L 11 6 L 1 11",fill:"none",stroke:"context-stroke",strokeWidth:"1.5",strokeLinejoin:"round"})})}function L0n({step:h,onRefClick:b}){return h.type==="message"?R.jsx(VVn,{msg:h}):h.type==="note"?R.jsx(eWn,{note:h}):h.type==="group"?R.jsx(YVn,{group:h,...b!==void 0?{onRefClick:b}:{},renderStep:p=>R.jsx(L0n,{step:p,...b!==void 0?{onRefClick:b}:{}},p.id)}):null}function iWn({laid:h,svgRef:b,onRefClick:p}){const{participants:v,steps:T,activations:M,totalWidth:j,totalHeight:P}=h;return R.jsxs("svg",{ref:b,width:j,height:P,viewBox:`0 0 ${j} ${P}`,xmlns:"http://www.w3.org/2000/svg",style:{fontFamily:"var(--archik-font, system-ui)"},children:[R.jsxs("defs",{children:[R.jsx(nWn,{id:_0n}),R.jsx(tWn,{id:N0n})]}),v.map(G=>R.jsx(ZVn,{participant:G},G.id)),v.map(G=>R.jsx(KVn,{participant:G,...G.kind!==void 0?{nodeKind:G.kind}:{}},G.id)),R.jsxs("g",{transform:`translate(0, ${kI})`,children:[M.map(G=>R.jsx("rect",{x:G.cx-k1n/2,y:G.startY,width:k1n,height:G.endY-G.startY,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1,rx:2},`${G.cx}-${G.startY}`)),T.map(G=>R.jsx(L0n,{step:G,...p!==void 0?{onRefClick:p}:{}},G.id))]})]})}const A1n="archik.seq.rail.open";function rWn({path:h,back:b}){const[p,v]=lt.useState({status:"loading"}),[T,M]=lt.useState(void 0),[j,P]=lt.useState([]),[G,J]=lt.useState(()=>{if(typeof window>"u")return!0;const hn=window.localStorage.getItem(A1n);return hn===null?!0:hn==="1"}),[se,re]=lt.useState(!1),fe=lt.useRef(null);lt.useEffect(()=>{typeof window<"u"&&window.localStorage.setItem(A1n,G?"1":"0")},[G]),lt.useEffect(()=>{fetch("/__archik/node-kinds").then(hn=>hn.ok?hn.json():null).then(hn=>{hn&&M(new Map(Object.entries(hn)))}).catch(()=>{})},[]),lt.useEffect(()=>{fetch("/__archik/usecases").then(hn=>hn.ok?hn.json():null).then(hn=>{hn&&P(hn.useCases??[])}).catch(()=>{})},[]),lt.useEffect(()=>{v({status:"loading"});const hn=encodeURIComponent(h);fetch(`/__archik/seq-file?path=${hn}`).then(async Rn=>{if(!Rn.ok)throw new Error(`${Rn.status} ${Rn.statusText}`);return Rn.text()}).then(Rn=>{const rt=I7e.parse(Rn),dt=LVn.safeParse(rt);if(!dt.success)throw new Error(dt.error.issues.map(Wn=>Wn.message).join("; "));v({status:"ready",doc:dt.data,raw:Rn})}).catch(Rn=>{v({status:"error",message:Rn instanceof Error?Rn.message:String(Rn)})})},[h]);const Ae=b?b.type==="usecase"?`/__archik/usecases?uc=${encodeURIComponent(b.value)}`:`/?file=${encodeURIComponent(b.value)}`:"/",Ze=b?.type==="usecase"?"Use cases":"Architecture",ie=lt.useMemo(()=>{if(p.status!=="ready")return null;const hn=p.doc.realizes;if(!hn)return null;const Rn=j.find(dt=>dt.id===hn.useCase);if(!Rn)return{useCase:hn.useCase,slice:hn.slice,name:void 0,slice_data:void 0};const rt=Rn.slices.find(dt=>dt.id===hn.slice);return{useCase:hn.useCase,slice:hn.slice,name:Rn.name,slice_data:rt,primaryActor:Rn.primaryActor}},[p,j]);if(p.status==="loading")return R.jsx("div",{className:"flex h-screen items-center justify-center",style:{color:"var(--archik-fg-muted)"},children:"Loading sequence diagram…"});if(p.status==="error")return R.jsxs("div",{className:"flex h-screen flex-col items-center justify-center gap-4",children:[R.jsx("div",{style:{color:"var(--archik-fg-error, #ef4444)"},children:p.message}),R.jsxs("a",{href:Ae,style:{color:"var(--archik-fg-muted)",fontSize:13},children:["← ",Ze]})]});const tn=UVn(p.doc,T),bn=h.replace(/^.*\//,"").replace(/\.archik\.seq\.yaml$/,""),_n=hn=>{const Rn=new URLSearchParams;Rn.set("path",hn),b?.type==="usecase"?Rn.set("from-uc",b.value):b?.type==="file"&&Rn.set("from-file",b.value),window.location.href=`/__archik/seq?${Rn.toString()}`};return R.jsxs("div",{className:"flex h-screen flex-col",style:{background:"var(--archik-canvas)"},children:[R.jsx(cWn,{backHref:Ae,backLabel:Ze,realizedSlice:ie,seqName:p.doc.name,railOpen:G,onToggleRail:()=>J(hn=>!hn),filename:bn,getSvg:()=>fe.current}),R.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[R.jsx("div",{style:{flex:1,overflow:"auto",padding:24},children:R.jsx(iWn,{laid:tn,svgRef:fe,onRefClick:_n})}),G&&R.jsx(uWn,{doc:p.doc,raw:p.raw,yamlOpen:se,onToggleYaml:()=>re(hn=>!hn),realizedSlice:ie,kinds:T})]})]})}function cWn({backHref:h,backLabel:b,realizedSlice:p,seqName:v,railOpen:T,onToggleRail:M,filename:j,getSvg:P}){return R.jsxs("header",{style:{display:"flex",alignItems:"center",gap:4,padding:"0 16px",height:48,borderBottom:"1px solid var(--archik-border)",background:"var(--archik-panel)",flexShrink:0,fontSize:13},children:[R.jsxs("a",{href:h,style:{display:"inline-flex",alignItems:"center",gap:2,color:"var(--archik-fg-dim)",textDecoration:"none"},children:[R.jsx(L1n,{size:14}),b]}),p&&R.jsxs(R.Fragment,{children:[R.jsx(U8e,{}),R.jsx("a",{href:`/__archik/usecases?uc=${encodeURIComponent(p.useCase)}`,style:{color:"var(--archik-fg-dim)",textDecoration:"none",fontFamily:"ui-monospace, monospace",fontSize:12},children:p.useCase}),R.jsx(U8e,{}),R.jsx("span",{style:{color:"var(--archik-fg)",fontFamily:"ui-monospace, monospace",fontSize:12},children:p.slice})]}),!p&&R.jsxs(R.Fragment,{children:[R.jsx(U8e,{}),R.jsx("span",{style:{color:"var(--archik-fg)",fontWeight:500},children:v})]}),R.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:6,alignItems:"center"},children:[R.jsx(S0n,{filename:j,getSvg:P}),R.jsx("button",{type:"button",onClick:M,"aria-label":T?"Hide details":"Show details","aria-pressed":T,title:T?"Hide details panel":"Show details panel",className:"archik-btn",style:{padding:"5px 8px"},children:T?R.jsx(fFn,{size:14}):R.jsx(hFn,{size:14})})]})]})}function U8e(){return R.jsx(SBn,{size:12,color:"var(--archik-fg-muted)",style:{marginInline:2}})}function uWn({doc:h,raw:b,yamlOpen:p,onToggleYaml:v,realizedSlice:T,kinds:M}){return R.jsxs("aside",{style:{width:300,flexShrink:0,borderLeft:"1px solid var(--archik-border)",background:"var(--archik-panel)",overflowY:"auto",padding:16,fontSize:12,color:"var(--archik-fg-dim)"},children:[R.jsx(tue,{title:"Realizes",children:T?R.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[R.jsx(T1n,{label:"Use case",children:R.jsxs("a",{href:`/__archik/usecases?uc=${encodeURIComponent(T.useCase)}`,style:iue({color:"var(--archik-accent)"}),children:[T.useCase,T.name?` — ${T.name}`:""]})}),R.jsx(T1n,{label:"Slice",children:R.jsx("code",{style:iue(),children:T.slice})}),T.slice_data?.description&&R.jsx("div",{style:{marginTop:4,fontSize:11,lineHeight:1.5},children:T.slice_data.description})]}):R.jsxs(x1n,{children:["No ",R.jsx("code",{children:"realizes"})," block — this is an ad-hoc / scratch flow, not bound to a use case slice."]})}),R.jsx(tue,{title:`Participants (${h.participants.length})`,children:R.jsx("ul",{style:M1n,children:h.participants.map(j=>{const P=M?.get(j.nodeId),G=P?Np[P]:void 0,J=G?.icon;return R.jsxs("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 0"},children:[J?R.jsx(J,{size:12,color:G.color,strokeWidth:2}):R.jsx("span",{style:{width:12}}),R.jsx("code",{style:iue(),children:j.nodeId}),j.id!==j.nodeId&&R.jsxs("span",{style:{fontSize:10,color:"var(--archik-fg-muted)"},children:["[",j.id,"]"]})]},j.id)})})}),T?.slice_data&&R.jsx(tue,{title:"Proved by",children:(T.slice_data.tests?.length??0)===0?R.jsx(x1n,{children:"No tests declared on this slice."}):R.jsx("ul",{style:{...M1n,listStyle:"none",paddingLeft:0},children:T.slice_data.tests.map(j=>R.jsxs("li",{style:{...iue(),fontSize:11,padding:"2px 0"},children:[R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"•"})," ",j]},j))})}),R.jsxs(tue,{title:"Source",children:[R.jsxs("button",{type:"button",onClick:v,className:"archik-btn",style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"4px 8px"},children:[R.jsx(zBn,{size:11}),p?"Hide YAML":"View YAML"]}),p&&R.jsx("pre",{style:{marginTop:8,padding:10,background:"var(--archik-surface)",border:"1px solid var(--archik-border)",borderRadius:4,fontSize:10,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--archik-fg-dim)",overflowX:"auto",whiteSpace:"pre",maxHeight:360,overflowY:"auto"},children:b})]})]})}function tue({title:h,children:b}){return R.jsxs("section",{style:{marginBottom:18},children:[R.jsx("h2",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--archik-fg-muted)",margin:"0 0 6px"},children:h}),b]})}function T1n({label:h,children:b}){return R.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline"},children:[R.jsx("span",{style:{fontSize:9,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",width:56,flexShrink:0},children:h}),R.jsx("span",{style:{flex:1,minWidth:0},children:b})]})}function x1n({children:h}){return R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-muted)",lineHeight:1.5},children:h})}function iue(h){return{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:11,color:"var(--archik-fg)",textDecoration:"none",...h}}const M1n={margin:0,paddingLeft:0,listStyle:"none"},sWn="/__archik/usecases",oWn="/__archik/trace";async function C1n(h,b){const p=await fetch(h,{cache:"no-store",signal:b});if(!p.ok)throw new Error(`HTTP ${p.status} ${p.statusText}`);return await p.json()}function lWn({selectedId:h}){const[b,p]=lt.useState({status:"loading"});return lt.useEffect(()=>{let v=!1;const T=new AbortController;return Promise.all([C1n(sWn,T.signal),C1n(oWn,T.signal)]).then(([M,j])=>{v||p({status:"ready",useCases:M.useCases??[],trace:j.rows??[]})}).catch(M=>{v||T.signal.aborted||p({status:"error",message:M instanceof Error?M.message:String(M)})}),()=>{v=!0,T.abort()}},[]),R.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",background:"var(--archik-canvas)",color:"var(--archik-fg)",fontFamily:"Inter, system-ui, sans-serif"},children:[R.jsx(fWn,{state:b}),R.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[b.status==="loading"&&R.jsx(J8e,{children:"Loading…"}),b.status==="error"&&R.jsxs(J8e,{tone:"error",children:["Couldn't load: ",b.message]}),b.status==="ready"&&b.useCases.length===0&&R.jsxs(J8e,{children:["No use cases defined yet. Add a ",R.jsx("code",{children:"*.archik.uc.yaml"})," file under ",R.jsx("code",{children:".archik/usecases/"}),"."]}),b.status==="ready"&&b.useCases.length>0&&R.jsx(aWn,{useCases:b.useCases,trace:b.trace,selectedId:h})]})]})}function fWn({state:h}){const b=lt.useMemo(()=>{if(h.status!=="ready")return null;let p=0,v=0,T=0;for(const M of h.trace)M.level==="full"?p++:M.level==="partial"?v++:T++;return{full:p,partial:v,none:T,total:h.trace.length}},[h]);return R.jsxs("header",{style:{display:"flex",alignItems:"center",gap:16,padding:"0 20px",height:52,borderBottom:"1px solid var(--archik-border)",background:"var(--archik-panel)",flexShrink:0},children:[R.jsxs("a",{href:"/",style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-fg-dim)",fontSize:13,textDecoration:"none"},children:[R.jsx(L1n,{size:14}),"Architecture"]}),R.jsx("span",{style:{color:"var(--archik-border-strong)"},children:"|"}),R.jsx("h1",{style:{fontSize:14,fontWeight:600,margin:0,color:"var(--archik-fg)"},children:"Use cases"}),b&&b.total>0&&R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginLeft:"auto",fontSize:12,color:"var(--archik-fg-dim)"},children:[R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-success)"},children:"●"})," ",b.full," full"]}),R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-warning)"},children:"◐"})," ",b.partial," partial"]}),R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"○"})," ",b.none," untraced"]}),R.jsxs("span",{style:{color:"var(--archik-fg-muted)"},children:["· ",b.total," ",b.total===1?"slice":"slices"]})]})]})}function aWn({useCases:h,trace:b,selectedId:p}){const v=lt.useMemo(()=>{const j=new Map;for(const P of b){const G=j.get(P.useCase);if(!G){j.set(P.useCase,P.level);continue}G==="none"||P.level==="none"?j.set(P.useCase,"none"):(G==="partial"||P.level==="partial")&&j.set(P.useCase,"partial")}return j},[b]),T=lt.useMemo(()=>{const j=new Map;for(const P of b)j.set(`${P.useCase}/${P.slice}`,P);return j},[b]),M=h.find(j=>j.id===p)??h[0];return R.jsxs(R.Fragment,{children:[R.jsx(hWn,{useCases:h,ucLevel:v,selectedId:M.id}),R.jsx(dWn,{useCase:M,traceByKey:T})]})}function hWn({useCases:h,ucLevel:b,selectedId:p}){return R.jsx("nav",{"aria-label":"Use cases",style:{width:260,borderRight:"1px solid var(--archik-border)",background:"var(--archik-panel)",overflowY:"auto",padding:"8px 0",flexShrink:0},children:R.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:h.map(v=>{const T=b.get(v.id)??"none",M=v.id===p;return R.jsx("li",{children:R.jsxs("a",{href:`/__archik/usecases?uc=${encodeURIComponent(v.id)}`,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 14px",textDecoration:"none",color:"var(--archik-fg)",background:M?"var(--archik-surface-hover)":"transparent",borderLeft:M?"2px solid var(--archik-accent)":"2px solid transparent",fontSize:13},children:[R.jsx(R0n,{level:T}),R.jsxs("span",{style:{flex:1,minWidth:0},children:[R.jsx("code",{style:{fontSize:12,fontFamily:"ui-monospace, monospace"},children:v.id}),R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.name})]}),v.status&&v.status!=="active"&&R.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:4,background:"var(--archik-surface)",color:"var(--archik-fg-muted)"},children:v.status})]})},v.id)})})})}function R0n({level:h}){const b=h==="full"?{glyph:"●",color:"var(--archik-success)",label:"fully traced"}:h==="partial"?{glyph:"◐",color:"var(--archik-warning)",label:"partially traced"}:{glyph:"○",color:"var(--archik-fg-muted)",label:"untraced"};return R.jsx("span",{title:b.label,"aria-label":b.label,style:{color:b.color,fontSize:12,lineHeight:1,width:12},children:b.glyph})}function dWn({useCase:h,traceByKey:b}){return R.jsx("main",{style:{flex:1,overflowY:"auto",padding:"24px 32px"},children:R.jsxs("div",{style:{maxWidth:820,margin:"0 auto"},children:[R.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:12,marginBottom:4},children:[R.jsx("code",{style:{fontSize:18,fontFamily:"ui-monospace, monospace",fontWeight:600,color:"var(--archik-fg)"},children:h.id}),h.status&&h.status!=="active"&&R.jsx("span",{className:"archik-pill",style:{fontSize:10},children:h.status})]}),R.jsx("div",{style:{fontSize:15,color:"var(--archik-fg-dim)",marginBottom:18},children:h.name}),R.jsx(bWn,{useCase:h}),h.goal&&R.jsx(cI,{title:"Goal",children:R.jsx("p",{style:{margin:0,lineHeight:1.55},children:h.goal})}),(h.preconditions?.length??0)>0&&R.jsx(cI,{title:"Preconditions",children:R.jsx("ul",{style:QU,children:h.preconditions.map((p,v)=>R.jsx("li",{children:p},v))})}),h.flows?.basic?.steps&&R.jsx(cI,{title:"Basic flow",children:R.jsx("ol",{style:{...QU,paddingLeft:22},children:h.flows.basic.steps.map((p,v)=>R.jsx("li",{style:{marginBottom:4},children:p},v))})}),(h.flows?.alternates?.length??0)>0&&R.jsx(cI,{title:"Alternate flows",children:h.flows.alternates.map(p=>R.jsxs("div",{style:{marginBottom:12,padding:12,background:"var(--archik-surface)",borderRadius:6,borderLeft:"3px solid var(--archik-warning)"},children:[R.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline",marginBottom:6},children:[R.jsx("code",{style:{fontSize:12,fontWeight:600},children:p.id}),p.branchFrom&&R.jsxs("span",{style:{fontSize:11,color:"var(--archik-fg-muted)"},children:["branches from ",p.branchFrom]})]}),R.jsx("ol",{style:{...QU,paddingLeft:22,fontSize:13},children:p.steps.map((v,T)=>R.jsx("li",{children:v},T))})]},p.id))}),(h.postconditions?.length??0)>0&&R.jsx(cI,{title:"Postconditions",children:R.jsx("ul",{style:QU,children:h.postconditions.map((p,v)=>R.jsx("li",{children:p},v))})}),(()=>{const p=h.slices??[];return R.jsx(cI,{title:`Slices (${p.length})`,children:p.length===0?R.jsx("div",{style:{fontSize:12,color:"var(--archik-fg-muted)"},children:"— no slices declared"}):R.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:p.map(v=>R.jsx(gWn,{slice:v,useCaseId:h.id,trace:b.get(`${h.id}/${v.id}`)},v.id))})})})(),R.jsxs("div",{style:{marginTop:32,paddingTop:16,borderTop:"1px solid var(--archik-border)",fontSize:11,color:"var(--archik-fg-muted)"},children:["Source:"," ",R.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:h.relPath})]})]})})}function bWn({useCase:h}){return R.jsxs("div",{style:{display:"flex",gap:24,padding:"10px 14px",background:"var(--archik-surface)",borderRadius:6,marginBottom:20,fontSize:12},children:[R.jsxs("div",{children:[R.jsx("div",{style:b7e,children:"Primary actor"}),R.jsx("div",{style:{marginTop:2},children:R.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:h.primaryActor})})]}),(h.secondaryActors?.length??0)>0&&R.jsxs("div",{children:[R.jsx("div",{style:b7e,children:"Secondary actors"}),R.jsx("div",{style:{marginTop:2},children:h.secondaryActors.map((b,p)=>R.jsxs("span",{children:[R.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:b}),p<h.secondaryActors.length-1&&", "]},b))})]})]})}function gWn({slice:h,useCaseId:b,trace:p}){const v=p?.level??"none";return R.jsxs("div",{style:{padding:14,background:"var(--archik-panel)",border:"1px solid var(--archik-border)",borderRadius:8},children:[R.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,marginBottom:8},children:[R.jsx(R0n,{level:v}),R.jsx("code",{style:{fontSize:13,fontFamily:"ui-monospace, monospace",fontWeight:600},children:h.id}),h.status&&h.status!=="active"&&R.jsxs("span",{style:{fontSize:10,color:"var(--archik-fg-muted)"},children:["[",h.status,"]"]}),R.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--archik-fg-muted)"},children:p?.realization&&p.realization.participants.length>0&&R.jsxs(R.Fragment,{children:["ECB"," ",p.realization.participants.filter(T=>T.stereotype!==void 0).length,"/",p.realization.participants.length]})})]}),h.description&&R.jsx("div",{style:{fontSize:13,color:"var(--archik-fg-dim)",marginBottom:10,lineHeight:1.5},children:h.description}),R.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:14,rowGap:8,fontSize:12,alignItems:"start"},children:[R.jsx("div",{style:H8e,children:"Tests"}),R.jsx("div",{children:(h.tests?.length??0)===0?R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"— none declared"}):R.jsx("ul",{style:{...QU,paddingLeft:0,listStyle:"none"},children:h.tests.map(T=>R.jsxs("li",{style:{fontFamily:"ui-monospace, monospace",fontSize:11},children:[R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"•"})," ",T]},T))})}),R.jsx("div",{style:H8e,children:"Realization"}),R.jsx("div",{children:h.realization?R.jsxs("a",{href:`/__archik/seq?path=${encodeURIComponent(h.realization.seqFile)}&from-uc=${encodeURIComponent(b)}`,style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-accent)",textDecoration:"none",fontFamily:"ui-monospace, monospace",fontSize:11},children:[R.jsx(I1n,{size:11}),wWn(h.realization.seqFile),R.jsx(D1n,{size:11,style:{opacity:.7}})]}):R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"— no seq file yet"})}),R.jsx("div",{style:H8e,children:"Flows"}),R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-dim)"},children:(h.flows??[]).join(", ")||"—"})]})]})}function wWn(h){return h.split("/").pop()?.replace(/\.archik\.seq\.yaml$/,"")??h}function cI({title:h,children:b}){return R.jsxs("section",{style:{marginBottom:24},children:[R.jsx("h2",{style:{fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",margin:"0 0 8px"},children:h}),b]})}function J8e({children:h,tone:b}){return R.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:b==="error"?"var(--archik-danger)":"var(--archik-fg-muted)",fontSize:13,padding:24,textAlign:"center"},children:h})}const b7e={fontSize:10,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",fontWeight:600},H8e={...b7e,fontSize:10,paddingTop:1},QU={margin:0,paddingLeft:18,fontSize:13,lineHeight:1.55},P0n=document.getElementById("root");if(!P0n)throw new Error("#root not found");const VU=new URLSearchParams(window.location.search),mue=window.location.pathname,pWn=mue==="/__archik/seq"||mue.startsWith("/__archik/seq/"),mWn=mue==="/__archik/usecases"||mue.startsWith("/__archik/usecases/"),K8e=Nzn.createRoot(P0n);if(pWn){const h=VU.get("path")??"",b=VU.get("from-uc"),p=VU.get("from-file")??VU.get("from"),v=b?{type:"usecase",value:b}:p?{type:"file",value:p}:null;K8e.render(R.jsx(lt.StrictMode,{children:R.jsx(rWn,{path:h,back:v})}))}else if(mWn){const h=VU.get("uc");K8e.render(R.jsx(lt.StrictMode,{children:R.jsx(lWn,{selectedId:h})}))}else K8e.render(R.jsx(lt.StrictMode,{children:R.jsx(EVn,{})}));
226
+ `);return b===-1?h:h.slice(0,b)}function wVn({files:h,currentPath:b,onSwitchFile:p}){const v=h.some(M=>M.hasSuggestion||M.isOrphanSuggestion);if(h.length<=1&&!v)return null;const T=h.find(M=>M.path===b)??h[0];return R.jsx(TT,{align:"start",trigger:M=>R.jsxs("button",{type:"button","aria-label":"Switch architecture file","aria-expanded":M,className:"archik-btn",style:{display:"flex",alignItems:"center",gap:6,padding:"4px 10px",fontSize:12,background:"transparent",color:"var(--archik-fg)"},children:[R.jsx(FBn,{size:13,strokeWidth:1.8}),R.jsx("span",{style:{fontWeight:600},children:T.name}),T.hasSuggestion&&R.jsx(pue,{}),R.jsx($1n,{size:12,strokeWidth:2,style:{opacity:.6}})]}),children:M=>R.jsxs("div",{style:{minWidth:220,padding:4},children:[R.jsx("div",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--archik-fg-muted)",padding:"6px 10px 4px"},children:"Architecture files"}),h.map(j=>{const P=j.path===T.path,G=j.isOrphanSuggestion===!0;return R.jsxs("button",{type:"button",title:G?`Pending sub-architecture (sidecar only — no main file yet). Click to view; accept via \`npx archik suggest accept ${j.path.replace(/\.archik\.suggested\.yaml$/,".archik.yaml")}\` to promote it, or /archik:accept.`:void 0,onClick:()=>{M(),!P&&p(j)},className:"archik-menu-item",style:{display:"flex",alignItems:"center",gap:8,width:"100%",textAlign:"left",padding:"6px 10px",fontSize:12,background:P?"var(--archik-surface-hover)":void 0,borderLeft:G?"2px dashed var(--archik-accent)":void 0,paddingLeft:G?8:void 0},children:[R.jsxs("span",{style:{fontWeight:P?600:400,color:"var(--archik-fg)"},children:[j.name,G&&R.jsx("span",{style:{marginLeft:6,fontSize:10,fontWeight:500,color:"var(--archik-accent)",letterSpacing:"0.04em"},children:"(pending)"})]}),j.hasSuggestion&&!G&&R.jsx(pue,{}),R.jsx("span",{style:{flex:1,fontSize:10,fontFamily:"ui-monospace, monospace",color:"var(--archik-fg-muted)",textAlign:"right"},children:j.path})]},j.path)})]})})}function pue(){return R.jsx("span",{"aria-label":"pending suggestion",title:"Pending suggestion",style:{width:6,height:6,borderRadius:3,background:"var(--archik-accent)",flexShrink:0}})}function pVn({stack:h,onGoToFrame:b,suggestionsByPath:p}){return h.length<=1?null:R.jsx("nav",{"aria-label":"Architecture file navigation",style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--archik-fg-muted)"},children:h.map((v,T)=>{const M=T===h.length-1,j=v.archikFile!==null&&p!==void 0&&p.has(v.archikFile);return R.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[M?R.jsxs("span",{style:{color:"var(--archik-fg)",fontWeight:600,display:"inline-flex",alignItems:"center",gap:6},"aria-current":"page",children:[v.label,j&&R.jsx(pue,{})]}):R.jsxs("button",{type:"button",onClick:()=>b(T),className:"archik-btn",style:{padding:"2px 6px",fontSize:12,color:"var(--archik-fg-muted)",background:"transparent",display:"inline-flex",alignItems:"center",gap:6},title:`Back to ${v.label}`,children:[v.label,j&&R.jsx(pue,{})]}),!M&&R.jsx("span",{"aria-hidden":"true",style:{opacity:.5},children:"›"})]},`${T}-${v.archikFile??"root"}`)})})}const mVn="/architecture.archik.yaml",vVn="/architecture.archik.suggested.yaml",yVn="/__archik/accept-suggestion",kVn=1500,h7e={label:"main",docUrl:mVn,sidecarUrl:vVn,acceptUrl:yVn,archikFile:null};function M0n(h,b){const p=h.replace(/\.archik\.yaml$/,".archik.suggested.yaml"),v=encodeURIComponent(h),T=encodeURIComponent(p);return{label:b,docUrl:`/__archik/file?path=${v}`,sidecarUrl:`/__archik/file?path=${T}`,acceptUrl:`/__archik/file-accept?path=${v}`,archikFile:h}}function jVn(){if(typeof window>"u")return null;const h=new URLSearchParams(window.location.search).get("file");return h!==null&&h.length>0?h:null}function SVn(h){if(typeof window>"u")return;const b=new URL(window.location.href);h===null||h.length===0?b.searchParams.delete("file"):b.searchParams.set("file",h),window.history.replaceState(null,"",b.toString())}function m1n(){const h=jVn();if(h===null)return[h7e];const p=(h.split("/").pop()??h).replace(/\.archik\.yaml$/i,"")||"main";return[M0n(h,p)]}function EVn(){const[h,b]=lt.useState({status:"loading"}),[p,v]=lt.useState(m1n),T=p[p.length-1],[M,j]=lt.useState([]),P=lt.useMemo(()=>new Set(M.filter(xn=>xn.hasSuggestion).map(xn=>xn.path)),[M]),G=lt.useMemo(()=>M.find(xn=>xn.isRoot)??null,[M]),J=T.archikFile===null?G?.path??null:T.archikFile,[se,re]=lt.useState(void 0),[fe,Ae]=lt.useState(void 0),[Ze,ie]=lt.useState("idle"),[tn,bn]=lt.useState(null),[_n,hn]=lt.useState(!1),[Rn,rt]=lt.useState(!1),[dt,Wn]=lt.useState({status:"none"}),[pt,wr]=lt.useState(!1),[Wr,Yr]=lt.useState([]),[Ui,Q]=lt.useState([]),Yo=100,[Ao,Jn]=lt.useState(()=>qXn()),ct=xn=>{Jn(xn),GXn(xn)},[ki,Br]=lt.useState(()=>BXn()),Xc=xn=>{Br(xn),FXn(xn)},[He,Yn]=lt.useState(()=>PXn()),ti=xn=>{Yn(xn),zXn(xn)},ji=lt.useMemo(()=>({...UXn(Ao),viewMode:ki}),[Ao,ki]),ar=lt.useMemo(()=>h.status==="ready"?new Set(h.document.nodes.filter(xn=>(xn.seqFiles?.length??0)>0).map(xn=>xn.id)):new Set,[h]),Jr=lt.useRef(!1),Oc=lt.useRef(null),Rs=lt.useRef(null),Wu=lt.useCallback(()=>Rs.current,[]),sh=lt.useRef(null),ds=oy(xn=>xn.selection),oa=oy(xn=>xn.connectFrom),r5=oy(xn=>xn.selectNode),Na=oy(xn=>xn.selectEdge),hy=oy(xn=>xn.toggleNode),iv=oy(xn=>xn.toggleEdge),Ab=oy(xn=>xn.clearSelection),t7=oy(xn=>xn.startConnect),su=oy(xn=>xn.cancelConnect),Vc=ds.length>0?ds.at(-1)??null:null,c5=lt.useMemo(()=>new Set(ds.filter(xn=>xn.type==="node").map(xn=>xn.id)),[ds]),Ps=lt.useMemo(()=>new Set(ds.filter(xn=>xn.type==="edge").map(xn=>xn.id)),[ds]);lt.useEffect(()=>{const xn=p[p.length-1];SVn(xn.archikFile)},[p]),lt.useEffect(()=>{if(typeof window>"u")return;const xn=()=>v(m1n());return window.addEventListener("popstate",xn),()=>window.removeEventListener("popstate",xn)},[]),lt.useEffect(()=>{let xn=!1;Oc.current="",Jr.current=!1;const Pt=()=>{BZn(T.docUrl).then(({document:xi,text:Dr})=>{if(xn||Dr===Oc.current)return;Oc.current=Dr,Jr.current=!0,b({status:"ready",document:xi}),hn(!1),typeof window<"u"&&xi.name&&(window.document.title=`${xi.name} — Archik`),Ae(void 0),Yr([]),Q([]);const Al=new Set(xi.nodes.map(ou=>ou.id)),To=new Set(xi.edges.map(ou=>ou.id));oy.setState(ou=>({selection:ou.selection.filter(Rc=>Rc.type==="node"?Al.has(Rc.id):To.has(Rc.id)),connectFrom:ou.connectFrom!==null&&Al.has(ou.connectFrom)?ou.connectFrom:null}))},xi=>{if(xn)return;const Dr=xi instanceof Error?xi.message:String(xi);Jr.current?Ae(Dr):b({status:"error",error:Dr})})};b({status:"loading"}),Pt();const Ji=s1n(Pt);return()=>{xn=!0,Ji()}},[T.docUrl]),lt.useEffect(()=>()=>{sh.current&&clearTimeout(sh.current)},[]),lt.useEffect(()=>{let xn=!1;const Pt=async()=>{try{const Dr=await fetch("/__archik/files",{cache:"no-store"});if(xn||!Dr.ok)return;const Al=await Dr.json();if(xn)return;Array.isArray(Al.files)&&j(Al.files)}catch{}};Pt();const Ji=s1n(()=>{Pt()}),xi=o1n(()=>{Pt()});return()=>{xn=!0,Ji(),xi()}},[]),lt.useEffect(()=>{if(h.status!=="ready")return;const xn=h.document;let Pt=!1;const Ji=async()=>{if(J!==null&&M.length>0&&M.some(Dr=>Dr.path===J)&&!P.has(J)){Wn({status:"none"});return}try{const Dr=await fetch(T.sidecarUrl,{cache:"no-store"});if(Pt)return;if(Dr.status===404){Wn({status:"none"});return}if(!Dr.ok){Wn({status:"error",message:`Sidecar fetch failed: HTTP ${Dr.status}`});return}const Al=await Dr.text();let To;try{To=w0n(Al)}catch(Rc){Wn({status:"error",message:Rc instanceof Error?Rc.message:String(Rc)});return}const ou=l7e(xn,To);Wn({status:"pending",added:ou.nodes.added.length+ou.edges.added.length,removed:ou.nodes.removed.length+ou.edges.removed.length,changed:ou.nodes.changed.length+ou.edges.changed.length,doc:To,...To.metadata?.suggestion?.note!==void 0?{note:To.metadata.suggestion.note}:{}})}catch(Dr){if(Pt)return;Wn({status:"error",message:Dr instanceof Error?Dr.message:String(Dr)})}};Ji();const xi=o1n(Ji);return()=>{Pt=!0,xi()}},[h,T.sidecarUrl,J,M,P]);const xT=lt.useCallback(async()=>{try{const xn=await fetch(T.acceptUrl,{method:"POST"});if(!xn.ok){const Pt=await xn.text();Wn({status:"error",message:`Accept failed: ${Pt||`HTTP ${xn.status}`}`});return}Wn({status:"none"}),wr(!1)}catch(xn){Wn({status:"error",message:xn instanceof Error?xn.message:String(xn)})}},[T.acceptUrl]),oh=lt.useCallback(async()=>{try{const xn=await fetch(T.sidecarUrl,{method:"DELETE"});if(!xn.ok&&xn.status!==404){const Pt=await xn.text();Wn({status:"error",message:`Reject failed: ${Pt||`HTTP ${xn.status}`}`});return}Wn({status:"none"}),wr(!1)}catch(xn){Wn({status:"error",message:xn instanceof Error?xn.message:String(xn)})}},[T.sidecarUrl]),MT=lt.useCallback(()=>{wr(xn=>!xn)},[]),dy=lt.useCallback(async()=>{let xn=null;if(b(Ji=>(Ji.status==="ready"&&(xn=Ji.document),Ji)),!xn)return;const Pt=G7e(xn);Oc.current=Pt,ie("saving"),bn(null);try{await FZn(T.docUrl,xn),ie("saved");let Ji=!1;b(xi=>(xi.status==="ready"&&xi.document===xn&&(Ji=!0),xi)),Ji&&hn(!1),sh.current&&clearTimeout(sh.current),sh.current=setTimeout(()=>ie("idle"),kVn)}catch(Ji){ie("error"),bn(Ji instanceof Error?Ji.message:String(Ji))}},[T.docUrl]),rv=G?.path??null,Zg=lt.useCallback((xn,Pt)=>rv===xn?h7e:M0n(xn,Pt),[rv]),by=lt.useCallback((xn,Pt)=>xn.archikFile===Pt?!0:xn.archikFile===null&&rv===Pt,[rv]),i7=lt.useCallback((xn,Pt)=>{v(Ji=>{const xi=Ji.findIndex(Dr=>by(Dr,xn));return xi>=0?xi===Ji.length-1?Ji:Ji.slice(0,xi+1):[...Ji,Zg(xn,Pt)]})},[Zg,by]),u5=lt.useCallback((xn,Pt)=>{v(Ji=>{const xi=Ji[Ji.length-1];return by(xi,xn)?Ji:[Zg(xn,Pt)]})},[Zg,by]),CT=lt.useCallback(xn=>{v(Pt=>xn<0||xn>=Pt.length-1?Pt:Pt.slice(0,xn+1))},[]),cv=lt.useCallback(xn=>{xn.isRoot?v([h7e]):u5(xn.path,xn.name)},[u5]),lh=lt.useCallback((xn,Pt)=>{if(oa===null){Pt&&(Pt.metaKey||Pt.ctrlKey||Pt.shiftKey)?hy(xn):r5(xn);return}if(xn===oa){su();return}let Ji=null;b(xi=>{if(xi.status!=="ready"||!xi.document.nodes.find(Rc=>Rc.id===oa))return xi;const Al=new Set(xi.document.edges.map(Rc=>Rc.id)),To=$8e(D8e(`${oa}-${xn}`),Al,"edge"),ou={id:To,from:oa,to:xn,relationship:"http_call"};try{const Rc=tI(xi.document,{type:"connect",edge:ou});return re(void 0),hn(!0),Yr(Bu=>[...Bu.slice(-(Yo-1)),xi.document]),Q([]),Ji=To,{status:"ready",document:Rc}}catch(Rc){const Bu=Rc instanceof Error?Rc.message:String(Rc);return re(Bu),xi}}),su(),Ji&&Na(Ji)},[oa,su,r5,hy,Na]),Tb=lt.useCallback((xn,Pt)=>{Pt&&(Pt.metaKey||Pt.ctrlKey||Pt.shiftKey)?iv(xn):Na(xn)},[Na,iv]),fh=lt.useCallback((xn,Pt)=>{let Ji=null;b(xi=>{if(xi.status!=="ready")return xi;const Dr=xi.document.nodes.find(Bu=>Bu.id===xn),Al=xi.document.nodes.find(Bu=>Bu.id===Pt);if(!Dr||!Al)return xi;const To=new Set(xi.document.edges.map(Bu=>Bu.id)),ou=$8e(D8e(`${xn}-${Pt}`),To,"edge"),Rc={id:ou,from:xn,to:Pt,relationship:"http_call"};try{const Bu=tI(xi.document,{type:"connect",edge:Rc});return re(void 0),hn(!0),Yr(Mb=>[...Mb.slice(-(Yo-1)),xi.document]),Q([]),Ji=ou,{status:"ready",document:Bu}}catch(Bu){const Mb=Bu instanceof Error?Bu.message:String(Bu);return re(Mb),xi}}),Ji&&Na(Ji)},[Na]),OT=lt.useCallback((xn,Pt,Ji)=>{b(xi=>{if(xi.status!=="ready")return xi;const Dr=new Set(xi.document.nodes.map(To=>To.id)),Al=$8e(D8e(Pt),Dr,xn);try{const To=tI(xi.document,{type:"add_node",node:{id:Al,kind:xn,name:Pt,description:Ji}});return re(void 0),hn(!0),Yr(ou=>[...ou.slice(-(Yo-1)),xi.document]),Q([]),{status:"ready",document:To}}catch(To){const ou=To instanceof Error?To.message:String(To);return re(ou),xi}})},[]),r7=lt.useCallback(xn=>{b(Pt=>{if(Pt.status!=="ready")return Pt;try{const Ji=tI(Pt.document,xn);return re(void 0),hn(!0),Yr(xi=>[...xi.slice(-(Yo-1)),Pt.document]),Q([]),{status:"ready",document:Ji}}catch(Ji){const xi=Ji instanceof Error?Ji.message:String(Ji);return re(xi),Pt}})},[]),s5=lt.useCallback(()=>{ds.length!==0&&(b(xn=>{if(xn.status!=="ready")return xn;let Pt=xn.document;try{const Ji=ds.filter(Dr=>Dr.type==="edge").map(Dr=>Dr.id);for(const Dr of Ji)Pt.edges.some(Al=>Al.id===Dr)&&(Pt=tI(Pt,{type:"disconnect",id:Dr}));const xi=ds.filter(Dr=>Dr.type==="node").map(Dr=>Dr.id);for(const Dr of xi)Pt.nodes.some(Al=>Al.id===Dr)&&(Pt=tI(Pt,{type:"remove_node",id:Dr}));return Pt===xn.document?xn:(re(void 0),hn(!0),Yr(Dr=>[...Dr.slice(-(Yo-1)),xn.document]),Q([]),{status:"ready",document:Pt})}catch(Ji){const xi=Ji instanceof Error?Ji.message:String(Ji);return re(xi),xn}}),Ab())},[ds,Ab]),$p=lt.useCallback(()=>{if(h.status!=="ready"||Wr.length===0)return;const xn=Wr[Wr.length-1];Yr(Pt=>Pt.slice(0,-1)),Q(Pt=>[...Pt,h.document]),b({status:"ready",document:xn}),hn(!0),re(void 0),Ab()},[h,Wr,Ab]),Xg=lt.useCallback(()=>{if(h.status!=="ready"||Ui.length===0)return;const xn=Ui[Ui.length-1];Q(Pt=>Pt.slice(0,-1)),Yr(Pt=>[...Pt,h.document]),b({status:"ready",document:xn}),hn(!0),re(void 0),Ab()},[h,Ui,Ab]);if(lt.useEffect(()=>{const xn=Pt=>{if((Pt.metaKey||Pt.ctrlKey)&&Pt.key==="s"){Pt.preventDefault(),_n&&dy();return}if((Pt.metaKey||Pt.ctrlKey)&&(Pt.key==="z"||Pt.key==="Z")){Pt.preventDefault(),Pt.shiftKey?Xg():$p();return}if((Pt.metaKey||Pt.ctrlKey)&&Pt.key==="y"){Pt.preventDefault(),Xg();return}if(Pt.key==="Escape"){oa&&su();return}if(Pt.key==="Delete"||Pt.key==="Backspace"){const Ji=Pt.target;if(Ji instanceof HTMLInputElement||Ji instanceof HTMLTextAreaElement||Ji instanceof HTMLSelectElement||Ji instanceof HTMLElement&&Ji.isContentEditable||ds.length===0)return;Pt.preventDefault(),s5()}};return window.addEventListener("keydown",xn),()=>window.removeEventListener("keydown",xn)},[_n,dy,oa,su,ds,s5,$p,Xg]),h.status==="loading")return R.jsxs(v1n,{children:["Loading ",T.docUrl,"…"]});if(h.status==="error")return R.jsx(v1n,{children:R.jsx("pre",{className:"max-w-3xl whitespace-pre-wrap text-xs text-rose-700",children:h.error})});const xb=h.document,E1=pt&&dt.status==="pending",gy=E1&&dt.status==="pending"?XZn(xb,dt.doc):null,Lp=E1&&dt.status==="pending"?y0n(l7e(xb,dt.doc)):null,wy=gy??xb,c7=Vc?.type==="node"?wy.nodes.find(xn=>xn.id===Vc.id):void 0,o5=Vc?.type==="edge"?wy.edges.find(xn=>xn.id===Vc.id):void 0,Rp=oa!==null?xb.nodes.find(xn=>xn.id===oa):void 0,u7=ds.length>1;return R.jsxs("div",{className:"flex h-full flex-col",style:{background:"var(--archik-canvas)",color:"var(--archik-fg)"},children:[R.jsx(bVn,{document:xb,commandError:se,saveStatus:Ze,...tn!==null?{saveError:tn}:{},isDirty:_n,onSave:()=>{dy()},onAddNode:OT,density:Ao,onDensityChange:ct,viewMode:ki,onViewModeChange:Xc,showStereotypeBands:He,onToggleStereotypeBands:()=>ti(!He),canUndo:Wr.length>0,canRedo:Ui.length>0,onUndo:$p,onRedo:Xg,getSvg:Wu,seqHighlight:Rn,onToggleSeqHighlight:()=>rt(xn=>!xn),seqNodeCount:ar.size,...fe!==void 0?{reloadError:fe}:{},...Rp!==void 0?{connectingFromName:Rp.name,onCancelConnect:su}:{}}),dt.status==="pending"&&R.jsx(TVn,{added:dt.added,removed:dt.removed,changed:dt.changed,note:dt.note,reviewing:E1,onReview:MT,onAccept:()=>{xT()},onReject:()=>{oh()}}),dt.status==="error"&&R.jsxs("div",{role:"alert",style:{background:"rgba(217, 119, 6, 0.12)",borderBottom:"1px solid rgba(217, 119, 6, 0.45)",color:"var(--archik-warning)",padding:"8px 16px",fontSize:12,display:"flex",alignItems:"center",gap:12},children:[R.jsx("span",{style:{fontWeight:700},children:"SUGGESTION ERROR —"}),R.jsx("span",{style:{flex:1,color:"var(--archik-fg)"},children:dt.message}),R.jsx("button",{type:"button",onClick:()=>Wn({status:"none"}),"aria-label":"Dismiss",style:{background:"transparent",border:"none",color:"var(--archik-fg-dim)",cursor:"pointer",fontSize:16,lineHeight:1},children:"×"})]}),fe!==void 0&&R.jsxs("div",{role:"alert",style:{background:"rgba(225, 29, 72, 0.12)",borderBottom:"1px solid rgba(225, 29, 72, 0.45)",color:"var(--archik-danger)",padding:"10px 16px",display:"flex",alignItems:"flex-start",gap:12,fontSize:12,lineHeight:1.5},children:[R.jsx("span",{style:{fontWeight:700,letterSpacing:"0.04em"},children:"FILE INVALID —"}),R.jsx("pre",{style:{margin:0,flex:1,whiteSpace:"pre-wrap",fontFamily:"inherit",color:"var(--archik-fg)"},children:fe}),R.jsx("button",{type:"button",onClick:()=>Ae(void 0),"aria-label":"Dismiss error",style:{background:"transparent",border:"none",color:"var(--archik-fg-dim)",cursor:"pointer",padding:"0 4px",fontSize:16,lineHeight:1},children:"×"})]}),R.jsxs("main",{className:"flex min-h-0 flex-1 p-4",style:{gap:0},children:[R.jsx("div",{className:"archik-panel",style:{flex:1,minWidth:0,overflow:"hidden"},children:R.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%"},children:[(M.length>1||p.length>1)&&R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",background:"var(--archik-surface)",borderBottom:"1px solid var(--archik-border)"},children:[R.jsx(wVn,{files:M,currentPath:J,onSwitchFile:cv}),R.jsx(pVn,{stack:p,onGoToFrame:CT,suggestionsByPath:P})]}),R.jsx(Bqn,{document:wy,className:"flex-1 archik-grid",layoutOptions:ji,viewMode:ki,showStereotypeBands:He,selectedNodeIds:c5,selectedEdgeIds:Ps,onSelectNode:lh,onSelectEdge:Tb,onSelectNothing:oa===null?Ab:su,onConnectDrag:fh,onOpenSubFile:i7,onCrossFileNavigate:u5,viewKey:T.docUrl,svgRef:Rs,...Lp?{diffStatuses:Lp}:{},...Rn&&ar.size>0?{glowNodeIds:ar}:{}})]})}),R.jsx("aside",{"aria-hidden":ds.length===0,className:`archik-drawer-shell ${ds.length>0?"archik-drawer-shell--open":"archik-drawer-shell--closed"}`,children:R.jsx("div",{className:"archik-panel archik-drawer-content archik-drawer-fade",style:{overflow:"hidden"},children:u7?R.jsx(AVn,{count:ds.length,onDelete:s5,onClear:Ab}):Vc?.type==="edge"?R.jsx(bXn,{edge:o5,dispatch:r7,readOnly:E1}):Vc?.type==="node"?R.jsx(oXn,{node:c7,dispatch:r7,onStartConnect:t7,allNodes:wy.nodes,readOnly:E1,viewKey:T.archikFile??void 0}):null},u7?`multi:${ds.length}`:Vc?`${Vc.type}:${Vc.id}`:"empty")})]})]})}function AVn({count:h,onDelete:b,onClear:p}){return R.jsxs("div",{className:"flex h-full flex-col gap-4 overflow-y-auto p-4 text-sm",children:[R.jsxs("div",{children:[R.jsx("div",{className:"archik-label",children:"Selection"}),R.jsxs("div",{style:{fontSize:18,fontWeight:600,color:"var(--archik-fg)",letterSpacing:"0.01em"},children:[h," items"]}),R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-dim)",marginTop:4},children:"Hold ⌘ / Ctrl while clicking to add or remove items."})]}),R.jsx("div",{className:"archik-divider"}),R.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-4",children:[R.jsx("button",{type:"button",onClick:p,className:"archik-btn",style:{justifyContent:"center",padding:"8px 12px"},children:"Clear selection"}),R.jsxs("button",{type:"button",onClick:b,className:"archik-btn archik-btn-danger",style:{justifyContent:"center",padding:"8px 12px"},children:["Delete ",h," items"]})]})]})}function v1n({children:h}){return R.jsx("div",{className:"flex h-full items-center justify-center p-6 text-sm",style:{background:"var(--archik-canvas)",color:"var(--archik-fg-dim)"},children:h})}function TVn({added:h,removed:b,changed:p,note:v,reviewing:T,onReview:M,onAccept:j,onReject:P}){const G=h+b+p;return R.jsxs("div",{role:"region","aria-label":"Pending suggestion",style:{background:"rgba(168, 85, 247, 0.12)",borderBottom:"1px solid rgba(168, 85, 247, 0.45)",padding:"10px 16px",display:"flex",alignItems:"center",gap:14,fontSize:12,lineHeight:1.4},children:[R.jsx("span",{style:{fontWeight:700,letterSpacing:"0.04em",color:"#c4b5fd"},children:"📝 SUGGESTION PENDING"}),R.jsxs("span",{style:{color:"var(--archik-fg)"},children:[G===0?"(identical to current — nothing to apply)":R.jsxs(R.Fragment,{children:[R.jsxs("span",{style:{color:"var(--archik-success)"},children:["+",h]})," ",R.jsxs("span",{style:{color:"var(--archik-danger)"},children:["−",b]})," ",R.jsxs("span",{style:{color:"var(--archik-warning)"},children:["~",p]})]}),v?R.jsxs("span",{style:{marginLeft:10,color:"var(--archik-fg-dim)",fontStyle:"italic"},children:['"',v,'"']}):null]}),R.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8},children:[R.jsx("button",{type:"button",onClick:M,className:"archik-btn",style:{padding:"5px 12px",fontSize:12,...T?{background:"#a855f7",color:"white",borderColor:"#a855f7"}:{}},children:T?"Hide diff":"Review"}),R.jsx("button",{type:"button",onClick:j,className:"archik-btn",title:G===0?"Suggestion already matches the current file — Accept just clears the sidecar.":"Apply the suggestion to the main file.",style:{padding:"5px 12px",fontSize:12,background:"var(--archik-success)",color:"white",borderColor:"var(--archik-success)"},children:"Accept"}),R.jsx("button",{type:"button",onClick:P,className:"archik-btn",style:{padding:"5px 12px",fontSize:12,color:"var(--archik-danger)",borderColor:"var(--archik-danger)"},children:"Reject"})]})]})}const xVn=n7(["sync","async","return","create","destroy"]),MVn=n7(["over","left_of","right_of"]),CVn=n7(["alt","opt","loop","par","break","ref"]),OVn=Kg({id:dd,nodeId:dd,label:hs().min(1).optional(),status:CI.optional()}),_Vn=Kg({type:oJ("message"),id:dd,from:dd,to:dd,label:hs().min(1),arrow:xVn,activate:VKn().optional(),status:CI.optional()}),NVn=Kg({type:oJ("note"),id:dd,position:MVn,participants:Jg(dd).min(1),text:hs().min(1),status:CI.optional()}),IVn=F7e(()=>Kg({label:hs().optional(),steps:Jg(C0n)})),DVn=F7e(()=>Kg({type:oJ("group"),id:dd,kind:CVn,condition:hs().optional(),label:hs().optional(),branches:Jg(IVn).optional(),seqFile:h0n.optional(),participants:Jg(dd).optional(),status:CI.optional()})),C0n=F7e(()=>o0n([_Vn,NVn,DVn]));function O0n(h,b){const p=[];for(const v of h)if(b.has(v.id)?p.push(v.id):b.add(v.id),v.type==="group"&&v.branches)for(const T of v.branches)p.push(...O0n(T.steps,b));return p}const $Vn=Kg({useCase:dd,slice:dd}),LVn=Kg({version:oJ("1.0"),name:hs().min(1),description:hs().optional(),realizes:$Vn.optional(),participants:Jg(OVn).min(1),steps:Jg(C0n)}).superRefine((h,b)=>{const p=new Set;for(let M=0;M<h.participants.length;M++){const j=h.participants[M];p.has(j.id)&&b.addIssue({code:jb.custom,path:["participants",M,"id"],message:`duplicate participant id "${j.id}"`}),p.add(j.id)}const v=new Set,T=O0n(h.steps,v);for(const M of T)b.addIssue({code:jb.custom,path:["steps"],message:`duplicate step id "${M}"`})}),kI=56,RVn=160,PVn=40,d7e=56,zVn=24,eue=12,BVn=20,FVn=6,y1n=64,pT=32,B8e=24,k1n=8,_0n="seq-arrow-filled",N0n="seq-arrow-open";function qVn(h){return Math.max(RVn,h.length*8+PVn*2)}function I0n(h,b,p,v,T,M=0){let j=p;const P=[];let G=Number.POSITIVE_INFINITY,J=Number.NEGATIVE_INFINITY;for(const se of h)if(se.type==="message"){const re=b.get(se.from),fe=b.get(se.to),Ae=re?.cx??v,Ze=fe?.cx??v;P.push({type:"message",id:se.id,fromCx:Ae,toCx:Ze,y:j,label:se.label,arrow:se.arrow,activate:se.activate??!1,isSelf:se.from===se.to,...se.status!==void 0?{status:se.status}:{}}),j+=se.from===se.to?d7e*1.5:d7e}else if(se.type==="note"){const re=se.participants.map(tn=>b.get(tn)?.cx).filter(tn=>tn!==void 0).sort((tn,bn)=>tn-bn),fe=re[0]??v,Ae=re[re.length-1]??T,Ze=Math.min(Math.max(se.text.length*7.5+24,Ae-fe+16,80),400);let ie;se.position==="left_of"?ie=fe-Ze-8:se.position==="right_of"?ie=Ae+8:ie=(fe+Ae)/2-Ze/2,G=Math.min(G,ie),J=Math.max(J,ie+Ze),P.push({type:"note",id:se.id,x:ie,y:j,width:Ze,height:y1n,text:se.text,...se.status!==void 0?{status:se.status}:{}}),j+=y1n+8}else if(se.type==="group"){const re=Math.min(M*FVn,eue),fe=v-eue+re,Ae=T-v+eue*2-re*2,Ze=j;j+=zVn;const ie=[];if(se.branches)for(let tn=0;tn<se.branches.length;tn++){const bn=se.branches[tn],_n=j,{items:hn,endY:Rn,contentMinX:rt,contentMaxX:dt}=I0n(bn.steps,b,j,v,T,M+1);j=Rn,G=Math.min(G,rt),J=Math.max(J,dt),ie.push({...bn.label!==void 0?{label:bn.label}:{},startY:_n,...tn<se.branches.length-1?{dividerY:j}:{},steps:hn}),tn<se.branches.length-1&&(j+=4)}j+=eue,P.push({type:"group",id:se.id,kind:se.kind,...se.condition!==void 0?{condition:se.condition}:{},...se.label!==void 0?{label:se.label}:{},...se.seqFile!==void 0?{seqFile:se.seqFile}:{},x:fe,y:Ze,width:Ae,height:j-Ze,branches:ie,...se.status!==void 0?{status:se.status}:{}}),G=Math.min(G,fe),J=Math.max(J,fe+Ae),j+=BVn}return{items:P,endY:j,contentMinX:G,contentMaxX:J}}function D0n(h){const b=new Map;for(const p of h)if(p.type==="message"&&p.arrow==="destroy"&&b.set(p.toCx,p.y+kI+20),p.type==="group")for(const v of p.branches)for(const[T,M]of D0n(v.steps))b.set(T,M);return b}function GVn(h){const b=[],p=new Map;function v(T){for(const M of T)if(M.type==="message"){if(M.activate&&M.arrow==="sync"&&!M.isSelf){const j=p.get(M.toCx)??[];j.push(M.y),p.set(M.toCx,j)}if(M.arrow==="return"&&!M.isSelf){const j=p.get(M.fromCx);if(j&&j.length>0){const P=j.pop();b.push({cx:M.fromCx,startY:P,endY:M.y}),j.length===0&&p.delete(M.fromCx)}}}else if(M.type==="group")for(const j of M.branches)v(j.steps)}v(h);for(const[T,M]of p)for(const j of M)b.push({cx:T,startY:j,endY:j+d7e/2});return b}function UVn(h,b){const p=h.participants.map(Wn=>qVn(Wn.label??Wn.nodeId));let v=pT;const T=h.participants.map((Wn,pt)=>{const wr=p[pt],Wr=v+wr/2;v+=wr;const Yr=b?.get(Wn.nodeId);return{id:Wn.id,nodeId:Wn.nodeId,label:Wn.label??Wn.nodeId,cx:Wr,colWidth:wr,...Yr!==void 0?{kind:Yr}:{},...Wn.status!==void 0?{status:Wn.status}:{},lifelineEndY:0}}),M=v+pT,j=new Map(T.map(Wn=>[Wn.id,Wn])),P=T[0]?.cx??pT,G=T[T.length-1]?.cx??M-pT,J=B8e,{items:se,endY:re,contentMinX:fe,contentMaxX:Ae}=I0n(h.steps,j,J,P,G),Ze=fe<pT&&Number.isFinite(fe)?pT-fe:0,ie=Number.isFinite(Ae)?Ae+Ze+pT:0,tn=Math.max(M+Ze,ie),bn=Ze>0?se.map(Wn=>$0n(Wn,Ze)):se,_n=Ze>0?T.map(Wn=>({...Wn,cx:Wn.cx+Ze})):T,hn=D0n(bn),Rn=_n.map(Wn=>({...Wn,lifelineEndY:hn.get(Wn.cx)??kI+re+B8e})),rt=kI+re+B8e,dt=GVn(bn);return{participants:Rn,steps:bn,activations:dt,totalWidth:tn,totalHeight:rt}}function $0n(h,b){return h.type==="message"?{...h,fromCx:h.fromCx+b,toCx:h.toCx+b}:h.type==="note"?{...h,x:h.x+b}:{...h,x:h.x+b,branches:h.branches.map(p=>({...p,steps:p.steps.map(v=>$0n(v,b))}))}}const nue=36,JVn=128,HVn=7,j1n=20,S1n=24;function KVn({participant:h,nodeKind:b}){const p=b?Np[b]:void 0,v=p?.color??"var(--archik-fg-muted)",T=(kI-nue)/2,M=p?.icon,j=Math.max(JVn,h.label.length*HVn+S1n+(M?j1n:0)),P=j/2,G=M?P+j1n/2:P,J=h.status,se=J==="proposed"?.55:J==="deprecated"?.35:1,re=J==="proposed"||J==="deprecated"?"4 3":void 0;return R.jsxs("g",{transform:`translate(${h.cx-P}, ${T})`,opacity:se,children:[R.jsx("rect",{width:j,height:nue,rx:8,fill:"var(--archik-node-fill)",stroke:v,strokeWidth:1.4,...re!==void 0?{strokeDasharray:re}:{}}),M&&R.jsx("g",{transform:`translate(${S1n/2}, ${(nue-14)/2})`,children:R.jsx(M,{size:14,color:v,strokeWidth:1.5})}),R.jsx("text",{x:G,y:nue/2+4,textAnchor:"middle",fontSize:12,fontWeight:500,fill:"var(--archik-fg)",fontFamily:"inherit",children:h.label})]})}function ZVn({participant:h}){const b=h.status,p=b==="proposed"?.3:b==="deprecated"?.2:.5;return R.jsx("line",{x1:h.cx,y1:kI,x2:h.cx,y2:h.lifelineEndY,stroke:"var(--archik-node-stroke)",strokeWidth:1,strokeDasharray:"4 4",opacity:p})}const F8e=32,q8e=20,XVn=-6;function VVn({msg:h}){const b=h.arrow==="return",p=h.arrow==="async",v=h.arrow==="create",T=b||v,M=h.arrow==="destroy",j=b||p?N0n:_0n,P=h.status==="proposed"?.5:h.status==="deprecated"?.35:1;if(h.isSelf){const re=h.fromCx,fe=h.y,Ae=`M ${re} ${fe} L ${re+F8e} ${fe} L ${re+F8e} ${fe+q8e} L ${re} ${fe+q8e}`;return R.jsxs("g",{opacity:P,children:[R.jsx("path",{d:Ae,fill:"none",stroke:"var(--archik-edge-filled)",strokeWidth:1.4,markerEnd:`url(#${j})`}),R.jsx("text",{x:re+F8e+6,y:fe+q8e/2+4,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:h.label})]})}const J=h.fromCx<h.toCx?h.toCx-6:h.toCx+6,se=(h.fromCx+h.toCx)/2;return R.jsxs("g",{opacity:P,children:[R.jsx("line",{x1:h.fromCx,y1:h.y,x2:J,y2:h.y,stroke:"var(--archik-edge-filled)",strokeWidth:1.4,strokeDasharray:T?"4 4":void 0,markerEnd:M?void 0:`url(#${j})`}),R.jsxs("text",{x:se,y:h.y+XVn,textAnchor:"middle",fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:[v&&"«create» ",h.label]}),h.arrow==="destroy"&&R.jsxs("g",{transform:`translate(${h.toCx-6}, ${h.y-6})`,children:[R.jsx("line",{x1:0,y1:0,x2:12,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5}),R.jsx("line",{x1:12,y1:0,x2:0,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5})]})]})}const WVn={alt:"#6366f1",opt:"#0ea5e9",loop:"#10b981",par:"#f59e0b",break:"#ef4444",ref:"#8b5cf6"},E1n=36,G8e=18;function YVn({group:h,renderStep:b,onRefClick:p}){const v=WVn[h.kind]??"var(--archik-fg-muted)",T=h.status==="proposed"?.55:h.status==="deprecated"?.35:1,M=h.kind==="ref"&&h.seqFile!==void 0&&p!==void 0;return R.jsxs("g",{opacity:T,onClick:M?()=>p(h.seqFile):void 0,style:M?{cursor:"pointer"}:void 0,children:[R.jsx("rect",{x:h.x,y:h.y,width:h.width,height:h.height,rx:4,fill:"none",stroke:v,strokeWidth:1.2,opacity:.6}),R.jsx("rect",{x:h.x,y:h.y,width:E1n,height:G8e,rx:4,fill:v,opacity:.8}),R.jsx("text",{x:h.x+6,y:h.y+G8e-5,fontSize:10,fontWeight:600,fill:"#fff",fontFamily:"inherit",children:h.kind}),(h.condition??h.label)&&R.jsx("text",{x:h.x+E1n+6,y:h.y+G8e-5,fontSize:10,fill:v,fontFamily:"inherit",children:h.condition??h.label}),h.branches.map((j,P)=>R.jsxs("g",{children:[j.label&&R.jsx("text",{x:h.x+6,y:j.startY+12,fontSize:10,fill:v,fontFamily:"inherit",children:j.label}),j.steps.map(G=>b(G)),j.dividerY!==void 0&&R.jsx("line",{x1:h.x,y1:j.dividerY,x2:h.x+h.width,y2:j.dividerY,stroke:v,strokeWidth:1,strokeDasharray:"4 2",opacity:.5})]},P))]})}const rI=10;function QVn(h,b){const p=Math.max(10,Math.floor(b/6.5));if(h.length<=p)return[h];const v=h.split(" "),T=[];let M="";for(const j of v)(M+(M?" ":"")+j).length>p&&M?(T.push(M),M=j):M=M?M+" "+j:j;return M&&T.push(M),T.slice(0,3)}function eWn({note:h}){const{x:b,y:p,width:v,height:T,text:M}=h,j=h.status==="proposed"?.55:h.status==="deprecated"?.35:1;return R.jsxs("g",{opacity:j,children:[R.jsx("path",{d:`M ${b} ${p} L ${b+v-rI} ${p} L ${b+v} ${p+rI} L ${b+v} ${p+T} L ${b} ${p+T} Z`,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),R.jsx("path",{d:`M ${b+v-rI} ${p} L ${b+v-rI} ${p+rI} L ${b+v} ${p+rI}`,fill:"none",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),QVn(M,v-16).map((P,G)=>R.jsx("text",{x:b+8,y:p+8+11+G*13,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:P},G))]})}function nWn({id:h}){return R.jsx("marker",{id:h,viewBox:"0 0 10 10",refX:"10",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:R.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"context-stroke"})})}function tWn({id:h}){return R.jsx("marker",{id:h,viewBox:"0 0 12 12",refX:"11",refY:"6",markerWidth:"7",markerHeight:"7",orient:"auto-start-reverse",children:R.jsx("path",{d:"M 1 1 L 11 6 L 1 11",fill:"none",stroke:"context-stroke",strokeWidth:"1.5",strokeLinejoin:"round"})})}function L0n({step:h,onRefClick:b}){return h.type==="message"?R.jsx(VVn,{msg:h}):h.type==="note"?R.jsx(eWn,{note:h}):h.type==="group"?R.jsx(YVn,{group:h,...b!==void 0?{onRefClick:b}:{},renderStep:p=>R.jsx(L0n,{step:p,...b!==void 0?{onRefClick:b}:{}},p.id)}):null}function iWn({laid:h,svgRef:b,onRefClick:p}){const{participants:v,steps:T,activations:M,totalWidth:j,totalHeight:P}=h;return R.jsxs("svg",{ref:b,width:j,height:P,viewBox:`0 0 ${j} ${P}`,xmlns:"http://www.w3.org/2000/svg",style:{fontFamily:"var(--archik-font, system-ui)"},children:[R.jsxs("defs",{children:[R.jsx(nWn,{id:_0n}),R.jsx(tWn,{id:N0n})]}),v.map(G=>R.jsx(ZVn,{participant:G},G.id)),v.map(G=>R.jsx(KVn,{participant:G,...G.kind!==void 0?{nodeKind:G.kind}:{}},G.id)),R.jsxs("g",{transform:`translate(0, ${kI})`,children:[M.map(G=>R.jsx("rect",{x:G.cx-k1n/2,y:G.startY,width:k1n,height:G.endY-G.startY,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1,rx:2},`${G.cx}-${G.startY}`)),T.map(G=>R.jsx(L0n,{step:G,...p!==void 0?{onRefClick:p}:{}},G.id))]})]})}const A1n="archik.seq.rail.open";function rWn({path:h,back:b}){const[p,v]=lt.useState({status:"loading"}),[T,M]=lt.useState(void 0),[j,P]=lt.useState([]),[G,J]=lt.useState(()=>{if(typeof window>"u")return!0;const hn=window.localStorage.getItem(A1n);return hn===null?!0:hn==="1"}),[se,re]=lt.useState(!1),fe=lt.useRef(null);lt.useEffect(()=>{typeof window<"u"&&window.localStorage.setItem(A1n,G?"1":"0")},[G]),lt.useEffect(()=>{fetch("/__archik/node-kinds").then(hn=>hn.ok?hn.json():null).then(hn=>{hn&&M(new Map(Object.entries(hn)))}).catch(()=>{})},[]),lt.useEffect(()=>{fetch("/__archik/usecases").then(hn=>hn.ok?hn.json():null).then(hn=>{hn&&P(hn.useCases??[])}).catch(()=>{})},[]),lt.useEffect(()=>{v({status:"loading"});const hn=encodeURIComponent(h);fetch(`/__archik/seq-file?path=${hn}`).then(async Rn=>{if(!Rn.ok)throw new Error(`${Rn.status} ${Rn.statusText}`);return Rn.text()}).then(Rn=>{const rt=I7e.parse(Rn),dt=LVn.safeParse(rt);if(!dt.success)throw new Error(dt.error.issues.map(Wn=>Wn.message).join("; "));v({status:"ready",doc:dt.data,raw:Rn})}).catch(Rn=>{v({status:"error",message:Rn instanceof Error?Rn.message:String(Rn)})})},[h]);const Ae=b?b.type==="usecase"?`/__archik/usecases?uc=${encodeURIComponent(b.value)}`:`/?file=${encodeURIComponent(b.value)}`:"/",Ze=b?.type==="usecase"?"Use cases":"Architecture",ie=lt.useMemo(()=>{if(p.status!=="ready")return null;const hn=p.doc.realizes;if(!hn)return null;const Rn=j.find(dt=>dt.id===hn.useCase);if(!Rn)return{useCase:hn.useCase,slice:hn.slice,name:void 0,slice_data:void 0};const rt=Rn.slices.find(dt=>dt.id===hn.slice);return{useCase:hn.useCase,slice:hn.slice,name:Rn.name,slice_data:rt,primaryActor:Rn.primaryActor}},[p,j]);if(p.status==="loading")return R.jsx("div",{className:"flex h-screen items-center justify-center",style:{color:"var(--archik-fg-muted)"},children:"Loading sequence diagram…"});if(p.status==="error")return R.jsxs("div",{className:"flex h-screen flex-col items-center justify-center gap-4",children:[R.jsx("div",{style:{color:"var(--archik-fg-error, #ef4444)"},children:p.message}),R.jsxs("a",{href:Ae,style:{color:"var(--archik-fg-muted)",fontSize:13},children:["← ",Ze]})]});const tn=UVn(p.doc,T),bn=h.replace(/^.*\//,"").replace(/\.archik\.seq\.yaml$/,""),_n=hn=>{const Rn=new URLSearchParams;Rn.set("path",hn),b?.type==="usecase"?Rn.set("from-uc",b.value):b?.type==="file"&&Rn.set("from-file",b.value),window.location.href=`/__archik/seq?${Rn.toString()}`};return R.jsxs("div",{className:"flex h-screen flex-col",style:{background:"var(--archik-canvas)"},children:[R.jsx(cWn,{backHref:Ae,backLabel:Ze,realizedSlice:ie,seqName:p.doc.name,railOpen:G,onToggleRail:()=>J(hn=>!hn),filename:bn,getSvg:()=>fe.current}),R.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[R.jsx("div",{style:{flex:1,overflow:"auto",padding:24},children:R.jsx(iWn,{laid:tn,svgRef:fe,onRefClick:_n})}),G&&R.jsx(uWn,{doc:p.doc,raw:p.raw,yamlOpen:se,onToggleYaml:()=>re(hn=>!hn),realizedSlice:ie,kinds:T})]})]})}function cWn({backHref:h,backLabel:b,realizedSlice:p,seqName:v,railOpen:T,onToggleRail:M,filename:j,getSvg:P}){return R.jsxs("header",{style:{display:"flex",alignItems:"center",gap:4,padding:"0 16px",height:48,borderBottom:"1px solid var(--archik-border)",background:"var(--archik-panel)",flexShrink:0,fontSize:13},children:[R.jsxs("a",{href:h,style:{display:"inline-flex",alignItems:"center",gap:2,color:"var(--archik-fg-dim)",textDecoration:"none"},children:[R.jsx(L1n,{size:14}),b]}),p&&R.jsxs(R.Fragment,{children:[R.jsx(U8e,{}),R.jsx("a",{href:`/__archik/usecases?uc=${encodeURIComponent(p.useCase)}`,style:{color:"var(--archik-fg-dim)",textDecoration:"none",fontFamily:"ui-monospace, monospace",fontSize:12},children:p.useCase}),R.jsx(U8e,{}),R.jsx("span",{style:{color:"var(--archik-fg)",fontFamily:"ui-monospace, monospace",fontSize:12},children:p.slice})]}),!p&&R.jsxs(R.Fragment,{children:[R.jsx(U8e,{}),R.jsx("span",{style:{color:"var(--archik-fg)",fontWeight:500},children:v})]}),R.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:6,alignItems:"center"},children:[R.jsx(S0n,{filename:j,getSvg:P}),R.jsx("button",{type:"button",onClick:M,"aria-label":T?"Hide details":"Show details","aria-pressed":T,title:T?"Hide details panel":"Show details panel",className:"archik-btn",style:{padding:"5px 8px"},children:T?R.jsx(fFn,{size:14}):R.jsx(hFn,{size:14})})]})]})}function U8e(){return R.jsx(SBn,{size:12,color:"var(--archik-fg-muted)",style:{marginInline:2}})}function uWn({doc:h,raw:b,yamlOpen:p,onToggleYaml:v,realizedSlice:T,kinds:M}){return R.jsxs("aside",{style:{width:300,flexShrink:0,borderLeft:"1px solid var(--archik-border)",background:"var(--archik-panel)",overflowY:"auto",padding:16,fontSize:12,color:"var(--archik-fg-dim)"},children:[R.jsx(tue,{title:"Realizes",children:T?R.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[R.jsx(T1n,{label:"Use case",children:R.jsxs("a",{href:`/__archik/usecases?uc=${encodeURIComponent(T.useCase)}`,style:iue({color:"var(--archik-accent)"}),children:[T.useCase,T.name?` — ${T.name}`:""]})}),R.jsx(T1n,{label:"Slice",children:R.jsx("code",{style:iue(),children:T.slice})}),T.slice_data?.description&&R.jsx("div",{style:{marginTop:4,fontSize:11,lineHeight:1.5},children:T.slice_data.description})]}):R.jsxs(x1n,{children:["No ",R.jsx("code",{children:"realizes"})," block — this is an ad-hoc / scratch flow, not bound to a use case slice."]})}),R.jsx(tue,{title:`Participants (${h.participants.length})`,children:R.jsx("ul",{style:M1n,children:h.participants.map(j=>{const P=M?.get(j.nodeId),G=P?Np[P]:void 0,J=G?.icon;return R.jsxs("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 0"},children:[J?R.jsx(J,{size:12,color:G.color,strokeWidth:2}):R.jsx("span",{style:{width:12}}),R.jsx("code",{style:iue(),children:j.nodeId}),j.id!==j.nodeId&&R.jsxs("span",{style:{fontSize:10,color:"var(--archik-fg-muted)"},children:["[",j.id,"]"]})]},j.id)})})}),T?.slice_data&&R.jsx(tue,{title:"Proved by",children:(T.slice_data.tests?.length??0)===0?R.jsx(x1n,{children:"No tests declared on this slice."}):R.jsx("ul",{style:{...M1n,listStyle:"none",paddingLeft:0},children:T.slice_data.tests.map(j=>R.jsxs("li",{style:{...iue(),fontSize:11,padding:"2px 0"},children:[R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"•"})," ",j]},j))})}),R.jsxs(tue,{title:"Source",children:[R.jsxs("button",{type:"button",onClick:v,className:"archik-btn",style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"4px 8px"},children:[R.jsx(zBn,{size:11}),p?"Hide YAML":"View YAML"]}),p&&R.jsx("pre",{style:{marginTop:8,padding:10,background:"var(--archik-surface)",border:"1px solid var(--archik-border)",borderRadius:4,fontSize:10,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--archik-fg-dim)",overflowX:"auto",whiteSpace:"pre",maxHeight:360,overflowY:"auto"},children:b})]})]})}function tue({title:h,children:b}){return R.jsxs("section",{style:{marginBottom:18},children:[R.jsx("h2",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--archik-fg-muted)",margin:"0 0 6px"},children:h}),b]})}function T1n({label:h,children:b}){return R.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline"},children:[R.jsx("span",{style:{fontSize:9,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",width:56,flexShrink:0},children:h}),R.jsx("span",{style:{flex:1,minWidth:0},children:b})]})}function x1n({children:h}){return R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-muted)",lineHeight:1.5},children:h})}function iue(h){return{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:11,color:"var(--archik-fg)",textDecoration:"none",...h}}const M1n={margin:0,paddingLeft:0,listStyle:"none"},sWn="/__archik/usecases",oWn="/__archik/trace";async function C1n(h,b){const p=await fetch(h,{cache:"no-store",signal:b});if(!p.ok)throw new Error(`HTTP ${p.status} ${p.statusText}`);return await p.json()}function lWn({selectedId:h}){const[b,p]=lt.useState({status:"loading"});return lt.useEffect(()=>{let v=!1;const T=new AbortController;return Promise.all([C1n(sWn,T.signal),C1n(oWn,T.signal)]).then(([M,j])=>{v||p({status:"ready",useCases:M.useCases??[],trace:j.rows??[]})}).catch(M=>{v||T.signal.aborted||p({status:"error",message:M instanceof Error?M.message:String(M)})}),()=>{v=!0,T.abort()}},[]),R.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100vh",background:"var(--archik-canvas)",color:"var(--archik-fg)",fontFamily:"Inter, system-ui, sans-serif"},children:[R.jsx(fWn,{state:b}),R.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[b.status==="loading"&&R.jsx(J8e,{children:"Loading…"}),b.status==="error"&&R.jsxs(J8e,{tone:"error",children:["Couldn't load: ",b.message]}),b.status==="ready"&&b.useCases.length===0&&R.jsxs(J8e,{children:["No use cases defined yet. Add a ",R.jsx("code",{children:"*.archik.uc.yaml"})," file under ",R.jsx("code",{children:".archik/usecases/"}),"."]}),b.status==="ready"&&b.useCases.length>0&&R.jsx(aWn,{useCases:b.useCases,trace:b.trace,selectedId:h})]})]})}function fWn({state:h}){const b=lt.useMemo(()=>{if(h.status!=="ready")return null;let p=0,v=0,T=0;for(const M of h.trace)M.level==="full"?p++:M.level==="partial"?v++:T++;return{full:p,partial:v,none:T,total:h.trace.length}},[h]);return R.jsxs("header",{style:{display:"flex",alignItems:"center",gap:16,padding:"0 20px",height:52,borderBottom:"1px solid var(--archik-border)",background:"var(--archik-panel)",flexShrink:0},children:[R.jsxs("a",{href:"/",style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-fg-dim)",fontSize:13,textDecoration:"none"},children:[R.jsx(L1n,{size:14}),"Architecture"]}),R.jsx("span",{style:{color:"var(--archik-border-strong)"},children:"|"}),R.jsx("h1",{style:{fontSize:14,fontWeight:600,margin:0,color:"var(--archik-fg)"},children:"Use cases"}),b&&b.total>0&&R.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginLeft:"auto",fontSize:12,color:"var(--archik-fg-dim)"},children:[R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-success)"},children:"●"})," ",b.full," full"]}),R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-warning)"},children:"◐"})," ",b.partial," partial"]}),R.jsxs("span",{children:[R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"○"})," ",b.none," untraced"]}),R.jsxs("span",{style:{color:"var(--archik-fg-muted)"},children:["· ",b.total," ",b.total===1?"slice":"slices"]})]})]})}function aWn({useCases:h,trace:b,selectedId:p}){const v=lt.useMemo(()=>{const j=new Map;for(const P of b){const G=j.get(P.useCase);if(!G){j.set(P.useCase,P.level);continue}G==="none"||P.level==="none"?j.set(P.useCase,"none"):(G==="partial"||P.level==="partial")&&j.set(P.useCase,"partial")}return j},[b]),T=lt.useMemo(()=>{const j=new Map;for(const P of b)j.set(`${P.useCase}/${P.slice}`,P);return j},[b]),M=h.find(j=>j.id===p)??h[0];return R.jsxs(R.Fragment,{children:[R.jsx(hWn,{useCases:h,ucLevel:v,selectedId:M.id}),R.jsx(dWn,{useCase:M,traceByKey:T})]})}function hWn({useCases:h,ucLevel:b,selectedId:p}){return R.jsx("nav",{"aria-label":"Use cases",style:{width:260,borderRight:"1px solid var(--archik-border)",background:"var(--archik-panel)",overflowY:"auto",padding:"8px 0",flexShrink:0},children:R.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:h.map(v=>{const T=b.get(v.id)??"none",M=v.id===p;return R.jsx("li",{children:R.jsxs("a",{href:`/__archik/usecases?uc=${encodeURIComponent(v.id)}`,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 14px",textDecoration:"none",color:"var(--archik-fg)",background:M?"var(--archik-surface-hover)":"transparent",borderLeft:M?"2px solid var(--archik-accent)":"2px solid transparent",fontSize:13},children:[R.jsx(R0n,{level:T}),R.jsxs("span",{style:{flex:1,minWidth:0},children:[R.jsx("code",{style:{fontSize:12,fontFamily:"ui-monospace, monospace"},children:v.id}),R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.name})]}),v.status&&v.status!=="active"&&R.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:4,background:"var(--archik-surface)",color:"var(--archik-fg-muted)"},children:v.status})]})},v.id)})})})}function R0n({level:h}){const b=h==="full"?{glyph:"●",color:"var(--archik-success)",label:"fully traced"}:h==="partial"?{glyph:"◐",color:"var(--archik-warning)",label:"partially traced"}:{glyph:"○",color:"var(--archik-fg-muted)",label:"untraced"};return R.jsx("span",{title:b.label,"aria-label":b.label,style:{color:b.color,fontSize:12,lineHeight:1,width:12},children:b.glyph})}function dWn({useCase:h,traceByKey:b}){return R.jsx("main",{style:{flex:1,overflowY:"auto",padding:"24px 32px"},children:R.jsxs("div",{style:{maxWidth:820,margin:"0 auto"},children:[R.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:12,marginBottom:4},children:[R.jsx("code",{style:{fontSize:18,fontFamily:"ui-monospace, monospace",fontWeight:600,color:"var(--archik-fg)"},children:h.id}),h.status&&h.status!=="active"&&R.jsx("span",{className:"archik-pill",style:{fontSize:10},children:h.status})]}),R.jsx("div",{style:{fontSize:15,color:"var(--archik-fg-dim)",marginBottom:18},children:h.name}),R.jsx(bWn,{useCase:h}),h.goal&&R.jsx(cI,{title:"Goal",children:R.jsx("p",{style:{margin:0,lineHeight:1.55},children:h.goal})}),(h.preconditions?.length??0)>0&&R.jsx(cI,{title:"Preconditions",children:R.jsx("ul",{style:QU,children:h.preconditions.map((p,v)=>R.jsx("li",{children:p},v))})}),h.flows?.basic?.steps&&R.jsx(cI,{title:"Basic flow",children:R.jsx("ol",{style:{...QU,paddingLeft:22},children:h.flows.basic.steps.map((p,v)=>R.jsx("li",{style:{marginBottom:4},children:p},v))})}),(h.flows?.alternates?.length??0)>0&&R.jsx(cI,{title:"Alternate flows",children:h.flows.alternates.map(p=>R.jsxs("div",{style:{marginBottom:12,padding:12,background:"var(--archik-surface)",borderRadius:6,borderLeft:"3px solid var(--archik-warning)"},children:[R.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline",marginBottom:6},children:[R.jsx("code",{style:{fontSize:12,fontWeight:600},children:p.id}),p.branchFrom&&R.jsxs("span",{style:{fontSize:11,color:"var(--archik-fg-muted)"},children:["branches from ",p.branchFrom]})]}),R.jsx("ol",{style:{...QU,paddingLeft:22,fontSize:13},children:p.steps.map((v,T)=>R.jsx("li",{children:v},T))})]},p.id))}),(h.postconditions?.length??0)>0&&R.jsx(cI,{title:"Postconditions",children:R.jsx("ul",{style:QU,children:h.postconditions.map((p,v)=>R.jsx("li",{children:p},v))})}),(()=>{const p=h.slices??[];return R.jsx(cI,{title:`Slices (${p.length})`,children:p.length===0?R.jsx("div",{style:{fontSize:12,color:"var(--archik-fg-muted)"},children:"— no slices declared"}):R.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:p.map(v=>R.jsx(gWn,{slice:v,useCaseId:h.id,trace:b.get(`${h.id}/${v.id}`)},v.id))})})})(),R.jsxs("div",{style:{marginTop:32,paddingTop:16,borderTop:"1px solid var(--archik-border)",fontSize:11,color:"var(--archik-fg-muted)"},children:["Source:"," ",R.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:h.relPath})]})]})})}function bWn({useCase:h}){return R.jsxs("div",{style:{display:"flex",gap:24,padding:"10px 14px",background:"var(--archik-surface)",borderRadius:6,marginBottom:20,fontSize:12},children:[R.jsxs("div",{children:[R.jsx("div",{style:b7e,children:"Primary actor"}),R.jsx("div",{style:{marginTop:2},children:R.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:h.primaryActor})})]}),(h.secondaryActors?.length??0)>0&&R.jsxs("div",{children:[R.jsx("div",{style:b7e,children:"Secondary actors"}),R.jsx("div",{style:{marginTop:2},children:h.secondaryActors.map((b,p)=>R.jsxs("span",{children:[R.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:b}),p<h.secondaryActors.length-1&&", "]},b))})]})]})}function gWn({slice:h,useCaseId:b,trace:p}){const v=p?.level??"none";return R.jsxs("div",{style:{padding:14,background:"var(--archik-panel)",border:"1px solid var(--archik-border)",borderRadius:8},children:[R.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,marginBottom:8},children:[R.jsx(R0n,{level:v}),R.jsx("code",{style:{fontSize:13,fontFamily:"ui-monospace, monospace",fontWeight:600},children:h.id}),h.status&&h.status!=="active"&&R.jsxs("span",{style:{fontSize:10,color:"var(--archik-fg-muted)"},children:["[",h.status,"]"]}),R.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--archik-fg-muted)"},children:p?.realization&&p.realization.participants.length>0&&R.jsxs(R.Fragment,{children:["ECB"," ",p.realization.participants.filter(T=>T.stereotype!==void 0).length,"/",p.realization.participants.length]})})]}),h.description&&R.jsx("div",{style:{fontSize:13,color:"var(--archik-fg-dim)",marginBottom:10,lineHeight:1.5},children:h.description}),R.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:14,rowGap:8,fontSize:12,alignItems:"start"},children:[R.jsx("div",{style:H8e,children:"Tests"}),R.jsx("div",{children:(h.tests?.length??0)===0?R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"— none declared"}):R.jsx("ul",{style:{...QU,paddingLeft:0,listStyle:"none"},children:h.tests.map(T=>R.jsxs("li",{style:{fontFamily:"ui-monospace, monospace",fontSize:11},children:[R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"•"})," ",T]},T))})}),R.jsx("div",{style:H8e,children:"Realization"}),R.jsx("div",{children:h.realization?R.jsxs("a",{href:`/__archik/seq?path=${encodeURIComponent(h.realization.seqFile)}&from-uc=${encodeURIComponent(b)}`,style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-accent)",textDecoration:"none",fontFamily:"ui-monospace, monospace",fontSize:11},children:[R.jsx(I1n,{size:11}),wWn(h.realization.seqFile),R.jsx(D1n,{size:11,style:{opacity:.7}})]}):R.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"— no seq file yet"})}),R.jsx("div",{style:H8e,children:"Flows"}),R.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-dim)"},children:(h.flows??[]).join(", ")||"—"})]})]})}function wWn(h){return h.split("/").pop()?.replace(/\.archik\.seq\.yaml$/,"")??h}function cI({title:h,children:b}){return R.jsxs("section",{style:{marginBottom:24},children:[R.jsx("h2",{style:{fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",margin:"0 0 8px"},children:h}),b]})}function J8e({children:h,tone:b}){return R.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:b==="error"?"var(--archik-danger)":"var(--archik-fg-muted)",fontSize:13,padding:24,textAlign:"center"},children:h})}const b7e={fontSize:10,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",fontWeight:600},H8e={...b7e,fontSize:10,paddingTop:1},QU={margin:0,paddingLeft:18,fontSize:13,lineHeight:1.55},P0n=document.getElementById("root");if(!P0n)throw new Error("#root not found");const VU=new URLSearchParams(window.location.search),mue=window.location.pathname,pWn=mue==="/__archik/seq"||mue.startsWith("/__archik/seq/"),mWn=mue==="/__archik/usecases"||mue.startsWith("/__archik/usecases/"),K8e=Nzn.createRoot(P0n);if(pWn){const h=VU.get("path")??"",b=VU.get("from-uc"),p=VU.get("from-file")??VU.get("from"),v=b?{type:"usecase",value:b}:p?{type:"file",value:p}:null;K8e.render(R.jsx(lt.StrictMode,{children:R.jsx(rWn,{path:h,back:v})}))}else if(mWn){const h=VU.get("uc");K8e.render(R.jsx(lt.StrictMode,{children:R.jsx(lWn,{selectedId:h})}))}else K8e.render(R.jsx(lt.StrictMode,{children:R.jsx(EVn,{})}));
@@ -14,7 +14,7 @@
14
14
  }
15
15
  } catch {}
16
16
  </script>
17
- <script type="module" crossorigin src="/assets/index-Cd_Pl5-J.js"></script>
17
+ <script type="module" crossorigin src="/assets/index-Dl4i5i09.js"></script>
18
18
  <link rel="stylesheet" crossorigin href="/assets/index-DVBaG20X.css">
19
19
  </head>
20
20
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "archik",
3
- "version": "0.12.45",
3
+ "version": "0.12.46",
4
4
  "description": "The shared vocabulary between you and Claude Code, at the engineering level. Plain-YAML architecture diagrams with a live browser canvas, headless SVG render in CI, and an installable Claude skill so the model treats the diagram as the spec.",
5
5
  "keywords": [
6
6
  "architecture",