import{a}from"./chunk-DLPEQYKV.mjs";import"./chunk-LVPDR3D2.mjs";import{c as H}from"./chunk-RIT5WMHA.mjs";import{b as R}from"./chunk-O53OUY2B.mjs";import"./chunk-JD45QQDD.mjs";import{a as b}from"./chunk-ICS3PEIS.mjs";import"./chunk-SIWBT4LK.mjs";import{a as w}from"./chunk-CAOKJGEV.mjs";import{h as V,j as y}from"./chunk-QPV2G662.mjs";import{a as j}from"./chunk-AUIVUOKV.mjs";import{a as h,b as l,e as p,f as C,g as o,h as e}from"./chunk-IFUYCFBO.mjs";import{a as B}from"./chunk-3PFH3U2T.mjs";import"./chunk-76CZ6Z7T.mjs";import{execSync as P}from"child_process";import F from"fs/promises";e.mock("node:child_process");e.mock("node:fs/promises");e.mock("./file-parser");e.mock("./file-serializer");e.mock("./merger");e.mock("./normalizer");e.mock("./utils");e.mock("./conflict-helper");e.mock("./logger");var k=e.mocked(P),v=e.mocked(F),s=e.mocked(j),f=e.mocked(B),n=e.mocked(H),g=e.mocked(R),d=e.mocked(y),c=e.mocked(V),W=e.mocked(w),S=e.mocked(b);h("resolveConflicts",()=>{let u={info:e.fn(),debug:e.fn(),warn:e.fn(),error:e.fn(),flush:e.fn()};p(()=>{e.clearAllMocks(),S.mockResolvedValue(u),g.mockResolvedValue({debug:!1,customStrategies:{}}),c.mockResolvedValue([])}),C(()=>{e.clearAllMocks()}),l("processes files without conflicts successfully",async()=>{let t={defaultStrategy:"ours"},i={filePath:"test.json",content:"content"},r={theirs:{a:1},ours:{a:2},format:"json"},m={a:2};c.mockResolvedValue([i]),s.mockResolvedValue(r),n.mockResolvedValue(m),f.mockResolvedValue('{"a":2}'),d.mockResolvedValue("backup/test.json"),await a(t),o(g).toHaveBeenCalledWith(t),o(c).toHaveBeenCalled(),o(s).toHaveBeenCalledWith("content",{filename:"test.json"}),o(n).toHaveBeenCalledWith({ours:{a:2},theirs:{a:1},base:void 0,filePath:"test.json",conflicts:[],path:"",ctx:o.objectContaining({config:o.any(Object),strategies:{},_strategyCache:o.any(Map)})}),o(d).toHaveBeenCalledWith("test.json",void 0),o(f).toHaveBeenCalledWith("json",m),o(v.writeFile).toHaveBeenCalledWith("test.json",'{"a":2}',"utf8"),o(k).toHaveBeenCalledWith("git add test.json"),o(u.flush).toHaveBeenCalled()}),l("handles files with conflicts",async()=>{let t={writeConflictSidecar:!0},i=[{path:"a",reason:"test conflict"}],r="conflict content";c.mockResolvedValue([{filePath:"test.json",content:"content"}]),s.mockResolvedValue({theirs:{},ours:{},format:"json"}),n.mockImplementation(({conflicts:m})=>(m.push(...i),Promise.resolve({}))),W.mockResolvedValue(r),await a(t),o(W).toHaveBeenCalledWith({},{},{},"json"),o(v.writeFile).toHaveBeenCalledWith("test.json",r,"utf8"),o(v.writeFile).toHaveBeenCalledWith("test.json.conflict.json",JSON.stringify(i,null,2)),o(k).not.toHaveBeenCalled()}),l("handles git staging errors gracefully",async()=>{c.mockResolvedValue([{filePath:"test.json",content:"content"}]),s.mockResolvedValue({theirs:{},ours:{},format:"json"}),n.mockResolvedValue({}),f.mockResolvedValue("{}"),k.mockImplementation(()=>{throw new Error("git error")}),await a({}),o(u.warn).toHaveBeenCalledWith("test.json","Failed to stage file: Error: git error")}),l("enables debug logging when configured",async()=>{let t={debug:!0};g.mockResolvedValue({debug:!0,customStrategies:{}}),c.mockResolvedValue([{filePath:"test.json",content:"content"}]),s.mockResolvedValue({theirs:{},ours:{},format:"json"}),n.mockResolvedValue({}),await a(t)}),l("processes multiple files concurrently",async()=>{let t=[{filePath:"file1.json",content:"content1"},{filePath:"file2.json",content:"content2"}];c.mockResolvedValue(t),s.mockResolvedValue({theirs:{},ours:{},format:"json"}),n.mockResolvedValue({}),f.mockResolvedValue("{}"),await a({}),o(s).toHaveBeenCalledTimes(2),o(n).toHaveBeenCalledTimes(2),o(d).toHaveBeenCalledTimes(2)}),l("uses custom backup directory",async()=>{let t={backupDir:"custom-backup"};c.mockResolvedValue([{filePath:"test.json",content:"content"}]),s.mockResolvedValue({theirs:{},ours:{},format:"json"}),n.mockResolvedValue({}),await a(t),o(d).toHaveBeenCalledWith("test.json","custom-backup")})});
