import a from"child_process";import{e as i}from"./index-B8MOUWcP.mjs";import{i as s}from"./AsyncSqlite-8sGv3lfc.mjs";import{BUILD_DIR_PATH as c}from"./constants-DED7MIJj.mjs";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"4.2.860"}}catch{}})();try{(function(){var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5917c278-2a86-4459-9205-dd43c769fff0",e._sentryDebugIdIdentifier="sentry-dbid-5917c278-2a86-4459-9205-dd43c769fff0")})()}catch{}const r=c+"/ContactsServer";async function d(e){s&&console.time("macos contacts server exec");const{stdout:t}=await i(r,[e]);if(s&&console.timeEnd("macos contacts server exec"),!t.startsWith("{"))throw logger.error("contacts server non-json response",t),Error("contacts server non-json response");s&&console.time("macos contacts server parse");const o=JSON.parse(t);return s&&console.timeEnd("macos contacts server parse"),{data:o,size:t.length}}const p=async()=>{const e=n=>typeof n!="object"||n==null||!("identifier"in n)?!1:(Object.assign(n,{id:n.identifier}),"id"in n),t=n=>typeof n.data=="object"&&n.data!=null&&"response"in n.data&&Array.isArray(n.data.response)&&n.data.response.every(e),o=await d("fetch-all");if(!t(o))throw new Error("ContactsServer returned malformed data when trying to fetch all contacts");return o};function y(e){const t=a.spawn(r,["listen"]);t.stdout.on("data",o=>{o.toString().includes("contacts_changed")&&e()}),t.on("error",o=>{logger.error("ContactsServer.listenForContactsChanges -> cp.error",o),globalThis.Sentry.captureException(o)})}export{p as f,y as l};
//# sourceMappingURL=macos-contacts-server-ClUNd65v.mjs.map
