;ELC   
;;; Compiled
;;; in Emacs version 29.4
;;; with all optimizations.



(byte-code "\300\301!\210\300\302!\207" [require eudc executable] 2)#@51 See `eudc-protocol-attributes-translation-alist'.
(defvar eudc-macos-contacts-attributes-translation-alist '((name . last_name) (firstname . first_name) (email . email) (phone . phone) (title . job_title) (o . organization) (ou . department)) (#$ . 152))#@42 See `eudc-macos-contacts-search-helper'.
(defconst eudc-macos-contacts--unsearchable-attributes '(email phone) (#$ . 412))
(byte-code "\300\301\302\303#\210\300\304\305\303#\210\300\306\307\303#\210\300\310\305\303#\207" [eudc-protocol-set eudc-query-function eudc-macos-contacts-query-internal macos-contacts eudc-list-attributes-function nil eudc-protocol-attributes-translation-alist eudc-macos-contacts-attributes-translation-alist eudc-protocol-has-default-query-attributes] 4)#@729 Helper function to query the Contacts app via AppleScript.
Searches for all persons matching QUERY.  QUERY is a list of cons
cells (ATTR . VALUE) where ATTRs should be valid macOS Contacts
attribute names with space characters replaced by `_' characters.
Thus, to for instance search for the "first name" attribute in
the Contacts app, the corresponding ATTR would be the symbol
`first_name'.

Note that due to the way the Contacts app exposes its data via
AppleScript, the attributes listed in
`eudc-macos-contacts--unsearchable-attributes' can not be searched
efficiently.  If and when one of these attributes appears in
QUERY, it is thus skipped, and the query is composed from the
other attributes in the QUERY.

(fn QUERY)
(defalias 'eudc-macos-contacts-search-helper #[257 "\302\303 \211\203Q \211@\304\305\306\307@!#A\310@\"\203# @	>\2030 \311\312\313\314\"P!\266\202J \302V\203; \315P\262\313\316#P\262T\262\266A\266\202\202 \210\211\317\230?\205p \320\321!\203m \322\321\323\324\323\325\313\326\"&\207\311\327!\207" [eudc-macos-contacts-attributes-translation-alist eudc-macos-contacts--unsearchable-attributes 0 string string-replace "_" " " symbol-name rassq message "[eudc] Warning in macOS Contacts backend: can not search in attribute " format "\"%s\"; skipping it." " and " "(%s contains \"%s\")" "" executable-find "osascript" call-process nil t "-e" "\non joinLines(theText)\n        if (theText is missing value) or (theText is \"\") then\n                return \"\"\n        else\n                set thePars to paragraphs of theText\n                set result to {}\n                repeat with para in thePars\n                        set result to result & {para & space}\n                end repeat\n                return text 1 thru -2 of (result as text)\n        end if\nend joinLines\n\non run\n        set results to {}\n        tell application \"Address Book\"\n                set pList to every person whose %s\n                repeat with pers in pList\n                        set pText to ¬\n                                first name of pers & \":\" & ¬\n                                last name of pers & \":\"\n                        if (job title of pers is not missing value) then ¬\n                                set pText to pText ¬\n                                        & my joinLines(job title of pers)\n                        set pText to pText & \":\"\n                        if (department of pers is not missing value) then ¬\n                                set pText to pText ¬\n                                        & my joinLines(department of pers)\n                        set pText to pText & \":\"\n                        if (organization of pers is not missing value) then ¬\n                                set pText to pText ¬\n                                        & my joinLines(organization of pers)\n                        set pText to pText & \":\"\n                        if (count emails of pers) > 0 then\n                                repeat with emailAddr in emails of pers\n                                        set pText to pText & value ¬\n                                                of emailAddr & \",\"\n                                end repeat\n                                set pText to text 1 thru -2 of pText\n                        end if\n                        set pText to pText & \":\"\n                        if (count phones of pers) > 0 then\n                                repeat with phoneNmbr in phones of pers\n                                        set pText to pText & value ¬\n                                                of phoneNmbr & \",\"\n                                end repeat\n                                set pText to text 1 thru -2 of pText\n                        end if\n                        set results to results & {pText & \"\n\"}\n                end repeat\n                get results as text\n        end tell\nend run\n" "[eudc] Error in macOS Contacts backend: `osascript' executable not found. Is this is a macOS 10.0 or later system?"] 12 (#$ . 901)])#@270 Query macOS Contacts with QUERY.
QUERY is a list of cons cells (ATTR . VALUE) where ATTRs should be valid
macOS Contacts attribute names.
RETURN-ATTRS is a list of attributes to return, defaulting to
`eudc-default-return-attributes'.

(fn QUERY &optional RETURN-ATTRS)
(defalias 'eudc-macos-contacts-query-internal #[513 "\300\301!\302rq\210\303 \210\304!\210\305ed\"\210eb\210m\204\207 \306 \307 \232\204\201 \310\302\311`\307 {\312\"\211\203q \211@\211A\262\242\313\230\204i \211\314>\203b \311\315\"\211\203] \211@BB\262A\266\202\202H \266\202j \211BB\262\210A\266\202\202, \210\316\317\"\204 \211\237B\262\266\302y\210\202 )\207" [get-buffer-create " *macOS Contacts*" nil erase-buffer eudc-macos-contacts-search-helper delete-duplicate-lines line-beginning-position line-end-position (first_name last_name job_title department organization email phone) split-string ":" "" (phone email) "," length= 0] 13 (#$ . 5057)])#@210 Set the EUDC server to macOS Contacts app.
The server in DUMMY is not actually used, since this backend
always and implicitly connects to an instance of the Contacts app
running on the local host.

(fn DUMMY)
(defalias 'eudc-macos-contacts-set-server #[257 "\300\301\"\210\302\303!\207" [eudc-set-server macos-contacts message "[eudc] macOS Contacts app server selected"] 4 (#$ . 6010) nil])
(byte-code "\300\301!\210\302\303!\207" [eudc-register-protocol macos-contacts provide eudcb-macos-contacts] 2)
