archik 0.19.4 → 0.19.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/archik.mjs
CHANGED
|
@@ -515,7 +515,7 @@ ${u}
|
|
|
515
515
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let w of o.seen.entries()){let v=w[1];if(c===w[0]){y(w);continue}if(o.external){let T=o.external.registry.get(w[0])?.id;if(c!==w[0]&&T){y(w);continue}}if(o.metadataRegistry.get(w[0])?.id){y(w);continue}if(v.cycle){y(w);continue}if(v.count>1&&o.reused==="ref"){y(w);continue}}}function _E(o,c){let u=o.seen.get(c);if(!u)throw new Error("Unprocessed schema. This is a bug in Zod.");let p=w=>{let v=o.seen.get(w);if(v.ref===null)return;let _=v.def??v.schema,T={..._},R=v.ref;if(v.ref=null,R){p(R);let B=o.seen.get(R),V=B.schema;if(V.$ref&&(o.target==="draft-07"||o.target==="draft-04"||o.target==="openapi-3.0")?(_.allOf=_.allOf??[],_.allOf.push(V)):Object.assign(_,V),Object.assign(_,T),w._zod.parent===R)for(let ee in _)ee==="$ref"||ee==="allOf"||ee in T||delete _[ee];if(V.$ref&&B.def)for(let ee in _)ee==="$ref"||ee==="allOf"||ee in B.def&&JSON.stringify(_[ee])===JSON.stringify(B.def[ee])&&delete _[ee]}let F=w._zod.parent;if(F&&F!==R){p(F);let B=o.seen.get(F);if(B?.schema.$ref&&(_.$ref=B.schema.$ref,B.def))for(let V in _)V==="$ref"||V==="allOf"||V in B.def&&JSON.stringify(_[V])===JSON.stringify(B.def[V])&&delete _[V]}o.override({zodSchema:w,jsonSchema:_,path:v.path??[]})};for(let w of[...o.seen.entries()].reverse())p(w[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 w=o.external.registry.get(c)?.id;if(!w)throw new Error("Schema is missing an `id` property");f.$id=o.external.uri(w)}Object.assign(f,u.def??u.schema);let y=o.external?.defs??{};for(let w of o.seen.entries()){let v=w[1];v.def&&v.defId&&(y[v.defId]=v.def)}o.external||Object.keys(y).length>0&&(o.target==="draft-2020-12"?f.$defs=y:f.definitions=y);try{let w=JSON.parse(JSON.stringify(f));return Object.defineProperty(w,"~standard",{value:{...c["~standard"],jsonSchema:{input:Xq(c,"input",o.processors),output:Xq(c,"output",o.processors)}},enumerable:!1,writable:!1}),w}catch{throw new Error("Error converting schema to JSON.")}}function ib(o,c){let u=c??{seen:new Set};if(u.seen.has(o))return!1;u.seen.add(o);let p=o._zod.def;if(p.type==="transform")return!0;if(p.type==="array")return ib(p.element,u);if(p.type==="set")return ib(p.valueType,u);if(p.type==="lazy")return ib(p.getter(),u);if(p.type==="promise"||p.type==="optional"||p.type==="nonoptional"||p.type==="nullable"||p.type==="readonly"||p.type==="default"||p.type==="prefault")return ib(p.innerType,u);if(p.type==="intersection")return ib(p.left,u)||ib(p.right,u);if(p.type==="record"||p.type==="map")return ib(p.keyType,u)||ib(p.valueType,u);if(p.type==="pipe")return ib(p.in,u)||ib(p.out,u);if(p.type==="object"){for(let f in p.shape)if(ib(p.shape[f],u))return!0;return!1}if(p.type==="union"){for(let f of p.options)if(ib(f,u))return!0;return!1}if(p.type==="tuple"){for(let f of p.items)if(ib(f,u))return!0;return!!(p.rest&&ib(p.rest,u))}return!1}var C1t=(o,c={})=>u=>{let p=xE({...u,processors:c});return ll(o,p),SE(p,o),_E(p,o)},Xq=(o,c,u={})=>p=>{let{libraryOptions:f,target:y}=p??{},w=xE({...f??{},target:y,io:c,processors:u});return ll(o,w),SE(w,o),_E(w,o)};var pGn={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},I1t=(o,c,u,p)=>{let f=u;f.type="string";let{minimum:y,maximum:w,format:v,patterns:_,contentEncoding:T}=o._zod.bag;if(typeof y=="number"&&(f.minLength=y),typeof w=="number"&&(f.maxLength=w),v&&(f.format=pGn[v]??v,f.format===""&&delete f.format,v==="time"&&delete f.format),T&&(f.contentEncoding=T),_&&_.size>0){let R=[..._];R.length===1?f.pattern=R[0].source:R.length>1&&(f.allOf=[...R.map(F=>({...c.target==="draft-07"||c.target==="draft-04"||c.target==="openapi-3.0"?{type:"string"}:{},pattern:F.source}))])}},E1t=(o,c,u,p)=>{let f=u,{minimum:y,maximum:w,format:v,multipleOf:_,exclusiveMaximum:T,exclusiveMinimum:R}=o._zod.bag;typeof v=="string"&&v.includes("int")?f.type="integer":f.type="number",typeof R=="number"&&(c.target==="draft-04"||c.target==="openapi-3.0"?(f.minimum=R,f.exclusiveMinimum=!0):f.exclusiveMinimum=R),typeof y=="number"&&(f.minimum=y,typeof R=="number"&&c.target!=="draft-04"&&(R>=y?delete f.minimum:delete f.exclusiveMinimum)),typeof T=="number"&&(c.target==="draft-04"||c.target==="openapi-3.0"?(f.maximum=T,f.exclusiveMaximum=!0):f.exclusiveMaximum=T),typeof w=="number"&&(f.maximum=w,typeof T=="number"&&c.target!=="draft-04"&&(T<=w?delete f.maximum:delete f.exclusiveMaximum)),typeof _=="number"&&(f.multipleOf=_)},P1t=(o,c,u,p)=>{u.type="boolean"},L1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},T1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},A1t=(o,c,u,p)=>{c.target==="openapi-3.0"?(u.type="string",u.nullable=!0,u.enum=[null]):u.type="null"},N1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},R1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},D1t=(o,c,u,p)=>{u.not={}},O1t=(o,c,u,p)=>{},F1t=(o,c,u,p)=>{},z1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},$1t=(o,c,u,p)=>{let f=o._zod.def,y=Ree(f.entries);y.every(w=>typeof w=="number")&&(u.type="number"),y.every(w=>typeof w=="string")&&(u.type="string"),u.enum=y},j1t=(o,c,u,p)=>{let f=o._zod.def,y=[];for(let w of f.values)if(w===void 0){if(c.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof w=="bigint"){if(c.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");y.push(Number(w))}else y.push(w);if(y.length!==0)if(y.length===1){let w=y[0];u.type=w===null?"null":typeof w,c.target==="draft-04"||c.target==="openapi-3.0"?u.enum=[w]:u.const=w}else y.every(w=>typeof w=="number")&&(u.type="number"),y.every(w=>typeof w=="string")&&(u.type="string"),y.every(w=>typeof w=="boolean")&&(u.type="boolean"),y.every(w=>w===null)&&(u.type="null"),u.enum=y},B1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},H1t=(o,c,u,p)=>{let f=u,y=o._zod.pattern;if(!y)throw new Error("Pattern not found in template literal");f.type="string",f.pattern=y.source},U1t=(o,c,u,p)=>{let f=u,y={type:"string",format:"binary",contentEncoding:"binary"},{minimum:w,maximum:v,mime:_}=o._zod.bag;w!==void 0&&(y.minLength=w),v!==void 0&&(y.maxLength=v),_?_.length===1?(y.contentMediaType=_[0],Object.assign(f,y)):(Object.assign(f,y),f.anyOf=_.map(T=>({contentMediaType:T}))):Object.assign(f,y)},q1t=(o,c,u,p)=>{u.type="boolean"},G1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},V1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},W1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},J1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Z1t=(o,c,u,p)=>{if(c.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},X1t=(o,c,u,p)=>{let f=u,y=o._zod.def,{minimum:w,maximum:v}=o._zod.bag;typeof w=="number"&&(f.minItems=w),typeof v=="number"&&(f.maxItems=v),f.type="array",f.items=ll(y.element,c,{...p,path:[...p.path,"items"]})},K1t=(o,c,u,p)=>{let f=u,y=o._zod.def;f.type="object",f.properties={};let w=y.shape;for(let T in w)f.properties[T]=ll(w[T],c,{...p,path:[...p.path,"properties",T]});let v=new Set(Object.keys(w)),_=new Set([...v].filter(T=>{let R=y.shape[T]._zod;return c.io==="input"?R.optin===void 0:R.optout===void 0}));_.size>0&&(f.required=Array.from(_)),y.catchall?._zod.def.type==="never"?f.additionalProperties=!1:y.catchall?y.catchall&&(f.additionalProperties=ll(y.catchall,c,{...p,path:[...p.path,"additionalProperties"]})):c.io==="output"&&(f.additionalProperties=!1)},Npe=(o,c,u,p)=>{let f=o._zod.def,y=f.inclusive===!1,w=f.options.map((v,_)=>ll(v,c,{...p,path:[...p.path,y?"oneOf":"anyOf",_]}));y?u.oneOf=w:u.anyOf=w},Y1t=(o,c,u,p)=>{let f=o._zod.def,y=ll(f.left,c,{...p,path:[...p.path,"allOf",0]}),w=ll(f.right,c,{...p,path:[...p.path,"allOf",1]}),v=T=>"allOf"in T&&Object.keys(T).length===1,_=[...v(y)?y.allOf:[y],...v(w)?w.allOf:[w]];u.allOf=_},Q1t=(o,c,u,p)=>{let f=u,y=o._zod.def;f.type="array";let w=c.target==="draft-2020-12"?"prefixItems":"items",v=c.target==="draft-2020-12"||c.target==="openapi-3.0"?"items":"additionalItems",_=y.items.map((B,V)=>ll(B,c,{...p,path:[...p.path,w,V]})),T=y.rest?ll(y.rest,c,{...p,path:[...p.path,v,...c.target==="openapi-3.0"?[y.items.length]:[]]}):null;c.target==="draft-2020-12"?(f.prefixItems=_,T&&(f.items=T)):c.target==="openapi-3.0"?(f.items={anyOf:_},T&&f.items.anyOf.push(T),f.minItems=_.length,T||(f.maxItems=_.length)):(f.items=_,T&&(f.additionalItems=T));let{minimum:R,maximum:F}=o._zod.bag;typeof R=="number"&&(f.minItems=R),typeof F=="number"&&(f.maxItems=F)},eht=(o,c,u,p)=>{let f=u,y=o._zod.def;f.type="object";let w=y.keyType,_=w._zod.bag?.patterns;if(y.mode==="loose"&&_&&_.size>0){let R=ll(y.valueType,c,{...p,path:[...p.path,"patternProperties","*"]});f.patternProperties={};for(let F of _)f.patternProperties[F.source]=R}else(c.target==="draft-07"||c.target==="draft-2020-12")&&(f.propertyNames=ll(y.keyType,c,{...p,path:[...p.path,"propertyNames"]})),f.additionalProperties=ll(y.valueType,c,{...p,path:[...p.path,"additionalProperties"]});let T=w._zod.values;if(T){let R=[...T].filter(F=>typeof F=="string"||typeof F=="number");R.length>0&&(f.required=R)}},tht=(o,c,u,p)=>{let f=o._zod.def,y=ll(f.innerType,c,p),w=c.seen.get(o);c.target==="openapi-3.0"?(w.ref=f.innerType,u.nullable=!0):u.anyOf=[y,{type:"null"}]},nht=(o,c,u,p)=>{let f=o._zod.def;ll(f.innerType,c,p);let y=c.seen.get(o);y.ref=f.innerType},rht=(o,c,u,p)=>{let f=o._zod.def;ll(f.innerType,c,p);let y=c.seen.get(o);y.ref=f.innerType,u.default=JSON.parse(JSON.stringify(f.defaultValue))},iht=(o,c,u,p)=>{let f=o._zod.def;ll(f.innerType,c,p);let y=c.seen.get(o);y.ref=f.innerType,c.io==="input"&&(u._prefault=JSON.parse(JSON.stringify(f.defaultValue)))},oht=(o,c,u,p)=>{let f=o._zod.def;ll(f.innerType,c,p);let y=c.seen.get(o);y.ref=f.innerType;let w;try{w=f.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}u.default=w},cht=(o,c,u,p)=>{let f=o._zod.def,y=c.io==="input"?f.in._zod.def.type==="transform"?f.out:f.in:f.out;ll(y,c,p);let w=c.seen.get(o);w.ref=y},aht=(o,c,u,p)=>{let f=o._zod.def;ll(f.innerType,c,p);let y=c.seen.get(o);y.ref=f.innerType,u.readOnly=!0},sht=(o,c,u,p)=>{let f=o._zod.def;ll(f.innerType,c,p);let y=c.seen.get(o);y.ref=f.innerType},Rpe=(o,c,u,p)=>{let f=o._zod.def;ll(f.innerType,c,p);let y=c.seen.get(o);y.ref=f.innerType},lht=(o,c,u,p)=>{let f=o._zod.innerType;ll(f,c,p);let y=c.seen.get(o);y.ref=f},Ape={string:I1t,number:E1t,boolean:P1t,bigint:L1t,symbol:T1t,null:A1t,undefined:N1t,void:R1t,never:D1t,any:O1t,unknown:F1t,date:z1t,enum:$1t,literal:j1t,nan:B1t,template_literal:H1t,file:U1t,success:q1t,custom:G1t,function:V1t,transform:W1t,map:J1t,set:Z1t,array:X1t,object:K1t,union:Npe,intersection:Y1t,tuple:Q1t,record:eht,nullable:tht,nonoptional:nht,default:rht,prefault:iht,catch:oht,pipe:cht,readonly:aht,promise:sht,optional:Rpe,lazy:lht};function Dpe(o,c){if("_idmap"in o){let p=o,f=xE({...c,processors:Ape}),y={};for(let _ of p._idmap.entries()){let[T,R]=_;ll(R,f)}let w={},v={registry:p,uri:c?.uri,defs:y};f.external=v;for(let _ of p._idmap.entries()){let[T,R]=_;SE(f,R),w[T]=_E(f,R)}if(Object.keys(y).length>0){let _=f.target==="draft-2020-12"?"$defs":"definitions";w.__shared={[_]:y}}return{schemas:w}}let u=xE({...c,processors:Ape});return ll(o,u),SE(u,o),_E(u,o)}var Ope=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 u=c?.target??"draft-2020-12";u==="draft-4"&&(u="draft-04"),u==="draft-7"&&(u="draft-07"),this.ctx=xE({processors:Ape,target:u,...c?.metadata&&{metadata:c.metadata},...c?.unrepresentable&&{unrepresentable:c.unrepresentable},...c?.override&&{override:c.override},...c?.io&&{io:c.io}})}process(c,u={path:[],schemaPath:[]}){return ll(c,this.ctx,u)}emit(c,u){u&&(u.cycles&&(this.ctx.cycles=u.cycles),u.reused&&(this.ctx.reused=u.reused),u.external&&(this.ctx.external=u.external)),SE(this.ctx,c);let p=_E(this.ctx,c),{"~standard":f,...y}=p;return y}};var Nrn={};var Yee={};Qx(Yee,{ZodAny:()=>Nht,ZodArray:()=>Fht,ZodBase64:()=>rge,ZodBase64URL:()=>ige,ZodBigInt:()=>rG,ZodBigIntFormat:()=>age,ZodBoolean:()=>nG,ZodCIDRv4:()=>tge,ZodCIDRv6:()=>nge,ZodCUID:()=>Jpe,ZodCUID2:()=>Zpe,ZodCatch:()=>oft,ZodCodec:()=>gge,ZodCustom:()=>lte,ZodCustomStringFormat:()=>eG,ZodDate:()=>ite,ZodDefault:()=>Qht,ZodDiscriminatedUnion:()=>$ht,ZodE164:()=>oge,ZodEmail:()=>Gpe,ZodEmoji:()=>Vpe,ZodEnum:()=>Yq,ZodExactOptional:()=>Xht,ZodFile:()=>Jht,ZodFunction:()=>pft,ZodGUID:()=>Qee,ZodIPv4:()=>Qpe,ZodIPv6:()=>ege,ZodIntersection:()=>jht,ZodJWT:()=>cge,ZodKSUID:()=>Ype,ZodLazy:()=>dft,ZodLiteral:()=>Wht,ZodMAC:()=>Cht,ZodMap:()=>Ght,ZodNaN:()=>aft,ZodNanoID:()=>Wpe,ZodNever:()=>Dht,ZodNonOptional:()=>fge,ZodNull:()=>Tht,ZodNullable:()=>Yht,ZodNumber:()=>tG,ZodNumberFormat:()=>TR,ZodObject:()=>cte,ZodOptional:()=>hge,ZodPipe:()=>pge,ZodPrefault:()=>tft,ZodPromise:()=>fft,ZodReadonly:()=>sft,ZodRecord:()=>ste,ZodSet:()=>Vht,ZodString:()=>Qq,ZodStringFormat:()=>iu,ZodSuccess:()=>ift,ZodSymbol:()=>Pht,ZodTemplateLiteral:()=>uft,ZodTransform:()=>Zht,ZodTuple:()=>Hht,ZodType:()=>kc,ZodULID:()=>Xpe,ZodURL:()=>rte,ZodUUID:()=>j9,ZodUndefined:()=>Lht,ZodUnion:()=>ate,ZodUnknown:()=>Rht,ZodVoid:()=>Oht,ZodXID:()=>Kpe,ZodXor:()=>zht,_ZodString:()=>qpe,_default:()=>eft,_function:()=>jin,any:()=>min,array:()=>ote,base64:()=>tin,base64url:()=>nin,bigint:()=>fin,boolean:()=>Eht,catch:()=>cft,check:()=>Bin,cidrv4:()=>Qrn,cidrv6:()=>ein,codec:()=>Fin,cuid:()=>Grn,cuid2:()=>Vrn,custom:()=>Hin,date:()=>vin,describe:()=>Uin,discriminatedUnion:()=>Cin,e164:()=>rin,email:()=>Drn,emoji:()=>Urn,enum:()=>uge,exactOptional:()=>Kht,file:()=>Nin,float32:()=>lin,float64:()=>uin,function:()=>jin,guid:()=>Orn,hash:()=>sin,hex:()=>ain,hostname:()=>cin,httpUrl:()=>Hrn,instanceof:()=>Gin,int:()=>Upe,int32:()=>din,int64:()=>pin,intersection:()=>Bht,ipv4:()=>Xrn,ipv6:()=>Yrn,json:()=>Win,jwt:()=>iin,keyof:()=>kin,ksuid:()=>Zrn,lazy:()=>hft,literal:()=>Ain,looseObject:()=>Sin,looseRecord:()=>Ein,mac:()=>Krn,map:()=>Pin,meta:()=>qin,nan:()=>Oin,nanoid:()=>qrn,nativeEnum:()=>Tin,never:()=>sge,nonoptional:()=>rft,null:()=>Aht,nullable:()=>tte,nullish:()=>Rin,number:()=>Iht,object:()=>Min,optional:()=>ete,partialRecord:()=>Iin,pipe:()=>nte,prefault:()=>nft,preprocess:()=>Jin,promise:()=>$in,readonly:()=>lft,record:()=>qht,refine:()=>gft,set:()=>Lin,strictObject:()=>xin,string:()=>Hpe,stringFormat:()=>oin,stringbool:()=>Vin,success:()=>Din,superRefine:()=>yft,symbol:()=>yin,templateLiteral:()=>zin,transform:()=>dge,tuple:()=>Uht,uint32:()=>hin,uint64:()=>gin,ulid:()=>Wrn,undefined:()=>bin,union:()=>lge,unknown:()=>LR,url:()=>Brn,uuid:()=>Frn,uuidv4:()=>zrn,uuidv6:()=>$rn,uuidv7:()=>jrn,void:()=>win,xid:()=>Jrn,xor:()=>_in});var Fpe={};Qx(Fpe,{endsWith:()=>Hq,gt:()=>z9,gte:()=>rb,includes:()=>jq,length:()=>PR,lowercase:()=>zq,lt:()=>F9,lte:()=>xv,maxLength:()=>ER,maxSize:()=>ME,mime:()=>Uq,minLength:()=>oS,minSize:()=>$9,multipleOf:()=>kE,negative:()=>Epe,nonnegative:()=>Lpe,nonpositive:()=>Ppe,normalize:()=>qq,overwrite:()=>s6,positive:()=>Ipe,property:()=>Tpe,regex:()=>Fq,size:()=>IR,slugify:()=>Jq,startsWith:()=>Bq,toLowerCase:()=>Vq,toUpperCase:()=>Wq,trim:()=>Gq,uppercase:()=>$q});var Kq={};Qx(Kq,{ZodISODate:()=>$pe,ZodISODateTime:()=>zpe,ZodISODuration:()=>Bpe,ZodISOTime:()=>jpe,date:()=>dht,datetime:()=>uht,duration:()=>fht,time:()=>hht});var zpe=xt("ZodISODateTime",(o,c)=>{But.init(o,c),iu.init(o,c)});function uht(o){return Gdt(zpe,o)}var $pe=xt("ZodISODate",(o,c)=>{Hut.init(o,c),iu.init(o,c)});function dht(o){return Vdt($pe,o)}var jpe=xt("ZodISOTime",(o,c)=>{Uut.init(o,c),iu.init(o,c)});function hht(o){return Wdt(jpe,o)}var Bpe=xt("ZodISODuration",(o,c)=>{qut.init(o,c),iu.init(o,c)});function fht(o){return Jdt(Bpe,o)}var Rrn=(o,c)=>{$ee.init(o,c),o.name="ZodError",Object.defineProperties(o,{format:{value:u=>Bee(o,u)},flatten:{value:u=>jee(o,u)},addIssue:{value:u=>{o.issues.push(u),o.message=JSON.stringify(o.issues,Eq,2)}},addIssues:{value:u=>{o.issues.push(...u),o.message=JSON.stringify(o.issues,Eq,2)}},isEmpty:{get(){return o.issues.length===0}}})},yGn=xt("ZodError",Rrn),Hm=xt("ZodError",Rrn,{Parent:Error});var pht=Tq(Hm),ght=Aq(Hm),yht=Nq(Hm),bht=Rq(Hm),mht=D2e(Hm),wht=O2e(Hm),vht=F2e(Hm),kht=z2e(Hm),Mht=$2e(Hm),xht=j2e(Hm),Sht=B2e(Hm),_ht=H2e(Hm);var kc=xt("ZodType",(o,c)=>(Ho.init(o,c),Object.assign(o["~standard"],{jsonSchema:{input:Xq(o,"input"),output:Xq(o,"output")}}),o.toJSONSchema=C1t(o,{}),o.def=c,o.type=c.type,Object.defineProperty(o,"_def",{value:c}),o.check=(...u)=>o.clone(fr.mergeDefs(c,{checks:[...c.checks??[],...u.map(p=>typeof p=="function"?{_zod:{check:p,def:{check:"custom"},onattach:[]}}:p)]}),{parent:!0}),o.with=o.check,o.clone=(u,p)=>nb(o,u,p),o.brand=()=>o,o.register=((u,p)=>(u.add(o,p),o)),o.parse=(u,p)=>pht(o,u,p,{callee:o.parse}),o.safeParse=(u,p)=>yht(o,u,p),o.parseAsync=async(u,p)=>ght(o,u,p,{callee:o.parseAsync}),o.safeParseAsync=async(u,p)=>bht(o,u,p),o.spa=o.safeParseAsync,o.encode=(u,p)=>mht(o,u,p),o.decode=(u,p)=>wht(o,u,p),o.encodeAsync=async(u,p)=>vht(o,u,p),o.decodeAsync=async(u,p)=>kht(o,u,p),o.safeEncode=(u,p)=>Mht(o,u,p),o.safeDecode=(u,p)=>xht(o,u,p),o.safeEncodeAsync=async(u,p)=>Sht(o,u,p),o.safeDecodeAsync=async(u,p)=>_ht(o,u,p),o.refine=(u,p)=>o.check(gft(u,p)),o.superRefine=u=>o.check(yft(u)),o.overwrite=u=>o.check(s6(u)),o.optional=()=>ete(o),o.exactOptional=()=>Kht(o),o.nullable=()=>tte(o),o.nullish=()=>ete(tte(o)),o.nonoptional=u=>rft(o,u),o.array=()=>ote(o),o.or=u=>lge([o,u]),o.and=u=>Bht(o,u),o.transform=u=>nte(o,dge(u)),o.default=u=>eft(o,u),o.prefault=u=>nft(o,u),o.catch=u=>cft(o,u),o.pipe=u=>nte(o,u),o.readonly=()=>lft(o),o.describe=u=>{let p=o.clone();return Dp.add(p,{description:u}),p},Object.defineProperty(o,"description",{get(){return Dp.get(o)?.description},configurable:!0}),o.meta=(...u)=>{if(u.length===0)return Dp.get(o);let p=o.clone();return Dp.add(p,u[0]),p},o.isOptional=()=>o.safeParse(void 0).success,o.isNullable=()=>o.safeParse(null).success,o.apply=u=>u(o),o)),qpe=xt("_ZodString",(o,c)=>{CR.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(p,f,y)=>I1t(o,p,f,y);let u=o._zod.bag;o.format=u.format??null,o.minLength=u.minimum??null,o.maxLength=u.maximum??null,o.regex=(...p)=>o.check(Fq(...p)),o.includes=(...p)=>o.check(jq(...p)),o.startsWith=(...p)=>o.check(Bq(...p)),o.endsWith=(...p)=>o.check(Hq(...p)),o.min=(...p)=>o.check(oS(...p)),o.max=(...p)=>o.check(ER(...p)),o.length=(...p)=>o.check(PR(...p)),o.nonempty=(...p)=>o.check(oS(1,...p)),o.lowercase=p=>o.check(zq(p)),o.uppercase=p=>o.check($q(p)),o.trim=()=>o.check(Gq()),o.normalize=(...p)=>o.check(qq(...p)),o.toLowerCase=()=>o.check(Vq()),o.toUpperCase=()=>o.check(Wq()),o.slugify=()=>o.check(Jq())}),Qq=xt("ZodString",(o,c)=>{CR.init(o,c),qpe.init(o,c),o.email=u=>o.check(ape(Gpe,u)),o.url=u=>o.check(Kee(rte,u)),o.jwt=u=>o.check(Cpe(cge,u)),o.emoji=u=>o.check(hpe(Vpe,u)),o.guid=u=>o.check(Xee(Qee,u)),o.uuid=u=>o.check(spe(j9,u)),o.uuidv4=u=>o.check(lpe(j9,u)),o.uuidv6=u=>o.check(upe(j9,u)),o.uuidv7=u=>o.check(dpe(j9,u)),o.nanoid=u=>o.check(fpe(Wpe,u)),o.guid=u=>o.check(Xee(Qee,u)),o.cuid=u=>o.check(ppe(Jpe,u)),o.cuid2=u=>o.check(gpe(Zpe,u)),o.ulid=u=>o.check(ype(Xpe,u)),o.base64=u=>o.check(xpe(rge,u)),o.base64url=u=>o.check(Spe(ige,u)),o.xid=u=>o.check(bpe(Kpe,u)),o.ksuid=u=>o.check(mpe(Ype,u)),o.ipv4=u=>o.check(wpe(Qpe,u)),o.ipv6=u=>o.check(vpe(ege,u)),o.cidrv4=u=>o.check(kpe(tge,u)),o.cidrv6=u=>o.check(Mpe(nge,u)),o.e164=u=>o.check(_pe(oge,u)),o.datetime=u=>o.check(uht(u)),o.date=u=>o.check(dht(u)),o.time=u=>o.check(hht(u)),o.duration=u=>o.check(fht(u))});function Hpe(o){return Bdt(Qq,o)}var iu=xt("ZodStringFormat",(o,c)=>{ru.init(o,c),qpe.init(o,c)}),Gpe=xt("ZodEmail",(o,c)=>{Aut.init(o,c),iu.init(o,c)});function Drn(o){return ape(Gpe,o)}var Qee=xt("ZodGUID",(o,c)=>{Lut.init(o,c),iu.init(o,c)});function Orn(o){return Xee(Qee,o)}var j9=xt("ZodUUID",(o,c)=>{Tut.init(o,c),iu.init(o,c)});function Frn(o){return spe(j9,o)}function zrn(o){return lpe(j9,o)}function $rn(o){return upe(j9,o)}function jrn(o){return dpe(j9,o)}var rte=xt("ZodURL",(o,c)=>{Nut.init(o,c),iu.init(o,c)});function Brn(o){return Kee(rte,o)}function Hrn(o){return Kee(rte,{protocol:/^https?$/,hostname:I3.domain,...fr.normalizeParams(o)})}var Vpe=xt("ZodEmoji",(o,c)=>{Rut.init(o,c),iu.init(o,c)});function Urn(o){return hpe(Vpe,o)}var Wpe=xt("ZodNanoID",(o,c)=>{Dut.init(o,c),iu.init(o,c)});function qrn(o){return fpe(Wpe,o)}var Jpe=xt("ZodCUID",(o,c)=>{Out.init(o,c),iu.init(o,c)});function Grn(o){return ppe(Jpe,o)}var Zpe=xt("ZodCUID2",(o,c)=>{Fut.init(o,c),iu.init(o,c)});function Vrn(o){return gpe(Zpe,o)}var Xpe=xt("ZodULID",(o,c)=>{zut.init(o,c),iu.init(o,c)});function Wrn(o){return ype(Xpe,o)}var Kpe=xt("ZodXID",(o,c)=>{$ut.init(o,c),iu.init(o,c)});function Jrn(o){return bpe(Kpe,o)}var Ype=xt("ZodKSUID",(o,c)=>{jut.init(o,c),iu.init(o,c)});function Zrn(o){return mpe(Ype,o)}var Qpe=xt("ZodIPv4",(o,c)=>{Gut.init(o,c),iu.init(o,c)});function Xrn(o){return wpe(Qpe,o)}var Cht=xt("ZodMAC",(o,c)=>{Wut.init(o,c),iu.init(o,c)});function Krn(o){return Udt(Cht,o)}var ege=xt("ZodIPv6",(o,c)=>{Vut.init(o,c),iu.init(o,c)});function Yrn(o){return vpe(ege,o)}var tge=xt("ZodCIDRv4",(o,c)=>{Jut.init(o,c),iu.init(o,c)});function Qrn(o){return kpe(tge,o)}var nge=xt("ZodCIDRv6",(o,c)=>{Zut.init(o,c),iu.init(o,c)});function ein(o){return Mpe(nge,o)}var rge=xt("ZodBase64",(o,c)=>{Kut.init(o,c),iu.init(o,c)});function tin(o){return xpe(rge,o)}var ige=xt("ZodBase64URL",(o,c)=>{Yut.init(o,c),iu.init(o,c)});function nin(o){return Spe(ige,o)}var oge=xt("ZodE164",(o,c)=>{Qut.init(o,c),iu.init(o,c)});function rin(o){return _pe(oge,o)}var cge=xt("ZodJWT",(o,c)=>{edt.init(o,c),iu.init(o,c)});function iin(o){return Cpe(cge,o)}var eG=xt("ZodCustomStringFormat",(o,c)=>{tdt.init(o,c),iu.init(o,c)});function oin(o,c,u={}){return Zq(eG,o,c,u)}function cin(o){return Zq(eG,"hostname",I3.hostname,o)}function ain(o){return Zq(eG,"hex",I3.hex,o)}function sin(o,c){let u=c?.enc??"hex",p=`${o}_${u}`,f=I3[p];if(!f)throw new Error(`Unrecognized hash format: ${p}`);return Zq(eG,p,f,c)}var tG=xt("ZodNumber",(o,c)=>{Y2e.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(p,f,y)=>E1t(o,p,f,y),o.gt=(p,f)=>o.check(z9(p,f)),o.gte=(p,f)=>o.check(rb(p,f)),o.min=(p,f)=>o.check(rb(p,f)),o.lt=(p,f)=>o.check(F9(p,f)),o.lte=(p,f)=>o.check(xv(p,f)),o.max=(p,f)=>o.check(xv(p,f)),o.int=p=>o.check(Upe(p)),o.safe=p=>o.check(Upe(p)),o.positive=p=>o.check(z9(0,p)),o.nonnegative=p=>o.check(rb(0,p)),o.negative=p=>o.check(F9(0,p)),o.nonpositive=p=>o.check(xv(0,p)),o.multipleOf=(p,f)=>o.check(kE(p,f)),o.step=(p,f)=>o.check(kE(p,f)),o.finite=()=>o;let u=o._zod.bag;o.minValue=Math.max(u.minimum??Number.NEGATIVE_INFINITY,u.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,o.maxValue=Math.min(u.maximum??Number.POSITIVE_INFINITY,u.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,o.isInt=(u.format??"").includes("int")||Number.isSafeInteger(u.multipleOf??.5),o.isFinite=!0,o.format=u.format??null});function Iht(o){return Zdt(tG,o)}var TR=xt("ZodNumberFormat",(o,c)=>{ndt.init(o,c),tG.init(o,c)});function Upe(o){return Kdt(TR,o)}function lin(o){return Ydt(TR,o)}function uin(o){return Qdt(TR,o)}function din(o){return e1t(TR,o)}function hin(o){return t1t(TR,o)}var nG=xt("ZodBoolean",(o,c)=>{Gee.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>P1t(o,u,p,f)});function Eht(o){return n1t(nG,o)}var rG=xt("ZodBigInt",(o,c)=>{Q2e.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(p,f,y)=>L1t(o,p,f,y),o.gte=(p,f)=>o.check(rb(p,f)),o.min=(p,f)=>o.check(rb(p,f)),o.gt=(p,f)=>o.check(z9(p,f)),o.gte=(p,f)=>o.check(rb(p,f)),o.min=(p,f)=>o.check(rb(p,f)),o.lt=(p,f)=>o.check(F9(p,f)),o.lte=(p,f)=>o.check(xv(p,f)),o.max=(p,f)=>o.check(xv(p,f)),o.positive=p=>o.check(z9(BigInt(0),p)),o.negative=p=>o.check(F9(BigInt(0),p)),o.nonpositive=p=>o.check(xv(BigInt(0),p)),o.nonnegative=p=>o.check(rb(BigInt(0),p)),o.multipleOf=(p,f)=>o.check(kE(p,f));let u=o._zod.bag;o.minValue=u.minimum??null,o.maxValue=u.maximum??null,o.format=u.format??null});function fin(o){return i1t(rG,o)}var age=xt("ZodBigIntFormat",(o,c)=>{rdt.init(o,c),rG.init(o,c)});function pin(o){return c1t(age,o)}function gin(o){return a1t(age,o)}var Pht=xt("ZodSymbol",(o,c)=>{idt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>T1t(o,u,p,f)});function yin(o){return s1t(Pht,o)}var Lht=xt("ZodUndefined",(o,c)=>{odt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>N1t(o,u,p,f)});function bin(o){return l1t(Lht,o)}var Tht=xt("ZodNull",(o,c)=>{cdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>A1t(o,u,p,f)});function Aht(o){return u1t(Tht,o)}var Nht=xt("ZodAny",(o,c)=>{adt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>O1t(o,u,p,f)});function min(){return d1t(Nht)}var Rht=xt("ZodUnknown",(o,c)=>{sdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>F1t(o,u,p,f)});function LR(){return h1t(Rht)}var Dht=xt("ZodNever",(o,c)=>{ldt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>D1t(o,u,p,f)});function sge(o){return f1t(Dht,o)}var Oht=xt("ZodVoid",(o,c)=>{udt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>R1t(o,u,p,f)});function win(o){return p1t(Oht,o)}var ite=xt("ZodDate",(o,c)=>{ddt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(p,f,y)=>z1t(o,p,f,y),o.min=(p,f)=>o.check(rb(p,f)),o.max=(p,f)=>o.check(xv(p,f));let u=o._zod.bag;o.minDate=u.minimum?new Date(u.minimum):null,o.maxDate=u.maximum?new Date(u.maximum):null});function vin(o){return g1t(ite,o)}var Fht=xt("ZodArray",(o,c)=>{hdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>X1t(o,u,p,f),o.element=c.element,o.min=(u,p)=>o.check(oS(u,p)),o.nonempty=u=>o.check(oS(1,u)),o.max=(u,p)=>o.check(ER(u,p)),o.length=(u,p)=>o.check(PR(u,p)),o.unwrap=()=>o.element});function ote(o,c){return m1t(Fht,o,c)}function kin(o){let c=o._zod.def.shape;return uge(Object.keys(c))}var cte=xt("ZodObject",(o,c)=>{fdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>K1t(o,u,p,f),fr.defineLazy(o,"shape",()=>c.shape),o.keyof=()=>uge(Object.keys(o._zod.def.shape)),o.catchall=u=>o.clone({...o._zod.def,catchall:u}),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:sge()}),o.strip=()=>o.clone({...o._zod.def,catchall:void 0}),o.extend=u=>fr.extend(o,u),o.safeExtend=u=>fr.safeExtend(o,u),o.merge=u=>fr.merge(o,u),o.pick=u=>fr.pick(o,u),o.omit=u=>fr.omit(o,u),o.partial=(...u)=>fr.partial(hge,o,u[0]),o.required=(...u)=>fr.required(fge,o,u[0])});function Min(o,c){let u={type:"object",shape:o??{},...fr.normalizeParams(c)};return new cte(u)}function xin(o,c){return new cte({type:"object",shape:o,catchall:sge(),...fr.normalizeParams(c)})}function Sin(o,c){return new cte({type:"object",shape:o,catchall:LR(),...fr.normalizeParams(c)})}var ate=xt("ZodUnion",(o,c)=>{Vee.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>Npe(o,u,p,f),o.options=c.options});function lge(o,c){return new ate({type:"union",options:o,...fr.normalizeParams(c)})}var zht=xt("ZodXor",(o,c)=>{ate.init(o,c),pdt.init(o,c),o._zod.processJSONSchema=(u,p,f)=>Npe(o,u,p,f),o.options=c.options});function _in(o,c){return new zht({type:"union",options:o,inclusive:!1,...fr.normalizeParams(c)})}var $ht=xt("ZodDiscriminatedUnion",(o,c)=>{ate.init(o,c),gdt.init(o,c)});function Cin(o,c,u){return new $ht({type:"union",options:c,discriminator:o,...fr.normalizeParams(u)})}var jht=xt("ZodIntersection",(o,c)=>{ydt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>Y1t(o,u,p,f)});function Bht(o,c){return new jht({type:"intersection",left:o,right:c})}var Hht=xt("ZodTuple",(o,c)=>{epe.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>Q1t(o,u,p,f),o.rest=u=>o.clone({...o._zod.def,rest:u})});function Uht(o,c,u){let p=c instanceof Ho,f=p?u:c,y=p?c:null;return new Hht({type:"tuple",items:o,rest:y,...fr.normalizeParams(f)})}var ste=xt("ZodRecord",(o,c)=>{bdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>eht(o,u,p,f),o.keyType=c.keyType,o.valueType=c.valueType});function qht(o,c,u){return new ste({type:"record",keyType:o,valueType:c,...fr.normalizeParams(u)})}function Iin(o,c,u){let p=nb(o);return p._zod.values=void 0,new ste({type:"record",keyType:p,valueType:c,...fr.normalizeParams(u)})}function Ein(o,c,u){return new ste({type:"record",keyType:o,valueType:c,mode:"loose",...fr.normalizeParams(u)})}var Ght=xt("ZodMap",(o,c)=>{mdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>J1t(o,u,p,f),o.keyType=c.keyType,o.valueType=c.valueType,o.min=(...u)=>o.check($9(...u)),o.nonempty=u=>o.check($9(1,u)),o.max=(...u)=>o.check(ME(...u)),o.size=(...u)=>o.check(IR(...u))});function Pin(o,c,u){return new Ght({type:"map",keyType:o,valueType:c,...fr.normalizeParams(u)})}var Vht=xt("ZodSet",(o,c)=>{wdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>Z1t(o,u,p,f),o.min=(...u)=>o.check($9(...u)),o.nonempty=u=>o.check($9(1,u)),o.max=(...u)=>o.check(ME(...u)),o.size=(...u)=>o.check(IR(...u))});function Lin(o,c){return new Vht({type:"set",valueType:o,...fr.normalizeParams(c)})}var Yq=xt("ZodEnum",(o,c)=>{vdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(p,f,y)=>$1t(o,p,f,y),o.enum=c.entries,o.options=Object.values(c.entries);let u=new Set(Object.keys(c.entries));o.extract=(p,f)=>{let y={};for(let w of p)if(u.has(w))y[w]=c.entries[w];else throw new Error(`Key ${w} not found in enum`);return new Yq({...c,checks:[],...fr.normalizeParams(f),entries:y})},o.exclude=(p,f)=>{let y={...c.entries};for(let w of p)if(u.has(w))delete y[w];else throw new Error(`Key ${w} not found in enum`);return new Yq({...c,checks:[],...fr.normalizeParams(f),entries:y})}});function uge(o,c){let u=Array.isArray(o)?Object.fromEntries(o.map(p=>[p,p])):o;return new Yq({type:"enum",entries:u,...fr.normalizeParams(c)})}function Tin(o,c){return new Yq({type:"enum",entries:o,...fr.normalizeParams(c)})}var Wht=xt("ZodLiteral",(o,c)=>{kdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>j1t(o,u,p,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 Ain(o,c){return new Wht({type:"literal",values:Array.isArray(o)?o:[o],...fr.normalizeParams(c)})}var Jht=xt("ZodFile",(o,c)=>{Mdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>U1t(o,u,p,f),o.min=(u,p)=>o.check($9(u,p)),o.max=(u,p)=>o.check(ME(u,p)),o.mime=(u,p)=>o.check(Uq(Array.isArray(u)?u:[u],p))});function Nin(o){return w1t(Jht,o)}var Zht=xt("ZodTransform",(o,c)=>{xdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>W1t(o,u,p,f),o._zod.parse=(u,p)=>{if(p.direction==="backward")throw new yE(o.constructor.name);u.addIssue=y=>{if(typeof y=="string")u.issues.push(fr.issue(y,u.value,c));else{let w=y;w.fatal&&(w.continue=!1),w.code??(w.code="custom"),w.input??(w.input=u.value),w.inst??(w.inst=o),u.issues.push(fr.issue(w))}};let f=c.transform(u.value,u);return f instanceof Promise?f.then(y=>(u.value=y,u)):(u.value=f,u)}});function dge(o){return new Zht({type:"transform",transform:o})}var hge=xt("ZodOptional",(o,c)=>{tpe.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>Rpe(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function ete(o){return new hge({type:"optional",innerType:o})}var Xht=xt("ZodExactOptional",(o,c)=>{Sdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>Rpe(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function Kht(o){return new Xht({type:"optional",innerType:o})}var Yht=xt("ZodNullable",(o,c)=>{_dt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>tht(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function tte(o){return new Yht({type:"nullable",innerType:o})}function Rin(o){return ete(tte(o))}var Qht=xt("ZodDefault",(o,c)=>{Cdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>rht(o,u,p,f),o.unwrap=()=>o._zod.def.innerType,o.removeDefault=o.unwrap});function eft(o,c){return new Qht({type:"default",innerType:o,get defaultValue(){return typeof c=="function"?c():fr.shallowClone(c)}})}var tft=xt("ZodPrefault",(o,c)=>{Idt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>iht(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function nft(o,c){return new tft({type:"prefault",innerType:o,get defaultValue(){return typeof c=="function"?c():fr.shallowClone(c)}})}var fge=xt("ZodNonOptional",(o,c)=>{Edt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>nht(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function rft(o,c){return new fge({type:"nonoptional",innerType:o,...fr.normalizeParams(c)})}var ift=xt("ZodSuccess",(o,c)=>{Pdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>q1t(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function Din(o){return new ift({type:"success",innerType:o})}var oft=xt("ZodCatch",(o,c)=>{Ldt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>oht(o,u,p,f),o.unwrap=()=>o._zod.def.innerType,o.removeCatch=o.unwrap});function cft(o,c){return new oft({type:"catch",innerType:o,catchValue:typeof c=="function"?c:()=>c})}var aft=xt("ZodNaN",(o,c)=>{Tdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>B1t(o,u,p,f)});function Oin(o){return b1t(aft,o)}var pge=xt("ZodPipe",(o,c)=>{Adt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>cht(o,u,p,f),o.in=c.in,o.out=c.out});function nte(o,c){return new pge({type:"pipe",in:o,out:c})}var gge=xt("ZodCodec",(o,c)=>{pge.init(o,c),Wee.init(o,c)});function Fin(o,c,u){return new gge({type:"pipe",in:o,out:c,transform:u.decode,reverseTransform:u.encode})}var sft=xt("ZodReadonly",(o,c)=>{Ndt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>aht(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function lft(o){return new sft({type:"readonly",innerType:o})}var uft=xt("ZodTemplateLiteral",(o,c)=>{Rdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>H1t(o,u,p,f)});function zin(o,c){return new uft({type:"template_literal",parts:o,...fr.normalizeParams(c)})}var dft=xt("ZodLazy",(o,c)=>{Fdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>lht(o,u,p,f),o.unwrap=()=>o._zod.def.getter()});function hft(o){return new dft({type:"lazy",getter:o})}var fft=xt("ZodPromise",(o,c)=>{Odt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>sht(o,u,p,f),o.unwrap=()=>o._zod.def.innerType});function $in(o){return new fft({type:"promise",innerType:o})}var pft=xt("ZodFunction",(o,c)=>{Ddt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>V1t(o,u,p,f)});function jin(o){return new pft({type:"function",input:Array.isArray(o?.input)?Uht(o?.input):o?.input??ote(LR()),output:o?.output??LR()})}var lte=xt("ZodCustom",(o,c)=>{zdt.init(o,c),kc.init(o,c),o._zod.processJSONSchema=(u,p,f)=>G1t(o,u,p,f)});function Bin(o){let c=new xu({check:"custom"});return c._zod.check=o,c}function Hin(o,c){return v1t(lte,o??(()=>!0),c)}function gft(o,c={}){return k1t(lte,o,c)}function yft(o){return M1t(o)}var Uin=x1t,qin=S1t;function Gin(o,c={}){let u=new lte({type:"custom",check:"custom",fn:p=>p instanceof o,abort:!0,...fr.normalizeParams(c)});return u._zod.bag.Class=o,u._zod.check=p=>{p.value instanceof o||p.issues.push({code:"invalid_type",expected:o.name,input:p.value,inst:u,path:[...u._zod.def.path??[]]})},u}var Vin=(...o)=>_1t({Codec:gge,Boolean:nG,String:Qq},...o);function Win(o){let c=hft(()=>lge([Hpe(o),Iht(),Eht(),Aht(),ote(c),qht(Hpe(),c)]));return c}function Jin(o,c){return nte(dge(o),c)}var mGn={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 wGn(o){Mh({customError:o})}function vGn(){return Mh().customError}var bft;bft||(bft={});var Hr={...Yee,...Fpe,iso:Kq},kGn=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 MGn(o,c){let u=o.$schema;return u==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":u==="http://json-schema.org/draft-07/schema#"?"draft-7":u==="http://json-schema.org/draft-04/schema#"?"draft-4":c??"draft-2020-12"}function xGn(o,c){if(!o.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");let u=o.slice(1).split("/").filter(Boolean);if(u.length===0)return c.rootSchema;let p=c.version==="draft-2020-12"?"$defs":"definitions";if(u[0]===p){let f=u[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 Zin(o,c){if(o.not!==void 0){if(typeof o.not=="object"&&Object.keys(o.not).length===0)return Hr.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 Hr.lazy(()=>{if(!c.refs.has(f))throw new Error(`Circular reference not resolved: ${f}`);return c.refs.get(f)});c.processing.add(f);let y=xGn(f,c),w=$g(y,c);return c.refs.set(f,w),c.processing.delete(f),w}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 Hr.null();if(f.length===0)return Hr.never();if(f.length===1)return Hr.literal(f[0]);if(f.every(w=>typeof w=="string"))return Hr.enum(f);let y=f.map(w=>Hr.literal(w));return y.length<2?y[0]:Hr.union([y[0],y[1],...y.slice(2)])}if(o.const!==void 0)return Hr.literal(o.const);let u=o.type;if(Array.isArray(u)){let f=u.map(y=>{let w={...o,type:y};return Zin(w,c)});return f.length===0?Hr.never():f.length===1?f[0]:Hr.union(f)}if(!u)return Hr.any();let p;switch(u){case"string":{let f=Hr.string();if(o.format){let y=o.format;y==="email"?f=f.check(Hr.email()):y==="uri"||y==="uri-reference"?f=f.check(Hr.url()):y==="uuid"||y==="guid"?f=f.check(Hr.uuid()):y==="date-time"?f=f.check(Hr.iso.datetime()):y==="date"?f=f.check(Hr.iso.date()):y==="time"?f=f.check(Hr.iso.time()):y==="duration"?f=f.check(Hr.iso.duration()):y==="ipv4"?f=f.check(Hr.ipv4()):y==="ipv6"?f=f.check(Hr.ipv6()):y==="mac"?f=f.check(Hr.mac()):y==="cidr"?f=f.check(Hr.cidrv4()):y==="cidr-v6"?f=f.check(Hr.cidrv6()):y==="base64"?f=f.check(Hr.base64()):y==="base64url"?f=f.check(Hr.base64url()):y==="e164"?f=f.check(Hr.e164()):y==="jwt"?f=f.check(Hr.jwt()):y==="emoji"?f=f.check(Hr.emoji()):y==="nanoid"?f=f.check(Hr.nanoid()):y==="cuid"?f=f.check(Hr.cuid()):y==="cuid2"?f=f.check(Hr.cuid2()):y==="ulid"?f=f.check(Hr.ulid()):y==="xid"?f=f.check(Hr.xid()):y==="ksuid"&&(f=f.check(Hr.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))),p=f;break}case"number":case"integer":{let f=u==="integer"?Hr.number().int():Hr.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)),p=f;break}case"boolean":{p=Hr.boolean();break}case"null":{p=Hr.null();break}case"object":{let f={},y=o.properties||{},w=new Set(o.required||[]);for(let[_,T]of Object.entries(y)){let R=$g(T,c);f[_]=w.has(_)?R:R.optional()}if(o.propertyNames){let _=$g(o.propertyNames,c),T=o.additionalProperties&&typeof o.additionalProperties=="object"?$g(o.additionalProperties,c):Hr.any();if(Object.keys(f).length===0){p=Hr.record(_,T);break}let R=Hr.object(f).passthrough(),F=Hr.looseRecord(_,T);p=Hr.intersection(R,F);break}if(o.patternProperties){let _=o.patternProperties,T=Object.keys(_),R=[];for(let B of T){let V=$g(_[B],c),se=Hr.string().regex(new RegExp(B));R.push(Hr.looseRecord(se,V))}let F=[];if(Object.keys(f).length>0&&F.push(Hr.object(f).passthrough()),F.push(...R),F.length===0)p=Hr.object({}).passthrough();else if(F.length===1)p=F[0];else{let B=Hr.intersection(F[0],F[1]);for(let V=2;V<F.length;V++)B=Hr.intersection(B,F[V]);p=B}break}let v=Hr.object(f);o.additionalProperties===!1?p=v.strict():typeof o.additionalProperties=="object"?p=v.catchall($g(o.additionalProperties,c)):p=v.passthrough();break}case"array":{let f=o.prefixItems,y=o.items;if(f&&Array.isArray(f)){let w=f.map(_=>$g(_,c)),v=y&&typeof y=="object"&&!Array.isArray(y)?$g(y,c):void 0;v?p=Hr.tuple(w).rest(v):p=Hr.tuple(w),typeof o.minItems=="number"&&(p=p.check(Hr.minLength(o.minItems))),typeof o.maxItems=="number"&&(p=p.check(Hr.maxLength(o.maxItems)))}else if(Array.isArray(y)){let w=y.map(_=>$g(_,c)),v=o.additionalItems&&typeof o.additionalItems=="object"?$g(o.additionalItems,c):void 0;v?p=Hr.tuple(w).rest(v):p=Hr.tuple(w),typeof o.minItems=="number"&&(p=p.check(Hr.minLength(o.minItems))),typeof o.maxItems=="number"&&(p=p.check(Hr.maxLength(o.maxItems)))}else if(y!==void 0){let w=$g(y,c),v=Hr.array(w);typeof o.minItems=="number"&&(v=v.min(o.minItems)),typeof o.maxItems=="number"&&(v=v.max(o.maxItems)),p=v}else p=Hr.array(Hr.any());break}default:throw new Error(`Unsupported type: ${u}`)}return o.description&&(p=p.describe(o.description)),o.default!==void 0&&(p=p.default(o.default)),p}function $g(o,c){if(typeof o=="boolean")return o?Hr.any():Hr.never();let u=Zin(o,c),p=o.type||o.enum!==void 0||o.const!==void 0;if(o.anyOf&&Array.isArray(o.anyOf)){let v=o.anyOf.map(T=>$g(T,c)),_=Hr.union(v);u=p?Hr.intersection(u,_):_}if(o.oneOf&&Array.isArray(o.oneOf)){let v=o.oneOf.map(T=>$g(T,c)),_=Hr.xor(v);u=p?Hr.intersection(u,_):_}if(o.allOf&&Array.isArray(o.allOf))if(o.allOf.length===0)u=p?u:Hr.any();else{let v=p?u:$g(o.allOf[0],c),_=p?0:1;for(let T=_;T<o.allOf.length;T++)v=Hr.intersection(v,$g(o.allOf[T],c));u=v}o.nullable===!0&&c.version==="openapi-3.0"&&(u=Hr.nullable(u)),o.readOnly===!0&&(u=Hr.readonly(u));let f={},y=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(let v of y)v in o&&(f[v]=o[v]);let w=["contentEncoding","contentMediaType","contentSchema"];for(let v of w)v in o&&(f[v]=o[v]);for(let v of Object.keys(o))kGn.has(v)||(f[v]=o[v]);return Object.keys(f).length>0&&c.registry.add(u,f),u}function Xin(o,c){if(typeof o=="boolean")return o?Hr.any():Hr.never();let u=MGn(o,c?.defaultTarget),p=o.$defs||o.definitions||{},f={version:u,defs:p,refs:new Map,processing:new Set,rootSchema:o,registry:c?.registry??Dp};return $g(o,f)}var mft={};Qx(mft,{bigint:()=>IGn,boolean:()=>CGn,date:()=>EGn,number:()=>_Gn,string:()=>SGn});function SGn(o){return Hdt(Qq,o)}function _Gn(o){return Xdt(tG,o)}function CGn(o){return r1t(nG,o)}function IGn(o){return o1t(rG,o)}function EGn(o){return y1t(ite,o)}Mh(npe());var wft=["service","function","worker","agent","database","cache","vectordb","storage","model","dto","dataobject","queue","topic","stream","gateway","cdn","route","interface","adapter","port","llm","prompt","tool","auth","observability","cloud","frontend","external","human","page","component","store","hook","module","custom"],yge=ct.enum(wft),PGn=new Set(["service","function","worker","module","page","component","store","hook","model","dto","dataobject"]);function bge(o){return PGn.has(o)}var vft=["http_call","grpc","invokes","routes_to","websocket","webhook","reads","writes","publishes","subscribes","streams_to","implements","extends","depends_on","has_a","uses"],ute=ct.enum(vft),LGn={http_call:"runtime",grpc:"runtime",invokes:"runtime",routes_to:"runtime",websocket:"runtime",webhook:"runtime",reads:"runtime",writes:"runtime",publishes:"runtime",subscribes:"runtime",streams_to:"runtime",implements:"structural",extends:"structural",depends_on:"structural",has_a:"structural",uses:"structural"};function Kin(o){return LGn[o]}var E3=ct.enum(["proposed","active","deprecated"]),Yin=ct.enum(["boundary","control","entity"]),TGn=ct.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"}),AGn=/^[a-z][a-z0-9-]*$/,ba=ct.string().regex(AGn,"id must match /^[a-z][a-z0-9-]*$/"),kft=ct.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`"}),dte=ct.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`"}),NGn=ct.strictObject({name:ct.string().min(1),protocol:ct.string().min(1),description:ct.string().optional()}),RGn=ct.strictObject({id:ba,kind:yge,name:ct.string().min(1),description:ct.string().min(1).optional(),stack:ct.string().optional(),responsibilities:ct.array(ct.string().min(1)).optional(),interfaces:ct.array(NGn).optional(),notes:ct.array(ct.string()).optional(),parentId:ba.optional(),archikFile:kft.optional(),seqFiles:ct.array(dte).min(1).optional(),sourcePath:TGn.optional(),status:E3.optional(),stereotype:Yin.optional(),owner:ct.string().min(1).optional(),metadata:ct.record(ct.string(),ct.unknown()).optional()}),DGn=ct.strictObject({id:ba,from:ba,to:ba,relationship:ute,label:ct.string().optional(),description:ct.string().optional(),protocol:ct.string().optional(),color:ct.string().optional(),status:E3.optional(),fromFile:kft.optional(),toFile:kft.optional()}),iG=ct.strictObject({id:ba.optional(),kind:yge.optional(),parent:ba.optional(),notParent:ba.optional(),stereotype:Yin.optional()}).refine(o=>Object.values(o).some(c=>c!==void 0),{message:"selector must set at least one of id / kind / parent / notParent / stereotype"}),OGn=ct.strictObject({relationship:ute.optional(),from:iG.optional(),to:iG.optional()}).refine(o=>o.relationship!==void 0||o.from!==void 0||o.to!==void 0,{message:"forbidEdge must set at least one of relationship / from / to"}),FGn=ct.strictObject({kinds:ct.array(yge).min(1).optional()}),zGn=ct.strictObject({node:iG,to:iG.optional(),from:iG.optional(),relationship:ute.optional()}).refine(o=>o.to!==void 0!=(o.from!==void 0),{message:"requireEdge must set exactly one of `to` (outgoing) or `from` (incoming)"}),$Gn=ct.strictObject({node:iG,max:ct.number().int().min(0),relationship:ute.optional()}),jGn=ct.strictObject({id:ba,description:ct.string().min(1),forbidEdge:OGn.optional(),requireOwner:FGn.optional(),requireEdge:zGn.optional(),maxDependencies:$Gn.optional(),except:ct.array(ba).min(1).optional()}).superRefine((o,c)=>{[o.forbidEdge,o.requireOwner,o.requireEdge,o.maxDependencies].filter(p=>p!==void 0).length!==1&&c.addIssue({code:ct.ZodIssueCode.custom,message:`constraint "${o.id}" must define exactly one rule (forbidEdge, requireOwner, requireEdge, or maxDependencies)`})}),BGn=ct.strictObject({from:ct.string().min(1),at:ct.string().min(1),note:ct.string().optional()}),HGn=ct.strictObject({createdAt:ct.string().min(1).optional(),updatedAt:ct.string().min(1).optional(),suggestion:BGn.optional()}),Qin=ct.strictObject({version:ct.literal("1.0"),name:ct.string().min(1),description:ct.string().optional(),nodes:ct.array(RGn),edges:ct.array(DGn),constraints:ct.array(jGn).min(1).optional(),metadata:HGn.optional()}).superRefine((o,c)=>{let u=new Set;for(let v=0;v<o.nodes.length;v++){let _=o.nodes[v];u.has(_.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["nodes",v,"id"],message:`duplicate node id "${_.id}"`}),u.add(_.id),(_.description===void 0||_.description.length===0)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["nodes",v,"description"],message:`node "${_.id}" is missing required \`description\`. Every node must explain what it does (its responsibility / behaviour) \u2014 not just restate its kind or name.`})}let p=new Set;for(let v=0;v<o.edges.length;v++){let _=o.edges[v];p.has(_.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["edges",v,"id"],message:`duplicate edge id "${_.id}"`}),p.add(_.id),_.fromFile===void 0&&!u.has(_.from)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["edges",v,"from"],message:`edge "${_.id}" references unknown node "${_.from}"`}),_.toFile===void 0&&!u.has(_.to)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["edges",v,"to"],message:`edge "${_.id}" references unknown node "${_.to}"`}),_.fromFile!==void 0&&_.toFile!==void 0&&c.addIssue({code:ct.ZodIssueCode.custom,path:["edges",v],message:`edge "${_.id}" has both fromFile and toFile \u2014 at least one endpoint must be local to this file`}),_.from===_.to&&_.fromFile===void 0&&_.toFile===void 0&&c.addIssue({code:ct.ZodIssueCode.custom,path:["edges",v],message:`edge "${_.id}" is a self-loop (from === to). Self-loops aren't meaningful in an architecture diagram.`})}let f=new Map;for(let v of o.nodes)f.set(v.id,v.parentId);for(let v=0;v<o.nodes.length;v++){let _=o.nodes[v];if(_.parentId===void 0)continue;if(_.parentId===_.id){c.addIssue({code:ct.ZodIssueCode.custom,path:["nodes",v,"parentId"],message:`node "${_.id}" lists itself as parentId`});continue}if(!u.has(_.parentId)){c.addIssue({code:ct.ZodIssueCode.custom,path:["nodes",v,"parentId"],message:`node "${_.id}" parentId "${_.parentId}" doesn't match any node`});continue}let T=new Set([_.id]),R=_.parentId,F=0;for(;R!==void 0&&F<=o.nodes.length;){if(T.has(R)){c.addIssue({code:ct.ZodIssueCode.custom,path:["nodes",v,"parentId"],message:`node "${_.id}" is part of a parentId cycle (via "${R}")`});break}T.add(R),R=f.get(R),F++}}function y(v,_){let T=f.get(_),R=0;for(;T!==void 0&&R<=o.nodes.length;){if(T===v)return!0;T=f.get(T),R++}return!1}for(let v=0;v<o.edges.length;v++){let _=o.edges[v];_.fromFile!==void 0||_.toFile!==void 0||!u.has(_.from)||!u.has(_.to)||(y(_.from,_.to)||y(_.to,_.from))&&c.addIssue({code:ct.ZodIssueCode.custom,path:["edges",v],message:`edge "${_.id}" connects "${_.from}" and "${_.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 w=new Map;for(let v=0;v<o.edges.length;v++){let _=o.edges[v];if(_.fromFile!==void 0||_.toFile!==void 0)continue;let T=`${_.from}\0${_.to}\0${_.relationship}`,R=w.get(T);if(R!==void 0){c.addIssue({code:ct.ZodIssueCode.custom,path:["edges",v],message:`edge "${_.id}" duplicates "${R}" \u2014 same from/to/relationship (${_.from} \u2192 ${_.to} via ${_.relationship}). The diagram already expresses this connection; remove one of them.`});continue}w.set(T,_.id)}});function oG(o,c,u){let p=[],f=new Map;for(let y of o.nodes)y.sourcePath!==void 0&&y.sourcePath.length>0&&f.set(y.id,y.sourcePath);return o.nodes.forEach((y,w)=>{if(!bge(y.kind))return;let v=y.status==="proposed"||y.status==="deprecated";if(y.sourcePath===void 0||y.sourcePath.length===0){if(v)return;p.push({path:`nodes.${w}.sourcePath`,message:`node "${y.id}" (kind: ${y.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(!u(y.sourcePath)){p.push({path:`nodes.${w}.sourcePath`,message:`node "${y.id}" sourcePath "${y.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(y.parentId!==void 0){let _=f.get(y.parentId);_!==void 0&&UGn(_)&&!Mft(y.sourcePath,_)&&p.push({path:`nodes.${w}.sourcePath`,message:`node "${y.id}" sourcePath "${y.sourcePath}" is not inside its parent's sourcePath "${_}". The diagram says "${y.id}" lives inside "${y.parentId}", but the source tree disagrees. Either fix the path, change the parentId, or drop one of the sourcePaths.`})}}),p}function Mft(o,c){let u=o.replace(/\/+$/,""),p=c.replace(/\/+$/,"");return u===p?!0:u.startsWith(p+"/")}function UGn(o){let c=o.split("/").pop()??"";return!/\.[^./]+$/.test(c)}function cG(o,c){let u=[];return o.nodes.forEach((p,f)=>{p.archikFile!==void 0&&(c(p.archikFile)||u.push({path:`nodes.${f}.archikFile`,message:`archikFile "${p.archikFile}" does not exist (resolved relative to the project root)`}))}),o.edges.forEach((p,f)=>{p.fromFile!==void 0&&!c(p.fromFile)&&u.push({path:`edges.${f}.fromFile`,message:`fromFile "${p.fromFile}" does not exist (resolved relative to the project root)`}),p.toFile!==void 0&&!c(p.toFile)&&u.push({path:`edges.${f}.toFile`,message:`toFile "${p.toFile}" does not exist (resolved relative to the project root)`})}),u}function ton(o,c){let u=[];return o.nodes.forEach((p,f)=>{p.seqFiles&&p.seqFiles.forEach((y,w)=>{c(y)||u.push({path:`nodes.${f}.seqFiles.${w}`,message:`seqFile "${y}" does not exist on disk (resolved relative to the project root)`})})}),u}function eon(o){return o.length===0?"<root>":o.map(String).join(".")}function qGn(o,c){let u=o[o.length-1],p=/expected array/i.test(c)&&/received\s+string/i.test(c),f=/received\s+undefined/i.test(c)||/required/i.test(c);return p&&(u==="notes"||u==="responsibilities"||u==="interfaces")?`${String(u)} is an array \u2014 wrap your value, e.g. ${String(u)}: ['first', 'second']. Run \`npx archik schema\` for the full shape.`:f&&u==="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 GGn(o){return o.issues.flatMap(c=>{if(c.code==="unrecognized_keys")return c.keys.map(f=>({path:eon([...c.path,f]),message:"unrecognized key"}));let u=qGn(c.path,c.message),p=u===null?c.message:`${c.message}
|
|
516
516
|
hint: ${u}`;return[{path:eon(c.path),message:p}]})}function jg(o){let c=Qin.safeParse(o);return c.success?{ok:!0,value:c.data}:{ok:!1,errors:GGn(c.error)}}function Zu(o){return o.map(c=>` \u2022 ${c.path}: ${c.message}`).join(`
|
|
517
517
|
`)}import{readFile as VGn,readdir as WGn}from"node:fs/promises";import hte from"node:path";var xft=mi(kv(),1);function Xu(o){let c;try{c=xft.default.parse(o)}catch(p){let f=p instanceof Error?p.message:String(p);throw new Error(`Invalid YAML: ${f}`)}let u=jg(c);if(!u.ok)throw new Error(`Invalid Archik document:
|
|
518
|
-
${Zu(u.errors)}`);return u.value}function Sv(o){return xft.default.stringify(o,{indent:2,lineWidth:0})}var JGn=6;function Sft(o,c){return hte.relative(o,c).split(hte.sep).join("/")||hte.basename(c)}function ZGn(o){return o.endsWith(".archik.yaml")&&!o.endsWith(".archik.suggested.yaml")}async function ul(o,c){let u=[],p=[],f=new Set,y=async v=>{if(f.has(v))return;f.add(v);let _;try{_=await VGn(v,"utf-8")}catch(T){p.push({abs:v,relPath:Sft(c,v),message:T instanceof Error?T.message:String(T)});return}try{let T=Xu(_);u.push({abs:v,relPath:Sft(c,v),doc:T})}catch(T){p.push({abs:v,relPath:Sft(c,v),message:T instanceof Error?T.message:String(T)})}};await y(o);let w=async(v,_)=>{if(_>JGn)return;let T;try{T=await WGn(v,{withFileTypes:!0})}catch{return}for(let R of T){let F=hte.join(v,R.name);if(R.isDirectory()){await w(F,_+1);continue}R.isFile()&&ZGn(R.name)&&await y(F)}};return await w(hte.join(c,".archik"),0),{docs:u,errors:p}}var ion=mi(kv(),1);import{readFile as oVn,readdir as cVn}from"node:fs/promises";import pte from"node:path";var XGn=ct.enum(["sync","async","return","create","destroy"]),KGn=ct.enum(["over","left_of","right_of"]),YGn=ct.enum(["alt","opt","loop","par","break","ref"]),QGn=ct.strictObject({id:ba,nodeId:ba,label:ct.string().min(1).optional(),status:E3.optional()}),eVn=ct.strictObject({type:ct.literal("message"),id:ba,from:ba,to:ba,label:ct.string().min(1),arrow:XGn,activate:ct.boolean().optional(),status:E3.optional()}),tVn=ct.strictObject({type:ct.literal("note"),id:ba,position:KGn,participants:ct.array(ba).min(1),text:ct.string().min(1),status:E3.optional()}),nVn=ct.lazy(()=>ct.strictObject({label:ct.string().optional(),steps:ct.array(non)})),rVn=ct.lazy(()=>ct.strictObject({type:ct.literal("group"),id:ba,kind:YGn,condition:ct.string().optional(),label:ct.string().optional(),branches:ct.array(nVn).optional(),seqFile:dte.optional(),participants:ct.array(ba).optional(),status:E3.optional()})),non=ct.lazy(()=>ct.union([eVn,tVn,rVn]));function ron(o,c){let u=[];for(let p of o)if(c.has(p.id)?u.push(p.id):c.add(p.id),p.type==="group"&&p.branches)for(let f of p.branches)u.push(...ron(f.steps,c));return u}var iVn=ct.strictObject({useCase:ba,slice:ba}),fte=ct.strictObject({version:ct.literal("1.0"),name:ct.string().min(1),description:ct.string().optional(),realizes:iVn.optional(),participants:ct.array(QGn).min(1),steps:ct.array(non)}).superRefine((o,c)=>{let u=new Set;for(let y=0;y<o.participants.length;y++){let w=o.participants[y];u.has(w.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["participants",y,"id"],message:`duplicate participant id "${w.id}"`}),u.add(w.id)}let p=new Set,f=ron(o.steps,p);for(let y of f)c.addIssue({code:ct.ZodIssueCode.custom,path:["steps"],message:`duplicate step id "${y}"`})});var aVn=6;function sVn(o,c){return pte.relative(o,c).split(pte.sep).join("/")||pte.basename(c)}async function _v(o){let c=[],u=[],p=async y=>{let w=sVn(o,y),v;try{v=await oVn(y,"utf-8")}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)});return}try{let _=ion.default.parse(v),T=fte.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)})}},f=async(y,w)=>{if(w>aVn)return;let v;try{v=await cVn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=pte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&_.name.endsWith(".archik.seq.yaml")&&await p(T)}};return await f(pte.join(o,".archik"),0),{docs:c,errors:u}}var con=mi(kv(),1);import{readFile as bVn,readdir as mVn}from"node:fs/promises";import gte from"node:path";var lVn=ct.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"}),uVn=/^[a-z][a-z0-9-]*\.\d+$/,dVn=ct.string().regex(uVn,"branchFrom must be `<flowId>.<stepNumber>` (e.g. basic.3)"),hVn=ct.strictObject({steps:ct.array(ct.string().min(1)).min(1)}),fVn=ct.strictObject({id:ba,branchFrom:dVn,steps:ct.array(ct.string().min(1)).min(1)}),pVn=ct.strictObject({basic:hVn,alternates:ct.array(fVn).optional()}),gVn=ct.strictObject({seqFile:dte}),yVn=ct.strictObject({id:ba,description:ct.string().min(1),flows:ct.array(ba).min(1),tests:ct.array(lVn).optional(),realization:gVn.optional(),status:E3.optional()}),oon=ct.strictObject({version:ct.literal("1.0"),id:ba,name:ct.string().min(1),description:ct.string().optional(),status:E3.optional(),primaryActor:ba,secondaryActors:ct.array(ba).optional(),goal:ct.string().min(1),preconditions:ct.array(ct.string().min(1)).optional(),postconditions:ct.array(ct.string().min(1)).optional(),flows:pVn,slices:ct.array(yVn).min(1)}).superRefine((o,c)=>{let u=new Map;u.set("basic",o.flows.basic.steps.length);let p=new Set;o.flows.alternates&&(o.flows.alternates.forEach((y,w)=>{y.id==="basic"&&c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"id"],message:'alternate id "basic" collides with the basic flow'}),p.has(y.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"id"],message:`duplicate alternate flow id "${y.id}"`}),p.add(y.id),u.set(y.id,y.steps.length)}),o.flows.alternates.forEach((y,w)=>{let[v,_]=y.branchFrom.split("."),T=Number(_),R=u.get(v);if(R===void 0){c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"branchFrom"],message:`branchFrom "${y.branchFrom}" references unknown flow "${v}"`});return}(T<1||T>R)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"branchFrom"],message:`branchFrom "${y.branchFrom}" step ${T} is out of range (flow "${v}" has ${R} step(s))`})}));let f=new Set;o.slices.forEach((y,w)=>{f.has(y.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"id"],message:`duplicate slice id "${y.id}"`}),f.add(y.id),y.flows.forEach((_,T)=>{u.has(_)||c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"flows",T],message:`slice "${y.id}" references unknown flow "${_}". Available: ${Array.from(u.keys()).join(", ")}.`})}),y.flows.includes("basic")||c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"flows"],message:`slice "${y.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.`}),!(y.status==="proposed"||y.status==="deprecated")&&(y.tests===void 0||y.tests.length===0)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"tests"],message:`slice "${y.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 wVn=6;function vVn(o,c){return gte.relative(o,c).split(gte.sep).join("/")||gte.basename(c)}function kVn(o){return o.endsWith(".archik.uc.yaml")}async function Op(o){let c=[],u=[],p=async y=>{let w=vVn(o,y),v;try{v=await bVn(y,"utf-8")}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let _;try{_=con.default.parse(v)}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let T=oon.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})},f=async(y,w)=>{if(w>wVn)return;let v;try{v=await mVn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=gte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&kVn(_.name)&&await p(T)}};return await f(gte.join(o,".archik","usecases"),0),{docs:c,errors:u}}var son=mi(kv(),1);import{readFile as SVn,readdir as _Vn}from"node:fs/promises";import yte from"node:path";var MVn=ct.enum(["human","external-system","time","device"]),xVn=ct.strictObject({id:ba,kind:MVn,description:ct.string().min(1),goals:ct.array(ct.string().min(1)).optional(),status:E3.optional()}),aon=ct.strictObject({version:ct.literal("1.0"),description:ct.string().optional(),actors:ct.array(xVn).min(1)}).superRefine((o,c)=>{let u=new Set;o.actors.forEach((p,f)=>{u.has(p.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["actors",f,"id"],message:`duplicate actor id "${p.id}"`}),u.add(p.id)})});var CVn=6;function IVn(o,c){return yte.relative(o,c).split(yte.sep).join("/")||yte.basename(c)}function EVn(o){return o.endsWith(".archik.actors.yaml")}async function aS(o){let c=[],u=[],p=async y=>{let w=IVn(o,y),v;try{v=await SVn(y,"utf-8")}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let _;try{_=son.default.parse(v)}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let T=aon.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})},f=async(y,w)=>{if(w>CVn)return;let v;try{v=await _Vn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=yte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&EVn(_.name)&&await p(T)}};return await f(yte.join(o,".archik"),0),{docs:c,errors:u}}import{readFile as LVn,readdir as TVn}from"node:fs/promises";import bte from"node:path";var PVn=ct.strictObject({id:ba.optional(),from:ba,to:ba,label:ct.string().min(1),data:ct.strictObject({in:ct.unknown().optional(),out:ct.unknown().optional()}).optional(),status:ct.enum(["ok","error"]).default("ok")}),lon=ct.strictObject({version:ct.literal("1.0"),useCase:ba,slice:ba,seqFile:ct.string().min(1).optional(),recordedAt:ct.string().min(1),steps:ct.array(PVn).min(1)});var AVn=6;function NVn(o,c){return bte.relative(o,c).split(bte.sep).join("/")||bte.basename(c)}async function aG(o){let c=[],u=[],p=async y=>{let w=NVn(o,y),v;try{v=await LVn(y,"utf-8")}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)});return}try{let _=JSON.parse(v),T=lon.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)})}},f=async(y,w)=>{if(w>AVn)return;let v;try{v=await TVn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=bte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&_.name.endsWith(".archik.trace.json")&&await p(T)}};return await f(bte.join(o,".archik"),0),{docs:c,errors:u}}function RVn(o){let c=new Set,u=p=>{for(let f of p){let y=f;if(y.type==="message"&&y.id&&c.add(y.id),y.branches)for(let w of y.branches)u(w.steps)}};return u(o),c}function uon(o,c,u){let p=[],f=[],y=new Set;for(let{doc:w}of c)for(let v of w.slices)y.add(`${w.id}/${v.id}`);for(let{relPath:w,doc:v}of o){if(!y.has(`${v.useCase}/${v.slice}`)){p.push({path:w,message:`trace targets unknown use case / slice "${v.useCase}/${v.slice}"`});continue}if(v.seqFile===void 0)continue;let _=u.find(B=>B.relPath===v.seqFile||B.abs.endsWith("/"+v.seqFile));if(_===void 0){p.push({path:w,message:`trace seqFile "${v.seqFile}" is not a discovered sequence diagram`});continue}let T=RVn(_.doc.steps),R=new Set(_.doc.participants.map(B=>B.id)),F=new Set;for(let B of v.steps){B.id!==void 0&&(T.has(B.id)?F.add(B.id):p.push({path:w,message:`trace step id "${B.id}" is not a message id in ${v.seqFile}`}));for(let V of[B.from,B.to])R.has(V)||p.push({path:w,message:`trace step references "${V}", not a participant in ${v.seqFile}`})}for(let B of T)F.has(B)||f.push(`${w}: seq step "${B}" was not exercised by this run`)}return{errors:p,info:f}}function don(o,c,u,p){o.forEach((f,y)=>{let w=`${p}.${y}`;f.type==="message"?(c.has(f.from)||u.push({path:`${w}.from`,message:`participant "${f.from}" is not declared in participants`}),c.has(f.to)||u.push({path:`${w}.to`,message:`participant "${f.to}" is not declared in participants`})):f.type==="note"?f.participants.forEach((v,_)=>{c.has(v)||u.push({path:`${w}.participants.${_}`,message:`participant "${v}" is not declared in participants`})}):f.type==="group"&&f.branches&&f.branches.forEach((v,_)=>{don(v.steps,c,u,`${w}.branches.${_}.steps`)})})}function hon(o,c){let u=[],p=new Set;return o.participants.forEach((f,y)=>{p.add(f.id),c.has(f.nodeId)||u.push({path:`participants.${y}.nodeId`,message:`nodeId "${f.nodeId}" does not match any architecture node. Run \`npx archik q list\` to see available node ids.`})}),don(o.steps,p,u,"steps"),u}var DVn={boundary:new Set(["control"]),control:new Set(["boundary","control","entity"]),entity:new Set(["control","entity"])};function fon(o,c,u,p,f,y){o.forEach((w,v)=>{let _=`${f}.${v}`;if(w.type==="message"){let T=c.get(w.from),R=c.get(w.to);if(T===void 0||R===void 0)return;let F=DVn[T];F&&!F.has(R)&&y.push({path:`${u}:${_}`,message:`ECB violation in seq "${p}" message "${w.id}": ${T} \u2192 ${R} 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 w.type==="group"&&w.branches&&w.branches.forEach((T,R)=>{fon(T.steps,c,u,p,`${_}.branches.${R}.steps`,y)})})}function pon(o,c){let u=[],p=new Map;for(let{doc:f}of c)for(let y of f.nodes)y.stereotype!==void 0&&p.set(y.id,y.stereotype);for(let f of o){if(f.doc.realizes===void 0)continue;let y=new Map;for(let w of f.doc.participants){let v=p.get(w.nodeId);v!==void 0&&y.set(w.id,v)}fon(f.doc.steps,y,f.relPath,f.doc.name,"steps",u)}return u}function gon(o,c){let u=[],p=new Map;for(let{doc:f}of c)for(let y of f.nodes){let w=p.get(y.id)??new Set;for(let v of y.seqFiles??[])w.add(v);p.set(y.id,w)}for(let f of o){if(f.doc.realizes===void 0)continue;let y=new Set;for(let w of f.doc.participants){if(y.has(w.nodeId))continue;let v=p.get(w.nodeId);v!==void 0&&(v.has(f.relPath)||(y.add(w.nodeId),u.push({path:`${f.relPath}:participants.${w.id}`,message:`seq "${f.doc.name}" lists node "${w.nodeId}" as a participant, but that node's \`seqFiles\` array does not reference this diagram. Add "${f.relPath}" to node "${w.nodeId}"'s \`seqFiles\` array via \`npx archik suggest set\` so the canvas can surface the flow on that node.`})))}}return u}function yon(o,c){let u=[],p=new Map(c.map(f=>[f.doc.id,f]));for(let f of o){if(f.doc.realizes===void 0)continue;let{useCase:y,slice:w}=f.doc.realizes,v=p.get(y);if(v===void 0){u.push({path:`${f.relPath}:realizes.useCase`,message:`seq diagram "${f.doc.name}" claims to realize use case "${y}" but no such use case file was found.`});continue}let _=v.doc.slices.find(T=>T.id===w);if(_===void 0){u.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" claims to realize slice "${w}" of use case "${y}", but that use case has no slice with that id. Available slices: ${v.doc.slices.map(T=>T.id).join(", ")}.`});continue}if(_.realization===void 0){u.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" realizes slice "${w}" of "${y}", but the slice does not declare \`realization.seqFile\`. Add \`realization: { seqFile: "${f.relPath}" }\` to slice "${w}" in ${v.relPath}.`});continue}_.realization.seqFile!==f.relPath&&u.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" realizes slice "${w}" of "${y}", but that slice's realization.seqFile points at "${_.realization.seqFile}", not at this file ("${f.relPath}"). Pick one canonical seq file and update both sides.`})}return u}function bon(o){let c=new Map,u=[];for(let{relPath:p,doc:f}of o)for(let y of f.actors){let w=c.get(y.id);if(w!==void 0){u.push({path:p,message:`actor id "${y.id}" is duplicated across actor files (also defined in ${w.relPath})`});continue}c.set(y.id,{relPath:p})}return{index:c,errors:u}}function mon(o){let c=new Map,u=[];for(let{relPath:p,doc:f}of o){let y=c.get(f.id);if(y!==void 0){u.push({path:p,message:`use case id "${f.id}" is duplicated across files (also defined in ${y.relPath})`});continue}c.set(f.id,{relPath:p})}return{index:c,errors:u}}function won(o,c){let u=[];for(let{relPath:p,doc:f}of o)c.has(f.primaryActor)||u.push({path:`${p}:primaryActor`,message:`use case "${f.id}" references unknown primaryActor "${f.primaryActor}". Define it in a *.archik.actors.yaml file.`}),f.secondaryActors&&f.secondaryActors.forEach((y,w)=>{c.has(y)||u.push({path:`${p}:secondaryActors.${w}`,message:`use case "${f.id}" references unknown secondary actor "${y}". Define it in a *.archik.actors.yaml file.`})});return u}function von(o,c){let u=[];for(let{relPath:p,doc:f}of o)f.slices.forEach((y,w)=>{y.status==="proposed"||y.status==="deprecated"||y.tests!==void 0&&y.tests.forEach((_,T)=>{c(_)||u.push({path:`${p}:slices.${w}.tests.${T}`,message:`slice "${y.id}" test "${_}" does not exist on disk (resolved relative to project root). Either fix the path or mark the slice \`status: proposed\`.`})})});return u}function kon(o,c){let u=[],p=new Map(c.map(f=>[f.relPath,f]));for(let{relPath:f,doc:y}of o)y.slices.forEach((w,v)=>{if(w.realization===void 0)return;let _=p.get(w.realization.seqFile);if(_===void 0){u.push({path:`${f}:slices.${v}.realization.seqFile`,message:`slice "${w.id}" realization seqFile "${w.realization.seqFile}" does not exist or did not parse. Run \`npx archik q sequences\` to see available seq files.`});return}if(_.doc.realizes===void 0){u.push({path:`${f}:slices.${v}.realization.seqFile`,message:`slice "${w.id}" claims realization "${w.realization.seqFile}", but that seq diagram has no \`realizes\` block. Add \`realizes: { useCase: "${y.id}", slice: "${w.id}" }\` to ${_.relPath}, or remove the realization claim.`});return}(_.doc.realizes.useCase!==y.id||_.doc.realizes.slice!==w.id)&&u.push({path:`${f}:slices.${v}.realization.seqFile`,message:`slice "${w.id}" claims realization "${w.realization.seqFile}", but that seq diagram's \`realizes\` points at "${_.doc.realizes.useCase}/${_.doc.realizes.slice}", not at "${y.id}/${w.id}". Pick one canonical link.`})});return u}import mte from"node:path";function Cv(o){let c=mte.dirname(o),u=mte.basename(o),p=mte.extname(u),f=p.length>0?u.slice(0,-p.length):u;return mte.join(c,`${f}.suggested${p}`)}function sG(o){return mte.basename(o).endsWith(".archik.suggested.yaml")?"suggested":"normal"}function Mon(o){return o.metadata?.suggestion!==void 0}function mge(o){if(o.metadata?.suggestion===void 0)return o;let{suggestion:c,...u}=o.metadata,p={...o};return Object.keys(u).length===0?delete p.metadata:p.metadata=u,p}function OVn(o){let c=new Map;for(let p of o)c.set(p.id,p.parentId);let u=new Map;for(let p of o){let f=new Set,y=p.parentId,w=0;for(;y!==void 0&&w<=o.length&&!f.has(y);)f.add(y),y=c.get(y),w++;u.set(p.id,f)}return u}function lG(o,c,u){if(c.id!==void 0&&o.id!==c.id||c.kind!==void 0&&o.kind!==c.kind||c.stereotype!==void 0&&o.stereotype!==c.stereotype)return!1;let p=u.get(o.id)??new Set;return!(c.parent!==void 0&&!p.has(c.parent)||c.notParent!==void 0&&p.has(c.notParent))}function wge(o,c,u,p){let f=o.filter(y=>y.abs!==c);return f.push({abs:c,relPath:u,doc:p}),_ft(f)}function _ft(o){let c=[],u=o.flatMap(_=>_.doc.nodes),p=o.flatMap(_=>_.doc.edges.map(T=>({edge:T,relPath:_.relPath}))),f=new Map(u.map(_=>[_.id,_])),y=OVn(u),w=[],v=new Map;for(let _ of o)for(let T of _.doc.constraints??[]){let R=v.get(T.id);if(R!==void 0){c.push({path:`constraints.${T.id}`,message:`duplicate constraint id "${T.id}" (already defined in ${R})`});continue}v.set(T.id,_.relPath),w.push({constraint:T,relPath:_.relPath})}for(let{constraint:_}of w){let T=new Set(_.except??[]);if(_.forbidEdge!==void 0){let R=_.forbidEdge;for(let{edge:F,relPath:B}of p)if(!T.has(F.id)&&!(R.relationship!==void 0&&F.relationship!==R.relationship)){if(R.from!==void 0){let V=f.get(F.from);if(V===void 0||!lG(V,R.from,y))continue}if(R.to!==void 0){let V=f.get(F.to);if(V===void 0||!lG(V,R.to,y))continue}c.push({path:`constraints.${_.id}`,message:`edge "${F.id}" (${F.from} \u2192 ${F.to} via ${F.relationship}, in ${B}) violates constraint "${_.id}": ${_.description} \u2014 fix the edge, or add "${F.id}" to the constraint's \`except\` list with a reason in review.`})}}if(_.requireEdge!==void 0){let R=_.requireEdge;for(let F of u){if(T.has(F.id)||!lG(F,R.node,y)||p.some(({edge:se})=>{if(R.relationship!==void 0&&se.relationship!==R.relationship)return!1;if(R.to!==void 0){if(se.from!==F.id)return!1;let ce=f.get(se.to);return ce!==void 0&&lG(ce,R.to,y)}if(se.to!==F.id)return!1;let ee=f.get(se.from);return ee!==void 0&&lG(ee,R.from,y)}))continue;let V=R.to!==void 0?`an outgoing edge to a node matching ${JSON.stringify(R.to)}`:`an incoming edge from a node matching ${JSON.stringify(R.from)}`;c.push({path:`constraints.${_.id}`,message:`node "${F.id}" (kind: ${F.kind}) violates constraint "${_.id}": ${_.description} \u2014 it needs ${V}`+(R.relationship!==void 0?` (relationship: ${R.relationship})`:"")+`, or add "${F.id}" to the constraint's \`except\` list.`})}}if(_.maxDependencies!==void 0){let R=_.maxDependencies;for(let F of u){if(T.has(F.id)||!lG(F,R.node,y))continue;let B=p.filter(({edge:V})=>V.from===F.id&&(R.relationship===void 0||V.relationship===R.relationship));B.length<=R.max||c.push({path:`constraints.${_.id}`,message:`node "${F.id}" (kind: ${F.kind}) violates constraint "${_.id}": ${_.description} \u2014 ${B.length} outgoing ${R.relationship??""} edge(s), max is ${R.max} (${B.map(V=>V.edge.to).join(", ")}). Split the node, introduce a port/gateway, or add "${F.id}" to \`except\`.`})}}if(_.requireOwner!==void 0){let R=_.requireOwner.kinds;for(let F of u)T.has(F.id)||R!==void 0&&!R.includes(F.kind)||F.owner===void 0&&c.push({path:`constraints.${_.id}`,message:`node "${F.id}" (kind: ${F.kind}) violates constraint "${_.id}": ${_.description} \u2014 add \`owner: <team>\` to the node, or add "${F.id}" to the constraint's \`except\` list.`})}}return c}var CE={maxNodes:15,maxEdges:20,maxChildren:6,maxDegree:6,maxDepth:3};function FVn(o,c){let u=0,p=c.get(o);for(;p!==void 0&&u<=c.size;)u++,p=c.get(p);return u}function vge(o,c){let u=[];for(let{doc:f,relPath:y}of o){f.nodes.length>c.maxNodes&&u.push({kind:"file-nodes",subject:y,value:f.nodes.length,limit:c.maxNodes,suggestion:`split ${y} into sub-files via archikFile (${f.nodes.length} nodes; limit ${c.maxNodes})`}),f.edges.length>c.maxEdges&&u.push({kind:"file-edges",subject:y,value:f.edges.length,limit:c.maxEdges,suggestion:`split ${y} into sub-files via archikFile (${f.edges.length} edges; limit ${c.maxEdges})`});let w=new Map,v=new Map;for(let _ of f.nodes)v.set(_.id,_.parentId);for(let _ of f.nodes)_.parentId!==void 0&&w.set(_.parentId,(w.get(_.parentId)??0)+1);for(let[_,T]of w)T>c.maxChildren&&u.push({kind:"container-children",subject:_,value:T,limit:c.maxChildren,suggestion:`give container '${_}' its own archikFile \u2014 ${T} children, limit ${c.maxChildren}`});for(let _ of f.nodes){let T=FVn(_.id,v);T>c.maxDepth&&u.push({kind:"nesting-depth",subject:_.id,value:T,limit:c.maxDepth,suggestion:`flatten or split \u2014 '${_.id}' is ${T} levels deep, limit ${c.maxDepth}`})}}let p=new Map;for(let{doc:f}of o)for(let y of f.edges)p.set(y.from,(p.get(y.from)??0)+1),p.set(y.to,(p.get(y.to)??0)+1);for(let[f,y]of p)y>c.maxDegree&&u.push({kind:"node-degree",subject:f,value:y,limit:c.maxDegree,suggestion:`'${f}' has ${y} connections \u2014 name a bounded context or add a port/gateway (limit ${c.maxDegree})`});return u.sort((f,y)=>y.value-y.limit-(f.value-f.limit)),u}var jVn=o=>{let c=dn(o,"json");return c!==void 0&&c!=="false"&&c!=="0"};function Iv(o){console.log(JSON.stringify(o,null,2))}async function AR(o){let c=jVn(o),u;try{u=await cc(o._[0])}catch(nn){let cn=nn instanceof Error?nn.message:String(nn);return c?Iv({ok:!1,errors:[{path:"<root>",message:cn}]}):console.error(`\u2717 ${cn}`),1}let p=xon.relative(process.cwd(),u)||u,f;try{f=await $Vn(u,"utf-8")}catch(nn){let cn=nn instanceof Error?nn.message:String(nn);return c?Iv({ok:!1,file:p,errors:[{path:"<root>",message:cn}]}):(console.error(`\u2717 Cannot read ${p}`),console.error(cn)),1}let y;try{y=Son.default.parse(f)}catch(nn){let Nr=[{path:"<root>",message:`Invalid YAML: ${nn instanceof Error?nn.message:String(nn)}`}];return c?Iv({ok:!1,file:p,errors:Nr}):(console.error(`\u2717 ${p}`),console.error(Zu(Nr))),1}let w=jg(y);if(!w.ok)return c?Iv({ok:!1,file:p,errors:w.errors}):(console.error(`\u2717 ${p}`),console.error(Zu(w.errors))),1;let v=Ba(u),_=nn=>zVn(xon.resolve(v,nn)),T=cG(w.value,_);if(T.length>0)return c?Iv({ok:!1,file:p,errors:T}):(console.error(`\u2717 ${p}`),console.error(Zu(T))),1;let R=sG(u),F=oG(w.value,R,_);if(F.length>0)return c?Iv({ok:!1,file:p,errors:F}):(console.error(`\u2717 ${p}`),console.error(Zu(F))),1;let B=await ul(u,v);if(B.errors.length>0){if(c)Iv({ok:!1,file:p,errors:B.errors.map(nn=>({path:nn.relPath,message:nn.message}))});else for(let nn of B.errors)console.error(`\u2717 ${nn.relPath}: ${nn.message}`);return 1}let V=new Set(B.docs.flatMap(nn=>nn.doc.nodes.map(cn=>cn.id))),se=[];for(let{doc:nn}of B.docs)se.push(...ton(nn,_));if(se.length>0){if(c)Iv({ok:!1,file:p,errors:se});else{console.error("\u2717 seqFiles path errors:");for(let nn of se)console.error(` \u2717 ${nn.path}: ${nn.message}`)}return 1}let ee=await _v(v),ce=0;for(let nn of ee.errors)c||console.error(`\u2717 ${nn.relPath}: ${nn.message}`),ce++;for(let{relPath:nn,doc:cn}of ee.docs){let Nr=hon(cn,V);if(Nr.length>0){if(!c){console.error(`\u2717 ${nn}`);for(let oi of Nr)console.error(` \u2717 ${oi.path}: ${oi.message}`)}ce+=Nr.length}}if(ce>0)return c&&Iv({ok:!1,file:p,errors:[{path:"<seq>",message:`${ce} sequence diagram error(s)`}]}),1;let ge=await Op(v),Oe=await aS(v),ut=[];for(let nn of ge.errors)ut.push({path:nn.relPath,message:nn.message});for(let nn of Oe.errors)ut.push({path:nn.relPath,message:nn.message});if(ut.length===0){let nn=bon(Oe.docs);ut.push(...nn.errors);let cn=mon(ge.docs);ut.push(...cn.errors),ut.length===0&&(ut.push(...won(ge.docs,nn.index)),ut.push(...von(ge.docs,_)),ut.push(...kon(ge.docs,ee.docs)),ut.push(...yon(ee.docs,ge.docs)),ut.push(...pon(ee.docs,B.docs)),ut.push(...gon(ee.docs,B.docs)))}if(ut.length>0)return c?Iv({ok:!1,file:p,errors:ut}):(console.error(`\u2717 ${p}`),console.error(Zu(ut))),1;let Se=await aG(v),je=Se.errors.map(nn=>({path:nn.relPath,message:nn.message})),Be=[];if(je.length===0){let nn=uon(Se.docs,ge.docs,ee.docs);je.push(...nn.errors),Be=nn.info}if(je.length>0)return c?Iv({ok:!1,file:p,errors:je}):(console.error(`\u2717 ${p}`),console.error(Zu(je))),1;let tn=_ft(B.docs);if(tn.length>0)return c?Iv({ok:!1,file:p,errors:tn}):(console.error(`\u2717 ${p}`),console.error(Zu(tn))),1;let Gt=Oe.docs.reduce((nn,cn)=>nn+cn.doc.actors.length,0),xn=ge.docs.length,Vn=vge(B.docs,CE).length;if(c)Iv({ok:!0,file:p,nodes:w.value.nodes.length,edges:w.value.edges.length,useCases:xn,actors:Gt,complexityHints:Vn});else{let nn=B.docs.reduce((Pi,ue)=>Pi+ue.doc.nodes.length,0),cn=B.docs.reduce((Pi,ue)=>Pi+ue.doc.edges.length,0),Nr=B.docs.length,oi=Nr>1?` (${Nr} files)`:"",wo=xn>0?`, ${xn} use case${xn===1?"":"s"}`:"",Za=Gt>0?`, ${Gt} actor${Gt===1?"":"s"}`:"";console.log(`\u2713 ${p}${oi} \u2014 ${nn} nodes, ${cn} edges${wo}${Za}`),Vn>0&&console.log(`\u24D8 ${Vn} complexity hint${Vn===1?"":"s"} \u2014 run \`archik complexity\` to see them`);for(let Pi of Be)console.log(`\u24D8 ${Pi}`)}return 0}var w2t=mi(P3(),1),v2t=mi(Dye(),1),Gln=mi(kv(),1);import{mkdir as Hln,readFile as Uln,writeFile as qln}from"node:fs/promises";import OG from"node:path";var Rsn=mi(Lsn(),1);function cne(o,c){return o.length*c}function t0(o,c,u){if(c<=0)return"";let p=Math.floor(c/u);return o.length<=p?o:p<=1?"\u2026":o.slice(0,p-1)+"\u2026"}var ane={nodeSpacing:60,layerSpacing:100,padding:40,viewMode:"detailed"};function HXn(o){let c=o.nodeSpacing??ane.nodeSpacing,u=o.layerSpacing??ane.layerSpacing,p=o.padding??ane.padding;return{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.layered.spacing.nodeNodeBetweenLayers":String(u),"elk.spacing.nodeNode":String(c),"elk.padding":`[top=${p}, left=${p}, bottom=${p}, right=${p}]`,"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 ed={width:172,height:82},Tsn={width:172,height:90},UXn={service:ed,function:ed,worker:ed,agent:ed,database:{width:184,height:100},cache:Tsn,vectordb:ed,storage:ed,model:ed,dto:ed,dataobject:ed,queue:{width:188,height:80},topic:ed,stream:ed,gateway:ed,cdn:ed,route:ed,interface:ed,adapter:ed,port:ed,llm:ed,prompt:ed,tool:ed,auth:ed,observability:ed,cloud:{width:200,height:120},frontend:Tsn,page:ed,component:ed,store:ed,hook:ed,external:{width:184,height:100},human:{width:184,height:100},module:{width:240,height:130},custom:{width:240,height:130}},dl={width:152,height:36},Asn={width:200,height:80},qXn={service:dl,function:dl,worker:dl,agent:dl,database:dl,cache:dl,vectordb:dl,storage:dl,model:dl,dto:dl,dataobject:dl,queue:{width:168,height:36},topic:dl,stream:dl,gateway:dl,cdn:dl,route:dl,interface:dl,adapter:dl,port:dl,llm:dl,prompt:dl,tool:dl,auth:dl,observability:dl,cloud:dl,frontend:dl,page:dl,component:dl,store:dl,hook:dl,external:{width:168,height:40},human:{width:168,height:40},module:Asn,custom:Asn},GXn=24,Nsn=320;function VXn(o,c,u){if(o.kind==="module"||o.kind==="custom")return c;if(u==="compact"){let v=36+cne(o.name,5.9)+12;return Math.max(c,Math.min(Nsn,Math.ceil(v)))}let p=cne(o.name,7.4),f=o.stack!==void 0?cne(o.stack,5.9):0,y=Math.max(p,f)+GXn;return Math.max(c,Math.min(Nsn,Math.ceil(y)))}var WXn={top:48,left:18,bottom:18,right:18};function JXn(o,c,u,p){let f=u[o.kind],y={id:o.id,width:VXn(o,f.width,p),height:f.height};if(c.length>0){y.children=c;let w=p==="compact"?{top:30,left:12,bottom:12,right:12}:WXn;y.layoutOptions={"elk.padding":`[top=${w.top}, left=${w.left}, bottom=${w.bottom}, right=${w.right}]`}}return y}function ZXn(o,c,u){let p=new Map;for(let v of o.nodes)p.set(v.id,v);let f=new Map;for(let v of o.nodes){let _=f.get(v.parentId)??[];_.push(v),f.set(v.parentId,_)}function y(v){let _=(f.get(v.id)??[]).map(y);return JXn(v,_,c,u)}return{roots:(f.get(void 0)??[]).map(y),byId:p}}function XXn(o){return o.fromFile===void 0&&o.toFile===void 0}function KXn(o){return o.edges.filter(XXn).map(c=>{let u={id:c.id,sources:[c.from],targets:[c.to]};return c.label!==void 0&&c.label.length>0&&(u.labels=[{text:c.label,width:Math.ceil(cne(c.label,5.9)),height:14}]),u})}function Gm(o){return o??0}function Dsn(o,c){let u=c.get(o.id);if(!u)throw new Error(`ELK returned unknown node id "${o.id}"`);let p=(o.children??[]).map(f=>Dsn(f,c));return{...u,x:Gm(o.x),y:Gm(o.y),width:Gm(o.width),height:Gm(o.height),children:p}}function YXn(o,c){let u=new Map,p=new Map,f=(T,R,F,B)=>{let V=R+Gm(T.x),se=F+Gm(T.y);u.set(T.id,{x:V,y:se}),p.set(T.id,B);let ee=[...B,T.id];for(let ce of T.children??[])f(ce,V,se,ee)};f(o,0,0,[]);let y=(T,R)=>{let F=p.get(T)??[],B=p.get(R)??[],V=0;for(;V<F.length&&V<B.length&&F[V]===B[V];)V++;let se=V===0?o.id:F[V-1];return u.get(se)??{x:0,y:0}},w=new Map,v=new Map,_=T=>{for(let R of T.edges??[]){let F=R.sources?.[0]??"",B=R.targets?.[0]??"",V=y(F,B),se=ge=>({x:Gm(ge.x)+V.x,y:Gm(ge.y)+V.y}),ee=(R.sections??[]).map(ge=>({startPoint:se(ge.startPoint),endPoint:se(ge.endPoint),bendPoints:(ge.bendPoints??[]).map(se)}));w.set(R.id,ee);let ce=(R.labels??[]).map(ge=>({text:typeof ge.text=="string"?ge.text:"",x:Gm(ge.x)+V.x,y:Gm(ge.y)+V.y,width:Gm(ge.width),height:Gm(ge.height)}));v.set(R.id,ce)}for(let R of T.children??[])_(R)};return _(o),c.edges.map(T=>({...T,sections:w.get(T.id)??[],labels:v.get(T.id)??[]}))}var QXn=new Rsn.default;async function eKn(o,c={}){if(o.nodes.length===0)return{document:o,width:0,height:0,roots:[],edges:[]};let u=c.viewMode==="compact"?"compact":"detailed",p=u==="compact"?qXn:UXn,{roots:f,byId:y}=ZXn(o,p,u),w={id:"__root__",layoutOptions:HXn(c),children:f,edges:KXn(o)},v=await QXn.layout(w),_=(v.children??[]).map(T=>Dsn(T,y));return{document:o,width:Gm(v.width),height:Gm(v.height),roots:_,edges:YXn(v,o)}}var Oye={name:"elk",layout:eKn};var Ili={[Oye.name]:Oye},tKn=Oye;function TG(o,c){return tKn.layout(o,c)}function Osn(o,c,u){let p=new Map,f=(v,_)=>{let T=p.get(v)??new Set;T.add(_),p.set(v,T)};for(let v of o)f(v.from,v.to),f(v.to,v.from);let y=new Set([c]),w=new Set([c]);for(let v=0;v<u;v++){let _=new Set;for(let T of w)for(let R of p.get(T)??[])y.has(R)||(y.add(R),_.add(R));if(_.size===0)break;w=_}return y}function Fsn(o,c,u){let p=o.flatMap(v=>v.doc.edges),f=Osn(p,c,u),y=[],w=[];for(let{doc:v,relPath:_}of o){for(let T of v.nodes)f.has(T.id)&&y.push({node:T,relPath:_});for(let T of v.edges)f.has(T.from)&&f.has(T.to)&&w.push({edge:T,relPath:_})}return{nodes:y,edges:w}}function zsn(o,c,u){let p=Osn(o.edges,c,u);return{...o,nodes:o.nodes.filter(f=>p.has(f.id)).map(f=>f.parentId!==void 0&&!p.has(f.parentId)?(({parentId:y,...w})=>w)(f):f),edges:o.edges.filter(f=>p.has(f.from)&&p.has(f.to))}}function $sn(o,c){let u=new Set(c.hideRel??[]),p=c.onlyRel?new Set(c.onlyRel):null,f=o.edges.filter(y=>!(p&&!p.has(y.relationship)||u.has(y.relationship)||c.hideStructural&&Kin(y.relationship)==="structural"));return{...o,edges:f}}function nKn(o){return Math.max(160,o.length*8+80)}function jsn(o,c,u,p,f,y=0){let w=u,v=[],_=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY;for(let R of o)if(R.type==="message"){let F=c.get(R.from),B=c.get(R.to),V=F?.cx??p,se=B?.cx??p;v.push({type:"message",id:R.id,fromCx:V,toCx:se,y:w,label:R.label,arrow:R.arrow,activate:R.activate??!1,isSelf:R.from===R.to,...R.status!==void 0?{status:R.status}:{}}),w+=R.from===R.to?56*1.5:56}else if(R.type==="note"){let F=R.participants.map(ce=>c.get(ce)?.cx).filter(ce=>ce!==void 0).sort((ce,ge)=>ce-ge),B=F[0]??p,V=F[F.length-1]??f,se=Math.min(Math.max(R.text.length*7.5+24,V-B+16,80),400),ee;R.position==="left_of"?ee=B-se-8:R.position==="right_of"?ee=V+8:ee=(B+V)/2-se/2,_=Math.min(_,ee),T=Math.max(T,ee+se),v.push({type:"note",id:R.id,x:ee,y:w,width:se,height:64,text:R.text,...R.status!==void 0?{status:R.status}:{}}),w+=72}else if(R.type==="group"){let F=Math.min(y*6,12),B=p-12+F,V=f-p+24-F*2,se=w;w+=24;let ee=[];if(R.branches)for(let ce=0;ce<R.branches.length;ce++){let ge=R.branches[ce],Oe=w,{items:ut,endY:Se,contentMinX:je,contentMaxX:Be}=jsn(ge.steps,c,w,p,f,y+1);w=Se,_=Math.min(_,je),T=Math.max(T,Be),ee.push({...ge.label!==void 0?{label:ge.label}:{},startY:Oe,...ce<R.branches.length-1?{dividerY:w}:{},steps:ut}),ce<R.branches.length-1&&(w+=4)}w+=12,v.push({type:"group",id:R.id,kind:R.kind,...R.condition!==void 0?{condition:R.condition}:{},...R.label!==void 0?{label:R.label}:{},...R.seqFile!==void 0?{seqFile:R.seqFile}:{},x:B,y:se,width:V,height:w-se,branches:ee,...R.status!==void 0?{status:R.status}:{}}),_=Math.min(_,B),T=Math.max(T,B+V),w+=20}return{items:v,endY:w,contentMinX:_,contentMaxX:T}}function Bsn(o){let c=new Map;for(let u of o)if(u.type==="message"&&u.arrow==="destroy"&&c.set(u.toCx,u.y+56+20),u.type==="group")for(let p of u.branches)for(let[f,y]of Bsn(p.steps))c.set(f,y);return c}function rKn(o){let c=[],u=new Map;function p(f){for(let y of f)if(y.type==="message"){if(y.activate&&y.arrow==="sync"&&!y.isSelf){let w=u.get(y.toCx)??[];w.push(y.y),u.set(y.toCx,w)}if(y.arrow==="return"&&!y.isSelf){let w=u.get(y.fromCx);if(w&&w.length>0){let v=w.pop();c.push({cx:y.fromCx,startY:v,endY:y.y}),w.length===0&&u.delete(y.fromCx)}}}else if(y.type==="group")for(let w of y.branches)p(w.steps)}p(o);for(let[f,y]of u)for(let w of y)c.push({cx:f,startY:w,endY:w+56/2});return c}function Hsn(o,c){let u=o.participants.map(tn=>nKn(tn.label??tn.nodeId)),p=32,f=o.participants.map((tn,Gt)=>{let xn=u[Gt],Vn=p+xn/2;p+=xn;let nn=c?.get(tn.nodeId);return{id:tn.id,nodeId:tn.nodeId,label:tn.label??tn.nodeId,cx:Vn,colWidth:xn,...nn!==void 0?{kind:nn}:{},...tn.status!==void 0?{status:tn.status}:{},lifelineEndY:0}}),y=p+32,w=new Map(f.map(tn=>[tn.id,tn])),v=f[0]?.cx??32,_=f[f.length-1]?.cx??y-32,T=24,{items:R,endY:F,contentMinX:B,contentMaxX:V}=jsn(o.steps,w,T,v,_),se=B<32&&Number.isFinite(B)?32-B:0,ee=Number.isFinite(V)?V+se+32:0,ce=Math.max(y+se,ee),ge=se>0?R.map(tn=>Usn(tn,se)):R,Oe=se>0?f.map(tn=>({...tn,cx:tn.cx+se})):f,ut=Bsn(ge),Se=Oe.map(tn=>({...tn,lifelineEndY:ut.get(tn.cx)??56+F+24})),je=56+F+24,Be=rKn(ge);return{participants:Se,steps:ge,activations:Be,totalWidth:ce,totalHeight:je}}function Usn(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(u=>({...u,steps:u.steps.map(p=>Usn(p,c))}))}}var ci=mi(s2t(),1);var D3=mi(hc(),1),Ysn=(o,c,u)=>({width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:c,strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round"});function Qsn({size:o=16,color:c="currentColor",strokeWidth:u=1.8}){return(0,D3.jsxs)("svg",{...Ysn(o,c,u),"aria-hidden":"true",children:[(0,D3.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3.5",ry:"3.5"}),(0,D3.jsx)("line",{x1:"9",y1:"9",x2:"9",y2:"13"}),(0,D3.jsx)("line",{x1:"15",y1:"9",x2:"15",y2:"13"}),(0,D3.jsx)("circle",{cx:"12",cy:"16.5",r:"1",fill:c,stroke:"none"})]})}function eln({size:o=16,color:c="currentColor",strokeWidth:u=1.8}){return(0,D3.jsxs)("svg",{...Ysn(o,c,u),"aria-hidden":"true",children:[(0,D3.jsx)("path",{d:"M 7.5 6 L 3.5 12 L 7.5 18"}),(0,D3.jsx)("path",{d:"M 16.5 6 L 20.5 12 L 16.5 18"}),(0,D3.jsx)("circle",{cx:"13",cy:"8.6",r:"0.9",fill:c,stroke:"none"}),(0,D3.jsx)("line",{x1:"13",y1:"11",x2:"11",y2:"16.5"})]})}var Vm={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.)."},model:{color:"#2dd4bf",icon:ci.Shapes,description:"Domain model \u2014 rich business object with behavior."},dto:{color:"#4ade80",icon:ci.FileJson2,description:"Data transfer object \u2014 shape crossing a boundary."},dataobject:{color:"#86efac",icon:ci.Braces,description:"Plain data structure / record, no behavior."},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:eln,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:Qsn,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 Kz=mi(hc(),1),WOe=36,z6r=128,$6r=7,tln=20,nln=24;function rln({participant:o,nodeKind:c}){let u=c?Vm[c]:void 0,p=u?.color??"var(--archik-fg-muted)",f=(56-WOe)/2,y=u?.icon,w=Math.max(z6r,o.label.length*$6r+nln+(y?tln:0)),v=w/2,_=y?v+tln/2:v,T=o.status,R=T==="proposed"?.55:T==="deprecated"?.35:1,F=T==="proposed"||T==="deprecated"?"4 3":void 0;return(0,Kz.jsxs)("g",{transform:`translate(${o.cx-v}, ${f})`,opacity:R,children:[(0,Kz.jsx)("rect",{width:w,height:WOe,rx:8,fill:"var(--archik-node-fill)",stroke:p,strokeWidth:1.4,...F!==void 0?{strokeDasharray:F}:{}}),y&&(0,Kz.jsx)("g",{transform:`translate(${nln/2}, ${(WOe-14)/2})`,children:(0,Kz.jsx)(y,{size:14,color:p,strokeWidth:1.5})}),(0,Kz.jsx)("text",{x:_,y:WOe/2+4,textAnchor:"middle",fontSize:12,fontWeight:500,fill:"var(--archik-fg)",fontFamily:"inherit",children:o.label})]})}var oln=mi(hc(),1);function iln({participant:o}){let c=o.status,u=c==="proposed"?.35:c==="deprecated"?.25:.6;return(0,oln.jsx)("line",{x1:o.cx,y1:56,x2:o.cx,y2:o.lifelineEndY,stroke:"var(--archik-fg-muted)",strokeWidth:1.2,strokeDasharray:"6 5",opacity:u})}function u2t(o,c){let u=o.x-c.x,p=o.y-c.y,f=Math.hypot(u,p);if(f<.01)return null;let y=u/f,w=p/f;return{ux:y,uy:w,px:-w,py:y,len:f}}var n0=o=>String(Math.round(o*100)/100);function AG(o,c,u=10,p=4){let f=u2t(o,c);if(!f)return"";let y=o.x-f.ux*u,w=o.y-f.uy*u;return`M ${n0(y+f.px*p)} ${n0(w+f.py*p)} L ${n0(o.x)} ${n0(o.y)} L ${n0(y-f.px*p)} ${n0(w-f.py*p)} Z`}function JOe(o,c,u=10,p=4.5){let f=u2t(o,c);if(!f)return"";let y=o.x-f.ux*u,w=o.y-f.uy*u;return`M ${n0(y+f.px*p)} ${n0(w+f.py*p)} L ${n0(o.x)} ${n0(o.y)} L ${n0(y-f.px*p)} ${n0(w-f.py*p)}`}function cln(o,c,u=14,p=6){return AG(o,c,u,p)}function aln(o,c,u=14,p=4.5){let f=u2t(c,o);if(!f)return"";let y=o.x+f.ux*(u/2),w=o.y+f.uy*(u/2),v=o.x+f.ux*u,_=o.y+f.uy*u;return`M ${n0(o.x)} ${n0(o.y)} L ${n0(y+f.px*p)} ${n0(w+f.py*p)} L ${n0(v)} ${n0(_)} L ${n0(y-f.px*p)} ${n0(w-f.py*p)} Z`}var Rv=mi(hc(),1),ZOe=32,lne=20,j6r=-6,XOe="var(--archik-edge-filled)";function sln({msg:o}){let c=o.arrow==="return",u=o.arrow==="async",p=o.arrow==="create",f=c||p,y=o.arrow==="destroy",w=c||u,v=o.status==="proposed"?.5:o.status==="deprecated"?.35:1,_=(B,V)=>w?(0,Rv.jsx)("path",{"data-archik-arrowhead":"end",d:JOe(B,V),fill:"none",stroke:XOe,strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"}):(0,Rv.jsx)("path",{"data-archik-arrowhead":"end",d:AG(B,V),fill:XOe});if(o.isSelf){let B=o.fromCx,V=o.y,se=`M ${B} ${V} L ${B+ZOe} ${V} L ${B+ZOe} ${V+lne} L ${B} ${V+lne}`;return(0,Rv.jsxs)("g",{opacity:v,children:[(0,Rv.jsx)("path",{d:se,fill:"none",stroke:XOe,strokeWidth:1.4}),_({x:B,y:V+lne},{x:B+ZOe,y:V+lne}),(0,Rv.jsx)("text",{x:B+ZOe+6,y:V+lne/2+4,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:o.label})]})}let R=o.fromCx<o.toCx?o.toCx-6:o.toCx+6,F=(o.fromCx+o.toCx)/2;return(0,Rv.jsxs)("g",{opacity:v,children:[(0,Rv.jsx)("line",{x1:o.fromCx,y1:o.y,x2:R,y2:o.y,stroke:XOe,strokeWidth:1.4,strokeDasharray:f?"4 4":void 0}),!y&&_({x:o.toCx,y:o.y},{x:o.fromCx,y:o.y}),(0,Rv.jsxs)("text",{x:F,y:o.y+j6r,textAnchor:"middle",fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:[p&&"\xABcreate\xBB ",o.label]}),o.arrow==="destroy"&&(0,Rv.jsxs)("g",{transform:`translate(${o.toCx-6}, ${o.y-6})`,children:[(0,Rv.jsx)("line",{x1:0,y1:0,x2:12,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5}),(0,Rv.jsx)("line",{x1:12,y1:0,x2:0,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5})]})]})}var Y9=mi(hc(),1),B6r={alt:"#6366f1",opt:"#0ea5e9",loop:"#10b981",par:"#f59e0b",break:"#ef4444",ref:"#8b5cf6"},lln=36,d2t=18;function uln({group:o,renderStep:c,onRefClick:u}){let p=B6r[o.kind]??"var(--archik-fg-muted)",f=o.status==="proposed"?.55:o.status==="deprecated"?.35:1,y=o.kind==="ref"&&o.seqFile!==void 0&&u!==void 0;return(0,Y9.jsxs)("g",{opacity:f,onClick:y?()=>u(o.seqFile):void 0,style:y?{cursor:"pointer"}:void 0,children:[(0,Y9.jsx)("rect",{x:o.x,y:o.y,width:o.width,height:o.height,rx:4,fill:"none",stroke:p,strokeWidth:1.2,opacity:.8}),(0,Y9.jsx)("rect",{x:o.x,y:o.y,width:lln,height:d2t,rx:4,fill:p,opacity:.8}),(0,Y9.jsx)("text",{x:o.x+6,y:o.y+d2t-5,fontSize:10,fontWeight:600,fill:"#fff",fontFamily:"inherit",children:o.kind}),(o.condition??o.label)&&(0,Y9.jsx)("text",{x:o.x+lln+6,y:o.y+d2t-5,fontSize:10,fill:p,fontFamily:"inherit",children:o.condition??o.label}),o.branches.map((w,v)=>(0,Y9.jsxs)("g",{children:[w.label&&(0,Y9.jsx)("text",{x:o.x+6,y:w.startY+12,fontSize:10,fill:p,fontFamily:"inherit",children:w.label}),w.steps.map(_=>c(_)),w.dividerY!==void 0&&(0,Y9.jsx)("line",{x1:o.x,y1:w.dividerY,x2:o.x+o.width,y2:w.dividerY,stroke:p,strokeWidth:1,strokeDasharray:"4 2",opacity:.65})]},v))]})}var NG=mi(hc(),1);function H6r(o,c){let u=Math.max(10,Math.floor(c/6.5));if(o.length<=u)return[o];let p=o.split(" "),f=[],y="";for(let w of p)(y+(y?" ":"")+w).length>u&&y?(f.push(y),y=w):y=y?y+" "+w:w;return y&&f.push(y),f.slice(0,3)}function dln({note:o}){let{x:c,y:u,width:p,height:f,text:y}=o,w=o.status==="proposed"?.55:o.status==="deprecated"?.35:1;return(0,NG.jsxs)("g",{opacity:w,children:[(0,NG.jsx)("path",{d:`M ${c} ${u} L ${c+p-10} ${u} L ${c+p} ${u+10} L ${c+p} ${u+f} L ${c} ${u+f} Z`,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),(0,NG.jsx)("path",{d:`M ${c+p-10} ${u} L ${c+p-10} ${u+10} L ${c+p} ${u+10}`,fill:"none",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),H6r(y,p-16).map((v,_)=>(0,NG.jsx)("text",{x:c+8,y:u+8+11+_*13,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:v},_))]})}var O3=mi(hc(),1);function fln({step:o,onRefClick:c}){return o.type==="message"?(0,O3.jsx)(sln,{msg:o}):o.type==="note"?(0,O3.jsx)(dln,{note:o}):o.type==="group"?(0,O3.jsx)(uln,{group:o,...c!==void 0?{onRefClick:c}:{},renderStep:u=>(0,O3.jsx)(fln,{step:u,...c!==void 0?{onRefClick:c}:{}},u.id)}):null}function pln({laid:o,svgRef:c,onRefClick:u}){let{participants:p,steps:f,activations:y,totalWidth:w,totalHeight:v}=o;return(0,O3.jsxs)("svg",{ref:c,width:w,height:v,viewBox:`0 0 ${w} ${v}`,xmlns:"http://www.w3.org/2000/svg",style:{fontFamily:"var(--archik-font, system-ui)"},children:[p.map(_=>(0,O3.jsx)(iln,{participant:_},_.id)),p.map(_=>(0,O3.jsx)(rln,{participant:_,..._.kind!==void 0?{nodeKind:_.kind}:{}},_.id)),(0,O3.jsxs)("g",{transform:`translate(0, ${56})`,children:[y.map(_=>(0,O3.jsx)("rect",{x:_.cx-8/2,y:_.startY,width:8,height:_.endY-_.startY,fill:"var(--archik-surface)",stroke:"var(--archik-fg-muted)",strokeWidth:1.2,rx:2},`${_.cx}-${_.startY}`)),f.map(_=>(0,O3.jsx)(fln,{step:_,...u!==void 0?{onRefClick:u}:{}},_.id))]})]})}var HE=mi(hc(),1),r0=28;function RG({kind:o,iconAt:c,labelAt:u}){let p=Vm[o],f=p.icon,y=14;return(0,HE.jsxs)(HE.Fragment,{children:[(0,HE.jsx)("g",{transform:`translate(${c.cx-y/2}, ${c.cy-y/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,HE.jsx)(f,{size:y,color:p.color,strokeWidth:1.8})}),(0,HE.jsx)("text",{x:u.cx,y:u.cy,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.toUpperCase()})]})}var UE=mi(hc(),1),U6r=24;function gln({node:o,selected:c}){let u=o.width,p=o.height,f=o.stack!==void 0,y=r0+(p-r0)/2,w=f?y-4:y+4,v=y+14,_=Math.max(0,u-U6r),T=t0(o.name,_,7.4),R=f?t0(o.stack,_,5.9):"";return(0,UE.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,UE.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,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,UE.jsx)("line",{x1:0,y1:r0,x2:u,y2:r0,stroke:"var(--archik-node-stroke)",strokeOpacity:.25,strokeWidth:1}),(0,UE.jsx)(RG,{kind:o.kind,iconAt:{cx:18,cy:r0/2},labelAt:{cx:u/2,cy:r0/2+3}}),(0,UE.jsx)("text",{x:u/2,y:w,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:T}),f&&(0,UE.jsx)("text",{x:u/2,y:v,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:R})]})}var qE=mi(hc(),1);function yln({node:o,selected:c}){let u=o.width,p=o.height,f=Math.min(p/2,28),y=o.stack!==void 0,w=r0+(p-r0)/2,v=y?w-4:w+4,_=w+14,T=Math.max(0,u-2*f-8),R=t0(o.name,T,7.4),F=y?t0(o.stack,T,5.9):"",B=c?"var(--archik-selected)":"var(--archik-node-stroke)";return(0,qE.jsxs)("g",{className:"archik-node archik-node--queue",children:[(0,qE.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,rx:f,ry:f,fill:"var(--archik-node-fill)",stroke:B,strokeWidth:c?1.8:1.4}),(0,qE.jsx)("line",{x1:f,y1:r0,x2:u-f,y2:r0,stroke:B,strokeOpacity:.25,strokeWidth:1}),(0,qE.jsx)(RG,{kind:"queue",iconAt:{cx:f+8,cy:r0/2},labelAt:{cx:u/2,cy:r0/2+3}}),(0,qE.jsx)("text",{x:u/2,y:v,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:R}),y&&(0,qE.jsx)("text",{x:u/2,y:_,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:F})]})}var GE=mi(hc(),1),q6r=24;function bln({node:o,selected:c}){let u=o.width,p=o.height,f=o.description!==void 0,y=r0,w=y+(p-y)/2,v=f?w-2:w+4,_=p-12,T=Math.max(0,u-q6r),R=t0(o.name,T,7.4),F=f?t0(o.description,T,5.9):"",B=c?"var(--archik-selected)":"var(--archik-node-stroke-soft)";return(0,GE.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,GE.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,rx:8,ry:8,fill:"var(--archik-node-fill-tinted)",stroke:B,strokeWidth:c?1.8:1.2,strokeDasharray:c?void 0:"6 4"}),(0,GE.jsx)("line",{x1:6,y1:r0,x2:u-6,y2:r0,stroke:B,strokeOpacity:.25,strokeWidth:1}),(0,GE.jsx)(RG,{kind:o.kind,iconAt:{cx:18,cy:r0/2},labelAt:{cx:u/2,cy:r0/2+3}}),(0,GE.jsx)("text",{x:u/2,y:v,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:R}),f&&(0,GE.jsx)("text",{x:u/2,y:_,textAnchor:"middle",fontSize:10,fill:"var(--archik-node-text-dim)",children:F})]})}var h6=mi(hc(),1),G6r=28,h2t=10,V6r=22;function mln({node:o,selected:c}){let u=o.width,p=o.height,f=u/2,y=h2t,w=Vm[o.kind],v=w.icon,_=c?"var(--archik-selected)":"var(--archik-node-stroke)",T=c?1.8:1.4,R=o.stack!==void 0,F=Math.max(0,u-G6r),B=t0(o.name,F,7.4),V=R?t0(o.stack,F,5.9):"",se=p,ee=se-V6r,ce=(ee+se)/2,ut=(y+8+ee)/2,Se=R?ut-4:ut+4,je=ut+14;return(0,h6.jsxs)("g",{className:"archik-node archik-node--database",children:[(0,h6.jsx)("path",{className:c?"archik-selected-glow":void 0,d:f2t(u,p,y),fill:"var(--archik-node-fill)",stroke:_,strokeWidth:T,strokeLinejoin:"round"}),(0,h6.jsx)("ellipse",{cx:f,cy:y,rx:u/2,ry:y,fill:"var(--archik-node-fill)",stroke:_,strokeWidth:T}),(0,h6.jsx)("text",{x:f,y:Se,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"var(--archik-node-text)",children:B}),R&&(0,h6.jsx)("text",{x:f,y:je,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:V}),(0,h6.jsx)("line",{x1:4,y1:ee,x2:u-4,y2:ee,stroke:_,strokeOpacity:.45,strokeWidth:1}),(0,h6.jsx)("g",{transform:`translate(14, ${ce-7})`,pointerEvents:"none","aria-hidden":"true",children:(0,h6.jsx)(v,{size:14,color:w.color,strokeWidth:1.9})}),(0,h6.jsx)("text",{x:f,y:ce+4,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()})]})}var W6r=10;function f2t(o,c,u){let p=W6r;return[`M 0 ${u}`,`L 0 ${c-p}`,`A ${p} ${p} 0 0 0 ${p} ${c}`,`L ${o-p} ${c}`,`A ${p} ${p} 0 0 0 ${o} ${c-p}`,`L ${o} ${u}`,`A ${o/2} ${u} 0 0 0 0 ${u}`,"Z"].join(" ")}var bS=mi(hc(),1),J6r=36,wln=18;function vln({node:o,selected:c}){let u=o.width,p=o.height,f=Vm[o.kind],y=f.icon,w=c?"var(--archik-selected)":"var(--archik-node-stroke)",v=c?1.8:1.4,_=o.stack!==void 0,T=Math.max(0,u-J6r),R=t0(o.name,T,7.4),F=_?t0(o.stack,T,5.9):"",B=u/2,V=p*.55,se=_?V-4:V+4,ee=V+14;return(0,bS.jsxs)("g",{className:"archik-node archik-node--cloud",children:[(0,bS.jsx)("path",{className:c?"archik-selected-glow":void 0,d:Z6r(u,p),fill:"var(--archik-node-fill)",stroke:w,strokeWidth:v,strokeLinejoin:"round"}),(0,bS.jsx)("g",{transform:`translate(18, ${wln-6})`,pointerEvents:"none","aria-hidden":"true",children:(0,bS.jsx)(y,{size:14,color:f.color,strokeWidth:1.9})}),(0,bS.jsx)("text",{x:B,y:wln+4,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()}),(0,bS.jsx)("text",{x:B,y:se,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:R}),_&&(0,bS.jsx)("text",{x:B,y:ee,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:F})]})}function Z6r(o,c){let p=c-2,f=c*.62,y=Math.min(c*.18,14),w=o-4,v=c*.5,_=Math.min(w*.15,v*.85),T=Math.min(w*.18,v),R=Math.min(w*.15,v*.85),F=2*(_+T+R),B=Math.max(0,w-F)/4,V=2,se=o-2,ee=V+B,ce=ee+2*_,ge=ce+B,Oe=ge+2*T,ut=Oe+B,Se=ut+2*R;return[`M ${V} ${p-y}`,`Q ${V} ${p} ${V+y} ${p}`,`L ${se-y} ${p}`,`Q ${se} ${p} ${se} ${p-y}`,`L ${se} ${f}`,`L ${Se} ${f}`,`A ${R} ${R} 0 0 0 ${ut} ${f}`,`L ${Oe} ${f}`,`A ${T} ${T} 0 0 0 ${ge} ${f}`,`L ${ce} ${f}`,`A ${_} ${_} 0 0 0 ${ee} ${f}`,`L ${V} ${f}`,"Z"].join(" ")}var hb=mi(hc(),1),DG=32,KOe=14,p2t=14;function kln({node:o,selected:c,depth:u=0}){let p=o.width,f=o.height;if(!(o.children.length>0))return(0,hb.jsx)(K6r,{node:o,selected:!!c});let w=Vm[o.kind],v=w.icon,_=Math.min(.04+u*.06,.22),T=Math.min(.55+u*.12,.95),R=c?"var(--archik-selected)":"var(--archik-container-border)",F=c?1.8:1.2,B=Math.max(0,p-KOe*2-60),V=t0(o.name,B,7.4);return(0,hb.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--container`,children:[(0,hb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:p,height:f,rx:8,ry:8,fill:w.color,fillOpacity:_,stroke:R,strokeWidth:F,pointerEvents:"none"}),u>=1&&p>8&&f>8&&(0,hb.jsx)("rect",{x:3,y:3,width:p-6,height:f-6,rx:6,ry:6,fill:"none",stroke:w.color,strokeOpacity:Math.min(.18+(u-1)*.06,.32),strokeWidth:1,pointerEvents:"none"}),(0,hb.jsx)("path",{d:X6r(p,DG,8),fill:w.color,fillOpacity:T*.18}),(0,hb.jsx)("line",{x1:0,y1:DG,x2:p,y2:DG,stroke:R,strokeOpacity:.45,strokeWidth:1}),(0,hb.jsx)("g",{transform:`translate(${KOe}, ${DG/2-p2t/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,hb.jsx)(v,{size:p2t,color:w.color,strokeWidth:1.9})}),(0,hb.jsx)("text",{x:KOe+p2t+8,y:DG/2+4,fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:V}),(0,hb.jsx)("text",{x:p-KOe,y:DG/2+3,textAnchor:"end",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()})]})}function X6r(o,c,u){return`M ${u} 0 H ${o-u} A ${u} ${u} 0 0 1 ${o} ${u} V ${c} H 0 V ${u} A ${u} ${u} 0 0 1 ${u} 0 Z`}function K6r({node:o,selected:c}){let u=o.width,p=o.height,f=Vm[o.kind],y=c?"var(--archik-selected)":"var(--archik-node-stroke-soft)";return(0,hb.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,hb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,rx:8,ry:8,fill:"var(--archik-node-fill-tinted)",stroke:y,strokeWidth:c?1.8:1.2,strokeDasharray:c?void 0:"5 4"}),(0,hb.jsx)("text",{x:u/2,y:p/2+4,textAnchor:"middle",fontSize:12,fontWeight:600,fill:f.color,children:o.name})]})}var fb=mi(hc(),1),une=24,Mln=10,g2t=28;function xln({node:o,selected:c,depth:u=0}){let p=o.width,f=o.height,y=Vm[o.kind],w=y.icon,v=o.kind==="external";if(o.children.length>0)return(0,fb.jsx)(Y6r,{node:o,selected:!!c,depth:u});let _=c?"var(--archik-selected)":v?"var(--archik-node-stroke-soft)":"var(--archik-node-stroke)",T=v?"var(--archik-node-fill-tinted)":"var(--archik-node-fill)",R=o.kind==="queue"?Math.min(f/2,18):8;return(0,fb.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--compact`,children:[(0,fb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:p,height:f,rx:R,ry:R,fill:T,stroke:_,strokeWidth:c?1.8:1.4,strokeDasharray:v&&!c?"5 4":void 0}),(0,fb.jsx)("g",{transform:`translate(${Mln}, ${f/2-7})`,pointerEvents:"none","aria-hidden":"true",children:(0,fb.jsx)(w,{size:13,color:y.color,strokeWidth:1.9})}),(0,fb.jsx)("text",{x:g2t,y:f/2+4,fontSize:12,fontWeight:600,fill:"var(--archik-node-text)",children:t0(o.name,Math.max(0,p-g2t-8),5.9)})]})}function Y6r({node:o,selected:c,depth:u}){let p=o.width,f=o.height,y=Vm[o.kind],w=y.icon,v=Math.min(.04+u*.035,.14),_=Math.min(.55+u*.08,.85),T=c?"var(--archik-selected)":"var(--archik-container-border)",R=Math.max(0,p-12-22),F=t0(o.name,R,5.9);return(0,fb.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--compact archik-node--container`,children:[(0,fb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:p,height:f,rx:6,ry:6,fill:y.color,fillOpacity:v,stroke:T,strokeWidth:c?1.8:1.2}),(0,fb.jsx)("path",{d:Q6r(p,une,6),fill:y.color,fillOpacity:_*.18}),(0,fb.jsx)("line",{x1:0,y1:une,x2:p,y2:une,stroke:T,strokeOpacity:.45,strokeWidth:1}),(0,fb.jsx)("g",{transform:`translate(${Mln}, ${une/2-6})`,pointerEvents:"none","aria-hidden":"true",children:(0,fb.jsx)(w,{size:12,color:y.color,strokeWidth:1.9})}),(0,fb.jsx)("text",{x:g2t,y:une/2+4,fontSize:12,fontWeight:600,fill:"var(--archik-node-text)",children:F})]})}function Q6r(o,c,u){return`M ${u} 0 H ${o-u} A ${u} ${u} 0 0 1 ${o} ${u} V ${c} H 0 V ${u} A ${u} ${u} 0 0 1 ${u} 0 Z`}var Q9=mi(s2t(),1),_d=mi(hc(),1),e8r=12,t8r=18;function Sln({Icon:o,cx:c,cy:u,size:p=e8r,color:f,strokeWidth:y=1.8}){return(0,_d.jsx)("g",{transform:`translate(${c-p/2}, ${u-p/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,_d.jsx)(o,{size:p,color:f??"var(--archik-fg-dim)",strokeWidth:y})})}function _ln(o){return(0,_d.jsx)(Sln,{Icon:Q9.Info,...o})}function Cln(o){return(0,_d.jsx)(Sln,{Icon:Q9.StickyNote,...o})}function Iln({cx:o,cy:c,filePath:u,fileLabel:p,onClick:f,size:y=13}){return(0,_d.jsxs)("g",{transform:`translate(${o-y/2}, ${c-y/2})`,style:{cursor:f?"pointer":"default"},onClick:f,children:[(0,_d.jsx)("title",{children:`Cross-file edge \u2192 ${p} (${u})`}),(0,_d.jsx)("circle",{cx:y/2,cy:y/2,r:y/2+.5,fill:"var(--archik-fg-dim)",fillOpacity:.12,stroke:"var(--archik-fg-dim)",strokeOpacity:.4,strokeWidth:1}),(0,_d.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,_d.jsx)(Q9.ArrowUpRight,{size:y-2,color:"var(--archik-fg-muted)",strokeWidth:2.2})})]})}function Eln({cx:o,cy:c,onClick:u,size:p=14}){return(0,_d.jsxs)("g",{transform:`translate(${o-p/2}, ${c-p/2})`,style:{cursor:u?"pointer":"default"},onClick:u,children:[(0,_d.jsx)("title",{children:"Open sub-architecture"}),(0,_d.jsx)("circle",{cx:p/2,cy:p/2,r:p/2+.5,fill:"var(--archik-accent)",fillOpacity:.16,stroke:"var(--archik-accent)",strokeOpacity:.45,strokeWidth:1}),(0,_d.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,_d.jsx)(Q9.ChevronDown,{size:p-2,color:"var(--archik-accent)",strokeWidth:2.2})})]})}function Pln({cx:o,cy:c,files:u,count:p,size:f=14}){let y=u.length===1?`Open sequence diagram \u2192 ${u[0].label} (${u[0].path})`:`${u.length} sequence diagrams on this node:
|
|
518
|
+
${Zu(u.errors)}`);return u.value}function Sv(o){return xft.default.stringify(o,{indent:2,lineWidth:0})}var JGn=6;function Sft(o,c){return hte.relative(o,c).split(hte.sep).join("/")||hte.basename(c)}function ZGn(o){return o.endsWith(".archik.yaml")&&!o.endsWith(".archik.suggested.yaml")}async function ul(o,c){let u=[],p=[],f=new Set,y=async v=>{if(f.has(v))return;f.add(v);let _;try{_=await VGn(v,"utf-8")}catch(T){p.push({abs:v,relPath:Sft(c,v),message:T instanceof Error?T.message:String(T)});return}try{let T=Xu(_);u.push({abs:v,relPath:Sft(c,v),doc:T})}catch(T){p.push({abs:v,relPath:Sft(c,v),message:T instanceof Error?T.message:String(T)})}};await y(o);let w=async(v,_)=>{if(_>JGn)return;let T;try{T=await WGn(v,{withFileTypes:!0})}catch{return}for(let R of T){let F=hte.join(v,R.name);if(R.isDirectory()){await w(F,_+1);continue}R.isFile()&&ZGn(R.name)&&await y(F)}};return await w(hte.join(c,".archik"),0),{docs:u,errors:p}}var ion=mi(kv(),1);import{readFile as oVn,readdir as cVn}from"node:fs/promises";import pte from"node:path";var XGn=ct.enum(["sync","async","return","create","destroy"]),KGn=ct.enum(["over","left_of","right_of"]),YGn=ct.enum(["alt","opt","loop","par","break","ref"]),QGn=ct.strictObject({id:ba,nodeId:ba,label:ct.string().min(1).optional(),status:E3.optional()}),eVn=ct.strictObject({type:ct.literal("message"),id:ba,from:ba,to:ba,label:ct.string().min(1),arrow:XGn,activate:ct.boolean().optional(),status:E3.optional()}),tVn=ct.strictObject({type:ct.literal("note"),id:ba,position:KGn,participants:ct.array(ba).min(1),text:ct.string().min(1),status:E3.optional()}),nVn=ct.lazy(()=>ct.strictObject({label:ct.string().optional(),steps:ct.array(non)})),rVn=ct.lazy(()=>ct.strictObject({type:ct.literal("group"),id:ba,kind:YGn,condition:ct.string().optional(),label:ct.string().optional(),branches:ct.array(nVn).optional(),seqFile:dte.optional(),participants:ct.array(ba).optional(),status:E3.optional()})),non=ct.lazy(()=>ct.union([eVn,tVn,rVn]));function ron(o,c){let u=[];for(let p of o)if(c.has(p.id)?u.push(p.id):c.add(p.id),p.type==="group"&&p.branches)for(let f of p.branches)u.push(...ron(f.steps,c));return u}var iVn=ct.strictObject({useCase:ba,slice:ba}),fte=ct.strictObject({version:ct.literal("1.0"),name:ct.string().min(1),description:ct.string().optional(),realizes:iVn.optional(),participants:ct.array(QGn).min(1),steps:ct.array(non)}).superRefine((o,c)=>{let u=new Set;for(let y=0;y<o.participants.length;y++){let w=o.participants[y];u.has(w.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["participants",y,"id"],message:`duplicate participant id "${w.id}"`}),u.add(w.id)}let p=new Set,f=ron(o.steps,p);for(let y of f)c.addIssue({code:ct.ZodIssueCode.custom,path:["steps"],message:`duplicate step id "${y}"`})});var aVn=6;function sVn(o,c){return pte.relative(o,c).split(pte.sep).join("/")||pte.basename(c)}async function _v(o){let c=[],u=[],p=async y=>{let w=sVn(o,y),v;try{v=await oVn(y,"utf-8")}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)});return}try{let _=ion.default.parse(v),T=fte.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)})}},f=async(y,w)=>{if(w>aVn)return;let v;try{v=await cVn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=pte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&_.name.endsWith(".archik.seq.yaml")&&await p(T)}};return await f(pte.join(o,".archik"),0),{docs:c,errors:u}}var con=mi(kv(),1);import{readFile as bVn,readdir as mVn}from"node:fs/promises";import gte from"node:path";var lVn=ct.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"}),uVn=/^[a-z][a-z0-9-]*\.\d+$/,dVn=ct.string().regex(uVn,"branchFrom must be `<flowId>.<stepNumber>` (e.g. basic.3)"),hVn=ct.strictObject({steps:ct.array(ct.string().min(1)).min(1)}),fVn=ct.strictObject({id:ba,branchFrom:dVn,steps:ct.array(ct.string().min(1)).min(1)}),pVn=ct.strictObject({basic:hVn,alternates:ct.array(fVn).optional()}),gVn=ct.strictObject({seqFile:dte}),yVn=ct.strictObject({id:ba,description:ct.string().min(1),flows:ct.array(ba).min(1),tests:ct.array(lVn).optional(),realization:gVn.optional(),status:E3.optional()}),oon=ct.strictObject({version:ct.literal("1.0"),id:ba,name:ct.string().min(1),description:ct.string().optional(),status:E3.optional(),primaryActor:ba,secondaryActors:ct.array(ba).optional(),goal:ct.string().min(1),preconditions:ct.array(ct.string().min(1)).optional(),postconditions:ct.array(ct.string().min(1)).optional(),flows:pVn,slices:ct.array(yVn).min(1)}).superRefine((o,c)=>{let u=new Map;u.set("basic",o.flows.basic.steps.length);let p=new Set;o.flows.alternates&&(o.flows.alternates.forEach((y,w)=>{y.id==="basic"&&c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"id"],message:'alternate id "basic" collides with the basic flow'}),p.has(y.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"id"],message:`duplicate alternate flow id "${y.id}"`}),p.add(y.id),u.set(y.id,y.steps.length)}),o.flows.alternates.forEach((y,w)=>{let[v,_]=y.branchFrom.split("."),T=Number(_),R=u.get(v);if(R===void 0){c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"branchFrom"],message:`branchFrom "${y.branchFrom}" references unknown flow "${v}"`});return}(T<1||T>R)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["flows","alternates",w,"branchFrom"],message:`branchFrom "${y.branchFrom}" step ${T} is out of range (flow "${v}" has ${R} step(s))`})}));let f=new Set;o.slices.forEach((y,w)=>{f.has(y.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"id"],message:`duplicate slice id "${y.id}"`}),f.add(y.id),y.flows.forEach((_,T)=>{u.has(_)||c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"flows",T],message:`slice "${y.id}" references unknown flow "${_}". Available: ${Array.from(u.keys()).join(", ")}.`})}),y.flows.includes("basic")||c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"flows"],message:`slice "${y.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.`}),!(y.status==="proposed"||y.status==="deprecated")&&(y.tests===void 0||y.tests.length===0)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["slices",w,"tests"],message:`slice "${y.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 wVn=6;function vVn(o,c){return gte.relative(o,c).split(gte.sep).join("/")||gte.basename(c)}function kVn(o){return o.endsWith(".archik.uc.yaml")}async function Op(o){let c=[],u=[],p=async y=>{let w=vVn(o,y),v;try{v=await bVn(y,"utf-8")}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let _;try{_=con.default.parse(v)}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let T=oon.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})},f=async(y,w)=>{if(w>wVn)return;let v;try{v=await mVn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=gte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&kVn(_.name)&&await p(T)}};return await f(gte.join(o,".archik","usecases"),0),{docs:c,errors:u}}var son=mi(kv(),1);import{readFile as SVn,readdir as _Vn}from"node:fs/promises";import yte from"node:path";var MVn=ct.enum(["human","external-system","time","device"]),xVn=ct.strictObject({id:ba,kind:MVn,description:ct.string().min(1),goals:ct.array(ct.string().min(1)).optional(),status:E3.optional()}),aon=ct.strictObject({version:ct.literal("1.0"),description:ct.string().optional(),actors:ct.array(xVn).min(1)}).superRefine((o,c)=>{let u=new Set;o.actors.forEach((p,f)=>{u.has(p.id)&&c.addIssue({code:ct.ZodIssueCode.custom,path:["actors",f,"id"],message:`duplicate actor id "${p.id}"`}),u.add(p.id)})});var CVn=6;function IVn(o,c){return yte.relative(o,c).split(yte.sep).join("/")||yte.basename(c)}function EVn(o){return o.endsWith(".archik.actors.yaml")}async function aS(o){let c=[],u=[],p=async y=>{let w=IVn(o,y),v;try{v=await SVn(y,"utf-8")}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let _;try{_=son.default.parse(v)}catch(R){u.push({abs:y,relPath:w,message:R instanceof Error?R.message:String(R)});return}let T=aon.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})},f=async(y,w)=>{if(w>CVn)return;let v;try{v=await _Vn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=yte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&EVn(_.name)&&await p(T)}};return await f(yte.join(o,".archik"),0),{docs:c,errors:u}}import{readFile as LVn,readdir as TVn}from"node:fs/promises";import bte from"node:path";var PVn=ct.strictObject({id:ba.optional(),from:ba,to:ba,label:ct.string().min(1),data:ct.strictObject({in:ct.unknown().optional(),out:ct.unknown().optional()}).optional(),status:ct.enum(["ok","error"]).default("ok")}),lon=ct.strictObject({version:ct.literal("1.0"),useCase:ba,slice:ba,seqFile:ct.string().min(1).optional(),recordedAt:ct.string().min(1),steps:ct.array(PVn).min(1)});var AVn=6;function NVn(o,c){return bte.relative(o,c).split(bte.sep).join("/")||bte.basename(c)}async function aG(o){let c=[],u=[],p=async y=>{let w=NVn(o,y),v;try{v=await LVn(y,"utf-8")}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)});return}try{let _=JSON.parse(v),T=lon.safeParse(_);if(!T.success){u.push({abs:y,relPath:w,message:T.error.issues.map(R=>R.message).join("; ")});return}c.push({abs:y,relPath:w,doc:T.data})}catch(_){u.push({abs:y,relPath:w,message:_ instanceof Error?_.message:String(_)})}},f=async(y,w)=>{if(w>AVn)return;let v;try{v=await TVn(y,{withFileTypes:!0})}catch{return}for(let _ of v){let T=bte.join(y,_.name);if(_.isDirectory()){await f(T,w+1);continue}_.isFile()&&_.name.endsWith(".archik.trace.json")&&await p(T)}};return await f(bte.join(o,".archik"),0),{docs:c,errors:u}}function RVn(o){let c=new Set,u=p=>{for(let f of p){let y=f;if(y.type==="message"&&y.id&&c.add(y.id),y.branches)for(let w of y.branches)u(w.steps)}};return u(o),c}function uon(o,c,u){let p=[],f=[],y=new Set;for(let{doc:w}of c)for(let v of w.slices)y.add(`${w.id}/${v.id}`);for(let{relPath:w,doc:v}of o){if(!y.has(`${v.useCase}/${v.slice}`)){p.push({path:w,message:`trace targets unknown use case / slice "${v.useCase}/${v.slice}"`});continue}if(v.seqFile===void 0)continue;let _=u.find(B=>B.relPath===v.seqFile||B.abs.endsWith("/"+v.seqFile));if(_===void 0){p.push({path:w,message:`trace seqFile "${v.seqFile}" is not a discovered sequence diagram`});continue}let T=RVn(_.doc.steps),R=new Set(_.doc.participants.map(B=>B.id)),F=new Set;for(let B of v.steps){B.id!==void 0&&(T.has(B.id)?F.add(B.id):p.push({path:w,message:`trace step id "${B.id}" is not a message id in ${v.seqFile}`}));for(let V of[B.from,B.to])R.has(V)||p.push({path:w,message:`trace step references "${V}", not a participant in ${v.seqFile}`})}for(let B of T)F.has(B)||f.push(`${w}: seq step "${B}" was not exercised by this run`)}return{errors:p,info:f}}function don(o,c,u,p){o.forEach((f,y)=>{let w=`${p}.${y}`;f.type==="message"?(c.has(f.from)||u.push({path:`${w}.from`,message:`participant "${f.from}" is not declared in participants`}),c.has(f.to)||u.push({path:`${w}.to`,message:`participant "${f.to}" is not declared in participants`})):f.type==="note"?f.participants.forEach((v,_)=>{c.has(v)||u.push({path:`${w}.participants.${_}`,message:`participant "${v}" is not declared in participants`})}):f.type==="group"&&f.branches&&f.branches.forEach((v,_)=>{don(v.steps,c,u,`${w}.branches.${_}.steps`)})})}function hon(o,c){let u=[],p=new Set;return o.participants.forEach((f,y)=>{p.add(f.id),c.has(f.nodeId)||u.push({path:`participants.${y}.nodeId`,message:`nodeId "${f.nodeId}" does not match any architecture node. Run \`npx archik q list\` to see available node ids.`})}),don(o.steps,p,u,"steps"),u}var DVn={boundary:new Set(["control"]),control:new Set(["boundary","control","entity"]),entity:new Set(["control","entity"])};function fon(o,c,u,p,f,y){o.forEach((w,v)=>{let _=`${f}.${v}`;if(w.type==="message"){let T=c.get(w.from),R=c.get(w.to);if(T===void 0||R===void 0)return;let F=DVn[T];F&&!F.has(R)&&y.push({path:`${u}:${_}`,message:`ECB violation in seq "${p}" message "${w.id}": ${T} \u2192 ${R} 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 w.type==="group"&&w.branches&&w.branches.forEach((T,R)=>{fon(T.steps,c,u,p,`${_}.branches.${R}.steps`,y)})})}function pon(o,c){let u=[],p=new Map;for(let{doc:f}of c)for(let y of f.nodes)y.stereotype!==void 0&&p.set(y.id,y.stereotype);for(let f of o){if(f.doc.realizes===void 0)continue;let y=new Map;for(let w of f.doc.participants){let v=p.get(w.nodeId);v!==void 0&&y.set(w.id,v)}fon(f.doc.steps,y,f.relPath,f.doc.name,"steps",u)}return u}function gon(o,c){let u=[],p=new Map;for(let{doc:f}of c)for(let y of f.nodes){let w=p.get(y.id)??new Set;for(let v of y.seqFiles??[])w.add(v);p.set(y.id,w)}for(let f of o){if(f.doc.realizes===void 0)continue;let y=new Set;for(let w of f.doc.participants){if(y.has(w.nodeId))continue;let v=p.get(w.nodeId);v!==void 0&&(v.has(f.relPath)||(y.add(w.nodeId),u.push({path:`${f.relPath}:participants.${w.id}`,message:`seq "${f.doc.name}" lists node "${w.nodeId}" as a participant, but that node's \`seqFiles\` array does not reference this diagram. Add "${f.relPath}" to node "${w.nodeId}"'s \`seqFiles\` array via \`npx archik suggest set\` so the canvas can surface the flow on that node.`})))}}return u}function yon(o,c){let u=[],p=new Map(c.map(f=>[f.doc.id,f]));for(let f of o){if(f.doc.realizes===void 0)continue;let{useCase:y,slice:w}=f.doc.realizes,v=p.get(y);if(v===void 0){u.push({path:`${f.relPath}:realizes.useCase`,message:`seq diagram "${f.doc.name}" claims to realize use case "${y}" but no such use case file was found.`});continue}let _=v.doc.slices.find(T=>T.id===w);if(_===void 0){u.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" claims to realize slice "${w}" of use case "${y}", but that use case has no slice with that id. Available slices: ${v.doc.slices.map(T=>T.id).join(", ")}.`});continue}if(_.realization===void 0){u.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" realizes slice "${w}" of "${y}", but the slice does not declare \`realization.seqFile\`. Add \`realization: { seqFile: "${f.relPath}" }\` to slice "${w}" in ${v.relPath}.`});continue}_.realization.seqFile!==f.relPath&&u.push({path:`${f.relPath}:realizes.slice`,message:`seq diagram "${f.doc.name}" realizes slice "${w}" of "${y}", but that slice's realization.seqFile points at "${_.realization.seqFile}", not at this file ("${f.relPath}"). Pick one canonical seq file and update both sides.`})}return u}function bon(o){let c=new Map,u=[];for(let{relPath:p,doc:f}of o)for(let y of f.actors){let w=c.get(y.id);if(w!==void 0){u.push({path:p,message:`actor id "${y.id}" is duplicated across actor files (also defined in ${w.relPath})`});continue}c.set(y.id,{relPath:p})}return{index:c,errors:u}}function mon(o){let c=new Map,u=[];for(let{relPath:p,doc:f}of o){let y=c.get(f.id);if(y!==void 0){u.push({path:p,message:`use case id "${f.id}" is duplicated across files (also defined in ${y.relPath})`});continue}c.set(f.id,{relPath:p})}return{index:c,errors:u}}function won(o,c){let u=[];for(let{relPath:p,doc:f}of o)c.has(f.primaryActor)||u.push({path:`${p}:primaryActor`,message:`use case "${f.id}" references unknown primaryActor "${f.primaryActor}". Define it in a *.archik.actors.yaml file.`}),f.secondaryActors&&f.secondaryActors.forEach((y,w)=>{c.has(y)||u.push({path:`${p}:secondaryActors.${w}`,message:`use case "${f.id}" references unknown secondary actor "${y}". Define it in a *.archik.actors.yaml file.`})});return u}function von(o,c){let u=[];for(let{relPath:p,doc:f}of o)f.slices.forEach((y,w)=>{y.status==="proposed"||y.status==="deprecated"||y.tests!==void 0&&y.tests.forEach((_,T)=>{c(_)||u.push({path:`${p}:slices.${w}.tests.${T}`,message:`slice "${y.id}" test "${_}" does not exist on disk (resolved relative to project root). Either fix the path or mark the slice \`status: proposed\`.`})})});return u}function kon(o,c){let u=[],p=new Map(c.map(f=>[f.relPath,f]));for(let{relPath:f,doc:y}of o)y.slices.forEach((w,v)=>{if(w.realization===void 0)return;let _=p.get(w.realization.seqFile);if(_===void 0){u.push({path:`${f}:slices.${v}.realization.seqFile`,message:`slice "${w.id}" realization seqFile "${w.realization.seqFile}" does not exist or did not parse. Run \`npx archik q sequences\` to see available seq files.`});return}if(_.doc.realizes===void 0){u.push({path:`${f}:slices.${v}.realization.seqFile`,message:`slice "${w.id}" claims realization "${w.realization.seqFile}", but that seq diagram has no \`realizes\` block. Add \`realizes: { useCase: "${y.id}", slice: "${w.id}" }\` to ${_.relPath}, or remove the realization claim.`});return}(_.doc.realizes.useCase!==y.id||_.doc.realizes.slice!==w.id)&&u.push({path:`${f}:slices.${v}.realization.seqFile`,message:`slice "${w.id}" claims realization "${w.realization.seqFile}", but that seq diagram's \`realizes\` points at "${_.doc.realizes.useCase}/${_.doc.realizes.slice}", not at "${y.id}/${w.id}". Pick one canonical link.`})});return u}import mte from"node:path";function Cv(o){let c=mte.dirname(o),u=mte.basename(o),p=mte.extname(u),f=p.length>0?u.slice(0,-p.length):u;return mte.join(c,`${f}.suggested${p}`)}function sG(o){return mte.basename(o).endsWith(".archik.suggested.yaml")?"suggested":"normal"}function Mon(o){return o.metadata?.suggestion!==void 0}function mge(o){if(o.metadata?.suggestion===void 0)return o;let{suggestion:c,...u}=o.metadata,p={...o};return Object.keys(u).length===0?delete p.metadata:p.metadata=u,p}function OVn(o){let c=new Map;for(let p of o)c.set(p.id,p.parentId);let u=new Map;for(let p of o){let f=new Set,y=p.parentId,w=0;for(;y!==void 0&&w<=o.length&&!f.has(y);)f.add(y),y=c.get(y),w++;u.set(p.id,f)}return u}function lG(o,c,u){if(c.id!==void 0&&o.id!==c.id||c.kind!==void 0&&o.kind!==c.kind||c.stereotype!==void 0&&o.stereotype!==c.stereotype)return!1;let p=u.get(o.id)??new Set;return!(c.parent!==void 0&&!p.has(c.parent)||c.notParent!==void 0&&p.has(c.notParent))}function wge(o,c,u,p){let f=o.filter(y=>y.abs!==c);return f.push({abs:c,relPath:u,doc:p}),_ft(f)}function _ft(o){let c=[],u=o.flatMap(_=>_.doc.nodes),p=o.flatMap(_=>_.doc.edges.map(T=>({edge:T,relPath:_.relPath}))),f=new Map(u.map(_=>[_.id,_])),y=OVn(u),w=[],v=new Map;for(let _ of o)for(let T of _.doc.constraints??[]){let R=v.get(T.id);if(R!==void 0){c.push({path:`constraints.${T.id}`,message:`duplicate constraint id "${T.id}" (already defined in ${R})`});continue}v.set(T.id,_.relPath),w.push({constraint:T,relPath:_.relPath})}for(let{constraint:_}of w){let T=new Set(_.except??[]);if(_.forbidEdge!==void 0){let R=_.forbidEdge;for(let{edge:F,relPath:B}of p)if(!T.has(F.id)&&!(R.relationship!==void 0&&F.relationship!==R.relationship)){if(R.from!==void 0){let V=f.get(F.from);if(V===void 0||!lG(V,R.from,y))continue}if(R.to!==void 0){let V=f.get(F.to);if(V===void 0||!lG(V,R.to,y))continue}c.push({path:`constraints.${_.id}`,message:`edge "${F.id}" (${F.from} \u2192 ${F.to} via ${F.relationship}, in ${B}) violates constraint "${_.id}": ${_.description} \u2014 fix the edge, or add "${F.id}" to the constraint's \`except\` list with a reason in review.`})}}if(_.requireEdge!==void 0){let R=_.requireEdge;for(let F of u){if(T.has(F.id)||!lG(F,R.node,y)||p.some(({edge:se})=>{if(R.relationship!==void 0&&se.relationship!==R.relationship)return!1;if(R.to!==void 0){if(se.from!==F.id)return!1;let ce=f.get(se.to);return ce!==void 0&&lG(ce,R.to,y)}if(se.to!==F.id)return!1;let ee=f.get(se.from);return ee!==void 0&&lG(ee,R.from,y)}))continue;let V=R.to!==void 0?`an outgoing edge to a node matching ${JSON.stringify(R.to)}`:`an incoming edge from a node matching ${JSON.stringify(R.from)}`;c.push({path:`constraints.${_.id}`,message:`node "${F.id}" (kind: ${F.kind}) violates constraint "${_.id}": ${_.description} \u2014 it needs ${V}`+(R.relationship!==void 0?` (relationship: ${R.relationship})`:"")+`, or add "${F.id}" to the constraint's \`except\` list.`})}}if(_.maxDependencies!==void 0){let R=_.maxDependencies;for(let F of u){if(T.has(F.id)||!lG(F,R.node,y))continue;let B=p.filter(({edge:V})=>V.from===F.id&&(R.relationship===void 0||V.relationship===R.relationship));B.length<=R.max||c.push({path:`constraints.${_.id}`,message:`node "${F.id}" (kind: ${F.kind}) violates constraint "${_.id}": ${_.description} \u2014 ${B.length} outgoing ${R.relationship??""} edge(s), max is ${R.max} (${B.map(V=>V.edge.to).join(", ")}). Split the node, introduce a port/gateway, or add "${F.id}" to \`except\`.`})}}if(_.requireOwner!==void 0){let R=_.requireOwner.kinds;for(let F of u)T.has(F.id)||R!==void 0&&!R.includes(F.kind)||F.owner===void 0&&c.push({path:`constraints.${_.id}`,message:`node "${F.id}" (kind: ${F.kind}) violates constraint "${_.id}": ${_.description} \u2014 add \`owner: <team>\` to the node, or add "${F.id}" to the constraint's \`except\` list.`})}}return c}var CE={maxNodes:15,maxEdges:20,maxChildren:6,maxDegree:6,maxDepth:3};function FVn(o,c){let u=0,p=c.get(o);for(;p!==void 0&&u<=c.size;)u++,p=c.get(p);return u}function vge(o,c){let u=[];for(let{doc:f,relPath:y}of o){f.nodes.length>c.maxNodes&&u.push({kind:"file-nodes",subject:y,value:f.nodes.length,limit:c.maxNodes,suggestion:`split ${y} into sub-files via archikFile (${f.nodes.length} nodes; limit ${c.maxNodes})`}),f.edges.length>c.maxEdges&&u.push({kind:"file-edges",subject:y,value:f.edges.length,limit:c.maxEdges,suggestion:`split ${y} into sub-files via archikFile (${f.edges.length} edges; limit ${c.maxEdges})`});let w=new Map,v=new Map;for(let _ of f.nodes)v.set(_.id,_.parentId);for(let _ of f.nodes)_.parentId!==void 0&&w.set(_.parentId,(w.get(_.parentId)??0)+1);for(let[_,T]of w)T>c.maxChildren&&u.push({kind:"container-children",subject:_,value:T,limit:c.maxChildren,suggestion:`give container '${_}' its own archikFile \u2014 ${T} children, limit ${c.maxChildren}`});for(let _ of f.nodes){let T=FVn(_.id,v);T>c.maxDepth&&u.push({kind:"nesting-depth",subject:_.id,value:T,limit:c.maxDepth,suggestion:`flatten or split \u2014 '${_.id}' is ${T} levels deep, limit ${c.maxDepth}`})}}let p=new Map;for(let{doc:f}of o)for(let y of f.edges)p.set(y.from,(p.get(y.from)??0)+1),p.set(y.to,(p.get(y.to)??0)+1);for(let[f,y]of p)y>c.maxDegree&&u.push({kind:"node-degree",subject:f,value:y,limit:c.maxDegree,suggestion:`'${f}' has ${y} connections \u2014 name a bounded context or add a port/gateway (limit ${c.maxDegree})`});return u.sort((f,y)=>y.value-y.limit-(f.value-f.limit)),u}var jVn=o=>{let c=dn(o,"json");return c!==void 0&&c!=="false"&&c!=="0"};function Iv(o){console.log(JSON.stringify(o,null,2))}async function AR(o){let c=jVn(o),u;try{u=await cc(o._[0])}catch(nn){let cn=nn instanceof Error?nn.message:String(nn);return c?Iv({ok:!1,errors:[{path:"<root>",message:cn}]}):console.error(`\u2717 ${cn}`),1}let p=xon.relative(process.cwd(),u)||u,f;try{f=await $Vn(u,"utf-8")}catch(nn){let cn=nn instanceof Error?nn.message:String(nn);return c?Iv({ok:!1,file:p,errors:[{path:"<root>",message:cn}]}):(console.error(`\u2717 Cannot read ${p}`),console.error(cn)),1}let y;try{y=Son.default.parse(f)}catch(nn){let Nr=[{path:"<root>",message:`Invalid YAML: ${nn instanceof Error?nn.message:String(nn)}`}];return c?Iv({ok:!1,file:p,errors:Nr}):(console.error(`\u2717 ${p}`),console.error(Zu(Nr))),1}let w=jg(y);if(!w.ok)return c?Iv({ok:!1,file:p,errors:w.errors}):(console.error(`\u2717 ${p}`),console.error(Zu(w.errors))),1;let v=Ba(u),_=nn=>zVn(xon.resolve(v,nn)),T=cG(w.value,_);if(T.length>0)return c?Iv({ok:!1,file:p,errors:T}):(console.error(`\u2717 ${p}`),console.error(Zu(T))),1;let R=sG(u),F=oG(w.value,R,_);if(F.length>0)return c?Iv({ok:!1,file:p,errors:F}):(console.error(`\u2717 ${p}`),console.error(Zu(F))),1;let B=await ul(u,v);if(B.errors.length>0){if(c)Iv({ok:!1,file:p,errors:B.errors.map(nn=>({path:nn.relPath,message:nn.message}))});else for(let nn of B.errors)console.error(`\u2717 ${nn.relPath}: ${nn.message}`);return 1}let V=new Set(B.docs.flatMap(nn=>nn.doc.nodes.map(cn=>cn.id))),se=[];for(let{doc:nn}of B.docs)se.push(...ton(nn,_));if(se.length>0){if(c)Iv({ok:!1,file:p,errors:se});else{console.error("\u2717 seqFiles path errors:");for(let nn of se)console.error(` \u2717 ${nn.path}: ${nn.message}`)}return 1}let ee=await _v(v),ce=0;for(let nn of ee.errors)c||console.error(`\u2717 ${nn.relPath}: ${nn.message}`),ce++;for(let{relPath:nn,doc:cn}of ee.docs){let Nr=hon(cn,V);if(Nr.length>0){if(!c){console.error(`\u2717 ${nn}`);for(let oi of Nr)console.error(` \u2717 ${oi.path}: ${oi.message}`)}ce+=Nr.length}}if(ce>0)return c&&Iv({ok:!1,file:p,errors:[{path:"<seq>",message:`${ce} sequence diagram error(s)`}]}),1;let ge=await Op(v),Oe=await aS(v),ut=[];for(let nn of ge.errors)ut.push({path:nn.relPath,message:nn.message});for(let nn of Oe.errors)ut.push({path:nn.relPath,message:nn.message});if(ut.length===0){let nn=bon(Oe.docs);ut.push(...nn.errors);let cn=mon(ge.docs);ut.push(...cn.errors),ut.length===0&&(ut.push(...won(ge.docs,nn.index)),ut.push(...von(ge.docs,_)),ut.push(...kon(ge.docs,ee.docs)),ut.push(...yon(ee.docs,ge.docs)),ut.push(...pon(ee.docs,B.docs)),ut.push(...gon(ee.docs,B.docs)))}if(ut.length>0)return c?Iv({ok:!1,file:p,errors:ut}):(console.error(`\u2717 ${p}`),console.error(Zu(ut))),1;let Se=await aG(v),je=Se.errors.map(nn=>({path:nn.relPath,message:nn.message})),Be=[];if(je.length===0){let nn=uon(Se.docs,ge.docs,ee.docs);je.push(...nn.errors),Be=nn.info}if(je.length>0)return c?Iv({ok:!1,file:p,errors:je}):(console.error(`\u2717 ${p}`),console.error(Zu(je))),1;let tn=_ft(B.docs);if(tn.length>0)return c?Iv({ok:!1,file:p,errors:tn}):(console.error(`\u2717 ${p}`),console.error(Zu(tn))),1;let Gt=Oe.docs.reduce((nn,cn)=>nn+cn.doc.actors.length,0),xn=ge.docs.length,Vn=vge(B.docs,CE).length;if(c)Iv({ok:!0,file:p,nodes:w.value.nodes.length,edges:w.value.edges.length,useCases:xn,actors:Gt,complexityHints:Vn});else{let nn=B.docs.reduce((Pi,ue)=>Pi+ue.doc.nodes.length,0),cn=B.docs.reduce((Pi,ue)=>Pi+ue.doc.edges.length,0),Nr=B.docs.length,oi=Nr>1?` (${Nr} files)`:"",wo=xn>0?`, ${xn} use case${xn===1?"":"s"}`:"",Za=Gt>0?`, ${Gt} actor${Gt===1?"":"s"}`:"";console.log(`\u2713 ${p}${oi} \u2014 ${nn} nodes, ${cn} edges${wo}${Za}`),Vn>0&&console.log(`\u24D8 ${Vn} complexity hint${Vn===1?"":"s"} \u2014 run \`archik complexity\` to see them`);for(let Pi of Be)console.log(`\u24D8 ${Pi}`)}return 0}var w2t=mi(P3(),1),v2t=mi(Dye(),1),Gln=mi(kv(),1);import{mkdir as Hln,readFile as Uln,writeFile as qln}from"node:fs/promises";import OG from"node:path";var Rsn=mi(Lsn(),1);function cne(o,c){return o.length*c}function t0(o,c,u){if(c<=0)return"";let p=Math.floor(c/u);return o.length<=p?o:p<=1?"\u2026":o.slice(0,p-1)+"\u2026"}var ane={nodeSpacing:60,layerSpacing:100,padding:40,viewMode:"detailed"};function HXn(o){let c=o.nodeSpacing??ane.nodeSpacing,u=o.layerSpacing??ane.layerSpacing,p=o.padding??ane.padding;return{"elk.algorithm":"layered","elk.direction":"RIGHT","elk.edgeRouting":"ORTHOGONAL","elk.layered.spacing.nodeNodeBetweenLayers":String(u),"elk.spacing.nodeNode":String(c),"elk.padding":`[top=${p}, left=${p}, bottom=${p}, right=${p}]`,"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 ed={width:172,height:82},Tsn={width:172,height:90},UXn={service:ed,function:ed,worker:ed,agent:ed,database:{width:184,height:100},cache:Tsn,vectordb:ed,storage:ed,model:ed,dto:ed,dataobject:ed,queue:{width:188,height:80},topic:ed,stream:ed,gateway:ed,cdn:ed,route:ed,interface:ed,adapter:ed,port:ed,llm:ed,prompt:ed,tool:ed,auth:ed,observability:ed,cloud:{width:200,height:120},frontend:Tsn,page:ed,component:ed,store:ed,hook:ed,external:{width:184,height:100},human:{width:184,height:100},module:{width:240,height:130},custom:{width:240,height:130}},dl={width:152,height:36},Asn={width:200,height:80},qXn={service:dl,function:dl,worker:dl,agent:dl,database:dl,cache:dl,vectordb:dl,storage:dl,model:dl,dto:dl,dataobject:dl,queue:{width:168,height:36},topic:dl,stream:dl,gateway:dl,cdn:dl,route:dl,interface:dl,adapter:dl,port:dl,llm:dl,prompt:dl,tool:dl,auth:dl,observability:dl,cloud:dl,frontend:dl,page:dl,component:dl,store:dl,hook:dl,external:{width:168,height:40},human:{width:168,height:40},module:Asn,custom:Asn},GXn=24,Nsn=320;function VXn(o,c,u){if(o.kind==="module"||o.kind==="custom")return c;if(u==="compact"){let v=36+cne(o.name,5.9)+12;return Math.max(c,Math.min(Nsn,Math.ceil(v)))}let p=cne(o.name,7.4),f=o.stack!==void 0?cne(o.stack,5.9):0,y=Math.max(p,f)+GXn;return Math.max(c,Math.min(Nsn,Math.ceil(y)))}var WXn={top:48,left:18,bottom:18,right:18};function JXn(o,c,u,p){let f=u[o.kind],y={id:o.id,width:VXn(o,f.width,p),height:f.height};if(c.length>0){y.children=c;let w=p==="compact"?{top:30,left:12,bottom:12,right:12}:WXn;y.layoutOptions={"elk.padding":`[top=${w.top}, left=${w.left}, bottom=${w.bottom}, right=${w.right}]`}}return y}function ZXn(o,c,u){let p=new Map;for(let v of o.nodes)p.set(v.id,v);let f=new Map;for(let v of o.nodes){let _=f.get(v.parentId)??[];_.push(v),f.set(v.parentId,_)}function y(v){let _=(f.get(v.id)??[]).map(y);return JXn(v,_,c,u)}return{roots:(f.get(void 0)??[]).map(y),byId:p}}function XXn(o){return o.fromFile===void 0&&o.toFile===void 0}function KXn(o){return o.edges.filter(XXn).map(c=>{let u={id:c.id,sources:[c.from],targets:[c.to]};return c.label!==void 0&&c.label.length>0&&(u.labels=[{text:c.label,width:Math.ceil(cne(c.label,5.9)),height:14}]),u})}function Gm(o){return o??0}function Dsn(o,c){let u=c.get(o.id);if(!u)throw new Error(`ELK returned unknown node id "${o.id}"`);let p=(o.children??[]).map(f=>Dsn(f,c));return{...u,x:Gm(o.x),y:Gm(o.y),width:Gm(o.width),height:Gm(o.height),children:p}}function YXn(o,c){let u=new Map,p=new Map,f=(T,R,F,B)=>{let V=R+Gm(T.x),se=F+Gm(T.y);u.set(T.id,{x:V,y:se}),p.set(T.id,B);let ee=[...B,T.id];for(let ce of T.children??[])f(ce,V,se,ee)};f(o,0,0,[]);let y=(T,R)=>{let F=p.get(T)??[],B=p.get(R)??[],V=0;for(;V<F.length&&V<B.length&&F[V]===B[V];)V++;let se=V===0?o.id:F[V-1];return u.get(se)??{x:0,y:0}},w=new Map,v=new Map,_=T=>{for(let R of T.edges??[]){let F=R.sources?.[0]??"",B=R.targets?.[0]??"",V=y(F,B),se=ge=>({x:Gm(ge.x)+V.x,y:Gm(ge.y)+V.y}),ee=(R.sections??[]).map(ge=>({startPoint:se(ge.startPoint),endPoint:se(ge.endPoint),bendPoints:(ge.bendPoints??[]).map(se)}));w.set(R.id,ee);let ce=(R.labels??[]).map(ge=>({text:typeof ge.text=="string"?ge.text:"",x:Gm(ge.x)+V.x,y:Gm(ge.y)+V.y,width:Gm(ge.width),height:Gm(ge.height)}));v.set(R.id,ce)}for(let R of T.children??[])_(R)};return _(o),c.edges.map(T=>({...T,sections:w.get(T.id)??[],labels:v.get(T.id)??[]}))}var QXn=new Rsn.default;async function eKn(o,c={}){if(o.nodes.length===0)return{document:o,width:0,height:0,roots:[],edges:[]};let u=c.viewMode==="compact"?"compact":"detailed",p=u==="compact"?qXn:UXn,{roots:f,byId:y}=ZXn(o,p,u),w={id:"__root__",layoutOptions:HXn(c),children:f,edges:KXn(o)},v=await QXn.layout(w),_=(v.children??[]).map(T=>Dsn(T,y));return{document:o,width:Gm(v.width),height:Gm(v.height),roots:_,edges:YXn(v,o)}}var Oye={name:"elk",layout:eKn};var Ili={[Oye.name]:Oye},tKn=Oye;function TG(o,c){return tKn.layout(o,c)}function Osn(o,c,u){let p=new Map,f=(v,_)=>{let T=p.get(v)??new Set;T.add(_),p.set(v,T)};for(let v of o)f(v.from,v.to),f(v.to,v.from);let y=new Set([c]),w=new Set([c]);for(let v=0;v<u;v++){let _=new Set;for(let T of w)for(let R of p.get(T)??[])y.has(R)||(y.add(R),_.add(R));if(_.size===0)break;w=_}return y}function Fsn(o,c,u){let p=o.flatMap(v=>v.doc.edges),f=Osn(p,c,u),y=[],w=[];for(let{doc:v,relPath:_}of o){for(let T of v.nodes)f.has(T.id)&&y.push({node:T,relPath:_});for(let T of v.edges)f.has(T.from)&&f.has(T.to)&&w.push({edge:T,relPath:_})}return{nodes:y,edges:w}}function zsn(o,c,u){let p=Osn(o.edges,c,u);return{...o,nodes:o.nodes.filter(f=>p.has(f.id)).map(f=>f.parentId!==void 0&&!p.has(f.parentId)?(({parentId:y,...w})=>w)(f):f),edges:o.edges.filter(f=>p.has(f.from)&&p.has(f.to))}}function $sn(o,c){let u=new Set(c.hideRel??[]),p=c.onlyRel?new Set(c.onlyRel):null,f=o.edges.filter(y=>!(p&&!p.has(y.relationship)||u.has(y.relationship)||c.hideStructural&&Kin(y.relationship)==="structural"));return{...o,edges:f}}function nKn(o){return Math.max(160,o.length*8+80)}function jsn(o,c,u,p,f,y=0){let w=u,v=[],_=Number.POSITIVE_INFINITY,T=Number.NEGATIVE_INFINITY;for(let R of o)if(R.type==="message"){let F=c.get(R.from),B=c.get(R.to),V=F?.cx??p,se=B?.cx??p;v.push({type:"message",id:R.id,fromCx:V,toCx:se,y:w,label:R.label,arrow:R.arrow,activate:R.activate??!1,isSelf:R.from===R.to,...R.status!==void 0?{status:R.status}:{}}),w+=R.from===R.to?56*1.5:56}else if(R.type==="note"){let F=R.participants.map(ce=>c.get(ce)?.cx).filter(ce=>ce!==void 0).sort((ce,ge)=>ce-ge),B=F[0]??p,V=F[F.length-1]??f,se=Math.min(Math.max(R.text.length*7.5+24,V-B+16,80),400),ee;R.position==="left_of"?ee=B-se-8:R.position==="right_of"?ee=V+8:ee=(B+V)/2-se/2,_=Math.min(_,ee),T=Math.max(T,ee+se),v.push({type:"note",id:R.id,x:ee,y:w,width:se,height:64,text:R.text,...R.status!==void 0?{status:R.status}:{}}),w+=72}else if(R.type==="group"){let F=Math.min(y*6,12),B=p-12+F,V=f-p+24-F*2,se=w;w+=24;let ee=[];if(R.branches)for(let ce=0;ce<R.branches.length;ce++){let ge=R.branches[ce],Oe=w,{items:ut,endY:Se,contentMinX:je,contentMaxX:Be}=jsn(ge.steps,c,w,p,f,y+1);w=Se,_=Math.min(_,je),T=Math.max(T,Be),ee.push({...ge.label!==void 0?{label:ge.label}:{},startY:Oe,...ce<R.branches.length-1?{dividerY:w}:{},steps:ut}),ce<R.branches.length-1&&(w+=4)}w+=12,v.push({type:"group",id:R.id,kind:R.kind,...R.condition!==void 0?{condition:R.condition}:{},...R.label!==void 0?{label:R.label}:{},...R.seqFile!==void 0?{seqFile:R.seqFile}:{},x:B,y:se,width:V,height:w-se,branches:ee,...R.status!==void 0?{status:R.status}:{}}),_=Math.min(_,B),T=Math.max(T,B+V),w+=20}return{items:v,endY:w,contentMinX:_,contentMaxX:T}}function Bsn(o){let c=new Map;for(let u of o)if(u.type==="message"&&u.arrow==="destroy"&&c.set(u.toCx,u.y+56+20),u.type==="group")for(let p of u.branches)for(let[f,y]of Bsn(p.steps))c.set(f,y);return c}function rKn(o){let c=[],u=new Map;function p(f){for(let y of f)if(y.type==="message"){if(y.activate&&y.arrow==="sync"&&!y.isSelf){let w=u.get(y.toCx)??[];w.push(y.y),u.set(y.toCx,w)}if(y.arrow==="return"&&!y.isSelf){let w=u.get(y.fromCx);if(w&&w.length>0){let v=w.pop();c.push({cx:y.fromCx,startY:v,endY:y.y}),w.length===0&&u.delete(y.fromCx)}}}else if(y.type==="group")for(let w of y.branches)p(w.steps)}p(o);for(let[f,y]of u)for(let w of y)c.push({cx:f,startY:w,endY:w+56/2});return c}function Hsn(o,c){let u=o.participants.map(tn=>nKn(tn.label??tn.nodeId)),p=32,f=o.participants.map((tn,Gt)=>{let xn=u[Gt],Vn=p+xn/2;p+=xn;let nn=c?.get(tn.nodeId);return{id:tn.id,nodeId:tn.nodeId,label:tn.label??tn.nodeId,cx:Vn,colWidth:xn,...nn!==void 0?{kind:nn}:{},...tn.status!==void 0?{status:tn.status}:{},lifelineEndY:0}}),y=p+32,w=new Map(f.map(tn=>[tn.id,tn])),v=f[0]?.cx??32,_=f[f.length-1]?.cx??y-32,T=24,{items:R,endY:F,contentMinX:B,contentMaxX:V}=jsn(o.steps,w,T,v,_),se=B<32&&Number.isFinite(B)?32-B:0,ee=Number.isFinite(V)?V+se+32:0,ce=Math.max(y+se,ee),ge=se>0?R.map(tn=>Usn(tn,se)):R,Oe=se>0?f.map(tn=>({...tn,cx:tn.cx+se})):f,ut=Bsn(ge),Se=Oe.map(tn=>({...tn,lifelineEndY:ut.get(tn.cx)??56+F+24})),je=56+F+24,Be=rKn(ge);return{participants:Se,steps:ge,activations:Be,totalWidth:ce,totalHeight:je}}function Usn(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(u=>({...u,steps:u.steps.map(p=>Usn(p,c))}))}}var ci=mi(s2t(),1);var D3=mi(hc(),1),Ysn=(o,c,u)=>({width:o,height:o,viewBox:"0 0 24 24",fill:"none",stroke:c,strokeWidth:u,strokeLinecap:"round",strokeLinejoin:"round"});function Qsn({size:o=16,color:c="currentColor",strokeWidth:u=1.8}){return(0,D3.jsxs)("svg",{...Ysn(o,c,u),"aria-hidden":"true",children:[(0,D3.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3.5",ry:"3.5"}),(0,D3.jsx)("line",{x1:"9",y1:"9",x2:"9",y2:"13"}),(0,D3.jsx)("line",{x1:"15",y1:"9",x2:"15",y2:"13"}),(0,D3.jsx)("circle",{cx:"12",cy:"16.5",r:"1",fill:c,stroke:"none"})]})}function eln({size:o=16,color:c="currentColor",strokeWidth:u=1.8}){return(0,D3.jsxs)("svg",{...Ysn(o,c,u),"aria-hidden":"true",children:[(0,D3.jsx)("path",{d:"M 7.5 6 L 3.5 12 L 7.5 18"}),(0,D3.jsx)("path",{d:"M 16.5 6 L 20.5 12 L 16.5 18"}),(0,D3.jsx)("circle",{cx:"13",cy:"8.6",r:"0.9",fill:c,stroke:"none"}),(0,D3.jsx)("line",{x1:"13",y1:"11",x2:"11",y2:"16.5"})]})}var Vm={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.)."},model:{color:"#2dd4bf",icon:ci.Shapes,description:"Domain model \u2014 rich business object with behavior."},dto:{color:"#4ade80",icon:ci.FileJson2,description:"Data transfer object \u2014 shape crossing a boundary."},dataobject:{color:"#86efac",icon:ci.Braces,description:"Plain data structure / record, no behavior."},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:eln,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:Qsn,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 Kz=mi(hc(),1),WOe=36,z6r=128,$6r=7,tln=20,nln=24;function rln({participant:o,nodeKind:c}){let u=c?Vm[c]:void 0,p=u?.color??"var(--archik-fg-muted)",f=(56-WOe)/2,y=u?.icon,w=Math.max(z6r,o.label.length*$6r+nln+(y?tln:0)),v=w/2,_=y?v+tln/2:v,T=o.status,R=T==="proposed"?.55:T==="deprecated"?.35:1,F=T==="proposed"||T==="deprecated"?"4 3":void 0;return(0,Kz.jsxs)("g",{transform:`translate(${o.cx-v}, ${f})`,opacity:R,children:[(0,Kz.jsx)("rect",{width:w,height:WOe,rx:8,fill:"var(--archik-node-fill)",stroke:p,strokeWidth:1.4,...F!==void 0?{strokeDasharray:F}:{}}),y&&(0,Kz.jsx)("g",{transform:`translate(${nln/2}, ${(WOe-14)/2})`,children:(0,Kz.jsx)(y,{size:14,color:p,strokeWidth:1.5})}),(0,Kz.jsx)("text",{x:_,y:WOe/2+4,textAnchor:"middle",fontSize:12,fontWeight:500,fill:"var(--archik-fg)",fontFamily:"inherit",children:o.label})]})}var oln=mi(hc(),1);function iln({participant:o}){let c=o.status,u=c==="proposed"?.35:c==="deprecated"?.25:.6;return(0,oln.jsx)("line",{x1:o.cx,y1:56,x2:o.cx,y2:o.lifelineEndY,stroke:"var(--archik-fg-muted)",strokeWidth:1.2,strokeDasharray:"6 5",opacity:u})}function u2t(o,c){let u=o.x-c.x,p=o.y-c.y,f=Math.hypot(u,p);if(f<.01)return null;let y=u/f,w=p/f;return{ux:y,uy:w,px:-w,py:y,len:f}}var n0=o=>String(Math.round(o*100)/100);function AG(o,c,u=10,p=4){let f=u2t(o,c);if(!f)return"";let y=o.x-f.ux*u,w=o.y-f.uy*u;return`M ${n0(y+f.px*p)} ${n0(w+f.py*p)} L ${n0(o.x)} ${n0(o.y)} L ${n0(y-f.px*p)} ${n0(w-f.py*p)} Z`}function JOe(o,c,u=10,p=4.5){let f=u2t(o,c);if(!f)return"";let y=o.x-f.ux*u,w=o.y-f.uy*u;return`M ${n0(y+f.px*p)} ${n0(w+f.py*p)} L ${n0(o.x)} ${n0(o.y)} L ${n0(y-f.px*p)} ${n0(w-f.py*p)}`}function cln(o,c,u=14,p=6){return AG(o,c,u,p)}function aln(o,c,u=14,p=4.5){let f=u2t(c,o);if(!f)return"";let y=o.x+f.ux*(u/2),w=o.y+f.uy*(u/2),v=o.x+f.ux*u,_=o.y+f.uy*u;return`M ${n0(o.x)} ${n0(o.y)} L ${n0(y+f.px*p)} ${n0(w+f.py*p)} L ${n0(v)} ${n0(_)} L ${n0(y-f.px*p)} ${n0(w-f.py*p)} Z`}var Rv=mi(hc(),1),ZOe=32,lne=20,j6r=-6,XOe="var(--archik-edge-filled)";function sln({msg:o}){let c=o.arrow==="return",u=o.arrow==="async",p=o.arrow==="create",f=c||p,y=o.arrow==="destroy",w=c||u,v=o.status==="proposed"?.5:o.status==="deprecated"?.35:1,_=(B,V)=>w?(0,Rv.jsx)("path",{"data-archik-arrowhead":"end",d:JOe(B,V),fill:"none",stroke:XOe,strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"}):(0,Rv.jsx)("path",{"data-archik-arrowhead":"end",d:AG(B,V),fill:XOe});if(o.isSelf){let B=o.fromCx,V=o.y,se=`M ${B} ${V} L ${B+ZOe} ${V} L ${B+ZOe} ${V+lne} L ${B} ${V+lne}`;return(0,Rv.jsxs)("g",{opacity:v,children:[(0,Rv.jsx)("path",{d:se,fill:"none",stroke:XOe,strokeWidth:1.4}),_({x:B,y:V+lne},{x:B+ZOe,y:V+lne}),(0,Rv.jsx)("text",{x:B+ZOe+6,y:V+lne/2+4,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",stroke:"var(--archik-canvas)",strokeWidth:3,paintOrder:"stroke",children:o.label})]})}let R=o.fromCx<o.toCx?o.toCx-6:o.toCx+6,F=(o.fromCx+o.toCx)/2;return(0,Rv.jsxs)("g",{opacity:v,children:[(0,Rv.jsx)("line",{x1:o.fromCx,y1:o.y,x2:R,y2:o.y,stroke:XOe,strokeWidth:1.4,strokeDasharray:f?"4 4":void 0}),!y&&_({x:o.toCx,y:o.y},{x:o.fromCx,y:o.y}),(0,Rv.jsxs)("text",{x:F,y:o.y+j6r,textAnchor:"middle",fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",stroke:"var(--archik-canvas)",strokeWidth:3,paintOrder:"stroke",children:[p&&"\xABcreate\xBB ",o.label]}),o.arrow==="destroy"&&(0,Rv.jsxs)("g",{transform:`translate(${o.toCx-6}, ${o.y-6})`,children:[(0,Rv.jsx)("line",{x1:0,y1:0,x2:12,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5}),(0,Rv.jsx)("line",{x1:12,y1:0,x2:0,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5})]})]})}var Y9=mi(hc(),1),B6r={alt:"#6366f1",opt:"#0ea5e9",loop:"#10b981",par:"#f59e0b",break:"#ef4444",ref:"#8b5cf6"},lln=36,d2t=18;function uln({group:o,renderStep:c,onRefClick:u}){let p=B6r[o.kind]??"var(--archik-fg-muted)",f=o.status==="proposed"?.55:o.status==="deprecated"?.35:1,y=o.kind==="ref"&&o.seqFile!==void 0&&u!==void 0;return(0,Y9.jsxs)("g",{opacity:f,onClick:y?()=>u(o.seqFile):void 0,style:y?{cursor:"pointer"}:void 0,children:[(0,Y9.jsx)("rect",{x:o.x,y:o.y,width:o.width,height:o.height,rx:4,fill:"none",stroke:p,strokeWidth:1.2,opacity:.8}),(0,Y9.jsx)("rect",{x:o.x,y:o.y,width:lln,height:d2t,rx:4,fill:p,opacity:.8}),(0,Y9.jsx)("text",{x:o.x+6,y:o.y+d2t-5,fontSize:10,fontWeight:600,fill:"#fff",fontFamily:"inherit",children:o.kind}),(o.condition??o.label)&&(0,Y9.jsx)("text",{x:o.x+lln+6,y:o.y+d2t-5,fontSize:10,fill:p,fontFamily:"inherit",children:o.condition??o.label}),o.branches.map((w,v)=>(0,Y9.jsxs)("g",{children:[w.label&&(0,Y9.jsx)("text",{x:o.x+6,y:w.startY+12,fontSize:10,fill:p,fontFamily:"inherit",children:w.label}),w.steps.map(_=>c(_)),w.dividerY!==void 0&&(0,Y9.jsx)("line",{x1:o.x,y1:w.dividerY,x2:o.x+o.width,y2:w.dividerY,stroke:p,strokeWidth:1,strokeDasharray:"4 2",opacity:.65})]},v))]})}var NG=mi(hc(),1);function H6r(o,c){let u=Math.max(10,Math.floor(c/6.5));if(o.length<=u)return[o];let p=o.split(" "),f=[],y="";for(let w of p)(y+(y?" ":"")+w).length>u&&y?(f.push(y),y=w):y=y?y+" "+w:w;return y&&f.push(y),f.slice(0,3)}function dln({note:o}){let{x:c,y:u,width:p,height:f,text:y}=o,w=o.status==="proposed"?.55:o.status==="deprecated"?.35:1;return(0,NG.jsxs)("g",{opacity:w,children:[(0,NG.jsx)("path",{d:`M ${c} ${u} L ${c+p-10} ${u} L ${c+p} ${u+10} L ${c+p} ${u+f} L ${c} ${u+f} Z`,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),(0,NG.jsx)("path",{d:`M ${c+p-10} ${u} L ${c+p-10} ${u+10} L ${c+p} ${u+10}`,fill:"none",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),H6r(y,p-16).map((v,_)=>(0,NG.jsx)("text",{x:c+8,y:u+8+11+_*13,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:v},_))]})}var O3=mi(hc(),1);function fln({step:o,onRefClick:c}){return o.type==="message"?(0,O3.jsx)(sln,{msg:o}):o.type==="note"?(0,O3.jsx)(dln,{note:o}):o.type==="group"?(0,O3.jsx)(uln,{group:o,...c!==void 0?{onRefClick:c}:{},renderStep:u=>(0,O3.jsx)(fln,{step:u,...c!==void 0?{onRefClick:c}:{}},u.id)}):null}function pln({laid:o,svgRef:c,onRefClick:u}){let{participants:p,steps:f,activations:y,totalWidth:w,totalHeight:v}=o;return(0,O3.jsxs)("svg",{ref:c,width:w,height:v,viewBox:`0 0 ${w} ${v}`,xmlns:"http://www.w3.org/2000/svg",style:{fontFamily:"var(--archik-font, system-ui)"},children:[p.map(_=>(0,O3.jsx)(iln,{participant:_},_.id)),p.map(_=>(0,O3.jsx)(rln,{participant:_,..._.kind!==void 0?{nodeKind:_.kind}:{}},_.id)),(0,O3.jsxs)("g",{transform:`translate(0, ${56})`,children:[y.map(_=>(0,O3.jsx)("rect",{x:_.cx-8/2,y:_.startY,width:8,height:_.endY-_.startY,fill:"var(--archik-surface)",stroke:"var(--archik-fg-muted)",strokeWidth:1.2,rx:2},`${_.cx}-${_.startY}`)),f.map(_=>(0,O3.jsx)(fln,{step:_,...u!==void 0?{onRefClick:u}:{}},_.id))]})]})}var HE=mi(hc(),1),r0=28;function RG({kind:o,iconAt:c,labelAt:u}){let p=Vm[o],f=p.icon,y=14;return(0,HE.jsxs)(HE.Fragment,{children:[(0,HE.jsx)("g",{transform:`translate(${c.cx-y/2}, ${c.cy-y/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,HE.jsx)(f,{size:y,color:p.color,strokeWidth:1.8})}),(0,HE.jsx)("text",{x:u.cx,y:u.cy,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.toUpperCase()})]})}var UE=mi(hc(),1),U6r=24;function gln({node:o,selected:c}){let u=o.width,p=o.height,f=o.stack!==void 0,y=r0+(p-r0)/2,w=f?y-4:y+4,v=y+14,_=Math.max(0,u-U6r),T=t0(o.name,_,7.4),R=f?t0(o.stack,_,5.9):"";return(0,UE.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,UE.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,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,UE.jsx)("line",{x1:0,y1:r0,x2:u,y2:r0,stroke:"var(--archik-node-stroke)",strokeOpacity:.25,strokeWidth:1}),(0,UE.jsx)(RG,{kind:o.kind,iconAt:{cx:18,cy:r0/2},labelAt:{cx:u/2,cy:r0/2+3}}),(0,UE.jsx)("text",{x:u/2,y:w,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:T}),f&&(0,UE.jsx)("text",{x:u/2,y:v,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:R})]})}var qE=mi(hc(),1);function yln({node:o,selected:c}){let u=o.width,p=o.height,f=Math.min(p/2,28),y=o.stack!==void 0,w=r0+(p-r0)/2,v=y?w-4:w+4,_=w+14,T=Math.max(0,u-2*f-8),R=t0(o.name,T,7.4),F=y?t0(o.stack,T,5.9):"",B=c?"var(--archik-selected)":"var(--archik-node-stroke)";return(0,qE.jsxs)("g",{className:"archik-node archik-node--queue",children:[(0,qE.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,rx:f,ry:f,fill:"var(--archik-node-fill)",stroke:B,strokeWidth:c?1.8:1.4}),(0,qE.jsx)("line",{x1:f,y1:r0,x2:u-f,y2:r0,stroke:B,strokeOpacity:.25,strokeWidth:1}),(0,qE.jsx)(RG,{kind:"queue",iconAt:{cx:f+8,cy:r0/2},labelAt:{cx:u/2,cy:r0/2+3}}),(0,qE.jsx)("text",{x:u/2,y:v,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:R}),y&&(0,qE.jsx)("text",{x:u/2,y:_,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:F})]})}var GE=mi(hc(),1),q6r=24;function bln({node:o,selected:c}){let u=o.width,p=o.height,f=o.description!==void 0,y=r0,w=y+(p-y)/2,v=f?w-2:w+4,_=p-12,T=Math.max(0,u-q6r),R=t0(o.name,T,7.4),F=f?t0(o.description,T,5.9):"",B=c?"var(--archik-selected)":"var(--archik-node-stroke-soft)";return(0,GE.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,GE.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,rx:8,ry:8,fill:"var(--archik-node-fill-tinted)",stroke:B,strokeWidth:c?1.8:1.2,strokeDasharray:c?void 0:"6 4"}),(0,GE.jsx)("line",{x1:6,y1:r0,x2:u-6,y2:r0,stroke:B,strokeOpacity:.25,strokeWidth:1}),(0,GE.jsx)(RG,{kind:o.kind,iconAt:{cx:18,cy:r0/2},labelAt:{cx:u/2,cy:r0/2+3}}),(0,GE.jsx)("text",{x:u/2,y:v,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:R}),f&&(0,GE.jsx)("text",{x:u/2,y:_,textAnchor:"middle",fontSize:10,fill:"var(--archik-node-text-dim)",children:F})]})}var h6=mi(hc(),1),G6r=28,h2t=10,V6r=22;function mln({node:o,selected:c}){let u=o.width,p=o.height,f=u/2,y=h2t,w=Vm[o.kind],v=w.icon,_=c?"var(--archik-selected)":"var(--archik-node-stroke)",T=c?1.8:1.4,R=o.stack!==void 0,F=Math.max(0,u-G6r),B=t0(o.name,F,7.4),V=R?t0(o.stack,F,5.9):"",se=p,ee=se-V6r,ce=(ee+se)/2,ut=(y+8+ee)/2,Se=R?ut-4:ut+4,je=ut+14;return(0,h6.jsxs)("g",{className:"archik-node archik-node--database",children:[(0,h6.jsx)("path",{className:c?"archik-selected-glow":void 0,d:f2t(u,p,y),fill:"var(--archik-node-fill)",stroke:_,strokeWidth:T,strokeLinejoin:"round"}),(0,h6.jsx)("ellipse",{cx:f,cy:y,rx:u/2,ry:y,fill:"var(--archik-node-fill)",stroke:_,strokeWidth:T}),(0,h6.jsx)("text",{x:f,y:Se,textAnchor:"middle",fontSize:14,fontWeight:600,fill:"var(--archik-node-text)",children:B}),R&&(0,h6.jsx)("text",{x:f,y:je,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:V}),(0,h6.jsx)("line",{x1:4,y1:ee,x2:u-4,y2:ee,stroke:_,strokeOpacity:.45,strokeWidth:1}),(0,h6.jsx)("g",{transform:`translate(14, ${ce-7})`,pointerEvents:"none","aria-hidden":"true",children:(0,h6.jsx)(v,{size:14,color:w.color,strokeWidth:1.9})}),(0,h6.jsx)("text",{x:f,y:ce+4,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()})]})}var W6r=10;function f2t(o,c,u){let p=W6r;return[`M 0 ${u}`,`L 0 ${c-p}`,`A ${p} ${p} 0 0 0 ${p} ${c}`,`L ${o-p} ${c}`,`A ${p} ${p} 0 0 0 ${o} ${c-p}`,`L ${o} ${u}`,`A ${o/2} ${u} 0 0 0 0 ${u}`,"Z"].join(" ")}var bS=mi(hc(),1),J6r=36,wln=18;function vln({node:o,selected:c}){let u=o.width,p=o.height,f=Vm[o.kind],y=f.icon,w=c?"var(--archik-selected)":"var(--archik-node-stroke)",v=c?1.8:1.4,_=o.stack!==void 0,T=Math.max(0,u-J6r),R=t0(o.name,T,7.4),F=_?t0(o.stack,T,5.9):"",B=u/2,V=p*.55,se=_?V-4:V+4,ee=V+14;return(0,bS.jsxs)("g",{className:"archik-node archik-node--cloud",children:[(0,bS.jsx)("path",{className:c?"archik-selected-glow":void 0,d:Z6r(u,p),fill:"var(--archik-node-fill)",stroke:w,strokeWidth:v,strokeLinejoin:"round"}),(0,bS.jsx)("g",{transform:`translate(18, ${wln-6})`,pointerEvents:"none","aria-hidden":"true",children:(0,bS.jsx)(y,{size:14,color:f.color,strokeWidth:1.9})}),(0,bS.jsx)("text",{x:B,y:wln+4,textAnchor:"middle",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()}),(0,bS.jsx)("text",{x:B,y:se,textAnchor:"middle",fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:R}),_&&(0,bS.jsx)("text",{x:B,y:ee,textAnchor:"middle",fontSize:11,fill:"var(--archik-node-text-dim)",children:F})]})}function Z6r(o,c){let p=c-2,f=c*.62,y=Math.min(c*.18,14),w=o-4,v=c*.5,_=Math.min(w*.15,v*.85),T=Math.min(w*.18,v),R=Math.min(w*.15,v*.85),F=2*(_+T+R),B=Math.max(0,w-F)/4,V=2,se=o-2,ee=V+B,ce=ee+2*_,ge=ce+B,Oe=ge+2*T,ut=Oe+B,Se=ut+2*R;return[`M ${V} ${p-y}`,`Q ${V} ${p} ${V+y} ${p}`,`L ${se-y} ${p}`,`Q ${se} ${p} ${se} ${p-y}`,`L ${se} ${f}`,`L ${Se} ${f}`,`A ${R} ${R} 0 0 0 ${ut} ${f}`,`L ${Oe} ${f}`,`A ${T} ${T} 0 0 0 ${ge} ${f}`,`L ${ce} ${f}`,`A ${_} ${_} 0 0 0 ${ee} ${f}`,`L ${V} ${f}`,"Z"].join(" ")}var hb=mi(hc(),1),DG=32,KOe=14,p2t=14;function kln({node:o,selected:c,depth:u=0}){let p=o.width,f=o.height;if(!(o.children.length>0))return(0,hb.jsx)(K6r,{node:o,selected:!!c});let w=Vm[o.kind],v=w.icon,_=Math.min(.04+u*.06,.22),T=Math.min(.55+u*.12,.95),R=c?"var(--archik-selected)":"var(--archik-container-border)",F=c?1.8:1.2,B=Math.max(0,p-KOe*2-60),V=t0(o.name,B,7.4);return(0,hb.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--container`,children:[(0,hb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:p,height:f,rx:8,ry:8,fill:w.color,fillOpacity:_,stroke:R,strokeWidth:F,pointerEvents:"none"}),u>=1&&p>8&&f>8&&(0,hb.jsx)("rect",{x:3,y:3,width:p-6,height:f-6,rx:6,ry:6,fill:"none",stroke:w.color,strokeOpacity:Math.min(.18+(u-1)*.06,.32),strokeWidth:1,pointerEvents:"none"}),(0,hb.jsx)("path",{d:X6r(p,DG,8),fill:w.color,fillOpacity:T*.18}),(0,hb.jsx)("line",{x1:0,y1:DG,x2:p,y2:DG,stroke:R,strokeOpacity:.45,strokeWidth:1}),(0,hb.jsx)("g",{transform:`translate(${KOe}, ${DG/2-p2t/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,hb.jsx)(v,{size:p2t,color:w.color,strokeWidth:1.9})}),(0,hb.jsx)("text",{x:KOe+p2t+8,y:DG/2+4,fontSize:13,fontWeight:600,fill:"var(--archik-node-text)",children:V}),(0,hb.jsx)("text",{x:p-KOe,y:DG/2+3,textAnchor:"end",fontSize:9.5,fontWeight:600,letterSpacing:"0.12em",fill:"var(--archik-node-caption)",children:o.kind.toUpperCase()})]})}function X6r(o,c,u){return`M ${u} 0 H ${o-u} A ${u} ${u} 0 0 1 ${o} ${u} V ${c} H 0 V ${u} A ${u} ${u} 0 0 1 ${u} 0 Z`}function K6r({node:o,selected:c}){let u=o.width,p=o.height,f=Vm[o.kind],y=c?"var(--archik-selected)":"var(--archik-node-stroke-soft)";return(0,hb.jsxs)("g",{className:`archik-node archik-node--${o.kind}`,children:[(0,hb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:u,height:p,rx:8,ry:8,fill:"var(--archik-node-fill-tinted)",stroke:y,strokeWidth:c?1.8:1.2,strokeDasharray:c?void 0:"5 4"}),(0,hb.jsx)("text",{x:u/2,y:p/2+4,textAnchor:"middle",fontSize:12,fontWeight:600,fill:f.color,children:o.name})]})}var fb=mi(hc(),1),une=24,Mln=10,g2t=28;function xln({node:o,selected:c,depth:u=0}){let p=o.width,f=o.height,y=Vm[o.kind],w=y.icon,v=o.kind==="external";if(o.children.length>0)return(0,fb.jsx)(Y6r,{node:o,selected:!!c,depth:u});let _=c?"var(--archik-selected)":v?"var(--archik-node-stroke-soft)":"var(--archik-node-stroke)",T=v?"var(--archik-node-fill-tinted)":"var(--archik-node-fill)",R=o.kind==="queue"?Math.min(f/2,18):8;return(0,fb.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--compact`,children:[(0,fb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:p,height:f,rx:R,ry:R,fill:T,stroke:_,strokeWidth:c?1.8:1.4,strokeDasharray:v&&!c?"5 4":void 0}),(0,fb.jsx)("g",{transform:`translate(${Mln}, ${f/2-7})`,pointerEvents:"none","aria-hidden":"true",children:(0,fb.jsx)(w,{size:13,color:y.color,strokeWidth:1.9})}),(0,fb.jsx)("text",{x:g2t,y:f/2+4,fontSize:12,fontWeight:600,fill:"var(--archik-node-text)",children:t0(o.name,Math.max(0,p-g2t-8),5.9)})]})}function Y6r({node:o,selected:c,depth:u}){let p=o.width,f=o.height,y=Vm[o.kind],w=y.icon,v=Math.min(.04+u*.035,.14),_=Math.min(.55+u*.08,.85),T=c?"var(--archik-selected)":"var(--archik-container-border)",R=Math.max(0,p-12-22),F=t0(o.name,R,5.9);return(0,fb.jsxs)("g",{className:`archik-node archik-node--${o.kind} archik-node--compact archik-node--container`,children:[(0,fb.jsx)("rect",{className:c?"archik-selected-glow":void 0,width:p,height:f,rx:6,ry:6,fill:y.color,fillOpacity:v,stroke:T,strokeWidth:c?1.8:1.2}),(0,fb.jsx)("path",{d:Q6r(p,une,6),fill:y.color,fillOpacity:_*.18}),(0,fb.jsx)("line",{x1:0,y1:une,x2:p,y2:une,stroke:T,strokeOpacity:.45,strokeWidth:1}),(0,fb.jsx)("g",{transform:`translate(${Mln}, ${une/2-6})`,pointerEvents:"none","aria-hidden":"true",children:(0,fb.jsx)(w,{size:12,color:y.color,strokeWidth:1.9})}),(0,fb.jsx)("text",{x:g2t,y:une/2+4,fontSize:12,fontWeight:600,fill:"var(--archik-node-text)",children:F})]})}function Q6r(o,c,u){return`M ${u} 0 H ${o-u} A ${u} ${u} 0 0 1 ${o} ${u} V ${c} H 0 V ${u} A ${u} ${u} 0 0 1 ${u} 0 Z`}var Q9=mi(s2t(),1),_d=mi(hc(),1),e8r=12,t8r=18;function Sln({Icon:o,cx:c,cy:u,size:p=e8r,color:f,strokeWidth:y=1.8}){return(0,_d.jsx)("g",{transform:`translate(${c-p/2}, ${u-p/2})`,pointerEvents:"none","aria-hidden":"true",children:(0,_d.jsx)(o,{size:p,color:f??"var(--archik-fg-dim)",strokeWidth:y})})}function _ln(o){return(0,_d.jsx)(Sln,{Icon:Q9.Info,...o})}function Cln(o){return(0,_d.jsx)(Sln,{Icon:Q9.StickyNote,...o})}function Iln({cx:o,cy:c,filePath:u,fileLabel:p,onClick:f,size:y=13}){return(0,_d.jsxs)("g",{transform:`translate(${o-y/2}, ${c-y/2})`,style:{cursor:f?"pointer":"default"},onClick:f,children:[(0,_d.jsx)("title",{children:`Cross-file edge \u2192 ${p} (${u})`}),(0,_d.jsx)("circle",{cx:y/2,cy:y/2,r:y/2+.5,fill:"var(--archik-fg-dim)",fillOpacity:.12,stroke:"var(--archik-fg-dim)",strokeOpacity:.4,strokeWidth:1}),(0,_d.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,_d.jsx)(Q9.ArrowUpRight,{size:y-2,color:"var(--archik-fg-muted)",strokeWidth:2.2})})]})}function Eln({cx:o,cy:c,onClick:u,size:p=14}){return(0,_d.jsxs)("g",{transform:`translate(${o-p/2}, ${c-p/2})`,style:{cursor:u?"pointer":"default"},onClick:u,children:[(0,_d.jsx)("title",{children:"Open sub-architecture"}),(0,_d.jsx)("circle",{cx:p/2,cy:p/2,r:p/2+.5,fill:"var(--archik-accent)",fillOpacity:.16,stroke:"var(--archik-accent)",strokeOpacity:.45,strokeWidth:1}),(0,_d.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,_d.jsx)(Q9.ChevronDown,{size:p-2,color:"var(--archik-accent)",strokeWidth:2.2})})]})}function Pln({cx:o,cy:c,files:u,count:p,size:f=14}){let y=u.length===1?`Open sequence diagram \u2192 ${u[0].label} (${u[0].path})`:`${u.length} sequence diagrams on this node:
|
|
519
519
|
`+u.map(w=>` \u2022 ${w.label}`).join(`
|
|
520
520
|
`)+`
|
|
521
521
|
Click to open the first; the rest live in the inspector.`;return(0,_d.jsxs)("g",{transform:`translate(${o-f/2}, ${c-f/2})`,style:{cursor:"pointer"},children:[(0,_d.jsx)("title",{children:y}),(0,_d.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,_d.jsx)("g",{transform:"translate(1, 1)",pointerEvents:"none",children:(0,_d.jsx)(Q9.GitBranch,{size:f-2,color:"var(--archik-status-proposed)",strokeWidth:2.2})}),p!==void 0&&p>1&&(0,_d.jsxs)("g",{pointerEvents:"none",children:[(0,_d.jsx)("circle",{cx:f/2,cy:-3,r:5.5,fill:"var(--archik-canvas)"}),(0,_d.jsx)("circle",{cx:f/2,cy:-3,r:4.5,fill:"var(--archik-status-proposed)"}),(0,_d.jsx)("text",{x:f/2,y:-.5,fontSize:7.5,fontWeight:700,fill:"#ffffff",textAnchor:"middle",children:p})]})]})}function Lln(o,c,u,p=!1){if(p)return{right:{x:c-14,y:42}};switch(o){case"queue":{let y=Math.min(u/2,28);return{right:{x:c-y-4,y:14}}}case"database":return{right:{x:c-14,y:u-11}};case"module":case"custom":return{right:{x:c-14,y:42}};default:return{right:{x:c-14,y:14}}}}function Tln(o,c){return Array.from({length:c},(u,p)=>({x:o.x-p*t8r,y:o.y}))}var hl=mi(hc(),1);function n8r({node:o,selected:c,viewMode:u,depth:p}){if(u==="compact")return(0,hl.jsx)(xln,{node:o,selected:c,depth:p});if(o.children.length>0)return(0,hl.jsx)(kln,{node:o,selected:c,depth:p});switch(o.kind){case"queue":return(0,hl.jsx)(yln,{node:o,selected:c});case"external":case"human":return(0,hl.jsx)(bln,{node:o,selected:c});case"database":return(0,hl.jsx)(mln,{node:o,selected:c});case"cloud":return(0,hl.jsx)(vln,{node:o,selected:c});case"module":case"custom":case"service":case"function":case"worker":case"agent":case"cache":case"vectordb":case"storage":case"model":case"dto":case"dataobject":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,hl.jsx)(gln,{node:o,selected:c});default:{let f=o.kind;throw new Error("unreachable node kind")}}}function y2t({node:o,selectedNodeIds:c,glowNodeIds:u,onSelectNode:p,onOpenSubFile:f,onCrossFileNavigate:y,crossFileByNode:w,viewMode:v="detailed",depth:_=0,showStereotypeBands:T=!0}){let R=c?.has(o.id)??!1,F=u?.has(o.id)??!1,B=o.children.length>0,V=B?_+1:_,se=p?ce=>{ce.stopPropagation(),p(o.id,ce)}:void 0,ee=o.description!==void 0&&o.description.length>0;return(0,hl.jsxs)("g",{"data-archik-node-id":o.id,...R?{"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})`,...se!==void 0?{onClick:se}:{},style:p?{cursor:"pointer"}:void 0,children:[F&&(0,hl.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,hl.jsx)(n8r,{node:o,selected:R,viewMode:v,depth:_}),o.stereotype!==void 0&&T&&(0,hl.jsxs)(hl.Fragment,{children:[(0,hl.jsx)("clipPath",{id:`archik-nclip-${o.id}`,children:o.kind==="database"?(0,hl.jsx)("path",{d:f2t(o.width,o.height,h2t)}):(0,hl.jsx)("rect",{width:o.width,height:o.height,rx:8,ry:8})}),(0,hl.jsx)("rect",{className:"archik-stereotype-band",x:0,y:0,width:o.width,height:4,clipPath:`url(#archik-nclip-${o.id})`,style:{pointerEvents:"none"}})]}),v==="detailed"&&(()=>{let ce=o.notes!==void 0&&o.notes.length>0,ge=o.archikFile!==void 0&&o.archikFile.length>0,Oe=w?.get(o.id),ut=Oe?Array.from(Oe).sort():[],Se=o.seqFiles??[],je=[];ge&&je.push("subarch"),Se.length>0&&je.push({type:"seq",paths:Se});for(let Gt of ut)je.push({type:"crossfile",path:Gt});if(ee&&je.push("info"),ce&&je.push("notes"),je.length===0)return null;let Be=Lln(o.kind,o.width,o.height,B),tn=Tln(Be.right,je.length);return(0,hl.jsx)(hl.Fragment,{children:je.map((Gt,xn)=>{let Vn=tn[xn];if(typeof Gt=="object"&&Gt.type==="seq"){let nn=Gt.paths.map(Nr=>({path:Nr,label:Nr.split("/").pop().replace(/\.archik\.seq\.yaml$/,"")})),cn=`/__archik/seq?path=${encodeURIComponent(nn[0].path)}`;return(0,hl.jsx)("a",{href:cn,onClick:Nr=>Nr.stopPropagation(),children:(0,hl.jsx)(Pln,{cx:Vn.x,cy:Vn.y,files:nn,count:nn.length})},"seq")}if(typeof Gt=="object"&&Gt.type==="crossfile"){let nn=Gt.path,cn=nn.split("/").pop().replace(/\.archik\.yaml$/,""),Nr=y??f,oi=Nr?wo=>{wo.stopPropagation(),Nr(nn,cn)}:void 0;return(0,hl.jsx)(Iln,{cx:Vn.x,cy:Vn.y,filePath:nn,fileLabel:cn,...oi?{onClick:oi}:{}},`xf-${nn}`)}if(Gt==="subarch"){let nn=o.archikFile,cn=f?Nr=>{Nr.stopPropagation(),f(nn,o.name)}:void 0;return(0,hl.jsx)(Eln,{cx:Vn.x,cy:Vn.y,...cn?{onClick:cn}:{}},"subarch")}return Gt==="info"?(0,hl.jsx)(_ln,{cx:Vn.x,cy:Vn.y,color:"var(--archik-node-caption)"},"info"):(0,hl.jsxs)("g",{children:[(0,hl.jsx)(Cln,{cx:Vn.x,cy:Vn.y,color:"var(--archik-node-caption)"}),o.notes&&o.notes.length>1&&(0,hl.jsx)("text",{x:Vn.x+7,y:Vn.y-5,fontSize:8,fontWeight:700,fill:"var(--archik-accent)",textAnchor:"middle",pointerEvents:"none",children:o.notes.length})]},"notes")})})})(),o.children.map(ce=>(0,hl.jsx)(y2t,{node:ce,viewMode:v,depth:V,showStereotypeBands:T,...c!==void 0?{selectedNodeIds:c}:{},...u!==void 0?{glowNodeIds:u}:{},...p!==void 0?{onSelectNode:p}:{},...f!==void 0?{onOpenSubFile:f}:{},...y!==void 0?{onCrossFileNavigate:y}:{},...w!==void 0?{crossFileByNode:w}:{}},ce.id))]})}var F3=mi(hc(),1),f6="var(--archik-edge-filled)",dne="var(--archik-edge-dim)",r8r={http_call:{stroke:f6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,head:"filled"},grpc:{stroke:f6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,head:"filled"},invokes:{stroke:f6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,head:"filled"},routes_to:{stroke:f6,strokeWidth:1.4,head:"filled"},websocket:{stroke:f6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,head:"filled",startHead:"filled"},webhook:{stroke:f6,strokeWidth:1.4,strokeDasharray:"2 6",animated:!0,head:"filled"},reads:{stroke:f6,strokeWidth:1.4,head:"open"},writes:{stroke:f6,strokeWidth:1.4,head:"filled"},publishes:{stroke:f6,strokeWidth:1.4,head:"filled"},subscribes:{stroke:f6,strokeWidth:1.4,head:"filled"},streams_to:{stroke:f6,strokeWidth:1.4,head:"filled"},implements:{stroke:dne,strokeWidth:1.2,strokeDasharray:"7 5",head:"triangle"},extends:{stroke:dne,strokeWidth:1.2,head:"triangle"},depends_on:{stroke:dne,strokeWidth:1.2,strokeDasharray:"7 5",head:"open"},has_a:{stroke:dne,strokeWidth:1.2,head:"open",startHead:"diamond"},uses:{stroke:dne,strokeWidth:1.2,head:"open"}};function Aln(o){return o.map(c=>`${c.x},${c.y}`).join(" ")}function i8r(o){if(o.length===0)return;let c=Math.floor(o.length/2);if(o.length%2===1)return o[c];let u=o[c-1],p=o[c];return{x:(u.x+p.x)/2,y:(u.y+p.y)/2}}function Nln({edge:o,selectedEdgeIds:c,onSelectEdge:u}){let p=o.sections[0];if(!p)return null;let f=[p.startPoint,...p.bendPoints,p.endPoint],y=r8r[o.relationship],w=o.labels[0],v=w?{x:w.x+w.width/2,y:w.y+w.height/2}:i8r(f),_=c?.has(o.id)??!1,T=o.status==="proposed"?"var(--archik-status-proposed)":o.status==="deprecated"?"var(--archik-status-deprecated)":void 0,R=_?"var(--archik-selected)":T??o.color??y.stroke,F=_?y.strokeWidth+.5:y.strokeWidth,B=!_&&y.animated?"archik-edge-flowing":void 0,V=f[f.length-1],se=f[f.length-2]??V,ee=f[0],ce=f[1]??ee,ge=_?"filled":y.head,Oe=_?void 0:y.startHead,ut=y.strokeDasharray!==void 0?y.strokeDasharray.trim().split(/\s+/).reduce((Be,tn)=>Be+Number(tn),0):0,Se=B!==void 0&&ut>0?{"--archik-dash-period":String(ut)}:void 0,je=u?Be=>{Be.stopPropagation(),u(o.id,Be)}:void 0;return(0,F3.jsxs)("g",{"data-archik-edge-id":o.id,"data-archik-edge-relationship":o.relationship,..._?{"data-archik-selected":"true"}:{},...o.status!==void 0&&o.status!=="active"?{"data-archik-status":o.status}:{},className:`archik-edge archik-edge--${o.relationship}`,...je!==void 0?{onClick:je}:{},style:u?{cursor:"pointer"}:void 0,children:[u&&(0,F3.jsx)("polyline",{"data-archik-edge-hitarea":"",points:Aln(f),fill:"none",stroke:"transparent",strokeWidth:14,strokeLinecap:"round",strokeLinejoin:"round"}),(0,F3.jsx)("polyline",{className:B,points:Aln(f),fill:"none",stroke:R,strokeWidth:F,strokeLinecap:"round",strokeLinejoin:"round",...y.strokeDasharray!==void 0?{strokeDasharray:y.strokeDasharray}:{},...Se!==void 0?{style:Se}:{}}),ge==="filled"&&(0,F3.jsx)("path",{"data-archik-arrowhead":"end",d:AG(V,se),fill:R}),ge==="open"&&(0,F3.jsx)("path",{"data-archik-arrowhead":"end",d:JOe(V,se),fill:"none",stroke:R,strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"}),ge==="triangle"&&(0,F3.jsx)("path",{"data-archik-arrowhead":"end",d:cln(V,se),fill:"var(--archik-panel)",stroke:R,strokeWidth:1.8,strokeLinejoin:"round"}),Oe==="filled"&&(0,F3.jsx)("path",{"data-archik-arrowhead":"start",d:AG(ee,ce),fill:R}),Oe==="diamond"&&(0,F3.jsx)("path",{"data-archik-arrowhead":"start",d:aln(ee,ce),fill:R}),o.label!==void 0&&v!==void 0&&(0,F3.jsx)("g",{transform:`translate(${v.x}, ${w?v.y+4:v.y-6})`,children:(0,F3.jsx)("text",{textAnchor:"middle",fontSize:11,fontWeight:_?700:500,fill:_?"var(--archik-selected)":"var(--archik-fg-dim)",stroke:"var(--archik-panel)",strokeWidth:_?4:3,paintOrder:"stroke",children:o.label})})]})}var pb=mi(hc(),1);var b2t={added:"var(--archik-success)",removed:"var(--archik-danger)",changed:"var(--archik-warning)"};function o8r(o){let c=[],u=(p,f,y)=>{for(let w of p){let v=f+w.x,_=y+w.y;c.push({...w,absX:v,absY:_}),w.children.length>0&&u(w.children,v,_)}};return u(o,0,0),c}function c8r(o){return o.replace(/[^a-z0-9-]/g,c=>`\\${c}`)}function Oln({statuses:o,scopeClass:c}){let u=[];for(let[f,y]of o.nodes)y==="removed"&&u.push(f);if(u.length===0)return null;let p=u.map(f=>`.${c} [data-archik-node-id="${c8r(f)}"] { opacity: 0.35; }`).join(`
|
|
@@ -223,4 +223,4 @@ ${nWn(p)}
|
|
|
223
223
|
`)}function cWn(f,d){const p=d.get(f.from)?.name??f.from,m=d.get(f.to)?.name??f.to,E=f.label!==void 0?`: ${f.label}`:"",M=f.status&&f.status!=="active"?` _(${f.status})_`:"";return`- ${p} **${f.relationship}** ${m}${E}${M}`}function sWn(f){const d=new Map;for(const m of f.nodes)d.set(m.id,m);const p=[];if(p.push(`# ${f.name}`),f.description!==void 0&&p.push("",f.description),p.push("","## Components"),f.nodes.length===0)p.push("","_No components yet._");else for(const m of f.nodes)p.push("",rWn(m));if(p.push("","## Connections"),f.edges.length===0)p.push("","_No connections yet._");else{p.push("");for(const m of f.edges)p.push(cWn(m,d))}return`${p.join(`
|
|
224
224
|
`)}
|
|
225
225
|
`}const uWn={name:"yaml",label:"YAML",extension:".yaml",mime:"application/yaml",export:oje},oWn={name:"json",label:"JSON",extension:".json",mime:"application/json",export:ibn},lWn={name:"markdown",label:"Markdown",extension:".md",mime:"text/markdown",export:sWn},fWn=[uWn,oWn,lWn];function fbn({document:f,filename:d,getSvg:p}){const m=async k=>{try{await navigator.clipboard.writeText(k)}catch{}},E=()=>{const k=p?.();k&&q1n(G1n(d,"svg"),tWn(k))},M=async()=>{const k=p?.();if(k)try{const D=await iWn(k);q1n(G1n(d,"png"),D)}catch(D){console.error("PNG export failed:",D)}};return I.jsx(u7,{trigger:k=>I.jsxs("button",{type:"button",className:"archik-btn",children:["Export",I.jsx("span",{style:{opacity:.6},children:k?"▴":"▾"})]}),children:k=>I.jsxs(I.Fragment,{children:[f&&fWn.map(D=>I.jsxs("button",{type:"button",className:"archik-menu-item",onClick:()=>{m(D.export(f)),k()},children:[I.jsx("span",{style:{minWidth:60,color:"var(--archik-fg-dim)"},children:"Copy"}),I.jsx("span",{children:D.label})]},D.name)),f&&I.jsxs(I.Fragment,{children:[I.jsx("hr",{style:{border:0,borderTop:"1px solid var(--archik-border)",margin:"4px 0"}}),I.jsxs("button",{type:"button",className:"archik-menu-item",onClick:()=>{oVn(d,f),k()},children:[I.jsx("span",{style:{minWidth:60,color:"var(--archik-fg-dim)"},children:"Download"}),I.jsx("span",{children:"YAML"})]})]}),p&&I.jsxs(I.Fragment,{children:[I.jsxs("button",{type:"button",className:"archik-menu-item",onClick:()=>{E(),k()},children:[I.jsx("span",{style:{minWidth:60,color:"var(--archik-fg-dim)"},children:"Download"}),I.jsx("span",{children:"SVG"})]}),I.jsxs("button",{type:"button",className:"archik-menu-item",onClick:()=>{M(),k()},children:[I.jsx("span",{style:{minWidth:60,color:"var(--archik-fg-dim)"},children:"Download"}),I.jsx("span",{children:"PNG"})]})]})]})})}const abn="archik-density",hbn="archik-view-mode",dbn="archik-show-stereotype-bands",pI=1,Y8e="detailed",Q8e=!1;function aWn(){if(typeof localStorage>"u")return Q8e;try{const f=localStorage.getItem(dbn);return f==="true"?!0:f==="false"?!1:Q8e}catch{return Q8e}}function hWn(f){if(!(typeof localStorage>"u"))try{localStorage.setItem(dbn,f?"true":"false")}catch{}}function dWn(){if(typeof localStorage>"u")return Y8e;try{return localStorage.getItem(hbn)==="compact"?"compact":Y8e}catch{return Y8e}}function bWn(f){if(!(typeof localStorage>"u"))try{localStorage.setItem(hbn,f)}catch{}}function gWn(){if(typeof localStorage>"u")return pI;try{const f=localStorage.getItem(abn);if(!f)return pI;const d=Number.parseFloat(f);return Number.isFinite(d)?fje(d):pI}catch{return pI}}function wWn(f){if(!(typeof localStorage>"u"))try{localStorage.setItem(abn,String(fje(f)))}catch{}}function fje(f){return Math.max(.3,Math.min(4,f))}function pWn(f){const d=fje(f);return{nodeSpacing:Math.round(60*d),layerSpacing:Math.round(100*d),padding:Math.round(40*d)}}function mWn({density:f,onChange:d}){const p=Math.round(f*100);return I.jsx(u7,{align:"end",trigger:m=>I.jsxs("button",{type:"button",className:"archik-btn","aria-expanded":m,title:"Layout density",children:["Spacing",I.jsxs("span",{style:{opacity:.6},children:[p,"%"]})]}),children:()=>I.jsxs("div",{style:{minWidth:"min(240px, calc(100vw - 16px))",padding:8},children:[I.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:6},children:[I.jsx("span",{className:"archik-label",style:{margin:0},children:"Node spacing"}),I.jsxs("span",{className:"archik-mono",style:{fontSize:11,color:"var(--archik-fg-dim)"},children:[p,"%"]})]}),I.jsx("input",{type:"range",min:.3,max:4,step:.1,value:f,onChange:m=>d(Number.parseFloat(m.target.value)),style:{width:"100%",accentColor:"var(--archik-accent)"}}),I.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:10,color:"var(--archik-fg-muted)",marginTop:4},children:[I.jsx("span",{children:"tight"}),I.jsx("span",{children:"roomy"})]}),I.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:10},children:I.jsx("button",{type:"button",className:"archik-btn",onClick:()=>d(pI),disabled:f===pI,children:"Reset"})})]})})}function vWn(){return I.jsx(u7,{align:"end",trigger:f=>I.jsxs("button",{type:"button",className:"archik-btn","aria-expanded":f,children:["Legend",I.jsx("span",{style:{opacity:.6},children:f?"▴":"▾"})]}),children:()=>I.jsxs("div",{style:{minWidth:"min(320px, calc(100vw - 16px))",maxHeight:"min(70vh, 520px)",overflowY:"auto",padding:6},children:[I.jsx(aje,{first:!0,children:"Node kinds"}),sje.map(f=>{const d=zp[f],p=d.icon;return I.jsxs("div",{style:{display:"grid",gridTemplateColumns:"20px 80px 1fr",alignItems:"center",gap:8,padding:"5px 6px",fontSize:12},children:[I.jsx("span",{"aria-hidden":"true",style:{display:"flex",alignItems:"center",justifyContent:"center",color:d.color},children:I.jsx(p,{size:14,strokeWidth:1.8})}),I.jsx("code",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--archik-fg)",fontSize:11},children:f}),I.jsx("span",{style:{color:"var(--archik-fg-dim)"},children:d.description})]},f)}),I.jsx(kWn,{}),I.jsx(SWn,{})]})})}const yWn=[{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 kWn(){return I.jsxs(I.Fragment,{children:[I.jsx(aje,{first:!1,children:"Stereotype (ECB)"}),yWn.map(f=>I.jsxs("div",{style:{display:"grid",gridTemplateColumns:"20px 80px 1fr",alignItems:"center",gap:8,padding:"5px 6px",fontSize:12},children:[I.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",width:12,height:12,borderRadius:3,background:`var(${f.varName})`}}),I.jsx("code",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--archik-fg)",fontSize:11},children:f.id}),I.jsx("span",{style:{color:"var(--archik-fg-dim)"},children:f.description})]},f.id))]})}function aje({first:f,children:d}){return I.jsx("div",{style:{position:"sticky",top:0,background:"var(--archik-panel)",fontSize:10,letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--archik-fg-muted)",zIndex:1,...f===!0?{padding:"4px 6px 8px"}:{padding:"12px 6px 8px",marginTop:6,borderTop:"1px solid var(--archik-border)"}},children:d})}function jWn({relationship:f}){const d=ydn[f],p={x:48,y:7},m={x:14,y:7};return I.jsxs("svg",{width:64,height:14,"aria-hidden":"true",children:[I.jsx("line",{x1:14,y1:7,x2:48,y2:7,stroke:d.stroke,strokeWidth:d.strokeWidth,...d.strokeDasharray!==void 0?{strokeDasharray:d.strokeDasharray}:{}}),d.head==="filled"&&I.jsx("path",{d:jI(p,m),fill:d.stroke}),d.head==="open"&&I.jsx("path",{d:$7e(p,m),fill:"none",stroke:d.stroke,strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"}),d.head==="triangle"&&I.jsx("path",{d:mdn(p,m),fill:"var(--archik-panel)",stroke:d.stroke,strokeWidth:1.8,strokeLinejoin:"round"}),d.startHead==="filled"&&I.jsx("path",{d:jI(m,p),fill:d.stroke}),d.startHead==="diamond"&&I.jsx("path",{d:vdn(m,p),fill:d.stroke})]})}function SWn(){const f=Ase.filter(p=>v7e(p)==="runtime"),d=Ase.filter(p=>v7e(p)==="structural");return I.jsxs(I.Fragment,{children:[I.jsx(aje,{first:!1,children:"Relationships"}),[["Runtime",f],["Structural (UML)",d]].map(([p,m])=>I.jsxs("div",{children:[I.jsx("div",{style:{fontSize:10,color:"var(--archik-fg-muted)",padding:"4px 6px 2px"},children:p}),m.map(E=>I.jsxs("div",{style:{display:"grid",gridTemplateColumns:"64px 90px 1fr",alignItems:"center",gap:8,padding:"5px 6px",fontSize:12},children:[I.jsx(jWn,{relationship:E}),I.jsx("code",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--archik-fg)",fontSize:11},children:E}),I.jsx("span",{style:{color:"var(--archik-fg-dim)"},children:GXn[E]})]},E))]},p))]})}function EWn({size:f=22}){return I.jsxs("svg",{width:f,height:f,viewBox:"0 0 24 24",fill:"none",role:"img","aria-label":"Archik",style:{display:"block"},children:[I.jsx("path",{d:"M 12 5 L 5 18",stroke:"var(--archik-accent)",strokeWidth:"1.4",strokeLinecap:"round"}),I.jsx("path",{d:"M 12 5 L 19 18",stroke:"var(--archik-accent-bright)",strokeWidth:"1.4",strokeLinecap:"round"}),I.jsx("path",{d:"M 5 18 L 19 18",stroke:"var(--archik-magenta)",strokeWidth:"1.2",strokeLinecap:"round",strokeDasharray:"2.5 2.5"}),I.jsx("circle",{cx:"12",cy:"5",r:"2.6",fill:"var(--archik-accent)"}),I.jsx("circle",{cx:"5",cy:"18",r:"2.6",fill:"var(--archik-accent-bright)"}),I.jsx("circle",{cx:"19",cy:"18",r:"2.6",fill:"var(--archik-magenta)"})]})}const xWn=8;function AWn(f,d){const p=d.trim().toLowerCase();if(p==="")return[];const m=[];for(const E of f){const M=E.id.toLowerCase(),k=E.name.toLowerCase();let D=-1;M===p||k===p?D=0:M.startsWith(p)||k.startsWith(p)?D=1:M.includes(p)||k.includes(p)?D=2:E.owner?.toLowerCase().includes(p)??!1?D=3:E.kind.toLowerCase()===p?D=4:(E.description?.toLowerCase().includes(p)??!1)&&(D=5),D>=0&&m.push({node:E,score:D})}return m.sort((E,M)=>E.score-M.score||E.node.id.localeCompare(M.node.id)).slice(0,xWn).map(E=>E.node)}function TWn({document:f}){const[d,p]=Fn.useState(""),[m,E]=Fn.useState(0),[M,k]=Fn.useState(!1),D=Fn.useRef(null),z=Nf(se=>se.selectNode),U=Fn.useMemo(()=>AWn(f.nodes,d),[f.nodes,d]),ee=M&&U.length>0;Fn.useEffect(()=>{const se=pe=>{if(pe.key!=="/"||pe.metaKey||pe.ctrlKey||pe.altKey)return;const Je=pe.target,ie=Je?.tagName;ie==="INPUT"||ie==="TEXTAREA"||Je?.isContentEditable||(pe.preventDefault(),D.current?.focus())};return window.addEventListener("keydown",se),()=>window.removeEventListener("keydown",se)},[]);const ce=se=>{z(se.id),p(""),E(0),D.current?.blur()};return I.jsxs("div",{className:"relative",style:{minWidth:180},children:[I.jsx(Tqn,{size:13,strokeWidth:1.8,"aria-hidden":!0,style:{position:"absolute",left:8,top:"50%",transform:"translateY(-50%)",color:"var(--archik-fg-dim)",pointerEvents:"none"}}),I.jsx("input",{ref:D,type:"search",role:"combobox","aria-expanded":ee,"aria-label":"Search nodes",placeholder:"Search nodes ( / )",value:d,onChange:se=>{p(se.target.value),E(0)},onFocus:()=>k(!0),onBlur:()=>{setTimeout(()=>k(!1),120)},onKeyDown:se=>{if(se.key==="Escape"){p(""),D.current?.blur();return}if(U.length!==0){if(se.key==="ArrowDown")se.preventDefault(),E(pe=>(pe+1)%U.length);else if(se.key==="ArrowUp")se.preventDefault(),E(pe=>(pe-1+U.length)%U.length);else if(se.key==="Enter"){se.preventDefault();const pe=U[m];pe!==void 0&&ce(pe)}}},className:"archik-input w-full",style:{paddingLeft:26,fontSize:12}}),ee&&I.jsx("ul",{role:"listbox","aria-label":"Node search results",className:"absolute z-50 mt-1 w-72 overflow-hidden rounded-md",style:{background:"var(--archik-panel)",border:"1px solid var(--archik-border)",boxShadow:"0 8px 24px rgba(0,0,0,0.25)",listStyle:"none",margin:"4px 0 0",padding:4},children:U.map((se,pe)=>I.jsx("li",{role:"option","aria-selected":pe===m,children:I.jsxs("button",{type:"button",onMouseDown:Je=>{Je.preventDefault(),ce(se)},onMouseEnter:()=>E(pe),className:"flex w-full items-baseline gap-2 rounded px-2 py-1.5 text-left",style:{background:pe===m?"var(--archik-accent-soft, rgba(99,102,241,0.18))":"transparent",color:"var(--archik-fg)",fontSize:12},children:[I.jsx("span",{className:"archik-mono",style:{fontSize:11},children:se.id}),I.jsx("span",{style:{color:"var(--archik-fg-dim)",fontSize:11},children:se.kind}),I.jsx("span",{className:"truncate",style:{color:"var(--archik-fg-dim)",fontSize:11,marginLeft:"auto"},children:se.name})]})},se.id))})]})}const MWn="archik-theme";function A7e(){return typeof document>"u"?"dark":document.documentElement.getAttribute("data-theme")==="light"?"light":"dark"}function CWn(f){if(!(typeof document>"u")){document.documentElement.setAttribute("data-theme",f);try{localStorage.setItem(MWn,f)}catch{}}}function OWn(){const f=A7e()==="dark"?"light":"dark";return CWn(f),f}function _Wn(){const[f,d]=Fn.useState(()=>A7e());Fn.useEffect(()=>{d(A7e())},[]);const p=()=>{d(OWn())},m=f==="dark"?"Light theme":"Dark theme",E=f==="dark"?"☀":"☾";return I.jsx("button",{type:"button",onClick:p,title:m,"aria-label":m,className:"archik-btn",style:{minWidth:30,justifyContent:"center"},children:I.jsx("span",{"aria-hidden":"true",children:E})})}const NWn="/__archik/usecases",IWn="/__archik/trace",$Wn="/__archik/traces";async function e7e(f,d){const p=await fetch(f,{cache:"no-store",signal:d});if(!p.ok)throw new Error(`HTTP ${p.status} ${p.statusText}`);return await p.json()}function DWn(){const[f,d]=Fn.useState({status:"loading"}),[p,m]=Fn.useState(0);return Fn.useEffect(()=>{let E=!1;const M=new AbortController;return Promise.all([e7e(NWn,M.signal),e7e(IWn,M.signal),e7e($Wn,M.signal).catch(()=>({ok:!0,traces:[]}))]).then(([k,D,z])=>{E||d({status:"ready",useCases:k.useCases??[],trace:D.rows??[],traceDocs:z.traces??[]})}).catch(k=>{E||M.signal.aborted||d({status:"error",message:k instanceof Error?k.message:String(k)})}),()=>{E=!0,M.abort()}},[p]),I.jsx(u7,{align:"end",trigger:E=>I.jsxs("button",{type:"button",className:"archik-btn","aria-expanded":E,onClick:()=>{E||m(M=>M+1)},children:[I.jsx(LWn,{state:f}),I.jsx("span",{style:{opacity:.6,marginLeft:6},children:E?"▴":"▾"})]}),children:()=>I.jsx(RWn,{state:f})})}function LWn({state:f}){if(f.status!=="ready"||f.trace.length===0)return I.jsx(I.Fragment,{children:"Use cases"});const d=bbn(f.trace);return d.none>0?I.jsxs("span",{title:`${d.none} untraced — needs tests + seq`,children:["Use cases"," ",I.jsxs("span",{style:{color:"var(--archik-danger)"},children:["○ ",d.none," untraced"]})]}):d.partial>0?I.jsxs("span",{title:`${d.partial} partial — missing test or realisation`,children:["Use cases"," ",I.jsxs("span",{style:{color:"var(--archik-warning)"},children:["◐ ",d.partial," to finish"]})]}):I.jsxs("span",{title:`All ${d.full} slices traced — ready to ship`,children:["Use cases"," ",I.jsx("span",{style:{color:"var(--archik-success)",fontWeight:600},children:"✓ all traced"})]})}function bbn(f){let d=0,p=0,m=0;for(const E of f)E.level==="full"?d++:E.level==="partial"?p++:m++;return{full:d,partial:p,none:m}}function RWn({state:f}){return I.jsxs("div",{style:{minWidth:360,maxHeight:"min(70vh, 560px)",overflowY:"auto",padding:6},children:[I.jsx(UWn,{label:"Use cases",children:I.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 →"})}),f.status==="loading"&&I.jsx(n7e,{children:"Loading…"}),f.status==="error"&&I.jsxs(n7e,{tone:"error",children:["Couldn't load: ",f.message]}),f.status==="ready"&&f.useCases.length===0&&I.jsxs(n7e,{children:["No use cases defined. Add a ",I.jsx("code",{children:"*.archik.uc.yaml"})," file under"," ",I.jsx("code",{children:".archik/usecases/"}),"."]}),f.status==="ready"&&f.useCases.length>0&&I.jsxs(I.Fragment,{children:[I.jsx(PWn,{trace:f.trace}),I.jsx(zWn,{useCases:f.useCases,trace:f.trace,traceDocs:f.traceDocs})]})]})}function PWn({trace:f}){const d=Fn.useMemo(()=>bbn(f),[f]),p=f.length;return p===0?I.jsx(I.Fragment,{}):I.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:[I.jsx("span",{style:{fontWeight:600,color:"var(--archik-fg)"},children:"Trace"}),I.jsxs("span",{children:[I.jsx("span",{style:{color:"var(--archik-success)"},children:"●"})," ",d.full," full"]}),I.jsxs("span",{children:[I.jsx("span",{style:{color:"var(--archik-warning)"},children:"◐"})," ",d.partial," partial"]}),I.jsxs("span",{children:[I.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"○"})," ",d.none," untraced"]}),I.jsxs("span",{style:{marginLeft:"auto",color:"var(--archik-fg-muted)"},children:[p," ",p===1?"slice":"slices"]})]})}function zWn({useCases:f,trace:d,traceDocs:p}){const m=Fn.useMemo(()=>{const M=new Map;for(const k of d)M.set(`${k.useCase}/${k.slice}`,k.level);return M},[d]),E=Fn.useMemo(()=>{const M=new Map;for(const k of p)M.set(`${k.useCase}/${k.slice}`,k);return M},[p]);return I.jsx("div",{children:f.map(M=>I.jsx(BWn,{uc:M,traceByKey:m,traceDocByKey:E},M.id))})}function BWn({uc:f,traceByKey:d,traceDocByKey:p}){return I.jsxs("div",{style:{padding:"8px 8px 6px",borderTop:"1px solid var(--archik-border)"},children:[I.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,marginBottom:2},children:[I.jsx("code",{style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:12,color:"var(--archik-fg)"},children:f.id}),I.jsx("span",{style:{color:"var(--archik-fg-dim)",fontSize:11},children:f.name}),f.status&&f.status!=="active"&&I.jsx("span",{className:"archik-pill",style:{fontSize:9,marginLeft:"auto"},children:f.status})]}),I.jsxs("div",{style:{color:"var(--archik-fg-muted)",fontSize:11},children:["primary ",I.jsx("code",{children:f.primaryActor}),f.secondaryActors&&f.secondaryActors.length>0&&I.jsxs(I.Fragment,{children:[" ","· secondary"," ",f.secondaryActors.map((m,E)=>I.jsxs("span",{children:[E>0&&", ",I.jsx("code",{children:m})]},m))]})]}),I.jsx("ul",{style:{marginTop:6,listStyle:"none",padding:0},children:f.slices.map(m=>{const E=d.get(`${f.id}/${m.id}`),M=p.get(`${f.id}/${m.id}`);return I.jsx(FWn,{slice:m,level:E,useCaseId:f.id,traceDoc:M},m.id)})})]})}function FWn({slice:f,level:d,useCaseId:p,traceDoc:m}){const[E,M]=Fn.useState(!1);return I.jsxs("li",{style:{padding:"3px 0"},children:[I.jsxs("button",{type:"button",onClick:()=>M(k=>!k),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":E,children:[I.jsx(GWn,{level:d}),I.jsxs("span",{style:{fontSize:12,color:"var(--archik-fg)",display:"flex",alignItems:"baseline",gap:6},children:[I.jsx("code",{children:f.id}),f.status&&f.status!=="active"&&I.jsxs("span",{style:{color:"var(--archik-fg-dim)",fontSize:10},children:["[",f.status,"]"]}),I.jsx("span",{style:{color:"var(--archik-fg-dim)",fontSize:11,marginLeft:"auto"},children:(()=>{const k=f.tests?.length??0,D=`${k} ${k===1?"test":"tests"}`,z=f.realization?"realized":"no seq";return`${D} • ${z}`})()}),m&&I.jsx("span",{title:"Has a recorded concrete run","aria-label":"has concrete run",style:{color:"var(--archik-accent)",fontSize:11,marginLeft:2},children:"●"})]})]}),E&&I.jsxs("div",{style:{paddingLeft:24,color:"var(--archik-fg-dim)",fontSize:11,paddingBottom:4},children:[I.jsx("div",{style:{color:"var(--archik-fg)",marginBottom:4,lineHeight:1.4},children:f.description}),f.tests&&f.tests.length>0&&I.jsxs("div",{children:["tests:"," ",f.tests.map((k,D)=>I.jsxs("code",{children:[D>0&&", ",k]},k))]}),f.realization&&I.jsxs("div",{children:["realises: ",I.jsx("code",{children:f.realization.seqFile})]}),m&&I.jsx("div",{style:{marginTop:4},children:I.jsxs("a",{href:`/__archik/trace-page?path=${encodeURIComponent(m.relPath)}&from-uc=${encodeURIComponent(p)}`,style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-accent)",textDecoration:"none",fontSize:11},title:`Open the concrete run (${m.steps} steps)`,children:["● Concrete run",I.jsxs("span",{style:{color:"var(--archik-fg-muted)"},children:[" ",m.recordedAt]})]})}),!f.tests?.length&&!f.realization&&!m&&I.jsx("div",{children:"(no tests, no realisation)"})]})]})}const qWn={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 GWn({level:f}){const d=qWn[f??"missing"];return I.jsx("span",{title:d.title,"aria-label":d.title,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,fontSize:11,fontWeight:600,color:d.tone},children:d.glyph})}function UWn({label:f,children:d}){return I.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:[I.jsx("span",{children:f}),d]})}function n7e({children:f,tone:d}){return I.jsx("div",{style:{padding:"8px 8px 12px",fontSize:12,color:d==="error"?"var(--archik-status-deprecated, #f87171)":"var(--archik-fg-dim)"},children:f})}const HWn={idle:"",saving:"archik-pill archik-pill--info",saved:"archik-pill archik-pill--success",error:"archik-pill archik-pill--danger"},JWn={idle:null,saving:"Saving…",saved:"Saved",error:"Save failed"};function KWn({document:f,filename:d="architecture.archik.yaml",commandError:p,reloadError:m,saveStatus:E="idle",saveError:M,isDirty:k=!1,onSave:D,onAddNode:z,connectingFromName:U,onCancelConnect:ee,density:ce,onDensityChange:se,viewMode:pe,onViewModeChange:Je,showStereotypeBands:ie,onToggleStereotypeBands:Ye,canUndo:an=!1,canRedo:_n=!1,onUndo:hn,onRedo:Rn,getSvg:nt,seqHighlight:ot,onToggleSeqHighlight:et,seqNodeCount:gt,hideStructural:dr,onToggleHideStructural:tc,onCollapseAll:Lr,onExpandAll:Ni,focusDepth:Q,onFocusDepthChange:Pu,onClearFocus:zu}){const Hn=JWn[E],tt=typeof navigator<"u"&&/Mac/i.test(navigator.platform)?"⌘S":"Ctrl+S",di=i7("(max-width: 900px)"),br=i7("(max-width: 640px)"),jc=I.jsx(TWn,{document:f}),Ke=I.jsxs(I.Fragment,{children:[hn!==void 0&&I.jsx("button",{type:"button",onClick:hn,disabled:!an,title:`Undo (${tt.replace("S","Z")})`,"aria-label":"Undo",className:"archik-btn",style:{padding:"5px 8px"},children:I.jsx(Gqn,{size:14,strokeWidth:1.8})}),Rn!==void 0&&I.jsx("button",{type:"button",onClick:Rn,disabled:!_n,title:`Redo (${tt.replace("S","⇧Z").replace("Ctrl+","Ctrl+Shift+")})`,"aria-label":"Redo",className:"archik-btn",style:{padding:"5px 8px"},children:I.jsx(kqn,{size:14,strokeWidth:1.8})})]}),Yn=I.jsxs(I.Fragment,{children:[I.jsx(DWn,{}),I.jsx(KVn,{}),I.jsx(vWn,{}),I.jsx(fbn,{document:f,filename:d,...nt!==void 0?{getSvg:nt}:{}})]}),Ut=[];return pe!==void 0&&Je!==void 0&&Ut.push({key:"view-mode",label:pe==="compact"?"Detailed view":"Compact view",node:I.jsx("button",{type:"button",onClick:()=>Je(pe==="compact"?"detailed":"compact"),title:pe==="compact"?"Switch to detailed view":"Switch to compact view","aria-label":"Toggle view mode",className:"archik-btn",style:{padding:"5px 8px"},children:pe==="compact"?I.jsx(VFn,{size:14,strokeWidth:1.8}):I.jsx(xqn,{size:14,strokeWidth:1.8})})}),ie!==void 0&&Ye!==void 0&&Ut.push({key:"ecb",label:"ECB stereotype bands",node:I.jsx("button",{type:"button",onClick:Ye,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:I.jsx(zqn,{size:14,strokeWidth:1.8})})}),tc!==void 0&&Ut.push({key:"hide-weak",label:"Hide weak edges",node:I.jsx("button",{type:"button",onClick:tc,title:dr?"Show weak edges":"Hide weak edges (uses / depends_on / has_a / implements / extends)","aria-label":"Hide weak edges","aria-pressed":dr,className:"archik-btn",style:{padding:"5px 8px",...dr?{background:"var(--archik-accent)",borderColor:"var(--archik-accent)",color:"white"}:{}},children:I.jsx(NFn,{size:14,strokeWidth:1.8})})}),Lr!==void 0&&Ut.push({key:"collapse-all",label:"Collapse all containers",node:I.jsx("button",{type:"button",onClick:Lr,title:"Collapse all containers","aria-label":"Collapse all",className:"archik-btn",style:{padding:"5px 8px"},children:I.jsx(sqn,{size:14,strokeWidth:1.8})})}),Ni!==void 0&&Ut.push({key:"expand-all",label:"Expand all containers",node:I.jsx("button",{type:"button",onClick:Ni,title:"Expand all containers","aria-label":"Expand all",className:"archik-btn",style:{padding:"5px 8px"},children:I.jsx(tqn,{size:14,strokeWidth:1.8})})}),Q!==void 0&&Pu!==void 0&&zu!==void 0&&Ut.push({key:"focus",label:"Focus depth",node:I.jsxs("div",{role:"group","aria-label":"Focus mode",className:"archik-focus-control",style:{display:"flex",alignItems:"center",gap:2,height:28,padding:"0 4px",borderRadius:7,border:"1px solid var(--archik-accent)",background:"color-mix(in srgb, var(--archik-accent) 12%, var(--archik-panel))"},children:[I.jsx(odn,{size:13,strokeWidth:2,style:{color:"var(--archik-accent)"},"aria-hidden":"true"}),I.jsx("span",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.02em",color:"var(--archik-accent)",marginRight:2},children:"Focus"}),I.jsx("button",{type:"button","aria-label":"Decrease focus depth",title:"Show fewer hops",disabled:Q<=0,onClick:()=>Pu(Math.max(0,Q-1)),className:"archik-focus-step",children:I.jsx(oqn,{size:13,strokeWidth:2})}),I.jsx("span",{className:"archik-mono","aria-label":`Focus depth ${Q}`,style:{minWidth:16,textAlign:"center",fontSize:12,fontWeight:600,color:"var(--archik-fg)"},children:Q}),I.jsx("button",{type:"button","aria-label":"Increase focus depth",title:"Show more hops",onClick:()=>Pu(Q+1),className:"archik-focus-step",children:I.jsx(adn,{size:13,strokeWidth:2})}),I.jsx("span",{"aria-hidden":"true",style:{width:1,height:16,margin:"0 2px",background:"var(--archik-border)"}}),I.jsx("button",{type:"button","aria-label":"Clear focus",title:"Clear focus (Esc)",onClick:zu,className:"archik-focus-step",children:I.jsx(Wqn,{size:13,strokeWidth:2})})]})}),ce!==void 0&&se!==void 0&&Ut.push({key:"density",label:"Spacing",node:I.jsx(mWn,{density:ce,onChange:se})}),et!==void 0&&(gt??0)>0&&Ut.push({key:"seq-highlight",label:"Sequence highlights",node:I.jsx("button",{type:"button",onClick:et,title:ot?"Hide sequence diagram highlights":`Show ${gt} node${gt===1?"":"s"} with sequence diagrams`,"aria-label":"Toggle sequence diagram highlights","aria-pressed":ot,className:"archik-btn",style:{padding:"5px 8px",...ot?{background:"var(--archik-status-proposed)",borderColor:"var(--archik-status-proposed)",color:"white"}:{}},children:I.jsx(fdn,{size:14,strokeWidth:1.8})})}),I.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:[I.jsxs("div",{className:"flex items-center gap-2",children:[I.jsx(EWn,{}),I.jsx("span",{className:"text-sm font-semibold tracking-tight",style:{color:"var(--archik-fg)",letterSpacing:"0.02em"},children:"Archik"})]}),I.jsx("span",{className:"archik-mono",style:{color:"var(--archik-fg-dim)",fontSize:11,opacity:.85,...br?{maxWidth:90,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}:{}},children:f.name}),U!==void 0&&I.jsxs("span",{className:"archik-pill archik-pill--info",children:["Connecting from ",I.jsx("strong",{children:U}),I.jsx("button",{type:"button",onClick:ee,className:"underline hover:no-underline",style:{color:"var(--archik-accent)"},children:"cancel (Esc)"})]}),p!==void 0&&I.jsx("span",{className:"archik-pill archik-pill--danger",children:p}),m!==void 0&&I.jsx("span",{className:"archik-pill archik-pill--warning",title:m,children:"File reload error"}),Hn!==null&&I.jsx("span",{className:HWn[E],...E==="error"&&M!==void 0?{title:M}:{},children:Hn}),E==="error"&&M!==void 0&&!br&&I.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:ZWn(M)}),I.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[!br&&jc,!br&&Ke,z!==void 0&&I.jsx(GVn,{onAdd:z}),!di&&Ut.map(ci=>I.jsx(Fn.Fragment,{children:ci.node},ci.key)),!di&&Yn,di&&I.jsx(u7,{align:"end",trigger:ci=>I.jsx("button",{type:"button",className:"archik-btn","aria-label":"More actions","aria-expanded":ci,title:"More actions",style:{padding:"5px 8px"},children:I.jsx(MFn,{size:14,strokeWidth:1.8})}),children:()=>I.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:8,minWidth:"min(220px, calc(100vw - 16px))",maxHeight:"min(70vh, 560px)",overflowY:"auto"},children:[br&&I.jsxs(I.Fragment,{children:[I.jsx("div",{children:jc}),I.jsx("div",{style:{display:"flex",gap:8},children:Ke})]}),Ut.map(ci=>I.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:12,color:"var(--archik-fg)"},children:[ci.node,I.jsx("span",{children:ci.label})]},ci.key)),I.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",borderTop:"1px solid var(--archik-border)",paddingTop:8},children:Yn})]})}),I.jsx("button",{type:"button",onClick:D,disabled:!k||E==="saving",title:`Save to ${d} (${tt})`,className:"archik-btn archik-btn-primary",children:k?"Save •":"Save"}),I.jsx(_Wn,{})]})]})}function ZWn(f){const d=f.indexOf(`
|
|
226
|
-
`);return d===-1?f:f.slice(0,d)}function XWn({files:f,currentPath:d,onSwitchFile:p}){const m=f.some(M=>M.hasSuggestion||M.isOrphanSuggestion);if(f.length<=1&&!m)return null;const E=f.find(M=>M.path===d)??f[0];return I.jsx(u7,{align:"start",trigger:M=>I.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:[I.jsx(zFn,{size:13,strokeWidth:1.8}),I.jsx("span",{style:{fontWeight:600},children:E.name}),E.hasSuggestion&&I.jsx(Tse,{}),I.jsx(Cse,{size:12,strokeWidth:2,style:{opacity:.6}})]}),children:M=>I.jsxs("div",{style:{minWidth:"min(220px, calc(100vw - 16px))",padding:4},children:[I.jsx("div",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--archik-fg-muted)",padding:"6px 10px 4px"},children:"Architecture files"}),f.map(k=>{const D=k.path===E.path,z=k.isOrphanSuggestion===!0;return I.jsxs("button",{type:"button",title:z?`Pending sub-architecture (sidecar only — no main file yet). Click to view; accept via \`npx archik suggest accept ${k.path.replace(/\.archik\.suggested\.yaml$/,".archik.yaml")}\` to promote it, or /archik:accept.`:void 0,onClick:()=>{M(),!D&&p(k)},className:"archik-menu-item",style:{display:"flex",alignItems:"center",gap:8,width:"100%",textAlign:"left",padding:"6px 10px",fontSize:12,background:D?"var(--archik-surface-hover)":void 0,borderLeft:z?"2px dashed var(--archik-accent)":void 0,paddingLeft:z?8:void 0},children:[I.jsxs("span",{style:{fontWeight:D?600:400,color:"var(--archik-fg)"},children:[k.name,z&&I.jsx("span",{style:{marginLeft:6,fontSize:10,fontWeight:500,color:"var(--archik-accent)",letterSpacing:"0.04em"},children:"(pending)"})]}),k.hasSuggestion&&!z&&I.jsx(Tse,{}),I.jsx("span",{style:{flex:1,fontSize:10,fontFamily:"ui-monospace, monospace",color:"var(--archik-fg-muted)",textAlign:"right"},children:k.path})]},k.path)})]})})}function Tse(){return I.jsx("span",{"aria-label":"pending suggestion",title:"Pending suggestion",style:{width:6,height:6,borderRadius:3,background:"var(--archik-accent)",flexShrink:0}})}function VWn({stack:f,onGoToFrame:d,suggestionsByPath:p}){return f.length<=1?null:I.jsx("nav",{"aria-label":"Architecture file navigation",style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--archik-fg-muted)"},children:f.map((m,E)=>{const M=E===f.length-1,k=m.archikFile!==null&&p!==void 0&&p.has(m.archikFile);return I.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[M?I.jsxs("span",{style:{color:"var(--archik-fg)",fontWeight:600,display:"inline-flex",alignItems:"center",gap:6},"aria-current":"page",children:[m.label,k&&I.jsx(Tse,{})]}):I.jsxs("button",{type:"button",onClick:()=>d(E),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 ${m.label}`,children:[m.label,k&&I.jsx(Tse,{})]}),!M&&I.jsx("span",{"aria-hidden":"true",style:{opacity:.5},children:"›"})]},`${E}-${m.archikFile??"root"}`)})})}const WWn="/architecture.archik.yaml",YWn="/architecture.archik.suggested.yaml",QWn="/__archik/accept-suggestion",eYn=1500,T7e={label:"main",docUrl:WWn,sidecarUrl:YWn,acceptUrl:QWn,archikFile:null};function gbn(f,d){const p=f.replace(/\.archik\.yaml$/,".archik.suggested.yaml"),m=encodeURIComponent(f),E=encodeURIComponent(p);return{label:d,docUrl:`/__archik/file?path=${m}`,sidecarUrl:`/__archik/file?path=${E}`,acceptUrl:`/__archik/file-accept?path=${m}`,archikFile:f}}function nYn(){if(typeof window>"u")return null;const f=new URLSearchParams(window.location.search).get("file");return f!==null&&f.length>0?f:null}function tYn(f){if(typeof window>"u")return;const d=new URL(window.location.href);f===null||f.length===0?d.searchParams.delete("file"):d.searchParams.set("file",f),window.history.replaceState(null,"",d.toString())}function U1n(){const f=nYn();if(f===null)return[T7e];const p=(f.split("/").pop()??f).replace(/\.archik\.yaml$/i,"")||"main";return[gbn(f,p)]}function iYn(){const[f,d]=Fn.useState({status:"loading"}),[p,m]=Fn.useState(U1n),E=p[p.length-1],[M,k]=Fn.useState([]),D=Fn.useMemo(()=>new Set(M.filter(on=>on.hasSuggestion).map(on=>on.path)),[M]),z=Fn.useMemo(()=>M.find(on=>on.isRoot)??null,[M]),U=E.archikFile===null?z?.path??null:E.archikFile,[ee,ce]=Fn.useState(void 0),[se,pe]=Fn.useState(void 0),[Je,ie]=Fn.useState("idle"),[Ye,an]=Fn.useState(null),[_n,hn]=Fn.useState(!1),[Rn,nt]=Fn.useState(!1),[ot,et]=Fn.useState({status:"none"}),[gt,dr]=Fn.useState(!1),[tc,Lr]=Fn.useState([]),[Ni,Q]=Fn.useState([]),Pu=100,[zu,Hn]=Fn.useState(()=>gWn()),tt=on=>{Hn(on),wWn(on)},[di,br]=Fn.useState(()=>dWn()),jc=on=>{br(on),bWn(on)},[Ke,Yn]=Fn.useState(()=>aWn()),Ut=on=>{Yn(on),hWn(on)},ci=Fn.useMemo(()=>({...pWn(zu),viewMode:di}),[zu,di]),gr=Fn.useMemo(()=>f.status==="ready"?new Set(f.document.nodes.filter(on=>(on.seqFiles?.length??0)>0).map(on=>on.id)):new Set,[f]),Kr=Fn.useRef(!1),_c=Fn.useRef(null),Bu=Fn.useRef(null),Ws=Fn.useCallback(()=>Bu.current,[]),gh=Fn.useRef(null),hu=Nf(on=>on.selection),da=Nf(on=>on.connectFrom),fk=Nf(on=>on.selectNode),Ba=Nf(on=>on.selectEdge),py=Nf(on=>on.toggleNode),ov=Nf(on=>on.toggleEdge),A0=Nf(on=>on.clearSelection),o7=Nf(on=>on.startConnect),cs=Nf(on=>on.cancelConnect),Bs=Nf(on=>on.collapsed),lv=Nf(on=>on.hideStructural),ss=Nf(on=>on.focus),NA=Nf(on=>on.collapseAll),wh=Nf(on=>on.expandAll),IA=Nf(on=>on.setHideStructural),l7=Nf(on=>on.setFocusDepth),qp=Nf(on=>on.clearFocus),Xh=hu.length>0?hu.at(-1)??null:null,$A=Fn.useMemo(()=>new Set(hu.filter(on=>on.type==="node").map(on=>on.id)),[hu]),f7=Fn.useMemo(()=>new Set(hu.filter(on=>on.type==="edge").map(on=>on.id)),[hu]);Fn.useEffect(()=>{const on=p[p.length-1];tYn(on.archikFile)},[p]),Fn.useEffect(()=>{if(typeof window>"u")return;const on=()=>m(U1n());return window.addEventListener("popstate",on),()=>window.removeEventListener("popstate",on)},[]),Fn.useEffect(()=>{let on=!1;_c.current="",Kr.current=!1;const Pt=()=>{sVn(E.docUrl).then(({document:Ii,text:Tr})=>{if(on||Tr===_c.current)return;_c.current=Tr,Kr.current=!0,d({status:"ready",document:Ii}),hn(!1),typeof window<"u"&&Ii.name&&(window.document.title=`${Ii.name} — Archik`),pe(void 0),Lr([]),Q([]);const tl=new Set(Ii.nodes.map($s=>$s.id)),Au=new Set(Ii.edges.map($s=>$s.id));Nf.setState($s=>({selection:$s.selection.filter(Yu=>Yu.type==="node"?tl.has(Yu.id):Au.has(Yu.id)),connectFrom:$s.connectFrom!==null&&tl.has($s.connectFrom)?$s.connectFrom:null}))},Ii=>{if(on)return;const Tr=Ii instanceof Error?Ii.message:String(Ii);Kr.current?pe(Tr):d({status:"error",error:Tr})})};d({status:"loading"}),Pt();const Xi=$1n(Pt);return()=>{on=!0,Xi()}},[E.docUrl]),Fn.useEffect(()=>()=>{gh.current&&clearTimeout(gh.current)},[]),Fn.useEffect(()=>{let on=!1;const Pt=async()=>{try{const Tr=await fetch("/__archik/files",{cache:"no-store"});if(on||!Tr.ok)return;const tl=await Tr.json();if(on)return;Array.isArray(tl.files)&&k(tl.files)}catch{}};Pt();const Xi=$1n(()=>{Pt()}),Ii=D1n(()=>{Pt()});return()=>{on=!0,Xi(),Ii()}},[]),Fn.useEffect(()=>{if(f.status!=="ready")return;const on=f.document;let Pt=!1;const Xi=async()=>{if(U!==null&&M.length>0&&M.some(Tr=>Tr.path===U)&&!D.has(U)){et({status:"none"});return}try{const Tr=await fetch(E.sidecarUrl,{cache:"no-store"});if(Pt)return;if(Tr.status===404){et({status:"none"});return}if(!Tr.ok){et({status:"error",message:`Sidecar fetch failed: HTTP ${Tr.status}`});return}const tl=await Tr.text();let Au;try{Au=tbn(tl)}catch(Yu){et({status:"error",message:Yu instanceof Error?Yu.message:String(Yu)});return}const $s=E7e(on,Au);et({status:"pending",added:$s.nodes.added.length+$s.edges.added.length,removed:$s.nodes.removed.length+$s.edges.removed.length,changed:$s.nodes.changed.length+$s.edges.changed.length,doc:Au,...Au.metadata?.suggestion?.note!==void 0?{note:Au.metadata.suggestion.note}:{}})}catch(Tr){if(Pt)return;et({status:"error",message:Tr instanceof Error?Tr.message:String(Tr)})}};Xi();const Ii=D1n(Xi);return()=>{Pt=!0,Ii()}},[f,E.sidecarUrl,U,M,D]);const DA=Fn.useCallback(async()=>{try{const on=await fetch(E.acceptUrl,{method:"POST"});if(!on.ok){const Pt=await on.text();et({status:"error",message:`Accept failed: ${Pt||`HTTP ${on.status}`}`});return}et({status:"none"}),dr(!1)}catch(on){et({status:"error",message:on instanceof Error?on.message:String(on)})}},[E.acceptUrl]),LA=Fn.useCallback(async()=>{try{const on=await fetch(E.sidecarUrl,{method:"DELETE"});if(!on.ok&&on.status!==404){const Pt=await on.text();et({status:"error",message:`Reject failed: ${Pt||`HTTP ${on.status}`}`});return}et({status:"none"}),dr(!1)}catch(on){et({status:"error",message:on instanceof Error?on.message:String(on)})}},[E.sidecarUrl]),fv=Fn.useCallback(()=>{dr(on=>!on)},[]),ba=Fn.useCallback(async()=>{let on=null;if(d(Xi=>(Xi.status==="ready"&&(on=Xi.document),Xi)),!on)return;const Pt=oje(on);_c.current=Pt,ie("saving"),an(null);try{await uVn(E.docUrl,on),ie("saved");let Xi=!1;d(Ii=>(Ii.status==="ready"&&Ii.document===on&&(Xi=!0),Ii)),Xi&&hn(!1),gh.current&&clearTimeout(gh.current),gh.current=setTimeout(()=>ie("idle"),eYn)}catch(Xi){ie("error"),an(Xi instanceof Error?Xi.message:String(Xi))}},[E.docUrl]),N1=z?.path??null,$f=Fn.useCallback((on,Pt)=>N1===on?T7e:gbn(on,Pt),[N1]),my=Fn.useCallback((on,Pt)=>on.archikFile===Pt?!0:on.archikFile===null&&N1===Pt,[N1]),RA=Fn.useCallback((on,Pt)=>{m(Xi=>{const Ii=Xi.findIndex(Tr=>my(Tr,on));return Ii>=0?Ii===Xi.length-1?Xi:Xi.slice(0,Ii+1):[...Xi,$f(on,Pt)]})},[$f,my]),ak=Fn.useCallback((on,Pt)=>{m(Xi=>{const Ii=Xi[Xi.length-1];return my(Ii,on)?Xi:[$f(on,Pt)]})},[$f,my]),vy=Fn.useCallback(on=>{m(Pt=>on<0||on>=Pt.length-1?Pt:Pt.slice(0,on+1))},[]),yy=Fn.useCallback(on=>{on.isRoot?m([T7e]):ak(on.path,on.name)},[ak]),ky=Fn.useCallback((on,Pt)=>{if(da===null){Pt&&(Pt.metaKey||Pt.ctrlKey||Pt.shiftKey)?py(on):fk(on);return}if(on===da){cs();return}let Xi=null;d(Ii=>{if(Ii.status!=="ready"||!Ii.document.nodes.find(Yu=>Yu.id===da))return Ii;const tl=new Set(Ii.document.edges.map(Yu=>Yu.id)),Au=V8e(X8e(`${da}-${on}`),tl,"edge"),$s={id:Au,from:da,to:on,relationship:"http_call"};try{const Yu=uI(Ii.document,{type:"connect",edge:$s});return ce(void 0),hn(!0),Lr(qo=>[...qo.slice(-(Pu-1)),Ii.document]),Q([]),Xi=Au,{status:"ready",document:Yu}}catch(Yu){const qo=Yu instanceof Error?Yu.message:String(Yu);return ce(qo),Ii}}),cs(),Xi&&Ba(Xi)},[da,cs,fk,py,Ba]),ew=Fn.useCallback((on,Pt)=>{Pt&&(Pt.metaKey||Pt.ctrlKey||Pt.shiftKey)?ov(on):Ba(on)},[Ba,ov]),jy=Fn.useCallback((on,Pt)=>{let Xi=null;d(Ii=>{if(Ii.status!=="ready")return Ii;const Tr=Ii.document.nodes.find(qo=>qo.id===on),tl=Ii.document.nodes.find(qo=>qo.id===Pt);if(!Tr||!tl)return Ii;const Au=new Set(Ii.document.edges.map(qo=>qo.id)),$s=V8e(X8e(`${on}-${Pt}`),Au,"edge"),Yu={id:$s,from:on,to:Pt,relationship:"http_call"};try{const qo=uI(Ii.document,{type:"connect",edge:Yu});return ce(void 0),hn(!0),Lr(Go=>[...Go.slice(-(Pu-1)),Ii.document]),Q([]),Xi=$s,{status:"ready",document:qo}}catch(qo){const Go=qo instanceof Error?qo.message:String(qo);return ce(Go),Ii}}),Xi&&Ba(Xi)},[Ba]),av=Fn.useCallback((on,Pt,Xi)=>{d(Ii=>{if(Ii.status!=="ready")return Ii;const Tr=new Set(Ii.document.nodes.map(Au=>Au.id)),tl=V8e(X8e(Pt),Tr,on);try{const Au=uI(Ii.document,{type:"add_node",node:{id:tl,kind:on,name:Pt,description:Xi}});return ce(void 0),hn(!0),Lr($s=>[...$s.slice(-(Pu-1)),Ii.document]),Q([]),{status:"ready",document:Au}}catch(Au){const $s=Au instanceof Error?Au.message:String(Au);return ce($s),Ii}})},[]),a7=Fn.useCallback(on=>{d(Pt=>{if(Pt.status!=="ready")return Pt;try{const Xi=uI(Pt.document,on);return ce(void 0),hn(!0),Lr(Ii=>[...Ii.slice(-(Pu-1)),Pt.document]),Q([]),{status:"ready",document:Xi}}catch(Xi){const Ii=Xi instanceof Error?Xi.message:String(Xi);return ce(Ii),Pt}})},[]),Sy=Fn.useCallback(()=>{hu.length!==0&&(d(on=>{if(on.status!=="ready")return on;let Pt=on.document;try{const Xi=hu.filter(Tr=>Tr.type==="edge").map(Tr=>Tr.id);for(const Tr of Xi)Pt.edges.some(tl=>tl.id===Tr)&&(Pt=uI(Pt,{type:"disconnect",id:Tr}));const Ii=hu.filter(Tr=>Tr.type==="node").map(Tr=>Tr.id);for(const Tr of Ii)Pt.nodes.some(tl=>tl.id===Tr)&&(Pt=uI(Pt,{type:"remove_node",id:Tr}));return Pt===on.document?on:(ce(void 0),hn(!0),Lr(Tr=>[...Tr.slice(-(Pu-1)),on.document]),Q([]),{status:"ready",document:Pt})}catch(Xi){const Ii=Xi instanceof Error?Xi.message:String(Xi);return ce(Ii),on}}),A0())},[hu,A0]),hv=Fn.useCallback(()=>{if(f.status!=="ready"||tc.length===0)return;const on=tc[tc.length-1];Lr(Pt=>Pt.slice(0,-1)),Q(Pt=>[...Pt,f.document]),d({status:"ready",document:on}),hn(!0),ce(void 0),A0()},[f,tc,A0]),Rb=Fn.useCallback(()=>{if(f.status!=="ready"||Ni.length===0)return;const on=Ni[Ni.length-1];Q(Pt=>Pt.slice(0,-1)),Lr(Pt=>[...Pt,f.document]),d({status:"ready",document:on}),hn(!0),ce(void 0),A0()},[f,Ni,A0]);if(Fn.useEffect(()=>{const on=Pt=>{if((Pt.metaKey||Pt.ctrlKey)&&Pt.key==="s"){Pt.preventDefault(),_n&&ba();return}if((Pt.metaKey||Pt.ctrlKey)&&(Pt.key==="z"||Pt.key==="Z")){Pt.preventDefault(),Pt.shiftKey?Rb():hv();return}if((Pt.metaKey||Pt.ctrlKey)&&Pt.key==="y"){Pt.preventDefault(),Rb();return}if(Pt.key==="Escape"){da?cs():ss&&qp();return}if(Pt.key==="Delete"||Pt.key==="Backspace"){const Xi=Pt.target;if(Xi instanceof HTMLInputElement||Xi instanceof HTMLTextAreaElement||Xi instanceof HTMLSelectElement||Xi instanceof HTMLElement&&Xi.isContentEditable||hu.length===0)return;Pt.preventDefault(),Sy()}};return window.addEventListener("keydown",on),()=>window.removeEventListener("keydown",on)},[_n,ba,da,cs,hu,Sy,hv,Rb,ss,qp]),Fn.useEffect(()=>{f.status==="ready"&&AVn(ss,f.document)&&qp()},[f,ss,qp]),f.status==="loading")return I.jsxs(H1n,{children:["Loading ",E.docUrl,"…"]});if(f.status==="error")return I.jsx(H1n,{children:I.jsx("pre",{className:"max-w-3xl whitespace-pre-wrap text-xs text-rose-700",children:f.error})});const nw=f.document,T0=gt&&ot.status==="pending",hk=T0&&ot.status==="pending"?gVn(nw,ot.doc):null,dk=T0&&ot.status==="pending"?sbn(E7e(nw,ot.doc)):null,kd=hk??nw,bk=Bs.size>0?ubn(kd,Bs):kd,h7={collapsed:Bs,hideStructural:lv,focus:ss!==null&&bk.nodes.some(on=>on.id===ss.id)?ss:null},d7=MVn(kd,h7),M0=Xh?.type==="node"?kd.nodes.find(on=>on.id===Xh.id):void 0,uf=Xh?.type==="edge"?kd.edges.find(on=>on.id===Xh.id):void 0,ga=da!==null?nw.nodes.find(on=>on.id===da):void 0,tw=hu.length>1;return I.jsxs("div",{className:"flex h-full flex-col",style:{background:"var(--archik-canvas)",color:"var(--archik-fg)"},children:[I.jsx(KWn,{document:nw,commandError:ee,saveStatus:Je,...Ye!==null?{saveError:Ye}:{},isDirty:_n,onSave:()=>{ba()},onAddNode:av,density:zu,onDensityChange:tt,viewMode:di,onViewModeChange:jc,showStereotypeBands:Ke,onToggleStereotypeBands:()=>Ut(!Ke),canUndo:tc.length>0,canRedo:Ni.length>0,onUndo:hv,onRedo:Rb,getSvg:Ws,seqHighlight:Rn,onToggleSeqHighlight:()=>nt(on=>!on),seqNodeCount:gr.size,hideStructural:lv,onToggleHideStructural:()=>IA(!lv),onCollapseAll:()=>NA(nw.nodes.filter(on=>nw.nodes.some(Pt=>Pt.parentId===on.id)).map(on=>on.id)),onExpandAll:wh,...ss?{focusDepth:ss.depth,onFocusDepthChange:l7,onClearFocus:qp}:{},...se!==void 0?{reloadError:se}:{},...ga!==void 0?{connectingFromName:ga.name,onCancelConnect:cs}:{}}),ot.status==="pending"&&I.jsx(cYn,{added:ot.added,removed:ot.removed,changed:ot.changed,note:ot.note,reviewing:T0,onReview:fv,onAccept:()=>{DA()},onReject:()=>{LA()}}),ot.status==="error"&&I.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:[I.jsx("span",{style:{fontWeight:700},children:"SUGGESTION ERROR —"}),I.jsx("span",{style:{flex:1,color:"var(--archik-fg)"},children:ot.message}),I.jsx("button",{type:"button",onClick:()=>et({status:"none"}),"aria-label":"Dismiss",style:{background:"transparent",border:"none",color:"var(--archik-fg-dim)",cursor:"pointer",fontSize:16,lineHeight:1},children:"×"})]}),se!==void 0&&I.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:[I.jsx("span",{style:{fontWeight:700,letterSpacing:"0.04em"},children:"FILE INVALID —"}),I.jsx("pre",{style:{margin:0,flex:1,whiteSpace:"pre-wrap",fontFamily:"inherit",color:"var(--archik-fg)"},children:se}),I.jsx("button",{type:"button",onClick:()=>pe(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:"×"})]}),I.jsxs("main",{className:"archik-main flex min-h-0 flex-1 p-4",style:{gap:0},children:[I.jsx("div",{className:"archik-panel",style:{flex:1,minWidth:0,overflow:"hidden"},children:I.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%"},children:[(M.length>1||p.length>1)&&I.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",background:"var(--archik-surface)",borderBottom:"1px solid var(--archik-border)"},children:[I.jsx(XWn,{files:M,currentPath:U,onSwitchFile:yy}),I.jsx(VWn,{stack:p,onGoToFrame:vy,suggestionsByPath:D})]}),I.jsx(KGn,{document:d7,className:"flex-1 archik-grid",layoutOptions:ci,viewMode:di,showStereotypeBands:Ke,selectedNodeIds:$A,selectedEdgeIds:f7,onSelectNode:ky,onSelectEdge:ew,onSelectNothing:da===null?A0:cs,onConnectDrag:jy,onOpenSubFile:RA,onCrossFileNavigate:ak,viewKey:E.docUrl,svgRef:Bu,...dk?{diffStatuses:dk}:{},...Rn&&gr.size>0?{glowNodeIds:gr}:{}})]})}),I.jsx("aside",{"aria-hidden":hu.length===0,className:`archik-drawer-shell ${hu.length>0?"archik-drawer-shell--open":"archik-drawer-shell--closed"}`,children:I.jsxs("div",{className:"archik-panel archik-drawer-content archik-drawer-fade",style:{overflow:"hidden"},children:[I.jsxs("div",{className:"archik-sheet-handle",children:[I.jsx("span",{className:"archik-sheet-grip","aria-hidden":"true"}),I.jsx("button",{type:"button","aria-label":"Close inspector",className:"archik-sheet-close",onClick:A0,children:"✕"})]}),tw?I.jsx(rYn,{count:hu.length,onDelete:Sy,onClear:A0}):Xh?.type==="edge"?I.jsx(FVn,{edge:uf,dispatch:a7,readOnly:T0}):Xh?.type==="node"?I.jsx($Vn,{node:M0,dispatch:a7,onStartConnect:o7,allNodes:kd.nodes,readOnly:T0,viewKey:E.archikFile??void 0}):null]},tw?`multi:${hu.length}`:Xh?`${Xh.type}:${Xh.id}`:"empty")})]})]})}function rYn({count:f,onDelete:d,onClear:p}){return I.jsxs("div",{className:"flex h-full flex-col gap-4 overflow-y-auto p-4 text-sm",children:[I.jsxs("div",{children:[I.jsx("div",{className:"archik-label",children:"Selection"}),I.jsxs("div",{style:{fontSize:18,fontWeight:600,color:"var(--archik-fg)",letterSpacing:"0.01em"},children:[f," items"]}),I.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-dim)",marginTop:4},children:"Hold ⌘ / Ctrl while clicking to add or remove items."})]}),I.jsx("div",{className:"archik-divider"}),I.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-4",children:[I.jsx("button",{type:"button",onClick:p,className:"archik-btn",style:{justifyContent:"center",padding:"8px 12px"},children:"Clear selection"}),I.jsxs("button",{type:"button",onClick:d,className:"archik-btn archik-btn-danger",style:{justifyContent:"center",padding:"8px 12px"},children:["Delete ",f," items"]})]})]})}function H1n({children:f}){return I.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:f})}function cYn({added:f,removed:d,changed:p,note:m,reviewing:E,onReview:M,onAccept:k,onReject:D}){const z=f+d+p;return I.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:[I.jsx("span",{style:{fontWeight:700,letterSpacing:"0.04em",color:"#c4b5fd"},children:"📝 SUGGESTION PENDING"}),I.jsxs("span",{style:{color:"var(--archik-fg)"},children:[z===0?"(identical to current — nothing to apply)":I.jsxs(I.Fragment,{children:[I.jsxs("span",{style:{color:"var(--archik-success)"},children:["+",f]})," ",I.jsxs("span",{style:{color:"var(--archik-danger)"},children:["−",d]})," ",I.jsxs("span",{style:{color:"var(--archik-warning)"},children:["~",p]})]}),m?I.jsxs("span",{style:{marginLeft:10,color:"var(--archik-fg-dim)",fontStyle:"italic"},children:['"',m,'"']}):null]}),I.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8},children:[I.jsx("button",{type:"button",onClick:M,className:"archik-btn",style:{padding:"5px 12px",fontSize:12,...E?{background:"#a855f7",color:"white",borderColor:"#a855f7"}:{}},children:E?"Hide diff":"Review"}),I.jsx("button",{type:"button",onClick:k,className:"archik-btn",title:z===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"}),I.jsx("button",{type:"button",onClick:D,className:"archik-btn",style:{padding:"5px 12px",fontSize:12,color:"var(--archik-danger)",borderColor:"var(--archik-danger)"},children:"Reject"})]})]})}const sYn=lk(["sync","async","return","create","destroy"]),uYn=lk(["over","left_of","right_of"]),oYn=lk(["alt","opt","loop","par","break","ref"]),lYn=If({id:Fo,nodeId:Fo,label:ms().min(1).optional(),status:RI.optional()}),fYn=If({type:LI("message"),id:Fo,from:Fo,to:Fo,label:ms().min(1),arrow:sYn,activate:hXn().optional(),status:RI.optional()}),aYn=If({type:LI("note"),id:Fo,position:uYn,participants:_1(Fo).min(1),text:ms().min(1),status:RI.optional()}),hYn=cje(()=>If({label:ms().optional(),steps:_1(wbn)})),dYn=cje(()=>If({type:LI("group"),id:Fo,kind:oYn,condition:ms().optional(),label:ms().optional(),branches:_1(hYn).optional(),seqFile:Y0n.optional(),participants:_1(Fo).optional(),status:RI.optional()})),wbn=cje(()=>Z0n([fYn,aYn,dYn]));function pbn(f,d){const p=[];for(const m of f)if(d.has(m.id)?p.push(m.id):d.add(m.id),m.type==="group"&&m.branches)for(const E of m.branches)p.push(...pbn(E.steps,d));return p}const bYn=If({useCase:Fo,slice:Fo}),gYn=If({version:LI("1.0"),name:ms().min(1),description:ms().optional(),realizes:bYn.optional(),participants:_1(lYn).min(1),steps:_1(wbn)}).superRefine((f,d)=>{const p=new Set;for(let M=0;M<f.participants.length;M++){const k=f.participants[M];p.has(k.id)&&d.addIssue({code:E0.custom,path:["participants",M,"id"],message:`duplicate participant id "${k.id}"`}),p.add(k.id)}const m=new Set,E=pbn(f.steps,m);for(const M of E)d.addIssue({code:E0.custom,path:["steps"],message:`duplicate step id "${M}"`})}),TI=56,wYn=160,pYn=40,M7e=56,mYn=24,rse=12,vYn=20,yYn=6,J1n=64,SA=32,t7e=24,K1n=8;function kYn(f){return Math.max(wYn,f.length*8+pYn*2)}function mbn(f,d,p,m,E,M=0){let k=p;const D=[];let z=Number.POSITIVE_INFINITY,U=Number.NEGATIVE_INFINITY;for(const ee of f)if(ee.type==="message"){const ce=d.get(ee.from),se=d.get(ee.to),pe=ce?.cx??m,Je=se?.cx??m;D.push({type:"message",id:ee.id,fromCx:pe,toCx:Je,y:k,label:ee.label,arrow:ee.arrow,activate:ee.activate??!1,isSelf:ee.from===ee.to,...ee.status!==void 0?{status:ee.status}:{}}),k+=ee.from===ee.to?M7e*1.5:M7e}else if(ee.type==="note"){const ce=ee.participants.map(Ye=>d.get(Ye)?.cx).filter(Ye=>Ye!==void 0).sort((Ye,an)=>Ye-an),se=ce[0]??m,pe=ce[ce.length-1]??E,Je=Math.min(Math.max(ee.text.length*7.5+24,pe-se+16,80),400);let ie;ee.position==="left_of"?ie=se-Je-8:ee.position==="right_of"?ie=pe+8:ie=(se+pe)/2-Je/2,z=Math.min(z,ie),U=Math.max(U,ie+Je),D.push({type:"note",id:ee.id,x:ie,y:k,width:Je,height:J1n,text:ee.text,...ee.status!==void 0?{status:ee.status}:{}}),k+=J1n+8}else if(ee.type==="group"){const ce=Math.min(M*yYn,rse),se=m-rse+ce,pe=E-m+rse*2-ce*2,Je=k;k+=mYn;const ie=[];if(ee.branches)for(let Ye=0;Ye<ee.branches.length;Ye++){const an=ee.branches[Ye],_n=k,{items:hn,endY:Rn,contentMinX:nt,contentMaxX:ot}=mbn(an.steps,d,k,m,E,M+1);k=Rn,z=Math.min(z,nt),U=Math.max(U,ot),ie.push({...an.label!==void 0?{label:an.label}:{},startY:_n,...Ye<ee.branches.length-1?{dividerY:k}:{},steps:hn}),Ye<ee.branches.length-1&&(k+=4)}k+=rse,D.push({type:"group",id:ee.id,kind:ee.kind,...ee.condition!==void 0?{condition:ee.condition}:{},...ee.label!==void 0?{label:ee.label}:{},...ee.seqFile!==void 0?{seqFile:ee.seqFile}:{},x:se,y:Je,width:pe,height:k-Je,branches:ie,...ee.status!==void 0?{status:ee.status}:{}}),z=Math.min(z,se),U=Math.max(U,se+pe),k+=vYn}return{items:D,endY:k,contentMinX:z,contentMaxX:U}}function vbn(f){const d=new Map;for(const p of f)if(p.type==="message"&&p.arrow==="destroy"&&d.set(p.toCx,p.y+TI+20),p.type==="group")for(const m of p.branches)for(const[E,M]of vbn(m.steps))d.set(E,M);return d}function jYn(f){const d=[],p=new Map;function m(E){for(const M of E)if(M.type==="message"){if(M.activate&&M.arrow==="sync"&&!M.isSelf){const k=p.get(M.toCx)??[];k.push(M.y),p.set(M.toCx,k)}if(M.arrow==="return"&&!M.isSelf){const k=p.get(M.fromCx);if(k&&k.length>0){const D=k.pop();d.push({cx:M.fromCx,startY:D,endY:M.y}),k.length===0&&p.delete(M.fromCx)}}}else if(M.type==="group")for(const k of M.branches)m(k.steps)}m(f);for(const[E,M]of p)for(const k of M)d.push({cx:E,startY:k,endY:k+M7e/2});return d}function SYn(f,d){const p=f.participants.map(et=>kYn(et.label??et.nodeId));let m=SA;const E=f.participants.map((et,gt)=>{const dr=p[gt],tc=m+dr/2;m+=dr;const Lr=d?.get(et.nodeId);return{id:et.id,nodeId:et.nodeId,label:et.label??et.nodeId,cx:tc,colWidth:dr,...Lr!==void 0?{kind:Lr}:{},...et.status!==void 0?{status:et.status}:{},lifelineEndY:0}}),M=m+SA,k=new Map(E.map(et=>[et.id,et])),D=E[0]?.cx??SA,z=E[E.length-1]?.cx??M-SA,U=t7e,{items:ee,endY:ce,contentMinX:se,contentMaxX:pe}=mbn(f.steps,k,U,D,z),Je=se<SA&&Number.isFinite(se)?SA-se:0,ie=Number.isFinite(pe)?pe+Je+SA:0,Ye=Math.max(M+Je,ie),an=Je>0?ee.map(et=>ybn(et,Je)):ee,_n=Je>0?E.map(et=>({...et,cx:et.cx+Je})):E,hn=vbn(an),Rn=_n.map(et=>({...et,lifelineEndY:hn.get(et.cx)??TI+ce+t7e})),nt=TI+ce+t7e,ot=jYn(an);return{participants:Rn,steps:an,activations:ot,totalWidth:Ye,totalHeight:nt}}function ybn(f,d){return f.type==="message"?{...f,fromCx:f.fromCx+d,toCx:f.toCx+d}:f.type==="note"?{...f,x:f.x+d}:{...f,x:f.x+d,branches:f.branches.map(p=>({...p,steps:p.steps.map(m=>ybn(m,d))}))}}const cse=36,EYn=128,xYn=7,Z1n=20,X1n=24;function AYn({participant:f,nodeKind:d}){const p=d?zp[d]:void 0,m=p?.color??"var(--archik-fg-muted)",E=(TI-cse)/2,M=p?.icon,k=Math.max(EYn,f.label.length*xYn+X1n+(M?Z1n:0)),D=k/2,z=M?D+Z1n/2:D,U=f.status,ee=U==="proposed"?.55:U==="deprecated"?.35:1,ce=U==="proposed"||U==="deprecated"?"4 3":void 0;return I.jsxs("g",{transform:`translate(${f.cx-D}, ${E})`,opacity:ee,children:[I.jsx("rect",{width:k,height:cse,rx:8,fill:"var(--archik-node-fill)",stroke:m,strokeWidth:1.4,...ce!==void 0?{strokeDasharray:ce}:{}}),M&&I.jsx("g",{transform:`translate(${X1n/2}, ${(cse-14)/2})`,children:I.jsx(M,{size:14,color:m,strokeWidth:1.5})}),I.jsx("text",{x:z,y:cse/2+4,textAnchor:"middle",fontSize:12,fontWeight:500,fill:"var(--archik-fg)",fontFamily:"inherit",children:f.label})]})}function TYn({participant:f}){const d=f.status,p=d==="proposed"?.35:d==="deprecated"?.25:.6;return I.jsx("line",{x1:f.cx,y1:TI,x2:f.cx,y2:f.lifelineEndY,stroke:"var(--archik-fg-muted)",strokeWidth:1.2,strokeDasharray:"6 5",opacity:p})}const sse=32,iH=20,MYn=-6,use="var(--archik-edge-filled)";function CYn({msg:f}){const d=f.arrow==="return",p=f.arrow==="async",m=f.arrow==="create",E=d||m,M=f.arrow==="destroy",k=d||p,D=f.status==="proposed"?.5:f.status==="deprecated"?.35:1,z=(se,pe)=>k?I.jsx("path",{"data-archik-arrowhead":"end",d:$7e(se,pe),fill:"none",stroke:use,strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"}):I.jsx("path",{"data-archik-arrowhead":"end",d:jI(se,pe),fill:use});if(f.isSelf){const se=f.fromCx,pe=f.y,Je=`M ${se} ${pe} L ${se+sse} ${pe} L ${se+sse} ${pe+iH} L ${se} ${pe+iH}`;return I.jsxs("g",{opacity:D,children:[I.jsx("path",{d:Je,fill:"none",stroke:use,strokeWidth:1.4}),z({x:se,y:pe+iH},{x:se+sse,y:pe+iH}),I.jsx("text",{x:se+sse+6,y:pe+iH/2+4,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:f.label})]})}const ee=f.fromCx<f.toCx?f.toCx-6:f.toCx+6,ce=(f.fromCx+f.toCx)/2;return I.jsxs("g",{opacity:D,children:[I.jsx("line",{x1:f.fromCx,y1:f.y,x2:ee,y2:f.y,stroke:use,strokeWidth:1.4,strokeDasharray:E?"4 4":void 0}),!M&&z({x:f.toCx,y:f.y},{x:f.fromCx,y:f.y}),I.jsxs("text",{x:ce,y:f.y+MYn,textAnchor:"middle",fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:[m&&"«create» ",f.label]}),f.arrow==="destroy"&&I.jsxs("g",{transform:`translate(${f.toCx-6}, ${f.y-6})`,children:[I.jsx("line",{x1:0,y1:0,x2:12,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5}),I.jsx("line",{x1:12,y1:0,x2:0,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5})]})]})}const OYn={alt:"#6366f1",opt:"#0ea5e9",loop:"#10b981",par:"#f59e0b",break:"#ef4444",ref:"#8b5cf6"},V1n=36,i7e=18;function _Yn({group:f,renderStep:d,onRefClick:p}){const m=OYn[f.kind]??"var(--archik-fg-muted)",E=f.status==="proposed"?.55:f.status==="deprecated"?.35:1,M=f.kind==="ref"&&f.seqFile!==void 0&&p!==void 0;return I.jsxs("g",{opacity:E,onClick:M?()=>p(f.seqFile):void 0,style:M?{cursor:"pointer"}:void 0,children:[I.jsx("rect",{x:f.x,y:f.y,width:f.width,height:f.height,rx:4,fill:"none",stroke:m,strokeWidth:1.2,opacity:.8}),I.jsx("rect",{x:f.x,y:f.y,width:V1n,height:i7e,rx:4,fill:m,opacity:.8}),I.jsx("text",{x:f.x+6,y:f.y+i7e-5,fontSize:10,fontWeight:600,fill:"#fff",fontFamily:"inherit",children:f.kind}),(f.condition??f.label)&&I.jsx("text",{x:f.x+V1n+6,y:f.y+i7e-5,fontSize:10,fill:m,fontFamily:"inherit",children:f.condition??f.label}),f.branches.map((k,D)=>I.jsxs("g",{children:[k.label&&I.jsx("text",{x:f.x+6,y:k.startY+12,fontSize:10,fill:m,fontFamily:"inherit",children:k.label}),k.steps.map(z=>d(z)),k.dividerY!==void 0&&I.jsx("line",{x1:f.x,y1:k.dividerY,x2:f.x+f.width,y2:k.dividerY,stroke:m,strokeWidth:1,strokeDasharray:"4 2",opacity:.65})]},D))]})}const lI=10;function NYn(f,d){const p=Math.max(10,Math.floor(d/6.5));if(f.length<=p)return[f];const m=f.split(" "),E=[];let M="";for(const k of m)(M+(M?" ":"")+k).length>p&&M?(E.push(M),M=k):M=M?M+" "+k:k;return M&&E.push(M),E.slice(0,3)}function IYn({note:f}){const{x:d,y:p,width:m,height:E,text:M}=f,k=f.status==="proposed"?.55:f.status==="deprecated"?.35:1;return I.jsxs("g",{opacity:k,children:[I.jsx("path",{d:`M ${d} ${p} L ${d+m-lI} ${p} L ${d+m} ${p+lI} L ${d+m} ${p+E} L ${d} ${p+E} Z`,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),I.jsx("path",{d:`M ${d+m-lI} ${p} L ${d+m-lI} ${p+lI} L ${d+m} ${p+lI}`,fill:"none",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),NYn(M,m-16).map((D,z)=>I.jsx("text",{x:d+8,y:p+8+11+z*13,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:D},z))]})}function kbn({step:f,onRefClick:d}){return f.type==="message"?I.jsx(CYn,{msg:f}):f.type==="note"?I.jsx(IYn,{note:f}):f.type==="group"?I.jsx(_Yn,{group:f,...d!==void 0?{onRefClick:d}:{},renderStep:p=>I.jsx(kbn,{step:p,...d!==void 0?{onRefClick:d}:{}},p.id)}):null}function $Yn({laid:f,svgRef:d,onRefClick:p}){const{participants:m,steps:E,activations:M,totalWidth:k,totalHeight:D}=f;return I.jsxs("svg",{ref:d,width:k,height:D,viewBox:`0 0 ${k} ${D}`,xmlns:"http://www.w3.org/2000/svg",style:{fontFamily:"var(--archik-font, system-ui)"},children:[m.map(z=>I.jsx(TYn,{participant:z},z.id)),m.map(z=>I.jsx(AYn,{participant:z,...z.kind!==void 0?{nodeKind:z.kind}:{}},z.id)),I.jsxs("g",{transform:`translate(0, ${TI})`,children:[M.map(z=>I.jsx("rect",{x:z.cx-K1n/2,y:z.startY,width:K1n,height:z.endY-z.startY,fill:"var(--archik-surface)",stroke:"var(--archik-fg-muted)",strokeWidth:1.2,rx:2},`${z.cx}-${z.startY}`)),E.map(z=>I.jsx(kbn,{step:z,...p!==void 0?{onRefClick:p}:{}},z.id))]})]})}const W1n="archik.seq.rail.open";function DYn({path:f,back:d}){const[p,m]=Fn.useState({status:"loading"}),[E,M]=Fn.useState(void 0),[k,D]=Fn.useState([]),[z,U]=Fn.useState(()=>{if(typeof window>"u")return!0;const hn=window.localStorage.getItem(W1n);return hn!==null?hn==="1":typeof window.matchMedia=="function"?!window.matchMedia("(max-width: 768px)").matches:!0}),[ee,ce]=Fn.useState(!1),se=Fn.useRef(null);Fn.useEffect(()=>{typeof window<"u"&&window.localStorage.setItem(W1n,z?"1":"0")},[z]),Fn.useEffect(()=>{fetch("/__archik/node-kinds").then(hn=>hn.ok?hn.json():null).then(hn=>{hn&&M(new Map(Object.entries(hn)))}).catch(()=>{})},[]),Fn.useEffect(()=>{fetch("/__archik/usecases").then(hn=>hn.ok?hn.json():null).then(hn=>{hn&&D(hn.useCases??[])}).catch(()=>{})},[]),Fn.useEffect(()=>{m({status:"loading"});const hn=encodeURIComponent(f);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 nt=W7e.parse(Rn),ot=gYn.safeParse(nt);if(!ot.success)throw new Error(ot.error.issues.map(et=>et.message).join("; "));m({status:"ready",doc:ot.data,raw:Rn})}).catch(Rn=>{m({status:"error",message:Rn instanceof Error?Rn.message:String(Rn)})})},[f]);const pe=d?d.type==="usecase"?`/__archik/usecases?uc=${encodeURIComponent(d.value)}`:`/?file=${encodeURIComponent(d.value)}`:"/",Je=d?.type==="usecase"?"Use cases":"Architecture",ie=Fn.useMemo(()=>{if(p.status!=="ready")return null;const hn=p.doc.realizes;if(!hn)return null;const Rn=k.find(ot=>ot.id===hn.useCase);if(!Rn)return{useCase:hn.useCase,slice:hn.slice,name:void 0,slice_data:void 0};const nt=Rn.slices.find(ot=>ot.id===hn.slice);return{useCase:hn.useCase,slice:hn.slice,name:Rn.name,slice_data:nt,primaryActor:Rn.primaryActor}},[p,k]);if(p.status==="loading")return I.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 I.jsxs("div",{className:"flex h-screen flex-col items-center justify-center gap-4",children:[I.jsx("div",{style:{color:"var(--archik-fg-error, #ef4444)"},children:p.message}),I.jsxs("a",{href:pe,style:{color:"var(--archik-fg-muted)",fontSize:13},children:["← ",Je]})]});const Ye=SYn(p.doc,E),an=f.replace(/^.*\//,"").replace(/\.archik\.seq\.yaml$/,""),_n=hn=>{const Rn=new URLSearchParams;Rn.set("path",hn),d?.type==="usecase"?Rn.set("from-uc",d.value):d?.type==="file"&&Rn.set("from-file",d.value),window.location.href=`/__archik/seq?${Rn.toString()}`};return I.jsxs("div",{className:"flex h-dvh flex-col",style:{background:"var(--archik-canvas)"},children:[I.jsx(RYn,{backHref:pe,backLabel:Je,realizedSlice:ie,seqName:p.doc.name,railOpen:z,onToggleRail:()=>U(hn=>!hn),filename:an,getSvg:()=>se.current}),I.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[I.jsx(LYn,{laid:Ye,svgRef:se,onRefClick:_n}),z&&I.jsx(PYn,{doc:p.doc,raw:p.raw,yamlOpen:ee,onToggleYaml:()=>ce(hn=>!hn),realizedSlice:ie,kinds:E})]})]})}const jbn=.25,Sbn=4,Y1n=1.2,r7e=f=>Math.max(jbn,Math.min(Sbn,f));function LYn({laid:f,svgRef:d,onRefClick:p}){const m=i7("(max-width: 768px)"),E=Fn.useMemo(()=>{if(!m||typeof window>"u")return 1;const U=window.innerWidth-48;return r7e(Math.min(1,U/f.totalWidth))},[m,f.totalWidth]),[M,k]=Fn.useState(E),D=Fn.useRef(M);D.current=M;const z=Fn.useRef(null);return Fn.useEffect(()=>{k(E)},[E]),kdn({scrollRef:z,zoomRef:D,setZoom:k,min:jbn,max:Sbn,enabled:!0}),I.jsxs("div",{style:{flex:1,position:"relative",overflow:"hidden",display:"flex"},children:[I.jsx("div",{ref:z,style:{flex:1,overflow:"auto",padding:24,touchAction:"pan-x pan-y",overscrollBehavior:"contain"},children:I.jsx("div",{style:{width:f.totalWidth*M,height:f.totalHeight*M},children:I.jsx("div",{style:{transform:`scale(${M})`,transformOrigin:"0 0"},children:I.jsx($Yn,{laid:f,svgRef:d,...p!==void 0?{onRefClick:p}:{}})})})}),I.jsx(jdn,{zoom:M,onZoomIn:()=>k(U=>r7e(U*Y1n)),onZoomOut:()=>k(U=>r7e(U/Y1n)),onZoomReset:()=>k(E)})]})}function RYn({backHref:f,backLabel:d,realizedSlice:p,seqName:m,railOpen:E,onToggleRail:M,filename:k,getSvg:D}){return I.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:[I.jsxs("a",{href:f,style:{display:"inline-flex",alignItems:"center",gap:2,color:"var(--archik-fg-dim)",textDecoration:"none"},children:[I.jsx(_7e,{size:14}),d]}),p&&I.jsxs(I.Fragment,{children:[I.jsx(c7e,{}),I.jsx("a",{href:`/__archik/usecases?uc=${encodeURIComponent(p.useCase)}`,style:{color:"var(--archik-fg-dim)",textDecoration:"none",fontFamily:"ui-monospace, monospace",fontSize:12,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"30vw"},children:p.useCase}),I.jsx(c7e,{}),I.jsx("span",{style:{color:"var(--archik-fg)",fontFamily:"ui-monospace, monospace",fontSize:12,whiteSpace:"nowrap"},children:p.slice})]}),!p&&I.jsxs(I.Fragment,{children:[I.jsx(c7e,{}),I.jsx("span",{style:{color:"var(--archik-fg)",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"40vw"},children:m})]}),I.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:6,alignItems:"center"},children:[I.jsx(fbn,{filename:k,getSvg:D}),I.jsx("button",{type:"button",onClick:M,"aria-label":E?"Hide details":"Show details","aria-pressed":E,title:E?"Hide details panel":"Show details panel",className:"archik-btn",style:{padding:"5px 8px"},children:E?I.jsx(bqn,{size:14}):I.jsx(wqn,{size:14})})]})]})}function c7e(){return I.jsx(Ose,{size:12,color:"var(--archik-fg-muted)",style:{marginInline:2}})}function PYn({doc:f,raw:d,yamlOpen:p,onToggleYaml:m,realizedSlice:E,kinds:M}){const k=i7("(max-width: 768px)");return I.jsxs("aside",{style:k?{position:"fixed",right:0,top:48,bottom:0,width:"min(320px, 85vw)",zIndex:30,borderLeft:"1px solid var(--archik-border)",background:"var(--archik-panel)",overflowY:"auto",padding:16,fontSize:12,color:"var(--archik-fg-dim)",boxShadow:"-8px 0 24px rgba(0, 0, 0, 0.3)"}:{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:[I.jsx(ose,{title:"Realizes",children:E?I.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[I.jsx(Q1n,{label:"Use case",children:I.jsxs("a",{href:`/__archik/usecases?uc=${encodeURIComponent(E.useCase)}`,style:lse({color:"var(--archik-accent)"}),children:[E.useCase,E.name?` — ${E.name}`:""]})}),I.jsx(Q1n,{label:"Slice",children:I.jsx("code",{style:lse(),children:E.slice})}),E.slice_data?.description&&I.jsx("div",{style:{marginTop:4,fontSize:11,lineHeight:1.5},children:E.slice_data.description})]}):I.jsxs(edn,{children:["No ",I.jsx("code",{children:"realizes"})," block — this is an ad-hoc / scratch flow, not bound to a use case slice."]})}),I.jsx(ose,{title:`Participants (${f.participants.length})`,children:I.jsx("ul",{style:ndn,children:f.participants.map(D=>{const z=M?.get(D.nodeId),U=z?zp[z]:void 0,ee=U?.icon;return I.jsxs("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 0"},children:[ee?I.jsx(ee,{size:12,color:U.color,strokeWidth:2}):I.jsx("span",{style:{width:12}}),I.jsx("code",{style:lse(),children:D.nodeId}),D.id!==D.nodeId&&I.jsxs("span",{style:{fontSize:10,color:"var(--archik-fg-muted)"},children:["[",D.id,"]"]})]},D.id)})})}),E?.slice_data&&I.jsx(ose,{title:"Proved by",children:(E.slice_data.tests?.length??0)===0?I.jsx(edn,{children:"No tests declared on this slice."}):I.jsx("ul",{style:{...ndn,listStyle:"none",paddingLeft:0},children:E.slice_data.tests.map(D=>I.jsxs("li",{style:{...lse(),fontSize:11,padding:"2px 0"},children:[I.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"•"})," ",D]},D))})}),I.jsxs(ose,{title:"Source",children:[I.jsxs("button",{type:"button",onClick:m,className:"archik-btn",style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"4px 8px"},children:[I.jsx(ldn,{size:11}),p?"Hide YAML":"View YAML"]}),p&&I.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:d})]})]})}function ose({title:f,children:d}){return I.jsxs("section",{style:{marginBottom:18},children:[I.jsx("h2",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--archik-fg-muted)",margin:"0 0 6px"},children:f}),d]})}function Q1n({label:f,children:d}){return I.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline"},children:[I.jsx("span",{style:{fontSize:9,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",width:56,flexShrink:0},children:f}),I.jsx("span",{style:{flex:1,minWidth:0},children:d})]})}function edn({children:f}){return I.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-muted)",lineHeight:1.5},children:f})}function lse(f){return{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:11,color:"var(--archik-fg)",textDecoration:"none",...f}}const ndn={margin:0,paddingLeft:0,listStyle:"none"},zYn=If({id:Fo.optional(),from:Fo,to:Fo,label:ms().min(1),data:If({in:hH().optional(),out:hH().optional()}).optional(),status:lk(["ok","error"]).default("ok")}),BYn=If({version:LI("1.0"),useCase:Fo,slice:Fo,seqFile:ms().min(1).optional(),recordedAt:ms().min(1),steps:_1(zYn).min(1)});function FYn({trace:f,back:d}){return I.jsxs("div",{className:"archik-trace-page",style:{display:"flex",flexDirection:"column",height:"100dvh",background:"var(--archik-canvas)",color:"var(--archik-fg)",fontFamily:"Inter, system-ui, sans-serif"},children:[I.jsx(qYn,{trace:f,back:d??null}),I.jsx("main",{style:{flex:1,overflowY:"auto",padding:"24px 32px"},children:I.jsxs("div",{style:{maxWidth:760,margin:"0 auto"},children:[I.jsx(GYn,{trace:f}),I.jsx("ol",{style:{listStyle:"none",margin:"20px 0 0",padding:0,display:"flex",flexDirection:"column",gap:0},children:f.steps.map((p,m)=>I.jsx(UYn,{step:p,index:m,last:m===f.steps.length-1},p.id??`${p.from}->${p.to}:${m}`))})]})})]})}function qYn({trace:f,back:d}){const p=d?d.type==="usecase"?`/__archik/usecases?uc=${encodeURIComponent(d.value)}`:`/?file=${encodeURIComponent(d.value)}`:`/__archik/usecases?uc=${encodeURIComponent(f.useCase)}`,m=d?.type==="file"?"Architecture":"Use cases";return I.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:[I.jsxs("a",{href:p,style:{display:"inline-flex",alignItems:"center",gap:2,color:"var(--archik-fg-dim)",textDecoration:"none"},children:[I.jsx(_7e,{size:14}),m]}),I.jsx(tdn,{}),I.jsx("a",{href:`/__archik/usecases?uc=${encodeURIComponent(f.useCase)}`,style:{color:"var(--archik-fg-dim)",textDecoration:"none",fontFamily:"ui-monospace, monospace",fontSize:12},children:f.useCase}),I.jsx(tdn,{}),I.jsx("span",{style:{color:"var(--archik-fg)",fontFamily:"ui-monospace, monospace",fontSize:12},children:f.slice}),I.jsx("span",{className:"archik-pill",style:{fontSize:9,marginLeft:8},title:"Concrete run — recorded values from a real test",children:"concrete run"})]})}function tdn(){return I.jsx(Ose,{size:12,color:"var(--archik-fg-muted)",style:{marginInline:2}})}function GYn({trace:f}){return I.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:24,padding:"12px 16px",background:"var(--archik-surface)",borderRadius:8,fontSize:12},children:[I.jsx(fse,{label:"Use case / slice",children:I.jsxs("code",{style:Mse(),children:[f.useCase," / ",f.slice]})}),I.jsx(fse,{label:"Recorded at",children:I.jsx("span",{style:{color:"var(--archik-fg)"},children:f.recordedAt})}),I.jsx(fse,{label:"Steps",children:I.jsx("span",{style:{color:"var(--archik-fg)"},children:f.steps.length})}),f.seqFile&&I.jsx(fse,{label:"Bound to",children:I.jsxs("a",{href:`/__archik/seq?path=${encodeURIComponent(f.seqFile)}&from-uc=${encodeURIComponent(f.useCase)}`,style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-accent)",textDecoration:"none",...Mse()},title:"Open the abstract sequence diagram this run realises",children:[I.jsx(ldn,{size:11}),f.seqFile]})})]})}function UYn({step:f,index:d,last:p}){const[m,E]=Fn.useState(!1),M=f.data!==void 0&&(f.data.in!==void 0||f.data.out!==void 0);return I.jsxs("li",{style:{display:"grid",gridTemplateColumns:"20px 1fr",columnGap:12},children:[I.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[I.jsx(HYn,{status:f.status}),!p&&I.jsx("span",{style:{flex:1,width:2,minHeight:12,background:"var(--archik-border)"}})]}),I.jsxs("div",{style:{paddingBottom:p?0:16},children:[I.jsxs("button",{type:"button",onClick:()=>M&&E(k=>!k),className:"archik-btn","aria-expanded":M?m:void 0,disabled:!M,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 10px",background:"var(--archik-panel)",border:"1px solid var(--archik-border)",borderRadius:8,textAlign:"left",cursor:M?"pointer":"default"},children:[I.jsxs("span",{style:{color:"var(--archik-fg-muted)",fontSize:11},children:[d+1,"."]}),I.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11},children:[I.jsx("code",{style:Mse(),children:f.from}),I.jsx(Ose,{size:11,color:"var(--archik-fg-muted)"}),I.jsx("code",{style:Mse(),children:f.to})]}),I.jsx("span",{style:{fontSize:13,color:"var(--archik-fg)",fontWeight:500,marginLeft:4},children:f.label}),f.status==="error"&&I.jsx("span",{className:"archik-pill",style:{fontSize:9,color:"var(--archik-danger)",borderColor:"var(--archik-danger)"},children:"error"}),M&&I.jsx(Cse,{size:14,color:"var(--archik-fg-muted)",style:{marginLeft:"auto",transform:m?"rotate(180deg)":"none",transition:"transform 0.12s"}}),!M&&I.jsx("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--archik-fg-muted)"},children:"no data"})]}),m&&M&&I.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,marginTop:8},children:[f.data?.in!==void 0&&I.jsx(idn,{label:"in",value:f.data.in}),f.data?.out!==void 0&&I.jsx(idn,{label:"out",value:f.data.out})]})]})]})}function idn({label:f,value:d}){return I.jsxs("div",{children:[I.jsx("div",{style:{fontSize:9,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--archik-fg-muted)",marginBottom:2},children:f}),I.jsx("pre",{style:{margin:0,padding:10,background:"var(--archik-surface)",border:"1px solid var(--archik-border)",borderRadius:6,fontSize:11,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--archik-fg-dim)",overflowX:"auto",whiteSpace:"pre"},children:JSON.stringify(d,null,2)})]})}function HYn({status:f}){return f==="error"?I.jsx("span",{"aria-label":"error",title:"error",style:{display:"inline-flex"},children:I.jsx(dFn,{size:16,color:"var(--archik-danger)"})}):I.jsx("span",{"aria-label":"ok",title:"ok",style:{display:"inline-flex"},children:I.jsx(gFn,{size:16,color:"var(--archik-success)"})})}function fse({label:f,children:d}){return I.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[I.jsx("span",{style:{fontSize:9,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)"},children:f}),I.jsx("span",{children:d})]})}function Mse(f){return{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:11,color:"var(--archik-fg)",textDecoration:"none",...f}}function JYn({path:f,back:d}){const[p,m]=Fn.useState({status:"loading"});return Fn.useEffect(()=>{m({status:"loading"});const E=encodeURIComponent(f);fetch(`/__archik/trace-file?path=${E}`).then(async M=>{if(!M.ok)throw new Error(`${M.status} ${M.statusText}`);return M.text()}).then(M=>{const k=JSON.parse(M),D=BYn.safeParse(k);if(!D.success)throw new Error(D.error.issues.map(z=>z.message).join("; "));m({status:"ready",doc:D.data})}).catch(M=>{m({status:"error",message:M instanceof Error?M.message:String(M)})})},[f]),p.status==="loading"?I.jsx("div",{className:"flex h-screen items-center justify-center",style:{color:"var(--archik-fg-muted)"},children:"Loading trace…"}):p.status==="error"?I.jsxs("div",{className:"flex h-screen flex-col items-center justify-center gap-4",children:[I.jsx("div",{style:{color:"var(--archik-danger)"},children:p.message}),I.jsx("a",{href:"/__archik/usecases",style:{color:"var(--archik-fg-muted)",fontSize:13},children:"← Use cases"})]}):I.jsx(FYn,{trace:p.doc,back:d})}const KYn="/__archik/usecases",ZYn="/__archik/trace",XYn="/__archik/traces";async function s7e(f,d){const p=await fetch(f,{cache:"no-store",signal:d});if(!p.ok)throw new Error(`HTTP ${p.status} ${p.statusText}`);return await p.json()}function VYn({selectedId:f}){const[d,p]=Fn.useState({status:"loading"}),m=i7("(max-width: 768px)");return Fn.useEffect(()=>{let E=!1;const M=new AbortController;return Promise.all([s7e(KYn,M.signal),s7e(ZYn,M.signal),s7e(XYn,M.signal).catch(()=>({ok:!0,traces:[]}))]).then(([k,D,z])=>{E||p({status:"ready",useCases:k.useCases??[],trace:D.rows??[],traceDocs:z.traces??[]})}).catch(k=>{E||M.signal.aborted||p({status:"error",message:k instanceof Error?k.message:String(k)})}),()=>{E=!0,M.abort()}},[]),I.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100dvh",background:"var(--archik-canvas)",color:"var(--archik-fg)",fontFamily:"Inter, system-ui, sans-serif"},children:[I.jsx(WYn,{state:d}),I.jsxs("div",{style:{flex:1,display:"flex",flexDirection:m?"column":"row",overflow:"hidden"},children:[d.status==="loading"&&I.jsx(u7e,{children:"Loading…"}),d.status==="error"&&I.jsxs(u7e,{tone:"error",children:["Couldn't load: ",d.message]}),d.status==="ready"&&d.useCases.length===0&&I.jsxs(u7e,{children:["No use cases defined yet. Add a ",I.jsx("code",{children:"*.archik.uc.yaml"})," file under ",I.jsx("code",{children:".archik/usecases/"}),"."]}),d.status==="ready"&&d.useCases.length>0&&I.jsx(YYn,{useCases:d.useCases,trace:d.trace,traceDocs:d.traceDocs,selectedId:f})]})]})}function WYn({state:f}){const d=i7("(max-width: 640px)"),p=Fn.useMemo(()=>{if(f.status!=="ready")return null;let m=0,E=0,M=0;for(const k of f.trace)k.level==="full"?m++:k.level==="partial"?E++:M++;return{full:m,partial:E,none:M,total:f.trace.length}},[f]);return I.jsxs("header",{style:{display:"flex",alignItems:"center",gap:d?8:16,padding:d?"0 12px":"0 20px",height:52,borderBottom:"1px solid var(--archik-border)",background:"var(--archik-panel)",flexShrink:0},children:[I.jsxs("a",{href:"/",style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-fg-dim)",fontSize:13,textDecoration:"none",whiteSpace:"nowrap"},children:[I.jsx(_7e,{size:14}),"Architecture"]}),I.jsx("span",{style:{color:"var(--archik-border-strong)"},children:"|"}),I.jsx("h1",{style:{fontSize:14,fontWeight:600,margin:0,color:"var(--archik-fg)",whiteSpace:"nowrap"},children:"Use cases"}),p&&p.total>0&&!d&&I.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginLeft:"auto",fontSize:12,color:"var(--archik-fg-dim)"},children:[I.jsxs("span",{children:[I.jsx("span",{style:{color:"var(--archik-success)"},children:"●"})," ",p.full," full"]}),I.jsxs("span",{children:[I.jsx("span",{style:{color:"var(--archik-warning)"},children:"◐"})," ",p.partial," partial"]}),I.jsxs("span",{children:[I.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"○"})," ",p.none," untraced"]}),I.jsxs("span",{style:{color:"var(--archik-fg-muted)"},children:["· ",p.total," ",p.total===1?"slice":"slices"]})]})]})}function YYn({useCases:f,trace:d,traceDocs:p,selectedId:m}){const E=Fn.useMemo(()=>{const z=new Map;for(const U of d){const ee=z.get(U.useCase);if(!ee){z.set(U.useCase,U.level);continue}ee==="none"||U.level==="none"?z.set(U.useCase,"none"):(ee==="partial"||U.level==="partial")&&z.set(U.useCase,"partial")}return z},[d]),M=Fn.useMemo(()=>{const z=new Map;for(const U of d)z.set(`${U.useCase}/${U.slice}`,U);return z},[d]),k=Fn.useMemo(()=>{const z=new Map;for(const U of p)z.set(`${U.useCase}/${U.slice}`,U);return z},[p]),D=f.find(z=>z.id===m)??f[0];return I.jsxs(I.Fragment,{children:[I.jsx(QYn,{useCases:f,ucLevel:E,selectedId:D.id}),I.jsx(eQn,{useCase:D,traceByKey:M,traceDocByKey:k})]})}function QYn({useCases:f,ucLevel:d,selectedId:p}){const m=i7("(max-width: 768px)");return I.jsx("nav",{"aria-label":"Use cases",style:{width:m?"100%":260,...m?{maxHeight:"40dvh",borderBottom:"1px solid var(--archik-border)"}:{borderRight:"1px solid var(--archik-border)"},background:"var(--archik-panel)",overflowY:"auto",padding:"8px 0",flexShrink:0},children:I.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:f.map(E=>{const M=d.get(E.id)??"none",k=E.id===p;return I.jsx("li",{children:I.jsxs("a",{href:`/__archik/usecases?uc=${encodeURIComponent(E.id)}`,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 14px",textDecoration:"none",color:"var(--archik-fg)",background:k?"var(--archik-surface-hover)":"transparent",borderLeft:k?"2px solid var(--archik-accent)":"2px solid transparent",fontSize:13},children:[I.jsx(Ebn,{level:M}),I.jsxs("span",{style:{flex:1,minWidth:0},children:[I.jsx("code",{style:{fontSize:12,fontFamily:"ui-monospace, monospace"},children:E.id}),I.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:E.name})]}),E.status&&E.status!=="active"&&I.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:4,background:"var(--archik-surface)",color:"var(--archik-fg-muted)"},children:E.status})]})},E.id)})})})}function Ebn({level:f}){const d=f==="full"?{glyph:"●",color:"var(--archik-success)",label:"fully traced"}:f==="partial"?{glyph:"◐",color:"var(--archik-warning)",label:"partially traced"}:{glyph:"○",color:"var(--archik-fg-muted)",label:"untraced"};return I.jsx("span",{title:d.label,"aria-label":d.label,style:{color:d.color,fontSize:12,lineHeight:1,width:12},children:d.glyph})}function eQn({useCase:f,traceByKey:d,traceDocByKey:p}){return I.jsx("main",{style:{flex:1,overflowY:"auto",padding:"24px 32px"},children:I.jsxs("div",{style:{maxWidth:820,margin:"0 auto"},children:[I.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:12,marginBottom:4},children:[I.jsx("code",{style:{fontSize:18,fontFamily:"ui-monospace, monospace",fontWeight:600,color:"var(--archik-fg)"},children:f.id}),f.status&&f.status!=="active"&&I.jsx("span",{className:"archik-pill",style:{fontSize:10},children:f.status})]}),I.jsx("div",{style:{fontSize:15,color:"var(--archik-fg-dim)",marginBottom:18},children:f.name}),I.jsx(nQn,{useCase:f}),f.goal&&I.jsx(fI,{title:"Goal",children:I.jsx("p",{style:{margin:0,lineHeight:1.55},children:f.goal})}),(f.preconditions?.length??0)>0&&I.jsx(fI,{title:"Preconditions",children:I.jsx("ul",{style:sH,children:f.preconditions.map((m,E)=>I.jsx("li",{children:m},E))})}),f.flows?.basic?.steps&&I.jsx(fI,{title:"Basic flow",children:I.jsx("ol",{style:{...sH,paddingLeft:22},children:f.flows.basic.steps.map((m,E)=>I.jsx("li",{style:{marginBottom:4},children:m},E))})}),(f.flows?.alternates?.length??0)>0&&I.jsx(fI,{title:"Alternate flows",children:f.flows.alternates.map(m=>I.jsxs("div",{style:{marginBottom:12,padding:12,background:"var(--archik-surface)",borderRadius:6,borderLeft:"3px solid var(--archik-warning)"},children:[I.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline",marginBottom:6},children:[I.jsx("code",{style:{fontSize:12,fontWeight:600},children:m.id}),m.branchFrom&&I.jsxs("span",{style:{fontSize:11,color:"var(--archik-fg-muted)"},children:["branches from ",m.branchFrom]})]}),I.jsx("ol",{style:{...sH,paddingLeft:22,fontSize:13},children:m.steps.map((E,M)=>I.jsx("li",{children:E},M))})]},m.id))}),(f.postconditions?.length??0)>0&&I.jsx(fI,{title:"Postconditions",children:I.jsx("ul",{style:sH,children:f.postconditions.map((m,E)=>I.jsx("li",{children:m},E))})}),(()=>{const m=f.slices??[];return I.jsx(fI,{title:`Slices (${m.length})`,children:m.length===0?I.jsx("div",{style:{fontSize:12,color:"var(--archik-fg-muted)"},children:"— no slices declared"}):I.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:m.map(E=>I.jsx(tQn,{slice:E,useCaseId:f.id,trace:d.get(`${f.id}/${E.id}`),traceDoc:p.get(`${f.id}/${E.id}`)},E.id))})})})(),I.jsxs("div",{style:{marginTop:32,paddingTop:16,borderTop:"1px solid var(--archik-border)",fontSize:11,color:"var(--archik-fg-muted)"},children:["Source:"," ",I.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:f.relPath})]})]})})}function nQn({useCase:f}){return I.jsxs("div",{style:{display:"flex",gap:24,padding:"10px 14px",background:"var(--archik-surface)",borderRadius:6,marginBottom:20,fontSize:12},children:[I.jsxs("div",{children:[I.jsx("div",{style:C7e,children:"Primary actor"}),I.jsx("div",{style:{marginTop:2},children:I.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:f.primaryActor})})]}),(f.secondaryActors?.length??0)>0&&I.jsxs("div",{children:[I.jsx("div",{style:C7e,children:"Secondary actors"}),I.jsx("div",{style:{marginTop:2},children:f.secondaryActors.map((d,p)=>I.jsxs("span",{children:[I.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:d}),p<f.secondaryActors.length-1&&", "]},d))})]})]})}function tQn({slice:f,useCaseId:d,trace:p,traceDoc:m}){const E=p?.level??"none";return I.jsxs("div",{style:{padding:14,background:"var(--archik-panel)",border:"1px solid var(--archik-border)",borderRadius:8},children:[I.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,marginBottom:8},children:[I.jsx(Ebn,{level:E}),I.jsx("code",{style:{fontSize:13,fontFamily:"ui-monospace, monospace",fontWeight:600},children:f.id}),f.status&&f.status!=="active"&&I.jsxs("span",{style:{fontSize:10,color:"var(--archik-fg-muted)"},children:["[",f.status,"]"]}),I.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--archik-fg-muted)"},children:p?.realization&&p.realization.participants.length>0&&I.jsxs(I.Fragment,{children:["ECB"," ",p.realization.participants.filter(M=>M.stereotype!==void 0).length,"/",p.realization.participants.length]})})]}),f.description&&I.jsx("div",{style:{fontSize:13,color:"var(--archik-fg-dim)",marginBottom:10,lineHeight:1.5},children:f.description}),I.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:14,rowGap:8,fontSize:12,alignItems:"start"},children:[I.jsx("div",{style:ase,children:"Tests"}),I.jsx("div",{children:(f.tests?.length??0)===0?I.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"— none declared"}):I.jsx("ul",{style:{...sH,paddingLeft:0,listStyle:"none"},children:f.tests.map(M=>I.jsxs("li",{style:{fontFamily:"ui-monospace, monospace",fontSize:11},children:[I.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"•"})," ",M]},M))})}),I.jsx("div",{style:ase,children:"Realization"}),I.jsx("div",{children:f.realization?I.jsxs("a",{href:`/__archik/seq?path=${encodeURIComponent(f.realization.seqFile)}&from-uc=${encodeURIComponent(d)}`,style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-accent)",textDecoration:"none",fontFamily:"ui-monospace, monospace",fontSize:11},children:[I.jsx(udn,{size:11}),iQn(f.realization.seqFile),I.jsx(o7e,{size:11,style:{opacity:.7}})]}):I.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"— no seq file yet"})}),I.jsx("div",{style:ase,children:"Flow chart"}),I.jsx("div",{children:m?I.jsxs("a",{href:`/__archik/trace-page?path=${encodeURIComponent(m.relPath)}&from-uc=${encodeURIComponent(d)}`,style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-accent)",textDecoration:"none",fontSize:11},title:`Open the concrete run (${m.steps} steps)`,children:["● Concrete run",I.jsxs("span",{style:{color:"var(--archik-fg-muted)"},children:[" ",m.recordedAt]}),I.jsx(o7e,{size:11,style:{opacity:.7}})]}):I.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"— no recorded run yet"})}),I.jsx("div",{style:ase,children:"Flows"}),I.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-dim)"},children:(f.flows??[]).join(", ")||"—"})]})]})}function iQn(f){return f.split("/").pop()?.replace(/\.archik\.seq\.yaml$/,"")??f}function fI({title:f,children:d}){return I.jsxs("section",{style:{marginBottom:24},children:[I.jsx("h2",{style:{fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",margin:"0 0 8px"},children:f}),d]})}function u7e({children:f,tone:d}){return I.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:d==="error"?"var(--archik-danger)":"var(--archik-fg-muted)",fontSize:13,padding:24,textAlign:"center"},children:f})}const C7e={fontSize:10,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",fontWeight:600},ase={...C7e,fontSize:10,paddingTop:1},sH={margin:0,paddingLeft:18,fontSize:13,lineHeight:1.55},xbn=document.getElementById("root");if(!xbn)throw new Error("#root not found");const rk=new URLSearchParams(window.location.search),MI=window.location.pathname,rQn=MI==="/__archik/seq"||MI.startsWith("/__archik/seq/"),cQn=MI==="/__archik/trace-page"||MI.startsWith("/__archik/trace-page/"),sQn=MI==="/__archik/usecases"||MI.startsWith("/__archik/usecases/"),hse=vBn.createRoot(xbn);if(rQn){const f=rk.get("path")??"",d=rk.get("from-uc"),p=rk.get("from-file")??rk.get("from"),m=d?{type:"usecase",value:d}:p?{type:"file",value:p}:null;hse.render(I.jsx(Fn.StrictMode,{children:I.jsx(DYn,{path:f,back:m})}))}else if(cQn){const f=rk.get("path")??"",d=rk.get("from-uc"),p=rk.get("from-file")??rk.get("from"),m=d?{type:"usecase",value:d}:p?{type:"file",value:p}:null;hse.render(I.jsx(Fn.StrictMode,{children:I.jsx(JYn,{path:f,back:m})}))}else if(sQn){const f=rk.get("uc");hse.render(I.jsx(Fn.StrictMode,{children:I.jsx(VYn,{selectedId:f})}))}else hse.render(I.jsx(Fn.StrictMode,{children:I.jsx(iYn,{})}));
|
|
226
|
+
`);return d===-1?f:f.slice(0,d)}function XWn({files:f,currentPath:d,onSwitchFile:p}){const m=f.some(M=>M.hasSuggestion||M.isOrphanSuggestion);if(f.length<=1&&!m)return null;const E=f.find(M=>M.path===d)??f[0];return I.jsx(u7,{align:"start",trigger:M=>I.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:[I.jsx(zFn,{size:13,strokeWidth:1.8}),I.jsx("span",{style:{fontWeight:600},children:E.name}),E.hasSuggestion&&I.jsx(Tse,{}),I.jsx(Cse,{size:12,strokeWidth:2,style:{opacity:.6}})]}),children:M=>I.jsxs("div",{style:{minWidth:"min(220px, calc(100vw - 16px))",padding:4},children:[I.jsx("div",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--archik-fg-muted)",padding:"6px 10px 4px"},children:"Architecture files"}),f.map(k=>{const D=k.path===E.path,z=k.isOrphanSuggestion===!0;return I.jsxs("button",{type:"button",title:z?`Pending sub-architecture (sidecar only — no main file yet). Click to view; accept via \`npx archik suggest accept ${k.path.replace(/\.archik\.suggested\.yaml$/,".archik.yaml")}\` to promote it, or /archik:accept.`:void 0,onClick:()=>{M(),!D&&p(k)},className:"archik-menu-item",style:{display:"flex",alignItems:"center",gap:8,width:"100%",textAlign:"left",padding:"6px 10px",fontSize:12,background:D?"var(--archik-surface-hover)":void 0,borderLeft:z?"2px dashed var(--archik-accent)":void 0,paddingLeft:z?8:void 0},children:[I.jsxs("span",{style:{fontWeight:D?600:400,color:"var(--archik-fg)"},children:[k.name,z&&I.jsx("span",{style:{marginLeft:6,fontSize:10,fontWeight:500,color:"var(--archik-accent)",letterSpacing:"0.04em"},children:"(pending)"})]}),k.hasSuggestion&&!z&&I.jsx(Tse,{}),I.jsx("span",{style:{flex:1,fontSize:10,fontFamily:"ui-monospace, monospace",color:"var(--archik-fg-muted)",textAlign:"right"},children:k.path})]},k.path)})]})})}function Tse(){return I.jsx("span",{"aria-label":"pending suggestion",title:"Pending suggestion",style:{width:6,height:6,borderRadius:3,background:"var(--archik-accent)",flexShrink:0}})}function VWn({stack:f,onGoToFrame:d,suggestionsByPath:p}){return f.length<=1?null:I.jsx("nav",{"aria-label":"Architecture file navigation",style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--archik-fg-muted)"},children:f.map((m,E)=>{const M=E===f.length-1,k=m.archikFile!==null&&p!==void 0&&p.has(m.archikFile);return I.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[M?I.jsxs("span",{style:{color:"var(--archik-fg)",fontWeight:600,display:"inline-flex",alignItems:"center",gap:6},"aria-current":"page",children:[m.label,k&&I.jsx(Tse,{})]}):I.jsxs("button",{type:"button",onClick:()=>d(E),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 ${m.label}`,children:[m.label,k&&I.jsx(Tse,{})]}),!M&&I.jsx("span",{"aria-hidden":"true",style:{opacity:.5},children:"›"})]},`${E}-${m.archikFile??"root"}`)})})}const WWn="/architecture.archik.yaml",YWn="/architecture.archik.suggested.yaml",QWn="/__archik/accept-suggestion",eYn=1500,T7e={label:"main",docUrl:WWn,sidecarUrl:YWn,acceptUrl:QWn,archikFile:null};function gbn(f,d){const p=f.replace(/\.archik\.yaml$/,".archik.suggested.yaml"),m=encodeURIComponent(f),E=encodeURIComponent(p);return{label:d,docUrl:`/__archik/file?path=${m}`,sidecarUrl:`/__archik/file?path=${E}`,acceptUrl:`/__archik/file-accept?path=${m}`,archikFile:f}}function nYn(){if(typeof window>"u")return null;const f=new URLSearchParams(window.location.search).get("file");return f!==null&&f.length>0?f:null}function tYn(f){if(typeof window>"u")return;const d=new URL(window.location.href);f===null||f.length===0?d.searchParams.delete("file"):d.searchParams.set("file",f),window.history.replaceState(null,"",d.toString())}function U1n(){const f=nYn();if(f===null)return[T7e];const p=(f.split("/").pop()??f).replace(/\.archik\.yaml$/i,"")||"main";return[gbn(f,p)]}function iYn(){const[f,d]=Fn.useState({status:"loading"}),[p,m]=Fn.useState(U1n),E=p[p.length-1],[M,k]=Fn.useState([]),D=Fn.useMemo(()=>new Set(M.filter(on=>on.hasSuggestion).map(on=>on.path)),[M]),z=Fn.useMemo(()=>M.find(on=>on.isRoot)??null,[M]),U=E.archikFile===null?z?.path??null:E.archikFile,[ee,ce]=Fn.useState(void 0),[se,pe]=Fn.useState(void 0),[Je,ie]=Fn.useState("idle"),[Ye,an]=Fn.useState(null),[_n,hn]=Fn.useState(!1),[Rn,nt]=Fn.useState(!1),[ot,et]=Fn.useState({status:"none"}),[gt,dr]=Fn.useState(!1),[tc,Lr]=Fn.useState([]),[Ni,Q]=Fn.useState([]),Pu=100,[zu,Hn]=Fn.useState(()=>gWn()),tt=on=>{Hn(on),wWn(on)},[di,br]=Fn.useState(()=>dWn()),jc=on=>{br(on),bWn(on)},[Ke,Yn]=Fn.useState(()=>aWn()),Ut=on=>{Yn(on),hWn(on)},ci=Fn.useMemo(()=>({...pWn(zu),viewMode:di}),[zu,di]),gr=Fn.useMemo(()=>f.status==="ready"?new Set(f.document.nodes.filter(on=>(on.seqFiles?.length??0)>0).map(on=>on.id)):new Set,[f]),Kr=Fn.useRef(!1),_c=Fn.useRef(null),Bu=Fn.useRef(null),Ws=Fn.useCallback(()=>Bu.current,[]),gh=Fn.useRef(null),hu=Nf(on=>on.selection),da=Nf(on=>on.connectFrom),fk=Nf(on=>on.selectNode),Ba=Nf(on=>on.selectEdge),py=Nf(on=>on.toggleNode),ov=Nf(on=>on.toggleEdge),A0=Nf(on=>on.clearSelection),o7=Nf(on=>on.startConnect),cs=Nf(on=>on.cancelConnect),Bs=Nf(on=>on.collapsed),lv=Nf(on=>on.hideStructural),ss=Nf(on=>on.focus),NA=Nf(on=>on.collapseAll),wh=Nf(on=>on.expandAll),IA=Nf(on=>on.setHideStructural),l7=Nf(on=>on.setFocusDepth),qp=Nf(on=>on.clearFocus),Xh=hu.length>0?hu.at(-1)??null:null,$A=Fn.useMemo(()=>new Set(hu.filter(on=>on.type==="node").map(on=>on.id)),[hu]),f7=Fn.useMemo(()=>new Set(hu.filter(on=>on.type==="edge").map(on=>on.id)),[hu]);Fn.useEffect(()=>{const on=p[p.length-1];tYn(on.archikFile)},[p]),Fn.useEffect(()=>{if(typeof window>"u")return;const on=()=>m(U1n());return window.addEventListener("popstate",on),()=>window.removeEventListener("popstate",on)},[]),Fn.useEffect(()=>{let on=!1;_c.current="",Kr.current=!1;const Pt=()=>{sVn(E.docUrl).then(({document:Ii,text:Tr})=>{if(on||Tr===_c.current)return;_c.current=Tr,Kr.current=!0,d({status:"ready",document:Ii}),hn(!1),typeof window<"u"&&Ii.name&&(window.document.title=`${Ii.name} — Archik`),pe(void 0),Lr([]),Q([]);const tl=new Set(Ii.nodes.map($s=>$s.id)),Au=new Set(Ii.edges.map($s=>$s.id));Nf.setState($s=>({selection:$s.selection.filter(Yu=>Yu.type==="node"?tl.has(Yu.id):Au.has(Yu.id)),connectFrom:$s.connectFrom!==null&&tl.has($s.connectFrom)?$s.connectFrom:null}))},Ii=>{if(on)return;const Tr=Ii instanceof Error?Ii.message:String(Ii);Kr.current?pe(Tr):d({status:"error",error:Tr})})};d({status:"loading"}),Pt();const Xi=$1n(Pt);return()=>{on=!0,Xi()}},[E.docUrl]),Fn.useEffect(()=>()=>{gh.current&&clearTimeout(gh.current)},[]),Fn.useEffect(()=>{let on=!1;const Pt=async()=>{try{const Tr=await fetch("/__archik/files",{cache:"no-store"});if(on||!Tr.ok)return;const tl=await Tr.json();if(on)return;Array.isArray(tl.files)&&k(tl.files)}catch{}};Pt();const Xi=$1n(()=>{Pt()}),Ii=D1n(()=>{Pt()});return()=>{on=!0,Xi(),Ii()}},[]),Fn.useEffect(()=>{if(f.status!=="ready")return;const on=f.document;let Pt=!1;const Xi=async()=>{if(U!==null&&M.length>0&&M.some(Tr=>Tr.path===U)&&!D.has(U)){et({status:"none"});return}try{const Tr=await fetch(E.sidecarUrl,{cache:"no-store"});if(Pt)return;if(Tr.status===404){et({status:"none"});return}if(!Tr.ok){et({status:"error",message:`Sidecar fetch failed: HTTP ${Tr.status}`});return}const tl=await Tr.text();let Au;try{Au=tbn(tl)}catch(Yu){et({status:"error",message:Yu instanceof Error?Yu.message:String(Yu)});return}const $s=E7e(on,Au);et({status:"pending",added:$s.nodes.added.length+$s.edges.added.length,removed:$s.nodes.removed.length+$s.edges.removed.length,changed:$s.nodes.changed.length+$s.edges.changed.length,doc:Au,...Au.metadata?.suggestion?.note!==void 0?{note:Au.metadata.suggestion.note}:{}})}catch(Tr){if(Pt)return;et({status:"error",message:Tr instanceof Error?Tr.message:String(Tr)})}};Xi();const Ii=D1n(Xi);return()=>{Pt=!0,Ii()}},[f,E.sidecarUrl,U,M,D]);const DA=Fn.useCallback(async()=>{try{const on=await fetch(E.acceptUrl,{method:"POST"});if(!on.ok){const Pt=await on.text();et({status:"error",message:`Accept failed: ${Pt||`HTTP ${on.status}`}`});return}et({status:"none"}),dr(!1)}catch(on){et({status:"error",message:on instanceof Error?on.message:String(on)})}},[E.acceptUrl]),LA=Fn.useCallback(async()=>{try{const on=await fetch(E.sidecarUrl,{method:"DELETE"});if(!on.ok&&on.status!==404){const Pt=await on.text();et({status:"error",message:`Reject failed: ${Pt||`HTTP ${on.status}`}`});return}et({status:"none"}),dr(!1)}catch(on){et({status:"error",message:on instanceof Error?on.message:String(on)})}},[E.sidecarUrl]),fv=Fn.useCallback(()=>{dr(on=>!on)},[]),ba=Fn.useCallback(async()=>{let on=null;if(d(Xi=>(Xi.status==="ready"&&(on=Xi.document),Xi)),!on)return;const Pt=oje(on);_c.current=Pt,ie("saving"),an(null);try{await uVn(E.docUrl,on),ie("saved");let Xi=!1;d(Ii=>(Ii.status==="ready"&&Ii.document===on&&(Xi=!0),Ii)),Xi&&hn(!1),gh.current&&clearTimeout(gh.current),gh.current=setTimeout(()=>ie("idle"),eYn)}catch(Xi){ie("error"),an(Xi instanceof Error?Xi.message:String(Xi))}},[E.docUrl]),N1=z?.path??null,$f=Fn.useCallback((on,Pt)=>N1===on?T7e:gbn(on,Pt),[N1]),my=Fn.useCallback((on,Pt)=>on.archikFile===Pt?!0:on.archikFile===null&&N1===Pt,[N1]),RA=Fn.useCallback((on,Pt)=>{m(Xi=>{const Ii=Xi.findIndex(Tr=>my(Tr,on));return Ii>=0?Ii===Xi.length-1?Xi:Xi.slice(0,Ii+1):[...Xi,$f(on,Pt)]})},[$f,my]),ak=Fn.useCallback((on,Pt)=>{m(Xi=>{const Ii=Xi[Xi.length-1];return my(Ii,on)?Xi:[$f(on,Pt)]})},[$f,my]),vy=Fn.useCallback(on=>{m(Pt=>on<0||on>=Pt.length-1?Pt:Pt.slice(0,on+1))},[]),yy=Fn.useCallback(on=>{on.isRoot?m([T7e]):ak(on.path,on.name)},[ak]),ky=Fn.useCallback((on,Pt)=>{if(da===null){Pt&&(Pt.metaKey||Pt.ctrlKey||Pt.shiftKey)?py(on):fk(on);return}if(on===da){cs();return}let Xi=null;d(Ii=>{if(Ii.status!=="ready"||!Ii.document.nodes.find(Yu=>Yu.id===da))return Ii;const tl=new Set(Ii.document.edges.map(Yu=>Yu.id)),Au=V8e(X8e(`${da}-${on}`),tl,"edge"),$s={id:Au,from:da,to:on,relationship:"http_call"};try{const Yu=uI(Ii.document,{type:"connect",edge:$s});return ce(void 0),hn(!0),Lr(qo=>[...qo.slice(-(Pu-1)),Ii.document]),Q([]),Xi=Au,{status:"ready",document:Yu}}catch(Yu){const qo=Yu instanceof Error?Yu.message:String(Yu);return ce(qo),Ii}}),cs(),Xi&&Ba(Xi)},[da,cs,fk,py,Ba]),ew=Fn.useCallback((on,Pt)=>{Pt&&(Pt.metaKey||Pt.ctrlKey||Pt.shiftKey)?ov(on):Ba(on)},[Ba,ov]),jy=Fn.useCallback((on,Pt)=>{let Xi=null;d(Ii=>{if(Ii.status!=="ready")return Ii;const Tr=Ii.document.nodes.find(qo=>qo.id===on),tl=Ii.document.nodes.find(qo=>qo.id===Pt);if(!Tr||!tl)return Ii;const Au=new Set(Ii.document.edges.map(qo=>qo.id)),$s=V8e(X8e(`${on}-${Pt}`),Au,"edge"),Yu={id:$s,from:on,to:Pt,relationship:"http_call"};try{const qo=uI(Ii.document,{type:"connect",edge:Yu});return ce(void 0),hn(!0),Lr(Go=>[...Go.slice(-(Pu-1)),Ii.document]),Q([]),Xi=$s,{status:"ready",document:qo}}catch(qo){const Go=qo instanceof Error?qo.message:String(qo);return ce(Go),Ii}}),Xi&&Ba(Xi)},[Ba]),av=Fn.useCallback((on,Pt,Xi)=>{d(Ii=>{if(Ii.status!=="ready")return Ii;const Tr=new Set(Ii.document.nodes.map(Au=>Au.id)),tl=V8e(X8e(Pt),Tr,on);try{const Au=uI(Ii.document,{type:"add_node",node:{id:tl,kind:on,name:Pt,description:Xi}});return ce(void 0),hn(!0),Lr($s=>[...$s.slice(-(Pu-1)),Ii.document]),Q([]),{status:"ready",document:Au}}catch(Au){const $s=Au instanceof Error?Au.message:String(Au);return ce($s),Ii}})},[]),a7=Fn.useCallback(on=>{d(Pt=>{if(Pt.status!=="ready")return Pt;try{const Xi=uI(Pt.document,on);return ce(void 0),hn(!0),Lr(Ii=>[...Ii.slice(-(Pu-1)),Pt.document]),Q([]),{status:"ready",document:Xi}}catch(Xi){const Ii=Xi instanceof Error?Xi.message:String(Xi);return ce(Ii),Pt}})},[]),Sy=Fn.useCallback(()=>{hu.length!==0&&(d(on=>{if(on.status!=="ready")return on;let Pt=on.document;try{const Xi=hu.filter(Tr=>Tr.type==="edge").map(Tr=>Tr.id);for(const Tr of Xi)Pt.edges.some(tl=>tl.id===Tr)&&(Pt=uI(Pt,{type:"disconnect",id:Tr}));const Ii=hu.filter(Tr=>Tr.type==="node").map(Tr=>Tr.id);for(const Tr of Ii)Pt.nodes.some(tl=>tl.id===Tr)&&(Pt=uI(Pt,{type:"remove_node",id:Tr}));return Pt===on.document?on:(ce(void 0),hn(!0),Lr(Tr=>[...Tr.slice(-(Pu-1)),on.document]),Q([]),{status:"ready",document:Pt})}catch(Xi){const Ii=Xi instanceof Error?Xi.message:String(Xi);return ce(Ii),on}}),A0())},[hu,A0]),hv=Fn.useCallback(()=>{if(f.status!=="ready"||tc.length===0)return;const on=tc[tc.length-1];Lr(Pt=>Pt.slice(0,-1)),Q(Pt=>[...Pt,f.document]),d({status:"ready",document:on}),hn(!0),ce(void 0),A0()},[f,tc,A0]),Rb=Fn.useCallback(()=>{if(f.status!=="ready"||Ni.length===0)return;const on=Ni[Ni.length-1];Q(Pt=>Pt.slice(0,-1)),Lr(Pt=>[...Pt,f.document]),d({status:"ready",document:on}),hn(!0),ce(void 0),A0()},[f,Ni,A0]);if(Fn.useEffect(()=>{const on=Pt=>{if((Pt.metaKey||Pt.ctrlKey)&&Pt.key==="s"){Pt.preventDefault(),_n&&ba();return}if((Pt.metaKey||Pt.ctrlKey)&&(Pt.key==="z"||Pt.key==="Z")){Pt.preventDefault(),Pt.shiftKey?Rb():hv();return}if((Pt.metaKey||Pt.ctrlKey)&&Pt.key==="y"){Pt.preventDefault(),Rb();return}if(Pt.key==="Escape"){da?cs():ss&&qp();return}if(Pt.key==="Delete"||Pt.key==="Backspace"){const Xi=Pt.target;if(Xi instanceof HTMLInputElement||Xi instanceof HTMLTextAreaElement||Xi instanceof HTMLSelectElement||Xi instanceof HTMLElement&&Xi.isContentEditable||hu.length===0)return;Pt.preventDefault(),Sy()}};return window.addEventListener("keydown",on),()=>window.removeEventListener("keydown",on)},[_n,ba,da,cs,hu,Sy,hv,Rb,ss,qp]),Fn.useEffect(()=>{f.status==="ready"&&AVn(ss,f.document)&&qp()},[f,ss,qp]),f.status==="loading")return I.jsxs(H1n,{children:["Loading ",E.docUrl,"…"]});if(f.status==="error")return I.jsx(H1n,{children:I.jsx("pre",{className:"max-w-3xl whitespace-pre-wrap text-xs text-rose-700",children:f.error})});const nw=f.document,T0=gt&&ot.status==="pending",hk=T0&&ot.status==="pending"?gVn(nw,ot.doc):null,dk=T0&&ot.status==="pending"?sbn(E7e(nw,ot.doc)):null,kd=hk??nw,bk=Bs.size>0?ubn(kd,Bs):kd,h7={collapsed:Bs,hideStructural:lv,focus:ss!==null&&bk.nodes.some(on=>on.id===ss.id)?ss:null},d7=MVn(kd,h7),M0=Xh?.type==="node"?kd.nodes.find(on=>on.id===Xh.id):void 0,uf=Xh?.type==="edge"?kd.edges.find(on=>on.id===Xh.id):void 0,ga=da!==null?nw.nodes.find(on=>on.id===da):void 0,tw=hu.length>1;return I.jsxs("div",{className:"flex h-full flex-col",style:{background:"var(--archik-canvas)",color:"var(--archik-fg)"},children:[I.jsx(KWn,{document:nw,commandError:ee,saveStatus:Je,...Ye!==null?{saveError:Ye}:{},isDirty:_n,onSave:()=>{ba()},onAddNode:av,density:zu,onDensityChange:tt,viewMode:di,onViewModeChange:jc,showStereotypeBands:Ke,onToggleStereotypeBands:()=>Ut(!Ke),canUndo:tc.length>0,canRedo:Ni.length>0,onUndo:hv,onRedo:Rb,getSvg:Ws,seqHighlight:Rn,onToggleSeqHighlight:()=>nt(on=>!on),seqNodeCount:gr.size,hideStructural:lv,onToggleHideStructural:()=>IA(!lv),onCollapseAll:()=>NA(nw.nodes.filter(on=>nw.nodes.some(Pt=>Pt.parentId===on.id)).map(on=>on.id)),onExpandAll:wh,...ss?{focusDepth:ss.depth,onFocusDepthChange:l7,onClearFocus:qp}:{},...se!==void 0?{reloadError:se}:{},...ga!==void 0?{connectingFromName:ga.name,onCancelConnect:cs}:{}}),ot.status==="pending"&&I.jsx(cYn,{added:ot.added,removed:ot.removed,changed:ot.changed,note:ot.note,reviewing:T0,onReview:fv,onAccept:()=>{DA()},onReject:()=>{LA()}}),ot.status==="error"&&I.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:[I.jsx("span",{style:{fontWeight:700},children:"SUGGESTION ERROR —"}),I.jsx("span",{style:{flex:1,color:"var(--archik-fg)"},children:ot.message}),I.jsx("button",{type:"button",onClick:()=>et({status:"none"}),"aria-label":"Dismiss",style:{background:"transparent",border:"none",color:"var(--archik-fg-dim)",cursor:"pointer",fontSize:16,lineHeight:1},children:"×"})]}),se!==void 0&&I.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:[I.jsx("span",{style:{fontWeight:700,letterSpacing:"0.04em"},children:"FILE INVALID —"}),I.jsx("pre",{style:{margin:0,flex:1,whiteSpace:"pre-wrap",fontFamily:"inherit",color:"var(--archik-fg)"},children:se}),I.jsx("button",{type:"button",onClick:()=>pe(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:"×"})]}),I.jsxs("main",{className:"archik-main flex min-h-0 flex-1 p-4",style:{gap:0},children:[I.jsx("div",{className:"archik-panel",style:{flex:1,minWidth:0,overflow:"hidden"},children:I.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%"},children:[(M.length>1||p.length>1)&&I.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",background:"var(--archik-surface)",borderBottom:"1px solid var(--archik-border)"},children:[I.jsx(XWn,{files:M,currentPath:U,onSwitchFile:yy}),I.jsx(VWn,{stack:p,onGoToFrame:vy,suggestionsByPath:D})]}),I.jsx(KGn,{document:d7,className:"flex-1 archik-grid",layoutOptions:ci,viewMode:di,showStereotypeBands:Ke,selectedNodeIds:$A,selectedEdgeIds:f7,onSelectNode:ky,onSelectEdge:ew,onSelectNothing:da===null?A0:cs,onConnectDrag:jy,onOpenSubFile:RA,onCrossFileNavigate:ak,viewKey:E.docUrl,svgRef:Bu,...dk?{diffStatuses:dk}:{},...Rn&&gr.size>0?{glowNodeIds:gr}:{}})]})}),I.jsx("aside",{"aria-hidden":hu.length===0,className:`archik-drawer-shell ${hu.length>0?"archik-drawer-shell--open":"archik-drawer-shell--closed"}`,children:I.jsxs("div",{className:"archik-panel archik-drawer-content archik-drawer-fade",style:{overflow:"hidden"},children:[I.jsxs("div",{className:"archik-sheet-handle",children:[I.jsx("span",{className:"archik-sheet-grip","aria-hidden":"true"}),I.jsx("button",{type:"button","aria-label":"Close inspector",className:"archik-sheet-close",onClick:A0,children:"✕"})]}),tw?I.jsx(rYn,{count:hu.length,onDelete:Sy,onClear:A0}):Xh?.type==="edge"?I.jsx(FVn,{edge:uf,dispatch:a7,readOnly:T0}):Xh?.type==="node"?I.jsx($Vn,{node:M0,dispatch:a7,onStartConnect:o7,allNodes:kd.nodes,readOnly:T0,viewKey:E.archikFile??void 0}):null]},tw?`multi:${hu.length}`:Xh?`${Xh.type}:${Xh.id}`:"empty")})]})]})}function rYn({count:f,onDelete:d,onClear:p}){return I.jsxs("div",{className:"flex h-full flex-col gap-4 overflow-y-auto p-4 text-sm",children:[I.jsxs("div",{children:[I.jsx("div",{className:"archik-label",children:"Selection"}),I.jsxs("div",{style:{fontSize:18,fontWeight:600,color:"var(--archik-fg)",letterSpacing:"0.01em"},children:[f," items"]}),I.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-dim)",marginTop:4},children:"Hold ⌘ / Ctrl while clicking to add or remove items."})]}),I.jsx("div",{className:"archik-divider"}),I.jsxs("div",{className:"mt-auto flex flex-col gap-2 pt-4",children:[I.jsx("button",{type:"button",onClick:p,className:"archik-btn",style:{justifyContent:"center",padding:"8px 12px"},children:"Clear selection"}),I.jsxs("button",{type:"button",onClick:d,className:"archik-btn archik-btn-danger",style:{justifyContent:"center",padding:"8px 12px"},children:["Delete ",f," items"]})]})]})}function H1n({children:f}){return I.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:f})}function cYn({added:f,removed:d,changed:p,note:m,reviewing:E,onReview:M,onAccept:k,onReject:D}){const z=f+d+p;return I.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:[I.jsx("span",{style:{fontWeight:700,letterSpacing:"0.04em",color:"#c4b5fd"},children:"📝 SUGGESTION PENDING"}),I.jsxs("span",{style:{color:"var(--archik-fg)"},children:[z===0?"(identical to current — nothing to apply)":I.jsxs(I.Fragment,{children:[I.jsxs("span",{style:{color:"var(--archik-success)"},children:["+",f]})," ",I.jsxs("span",{style:{color:"var(--archik-danger)"},children:["−",d]})," ",I.jsxs("span",{style:{color:"var(--archik-warning)"},children:["~",p]})]}),m?I.jsxs("span",{style:{marginLeft:10,color:"var(--archik-fg-dim)",fontStyle:"italic"},children:['"',m,'"']}):null]}),I.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:8},children:[I.jsx("button",{type:"button",onClick:M,className:"archik-btn",style:{padding:"5px 12px",fontSize:12,...E?{background:"#a855f7",color:"white",borderColor:"#a855f7"}:{}},children:E?"Hide diff":"Review"}),I.jsx("button",{type:"button",onClick:k,className:"archik-btn",title:z===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"}),I.jsx("button",{type:"button",onClick:D,className:"archik-btn",style:{padding:"5px 12px",fontSize:12,color:"var(--archik-danger)",borderColor:"var(--archik-danger)"},children:"Reject"})]})]})}const sYn=lk(["sync","async","return","create","destroy"]),uYn=lk(["over","left_of","right_of"]),oYn=lk(["alt","opt","loop","par","break","ref"]),lYn=If({id:Fo,nodeId:Fo,label:ms().min(1).optional(),status:RI.optional()}),fYn=If({type:LI("message"),id:Fo,from:Fo,to:Fo,label:ms().min(1),arrow:sYn,activate:hXn().optional(),status:RI.optional()}),aYn=If({type:LI("note"),id:Fo,position:uYn,participants:_1(Fo).min(1),text:ms().min(1),status:RI.optional()}),hYn=cje(()=>If({label:ms().optional(),steps:_1(wbn)})),dYn=cje(()=>If({type:LI("group"),id:Fo,kind:oYn,condition:ms().optional(),label:ms().optional(),branches:_1(hYn).optional(),seqFile:Y0n.optional(),participants:_1(Fo).optional(),status:RI.optional()})),wbn=cje(()=>Z0n([fYn,aYn,dYn]));function pbn(f,d){const p=[];for(const m of f)if(d.has(m.id)?p.push(m.id):d.add(m.id),m.type==="group"&&m.branches)for(const E of m.branches)p.push(...pbn(E.steps,d));return p}const bYn=If({useCase:Fo,slice:Fo}),gYn=If({version:LI("1.0"),name:ms().min(1),description:ms().optional(),realizes:bYn.optional(),participants:_1(lYn).min(1),steps:_1(wbn)}).superRefine((f,d)=>{const p=new Set;for(let M=0;M<f.participants.length;M++){const k=f.participants[M];p.has(k.id)&&d.addIssue({code:E0.custom,path:["participants",M,"id"],message:`duplicate participant id "${k.id}"`}),p.add(k.id)}const m=new Set,E=pbn(f.steps,m);for(const M of E)d.addIssue({code:E0.custom,path:["steps"],message:`duplicate step id "${M}"`})}),TI=56,wYn=160,pYn=40,M7e=56,mYn=24,rse=12,vYn=20,yYn=6,J1n=64,SA=32,t7e=24,K1n=8;function kYn(f){return Math.max(wYn,f.length*8+pYn*2)}function mbn(f,d,p,m,E,M=0){let k=p;const D=[];let z=Number.POSITIVE_INFINITY,U=Number.NEGATIVE_INFINITY;for(const ee of f)if(ee.type==="message"){const ce=d.get(ee.from),se=d.get(ee.to),pe=ce?.cx??m,Je=se?.cx??m;D.push({type:"message",id:ee.id,fromCx:pe,toCx:Je,y:k,label:ee.label,arrow:ee.arrow,activate:ee.activate??!1,isSelf:ee.from===ee.to,...ee.status!==void 0?{status:ee.status}:{}}),k+=ee.from===ee.to?M7e*1.5:M7e}else if(ee.type==="note"){const ce=ee.participants.map(Ye=>d.get(Ye)?.cx).filter(Ye=>Ye!==void 0).sort((Ye,an)=>Ye-an),se=ce[0]??m,pe=ce[ce.length-1]??E,Je=Math.min(Math.max(ee.text.length*7.5+24,pe-se+16,80),400);let ie;ee.position==="left_of"?ie=se-Je-8:ee.position==="right_of"?ie=pe+8:ie=(se+pe)/2-Je/2,z=Math.min(z,ie),U=Math.max(U,ie+Je),D.push({type:"note",id:ee.id,x:ie,y:k,width:Je,height:J1n,text:ee.text,...ee.status!==void 0?{status:ee.status}:{}}),k+=J1n+8}else if(ee.type==="group"){const ce=Math.min(M*yYn,rse),se=m-rse+ce,pe=E-m+rse*2-ce*2,Je=k;k+=mYn;const ie=[];if(ee.branches)for(let Ye=0;Ye<ee.branches.length;Ye++){const an=ee.branches[Ye],_n=k,{items:hn,endY:Rn,contentMinX:nt,contentMaxX:ot}=mbn(an.steps,d,k,m,E,M+1);k=Rn,z=Math.min(z,nt),U=Math.max(U,ot),ie.push({...an.label!==void 0?{label:an.label}:{},startY:_n,...Ye<ee.branches.length-1?{dividerY:k}:{},steps:hn}),Ye<ee.branches.length-1&&(k+=4)}k+=rse,D.push({type:"group",id:ee.id,kind:ee.kind,...ee.condition!==void 0?{condition:ee.condition}:{},...ee.label!==void 0?{label:ee.label}:{},...ee.seqFile!==void 0?{seqFile:ee.seqFile}:{},x:se,y:Je,width:pe,height:k-Je,branches:ie,...ee.status!==void 0?{status:ee.status}:{}}),z=Math.min(z,se),U=Math.max(U,se+pe),k+=vYn}return{items:D,endY:k,contentMinX:z,contentMaxX:U}}function vbn(f){const d=new Map;for(const p of f)if(p.type==="message"&&p.arrow==="destroy"&&d.set(p.toCx,p.y+TI+20),p.type==="group")for(const m of p.branches)for(const[E,M]of vbn(m.steps))d.set(E,M);return d}function jYn(f){const d=[],p=new Map;function m(E){for(const M of E)if(M.type==="message"){if(M.activate&&M.arrow==="sync"&&!M.isSelf){const k=p.get(M.toCx)??[];k.push(M.y),p.set(M.toCx,k)}if(M.arrow==="return"&&!M.isSelf){const k=p.get(M.fromCx);if(k&&k.length>0){const D=k.pop();d.push({cx:M.fromCx,startY:D,endY:M.y}),k.length===0&&p.delete(M.fromCx)}}}else if(M.type==="group")for(const k of M.branches)m(k.steps)}m(f);for(const[E,M]of p)for(const k of M)d.push({cx:E,startY:k,endY:k+M7e/2});return d}function SYn(f,d){const p=f.participants.map(et=>kYn(et.label??et.nodeId));let m=SA;const E=f.participants.map((et,gt)=>{const dr=p[gt],tc=m+dr/2;m+=dr;const Lr=d?.get(et.nodeId);return{id:et.id,nodeId:et.nodeId,label:et.label??et.nodeId,cx:tc,colWidth:dr,...Lr!==void 0?{kind:Lr}:{},...et.status!==void 0?{status:et.status}:{},lifelineEndY:0}}),M=m+SA,k=new Map(E.map(et=>[et.id,et])),D=E[0]?.cx??SA,z=E[E.length-1]?.cx??M-SA,U=t7e,{items:ee,endY:ce,contentMinX:se,contentMaxX:pe}=mbn(f.steps,k,U,D,z),Je=se<SA&&Number.isFinite(se)?SA-se:0,ie=Number.isFinite(pe)?pe+Je+SA:0,Ye=Math.max(M+Je,ie),an=Je>0?ee.map(et=>ybn(et,Je)):ee,_n=Je>0?E.map(et=>({...et,cx:et.cx+Je})):E,hn=vbn(an),Rn=_n.map(et=>({...et,lifelineEndY:hn.get(et.cx)??TI+ce+t7e})),nt=TI+ce+t7e,ot=jYn(an);return{participants:Rn,steps:an,activations:ot,totalWidth:Ye,totalHeight:nt}}function ybn(f,d){return f.type==="message"?{...f,fromCx:f.fromCx+d,toCx:f.toCx+d}:f.type==="note"?{...f,x:f.x+d}:{...f,x:f.x+d,branches:f.branches.map(p=>({...p,steps:p.steps.map(m=>ybn(m,d))}))}}const cse=36,EYn=128,xYn=7,Z1n=20,X1n=24;function AYn({participant:f,nodeKind:d}){const p=d?zp[d]:void 0,m=p?.color??"var(--archik-fg-muted)",E=(TI-cse)/2,M=p?.icon,k=Math.max(EYn,f.label.length*xYn+X1n+(M?Z1n:0)),D=k/2,z=M?D+Z1n/2:D,U=f.status,ee=U==="proposed"?.55:U==="deprecated"?.35:1,ce=U==="proposed"||U==="deprecated"?"4 3":void 0;return I.jsxs("g",{transform:`translate(${f.cx-D}, ${E})`,opacity:ee,children:[I.jsx("rect",{width:k,height:cse,rx:8,fill:"var(--archik-node-fill)",stroke:m,strokeWidth:1.4,...ce!==void 0?{strokeDasharray:ce}:{}}),M&&I.jsx("g",{transform:`translate(${X1n/2}, ${(cse-14)/2})`,children:I.jsx(M,{size:14,color:m,strokeWidth:1.5})}),I.jsx("text",{x:z,y:cse/2+4,textAnchor:"middle",fontSize:12,fontWeight:500,fill:"var(--archik-fg)",fontFamily:"inherit",children:f.label})]})}function TYn({participant:f}){const d=f.status,p=d==="proposed"?.35:d==="deprecated"?.25:.6;return I.jsx("line",{x1:f.cx,y1:TI,x2:f.cx,y2:f.lifelineEndY,stroke:"var(--archik-fg-muted)",strokeWidth:1.2,strokeDasharray:"6 5",opacity:p})}const sse=32,iH=20,MYn=-6,use="var(--archik-edge-filled)";function CYn({msg:f}){const d=f.arrow==="return",p=f.arrow==="async",m=f.arrow==="create",E=d||m,M=f.arrow==="destroy",k=d||p,D=f.status==="proposed"?.5:f.status==="deprecated"?.35:1,z=(se,pe)=>k?I.jsx("path",{"data-archik-arrowhead":"end",d:$7e(se,pe),fill:"none",stroke:use,strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"}):I.jsx("path",{"data-archik-arrowhead":"end",d:jI(se,pe),fill:use});if(f.isSelf){const se=f.fromCx,pe=f.y,Je=`M ${se} ${pe} L ${se+sse} ${pe} L ${se+sse} ${pe+iH} L ${se} ${pe+iH}`;return I.jsxs("g",{opacity:D,children:[I.jsx("path",{d:Je,fill:"none",stroke:use,strokeWidth:1.4}),z({x:se,y:pe+iH},{x:se+sse,y:pe+iH}),I.jsx("text",{x:se+sse+6,y:pe+iH/2+4,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",stroke:"var(--archik-canvas)",strokeWidth:3,paintOrder:"stroke",children:f.label})]})}const ee=f.fromCx<f.toCx?f.toCx-6:f.toCx+6,ce=(f.fromCx+f.toCx)/2;return I.jsxs("g",{opacity:D,children:[I.jsx("line",{x1:f.fromCx,y1:f.y,x2:ee,y2:f.y,stroke:use,strokeWidth:1.4,strokeDasharray:E?"4 4":void 0}),!M&&z({x:f.toCx,y:f.y},{x:f.fromCx,y:f.y}),I.jsxs("text",{x:ce,y:f.y+MYn,textAnchor:"middle",fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",stroke:"var(--archik-canvas)",strokeWidth:3,paintOrder:"stroke",children:[m&&"«create» ",f.label]}),f.arrow==="destroy"&&I.jsxs("g",{transform:`translate(${f.toCx-6}, ${f.y-6})`,children:[I.jsx("line",{x1:0,y1:0,x2:12,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5}),I.jsx("line",{x1:12,y1:0,x2:0,y2:12,stroke:"var(--archik-fg-muted)",strokeWidth:1.5})]})]})}const OYn={alt:"#6366f1",opt:"#0ea5e9",loop:"#10b981",par:"#f59e0b",break:"#ef4444",ref:"#8b5cf6"},V1n=36,i7e=18;function _Yn({group:f,renderStep:d,onRefClick:p}){const m=OYn[f.kind]??"var(--archik-fg-muted)",E=f.status==="proposed"?.55:f.status==="deprecated"?.35:1,M=f.kind==="ref"&&f.seqFile!==void 0&&p!==void 0;return I.jsxs("g",{opacity:E,onClick:M?()=>p(f.seqFile):void 0,style:M?{cursor:"pointer"}:void 0,children:[I.jsx("rect",{x:f.x,y:f.y,width:f.width,height:f.height,rx:4,fill:"none",stroke:m,strokeWidth:1.2,opacity:.8}),I.jsx("rect",{x:f.x,y:f.y,width:V1n,height:i7e,rx:4,fill:m,opacity:.8}),I.jsx("text",{x:f.x+6,y:f.y+i7e-5,fontSize:10,fontWeight:600,fill:"#fff",fontFamily:"inherit",children:f.kind}),(f.condition??f.label)&&I.jsx("text",{x:f.x+V1n+6,y:f.y+i7e-5,fontSize:10,fill:m,fontFamily:"inherit",children:f.condition??f.label}),f.branches.map((k,D)=>I.jsxs("g",{children:[k.label&&I.jsx("text",{x:f.x+6,y:k.startY+12,fontSize:10,fill:m,fontFamily:"inherit",children:k.label}),k.steps.map(z=>d(z)),k.dividerY!==void 0&&I.jsx("line",{x1:f.x,y1:k.dividerY,x2:f.x+f.width,y2:k.dividerY,stroke:m,strokeWidth:1,strokeDasharray:"4 2",opacity:.65})]},D))]})}const lI=10;function NYn(f,d){const p=Math.max(10,Math.floor(d/6.5));if(f.length<=p)return[f];const m=f.split(" "),E=[];let M="";for(const k of m)(M+(M?" ":"")+k).length>p&&M?(E.push(M),M=k):M=M?M+" "+k:k;return M&&E.push(M),E.slice(0,3)}function IYn({note:f}){const{x:d,y:p,width:m,height:E,text:M}=f,k=f.status==="proposed"?.55:f.status==="deprecated"?.35:1;return I.jsxs("g",{opacity:k,children:[I.jsx("path",{d:`M ${d} ${p} L ${d+m-lI} ${p} L ${d+m} ${p+lI} L ${d+m} ${p+E} L ${d} ${p+E} Z`,fill:"var(--archik-node-fill)",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),I.jsx("path",{d:`M ${d+m-lI} ${p} L ${d+m-lI} ${p+lI} L ${d+m} ${p+lI}`,fill:"none",stroke:"var(--archik-node-stroke)",strokeWidth:1.2}),NYn(M,m-16).map((D,z)=>I.jsx("text",{x:d+8,y:p+8+11+z*13,fontSize:11,fill:"var(--archik-fg)",fontFamily:"inherit",children:D},z))]})}function kbn({step:f,onRefClick:d}){return f.type==="message"?I.jsx(CYn,{msg:f}):f.type==="note"?I.jsx(IYn,{note:f}):f.type==="group"?I.jsx(_Yn,{group:f,...d!==void 0?{onRefClick:d}:{},renderStep:p=>I.jsx(kbn,{step:p,...d!==void 0?{onRefClick:d}:{}},p.id)}):null}function $Yn({laid:f,svgRef:d,onRefClick:p}){const{participants:m,steps:E,activations:M,totalWidth:k,totalHeight:D}=f;return I.jsxs("svg",{ref:d,width:k,height:D,viewBox:`0 0 ${k} ${D}`,xmlns:"http://www.w3.org/2000/svg",style:{fontFamily:"var(--archik-font, system-ui)"},children:[m.map(z=>I.jsx(TYn,{participant:z},z.id)),m.map(z=>I.jsx(AYn,{participant:z,...z.kind!==void 0?{nodeKind:z.kind}:{}},z.id)),I.jsxs("g",{transform:`translate(0, ${TI})`,children:[M.map(z=>I.jsx("rect",{x:z.cx-K1n/2,y:z.startY,width:K1n,height:z.endY-z.startY,fill:"var(--archik-surface)",stroke:"var(--archik-fg-muted)",strokeWidth:1.2,rx:2},`${z.cx}-${z.startY}`)),E.map(z=>I.jsx(kbn,{step:z,...p!==void 0?{onRefClick:p}:{}},z.id))]})]})}const W1n="archik.seq.rail.open";function DYn({path:f,back:d}){const[p,m]=Fn.useState({status:"loading"}),[E,M]=Fn.useState(void 0),[k,D]=Fn.useState([]),[z,U]=Fn.useState(()=>{if(typeof window>"u")return!0;const hn=window.localStorage.getItem(W1n);return hn!==null?hn==="1":typeof window.matchMedia=="function"?!window.matchMedia("(max-width: 768px)").matches:!0}),[ee,ce]=Fn.useState(!1),se=Fn.useRef(null);Fn.useEffect(()=>{typeof window<"u"&&window.localStorage.setItem(W1n,z?"1":"0")},[z]),Fn.useEffect(()=>{fetch("/__archik/node-kinds").then(hn=>hn.ok?hn.json():null).then(hn=>{hn&&M(new Map(Object.entries(hn)))}).catch(()=>{})},[]),Fn.useEffect(()=>{fetch("/__archik/usecases").then(hn=>hn.ok?hn.json():null).then(hn=>{hn&&D(hn.useCases??[])}).catch(()=>{})},[]),Fn.useEffect(()=>{m({status:"loading"});const hn=encodeURIComponent(f);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 nt=W7e.parse(Rn),ot=gYn.safeParse(nt);if(!ot.success)throw new Error(ot.error.issues.map(et=>et.message).join("; "));m({status:"ready",doc:ot.data,raw:Rn})}).catch(Rn=>{m({status:"error",message:Rn instanceof Error?Rn.message:String(Rn)})})},[f]);const pe=d?d.type==="usecase"?`/__archik/usecases?uc=${encodeURIComponent(d.value)}`:`/?file=${encodeURIComponent(d.value)}`:"/",Je=d?.type==="usecase"?"Use cases":"Architecture",ie=Fn.useMemo(()=>{if(p.status!=="ready")return null;const hn=p.doc.realizes;if(!hn)return null;const Rn=k.find(ot=>ot.id===hn.useCase);if(!Rn)return{useCase:hn.useCase,slice:hn.slice,name:void 0,slice_data:void 0};const nt=Rn.slices.find(ot=>ot.id===hn.slice);return{useCase:hn.useCase,slice:hn.slice,name:Rn.name,slice_data:nt,primaryActor:Rn.primaryActor}},[p,k]);if(p.status==="loading")return I.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 I.jsxs("div",{className:"flex h-screen flex-col items-center justify-center gap-4",children:[I.jsx("div",{style:{color:"var(--archik-fg-error, #ef4444)"},children:p.message}),I.jsxs("a",{href:pe,style:{color:"var(--archik-fg-muted)",fontSize:13},children:["← ",Je]})]});const Ye=SYn(p.doc,E),an=f.replace(/^.*\//,"").replace(/\.archik\.seq\.yaml$/,""),_n=hn=>{const Rn=new URLSearchParams;Rn.set("path",hn),d?.type==="usecase"?Rn.set("from-uc",d.value):d?.type==="file"&&Rn.set("from-file",d.value),window.location.href=`/__archik/seq?${Rn.toString()}`};return I.jsxs("div",{className:"flex h-dvh flex-col",style:{background:"var(--archik-canvas)"},children:[I.jsx(RYn,{backHref:pe,backLabel:Je,realizedSlice:ie,seqName:p.doc.name,railOpen:z,onToggleRail:()=>U(hn=>!hn),filename:an,getSvg:()=>se.current}),I.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[I.jsx(LYn,{laid:Ye,svgRef:se,onRefClick:_n}),z&&I.jsx(PYn,{doc:p.doc,raw:p.raw,yamlOpen:ee,onToggleYaml:()=>ce(hn=>!hn),realizedSlice:ie,kinds:E})]})]})}const jbn=.25,Sbn=4,Y1n=1.2,r7e=f=>Math.max(jbn,Math.min(Sbn,f));function LYn({laid:f,svgRef:d,onRefClick:p}){const m=i7("(max-width: 768px)"),E=Fn.useMemo(()=>{if(!m||typeof window>"u")return 1;const U=window.innerWidth-48;return r7e(Math.min(1,U/f.totalWidth))},[m,f.totalWidth]),[M,k]=Fn.useState(E),D=Fn.useRef(M);D.current=M;const z=Fn.useRef(null);return Fn.useEffect(()=>{k(E)},[E]),kdn({scrollRef:z,zoomRef:D,setZoom:k,min:jbn,max:Sbn,enabled:!0}),I.jsxs("div",{style:{flex:1,position:"relative",overflow:"hidden",display:"flex"},children:[I.jsx("div",{ref:z,style:{flex:1,overflow:"auto",padding:24,touchAction:"pan-x pan-y",overscrollBehavior:"contain"},children:I.jsx("div",{style:{width:f.totalWidth*M,height:f.totalHeight*M,margin:"0 auto"},children:I.jsx("div",{style:{transform:`scale(${M})`,transformOrigin:"0 0"},children:I.jsx($Yn,{laid:f,svgRef:d,...p!==void 0?{onRefClick:p}:{}})})})}),I.jsx(jdn,{zoom:M,onZoomIn:()=>k(U=>r7e(U*Y1n)),onZoomOut:()=>k(U=>r7e(U/Y1n)),onZoomReset:()=>k(E)})]})}function RYn({backHref:f,backLabel:d,realizedSlice:p,seqName:m,railOpen:E,onToggleRail:M,filename:k,getSvg:D}){return I.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:[I.jsxs("a",{href:f,style:{display:"inline-flex",alignItems:"center",gap:2,color:"var(--archik-fg-dim)",textDecoration:"none"},children:[I.jsx(_7e,{size:14}),d]}),p&&I.jsxs(I.Fragment,{children:[I.jsx(c7e,{}),I.jsx("a",{href:`/__archik/usecases?uc=${encodeURIComponent(p.useCase)}`,style:{color:"var(--archik-fg-dim)",textDecoration:"none",fontFamily:"ui-monospace, monospace",fontSize:12,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"30vw"},children:p.useCase}),I.jsx(c7e,{}),I.jsx("span",{style:{color:"var(--archik-fg)",fontFamily:"ui-monospace, monospace",fontSize:12,whiteSpace:"nowrap"},children:p.slice})]}),!p&&I.jsxs(I.Fragment,{children:[I.jsx(c7e,{}),I.jsx("span",{style:{color:"var(--archik-fg)",fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"40vw"},children:m})]}),I.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:6,alignItems:"center"},children:[I.jsx(fbn,{filename:k,getSvg:D}),I.jsx("button",{type:"button",onClick:M,"aria-label":E?"Hide details":"Show details","aria-pressed":E,title:E?"Hide details panel":"Show details panel",className:"archik-btn",style:{padding:"5px 8px"},children:E?I.jsx(bqn,{size:14}):I.jsx(wqn,{size:14})})]})]})}function c7e(){return I.jsx(Ose,{size:12,color:"var(--archik-fg-muted)",style:{marginInline:2}})}function PYn({doc:f,raw:d,yamlOpen:p,onToggleYaml:m,realizedSlice:E,kinds:M}){const k=i7("(max-width: 768px)");return I.jsxs("aside",{style:k?{position:"fixed",right:0,top:48,bottom:0,width:"min(320px, 85vw)",zIndex:30,borderLeft:"1px solid var(--archik-border)",background:"var(--archik-panel)",overflowY:"auto",padding:16,fontSize:12,color:"var(--archik-fg-dim)",boxShadow:"-8px 0 24px rgba(0, 0, 0, 0.3)"}:{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:[I.jsx(ose,{title:"Realizes",children:E?I.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[I.jsx(Q1n,{label:"Use case",children:I.jsxs("a",{href:`/__archik/usecases?uc=${encodeURIComponent(E.useCase)}`,style:lse({color:"var(--archik-accent)"}),children:[E.useCase,E.name?` — ${E.name}`:""]})}),I.jsx(Q1n,{label:"Slice",children:I.jsx("code",{style:lse(),children:E.slice})}),E.slice_data?.description&&I.jsx("div",{style:{marginTop:4,fontSize:11,lineHeight:1.5},children:E.slice_data.description})]}):I.jsxs(edn,{children:["No ",I.jsx("code",{children:"realizes"})," block — this is an ad-hoc / scratch flow, not bound to a use case slice."]})}),I.jsx(ose,{title:`Participants (${f.participants.length})`,children:I.jsx("ul",{style:ndn,children:f.participants.map(D=>{const z=M?.get(D.nodeId),U=z?zp[z]:void 0,ee=U?.icon;return I.jsxs("li",{style:{display:"flex",alignItems:"center",gap:8,padding:"3px 0"},children:[ee?I.jsx(ee,{size:12,color:U.color,strokeWidth:2}):I.jsx("span",{style:{width:12}}),I.jsx("code",{style:lse(),children:D.nodeId}),D.id!==D.nodeId&&I.jsxs("span",{style:{fontSize:10,color:"var(--archik-fg-muted)"},children:["[",D.id,"]"]})]},D.id)})})}),E?.slice_data&&I.jsx(ose,{title:"Proved by",children:(E.slice_data.tests?.length??0)===0?I.jsx(edn,{children:"No tests declared on this slice."}):I.jsx("ul",{style:{...ndn,listStyle:"none",paddingLeft:0},children:E.slice_data.tests.map(D=>I.jsxs("li",{style:{...lse(),fontSize:11,padding:"2px 0"},children:[I.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"•"})," ",D]},D))})}),I.jsxs(ose,{title:"Source",children:[I.jsxs("button",{type:"button",onClick:m,className:"archik-btn",style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,padding:"4px 8px"},children:[I.jsx(ldn,{size:11}),p?"Hide YAML":"View YAML"]}),p&&I.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:d})]})]})}function ose({title:f,children:d}){return I.jsxs("section",{style:{marginBottom:18},children:[I.jsx("h2",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--archik-fg-muted)",margin:"0 0 6px"},children:f}),d]})}function Q1n({label:f,children:d}){return I.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline"},children:[I.jsx("span",{style:{fontSize:9,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",width:56,flexShrink:0},children:f}),I.jsx("span",{style:{flex:1,minWidth:0},children:d})]})}function edn({children:f}){return I.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-muted)",lineHeight:1.5},children:f})}function lse(f){return{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:11,color:"var(--archik-fg)",textDecoration:"none",...f}}const ndn={margin:0,paddingLeft:0,listStyle:"none"},zYn=If({id:Fo.optional(),from:Fo,to:Fo,label:ms().min(1),data:If({in:hH().optional(),out:hH().optional()}).optional(),status:lk(["ok","error"]).default("ok")}),BYn=If({version:LI("1.0"),useCase:Fo,slice:Fo,seqFile:ms().min(1).optional(),recordedAt:ms().min(1),steps:_1(zYn).min(1)});function FYn({trace:f,back:d}){return I.jsxs("div",{className:"archik-trace-page",style:{display:"flex",flexDirection:"column",height:"100dvh",background:"var(--archik-canvas)",color:"var(--archik-fg)",fontFamily:"Inter, system-ui, sans-serif"},children:[I.jsx(qYn,{trace:f,back:d??null}),I.jsx("main",{style:{flex:1,overflowY:"auto",padding:"24px 32px"},children:I.jsxs("div",{style:{maxWidth:760,margin:"0 auto"},children:[I.jsx(GYn,{trace:f}),I.jsx("ol",{style:{listStyle:"none",margin:"20px 0 0",padding:0,display:"flex",flexDirection:"column",gap:0},children:f.steps.map((p,m)=>I.jsx(UYn,{step:p,index:m,last:m===f.steps.length-1},p.id??`${p.from}->${p.to}:${m}`))})]})})]})}function qYn({trace:f,back:d}){const p=d?d.type==="usecase"?`/__archik/usecases?uc=${encodeURIComponent(d.value)}`:`/?file=${encodeURIComponent(d.value)}`:`/__archik/usecases?uc=${encodeURIComponent(f.useCase)}`,m=d?.type==="file"?"Architecture":"Use cases";return I.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:[I.jsxs("a",{href:p,style:{display:"inline-flex",alignItems:"center",gap:2,color:"var(--archik-fg-dim)",textDecoration:"none"},children:[I.jsx(_7e,{size:14}),m]}),I.jsx(tdn,{}),I.jsx("a",{href:`/__archik/usecases?uc=${encodeURIComponent(f.useCase)}`,style:{color:"var(--archik-fg-dim)",textDecoration:"none",fontFamily:"ui-monospace, monospace",fontSize:12},children:f.useCase}),I.jsx(tdn,{}),I.jsx("span",{style:{color:"var(--archik-fg)",fontFamily:"ui-monospace, monospace",fontSize:12},children:f.slice}),I.jsx("span",{className:"archik-pill",style:{fontSize:9,marginLeft:8},title:"Concrete run — recorded values from a real test",children:"concrete run"})]})}function tdn(){return I.jsx(Ose,{size:12,color:"var(--archik-fg-muted)",style:{marginInline:2}})}function GYn({trace:f}){return I.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:24,padding:"12px 16px",background:"var(--archik-surface)",borderRadius:8,fontSize:12},children:[I.jsx(fse,{label:"Use case / slice",children:I.jsxs("code",{style:Mse(),children:[f.useCase," / ",f.slice]})}),I.jsx(fse,{label:"Recorded at",children:I.jsx("span",{style:{color:"var(--archik-fg)"},children:f.recordedAt})}),I.jsx(fse,{label:"Steps",children:I.jsx("span",{style:{color:"var(--archik-fg)"},children:f.steps.length})}),f.seqFile&&I.jsx(fse,{label:"Bound to",children:I.jsxs("a",{href:`/__archik/seq?path=${encodeURIComponent(f.seqFile)}&from-uc=${encodeURIComponent(f.useCase)}`,style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-accent)",textDecoration:"none",...Mse()},title:"Open the abstract sequence diagram this run realises",children:[I.jsx(ldn,{size:11}),f.seqFile]})})]})}function UYn({step:f,index:d,last:p}){const[m,E]=Fn.useState(!1),M=f.data!==void 0&&(f.data.in!==void 0||f.data.out!==void 0);return I.jsxs("li",{style:{display:"grid",gridTemplateColumns:"20px 1fr",columnGap:12},children:[I.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[I.jsx(HYn,{status:f.status}),!p&&I.jsx("span",{style:{flex:1,width:2,minHeight:12,background:"var(--archik-border)"}})]}),I.jsxs("div",{style:{paddingBottom:p?0:16},children:[I.jsxs("button",{type:"button",onClick:()=>M&&E(k=>!k),className:"archik-btn","aria-expanded":M?m:void 0,disabled:!M,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 10px",background:"var(--archik-panel)",border:"1px solid var(--archik-border)",borderRadius:8,textAlign:"left",cursor:M?"pointer":"default"},children:[I.jsxs("span",{style:{color:"var(--archik-fg-muted)",fontSize:11},children:[d+1,"."]}),I.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11},children:[I.jsx("code",{style:Mse(),children:f.from}),I.jsx(Ose,{size:11,color:"var(--archik-fg-muted)"}),I.jsx("code",{style:Mse(),children:f.to})]}),I.jsx("span",{style:{fontSize:13,color:"var(--archik-fg)",fontWeight:500,marginLeft:4},children:f.label}),f.status==="error"&&I.jsx("span",{className:"archik-pill",style:{fontSize:9,color:"var(--archik-danger)",borderColor:"var(--archik-danger)"},children:"error"}),M&&I.jsx(Cse,{size:14,color:"var(--archik-fg-muted)",style:{marginLeft:"auto",transform:m?"rotate(180deg)":"none",transition:"transform 0.12s"}}),!M&&I.jsx("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--archik-fg-muted)"},children:"no data"})]}),m&&M&&I.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,marginTop:8},children:[f.data?.in!==void 0&&I.jsx(idn,{label:"in",value:f.data.in}),f.data?.out!==void 0&&I.jsx(idn,{label:"out",value:f.data.out})]})]})]})}function idn({label:f,value:d}){return I.jsxs("div",{children:[I.jsx("div",{style:{fontSize:9,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--archik-fg-muted)",marginBottom:2},children:f}),I.jsx("pre",{style:{margin:0,padding:10,background:"var(--archik-surface)",border:"1px solid var(--archik-border)",borderRadius:6,fontSize:11,fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",color:"var(--archik-fg-dim)",overflowX:"auto",whiteSpace:"pre"},children:JSON.stringify(d,null,2)})]})}function HYn({status:f}){return f==="error"?I.jsx("span",{"aria-label":"error",title:"error",style:{display:"inline-flex"},children:I.jsx(dFn,{size:16,color:"var(--archik-danger)"})}):I.jsx("span",{"aria-label":"ok",title:"ok",style:{display:"inline-flex"},children:I.jsx(gFn,{size:16,color:"var(--archik-success)"})})}function fse({label:f,children:d}){return I.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[I.jsx("span",{style:{fontSize:9,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)"},children:f}),I.jsx("span",{children:d})]})}function Mse(f){return{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace",fontSize:11,color:"var(--archik-fg)",textDecoration:"none",...f}}function JYn({path:f,back:d}){const[p,m]=Fn.useState({status:"loading"});return Fn.useEffect(()=>{m({status:"loading"});const E=encodeURIComponent(f);fetch(`/__archik/trace-file?path=${E}`).then(async M=>{if(!M.ok)throw new Error(`${M.status} ${M.statusText}`);return M.text()}).then(M=>{const k=JSON.parse(M),D=BYn.safeParse(k);if(!D.success)throw new Error(D.error.issues.map(z=>z.message).join("; "));m({status:"ready",doc:D.data})}).catch(M=>{m({status:"error",message:M instanceof Error?M.message:String(M)})})},[f]),p.status==="loading"?I.jsx("div",{className:"flex h-screen items-center justify-center",style:{color:"var(--archik-fg-muted)"},children:"Loading trace…"}):p.status==="error"?I.jsxs("div",{className:"flex h-screen flex-col items-center justify-center gap-4",children:[I.jsx("div",{style:{color:"var(--archik-danger)"},children:p.message}),I.jsx("a",{href:"/__archik/usecases",style:{color:"var(--archik-fg-muted)",fontSize:13},children:"← Use cases"})]}):I.jsx(FYn,{trace:p.doc,back:d})}const KYn="/__archik/usecases",ZYn="/__archik/trace",XYn="/__archik/traces";async function s7e(f,d){const p=await fetch(f,{cache:"no-store",signal:d});if(!p.ok)throw new Error(`HTTP ${p.status} ${p.statusText}`);return await p.json()}function VYn({selectedId:f}){const[d,p]=Fn.useState({status:"loading"}),m=i7("(max-width: 768px)");return Fn.useEffect(()=>{let E=!1;const M=new AbortController;return Promise.all([s7e(KYn,M.signal),s7e(ZYn,M.signal),s7e(XYn,M.signal).catch(()=>({ok:!0,traces:[]}))]).then(([k,D,z])=>{E||p({status:"ready",useCases:k.useCases??[],trace:D.rows??[],traceDocs:z.traces??[]})}).catch(k=>{E||M.signal.aborted||p({status:"error",message:k instanceof Error?k.message:String(k)})}),()=>{E=!0,M.abort()}},[]),I.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100dvh",background:"var(--archik-canvas)",color:"var(--archik-fg)",fontFamily:"Inter, system-ui, sans-serif"},children:[I.jsx(WYn,{state:d}),I.jsxs("div",{style:{flex:1,display:"flex",flexDirection:m?"column":"row",overflow:"hidden"},children:[d.status==="loading"&&I.jsx(u7e,{children:"Loading…"}),d.status==="error"&&I.jsxs(u7e,{tone:"error",children:["Couldn't load: ",d.message]}),d.status==="ready"&&d.useCases.length===0&&I.jsxs(u7e,{children:["No use cases defined yet. Add a ",I.jsx("code",{children:"*.archik.uc.yaml"})," file under ",I.jsx("code",{children:".archik/usecases/"}),"."]}),d.status==="ready"&&d.useCases.length>0&&I.jsx(YYn,{useCases:d.useCases,trace:d.trace,traceDocs:d.traceDocs,selectedId:f})]})]})}function WYn({state:f}){const d=i7("(max-width: 640px)"),p=Fn.useMemo(()=>{if(f.status!=="ready")return null;let m=0,E=0,M=0;for(const k of f.trace)k.level==="full"?m++:k.level==="partial"?E++:M++;return{full:m,partial:E,none:M,total:f.trace.length}},[f]);return I.jsxs("header",{style:{display:"flex",alignItems:"center",gap:d?8:16,padding:d?"0 12px":"0 20px",height:52,borderBottom:"1px solid var(--archik-border)",background:"var(--archik-panel)",flexShrink:0},children:[I.jsxs("a",{href:"/",style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-fg-dim)",fontSize:13,textDecoration:"none",whiteSpace:"nowrap"},children:[I.jsx(_7e,{size:14}),"Architecture"]}),I.jsx("span",{style:{color:"var(--archik-border-strong)"},children:"|"}),I.jsx("h1",{style:{fontSize:14,fontWeight:600,margin:0,color:"var(--archik-fg)",whiteSpace:"nowrap"},children:"Use cases"}),p&&p.total>0&&!d&&I.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginLeft:"auto",fontSize:12,color:"var(--archik-fg-dim)"},children:[I.jsxs("span",{children:[I.jsx("span",{style:{color:"var(--archik-success)"},children:"●"})," ",p.full," full"]}),I.jsxs("span",{children:[I.jsx("span",{style:{color:"var(--archik-warning)"},children:"◐"})," ",p.partial," partial"]}),I.jsxs("span",{children:[I.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"○"})," ",p.none," untraced"]}),I.jsxs("span",{style:{color:"var(--archik-fg-muted)"},children:["· ",p.total," ",p.total===1?"slice":"slices"]})]})]})}function YYn({useCases:f,trace:d,traceDocs:p,selectedId:m}){const E=Fn.useMemo(()=>{const z=new Map;for(const U of d){const ee=z.get(U.useCase);if(!ee){z.set(U.useCase,U.level);continue}ee==="none"||U.level==="none"?z.set(U.useCase,"none"):(ee==="partial"||U.level==="partial")&&z.set(U.useCase,"partial")}return z},[d]),M=Fn.useMemo(()=>{const z=new Map;for(const U of d)z.set(`${U.useCase}/${U.slice}`,U);return z},[d]),k=Fn.useMemo(()=>{const z=new Map;for(const U of p)z.set(`${U.useCase}/${U.slice}`,U);return z},[p]),D=f.find(z=>z.id===m)??f[0];return I.jsxs(I.Fragment,{children:[I.jsx(QYn,{useCases:f,ucLevel:E,selectedId:D.id}),I.jsx(eQn,{useCase:D,traceByKey:M,traceDocByKey:k})]})}function QYn({useCases:f,ucLevel:d,selectedId:p}){const m=i7("(max-width: 768px)");return I.jsx("nav",{"aria-label":"Use cases",style:{width:m?"100%":260,...m?{maxHeight:"40dvh",borderBottom:"1px solid var(--archik-border)"}:{borderRight:"1px solid var(--archik-border)"},background:"var(--archik-panel)",overflowY:"auto",padding:"8px 0",flexShrink:0},children:I.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:f.map(E=>{const M=d.get(E.id)??"none",k=E.id===p;return I.jsx("li",{children:I.jsxs("a",{href:`/__archik/usecases?uc=${encodeURIComponent(E.id)}`,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 14px",textDecoration:"none",color:"var(--archik-fg)",background:k?"var(--archik-surface-hover)":"transparent",borderLeft:k?"2px solid var(--archik-accent)":"2px solid transparent",fontSize:13},children:[I.jsx(Ebn,{level:M}),I.jsxs("span",{style:{flex:1,minWidth:0},children:[I.jsx("code",{style:{fontSize:12,fontFamily:"ui-monospace, monospace"},children:E.id}),I.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:E.name})]}),E.status&&E.status!=="active"&&I.jsx("span",{style:{fontSize:9,padding:"1px 6px",borderRadius:4,background:"var(--archik-surface)",color:"var(--archik-fg-muted)"},children:E.status})]})},E.id)})})})}function Ebn({level:f}){const d=f==="full"?{glyph:"●",color:"var(--archik-success)",label:"fully traced"}:f==="partial"?{glyph:"◐",color:"var(--archik-warning)",label:"partially traced"}:{glyph:"○",color:"var(--archik-fg-muted)",label:"untraced"};return I.jsx("span",{title:d.label,"aria-label":d.label,style:{color:d.color,fontSize:12,lineHeight:1,width:12},children:d.glyph})}function eQn({useCase:f,traceByKey:d,traceDocByKey:p}){return I.jsx("main",{style:{flex:1,overflowY:"auto",padding:"24px 32px"},children:I.jsxs("div",{style:{maxWidth:820,margin:"0 auto"},children:[I.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:12,marginBottom:4},children:[I.jsx("code",{style:{fontSize:18,fontFamily:"ui-monospace, monospace",fontWeight:600,color:"var(--archik-fg)"},children:f.id}),f.status&&f.status!=="active"&&I.jsx("span",{className:"archik-pill",style:{fontSize:10},children:f.status})]}),I.jsx("div",{style:{fontSize:15,color:"var(--archik-fg-dim)",marginBottom:18},children:f.name}),I.jsx(nQn,{useCase:f}),f.goal&&I.jsx(fI,{title:"Goal",children:I.jsx("p",{style:{margin:0,lineHeight:1.55},children:f.goal})}),(f.preconditions?.length??0)>0&&I.jsx(fI,{title:"Preconditions",children:I.jsx("ul",{style:sH,children:f.preconditions.map((m,E)=>I.jsx("li",{children:m},E))})}),f.flows?.basic?.steps&&I.jsx(fI,{title:"Basic flow",children:I.jsx("ol",{style:{...sH,paddingLeft:22},children:f.flows.basic.steps.map((m,E)=>I.jsx("li",{style:{marginBottom:4},children:m},E))})}),(f.flows?.alternates?.length??0)>0&&I.jsx(fI,{title:"Alternate flows",children:f.flows.alternates.map(m=>I.jsxs("div",{style:{marginBottom:12,padding:12,background:"var(--archik-surface)",borderRadius:6,borderLeft:"3px solid var(--archik-warning)"},children:[I.jsxs("div",{style:{display:"flex",gap:8,alignItems:"baseline",marginBottom:6},children:[I.jsx("code",{style:{fontSize:12,fontWeight:600},children:m.id}),m.branchFrom&&I.jsxs("span",{style:{fontSize:11,color:"var(--archik-fg-muted)"},children:["branches from ",m.branchFrom]})]}),I.jsx("ol",{style:{...sH,paddingLeft:22,fontSize:13},children:m.steps.map((E,M)=>I.jsx("li",{children:E},M))})]},m.id))}),(f.postconditions?.length??0)>0&&I.jsx(fI,{title:"Postconditions",children:I.jsx("ul",{style:sH,children:f.postconditions.map((m,E)=>I.jsx("li",{children:m},E))})}),(()=>{const m=f.slices??[];return I.jsx(fI,{title:`Slices (${m.length})`,children:m.length===0?I.jsx("div",{style:{fontSize:12,color:"var(--archik-fg-muted)"},children:"— no slices declared"}):I.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:m.map(E=>I.jsx(tQn,{slice:E,useCaseId:f.id,trace:d.get(`${f.id}/${E.id}`),traceDoc:p.get(`${f.id}/${E.id}`)},E.id))})})})(),I.jsxs("div",{style:{marginTop:32,paddingTop:16,borderTop:"1px solid var(--archik-border)",fontSize:11,color:"var(--archik-fg-muted)"},children:["Source:"," ",I.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:f.relPath})]})]})})}function nQn({useCase:f}){return I.jsxs("div",{style:{display:"flex",gap:24,padding:"10px 14px",background:"var(--archik-surface)",borderRadius:6,marginBottom:20,fontSize:12},children:[I.jsxs("div",{children:[I.jsx("div",{style:C7e,children:"Primary actor"}),I.jsx("div",{style:{marginTop:2},children:I.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:f.primaryActor})})]}),(f.secondaryActors?.length??0)>0&&I.jsxs("div",{children:[I.jsx("div",{style:C7e,children:"Secondary actors"}),I.jsx("div",{style:{marginTop:2},children:f.secondaryActors.map((d,p)=>I.jsxs("span",{children:[I.jsx("code",{style:{fontFamily:"ui-monospace, monospace"},children:d}),p<f.secondaryActors.length-1&&", "]},d))})]})]})}function tQn({slice:f,useCaseId:d,trace:p,traceDoc:m}){const E=p?.level??"none";return I.jsxs("div",{style:{padding:14,background:"var(--archik-panel)",border:"1px solid var(--archik-border)",borderRadius:8},children:[I.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,marginBottom:8},children:[I.jsx(Ebn,{level:E}),I.jsx("code",{style:{fontSize:13,fontFamily:"ui-monospace, monospace",fontWeight:600},children:f.id}),f.status&&f.status!=="active"&&I.jsxs("span",{style:{fontSize:10,color:"var(--archik-fg-muted)"},children:["[",f.status,"]"]}),I.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--archik-fg-muted)"},children:p?.realization&&p.realization.participants.length>0&&I.jsxs(I.Fragment,{children:["ECB"," ",p.realization.participants.filter(M=>M.stereotype!==void 0).length,"/",p.realization.participants.length]})})]}),f.description&&I.jsx("div",{style:{fontSize:13,color:"var(--archik-fg-dim)",marginBottom:10,lineHeight:1.5},children:f.description}),I.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",columnGap:14,rowGap:8,fontSize:12,alignItems:"start"},children:[I.jsx("div",{style:ase,children:"Tests"}),I.jsx("div",{children:(f.tests?.length??0)===0?I.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"— none declared"}):I.jsx("ul",{style:{...sH,paddingLeft:0,listStyle:"none"},children:f.tests.map(M=>I.jsxs("li",{style:{fontFamily:"ui-monospace, monospace",fontSize:11},children:[I.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"•"})," ",M]},M))})}),I.jsx("div",{style:ase,children:"Realization"}),I.jsx("div",{children:f.realization?I.jsxs("a",{href:`/__archik/seq?path=${encodeURIComponent(f.realization.seqFile)}&from-uc=${encodeURIComponent(d)}`,style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-accent)",textDecoration:"none",fontFamily:"ui-monospace, monospace",fontSize:11},children:[I.jsx(udn,{size:11}),iQn(f.realization.seqFile),I.jsx(o7e,{size:11,style:{opacity:.7}})]}):I.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"— no seq file yet"})}),I.jsx("div",{style:ase,children:"Flow chart"}),I.jsx("div",{children:m?I.jsxs("a",{href:`/__archik/trace-page?path=${encodeURIComponent(m.relPath)}&from-uc=${encodeURIComponent(d)}`,style:{display:"inline-flex",alignItems:"center",gap:4,color:"var(--archik-accent)",textDecoration:"none",fontSize:11},title:`Open the concrete run (${m.steps} steps)`,children:["● Concrete run",I.jsxs("span",{style:{color:"var(--archik-fg-muted)"},children:[" ",m.recordedAt]}),I.jsx(o7e,{size:11,style:{opacity:.7}})]}):I.jsx("span",{style:{color:"var(--archik-fg-muted)"},children:"— no recorded run yet"})}),I.jsx("div",{style:ase,children:"Flows"}),I.jsx("div",{style:{fontSize:11,color:"var(--archik-fg-dim)"},children:(f.flows??[]).join(", ")||"—"})]})]})}function iQn(f){return f.split("/").pop()?.replace(/\.archik\.seq\.yaml$/,"")??f}function fI({title:f,children:d}){return I.jsxs("section",{style:{marginBottom:24},children:[I.jsx("h2",{style:{fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",margin:"0 0 8px"},children:f}),d]})}function u7e({children:f,tone:d}){return I.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:d==="error"?"var(--archik-danger)":"var(--archik-fg-muted)",fontSize:13,padding:24,textAlign:"center"},children:f})}const C7e={fontSize:10,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--archik-fg-muted)",fontWeight:600},ase={...C7e,fontSize:10,paddingTop:1},sH={margin:0,paddingLeft:18,fontSize:13,lineHeight:1.55},xbn=document.getElementById("root");if(!xbn)throw new Error("#root not found");const rk=new URLSearchParams(window.location.search),MI=window.location.pathname,rQn=MI==="/__archik/seq"||MI.startsWith("/__archik/seq/"),cQn=MI==="/__archik/trace-page"||MI.startsWith("/__archik/trace-page/"),sQn=MI==="/__archik/usecases"||MI.startsWith("/__archik/usecases/"),hse=vBn.createRoot(xbn);if(rQn){const f=rk.get("path")??"",d=rk.get("from-uc"),p=rk.get("from-file")??rk.get("from"),m=d?{type:"usecase",value:d}:p?{type:"file",value:p}:null;hse.render(I.jsx(Fn.StrictMode,{children:I.jsx(DYn,{path:f,back:m})}))}else if(cQn){const f=rk.get("path")??"",d=rk.get("from-uc"),p=rk.get("from-file")??rk.get("from"),m=d?{type:"usecase",value:d}:p?{type:"file",value:p}:null;hse.render(I.jsx(Fn.StrictMode,{children:I.jsx(JYn,{path:f,back:m})}))}else if(sQn){const f=rk.get("uc");hse.render(I.jsx(Fn.StrictMode,{children:I.jsx(VYn,{selectedId:f})}))}else hse.render(I.jsx(Fn.StrictMode,{children:I.jsx(iYn,{})}));
|
package/dist/ui/index.html
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
}
|
|
15
15
|
} catch {}
|
|
16
16
|
</script>
|
|
17
|
-
<script type="module" crossorigin src="/assets/index-
|
|
17
|
+
<script type="module" crossorigin src="/assets/index-C1kLj8Cy.js"></script>
|
|
18
18
|
<link rel="stylesheet" crossorigin href="/assets/index-BrvxaIkh.css">
|
|
19
19
|
</head>
|
|
20
20
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "archik",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.5",
|
|
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",
|