;; ported-from: src/text.ts @ v1.2.0
;;
;; The kit's own user-facing strings, with an injection seam for app locales.
;;
;; Every chip/toast string lives in the EN table below, keyed under social.*
;; Apps that localize pass their `t` through the components' opts; anything the
;; app's catalog doesn't cover (or an app that passes nothing) falls back to
;; the EN text here, so the kit renders sensibly on its own. The SocialTextKey
;; string-literal union in types/text.d.ts is GENERATED from this file
;; (scripts/gen-text-dts.mjs) so app catalogs can declare their block as
;; Record<SocialTextKey, …> and let tsc catch drift after a kit bump.
(ns ardegazu.social.text)
(def ^:private EN
(js-obj
"social.sheet.title" "invite a friend here"
"social.sheet.here-now" "here now · {app}"
"social.sheet.drop" "will find it in their drop"
"social.sheet.invite" "invite"
"social.sheet.sent" "sent ✓"
"social.sheet.parked" "parked ✓"
"social.sheet.share" "share the room link"
"social.sheet.nofriends" "no friends saved yet — anyone with the link can join"
"social.sheet.hub" "find friends on ardegazu.ro"
"social.home.title" "back to the hub — ardegazu.ro"
"social.chip.join" "friends can join"
"social.chip.join.title" "while on, friends on ardegazu.ro see a join button for this room"
"social.chip.invite" "🫶 invite a friend"
"social.chip.invite.title" "seal an invite for this room to a friend — live or into their drop"
"social.toast.invites-you" "{name} invites you"
"social.toast.join" "join"
"social.toast.share" "share"
"social.toast.copy" "⎘ copy link"
"social.toast.not-now" "not now"
"social.toast.copied" "copied ✓"
"social.toast.come-to" "come to {app}"
"social.toast.come-play" "come play"
"social.invite.join" "come join me in {app}"
"social.paste.chip" "🎟 got an invite?"
"social.paste.chip.title" "paste an invite link — this window joins the room (works installed)"
"social.paste.placeholder" "paste the invite link…"
"social.paste.join" "join"
"social.paste.error" "that's not an invite — paste the whole link"))
(def ^:private fill-re (js/RegExp. "\\{(\\w+)\\}" "g"))
(defn- fill [template vars]
(if ^boolean (js* "!!(~{})" vars)
(.replace template fill-re
(fn [m k]
(if ^boolean (js-in k vars)
(js* "String(~{})" (unchecked-get vars k))
m)))
template))
(defn en-text
"The built-in EN text — also what senders put on the wire as the legacy
invite label, which must stay English-stable for old receivers."
[key vars]
(fill (unchecked-get EN key) vars))
(defn mk-t
"Wrap an optional app translator with the EN fallback."
[user-t]
(fn [key vars]
(let [s (when ^boolean (js* "!!(~{})" user-t) (user-t key vars))]
(if (and (string? s)
(not (identical? s ""))
(not (identical? s key)))
s
(en-text key vars)))))