import{a as d}from"./chunk-JD45QQDD.mjs";import{a as S,c as r,d as g,e as x,f as C}from"./chunk-QPV2G662.mjs";var R=t=>{switch(t){case r:return"OK";case g:return"CONTINUE";case x:return"FAIL";case C:return"SKIP";default:return`UNKNOWN(${t})`}},T=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),A={ours:({ours:t})=>({status:r,value:t}),theirs:({theirs:t})=>({status:r,value:t}),base:({base:t})=>({status:r,value:t}),drop:t=>({status:r,value:S}),skip:({path:t})=>({status:C,reason:`Skip strategy applied at ${t}`}),"non-empty":({ours:t,theirs:e,base:n})=>t!=null&&t!==""?{status:r,value:t}:e!=null&&e!==""?{status:r,value:e}:n!=null&&n!==""?{status:r,value:n}:{status:g},update:({ours:t,theirs:e})=>t!==void 0?{status:r,value:e}:{status:r,value:S},merge:async t=>{let{ours:e,theirs:n,base:s,path:y,filePath:a,ctx:i,conflicts:u}=t;if(T(e)&&T(n)){let f=new Set([...Object.keys(e),...Object.keys(n)]),l={};for(let o of f)l[o]=await w({ours:e[o],theirs:n[o],base:T(s)?s[o]:void 0,path:y?`${y}.${o}`:o,filePath:a,ctx:i,conflicts:u});return{status:r,value:l}}return{status:g,reason:"Unmergeable type"}},concat:({ours:t,theirs:e,path:n})=>Array.isArray(t)&&Array.isArray(e)?{status:r,value:[...t,...e]}:{status:g,reason:`Cannot concat at ${n}`},unique:({ours:t,theirs:e,path:n})=>Array.isArray(t)&&Array.isArray(e)?{status:r,value:[...new Set([...t,...e])]}:{status:g,reason:`Cannot concat at ${n}`}},w=async({ours:t,theirs:e,base:n,path:s,filePath:y,ctx:a,conflicts:i})=>{var f;if(t===e)return t;a._strategyCache||(a._strategyCache=new Map);let u=a._strategyCache.get(s);u||(u=d(s,a.config),a._strategyCache.set(s,u));for(let l of u){let o=(f=A[l])!=null?f:a.strategies[l];if(!o)continue;let c=await o({ours:t,theirs:e,base:n,path:s,filePath:y,ctx:a,conflicts:i});switch(c.status){case r:return c.value;case g:continue;case C:i.push({path:s,reason:c.reason});return;case x:throw i.push({path:s,reason:c.reason}),new Error(`Merge failed at ${s}: ${c.reason}`)}}i.push({path:s,reason:`All strategies failed (tried: ${u.join(", ")||"none"})`,...a.config.debug?{ours:t,theirs:e,base:n}:{}})};export{R as a,A as b,w as c};
