kakao-map-components
Version:
Web Components for using kakao map api
768 lines (767 loc) • 28.6 kB
JavaScript
const pt = "__kakao-maps-components__";
var ut = /* @__PURE__ */ ((r) => (r[r.INITIALIZED = 0] = "INITIALIZED", r[r.LOADING = 1] = "LOADING", r[r.SUCCESS = 2] = "SUCCESS", r[r.FAILURE = 3] = "FAILURE", r))(ut || {});
const ft = `${pt}_Loader`, l = class l {
constructor({
appkey: t,
id: e = ft,
libraries: s = [],
nonce: i,
retries: o = 3,
url: n = "//dapi.kakao.com/v2/maps/sdk.js"
}) {
if (this.callbacks = [], this.done = !1, this.loading = !1, this.errors = [], this.id = e, this.appkey = t, this.libraries = s, this.nonce = i, this.retries = o, this.url = n, l.instance && !l.equalOptions(this.options, l.instance.options) && !l.equalOptions(this.options, l.instance.options))
switch (l.instance.status) {
case 3:
throw new Error(
`Loader must not be called again with different options.
${JSON.stringify(
this.options,
null,
2
)}
!==
${JSON.stringify(l.instance.options, null, 2)}`
);
default:
l.instance.reset(), l.instance = this;
break;
}
return l.instance || (l.instance = this), l.instance;
}
get options() {
return {
appkey: this.appkey,
id: this.id,
libraries: this.libraries,
nonce: this.nonce,
retries: this.retries,
url: this.url
};
}
static addLoadEventLisnter(t) {
return window.kakao && window.kakao.maps && window.kakao.maps.load(t), l.loadEventCallback.add(t), t;
}
static removeLoadEventLisnter(t) {
return l.loadEventCallback.delete(t);
}
load() {
return new Promise((t, e) => {
this.loadCallback((s) => {
s ? e(s) : t(window.kakao);
});
});
}
get status() {
return this.onEvent ? 3 : this.done ? 2 : this.loading ? 1 : 0;
}
get failed() {
return this.done && !this.loading && this.errors.length >= this.retries + 1;
}
loadCallback(t) {
this.callbacks.push(t), this.execute();
}
resetIfRetryingFailed() {
this.failed && this.reset();
}
reset() {
this.deleteScript(), this.done = !0, this.loading = !1, this.errors = [], this.onEvent = void 0;
}
execute() {
if (this.resetIfRetryingFailed(), this.done)
this.callback();
else {
if (window.kakao && window.kakao.maps) {
console.warn(
"Kakao Maps이 이미 외부 요소에 의해 로딩되어 있습니다.설정한 옵션과 일치 하지 않을 수 있으며, 이에 따른 예상치 동작이 발생할 수 있습니다."
), window.kakao.maps.load(this.callback);
return;
}
this.loading || (this.loading = !0, this.setScript());
}
}
setScript() {
document.getElementById(this.id) && this.callback();
const t = this.createUrl(), e = document.createElement("script");
e.id = this.id, e.type = "text/javascript", e.src = t, e.onerror = this.loadErrorCallback.bind(this), e.onload = this.callback.bind(this), e.defer = !0, e.async = !0, this.nonce && (e.nonce = this.nonce), document.head.appendChild(e);
}
loadErrorCallback(t) {
if (this.errors.push(t), this.errors.length <= this.retries) {
const e = this.errors.length * 2 ** this.errors.length;
console.log(`Failed to load Kakao Maps script, retrying in ${e} ms.`), setTimeout(() => {
this.deleteScript(), this.setScript();
}, e);
} else
this.done = !0, this.loading = !1, this.onEvent = this.errors[this.errors.length - 1], this.callbacks.forEach((e) => {
e(this.onEvent);
}), this.callbacks = [], l.loadEventCallback.forEach((e) => {
e(this.onEvent);
});
}
createUrl() {
let t = this.url;
return t += `?appkey=${this.appkey}`, this.libraries.length && (t += `&libraries=${this.libraries.join(",")}`), t += "&autoload=false", t;
}
deleteScript() {
const t = document.getElementById(this.id);
t && t.remove();
}
callback() {
kakao.maps.load(() => {
l.instance.done = !0, l.instance.loading = !1, l.instance.callbacks.forEach((t) => {
t(l.instance.onEvent);
}), l.instance.callbacks = [], l.loadEventCallback.forEach((t) => {
t(l.instance.onEvent);
});
});
}
static equalOptions(t, e) {
if (t.appkey !== e.appkey || t.id !== e.id || t.libraries.length !== e.libraries.length) return !1;
for (let s = 0; s < t.libraries.length; ++s)
if (t.libraries[s] !== e.libraries[s]) return !1;
return !(t.nonce !== e.nonce || t.retries !== e.retries || t.url !== e.url);
}
};
l.loadEventCallback = /* @__PURE__ */ new Set();
let F = l;
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const M = globalThis, W = M.ShadowRoot && (M.ShadyCSS === void 0 || M.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, ot = Symbol(), Z = /* @__PURE__ */ new WeakMap();
let $t = class {
constructor(t, e, s) {
if (this._$cssResult$ = !0, s !== ot) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
this.cssText = t, this.t = e;
}
get styleSheet() {
let t = this.o;
const e = this.t;
if (W && t === void 0) {
const s = e !== void 0 && e.length === 1;
s && (t = Z.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), s && Z.set(e, t));
}
return t;
}
toString() {
return this.cssText;
}
};
const gt = (r) => new $t(typeof r == "string" ? r : r + "", void 0, ot), _t = (r, t) => {
if (W) r.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
else for (const e of t) {
const s = document.createElement("style"), i = M.litNonce;
i !== void 0 && s.setAttribute("nonce", i), s.textContent = e.cssText, r.appendChild(s);
}
}, G = W ? (r) => r : (r) => r instanceof CSSStyleSheet ? ((t) => {
let e = "";
for (const s of t.cssRules) e += s.cssText;
return gt(e);
})(r) : r;
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const { is: mt, defineProperty: yt, getOwnPropertyDescriptor: At, getOwnPropertyNames: vt, getOwnPropertySymbols: Et, getPrototypeOf: bt } = Object, _ = globalThis, Q = _.trustedTypes, St = Q ? Q.emptyScript : "", L = _.reactiveElementPolyfillSupport, k = (r, t) => r, R = { toAttribute(r, t) {
switch (t) {
case Boolean:
r = r ? St : null;
break;
case Object:
case Array:
r = r == null ? r : JSON.stringify(r);
}
return r;
}, fromAttribute(r, t) {
let e = r;
switch (t) {
case Boolean:
e = r !== null;
break;
case Number:
e = r === null ? null : Number(r);
break;
case Object:
case Array:
try {
e = JSON.parse(r);
} catch {
e = null;
}
}
return e;
} }, V = (r, t) => !mt(r, t), X = { attribute: !0, type: String, converter: R, reflect: !1, hasChanged: V };
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), _.litPropertyMetadata ?? (_.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
class E extends HTMLElement {
static addInitializer(t) {
this._$Ei(), (this.l ?? (this.l = [])).push(t);
}
static get observedAttributes() {
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
}
static createProperty(t, e = X) {
if (e.state && (e.attribute = !1), this._$Ei(), this.elementProperties.set(t, e), !e.noAccessor) {
const s = Symbol(), i = this.getPropertyDescriptor(t, s, e);
i !== void 0 && yt(this.prototype, t, i);
}
}
static getPropertyDescriptor(t, e, s) {
const { get: i, set: o } = At(this.prototype, t) ?? { get() {
return this[e];
}, set(n) {
this[e] = n;
} };
return { get() {
return i == null ? void 0 : i.call(this);
}, set(n) {
const h = i == null ? void 0 : i.call(this);
o.call(this, n), this.requestUpdate(t, h, s);
}, configurable: !0, enumerable: !0 };
}
static getPropertyOptions(t) {
return this.elementProperties.get(t) ?? X;
}
static _$Ei() {
if (this.hasOwnProperty(k("elementProperties"))) return;
const t = bt(this);
t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
}
static finalize() {
if (this.hasOwnProperty(k("finalized"))) return;
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(k("properties"))) {
const e = this.properties, s = [...vt(e), ...Et(e)];
for (const i of s) this.createProperty(i, e[i]);
}
const t = this[Symbol.metadata];
if (t !== null) {
const e = litPropertyMetadata.get(t);
if (e !== void 0) for (const [s, i] of e) this.elementProperties.set(s, i);
}
this._$Eh = /* @__PURE__ */ new Map();
for (const [e, s] of this.elementProperties) {
const i = this._$Eu(e, s);
i !== void 0 && this._$Eh.set(i, e);
}
this.elementStyles = this.finalizeStyles(this.styles);
}
static finalizeStyles(t) {
const e = [];
if (Array.isArray(t)) {
const s = new Set(t.flat(1 / 0).reverse());
for (const i of s) e.unshift(G(i));
} else t !== void 0 && e.push(G(t));
return e;
}
static _$Eu(t, e) {
const s = e.attribute;
return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0;
}
constructor() {
super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
}
_$Ev() {
var t;
this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this));
}
addController(t) {
var e;
(this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t));
}
removeController(t) {
var e;
(e = this._$EO) == null || e.delete(t);
}
_$E_() {
const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
for (const s of e.keys()) this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]);
t.size > 0 && (this._$Ep = t);
}
createRenderRoot() {
const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
return _t(t, this.constructor.elementStyles), t;
}
connectedCallback() {
var t;
this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((e) => {
var s;
return (s = e.hostConnected) == null ? void 0 : s.call(e);
});
}
enableUpdating(t) {
}
disconnectedCallback() {
var t;
(t = this._$EO) == null || t.forEach((e) => {
var s;
return (s = e.hostDisconnected) == null ? void 0 : s.call(e);
});
}
attributeChangedCallback(t, e, s) {
this._$AK(t, s);
}
_$EC(t, e) {
var o;
const s = this.constructor.elementProperties.get(t), i = this.constructor._$Eu(t, s);
if (i !== void 0 && s.reflect === !0) {
const n = (((o = s.converter) == null ? void 0 : o.toAttribute) !== void 0 ? s.converter : R).toAttribute(e, s.type);
this._$Em = t, n == null ? this.removeAttribute(i) : this.setAttribute(i, n), this._$Em = null;
}
}
_$AK(t, e) {
var o;
const s = this.constructor, i = s._$Eh.get(t);
if (i !== void 0 && this._$Em !== i) {
const n = s.getPropertyOptions(i), h = typeof n.converter == "function" ? { fromAttribute: n.converter } : ((o = n.converter) == null ? void 0 : o.fromAttribute) !== void 0 ? n.converter : R;
this._$Em = i, this[i] = h.fromAttribute(e, n.type), this._$Em = null;
}
}
requestUpdate(t, e, s) {
if (t !== void 0) {
if (s ?? (s = this.constructor.getPropertyOptions(t)), !(s.hasChanged ?? V)(this[t], e)) return;
this.P(t, e, s);
}
this.isUpdatePending === !1 && (this._$ES = this._$ET());
}
P(t, e, s) {
this._$AL.has(t) || this._$AL.set(t, e), s.reflect === !0 && this._$Em !== t && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(t);
}
async _$ET() {
this.isUpdatePending = !0;
try {
await this._$ES;
} catch (e) {
Promise.reject(e);
}
const t = this.scheduleUpdate();
return t != null && await t, !this.isUpdatePending;
}
scheduleUpdate() {
return this.performUpdate();
}
performUpdate() {
var s;
if (!this.isUpdatePending) return;
if (!this.hasUpdated) {
if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
for (const [o, n] of this._$Ep) this[o] = n;
this._$Ep = void 0;
}
const i = this.constructor.elementProperties;
if (i.size > 0) for (const [o, n] of i) n.wrapped !== !0 || this._$AL.has(o) || this[o] === void 0 || this.P(o, this[o], n);
}
let t = !1;
const e = this._$AL;
try {
t = this.shouldUpdate(e), t ? (this.willUpdate(e), (s = this._$EO) == null || s.forEach((i) => {
var o;
return (o = i.hostUpdate) == null ? void 0 : o.call(i);
}), this.update(e)) : this._$EU();
} catch (i) {
throw t = !1, this._$EU(), i;
}
t && this._$AE(e);
}
willUpdate(t) {
}
_$AE(t) {
var e;
(e = this._$EO) == null || e.forEach((s) => {
var i;
return (i = s.hostUpdated) == null ? void 0 : i.call(s);
}), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
}
_$EU() {
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
}
get updateComplete() {
return this.getUpdateComplete();
}
getUpdateComplete() {
return this._$ES;
}
shouldUpdate(t) {
return !0;
}
update(t) {
this._$Ej && (this._$Ej = this._$Ej.forEach((e) => this._$EC(e, this[e]))), this._$EU();
}
updated(t) {
}
firstUpdated(t) {
}
}
E.elementStyles = [], E.shadowRootOptions = { mode: "open" }, E[k("elementProperties")] = /* @__PURE__ */ new Map(), E[k("finalized")] = /* @__PURE__ */ new Map(), L == null || L({ ReactiveElement: E }), (_.reactiveElementVersions ?? (_.reactiveElementVersions = [])).push("2.0.4");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const C = globalThis, I = C.trustedTypes, Y = I ? I.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, at = "$lit$", g = `lit$${Math.random().toFixed(9).slice(2)}$`, ht = "?" + g, wt = `<${ht}>`, v = document, U = () => v.createComment(""), O = (r) => r === null || typeof r != "object" && typeof r != "function", K = Array.isArray, kt = (r) => K(r) || typeof (r == null ? void 0 : r[Symbol.iterator]) == "function", j = `[
\f\r]`, w = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, tt = /-->/g, et = />/g, y = RegExp(`>|${j}(?:([^\\s"'>=/]+)(${j}*=${j}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`, "g"), st = /'/g, it = /"/g, lt = /^(?:script|style|textarea|title)$/i, Ct = (r) => (t, ...e) => ({ _$litType$: r, strings: t, values: e }), z = Ct(1), b = Symbol.for("lit-noChange"), p = Symbol.for("lit-nothing"), rt = /* @__PURE__ */ new WeakMap(), A = v.createTreeWalker(v, 129);
function ct(r, t) {
if (!K(r) || !r.hasOwnProperty("raw")) throw Error("invalid template strings array");
return Y !== void 0 ? Y.createHTML(t) : t;
}
const Pt = (r, t) => {
const e = r.length - 1, s = [];
let i, o = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", n = w;
for (let h = 0; h < e; h++) {
const a = r[h];
let d, u, c = -1, f = 0;
for (; f < a.length && (n.lastIndex = f, u = n.exec(a), u !== null); ) f = n.lastIndex, n === w ? u[1] === "!--" ? n = tt : u[1] !== void 0 ? n = et : u[2] !== void 0 ? (lt.test(u[2]) && (i = RegExp("</" + u[2], "g")), n = y) : u[3] !== void 0 && (n = y) : n === y ? u[0] === ">" ? (n = i ?? w, c = -1) : u[1] === void 0 ? c = -2 : (c = n.lastIndex - u[2].length, d = u[1], n = u[3] === void 0 ? y : u[3] === '"' ? it : st) : n === it || n === st ? n = y : n === tt || n === et ? n = w : (n = y, i = void 0);
const $ = n === y && r[h + 1].startsWith("/>") ? " " : "";
o += n === w ? a + wt : c >= 0 ? (s.push(d), a.slice(0, c) + at + a.slice(c) + g + $) : a + g + (c === -2 ? h : $);
}
return [ct(r, o + (r[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), s];
};
class x {
constructor({ strings: t, _$litType$: e }, s) {
let i;
this.parts = [];
let o = 0, n = 0;
const h = t.length - 1, a = this.parts, [d, u] = Pt(t, e);
if (this.el = x.createElement(d, s), A.currentNode = this.el.content, e === 2 || e === 3) {
const c = this.el.content.firstChild;
c.replaceWith(...c.childNodes);
}
for (; (i = A.nextNode()) !== null && a.length < h; ) {
if (i.nodeType === 1) {
if (i.hasAttributes()) for (const c of i.getAttributeNames()) if (c.endsWith(at)) {
const f = u[n++], $ = i.getAttribute(c).split(g), H = /([.?@])?(.*)/.exec(f);
a.push({ type: 1, index: o, name: H[2], strings: $, ctor: H[1] === "." ? Ot : H[1] === "?" ? xt : H[1] === "@" ? Tt : D }), i.removeAttribute(c);
} else c.startsWith(g) && (a.push({ type: 6, index: o }), i.removeAttribute(c));
if (lt.test(i.tagName)) {
const c = i.textContent.split(g), f = c.length - 1;
if (f > 0) {
i.textContent = I ? I.emptyScript : "";
for (let $ = 0; $ < f; $++) i.append(c[$], U()), A.nextNode(), a.push({ type: 2, index: ++o });
i.append(c[f], U());
}
}
} else if (i.nodeType === 8) if (i.data === ht) a.push({ type: 2, index: o });
else {
let c = -1;
for (; (c = i.data.indexOf(g, c + 1)) !== -1; ) a.push({ type: 7, index: o }), c += g.length - 1;
}
o++;
}
}
static createElement(t, e) {
const s = v.createElement("template");
return s.innerHTML = t, s;
}
}
function S(r, t, e = r, s) {
var n, h;
if (t === b) return t;
let i = s !== void 0 ? (n = e._$Co) == null ? void 0 : n[s] : e._$Cl;
const o = O(t) ? void 0 : t._$litDirective$;
return (i == null ? void 0 : i.constructor) !== o && ((h = i == null ? void 0 : i._$AO) == null || h.call(i, !1), o === void 0 ? i = void 0 : (i = new o(r), i._$AT(r, e, s)), s !== void 0 ? (e._$Co ?? (e._$Co = []))[s] = i : e._$Cl = i), i !== void 0 && (t = S(r, i._$AS(r, t.values), i, s)), t;
}
class Ut {
constructor(t, e) {
this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
}
get parentNode() {
return this._$AM.parentNode;
}
get _$AU() {
return this._$AM._$AU;
}
u(t) {
const { el: { content: e }, parts: s } = this._$AD, i = ((t == null ? void 0 : t.creationScope) ?? v).importNode(e, !0);
A.currentNode = i;
let o = A.nextNode(), n = 0, h = 0, a = s[0];
for (; a !== void 0; ) {
if (n === a.index) {
let d;
a.type === 2 ? d = new T(o, o.nextSibling, this, t) : a.type === 1 ? d = new a.ctor(o, a.name, a.strings, this, t) : a.type === 6 && (d = new Nt(o, this, t)), this._$AV.push(d), a = s[++h];
}
n !== (a == null ? void 0 : a.index) && (o = A.nextNode(), n++);
}
return A.currentNode = v, i;
}
p(t) {
let e = 0;
for (const s of this._$AV) s !== void 0 && (s.strings !== void 0 ? (s._$AI(t, s, e), e += s.strings.length - 2) : s._$AI(t[e])), e++;
}
}
class T {
get _$AU() {
var t;
return ((t = this._$AM) == null ? void 0 : t._$AU) ?? this._$Cv;
}
constructor(t, e, s, i) {
this.type = 2, this._$AH = p, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = s, this.options = i, this._$Cv = (i == null ? void 0 : i.isConnected) ?? !0;
}
get parentNode() {
let t = this._$AA.parentNode;
const e = this._$AM;
return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t;
}
get startNode() {
return this._$AA;
}
get endNode() {
return this._$AB;
}
_$AI(t, e = this) {
t = S(this, t, e), O(t) ? t === p || t == null || t === "" ? (this._$AH !== p && this._$AR(), this._$AH = p) : t !== this._$AH && t !== b && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : kt(t) ? this.k(t) : this._(t);
}
O(t) {
return this._$AA.parentNode.insertBefore(t, this._$AB);
}
T(t) {
this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
}
_(t) {
this._$AH !== p && O(this._$AH) ? this._$AA.nextSibling.data = t : this.T(v.createTextNode(t)), this._$AH = t;
}
$(t) {
var o;
const { values: e, _$litType$: s } = t, i = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = x.createElement(ct(s.h, s.h[0]), this.options)), s);
if (((o = this._$AH) == null ? void 0 : o._$AD) === i) this._$AH.p(e);
else {
const n = new Ut(i, this), h = n.u(this.options);
n.p(e), this.T(h), this._$AH = n;
}
}
_$AC(t) {
let e = rt.get(t.strings);
return e === void 0 && rt.set(t.strings, e = new x(t)), e;
}
k(t) {
K(this._$AH) || (this._$AH = [], this._$AR());
const e = this._$AH;
let s, i = 0;
for (const o of t) i === e.length ? e.push(s = new T(this.O(U()), this.O(U()), this, this.options)) : s = e[i], s._$AI(o), i++;
i < e.length && (this._$AR(s && s._$AB.nextSibling, i), e.length = i);
}
_$AR(t = this._$AA.nextSibling, e) {
var s;
for ((s = this._$AP) == null ? void 0 : s.call(this, !1, !0, e); t && t !== this._$AB; ) {
const i = t.nextSibling;
t.remove(), t = i;
}
}
setConnected(t) {
var e;
this._$AM === void 0 && (this._$Cv = t, (e = this._$AP) == null || e.call(this, t));
}
}
class D {
get tagName() {
return this.element.tagName;
}
get _$AU() {
return this._$AM._$AU;
}
constructor(t, e, s, i, o) {
this.type = 1, this._$AH = p, this._$AN = void 0, this.element = t, this.name = e, this._$AM = i, this.options = o, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = p;
}
_$AI(t, e = this, s, i) {
const o = this.strings;
let n = !1;
if (o === void 0) t = S(this, t, e, 0), n = !O(t) || t !== this._$AH && t !== b, n && (this._$AH = t);
else {
const h = t;
let a, d;
for (t = o[0], a = 0; a < o.length - 1; a++) d = S(this, h[s + a], e, a), d === b && (d = this._$AH[a]), n || (n = !O(d) || d !== this._$AH[a]), d === p ? t = p : t !== p && (t += (d ?? "") + o[a + 1]), this._$AH[a] = d;
}
n && !i && this.j(t);
}
j(t) {
t === p ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
}
}
class Ot extends D {
constructor() {
super(...arguments), this.type = 3;
}
j(t) {
this.element[this.name] = t === p ? void 0 : t;
}
}
class xt extends D {
constructor() {
super(...arguments), this.type = 4;
}
j(t) {
this.element.toggleAttribute(this.name, !!t && t !== p);
}
}
class Tt extends D {
constructor(t, e, s, i, o) {
super(t, e, s, i, o), this.type = 5;
}
_$AI(t, e = this) {
if ((t = S(this, t, e, 0) ?? p) === b) return;
const s = this._$AH, i = t === p && s !== p || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, o = t !== p && (s === p || i);
i && this.element.removeEventListener(this.name, this, s), o && this.element.addEventListener(this.name, this, t), this._$AH = t;
}
handleEvent(t) {
var e;
typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, t) : this._$AH.handleEvent(t);
}
}
class Nt {
constructor(t, e, s) {
this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = s;
}
get _$AU() {
return this._$AM._$AU;
}
_$AI(t) {
S(this, t);
}
}
const B = C.litHtmlPolyfillSupport;
B == null || B(x, T), (C.litHtmlVersions ?? (C.litHtmlVersions = [])).push("3.2.1");
const Ht = (r, t, e) => {
const s = (e == null ? void 0 : e.renderBefore) ?? t;
let i = s._$litPart$;
if (i === void 0) {
const o = (e == null ? void 0 : e.renderBefore) ?? null;
s._$litPart$ = i = new T(t.insertBefore(U(), o), o, void 0, e ?? {});
}
return i._$AI(r), i;
};
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
let P = class extends E {
constructor() {
super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
}
createRenderRoot() {
var e;
const t = super.createRenderRoot();
return (e = this.renderOptions).renderBefore ?? (e.renderBefore = t.firstChild), t;
}
update(t) {
const e = this.render();
this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = Ht(e, this.renderRoot, this.renderOptions);
}
connectedCallback() {
var t;
super.connectedCallback(), (t = this._$Do) == null || t.setConnected(!0);
}
disconnectedCallback() {
var t;
super.disconnectedCallback(), (t = this._$Do) == null || t.setConnected(!1);
}
render() {
return b;
}
};
var nt;
P._$litElement$ = !0, P.finalized = !0, (nt = globalThis.litElementHydrateSupport) == null || nt.call(globalThis, { LitElement: P });
const q = globalThis.litElementPolyfillSupport;
q == null || q({ LitElement: P });
(globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.1.1");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const Mt = (r) => (t, e) => {
e !== void 0 ? e.addInitializer(() => {
customElements.define(r, t);
}) : customElements.define(r, t);
};
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const Rt = { attribute: !0, type: String, converter: R, reflect: !1, hasChanged: V }, It = (r = Rt, t, e) => {
const { kind: s, metadata: i } = e;
let o = globalThis.litPropertyMetadata.get(i);
if (o === void 0 && globalThis.litPropertyMetadata.set(i, o = /* @__PURE__ */ new Map()), o.set(e.name, r), s === "accessor") {
const { name: n } = e;
return { set(h) {
const a = t.get.call(this);
t.set.call(this, h), this.requestUpdate(n, a, r);
}, init(h) {
return h !== void 0 && this.P(n, void 0, r), h;
} };
}
if (s === "setter") {
const { name: n } = e;
return function(h) {
const a = this[n];
t.call(this, h), this.requestUpdate(n, a, r);
};
}
throw Error("Unsupported decorator location: " + s);
};
function J(r) {
return (t, e) => typeof e == "object" ? It(r, t, e) : ((s, i, o) => {
const n = i.hasOwnProperty(o);
return i.constructor.createProperty(o, n ? { ...s, wrapped: !0 } : s), n ? Object.getOwnPropertyDescriptor(i, o) : void 0;
})(r, t, e);
}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
function dt(r) {
return J({ ...r, state: !0, attribute: !1 });
}
var Dt = Object.defineProperty, Lt = Object.getOwnPropertyDescriptor, N = (r, t, e, s) => {
for (var i = s > 1 ? void 0 : s ? Lt(t, e) : t, o = r.length - 1, n; o >= 0; o--)
(n = r[o]) && (i = (s ? n(t, e, i) : n(i)) || i);
return s && i && Dt(t, e, i), i;
};
let m = class extends P {
constructor() {
super(...arguments), this.options = {
appkey: ""
}, this.loading = !0;
}
connectedCallback() {
super.connectedCallback(), m.instance ? console.warn(
"Found multiple instances of this element on the same page. The Kakao Maps JavaScript API can only be configured once. Please ensure you only have a single instance."
) : m.instance = this;
}
willUpdate(r) {
super.willUpdate(r), r.has("appkey") && this.appkey && (this.options.appkey = this.appkey);
}
updated(r) {
super.updated(r), r.has("options") && this.options && new F({
...this.options
}).load().then(() => {
this.loading = !1;
}).catch((t) => {
this.error = t;
}), r.has("loading") && !this.loading && this.dispatchEvent(new CustomEvent("kakao-api-loaded")), r.has("error") && this.error && this.dispatchEvent(new CustomEvent("kakao-api-error", { detail: this.error }));
}
render() {
return this.loading ? this.error ? z`<slot name="error"></slot>` : z`<slot name="loading"></slot>` : z`<slot></slot>`;
}
};
N([
J({ type: String })
], m.prototype, "appkey", 2);
N([
J({ type: Object })
], m.prototype, "options", 2);
N([
dt()
], m.prototype, "loading", 2);
N([
dt()
], m.prototype, "error", 2);
m = N([
Mt("kakao-api-loader")
], m);
export {
m as KakaoApiLoader,
F as Loader,
ut as LoaderStatus
};