export function createDetailedError(e,s,t){return{code:e,message:s,hint:t?.hint,suggested_action:t?.suggested_action,field:t?.field,docs:t?.docs,severity:t?.severity}}export function formatErrorForUser(e){const s=[e.message];return e.field&&s.push("Field: "+e.field),e.hint&&s.push("Hint: "+e.hint),e.docs&&s.push("Docs: "+e.docs),s.join("\n")}export function formatErrorForLog(e){const s=["["+e.code+"] "+e.message];return e.field&&s.push("field="+e.field),e.hint&&s.push('hint="'+e.hint+'"'),e.docs&&s.push("docs="+e.docs),s.join(" | ")}export function isACIError(e){if("object"!=typeof e||null===e)return!1;const s=e;return!("string"!=typeof s.code||"string"!=typeof s.message||void 0!==s.hint&&"string"!=typeof s.hint||void 0!==s.field&&"string"!=typeof s.field||void 0!==s.docs&&"string"!=typeof s.docs)}export function toACIError(e){return isACIError(e)?e:e instanceof Error?{code:"INTERNAL_ERROR",message:e.message,hint:"An unexpected error occurred"}:{code:"UNKNOWN_ERROR",message:String(e),hint:"An unexpected error occurred"}}export function formatErrorStructured(e){const s=["Error: "+e.message,"Code: "+e.code];e.severity&&s.push("Severity: "+e.severity),e.field&&s.push("Field: "+e.field),e.hint&&s.push("Hint: "+e.hint),e.suggested_action&&s.push("Action: "+e.suggested_action),e.docs&&s.push("Docs: "+e.docs);const t=s.join("\n"),o=["error",e.code,e.message];if(e.severity&&o.push("severity="+e.severity),e.field&&o.push("field="+e.field),e.hint){const s=e.hint.replace(/"/g,'\\"');o.push('hint="'+s+'"')}if(e.suggested_action){const s=e.suggested_action.replace(/"/g,'\\"');o.push('action="'+s+'"')}e.docs&&o.push("docs="+e.docs);const i=o.join(" | "),r={code:e.code,message:e.message};e.severity&&(r.severity=e.severity),e.field&&(r.field=e.field),e.hint&&(r.hint=e.hint),e.suggested_action&&(r.suggested_action=e.suggested_action),e.docs&&(r.docs=e.docs);const n=JSON.stringify(r),c=["**Error:** "+e.message,"**Code:** `"+e.code+"`"];e.severity&&c.push("**Severity:** "+e.severity),e.field&&c.push("**Field:** `"+e.field+"`"),e.hint&&c.push("**Hint:** "+e.hint),e.suggested_action&&c.push("**Action:** "+e.suggested_action),e.docs&&c.push("**Docs:** ["+e.docs+"]("+e.docs+")");const d=c.join("\n\n");return{...e,formats:{multiline:t,singleline:i,json:n,markdown:d}}}export const ERROR_DETAILS={};